Files
next-tjwater-agent/.opencode/tools/publish_task_presentation.ts
T
jiang 6336157ff4
Generic Container CI/CD / test-build-publish (push) Successful in 1m6s
Agent CI/CD / build-test-publish-and-deploy (push) Successful in 1m7s
feat: upgrade investigation and presentation runtime
2026-10-30 17:30:19 +08:00

26 lines
1.8 KiB
TypeScript

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; data may be omitted; any supplied data is validated by the Server against 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;
},
});