Community编程与开发github.com

TaskFlow

协调多步骤的分离式任务,形成一个持久的 TaskFlow 作业,包含所有者上下文、状态、等待和子任务。

TaskFlow 是什么?

TaskFlow 是一个 AI 代理技能,用于管理需要跨多个提示或分离式运行执行的长时间运行工作流。它允许代理将多步骤的、分离的工作(如 ACP 或子代理任务)作为单一的、持久的作业来编排,该作业具有自己的身份、拥有者会话和状态容器。该技能抽象了状态持久化、修订冲突处理以及链接子任务的创建过程,确保即使遇到重启或冲突,作业依然保持可靠。它支持托管生命周期,包括创建、运行任务、等待外部输入、恢复、完成或取消,并提供如 'stateJson' 和 'waitJson' 这样的 API 用于状态和等待条件。TaskFlow 适合用于那些需要通过连贯逻辑编排多步后台工作并最终向拥有者生成清晰更新的场景。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clawdbot/clawdbot/tree/main/skills/taskflow

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

TaskFlow 是做什么的?

当一个作业需要跨越一个提示或一次分离式运行的生命周期时,请使用 TaskFlow,但你仍然希望拥有一个所有者会话、一个返回上下文以及一个可以检查或恢复工作的地方。

何时使用

  • 多步骤后台工作,且有一个所有者
  • 等待分离的 ACP 或子代理任务的工作
  • 可能需要向所有者发出一次清晰更新的作业
  • 在步骤之间需要少量持久化状态的作业
  • 必须能干净处理重启和修订冲突的插件或工具工作

TaskFlow 拥有的内容

  • 流程标识
  • 所有者会话和请求者来源
  • currentStep、stateJson 和 waitJson
  • 链接的子任务及其父流程 ID
  • 完成、失败、取消、等待和阻塞状态
  • 用于冲突安全突变的修订跟踪

它不拥有分支或业务逻辑。将这些放在 Lobster、acpx 或调用代码中。

当前运行时形态

规范的插件/运行时入口点:

  • api.runtime.tasks.flow
  • api.runtime.taskFlow 仍作为别名存在,但 api.runtime.tasks.flow 是规范形态

绑定:

  • api.runtime.tasks.flow.fromToolContext(ctx) 当你已经有带有 sessionKey 的可信工具上下文时
  • api.runtime.tasks.flow.bindSession({ sessionKey, requesterOrigin }) 当你的绑定层已经解析了会话和交付上下文时

托管流程生命周期:

  1. createManaged(...)
  2. runTask(...)
  3. setWaiting(...) 当等待人员或外部系统时
  4. resume(...) 当工作可以继续时
  5. finish(...) 或 fail(...)
  6. requestCancel(...) 或 cancel(...) 当整个作业应停止时

设计约束

  • 当你的代码拥有编排权时,使用托管 TaskFlow。
  • 由核心运行时为分离的 ACP/子代理工作创建的单任务镜像流程;此技能主要针对托管流程。
  • 将 stateJson 视为持久化的状态包。没有单独的 setFlowOutput 或 appendFlowOutput API。
  • 创建后的每个变更方法都经过修订检查。在每次成功变更后,向前推进最新的 flow.revision。
  • runTask(...) 将子任务链接到流程。当你想要父级编排时,应使用它而不是手动创建分离任务。

示例形态

const taskFlow = api.runtime.tasks.flow.fromToolContext(ctx);

const created = taskFlow.createManaged({
  controllerId: "my-plugin/inbox-triage",
  goal: "triage inbox",
  currentStep: "classify",
  stateJson: {
    businessThreads: [],
    personalItems: [],
    eodSummary: [],
  },
});

const classify = taskFlow.runTask({
  flowId: created.flowId,
  runtime: "acp",
  childSessionKey: "agent:main:subagent:classifier",
  runId: "inbox-classify-1",
  task: "Classify inbox messages",
  status: "running",
  startedAt: Date.now(),
  lastEventAt: Date.now(),
});

if (!classify.created) {
  throw new Error(classify.reason);
}

const waiting = taskFlow.setWaiting({
  flowId: created.flowId,
  expectedRevision: created.revision,
  currentStep: "await_business_reply",
  stateJson: {
    businessThreads: ["slack:thread-1"],
    personalItems: [],
    eodSummary: [],
  },
  waitJson: {
    kind: "reply",
    channel: "slack",
    threadKey: "slack:thread-1",
  },
});

