jinzd-ai-cli 0.4.191 → 0.4.194

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  TEST_TIMEOUT
4
- } from "./chunk-ASVBZIUE.js";
4
+ } from "./chunk-ZEHHAE3B.js";
5
5
 
6
6
  // src/tools/builtin/run-tests.ts
7
7
  import { execSync, spawnSync } from "child_process";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CONFIG_DIR_NAME,
4
4
  VERSION
5
- } from "./chunk-ASVBZIUE.js";
5
+ } from "./chunk-ZEHHAE3B.js";
6
6
 
7
7
  // src/diagnostics/crash-log.ts
8
8
  import {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  truncateForPersist
4
- } from "./chunk-RQ7JVLFM.js";
4
+ } from "./chunk-ZJX6ZU5D.js";
5
5
  import {
6
6
  APP_NAME,
7
7
  CONFIG_DIR_NAME,
@@ -11,7 +11,7 @@ import {
11
11
  MCP_PROTOCOL_VERSION,
12
12
  MCP_TOOL_PREFIX,
13
13
  VERSION
14
- } from "./chunk-ASVBZIUE.js";
14
+ } from "./chunk-ZEHHAE3B.js";
15
15
 
16
16
  // src/mcp/client.ts
17
17
  import { spawn } from "child_process";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  CONFIG_DIR_NAME
4
- } from "./chunk-ASVBZIUE.js";
4
+ } from "./chunk-ZEHHAE3B.js";
5
5
  import {
6
6
  atomicWriteFileSync
7
7
  } from "./chunk-IW3Q7AE5.js";
@@ -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.191";
9
+ var VERSION = "0.4.194";
10
10
  var APP_NAME = "ai-cli";
11
11
  var CONFIG_DIR_NAME = ".aicli";
12
12
  var CONFIG_FILE_NAME = "config.json";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/core/constants.ts
4
- var VERSION = "0.4.191";
4
+ var VERSION = "0.4.194";
5
5
  var APP_NAME = "ai-cli";
6
6
  var CONFIG_DIR_NAME = ".aicli";
7
7
  var CONFIG_FILE_NAME = "config.json";
@@ -5,14 +5,15 @@ import {
5
5
  } from "./chunk-T2NL5ZIA.js";
6
6
  import {
7
7
  runTestsTool
8
- } from "./chunk-HSQAKOYX.js";
8
+ } from "./chunk-3KCEPI4E.js";
9
9
  import {
10
10
  runTool
11
- } from "./chunk-Y3PNCW7A.js";
11
+ } from "./chunk-CKBBAXCA.js";
12
12
  import {
13
13
  getDangerLevel,
14
- isFileWriteTool
15
- } from "./chunk-HIU2SH4V.js";
14
+ isFileWriteTool,
15
+ runLeanAgentLoop
16
+ } from "./chunk-ZRG2FPC6.js";
16
17
  import {
17
18
  EnvLoader,
18
19
  NetworkError,
@@ -25,7 +26,7 @@ import {
25
26
  SUBAGENT_ALLOWED_TOOLS,
26
27
  SUBAGENT_DEFAULT_MAX_ROUNDS,
27
28
  SUBAGENT_MAX_ROUNDS_LIMIT
28
- } from "./chunk-ASVBZIUE.js";
29
+ } from "./chunk-ZEHHAE3B.js";
29
30
  import {
30
31
  fileCheckpoints
31
32
  } from "./chunk-4BKXL7SM.js";
