@google/gemini-cli 0.36.0-preview.0 → 0.36.0-preview.2

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 (45) hide show
  1. package/bundle/{chunk-K2M7OTIP.js → chunk-25V3TYNR.js} +9 -10
  2. package/bundle/{chunk-N7MAJ3JD.js → chunk-6F64DR53.js} +6 -6
  3. package/bundle/{chunk-6UAL5KXG.js → chunk-EUXACAGL.js} +9 -12
  4. package/bundle/{chunk-BE2CAP4N.js → chunk-HLML5SVJ.js} +29 -27
  5. package/bundle/{chunk-3HNPGRRW.js → chunk-IOJJTEIC.js} +2 -2
  6. package/bundle/{chunk-S36ET7IB.js → chunk-KGPUJGU6.js} +6 -6
  7. package/bundle/{chunk-3XQWOVPH.js → chunk-MRJRXC63.js} +2 -2
  8. package/bundle/{chunk-HXZPARYO.js → chunk-MXNIJ4RK.js} +2 -2
  9. package/bundle/{chunk-4NIOHPQN.js → chunk-NKTSTYJO.js} +72 -60
  10. package/bundle/chunk-NT4MG3B6.js +93175 -0
  11. package/bundle/chunk-OOZG4FMQ.js +137 -0
  12. package/bundle/{chunk-PVQN7ZVP.js → chunk-PXG3YTLU.js} +42 -27
  13. package/bundle/{chunk-CDXJ3P4V.js → chunk-SV2TJWFU.js} +5596 -10443
  14. package/bundle/chunk-WHT3ZS7S.js +354051 -0
  15. package/bundle/{cleanup-6R6IEU7T.js → cleanup-2WKEMFXG.js} +3 -3
  16. package/bundle/{cleanup-I7KFQ3LC.js → cleanup-B67M5WAO.js} +3 -3
  17. package/bundle/{cleanup-R6KR4XCS.js → cleanup-PJ323T24.js} +3 -3
  18. package/bundle/cleanup-PKVUY3XO.js +29 -0
  19. package/bundle/{core-IZK42CWE.js → core-7GUY3XKQ.js} +2 -2
  20. package/bundle/{devtoolsService-HLM6BC5R.js → devtoolsService-B7OD724C.js} +3 -3
  21. package/bundle/{devtoolsService-GIESJD2E.js → devtoolsService-JGPJ2GN4.js} +5 -4
  22. package/bundle/{devtoolsService-PGDD2J4F.js → devtoolsService-LU3DLIVB.js} +3 -3
  23. package/bundle/devtoolsService-RGAOIVMN.js +854 -0
  24. package/bundle/{core-J3CTNETR.js → dist-DTCLJTHN.js} +2 -2
  25. package/bundle/{dist-6WEZWPRQ.js → dist-X3ESBKEG.js} +2 -2
  26. package/bundle/dist-YQXQRQYA.js +1882 -0
  27. package/bundle/docs/reference/configuration.md +1 -1
  28. package/bundle/{gemini-AI362DTR.js → gemini-7BPDTLSV.js} +7 -7
  29. package/bundle/{gemini-GZFHIDDH.js → gemini-CJ5HU32O.js} +155 -140
  30. package/bundle/{gemini-5ARDVELJ.js → gemini-GA5SXGI6.js} +7 -7
  31. package/bundle/gemini-RFUB3W5S.js +14455 -0
  32. package/bundle/gemini.js +4 -4
  33. package/bundle/{interactiveCli-OYO74BPW.js → interactiveCli-2EVI7UVZ.js} +5 -5
  34. package/bundle/{interactiveCli-LGOLNK44.js → interactiveCli-2OAVBJCC.js} +253 -236
  35. package/bundle/{interactiveCli-PXX77G77.js → interactiveCli-CRDA6GQ7.js} +5 -5
  36. package/bundle/interactiveCli-SHFDAMKC.js +49314 -0
  37. package/bundle/{memoryDiscovery-WPGC7DAZ.js → memoryDiscovery-JXHCZBWK.js} +1 -1
  38. package/bundle/{memoryDiscovery-FNLUOGLO.js → memoryDiscovery-VQKOP6YW.js} +1 -1
  39. package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
  40. package/bundle/{oauth2-provider-X3F7PSVB.js → oauth2-provider-D6HJJAVX.js} +2 -2
  41. package/bundle/{oauth2-provider-I6AYNUSI.js → oauth2-provider-KEZJCOYM.js} +39 -73
  42. package/bundle/oauth2-provider-TSEQG63I.js +237 -0
  43. package/bundle/{oauth2-provider-G7GIGUQF.js → oauth2-provider-ZT3CIEZO.js} +2 -2
  44. package/bundle/policies/plan.toml +10 -0
  45. package/package.json +1 -1
