@gitlab/gitlab-ai-provider 3.1.1 → 3.1.3
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 +9 -0
- package/README.md +9 -30
- package/dist/gitlab-gitlab-ai-provider-3.1.3.tgz +0 -0
- package/dist/index.d.mts +75 -85
- package/dist/index.d.ts +75 -85
- package/dist/index.js +174 -1307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +171 -1301
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/gitlab-gitlab-ai-provider-3.1.1.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
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.1.3 (2026-01-21)</small>
|
|
6
|
+
|
|
7
|
+
- Merge branch 'fix/streaming-tool-call-handling' into 'main' ([22279b1](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/22279b1))
|
|
8
|
+
- fix: refactor streaming to handle tool calls properly ([88fb513](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/88fb513))
|
|
9
|
+
|
|
10
|
+
## <small>3.1.2 (2026-01-18)</small>
|
|
11
|
+
|
|
12
|
+
- fix: removed API tools and added new env variable ([a64ef6d](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/a64ef6d))
|
|
13
|
+
|
|
5
14
|
## <small>3.1.1 (2026-01-14)</small>
|
|
6
15
|
|
|
7
16
|
- fix: use models mapping for Anthropic ([7b876ec](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/7b876ec))
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A comprehensive TypeScript provider for integrating GitLab Duo AI capabilities w
|
|
|
7
7
|
- **🤖 Agentic Chat**: Native tool calling support via GitLab's Anthropic proxy
|
|
8
8
|
- **🔐 Multiple Authentication**: Support for OAuth, Personal Access Tokens, and OpenCode auth
|
|
9
9
|
- **🌐 Self-Hosted Support**: Works with both GitLab.com and self-hosted instances
|
|
10
|
-
-
|
|
10
|
+
- **🔧 Tool Support**: Native tool calling via Vercel AI SDK
|
|
11
11
|
- **🔍 Project Detection**: Automatic GitLab project detection from git remotes
|
|
12
12
|
- **💾 Smart Caching**: Project and token caching for optimal performance
|
|
13
13
|
- **🎯 Type-Safe**: Complete TypeScript definitions with Zod validation
|
|
@@ -224,33 +224,6 @@ Provides native tool calling through GitLab's Anthropic proxy.
|
|
|
224
224
|
- Direct access token management
|
|
225
225
|
- Supports all Anthropic tool calling features
|
|
226
226
|
|
|
227
|
-
### Tool Executors
|
|
228
|
-
|
|
229
|
-
#### AnthropicToolExecutor
|
|
230
|
-
|
|
231
|
-
Executes local file system and command tools:
|
|
232
|
-
|
|
233
|
-
- `list_dir` - List directory contents
|
|
234
|
-
- `read_file` - Read file contents
|
|
235
|
-
- `write_file` - Write to files
|
|
236
|
-
- `edit_file` - Edit file with find/replace
|
|
237
|
-
- `find_files` - Find files by pattern
|
|
238
|
-
- `mkdir` - Create directories
|
|
239
|
-
- `grep` - Search file contents
|
|
240
|
-
- `run_command` - Execute shell commands
|
|
241
|
-
- `run_git_command` - Execute git commands
|
|
242
|
-
|
|
243
|
-
#### GitLabApiToolExecutor
|
|
244
|
-
|
|
245
|
-
Executes GitLab API operations:
|
|
246
|
-
|
|
247
|
-
- Merge Requests: get, list, changes, discussions, notes
|
|
248
|
-
- Issues: get, list, notes
|
|
249
|
-
- Pipelines: list, get, jobs, logs
|
|
250
|
-
- Repository: files, commits, branches
|
|
251
|
-
- Search: global and project search
|
|
252
|
-
- Projects: get, members
|
|
253
|
-
|
|
254
227
|
### Supporting Utilities
|
|
255
228
|
|
|
256
229
|
#### GitLabProjectDetector
|
|
@@ -321,9 +294,17 @@ interface GitLabProviderSettings {
|
|
|
321
294
|
name?: string; // Provider name prefix
|
|
322
295
|
headers?: Record<string, string>; // Custom headers
|
|
323
296
|
fetch?: typeof fetch; // Custom fetch implementation
|
|
297
|
+
aiGatewayUrl?: string; // AI Gateway URL (default: 'https://cloud.gitlab.com')
|
|
324
298
|
}
|
|
325
299
|
```
|
|
326
300
|
|
|
301
|
+
### Environment Variables
|
|
302
|
+
|
|
303
|
+
| Variable | Description | Default |
|
|
304
|
+
| ----------------------- | ------------------------------------------- | -------------------------- |
|
|
305
|
+
| `GITLAB_TOKEN` | GitLab Personal Access Token or OAuth token | - |
|
|
306
|
+
| `GITLAB_AI_GATEWAY_URL` | AI Gateway URL for Anthropic proxy | `https://cloud.gitlab.com` |
|
|
307
|
+
|
|
327
308
|
### Agentic Chat Options
|
|
328
309
|
|
|
329
310
|
```typescript
|
|
@@ -392,8 +373,6 @@ gitlab-ai-provider/
|
|
|
392
373
|
│ ├── gitlab-oauth-types.ts # OAuth types
|
|
393
374
|
│ ├── gitlab-project-detector.ts # Project detection
|
|
394
375
|
│ ├── gitlab-project-cache.ts # Project caching
|
|
395
|
-
│ ├── gitlab-anthropic-tools.ts # Anthropic tool executor
|
|
396
|
-
│ ├── gitlab-api-tools.ts # GitLab API tool executor
|
|
397
376
|
│ ├── gitlab-api-types.ts # API types
|
|
398
377
|
│ ├── gitlab-error.ts # Error handling
|
|
399
378
|
│ └── gitlab-workflow-debug.ts # Debug logging
|
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
4
3
|
|
|
5
4
|
interface GitLabAgenticConfig {
|
|
6
5
|
provider: string;
|
|
@@ -29,6 +28,12 @@ interface GitLabAgenticConfig {
|
|
|
29
28
|
featureFlags?: {
|
|
30
29
|
DuoAgentPlatformNext: true;
|
|
31
30
|
} & Record<string, boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
33
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
34
|
+
* @default 'https://cloud.gitlab.com'
|
|
35
|
+
*/
|
|
36
|
+
aiGatewayUrl?: string;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* GitLab Agentic Language Model
|
|
@@ -189,6 +194,12 @@ interface GitLabProviderSettings {
|
|
|
189
194
|
* Default feature flags to pass to the GitLab API for all agentic chat models
|
|
190
195
|
*/
|
|
191
196
|
featureFlags?: Record<string, boolean>;
|
|
197
|
+
/**
|
|
198
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
199
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
200
|
+
* @default 'https://cloud.gitlab.com'
|
|
201
|
+
*/
|
|
202
|
+
aiGatewayUrl?: string;
|
|
192
203
|
}
|
|
193
204
|
declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
|
|
194
205
|
/**
|
|
@@ -371,89 +382,6 @@ declare class GitLabOAuthManager {
|
|
|
371
382
|
private createExpiresTimestamp;
|
|
372
383
|
}
|
|
373
384
|
|
|
374
|
-
/**
|
|
375
|
-
* Tool definitions for Anthropic Claude
|
|
376
|
-
*/
|
|
377
|
-
declare const ANTHROPIC_TOOLS: Tool[];
|
|
378
|
-
interface ToolResult {
|
|
379
|
-
result: string;
|
|
380
|
-
error?: string;
|
|
381
|
-
}
|
|
382
|
-
interface ToolInput {
|
|
383
|
-
[key: string]: unknown;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Tool executor for local file and command operations
|
|
387
|
-
*/
|
|
388
|
-
declare class AnthropicToolExecutor {
|
|
389
|
-
private readonly workingDirectory;
|
|
390
|
-
constructor(workingDirectory: string);
|
|
391
|
-
/**
|
|
392
|
-
* Execute a tool by name with given input
|
|
393
|
-
*/
|
|
394
|
-
execute(toolName: string, input: ToolInput): Promise<ToolResult>;
|
|
395
|
-
private resolvePath;
|
|
396
|
-
private listDir;
|
|
397
|
-
private readFile;
|
|
398
|
-
private writeFile;
|
|
399
|
-
private editFile;
|
|
400
|
-
private findFiles;
|
|
401
|
-
private mkdir;
|
|
402
|
-
private grep;
|
|
403
|
-
private runCommand;
|
|
404
|
-
private runGitCommand;
|
|
405
|
-
private executeCommand;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* GitLab API tools for interacting with GitLab resources
|
|
410
|
-
* These tools allow the AI to access merge requests, issues, pipelines, etc.
|
|
411
|
-
*/
|
|
412
|
-
declare const GITLAB_API_TOOLS: Tool[];
|
|
413
|
-
interface GitLabApiToolsConfig {
|
|
414
|
-
instanceUrl: string;
|
|
415
|
-
token: string;
|
|
416
|
-
fetch?: typeof fetch;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Executor for GitLab API tools
|
|
420
|
-
*/
|
|
421
|
-
declare class GitLabApiToolExecutor {
|
|
422
|
-
private readonly config;
|
|
423
|
-
constructor(config: GitLabApiToolsConfig);
|
|
424
|
-
private get headers();
|
|
425
|
-
private fetchApi;
|
|
426
|
-
private encodeProjectId;
|
|
427
|
-
/**
|
|
428
|
-
* Execute a GitLab API tool by name
|
|
429
|
-
*/
|
|
430
|
-
execute(toolName: string, input: ToolInput): Promise<ToolResult>;
|
|
431
|
-
private getMergeRequest;
|
|
432
|
-
private listMergeRequests;
|
|
433
|
-
private getMrChanges;
|
|
434
|
-
private listMrDiscussions;
|
|
435
|
-
private createMrNote;
|
|
436
|
-
private getIssue;
|
|
437
|
-
private listIssues;
|
|
438
|
-
private createIssueNote;
|
|
439
|
-
private listPipelines;
|
|
440
|
-
private getPipeline;
|
|
441
|
-
private listPipelineJobs;
|
|
442
|
-
private getJobLog;
|
|
443
|
-
private retryJob;
|
|
444
|
-
private getFile;
|
|
445
|
-
private listCommits;
|
|
446
|
-
private getCommitDiff;
|
|
447
|
-
private listBranches;
|
|
448
|
-
private search;
|
|
449
|
-
private getProject;
|
|
450
|
-
private listProjectMembers;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Check if a tool name is a GitLab API tool
|
|
454
|
-
*/
|
|
455
|
-
declare function isGitLabApiTool(toolName: string): boolean;
|
|
456
|
-
|
|
457
385
|
/**
|
|
458
386
|
* Simple in-memory cache for GitLab project information
|
|
459
387
|
* Used to avoid repeated API calls when detecting projects from git remotes
|
|
@@ -584,4 +512,66 @@ declare class GitLabProjectDetector {
|
|
|
584
512
|
getCache(): GitLabProjectCache;
|
|
585
513
|
}
|
|
586
514
|
|
|
587
|
-
|
|
515
|
+
/**
|
|
516
|
+
* Response from /api/v4/ai/third_party_agents/direct_access
|
|
517
|
+
*/
|
|
518
|
+
declare const directAccessTokenSchema: z.ZodObject<{
|
|
519
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
520
|
+
token: z.ZodString;
|
|
521
|
+
}, "strip", z.ZodTypeAny, {
|
|
522
|
+
headers?: Record<string, string>;
|
|
523
|
+
token?: string;
|
|
524
|
+
}, {
|
|
525
|
+
headers?: Record<string, string>;
|
|
526
|
+
token?: string;
|
|
527
|
+
}>;
|
|
528
|
+
type DirectAccessToken = z.infer<typeof directAccessTokenSchema>;
|
|
529
|
+
declare const DEFAULT_AI_GATEWAY_URL = "https://cloud.gitlab.com";
|
|
530
|
+
interface GitLabDirectAccessConfig {
|
|
531
|
+
instanceUrl: string;
|
|
532
|
+
getHeaders: () => Record<string, string>;
|
|
533
|
+
fetch?: typeof fetch;
|
|
534
|
+
/**
|
|
535
|
+
* Optional callback to refresh the API key when a 401 error occurs.
|
|
536
|
+
* Should clear cached credentials and re-fetch from auth provider.
|
|
537
|
+
*/
|
|
538
|
+
refreshApiKey?: () => Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Feature flags to pass to the GitLab API
|
|
541
|
+
*/
|
|
542
|
+
featureFlags?: Record<string, boolean>;
|
|
543
|
+
/**
|
|
544
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
545
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
546
|
+
* @default 'https://cloud.gitlab.com'
|
|
547
|
+
*/
|
|
548
|
+
aiGatewayUrl?: string;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Client for GitLab's third-party agents direct access API.
|
|
552
|
+
* This allows routing requests through GitLab's proxy to Anthropic.
|
|
553
|
+
*/
|
|
554
|
+
declare class GitLabDirectAccessClient {
|
|
555
|
+
private readonly config;
|
|
556
|
+
private readonly fetchFn;
|
|
557
|
+
private readonly aiGatewayUrl;
|
|
558
|
+
private cachedToken;
|
|
559
|
+
private tokenExpiresAt;
|
|
560
|
+
constructor(config: GitLabDirectAccessConfig);
|
|
561
|
+
/**
|
|
562
|
+
* Get a direct access token for the Anthropic proxy.
|
|
563
|
+
* Tokens are cached for 25 minutes (they expire after 30 minutes).
|
|
564
|
+
* @param forceRefresh - If true, ignores the cache and fetches a new token
|
|
565
|
+
*/
|
|
566
|
+
getDirectAccessToken(forceRefresh?: boolean): Promise<DirectAccessToken>;
|
|
567
|
+
/**
|
|
568
|
+
* Get the Anthropic proxy base URL
|
|
569
|
+
*/
|
|
570
|
+
getAnthropicProxyUrl(): string;
|
|
571
|
+
/**
|
|
572
|
+
* Invalidate the cached token
|
|
573
|
+
*/
|
|
574
|
+
invalidateToken(): void;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export { BUNDLED_CLIENT_ID, DEFAULT_AI_GATEWAY_URL, type DirectAccessToken, GITLAB_COM_URL, type GitLabAgenticConfig, GitLabAgenticLanguageModel, type GitLabAgenticOptions, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, MODEL_ID_TO_ANTHROPIC_MODEL, OAUTH_SCOPES, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, TOKEN_EXPIRY_SKEW_MS, createGitLab, getAnthropicModelForModelId, gitlab };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV2, LanguageModelV2CallOptions, LanguageModelV2Content, LanguageModelV2FinishReason, LanguageModelV2Usage, LanguageModelV2CallWarning, LanguageModelV2StreamPart } from '@ai-sdk/provider';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { Tool } from '@anthropic-ai/sdk/resources/messages';
|
|
4
3
|
|
|
5
4
|
interface GitLabAgenticConfig {
|
|
6
5
|
provider: string;
|
|
@@ -29,6 +28,12 @@ interface GitLabAgenticConfig {
|
|
|
29
28
|
featureFlags?: {
|
|
30
29
|
DuoAgentPlatformNext: true;
|
|
31
30
|
} & Record<string, boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
33
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
34
|
+
* @default 'https://cloud.gitlab.com'
|
|
35
|
+
*/
|
|
36
|
+
aiGatewayUrl?: string;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* GitLab Agentic Language Model
|
|
@@ -189,6 +194,12 @@ interface GitLabProviderSettings {
|
|
|
189
194
|
* Default feature flags to pass to the GitLab API for all agentic chat models
|
|
190
195
|
*/
|
|
191
196
|
featureFlags?: Record<string, boolean>;
|
|
197
|
+
/**
|
|
198
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
199
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
200
|
+
* @default 'https://cloud.gitlab.com'
|
|
201
|
+
*/
|
|
202
|
+
aiGatewayUrl?: string;
|
|
192
203
|
}
|
|
193
204
|
declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
|
|
194
205
|
/**
|
|
@@ -371,89 +382,6 @@ declare class GitLabOAuthManager {
|
|
|
371
382
|
private createExpiresTimestamp;
|
|
372
383
|
}
|
|
373
384
|
|
|
374
|
-
/**
|
|
375
|
-
* Tool definitions for Anthropic Claude
|
|
376
|
-
*/
|
|
377
|
-
declare const ANTHROPIC_TOOLS: Tool[];
|
|
378
|
-
interface ToolResult {
|
|
379
|
-
result: string;
|
|
380
|
-
error?: string;
|
|
381
|
-
}
|
|
382
|
-
interface ToolInput {
|
|
383
|
-
[key: string]: unknown;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Tool executor for local file and command operations
|
|
387
|
-
*/
|
|
388
|
-
declare class AnthropicToolExecutor {
|
|
389
|
-
private readonly workingDirectory;
|
|
390
|
-
constructor(workingDirectory: string);
|
|
391
|
-
/**
|
|
392
|
-
* Execute a tool by name with given input
|
|
393
|
-
*/
|
|
394
|
-
execute(toolName: string, input: ToolInput): Promise<ToolResult>;
|
|
395
|
-
private resolvePath;
|
|
396
|
-
private listDir;
|
|
397
|
-
private readFile;
|
|
398
|
-
private writeFile;
|
|
399
|
-
private editFile;
|
|
400
|
-
private findFiles;
|
|
401
|
-
private mkdir;
|
|
402
|
-
private grep;
|
|
403
|
-
private runCommand;
|
|
404
|
-
private runGitCommand;
|
|
405
|
-
private executeCommand;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* GitLab API tools for interacting with GitLab resources
|
|
410
|
-
* These tools allow the AI to access merge requests, issues, pipelines, etc.
|
|
411
|
-
*/
|
|
412
|
-
declare const GITLAB_API_TOOLS: Tool[];
|
|
413
|
-
interface GitLabApiToolsConfig {
|
|
414
|
-
instanceUrl: string;
|
|
415
|
-
token: string;
|
|
416
|
-
fetch?: typeof fetch;
|
|
417
|
-
}
|
|
418
|
-
/**
|
|
419
|
-
* Executor for GitLab API tools
|
|
420
|
-
*/
|
|
421
|
-
declare class GitLabApiToolExecutor {
|
|
422
|
-
private readonly config;
|
|
423
|
-
constructor(config: GitLabApiToolsConfig);
|
|
424
|
-
private get headers();
|
|
425
|
-
private fetchApi;
|
|
426
|
-
private encodeProjectId;
|
|
427
|
-
/**
|
|
428
|
-
* Execute a GitLab API tool by name
|
|
429
|
-
*/
|
|
430
|
-
execute(toolName: string, input: ToolInput): Promise<ToolResult>;
|
|
431
|
-
private getMergeRequest;
|
|
432
|
-
private listMergeRequests;
|
|
433
|
-
private getMrChanges;
|
|
434
|
-
private listMrDiscussions;
|
|
435
|
-
private createMrNote;
|
|
436
|
-
private getIssue;
|
|
437
|
-
private listIssues;
|
|
438
|
-
private createIssueNote;
|
|
439
|
-
private listPipelines;
|
|
440
|
-
private getPipeline;
|
|
441
|
-
private listPipelineJobs;
|
|
442
|
-
private getJobLog;
|
|
443
|
-
private retryJob;
|
|
444
|
-
private getFile;
|
|
445
|
-
private listCommits;
|
|
446
|
-
private getCommitDiff;
|
|
447
|
-
private listBranches;
|
|
448
|
-
private search;
|
|
449
|
-
private getProject;
|
|
450
|
-
private listProjectMembers;
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* Check if a tool name is a GitLab API tool
|
|
454
|
-
*/
|
|
455
|
-
declare function isGitLabApiTool(toolName: string): boolean;
|
|
456
|
-
|
|
457
385
|
/**
|
|
458
386
|
* Simple in-memory cache for GitLab project information
|
|
459
387
|
* Used to avoid repeated API calls when detecting projects from git remotes
|
|
@@ -584,4 +512,66 @@ declare class GitLabProjectDetector {
|
|
|
584
512
|
getCache(): GitLabProjectCache;
|
|
585
513
|
}
|
|
586
514
|
|
|
587
|
-
|
|
515
|
+
/**
|
|
516
|
+
* Response from /api/v4/ai/third_party_agents/direct_access
|
|
517
|
+
*/
|
|
518
|
+
declare const directAccessTokenSchema: z.ZodObject<{
|
|
519
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
520
|
+
token: z.ZodString;
|
|
521
|
+
}, "strip", z.ZodTypeAny, {
|
|
522
|
+
headers?: Record<string, string>;
|
|
523
|
+
token?: string;
|
|
524
|
+
}, {
|
|
525
|
+
headers?: Record<string, string>;
|
|
526
|
+
token?: string;
|
|
527
|
+
}>;
|
|
528
|
+
type DirectAccessToken = z.infer<typeof directAccessTokenSchema>;
|
|
529
|
+
declare const DEFAULT_AI_GATEWAY_URL = "https://cloud.gitlab.com";
|
|
530
|
+
interface GitLabDirectAccessConfig {
|
|
531
|
+
instanceUrl: string;
|
|
532
|
+
getHeaders: () => Record<string, string>;
|
|
533
|
+
fetch?: typeof fetch;
|
|
534
|
+
/**
|
|
535
|
+
* Optional callback to refresh the API key when a 401 error occurs.
|
|
536
|
+
* Should clear cached credentials and re-fetch from auth provider.
|
|
537
|
+
*/
|
|
538
|
+
refreshApiKey?: () => Promise<void>;
|
|
539
|
+
/**
|
|
540
|
+
* Feature flags to pass to the GitLab API
|
|
541
|
+
*/
|
|
542
|
+
featureFlags?: Record<string, boolean>;
|
|
543
|
+
/**
|
|
544
|
+
* AI Gateway URL for the Anthropic proxy.
|
|
545
|
+
* Can also be set via GITLAB_AI_GATEWAY_URL environment variable.
|
|
546
|
+
* @default 'https://cloud.gitlab.com'
|
|
547
|
+
*/
|
|
548
|
+
aiGatewayUrl?: string;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Client for GitLab's third-party agents direct access API.
|
|
552
|
+
* This allows routing requests through GitLab's proxy to Anthropic.
|
|
553
|
+
*/
|
|
554
|
+
declare class GitLabDirectAccessClient {
|
|
555
|
+
private readonly config;
|
|
556
|
+
private readonly fetchFn;
|
|
557
|
+
private readonly aiGatewayUrl;
|
|
558
|
+
private cachedToken;
|
|
559
|
+
private tokenExpiresAt;
|
|
560
|
+
constructor(config: GitLabDirectAccessConfig);
|
|
561
|
+
/**
|
|
562
|
+
* Get a direct access token for the Anthropic proxy.
|
|
563
|
+
* Tokens are cached for 25 minutes (they expire after 30 minutes).
|
|
564
|
+
* @param forceRefresh - If true, ignores the cache and fetches a new token
|
|
565
|
+
*/
|
|
566
|
+
getDirectAccessToken(forceRefresh?: boolean): Promise<DirectAccessToken>;
|
|
567
|
+
/**
|
|
568
|
+
* Get the Anthropic proxy base URL
|
|
569
|
+
*/
|
|
570
|
+
getAnthropicProxyUrl(): string;
|
|
571
|
+
/**
|
|
572
|
+
* Invalidate the cached token
|
|
573
|
+
*/
|
|
574
|
+
invalidateToken(): void;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
export { BUNDLED_CLIENT_ID, DEFAULT_AI_GATEWAY_URL, type DirectAccessToken, GITLAB_COM_URL, type GitLabAgenticConfig, GitLabAgenticLanguageModel, type GitLabAgenticOptions, GitLabDirectAccessClient, type GitLabDirectAccessConfig, GitLabError, type GitLabErrorOptions, GitLabOAuthManager, type GitLabOAuthTokenResponse, type GitLabOAuthTokens, type GitLabProject, GitLabProjectCache, GitLabProjectDetector, type GitLabProjectDetectorConfig, type GitLabProvider, type GitLabProviderSettings, MODEL_ID_TO_ANTHROPIC_MODEL, OAUTH_SCOPES, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, TOKEN_EXPIRY_SKEW_MS, createGitLab, getAnthropicModelForModelId, gitlab };
|