Skip to content
11 changes: 11 additions & 0 deletions .changeset/selectable-dictation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@schlessera/brain-ui-server": minor
"@schlessera/brain-ui-sdk": minor
"@schlessera/brain-ui-react": minor
---

Register multiple dictation providers, discover their destinations and capabilities,
and persist an owner-controlled default with revision checks. Bind session minting
and saved-audio uploads to the explicitly disclosed provider, and reject retries
that change a receipt's provider. Preserve bodyless clients and legacy by-value
registration while exposing additive protocol types and client helpers.
10 changes: 8 additions & 2 deletions api-report/ui-react.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ signatures (every public export and the types it is made of)
success: boolean;
}>;
checkWorkerHost: () => Promise<WorkerHostStatus>;
dictationSettings: () => Promise<DictationSettings>;
fileResolve: (path: string) => Promise<{
ancestors: string[];
exists: boolean;
Expand Down Expand Up @@ -1228,6 +1229,7 @@ signatures (every public export and the types it is made of)
timeZone: null | string;
}>;
refreshModels: () => Promise<ModelCatalogResponse>;
saveDictationSettings: (settings: DictationSettings) => Promise<DictationSettings>;
sessionRecovery: (sessionId: string, opts?: {
signal?: AbortSignal;
}) => Promise<SessionRecoveryResult>;
Expand Down Expand Up @@ -1333,7 +1335,8 @@ signatures (every public export and the types it is made of)
voiceOverrides: (signal?: AbortSignal) => Promise<{
overrides: PronunciationOverride[];
}>;
voiceSession: (signal?: AbortSignal) => Promise<VoiceSessionResponse>;
voiceProviders: () => Promise<VoiceProvidersResponse>;
voiceSession: (signal?: AbortSignal, selection?: VoiceSessionRequest) => Promise<VoiceSessionResponse>;
voiceToken: () => Promise<VoiceTokenResponse>;
vpnCheck: () => Promise<{
vpn: boolean;
Expand Down Expand Up @@ -1601,6 +1604,7 @@ signatures (every public export and the types it is made of)
success: boolean;
}>;
checkWorkerHost: () => Promise<import("@schlessera/brain-ui-sdk").WorkerHostStatus>;
dictationSettings: () => Promise<import("@schlessera/brain-ui-sdk").DictationSettings>;
fileResolve: (path: string) => Promise<{
ancestors: string[];
exists: boolean;
Expand Down Expand Up @@ -1722,6 +1726,7 @@ signatures (every public export and the types it is made of)
timeZone: null | string;
}>;
refreshModels: () => Promise<import("@schlessera/brain-ui-sdk").ModelCatalogResponse>;
saveDictationSettings: (settings: import("@schlessera/brain-ui-sdk").DictationSettings) => Promise<import("@schlessera/brain-ui-sdk").DictationSettings>;
sessionRecovery: (sessionId: string, opts?: {
signal?: AbortSignal;
}) => Promise<import("@schlessera/brain-ui-sdk").SessionRecoveryResult>;
Expand Down Expand Up @@ -1827,7 +1832,8 @@ signatures (every public export and the types it is made of)
voiceOverrides: (signal?: AbortSignal) => Promise<{
overrides: import("@schlessera/brain-ui-sdk").PronunciationOverride[];
}>;
voiceSession: (signal?: AbortSignal) => Promise<import("@schlessera/brain-ui-sdk").VoiceSessionResponse>;
voiceProviders: () => Promise<import("@schlessera/brain-ui-sdk").VoiceProvidersResponse>;
voiceSession: (signal?: AbortSignal, selection?: import("@schlessera/brain-ui-sdk").VoiceSessionRequest) => Promise<import("@schlessera/brain-ui-sdk").VoiceSessionResponse>;
voiceToken: () => Promise<import("@schlessera/brain-ui-sdk").VoiceTokenResponse>;
vpnCheck: () => Promise<{
vpn: boolean;
Expand Down
45 changes: 45 additions & 0 deletions api-report/ui-sdk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export "." (./src/index.ts)
type DialogueEvidence
type DialoguePage
type DialogueRecord
type DictationSettings
type Draft
type DraftAttachment
type DraftAttachmentResponse
Expand Down Expand Up @@ -468,6 +469,8 @@ export "." (./src/index.ts)
type VoiceCapabilitiesResponse
type VoiceKeytermsResponse
type VoiceMode
type VoiceProvidersResponse
type VoiceSessionRequest
type VoiceSessionResponse
type VoiceTokenResponse
type WikilinkMapResponse
Expand Down Expand Up @@ -742,6 +745,7 @@ export "./client" (./src/client/index.ts)
type DialogueEvidence
type DialoguePage
type DialogueRecord
type DictationSettings
type Draft
type DraftAttachment
type DraftAttachmentResponse
Expand Down Expand Up @@ -1133,6 +1137,8 @@ export "./client" (./src/client/index.ts)
type VoiceCapabilitiesResponse
type VoiceKeytermsResponse
type VoiceMode
type VoiceProvidersResponse
type VoiceSessionRequest
type VoiceSessionResponse
type VoiceTokenResponse
type WebSocketClose
Expand Down Expand Up @@ -1602,6 +1608,7 @@ export "./protocol" (./src/protocol.ts)
type DialogueEvidence
type DialoguePage
type DialogueRecord
type DictationSettings
type Draft
type DraftAttachment
type DraftAttachmentResponse
Expand Down Expand Up @@ -1896,6 +1903,8 @@ export "./protocol" (./src/protocol.ts)
type VoiceCapabilitiesResponse
type VoiceKeytermsResponse
type VoiceMode
type VoiceProvidersResponse
type VoiceSessionRequest
type VoiceSessionResponse
type VoiceTokenResponse
type WikilinkMapResponse
Expand Down Expand Up @@ -2408,6 +2417,7 @@ export "./server" (./src/server/index.ts)
type DialogueEvidence
type DialoguePage
type DialogueRecord
type DictationSettings
type Draft
type DraftAttachment
type DraftAttachmentResponse
Expand Down Expand Up @@ -2845,6 +2855,8 @@ export "./server" (./src/server/index.ts)
type VoiceCapabilitiesResponse
type VoiceKeytermsResponse
type VoiceMode
type VoiceProvidersResponse
type VoiceSessionRequest
type VoiceSessionResponse
type VoiceTokenResponse
type WebSearchBrief
Expand Down Expand Up @@ -7297,6 +7309,12 @@ signatures (every public export and the types it is made of)
identity: string;
evidence: DialogueEvidence;
}
DictationSettings (packages/ui-sdk/src/protocol.ts)
export interface DictationSettings {
defaultProvider: string | null;
smart: boolean;
revision: string;
}
Draft (packages/ui-sdk/src/protocol.ts)
export interface Draft {
draftId: string;
Expand Down Expand Up @@ -11391,13 +11409,17 @@ signatures (every public export and the types it is made of)
keyterms: boolean;
endpointing: boolean;
savedAudio?: boolean;
smartTranscription?: boolean;
}
SpeechProvider (packages/ui-sdk/src/server/speech.ts)
export interface SpeechProvider {
id: string;
label?: string;
destination?: string;
capabilities: SpeechCapabilities;
createSession(opts: {
keyterms: string[];
mode?: "smart" | "verbatim";
}): Promise<SpeechSession>;
transcribeRecording?(input: {
audio: Uint8Array;
Expand Down Expand Up @@ -12444,6 +12466,29 @@ signatures (every public export and the types it is made of)
}
VoiceMode (packages/ui-sdk/src/protocol.ts)
export type VoiceMode = "idle" | "dictate" | "conversation";
VoiceProvidersResponse (packages/ui-sdk/src/protocol.ts)
export interface VoiceProvidersResponse {
providers: Array<{
id: string;
label: string;
destination?: string;
capabilities: SpeechCapabilities;
}>;
dictation: {
saved: string | null;
savedUsable: boolean;
host: string | null;
effective: string | null;
source: "saved" | "host" | "only" | "none" | "unavailable";
smart: boolean;
revision: string;
};
}
VoiceSessionRequest (packages/ui-sdk/src/protocol.ts)
export interface VoiceSessionRequest {
providerId?: string;
smart?: boolean;
}
VoiceSessionResponse (packages/ui-sdk/src/protocol.ts)
export interface VoiceSessionResponse {
providerId: string;
Expand Down
2 changes: 2 additions & 0 deletions api-report/ui-server.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ signatures (every public export and the types it is made of)
dbPath?: string;
renderer?: AppRenderer;
speechProvider?: SpeechProvider;
speechProviders?: SpeechProvider[];
defaultSpeechProviderId?: string;
conversationProvider?: LiveConversationProvider;
labeller?: LabellerOptions;
turnTimeoutMs?: number;
Expand Down
27 changes: 16 additions & 11 deletions docs/decisions/dictation-speech.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,26 @@ or bypass the host's permission and turn machinery.
`createApp({ speechProvider })` supplies an implementation by value. It wins
over automatic Deepgram discovery. An explicit `config.voice.provider` must
match its id; a mismatch fails instead of choosing either implementation
(`pickSpeechProvider`, `packages/ui-server/src/voice/speech-providers.ts:127-155`).
(`createSpeechProviderRegistry`, `packages/ui-server/src/voice/speech-providers.ts:174-242`).
Without the value, existing selection remains: explicit built-ins, automatic
Deepgram only when its key is present, otherwise failure. Browser speech is an
explicit opt-in; it never becomes a fallback after a missing key or provider
failure.

Provider validation and session validation happen inside the mounted session
route's existing error boundary. A provider id is nonempty, trimmed and
Legacy configuration errors stay inside the mounted session route's existing
error boundary: an invalid by-value `speechProvider`, a `VOICE_PROVIDER` that
mismatches it, or a `VOICE_PROVIDER` naming an unregistered provider still lets
the server start and answers the voice routes with the existing 500 `{ error }`.
Only misuse of the additive #3707 options (`speechProviders` together with
`speechProvider`, an invalid or duplicate list entry, an unregistered
`defaultSpeechProviderId`) fails construction. A provider id is nonempty, trimmed and
lowercase, matching environment resolution. All four capabilities are boolean;
`createSession` is callable. Sessions carry a string URL, finite nonnegative
expiry and optional string token/string-record params. Empty URL and zero
expiry remain valid for browser/local implementations. Unknown configuration,
mismatch, invalid implementations/results and minting failures return the
existing 500 `{ error }` envelope. Authentication and the deprecated
Deepgram-specific token route keep their existing meanings.
expiry remain valid for browser/local implementations. Invalid session results
and legacy minting failures retain the existing 500 `{ error }` envelope.
Authentication and the deprecated Deepgram-specific token route keep their
existing meanings.

Keyterms are built only for a provider declaring support. The route snapshots
identity/capabilities before minting; the matching client receives the minted
Expand Down Expand Up @@ -124,10 +129,10 @@ path through the brain server under these rulings: recognition of playback via
a live track remains a browser path, and on-device recognition is outside the
baseline. Thus Deepgram is the only built-in saved-audio implementation;
external providers may omit the optional method on the existing seam
(`transcribeRecording?`, `packages/ui-sdk/src/server/speech.ts:38-43`).
(`transcribeRecording?`, `packages/ui-sdk/src/server/speech.ts:40-45`).
The server derives the advertised capability from that method, rather than
trusting a flag disconnected from its executor
(`speechCapabilities`, `packages/ui-server/src/voice/speech-providers.ts:180-182`).
(`speechCapabilities`, `packages/ui-server/src/voice/speech-providers.ts:153-155`).
An absent capability keeps playback, typing and retention available, with the
tray's explicit unavailable explanation.

Expand Down Expand Up @@ -168,13 +173,13 @@ transient/capacity rejection: provider errors, rate limits and definitive
provider timeouts. Unknown outcomes stay terminal. Audio/media, parameter,
validation and authentication failures do not offer Retry. Classification and
attempt counts belong to the receipt, not an automatic client retry loop
(`transcriptionFailure`, `packages/ui-server/src/routes/transcriptions.ts:21-36`).
(`transcriptionFailure`, `packages/ui-server/src/routes/transcriptions.ts:22-37`).
This qualified rule supersedes an unqualified promise of one call even after
an explicit retry. Plain repeats and uncertain outcomes never redispatch.

The upload budget is **10,041,155 bytes**, a derived policy value rather than a
duration check (`MAX_TRANSCRIPTION_BYTES`,
`packages/ui-server/src/routes/transcriptions.ts:14-18`). The
`packages/ui-server/src/routes/transcriptions.ts:15-19`). The
[October 8 bitrate finding](https://github.com/schlessera/brain-kit/issues/1021#issuecomment-6055498109)
reran the V1 probe's track-ended case three times per desktop engine, with
Chromium 153.0.8010.12 and Firefox 155.0 in Playwright 1.63.0's Ubuntu 24.04.4
Expand Down
27 changes: 23 additions & 4 deletions docs/extending/speech.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,29 @@ A supplied value takes precedence over automatic Deepgram key detection. If
`config.voice.provider` is set (including by `VOICE_PROVIDER`), it must equal
the supplied id. Ids are nonempty, trimmed and lowercase. Without a value,
`deepgram`/`webspeech` keep their existing selection rules; absent credentials
never select browser speech. A mismatch or provider failure returns 500
`{ error }` from the existing protected `POST /api/voice/session`, without
trying another service. Validation occurs on that request, before calling an
invalid provider or publishing an invalid session.
never select browser speech. A mismatch, an invalid legacy value, session
validation and provider failures return 500 `{ error }` from the protected
`POST /api/voice/session`, without trying another service.

To offer several services, pass `createApp({ speechProviders: [first, second],
defaultSpeechProviderId: first.id })`. The list adds to configured built-ins;
duplicate ids (including built-in collisions), supplying both registration options,
and an unregistered `defaultSpeechProviderId` fail construction. Browser speech remains opt-in.
The legacy single value replaces built-ins. A saved dictation choice overrides
the host default; a removed saved choice blocks dictation until explicitly changed.
Registration snapshots metadata, capabilities and bound methods; changing a supplied
object afterward does not alter the registered set or running operations.

Optional `label` and `destination` describe the service to users. Keep credentials
out of both. Declare `smartTranscription: true` only if `createSession` honors
`mode: "smart" | "verbatim"`; the server passes mode only for that capability.
The saved switch starts true. Existing implementations need no new fields.
Use `voiceProviders()` for discovery (no mint), then send the disclosed id in
`voiceSession(signal, { providerId, smart })`. Saved recordings send
`Speech-Provider` with the confirmed id; a retry must retain the receipt's provider.
See the [HTTP specification](../http-api.md#selectable-dictation-providers) for
settings revisions, exact selection errors and the no-fallback rule. Gemini's
built-in factory is implemented separately in #3708; no placeholder is registered.

The four streaming capabilities are boolean. Optional `savedAudio` is derived from a callable `transcribeRecording`; a contradictory explicit declaration is rejected. `streaming` describes streaming recognition,
`interimResults` controls partial display, `keyterms` controls domain-term
Expand Down
5 changes: 4 additions & 1 deletion docs/http-api-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ row's real mounting check. They do not establish mounting by themselves.
| `POST /api/status/worker-host` | `mounted supported handler: POST /api/status/worker-host` | T |
| `GET /api/voice/keyterms` | `mounted supported handler: GET /api/voice/keyterms` | N |
| `GET /api/voice/overrides` | `mounted supported handler: GET /api/voice/overrides` | N |
| `GET /api/voice/providers` | `mounted supported handler: GET /api/voice/providers` | R |
| `GET /api/voice/dictation/settings` | `mounted supported handler: GET /api/voice/dictation/settings` | R |
| `PUT /api/voice/dictation/settings` | `mounted supported handler: PUT /api/voice/dictation/settings` | R |
| `GET /api/voice/capabilities` | `mounted supported handler: GET /api/voice/capabilities` | R |
| `GET /api/voice/recordings/:recordingId/transcription` | `mounted supported handler: GET /api/voice/recordings/:recordingId/transcription` | R |
| `PUT /api/voice/recordings/:recordingId/transcription` | `mounted supported handler: PUT /api/voice/recordings/:recordingId/transcription` | R |
Expand Down Expand Up @@ -507,7 +510,7 @@ track measurements and unchanged original bytes; the composer transport creates
no inbox thread. Detailed parser/intake/containment checks live in
[track-intake.test.ts](../packages/ui-server/tests/track-intake.test.ts).

**R** — [saved-transcription.test.ts](../packages/ui-server/tests/saved-transcription.test.ts): concurrent real-route claims/retries, server hashes, body caps, account access, terminal outcomes, tombstones and keyless provider transport.
**R** — [selectable-dictation.test.ts](../packages/ui-server/tests/selectable-dictation.test.ts) covers exact provider selection, settings revisions/authority and held mint/upload binding; [saved-transcription.test.ts](../packages/ui-server/tests/saved-transcription.test.ts): concurrent real-route claims/retries, server hashes, body caps, account access, terminal outcomes, tombstones and keyless provider transport.

**RV — User history restoration.** `turn-revert.test.ts` exercises raw restoration,
Undo, partial conflicts, operation identity, authorization, original voice and
Expand Down
Loading
Loading