@join-pantheon/cli 0.38.1 → 0.38.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.
package/dist/doctor.js CHANGED
@@ -11,11 +11,12 @@ import { commandState } from "./command-state.js";
11
11
  import { existsSync, readFileSync, readdirSync, realpathSync } from "node:fs";
12
12
  import { homedir, platform } from "node:os";
13
13
  import { dirname, join, resolve, sep } from "node:path";
14
- import { expectedLauncher, managedLayout, runtimeNodeFit, runtimeVerdict } from "./managed.js";
14
+ import { expectedLauncher, installerLineHere, managedLayout, runtimeNodeFit, runtimeVerdict } from "./managed.js";
15
+ import { heldBack, heldUpgradeSentence, readProbation, readRolledBack } from "./upgrade-probation.js";
15
16
  import { compareVersions } from "./installer.js";
16
17
  import { PKG_NAME } from "./upgrade.js";
17
18
  import { PantheonClient } from "./client.js";
18
- import { load, resolveFor, loadAll, configFor, CONFIG_PATH } from "./config.js";
19
+ import { load, resolveFor, loadAll, configFor, CONFIG_DIR, CONFIG_PATH } from "./config.js";
19
20
  import { fingerprint, signChallenge, verifyChallenge } from "./identity.js";
20
21
  import { approvalSummary, briefState, chosenApproval, copilotMcpConfigFile, kiroMcpConfigFile, onPath } from "./install.js";
21
22
  import { hookState, readIntent, agentHookStates, repairNote } from "./notify.js";
@@ -24,7 +25,7 @@ import { workerProc, menubarProc, notifierProc, workerFlagRunMinutes } from "./m
24
25
  import { isCatchAllDomain } from "./protocol.js";
25
26
  import { probeLinuxSandbox, sandboxDoctorRow } from "./linux-sandbox.js";
26
27
  import { goneLine, leaveCommand, removalKey, removalRefusal, removals, removalWords, teamsOf } from "./removed.js";
27
- import { agentById, chooseAgent, describeChoice, detectAvailable, folderReaderLine, knownUserBinary, unattendedReadiness, unattendedRefusal, skippedSummary, SANDBOXED_FOR_UNATTENDED } from "./agents.js";
28
+ import { agentById, cannotStartWords, chooseAgent, describeChoice, detectAvailable, folderReaderLine, knownUserBinary, unattendedReadiness, unattendedRefusal, skippedSummary, SANDBOXED_FOR_UNATTENDED } from "./agents.js";
28
29
  import { loginShellLookup, npmSpawn, onPathNamed, which, whichWindows } from "./which.js";
29
30
  import { VERSION } from "./version.js";
30
31
  import { borrowedScheduler, realSys, serviceInstalled, serviceLogFile, servicesUnavailable } from "./service.js";
@@ -236,6 +237,49 @@ export function crashLoopRows(o = {}) {
236
237
  }
237
238
  return rows;
238
239
  }
240
+ export function upgradeRows(o = {}) {
241
+ const m = o.m === undefined ? managedLayout() : o.m;
242
+ if (!m)
243
+ return [];
244
+ const rows = [];
245
+ const p = (() => { try {
246
+ return readProbation(m);
247
+ }
248
+ catch {
249
+ return null;
250
+ } })();
251
+ if (p?.stuck && p.to === (o.version ?? VERSION)) {
252
+ rows.push({
253
+ level: "warn", name: "upgrade",
254
+ detail: `Pantheon ${p.to} kept failing on this computer after it was installed, and could not go back to the version before it by itself: ${p.stuck_why ?? "no previous version is kept"}`,
255
+ fix: `run the installer again — it repairs Pantheon and keeps your teams and settings: ${installerLineHere(o.relay, o.os ?? platform())}`,
256
+ share: `${p.to} failing, could not go back`,
257
+ });
258
+ }
259
+ const h = (() => { try {
260
+ return readRolledBack(m);
261
+ }
262
+ catch {
263
+ return null;
264
+ } })();
265
+ if (h)
266
+ rows.push({ level: "pass", name: "upgrade", detail: heldUpgradeSentence(h), share: `went back from ${h.version} to ${h.back_to}` });
267
+ return rows;
268
+ }
269
+ export function versionSkewRow(local, relayPkg, held) {
270
+ if (held && held.version === relayPkg) {
271
+ return {
272
+ level: "pass",
273
+ detail: `this machine is ${local}; the relay is ${relayPkg}, which did not work on this computer and was put back to ${held.back_to} — nothing to do, it updates by itself when a newer release is out`,
274
+ share: `this machine ${local}; relay ${relayPkg} was put back here`,
275
+ };
276
+ }
277
+ return {
278
+ level: "warn", detail: `this machine is ${local}, the relay is ${relayPkg}`,
279
+ fix: "run `pantheon upgrade` on the older side — features land on both halves of the wire, and the protocol version cannot tell you they are missing",
280
+ share: `this machine ${local}, relay ${relayPkg}`,
281
+ };
282
+ }
239
283
  export async function doctor(projectDir) {
240
284
  const out = [];
241
285
  const add = (level, name, detail, fix, share) => out.push({ level, name, detail, ...(fix ? { fix } : {}), ...(share ? { share } : {}) });
@@ -263,6 +307,8 @@ export async function doctor(projectDir) {
263
307
  const fit = runtimeNodeFit(facts.layout, process.versions.node, newestRelease(), relay);
264
308
  if (fit)
265
309
  add(fit.level, "runtime node", fit.detail, fit.fix, fit.share);
310
+ for (const r of upgradeRows({ m: facts.layout, relay }))
311
+ add(r.level, r.name, r.detail, r.fix, r.share);
266
312
  }
267
313
  }
