opencode-gitlab-duo-agentic 0.2.14 → 0.2.16

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 +34 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -456,23 +456,6 @@ function extractAgentTextDeltas(checkpoint, state) {
456
456
  state.uiChatLog = next;
457
457
  return out;
458
458
  }
459
- function extractToolRequests(checkpoint, state) {
460
- const next = parseCheckpoint(checkpoint);
461
- const requests = [];
462
- for (let i = 0; i < next.length; i++) {
463
- const item = next[i];
464
- if (item.message_type !== "request") continue;
465
- if (!item.tool_info) continue;
466
- if (state.processedRequestIndices.has(i)) continue;
467
- state.processedRequestIndices.add(i);
468
- requests.push({
469
- requestId: item.correlation_id ?? randomUUID(),
470
- toolName: item.tool_info.name,
471
- args: item.tool_info.args ?? {}
472
- });
473
- }
474
- return requests;
475
- }
476
459
  function parseCheckpoint(raw) {
477
460
  if (!raw) return [];
478
461
  try {
@@ -786,6 +769,15 @@ function mapActionToToolRequest(action) {
786
769
  return null;
787
770
  }
788
771
 
772
+ // src/utils/debug-log.ts
773
+ import { appendFileSync } from "fs";
774
+ var LOG_FILE = "/tmp/duo-workflow-debug.log";
775
+ function dlog(msg) {
776
+ const ts = (/* @__PURE__ */ new Date()).toISOString();
777
+ appendFileSync(LOG_FILE, `[${ts}] ${msg}
778
+ `);
779
+ }
780
+
789
781
  // src/workflow/session.ts
790
782
  var WorkflowSession = class {
791
783
  #client;
@@ -848,7 +840,8 @@ var WorkflowSession = class {
848
840
  const socket = new WorkflowWebSocketClient({
849
841
  action: (action) => this.#handleAction(action, queue),
850
842
  error: (error) => queue.push({ type: "error", message: error.message }),
851
- close: (_code, _reason) => {
843
+ close: (code, reason) => {
844
+ dlog(`ws-close: code=${code} reason=${reason} pendingApproval=${this.#pendingApproval}`);
852
845
  this.#socket = void 0;
853
846
  if (this.#pendingApproval) {
854
847
  this.#pendingApproval = false;
@@ -900,6 +893,7 @@ var WorkflowSession = class {
900
893
  * Send a tool result back to DWS on the existing connection.
901
894
  */
902
895
  sendToolResult(requestId, output, error) {
896
+ dlog(`sendToolResult: reqId=${requestId} output=${output.length}b error=${error ?? "none"} socket=${!!this.#socket}`);
903
897
  if (!this.#socket) throw new Error("Not connected");
904
898
  this.#socket.send({
905
899
  actionResponse: {
@@ -933,24 +927,21 @@ var WorkflowSession = class {
933
927
  if (isCheckpointAction(action)) {
934
928
  const ckpt = action.newCheckpoint.checkpoint;
935
929
  const status = action.newCheckpoint.status;
930
+ dlog(`checkpoint: status=${status} ckptLen=${ckpt.length}`);
936
931
  const deltas = extractAgentTextDeltas(ckpt, this.#checkpoint);
937
932
  for (const delta of deltas) {
938
933
  queue.push({ type: "text-delta", value: delta });
939
934
  }
935
+ if (deltas.length > 0) {
936
+ dlog(`checkpoint: ${deltas.length} text deltas`);
937
+ }
940
938
  if (isToolApproval(status)) {
939
+ dlog(`checkpoint: TOOL_APPROVAL \u2192 pendingApproval=true (waiting for DWS close)`);
941
940
  this.#pendingApproval = true;
942
941
  return;
943
942
  }
944
- const toolRequests = extractToolRequests(ckpt, this.#checkpoint);
945
- for (const req of toolRequests) {
946
- queue.push({
947
- type: "tool-request",
948
- requestId: req.requestId,
949
- toolName: req.toolName,
950
- args: req.args
951
- });
952
- }
953
943
  if (isTurnComplete(status)) {
944
+ dlog(`checkpoint: turnComplete \u2192 close queue+connection`);
954
945
  queue.close();
955
946
  this.#closeConnection();
956
947
  }
@@ -959,12 +950,15 @@ var WorkflowSession = class {
959
950
  const toolAction = action;
960
951
  const mapped = mapActionToToolRequest(toolAction);
961
952
  if (mapped) {
953
+ dlog(`standalone: ${mapped.toolName} reqId=${mapped.requestId} args=${JSON.stringify(mapped.args).slice(0, 200)}`);
962
954
  queue.push({
963
955
  type: "tool-request",
964
956
  requestId: mapped.requestId,
965
957
  toolName: mapped.toolName,
966
958
  args: mapped.args
967
959
  });
960
+ } else {
961
+ dlog(`standalone: UNMAPPED action keys=${Object.keys(action).join(",")}`);
968
962
  }
969
963
  }
970
964
  // ---------------------------------------------------------------------------
@@ -981,12 +975,15 @@ var WorkflowSession = class {
981
975
  * when the standalone action arrives on the new stream.
982
976
  */
983
977
  #reconnectWithApproval(queue) {
978
+ dlog(`reconnectWithApproval: starting (workflowId=${this.#workflowId})`);
984
979
  this.#connectSocket(queue).then(() => {
985
980
  if (!this.#socket || !this.#workflowId) {
981
+ dlog(`reconnectWithApproval: FAILED no socket/workflowId`);
986
982
  queue.close();
987
983
  return;
988
984
  }
989
985
  const mcpTools = this.#toolsConfig?.mcpTools ?? [];
986
+ dlog(`reconnectWithApproval: sending startRequest with approval (mcpTools=${mcpTools.length})`);
990
987
  this.#socket.send({
991
988
  startRequest: {
992
989
  workflowID: this.#workflowId,
@@ -1002,7 +999,9 @@ var WorkflowSession = class {
1002
999
  }
1003
1000
  });
1004
1001
  this.#startRequestSent = true;
1005
- }).catch(() => {
1002
+ dlog(`reconnectWithApproval: approval sent, waiting for standalone actions`);
1003
+ }).catch((err) => {
1004
+ dlog(`reconnectWithApproval: ERROR ${err instanceof Error ? err.message : String(err)}`);
1006
1005
  this.#queue = void 0;
1007
1006
  queue.close();
1008
1007
  });
@@ -1466,6 +1465,7 @@ var DuoWorkflowModel = class {
1466
1465
  const toolResults = extractToolResults(options.prompt);
1467
1466
  const session = this.#resolveSession(sessionID);
1468
1467
  const textId = randomUUID3();
1468
+ dlog(`doStream: goal=${goal?.length ?? 0}ch toolResults=${toolResults.length} hasStarted=${session.hasStarted} pending=${this.#pendingToolRequests.size} sent=${this.#sentToolCallIds.size}`);
1469
1469
  if (sessionID !== this.#stateSessionId) {
1470
1470
  this.#pendingToolRequests.clear();
1471
1471
  this.#multiCallGroups.clear();
@@ -1496,6 +1496,7 @@ var DuoWorkflowModel = class {
1496
1496
  const freshResults = toolResults.filter(
1497
1497
  (r) => !model.#sentToolCallIds.has(r.toolCallId)
1498
1498
  );
1499
+ dlog(`phase1: ${toolResults.length} total, ${freshResults.length} fresh`);
1499
1500
  let sentToolResults = false;
1500
1501
  for (const result of freshResults) {
1501
1502
  const hashIdx = result.toolCallId.indexOf("#");
@@ -1520,9 +1521,11 @@ var DuoWorkflowModel = class {
1520
1521
  }
1521
1522
  const pending = model.#pendingToolRequests.get(result.toolCallId);
1522
1523
  if (!pending) {
1524
+ dlog(`phase1: SKIP ${result.toolCallId} (not pending)`);
1523
1525
  model.#sentToolCallIds.add(result.toolCallId);
1524
1526
  continue;
1525
1527
  }
1528
+ dlog(`phase1: SEND ${result.toolCallId} output=${result.output.length}b`);
1526
1529
  session.sendToolResult(result.toolCallId, result.output, result.error);
1527
1530
  sentToolResults = true;
1528
1531
  model.#sentToolCallIds.add(result.toolCallId);
@@ -1588,8 +1591,11 @@ var DuoWorkflowModel = class {
1588
1591
  try {
1589
1592
  mapped = mapDuoToolRequest(event.toolName, event.args);
1590
1593
  } catch {
1594
+ dlog(`phase3: MAPPING FAILED ${event.toolName}`);
1591
1595
  continue;
1592
1596
  }
1597
+ const mName = Array.isArray(mapped) ? mapped.map((m) => m.toolName).join(",") : mapped.toolName;
1598
+ dlog(`phase3: tool-request ${event.toolName} \u2192 ${mName} reqId=${event.requestId}`);
1593
1599
  if (hasText) {
1594
1600
  controller.enqueue({ type: "text-end", id: textId });
1595
1601
  }
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.16",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",