@google/gemini-cli-a2a-server 0.11.2 → 0.11.3

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.
@@ -288503,8 +288503,8 @@ var Float64Vector = import_vector.default.Float64Vector;
288503
288503
  var PointerVector = import_vector.default.PointerVector;
288504
288504
 
288505
288505
  // packages/core/dist/src/generated/git-commit.js
288506
- var GIT_COMMIT_INFO = "f36dec6a";
288507
- var CLI_VERSION = "0.11.2";
288506
+ var GIT_COMMIT_INFO = "44b3c974";
288507
+ var CLI_VERSION = "0.11.3";
288508
288508
 
288509
288509
  // packages/core/dist/src/ide/detect-ide.js
288510
288510
  var IDE_DEFINITIONS = {
@@ -290970,7 +290970,7 @@ function createContentGeneratorConfig(config2, authType) {
290970
290970
  return contentGeneratorConfig;
290971
290971
  }
290972
290972
  async function createContentGenerator(config2, gcConfig, sessionId2) {
290973
- const version3 = "0.11.2";
290973
+ const version3 = "0.11.3";
290974
290974
  const userAgent = `GeminiCLI/${version3} (${process.platform}; ${process.arch})`;
290975
290975
  const baseHeaders = {
290976
290976
  "User-Agent": userAgent
@@ -324782,8 +324782,7 @@ function classifyGoogleError(error) {
324782
324782
  for (const violation of quotaFailure.violations) {
324783
324783
  const quotaId = violation.quotaId ?? "";
324784
324784
  if (quotaId.includes("PerDay") || quotaId.includes("Daily")) {
324785
- return new TerminalQuotaError(`${googleApiError.message}
324786
- Expected quota reset within 24h.`, googleApiError);
324785
+ return new TerminalQuotaError(`You have exhausted your daily quota on this model.`, googleApiError);
324787
324786
  }
324788
324787
  }
324789
324788
  }
@@ -324812,8 +324811,7 @@ Expected quota reset within 24h.`, googleApiError);
324812
324811
  }
324813
324812
  const quotaLimit = errorInfo.metadata?.["quota_limit"] ?? "";
324814
324813
  if (quotaLimit.includes("PerDay") || quotaLimit.includes("Daily")) {
324815
- return new TerminalQuotaError(`${googleApiError.message}
324816
- Expected quota reset within 24h.`, googleApiError);
324814
+ return new TerminalQuotaError(`You have exhausted your daily quota on this model.`, googleApiError);
324817
324815
  }
324818
324816
  }
324819
324817
  if (retryInfo?.retryDelay) {
@@ -337928,6 +337926,24 @@ ${directoryContext}
337928
337926
  const initialParts = [{ text: context2 }];
337929
337927
  return initialParts;
337930
337928
  }
337929
+ async function getInitialChatHistory(config2, extraHistory) {
337930
+ const envParts = await getEnvironmentContext(config2);
337931
+ const envContextString = envParts.map((part) => part.text || "").join("\n\n");
337932
+ const allSetupText = `
337933
+ ${envContextString}
337934
+
337935
+ Reminder: Do not return an empty response when a tool call is required.
337936
+
337937
+ My setup is complete. I will provide my first command in the next turn.
337938
+ `.trim();
337939
+ return [
337940
+ {
337941
+ role: "user",
337942
+ parts: [{ text: allSetupText }]
337943
+ },
337944
+ ...extraHistory ?? []
337945
+ ];
337946
+ }
337931
337947
 
337932
337948
  // packages/core/dist/src/utils/generateContentResponseUtilities.js
337933
337949
  function getResponseTextFromParts(parts2) {
@@ -340034,7 +340050,10 @@ var LoopDetectionService = class {
340034
340050
  * @returns true if a loop is detected, false otherwise
340035
340051
  */
340036
340052
  addAndCheck(event) {
340037
- if (this.loopDetected || this.disabledForSession) {
340053
+ if (this.disabledForSession) {
340054
+ return false;
340055
+ }
340056
+ if (this.loopDetected) {
340038
340057
  return this.loopDetected;
340039
340058
  }
340040
340059
  switch (event.type) {
@@ -340282,10 +340301,9 @@ var LoopDetectionService = class {
340282
340301
  }
340283
340302
  };
340284
340303
 
340285
- // packages/core/dist/src/core/client.js
340286
- function isThinkingSupported(model) {
340287
- return model.startsWith("gemini-2.5") || model === DEFAULT_GEMINI_MODEL_AUTO;
340288
- }
340304
+ // packages/core/dist/src/services/chatCompressionService.js
340305
+ var DEFAULT_COMPRESSION_TOKEN_THRESHOLD = 0.2;
340306
+ var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
340289
340307
  function findCompressSplitPoint(contents, fraction) {
340290
340308
  if (fraction <= 0 || fraction >= 1) {
340291
340309
  throw new Error("Fraction must be between 0 and 1");
@@ -340311,9 +340329,109 @@ function findCompressSplitPoint(contents, fraction) {
340311
340329
  }
340312
340330
  return lastSplitPoint;
340313
340331
  }
340332
+ var ChatCompressionService = class {
340333
+ async compress(chat, promptId, force, model, config2, hasFailedCompressionAttempt) {
340334
+ const curatedHistory = chat.getHistory(true);
340335
+ if (curatedHistory.length === 0 || hasFailedCompressionAttempt && !force) {
340336
+ return {
340337
+ newHistory: null,
340338
+ info: {
340339
+ originalTokenCount: 0,
340340
+ newTokenCount: 0,
340341
+ compressionStatus: CompressionStatus.NOOP
340342
+ }
340343
+ };
340344
+ }
340345
+ const originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
340346
+ if (!force) {
340347
+ const threshold = config2.getCompressionThreshold() ?? DEFAULT_COMPRESSION_TOKEN_THRESHOLD;
340348
+ if (originalTokenCount < threshold * tokenLimit(model)) {
340349
+ return {
340350
+ newHistory: null,
340351
+ info: {
340352
+ originalTokenCount,
340353
+ newTokenCount: originalTokenCount,
340354
+ compressionStatus: CompressionStatus.NOOP
340355
+ }
340356
+ };
340357
+ }
340358
+ }
340359
+ const splitPoint = findCompressSplitPoint(curatedHistory, 1 - COMPRESSION_PRESERVE_THRESHOLD);
340360
+ const historyToCompress = curatedHistory.slice(0, splitPoint);
340361
+ const historyToKeep = curatedHistory.slice(splitPoint);
340362
+ if (historyToCompress.length === 0) {
340363
+ return {
340364
+ newHistory: null,
340365
+ info: {
340366
+ originalTokenCount,
340367
+ newTokenCount: originalTokenCount,
340368
+ compressionStatus: CompressionStatus.NOOP
340369
+ }
340370
+ };
340371
+ }
340372
+ const summaryResponse = await config2.getContentGenerator().generateContent({
340373
+ model,
340374
+ contents: [
340375
+ ...historyToCompress,
340376
+ {
340377
+ role: "user",
340378
+ parts: [
340379
+ {
340380
+ text: "First, reason in your scratchpad. Then, generate the <state_snapshot>."
340381
+ }
340382
+ ]
340383
+ }
340384
+ ],
340385
+ config: {
340386
+ systemInstruction: { text: getCompressionPrompt() }
340387
+ }
340388
+ }, promptId);
340389
+ const summary = getResponseText(summaryResponse) ?? "";
340390
+ const extraHistory = [
340391
+ {
340392
+ role: "user",
340393
+ parts: [{ text: summary }]
340394
+ },
340395
+ {
340396
+ role: "model",
340397
+ parts: [{ text: "Got it. Thanks for the additional context!" }]
340398
+ },
340399
+ ...historyToKeep
340400
+ ];
340401
+ const fullNewHistory = await getInitialChatHistory(config2, extraHistory);
340402
+ const newTokenCount = Math.floor(fullNewHistory.reduce((total, content) => total + JSON.stringify(content).length, 0) / 4);
340403
+ logChatCompression(config2, makeChatCompressionEvent({
340404
+ tokens_before: originalTokenCount,
340405
+ tokens_after: newTokenCount
340406
+ }));
340407
+ if (newTokenCount > originalTokenCount) {
340408
+ return {
340409
+ newHistory: null,
340410
+ info: {
340411
+ originalTokenCount,
340412
+ newTokenCount,
340413
+ compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT
340414
+ }
340415
+ };
340416
+ } else {
340417
+ uiTelemetryService.setLastPromptTokenCount(newTokenCount);
340418
+ return {
340419
+ newHistory: extraHistory,
340420
+ info: {
340421
+ originalTokenCount,
340422
+ newTokenCount,
340423
+ compressionStatus: CompressionStatus.COMPRESSED
340424
+ }
340425
+ };
340426
+ }
340427
+ }
340428
+ };
340429
+
340430
+ // packages/core/dist/src/core/client.js
340431
+ function isThinkingSupported(model) {
340432
+ return model.startsWith("gemini-2.5") || model === DEFAULT_GEMINI_MODEL_AUTO;
340433
+ }
340314
340434
  var MAX_TURNS = 100;
340315
- var COMPRESSION_TOKEN_THRESHOLD = 0.7;
340316
- var COMPRESSION_PRESERVE_THRESHOLD = 0.3;
340317
340435
  var GeminiClient = class {
340318
340436
  config;
340319
340437
  chat;
@@ -340323,6 +340441,7 @@ var GeminiClient = class {
340323
340441
  };
340324
340442
  sessionTurnCount = 0;
340325
340443
  loopDetector;
340444
+ compressionService;
340326
340445
  lastPromptId;
340327
340446
  currentSequenceModel = null;
340328
340447
  lastSentIdeContext;
@@ -340335,6 +340454,7 @@ var GeminiClient = class {
340335
340454
  constructor(config2) {
340336
340455
  this.config = config2;
340337
340456
  this.loopDetector = new LoopDetectionService(config2);
340457
+ this.compressionService = new ChatCompressionService();
340338
340458
  this.lastPromptId = this.config.getSessionId();
340339
340459
  }
340340
340460
  async initialize() {
@@ -340401,22 +340521,7 @@ var GeminiClient = class {
340401
340521
  const toolRegistry = this.config.getToolRegistry();
340402
340522
  const toolDeclarations = toolRegistry.getFunctionDeclarations();
340403
340523
  const tools = [{ functionDeclarations: toolDeclarations }];
340404
- const envParts = await getEnvironmentContext(this.config);
340405
- const envContextString = envParts.map((part) => part.text || "").join("\n\n");
340406
- const allSetupText = `
340407
- ${envContextString}
340408
-
340409
- Reminder: Do not return an empty response when a tool call is required.
340410
-
340411
- My setup is complete. I will provide my first command in the next turn.
340412
- `.trim();
340413
- const history = [
340414
- {
340415
- role: "user",
340416
- parts: [{ text: allSetupText }]
340417
- },
340418
- ...extraHistory ?? []
340419
- ];
340524
+ const history = await getInitialChatHistory(this.config, extraHistory);
340420
340525
  try {
340421
340526
  const userMemory = this.config.getUserMemory();
340422
340527
  const systemInstruction = getCoreSystemPrompt(this.config, userMemory);
@@ -340728,87 +340833,16 @@ My setup is complete. I will provide my first command in the next turn.
340728
340833
  }
340729
340834
  async tryCompressChat(prompt_id, force = false) {
340730
340835
  const model = this._getEffectiveModelForCurrentTurn();
340731
- const curatedHistory = this.getChat().getHistory(true);
340732
- if (curatedHistory.length === 0 || this.hasFailedCompressionAttempt && !force) {
340733
- return {
340734
- originalTokenCount: 0,
340735
- newTokenCount: 0,
340736
- compressionStatus: CompressionStatus.NOOP
340737
- };
340738
- }
340739
- const originalTokenCount = uiTelemetryService.getLastPromptTokenCount();
340740
- const contextPercentageThreshold = this.config.getChatCompression()?.contextPercentageThreshold;
340741
- if (!force) {
340742
- const threshold = contextPercentageThreshold ?? COMPRESSION_TOKEN_THRESHOLD;
340743
- if (originalTokenCount < threshold * tokenLimit(model)) {
340744
- return {
340745
- originalTokenCount,
340746
- newTokenCount: originalTokenCount,
340747
- compressionStatus: CompressionStatus.NOOP
340748
- };
340749
- }
340750
- }
340751
- const splitPoint = findCompressSplitPoint(curatedHistory, 1 - COMPRESSION_PRESERVE_THRESHOLD);
340752
- const historyToCompress = curatedHistory.slice(0, splitPoint);
340753
- const historyToKeep = curatedHistory.slice(splitPoint);
340754
- if (historyToCompress.length === 0) {
340755
- return {
340756
- originalTokenCount,
340757
- newTokenCount: originalTokenCount,
340758
- compressionStatus: CompressionStatus.NOOP
340759
- };
340760
- }
340761
- const summaryResponse = await this.config.getContentGenerator().generateContent({
340762
- model,
340763
- contents: [
340764
- ...historyToCompress,
340765
- {
340766
- role: "user",
340767
- parts: [
340768
- {
340769
- text: "First, reason in your scratchpad. Then, generate the <state_snapshot>."
340770
- }
340771
- ]
340772
- }
340773
- ],
340774
- config: {
340775
- systemInstruction: { text: getCompressionPrompt() }
340776
- }
340777
- }, prompt_id);
340778
- const summary = getResponseText(summaryResponse) ?? "";
340779
- const chat = await this.startChat([
340780
- {
340781
- role: "user",
340782
- parts: [{ text: summary }]
340783
- },
340784
- {
340785
- role: "model",
340786
- parts: [{ text: "Got it. Thanks for the additional context!" }]
340787
- },
340788
- ...historyToKeep
340789
- ]);
340790
- this.forceFullIdeContext = true;
340791
- const newTokenCount = Math.floor(chat.getHistory().reduce((total, content) => total + JSON.stringify(content).length, 0) / 4);
340792
- logChatCompression(this.config, makeChatCompressionEvent({
340793
- tokens_before: originalTokenCount,
340794
- tokens_after: newTokenCount
340795
- }));
340796
- if (newTokenCount > originalTokenCount) {
340836
+ const { newHistory, info: info2 } = await this.compressionService.compress(this.getChat(), prompt_id, force, model, this.config, this.hasFailedCompressionAttempt);
340837
+ if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
340797
340838
  this.hasFailedCompressionAttempt = !force && true;
340798
- return {
340799
- originalTokenCount,
340800
- newTokenCount,
340801
- compressionStatus: CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT
340802
- };
340803
- } else {
340804
- this.chat = chat;
340805
- uiTelemetryService.setLastPromptTokenCount(newTokenCount);
340839
+ } else if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
340840
+ if (newHistory) {
340841
+ this.chat = await this.startChat(newHistory);
340842
+ this.forceFullIdeContext = true;
340843
+ }
340806
340844
  }
340807
- return {
340808
- originalTokenCount,
340809
- newTokenCount,
340810
- compressionStatus: CompressionStatus.COMPRESSED
340811
- };
340845
+ return info2;
340812
340846
  }
340813
340847
  };
340814
340848
 
@@ -348676,7 +348710,7 @@ var Config = class {
348676
348710
  summarizeToolOutput;
348677
348711
  experimentalZedIntegration = false;
348678
348712
  loadMemoryFromIncludeDirectories = false;
348679
- chatCompression;
348713
+ compressionThreshold;
348680
348714
  interactive;
348681
348715
  ptyInfo;
348682
348716
  trustedFolder;
@@ -348761,7 +348795,7 @@ var Config = class {
348761
348795
  this.folderTrust = params.folderTrust ?? false;
348762
348796
  this.ideMode = params.ideMode ?? false;
348763
348797
  this.loadMemoryFromIncludeDirectories = params.loadMemoryFromIncludeDirectories ?? false;
348764
- this.chatCompression = params.chatCompression;
348798
+ this.compressionThreshold = params.compressionThreshold;
348765
348799
  this.interactive = params.interactive ?? false;
348766
348800
  this.ptyInfo = params.ptyInfo ?? "child_process";
348767
348801
  this.trustedFolder = params.trustedFolder;
@@ -349135,8 +349169,8 @@ var Config = class {
349135
349169
  setFileSystemService(fileSystemService) {
349136
349170
  this.fileSystemService = fileSystemService;
349137
349171
  }
349138
- getChatCompression() {
349139
- return this.chatCompression;
349172
+ getCompressionThreshold() {
349173
+ return this.compressionThreshold;
349140
349174
  }
349141
349175
  isInteractiveShellEnabled() {
349142
349176
  return this.interactive && this.ptyInfo !== "child_process" && this.enableInteractiveShell;