@google/gemini-cli 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.
Files changed (69) hide show
  1. package/bundle/{chunk-M4DUGOFW.js → chunk-2DHAEQE2.js} +90 -467
  2. package/bundle/{chunk-4JZM4J6T.js → chunk-2XM6DOWE.js} +2 -2
  3. package/bundle/{chunk-COHD3EAC.js → chunk-3VMO3WD7.js} +1 -1
  4. package/bundle/{chunk-TFNEL7HO.js → chunk-4GWDIIAP.js} +3 -3
  5. package/bundle/{chunk-LUG3MZLD.js → chunk-6DKHPDQ5.js} +1 -1
  6. package/bundle/{chunk-TYD74VXO.js → chunk-72GZSNV7.js} +14774 -8191
  7. package/bundle/{chunk-HBDPUOQW.js → chunk-7ETVC4KO.js} +1 -1
  8. package/bundle/{chunk-YIGDOMHJ.js → chunk-DML6Y2ZP.js} +2 -2
  9. package/bundle/{chunk-UFG6C5KE.js → chunk-DP2XO3WB.js} +1 -1
  10. package/bundle/{chunk-TNMENZTI.js → chunk-E2SRID3J.js} +1 -1
  11. package/bundle/{chunk-YZ6TLILF.js → chunk-F6RVU2CO.js} +1 -1
  12. package/bundle/{chunk-RETG7Z2C.js → chunk-GCL7X4WZ.js} +2 -2
  13. package/bundle/{chunk-QE6SEL5N.js → chunk-I47WLEEQ.js} +11 -45
  14. package/bundle/{chunk-AKMRRSMV.js → chunk-KCP45VUB.js} +1 -1
  15. package/bundle/{chunk-OF7DGARD.js → chunk-L5NOFB6M.js} +1 -1
  16. package/bundle/{chunk-H3SOW6BD.js → chunk-MLY4WQFO.js} +90 -421
  17. package/bundle/{chunk-MMWXIMUF.js → chunk-MNVEFU25.js} +3 -3
  18. package/bundle/{chunk-TKA3MSVK.js → chunk-OXDVMGJ3.js} +3 -3
  19. package/bundle/{chunk-GN6LRBHR.js → chunk-RWN52KQV.js} +5 -8
  20. package/bundle/{chunk-M5SV3LCW.js → chunk-T4GE6V5B.js} +8 -9
  21. package/bundle/{chunk-NZIIZAV3.js → chunk-TYBBTU4O.js} +1 -1
  22. package/bundle/{chunk-DOFIJ3YI.js → chunk-V43EQ7B6.js} +11 -45
  23. package/bundle/{chunk-R2TEKWUG.js → chunk-YOPBONYF.js} +1 -1
  24. package/bundle/{chunk-A3VAHJM3.js → chunk-ZRKGL4ZL.js} +62 -109
  25. package/bundle/{cleanup-HE7KYQAJ.js → cleanup-B2NP6ZJB.js} +2 -2
  26. package/bundle/{cleanup-INM5W2O2.js → cleanup-GJFEQLCV.js} +2 -2
  27. package/bundle/{cleanup-XSZILZES.js → cleanup-NYOWMRTL.js} +2 -2
  28. package/bundle/{core-PLITVDXB.js → core-4NPF436I.js} +1 -7
  29. package/bundle/{dist-5EPN333M.js → core-BXNHRQQE.js} +1 -7
  30. package/bundle/{devtoolsService-BUSRWWOS.js → devtoolsService-2TDRPBCW.js} +2 -2
  31. package/bundle/{devtoolsService-4D2QFII3.js → devtoolsService-47DUPCKM.js} +2 -2
  32. package/bundle/{devtoolsService-P7HLE6U4.js → devtoolsService-BIYZH2ME.js} +3 -4
  33. package/bundle/{dist-EBAUDX6K.js → dist-6S53KFXU.js} +1 -7
  34. package/bundle/docs/changelogs/index.md +0 -16
  35. package/bundle/docs/changelogs/latest.md +55 -34
  36. package/bundle/docs/changelogs/preview.md +3 -7
  37. package/bundle/{gemini-LJOD63ZZ.js → gemini-CGCV5XPN.js} +14 -14
  38. package/bundle/{gemini-E77OMSLO.js → gemini-J6X2T2ZI.js} +14 -14
  39. package/bundle/{gemini-III4I2TY.js → gemini-ZBM332DO.js} +198 -214
  40. package/bundle/gemini.js +7 -7
  41. package/bundle/{interactiveCli-GCRH54ZM.js → interactiveCli-HUDGOV74.js} +14 -31
  42. package/bundle/{interactiveCli-BJCS4WF5.js → interactiveCli-IDDEAOD5.js} +14 -31
  43. package/bundle/{interactiveCli-A3LNKRJV.js → interactiveCli-R4EMLFLM.js} +298 -334
  44. package/bundle/{liteRtServerManager-34QJA5UR.js → liteRtServerManager-A4B5FMXL.js} +4 -4
  45. package/bundle/{liteRtServerManager-PJMI7L5V.js → liteRtServerManager-QE27SHMQ.js} +4 -4
  46. package/bundle/{liteRtServerManager-TPFCEVH7.js → liteRtServerManager-WXCXUPDQ.js} +4 -4
  47. package/bundle/{oauth2-provider-HIFZ2YSU.js → oauth2-provider-3F6FOWLR.js} +1 -1
  48. package/bundle/{oauth2-provider-4IJXZY2A.js → oauth2-provider-43ANEHLB.js} +1 -1
  49. package/bundle/{oauth2-provider-65ESWRXC.js → oauth2-provider-MWRLM45J.js} +72 -38
  50. package/bundle/{start-6ET4IGUD.js → start-SQ2SPNQL.js} +6 -6
  51. package/bundle/{start-HKFTMESR.js → start-W7O4IWQ7.js} +6 -6
  52. package/bundle/{start-IYXWZL5M.js → start-ZMLXZ4VX.js} +6 -6
  53. package/package.json +1 -1
  54. package/bundle/chunk-BZNLCS4I.js +0 -398
  55. package/bundle/chunk-FW6KQPO4.js +0 -102951
  56. package/bundle/chunk-HM4SUAV7.js +0 -17368
  57. package/bundle/chunk-QPGOBA6C.js +0 -118
  58. package/bundle/chunk-X4QSELXY.js +0 -400361
  59. package/bundle/chunk-X63LZNK3.js +0 -1571
  60. package/bundle/chunk-YNCGLYYB.js +0 -154
  61. package/bundle/chunk-YUTWSGVZ.js +0 -512
  62. package/bundle/cleanup-ZZ2TESXC.js +0 -32
  63. package/bundle/devtoolsService-YD7ORPBB.js +0 -4359
  64. package/bundle/dist-SYCD6I6K.js +0 -2244
  65. package/bundle/gemini-46IOIZQR.js +0 -17863
  66. package/bundle/interactiveCli-XDQJSJNE.js +0 -34907
  67. package/bundle/liteRtServerManager-YPMJZLFF.js +0 -65
  68. package/bundle/oauth2-provider-KTV4RAAH.js +0 -235
  69. package/bundle/start-TIGZXUOM.js +0 -18
