@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
@@ -253700,7 +253700,6 @@ var REFERENCE_CONTENT_END = "--- End of content ---";
253700
253700
  var DEFAULT_MAX_LINES_TEXT_FILE = 2e3;
253701
253701
  var MAX_LINE_LENGTH_TEXT_FILE = 2e3;
253702
253702
  var MAX_FILE_SIZE_MB = 20;
253703
- var MAX_STORED_TOOL_OUTPUT_BYTES = 64 * 1024;
253704
253703
  var EMPTY_RESPONSE_COMPRESS_SUGGESTION = "The model returned an empty text response. If your context window is near capacity, try using /compress.";
253705
253704
  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.";
253706
253705
  var MAX_TOKENS_EXCEEDED_SUGGESTION = "Model response was truncated because it exceeded the token limit. Try using /compress to free up context space.";
@@ -283413,8 +283412,8 @@ function isValidToolName(name3, options = {}) {
283413
283412
  }
283414
283413
 
283415
283414
  // packages/core/dist/src/generated/git-commit.js
283416
- var GIT_COMMIT_INFO = "bedef96ef";
283417
- var CLI_VERSION = "0.62.0-nightly.20260918.g9450ade79";
283415
+ var GIT_COMMIT_INFO = "9ac01f80f";
283416
+ var CLI_VERSION = "0.62.0";
283418
283417
 
283419
283418
  // packages/core/dist/src/ide/detect-ide.js
283420
283419
  var IDE_DEFINITIONS = {
@@ -306708,7 +306707,7 @@ function getVersion() {
306708
306707
  }
306709
306708
  versionPromise = (async () => {
306710
306709
  const pkgJson = await getPackageJson(__dirname4);
306711
- return "0.62.0-nightly.20260925.gbedef96ef";
306710
+ return "0.62.0";
306712
306711
  })();
306713
306712
  return versionPromise;
306714
306713
  }
@@ -313294,7 +313293,6 @@ function getSafeGitEnv(baseEnv = process.env) {
313294
313293
  }
