feat(agent): align investigation reports and selected context

This commit is contained in:
2026-10-10 16:02:47 +08:00
parent d58bd19039
commit a31b76a793
18 changed files with 1172 additions and 44 deletions
@@ -3,11 +3,12 @@ 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: {},
async execute(_args, context) {
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 },
});
+1 -1
View File
@@ -3,7 +3,7 @@ import { getInternalBridgeConfig } from "../internalBridge.js";
import { proposedTaskActionSchema } from "../../src/product/operational-task-contract.js";
export default tool({
description: "Propose a work-order creation or command action for human approval after its node exists in the published current plan. This tool only creates a pending approval record and can never execute the action. After success, republish the plan with the returned action_id in action_refs before publishing the final report. create_work_order requires title, description and work_order_type; its priority is normal or urgent. issue_command requires command_type, target, parameters, impact_summary, non-empty preconditions and expires_at.",
description: "Propose a concrete work-order creation or command draft for human approval after saving an interim concluded report for the current run. This tool only creates a pending approval record and can never execute the action. No execution plan is required; node_id is an optional display reference. After success, publish a final report and optionally link the returned action_id in diagram node_refs. create_work_order requires title, description and work_order_type; its priority is normal or urgent. issue_command requires command_type, target, parameters, impact_summary, non-empty preconditions and expires_at.",
args: {
request_id: tool.schema.string().describe("Stable UUID idempotency key for this proposal"),
kind: tool.schema.enum(["create_work_order", "issue_command"]),
+1 -1
View File
@@ -3,7 +3,7 @@ import { getInternalBridgeConfig } from "../internalBridge.js";
import { newExecutionPlanSchema } from "../../src/routes/executionPlan.js";
export default tool({
description: "Publish the current full execution plan and progress to TJWater Server. Plans may be updated multiple times during investigation; a plan-only publish is intermediate and does not finish the task unless it explicitly records Agent failure. Publish the relevant plan node before proposing an action, then republish the plan with the returned action_id before the final report. Preserve stable node IDs and completed evidence. A running or completed node may only depend on completed or skipped predecessors. Edges are dependencies or labeled conditional branches, never guessed from list order. Human actions stay waiting until externally confirmed. Evidence must identify synthetic inputs, tool results or human confirmation accurately. This records a plan, it does not execute actions.",
description: "Publish an optional legacy investigation description to TJWater Server. This display snapshot never schedules the Agent or controls event-investigation completion. Prefer the optional Mermaid diagram in publish_task_report for a human-facing investigation narrative. Existing plan validation still requires stable node IDs, factual evidence and explicit edges. Do not invent dependencies from list order or infer human completion. Reports and action proposals do not require this plan. Missing critical data ends the round with a final insufficient_data report. This tool only records explanatory information, it does not execute actions.",
args: {
request_id: tool.schema.string().describe("Stable UUID idempotency key for this plan revision"),
schema: tool.schema.enum(["execution-plan@2"]),
+23 -1
View File
@@ -2,7 +2,7 @@ import { tool } from "../tool.js";
import { getInternalBridgeConfig } from "../internalBridge.js";
export default tool({
description: "Publish the final concise report for this execution turn after the current full plan and any pending action proposals have been saved. The Server combines this report with the current generation and session plan to settle the task as running, waiting_human or completed. This records artifacts; it does not perform field work or execute commands.",
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({
@@ -12,6 +12,28 @@ export default tool({
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: tool.schema.object({
title: tool.schema.string(),
mermaid: tool.schema.string().describe("Mermaid flowchart source, no Markdown fences, initialization directives or click callbacks"),
node_refs: tool.schema.array(tool.schema.object({
node_id: tool.schema.string(), label: tool.schema.string(),
evidence_refs: tool.schema.array(tool.schema.string()),
action_refs: tool.schema.array(tool.schema.string()),
})),
}).nullable().optional(),
}),
evidence: tool.schema.array(tool.schema.object({
evidence_id: tool.schema.string(),