local

package
v0.51.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

View Source
const RuntimeKindLocal = "local"

RuntimeKindLocal marks session records produced by this provider.

Variables

View Source
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 New

func New(opts Options) (*Provider, error)

func (*Provider) CurrentSession

func (p *Provider) CurrentSession(context.Context) (speechkit.VoiceAgentSession, error)

CurrentSession returns a snapshot of the running (or last) session record.

func (*Provider) EndAudioStream

func (p *Provider) EndAudioStream() error

EndAudioStream signals the end of the current microphone stream.

func (*Provider) SendAudio

func (p *Provider) SendAudio(chunk []byte) error

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) SendText

func (p *Provider) SendText(_ context.Context, text string) error

SendText injects a user text turn into the active session.

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

func (p *Provider) State() live.State

State exposes the underlying live session state (inactive when no session is active).

func (*Provider) StopVoiceAgent

func (p *Provider) StopVoiceAgent(context.Context) (speechkit.VoiceAgentSession, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL