UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.16 kB
import{l as isRecord}from"./record-coerce-BTbqdJ3-.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs"; //!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}function acquireBackgroundTaskHolds(e,t,n){let r;do{r=false;for(const i of n){const n=i.task_id;if(typeof n!==`string`||e.taskOwners.get(n)!==t.inputUuid||t.pendingBackgroundTaskIds.has(n))continue;const a=e.runningDescendants.get(n);if((a===void 0||t.pendingBackgroundTaskIds.has(a))&&(i.task_type===`local_agent`||i.task_type===`local_workflow`||i.task_type===`local_bash`&&t.foregroundTaskIds.has(n))){t.pendingBackgroundTaskIds.add(n);r=true}}}while(r)}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}export{recordTaskOwnership as i,readReplayedTaskId as n,recordRunningDescendants as r,acquireBackgroundTaskHolds as t};