Documentation
¶
Index ¶
- Variables
- type AssistantTextDelta
- type Context
- type ContextUpdate
- type Error
- type InterruptSource
- type Interrupted
- type MessageEnvelope
- type MessageKind
- type RTCAnswer
- type RTCOffer
- type ReasoningDelta
- type RecognitionModel
- type ServiceAuthorization
- type SessionClose
- type SessionReady
- type SessionSetup
- type SessionStatus
- type SessionUsage
- type Speaker
- type SpeechConfig
- type SpeechEnded
- type SpeechLocation
- type SpeechStarted
- type StatusResp
- type SynthesisModel
- type TokenUsage
- type ToolCall
- type ToolDeclaration
- type ToolResult
- type TranscriptDelta
- type TranscriptDraft
- type TurnCancel
- type TurnState
- type TurnStatus
- type UserMessage
- type Voice
- type VoiceChoice
- type VoiceChoiceDefault
- type VoiceChoicesResp
- type VoiceConfig
- type VoiceRTCAnswerResp
- type VoiceRTCClientDiagnostics
- type VoiceRTCConnectionState
- type VoiceRTCConnectivityIssue
- type VoiceRTCConnectivitySide
- type VoiceRTCDataChannelState
- type VoiceRTCDiagnosticsReq
- type VoiceRTCDiagnosticsResp
- type VoiceRTCICEConnectionState
- type VoiceRTCICEGatheringState
- type VoiceRTCOfferReq
- type VoiceRTCServerDiagnostics
- type VoiceRTCSignalingState
- type VoiceRTCUDPEndpoint
- type VoiceTextTicketReq
- type VoiceTextTicketResp
- type VoiceTransport
Constants ¶
This section is empty.
Variables ¶
var Routes = []apispec.Route{ {Name: "voiceChoices", Doc: "Lists available voice choices and their supported transports.", Method: "GET", Path: "/api/voicegateway/v2/voice/choices", Resp: reflect.TypeFor[VoiceChoicesResp](), Category: "Voice", HeadersArg: true}, { Category: "Voice", HeadersArg: true, Name: "voiceTextTicket", Doc: "Authorizes a browser text-session upgrade with a short-lived, single-use ticket.", Method: "POST", Path: "/api/voicegateway/v2/voice/text/ticket", Req: reflect.TypeFor[VoiceTextTicketReq](), Resp: reflect.TypeFor[VoiceTextTicketResp](), }, { Category: "Voice", HeadersArg: true, Name: "voiceRTCOffer", Doc: "Exchanges a WebRTC SDP offer for an answer, opening a voice gateway session.", Method: "POST", Path: "/api/voicegateway/v2/voice/rtc/offer", Req: reflect.TypeFor[VoiceRTCOfferReq](), Resp: reflect.TypeFor[VoiceRTCAnswerResp](), }, { Category: "Voice", HeadersArg: true, Name: "diagnoseVoiceRTC", Doc: "Returns structured WebRTC connectivity diagnostics for a voice bridge session.", Method: "POST", Path: "/api/voicegateway/v2/voice/rtc/{sessionID}/diagnostics", Req: reflect.TypeFor[VoiceRTCDiagnosticsReq](), Resp: reflect.TypeFor[VoiceRTCDiagnosticsResp](), }, { Category: "Voice", HeadersArg: true, Name: "closeVoiceRTC", Doc: "Closes a WebRTC voice bridge session.", Method: "POST", Path: "/api/voicegateway/v2/voice/rtc/{sessionID}", Resp: reflect.TypeFor[StatusResp](), }, }
Routes lists the voice gateway JSON API endpoints used by the SDK generator. It excludes the WebSocket text-session routes, GET /api/voicegateway/v2/voice/text and /api/voicegateway/v2/voice/text/browser, which carry no JSON request or response body.
Immutable
var SDKAPI = apispec.Config[voiceapi.ErrorCode]{ Routes: Routes, SDKPackagePaths: map[string]struct{}{ reflect.TypeFor[StatusResp]().PkgPath(): {}, reflect.TypeFor[voiceapi.ErrorResponse]().PkgPath(): {}, }, ExtraSeeds: []reflect.Type{ reflect.TypeFor[voiceapi.ErrorResponse](), reflect.TypeFor[MessageEnvelope](), reflect.TypeFor[SessionSetup](), reflect.TypeFor[ContextUpdate](), reflect.TypeFor[UserMessage](), reflect.TypeFor[ToolResult](), reflect.TypeFor[TurnCancel](), reflect.TypeFor[SessionClose](), reflect.TypeFor[RTCOffer](), reflect.TypeFor[RTCAnswer](), reflect.TypeFor[SessionReady](), reflect.TypeFor[SessionStatus](), reflect.TypeFor[SessionUsage](), reflect.TypeFor[TranscriptDelta](), reflect.TypeFor[TranscriptDraft](), reflect.TypeFor[AssistantTextDelta](), reflect.TypeFor[ReasoningDelta](), reflect.TypeFor[SpeechStarted](), reflect.TypeFor[SpeechEnded](), reflect.TypeFor[ToolCall](), reflect.TypeFor[TurnStatus](), reflect.TypeFor[Interrupted](), reflect.TypeFor[Error](), }, DocumentExtraSeeds: true, KotlinPackage: "com.fghbuild.voicegateway.sdk.v2", APIDocTitle: "Voice Gateway v2 API Reference", APIDocIntro: "RESTful JSON signaling API served at `/api/voicegateway/v2/voice/`.", SpecialTypes: []apispec.SpecialType{ { Type: reflect.TypeFor[json.RawMessage](), TSType: "any /* json.RawMessage */", KTType: "JsonElement", SwiftType: "JSONValue", DocType: "JSONValue", TSValidate: "%[1]s", }, { Type: reflect.TypeFor[map[string]any](), TSType: "{ [key: string]: any /* json.RawMessage */}", KTType: "Map<String, JsonElement>", SwiftType: "[String: JSONValue]", DocType: "Record<string, JSONValue>", }, }, ErrorCodes: []apispec.ErrorCodeSpec[voiceapi.ErrorCode]{ {Code: voiceapi.CodeBadRequest, Status: 400}, {Code: voiceapi.CodeVoiceBridgeUnavailable, Status: 503}, {Code: voiceapi.CodeUnauthorized, Status: 401}, {Code: voiceapi.CodeVoiceOfferFailed, Status: 500}, }, }
SDKAPI is the SDK generation specification for the voice gateway API.
Immutable
Functions ¶
This section is empty.
Types ¶
type AssistantTextDelta ¶
type AssistantTextDelta struct {
// Kind is "assistant.text.delta".
Kind MessageKind `json:"kind"`
// Text is an incremental assistant text fragment.
Text string `json:"text"`
// ResponseID is the opaque gateway-scoped response identity. Assistant
// text and its usage share this value; user text and uncorrelated providers
// omit it. Separate response IDs must not be merged into one transcript entry.
ResponseID string `json:"responseID,omitempty"`
}
AssistantTextDelta is a gateway message that streams assistant text. Each fragment appends to previously emitted text; it never replaces it.
type Context ¶
type Context struct {
// SystemInstruction is provider-neutral instruction text for the assistant.
SystemInstruction string `json:"systemInstruction,omitempty"`
// Text is additional conversational context for the session.
Text string `json:"text,omitempty"`
}
Context carries provider-neutral text or instruction context.
type ContextUpdate ¶
type ContextUpdate struct {
// Generate requests a response to this service update, without recording user speech.
Generate bool `json:"generate,omitempty"`
// Kind must be "context.update".
Kind MessageKind `json:"kind"`
// Context contains the instructions or text to append.
Context Context `json:"context"`
}
ContextUpdate is a client message that appends session context. Context is passive unless Generate explicitly requests an assistant response.
type Error ¶
type Error struct {
// Kind is "error".
Kind MessageKind `json:"kind"`
// Message is a human-readable error description.
Message string `json:"message"`
// Recoverable reports whether the client may continue using the session.
Recoverable bool `json:"recoverable"`
}
Error is a gateway message that reports an error.
type InterruptSource ¶
type InterruptSource string
InterruptSource identifies why a voice gateway turn was interrupted.
const ( // InterruptSourceUser means user speech interrupted the assistant. InterruptSourceUser InterruptSource = "user" // InterruptSourceTool means tool execution was cancelled. InterruptSourceTool InterruptSource = "tool" )
type Interrupted ¶
type Interrupted struct {
// Kind is "interrupted".
Kind MessageKind `json:"kind"`
// Source identifies what interrupted the turn.
Source InterruptSource `json:"source"`
// Message optionally provides more detail about the interruption.
Message string `json:"message,omitempty"`
}
Interrupted is a gateway message that reports an interruption.
type MessageEnvelope ¶
type MessageEnvelope struct {
// Kind is the message discriminator used to decode the concrete message type.
Kind MessageKind `json:"kind"`
}
MessageEnvelope carries the kind used to dispatch data-channel messages.
type MessageKind ¶
type MessageKind string
MessageKind identifies a voice gateway WebRTC data-channel message.
const ( // MessageKindSessionSetup starts a provider-neutral voice session. MessageKindSessionSetup MessageKind = "session.setup" // MessageKindContextUpdate sends provider-neutral text context to the session. MessageKindContextUpdate MessageKind = "context.update" // MessageKindUserMessage appends completed user text and asks the assistant to respond. MessageKindUserMessage MessageKind = "user.message" // MessageKindToolResult returns the result of a tool call. MessageKindToolResult MessageKind = "tool.result" // MessageKindTurnCancel asks the gateway to cancel the current turn. MessageKindTurnCancel MessageKind = "turn.cancel" // MessageKindSessionClose asks the gateway to close the session. MessageKindSessionClose MessageKind = "session.close" // MessageKindRTCAnswer answers the gateway's rtc.offer. MessageKindRTCAnswer MessageKind = "rtc.answer" // MessageKindSessionReady reports that the gateway session is ready. MessageKindSessionReady MessageKind = "session.ready" // MessageKindSessionStatus reports startup progress before session.ready. MessageKindSessionStatus MessageKind = "session.status" // MessageKindSessionUsage reports cumulative provider usage for this connection. MessageKindSessionUsage MessageKind = "session.usage" // MessageKindRTCOffer renegotiates the WebRTC media session. MessageKindRTCOffer MessageKind = "rtc.offer" // MessageKindTranscriptDelta streams transcript text. MessageKindTranscriptDelta MessageKind = "transcript.delta" // MessageKindTranscriptDraft replaces provisional user text, without committing it. MessageKindTranscriptDraft MessageKind = "transcript.draft" // MessageKindAssistantTextDelta streams assistant text. MessageKindAssistantTextDelta MessageKind = "assistant.text.delta" // MessageKindReasoningDelta streams provider reasoning text. MessageKindReasoningDelta MessageKind = "reasoning.delta" // MessageKindSpeechStarted reports that speech output started. MessageKindSpeechStarted MessageKind = "speech.started" // MessageKindSpeechEnded reports that speech output ended. MessageKindSpeechEnded MessageKind = "speech.ended" // MessageKindToolCall asks the client to execute a tool. MessageKindToolCall MessageKind = "tool.call" // MessageKindTurnStatus reports gateway work on the current turn. MessageKindTurnStatus MessageKind = "turn.status" // MessageKindInterrupted reports an interruption. MessageKindInterrupted MessageKind = "interrupted" // MessageKindError reports a gateway error. MessageKindError MessageKind = "error" )
type RTCAnswer ¶ added in v0.5.0
type RTCAnswer struct {
// Kind must be "rtc.answer".
Kind MessageKind `json:"kind"`
// SDP is the client's SDP answer.
SDP string `json:"sdp"`
}
RTCAnswer is a client message that answers rtc.offer.
type RTCOffer ¶ added in v0.5.0
type RTCOffer struct {
// Kind is "rtc.offer".
Kind MessageKind `json:"kind"`
// SDP is the gateway's SDP offer.
SDP string `json:"sdp"`
}
RTCOffer is a gateway message that renegotiates the WebRTC media session.
The gateway sends at most one, after session.ready, and only to a client whose session.setup set renegotiation. The client applies it as the remote description and replies with rtc.answer; until then the session keeps its current media parameters.
type ReasoningDelta ¶
type ReasoningDelta struct {
// Kind is "reasoning.delta".
Kind MessageKind `json:"kind"`
// Text is an incremental reasoning fragment.
Text string `json:"text"`
// ResponseID is the opaque gateway-scoped response identity. Assistant
// text and its usage share this value; user text and uncorrelated providers
// omit it. Separate response IDs must not be merged into one transcript entry.
ResponseID string `json:"responseID,omitempty"`
}
ReasoningDelta is a gateway message that streams provider reasoning text.
Reasoning is not speech and not a transcript statement. A client decides whether to display it, but must not speak it or replay it as recovery context. The gateway includes it in the session activity log.
type RecognitionModel ¶
type RecognitionModel struct {
// ID is the operator-configured id; it stays the same while the stage's
// settings change.
ID string `json:"id"`
Label string `json:"label"`
}
RecognitionModel identifies one configured recognition stage without exposing endpoints or credentials.
type ServiceAuthorization ¶
type ServiceAuthorization struct {
Kind string `json:"kind"`
InstanceID string `json:"instanceID"`
BaseURL string `json:"baseURL"`
Token string `json:"token"`
}
ServiceAuthorization identifies the host and carries its scoped gateway token.
type SessionClose ¶
type SessionClose struct {
// Kind must be "session.close".
Kind MessageKind `json:"kind"`
// Reason optionally explains why the client closed the session.
Reason string `json:"reason,omitempty"`
}
SessionClose is a client message that closes the voice session.
type SessionReady ¶
type SessionReady struct {
// Kind is "session.ready".
Kind MessageKind `json:"kind"`
}
SessionReady is a gateway message that reports the session is ready.
The gateway sends it before any turn and does not follow it with turn.status idle: clients that capture speech start listening on session.ready unless they request a response first.
type SessionSetup ¶
type SessionSetup struct {
// Kind must be "session.setup".
Kind MessageKind `json:"kind"`
// Voice contains the requested voice and language.
Voice VoiceConfig `json:"voice"`
// Tools declares the client-side tools the assistant may call.
Tools []ToolDeclaration `json:"tools"`
// Context provides initial instructions or text context for the session.
Context Context `json:"context"`
// IncludeReasoning requests optional provider reasoning output for this session.
// It does not enable thinking or change reasoning effort.
IncludeReasoning bool `json:"includeReasoning,omitempty"`
// Speech selects the owner of recognition and synthesis for this session.
Speech *SpeechConfig `json:"speech,omitempty"`
// RecognitionModelID selects a recognitionModels entry for a composable LLM.
// Omitted uses the first available entry when input is gateway-owned.
// It must be omitted for client-owned recognition and indivisible choices.
RecognitionModelID string `json:"recognitionModelID,omitempty"`
// SynthesisModelID selects a synthesisModels entry for a composable LLM.
// Omitted uses the first available entry when output is gateway-owned.
// It must be omitted for client-owned synthesis and indivisible choices.
SynthesisModelID string `json:"synthesisModelID,omitempty"`
// Renegotiation declares that the client answers rtc.offer. The gateway then
// sends one after session.ready when the session takes microphone audio
// below 48 kHz, capping the client's Opus encoder with RFC 7587
// maxplaybackrate so it stops spending uplink bits on audio the backend
// discards. It applies only to WebRTC sessions.
Renegotiation bool `json:"renegotiation,omitempty"`
}
SessionSetup is the client message that initializes a voice session.
type SessionStatus ¶
type SessionStatus struct {
// Kind is "session.status".
Kind MessageKind `json:"kind"`
// Message is a short user-visible description of startup work.
Message string `json:"message"`
}
SessionStatus reports startup progress. Gateways repeat it at least every five seconds while loading or waiting for capacity. Clients may refresh their setup timeout on receipt; only session.ready enables microphone input.
type SessionUsage ¶
type SessionUsage struct {
// Kind is "session.usage".
Kind MessageKind `json:"kind"`
// SessionID identifies the gateway connection that owns these totals.
SessionID string `json:"sessionID"`
// Provider identifies the generation provider.
Provider string `json:"provider"`
// Model identifies the generation model.
Model string `json:"model"`
// Totals sums all reported responses, including tool continuations.
Totals TokenUsage `json:"totals"`
// LastResponse contains the latest reported response counts, when available.
LastResponse *TokenUsage `json:"lastResponse,omitempty"`
// ResponseID identifies the response observed by this report. It is opaque
// and unique across gateway connections. Empty means the provider did not
// supply a reliable response association.
ResponseID string `json:"responseID,omitempty"`
// ResponseUsage contains counts for ResponseID in this report only. Unlike
// LastResponse, it is never carried forward into context-only reports.
ResponseUsage *TokenUsage `json:"responseUsage,omitempty"`
// ContextTokens is the latest reported context size, never summed.
ContextTokens *int64 `json:"contextTokens,omitempty"`
// ContextWindow is the latest reported context capacity.
ContextWindow *int64 `json:"contextWindow,omitempty"`
}
SessionUsage is an idempotent snapshot for one gateway connection. Clients replace snapshots with the same SessionID and carry totals across automatic reconnects in one conversation. Missing reports are excluded from totals; this is observed model usage, not a billing statement or ASR/TTS accounting.
type SpeechConfig ¶
type SpeechConfig struct {
Input SpeechLocation `json:"input,omitempty"`
Output SpeechLocation `json:"output,omitempty"`
}
SpeechConfig selects recognition and synthesis independently. Empty fields use transport defaults: WebRTC uses each configured gateway stage; text uses client speech. Explicit unsupported selections fail before model initialization.
type SpeechEnded ¶
type SpeechEnded struct {
// Kind is "speech.ended".
Kind MessageKind `json:"kind"`
// Speaker identifies whose speech output ended.
Speaker Speaker `json:"speaker"`
}
SpeechEnded is a gateway message that reports speech output ended.
type SpeechLocation ¶
type SpeechLocation string
SpeechLocation identifies which side owns a speech stage.
const ( // SpeechLocationClient uses the client's speech facilities. SpeechLocationClient SpeechLocation = "client" // SpeechLocationGateway uses the gateway's configured speech model. SpeechLocationGateway SpeechLocation = "gateway" )
type SpeechStarted ¶
type SpeechStarted struct {
// Kind is "speech.started".
Kind MessageKind `json:"kind"`
// Speaker identifies whose speech output started.
Speaker Speaker `json:"speaker"`
}
SpeechStarted is a gateway message that reports speech output started.
type StatusResp ¶
type StatusResp struct {
// Status is a short human-readable result such as "closed".
Status string `json:"status"`
}
StatusResp is a common response for mutation endpoints.
type SynthesisModel ¶
type SynthesisModel struct {
// ID is the operator-configured id; it stays the same while the stage's
// settings change.
ID string `json:"id"`
Label string `json:"label"`
// Voices lists the selectable voices. Omitted when the stage offers no
// voice selection.
Voices []Voice `json:"voices,omitempty"`
}
SynthesisModel identifies one configured synthesis stage without exposing endpoints or credentials.
type TokenUsage ¶
type TokenUsage struct {
// InputTokens includes the input processed again on each model request.
InputTokens *int64 `json:"inputTokens,omitempty"`
// OutputTokens counts generated output as reported by the provider.
OutputTokens *int64 `json:"outputTokens,omitempty"`
// CachedTokens is the reported cached-input breakdown.
CachedTokens *int64 `json:"cachedTokens,omitempty"`
// ReasoningTokens is the reported reasoning breakdown.
ReasoningTokens *int64 `json:"reasoningTokens,omitempty"`
}
TokenUsage contains provider-reported counts. Nil means unavailable. Cached and reasoning counts are breakdowns, never additional tokens to sum with input and output; providers differ in how they account for reasoning output.
type ToolCall ¶
type ToolCall struct {
// Kind is "tool.call".
Kind MessageKind `json:"kind"`
// ID uniquely identifies this tool call for the matching tool.result.
ID string `json:"id"`
// Name is the requested tool name.
Name string `json:"name"`
// Args is the JSON argument object for the requested tool.
Args json.RawMessage `json:"args"`
}
ToolCall is a gateway message that asks the client to execute a tool.
type ToolDeclaration ¶
type ToolDeclaration struct {
// Name is the tool name the assistant uses in tool.call messages.
Name string `json:"name"`
// Description explains when and how the assistant should use the tool.
Description string `json:"description"`
// Parameters is a JSON Schema object describing the tool arguments. When
// present, it must declare "type": "object".
Parameters json.RawMessage `json:"parameters"`
}
ToolDeclaration is a provider-neutral service tool declaration.
type ToolResult ¶
type ToolResult struct {
// Kind must be "tool.result".
Kind MessageKind `json:"kind"`
// ID matches the tool.call ID being answered.
ID string `json:"id"`
// Name is the tool name that produced the result.
Name string `json:"name"`
// Result is the JSON result returned to the assistant.
Result json.RawMessage `json:"result"`
}
ToolResult is a client message that returns a tool execution result.
type TranscriptDelta ¶
type TranscriptDelta struct {
// Kind is "transcript.delta".
Kind MessageKind `json:"kind"`
// Speaker identifies who produced this transcript text.
Speaker Speaker `json:"speaker"`
// Text is an incremental transcript fragment.
Text string `json:"text"`
// ResponseID is the opaque gateway-scoped response identity. Assistant
// text and its usage share this value; user text and uncorrelated providers
// omit it. Separate response IDs must not be merged into one transcript entry.
ResponseID string `json:"responseID,omitempty"`
// DraftID atomically replaces the matching user draft when this text commits.
DraftID string `json:"draft_id,omitempty"`
}
TranscriptDelta is a gateway message that streams transcript text. Each fragment appends to previously emitted text; it never replaces it.
type TranscriptDraft ¶
type TranscriptDraft struct {
Kind MessageKind `json:"kind"`
ID string `json:"id"`
Text string `json:"text"`
}
TranscriptDraft is an ephemeral full-text user hypothesis for one microphone utterance. Revisions replace text for ID. Empty Text clears only that ID. Drafts never enter conversation history, activity logs, or recovery context.
type TurnCancel ¶
type TurnCancel struct {
// Kind must be "turn.cancel".
Kind MessageKind `json:"kind"`
// Reason optionally explains why the current assistant turn was cancelled.
Reason string `json:"reason,omitempty"`
}
TurnCancel is a client message that cancels the current turn.
type TurnState ¶
type TurnState string
TurnState identifies the gateway work that precedes assistant output.
const ( // TurnStateIdle means the gateway has no turn in progress. TurnStateIdle TurnState = "idle" // TurnStateThinking means the assistant is generating a response. TurnStateThinking TurnState = "thinking" // TurnStateTranscribing means the gateway is converting user speech to text. TurnStateTranscribing TurnState = "transcribing" )
type TurnStatus ¶
type TurnStatus struct {
// Kind is "turn.status".
Kind MessageKind `json:"kind"`
// State is the gateway work in progress; idle ends the turn, including
// one that produced no speech.
State TurnState `json:"state"`
}
TurnStatus is a gateway message that reports work on the current turn.
Backends that cannot observe their own progress never send it. Speech output and tool calls take display precedence over the reported state.
type UserMessage ¶
type UserMessage struct {
// Kind must be "user.message".
Kind MessageKind `json:"kind"`
// Text is the completed user utterance to send to the assistant.
Text string `json:"text"`
}
UserMessage is a client message that appends completed user text and asks the assistant to respond.
type Voice ¶
type Voice struct {
// Name is the SessionSetup.voice.name that selects this voice.
Name string `json:"name"`
// Language is the ISO 639-1 code of the only language the voice speaks,
// such as "fr". Clients offer the voice only in sessions whose language
// tag has that base subtag, and session.setup rejects it in another.
// Empty means the voice speaks every language the model does.
Language string `json:"language,omitempty"`
// Default marks the voice a session speaks with when SessionSetup.voice.name
// is empty and the session language is one the voice speaks. A list has
// either one default without a language or at most one default per
// language; clients reject a list that mixes both. A list without a
// default leaves the choice to the provider.
Default bool `json:"default,omitempty"`
}
Voice is one selectable voice of a voice choice or synthesis model.
type VoiceChoice ¶
type VoiceChoice struct {
// ID is the operator-configured id. It stays the same while the choice's
// settings change, so clients save it; a saved id the catalog no longer
// lists falls back to the default.
ID string `json:"id"`
Label string `json:"label"`
Transports []VoiceTransport `json:"transports"`
// Voices lists the selectable voices. Omitted when the choice does not
// offer voice selection.
Voices []Voice `json:"voices,omitempty"`
// SpeechModes lists supported input/output ownership combinations.
// Missing metadata from older gateways means transport defaults only.
SpeechModes []SpeechConfig `json:"speechModes,omitempty"`
// Composable allows independent recognition and synthesis model selections.
Composable bool `json:"composable,omitempty"`
}
VoiceChoice describes a selectable backend without exposing its credentials.
type VoiceChoiceDefault ¶
type VoiceChoiceDefault struct {
// Transport is the family this default applies to.
Transport VoiceTransport `json:"transport"`
// ID names a choice that offers Transport.
ID string `json:"id"`
}
VoiceChoiceDefault names the choice a transport family uses when a session omits choiceID. A family is one transport: WebRTC audio for gateway speech, or text for client speech with a gateway LLM.
func DefaultChoices ¶
func DefaultChoices(choices []VoiceChoice, preferred []VoiceChoiceDefault) []VoiceChoiceDefault
DefaultChoices returns one default per transport offered by choices.
A transport uses the first preferred entry that names a choice offering it, and otherwise the first choice that offers it. Transports no choice offers are omitted.
type VoiceChoicesResp ¶
type VoiceChoicesResp struct {
Choices []VoiceChoice `json:"choices"`
// Defaults holds one entry per offered transport, ordered by transport name.
Defaults []VoiceChoiceDefault `json:"defaults"`
// RecognitionModels lists gateway recognition stages in preference order.
RecognitionModels []RecognitionModel `json:"recognitionModels,omitempty"`
// SynthesisModels lists gateway synthesis stages in preference order.
SynthesisModels []SynthesisModel `json:"synthesisModels,omitempty"`
// STUNServers lists the stun: or stuns: URLs a WebRTC client configures as
// its ICE servers. Omitted means none: the client gathers host candidates
// only and contacts no STUN server.
STUNServers []string `json:"stunServers,omitempty"`
}
VoiceChoicesResp advertises the available voice choices and one default per offered family.
func (*VoiceChoicesResp) DefaultChoiceID ¶
func (r *VoiceChoicesResp) DefaultChoiceID(transport VoiceTransport) string
DefaultChoiceID returns the default choice for transport, or "" when the gateway offers no choice for it.
type VoiceConfig ¶
type VoiceConfig struct {
// Name is the requested voice name from the catalog's voices. Empty uses
// the voice the catalog marks default for the session language, else the
// configured voice, else the provider default. A voice of another language
// fails session setup.
Name string `json:"name,omitempty"`
// Language is the requested BCP 47 language tag, such as "en-US" or "fr-CA".
// Empty defaults to "en-US"; an invalid tag fails session setup. A session
// speaks one language, and the assistant replies in it. Synthesis and
// recognition models that take a language receive it, recognition as a
// hint or forced; other models ignore it. A model that declares its
// languages fails session setup for another one. A model whose server
// rejects the language fails when its connection starts: at session setup
// for realtime choices, and at each utterance for recognition.
Language string `json:"language"`
}
VoiceConfig describes provider-neutral voice preferences.
type VoiceRTCAnswerResp ¶
type VoiceRTCAnswerResp struct {
// SDP is the gateway WebRTC answer session description to pass to setRemoteDescription with type "answer".
SDP string `json:"sdp"`
// SessionID identifies the voice RTC session for diagnostics and close calls.
SessionID string `json:"sessionID"`
}
VoiceRTCAnswerResp is the response for POST /api/voicegateway/v2/voice/rtc/offer.
type VoiceRTCClientDiagnostics ¶
type VoiceRTCClientDiagnostics struct {
// ICEConnectionState is the client's RTCPeerConnection.iceConnectionState.
ICEConnectionState VoiceRTCICEConnectionState `json:"iceConnectionState,omitempty"`
// ICEGatheringState is the client's RTCPeerConnection.iceGatheringState.
ICEGatheringState VoiceRTCICEGatheringState `json:"iceGatheringState,omitempty"`
// ConnectionState is the client's RTCPeerConnection.connectionState.
ConnectionState VoiceRTCConnectionState `json:"connectionState,omitempty"`
// SignalingState is the client's RTCPeerConnection.signalingState.
SignalingState VoiceRTCSignalingState `json:"signalingState,omitempty"`
// DataChannelState is the client's voice-gateway RTCDataChannel.readyState.
DataChannelState VoiceRTCDataChannelState `json:"dataChannelState,omitempty"`
}
VoiceRTCClientDiagnostics reports client-observed WebRTC state for diagnosis.
type VoiceRTCConnectionState ¶
type VoiceRTCConnectionState string
VoiceRTCConnectionState is a WebRTC peer connection state.
const ( VoiceRTCConnectionStateNew VoiceRTCConnectionState = "new" VoiceRTCConnectionStateConnecting VoiceRTCConnectionState = "connecting" VoiceRTCConnectionStateConnected VoiceRTCConnectionState = "connected" VoiceRTCConnectionStateDisconnected VoiceRTCConnectionState = "disconnected" VoiceRTCConnectionStateFailed VoiceRTCConnectionState = "failed" VoiceRTCConnectionStateClosed VoiceRTCConnectionState = "closed" )
Voice RTC connection states.
type VoiceRTCConnectivityIssue ¶
type VoiceRTCConnectivityIssue string
VoiceRTCConnectivityIssue identifies a structured voice RTC connectivity issue.
const ( VoiceRTCConnectivityIssueNone VoiceRTCConnectivityIssue = "none" VoiceRTCConnectivityIssueServerSessionMissing VoiceRTCConnectivityIssue = "server_session_missing" VoiceRTCConnectivityIssueServerICEFailed VoiceRTCConnectivityIssue = "server_ice_failed" VoiceRTCConnectivityIssueUDPUnreachable VoiceRTCConnectivityIssue = "udp_unreachable" VoiceRTCConnectivityIssueDataChannelNotOpen VoiceRTCConnectivityIssue = "data_channel_not_open" VoiceRTCConnectivityIssueVoiceBackendConnecting VoiceRTCConnectivityIssue = "voice_backend_connecting" VoiceRTCConnectivityIssueSessionReadyNotDelivered VoiceRTCConnectivityIssue = "session_ready_not_delivered" VoiceRTCConnectivityIssueUnknownTimeout VoiceRTCConnectivityIssue = "unknown_timeout" )
Voice RTC connectivity issues.
type VoiceRTCConnectivitySide ¶
type VoiceRTCConnectivitySide string
VoiceRTCConnectivitySide identifies where a voice RTC failure appears to be.
const ( VoiceRTCConnectivitySideNone VoiceRTCConnectivitySide = "none" VoiceRTCConnectivitySideServer VoiceRTCConnectivitySide = "server" VoiceRTCConnectivitySideClient VoiceRTCConnectivitySide = "client" VoiceRTCConnectivitySideNetwork VoiceRTCConnectivitySide = "network" VoiceRTCConnectivitySideUnknown VoiceRTCConnectivitySide = "unknown" )
Voice RTC connectivity sides.
type VoiceRTCDataChannelState ¶
type VoiceRTCDataChannelState string
VoiceRTCDataChannelState is a WebRTC data channel state.
const ( VoiceRTCDataChannelStateNew VoiceRTCDataChannelState = "new" VoiceRTCDataChannelStateConnecting VoiceRTCDataChannelState = "connecting" VoiceRTCDataChannelStateOpen VoiceRTCDataChannelState = "open" VoiceRTCDataChannelStateClosing VoiceRTCDataChannelState = "closing" VoiceRTCDataChannelStateClosed VoiceRTCDataChannelState = "closed" )
Voice RTC data channel states.
type VoiceRTCDiagnosticsReq ¶
type VoiceRTCDiagnosticsReq struct {
// Client contains the browser/client WebRTC state observed by the caller.
Client VoiceRTCClientDiagnostics `json:"client,omitzero"`
}
VoiceRTCDiagnosticsReq is the request body for POST /api/voicegateway/v2/voice/rtc/{sessionID}/diagnostics.
type VoiceRTCDiagnosticsResp ¶
type VoiceRTCDiagnosticsResp struct {
// SessionID is the diagnosed voice RTC session ID.
SessionID string `json:"sessionID"`
// Issue is the machine-readable connectivity diagnosis.
Issue VoiceRTCConnectivityIssue `json:"issue"`
// Side identifies where the issue appears to be.
Side VoiceRTCConnectivitySide `json:"side"`
// Message is a human-readable explanation of the diagnosis.
Message string `json:"message"`
// Server contains gateway-observed WebRTC state.
Server VoiceRTCServerDiagnostics `json:"server"`
// Client echoes the client diagnostics included in the request.
Client VoiceRTCClientDiagnostics `json:"client,omitzero"`
}
VoiceRTCDiagnosticsResp reports structured WebRTC connectivity diagnostics.
type VoiceRTCICEConnectionState ¶
type VoiceRTCICEConnectionState string
VoiceRTCICEConnectionState is a WebRTC ICE transport connection state.
const ( VoiceRTCICEConnectionStateNew VoiceRTCICEConnectionState = "new" VoiceRTCICEConnectionStateChecking VoiceRTCICEConnectionState = "checking" VoiceRTCICEConnectionStateConnected VoiceRTCICEConnectionState = "connected" VoiceRTCICEConnectionStateCompleted VoiceRTCICEConnectionState = "completed" VoiceRTCICEConnectionStateDisconnected VoiceRTCICEConnectionState = "disconnected" VoiceRTCICEConnectionStateFailed VoiceRTCICEConnectionState = "failed" VoiceRTCICEConnectionStateClosed VoiceRTCICEConnectionState = "closed" )
Voice RTC ICE connection states.
type VoiceRTCICEGatheringState ¶
type VoiceRTCICEGatheringState string
VoiceRTCICEGatheringState is a WebRTC ICE candidate gathering state.
const ( VoiceRTCICEGatheringStateNew VoiceRTCICEGatheringState = "new" VoiceRTCICEGatheringStateGathering VoiceRTCICEGatheringState = "gathering" VoiceRTCICEGatheringStateComplete VoiceRTCICEGatheringState = "complete" )
Voice RTC ICE gathering states.
type VoiceRTCOfferReq ¶
type VoiceRTCOfferReq struct {
// ChoiceID selects a gateway choice; empty uses the advertised default.
ChoiceID string `json:"choiceID,omitempty"`
// SDP is the browser/client WebRTC offer session description from RTCSessionDescription.sdp after createOffer and setLocalDescription.
SDP string `json:"sdp"`
// Service authorizes a session on a standalone gateway. Embedded gateways use host authentication.
Service *ServiceAuthorization `json:"service,omitempty"`
}
VoiceRTCOfferReq is the request body for POST /api/voicegateway/v2/voice/rtc/offer.
func (*VoiceRTCOfferReq) Validate ¶
func (r *VoiceRTCOfferReq) Validate() error
Validate checks that the SDP offer is provided.
type VoiceRTCServerDiagnostics ¶
type VoiceRTCServerDiagnostics struct {
// SessionFound reports whether the gateway still has the requested session.
SessionFound bool `json:"sessionFound"`
// UDPEndpoints are the LAN/Tailscale and optional UPnP public UDP candidates advertised to the client.
UDPEndpoints []VoiceRTCUDPEndpoint `json:"udpEndpoints,omitempty"`
// UDPMappingError is the last UPnP mapping or refresh error, if any.
UDPMappingError string `json:"udpMappingError,omitempty"`
// ICEConnectionState is the gateway PeerConnection ICE connection state.
ICEConnectionState VoiceRTCICEConnectionState `json:"iceConnectionState,omitempty"`
// ICEGatheringState is the gateway PeerConnection ICE gathering state.
ICEGatheringState VoiceRTCICEGatheringState `json:"iceGatheringState,omitempty"`
// ConnectionState is the gateway PeerConnection aggregate connection state.
ConnectionState VoiceRTCConnectionState `json:"connectionState,omitempty"`
// SignalingState is the gateway PeerConnection signaling state.
SignalingState VoiceRTCSignalingState `json:"signalingState,omitempty"`
// DataChannelState is the gateway-observed voice data channel state.
DataChannelState VoiceRTCDataChannelState `json:"dataChannelState,omitempty"`
// DataChannelOpened reports whether the voice data channel reached open.
DataChannelOpened bool `json:"dataChannelOpened,omitempty"`
// AudioTrackReceived reports whether the gateway received the client's microphone track.
AudioTrackReceived bool `json:"audioTrackReceived,omitempty"`
// BackendConnected reports whether the gateway connected to the configured voice backend.
BackendConnected bool `json:"backendConnected,omitempty"`
// SessionReadySent reports whether the gateway sent session.ready to the client.
SessionReadySent bool `json:"sessionReadySent,omitempty"`
}
VoiceRTCServerDiagnostics reports server-observed WebRTC state for diagnosis.
type VoiceRTCSignalingState ¶
type VoiceRTCSignalingState string
VoiceRTCSignalingState is a WebRTC peer connection signaling state.
const ( VoiceRTCSignalingStateStable VoiceRTCSignalingState = "stable" VoiceRTCSignalingStateHaveLocalOffer VoiceRTCSignalingState = "have-local-offer" VoiceRTCSignalingStateHaveRemoteOffer VoiceRTCSignalingState = "have-remote-offer" VoiceRTCSignalingStateHaveLocalPranswer VoiceRTCSignalingState = "have-local-pranswer" VoiceRTCSignalingStateHaveRemotePranswer VoiceRTCSignalingState = "have-remote-pranswer" VoiceRTCSignalingStateClosed VoiceRTCSignalingState = "closed" )
Voice RTC signaling states.
type VoiceRTCUDPEndpoint ¶
type VoiceRTCUDPEndpoint struct {
// Host is an IP address advertised in the gateway SDP answer.
Host string `json:"host"`
// Port is the UDP port paired with host in the gateway SDP answer.
Port int `json:"port"`
}
VoiceRTCUDPEndpoint reports one server UDP candidate for diagnosis.
type VoiceTextTicketReq ¶
type VoiceTextTicketReq struct {
// ChoiceID selects a text-capable choice, bound to the issued ticket.
ChoiceID string `json:"choiceID,omitempty"`
// Service authorizes a session on a standalone gateway.
Service *ServiceAuthorization `json:"service,omitempty"`
}
VoiceTextTicketReq authorizes a browser text-session WebSocket upgrade. Embedded hosts authenticate this HTTP request before dispatch.
type VoiceTextTicketResp ¶
type VoiceTextTicketResp struct {
Ticket string `json:"ticket"`
}
VoiceTextTicketResp carries a single-use ticket that expires after 30 seconds. Connect to /api/voicegateway/v2/voice/text/browser with the gomode.ticket.<ticket> WebSocket subprotocol alongside gomode.text.v2. Never put it in a URL or store it persistently.
type VoiceTransport ¶
type VoiceTransport string
VoiceTransport identifies how clients communicate with a voice choice.
const ( // VoiceTransportText carries text with client speech recognition and synthesis. VoiceTransportText VoiceTransport = "text" // VoiceTransportWebRTC carries audio through WebRTC. VoiceTransportWebRTC VoiceTransport = "webrtc" )