Files
next-tjwater-agent/.opencode/tools/query_operational_task_data.ts
T
jiang 7383ed6d13 feat(agent): migrate OpenCode 2 runtime and sandbox tools
Upgrade the runtime and native plugin API to OpenCode 2.0.24. Restore
session-scoped learning, credential renewal, typed project queries and
controlled frontend actions from the legacy Agent.

Replace host Shell execution with an approved Landlock/seccomp executor
and persistent per-session workspaces. Add typed Bocha search and Tianditu
geocoding bridges using the owning session credential. Require a working
kernel sandbox before startup and persist workspace files in deployments.

Validation completed before this commit: TypeScript checks, 150 Bun tests,
Docker build and UID 10001 sandbox execution, native Shell approval and
session recovery. Tianditu succeeded; Bocha currently reports exhausted
account quota. Unrelated investigation-report contract work is excluded.
2026-10-08 15:46:37 +08:00

33 lines
1.6 KiB
TypeScript

import { tool } from "../tool.js";
import { getInternalBridgeConfig } from "../internalBridge.js";
export default tool({
description: "Query one authorized operational data source through TJWater Server. Sources are finite and task-scoped; arbitrary URLs are not supported. peripheral_work_orders contains work-order and complaint business records. peripheral_observations is point/time-window monitoring observations, not complaint text, and requires point_id, start and end. Treat origin=synthetic as synthetic evidence. If truncated=true, do not infer that the unreturned full range has no anomalies.",
args: {
source: tool.schema.enum([
"workbench_runtime",
"scada_devices",
"scada_readings",
"peripheral_points",
"peripheral_work_orders",
"peripheral_observations",
"peripheral_test_data",
]),
device_ids: tool.schema.array(tool.schema.string()).optional(),
point_id: tool.schema.string().optional(),
start: tool.schema.string().optional(),
end: tool.schema.string().optional(),
},
async execute(query, context) {
const { baseUrl, internalToken } = getInternalBridgeConfig();
const response = await fetch(`${baseUrl}/internal/operational-task/data-query`, {
method: "POST",
headers: { "Content-Type": "application/json", "x-agent-internal-token": internalToken },
body: JSON.stringify({ session_id: context.sessionID, query }),
});
const text = await response.text();
if (!response.ok) throw new Error(`task data query failed (${response.status}): ${text}`);
return text;
},
});