feat(agent): unify MCP tools and adopt Responses delivery

Move project and host queries into native MCP with host-owned OAuth/context,
while retaining memory, skills, actions and publication plugins. Add nearby-model
queries and explicit chat/task/learning model defaults.

Adopt Responses HTTP/SSE and native steer/queue inbox delivery, preserving scoped
session ownership, pending input edits and investigation communication.

Disable local-provider discovery: Server /health allowed native vLLM to probe
/v1/models on port 8000. A native before/after regression prevents recurrence.

Validation: 170 focused Bun tests; service/plugin typechecks; native discovery,
provider-discovery and input-inbox smoke checks; no paid model inference.
This commit is contained in:
2026-10-19 18:46:58 +08:00
parent f5c3cde2c2
commit 6a49d2209e
164 changed files with 12286 additions and 2368 deletions
@@ -0,0 +1,49 @@
import { tool } from "../tool.js";
// OpenCode owns a separate Zod version. Native parameters are described here;
// product schemas revalidate progress and presentation at execution boundaries.
const text = tool.schema.string().trim().min(1);
const identifier = text.max(128);
const layer = tool.schema.enum(["junctions", "pipes", "valves", "pumps", "tanks", "reservoirs", "scada"]);
export const taskPublicationDiagramSchema = tool.schema.object({
title: text,
mermaid: text.max(20000).describe("Mermaid flowchart source; no Markdown fences, initialization directives or click callbacks"),
node_refs: tool.schema.array(tool.schema.object({
node_id: tool.schema.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,79}$/),
label: text,
evidence_refs: tool.schema.array(text).default([]),
action_refs: tool.schema.array(tool.schema.string().uuid()).default([]),
status: tool.schema.enum(["pending", "running", "completed", "waiting_human", "failed", "skipped", "cancelled"]).nullish(),
map_targets: tool.schema.array(tool.schema.object({ source_id: layer, feature_id: identifier }).strict()).max(100).default([]),
}).strict()).max(100).default([]),
}).strict();
export const taskPublicationProgressSchema = tool.schema.object({
summary: text.max(20000),
diagram: taskPublicationDiagramSchema.nullable().default(null),
}).strict();
const chart = tool.schema.object({
title: tool.schema.string().max(200),
chart_type: tool.schema.enum(["line", "bar"]),
x_data: tool.schema.array(tool.schema.string().max(128)).min(1).max(100),
series: tool.schema.array(tool.schema.object({
name: tool.schema.string().max(128), data: tool.schema.array(tool.schema.number().finite()).min(1).max(100),
}).strict()).min(1).max(8),
}).strict();
export const taskPublicationCommandSchema = tool.schema.discriminatedUnion("action", [
tool.schema.object({
action: tool.schema.literal("highlight_features"), layer,
feature_ids: tool.schema.array(identifier).min(1).max(100),
effect: tool.schema.enum(["steady", "pulse"]).default("steady"),
}).strict(),
tool.schema.object({ action: tool.schema.literal("clear_highlights") }).strict(),
tool.schema.object({ action: tool.schema.literal("open_chart"), chart_id: identifier, chart,
evidence_refs: tool.schema.array(text).min(1).max(100) }).strict(),
tool.schema.object({ action: tool.schema.literal("close_chart"), chart_id: identifier }).strict(),
tool.schema.object({ action: tool.schema.literal("set_overlay"), overlay_id: identifier,
title: text.max(200), mode: tool.schema.enum(["geometry", "heatmap"]), evidence_id: text }).strict(),
tool.schema.object({ action: tool.schema.literal("clear_overlay"), overlay_id: identifier }).strict(),
]);