if (!waiting.applied) {
  throw new Error(waiting.code);
}

const resumed = taskFlow.resume({
  flowId: waiting.flow.flowId,
  expectedRevision: waiting.flow.revision,
  status: "running",
  currentStep: "finalize",
  stateJson: waiting.flow.stateJson,
});

if (!resumed.applied) {
  throw new Error(resumed.code);
}

taskFlow.finish({
  flowId: resumed.flow.flowId,
  expectedRevision: resumed.flow.revision,
  stateJson: resumed.flow.stateJson,
});

将条件逻辑保持在运行时之上

使用流程运行时来处理状态和任务链接。将决策放在编排层:

  • business -> 发布到 Slack 并等待
  • personal -> 立即通知所有者
  • later -> 附加到日终摘要桶中

操作模式

  • 仅存储恢复所需的最小状态。
  • 在 blockedSummary 中放置人类可读的等待原因,或在 waitJson 中放置结构化的等待元数据。
  • 当编排器需要子工作的紧凑健康视图时,使用 getTaskSummary(flowId)。
  • 当调用者希望流程立即停止调度时,使用 requestCancel(...)。
  • 当你还想取消处于活动状态的链接子任务时,使用 cancel(...)。

示例

  • 参见 skills/taskflow/examples/inbox-triage.lobster
  • 参见 skills/taskflow/examples/pr-intake.lobster
  • 参见 skills/taskflow-inbox-triage/SKILL.md 以了解具体的路由模式

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

1password

Set up and use 1Password CLI for sign-in, desktop integration, and reading or injecting secrets.

acp-router

Route plain-language requests for Claude Code, Cursor, Copilot, OpenClaw ACP, OpenCode, Gemini CLI, Grok Build, Qwen, Kiro, Kimi, iFlow, Factory Droid, Kilocode, or explicit ACP harness work into either OpenClaw ACP runtime sessions or direct acpx-driven sessions ("telephone game" flow). For coding-agent thread requests, read this skill first, then use only `sessions_spawn` for thread creation. Codex chat binding defaults to the native Codex app-server plugin unless ACP is explicit or background spawn needs ACP.

add-model-provider

Add and live-prove a model provider with non-interactive config one-liners, without exposing credentials.

agent-transcript

Requested GitHub PR/issue agent transcripts: redact, trim, preview, and insert safely.

apple-notes

Create, view, edit, delete, search, move, or export Apple Notes via the memo CLI on macOS.

apple-reminders

List, add, edit, complete, or delete Apple Reminders and reminder lists via remindctl.

auto-qa

Run OpenClaw-wide autonomous QA and live/stress campaigns across independent subsystem lanes, with verified fixes and a resumable evidence report.

autoreview

Structured code review through the shared OpenClaw agent-skills installation.

bear-notes

Create, search, and manage Bear notes via grizzly CLI.

blacksmith-testbox

Run Blacksmith Testbox for CI-parity checks, secrets, hosted services, migrations, or builds local cannot reproduce.

block-kit

Use proactively for structured or interactive Slack replies, and when asked to author or validate native Slack Block Kit JSON.

blogwatcher

Monitor blogs and RSS/Atom feeds for updates using the blogwatcher CLI.

blucli

BluOS CLI (blu) for discovery, playback, grouping, and volume.

bluebubbles

Send and manage iMessages via BlueBubbles, including attachments, tapbacks, edits, replies, and groups.

browser-automation

Use when controlling web pages with the OpenClaw browser tool, especially multi-step flows, login checks, tab management, or recovery from stale refs/timeouts.

camsnap

Capture frames or clips from RTSP/ONVIF cameras and local webcams, including USB pan/tilt/zoom control.

canvas

Present HTML on connected OpenClaw node canvases, navigate/eval/snapshot, and debug canvas host URLs.

channel-message-flows

Use when running QA Lab channel message flow evidence.

clawdtributor

Clawtributor PRs here, last week or another window: discover conversation refs, recheck GitHub, rank by impact.

clawhub

Search ClawHub for plugins by default, or skills and agent Templates when requested; add Templates; install, verify, update, uninstall, publish, or sync skills.

相关技能