Versions in this module Expand all Collapse all v0 v0.2.0 Nov 2, 2026 v0.1.0 Nov 1, 2026 Changes in this version + const ConformanceGreeting + const ConnectPath + const DefaultURL + const HeaderBytes + const Host + const ProtocolVersion + const RetainedFrames + const Subprotocol + const Version + var ErrSessionEnded = errors.New("the session has ended") + var ErrTextSession = errors.New("the session is a text session") + var FromAgent = map[string]struct + var FromSent = map[string]struct + var PartyKinds = []string + var SessionEndReasons = []string + var SessionScoped = map[string]struct + var SessionTypes = map[string][]string + var Uncounted = map[string]struct + func AudioFrame(stream int, samples []byte) ([]byte, error) + func BytesPerFrame(sampleRate, milliseconds int) int + func Encode(frame Frame) ([]byte, error) + func SamplesOf(frame []byte) []byte + func StreamOf(frame []byte) int + type Agent struct + func New(options Options) *Agent + func (a *Agent) Run(ctx context.Context) error + func (a *Agent) Serve() error + func (a *Agent) Sessions() []*Session + func (a *Agent) Stop() + type AgentClear struct + SessionID string + func (*AgentClear) Type() string + func (f *AgentClear) Session() string + func (f AgentClear) MarshalJSON() ([]byte, error) + type AgentSay struct + Interruptible *bool + Last *bool + SessionID string + Text string + func (*AgentSay) Type() string + func (f *AgentSay) Session() string + func (f AgentSay) MarshalJSON() ([]byte, error) + type BaseHandler struct + func (BaseHandler) OnAudio(context.Context, *Session, []byte) + func (BaseHandler) OnConnected(context.Context, *ConnectionReady) + func (BaseHandler) OnError(context.Context, *ErrorFrame) + func (BaseHandler) OnFrame(context.Context, *Session, *UnknownFrame) + func (BaseHandler) OnSessionEnd(context.Context, *Session, *SessionEnd) + func (BaseHandler) OnSessionLost(context.Context, *Session) + func (BaseHandler) OnSessionStart(context.Context, *Session) + func (BaseHandler) OnToolResult(context.Context, *Session, *ToolResult) + func (BaseHandler) OnUserSaid(context.Context, *Session, *UserSaid) + type ConformanceHandler struct + func (ConformanceHandler) OnAudio(_ context.Context, session *Session, samples []byte) + func (ConformanceHandler) OnSessionStart(_ context.Context, session *Session) + func (ConformanceHandler) OnToolResult(_ context.Context, session *Session, result *ToolResult) + func (ConformanceHandler) OnUserSaid(ctx context.Context, session *Session, said *UserSaid) + type ConformanceStep struct + Action string + Arguments map[string]any + Last *bool + Name string + Text string + func Decide(text string) []ConformanceStep + type ConnectionDraining struct + func (*ConnectionDraining) Type() string + func (f ConnectionDraining) MarshalJSON() ([]byte, error) + type ConnectionReady struct + HeartbeatIntervalMs int64 + MaxSessions int64 + ProtocolVersion string + func (*ConnectionReady) Type() string + func (f ConnectionReady) MarshalJSON() ([]byte, error) + type ErrorFrame struct + Error *ErrorInfo + FrameType *string + SessionID *string + func (*ErrorFrame) Type() string + func (f ErrorFrame) MarshalJSON() ([]byte, error) + type ErrorInfo struct + Code string + Message string + type Frame interface + Type func() string + func Decode(data []byte) (Frame, error) + type FrameError struct + Message string + func (e *FrameError) Error() string + type Handler interface + OnAudio func(ctx context.Context, session *Session, samples []byte) + OnConnected func(ctx context.Context, ready *ConnectionReady) + OnError func(ctx context.Context, err *ErrorFrame) + OnFrame func(ctx context.Context, session *Session, frame *UnknownFrame) + OnSessionEnd func(ctx context.Context, session *Session, end *SessionEnd) + OnSessionLost func(ctx context.Context, session *Session) + OnSessionStart func(ctx context.Context, session *Session) + OnToolResult func(ctx context.Context, session *Session, result *ToolResult) + OnUserSaid func(ctx context.Context, session *Session, said *UserSaid) + type Options struct + APIKey string + AgentID string + Handler Handler + Logger *slog.Logger + URL string + type Party struct + Kind string + Value *string + type Ping struct + Ts int64 + func (*Ping) Type() string + func (f Ping) MarshalJSON() ([]byte, error) + type Pong struct + Ts int64 + func (*Pong) Type() string + func (f Pong) MarshalJSON() ([]byte, error) + type Refused struct + Reason string + Status int + func (r *Refused) Error() string + type Resume struct + Token string + WindowMs int64 + type SayOption func(*AgentSay) + func Interruptible(interruptible bool) SayOption + func Last(last bool) SayOption + type Session struct + AgentID string + CallID string + Context map[string]any + Direction string + From *Party + ID string + Language string + SampleRate int + SessionType string + Start *SessionStart + StartedAt string + To *Party + func (s *Session) Clear() error + func (s *Session) End() *SessionEnd + func (s *Session) Ended() bool + func (s *Session) Hangup(ctx context.Context) (*ToolResult, error) + func (s *Session) Hold(ctx context.Context, held bool) (*ToolResult, error) + func (s *Session) Lost() bool + func (s *Session) Received() int64 + func (s *Session) Resumable() bool + func (s *Session) Say(text string, options ...SayOption) error + func (s *Session) SendAudio(samples []byte) error + func (s *Session) SendDTMF(ctx context.Context, digits string) (*ToolResult, error) + func (s *Session) Sent() int64 + func (s *Session) Stream() (int, bool) + func (s *Session) Token() (string, bool) + func (s *Session) Tool(ctx context.Context, name string, arguments map[string]any) (*ToolResult, error) + func (s *Session) Transfer(ctx context.Context, to *Party) (*ToolResult, error) + func (s *Session) TransferNumber(ctx context.Context, number string) (*ToolResult, error) + func (s *Session) WindowMs() int64 + type SessionEnd struct + DurationMs int64 + Reason string + SessionID string + func (*SessionEnd) Type() string + func (f *SessionEnd) Session() string + func (f SessionEnd) MarshalJSON() ([]byte, error) + type SessionFrame interface + Session func() string + type SessionResume struct + Received int64 + SessionID string + Token string + func (*SessionResume) Type() string + func (f *SessionResume) Session() string + func (f SessionResume) MarshalJSON() ([]byte, error) + type SessionResumed struct + Audio *SessionResumedAudio + Received int64 + Resume *Resume + SessionID string + func (*SessionResumed) Type() string + func (f *SessionResumed) Session() string + func (f SessionResumed) MarshalJSON() ([]byte, error) + type SessionResumedAudio struct + Stream int64 + type SessionStart struct + AgentID string + Audio *SessionStartAudio + CallID string + Context map[string]any + Direction string + From *Party + Language *string + MaxDurationMs *int64 + Resume *Resume + SessionID string + SessionType string + StartedAt string + To *Party + func (*SessionStart) Type() string + func (f *SessionStart) Session() string + func (f SessionStart) MarshalJSON() ([]byte, error) + type SessionStartAudio struct + SampleRate *int64 + Stream int64 + type ToolCall struct + Arguments map[string]any + CallRef string + Name string + SessionID string + func (*ToolCall) Type() string + func (f *ToolCall) Session() string + func (f ToolCall) MarshalJSON() ([]byte, error) + type ToolResult struct + CallRef string + Error *ErrorInfo + Ok bool + SessionID string + func (*ToolResult) Type() string + func (f *ToolResult) Session() string + func (f ToolResult) MarshalJSON() ([]byte, error) + type UnknownFrame struct + Fields map[string]any + SessionID string + func NewUnknownFrame(fields map[string]any) *UnknownFrame + func (f *UnknownFrame) Session() string + func (f *UnknownFrame) Type() string + func (f UnknownFrame) MarshalJSON() ([]byte, error) + type UserSaid struct + Correction bool + SessionID string + Text string + func (*UserSaid) Type() string + func (f *UserSaid) Session() string + func (f UserSaid) MarshalJSON() ([]byte, error)