repoburg 1.3.136 → 1.3.138

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 (172) hide show
  1. package/CODEMAP.md +3 -11
  2. package/README.md +4 -4
  3. package/backend/.env +2 -2
  4. package/backend/CODEMAP.md +2 -3
  5. package/backend/dist/src/core-entities/llm-call-log.entity.d.ts +1 -1
  6. package/backend/dist/src/core-entities/llm-call-log.entity.js +3 -3
  7. package/backend/dist/src/core-entities/llm-call-log.entity.js.map +1 -1
  8. package/backend/dist/src/core-entities/session.entity.js +2 -2
  9. package/backend/dist/src/core-entities/session.entity.js.map +1 -1
  10. package/backend/dist/src/core-entities/system-prompt.entity.js +1 -1
  11. package/backend/dist/src/core-entities/system-prompt.entity.js.map +1 -1
  12. package/backend/dist/src/llm-call-logs/dto/llm-call-log.dto.d.ts +1 -1
  13. package/backend/dist/src/llm-call-logs/dto/llm-call-log.dto.js +1 -1
  14. package/backend/dist/src/llm-call-logs/dto/llm-call-log.dto.js.map +1 -1
  15. package/backend/dist/src/llm-call-logs/llm-call-logs.controller.js +1 -1
  16. package/backend/dist/src/llm-orchestration/action-handlers/manage-sub-agents.handler.js +1 -1
  17. package/backend/dist/src/llm-orchestration/action-handlers/overwrite-file.handler.js +1 -0
  18. package/backend/dist/src/llm-orchestration/action-handlers/overwrite-file.handler.js.map +1 -1
  19. package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js +3 -0
  20. package/backend/dist/src/llm-orchestration/action-handlers/quick-edit.handler.js.map +1 -1
  21. package/backend/dist/src/llm-provider/llm-provider.interface.d.ts +3 -9
  22. package/backend/dist/src/llm-provider/llm-provider.interface.js +2 -9
  23. package/backend/dist/src/llm-provider/llm-provider.interface.js.map +1 -1
  24. package/backend/dist/src/llm-provider/llm-provider.module.js +1 -2
  25. package/backend/dist/src/llm-provider/llm-provider.module.js.map +1 -1
  26. package/backend/dist/src/llm-provider/proxy-llm.provider.d.ts +1 -3
  27. package/backend/dist/src/llm-provider/proxy-llm.provider.js +4 -12
  28. package/backend/dist/src/llm-provider/proxy-llm.provider.js.map +1 -1
  29. package/backend/dist/src/llm-responses/dto/sync-conversation.dto.js +2 -2
  30. package/backend/dist/src/llm-responses/dto/sync-conversation.dto.js.map +1 -1
  31. package/backend/dist/src/sessions/dto/session.dto.d.ts +1 -1
  32. package/backend/dist/src/sessions/dto/session.dto.js +7 -7
  33. package/backend/dist/src/sessions/dto/session.dto.js.map +1 -1
  34. package/backend/dist/src/sessions/sessions.service.js +14 -5
  35. package/backend/dist/src/sessions/sessions.service.js.map +1 -1
  36. package/backend/dist/src/sub-agents/dto/create-sub-agent.dto.js +1 -1
  37. package/backend/dist/src/sub-agents/dto/create-sub-agent.dto.js.map +1 -1
  38. package/backend/dist/src/sub-agents/dto/update-sub-agent.dto.js +1 -1
  39. package/backend/dist/src/sub-agents/dto/update-sub-agent.dto.js.map +1 -1
  40. package/backend/dist/src/sub-agents/sub-agent.entity.js +1 -1
  41. package/backend/dist/src/sub-agents/sub-agent.entity.js.map +1 -1
  42. package/backend/dist/src/system-prompts/dto/system-prompt.dto.js +2 -2
  43. package/backend/dist/src/system-prompts/dto/system-prompt.dto.js.map +1 -1
  44. package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
  45. package/package.json +1 -2
  46. package/backend/dist/packages/gemini-core/examples/simple.d.ts +0 -1
  47. package/backend/dist/packages/gemini-core/examples/simple.js +0 -73
  48. package/backend/dist/packages/gemini-core/examples/simple.js.map +0 -1
  49. package/backend/dist/packages/gemini-core/index.d.ts +0 -3
  50. package/backend/dist/packages/gemini-core/index.js +0 -27
  51. package/backend/dist/packages/gemini-core/index.js.map +0 -1
  52. package/backend/dist/packages/gemini-core/src/code_assist/codeAssist.d.ts +0 -5
  53. package/backend/dist/packages/gemini-core/src/code_assist/codeAssist.js +0 -17
  54. package/backend/dist/packages/gemini-core/src/code_assist/codeAssist.js.map +0 -1
  55. package/backend/dist/packages/gemini-core/src/code_assist/converter.d.ts +0 -69
  56. package/backend/dist/packages/gemini-core/src/code_assist/converter.js +0 -129
  57. package/backend/dist/packages/gemini-core/src/code_assist/converter.js.map +0 -1
  58. package/backend/dist/packages/gemini-core/src/code_assist/oauth-credential-storage.d.ts +0 -8
  59. package/backend/dist/packages/gemini-core/src/code_assist/oauth-credential-storage.js +0 -84
  60. package/backend/dist/packages/gemini-core/src/code_assist/oauth-credential-storage.js.map +0 -1
  61. package/backend/dist/packages/gemini-core/src/code_assist/oauth2.d.ts +0 -12
  62. package/backend/dist/packages/gemini-core/src/code_assist/oauth2.js +0 -371
  63. package/backend/dist/packages/gemini-core/src/code_assist/oauth2.js.map +0 -1
  64. package/backend/dist/packages/gemini-core/src/code_assist/server.d.ts +0 -28
  65. package/backend/dist/packages/gemini-core/src/code_assist/server.js +0 -135
  66. package/backend/dist/packages/gemini-core/src/code_assist/server.js.map +0 -1
  67. package/backend/dist/packages/gemini-core/src/code_assist/setup.d.ts +0 -10
  68. package/backend/dist/packages/gemini-core/src/code_assist/setup.js +0 -94
  69. package/backend/dist/packages/gemini-core/src/code_assist/setup.js.map +0 -1
  70. package/backend/dist/packages/gemini-core/src/code_assist/types.d.ts +0 -106
  71. package/backend/dist/packages/gemini-core/src/code_assist/types.js +0 -28
  72. package/backend/dist/packages/gemini-core/src/code_assist/types.js.map +0 -1
  73. package/backend/dist/packages/gemini-core/src/config/config.d.ts +0 -22
  74. package/backend/dist/packages/gemini-core/src/config/config.js +0 -38
  75. package/backend/dist/packages/gemini-core/src/config/config.js.map +0 -1
  76. package/backend/dist/packages/gemini-core/src/config/models.d.ts +0 -6
  77. package/backend/dist/packages/gemini-core/src/config/models.js +0 -13
  78. package/backend/dist/packages/gemini-core/src/config/models.js.map +0 -1
  79. package/backend/dist/packages/gemini-core/src/config/storage.d.ts +0 -8
  80. package/backend/dist/packages/gemini-core/src/config/storage.js +0 -25
  81. package/backend/dist/packages/gemini-core/src/config/storage.js.map +0 -1
  82. package/backend/dist/packages/gemini-core/src/core/contentGenerator.d.ts +0 -23
  83. package/backend/dist/packages/gemini-core/src/core/contentGenerator.js +0 -63
  84. package/backend/dist/packages/gemini-core/src/core/contentGenerator.js.map +0 -1
  85. package/backend/dist/packages/gemini-core/src/core/geminiChat.d.ts +0 -34
  86. package/backend/dist/packages/gemini-core/src/core/geminiChat.js +0 -247
  87. package/backend/dist/packages/gemini-core/src/core/geminiChat.js.map +0 -1
  88. package/backend/dist/packages/gemini-core/src/core/geminiRequest.d.ts +0 -3
  89. package/backend/dist/packages/gemini-core/src/core/geminiRequest.js +0 -8
  90. package/backend/dist/packages/gemini-core/src/core/geminiRequest.js.map +0 -1
  91. package/backend/dist/packages/gemini-core/src/core/prompts.d.ts +0 -7
  92. package/backend/dist/packages/gemini-core/src/core/prompts.js +0 -69
  93. package/backend/dist/packages/gemini-core/src/core/prompts.js.map +0 -1
  94. package/backend/dist/packages/gemini-core/src/core/tokenLimits.d.ts +0 -5
  95. package/backend/dist/packages/gemini-core/src/core/tokenLimits.js +0 -25
  96. package/backend/dist/packages/gemini-core/src/core/tokenLimits.js.map +0 -1
  97. package/backend/dist/packages/gemini-core/src/index.d.ts +0 -18
  98. package/backend/dist/packages/gemini-core/src/index.js +0 -37
  99. package/backend/dist/packages/gemini-core/src/index.js.map +0 -1
  100. package/backend/dist/packages/gemini-core/src/mcp/token-storage/base-token-storage.d.ts +0 -14
  101. package/backend/dist/packages/gemini-core/src/mcp/token-storage/base-token-storage.js +0 -34
  102. package/backend/dist/packages/gemini-core/src/mcp/token-storage/base-token-storage.js.map +0 -1
  103. package/backend/dist/packages/gemini-core/src/mcp/token-storage/file-token-storage.d.ts +0 -19
  104. package/backend/dist/packages/gemini-core/src/mcp/token-storage/file-token-storage.js +0 -141
  105. package/backend/dist/packages/gemini-core/src/mcp/token-storage/file-token-storage.js.map +0 -1
  106. package/backend/dist/packages/gemini-core/src/mcp/token-storage/hybrid-token-storage.d.ts +0 -18
  107. package/backend/dist/packages/gemini-core/src/mcp/token-storage/hybrid-token-storage.js +0 -74
  108. package/backend/dist/packages/gemini-core/src/mcp/token-storage/hybrid-token-storage.js.map +0 -1
  109. package/backend/dist/packages/gemini-core/src/mcp/token-storage/index.d.ts +0 -6
  110. package/backend/dist/packages/gemini-core/src/mcp/token-storage/index.js +0 -24
  111. package/backend/dist/packages/gemini-core/src/mcp/token-storage/index.js.map +0 -1
  112. package/backend/dist/packages/gemini-core/src/mcp/token-storage/keychain-token-storage.d.ts +0 -26
  113. package/backend/dist/packages/gemini-core/src/mcp/token-storage/keychain-token-storage.js +0 -188
  114. package/backend/dist/packages/gemini-core/src/mcp/token-storage/keychain-token-storage.js.map +0 -1
  115. package/backend/dist/packages/gemini-core/src/mcp/token-storage/types.d.ts +0 -27
  116. package/backend/dist/packages/gemini-core/src/mcp/token-storage/types.js +0 -9
  117. package/backend/dist/packages/gemini-core/src/mcp/token-storage/types.js.map +0 -1
  118. package/backend/dist/packages/gemini-core/src/utils/errors.d.ts +0 -34
  119. package/backend/dist/packages/gemini-core/src/utils/errors.js +0 -103
  120. package/backend/dist/packages/gemini-core/src/utils/errors.js.map +0 -1
  121. package/backend/dist/packages/gemini-core/src/utils/partUtils.d.ts +0 -7
  122. package/backend/dist/packages/gemini-core/src/utils/partUtils.js +0 -108
  123. package/backend/dist/packages/gemini-core/src/utils/partUtils.js.map +0 -1
  124. package/backend/dist/packages/gemini-core/src/utils/quotaErrorDetection.d.ts +0 -16
  125. package/backend/dist/packages/gemini-core/src/utils/quotaErrorDetection.js +0 -60
  126. package/backend/dist/packages/gemini-core/src/utils/quotaErrorDetection.js.map +0 -1
  127. package/backend/dist/packages/gemini-core/src/utils/retry.d.ts +0 -14
  128. package/backend/dist/packages/gemini-core/src/utils/retry.js +0 -154
  129. package/backend/dist/packages/gemini-core/src/utils/retry.js.map +0 -1
  130. package/backend/dist/packages/gemini-core/src/utils/session.d.ts +0 -1
  131. package/backend/dist/packages/gemini-core/src/utils/session.js +0 -6
  132. package/backend/dist/packages/gemini-core/src/utils/session.js.map +0 -1
  133. package/backend/dist/packages/gemini-core/src/utils/userAccountManager.d.ts +0 -10
  134. package/backend/dist/packages/gemini-core/src/utils/userAccountManager.js +0 -106
  135. package/backend/dist/packages/gemini-core/src/utils/userAccountManager.js.map +0 -1
  136. package/backend/dist/src/gemini/gemini-llm.provider.d.ts +0 -12
  137. package/backend/dist/src/gemini/gemini-llm.provider.js +0 -126
  138. package/backend/dist/src/gemini/gemini-llm.provider.js.map +0 -1
  139. package/backend/dist/src/gemini/gemini.module.d.ts +0 -2
  140. package/backend/dist/src/gemini/gemini.module.js +0 -21
  141. package/backend/dist/src/gemini/gemini.module.js.map +0 -1
  142. package/backend/packages/gemini-core/CODEMAP.md +0 -30
  143. package/backend/packages/gemini-core/examples/simple.ts +0 -120
  144. package/backend/packages/gemini-core/index.ts +0 -15
  145. package/backend/packages/gemini-core/src/code_assist/codeAssist.ts +0 -37
  146. package/backend/packages/gemini-core/src/code_assist/converter.ts +0 -250
  147. package/backend/packages/gemini-core/src/code_assist/oauth-credential-storage.ts +0 -129
  148. package/backend/packages/gemini-core/src/code_assist/oauth2.ts +0 -541
  149. package/backend/packages/gemini-core/src/code_assist/server.ts +0 -236
  150. package/backend/packages/gemini-core/src/code_assist/setup.ts +0 -124
  151. package/backend/packages/gemini-core/src/code_assist/types.ts +0 -201
  152. package/backend/packages/gemini-core/src/config/config.ts +0 -75
  153. package/backend/packages/gemini-core/src/config/models.ts +0 -23
  154. package/backend/packages/gemini-core/src/config/storage.ts +0 -30
  155. package/backend/packages/gemini-core/src/core/contentGenerator.ts +0 -136
  156. package/backend/packages/gemini-core/src/core/geminiChat.ts +0 -385
  157. package/backend/packages/gemini-core/src/core/geminiRequest.ts +0 -19
  158. package/backend/packages/gemini-core/src/core/prompts.ts +0 -109
  159. package/backend/packages/gemini-core/src/core/tokenLimits.ts +0 -32
  160. package/backend/packages/gemini-core/src/index.ts +0 -35
  161. package/backend/packages/gemini-core/src/mcp/token-storage/base-token-storage.ts +0 -49
  162. package/backend/packages/gemini-core/src/mcp/token-storage/file-token-storage.ts +0 -184
  163. package/backend/packages/gemini-core/src/mcp/token-storage/hybrid-token-storage.ts +0 -97
  164. package/backend/packages/gemini-core/src/mcp/token-storage/index.ts +0 -14
  165. package/backend/packages/gemini-core/src/mcp/token-storage/keychain-token-storage.ts +0 -251
  166. package/backend/packages/gemini-core/src/mcp/token-storage/types.ts +0 -42
  167. package/backend/packages/gemini-core/src/utils/errors.ts +0 -112
  168. package/backend/packages/gemini-core/src/utils/partUtils.ts +0 -169
  169. package/backend/packages/gemini-core/src/utils/quotaErrorDetection.ts +0 -102
  170. package/backend/packages/gemini-core/src/utils/retry.ts +0 -265
  171. package/backend/packages/gemini-core/src/utils/session.ts +0 -9
  172. package/backend/packages/gemini-core/src/utils/userAccountManager.ts +0 -140
