Registry / 程序注册表
程序广场
发现并运行团队内的 AI 程序,或将它们编排成自动化工作流
Input / 输入参数
History / 运行历史
New / 注册
注册新程序
Pipelines / 工作流
工作流列表
先点 DEMO 工作流一键运行感受编排,再新建自己的自动化流水线
Runs / 运行中心
运行中心
跨程序与工作流的统一执行档案:检视输入输出、定位失败、一键重跑
Developer Docs / 协议文档
程序接入协议
两种运行模式的接入规范:HTTP API 直连 与 iframe 嵌入,附可复制代码片段
01 / 接入概览
两种运行模式
程序通过「注册程序」页登记 URL 与接口签名(inputs / outputs)。平台根据运行模式与 URL 协议自动选择执行通道:api 模式 + http(s) 地址走真实 HTTP 请求;iframe 模式 + http(s) 或相对路径走沙箱嵌入 + postMessage 协议;api://、iframe:// 为内置演示协议的 Mock 执行器。
| 模式 | URL 形式 | 执行通道 | 适用场景 |
|---|---|---|---|
| api | https://… | fetch 真实 HTTP 请求 | REST 接口、Serverless 函数 |
| iframe | https://… 或 /path.html | 沙箱 iframe + postMessage | 有 UI 的页面程序、需浏览器环境的计算 |
| 任意 | api://key、iframe://key | 内置 Mock 执行器 | 演示、流程验证 |
| link(跳转型) | https://… | 新标签页直接打开 | 外部 AI 工具 / 网站入口聚合 |
02 / HTTP API 模式
请求构造规则
| 配置项 | 说明 |
|---|---|
| method | GET / POST / PUT / PATCH / DELETE;GET 与 HEAD 不发送请求体 |
| headers | 每行一个 Key: Value,未显式设置时 POST 类请求自动补 Content-Type: application/json |
| bodyTemplate | 支持 {{输入key}} 与嵌套路径 {{a.b}} 插值;留空则发送全部输入的 JSON |
| responsePath | 点路径提取响应字段,如 data.result;留空取整个响应体 |
| timeoutMs | 超时中止(AbortController),默认 15000ms |
URL 本身也支持插值。对象类型输入插值时自动 JSON 序列化。单输出程序的标量响应自动包装为 {输出key: 值}。
# 等价于平台发出的请求(POST + 模板插值)
curl -X POST 'https://api.example.com/v1/summary' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <token>' \
-d '{"prompt": "{{text}}", "lang": "{{lang}}"}'// api 模式程序注册载荷示例
{
"name": "文本摘要服务",
"url": "https://api.example.com/v1/summary",
"runMode": "api",
"apiConfig": {
"method": "POST",
"headers": { "Authorization": "Bearer <token>" },
"bodyTemplate": "{\"prompt\": \"{{text}}\"}",
"responsePath": "data.summary",
"timeoutMs": 15000
},
"inputs": [{ "key": "text", "type": "string", "label": "原文", "required": true }],
"outputs": [{ "key": "summary", "type": "string", "label": "摘要" }]
}⚠️ 浏览器直连受目标服务 CORS 策略约束:目标需返回 Access-Control-Allow-Origin,否则请求会被浏览器拦截(平台会给出明确错误提示)。
03 / iframe 嵌入模式
postMessage 消息协议
子页 → 宿主 ready→
宿主 → 子页 run(runId, inputs)→
子页 → 宿主 result / error
| 方向 | 消息 | 说明 |
|---|---|---|
| 子页 → 宿主 | { source:'aihub-child', type:'ready' } | 子页加载并完成监听器注册后发送 |
| 宿主 → 子页 | { source:'aihub-host', type:'run', runId, inputs } | 收到 ready 后立即发送;未握手则等待 readyWaitMs 后乐观直发 |
| 子页 → 宿主 | { source:'aihub-child', type:'result', runId, output } | 执行成功,runId 必须原样回带 |
| 子页 → 宿主 | { source:'aihub-child', type:'error', runId, error } | 执行失败,error 为错误信息字符串 |
// 子程序最小接入代码(完整范例见 iframe-child-demo.html)
if (window.parent !== window) {
window.parent.postMessage({ source: 'aihub-child', type: 'ready' }, '*');
}
window.addEventListener('message', (e) => {
const d = e.data;
if (!d || d.source !== 'aihub-host' || d.type !== 'run') return;
try {
const output = yourBusinessLogic(d.inputs); // ← 业务逻辑
e.source.postMessage({ source: 'aihub-child', type: 'result', runId: d.runId, output }, e.origin);
} catch (err) {
e.source.postMessage({ source: 'aihub-child', type: 'error', runId: d.runId, error: err.message }, e.origin);
}
});| 配置项 | 说明 |
|---|---|
| timeoutMs | 执行总超时,默认 30000ms,超时判定失败并销毁 iframe |
| readyWaitMs | iframe load 后等待 ready 握手的时长,默认 1500ms,超时直接发送输入 |
| sandbox | strict(仅脚本)/ standard(+同源+表单,默认)/ loose(+弹窗+下载) |
04 / 签名类型与连线兼容
类型系统
| 源类型 ↓ / 目标 → | 可连接目标类型 |
|---|---|
| string | string, json |
| number | number, string |
| boolean | boolean, string |
| json | json, string |
| file | file |
数据流经连线时按目标声明类型自动强转:string→json 尝试 JSON.parse,对象→string 自动 JSON 序列化,number/boolean 互转遵循 JS 语义。类型不兼容的连线在画布上即被拦截并提示。
Empty Canvas
从左侧拖拽程序到此处 · 滚轮缩放 · 拖拽空白处平移
Execution / 执行日志
节点详情
Status / 状态
Input / 输入数据COPY
Output / 输出数据COPY
Meta / 执行信息