@myassis/gateway 1.0.52 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -152,6 +152,9 @@ const editTool = {
|
|
|
152
152
|
},
|
|
153
153
|
handler: async (args) => {
|
|
154
154
|
try {
|
|
155
|
+
if (typeof args === 'string') {
|
|
156
|
+
return { success: false, errorMessage: `参数过大 (${(args.length / 1024).toFixed(1)}KB),大文件请分批进行edit 操作` };
|
|
157
|
+
}
|
|
155
158
|
const { path: filePath, edits } = args;
|
|
156
159
|
// ---- 参数校验 ----
|
|
157
160
|
if (!filePath)
|
|
@@ -136,7 +136,15 @@ exports.fileTool = {
|
|
|
136
136
|
},
|
|
137
137
|
handler: async (args) => {
|
|
138
138
|
try {
|
|
139
|
+
// 如果 args 是原始 JSON 字符串(上游 parseAruments 解析失败时原样返回),
|
|
140
|
+
// 先做轻量级检查:大文件写入时字符串极长,直接拦截避免 JSON.parse 爆内存
|
|
141
|
+
if (typeof args === 'string') {
|
|
142
|
+
return { success: false, errorMessage: `参数过大 (${(args.length / 1024).toFixed(1)}KB),大文件写入请分批进行或使用多次 edit 操作` };
|
|
143
|
+
}
|
|
139
144
|
const { action, path: filePath, content, searchQuery, maxResults = 50, excludeDirs, caseSensitive = false, wholeWord = false } = args;
|
|
145
|
+
if (!action) {
|
|
146
|
+
return { success: false, errorMessage: '缺少必需参数: action' };
|
|
147
|
+
}
|
|
140
148
|
const effectiveExcludeDirs = typeof excludeDirs === 'string' && excludeDirs.trim()
|
|
141
149
|
? [...new Set([...DEFAULT_EXCLUDE_DIRS, ...excludeDirs.split(',').map((d) => d.trim()).filter(Boolean)])]
|
|
142
150
|
: DEFAULT_EXCLUDE_DIRS;
|