opencode-gitlab-duo-agentic 0.2.14 → 0.2.15

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 +35 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -786,6 +786,15 @@ function mapActionToToolRequest(action) {
786
786
  return null;
787
787
  }
788
788
 
789
+ // src/utils/debug-log.ts
790
+ import { appendFileSync } from "fs";
791
+ var LOG_FILE = "/tmp/duo-workflow-debug.log";
792
+ function dlog(msg) {
793
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
794
+ appendFileSync(LOG_FILE, `[${ts}] ${msg}
795
+ `);
796
+ }
797
+
789
798
  // src/workflow/session.ts
790
799
  var WorkflowSession = class {
791
800
  #client;
@@ -848,7 +857,8 @@ var WorkflowSession = class {
848
857
  const socket = new WorkflowWebSocketClient({
849
858
  action: (action) => this.#handleAction(action, queue),
850
859
  error: (error) => queue.push({ type: "error", message: error.message }),
851
- close: (_code, _reason) => {
860
+ close: (code, reason) => {
861
+ dlog(`ws-close: code=${code} reason=${reason} pendingApproval=${this.#pendingApproval}`);
852
862
  this.#socket = void 0;
853
863
  if (this.#pendingApproval) {
854
864
  this.#pendingApproval = false;
@@ -900,6 +910,7 @@ var WorkflowSession = class {
900
910
  * Send a tool result back to DWS on the existing connection.
901
911
  */
902
912
  sendToolResult(requestId, output, error) {
913
+ dlog(`sendToolResult: reqId=${requestId} output=${output.length}b error=${error ?? "none"} socket=${!!this.#socket}`);
903
914
  if (!this.#socket) throw new Error("Not connected");
904
915
  this.#socket.send({
905
916
  actionResponse: {
@@ -933,16 +944,22 @@ var WorkflowSession = class {
933
944
  if (isCheckpointAction(action)) {
934
945
  const ckpt = action.newCheckpoint.checkpoint;
935
946
  const status = action.newCheckpoint.status;
947
+ dlog(`checkpoint: status=${status} ckptLen=${ckpt.length}`);
936
948
  const deltas = extractAgentTextDeltas(ckpt, this.#checkpoint);
937
949
  for (const delta of deltas) {
938
950
  queue.push({ type: "text-delta", value: delta });
939
951
  }
952
+ if (deltas.length > 0) {
953
+ dlog(`checkpoint: ${deltas.length} text deltas`);
954
+ }
940
955
  if (isToolApproval(status)) {
956
+ dlog(`checkpoint: TOOL_APPROVAL \u2192 pendingApproval=true (waiting for DWS close)`);
941
957
  this.#pendingApproval = true;
942
958
  return;
943
959
  }
944
960
  const toolRequests = extractToolRequests(ckpt, this.#checkpoint);
945
961
  for (const req of toolRequests) {
962
+ dlog(`checkpoint: tool-request name=${req.toolName} reqId=${req.requestId}`);
946
963
  queue.push({
947
964
  type: "tool-request",
948
965
  requestId: req.requestId,
@@ -951,6 +968,7 @@ var WorkflowSession = class {
951
968
  });
952
969
  }
953
970
  if (isTurnComplete(status)) {
971
+ dlog(`checkpoint: turnComplete \u2192 close queue+connection`);
954
972
  queue.close();
955
973
  this.#closeConnection();
956
974
  }
@@ -959,12 +977,15 @@ var WorkflowSession = class {
959
977
  const toolAction = action;
960
978
  const mapped = mapActionToToolRequest(toolAction);
961
979
  if (mapped) {
980
+ dlog(`standalone: ${mapped.toolName} reqId=${mapped.requestId} args=${JSON.stringify(mapped.args).slice(0, 200)}`);
962
981
  queue.push({
963
982
  type: "tool-request",
964
983
  requestId: mapped.requestId,
965
984
  toolName: mapped.toolName,
966
985
  args: mapped.args
967
986
  });
987
+ } else {
988
+ dlog(`standalone: UNMAPPED action keys=${Object.keys(action).join(",")}`);
968
989
  }
969
990
  }
970
991
  // ---------------------------------------------------------------------------
@@ -981,12 +1002,15 @@ var WorkflowSession = class {
981
1002
  * when the standalone action arrives on the new stream.
982
1003
  */
983
1004
  #reconnectWithApproval(queue) {
1005
+ dlog(`reconnectWithApproval: starting (workflowId=${this.#workflowId})`);
984
1006
  this.#connectSocket(queue).then(() => {
985
1007
  if (!this.#socket || !this.#workflowId) {
1008
+ dlog(`reconnectWithApproval: FAILED no socket/workflowId`);
986
1009
  queue.close();
987
1010
  return;
988
1011
  }
989
1012
  const mcpTools = this.#toolsConfig?.mcpTools ?? [];
1013
+ dlog(`reconnectWithApproval: sending startRequest with approval (mcpTools=${mcpTools.length})`);
990
1014
  this.#socket.send({
991
1015
  startRequest: {
992
1016
  workflowID: this.#workflowId,
@@ -1002,7 +1026,9 @@ var WorkflowSession = class {
1002
1026
  }
1003
1027
  });
1004
1028
  this.#startRequestSent = true;
1005
- }).catch(() => {
1029
+ dlog(`reconnectWithApproval: approval sent, waiting for standalone actions`);
1030
+ }).catch((err) => {
1031
+ dlog(`reconnectWithApproval: ERROR ${err instanceof Error ? err.message : String(err)}`);
1006
1032
  this.#queue = void 0;
1007
1033
  queue.close();
1008
1034
  });
@@ -1466,6 +1492,7 @@ var DuoWorkflowModel = class {
1466
1492
  const toolResults = extractToolResults(options.prompt);
1467
1493
  const session = this.#resolveSession(sessionID);
1468
1494
  const textId = randomUUID3();
1495
+ dlog(`doStream: goal=${goal?.length ?? 0}ch toolResults=${toolResults.length} hasStarted=${session.hasStarted} pending=${this.#pendingToolRequests.size} sent=${this.#sentToolCallIds.size}`);
1469
1496
  if (sessionID !== this.#stateSessionId) {
1470
1497
  this.#pendingToolRequests.clear();
1471
1498
  this.#multiCallGroups.clear();
@@ -1496,6 +1523,7 @@ var DuoWorkflowModel = class {
1496
1523
  const freshResults = toolResults.filter(
1497
1524
  (r) => !model.#sentToolCallIds.has(r.toolCallId)
1498
1525
  );
1526
+ dlog(`phase1: ${toolResults.length} total, ${freshResults.length} fresh`);
1499
1527
  let sentToolResults = false;
1500
1528
  for (const result of freshResults) {
1501
1529
  const hashIdx = result.toolCallId.indexOf("#");
@@ -1520,9 +1548,11 @@ var DuoWorkflowModel = class {
1520
1548
  }
1521
1549
  const pending = model.#pendingToolRequests.get(result.toolCallId);
1522
1550
  if (!pending) {
1551
+ dlog(`phase1: SKIP ${result.toolCallId} (not pending)`);
1523
1552
  model.#sentToolCallIds.add(result.toolCallId);
1524
1553
  continue;
1525
1554
  }
1555
+ dlog(`phase1: SEND ${result.toolCallId} output=${result.output.length}b`);
1526
1556
  session.sendToolResult(result.toolCallId, result.output, result.error);
1527
1557
  sentToolResults = true;
1528
1558
  model.#sentToolCallIds.add(result.toolCallId);
@@ -1588,8 +1618,11 @@ var DuoWorkflowModel = class {
1588
1618
  try {
1589
1619
  mapped = mapDuoToolRequest(event.toolName, event.args);
1590
1620
  } catch {
1621
+ dlog(`phase3: MAPPING FAILED ${event.toolName}`);
1591
1622
  continue;
1592
1623
  }
1624
+ const mName = Array.isArray(mapped) ? mapped.map((m) => m.toolName).join(",") : mapped.toolName;
1625
+ dlog(`phase3: tool-request ${event.toolName} \u2192 ${mName} reqId=${event.requestId}`);
1593
1626
  if (hasText) {
1594
1627
  controller.enqueue({ type: "text-end", id: textId });
1595
1628
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",