opencode-gitlab-duo-agentic 0.2.20 → 0.2.21

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 +53 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -793,11 +793,16 @@ var WorkflowSession = class {
793
793
  #queue;
794
794
  #startRequestSent = false;
795
795
  #pendingApproval = false;
796
- constructor(client, modelId, cwd) {
796
+ #onWorkflowCreated;
797
+ constructor(client, modelId, cwd, options) {
797
798
  this.#client = client;
798
799
  this.#tokenService = new WorkflowTokenService(client);
799
800
  this.#modelId = modelId;
800
801
  this.#cwd = cwd;
802
+ if (options?.existingWorkflowId) {
803
+ this.#workflowId = options.existingWorkflowId;
804
+ }
805
+ this.#onWorkflowCreated = options?.onWorkflowCreated;
801
806
  }
802
807
  /**
803
808
  * Opt-in: override the server-side system prompt and/or register MCP tools.
@@ -1088,7 +1093,9 @@ var WorkflowSession = class {
1088
1093
  const details = [created.message, created.error].filter(Boolean).join("; ");
1089
1094
  throw new Error(`failed to create workflow${details ? `: ${details}` : ""}`);
1090
1095
  }
1091
- return String(created.id);
1096
+ const workflowId = String(created.id);
1097
+ this.#onWorkflowCreated?.(workflowId);
1098
+ return workflowId;
1092
1099
  }
1093
1100
  async #loadProjectContext() {
1094
1101
  if (this.#projectPath !== void 0) return;
@@ -1466,6 +1473,39 @@ CODE QUALITY:
1466
1473
  </communication>
1467
1474
  </system-reminder>`;
1468
1475
 
1476
+ // src/workflow/session-store.ts
1477
+ import { readFileSync, writeFileSync, mkdirSync } from "fs";
1478
+ import { join } from "path";
1479
+ import { homedir } from "os";
1480
+ function getStorePath() {
1481
+ const dir = process.env.XDG_CACHE_HOME?.trim() ? join(process.env.XDG_CACHE_HOME, "opencode") : join(homedir(), ".cache", "opencode");
1482
+ return join(dir, "duo-workflow-sessions.json");
1483
+ }
1484
+ function readStore() {
1485
+ try {
1486
+ return JSON.parse(readFileSync(getStorePath(), "utf8"));
1487
+ } catch {
1488
+ return {};
1489
+ }
1490
+ }
1491
+ function writeStore(store) {
1492
+ try {
1493
+ const storePath = getStorePath();
1494
+ mkdirSync(join(storePath, ".."), { recursive: true });
1495
+ writeFileSync(storePath, JSON.stringify(store, null, 2), "utf8");
1496
+ } catch {
1497
+ }
1498
+ }
1499
+ function saveWorkflowId(key, workflowId) {
1500
+ const store = readStore();
1501
+ store[key] = workflowId;
1502
+ writeStore(store);
1503
+ }
1504
+ function loadWorkflowId(key) {
1505
+ const store = readStore();
1506
+ return store[key];
1507
+ }
1508
+
1469
1509
  // src/provider/duo-workflow-model.ts
1470
1510
  var sessions = /* @__PURE__ */ new Map();
1471
1511
  var UNKNOWN_USAGE = {
@@ -1743,7 +1783,17 @@ var DuoWorkflowModel = class {
1743
1783
  const key = sessionKey(this.#client.instanceUrl, this.modelId, sessionID);
1744
1784
  const existing = sessions.get(key);
1745
1785
  if (existing) return existing;
1746
- const created = new WorkflowSession(this.#client, this.modelId, this.#cwd);
1786
+ const existingWorkflowId = loadWorkflowId(key);
1787
+ if (existingWorkflowId) {
1788
+ dlog(`resolveSession: restored workflowId=${existingWorkflowId} from disk for ${sessionID}`);
1789
+ }
1790
+ const created = new WorkflowSession(this.#client, this.modelId, this.#cwd, {
1791
+ existingWorkflowId,
1792
+ onWorkflowCreated: (workflowId) => {
1793
+ dlog(`resolveSession: saving workflowId=${workflowId} for ${sessionID}`);
1794
+ saveWorkflowId(key, workflowId);
1795
+ }
1796
+ });
1747
1797
  if (this.#toolsConfig) created.setToolsConfig(this.#toolsConfig);
1748
1798
  sessions.set(key, created);
1749
1799
  return created;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.2.20",
3
+ "version": "0.2.21",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",