← Back to PRs

#20053: feat(voicewake): trigger-based routing to agent/session

by longbiaochen open 2026-02-18 13:16 View on GitHub →
docs app: macos app: web-ui gateway scripts size: L
Clean replacement for #17994 (which was auto-closed as dirty after an upstream merge).\n\nIncludes:\n- voiceWakeTrigger routing config + gateway methods\n- session/agent route resolution + validation for known agents\n- protocol model sync + tests for routing behavior\n- macOS forwarding integration and docs\n\nAlso carries the prior CI stabilization tweak in scripts/test-parallel.mjs (2 workers on macOS). <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR adds trigger-based voice wake routing, allowing different wake words to route messages to specific agents or sessions. The implementation spans the full stack: Swift wake-word detection (`WakeWordGate`, `VoiceWakeRuntime`, `VoiceWakeForwarder`), the gateway protocol and RPC layer (`voicewake.routing.get/set`), infra storage with normalization (`voicewake-routing.ts`), and the agent handler's route resolution logic. - **Routing config store**: New `VoiceWakeRoutingConfig` type with `defaultTarget` and per-trigger `routes`, persisted to `settings/voicewake-routing.json`. Normalization handles whitespace collapsing, empty-trigger filtering, and exclusive discriminant validation (`mode` vs `agentId` vs `sessionKey`). - **Agent handler integration**: When `voiceWakeTrigger` is provided and no explicit `agentId`/`replyTo`/`to` is set, the handler resolves a route from the config. Routed targets are validated against known agents, with graceful fallback + warning logs for unknown/malformed targets. - **Protocol sync**: Swift `GatewayModels` updated in both `apps/macos` and `apps/shared` (kept identical). `WakeWordGateMatch` now carries the matched trigger string through the detection → capture → forward pipeline. - **Event broadcasting**: `voicewake.routing.changed` event pushed to nodes on connect and on config updates, matching the existing `voicewake.changed` pattern. - **CI fix**: macOS CI workers bumped from 1 to 2 to reduce cross-file state leakage flakes. - **Issues found**: Missing `VoiceWakeRoutingConfig` type import in `server.impl.ts` (should cause TS compilation error), and `null` config passes the `voicewake.routing.set` validation guard due to `typeof null === "object"`. <h3>Confidence Score: 3/5</h3> - Likely safe with two issues to address: a missing type import that may break TypeScript compilation, and a null-config validation gap in the routing set handler. - The feature is well-structured with thorough tests (unit, e2e, agent handler tests), proper validation, and clean protocol sync. However, the missing VoiceWakeRoutingConfig import in server.impl.ts is a potential compilation error, and the null config validation gap could cause unexpected config resets. Both are straightforward fixes. - `src/gateway/server.impl.ts` (missing type import), `src/gateway/server-methods/voicewake-routing.ts` (null config validation) <sub>Last reviewed commit: 38a720a</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs