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 taskReportUiBlocksSchema = tool.schema.array(tool.schema.object({ block: tool.schema.object({ version: tool.schema.literal("answer-ui@1"), block_id: tool.schema.string().regex(/^[a-zA-Z0-9_-]{1,80}$/), fallback_text: text.max(4000), spec: tool.schema.object({ root: tool.schema.string(), elements: tool.schema.record(tool.schema.string(), tool.schema.object({ type: tool.schema.string(), props: tool.schema.record(tool.schema.string(), tool.schema.unknown()), children: tool.schema.array(tool.schema.string()).max(48), }).strict()), }).strict(), }).strict(), evidence_refs: tool.schema.array(identifier).min(1).max(100), }).strict()).max(8).optional(); 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(), ]);