jinzd-ai-cli 0.4.64 → 0.4.65

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.
@@ -8,7 +8,7 @@ import {
8
8
  RateLimitError,
9
9
  schemaToJsonSchema,
10
10
  truncateForPersist
11
- } from "./chunk-YF3Z47AT.js";
11
+ } from "./chunk-SKN6HBBT.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-S6P5MYUF.js";
24
+ } from "./chunk-AQNAV4H4.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
- result.push(
3763
- ...provider.buildToolResultMessages(toolCalls, toolResults, msg.reasoningContent)
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({
@@ -8,7 +8,7 @@ import { platform } from "os";
8
8
  import chalk from "chalk";
9
9
 
10
10
  // src/core/constants.ts
11
- var VERSION = "0.4.64";
11
+ var VERSION = "0.4.65";
12
12
  var APP_NAME = "ai-cli";
13
13
  var CONFIG_DIR_NAME = ".aicli";
14
14
  var CONFIG_FILE_NAME = "config.json";
@@ -10,7 +10,7 @@ import {
10
10
  SUBAGENT_DEFAULT_MAX_ROUNDS,
11
11
  SUBAGENT_MAX_ROUNDS_LIMIT,
12
12
  runTestsTool
13
- } from "./chunk-S6P5MYUF.js";
13
+ } from "./chunk-AQNAV4H4.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 parallelPhase = safeParallel.length > 0 ? Promise.all(safeParallel.map(async ({ idx, call }) => {
1390
- results[idx] = await this.execute(call);
1391
- })) : Promise.resolve();
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
- results[idx] = await this.execute(call);
1401
+ await wrapExec(idx, call);
1395
1402
  }
1396
1403
  })();
1397
1404
  await Promise.all([parallelPhase, bashPhase]);
@@ -6,7 +6,7 @@ import { platform } from "os";
6
6
  import chalk from "chalk";
7
7
 
8
8
  // src/core/constants.ts
9
- var VERSION = "0.4.64";
9
+ var VERSION = "0.4.65";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -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-ZTMZIHNF.js");
388
+ const { TaskOrchestrator } = await import("./task-orchestrator-4DCUYIRI.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-JSAPO5GI.js";
34
+ } from "./chunk-2B2EVU6Z.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-YF3Z47AT.js";
49
+ } from "./chunk-SKN6HBBT.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-S6P5MYUF.js";
74
+ } from "./chunk-AQNAV4H4.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-WNHU6QH3.js");
2196
+ const { executeTests } = await import("./run-tests-C4CEOYZP.js");
2197
2197
  const argStr = args.join(" ").trim();
2198
2198
  let testArgs = {};
2199
2199
  if (argStr) {
@@ -5905,7 +5905,7 @@ program.command("web").description("Start Web UI server with browser-based chat
5905
5905
  console.error("Error: Invalid port number. Must be between 1 and 65535.");
5906
5906
  process.exit(1);
5907
5907
  }
5908
- const { startWebServer } = await import("./server-R7OJYTSP.js");
5908
+ const { startWebServer } = await import("./server-CDRR3DC7.js");
5909
5909
  await startWebServer({ port, host: options.host });
5910
5910
  });
5911
5911
  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 +6138,7 @@ program.command("hub [topic]").description("Start multi-agent hub (discuss / bra
6138
6138
  }),
6139
6139
  config.get("customProviders")
6140
6140
  );
6141
- const { startHub } = await import("./hub-KEBKTLLR.js");
6141
+ const { startHub } = await import("./hub-TKYPJZEX.js");
6142
6142
  await startHub(
6143
6143
  {
6144
6144
  topic: topic ?? "",
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  executeTests,
4
4
  runTestsTool
5
- } from "./chunk-S6P5MYUF.js";
5
+ } from "./chunk-AQNAV4H4.js";
6
6
  export {
7
7
  executeTests,
8
8
  runTestsTool
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  executeTests,
3
3
  runTestsTool
4
- } from "./chunk-NJEMUAJD.js";
4
+ } from "./chunk-UNLZJRCY.js";
5
5
  export {
6
6
  executeTests,
7
7
  runTestsTool
@@ -21,7 +21,7 @@ import {
21
21
  persistToolRound,
22
22
  rebuildExtraMessages,
23
23
  setupProxy
24
- } from "./chunk-JSAPO5GI.js";
24
+ } from "./chunk-2B2EVU6Z.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-YF3Z47AT.js";
44
+ } from "./chunk-SKN6HBBT.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-S6P5MYUF.js";
64
+ } from "./chunk-AQNAV4H4.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 parallelPhase = safeParallel.length > 0 ? Promise.all(safeParallel.map(async ({ idx, call }) => {
349
- results[idx] = await this.execute(call);
350
- })) : Promise.resolve();
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
- results[idx] = await this.execute(call);
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-WNHU6QH3.js");
1974
+ const { executeTests } = await import("./run-tests-C4CEOYZP.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-YF3Z47AT.js";
7
+ } from "./chunk-SKN6HBBT.js";
8
8
  import "./chunk-4BKXL7SM.js";
9
9
  import {
10
10
  SUBAGENT_ALLOWED_TOOLS
11
- } from "./chunk-S6P5MYUF.js";
11
+ } from "./chunk-AQNAV4H4.js";
12
12
 
13
13
  // src/hub/task-orchestrator.ts
14
14
  import { createInterface } from "readline";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jinzd-ai-cli",
3
- "version": "0.4.64",
3
+ "version": "0.4.65",
4
4
  "description": "Cross-platform REPL-style AI CLI with multi-provider support",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",