local

package
v0.74.4 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (voice satellites, embedded devices) feed microphone PCM through Provider.SendAudio and play back agent audio via Options.Callbacks.OnAudio.

Stability: Beta — API-checked; may change with a changelog callout.

Index

Constants

View Source
const RuntimeKindLocal = "local"

RuntimeKindLocal marks session records produced by this provider.

Variables

View Source
var (
	// ErrSessionActive is returned by StartVoiceAgent while a session is
	// already running.
	ErrSessionActive = errors.New("speechkit voiceagent/local: a session is already active")
	// ErrNoActiveSession is returned when there is no session to act on:
	// before the first StartVoiceAgent, after StopVoiceAgent for the send
	// and stop methods, and on a nil *Provider.
	ErrNoActiveSession = errors.New("speechkit voiceagent/local: no active session")
)

Errors reported by Provider. Both are returned directly, so hosts can compare them with errors.Is.

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
	// [liveall.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)

New returns a Provider for opts after filling defaults: a nil Factory uses liveall.NewProviderForConfig, and an Idle config with neither bound set uses live.DefaultIdleConfig. The error result is currently always nil.

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(ctx 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 liveall.NewProviderForConfig; tests inject fakes here.

Jump to

Keyboard shortcuts

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