style(opencode): format tool definitions
This commit is contained in:
@@ -6,7 +6,9 @@ export default tool({
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this style action is needed for the current user request."),
|
||||
.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'."),
|
||||
@@ -16,14 +18,26 @@ export default tool({
|
||||
.describe("Whether to reset the target layer to its default style."),
|
||||
style_config: tool.schema
|
||||
.object({
|
||||
property: tool.schema.string().optional().describe("Data property to render."),
|
||||
property: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Data property to render."),
|
||||
classification_method: tool.schema
|
||||
.enum(["pretty_breaks", "custom_breaks"])
|
||||
.optional()
|
||||
.describe("Classification method."),
|
||||
segments: tool.schema.number().optional().describe("Number of segments."),
|
||||
min_size: tool.schema.number().optional().describe("Minimum point radius."),
|
||||
max_size: tool.schema.number().optional().describe("Maximum point radius."),
|
||||
segments: tool.schema
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Number of segments."),
|
||||
min_size: tool.schema
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Minimum point radius."),
|
||||
max_size: tool.schema
|
||||
.number()
|
||||
.optional()
|
||||
.describe("Maximum point radius."),
|
||||
min_stroke_width: tool.schema
|
||||
.number()
|
||||
.optional()
|
||||
@@ -43,8 +57,14 @@ export default tool({
|
||||
single_palette_index: tool.schema.number().optional(),
|
||||
gradient_palette_index: tool.schema.number().optional(),
|
||||
rainbow_palette_index: tool.schema.number().optional(),
|
||||
show_labels: tool.schema.boolean().optional().describe("Whether to show labels."),
|
||||
show_id: tool.schema.boolean().optional().describe("Whether to show ids."),
|
||||
show_labels: tool.schema
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Whether to show labels."),
|
||||
show_id: tool.schema
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Whether to show ids."),
|
||||
opacity: tool.schema.number().optional().describe("Opacity in [0, 1]."),
|
||||
adjust_width_by_property: tool.schema
|
||||
.boolean()
|
||||
|
||||
@@ -5,8 +5,12 @@ export default tool({
|
||||
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."),
|
||||
.describe(
|
||||
"Why this map positioning action is needed for the user request.",
|
||||
),
|
||||
ids: tool.schema
|
||||
.array(tool.schema.string())
|
||||
.describe("Feature ids to locate."),
|
||||
feature_type: tool.schema
|
||||
.enum(["junction", "pipe", "valve", "reservoir", "pump", "tank"])
|
||||
.describe("Type of feature to locate."),
|
||||
|
||||
@@ -6,7 +6,9 @@ export default tool({
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this junction rendering action is needed for the user request."),
|
||||
.describe(
|
||||
"Why this junction rendering action is needed for the user request.",
|
||||
),
|
||||
render_ref: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
|
||||
@@ -22,18 +22,21 @@ export default tool({
|
||||
.describe("Optional maximum number of hits to return."),
|
||||
},
|
||||
async execute(args, context) {
|
||||
const response = await fetch(`${internalBaseUrl}/internal/tools/session-search`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
const response = await fetch(
|
||||
`${internalBaseUrl}/internal/tools/session-search`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
max_results: args.max_results,
|
||||
query: args.query,
|
||||
session_id: context.sessionID,
|
||||
}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
max_results: args.max_results,
|
||||
query: args.query,
|
||||
session_id: context.sessionID,
|
||||
}),
|
||||
});
|
||||
);
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(text);
|
||||
|
||||
@@ -21,8 +21,14 @@ export default tool({
|
||||
}),
|
||||
)
|
||||
.describe("Series data."),
|
||||
x_axis_name: tool.schema.string().optional().describe("X-axis display name."),
|
||||
y_axis_name: tool.schema.string().optional().describe("Y-axis display name."),
|
||||
x_axis_name: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("X-axis display name."),
|
||||
y_axis_name: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Y-axis display name."),
|
||||
},
|
||||
async execute() {
|
||||
// 图表数据已经在工具参数里,前端收到 tool_call 后直接渲染,不再二次请求后端。
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
||||
const internalBaseUrl =
|
||||
process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
||||
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
||||
|
||||
export default tool({
|
||||
@@ -9,7 +10,9 @@ export default tool({
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this local render payload should be persisted as a render_ref."),
|
||||
.describe(
|
||||
"Why this local render payload should be persisted as a render_ref.",
|
||||
),
|
||||
file_path: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
@@ -17,17 +20,20 @@ export default tool({
|
||||
),
|
||||
},
|
||||
async execute(args, context) {
|
||||
const response = await fetch(`${internalBaseUrl}/internal/tools/store-render-ref`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
const response = await fetch(
|
||||
`${internalBaseUrl}/internal/tools/store-render-ref`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
file_path: args.file_path,
|
||||
}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
file_path: args.file_path,
|
||||
}),
|
||||
});
|
||||
);
|
||||
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { tool } from "@opencode-ai/plugin";
|
||||
|
||||
const internalBaseUrl = process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
||||
const internalBaseUrl =
|
||||
process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
||||
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
||||
|
||||
export default tool({
|
||||
@@ -21,19 +22,22 @@ export default tool({
|
||||
.describe("超时秒数,默认 120。大结果集建议设 300+。"),
|
||||
},
|
||||
async execute(args, context) {
|
||||
const response = await fetch(`${internalBaseUrl}/internal/tools/tjwater-cli-call`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
const response = await fetch(
|
||||
`${internalBaseUrl}/internal/tools/tjwater-cli-call`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"x-agent-internal-token": internalToken,
|
||||
},
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
reason: args.reason,
|
||||
command: args.command,
|
||||
timeout: args.timeout,
|
||||
}),
|
||||
},
|
||||
body: JSON.stringify({
|
||||
session_id: context.sessionID,
|
||||
reason: args.reason,
|
||||
command: args.command,
|
||||
timeout: args.timeout,
|
||||
}),
|
||||
});
|
||||
);
|
||||
|
||||
const text = await response.text();
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -5,15 +5,23 @@ export default tool({
|
||||
args: {
|
||||
reason: tool.schema
|
||||
.string()
|
||||
.describe("Why this history panel should be opened for the current task."),
|
||||
.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."),
|
||||
data_type: tool.schema
|
||||
.enum(["realtime", "scheme", "none"])
|
||||
.describe("History data source type."),
|
||||
start_time: tool.schema.string().optional().describe("Optional ISO8601 start time."),
|
||||
end_time: tool.schema.string().optional().describe("Optional ISO8601 end time."),
|
||||
start_time: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Optional ISO8601 start time."),
|
||||
end_time: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Optional ISO8601 end time."),
|
||||
},
|
||||
async execute() {
|
||||
// 返回短确认即可;面板打开动作由前端根据 tool_call 参数完成。
|
||||
|
||||
@@ -10,9 +10,18 @@ export default tool({
|
||||
.array(tool.schema.string())
|
||||
.optional()
|
||||
.describe("Preferred SCADA device ids."),
|
||||
device_id: tool.schema.string().optional().describe("Single SCADA device id."),
|
||||
start_time: tool.schema.string().optional().describe("Optional ISO8601 start time."),
|
||||
end_time: tool.schema.string().optional().describe("Optional ISO8601 end time."),
|
||||
device_id: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Single SCADA device id."),
|
||||
start_time: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Optional ISO8601 start time."),
|
||||
end_time: tool.schema
|
||||
.string()
|
||||
.optional()
|
||||
.describe("Optional ISO8601 end time."),
|
||||
},
|
||||
async execute() {
|
||||
// SCADA 面板仍在浏览器侧执行,工具结果不承载实际监测数据。
|
||||
|
||||
Reference in New Issue
Block a user