Files
next-tjwater-agent/.opencode/tools/publish_task_progress.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 { 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;
},
});