Documentation
¶
Overview ¶
Package local implements voiceagent.Provider on top of an in-process live session — realtime voice agents (Deepgram Voice Agent, Gemini Live, OpenAI Realtime, AssemblyAI, cascaded) without a speechkit-server.
It is the composition seam between the embeddable voiceagent.Service (what companion.HandsFree TargetVoiceAgent consumes) and the realtime runtime in live + agentkit: tool definitions from the registry are announced to the provider (e.g. Deepgram agent.think.functions), tool calls are executed client-side and answered via SendToolResponse, and final input/output transcripts accumulate into the returned speechkit.VoiceAgentSession record.
Hosts that own audio I/O (the kombify box companion, future satellites) feed microphone PCM through Provider.SendAudio and play back agent audio via Options.Callbacks.OnAudio.
Index ¶
- Constants
- Variables
- type Options
- type Provider
- func (p *Provider) CurrentSession(context.Context) (speechkit.VoiceAgentSession, error)
- func (p *Provider) EndAudioStream() error
- func (p *Provider) SendAudio(chunk []byte) error
- func (p *Provider) SendText(_ context.Context, text string) error
- func (p *Provider) StartVoiceAgent(ctx context.Context, cfg voiceagent.Config, cbs voiceagent.Callbacks) error
- func (p *Provider) State() live.State
- func (p *Provider) StopVoiceAgent(context.Context) (speechkit.VoiceAgentSession, error)
- type ProviderFactory
Constants ¶
const RuntimeKindLocal = "local"
RuntimeKindLocal marks session records produced by this provider.
Variables ¶
var ( ErrSessionActive = errors.New("speechkit voiceagent/local: a session is already active") ErrNoActiveSession = errors.New("speechkit voiceagent/local: no active session") )
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Live is the base realtime configuration (provider, model, voice,
// locale, API key, framework prompt, policies, provider options).
// StartVoiceAgent merges the per-session [voiceagent.Config] on top.
Live live.LiveConfig
// Idle bounds session lifetime; zero values fall back to
// [live.DefaultIdleConfig]. Hosts paying per connection minute
// (Deepgram Voice Agent) should set these aggressively.
Idle live.IdleConfig
// Tools are executed client-side when the agent calls them; their
// definitions are announced to the provider on session start.
Tools *agentkit.ToolRegistry
// Hooks observe session lifecycle (user/agent messages, tool calls).
Hooks agentkit.LifecycleHooks
// Memory is the session-scoped store handed to tools; defaults to the
// in-memory implementation.
Memory agentkit.Memory
// Callbacks are the rich host callbacks (audio playback, barge-in,
// transcripts, state changes). The thin [voiceagent.Callbacks] passed
// by the service are invoked in addition, never instead.
Callbacks live.Callbacks
// Factory overrides live-provider construction; nil uses
// [live.NewProviderForConfig].
Factory ProviderFactory
}
Options configure the local provider. All fields are optional except Live, which must at least name the realtime provider (or profile) to use.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider adapts an agentkit.AgentSession to voiceagent.Provider. Methods are safe for concurrent use; only one session is active at a time (matching live.Session semantics).
func (*Provider) CurrentSession ¶
CurrentSession returns a snapshot of the running (or last) session record.
func (*Provider) EndAudioStream ¶
EndAudioStream signals the end of the current microphone stream.
func (*Provider) SendAudio ¶
SendAudio forwards a 16 kHz S16LE mono PCM chunk from the host microphone into the session. It exceeds the voiceagent.Provider interface: audio-owning hosts (the box companion) call it directly.
func (*Provider) StartVoiceAgent ¶
func (p *Provider) StartVoiceAgent(ctx context.Context, cfg voiceagent.Config, cbs voiceagent.Callbacks) error
StartVoiceAgent opens a live session. cfg fields override the base Options.Live where set: Model, Locale, ProviderProfileID → ProfileID, Instruction → FrameworkPrompt.
func (*Provider) State ¶
State exposes the underlying live session state (inactive when no session is active).
func (*Provider) StopVoiceAgent ¶
StopVoiceAgent ends the session and returns the accumulated record.
type ProviderFactory ¶
type ProviderFactory func(live.LiveConfig) (live.LiveProvider, live.LiveConfig, error)
ProviderFactory builds a live provider for a normalized config. The default is live.NewProviderForConfig; tests inject fakes here.