Documentation
¶
Overview ¶
Package appserver 用 Codex app-server 协议服务 Codex 客户端(Codex TUI、Paseo):每条 Codex 连接经 runtimeclient 连共享的 serve(本机的,或命令行、配置指定的远端),把 Codex 请求翻译成 OpenVaala 协议,再把 OpenVaala 事件翻译成 Codex 通知。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AppServer ¶
type AppServer interface {
// Run 服务到 ctx 结束;监听失败时提前返回,stdio 模式在输入结束或与 serve 断开时也返回。返回前关闭全部连接并等待它们的任务。
// stdio 输入结束时返回 nil,与 serve 断开时返回 runtimeclient.ErrConnectionLost;监听模式在 ctx 结束时返回 ctx.Err()。
Run(ctx context.Context) error
}
AppServer 用 Codex app-server 协议服务客户端:stdio 模式只服务一条连接,监听模式服务每个接入的连接; 每条连接通过 runtimeclient 连共享 serve,把 Codex 请求翻译成 OpenVaala 协议。
func NewAppServer ¶
func NewAppServer(opt *AppServerOpt) (AppServer, error)
NewAppServer 校验依赖和连接入口,创建 AppServer。
type AppServerOpt ¶
type AppServerOpt struct {
// RuntimeServer 为每条连接选择要连的 serve。
RuntimeServer RuntimeServerLocator
// AgentName 是新建对话使用的 Agent。
AgentName string
// Version 写进 initialize 的 userAgent 和 Thread.cliVersion。
Version string
// ConfigDirectory 作为 initialize 的 codexHome 返回。
ConfigDirectory string
Telemetry *telemetry.Telemetry
// PathMappings 把 Codex 客户端给的目录换成 serve 路径(新建对话的 cwd、skills/list、thread/list 的筛选),
// 再把对话归属的目录换回客户端路径写进 Thread 的 cwd;其他路径原样返回。
PathMappings config.PathMappings
// Input、Output 是 stdio 模式的协议流,每行一条 JSON。
Input io.ReadCloser
Output io.WriteCloser
// Listener 非空时改为监听模式,按 WebSocket 收发。
Listener net.Listener
}
AppServerOpt 指定连哪个 serve、新对话用哪个 Agent,以及 stdio 和监听两种入口用哪一种。
func NewAppServerOpt ¶
func NewAppServerOpt(runtimeServer RuntimeServerLocator, agentName string) *AppServerOpt
NewAppServerOpt 设置 serve 查询入口和新对话使用的 Agent。
func (*AppServerOpt) WithListener ¶
func (opt *AppServerOpt) WithListener(listener net.Listener) *AppServerOpt
WithListener 设置接收 WebSocket 连接的监听器。
func (*AppServerOpt) WithStdio ¶
func (opt *AppServerOpt) WithStdio(input io.ReadCloser, output io.WriteCloser) *AppServerOpt
WithStdio 设置按行收发消息的 stdio 模式。
type RuntimeServerInfo ¶
type RuntimeServerInfo struct {
URL string
Token string // 为空时沿用 URL 里的 ?token=
// Source 是地址的来源:--url、client.url 或 local,写进连接日志。
Source string
// LocalServerID 是本机 runtime-server.yaml 里的 server_id,文件不存在或读不出来时为空;
// 连上后和 serve 返回的 server_id 比较,判断连的是不是本机 serve。
LocalServerID string
}
RuntimeServerInfo 是连接 serve 要用的 OpenVaala 协议地址和 token,以及地址的来源和本机 server_id。
type RuntimeServerLocator ¶
type RuntimeServerLocator interface {
// GetRuntimeServer 返回地址、token、地址来源和本机 server_id;本机 serve 没在运行时启动它。
GetRuntimeServer(ctx context.Context) (RuntimeServerInfo, error)
}
RuntimeServerLocator 为每条 Codex 连接选择 serve,支持并发查询。
Click to show internal directories.
Click to hide internal directories.