Documentation
¶
Overview ¶
Package cli 定义 openvaala 命令行:加载配置,运行 TUI、serve、web、acp、app-server、codex、reindex、plugin 和 config 命令。
Index ¶
- func BuildCLIHandler(handler func(context.Context, *AppArgs) error) func(*cobra.Command, []string) error
- func GetConfigFlags(flags *pflag.FlagSet) ([]string, error)
- func GetWebUIURL(runtimeURL, token string) (string, error)
- func NewCLI(opt *CLIOpt) *cobra.Command
- type AppArgs
- type CLIFlags
- type CLIOpt
- type RuntimeServerConnection
- type RuntimeServerStartOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCLIHandler ¶
func BuildCLIHandler(handler func(context.Context, *AppArgs) error) func(*cobra.Command, []string) error
BuildCLIHandler 包装 handler 成 RunE:先加载配置、收集命令参数,再调用 handler。
func GetConfigFlags ¶
GetConfigFlags 收集显式传入的 --config-file、--agents-dir、--models-dir 和 --agent,写成 --name=value。
func GetWebUIURL ¶
GetWebUIURL 将服务连接地址转成 WebUI 地址,并把登录令牌放在 fragment 中。
Types ¶
type AppArgs ¶
type AppArgs struct {
Config *config.Config
Stdin io.Reader
Stdout io.Writer
// RuntimeURL 是 --url 指定的 Runtime Server 地址;为空时 getRuntimeConnection 依次用 client.url、本机 serve(没有就自动拉起)。
RuntimeURL string
// Stderr 接收 serve、acp 和 app-server 的文本日志,以及客户端的旧 serve 提示;codex 子进程使用它,正常退出后追加重连提示。TUI 不使用。
Stderr io.Writer
// Version 是程序版本,写入遥测的 service.version。
Version string
// IdleTimeout 是 serve 的隐藏参数 --idle-timeout:大于 0 时没有连接且没有 Turn 在执行这么久后 serve 自己退出;为 0 时常驻。
IdleTimeout time.Duration
// ConfigFlags 保存显式传入的配置文件、Agent 目录、模型目录和 Agent 名称,格式为 --name=value;仅配置文件转为绝对路径。自动启动 serve 时原样传入,不含 Codex 的 -c/--config。
ConfigFlags []string
// Executable 是当前进程的可执行文件路径,客户端用它自动拉起 serve;取不到时为空,拉起 serve 会失败。
Executable string
// ConfigPath 是读取的配置文件的绝对路径(--config-file、OPENVAALA_CONFIG 或默认位置);app-server 把它所在目录交给 Codex 客户端。
ConfigPath string
// ConfigOpt 是加载 Config 用的选项;serve 把它交给 config.ConfigFiles,重新加载时用同一个配置路径和 flag。
ConfigOpt *config.LoadConfigOpt
// AppServerListen 是 app-server 的 --listen,默认 stdio://。
AppServerListen string
// IsAppServerStdio 是否传入了 --stdio?
IsAppServerStdio bool
// PrintAppServerStartupConfig 是否只输出 Codex 桌面启动检查需要的 JSON,然后退出?
PrintAppServerStartupConfig bool
// UnsupportedWebSocketFlags 是 app-server 收到的 codex WebSocket 认证参数名(--ws-auth 等):OpenVaala 不支持,出现就报错。
UnsupportedWebSocketFlags []string
// IgnoredCodexFlags 是用户传入的 codex 参数名(-c/--config、--enable、--disable、--strict-config,
// 以及 app-server 的分析、code-mode、remote-control 和启动客户端、退出登录参数);普通 app-server 启动时写一条 Debug 日志。
IgnoredCodexFlags []string
// CodexRootArguments 是用户传入的 codex 根命令参数,按 codex 的写法排好(-c k=v、--enable x、--disable y、--strict-config);
// openvaala codex 把它们交给 codex,app-server 等命令收下不用。
CodexRootArguments []string
// CodexArguments 是 openvaala codex 之后的参数(codex 自己的参数写在 -- 之后),接在 CodexRootArguments 之后交给 codex;
// codex app 时是可选的一个工作目录。其他命令不收位置参数,为空。
CodexArguments []string
}
AppArgs 保存已加载的配置、命令参数、标准流和版本。
type CLIFlags ¶
type CLIFlags struct {
ConfigFilePath string
AgentsDirectory string
ModelsDirectory string
AgentName string
}
CLIFlags 保存 Cobra 直接解析的参数;是否显式传入由 Cobra 的 Changed 状态判断。
type RuntimeServerConnection ¶
type RuntimeServerConnection struct {
URL string `yaml:"url"`
Token string `yaml:"token"`
// Executable 是 serve 的可执行文件路径(软链接已解析),取不到时为空;客户端拿它和自己的可执行文件比较,发现升级或重新编译前的旧 serve。
Executable string `yaml:"executable"`
// ExecutableModifiedAt 是 serve 启动时 Executable 的修改时间,取不到时为零值。
ExecutableModifiedAt time.Time `yaml:"executable_modified_at"`
// ServerID 标识这台机器上的 serve,重启后沿用;客户端读到的和 initialize 返回的一致时,两边用的是同一个文件系统。
ServerID string `yaml:"server_id"`
}
RuntimeServerConnection 是 serve 启动后写入 ~/.local/state/openvaala/runtime-server.yaml 的连接信息,本机客户端读它来连接。
func EnsureRuntimeServer ¶
func EnsureRuntimeServer(ctx context.Context, opt *RuntimeServerStartOpt) (connection RuntimeServerConnection, err error)
EnsureRuntimeServer 复用能访问的本机 serve,没有时在后台拉起并等待就绪;空闲时长为 0 时新进程常驻。
Click to show internal directories.
Click to hide internal directories.