@google/gemini-cli 0.64.0-preview.0 → 0.65.0-nightly.20261008.g44d764ee5

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 (72) hide show
  1. package/bundle/{chunk-2NQXIWQK.js → chunk-3E6LR7PD.js} +32 -4
  2. package/bundle/{chunk-EBP6K2WG.js → chunk-3HM2DUPL.js} +50 -18
  3. package/bundle/{chunk-HSZIYPL6.js → chunk-4YOFVKC3.js} +3 -3
  4. package/bundle/{chunk-KCCVXZ52.js → chunk-63N5Z55Y.js} +114 -69
  5. package/bundle/{chunk-UFQDAROY.js → chunk-7BGM6KG2.js} +1 -1
  6. package/bundle/{chunk-EDYPRCAA.js → chunk-7PODN7KW.js} +2 -2
  7. package/bundle/{chunk-ZQW7OGUO.js → chunk-ARJWMIGO.js} +628 -124
  8. package/bundle/{chunk-U76XPSKR.js → chunk-AUU7WOFW.js} +50 -18
  9. package/bundle/{chunk-SDWOC67Z.js → chunk-BA5YFKKS.js} +1 -1
  10. package/bundle/{chunk-UBGF6JU5.js → chunk-BIHX2DZB.js} +1 -1
  11. package/bundle/{chunk-HN74ORTP.js → chunk-EZGM7WCW.js} +32 -4
  12. package/bundle/{chunk-NX7TO2DU.js → chunk-G73R7Q4K.js} +1 -1
  13. package/bundle/{chunk-EFX5XL6M.js → chunk-HN32MQMG.js} +2 -2
  14. package/bundle/{chunk-VBVCLWLA.js → chunk-HRPULK65.js} +2 -2
  15. package/bundle/{chunk-A4TO2DY2.js → chunk-IL5DA7Y5.js} +8460 -14960
  16. package/bundle/{chunk-2VN53SWW.js → chunk-IUZHBNL5.js} +9 -8
  17. package/bundle/{chunk-EDVFNWRG.js → chunk-JPVUKQJ7.js} +1 -1
  18. package/bundle/{chunk-QUCRASYB.js → chunk-LGG27U7G.js} +1 -1
  19. package/bundle/{chunk-MLSLNORV.js → chunk-MV5ZEQKH.js} +3 -3
  20. package/bundle/chunk-PFU4B5QN.js +154 -0
  21. package/bundle/{chunk-ZPLFLZQA.js → chunk-PPUDMLP4.js} +38 -8
  22. package/bundle/{chunk-VJYKQD5D.js → chunk-Q2G3IFID.js} +3 -3
  23. package/bundle/chunk-Q6FM3IBA.js +512 -0
  24. package/bundle/chunk-RUV5VETL.js +17535 -0
  25. package/bundle/chunk-SQDLQBAY.js +118 -0
  26. package/bundle/chunk-UB5UMEXC.js +401700 -0
  27. package/bundle/{chunk-ZOHM7BPT.js → chunk-UCDMKAAW.js} +1 -1
  28. package/bundle/{chunk-Y2HXXBXI.js → chunk-XDI7ON7P.js} +1 -1
  29. package/bundle/{chunk-6OFXOGEG.js → chunk-XMBLOFHQ.js} +667 -128
  30. package/bundle/chunk-YMVWBWWO.js +1571 -0
  31. package/bundle/chunk-ZCMBTRVW.js +425 -0
  32. package/bundle/chunk-ZQB4PBVQ.js +103153 -0
  33. package/bundle/{cleanup-GGCB2LVD.js → cleanup-333PJ32W.js} +2 -2
  34. package/bundle/{cleanup-JRDG3OTL.js → cleanup-FAR6AR3H.js} +2 -2
  35. package/bundle/{cleanup-SSW6IXTR.js → cleanup-GL3Y6D27.js} +2 -2
  36. package/bundle/cleanup-JB3GTDPK.js +32 -0
  37. package/bundle/{core-IUIZE6JW.js → core-4FIJ3NBL.js} +13 -1
  38. package/bundle/{devtoolsService-3SADPKKB.js → devtoolsService-2WM4AKWJ.js} +2 -2
  39. package/bundle/{devtoolsService-XZCKFZP5.js → devtoolsService-3VV6G7M6.js} +2 -2
  40. package/bundle/{devtoolsService-MF6JKRUV.js → devtoolsService-4Q6IMJZW.js} +4 -3
  41. package/bundle/devtoolsService-MNAMTUTD.js +4359 -0
  42. package/bundle/{dist-7L3BRW6V.js → dist-B6O7SDYJ.js} +13 -1
  43. package/bundle/{core-6HRWFQZW.js → dist-BBUYPVDB.js} +13 -1
  44. package/bundle/dist-HG6AYV4Z.js +2264 -0
  45. package/bundle/docs/changelogs/index.md +14 -0
  46. package/bundle/docs/changelogs/latest.md +55 -34
  47. package/bundle/docs/changelogs/preview.md +59 -54
  48. package/bundle/docs/cli/telemetry.md +1 -0
  49. package/bundle/docs/reference/configuration.md +7 -0
  50. package/bundle/docs/tools/mcp-server.md +41 -12
  51. package/bundle/{gemini-JPMMQ3KA.js → gemini-3RQKEPRX.js} +41 -21
  52. package/bundle/{gemini-QOQNG5VY.js → gemini-O5W6WLU3.js} +241 -205
  53. package/bundle/gemini-PE5RKGLA.js +17954 -0
  54. package/bundle/{gemini-ZMMDUAQJ.js → gemini-TZNM5EXD.js} +41 -21
  55. package/bundle/gemini.js +7 -7
  56. package/bundle/{interactiveCli-UDWGRVJL.js → interactiveCli-EY52EA4C.js} +50 -32
  57. package/bundle/{interactiveCli-3I4TG5SK.js → interactiveCli-P4I2OMIO.js} +354 -317
  58. package/bundle/{interactiveCli-R3P4A3FC.js → interactiveCli-PGWKO5T6.js} +50 -32
  59. package/bundle/interactiveCli-T2TOLST3.js +34997 -0
  60. package/bundle/{liteRtServerManager-OVPUSK2T.js → liteRtServerManager-52LZHRIE.js} +4 -4
  61. package/bundle/{liteRtServerManager-RAV63AGE.js → liteRtServerManager-GG66IH7W.js} +4 -4
  62. package/bundle/{liteRtServerManager-4MWCEVVM.js → liteRtServerManager-TAPI266B.js} +4 -4
  63. package/bundle/liteRtServerManager-ZMK3WM5V.js +65 -0
  64. package/bundle/{oauth2-provider-FVTRRJZR.js → oauth2-provider-7PEUKPJH.js} +47 -9
  65. package/bundle/{oauth2-provider-XFP63FGJ.js → oauth2-provider-EU3BXPHB.js} +84 -80
  66. package/bundle/oauth2-provider-JB36DOZE.js +273 -0
  67. package/bundle/{oauth2-provider-EWOA64PR.js → oauth2-provider-W7KEN635.js} +51 -9
  68. package/bundle/{start-DJAIXPPY.js → start-2D4TOWA4.js} +6 -6
  69. package/bundle/{start-VQQ2Q5KT.js → start-G7MFP7R2.js} +6 -6
  70. package/bundle/{start-5O7TBK5L.js → start-VJAR6RFJ.js} +6 -6
  71. package/bundle/start-VWUPOWW5.js +18 -0
  72. package/package.json +1 -1
@@ -42665,7 +42665,7 @@ var require_metadata3 = __commonJS({
42665
42665
  }
42666
42666
  }
42667
42667
  }