@@ -10,7 +10,7 @@ import {
10
10
  loadServerHierarchicalMemory,
11
11
  readGeminiMdFiles,
12
12
  refreshServerHierarchicalMemory
13
- } from "./chunk-PVQN7ZVP.js";
13
+ } from "./chunk-PXG3YTLU.js";
14
14
  import "./chunk-664ZODQF.js";
15
15
  import "./chunk-34MYV7JD.js";
16
16
  export {
@@ -10,7 +10,7 @@ import {
10
10
  loadServerHierarchicalMemory,
11
11
  readGeminiMdFiles,
12
12
  refreshServerHierarchicalMemory
13
- } from "./chunk-BE2CAP4N.js";
13
+ } from "./chunk-HLML5SVJ.js";
14
14
  import "./chunk-664ZODQF.js";
15
15
  import "./chunk-34MYV7JD.js";
16
16
  export {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/gemini-cli-devtools",
3
- "version": "0.36.0-preview.0",
3
+ "version": "0.36.0-preview.2",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
@@ -11,14 +11,14 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-6UAL5KXG.js";
14
+ } from "./chunk-EUXACAGL.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
18
18
  coreEvents,
19
19
  debugLogger,
20
20
  getErrorMessage
21
- } from "./chunk-BE2CAP4N.js";
21
+ } from "./chunk-HLML5SVJ.js";
22
22
  import "./chunk-664ZODQF.js";
23
23
  import "./chunk-RJTRUG2J.js";
24
24
  import "./chunk-IUUIT4SU.js";
@@ -11,42 +11,42 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-CDXJ3P4V.js";
14
+ } from "./chunk-SV2TJWFU.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
18
18
  coreEvents,
19
19
  debugLogger,
20
20
  getErrorMessage
21
- } from "./chunk-PVQN7ZVP.js";
21
+ } from "./chunk-HLML5SVJ.js";
22
22
  import "./chunk-664ZODQF.js";
23
23
  import "./chunk-RJTRUG2J.js";
24
24
  import "./chunk-IUUIT4SU.js";
25
25
  import "./chunk-34MYV7JD.js";
26
26
 
27
- // packages/core/src/agents/auth-provider/oauth2-provider.ts
27
+ // packages/core/dist/src/agents/auth-provider/oauth2-provider.js
28
28
  var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
29
+ config;
30
+ agentName;
31
+ agentCardUrl;
32
+ type = "oauth2";
33
+ tokenStorage;
34
+ cachedToken = null;
35
+ /** Resolved OAuth URLs — may come from config or agent card. */
36
+ authorizationUrl;
37
+ tokenUrl;
38
+ scopes;
29
39
  constructor(config, agentName, agentCard, agentCardUrl) {
30
40
  super();
31
41
  this.config = config;
32
42
  this.agentName = agentName;
33
43
  this.agentCardUrl = agentCardUrl;
34
- this.tokenStorage = new MCPOAuthTokenStorage(
35
- Storage.getA2AOAuthTokensPath(),
36
- "gemini-cli-a2a"
37
- );
44
+ this.tokenStorage = new MCPOAuthTokenStorage(Storage.getA2AOAuthTokensPath(), "gemini-cli-a2a");
38
45
  this.authorizationUrl = config.authorization_url;
39
46
  this.tokenUrl = config.token_url;
40
47
  this.scopes = config.scopes;
41
48
  this.mergeAgentCardDefaults(agentCard);
42
49
  }
