import { tool } from "../tool.js"; import { getInternalBridgeConfig } from "../internalBridge.js"; export default tool({ description: "Read the current operational task's authorized task, plan, report, evidence and scoped investigation data from TJWater Server. Use this before investigating a task. It is read-only and does not expose credentials.", args: { report_revision: tool.schema.number().int().positive().optional().describe("Read this persisted report revision alongside the current task when explaining a historical report") }, async execute(args, context) { const { baseUrl, internalToken } = getInternalBridgeConfig(); const url = new URL("/internal/operational-task/context", baseUrl); url.searchParams.set("session_id", context.sessionID); if (args.report_revision != null) url.searchParams.set("report_revision", String(args.report_revision)); const response = await fetch(url, { headers: { Accept: "application/json", "x-agent-internal-token": internalToken }, }); const text = await response.text(); if (!response.ok) throw new Error(`task context request failed (${response.status}): ${text}`); return text; }, });