gitlab-ai-provider 6.3.0 → 6.4.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 +9 -0
- package/README.md +33 -0
- package/dist/gitlab-ai-provider-6.4.1.tgz +0 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +75 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +75 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/gitlab-ai-provider-6.3.0.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1582,7 +1582,7 @@ var GitLabOpenAILanguageModel = class {
|
|
|
1582
1582
|
import WebSocket from "isomorphic-ws";
|
|
1583
1583
|
|
|
1584
1584
|
// src/version.ts
|
|
1585
|
-
var VERSION = true ? "6.
|
|
1585
|
+
var VERSION = true ? "6.4.0" : "0.0.0-dev";
|
|
1586
1586
|
|
|
1587
1587
|
// src/gitlab-workflow-types.ts
|
|
1588
1588
|
var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
|
|
@@ -1766,6 +1766,12 @@ var GitLabWorkflowClient = class {
|
|
|
1766
1766
|
if (options.modelRef && options.modelRef !== "default") {
|
|
1767
1767
|
url.searchParams.set("user_selected_model_identifier", options.modelRef);
|
|
1768
1768
|
}
|
|
1769
|
+
if (options.aiCatalogItemVersionId) {
|
|
1770
|
+
url.searchParams.set("ai_catalog_item_version_id", String(options.aiCatalogItemVersionId));
|
|
1771
|
+
}
|
|
1772
|
+
if (options.workflowDefinition) {
|
|
1773
|
+
url.searchParams.set("workflow_definition", options.workflowDefinition);
|
|
1774
|
+
}
|
|
1769
1775
|
return url.toString();
|
|
1770
1776
|
}
|
|
1771
1777
|
buildWebSocketHeaders(options) {
|
|
@@ -3413,7 +3419,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3413
3419
|
this.sessionWorkflows.set(sessionKey, {
|
|
3414
3420
|
workflowId,
|
|
3415
3421
|
workflowDefinition: effectiveDefinition,
|
|
3416
|
-
agentEmitted: /* @__PURE__ */ new Map()
|
|
3422
|
+
agentEmitted: /* @__PURE__ */ new Map(),
|
|
3423
|
+
toolEntries: /* @__PURE__ */ new Set()
|
|
3417
3424
|
});
|
|
3418
3425
|
sess = this.sessionWorkflows.get(sessionKey);
|
|
3419
3426
|
}
|
|
@@ -3433,6 +3440,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3433
3440
|
currentAgentMessageId: "",
|
|
3434
3441
|
activeClient: wsClient,
|
|
3435
3442
|
processedRequestIDs: /* @__PURE__ */ new Set(),
|
|
3443
|
+
emittedToolEntries: new Set(sess?.toolEntries),
|
|
3444
|
+
emittedToolKeys: /* @__PURE__ */ new Set(),
|
|
3436
3445
|
sessionKey
|
|
3437
3446
|
};
|
|
3438
3447
|
for (const msg of options.prompt) {
|
|
@@ -3457,7 +3466,9 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3457
3466
|
headers: this.config.getHeaders(),
|
|
3458
3467
|
projectId: this.workflowOptions.projectId,
|
|
3459
3468
|
namespaceId: this.workflowOptions.namespaceId,
|
|
3460
|
-
rootNamespaceId: this.workflowOptions.rootNamespaceId
|
|
3469
|
+
rootNamespaceId: this.workflowOptions.rootNamespaceId,
|
|
3470
|
+
aiCatalogItemVersionId: callAiCatalogItemVersionId,
|
|
3471
|
+
workflowDefinition: callWorkflowDefinition ?? this.workflowOptions.workflowDefinition
|
|
3461
3472
|
},
|
|
3462
3473
|
(event) => {
|
|
3463
3474
|
this.handleWorkflowEvent(
|
|
@@ -3468,7 +3479,11 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3468
3479
|
toolExecutor,
|
|
3469
3480
|
() => `text-${textBlockCounter++}`,
|
|
3470
3481
|
availableToolNames,
|
|
3471
|
-
startReq
|
|
3482
|
+
startReq,
|
|
3483
|
+
{
|
|
3484
|
+
aiCatalogItemVersionId: callAiCatalogItemVersionId,
|
|
3485
|
+
workflowDefinition: callWorkflowDefinition ?? this.workflowOptions.workflowDefinition
|
|
3486
|
+
}
|
|
3472
3487
|
);
|
|
3473
3488
|
}
|
|
3474
3489
|
);
|
|
@@ -3563,7 +3578,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3563
3578
|
// ---------------------------------------------------------------------------
|
|
3564
3579
|
// Event handling
|
|
3565
3580
|
// ---------------------------------------------------------------------------
|
|
3566
|
-
handleWorkflowEvent(ss, event, controller, wsClient, toolExecutor, nextTextId, availableToolNames, startReq) {
|
|
3581
|
+
handleWorkflowEvent(ss, event, controller, wsClient, toolExecutor, nextTextId, availableToolNames, startReq, wsExtras) {
|
|
3567
3582
|
if (ss.streamClosed) {
|
|
3568
3583
|
return;
|
|
3569
3584
|
}
|
|
@@ -3576,6 +3591,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3576
3591
|
const { requestID, data } = event;
|
|
3577
3592
|
if (ss.processedRequestIDs.has(requestID)) break;
|
|
3578
3593
|
ss.processedRequestIDs.add(requestID);
|
|
3594
|
+
ss.emittedToolKeys.add(data.name);
|
|
3579
3595
|
let parsedArgs;
|
|
3580
3596
|
try {
|
|
3581
3597
|
JSON.parse(data.args);
|
|
@@ -3625,6 +3641,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3625
3641
|
if (ss.processedRequestIDs.has(event.requestID)) break;
|
|
3626
3642
|
ss.processedRequestIDs.add(event.requestID);
|
|
3627
3643
|
const mapped = mapBuiltinTool(event.toolName, event.data, availableToolNames);
|
|
3644
|
+
ss.emittedToolKeys.add(mapped.toolName);
|
|
3628
3645
|
const mappedArgs = JSON.stringify(mapped.args);
|
|
3629
3646
|
if (ss.activeTextBlockId) {
|
|
3630
3647
|
controller.enqueue({ type: "text-end", id: ss.activeTextBlockId });
|
|
@@ -3673,7 +3690,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3673
3690
|
controller,
|
|
3674
3691
|
toolExecutor,
|
|
3675
3692
|
nextTextId,
|
|
3676
|
-
availableToolNames
|
|
3693
|
+
availableToolNames,
|
|
3694
|
+
wsExtras
|
|
3677
3695
|
).catch((_err) => {
|
|
3678
3696
|
ss.approvalPending = false;
|
|
3679
3697
|
if (ss.deferredClose) {
|
|
@@ -3805,6 +3823,51 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3805
3823
|
}
|
|
3806
3824
|
for (let i = 0; i < chatLog.length; i++) {
|
|
3807
3825
|
const entry = chatLog[i];
|
|
3826
|
+
if (entry.message_type === "tool" && entry.tool_info) {
|
|
3827
|
+
const toolId = entry.message_id || entry.correlation_id || `tool-${i}`;
|
|
3828
|
+
if (ss.emittedToolEntries.has(toolId)) continue;
|
|
3829
|
+
const name = entry.tool_info.name;
|
|
3830
|
+
const args = JSON.stringify(entry.tool_info.args ?? {});
|
|
3831
|
+
if (ss.emittedToolKeys.has(name)) {
|
|
3832
|
+
ss.emittedToolEntries.add(toolId);
|
|
3833
|
+
const sess2 = this.sessionWorkflows.get(ss.sessionKey);
|
|
3834
|
+
if (sess2) sess2.toolEntries.add(toolId);
|
|
3835
|
+
continue;
|
|
3836
|
+
}
|
|
3837
|
+
if (ss.activeTextBlockId) {
|
|
3838
|
+
controller.enqueue({ type: "text-end", id: ss.activeTextBlockId });
|
|
3839
|
+
ss.activeTextBlockId = null;
|
|
3840
|
+
}
|
|
3841
|
+
controller.enqueue({
|
|
3842
|
+
type: "tool-input-start",
|
|
3843
|
+
id: toolId,
|
|
3844
|
+
toolName: name,
|
|
3845
|
+
providerExecuted: true
|
|
3846
|
+
});
|
|
3847
|
+
controller.enqueue({ type: "tool-input-delta", id: toolId, delta: args });
|
|
3848
|
+
controller.enqueue({ type: "tool-input-end", id: toolId });
|
|
3849
|
+
controller.enqueue({
|
|
3850
|
+
type: "tool-call",
|
|
3851
|
+
toolCallId: toolId,
|
|
3852
|
+
toolName: name,
|
|
3853
|
+
input: args,
|
|
3854
|
+
providerExecuted: true,
|
|
3855
|
+
dynamic: true
|
|
3856
|
+
});
|
|
3857
|
+
const response = entry.tool_info.tool_response;
|
|
3858
|
+
const output = typeof response === "string" ? response : response ? response.content : entry.content || "";
|
|
3859
|
+
controller.enqueue({
|
|
3860
|
+
type: "tool-result",
|
|
3861
|
+
toolCallId: toolId,
|
|
3862
|
+
toolName: name,
|
|
3863
|
+
result: { output, title: name, metadata: {} },
|
|
3864
|
+
isError: false
|
|
3865
|
+
});
|
|
3866
|
+
ss.emittedToolEntries.add(toolId);
|
|
3867
|
+
const sess = this.sessionWorkflows.get(ss.sessionKey);
|
|
3868
|
+
if (sess) sess.toolEntries.add(toolId);
|
|
3869
|
+
continue;
|
|
3870
|
+
}
|
|
3808
3871
|
if (entry.message_type !== "agent") continue;
|
|
3809
3872
|
const content = entry.content || "";
|
|
3810
3873
|
const msgId = entry.message_id || `idx-${i}`;
|
|
@@ -3942,7 +4005,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3942
4005
|
}
|
|
3943
4006
|
}
|
|
3944
4007
|
}
|
|
3945
|
-
async approveAndResume(ss, tools, startReq, controller, toolExecutor, nextTextId, availableToolNames) {
|
|
4008
|
+
async approveAndResume(ss, tools, startReq, controller, toolExecutor, nextTextId, availableToolNames, wsExtras) {
|
|
3946
4009
|
const handler = this.workflowOptions.approvalHandler;
|
|
3947
4010
|
if (!handler || !startReq) {
|
|
3948
4011
|
ss.approvalPending = false;
|
|
@@ -3982,7 +4045,9 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3982
4045
|
headers: this.config.getHeaders(),
|
|
3983
4046
|
projectId: this.workflowOptions.projectId,
|
|
3984
4047
|
namespaceId: this.workflowOptions.namespaceId,
|
|
3985
|
-
rootNamespaceId: this.workflowOptions.rootNamespaceId
|
|
4048
|
+
rootNamespaceId: this.workflowOptions.rootNamespaceId,
|
|
4049
|
+
aiCatalogItemVersionId: wsExtras?.aiCatalogItemVersionId,
|
|
4050
|
+
workflowDefinition: wsExtras?.workflowDefinition
|
|
3986
4051
|
},
|
|
3987
4052
|
(event) => this.handleWorkflowEvent(
|
|
3988
4053
|
ss,
|
|
@@ -3992,7 +4057,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
3992
4057
|
toolExecutor,
|
|
3993
4058
|
nextTextId,
|
|
3994
4059
|
availableToolNames,
|
|
3995
|
-
newStartReq
|
|
4060
|
+
newStartReq,
|
|
4061
|
+
wsExtras
|
|
3996
4062
|
)
|
|
3997
4063
|
);
|
|
3998
4064
|
newClient.sendStartRequest(newStartReq);
|