feat(tasks): enforce dynamic execution plans

This commit is contained in:
2026-09-24 16:36:12 +08:00
parent 485ceff7e3
commit e0d37f9da9
13 changed files with 1942 additions and 17 deletions
@@ -0,0 +1,28 @@
import { tool } from "@opencode-ai/plugin";
import { getInternalBridgeConfig } from "../internalBridge.js";
export default tool({
description: "Request task-scoped access to one or more finite investigation data sources. This only creates a pending human review record. Do not query the requested sources until the approved scope appears in task context; after denial, mark the evidence gap and continue with available facts.",
args: {
request_id: tool.schema.string().uuid(),
node_id: tool.schema.string().min(1),
scopes: tool.schema.array(tool.schema.enum([
"workbench_runtime", "scada_devices", "scada_readings", "peripheral_points",
"peripheral_work_orders", "peripheral_observations", "peripheral_test_data",
])).min(1),
reason: tool.schema.string().min(1),
},
async execute(args, context) {
const { baseUrl, internalToken } = getInternalBridgeConfig();
const response = await fetch(`${baseUrl}/internal/operational-task/access-requests`, {
method: "POST",
headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken },
body: JSON.stringify({ session_id: context.sessionID, request: {
requestId: args.request_id, nodeId: args.node_id, scopes: args.scopes, reason: args.reason,
} }),
});
const text = await response.text();
if (!response.ok) throw new Error(`task data access request failed (${response.status}): ${text}`);
return text;
},
});