feat(agent): add frontend action bridge

This commit is contained in:
2026-07-13 17:26:03 +08:00
parent 4418e99a5c
commit 6b45e7c40c
16 changed files with 447 additions and 14 deletions
+5 -5
View File
@@ -1,4 +1,5 @@
import { tool } from "@opencode-ai/plugin";
import { executeFrontendAction } from "./frontend_action.js";
export default tool({
description: "在前端地图上定位并高亮指定的管网要素。",
@@ -9,14 +10,13 @@ export default tool({
"Why this map positioning action is needed for the user request.",
),
ids: tool.schema
.array(tool.schema.string())
.array(tool.schema.string().min(1)).min(1).max(100)
.describe("Feature ids to locate."),
feature_type: tool.schema
.enum(["junction", "pipe", "valve", "reservoir", "pump", "tank"])
.enum(["junction", "pipe", "valve", "reservoir", "pump", "tank", "conduit", "orifice", "outfall"])
.describe("Type of feature to locate."),
},
async execute() {
// 前端工具只负责生成 tool part,真正的地图动作由 Agent SSE 适配层转发给浏览器执行。
return "已在地图上定位到指定要素。";
async execute(args, context) {
return executeFrontendAction("locate_features", args, context);
},
});