aemeathcli 1.0.9 → 1.0.11
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.
- package/LICENSE +21 -0
- package/README.md +609 -608
- package/dist/App-YAHJUWCX.js +4274 -0
- package/dist/App-YAHJUWCX.js.map +1 -0
- package/dist/agent-store/architect.md +32 -0
- package/dist/agent-store/debugger.md +32 -0
- package/dist/agent-store/developer.md +29 -0
- package/dist/agent-store/documenter.md +30 -0
- package/dist/agent-store/researcher.md +31 -0
- package/dist/agent-store/reviewer.md +28 -0
- package/dist/agent-store/supervisor.md +37 -0
- package/dist/agent-store/tester.md +30 -0
- package/dist/api-key-fallback-UN3TJEOO.js +11 -0
- package/dist/{api-key-fallback-YQQBOQIL.js.map → api-key-fallback-UN3TJEOO.js.map} +1 -1
- package/dist/auth-status-EIM5A5KL.js +13 -0
- package/dist/auth-status-EIM5A5KL.js.map +1 -0
- package/dist/{chunk-UY2SYSEZ.js → chunk-25UNNEHN.js} +32 -103
- package/dist/chunk-25UNNEHN.js.map +1 -0
- package/dist/{chunk-CYQNBB25.js → chunk-2GKOK6T7.js} +28 -5
- package/dist/chunk-2GKOK6T7.js.map +1 -0
- package/dist/{chunk-MFBHNWGV.js → chunk-2LF7ALGR.js} +12 -20
- package/dist/chunk-2LF7ALGR.js.map +1 -0
- package/dist/{chunk-H66O5Z2V.js → chunk-2NWNIKBK.js} +42 -7
- package/dist/chunk-2NWNIKBK.js.map +1 -0
- package/dist/chunk-3TSPZRGM.js +26 -0
- package/dist/chunk-3TSPZRGM.js.map +1 -0
- package/dist/{chunk-ZGOHARPV.js → chunk-473JN6M5.js} +2 -2
- package/dist/chunk-473JN6M5.js.map +1 -0
- package/dist/{chunk-IYW62KKR.js → chunk-5XFSV6PF.js} +66 -23
- package/dist/chunk-5XFSV6PF.js.map +1 -0
- package/dist/{chunk-HCIHOHLX.js → chunk-62HSGYQD.js} +2 -2
- package/dist/chunk-62HSGYQD.js.map +1 -0
- package/dist/{chunk-I5PZ4JTS.js → chunk-6GUD7QIM.js} +4 -4
- package/dist/chunk-6GUD7QIM.js.map +1 -0
- package/dist/{chunk-4IJD72YB.js → chunk-AQ23TYSQ.js} +7 -7
- package/dist/chunk-AQ23TYSQ.js.map +1 -0
- package/dist/{chunk-NBR3GHMT.js → chunk-BY4DAKUU.js} +39 -7
- package/dist/chunk-BY4DAKUU.js.map +1 -0
- package/dist/chunk-CC7MGWYY.js +12 -0
- package/dist/chunk-CC7MGWYY.js.map +1 -0
- package/dist/chunk-CTFZTARK.js +155 -0
- package/dist/chunk-CTFZTARK.js.map +1 -0
- package/dist/chunk-FIC7AK4Q.js +232 -0
- package/dist/chunk-FIC7AK4Q.js.map +1 -0
- package/dist/chunk-GU33WKPG.js +140 -0
- package/dist/chunk-GU33WKPG.js.map +1 -0
- package/dist/{chunk-VUG4IZ7J.js → chunk-H2SYKIMI.js} +10 -10
- package/dist/chunk-H2SYKIMI.js.map +1 -0
- package/dist/{chunk-JAXXTYID.js → chunk-HEKFAKVH.js} +2 -2
- package/dist/chunk-HEKFAKVH.js.map +1 -0
- package/dist/chunk-IARA5XYP.js +186 -0
- package/dist/chunk-IARA5XYP.js.map +1 -0
- package/dist/{chunk-HMJRPNPZ.js → chunk-LCYH4T6N.js} +95 -23
- package/dist/chunk-LCYH4T6N.js.map +1 -0
- package/dist/{chunk-CARHU3DO.js → chunk-LDVY5ELP.js} +66 -18
- package/dist/chunk-LDVY5ELP.js.map +1 -0
- package/dist/chunk-OCJPQFOR.js +88 -0
- package/dist/chunk-OCJPQFOR.js.map +1 -0
- package/dist/chunk-ODBY7S4X.js +141 -0
- package/dist/chunk-ODBY7S4X.js.map +1 -0
- package/dist/{chunk-DAHGLHNR.js → chunk-ONQ4WCUI.js} +7 -142
- package/dist/chunk-ONQ4WCUI.js.map +1 -0
- package/dist/{chunk-WPP3PEDE.js → chunk-P5TKZM3T.js} +32 -107
- package/dist/chunk-P5TKZM3T.js.map +1 -0
- package/dist/{chunk-ASGRGXYK.js → chunk-P66WDACW.js} +23 -22
- package/dist/chunk-P66WDACW.js.map +1 -0
- package/dist/{chunk-LSOYPSAT.js → chunk-QCRK4QEL.js} +4 -4
- package/dist/chunk-QCRK4QEL.js.map +1 -0
- package/dist/{chunk-YL5XFHR3.js → chunk-ROJPFPJ7.js} +2 -2
- package/dist/chunk-ROJPFPJ7.js.map +1 -0
- package/dist/chunk-RP2TAL3J.js +71 -0
- package/dist/chunk-RP2TAL3J.js.map +1 -0
- package/dist/{chunk-6PDJ45T4.js → chunk-RYOB3TLZ.js} +51 -26
- package/dist/chunk-RYOB3TLZ.js.map +1 -0
- package/dist/{chunk-Y5XVD2CD.js → chunk-SOQFMNQC.js} +110 -83
- package/dist/chunk-SOQFMNQC.js.map +1 -0
- package/dist/{chunk-TEVZS4FA.js → chunk-TDFTX32B.js} +16 -9
- package/dist/chunk-TDFTX32B.js.map +1 -0
- package/dist/chunk-VBLLDY4R.js +38 -0
- package/dist/chunk-VBLLDY4R.js.map +1 -0
- package/dist/{chunk-CGEV3ARR.js → chunk-VJNQJALF.js} +4 -4
- package/dist/chunk-VJNQJALF.js.map +1 -0
- package/dist/chunk-WAYSJMPS.js +26 -0
- package/dist/chunk-WAYSJMPS.js.map +1 -0
- package/dist/chunk-WC72BRHR.js +241 -0
- package/dist/chunk-WC72BRHR.js.map +1 -0
- package/dist/{chunk-MXZSI3AY.js → chunk-YPFOE2QJ.js} +43 -11
- package/dist/chunk-YPFOE2QJ.js.map +1 -0
- package/dist/claude-adapter-6P4SJH7P.js +7 -0
- package/dist/{claude-adapter-QMLFMSP3.js.map → claude-adapter-6P4SJH7P.js.map} +1 -1
- package/dist/{claude-login-5WELXPKT.js → claude-login-IS5WTBMP.js} +10 -10
- package/dist/claude-login-IS5WTBMP.js.map +1 -0
- package/dist/cli.js +371 -172
- package/dist/cli.js.map +1 -1
- package/dist/{codex-login-DDJBCT43.js → codex-login-GMPF64MR.js} +18 -17
- package/dist/codex-login-GMPF64MR.js.map +1 -0
- package/dist/config-store-POB6I37G.js +7 -0
- package/dist/{config-store-W6FBCQAQ.js.map → config-store-POB6I37G.js.map} +1 -1
- package/dist/conversation-store-PRBHWQMJ.js +4 -0
- package/dist/conversation-store-PRBHWQMJ.js.map +1 -0
- package/dist/detect-providers-C4SVQHFF.js +4 -0
- package/dist/detect-providers-C4SVQHFF.js.map +1 -0
- package/dist/executor-RUX7VK3T.js +4 -0
- package/dist/{executor-6RIKIGXK.js.map → executor-RUX7VK3T.js.map} +1 -1
- package/dist/first-run-GDEVRFPO.js +230 -0
- package/dist/first-run-GDEVRFPO.js.map +1 -0
- package/dist/gemini-adapter-MV3U4QFH.js +7 -0
- package/dist/{gemini-adapter-6JIHZ7WI.js.map → gemini-adapter-MV3U4QFH.js.map} +1 -1
- package/dist/{gemini-login-YEPK6GGW.js → gemini-login-KE224MSW.js} +13 -14
- package/dist/gemini-login-KE224MSW.js.map +1 -0
- package/dist/index.d.ts +47 -17
- package/dist/index.js +86 -471
- package/dist/index.js.map +1 -1
- package/dist/input-history-MIOO3FIW.js +57 -0
- package/dist/input-history-MIOO3FIW.js.map +1 -0
- package/dist/kimi-adapter-UODMNX6K.js +6 -0
- package/dist/{kimi-adapter-JN4HFFHU.js.map → kimi-adapter-UODMNX6K.js.map} +1 -1
- package/dist/{kimi-login-ZR74MIY4.js → kimi-login-DNT5YBKX.js} +18 -17
- package/dist/kimi-login-DNT5YBKX.js.map +1 -0
- package/dist/logger-PLPDWACQ.js +3 -0
- package/dist/logger-PLPDWACQ.js.map +1 -0
- package/dist/model-discovery-O64ZWPX5.js +6 -0
- package/dist/model-discovery-O64ZWPX5.js.map +1 -0
- package/dist/native-cli-adapters-JMZX2C2C.js +8 -0
- package/dist/{native-cli-adapters-OLW3XX57.js.map → native-cli-adapters-JMZX2C2C.js.map} +1 -1
- package/dist/ollama-adapter-GE67BNSS.js +5 -0
- package/dist/{ollama-adapter-OJQ3FKWK.js.map → ollama-adapter-GE67BNSS.js.map} +1 -1
- package/dist/openai-adapter-SHPLK77L.js +7 -0
- package/dist/{openai-adapter-XU46EN7B.js.map → openai-adapter-SHPLK77L.js.map} +1 -1
- package/dist/pathResolver-A6IXQQFE.js +3 -0
- package/dist/pathResolver-A6IXQQFE.js.map +1 -0
- package/dist/profile-loader-TNAXBLDX.js +162 -0
- package/dist/profile-loader-TNAXBLDX.js.map +1 -0
- package/dist/registry-3NHVCXCZ.js +6 -0
- package/dist/{registry-H7B3AHPQ.js.map → registry-3NHVCXCZ.js.map} +1 -1
- package/dist/registry-7CQ3NCAD.js +5 -0
- package/dist/{registry-OYWYT7WL.js.map → registry-7CQ3NCAD.js.map} +1 -1
- package/dist/server-manager-DES23IBQ.js +5 -0
- package/dist/{server-manager-PTGBHCLS.js.map → server-manager-DES23IBQ.js.map} +1 -1
- package/dist/session-manager-EHD7GWM2.js +12 -0
- package/dist/{session-manager-NYB2RKMS.js.map → session-manager-EHD7GWM2.js.map} +1 -1
- package/dist/skills/built-in/code-review/SKILL.md +85 -0
- package/dist/skills/built-in/commit/SKILL.md +83 -0
- package/dist/skills/built-in/debug/SKILL.md +119 -0
- package/dist/skills/built-in/plan/SKILL.md +123 -0
- package/dist/skills/built-in/refactor/SKILL.md +132 -0
- package/dist/skills/built-in/test/SKILL.md +128 -0
- package/dist/sqlite-store-7ZIVOUNI.js +5 -0
- package/dist/sqlite-store-7ZIVOUNI.js.map +1 -0
- package/dist/team-manager-6DCNLGTC.js +11 -0
- package/dist/{team-manager-HC4XGCFY.js.map → team-manager-6DCNLGTC.js.map} +1 -1
- package/dist/team-state-R2D7DT5M.js +3 -0
- package/dist/team-state-R2D7DT5M.js.map +1 -0
- package/dist/tmux-manager-WBKHUHDT.js +6 -0
- package/dist/{tmux-manager-GPYZ3WQH.js.map → tmux-manager-WBKHUHDT.js.map} +1 -1
- package/dist/tools-I6XCTEZY.js +6 -0
- package/dist/{tools-TSMXMHIF.js.map → tools-I6XCTEZY.js.map} +1 -1
- package/package.json +93 -89
- package/dist/App-TE3JJKOW.js +0 -2789
- package/dist/App-TE3JJKOW.js.map +0 -1
- package/dist/api-key-fallback-YQQBOQIL.js +0 -11
- package/dist/chunk-4IJD72YB.js.map +0 -1
- package/dist/chunk-6PDJ45T4.js.map +0 -1
- package/dist/chunk-ASGRGXYK.js.map +0 -1
- package/dist/chunk-CARHU3DO.js.map +0 -1
- package/dist/chunk-CGEV3ARR.js.map +0 -1
- package/dist/chunk-CS5X3BWX.js +0 -27
- package/dist/chunk-CS5X3BWX.js.map +0 -1
- package/dist/chunk-CYQNBB25.js.map +0 -1
- package/dist/chunk-DAHGLHNR.js.map +0 -1
- package/dist/chunk-H66O5Z2V.js.map +0 -1
- package/dist/chunk-HCIHOHLX.js.map +0 -1
- package/dist/chunk-HMJRPNPZ.js.map +0 -1
- package/dist/chunk-I5PZ4JTS.js.map +0 -1
- package/dist/chunk-IYW62KKR.js.map +0 -1
- package/dist/chunk-JAXXTYID.js.map +0 -1
- package/dist/chunk-LSOYPSAT.js.map +0 -1
- package/dist/chunk-MFBHNWGV.js.map +0 -1
- package/dist/chunk-MXZSI3AY.js.map +0 -1
- package/dist/chunk-NBR3GHMT.js.map +0 -1
- package/dist/chunk-TEVZS4FA.js.map +0 -1
- package/dist/chunk-UY2SYSEZ.js.map +0 -1
- package/dist/chunk-VUG4IZ7J.js.map +0 -1
- package/dist/chunk-WAHVZH7V.js +0 -260
- package/dist/chunk-WAHVZH7V.js.map +0 -1
- package/dist/chunk-WPP3PEDE.js.map +0 -1
- package/dist/chunk-Y5XVD2CD.js.map +0 -1
- package/dist/chunk-YL5XFHR3.js.map +0 -1
- package/dist/chunk-ZGOHARPV.js.map +0 -1
- package/dist/claude-adapter-QMLFMSP3.js +0 -6
- package/dist/claude-login-5WELXPKT.js.map +0 -1
- package/dist/codex-login-DDJBCT43.js.map +0 -1
- package/dist/config-store-W6FBCQAQ.js +0 -6
- package/dist/executor-6RIKIGXK.js +0 -4
- package/dist/gemini-adapter-6JIHZ7WI.js +0 -6
- package/dist/gemini-login-YEPK6GGW.js.map +0 -1
- package/dist/kimi-adapter-JN4HFFHU.js +0 -6
- package/dist/kimi-login-ZR74MIY4.js.map +0 -1
- package/dist/native-cli-adapters-OLW3XX57.js +0 -6
- package/dist/ollama-adapter-OJQ3FKWK.js +0 -6
- package/dist/openai-adapter-XU46EN7B.js +0 -6
- package/dist/registry-H7B3AHPQ.js +0 -5
- package/dist/registry-OYWYT7WL.js +0 -6
- package/dist/server-manager-PTGBHCLS.js +0 -5
- package/dist/session-manager-NYB2RKMS.js +0 -12
- package/dist/team-manager-HC4XGCFY.js +0 -11
- package/dist/tmux-manager-GPYZ3WQH.js +0 -6
- package/dist/tools-TSMXMHIF.js +0 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { validatePath, isCommandBlocked, redactSecrets } from './chunk-
|
|
2
|
-
import { FileNotFoundError, ExecutionTimeoutError } from './chunk-
|
|
3
|
-
import { logger } from './chunk-
|
|
1
|
+
import { validatePath, isPathAllowed, isCommandBlocked, redactSecrets } from './chunk-VBLLDY4R.js';
|
|
2
|
+
import { FileNotFoundError, ExecutionTimeoutError } from './chunk-473JN6M5.js';
|
|
3
|
+
import { logger } from './chunk-HEKFAKVH.js';
|
|
4
4
|
import { stat, readFile, mkdir, writeFile } from 'fs/promises';
|
|
5
5
|
import { dirname, resolve, extname } from 'path';
|
|
6
6
|
import fg from 'fast-glob';
|
|
@@ -72,7 +72,7 @@ var ToolRegistry = class {
|
|
|
72
72
|
isError: true
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
if (tool.requiresApproval(context
|
|
75
|
+
if (tool.requiresApproval(context, call.arguments)) {
|
|
76
76
|
return {
|
|
77
77
|
toolCallId: call.id,
|
|
78
78
|
name: call.name,
|
|
@@ -82,7 +82,7 @@ var ToolRegistry = class {
|
|
|
82
82
|
}
|
|
83
83
|
try {
|
|
84
84
|
logger.debug({ toolName: call.name, args: redactToolArgs(call.arguments) }, "Executing tool");
|
|
85
|
-
const result = await tool.execute(call.arguments);
|
|
85
|
+
const result = await tool.execute(call.arguments, context);
|
|
86
86
|
return {
|
|
87
87
|
...result,
|
|
88
88
|
toolCallId: call.id,
|
|
@@ -168,10 +168,6 @@ function formatWithLineNumbers(content, offset, limit) {
|
|
|
168
168
|
return `${lineNum} ${truncated}`;
|
|
169
169
|
}).join("\n");
|
|
170
170
|
}
|
|
171
|
-
var projectRoot = process.cwd();
|
|
172
|
-
function setReadProjectRoot(root) {
|
|
173
|
-
projectRoot = root;
|
|
174
|
-
}
|
|
175
171
|
function createReadTool() {
|
|
176
172
|
return {
|
|
177
173
|
definition: {
|
|
@@ -201,10 +197,10 @@ function createReadTool() {
|
|
|
201
197
|
]
|
|
202
198
|
},
|
|
203
199
|
category: "file",
|
|
204
|
-
requiresApproval: (
|
|
200
|
+
requiresApproval: (_context, _args) => {
|
|
205
201
|
return false;
|
|
206
202
|
},
|
|
207
|
-
execute: async (args) => {
|
|
203
|
+
execute: async (args, context) => {
|
|
208
204
|
const filePath = args["file_path"];
|
|
209
205
|
if (typeof filePath !== "string" || filePath.length === 0) {
|
|
210
206
|
return {
|
|
@@ -214,6 +210,8 @@ function createReadTool() {
|
|
|
214
210
|
isError: true
|
|
215
211
|
};
|
|
216
212
|
}
|
|
213
|
+
const projectRoot = context.projectRoot;
|
|
214
|
+
const allowedPaths = context.allowedPaths;
|
|
217
215
|
let resolvedPath;
|
|
218
216
|
try {
|
|
219
217
|
resolvedPath = validatePath(filePath, projectRoot);
|
|
@@ -221,6 +219,14 @@ function createReadTool() {
|
|
|
221
219
|
const msg = err instanceof Error ? err.message : "Path validation failed";
|
|
222
220
|
return { toolCallId: "", name: "read", content: msg, isError: true };
|
|
223
221
|
}
|
|
222
|
+
if (!isPathAllowed(resolvedPath, allowedPaths, projectRoot)) {
|
|
223
|
+
return {
|
|
224
|
+
toolCallId: "",
|
|
225
|
+
name: "read",
|
|
226
|
+
content: `Access denied: ${resolvedPath} is outside the configured allowed paths.`,
|
|
227
|
+
isError: true
|
|
228
|
+
};
|
|
229
|
+
}
|
|
224
230
|
let fileStat;
|
|
225
231
|
try {
|
|
226
232
|
fileStat = await stat(resolvedPath);
|
|
@@ -300,10 +306,6 @@ function isConfigFile(filePath) {
|
|
|
300
306
|
const base = filePath.split("/").pop() ?? "";
|
|
301
307
|
return CONFIG_EXTENSIONS.has(ext) || SENSITIVE_FILENAMES.has(base);
|
|
302
308
|
}
|
|
303
|
-
var projectRoot2 = process.cwd();
|
|
304
|
-
function setWriteProjectRoot(root) {
|
|
305
|
-
projectRoot2 = root;
|
|
306
|
-
}
|
|
307
309
|
function createWriteTool() {
|
|
308
310
|
return {
|
|
309
311
|
definition: {
|
|
@@ -325,10 +327,10 @@ function createWriteTool() {
|
|
|
325
327
|
]
|
|
326
328
|
},
|
|
327
329
|
category: "file",
|
|
328
|
-
requiresApproval: (
|
|
329
|
-
return
|
|
330
|
+
requiresApproval: (context, _args) => {
|
|
331
|
+
return context.permissionMode === "strict" || context.permissionMode === "standard";
|
|
330
332
|
},
|
|
331
|
-
execute: async (args) => {
|
|
333
|
+
execute: async (args, context) => {
|
|
332
334
|
const filePath = args["file_path"];
|
|
333
335
|
const content = args["content"];
|
|
334
336
|
if (typeof filePath !== "string" || filePath.length === 0) {
|
|
@@ -347,13 +349,23 @@ function createWriteTool() {
|
|
|
347
349
|
isError: true
|
|
348
350
|
};
|
|
349
351
|
}
|
|
352
|
+
const projectRoot = context.projectRoot;
|
|
353
|
+
const allowedPaths = context.allowedPaths;
|
|
350
354
|
let resolvedPath;
|
|
351
355
|
try {
|
|
352
|
-
resolvedPath = validatePath(filePath,
|
|
356
|
+
resolvedPath = validatePath(filePath, projectRoot);
|
|
353
357
|
} catch (err) {
|
|
354
358
|
const msg = err instanceof Error ? err.message : "Path validation failed";
|
|
355
359
|
return { toolCallId: "", name: "write", content: msg, isError: true };
|
|
356
360
|
}
|
|
361
|
+
if (!isPathAllowed(resolvedPath, allowedPaths, projectRoot)) {
|
|
362
|
+
return {
|
|
363
|
+
toolCallId: "",
|
|
364
|
+
name: "write",
|
|
365
|
+
content: `Access denied: ${resolvedPath} is outside the configured allowed paths.`,
|
|
366
|
+
isError: true
|
|
367
|
+
};
|
|
368
|
+
}
|
|
357
369
|
const parentDir = dirname(resolvedPath);
|
|
358
370
|
try {
|
|
359
371
|
await mkdir(parentDir, { recursive: true });
|
|
@@ -399,10 +411,6 @@ function createWriteTool() {
|
|
|
399
411
|
}
|
|
400
412
|
};
|
|
401
413
|
}
|
|
402
|
-
var projectRoot3 = process.cwd();
|
|
403
|
-
function setEditProjectRoot(root) {
|
|
404
|
-
projectRoot3 = root;
|
|
405
|
-
}
|
|
406
414
|
function createEditTool() {
|
|
407
415
|
return {
|
|
408
416
|
definition: {
|
|
@@ -437,10 +445,10 @@ function createEditTool() {
|
|
|
437
445
|
]
|
|
438
446
|
},
|
|
439
447
|
category: "file",
|
|
440
|
-
requiresApproval: (
|
|
441
|
-
return
|
|
448
|
+
requiresApproval: (context, _args) => {
|
|
449
|
+
return context.permissionMode === "strict" || context.permissionMode === "standard";
|
|
442
450
|
},
|
|
443
|
-
execute: async (args) => {
|
|
451
|
+
execute: async (args, context) => {
|
|
444
452
|
const filePath = args["file_path"];
|
|
445
453
|
const oldString = args["old_string"];
|
|
446
454
|
const newString = args["new_string"];
|
|
@@ -477,13 +485,23 @@ function createEditTool() {
|
|
|
477
485
|
isError: true
|
|
478
486
|
};
|
|
479
487
|
}
|
|
488
|
+
const projectRoot = context.projectRoot;
|
|
489
|
+
const allowedPaths = context.allowedPaths;
|
|
480
490
|
let resolvedPath;
|
|
481
491
|
try {
|
|
482
|
-
resolvedPath = validatePath(filePath,
|
|
492
|
+
resolvedPath = validatePath(filePath, projectRoot);
|
|
483
493
|
} catch (err) {
|
|
484
494
|
const msg = err instanceof Error ? err.message : "Path validation failed";
|
|
485
495
|
return { toolCallId: "", name: "edit", content: msg, isError: true };
|
|
486
496
|
}
|
|
497
|
+
if (!isPathAllowed(resolvedPath, allowedPaths, projectRoot)) {
|
|
498
|
+
return {
|
|
499
|
+
toolCallId: "",
|
|
500
|
+
name: "edit",
|
|
501
|
+
content: `Access denied: ${resolvedPath} is outside the configured allowed paths.`,
|
|
502
|
+
isError: true
|
|
503
|
+
};
|
|
504
|
+
}
|
|
487
505
|
try {
|
|
488
506
|
const fileStat = await stat(resolvedPath);
|
|
489
507
|
if (!fileStat.isFile()) {
|
|
@@ -545,10 +563,6 @@ function createEditTool() {
|
|
|
545
563
|
};
|
|
546
564
|
}
|
|
547
565
|
var MAX_RESULTS = 1e3;
|
|
548
|
-
var projectRoot4 = process.cwd();
|
|
549
|
-
function setGlobProjectRoot(root) {
|
|
550
|
-
projectRoot4 = root;
|
|
551
|
-
}
|
|
552
566
|
function createGlobTool() {
|
|
553
567
|
return {
|
|
554
568
|
definition: {
|
|
@@ -570,10 +584,10 @@ function createGlobTool() {
|
|
|
570
584
|
]
|
|
571
585
|
},
|
|
572
586
|
category: "search",
|
|
573
|
-
requiresApproval: (
|
|
587
|
+
requiresApproval: (_context, _args) => {
|
|
574
588
|
return false;
|
|
575
589
|
},
|
|
576
|
-
execute: async (args) => {
|
|
590
|
+
execute: async (args, context) => {
|
|
577
591
|
const pattern = args["pattern"];
|
|
578
592
|
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
579
593
|
return {
|
|
@@ -583,12 +597,22 @@ function createGlobTool() {
|
|
|
583
597
|
isError: true
|
|
584
598
|
};
|
|
585
599
|
}
|
|
600
|
+
const projectRoot = context.projectRoot;
|
|
601
|
+
const allowedPaths = context.allowedPaths;
|
|
586
602
|
let searchPath;
|
|
587
603
|
if (typeof args["path"] === "string" && args["path"].length > 0) {
|
|
588
|
-
const resolved = resolve(
|
|
589
|
-
searchPath = validatePath(resolved,
|
|
604
|
+
const resolved = resolve(projectRoot, args["path"]);
|
|
605
|
+
searchPath = validatePath(resolved, projectRoot);
|
|
590
606
|
} else {
|
|
591
|
-
searchPath =
|
|
607
|
+
searchPath = projectRoot;
|
|
608
|
+
}
|
|
609
|
+
if (!isPathAllowed(searchPath, allowedPaths, projectRoot)) {
|
|
610
|
+
return {
|
|
611
|
+
toolCallId: "",
|
|
612
|
+
name: "glob",
|
|
613
|
+
content: `Access denied: ${searchPath} is outside the configured allowed paths.`,
|
|
614
|
+
isError: true
|
|
615
|
+
};
|
|
592
616
|
}
|
|
593
617
|
let matchedPaths;
|
|
594
618
|
try {
|
|
@@ -742,10 +766,6 @@ function applyLimits(output, headLimit, offset) {
|
|
|
742
766
|
}
|
|
743
767
|
return result;
|
|
744
768
|
}
|
|
745
|
-
var projectRoot5 = process.cwd();
|
|
746
|
-
function setGrepProjectRoot(root) {
|
|
747
|
-
projectRoot5 = root;
|
|
748
|
-
}
|
|
749
769
|
function createGrepTool() {
|
|
750
770
|
return {
|
|
751
771
|
definition: {
|
|
@@ -833,10 +853,10 @@ function createGrepTool() {
|
|
|
833
853
|
]
|
|
834
854
|
},
|
|
835
855
|
category: "search",
|
|
836
|
-
requiresApproval: (
|
|
856
|
+
requiresApproval: (_context, _args) => {
|
|
837
857
|
return false;
|
|
838
858
|
},
|
|
839
|
-
execute: async (args) => {
|
|
859
|
+
execute: async (args, context) => {
|
|
840
860
|
const pattern = args["pattern"];
|
|
841
861
|
if (typeof pattern !== "string" || pattern.length === 0) {
|
|
842
862
|
return {
|
|
@@ -846,12 +866,22 @@ function createGrepTool() {
|
|
|
846
866
|
isError: true
|
|
847
867
|
};
|
|
848
868
|
}
|
|
869
|
+
const projectRoot = context.projectRoot;
|
|
870
|
+
const allowedPaths = context.allowedPaths;
|
|
849
871
|
let searchPath;
|
|
850
872
|
if (typeof args["path"] === "string" && args["path"].length > 0) {
|
|
851
|
-
const resolved = resolve(
|
|
852
|
-
searchPath = validatePath(resolved,
|
|
873
|
+
const resolved = resolve(projectRoot, args["path"]);
|
|
874
|
+
searchPath = validatePath(resolved, projectRoot);
|
|
853
875
|
} else {
|
|
854
|
-
searchPath =
|
|
876
|
+
searchPath = projectRoot;
|
|
877
|
+
}
|
|
878
|
+
if (!isPathAllowed(searchPath, allowedPaths, projectRoot)) {
|
|
879
|
+
return {
|
|
880
|
+
toolCallId: "",
|
|
881
|
+
name: "grep",
|
|
882
|
+
content: `Access denied: ${searchPath} is outside the configured allowed paths.`,
|
|
883
|
+
isError: true
|
|
884
|
+
};
|
|
855
885
|
}
|
|
856
886
|
const outputMode = args["output_mode"] === "content" || args["output_mode"] === "count" ? args["output_mode"] : "files_with_matches";
|
|
857
887
|
const headLimit = typeof args["head_limit"] === "number" ? args["head_limit"] : DEFAULT_HEAD_LIMIT;
|
|
@@ -984,14 +1014,6 @@ function truncateOutput(output) {
|
|
|
984
1014
|
}
|
|
985
1015
|
return output.substring(0, MAX_OUTPUT_LENGTH2) + "\n...(truncated)";
|
|
986
1016
|
}
|
|
987
|
-
var workingDirectory = process.cwd();
|
|
988
|
-
var blockedCommands = [];
|
|
989
|
-
function setBashWorkingDirectory(dir) {
|
|
990
|
-
workingDirectory = dir;
|
|
991
|
-
}
|
|
992
|
-
function setBashBlockedCommands(commands) {
|
|
993
|
-
blockedCommands = commands;
|
|
994
|
-
}
|
|
995
1017
|
function createBashTool() {
|
|
996
1018
|
return {
|
|
997
1019
|
definition: {
|
|
@@ -1020,17 +1042,18 @@ function createBashTool() {
|
|
|
1020
1042
|
]
|
|
1021
1043
|
},
|
|
1022
1044
|
category: "shell",
|
|
1023
|
-
requiresApproval: (
|
|
1045
|
+
requiresApproval: (context, args) => {
|
|
1024
1046
|
const command = typeof args["command"] === "string" ? args["command"] : "";
|
|
1047
|
+
const blockedCommands = context.blockedCommands;
|
|
1025
1048
|
if (isDangerousCommand(command) || isCommandBlocked(command, blockedCommands)) {
|
|
1026
1049
|
return true;
|
|
1027
1050
|
}
|
|
1028
|
-
if (
|
|
1051
|
+
if (context.permissionMode === "strict") {
|
|
1029
1052
|
return true;
|
|
1030
1053
|
}
|
|
1031
1054
|
return false;
|
|
1032
1055
|
},
|
|
1033
|
-
execute: async (args) => {
|
|
1056
|
+
execute: async (args, context) => {
|
|
1034
1057
|
const command = args["command"];
|
|
1035
1058
|
if (typeof command !== "string" || command.length === 0) {
|
|
1036
1059
|
return {
|
|
@@ -1040,6 +1063,10 @@ function createBashTool() {
|
|
|
1040
1063
|
isError: true
|
|
1041
1064
|
};
|
|
1042
1065
|
}
|
|
1066
|
+
const workingDirectory = context.workingDirectory;
|
|
1067
|
+
const blockedCommands = context.blockedCommands;
|
|
1068
|
+
const allowedPaths = context.allowedPaths;
|
|
1069
|
+
const projectRoot = context.projectRoot;
|
|
1043
1070
|
const lowerCommand = command.toLowerCase().trim();
|
|
1044
1071
|
for (const pattern of DANGEROUS_PATTERNS) {
|
|
1045
1072
|
if (lowerCommand.includes(pattern)) {
|
|
@@ -1059,6 +1086,14 @@ function createBashTool() {
|
|
|
1059
1086
|
isError: true
|
|
1060
1087
|
};
|
|
1061
1088
|
}
|
|
1089
|
+
if (!isPathAllowed(workingDirectory, allowedPaths, projectRoot)) {
|
|
1090
|
+
return {
|
|
1091
|
+
toolCallId: "",
|
|
1092
|
+
name: "bash",
|
|
1093
|
+
content: `Access denied: working directory ${workingDirectory} is outside the configured allowed paths.`,
|
|
1094
|
+
isError: true
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1062
1097
|
let timeoutMs = DEFAULT_TIMEOUT_MS;
|
|
1063
1098
|
if (typeof args["timeout"] === "number") {
|
|
1064
1099
|
timeoutMs = Math.max(1e3, Math.min(args["timeout"], MAX_TIMEOUT_MS));
|
|
@@ -1149,7 +1184,7 @@ function createWebSearchTool() {
|
|
|
1149
1184
|
]
|
|
1150
1185
|
},
|
|
1151
1186
|
category: "web",
|
|
1152
|
-
requiresApproval: (
|
|
1187
|
+
requiresApproval: (_context, _args) => {
|
|
1153
1188
|
return false;
|
|
1154
1189
|
},
|
|
1155
1190
|
execute: async (args) => {
|
|
@@ -1237,6 +1272,9 @@ function isPrivateHostname(hostname) {
|
|
|
1237
1272
|
const ipMatch = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(hostname);
|
|
1238
1273
|
if (ipMatch) {
|
|
1239
1274
|
const [, a, b] = ipMatch;
|
|
1275
|
+
if (a === void 0 || b === void 0) {
|
|
1276
|
+
return false;
|
|
1277
|
+
}
|
|
1240
1278
|
const first = parseInt(a, 10);
|
|
1241
1279
|
const second = parseInt(b, 10);
|
|
1242
1280
|
if (first === 127) return true;
|
|
@@ -1304,9 +1342,7 @@ function createWebFetchTool() {
|
|
|
1304
1342
|
]
|
|
1305
1343
|
},
|
|
1306
1344
|
category: "web",
|
|
1307
|
-
requiresApproval: (
|
|
1308
|
-
return false;
|
|
1309
|
-
},
|
|
1345
|
+
requiresApproval: (_context, _args) => false,
|
|
1310
1346
|
execute: async (args) => {
|
|
1311
1347
|
const rawUrl = args["url"];
|
|
1312
1348
|
if (typeof rawUrl !== "string" || rawUrl.length === 0) {
|
|
@@ -1332,7 +1368,9 @@ function createWebFetchTool() {
|
|
|
1332
1368
|
}
|
|
1333
1369
|
logger.debug({ url, timeout: timeoutMs }, "Fetching URL");
|
|
1334
1370
|
const controller = new AbortController();
|
|
1335
|
-
const timeoutId = setTimeout(() =>
|
|
1371
|
+
const timeoutId = setTimeout(() => {
|
|
1372
|
+
controller.abort();
|
|
1373
|
+
}, timeoutMs);
|
|
1336
1374
|
try {
|
|
1337
1375
|
const response = await fetch(url, {
|
|
1338
1376
|
signal: controller.signal,
|
|
@@ -1463,10 +1501,6 @@ function truncateOutput2(output) {
|
|
|
1463
1501
|
}
|
|
1464
1502
|
return output.substring(0, MAX_OUTPUT_LENGTH3) + "\n...(truncated)";
|
|
1465
1503
|
}
|
|
1466
|
-
var workingDirectory2 = process.cwd();
|
|
1467
|
-
function setGitWorkingDirectory(dir) {
|
|
1468
|
-
workingDirectory2 = dir;
|
|
1469
|
-
}
|
|
1470
1504
|
function createGitTool() {
|
|
1471
1505
|
return {
|
|
1472
1506
|
definition: {
|
|
@@ -1482,7 +1516,7 @@ function createGitTool() {
|
|
|
1482
1516
|
]
|
|
1483
1517
|
},
|
|
1484
1518
|
category: "git",
|
|
1485
|
-
requiresApproval: (
|
|
1519
|
+
requiresApproval: (context, args) => {
|
|
1486
1520
|
const command = typeof args["command"] === "string" ? args["command"] : "";
|
|
1487
1521
|
const subcommand = parseGitSubcommand(command);
|
|
1488
1522
|
if (hasDangerousFlags(command)) {
|
|
@@ -1491,15 +1525,15 @@ function createGitTool() {
|
|
|
1491
1525
|
if (subcommand && READ_ONLY_SUBCOMMANDS.has(subcommand)) {
|
|
1492
1526
|
return false;
|
|
1493
1527
|
}
|
|
1494
|
-
if (
|
|
1528
|
+
if (context.permissionMode === "strict") {
|
|
1495
1529
|
return true;
|
|
1496
1530
|
}
|
|
1497
|
-
if (subcommand === "push" &&
|
|
1531
|
+
if (subcommand === "push" && context.permissionMode === "standard") {
|
|
1498
1532
|
return true;
|
|
1499
1533
|
}
|
|
1500
1534
|
return false;
|
|
1501
1535
|
},
|
|
1502
|
-
execute: async (args) => {
|
|
1536
|
+
execute: async (args, context) => {
|
|
1503
1537
|
const command = args["command"];
|
|
1504
1538
|
if (typeof command !== "string" || command.length === 0) {
|
|
1505
1539
|
return {
|
|
@@ -1509,6 +1543,7 @@ function createGitTool() {
|
|
|
1509
1543
|
isError: true
|
|
1510
1544
|
};
|
|
1511
1545
|
}
|
|
1546
|
+
const workingDirectory = context.workingDirectory;
|
|
1512
1547
|
const trimmedCommand = command.trim();
|
|
1513
1548
|
if (!trimmedCommand.startsWith("git ")) {
|
|
1514
1549
|
return {
|
|
@@ -1536,10 +1571,10 @@ function createGitTool() {
|
|
|
1536
1571
|
isError: true
|
|
1537
1572
|
};
|
|
1538
1573
|
}
|
|
1539
|
-
logger.debug({ command: trimmedCommand, subcommand, cwd:
|
|
1574
|
+
logger.debug({ command: trimmedCommand, subcommand, cwd: workingDirectory }, "Executing git command");
|
|
1540
1575
|
try {
|
|
1541
1576
|
const result = await execaCommand(trimmedCommand, {
|
|
1542
|
-
cwd:
|
|
1577
|
+
cwd: workingDirectory,
|
|
1543
1578
|
timeout: GIT_TIMEOUT_MS,
|
|
1544
1579
|
reject: false,
|
|
1545
1580
|
env: {
|
|
@@ -1583,15 +1618,7 @@ function createGitTool() {
|
|
|
1583
1618
|
}
|
|
1584
1619
|
|
|
1585
1620
|
// src/tools/index.ts
|
|
1586
|
-
function createDefaultRegistry(
|
|
1587
|
-
setReadProjectRoot(context.projectRoot);
|
|
1588
|
-
setWriteProjectRoot(context.projectRoot);
|
|
1589
|
-
setEditProjectRoot(context.projectRoot);
|
|
1590
|
-
setGlobProjectRoot(context.projectRoot);
|
|
1591
|
-
setGrepProjectRoot(context.projectRoot);
|
|
1592
|
-
setBashWorkingDirectory(context.workingDirectory);
|
|
1593
|
-
setBashBlockedCommands(context.blockedCommands);
|
|
1594
|
-
setGitWorkingDirectory(context.workingDirectory);
|
|
1621
|
+
function createDefaultRegistry(_context) {
|
|
1595
1622
|
const registry = new ToolRegistry();
|
|
1596
1623
|
registry.register(createReadTool());
|
|
1597
1624
|
registry.register(createWriteTool());
|
|
@@ -1605,6 +1632,6 @@ function createDefaultRegistry(context) {
|
|
|
1605
1632
|
return registry;
|
|
1606
1633
|
}
|
|
1607
1634
|
|
|
1608
|
-
export { ToolRegistry, createBashTool, createDefaultRegistry, createEditTool, createGitTool, createGlobTool, createGrepTool, createReadTool, createWebFetchTool, createWebSearchTool, createWriteTool,
|
|
1609
|
-
//# sourceMappingURL=chunk-
|
|
1610
|
-
//# sourceMappingURL=chunk-
|
|
1635
|
+
export { ToolRegistry, createBashTool, createDefaultRegistry, createEditTool, createGitTool, createGlobTool, createGrepTool, createReadTool, createWebFetchTool, createWebSearchTool, createWriteTool, setWebSearchProvider };
|
|
1636
|
+
//# sourceMappingURL=chunk-SOQFMNQC.js.map
|
|
1637
|
+
//# sourceMappingURL=chunk-SOQFMNQC.js.map
|