orchestrator

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package orchestrator 是 conduct 的解释器内核:把一份 workflow 定义展开成确定性步骤, 逐步驱动 AI 引擎执行,串联上游产物与评测反馈,并把运行记录落盘。

移植自 Python 原型 paw_workflow.py:run_workflow(其祖本是 x-one-web 的 TS orchestrator)。 呈现(人类进度 / --json 事件)经 Observer 外置,内核只管编排与落盘。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Observer

type Observer interface {
	// OnExpand 报告展开后的总步数与清单;startIndex 为本次实际开跑的起始下标(Run 恒为 0,Resume 为
	// trace 推断出的重入点),供人类进度区分「整趟展开」与「从中断处恢复、共剩几步」,避免把 resume
	// 误显为整趟 N 步。
	OnExpand(steps []workflow.ExecutionStep, startIndex int)
	OnStepStart(info StepInfo)       // 某步开跑前
	OnStepDone(entry run.TraceEntry) // 某步落定(成功或失败),trace 已落盘
}

Observer 接收编排过程中的事件,由调用方(CLI)装成人类进度或 --json 逐步事件。

type Orchestrator

type Orchestrator struct {
	Store   *store.Store
	Engines func(name string) (engine.Engine, error)
	Now     func() time.Time
}

Orchestrator 编排一次运行。Engines / Now 可注入以便测试(默认解析真实引擎与真实时钟)。

func New

func New(st *store.Store) *Orchestrator

New 构造一个用真实引擎注册表与真实时钟的 Orchestrator。

func (*Orchestrator) Resume added in v0.0.2

func (o *Orchestrator) Resume(ctx context.Context, record *run.Record, trace []run.TraceEntry, obs Observer) error

Resume 从一次未完成运行的中断处续跑到终态,续写同一 runs/<id>/、run id 不变(语义即「恢复这次运行」)。 恢复源全部来自落盘:workflowSnapshot(不回读 store 里可能已被 edit/delete 的活 workflow)经 Expand 确定性还原步骤序列、trace 末条记录推断重入下标;trace 中 stepIndex<R 且末条 success 的记录回放重建 artifacts/feedback(见 replayState)。调用方(CLI)已做派生态的 fail-loud 前置校验,本方法仍对缺失 快照 / trace 与快照不一致做防御性报错,不带病续跑、不静默。

func (*Orchestrator) Run

func (o *Orchestrator) Run(ctx context.Context, def *workflow.Definition, userPrompt, cwd string, obs Observer) (string, error)

Run 解释运行一份(已通过校验的)定义,返回 run id。任一步引擎失败:写失败 trace、把 run 收尾为 failed 并生成 summary,然后返回该错误(调用方据此退 1);已完成步骤的 trace 保留。

type StepInfo

type StepInfo struct {
	StepIndex   int
	Type        string // agent | evaluator
	NodeID      string
	DisplayName string
	Iteration   int
	Engine      string
	Model       string // 解析后的模型;空串=用引擎默认
}

StepInfo 是一步开跑前已知的信息,供 Observer 打印进度(不含产物 / 耗时,那些在 OnStepDone 的 trace 里)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL