import { tool } from "@opencode-ai/plugin"; export default tool({ description: "在前端地图上对 junctions 图层应用分区渲染。使用前必须完成两步:① 准备数据结构(JSON 文件,结构为 { node_area_map: Record, area_ids?: string[], area_colors?: Record },其中 node_area_map 的 key 是 junction/node id,value 是 area id);② 调用 store_render_ref 将 JSON 文件存储到受控路径,获取 render_ref(格式为 res-...);③ 将 render_ref 传入本工具完成前端渲染。注意:不要先把 ref 内容完整读出再传给前端,也不要直接传本地文件路径。", args: { reason: tool.schema .string() .describe( "Why this junction rendering action is needed for the user request.", ), render_ref: tool.schema .string() .describe( "上一步通过 store_render_ref 获得的渲染引用 ID(res-...)。前端会按该引用拉取完整 payload 并渲染。不可直接传入本地文件路径或完整 JSON 数据。", ), }, async execute() { // 工具参数里只需要 render_ref;浏览器端会再用该引用回读完整 payload.data 并完成渲染。 return "已在地图上应用节点分区渲染。"; }, });