@vybestack/llxprt-code-core 0.1.13 → 0.1.14-nightly.250729.2076f7c6
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/README.md +24 -0
- package/dist/src/code_assist/codeAssist.d.ts +2 -1
- package/dist/src/code_assist/codeAssist.js +4 -3
- package/dist/src/code_assist/codeAssist.js.map +1 -1
- package/dist/src/code_assist/oauth2.js +9 -2
- package/dist/src/code_assist/oauth2.js.map +1 -1
- package/dist/src/code_assist/oauth2.test.js +94 -2
- package/dist/src/code_assist/oauth2.test.js.map +1 -1
- package/dist/src/code_assist/server.d.ts +5 -6
- package/dist/src/code_assist/server.js +7 -70
- package/dist/src/code_assist/server.js.map +1 -1
- package/dist/src/code_assist/setup.d.ts +6 -1
- package/dist/src/code_assist/setup.js +4 -1
- package/dist/src/code_assist/setup.js.map +1 -1
- package/dist/src/code_assist/setup.test.js +4 -1
- package/dist/src/code_assist/setup.test.js.map +1 -1
- package/dist/src/code_assist/types.d.ts +2 -2
- package/dist/src/config/config.d.ts +25 -3
- package/dist/src/config/config.js +47 -10
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +1 -26
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/flashFallback.test.js +1 -1
- package/dist/src/config/flashFallback.test.js.map +1 -1
- package/dist/src/core/client.d.ts +6 -2
- package/dist/src/core/client.js +41 -18
- package/dist/src/core/client.js.map +1 -1
- package/dist/src/core/client.test.js +78 -24
- package/dist/src/core/client.test.js.map +1 -1
- package/dist/src/core/contentGenerator.d.ts +1 -1
- package/dist/src/core/contentGenerator.js +1 -1
- package/dist/src/core/contentGenerator.js.map +1 -1
- package/dist/src/core/coreToolScheduler.js +14 -1
- package/dist/src/core/coreToolScheduler.js.map +1 -1
- package/dist/src/core/coreToolScheduler.test.js +80 -0
- package/dist/src/core/coreToolScheduler.test.js.map +1 -1
- package/dist/src/core/geminiChat.d.ts +4 -3
- package/dist/src/core/geminiChat.js +8 -11
- package/dist/src/core/geminiChat.js.map +1 -1
- package/dist/src/core/geminiRequest.js +2 -37
- package/dist/src/core/geminiRequest.js.map +1 -1
- package/dist/src/core/logger.js +6 -0
- package/dist/src/core/logger.js.map +1 -1
- package/dist/src/core/nonInteractiveToolExecutor.test.js +5 -5
- package/dist/src/core/prompts.js +42 -18
- package/dist/src/core/prompts.js.map +1 -1
- package/dist/src/core/prompts.test.js +121 -4
- package/dist/src/core/prompts.test.js.map +1 -1
- package/dist/src/core/turn.d.ts +7 -2
- package/dist/src/core/turn.js +9 -0
- package/dist/src/core/turn.js.map +1 -1
- package/dist/src/core/turn.test.js +129 -0
- package/dist/src/core/turn.test.js.map +1 -1
- package/dist/src/ide/ide-client.d.ts +28 -0
- package/dist/src/ide/ide-client.js +79 -0
- package/dist/src/ide/ide-client.js.map +1 -0
- package/dist/src/ide/ideContext.d.ts +174 -0
- package/dist/src/{services → ide}/ideContext.js +28 -25
- package/dist/src/ide/ideContext.js.map +1 -0
- package/dist/src/{services → ide}/ideContext.test.js +39 -39
- package/dist/src/ide/ideContext.test.js.map +1 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.js +4 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/google-auth-provider.d.ts +23 -0
- package/dist/src/mcp/google-auth-provider.js +63 -0
- package/dist/src/mcp/google-auth-provider.js.map +1 -0
- package/dist/src/mcp/google-auth-provider.test.js +54 -0
- package/dist/src/mcp/google-auth-provider.test.js.map +1 -0
- package/dist/src/providers/anthropic/AnthropicProvider.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.d.ts +2 -0
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js +36 -0
- package/dist/src/providers/gemini/GeminiProvider.integration.test.js.map +1 -1
- package/dist/src/providers/gemini/GeminiProvider.js +57 -10
- package/dist/src/providers/gemini/GeminiProvider.js.map +1 -1
- package/dist/src/providers/openai/OpenAIProvider.js +10 -7
- package/dist/src/providers/openai/OpenAIProvider.js.map +1 -1
- package/dist/src/services/fileDiscoveryService.d.ts +4 -4
- package/dist/src/services/fileDiscoveryService.js +8 -8
- package/dist/src/services/gitService.js +1 -1
- package/dist/src/services/gitService.js.map +1 -1
- package/dist/src/services/gitService.test.js +1 -1
- package/dist/src/services/gitService.test.js.map +1 -1
- package/dist/src/services/loopDetectionService.d.ts +48 -5
- package/dist/src/services/loopDetectionService.js +127 -41
- package/dist/src/services/loopDetectionService.js.map +1 -1
- package/dist/src/services/loopDetectionService.test.js +50 -123
- package/dist/src/services/loopDetectionService.test.js.map +1 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +2 -1
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +17 -2
- package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -1
- package/dist/src/telemetry/constants.d.ts +16 -15
- package/dist/src/telemetry/constants.js +16 -15
- package/dist/src/telemetry/constants.js.map +1 -1
- package/dist/src/telemetry/file-exporters.d.ts +28 -0
- package/dist/src/telemetry/file-exporters.js +62 -0
- package/dist/src/telemetry/file-exporters.js.map +1 -0
- package/dist/src/telemetry/loggers.d.ts +2 -1
- package/dist/src/telemetry/loggers.js +18 -3
- package/dist/src/telemetry/loggers.js.map +1 -1
- package/dist/src/telemetry/sdk.js +22 -7
- package/dist/src/telemetry/sdk.js.map +1 -1
- package/dist/src/telemetry/types.d.ts +9 -2
- package/dist/src/telemetry/types.js +13 -1
- package/dist/src/telemetry/types.js.map +1 -1
- package/dist/src/tools/ToolFormatter.js +19 -1
- package/dist/src/tools/ToolFormatter.js.map +1 -1
- package/dist/src/tools/edit.js +10 -4
- package/dist/src/tools/edit.js.map +1 -1
- package/dist/src/tools/edit.test.js +12 -0
- package/dist/src/tools/edit.test.js.map +1 -1
- package/dist/src/tools/grep.test.js +1 -1
- package/dist/src/tools/grep.test.js.map +1 -1
- package/dist/src/tools/ls.d.ts +5 -2
- package/dist/src/tools/ls.js +39 -10
- package/dist/src/tools/ls.js.map +1 -1
- package/dist/src/tools/mcp-client.d.ts +5 -1
- package/dist/src/tools/mcp-client.js +416 -29
- package/dist/src/tools/mcp-client.js.map +1 -1
- package/dist/src/tools/mcp-client.test.js +46 -6
- package/dist/src/tools/mcp-client.test.js.map +1 -1
- package/dist/src/tools/mcp-tool.js +1 -1
- package/dist/src/tools/mcp-tool.js.map +1 -1
- package/dist/src/tools/mcp-tool.test.js +34 -0
- package/dist/src/tools/mcp-tool.test.js.map +1 -1
- package/dist/src/tools/read-file.js +1 -1
- package/dist/src/tools/read-file.test.js +98 -69
- package/dist/src/tools/read-file.test.js.map +1 -1
- package/dist/src/tools/read-many-files.d.ts +5 -2
- package/dist/src/tools/read-many-files.js +61 -16
- package/dist/src/tools/read-many-files.js.map +1 -1
- package/dist/src/tools/read-many-files.test.js +5 -2
- package/dist/src/tools/read-many-files.test.js.map +1 -1
- package/dist/src/tools/shell.d.ts +15 -26
- package/dist/src/tools/shell.js +137 -358
- package/dist/src/tools/shell.js.map +1 -1
- package/dist/src/tools/shell.test.js +73 -318
- package/dist/src/tools/shell.test.js.map +1 -1
- package/dist/src/tools/tool-registry.d.ts +13 -1
- package/dist/src/tools/tool-registry.js +45 -1
- package/dist/src/tools/tool-registry.js.map +1 -1
- package/dist/src/tools/tool-registry.test.js +3 -3
- package/dist/src/tools/tool-registry.test.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.d.ts +2 -0
- package/dist/src/utils/bfsFileSearch.js +4 -1
- package/dist/src/utils/bfsFileSearch.js.map +1 -1
- package/dist/src/utils/bfsFileSearch.test.js +108 -105
- package/dist/src/utils/bfsFileSearch.test.js.map +1 -1
- package/dist/src/utils/editCorrector.js +4 -4
- package/dist/src/utils/editCorrector.js.map +1 -1
- package/dist/src/utils/editCorrector.test.js +1 -1
- package/dist/src/utils/editor.js +16 -10
- package/dist/src/utils/editor.js.map +1 -1
- package/dist/src/utils/editor.test.js +128 -28
- package/dist/src/utils/editor.test.js.map +1 -1
- package/dist/src/utils/errorReporting.d.ts +1 -1
- package/dist/src/utils/errorReporting.js +2 -2
- package/dist/src/utils/errorReporting.js.map +1 -1
- package/dist/src/utils/errorReporting.test.js +44 -38
- package/dist/src/utils/errorReporting.test.js.map +1 -1
- package/dist/src/utils/fileUtils.d.ts +4 -4
- package/dist/src/utils/fileUtils.js +31 -15
- package/dist/src/utils/fileUtils.js.map +1 -1
- package/dist/src/utils/fileUtils.test.js +37 -37
- package/dist/src/utils/fileUtils.test.js.map +1 -1
- package/dist/src/utils/getFolderStructure.d.ts +3 -2
- package/dist/src/utils/getFolderStructure.js +27 -28
- package/dist/src/utils/getFolderStructure.js.map +1 -1
- package/dist/src/utils/getFolderStructure.test.js +169 -185
- package/dist/src/utils/getFolderStructure.test.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.js +4 -7
- package/dist/src/utils/gitIgnoreParser.js.map +1 -1
- package/dist/src/utils/gitIgnoreParser.test.js +71 -62
- package/dist/src/utils/gitIgnoreParser.test.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.d.ts +2 -1
- package/dist/src/utils/memoryDiscovery.js +11 -5
- package/dist/src/utils/memoryDiscovery.js.map +1 -1
- package/dist/src/utils/memoryDiscovery.test.js +160 -371
- package/dist/src/utils/memoryDiscovery.test.js.map +1 -1
- package/dist/src/utils/partUtils.d.ts +14 -0
- package/dist/src/utils/partUtils.js +65 -0
- package/dist/src/utils/partUtils.js.map +1 -0
- package/dist/src/utils/partUtils.test.d.ts +6 -0
- package/dist/src/utils/partUtils.test.js +130 -0
- package/dist/src/utils/partUtils.test.js.map +1 -0
- package/dist/src/utils/paths.d.ts +11 -0
- package/dist/src/utils/paths.js +17 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/quotaErrorDetection.js.map +1 -1
- package/dist/src/utils/retry.js +1 -1
- package/dist/src/utils/retry.js.map +1 -1
- package/dist/src/utils/schemaValidator.js +5 -2
- package/dist/src/utils/schemaValidator.js.map +1 -1
- package/dist/src/utils/shell-utils.d.ts +44 -0
- package/dist/src/utils/shell-utils.js +243 -0
- package/dist/src/utils/shell-utils.js.map +1 -0
- package/dist/src/utils/shell-utils.test.d.ts +6 -0
- package/dist/src/utils/shell-utils.test.js +450 -0
- package/dist/src/utils/shell-utils.test.js.map +1 -0
- package/dist/src/utils/summarizer.js +1 -30
- package/dist/src/utils/summarizer.js.map +1 -1
- package/dist/src/utils/systemEncoding.d.ts +40 -0
- package/dist/src/utils/systemEncoding.js +149 -0
- package/dist/src/utils/systemEncoding.js.map +1 -0
- package/dist/src/utils/systemEncoding.test.d.ts +6 -0
- package/dist/src/utils/systemEncoding.test.js +368 -0
- package/dist/src/utils/systemEncoding.test.js.map +1 -0
- package/dist/src/utils/user_account.test.js +1 -1
- package/dist/src/utils/user_account.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -1
- package/dist/src/core/geminiRequest.test.js +0 -72
- package/dist/src/core/geminiRequest.test.js.map +0 -1
- package/dist/src/services/ideContext.d.ts +0 -126
- package/dist/src/services/ideContext.js.map +0 -1
- package/dist/src/services/ideContext.test.js.map +0 -1
- /package/dist/src/{services → ide}/ideContext.test.d.ts +0 -0
- /package/dist/src/{core/geminiRequest.test.d.ts → mcp/google-auth-provider.test.d.ts} +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Zod schema for validating a cursor position.
|
|
9
|
+
*/
|
|
10
|
+
export declare const CursorSchema: z.ZodObject<{
|
|
11
|
+
line: z.ZodNumber;
|
|
12
|
+
character: z.ZodNumber;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
line: number;
|
|
15
|
+
character: number;
|
|
16
|
+
}, {
|
|
17
|
+
line: number;
|
|
18
|
+
character: number;
|
|
19
|
+
}>;
|
|
20
|
+
export type Cursor = z.infer<typeof CursorSchema>;
|
|
21
|
+
/**
|
|
22
|
+
* Zod schema for validating an active file context from the IDE.
|
|
23
|
+
*/
|
|
24
|
+
export declare const OpenFilesSchema: z.ZodObject<{
|
|
25
|
+
activeFile: z.ZodString;
|
|
26
|
+
selectedText: z.ZodOptional<z.ZodString>;
|
|
27
|
+
cursor: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
line: z.ZodNumber;
|
|
29
|
+
character: z.ZodNumber;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
line: number;
|
|
32
|
+
character: number;
|
|
33
|
+
}, {
|
|
34
|
+
line: number;
|
|
35
|
+
character: number;
|
|
36
|
+
}>>;
|
|
37
|
+
recentOpenFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
38
|
+
filePath: z.ZodString;
|
|
39
|
+
timestamp: z.ZodNumber;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
filePath: string;
|
|
42
|
+
timestamp: number;
|
|
43
|
+
}, {
|
|
44
|
+
filePath: string;
|
|
45
|
+
timestamp: number;
|
|
46
|
+
}>, "many">>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
activeFile: string;
|
|
49
|
+
cursor?: {
|
|
50
|
+
line: number;
|
|
51
|
+
character: number;
|
|
52
|
+
} | undefined;
|
|
53
|
+
selectedText?: string | undefined;
|
|
54
|
+
recentOpenFiles?: {
|
|
55
|
+
filePath: string;
|
|
56
|
+
timestamp: number;
|
|
57
|
+
}[] | undefined;
|
|
58
|
+
}, {
|
|
59
|
+
activeFile: string;
|
|
60
|
+
cursor?: {
|
|
61
|
+
line: number;
|
|
62
|
+
character: number;
|
|
63
|
+
} | undefined;
|
|
64
|
+
selectedText?: string | undefined;
|
|
65
|
+
recentOpenFiles?: {
|
|
66
|
+
filePath: string;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export type OpenFiles = z.infer<typeof OpenFilesSchema>;
|
|
71
|
+
/**
|
|
72
|
+
* Zod schema for validating the 'ide/openFilesChanged' notification from the IDE.
|
|
73
|
+
*/
|
|
74
|
+
export declare const OpenFilesNotificationSchema: z.ZodObject<{
|
|
75
|
+
method: z.ZodLiteral<"ide/openFilesChanged">;
|
|
76
|
+
params: z.ZodObject<{
|
|
77
|
+
activeFile: z.ZodString;
|
|
78
|
+
selectedText: z.ZodOptional<z.ZodString>;
|
|
79
|
+
cursor: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
line: z.ZodNumber;
|
|
81
|
+
character: z.ZodNumber;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
line: number;
|
|
84
|
+
character: number;
|
|
85
|
+
}, {
|
|
86
|
+
line: number;
|
|
87
|
+
character: number;
|
|
88
|
+
}>>;
|
|
89
|
+
recentOpenFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
+
filePath: z.ZodString;
|
|
91
|
+
timestamp: z.ZodNumber;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
filePath: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
}, {
|
|
96
|
+
filePath: string;
|
|
97
|
+
timestamp: number;
|
|
98
|
+
}>, "many">>;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
activeFile: string;
|
|
101
|
+
cursor?: {
|
|
102
|
+
line: number;
|
|
103
|
+
character: number;
|
|
104
|
+
} | undefined;
|
|
105
|
+
selectedText?: string | undefined;
|
|
106
|
+
recentOpenFiles?: {
|
|
107
|
+
filePath: string;
|
|
108
|
+
timestamp: number;
|
|
109
|
+
}[] | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
activeFile: string;
|
|
112
|
+
cursor?: {
|
|
113
|
+
line: number;
|
|
114
|
+
character: number;
|
|
115
|
+
} | undefined;
|
|
116
|
+
selectedText?: string | undefined;
|
|
117
|
+
recentOpenFiles?: {
|
|
118
|
+
filePath: string;
|
|
119
|
+
timestamp: number;
|
|
120
|
+
}[] | undefined;
|
|
121
|
+
}>;
|
|
122
|
+
}, "strip", z.ZodTypeAny, {
|
|
123
|
+
method: "ide/openFilesChanged";
|
|
124
|
+
params: {
|
|
125
|
+
activeFile: string;
|
|
126
|
+
cursor?: {
|
|
127
|
+
line: number;
|
|
128
|
+
character: number;
|
|
129
|
+
} | undefined;
|
|
130
|
+
selectedText?: string | undefined;
|
|
131
|
+
recentOpenFiles?: {
|
|
132
|
+
filePath: string;
|
|
133
|
+
timestamp: number;
|
|
134
|
+
}[] | undefined;
|
|
135
|
+
};
|
|
136
|
+
}, {
|
|
137
|
+
method: "ide/openFilesChanged";
|
|
138
|
+
params: {
|
|
139
|
+
activeFile: string;
|
|
140
|
+
cursor?: {
|
|
141
|
+
line: number;
|
|
142
|
+
character: number;
|
|
143
|
+
} | undefined;
|
|
144
|
+
selectedText?: string | undefined;
|
|
145
|
+
recentOpenFiles?: {
|
|
146
|
+
filePath: string;
|
|
147
|
+
timestamp: number;
|
|
148
|
+
}[] | undefined;
|
|
149
|
+
};
|
|
150
|
+
}>;
|
|
151
|
+
type OpenFilesSubscriber = (openFiles: OpenFiles | undefined) => void;
|
|
152
|
+
/**
|
|
153
|
+
* Creates a new store for managing the IDE's active file context.
|
|
154
|
+
* This factory function encapsulates the state and logic, allowing for the creation
|
|
155
|
+
* of isolated instances, which is particularly useful for testing.
|
|
156
|
+
*
|
|
157
|
+
* @returns An object with methods to interact with the active file context.
|
|
158
|
+
*/
|
|
159
|
+
export declare function createIdeContextStore(): {
|
|
160
|
+
setOpenFilesContext: (newOpenFiles: OpenFiles) => void;
|
|
161
|
+
getOpenFilesContext: () => OpenFiles | undefined;
|
|
162
|
+
subscribeToOpenFiles: (subscriber: OpenFilesSubscriber) => () => void;
|
|
163
|
+
clearOpenFilesContext: () => void;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* The default, shared instance of the IDE context store for the application.
|
|
167
|
+
*/
|
|
168
|
+
export declare const ideContext: {
|
|
169
|
+
setOpenFilesContext: (newOpenFiles: OpenFiles) => void;
|
|
170
|
+
getOpenFilesContext: () => OpenFiles | undefined;
|
|
171
|
+
subscribeToOpenFiles: (subscriber: OpenFilesSubscriber) => () => void;
|
|
172
|
+
clearOpenFilesContext: () => void;
|
|
173
|
+
};
|
|
174
|
+
export {};
|
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
/**
|
|
8
|
-
* The reserved server name for the IDE's MCP server.
|
|
9
|
-
*/
|
|
10
|
-
export const IDE_SERVER_NAME = '_ide_server';
|
|
11
7
|
/**
|
|
12
8
|
* Zod schema for validating a cursor position.
|
|
13
9
|
*/
|
|
@@ -18,16 +14,23 @@ export const CursorSchema = z.object({
|
|
|
18
14
|
/**
|
|
19
15
|
* Zod schema for validating an active file context from the IDE.
|
|
20
16
|
*/
|
|
21
|
-
export const
|
|
22
|
-
|
|
17
|
+
export const OpenFilesSchema = z.object({
|
|
18
|
+
activeFile: z.string(),
|
|
19
|
+
selectedText: z.string().optional(),
|
|
23
20
|
cursor: CursorSchema.optional(),
|
|
21
|
+
recentOpenFiles: z
|
|
22
|
+
.array(z.object({
|
|
23
|
+
filePath: z.string(),
|
|
24
|
+
timestamp: z.number(),
|
|
25
|
+
}))
|
|
26
|
+
.optional(),
|
|
24
27
|
});
|
|
25
28
|
/**
|
|
26
|
-
* Zod schema for validating the 'ide/
|
|
29
|
+
* Zod schema for validating the 'ide/openFilesChanged' notification from the IDE.
|
|
27
30
|
*/
|
|
28
|
-
export const
|
|
29
|
-
method: z.literal('ide/
|
|
30
|
-
params:
|
|
31
|
+
export const OpenFilesNotificationSchema = z.object({
|
|
32
|
+
method: z.literal('ide/openFilesChanged'),
|
|
33
|
+
params: OpenFilesSchema,
|
|
31
34
|
});
|
|
32
35
|
/**
|
|
33
36
|
* Creates a new store for managing the IDE's active file context.
|
|
@@ -37,37 +40,37 @@ export const ActiveFileNotificationSchema = z.object({
|
|
|
37
40
|
* @returns An object with methods to interact with the active file context.
|
|
38
41
|
*/
|
|
39
42
|
export function createIdeContextStore() {
|
|
40
|
-
let
|
|
43
|
+
let openFilesContext = undefined;
|
|
41
44
|
const subscribers = new Set();
|
|
42
45
|
/**
|
|
43
46
|
* Notifies all registered subscribers about the current active file context.
|
|
44
47
|
*/
|
|
45
48
|
function notifySubscribers() {
|
|
46
49
|
for (const subscriber of subscribers) {
|
|
47
|
-
subscriber(
|
|
50
|
+
subscriber(openFilesContext);
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
54
|
* Sets the active file context and notifies all registered subscribers of the change.
|
|
52
|
-
* @param
|
|
55
|
+
* @param newOpenFiles The new active file context from the IDE.
|
|
53
56
|
*/
|
|
54
|
-
function
|
|
55
|
-
|
|
57
|
+
function setOpenFilesContext(newOpenFiles) {
|
|
58
|
+
openFilesContext = newOpenFiles;
|
|
56
59
|
notifySubscribers();
|
|
57
60
|
}
|
|
58
61
|
/**
|
|
59
62
|
* Clears the active file context and notifies all registered subscribers of the change.
|
|
60
63
|
*/
|
|
61
|
-
function
|
|
62
|
-
|
|
64
|
+
function clearOpenFilesContext() {
|
|
65
|
+
openFilesContext = undefined;
|
|
63
66
|
notifySubscribers();
|
|
64
67
|
}
|
|
65
68
|
/**
|
|
66
69
|
* Retrieves the current active file context.
|
|
67
|
-
* @returns The `
|
|
70
|
+
* @returns The `OpenFiles` object if a file is active; otherwise, `undefined`.
|
|
68
71
|
*/
|
|
69
|
-
function
|
|
70
|
-
return
|
|
72
|
+
function getOpenFilesContext() {
|
|
73
|
+
return openFilesContext;
|
|
71
74
|
}
|
|
72
75
|
/**
|
|
73
76
|
* Subscribes to changes in the active file context.
|
|
@@ -78,17 +81,17 @@ export function createIdeContextStore() {
|
|
|
78
81
|
* @param subscriber The function to be called when the active file context changes.
|
|
79
82
|
* @returns A function that, when called, will unsubscribe the provided subscriber.
|
|
80
83
|
*/
|
|
81
|
-
function
|
|
84
|
+
function subscribeToOpenFiles(subscriber) {
|
|
82
85
|
subscribers.add(subscriber);
|
|
83
86
|
return () => {
|
|
84
87
|
subscribers.delete(subscriber);
|
|
85
88
|
};
|
|
86
89
|
}
|
|
87
90
|
return {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
setOpenFilesContext,
|
|
92
|
+
getOpenFilesContext,
|
|
93
|
+
subscribeToOpenFiles,
|
|
94
|
+
clearOpenFilesContext,
|
|
92
95
|
};
|
|
93
96
|
}
|
|
94
97
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ideContext.js","sourceRoot":"","sources":["../../../src/ide/ideContext.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC,CAAC;AAGH;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,MAAM,EAAE,YAAY,CAAC,QAAQ,EAAE;IAC/B,eAAe,EAAE,CAAC;SACf,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;KACtB,CAAC,CACH;SACA,QAAQ,EAAE;CACd,CAAC,CAAC;AAGH;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC;IACzC,MAAM,EAAE,eAAe;CACxB,CAAC,CAAC;AAIH;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB;IACnC,IAAI,gBAAgB,GAA0B,SAAS,CAAC;IACxD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEnD;;OAEG;IACH,SAAS,iBAAiB;QACxB,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,UAAU,CAAC,gBAAgB,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,SAAS,mBAAmB,CAAC,YAAuB;QAClD,gBAAgB,GAAG,YAAY,CAAC;QAChC,iBAAiB,EAAE,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,SAAS,qBAAqB;QAC5B,gBAAgB,GAAG,SAAS,CAAC;QAC7B,iBAAiB,EAAE,CAAC;IACtB,CAAC;IAED;;;OAGG;IACH,SAAS,mBAAmB;QAC1B,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED;;;;;;;;OAQG;IACH,SAAS,oBAAoB,CAAC,UAA+B;QAC3D,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC5B,OAAO,GAAG,EAAE;YACV,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACjC,CAAC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,mBAAmB;QACnB,mBAAmB;QACnB,oBAAoB;QACpB,qBAAqB;KACtB,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC"}
|
|
@@ -12,59 +12,59 @@ describe('ideContext - Active File', () => {
|
|
|
12
12
|
ideContext = createIdeContextStore();
|
|
13
13
|
});
|
|
14
14
|
it('should return undefined initially for active file context', () => {
|
|
15
|
-
expect(ideContext.
|
|
15
|
+
expect(ideContext.getOpenFilesContext()).toBeUndefined();
|
|
16
16
|
});
|
|
17
17
|
it('should set and retrieve the active file context', () => {
|
|
18
18
|
const testFile = {
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
activeFile: '/path/to/test/file.ts',
|
|
20
|
+
selectedText: '1234',
|
|
21
21
|
};
|
|
22
|
-
ideContext.
|
|
23
|
-
const activeFile = ideContext.
|
|
22
|
+
ideContext.setOpenFilesContext(testFile);
|
|
23
|
+
const activeFile = ideContext.getOpenFilesContext();
|
|
24
24
|
expect(activeFile).toEqual(testFile);
|
|
25
25
|
});
|
|
26
26
|
it('should update the active file context when called multiple times', () => {
|
|
27
27
|
const firstFile = {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
activeFile: '/path/to/first.js',
|
|
29
|
+
selectedText: '1234',
|
|
30
30
|
};
|
|
31
|
-
ideContext.
|
|
31
|
+
ideContext.setOpenFilesContext(firstFile);
|
|
32
32
|
const secondFile = {
|
|
33
|
-
|
|
33
|
+
activeFile: '/path/to/second.py',
|
|
34
34
|
cursor: { line: 20, character: 30 },
|
|
35
35
|
};
|
|
36
|
-
ideContext.
|
|
37
|
-
const activeFile = ideContext.
|
|
36
|
+
ideContext.setOpenFilesContext(secondFile);
|
|
37
|
+
const activeFile = ideContext.getOpenFilesContext();
|
|
38
38
|
expect(activeFile).toEqual(secondFile);
|
|
39
39
|
});
|
|
40
40
|
it('should handle empty string for file path', () => {
|
|
41
41
|
const testFile = {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
activeFile: '',
|
|
43
|
+
selectedText: '1234',
|
|
44
44
|
};
|
|
45
|
-
ideContext.
|
|
46
|
-
expect(ideContext.
|
|
45
|
+
ideContext.setOpenFilesContext(testFile);
|
|
46
|
+
expect(ideContext.getOpenFilesContext()).toEqual(testFile);
|
|
47
47
|
});
|
|
48
48
|
it('should notify subscribers when active file context changes', () => {
|
|
49
49
|
const subscriber1 = vi.fn();
|
|
50
50
|
const subscriber2 = vi.fn();
|
|
51
|
-
ideContext.
|
|
52
|
-
ideContext.
|
|
51
|
+
ideContext.subscribeToOpenFiles(subscriber1);
|
|
52
|
+
ideContext.subscribeToOpenFiles(subscriber2);
|
|
53
53
|
const testFile = {
|
|
54
|
-
|
|
54
|
+
activeFile: '/path/to/subscribed.ts',
|
|
55
55
|
cursor: { line: 15, character: 25 },
|
|
56
56
|
};
|
|
57
|
-
ideContext.
|
|
57
|
+
ideContext.setOpenFilesContext(testFile);
|
|
58
58
|
expect(subscriber1).toHaveBeenCalledTimes(1);
|
|
59
59
|
expect(subscriber1).toHaveBeenCalledWith(testFile);
|
|
60
60
|
expect(subscriber2).toHaveBeenCalledTimes(1);
|
|
61
61
|
expect(subscriber2).toHaveBeenCalledWith(testFile);
|
|
62
62
|
// Test with another update
|
|
63
63
|
const newFile = {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
activeFile: '/path/to/new.js',
|
|
65
|
+
selectedText: '1234',
|
|
66
66
|
};
|
|
67
|
-
ideContext.
|
|
67
|
+
ideContext.setOpenFilesContext(newFile);
|
|
68
68
|
expect(subscriber1).toHaveBeenCalledTimes(2);
|
|
69
69
|
expect(subscriber1).toHaveBeenCalledWith(newFile);
|
|
70
70
|
expect(subscriber2).toHaveBeenCalledTimes(2);
|
|
@@ -73,39 +73,39 @@ describe('ideContext - Active File', () => {
|
|
|
73
73
|
it('should stop notifying a subscriber after unsubscribe', () => {
|
|
74
74
|
const subscriber1 = vi.fn();
|
|
75
75
|
const subscriber2 = vi.fn();
|
|
76
|
-
const unsubscribe1 = ideContext.
|
|
77
|
-
ideContext.
|
|
78
|
-
ideContext.
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
const unsubscribe1 = ideContext.subscribeToOpenFiles(subscriber1);
|
|
77
|
+
ideContext.subscribeToOpenFiles(subscriber2);
|
|
78
|
+
ideContext.setOpenFilesContext({
|
|
79
|
+
activeFile: '/path/to/file1.txt',
|
|
80
|
+
selectedText: '1234',
|
|
81
81
|
});
|
|
82
82
|
expect(subscriber1).toHaveBeenCalledTimes(1);
|
|
83
83
|
expect(subscriber2).toHaveBeenCalledTimes(1);
|
|
84
84
|
unsubscribe1();
|
|
85
|
-
ideContext.
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
ideContext.setOpenFilesContext({
|
|
86
|
+
activeFile: '/path/to/file2.txt',
|
|
87
|
+
selectedText: '1234',
|
|
88
88
|
});
|
|
89
89
|
expect(subscriber1).toHaveBeenCalledTimes(1); // Should not be called again
|
|
90
90
|
expect(subscriber2).toHaveBeenCalledTimes(2);
|
|
91
91
|
});
|
|
92
92
|
it('should allow the cursor to be optional', () => {
|
|
93
93
|
const testFile = {
|
|
94
|
-
|
|
94
|
+
activeFile: '/path/to/test/file.ts',
|
|
95
95
|
};
|
|
96
|
-
ideContext.
|
|
97
|
-
const activeFile = ideContext.
|
|
96
|
+
ideContext.setOpenFilesContext(testFile);
|
|
97
|
+
const activeFile = ideContext.getOpenFilesContext();
|
|
98
98
|
expect(activeFile).toEqual(testFile);
|
|
99
99
|
});
|
|
100
100
|
it('should clear the active file context', () => {
|
|
101
101
|
const testFile = {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
activeFile: '/path/to/test/file.ts',
|
|
103
|
+
selectedText: '1234',
|
|
104
104
|
};
|
|
105
|
-
ideContext.
|
|
106
|
-
expect(ideContext.
|
|
107
|
-
ideContext.
|
|
108
|
-
expect(ideContext.
|
|
105
|
+
ideContext.setOpenFilesContext(testFile);
|
|
106
|
+
expect(ideContext.getOpenFilesContext()).toEqual(testFile);
|
|
107
|
+
ideContext.clearOpenFilesContext();
|
|
108
|
+
expect(ideContext.getOpenFilesContext()).toBeUndefined();
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
//# sourceMappingURL=ideContext.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ideContext.test.js","sourceRoot":"","sources":["../../../src/ide/ideContext.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA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,uBAAuB;SACpC,CAAC;QAEF,UAAU,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAEzC,MAAM,UAAU,GAAG,UAAU,CAAC,mBAAmB,EAAE,CAAC;QACpD,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,QAAQ,GAAG;YACf,UAAU,EAAE,uBAAuB;YACnC,YAAY,EAAE,MAAM;SACrB,CAAC;QAEF,UAAU,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;QAEzC,MAAM,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE3D,UAAU,CAAC,qBAAqB,EAAE,CAAC;QAEnC,MAAM,CAAC,UAAU,CAAC,mBAAmB,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;IAC3D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -28,9 +28,11 @@ export * from './utils/editor.js';
|
|
|
28
28
|
export * from './utils/quotaErrorDetection.js';
|
|
29
29
|
export * from './utils/fileUtils.js';
|
|
30
30
|
export * from './utils/retry.js';
|
|
31
|
+
export * from './utils/systemEncoding.js';
|
|
31
32
|
export * from './services/fileDiscoveryService.js';
|
|
32
33
|
export * from './services/gitService.js';
|
|
33
|
-
export * from './
|
|
34
|
+
export * from './ide/ide-client.js';
|
|
35
|
+
export * from './ide/ideContext.js';
|
|
34
36
|
export * from './tools/tools.js';
|
|
35
37
|
export * from './tools/tool-registry.js';
|
|
36
38
|
export * from './tools/read-file.js';
|
package/dist/src/index.js
CHANGED
|
@@ -31,10 +31,13 @@ export * from './utils/editor.js';
|
|
|
31
31
|
export * from './utils/quotaErrorDetection.js';
|
|
32
32
|
export * from './utils/fileUtils.js';
|
|
33
33
|
export * from './utils/retry.js';
|
|
34
|
+
export * from './utils/systemEncoding.js';
|
|
34
35
|
// Export services
|
|
35
36
|
export * from './services/fileDiscoveryService.js';
|
|
36
37
|
export * from './services/gitService.js';
|
|
37
|
-
|
|
38
|
+
// Export IDE specific logic
|
|
39
|
+
export * from './ide/ide-client.js';
|
|
40
|
+
export * from './ide/ideContext.js';
|
|
38
41
|
// Export base tool definitions
|
|
39
42
|
export * from './tools/tools.js';
|
|
40
43
|
export * from './tools/tool-registry.js';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,gBAAgB;AAChB,cAAc,oBAAoB,CAAC;AAEnC,oBAAoB;AACpB,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sCAAsC,CAAC;AAErD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AAEvC,mBAAmB;AACnB,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;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,CAAC;AAE7C,iBAAiB;AACjB,cAAc,iCAAiC,CAAC;AAEhD,yBAAyB;AACzB,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
7
|
+
import { OAuthClientInformation, OAuthClientInformationFull, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js';
|
|
8
|
+
import { MCPServerConfig } from '../config/config.js';
|
|
9
|
+
export declare class GoogleCredentialProvider implements OAuthClientProvider {
|
|
10
|
+
private readonly config?;
|
|
11
|
+
private readonly auth;
|
|
12
|
+
readonly redirectUrl = "";
|
|
13
|
+
readonly clientMetadata: OAuthClientMetadata;
|
|
14
|
+
private _clientInformation?;
|
|
15
|
+
constructor(config?: MCPServerConfig | undefined);
|
|
16
|
+
clientInformation(): OAuthClientInformation | undefined;
|
|
17
|
+
saveClientInformation(clientInformation: OAuthClientInformationFull): void;
|
|
18
|
+
tokens(): Promise<OAuthTokens | undefined>;
|
|
19
|
+
saveTokens(_tokens: OAuthTokens): void;
|
|
20
|
+
redirectToAuthorization(_authorizationUrl: URL): void;
|
|
21
|
+
saveCodeVerifier(_codeVerifier: string): void;
|
|
22
|
+
codeVerifier(): string;
|
|
23
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GoogleAuth } from 'google-auth-library';
|
|
7
|
+
export class GoogleCredentialProvider {
|
|
8
|
+
config;
|
|
9
|
+
auth;
|
|
10
|
+
// Properties required by OAuthClientProvider, with no-op values
|
|
11
|
+
redirectUrl = '';
|
|
12
|
+
clientMetadata = {
|
|
13
|
+
client_name: 'Gemini CLI (Google ADC)',
|
|
14
|
+
redirect_uris: [],
|
|
15
|
+
grant_types: [],
|
|
16
|
+
response_types: [],
|
|
17
|
+
token_endpoint_auth_method: 'none',
|
|
18
|
+
};
|
|
19
|
+
_clientInformation;
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.config = config;
|
|
22
|
+
const scopes = this.config?.oauth?.scopes;
|
|
23
|
+
if (!scopes || scopes.length === 0) {
|
|
24
|
+
throw new Error('Scopes must be provided in the oauth config for Google Credentials provider');
|
|
25
|
+
}
|
|
26
|
+
this.auth = new GoogleAuth({
|
|
27
|
+
scopes,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
clientInformation() {
|
|
31
|
+
return this._clientInformation;
|
|
32
|
+
}
|
|
33
|
+
saveClientInformation(clientInformation) {
|
|
34
|
+
this._clientInformation = clientInformation;
|
|
35
|
+
}
|
|
36
|
+
async tokens() {
|
|
37
|
+
const client = await this.auth.getClient();
|
|
38
|
+
const accessTokenResponse = await client.getAccessToken();
|
|
39
|
+
if (!accessTokenResponse.token) {
|
|
40
|
+
console.error('Failed to get access token from Google ADC');
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const tokens = {
|
|
44
|
+
access_token: accessTokenResponse.token,
|
|
45
|
+
token_type: 'Bearer',
|
|
46
|
+
};
|
|
47
|
+
return tokens;
|
|
48
|
+
}
|
|
49
|
+
saveTokens(_tokens) {
|
|
50
|
+
// No-op, ADC manages tokens.
|
|
51
|
+
}
|
|
52
|
+
redirectToAuthorization(_authorizationUrl) {
|
|
53
|
+
// No-op
|
|
54
|
+
}
|
|
55
|
+
saveCodeVerifier(_codeVerifier) {
|
|
56
|
+
// No-op
|
|
57
|
+
}
|
|
58
|
+
codeVerifier() {
|
|
59
|
+
// No-op
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=google-auth-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-auth-provider.js","sourceRoot":"","sources":["../../../src/mcp/google-auth-provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,MAAM,OAAO,wBAAwB;IAcN;IAbZ,IAAI,CAAa;IAElC,gEAAgE;IACvD,WAAW,GAAG,EAAE,CAAC;IACjB,cAAc,GAAwB;QAC7C,WAAW,EAAE,yBAAyB;QACtC,aAAa,EAAE,EAAE;QACjB,WAAW,EAAE,EAAE;QACf,cAAc,EAAE,EAAE;QAClB,0BAA0B,EAAE,MAAM;KACnC,CAAC;IACM,kBAAkB,CAA8B;IAExD,YAA6B,MAAwB;QAAxB,WAAM,GAAN,MAAM,CAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;QAC1C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC;YACzB,MAAM;SACP,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,qBAAqB,CAAC,iBAA6C;QACjE,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;QAC3C,MAAM,mBAAmB,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;QAE1D,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAC5D,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,MAAM,GAAgB;YAC1B,YAAY,EAAE,mBAAmB,CAAC,KAAK;YACvC,UAAU,EAAE,QAAQ;SACrB,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAoB;QAC7B,6BAA6B;IAC/B,CAAC;IAED,uBAAuB,CAAC,iBAAsB;QAC5C,QAAQ;IACV,CAAC;IAED,gBAAgB,CAAC,aAAqB;QACpC,QAAQ;IACV,CAAC;IAED,YAAY;QACV,QAAQ;QACR,OAAO,EAAE,CAAC;IACZ,CAAC;CACF"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { GoogleAuth } from 'google-auth-library';
|
|
7
|
+
import { GoogleCredentialProvider } from './google-auth-provider.js';
|
|
8
|
+
import { vi, describe, beforeEach, it, expect } from 'vitest';
|
|
9
|
+
vi.mock('google-auth-library');
|
|
10
|
+
describe('GoogleCredentialProvider', () => {
|
|
11
|
+
it('should throw an error if no scopes are provided', () => {
|
|
12
|
+
expect(() => new GoogleCredentialProvider()).toThrow('Scopes must be provided in the oauth config for Google Credentials provider');
|
|
13
|
+
});
|
|
14
|
+
it('should use scopes from the config if provided', () => {
|
|
15
|
+
const config = {
|
|
16
|
+
oauth: {
|
|
17
|
+
scopes: ['scope1', 'scope2'],
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
new GoogleCredentialProvider(config);
|
|
21
|
+
expect(GoogleAuth).toHaveBeenCalledWith({
|
|
22
|
+
scopes: ['scope1', 'scope2'],
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('with provider instance', () => {
|
|
26
|
+
let provider;
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
const config = {
|
|
29
|
+
oauth: {
|
|
30
|
+
scopes: ['scope1', 'scope2'],
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
provider = new GoogleCredentialProvider(config);
|
|
34
|
+
vi.clearAllMocks();
|
|
35
|
+
});
|
|
36
|
+
it('should return credentials', async () => {
|
|
37
|
+
const mockClient = {
|
|
38
|
+
getAccessToken: vi.fn().mockResolvedValue({ token: 'test-token' }),
|
|
39
|
+
};
|
|
40
|
+
GoogleAuth.prototype.getClient.mockResolvedValue(mockClient);
|
|
41
|
+
const credentials = await provider.tokens();
|
|
42
|
+
expect(credentials?.access_token).toBe('test-token');
|
|
43
|
+
});
|
|
44
|
+
it('should return undefined if access token is not available', async () => {
|
|
45
|
+
const mockClient = {
|
|
46
|
+
getAccessToken: vi.fn().mockResolvedValue({ token: null }),
|
|
47
|
+
};
|
|
48
|
+
GoogleAuth.prototype.getClient.mockResolvedValue(mockClient);
|
|
49
|
+
const credentials = await provider.tokens();
|
|
50
|
+
expect(credentials).toBeUndefined();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
//# sourceMappingURL=google-auth-provider.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"google-auth-provider.test.js","sourceRoot":"","sources":["../../../src/mcp/google-auth-provider.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAC;AAGpE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAE/B,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,iDAAiD,EAAE,GAAG,EAAE;QACzD,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,wBAAwB,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