Navigation
ELOWEN · Documentation

Last updated: October 27, 2026

Browse documentation · voice-bot implementation
Developer reference

voice-bot implementation

The manifest declares provides.literalArgumentTools: ["VoiceCall"] because prompt is saved in the call reservation and forwarded as instructions to the voice agent. The core vault layer preserves all tool arguments without raising the coordinated core 0.30.47 floor; it does not resolve vault references in prompt, init_message or the phone number. The external service receives literal references, not vault access. Ordinary call authorization, rate limits and output/error/live-update scrubbing remain active, with no extra inference or plugin-owned substitution path. tests/voiceBotVaultArguments.test.ts verifies the real configured manifest-to-registry contribution without placing a call.

Migration entry

The manifest entry exports migrate(db: PluginDb<never>): Promise<void> beside register. The daemon loader always awaits it before registration for this reads: ['db'] plugin; the DB CLI calls the same export without registering tools, routes, timers or services. The export runs only the existing transactional plugin SQL through db.migrate. A failed step rolls back its SQL and ledger entry and prevents registration. Repeated calls skip applied versions. Runtime store construction never invokes migrations. Tests that bypass the loader explicitly await this export before using their fixture.

Error rendering

VoiceCall transport failures use errorText from elowen-plugin-shared/errors. errorText(error) retains Error.message and otherwise uses String(error); conversion failures propagate. It formats only an existing failure and does not log, retry or invent a success result. VoiceCall applies its existing token redaction after conversion. With no failure there is no error conversion.

Call audit store

Registration awaits ctx.db() and openStore(db) before registering the tool and account-removal hook, including when the endpoint is unconfigured. The asynchronous PluginDb owns the quoted "plugin_voice-bot".calls table. Migration 1 creates an identity id, a timestamptz created_at and the created-at index.

The store exposes asynchronous reserve, settle and removeUser. VoiceCall awaits ctx.currentAccountUserId() and captures the session before admission, so reserve binds the resolved account id rather than a Promise. reserve takes a transaction advisory lock keyed by the schema and .calls.rate-limit, then reads the rolling window and inserts the requested attempt on that same connection. Concurrent daemon and runner calls share the lock, including when no calls exist yet. A rejected admission returns the count and oldest timestamp without adding a row. Failed and unknown attempts count toward the hourly cap.

HTTP starts only after reservation commits, outside the database transaction. VoiceCall awaits settlement before returning the outcome, keeping a response capped at 8,000 characters. Database failures propagate and never produce a successful call result. The account-removal hook awaits deletion of the account's numbers and transcripts. Settlement after removal updates no row and does not recreate personal data. No core-table SQL or synchronous database handle is used.

Public HTTP transport

VoiceCall binds createPublicHttpFetch from elowen-plugin-shared/httpClient to () => ctx.host.publicHttp(). The host transport is acquired lazily, only after input validation and a committed call reservation. It owns public-destination validation and the pinned connection; VoiceCall has no global-fetch fallback. The shared bridge encodes the JSON body and decodes the native response without retrying or following POST redirects. The configured whole-call deadline is passed through as the request's abort signal.

A transport exception, including a connection reset or timeout after dispatch, leaves the call unknown, retains its hourly reservation, and explicitly warns against automatic redial. An interrupted successful response also stays unknown. Neither case proves that the phone did not ring. Token redaction, explicit HTTP refusals, final-result parsing, audit settlement and account removal retain their existing behavior.

Voice service contract

The configured service receives one POST per call and must keep the request open until the call ends. It should return a JSON result with:

  • answered — whether the call was picked up.
  • elapsed_seconds — the duration in seconds, when available.
  • status or result — the service's own outcome label.
  • transcript — the conversation, when available.
  • timed_out — when the service ended the call on its own time limit.
  • call_sid — the service's call identifier.

When the reply cannot be read, is not JSON, or does not say whether the call was answered, the outcome stays unknown: the call may have taken place, so Elowen reports that and shows the start of the reply instead of claiming the call went unanswered. The prompt is limited to 4,000 characters, and a stored response is cut to 8,000 characters, including the responses of failed calls.