gitlab-ai-provider 5.3.2 → 6.0.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 +25 -0
- package/dist/gitlab-ai-provider-6.0.0.tgz +0 -0
- package/dist/index.d.mts +28 -47
- package/dist/index.d.ts +28 -47
- package/dist/index.js +198 -110
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +198 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/gitlab-ai-provider-5.3.2.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -171,7 +171,7 @@ var GitLabDirectAccessClient = class {
|
|
|
171
171
|
|
|
172
172
|
// src/gitlab-anthropic-language-model.ts
|
|
173
173
|
var GitLabAnthropicLanguageModel = class {
|
|
174
|
-
specificationVersion = "
|
|
174
|
+
specificationVersion = "v3";
|
|
175
175
|
modelId;
|
|
176
176
|
supportedUrls = {};
|
|
177
177
|
config;
|
|
@@ -330,10 +330,14 @@ ${message.content}` : message.content;
|
|
|
330
330
|
resultContent = part.output.value;
|
|
331
331
|
} else if (part.output.type === "json") {
|
|
332
332
|
resultContent = JSON.stringify(part.output.value);
|
|
333
|
+
} else if (part.output.type === "content") {
|
|
334
|
+
resultContent = JSON.stringify(part.output.value);
|
|
333
335
|
} else if (part.output.type === "error-text") {
|
|
334
336
|
resultContent = part.output.value;
|
|
335
337
|
} else if (part.output.type === "error-json") {
|
|
336
338
|
resultContent = JSON.stringify(part.output.value);
|
|
339
|
+
} else if (part.output.type === "execution-denied") {
|
|
340
|
+
resultContent = part.output.reason ?? "Tool execution denied.";
|
|
337
341
|
} else {
|
|
338
342
|
resultContent = JSON.stringify(part.output);
|
|
339
343
|
}
|
|
@@ -356,18 +360,41 @@ ${message.content}` : message.content;
|
|
|
356
360
|
* Convert Anthropic finish reason to AI SDK format
|
|
357
361
|
*/
|
|
358
362
|
convertFinishReason(stopReason) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
363
|
+
const unified = (() => {
|
|
364
|
+
switch (stopReason) {
|
|
365
|
+
case "end_turn":
|
|
366
|
+
return "stop";
|
|
367
|
+
case "stop_sequence":
|
|
368
|
+
return "stop";
|
|
369
|
+
case "max_tokens":
|
|
370
|
+
return "length";
|
|
371
|
+
case "tool_use":
|
|
372
|
+
return "tool-calls";
|
|
373
|
+
default:
|
|
374
|
+
return "other";
|
|
375
|
+
}
|
|
376
|
+
})();
|
|
377
|
+
return { unified, raw: stopReason ?? void 0 };
|
|
378
|
+
}
|
|
379
|
+
createUsage(params) {
|
|
380
|
+
const inputTotal = params?.inputTotal;
|
|
381
|
+
const outputTotal = params?.outputTotal;
|
|
382
|
+
const cacheRead = params?.cacheRead;
|
|
383
|
+
const cacheWrite = params?.cacheWrite;
|
|
384
|
+
return {
|
|
385
|
+
inputTokens: {
|
|
386
|
+
total: inputTotal,
|
|
387
|
+
noCache: inputTotal == null ? void 0 : Math.max(0, inputTotal - (cacheRead ?? 0) - (cacheWrite ?? 0)),
|
|
388
|
+
cacheRead,
|
|
389
|
+
cacheWrite
|
|
390
|
+
},
|
|
391
|
+
outputTokens: {
|
|
392
|
+
total: outputTotal,
|
|
393
|
+
text: outputTotal,
|
|
394
|
+
reasoning: params?.outputReasoning
|
|
395
|
+
},
|
|
396
|
+
raw: params?.raw
|
|
397
|
+
};
|
|
371
398
|
}
|
|
372
399
|
async doGenerate(options) {
|
|
373
400
|
return this.doGenerateWithRetry(options, false);
|
|
@@ -407,11 +434,13 @@ ${message.content}` : message.content;
|
|
|
407
434
|
});
|
|
408
435
|
}
|
|
409
436
|
}
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
437
|
+
const rawUsage = response.usage;
|
|
438
|
+
const usage = this.createUsage({
|
|
439
|
+
inputTotal: response.usage.input_tokens,
|
|
440
|
+
outputTotal: response.usage.output_tokens,
|
|
441
|
+
cacheRead: rawUsage.cache_read_input_tokens,
|
|
442
|
+
cacheWrite: rawUsage.cache_creation_input_tokens
|
|
443
|
+
});
|
|
415
444
|
return {
|
|
416
445
|
content,
|
|
417
446
|
finishReason: this.convertFinishReason(response.stop_reason),
|
|
@@ -467,12 +496,8 @@ ${message.content}` : message.content;
|
|
|
467
496
|
const stream = new ReadableStream({
|
|
468
497
|
start: async (controller) => {
|
|
469
498
|
const contentBlocks = {};
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
outputTokens: 0,
|
|
473
|
-
totalTokens: 0
|
|
474
|
-
};
|
|
475
|
-
let finishReason = "unknown";
|
|
499
|
+
let usage = self.createUsage();
|
|
500
|
+
let finishReason = { unified: "other", raw: void 0 };
|
|
476
501
|
try {
|
|
477
502
|
const anthropicStream = client.messages.stream(requestBody, {
|
|
478
503
|
signal: options.abortSignal
|
|
@@ -487,7 +512,14 @@ ${message.content}` : message.content;
|
|
|
487
512
|
switch (event.type) {
|
|
488
513
|
case "message_start":
|
|
489
514
|
if (event.message.usage) {
|
|
490
|
-
usage
|
|
515
|
+
usage = self.createUsage({
|
|
516
|
+
inputTotal: event.message.usage.input_tokens,
|
|
517
|
+
outputTotal: usage.outputTokens.total,
|
|
518
|
+
outputReasoning: usage.outputTokens.reasoning,
|
|
519
|
+
cacheRead: usage.inputTokens.cacheRead,
|
|
520
|
+
cacheWrite: usage.inputTokens.cacheWrite,
|
|
521
|
+
raw: usage.raw
|
|
522
|
+
});
|
|
491
523
|
}
|
|
492
524
|
controller.enqueue({
|
|
493
525
|
type: "response-metadata",
|
|
@@ -559,8 +591,14 @@ ${message.content}` : message.content;
|
|
|
559
591
|
}
|
|
560
592
|
case "message_delta":
|
|
561
593
|
if (event.usage) {
|
|
562
|
-
usage
|
|
563
|
-
|
|
594
|
+
usage = self.createUsage({
|
|
595
|
+
inputTotal: usage.inputTokens.total,
|
|
596
|
+
outputTotal: event.usage.output_tokens,
|
|
597
|
+
outputReasoning: usage.outputTokens.reasoning,
|
|
598
|
+
cacheRead: usage.inputTokens.cacheRead,
|
|
599
|
+
cacheWrite: usage.inputTokens.cacheWrite,
|
|
600
|
+
raw: usage.raw
|
|
601
|
+
});
|
|
564
602
|
}
|
|
565
603
|
if (event.delta.stop_reason) {
|
|
566
604
|
finishReason = self.convertFinishReason(event.delta.stop_reason);
|
|
@@ -760,7 +798,7 @@ var MODEL_ID_TO_ANTHROPIC_MODEL = Object.fromEntries(
|
|
|
760
798
|
|
|
761
799
|
// src/gitlab-openai-language-model.ts
|
|
762
800
|
var GitLabOpenAILanguageModel = class {
|
|
763
|
-
specificationVersion = "
|
|
801
|
+
specificationVersion = "v3";
|
|
764
802
|
modelId;
|
|
765
803
|
supportedUrls = {};
|
|
766
804
|
config;
|
|
@@ -906,10 +944,14 @@ var GitLabOpenAILanguageModel = class {
|
|
|
906
944
|
resultContent = part.output.value;
|
|
907
945
|
} else if (part.output.type === "json") {
|
|
908
946
|
resultContent = JSON.stringify(part.output.value);
|
|
947
|
+
} else if (part.output.type === "content") {
|
|
948
|
+
resultContent = JSON.stringify(part.output.value);
|
|
909
949
|
} else if (part.output.type === "error-text") {
|
|
910
950
|
resultContent = part.output.value;
|
|
911
951
|
} else if (part.output.type === "error-json") {
|
|
912
952
|
resultContent = JSON.stringify(part.output.value);
|
|
953
|
+
} else if (part.output.type === "execution-denied") {
|
|
954
|
+
resultContent = part.output.reason ?? "Tool execution denied.";
|
|
913
955
|
} else {
|
|
914
956
|
resultContent = JSON.stringify(part.output);
|
|
915
957
|
}
|
|
@@ -925,18 +967,40 @@ var GitLabOpenAILanguageModel = class {
|
|
|
925
967
|
return messages;
|
|
926
968
|
}
|
|
927
969
|
convertFinishReason(finishReason) {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
970
|
+
const unified = (() => {
|
|
971
|
+
switch (finishReason) {
|
|
972
|
+
case "stop":
|
|
973
|
+
return "stop";
|
|
974
|
+
case "length":
|
|
975
|
+
return "length";
|
|
976
|
+
case "tool_calls":
|
|
977
|
+
return "tool-calls";
|
|
978
|
+
case "content_filter":
|
|
979
|
+
return "content-filter";
|
|
980
|
+
default:
|
|
981
|
+
return "other";
|
|
982
|
+
}
|
|
983
|
+
})();
|
|
984
|
+
return { unified, raw: finishReason ?? void 0 };
|
|
985
|
+
}
|
|
986
|
+
createUsage(params) {
|
|
987
|
+
const inputTotal = params?.inputTotal;
|
|
988
|
+
const outputTotal = params?.outputTotal;
|
|
989
|
+
const cacheRead = params?.cacheRead;
|
|
990
|
+
return {
|
|
991
|
+
inputTokens: {
|
|
992
|
+
total: inputTotal,
|
|
993
|
+
noCache: inputTotal == null ? void 0 : Math.max(0, inputTotal - (cacheRead ?? 0)),
|
|
994
|
+
cacheRead,
|
|
995
|
+
cacheWrite: void 0
|
|
996
|
+
},
|
|
997
|
+
outputTokens: {
|
|
998
|
+
total: outputTotal,
|
|
999
|
+
text: outputTotal,
|
|
1000
|
+
reasoning: params?.outputReasoning
|
|
1001
|
+
},
|
|
1002
|
+
raw: params?.raw
|
|
1003
|
+
};
|
|
940
1004
|
}
|
|
941
1005
|
/**
|
|
942
1006
|
* Convert tools to Responses API format
|
|
@@ -953,7 +1017,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
953
1017
|
name: tool.name,
|
|
954
1018
|
description: tool.description || "",
|
|
955
1019
|
parameters: schema,
|
|
956
|
-
strict:
|
|
1020
|
+
strict: tool.strict
|
|
957
1021
|
};
|
|
958
1022
|
});
|
|
959
1023
|
}
|
|
@@ -1004,10 +1068,14 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1004
1068
|
resultContent = part.output.value;
|
|
1005
1069
|
} else if (part.output.type === "json") {
|
|
1006
1070
|
resultContent = JSON.stringify(part.output.value);
|
|
1071
|
+
} else if (part.output.type === "content") {
|
|
1072
|
+
resultContent = JSON.stringify(part.output.value);
|
|
1007
1073
|
} else if (part.output.type === "error-text") {
|
|
1008
1074
|
resultContent = part.output.value;
|
|
1009
1075
|
} else if (part.output.type === "error-json") {
|
|
1010
1076
|
resultContent = JSON.stringify(part.output.value);
|
|
1077
|
+
} else if (part.output.type === "execution-denied") {
|
|
1078
|
+
resultContent = part.output.reason ?? "Tool execution denied.";
|
|
1011
1079
|
} else {
|
|
1012
1080
|
resultContent = JSON.stringify(part.output);
|
|
1013
1081
|
}
|
|
@@ -1036,20 +1104,23 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1036
1104
|
*/
|
|
1037
1105
|
convertResponsesStatus(status, hasToolCalls = false) {
|
|
1038
1106
|
if (hasToolCalls) {
|
|
1039
|
-
return "tool-calls";
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1107
|
+
return { unified: "tool-calls", raw: status };
|
|
1108
|
+
}
|
|
1109
|
+
const unified = (() => {
|
|
1110
|
+
switch (status) {
|
|
1111
|
+
case "completed":
|
|
1112
|
+
return "stop";
|
|
1113
|
+
case "incomplete":
|
|
1114
|
+
return "length";
|
|
1115
|
+
case "cancelled":
|
|
1116
|
+
return "stop";
|
|
1117
|
+
case "failed":
|
|
1118
|
+
return "error";
|
|
1119
|
+
default:
|
|
1120
|
+
return "other";
|
|
1121
|
+
}
|
|
1122
|
+
})();
|
|
1123
|
+
return { unified, raw: status };
|
|
1053
1124
|
}
|
|
1054
1125
|
async doGenerate(options) {
|
|
1055
1126
|
if (this.useResponsesApi) {
|
|
@@ -1092,11 +1163,12 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1092
1163
|
}
|
|
1093
1164
|
}
|
|
1094
1165
|
}
|
|
1095
|
-
const usage = {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1166
|
+
const usage = this.createUsage({
|
|
1167
|
+
inputTotal: response.usage?.prompt_tokens,
|
|
1168
|
+
outputTotal: response.usage?.completion_tokens,
|
|
1169
|
+
cacheRead: response.usage?.prompt_tokens_details?.cached_tokens,
|
|
1170
|
+
raw: { total_tokens: response.usage?.total_tokens }
|
|
1171
|
+
});
|
|
1100
1172
|
return {
|
|
1101
1173
|
content,
|
|
1102
1174
|
finishReason: this.convertFinishReason(choice?.finish_reason),
|
|
@@ -1163,11 +1235,13 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1163
1235
|
});
|
|
1164
1236
|
}
|
|
1165
1237
|
}
|
|
1166
|
-
const usage = {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1238
|
+
const usage = this.createUsage({
|
|
1239
|
+
inputTotal: response.usage?.input_tokens,
|
|
1240
|
+
outputTotal: response.usage?.output_tokens,
|
|
1241
|
+
outputReasoning: response.usage?.output_tokens_details?.reasoning_tokens,
|
|
1242
|
+
cacheRead: response.usage?.input_tokens_details?.cached_tokens,
|
|
1243
|
+
raw: { total_tokens: response.usage?.total_tokens }
|
|
1244
|
+
});
|
|
1171
1245
|
return {
|
|
1172
1246
|
content,
|
|
1173
1247
|
finishReason: this.convertResponsesStatus(response.status, hasToolCalls),
|
|
@@ -1226,12 +1300,8 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1226
1300
|
const stream = new ReadableStream({
|
|
1227
1301
|
start: async (controller) => {
|
|
1228
1302
|
const toolCalls = {};
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
outputTokens: 0,
|
|
1232
|
-
totalTokens: 0
|
|
1233
|
-
};
|
|
1234
|
-
let finishReason = "unknown";
|
|
1303
|
+
let usage = self.createUsage();
|
|
1304
|
+
let finishReason = { unified: "other", raw: void 0 };
|
|
1235
1305
|
let textStarted = false;
|
|
1236
1306
|
const textId = "text-0";
|
|
1237
1307
|
try {
|
|
@@ -1289,9 +1359,12 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1289
1359
|
finishReason = self.convertFinishReason(choice.finish_reason);
|
|
1290
1360
|
}
|
|
1291
1361
|
if (chunk.usage) {
|
|
1292
|
-
usage
|
|
1293
|
-
|
|
1294
|
-
|
|
1362
|
+
usage = self.createUsage({
|
|
1363
|
+
inputTotal: chunk.usage.prompt_tokens,
|
|
1364
|
+
outputTotal: chunk.usage.completion_tokens,
|
|
1365
|
+
cacheRead: chunk.usage.prompt_tokens_details?.cached_tokens,
|
|
1366
|
+
raw: { total_tokens: chunk.usage.total_tokens }
|
|
1367
|
+
});
|
|
1295
1368
|
}
|
|
1296
1369
|
}
|
|
1297
1370
|
if (textStarted) {
|
|
@@ -1371,12 +1444,8 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1371
1444
|
const stream = new ReadableStream({
|
|
1372
1445
|
start: async (controller) => {
|
|
1373
1446
|
const toolCalls = {};
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
outputTokens: 0,
|
|
1377
|
-
totalTokens: 0
|
|
1378
|
-
};
|
|
1379
|
-
let finishReason = "unknown";
|
|
1447
|
+
let usage = self.createUsage();
|
|
1448
|
+
let finishReason = { unified: "other", raw: void 0 };
|
|
1380
1449
|
let textStarted = false;
|
|
1381
1450
|
const textId = "text-0";
|
|
1382
1451
|
try {
|
|
@@ -1438,9 +1507,13 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1438
1507
|
const hasToolCalls2 = Object.keys(toolCalls).length > 0;
|
|
1439
1508
|
finishReason = self.convertResponsesStatus(event.response.status, hasToolCalls2);
|
|
1440
1509
|
if (event.response.usage) {
|
|
1441
|
-
usage
|
|
1442
|
-
|
|
1443
|
-
|
|
1510
|
+
usage = self.createUsage({
|
|
1511
|
+
inputTotal: event.response.usage.input_tokens,
|
|
1512
|
+
outputTotal: event.response.usage.output_tokens,
|
|
1513
|
+
outputReasoning: event.response.usage.output_tokens_details?.reasoning_tokens,
|
|
1514
|
+
cacheRead: event.response.usage.input_tokens_details?.cached_tokens,
|
|
1515
|
+
raw: { total_tokens: event.response.usage.total_tokens }
|
|
1516
|
+
});
|
|
1444
1517
|
}
|
|
1445
1518
|
}
|
|
1446
1519
|
}
|
|
@@ -1448,8 +1521,8 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1448
1521
|
controller.enqueue({ type: "text-end", id: textId });
|
|
1449
1522
|
}
|
|
1450
1523
|
const hasToolCalls = Object.keys(toolCalls).length > 0;
|
|
1451
|
-
if (hasToolCalls && finishReason === "stop") {
|
|
1452
|
-
finishReason = "tool-calls";
|
|
1524
|
+
if (hasToolCalls && finishReason.unified === "stop") {
|
|
1525
|
+
finishReason = { unified: "tool-calls", raw: finishReason.raw };
|
|
1453
1526
|
}
|
|
1454
1527
|
for (const tc of Object.values(toolCalls)) {
|
|
1455
1528
|
controller.enqueue({ type: "tool-input-end", id: tc.callId });
|
|
@@ -1509,7 +1582,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1509
1582
|
import WebSocket from "isomorphic-ws";
|
|
1510
1583
|
|
|
1511
1584
|
// src/version.ts
|
|
1512
|
-
var VERSION = true ? "5.3.
|
|
1585
|
+
var VERSION = true ? "5.3.3" : "0.0.0-dev";
|
|
1513
1586
|
|
|
1514
1587
|
// src/gitlab-workflow-types.ts
|
|
1515
1588
|
var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
|
|
@@ -1735,6 +1808,8 @@ var GitLabWorkflowClient = class {
|
|
|
1735
1808
|
});
|
|
1736
1809
|
} else if (checkpoint.status === "STOPPED" || checkpoint.status === "CANCELLED") {
|
|
1737
1810
|
this.emit({ type: "completed" });
|
|
1811
|
+
} else if (checkpoint.status === "TOOL_CALL_APPROVAL_REQUIRED" || checkpoint.status === "PLAN_APPROVAL_REQUIRED") {
|
|
1812
|
+
this.emit({ type: "completed" });
|
|
1738
1813
|
}
|
|
1739
1814
|
return;
|
|
1740
1815
|
}
|
|
@@ -2871,7 +2946,7 @@ function minimalSchema(schemaStr) {
|
|
|
2871
2946
|
}
|
|
2872
2947
|
}
|
|
2873
2948
|
var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
2874
|
-
specificationVersion = "
|
|
2949
|
+
specificationVersion = "v3";
|
|
2875
2950
|
modelId;
|
|
2876
2951
|
supportedUrls = {};
|
|
2877
2952
|
config;
|
|
@@ -3172,16 +3247,34 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3172
3247
|
get workflowId() {
|
|
3173
3248
|
return this.currentWorkflowId;
|
|
3174
3249
|
}
|
|
3250
|
+
createUsage(params) {
|
|
3251
|
+
return {
|
|
3252
|
+
inputTokens: {
|
|
3253
|
+
total: params?.inputTotal,
|
|
3254
|
+
noCache: params?.inputTotal,
|
|
3255
|
+
cacheRead: void 0,
|
|
3256
|
+
cacheWrite: void 0
|
|
3257
|
+
},
|
|
3258
|
+
outputTokens: {
|
|
3259
|
+
total: params?.outputTotal,
|
|
3260
|
+
text: params?.outputTotal,
|
|
3261
|
+
reasoning: void 0
|
|
3262
|
+
}
|
|
3263
|
+
};
|
|
3264
|
+
}
|
|
3265
|
+
createFinishReason(unified, raw) {
|
|
3266
|
+
return { unified, raw };
|
|
3267
|
+
}
|
|
3175
3268
|
// ---------------------------------------------------------------------------
|
|
3176
|
-
//
|
|
3269
|
+
// LanguageModelV3 — doGenerate (non-streaming)
|
|
3177
3270
|
// ---------------------------------------------------------------------------
|
|
3178
3271
|
async doGenerate(options) {
|
|
3179
3272
|
const { stream } = await this.doStream(options);
|
|
3180
3273
|
const reader = stream.getReader();
|
|
3181
3274
|
const textParts = [];
|
|
3182
3275
|
const toolCalls = [];
|
|
3183
|
-
let finishReason = "
|
|
3184
|
-
|
|
3276
|
+
let finishReason = { unified: "other", raw: void 0 };
|
|
3277
|
+
let usage = this.createUsage();
|
|
3185
3278
|
try {
|
|
3186
3279
|
while (true) {
|
|
3187
3280
|
const { done, value } = await reader.read();
|
|
@@ -3201,9 +3294,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3201
3294
|
case "finish":
|
|
3202
3295
|
finishReason = value.finishReason;
|
|
3203
3296
|
if (value.usage) {
|
|
3204
|
-
usage
|
|
3205
|
-
usage.outputTokens = value.usage.outputTokens ?? 0;
|
|
3206
|
-
usage.totalTokens = value.usage.totalTokens ?? 0;
|
|
3297
|
+
usage = value.usage;
|
|
3207
3298
|
}
|
|
3208
3299
|
break;
|
|
3209
3300
|
case "error":
|
|
@@ -3222,7 +3313,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3222
3313
|
return { content, finishReason, usage, warnings: [] };
|
|
3223
3314
|
}
|
|
3224
3315
|
// ---------------------------------------------------------------------------
|
|
3225
|
-
//
|
|
3316
|
+
// LanguageModelV3 — doStream (streaming)
|
|
3226
3317
|
// ---------------------------------------------------------------------------
|
|
3227
3318
|
async doStream(options) {
|
|
3228
3319
|
const goal = this.extractGoalFromPrompt(options.prompt);
|
|
@@ -3488,8 +3579,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3488
3579
|
const outputTokens = Math.ceil(ss.streamedOutputChars / 4);
|
|
3489
3580
|
controller.enqueue({
|
|
3490
3581
|
type: "finish",
|
|
3491
|
-
finishReason: "stop",
|
|
3492
|
-
usage: { inputTokens,
|
|
3582
|
+
finishReason: this.createFinishReason("stop", "completed"),
|
|
3583
|
+
usage: this.createUsage({ inputTotal: inputTokens, outputTotal: outputTokens })
|
|
3493
3584
|
});
|
|
3494
3585
|
ss.streamClosed = true;
|
|
3495
3586
|
controller.close();
|
|
@@ -3546,8 +3637,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3546
3637
|
const outTok = Math.ceil(ss.streamedOutputChars / 4);
|
|
3547
3638
|
controller.enqueue({
|
|
3548
3639
|
type: "finish",
|
|
3549
|
-
finishReason: "stop",
|
|
3550
|
-
usage: {
|
|
3640
|
+
finishReason: this.createFinishReason("stop", "closed"),
|
|
3641
|
+
usage: this.createUsage({ inputTotal: inTok, outputTotal: outTok })
|
|
3551
3642
|
});
|
|
3552
3643
|
ss.streamClosed = true;
|
|
3553
3644
|
controller.close();
|
|
@@ -3593,7 +3684,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3593
3684
|
if (!chatLog || !Array.isArray(chatLog) || chatLog.length === 0) {
|
|
3594
3685
|
return;
|
|
3595
3686
|
}
|
|
3596
|
-
if (checkpoint.status !== "RUNNING" && checkpoint.status !== "INPUT_REQUIRED" && checkpoint.status !== "FINISHED" && checkpoint.status !== "COMPLETED") {
|
|
3687
|
+
if (checkpoint.status !== "RUNNING" && checkpoint.status !== "INPUT_REQUIRED" && checkpoint.status !== "FINISHED" && checkpoint.status !== "COMPLETED" && checkpoint.status !== "TOOL_CALL_APPROVAL_REQUIRED") {
|
|
3597
3688
|
return;
|
|
3598
3689
|
}
|
|
3599
3690
|
for (let i = 0; i < chatLog.length; i++) {
|
|
@@ -3664,8 +3755,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3664
3755
|
toolCallId: requestID,
|
|
3665
3756
|
toolName,
|
|
3666
3757
|
result: errorText,
|
|
3667
|
-
isError: true
|
|
3668
|
-
providerExecuted: true
|
|
3758
|
+
isError: true
|
|
3669
3759
|
});
|
|
3670
3760
|
} else {
|
|
3671
3761
|
safeEnqueue({
|
|
@@ -3677,8 +3767,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3677
3767
|
title: toolTitle,
|
|
3678
3768
|
metadata: toolMetadata
|
|
3679
3769
|
},
|
|
3680
|
-
isError: false
|
|
3681
|
-
providerExecuted: true
|
|
3770
|
+
isError: false
|
|
3682
3771
|
});
|
|
3683
3772
|
}
|
|
3684
3773
|
} else {
|
|
@@ -3689,8 +3778,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3689
3778
|
toolCallId: requestID,
|
|
3690
3779
|
toolName,
|
|
3691
3780
|
result: errorMsg,
|
|
3692
|
-
isError: true
|
|
3693
|
-
providerExecuted: true
|
|
3781
|
+
isError: true
|
|
3694
3782
|
});
|
|
3695
3783
|
}
|
|
3696
3784
|
} catch (error) {
|
|
@@ -3702,8 +3790,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3702
3790
|
toolCallId: requestID,
|
|
3703
3791
|
toolName,
|
|
3704
3792
|
result: errorMsg,
|
|
3705
|
-
isError: true
|
|
3706
|
-
providerExecuted: true
|
|
3793
|
+
isError: true
|
|
3707
3794
|
});
|
|
3708
3795
|
} finally {
|
|
3709
3796
|
ss.pendingToolCount--;
|
|
@@ -3739,7 +3826,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3739
3826
|
// ---------------------------------------------------------------------------
|
|
3740
3827
|
async buildWorkflowMetadata() {
|
|
3741
3828
|
const metadata = {
|
|
3742
|
-
extended_logging: false
|
|
3829
|
+
extended_logging: false,
|
|
3830
|
+
tool_approval_for_session_enabled: true
|
|
3743
3831
|
};
|
|
3744
3832
|
try {
|
|
3745
3833
|
const workDir = this.workflowOptions.workingDirectory ?? process.cwd();
|
|
@@ -4301,13 +4389,13 @@ function createGitLab(options = {}) {
|
|
|
4301
4389
|
return createAgenticChatModel(modelId);
|
|
4302
4390
|
};
|
|
4303
4391
|
const provider = Object.assign((modelId) => createDefaultModel(modelId), {
|
|
4304
|
-
specificationVersion: "
|
|
4392
|
+
specificationVersion: "v3",
|
|
4305
4393
|
languageModel: createDefaultModel,
|
|
4306
4394
|
chat: createDefaultModel,
|
|
4307
4395
|
agenticChat: createAgenticChatModel,
|
|
4308
4396
|
workflowChat: createWorkflowChatModel
|
|
4309
4397
|
});
|
|
4310
|
-
provider.
|
|
4398
|
+
provider.embeddingModel = (modelId) => {
|
|
4311
4399
|
throw new GitLabError({
|
|
4312
4400
|
message: `GitLab provider does not support text embedding models. Model ID: ${modelId}`
|
|
4313
4401
|
});
|