Skip to content

跨语言(手段说明)

主路径请先读:跨项目复用
本页说明:当项目边界用 HTTP Unit 实现时,各语言如何用 SDK 调 Orchestrator——跨语言是手段,不是「同一工作流里混用多种子 Agent」的目标。

Uni-Flow 的执行核(Orchestrator)为 Node HTTP 服务;任意语言实现的能力只要遵守 Remote Unit HTTP Contract,即可通过 bindings 接入同一 YAML 拓扑。

架构概览

组件职责
Orchestrator校验 YAML、注册工作流、调度 Engine、暴露 HTTP / MCP
HTTP Unit实现 POST + AgentOutput JSON,供 builtin.http / bindings 调用
SDK调用 Orchestrator REST;本地可做 YAML Schema 校验

三步跑通

详细步骤与命令见仓库 examples/cross-lang/README.md
跨项目「对内 workflow、对外 Unit」见 examples/workflow-as-unit/

1. 启动 Orchestrator

bash
npm run build
npx tsx examples/cross-lang/ts/start-orch-only.ts

默认监听 http://127.0.0.1:8787

2. 启动 HTTP Unit(greeter)

Python / Java demo 默认自启 127.0.0.1:9101/execute。若已有 Unit:

bash
export SKIP_LOCAL_GREETER=1
export GREETER_URL=http://your-host:9101/execute

3. 运行 SDK Demo

语言命令
TypeScriptnpx tsx examples/cross-lang/ts/run-ts-demo.ts
Pythonpip install -e sdk/pythonpython examples/cross-lang/python/run_demo.py
Java编译后 java -cp out io.uniflow.examples.RunDemo

环境变量

变量默认值说明
UNIFLOW_URLhttp://127.0.0.1:8787Orchestrator 基址
GREETER_PORT9101本地 Unit 端口
GREETER_URLhttp://127.0.0.1:9101/executebindings 中的 endpoint
SKIP_LOCAL_GREETER未设置设为 1 时不自启 Unit

SDK 文档

Remote Unit 契约

Remote Unit HTTP Contract — 请求体含 input / context;响应为 AgentOutput JSON。

Registry 内存态

Orchestrator 进程退出后,from-yaml 注册的工作流会从内存消失;YAML 文件仍在,重启后需重新注册。

示例页

MIT Licensed