@google/gemini-cli 0.54.0-preview.0 → 0.54.0-preview.1

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 (66) hide show
  1. package/bundle/{chunk-PMUWVEQP.js → chunk-525VQXSC.js} +7 -7
  2. package/bundle/{chunk-4GNXWN36.js → chunk-AFGG2RPD.js} +1 -1
  3. package/bundle/{chunk-K7T2IFNS.js → chunk-CULEIHKX.js} +1 -1
  4. package/bundle/{chunk-CPVZILP2.js → chunk-CVUISPMN.js} +2 -2
  5. package/bundle/{chunk-24AZRO3S.js → chunk-D2EAX3ZX.js} +3 -3
  6. package/bundle/{chunk-QZ32DOIY.js → chunk-DIJ6I3G3.js} +8 -5
  7. package/bundle/{chunk-HYGO4QEK.js → chunk-DPIHBZAT.js} +2 -2
  8. package/bundle/{chunk-XTGYOEM3.js → chunk-FMTFTARW.js} +1 -1
  9. package/bundle/{chunk-GMYSSSFG.js → chunk-FXXIWHGQ.js} +1 -1
  10. package/bundle/{chunk-BMD42WWR.js → chunk-IO55T6DE.js} +3 -3
  11. package/bundle/{chunk-I2F6JPKA.js → chunk-IYJYJHOC.js} +7 -7
  12. package/bundle/{chunk-X7LEASVK.js → chunk-JIT42EQ2.js} +1 -1
  13. package/bundle/{chunk-YVWOOS5D.js → chunk-K3SJRITH.js} +3 -3
  14. package/bundle/{chunk-S2XDE4E6.js → chunk-MSUXP6KY.js} +67 -54
  15. package/bundle/{chunk-UOZMJZMA.js → chunk-OGXJPYSG.js} +180 -39
  16. package/bundle/{chunk-KFW7GOXJ.js → chunk-PEJMTAMT.js} +2 -2
  17. package/bundle/chunk-RCBLHUUY.js +398 -0
  18. package/bundle/chunk-RDYXVWPW.js +118 -0
  19. package/bundle/{chunk-YOK6TS2W.js → chunk-RO4LFQ22.js} +7784 -14255
  20. package/bundle/{chunk-KU7W3PYO.js → chunk-SBSLQYOV.js} +1 -1
  21. package/bundle/{chunk-CZ6IKC6W.js → chunk-SMLDN56O.js} +1 -1
  22. package/bundle/{chunk-ANCJ47GY.js → chunk-T6U6FIO7.js} +9 -8
  23. package/bundle/{chunk-HM6J5QFA.js → chunk-TNVY3HW2.js} +208 -42
  24. package/bundle/chunk-TTNCL6R2.js +154 -0
  25. package/bundle/chunk-UUIODUV3.js +102505 -0
  26. package/bundle/{chunk-ZJJUEIJO.js → chunk-UZMDXL7Q.js} +1 -1
  27. package/bundle/{chunk-JKXIXUUH.js → chunk-VA3G5QBP.js} +1 -1
  28. package/bundle/chunk-XE7YFMNO.js +1571 -0
  29. package/bundle/chunk-YDQPFZ2Y.js +512 -0
  30. package/bundle/{chunk-5X6WKNCA.js → chunk-Z62YA2V7.js} +1 -1
  31. package/bundle/chunk-ZHTU5ILJ.js +397085 -0
  32. package/bundle/chunk-ZPRVIRJI.js +17332 -0
  33. package/bundle/{cleanup-CI4EZBGK.js → cleanup-HQV2IFKH.js} +2 -2
  34. package/bundle/{cleanup-NW33L7BG.js → cleanup-L5VWLPP4.js} +2 -2
  35. package/bundle/{cleanup-WCECJVAH.js → cleanup-XXP2E7MI.js} +2 -2
  36. package/bundle/cleanup-ZVT5D3O6.js +32 -0
  37. package/bundle/{core-X6AKTKZS.js → core-57QOTUGQ.js} +15 -1
  38. package/bundle/{devtoolsService-I4VSDXDZ.js → devtoolsService-35UP55Q3.js} +2 -2
  39. package/bundle/{devtoolsService-YWDOWAQ7.js → devtoolsService-3CR2FLT6.js} +4 -3
  40. package/bundle/devtoolsService-6ODDI2AX.js +4359 -0
  41. package/bundle/{devtoolsService-HT4GPBRA.js → devtoolsService-ZSEA3CMZ.js} +2 -2
  42. package/bundle/{dist-FM4XWKSV.js → dist-47AO7W6O.js} +15 -1
  43. package/bundle/{core-JXOKFSQM.js → dist-H6O2HKLX.js} +15 -1
  44. package/bundle/dist-OQCDYU7F.js +2170 -0
  45. package/bundle/{gemini-M37ESLGX.js → gemini-HAONW54R.js} +282 -202
  46. package/bundle/gemini-IDZJKL5P.js +16491 -0
  47. package/bundle/{gemini-6QYTVAVR.js → gemini-LO7DND33.js} +83 -19
  48. package/bundle/{gemini-LAE4PTZV.js → gemini-UCXGGSBW.js} +83 -19
  49. package/bundle/gemini.js +7 -7
  50. package/bundle/{interactiveCli-353YNM5T.js → interactiveCli-3ACLI4L7.js} +99 -9
  51. package/bundle/{interactiveCli-OZI3EOZ3.js → interactiveCli-6R7JZJ2X.js} +406 -297
  52. package/bundle/interactiveCli-EHIAN3B3.js +34906 -0
  53. package/bundle/{interactiveCli-D26FIBDY.js → interactiveCli-TRSGHNSO.js} +99 -9
  54. package/bundle/{liteRtServerManager-CHOKKKD7.js → liteRtServerManager-3VYWFFDR.js} +4 -4
  55. package/bundle/{liteRtServerManager-QZER65XK.js → liteRtServerManager-E5CRSVVL.js} +4 -4
  56. package/bundle/{liteRtServerManager-5L6ZKYIO.js → liteRtServerManager-VFS4GSUO.js} +4 -4
  57. package/bundle/liteRtServerManager-XWQ4FJKY.js +65 -0
  58. package/bundle/{oauth2-provider-2DMHCM63.js → oauth2-provider-3UXFRSIK.js} +1 -1
  59. package/bundle/{oauth2-provider-RYXZZKGA.js → oauth2-provider-54DMURL5.js} +38 -72
  60. package/bundle/{oauth2-provider-DOSOCLE2.js → oauth2-provider-66YNXHST.js} +1 -1
  61. package/bundle/oauth2-provider-JGXWLD5K.js +235 -0
  62. package/bundle/{start-GSFOK3MC.js → start-2X7CSHIJ.js} +6 -6
  63. package/bundle/{start-H6TOQQTQ.js → start-JT4SJ6FO.js} +6 -6
  64. package/bundle/{start-6KDQYY22.js → start-LZJM7TIF.js} +6 -6
  65. package/bundle/start-YHTESBGR.js +18 -0
  66. package/package.json +1 -1
