Documentation
¶
Overview ¶
Package codex drives the official OpenAI Codex binary as an agentbridge.Agent. Two transports behind one seam: the stateful `codex app-server` JSON-RPC connection (primary — steer, interrupt, and approval round-trips) and `codex exec --json` one-shot turns (fallback). Wire shapes are pinned against `codex app-server generate-json-schema` from codex-cli 0.147.0; unknown notifications and fields are tolerated.
Auth is detection-only: the user signs the Codex CLI in themselves (ChatGPT subscription or API key), the bridge reads nothing beyond the sign-in method and plan label, and a policy reversal on OpenAI's side degrades to API-key-authed Codex with zero code change here.
Index ¶
- type Bridge
- func (b *Bridge) Close() error
- func (b *Bridge) Events() <-chan agentbridge.Event
- func (b *Bridge) Interrupt(ctx context.Context, ref agentbridge.ThreadRef) error
- func (b *Bridge) LastThreadRef() agentbridge.ThreadRef
- func (b *Bridge) RespondApproval(_ context.Context, id string, d agentbridge.Decision) error
- func (b *Bridge) StartTurn(ctx context.Context, req agentbridge.TurnRequest) (agentbridge.ThreadRef, error)
- func (b *Bridge) Status(ctx context.Context) agentbridge.Status
- func (b *Bridge) Steer(ctx context.Context, ref agentbridge.ThreadRef, text string) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge struct {
// contains filtered or unexported fields
}
Bridge implements agentbridge.Agent against the codex CLI. One turn runs at a time; concurrent StartTurn returns ErrBusy.
func New ¶
New constructs the bridge. Construction never fails — capability is reported honestly through Status so hosts can render/speak the reason.
func (*Bridge) Close ¶
Close implements agentbridge.Agent: interrupts running work, denies pending approvals, and closes the event stream.
func (*Bridge) Events ¶
func (b *Bridge) Events() <-chan agentbridge.Event
Events implements agentbridge.Agent.
func (*Bridge) LastThreadRef ¶
func (b *Bridge) LastThreadRef() agentbridge.ThreadRef
LastThreadRef returns the most recently observed thread reference — the default target for "continue working on that" follow-up turns.
func (*Bridge) RespondApproval ¶
RespondApproval implements agentbridge.Agent. Only app-server mode raises approvals; exec mode runs non-interactively.
func (*Bridge) StartTurn ¶
func (b *Bridge) StartTurn(ctx context.Context, req agentbridge.TurnRequest) (agentbridge.ThreadRef, error)
StartTurn implements agentbridge.Agent (fast-ack; the turn continues in the background and progress arrives on Events).
type Config ¶
type Config struct {
// BinaryPath pins the codex binary; empty means PATH lookup.
BinaryPath string
// CodexHome overrides the auth-detection directory (tests); empty means
// $CODEX_HOME or ~/.codex.
CodexHome string
// Mode selects the transport: "auto" (default; app-server with exec
// fallback), "app_server", or "exec".
Mode string
// ClientVersion is reported in the app-server initialize handshake.
ClientVersion string
// EventBuffer sizes the Events channel; default 64.
EventBuffer int
// Logger defaults to slog.Default().
Logger *slog.Logger
}
Config configures the bridge. All fields are optional.