313295
313294
  return {
313296
313295
  ...cleanedEnv,
313297
- GIT_TERMINAL_PROMPT: "0",
313298
313296
  GIT_CONFIG_GLOBAL: devNullPath,
313299
313297
  GIT_CONFIG_SYSTEM: devNullPath,
313300
313298
  GIT_CONFIG_NOSYSTEM: "1",
@@ -323655,33 +323653,6 @@ ${truncated}`;
323655
323653
  }
323656
323654
  }
323657
323655
  }
323658
- if (child.stdout) {
323659
- child.stdout.removeAllListeners();
323660
- try {
323661
- child.stdout.destroy();
323662
- } catch {
323663
- }
323664
- }
323665
- if (child.stderr) {
323666
- child.stderr.removeAllListeners();
323667
- try {
323668
- child.stderr.destroy();
323669
- } catch {
323670
- }
323671
- }
323672
- const stdin = child.stdin;
323673
- if (stdin) {
323674
- stdin.removeAllListeners();
323675
- try {
323676
- stdin.destroy();
323677
- } catch {
323678
- }
323679
- }
323680
- child.removeAllListeners("error");
323681
- child.removeAllListeners("close");
323682
- state.sniffChunks.length = 0;
323683
- stdoutDecoder = null;
323684
- stderrDecoder = null;
323685
323656
  return;
323686
323657
  };
323687
323658
  var cleanup = cleanup2;
@@ -323813,7 +323784,6 @@ ${truncated}`;
323813
323784
  cleanup2();
323814
323785
  cmdCleanup?.();
323815
323786
  let combinedOutput = state.output;
323816
- state.output = "";
323817
323787
  if (state.truncated) {
323818
323788
  const truncationMessage = `
323819
323789
  [GEMINI_CLI_WARNING: Output truncated. The buffer is limited to ${MAX_CHILD_PROCESS_BUFFER_SIZE / (1024 * 1024)}MB.]`;
@@ -323849,8 +323819,9 @@ ${truncated}`;
323849
323819
  historyItem.endTime = Date.now();
323850
323820
  }
323851
323821
  onOutputEvent(event);
323852
- _ShellExecutionService.activeChildProcesses.delete(pid);
323853
- _ShellExecutionService.cleanupLogStream(pid);
323822
+ _ShellExecutionService.cleanupLogStream(pid).then(() => {
323823
+ _ShellExecutionService.activeChildProcesses.delete(pid);
323824
+ });
323854
323825
  ExecutionLifecycleService.completeWithResult(pid, resultPayload);
323855
323826
  } else {
323856
323827
  resolveWithoutPid?.(resultPayload);
@@ -335912,133 +335883,6 @@ var PreCompressTrigger;
335912
335883
 
335913
335884
  // packages/core/dist/src/context/chatCompressionService.js
335914
335885
  var DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.5;
335915
- var RECENT_TURNS_PROTECTED = 3;
335916
- var RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE = /* @__PURE__ */ new Set([
335917
- "read_file",
335918
- "read_many_files",
335919
- "get_internal_docs",
335920
- "read_mcp_resource",
335921
- "grep",
335922
- "rip_grep",
335923
- "glob",
335924
- "search_file_content",
335925
- "find_files"
335926
- ]);
335927
- function isExemptRetrievalTool(toolName, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
335928
- if (!toolName) {
335929
- return false;
335930
- }
335931
- const normalized2 = toolName.toLowerCase();
335932
- if (exemptTools.has(normalized2)) {
335933
- return true;
335934
- }
335935
- return normalized2.endsWith("read_file") || normalized2.endsWith("read_files") || normalized2.endsWith("read_many_files") || normalized2.endsWith("read_resource");
335936
- }
335937
- var COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES = 2048;
335938
- var defaultGraphemeSegmenter = new Intl.Segmenter(void 0, {
335939
- granularity: "grapheme"
335940
- });
335941
- function collapseOlderFunctionResponses(history, maxBytesPerOldResponse = COLLAPSED_FUNCTION_RESPONSE_MAX_BYTES, segmenter2 = defaultGraphemeSegmenter, protectedTurns = RECENT_TURNS_PROTECTED, exemptTools = RETRIEVAL_TOOL_NAMES_EXEMPT_FROM_COLLAPSE) {
335942
- const toolIndices = [];
335943
- for (let i3 = 0; i3 < history.length; i3++) {
335944
- if (history[i3].role === "user" && history[i3].parts?.some((p) => !!p.functionResponse)) {
335945
- toolIndices.push(i3);
335946
- }
335947
- }
335948
- if (toolIndices.length <= protectedTurns) {
335949
- return history;
335950
- }
335951
- const cutoffToolIndex = toolIndices[toolIndices.length - protectedTurns];
335952
- const collapseString = (str2) => {
335953
- const totalBytes = Buffer.byteLength(str2, "utf8");
335954
- if (totalBytes <= maxBytesPerOldResponse) {
335955
- return str2;
335956
- }
335957
- const previewBytes = maxBytesPerOldResponse;
335958
- let preview = "";
335959
- let currentBytes = 0;
335960
- for (const { segment } of segmenter2.segment(str2)) {
335961
- const segmentBytes = Buffer.byteLength(segment, "utf8");
335962
- if (currentBytes + segmentBytes > previewBytes) {
335963
- break;
335964
- }
335965
- preview += segment;
335966
- currentBytes += segmentBytes;
335967
- }
335968
- const omittedBytes = totalBytes - currentBytes;
335969
- return `${preview}
335970
- ... [Tool output collapsed from previous turn: ${omittedBytes} bytes omitted to conserve memory] ...`;
335971
- };
335972
- const collapseValue = (val) => {
335973
- if (typeof val === "string") {
335974
- return collapseString(val);
335975
- }
335976
- if (Array.isArray(val)) {
335977
- let arrayModified = false;
335978
- const newVal = val.map((item) => {
335979
- const collapsed = collapseValue(item);
335980
- if (collapsed !== item) {
335981
- arrayModified = true;
335982
- }
335983
- return collapsed;
335984
- });
335985
- return arrayModified ? newVal : val;
335986
- }
335987
- if (typeof val === "object" && val !== null) {
335988
- const proto = Object.getPrototypeOf(val);
335989
- if (proto !== Object.prototype && proto !== null) {
335990
- return val;
335991
- }
335992
- let objModified = false;
335993
- const copy = {};
335994
- for (const [k, v] of Object.entries(val)) {
335995
- const collapsed = collapseValue(v);
335996
- if (collapsed !== v) {
335997
- objModified = true;
335998
- }
335999
- copy[k] = collapsed;
336000
- }
336001
- return objModified ? copy : val;
336002
- }
336003
- return val;
336004
- };
336005
- let modified = false;
336006
- const newHistory = history.map((content, idx) => {
336007
- if (idx >= cutoffToolIndex || content.role !== "user" || !content.parts) {
336008
- return content;
336009
- }
336010
- let partsModified = false;
336011
- const newParts = content.parts.map((part) => {
336012
- if (!part.functionResponse?.response) {
336013
- return part;
336014
- }
336015
- if (isExemptRetrievalTool(part.functionResponse.name, exemptTools)) {
336016
- return part;
336017
- }
336018
- const resp = part.functionResponse.response;
336019
- const newResp = collapseValue(resp);
336020
- if (newResp !== resp) {
336021
- partsModified = true;
336022
- return {
336023
- ...part,
336024
- functionResponse: {
336025
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
336026
- ...part.functionResponse,
336027
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
336028
- response: newResp
336029
- }
336030
- };
336031
- }
336032
- return part;
336033
- });
336034
- if (partsModified) {
336035
- modified = true;
336036
- return { ...content, parts: newParts };
336037
- }
336038
- return content;
336039
- });
336040
- return modified ? newHistory : history;
336041
- }
336042
335886
  var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
336043
335887
  var COMPRESSION_FUNCTION_RESPONSE_TOKEN_BUDGET = 5e4;
336044
335888
  function findCompressSplitPoint(contents, fraction) {
@@ -336167,12 +336011,10 @@ var ChatCompressionService = class {
336167
336011
  }
336168
336012
  const trigger = force ? PreCompressTrigger.Manual : PreCompressTrigger.Auto;
336169
336013
  await config2.getHookSystem()?.firePreCompressEvent(trigger);
336170
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
336171
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(curatedHistory.flatMap((c4) => c4.parts || []));
336014
+ const originalTokenCount = chat.getLastPromptTokenCount();
336172
336015
  if (!force) {
336173
336016
  const threshold = await config2.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
336174
- const isOverModelThreshold = originalTokenCount >= threshold * tokenLimit(model);
336175
- if (!isOverModelThreshold) {
336017
+ if (originalTokenCount < threshold * tokenLimit(model)) {
336176
336018
  return {
336177
336019
  newHistory: null,
336178
336020
  info: {
@@ -336310,8 +336152,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
336310
336152
  }
336311
336153
  };
336312
336154
  } else {
336313
- historyToCompressTruncated.length = 0;
336314
- originalHistoryToCompress.length = 0;
336315
336155
  return {
336316
336156
  newHistory: extraHistory,
336317
336157
  info: {
@@ -336324,169 +336164,6 @@ First, reason in your scratchpad. Then, generate the updated <state_snapshot>.`
336324
336164
  }
336325
336165
  };