@@ -3801,9 +3802,19 @@ ${preamble}`;
3801
3802
  }
3802
3803
 
3803
3804
  // src/tools/builtin/save-last-response.ts
3804
- import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync2 } from "fs";
3805
+ import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync2, unlinkSync as unlinkSync2, rmdirSync as rmdirSync2 } from "fs";
3805
3806
  import { dirname as dirname3 } from "path";
3806
3807
  var lastResponseStore = { content: "" };
3808
+ function cleanupRejectedTeeFile(filePath) {
3809
+ try {
3810
+ unlinkSync2(filePath);
3811
+ } catch {
3812
+ }
3813
+ try {
3814
+ rmdirSync2(dirname3(filePath));
3815
+ } catch {
3816
+ }
3817
+ }
3807
3818
  var saveLastResponseTool = {
3808
3819
  definition: {
3809
3820
  name: "save_last_response",
@@ -4345,61 +4356,37 @@ async function runSubAgent(task, maxRounds, agentIndex, ctx) {
4345
4356
  ];
4346
4357
  const subSystemPrompt = buildSubAgentSystemPrompt(task, ctx.systemPrompt);
4347
4358
  const toolDefs = subRegistry.getDefinitions();
4348
- const extraMessages = [];
4349
- const totalUsage = { inputTokens: 0, outputTokens: 0 };
4350
- let finalContent = "";
4351
4359
  printSubAgentHeader(task, maxRounds, agentIndex);
4352
- try {
4353
- for (let round = 0; round < maxRounds; round++) {
4360
+ const loop = await runLeanAgentLoop({
4361
+ provider: ctx.provider,
4362
+ messages: subMessages,
4363
+ model: ctx.model,
4364
+ maxRounds,
4365
+ chatParams: {
4366
+ temperature: ctx.modelParams.temperature,
4367
+ maxTokens: ctx.modelParams.maxTokens,
4368
+ timeout: ctx.modelParams.timeout,
4369
+ thinking: ctx.modelParams.thinking
4370
+ },
4371
+ executeTools: (calls) => subExecutor.executeAll(calls),
4372
+ systemPromptForRound: () => subSystemPrompt,
4373
+ toolDefsForRound: () => toolDefs,
4374
+ onRoundStart: (round) => {
4354
4375
  subExecutor.setRoundInfo(round + 1, maxRounds);
4355
- const result = await ctx.provider.chatWithTools(
4356
- {
4357
- messages: subMessages,
4358
- model: ctx.model,
4359
- systemPrompt: subSystemPrompt,
4360
- stream: false,
4361
- temperature: ctx.modelParams.temperature,
4362
- maxTokens: ctx.modelParams.maxTokens,
4363
- timeout: ctx.modelParams.timeout,
4364
- thinking: ctx.modelParams.thinking,
4365
- ...extraMessages.length > 0 ? { _extraMessages: extraMessages } : {}
4366
- },
4367
- toolDefs
4368
- );
4369
- if (result.usage) {
4370
- totalUsage.inputTokens += result.usage.inputTokens;
4371
- totalUsage.outputTokens += result.usage.outputTokens;
4372
- }
4373
- if ("content" in result) {
4374
- finalContent = result.content;
4375
- break;
4376
- }
4377
4376
  if (ctx.configManager) {
4378
4377
  googleSearchContext.configManager = ctx.configManager;
4379
4378
  }
4380
- const toolResults = await subExecutor.executeAll(result.toolCalls);
4381
- const reasoningContent = "reasoningContent" in result ? result.reasoningContent : void 0;
4382
- const newMsgs = ctx.provider.buildToolResultMessages(
4383
- result.toolCalls,
4384
- toolResults,
4385
- reasoningContent
4386
- );
4387
- extraMessages.push(...newMsgs);
4388
- }
4389
- if (!finalContent) {
4390
- finalContent = `(Sub-agent reached maximum rounds (${maxRounds}) without producing a final response)`;
4391
- }
4392
- } catch (err) {
4393
- const errMsg = err instanceof Error ? err.message : String(err);
4394
- finalContent = `(Sub-agent error: ${errMsg})`;
4395
- process.stderr.write(
4396
- `
4379
+ },
4380
+ onRoundsExhausted: () => `(Sub-agent reached maximum rounds (${maxRounds}) without producing a final response)`,
4381
+ onError: (errMsg) => {
4382
+ process.stderr.write(`
4397
4383
  [spawn_agent] Error in sub-agent loop: ${errMsg}
4398
- `
4399
- );
4400
- }
4401
- printSubAgentFooter(totalUsage, agentIndex);
4402
- return { content: finalContent, usage: totalUsage };
4384
+ `);
4385
+ return `(Sub-agent error: ${errMsg})`;
4386
+ }
4387
+ });
4388
+ printSubAgentFooter(loop.usage, agentIndex);
4389
+ return { content: loop.content, usage: loop.usage };
4403
4390
  }
4404
4391
  var spawnAgentTool = {
4405
4392
  definition: {
@@ -5660,6 +5647,7 @@ export {
5660
5647
  truncateOutput,
5661
5648
  ToolExecutor,
5662
5649
  lastResponseStore,
5650
+ cleanupRejectedTeeFile,
5663
5651
  askUserContext,
5664
5652
  googleSearchContext,
5665
5653
  spawnAgentContext,