Documentation
¶
Overview ¶
Package codex adapts the Codex CLI to the agent Runtime contract. 使用 codex app-server --listen stdio:// 模式进行通信。
Package codex provides the Codex CLI Runtime type.
Index ¶
- Constants
- type Adapter
- type AppServer
- func (s *AppServer) Close() error
- func (s *AppServer) PID() int
- func (s *AppServer) PendingApproval() *ServerRequest
- func (s *AppServer) RespondApproval(ctx context.Context, reqID sonic.NoCopyRawMessage, decision string) error
- func (s *AppServer) ResumeThread(ctx context.Context, threadID string, modelCfg agent.ModelConfig, ...) error
- func (s *AppServer) SetEventChannel(ch chan<- agent.NodeEvent)
- func (s *AppServer) SetPendingApproval(req *ServerRequest)
- func (s *AppServer) SetThreadID(threadID string)
- func (s *AppServer) SetTurnID(id string)
- func (s *AppServer) StartThread(ctx context.Context, modelCfg agent.ModelConfig, systemPrompt string) (string, error)
- func (s *AppServer) StartTurn(ctx context.Context, threadID string, prompt string) (string, error)
- func (s *AppServer) Stop() error
- func (s *AppServer) ThreadID() string
- func (s *AppServer) TurnID() string
- type AppServerInvoker
- type Client
- func (c *Client) Call(ctx context.Context, method string, params any, result any) error
- func (c *Client) Close()
- func (c *Client) Notify(method string, params any) error
- func (c *Client) ReadLoop(ctx context.Context) error
- func (c *Client) Respond(id sonic.NoCopyRawMessage, result any) error
- func (c *Client) RespondError(id sonic.NoCopyRawMessage, code int, message string) error
- type Runtime
- type ServerRequest
Constants ¶
const ( // Kind is the canonical runtime kind for Codex CLI. Kind = agent.RuntimeKindCodex )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter 通过 Codex CLI app-server 模式执行提示。
func NewAdapter ¶
NewAdapter 创建 Codex CLI 引擎适配器(app-server 模式)。
func (*Adapter) GetSkillDir ¶
GetSkillDir returns the skill directory path for Codex CLI.
func (*Adapter) Invoke ¶
func (a *Adapter) Invoke(ctx context.Context, req cli.InvocationRequest) (*cli.Invocation, error)
Invoke starts Codex CLI and returns its process activity stream.
type AppServer ¶
type AppServer struct {
// contains filtered or unexported fields
}
AppServer 管理一个 codex app-server 进程。
func (*AppServer) PendingApproval ¶
func (s *AppServer) PendingApproval() *ServerRequest
func (*AppServer) RespondApproval ¶
func (*AppServer) ResumeThread ¶
func (*AppServer) SetEventChannel ¶
func (*AppServer) SetPendingApproval ¶
func (s *AppServer) SetPendingApproval(req *ServerRequest)
func (*AppServer) SetThreadID ¶
SetThreadID 设置当前 thread ID(供 invoker 使用)。
func (*AppServer) StartThread ¶
type AppServerInvoker ¶
type AppServerInvoker struct {
// contains filtered or unexported fields
}
func NewAppServerInvoker ¶
func NewAppServerInvoker(binary string, extraEnv map[string]string) *AppServerInvoker
func (*AppServerInvoker) Invoke ¶
func (inv *AppServerInvoker) Invoke(ctx context.Context, req cli.InvocationRequest) (*cli.Invocation, error)
type Client ¶
type Client struct {
// 回调:由上层设置
OnNotification func(method string, params sonic.NoCopyRawMessage)
OnServerRequest func(req ServerRequest)
// contains filtered or unexported fields
}
Client 是 JSON-RPC 2.0 客户端,基于独立的 reader/writer 进行行分隔的 JSON 通信。
func NewClientWithScanner ¶
NewClientWithScanner 使用已有的 scanner 创建客户端。 用于 initialize 阶段已通过独立 scanner 读取首行响应后, 继续复用同一个 scanner(避免 bufio 内部缓冲区数据丢失)。
func (*Client) Respond ¶
func (c *Client) Respond(id sonic.NoCopyRawMessage, result any) error
Respond 响应来自 app-server 的请求(如审批决策)。
func (*Client) RespondError ¶
RespondError 响应给 app-server 返回错误。
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime executes requests through Codex CLI.
func NewWithInvoker ¶
NewWithInvoker creates a Codex Runtime with an injected process invoker.
func (*Runtime) Execute ¶
func (r *Runtime) Execute( ctx context.Context, request agent.ExecutionRequest, observer agent.NodeObserver, ) (agent.ExecutionResult, error)
type ServerRequest ¶
type ServerRequest struct {
ID sonic.NoCopyRawMessage
Method string
Params sonic.NoCopyRawMessage
}
ServerRequest 表示来自 Codex app-server 的请求(需要客户端响应)。