# Leo Oracle Call Update

Status: v9.10.1024 source integration and call-settings improvements complete; no service restarted and no live call made.
Owner explicitly approved sharing call context, relevant memories and tool results
with Groq, and requested temporary editable drafts as the caller's visible thinking.

## Implemented Locally

`[internal module]`:

- Read configuration before evaluating voice model and tuning constants.
- Start Leo's pickup after 150 ms; default generated-greeting budget is 1200 ms.
  The local fallback can greet the caller by the authenticated display name.
  Explicit environment settings still override defaults.
- Default Leo speech endpoint is 700 ms. Existing noise/sustained-speech gates remain.
- Bound buffered microphone audio to ten seconds, including during slow replies.
- Drain speech buffered during a prior turn; serialize typed turns and suppress
  stale replies after newer input or hangup.
- Abort speech requests on interruption/hangup; give transcription an eight-second
  timeout and cancel it on hangup.
- Synthesize Orpheus one piece ahead of playback, preserving the 200-character cap.
  Default retry count drops from three to one; each piece has a twelve-second
  total request/retry budget. No new voice provider or voice switching is introduced.
- Stop logging the private values removed by the privacy scrubber.

The configured expressive voice is Orpheus, model `canopylabs/orpheus-v1-english`.
Its existing API supports vocal directions and a 200-character input limit:
https://console.groq.com/docs/text-to-speech/orpheus

## Connected In Source

`[internal module]` now connects through
`leo-call-runtime.mjs` to Leo's Oracle call session. It replaces the two-model
fast/IPC race for Leo. `LEO_CALL_AGENT=0` explicitly restores the legacy path.

It provides isolated per-call history, up to eight bounded tool-result records,
source URLs, lookup-result recall, caller-aware greetings, tool allowlists,
sequential tool/result/reply processing, a turn deadline, cancellation, and honest
unconfirmed-action responses. Guest calls cannot dispatch the owner delegation
or local-document tools. Raw filesystem/shell tools are never exposed by this draft.

The production connection reuses the current Groq chat endpoint
`https://api.groq.com/openai/v1/chat/completions` and configured models/key. It
sends the caller's identity/context, recent conversation, bounded prior
memories and retrieved tool results to that provider. This can include private
information in conversation, memory, project documents, or tool output.

The original approval block is resolved by the owner's explicit approval.
Account-scoped memory is filtered by exact ID, never by a matching username.
Submitted exchanges persist in the caller's private Oracle voice transcript channel.
Shared room calls receive no individual caller's private memory or owner-only tools.

Tool results now carry source links into the call UI; Orpheus receives vocal
directions while captions omit those controls. The existing Google search adapter
returns actual source URLs and supports a caller cancellation/deadline signal.
Hands-free long-form narration is not supplied by this change.
Tool timeouts stop waiting; they cannot undo an action already accepted downstream.

## Call Settings And Devices (v9.10.1024)

The settings button is restored. The speaker button opens output/volume settings
instead of unpredictably cycling devices or volume modes. The selected microphone
and output reflect the live devices; unsupported output routing is disabled.
Playback volume works on AI audio and human-call playback. Failed AI microphone
swaps retain the working capture, mute survives device changes, and obsolete
permission/socket callbacks cannot revive a prior call. Camera/screen inputs are
disabled unless the server advertises support. Short-screen controls no longer
move when the text box loses focus. Device labels are rendered as text, not HTML.

## Shared Thinking Drafts

Leo's call overlay now has a text box and a per-call, default-off
"Share my thinking with Leo" checkbox. It uses the authenticated voice WebSocket;
there is no new HTTP route and no broadcast to other callers.

- Client updates wait for 1000 ms of quiet and are capped at one nonempty update per
  five seconds. Duplicate text and unfinished IME composition are not transmitted.
  Clear/opt-out messages bypass the cap to discard shared text promptly.
- Preparation waits another 900 ms and runs no more than once per five seconds.
- Draft preparation has tools disabled and does not access saved memory or persist
  unsent text. It uses the current draft and up to four recent committed call messages.
- A short provisional interpretation can be reused only if the sent text matches
  the prepared draft. The final submitted wording remains authoritative.
- Send, deletion, disabling sharing, or hangup clears the draft. Idle drafts expire
  after two minutes; reconnect starts a fresh temporary draft context.
- A submitted message is the only path that answers, uses tools, and records a turn.
- Like call messages, an opted-in draft goes to Groq. Clearing it removes local
  draft state; it cannot retract a request already sent to the provider.

This is temporary language interpretation, not a new mathematical learning rule.
Whether it improves real conversational latency/understanding still needs a live test.

## Verification

30 offline tests pass across `groq-call-lifecycle.test.mjs`,
`leo-call-agent.test.mjs`, `leo-call-runtime.test.mjs`, `call-draft.test.mjs`,
and `call-device.test.mjs`.
They cover provider failover, draft behavior, delayed replies, typed-turn ordering,
speech buffered during thinking, bounded continuous audio, transcription/synthesis
cancellation, bounded TTS prefetch, caller separation, guest tool denial,
tool-result grounding, source recall, and unconfirmed action timeouts.

JavaScript syntax checks passed. Tests used fake providers and synthetic audio;
they did not load real credentials, use the microphone, spend provider credits,
start GPU jobs, or restart KAI. Real latency, accent, emotional delivery and live
tool completion have not been verified. Deployment is still pending: the Oracle
dashboard needs to reload its call modules, and clients need the updated scripts.
No Rust rebuild or KAI engine restart is needed for these Leo changes.

The offline browser test passes at 390x844, 320x568, 1280x800 and 844x390 and checks
opt-in draft sharing, Send/clear, control reachability and minimized-call behavior.
Screenshots are under `reports/leo-call-ui/`. It uses the existing Chromium runtime
with network requests and GPU disabled. Edge failed to launch; Chromium passed.

The changed production code and package version diff pass whitespace checks.
The wider Codex diff still reports unrelated existing trailing whitespace;
those sections were left unchanged.
