Skip to content

uni-flow 公开 API(中文注解)


uni-flow 公开 API(中文注解) / WorkflowRegistry

Class: WorkflowRegistry

Defined in: orchestrator/registry.ts:50

进程内工作流注册表:保存工厂与进行中的 Engine / RunRecord。

注册信息仅在进程内存中;Orchestrator 重启后需重新 register / registerFromYaml

Constructors

Constructor

new WorkflowRegistry(defaultOptions?): WorkflowRegistry

Defined in: orchestrator/registry.ts:59

Parameters

defaultOptions?

WorkflowEngineOptions = {}

创建 Engine 时的默认 Layer4 / 策略选项

Returns

WorkflowRegistry

Methods

getEngine()

getEngine(runId): WorkflowEngine | undefined

Defined in: orchestrator/registry.ts:106

按 runId 取仍存活的 Engine(若有)。

Parameters

runId

string

Returns

WorkflowEngine | undefined


getRun()

getRun(runId): RunRecord | undefined

Defined in: orchestrator/registry.ts:101

按 runId 查询运行记录。

Parameters

runId

string

Returns

RunRecord | undefined


has()

has(workflowId): boolean

Defined in: orchestrator/registry.ts:91

是否已注册该工作流。

Parameters

workflowId

string

Returns

boolean


listWorkflows()

listWorkflows(): string[]

Defined in: orchestrator/registry.ts:96

列出已注册工作流 id。

Returns

string[]


register()

register(workflowId, factory): void

Defined in: orchestrator/registry.ts:69

注册工作流工厂。

Parameters

workflowId

string

工作流 id

factory

WorkflowFactory

返回 config / options 的工厂

Returns

void


registerFromYaml()

registerFromYaml(yaml, bindings?): Promise<{ workflowId: string; }>

Defined in: orchestrator/registry.ts:80

校验 YAML、解析 bindings,并以 metadata.id 注册;每次 run 重新构建配置以刷新 ControlFlow 游标。

Parameters

yaml

string

Workflow YAML 文本

bindings?

UsesBindings

可选 HTTP uses 绑定

Returns

Promise<{ workflowId: string; }>

注册后的 workflowId


respondHITL()

respondHITL(runId, approved, responder): Promise<RunRecord>

Defined in: orchestrator/registry.ts:229

响应 HITL 并继续 resume。

Parameters

runId

string

运行 id

approved

boolean

是否批准

responder

string

审批人标识

Returns

Promise<RunRecord>

继续执行后的运行记录


resumeRun()

resumeRun(runId, snapshotId?): Promise<RunRecord>

Defined in: orchestrator/registry.ts:192

从检查点恢复指定 run。

Parameters

runId

string

运行 id

snapshotId?

string

可选快照 id

Returns

Promise<RunRecord>

更新后的运行记录


startRun()

startRun(workflowId, input?): Promise<RunRecord>

Defined in: orchestrator/registry.ts:125

异步启动一次运行(立即返回 running 的 RunRecord,后台执行 engine.run)。

Parameters

workflowId

string

已注册工作流

input?

Record<string, unknown>

写入 SharedState 的初始输入

Returns

Promise<RunRecord>

新建的运行记录


startRunSync()

startRunSync(workflowId, input?): Promise<RunRecord>

Defined in: orchestrator/registry.ts:154

同步启动并等待运行结束(或暂停于 HITL)。

Parameters

workflowId

string

已注册工作流

input?

Record<string, unknown>

初始 SharedState 输入

Returns

Promise<RunRecord>

完成后的运行记录

MIT Licensed