squadrant 0.16.1 → 0.16.3

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.
@@ -1110,7 +1110,7 @@ async function appendToMailbox(opts) {
1110
1110
  }));
1111
1111
  }
1112
1112
  async function appendCaptainMessage(opts) {
1113
- await appendEntry(opts.stateRoot, opts.project, (seq) => ({
1113
+ return appendEntry(opts.stateRoot, opts.project, (seq) => ({
1114
1114
  seq,
1115
1115
  ts: (/* @__PURE__ */ new Date()).toISOString(),
1116
1116
  kind: "captain.message",
@@ -1512,6 +1512,9 @@ function reconcileLiveness(prev, next) {
1512
1512
  }
1513
1513
  if (next.startedAt >= prev.startedAt || next.lastState === "end")
1514
1514
  return next;
1515
+ const prevAlive = prev.lastState === "start" && prev.pidAlive;
1516
+ if (!prevAlive && next.lastState === "start" && next.pidAlive)
1517
+ return next;
1515
1518
  return prev;
1516
1519
  }
1517
1520
 
@@ -2168,9 +2171,15 @@ async function runLivenessTick(deps) {
2168
2171
  return;
2169
2172
  }
2170
2173
  const seen = /* @__PURE__ */ new Set();
2174
+ const knownCaptainSessions = /* @__PURE__ */ new Map();
2175
+ for (const e of deps.registry.all()) {
2176
+ if (e.role === "captain")
2177
+ knownCaptainSessions.set(e.sessionId, e.project);
2178
+ }
2171
2179
  const byProject = /* @__PURE__ */ new Map();
2172
2180
  for (const r of records) {
2173
- if (r.role !== "captain")
2181
+ const role = r.role === "captain" || knownCaptainSessions.get(r.sessionId) === r.project ? "captain" : r.role;
2182
+ if (role !== "captain")
2174
2183
  continue;
2175
2184
  let arr = byProject.get(r.project);
2176
2185
  if (!arr) {
@@ -2202,10 +2211,14 @@ async function runLivenessTick(deps) {
2202
2211
  logEntry(deps.log, project, deps.registry.get(project));
2203
2212
  }
2204
2213
  for (const e of deps.registry.all()) {
2205
- if (e.role === "captain" && e.lastState === "start" && !seen.has(e.project)) {
2206
- deps.registry.markEnded(e.project, now);
2207
- logEntry(deps.log, e.project, deps.registry.get(e.project));
2214
+ if (e.role !== "captain" || e.lastState !== "start" || seen.has(e.project))
2215
+ continue;
2216
+ if (e.pid == null || deps.isPidAlive(e.pid)) {
2217
+ deps.log?.(`[${e.role}/runtime] ${e.project} pid=${e.pid} missing from snapshot but not confirmed dead \u2014 leaving alive`);
2218
+ continue;
2208
2219
  }
2220
+ deps.registry.markEnded(e.project, now);
2221
+ logEntry(deps.log, e.project, deps.registry.get(e.project));
2209
2222
  }
2210
2223
  if (deps.reap) {
2211
2224
  for (const e of deps.registry.all()) {
@@ -4420,6 +4433,7 @@ import { execSync as execSync6 } from "child_process";
4420
4433
  import { readFileSync as readFileSync9 } from "fs";
4421
4434
  import { homedir as homedir9 } from "os";
4422
4435
  import { join as join14 } from "path";
4436
+ var nextAskUserQuestionRequestId = Date.now();
4423
4437
 
4424
4438
  // packages/agents/dist/headless/types.js
4425
4439
  var HEADLESS_ERROR_TAIL = 2e3;