opencode-gitlab-duo-agentic 0.2.10 → 0.2.12

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 +37 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -558,6 +558,14 @@ var TURN_COMPLETE_STATUSES = /* @__PURE__ */ new Set([
558
558
  function isTurnComplete(status) {
559
559
  return TURN_COMPLETE_STATUSES.has(status);
560
560
  }
561
+ var AWAITING_RESPONSE_STATUSES = /* @__PURE__ */ new Set([
562
+ WORKFLOW_STATUS.TOOL_CALL_APPROVAL_REQUIRED,
563
+ WORKFLOW_STATUS.INPUT_REQUIRED,
564
+ WORKFLOW_STATUS.PLAN_APPROVAL_REQUIRED
565
+ ]);
566
+ function isAwaitingResponse(status) {
567
+ return AWAITING_RESPONSE_STATUSES.has(status);
568
+ }
561
569
 
562
570
  // src/workflow/websocket-client.ts
563
571
  import WebSocket from "isomorphic-ws";
@@ -776,6 +784,17 @@ function mapActionToToolRequest(action) {
776
784
  return null;
777
785
  }
778
786
 
787
+ // src/utils/debug-log.ts
788
+ import { appendFileSync } from "fs";
789
+ var LOG = "/tmp/duo-workflow-debug.log";
790
+ function dlog(msg) {
791
+ try {
792
+ appendFileSync(LOG, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
793
+ `);
794
+ } catch {
795
+ }
796
+ }
797
+
779
798
  // src/workflow/session.ts
780
799
  var WorkflowSession = class {
781
800
  #client;
@@ -872,6 +891,7 @@ var WorkflowSession = class {
872
891
  * Send a tool result back to DWS on the existing connection.
873
892
  */
874
893
  sendToolResult(requestId, output, error) {
894
+ dlog(`sendToolResult: reqId=${requestId} output=${output.length}b socket=${!!this.#socket}`);
875
895
  if (!this.#socket) throw new Error("Not connected");
876
896
  this.#socket.send({
877
897
  actionResponse: {
@@ -917,15 +937,20 @@ var WorkflowSession = class {
917
937
  args: req.args
918
938
  });
919
939
  }
920
- if (isTurnComplete(action.newCheckpoint.status)) {
940
+ const status = action.newCheckpoint.status;
941
+ if (isTurnComplete(status) && !isAwaitingResponse(status)) {
942
+ dlog(`action: checkpoint status=${status} CLOSE`);
921
943
  queue.close();
922
944
  this.#closeConnection();
945
+ } else {
946
+ dlog(`action: checkpoint status=${status} KEEP-ALIVE`);
923
947
  }
924
948
  return;
925
949
  }
926
950
  const toolAction = action;
927
951
  const mapped = mapActionToToolRequest(toolAction);
928
952
  if (mapped) {
953
+ dlog(`action: standalone ${mapped.toolName} reqId=${mapped.requestId}`);
929
954
  queue.push({
930
955
  type: "tool-request",
931
956
  requestId: mapped.requestId,
@@ -1395,6 +1420,7 @@ var DuoWorkflowModel = class {
1395
1420
  const toolResults = extractToolResults(options.prompt);
1396
1421
  const session = this.#resolveSession(sessionID);
1397
1422
  const textId = randomUUID3();
1423
+ dlog(`doStream: goal=${goal?.length ?? 0}ch toolResults=${toolResults.length} hasStarted=${session.hasStarted} pending=${this.#pendingToolRequests.size} sent=${this.#sentToolCallIds.size}`);
1398
1424
  if (sessionID !== this.#stateSessionId) {
1399
1425
  this.#pendingToolRequests.clear();
1400
1426
  this.#multiCallGroups.clear();
@@ -1421,9 +1447,14 @@ var DuoWorkflowModel = class {
1421
1447
  }
1422
1448
  model.#lastSentGoal = null;
1423
1449
  }
1450
+ await session.ensureConnected(goal || "");
1424
1451
  const freshResults = toolResults.filter(
1425
1452
  (r) => !model.#sentToolCallIds.has(r.toolCallId)
1426
1453
  );
1454
+ dlog(`phase1: ${toolResults.length} total, ${freshResults.length} fresh, sentIds=${[...model.#sentToolCallIds].join(",")}`);
1455
+ for (const r of toolResults) {
1456
+ dlog(` tr: id=${r.toolCallId} inSent=${model.#sentToolCallIds.has(r.toolCallId)} inPending=${model.#pendingToolRequests.has(r.toolCallId)} out=${r.output.length}b`);
1457
+ }
1427
1458
  let sentToolResults = false;
1428
1459
  for (const result of freshResults) {
1429
1460
  const hashIdx = result.toolCallId.indexOf("#");
@@ -1448,9 +1479,11 @@ var DuoWorkflowModel = class {
1448
1479
  }
1449
1480
  const pending = model.#pendingToolRequests.get(result.toolCallId);
1450
1481
  if (!pending) {
1482
+ dlog(`phase1: SKIP ${result.toolCallId} (not pending)`);
1451
1483
  model.#sentToolCallIds.add(result.toolCallId);
1452
1484
  continue;
1453
1485
  }
1486
+ dlog(`phase1: SEND ${result.toolCallId} output=${result.output.length}b`);
1454
1487
  session.sendToolResult(result.toolCallId, result.output, result.error);
1455
1488
  sentToolResults = true;
1456
1489
  model.#sentToolCallIds.add(result.toolCallId);
@@ -1516,8 +1549,11 @@ var DuoWorkflowModel = class {
1516
1549
  try {
1517
1550
  mapped = mapDuoToolRequest(event.toolName, event.args);
1518
1551
  } catch {
1552
+ dlog(`phase3: MAPPING FAILED ${event.toolName}`);
1519
1553
  continue;
1520
1554
  }
1555
+ const mName = Array.isArray(mapped) ? mapped.map((m) => m.toolName).join(",") : mapped.toolName;
1556
+ dlog(`phase3: tool-request ${event.toolName} \u2192 ${mName} reqId=${event.requestId}`);
1521
1557
  if (hasText) {
1522
1558
  controller.enqueue({ type: "text-end", id: textId });
1523
1559
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.2.10",
3
+ "version": "0.2.12",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",