336326
336166
 
336327
- // packages/core/dist/src/utils/tool-utils.js
336328
- var import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
336329
- function isToolCallResponseInfo(data) {
336330
- return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
336331
- }
336332
- function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
336333
- const matches = allToolNames.map((toolName) => ({
336334
- name: toolName,
336335
- distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
336336
- }));
336337
- matches.sort((a2, b) => a2.distance - b.distance);
336338
- const topNResults = matches.slice(0, topN);
336339
- if (topNResults.length === 0) {
336340
- return "";
336341
- }
336342
- const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
336343
- if (topNResults.length > 1) {
336344
- return ` Did you mean one of: ${suggestedNames}?`;
336345
- } else {
336346
- return ` Did you mean ${suggestedNames}?`;
336347
- }
336348
- }
336349
- function doesToolInvocationMatch(toolOrToolName, invocation, patterns) {
336350
- let toolNames;
336351
- if (isTool(toolOrToolName)) {
336352
- toolNames = [toolOrToolName.name, toolOrToolName.constructor.name];
336353
- } else {
336354
- toolNames = [toolOrToolName];
336355
- }
336356
- if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
336357
- toolNames = [.../* @__PURE__ */ new Set([...toolNames, ...SHELL_TOOL_NAMES])];
336358
- }
336359
- for (const pattern of patterns) {
336360
- const openParen = pattern.indexOf("(");
336361
- if (openParen === -1) {
336362
- if (toolNames.includes(pattern)) {
336363
- return true;
336364
- }
336365
- continue;
336366
- }
336367
- const patternToolName = pattern.substring(0, openParen);
336368
- if (!toolNames.includes(patternToolName)) {
336369
- continue;
336370
- }
336371
- if (!pattern.endsWith(")")) {
336372
- continue;
336373
- }
336374
- const argPattern = pattern.substring(openParen + 1, pattern.length - 1);
336375
- let command;
336376
- if (typeof invocation === "string") {
336377
- command = invocation;
336378
- } else {
336379
- if (!("command" in invocation.params)) {
336380
- continue;
336381
- }
336382
- command = String(invocation.params.command);
336383
- }
336384
- if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
336385
- if (command === argPattern || command.startsWith(argPattern + " ")) {
336386
- return true;
336387
- }
336388
- }
336389
- }
336390
- return false;
336391
- }
336392
- var segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
336393
- function truncateToolOutput(text, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
336394
- if (Buffer.byteLength(text, "utf8") <= maxBytes) {
336395
- return text;
336396
- }
336397
- const suffix = savedFilePath ? `
336398
- ... [Tool output truncated to conserve memory. For full output see: ${savedFilePath}]` : "\n... [Tool output truncated to conserve memory]";
336399
- const targetBytes = Math.max(0, maxBytes - Buffer.byteLength(suffix, "utf8"));
336400
- let accumulatedBytes = 0;
336401
- let truncatedText = "";
336402
- for (const { segment } of segmenter.segment(text)) {
336403
- const segmentBytes = Buffer.byteLength(segment, "utf8");
336404
- if (accumulatedBytes + segmentBytes > targetBytes) {
336405
- break;
336406
- }
336407
- accumulatedBytes += segmentBytes;
336408
- truncatedText += segment;
336409
- }
336410
- return truncatedText + suffix;
336411
- }
336412
- function truncateFunctionResponsePart(part, maxBytes = MAX_STORED_TOOL_OUTPUT_BYTES, savedFilePath) {
336413
- if (part.text && Buffer.byteLength(part.text, "utf8") > maxBytes) {
336414
- return {
336415
- ...part,
336416
- text: truncateToolOutput(part.text, maxBytes, savedFilePath)
336417
- };
336418
- }
336419
- if (!part.functionResponse?.response) {
336420
- return part;
336421
- }
336422
- const resp = part.functionResponse.response;
336423
- if (typeof resp === "string") {
336424
- if (Buffer.byteLength(resp, "utf8") > maxBytes) {
336425
- return {
336426
- ...part,
336427
- functionResponse: {
336428
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
336429
- ...part.functionResponse,
336430
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
336431
- response: truncateToolOutput(resp, maxBytes, savedFilePath)
336432
- }
336433
- };
336434
- }
336435
- return part;
336436
- }
336437
- if (typeof resp === "object" && resp !== null) {
336438
- const truncateValue = (val) => {
336439
- if (typeof val === "string") {
336440
- if (Buffer.byteLength(val, "utf8") > maxBytes) {
336441
- return truncateToolOutput(val, maxBytes, savedFilePath);
336442
- }
336443
- return val;
336444
- }
336445
- if (Array.isArray(val)) {
336446
- let arrayModified = false;
336447
- const newVal = val.map((item) => {
336448
- const truncated = truncateValue(item);
336449
- if (truncated !== item) {
336450
- arrayModified = true;
336451
- }
336452
- return truncated;
336453
- });
336454
- return arrayModified ? newVal : val;
336455
- }
336456
- if (typeof val === "object" && val !== null) {
336457
- const proto = Object.getPrototypeOf(val);
336458
- if (proto !== Object.prototype && proto !== null) {
336459
- return val;
336460
- }
336461
- let objModified = false;
336462
- const copy = {};
336463
- for (const [k, v] of Object.entries(val)) {
336464
- const truncated = truncateValue(v);
336465
- if (truncated !== v) {
336466
- objModified = true;
336467
- }
336468
- copy[k] = truncated;
336469
- }
336470
- return objModified ? copy : val;
336471
- }
336472
- return val;
336473
- };
336474
- const newResp = truncateValue(resp);
336475
- if (newResp !== resp) {
336476
- return {
336477
- ...part,
336478
- functionResponse: {
336479
- // eslint-disable-next-line @typescript-eslint/no-misused-spread
336480
- ...part.functionResponse,
336481
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
336482
- response: newResp
336483
- }
336484
- };
336485
- }
336486
- }
336487
- return part;
336488
- }
336489
-
336490
336167
  // packages/core/dist/src/agents/types.js