43
- type = "oauth2";
44
- tokenStorage;
45
- cachedToken = null;
46
- /** Resolved OAuth URLs — may come from config or agent card. */
47
- authorizationUrl;
48
- tokenUrl;
49
- scopes;
50
50
  /**
51
51
  * Initialize the provider by loading any persisted token from storage.
52
52
  * Also discovers OAuth URLs from the agent card if not yet resolved.
@@ -58,9 +58,7 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
58
58
  const credentials = await this.tokenStorage.getCredentials(this.agentName);
59
59
  if (credentials && !this.tokenStorage.isTokenExpired(credentials.token)) {
60
60
  this.cachedToken = credentials.token;
61
- debugLogger.debug(
62
- `[OAuth2AuthProvider] Loaded valid cached token for "${this.agentName}"`
63
- );
61
+ debugLogger.debug(`[OAuth2AuthProvider] Loaded valid cached token for "${this.agentName}"`);
64
62
  }
65
63
  }
66
64
  /**
@@ -73,25 +71,16 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
73
71
  }
74
72
  if (this.cachedToken?.refreshToken && this.tokenUrl && this.config.client_id) {
75
73
  try {
76
- const refreshed = await refreshAccessToken(
77
- {
78
- clientId: this.config.client_id,
79
- clientSecret: this.config.client_secret,
80
- scopes: this.scopes
81
- },
82
- this.cachedToken.refreshToken,
83
- this.tokenUrl
84
- );
85
- this.cachedToken = this.toOAuthToken(
86
- refreshed,
87
- this.cachedToken.refreshToken
88
- );
74
+ const refreshed = await refreshAccessToken({
75
+ clientId: this.config.client_id,
76
+ clientSecret: this.config.client_secret,
77
+ scopes: this.scopes
78
+ }, this.cachedToken.refreshToken, this.tokenUrl);
79
+ this.cachedToken = this.toOAuthToken(refreshed, this.cachedToken.refreshToken);
89
80
  await this.persistToken();
90
81
  return { Authorization: `Bearer ${this.cachedToken.accessToken}` };
91
82
  } catch (error) {
92
- debugLogger.debug(
93
- `[OAuth2AuthProvider] Refresh failed, falling back to interactive flow: ${getErrorMessage(error)}`
94
- );
83
+ debugLogger.debug(`[OAuth2AuthProvider] Refresh failed, falling back to interactive flow: ${getErrorMessage(error)}`);
95
84
  await this.tokenStorage.deleteCredentials(this.agentName);
96
85
  }
97
86
  }
@@ -110,9 +99,7 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
110
99
  return void 0;
111
100
  }
112
101
  this.authRetryCount++;
113
- debugLogger.debug(
114
- "[OAuth2AuthProvider] Auth failure, clearing token and re-authenticating"
115
- );
102
+ debugLogger.debug("[OAuth2AuthProvider] Auth failure, clearing token and re-authenticating");
116
103
  this.cachedToken = null;
117
104
  await this.tokenStorage.deleteCredentials(this.agentName);
118
105
  return this.headers();
@@ -125,7 +112,8 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
125
112
  * `securitySchemes` when not already provided via user config.
126
113
  */
