Skip to content

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


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

Function: runWorkflowAsUnit()

runWorkflowAsUnit(source, input, options?): Promise<AgentOutput>

Defined in: yaml/workflow-as-unit.ts:75

把整份 Workflow YAML 当作单个 Unit 执行:AgentInputengine.runAgentOutput

用于跨项目 TS↔TS 组合(子服务对外只暴露 Unit 契约)。业务旋钮放在 input.params(勿放 secrets)。

Parameters

source

string

Workflow YAML 路径或文本(同 createEngineFromYaml

input

AgentInput

标准 Unit 输入(task / 可选 context / params

options?

RunWorkflowAsUnitOptions = {}

registry、bindings、内容键或自定义 mapResult

Returns

Promise<AgentOutput>

符合 Remote Unit 契约的 AgentOutput

Example

ts
import { runWorkflowAsUnit, createMockAdapter } from 'uni-flow';

const out = await runWorkflowAsUnit(
  yamlText,
  { task: 'summarize', params: { mode: 'brief' } },
  {
    registry: { 'demo.echo': () => createMockAdapter() },
    contentStateKey: 'output.echo',
  },
);
console.log(out.content, out.metadata);

MIT Licensed