Community程式設計與開發github.com

TaskFlow

協調多步驟的獨立任務,形成一個具有所有者上下文、狀態、等待和子任務的持久化 TaskFlow 作業。

TaskFlow 是什麼?

TaskFlow 是一個用於管理需要比單次提示或單次獨立運行更長壽命的多步驟背景工作的運行時協調工具。它提供了一個統一的擁有者會話、一個返回上下文以及一個用於檢查或恢復工作進度的單一位置。主要功能包括持久化狀態存儲(stateJson)、步驟進度追蹤、任務連結、等待外部事件或人員(setWaiting/resume),以及修訂衝突檢測以確保安全的變更。它專為需要處理 ACP 或子代理任務、在重啟後存活並避免修訂衝突的介面或插件工作而設計。開發者應使用受管的 TaskFlow 生命週期方法(createManaged、runTask、setWaiting、resume、finish、fail)來編排工作,同時將業務邏輯和分支條件保留在上層調用程式碼中(例如 Lobster 或 acpx)。此技能支援 Claude Code、Cursor 和 Codex 等平台,這些平台需要透過 API api.runtime.tasks.flow 或其舊別名 api.runtime.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.

相關技能