gitlab-ai-provider 5.3.1 → 5.3.2

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,11 @@
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.2 (2026-03-24)</small>
6
+
7
+ - Merge branch 'fix/system-prompt-workflow-flowconfig' into 'main' ([ffe99d6](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/ffe99d6))
8
+ - fix: route system prompt via flowConfig and strip plan mode from DWS goal ([b71dc85](https://gitlab.com/vglafirov/gitlab-ai-provider/commit/b71dc85))
9
+
5
10
  ## <small>5.3.1 (2026-03-23)</small>
6
11
 
7
12
  - 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.1" : "0.0.0-dev";
1584
1584
 
1585
1585
  // src/gitlab-workflow-types.ts
1586
1586
  var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
@@ -3020,6 +3020,17 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3020
3020
  * alongside `toolExecutor`. Takes precedence over `workflowOptions.onSelectModel`.
3021
3021
  */
3022
3022
  onSelectModel = null;
3023
+ /**
3024
+ * Set the system prompt to override DWS's default.
3025
+ * Sent via `flowConfig.prompts[].prompt_template.system` at stream time.
3026
+ * Can be updated between doStream() calls (e.g., per agent/session).
3027
+ */
3028
+ set systemPrompt(prompt) {
3029
+ this.workflowOptions.systemPrompt = prompt ?? void 0;
3030
+ }
3031
+ get systemPrompt() {
3032
+ return this.workflowOptions.systemPrompt ?? null;
3033
+ }
3023
3034
  get toolExecutor() {
3024
3035
  return this._toolExecutor;
3025
3036
  }
@@ -3388,9 +3399,15 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3388
3399
  };
3389
3400
  if (this.workflowOptions.flowConfig) {
3390
3401
  startReq.flowConfig = this.workflowOptions.flowConfig;
3402
+ } else if (this.workflowOptions.systemPrompt) {
3403
+ startReq.flowConfig = {
3404
+ prompts: [{ prompt_template: { system: this.workflowOptions.systemPrompt } }]
3405
+ };
3391
3406
  }
3392
3407
  if (this.workflowOptions.flowConfigSchemaVersion) {
3393
3408
  startReq.flowConfigSchemaVersion = this.workflowOptions.flowConfigSchemaVersion;
3409
+ } else if (startReq.flowConfig) {
3410
+ startReq.flowConfigSchemaVersion = "v1";
3394
3411
  }
3395
3412
  wsClient.sendStartRequest(startReq);
3396
3413
  controller.enqueue({
@@ -3831,13 +3848,16 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3831
3848
  /**
3832
3849
  * Extract the user's goal (last user message) from the AI SDK prompt.
3833
3850
  */
3851
+ static SYSTEM_REMINDER_RE = /<system-reminder>([\s\S]*?)<\/system-reminder>/g;
3834
3852
  extractGoalFromPrompt(prompt) {
3835
3853
  for (let i = prompt.length - 1; i >= 0; i--) {
3836
3854
  const message = prompt[i];
3837
3855
  if (message.role === "user") {
3838
3856
  const textParts = message.content.filter((part) => part.type === "text").map((part) => part.text);
3839
3857
  if (textParts.length > 0) {
3840
- return textParts.join("\n");
3858
+ const raw = textParts.join("\n");
3859
+ const cleaned = raw.replace(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE, "").trim();
3860
+ return cleaned || raw;
3841
3861
  }
3842
3862
  }
3843
3863
  }
@@ -3931,6 +3951,23 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3931
3951
  metadata: JSON.stringify({ role: "assistant" })
3932
3952
  });
3933
3953
  }
3954
+ } else if (message.role === "user") {
3955
+ for (const part of message.content) {
3956
+ if (part.type === "text") {
3957
+ const text = part.text;
3958
+ const matches = text.matchAll(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE);
3959
+ for (const match of matches) {
3960
+ const inner = match[1].trim();
3961
+ if (inner) {
3962
+ context.push({
3963
+ category: "agent_context",
3964
+ content: inner,
3965
+ metadata: JSON.stringify({ source: "system-reminder" })
3966
+ });
3967
+ }
3968
+ }
3969
+ }
3970
+ }
3934
3971
  }
3935
3972
  }
3936
3973
  return context;