t158 P1 素材:workflow export/import 原語(definition 端點+CLI 命令,未接線)
leo 07-31:「你要做的就是一個叫 export,另一個是 import……現在如果我要把我做的 工作流分享給同事,我要怎麼 export?他要如何 import?是缺了功能用 search 來湊嗎?」 - cypher GET /webhooks/named/:name/definition:吐可攜定義(graph+config+description =record 原樣)——export 的引擎端;import 端直接 POST /webhooks/named 即送進任何實例 - cli/commands/workflow.ts:acr workflow export <name>(definition→.workflow.yaml, flow 從 graph.edges 反推供人讀)/import <file>(graph 直 POST,零編圖零 search 零存在性驗證=V2 純複製;手寫 yaml 無 graph → 指去 acr push) - ⚠️ 未接線:index.ts 尚未掛 workflow 命令組(P1 收尾:接線+分享場景 A export→ B import 驗收+parser 共用模組化) 安裝器側 P0(rag-installer 5a6539d)已用同形狀(打包期預編 graph+純上傳)上 prod。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -471,6 +471,28 @@ webhooksNamedRouter.get('/q/:ns/:name', async (c) => {
|
||||
return queryNamed(c, c.req.param('ns'), c.req.param('name'), queryStringContext(c));
|
||||
});
|
||||
|
||||
// GET /webhooks/named/:name/definition — 吐 workflow 的可攜定義(t158 export 原語)。
|
||||
// leo 07-31:「如果我要把我做的工作流分享給同事,我要怎麼 export?他要如何 import?
|
||||
// 在從前就是寫成幾個 yaml 丟過去讓新的送進 KBDB 不是嗎?」
|
||||
// 回 record 原樣(graph+config+description)=import 端可直接 POST /webhooks/named 送進
|
||||
// 任何實例(acr workflow import/安裝器同一條路)。執行語義不驗證(部署≠發現)。
|
||||
webhooksNamedRouter.get('/webhooks/named/:name/definition', async (c) => {
|
||||
const apiKey = c.req.header('X-Arcrun-API-Key');
|
||||
if (!apiKey) return c.json({ error: '缺少 X-Arcrun-API-Key header' }, 401);
|
||||
const name = c.req.param('name');
|
||||
const raw = await c.env.WEBHOOKS.get(kvKey(apiKey, name), 'text');
|
||||
if (!raw) return c.json({ error: `找不到 workflow "${name}"` }, 404);
|
||||
const rec = JSON.parse(raw) as NamedWorkflowRecord;
|
||||
return c.json({
|
||||
name: rec.name,
|
||||
description: rec.description ?? '',
|
||||
graph: rec.graph,
|
||||
config: rec.config ?? {},
|
||||
created_at: rec.created_at ?? '',
|
||||
...(rec.cron_expr ? { cron_expr: rec.cron_expr } : {}),
|
||||
});
|
||||
});
|
||||
|
||||
// GET /webhooks/named — 列出當前 api_key 下所有 workflow
|
||||
webhooksNamedRouter.get('/webhooks/named', async (c) => {
|
||||
const apiKey = c.req.header('X-Arcrun-API-Key');
|
||||
|
||||
Reference in New Issue
Block a user