Documentation
¶
Overview ¶
Package agentbridge defines the framework-neutral seam through which a SpeechKit host fronts an external coding agent (adopted 2026-08-10, AI-VOICE-SPEECHKIT-TARGET.md "External Coding Agent Bridge"). The first implementation drives the official OpenAI Codex binary (agentbridge/codex); a Claude Code adapter can implement the same seam later. The seam abstracts at the "coding agent session" level — start/steer/interrupt/status/events/approvals — never at the wire-protocol level of any one CLI.
Security posture is fail-closed by design: the bridge only *detects* the agent CLI's own login, never implements or refreshes OAuth material; side-effectful sandbox levels require explicit per-project configuration; and approval decisions are host-UI actions, deliberately not part of any model-invocable tool surface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotInstalled = errors.New("agentbridge: agent binary not installed") ErrNotSignedIn = errors.New("agentbridge: agent binary installed but not signed in") ErrUnsupported = errors.New("agentbridge: operation not supported in the current mode") ErrBusy = errors.New("agentbridge: another turn is already running") )
Sentinel errors implementations return so hosts can degrade with honest, speakable messages.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent interface {
// Status reports installation, auth, and transport capability.
Status(ctx context.Context) Status
// StartTurn acknowledges fast (well under a second) while the turn keeps
// running asynchronously; progress arrives on Events.
StartTurn(ctx context.Context, req TurnRequest) (ThreadRef, error)
// Steer injects mid-turn guidance. Exec-mode implementations return
// ErrUnsupported.
Steer(ctx context.Context, ref ThreadRef, text string) error
// Interrupt stops the running turn.
Interrupt(ctx context.Context, ref ThreadRef) error
// RespondApproval answers a pending ApprovalRequest by ID.
RespondApproval(ctx context.Context, id string, d Decision) error
// Events returns the normalized event stream. Closed by Close.
Events() <-chan Event
Close() error
}
Agent is the external-coding-agent seam. Implementations must be safe for concurrent use by one host.
type ApprovalRequest ¶
type ApprovalRequest struct {
ID string
Kind string // "command" | "patch"
Command string // exact command line for the command kind
Summary string
Cwd string
}
ApprovalRequest asks the host to approve a side effect. The host renders Command/Summary verbatim from agent-delivered data — never from model paraphrase — and answers via Agent.RespondApproval.
type AuthMethod ¶
type AuthMethod string
AuthMethod describes how the external agent CLI is signed in.
const ( AuthChatGPT AuthMethod = "chatgpt" // agent CLI holds a ChatGPT-subscription login AuthAPIKey AuthMethod = "api_key" // agent CLI is configured with a platform API key AuthNone AuthMethod = "none" // installed but not signed in )
type Event ¶
type Event struct {
Type EventType
ThreadID string
TurnID string
Item *Item
Approval *ApprovalRequest
Err string
}
Event is the normalized stream a host consumes.
type EventType ¶
type EventType string
EventType enumerates normalized bridge events.
const ( EventThreadStarted EventType = "thread_started" EventTurnStarted EventType = "turn_started" EventItemStarted EventType = "item_started" EventItemCompleted EventType = "item_completed" EventTurnCompleted EventType = "turn_completed" EventApprovalRequested EventType = "approval_requested" EventBridgeState EventType = "bridge_state" EventError EventType = "error" )
type Item ¶
type Item struct {
Kind string // agent_message | reasoning | command_execution | file_change | mcp_tool_call | web_search | ...
Summary string // short human-readable description of the item
}
Item is one unit of agent work (message, reasoning, command, file change).
type Project ¶
type Project struct {
Alias string // spoken-friendly unique name ("speechkit")
Path string // absolute directory
Sandbox SandboxMode
}
Project is an allowlisted working directory the agent may operate in.
type SandboxMode ¶
type SandboxMode string
SandboxMode is the execution sandbox ceiling for agent turns. "danger-full-access" is deliberately unrepresentable.
const ( SandboxReadOnly SandboxMode = "read-only" SandboxWorkspaceWrite SandboxMode = "workspace-write" )
type Status ¶
type Status struct {
Installed bool
BinaryPath string
Version string
Auth AuthMethod
Plan string // best-effort plan label ("plus", "pro", ...); empty when unknown
Mode Mode
Detail string // human-readable degradation reason; speakable
}
Status reports the bridge's current capability, in terms a host can render or speak verbatim. It never contains token material.
type ThreadRef ¶
ThreadRef identifies the turn that was started. ThreadID may be empty on a fresh thread until the implementation reports it via EventThreadStarted.
type TurnRequest ¶
type TurnRequest struct {
Project Project
Prompt string
ThreadID string // non-empty = resume/continue that thread
Sandbox SandboxMode
}
TurnRequest starts (or continues) one agent turn.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package codex drives the official OpenAI Codex binary as an agentbridge.Agent.
|
Package codex drives the official OpenAI Codex binary as an agentbridge.Agent. |
|
Package voicetools binds an agentbridge.Agent to the voice agent's tool surface with the "Call GPT" semantics (owner decision 2026-08-10, AI-VOICE-SPEECHKIT-TARGET.md External Coding Agent Bridge):
|
Package voicetools binds an agentbridge.Agent to the voice agent's tool surface with the "Call GPT" semantics (owner decision 2026-08-10, AI-VOICE-SPEECHKIT-TARGET.md External Coding Agent Bridge): |