@evident-ai/cli 3.0.1-dev.f0063e2 → 3.0.1-dev.f10ab0f

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.
package/dist/index.js CHANGED
@@ -470,6 +470,12 @@ import chalk6 from "chalk";
470
470
  import ora3 from "ora";
471
471
  import { select as select3 } from "@inquirer/prompts";
472
472
 
473
+ // ../../packages/types/src/opencode/index.ts
474
+ function opencodeMessageIdFor(queuedMessageId) {
475
+ const sanitized = queuedMessageId.replace(/[^a-zA-Z0-9]/g, "_");
476
+ return `msg_${sanitized}`;
477
+ }
478
+
473
479
  // ../../packages/types/src/telemetry/index.ts
474
480
  var TelemetryEventTypes = {
475
481
  // Agent activity events (shown in web UI activity log)
@@ -1023,6 +1029,12 @@ function parentIdOf(m) {
1023
1029
  const infoParent = m.info?.parentID;
1024
1030
  return typeof infoParent === "string" ? infoParent : void 0;
1025
1031
  }
1032
+ function finishOf(m) {
1033
+ if (!m || typeof m !== "object") return void 0;
1034
+ if (typeof m.finish === "string") return m.finish;
1035
+ const infoFinish = m.info?.finish;
1036
+ return typeof infoFinish === "string" ? infoFinish : void 0;
1037
+ }
1026
1038
  async function createOpenCodeSession(port, directory) {
1027
1039
  const url = new URL(`${opencodeBase(port)}/session`);
1028
1040
  if (directory && directory.trim()) {
@@ -1080,19 +1092,36 @@ function findAssistantReplyAfter(messages, userMessageId) {
1080
1092
  }
1081
1093
  return null;
1082
1094
  }
1095
+ function findLastAssistantReplyFor(messages, userMessageId) {
1096
+ if (!messages || messages.length === 0) return null;
1097
+ for (let i = messages.length - 1; i >= 0; i--) {
1098
+ const m = messages[i];
1099
+ if (roleOf(m) === "assistant" && parentIdOf(m) === userMessageId) return m;
1100
+ }
1101
+ const userIndex = messages.findIndex((m) => idOf(m) === userMessageId);
1102
+ if (userIndex === -1) return null;
1103
+ let last = null;
1104
+ for (let i = userIndex + 1; i < messages.length; i++) {
1105
+ const role = roleOf(messages[i]);
1106
+ if (role === "user") break;
1107
+ if (role === "assistant") last = messages[i];
1108
+ }
1109
+ return last;
1110
+ }
1083
1111
  function messageRunState(messages, userMessageId) {
1084
1112
  if (!messages || messages.length === 0) return "unknown";
1085
1113
  const hasUser = messages.some((m) => idOf(m) === userMessageId);
1086
- const reply = findAssistantReplyAfter(messages, userMessageId);
1114
+ const reply = findLastAssistantReplyFor(messages, userMessageId);
1087
1115
  if (!hasUser) {
1088
1116
  if (!reply) return "unknown";
1089
1117
  }
1090
1118
  if (!reply) return "queued";
1091
- return completedOf(reply) != null ? "done" : "running";
1119
+ if (completedOf(reply) == null) return "running";
1120
+ if (finishOf(reply) === "tool-calls") return "running";
1121
+ return "done";
1092
1122
  }
1093
- function opencodeMessageIdFor(queuedMessageId) {
1094
- const sanitized = queuedMessageId.replace(/[^a-zA-Z0-9]/g, "_");
1095
- return `msg_${sanitized}`;
1123
+ function opencodeMessageIdFor2(queuedMessageId) {
1124
+ return opencodeMessageIdFor(queuedMessageId);
1096
1125
  }
1097
1126
 
1098
1127
  // src/lib/tunnel/connection.ts
@@ -1645,11 +1674,13 @@ var ChannelDriver = class {
1645
1674
  const sessionId = await this.ensureSession(conv);
1646
1675
  const messages = await this.getPendingMessages(conv.id);
1647
1676
  let dispatched = 0;
1677
+ let skippedAlreadyDispatched = 0;
1648
1678
  for (const message of messages) {
1649
1679
  if (this.dispatched.has(message.id)) {
1680
+ skippedAlreadyDispatched += 1;
1650
1681
  continue;
1651
1682
  }
1652
- const opencodeMessageId = opencodeMessageIdFor(message.id);
1683
+ const opencodeMessageId = opencodeMessageIdFor2(message.id);
1653
1684
  const options = {
1654
1685
  agent: message.opencode_agent ?? void 0,
1655
1686
  model: message.opencode_model ?? void 0
@@ -1679,6 +1710,13 @@ var ChannelDriver = class {
1679
1710
  this.registerInFlight(conv, sessionId, message, opencodeMessageId);
1680
1711
  dispatched += 1;
1681
1712
  }
1713
+ if (messages.length > 0 && dispatched === 0 && skippedAlreadyDispatched === messages.length) {
1714
+ this.log({
1715
+ level: "error",
1716
+ message: `Conversation ${conv.id.slice(0, 8)} has ${messages.length} pending message(s) but ALL are already marked dispatched locally (in-flight set: ${this.dispatched.size}) \u2014 none sent to OpenCode this tick. If this repeats, a message may be stuck acknowledged-but-never-dispatched (its watcher never settled).`,
1717
+ conversation_id: conv.id
1718
+ });
1719
+ }
1682
1720
  this.ensureWatcherRunning(sessionId);
1683
1721
  return dispatched;
1684
1722
  }