openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
27 lines (26 loc) • 1.77 kB
JavaScript
import { c as isRecord } from "./record-coerce-TIsquoVR.mjs";
import "./string-coerce-runtime-BbIJhy7G.mjs";
//#region extensions/anthropic/cli-runtime-tasks.ts
function readReplayedTaskId(message, inputUuid) {
if (message.type !== "user" || message.isReplay !== true || message.parent_tool_use_id !== null || message.uuid === inputUuid || !isRecord(message.message)) return;
if (message.origin !== void 0 && (!isRecord(message.origin) || message.origin.kind !== "task-notification" || message.origin.subkind !== void 0)) return;
const content = message.message.content;
const first = Array.isArray(content) ? content[0] : void 0;
const text = typeof content === "string" ? content : isRecord(first) && first.type === "text" && typeof first.text === "string" ? first.text : "";
return /^<task-notification>\s*<task-id>([^<]+)<\/task-id>/u.exec(text)?.[1];
}
function recordTaskOwnership(session, task, inputUuid) {
const taskId = task.task_id;
if (typeof taskId !== "string" || !taskId) return;
const previous = session.taskOwners.get(taskId);
const owner = task.owned_by_subagent === true || typeof task.parent_task_id === "string" ? false : previous ?? inputUuid;
if (owner !== previous) session.taskOwners.set(taskId, owner);
if (typeof task.run_id === "string" && task.run_id) session.taskRuns.set(task.run_id, taskId);
return owner === false ? void 0 : taskId;
}
/** Agents and workflows make their own tool calls; subagent-owned work can resume its Agent. */
function isDescendantTask(task) {
return task.task_type === "local_agent" || task.task_type === "local_workflow" || task.owned_by_subagent === true || typeof task.parent_task_id === "string";
}
//#endregion
export { readReplayedTaskId as n, recordTaskOwnership as r, isDescendantTask as t };