29 lines
1.4 KiB
TypeScript
29 lines
1.4 KiB
TypeScript
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;
|
|
},
|
|
});
|