import { tool } from "../tool.js"; import { getInternalBridgeConfig } from "../internalBridge.js"; import { taskProgressSchema } from "../../src/product/investigation-report.js"; import { taskPublicationProgressSchema } from "./task-publication-schema.js"; export default tool({ description: "Publish the complete current investigation progress from a task execution session. Publish before starting a real investigation step and when changing direction. The summary and optional Mermaid diagram describe actual activity for people; they never schedule the Agent or derive status from todo. Every node_refs node_id must exactly reuse an id declared in the Mermaid source; do not use A/B nodes in Mermaid and separate semantic ids in node_refs. The entire diagram may be redrawn, and only explicitly running nodes indicate current activity. Map targets reference known supply features. Use a stable UUID request_id and reuse it on retries. Publishing progress does not complete the run or confirm any human work.", args: { request_id: tool.schema.string().uuid().describe("Stable UUID idempotency key; reuse for retries of this progress publication"), progress: taskPublicationProgressSchema, }, async execute(args, context) { const progress = taskProgressSchema.parse(args.progress); const { baseUrl, internalToken } = getInternalBridgeConfig(); const response = await fetch(`${baseUrl}/internal/operational-task/artifacts`, { method: "POST", headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken }, signal: context.signal, body: JSON.stringify({ session_id: context.sessionID, request_id: args.request_id, progress }), }); const text = await response.text(); if (!response.ok) throw new Error(`task progress publish failed (${response.status}): ${text}`); return text; }, });