Documentation
¶
Overview ¶
Package engine 定义 AI 编程引擎的无头执行抽象,以及引擎注册表。
每种引擎(如 claude-code、antigravity)实现同一个 Engine 接口, 以子进程 / 无头 CLI 方式运行一个提示词并返回产物文本。workflow 节点通过 engine 字段按名字选择引擎,由本包的注册表解析到具体实现。
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotImplemented = errors.New("engine not yet implemented")
ErrNotImplemented 是「引擎已登记但无头执行尚未落地」的约定返回值(承 AGENTS.md「不假装成功」)。 现有已注册引擎均已实装,暂无使用者;若将来先登记某引擎 stub,即用它显式占位而非空实现冒充可用。
Functions ¶
func ShellQuote ¶ added in v0.1.2
ShellQuote quotes one shell argument for display and copy. It does not execute the result.
Types ¶
type Engine ¶
type Engine interface {
// Descriptor 返回注册、校验和展示所需的静态元数据。
Descriptor() EngineDescriptor
// Run 以无头方式执行一个提示词并返回产物。
Run(ctx context.Context, request RunRequest) (RunResult, error)
}
Engine 抽象一个可被无头调用的 AI 编程引擎。
type EngineCapability ¶
type EngineCapability struct {
// AllowsModel 指示是否接受 model 字段。
AllowsModel bool
// ModelSuggestions 是 model 字段的常见建议值,仅供 UI 展示,不是白名单。
ModelSuggestions []string
// AllowsEffort 指示是否接受统一的 effort 字段。
AllowsEffort bool
// EffortValues 是 effort 的合法取值集;AllowsEffort=false 时为空。
EffortValues []string
}
EngineCapability 描述一个引擎接受的 engineConfig 形态(判别联合的「合法字段表」)。
type EngineDescriptor ¶ added in v0.1.2
type EngineDescriptor struct {
Name string
Capability EngineCapability
IconFilename string
SessionReplayCommand func(sessionID string) string
}
EngineDescriptor 把引擎实现、配置能力和展示元数据聚拢为一份注册事实源。
func Describe ¶ added in v0.1.2
func Describe(name string) (EngineDescriptor, bool)
Describe 返回指定引擎 descriptor 的深拷贝。
func RegisteredDescriptors ¶ added in v0.1.2
func RegisteredDescriptors() []EngineDescriptor
RegisteredDescriptors 返回按 name 排序的 descriptor 深拷贝。
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 数;引擎不提供时为 nil。已知值 0 仍以非 nil 指针表示。
Tokens *int
// SessionID 是本次运行的引擎会话/线程 id,从各引擎自身 JSON 输出取
//(claude-code / qoder 的 session_id、antigravity 的 conversation_id、codex 的 thread_id);
// conduct 记入该步 trace,供凭引擎自带工具回放本步。引擎不回报或回报空串时为 nil。
SessionID *string
}
RunResult 是一次无头引擎执行的产物。