336491
336168
  var AgentTerminateMode;
336492
336169
  (function(AgentTerminateMode2) {
@@ -340852,7 +340529,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
340852
340529
  return provider;
340853
340530
  }
340854
340531
  case "oauth2": {
340855
- const { OAuth2AuthProvider } = await import("./oauth2-provider-4IJXZY2A.js");
340532
+ const { OAuth2AuthProvider } = await import("./oauth2-provider-43ANEHLB.js");
340856
340533
  const provider = new OAuth2AuthProvider(authConfig, options.agentName ?? "unknown", agentCard, options.agentCardUrl);
340857
340534
  await provider.initialize();
340858
340535
  return provider;
@@ -341974,6 +341651,72 @@ function getToolCallContext() {
341974
341651
  return toolCallContext.getStore();
341975
341652
  }
341976
341653
 
341654
+ // packages/core/dist/src/utils/tool-utils.js
341655
+ var import_fast_levenshtein2 = __toESM(require_levenshtein(), 1);
341656
+ function isToolCallResponseInfo(data) {
341657
+ return typeof data === "object" && data !== null && "callId" in data && "responseParts" in data;
341658
+ }
341659
+ function getToolSuggestion(unknownToolName, allToolNames, topN = 3) {
341660
+ const matches = allToolNames.map((toolName) => ({
341661
+ name: toolName,
341662
+ distance: import_fast_levenshtein2.default.get(unknownToolName, toolName)
341663
+ }));
341664
+ matches.sort((a2, b) => a2.distance - b.distance);
341665
+ const topNResults = matches.slice(0, topN);
341666
+ if (topNResults.length === 0) {
341667
+ return "";
341668
+ }
341669
+ const suggestedNames = topNResults.map((match2) => `"${match2.name}"`).join(", ");
341670
+ if (topNResults.length > 1) {
341671
+ return ` Did you mean one of: ${suggestedNames}?`;
341672
+ } else {
341673
+ return ` Did you mean ${suggestedNames}?`;
341674
+ }
341675
+ }
341676
+ function doesToolInvocationMatch(toolOrToolName, invocation, patterns) {
341677
+ let toolNames;
341678
+ if (isTool(toolOrToolName)) {
341679
+ toolNames = [toolOrToolName.name, toolOrToolName.constructor.name];
341680
+ } else {
341681
+ toolNames = [toolOrToolName];
341682
+ }
341683
+ if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
341684
+ toolNames = [.../* @__PURE__ */ new Set([...toolNames, ...SHELL_TOOL_NAMES])];
341685
+ }
341686
+ for (const pattern of patterns) {
341687
+ const openParen = pattern.indexOf("(");
341688
+ if (openParen === -1) {
341689
+ if (toolNames.includes(pattern)) {
341690
+ return true;
341691
+ }
341692
+ continue;
341693
+ }
341694
+ const patternToolName = pattern.substring(0, openParen);
341695
+ if (!toolNames.includes(patternToolName)) {
341696
+ continue;
341697
+ }
341698
+ if (!pattern.endsWith(")")) {
341699
+ continue;
341700
+ }
341701
+ const argPattern = pattern.substring(openParen + 1, pattern.length - 1);
341702
+ let command;
341703
+ if (typeof invocation === "string") {
341704
+ command = invocation;
341705
+ } else {
341706
+ if (!("command" in invocation.params)) {
341707
+ continue;
341708
+ }
341709
+ command = String(invocation.params.command);
341710
+ }
341711
+ if (toolNames.some((name3) => SHELL_TOOL_NAMES.includes(name3))) {
341712
+ if (command === argPattern || command.startsWith(argPattern + " ")) {
341713
+ return true;
341714
+ }
341715
+ }
341716
+ }
341717
+ return false;
341718
+ }
341719
+
341977
341720
  // packages/core/dist/src/scheduler/state-manager.js
341978
341721
  var SchedulerStateManager = class {
341979
341722
  messageBus;
@@ -347869,16 +347612,13 @@ var ToolExecutor = class {
347869
347612
  const originalContentLength = content.length;
347870
347613
  const { outputFile: savedPath } = await saveTruncatedToolOutput(content, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
347871
347614
  outputFile = savedPath;
347872
- let truncatedContent = formatTruncatedToolOutput(content, outputFile, threshold);
347615
+ const truncatedContent = formatTruncatedToolOutput(content, outputFile, threshold);
347873
347616
  logToolOutputTruncated(this.config, new ToolOutputTruncatedEvent(call.request.prompt_id, {
347874
347617
  toolName,
347875
347618
  originalContentLength,
347876
347619
  truncatedContentLength: truncatedContent.length,
347877
347620
  threshold
347878
347621
  }));
347879
- if (typeof truncatedContent === "string" && Buffer.byteLength(truncatedContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347880
- truncatedContent = truncateToolOutput(truncatedContent, MAX_STORED_TOOL_OUTPUT_BYTES);
347881
- }
347882
347622
  return { truncatedContent, outputFile };
347883
347623
  }
347884
347624
  } else if (Array.isArray(content) && content.length === 1 && "tool" in call && call.tool instanceof DiscoveredMCPTool) {
@@ -347890,10 +347630,7 @@ var ToolExecutor = class {
347890
347630
  const originalContentLength = textContent2.length;
347891
347631
  const { outputFile: savedPath } = await saveTruncatedToolOutput(textContent2, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
347892
347632
  outputFile = savedPath;
347893
- let truncatedText = formatTruncatedToolOutput(textContent2, outputFile, threshold);
347894
- if (typeof truncatedText === "string" && Buffer.byteLength(truncatedText, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347895
- truncatedText = truncateToolOutput(truncatedText, MAX_STORED_TOOL_OUTPUT_BYTES);
347896
- }
347633
+ const truncatedText = formatTruncatedToolOutput(textContent2, outputFile, threshold);
347897
347634
  const truncatedContent = [
347898
347635
  { ...firstPart, text: truncatedText }
347899
347636
  ];
@@ -347907,45 +347644,7 @@ var ToolExecutor = class {
347907
347644
  }
347908
347645
  }
347909
347646
  }
347910
- const ensureOutputFile = async (rawText) => {
347911
- if (!outputFile) {
347912
- try {
347913
- const { outputFile: savedPath } = await saveTruncatedToolOutput(rawText, toolName, callId, this.config.storage.getProjectTempDir(), this.context.promptId);
347914
- outputFile = savedPath;
347915
- } catch {
347916
- }
347917
- }
347918
- return outputFile;
347919
- };
347920
- let finalContent = content;
347921
- if (typeof finalContent === "string") {
347922
- if (Buffer.byteLength(finalContent, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347923
- const savedPath = await ensureOutputFile(finalContent);
347924
- finalContent = truncateToolOutput(finalContent, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath);
347925
- }
347926
- } else if (Array.isArray(finalContent)) {
347927
- finalContent = await Promise.all(finalContent.map(async (part) => {
347928
- if (typeof part === "string" && Buffer.byteLength(part, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347929
- const savedPath = await ensureOutputFile(part);
347930
- return truncateToolOutput(part, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath);
347931
- }
347932
- if (typeof part === "object" && part !== null && "text" in part && typeof part.text === "string" && Buffer.byteLength(part.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347933
- const savedPath = await ensureOutputFile(part.text);
347934
- return {
347935
- ...part,
347936
- text: truncateToolOutput(part.text, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath)
347937
- };
347938
- }
347939
- return part;
347940
- }));
347941
- } else if (typeof finalContent === "object" && finalContent !== null && "text" in finalContent && typeof finalContent.text === "string" && Buffer.byteLength(finalContent.text, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
347942
- const savedPath = await ensureOutputFile(finalContent.text);
347943
- finalContent = {
347944
- ...finalContent,
347945
- text: truncateToolOutput(finalContent.text, MAX_STORED_TOOL_OUTPUT_BYTES, savedPath)
347946
- };
347947
- }
347948
- return { truncatedContent: finalContent, outputFile };
347647
+ return { truncatedContent: content, outputFile };
347949
347648
  }
347950
347649
  async createCancelledResult(call, reason, toolResult) {
347951
347650
  const errorMessage = `[Operation Cancelled] ${reason}`;
@@ -348761,14 +348460,14 @@ function normalizeSpace(text) {
348761
348460
  return text.replace(/\s+/g, " ").trim();
348762
348461
  }
348763
348462
  function safeSlice(text, start2, end) {
348764
- const segmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
348765
- const segments = Array.from(segmenter2.segment(text));
348463
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
348464
+ const segments = Array.from(segmenter.segment(text));
348766
348465
  return segments.slice(start2, end).map((s2) => s2.segment).join("");
348767
348466
  }
348768
348467
  function safeLength(text) {
348769
- const segmenter2 = new Intl.Segmenter(void 0, { granularity: "grapheme" });
348468
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
348770
348469
  let count2 = 0;
348771
- for (const _ of segmenter2.segment(text)) {
348470
+ for (const _ of segmenter.segment(text)) {
348772
348471
  count2++;
348773
348472
  }
348774
348473
  return count2;
@@ -349893,30 +349592,13 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
349893
349592
  }
349894
349593
  async tryCompressChat(chat, prompt_id, abortSignal) {
349895
349594
  const model = this.definition.modelConfig.model ?? DEFAULT_GEMINI_MODEL;
349896
- const threshold = await this.context.config.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
349897
- const modelLimit = tokenLimit(model);
349898
- const lastPromptTokenCount = chat.getLastPromptTokenCount();
349899
- const currentHistory = chat.getHistory(false);
349900
- const originalTokenCount = lastPromptTokenCount > 0 ? lastPromptTokenCount : estimateTokenCountSync(currentHistory.flatMap((c4) => c4.parts || []));
349901
- if (originalTokenCount >= threshold * modelLimit) {
349902
- const collapsedHistory = collapseOlderFunctionResponses(currentHistory);
349903
- if (collapsedHistory !== currentHistory) {
349904
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
349905
- const turns = collapsedHistory.map((c4, idx) => ({
349906
- id: existingTurns[idx]?.id ?? randomUUID13(),
349907
- content: c4
349908
- }));
349909
- chat.setHistory(turns);
349910
- }
349911
- }
349912
349595
  const { newHistory, info: info2 } = await this.compressionService.compress(chat, prompt_id, false, model, this.context.config, this.hasFailedCompressionAttempt, abortSignal);
349913
349596
  if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
349914
349597
  this.hasFailedCompressionAttempt = true;
349915
349598
  } else if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
349916
349599
  if (newHistory) {
349917
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
349918
- const turns = newHistory.map((c4, idx) => ({
349919
- id: existingTurns[idx]?.id ?? randomUUID13(),
349600
+ const turns = newHistory.map((c4) => ({
349601
+ id: randomUUID13(),
349920
349602
  content: c4
349921
349603
  }));
349922
349604
  chat.setHistory(turns);
@@ -349924,9 +349606,8 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
349924
349606
  }
349925
349607
  } else if (info2.compressionStatus === CompressionStatus.CONTENT_TRUNCATED) {
349926
349608
  if (newHistory) {
349927
- const existingTurns = chat.getHistoryTurns?.(false) ?? [];
349928
- const turns = newHistory.map((c4, idx) => ({
349929
- id: existingTurns[idx]?.id ?? randomUUID13(),
349609
+ const turns = newHistory.map((c4) => ({
349610
+ id: randomUUID13(),
349930
349611
  content: c4
349931
349612
  }));
349932
349613
  chat.setHistory(turns);
@@ -350109,15 +349790,6 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
350109
349790
  signal,
350110
349791
  onWaitingForConfirmation
350111
349792
  });
350112
- for (const call of completedCalls) {
350113
- const outputFile = call.response?.outputFile;
350114
- if (call.response?.responseParts) {
350115
- call.response.responseParts = call.response.responseParts.map((p) => truncateFunctionResponsePart(p, MAX_STORED_TOOL_OUTPUT_BYTES, outputFile));
350116
- }
350117
- if (typeof call.response?.resultDisplay === "string" && Buffer.byteLength(call.response.resultDisplay, "utf8") > MAX_STORED_TOOL_OUTPUT_BYTES) {
350118
- call.response.resultDisplay = truncateToolOutput(call.response.resultDisplay, MAX_STORED_TOOL_OUTPUT_BYTES, outputFile);
350119
- }
350120
- }
350121
349793
  chat.recordCompletedToolCalls(model, completedCalls);
350122
349794
  for (const call of completedCalls) {
350123
349795
  const toolName = toolNameMap.get(call.request.callId) || call.request.name;
@@ -350183,7 +349855,7 @@ var LocalAgentExecutor = class _LocalAgentExecutor {
350183
349855
  const callId = functionCall.id ?? `${promptId}-${index}`;
350184
349856
  const part = syncResults.get(callId);
350185
349857
  if (part) {
350186
- toolResponseParts.push(truncateFunctionResponsePart(part, MAX_STORED_TOOL_OUTPUT_BYTES));
349858
+ toolResponseParts.push(part);
350187
349859
  continue;
350188
349860
  }
350189
349861
  const isAborted2 = signal.aborted;
@@ -398650,7 +398322,6 @@ export {
398650
398322
  DEFAULT_MAX_LINES_TEXT_FILE,
398651
398323
  MAX_LINE_LENGTH_TEXT_FILE,
398652
398324
  MAX_FILE_SIZE_MB,
398653
- MAX_STORED_TOOL_OUTPUT_BYTES,
398654
398325
  EMPTY_RESPONSE_COMPRESS_SUGGESTION,
398655
398326
  THINKING_ONLY_COMPRESS_SUGGESTION,
398656
398327
  MAX_TOKENS_EXCEEDED_SUGGESTION,
@@ -399424,11 +399095,6 @@ export {
399424
399095
  SessionStartSource,
399425
399096
  SessionEndReason,
399426
399097
  PreCompressTrigger,
399427
- isToolCallResponseInfo,
399428
- getToolSuggestion,
399429
- doesToolInvocationMatch,
399430
- truncateToolOutput,
399431
- truncateFunctionResponsePart,
399432
399098
  AgentTerminateMode,
399433
399099
  DEFAULT_QUERY_STRING,
399434
399100
  DEFAULT_MAX_TURNS,
@@ -399463,6 +399129,9 @@ export {
399463
399129
  exchangeCodeForToken,
399464
399130
  refreshAccessToken,
399465
399131
  ModelConfigService,
399132
+ isToolCallResponseInfo,
399133
+ getToolSuggestion,
399134
+ doesToolInvocationMatch,
399466
399135
  getPolicyDenialError,
399467
399136
  checkPolicy,
399468
399137
  updatePolicy,