@google/gemini-cli-a2a-server 0.41.0-preview.1 → 0.42.0-nightly.20260501.gcaa046641

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.
@@ -126051,8 +126051,10 @@ var init_events = __esm({
126051
126051
  /**
126052
126052
  * Flushes buffered messages. Call this immediately after primary UI listener
126053
126053
  * subscribes.
126054
+ *
126055
+ * @param transform - Optional function to transform events before they are emitted.
126054
126056
  */
126055
- drainBacklogs() {
126057
+ drainBacklogs(transform2) {
126056
126058
  const backlog = this._eventBacklog;
126057
126059
  const head = this._backlogHead;
126058
126060
  this._eventBacklog = [];
@@ -126061,7 +126063,16 @@ var init_events = __esm({
126061
126063
  const item = backlog[i3];
126062
126064
  if (item === void 0)
126063
126065
  continue;
126064
- this.emit(item.event, ...item.args);
126066
+ let eventToEmit = item.event;
126067
+ let argsToEmit = item.args;
126068
+ if (transform2) {
126069
+ const transformed = transform2(item.event, item.args);
126070
+ if (!transformed)
126071
+ continue;
126072
+ eventToEmit = transformed.event;
126073
+ argsToEmit = transformed.args;
126074
+ }
126075
+ this.emit(eventToEmit, ...argsToEmit);
126065
126076
  }
126066
126077
  }
126067
126078
  emitTelemetryKeychainAvailability(event) {
@@ -209422,8 +209433,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
209422
209433
  var init_git_commit = __esm({
209423
209434
  "packages/core/dist/src/generated/git-commit.js"() {
209424
209435
  "use strict";
209425
- GIT_COMMIT_INFO = "7d233ddd5";
209426
- CLI_VERSION = "0.41.0-preview.1";
209436
+ GIT_COMMIT_INFO = "caa046641";
209437
+ CLI_VERSION = "0.42.0-nightly.20260501.gcaa046641";
209427
209438
  }
209428
209439
  });
209429
209440
 
@@ -280351,6 +280362,7 @@ var init_chatRecordingService = __esm({
280351
280362
  */
280352
280363
  async deleteSessionAndArtifacts(chatsDir, file, tempDir) {
280353
280364
  const filePath = path27.join(chatsDir, file);
280365
+ let fullSessionId;
280354
280366
  try {
280355
280367
  const CHUNK_SIZE = 4096;
280356
280368
  const buffer = Buffer.alloc(CHUNK_SIZE);
@@ -280359,31 +280371,66 @@ var init_chatRecordingService = __esm({
280359
280371
  try {
280360
280372
  fd = await fs35.promises.open(filePath, "r");
280361
280373
  const { bytesRead } = await fd.read(buffer, 0, CHUNK_SIZE, 0);
280362
- if (bytesRead === 0) {
280363
- await fd.close();
280364
- await fs35.promises.unlink(filePath);
280365
- return;
280374
+ if (bytesRead > 0) {
280375
+ const contentChunk = buffer.toString("utf8", 0, bytesRead);
280376
+ const newlineIndex = contentChunk.indexOf("\n");
280377
+ firstLine = newlineIndex !== -1 ? contentChunk.substring(0, newlineIndex) : contentChunk;
280378
+ try {
280379
+ const content = JSON.parse(firstLine);
280380
+ if (isSessionIdRecord(content)) {
280381
+ fullSessionId = content.sessionId;
280382
+ }
280383
+ } catch {
280384
+ }
280366
280385
  }
280367
- const contentChunk = buffer.toString("utf8", 0, bytesRead);
280368
- const newlineIndex = contentChunk.indexOf("\n");
280369
- firstLine = newlineIndex !== -1 ? contentChunk.substring(0, newlineIndex) : contentChunk;
280370
280386
  } finally {
280371
280387
  if (fd !== void 0) {
280372
280388
  await fd.close();
280373
280389
  }
280374
280390
  }
280375
- const content = JSON.parse(firstLine);
280376
- let fullSessionId;
280377
- if (isSessionIdRecord(content)) {
280378
- fullSessionId = content["sessionId"];
280391
+ if (!fullSessionId) {
280392
+ try {
280393
+ const fileContent = await fs35.promises.readFile(filePath, "utf8");
280394
+ const parsed = JSON.parse(fileContent);
280395
+ if (isSessionIdRecord(parsed)) {
280396
+ fullSessionId = parsed.sessionId;
280397
+ }
280398
+ } catch {
280399
+ }
280379
280400
  }
280380
- await fs35.promises.unlink(filePath);
280381
280401
  if (fullSessionId) {
280382
280402
  await deleteSessionArtifactsAsync(fullSessionId, tempDir);
280383
280403
  await deleteSubagentSessionDirAndArtifactsAsync(fullSessionId, chatsDir, tempDir);
280384
280404
  }
280385
280405
  } catch (error2) {
280386
- debugLogger.error(`Error deleting associated file ${file}:`, error2);
280406
+ debugLogger.error(`Error deleting artifacts for session file ${file}:`, error2);
280407
+ } finally {
280408
+ try {
280409
+ await fs35.promises.unlink(filePath);
280410
+ } catch (error2) {
280411
+ if (isNodeError(error2) && error2.code !== "ENOENT") {
280412
+ debugLogger.error(`Error unlinking session file ${file}:`, error2);
280413
+ }
280414
+ }
280415
+ }
280416
+ }
280417
+ /**
280418
+ * Asynchronously deletes the current session's chat file and tool outputs.
280419
+ * This encapsulates the session ID logic and uses non-blocking I/O to avoid
280420
+ * blocking the event loop on exit.
280421
+ */
280422
+ async deleteCurrentSessionAsync() {
280423
+ if (!this.conversationFile) {
280424
+ return;
280425
+ }
280426
+ try {
280427
+ const tempDir = this.context.config.storage.getProjectTempDir();
280428
+ await fs35.promises.unlink(this.conversationFile).catch(() => {
280429
+ });
280430
+ await deleteSessionArtifactsAsync(this.sessionId, tempDir);
280431
+ } catch (error2) {
280432
+ debugLogger.error("Error deleting current session.", error2);
280433
+ throw error2;
280387
280434
  }
280388
280435
  }
280389
280436
  /**
@@ -329384,7 +329431,7 @@ function getVersion() {
329384
329431
  }
329385
329432
  versionPromise = (async () => {
329386
329433
  const pkgJson = await getPackageJson(__dirname4);
329387
- return "0.41.0-preview.1";
329434
+ return "0.42.0-nightly.20260501.gcaa046641";
329388
329435
  })();
329389
329436
  return versionPromise;
329390
329437
  }
@@ -330218,14 +330265,36 @@ var init_errorClassification = __esm({
330218
330265
 
330219
330266
  // packages/core/dist/src/availability/policyCatalog.js
330220
330267
  function getModelPolicyChain(options) {
330268
+ const isAuto = options.isAutoSelection ?? false;
330221
330269
  if (options.previewEnabled) {
330222
- const previewModel = resolveModel(PREVIEW_GEMINI_MODEL, options.useGemini31, options.useGemini31FlashLite, options.useCustomToolModel);
330270
+ const proModel = resolveModel(PREVIEW_GEMINI_MODEL, options.useGemini31, options.useGemini31FlashLite, options.useCustomToolModel);
330223
330271
  return [
330224
- definePolicy({ model: previewModel }),
330225
- definePolicy({ model: PREVIEW_GEMINI_FLASH_MODEL, isLastResort: true })
330272
+ definePolicy({
330273
+ model: proModel,
330274
+ ...isAuto ? {
330275
+ maxAttempts: 3,
330276
+ actions: { ...DEFAULT_ACTIONS, transient: "silent" },
330277
+ stateTransitions: { ...DEFAULT_STATE, transient: "sticky_retry" }
330278
+ } : {}
330279
+ }),
330280
+ definePolicy({
330281
+ model: PREVIEW_GEMINI_FLASH_MODEL,
330282
+ isLastResort: true,
330283
+ maxAttempts: 10
330284
+ })
330226
330285
  ];
330227
330286
  }
330228
- return cloneChain(DEFAULT_CHAIN);
330287
+ return [
330288
+ definePolicy({
330289
+ model: DEFAULT_GEMINI_MODEL,
330290
+ ...isAuto ? AUTO_ROUTING_OVERRIDES : {}
330291
+ }),
330292
+ definePolicy({
330293
+ model: DEFAULT_GEMINI_FLASH_MODEL,
330294
+ isLastResort: true,
330295
+ maxAttempts: 10
330296
+ })
330297
+ ];
330229
330298
  }
330230
330299
  function createSingleModelChain(model) {
330231
330300
  return [definePolicy({ model, isLastResort: true })];
@@ -330240,6 +330309,7 @@ function definePolicy(config3) {
330240
330309
  return {
330241
330310
  model: config3.model,
330242
330311
  isLastResort: config3.isLastResort,
330312
+ maxAttempts: config3.maxAttempts,
330243
330313
  actions: { ...DEFAULT_ACTIONS, ...config3.actions ?? {} },
330244
330314
  stateTransitions: {
330245
330315
  ...DEFAULT_STATE,
@@ -330257,7 +330327,7 @@ function clonePolicy(policy) {
330257
330327
  function cloneChain(chain2) {
330258
330328
  return chain2.map(clonePolicy);
330259
330329
  }
330260
- var DEFAULT_ACTIONS, SILENT_ACTIONS, DEFAULT_STATE, DEFAULT_CHAIN, FLASH_LITE_CHAIN;
330330
+ var DEFAULT_ACTIONS, SILENT_ACTIONS, DEFAULT_STATE, AUTO_ROUTING_OVERRIDES, FLASH_LITE_CHAIN;
330261
330331
  var init_policyCatalog = __esm({
330262
330332
  "packages/core/dist/src/availability/policyCatalog.js"() {
330263
330333
  "use strict";
@@ -330276,14 +330346,18 @@ var init_policyCatalog = __esm({
330276
330346
  };
330277
330347
  DEFAULT_STATE = {
330278
330348
  terminal: "terminal",
330279
- transient: "sticky_retry",
330349
+ transient: "terminal",
330280
330350
  not_found: "terminal",
330281
330351
  unknown: "terminal"
330282
330352
  };
330283
- DEFAULT_CHAIN = [
330284
- definePolicy({ model: DEFAULT_GEMINI_MODEL }),
330285
- definePolicy({ model: DEFAULT_GEMINI_FLASH_MODEL, isLastResort: true })
330286
- ];
330353
+ AUTO_ROUTING_OVERRIDES = {
330354
+ maxAttempts: 3,
330355
+ actions: { ...DEFAULT_ACTIONS, transient: "silent" },
330356
+ stateTransitions: {
330357
+ ...DEFAULT_STATE,
330358
+ transient: "sticky_retry"
330359
+ }
330360
+ };
330287
330361
  FLASH_LITE_CHAIN = [
330288
330362
  definePolicy({
330289
330363
  model: DEFAULT_GEMINI_FLASH_LITE_MODEL,
@@ -330322,14 +330396,16 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
330322
330396
  };
330323
330397
  if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) {
330324
330398
  chain2 = config3.modelConfigService.resolveChain("lite", context2);
330325
- } else if (isGemini3Model(resolvedModel, config3) || isAutoModel(preferredModel ?? "", config3) || isAutoModel(configuredModel, config3)) {
330326
- if (isAutoModel(configuredModel, config3) && config3.modelConfigService.getModelChain(configuredModel)) {
330399
+ } else if (isGemini3Model(resolvedModel, config3) || isAutoPreferred || isAutoConfigured) {
330400
+ if (isAutoConfigured && config3.modelConfigService.getModelChain(configuredModel)) {
330327
330401
  chain2 = config3.modelConfigService.resolveChain(configuredModel, context2);
330328
330402
  }
330329
330403
  if (!chain2) {
330404
+ const isAutoSelection = isAutoPreferred || isAutoConfigured;
330330
330405
  const previewEnabled = hasAccessToPreview && (isGemini3Model(resolvedModel, config3) || preferredModel === PREVIEW_GEMINI_MODEL_AUTO || configuredModel === PREVIEW_GEMINI_MODEL_AUTO);
330406
+ const autoPrefix = isAutoSelection ? "auto-" : "";
330331
330407
  const chainKey = previewEnabled ? "preview" : "default";
330332
- chain2 = config3.modelConfigService.resolveChain(chainKey, context2);
330408
+ chain2 = config3.modelConfigService.resolveChain(`${autoPrefix}${chainKey}`, context2);
330333
330409
  }
330334
330410
  }
330335
330411
  if (!chain2) {
@@ -330340,10 +330416,12 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
330340
330416
  if (resolvedModel === DEFAULT_GEMINI_FLASH_LITE_MODEL) {
330341
330417
  chain2 = getFlashLitePolicyChain();
330342
330418
  } else if (isGemini3Model(resolvedModel, config3) || isAutoPreferred || isAutoConfigured) {
330419
+ const isAutoSelection = isAutoPreferred || isAutoConfigured;
330343
330420
  if (hasAccessToPreview) {
330344
330421
  const previewEnabled = isGemini3Model(resolvedModel, config3) || preferredModel === PREVIEW_GEMINI_MODEL_AUTO || configuredModel === PREVIEW_GEMINI_MODEL_AUTO;
330345
330422
  chain2 = getModelPolicyChain({
330346
330423
  previewEnabled,
330424
+ isAutoSelection,
330347
330425
  userTier: config3.getUserTier(),
330348
330426
  useGemini31,
330349
330427
  useGemini31FlashLite,
@@ -330352,6 +330430,7 @@ function resolvePolicyChain(config3, preferredModel, wrapsAround = false) {
330352
330430
  } else {
330353
330431
  chain2 = getModelPolicyChain({
330354
330432
  previewEnabled: false,
330433
+ isAutoSelection,
330355
330434
  userTier: config3.getUserTier(),
330356
330435
  useGemini31,
330357
330436
  useGemini31FlashLite,
@@ -330431,10 +330510,12 @@ function applyModelSelection(config3, modelConfigKey, options = {}) {
330431
330510
  if (selection.attempts && options.consumeAttempt !== false) {
330432
330511
  config3.getModelAvailabilityService().consumeStickyAttempt(finalModel);
330433
330512
  }
330513
+ const chain2 = resolvePolicyChain(config3, finalModel);
330514
+ const policy = chain2.find((p2) => p2.model === finalModel);
330434
330515
  return {
330435
330516
  model: finalModel,
330436
330517
  config: generateContentConfig,
330437
- maxAttempts: selection.attempts
330518
+ maxAttempts: selection.attempts ?? policy?.maxAttempts
330438
330519
  };
330439
330520
  }
330440
330521
  function applyAvailabilityTransition(getContext, failureKind) {
@@ -330447,7 +330528,8 @@ function applyAvailabilityTransition(getContext, failureKind) {
330447
330528
  if (transition === "terminal") {
330448
330529
  context2.service.markTerminal(context2.policy.model, failureKind === "terminal" ? "quota" : "capacity");
330449
330530
  } else if (transition === "sticky_retry") {
330450
- context2.service.markRetryOncePerTurn(context2.policy.model);
330531
+ context2.service.markRetryOncePerTurn(context2.policy.model, context2.policy.maxAttempts);
330532
+ context2.service.consumeStickyAttempt(context2.policy.model);
330451
330533
  }
330452
330534
  }
330453
330535
  var init_policyHelpers = __esm({
@@ -330752,6 +330834,7 @@ async function retryWithBackoff(fn2, options) {
330752
330834
  shouldRetryOnError: isRetryableError,
330753
330835
  ...cleanOptions
330754
330836
  };
330837
+ const getCurrentMaxAttempts = () => getAvailabilityContext?.()?.policy.maxAttempts ?? maxAttempts;
330755
330838
  let attempt = 0;
330756
330839
  let currentDelay = initialDelayMs;
330757
330840
  const throwIfAborted = () => {
@@ -330759,7 +330842,7 @@ async function retryWithBackoff(fn2, options) {
330759
330842
  throw createAbortError();
330760
330843
  }
330761
330844
  };
330762
- while (attempt < maxAttempts) {
330845
+ while (attempt < getCurrentMaxAttempts()) {
330763
330846
  if (signal?.aborted) {
330764
330847
  throw createAbortError();
330765
330848
  }
@@ -330823,7 +330906,7 @@ async function retryWithBackoff(fn2, options) {
330823
330906
  }
330824
330907
  const is500 = errorCode !== void 0 && errorCode >= 500 && errorCode < 600;
330825
330908
  if (classifiedError instanceof RetryableQuotaError || is500) {
330826
- if (attempt >= maxAttempts) {
330909
+ if (attempt >= getCurrentMaxAttempts()) {
330827
330910
  const errorMessage = classifiedError instanceof Error ? classifiedError.message : "";
330828
330911
  debugLogger.warn(`Attempt ${attempt} failed${errorMessage ? `: ${errorMessage}` : ""}. Max attempts reached`);
330829
330912
  if (onPersistent429) {
@@ -330864,7 +330947,7 @@ async function retryWithBackoff(fn2, options) {
330864
330947
  continue;
330865
330948
  }
330866
330949
  }
330867
- if (attempt >= maxAttempts || // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
330950
+ if (attempt >= getCurrentMaxAttempts() || // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
330868
330951
  !shouldRetryOnError(error2, retryFetchErrors)) {
330869
330952
  throw error2;
330870
330953
  }
@@ -330927,8 +331010,11 @@ var init_retry = __esm({
330927
331010
  "EAI_AGAIN",
330928
331011
  "ECONNREFUSED",
330929
331012
  "ERR_SSL_WRONG_VERSION_NUMBER",
330930
- "EPROTO"
331013
+ "EPROTO",
330931
331014
  // Generic protocol error (often SSL-related)
331015
+ "UND_ERR_HEADERS_TIMEOUT",
331016
+ "UND_ERR_BODY_TIMEOUT",
331017
+ "UND_ERR_CONNECT_TIMEOUT"
330932
331018
  ];
330933
331019
  RETRYABLE_SSL_ERROR_PATTERN = /^ERR_SSL_.*BAD_RECORD_MAC/i;
330934
331020
  FETCH_FAILED_MESSAGE = "fetch failed";
@@ -331077,7 +331163,7 @@ var init_baseLlmClient = __esm({
331077
331163
  authType: this.authType ?? this.config.getContentGeneratorConfig()?.authType,
331078
331164
  retryFetchErrors: this.config.getRetryFetchErrors(),
331079
331165
  onRetry: (attempt, error2, delayMs) => {
331080
- const actualMaxAttempts = availabilityMaxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS2;
331166
+ const actualMaxAttempts = getAvailabilityContext()?.policy.maxAttempts ?? maxAttempts ?? DEFAULT_MAX_ATTEMPTS2;
331081
331167
  const modelName = getDisplayString(currentModel);
331082
331168
  const errorType = getRetryErrorType(error2);
331083
331169
  coreEvents.emitRetryAttempt({
@@ -332896,24 +332982,26 @@ var init_telemetry2 = __esm({
332896
332982
  });
332897
332983
 
332898
332984
  // packages/core/dist/src/utils/channel.js
332985
+ function getChannelFromVersion(version4) {
332986
+ if (!version4 || version4.includes("nightly")) {
332987
+ return ReleaseChannel.NIGHTLY;
332988
+ }
332989
+ if (version4.includes("preview")) {
332990
+ return ReleaseChannel.PREVIEW;
332991
+ }
332992
+ return ReleaseChannel.STABLE;
332993
+ }
332899
332994
  async function getReleaseChannel(cwd) {
332900
332995
  if (cache.has(cwd)) {
332901
332996
  return cache.get(cwd);
332902
332997
  }
332903
332998
  const packageJson4 = await getPackageJson(cwd);
332904
332999
  const version4 = packageJson4?.version ?? "";
332905
- let channel;
332906
- if (version4.includes("nightly") || version4 === "") {
332907
- channel = ReleaseChannel.NIGHTLY;
332908
- } else if (version4.includes("preview")) {
332909
- channel = ReleaseChannel.PREVIEW;
332910
- } else {
332911
- channel = ReleaseChannel.STABLE;
332912
- }
333000
+ const channel = getChannelFromVersion(version4);
332913
333001
  cache.set(cwd, channel);
332914
333002
  return channel;
332915
333003
  }
332916
- var ReleaseChannel, cache;
333004
+ var ReleaseChannel, RELEASE_CHANNEL_STABILITY, cache;
332917
333005
  var init_channel = __esm({
332918
333006
  "packages/core/dist/src/utils/channel.js"() {
332919
333007
  "use strict";
@@ -332923,6 +333011,11 @@ var init_channel = __esm({
332923
333011
  ReleaseChannel2["PREVIEW"] = "preview";
332924
333012
  ReleaseChannel2["STABLE"] = "stable";
332925
333013
  })(ReleaseChannel || (ReleaseChannel = {}));
333014
+ RELEASE_CHANNEL_STABILITY = {
333015
+ [ReleaseChannel.NIGHTLY]: 0,
333016
+ [ReleaseChannel.PREVIEW]: 1,
333017
+ [ReleaseChannel.STABLE]: 2
333018
+ };
332926
333019
  cache = /* @__PURE__ */ new Map();
332927
333020
  }
332928
333021
  });
@@ -334245,15 +334338,11 @@ var init_recordingContentGenerator = __esm({
334245
334338
  // packages/core/dist/src/core/contentGenerator.js
334246
334339
  import * as os25 from "node:os";
334247
334340
  function validateBaseUrl(baseUrl) {
334248
- let url5;
334249
334341
  try {
334250
- url5 = new URL(baseUrl);
334342
+ new URL(baseUrl);
334251
334343
  } catch {
334252
334344
  throw new Error(`Invalid custom base URL: ${baseUrl}`);
334253
334345
  }
334254
- if (url5.protocol !== "https:" && !LOCAL_HOSTNAMES.includes(url5.hostname)) {
334255
- throw new Error("Custom base URL must use HTTPS unless it is localhost.");
334256
- }
334257
334346
  }
334258
334347
  async function createContentGeneratorConfig(config3, authType, apiKey, baseUrl, customHeaders, vertexAiRouting) {
334259
334348
  const geminiApiKey = apiKey || process.env["GEMINI_API_KEY"] || await loadApiKey() || void 0;
@@ -334383,7 +334472,7 @@ async function createContentGenerator(config3, gcConfig, sessionId) {
334383
334472
  }
334384
334473
  return generator;
334385
334474
  }
334386
- var AuthType2, LOCAL_HOSTNAMES, VERTEX_AI_REQUEST_TYPE_HEADER, VERTEX_AI_SHARED_REQUEST_TYPE_HEADER;
334475
+ var AuthType2, VERTEX_AI_REQUEST_TYPE_HEADER, VERTEX_AI_SHARED_REQUEST_TYPE_HEADER;
334387
334476
  var init_contentGenerator = __esm({
334388
334477
  "packages/core/dist/src/core/contentGenerator.js"() {
334389
334478
  "use strict";
@@ -334406,7 +334495,6 @@ var init_contentGenerator = __esm({
334406
334495
  AuthType3["COMPUTE_ADC"] = "compute-default-credentials";
334407
334496
  AuthType3["GATEWAY"] = "gateway";
334408
334497
  })(AuthType2 || (AuthType2 = {}));
334409
- LOCAL_HOSTNAMES = ["localhost", "127.0.0.1", "[::1]"];
334410
334498
  VERTEX_AI_REQUEST_TYPE_HEADER = "X-Vertex-AI-LLM-Request-Type";
334411
334499
  VERTEX_AI_SHARED_REQUEST_TYPE_HEADER = "X-Vertex-AI-LLM-Shared-Request-Type";
334412
334500
  }
@@ -344028,7 +344116,7 @@ var init_grep = __esm({
344028
344116
  const grepAvailable = await this.isCommandAvailable("grep");
344029
344117
  if (grepAvailable) {
344030
344118
  strategyUsed = "system grep";
344031
- const grepArgs = ["-r", "-n", "-H", "-E", "-I"];
344119
+ const grepArgs = ["-r", "-n", "-H", "-E", "-I", "-i"];
344032
344120
  const globExcludes = this.fileExclusions.getGlobExcludes();
344033
344121
  const commonExcludes = globExcludes.map((pattern2) => {
344034
344122
  let dir = pattern2;
@@ -357124,13 +357212,13 @@ function updateGlobalFetchTimeouts(timeoutMs) {
357124
357212
  if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
357125
357213
  throw new RangeError(`Invalid timeout value: ${timeoutMs}. Must be a positive finite number.`);
357126
357214
  }
357127
- defaultTimeout = timeoutMs;
357215
+ defaultHeadersTimeout = timeoutMs;
357128
357216
  if (currentProxy) {
357129
357217
  setGlobalProxy(currentProxy);
357130
357218
  } else {
357131
357219
  (0, import_undici2.setGlobalDispatcher)(new import_undici2.Agent({
357132
- headersTimeout: defaultTimeout,
357133
- bodyTimeout: defaultTimeout
357220
+ headersTimeout: defaultHeadersTimeout,
357221
+ bodyTimeout: defaultBodyTimeout
357134
357222
  }));
357135
357223
  }
357136
357224
  }
@@ -357201,11 +357289,11 @@ function setGlobalProxy(proxy2) {
357201
357289
  currentProxy = proxy2;
357202
357290
  (0, import_undici2.setGlobalDispatcher)(new import_undici2.ProxyAgent({
357203
357291
  uri: proxy2,
357204
- headersTimeout: defaultTimeout,
357205
- bodyTimeout: defaultTimeout
357292
+ headersTimeout: defaultHeadersTimeout,
357293
+ bodyTimeout: defaultBodyTimeout
357206
357294
  }));
357207
357295
  }
357208
- var import_undici2, import_ipaddr, FetchError2, defaultTimeout, currentProxy, IANA_BENCHMARK_RANGE;
357296
+ var import_undici2, import_ipaddr, FetchError2, defaultHeadersTimeout, defaultBodyTimeout, currentProxy, IANA_BENCHMARK_RANGE;
357209
357297
  var init_fetch = __esm({
357210
357298
  "packages/core/dist/src/utils/fetch.js"() {
357211
357299
  "use strict";
@@ -357220,11 +357308,12 @@ var init_fetch = __esm({
357220
357308
  this.name = "FetchError";
357221
357309
  }
357222
357310
  };
357223
- defaultTimeout = 3e5;
357311
+ defaultHeadersTimeout = 6e4;
357312
+ defaultBodyTimeout = 3e5;
357224
357313
  currentProxy = void 0;
357225
357314
  (0, import_undici2.setGlobalDispatcher)(new import_undici2.Agent({
357226
- headersTimeout: defaultTimeout,
357227
- bodyTimeout: defaultTimeout
357315
+ headersTimeout: defaultHeadersTimeout,
357316
+ bodyTimeout: defaultBodyTimeout
357228
357317
  }));
357229
357318
  IANA_BENCHMARK_RANGE = import_ipaddr.default.parseCIDR("198.18.0.0/15");
357230
357319
  }
@@ -364933,7 +365022,7 @@ ${options.planModeToolsList}
364933
365022
  - **Inquiries:** If the request is an **Inquiry** (e.g., "How does X work?"), answer directly. DO NOT create a plan.
364934
365023
  - **Directives:** If the request is a **Directive** (e.g., "Fix bug Y"), follow the workflow below.
364935
365024
  5. **Plan Storage:** Save plans as Markdown (.md) using descriptive filenames.
364936
- 6. **Direct Modification:** If asked to modify code, explain you are in Plan Mode and use ${formatToolName(EXIT_PLAN_MODE_TOOL_NAME)} to request approval.
365025
+ 6. **Direct Modification:** If asked to modify code, explain you are in Plan Mode and use the built-in ${formatToolName(EXIT_PLAN_MODE_TOOL_NAME)} tool to request approval. **CRITICAL: NEVER attempt to call this tool via ${formatToolName(SHELL_TOOL_NAME)}.**
364937
365026
  7. **Presenting Plan:** When seeking informal agreement on a plan, or any time the user asks to see the plan, you MUST output the full content of the plan in the chat response. This overrides the "Minimal Output" guideline.
364938
365027
 
364939
365028
  ## Planning Workflow
@@ -364957,7 +365046,7 @@ Write the implementation plan to \`${options.plansDir}/\`. The plan's structure
364957
365046
  - **Complex Tasks:** Include **Background & Motivation**, **Scope & Impact**, **Proposed Solution**, **Alternatives Considered**, a phased **Implementation Plan**, **Verification**, and **Migration & Rollback** strategies.${options.interactive ? "\n- **Alignment Check:** After drafting the plan, you MUST present it to the user in the chat (adhering to Rule 7 for presenting plans) to ensure alignment on the specific details. Ask for feedback or confirmation, and proceed to Step 4 (Review & Approval) once the user agrees with the detailed plan." : ""}
364958
365047
 
364959
365048
  ### 4. Review & Approval
364960
- ONLY use the ${formatToolName(EXIT_PLAN_MODE_TOOL_NAME)} tool to present the plan for formal approval AFTER you have reached an informal agreement with the user in the chat regarding the proposed strategy. When called, this tool will present the plan and ${options.interactive ? "formally request approval." : "begin implementation."}
365049
+ ONLY use the built-in ${formatToolName(EXIT_PLAN_MODE_TOOL_NAME)} tool to present the plan for formal approval AFTER you have reached an informal agreement with the user in the chat regarding the proposed strategy. **CRITICAL: NEVER attempt to call this tool via ${formatToolName(SHELL_TOOL_NAME)}.** When called, this tool will present the plan and ${options.interactive ? "formally request approval." : "begin implementation."}
364961
365050
 
364962
365051
  ${renderApprovedPlanSection(options.approvedPlanPath)}`.trim();
364963
365052
  }
@@ -365582,7 +365671,7 @@ ${options.planModeToolsList}
365582
365671
  - Save the implementation plan to the designated plans directory
365583
365672
 
365584
365673
  ### Phase 4: Review & Approval
365585
- - Present the plan and request approval for the finalized plan using the \`${EXIT_PLAN_MODE_TOOL_NAME}\` tool
365674
+ - Present the plan and request approval for the finalized plan using the built-in \`${EXIT_PLAN_MODE_TOOL_NAME}\` tool. **CRITICAL: NEVER attempt to call this tool via \`${SHELL_TOOL_NAME}\`.**
365586
365675
  - If plan is approved, you can begin implementation
365587
365676
  - If plan is rejected, address the feedback and iterate on the plan
365588
365677
 
@@ -369982,7 +370071,12 @@ function convertFrontmatterAuthToConfig(frontmatter) {
369982
370071
  client_secret: frontmatter.client_secret,
369983
370072
  scopes: frontmatter.scopes,
369984
370073
  authorization_url: frontmatter.authorization_url,
369985
- token_url: frontmatter.token_url
370074
+ token_url: frontmatter.token_url,
370075
+ issuer: frontmatter.issuer,
370076
+ audiences: frontmatter.audiences,
370077
+ redirect_uri: frontmatter.redirect_uri,
370078
+ token_param_name: frontmatter.token_param_name,
370079
+ registration_url: frontmatter.registration_url
369986
370080
  };
369987
370081
  default: {
369988
370082
  const exhaustive = frontmatter;
@@ -370048,7 +370142,12 @@ function markdownToAgentDefinition(markdown, metadata2) {
370048
370142
  clientSecret: config3.auth.client_secret,
370049
370143
  scopes: config3.auth.scopes,
370050
370144
  authorizationUrl: config3.auth.authorization_url,
370051
- tokenUrl: config3.auth.token_url
370145
+ tokenUrl: config3.auth.token_url,
370146
+ issuer: config3.auth.issuer,
370147
+ audiences: config3.auth.audiences,
370148
+ redirectUri: config3.auth.redirect_uri,
370149
+ tokenParamName: config3.auth.token_param_name,
370150
+ registrationUrl: config3.auth.registration_url
370052
370151
  };
370053
370152
  }
370054
370153
  }
@@ -370184,7 +370283,12 @@ var init_agentLoader = __esm({
370184
370283
  client_secret: external_exports.string().optional(),
370185
370284
  scopes: external_exports.array(external_exports.string()).optional(),
370186
370285
  authorization_url: external_exports.string().url().optional(),
370187
- token_url: external_exports.string().url().optional()
370286
+ token_url: external_exports.string().url().optional(),
370287
+ issuer: external_exports.string().url().optional(),
370288
+ audiences: external_exports.array(external_exports.string()).optional(),
370289
+ redirect_uri: external_exports.string().url().optional(),
370290
+ token_param_name: external_exports.string().optional(),
370291
+ registration_url: external_exports.string().url().optional()
370188
370292
  })
370189
370293
  ]).optional()
370190
370294
  });
@@ -370230,7 +370334,12 @@ var init_agentLoader = __esm({
370230
370334
  client_secret: external_exports.string().optional(),
370231
370335
  scopes: external_exports.array(external_exports.string()).optional(),
370232
370336
  authorization_url: external_exports.string().url().optional(),
370233
- token_url: external_exports.string().url().optional()
370337
+ token_url: external_exports.string().url().optional(),
370338
+ issuer: external_exports.string().url().optional(),
370339
+ audiences: external_exports.array(external_exports.string()).optional(),
370340
+ redirect_uri: external_exports.string().url().optional(),
370341
+ token_param_name: external_exports.string().optional(),
370342
+ registration_url: external_exports.string().url().optional()
370234
370343
  });
370235
370344
  authConfigSchema = external_exports.discriminatedUnion("type", [
370236
370345
  apiKeyAuthSchema,
@@ -384887,7 +384996,7 @@ var init_a2aUtils = __esm({
384887
384996
  if (message.role === "user")
384888
384997
  return;
384889
384998
  const text = extractPartsText(message.parts, "");
384890
- if (text && this.messageLog[this.messageLog.length - 1] !== text) {
384999
+ if (text && this.messageLog.at(-1) !== text) {
384891
385000
  this.messageLog.push(text);
384892
385001
  }
384893
385002
  }
@@ -393213,7 +393322,7 @@ var init_modelAvailabilityService = __esm({
393213
393322
  markHealthy(model) {
393214
393323
  this.clearState(model);
393215
393324
  }
393216
- markRetryOncePerTurn(model) {
393325
+ markRetryOncePerTurn(model, attempts = 1) {
393217
393326
  const currentState = this.health.get(model);
393218
393327
  if (currentState?.status === "terminal") {
393219
393328
  return;
@@ -393225,7 +393334,8 @@ var init_modelAvailabilityService = __esm({
393225
393334
  this.setState(model, {
393226
393335
  status: "sticky_retry",
393227
393336
  reason: "retry_once_per_turn",
393228
- consumed
393337
+ consumed,
393338
+ attempts
393229
393339
  });
393230
393340
  }
393231
393341
  consumeStickyAttempt(model) {
@@ -393253,7 +393363,7 @@ var init_modelAvailabilityService = __esm({
393253
393363
  const snapshot = this.snapshot(model);
393254
393364
  if (snapshot.available) {
393255
393365
  const state = this.health.get(model);
393256
- const attempts = state?.status === "sticky_retry" ? 1 : void 0;
393366
+ const attempts = state?.status === "sticky_retry" ? state.attempts : void 0;
393257
393367
  return { selectedModel: model, skipped, attempts };
393258
393368
  } else {
393259
393369
  skipped.push({ model, reason: snapshot.reason ?? "unknown" });
@@ -394596,7 +394706,7 @@ var init_defaultModelConfigs = __esm({
394596
394706
  },
394597
394707
  stateTransitions: {
394598
394708
  terminal: "terminal",
394599
- transient: "sticky_retry",
394709
+ transient: "terminal",
394600
394710
  not_found: "terminal",
394601
394711
  unknown: "terminal"
394602
394712
  }
@@ -394604,18 +394714,54 @@ var init_defaultModelConfigs = __esm({
394604
394714
  {
394605
394715
  model: "gemini-3-flash-preview",
394606
394716
  isLastResort: true,
394717
+ maxAttempts: 10,
394607
394718
  actions: {
394608
394719
  terminal: "prompt",
394609
394720
  transient: "prompt",
394610
394721
  not_found: "prompt",
394611
394722
  unknown: "prompt"
394612
394723
  },
394724
+ stateTransitions: {
394725
+ terminal: "terminal",
394726
+ transient: "terminal",
394727
+ not_found: "terminal",
394728
+ unknown: "terminal"
394729
+ }
394730
+ }
394731
+ ],
394732
+ "auto-preview": [
394733
+ {
394734
+ model: "gemini-3-pro-preview",
394735
+ maxAttempts: 3,
394736
+ actions: {
394737
+ terminal: "prompt",
394738
+ transient: "silent",
394739
+ not_found: "prompt",
394740
+ unknown: "prompt"
394741
+ },
394613
394742
  stateTransitions: {
394614
394743
  terminal: "terminal",
394615
394744
  transient: "sticky_retry",
394616
394745
  not_found: "terminal",
394617
394746
  unknown: "terminal"
394618
394747
  }
394748
+ },
394749
+ {
394750
+ model: "gemini-3-flash-preview",
394751
+ isLastResort: true,
394752
+ maxAttempts: 10,
394753
+ actions: {
394754
+ terminal: "prompt",
394755
+ transient: "prompt",
394756
+ not_found: "prompt",
394757
+ unknown: "prompt"
394758
+ },
394759
+ stateTransitions: {
394760
+ terminal: "terminal",
394761
+ transient: "terminal",
394762
+ not_found: "terminal",
394763
+ unknown: "terminal"
394764
+ }
394619
394765
  }
394620
394766
  ],
394621
394767
  default: [
@@ -394637,18 +394783,54 @@ var init_defaultModelConfigs = __esm({
394637
394783
  {
394638
394784
  model: "gemini-2.5-flash",
394639
394785
  isLastResort: true,
394786
+ maxAttempts: 10,
394640
394787
  actions: {
394641
394788
  terminal: "prompt",
394642
394789
  transient: "prompt",
394643
394790
  not_found: "prompt",
394644
394791
  unknown: "prompt"
394645
394792
  },
394793
+ stateTransitions: {
394794
+ terminal: "terminal",
394795
+ transient: "terminal",
394796
+ not_found: "terminal",
394797
+ unknown: "terminal"
394798
+ }
394799
+ }
394800
+ ],
394801
+ "auto-default": [
394802
+ {
394803
+ model: "gemini-2.5-pro",
394804
+ maxAttempts: 3,
394805
+ actions: {
394806
+ terminal: "prompt",
394807
+ transient: "silent",
394808
+ not_found: "prompt",
394809
+ unknown: "prompt"
394810
+ },
394646
394811
  stateTransitions: {
394647
394812
  terminal: "terminal",
394648
394813
  transient: "sticky_retry",
394649
394814
  not_found: "terminal",
394650
394815
  unknown: "terminal"
394651
394816
  }
394817
+ },
394818
+ {
394819
+ model: "gemini-2.5-flash",
394820
+ isLastResort: true,
394821
+ maxAttempts: 10,
394822
+ actions: {
394823
+ terminal: "prompt",
394824
+ transient: "prompt",
394825
+ not_found: "prompt",
394826
+ unknown: "prompt"
394827
+ },
394828
+ stateTransitions: {
394829
+ terminal: "terminal",
394830
+ transient: "terminal",
394831
+ not_found: "terminal",
394832
+ unknown: "terminal"
394833
+ }
394652
394834
  }
394653
394835
  ],
394654
394836
  lite: [
@@ -394662,7 +394844,7 @@ var init_defaultModelConfigs = __esm({
394662
394844
  },
394663
394845
  stateTransitions: {
394664
394846
  terminal: "terminal",
394665
- transient: "sticky_retry",
394847
+ transient: "terminal",
394666
394848
  not_found: "terminal",
394667
394849
  unknown: "terminal"
394668
394850
  }
@@ -394677,7 +394859,7 @@ var init_defaultModelConfigs = __esm({
394677
394859
  },
394678
394860
  stateTransitions: {
394679
394861
  terminal: "terminal",
394680
- transient: "sticky_retry",
394862
+ transient: "terminal",
394681
394863
  not_found: "terminal",
394682
394864
  unknown: "terminal"
394683
394865
  }
@@ -394693,7 +394875,7 @@ var init_defaultModelConfigs = __esm({
394693
394875
  },
394694
394876
  stateTransitions: {
394695
394877
  terminal: "terminal",
394696
- transient: "sticky_retry",
394878
+ transient: "terminal",
394697
394879
  not_found: "terminal",
394698
394880
  unknown: "terminal"
394699
394881
  }
@@ -395141,12 +395323,17 @@ async function readGeminiMdFiles(filePaths, importFormat = "tree", boundaryMarke
395141
395323
  debugLogger.debug("[DEBUG] [MemoryDiscovery] Successfully read and processed imports:", filePath, `(Length: ${processedResult.content.length})`);
395142
395324
  return { filePath, content: processedResult.content };
395143
395325
  } catch (error2) {
395144
- const isTestEnv = process.env["VITEST"];
395145
- if (!isTestEnv) {
395146
- const message = error2 instanceof Error ? error2.message : String(error2);
395147
- logger6.warn(`Warning: Could not read ${getAllGeminiMdFilenames()} file at ${filePath}. Error: ${message}`);
395326
+ const isEISDIR = error2 instanceof Error && error2.code === "EISDIR";
395327
+ if (isEISDIR) {
395328
+ debugLogger.debug("[DEBUG] [MemoryDiscovery] Skipping directory at GEMINI.md path:", filePath);
395329
+ } else {
395330
+ const isTestEnv = process.env["VITEST"];
395331
+ if (!isTestEnv) {
395332
+ const message = error2 instanceof Error ? error2.message : String(error2);
395333
+ logger6.warn(`Warning: Could not read ${getAllGeminiMdFilenames()} file at ${filePath}. Error: ${message}`);
395334
+ }
395335
+ debugLogger.debug("[DEBUG] [MemoryDiscovery] Failed to read:", filePath);
395148
395336
  }
395149
- debugLogger.debug("[DEBUG] [MemoryDiscovery] Failed to read:", filePath);
395150
395337
  return { filePath, content: null };
395151
395338
  }
395152
395339
  });
@@ -402489,12 +402676,13 @@ var init_mcp_client_manager = __esm({
402489
402676
  await Promise.all(Object.keys(extension.mcpServers ?? {}).map((name3) => {
402490
402677
  const config3 = this.allServerConfigs.get(name3);
402491
402678
  if (config3?.extension?.id === extension.id) {
402679
+ const clientKey = this.getClientKey(name3, config3);
402492
402680
  this.allServerConfigs.delete(name3);
402493
402681
  const index = this.blockedMcpServers.findIndex((s5) => s5.name === name3 && s5.extensionName === extension.name);
402494
402682
  if (index !== -1) {
402495
402683
  this.blockedMcpServers.splice(index, 1);
402496
402684
  }
402497
- return this.disconnectClient(name3, true);
402685
+ return this.disconnectClient(clientKey, true);
402498
402686
  }
402499
402687
  return Promise.resolve();
402500
402688
  }));