@@ -157,10 +157,10 @@ import {
157
157
  widestLineFromStyledChars,
158
158
  wordBreakStyledChars,
159
159
  wrapStyledChars
160
- } from "./chunk-S2XDE4E6.js";
160
+ } from "./chunk-IYJYJHOC.js";
161
161
  import {
162
162
  require_source
163
- } from "./chunk-KU7W3PYO.js";
163
+ } from "./chunk-XE7YFMNO.js";
164
164
  import {
165
165
  appEvents
166
166
  } from "./chunk-5PS3AYFU.js";
@@ -214,24 +214,24 @@ import {
214
214
  stripAnsi,
215
215
  stripUnsafeCharacters,
216
216
  toCodePoints
217
- } from "./chunk-QZ32DOIY.js";
217
+ } from "./chunk-VA3G5QBP.js";
218
218
  import {
219
219
  handleAutoUpdate,
220
220
  isDevelopment,
221
221
  relaunchApp,
222
222
  setUpdateHandler
223
- } from "./chunk-KFW7GOXJ.js";
223
+ } from "./chunk-RCBLHUUY.js";
224
224
  import {
225
225
  isTodoList,
226
226
  mapCoreStatusToDisplayStatus,
227
227
  require_react
228
- } from "./chunk-ANCJ47GY.js";
228
+ } from "./chunk-Z62YA2V7.js";
229
229
  import {
230
230
  registerCleanup,
231
231
  removeCleanup,
232
232
  runExitCleanup,
233
233
  setupTtyCheck
234
- } from "./chunk-XTGYOEM3.js";
234
+ } from "./chunk-FMTFTARW.js";
235
235
  import {
236
236
  ACTIVATE_SKILL_TOOL_NAME,
237
237
  AGENT_TOOL_NAME,
@@ -268,8 +268,10 @@ import {
268
268
  LegacyAgentProtocol,
269
269
  LlmRole,
270
270
  Logger,
271
+ MAX_TOKENS_EXCEEDED_SUGGESTION,
271
272
  ModelNotFoundError,
272
273
  ModelSlashCommandEvent,
274
+ OTHER_BLOCKED_MESSAGE,
273
275
  OverageMenuShownEvent,
274
276
  OverageOptionSelectedEvent,
275
277
  PREVIEW_GEMINI_3_1_CUSTOM_TOOLS_MODEL,
@@ -281,16 +283,20 @@ import {
281
283
  ProjectIdRequiredError,
282
284
  READ_FILE_DISPLAY_NAME,
283
285
  READ_MANY_FILES_DISPLAY_NAME,
286
+ RECITATION_BLOCKED_MESSAGE,
284
287
  RELEASE_CHANNEL_STABILITY,
285
288
  ROOT_SCHEDULER_ID,
289
+ SAFETY_BLOCKED_MESSAGE,
286
290
  SHELL_TOOL_NAME,
287
291
  Scheduler,
288
292
  ShellExecutionService,
289
293
  SlashCommandStatus,
290
294
  Storage,
295
+ THINKING_ONLY_COMPRESS_SUGGESTION,
291
296
  TOPIC_PARAM_STRATEGIC_INTENT,
292
297
  TOPIC_PARAM_SUMMARY,
293
298
  TOPIC_PARAM_TITLE,
299
+ TRUE_EMPTY_RESPONSE_MESSAGE,
294
300
  TerminalQuotaError,
295
301
  TranscriptionFactory,
296
302
  UPDATE_TOPIC_DISPLAY_NAME,
@@ -412,7 +418,7 @@ import {
412
418
  validatePlanContent,
413
419
  validatePlanPath,
414
420
  writeToStdout
415
- } from "./chunk-YOK6TS2W.js";
421
+ } from "./chunk-TNVY3HW2.js";
416
422
  import "./chunk-664ZODQF.js";
417
423
  import "./chunk-IUUIT4SU.js";
418
424
  import "./chunk-TUDYL3X4.js";
@@ -8031,6 +8037,18 @@ function areModelMetricsEqual(a, b) {
8031
8037
  if (a.api.totalRequests !== b.api.totalRequests || a.api.totalErrors !== b.api.totalErrors || a.api.totalLatencyMs !== b.api.totalLatencyMs) {
8032
8038
  return false;
8033
8039
  }
8040
+ const errorsA = a.api.errorsByType || {};
8041
+ const errorsB = b.api.errorsByType || {};
8042
+ const keysA = Object.keys(errorsA);
8043
+ const keysB = Object.keys(errorsB);
8044
+ if (keysA.length !== keysB.length) {
8045
+ return false;
8046
+ }
8047
+ for (const key of keysA) {
8048
+ if (errorsA[key] !== errorsB[key]) {
8049
+ return false;
8050
+ }
8051
+ }
8034
8052
  if (a.tokens.input !== b.tokens.input || a.tokens.prompt !== b.tokens.prompt || a.tokens.candidates !== b.tokens.candidates || a.tokens.total !== b.tokens.total || a.tokens.cached !== b.tokens.cached || a.tokens.thoughts !== b.tokens.thoughts || a.tokens.tool !== b.tokens.tool) {
8035
8053
  return false;
8036
8054
  }
@@ -27746,6 +27764,52 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
27746
27764
  maybeAddLowVerbosityFailureNote
27747
27765
  ]
27748
27766
  );
27767
+ const handleInvalidStreamEvent = (0, import_react99.useCallback)(
27768
+ (eventValue, userMessageTimestamp) => {
27769
+ if (pendingHistoryItemRef.current) {
27770
+ addItem(pendingHistoryItemRef.current, userMessageTimestamp);
27771
+ setPendingHistoryItem(null);
27772
+ }
27773
+ maybeAddSuppressedToolErrorNote(userMessageTimestamp);
27774
+ let text = eventValue?.message?.trim() || "Invalid stream received from model";
27775
+ if (eventValue?.type === "NO_RESPONSE_TEXT") {
27776
+ text = TRUE_EMPTY_RESPONSE_MESSAGE;
27777
+ } else if (eventValue?.type === "THINKING_ONLY_RESPONSE") {
27778
+ text = THINKING_ONLY_COMPRESS_SUGGESTION;
27779
+ } else if (eventValue?.type === "MAX_TOKENS_EXCEEDED") {
27780
+ text = MAX_TOKENS_EXCEEDED_SUGGESTION;
27781
+ } else if (eventValue?.type === "SAFETY_BLOCKED") {
27782
+ text = SAFETY_BLOCKED_MESSAGE;
27783
+ } else if (eventValue?.type === "RECITATION_BLOCKED") {
27784
+ text = RECITATION_BLOCKED_MESSAGE;
27785
+ } else if (eventValue?.type === "OTHER_BLOCKED") {
27786
+ text = OTHER_BLOCKED_MESSAGE;
27787
+ }
27788
+ uiTelemetryService.recordSemanticValidationError(
27789
+ geminiClient.getCurrentSequenceModel() ?? config.getModel(),
27790
+ eventValue?.type || "INVALID_STREAM"
27791
+ );
27792
+ addItem(
27793
+ {
27794
+ type: "error" /* ERROR */,
27795
+ text
27796
+ },
27797
+ userMessageTimestamp
27798
+ );
27799
+ maybeAddLowVerbosityFailureNote(userMessageTimestamp);
27800
+ setThought(null);
27801
+ },
27802
+ [
27803
+ addItem,
27804
+ pendingHistoryItemRef,
27805
+ setPendingHistoryItem,
27806
+ setThought,
27807
+ maybeAddSuppressedToolErrorNote,
27808
+ maybeAddLowVerbosityFailureNote,
27809
+ config,
27810
+ geminiClient
27811
+ ]
27812
+ );
27749
27813
  const handleCitationEvent = (0, import_react99.useCallback)(
27750
27814
  (text, userMessageTimestamp) => {
27751
27815
  if (!showCitations(settings)) {
@@ -28001,7 +28065,9 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28001
28065
  loopDetectedRef.current = true;
28002
28066
  break;
28003
28067
  case "retry" /* Retry */:
28068
+ break;
28004
28069
  case "invalid_stream" /* InvalidStream */:
28070
+ handleInvalidStreamEvent(event.value, userMessageTimestamp);
28005
28071
  break;
28006
28072
  default: {
28007
28073
  const unreachable = event;
@@ -28033,6 +28099,7 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28033
28099
  handleChatModelEvent,
28034
28100
  handleAgentExecutionStoppedEvent,
28035
28101
  handleAgentExecutionBlockedEvent,
28102
+ handleInvalidStreamEvent,
28036
28103
  addItem,
28037
28104
  pendingHistoryItemRef,
28038
28105
  setPendingHistoryItem,
@@ -28275,6 +28342,28 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28275
28342
  return false;
28276
28343
  }
28277
28344
  );
28345
+ if (turnCancelledRef.current) {
28346
+ setIsResponding(false);
28347
+ const geminiTools2 = completedAndReadyToSubmitTools.filter(
28348
+ (t) => !t.request.isClientInitiated
28349
+ );
28350
+ if (geminiClient && geminiTools2.length > 0) {
28351
+ const combinedParts = geminiTools2.flatMap(
28352
+ (toolCall) => toolCall.response.responseParts
28353
+ );
28354
+ if (combinedParts.length > 0) {
28355
+ geminiClient.addHistory({
28356
+ role: "user",
28357
+ parts: combinedParts
28358
+ });
28359
+ }
28360
+ }
28361
+ const callIdsToMarkAsSubmitted2 = toolCalls.map(
28362
+ (toolCall) => toolCall.request.callId
28363
+ );
28364
+ markToolsAsSubmitted(callIdsToMarkAsSubmitted2);
28365
+ return;
28366
+ }
28278
28367
  const clientTools = completedAndReadyToSubmitTools.filter(
28279
28368
  (t) => t.request.isClientInitiated
28280
28369
  );
@@ -28412,7 +28501,8 @@ var useGeminiStream = (geminiClient, history, addItem, config, settings, onDebug
28412
28501
  isLowErrorVerbosity,
28413
28502
  maybeAddSuppressedToolErrorNote,
28414
28503
  maybeAddLowVerbosityFailureNote,
28415
- setIsResponding
28504
+ setIsResponding,
28505
+ toolCalls
28416
28506
  ]
28417
28507
  );
28418
28508
  const pendingHistoryItems = (0, import_react99.useMemo)(
@@ -33778,7 +33868,7 @@ ${queuedText}` : queuedText;
33778
33868
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
33779
33869
  if (settings.merged.general.devtools) {
33780
33870
  void (async () => {
33781
- const { toggleDevToolsPanel } = await import("./devtoolsService-HT4GPBRA.js");
33871
+ const { toggleDevToolsPanel } = await import("./devtoolsService-ZSEA3CMZ.js");
33782
33872
  await toggleDevToolsPanel(
33783
33873
  config,
33784
33874
  showErrorDetails,
@@ -3,11 +3,11 @@ import {
3
3
  DEFAULT_PORT,
4
4
  getBinaryPath,
5
5
  isServerRunning
6
- } from "./chunk-QZ32DOIY.js";
7
- import "./chunk-ANCJ47GY.js";
6
+ } from "./chunk-VA3G5QBP.js";
7
+ import "./chunk-Z62YA2V7.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-YOK6TS2W.js";
10
+ } from "./chunk-TNVY3HW2.js";
11
11
  import "./chunk-664ZODQF.js";
12
12
  import "./chunk-IUUIT4SU.js";
13
13
  import "./chunk-TUDYL3X4.js";
@@ -41,7 +41,7 @@ var LiteRtServerManager = class {
41
41
  `[LiteRtServerManager] Auto-starting LiteRT server on port ${port}...`
42
42
  );
43
43
  try {
44
- const { startServer } = await import("./start-GSFOK3MC.js");
44
+ const { startServer } = await import("./start-JT4SJ6FO.js");
45
45
  const started = await startServer(binaryPath, port);
46
46
  if (started) {
47
47
  debugLogger.log(`[LiteRtServerManager] Server started on port ${port}`);
@@ -3,11 +3,11 @@ import {
3
3
  DEFAULT_PORT,
4
4
  getBinaryPath,
5
5
  isServerRunning
6
- } from "./chunk-4GNXWN36.js";
7
- import "./chunk-CZ6IKC6W.js";
6
+ } from "./chunk-DIJ6I3G3.js";
7
+ import "./chunk-T6U6FIO7.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-UOZMJZMA.js";
10
+ } from "./chunk-ZHTU5ILJ.js";
11
11
  import "./chunk-664ZODQF.js";
12
12
  import "./chunk-IUUIT4SU.js";
13
13
  import "./chunk-TUDYL3X4.js";
@@ -41,7 +41,7 @@ var LiteRtServerManager = class {
41
41
  `[LiteRtServerManager] Auto-starting LiteRT server on port ${port}...`
42
42
  );
43
43
  try {
44
- const { startServer } = await import("./start-6KDQYY22.js");
44
+ const { startServer } = await import("./start-YHTESBGR.js");
45
45
  const started = await startServer(binaryPath, port);
46
46
  if (started) {
47
47
  debugLogger.log(`[LiteRtServerManager] Server started on port ${port}`);
@@ -3,11 +3,11 @@ import {
3
3
  DEFAULT_PORT,
4
4
  getBinaryPath,
5
5
  isServerRunning
6
- } from "./chunk-JKXIXUUH.js";
7
- import "./chunk-5X6WKNCA.js";
6
+ } from "./chunk-ZPRVIRJI.js";
7
+ import "./chunk-SMLDN56O.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-HM6J5QFA.js";
10
+ } from "./chunk-RO4LFQ22.js";
11
11
  import "./chunk-664ZODQF.js";
12
12
  import "./chunk-IUUIT4SU.js";
13
13
  import "./chunk-TUDYL3X4.js";
@@ -41,7 +41,7 @@ var LiteRtServerManager = class {
41
41
  `[LiteRtServerManager] Auto-starting LiteRT server on port ${port}...`
42
42
  );
43
43
  try {
44
- const { startServer } = await import("./start-H6TOQQTQ.js");
44
+ const { startServer } = await import("./start-2X7CSHIJ.js");
45
45
  const started = await startServer(binaryPath, port);
46
46
  if (started) {
47
47
  debugLogger.log(`[LiteRtServerManager] Server started on port ${port}`);
@@ -0,0 +1,65 @@
1
+ const require = (await import('node:module')).createRequire(import.meta.url); const __chunk_filename = (await import('node:url')).fileURLToPath(import.meta.url); const __chunk_dirname = (await import('node:path')).dirname(__chunk_filename);
2
+ import {
3
+ DEFAULT_PORT,
4
+ getBinaryPath,
5
+ isServerRunning
6
+ } from "./chunk-AFGG2RPD.js";
7
+ import "./chunk-YDQPFZ2Y.js";
8
+ import {
9
+ debugLogger
10
+ } from "./chunk-OGXJPYSG.js";
11
+ import "./chunk-664ZODQF.js";
12
+ import "./chunk-IUUIT4SU.js";
13
+ import "./chunk-TUDYL3X4.js";
14
+ import "./chunk-34MYV7JD.js";
15
+
16
+ // packages/cli/src/services/liteRtServerManager.ts
17
+ import fs from "node:fs";
18
+ var LiteRtServerManager = class {
19
+ static async ensureRunning(gemmaSettings) {
20
+ if (!gemmaSettings?.enabled) return;
21
+ if (gemmaSettings.autoStartServer === false) return;
22
+ const binaryPath = getBinaryPath();
23
+ if (!binaryPath || !fs.existsSync(binaryPath)) {
24
+ debugLogger.log(
25
+ '[LiteRtServerManager] Binary not installed, skipping auto-start. Run "gemini gemma setup".'
26
+ );
27
+ return;
28
+ }
29
+ const port = parseInt(
30
+ gemmaSettings.classifier?.host?.match(/:(\d+)/)?.[1] ?? "",
31
+ 10
32
+ ) || DEFAULT_PORT;
33
+ const running = await isServerRunning(port);
34
+ if (running) {
35
+ debugLogger.log(
36
+ `[LiteRtServerManager] Server already running on port ${port}`
37
+ );
38
+ return;
39
+ }
40
+ debugLogger.log(
41
+ `[LiteRtServerManager] Auto-starting LiteRT server on port ${port}...`
42
+ );
43
+ try {
44
+ const { startServer } = await import("./start-LZJM7TIF.js");
45
+ const started = await startServer(binaryPath, port);
46
+ if (started) {
47
+ debugLogger.log(`[LiteRtServerManager] Server started on port ${port}`);
48
+ } else {
49
+ debugLogger.warn(
50
+ `[LiteRtServerManager] Server may not have started correctly on port ${port}`
51
+ );
52
+ }
53
+ } catch (error) {
54
+ debugLogger.warn("[LiteRtServerManager] Auto-start failed:", error);
55
+ }
56
+ }
57
+ };
58
+ export {
59
+ LiteRtServerManager
60
+ };
61
+ /**
62
+ * @license
63
+ * Copyright 2026 Google LLC
64
+ * SPDX-License-Identifier: Apache-2.0
65
+ */
@@ -16,7 +16,7 @@ import {
16
16
  openBrowserSecurely,
17
17
  refreshAccessToken,
18
18
  startCallbackServer
19
- } from "./chunk-UOZMJZMA.js";
19
+ } from "./chunk-ZHTU5ILJ.js";
20
20
  import "./chunk-664ZODQF.js";
21
21
  import "./chunk-IUUIT4SU.js";
22
22
  import "./chunk-TUDYL3X4.js";
@@ -16,35 +16,35 @@ import {
16
16
  openBrowserSecurely,
17
17
  refreshAccessToken,
18
18
  startCallbackServer
19
- } from "./chunk-YOK6TS2W.js";
19
+ } from "./chunk-OGXJPYSG.js";
20
20
  import "./chunk-664ZODQF.js";
21
21
  import "./chunk-IUUIT4SU.js";
22
22
  import "./chunk-TUDYL3X4.js";
23
23
  import "./chunk-34MYV7JD.js";
24
24
 
25
- // packages/core/src/agents/auth-provider/oauth2-provider.ts
25
+ // packages/core/dist/src/agents/auth-provider/oauth2-provider.js
26
26
  var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
27
+ config;
28
+ agentName;
29
+ agentCardUrl;
30
+ type = "oauth2";
31
+ tokenStorage;
32
+ cachedToken = null;
33
+ /** Resolved OAuth URLs — may come from config or agent card. */
34
+ authorizationUrl;
35
+ tokenUrl;
36
+ scopes;
27
37
  constructor(config, agentName, agentCard, agentCardUrl) {
28
38
  super();
29
39
  this.config = config;
30
40
  this.agentName = agentName;
31
41
  this.agentCardUrl = agentCardUrl;
32
- this.tokenStorage = new MCPOAuthTokenStorage(
33
- Storage.getA2AOAuthTokensPath(),
34
- "gemini-cli-a2a"
35
- );
42
+ this.tokenStorage = new MCPOAuthTokenStorage(Storage.getA2AOAuthTokensPath(), "gemini-cli-a2a");
36
43
  this.authorizationUrl = config.authorization_url;
37
44
  this.tokenUrl = config.token_url;
38
45
  this.scopes = config.scopes;
39
46
  this.mergeAgentCardDefaults(agentCard);
40
47
  }
41
- type = "oauth2";
42
- tokenStorage;
43
- cachedToken = null;
44
- /** Resolved OAuth URLs — may come from config or agent card. */
45
- authorizationUrl;
46
- tokenUrl;
47
- scopes;
48
48
  /**
49
49
  * Initialize the provider by loading any persisted token from storage.
50
50
  * Also discovers OAuth URLs from the agent card if not yet resolved.
@@ -56,9 +56,7 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
56
56
  const credentials = await this.tokenStorage.getCredentials(this.agentName);
57
57
  if (credentials && !this.tokenStorage.isTokenExpired(credentials.token)) {
58
58
  this.cachedToken = credentials.token;
59
- debugLogger.debug(
60
- `[OAuth2AuthProvider] Loaded valid cached token for "${this.agentName}"`
61
- );
59
+ debugLogger.debug(`[OAuth2AuthProvider] Loaded valid cached token for "${this.agentName}"`);
62
60
  }
63
61
  }
64
62
  /**
@@ -71,25 +69,16 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
71
69
  }
72
70
  if (this.cachedToken?.refreshToken && this.tokenUrl && this.config.client_id) {
73
71
  try {
74
- const refreshed = await refreshAccessToken(
75
- {
76
- clientId: this.config.client_id,
77
- clientSecret: this.config.client_secret,
78
- scopes: this.scopes
79
- },
80
- this.cachedToken.refreshToken,
81
- this.tokenUrl
82
- );
83
- this.cachedToken = this.toOAuthToken(
84
- refreshed,
85
- this.cachedToken.refreshToken
86
- );
72
+ const refreshed = await refreshAccessToken({
73
+ clientId: this.config.client_id,
74
+ clientSecret: this.config.client_secret,
75
+ scopes: this.scopes
76
+ }, this.cachedToken.refreshToken, this.tokenUrl);
77
+ this.cachedToken = this.toOAuthToken(refreshed, this.cachedToken.refreshToken);
87
78
  await this.persistToken();
88
79
  return { Authorization: `Bearer ${this.cachedToken.accessToken}` };
89
80
  } catch (error) {
90
- debugLogger.debug(
91
- `[OAuth2AuthProvider] Refresh failed, falling back to interactive flow: ${getErrorMessage(error)}`
92
- );
81
+ debugLogger.debug(`[OAuth2AuthProvider] Refresh failed, falling back to interactive flow: ${getErrorMessage(error)}`);
93
82
  await this.tokenStorage.deleteCredentials(this.agentName);
94
83
  }
95
84
  }
@@ -108,9 +97,7 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
108
97
  return void 0;
109
98
  }
110
99
  this.authRetryCount++;
111
- debugLogger.debug(
112
- "[OAuth2AuthProvider] Auth failure, clearing token and re-authenticating"
113
- );
100
+ debugLogger.debug("[OAuth2AuthProvider] Auth failure, clearing token and re-authenticating");
114
101
  this.cachedToken = null;
115
102
  await this.tokenStorage.deleteCredentials(this.agentName);
116
103
  return this.headers();
@@ -123,7 +110,8 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
123
110
  * `securitySchemes` when not already provided via user config.
124
111
  */
125
112
  mergeAgentCardDefaults(agentCard) {
126
- if (!agentCard?.securitySchemes) return;
113
+ if (!agentCard?.securitySchemes)
114
+ return;
127
115
  for (const scheme of Object.values(agentCard.securitySchemes)) {
128
116
  if (scheme.type === "oauth2" && scheme.flows.authorizationCode) {
129
117
  const flow = scheme.flows.authorizationCode;
@@ -139,18 +127,15 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
139
127
  * (which normalizes proto-format cards) and extract OAuth2 URLs.
140
128
  */
141
129
  async fetchAgentCardDefaults() {
142
- if (!this.agentCardUrl) return;
130
+ if (!this.agentCardUrl)
131
+ return;
143
132
  try {
144
- debugLogger.debug(
145
- `[OAuth2AuthProvider] Fetching agent card from ${this.agentCardUrl}`
146
- );
133
+ debugLogger.debug(`[OAuth2AuthProvider] Fetching agent card from ${this.agentCardUrl}`);
147
134
  const resolver = new DefaultAgentCardResolver();
148
135
  const card = await resolver.resolve(this.agentCardUrl, "");
149
136
  this.mergeAgentCardDefaults(card);
150
137
  } catch (error) {
151
- debugLogger.warn(
152
- `[OAuth2AuthProvider] Could not fetch agent card for OAuth URL discovery: ${getErrorMessage(error)}`
153
- );
138
+ debugLogger.warn(`[OAuth2AuthProvider] Could not fetch agent card for OAuth URL discovery: ${getErrorMessage(error)}`);
154
139
  }
155
140
  }
156
141
  /**
@@ -158,14 +143,10 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
158
143
  */
159
144
  async authenticateInteractively() {
160
145
  if (!this.config.client_id) {
161
- throw new Error(
162
- `OAuth2 authentication for agent "${this.agentName}" requires a client_id. Add client_id to the auth config in your agent definition.`
163
- );
146
+ throw new Error(`OAuth2 authentication for agent "${this.agentName}" requires a client_id. Add client_id to the auth config in your agent definition.`);
164
147
  }
165
148
  if (!this.authorizationUrl || !this.tokenUrl) {
166
- throw new Error(
167
- `OAuth2 authentication for agent "${this.agentName}" requires authorization_url and token_url. Provide them in the auth config or ensure the agent card exposes an oauth2 security scheme.`
168
- );
149
+ throw new Error(`OAuth2 authentication for agent "${this.agentName}" requires authorization_url and token_url. Provide them in the auth config or ensure the agent card exposes an oauth2 security scheme.`);
169
150
  }
170
151
  const flowConfig = {
171
152
  clientId: this.config.client_id,
@@ -184,36 +165,25 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
184
165
  redirectPort,
185
166
  /* resource= */
186
167
  void 0
187
- // No MCP resource parameter for A2A.
188
- );
189
- const consent = await getConsentForOauth(
190
- `Authentication required for A2A agent: '${this.agentName}'.`
191
168
  );
169
+ const consent = await getConsentForOauth(`Authentication required for A2A agent: '${this.agentName}'.`);
192
170
  if (!consent) {
193
171
  throw new FatalCancellationError("Authentication cancelled by user.");
194
172
  }
195
- coreEvents.emitFeedback(
196
- "info",
197
- `\u2192 Opening your browser for OAuth sign-in...
173
+ coreEvents.emitFeedback("info", `\u2192 Opening your browser for OAuth sign-in...
198
174
 
199
175
  If the browser does not open, copy and paste this URL into your browser:
200
176
  ${authUrl}
201
177
 
202
178
  \u{1F4A1} TIP: Triple-click to select the entire URL, then copy and paste it into your browser.
203
- \u26A0\uFE0F Make sure to copy the COMPLETE URL - it may wrap across multiple lines.`
204
- );
179
+ \u26A0\uFE0F Make sure to copy the COMPLETE URL - it may wrap across multiple lines.`);
205
180
  try {
206
181
  await openBrowserSecurely(authUrl);
207
182
  } catch (error) {
208
- debugLogger.warn(
209
- "Failed to open browser automatically:",
210
- getErrorMessage(error)
211
- );
183
+ debugLogger.warn("Failed to open browser automatically:", getErrorMessage(error));
212
184
  }
213
185
  const { code } = await callbackServer.response;
214
- debugLogger.debug(
215
- "\u2713 Authorization code received, exchanging for tokens..."
216
- );
186
+ debugLogger.debug("\u2713 Authorization code received, exchanging for tokens...");
217
187
  const tokenResponse = await exchangeCodeForToken(
218
188
  flowConfig,
219
189
  code,
@@ -250,13 +220,9 @@ ${authUrl}
250
220
  * Persist the current cached token to disk.
251
221
  */
252
222
  async persistToken() {
253
- if (!this.cachedToken) return;
254
- await this.tokenStorage.saveToken(
255
- this.agentName,
256
- this.cachedToken,
257
- this.config.client_id,
258
- this.tokenUrl
259
- );
223
+ if (!this.cachedToken)
224
+ return;
225
+ await this.tokenStorage.saveToken(this.agentName, this.cachedToken, this.config.client_id, this.tokenUrl);
260
226
  }
261
227
  };
262
228
  export {
@@ -16,7 +16,7 @@ import {
16
16
  openBrowserSecurely,
17
17
  refreshAccessToken,
18
18
  startCallbackServer
19
- } from "./chunk-HM6J5QFA.js";
19
+ } from "./chunk-TNVY3HW2.js";
20
20
  import "./chunk-664ZODQF.js";
21
21
  import "./chunk-IUUIT4SU.js";
22
22
  import "./chunk-TUDYL3X4.js";