@google/gemini-cli 0.45.0 → 0.46.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 (71) hide show
  1. package/bundle/{chunk-SG46YSQ3.js → chunk-24H54ISH.js} +7 -7
  2. package/bundle/{chunk-YI3KORH5.js → chunk-3EC3ZLRQ.js} +2 -2
  3. package/bundle/{chunk-EORX7LYI.js → chunk-3WW2LTMX.js} +1 -1
  4. package/bundle/{chunk-2ARYG3KE.js → chunk-4B7MDBUK.js} +1 -1
  5. package/bundle/{chunk-EUYIPFPA.js → chunk-5CWORGE3.js} +1 -1
  6. package/bundle/{chunk-K6WTIGVC.js → chunk-5IBYZHR7.js} +2 -2
  7. package/bundle/{chunk-TWSSMLUS.js → chunk-7Y6NU65D.js} +1 -1
  8. package/bundle/{chunk-4KOU3QNT.js → chunk-EG7USKV5.js} +8 -5
  9. package/bundle/{chunk-PNU4GACG.js → chunk-EZDKSTIF.js} +2 -2
  10. package/bundle/{chunk-THZMPVCN.js → chunk-GRD2P7HY.js} +1 -1
  11. package/bundle/chunk-HQNVDCXK.js +154 -0
  12. package/bundle/chunk-ILHDA6XU.js +17320 -0
  13. package/bundle/{chunk-6T7N6JF2.js → chunk-ITC7TFJU.js} +156 -50
  14. package/bundle/{chunk-53SRWMUU.js → chunk-JF6RJW53.js} +1 -1
  15. package/bundle/chunk-JPYTHGMI.js +398 -0
  16. package/bundle/{chunk-XV2YFH7B.js → chunk-KOJR46UO.js} +7654 -14056
  17. package/bundle/{chunk-4EBMYFID.js → chunk-KQ4V7ZN4.js} +67 -54
  18. package/bundle/chunk-O3UKVEBS.js +81685 -0
  19. package/bundle/{chunk-VL3FKVC7.js → chunk-ONUDATHO.js} +3 -3
  20. package/bundle/{chunk-N6QPQL7E.js → chunk-QEVRJ7HY.js} +183 -50
  21. package/bundle/{chunk-3TWZMAJU.js → chunk-QFWAILKU.js} +3 -3
  22. package/bundle/{chunk-GVEZJIV3.js → chunk-QMCEWHRR.js} +1 -1
  23. package/bundle/{chunk-IL7J46PP.js → chunk-R4LEIQZM.js} +3 -3
  24. package/bundle/{chunk-JLFE3KRS.js → chunk-RXYIE5L5.js} +1 -1
  25. package/bundle/{chunk-Z5F25543.js → chunk-UM53YDCH.js} +1 -1
  26. package/bundle/{chunk-PXEK5ENZ.js → chunk-VEHSYWQT.js} +9 -8
  27. package/bundle/chunk-VETILJQA.js +1571 -0
  28. package/bundle/chunk-VOFVOS4I.js +118 -0
  29. package/bundle/chunk-WRWCUHAM.js +512 -0
  30. package/bundle/chunk-XVDCGVTF.js +394545 -0
  31. package/bundle/{chunk-HFVEWB6N.js → chunk-YINW7YTJ.js} +1 -1
  32. package/bundle/{chunk-KSNTXH4E.js → chunk-YIOYXRDP.js} +7 -7
  33. package/bundle/{cleanup-3SMSXJJA.js → cleanup-4ZTB4WMN.js} +2 -2
  34. package/bundle/{cleanup-FNQ3LEWG.js → cleanup-7LLX4OFN.js} +2 -2
  35. package/bundle/{cleanup-I56KHTTC.js → cleanup-GI5426XS.js} +2 -2
  36. package/bundle/cleanup-ZBLVGXIK.js +32 -0
  37. package/bundle/{core-KGXBOJTX.js → core-3UQQYNJF.js} +7 -1
  38. package/bundle/{devtoolsService-EW3B2Y63.js → devtoolsService-GJWWZ2KK.js} +2 -2
  39. package/bundle/{devtoolsService-F7PHNBEQ.js → devtoolsService-UNQILSWI.js} +4 -3
  40. package/bundle/devtoolsService-Z2YXVMYF.js +856 -0
  41. package/bundle/{devtoolsService-VFEFRDYG.js → devtoolsService-ZYGDAPOV.js} +2 -2
  42. package/bundle/{dist-2G5KTD32.js → dist-4NVM6I2N.js} +7 -1
  43. package/bundle/{core-AQUUQTX2.js → dist-LIQULVXZ.js} +7 -1
  44. package/bundle/dist-XPP357J7.js +2140 -0
  45. package/bundle/docs/changelogs/index.md +14 -0
  46. package/bundle/docs/changelogs/latest.md +202 -199
  47. package/bundle/docs/changelogs/preview.md +44 -200
  48. package/bundle/docs/issue-and-pr-automation.md +29 -1
  49. package/bundle/docs/reference/configuration.md +71 -0
  50. package/bundle/{gemini-ORQHD633.js → gemini-5WY2YO7R.js} +18 -15
  51. package/bundle/{gemini-JMMBFICD.js → gemini-7GZVH4VW.js} +216 -197
  52. package/bundle/{gemini-4KS2EZX6.js → gemini-QDOVPRKF.js} +18 -15
  53. package/bundle/gemini-RBKWBGCC.js +16409 -0
  54. package/bundle/gemini.js +7 -7
  55. package/bundle/{interactiveCli-XUZZOZXX.js → interactiveCli-BMKHWEH4.js} +29 -13
  56. package/bundle/{interactiveCli-ESB66RW7.js → interactiveCli-OEFOYFJU.js} +335 -300
  57. package/bundle/interactiveCli-OGE5OTZB.js +34742 -0
  58. package/bundle/{interactiveCli-ZJXV4DW7.js → interactiveCli-W3CMLQIM.js} +29 -13
  59. package/bundle/{liteRtServerManager-HELKQKOZ.js → liteRtServerManager-3QOJEGNL.js} +4 -4
  60. package/bundle/{liteRtServerManager-RNNHEQJI.js → liteRtServerManager-HPVNUYFX.js} +4 -4
  61. package/bundle/{liteRtServerManager-DORIWEMR.js → liteRtServerManager-Q6LTEYH4.js} +4 -4
  62. package/bundle/liteRtServerManager-YL4YRHOA.js +65 -0
  63. package/bundle/{oauth2-provider-2IJNOFOO.js → oauth2-provider-3WXIASQA.js} +1 -1
  64. package/bundle/{oauth2-provider-7N4OFPTL.js → oauth2-provider-CTPS7JLT.js} +1 -1
  65. package/bundle/{oauth2-provider-YYLBPESU.js → oauth2-provider-K52EY6RG.js} +38 -72
  66. package/bundle/oauth2-provider-PJJE326A.js +235 -0
  67. package/bundle/{start-IGG6LDST.js → start-25W6VZG6.js} +6 -6
  68. package/bundle/{start-R7DTCFCN.js → start-JBJSIKIB.js} +6 -6
  69. package/bundle/{start-66KF6MVV.js → start-PK22QMBT.js} +6 -6
  70. package/bundle/start-XAEHV6FV.js +18 -0
  71. package/package.json +1 -1
