jinzd-ai-cli 0.4.84 → 0.4.85
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/dist/{batch-QAIJGCG3.js → batch-YBWWF5BJ.js} +2 -2
- package/dist/{chunk-E7G3QCMU.js → chunk-4GMAVGPX.js} +1 -1
- package/dist/{chunk-YY7EPHN4.js → chunk-6IOQPMMT.js} +2 -2
- package/dist/{chunk-V6ZENAVD.js → chunk-APU36NHI.js} +1 -1
- package/dist/{chunk-6WKHRV3J.js → chunk-AX7T3J7G.js} +1 -1
- package/dist/{chunk-3BLU2654.js → chunk-XEXVG3CQ.js} +1 -1
- package/dist/{chunk-UJPR6N6O.js → chunk-YBL4QDLD.js} +10 -10
- package/dist/electron-server.js +15 -15
- package/dist/{hub-MP66YGSM.js → hub-RCX7G5T6.js} +1 -1
- package/dist/index.js +12 -11
- package/dist/{run-tests-N4PJMRDQ.js → run-tests-KWVQL2PO.js} +2 -2
- package/dist/{run-tests-JFREA67C.js → run-tests-PIISCS6B.js} +1 -1
- package/dist/{server-EGK4ASC7.js → server-GAKP7VZ7.js} +115 -19
- package/dist/{server-6QLOHAJJ.js → server-WNL7UU5Q.js} +6 -6
- package/dist/{task-orchestrator-24TW64OU.js → task-orchestrator-H73NIC6T.js} +3 -3
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigManager
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-APU36NHI.js";
|
|
5
5
|
import "./chunk-2ZD3YTVM.js";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-XEXVG3CQ.js";
|
|
7
7
|
|
|
8
8
|
// src/cli/batch.ts
|
|
9
9
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
schemaToJsonSchema,
|
|
4
4
|
truncateForPersist
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-YBL4QDLD.js";
|
|
6
6
|
import {
|
|
7
7
|
AuthError,
|
|
8
8
|
ProviderError,
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
MCP_PROTOCOL_VERSION,
|
|
19
19
|
MCP_TOOL_PREFIX,
|
|
20
20
|
VERSION
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
22
22
|
|
|
23
23
|
// src/providers/claude.ts
|
|
24
24
|
import Anthropic from "@anthropic-ai/sdk";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from "./chunk-6VRJGH25.js";
|
|
20
20
|
import {
|
|
21
21
|
runTestsTool
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-AX7T3J7G.js";
|
|
23
23
|
import {
|
|
24
24
|
CONFIG_DIR_NAME,
|
|
25
25
|
DEFAULT_MAX_TOOL_OUTPUT_CHARS_CAP,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
SUBAGENT_ALLOWED_TOOLS,
|
|
28
28
|
SUBAGENT_DEFAULT_MAX_ROUNDS,
|
|
29
29
|
SUBAGENT_MAX_ROUNDS_LIMIT
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
31
31
|
|
|
32
32
|
// src/tools/types.ts
|
|
33
33
|
function isFileWriteTool(name) {
|
|
@@ -432,7 +432,7 @@ function updateCwdFromCommand(command, baseCwd) {
|
|
|
432
432
|
|
|
433
433
|
// src/tools/builtin/read-file.ts
|
|
434
434
|
import { readFileSync as readFileSync2, existsSync as existsSync3, statSync as statSync2, readdirSync as readdirSync2 } from "fs";
|
|
435
|
-
import {
|
|
435
|
+
import { execFileSync } from "child_process";
|
|
436
436
|
import { extname, resolve as resolve2, basename, sep, dirname } from "path";
|
|
437
437
|
import { homedir } from "os";
|
|
438
438
|
|
|
@@ -633,7 +633,7 @@ function findSimilarFiles(filePath) {
|
|
|
633
633
|
}
|
|
634
634
|
function tryExtractPdfText(absPath) {
|
|
635
635
|
try {
|
|
636
|
-
const output =
|
|
636
|
+
const output = execFileSync("pdftotext", [absPath, "-"], {
|
|
637
637
|
timeout: 15e3,
|
|
638
638
|
encoding: "utf-8",
|
|
639
639
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -642,8 +642,8 @@ function tryExtractPdfText(absPath) {
|
|
|
642
642
|
} catch {
|
|
643
643
|
}
|
|
644
644
|
try {
|
|
645
|
-
const pyScript =
|
|
646
|
-
const output =
|
|
645
|
+
const pyScript = 'import sys; exec("try:\\n from pdfminer.high_level import extract_text\\n print(extract_text(sys.argv[1]))\\nexcept: pass")';
|
|
646
|
+
const output = execFileSync("python", ["-c", pyScript, absPath], {
|
|
647
647
|
timeout: 15e3,
|
|
648
648
|
encoding: "utf-8",
|
|
649
649
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1008,7 +1008,7 @@ function simpleDiff(oldLines, newLines) {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
1010
|
// src/tools/hooks.ts
|
|
1011
|
-
import { execSync as
|
|
1011
|
+
import { execSync as execSync2 } from "child_process";
|
|
1012
1012
|
function shellEscape(value) {
|
|
1013
1013
|
return "'" + value.replace(/'/g, "'\\''") + "'";
|
|
1014
1014
|
}
|
|
@@ -1020,7 +1020,7 @@ function runHook(template, vars) {
|
|
|
1020
1020
|
cmd = cmd.replace(/\{args\}/g, shellEscape(vars.args ?? ""));
|
|
1021
1021
|
cmd = cmd.replace(/\{status\}/g, shellEscape(vars.status ?? ""));
|
|
1022
1022
|
try {
|
|
1023
|
-
|
|
1023
|
+
execSync2(cmd, {
|
|
1024
1024
|
timeout: 5e3,
|
|
1025
1025
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1026
1026
|
encoding: "utf-8"
|
|
@@ -3922,7 +3922,7 @@ var taskStopTool = {
|
|
|
3922
3922
|
};
|
|
3923
3923
|
|
|
3924
3924
|
// src/tools/builtin/git-tools.ts
|
|
3925
|
-
import {
|
|
3925
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
3926
3926
|
import { existsSync as existsSync10 } from "fs";
|
|
3927
3927
|
import { join as join5 } from "path";
|
|
3928
3928
|
function assertGitRepo(cwd) {
|
|
@@ -3938,7 +3938,7 @@ function assertGitRepo(cwd) {
|
|
|
3938
3938
|
}
|
|
3939
3939
|
function runGit(args, cwd, maxBuffer = 10 * 1024 * 1024) {
|
|
3940
3940
|
try {
|
|
3941
|
-
const output =
|
|
3941
|
+
const output = execFileSync2("git", args, {
|
|
3942
3942
|
cwd,
|
|
3943
3943
|
encoding: "utf-8",
|
|
3944
3944
|
maxBuffer,
|
package/dist/electron-server.js
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
VERSION,
|
|
37
37
|
buildUserIdentityPrompt,
|
|
38
38
|
runTestsTool
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-4GMAVGPX.js";
|
|
40
40
|
import {
|
|
41
41
|
hasSemanticIndex,
|
|
42
42
|
semanticSearch
|
|
@@ -3581,7 +3581,7 @@ function updateCwdFromCommand(command, baseCwd) {
|
|
|
3581
3581
|
|
|
3582
3582
|
// src/tools/builtin/read-file.ts
|
|
3583
3583
|
import { readFileSync as readFileSync4, existsSync as existsSync5, statSync as statSync2, readdirSync as readdirSync3 } from "fs";
|
|
3584
|
-
import {
|
|
3584
|
+
import { execFileSync } from "child_process";
|
|
3585
3585
|
import { extname, resolve as resolve2, basename, sep, dirname } from "path";
|
|
3586
3586
|
import { homedir as homedir2 } from "os";
|
|
3587
3587
|
|
|
@@ -3782,7 +3782,7 @@ function findSimilarFiles(filePath) {
|
|
|
3782
3782
|
}
|
|
3783
3783
|
function tryExtractPdfText(absPath) {
|
|
3784
3784
|
try {
|
|
3785
|
-
const output =
|
|
3785
|
+
const output = execFileSync("pdftotext", [absPath, "-"], {
|
|
3786
3786
|
timeout: 15e3,
|
|
3787
3787
|
encoding: "utf-8",
|
|
3788
3788
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -3791,8 +3791,8 @@ function tryExtractPdfText(absPath) {
|
|
|
3791
3791
|
} catch {
|
|
3792
3792
|
}
|
|
3793
3793
|
try {
|
|
3794
|
-
const pyScript =
|
|
3795
|
-
const output =
|
|
3794
|
+
const pyScript = 'import sys; exec("try:\\n from pdfminer.high_level import extract_text\\n print(extract_text(sys.argv[1]))\\nexcept: pass")';
|
|
3795
|
+
const output = execFileSync("python", ["-c", pyScript, absPath], {
|
|
3796
3796
|
timeout: 15e3,
|
|
3797
3797
|
encoding: "utf-8",
|
|
3798
3798
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -4157,7 +4157,7 @@ function simpleDiff(oldLines, newLines) {
|
|
|
4157
4157
|
}
|
|
4158
4158
|
|
|
4159
4159
|
// src/tools/hooks.ts
|
|
4160
|
-
import { execSync as
|
|
4160
|
+
import { execSync as execSync2 } from "child_process";
|
|
4161
4161
|
function shellEscape(value) {
|
|
4162
4162
|
return "'" + value.replace(/'/g, "'\\''") + "'";
|
|
4163
4163
|
}
|
|
@@ -4169,7 +4169,7 @@ function runHook(template, vars) {
|
|
|
4169
4169
|
cmd = cmd.replace(/\{args\}/g, shellEscape(vars.args ?? ""));
|
|
4170
4170
|
cmd = cmd.replace(/\{status\}/g, shellEscape(vars.status ?? ""));
|
|
4171
4171
|
try {
|
|
4172
|
-
|
|
4172
|
+
execSync2(cmd, {
|
|
4173
4173
|
timeout: 5e3,
|
|
4174
4174
|
stdio: ["pipe", "pipe", "pipe"],
|
|
4175
4175
|
encoding: "utf-8"
|
|
@@ -7032,7 +7032,7 @@ var taskStopTool = {
|
|
|
7032
7032
|
};
|
|
7033
7033
|
|
|
7034
7034
|
// src/tools/builtin/git-tools.ts
|
|
7035
|
-
import {
|
|
7035
|
+
import { execFileSync as execFileSync2 } from "child_process";
|
|
7036
7036
|
import { existsSync as existsSync12 } from "fs";
|
|
7037
7037
|
import { join as join7 } from "path";
|
|
7038
7038
|
function assertGitRepo(cwd) {
|
|
@@ -7048,7 +7048,7 @@ function assertGitRepo(cwd) {
|
|
|
7048
7048
|
}
|
|
7049
7049
|
function runGit(args, cwd, maxBuffer = 10 * 1024 * 1024) {
|
|
7050
7050
|
try {
|
|
7051
|
-
const output =
|
|
7051
|
+
const output = execFileSync2("git", args, {
|
|
7052
7052
|
cwd,
|
|
7053
7053
|
encoding: "utf-8",
|
|
7054
7054
|
maxBuffer,
|
|
@@ -9221,15 +9221,15 @@ function autoTrimSessionIfNeeded(session, sizeLimit = SESSION_SIZE_LIMIT) {
|
|
|
9221
9221
|
// src/web/session-handler.ts
|
|
9222
9222
|
import { existsSync as existsSync20, readFileSync as readFileSync13, appendFileSync as appendFileSync3, writeFileSync as writeFileSync8, mkdirSync as mkdirSync9, readdirSync as readdirSync9, statSync as statSync8 } from "fs";
|
|
9223
9223
|
import { join as join13, resolve as resolve4 } from "path";
|
|
9224
|
-
import { execSync as
|
|
9224
|
+
import { execSync as execSync4 } from "child_process";
|
|
9225
9225
|
|
|
9226
9226
|
// src/tools/git-context.ts
|
|
9227
|
-
import { execSync as
|
|
9227
|
+
import { execSync as execSync3 } from "child_process";
|
|
9228
9228
|
import { existsSync as existsSync19 } from "fs";
|
|
9229
9229
|
import { join as join12 } from "path";
|
|
9230
9230
|
function runGit2(cmd, cwd) {
|
|
9231
9231
|
try {
|
|
9232
|
-
return
|
|
9232
|
+
return execSync3(`git ${cmd}`, {
|
|
9233
9233
|
cwd,
|
|
9234
9234
|
encoding: "utf-8",
|
|
9235
9235
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -10953,7 +10953,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
10953
10953
|
let diff;
|
|
10954
10954
|
try {
|
|
10955
10955
|
const cmd = staged ? "git diff --staged" : "git diff";
|
|
10956
|
-
diff =
|
|
10956
|
+
diff = execSync4(cmd, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
10957
10957
|
} catch {
|
|
10958
10958
|
this.send({ type: "error", message: "Failed to run git diff." });
|
|
10959
10959
|
break;
|
|
@@ -10992,7 +10992,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
10992
10992
|
let secDiff;
|
|
10993
10993
|
try {
|
|
10994
10994
|
const cmd = secStaged ? "git diff --staged" : "git diff";
|
|
10995
|
-
secDiff =
|
|
10995
|
+
secDiff = execSync4(cmd, { encoding: "utf-8", timeout: 1e4 }).trim();
|
|
10996
10996
|
} catch {
|
|
10997
10997
|
this.send({ type: "error", message: "Failed to run git diff." });
|
|
10998
10998
|
break;
|
|
@@ -11070,7 +11070,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
11070
11070
|
case "test": {
|
|
11071
11071
|
this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
|
|
11072
11072
|
try {
|
|
11073
|
-
const { executeTests } = await import("./run-tests-
|
|
11073
|
+
const { executeTests } = await import("./run-tests-PIISCS6B.js");
|
|
11074
11074
|
const argStr = args.join(" ").trim();
|
|
11075
11075
|
let testArgs = {};
|
|
11076
11076
|
if (argStr) {
|
|
@@ -385,7 +385,7 @@ ${content}`);
|
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
async function runTaskMode(config, providers, configManager, topic) {
|
|
388
|
-
const { TaskOrchestrator } = await import("./task-orchestrator-
|
|
388
|
+
const { TaskOrchestrator } = await import("./task-orchestrator-H73NIC6T.js");
|
|
389
389
|
const orchestrator = new TaskOrchestrator(config, providers, configManager);
|
|
390
390
|
let interrupted = false;
|
|
391
391
|
const onSigint = () => {
|
package/dist/index.js
CHANGED
|
@@ -30,10 +30,10 @@ import {
|
|
|
30
30
|
saveDevState,
|
|
31
31
|
sessionHasMeaningfulContent,
|
|
32
32
|
setupProxy
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-6IOQPMMT.js";
|
|
34
34
|
import {
|
|
35
35
|
ConfigManager
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-APU36NHI.js";
|
|
37
37
|
import {
|
|
38
38
|
ToolExecutor,
|
|
39
39
|
ToolRegistry,
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
spawnAgentContext,
|
|
50
50
|
theme,
|
|
51
51
|
undoStack
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-YBL4QDLD.js";
|
|
53
53
|
import "./chunk-2ZD3YTVM.js";
|
|
54
54
|
import {
|
|
55
55
|
fileCheckpoints
|
|
@@ -58,7 +58,7 @@ import "./chunk-NHNWUBXB.js";
|
|
|
58
58
|
import "./chunk-CQQQFNND.js";
|
|
59
59
|
import "./chunk-6VRJGH25.js";
|
|
60
60
|
import "./chunk-PFYAAX2S.js";
|
|
61
|
-
import "./chunk-
|
|
61
|
+
import "./chunk-AX7T3J7G.js";
|
|
62
62
|
import {
|
|
63
63
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
64
64
|
AUTHOR,
|
|
@@ -80,7 +80,7 @@ import {
|
|
|
80
80
|
SKILLS_DIR_NAME,
|
|
81
81
|
VERSION,
|
|
82
82
|
buildUserIdentityPrompt
|
|
83
|
-
} from "./chunk-
|
|
83
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
84
84
|
|
|
85
85
|
// src/index.ts
|
|
86
86
|
import { program } from "commander";
|
|
@@ -2592,7 +2592,7 @@ ${hint}` : "")
|
|
|
2592
2592
|
usage: "/test [command|filter]",
|
|
2593
2593
|
async execute(args, ctx) {
|
|
2594
2594
|
try {
|
|
2595
|
-
const { executeTests } = await import("./run-tests-
|
|
2595
|
+
const { executeTests } = await import("./run-tests-KWVQL2PO.js");
|
|
2596
2596
|
const argStr = args.join(" ").trim();
|
|
2597
2597
|
let testArgs = {};
|
|
2598
2598
|
if (argStr) {
|
|
@@ -6485,7 +6485,7 @@ program.command("web").description("Start Web UI server with browser-based chat
|
|
|
6485
6485
|
console.error("Error: Invalid port number. Must be between 1 and 65535.");
|
|
6486
6486
|
process.exit(1);
|
|
6487
6487
|
}
|
|
6488
|
-
const { startWebServer } = await import("./server-
|
|
6488
|
+
const { startWebServer } = await import("./server-WNL7UU5Q.js");
|
|
6489
6489
|
await startWebServer({ port, host: options.host });
|
|
6490
6490
|
});
|
|
6491
6491
|
program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
|
|
@@ -6608,7 +6608,7 @@ program.command("sessions").description("List recent conversation sessions").act
|
|
|
6608
6608
|
});
|
|
6609
6609
|
program.command("batch <action> [arg] [arg2]").description("Anthropic Message Batches: submit | list | status <id> | results <id> [out] | cancel <id>").option("--dry-run", "Parse and validate input without submitting (submit only)").action(async (action, arg, arg2, options) => {
|
|
6610
6610
|
try {
|
|
6611
|
-
const batch = await import("./batch-
|
|
6611
|
+
const batch = await import("./batch-YBWWF5BJ.js");
|
|
6612
6612
|
switch (action) {
|
|
6613
6613
|
case "submit":
|
|
6614
6614
|
if (!arg) {
|
|
@@ -6650,10 +6650,11 @@ program.command("batch <action> [arg] [arg2]").description("Anthropic Message Ba
|
|
|
6650
6650
|
process.exit(1);
|
|
6651
6651
|
}
|
|
6652
6652
|
});
|
|
6653
|
-
program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow
|
|
6654
|
-
const { startMcpServer } = await import("./server-
|
|
6653
|
+
program.command("mcp-serve").description("Start an MCP server over STDIO, exposing aicli's built-in tools to Claude Desktop / Cursor / other MCP clients").option("--allow-destructive", "Allow bash / run_interactive / task_create (always destructive in MCP mode)").option("--allow-outside-cwd", "Allow tool path arguments to escape the sandbox root \u2014 disabled by default").option("--tools <list>", "Comma-separated whitelist of tools to expose (default: all eligible tools)").option("--cwd <path>", "Working directory AND sandbox root (default: current directory)").action(async (options) => {
|
|
6654
|
+
const { startMcpServer } = await import("./server-GAKP7VZ7.js");
|
|
6655
6655
|
await startMcpServer({
|
|
6656
6656
|
allowDestructive: !!options.allowDestructive,
|
|
6657
|
+
allowOutsideCwd: !!options.allowOutsideCwd,
|
|
6657
6658
|
tools: options.tools ? options.tools.split(",").map((s) => s.trim()).filter(Boolean) : void 0,
|
|
6658
6659
|
cwd: options.cwd
|
|
6659
6660
|
});
|
|
@@ -6777,7 +6778,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
|
|
|
6777
6778
|
}),
|
|
6778
6779
|
config.get("customProviders")
|
|
6779
6780
|
);
|
|
6780
|
-
const { startHub } = await import("./hub-
|
|
6781
|
+
const { startHub } = await import("./hub-RCX7G5T6.js");
|
|
6781
6782
|
await startHub(
|
|
6782
6783
|
{
|
|
6783
6784
|
topic: topic ?? "",
|
|
@@ -3,28 +3,78 @@ import {
|
|
|
3
3
|
ToolRegistry,
|
|
4
4
|
getDangerLevel,
|
|
5
5
|
schemaToJsonSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YBL4QDLD.js";
|
|
7
7
|
import "./chunk-2ZD3YTVM.js";
|
|
8
8
|
import "./chunk-4BKXL7SM.js";
|
|
9
9
|
import "./chunk-NHNWUBXB.js";
|
|
10
10
|
import "./chunk-CQQQFNND.js";
|
|
11
11
|
import "./chunk-6VRJGH25.js";
|
|
12
12
|
import "./chunk-PFYAAX2S.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-AX7T3J7G.js";
|
|
14
14
|
import {
|
|
15
15
|
VERSION
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
17
17
|
|
|
18
18
|
// src/mcp/server.ts
|
|
19
19
|
import { createInterface } from "readline";
|
|
20
|
+
import { resolve } from "path";
|
|
21
|
+
import { realpathSync } from "fs";
|
|
20
22
|
var STDIN_TOOLS = /* @__PURE__ */ new Set(["ask_user", "spawn_agent"]);
|
|
23
|
+
var MCP_ALWAYS_DESTRUCTIVE = /* @__PURE__ */ new Set([
|
|
24
|
+
"bash",
|
|
25
|
+
"run_interactive",
|
|
26
|
+
"task_create"
|
|
27
|
+
]);
|
|
28
|
+
var TOOL_PATH_ARGS = {
|
|
29
|
+
read_file: ["path"],
|
|
30
|
+
write_file: ["path"],
|
|
31
|
+
edit_file: ["path"],
|
|
32
|
+
list_dir: ["path"],
|
|
33
|
+
grep_files: ["path"],
|
|
34
|
+
glob_files: ["path"],
|
|
35
|
+
notebook_edit: ["path"],
|
|
36
|
+
save_last_response: ["path"],
|
|
37
|
+
git_status: ["path"],
|
|
38
|
+
git_diff: ["path", "file"],
|
|
39
|
+
git_log: ["path", "file"],
|
|
40
|
+
git_commit: ["path", "files"],
|
|
41
|
+
find_symbol: ["path"],
|
|
42
|
+
get_outline: ["file", "path"],
|
|
43
|
+
find_references: ["path"],
|
|
44
|
+
search_code: ["path"],
|
|
45
|
+
bash: ["cwd"],
|
|
46
|
+
run_interactive: ["cwd"]
|
|
47
|
+
};
|
|
21
48
|
var McpServer = class {
|
|
22
49
|
registry;
|
|
23
50
|
opts;
|
|
24
51
|
initialized = false;
|
|
52
|
+
sandboxRoot;
|
|
53
|
+
eligibleNames;
|
|
25
54
|
constructor(registry, opts = {}) {
|
|
26
55
|
this.registry = registry;
|
|
27
56
|
this.opts = opts;
|
|
57
|
+
this.sandboxRoot = this.resolveSandboxRoot(opts.cwd);
|
|
58
|
+
this.eligibleNames = this.computeEligibleNames();
|
|
59
|
+
}
|
|
60
|
+
resolveSandboxRoot(cwd) {
|
|
61
|
+
const base = cwd ? resolve(cwd) : process.cwd();
|
|
62
|
+
try {
|
|
63
|
+
return realpathSync(base);
|
|
64
|
+
} catch {
|
|
65
|
+
return base;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
computeEligibleNames() {
|
|
69
|
+
const names = /* @__PURE__ */ new Set();
|
|
70
|
+
const whitelist = this.opts.tools && this.opts.tools.length > 0 ? new Set(this.opts.tools) : null;
|
|
71
|
+
for (const tool of this.registry.listAll()) {
|
|
72
|
+
const name = tool.definition.name;
|
|
73
|
+
if (STDIN_TOOLS.has(name)) continue;
|
|
74
|
+
if (whitelist && !whitelist.has(name)) continue;
|
|
75
|
+
names.add(name);
|
|
76
|
+
}
|
|
77
|
+
return names;
|
|
28
78
|
}
|
|
29
79
|
async start() {
|
|
30
80
|
if (this.opts.cwd) {
|
|
@@ -48,7 +98,9 @@ var McpServer = class {
|
|
|
48
98
|
});
|
|
49
99
|
rl.on("close", () => process.exit(0));
|
|
50
100
|
process.stdin.resume();
|
|
51
|
-
this.log(`aicli MCP server v${VERSION} started.
|
|
101
|
+
this.log(`aicli MCP server v${VERSION} started. sandboxRoot=${this.sandboxRoot}`);
|
|
102
|
+
if (this.opts.allowDestructive) this.log("WARNING: --allow-destructive enabled");
|
|
103
|
+
if (this.opts.allowOutsideCwd) this.log("WARNING: --allow-outside-cwd enabled");
|
|
52
104
|
}
|
|
53
105
|
// ── dispatcher ─────────────────────────────────────────────────────────────
|
|
54
106
|
async dispatch(msg) {
|
|
@@ -69,9 +121,17 @@ var McpServer = class {
|
|
|
69
121
|
this.handleInitialize(id, params);
|
|
70
122
|
break;
|
|
71
123
|
case "tools/list":
|
|
124
|
+
if (!this.initialized) {
|
|
125
|
+
this.sendError(id, -32002, "Server not initialized");
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
72
128
|
this.handleToolsList(id);
|
|
73
129
|
break;
|
|
74
130
|
case "tools/call":
|
|
131
|
+
if (!this.initialized) {
|
|
132
|
+
this.sendError(id, -32002, "Server not initialized");
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
75
135
|
await this.handleToolCall(id, params);
|
|
76
136
|
break;
|
|
77
137
|
case "ping":
|
|
@@ -81,12 +141,13 @@ var McpServer = class {
|
|
|
81
141
|
this.sendError(id, -32601, `Method not found: ${method}`);
|
|
82
142
|
}
|
|
83
143
|
} catch (err) {
|
|
84
|
-
const
|
|
85
|
-
this.sendError(id, -32603, `Internal error: ${
|
|
144
|
+
const emsg = err instanceof Error ? err.message : String(err);
|
|
145
|
+
this.sendError(id, -32603, `Internal error: ${emsg}`);
|
|
86
146
|
}
|
|
87
147
|
}
|
|
88
148
|
// ── handlers ───────────────────────────────────────────────────────────────
|
|
89
149
|
handleInitialize(id, _params) {
|
|
150
|
+
this.initialized = true;
|
|
90
151
|
this.sendResult(id, {
|
|
91
152
|
protocolVersion: "2024-11-05",
|
|
92
153
|
capabilities: { tools: {} },
|
|
@@ -94,7 +155,7 @@ var McpServer = class {
|
|
|
94
155
|
});
|
|
95
156
|
}
|
|
96
157
|
handleToolsList(id) {
|
|
97
|
-
const tools = this.
|
|
158
|
+
const tools = [...this.eligibleNames].map((n) => this.registry.get(n)).filter((t) => !!t);
|
|
98
159
|
const list = tools.map((tool) => {
|
|
99
160
|
const params = tool.definition.parameters;
|
|
100
161
|
const properties = {};
|
|
@@ -122,15 +183,28 @@ var McpServer = class {
|
|
|
122
183
|
this.sendError(id, -32602, "Missing required param: name");
|
|
123
184
|
return;
|
|
124
185
|
}
|
|
186
|
+
if (!this.eligibleNames.has(name)) {
|
|
187
|
+
this.sendError(id, -32602, `Tool not exposed: ${name}`);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
125
190
|
const tool = this.registry.get(name);
|
|
126
191
|
if (!tool) {
|
|
127
192
|
this.sendError(id, -32602, `Unknown tool: ${name}`);
|
|
128
193
|
return;
|
|
129
194
|
}
|
|
130
|
-
const
|
|
195
|
+
const forcedDestructive = MCP_ALWAYS_DESTRUCTIVE.has(name);
|
|
196
|
+
const level = forcedDestructive ? "destructive" : getDangerLevel(name, args);
|
|
131
197
|
if (level === "destructive" && !this.opts.allowDestructive) {
|
|
132
198
|
this.sendResult(id, {
|
|
133
|
-
content: [{ type: "text", text: `Tool '${name}'
|
|
199
|
+
content: [{ type: "text", text: `Tool '${name}' requires --allow-destructive in MCP mode.` }],
|
|
200
|
+
isError: true
|
|
201
|
+
});
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const pathErr = this.validatePathArgs(name, args);
|
|
205
|
+
if (pathErr) {
|
|
206
|
+
this.sendResult(id, {
|
|
207
|
+
content: [{ type: "text", text: pathErr }],
|
|
134
208
|
isError: true
|
|
135
209
|
});
|
|
136
210
|
return;
|
|
@@ -148,17 +222,39 @@ var McpServer = class {
|
|
|
148
222
|
});
|
|
149
223
|
}
|
|
150
224
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Validate that every known path-bearing argument of `toolName` resolves
|
|
227
|
+
* inside the sandbox root. Returns an error message on violation, else undef.
|
|
228
|
+
*
|
|
229
|
+
* We do NOT realpath() per-call: write_file targets may not exist yet, and
|
|
230
|
+
* realpath on every call is a syscall per arg. The root itself is realpath'd
|
|
231
|
+
* once at construction, which stops the "sandbox root is a symlink pointing
|
|
232
|
+
* elsewhere" class of attack. Symlinks inside the tree are allowed.
|
|
233
|
+
*/
|
|
234
|
+
validatePathArgs(toolName, args) {
|
|
235
|
+
if (this.opts.allowOutsideCwd) return void 0;
|
|
236
|
+
const keys = TOOL_PATH_ARGS[toolName];
|
|
237
|
+
if (!keys) return void 0;
|
|
238
|
+
for (const key of keys) {
|
|
239
|
+
const value = args[key];
|
|
240
|
+
if (value === void 0 || value === null) continue;
|
|
241
|
+
const list = Array.isArray(value) ? value : [value];
|
|
242
|
+
for (const entry of list) {
|
|
243
|
+
if (typeof entry !== "string" || entry.length === 0) continue;
|
|
244
|
+
const abs = resolve(this.sandboxRoot, entry);
|
|
245
|
+
if (!this.isInsideSandbox(abs)) {
|
|
246
|
+
return `Path '${entry}' escapes sandbox root '${this.sandboxRoot}'. Pass --allow-outside-cwd to permit.`;
|
|
247
|
+
}
|
|
159
248
|
}
|
|
160
|
-
|
|
161
|
-
|
|
249
|
+
}
|
|
250
|
+
return void 0;
|
|
251
|
+
}
|
|
252
|
+
isInsideSandbox(abs) {
|
|
253
|
+
const norm = process.platform === "win32" ? abs.toLowerCase() : abs;
|
|
254
|
+
const root = process.platform === "win32" ? this.sandboxRoot.toLowerCase() : this.sandboxRoot;
|
|
255
|
+
if (norm === root) return true;
|
|
256
|
+
const sep = process.platform === "win32" ? "\\" : "/";
|
|
257
|
+
return norm.startsWith(root + sep);
|
|
162
258
|
}
|
|
163
259
|
// ── transport ──────────────────────────────────────────────────────────────
|
|
164
260
|
sendResult(id, result) {
|
|
@@ -20,10 +20,10 @@ import {
|
|
|
20
20
|
persistToolRound,
|
|
21
21
|
rebuildExtraMessages,
|
|
22
22
|
setupProxy
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-6IOQPMMT.js";
|
|
24
24
|
import {
|
|
25
25
|
ConfigManager
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-APU36NHI.js";
|
|
27
27
|
import {
|
|
28
28
|
ToolExecutor,
|
|
29
29
|
ToolRegistry,
|
|
@@ -41,14 +41,14 @@ import {
|
|
|
41
41
|
spawnAgentContext,
|
|
42
42
|
truncateOutput,
|
|
43
43
|
undoStack
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-YBL4QDLD.js";
|
|
45
45
|
import "./chunk-2ZD3YTVM.js";
|
|
46
46
|
import "./chunk-4BKXL7SM.js";
|
|
47
47
|
import "./chunk-NHNWUBXB.js";
|
|
48
48
|
import "./chunk-CQQQFNND.js";
|
|
49
49
|
import "./chunk-6VRJGH25.js";
|
|
50
50
|
import "./chunk-PFYAAX2S.js";
|
|
51
|
-
import "./chunk-
|
|
51
|
+
import "./chunk-AX7T3J7G.js";
|
|
52
52
|
import {
|
|
53
53
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
54
54
|
AUTHOR,
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
SKILLS_DIR_NAME,
|
|
68
68
|
VERSION,
|
|
69
69
|
buildUserIdentityPrompt
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
71
71
|
import {
|
|
72
72
|
AuthManager
|
|
73
73
|
} from "./chunk-BYNY5JPB.js";
|
|
@@ -2229,7 +2229,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
2229
2229
|
case "test": {
|
|
2230
2230
|
this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
|
|
2231
2231
|
try {
|
|
2232
|
-
const { executeTests } = await import("./run-tests-
|
|
2232
|
+
const { executeTests } = await import("./run-tests-KWVQL2PO.js");
|
|
2233
2233
|
const argStr = args.join(" ").trim();
|
|
2234
2234
|
let testArgs = {};
|
|
2235
2235
|
if (argStr) {
|
|
@@ -4,17 +4,17 @@ import {
|
|
|
4
4
|
getDangerLevel,
|
|
5
5
|
googleSearchContext,
|
|
6
6
|
truncateOutput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YBL4QDLD.js";
|
|
8
8
|
import "./chunk-2ZD3YTVM.js";
|
|
9
9
|
import "./chunk-4BKXL7SM.js";
|
|
10
10
|
import "./chunk-NHNWUBXB.js";
|
|
11
11
|
import "./chunk-CQQQFNND.js";
|
|
12
12
|
import "./chunk-6VRJGH25.js";
|
|
13
13
|
import "./chunk-PFYAAX2S.js";
|
|
14
|
-
import "./chunk-
|
|
14
|
+
import "./chunk-AX7T3J7G.js";
|
|
15
15
|
import {
|
|
16
16
|
SUBAGENT_ALLOWED_TOOLS
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-XEXVG3CQ.js";
|
|
18
18
|
|
|
19
19
|
// src/hub/task-orchestrator.ts
|
|
20
20
|
import { createInterface } from "readline";
|