Files
next-tjwater-agent/.opencode/tools/publish_task_report.ts
T
jiang 6a49d2209e feat(agent): unify MCP tools and adopt Responses delivery
Move project and host queries into native MCP with host-owned OAuth/context,
while retaining memory, skills, actions and publication plugins. Add nearby-model
queries and explicit chat/task/learning model defaults.

Adopt Responses HTTP/SSE and native steer/queue inbox delivery, preserving scoped
session ownership, pending input edits and investigation communication.

Disable local-provider discovery: Server /health allowed native vLLM to probe
/v1/models on port 8000. A native before/after regression prevents recurrence.

Validation: 170 focused Bun tests; service/plugin typechecks; native discovery,
provider-discovery and input-inbox smoke checks; no paid model inference.
2026-10-19 18:46:58 +08:00

52 lines
2.7 KiB
TypeScript

import { tool } from "../tool.js";
import { getInternalBridgeConfig } from "../internalBridge.js";
import { taskPublicationDiagramSchema } from "./task-publication-schema.js";
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.",
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(),
}),
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;
},
});