gitlab-ai-provider 6.4.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/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.3.0" : "0.0.0-dev";
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) => {
@@ -3419,7 +3419,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3419
3419
  this.sessionWorkflows.set(sessionKey, {
3420
3420
  workflowId,
3421
3421
  workflowDefinition: effectiveDefinition,
3422
- agentEmitted: /* @__PURE__ */ new Map()
3422
+ agentEmitted: /* @__PURE__ */ new Map(),
3423
+ toolEntries: /* @__PURE__ */ new Set()
3423
3424
  });
3424
3425
  sess = this.sessionWorkflows.get(sessionKey);
3425
3426
  }
@@ -3439,6 +3440,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3439
3440
  currentAgentMessageId: "",
3440
3441
  activeClient: wsClient,
3441
3442
  processedRequestIDs: /* @__PURE__ */ new Set(),
3443
+ emittedToolEntries: new Set(sess?.toolEntries),
3444
+ emittedToolKeys: /* @__PURE__ */ new Set(),
3442
3445
  sessionKey
3443
3446
  };
3444
3447
  for (const msg of options.prompt) {
@@ -3588,6 +3591,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3588
3591
  const { requestID, data } = event;
3589
3592
  if (ss.processedRequestIDs.has(requestID)) break;
3590
3593
  ss.processedRequestIDs.add(requestID);
3594
+ ss.emittedToolKeys.add(data.name);
3591
3595
  let parsedArgs;
3592
3596
  try {
3593
3597
  JSON.parse(data.args);
@@ -3637,6 +3641,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3637
3641
  if (ss.processedRequestIDs.has(event.requestID)) break;
3638
3642
  ss.processedRequestIDs.add(event.requestID);
3639
3643
  const mapped = mapBuiltinTool(event.toolName, event.data, availableToolNames);
3644
+ ss.emittedToolKeys.add(mapped.toolName);
3640
3645
  const mappedArgs = JSON.stringify(mapped.args);
3641
3646
  if (ss.activeTextBlockId) {
3642
3647
  controller.enqueue({ type: "text-end", id: ss.activeTextBlockId });
@@ -3818,6 +3823,51 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3818
3823
  }
3819
3824
  for (let i = 0; i < chatLog.length; i++) {
3820
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
+ }
3821
3871
  if (entry.message_type !== "agent") continue;
3822
3872
  const content = entry.content || "";
3823
3873
  const msgId = entry.message_id || `idx-${i}`;