跨语言(手段说明)
主路径请先读:跨项目复用。
本页说明:当项目边界用 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/execute3. 运行 SDK Demo
| 语言 | 命令 |
|---|---|
| TypeScript | npx tsx examples/cross-lang/ts/run-ts-demo.ts |
| Python | pip install -e sdk/python 后 python examples/cross-lang/python/run_demo.py |
| Java | 编译后 java -cp out io.uniflow.examples.RunDemo |
环境变量
| 变量 | 默认值 | 说明 |
|---|---|---|
UNIFLOW_URL | http://127.0.0.1:8787 | Orchestrator 基址 |
GREETER_PORT | 9101 | 本地 Unit 端口 |
GREETER_URL | http://127.0.0.1:9101/execute | bindings 中的 endpoint |
SKIP_LOCAL_GREETER | 未设置 | 设为 1 时不自启 Unit |
SDK 文档
Remote Unit 契约
Remote Unit HTTP Contract — 请求体含 input / context;响应为 AgentOutput JSON。
Registry 内存态
Orchestrator 进程退出后,from-yaml 注册的工作流会从内存消失;YAML 文件仍在,重启后需重新注册。