Files
next-tjwater-agent/.opencode/tools/task-publication-schema.ts
T
jiang 6336157ff4
Generic Container CI/CD / test-build-publish (push) Successful in 1m6s
Agent CI/CD / build-test-publish-and-deploy (push) Successful in 1m7s
feat: upgrade investigation and presentation runtime
2026-10-30 17:30:19 +08:00

51 lines
3.0 KiB
TypeScript

import { tool } from "../tool.js";
import { mermaidDeclaresNodeId } from "../../src/product/investigation-report.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}$/),
phase: tool.schema.literal("final").optional(),
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. Reuse the exact Mermaid node ids in node_refs"),
node_refs: tool.schema.array(tool.schema.object({
node_id: tool.schema.string().regex(/^[A-Za-z_][A-Za-z0-9_-]{0,79}$/).describe("Exact id of a node declared in the Mermaid source; do not create a separate reference id"),
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", "waiting_human", "failed", "skipped", "cancelled"]).nullish().describe("Evidence-confirmed node state; waiting means prerequisites/external/system result, waiting_human requires manual authorization/approval/feedback. Unknown stays omitted/null; host controls colors."),
map_targets: tool.schema.array(tool.schema.object({ source_id: layer, feature_id: identifier }).strict()).max(100).default([]),
}).strict()).max(100).default([]),
}).strict().refine(
(diagram) => diagram.node_refs.every((node) => mermaidDeclaresNodeId(diagram.mermaid, node.node_id)),
"Every node_refs node_id must be declared with the same id in the Mermaid source",
);
export const taskPublicationProgressSchema = tool.schema.object({
summary: text.max(20000),
diagram: taskPublicationDiagramSchema.nullable().default(null),
}).strict();
import { createViewSchemas } from "../../src/frontendAction/command.js";
export const taskPublicationCommandSchema = createViewSchemas(tool.schema as unknown as Parameters<typeof createViewSchemas>[0], true).command as unknown as ReturnType<typeof tool.schema.object>;