@gitlab/gitlab-ai-provider 1.0.5 → 3.0.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,54 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
4
4
 
5
+ ## <small>3.0.7 (2025-12-19)</small>
6
+
7
+ - fix: convert relative links to absolute GitLab URLs in README ([accde31](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/accde31))
8
+
9
+ ## <small>3.0.6 (2025-12-19)</small>
10
+
11
+ - fix: use NPM_ID_TOKEN with correct audience for OIDC ([03fb549](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/03fb549))
12
+
13
+ ## <small>3.0.5 (2025-12-19)</small>
14
+
15
+ - fix: use NPM_TOKEN for authentication (OIDC not supported for GitLab) ([4d595cf](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/4d595cf))
16
+
17
+ ## <small>3.0.4 (2025-12-19)</small>
18
+
19
+ - refactor: use artifacts for version propagation ([03d4935](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/03d4935))
20
+ - fix: use OIDC for npmjs.org and sync version ([e5ff429](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e5ff429))
21
+
22
+ ## <small>3.0.3 (2025-12-19)</small>
23
+
24
+ - fix: update package-lock.json with MIT license ([d724d20](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/d724d20))
25
+ - fix: use NPM_TOKEN for npmjs.org authentication ([e96d9de](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e96d9de))
26
+
27
+ ## <small>3.0.2 (2025-12-19)</small>
28
+
29
+ - fix: correct license to MIT in package.json ([6df4154](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/6df4154))
30
+
31
+ ## <small>3.0.1 (2025-12-19)</small>
32
+
33
+ - fix: use SIGSTORE_ID_TOKEN for npm provenance ([e5c8c7f](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e5c8c7f))
34
+
35
+ ## 3.0.0 (2025-12-19)
36
+
37
+ - feat: automate publishing workflow ([f8c384d](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/f8c384d))
38
+
39
+ ### BREAKING CHANGE
40
+
41
+ - Publishing now happens automatically on every main branch commit
42
+
43
+ ## 2.0.0 (2025-12-18)
44
+
45
+ - fix: bump the version ([02df4b2](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/02df4b2))
46
+ - fix: remove GitLab registry config and add test dependencies ([81cc14e](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/81cc14e))
47
+ - feat: configure publishing to npmjs.org with OIDC ([bb62d90](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/bb62d90))
48
+
49
+ ### BREAKING CHANGE
50
+
51
+ - Package now only published to npmjs.org as @gitlab/gitlab-ai-provider
52
+
5
53
  ## <small>1.0.5 (2025-12-18)</small>
6
54
 
7
55
  - Merge branch 'main' of gitlab.com:gitlab-org/editor-extensions/gitlab-ai-provider ([f93aa47](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/f93aa47))
package/README.md CHANGED
@@ -380,7 +380,7 @@ gitlab-ai-provider/
380
380
 
381
381
  ## 🤝 Contributing
382
382
 
383
- Contributions are welcome! Please see our [Contributing Guide](./CONTRIBUTING.md) for detailed guidelines on:
383
+ Contributions are welcome! Please see our [Contributing Guide](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/-/blob/main/CONTRIBUTING.md) for detailed guidelines on:
384
384
 
385
385
  - Code style and conventions
386
386
  - Development workflow
