@google/gemini-cli-a2a-server 0.62.0-nightly.20260925.gbedef96ef → 0.62.0

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.
@@ -68266,7 +68266,7 @@ var init_ignorePatterns = __esm({
68266
68266
  });
68267
68267
 
68268
68268
  // packages/core/dist/src/utils/constants.js
68269
- var REFERENCE_CONTENT_END, DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, MAX_FILE_SIZE_MB, MAX_STORED_TOOL_OUTPUT_BYTES;
68269
+ var REFERENCE_CONTENT_END, DEFAULT_MAX_LINES_TEXT_FILE, MAX_LINE_LENGTH_TEXT_FILE, MAX_FILE_SIZE_MB;
68270
68270
  var init_constants = __esm({
68271
68271
  "packages/core/dist/src/utils/constants.js"() {
68272
68272
  "use strict";
@@ -68274,7 +68274,6 @@ var init_constants = __esm({
68274
68274
  DEFAULT_MAX_LINES_TEXT_FILE = 2e3;
68275
68275
  MAX_LINE_LENGTH_TEXT_FILE = 2e3;
68276
68276
  MAX_FILE_SIZE_MB = 20;
68277
- MAX_STORED_TOOL_OUTPUT_BYTES = 64 * 1024;
68278
68277
  }
68279
68278
  });
68280
68279
 
@@ -221253,8 +221252,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
221253
221252
  var init_git_commit = __esm({
221254
221253
  "packages/core/dist/src/generated/git-commit.js"() {
221255
221254
  "use strict";
221256
- GIT_COMMIT_INFO = "bedef96ef";
221257
- CLI_VERSION = "0.62.0-nightly.20260925.gbedef96ef";
221255
+ GIT_COMMIT_INFO = "9ac01f80f";
221256
+ CLI_VERSION = "0.62.0";
221258
221257
  }
221259
221258
  });
221260
221259
 
@@ -336985,7 +336984,7 @@ function getVersion() {
336985
336984
  }
336986
336985
  versionPromise = (async () => {
336987
336986
  const pkgJson = await getPackageJson(__dirname4);
336988
- return "0.62.0-nightly.20260925.gbedef96ef";
336987
+ return "0.62.0";
336989
336988
  })();
336990
336989
  return versionPromise;
336991
336990
  }
@@ -344448,7 +344447,6 @@ function getSafeGitEnv(baseEnv = process.env) {
344448
344447
  }
344449
344448
  return {
344450
344449
  ...cleanedEnv,
344451
- GIT_TERMINAL_PROMPT: "0",
344452
344450
  GIT_CONFIG_GLOBAL: devNullPath,
344453
344451
  GIT_CONFIG_SYSTEM: devNullPath,
344454
344452
  GIT_CONFIG_NOSYSTEM: "1",
@@ -358481,33 +358479,6 @@ ${truncated}`;
358481
358479
  }
358482
358480
  }
358483
358481
  }
358484
- if (child.stdout) {
358485
- child.stdout.removeAllListeners();
358486
- try {
358487
- child.stdout.destroy();
358488
- } catch {
358489
- }
358490
- }
358491
- if (child.stderr) {
358492
- child.stderr.removeAllListeners();
358493
- try {
358494
- child.stderr.destroy();
358495
- } catch {
358496
- }
358497
- }
358498
- const stdin = child.stdin;
358499
- if (stdin) {
358500
- stdin.removeAllListeners();
358501
- try {
358502
- stdin.destroy();
358503
- } catch {
358504
- }
358505
- }
358506
- child.removeAllListeners("error");
358507
- child.removeAllListeners("close");
358508
- state.sniffChunks.length = 0;
358509
- stdoutDecoder = null;
358510
- stderrDecoder = null;
358511
358482
  return;
358512
358483
  };
358513
358484
  var cleanup = cleanup2;
@@ -358639,7 +358610,6 @@ ${truncated}`;
358639
358610
  cleanup2();
358640
358611
  cmdCleanup?.();
358641
358612
  let combinedOutput = state.output;
358642
- state.output = "";
358643
358613
  if (state.truncated) {
358644
358614
  const truncationMessage = `
358645
358615
  [GEMINI_CLI_WARNING: Output truncated. The buffer is limited to ${MAX_CHILD_PROCESS_BUFFER_SIZE / (1024 * 1024)}MB.]`;
@@ -358675,8 +358645,9 @@ ${truncated}`;
358675
358645
  historyItem.endTime = Date.now();
358676
358646
  }
358677
358647
  onOutputEvent(event);
358678
- _ShellExecutionService.activeChildProcesses.delete(pid);
358679
- _ShellExecutionService.cleanupLogStream(pid);
358648
+ _ShellExecutionService.cleanupLogStream(pid).then(() => {
358649
+ _ShellExecutionService.activeChildProcesses.delete(pid);
358650
+ });
358680
358651
  ExecutionLifecycleService.completeWithResult(pid, resultPayload);
358681
358652
  } else {
358682
358653
  resolveWithoutPid?.(resultPayload);
@@ -371243,117 +371214,6 @@ var init_types13 = __esm({
371243
371214
  });
371244
371215
 
371245
371216
  // packages/core/dist/src/context/chatCompressionService.js
371246
- function isExemptRetrievalTool(toolName, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
371247
- if (!toolName) {
371248
- return false;
371249
- }
371250
- const normalized = toolName.toLowerCase();
371251
- if (exemptTools.has(normalized)) {
371252
- return true;
371253
- }
371254
- return normalized.endsWith("read_file") || normalized.endsWith("read_files") || normalized.endsWith("read_many_files") || normalized.endsWith("read_resource");
371255
- }
371256
- function collapseOlderFunctionResponses(history, maxBytesPerOldResponse = COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES, segmenter2 = defaultGraphemeSegmenter, protectedTurns = RECENT_TURNS_PROTECTED, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
371257
- const toolIndices = [];
371258
- for (let i3 = 0; i3 < history.length; i3++) {
371259
- if (history[i3].role === "user" && history[i3].parts?.some((p2) => !!p2.functionResponse)) {
371260
- toolIndices.push(i3);
371261
- }
371262
- }
371263
- if (toolIndices.length <= protectedTurns) {
371264
- return history;
371265
- }
371266
- const cutoffToolIndex = toolIndices[toolIndices.length - protectedTurns];
371267
- const collapseString = (str2) => {
371268
- const totalBytes = Buffer.byteLength(str2, "utf8");
371269
- if (totalBytes <= maxBytesPerOldResponse) {
371270
- return str2;
371271
- }
371272
- const previewBytes = maxBytesPerOldResponse;
371273
- let preview = "";
371274
- let currentBytes = 0;
371275
- for (const { segment } of segmenter2.segment(str2)) {
371276
- const segmentBytes = Buffer.byteLength(segment, "utf8");
371277
- if (currentBytes + segmentBytes > previewBytes) {
371278
- break;
371279
- }
371280
- preview += segment;
371281
- currentBytes += segmentBytes;
371282
- }
371283
- const omittedBytes = totalBytes - currentBytes;
371284
- return `${preview}
371285
- ... [Tool output collapsed from previous turn: ${omittedBytes} bytes omitted to conserve memory] ...`;
371286
- };
371287
- const collapseValue = (val) => {
371288
- if (typeof val === "string") {
371289
- return collapseString(val);
371290
- }
371291
- if (Array.isArray(val)) {
371292
- let arrayModified = false;
371293
- const newVal = val.map((item) => {
371294
- const collapsed = collapseValue(item);
371295
- if (collapsed !== item) {
371296
- arrayModified = true;
371297
- }
371298
- return collapsed;
371299
- });
371300
- return arrayModified ? newVal : val;
371301
- }
371302
- if (typeof val === "object" && val !== null) {
371303
- const proto = Object.getPrototypeOf(val);
371304
- if (proto !== Object.prototype && proto !== null) {
371305
- return val;
371306
- }
371307
- let objModified = false;
371308
- const copy = {};
371309
- for (const [k2, v2] of Object.entries(val)) {
371310
- const collapsed = collapseValue(v2);
371311
- if (collapsed !== v2) {
371312
- objModified = true;
371313
- }
371314
- copy[k2] = collapsed;
371315
- }
371316
- return objModified ? copy : val;
371317
- }
371318
- return val;
371319
- };
371320
- let modified = false;
371321
- const newHistory = history.map((content, idx) => {
371322
- if (idx >= cutoffToolIndex || content.role !== "user" || !content.parts) {
371323
- return content;
371324
- }
371325
- let partsModified = false;
371326
- const newParts = content.parts.map((part) => {
371327
- if (!part.functionResponse?.response) {
371328
- return part;
371329
- }
371330
- if (isExemptRetrievalTool(part.functionResponse.name, exemptTools)) {
371331
- return part;
371332
- }
371333
- const resp = part.functionResponse.response;
371334
- const newResp = collapseValue(resp);
371335
- if (newResp !== resp) {
371336
- partsModified = true;
371337
- return {
371338
- ...part,
371339
- functionResponse: {
371340
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
371341
- ...part.functionResponse,
371342
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
371343
- response: newResp
371344
- }
371345
- };
371346
- }
371347
- return part;
371348
- });
371349
- if (partsModified) {
371350
- modified = true;
371351
- return { ...content, parts: newParts };
371352
- }
371353
- return content;
371354
- });
371355
- return modified ? newHistory : history;
371356
- }
371357
371217
  function findCompressSplitPoint(contents, fraction) {
371358
371218
  if (fraction <= 0 || fraction >= 1) {
371359
371219
  throw new Error("Fraction must be between 0 and 1");
@@ -371465,7 +371325,7 @@ async function truncateHistoryToBudget(history, config2) {
371465
371325
  }
371466
371326
  return truncatedHistory;
371467
371327
  }
371468
- var DEFAULT_COMPRESSION_TOKEN_THRESHOLD, RECENT_TURNS_PROTECTED, RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE, COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES, defaultGraphemeSegmenter, COMPRESSION_PRESERVE_THRESHOLD, COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET, ChatCompressionService;
371328
+ var DEFAULT_COMPRESSION_TOKEN_THRESHOLD, COMPRESSION_PRESERVE_THRESHOLD, COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET, ChatCompressionService;
371469
371329
  var init_chatCompressionService = __esm({
371470
371330
  "packages/core/dist/src/context/chatCompressionService.js"() {
371471
371331
  "use strict";
@@ -371482,22 +371342,6 @@ var init_chatCompressionService = __esm({
371482
371342
  init_models();
371483
371343
  init_types13();
371484
371344
  DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.5;
371485
- RECENT_TURNS_PROTECTED = 3;
371486
- RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE = /* @__PURE__ */ new Set([
371487
- "read_file",
371488
- "read_many_files",
371489
- "get_internal_docs",
371490
- "read_mcp_resource",
371491
- "grep",
371492
- "rip_grep",
371493
- "glob",
371494
- "search_file_content",
371495
- "find_files"
371496
- ]);
371497
- COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES = 2048;
371498
- defaultGraphemeSegmenter = new Intl.Segmenter(void 0, {
371499
- granularity: "grapheme"
371500
- });
371501
371345
  COMPRESSION_PRESERVE_THRESHOLD = 0.3;
371502
371346
  COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET = 5e4;
371503
371347
  ChatCompressionService = class {
@@ -371515,12 +371359,10 @@ var init_chatCompressionService = __esm({
371515
371359
  }
371516
371360
  const trigger = force ? PreCompressTrigger.Manual : PreCompressTrigger.Auto;
371517
371361
  await config2.getHookSystem()?.firePreCompressEvent(trigger);
371518
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
371519
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(curatedHistory.flatMap((c2) => c2.parts || []));
371362
+ const originalTokenCount = chat.getLastPromptTokenCount();
371520
371363
  if (!force) {
371521
371364
  const threshold = await config2.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
371522
- const isOverModelThreshold = originalTokenCount >= threshold * tokenLimit(model);
371523
- if (!isOverModelThreshold) {
371365
+ if (originalTokenCount < threshold * tokenLimit(model)) {
371524
371366
  return {
371525
371367
  newHistory: null,
371526
371368
  info: {
@@ -371658,8 +371500,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
371658
371500
  }
371659
371501
  };
371660
371502
  } else {
371661
- historyToCompressTruncated.length = 0;
371662
- originalHistoryToCompress.length = 0;
371663
371503
  return {
371664
371504
  newHistory: extraHistory,
371665
371505
  info: {
@@ -371674,135 +371514,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
371674
371514
  }
371675
371515
  });
371676
371516
 
371677
- // packages/core/dist/src/utils/tool-utils.js
371678
- function isToolCallResponseInfo(data) {
371679
- return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
371680
- }
371681
- function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
371682
- const matches = allToolNames.map((toolName) => ({
371683
- name: toolName,
371684
- distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
371685
- }));
371686
- matches.sort((a, b2) => a.distance - b2.distance);
371687
- const topNResults = matches.slice(0, topN);
371688
- if (topNResults.length === 0) {
371689
- return "";
371690
- }
371691
- const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
371692
- if (topNResults.length > 1) {
371693
- return ` Did you mean one of: ${suggestedNames}?`;
371694
- } else {
371695
- return ` Did you mean ${suggestedNames}?`;
371696
- }
371697
- }
371698
- function truncateToolOutput(text, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
371699
- if (Buffer.byteLength(text, "utf8") <= maxBytes) {
371700
- return text;
371701
- }
371702
- const suffix = savedFilePath ? `
371703
- ... [Tool output truncated to conserve memory. For full output see: ${savedFilePath}]` : "\n... [Tool output truncated to conserve memory]";
371704
- const targetBytes = Math.max(0, maxBytes - Buffer.byteLength(suffix, "utf8"));
371705
- let accumulatedBytes = 0;
371706
- let truncatedText = "";
371707
- for (const { segment } of segmenter.segment(text)) {
371708
- const segmentBytes = Buffer.byteLength(segment, "utf8");
371709
- if (accumulatedBytes + segmentBytes > targetBytes) {
371710
- break;
371711
- }
371712
- accumulatedBytes += segmentBytes;
371713
- truncatedText += segment;
371714
- }
371715
- return truncatedText + suffix;
371716
- }
371717
- function truncateFunctionResponsePart(part, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
371718
- if (part.text && Buffer.byteLength(part.text, "utf8") > maxBytes) {
371719
- return {
371720
- ...part,
371721
- text: truncateToolOutput(part.text, maxBytes, savedFilePath)
371722
- };
371723
- }
371724
- if (!part.functionResponse?.response) {
371725
- return part;
371726
- }
371727
- const resp = part.functionResponse.response;
371728
- if (typeof resp === "string") {
371729
- if (Buffer.byteLength(resp, "utf8") > maxBytes) {
371730
- return {
371731
- ...part,
371732
- functionResponse: {
371733
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
371734
- ...part.functionResponse,
371735
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
371736
- response: truncateToolOutput(resp, maxBytes, savedFilePath)
371737
- }
371738
- };
371739
- }
371740
- return part;
371741
- }
371742
- if (typeof resp === "object" && resp !== null) {
371743
- const truncateValue = (val) => {
371744
- if (typeof val === "string") {
371745
- if (Buffer.byteLength(val, "utf8") > maxBytes) {
371746
- return truncateToolOutput(val, maxBytes, savedFilePath);
371747
- }
371748
- return val;
371749
- }
371750
- if (Array.isArray(val)) {
371751
- let arrayModified = false;
371752
- const newVal = val.map((item) => {
371753
- const truncated = truncateValue(item);
371754
- if (truncated !== item) {
371755
- arrayModified = true;
371756
- }
371757
- return truncated;
371758
- });
371759
- return arrayModified ? newVal : val;
371760
- }
371761
- if (typeof val === "object" && val !== null) {
371762
- const proto = Object.getPrototypeOf(val);
371763
- if (proto !== Object.prototype && proto !== null) {
371764
- return val;
371765
- }
371766
- let objModified = false;
371767
- const copy = {};
371768
- for (const [k2, v2] of Object.entries(val)) {
371769
- const truncated = truncateValue(v2);
371770
- if (truncated !== v2) {
371771
- objModified = true;
371772
- }
371773
- copy[k2] = truncated;
371774
- }
371775
- return objModified ? copy : val;
371776
- }
371777
- return val;
371778
- };
371779
- const newResp = truncateValue(resp);
371780
- if (newResp !== resp) {
371781
- return {
371782
- ...part,
371783
- functionResponse: {
371784
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
371785
- ...part.functionResponse,
371786
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
371787
- response: newResp
371788
- }
371789
- };
371790
- }
371791
- }
371792
- return part;
371793
- }
371794
- var import_fast_levenshtein2, segmenter;
371795
- var init_tool_utils = __esm({
371796
- "packages/core/dist/src/utils/tool-utils.js"() {
371797
- "use strict";
371798
- init_src3();
371799
- init_shell_utils();
371800
- import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
371801
- init_constants();
371802
- segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
371803
- }
371804
- });
371805
-
371806
371517
  // packages/core/dist/src/agents/types.js
371807
371518
  function isSubagentProgress(obj) {
371808
371519
  return typeof obj === "object" && obj !== null && "isSubagentProgress" in obj && obj.isSubagentProgress === true;
@@ -381510,6 +381221,37 @@ var init_toolCallContext = __esm({
381510
381221
  }
381511
381222
  });
381512
381223
 
381224
+ // packages/core/dist/src/utils/tool-utils.js
381225
+ function isToolCallResponseInfo(data) {
381226
+ return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
381227
+ }
381228
+ function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
381229
+ const matches = allToolNames.map((toolName) => ({
381230
+ name: toolName,
381231
+ distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
381232
+ }));
381233
+ matches.sort((a, b2) => a.distance - b2.distance);
381234
+ const topNResults = matches.slice(0, topN);
381235
+ if (topNResults.length === 0) {
381236
+ return "";
381237
+ }
381238
+ const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
381239
+ if (topNResults.length > 1) {
381240
+ return ` Did you mean one of: ${suggestedNames}?`;
381241
+ } else {
381242
+ return ` Did you mean ${suggestedNames}?`;
381243
+ }
381244
+ }
381245
+ var import_fast_levenshtein2;
381246
+ var init_tool_utils = __esm({
381247
+ "packages/core/dist/src/utils/tool-utils.js"() {
381248
+ "use strict";
381249
+ init_src3();
381250
+ init_shell_utils();
381251
+ import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
381252
+ }
381253
+ });
381254
+
381513
381255
  // packages/core/dist/src/scheduler/state-manager.js
381514
381256
  var SchedulerStateManager;
381515
381257
  var init_state_manager = __esm({
@@ -387720,8 +387462,6 @@ var init_tool_executor = __esm({
387720
387462
  init_coreToolHookTriggers();
387721
387463
  init_fileUtils();
387722
387464
  init_generateContentResponseUtilities();
387723
- init_tool_utils();
387724
- init_constants();
387725
387465
  init_types3();
387726
387466
  init_constants2();
387727
387467
  ToolExecutor = class {
@@ -387823,16 +387563,13 @@ var init_tool_executor = __esm({
387823
387563
  const originalContentLength = content.length;
387824
387564
  const { outputFile: savedPath } = await saveTruncatedToolOutput(content, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
387825
387565
  outputFile = savedPath;
387826
- let truncatedContent = formatTruncatedToolOutput(content, outputFile, threshold);
387566
+ const truncatedContent = formatTruncatedToolOutput(content, outputFile, threshold);
387827
387567
  logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(call.request.prompt_id, {
387828
387568
  toolName,
387829
387569
  originalContentLength,
387830
387570
  truncatedContentLength: truncatedContent.length,
387831
387571
  threshold
387832
387572
  }));
387833
- if (typeof truncatedContent === "string" && Buffer.byteLength(truncatedContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387834
- truncatedContent = truncateToolOutput(truncatedContent, MAX_STORED_TOOL_OUTPUT_BYTES);
387835
- }
387836
387573
  return { truncatedContent, outputFile };
387837
387574
  }
387838
387575
  } else if (Array.isArray(content) && content.length === 1 && "tool" in call && call.tool instanceof DiscoveredMCPTool) {
@@ -387844,10 +387581,7 @@ var init_tool_executor = __esm({
387844
387581
  const originalContentLength = textContent2.length;
387845
387582
  const { outputFile: savedPath } = await saveTruncatedToolOutput(textContent2, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
387846
387583
  outputFile = savedPath;
387847
- let truncatedText = formatTruncatedToolOutput(textContent2, outputFile, threshold);
387848
- if (typeof truncatedText === "string" && Buffer.byteLength(truncatedText, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387849
- truncatedText = truncateToolOutput(truncatedText, MAX_STORED_TOOL_OUTPUT_BYTES);
387850
- }
387584
+ const truncatedText = formatTruncatedToolOutput(textContent2, outputFile, threshold);
387851
387585
  const truncatedContent = [
387852
387586
  { ...firstPart, text: truncatedText }
387853
387587
  ];
@@ -387861,45 +387595,7 @@ var init_tool_executor = __esm({
387861
387595
  }
387862
387596
  }
387863
387597
  }
387864
- const ensureOutputFile = async (rawText) => {
387865
- if (!outputFile) {
387866
- try {
387867
- const { outputFile: savedPath } = await saveTruncatedToolOutput(rawText, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
387868
- outputFile = savedPath;
387869
- } catch {
387870
- }
387871
- }
387872
- return outputFile;
387873
- };
387874
- let finalContent = content;
387875
- if (typeof finalContent === "string") {
387876
- if (Buffer.byteLength(finalContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387877
- const savedPath = await ensureOutputFile(finalContent);
387878
- finalContent = truncateToolOutput(finalContent, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath);
387879
- }
387880
- } else if (Array.isArray(finalContent)) {
387881
- finalContent = await Promise.all(finalContent.map(async (part) => {
387882
- if (typeof part === "string" && Buffer.byteLength(part, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387883
- const savedPath = await ensureOutputFile(part);
387884
- return truncateToolOutput(part, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath);
387885
- }
387886
- if (typeof part === "object" && part !== null && "text" in part && typeof part.text === "string" && Buffer.byteLength(part.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387887
- const savedPath = await ensureOutputFile(part.text);
387888
- return {
387889
- ...part,
387890
- text: truncateToolOutput(part.text, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath)
387891
- };
387892
- }
387893
- return part;
387894
- }));
387895
- } else if (typeof finalContent === "object" && finalContent !== null && "text" in finalContent && typeof finalContent.text === "string" && Buffer.byteLength(finalContent.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
387896
- const savedPath = await ensureOutputFile(finalContent.text);
387897
- finalContent = {
387898
- ...finalContent,
387899
- text: truncateToolOutput(finalContent.text, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath)
387900
- };
387901
- }
387902
- return { truncatedContent: finalContent, outputFile };
387598
+ return { truncatedContent: content, outputFile };
387903
387599
  }
387904
387600
  async createCancelledResult(call, reason, toolResult) {
387905
387601
  const errorMessage = `[Operation Cancelled] ${reason}`;
@@ -389350,8 +389046,6 @@ var init_local_executor = __esm({
389350
389046
  init_turn();
389351
389047
  init_types3();
389352
389048
  init_chatCompressionService();
389353
- init_constants();
389354
- init_tool_utils();
389355
389049
  init_environmentContext();
389356
389050
  init_snippets();
389357
389051
  init_promptIdContext();
@@ -389361,8 +389055,6 @@ var init_local_executor = __esm({
389361
389055
  init_errors2();
389362
389056
  init_utils6();
389363
389057
  init_models();
389364
- init_tokenLimits();
389365
- init_tokenCalculation();
389366
389058
  init_mnemonist();
389367
389059
  init_thoughtUtils();
389368
389060
  init_debugLogger();
@@ -389880,30 +389572,13 @@ var init_local_executor = __esm({
389880
389572
  }
389881
389573
  async tryCompressChat(chat, prompt_id, abortSignal) {
389882
389574
  const model = this.definition.modelConfig.model ?? DEFAULT_GEMINI_MODEL;
389883
- const threshold = await this.context.config.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
389884
- const modelLimit = tokenLimit(model);
389885
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
389886
- const currentHistory = chat.getHistory(false);
389887
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(currentHistory.flatMap((c2) => c2.parts || []));
389888
- if (originalTokenCount >= threshold * modelLimit) {
389889
- const collapsedHistory = collapseOlderFunctionResponses(currentHistory);
389890
- if (collapsedHistory !== currentHistory) {
389891
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
389892
- const turns = collapsedHistory.map((c2, idx) => ({
389893
- id: existingTurns[idx]?.id ?? randomUUID15(),
389894
- content: c2
389895
- }));
389896
- chat.setHistory(turns);
389897
- }
389898
- }
389899
389575
  const { newHistory, info: info2 } = await this.compressionService.compress(chat, prompt_id, false, model, this.context.config, this.hasFailedCompressionAttempt, abortSignal);
389900
389576
  if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
389901
389577
  this.hasFailedCompressionAttempt = true;
389902
389578
  } else if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
389903
389579
  if (newHistory) {
389904
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
389905
- const turns = newHistory.map((c2, idx) => ({
389906
- id: existingTurns[idx]?.id ?? randomUUID15(),
389580
+ const turns = newHistory.map((c2) => ({
389581
+ id: randomUUID15(),
389907
389582
  content: c2
389908
389583
  }));
389909
389584
  chat.setHistory(turns);
@@ -389911,9 +389586,8 @@ var init_local_executor = __esm({
389911
389586
  }
389912
389587
  } else if (info2.compressionStatus === CompressionStatus.CONTENT_TRUNCATED) {
389913
389588
  if (newHistory) {
389914
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
389915
- const turns = newHistory.map((c2, idx) => ({
389916
- id: existingTurns[idx]?.id ?? randomUUID15(),
389589
+ const turns = newHistory.map((c2) => ({
389590
+ id: randomUUID15(),
389917
389591
  content: c2
389918
389592
  }));
389919
389593
  chat.setHistory(turns);
@@ -390096,15 +389770,6 @@ var init_local_executor = __esm({
390096
389770
  signal,
390097
389771
  onWaitingForConfirmation
390098
389772
  });
390099
- for (const call of completedCalls) {
390100
- const outputFile = call.response?.outputFile;
390101
- if (call.response?.responseParts) {
390102
- call.response.responseParts = call.response.responseParts.map((p2) => truncateFunctionResponsePart(p2, MAX_STORED_TOOL_OUTPUT_BYTES, outputFile));
390103
- }
390104
- if (typeof call.response?.resultDisplay === "string" && Buffer.byteLength(call.response.resultDisplay, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
390105
- call.response.resultDisplay = truncateToolOutput(call.response.resultDisplay, MAX_STORED_TOOL_OUTPUT_BYTES, outputFile);
390106
- }
390107
- }
390108
389773
  chat.recordCompletedToolCalls(model, completedCalls);
390109
389774
  for (const call of completedCalls) {
390110
389775
  const toolName = toolNameMap.get(call.request.callId) || call.request.name;
@@ -390170,7 +389835,7 @@ var init_local_executor = __esm({
390170
389835
  const callId = functionCall.id ?? `${promptId}-${index}`;
390171
389836
  const part = syncResults.get(callId);
390172
389837
  if (part) {
390173
- toolResponseParts.push(truncateFunctionResponsePart(part, MAX_STORED_TOOL_OUTPUT_BYTES));
389838
+ toolResponseParts.push(part);
390174
389839
  continue;
390175
389840
  }
390176
389841
  const isAborted2 = signal.aborted;