UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

37 lines (36 loc) • 2.03 kB
import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import "./string-coerce-runtime-BwAZZDf5.mjs"; //#region extensions/anthropic/cli-runtime-tasks.ts function readReplayedTaskId(e, t) { if (e.type !== "user" || e.isReplay !== true || e.parent_tool_use_id !== null || typeof e.uuid === "string" && t.has(e.uuid) || !isRecord(e.message)) return; if (e.origin !== void 0 && (!isRecord(e.origin) || e.origin.kind !== "task-notification" || e.origin.subkind !== void 0)) return; const n = e.message.content; const r = Array.isArray(n) ? n[0] : void 0; const i = typeof n === "string" ? n : isRecord(r) && r.type === "text" && typeof r.text === "string" ? r.text : ""; return /^<task-notification>\s*<task-id>([^<]+)<\/task-id>/u.exec(i)?.[1]; } function recordTaskOwnership(e, t, n) { const r = t.task_id; if (typeof r !== "string" || !r) return; const i = e.taskOwners.get(r); const a = t.owned_by_subagent === true ? false : i ?? n; if (a !== i) e.taskOwners.set(r, a); if (typeof t.run_id === "string" && t.run_id) e.taskRuns.set(t.run_id, r); return a === false ? void 0 : r; } /** Agents and workflows make their own tool calls; subagent-owned work can resume its Agent. */ function isDescendantTask(e) { return e.task_type === "local_agent" || e.task_type === "local_workflow" || e.owned_by_subagent === true || typeof e.parent_task_id === "string"; } function recordRunningDescendants(e, t) { const n = t.subtype === "task_started" ? [t] : t.subtype === "background_tasks_changed" && Array.isArray(t.tasks) ? t.tasks.filter(isRecord) : []; for (const t of n) if (typeof t.task_id === "string" && isDescendantTask(t)) e.set(t.task_id, typeof t.parent_task_id === "string" ? t.parent_task_id : e.get(t.task_id)); if (t.subtype === "task_notification" && typeof t.task_id === "string") { const n = e.get(t.task_id); e.delete(t.task_id); return n !== void 0 && e.has(n); } return false; } //#endregion export { recordRunningDescendants as n, recordTaskOwnership as r, readReplayedTaskId as t };