@@ -413,9 +413,9 @@ Contributions are welcome! Please see our [Contributing Guide](./CONTRIBUTING.md
413
413
  - [GitLab Repository](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider)
414
414
  - [npm Package](https://www.npmjs.com/package/@gitlab/gitlab-ai-provider)
415
415
  - [Issue Tracker](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/-/issues)
416
- - [Contributing Guide](./CONTRIBUTING.md)
417
- - [Changelog](./CHANGELOG.md)
418
- - [Agent Guidelines](./AGENTS.md)
416
+ - [Contributing Guide](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/-/blob/main/CONTRIBUTING.md)
417
+ - [Changelog](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/-/blob/main/CHANGELOG.md)
418
+ - [Agent Guidelines](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/-/blob/main/AGENTS.md)
419
419
 
420
420
  ## 🙏 Acknowledgments
421
421
 
package/dist/index.d.ts CHANGED
@@ -1,42 +1,34 @@
1
- import {
2
- LanguageModelV2,
3
- LanguageModelV2CallOptions,
4
- LanguageModelV2Content,
5
- LanguageModelV2FinishReason,
6
- LanguageModelV2Usage,
7
- LanguageModelV2CallWarning,
8
- LanguageModelV2StreamPart,
9
- } from '@ai-sdk/provider';
1
+ import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2StreamPart } from '@ai-sdk/provider';
10
2
  import { z } from 'zod';
11
3
  import { Tool } from '@anthropic-ai/sdk/resources/messages';
12
4
 
13
5
  interface GitLabAgenticConfig {
14
- provider: string;
15
- instanceUrl: string;
16
- getHeaders: () => Record<string, string>;
17
- fetch?: typeof fetch;
18
- /**
19
- * Optional callback to refresh the API key when a 401 error occurs.
20
- * Should clear cached credentials and re-fetch from auth provider.
21
- */
22
- refreshApiKey?: () => Promise<void>;
23
- /**
24
- * The Anthropic model to use (e.g., 'claude-sonnet-4-5-20250929')
25
- * @default 'claude-sonnet-4-5-20250929'
26
- */
27
- anthropicModel?: string;
28
- /**
29
- * Maximum tokens to generate
30
- * @default 8192
31
- */
32
- maxTokens?: number;
33
- /**
34
- * Feature flags to pass to the GitLab API
35
- * @default { DuoAgentPlatformNext: true }
36
- */
37
- featureFlags?: {
38
- DuoAgentPlatformNext: true;
39
- } & Record<string, boolean>;
6
+ provider: string;
7
+ instanceUrl: string;
8
+ getHeaders: () => Record<string, string>;
9
+ fetch?: typeof fetch;
10
+ /**
11
+ * Optional callback to refresh the API key when a 401 error occurs.
12
+ * Should clear cached credentials and re-fetch from auth provider.
13
+ */
14
+ refreshApiKey?: () => Promise<void>;
15
+ /**
16
+ * The Anthropic model to use (e.g., 'claude-sonnet-4-5-20250929')
17
+ * @default 'claude-sonnet-4-5-20250929'
18
+ */
19
+ anthropicModel?: string;
20
+ /**
21
+ * Maximum tokens to generate
22
+ * @default 8192
23
+ */
24
+ maxTokens?: number;
25
+ /**
26
+ * Feature flags to pass to the GitLab API
27
+ * @default { DuoAgentPlatformNext: true }
28
+ */
29
+ featureFlags?: {
30
+ DuoAgentPlatformNext: true;
31
+ } & Record<string, boolean>;
40
32
  }
41
33
  /**
42
34
  * GitLab Agentic Language Model
@@ -46,122 +38,122 @@ interface GitLabAgenticConfig {
46
38
  * at https://cloud.gitlab.com/ai/v1/proxy/anthropic/
47
39
  */
48
40
  declare class GitLabAgenticLanguageModel implements LanguageModelV2 {
49
- readonly specificationVersion: 'v2';
50
- readonly modelId: string;
51
- readonly supportedUrls: Record<string, RegExp[]>;
52
- private readonly config;
53
- private readonly directAccessClient;
54
- private anthropicClient;
55
- constructor(modelId: string, config: GitLabAgenticConfig);
56
- get provider(): string;
57
- /**
58
- * Get or create an Anthropic client with valid credentials
59
- * @param forceRefresh - If true, forces a token refresh before creating the client
60
- */
61
- private getAnthropicClient;
62
- /**
63
- * Check if an error is a token-related authentication error that can be retried
64
- */
65
- private isTokenError;
66
- /**
67
- * Convert AI SDK tools to Anthropic tool format
68
- */
69
- private convertTools;
70
- /**
71
- * Convert AI SDK tool choice to Anthropic format
72
- */
73
- private convertToolChoice;
74
- /**
75
- * Convert AI SDK prompt to Anthropic messages format
76
- */
77
- private convertPrompt;
78
- /**
79
- * Convert Anthropic finish reason to AI SDK format
80
- */
81
- private convertFinishReason;
82
- doGenerate(options: LanguageModelV2CallOptions): Promise<{
83
- content: LanguageModelV2Content[];
84
- finishReason: LanguageModelV2FinishReason;
85
- usage: LanguageModelV2Usage;
86
- warnings: LanguageModelV2CallWarning[];
87
- }>;
88
- private doGenerateWithRetry;
89
- doStream(options: LanguageModelV2CallOptions): Promise<{
90
- stream: ReadableStream<LanguageModelV2StreamPart>;
91
- request?: {
92
- body?: unknown;
93
- };
94
- response?: {
95
- headers?: Record<string, string>;
96
- };
97
- }>;
98
- private doStreamWithRetry;
41
+ readonly specificationVersion: "v2";
42
+ readonly modelId: string;
43
+ readonly supportedUrls: Record<string, RegExp[]>;
44
+ private readonly config;
45
+ private readonly directAccessClient;
46
+ private anthropicClient;
47
+ constructor(modelId: string, config: GitLabAgenticConfig);
48
+ get provider(): string;
49
+ /**
50
+ * Get or create an Anthropic client with valid credentials
51
+ * @param forceRefresh - If true, forces a token refresh before creating the client
52
+ */
53
+ private getAnthropicClient;
54
+ /**
55
+ * Check if an error is a token-related authentication error that can be retried
56
+ */
57
+ private isTokenError;
58
+ /**
59
+ * Convert AI SDK tools to Anthropic tool format
60
+ */
61
+ private convertTools;
62
+ /**
63
+ * Convert AI SDK tool choice to Anthropic format
64
+ */
65
+ private convertToolChoice;
66
+ /**
67
+ * Convert AI SDK prompt to Anthropic messages format
68
+ */
69
+ private convertPrompt;
70
+ /**
71
+ * Convert Anthropic finish reason to AI SDK format
72
+ */
73
+ private convertFinishReason;
74
+ doGenerate(options: LanguageModelV2CallOptions): Promise<{
75
+ content: LanguageModelV2Content[];
76
+ finishReason: LanguageModelV2FinishReason;
77
+ usage: LanguageModelV2Usage;
78
+ warnings: LanguageModelV2CallWarning[];
79
+ }>;
80
+ private doGenerateWithRetry;
81
+ doStream(options: LanguageModelV2CallOptions): Promise<{
82
+ stream: ReadableStream<LanguageModelV2StreamPart>;
83
+ request?: {
84
+ body?: unknown;
85
+ };
86
+ response?: {
87
+ headers?: Record<string, string>;
88
+ };
89
+ }>;
90
+ private doStreamWithRetry;
99
91
  }
100
92
 
101
93
  interface GitLabProvider {
102
- (modelId: string): LanguageModelV2;
103
- readonly specificationVersion: 'v2';
104
- languageModel(modelId: string): LanguageModelV2;
105
- chat(modelId: string): LanguageModelV2;
106
- agenticChat(modelId: string, options?: GitLabAgenticOptions): GitLabAgenticLanguageModel;
107
- textEmbeddingModel(modelId: string): never;
108
- imageModel(modelId: string): never;
94
+ (modelId: string): LanguageModelV2;
95
+ readonly specificationVersion: 'v2';
96
+ languageModel(modelId: string): LanguageModelV2;
97
+ chat(modelId: string): LanguageModelV2;
98
+ agenticChat(modelId: string, options?: GitLabAgenticOptions): GitLabAgenticLanguageModel;
99
+ textEmbeddingModel(modelId: string): never;
100
+ imageModel(modelId: string): never;
109
101
  }
110
102
  interface GitLabAgenticOptions {
111
- /**
112
- * The Anthropic model to use
113
- * @default 'claude-sonnet-4-20250514'
114
- */
115
- anthropicModel?: string;
116
- /**
117
- * Maximum tokens to generate
118
- * @default 8192
119
- */
120
- maxTokens?: number;
121
- /**
122
- * Feature flags to pass to the GitLab API
123
- */
124
- featureFlags?: Record<string, boolean>;
103
+ /**
104
+ * The Anthropic model to use
105
+ * @default 'claude-sonnet-4-20250514'
106
+ */
107
+ anthropicModel?: string;
108
+ /**
109
+ * Maximum tokens to generate
110
+ * @default 8192
111
+ */
112
+ maxTokens?: number;
113
+ /**
114
+ * Feature flags to pass to the GitLab API
115
+ */
116
+ featureFlags?: Record<string, boolean>;
125
117
  }
126
118
  interface GitLabProviderSettings {
127
- /**
128
- * GitLab instance URL (e.g., 'https://gitlab.com')
129
- * @default 'https://gitlab.com'
130
- */
131
- instanceUrl?: string;
132
- /**
133
- * API token (Personal Access Token or OAuth access token)
134
- * Can also be set via GITLAB_TOKEN environment variable
135
- */
136
- apiKey?: string;
137
- /**
138
- * OAuth refresh token (optional, for OAuth flow)
139
- */
140
- refreshToken?: string;
141
- /**
142
- * OAuth client ID (required for OAuth flow)
143
- */
144
- clientId?: string;
145
- /**
146
- * OAuth redirect URI (required for OAuth flow)
147
- */
148
- redirectUri?: string;
149
- /**
150
- * Custom headers to include in requests
151
- */
152
- headers?: Record<string, string>;
153
- /**
154
- * Custom fetch implementation
155
- */
156
- fetch?: typeof fetch;
157
- /**
158
- * Provider name override
159
- */
160
- name?: string;
161
- /**
162
- * Default feature flags to pass to the GitLab API for all agentic chat models
163
- */
164
- featureFlags?: Record<string, boolean>;
119
+ /**
120
+ * GitLab instance URL (e.g., 'https://gitlab.com')
121
+ * @default 'https://gitlab.com'
122
+ */
123
+ instanceUrl?: string;
124
+ /**
125
+ * API token (Personal Access Token or OAuth access token)
126
+ * Can also be set via GITLAB_TOKEN environment variable
127
+ */
128
+ apiKey?: string;
129
+ /**
130
+ * OAuth refresh token (optional, for OAuth flow)
131
+ */
132
+ refreshToken?: string;
133
+ /**
134
+ * OAuth client ID (required for OAuth flow)
135
+ */
136
+ clientId?: string;
137
+ /**
138
+ * OAuth redirect URI (required for OAuth flow)
139
+ */
140
+ redirectUri?: string;
141
+ /**
142
+ * Custom headers to include in requests
143
+ */
144
+ headers?: Record<string, string>;
145
+ /**
146
+ * Custom fetch implementation
147
+ */
148
+ fetch?: typeof fetch;
149
+ /**
150
+ * Provider name override
151
+ */
152
+ name?: string;
153
+ /**
154
+ * Default feature flags to pass to the GitLab API for all agentic chat models
155
+ */
156
+ featureFlags?: Record<string, boolean>;
165
157
  }
166
158
  declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
167
159
  /**
@@ -177,45 +169,39 @@ declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
177
169
  declare const gitlab: GitLabProvider;
178
170
 
179
171
  interface GitLabErrorOptions {
180
- message: string;
181
- statusCode?: number;
182
- responseBody?: string;
183
- cause?: unknown;
172
+ message: string;
173
+ statusCode?: number;
174
+ responseBody?: string;
175
+ cause?: unknown;
184
176
  }
185
177
  declare class GitLabError extends Error {
186
- readonly statusCode?: number;
187
- readonly responseBody?: string;
188
- readonly cause?: unknown;
189
- constructor(options: GitLabErrorOptions);
190
- static fromResponse(response: Response, body: string): GitLabError;
191
- isAuthError(): boolean;
192
- isRateLimitError(): boolean;
193
- isForbiddenError(): boolean;
194
- isServerError(): boolean;
178
+ readonly statusCode?: number;
179
+ readonly responseBody?: string;
180
+ readonly cause?: unknown;
181
+ constructor(options: GitLabErrorOptions);
182
+ static fromResponse(response: Response, body: string): GitLabError;
183
+ isAuthError(): boolean;
184
+ isRateLimitError(): boolean;
185
+ isForbiddenError(): boolean;
186
+ isServerError(): boolean;
195
187
  }
196
188
 
197
- declare const gitlabOAuthTokenResponseSchema: z.ZodObject<
198
- {
189
+ declare const gitlabOAuthTokenResponseSchema: z.ZodObject<{
199
190
  access_token: z.ZodString;
200
191
  refresh_token: z.ZodOptional<z.ZodString>;
201
192
  expires_in: z.ZodNumber;
202
193
  created_at: z.ZodNumber;
203
- },
204
- 'strip',
205
- z.ZodTypeAny,
206
- {
194
+ }, "strip", z.ZodTypeAny, {
207
195
  access_token?: string;
208
196
  refresh_token?: string;
209
197
  expires_in?: number;
210
198
  created_at?: number;
211
- },
212
- {
199
+ }, {
213
200
  access_token?: string;
214
201
  refresh_token?: string;
215
202
  expires_in?: number;
216
203
  created_at?: number;
217
- }
218
- >;
204
+ }>;
219
205
  type GitLabOAuthTokenResponse = z.infer<typeof gitlabOAuthTokenResponseSchema>;
220
206
 
221
207
  /**
@@ -223,33 +209,32 @@ type GitLabOAuthTokenResponse = z.infer<typeof gitlabOAuthTokenResponseSchema>;
223
209
  * Based on gitlab-vscode-extension and gitlab-lsp patterns
224
210
  */
225
211
  interface GitLabOAuthTokens {
226
- accessToken: string;
227
- refreshToken: string;
228
- expiresAt: number;
229
- instanceUrl: string;
212
+ accessToken: string;
213
+ refreshToken: string;
214
+ expiresAt: number;
215
+ instanceUrl: string;
230
216
  }
231
217
  interface OpenCodeAuthOAuth {
232
- type: 'oauth';
233
- refresh: string;
234
- access: string;
235
- expires: number;
236
- instanceUrl?: string;
218
+ type: 'oauth';
219
+ refresh: string;
220
+ access: string;
221
+ expires: number;
222
+ instanceUrl?: string;
237
223
  }
238
224
  interface OpenCodeAuthApi {
239
- type: 'api';
240
- key: string;
225
+ type: 'api';
226
+ key: string;
241
227
  }
242
228
  type OpenCodeAuth = OpenCodeAuthOAuth | OpenCodeAuthApi;
243
229
  /**
244
230
  * Bundled OAuth client ID for GitLab.com
245
231
  * Same as used in gitlab-vscode-extension
246
232
  */
247
- declare const BUNDLED_CLIENT_ID =
248
- '36f2a70cddeb5a0889d4fd8295c241b7e9848e89cf9e599d0eed2d8e5350fbf5';
233
+ declare const BUNDLED_CLIENT_ID = "36f2a70cddeb5a0889d4fd8295c241b7e9848e89cf9e599d0eed2d8e5350fbf5";
249
234
  /**
250
235
  * GitLab.com URL constant
251
236
  */
252
- declare const GITLAB_COM_URL = 'https://gitlab.com';
237
+ declare const GITLAB_COM_URL = "https://gitlab.com";
253
238
  /**
254
239
  * Token expiry skew in milliseconds (5 minutes)
255
240
  * Refresh tokens this many milliseconds before they expire
@@ -267,61 +252,61 @@ declare const OAUTH_SCOPES: string[];
267
252
  */
268
253
 
269
254
  interface TokenExchangeParams {
270
- instanceUrl: string;
271
- clientId?: string;
272
- redirectUri?: string;
255
+ instanceUrl: string;
256
+ clientId?: string;
257
+ redirectUri?: string;
273
258
  }
274
259
  interface AuthorizationCodeParams extends TokenExchangeParams {
275
- code: string;
276
- codeVerifier: string;
260
+ code: string;
261
+ codeVerifier: string;
277
262
  }
278
263
  interface RefreshTokenParams extends TokenExchangeParams {
279
- refreshToken: string;
264
+ refreshToken: string;
280
265
  }
281
266
  declare class GitLabOAuthManager {
282
- private fetch;
283
- constructor(fetchImpl?: typeof fetch);
284
- /**
285
- * Check if a token is expired
286
- */
287
- isTokenExpired(expiresAt: number): boolean;
288
- /**
289
- * Check if a token needs refresh (within skew window)
290
- */
291
- needsRefresh(expiresAt: number): boolean;
292
- /**
293
- * Refresh tokens if needed
294
- * Returns the same tokens if refresh is not needed, or new tokens if refreshed
295
- */
296
- refreshIfNeeded(tokens: GitLabOAuthTokens, clientId?: string): Promise<GitLabOAuthTokens>;
297
- /**
298
- * Exchange authorization code for tokens
299
- * Based on gitlab-vscode-extension createOAuthAccountFromCode
300
- */
301
- exchangeAuthorizationCode(params: AuthorizationCodeParams): Promise<GitLabOAuthTokens>;
302
- /**
303
- * Exchange refresh token for new tokens
304
- * Based on gitlab-vscode-extension TokenExchangeService
305
- */
306
- exchangeRefreshToken(params: RefreshTokenParams): Promise<GitLabOAuthTokens>;
307
- /**
308
- * Get the OAuth client ID for an instance
309
- */
310
- private getClientId;
311
- /**
312
- * Exchange token with GitLab OAuth endpoint
313
- * Based on gitlab-vscode-extension GitLabService.exchangeToken
314
- */
315
- private exchangeToken;
316
- /**
317
- * Create GitLabOAuthTokens from token response
318
- */
319
- private createTokensFromResponse;
320
- /**
321
- * Create expiry timestamp from token response
322
- * Based on gitlab-vscode-extension createExpiresTimestamp
323
- */
324
- private createExpiresTimestamp;
267
+ private fetch;
268
+ constructor(fetchImpl?: typeof fetch);
269
+ /**
270
+ * Check if a token is expired
271
+ */
272
+ isTokenExpired(expiresAt: number): boolean;
273
+ /**
274
+ * Check if a token needs refresh (within skew window)
275
+ */
276
+ needsRefresh(expiresAt: number): boolean;
277
+ /**
278
+ * Refresh tokens if needed
279
+ * Returns the same tokens if refresh is not needed, or new tokens if refreshed
280
+ */
281
+ refreshIfNeeded(tokens: GitLabOAuthTokens, clientId?: string): Promise<GitLabOAuthTokens>;
282
+ /**
283
+ * Exchange authorization code for tokens
284
+ * Based on gitlab-vscode-extension createOAuthAccountFromCode
285
+ */
286
+ exchangeAuthorizationCode(params: AuthorizationCodeParams): Promise<GitLabOAuthTokens>;
287
+ /**
288
+ * Exchange refresh token for new tokens
289
+ * Based on gitlab-vscode-extension TokenExchangeService
290
+ */
291
+ exchangeRefreshToken(params: RefreshTokenParams): Promise<GitLabOAuthTokens>;
292
+ /**
293
+ * Get the OAuth client ID for an instance
294
+ */
295
+ private getClientId;
296
+ /**
297
+ * Exchange token with GitLab OAuth endpoint
298
+ * Based on gitlab-vscode-extension GitLabService.exchangeToken
299
+ */
300
+ private exchangeToken;
301
+ /**
302
+ * Create GitLabOAuthTokens from token response
303
+ */
304
+ private createTokensFromResponse;
305
+ /**
306
+ * Create expiry timestamp from token response
307
+ * Based on gitlab-vscode-extension createExpiresTimestamp
308
+ */
309
+ private createExpiresTimestamp;
325
310
  }
326
311
 
327
312
  /**
@@ -329,33 +314,33 @@ declare class GitLabOAuthManager {
329
314
  */
330
315
  declare const ANTHROPIC_TOOLS: Tool[];
331
316
  interface ToolResult {
332
- result: string;
333
- error?: string;
317
+ result: string;
318
+ error?: string;
334
319
  }
335
320
  interface ToolInput {
336
- [key: string]: unknown;
321
+ [key: string]: unknown;
337
322
  }
338
323
  /**
339
324
  * Tool executor for local file and command operations
340
325
  */
341
326
  declare class AnthropicToolExecutor {
342
- private readonly workingDirectory;
343
- constructor(workingDirectory: string);
344
- /**
345
- * Execute a tool by name with given input
346
- */
347
- execute(toolName: string, input: ToolInput): Promise<ToolResult>;
348
- private resolvePath;
349
- private listDir;
350
- private readFile;
351
- private writeFile;
352
- private editFile;
353
- private findFiles;
354
- private mkdir;
355
- private grep;
356
- private runCommand;
357
- private runGitCommand;
358
- private executeCommand;
327
+ private readonly workingDirectory;
328
+ constructor(workingDirectory: string);
329
+ /**
330
+ * Execute a tool by name with given input
331
+ */
332
+ execute(toolName: string, input: ToolInput): Promise<ToolResult>;
333
+ private resolvePath;
334
+ private listDir;
335
+ private readFile;
336
+ private writeFile;
337
+ private editFile;
338
+ private findFiles;
339
+ private mkdir;
340
+ private grep;
341
+ private runCommand;
342
+ private runGitCommand;
343
+ private executeCommand;
359
344
  }
360
345
 
361
346
  /**
@@ -364,43 +349,43 @@ declare class AnthropicToolExecutor {
364
349
  */
365
350
  declare const GITLAB_API_TOOLS: Tool[];
366
351
  interface GitLabApiToolsConfig {
367
- instanceUrl: string;
368
- token: string;
369
- fetch?: typeof fetch;
352
+ instanceUrl: string;
353
+ token: string;
354
+ fetch?: typeof fetch;
370
355
  }
371
356
  /**
372
357
  * Executor for GitLab API tools
373
358
  */
374
359
  declare class GitLabApiToolExecutor {
375
- private readonly config;
376
- constructor(config: GitLabApiToolsConfig);
377
- private get headers();
378
- private fetchApi;
379
- private encodeProjectId;
380
- /**
381
- * Execute a GitLab API tool by name
382
- */
383
- execute(toolName: string, input: ToolInput): Promise<ToolResult>;
384
- private getMergeRequest;
385
- private listMergeRequests;
386
- private getMrChanges;
387
- private listMrDiscussions;
388
- private createMrNote;
389
- private getIssue;
390
- private listIssues;
391
- private createIssueNote;
392
- private listPipelines;
393
- private getPipeline;
394
- private listPipelineJobs;
395
- private getJobLog;
396
- private retryJob;
397
- private getFile;
398
- private listCommits;
399
- private getCommitDiff;
400
- private listBranches;
401
- private search;
402
- private getProject;
403
- private listProjectMembers;
360
+ private readonly config;
361
+ constructor(config: GitLabApiToolsConfig);
362
+ private get headers();
363
+ private fetchApi;
364
+ private encodeProjectId;
365
+ /**
366
+ * Execute a GitLab API tool by name
367
+ */
368
+ execute(toolName: string, input: ToolInput): Promise<ToolResult>;
369
+ private getMergeRequest;
370
+ private listMergeRequests;
371
+ private getMrChanges;
372
+ private listMrDiscussions;
373
+ private createMrNote;
374
+ private getIssue;
375
+ private listIssues;
376
+ private createIssueNote;
377
+ private listPipelines;
378
+ private getPipeline;
379
+ private listPipelineJobs;
380
+ private getJobLog;
381
+ private retryJob;
382
+ private getFile;
383
+ private listCommits;
384
+ private getCommitDiff;
385
+ private listBranches;
386
+ private search;
387
+ private getProject;
388
+ private listProjectMembers;
404
389
  }
405
390
  /**
406
391
  * Check if a tool name is a GitLab API tool
@@ -412,68 +397,68 @@ declare function isGitLabApiTool(toolName: string): boolean;
412
397
  * Used to avoid repeated API calls when detecting projects from git remotes
413
398
  */
414
399
  interface GitLabProject {
415
- id: number;
416
- path: string;
417
- pathWithNamespace: string;
418
- name: string;
419
- namespaceId?: number;
400
+ id: number;
401
+ path: string;
402
+ pathWithNamespace: string;
403
+ name: string;
404
+ namespaceId?: number;
420
405
  }
421
406
  /**
422
407
  * In-memory cache for GitLab project information with TTL support
423
408
  */
424
409
  declare class GitLabProjectCache {
425
- private cache;
426
- private defaultTTL;
427
- /**
428
- * Create a new project cache
429
- * @param defaultTTL - Default time-to-live in milliseconds (default: 5 minutes)
430
- */
431
- constructor(defaultTTL?: number);
432
- /**
433
- * Get a cached project by key
434
- * @param key - Cache key (typically the working directory path)
435
- * @returns The cached project or null if not found or expired
436
- */
437
- get(key: string): GitLabProject | null;
438
- /**
439
- * Store a project in the cache
440
- * @param key - Cache key (typically the working directory path)
441
- * @param project - The project to cache
442
- * @param ttl - Optional custom TTL in milliseconds
443
- */
444
- set(key: string, project: GitLabProject, ttl?: number): void;
445
- /**
446
- * Check if a key exists in the cache (and is not expired)
447
- * @param key - Cache key to check
448
- * @returns true if the key exists and is not expired
449
- */
450
- has(key: string): boolean;
451
- /**
452
- * Remove a specific entry from the cache
453
- * @param key - Cache key to remove
454
- */
455
- delete(key: string): void;
456
- /**
457
- * Clear all entries from the cache
458
- */
459
- clear(): void;
460
- /**
461
- * Get the number of entries in the cache (including expired ones)
462
- */
463
- get size(): number;
464
- /**
465
- * Clean up expired entries from the cache
466
- * This is useful for long-running processes to prevent memory leaks
467
- */
468
- cleanup(): void;
410
+ private cache;
411
+ private defaultTTL;
412
+ /**
413
+ * Create a new project cache
414
+ * @param defaultTTL - Default time-to-live in milliseconds (default: 5 minutes)
415
+ */
416
+ constructor(defaultTTL?: number);
417
+ /**
418
+ * Get a cached project by key
419
+ * @param key - Cache key (typically the working directory path)
420
+ * @returns The cached project or null if not found or expired
421
+ */
422
+ get(key: string): GitLabProject | null;
423
+ /**
424
+ * Store a project in the cache
425
+ * @param key - Cache key (typically the working directory path)
426
+ * @param project - The project to cache
427
+ * @param ttl - Optional custom TTL in milliseconds
428
+ */
429
+ set(key: string, project: GitLabProject, ttl?: number): void;
430
+ /**
431
+ * Check if a key exists in the cache (and is not expired)
432
+ * @param key - Cache key to check
433
+ * @returns true if the key exists and is not expired
434
+ */
435
+ has(key: string): boolean;
436
+ /**
437
+ * Remove a specific entry from the cache
438
+ * @param key - Cache key to remove
439
+ */
440
+ delete(key: string): void;
441
+ /**
442
+ * Clear all entries from the cache
443
+ */
444
+ clear(): void;
445
+ /**
446
+ * Get the number of entries in the cache (including expired ones)
447
+ */
448
+ get size(): number;
449
+ /**
450
+ * Clean up expired entries from the cache
451
+ * This is useful for long-running processes to prevent memory leaks
452
+ */
453
+ cleanup(): void;
469
454
  }
470
455
 
471
456
  interface GitLabProjectDetectorConfig {
472
- instanceUrl: string;
473
- getHeaders: () => Record<string, string>;
474
- fetch?: typeof fetch;
475
- cache?: GitLabProjectCache;
476
- gitTimeout?: number;
457
+ instanceUrl: string;
458
+ getHeaders: () => Record<string, string>;
459
+ fetch?: typeof fetch;
460
+ cache?: GitLabProjectCache;
461
+ gitTimeout?: number;
477
462
  }
478
463
  /**
479
464
  * Detects GitLab project information from git remote URLs
@@ -485,88 +470,56 @@ interface GitLabProjectDetectorConfig {
485
470
  * - Cache project information to avoid repeated API calls
486
471
  */
487
472
  declare class GitLabProjectDetector {
488
- private readonly config;
489
- private readonly fetchFn;
490
- private readonly cache;
491
- constructor(config: GitLabProjectDetectorConfig);
492
- /**
493
- * Auto-detect GitLab project from git remote in the working directory
494
- *
495
- * @param workingDirectory - The directory to check for git remote
496
- * @param remoteName - The git remote name to use (default: 'origin')
497
- * @returns The detected project or null if detection fails
498
- */
499
- detectProject(workingDirectory: string, remoteName?: string): Promise<GitLabProject | null>;
500
- /**
501
- * Parse a git remote URL to extract the project path
502
- *
503
- * Supports:
504
- * - SSH: git@gitlab.com:namespace/project.git
505
- * - HTTPS: https://gitlab.com/namespace/project.git
506
- * - HTTP: http://gitlab.local/namespace/project.git
507
- * - Custom domains and ports
508
- *
509
- * @param remoteUrl - The git remote URL
510
- * @param instanceUrl - The GitLab instance URL to match against
511
- * @returns The project path (e.g., "namespace/project") or null if parsing fails
512
- */
513
- parseGitRemoteUrl(remoteUrl: string, instanceUrl: string): string | null;
514
- /**
515
- * Get the git remote URL from a working directory
516
- *
517
- * @param workingDirectory - The directory to check
518
- * @param remoteName - The git remote name (default: 'origin')
519
- * @returns The remote URL or null if not found
520
- */
521
- getGitRemoteUrl(workingDirectory: string, remoteName?: string): Promise<string | null>;
522
- /**
523
- * Fetch project details from GitLab API by project path
524
- *
525
- * @param projectPath - The project path (e.g., "namespace/project")
526
- * @returns The project details
527
- * @throws GitLabError if the API call fails
528
- */
529
- getProjectByPath(projectPath: string): Promise<GitLabProject>;
530
- /**
531
- * Clear the project cache
532
- */
533
- clearCache(): void;
534
- /**
535
- * Get the cache instance (useful for testing)
536
- */
537
- getCache(): GitLabProjectCache;
473
+ private readonly config;
474
+ private readonly fetchFn;
475
+ private readonly cache;
476
+ constructor(config: GitLabProjectDetectorConfig);
477
+ /**
478
+ * Auto-detect GitLab project from git remote in the working directory
479
+ *
480
+ * @param workingDirectory - The directory to check for git remote
481
+ * @param remoteName - The git remote name to use (default: 'origin')
482
+ * @returns The detected project or null if detection fails
483
+ */
484
+ detectProject(workingDirectory: string, remoteName?: string): Promise<GitLabProject | null>;
485
+ /**
486
+ * Parse a git remote URL to extract the project path
487
+ *
488
+ * Supports:
489
+ * - SSH: git@gitlab.com:namespace/project.git
490
+ * - HTTPS: https://gitlab.com/namespace/project.git
491
+ * - HTTP: http://gitlab.local/namespace/project.git
492
+ * - Custom domains and ports
493
+ *
494
+ * @param remoteUrl - The git remote URL
495
+ * @param instanceUrl - The GitLab instance URL to match against
496
+ * @returns The project path (e.g., "namespace/project") or null if parsing fails
497
+ */
498
+ parseGitRemoteUrl(remoteUrl: string, instanceUrl: string): string | null;
499
+ /**
500
+ * Get the git remote URL from a working directory
501
+ *
502
+ * @param workingDirectory - The directory to check
503
+ * @param remoteName - The git remote name (default: 'origin')
504
+ * @returns The remote URL or null if not found
505
+ */
506
+ getGitRemoteUrl(workingDirectory: string, remoteName?: string): Promise<string | null>;
507
+ /**
508
+ * Fetch project details from GitLab API by project path
509
+ *
510
+ * @param projectPath - The project path (e.g., "namespace/project")
511
+ * @returns The project details
512
+ * @throws GitLabError if the API call fails
513
+ */
514
+ getProjectByPath(projectPath: string): Promise<GitLabProject>;
515
+ /**
516
+ * Clear the project cache
517
+ */
518
+ clearCache(): void;
519
+ /**
520
+ * Get the cache instance (useful for testing)
521
+ */
522
+ getCache(): GitLabProjectCache;
538
523
  }
539
524
 
540
- export {
541
- ANTHROPIC_TOOLS,
542
- AnthropicToolExecutor,
543
- BUNDLED_CLIENT_ID,
544
- GITLAB_API_TOOLS,
545
- GITLAB_COM_URL,
546
- type GitLabAgenticConfig,
547
- GitLabAgenticLanguageModel,
548
- type GitLabAgenticOptions,
549
- GitLabApiToolExecutor,
550
- type GitLabApiToolsConfig,
551
- GitLabError,
552
- type GitLabErrorOptions,
553
- GitLabOAuthManager,
554
- type GitLabOAuthTokenResponse,
555
- type GitLabOAuthTokens,
556
- type GitLabProject,
557
- GitLabProjectCache,
558
- GitLabProjectDetector,
559
- type GitLabProjectDetectorConfig,
560
- type GitLabProvider,
561
- type GitLabProviderSettings,
562
- OAUTH_SCOPES,
563
- type OpenCodeAuth,
564
- type OpenCodeAuthApi,
565
- type OpenCodeAuthOAuth,
566
- TOKEN_EXPIRY_SKEW_MS,
567
- type ToolInput,
568
- type ToolResult,
569
- createGitLab,
570
- gitlab,
571
- isGitLabApiTool,
572
- };
525
+ export { ANTHROPIC_TOOLS, AnthropicToolExecutor, BUNDLED_CLIENT_ID, GITLAB_API_TOOLS, GITLAB_COM_URL, type GitLabAgenticConfig, GitLabAgenticLanguageModel, type GitLabAgenticOptions, GitLabApiToolExecutor, type GitLabApiToolsConfig, GitLabError, type GitLabErrorOptions, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, OAUTH_SCOPES, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, TOKEN_EXPIRY_SKEW_MS, type ToolInput, type ToolResult, createGitLab, gitlab, isGitLabApiTool };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@gitlab/gitlab-ai-provider",
3
- "version": "1.0.5",
3
+ "version": "3.0.7",
4
4
  "description": "GitLab Duo provider for Vercel AI SDK",
5
- "license": "Apache-2.0",
5
+ "license": "MIT",
6
6
  "author": "Vladimir Glafirov",
7
7
  "repository": {
8
8
  "type": "git",