gitlab-ai-provider 5.3.0 → 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/dist/index.mjs CHANGED
@@ -1509,7 +1509,7 @@ var GitLabOpenAILanguageModel = class {
1509
1509
  import WebSocket from "isomorphic-ws";
1510
1510
 
1511
1511
  // src/version.ts
1512
- var VERSION = true ? "5.2.2" : "0.0.0-dev";
1512
+ var VERSION = true ? "5.3.1" : "0.0.0-dev";
1513
1513
 
1514
1514
  // src/gitlab-workflow-types.ts
1515
1515
  var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
@@ -2949,6 +2949,17 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
2949
2949
  * alongside `toolExecutor`. Takes precedence over `workflowOptions.onSelectModel`.
2950
2950
  */
2951
2951
  onSelectModel = null;
2952
+ /**
2953
+ * Set the system prompt to override DWS's default.
2954
+ * Sent via `flowConfig.prompts[].prompt_template.system` at stream time.
2955
+ * Can be updated between doStream() calls (e.g., per agent/session).
2956
+ */
2957
+ set systemPrompt(prompt) {
2958
+ this.workflowOptions.systemPrompt = prompt ?? void 0;
2959
+ }
2960
+ get systemPrompt() {
2961
+ return this.workflowOptions.systemPrompt ?? null;
2962
+ }
2952
2963
  get toolExecutor() {
2953
2964
  return this._toolExecutor;
2954
2965
  }
@@ -3317,9 +3328,15 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3317
3328
  };
3318
3329
  if (this.workflowOptions.flowConfig) {
3319
3330
  startReq.flowConfig = this.workflowOptions.flowConfig;
3331
+ } else if (this.workflowOptions.systemPrompt) {
3332
+ startReq.flowConfig = {
3333
+ prompts: [{ prompt_template: { system: this.workflowOptions.systemPrompt } }]
3334
+ };
3320
3335
  }
3321
3336
  if (this.workflowOptions.flowConfigSchemaVersion) {
3322
3337
  startReq.flowConfigSchemaVersion = this.workflowOptions.flowConfigSchemaVersion;
3338
+ } else if (startReq.flowConfig) {
3339
+ startReq.flowConfigSchemaVersion = "v1";
3323
3340
  }
3324
3341
  wsClient.sendStartRequest(startReq);
3325
3342
  controller.enqueue({
@@ -3760,13 +3777,16 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3760
3777
  /**
3761
3778
  * Extract the user's goal (last user message) from the AI SDK prompt.
3762
3779
  */
3780
+ static SYSTEM_REMINDER_RE = /<system-reminder>([\s\S]*?)<\/system-reminder>/g;
3763
3781
  extractGoalFromPrompt(prompt) {
3764
3782
  for (let i = prompt.length - 1; i >= 0; i--) {
3765
3783
  const message = prompt[i];
3766
3784
  if (message.role === "user") {
3767
3785
  const textParts = message.content.filter((part) => part.type === "text").map((part) => part.text);
3768
3786
  if (textParts.length > 0) {
3769
- return textParts.join("\n");
3787
+ const raw = textParts.join("\n");
3788
+ const cleaned = raw.replace(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE, "").trim();
3789
+ return cleaned || raw;
3770
3790
  }
3771
3791
  }
3772
3792
  }
@@ -3860,6 +3880,23 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
3860
3880
  metadata: JSON.stringify({ role: "assistant" })
3861
3881
  });
3862
3882
  }
3883
+ } else if (message.role === "user") {
3884
+ for (const part of message.content) {
3885
+ if (part.type === "text") {
3886
+ const text = part.text;
3887
+ const matches = text.matchAll(_GitLabWorkflowLanguageModel.SYSTEM_REMINDER_RE);
3888
+ for (const match of matches) {
3889
+ const inner = match[1].trim();
3890
+ if (inner) {
3891
+ context.push({
3892
+ category: "agent_context",
3893
+ content: inner,
3894
+ metadata: JSON.stringify({ source: "system-reminder" })
3895
+ });
3896
+ }
3897
+ }
3898
+ }
3899
+ }
3863
3900
  }
3864
3901
  }
3865
3902
  return context;