运行时依赖
安装命令
点击复制技能文档
TaskFlow inbox triage
This is a concrete example of how to think about TaskFlow without turning the core 运行time into a DSL.
Goal
Triage inbox items with one owner flow:
business → post to Slack and wAIt for reply personal → 通知 the owner now everything else → keep for end-of-day summary Pattern 创建 one flow for the inbox batch. 运行 one detached task to classify new items. Persist the routing 状态 in 状态Json. Move to wAIting only when an outside reply is required. 恢复 the flow when classification or human 输入 completes. Finish when the batch has been 路由d. Suggested 状态Json shape { "businessThreads": [], "personalItems": [], "eodSummary": [] }
Suggested wAItJson when blocked on Slack:
{ "kind": "reply", "channel": "slack", "threadKey": "slack:thread-1" }
Minimal 运行time calls const taskFlow = API.运行time.tasks.flow.from工具上下文(ctx);
const 创建d = taskFlow.创建Managed({ 控制器Id: "my-插件/inbox-triage", goal: "triage inbox", currentStep: "classify", 状态Json: { businessThreads: [], personalItems: [], eodSummary: [], }, });
const child = taskFlow.运行Task({ flowId: 创建d.flowId, 运行time: "acp", child会话Key: "代理:mAIn:sub代理:classifier", task: "Classify inbox messages", 状态: "运行ning", 启动edAt: Date.now(), lastEventAt: Date.now(), });
if (!child.创建d) { throw new Error(child.reason); }
const wAIting = taskFlow.设置WAIting({ flowId: 创建d.flowId, expectedRevision: 创建d.revision, currentStep: "awAIt_business_reply", 状态Json: { businessThreads: ["slack:thread-1"], personalItems: [], eodSummary: [], }, wAItJson: { kind: "reply", channel: "slack", threadKey: "slack:thread-1", }, });
if (!wAIting.应用lied) { throw new Error(wAIting.code); }
const 恢复d = taskFlow.恢复({ flowId: wAIting.flow.flowId, expectedRevision: wAIting.flow.revision, 状态: "运行ning", currentStep: "路由_items", 状态Json: wAIting.flow.状态Json, });
if (!恢复d.应用lied) { throw new Error(恢复d.code); }
taskFlow.finish({ flowId: 恢复d.flow.flowId, expectedRevision: 恢复d.flow.revision, 状态Json: 恢复d.flow.状态Json, });
Related example 技能s/taskflow/examples/inbox-triage.lobster