54 lines
3.2 KiB
TypeScript
54 lines
3.2 KiB
TypeScript
import { tool } from "../tool.js";
|
|
import { getInternalBridgeConfig } from "../internalBridge.js";
|
|
import { taskPublicationDiagramSchema, taskReportUiBlocksSchema } from "./task-publication-schema.js";
|
|
import catalog from "../../src/chat/answer-ui-catalog.json" with { type: "json" };
|
|
|
|
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. Optional ui_blocks express evidence as interactive metrics, charts, tables and forms. Each block references saved report evidence, has a unique block_id and a text fallback. Maximum 8 blocks / 400 KB total. Do not duplicate the conclusion or invent data to fill a layout. Component property schemas: " + JSON.stringify(catalog.props),
|
|
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: taskPublicationDiagramSchema.nullish(),
|
|
ui_blocks: taskReportUiBlocksSchema,
|
|
}),
|
|
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;
|
|
},
|
|
});
|