gitlab-ai-provider 5.3.1 → 5.3.3

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 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
+ ## <small>5.3.3 (2026-03-25)</small>
6
+
7
+ - Merge branch 'vg/tools-fix' into 'main' ([d33e8c0](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/d33e8c0))
8
+ - fix: fixed tools approval flow ([9597307](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/9597307))
9
+
10
+ ## <small>5.3.2 (2026-03-24)</small>
11
+
12
+ - Merge branch 'fix/system-prompt-workflow-flowconfig' into 'main' ([ffe99d6](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/ffe99d6))
13
+ - fix: route system prompt via flowConfig and strip plan mode from DWS goal ([b71dc85](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/b71dc85))
14
+
5
15
  ## <small>5.3.1 (2026-03-23)</small>
6
16
 
7
17
  - fix: rebuild dist files to include GPT-5.4 model mappings ([4bfe220](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/4bfe220))
package/dist/index.d.mts CHANGED
@@ -522,10 +522,22 @@ interface GitLabWorkflowOptions {
522
522
  * Defaults to `process.cwd()`.
523
523
  */
524
524
  workingDirectory?: string;
525
+ /**
526
+ * System prompt to override DWS's default system prompt.
527
+ * Sent via `flowConfig.prompts[].prompt_template.system`.
528
+ *
529
+ * When set and `flowConfig` is not explicitly provided, the SDK
530
+ * auto-generates the appropriate `flowConfig` and sets
531
+ * `flowConfigSchemaVersion` to `'v1'`.
532
+ *
533
+ * Explicit `flowConfig` takes precedence if both are provided.
534
+ */
535
+ systemPrompt?: string;
525
536
  /**
526
537
  * Flow configuration (parsed YAML object) to send to DWS.
527
538
  * Controls agent behavior, intermediate text generation, etc.
528
539
  * Sent as `startRequest.flowConfig`.
540
+ * Takes precedence over `systemPrompt` if both are provided.
529
541
  */
530
542
  flowConfig?: unknown;
531
543
  /**
@@ -719,6 +731,13 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
719
731
  * alongside `toolExecutor`. Takes precedence over `workflowOptions.onSelectModel`.
720
732
  */
721
733
  onSelectModel: ((models: AiModel[]) => Promise<string | null | undefined>) | null;
734
+ /**
735
+ * Set the system prompt to override DWS's default.
736
+ * Sent via `flowConfig.prompts[].prompt_template.system` at stream time.
737
+ * Can be updated between doStream() calls (e.g., per agent/session).
738
+ */
739
+ set systemPrompt(prompt: string | null);
740
+ get systemPrompt(): string | null;
722
741
  get toolExecutor(): WorkflowToolExecutor | null;
723
742
  set toolExecutor(executor: WorkflowToolExecutor | null);
724
743
  constructor(modelId: string, config: GitLabWorkflowLanguageModelConfig, workflowOptions?: GitLabWorkflowOptions);
@@ -801,6 +820,7 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
801
820
  /**
802
821
  * Extract the user's goal (last user message) from the AI SDK prompt.
803
822
  */
823
+ private static readonly SYSTEM_REMINDER_RE;
804
824
  private extractGoalFromPrompt;
805
825
  /**
806
826
  * Convert AI SDK tools to DWS McpToolDefinition format.
package/dist/index.d.ts CHANGED
@@ -522,10 +522,22 @@ interface GitLabWorkflowOptions {
522
522
  * Defaults to `process.cwd()`.
523
523
  */
524
524
  workingDirectory?: string;
525
+ /**
526
+ * System prompt to override DWS's default system prompt.
527
+ * Sent via `flowConfig.prompts[].prompt_template.system`.
528
+ *
529
+ * When set and `flowConfig` is not explicitly provided, the SDK
530
+ * auto-generates the appropriate `flowConfig` and sets
531
+ * `flowConfigSchemaVersion` to `'v1'`.
532
+ *
533
+ * Explicit `flowConfig` takes precedence if both are provided.
534
+ */
535
+ systemPrompt?: string;
525
536
  /**
526
537
  * Flow configuration (parsed YAML object) to send to DWS.
527
538
  * Controls agent behavior, intermediate text generation, etc.
528
539
  * Sent as `startRequest.flowConfig`.
540
+ * Takes precedence over `systemPrompt` if both are provided.
529
541
  */
530
542
  flowConfig?: unknown;
531
543
  /**
@@ -719,6 +731,13 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
719
731
  * alongside `toolExecutor`. Takes precedence over `workflowOptions.onSelectModel`.
720
732
  */
721
733
  onSelectModel: ((models: AiModel[]) => Promise<string | null | undefined>) | null;
734
+ /**
735
+ * Set the system prompt to override DWS's default.
736
+ * Sent via `flowConfig.prompts[].prompt_template.system` at stream time.
737
+ * Can be updated between doStream() calls (e.g., per agent/session).
738
+ */
739
+ set systemPrompt(prompt: string | null);
740
+ get systemPrompt(): string | null;
722
741
  get toolExecutor(): WorkflowToolExecutor | null;
723
742
  set toolExecutor(executor: WorkflowToolExecutor | null);
724
743
  constructor(modelId: string, config: GitLabWorkflowLanguageModelConfig, workflowOptions?: GitLabWorkflowOptions);
@@ -801,6 +820,7 @@ declare class GitLabWorkflowLanguageModel implements LanguageModelV2 {
801
820
  /**
802
821
  * Extract the user's goal (last user message) from the AI SDK prompt.
803
822
  */
823
+ private static readonly SYSTEM_REMINDER_RE;
804
824
  private extractGoalFromPrompt;
805
825
  /**
806
826
  * Convert AI SDK tools to DWS McpToolDefinition format.
package/dist/index.js CHANGED
@@ -1580,7 +1580,7 @@ var GitLabOpenAILanguageModel = class {
1580
1580
  var import_isomorphic_ws = __toESM(require("isomorphic-ws"));
1581
1581
 
1582
1582
  // src/version.ts
1583
- var VERSION = true ? "5.3.0" : "0.0.0-dev";
1583
+ var VERSION = true ? "5.3.2" : "0.0.0-dev";
1584
1584
 
1585
1585
  // src/gitlab-workflow-types.ts
1586
1586
  var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
@@ -1806,6 +1806,8 @@ var GitLabWorkflowClient = class {
1806
1806
  });
1807
1807
  } else if (checkpoint.status === "STOPPED" || checkpoint.status === "CANCELLED") {
1808
1808
  this.emit({ type: "completed" });
1809
+ } else if (checkpoint.status === "TOOL_CALL_APPROVAL_REQUIRED" || checkpoint.status === "PLAN_APPROVAL_REQUIRED") {
1810
+ this.emit({ type: "completed" });
1809
1811
  }
1810
1812
  return;
1811
1813
  }
@@ -3020,6 +3022,17 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3020
3022
  * alongside `toolExecutor`. Takes precedence over `workflowOptions.onSelectModel`.
3021
3023
  */
3022
3024
  onSelectModel = null;
3025
+ /**
3026
+ * Set the system prompt to override DWS's default.
3027
+ * Sent via `flowConfig.prompts[].prompt_template.system` at stream time.
3028
+ * Can be updated between doStream() calls (e.g., per agent/session).
3029
+ */
3030
+ set systemPrompt(prompt) {
3031
+ this.workflowOptions.systemPrompt = prompt ?? void 0;
3032
+ }
3033
+ get systemPrompt() {
3034
+ return this.workflowOptions.systemPrompt ?? null;
3035
+ }
3023
3036
  get toolExecutor() {
3024
3037
  return this._toolExecutor;
3025
3038
  }
@@ -3388,9 +3401,15 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3388
3401
  };
3389
3402
  if (this.workflowOptions.flowConfig) {
3390
3403
  startReq.flowConfig = this.workflowOptions.flowConfig;
3404
+ } else if (this.workflowOptions.systemPrompt) {
3405
+ startReq.flowConfig = {
3406
+ prompts: [{ prompt_template: { system: this.workflowOptions.systemPrompt } }]
3407
+ };
3391
3408
  }
3392
3409
  if (this.workflowOptions.flowConfigSchemaVersion) {
3393
3410
  startReq.flowConfigSchemaVersion = this.workflowOptions.flowConfigSchemaVersion;
3411
+ } else if (startReq.flowConfig) {
3412
+ startReq.flowConfigSchemaVersion = "v1";
3394
3413
  }
3395
3414
  wsClient.sendStartRequest(startReq);
3396
3415
  controller.enqueue({
@@ -3647,7 +3666,7 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3647
3666
  if (!chatLog || !Array.isArray(chatLog) || chatLog.length === 0) {
3648
3667
  return;
3649
3668
  }
3650
- if (checkpoint.status !== "RUNNING" && checkpoint.status !== "INPUT_REQUIRED" && checkpoint.status !== "FINISHED" && checkpoint.status !== "COMPLETED") {
3669
+ if (checkpoint.status !== "RUNNING" && checkpoint.status !== "INPUT_REQUIRED" && checkpoint.status !== "FINISHED" && checkpoint.status !== "COMPLETED" && checkpoint.status !== "TOOL_CALL_APPROVAL_REQUIRED") {
3651
3670
  return;
3652
3671
  }
3653
3672
  for (let i = 0; i < chatLog.length; i++) {
@@ -3793,7 +3812,8 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3793
3812
  // ---------------------------------------------------------------------------
3794
3813
  async buildWorkflowMetadata() {
3795
3814
  const metadata = {
3796
- extended_logging: false
3815
+ extended_logging: false,
3816
+ tool_approval_for_session_enabled: true
3797
3817
  };
3798
3818
  try {
3799
3819
  const workDir = this.workflowOptions.workingDirectory ?? process.cwd();
@@ -3831,13 +3851,16 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3831
3851
  /**
3832
3852
  * Extract the user's goal (last user message) from the AI SDK prompt.
3833
3853
  */
3854
+ static SYSTEM_REMINDER_RE = /<system-reminder>([\s\S]*?)<\/system-reminder>/g;
3834
3855
  extractGoalFromPrompt(prompt) {
3835
3856
  for (let i = prompt.length - 1; i >= 0; i--) {
3836
3857
  const message = prompt[i];
3837
3858
  if (message.role === "user") {
3838
3859
  const textParts = message.content.filter((part) => part.type === "text").map((part) => part.text);
3839
3860
  if (textParts.length > 0) {
3840
- return textParts.join("\n");
3861
+ const raw = textParts.join("\n");
3862
+ const cleaned = raw.replace(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE, "").trim();
3863
+ return cleaned || raw;
3841
3864
  }
3842
3865
  }
3843
3866
  }
@@ -3931,6 +3954,23 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3931
3954
  metadata: JSON.stringify({ role: "assistant" })
3932
3955
  });
3933
3956
  }
3957
+ } else if (message.role === "user") {
3958
+ for (const part of message.content) {
3959
+ if (part.type === "text") {
3960
+ const text = part.text;
3961
+ const matches = text.matchAll(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE);
3962
+ for (const match of matches) {
3963
+ const inner = match[1].trim();
3964
+ if (inner) {
3965
+ context.push({
3966
+ category: "agent_context",
3967
+ content: inner,
3968
+ metadata: JSON.stringify({ source: "system-reminder" })
3969
+ });
3970
+ }
3971
+ }
3972
+ }
3973
+ }
3934
3974
  }
3935
3975
  }
3936
3976
  return context;