@@ -155,13 +155,13 @@ import {
155
155
  widestLineFromStyledChars,
156
156
  wordBreakStyledChars,
157
157
  wrapStyledChars
158
- } from "./chunk-KSNTXH4E.js";
158
+ } from "./chunk-YIOYXRDP.js";
159
159
  import {
160
160
  appEvents
161
161
  } from "./chunk-5PS3AYFU.js";
162
162
  import {
163
163
  require_source
164
- } from "./chunk-GVEZJIV3.js";
164
+ } from "./chunk-VETILJQA.js";
165
165
  import {
166
166
  ACTIVE_SHELL_MAX_LINES,
167
167
  COMPACT_TOOL_SUBVIEW_MAX_LINES,
@@ -211,24 +211,24 @@ import {
211
211
  stringWidth,
212
212
  stripUnsafeCharacters,
213
213
  toCodePoints
214
- } from "./chunk-2ARYG3KE.js";
214
+ } from "./chunk-4B7MDBUK.js";
215
215
  import {
216
216
  handleAutoUpdate,
217
217
  isDevelopment,
218
218
  relaunchApp,
219
219
  setUpdateHandler
220
- } from "./chunk-YI3KORH5.js";
220
+ } from "./chunk-3EC3ZLRQ.js";
221
221
  import {
222
222
  isTodoList,
223
223
  mapCoreStatusToDisplayStatus,
224
224
  require_react
225
- } from "./chunk-HFVEWB6N.js";
225
+ } from "./chunk-YINW7YTJ.js";
226
226
  import {
227
227
  registerCleanup,
228
228
  removeCleanup,
229
229
  runExitCleanup,
230
230
  setupTtyCheck
231
- } from "./chunk-TWSSMLUS.js";
231
+ } from "./chunk-HQNVDCXK.js";
232
232
  import {
233
233
  ACTIVATE_SKILL_TOOL_NAME,
234
234
  AGENT_TOOL_NAME,
@@ -410,7 +410,7 @@ import {
410
410
  validatePlanContent,
411
411
  validatePlanPath,
412
412
  writeToStdout
413
- } from "./chunk-N6QPQL7E.js";
413
+ } from "./chunk-QEVRJ7HY.js";
414
414
  import "./chunk-6HI7VNOG.js";
