Documentation
¶
Overview ¶
Package reducer implements the framework-neutral state machine shared by realtime clients. It deliberately owns protocol state, not transports, devices, effects, or views. Those adapters feed operations in and execute the returned OpenAI Realtime commands.
Index ¶
- Constants
- func CompareResult(expect Expectation, actual Result) error
- func CorpusSource() ([]byte, error)
- func JavaScriptSource() ([]byte, error)
- func SwiftSourceDigest() (string, error)
- func ValidateCorpusJSON(payload []byte) error
- type ConnectionSnapshot
- type ConversationItem
- type Corpus
- type Expectation
- type Limits
- type NegotiationSnapshot
- type Operation
- type PlayoutSnapshot
- type ProtocolEntry
- type Reducer
- type ResponseSnapshot
- type Result
- type SessionSnapshot
- type Snapshot
- type Step
- type ToolCall
- type TruncationSnapshot
- type Vector
- type VideoSnapshot
Constants ¶
const ( FormatVersion = 1 MaxCorpusBytes = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
func CompareResult ¶
func CompareResult(expect Expectation, actual Result) error
func CorpusSource ¶
func JavaScriptSource ¶
func SwiftSourceDigest ¶
SwiftSourceDigest binds a native implementation selection to the exact portable reducer/package sources that are compiled into it.
func ValidateCorpusJSON ¶
ValidateCorpusJSON is exposed for non-file adapters and fuzz tests. It is intentionally just as strict as LoadCorpus.
Types ¶
type ConnectionSnapshot ¶
type ConversationItem ¶
type Corpus ¶
type Expectation ¶
type Expectation struct {
Snapshot Snapshot `json:"snapshot"`
Outbound []json.RawMessage `json:"outbound"`
Errors []string `json:"errors"`
}
type Limits ¶
type Limits struct {
MaxVectors int `json:"max_vectors"`
MaxStepsPerVector int `json:"max_steps_per_vector"`
MaxEventBytes int `json:"max_event_bytes"`
MaxStringBytes int `json:"max_string_bytes"`
MaxConversationItems int `json:"max_conversation_items"`
MaxToolCalls int `json:"max_tool_calls"`
MaxOutboundEvents int `json:"max_outbound_events"`
MaxProtocolLogEntries int `json:"max_protocol_log_entries"`
MaxErrorsPerVector int `json:"max_errors_per_vector"`
MaxReconnectAttempts int `json:"max_reconnect_attempts"`
MaxVirtualTimeMS int64 `json:"max_virtual_time_ms"`
}
Limits are part of the corpus format so every language applies the same resource ceilings before reducing attacker-controlled protocol messages.
func DefaultLimits ¶
func DefaultLimits() Limits
type NegotiationSnapshot ¶
type Operation ¶
type Operation struct {
Kind string `json:"kind"`
Transport string `json:"transport,omitempty"`
Reason string `json:"reason,omitempty"`
Event json.RawMessage `json:"event,omitempty"`
Session json.RawMessage `json:"session,omitempty"`
ItemID string `json:"item_id,omitempty"`
Text string `json:"text,omitempty"`
Speaking bool `json:"speaking,omitempty"`
PlayedMS int64 `json:"played_ms,omitempty"`
CallID string `json:"call_id,omitempty"`
Status string `json:"status,omitempty"`
Output string `json:"output,omitempty"`
Error string `json:"error,omitempty"`
// contains filtered or unexported fields
}
Operation is the portable adapter boundary. Fields not used by Kind are rejected; this prevents a malformed vector from being interpreted differently by permissive decoders in another language.
func (*Operation) UnmarshalJSON ¶
type PlayoutSnapshot ¶
type ProtocolEntry ¶
type Reducer ¶
type Reducer struct {
// contains filtered or unexported fields
}
func (*Reducer) Outbound ¶
func (reducer *Reducer) Outbound() []json.RawMessage
type ResponseSnapshot ¶
type SessionSnapshot ¶
type SessionSnapshot struct {
ID string `json:"id"`
ManualTurns bool `json:"manual_turns"`
OpenRealtime NegotiationSnapshot `json:"openrealtime"`
}
type Snapshot ¶
type Snapshot struct {
NowMS int64 `json:"now_ms"`
Connection ConnectionSnapshot `json:"connection"`
Session SessionSnapshot `json:"session"`
Response ResponseSnapshot `json:"response"`
Conversation []ConversationItem `json:"conversation"`
Playout PlayoutSnapshot `json:"playout"`
Tools []ToolCall `json:"tools"`
LastTruncation TruncationSnapshot `json:"last_truncation"`
LastError string `json:"last_error"`
ProtocolLog []ProtocolEntry `json:"protocol_log"`
}