42668
- var Metadata2 = class _Metadata {
42668
+ var Metadata3 = class _Metadata {
42669
42669
  constructor(options = {}) {
42670
42670
  this.internalRepr = /* @__PURE__ */ new Map();
42671
42671
  this.opaqueData = /* @__PURE__ */ new Map();
@@ -42857,7 +42857,7 @@ var require_metadata3 = __commonJS({
42857
42857
  return result2;
42858
42858
  }
42859
42859
  };
42860
- exports2.Metadata = Metadata2;
42860
+ exports2.Metadata = Metadata3;
42861
42861
  var bufToString = (val) => {
42862
42862
  return Buffer.isBuffer(val) ? val.toString("base64") : val;
42863
42863
  };
@@ -66504,10 +66504,10 @@ var require_grpc_exporter_transport = __commonJS({
66504
66504
  exports2.createSslCredentials = createSslCredentials;
66505
66505
  function createEmptyMetadata() {
66506
66506
  const {
66507
- Metadata: Metadata2
66507
+ Metadata: Metadata3
66508
66508
  // eslint-disable-next-line @typescript-eslint/no-require-imports
66509
66509
  } = require_src15();
66510
- return new Metadata2();
66510
+ return new Metadata3();
66511
66511
  }
66512
66512
  exports2.createEmptyMetadata = createEmptyMetadata;
66513
66513
  var GrpcExporterTransport = class {
@@ -67286,9 +67286,9 @@ var require_otlp_grpc_env_configuration = __commonJS({
67286
67286
  if (Object.keys(signalSpecificHeaders).length === 0 && Object.keys(nonSignalSpecificHeaders).length === 0) {
67287
67287
  return void 0;
67288
67288
  }
67289
- const mergeHeaders2 = Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders);
67289
+ const mergeHeaders3 = Object.assign({}, nonSignalSpecificHeaders, signalSpecificHeaders);
67290
67290
  const metadata2 = (0, grpc_exporter_transport_1.createEmptyMetadata)();
67291
- for (const [key, value] of Object.entries(mergeHeaders2)) {
67291
+ for (const [key, value] of Object.entries(mergeHeaders3)) {
67292
67292
  metadata2.set(key, value);
67293
67293
  }
67294
67294
  return metadata2;
@@ -145466,8 +145466,8 @@ var require_grpc = __commonJS({
145466
145466
  return grpcPackage;
145467
145467
  }
145468
145468
  metadataBuilder(headers) {
145469
- const Metadata2 = this.grpc.Metadata;
145470
- const baseMetadata = new Metadata2();
145469
+ const Metadata3 = this.grpc.Metadata;
145470
+ const baseMetadata = new Metadata3();
145471
145471
  for (const key in headers) {
145472
145472
  const value = headers[key];
145473
145473
  if (Array.isArray(value)) {
@@ -211016,7 +211016,7 @@ var require_util20 = __commonJS({
211016
211016
  return true;
211017
211017
  }
211018
211018
  var headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
211019
- function isValidHeaderValue(characters) {
211019
+ function isValidHeaderValue2(characters) {
211020
211020
  return !headerCharRegex.test(characters);
211021
211021
  }
211022
211022
  var rangeHeaderRegex = /^bytes (\d+)-(\d+)\/(\d+)?$/;
@@ -211152,7 +211152,7 @@ var require_util20 = __commonJS({
211152
211152
  serializePathWithQuery,
211153
211153
  addAbortListener: addAbortListener3,
211154
211154
  isValidHTTPToken,
211155
- isValidHeaderValue,
211155
+ isValidHeaderValue: isValidHeaderValue2,
211156
211156
  isTokenCharCode,
211157
211157
  parseRangeHeader,
211158
211158
  normalizedMethodRecordsBase,
@@ -211412,7 +211412,7 @@ var require_request = __commonJS({
211412
211412
  var assert3 = __require("node:assert");
211413
211413
  var {
211414
211414
  isValidHTTPToken,
211415
- isValidHeaderValue,
211415
+ isValidHeaderValue: isValidHeaderValue2,
211416
211416
  isStream: isStream4,
211417
211417
  destroy,
211418
211418
  isBuffer,
@@ -211673,7 +211673,7 @@ var require_request = __commonJS({
211673
211673
  const arr = [];
211674
211674
  for (let i3 = 0; i3 < val.length; i3++) {
211675
211675
  if (typeof val[i3] === "string") {
211676
- if (!isValidHeaderValue(val[i3])) {
211676
+ if (!isValidHeaderValue2(val[i3])) {
211677
211677
  throw new InvalidArgumentError(`invalid ${key} header`);
211678
211678
  }
211679
211679
  arr.push(val[i3]);
@@ -211687,7 +211687,7 @@ var require_request = __commonJS({
211687
211687
  }
211688
211688
  val = arr;
211689
211689
  } else if (typeof val === "string") {
211690
- if (!isValidHeaderValue(val)) {
211690
+ if (!isValidHeaderValue2(val)) {
211691
211691
  throw new InvalidArgumentError(`invalid ${key} header`);
211692
211692
  }
211693
211693
  } else if (val === null) {
@@ -213941,7 +213941,7 @@ var require_util21 = __commonJS({
213941
213941
  return null;
213942
213942
  }
213943
213943
  let location = response.headersList.get("location", true);
213944
- if (location !== null && isValidHeaderValue(location)) {
213944
+ if (location !== null && isValidHeaderValue2(location)) {
213945
213945
  if (!isValidEncodedURL(location)) {
213946
213946
  location = normalizeBinaryStringToUtf8(location);
213947
213947
  }
@@ -213989,8 +213989,8 @@ var require_util21 = __commonJS({
213989
213989
  }
213990
213990
  return true;
213991
213991
  }
213992
- var isValidHeaderName = isValidHTTPToken;
213993
- function isValidHeaderValue(potentialValue) {
213992
+ var isValidHeaderName2 = isValidHTTPToken;
213993
+ function isValidHeaderValue2(potentialValue) {
213994
213994
  return (potentialValue[0] === " " || potentialValue[0] === " " || potentialValue[potentialValue.length - 1] === " " || potentialValue[potentialValue.length - 1] === " " || potentialValue.includes("\n") || potentialValue.includes("\r") || potentialValue.includes("\0")) === false;
213995
213995
  }
213996
213996
  function parseReferrerPolicy(actualResponse) {
@@ -214783,8 +214783,8 @@ var require_util21 = __commonJS({
214783
214783
  serializeJavascriptValueToJSONString,
214784
214784
  iteratorMixin,
214785
214785
  createIterator,
214786
- isValidHeaderName,
214787
- isValidHeaderValue,
214786
+ isValidHeaderName: isValidHeaderName2,
214787
+ isValidHeaderValue: isValidHeaderValue2,
214788
214788
  isErrorLike,
214789
214789
  fullyReadBody,
214790
214790
  bytesMatch,
@@ -223806,8 +223806,8 @@ var require_headers = __commonJS({
223806
223806
  var { kEnumerableProperty } = require_util20();
223807
223807
  var {
223808
223808
  iteratorMixin,
223809
- isValidHeaderName,
223810
- isValidHeaderValue
223809
+ isValidHeaderName: isValidHeaderName2,
223810
+ isValidHeaderValue: isValidHeaderValue2
223811
223811
  } = require_util21();
223812
223812
  var { webidl } = require_webidl();
223813
223813
  var assert3 = __require("node:assert");
@@ -223849,13 +223849,13 @@ var require_headers = __commonJS({
223849
223849
  }
223850
223850
  function appendHeader(headers, name3, value) {
223851
223851
  value = headerValueNormalize(value);
223852
- if (!isValidHeaderName(name3)) {
223852
+ if (!isValidHeaderName2(name3)) {
223853
223853
  throw webidl.errors.invalidArgument({
223854
223854
  prefix: "Headers.append",
223855
223855
  value: name3,
223856
223856
  type: "header name"
223857
223857
  });
223858
- } else if (!isValidHeaderValue(value)) {
223858
+ } else if (!isValidHeaderValue2(value)) {
223859
223859
  throw webidl.errors.invalidArgument({
223860
223860
  prefix: "Headers.append",
223861
223861
  value,
@@ -224100,7 +224100,7 @@ var require_headers = __commonJS({
224100
224100
  webidl.argumentLengthCheck(arguments, 1, "Headers.delete");
224101
224101
  const prefix = "Headers.delete";
224102
224102
  name3 = webidl.converters.ByteString(name3, prefix, "name");
224103
- if (!isValidHeaderName(name3)) {
224103
+ if (!isValidHeaderName2(name3)) {
224104
224104
  throw webidl.errors.invalidArgument({
224105
224105
  prefix: "Headers.delete",
224106
224106
  value: name3,
@@ -224121,7 +224121,7 @@ var require_headers = __commonJS({
224121
224121
  webidl.argumentLengthCheck(arguments, 1, "Headers.get");
224122
224122
  const prefix = "Headers.get";
224123
224123
  name3 = webidl.converters.ByteString(name3, prefix, "name");
224124
- if (!isValidHeaderName(name3)) {
224124
+ if (!isValidHeaderName2(name3)) {
224125
224125
  throw webidl.errors.invalidArgument({
224126
224126
  prefix,
224127
224127
  value: name3,
@@ -224136,7 +224136,7 @@ var require_headers = __commonJS({
224136
224136
  webidl.argumentLengthCheck(arguments, 1, "Headers.has");
224137
224137
  const prefix = "Headers.has";
224138
224138
  name3 = webidl.converters.ByteString(name3, prefix, "name");
224139
- if (!isValidHeaderName(name3)) {
224139
+ if (!isValidHeaderName2(name3)) {
224140
224140
  throw webidl.errors.invalidArgument({
224141
224141
  prefix,
224142
224142
  value: name3,
@@ -224153,13 +224153,13 @@ var require_headers = __commonJS({
224153
224153
  name3 = webidl.converters.ByteString(name3, prefix, "name");
224154
224154
  value = webidl.converters.ByteString(value, prefix, "value");
224155
224155
  value = headerValueNormalize(value);
224156
- if (!isValidHeaderName(name3)) {
224156
+ if (!isValidHeaderName2(name3)) {
224157
224157
  throw webidl.errors.invalidArgument({
224158
224158
  prefix,
224159
224159
  value: name3,
224160
224160
  type: "header name"
224161
224161
  });
224162
- } else if (!isValidHeaderValue(value)) {
224162
+ } else if (!isValidHeaderValue2(value)) {
224163
224163
  throw webidl.errors.invalidArgument({
224164
224164
  prefix,
224165
224165
  value,
@@ -226539,7 +226539,7 @@ var require_util22 = __commonJS({
226539
226539
  "use strict";
226540
226540
  var assert3 = __require("node:assert");
226541
226541
  var { URLSerializer } = require_data_url();
226542
- var { isValidHeaderName } = require_util21();
226542
+ var { isValidHeaderName: isValidHeaderName2 } = require_util21();
226543
226543
  function urlEquals(A, B, excludeFragment = false) {
226544
226544
  const serializedA = URLSerializer(A, excludeFragment);
226545
226545
  const serializedB = URLSerializer(B, excludeFragment);
@@ -226550,7 +226550,7 @@ var require_util22 = __commonJS({
226550
226550
  const values = [];
226551
226551
  for (let value of header.split(",")) {
226552
226552
  value = value.trim();
226553
- if (isValidHeaderName(value)) {
226553
+ if (isValidHeaderName2(value)) {
226554
226554
  values.push(value);
226555
226555
  }
226556
226556
  }
@@ -280365,6 +280365,7 @@ var import_exporter_trace_otlp_http = __toESM(require_src24(), 1);
280365
280365
  var import_exporter_logs_otlp_http = __toESM(require_src25(), 1);
280366
280366
  var import_exporter_metrics_otlp_http = __toESM(require_src22(), 1);
280367
280367
  init_esm3();
280368
+ var import_grpc_js = __toESM(require_src15(), 1);
280368
280369
  var import_sdk_node = __toESM(require_src39(), 1);
280369
280370
  init_esm2();
280370
280371
  var import_resources = __toESM(require_src17(), 1);
@@ -283529,8 +283530,8 @@ function isValidToolName(name3, options = {}) {
283529
283530
  }
283530
283531
 
283531
283532
  // packages/core/dist/src/generated/git-commit.js
283532
- var GIT_COMMIT_INFO = "fb972b2f8";
283533
- var CLI_VERSION = "0.64.0-preview.0";
283533
+ var GIT_COMMIT_INFO = "44d764ee5";
283534
+ var CLI_VERSION = "0.65.0-nightly.20261008.g44d764ee5";
283534
283535
 
283535
283536
  // packages/core/dist/src/ide/detect-ide.js
283536
283537
  var IDE_DEFINITIONS = {
@@ -285545,36 +285546,193 @@ function parseTelemetryTargetValue(value) {
285545
285546
  }
285546
285547
  return void 0;
285547
285548
  }
285549
+ var HEADER_NAME_REGEX = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
285550
+ function isValidHeaderName(name3) {
285551
+ const lower = name3.toLowerCase();
285552
+ return HEADER_NAME_REGEX.test(name3) && lower !== "__proto__" && lower !== "constructor" && lower !== "prototype";
285553
+ }
285554
+ function isValidHeaderValue(value) {
285555
+ for (let i3 = 0; i3 < value.length; i3++) {
285556
+ const code = value.charCodeAt(i3);
285557
+ if (code < 32 && code !== 9 || code === 127) {
285558
+ return false;
285559
+ }
285560
+ }
285561
+ return true;
285562
+ }
285563
+ function stripQuotes(value) {
285564
+ if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
285565
+ return value.slice(1, -1);
285566
+ }
285567
+ return value;
285568
+ }
285569
+ var ALLOWED_TELEMETRY_ENV_KEYS = /* @__PURE__ */ new Set([
285570
+ "GEMINI_TELEMETRY_ENABLED",
285571
+ "GEMINI_TELEMETRY_TRACES_ENABLED",
285572
+ "GEMINI_TELEMETRY_TARGET",
285573
+ "GEMINI_TELEMETRY_OTLP_ENDPOINT",
285574
+ "OTEL_EXPORTER_OTLP_ENDPOINT",
285575
+ "GEMINI_TELEMETRY_OTLP_PROTOCOL",
285576
+ "GEMINI_TELEMETRY_OTLP_HEADERS",
285577
+ "OTEL_EXPORTER_OTLP_HEADERS",
285578
+ "GEMINI_TELEMETRY_LOG_PROMPTS",
285579
+ "GEMINI_TELEMETRY_OUTFILE",
285580
+ "GEMINI_TELEMETRY_USE_COLLECTOR",
285581
+ "GEMINI_TELEMETRY_USE_CLI_AUTH"
285582
+ ]);
285583
+ function setHeaderCaseInsensitive(headers, lowerKeyMap, key, value) {
285584
+ const lowerKey = key.toLowerCase();
285585
+ const existingKey = lowerKeyMap.get(lowerKey);
285586
+ if (existingKey !== void 0 && existingKey !== key) {
285587
+ delete headers[existingKey];
285588
+ }
285589
+ headers[key] = value;
285590
+ lowerKeyMap.set(lowerKey, key);
285591
+ }
285592
+ function validateHeadersObject(headers) {
285593
+ if (typeof headers !== "object" || headers === null || Array.isArray(headers)) {
285594
+ return void 0;
285595
+ }
285596
+ const validated = {};
285597
+ const lowerKeyMap = /* @__PURE__ */ new Map();
285598
+ for (const [k, v] of Object.entries(headers)) {
285599
+ const trimmedKey = k.trim();
285600
+ if (typeof v !== "string" || !trimmedKey || !isValidHeaderName(trimmedKey) || !isValidHeaderValue(v)) {
285601
+ return void 0;
285602
+ }
285603
+ setHeaderCaseInsensitive(validated, lowerKeyMap, trimmedKey, v);
285604
+ }
285605
+ return validated;
285606
+ }
285607
+ function parseOtlpHeaders(value) {
285608
+ if (!value || value.trim() === "")
285609
+ return void 0;
285610
+ const trimmed2 = value.trim();
285611
+ if (trimmed2.startsWith("{")) {
285612
+ try {
285613
+ const parsed = JSON.parse(trimmed2);
285614
+ const validated = validateHeadersObject(parsed);
285615
+ if (!validated || Object.keys(validated).length === 0) {
285616
+ return void 0;
285617
+ }
285618
+ return validated;
285619
+ } catch {
285620
+ return void 0;
285621
+ }
285622
+ }
285623
+ if (trimmed2.startsWith("[")) {
285624
+ return void 0;
285625
+ }
285626
+ const headers = {};
285627
+ const lowerKeyMap = /* @__PURE__ */ new Map();
285628
+ const pairs2 = trimmed2.split(",");
285629
+ for (const pair of pairs2) {
285630
+ const trimmedPair = pair.trim();
285631
+ if (!trimmedPair)
285632
+ continue;
285633
+ const eqIndex = trimmedPair.indexOf("=");
285634
+ if (eqIndex === -1)
285635
+ continue;
285636
+ let key = trimmedPair.slice(0, eqIndex).trim();
285637
+ let val = stripQuotes(trimmedPair.slice(eqIndex + 1).trim());
285638
+ try {
285639
+ key = decodeURIComponent(key);
285640
+ val = decodeURIComponent(val);
285641
+ } catch {
285642
+ }
285643
+ if (key && isValidHeaderName(key) && isValidHeaderValue(val)) {
285644
+ setHeaderCaseInsensitive(headers, lowerKeyMap, key, val);
285645
+ }
285646
+ }
285647
+ return Object.keys(headers).length > 0 ? headers : void 0;
285648
+ }
285649
+ function mergeHeaders2(...sources) {
285650
+ const definedSources = sources.filter((s2) => s2 !== void 0);
285651
+ if (definedSources.length === 0) {
285652
+ return void 0;
285653
+ }
285654
+ const merged = {};
285655
+ const lowerKeyMap = /* @__PURE__ */ new Map();
285656
+ for (const source of definedSources) {
285657
+ for (const [key, value] of Object.entries(source)) {
285658
+ setHeaderCaseInsensitive(merged, lowerKeyMap, key, value);
285659
+ }
285660
+ }
285661
+ return merged;
285662
+ }
285548
285663
  async function resolveTelemetrySettings(options) {
285549
285664
  const argv = options.argv ?? {};
285550
- const env2 = options.env ?? {};
285665
+ const sanitizedEnv = Object.fromEntries(Object.entries(options.env ?? {}).filter(([key]) => ALLOWED_TELEMETRY_ENV_KEYS.has(key)));
285551
285666
  const settings = options.settings ?? {};
285552
- const enabled = argv.telemetry ?? parseBooleanEnvFlag(env2["GEMINI_TELEMETRY_ENABLED"]) ?? settings.enabled;
285553
- const traces = parseBooleanEnvFlag(env2["GEMINI_TELEMETRY_TRACES_ENABLED"]) ?? settings.traces;
285554
- const rawTarget = argv.telemetryTarget ?? env2["GEMINI_TELEMETRY_TARGET"] ?? settings.target;
285667
+ const createInvalidHeadersError = (source) => new FatalConfigError(`Invalid telemetry OTLP headers in ${source}. Expected JSON object or key=value pairs`);
285668
+ const createInvalidHeaderTokensError = (source) => new FatalConfigError(`Invalid telemetry OTLP headers in ${source}: header names and values must be valid HTTP header tokens.`);
285669
+ const enabled = argv.telemetry ?? parseBooleanEnvFlag(sanitizedEnv["GEMINI_TELEMETRY_ENABLED"]) ?? settings.enabled;
285670
+ const traces = parseBooleanEnvFlag(sanitizedEnv["GEMINI_TELEMETRY_TRACES_ENABLED"]) ?? settings.traces;
285671
+ const rawTarget = argv.telemetryTarget ?? sanitizedEnv["GEMINI_TELEMETRY_TARGET"] ?? settings.target;
285555
285672
  const target = parseTelemetryTargetValue(rawTarget);
285556
285673
  if (rawTarget !== void 0 && target === void 0) {
285557
285674
  throw new FatalConfigError(`Invalid telemetry target: ${String(rawTarget)}. Valid values are: local, gcp`);
285558
285675
  }
285559
- const otlpEndpoint = argv.telemetryOtlpEndpoint ?? env2["GEMINI_TELEMETRY_OTLP_ENDPOINT"] ?? env2["OTEL_EXPORTER_OTLP_ENDPOINT"] ?? settings.otlpEndpoint;
285560
- const rawProtocol = argv.telemetryOtlpProtocol ?? env2["GEMINI_TELEMETRY_OTLP_PROTOCOL"] ?? settings.otlpProtocol;
285676
+ const otlpEndpoint = argv.telemetryOtlpEndpoint ?? sanitizedEnv["GEMINI_TELEMETRY_OTLP_ENDPOINT"] ?? sanitizedEnv["OTEL_EXPORTER_OTLP_ENDPOINT"] ?? settings.otlpEndpoint;
285677
+ const rawProtocol = argv.telemetryOtlpProtocol ?? sanitizedEnv["GEMINI_TELEMETRY_OTLP_PROTOCOL"] ?? settings.otlpProtocol;
285561
285678
  const otlpProtocol = ["grpc", "http"].find((p) => p === rawProtocol);
285562
285679
  if (rawProtocol !== void 0 && otlpProtocol === void 0) {
285563
285680
  throw new FatalConfigError(`Invalid telemetry OTLP protocol: ${String(rawProtocol)}. Valid values are: grpc, http`);
285564
285681
  }
285565
- const logPrompts = argv.telemetryLogPrompts ?? parseBooleanEnvFlag(env2["GEMINI_TELEMETRY_LOG_PROMPTS"]) ?? settings.logPrompts;
285566
- const outfile = argv.telemetryOutfile ?? env2["GEMINI_TELEMETRY_OUTFILE"] ?? settings.outfile;
285567
- const useCollector = parseBooleanEnvFlag(env2["GEMINI_TELEMETRY_USE_COLLECTOR"]) ?? settings.useCollector;
285682
+ const logPrompts = argv.telemetryLogPrompts ?? parseBooleanEnvFlag(sanitizedEnv["GEMINI_TELEMETRY_LOG_PROMPTS"]) ?? settings.logPrompts;
285683
+ const outfile = argv.telemetryOutfile ?? sanitizedEnv["GEMINI_TELEMETRY_OUTFILE"] ?? settings.outfile;
285684
+ const useCollector = parseBooleanEnvFlag(sanitizedEnv["GEMINI_TELEMETRY_USE_COLLECTOR"]) ?? settings.useCollector;
285685
+ let settingsHeaders;
285686
+ if (settings.otlpHeaders !== void 0) {
285687
+ settingsHeaders = validateHeadersObject(settings.otlpHeaders);
285688
+ if (settingsHeaders === void 0) {
285689
+ throw createInvalidHeaderTokensError("settings");
285690
+ }
285691
+ }
285692
+ const rawOtelEnvHeaders = sanitizedEnv["OTEL_EXPORTER_OTLP_HEADERS"];
285693
+ let otelEnvHeaders;
285694
+ if (rawOtelEnvHeaders !== void 0 && rawOtelEnvHeaders.trim() !== "") {
285695
+ otelEnvHeaders = parseOtlpHeaders(rawOtelEnvHeaders);
285696
+ if (otelEnvHeaders === void 0) {
285697
+ throw createInvalidHeadersError("OTEL_EXPORTER_OTLP_HEADERS");
285698
+ }
285699
+ }
285700
+ const rawGeminiEnvHeaders = sanitizedEnv["GEMINI_TELEMETRY_OTLP_HEADERS"];
285701
+ let geminiEnvHeaders;
285702
+ if (rawGeminiEnvHeaders !== void 0 && rawGeminiEnvHeaders.trim() !== "") {
285703
+ geminiEnvHeaders = parseOtlpHeaders(rawGeminiEnvHeaders);
285704
+ if (geminiEnvHeaders === void 0) {
285705
+ throw createInvalidHeadersError("GEMINI_TELEMETRY_OTLP_HEADERS");
285706
+ }
285707
+ }
285708
+ let argvHeaders;
285709
+ if (argv.telemetryOtlpHeaders !== void 0) {
285710
+ if (typeof argv.telemetryOtlpHeaders === "string") {
285711
+ if (argv.telemetryOtlpHeaders.trim() !== "") {
285712
+ argvHeaders = parseOtlpHeaders(argv.telemetryOtlpHeaders);
285713
+ if (argvHeaders === void 0) {
285714
+ throw createInvalidHeadersError("argv");
285715
+ }
285716
+ }
285717
+ } else {
285718
+ argvHeaders = validateHeadersObject(argv.telemetryOtlpHeaders);
285719
+ if (argvHeaders === void 0) {
285720
+ throw createInvalidHeaderTokensError("argv");
285721
+ }
285722
+ }
285723
+ }
285724
+ const otlpHeaders = mergeHeaders2(settingsHeaders, otelEnvHeaders, geminiEnvHeaders, argvHeaders);
285568
285725
  return {
285569
285726
  enabled,
285570
285727
  traces,
285571
285728
  target,
285572
285729
  otlpEndpoint,
285573
285730
  otlpProtocol,
285731
+ otlpHeaders,
285574
285732
  logPrompts,
285575
285733
  outfile,
285576
285734
  useCollector,
285577
- useCliAuth: parseBooleanEnvFlag(env2["GEMINI_TELEMETRY_USE_CLI_AUTH"]) ?? settings.useCliAuth
285735
+ useCliAuth: parseBooleanEnvFlag(sanitizedEnv["GEMINI_TELEMETRY_USE_CLI_AUTH"]) ?? settings.useCliAuth
285578
285736
  };
285579
285737
  }
285580
285738
 
@@ -286098,24 +286256,52 @@ function isIgnoredUserContent(trimmedContent) {
286098
286256
  }
286099
286257
  function convertSessionToClientHistory(messages) {
286100
286258
  const clientHistory = [];
286101
- for (const msg of messages) {
286259
+ const seenFunctionResponseIds = /* @__PURE__ */ new Set();
286260
+ const pendingPartsToAppend = /* @__PURE__ */ new Map();
286261
+ for (let i3 = 0; i3 < messages.length; i3++) {
286262
+ const msg = messages[i3];
286102
286263
  if (msg.type === "info" || msg.type === "error" || msg.type === "warning") {
286103
286264
  continue;
286104
286265
  }
286105
286266
  if (msg.type === "user") {
286106
- const contentString = partListUnionToString(msg.content);
286107
- const trimmedContent = contentString.trim();
286108
- if (isIgnoredUserContent(trimmedContent)) {
286267
+ const extraParts = pendingPartsToAppend.get(msg.id) || [];
286268
+ pendingPartsToAppend.delete(msg.id);
286269
+ if (extraParts.length === 0) {
286270
+ if (!msg.content) {
286271
+ continue;
286272
+ }
286273
+ const contentString = partListUnionToString(msg.content);
286274
+ const trimmedContent = contentString.trim();
286275
+ if (isIgnoredUserContent(trimmedContent)) {
286276
+ continue;
286277
+ }
286278
+ }
286279
+ const parts2 = [
286280
+ ...msg.content ? ensurePartArray(msg.content) : [],
286281
+ ...extraParts
286282
+ ].filter((part) => {
286283
+ const respId = part?.functionResponse?.id;
286284
+ if (!respId) {
286285
+ return true;
286286
+ }
286287
+ if (seenFunctionResponseIds.has(respId)) {
286288
+ return false;
286289
+ }
286290
+ seenFunctionResponseIds.add(respId);
286291
+ return true;
286292
+ });
286293
+ if (parts2.length === 0) {
286109
286294
  continue;
286110
286295
  }
286111
286296
  clientHistory.push({
286112
286297
  id: msg.id,
286113
286298
  content: {
286114
286299
  role: "user",
286115
- parts: ensurePartArray(msg.content)
286300
+ parts: parts2
286116
286301
  }
286117
286302
  });
286118
286303
  } else if (msg.type === "gemini") {
286304
+ seenFunctionResponseIds.clear();
286119
286305
  const modelParts = [];
286120
286306
  const contentParts = msg.content ? ensurePartArray(msg.content) : [];
286121
286307
  const hasCallsInContent = contentParts.some((p) => !!p.functionCall);
@@ -286154,9 +286340,31 @@ function convertSessionToClientHistory(messages) {
286154
286340
  }
286155
286341
  });
286156
286342
  if (msg.toolCalls && msg.toolCalls.length > 0) {
286343
+ const recordedResponseIds = /* @__PURE__ */ new Set();
286344
+ let hasUntrackedFunctionResponse = false;
286345
+ let targetUserMsgId;
286346
+ for (let j = i3 + 1; j < messages.length; j++) {
286347
+ const nextMsg = messages[j];
286348
+ if (nextMsg.type === "gemini") {
286349
+ break;
286350
+ }
286351
+ if (nextMsg.type === "user" && nextMsg.content) {
286352
+ for (const part of ensurePartArray(nextMsg.content)) {
286353
+ if (part?.functionResponse) {
286354
+ targetUserMsgId ??= nextMsg.id;
286355
+ if (part.functionResponse.id) {
286356
+ recordedResponseIds.add(part.functionResponse.id);
286357
+ } else {
286358
+ hasUntrackedFunctionResponse = true;
286359
+ }
286360
+ }
286361
+ }
286362
+ }
286363
+ }
286157
286364
  const functionResponseParts = [];
286158
286365
  for (const toolCall of msg.toolCalls) {
286159
- if (toolCall.result) {
286366
+ const isAlreadyRecorded = toolCall.id ? recordedResponseIds.has(toolCall.id) : hasUntrackedFunctionResponse;
286367
+ if (toolCall.result && !isAlreadyRecorded) {
286160
286368
  let responseData;
286161
286369
  if (typeof toolCall.result === "string") {
286162
286370
  responseData = {
@@ -286178,13 +286386,34 @@ function convertSessionToClientHistory(messages) {
286178
286386
  }
286179
286387
  }
286180
286388
  if (functionResponseParts.length > 0) {
286181
- clientHistory.push({
286182
- id: `${msg.id}_response`,
286183
- content: {
286184
- role: "user",
286185
- parts: functionResponseParts
286389
+ if (targetUserMsgId) {
286390
+ const existingPending = pendingPartsToAppend.get(targetUserMsgId) || [];
286391
+ pendingPartsToAppend.set(targetUserMsgId, [
286392
+ ...existingPending,
286393
+ ...functionResponseParts
286394
+ ]);
286395
+ } else {
286396
+ const dedupedResponseParts = functionResponseParts.filter((part) => {
286397
+ const respId = part?.functionResponse?.id;
286398
+ if (!respId) {
286399
+ return true;
286400
+ }
286401
+ if (seenFunctionResponseIds.has(respId)) {
286402
+ return false;
286403
+ }
286404
+ seenFunctionResponseIds.add(respId);
286405
+ return true;
286406
+ });
286407
+ if (dedupedResponseParts.length > 0) {
286408
+ clientHistory.push({
286409
+ id: `${msg.id}_response`,
286410
+ content: {
286411
+ role: "user",
286412
+ parts: dedupedResponseParts
286413
+ }
286414
+ });
286186
286415
  }
286187
- });
286416
+ }
286188
286417
  }
286189
286418
  }
286190
286419
  }
@@ -286304,7 +286533,7 @@ function isResumableMessageRecord(message) {
286304
286533
  return false;
286305
286534
  }
286306
286535
  function hasResumableConversationContent(messages) {
286307
- return messages.some((message) => isResumableMessageRecord(message));
286536
+ return messages?.some((message) => isResumableMessageRecord(message)) ?? false;
286308
286537
  }
286309
286538
  function createJsonlRecordAccumulator(options) {
286310
286539
  let metadata2 = {};
@@ -286646,6 +286875,8 @@ var ChatRecordingService = class {
286646
286875
  queuedThoughts = [];
286647
286876
  queuedTokens = null;
286648
286877
  context;
286878
+ isResumedSession = false;
286879
+ initializationPromise = null;
286649
286880
  messageOrder = [];
286650
286881
  messageMetaMap = /* @__PURE__ */ new Map();
286651
286882
  toolCallMetaMap = /* @__PURE__ */ new Map();
@@ -286657,7 +286888,18 @@ var ChatRecordingService = class {
286657
286888
  this.sessionId = context2.promptId;
286658
286889
  this.projectHash = getProjectHash(context2.config.getProjectRoot());
286659
286890
  }
286891
+ getIsResumedSession() {
286892
+ return this.isResumedSession;
286893
+ }
286894
+ setIsResumedSession(isResumed) {
286895
+ this.isResumedSession = isResumed;
286896
+ }
286660
286897
  async initialize(resumedSessionData, kind) {
286898
+ this.isResumedSession = Boolean(resumedSessionData);
286899
+ this.initializationPromise = this.doInitialize(resumedSessionData, kind);
286900
+ return this.initializationPromise;
286901
+ }
286902
+ async doInitialize(resumedSessionData, kind) {
286661
286903
  try {
286662
286904
  this.kind = kind;
286663
286905
  if (resumedSessionData) {
@@ -286666,7 +286908,10 @@ var ChatRecordingService = class {
286666
286908
  this.kind = resumedSessionData.conversation.kind;
286667
286909
  const loadedRecord = await loadConversationRecord(this.conversationFile);
286668
286910
  if (loadedRecord) {
286669
- this.cachedConversation = loadedRecord;
286911
+ this.cachedConversation = {
286912
+ ...loadedRecord,
286913
+ messages: loadedRecord.messages ?? []
286914
+ };
286670
286915
  this.projectHash = this.cachedConversation.projectHash;
286671
286916
  if (this.conversationFile.endsWith(".json")) {
286672
286917
  this.conversationFile = this.conversationFile + "l";
@@ -286734,20 +286979,39 @@ var ChatRecordingService = class {
286734
286979
  const directories = this.kind === "subagent" ? [
286735
286980
  ...this.context.config.getWorkspaceContext()?.getDirectories() ?? []
286736
286981
  ] : void 0;
286737
- const initialMetadata = {
286738
- sessionId: this.sessionId,
286739
- projectHash: this.projectHash,
286740
- startTime: (/* @__PURE__ */ new Date()).toISOString(),
286741
- lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
286742
- kind: this.kind,
286743
- directories
286744
- };
286745
- this.appendRecord(initialMetadata);
286746
- this.cachedConversation = {
286747
- ...initialMetadata,
286748
- messages: []
286749
- };
286750
- this.rebuildIndexAndWindow([]);
286982
+ let fileAlreadyExisted = false;
286983
+ if (fs32.existsSync(this.conversationFile)) {
286984
+ fileAlreadyExisted = true;
286985
+ const loadedRecord = await loadConversationRecord(this.conversationFile);
286986
+ if (loadedRecord) {
286987
+ this.cachedConversation = {
286988
+ ...loadedRecord,
286989
+ messages: loadedRecord.messages ?? []
286990
+ };
286991
+ this.projectHash = this.cachedConversation.projectHash;
286992
+ if (loadedRecord.hasResumableContent || hasResumableConversationContent(this.cachedConversation.messages)) {
286993
+ this.isResumedSession = true;
286994
+ }
286995
+ }
286996
+ }
286997
+ if (!fileAlreadyExisted || !this.cachedConversation) {
286998
+ const initialMetadata = {
286999
+ sessionId: this.sessionId,
287000
+ projectHash: this.projectHash,
287001
+ startTime: (/* @__PURE__ */ new Date()).toISOString(),
287002
+ lastUpdated: (/* @__PURE__ */ new Date()).toISOString(),
287003
+ kind: this.kind,
287004
+ directories
287005
+ };
287006
+ this.appendRecord(initialMetadata);
287007
+ this.cachedConversation = {
287008
+ ...initialMetadata,
287009
+ messages: []
287010
+ };
287011
+ this.rebuildIndexAndWindow([]);
287012
+ } else {
287013
+ this.rebuildIndexAndWindow(this.cachedConversation.messages);
287014
+ }
286751
287015
  }
286752
287016
  this.queuedThoughts = [];
286753
287017
  this.queuedTokens = null;
@@ -286792,14 +287056,15 @@ var ChatRecordingService = class {
286792
287056
  this.hasEvictedMessages = msgs.length < this.messageOrder.length;
286793
287057
  }
286794
287058
  rebuildIndexAndWindow(messages) {
287059
+ const safeMessages = messages ?? [];
286795
287060
  this.messageOrder = [];
286796
287061
  this.messageMetaMap.clear();
286797
287062
  this.toolCallMetaMap.clear();
286798
- for (const msg of messages) {
287063
+ for (const msg of safeMessages) {
286799
287064
  this.indexMessage(msg);
286800
287065
  }
286801
287066
  if (this.cachedConversation) {
286802
- this.cachedConversation.messages = messages.length > MAX_HISTORY_MESSAGES ? messages.slice(-MAX_HISTORY_MESSAGES) : [...messages];
287067
+ this.cachedConversation.messages = safeMessages.length > MAX_HISTORY_MESSAGES ? safeMessages.slice(-MAX_HISTORY_MESSAGES) : [...safeMessages];
286803
287068
  this.hasEvictedMessages = this.cachedConversation.messages.length < this.messageOrder.length;
286804
287069
  } else {
286805
287070
  this.hasEvictedMessages = false;
@@ -287106,12 +287371,30 @@ var ChatRecordingService = class {
287106
287371
  * session with a real user prompt, model response, or tool activity.
287107
287372
  */
287108
287373
  async deleteCurrentSessionIfNotResumableAsync() {
287109
- if (!this.conversationFile || !this.cachedConversation) {
287374
+ if (this.initializationPromise) {
287375
+ try {
287376
+ await this.initializationPromise;
287377
+ } catch {
287378
+ }
287379
+ }
287380
+ if (this.isResumedSession) {
287110
287381
  return;
287111
287382
  }
287112
- if (hasResumableConversationContent(this.cachedConversation.messages) || Array.from(this.messageMetaMap.values()).some((m) => m.isResumable)) {
287383
+ if (!this.conversationFile) {
287113
287384
  return;
287114
287385
  }
287386
+ if (this.cachedConversation && hasResumableConversationContent(this.cachedConversation.messages ?? []) || Array.from(this.messageMetaMap.values()).some((m) => m.isResumable)) {
287387
+ return;
287388
+ }
287389
+ if (fs32.existsSync(this.conversationFile)) {
287390
+ try {
287391
+ const fileRecord = await loadConversationRecord(this.conversationFile);
287392
+ if (fileRecord && (fileRecord.hasResumableContent || hasResumableConversationContent(fileRecord.messages ?? []))) {
287393
+ return;
287394
+ }
287395
+ } catch {
287396
+ }
287397
+ }
287115
287398
  await this.deleteCurrentSessionAsync();
287116
287399
  }
287117
287400
  /**
@@ -288998,6 +289281,8 @@ async function initializeTelemetry(config2, credentials3) {
288998
289281
  exportIntervalMillis: 3e4
288999
289282
  });
289000
289283
  } else if (useOtlp) {
289284
+ const otlpHeaders = config2.getTelemetryOtlpHeaders?.() ?? {};
289285
+ const hasHeaders = Object.keys(otlpHeaders).length > 0;
289001
289286
  if (otlpProtocol === "http") {
289002
289287
  const buildUrl = (path118) => {
289003
289288
  const url3 = new URL(parsedEndpoint);
@@ -289005,30 +289290,52 @@ async function initializeTelemetry(config2, credentials3) {
289005
289290
  return url3.href;
289006
289291
  };
289007
289292
  spanExporter = new import_exporter_trace_otlp_http.OTLPTraceExporter({
289008
- url: buildUrl("v1/traces")
289293
+ url: buildUrl("v1/traces"),
289294
+ headers: hasHeaders ? otlpHeaders : void 0
289009
289295
  });
289010
289296
  logExporter = new import_exporter_logs_otlp_http.OTLPLogExporter({
289011
- url: buildUrl("v1/logs")
289297
+ url: buildUrl("v1/logs"),
289298
+ headers: hasHeaders ? otlpHeaders : void 0
289012
289299
  });
289013
289300
  metricReader = new import_sdk_metrics2.PeriodicExportingMetricReader({
289014
289301
  exporter: new import_exporter_metrics_otlp_http.OTLPMetricExporter({
289015
- url: buildUrl("v1/metrics")
289302
+ url: buildUrl("v1/metrics"),
289303
+ headers: hasHeaders ? otlpHeaders : void 0
289016
289304
  }),
289017
289305
  exportIntervalMillis: 1e4
289018
289306
  });
289019
289307
  } else {
289308
+ let metadata2;
289309
+ if (hasHeaders) {
289310
+ const candidateMetadata = new import_grpc_js.Metadata();
289311
+ let validCount = 0;
289312
+ for (const [key, value] of Object.entries(otlpHeaders)) {
289313
+ try {
289314
+ candidateMetadata.set(key, value);
289315
+ validCount++;
289316
+ } catch (error40) {
289317
+ debugLogger.warn(`[Telemetry] Skipping invalid gRPC metadata key "${key}":`, error40);
289318
+ }
289319
+ }
289320
+ if (validCount > 0) {
289321
+ metadata2 = candidateMetadata;
289322
+ }
289323
+ }
289020
289324
  spanExporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
289021
289325
  url: parsedEndpoint,
289022
- compression: CompressionAlgorithm.GZIP
289326
+ compression: CompressionAlgorithm.GZIP,
289327
+ ...metadata2 && { metadata: metadata2 }
289023
289328
  });
289024
289329
  logExporter = new import_exporter_logs_otlp_grpc.OTLPLogExporter({
289025
289330
  url: parsedEndpoint,
289026
- compression: CompressionAlgorithm.GZIP
289331
+ compression: CompressionAlgorithm.GZIP,
289332
+ ...metadata2 && { metadata: metadata2 }
289027
289333
  });
289028
289334
  metricReader = new import_sdk_metrics2.PeriodicExportingMetricReader({
289029
289335
  exporter: new import_exporter_metrics_otlp_grpc.OTLPMetricExporter({
289030
289336
  url: parsedEndpoint,
289031
- compression: CompressionAlgorithm.GZIP
289337
+ compression: CompressionAlgorithm.GZIP,
289338
+ ...metadata2 && { metadata: metadata2 }
289032
289339
  }),
289033
289340
  exportIntervalMillis: 1e4
289034
289341
  });
@@ -307310,7 +307617,7 @@ function getVersion() {
307310
307617
  }
307311
307618
  versionPromise = (async () => {
307312
307619
  const pkgJson = await getPackageJson(__dirname4);
307313
- return "0.64.0-preview.0";
307620
+ return "0.65.0-nightly.20261008.g44d764ee5";
307314
307621
  })();
307315
307622
  return versionPromise;
307316
307623
  }
@@ -307991,7 +308298,10 @@ function classifyValidationRequiredError(googleApiError) {
307991
308298
  }
307992
308299
  }
307993
308300
  if (!validationLink) {
307994
- validationLink = errorInfo.metadata?.["validation_link"];
308301
+ validationLink = errorInfo.metadata?.["validation_link"] ?? errorInfo.metadata?.["validation_url"];
308302
+ }
308303
+ if (!learnMoreUrl) {
308304
+ learnMoreUrl = errorInfo.metadata?.["validation_learn_more_url"];
307995
308305
  }
307996
308306
  return new ValidationRequiredError(googleApiError.message, googleApiError, validationLink, validationDescription, learnMoreUrl);
307997
308307
  }
@@ -308738,7 +309048,9 @@ async function retryWithBackoff(fn, options) {
308738
309048
  const getCurrentMaxAttempts = () => getAvailabilityContext?.()?.policy.maxAttempts ?? maxAttempts;
308739
309049
  let attempt = 0;
308740
309050
  let capacityAttempts = 0;
309051
+ let validationAttempts = 0;
308741
309052
  const MAX_SILENT_CAPACITY_ATTEMPTS = 3;
309053
+ const MAX_VALIDATION_ATTEMPTS = 3;
308742
309054
  let currentDelay = initialDelayMs;
308743
309055
  const throwIfAborted = () => {
308744
309056
  if (signal?.aborted) {
@@ -308816,7 +309128,8 @@ async function retryWithBackoff(fn, options) {
308816
309128
  }
308817
309129
  }
308818
309130
  if (classifiedError instanceof ValidationRequiredError) {
308819
- if (onValidationRequired) {
309131
+ if (onValidationRequired && validationAttempts < MAX_VALIDATION_ATTEMPTS) {
309132
+ validationAttempts++;
308820
309133
  try {
308821
309134
  const intent = await onValidationRequired(classifiedError);
308822
309135
  if (intent === "verify") {
@@ -311760,6 +312073,8 @@ async function _doSetupUser(client, projectId, config2, httpOptions = {}) {
311760
312073
  pluginType: "GEMINI"
311761
312074
  };
311762
312075
  const validationHandler = config2.getValidationHandler();
312076
+ const MAX_VALIDATION_ATTEMPTS = 3;
312077
+ let validationAttempts = 0;
311763
312078
  let loadRes;
311764
312079
  while (true) {
311765
312080
  loadRes = await caServer.loadCodeAssist({
@@ -311773,7 +312088,8 @@ async function _doSetupUser(client, projectId, config2, httpOptions = {}) {
311773
312088
  validateLoadCodeAssistResponse(loadRes);
311774
312089
  break;
311775
312090
  } catch (e2) {
311776
- if (e2 instanceof ValidationRequiredError && validationHandler) {
312091
+ if (e2 instanceof ValidationRequiredError && validationHandler && validationAttempts < MAX_VALIDATION_ATTEMPTS) {
312092
+ validationAttempts++;
311777
312093
  const intent = await validationHandler(e2.validationLink, e2.validationDescription);
311778
312094
  if (intent === "verify") {
311779
312095
  continue;
@@ -332836,6 +333152,9 @@ function scrubPart(part) {
332836
333152
  if (part.functionResponse.id) {
332837
333153
  scrubbedResp["id"] = part.functionResponse.id;
332838
333154
  }
333155
+ if ("parts" in part.functionResponse && Array.isArray(part.functionResponse.parts)) {
333156
+ scrubbedResp["parts"] = part.functionResponse.parts.map(scrubPart);
333157
+ }
332839
333158
  scrubbed["functionResponse"] = scrubbedResp;
332840
333159
  }
332841
333160
  if ("fileData" in part) {
@@ -332866,6 +333185,8 @@ var MID_STREAM_RETRY_OPTIONS = {
332866
333185
  };
332867
333186
  var SYNTHETIC_THOUGHT_SIGNATURE2 = "skip_thought_signature_validator";
332868
333187
  var INTERRUPTED_RESPONSE_PLACEHOLDER = "[The previous response was interrupted before it completed.]";
333188
+ var INTERRUPTED_TOOL_RESPONSE_ERROR = "Response was lost or interrupted.";
333189
+ var CONTINUE_PROMPT_TEXT = "Please continue.";
332869
333190
  function isIndexedPart(part) {
332870
333191
  return "callIndex" in part;
332871
333192
  }
@@ -333107,6 +333428,7 @@ var GeminiChat = class {
333107
333428
  let userContent = createUserContent(message);
333108
333429
  const isOriginalFunctionResponse = isFunctionResponse(userContent);
333109
333430
  if (!isOriginalFunctionResponse) {
333431
+ this.closeUnansweredToolCallsTurn();
333110
333432
  this.closeUnansweredToolResponseTurn();
333111
333433
  }
333112
333434
  const { model } = this.context.config.modelConfigService.getResolvedConfig(modelConfigKey);
@@ -333133,7 +333455,7 @@ var GeminiChat = class {
333133
333455
  } else {
333134
333456
  const history = this.agentHistory.get();
333135
333457
  const lastTurn = history[history.length - 1];
333136
- if (!lastTurn || partListUnionToString(lastTurn.content.parts || []) !== userMessageContent) {
333458
+ if (!lastTurn || lastTurn.content.role !== "user" || partListUnionToString(lastTurn.content.parts || []) !== userMessageContent) {
333137
333459
  const id = this.chatRecordingService.recordMessage({
333138
333460
  model,
333139
333461
  type: "user",
@@ -333181,11 +333503,12 @@ var GeminiChat = class {
333181
333503
  } else {
333182
333504
  const history = this.agentHistory.get();
333183
333505
  const lastTurn = history[history.length - 1];
333184
- if (!lastTurn || partListUnionToString(lastTurn.content.parts || []) !== partListUnionToString(userContent.parts || [])) {
333506
+ if (!lastTurn || lastTurn.content.role !== "user" || partListUnionToString(lastTurn.content.parts || []) !== partListUnionToString(userContent.parts || [])) {
333185
333507
  this.agentHistory.push({ id, content: userContent });
333186
333508
  }
333187
333509
  }
333188
333510
  }
333511
+ this.replaceEmptyTrailingUserTurn();
333189
333512
  const requestHistory = this.getHistoryTurns(true);
333190
333513
  const streamWithRetries = async function* () {
333191
333514
  let isSuccess = false;
@@ -333297,23 +333620,77 @@ var GeminiChat = class {
333297
333620
  return streamWithRetries.call(this);
333298
333621
  }
333299
333622
  /**
333300
- * Appends a closing model turn when history ends with an unanswered tool
333301
- * response, so the next user message stays a turn of its own.
333623
+ * Appends a dedicated synthetic user turn with matching functionResponse
333624
+ * parts when history ends with an unclosed model functionCall. The
333625
+ * subsequent user prompt is then recorded as a clean turn of its own (after
333626
+ * `closeUnansweredToolResponseTurn` adds the closing model turn).
333302
333627
  */
333303
- closeUnansweredToolResponseTurn() {
333628
+ closeUnansweredToolCallsTurn() {
333304
333629
  const turns = this.agentHistory.get();
333305
333630
  const last2 = turns[turns.length - 1];
333306
- if (last2?.content.role !== "user" || !last2.content.parts?.some((part) => !!part.functionResponse)) {
333631
+ if (last2?.content.role !== "model") {
333632
+ return;
333633
+ }
333634
+ const missingResponses = buildInterruptedToolResponseParts(last2.content.parts ?? []);
333635
+ if (missingResponses.length === 0) {
333307
333636
  return;
333308
333637
  }
333638
+ const id = this.chatRecordingService.recordSyntheticMessage("user", missingResponses);
333309
333639
  this.agentHistory.push({
333310
- id: randomUUID6(),
333311
- content: {
333312
- role: "model",
333313
- parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }]
333314
- }
333640
+ id,
333641
+ content: { role: "user", parts: missingResponses }
333315
333642
  });
333316
333643
  }
333644
+ /**
333645
+ * Replaces the parts of a trailing user turn that carries no content (e.g.
333646
+ * only empty text parts) with a continuation prompt, keeping the in-memory
333647
+ * history and the session log in sync. Runs once per send so that the
333648
+ * persisted history never keeps an empty user turn between model turns.
333649
+ */
333650
+ replaceEmptyTrailingUserTurn() {
333651
+ const turns = this.agentHistory.get();
333652
+ const last2 = turns[turns.length - 1];
333653
+ if (last2?.content.role !== "user" || hasNonEmptyParts(last2.content)) {
333654
+ return;
333655
+ }
333656
+ this.agentHistory.set([
333657
+ ...turns.slice(0, -1),
333658
+ {
333659
+ id: last2.id,
333660
+ content: { ...last2.content, parts: [{ text: CONTINUE_PROMPT_TEXT }] }
333661
+ }
333662
+ ]);
333663
+ this.chatRecordingService.updateMessagesFromHistory(this.agentHistory.get());
333664
+ }
333665
+ /**
333666
+ * Appends a closing model turn when history ends with an unanswered tool
333667
+ * response, so the next user message stays a turn of its own.
333668
+ */
333669
+ closeUnansweredToolResponseTurn() {
333670
+ const turns = this.agentHistory.get();
333671
+ let targetTurn = turns[turns.length - 1];
333672
+ let hadEmptyTrailingModelTurn = false;
333673
+ if (targetTurn?.content.role === "model" && (!targetTurn.content.parts || targetTurn.content.parts.length === 0)) {
333674
+ hadEmptyTrailingModelTurn = true;
333675
+ targetTurn = turns[turns.length - 2];
333676
+ }
333677
+ if (targetTurn?.content.role !== "user" || !targetTurn.content.parts?.some((part) => !!part.functionResponse)) {
333678
+ return;
333679
+ }
333680
+ if (hadEmptyTrailingModelTurn) {
333681
+ const lastTurn = turns[turns.length - 1];
333682
+ lastTurn.content.parts = [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }];
333683
+ this.chatRecordingService.updateMessagesFromHistory(turns);
333684
+ } else {
333685
+ this.agentHistory.push({
333686
+ id: randomUUID6(),
333687
+ content: {
333688
+ role: "model",
333689
+ parts: [{ text: INTERRUPTED_RESPONSE_PLACEHOLDER }]
333690
+ }
333691
+ });
333692
+ }
333693
+ }
333317
333694
  extractBinaryInjections(parts2) {
333318
333695
  const binaryParts = [];
333319
333696
  if (parts2) {
@@ -333430,10 +333807,14 @@ var GeminiChat = class {
333430
333807
  if (this.onModelChanged) {
333431
333808
  this.tools = await this.onModelChanged(modelToUse);
333432
333809
  }
333810
+ const normalizedContents = ensureTerminalUserTurn(contentsToUse);
333811
+ if (normalizedContents !== contentsToUse) {
333812
+ debugLogger.warn("Final contents do not end with a valid user turn. Normalizing contents to satisfy Gemini API invariant.");
333813
+ }
333433
333814
  lastModelToUse = modelToUse;
333434
333815
  lastConfig = config2;
333435
- lastContentsToUse = contentsToUse;
333436
- const finalContents = stripToolCallIdPrefixes(contentsToUse);
333816
+ lastContentsToUse = normalizedContents;
333817
+ const finalContents = stripToolCallIdPrefixes(normalizedContents);
333437
333818
  return this.context.config.getContentGenerator().generateContentStream({
333438
333819
  model: modelToUse,
333439
333820
  contents: finalContents,
@@ -333531,6 +333912,25 @@ var GeminiChat = class {
333531
333912
  }
333532
333913
  ensureStableToolIds(this.agentHistory.get());
333533
333914
  }
333915
+ /**
333916
+ * Removes the trailing model turn when it holds function calls that were
333917
+ * never answered (e.g. every call in the batch was declined). Earlier
333918
+ * completed tool rounds and the originating user prompt are kept, and the
333919
+ * durable IDs of the remaining turns are preserved.
333920
+ *
333921
+ * @returns true when a turn was removed.
333922
+ */
333923
+ discardTrailingUnansweredToolCallTurn() {
333924
+ const turns = this.agentHistory.get();
333925
+ const last2 = turns[turns.length - 1];
333926
+ if (last2?.content.role !== "model" || !last2.content.parts?.some((part) => !!part.functionCall)) {
333927
+ return false;
333928
+ }
333929
+ this.agentHistory.rollback(turns.length - 1);
333930
+ this.lastPromptTokenCount = estimateTokenCountSync(this.agentHistory.flatMap((c4) => c4.content.parts || []));
333931
+ this.chatRecordingService.updateMessagesFromHistory(this.agentHistory.get());
333932
+ return true;
333933
+ }
333534
333934
  setHistory(history) {
333535
333935
  const wrappedHistory = history.map((item) => {
333536
333936
  if ("id" in item && "content" in item) {
@@ -333884,8 +334284,41 @@ function isSchemaDepthError(errorMessage) {
333884
334284
  function isInvalidArgumentError(errorMessage) {
333885
334285
  return errorMessage.includes("Request contains an invalid argument");
333886
334286
  }
334287
+ function isEmptyTextPart(part) {
334288
+ if (part.text !== "") {
334289
+ return false;
334290
+ }
334291
+ return !Object.keys(part).some((key) => key !== "text" && key !== "thought" && key !== "callIndex");
334292
+ }
334293
+ function hasNonEmptyParts(content) {
334294
+ return (content.parts ?? []).some((part) => !isEmptyTextPart(part));
334295
+ }
334296
+ function buildInterruptedToolResponseParts(parts2) {
334297
+ return parts2.filter((part) => !!part?.functionCall).map((part) => ({
334298
+ functionResponse: {
334299
+ name: part.functionCall.name?.trim() || "generic_tool",
334300
+ id: part.functionCall.id,
334301
+ response: { error: INTERRUPTED_TOOL_RESPONSE_ERROR }
334302
+ }
334303
+ }));
334304
+ }
334305
+ function ensureTerminalUserTurn(contents) {
334306
+ const last2 = contents.at(-1);
334307
+ if (last2?.role === "user" && hasNonEmptyParts(last2)) {
334308
+ return contents;
334309
+ }
334310
+ if (last2?.role === "user") {
334311
+ return [
334312
+ ...contents.slice(0, -1),
334313
+ { ...last2, parts: [{ text: CONTINUE_PROMPT_TEXT }] }
334314
+ ];
334315
+ }
334316
+ const missingResponses = buildInterruptedToolResponseParts(last2?.parts ?? []);
334317
+ const parts2 = missingResponses.length > 0 ? missingResponses : [{ text: CONTINUE_PROMPT_TEXT }];
334318
+ return [...contents, { role: "user", parts: parts2 }];
334319
+ }
333887
334320
  function stripToolCallIdPrefixes(contents) {
333888
- return contents.map((content) => {
334321
+ const stripped = contents.map((content) => {
333889
334322
  const parts2 = (content.parts || []).map((part) => {
333890
334323
  const newPart = { ...part };
333891
334324
  if (newPart.functionCall) {
@@ -333893,8 +334326,7 @@ function stripToolCallIdPrefixes(contents) {
333893
334326
  const name3 = fc.name?.trim() || "generic_tool";
333894
334327
  if (fc.id && fc.id.startsWith(`${name3}__`)) {
333895
334328
  newPart.functionCall = {
333896
- name: fc.name,
333897
- args: fc.args,
334329
+ ...fc,
333898
334330
  id: fc.id.substring(name3.length + 2)
333899
334331
  };
333900
334332
  }
@@ -333904,8 +334336,9 @@ function stripToolCallIdPrefixes(contents) {
333904
334336
  const name3 = fr.name?.trim() || "generic_tool";
333905
334337
  if (fr.id && fr.id.startsWith(`${name3}__`)) {
333906
334338
  newPart.functionResponse = {
333907
- name: fr.name,
333908
- response: fr.response,
334339
+ // History parts are plain JSON objects, not class instances.
334340
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread
334341
+ ...fr,
333909
334342
  id: fr.id.substring(name3.length + 2)
333910
334343
  };
333911
334344
  }
@@ -333915,18 +334348,30 @@ function stripToolCallIdPrefixes(contents) {
333915
334348
  delete newPart.text;
333916
334349
  }
333917
334350
  return newPart;
333918
- }).filter((part) => {
333919
- const hasOtherKeys = Object.keys(part).some((key) => key !== "text" && key !== "thought" && key !== "callIndex");
333920
- if (part.text !== void 0 && part.text === "" && !hasOtherKeys) {
333921
- return false;
333922
- }
333923
- return true;
333924
- });
334351
+ }).filter((part) => !isEmptyTextPart(part));
333925
334352
  return {
333926
334353
  ...content,
333927
334354
  parts: parts2
333928
334355
  };
333929
- });
334356
+ }).filter((content) => content.parts.length > 0);
334357
+ return coalesceConsecutiveContents(stripped);
334358
+ }
334359
+ function coalesceConsecutiveContents(contents) {
334360
+ const result2 = [];
334361
+ for (const item of contents) {
334362
+ const lastIdx = result2.length - 1;
334363
+ const last2 = result2[lastIdx];
334364
+ if (last2 && last2.role && last2.role === item.role) {
334365
+ const hasParts = last2.parts || item.parts;
334366
+ result2[lastIdx] = {
334367
+ ...last2,
334368
+ parts: hasParts ? [...last2.parts || [], ...item.parts || []] : void 0
334369
+ };
334370
+ } else {
334371
+ result2.push({ ...item });
334372
+ }
334373
+ }
334374
+ return result2;
333930
334375
  }
333931
334376
  function coalesceConsecutiveRoles(history) {
333932
334377
  const result2 = [];
@@ -341235,7 +341680,13 @@ var OAuthUtils = class {
341235
341680
  issuer: metadata2.issuer,
341236
341681
  tokenUrl: metadata2.token_endpoint,
341237
341682
  scopes: metadata2.scopes_supported || [],
341238
- registrationUrl: metadata2.registration_endpoint
341683
+ registrationUrl: metadata2.registration_endpoint,
341684
+ // RFC 9207 Section 3: the flag defaults to false when omitted. Discovered
341685
+ // configurations therefore always carry an explicit boolean, which lets
341686
+ // the callback policy distinguish them from an explicitly configured issuer.
341687
+ // Only a literal boolean `true` enables the flag, so loosely typed values
341688
+ // returned by some servers (e.g. "false" or "0") are not coerced to true.
341689
+ authorizationResponseIssParameterSupported: metadata2.authorization_response_iss_parameter_supported === true
341239
341690
  };
341240
341691
  }
341241
341692
  /**
@@ -341559,7 +342010,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
341559
342010
  return provider;
341560
342011
  }
341561
342012
  case "oauth2": {
341562
- const { OAuth2AuthProvider } = await import("./oauth2-provider-FVTRRJZR.js");
342013
+ const { OAuth2AuthProvider } = await import("./oauth2-provider-JB36DOZE.js");
341563
342014
  const provider = new OAuth2AuthProvider(authConfig, options.agentName ?? "unknown", agentCard, options.agentCardUrl);
341564
342015
  await provider.initialize();
341565
342016
  return provider;
@@ -347707,6 +348158,21 @@ var GeminiClient = class {
347707
348158
  this.updateTelemetryTokenCount();
347708
348159
  this.forceFullIdeContext = true;
347709
348160
  }
348161
+ /**
348162
+ * Removes the trailing model turn when it only holds unanswered function
348163
+ * calls. See {@link GeminiChat.discardTrailingUnansweredToolCallTurn}.
348164
+ * Returns false without side effects when the chat is not initialized.
348165
+ */
348166
+ discardTrailingUnansweredToolCallTurn() {
348167
+ if (!this.isInitialized()) {
348168
+ return false;
348169
+ }
348170
+ const removed = this.getChat().discardTrailingUnansweredToolCallTurn();
348171
+ if (removed) {
348172
+ this.updateTelemetryTokenCount();
348173
+ }
348174
+ return removed;
348175
+ }
347710
348176
  lastUsedModelId;
347711
348177
  async setTools(modelId) {
347712
348178
  if (!this.chat) {
@@ -369889,7 +370355,7 @@ function areIssuersEqual(issuerA, issuerB) {
369889
370355
  }
369890
370356
  return normA === normB;
369891
370357
  }
369892
- function startCallbackServer(expectedState, port, expectedIssuer) {
370358
+ function startCallbackServer(expectedState, port, expectedIssuer, requireIssInResponse) {
369893
370359
  let portResolve;
369894
370360
  let portReject;
369895
370361
  const portPromise = new Promise((resolve29, reject) => {
@@ -369897,6 +370363,13 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369897
370363
  portReject = reject;
369898
370364
  });
369899
370365
  let timeoutId;
370366
+ const abortController = new AbortController();
370367
+ const clearCallbackTimeout = () => {
370368
+ if (timeoutId !== void 0) {
370369
+ clearTimeout(timeoutId);
370370
+ timeoutId = void 0;
370371
+ }
370372
+ };
369900
370373
  const responsePromise = new Promise((resolve29, reject) => {
369901
370374
  let serverPort;
369902
370375
  const server = http2.createServer(async (req, res) => {
@@ -369924,6 +370397,7 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369924
370397
  </body>
369925
370398
  </html>
369926
370399
  `);
370400
+ clearCallbackTimeout();
369927
370401
  server.close();
369928
370402
  reject(new Error(`OAuth error: ${error40}`));
369929
370403
  return;
@@ -369938,13 +370412,15 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369938
370412
  debugLogger.error(`OAuth callback state mismatch: received state "${state}", expected "${expectedState}". Possible CSRF attack.`);
369939
370413
  res.writeHead(400);
369940
370414
  res.end("Invalid state parameter");
370415
+ clearCallbackTimeout();
369941
370416
  server.close();
369942
370417
  reject(new Error("State mismatch - possible CSRF attack"));
369943
370418
  return;
369944
370419
  }
369945
370420
  if (expectedIssuer) {
369946
- if (!iss) {
369947
- debugLogger.error('OAuth callback rejected: Missing required "iss" parameter when an expected issuer is configured. Possible IdP mix-up attack (RFC 9207).');
370421
+ const requireIss = requireIssInResponse ?? true;
370422
+ if (requireIss && !iss) {
370423
+ debugLogger.error('OAuth callback rejected: Missing required "iss" parameter for the expected authorization server (RFC 9207).');
369948
370424
  res.writeHead(400, { "Content-Type": "text/html" });
369949
370425
  res.end(`
369950
370426
  <html>
@@ -369959,7 +370435,7 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369959
370435
  reject(new Error('Missing "iss" parameter in authorization response per RFC 9207'));
369960
370436
  return;
369961
370437
  }
369962
- if (!areIssuersEqual(iss, expectedIssuer)) {
370438
+ if (iss && !areIssuersEqual(iss, expectedIssuer)) {
369963
370439
  debugLogger.error("OAuth callback rejected: Issuer mismatch between authorization response and expected authorization server. Possible IdP mix-up attack (RFC 9207).");
369964
370440
  res.writeHead(400, { "Content-Type": "text/html" });
369965
370441
  res.end(`
@@ -369975,7 +370451,9 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369975
370451
  reject(new Error("Issuer mismatch in authorization response - possible OAuth mix-up attack"));
369976
370452
  return;
369977
370453
  }
369978
- debugLogger.debug("\u2713 OAuth callback issuer validated successfully.");
370454
+ if (iss) {
370455
+ debugLogger.debug("\u2713 OAuth callback issuer validated successfully.");
370456
+ }
369979
370457
  } else if (iss) {
369980
370458
  debugLogger.debug('OAuth callback received "iss" parameter (no expected issuer was configured).');
369981
370459
  }
@@ -369989,14 +370467,17 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
369989
370467
  </body>
369990
370468
  </html>
369991
370469
  `);
370470
+ clearCallbackTimeout();
369992
370471
  server.close();
369993
370472
  resolve29({ code, state, iss });
369994
370473
  } catch (error40) {
370474
+ clearCallbackTimeout();
369995
370475
  server.close();
369996
370476
  reject(error40);
369997
370477
  }
369998
370478
  });
369999
370479
  server.on("error", (error40) => {
370480
+ clearCallbackTimeout();
370000
370481
  portReject(error40);
370001
370482
  reject(error40);
370002
370483
  });
@@ -370020,23 +370501,31 @@ function startCallbackServer(expectedState, port, expectedIssuer) {
370020
370501
  debugLogger.log(`OAuth callback server listening on port ${serverPort}`);
370021
370502
  portResolve(serverPort);
370022
370503
  });
370023
- const abortController = new AbortController();
370024
370504
  timeoutId = setTimeout(() => {
370025
370505
  abortController.abort(new Error("OAuth callback timeout"));
370026
370506
  }, 5 * 60 * 1e3);
370027
370507
  timeoutId.unref();
370028
370508
  const onAbort = () => {
370029
- server.close();
370509
+ clearCallbackTimeout();
370510
+ if (server.listening) {
370511
+ server.close();
370512
+ }
370030
370513
  reject(abortController.signal.reason);
370031
370514
  };
370032
370515
  abortController.signal.addEventListener("abort", onAbort, { once: true });
370033
370516
  server.on("close", () => {
370517
+ clearCallbackTimeout();
370034
370518
  abortController.signal.removeEventListener("abort", onAbort);
370035
370519
  });
370036
370520
  });
370037
370521
  return {
370038
370522
  port: portPromise,
370039
- response: responsePromise
370523
+ response: responsePromise,
370524
+ cancel: (reason) => {
370525
+ if (!abortController.signal.aborted) {
370526
+ abortController.abort(reason ?? new Error("OAuth callback cancelled"));
370527
+ }
370528
+ }
370040
370529
  };
370041
370530
  }
370042
370531
  function getPortFromUrl(urlString) {
@@ -370379,6 +370868,7 @@ var MCPOAuthProvider = class {
370379
370868
  issuer: discoveredConfig.issuer,
370380
370869
  tokenUrl: discoveredConfig.tokenUrl,
370381
370870
  scopes: config2.scopes || discoveredConfig.scopes || [],
370871
+ authorizationResponseIssParameterSupported: config2.authorizationResponseIssParameterSupported ?? discoveredConfig.authorizationResponseIssParameterSupported,
370382
370872
  // Preserve existing client credentials
370383
370873
  clientId: config2.clientId,
370384
370874
  clientSecret: config2.clientSecret
@@ -370402,6 +370892,7 @@ var MCPOAuthProvider = class {
370402
370892
  issuer: discoveredConfig.issuer,
370403
370893
  scopes: config2.scopes || discoveredConfig.scopes || [],
370404
370894
  registrationUrl: discoveredConfig.registrationUrl,
370895
+ authorizationResponseIssParameterSupported: config2.authorizationResponseIssParameterSupported ?? discoveredConfig.authorizationResponseIssParameterSupported,
370405
370896
  // Preserve existing client credentials
370406
370897
  clientId: config2.clientId,
370407
370898
  clientSecret: config2.clientSecret
@@ -370414,7 +370905,8 @@ var MCPOAuthProvider = class {
370414
370905
  const pkceParams = generatePKCEParams();
370415
370906
  const preferredPort = getPortFromUrl(config2.redirectUri);
370416
370907
  debugLogger.debug(`Starting callback server for "${serverName}" (expected issuer: ${config2.issuer || "none"})...`);
370417
- const callbackServer = startCallbackServer(pkceParams.state, preferredPort, config2.issuer);
370908
+ const requireIssInResponse = config2.authorizationResponseIssParameterSupported ?? Boolean(config2.issuer);
370909
+ const callbackServer = startCallbackServer(pkceParams.state, preferredPort, config2.issuer, requireIssInResponse);
370418
370910
  const redirectPort = await callbackServer.port;
370419
370911
  debugLogger.debug(`Callback server listening on port ${redirectPort}`);
370420
370912
  if (!config2.clientId) {
@@ -371163,7 +371655,8 @@ async function handleAutomaticOAuth(mcpServerName, mcpServerConfig, wwwAuthentic
371163
371655
  authorizationUrl: oauthConfig.authorizationUrl,
371164
371656
  issuer: oauthConfig.issuer,
371165
371657
  tokenUrl: oauthConfig.tokenUrl,
371166
- scopes: oauthConfig.scopes || []
371658
+ scopes: oauthConfig.scopes || [],
371659
+ authorizationResponseIssParameterSupported: mcpServerConfig.oauth?.authorizationResponseIssParameterSupported ?? oauthConfig.authorizationResponseIssParameterSupported
371167
371660
  };
371168
371661
  debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
371169
371662
  const authProvider = new MCPOAuthProvider(new MCPOAuthTokenStorage());
@@ -371707,7 +372200,8 @@ async function connectToMcpServer(clientVersion, mcpServerName, mcpServerConfig,
371707
372200
  authorizationUrl: oauthConfig.authorizationUrl,
371708
372201
  issuer: oauthConfig.issuer,
371709
372202
  tokenUrl: oauthConfig.tokenUrl,
371710
- scopes: oauthConfig.scopes || []
372203
+ scopes: oauthConfig.scopes || [],
372204
+ authorizationResponseIssParameterSupported: mcpServerConfig.oauth?.authorizationResponseIssParameterSupported ?? oauthConfig.authorizationResponseIssParameterSupported
371711
372205
  };
371712
372206
  const authServerUrl = mcpServerConfig.httpUrl || mcpServerConfig.url;
371713
372207
  debugLogger.log(`Starting OAuth authentication for server '${mcpServerName}'...`);
@@ -376307,7 +376801,7 @@ function assertFloat32(arg) {
376307
376801
  }
376308
376802
 
376309
376803
  // packages/core/node_modules/@a2a-js/sdk/dist/chunk-QQCCX2KH.js
376310
- var import_grpc_js = __toESM(require_src15(), 1);
376804
+ var import_grpc_js2 = __toESM(require_src15(), 1);
376311
376805
  function createBaseEmpty() {
376312
376806
  return {};
376313
376807
  }
@@ -379613,7 +380107,7 @@ var A2AServiceService = {
379613
380107
  responseDeserialize: (value) => Empty.decode(value)
379614
380108
  }
379615
380109
  };
379616
- var A2AServiceClient = (0, import_grpc_js.makeGenericClientConstructor)(A2AServiceService, "a2a.v1.A2AService");
380110
+ var A2AServiceClient = (0, import_grpc_js2.makeGenericClientConstructor)(A2AServiceService, "a2a.v1.A2AService");
379617
380111
  function toTimestamp(dateStr) {
379618
380112
  const date5 = new globalThis.Date(dateStr);
379619
380113
  const seconds = Math.trunc(date5.getTime() / 1e3);
@@ -380462,6 +380956,7 @@ var Config = class {
380462
380956
  target: params.telemetry?.target ?? DEFAULT_TELEMETRY_TARGET,
380463
380957
  otlpEndpoint: params.telemetry?.otlpEndpoint ?? DEFAULT_OTLP_ENDPOINT,
380464
380958
  otlpProtocol: params.telemetry?.otlpProtocol,
380959
+ otlpHeaders: params.telemetry?.otlpHeaders,
380465
380960
  logPrompts: params.telemetry?.logPrompts ?? true,
380466
380961
  outfile: params.telemetry?.outfile,
380467
380962
  useCollector: params.telemetry?.useCollector,
@@ -381720,6 +382215,9 @@ ${sections.join("\n")}
381720
382215
  getTelemetryOtlpProtocol() {
381721
382216
  return this.telemetrySettings.otlpProtocol ?? "grpc";
381722
382217
  }
382218
+ getTelemetryOtlpHeaders() {
382219
+ return this.telemetrySettings.otlpHeaders ?? {};
382220
+ }
381723
382221
  getTelemetryTarget() {
381724
382222
  return this.telemetrySettings.target ?? DEFAULT_TELEMETRY_TARGET;
381725
382223
  }
@@ -399904,6 +400402,7 @@ export {
399904
400402
  GcpLogExporter,
399905
400403
  parseBooleanEnvFlag,
399906
400404
  parseTelemetryTargetValue,
400405
+ parseOtlpHeaders,
399907
400406
  resolveTelemetrySettings,
399908
400407
  logConsecaPolicyGeneration,
399909
400408
  logConsecaVerdict,
@@ -400210,6 +400709,8 @@ export {
400210
400709
  StreamEventType,
400211
400710
  SYNTHETIC_THOUGHT_SIGNATURE2 as SYNTHETIC_THOUGHT_SIGNATURE,
400212
400711
  INTERRUPTED_RESPONSE_PLACEHOLDER,
400712
+ INTERRUPTED_TOOL_RESPONSE_ERROR,
400713
+ CONTINUE_PROMPT_TEXT,
400213
400714
  isValidNonThoughtTextPart,
400214
400715
  THINKING_ONLY_NUDGE_MESSAGE,
400215
400716
  NO_RESPONSE_TEXT_NUDGE_MESSAGE,
@@ -400220,7 +400721,10 @@ export {
400220
400721
  GeminiChat,
400221
400722
  isSchemaDepthError,
400222
400723
  isInvalidArgumentError,
400724
+ buildInterruptedToolResponseParts,
400725
+ ensureTerminalUserTurn,
400223
400726
  stripToolCallIdPrefixes,
400727
+ coalesceConsecutiveContents,
400224
400728
  coalesceConsecutiveRoles,
400225
400729
  stripThoughts2 as stripThoughts,
400226
400730
  populateToolDisplay,