opencode-gitlab-duo-agentic 0.2.9 → 0.2.11

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 +23 -35
  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,17 +784,6 @@ function mapActionToToolRequest(action) {
776
784
  return null;
777
785
  }
778
786
 
779
- // src/utils/debug-log.ts
780
- import { appendFileSync } from "fs";
781
- var LOG = "/tmp/duo-workflow-debug.log";
782
- function dlog(msg) {
783
- try {
784
- appendFileSync(LOG, `[${(/* @__PURE__ */ new Date()).toISOString()}] ${msg}
785
- `);
786
- } catch {
787
- }
788
- }
789
-
790
787
  // src/workflow/session.ts
791
788
  var WorkflowSession = class {
792
789
  #client;
@@ -883,11 +880,7 @@ var WorkflowSession = class {
883
880
  * Send a tool result back to DWS on the existing connection.
884
881
  */
885
882
  sendToolResult(requestId, output, error) {
886
- if (!this.#socket) {
887
- dlog(`sendToolResult: NOT CONNECTED reqId=${requestId}`);
888
- throw new Error("Not connected");
889
- }
890
- dlog(`sendToolResult: reqId=${requestId} output=${output.length}b err=${error ?? "none"}`);
883
+ if (!this.#socket) throw new Error("Not connected");
891
884
  this.#socket.send({
892
885
  actionResponse: {
893
886
  requestID: requestId,
@@ -903,10 +896,7 @@ var WorkflowSession = class {
903
896
  * Returns null when the stream is closed (turn complete or connection lost).
904
897
  */
905
898
  async waitForEvent() {
906
- if (!this.#queue) {
907
- dlog("waitForEvent: queue=null");
908
- return null;
909
- }
899
+ if (!this.#queue) return null;
910
900
  return this.#queue.shift();
911
901
  }
912
902
  /**
@@ -928,7 +918,6 @@ var WorkflowSession = class {
928
918
  }
929
919
  const toolRequests = extractToolRequests(ckpt, this.#checkpoint);
930
920
  for (const req of toolRequests) {
931
- console.error(`[duo-workflow] checkpoint tool request: ${req.toolName} requestId=${req.requestId}`);
932
921
  queue.push({
933
922
  type: "tool-request",
934
923
  requestId: req.requestId,
@@ -936,7 +925,7 @@ var WorkflowSession = class {
936
925
  args: req.args
937
926
  });
938
927
  }
939
- if (isTurnComplete(action.newCheckpoint.status)) {
928
+ if (isTurnComplete(action.newCheckpoint.status) && !isAwaitingResponse(action.newCheckpoint.status)) {
940
929
  queue.close();
941
930
  this.#closeConnection();
942
931
  }
@@ -945,7 +934,6 @@ var WorkflowSession = class {
945
934
  const toolAction = action;
946
935
  const mapped = mapActionToToolRequest(toolAction);
947
936
  if (mapped) {
948
- dlog(`action: standalone ${mapped.toolName} reqId=${mapped.requestId}`);
949
937
  queue.push({
950
938
  type: "tool-request",
951
939
  requestId: mapped.requestId,
@@ -1415,7 +1403,6 @@ var DuoWorkflowModel = class {
1415
1403
  const toolResults = extractToolResults(options.prompt);
1416
1404
  const session = this.#resolveSession(sessionID);
1417
1405
  const textId = randomUUID3();
1418
- dlog(`doStream: goal=${goal?.length ?? 0}chars, toolResults=${toolResults.length}, hasStarted=${session.hasStarted}`);
1419
1406
  if (sessionID !== this.#stateSessionId) {
1420
1407
  this.#pendingToolRequests.clear();
1421
1408
  this.#multiCallGroups.clear();
@@ -1442,6 +1429,7 @@ var DuoWorkflowModel = class {
1442
1429
  }
1443
1430
  model.#lastSentGoal = null;
1444
1431
  }
1432
+ await session.ensureConnected(goal || "");
1445
1433
  const freshResults = toolResults.filter(
1446
1434
  (r) => !model.#sentToolCallIds.has(r.toolCallId)
1447
1435
  );
@@ -1469,11 +1457,9 @@ var DuoWorkflowModel = class {
1469
1457
  }
1470
1458
  const pending = model.#pendingToolRequests.get(result.toolCallId);
1471
1459
  if (!pending) {
1472
- dlog(`phase1: toolCallId=${result.toolCallId} pending=false SKIP`);
1473
1460
  model.#sentToolCallIds.add(result.toolCallId);
1474
1461
  continue;
1475
1462
  }
1476
- dlog(`phase1: toolCallId=${result.toolCallId} pending=true SEND output=${result.output.length}b`);
1477
1463
  session.sendToolResult(result.toolCallId, result.output, result.error);
1478
1464
  sentToolResults = true;
1479
1465
  model.#sentToolCallIds.add(result.toolCallId);
@@ -1524,10 +1510,7 @@ var DuoWorkflowModel = class {
1524
1510
  let hasText = false;
1525
1511
  while (true) {
1526
1512
  const event = await session.waitForEvent();
1527
- if (!event) {
1528
- dlog("phase3: event=null (queue closed)");
1529
- break;
1530
- }
1513
+ if (!event) break;
1531
1514
  if (event.type === "text-delta") {
1532
1515
  if (!event.value) continue;
1533
1516
  if (!hasText) {
@@ -1541,10 +1524,7 @@ var DuoWorkflowModel = class {
1541
1524
  let mapped;
1542
1525
  try {
1543
1526
  mapped = mapDuoToolRequest(event.toolName, event.args);
1544
- const name = Array.isArray(mapped) ? mapped.map((m) => m.toolName).join(",") : mapped.toolName;
1545
- dlog(`phase3: tool-request ${event.toolName} \u2192 ${name} reqId=${event.requestId}`);
1546
1527
  } catch {
1547
- dlog(`phase3: tool-request ${event.toolName} MAPPING FAILED`);
1548
1528
  continue;
1549
1529
  }
1550
1530
  if (hasText) {
@@ -1561,20 +1541,28 @@ var DuoWorkflowModel = class {
1561
1541
  model.#pendingToolRequests.set(subId, {});
1562
1542
  }
1563
1543
  for (let i = 0; i < mapped.length; i++) {
1544
+ const inputJson = JSON.stringify(mapped[i].args);
1545
+ controller.enqueue({ type: "tool-input-start", id: subIds[i], toolName: mapped[i].toolName });
1546
+ controller.enqueue({ type: "tool-input-delta", id: subIds[i], delta: inputJson });
1547
+ controller.enqueue({ type: "tool-input-end", id: subIds[i] });
1564
1548
  controller.enqueue({
1565
1549
  type: "tool-call",
1566
1550
  toolCallId: subIds[i],
1567
1551
  toolName: mapped[i].toolName,
1568
- input: JSON.stringify(mapped[i].args)
1552
+ input: inputJson
1569
1553
  });
1570
1554
  }
1571
1555
  } else {
1572
1556
  model.#pendingToolRequests.set(event.requestId, {});
1557
+ const inputJson = JSON.stringify(mapped.args);
1558
+ controller.enqueue({ type: "tool-input-start", id: event.requestId, toolName: mapped.toolName });
1559
+ controller.enqueue({ type: "tool-input-delta", id: event.requestId, delta: inputJson });
1560
+ controller.enqueue({ type: "tool-input-end", id: event.requestId });
1573
1561
  controller.enqueue({
1574
1562
  type: "tool-call",
1575
1563
  toolCallId: event.requestId,
1576
1564
  toolName: mapped.toolName,
1577
- input: JSON.stringify(mapped.args)
1565
+ input: inputJson
1578
1566
  });
1579
1567
  }
1580
1568
  controller.enqueue({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-gitlab-duo-agentic",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "OpenCode plugin and provider for GitLab Duo Agentic workflows",
5
5
  "license": "MIT",
6
6
  "type": "module",