Files
next-tjwater-agent/src/frontendAction/registry.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

31 lines
2.1 KiB
TypeScript

import { z } from "zod";
import { viewCommandVariants } from "./command.js";
import type { FrontendActionManifest } from "./types.js";
export { safeChartInput } from "./command.js";
const deviceId = z.string().trim().min(1).max(128);
const scadaLevel = z.enum(["high", "medium", "low", "unrated"]);
const levelCounts = z.object({
high: z.number().int().nonnegative(),
medium: z.number().int().nonnegative(),
low: z.number().int().nonnegative(),
unrated: z.number().int().nonnegative(),
}).strict();
const cleared = z.object({ cleared: z.literal(true) }).strict();
const outputs: Record<string, z.ZodTypeAny> = {
highlight_features: z.object({ highlighted_ids: z.array(deviceId).min(1), missing_ids: z.array(deviceId), fitted: z.boolean() }).strict(),
close_chart: z.object({ closed: z.literal(true) }).strict(),
set_overlay: z.object({ displayed: z.literal(true), feature_count: z.number().int().positive() }).strict(),
locate_features: z.object({ located_ids: z.array(deviceId).min(1), missing_ids: z.array(deviceId), fitted: z.literal(true) }).strict(),
zoom_to_map: z.object({ fitted: z.literal(true) }).strict(),
open_chart: z.object({ displayed: z.literal(true), series_count: z.number().int().positive() }).strict(),
render_scada_analysis: z.object({ rendered_ids: z.array(deviceId), missing_ids: z.array(deviceId), level_counts: levelCounts, fitted: z.literal(true) }).strict(),
};
const definitions = viewCommandVariants.map(inputSchema => {
const id = inputSchema.shape.action.value;
const manifest: FrontendActionManifest = { id, version: "frontend-action@2", risk: "view", timeoutMs: 15000, supportedSurfaces: id.includes("chart") ? ["side_panel", "canvas"] : ["map_overlay"] };
return { manifest, inputSchema, outputSchema: outputs[id] ?? cleared };
});
export const frontendActionRegistry = definitions.map(item => item.manifest);
export const getFrontendActionDefinition = (name: string) => definitions.find(item => item.manifest.id === name);
export const frontendActionRegistryResponse = { schema_version: "frontend-action-registry@2" as const, actions: frontendActionRegistry };