feat(runtime): add talk mode and capture tools

This commit is contained in:
William Valentin
2026-02-16 10:17:24 -08:00
parent a9b38150c0
commit 83b8e38b11
12 changed files with 391 additions and 4 deletions
+64
View File
@@ -544,3 +544,67 @@ describe('daemon audio routing integration', () => {
expect(atts?.some(a => a.mimeType === 'image/jpeg')).toBe(true);
});
});
describe('daemon talk mode (voice wake) integration', () => {
afterEach(() => {
vi.restoreAllMocks();
});
it('ignores messages until wake phrase is used', async () => {
const processSpy = vi.spyOn(AgentOrchestrator.prototype, 'process').mockResolvedValue('ok');
const session = {
id: 'telegram:user-talk-1',
addMessage: vi.fn(),
getHistory: vi.fn(() => []),
clear: vi.fn(),
replaceHistory: vi.fn(),
getConfig: vi.fn(() => undefined),
setConfig: vi.fn(),
deleteConfig: vi.fn(),
};
const router = createMessageRouter({
sessionManager: { getSession: vi.fn(() => session) } as unknown as MessageRouterDeps['sessionManager'],
modelRouter: {
getAvailableTiers: () => ['fast', 'default', 'complex', 'local'],
getAllLabels: () => ({ fast: 'fast', default: 'default', complex: 'complex', local: 'local' }),
getLabel: (tier: string) => tier,
} as unknown as MessageRouterDeps['modelRouter'],
systemPrompt: 'test prompt',
toolRegistry: { clone() { return this; }, register: vi.fn() } as unknown as MessageRouterDeps['toolRegistry'],
toolExecutor: {} as unknown as MessageRouterDeps['toolExecutor'],
config: {
agents: {
primary_tier: 'default',
delegation: { compaction: 'fast', memory_extraction: 'fast', classification: 'fast', tool_summarisation: 'fast', complex_reasoning: 'complex' },
max_delegation_depth: 3,
max_iterations: 10,
},
compaction: { enabled: false },
models: { default: { provider: 'anthropic', model: 'claude' } },
audio: { talk_mode: { enabled: true, wake_phrase: 'hey flynn', timeout_ms: 120000, allow_manual_toggle: true } },
} as unknown as MessageRouterDeps['config'],
});
const reply = vi.fn(async (_message: OutboundMessage) => {});
await router.handler({
id: 'm-talk-1',
channel: 'telegram',
senderId: 'user-talk-1',
text: 'hello there',
timestamp: Date.now(),
} as MessageRouterInput, reply);
expect(processSpy).not.toHaveBeenCalled();
await router.handler({
id: 'm-talk-2',
channel: 'telegram',
senderId: 'user-talk-1',
text: 'hey flynn what time is it?',
timestamp: Date.now(),
} as MessageRouterInput, reply);
expect(processSpy).toHaveBeenCalledOnce();
expect(processSpy).toHaveBeenCalledWith('what time is it?', undefined);
});
});