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

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
@@ -1023,6 +1023,12 @@ function parentIdOf(m) {
1023
1023
  const infoParent = m.info?.parentID;
1024
1024
  return typeof infoParent === "string" ? infoParent : void 0;
1025
1025
  }
1026
+ function finishOf(m) {
1027
+ if (!m || typeof m !== "object") return void 0;
1028
+ if (typeof m.finish === "string") return m.finish;
1029
+ const infoFinish = m.info?.finish;
1030
+ return typeof infoFinish === "string" ? infoFinish : void 0;
1031
+ }
1026
1032
  async function createOpenCodeSession(port, directory) {
1027
1033
  const url = new URL(`${opencodeBase(port)}/session`);
1028
1034
  if (directory && directory.trim()) {
@@ -1080,15 +1086,33 @@ function findAssistantReplyAfter(messages, userMessageId) {
1080
1086
  }
1081
1087
  return null;
1082
1088
  }
1089
+ function findLastAssistantReplyFor(messages, userMessageId) {
1090
+ if (!messages || messages.length === 0) return null;
1091
+ for (let i = messages.length - 1; i >= 0; i--) {
1092
+ const m = messages[i];
1093
+ if (roleOf(m) === "assistant" && parentIdOf(m) === userMessageId) return m;
1094
+ }
1095
+ const userIndex = messages.findIndex((m) => idOf(m) === userMessageId);
1096
+ if (userIndex === -1) return null;
1097
+ let last = null;
1098
+ for (let i = userIndex + 1; i < messages.length; i++) {
1099
+ const role = roleOf(messages[i]);
1100
+ if (role === "user") break;
1101
+ if (role === "assistant") last = messages[i];
1102
+ }
1103
+ return last;
1104
+ }
1083
1105
  function messageRunState(messages, userMessageId) {
1084
1106
  if (!messages || messages.length === 0) return "unknown";
1085
1107
  const hasUser = messages.some((m) => idOf(m) === userMessageId);
1086
- const reply = findAssistantReplyAfter(messages, userMessageId);
1108
+ const reply = findLastAssistantReplyFor(messages, userMessageId);
1087
1109
  if (!hasUser) {
1088
1110
  if (!reply) return "unknown";
1089
1111
  }
1090
1112
  if (!reply) return "queued";
1091
- return completedOf(reply) != null ? "done" : "running";
1113
+ if (completedOf(reply) == null) return "running";
1114
+ if (finishOf(reply) === "tool-calls") return "running";
1115
+ return "done";
1092
1116
  }
1093
1117
  function opencodeMessageIdFor(queuedMessageId) {
1094
1118
  const sanitized = queuedMessageId.replace(/[^a-zA-Z0-9]/g, "_");