import { tool } from "../tool.js"; import { getInternalBridgeConfig } from "../internalBridge.js"; import { taskPresentationCommandSchema } from "../../src/product/task-presentation.js"; import { taskPublicationCommandSchema } from "./task-publication-schema.js"; export default tool({ description: "Record a bounded map, chart or evidence-backed overlay presentation command for the current task execution. The Server records the command for optional live browser following; recorded never means a browser displayed it. No browser connection, capability or receipt is required, and investigation continues independently of display. Chart data must reflect the referenced persisted evidence. Overlay coordinates and values are extracted by the Server from the evidence snapshot; never supply invented geometry or arbitrary code. Use a stable UUID request_id and reuse it when retrying the same command.", args: { request_id: tool.schema.string().uuid().describe("Stable UUID idempotency key; reuse for retries of this command"), command: taskPublicationCommandSchema, }, async execute(args, context) { const command = taskPresentationCommandSchema.parse(args.command); const { baseUrl, internalToken } = getInternalBridgeConfig(); const response = await fetch(`${baseUrl}/internal/operational-task/presentation`, { 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, command }), }); const text = await response.text(); if (!response.ok) throw new Error(`task presentation publish failed (${response.status}): ${text}`); return text; }, });