jinzd-ai-cli 0.4.64 → 0.4.66
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/{chunk-JSAPO5GI.js → chunk-HOBLE365.js} +41 -12
- package/dist/{chunk-S6P5MYUF.js → chunk-NIJZBQ6I.js} +1 -1
- package/dist/{chunk-NJEMUAJD.js → chunk-UIFW7G4A.js} +1 -1
- package/dist/{chunk-YF3Z47AT.js → chunk-X5RX2VGQ.js} +12 -5
- package/dist/{hub-KEBKTLLR.js → hub-JA7HH44N.js} +1 -1
- package/dist/index.js +29 -12
- package/dist/{run-tests-WNHU6QH3.js → run-tests-47TTKJTB.js} +1 -1
- package/dist/{run-tests-ZABNMYY2.js → run-tests-E55HLJDD.js} +1 -1
- package/dist/{server-R7OJYTSP.js → server-A3SB52SS.js} +21 -9
- package/dist/{task-orchestrator-ZTMZIHNF.js → task-orchestrator-KOCFBDPK.js} +2 -2
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
RateLimitError,
|
|
9
9
|
schemaToJsonSchema,
|
|
10
10
|
truncateForPersist
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-X5RX2VGQ.js";
|
|
12
12
|
import {
|
|
13
13
|
APP_NAME,
|
|
14
14
|
CONFIG_DIR_NAME,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
MCP_TOOL_PREFIX,
|
|
22
22
|
PLUGINS_DIR_NAME,
|
|
23
23
|
VERSION
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-NIJZBQ6I.js";
|
|
25
25
|
|
|
26
26
|
// src/config/config-manager.ts
|
|
27
27
|
import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
|
|
@@ -3752,16 +3752,29 @@ function rebuildExtraMessages(provider, toolHistory) {
|
|
|
3752
3752
|
let j = i + 1;
|
|
3753
3753
|
while (j < toolHistory.length && toolHistory[j].role === "tool") {
|
|
3754
3754
|
const tm = toolHistory[j];
|
|
3755
|
+
if (!tm.toolCallId) {
|
|
3756
|
+
console.warn(
|
|
3757
|
+
`[rebuildExtraMessages] Skipping malformed tool message (missing toolCallId) at index ${j}; tool name="${toolCalls.find((_tc) => true)?.name ?? "unknown"}"`
|
|
3758
|
+
);
|
|
3759
|
+
j++;
|
|
3760
|
+
continue;
|
|
3761
|
+
}
|
|
3755
3762
|
toolResults.push({
|
|
3756
|
-
callId: tm.toolCallId
|
|
3763
|
+
callId: tm.toolCallId,
|
|
3757
3764
|
content: typeof tm.content === "string" ? tm.content : getContentText(tm.content),
|
|
3758
3765
|
isError: tm.isError ?? false
|
|
3759
3766
|
});
|
|
3760
3767
|
j++;
|
|
3761
3768
|
}
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3769
|
+
if (toolResults.length > 0) {
|
|
3770
|
+
result.push(
|
|
3771
|
+
...provider.buildToolResultMessages(toolCalls, toolResults, msg.reasoningContent)
|
|
3772
|
+
);
|
|
3773
|
+
} else {
|
|
3774
|
+
console.warn(
|
|
3775
|
+
`[rebuildExtraMessages] Dropping assistant turn with ${toolCalls.length} toolCalls but no valid tool results`
|
|
3776
|
+
);
|
|
3777
|
+
}
|
|
3765
3778
|
i = j;
|
|
3766
3779
|
} else {
|
|
3767
3780
|
result.push({
|
|
@@ -3806,18 +3819,34 @@ function trimOldToolOutput(messages, keepRecentRounds = 10) {
|
|
|
3806
3819
|
}
|
|
3807
3820
|
return trimmed;
|
|
3808
3821
|
}
|
|
3822
|
+
function cloneMessages(messages) {
|
|
3823
|
+
return messages.map((m) => ({ ...m }));
|
|
3824
|
+
}
|
|
3809
3825
|
function autoTrimSessionIfNeeded(session, sizeLimit = SESSION_SIZE_LIMIT) {
|
|
3810
|
-
const
|
|
3811
|
-
if (
|
|
3826
|
+
const originalSize = JSON.stringify(session.toJSON()).length;
|
|
3827
|
+
if (originalSize <= sizeLimit) return false;
|
|
3828
|
+
const snapshotLen = session.messages.length;
|
|
3829
|
+
let working = cloneMessages(session.messages.slice(0, snapshotLen));
|
|
3830
|
+
let committedSize = originalSize;
|
|
3831
|
+
let anyTrim = false;
|
|
3812
3832
|
let keepRecent = 10;
|
|
3813
3833
|
while (keepRecent >= 2) {
|
|
3814
|
-
const
|
|
3815
|
-
if (
|
|
3834
|
+
const trimmedCount = trimOldToolOutput(working, keepRecent);
|
|
3835
|
+
if (trimmedCount === 0) break;
|
|
3836
|
+
anyTrim = true;
|
|
3837
|
+
const originalMessages = session.messages;
|
|
3838
|
+
session.messages = [...working, ...originalMessages.slice(snapshotLen)];
|
|
3816
3839
|
const newSize = JSON.stringify(session.toJSON()).length;
|
|
3817
|
-
|
|
3840
|
+
session.messages = originalMessages;
|
|
3841
|
+
committedSize = newSize;
|
|
3842
|
+
if (newSize <= sizeLimit) break;
|
|
3818
3843
|
keepRecent = Math.max(2, Math.floor(keepRecent / 2));
|
|
3844
|
+
if (keepRecent < 2) break;
|
|
3819
3845
|
}
|
|
3820
|
-
return
|
|
3846
|
+
if (!anyTrim) return false;
|
|
3847
|
+
const appended = session.messages.slice(snapshotLen);
|
|
3848
|
+
session.messages.splice(0, session.messages.length, ...working, ...appended);
|
|
3849
|
+
return committedSize < originalSize;
|
|
3821
3850
|
}
|
|
3822
3851
|
|
|
3823
3852
|
// src/repl/dev-state.ts
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SUBAGENT_DEFAULT_MAX_ROUNDS,
|
|
11
11
|
SUBAGENT_MAX_ROUNDS_LIMIT,
|
|
12
12
|
runTestsTool
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NIJZBQ6I.js";
|
|
14
14
|
|
|
15
15
|
// src/tools/builtin/bash.ts
|
|
16
16
|
import { execSync } from "child_process";
|
|
@@ -1386,12 +1386,19 @@ var ToolExecutor = class {
|
|
|
1386
1386
|
}
|
|
1387
1387
|
const results = new Array(calls.length);
|
|
1388
1388
|
const t0 = Date.now();
|
|
1389
|
-
const
|
|
1390
|
-
|
|
1391
|
-
|
|
1389
|
+
const wrapExec = async (idx, call) => {
|
|
1390
|
+
try {
|
|
1391
|
+
results[idx] = await this.execute(call);
|
|
1392
|
+
} catch (err) {
|
|
1393
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
1394
|
+
console.error(`[executor] Unexpected error in tool "${call.name}":`, err);
|
|
1395
|
+
results[idx] = { callId: call.id, content: `Tool execution failed: ${msg}`, isError: true };
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
const parallelPhase = safeParallel.length > 0 ? Promise.all(safeParallel.map(({ idx, call }) => wrapExec(idx, call))) : Promise.resolve();
|
|
1392
1399
|
const bashPhase = (async () => {
|
|
1393
1400
|
for (const { idx, call } of safeBash) {
|
|
1394
|
-
|
|
1401
|
+
await wrapExec(idx, call);
|
|
1395
1402
|
}
|
|
1396
1403
|
})();
|
|
1397
1404
|
await Promise.all([parallelPhase, bashPhase]);
|
|
@@ -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-KOCFBDPK.js");
|
|
389
389
|
const orchestrator = new TaskOrchestrator(config, providers, configManager);
|
|
390
390
|
let interrupted = false;
|
|
391
391
|
const onSigint = () => {
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
saveDevState,
|
|
32
32
|
sessionHasMeaningfulContent,
|
|
33
33
|
setupProxy
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-HOBLE365.js";
|
|
35
35
|
import {
|
|
36
36
|
ToolExecutor,
|
|
37
37
|
ToolRegistry,
|
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
spawnAgentContext,
|
|
47
47
|
theme,
|
|
48
48
|
undoStack
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-X5RX2VGQ.js";
|
|
50
50
|
import {
|
|
51
51
|
fileCheckpoints
|
|
52
52
|
} from "./chunk-4BKXL7SM.js";
|
|
@@ -71,7 +71,7 @@ import {
|
|
|
71
71
|
SKILLS_DIR_NAME,
|
|
72
72
|
VERSION,
|
|
73
73
|
buildUserIdentityPrompt
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-NIJZBQ6I.js";
|
|
75
75
|
|
|
76
76
|
// src/index.ts
|
|
77
77
|
import { program } from "commander";
|
|
@@ -2193,7 +2193,7 @@ ${hint}` : "")
|
|
|
2193
2193
|
usage: "/test [command|filter]",
|
|
2194
2194
|
async execute(args, ctx) {
|
|
2195
2195
|
try {
|
|
2196
|
-
const { executeTests } = await import("./run-tests-
|
|
2196
|
+
const { executeTests } = await import("./run-tests-47TTKJTB.js");
|
|
2197
2197
|
const argStr = args.join(" ").trim();
|
|
2198
2198
|
let testArgs = {};
|
|
2199
2199
|
if (argStr) {
|
|
@@ -3280,14 +3280,31 @@ var CostTracker = class {
|
|
|
3280
3280
|
this.records = [];
|
|
3281
3281
|
}
|
|
3282
3282
|
}
|
|
3283
|
-
/**
|
|
3283
|
+
/**
|
|
3284
|
+
* Save to disk (atomic write).
|
|
3285
|
+
*
|
|
3286
|
+
* H2: Snapshot records before writing and only clear the dirty flag after
|
|
3287
|
+
* the write succeeds. If writeFileSync/renameSync throws, dirty remains
|
|
3288
|
+
* true so the next save() retries — prevents silent data loss on transient
|
|
3289
|
+
* disk errors. writeFileSync is sync in Node.js so there's no interleaving
|
|
3290
|
+
* risk within a single save() call; the snapshot mainly protects against
|
|
3291
|
+
* future refactors to async I/O.
|
|
3292
|
+
*/
|
|
3284
3293
|
save() {
|
|
3285
3294
|
if (!this.dirty) return;
|
|
3286
|
-
const
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3295
|
+
const snapshot = {
|
|
3296
|
+
version: 1,
|
|
3297
|
+
records: [...this.records]
|
|
3298
|
+
// shallow copy — records are plain data
|
|
3299
|
+
};
|
|
3300
|
+
try {
|
|
3301
|
+
const tmp = this.filePath + ".tmp";
|
|
3302
|
+
writeFileSync2(tmp, JSON.stringify(snapshot, null, 2), "utf-8");
|
|
3303
|
+
renameSync(tmp, this.filePath);
|
|
3304
|
+
this.dirty = false;
|
|
3305
|
+
} catch (err) {
|
|
3306
|
+
console.error("[cost-tracker] Failed to persist cost history:", err);
|
|
3307
|
+
}
|
|
3291
3308
|
}
|
|
3292
3309
|
/**
|
|
3293
3310
|
* Record cost from a completed session/interaction.
|
|
@@ -5905,7 +5922,7 @@ program.command("web").description("Start Web UI server with browser-based chat
|
|
|
5905
5922
|
console.error("Error: Invalid port number. Must be between 1 and 65535.");
|
|
5906
5923
|
process.exit(1);
|
|
5907
5924
|
}
|
|
5908
|
-
const { startWebServer } = await import("./server-
|
|
5925
|
+
const { startWebServer } = await import("./server-A3SB52SS.js");
|
|
5909
5926
|
await startWebServer({ port, host: options.host });
|
|
5910
5927
|
});
|
|
5911
5928
|
program.command("user [action] [username]").description("Manage Web UI users (list | create <name> | delete <name> | reset-password <name> | migrate <name>)").action(async (action, username) => {
|
|
@@ -6138,7 +6155,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
|
|
|
6138
6155
|
}),
|
|
6139
6156
|
config.get("customProviders")
|
|
6140
6157
|
);
|
|
6141
|
-
const { startHub } = await import("./hub-
|
|
6158
|
+
const { startHub } = await import("./hub-JA7HH44N.js");
|
|
6142
6159
|
await startHub(
|
|
6143
6160
|
{
|
|
6144
6161
|
topic: topic ?? "",
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
persistToolRound,
|
|
22
22
|
rebuildExtraMessages,
|
|
23
23
|
setupProxy
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-HOBLE365.js";
|
|
25
25
|
import {
|
|
26
26
|
AuthManager
|
|
27
27
|
} from "./chunk-BYNY5JPB.js";
|
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
spawnAgentContext,
|
|
42
42
|
truncateOutput,
|
|
43
43
|
undoStack
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-X5RX2VGQ.js";
|
|
45
45
|
import "./chunk-4BKXL7SM.js";
|
|
46
46
|
import {
|
|
47
47
|
AGENTIC_BEHAVIOR_GUIDELINE,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
SKILLS_DIR_NAME,
|
|
62
62
|
VERSION,
|
|
63
63
|
buildUserIdentityPrompt
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-NIJZBQ6I.js";
|
|
65
65
|
|
|
66
66
|
// src/web/server.ts
|
|
67
67
|
import express from "express";
|
|
@@ -345,12 +345,19 @@ var ToolExecutorWeb = class _ToolExecutorWeb {
|
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
const results = new Array(calls.length);
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
|
|
348
|
+
const wrapExec = async (idx, call) => {
|
|
349
|
+
try {
|
|
350
|
+
results[idx] = await this.execute(call);
|
|
351
|
+
} catch (err) {
|
|
352
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
353
|
+
console.error(`[tool-executor-web] Unexpected error in tool "${call.name}":`, err);
|
|
354
|
+
results[idx] = { callId: call.id, content: `Tool execution failed: ${msg}`, isError: true };
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
const parallelPhase = safeParallel.length > 0 ? Promise.all(safeParallel.map(({ idx, call }) => wrapExec(idx, call))) : Promise.resolve();
|
|
351
358
|
const bashPhase = (async () => {
|
|
352
359
|
for (const { idx, call } of safeBash) {
|
|
353
|
-
|
|
360
|
+
await wrapExec(idx, call);
|
|
354
361
|
}
|
|
355
362
|
})();
|
|
356
363
|
await Promise.all([parallelPhase, bashPhase]);
|
|
@@ -527,6 +534,8 @@ var SessionHandler = class _SessionHandler {
|
|
|
527
534
|
activeSystemPrompt;
|
|
528
535
|
/** Directories added via /add-dir */
|
|
529
536
|
addedDirs = /* @__PURE__ */ new Set();
|
|
537
|
+
/** Track MCP tool names used across this session (for MCP budget prioritization) */
|
|
538
|
+
usedMcpToolNames = /* @__PURE__ */ new Set();
|
|
530
539
|
/**
|
|
531
540
|
* 未保存会话的内存缓存(per-handler)。
|
|
532
541
|
* 当客户端通过 `session new` 创建新会话时,会话仅存在于 SessionManager._current 中,
|
|
@@ -1038,6 +1047,9 @@ Details: ${errMsg.split("\n")[0]}
|
|
|
1038
1047
|
round: round + 1,
|
|
1039
1048
|
tools: result.toolCalls.map((tc) => tc.name)
|
|
1040
1049
|
});
|
|
1050
|
+
for (const tc of result.toolCalls) {
|
|
1051
|
+
if (tc.name.startsWith("mcp__")) this.usedMcpToolNames.add(tc.name);
|
|
1052
|
+
}
|
|
1041
1053
|
googleSearchContext.configManager = this.config;
|
|
1042
1054
|
spawnAgentContext.provider = provider;
|
|
1043
1055
|
spawnAgentContext.model = this.currentModel;
|
|
@@ -1959,7 +1971,7 @@ ${undoResults.map((r) => ` \u2022 ${r}`).join("\n")}` });
|
|
|
1959
1971
|
case "test": {
|
|
1960
1972
|
this.send({ type: "info", message: "\u{1F9EA} Running tests..." });
|
|
1961
1973
|
try {
|
|
1962
|
-
const { executeTests } = await import("./run-tests-
|
|
1974
|
+
const { executeTests } = await import("./run-tests-47TTKJTB.js");
|
|
1963
1975
|
const argStr = args.join(" ").trim();
|
|
1964
1976
|
let testArgs = {};
|
|
1965
1977
|
if (argStr) {
|
|
@@ -2563,7 +2575,7 @@ Add .md files to create commands.` });
|
|
|
2563
2575
|
const contextWindow = this.getContextWindowSize();
|
|
2564
2576
|
if (contextWindow > 0) {
|
|
2565
2577
|
const toolBudget = Math.floor(contextWindow * 0.2);
|
|
2566
|
-
const { definitions, systemNote } = this.toolRegistry.getDefinitionsWithBudget(toolBudget);
|
|
2578
|
+
const { definitions, systemNote } = this.toolRegistry.getDefinitionsWithBudget(toolBudget, this.usedMcpToolNames);
|
|
2567
2579
|
return { toolDefs: definitions, mcpBudgetNote: systemNote };
|
|
2568
2580
|
}
|
|
2569
2581
|
return { toolDefs: this.toolRegistry.getDefinitions(), mcpBudgetNote: null };
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
getDangerLevel,
|
|
5
5
|
googleSearchContext,
|
|
6
6
|
truncateOutput
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-X5RX2VGQ.js";
|
|
8
8
|
import "./chunk-4BKXL7SM.js";
|
|
9
9
|
import {
|
|
10
10
|
SUBAGENT_ALLOWED_TOOLS
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-NIJZBQ6I.js";
|
|
12
12
|
|
|
13
13
|
// src/hub/task-orchestrator.ts
|
|
14
14
|
import { createInterface } from "readline";
|