realtime

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 6 Imported by: 1 module, 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 realtime defines explicit duplex model sessions. It owns no audio device, tool executor, transcript store, or endpoint selection.

Index

Constants

View Source
const APIVersion = "intelligence.realtime/v1"

Variables

This section is empty.

Functions

This section is empty.

Types

type AudioControl

type AudioControl interface {
	ClearInputAudio(context.Context) error
	TruncateAudio(context.Context, string, int, int) error
}

AudioControl is optional. Canceling output and truncating conversation audio to what was played are distinct caller decisions.

type Event

type Event struct {
	Kind       string                `json:"kind"`
	NativeType string                `json:"nativeType,omitempty"`
	ID         string                `json:"id,omitempty"`
	ItemID     string                `json:"itemId,omitempty"`
	ResponseID string                `json:"responseId,omitempty"`
	Status     string                `json:"status,omitempty"`
	Text       string                `json:"text,omitempty"`
	Audio      []byte                `json:"audio,omitempty"`
	Call       *inference.ToolCall   `json:"call,omitempty"`
	Usage      *inference.TokenUsage `json:"usage,omitempty"`
	OccurredAt time.Time             `json:"occurredAt"`
	Raw        []byte                `json:"raw,omitempty"`
}

func (Event) Validate

func (e Event) Validate() error

Validate rejects unbounded event data before it crosses a plugin boundary.

type OpenRequest

type OpenRequest struct {
	APIVersion string          `json:"apiVersion"`
	Model      string          `json:"model"`
	Options    json.RawMessage `json:"options,omitempty"`
}

OpenRequest starts a caller-selected model session. Options are interpreted only by the selected provider; no endpoint or credential is implicit.

func (OpenRequest) Validate

func (r OpenRequest) Validate() error

type Provider

type Provider interface {
	Open(context.Context, OpenRequest) (Session, error)
	Close() error
}

Provider opens a model session. A host grants access before opening it.

type Session

type Session interface {
	SendText(context.Context, string) error
	SendAudio(context.Context, []byte) error
	CommitAudio(context.Context) error
	Respond(context.Context) error
	Interrupt(context.Context) error
	SendToolResult(context.Context, string, []byte) error
	Receive(context.Context) (Event, error)
	Close() error
}

Session sends caller-selected turns and receives provider events. A tool proposal is data; it is never executed by this interface.

type State

type State struct {
	Connection     string    `json:"connection"`
	ResponseID     string    `json:"responseId,omitempty"`
	ResponseStatus string    `json:"responseStatus,omitempty"`
	LastEventAt    time.Time `json:"lastEventAt"`
}

State is a pure reducer. It never starts a session or performs an action.

func (State) Apply

func (s State) Apply(event Event) State

Jump to

Keyboard shortcuts

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