127
114
  mergeAgentCardDefaults(agentCard) {
128
- if (!agentCard?.securitySchemes) return;
115
+ if (!agentCard?.securitySchemes)
116
+ return;
129
117
  for (const scheme of Object.values(agentCard.securitySchemes)) {
130
118
  if (scheme.type === "oauth2" && scheme.flows.authorizationCode) {
131
119
  const flow = scheme.flows.authorizationCode;
@@ -141,18 +129,15 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
141
129
  * (which normalizes proto-format cards) and extract OAuth2 URLs.
142
130
  */
143
131
  async fetchAgentCardDefaults() {
144
- if (!this.agentCardUrl) return;
132
+ if (!this.agentCardUrl)
133
+ return;
145
134
  try {
146
- debugLogger.debug(
147
- `[OAuth2AuthProvider] Fetching agent card from ${this.agentCardUrl}`
148
- );
135
+ debugLogger.debug(`[OAuth2AuthProvider] Fetching agent card from ${this.agentCardUrl}`);
149
136
  const resolver = new DefaultAgentCardResolver();
150
137
  const card = await resolver.resolve(this.agentCardUrl, "");
151
138
  this.mergeAgentCardDefaults(card);
152
139
  } catch (error) {
153
- debugLogger.warn(
154
- `[OAuth2AuthProvider] Could not fetch agent card for OAuth URL discovery: ${getErrorMessage(error)}`
155
- );
140
+ debugLogger.warn(`[OAuth2AuthProvider] Could not fetch agent card for OAuth URL discovery: ${getErrorMessage(error)}`);
156
141
  }
157
142
  }
158
143
  /**
@@ -160,14 +145,10 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
160
145
  */
161
146
  async authenticateInteractively() {
162
147
  if (!this.config.client_id) {
163
- throw new Error(
164
- `OAuth2 authentication for agent "${this.agentName}" requires a client_id. Add client_id to the auth config in your agent definition.`
165
- );
148
+ throw new Error(`OAuth2 authentication for agent "${this.agentName}" requires a client_id. Add client_id to the auth config in your agent definition.`);
166
149
  }
167
150
  if (!this.authorizationUrl || !this.tokenUrl) {
168
- throw new Error(
169
- `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.`
170
- );
151
+ 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.`);
171
152
  }
172
153
  const flowConfig = {
173
154
  clientId: this.config.client_id,
@@ -186,36 +167,25 @@ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
186
167
  redirectPort,
187
168
  /* resource= */
188
169
  void 0
189
- // No MCP resource parameter for A2A.
190
- );
191
- const consent = await getConsentForOauth(
192
- `Authentication required for A2A agent: '${this.agentName}'.`
193
170
  );
171
+ const consent = await getConsentForOauth(`Authentication required for A2A agent: '${this.agentName}'.`);
194
172
  if (!consent) {
195
173
  throw new FatalCancellationError("Authentication cancelled by user.");
196
174
  }
197
- coreEvents.emitFeedback(
198
- "info",
199
- `\u2192 Opening your browser for OAuth sign-in...
175
+ coreEvents.emitFeedback("info", `\u2192 Opening your browser for OAuth sign-in...
200
176
 
201
177
  If the browser does not open, copy and paste this URL into your browser:
202
178
  ${authUrl}
203
179
 
204
180
  \u{1F4A1} TIP: Triple-click to select the entire URL, then copy and paste it into your browser.
205
- \u26A0\uFE0F Make sure to copy the COMPLETE URL - it may wrap across multiple lines.`
206
- );
181
+ \u26A0\uFE0F Make sure to copy the COMPLETE URL - it may wrap across multiple lines.`);
207
182
  try {
208
183
  await openBrowserSecurely(authUrl);
209
184
  } catch (error) {
210
- debugLogger.warn(
211
- "Failed to open browser automatically:",
212
- getErrorMessage(error)
213
- );
185
+ debugLogger.warn("Failed to open browser automatically:", getErrorMessage(error));
214
186
  }
215
187
  const { code } = await callbackServer.response;
216
- debugLogger.debug(
217
- "\u2713 Authorization code received, exchanging for tokens..."
218
- );
188
+ debugLogger.debug("\u2713 Authorization code received, exchanging for tokens...");
219
189
  const tokenResponse = await exchangeCodeForToken(
220
190
  flowConfig,
221
191
  code,
@@ -252,13 +222,9 @@ ${authUrl}
252
222
  * Persist the current cached token to disk.
253
223
  */
254
224
  async persistToken() {
255
- if (!this.cachedToken) return;
256
- await this.tokenStorage.saveToken(
257
- this.agentName,
258
- this.cachedToken,
259
- this.config.client_id,
260
- this.tokenUrl
261
- );
225
+ if (!this.cachedToken)
226
+ return;
227
+ await this.tokenStorage.saveToken(this.agentName, this.cachedToken, this.config.client_id, this.tokenUrl);
262
228
  }
263
229
  };
264
230
  export {
@@ -0,0 +1,237 @@
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
+ BaseA2AAuthProvider,
4
+ DefaultAgentCardResolver,
5
+ MCPOAuthTokenStorage,
6
+ buildAuthorizationUrl,
7
+ exchangeCodeForToken,
8
+ generatePKCEParams,
9
+ getConsentForOauth,
10
+ getPortFromUrl,
11
+ openBrowserSecurely,
12
+ refreshAccessToken,
13
+ startCallbackServer
14
+ } from "./chunk-WHT3ZS7S.js";
15
+ import {
16
+ FatalCancellationError,
17
+ Storage,
18
+ coreEvents,
19
+ debugLogger,
20
+ getErrorMessage
21
+ } from "./chunk-HLML5SVJ.js";
22
+ import "./chunk-664ZODQF.js";
23
+ import "./chunk-RJTRUG2J.js";
24
+ import "./chunk-IUUIT4SU.js";
25
+ import "./chunk-34MYV7JD.js";
26
+
27
+ // packages/core/dist/src/agents/auth-provider/oauth2-provider.js
28
+ var OAuth2AuthProvider = class extends BaseA2AAuthProvider {
29
+ config;
30
+ agentName;
31
+ agentCardUrl;
32
+ type = "oauth2";
33
+ tokenStorage;
34
+ cachedToken = null;
35
+ /** Resolved OAuth URLs — may come from config or agent card. */
36
+ authorizationUrl;
37
+ tokenUrl;
38
+ scopes;
39
+ constructor(config, agentName, agentCard, agentCardUrl) {
40
+ super();
41
+ this.config = config;
42
+ this.agentName = agentName;
43
+ this.agentCardUrl = agentCardUrl;
44
+ this.tokenStorage = new MCPOAuthTokenStorage(Storage.getA2AOAuthTokensPath(), "gemini-cli-a2a");
45
+ this.authorizationUrl = config.authorization_url;
46
+ this.tokenUrl = config.token_url;
47
+ this.scopes = config.scopes;
48
+ this.mergeAgentCardDefaults(agentCard);
49
+ }
50
+ /**
51
+ * Initialize the provider by loading any persisted token from storage.
52
+ * Also discovers OAuth URLs from the agent card if not yet resolved.
53
+ */
54
+ async initialize() {
55
+ if ((!this.authorizationUrl || !this.tokenUrl) && this.agentCardUrl) {
56
+ await this.fetchAgentCardDefaults();
57
+ }
58
+ const credentials = await this.tokenStorage.getCredentials(this.agentName);
59
+ if (credentials && !this.tokenStorage.isTokenExpired(credentials.token)) {
60
+ this.cachedToken = credentials.token;
61
+ debugLogger.debug(`[OAuth2AuthProvider] Loaded valid cached token for "${this.agentName}"`);
62
+ }
63
+ }
64
+ /**
65
+ * Return an Authorization header with a valid Bearer token.
66
+ * Refreshes or triggers interactive auth as needed.
67
+ */
68
+ async headers() {
69
+ if (this.cachedToken && !this.tokenStorage.isTokenExpired(this.cachedToken)) {
70
+ return { Authorization: `Bearer ${this.cachedToken.accessToken}` };
71
+ }
72
+ if (this.cachedToken?.refreshToken && this.tokenUrl && this.config.client_id) {
73
+ try {
74
+ const refreshed = await refreshAccessToken({
75
+ clientId: this.config.client_id,
76
+ clientSecret: this.config.client_secret,
77
+ scopes: this.scopes
78
+ }, this.cachedToken.refreshToken, this.tokenUrl);
79
+ this.cachedToken = this.toOAuthToken(refreshed, this.cachedToken.refreshToken);
80
+ await this.persistToken();
81
+ return { Authorization: `Bearer ${this.cachedToken.accessToken}` };
82
+ } catch (error) {
83
+ debugLogger.debug(`[OAuth2AuthProvider] Refresh failed, falling back to interactive flow: ${getErrorMessage(error)}`);
84
+ await this.tokenStorage.deleteCredentials(this.agentName);
85
+ }
86
+ }
87
+ this.cachedToken = await this.authenticateInteractively();
88
+ return { Authorization: `Bearer ${this.cachedToken.accessToken}` };
89
+ }
90
+ /**
91
+ * On 401/403, clear the cached token and re-authenticate (up to MAX_AUTH_RETRIES).
92
+ */
93
+ async shouldRetryWithHeaders(_req, res) {
94
+ if (res.status !== 401 && res.status !== 403) {
95
+ this.authRetryCount = 0;
96
+ return void 0;
97
+ }
98
+ if (this.authRetryCount >= BaseA2AAuthProvider.MAX_AUTH_RETRIES) {
99
+ return void 0;
100
+ }
101
+ this.authRetryCount++;
102
+ debugLogger.debug("[OAuth2AuthProvider] Auth failure, clearing token and re-authenticating");
103
+ this.cachedToken = null;
104
+ await this.tokenStorage.deleteCredentials(this.agentName);
105
+ return this.headers();
106
+ }
107
+ // ---------------------------------------------------------------------------
108
+ // Private helpers
109
+ // ---------------------------------------------------------------------------
110
+ /**
111
+ * Merge authorization_url, token_url, and scopes from the agent card's
112
+ * `securitySchemes` when not already provided via user config.
113
+ */
114
+ mergeAgentCardDefaults(agentCard) {
115
+ if (!agentCard?.securitySchemes)
116
+ return;
117
+ for (const scheme of Object.values(agentCard.securitySchemes)) {
118
+ if (scheme.type === "oauth2" && scheme.flows.authorizationCode) {
119
+ const flow = scheme.flows.authorizationCode;
120
+ this.authorizationUrl ??= flow.authorizationUrl;
121
+ this.tokenUrl ??= flow.tokenUrl;
122
+ this.scopes ??= Object.keys(flow.scopes);
123
+ break;
124
+ }
125
+ }
126
+ }
127
+ /**
128
+ * Fetch the agent card from `agentCardUrl` using `DefaultAgentCardResolver`
129
+ * (which normalizes proto-format cards) and extract OAuth2 URLs.
130
+ */
131
+ async fetchAgentCardDefaults() {
132
+ if (!this.agentCardUrl)
133
+ return;
134
+ try {
135
+ debugLogger.debug(`[OAuth2AuthProvider] Fetching agent card from ${this.agentCardUrl}`);
136
+ const resolver = new DefaultAgentCardResolver();
137
+ const card = await resolver.resolve(this.agentCardUrl, "");
138
+ this.mergeAgentCardDefaults(card);
139
+ } catch (error) {
140
+ debugLogger.warn(`[OAuth2AuthProvider] Could not fetch agent card for OAuth URL discovery: ${getErrorMessage(error)}`);
141
+ }
142
+ }
143
+ /**
144
+ * Run a full OAuth 2.0 Authorization Code + PKCE flow through the browser.
145
+ */
146
+ async authenticateInteractively() {
147
+ if (!this.config.client_id) {
148
+ throw new Error(`OAuth2 authentication for agent "${this.agentName}" requires a client_id. Add client_id to the auth config in your agent definition.`);
149
+ }
150
+ if (!this.authorizationUrl || !this.tokenUrl) {
151
+ 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.`);
152
+ }
153
+ const flowConfig = {
154
+ clientId: this.config.client_id,
155
+ clientSecret: this.config.client_secret,
156
+ authorizationUrl: this.authorizationUrl,
157
+ tokenUrl: this.tokenUrl,
158
+ scopes: this.scopes
159
+ };
160
+ const pkceParams = generatePKCEParams();
161
+ const preferredPort = getPortFromUrl(flowConfig.redirectUri);
162
+ const callbackServer = startCallbackServer(pkceParams.state, preferredPort);
163
+ const redirectPort = await callbackServer.port;
164
+ const authUrl = buildAuthorizationUrl(
165
+ flowConfig,
166
+ pkceParams,
167
+ redirectPort,
168
+ /* resource= */
169
+ void 0
170
+ );
171
+ const consent = await getConsentForOauth(`Authentication required for A2A agent: '${this.agentName}'.`);
172
+ if (!consent) {
173
+ throw new FatalCancellationError("Authentication cancelled by user.");
174
+ }
175
+ coreEvents.emitFeedback("info", `\u2192 Opening your browser for OAuth sign-in...
176
+
177
+ If the browser does not open, copy and paste this URL into your browser:
178
+ ${authUrl}
179
+
180
+ \u{1F4A1} TIP: Triple-click to select the entire URL, then copy and paste it into your browser.
181
+ \u26A0\uFE0F Make sure to copy the COMPLETE URL - it may wrap across multiple lines.`);
182
+ try {
183
+ await openBrowserSecurely(authUrl);
184
+ } catch (error) {
185
+ debugLogger.warn("Failed to open browser automatically:", getErrorMessage(error));
186
+ }
187
+ const { code } = await callbackServer.response;
188
+ debugLogger.debug("\u2713 Authorization code received, exchanging for tokens...");
189
+ const tokenResponse = await exchangeCodeForToken(
190
+ flowConfig,
191
+ code,
192
+ pkceParams.codeVerifier,
193
+ redirectPort,
194
+ /* resource= */
195
+ void 0
196
+ );
197
+ if (!tokenResponse.access_token) {
198
+ throw new Error("No access token received from token endpoint");
199
+ }
200
+ const token = this.toOAuthToken(tokenResponse);
201
+ this.cachedToken = token;
202
+ await this.persistToken();
203
+ debugLogger.debug("\u2713 OAuth2 authentication successful! Token saved.");
204
+ return token;
205
+ }
206
+ /**
207
+ * Convert an `OAuthTokenResponse` into the internal `OAuthToken` format.
208
+ */
209
+ toOAuthToken(response, fallbackRefreshToken) {
210
+ const token = {
211
+ accessToken: response.access_token,
212
+ tokenType: response.token_type || "Bearer",
213
+ refreshToken: response.refresh_token || fallbackRefreshToken,
214
+ scope: response.scope
215
+ };
216
+ if (response.expires_in) {
217
+ token.expiresAt = Date.now() + response.expires_in * 1e3;
218
+ }
219
+ return token;
220
+ }
221
+ /**
222
+ * Persist the current cached token to disk.
223
+ */
224
+ async persistToken() {
225
+ if (!this.cachedToken)
226
+ return;
227
+ await this.tokenStorage.saveToken(this.agentName, this.cachedToken, this.config.client_id, this.tokenUrl);
228
+ }
229
+ };
230
+ export {
231
+ OAuth2AuthProvider
232
+ };
233
+ /**
234
+ * @license
235
+ * Copyright 2026 Google LLC
236
+ * SPDX-License-Identifier: Apache-2.0
237
+ */
@@ -11,14 +11,14 @@ import {
11
11
  openBrowserSecurely,
12
12
  refreshAccessToken,
13
13
  startCallbackServer
14
- } from "./chunk-K2M7OTIP.js";
14
+ } from "./chunk-25V3TYNR.js";
15
15
  import {
16
16
  FatalCancellationError,
17
17
  Storage,
18
18
  coreEvents,
19
19
  debugLogger,
20
20
  getErrorMessage
21
- } from "./chunk-PVQN7ZVP.js";
21
+ } from "./chunk-PXG3YTLU.js";
22
22
  import "./chunk-664ZODQF.js";
