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.
This commit is contained in:
@@ -25,7 +25,24 @@ const renderScadaAnalysisInput = z.object({
|
||||
seen.add(item.device_id);
|
||||
});
|
||||
});
|
||||
const viewManifest = (id: string, map = false): FrontendActionManifest => ({ id, version: "frontend-action@1", risk: "view", timeoutMs: 15_000, supportedSurfaces: map ? ["map_overlay"] : ["side_panel", "canvas"] });
|
||||
export const safeChartInput = z.object({
|
||||
title: z.string().max(200), chart_type: z.enum(["line", "bar"]),
|
||||
x_data: z.array(z.string().max(128)).min(1).max(100),
|
||||
series: z.array(z.object({ name: z.string().max(128), data: z.array(z.number().finite()).min(1).max(100) }).strict()).min(1).max(8),
|
||||
}).strict().refine((value) => value.series.every((series) => series.data.length === value.x_data.length), "series must align with x_data");
|
||||
const definitions: Definition[] = [
|
||||
{ manifest: viewManifest("locate_features", true),
|
||||
inputSchema: z.object({ layer: z.enum(["junctions", "pipes", "valves", "pumps", "tanks", "reservoirs", "scada"]), feature_ids: z.array(deviceId).min(1).max(100) }).strict(),
|
||||
outputSchema: z.object({ located_ids: z.array(deviceId).min(1), missing_ids: z.array(deviceId), fitted: z.literal(true) }).strict() },
|
||||
{ manifest: viewManifest("zoom_to_map", true),
|
||||
inputSchema: z.object({ center: z.tuple([z.number().min(-180).max(180), z.number().min(-90).max(90)]), zoom: z.number().min(0).max(24) }).strict(),
|
||||
outputSchema: z.object({ fitted: z.literal(true) }).strict() },
|
||||
{ manifest: viewManifest("show_chart"), inputSchema: safeChartInput,
|
||||
outputSchema: z.object({ displayed: z.literal(true), series_count: z.number().int().positive() }).strict() },
|
||||
{ manifest: viewManifest("view_history"),
|
||||
inputSchema: z.object({ element_type: z.enum(["junction", "pipe"]), element_id: deviceId, start: z.string().datetime({ offset: true }), end: z.string().datetime({ offset: true }), chart: safeChartInput.optional() }).strict(),
|
||||
outputSchema: z.object({ displayed: z.literal(true), series_count: z.number().int().positive() }).strict() },
|
||||
{
|
||||
manifest: {
|
||||
id: "render_scada_analysis",
|
||||
|
||||
Reference in New Issue
Block a user