@google/gemini-cli 0.61.0-preview.0 → 0.61.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.
- package/bundle/{chunk-YJFCJUWN.js → chunk-34PFYALD.js} +1 -1
- package/bundle/{chunk-3KWHN3A7.js → chunk-4D7PRDBS.js} +1 -1
- package/bundle/{chunk-ZJHBR7W3.js → chunk-4YQFFXRN.js} +1 -1
- package/bundle/{chunk-OZG5CLDY.js → chunk-7HAUMOMS.js} +7 -7
- package/bundle/{chunk-FIYKTSCR.js → chunk-BFB2YEJY.js} +1 -1
- package/bundle/{chunk-AIMNGITH.js → chunk-BHKACUMI.js} +3 -3
- package/bundle/{chunk-WFZMFTEE.js → chunk-EM2O5AOZ.js} +3 -3
- package/bundle/{chunk-HGJ3LRCZ.js → chunk-EUZJSBKR.js} +1 -1
- package/bundle/{chunk-DO6WSZ5A.js → chunk-FSZD7V6N.js} +2 -2
- package/bundle/{chunk-DOJZLPDE.js → chunk-GOOJJ7ZQ.js} +1 -1
- package/bundle/{chunk-LDL5PSV7.js → chunk-H6SLDOAI.js} +2 -2
- package/bundle/{chunk-ACTC6X24.js → chunk-HDPU5WOJ.js} +291 -134
- package/bundle/{chunk-4WJNJ3DK.js → chunk-JKUZ4FYJ.js} +1 -1
- package/bundle/{chunk-ZOKIJ2CA.js → chunk-KXVODVLE.js} +67 -54
- package/bundle/{chunk-HQQJ2XNS.js → chunk-LZGP7KFI.js} +17 -2
- package/bundle/{chunk-UUSSUQWL.js → chunk-MNBKYFEY.js} +9 -8
- package/bundle/{chunk-XL4BRDNV.js → chunk-MXQQJJNZ.js} +7 -7
- package/bundle/{chunk-OANXWSAG.js → chunk-NQXTLK5U.js} +8027 -14705
- package/bundle/chunk-NXDIRTLT.js +512 -0
- package/bundle/{chunk-GLGFO33Y.js → chunk-O4KOWLVM.js} +17 -2
- package/bundle/chunk-OO7JC2QX.js +399635 -0
- package/bundle/{chunk-UCLFGIUA.js → chunk-OTWH6H2T.js} +2 -2
- package/bundle/{chunk-BCGPZKAR.js → chunk-PBNOO4UX.js} +1 -1
- package/bundle/{chunk-6HVPDYWM.js → chunk-SABJGE2G.js} +3 -3
- package/bundle/chunk-TFQNPQHU.js +154 -0
- package/bundle/{chunk-KUWKDEHW.js → chunk-UEKG6P2N.js} +24 -6
- package/bundle/chunk-UST2ZL7P.js +1571 -0
- package/bundle/chunk-VSZD56FP.js +102678 -0
- package/bundle/{chunk-FH2AJT7C.js → chunk-X63OLHR4.js} +325 -136
- package/bundle/chunk-YD7YFB3H.js +398 -0
- package/bundle/chunk-ZAUQFML4.js +118 -0
- package/bundle/chunk-ZXK7SZMG.js +17368 -0
- package/bundle/{cleanup-AM5TUWBB.js → cleanup-DGDWVDXX.js} +2 -2
- package/bundle/{cleanup-FLPPBDLV.js → cleanup-ILJI4AEW.js} +2 -2
- package/bundle/{cleanup-KI735Y45.js → cleanup-QW4EQ3QR.js} +2 -2
- package/bundle/cleanup-R6YFTONK.js +32 -0
- package/bundle/{core-R7CF7CQD.js → core-HFCJBVEU.js} +17 -1
- package/bundle/{devtoolsService-MA34M6Q7.js → devtoolsService-KXJDH42U.js} +2 -2
- package/bundle/{devtoolsService-UUGXHVTK.js → devtoolsService-LWSF6JIT.js} +2 -2
- package/bundle/{devtoolsService-WOA7VJLA.js → devtoolsService-N3A5BSJN.js} +4 -3
- package/bundle/devtoolsService-N4LL6WGD.js +4359 -0
- package/bundle/{dist-VH7RJCTA.js → dist-2BSGBE32.js} +17 -1
- package/bundle/{core-F6IWXMFD.js → dist-6YQ35ICZ.js} +17 -1
- package/bundle/dist-C4IKSTQN.js +2232 -0
- package/bundle/docs/reference/configuration.md +88 -25
- package/bundle/{gemini-SRSLV7D2.js → gemini-5UNXMZT3.js} +219 -201
- package/bundle/gemini-ATQ3WGVL.js +17764 -0
- package/bundle/{gemini-NLU2EPRF.js → gemini-G7D5KPQ2.js} +18 -16
- package/bundle/{gemini-N24ID3HC.js → gemini-RWMUQAJ6.js} +18 -16
- package/bundle/gemini.js +7 -7
- package/bundle/{interactiveCli-SOMGNC7U.js → interactiveCli-EAB7PSHJ.js} +19 -14
- package/bundle/{interactiveCli-DDJZ4B26.js → interactiveCli-JYJNFC5D.js} +326 -302
- package/bundle/interactiveCli-KQPTYHND.js +35029 -0
- package/bundle/{interactiveCli-PNXXOFIE.js → interactiveCli-WC6IXMOE.js} +19 -14
- package/bundle/{liteRtServerManager-HDIBGLHN.js → liteRtServerManager-27LLIZ3H.js} +4 -4
- package/bundle/{liteRtServerManager-XEOODEAA.js → liteRtServerManager-HB6JSWYM.js} +4 -4
- package/bundle/{liteRtServerManager-GW22Q7F4.js → liteRtServerManager-NSPOA7KV.js} +4 -4
- package/bundle/liteRtServerManager-WXCFUD52.js +65 -0
- package/bundle/{oauth2-provider-ZC45IIOS.js → oauth2-provider-5CXK7KFQ.js} +1 -1
- package/bundle/{oauth2-provider-SADAKLZ2.js → oauth2-provider-FYIOQREN.js} +1 -1
- package/bundle/{oauth2-provider-347DWYC5.js → oauth2-provider-N7JBWITO.js} +38 -72
- package/bundle/oauth2-provider-Z7WSYKBF.js +235 -0
- package/bundle/{start-IVH46CBG.js → start-4CI64D6Q.js} +6 -6
- package/bundle/{start-PRP35I6V.js → start-MHS6EQUA.js} +6 -6
- package/bundle/{start-H7F3LFFN.js → start-OO24SR5D.js} +6 -6
- package/bundle/start-WRVCTB7Z.js +18 -0
- package/package.json +1 -1
|
@@ -158,10 +158,10 @@ import {
|
|
|
158
158
|
widestLineFromStyledChars,
|
|
159
159
|
wordBreakStyledChars,
|
|
160
160
|
wrapStyledChars
|
|
161
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-MXQQJJNZ.js";
|
|
162
162
|
import {
|
|
163
163
|
require_source
|
|
164
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-EUZJSBKR.js";
|
|
165
165
|
import {
|
|
166
166
|
appEvents
|
|
167
167
|
} from "./chunk-5PS3AYFU.js";
|
|
@@ -215,24 +215,24 @@ import {
|
|
|
215
215
|
stripAnsi,
|
|
216
216
|
stripUnsafeCharacters,
|
|
217
217
|
toCodePoints
|
|
218
|
-
} from "./chunk-
|
|
218
|
+
} from "./chunk-O4KOWLVM.js";
|
|
219
219
|
import {
|
|
220
220
|
handleAutoUpdate,
|
|
221
221
|
isDevelopment,
|
|
222
222
|
relaunchApp,
|
|
223
223
|
setUpdateHandler
|
|
224
|
-
} from "./chunk-
|
|
224
|
+
} from "./chunk-OTWH6H2T.js";
|
|
225
225
|
import {
|
|
226
226
|
isTodoList,
|
|
227
227
|
mapCoreStatusToDisplayStatus,
|
|
228
228
|
require_react
|
|
229
|
-
} from "./chunk-
|
|
229
|
+
} from "./chunk-4YQFFXRN.js";
|
|
230
230
|
import {
|
|
231
231
|
registerCleanup,
|
|
232
232
|
removeCleanup,
|
|
233
233
|
runExitCleanup,
|
|
234
234
|
setupTtyCheck
|
|
235
|
-
} from "./chunk-
|
|
235
|
+
} from "./chunk-PBNOO4UX.js";
|
|
236
236
|
import {
|
|
237
237
|
ACTIVATE_SKILL_TOOL_NAME,
|
|
238
238
|
AGENT_TOOL_NAME,
|
|
@@ -419,7 +419,7 @@ import {
|
|
|
419
419
|
validatePlanContent,
|
|
420
420
|
validatePlanPath,
|
|
421
421
|
writeToStdout
|
|
422
|
-
} from "./chunk-
|
|
422
|
+
} from "./chunk-X63OLHR4.js";
|
|
423
423
|
import "./chunk-664ZODQF.js";
|
|
424
424
|
import "./chunk-IUUIT4SU.js";
|
|
425
425
|
import "./chunk-TUDYL3X4.js";
|
|
@@ -16773,7 +16773,8 @@ function ModelDialog({ onClose }) {
|
|
|
16773
16773
|
const preferredModel = config?.getModel() || GEMINI_MODEL_ALIAS_AUTO;
|
|
16774
16774
|
const shouldShowPreviewModels = config?.getHasAccessToPreviewModel() ?? false;
|
|
16775
16775
|
const useGemini31 = config?.getGemini31LaunchedSync?.() ?? false;
|
|
16776
|
-
const
|
|
16776
|
+
const useLatestFlash = config?.hasLatestFlashGAAccess?.() ?? false;
|
|
16777
|
+
const useLatestFlashLite = config?.hasLatestFlashLiteGAAccess?.() ?? false;
|
|
16777
16778
|
const selectedAuthType = settings.merged.security.auth.selectedType;
|
|
16778
16779
|
const useCustomToolModel = useGemini31 && selectedAuthType === "gemini-api-key" /* USE_GEMINI */;
|
|
16779
16780
|
const manualModelSelected = (0, import_react55.useMemo)(() => {
|
|
@@ -16818,7 +16819,8 @@ function ModelDialog({ onClose }) {
|
|
|
16818
16819
|
if (config?.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
16819
16820
|
const allOptions = config.getModelConfigService().getAvailableModelOptions({
|
|
16820
16821
|
useGemini3_1: useGemini31,
|
|
16821
|
-
|
|
16822
|
+
useLatestFlash,
|
|
16823
|
+
useLatestFlashLite,
|
|
16822
16824
|
useCustomTools: useCustomToolModel,
|
|
16823
16825
|
hasAccessToPreview: shouldShowPreviewModels,
|
|
16824
16826
|
hasAccessToProModel
|
|
@@ -16844,7 +16846,7 @@ function ModelDialog({ onClose }) {
|
|
|
16844
16846
|
description: getAutoModelDescription(
|
|
16845
16847
|
shouldShowPreviewModels,
|
|
16846
16848
|
useGemini31,
|
|
16847
|
-
|
|
16849
|
+
useLatestFlash
|
|
16848
16850
|
),
|
|
16849
16851
|
key: GEMINI_MODEL_ALIAS_AUTO
|
|
16850
16852
|
},
|
|
@@ -16861,7 +16863,8 @@ function ModelDialog({ onClose }) {
|
|
|
16861
16863
|
shouldShowPreviewModels,
|
|
16862
16864
|
manualModelSelected,
|
|
16863
16865
|
useGemini31,
|
|
16864
|
-
|
|
16866
|
+
useLatestFlash,
|
|
16867
|
+
useLatestFlashLite,
|
|
16865
16868
|
useCustomToolModel,
|
|
16866
16869
|
hasAccessToProModel
|
|
16867
16870
|
]);
|
|
@@ -16869,7 +16872,8 @@ function ModelDialog({ onClose }) {
|
|
|
16869
16872
|
if (config?.getExperimentalDynamicModelConfiguration?.() === true && config.getModelConfigService) {
|
|
16870
16873
|
const allOptions = config.getModelConfigService().getAvailableModelOptions({
|
|
16871
16874
|
useGemini3_1: useGemini31,
|
|
16872
|
-
|
|
16875
|
+
useLatestFlash,
|
|
16876
|
+
useLatestFlashLite,
|
|
16873
16877
|
useCustomTools: useCustomToolModel,
|
|
16874
16878
|
hasAccessToPreview: shouldShowPreviewModels,
|
|
16875
16879
|
hasAccessToProModel
|
|
@@ -16943,7 +16947,8 @@ function ModelDialog({ onClose }) {
|
|
|
16943
16947
|
}, [
|
|
16944
16948
|
shouldShowPreviewModels,
|
|
16945
16949
|
useGemini31,
|
|
16946
|
-
|
|
16950
|
+
useLatestFlash,
|
|
16951
|
+
useLatestFlashLite,
|
|
16947
16952
|
useCustomToolModel,
|
|
16948
16953
|
hasAccessToProModel,
|
|
16949
16954
|
config
|
|
@@ -33986,7 +33991,7 @@ ${queuedText}` : queuedText;
|
|
|
33986
33991
|
if (keyMatchers["app.showErrorDetails" /* SHOW_ERROR_DETAILS */](key)) {
|
|
33987
33992
|
if (settings.merged.general.devtools) {
|
|
33988
33993
|
void (async () => {
|
|
33989
|
-
const { toggleDevToolsPanel } = await import("./devtoolsService-
|
|
33994
|
+
const { toggleDevToolsPanel } = await import("./devtoolsService-KXJDH42U.js");
|
|
33990
33995
|
await toggleDevToolsPanel(
|
|
33991
33996
|
config,
|
|
33992
33997
|
showErrorDetails,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
DEFAULT_PORT,
|
|
4
4
|
getBinaryPath,
|
|
5
5
|
isServerRunning
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-O4KOWLVM.js";
|
|
7
|
+
import "./chunk-4YQFFXRN.js";
|
|
8
8
|
import {
|
|
9
9
|
debugLogger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-X63OLHR4.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-
|
|
44
|
+
const { startServer } = await import("./start-4CI64D6Q.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-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-ZXK7SZMG.js";
|
|
7
|
+
import "./chunk-NXDIRTLT.js";
|
|
8
8
|
import {
|
|
9
9
|
debugLogger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OO7JC2QX.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-
|
|
44
|
+
const { startServer } = await import("./start-WRVCTB7Z.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-
|
|
7
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-LZGP7KFI.js";
|
|
7
|
+
import "./chunk-MNBKYFEY.js";
|
|
8
8
|
import {
|
|
9
9
|
debugLogger
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-HDPU5WOJ.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-
|
|
44
|
+
const { startServer } = await import("./start-OO24SR5D.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-UEKG6P2N.js";
|
|
7
|
+
import "./chunk-34PFYALD.js";
|
|
8
|
+
import {
|
|
9
|
+
debugLogger
|
|
10
|
+
} from "./chunk-NQXTLK5U.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-MHS6EQUA.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,35 +16,35 @@ import {
|
|
|
16
16
|
openBrowserSecurely,
|
|
17
17
|
refreshAccessToken,
|
|
18
18
|
startCallbackServer
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NQXTLK5U.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.
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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)
|
|
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)
|
|
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)
|
|
254
|
-
|
|
255
|
-
|
|
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 {
|