23
23
  import "./chunk-RJTRUG2J.js";
24
24
  import "./chunk-IUUIT4SU.js";
@@ -110,6 +110,8 @@ priority = 70
110
110
  modes = ["plan"]
111
111
 
112
112
  # Allow write_file and replace for .md files in the plans directory (cross-platform)
113
+ # We split this into two rules to avoid ReDoS checker issues with nested optional segments.
114
+ # This rule handles the case where there is a session ID in the plan file path
113
115
  [[rule]]
114
116
  toolName = ["write_file", "replace"]
115
117
  decision = "allow"
@@ -117,6 +119,14 @@ priority = 70
117
119
  modes = ["plan"]
118
120
  argsPattern = "\\x00\"file_path\":\"[^\"]+[\\\\/]+\\.gemini[\\\\/]+tmp[\\\\/]+[\\w-]+[\\\\/]+[\\w-]+[\\\\/]+plans[\\\\/]+[\\w-]+\\.md\"\\x00"
119
121
 
122
+ # This rule handles the case where there isn't a session ID in the plan file path
123
+ [[rule]]
124
+ toolName = ["write_file", "replace"]
125
+ decision = "allow"
126
+ priority = 70
127
+ modes = ["plan"]
128
+ argsPattern = "\\x00\"file_path\":\"[^\"]+[\\\\/]+\\.gemini[\\\\/]+tmp[\\\\/]+[\\w-]+[\\\\/]+plans[\\\\/]+[\\w-]+\\.md\"\\x00"
129
+
120
130
  # Explicitly Deny other write operations in Plan mode with a clear message.
121
131
  [[rule]]
122
132
  toolName = ["write_file", "replace"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/gemini-cli",
3
- "version": "0.36.0-preview.0",
3
+ "version": "0.36.0-preview.2",
4
4
  "description": "Gemini CLI",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {