uni-flow 公开 API(中文注解) / createWorkflowAsUnitHttpHandler
Function: createWorkflowAsUnitHttpHandler()
createWorkflowAsUnitHttpHandler(
source,options?): (req,res) =>void
Defined in: yaml/workflow-as-unit.ts:122
创建 Node.js HTTP 监听器:处理 POST .../execute,请求体为 Remote Unit JSON { input }。
成功返回 200 + AgentOutput;失败返回 500,且 stopReason: 'error'。 非 POST 或不匹配路径时返回 404。
Parameters
source
string
子工作流 YAML 路径或文本
options?
WorkflowAsUnitHttpHandlerOptions = {}
同 runWorkflowAsUnit,外加 pathEndsWith
Returns
(req, res) => void,可直接交给 http.createServer
(req, res) => void
Example
ts
import { createServer } from 'node:http';
import { createWorkflowAsUnitHttpHandler } from 'uni-flow';
const handler = createWorkflowAsUnitHttpHandler('./child.workflow.yaml', {
registry: myRegistry,
});
createServer(handler).listen(3100);