415
415
  import "./chunk-TUDYL3X4.js";
416
416
  import "./chunk-IUUIT4SU.js";
@@ -8243,7 +8243,7 @@ var ModelUsageTable = ({ models }) => {
8243
8243
  Object.entries(models).forEach(([name, metrics]) => {
8244
8244
  rows.push({
8245
8245
  name,
8246
- displayName: name,
8246
+ displayName: getDisplayString(name),
8247
8247
  requests: metrics.api.totalRequests,
8248
8248
  cachedTokens: metrics.tokens.cached.toLocaleString(),
8249
8249
  inputTokens: metrics.tokens.prompt.toLocaleString(),
@@ -8727,7 +8727,7 @@ var ModelStatsDisplay = ({
8727
8727
  },
8728
8728
  ...modelNames.map((name) => ({
8729
8729
  key: name,
8730
- header: name,
8730
+ header: getDisplayString(name),
8731
8731
  flexGrow: 1,
8732
8732
  renderCell: (row) => {
8733
8733
  if (row.isSection) return null;
@@ -15027,9 +15027,18 @@ function EditorSettingsDialog({
15027
15027
  let editorIndex = currentPreference ? editorItems.findIndex(
15028
15028
  (item) => item.type === currentPreference
15029
15029
  ) : 0;
15030
- if (editorIndex === -1) {
15030
+ const isUnsupportedEditor = editorIndex === -1;
15031
+ if (isUnsupportedEditor) {
15031
15032
  editorIndex = 0;
15032
15033
  }
15034
+ (0, import_react50.useEffect)(() => {
15035
+ if (isUnsupportedEditor && currentPreference) {
15036
+ coreEvents.emitFeedback(
15037
+ "error",
15038
+ `Editor is not supported: ${currentPreference}`
15039
+ );
15040
+ }
15041
+ }, [isUnsupportedEditor, currentPreference]);
15033
15042
  const scopeItems = [
15034
15043
  {
15035
15044
  label: "User Settings",
@@ -16624,6 +16633,7 @@ function ModelDialog({ onClose }) {
16624
16633
  const preferredModel = config?.getModel() || GEMINI_MODEL_ALIAS_AUTO;
16625
16634
  const shouldShowPreviewModels = config?.getHasAccessToPreviewModel() ?? false;
16626
16635
  const useGemini31 = config?.getGemini31LaunchedSync?.() ?? false;
16636
+ const useGemini3_5Flash = config?.hasGemini35FlashGAAccess?.() ?? false;
16627
16637
  const selectedAuthType = settings.merged.security.auth.selectedType;
16628
16638
  const useCustomToolModel = useGemini31 && selectedAuthType === "gemini-api-key" /* USE_GEMINI */;
16629
16639
  const manualModelSelected = (0, import_react55.useMemo)(() => {
@@ -16668,6 +16678,7 @@ function ModelDialog({ onClose }) {
16668
16678
  if (config?.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
16669
16679
  const allOptions = config.getModelConfigService().getAvailableModelOptions({
16670
16680
  useGemini3_1: useGemini31,
16681
+ useGemini3_5Flash,
16671
16682
  useCustomTools: useCustomToolModel,
16672
16683
  hasAccessToPreview: shouldShowPreviewModels,
16673
16684
  hasAccessToProModel
@@ -16692,7 +16703,8 @@ function ModelDialog({ onClose }) {
16692
16703
  title: getDisplayString(GEMINI_MODEL_ALIAS_AUTO),
16693
16704
  description: getAutoModelDescription(
16694
16705
  shouldShowPreviewModels,
16695
- useGemini31
16706
+ useGemini31,
16707
+ useGemini3_5Flash
16696
16708
  ),
16697
16709
  key: GEMINI_MODEL_ALIAS_AUTO
16698
16710
  },
@@ -16709,6 +16721,7 @@ function ModelDialog({ onClose }) {
16709
16721
  shouldShowPreviewModels,
16710
16722
  manualModelSelected,
16711
16723
  useGemini31,
16724
+ useGemini3_5Flash,
16712
16725
  useCustomToolModel,
16713
16726
  hasAccessToProModel
16714
16727
  ]);
@@ -16716,6 +16729,7 @@ function ModelDialog({ onClose }) {
16716
16729
  if (config?.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
16717
16730
  const allOptions = config.getModelConfigService().getAvailableModelOptions({
16718
16731
  useGemini3_1: useGemini31,
16732
+ useGemini3_5Flash,
16719
16733
  useCustomTools: useCustomToolModel,
16720
16734
  hasAccessToPreview: shouldShowPreviewModels,
16721
16735
  hasAccessToProModel
@@ -16789,6 +16803,7 @@ function ModelDialog({ onClose }) {
16789
16803
  }, [
16790
16804
  shouldShowPreviewModels,
16791
16805
  useGemini31,
16806
+ useGemini3_5Flash,
16792
16807
  useCustomToolModel,
16793
16808
  hasAccessToProModel,
16794
16809
  config
@@ -22600,7 +22615,8 @@ var WITTY_LOADING_PHRASES = [
22600
22615
  "Have you tried turning it off and on again? (The loading screen, not me.)",
22601
22616
  "Constructing additional pylons",
22602
22617
  "New line? That\u2019s Ctrl+J.",
22603
- "Releasing the HypnoDrones"
22618
+ "Releasing the HypnoDrones",
22619
+ "Pushing the button, Frank."
22604
22620
  ];
22605
22621
 
22606
22622
  // packages/cli/src/ui/hooks/usePhraseCycler.ts
@@ -33702,7 +33718,7 @@ ${queuedText}` : queuedText;
33702
33718
  if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
33703
33719
  if (settings.merged.general.devtools) {
33704
33720
  void (async () => {
33705
- const { toggleDevToolsPanel } = await import("./devtoolsService-F7PHNBEQ.js");
33721
+ const { toggleDevToolsPanel } = await import("./devtoolsService-ZYGDAPOV.js");
33706
33722
  await toggleDevToolsPanel(
33707
33723
  config,
33708
33724
  showErrorDetails,
@@ -3,11 +3,11 @@ import {
3
3
  DEFAULT_PORT,
4
4
  getBinaryPath,
5
5
  isServerRunning
6
- } from "./chunk-4KOU3QNT.js";
7
- import "./chunk-PXEK5ENZ.js";
6
+ } from "./chunk-5CWORGE3.js";
7
+ import "./chunk-WRWCUHAM.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-XV2YFH7B.js";
10
+ } from "./chunk-ITC7TFJU.js";
11
11
  import "./chunk-6HI7VNOG.js";
12
12
  import "./chunk-TUDYL3X4.js";
13
13
  import "./chunk-IUUIT4SU.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-IGG6LDST.js");
44
+ const { startServer } = await import("./start-25W6VZG6.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-2ARYG3KE.js";
7
- import "./chunk-HFVEWB6N.js";
6
+ } from "./chunk-EG7USKV5.js";
7
+ import "./chunk-UM53YDCH.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-N6QPQL7E.js";
10
+ } from "./chunk-KOJR46UO.js";
11
11
  import "./chunk-6HI7VNOG.js";
12
12
  import "./chunk-TUDYL3X4.js";
13
13
  import "./chunk-IUUIT4SU.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-R7DTCFCN.js");
44
+ const { startServer } = await import("./start-PK22QMBT.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-EUYIPFPA.js";
7
- import "./chunk-Z5F25543.js";
6
+ } from "./chunk-ILHDA6XU.js";
7
+ import "./chunk-VEHSYWQT.js";
8
8
  import {
9
9
  debugLogger
10
- } from "./chunk-6T7N6JF2.js";
10
+ } from "./chunk-XVDCGVTF.js";
11
11
  import "./chunk-6HI7VNOG.js";
12
12
  import "./chunk-TUDYL3X4.js";
13
13
  import "./chunk-IUUIT4SU.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-66KF6MVV.js");
44
+ const { startServer } = await import("./start-XAEHV6FV.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-4B7MDBUK.js";
7
+ import "./chunk-YINW7YTJ.js";
8
+ import {
9
+ debugLogger
10
+ } from "./chunk-QEVRJ7HY.js";
11
+ import "./chunk-6HI7VNOG.js";
12
+ import "./chunk-TUDYL3X4.js";
13
+ import "./chunk-IUUIT4SU.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-JBJSIKIB.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-6T7N6JF2.js";
19
+ } from "./chunk-KOJR46UO.js";
20
20
  import "./chunk-6HI7VNOG.js";
21
21
  import "./chunk-TUDYL3X4.js";
22
22
  import "./chunk-IUUIT4SU.js";
@@ -16,7 +16,7 @@ import {
16
16
  openBrowserSecurely,
17
17
  refreshAccessToken,
18
18
  startCallbackServer
19
- } from "./chunk-N6QPQL7E.js";
19
+ } from "./chunk-QEVRJ7HY.js";
20
20
  import "./chunk-6HI7VNOG.js";
21
21
  import "./chunk-TUDYL3X4.js";
22
22
  import "./chunk-IUUIT4SU.js";
@@ -16,35 +16,35 @@ import {
16
16
  openBrowserSecurely,
17
17
  refreshAccessToken,
18
18
  startCallbackServer
19
- } from "./chunk-XV2YFH7B.js";
19
+ } from "./chunk-XVDCGVTF.js";
20
20
  import "./chunk-6HI7VNOG.js";
21
21
  import "./chunk-TUDYL3X4.js";
22
22
  import "./chunk-IUUIT4SU.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 {