44 lines
2.9 KiB
TypeScript
44 lines
2.9 KiB
TypeScript
import { toolReason } from "../tool-reason.js";
|
|
import { tool } from "../tool.js";
|
|
import { getInternalBridgeConfig } from "../internalBridge.js";
|
|
import { newExecutionPlanSchema } from "../../src/routes/executionPlan.js";
|
|
|
|
export default tool({
|
|
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. Follow the investigation instructions for report outcomes and stopping conditions; missing fields or planned field work do not themselves end the investigation. 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"]),
|
|
title: tool.schema.string(),
|
|
reason: toolReason.max(1000).describe("One concise sentence explaining why the plan or node status changed."),
|
|
nodes: tool.schema.array(tool.schema.object({
|
|
id: tool.schema.string(), title: tool.schema.string(),
|
|
status: tool.schema.enum(["pending", "running", "waiting", "completed", "failed", "skipped", "cancelled"]),
|
|
owner: tool.schema.enum(["agent", "human"]),
|
|
detail: tool.schema.string(), evidence: tool.schema.array(tool.schema.string()),
|
|
action_refs: tool.schema.array(tool.schema.string()).optional(),
|
|
kind: tool.schema.enum(["activity", "decision", "parallel_split", "parallel_join", "gate"]).optional(),
|
|
selected_edge_id: tool.schema.string().nullable().optional(),
|
|
gate_ref: tool.schema.string().nullable().optional(),
|
|
revisits_node_id: tool.schema.string().nullable().optional(),
|
|
})),
|
|
edges: tool.schema.array(tool.schema.object({ id: tool.schema.string().optional(), from: tool.schema.string(), to: tool.schema.string(), label: tool.schema.string() })),
|
|
},
|
|
async execute(args, context) {
|
|
const { request_id, ...input } = args;
|
|
const plan = newExecutionPlanSchema.parse(input);
|
|
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,
|
|
request_id,
|
|
execution_plan: plan,
|
|
}),
|
|
});
|
|
const text = await response.text();
|
|
if (!response.ok) throw new Error(`task plan publish failed (${response.status}): ${text}`);
|
|
return text;
|
|
},
|
|
});
|