feat(agent): 完善权限与结果引用安全
This commit is contained in:
@@ -3,10 +3,12 @@ import { tool } from "@opencode-ai/plugin";
|
||||
const internalBaseUrl =
|
||||
process.env.TJWATER_AGENT_INTERNAL_BASE_URL ?? "http://127.0.0.1:8787";
|
||||
const internalToken = process.env.TJWATER_AGENT_INTERNAL_TOKEN ?? "";
|
||||
const importDirectory =
|
||||
process.env.RESULT_REF_IMPORT_DIR ?? "./data/result-imports";
|
||||
|
||||
export default tool({
|
||||
description:
|
||||
"将本地 JSON 渲染数据文件存储到受控路径,返回可供 render_junctions 使用的 render_ref(res-...)。前置步骤:先准备好符合 render_junctions 数据结构的 JSON 文件 { node_area_map, area_ids?, area_colors? },写入本地路径后再调用本工具传入该路径,获取 render_ref 后传给 render_junctions 完成前端渲染。",
|
||||
`导入 ${importDirectory} 下的受控 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()
|
||||
@@ -16,7 +18,7 @@ export default tool({
|
||||
file_path: tool.schema
|
||||
.string()
|
||||
.describe(
|
||||
"本地 JSON 文件的绝对路径,内容为 render_junctions 所需的数据结构 { node_area_map, area_ids?, area_colors? }。",
|
||||
`位于 ${importDirectory} 内的包装 JSON 文件绝对路径。必须包含 metadata、location.file_path 和 data;data 才是 render_junctions 使用的 { node_area_map, area_ids?, area_colors? }。`,
|
||||
),
|
||||
},
|
||||
async execute(args, context) {
|
||||
|
||||
Reference in New Issue
Block a user