deviceagent

package
v0.70.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: Apache-2.0 Imports: 13 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 deviceagent implements the credential-minimal LAN-side SpeechKit device-agent client and its versioned wire contract.

Index

Constants

View Source
const (
	// CurrentProtocolVersion is the only version emitted or accepted by the
	// credential-minimal local bridge. The v0 protocol constant was removed
	// in v0.68.0; v0 clients never had server-owned pairing or authority
	// guarantees.
	CurrentProtocolVersion = "speechkit.device_agent.v1"

	CapabilityReady       = "ready"
	CapabilityUnavailable = "unavailable"
	CapabilityUnverified  = "unverified"
	ServerInstanceHeader  = "X-SpeechKit-Server-Instance-ID"
)

Variables

View Source
var (
	ErrMissingServerURL               = errors.New("speechkit deviceagent: server_url is required")
	ErrMissingPairingToken            = errors.New("speechkit deviceagent: pairing_token is required")
	ErrPairingTokenTooShort           = errors.New("speechkit deviceagent: pairing_token must contain at least 32 bytes")
	ErrPairingTokenInvalid            = errors.New("speechkit deviceagent: pairing_token must be a bounded bearer credential")
	ErrMissingExpectedServerInstance  = errors.New("speechkit deviceagent: expected_server_instance_id is required")
	ErrMissingExpectedPairingID       = errors.New("speechkit deviceagent: expected_pairing_id is required")
	ErrMissingAssistText              = errors.New("speechkit deviceagent: assist text is required")
	ErrMissingCommandID               = errors.New("speechkit deviceagent: command_id is required")
	ErrServerIdentityMismatch         = errors.New("speechkit deviceagent: server instance identity mismatch")
	ErrServerIdentityMissing          = errors.New("speechkit deviceagent: server instance identity header is missing")
	ErrPairingIdentityMismatch        = errors.New("speechkit deviceagent: pairing epoch identity mismatch")
	ErrAssistResponseMismatch         = errors.New("speechkit deviceagent: assist response does not match the request")
	ErrResponseTooLarge               = errors.New("speechkit deviceagent: server response exceeds the protocol limit")
	ErrInsecureServerTransport        = errors.New("speechkit deviceagent: plaintext HTTP is allowed only for a loopback server")
	ErrHomeAssistantBridgeUnavailable = errors.New("speechkit deviceagent: Home Assistant bridge is not ready")
	ErrTTSBridgeUnavailable           = errors.New("speechkit deviceagent: TTS bridge is not ready")
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Agent, error)

func (*Agent) Publish

func (a *Agent) Publish(ctx context.Context, ev Event) error

func (*Agent) Register

func (a *Agent) Register(ctx context.Context) (*RegistrationAck, error)

func (*Agent) RunFakeAssistCycle

func (a *Agent) RunFakeAssistCycle(ctx context.Context, opts CycleOptions) (*CycleResult, error)

type AssistRequest added in v0.50.0

type AssistRequest struct {
	RequestID string `json:"request_id"`
	SessionID string `json:"session_id"`
	CommandID string `json:"command_id"`
	DeviceID  string `json:"device_id"`
	RoomID    string `json:"room_id"`
	Text      string `json:"text"`
	Locale    string `json:"locale"`
}

type AssistResponse added in v0.50.0

type AssistResponse struct {
	Status         string `json:"status"`
	RequestID      string `json:"request_id"`
	ConversationID string `json:"conversation_id,omitempty"`
	ResponseType   string `json:"response_type,omitempty"`
	Speech         string `json:"speech,omitempty"`
	ActionExecuted string `json:"action_executed"` // yes | no | unknown
	Replayed       bool   `json:"replayed"`
	ErrorCode      string `json:"error_code,omitempty"`
	ReasonCode     string `json:"reason_code,omitempty"`
	Retryable      bool   `json:"retryable"`
	UserGuidance   string `json:"user_guidance,omitempty"`
}

type AudioDevice

type AudioDevice struct {
	ID        string `json:"id"`
	Name      string `json:"name,omitempty"`
	Kind      string `json:"kind"` // microphone | speaker
	Transport string `json:"transport,omitempty"`
}

type BridgeCapabilities added in v0.50.0

type BridgeCapabilities struct {
	HomeAssistant CapabilityState `json:"home_assistant"`
	TTS           CapabilityState `json:"tts"`
}

type BridgeError added in v0.50.0

type BridgeError struct {
	ErrorCode      string `json:"error_code"`
	ReasonCode     string `json:"reason_code"`
	Retryable      bool   `json:"retryable"`
	ActionExecuted string `json:"action_executed"`
	UserGuidance   string `json:"user_guidance"`
}

type Capabilities

type Capabilities struct {
	Dictation     bool `json:"dictation"`
	Assist        bool `json:"assist"`
	VoiceAgent    bool `json:"voice_agent"`
	WakewordLocal bool `json:"wakeword_local"`
	TTS           bool `json:"tts"`
	BargeIn       bool `json:"barge_in"`
}

