opencode-gitlab-duo-agentic 0.1.18 → 0.1.20

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -319,11 +319,13 @@ function toModelsConfig(available) {
319
319
  }
320
320
 
321
321
  // src/plugin/hooks.ts
322
+ var UTILITY_AGENTS = /* @__PURE__ */ new Set(["title", "compaction", "summary"]);
322
323
  async function createPluginHooks(input) {
323
324
  return {
324
325
  config: async (config) => applyRuntimeConfig(config, input.directory),
325
326
  "chat.params": async (context, output) => {
326
327
  if (!isGitLabProvider(context.model)) return;
328
+ if (isUtilityAgent(context.agent)) return;
327
329
  output.options = {
328
330
  ...output.options,
329
331
  workflowSessionID: context.sessionID
@@ -331,6 +333,7 @@ async function createPluginHooks(input) {
331
333
  },
332
334
  "chat.headers": async (context, output) => {
333
335
  if (!isGitLabProvider(context.model)) return;
336
+ if (isUtilityAgent(context.agent)) return;
334
337
  output.headers = {
335
338
  ...output.headers,
336
339
  "x-opencode-session": context.sessionID
@@ -338,6 +341,12 @@ async function createPluginHooks(input) {
338
341
  }
339
342
  };
340
343
  }
344
+ function isUtilityAgent(agent) {
345
+ if (typeof agent === "string") return UTILITY_AGENTS.has(agent);
346
+ if (agent && typeof agent === "object" && "name" in agent && typeof agent.name === "string")
347
+ return UTILITY_AGENTS.has(agent.name);
348
+ return false;
349
+ }
341
350
  function isGitLabProvider(model) {
342
351
  if (model.api?.npm === "opencode-gitlab-duo-agentic") return true;
343
352
  if (model.providerID === "gitlab" && model.api?.npm !== "@gitlab/gitlab-ai-provider") return true;
@@ -833,16 +842,28 @@ var DuoWorkflowModel = class {
833
842
  return created;
834
843
  }
835
844
  };
845
+ var UTILITY_PREFIXES = [
846
+ "Generate a title for this conversation",
847
+ "Summarize the following conversation"
848
+ ];
836
849
  function extractGoal(prompt) {
837
850
  for (let i = prompt.length - 1; i >= 0; i--) {
838
851
  const message = prompt[i];
839
852
  if (message.role !== "user") continue;
840
853
  const content = Array.isArray(message.content) ? message.content : [];
841
- const text2 = content.filter((part) => part.type === "text").map((part) => part.text).join("\n").trim();
854
+ const text2 = content.filter((part) => part.type === "text").map((part) => stripSystemReminders(part.text)).filter((t) => t && !UTILITY_PREFIXES.some((p) => t.startsWith(p))).join("\n").trim();
842
855
  if (text2) return text2;
843
856
  }
844
857
  return "";
845
858
  }
859
+ var SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
860
+ var WRAPPED_USER_RE = /^<system-reminder>\s*The user sent the following message:\s*\n([\s\S]*?)\n\s*Please address this message and continue with your tasks\.\s*<\/system-reminder>$/;
861
+ function stripSystemReminders(value) {
862
+ return value.replace(SYSTEM_REMINDER_RE, (block) => {
863
+ const wrapped = WRAPPED_USER_RE.exec(block);
864
+ return wrapped?.[1]?.trim() ?? "";
865
+ }).trim();
866
+ }
846
867
  function readSessionID(options) {
847
868
  const providerBlock = readProviderBlock(options);
848
869
  if (typeof providerBlock?.workflowSessionID === "string" && providerBlock.workflowSessionID.trim()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",