Documentation
¶
Overview ¶
Package engine 定义 AI 编程引擎的无头执行抽象,以及引擎注册表。
每种引擎(如 claude-code、antigravity)实现同一个 Engine 接口, 以子进程 / 无头 CLI 方式运行一个提示词并返回产物文本。workflow 节点通过 engine 字段按名字选择引擎,由本包的注册表解析到具体实现。
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotImplemented = errors.New("engine not yet implemented")
ErrNotImplemented 是「引擎已登记但无头执行尚未落地」的约定返回值(承 AGENTS.md「不假装成功」)。 现有四引擎均已实装,暂无使用者;若将来先登记某引擎 stub,即用它显式占位而非空实现冒充可用。
Functions ¶
Types ¶
type Engine ¶
type Engine interface {
// Name 返回引擎的稳定标识,即 workflow 定义里 engine 字段的取值(如 "claude-code")。
Name() string
// Run 以无头方式执行一个提示词并返回产物。
Run(ctx context.Context, request RunRequest) (RunResult, error)
}
Engine 抽象一个可被无头调用的 AI 编程引擎。
type EngineCapability ¶
type EngineCapability struct {
// AllowsModel 指示是否接受 model 字段。
AllowsModel bool
// EffortField 是该引擎接受的调优字段名:
// "effort" —— claude-code
// "reasoningEffort" —— qoder / codex(同用此字段,但各自的允许集不同)
// "" —— 无独立调优字段(如 antigravity,其推理强度编码在 model 标签后缀里)
EffortField string
// EffortValues 是 EffortField 的合法取值集;EffortField 为空时为 nil。
EffortValues []string
// ModelValues 是 model 字段的常见别名建议值,仅供 UI 下拉展示便利——不是白名单,
// model 本身是开放集合(各引擎接受别名之外的完整模型名,甚至自定义 API 后端的任意模型名),
// 故不接入 workflow.Validate 做强校验,任意非空串仍放行。为空表示该引擎未登记建议值
// (不代表不接受 model,见 AllowsModel)。
ModelValues []string
}
EngineCapability 描述一个引擎接受的 engineConfig 形态(判别联合的「合法字段表」)。
func Capability ¶
func Capability(name string) (EngineCapability, bool)
Capability 返回某引擎的 engineConfig 能力表;未登记能力表时 ok=false。
type RunRequest ¶
type RunRequest struct {
// Prompt 是喂给引擎的完整提示词。
Prompt string
// Model 指定模型;为空则交由引擎自身的默认模型。
Model string
// WorkingDirectory 是引擎读写文件的工作目录。
WorkingDirectory string
// Effort 是引擎特定的推理强度;各引擎语义不同,未设时为空字符串。
Effort string
}
RunRequest 是一次无头引擎执行的入参。
type RunResult ¶
type RunResult struct {
// Text 是本次运行的产物文本,作为 workflow 节点的输出。
Text string
// DurationMilliseconds 是本次运行的耗时。
DurationMilliseconds int64
// Tokens 是本次运行消耗的 token 数;引擎不提供时为 0。
Tokens int
// SessionID 是本次运行的引擎会话/线程 id,从各引擎自身 JSON 输出取
//(claude-code / qoder 的 session_id、antigravity 的 conversation_id、codex 的 thread_id);
// conduct 记入该步 trace,供凭引擎自带工具回放本步。引擎不回报时为空串。
SessionID string
}
RunResult 是一次无头引擎执行的产物。
Click to show internal directories.
Click to hide internal directories.