268
314
  const host = hostEnv();
@@ -485,13 +531,24 @@ export async function doctor(projectDir) {
485
531
  const line = describeChoice(choice).replace(/\bnot signed in\b/g, "signed out");
486
532
  const bad = choice.signIn && !choice.signIn.ok && !choice.signIn.unknown;
487
533
  const fellBack = !!prof.agent.primary_surface && choice.backend.id !== prof.agent.primary_surface && agents.length > 0;
488
- const shareLine = `${choice.backend.label} — ${choice.signIn?.detail ?? "not checked"}${choice.skipped.length ? `; ${skippedSummary(choice)}` : ""}`;
534
+ const shareLine = `${choice.backend.label} — ${choice.cannotStart ? "cannot start here" : choice.signIn?.detail ?? "not checked"}${choice.skipped.length ? `; ${skippedSummary(choice)}` : ""}`;
489
535
  const refused = unattendedRefusal(choice, { unsandboxedOk });
490
536
  const surface = prof.agent.primary_surface ? agentById(prof.agent.primary_surface) : undefined;
491
- if (refused)
537
+ const claudeHere = detectAvailable().some((a) => a.backend.id === "claude-code");
538
+ const passedOver = choice.skipped.filter((x) => x.cannotStart);
539
+ if (choice.cannotStart) {
540
+ const w = cannotStartWords(choice.backend, choice.cannotStart, { claudeHere });
541
+ add(workerSetUp ? "fail" : "warn", "worker agent", line, `no request can run here while you're away until it starts. ${w.fix}`, shareLine);
542
+ }
543
+ else if (refused)
492
544
  add("warn", "worker agent", line, `teammates' requests wait for your next session here: ${refused}`, shareLine);
493
545
  else if (bad)
494
546
  add("warn", "worker agent", line, `your agent is signed out, so every woken run here fails until you sign in again: ${choice.skipped.map((x) => x.why.replace(/\bnot signed in\b/g, "signed out")).join("; ") || "sign in to the agent CLI"}`, shareLine);
547
+ else if (passedOver.length) {
548
+ const x = passedOver.find((p) => p.backend.id === surface?.id) ?? passedOver[0];
549
+ const w = cannotStartWords(x.backend, x.cannotStart ?? {}, { claudeHere: true });
550
+ add("warn", "worker agent", line, `${x.backend.id === surface?.id ? `you chose ${x.backend.label} at setup; it` : x.backend.label} cannot start here, so runs while you're away use ${choice.backend.label}. ${w.fix}${x.backend.id === surface?.id ? ` To make ${choice.backend.label} your choice instead: pantheon setup --agent ${choice.backend.id}` : ""}`, shareLine);
551
+ }
495
552
  else if (fellBack)
496
553
  add("warn", "worker agent", line, prof.agent.primary_surface === "kiro"
497
554
  ? `you chose Kiro at setup; Kiro answers in your live sessions, and runs while you're away use ${choice.backend.label}`
@@ -506,6 +563,15 @@ export async function doctor(projectDir) {
506
563
  catch (e) {
507
564
  add("warn", "worker agent", e.message, "pantheon setup --agent <claude-code|codex|cursor|copilot|kiro> names one that is installed", "could not be chosen");
508
565
  }
566
+ try {
567
+ const { agentCannotStart } = await import("./readiness-alert.js");
568
+ const found = agentCannotStart(CONFIG_DIR);
569
+ const b = found ? agentById(found) : undefined;
570
+ if (b && !out.some((c) => c.name === "worker agent" && c.detail.includes(`${b.label} — cannot start here`))) {
571
+ add("warn", "worker agent", `your worker, in the background, found that ${b.label} cannot start there, although this terminal finds it`, `it looks again now${askedRecheck ? "" : " at its next check"}: pantheon status says what it finds. If it still cannot start there, the worker does not find a program this terminal does (the agent itself, or the Node it needs) — ${cannotStartWords(b, {}, { claudeHere: true }).fix}`, `${b.label} cannot start for the worker`);
572
+ }
573
+ }
574
+ catch { }
509
575
  try {
510
576
  const { signedOutChecking, SIGNED_OUT_AGENTS } = await import("./signed-out.js");
511
577
  const { SIGN_IN_FIX } = await import("./run-failure.js");
@@ -654,7 +720,13 @@ export async function doctor(projectDir) {
654
720
  add("pass", "version", `${VERSION}; the relay is holding upgrades at ${held} for now, so this machine stays where it is`, undefined, `${VERSION}, upgrades held at ${held}`);
655
721
  }
656
722
  else if (body.pkg && body.pkg !== VERSION) {
657
- add("warn", "version", `this machine is ${VERSION}, the relay is ${body.pkg}`, "run `pantheon upgrade` on the older side — features land on both halves of the wire, and the protocol version cannot tell you they are missing", `this machine ${VERSION}, relay ${body.pkg}`);
723
+ const row = versionSkewRow(VERSION, body.pkg, (() => { try {
724
+ return heldBack(body.pkg);
725
+ }
726
+ catch {
727
+ return null;
728
+ } })());
729
+ add(row.level, "version", row.detail, row.fix, row.share);
658
730
  }
659
731
  else if (body.pkg) {
660
732
  add("pass", "version", `${VERSION}, matching the relay`, undefined, `${VERSION}, matching the relay`);
package/dist/file-lock.js CHANGED
@@ -182,6 +182,24 @@ export function brokenStateFix(broken) {
182
182
  parts.push(`and the folder${folders.length === 1 ? "" : "s"} ${folders.join(", ")} in the Pantheon folder (on a Mac: chflags nouchg,nouappnd on ${folders.length === 1 ? "it" : "them"})`);
183
183
  return parts.join("; ");
184
184
  }
185
+ export function removeAside(p, o = {}) {
186
+ const rm = o.rm ?? ((x) => rmSync(x, { force: true }));
187
+ const tries = o.tries ?? 5;
188
+ for (let i = 0; i < tries; i++) {
189
+ try {
190
+ rm(p);
191
+ return true;
192
+ }
193
+ catch (e) {
194
+ const code = e.code;
195
+ if (code !== "EBUSY" && code !== "EPERM" && code !== "EACCES")
196
+ return false;
197
+ if (i < tries - 1)
198
+ (o.sleep ?? sleepSync)(5 * (i + 1));
199
+ }
200
+ }
201
+ return false;
202
+ }
185
203
  export function withFileLock(f, fn, waitMs = WAIT_MS) {
186
204
  mkdirSync(dirname(f), { recursive: true, mode: 0o700 });
187
205
  const lock = `${f}.lock`;
@@ -212,10 +230,7 @@ export function withFileLock(f, fn, waitMs = WAIT_MS) {
212
230
  }
213
231
  }
214
232
  finally {
215
- try {
216
- rmSync(made, { force: true });
217
- }
218
- catch { }
233
+ removeAside(made);
219
234
  }
220
235
  try {
221
236
  return fn();
@@ -521,6 +521,7 @@ export const REFUSAL_WORDS = {
521
521
  SPACE_UNREADABLE: "a team whose files could not be read",
522
522
  STALE_VIEW: "a change made from an out-of-date view",
523
523
  STORAGE: "a write the disk refused",
524
+ STORAGE_BUSY: "the disk was behind on this team's writes",
524
525
  SUMMARY_REQUIRED: "a long message with no one-line summary",
525
526
  TO_REQUIRED: "an ask that named nobody",
526
527
  TOO_MANY_GOALS: "too many open goals",
@@ -64,12 +64,17 @@ export const PANTHEON_HOME_ENTRIES = [
64
64
  { name: "data", what: "the relay's ledger", dir: true, kept: "it is your team's history and may be its only copy; delete it yourself once no relay runs from it" },
65
65
  { name: /^(\.DS_Store|Thumbs\.db|desktop\.ini)$/i, sample: ".DS_Store", what: "the file browser's folder cache" },
66
66
  ];
67
+ const LOCK_DEBRIS = /^(.+?)\.lock\.(?:[0-9a-f]+\.new|break(?:\.\d+\.[0-9a-f]+)?|stale\.\d+\.[0-9a-f]+)$/i;
67
68
  const LOCK_OR_TMP = /^(.+?)(\.lock|(\.[0-9a-f]+)*\.tmp)$/i;
68
69
  export function homeEntryFor(name) {
69
70
  const direct = (n) => PANTHEON_HOME_ENTRIES.find((e) => typeof e.name === "string" ? e.name === n : e.name.test(n)) ?? null;
70
71
  const e = direct(name);
71
72
  if (e)
72
73
  return e;
74
+ const d = LOCK_DEBRIS.exec(name);
75
+ const debrisOf = d ? direct(d[1]) : null;
76
+ if (debrisOf && !debrisOf.dir)
77
+ return { name, what: `a lock's leftover file (${debrisOf.what})` };
73
78
  const m = LOCK_OR_TMP.exec(name);
74
79
  const base = m ? direct(m[1]) : null;
75
80
  return base && !base.dir ? base : null;
package/dist/ledger.js CHANGED
@@ -180,15 +180,21 @@ export class Ledger {
180
180
  inTail = (_r, i) => tail[i] === 1;
181
181
  }
182
182
  let newestDropped = null;
183
+ const want = opts.onlyIfFrees ?? 0;
184
+ let frees = 0;
183
185
  const kept = this.records.filter((r, i) => {
184
186
  const keep = inTail(r, i) || opts.isLive(r.goal) || (opts.keep?.(r.id) ?? false);
185
187
  if (!keep && !pres?.is(r) && (newestDropped === null || r.ts > newestDropped))
186
188
  newestDropped = r.ts;
189
+ if (!keep && frees < want)
190
+ frees += Buffer.byteLength(JSON.stringify(r)) + 1;
187
191
  return keep;
188
192
  });
189
193
  const dropped = this.records.length - kept.length;
190
194
  if (dropped === 0)
191
195
  return { dropped: 0, kept: kept.length, newestDropped: null };
196
+ if (frees < want)
197
+ return { dropped: 0, kept: n, newestDropped: null };
192
198
  const text = kept.map((r) => JSON.stringify(r)).join("\n") + "\n";
193
199
  writerFor(this.dir, this.stem).replace(this.file, text);
194
200
  this.records = kept;
package/dist/leftovers.js CHANGED
@@ -2,7 +2,7 @@ import { closeSync, existsSync, fstatSync, openSync, readFileSync, readSync, rea
2
2
  import { join } from "node:path";
3
3
  import { pendingView } from "./disk-writer.js";
4
4
  export const DELETED_NAME_HOLD_MS = 3_600_000;
5
- export const TEAM_FILES = [".members.json", ".jsonl", ".state.json", ".usage.json"];
5
+ export const TEAM_FILES = [".members.json", ".jsonl", ".state.json", ".usage.json", ".closed-goals.json"];
6
6
  const iso = (t) => new Date(t).toISOString().replace(/\.\d+Z$/, "Z");
7
7
  const strs = (x) => (Array.isArray(x) ? x.filter((h) => typeof h === "string") : []);
8
8
  export function tombViewOfText(text) {
@@ -102,7 +102,11 @@ export function classifyLeftover(dataDir, stem, tomb, hold = DELETED_NAME_HOLD_M
102
102
  const pending = pendingView(dataDir, stem, rf);
103
103
  if (pending === null || (pending === undefined && !existsSync(rf))) {
104
104
  const left = TEAM_FILES.filter((x) => x !== ".members.json" && existsSync(join(dataDir, `${stem}${x}`))).map((x) => `${stem}${x}`);
105
- return left.length ? out("unsure", `quarantine or delete incomplete: ${left.join(", ")} still here without the member list`) : out("live", "no member list on disk");
105
+ if (!left.length)
106
+ return out("live", "no member list on disk");
107
+ const unsure = out("unsure", `quarantine or delete incomplete: ${left.join(", ")} still here without the member list`);
108
+ return left.length === 1 && left[0] === `${stem}.closed-goals.json`
109
+ ? { ...unsure, why: `${unsure.why} (only its old closed goals: a new team may take the name after the hold, and never reads them)`, nameFree: true } : unsure;
106
110
  }
107
111
  if (tomb.unreadable)
108
112
  return out("unsure", `its tombstone cannot be read right now (${tomb.unreadable})`);
package/dist/mcp.js CHANGED
@@ -19,6 +19,7 @@ import { openFailureWhy, openQuestionGoal, questionFailureText, settleFailedQues
19
19
  import { VERSION } from "./version.js";
20
20
  import { installedVersion } from "./mcp-supervisor.js";
21
21
  import { behindStatusLine, localVersion, readVersionHealth, refreshRelayPkg, relayKey, RELAY_PKG_REFRESH_MS } from "./version-health.js";
22
+ import { readRolledBack } from "./upgrade-probation.js";
22
23
  import { loadPolicy } from "./worker-policy.js";
23
24
  import { backendFromLabel } from "./agents.js";
24
25
  import { agentHookStates } from "./notify.js";
@@ -406,7 +407,13 @@ export async function runMcp() {
406
407
  catch {
407
408
  policy = null;
408
409
  }
409
- const line = behindStatusLine({ local: localVersion(), seen, now: Date.now(), policy, state, full: !behindSaid });
410
+ const rolledBack = (() => { try {
411
+ return readRolledBack()?.version ?? null;
412
+ }
413
+ catch {
414
+ return null;
415
+ } })();
416
+ const line = behindStatusLine({ local: localVersion(), seen, now: Date.now(), policy, state, full: !behindSaid, rolledBack });
410
417
  if (line?.startsWith("PANTHEON IS OUT OF DATE"))
411
418
  behindSaid = true;
412
419
  return line;
package/dist/notice.js CHANGED
@@ -249,7 +249,7 @@ export function composeWaiting(items, team, ctx) {
249
249
  tag: `waiting_${team.replace(/[^A-Za-z0-9_]/g, "_")}`.slice(0, 60),
250
250
  };
251
251
  }
252
- export const DECLINE_CODES = ["wake", "wake_ask", "wake_off", "team_wake", "playbook", "capped", "failed", "commands", "not_here", "no_folder", "unavailable", "signed_out", "unsigned", "goal_cap"];
252
+ export const DECLINE_CODES = ["wake", "wake_ask", "wake_off", "team_wake", "playbook", "capped", "failed", "commands", "not_here", "no_folder", "unavailable", "signed_out", "unsigned", "goal_cap", "cannot_start"];
253
253
  export function declineCodeOf(r) {
254
254
  const m = r?.meta;
255
255
  if (!r || r.act !== "NOTE" || !m || typeof m.declined !== "string")
@@ -270,6 +270,7 @@ export function declineWords(code, who) {
270
270
  case "not_here": return `${who}'s computer doesn't have the repo it's about`;
271
271
  case "no_folder": return `nothing on ${who}'s computer is linked to this team yet`;
272
272
  case "signed_out": return `${who}'s agent is signed out`;
273
+ case "cannot_start": return `${who}'s agent can't start on ${who}'s computer`;
273
274
  case "unsigned": return `${who}'s computer couldn't check it came from you — upgrading Pantheon (pantheon upgrade) fixes that`;
274
275
  default: return `nothing on ${who}'s computer can take it while ${who} is away`;
275
276
  }
package/dist/pickup.js CHANGED
@@ -23,6 +23,7 @@ const UNAVAILABLE = {
23
23
  sandbox_unavailable: "its Linux sandbox can't start",
24
24
  pinned_kiro: "its worker is set to use Kiro, which answers only in live sessions",
25
25
  pinned_unsandboxed: "its worker is set to use an agent without a sandbox, and it is set to leave requests for its person",
26
+ cannot_start: "its agent can't start there",
26
27
  };
27
28
  function reasonOf(w) {
28
29
  if (w.reason && WORKER_REASONS.includes(w.reason))
package/dist/plain.js CHANGED
@@ -129,6 +129,7 @@ export const STEPS = {
129
129
  RESERVED_NAME: "pick another name",
130
130
  SIGNED_ONLY: "run it as the founder: `pantheon usage`",
131
131
  STORAGE: "wait a moment, then check `pantheon history` before sending it again — it may already be kept",
132
+ STORAGE_BUSY: "wait a few seconds, then send it again",
132
133
  SHUTTING_DOWN: "wait a few seconds, then try again",
133
134
  TOO_MANY_REFUSALS: "fix the request that keeps being refused, then reconnect",
134
135
  ID_TAKEN: "it may already be recorded — check `pantheon history` before sending it again",
package/dist/protocol.js CHANGED
@@ -264,7 +264,7 @@ export const DeleteSpace = z.object({
264
264
  });
265
265
  export const WORKER_REASONS = ["no_agent", "kiro_only", "not_signed_in", "unsandboxed_off", "no_agent_choice",
266
266
  "busy_turn", "recently_active", "no_signal", "capped", "outage", "awaiting_wake_approval", "busy_elsewhere", "unknown", "sandbox_unavailable",
267
- "pinned_kiro", "pinned_unsandboxed"];
267
+ "pinned_kiro", "pinned_unsandboxed", "cannot_start"];
268
268
  const WORK_ID = /^(cont:)?[a-z]{1,3}_[A-Za-z0-9_-]{4,64}$/;
269
269
  export const WorkerState = z.object({
270
270
  t: z.literal("worker_state"),
@@ -10,14 +10,14 @@ import { writeWhole } from "./pins.js";
10
10
  import { signedOutRefusal } from "./signed-out.js";
11
11
  import { refusedWords } from "./run-failure.js";
12
12
  export { READINESS_ALERT_FILE };
13
- export const PERSON_CODES = new Set(["not_signed_in", "no_agent", "sandbox_unavailable"]);
13
+ export const PERSON_CODES = new Set(["not_signed_in", "no_agent", "sandbox_unavailable", "cannot_start"]);
14
14
  export const FRESH_MS = 30 * 60_000;
15
15
  export const CONFIRM_MS = 50_000;
16
16
  export const PENDING_MAX_MS = 15 * 60_000;
17
17
  const REFRESH_MS = 5 * 60_000;
18
18
  const DAY_MS = 24 * 3_600_000;
19
19
  export const PROBLEM_LEAD = "Unattended work can't run";
20
- const CODES = new Set(["no_agent", "kiro_only", "not_signed_in", "unsandboxed_off", "no_agent_choice", "sandbox_unavailable"]);
20
+ const CODES = new Set(["no_agent", "kiro_only", "not_signed_in", "unsandboxed_off", "no_agent_choice", "sandbox_unavailable", "cannot_start"]);
21
21
  const AGENT_IDS = new Set(AGENTS.map((a) => a.id));
22
22
  const keyOf = (t) => `${t.code ?? ""}|${t.agent ?? ""}`;
23
23
  const seenKey = (s) => (s.ok ? "ok" : keyOf(s));
@@ -62,6 +62,8 @@ export function problemLine(code, agent, os = platform()) {
62
62
  return `${notInstalled(agent)} — pantheon doctor shows how to install it`;
63
63
  if (code === "sandbox_unavailable")
64
64
  return `${label(agent ?? "claude-code")}'s sandbox can't start — pantheon doctor shows the fix`;
65
+ if (code === "cannot_start")
66
+ return `${label(agent)} can't start on this computer — pantheon doctor shows why and the fix`;
65
67
  return null;
66
68
  }
67
69
  const forHowLong = (ms) => {
@@ -102,6 +104,15 @@ export function composeReadinessAlert(code, agent, o = {}) {
102
104
  ...button({ label: "Show me how", kind: "how", ...(agent ? { agent } : {}), dir: o.signInDir ?? homedir(), lines: [], why: head }),
103
105
  };
104
106
  }
107
+ if (code === "cannot_start") {
108
+ const head = "Your agent can't start";
109
+ return {
110
+ ...base,
111
+ heading: head,
112
+ body: fit(`${label(agent)} can't start on this computer, so teammates' requests wait. ${os === "win32" ? "Run pantheon doctor: it says why, and the one fix." : "Click Show me how for why, and the one fix."}`, BUDGET.body),
113
+ ...button({ label: "Show me how", kind: "how", ...(agent ? { agent } : {}), dir: o.signInDir ?? homedir(), lines: [], why: `${label(agent)} can't start on this computer` }),
114
+ };
115
+ }
105
116
  const missing = /^install them:/.test(o.fix ?? "");
106
117
  return {
107
118
  ...base,
@@ -456,6 +467,10 @@ const refused = (agent, home) => {
456
467
  return null;
457
468
  }
458
469
  };
470
+ export function agentCannotStart(home, now = Date.now()) {
471
+ const first = stuckReading(home, now);
472
+ return first?.code === "cannot_start" && first.agent ? first.agent : null;
473
+ }
459
474
  function stuckReading(home, now) {
460
475
  let text = null;
461
476
  try {