@google/gemini-cli 0.36.0-preview.8 → 0.37.0-preview.0

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 (74) hide show
  1. package/bundle/{chunk-N22U7LIR.js → chunk-3TN4SOLW.js} +6651 -4180
  2. package/bundle/{chunk-S2IQOR7T.js → chunk-7UZ4Y32N.js} +214 -66
  3. package/bundle/{chunk-QBLIM2T2.js → chunk-A62NZYIK.js} +711 -240
  4. package/bundle/{chunk-5JDHTAA3.js → chunk-LEK5YYAR.js} +6295 -4094
  5. package/bundle/{chunk-MYI75E6G.js → chunk-R5X4CMUM.js} +233 -70
  6. package/bundle/{chunk-5Y6Y7SEB.js → chunk-TJ76C6AA.js} +16847 -9496
  7. package/bundle/chunk-U4FACSVX.js +30 -0
  8. package/bundle/{chunk-UUJ4JLTB.js → chunk-ULC3DHVX.js} +711 -240
  9. package/bundle/{chunk-642LNT3F.js → chunk-XX7JYMTE.js} +765 -306
  10. package/bundle/{core-N4UNRLQA.js → core-5OME6LT4.js} +58 -4
  11. package/bundle/{dist-HD2ZHBHJ.js → core-CUCGSGCA.js} +58 -4
  12. package/bundle/{devtoolsService-7D3WUF33.js → devtoolsService-4FIYD6OW.js} +20 -3
  13. package/bundle/{devtoolsService-NA7MR5UO.js → devtoolsService-IDLWLZFQ.js} +21 -5
  14. package/bundle/{devtoolsService-Y53ZUB56.js → devtoolsService-TVWW3DBW.js} +20 -3
  15. package/bundle/{dist-JYY2GAAR.js → dist-YWCADMDD.js} +58 -4
  16. package/bundle/docs/CONTRIBUTING.md +10 -7
  17. package/bundle/docs/assets/theme-tokyonight-dark.png +0 -0
  18. package/bundle/docs/changelogs/index.md +24 -0
  19. package/bundle/docs/changelogs/latest.md +366 -459
  20. package/bundle/docs/changelogs/preview.md +362 -356
  21. package/bundle/docs/cli/acp-mode.md +126 -0
  22. package/bundle/docs/cli/cli-reference.md +1 -1
  23. package/bundle/docs/cli/notifications.md +5 -5
  24. package/bundle/docs/cli/plan-mode.md +12 -8
  25. package/bundle/docs/cli/sandbox.md +1 -1
  26. package/bundle/docs/cli/settings.md +14 -13
  27. package/bundle/docs/cli/themes.md +5 -0
  28. package/bundle/docs/core/index.md +2 -2
  29. package/bundle/docs/core/subagents.md +134 -23
  30. package/bundle/docs/get-started/gemini-3.md +1 -1
  31. package/bundle/docs/get-started/index.md +127 -1
  32. package/bundle/docs/ide-integration/index.md +99 -24
  33. package/bundle/docs/index.md +0 -2
  34. package/bundle/docs/redirects.json +1 -0
  35. package/bundle/docs/reference/commands.md +1 -3
  36. package/bundle/docs/reference/configuration.md +182 -91
  37. package/bundle/docs/reference/keyboard-shortcuts.md +14 -6
  38. package/bundle/docs/reference/policy-engine.md +16 -30
  39. package/bundle/docs/reference/tools.md +56 -23
  40. package/bundle/docs/resources/quota-and-pricing.md +23 -9
  41. package/bundle/docs/sidebar.json +11 -4
  42. package/bundle/docs/tools/planning.md +6 -4
  43. package/bundle/events-CLX3JQHP.js +12 -0
  44. package/bundle/gemini.js +342 -52
  45. package/bundle/{interactiveCli-R5N55BDV.js → interactiveCli-4WFWOVAQ.js} +5066 -4010
  46. package/bundle/{interactiveCli-LFO7EWZS.js → interactiveCli-4ZZ72DR3.js} +5066 -4010
  47. package/bundle/{interactiveCli-2JRQPNZP.js → interactiveCli-6SIGBRWS.js} +5279 -4240
  48. package/bundle/{memoryDiscovery-BQGYT4OD.js → memoryDiscovery-NS2EGHYH.js} +3 -1
  49. package/bundle/{memoryDiscovery-FCEPFZ3M.js → memoryDiscovery-VL3OH25S.js} +3 -1
  50. package/bundle/node_modules/@google/gemini-cli-devtools/dist/client/main.js +26 -19
  51. package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.d.ts +1 -1
  52. package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js +1 -1
  53. package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/_client-assets.js.map +1 -1
  54. package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js +35 -1
  55. package/bundle/node_modules/@google/gemini-cli-devtools/dist/src/index.js.map +1 -1
  56. package/bundle/node_modules/@google/gemini-cli-devtools/package.json +1 -1
  57. package/bundle/{oauth2-provider-2WD22PTI.js → oauth2-provider-HGHECKPY.js} +2 -2
  58. package/bundle/{oauth2-provider-QOWLZC44.js → oauth2-provider-TYBJKXSJ.js} +2 -2
  59. package/bundle/{oauth2-provider-34BPLPQX.js → oauth2-provider-YYRJ44X5.js} +73 -39
  60. package/bundle/policies/discovered.toml +7 -0
  61. package/bundle/policies/non-interactive.toml +7 -0
  62. package/bundle/policies/plan.toml +25 -0
  63. package/bundle/policies/read-only.toml +6 -0
  64. package/bundle/policies/sandbox-default.toml +3 -2
  65. package/bundle/policies/write.toml +21 -0
  66. package/bundle/policies/yolo.toml +1 -1
  67. package/package.json +1 -1
  68. package/bundle/chunk-FWCJAF6L.js +0 -97905
  69. package/bundle/chunk-X6CSYCBW.js +0 -354180
  70. package/bundle/devtoolsService-VU7N6PSG.js +0 -854
  71. package/bundle/dist-QEB25IFU.js +0 -1886
  72. package/bundle/docs/get-started/examples.md +0 -141
  73. package/bundle/interactiveCli-A6H7VTMC.js +0 -49299
  74. package/bundle/oauth2-provider-MZAUZWUS.js +0 -237
@@ -1,237 +0,0 @@
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-5Y6Y7SEB.js";
15
- import {
16
- FatalCancellationError,
17
- Storage,
18
- coreEvents,
19
- debugLogger,
20
- getErrorMessage
21
- } from "./chunk-S2IQOR7T.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
- */