codex

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, codexPath string, opts Options, in io.Reader, out io.Writer, logger *slog.Logger) error

Run is the convenience entry point for standalone usage: spawn codex, serve ACP over in/out until the connection ends, codex exits, or ctx is cancelled.

Types

type Agent

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

Agent implements acp.Agent for the codex app-server. It manages the long-lived `codex app-server` subprocess transparently (see Spawn) and exposes only ACP session-scoped operations to the host. Embed it in a host process via Spawn or Run — no separate ACP server binary is required.

func Spawn

func Spawn(ctx context.Context, codexPath string, opts Options) (*Agent, error)

Spawn starts a `codex app-server` subprocess and returns an Agent that talks to it. Use Agent.Close (or rely on ctx cancellation) to terminate the subprocess. The agent is ready to be wired into an acp.AgentSideConnection via Agent.SetAgentConnection.

codexPath is the path to (or PATH name of) the `codex` binary; empty defaults to "codex".

func (*Agent) Cancel

func (a *Agent) Cancel(ctx context.Context, params acp.CancelNotification) error

func (*Agent) Close

func (a *Agent) Close() error

Close terminates the codex subprocess. Idempotent.

func (*Agent) CloseSession

func (a *Agent) CloseSession(_ context.Context, params acp.CloseSessionRequest) (acp.CloseSessionResponse, error)

func (*Agent) Done

func (a *Agent) Done() <-chan struct{}

Done returns a channel closed when the codex subprocess exits.

func (*Agent) Initialize

func (*Agent) ListSessions

func (a *Agent) ListSessions(ctx context.Context, params acp.ListSessionsRequest) (acp.ListSessionsResponse, error)

func (*Agent) LoadSession

func (a *Agent) LoadSession(ctx context.Context, params acp.LoadSessionRequest) (acp.LoadSessionResponse, error)

func (*Agent) NewSession

func (a *Agent) NewSession(ctx context.Context, params acp.NewSessionRequest) (acp.NewSessionResponse, error)

func (*Agent) Prompt

func (a *Agent) Prompt(ctx context.Context, params acp.PromptRequest) (acp.PromptResponse, error)

func (*Agent) ResumeSession

func (a *Agent) ResumeSession(ctx context.Context, params acp.ResumeSessionRequest) (acp.ResumeSessionResponse, error)

func (*Agent) SetAgentConnection

func (a *Agent) SetAgentConnection(conn *acp.AgentSideConnection)

func (*Agent) SetSessionMode

type Options

type Options struct {
	// Model is the default model id used for new sessions. Empty / "default"
	// defers to codex's configured default.
	Model string

	// Effort is the default reasoning effort applied to new sessions.
	// Empty / "default" disables the override.
	Effort string

	// Env is the environment for the `codex app-server` subprocess. nil
	// means inherit the parent process env. To layer Wingman routing on
	// top, callers can pass
	// `pkg/external/codex.BuildEnv(os.Environ(), cfg)`.
	Env []string

	// ExtraArgs are extra CLI args prefixed before `app-server`. Use this
	// for top-level codex flags such as the `--config` pairs returned by
	// `pkg/external/codex.BuildArgs`.
	ExtraArgs []string
}

Options configures the codex subprocess and the Agent's defaults for new sessions.

Jump to

Keyboard shortcuts

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