@@ -253766,7 +253766,6 @@ var REFERENCE_CONTENT_END = "--- End of content ---";
253766
253766
  var DEFAULT_MAX_LINES_TEXT_FILE = 2e3;
253767
253767
  var MAX_LINE_LENGTH_TEXT_FILE = 2e3;
253768
253768
  var MAX_FILE_SIZE_MB = 20;
253769
- var MAX_STORED_TOOL_OUTPUT_BYTES = 64 * 1024;
253770
253769
  var EMPTY_RESPONSE_COMPRESS_SUGGESTION = "The model returned an empty text response. If your context window is near capacity, try using /compress.";
253771
253770
  var THINKING_ONLY_COMPRESS_SUGGESTION = "The model returned reasoning thoughts but no final response text. If your context window is near capacity, try using /compress.";
253772
253771
  var MAX_TOKENS_EXCEEDED_SUGGESTION = "Model response was truncated because it exceeded the token limit. Try using /compress to free up context space.";
@@ -283718,8 +283717,8 @@ function isValidToolName(name3, options = {}) {
283718
283717
  }
283719
283718
 
283720
283719
  // packages/core/src/generated/git-commit.ts
283721
- var GIT_COMMIT_INFO = "bedef96ef";
283722
- var CLI_VERSION = "0.62.0-nightly.20260918.g9450ade79";
283720
+ var GIT_COMMIT_INFO = "9ac01f80f";
283721
+ var CLI_VERSION = "0.62.0";
283723
283722
 
283724
283723
  // packages/core/src/ide/detect-ide.ts
283725
283724
  var IDE_DEFINITIONS = {
@@ -307339,7 +307338,7 @@ function getVersion() {
307339
307338
  }
307340
307339
  versionPromise = (async () => {
307341
307340
  const pkgJson = await getPackageJson(__dirname4);
307342
- return "0.62.0-nightly.20260918.g9450ade79";
307341
+ return "0.62.0";
307343
307342
  })();
307344
307343
  return versionPromise;
307345
307344
  }
@@ -314970,7 +314969,6 @@ function getSafeGitEnv(baseEnv = process.env) {
314970
314969
  }
