import { tool } from "../tool.js"; import { getInternalBridgeConfig } from "../internalBridge.js"; export default tool({ description: "Publish an evidence-backed investigation report. No todo or execution plan is required. An optional Mermaid diagram explains the investigation to people; it never schedules or completes work. Before proposing actions publish an interim concluded report, then publish a final report referencing the actual actions. Missing critical data ends the round with final insufficient_data and blocking gaps, no recommendations or pending items. Query failures are execution errors, not proof that data is absent. The run lifecycle endpoint settles execution independently of the diagram.", args: { request_id: tool.schema.string().describe("Stable UUID idempotency key for this report revision"), report: tool.schema.object({ title: tool.schema.string(), current_conclusion: tool.schema.string(), conclusion_boundary: tool.schema.string(), evidence_refs: tool.schema.array(tool.schema.string()), recommendations: tool.schema.array(tool.schema.string()), pending_items: tool.schema.array(tool.schema.string()), stage: tool.schema.enum(["interim", "final"]), outcome: tool.schema.enum(["concluded", "insufficient_data"]), stop_reason: tool.schema.string().nullable(), data_gaps: tool.schema.array(tool.schema.object({ gap_id: tool.schema.string(), node_id: tool.schema.string().nullable().optional(), missing_data: tool.schema.string(), scope: tool.schema.string(), impact: tool.schema.string(), required_data: tool.schema.string(), evidence_refs: tool.schema.array(tool.schema.string()), blocking: tool.schema.boolean(), })), diagram: tool.schema.object({ title: tool.schema.string(), mermaid: tool.schema.string().describe("Mermaid flowchart source, no Markdown fences, initialization directives or click callbacks"), node_refs: tool.schema.array(tool.schema.object({ node_id: tool.schema.string(), label: tool.schema.string(), evidence_refs: tool.schema.array(tool.schema.string()), action_refs: tool.schema.array(tool.schema.string()), })), }).nullable().optional(), }), evidence: tool.schema.array(tool.schema.object({ evidence_id: tool.schema.string(), kind: tool.schema.literal("synthetic"), summary: tool.schema.string(), source_label: tool.schema.string(), source_ref: tool.schema.string().optional(), observed_at: tool.schema.string(), })), }, async execute(args, context) { 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 }, body: JSON.stringify({ session_id: context.sessionID, ...args }), }); const text = await response.text(); if (!response.ok) throw new Error(`task report publish failed (${response.status}): ${text}`); return text; }, });