cubefarm 0.3.3 → 0.3.5

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.html CHANGED
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com" />
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
10
10
  <link href="https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet" />
11
- <script type="module" crossorigin src="/assets/index-BCFM-9fU.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-CeoPkKws.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-BU33ZUhQ.css">
13
13
  </head>
14
14
  <body>
@@ -1588,6 +1588,12 @@ function idleHook(live, b) {
1588
1588
  }
1589
1589
  return {};
1590
1590
  }
1591
+ function resumableSession(b, exists2) {
1592
+ const id = typeof b.session_id === "string" ? b.session_id : "";
1593
+ const file = typeof b.transcript_path === "string" ? b.transcript_path : "";
1594
+ return id && file && exists2(file) ? id : null;
1595
+ }
1596
+ var lostConversation = (screen) => /No conversation found with session ID/i.test(screen);
1591
1597
  function startCliSession(opts, callbacks) {
1592
1598
  const term = opts.terminal;
1593
1599
  const prev = lives.get(term);
@@ -1606,6 +1612,7 @@ function startCliSession(opts, callbacks) {
1606
1612
  const officePrompts = [];
1607
1613
  const launched = [];
1608
1614
  let mainThread = opts.resumeSessionId ?? null;
1615
+ let kept = opts.resumeSessionId ?? null;
1609
1616
  const usageResets = /* @__PURE__ */ new Map();
1610
1617
  const warned = /* @__PURE__ */ new Set();
1611
1618
  let done = false;
@@ -1699,6 +1706,13 @@ function startCliSession(opts, callbacks) {
1699
1706
  const hook = (b) => {
1700
1707
  const event = String(b.hook_event_name ?? "");
1701
1708
  const sub = typeof b.agent_id === "string" && b.agent_id !== "";
1709
+ if (cli === "claude" && !sub && b.session_id !== kept) {
1710
+ const id = resumableSession(b, fs6.existsSync);
1711
+ if (id) {
1712
+ kept = id;
1713
+ cb.sessionId(id);
1714
+ }
1715
+ }
1702
1716
  switch (event) {
1703
1717
  case "PreToolUse": {
1704
1718
  const name = String(b.tool_name ?? "");
@@ -1797,6 +1811,11 @@ function startCliSession(opts, callbacks) {
1797
1811
  return {};
1798
1812
  };
1799
1813
  const exited = (exitCode) => {
1814
+ if (cli === "claude" && opts.resumeSessionId && !begun && lostConversation(term.screen())) {
1815
+ cb.sessionId(null);
1816
+ finish({ ok: false, text: "", errors: [`${label} couldn't find the conversation it was resuming, so the next session starts a new one.`] });
1817
+ return;
1818
+ }
1800
1819
  const ok = exitCode === 0 && (lastText !== "" || cli !== "claude" && Date.now() - started > 2e4);
1801
1820
  finish({ ok, text: lastText, errors: ok ? [] : [`${label} exited${exitCode ? ` with code ${exitCode}` : ""} before finishing.`] });
1802
1821
  };
@@ -1898,7 +1917,7 @@ ${JSON.stringify(opts.outputSchema)}`;
1898
1917
  env[k] = v;
1899
1918
  }
1900
1919
  Object.assign(env, { TERM: "xterm-256color", COLORTERM: "truecolor" }, launch2.env);
1901
- if (cli === "claude") cb.sessionId(sessionId);
1920
+ if (cli === "claude" && opts.resumeSessionId) cb.sessionId(sessionId);
1902
1921
  term.note(`\u2500\u2500 ${label}${opts.label ? ` \xB7 ${opts.label}` : ""} \u2500\u2500`);
1903
1922
  const resumeId = cli === "claude" ? sessionId : opts.resumeSessionId ?? null;
1904
1923
  const l = { agentId: opts.agentId ?? "", cli, term, proc: null, token, dir, resumeId, statusLine, shots: /* @__PURE__ */ new Set(), session: { hook, exited } };
@@ -3465,6 +3484,13 @@ function mergeStep(pr, rec, now2, opts) {
3465
3484
  return { do: "merge", set };
3466
3485
  }
3467
3486
 
3487
+ // server/qaOrphans.ts
3488
+ function orphanedQa(qa, agents, busy) {
3489
+ return qa.filter(
3490
+ (q) => q.status === "testing" && !agents.some((a) => a.id === q.qaAgentId && busy.includes(a.status) && a.task === "qa" && a.repoId === q.repoId && a.prNumber === q.prNumber)
3491
+ );
3492
+ }
3493
+
3468
3494
  // server/previews.ts
3469
3495
  var PREVIEW_BASE_PORT = 6300;
3470
3496
  var LOG_KEEP = 200;
@@ -4243,6 +4269,7 @@ var Swarm = class {
4243
4269
  ]);
4244
4270
  for (const r of this.state.repos) void this.previews.refreshDefault(r);
4245
4271
  this.recover(interrupted);
4272
+ for (const rec of orphanedQa(this.state.qa, this.state.agents, BUSY)) this.setQa(rec, { status: "queued", qaAgentId: null });
4246
4273
  this.officeHead = await this.backend.office.head();
4247
4274
  const updated = await this.backend.office.takeLastUpdate().catch(() => null);
4248
4275
  if (updated) await this.reportUpdate(updated);
@@ -5205,7 +5232,7 @@ Note from the manager: ${note}` : ""
5205
5232
  },
5206
5233
  sessionId: (id) => {
5207
5234
  a.sessionId = id;
5208
- a.sessionCli = how.cli ?? "claude";
5235
+ a.sessionCli = id ? how.cli ?? "claude" : null;
5209
5236
  },
5210
5237
  browserUrl: (url) => {
5211
5238
  rt.browserUrl = url;
@@ -6131,7 +6158,7 @@ ${job.text}` } : job;
6131
6158
  },
6132
6159
  sessionId: (id) => {
6133
6160
  a.sessionId = id;
6134
- a.sessionCli = "claude";
6161
+ a.sessionCli = id ? "claude" : null;
6135
6162
  },
6136
6163
  browserUrl: () => void 0,
6137
6164
  screenshot: () => void 0,