314971
314970
  return {
314972
314971
  ...cleanedEnv,
314973
- GIT_TERMINAL_PROMPT: "0",
314974
314972
  GIT_CONFIG_GLOBAL: devNullPath,
314975
314973
  GIT_CONFIG_SYSTEM: devNullPath,
314976
314974
  GIT_CONFIG_NOSYSTEM: "1",
@@ -325669,33 +325667,6 @@ ${truncated}`;
325669
325667
  }
325670
325668
  }
325671
325669
  }
325672
- if (child.stdout) {
325673
- child.stdout.removeAllListeners();
325674
- try {
325675
- child.stdout.destroy();
325676
- } catch {
325677
- }
325678
- }
325679
- if (child.stderr) {
325680
- child.stderr.removeAllListeners();
325681
- try {
325682
- child.stderr.destroy();
325683
- } catch {
325684
- }
325685
- }
325686
- const stdin = child.stdin;
325687
- if (stdin) {
325688
- stdin.removeAllListeners();
325689
- try {
325690
- stdin.destroy();
325691
- } catch {
325692
- }
325693
- }
325694
- child.removeAllListeners("error");
325695
- child.removeAllListeners("close");
325696
- state.sniffChunks.length = 0;
325697
- stdoutDecoder = null;
325698
- stderrDecoder = null;
325699
325670
  return;
325700
325671
  };
325701
325672
  var cleanup = cleanup2;
@@ -325850,7 +325821,6 @@ ${truncated}`;
325850
325821
  cleanup2();
325851
325822
  cmdCleanup?.();
325852
325823
  let combinedOutput = state.output;
325853
- state.output = "";
325854
325824
  if (state.truncated) {
325855
325825
  const truncationMessage = `
325856
325826
  [GEMINI_CLI_WARNING: Output truncated. The buffer is limited to ${MAX_CHILD_PROCESS_BUFFER_SIZE / (1024 * 1024)}MB.]`;
@@ -325886,8 +325856,9 @@ ${truncated}`;
325886
325856
  historyItem.endTime = Date.now();
325887
325857
  }
325888
325858
  onOutputEvent(event);
325889
- _ShellExecutionService.activeChildProcesses.delete(pid);
325890
- _ShellExecutionService.cleanupLogStream(pid);
325859
+ _ShellExecutionService.cleanupLogStream(pid).then(() => {
325860
+ _ShellExecutionService.activeChildProcesses.delete(pid);
325861
+ });
325891
325862
  ExecutionLifecycleService.completeWithResult(pid, resultPayload);
325892
325863
  } else {
325893
325864
  resolveWithoutPid?.(resultPayload);
@@ -338522,133 +338493,6 @@ var PreCompressTrigger = /* @__PURE__ */ ((PreCompressTrigger2) => {
338522
338493
 
338523
338494
  // packages/core/src/context/chatCompressionService.ts
338524
338495
  var DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.5;
338525
- var RECENT_TURNS_PROTECTED = 3;
338526
- var RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE = /* @__PURE__ */ new Set([
338527
- "read_file",
338528
- "read_many_files",
338529
- "get_internal_docs",
338530
- "read_mcp_resource",
338531
- "grep",
338532
- "rip_grep",
338533
- "glob",
338534
- "search_file_content",
338535
- "find_files"
338536
- ]);
338537
- function isExemptRetrievalTool(toolName, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
338538
- if (!toolName) {
338539
- return false;
338540
- }
338541
- const normalized2 = toolName.toLowerCase();
338542
- if (exemptTools.has(normalized2)) {
338543
- return true;
338544
- }
338545
- return normalized2.endsWith("read_file") || normalized2.endsWith("read_files") || normalized2.endsWith("read_many_files") || normalized2.endsWith("read_resource");
338546
- }
338547
- var COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES = 2048;
338548
- var defaultGraphemeSegmenter = new Intl.Segmenter(void 0, {
338549
- granularity: "grapheme"
338550
- });
338551
- function collapseOlderFunctionResponses(history, maxBytesPerOldResponse = COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES, segmenter2 = defaultGraphemeSegmenter, protectedTurns = RECENT_TURNS_PROTECTED, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
338552
- const toolIndices = [];
338553
- for (let i3 = 0; i3 < history.length; i3++) {
338554
- if (history[i3].role === "user" && history[i3].parts?.some((p) => !!p.functionResponse)) {
338555
- toolIndices.push(i3);
338556
- }
338557
- }
338558
- if (toolIndices.length <= protectedTurns) {
338559
- return history;
338560
- }
338561
- const cutoffToolIndex = toolIndices[toolIndices.length - protectedTurns];
338562
- const collapseString = (str2) => {
338563
- const totalBytes = Buffer.byteLength(str2, "utf8");
338564
- if (totalBytes <= maxBytesPerOldResponse) {
338565
- return str2;
338566
- }
338567
- const previewBytes = maxBytesPerOldResponse;
338568
- let preview = "";
338569
- let currentBytes = 0;
338570
- for (const { segment } of segmenter2.segment(str2)) {
338571
- const segmentBytes = Buffer.byteLength(segment, "utf8");
338572
- if (currentBytes + segmentBytes > previewBytes) {
338573
- break;
338574
- }
338575
- preview += segment;
338576
- currentBytes += segmentBytes;
338577
- }
338578
- const omittedBytes = totalBytes - currentBytes;
338579
- return `${preview}
338580
- ... [Tool output collapsed from previous turn: ${omittedBytes} bytes omitted to conserve memory] ...`;
338581
- };
338582
- const collapseValue = (val) => {
338583
- if (typeof val === "string") {
338584
- return collapseString(val);
338585
- }
338586
- if (Array.isArray(val)) {
338587
- let arrayModified = false;
338588
- const newVal = val.map((item) => {
338589
- const collapsed = collapseValue(item);
338590
- if (collapsed !== item) {
338591
- arrayModified = true;
338592
- }
338593
- return collapsed;
338594
- });
338595
- return arrayModified ? newVal : val;
338596
- }
338597
- if (typeof val === "object" && val !== null) {
338598
- const proto = Object.getPrototypeOf(val);
338599
- if (proto !== Object.prototype && proto !== null) {
338600
- return val;
338601
- }
338602
- let objModified = false;
338603
- const copy = {};
338604
- for (const [k, v] of Object.entries(val)) {
338605
- const collapsed = collapseValue(v);
338606
- if (collapsed !== v) {
338607
- objModified = true;
338608
- }
338609
- copy[k] = collapsed;
338610
- }
338611
- return objModified ? copy : val;
338612
- }
338613
- return val;
338614
- };
338615
- let modified = false;
338616
- const newHistory = history.map((content, idx) => {
338617
- if (idx >= cutoffToolIndex || content.role !== "user" || !content.parts) {
338618
- return content;
338619
- }
338620
- let partsModified = false;
338621
- const newParts = content.parts.map((part) => {
338622
- if (!part.functionResponse?.response) {
338623
- return part;
338624
- }
338625
- if (isExemptRetrievalTool(part.functionResponse.name, exemptTools)) {
338626
- return part;
338627
- }
338628
- const resp = part.functionResponse.response;
338629
- const newResp = collapseValue(resp);
338630
- if (newResp !== resp) {
338631
- partsModified = true;
338632
- return {
338633
- ...part,
338634
- functionResponse: {
338635
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
338636
- ...part.functionResponse,
338637
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
338638
- response: newResp
338639
- }
338640
- };
338641
- }
338642
- return part;
338643
- });
338644
- if (partsModified) {
338645
- modified = true;
338646
- return { ...content, parts: newParts };
338647
- }
338648
- return content;
338649
- });
338650
- return modified ? newHistory : history;
338651
- }
338652
338496
  var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
338653
338497
  var COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET = 5e4;
338654
338498
  function findCompressSplitPoint(contents, fraction) {
@@ -338786,12 +338630,10 @@ var ChatCompressionService = class {
338786
338630
  }
338787
338631
  const trigger = force ? "manual" /* Manual */ : "auto" /* Auto */;
338788
338632
  await config2.getHookSystem()?.firePreCompressEvent(trigger);
338789
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
338790
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(curatedHistory.flatMap((c4) => c4.parts || []));
338633
+ const originalTokenCount = chat.getLastPromptTokenCount();
338791
338634
  if (!force) {
338792
338635
  const threshold = await config2.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
338793
- const isOverModelThreshold = originalTokenCount >= threshold * tokenLimit(model);
338794
- if (!isOverModelThreshold) {
338636
+ if (originalTokenCount < threshold * tokenLimit(model)) {
338795
338637
  return {
338796
338638
  newHistory: null,
338797
338639
  info: {
@@ -338953,8 +338795,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
338953
338795
  }
338954
338796
  };
338955
338797
  } else {
338956
- historyToCompressTruncated.length = 0;
338957
- originalHistoryToCompress.length = 0;
338958
338798
  return {
338959
338799
  newHistory: extraHistory,
338960
338800
  info: {
@@ -338967,173 +338807,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
338967
338807
  }
338968
338808
  };
338969
338809
 
338970
- // packages/core/src/utils/tool-utils.ts
338971
- var import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
338972
- function isToolCallResponseInfo(data) {
338973
- return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
338974
- }
338975
- function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
338976
- const matches = allToolNames.map((toolName) => ({
338977
- name: toolName,
338978
- distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
338979
- }));
338980
- matches.sort((a2, b) => a2.distance - b.distance);
338981
- const topNResults = matches.slice(0, topN);
338982
- if (topNResults.length === 0) {
338983
- return "";
338984
- }
338985
- const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
338986
- if (topNResults.length > 1) {
338987
- return ` Did you mean one of: ${suggestedNames}?`;
338988
- } else {
338989
- return ` Did you mean ${suggestedNames}?`;
338990
- }
338991
- }
338992
- function doesToolInvocationMatch(toolOrToolName, invocation, patterns) {
338993
- let toolNames;
338994
- if (isTool(toolOrToolName)) {
338995
- toolNames = [toolOrToolName.name, toolOrToolName.constructor.name];
338996
- } else {
338997
- toolNames = [toolOrToolName];
338998
- }
338999
- if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
339000
- toolNames = [.../* @__PURE__ */ new Set([...toolNames, ...SHELL_TOOL_NAMES])];
339001
- }
339002
- for (const pattern of patterns) {
339003
- const openParen = pattern.indexOf("(");
339004
- if (openParen === -1) {
339005
- if (toolNames.includes(pattern)) {
339006
- return true;
339007
- }
339008
- continue;
339009
- }
339010
- const patternToolName = pattern.substring(0, openParen);
339011
- if (!toolNames.includes(patternToolName)) {
339012
- continue;
339013
- }
339014
- if (!pattern.endsWith(")")) {
339015
- continue;
339016
- }
339017
- const argPattern = pattern.substring(openParen + 1, pattern.length - 1);
339018
- let command;
339019
- if (typeof invocation === "string") {
339020
- command = invocation;
339021
- } else {
339022
- if (!("command" in invocation.params)) {
339023
- continue;
339024
- }
339025
- command = String(invocation.params.command);
339026
- }
339027
- if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
339028
- if (command === argPattern || command.startsWith(argPattern + " ")) {
339029
- return true;
339030
- }
339031
- }
339032
- }
339033
- return false;
339034
- }
339035
- var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
339036
- function truncateToolOutput(text, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
339037
- if (Buffer.byteLength(text, "utf8") <= maxBytes) {
339038
- return text;
339039
- }
339040
- const suffix = savedFilePath ? `
339041
- ... [Tool output truncated to conserve memory. For full output see: ${savedFilePath}]` : "\n... [Tool output truncated to conserve memory]";
339042
- const targetBytes = Math.max(0, maxBytes - Buffer.byteLength(suffix, "utf8"));
339043
- let accumulatedBytes = 0;
339044
- let truncatedText = "";
339045
- for (const { segment } of segmenter.segment(text)) {
339046
- const segmentBytes = Buffer.byteLength(segment, "utf8");
339047
- if (accumulatedBytes + segmentBytes > targetBytes) {
339048
- break;
339049
- }
339050
- accumulatedBytes += segmentBytes;
339051
- truncatedText += segment;
339052
- }
339053
- return truncatedText + suffix;
339054
- }
339055
- function truncateFunctionResponsePart(part, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
339056
- if (part.text && Buffer.byteLength(part.text, "utf8") > maxBytes) {
339057
- return {
339058
- ...part,
339059
- text: truncateToolOutput(part.text, maxBytes, savedFilePath)
339060
- };
339061
- }
339062
- if (!part.functionResponse?.response) {
339063
- return part;
339064
- }
339065
- const resp = part.functionResponse.response;
339066
- if (typeof resp === "string") {
339067
- if (Buffer.byteLength(resp, "utf8") > maxBytes) {
339068
- return {
339069
- ...part,
339070
- functionResponse: {
339071
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
339072
- ...part.functionResponse,
339073
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
339074
- response: truncateToolOutput(
339075
- resp,
339076
- maxBytes,
339077
- savedFilePath
339078
- )
339079
- }
339080
- };
339081
- }
339082
- return part;
339083
- }
339084
- if (typeof resp === "object" && resp !== null) {
339085
- const truncateValue = (val) => {
339086
- if (typeof val === "string") {
339087
- if (Buffer.byteLength(val, "utf8") > maxBytes) {
339088
- return truncateToolOutput(val, maxBytes, savedFilePath);
339089
- }
339090
- return val;
339091
- }
339092
- if (Array.isArray(val)) {
339093
- let arrayModified = false;
339094
- const newVal = val.map((item) => {
339095
- const truncated = truncateValue(item);
339096
- if (truncated !== item) {
339097
- arrayModified = true;
339098
- }
339099
- return truncated;
339100
- });
339101
- return arrayModified ? newVal : val;
339102
- }
339103
- if (typeof val === "object" && val !== null) {
339104
- const proto = Object.getPrototypeOf(val);
339105
- if (proto !== Object.prototype && proto !== null) {
339106
- return val;
339107
- }
339108
- let objModified = false;
339109
- const copy = {};
339110
- for (const [k, v] of Object.entries(val)) {
339111
- const truncated = truncateValue(v);
339112
- if (truncated !== v) {
339113
- objModified = true;
339114
- }
339115
- copy[k] = truncated;
339116
- }
339117
- return objModified ? copy : val;
339118
- }
339119
- return val;
339120
- };
339121
- const newResp = truncateValue(resp);
339122
- if (newResp !== resp) {
339123
- return {
339124
- ...part,
339125
- functionResponse: {
339126
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
339127
- ...part.functionResponse,
339128
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
339129
- response: newResp
339130
- }
339131
- };
339132
- }
339133
- }
339134
- return part;
339135
- }
339136
-
339137
338810
  // packages/core/src/agents/types.ts
339138
338811
  var AgentTerminateMode = /* @__PURE__ */ ((AgentTerminateMode2) => {
339139
338812
  AgentTerminateMode2["ERROR"] = "ERROR";
@@ -343696,7 +343369,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
343696
343369
  return provider;
343697
343370
  }
343698
343371
  case "oauth2": {
343699
- const { OAuth2AuthProvider } = await import("./oauth2-provider-HIFZ2YSU.js");
343372
+ const { OAuth2AuthProvider } = await import("./oauth2-provider-MWRLM45J.js");
343700
343373
  const provider = new OAuth2AuthProvider(
343701
343374
  authConfig,
343702
343375
  options.agentName ?? "unknown",
@@ -344943,6 +344616,72 @@ function getToolCallContext() {
344943
344616
  return toolCallContext.getStore();
344944
344617
  }
344945
344618
 
344619
+ // packages/core/src/utils/tool-utils.ts
344620
+ var import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
344621
+ function isToolCallResponseInfo(data) {
344622
+ return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
344623
+ }
344624
+ function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
344625
+ const matches = allToolNames.map((toolName) => ({
344626
+ name: toolName,
344627
+ distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
344628
+ }));
344629
+ matches.sort((a2, b) => a2.distance - b.distance);
344630
+ const topNResults = matches.slice(0, topN);
344631
+ if (topNResults.length === 0) {
344632
+ return "";
344633
+ }
344634
+ const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
344635
+ if (topNResults.length > 1) {
344636
+ return ` Did you mean one of: ${suggestedNames}?`;
344637
+ } else {
344638
+ return ` Did you mean ${suggestedNames}?`;
344639
+ }
344640
+ }
344641
+ function doesToolInvocationMatch(toolOrToolName, invocation, patterns) {
344642
+ let toolNames;
344643
+ if (isTool(toolOrToolName)) {
344644
+ toolNames = [toolOrToolName.name, toolOrToolName.constructor.name];
344645
+ } else {
344646
+ toolNames = [toolOrToolName];
344647
+ }
344648
+ if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
344649
+ toolNames = [.../* @__PURE__ */ new Set([...toolNames, ...SHELL_TOOL_NAMES])];
344650
+ }
344651
+ for (const pattern of patterns) {
344652
+ const openParen = pattern.indexOf("(");
344653
+ if (openParen === -1) {
344654
+ if (toolNames.includes(pattern)) {
344655
+ return true;
344656
+ }
344657
+ continue;
344658
+ }
344659
+ const patternToolName = pattern.substring(0, openParen);
344660
+ if (!toolNames.includes(patternToolName)) {
344661
+ continue;
344662
+ }
344663
+ if (!pattern.endsWith(")")) {
344664
+ continue;
344665
+ }
344666
+ const argPattern = pattern.substring(openParen + 1, pattern.length - 1);
344667
+ let command;
344668
+ if (typeof invocation === "string") {
344669
+ command = invocation;
344670
+ } else {
344671
+ if (!("command" in invocation.params)) {
344672
+ continue;
344673
+ }
344674
+ command = String(invocation.params.command);
344675
+ }
344676
+ if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
344677
+ if (command === argPattern || command.startsWith(argPattern + " ")) {
344678
+ return true;
344679
+ }
344680
+ }
344681
+ }
344682
+ return false;
344683
+ }
344684
+
344946
344685
  // packages/core/src/scheduler/state-manager.ts
344947
344686
  var SchedulerStateManager = class {
344948
344687
  constructor(messageBus, schedulerId = ROOT_SCHEDULER_ID, onTerminalCall) {
@@ -351572,7 +351311,7 @@ var ToolExecutor = class {
351572
351311
  this.context.promptId
351573
351312
  );
351574
351313
  outputFile = savedPath;
351575
- let truncatedContent = formatTruncatedToolOutput(
351314
+ const truncatedContent = formatTruncatedToolOutput(
351576
351315
  content,
351577
351316
  outputFile,
351578
351317
  threshold
@@ -351586,12 +351325,6 @@ var ToolExecutor = class {
351586
351325
  threshold
351587
351326
  })
351588
351327
  );
351589
- if (typeof truncatedContent === "string" && Buffer.byteLength(truncatedContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351590
- truncatedContent = truncateToolOutput(
351591
- truncatedContent,
351592
- MAX_STORED_TOOL_OUTPUT_BYTES
351593
- );
351594
- }
351595
351328
  return { truncatedContent, outputFile };
351596
351329
  }
351597
351330
  } else if (Array.isArray(content) && content.length === 1 && "tool" in call && call.tool instanceof DiscoveredMCPTool) {
@@ -351609,17 +351342,11 @@ var ToolExecutor = class {
351609
351342
  this.context.promptId
351610
351343
  );
351611
351344
  outputFile = savedPath;
351612
- let truncatedText = formatTruncatedToolOutput(
351345
+ const truncatedText = formatTruncatedToolOutput(
351613
351346
  textContent2,
351614
351347
  outputFile,
351615
351348
  threshold
351616
351349
  );
351617
- if (typeof truncatedText === "string" && Buffer.byteLength(truncatedText, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351618
- truncatedText = truncateToolOutput(
351619
- truncatedText,
351620
- MAX_STORED_TOOL_OUTPUT_BYTES
351621
- );
351622
- }
351623
351350
  const truncatedContent = [
351624
351351
  { ...firstPart, text: truncatedText }
351625
351352
  ];
@@ -351636,69 +351363,7 @@ var ToolExecutor = class {
351636
351363
  }
351637
351364
  }
351638
351365
  }
351639
- const ensureOutputFile = async (rawText) => {
351640
- if (!outputFile) {
351641
- try {
351642
- const { outputFile: savedPath } = await saveTruncatedToolOutput(
351643
- rawText,
351644
- toolName,
351645
- callId,
351646
- this.config.storage.getProjectTempDir(),
351647
- this.context.promptId
351648
- );
351649
- outputFile = savedPath;
351650
- } catch {
351651
- }
351652
- }
351653
- return outputFile;
351654
- };
351655
- let finalContent = content;
351656
- if (typeof finalContent === "string") {
351657
- if (Buffer.byteLength(finalContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351658
- const savedPath = await ensureOutputFile(finalContent);
351659
- finalContent = truncateToolOutput(
351660
- finalContent,
351661
- MAX_STORED_TOOL_OUTPUT_BYTES,
351662
- savedPath
351663
- );
351664
- }
351665
- } else if (Array.isArray(finalContent)) {
351666
- finalContent = await Promise.all(
351667
- finalContent.map(async (part) => {
351668
- if (typeof part === "string" && Buffer.byteLength(part, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351669
- const savedPath = await ensureOutputFile(part);
351670
- return truncateToolOutput(
351671
- part,
351672
- MAX_STORED_TOOL_OUTPUT_BYTES,
351673
- savedPath
351674
- );
351675
- }
351676
- if (typeof part === "object" && part !== null && "text" in part && typeof part.text === "string" && Buffer.byteLength(part.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351677
- const savedPath = await ensureOutputFile(part.text);
351678
- return {
351679
- ...part,
351680
- text: truncateToolOutput(
351681
- part.text,
351682
- MAX_STORED_TOOL_OUTPUT_BYTES,
351683
- savedPath
351684
- )
351685
- };
351686
- }
351687
- return part;
351688
- })
351689
- );
351690
- } else if (typeof finalContent === "object" && finalContent !== null && "text" in finalContent && typeof finalContent.text === "string" && Buffer.byteLength(finalContent.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
351691
- const savedPath = await ensureOutputFile(finalContent.text);
351692
- finalContent = {
351693
- ...finalContent,
351694
- text: truncateToolOutput(
351695
- finalContent.text,
351696
- MAX_STORED_TOOL_OUTPUT_BYTES,
351697
- savedPath
351698
- )
351699
- };
351700
- }
351701
- return { truncatedContent: finalContent, outputFile };
351366
+ return { truncatedContent: content, outputFile };
351702
351367
  }
351703
351368
  async createCancelledResult(call, reason, toolResult) {
351704
351369
  const errorMessage = `[Operation Cancelled] ${reason}`;
@@ -352695,14 +352360,14 @@ function normalizeSpace(text) {
352695
352360
  return text.replace(/\s+/g, " ").trim();
352696
352361
  }
352697
352362
  function safeSlice(text, start2, end) {
352698
- const segmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
352699
- const segments = Array.from(segmenter2.segment(text));
352363
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
352364
+ const segments = Array.from(segmenter.segment(text));
352700
352365
  return segments.slice(start2, end).map((s2) => s2.segment).join("");
352701
352366
  }
352702
352367
  function safeLength(text) {
352703
- const segmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
352368
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
352704
352369
  let count2 = 0;
352705
- for (const _ of segmenter2.segment(text)) {
352370
+ for (const _ of segmenter.segment(text)) {
352706
352371
  count2++;
352707
352372
  }
352708
352373
  return count2;
@@ -353951,22 +353616,6 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
353951
353616
  }
353952
353617
  async tryCompressChat(chat, prompt_id, abortSignal) {
353953
353618
  const model = this.definition.modelConfig.model ?? DEFAULT_GEMINI_MODEL;
353954
- const threshold = await this.context.config.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
353955
- const modelLimit = tokenLimit(model);
353956
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
353957
- const currentHistory = chat.getHistory(false);
353958
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(currentHistory.flatMap((c4) => c4.parts || []));
353959
- if (originalTokenCount >= threshold * modelLimit) {
353960
- const collapsedHistory = collapseOlderFunctionResponses(currentHistory);
353961
- if (collapsedHistory !== currentHistory) {
353962
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
353963
- const turns = collapsedHistory.map((c4, idx) => ({
353964
- id: existingTurns[idx]?.id ?? randomUUID13(),
353965
- content: c4
353966
- }));
353967
- chat.setHistory(turns);
353968
- }
353969
- }
353970
353619
  const { newHistory, info: info2 } = await this.compressionService.compress(
353971
353620
  chat,
353972
353621
  prompt_id,
@@ -353980,9 +353629,8 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
353980
353629
  this.hasFailedCompressionAttempt = true;
353981
353630
  } else if (info2.compressionStatus === 1 /* COMPRESSED */) {
353982
353631
  if (newHistory) {
353983
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
353984
- const turns = newHistory.map((c4, idx) => ({
353985
- id: existingTurns[idx]?.id ?? randomUUID13(),
353632
+ const turns = newHistory.map((c4) => ({
353633
+ id: randomUUID13(),
353986
353634
  content: c4
353987
353635
  }));
353988
353636
  chat.setHistory(turns);
@@ -353990,9 +353638,8 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
353990
353638
  }
353991
353639
  } else if (info2.compressionStatus === 6 /* CONTENT_TRUNCATED */) {
353992
353640
  if (newHistory) {
353993
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
353994
- const turns = newHistory.map((c4, idx) => ({
353995
- id: existingTurns[idx]?.id ?? randomUUID13(),
353641
+ const turns = newHistory.map((c4) => ({
353642
+ id: randomUUID13(),
353996
353643
  content: c4
353997
353644
  }));
353998
353645
  chat.setHistory(turns);
@@ -354203,25 +353850,6 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
354203
353850
  onWaitingForConfirmation
354204
353851
  }
354205
353852
  );
354206
- for (const call of completedCalls) {
354207
- const outputFile = call.response?.outputFile;
354208
- if (call.response?.responseParts) {
354209
- call.response.responseParts = call.response.responseParts.map(
354210
- (p) => truncateFunctionResponsePart(
354211
- p,
354212
- MAX_STORED_TOOL_OUTPUT_BYTES,
354213
- outputFile
354214
- )
354215
- );
354216
- }
354217
- if (typeof call.response?.resultDisplay === "string" && Buffer.byteLength(call.response.resultDisplay, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
354218
- call.response.resultDisplay = truncateToolOutput(
354219
- call.response.resultDisplay,
354220
- MAX_STORED_TOOL_OUTPUT_BYTES,
354221
- outputFile
354222
- );
354223
- }
354224
- }
354225
353853
  chat.recordCompletedToolCalls(model, completedCalls);
354226
353854
  for (const call of completedCalls) {
354227
353855
  const toolName = toolNameMap.get(call.request.callId) || call.request.name;
@@ -354287,9 +353915,7 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
354287
353915
  const callId = functionCall.id ?? `${promptId}-${index}`;
354288
353916
  const part = syncResults.get(callId);
354289
353917
  if (part) {
354290
- toolResponseParts.push(
354291
- truncateFunctionResponsePart(part, MAX_STORED_TOOL_OUTPUT_BYTES)
354292
- );
353918
+ toolResponseParts.push(part);
354293
353919
  continue;
354294
353920
  }
354295
353921
  const isAborted2 = signal.aborted;
@@ -405610,7 +405236,6 @@ export {
405610
405236
  DEFAULT_MAX_LINES_TEXT_FILE,
405611
405237
  MAX_LINE_LENGTH_TEXT_FILE,
405612
405238
  MAX_FILE_SIZE_MB,
405613
- MAX_STORED_TOOL_OUTPUT_BYTES,
405614
405239
  EMPTY_RESPONSE_COMPRESS_SUGGESTION,
405615
405240
  THINKING_ONLY_COMPRESS_SUGGESTION,
405616
405241
  MAX_TOKENS_EXCEEDED_SUGGESTION,
@@ -406384,11 +406009,6 @@ export {
406384
406009
  SessionStartSource,
406385
406010
  SessionEndReason,
406386
406011
  PreCompressTrigger,
406387
- isToolCallResponseInfo,
406388
- getToolSuggestion,
406389
- doesToolInvocationMatch,
406390
- truncateToolOutput,
406391
- truncateFunctionResponsePart,
406392
406012
  AgentTerminateMode,
406393
406013
  DEFAULT_QUERY_STRING,
406394
406014
  DEFAULT_MAX_TURNS,
@@ -406423,6 +406043,9 @@ export {
406423
406043
  exchangeCodeForToken,
406424
406044
  refreshAccessToken,
406425
406045
  ModelConfigService,
406046
+ isToolCallResponseInfo,
406047
+ getToolSuggestion,
406048
+ doesToolInvocationMatch,
406426
406049
  getPolicyDenialError,
406427
406050
  checkPolicy,
406428
406051
  updatePolicy,