feat: add SCADA frontend action bridge
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
import { executeFrontendAction } from "./frontend_action.js";
|
||||
|
||||
const sensorId = tool.schema.string().trim().min(1).max(128);
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"将已经完成分析并确定等级的 SCADA 点位结果高亮、编号并定位到前端地图。等级只能来自已完成的分析结论。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.trim()
|
||||
.min(1)
|
||||
.describe("Why the completed SCADA analysis should be rendered on the map."),
|
||||
items: tool.schema
|
||||
.array(
|
||||
tool.schema.object({
|
||||
sensor_id: sensorId.describe("Trusted SCADA sensor identifier."),
|
||||
level: tool.schema
|
||||
.enum(["high", "medium", "low", "unrated"])
|
||||
.describe("Completed analysis level; use unrated only when no level was concluded."),
|
||||
}),
|
||||
)
|
||||
.min(1)
|
||||
.max(100)
|
||||
.refine(
|
||||
(items) => new Set(items.map((item) => item.sensor_id)).size === items.length,
|
||||
"sensor_id values must be unique",
|
||||
)
|
||||
.describe("One to one hundred unique SCADA analysis results."),
|
||||
},
|
||||
async execute(args, context) {
|
||||
return executeFrontendAction("render_scada_analysis", args, context);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user