Skip to content

feat(voice): add the voice gateway with spoken messages and calls - #133

Merged
cheetahbyte merged 6 commits into
mainfrom
voice
Nov 10, 2026
Merged

cheetahbyte merged 6 commits into
mainfrom
voice

Conversation

@cheetahbyte

@cheetahbyte cheetahbyte commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the voice gateway: a separate process (crumble-voice) that connects telephone lines to bots. Owners set it up under Settings > Voice gateway. Bots get spoken messages, can call the owner with call_owner, and can propose calls to other people that the owner approves in the bot chat.

phone ── SIP ── crumble-voice ── voice gateway token, /v1/voice/* ── server ── bot chat
                                                                       └── call conversation (outside calls only)
  • Configuration: GET/PUT /v1/voice-gateway save the owner's numbers and lines, and /v1/voice-gateway/token issues and revokes the token. The gateway receives its lines over GET /v1/voice/events.
  • Spoken messages: these carry origin.via voice. The bot is told its reply is read aloud, and the web shows "Spoken on a call".
  • Calls the bot places to the owner: call_owner dials the owner's first number, and hang_up ends a call. Calls are tracked in the settings row voice-gateway:calls, and the server ends calls that the gateway can't account for.
  • Outside calls: request_call creates a call request, and the owner approves or declines it on a card. The call runs in its own conversation that holds only the goal, the opening and hang_up, and what the callee says never reaches the bot chat.
  • Streaming replies: GET /v1/agents/{id}/events?partial=true streams the reply while the bot writes it, so the gateway can start speaking early.
  • Web: the lines are a selectable table with Calls you and Calls others checkboxes and a short Status (Registered, Not registered, Off, Offline, Connecting, Waiting, Not saved).

Clients: crumble-project/apple#9, crumble-project/android#13, and the gateway crumble-project/voice#1.

Evidence

  • The pre-push hook passed on the pushed head: bun run check (lint, format, typecheck, OpenAPI check, tests) and the apps/docs check and build.
  • bun test apps/web/features/voice-gateway: 6 pass.
  • The redesigned lines table and its statuses were reviewed by hand in the web app. No screenshots are attached.

Risk and rollback

Reversibility: Reversible. A revert leaves the voice-gateway settings rows and the stored token hash in the database. They are new keys and nothing reads them after a revert.

Blast radius:

  • New public API under /v1/voice-gateway, /v1/voice/* and call requests.
  • New message origins (voice, call, callee, call_request), new call and callee fields on events, and the partial query.
  • Bot tools: call_owner, hang_up and request_call.
  • Clients built against the old contract ignore the new fields. A message gateway adapter can no longer use the ID voice.

Outside calls are off unless a line has callsOthers and the gateway sets call.allowOutside. The docs note that their legal situation is unsettled.

GET /v1/agents/{id}/events?partial=true fills each snapshot's partial with the reply the bot is writing. Without the parameter, partial stays empty. Adds the voice gateway to the glossary.
A voice gateway connects telephone lines to bots. It authenticates with a
scoped voice gateway token on /v1/voice/*, receives its lines and the
owner's numbers over an event stream, and is managed under Settings >
Voice gateway.

- Spoken messages carry origin via "voice" and a model-only note; the
  web shows "Spoken on a call".
- Bots with a line that may call get call_owner, and hang_up during a
  call.
- Calls are reported with a start and an end, kept in the settings row
  voice-gateway:calls, and shown as call-started and call-ended events.
  An ended call wakes the bot once; the server ends a call itself when
  the voice gateway disappears, the token changes, or the line changes.
A bot whose line has "Can call other people" proposes an outside call
with request_call: the number, the callee, the goal, and its opening.
The owner approves or declines the call request on a card in the bot
chat, and approving dials at once.

The call runs in its own call conversation, which holds only the goal,
the opening, and the call rules, and whose only tool is hang_up. What
the callee says never reaches the bot chat: the server routes the voice
gateway's messages by the call's party and answers 409 for an outside
call ID it cannot place. Call turns are left out of learning reviews
and reply notifications. When the call ends, the bot chat gets one
notice, and the model alone reads the goal and the escaped transcript.

The web chat shows an outside call as one card that opens the call
beside the chat, live while it goes on. Selecting an open job or call
card again closes its panel.
Lines are now table rows with SIP username, display name, bot, Calls you
and Calls others checkboxes, and a status column. Rows are selected with
a checkbox column; deleting selected lines replaces the per-row button.

The status names why a saved line has no registration yet (Off, Offline,
Connecting, Waiting) instead of reporting it as not saved. Long reasons
move into a hover title so the column doesn't wrap.
A call ended by issuing a new voice gateway token now reads "revoked or
replaced" in call outcomes, refusals, and ended-call notices. The
display name is described as the caller name sent to the telephone
system, and hang_up's objection flag says the transcript is withheld
from the owner rather than deleted.

The voice gateway docs, the web client page, and the glossary now match
the server: the token's reach, outside call limits, request_call, and
when Crumble ends a call.
@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 3ab1c6b.

@github-actions

Copy link
Copy Markdown

Fallow audit report

Review needed

Found 1 finding.

Health (1)
Severity Rule Location Description
minor fallow/high-crap-score apps/web/features/voice-gateway/voice-gateway.tsx:380 'savedLineState' has CRAP score 31.6 (threshold: 30.0, cyclomatic 10)

Generated by fallow.

Gate outcomes: warned audit-verdict.

}

// Describes the saved line only while the draft still names the same bot.
function savedLineState(gateway: VoiceGateway, line: DraftLine) {
@cheetahbyte
cheetahbyte merged commit 391b2a4 into main Nov 10, 2026
11 checks passed
This was referenced Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants