@google/gemini-cli-a2a-server 0.21.0-nightly.20251204.3da4fd5f7 → 0.21.0-nightly.20251205.f4f2bcbd9

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.
@@ -311854,8 +311854,8 @@ var Float64Vector = import_vector.default.Float64Vector;
311854
311854
  var PointerVector = import_vector.default.PointerVector;
311855
311855
 
311856
311856
  // packages/core/dist/src/generated/git-commit.js
311857
- var GIT_COMMIT_INFO = "3da4fd5f7";
311858
- var CLI_VERSION = "0.21.0-nightly.20251204.3da4fd5f7";
311857
+ var GIT_COMMIT_INFO = "f4f2bcbd9";
311858
+ var CLI_VERSION = "0.21.0-nightly.20251205.f4f2bcbd9";
311859
311859
 
311860
311860
  // packages/core/dist/src/ide/detect-ide.js
311861
311861
  var IDE_DEFINITIONS = {
@@ -315000,7 +315000,7 @@ async function createContentGenerator(config3, gcConfig, sessionId2) {
315000
315000
  if (gcConfig.fakeResponses) {
315001
315001
  return FakeContentGenerator.fromFile(gcConfig.fakeResponses);
315002
315002
  }
315003
- const version4 = "0.21.0-nightly.20251204.3da4fd5f7";
315003
+ const version4 = "0.21.0-nightly.20251205.f4f2bcbd9";
315004
315004
  const customHeadersEnv = process.env["GEMINI_CLI_CUSTOM_HEADERS"] || void 0;
315005
315005
  const userAgent = `GeminiCLI/${version4} (${process.platform}; ${process.arch})`;
315006
315006
  const customHeadersMap = parseCustomHeaders(customHeadersEnv);
@@ -352866,7 +352866,6 @@ function delay2(ms, signal) {
352866
352866
  }
352867
352867
 
352868
352868
  // packages/core/dist/src/utils/retry.js
352869
- var FETCH_FAILED_MESSAGE = "exception TypeError: fetch failed sending request";
352870
352869
  var DEFAULT_RETRY_OPTIONS = {
352871
352870
  maxAttempts: 3,
352872
352871
  initialDelayMs: 5e3,
@@ -352874,9 +352873,43 @@ var DEFAULT_RETRY_OPTIONS = {
352874
352873
  // 30 seconds
352875
352874
  shouldRetryOnError: defaultShouldRetry
352876
352875
  };
352876
+ var RETRYABLE_NETWORK_CODES = [
352877
+ "ECONNRESET",
352878
+ "ETIMEDOUT",
352879
+ "EPIPE",
352880
+ "ENOTFOUND",
352881
+ "EAI_AGAIN",
352882
+ "ECONNREFUSED"
352883
+ ];
352884
+ function getNetworkErrorCode(error2) {
352885
+ const getCode = (obj) => {
352886
+ if (typeof obj !== "object" || obj === null) {
352887
+ return void 0;
352888
+ }
352889
+ if ("code" in obj && typeof obj.code === "string") {
352890
+ return obj.code;
352891
+ }
352892
+ return void 0;
352893
+ };
352894
+ const directCode = getCode(error2);
352895
+ if (directCode) {
352896
+ return directCode;
352897
+ }
352898
+ if (typeof error2 === "object" && error2 !== null && "cause" in error2) {
352899
+ return getCode(error2.cause);
352900
+ }
352901
+ return void 0;
352902
+ }
352903
+ var FETCH_FAILED_MESSAGE = "fetch failed";
352877
352904
  function defaultShouldRetry(error2, retryFetchErrors) {
352878
- if (retryFetchErrors && error2 instanceof Error && error2.message.includes(FETCH_FAILED_MESSAGE)) {
352879
- return true;
352905
+ if (retryFetchErrors && error2 instanceof Error) {
352906
+ if (error2.message.toLowerCase().includes(FETCH_FAILED_MESSAGE)) {
352907
+ return true;
352908
+ }
352909
+ const errorCode = getNetworkErrorCode(error2);
352910
+ if (errorCode && RETRYABLE_NETWORK_CODES.includes(errorCode)) {
352911
+ return true;
352912
+ }
352880
352913
  }
352881
352914
  if (error2 instanceof ApiError2) {
352882
352915
  if (error2.status === 400)
@@ -359252,24 +359285,11 @@ var ShellExecutionService = class {
359252
359285
  if (shellExecutionConfig.showColor) {
359253
359286
  newOutput = serializeTerminalToObject(headlessTerminal);
359254
359287
  } else {
359255
- const lines = [];
359256
- for (let y = 0; y < headlessTerminal.rows; y++) {
359257
- const line = buffer.getLine(buffer.viewportY + y);
359258
- const lineContent = line ? line.translateToString(true) : "";
359259
- lines.push([
359260
- {
359261
- text: lineContent,
359262
- bold: false,
359263
- italic: false,
359264
- underline: false,
359265
- dim: false,
359266
- inverse: false,
359267
- fg: "",
359268
- bg: ""
359269
- }
359270
- ]);
359271
- }
359272
- newOutput = lines;
359288
+ newOutput = (serializeTerminalToObject(headlessTerminal) || []).map((line) => line.map((token2) => {
359289
+ token2.fg = "";
359290
+ token2.bg = "";
359291
+ return token2;
359292
+ }));
359273
359293
  }
359274
359294
  let lastNonEmptyLine = -1;
359275
359295
  for (let i4 = newOutput.length - 1; i4 >= 0; i4--) {
@@ -370232,7 +370252,7 @@ var GeminiClient = class {
370232
370252
  const model = this._getEffectiveModelForCurrentTurn();
370233
370253
  const { newHistory, info: info2 } = await this.compressionService.compress(this.getChat(), prompt_id, force, model, this.config, this.hasFailedCompressionAttempt);
370234
370254
  if (info2.compressionStatus === CompressionStatus.COMPRESSION_FAILED_INFLATED_TOKEN_COUNT) {
370235
- this.hasFailedCompressionAttempt = !force && true;
370255
+ this.hasFailedCompressionAttempt = this.hasFailedCompressionAttempt || !force;
370236
370256
  } else if (info2.compressionStatus === CompressionStatus.COMPRESSED) {
370237
370257
  if (newHistory) {
370238
370258
  this.chat = await this.startChat(newHistory);
@@ -381702,7 +381722,7 @@ async function getClientMetadata() {
381702
381722
  clientMetadataPromise = (async () => ({
381703
381723
  ideName: "IDE_UNSPECIFIED",
381704
381724
  pluginType: "GEMINI",
381705
- ideVersion: "0.21.0-nightly.20251204.3da4fd5f7",
381725
+ ideVersion: "0.21.0-nightly.20251205.f4f2bcbd9",
381706
381726
  platform: getPlatform(),
381707
381727
  updateChannel: await getReleaseChannel(__dirname5)
381708
381728
  }))();
@@ -383629,17 +383649,23 @@ var McpClient = class {
383629
383649
  toolRegistry;
383630
383650
  promptRegistry;
383631
383651
  workspaceContext;
383652
+ cliConfig;
383632
383653
  debugMode;
383654
+ onToolsUpdated;
383633
383655
  client;
383634
383656
  transport;
383635
383657
  status = MCPServerStatus.DISCONNECTED;
383636
- constructor(serverName, serverConfig, toolRegistry, promptRegistry, workspaceContext, debugMode) {
383658
+ isRefreshing = false;
383659
+ pendingRefresh = false;
383660
+ constructor(serverName, serverConfig, toolRegistry, promptRegistry, workspaceContext, cliConfig, debugMode, onToolsUpdated) {
383637
383661
  this.serverName = serverName;
383638
383662
  this.serverConfig = serverConfig;
383639
383663
  this.toolRegistry = toolRegistry;
383640
383664
  this.promptRegistry = promptRegistry;
383641
383665
  this.workspaceContext = workspaceContext;
383666
+ this.cliConfig = cliConfig;
383642
383667
  this.debugMode = debugMode;
383668
+ this.onToolsUpdated = onToolsUpdated;
383643
383669
  }
383644
383670
  /**
383645
383671
  * Connects to the MCP server.
@@ -383651,6 +383677,14 @@ var McpClient = class {
383651
383677
  this.updateStatus(MCPServerStatus.CONNECTING);
383652
383678
  try {
383653
383679
  this.client = await connectToMcpServer(this.serverName, this.serverConfig, this.debugMode, this.workspaceContext);
383680
+ const capabilities = this.client.getServerCapabilities();
383681
+ if (capabilities?.tools?.listChanged) {
383682
+ debugLogger.log(`Server '${this.serverName}' supports tool updates. Listening for changes...`);
383683
+ this.client.setNotificationHandler(ToolListChangedNotificationSchema, async () => {
383684
+ debugLogger.log(`\u{1F514} Received tool update notification from '${this.serverName}'`);
383685
+ await this.refreshTools();
383686
+ });
383687
+ }
383654
383688
  const originalOnError = this.client.onerror;
383655
383689
  this.client.onerror = (error2) => {
383656
383690
  if (this.status !== MCPServerStatus.CONNECTED) {
@@ -383717,9 +383751,11 @@ var McpClient = class {
383717
383751
  throw new Error(`Client is not connected, must connect before interacting with the server. Current state is ${this.status}`);
383718
383752
  }
383719
383753
  }
383720
- async discoverTools(cliConfig) {
383754
+ async discoverTools(cliConfig, options2) {
383721
383755
  this.assertConnected();
383722
- return discoverTools(this.serverName, this.serverConfig, this.client, cliConfig, this.toolRegistry.getMessageBus());
383756
+ return discoverTools(this.serverName, this.serverConfig, this.client, cliConfig, this.toolRegistry.getMessageBus(), options2 ?? {
383757
+ timeout: this.serverConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC
383758
+ });
383723
383759
  }
383724
383760
  async discoverPrompts() {
383725
383761
  this.assertConnected();
@@ -383731,6 +383767,56 @@ var McpClient = class {
383731
383767
  getInstructions() {
383732
383768
  return this.client?.getInstructions();
383733
383769
  }
383770
+ /**
383771
+ * Refreshes the tools for this server by re-querying the MCP `tools/list` endpoint.
383772
+ *
383773
+ * This method implements a **Coalescing Pattern** to handle rapid bursts of notifications
383774
+ * (e.g., during server startup or bulk updates) without overwhelming the server or
383775
+ * creating race conditions in the global ToolRegistry.
383776
+ */
383777
+ async refreshTools() {
383778
+ if (this.isRefreshing) {
383779
+ debugLogger.log(`Tool refresh for '${this.serverName}' is already in progress. Pending update.`);
383780
+ this.pendingRefresh = true;
383781
+ return;
383782
+ }
383783
+ this.isRefreshing = true;
383784
+ try {
383785
+ do {
383786
+ this.pendingRefresh = false;
383787
+ if (this.status !== MCPServerStatus.CONNECTED || !this.client)
383788
+ break;
383789
+ const timeoutMs = this.serverConfig.timeout ?? MCP_DEFAULT_TIMEOUT_MSEC;
383790
+ const abortController = new AbortController();
383791
+ const timeoutId = setTimeout(() => abortController.abort(), timeoutMs);
383792
+ let newTools;
383793
+ try {
383794
+ newTools = await this.discoverTools(this.cliConfig, {
383795
+ signal: abortController.signal
383796
+ });
383797
+ } catch (err2) {
383798
+ debugLogger.error(`Discovery failed during refresh: ${getErrorMessage(err2)}`);
383799
+ clearTimeout(timeoutId);
383800
+ break;
383801
+ }
383802
+ this.toolRegistry.removeMcpToolsByServer(this.serverName);
383803
+ for (const tool of newTools) {
383804
+ this.toolRegistry.registerTool(tool);
383805
+ }
383806
+ this.toolRegistry.sortTools();
383807
+ if (this.onToolsUpdated) {
383808
+ await this.onToolsUpdated(abortController.signal);
383809
+ }
383810
+ clearTimeout(timeoutId);
383811
+ coreEvents.emitFeedback("info", `Tools updated for server: ${this.serverName}`);
383812
+ } while (this.pendingRefresh);
383813
+ } catch (error2) {
383814
+ debugLogger.error(`Critical error in refresh loop for ${this.serverName}: ${getErrorMessage(error2)}`);
383815
+ } finally {
383816
+ this.isRefreshing = false;
383817
+ this.pendingRefresh = false;
383818
+ }
383819
+ }
383734
383820
  };
383735
383821
  var serverStatuses = /* @__PURE__ */ new Map();
383736
383822
  var mcpDiscoveryState = MCPDiscoveryState.NOT_STARTED;
@@ -383853,11 +383939,11 @@ function populateMcpServerCommand(mcpServers, mcpServerCommand) {
383853
383939
  }
383854
383940
  return mcpServers;
383855
383941
  }
383856
- async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig, messageBus) {
383942
+ async function discoverTools(mcpServerName, mcpServerConfig, mcpClient, cliConfig, messageBus, options2) {
383857
383943
  try {
383858
383944
  if (mcpClient.getServerCapabilities()?.tools == null)
383859
383945
  return [];
383860
- const response = await mcpClient.listTools({});
383946
+ const response = await mcpClient.listTools({}, options2);
383861
383947
  const discoveredTools = [];
383862
383948
  for (const toolDef of response.tools) {
383863
383949
  try {
@@ -384410,7 +384496,13 @@ var McpClientManager = class {
384410
384496
  if (existing) {
384411
384497
  await existing.disconnect();
384412
384498
  }
384413
- const client = existing ?? new McpClient(name4, config3, this.toolRegistry, this.cliConfig.getPromptRegistry(), this.cliConfig.getWorkspaceContext(), this.cliConfig.getDebugMode());
384499
+ const client = existing ?? new McpClient(name4, config3, this.toolRegistry, this.cliConfig.getPromptRegistry(), this.cliConfig.getWorkspaceContext(), this.cliConfig, this.cliConfig.getDebugMode(), async () => {
384500
+ debugLogger.log("Tools changed, updating Gemini context...");
384501
+ const geminiClient = this.cliConfig.getGeminiClient();
384502
+ if (geminiClient.isInitialized()) {
384503
+ await geminiClient.setTools();
384504
+ }
384505
+ });
384414
384506
  if (!existing) {
384415
384507
  this.clients.set(name4, client);
384416
384508
  this.eventEmitter?.emit("mcp-client-update", this.clients);