@@ -1,236 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import type { OAuth2Client } from 'google-auth-library';
8
- import type {
9
- GoogleRpcResponse,
10
- LoadCodeAssistRequest,
11
- LoadCodeAssistResponse,
12
- LongRunningOperationResponse,
13
- OnboardUserRequest,
14
- } from './types';
15
- import type {
16
- CountTokensParameters,
17
- CountTokensResponse,
18
- EmbedContentParameters,
19
- EmbedContentResponse,
20
- GenerateContentParameters,
21
- GenerateContentResponse,
22
- } from '@google/genai';
23
- import * as readline from 'node:readline';
24
- import type { ContentGenerator } from '../core/contentGenerator';
25
- import { UserTierId } from './types';
26
- import type {
27
- CaCountTokenResponse,
28
- CaGenerateContentResponse,
29
- } from './converter';
30
- import {
31
- fromCountTokenResponse,
32
- fromGenerateContentResponse,
33
- toCountTokenRequest,
34
- toGenerateContentRequest,
35
- } from './converter';
36
-
37
- /** HTTP options to be used in each of the requests. */
38
- export interface HttpOptions {
39
- /** Additional HTTP headers to be sent with the request. */
40
- headers?: Record<string, string>;
41
- }
42
-
43
- export const CODE_ASSIST_ENDPOINT = 'https://cloudcode-pa.googleapis.com';
44
- export const CODE_ASSIST_API_VERSION = 'v1internal';
45
-
46
- export class CodeAssistServer implements ContentGenerator {
47
- constructor(
48
- readonly client: OAuth2Client,
49
- readonly projectId?: string,
50
- readonly httpOptions: HttpOptions = {},
51
- readonly sessionId?: string,
52
- readonly userTier?: UserTierId,
53
- ) {}
54
-
55
- async generateContentStream(
56
- req: GenerateContentParameters,
57
- userPromptId: string,
58
- ): Promise<AsyncGenerator<GenerateContentResponse>> {
59
- const resps = await this.requestStreamingPost<CaGenerateContentResponse>(
60
- 'streamGenerateContent',
61
- toGenerateContentRequest(
62
- req,
63
- userPromptId,
64
- this.projectId,
65
- this.sessionId,
66
- ),
67
- req.config?.abortSignal,
68
- );
69
- return (async function* (): AsyncGenerator<GenerateContentResponse> {
70
- for await (const resp of resps) {
71
- yield fromGenerateContentResponse(resp);
72
- }
73
- })();
74
- }
75
-
76
- async generateContent(
77
- req: GenerateContentParameters,
78
- userPromptId: string,
79
- ): Promise<GenerateContentResponse> {
80
- const resp = await this.requestPost<CaGenerateContentResponse>(
81
- 'generateContent',
82
- toGenerateContentRequest(
83
- req,
84
- userPromptId,
85
- this.projectId,
86
- this.sessionId,
87
- ),
88
- req.config?.abortSignal,
89
- );
90
- return fromGenerateContentResponse(resp);
91
- }
92
-
93
- async onboardUser(
94
- req: OnboardUserRequest,
95
- ): Promise<LongRunningOperationResponse> {
96
- return await this.requestPost<LongRunningOperationResponse>(
97
- 'onboardUser',
98
- req,
99
- );
100
- }
101
-
102
- async loadCodeAssist(
103
- req: LoadCodeAssistRequest,
104
- ): Promise<LoadCodeAssistResponse> {
105
- try {
106
- return await this.requestPost<LoadCodeAssistResponse>(
107
- 'loadCodeAssist',
108
- req,
109
- );
110
- } catch (e) {
111
- if (isVpcScAffectedUser(e)) {
112
- return {
113
- currentTier: { id: UserTierId.STANDARD },
114
- };
115
- } else {
116
- throw e;
117
- }
118
- }
119
- }
120
-
121
- async countTokens(req: CountTokensParameters): Promise<CountTokensResponse> {
122
- const resp = await this.requestPost<CaCountTokenResponse>(
123
- 'countTokens',
124
- toCountTokenRequest(req),
125
- );
126
- return fromCountTokenResponse(resp);
127
- }
128
-
129
- async embedContent(
130
- _req: EmbedContentParameters,
131
- ): Promise<EmbedContentResponse> {
132
- throw Error();
133
- }
134
-
135
- async requestPost<T>(
136
- method: string,
137
- req: object,
138
- signal?: AbortSignal,
139
- ): Promise<T> {
140
- const res = await this.client.request({
141
- url: this.getMethodUrl(method),
142
- method: 'POST',
143
- headers: {
144
- 'Content-Type': 'application/json',
145
- ...this.httpOptions.headers,
146
- },
147
- responseType: 'json',
148
- body: JSON.stringify(req),
149
- signal,
150
- });
151
- return res.data as T;
152
- }
153
-
154
- async requestGet<T>(method: string, signal?: AbortSignal): Promise<T> {
155
- const res = await this.client.request({
156
- url: this.getMethodUrl(method),
157
- method: 'GET',
158
- headers: {
159
- 'Content-Type': 'application/json',
160
- ...this.httpOptions.headers,
161
- },
162
- responseType: 'json',
163
- signal,
164
- });
165
- return res.data as T;
166
- }
167
-
168
- async requestStreamingPost<T>(
169
- method: string,
170
- req: object,
171
- signal?: AbortSignal,
172
- ): Promise<AsyncGenerator<T>> {
173
- const res = await this.client.request({
174
- url: this.getMethodUrl(method),
175
- method: 'POST',
176
- params: {
177
- alt: 'sse',
178
- },
179
- headers: {
180
- 'Content-Type': 'application/json',
181
- ...this.httpOptions.headers,
182
- },
183
- responseType: 'stream',
184
- body: JSON.stringify(req),
185
- signal,
186
- });
187
-
188
- return (async function* (): AsyncGenerator<T> {
189
- const rl = readline.createInterface({
190
- input: res.data as NodeJS.ReadableStream,
191
- crlfDelay: Infinity, // Recognizes '\r\n' and '\n' as line breaks
192
- });
193
-
194
- let bufferedLines: string[] = [];
195
- for await (const line of rl) {
196
- // blank lines are used to separate JSON objects in the stream
197
- if (line === '') {
198
- if (bufferedLines.length === 0) {
199
- continue; // no data to yield
200
- }
201
- yield JSON.parse(bufferedLines.join('\n')) as T;
202
- bufferedLines = []; // Reset the buffer after yielding
203
- } else if (line.startsWith('data: ')) {
204
- bufferedLines.push(line.slice(6).trim());
205
- } else {
206
- throw new Error(`Unexpected line format in response: ${line}`);
207
- }
208
- }
209
- })();
210
- }
211
-
212
- getMethodUrl(method: string): string {
213
- const endpoint =
214
- process.env['CODE_ASSIST_ENDPOINT'] ?? CODE_ASSIST_ENDPOINT;
215
- return `${endpoint}/${CODE_ASSIST_API_VERSION}:${method}`;
216
- }
217
- }
218
-
219
- function isVpcScAffectedUser(error: unknown): boolean {
220
- if (error && typeof error === 'object' && 'response' in error) {
221
- const gaxiosError = error as {
222
- response?: {
223
- data?: unknown;
224
- };
225
- };
226
- const response = gaxiosError.response?.data as
227
- | GoogleRpcResponse
228
- | undefined;
229
- if (Array.isArray(response?.error?.details)) {
230
- return response.error.details.some(
231
- (detail) => detail.reason === 'SECURITY_POLICY_VIOLATED',
232
- );
233
- }
234
- }
235
- return false;
236
- }
@@ -1,124 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import type {
8
- ClientMetadata,
9
- GeminiUserTier,
10
- LoadCodeAssistResponse,
11
- OnboardUserRequest,
12
- } from './types';
13
- import { UserTierId } from './types';
14
- import { CodeAssistServer } from './server';
15
- import type { OAuth2Client } from 'google-auth-library';
16
-
17
- export class ProjectIdRequiredError extends Error {
18
- constructor() {
19
- super(
20
- 'This account requires setting the GOOGLE_CLOUD_PROJECT env var. See https://goo.gle/gemini-cli-auth-docs#workspace-gca',
21
- );
22
- }
23
- }
24
-
25
- export interface UserData {
26
- projectId: string;
27
- userTier: UserTierId;
28
- }
29
-
30
- /**
31
- *
32
- * @param projectId the user's project id, if any
33
- * @returns the user's actual project id
34
- */
35
- export async function setupUser(client: OAuth2Client): Promise<UserData> {
36
- const projectId = process.env['GOOGLE_CLOUD_PROJECT'] || undefined;
37
- const caServer = new CodeAssistServer(client, projectId, {}, '', undefined);
38
- const coreClientMetadata: ClientMetadata = {
39
- ideType: 'IDE_UNSPECIFIED',
40
- platform: 'PLATFORM_UNSPECIFIED',
41
- pluginType: 'GEMINI',
42
- };
43
-
44
- const loadRes = await caServer.loadCodeAssist({
45
- cloudaicompanionProject: projectId,
46
- metadata: {
47
- ...coreClientMetadata,
48
- duetProject: projectId,
49
- },
50
- });
51
-
52
- if (loadRes.currentTier) {
53
- if (!loadRes.cloudaicompanionProject) {
54
- if (projectId) {
55
- return {
56
- projectId,
57
- userTier: loadRes.currentTier.id,
58
- };
59
- }
60
- throw new ProjectIdRequiredError();
61
- }
62
- return {
63
- projectId: loadRes.cloudaicompanionProject,
64
- userTier: loadRes.currentTier.id,
65
- };
66
- }
67
-
68
- const tier = getOnboardTier(loadRes);
69
-
70
- let onboardReq: OnboardUserRequest;
71
- if (tier.id === UserTierId.FREE) {
72
- // The free tier uses a managed google cloud project. Setting a project in the `onboardUser` request causes a `Precondition Failed` error.
73
- onboardReq = {
74
- tierId: tier.id,
75
- cloudaicompanionProject: undefined,
76
- metadata: coreClientMetadata,
77
- };
78
- } else {
79
- onboardReq = {
80
- tierId: tier.id,
81
- cloudaicompanionProject: projectId,
82
- metadata: {
83
- ...coreClientMetadata,
84
- duetProject: projectId,
85
- },
86
- };
87
- }
88
-
89
- // Poll onboardUser until long running operation is complete.
90
- let lroRes = await caServer.onboardUser(onboardReq);
91
- while (!lroRes.done) {
92
- await new Promise((f) => setTimeout(f, 5000));
93
- lroRes = await caServer.onboardUser(onboardReq);
94
- }
95
-
96
- if (!lroRes.response?.cloudaicompanionProject?.id) {
97
- if (projectId) {
98
- return {
99
- projectId,
100
- userTier: tier.id,
101
- };
102
- }
103
- throw new ProjectIdRequiredError();
104
- }
105
-
106
- return {
107
- projectId: lroRes.response.cloudaicompanionProject.id,
108
- userTier: tier.id,
109
- };
110
- }
111
-
112
- function getOnboardTier(res: LoadCodeAssistResponse): GeminiUserTier {
113
- for (const tier of res.allowedTiers || []) {
114
- if (tier.isDefault) {
115
- return tier;
116
- }
117
- }
118
- return {
119
- name: '',
120
- description: '',
121
- id: UserTierId.LEGACY,
122
- userDefinedCloudaicompanionProject: true,
123
- };
124
- }
@@ -1,201 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- export interface ClientMetadata {
8
- ideType?: ClientMetadataIdeType;
9
- ideVersion?: string;
10
- pluginVersion?: string;
11
- platform?: ClientMetadataPlatform;
12
- updateChannel?: string;
13
- duetProject?: string;
14
- pluginType?: ClientMetadataPluginType;
15
- ideName?: string;
16
- }
17
-
18
- export type ClientMetadataIdeType =
19
- | 'IDE_UNSPECIFIED'
20
- | 'VSCODE'
21
- | 'INTELLIJ'
22
- | 'VSCODE_CLOUD_WORKSTATION'
23
- | 'INTELLIJ_CLOUD_WORKSTATION'
24
- | 'CLOUD_SHELL';
25
- export type ClientMetadataPlatform =
26
- | 'PLATFORM_UNSPECIFIED'
27
- | 'DARWIN_AMD64'
28
- | 'DARWIN_ARM64'
29
- | 'LINUX_AMD64'
30
- | 'LINUX_ARM64'
31
- | 'WINDOWS_AMD64';
32
- export type ClientMetadataPluginType =
33
- | 'PLUGIN_UNSPECIFIED'
34
- | 'CLOUD_CODE'
35
- | 'GEMINI'
36
- | 'AIPLUGIN_INTELLIJ'
37
- | 'AIPLUGIN_STUDIO';
38
-
39
- export interface LoadCodeAssistRequest {
40
- cloudaicompanionProject?: string;
41
- metadata: ClientMetadata;
42
- }
43
-
44
- /**
45
- * Represents LoadCodeAssistResponse proto json field
46
- * http://google3/google/internal/cloud/code/v1internal/cloudcode.proto;l=224
47
- */
48
- export interface LoadCodeAssistResponse {
49
- currentTier?: GeminiUserTier | null;
50
- allowedTiers?: GeminiUserTier[] | null;
51
- ineligibleTiers?: IneligibleTier[] | null;
52
- cloudaicompanionProject?: string | null;
53
- }
54
-
55
- /**
56
- * GeminiUserTier reflects the structure received from the CodeAssist when calling LoadCodeAssist.
57
- */
58
- export interface GeminiUserTier {
59
- id: UserTierId;
60
- name?: string;
61
- description?: string;
62
- // This value is used to declare whether a given tier requires the user to configure the project setting on the IDE settings or not.
63
- userDefinedCloudaicompanionProject?: boolean | null;
64
- isDefault?: boolean;
65
- privacyNotice?: PrivacyNotice;
66
- hasAcceptedTos?: boolean;
67
- hasOnboardedPreviously?: boolean;
68
- }
69
-
70
- /**
71
- * Includes information specifying the reasons for a user's ineligibility for a specific tier.
72
- * @param reasonCode mnemonic code representing the reason for in-eligibility.
73
- * @param reasonMessage message to display to the user.
74
- * @param tierId id of the tier.
75
- * @param tierName name of the tier.
76
- */
77
- export interface IneligibleTier {
78
- reasonCode: IneligibleTierReasonCode;
79
- reasonMessage: string;
80
- tierId: UserTierId;
81
- tierName: string;
82
- }
83
-
84
- /**
85
- * List of predefined reason codes when a tier is blocked from a specific tier.
86
- * https://source.corp.google.com/piper///depot/google3/google/internal/cloud/code/v1internal/cloudcode.proto;l=378
87
- */
88
- export enum IneligibleTierReasonCode {
89
- // go/keep-sorted start
90
- DASHER_USER = 'DASHER_USER',
91
- INELIGIBLE_ACCOUNT = 'INELIGIBLE_ACCOUNT',
92
- NON_USER_ACCOUNT = 'NON_USER_ACCOUNT',
93
- RESTRICTED_AGE = 'RESTRICTED_AGE',
94
- RESTRICTED_NETWORK = 'RESTRICTED_NETWORK',
95
- UNKNOWN = 'UNKNOWN',
96
- UNKNOWN_LOCATION = 'UNKNOWN_LOCATION',
97
- UNSUPPORTED_LOCATION = 'UNSUPPORTED_LOCATION',
98
- // go/keep-sorted end
99
- }
100
- /**
101
- * UserTierId represents IDs returned from the Cloud Code Private API representing a user's tier
102
- *
103
- * //depot/google3/cloud/developer_experience/cloudcode/pa/service/usertier.go;l=16
104
- */
105
- export enum UserTierId {
106
- FREE = 'free-tier',
107
- LEGACY = 'legacy-tier',
108
- STANDARD = 'standard-tier',
109
- }
110
-
111
- /**
112
- * PrivacyNotice reflects the structure received from the CodeAssist in regards to a tier
113
- * privacy notice.
114
- */
115
- export interface PrivacyNotice {
116
- showNotice: boolean;
117
- noticeText?: string;
118
- }
119
-
120
- /**
121
- * Proto signature of OnboardUserRequest as payload to OnboardUser call
122
- */
123
- export interface OnboardUserRequest {
124
- tierId: string | undefined;
125
- cloudaicompanionProject: string | undefined;
126
- metadata: ClientMetadata | undefined;
127
- }
128
-
129
- /**
130
- * Represents LongRunningOperation proto
131
- * http://google3/google/longrunning/operations.proto;rcl=698857719;l=107
132
- */
133
- export interface LongRunningOperationResponse {
134
- name: string;
135
- done?: boolean;
136
- response?: OnboardUserResponse;
137
- }
138
-
139
- /**
140
- * Represents OnboardUserResponse proto
141
- * http://google3/google/internal/cloud/code/v1internal/cloudcode.proto;l=215
142
- */
143
- export interface OnboardUserResponse {
144
- // tslint:disable-next-line:enforce-name-casing This is the name of the field in the proto.
145
- cloudaicompanionProject?: {
146
- id: string;
147
- name: string;
148
- };
149
- }
150
-
151
- /**
152
- * Status code of user license status
153
- * it does not strictly correspond to the proto
154
- * Error value is an additional value assigned to error responses from OnboardUser
155
- */
156
- export enum OnboardUserStatusCode {
157
- Default = 'DEFAULT',
158
- Notice = 'NOTICE',
159
- Warning = 'WARNING',
160
- Error = 'ERROR',
161
- }
162
-
163
- /**
164
- * Status of user onboarded to gemini
165
- */
166
- export interface OnboardUserStatus {
167
- statusCode: OnboardUserStatusCode;
168
- displayMessage: string;
169
- helpLink: HelpLinkUrl | undefined;
170
- }
171
-
172
- export interface HelpLinkUrl {
173
- description: string;
174
- url: string;
175
- }
176
-
177
- export interface SetCodeAssistGlobalUserSettingRequest {
178
- cloudaicompanionProject?: string;
179
- freeTierDataCollectionOptin: boolean;
180
- }
181
-
182
- export interface CodeAssistGlobalUserSettingResponse {
183
- cloudaicompanionProject?: string;
184
- freeTierDataCollectionOptin: boolean;
185
- }
186
-
187
- /**
188
- * Relevant fields that can be returned from a Google RPC response
189
- */
190
- export interface GoogleRpcResponse {
191
- error?: {
192
- details?: GoogleRpcErrorInfo[];
193
- };
194
- }
195
-
196
- /**
197
- * Relevant fields that can be returned in the details of an error returned from GoogleRPCs
198
- */
199
- interface GoogleRpcErrorInfo {
200
- reason?: string;
201
- }
@@ -1,75 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import process from 'node:process';
8
- import type {
9
- ContentGenerator,
10
- ContentGeneratorConfig,
11
- } from '../core/contentGenerator';
12
- import {
13
- AuthType,
14
- createContentGenerator,
15
- createContentGeneratorConfig,
16
- } from '../core/contentGenerator';
17
- import { DEFAULT_GEMINI_FLASH_MODEL } from './models';
18
-
19
- export interface ConfigParameters {
20
- sessionId: string;
21
- model: string;
22
- }
23
-
24
- export class Config {
25
- private contentGeneratorConfig!: ContentGeneratorConfig;
26
- private contentGenerator!: ContentGenerator;
27
- private readonly sessionId: string;
28
- private model: string;
29
-
30
- constructor(params: ConfigParameters) {
31
- this.sessionId = params.sessionId;
32
- this.model = params.model;
33
- }
34
-
35
- getContentGenerator(): ContentGenerator {
36
- return this.contentGenerator;
37
- }
38
-
39
- async refreshAuth(authMethod: AuthType) {
40
- const newContentGeneratorConfig = createContentGeneratorConfig(
41
- this,
42
- authMethod,
43
- );
44
- this.contentGenerator = await createContentGenerator(
45
- newContentGeneratorConfig,
46
- this,
47
- this.getSessionId(),
48
- );
49
- // Only assign to instance properties after successful initialization
50
- this.contentGeneratorConfig = newContentGeneratorConfig;
51
- }
52
-
53
- getSessionId(): string {
54
- return this.sessionId;
55
- }
56
-
57
- getModel(): string {
58
- return this.model;
59
- }
60
-
61
- setModel(newModel: string): void {
62
- this.model = newModel;
63
- }
64
-
65
- // Used by code_assist/oauth2.ts
66
- isBrowserLaunchSuppressed(): boolean {
67
- return process.env['NO_BROWSER'] === 'true';
68
- }
69
-
70
- getContentGeneratorConfig(): ContentGeneratorConfig {
71
- return this.contentGeneratorConfig;
72
- }
73
- }
74
- // Export model constants for use in CLI
75
- export { DEFAULT_GEMINI_FLASH_MODEL };
@@ -1,23 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- export const DEFAULT_GEMINI_MODEL = 'gemini-2.5-pro';
8
- export const DEFAULT_GEMINI_FLASH_MODEL = 'gemini-2.5-flash';
9
- export const DEFAULT_GEMINI_FLASH_LITE_MODEL = 'gemini-2.5-flash-lite';
10
-
11
- export const DEFAULT_GEMINI_MODEL_AUTO = 'auto';
12
-
13
- export const DEFAULT_GEMINI_EMBEDDING_MODEL = 'gemini-embedding-001';
14
-
15
- /**
16
- * Determines the effective model to use.
17
- *
18
- * @param requestedModel The model that was originally requested.
19
- * @returns The effective model name.
20
- */
21
- export function getEffectiveModel(requestedModel: string): string {
22
- return requestedModel;
23
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import * as path from 'node:path';
8
- import * as os from 'node:os';
9
-
10
- export const GEMINI_DIR = '.gemini';
11
- export const GOOGLE_ACCOUNTS_FILENAME = 'google_accounts.json';
12
- export const OAUTH_FILE = 'oauth_creds.json';
13
-
14
- export class Storage {
15
- static getGlobalGeminiDir(): string {
16
- const homeDir = os.homedir();
17
- if (!homeDir) {
18
- return path.join(os.tmpdir(), '.gemini');
19
- }
20
- return path.join(homeDir, GEMINI_DIR);
21
- }
22
-
23
- static getGoogleAccountsPath(): string {
24
- return path.join(Storage.getGlobalGeminiDir(), GOOGLE_ACCOUNTS_FILENAME);
25
- }
26
-
27
- static getOAuthCredsPath(): string {
28
- return path.join(Storage.getGlobalGeminiDir(), OAUTH_FILE);
29
- }
30
- }