@gitlab/gitlab-ai-provider 3.0.9 → 3.1.1
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 +8 -0
- package/README.md +40 -0
- package/dist/gitlab-gitlab-ai-provider-3.1.1.tgz +0 -0
- package/dist/index.d.mts +64 -2
- package/dist/index.d.ts +64 -2
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -3
- package/dist/gitlab-gitlab-ai-provider-3.0.9.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
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.1 (2026-01-14)</small>
|
|
6
|
+
|
|
7
|
+
- fix: use models mapping for Anthropic ([7b876ec](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/7b876ec))
|
|
8
|
+
|
|
9
|
+
## 3.1.0 (2026-01-13)
|
|
10
|
+
|
|
11
|
+
- feat: improve npm metadata for better discoverability ([fc3795c](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/fc3795c))
|
|
12
|
+
|
|
5
13
|
## <small>3.0.9 (2026-01-07)</small>
|
|
6
14
|
|
|
7
15
|
- docs: removed unused documentation ([a5f3bdd](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/a5f3bdd))
|
package/README.md
CHANGED
|
@@ -75,6 +75,46 @@ const { text } = await generateText({
|
|
|
75
75
|
});
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
### Model Variants
|
|
79
|
+
|
|
80
|
+
The provider automatically maps specific model IDs to their corresponding Anthropic models:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { createGitLab } from '@gitlab/gitlab-ai-provider';
|
|
84
|
+
import { generateText } from 'ai';
|
|
85
|
+
|
|
86
|
+
const gitlab = createGitLab({
|
|
87
|
+
apiKey: process.env.GITLAB_TOKEN,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Use Claude Opus 4.5
|
|
91
|
+
const opusModel = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
92
|
+
// Automatically uses: claude-opus-4-5-20251101
|
|
93
|
+
|
|
94
|
+
// Use Claude Sonnet 4.5
|
|
95
|
+
const sonnetModel = gitlab.agenticChat('duo-chat-sonnet-4-5');
|
|
96
|
+
// Automatically uses: claude-sonnet-4-5-20250929
|
|
97
|
+
|
|
98
|
+
// Use Claude Haiku 4.5
|
|
99
|
+
const haikuModel = gitlab.agenticChat('duo-chat-haiku-4-5');
|
|
100
|
+
// Automatically uses: claude-haiku-4-5-20251001
|
|
101
|
+
|
|
102
|
+
// You can still override with explicit anthropicModel option
|
|
103
|
+
const customModel = gitlab.agenticChat('duo-chat-opus-4-5', {
|
|
104
|
+
anthropicModel: 'claude-sonnet-4-5-20250929', // Override mapping
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**Available Model Mappings:**
|
|
109
|
+
|
|
110
|
+
| Model ID | Anthropic Model |
|
|
111
|
+
| --------------------- | ---------------------------- |
|
|
112
|
+
| `duo-chat-opus-4-5` | `claude-opus-4-5-20251101` |
|
|
113
|
+
| `duo-chat-sonnet-4-5` | `claude-sonnet-4-5-20250929` |
|
|
114
|
+
| `duo-chat-haiku-4-5` | `claude-haiku-4-5-20251001` |
|
|
115
|
+
|
|
116
|
+
For unmapped model IDs, the provider defaults to `claude-sonnet-4-5-20250929`.
|
|
117
|
+
|
|
78
118
|
### Agentic Chat with Feature Flags
|
|
79
119
|
|
|
80
120
|
You can pass feature flags to enable experimental features in GitLab's Anthropic proxy:
|
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -95,6 +95,24 @@ interface GitLabProvider {
|
|
|
95
95
|
readonly specificationVersion: 'v2';
|
|
96
96
|
languageModel(modelId: string): LanguageModelV2;
|
|
97
97
|
chat(modelId: string): LanguageModelV2;
|
|
98
|
+
/**
|
|
99
|
+
* Create an agentic chat model with tool calling support
|
|
100
|
+
*
|
|
101
|
+
* @param modelId - GitLab model identifier. Some IDs automatically map to specific Anthropic models.
|
|
102
|
+
* @param options - Configuration options for the agentic model
|
|
103
|
+
* @returns A language model with native tool calling support via Anthropic
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Automatic model mapping
|
|
107
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
108
|
+
* // Uses claude-opus-4-5-20251101
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Explicit model override
|
|
112
|
+
* const model = gitlab.agenticChat('duo-chat', {
|
|
113
|
+
* anthropicModel: 'claude-sonnet-4-5-20250929'
|
|
114
|
+
* });
|
|
115
|
+
*/
|
|
98
116
|
agenticChat(modelId: string, options?: GitLabAgenticOptions): GitLabAgenticLanguageModel;
|
|
99
117
|
textEmbeddingModel(modelId: string): never;
|
|
100
118
|
imageModel(modelId: string): never;
|
|
@@ -102,7 +120,24 @@ interface GitLabProvider {
|
|
|
102
120
|
interface GitLabAgenticOptions {
|
|
103
121
|
/**
|
|
104
122
|
* The Anthropic model to use
|
|
105
|
-
*
|
|
123
|
+
*
|
|
124
|
+
* If not specified, automatically maps from the model ID:
|
|
125
|
+
* - 'duo-chat-opus-4-5' → 'claude-opus-4-5-20251101'
|
|
126
|
+
* - 'duo-chat-sonnet-4-5' → 'claude-sonnet-4-5-20250929'
|
|
127
|
+
* - 'duo-chat-haiku-4-5' → 'claude-haiku-4-5-20251001'
|
|
128
|
+
*
|
|
129
|
+
* For unmapped model IDs, defaults to 'claude-sonnet-4-5-20250929'
|
|
130
|
+
*
|
|
131
|
+
* @default Automatically mapped from model ID, or 'claude-sonnet-4-5-20250929'
|
|
132
|
+
* @example
|
|
133
|
+
* // Use automatic mapping
|
|
134
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Override with explicit model
|
|
138
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5', {
|
|
139
|
+
* anthropicModel: 'claude-sonnet-4-5-20250929'
|
|
140
|
+
* });
|
|
106
141
|
*/
|
|
107
142
|
anthropicModel?: string;
|
|
108
143
|
/**
|
|
@@ -168,6 +203,33 @@ declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
|
|
|
168
203
|
*/
|
|
169
204
|
declare const gitlab: GitLabProvider;
|
|
170
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Maps GitLab model IDs to their corresponding Anthropic model identifiers.
|
|
208
|
+
*
|
|
209
|
+
* This mapping allows users to specify model variants by model ID without
|
|
210
|
+
* needing to manually configure the anthropicModel option.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
214
|
+
* // Automatically uses 'claude-opus-4-5-20251101'
|
|
215
|
+
*/
|
|
216
|
+
declare const MODEL_ID_TO_ANTHROPIC_MODEL: Record<string, string>;
|
|
217
|
+
/**
|
|
218
|
+
* Gets the Anthropic model identifier for a given GitLab model ID.
|
|
219
|
+
*
|
|
220
|
+
* @param modelId - The GitLab model ID (e.g., 'duo-chat-opus-4-5')
|
|
221
|
+
* @returns The Anthropic model identifier, or undefined if no mapping exists
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* getAnthropicModelForModelId('duo-chat-opus-4-5')
|
|
225
|
+
* // Returns: 'claude-opus-4-5-20251101'
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* getAnthropicModelForModelId('duo-chat')
|
|
229
|
+
* // Returns: undefined (uses default)
|
|
230
|
+
*/
|
|
231
|
+
declare function getAnthropicModelForModelId(modelId: string): string | undefined;
|
|
232
|
+
|
|
171
233
|
interface GitLabErrorOptions {
|
|
172
234
|
message: string;
|
|
173
235
|
statusCode?: number;
|
|
@@ -522,4 +584,4 @@ declare class GitLabProjectDetector {
|
|
|
522
584
|
getCache(): GitLabProjectCache;
|
|
523
585
|
}
|
|
524
586
|
|
|
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 };
|
|
587
|
+
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, MODEL_ID_TO_ANTHROPIC_MODEL, OAUTH_SCOPES, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, TOKEN_EXPIRY_SKEW_MS, type ToolInput, type ToolResult, createGitLab, getAnthropicModelForModelId, gitlab, isGitLabApiTool };
|
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,24 @@ interface GitLabProvider {
|
|
|
95
95
|
readonly specificationVersion: 'v2';
|
|
96
96
|
languageModel(modelId: string): LanguageModelV2;
|
|
97
97
|
chat(modelId: string): LanguageModelV2;
|
|
98
|
+
/**
|
|
99
|
+
* Create an agentic chat model with tool calling support
|
|
100
|
+
*
|
|
101
|
+
* @param modelId - GitLab model identifier. Some IDs automatically map to specific Anthropic models.
|
|
102
|
+
* @param options - Configuration options for the agentic model
|
|
103
|
+
* @returns A language model with native tool calling support via Anthropic
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Automatic model mapping
|
|
107
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
108
|
+
* // Uses claude-opus-4-5-20251101
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* // Explicit model override
|
|
112
|
+
* const model = gitlab.agenticChat('duo-chat', {
|
|
113
|
+
* anthropicModel: 'claude-sonnet-4-5-20250929'
|
|
114
|
+
* });
|
|
115
|
+
*/
|
|
98
116
|
agenticChat(modelId: string, options?: GitLabAgenticOptions): GitLabAgenticLanguageModel;
|
|
99
117
|
textEmbeddingModel(modelId: string): never;
|
|
100
118
|
imageModel(modelId: string): never;
|
|
@@ -102,7 +120,24 @@ interface GitLabProvider {
|
|
|
102
120
|
interface GitLabAgenticOptions {
|
|
103
121
|
/**
|
|
104
122
|
* The Anthropic model to use
|
|
105
|
-
*
|
|
123
|
+
*
|
|
124
|
+
* If not specified, automatically maps from the model ID:
|
|
125
|
+
* - 'duo-chat-opus-4-5' → 'claude-opus-4-5-20251101'
|
|
126
|
+
* - 'duo-chat-sonnet-4-5' → 'claude-sonnet-4-5-20250929'
|
|
127
|
+
* - 'duo-chat-haiku-4-5' → 'claude-haiku-4-5-20251001'
|
|
128
|
+
*
|
|
129
|
+
* For unmapped model IDs, defaults to 'claude-sonnet-4-5-20250929'
|
|
130
|
+
*
|
|
131
|
+
* @default Automatically mapped from model ID, or 'claude-sonnet-4-5-20250929'
|
|
132
|
+
* @example
|
|
133
|
+
* // Use automatic mapping
|
|
134
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Override with explicit model
|
|
138
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5', {
|
|
139
|
+
* anthropicModel: 'claude-sonnet-4-5-20250929'
|
|
140
|
+
* });
|
|
106
141
|
*/
|
|
107
142
|
anthropicModel?: string;
|
|
108
143
|
/**
|
|
@@ -168,6 +203,33 @@ declare function createGitLab(options?: GitLabProviderSettings): GitLabProvider;
|
|
|
168
203
|
*/
|
|
169
204
|
declare const gitlab: GitLabProvider;
|
|
170
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Maps GitLab model IDs to their corresponding Anthropic model identifiers.
|
|
208
|
+
*
|
|
209
|
+
* This mapping allows users to specify model variants by model ID without
|
|
210
|
+
* needing to manually configure the anthropicModel option.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const model = gitlab.agenticChat('duo-chat-opus-4-5');
|
|
214
|
+
* // Automatically uses 'claude-opus-4-5-20251101'
|
|
215
|
+
*/
|
|
216
|
+
declare const MODEL_ID_TO_ANTHROPIC_MODEL: Record<string, string>;
|
|
217
|
+
/**
|
|
218
|
+
* Gets the Anthropic model identifier for a given GitLab model ID.
|
|
219
|
+
*
|
|
220
|
+
* @param modelId - The GitLab model ID (e.g., 'duo-chat-opus-4-5')
|
|
221
|
+
* @returns The Anthropic model identifier, or undefined if no mapping exists
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* getAnthropicModelForModelId('duo-chat-opus-4-5')
|
|
225
|
+
* // Returns: 'claude-opus-4-5-20251101'
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* getAnthropicModelForModelId('duo-chat')
|
|
229
|
+
* // Returns: undefined (uses default)
|
|
230
|
+
*/
|
|
231
|
+
declare function getAnthropicModelForModelId(modelId: string): string | undefined;
|
|
232
|
+
|
|
171
233
|
interface GitLabErrorOptions {
|
|
172
234
|
message: string;
|
|
173
235
|
statusCode?: number;
|
|
@@ -522,4 +584,4 @@ declare class GitLabProjectDetector {
|
|
|
522
584
|
getCache(): GitLabProjectCache;
|
|
523
585
|
}
|
|
524
586
|
|
|
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 };
|
|
587
|
+
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, MODEL_ID_TO_ANTHROPIC_MODEL, OAUTH_SCOPES, type OpenCodeAuth, type OpenCodeAuthApi, type OpenCodeAuthOAuth, TOKEN_EXPIRY_SKEW_MS, type ToolInput, type ToolResult, createGitLab, getAnthropicModelForModelId, gitlab, isGitLabApiTool };
|
package/dist/index.js
CHANGED
|
@@ -40,9 +40,11 @@ __export(index_exports, {
|
|
|
40
40
|
GitLabOAuthManager: () => GitLabOAuthManager,
|
|
41
41
|
GitLabProjectCache: () => GitLabProjectCache,
|
|
42
42
|
GitLabProjectDetector: () => GitLabProjectDetector,
|
|
43
|
+
MODEL_ID_TO_ANTHROPIC_MODEL: () => MODEL_ID_TO_ANTHROPIC_MODEL,
|
|
43
44
|
OAUTH_SCOPES: () => OAUTH_SCOPES,
|
|
44
45
|
TOKEN_EXPIRY_SKEW_MS: () => TOKEN_EXPIRY_SKEW_MS,
|
|
45
46
|
createGitLab: () => createGitLab,
|
|
47
|
+
getAnthropicModelForModelId: () => getAnthropicModelForModelId,
|
|
46
48
|
gitlab: () => gitlab,
|
|
47
49
|
isGitLabApiTool: () => isGitLabApiTool
|
|
48
50
|
});
|
|
@@ -749,6 +751,16 @@ var GitLabOAuthManager = class {
|
|
|
749
751
|
}
|
|
750
752
|
};
|
|
751
753
|
|
|
754
|
+
// src/model-mappings.ts
|
|
755
|
+
var MODEL_ID_TO_ANTHROPIC_MODEL = {
|
|
756
|
+
"duo-chat-opus-4-5": "claude-opus-4-5-20251101",
|
|
757
|
+
"duo-chat-sonnet-4-5": "claude-sonnet-4-5-20250929",
|
|
758
|
+
"duo-chat-haiku-4-5": "claude-haiku-4-5-20251001"
|
|
759
|
+
};
|
|
760
|
+
function getAnthropicModelForModelId(modelId) {
|
|
761
|
+
return MODEL_ID_TO_ANTHROPIC_MODEL[modelId];
|
|
762
|
+
}
|
|
763
|
+
|
|
752
764
|
// src/gitlab-provider.ts
|
|
753
765
|
var fs = __toESM(require("fs"));
|
|
754
766
|
var path = __toESM(require("path"));
|
|
@@ -895,7 +907,7 @@ function createGitLab(options = {}) {
|
|
|
895
907
|
getHeaders,
|
|
896
908
|
refreshApiKey,
|
|
897
909
|
fetch: options.fetch,
|
|
898
|
-
anthropicModel: agenticOptions?.anthropicModel,
|
|
910
|
+
anthropicModel: agenticOptions?.anthropicModel ?? getAnthropicModelForModelId(modelId),
|
|
899
911
|
maxTokens: agenticOptions?.maxTokens,
|
|
900
912
|
featureFlags
|
|
901
913
|
});
|
|
@@ -2392,9 +2404,11 @@ var GitLabProjectDetector = class {
|
|
|
2392
2404
|
GitLabOAuthManager,
|
|
2393
2405
|
GitLabProjectCache,
|
|
2394
2406
|
GitLabProjectDetector,
|
|
2407
|
+
MODEL_ID_TO_ANTHROPIC_MODEL,
|
|
2395
2408
|
OAUTH_SCOPES,
|
|
2396
2409
|
TOKEN_EXPIRY_SKEW_MS,
|
|
2397
2410
|
createGitLab,
|
|
2411
|
+
getAnthropicModelForModelId,
|
|
2398
2412
|
gitlab,
|
|
2399
2413
|
isGitLabApiTool
|
|
2400
2414
|
});
|