@gitlab/gitlab-ai-provider 1.0.5 → 3.0.6
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 +44 -0
- package/dist/gitlab-gitlab-ai-provider-3.0.6.tgz +0 -0
- package/dist/index.d.ts +372 -419
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
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.6 (2025-12-19)</small>
|
|
6
|
+
|
|
7
|
+
- fix: use NPM_ID_TOKEN with correct audience for OIDC ([03fb549](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/03fb549))
|
|
8
|
+
|
|
9
|
+
## <small>3.0.5 (2025-12-19)</small>
|
|
10
|
+
|
|
11
|
+
- fix: use NPM_TOKEN for authentication (OIDC not supported for GitLab) ([4d595cf](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/4d595cf))
|
|
12
|
+
|
|
13
|
+
## <small>3.0.4 (2025-12-19)</small>
|
|
14
|
+
|
|
15
|
+
- refactor: use artifacts for version propagation ([03d4935](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/03d4935))
|
|
16
|
+
- fix: use OIDC for npmjs.org and sync version ([e5ff429](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e5ff429))
|
|
17
|
+
|
|
18
|
+
## <small>3.0.3 (2025-12-19)</small>
|
|
19
|
+
|
|
20
|
+
- fix: update package-lock.json with MIT license ([d724d20](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/d724d20))
|
|
21
|
+
- fix: use NPM_TOKEN for npmjs.org authentication ([e96d9de](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e96d9de))
|
|
22
|
+
|
|
23
|
+
## <small>3.0.2 (2025-12-19)</small>
|
|
24
|
+
|
|
25
|
+
- fix: correct license to MIT in package.json ([6df4154](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/6df4154))
|
|
26
|
+
|
|
27
|
+
## <small>3.0.1 (2025-12-19)</small>
|
|
28
|
+
|
|
29
|
+
- fix: use SIGSTORE_ID_TOKEN for npm provenance ([e5c8c7f](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e5c8c7f))
|
|
30
|
+
|
|
31
|
+
## 3.0.0 (2025-12-19)
|
|
32
|
+
|
|
33
|
+
- feat: automate publishing workflow ([f8c384d](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/f8c384d))
|
|
34
|
+
|
|
35
|
+
### BREAKING CHANGE
|
|
36
|
+
|
|
37
|
+
- Publishing now happens automatically on every main branch commit
|
|
38
|
+
|
|
39
|
+
## 2.0.0 (2025-12-18)
|
|
40
|
+
|
|
41
|
+
- fix: bump the version ([02df4b2](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/02df4b2))
|
|
42
|
+
- fix: remove GitLab registry config and add test dependencies ([81cc14e](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/81cc14e))
|
|
43
|
+
- feat: configure publishing to npmjs.org with OIDC ([bb62d90](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/bb62d90))
|
|
44
|
+
|
|
45
|
+
### BREAKING CHANGE
|
|
46
|
+
|
|
47
|
+
- Package now only published to npmjs.org as @gitlab/gitlab-ai-provider
|
|
48
|
+
|
|
5
49
|
## <small>1.0.5 (2025-12-18)</small>
|
|
6
50
|
|
|
7
51
|
- 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))
|
|
Binary file
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
172
|
+
message: string;
|
|
173
|
+
statusCode?: number;
|
|
174
|
+
responseBody?: string;
|
|
175
|
+
cause?: unknown;
|
|
184
176
|
}
|
|
185
177
|
declare class GitLabError extends Error {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
212
|
+
accessToken: string;
|
|
213
|
+
refreshToken: string;
|
|
214
|
+
expiresAt: number;
|
|
215
|
+
instanceUrl: string;
|
|
230
216
|
}
|
|
231
217
|
interface OpenCodeAuthOAuth {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
218
|
+
type: 'oauth';
|
|
219
|
+
refresh: string;
|
|
220
|
+
access: string;
|
|
221
|
+
expires: number;
|
|
222
|
+
instanceUrl?: string;
|
|
237
223
|
}
|
|
238
224
|
interface OpenCodeAuthApi {
|
|
239
|
-
|
|
240
|
-
|
|
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 =
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
255
|
+
instanceUrl: string;
|
|
256
|
+
clientId?: string;
|
|
257
|
+
redirectUri?: string;
|
|
273
258
|
}
|
|
274
259
|
interface AuthorizationCodeParams extends TokenExchangeParams {
|
|
275
|
-
|
|
276
|
-
|
|
260
|
+
code: string;
|
|
261
|
+
codeVerifier: string;
|
|
277
262
|
}
|
|
278
263
|
interface RefreshTokenParams extends TokenExchangeParams {
|
|
279
|
-
|
|
264
|
+
refreshToken: string;
|
|
280
265
|
}
|
|
281
266
|
declare class GitLabOAuthManager {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
333
|
-
|
|
317
|
+
result: string;
|
|
318
|
+
error?: string;
|
|
334
319
|
}
|
|
335
320
|
interface ToolInput {
|
|
336
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
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
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
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