欄位
{
"id": "draft-reply",
"label": "Draft the reply",
"intent": "Draft a reply to the customer message in _watch_payload using the reply-drafting skill.",
"skills": ["reply-drafting"],
"requires_tools": ["mail_message_send"],
"on_error": { "retry": 1, "fallback": "notify_owner" }
} | 欄位 | 預設值 | 意義 |
|---|---|---|
id | 必填 | 在工作流程內不可重複。用於 connections 和資料路徑。 |
type | custom | 員工步驟,或 condition、loop、wait、http、command、decide 其中之一。 |
intent | 無 | 員工應達成的目標。員工步驟需要 intent 或 steps。 |
steps | [] | 一句話不夠說明時使用的有序指示。 |
label | 無 | 向擁有者顯示的名稱。 |
skills | [] | 要使用的技能。此處列出的市集技能會隨員工一起安裝。 |
tools | [] | 設定後,此步驟只能使用這些工具。 |
requires_tools | [] | 必須成功,此步驟才算完成的工具。 |
cmds | [] | 為此步驟指定的外掛指令。 |
mcps | [] | 為此步驟指定的 MCP 伺服器。 |
model | 無 | 此步驟使用的模型 ID。 |
params | 無 | 型別化活動的參數,以及員工步驟的 maxIterations。 |
min_iterations | 無 | 步驟完成前至少需要的模型回合數。 |
token_budget | 無 | {max}。估計值。 |
on_error | {retry: 1, fallback: notify_owner} | 重試,然後採用備援。重試之後仍失敗就會結束執行。 |
員工步驟
員工步驟會以員工的一個回合來執行:套用它的角色設定、記憶和連線,最多可使用 50 個模型回合,或 params.maxIterations。先前步驟的結果會以 [Activity 'id' result] 區塊傳入。以 emit 清單結束工作流程的步驟,會被告知要以那些事件呼叫 emit_event。exit 工具一律可用來結束執行。
資料內容
型別化活動會從同一個物件以點號路徑讀取值:inputs 存放這次執行的輸入,nodes.<id> 存放每個已完成活動的輸出(若是 JSON 則會解析為 JSON),而 item 存放迴圈中的目前項目。沒有前綴的路徑會先在 inputs 中尋找,再到 nodes 中尋找。
condition
{ "id": "large", "type": "condition", "params": { "expression": "inputs.amount >= 500" } } params.expression 為必填。它的輸出連線標示為 True 和 False。params.mode 決定如何解讀它:
| 模式 | 運算式 |
|---|---|
expression | 預設值。path op value,可使用 ==、!=、>=、<=、> 或 <,兩邊都是數字時以數字比較;或是單純的路徑,其值為真值時即為 true。 |
exists | 一個路徑;解析為真值時即為 true。 |
contains | path contains text,或與前一個輸出比對的純文字。 |
regex | 與前一個輸出比對的模式。 |
loop
{ "id": "each-invoice", "type": "loop", "params": { "source": "nodes.fetch.invoices", "concurrency": 4 } } params.source 是一份清單的路徑。標示為 Each item 的連線通往迴圈主體,主體會針對每個項目執行一次並設定 item;標示為 Done 的連線則在所有項目完成後執行。除非你設定 concurrency,否則所有反覆執行會同時開始。也接受 maxIterations 和 batchSize。
"connections": [
{ "from": "__trigger__", "to": "fetch" },
{ "from": "fetch", "to": "each-invoice" },
{ "from": "each-invoice", "to": "check", "label": "Each item" },
{ "from": "each-invoice", "to": "report", "label": "Done" }
] wait、http 與 command
{ "id": "pause", "type": "wait", "params": { "duration": "5m" } }
{ "id": "status", "type": "http", "params": { "url": "https://status.example.com/api", "method": "GET" } }
{ "id": "export", "type": "command", "params": { "command": "date -u" } } | 類型 | 必填 | 行為 |
|---|---|---|
wait | params.duration | 暫停一段以 s、m 或 h 表示的時間。沒有「等到某時」的功能;若要在事件發生時繼續,請用該事件觸發第二個工作流程。 |
http | params.url | 發出請求。method、headers 和 body 為選用。 |
command | params.command | 執行 shell 指令。其 stdout 就是活動的輸出。 |
decide
decide 活動會針對目前為止的工作提出型別化問題,並記錄結構化的答案,供 condition 據以路由。
{
"id": "triage",
"type": "decide",
"params": {
"questions": {
"urgency": { "type": "score", "instructions": "How urgent is this request?", "criteria": ["low", "normal", "high"] },
"refund": { "type": "noul", "instructions": "The customer is asking for money back." }
},
"default": { "urgency": "normal", "refund": false }
}
} | 問題類型 | criteria | 答案 |
|---|---|---|
choice | 選項對應說明的物件,2 到 255 個選項。 | choice、confidence 和 probabilities。 |
score | 2 到 10 個有序等級的清單。 | 從 0(第一個等級)往上的 score,以及 confidence。 |
noul | 無。 | noul,即該陳述成立的機率。 |
用 condition 依答案路由,例如 nodes.triage.urgency.score >= 1.5。params.default 為每個問題提供無法做出決定時的安全答案;採用預設值的答案信心度為 0。沒有預設值的問題不會得到答案,因此依據它的 condition 會走 False 邊。
錯誤
on_error.retry 設定失敗的活動要重試幾次;預設為 1。最後一次重試後,執行就會結束;若 fallback 為預設的 notify_owner,就會通知擁有者。Nebo 會在執行開始時檢查每個型別化活動的必要參數,並拒絕指向未知活動的分支。