@gitlab/gitlab-ai-provider 3.4.0 → 3.5.0
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 +10 -0
- package/dist/gitlab-gitlab-ai-provider-3.5.0.tgz +0 -0
- package/dist/index.d.mts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +112 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/gitlab-gitlab-ai-provider-3.4.0.tgz +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
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
|
+
## 3.5.0 (2026-02-06)
|
|
6
|
+
|
|
7
|
+
- Merge branch 'feat/add-opus-4-6' into 'main' ([b776bd7](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/b776bd7))
|
|
8
|
+
- feat(models): add Claude Opus 4.6 model support ([e221e45](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/e221e45))
|
|
9
|
+
|
|
10
|
+
## <small>3.4.1 (2026-02-06)</small>
|
|
11
|
+
|
|
12
|
+
- Merge branch 'vg/token_refresh_fix' into 'main' ([8c1f2c4](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/8c1f2c4))
|
|
13
|
+
- fix: detect context overflow errors before token refresh ([ce272cd](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/ce272cd))
|
|
14
|
+
|
|
5
15
|
## 3.4.0 (2026-02-02)
|
|
6
16
|
|
|
7
17
|
- Merge branch 'feat/ai-gateway-headers' into 'main' ([f2d4c79](https://gitlab.com/gitlab-org/editor-extensions/gitlab-ai-provider/commit/f2d4c79))
|
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -65,6 +65,11 @@ declare class GitLabAnthropicLanguageModel implements LanguageModelV2 {
|
|
|
65
65
|
* Check if an error is a token-related authentication error that can be retried
|
|
66
66
|
*/
|
|
67
67
|
private isTokenError;
|
|
68
|
+
/**
|
|
69
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
70
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
71
|
+
*/
|
|
72
|
+
private isContextOverflowError;
|
|
68
73
|
/**
|
|
69
74
|
* Convert AI SDK tools to Anthropic tool format
|
|
70
75
|
*/
|
|
@@ -265,6 +270,11 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
265
270
|
get provider(): string;
|
|
266
271
|
private getOpenAIClient;
|
|
267
272
|
private isTokenError;
|
|
273
|
+
/**
|
|
274
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
275
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
276
|
+
*/
|
|
277
|
+
private isContextOverflowError;
|
|
268
278
|
private convertTools;
|
|
269
279
|
private convertToolChoice;
|
|
270
280
|
private convertPrompt;
|
|
@@ -342,6 +352,11 @@ declare class GitLabError extends Error {
|
|
|
342
352
|
isRateLimitError(): boolean;
|
|
343
353
|
isForbiddenError(): boolean;
|
|
344
354
|
isServerError(): boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Check if this error is a context overflow error (prompt too long).
|
|
357
|
+
* These errors occur when the conversation exceeds the model's token limit.
|
|
358
|
+
*/
|
|
359
|
+
isContextOverflowError(): boolean;
|
|
345
360
|
}
|
|
346
361
|
|
|
347
362
|
declare const gitlabOAuthTokenResponseSchema: z.ZodObject<{
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,11 @@ declare class GitLabAnthropicLanguageModel implements LanguageModelV2 {
|
|
|
65
65
|
* Check if an error is a token-related authentication error that can be retried
|
|
66
66
|
*/
|
|
67
67
|
private isTokenError;
|
|
68
|
+
/**
|
|
69
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
70
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
71
|
+
*/
|
|
72
|
+
private isContextOverflowError;
|
|
68
73
|
/**
|
|
69
74
|
* Convert AI SDK tools to Anthropic tool format
|
|
70
75
|
*/
|
|
@@ -265,6 +270,11 @@ declare class GitLabOpenAILanguageModel implements LanguageModelV2 {
|
|
|
265
270
|
get provider(): string;
|
|
266
271
|
private getOpenAIClient;
|
|
267
272
|
private isTokenError;
|
|
273
|
+
/**
|
|
274
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
275
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
276
|
+
*/
|
|
277
|
+
private isContextOverflowError;
|
|
268
278
|
private convertTools;
|
|
269
279
|
private convertToolChoice;
|
|
270
280
|
private convertPrompt;
|
|
@@ -342,6 +352,11 @@ declare class GitLabError extends Error {
|
|
|
342
352
|
isRateLimitError(): boolean;
|
|
343
353
|
isForbiddenError(): boolean;
|
|
344
354
|
isServerError(): boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Check if this error is a context overflow error (prompt too long).
|
|
357
|
+
* These errors occur when the conversation exceeds the model's token limit.
|
|
358
|
+
*/
|
|
359
|
+
isContextOverflowError(): boolean;
|
|
345
360
|
}
|
|
346
361
|
|
|
347
362
|
declare const gitlabOAuthTokenResponseSchema: z.ZodObject<{
|
package/dist/index.js
CHANGED
|
@@ -96,6 +96,17 @@ var GitLabError = class _GitLabError extends Error {
|
|
|
96
96
|
isServerError() {
|
|
97
97
|
return this.statusCode !== void 0 && this.statusCode >= 500;
|
|
98
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Check if this error is a context overflow error (prompt too long).
|
|
101
|
+
* These errors occur when the conversation exceeds the model's token limit.
|
|
102
|
+
*/
|
|
103
|
+
isContextOverflowError() {
|
|
104
|
+
if (this.statusCode !== 400) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
const message = this.message?.toLowerCase() || "";
|
|
108
|
+
return message.includes("context overflow") || message.includes("prompt is too long") || message.includes("prompt too long") || message.includes("tokens") && message.includes("maximum");
|
|
109
|
+
}
|
|
99
110
|
};
|
|
100
111
|
|
|
101
112
|
// src/gitlab-direct-access.ts
|
|
@@ -266,6 +277,21 @@ var GitLabAnthropicLanguageModel = class {
|
|
|
266
277
|
}
|
|
267
278
|
return false;
|
|
268
279
|
}
|
|
280
|
+
/**
|
|
281
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
282
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
283
|
+
*/
|
|
284
|
+
isContextOverflowError(error) {
|
|
285
|
+
if (error instanceof import_sdk.default.APIError) {
|
|
286
|
+
if (error.status === 400) {
|
|
287
|
+
const message = error.message?.toLowerCase() || "";
|
|
288
|
+
if (message.includes("prompt is too long") || message.includes("prompt too long") || message.includes("tokens") && message.includes("maximum")) {
|
|
289
|
+
return true;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
269
295
|
/**
|
|
270
296
|
* Convert AI SDK tools to Anthropic tool format
|
|
271
297
|
*/
|
|
@@ -443,6 +469,14 @@ var GitLabAnthropicLanguageModel = class {
|
|
|
443
469
|
warnings: []
|
|
444
470
|
};
|
|
445
471
|
} catch (error) {
|
|
472
|
+
if (this.isContextOverflowError(error)) {
|
|
473
|
+
const apiError = error;
|
|
474
|
+
throw new GitLabError({
|
|
475
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
476
|
+
statusCode: 400,
|
|
477
|
+
cause: error
|
|
478
|
+
});
|
|
479
|
+
}
|
|
446
480
|
if (!isRetry && this.isTokenError(error)) {
|
|
447
481
|
this.directAccessClient.invalidateToken();
|
|
448
482
|
return this.doGenerateWithRetry(options, true);
|
|
@@ -450,6 +484,7 @@ var GitLabAnthropicLanguageModel = class {
|
|
|
450
484
|
if (error instanceof import_sdk.default.APIError) {
|
|
451
485
|
throw new GitLabError({
|
|
452
486
|
message: `Anthropic API error: ${error.message}`,
|
|
487
|
+
statusCode: error.status,
|
|
453
488
|
cause: error
|
|
454
489
|
});
|
|
455
490
|
}
|
|
@@ -630,6 +665,19 @@ var GitLabAnthropicLanguageModel = class {
|
|
|
630
665
|
});
|
|
631
666
|
}
|
|
632
667
|
}
|
|
668
|
+
if (self.isContextOverflowError(error)) {
|
|
669
|
+
const apiError = error;
|
|
670
|
+
controller.enqueue({
|
|
671
|
+
type: "error",
|
|
672
|
+
error: new GitLabError({
|
|
673
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
674
|
+
statusCode: 400,
|
|
675
|
+
cause: error
|
|
676
|
+
})
|
|
677
|
+
});
|
|
678
|
+
controller.close();
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
633
681
|
if (!isRetry && self.isTokenError(error)) {
|
|
634
682
|
self.directAccessClient.invalidateToken();
|
|
635
683
|
controller.enqueue({
|
|
@@ -647,6 +695,7 @@ var GitLabAnthropicLanguageModel = class {
|
|
|
647
695
|
type: "error",
|
|
648
696
|
error: new GitLabError({
|
|
649
697
|
message: `Anthropic API error: ${error.message}`,
|
|
698
|
+
statusCode: error.status,
|
|
650
699
|
cause: error
|
|
651
700
|
})
|
|
652
701
|
});
|
|
@@ -673,6 +722,7 @@ var import_openai = __toESM(require("openai"));
|
|
|
673
722
|
// src/model-mappings.ts
|
|
674
723
|
var MODEL_MAPPINGS = {
|
|
675
724
|
// Anthropic models
|
|
725
|
+
"duo-chat-opus-4-6": { provider: "anthropic", model: "claude-opus-4-6" },
|
|
676
726
|
"duo-chat-opus-4-5": { provider: "anthropic", model: "claude-opus-4-5-20251101" },
|
|
677
727
|
"duo-chat-sonnet-4-5": { provider: "anthropic", model: "claude-sonnet-4-5-20250929" },
|
|
678
728
|
"duo-chat-haiku-4-5": { provider: "anthropic", model: "claude-haiku-4-5-20251001" },
|
|
@@ -771,6 +821,21 @@ var GitLabOpenAILanguageModel = class {
|
|
|
771
821
|
}
|
|
772
822
|
return false;
|
|
773
823
|
}
|
|
824
|
+
/**
|
|
825
|
+
* Check if an error is a context overflow error (prompt too long)
|
|
826
|
+
* These should NOT trigger token refresh and should be reported to the user.
|
|
827
|
+
*/
|
|
828
|
+
isContextOverflowError(error) {
|
|
829
|
+
if (error instanceof import_openai.default.APIError) {
|
|
830
|
+
if (error.status === 400) {
|
|
831
|
+
const message = error.message?.toLowerCase() || "";
|
|
832
|
+
if (message.includes("prompt is too long") || message.includes("prompt too long") || message.includes("tokens") && message.includes("maximum")) {
|
|
833
|
+
return true;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
774
839
|
convertTools(tools) {
|
|
775
840
|
if (!tools || tools.length === 0) {
|
|
776
841
|
return void 0;
|
|
@@ -1051,6 +1116,14 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1051
1116
|
warnings: []
|
|
1052
1117
|
};
|
|
1053
1118
|
} catch (error) {
|
|
1119
|
+
if (this.isContextOverflowError(error)) {
|
|
1120
|
+
const apiError = error;
|
|
1121
|
+
throw new GitLabError({
|
|
1122
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
1123
|
+
statusCode: 400,
|
|
1124
|
+
cause: error
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1054
1127
|
if (!isRetry && this.isTokenError(error)) {
|
|
1055
1128
|
this.directAccessClient.invalidateToken();
|
|
1056
1129
|
return this.doGenerateWithChatApi(options, true);
|
|
@@ -1058,6 +1131,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1058
1131
|
if (error instanceof import_openai.default.APIError) {
|
|
1059
1132
|
throw new GitLabError({
|
|
1060
1133
|
message: `OpenAI API error: ${error.message}`,
|
|
1134
|
+
statusCode: error.status,
|
|
1061
1135
|
cause: error
|
|
1062
1136
|
});
|
|
1063
1137
|
}
|
|
@@ -1113,6 +1187,14 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1113
1187
|
warnings: []
|
|
1114
1188
|
};
|
|
1115
1189
|
} catch (error) {
|
|
1190
|
+
if (this.isContextOverflowError(error)) {
|
|
1191
|
+
const apiError = error;
|
|
1192
|
+
throw new GitLabError({
|
|
1193
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
1194
|
+
statusCode: 400,
|
|
1195
|
+
cause: error
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1116
1198
|
if (!isRetry && this.isTokenError(error)) {
|
|
1117
1199
|
this.directAccessClient.invalidateToken();
|
|
1118
1200
|
return this.doGenerateWithResponsesApi(options, true);
|
|
@@ -1120,6 +1202,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1120
1202
|
if (error instanceof import_openai.default.APIError) {
|
|
1121
1203
|
throw new GitLabError({
|
|
1122
1204
|
message: `OpenAI API error: ${error.message}`,
|
|
1205
|
+
statusCode: error.status,
|
|
1123
1206
|
cause: error
|
|
1124
1207
|
});
|
|
1125
1208
|
}
|
|
@@ -1238,6 +1321,19 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1238
1321
|
controller.enqueue({ type: "finish", finishReason, usage });
|
|
1239
1322
|
controller.close();
|
|
1240
1323
|
} catch (error) {
|
|
1324
|
+
if (self.isContextOverflowError(error)) {
|
|
1325
|
+
const apiError = error;
|
|
1326
|
+
controller.enqueue({
|
|
1327
|
+
type: "error",
|
|
1328
|
+
error: new GitLabError({
|
|
1329
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
1330
|
+
statusCode: 400,
|
|
1331
|
+
cause: error
|
|
1332
|
+
})
|
|
1333
|
+
});
|
|
1334
|
+
controller.close();
|
|
1335
|
+
return;
|
|
1336
|
+
}
|
|
1241
1337
|
if (!isRetry && self.isTokenError(error)) {
|
|
1242
1338
|
self.directAccessClient.invalidateToken();
|
|
1243
1339
|
controller.enqueue({
|
|
@@ -1252,6 +1348,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1252
1348
|
type: "error",
|
|
1253
1349
|
error: new GitLabError({
|
|
1254
1350
|
message: `OpenAI API error: ${error.message}`,
|
|
1351
|
+
statusCode: error.status,
|
|
1255
1352
|
cause: error
|
|
1256
1353
|
})
|
|
1257
1354
|
});
|
|
@@ -1378,6 +1475,19 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1378
1475
|
controller.enqueue({ type: "finish", finishReason, usage });
|
|
1379
1476
|
controller.close();
|
|
1380
1477
|
} catch (error) {
|
|
1478
|
+
if (self.isContextOverflowError(error)) {
|
|
1479
|
+
const apiError = error;
|
|
1480
|
+
controller.enqueue({
|
|
1481
|
+
type: "error",
|
|
1482
|
+
error: new GitLabError({
|
|
1483
|
+
message: `Context overflow: ${apiError.message}. Please start a new session or use /compact to reduce context.`,
|
|
1484
|
+
statusCode: 400,
|
|
1485
|
+
cause: error
|
|
1486
|
+
})
|
|
1487
|
+
});
|
|
1488
|
+
controller.close();
|
|
1489
|
+
return;
|
|
1490
|
+
}
|
|
1381
1491
|
if (!isRetry && self.isTokenError(error)) {
|
|
1382
1492
|
self.directAccessClient.invalidateToken();
|
|
1383
1493
|
controller.enqueue({
|
|
@@ -1392,6 +1502,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1392
1502
|
type: "error",
|
|
1393
1503
|
error: new GitLabError({
|
|
1394
1504
|
message: `OpenAI API error: ${error.message}`,
|
|
1505
|
+
statusCode: error.status,
|
|
1395
1506
|
cause: error
|
|
1396
1507
|
})
|
|
1397
1508
|
});
|
|
@@ -1569,7 +1680,7 @@ var GitLabOAuthManager = class {
|
|
|
1569
1680
|
};
|
|
1570
1681
|
|
|
1571
1682
|
// src/version.ts
|
|
1572
|
-
var VERSION = true ? "3.
|
|
1683
|
+
var VERSION = true ? "3.4.1" : "0.0.0-dev";
|
|
1573
1684
|
|
|
1574
1685
|
// src/gitlab-provider.ts
|
|
1575
1686
|
var fs = __toESM(require("fs"));
|