feat(agent): 完善分析编排与结果传输
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"开始一个新的业务活动阶段。仅在语义阶段发生变化时调用一次,用 title 概括阶段,用 reason 说明本阶段为何必要;同一阶段内的多个工具动作不要重复调用。该工具只更新用户可见的过程信息,不执行外部操作。",
|
||||
args: {
|
||||
title: tool.schema
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("面向用户的简短业务阶段标题,不包含工具名、函数名、文件名或命令。"),
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("本阶段对完成用户目标的必要性,使用一句简洁的自然语言。"),
|
||||
todos: tool.schema
|
||||
.array(
|
||||
tool.schema.object({
|
||||
id: tool.schema.string().optional(),
|
||||
content: tool.schema.string().min(1),
|
||||
status: tool.schema.enum([
|
||||
"pending",
|
||||
"in_progress",
|
||||
"completed",
|
||||
"cancelled",
|
||||
]),
|
||||
priority: tool.schema.enum(["low", "medium", "high"]).optional(),
|
||||
}),
|
||||
)
|
||||
.optional()
|
||||
.describe(
|
||||
"已有任务计划时提交完整状态快照,使本阶段与任务状态在同一次更新中生效。",
|
||||
),
|
||||
},
|
||||
async execute() {
|
||||
return "活动阶段已更新。";
|
||||
},
|
||||
});
|
||||
@@ -4,11 +4,6 @@ export default tool({
|
||||
description:
|
||||
"在前端地图上对节点或管道图层应用样式,或重置为默认样式。样式参数应尽量与前端样式编辑器字段保持一致。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Why this style action is needed for the current user request.",
|
||||
),
|
||||
layer_id: tool.schema
|
||||
.enum(["junctions", "pipes"])
|
||||
.describe("Target layer id. Must be exactly 'junctions' or 'pipes'."),
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"提交直接展示给用户的最终回答。只能在全部业务动作和其他工具调用完成后调用一次;调用后不得继续调用任何工具或输出额外文本。",
|
||||
args: {
|
||||
answer: tool.schema
|
||||
.string()
|
||||
.min(1)
|
||||
.describe("直接展示给用户的完整最终回答,使用简体中文和 Markdown。"),
|
||||
},
|
||||
async execute() {
|
||||
return "最终回答已提交。";
|
||||
},
|
||||
});
|
||||
@@ -8,9 +8,6 @@ export default tool({
|
||||
description:
|
||||
"调用 TJWater 后端的天地图地理编码服务,将中国境内结构化地址或地点名称转换为经纬度。若需缩放地图,把返回的 location.lon/location.lat 传给 zoom_to_map,并设置 source_crs='EPSG:4326'。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why geocoding is required for the current user request."),
|
||||
keyword: tool.schema
|
||||
.string()
|
||||
.describe("Address or place name to geocode, such as 北京市人民政府."),
|
||||
|
||||
@@ -3,11 +3,6 @@ import { tool } from "@opencode-ai/plugin";
|
||||
export default tool({
|
||||
description: "在前端地图上定位并高亮指定的管网要素。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Why this map positioning action is needed for the user request.",
|
||||
),
|
||||
ids: tool.schema
|
||||
.array(tool.schema.string())
|
||||
.describe("Feature ids to locate."),
|
||||
|
||||
@@ -11,9 +11,6 @@ export default tool({
|
||||
action: tool.schema
|
||||
.enum(["add", "list", "replace", "remove"])
|
||||
.describe("Memory operation to perform."),
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this memory should be persisted for future requests."),
|
||||
scope: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
|
||||
@@ -4,11 +4,6 @@ export default tool({
|
||||
description:
|
||||
"在前端地图上对 junctions 图层应用分区渲染。先把包装格式 { metadata, location: { file_path }, data: { node_area_map, area_ids?, area_colors? } } 写入 RESULT_REF_IMPORT_DIR,location.file_path 必须等于文件绝对路径;再调用 store_render_ref 获得 res-... 引用,最后把引用传入本工具。不要读取并转传完整 ref 内容,也不要直接传本地文件路径。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Why this junction rendering action is needed for the user request.",
|
||||
),
|
||||
render_ref: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
|
||||
@@ -8,9 +8,6 @@ export default tool({
|
||||
description:
|
||||
"搜索当前用户和项目范围内的历史会话 transcript。适合回忆过去讨论过的案例、约束和结论,避免把一次性案例写入 memory。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why prior session history is needed for the current request."),
|
||||
query: tool.schema
|
||||
.string()
|
||||
.describe("What to search for in prior session history."),
|
||||
|
||||
@@ -4,9 +4,6 @@ export default tool({
|
||||
description:
|
||||
"在前端对话界面中渲染图表。折线图/柱状图必须使用 x_data 作为横轴标签,series[].data 作为同长度的一维数值数组,不要把折线数据写成 ECharts 的 [x, y] 二维点数组。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this chart should be rendered for the user request."),
|
||||
title: tool.schema.string().optional().describe("Chart title."),
|
||||
chart_type: tool.schema
|
||||
.enum(["line", "bar", "pie"])
|
||||
|
||||
@@ -21,9 +21,6 @@ export default tool({
|
||||
"remove_script",
|
||||
])
|
||||
.describe("Skill maintenance operation."),
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this skill maintenance action is justified for future reuse."),
|
||||
skill_path: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
|
||||
@@ -23,11 +23,6 @@ export default tool({
|
||||
description:
|
||||
"导入当前对话工作目录下的受控 JSON 包装文件并返回 render_ref。文件必须是 { metadata: object, location: { file_path: string }, data: { node_area_map, area_ids?, area_colors? } },location.file_path 必须与传入的绝对路径完全一致。只接受当前对话工作目录内的真实文件,不接受其他对话目录、目录外路径或指向目录外的符号链接。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"为何需要将此本地渲染数据持久化为 render_ref,以便后续通过 render_junctions 渲染到前端。",
|
||||
),
|
||||
file_path: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
|
||||
@@ -6,15 +6,12 @@ const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"通过本地 Agent 桥接调用 tjwater-cli 命令访问 TJWater 后端服务。提供 CLI 子命令和参数。",
|
||||
"通过本地 Agent 桥接调用 tjwater-cli。命令路径和参数不是可自由拼接的语法;若当前会话或已加载工作流没有经过验证的完整命令,必须先调用 help 或 help <命令族>,再从返回的 command、usage 和 options 中选择。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this tool call is required for the current user request."),
|
||||
command: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"tjwater-cli 子命令,不含二进制路径。示例:'analysis runs list'、'data timeseries realtime links --start-time 2025-01-01T00:00:00+08:00 --end-time 2025-01-01T01:00:00+08:00'",
|
||||
"不含二进制路径。只可使用 help 响应或已验证工作流中出现的完整命令路径和参数,禁止类推不同命令族的层级,例如 analysis runs list 存在不代表 simulation runs list 存在。无法确认时调用 'help'、'help simulation' 或相应前缀的 help。",
|
||||
),
|
||||
timeout: tool.schema
|
||||
.number()
|
||||
@@ -38,7 +35,6 @@ export default tool({
|
||||
},
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
reason: args.reason,
|
||||
command: args.command,
|
||||
store_result: args.store_result,
|
||||
timeout: args.timeout,
|
||||
|
||||
@@ -3,11 +3,6 @@ import { tool } from "@opencode-ai/plugin";
|
||||
export default tool({
|
||||
description: "为选定的管网要素打开前端的历史记录或计算结果面板。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"Why this history panel should be opened for the current task.",
|
||||
),
|
||||
feature_infos: tool.schema
|
||||
.array(tool.schema.tuple([tool.schema.string(), tool.schema.string()]))
|
||||
.describe("List of [id, type] pairs."),
|
||||
|
||||
@@ -3,9 +3,6 @@ import { tool } from "@opencode-ai/plugin";
|
||||
export default tool({
|
||||
description: "打开前端的 SCADA 监测数据历史面板。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why SCADA panel interaction is required for this request."),
|
||||
device_ids: tool.schema
|
||||
.array(tool.schema.string())
|
||||
.optional()
|
||||
|
||||
@@ -8,9 +8,6 @@ export default tool({
|
||||
description:
|
||||
"调用 TJWater 后端的实时网页搜索服务。适合查询新闻、政策、规范、产品资料、公开网页事实等可能变化的信息。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why web search is required for the current user request."),
|
||||
query: tool.schema.string().describe("Search query text."),
|
||||
freshness: tool.schema
|
||||
.enum(["no_limit", "one_day", "one_week", "one_month", "one_year"])
|
||||
|
||||
@@ -4,9 +4,6 @@ export default tool({
|
||||
description:
|
||||
"在前端地图上缩放定位到坐标。默认坐标为 EPSG:3857;如果来自天地图 geocode 的 lon/lat,传 source_crs='EPSG:4326',前端会转换为 EPSG:3857 后缩放。",
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this map zoom action is needed for the current request."),
|
||||
x: tool.schema
|
||||
.number()
|
||||
.describe("X coordinate. For EPSG:4326 this is longitude; for EPSG:3857 this is meters."),
|
||||
|
||||
Reference in New Issue
Block a user