@proagentstore/cli 0.4.93 → 0.4.94

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.
@@ -13,16 +13,35 @@ export class CodingRuntime {
13
13
  reposBaseDir;
14
14
  sessions = new Map();
15
15
  /**
16
- * Coding sessions that are running here (#896).
16
+ * Coding turns that are running here (#896, #1007).
17
17
  *
18
- * A Claude session survives a restart — it is re-spawned with `--resume <session_id>` and only
19
- * the turn in flight is cut — but a Codex, Grok or raw-engine session restarts cold and its turn
20
- * is gone. Both are named, because the owner is the one deciding whether to take the machine.
18
+ * A retained session is a conversation, not necessarily work in flight: a healthy engine remains
19
+ * available at `runState: "idle"` between turns. Runner updates must protect only turns that can
20
+ * be interrupted. If this runtime cannot observe a session's state, retain the conservative busy
21
+ * answer rather than restarting across work whose state it cannot prove is idle.
21
22
  */
22
23
  liveWork() {
23
- return [...this.sessions.values()].map((s) => {
24
+ return [...this.sessions.values()].flatMap((s) => {
24
25
  const engine = s.clientType ?? "";
25
- return engine === "claude" ? "a Claude coding session (resumes after a restart)" : `a ${engine || "coding"} turn (lost on a restart)`;
26
+ const label = engine === "claude" ? "a Claude coding session (resumes after a restart)" : `a ${engine || "coding"} turn (lost on a restart)`;
27
+ try {
28
+ // `alive: false` is an observed inactive session. Any other answer (including a
29
+ // malformed older implementation) is unknown and must fail closed below.
30
+ const alive = s.alive;
31
+ if (alive === false)
32
+ return [];
33
+ const state = s.runState();
34
+ if (alive === true && state === "idle")
35
+ return [];
36
+ if (alive === true && (state === "thinking" || state === "responding"))
37
+ return [label];
38
+ // An unrecognised `alive`/`runState` pair is not proof that an engine is idle.
39
+ return [label];
40
+ }
41
+ catch {
42
+ // Do not turn a failed state probe into permission to restart the machine.
43
+ return [label];
44
+ }
26
45
  });
27
46
  }
28
47
  /** Background cold-start clones, one per folder (#858). */
package/dist/index.js CHANGED
@@ -1970,9 +1970,11 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
1970
1970
  const observationsUnavailable = sessionsResult.status !== "fulfilled" || healthResult.status !== "fulfilled" || !healthResult.value.work;
1971
1971
  const sessions = sessionsResult.status === "fulfilled" ? sessionsResult.value : { sessions: [] };
1972
1972
  const health = healthResult.status === "fulfilled" ? healthResult.value : {};
1973
- const activeCoding = (sessions.sessions ?? []).filter((s) => s.alive && s.runState && s.runState !== "idle").map((s) => s.sessionId);
1973
+ const activeCoding = (sessions.sessions ?? []).filter((s) => s.alive !== false && (s.alive !== true || !["idle", "thinking", "responding"].includes(s.runState ?? "") || s.runState !== "idle")).map((s) => s.sessionId || "coding-session-state-unavailable");
1974
1974
  const localRuns = health.work?.localRuns ?? 0;
1975
1975
  const codingTurns = health.work?.codingTurns ?? 0;
1976
+ const unmatchedCodingTurns = Math.max(0, codingTurns - activeCoding.length);
1977
+ const localDetail = health.work?.detail?.slice(codingTurns) ?? [];
1976
1978
  return {
1977
1979
  current: CLI_VERSION,
1978
1980
  latest: await latestPublishedVersion(),
@@ -1980,7 +1982,7 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
1980
1982
  restarter: restarterFrom(process.env),
1981
1983
  // A restart ends browser/application work too. Give these durable names to the same
1982
1984
  // planner so neither manual nor automatic update can mistake them for an idle machine.
1983
- busy: observationsUnavailable ? ["runner-work-observation-unavailable"] : [...activeCoding, ...Array.from({ length: codingTurns }, (_v, i) => `coding-turn-${i + 1}`), ...Array.from({ length: localRuns }, (_v, i) => health.work?.detail?.[i] || `local-run-${i + 1}`)]
1985
+ busy: observationsUnavailable ? ["runner-work-observation-unavailable"] : [...activeCoding, ...Array.from({ length: unmatchedCodingTurns }, (_v, i) => `coding-turn-unmatched-${i + 1}`), ...Array.from({ length: localRuns }, (_v, i) => localDetail[i] || `local-run-${i + 1}`)]
1984
1986
  };
1985
1987
  };
1986
1988
  let updateInstallInFlight = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proagentstore/cli",
3
- "version": "0.4.93",
3
+ "version": "0.4.94",
4
4
  "description": "CLI for creating, publishing, and running ProAgentStore agents",
5
5
  "license": "MIT",
6
6
  "type": "module",