Capabilities are device-reported facts. Pairing and server-side bridge readiness are deliberately absent: only the server can attest those.

type CapabilityState added in v0.50.0

type CapabilityState struct {
	Status     string `json:"status"`
	ReasonCode string `json:"reason_code,omitempty"`
}

type Config

type Config struct {
	ServerURL                string
	PairingToken             string
	ExpectedServerInstanceID string
	ExpectedPairingID        string
	UserAgent                string
	Device                   DeviceDescriptor
	Capabilities             Capabilities
	Health                   Health
	Locale                   string
}

Config describes a v1 device agent. Authentication is PairingToken only; Home Assistant authority, credentials and the HTTP transport policy are server-owned and cannot be supplied by the device.

type CycleOptions

type CycleOptions struct {
	RequestID string
	SessionID string
	CommandID string
	Text      string
	Locale    string
}

type CycleResult

type CycleResult struct {
	RequestID      string  `json:"request_id"`
	SessionID      string  `json:"session_id"`
	SpokenText     string  `json:"spoken_text"`
	ConversationID string  `json:"conversation_id,omitempty"`
	ResponseType   string  `json:"response_type,omitempty"`
	TTSProvider    string  `json:"tts_provider,omitempty"`
	Replayed       bool    `json:"replayed"`
	Events         []Event `json:"events"`
}

type DeviceDescriptor

type DeviceDescriptor struct {
	AgentID       string      `json:"agent_id"`
	DeviceID      string      `json:"device_id"`
	DisplayName   string      `json:"display_name,omitempty"`
	RoomID        string      `json:"room_id"`
	CaptureDevice AudioDevice `json:"capture_device"`
	OutputDevice  AudioDevice `json:"output_device"`
	Wakeword      Wakeword    `json:"wakeword"`
}

type ErrorEnvelope added in v0.50.0

type ErrorEnvelope struct {
	Error BridgeError `json:"error"`
}

type Event

type Event struct {
	Type          string            `json:"type"`
	Surface       string            `json:"surface"`
	Mode          string            `json:"mode"`
	RequestID     string            `json:"request_id,omitempty"`
	SessionID     string            `json:"session_id,omitempty"`
	DeviceID      string            `json:"device_id"`
	RoomID        string            `json:"room_id"`
	CapturePolicy string            `json:"capture_policy,omitempty"`
	Transport     string            `json:"transport,omitempty"`
	Text          string            `json:"text,omitempty"`
	SpeakText     string            `json:"speak_text,omitempty"`
	ReasonCode    string            `json:"reason_code,omitempty"`
	At            time.Time         `json:"at"`
	Metadata      map[string]string `json:"metadata,omitempty"`
}

type EventAck added in v0.50.0

type EventAck struct {
	Status string `json:"status"`
}

type HTTPError added in v0.50.0

type HTTPError struct {
	Method     string
	Path       string
	StatusCode int
	Envelope   ErrorEnvelope
}

func (*HTTPError) Error added in v0.50.0

func (e *HTTPError) Error() string

type Health

type Health struct {
	Status       string `json:"status"`
	CaptureReady bool   `json:"capture_ready"`
	OutputReady  bool   `json:"output_ready"`
	WakeReady    bool   `json:"wake_ready"`
}

type Registration

type Registration struct {
	Version      string           `json:"version"`
	RegisteredAt time.Time        `json:"registered_at"`
	Device       DeviceDescriptor `json:"device"`
	Capabilities Capabilities     `json:"capabilities"`
	Health       Health           `json:"health"`
}

Registration is the device-asserted half of the v1 handshake. Pairing state is never part of it; the server attests pairing in RegistrationAck.

type RegistrationAck

type RegistrationAck struct {
	Status           string             `json:"status"`
	PairingID        string             `json:"pairing_id"`
	ServerInstanceID string             `json:"server_instance_id"`
	ServerTime       string             `json:"server_time,omitempty"`
	Capabilities     BridgeCapabilities `json:"capabilities"`
}

type TTSRequest added in v0.50.0

type TTSRequest struct {
	RequestID string `json:"request_id"`
	Format    string `json:"format"`
}

type TTSResponse added in v0.50.0

type TTSResponse struct {
	RequestID   string `json:"request_id"`
	AudioBase64 string `json:"audio_base64"`
	Format      string `json:"format"`
	SampleRate  int    `json:"sample_rate"`
	DurationMS  int64  `json:"duration_ms"`
	Provider    string `json:"provider"`
	Voice       string `json:"voice,omitempty"`
}

type Wakeword

type Wakeword struct {
	Enabled bool   `json:"enabled"`
	Phrase  string `json:"phrase,omitempty"`
	Backend string `json:"backend,omitempty"`
	Status  string `json:"status"`
}

Jump to

Keyboard shortcuts

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