@join-pantheon/cli 0.37.1 → 0.37.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/accounts.js CHANGED
@@ -516,6 +516,10 @@ export class Accounts {
516
516
  return null;
517
517
  return { label: r.label ?? "a device", ip: r.ip ?? "", created_at: r.created_at, email: r.email };
518
518
  }
519
+ linkGone(token) {
520
+ const r = this.db.prepare("SELECT voided, expires_at FROM link_confirms WHERE token_hash = ?").get(sha(token));
521
+ return r && r.voided && now() <= r.expires_at ? "closed" : "gone";
522
+ }
519
523
  confirmLink(token, typed, ip) {
520
524
  const r = this.db.prepare("SELECT * FROM link_confirms WHERE token_hash = ?").get(sha(token));
521
525
  if (!r || r.voided || now() > r.expires_at || !this.linkStillLive(r))
package/dist/cli.js CHANGED
@@ -48,7 +48,7 @@ import { agentProblem, PROBLEM_LEAD } from "./readiness-alert.js";
48
48
  import { stripControls } from "./notice.js";
49
49
  import { awaitingDecision, pickupEstimate } from "./pickup.js";
50
50
  import { loadPolicy, requestReadinessRecheck, unsandboxedAllowed, savePolicy, MODE_LABELS, AUTOPILOT_PLAN_NOTE, effectiveMode, parseMode, describeMode } from "./worker-policy.js";
51
- import { alreadyMemberLine, askedLine, configureLines, fetchSeats, inUseLine, offerSeats, seatsForTeam, seatsToMove, startGate, RECOVER_WAITING_EXIT } from "./recover-offer.js";
51
+ import { alreadyMemberLine, askedLine, configureLines, fetchSeats, inUseLine, offerSeats, recoverCommand, seatsForTeam, seatsToMove, startGate, RECOVER_WAITING_EXIT } from "./recover-offer.js";
52
52
  import { hyphenateSpaces, shellArg, teamNameProblem } from "./team-name.js";
53
53
  import { folderRefusalHere, isTemporaryRefusal, projectFolderAnswer } from "./folder-guard.js";
54
54
  import { borrowedHome, installService, serviceInstalled, serviceLogFile, serviceState, servicesUnavailable, uninstallService } from "./service.js";
@@ -2036,6 +2036,20 @@ let workerHeldOnce = null;
2036
2036
  function workerHeld() {
2037
2037
  return (workerHeldOnce ??= workerHeldNow());
2038
2038
  }
2039
+ let alertsHeldOnce = null;
2040
+ function alertsHeld() {
2041
+ return (alertsHeldOnce ??= (async () => {
2042
+ try {
2043
+ if (servicesUnavailable(process.platform) || borrowedHome())
2044
+ return null;
2045
+ const { workerRunning } = await import("./finish-line.js");
2046
+ return await workerRunning({ installed: () => serviceInstalled("notifier"), running: () => serviceState("notifier").running });
2047
+ }
2048
+ catch {
2049
+ return null;
2050
+ }
2051
+ })());
2052
+ }
2039
2053
  async function workerHeldNow() {
2040
2054
  try {
2041
2055
  if (servicesUnavailable(process.platform))
@@ -2153,7 +2167,11 @@ async function finishLine(tools, o) {
2153
2167
  }
2154
2168
  const workerWanted = wakeOn && !argv.includes("--no-worker");
2155
2169
  const workerRowFailed = tools.some((t) => t.tool === "worker" && /^(failed|could not)/i.test(t.status));
2156
- return [...(o.extra ?? []), ...finishItems({ tools, readiness: ready, team: cfg?.space ?? "<team>", workerWanted, served, windows, pending, worker: workerWanted && (served ?? 0) > 0 && !workerRowFailed ? await workerHeld() : null })];
2170
+ const alertsOn = tools.some((t) => t.tool === "notifications" && /^on\b/i.test(t.status));
2171
+ return [...(o.extra ?? []), ...finishItems({ tools, readiness: ready, team: cfg?.space ?? "<team>", workerWanted, served, windows, pending,
2172
+ worker: workerWanted && (served ?? 0) > 0 && !workerRowFailed ? await workerHeld() : null,
2173
+ alerts: alertsOn ? await alertsHeld() : null,
2174
+ agentShell: !process.stdin.isTTY })];
2157
2175
  };
2158
2176
  let items = await gather();
2159
2177
  if (guideAsks(o.preset)) {
@@ -2344,6 +2362,10 @@ ${B("control")}
2344
2362
  pantheon hook install your agent keeps working when a peer is waiting on it
2345
2363
  (auto-detects claude / codex / cursor / copilot / kiro on this machine)
2346
2364
  pantheon spend woken runs on this machine, and what pantheon cannot see
2365
+ pantheon runs the copies of your repos the worker made for teammates' requests: which request each was
2366
+ for, who asked, and whether it holds anything unsaved
2367
+ (runs clean [<branch>] removes the ones that hold nothing unsaved · --pushed also deletes
2368
+ this computer's copy of branches that are pushed but not merged)
2347
2369
  pantheon leave remove what pantheon put on this machine
2348
2370
  pantheon uninstall remove Pantheon itself: its services, hooks, its own Node, the pantheon command, the PATH
2349
2371
  lines and what it keeps in ~/.pantheon — but not your identity, so installing again puts
@@ -2445,6 +2467,7 @@ const COMMAND_FLAGS = {
2445
2467
  history: "--goal <id> --from <member> --last <n> --since <seq> --short --presence --json",
2446
2468
  usage: "--space <team> --days <n> --json",
2447
2469
  network: "--proxy <url> [--no-proxy <hosts>] | --direct | --clear",
2470
+ runs: "[clean [<branch>]] --pushed (clean: also this computer's copy of branches that are pushed but not merged) --project <dir>",
2448
2471
  leave: "[<team> | <team id>] --yes --if-gone (only if the relay still says the team is deleted, or that you were removed) --keep-identity --stop-relay --project <dir>",
2449
2472
  uninstall: "--yes --forget-identity --stop-relay --project <dir>",
2450
2473
  stop: "[relay|worker|notifier|menubar|all] --port <n>",
@@ -2701,6 +2724,12 @@ async function main() {
2701
2724
  console.error("");
2702
2725
  for (const l of gate.lines)
2703
2726
  console.error(gate.code === 1 ? `\x1b[33m ${l}\x1b[0m` : ` ${l}`);
2727
+ const left = seatsToMove(seats).filter((x) => !res?.moved.includes(x.space) && !res?.asked.includes(x.space));
2728
+ if (JSON_OUT && gate.code === 1 && !named && left.length) {
2729
+ sayJson({ status: "needs_person", code: 1, reason: "pick_team", needs: "team", message: gate.lines.join(" "),
2730
+ teams: left.map((x) => ({ team: x.space, founder: x.founder, next: recoverCommand(x.space) })),
2731
+ new_team: "pantheon start --space <the name they give> --new-team" });
2732
+ }
2704
2733
  process.exit(gate.code);
2705
2734
  }
2706
2735
  if (!named && !argv.includes("--new-team") && argv.includes("--yes") && seatsToMove(seats).some((x) => !res?.moved.includes(x.space) && !res?.asked.includes(x.space))) {
@@ -4576,14 +4605,18 @@ async function main() {
4576
4605
  {
4577
4606
  const { removePantheonWorktrees, removeHomeLeftovers } = await import("./machine.js");
4578
4607
  const repos = [project, ...Object.values(all?.bindings ?? {}).map((b) => b.path).filter((p) => !!p)];
4579
- const trees = removePantheonWorktrees(repos, [...(homeRefusal ? [] : [join(CONFIG_DIR, "worktrees")]), ...repos.map((r) => join(r, ".pantheon", "worktrees"))]);
4608
+ const trees = removePantheonWorktrees(repos, [...(homeRefusal ? [] : [join(CONFIG_DIR, "worktrees")]), ...repos.map((r) => join(r, ".pantheon", "worktrees"))], CONFIG_DIR, undefined, undefined, !homeRefusal);
4580
4609
  removed.push(...trees.removed);
4581
4610
  left.push(...trees.left);
4582
4611
  if (!homeRefusal) {
4583
- try {
4584
- rmSync(join(CONFIG_DIR, "worktrees"), { recursive: true, force: true });
4612
+ if (!trees.kept) {
4613
+ try {
4614
+ rmSync(join(CONFIG_DIR, "worktrees"), { recursive: true, force: true });
4615
+ }
4616
+ catch { }
4585
4617
  }
4586
- catch { }
4618
+ else
4619
+ spare.push(join(CONFIG_DIR, "worktrees"));
4587
4620
  const rest = removeHomeLeftovers(CONFIG_DIR, keepIdentity, { uninstalling, refusal: null });
4588
4621
  removed.push(...rest.removed);
4589
4622
  left.push(...rest.left);
@@ -4648,6 +4681,53 @@ async function main() {
4648
4681
  console.log(l);
4649
4682
  return;
4650
4683
  }
4684
+ case "runs": {
4685
+ const { listRuns, runLines, cleanRuns } = await import("./runs.js");
4686
+ const { sameProcess, recordedRunAlive, RUN_RECORD } = await import("./worker.js");
4687
+ const all = loadAll();
4688
+ const project = resolve(flag("project", "."));
4689
+ const repos = [...new Set([project, ...Object.values(all?.bindings ?? {}).map((b) => b.path).filter((p) => !!p)].map((p) => resolve(p)))];
4690
+ const roots = [join(CONFIG_DIR, "worktrees"), ...repos.map((r) => join(r, ".pantheon", "worktrees"))];
4691
+ const runInFlight = (() => { try {
4692
+ const r = JSON.parse(readFileSync(join(CONFIG_DIR, RUN_RECORD), "utf8"));
4693
+ return typeof r.pid === "number" && Number.isInteger(r.pid) && r.pid > 1 && recordedRunAlive(r.pid);
4694
+ }
4695
+ catch {
4696
+ return false;
4697
+ } })();
4698
+ const alive = (pid, id) => sameProcess(pid, id);
4699
+ const trees = listRuns(repos, roots, CONFIG_DIR);
4700
+ const sub = argv[1];
4701
+ if (sub === "clean") {
4702
+ const which = argv.slice(2).find((a) => !a.startsWith("--"));
4703
+ const pick = which ? trees.filter((t) => t.branch === which || (!!t.worktree && (resolve(t.worktree) === resolve(which) || basename(t.worktree) === which))) : trees;
4704
+ if (which && !pick.length)
4705
+ die(`No background checkout or branch is called ${which} here. See them all: pantheon runs`);
4706
+ if (!pick.length) {
4707
+ console.log("Nothing to clean: the worker has no checkouts or branches on this computer.");
4708
+ break;
4709
+ }
4710
+ const r = cleanRuns(pick, { home: CONFIG_DIR, alive, runInFlight, dropPushed: argv.includes("--pushed") });
4711
+ for (const x of r.removed)
4712
+ console.log(` ✓ ${x.line}`);
4713
+ for (const x of r.kept)
4714
+ console.log(` · ${x.line}`);
4715
+ if (r.kept.length)
4716
+ console.log(D(`\n Kept ones hold something that would be lost. Look in the folder, commit or remove what is there, then run this again.`));
4717
+ break;
4718
+ }
4719
+ if (sub && sub !== "list")
4720
+ die("Usage: pantheon runs [clean [<branch>] [--pushed]]");
4721
+ if (!trees.length) {
4722
+ console.log("The worker has no checkouts or branches on this computer.");
4723
+ break;
4724
+ }
4725
+ console.log(B(`The worker's checkouts and branches (${trees.length}):\n`));
4726
+ for (const l of runLines(trees, { alive, runInFlight }))
4727
+ console.log(` ${l}`);
4728
+ console.log(D(`\n pantheon runs clean removes the ones that hold nothing unsaved; your own checkout and branches are never touched.`));
4729
+ break;
4730
+ }
4651
4731
  case "panic": {
4652
4732
  console.error(`${B("PANIC — locking down this machine")}\n`);
4653
4733
  logChanges([{ at: Date.now(), setting: "worker", from: "running", to: "stopped, wake grants revoked (pantheon panic)", asked_by: askedByLabel(whoIsAsking()), outcome: "stopped" }]);
package/dist/client.js CHANGED
@@ -2,7 +2,7 @@ import WebSocket from "ws";
2
2
  import { clearRemoval, recordGone, recordRemoval, restateDeletedWhen, removalFor, removalHoldMs, removalRefusal, REMOVED_CHECK_MS, REMOVED_FIRST_MS, REMOVED_MAX_MS } from "./removed.js";
3
3
  import { adoptSpaceId, loadAll, rememberTeamRepos, updateMembershipToken } from "./config.js";
4
4
  import { honourClearedAuthority } from "./profile.js";
5
- import { inflightKey, loadContinued, markContinued, releasedKey, storedKey, unmarkContinued } from "./continued.js";
5
+ import { inflightKey, liveReadKey, loadContinued, markContinued, markContinuedAll, releasedKey, storedKey, unmarkContinued } from "./continued.js";
6
6
  import { isAnsweredId, markAnswered, nonceOf, unmarkAnswered } from "./nonces.js";
7
7
  import { signedRead } from "./reads.js";
8
8
  import { repoName } from "./repo-route.js";
@@ -1233,6 +1233,16 @@ export class PantheonClient {
1233
1233
  catch { }
1234
1234
  }
1235
1235
  relayNow() { return Date.now() + this.relaySkewMs; }
1236
+ markShown(acts) {
1237
+ const now = Math.round(this.relayNow());
1238
+ if (!this.session)
1239
+ return;
1240
+ const ids = acts.filter((a) => a.from !== this.cfg.member && (a.act === "ANSWER" || a.act === "DELIVERED") && now - a.ts <= 24 * 3_600_000).map((a) => `${a.id} ${now} ${this.session}`);
1241
+ try {
1242
+ markContinuedAll(liveReadKey(this.pinTeam), ids);
1243
+ }
1244
+ catch { }
1245
+ }
1236
1246
  relaySkewMs = 0;
1237
1247
  learnRelayNow(now) {
1238
1248
  if (typeof now === "number" && Number.isFinite(now) && now > 0)
package/dist/continued.js CHANGED
@@ -35,6 +35,40 @@ export function continuationDone(id, home) {
35
35
  return all.includes(id) && !all.includes(`held-cont:${id}`);
36
36
  }
37
37
  export const inflightKey = (team) => `${team} inflight`;
38
+ export const liveReadKey = (team) => `${team} live-read`;
39
+ export function liveReadAt(teams, id, home) {
40
+ const out = [];
41
+ for (const t of teams) {
42
+ for (const x of loadContinued(liveReadKey(t), home)) {
43
+ const m = /^(\S+) (\d+) (\S+)$/.exec(x);
44
+ if (m && m[1] === id)
45
+ out.push({ at: Number(m[2]), session: m[3] });
46
+ }
47
+ }
48
+ return out;
49
+ }
50
+ export function markContinuedAll(space, ids, home) {
51
+ if (!ids.length)
52
+ return;
53
+ try {
54
+ const p = continuedPath(home);
55
+ const write = () => {
56
+ const all = readAll(home);
57
+ const list = (all[space] ?? []).filter((x) => !ids.includes(x));
58
+ list.push(...ids);
59
+ all[space] = capped(list);
60
+ mkdirSync(dirname(p), { recursive: true });
61
+ writeWhole(p, JSON.stringify(all));
62
+ };
63
+ try {
64
+ withFileLock(p, write);
65
+ }
66
+ catch {
67
+ write();
68
+ }
69
+ }
70
+ catch { }
71
+ }
38
72
  export const releasedKey = (team) => `${team} released`;
39
73
  export const SEND_LIFETIME_MS = 2 * 60_000;
40
74
  export function ownReleases(before, now, snapAt = Date.now()) {
package/dist/doctor.js CHANGED
@@ -632,6 +632,10 @@ export async function doctor(projectDir) {
632
632
  }
633
633
  catch (e) {
634
634
  const msg = e.message;
635
+ if (sandboxOffline()) {
636
+ add("warn", "relay", "not checked: this shell is Codex's sandbox, which has no network, so nothing here says whether this computer reaches the relay", "coding agent: run pantheon doctor again with network access, asking your person to approve it", "not checked (an offline sandbox)");
637
+ return out;
638
+ }
635
639
  const c = await certRow(false);
636
640
  const nx = c?.publicCa === false && worthCertificateCheck(e) ? interceptionExplanation(c) : explainNetError(e, health);
637
641
  if (nx) {
@@ -950,4 +954,7 @@ export function shareBlock(checks, now = new Date()) {
950
954
  `send it to ${FEEDBACK_ADDRESS} with one line on what you expected to happen`,
951
955
  ].join("\n");
952
956
  }
957
+ export function sandboxOffline(env = process.env) {
958
+ return env.CODEX_SANDBOX_NETWORK_DISABLED === "1";
959
+ }
953
960
  //# sourceMappingURL=doctor.js.map
@@ -36,11 +36,11 @@ export function codeEmailHtml(code, purpose, link) {
36
36
  <span style="font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:38px;line-height:1.1;letter-spacing:.26em;font-weight:700;color:#f1e7d3">${code}</span>
37
37
  </td>
38
38
  </tr></table>
39
- <p style="margin:22px 0 0;font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:15px;line-height:1.65;color:#26221f">Enter it where the terminal is waiting, to ${action}. Or run:</p>
39
+ <p style="margin:22px 0 0;font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:15px;line-height:1.65;color:#26221f">Give it to your coding agent, or enter it where the terminal is waiting, to ${action}. Or run:</p>
40
40
  </td></tr>
41
41
  <tr><td class="px" style="padding:12px 40px 6px"><table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td style="background:#1b1917;border-radius:8px;padding:13px 16px;font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:14px;line-height:1.75;color:#f1e7d3;word-break:break-all"><span style="color:#e36f55">$</span> pantheon verify ${code}</td></tr></table></td></tr>
42
42
  ${link ? ` <tr><td class="px" style="padding:18px 40px 6px">
43
- <p style="margin:0 0 12px;font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:15px;line-height:1.65;color:#26221f">Or confirm in your browser. You will type the two words your screen shows.</p>
43
+ <p style="margin:0 0 12px;font-family:'Space Mono',Menlo,Consolas,'Liberation Mono',monospace;font-size:15px;line-height:1.65;color:#26221f">Or confirm in your browser. You will type the two words in capitals that your coding agent (or terminal) showed you when it sent this email.</p>
44
44
  <a href="${esc(link)}" style="display:inline-block;background:#e36f55;color:#1b1917;border-radius:8px;padding:12px 20px;font-family:'Space Mono',Menlo,Consolas,monospace;font-size:15px;font-weight:700;text-decoration:none">Confirm it's you</a>
45
45
  </td></tr>` : ""}
46
46
  <tr><td class="px" style="padding:22px 40px 32px">
package/dist/email.js CHANGED
@@ -8,10 +8,10 @@ function subjectAndBody(code, purpose, link) {
8
8
  ``,
9
9
  `Your verification code is ${code}.`,
10
10
  ``,
11
- `Enter it where the terminal is waiting, to ${action}. Or run:`,
11
+ `Give it to your coding agent, or enter it where the terminal is waiting, to ${action}. Or run:`,
12
12
  ` pantheon verify ${code}`,
13
13
  ``,
14
- ...(link ? [`Or confirm in your browser — you will type the two words your screen shows:`, ` ${link}`, ``] : []),
14
+ ...(link ? [`Or confirm in your browser. You will type the two words in capitals that your coding agent (or terminal) showed you when it sent this email:`, ` ${link}`, ``] : []),
15
15
  `The code expires in 10 minutes and works once. If you did not ask for it,`,
16
16
  `ignore this email: nothing happens without the code.`,
17
17
  ``,
@@ -40,6 +40,12 @@ export function finishItems(f) {
40
40
  ? { says: "Your worker is installed but not running, so teammates' requests wait for you while you're away.", fix: "pantheon service restart worker" }
41
41
  : { says: "Your worker isn't installed, so teammates' requests wait for you while you're away.", fix: "pantheon service install worker" });
42
42
  }
43
+ const alertsSaid = out.some((i) => /^The desktop alerts are installed but not running|^notifications was not set up/.test(i.says));
44
+ if (f.alerts && !(f.alerts.installed && f.alerts.loaded) && !alertsSaid) {
45
+ out.push(f.alerts.installed
46
+ ? { says: "Desktop alerts are installed but not running, so you won't hear when a teammate needs you.", fix: "pantheon service restart notifier" }
47
+ : { says: "Desktop alerts aren't installed, so you won't hear when a teammate needs you.", fix: "pantheon service install notifier" });
48
+ }
43
49
  if (f.workerWanted && f.served === 0) {
44
50
  out.push({ says: `Nothing on this machine is bound to "${f.team}", so your worker has nothing to work in while you're away.`, fix: `from the folder you work in (a repo, or a folder of docs): pantheon use ${f.team} --here` });
45
51
  }
@@ -55,6 +61,11 @@ export function finishItems(f) {
55
61
  if (hook && /codex: run \/hooks/i.test(hook.status) && !rowFailed(hook.status) && !/^skipped/i.test(hook.status)) {
56
62
  out.push({ says: "Codex skips Pantheon's wake-up hook until you approve it.", fix: "in Codex, run /hooks once and approve it" });
57
63
  }
64
+ if (f.agentShell) {
65
+ for (const i of out)
66
+ if (/^pantheon service (restart|install) /.test(i.fix))
67
+ i.fix = `${i.fix} (coding agent: ask your person to approve running this outside your sandbox — a sandbox can't start background services)`;
68
+ }
58
69
  if (f.pending > 0) {
59
70
  out.push({ says: `${f.pending === 1 ? "A change" : `${f.pending} changes`} to your setup ${f.pending === 1 ? "waits" : "wait"} for you to confirm.`, fix: "pantheon changes" });
60
71
  }
@@ -194,15 +194,19 @@ function codeSent(cmd, deps, s) {
194
194
  ? `A code was sent to ${s.email} ${s.reused} min ago — use that one. ${SPAM}`
195
195
  : `Sent a 6-digit code to ${s.email}. ${SPAM}${s.dev ? " (A dev relay: the code is in its log.)" : ""}`;
196
196
  const who = s.account === "new" ? `This makes a new account, ${s.username}.` : `This signs this computer in to your account.`;
197
+ const tell = s.words
198
+ ? `Check your email (and spam) for a message from Pantheon. Either tell me the 6-digit code in it, or open its link and type these two words there: ${s.words.toUpperCase()}`
199
+ : `Check your email (and spam) for a message from Pantheon, and tell me the 6-digit code in it.`;
197
200
  return {
198
201
  kind: "needs_person", needs: "code",
199
- lines: [head, who, `When the person has the code, run: ${nxt}`,
200
- ...(s.words ? [`Or they open the link in that email and type these two words there: ${s.words.toUpperCase()} — then run: ${cont}`] : []),
202
+ lines: [head, who, `Say this to the person, word for word: "${tell}"`, `When the person has the code, run: ${nxt}`,
203
+ ...(s.words ? [`If they typed the words in the link instead, run: ${cont}`] : []),
201
204
  `Wrong address? Run the first command again with the right --email.`],
202
205
  json: {
203
206
  needs: "code", sent_to: s.email, account: s.account,
204
207
  ...(s.username ? { username: s.username } : {}),
205
208
  ...(s.reused ? { reused: true } : {}),
209
+ tell_person: tell,
206
210
  next: nxt,
207
211
  ...(s.words ? { link: true, words: s.words, next_link: cont } : {}),
208
212
  },
@@ -222,7 +226,7 @@ function needsUsername(cmd, deps, email, suggested, why) {
222
226
  export function unreachableWhy(why, env) {
223
227
  if (env.CODEX_SANDBOX_NETWORK_DISABLED !== "1")
224
228
  return why;
225
- return `${why || "no network"}. This shell has no network (Codex's sandbox): run the same command in a terminal of your own, or allow Codex network access`;
229
+ return `${why || "no network"}. This shell has no network (Codex's sandbox): ask the person to approve network access for this command — or, if Codex turned it down without asking them, to choose "Ask for approval" in Codex's permissions menu — then run the same command again; the code still works`;
226
230
  }
227
231
  export async function enterCode(o) {
228
232
  const { deps, cmd } = o;
@@ -91,10 +91,14 @@ export function forgetTeamTraces(f, m, home = CONFIG_DIR) {
91
91
  else {
92
92
  const repos = Object.values(f.bindings ?? {}).filter((b) => b.space === m.id && b.path).map((b) => b.path);
93
93
  try {
94
- const trees = removePantheonWorktrees(repos, [dir]);
94
+ const trees = removePantheonWorktrees(repos, [dir], home);
95
95
  left.push(...trees.left);
96
- rmSync(dir, { recursive: true, force: true });
97
- removed.push("its worker's scratch worktrees");
96
+ if (!trees.kept) {
97
+ rmSync(dir, { recursive: true, force: true });
98
+ removed.push("its worker's scratch worktrees");
99
+ }
100
+ else if (trees.removed.length)
101
+ removed.push("its worker's scratch worktrees that held nothing unsaved");
98
102
  }
99
103
  catch (e) {
100
104
  left.push(`${dir} (${e.message})`);
package/dist/git-safe.js CHANGED
@@ -221,7 +221,7 @@ function inspect(worktree, a, snapshot = false) {
221
221
  }
222
222
  function commonOf(project) {
223
223
  try {
224
- const out = execFileSync("git", [...gitHarden(), "rev-parse", "--git-common-dir"], { cwd: project, encoding: "utf8", windowsHide: true, stdio: ["ignore", "pipe", "ignore"], env: { ...process.env, GIT_CONFIG_NOSYSTEM: "1" }, timeout: 10_000 }).trim();
224
+ const out = execFileSync("git", ["-c", "core.fsmonitor=false", "-c", "protocol.file.allow=user", "rev-parse", "--git-common-dir"], { cwd: project, encoding: "utf8", windowsHide: true, stdio: ["ignore", "pipe", "ignore"], env: { ...process.env, GIT_CONFIG_NOSYSTEM: "1" }, timeout: 10_000 }).trim();
225
225
  return real(resolve(project, out));
226
226
  }
227
227
  catch {
package/dist/machine.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { execFileSync } from "node:child_process";
2
- import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
2
+ import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, rmSync, rmdirSync, statSync, writeFileSync } from "node:fs";
3
3
  import { homedir, hostname, networkInterfaces, platform } from "node:os";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { CONFIG_DIR } from "./config.js";
6
+ import { cleanRuns, listRuns, realGit, runRecordAlive } from "./runs.js";
6
7
  import { borrowedHome, disableService, existingUnitPath, plistPath, serviceInstalled, serviceLogFile, stopWindowsHost, unitPath, unitPaths, uninstallService } from "./service.js";
7
8
  import { LEGACY_TASK_NAME, hostAlive, hostChildRunning, hostFiles, isHostKind, readHostState, recordedTaskName } from "./win-host.js";
8
9
  import { copilotMcpConfigFile, vsCodeUserDir, kiroMcpConfigFile, kiroDir, claudeUserEntryState, userEntry } from "./install.js";
@@ -818,43 +819,32 @@ export function ownWorkerPid(io = realProcScanIo()) {
818
819
  const w = pidFileWorker(io);
819
820
  return w?.confirmed ? w.pid : null;
820
821
  }
821
- export function removePantheonWorktrees(repos, roots, git = (repo, args) => execFileSync("git", ["-C", repo, ...args], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 30_000 })) {
822
+ export function removePantheonWorktrees(repos, roots, home = CONFIG_DIR, git, alive = (pid) => { try {
823
+ process.kill(pid, 0);
824
+ return true;
825
+ }
826
+ catch {
827
+ return false;
828
+ } }, record = true) {
822
829
  const removed = [], left = [];
823
- const real = (p) => { try {
824
- return realpathSync(p);
825
- }
826
- catch {
827
- return resolve(p);
828
- } };
829
- const rootsReal = roots.map(real);
830
- const under = (p) => { const pp = real(p); return rootsReal.some((rr) => pp === rr || pp.startsWith(rr + "/") || pp.startsWith(rr + "\\")); };
831
- for (const repo of [...new Set(repos.map((r) => resolve(r)))]) {
832
- let list;
830
+ const trees = listRuns(repos, roots, home, git).filter((t) => t.worktree);
831
+ const r = cleanRuns(trees, { home, ...(git ? { git } : {}), alive, dropPushed: true, record, runInFlight: runRecordAlive(home) });
832
+ const byRepo = new Map();
833
+ for (const x of r.removed)
834
+ if (x.tree.worktree)
835
+ byRepo.set(x.tree.repo, (byRepo.get(x.tree.repo) ?? 0) + 1);
836
+ for (const [repo, n] of byRepo)
837
+ removed.push(`${n} worktree${n === 1 ? "" : "s"} the worker made in ${repo}`);
838
+ for (const x of r.kept)
839
+ left.push(`${x.line} — it is at ${x.tree.worktree}; look, then remove it yourself: git -C ${x.tree.repo} worktree remove ${x.tree.worktree}`);
840
+ for (const repo of new Set(trees.map((t) => t.repo))) {
833
841
  try {
834
- list = git(repo, ["worktree", "list", "--porcelain"]);
835
- }
836
- catch {
837
- continue;
838
- }
839
- const trees = [...list.matchAll(/^worktree (.+)$/gm)].map((m) => m[1].trim()).filter(under);
840
- let n = 0;
841
- for (const t of trees) {
842
- try {
843
- git(repo, ["worktree", "remove", "--force", t]);
844
- n++;
845
- }
846
- catch (e) {
847
- left.push(`the worktree ${t} in ${repo} (${e.message.split("\n")[0]}) — git -C ${repo} worktree remove --force ${t}`);
848
- }
849
- }
850
- try {
851
- git(repo, ["worktree", "prune"]);
842
+ (git ?? realGit)(repo, ["worktree", "prune"]);
852
843
  }
853
844
  catch { }
854
- if (n)
855
- removed.push(`${n} worktree${n === 1 ? "" : "s"} the worker made in ${repo}`);
856
845
  }
857
- return { removed, left };
846
+ const kept = r.kept.length > 0;
847
+ return { removed, left, kept };
858
848
  }
859
849
  const MANAGED_LAUNCHERS = ["pantheon", "pantheon.cmd"];
860
850
  export function removeHomeLeftovers(home, keep, opts = {}) {
package/dist/mcp.js CHANGED
@@ -370,6 +370,8 @@ export async function runMcp() {
370
370
  : h.goal !== null && h.goal === o.goal && o.claimed_by?.session === client.session);
371
371
  const stillOwed = () => role !== "worker" ? client.myWork() : client.myWork().filter((o) => !o.owner.startsWith("human:") && !handed(o));
372
372
  const fmtAll = (acts) => {
373
+ if (role === "interactive")
374
+ client.markShown(acts);
373
375
  const flagged = acts.some((a) => assess(a.body).length > 0);
374
376
  const rubric = !rubricShown || flagged ? fenceRubric(acts.length) : fenceReminder(acts.length);
375
377
  rubricShown = true;
package/dist/notice.js CHANGED
@@ -228,4 +228,25 @@ export function composeJoined(names, team) {
228
228
  tag: `joined_${team.replace(/[^A-Za-z0-9_]/g, "_")}`.slice(0, 60),
229
229
  };
230
230
  }
231
+ function requestWords(line) {
232
+ return plain(line).replace(/^[a-z0-9._-]+\s+(?:proposed|objected|delivered)\s*:\s*/i, "").replace(/\s*—\s*ACCEPT or OBJECT$/, "").replace(/[.!?…:;,\s]+$/, "");
233
+ }
234
+ export function composeWaiting(items, team, ctx) {
235
+ const one = items.length === 1;
236
+ const who = [...new Set(items.map((i) => i.from))];
237
+ const prompt = "Teammates are waiting on me in Pantheon. Call pantheon_status, then handle what is waiting on me.";
238
+ return {
239
+ kind: "delivery",
240
+ who: team,
241
+ heading: fit(one ? `${items[0].from} is waiting on you` : `${items.length} requests are waiting on you`, BUDGET.heading),
242
+ context: "",
243
+ body: fit(one
244
+ ? `${requestWords(items[0].what) || "A request"}. Your agent hasn't picked it up: open it to answer.`
245
+ : `From ${who.length === 1 ? who[0] : `${who.slice(0, -1).join(", ")} and ${who[who.length - 1]}`}. Your agent hasn't picked them up: open it to answer.`, BUDGET.body),
246
+ ttl: 30,
247
+ sound: false,
248
+ primary: primaryFor(ctx.tools, ctx.preferred, prompt),
249
+ tag: `waiting_${team.replace(/[^A-Za-z0-9_]/g, "_")}`.slice(0, 60),
250
+ };
251
+ }
231
252
  //# sourceMappingURL=notice.js.map
package/dist/notifier.js CHANGED
@@ -9,8 +9,9 @@ import { dirname, join, resolve } from "node:path";
9
9
  import { fileURLToPath } from "node:url";
10
10
  import { PantheonClient } from "./client.js";
11
11
  import { CONFIG_DIR } from "./config.js";
12
+ import { awaitingDecision } from "./pickup.js";
12
13
  import { loadProfile } from "./profile.js";
13
- import { APP_TOOLS, CLAUDE_APP_CHOSEN, composeDecision, composeDelivery, composeJoined, composePassedOver, composeWakeAsk, neverAlerts, passedOverNotice, TOOL_LABELS } from "./notice.js";
14
+ import { APP_TOOLS, CLAUDE_APP_CHOSEN, composeDecision, composeDelivery, composeJoined, composePassedOver, composeWaiting, composeWakeAsk, neverAlerts, passedOverNotice, TOOL_LABELS } from "./notice.js";
14
15
  import { loadPolicy } from "./worker-policy.js";
15
16
  import { withoutAgentMarkers } from "./setup-changes.js";
16
17
  import { wakeAlerted } from "./continued.js";
@@ -32,6 +33,22 @@ export function reminderGap(n, reminderMs) {
32
33
  export function wakeAskWhat(body) {
33
34
  return /answer while you are away:\s*(.+)$/m.exec(body)?.[1]?.trim() ?? body.split("\n")[0] ?? "";
34
35
  }
36
+ export const WAITING_AFTER_MS = 5 * 60_000;
37
+ export const WAITING_EVERY_MS = 30 * 60_000;
38
+ export const WAITING_MAX_AGE_MS = 24 * 3_600_000;
39
+ export function requestFrom(body) {
40
+ return /^([a-z0-9._-]+)\s+(?:asked|proposed|objected|delivered|escalated)\s*:/i.exec(body)?.[1]
41
+ ?? /^(?:ASK|PROPOSE|DELIVERED|CONTRACT|COMMIT|OBJECT)\s+from\s+([a-z0-9._-]+)/i.exec(body)?.[1];
42
+ }
43
+ let machineWaitingAt = 0;
44
+ export function resetWaitingClock() { machineWaitingAt = 0; }
45
+ export function waitingRequests(obligations, member, state, now, fromOf) {
46
+ return obligations.filter((o) => o.owner === member && o.kind !== "HUMAN" && o.kind !== "CONTINUE" && !o.claimed_by
47
+ && now - o.created_at >= WAITING_AFTER_MS && now - o.created_at < WAITING_MAX_AGE_MS
48
+ && state.notified_at[`act:wait:${o.ref}`] === undefined
49
+ && !awaitingDecision(obligations, o)
50
+ && (() => { const f = fromOf(o); return !!f && f !== member; })());
51
+ }
35
52
  export function humanObligations(obligations, member) {
36
53
  return obligations.filter((o) => o.kind === "HUMAN" && o.owner === `human:${member}`);
37
54
  }
@@ -355,6 +372,26 @@ export class HumanNotifier {
355
372
  this.opts.log(`! could not show a desktop notification for ${obligation.id}`);
356
373
  }
357
374
  }
375
+ if (prefs.decisions) {
376
+ const fromOf = (o) => client.seenAct(o.ref)?.from ?? requestFrom(o.body);
377
+ const relayNow = now() + (client.relayNow() - Date.now());
378
+ const me = client.roster.find((m) => m.id === this.cfg.member);
379
+ const workerBusy = me?.worker?.state === "running" && me.sessions.some((x) => x.role === "worker");
380
+ const waiting = workerBusy ? [] : waitingRequests(client.obligations, this.cfg.member, state, relayNow, fromOf);
381
+ const last = Math.max(state.notified_at["act:wait:last"] ?? 0, machineWaitingAt);
382
+ if (waiting.length && (last === 0 || now() - last >= WAITING_EVERY_MS)) {
383
+ const items = waiting.map((o) => ({ from: fromOf(o), what: client.seenAct(o.ref)?.summary ?? o.body }));
384
+ const ok = await send(withLabel(composeWaiting(items, this.cfg.space, { tools, preferred: preferredTool(profile, tools), now: now() })));
385
+ if (ok) {
386
+ for (const o of waiting)
387
+ state.notified_at[`act:wait:${o.ref}`] = now();
388
+ state.notified_at["act:wait:last"] = now();
389
+ machineWaitingAt = now();
390
+ dirty = true;
391
+ this.opts.log(`> waiting alert: ${waiting.length} request${waiting.length === 1 ? "" : "s"} nothing here picked up`);
392
+ }
393
+ }
394
+ }
358
395
  if (dirty || !existsSync(stateFile))
359
396
  writeState(stateFile, state);
360
397
  const arrived = await client.next(pollMs);
@@ -61,8 +61,9 @@ export function agentRequest(invite, o) {
61
61
  `First ask me for my email and for the username my teammates will see (it can't be changed later).${invite ? " Don't open the invite link: it holds a one-time secret, and the installer takes it as it is." : ""}`,
62
62
  `On a Mac or Linux: download the installer and read it before running it — curl -fsSL ${base}/install.sh -o pantheon-install.sh — then run: sh pantheon-install.sh ${verb} ${flags}`,
63
63
  `On Windows: curl.exe -fsSL ${base}/install.ps1 -o pantheon-install.ps1, read it, then run: powershell -NoProfile -Command "Set-Item Env:PANTHEON_ARGS '${psVerb} ${flags}'; Get-Content -Raw pantheon-install.ps1 | iex"`,
64
- `It emails me a 6-digit code (it may land in spam). Ask me for it, then run the exact command it prints next (it names Pantheon by its full path, since this shell may not find \`pantheon\` yet), with the code in place of <the 6-digit code>.`,
65
- `If this shell can't go online (Codex keeps it offline unless I allow it, and may turn the request down by itself), don't retry or look for a way around it: give me the same commands to run in a terminal of my own, without the --email and --username part. There it asks me for my email, the code and my username itself. Then I quit and reopen you once.`,
64
+ `It emails me a 6-digit code and a link (it may land in spam), and prints two words in capitals. When you ask me for the code, show me those two words too: I can give you the code, or open the email's link and type the words there. Then, for the way I used, run the exact command it prints next (it names Pantheon by its full path, since this shell may not find \`pantheon\` yet), with the code in place of <the 6-digit code>.`,
65
+ ...(invite ? [] : [`If it says I'm already in some teams, show me their names and ask which this computer should join, then run the line it gives for each one I pick. Don't ask me to name a new team unless I say I want one.`]),
66
+ `The download, the sign-in and the setup need network access, and the setup starts Pantheon's background helpers, which a sandbox blocks. If your shell runs in a sandbox (Codex's does), ask me to approve running each of them outside it. In Codex, ask me to approve running them with network access. If the request is turned down without asking me, or this shell still can't go online, don't look for a way around it: tell me to choose "Ask for approval" in Codex's permissions menu (under the message box), then try again when I say so.`,
66
67
  "What it changes, to tell me before running it:",
67
68
  ...INSTALL_CHANGES.slice(0, 3).map((c) => `- ${c}`),
68
69
  ].join("\n");
@@ -63,12 +63,14 @@ export async function offerSeats(seats, deps) {
63
63
  deps.log(` ${strayLine(s)}`);
64
64
  if (!offered.length)
65
65
  return out;
66
- for (const s of offered)
67
- deps.log(` ${seatLine(s)}`);
68
66
  if (!deps.tty) {
69
- deps.log(` A coding agent setting Pantheon up here runs ${offered.length === 1 ? "that" : "those"} before \`pantheon start\`, never a new team in ${offered.length === 1 ? "its" : "their"} place.`);
67
+ deps.log(` ${teamsQuestion(offered)}`);
68
+ for (const s of offered)
69
+ deps.log(` ${seatLine(s)}`);
70
70
  return out;
71
71
  }
72
+ for (const s of offered)
73
+ deps.log(` ${seatLine(s)}`);
72
74
  for (const s of offered) {
73
75
  const a = ((await deps.ask(` Move your seat in ${s.space} to this machine now? [Y/n] `)) ?? "n").trim().toLowerCase();
74
76
  if (a === "" || a === "y" || a === "yes") {
@@ -87,6 +89,15 @@ export async function offerSeats(seats, deps) {
87
89
  }
88
90
  return out;
89
91
  }
92
+ export function listTeams(seats) {
93
+ const n = seats.map((s) => s.space);
94
+ return n.length <= 1 ? (n[0] ?? "") : `${n.slice(0, -1).join(", ")} and ${n[n.length - 1]}`;
95
+ }
96
+ export function teamsQuestion(seats) {
97
+ return seats.length === 1
98
+ ? `Ask the person: "You're already in ${seats[0].space}. Bring it to this computer?" (It moves from your other computer.) On a yes, run:`
99
+ : `Ask the person which of these teams this computer should join (each one moves from your other computer); it can be several. Then run the line for each:`;
100
+ }
90
101
  export async function startGate(o) {
91
102
  const asked = o.asked ?? [];
92
103
  const waiting = seatsToMove(o.seats).filter((s) => !o.moved.includes(s.space) && !asked.includes(s.space));
@@ -112,9 +123,9 @@ export async function startGate(o) {
112
123
  const how = waiting.map((s) => ` ${recoverCommand(s.space)}`);
113
124
  if (!o.tty) {
114
125
  return { go: false, code: 1, lines: [
115
- `not creating a new team: this account already has a seat in ${waiting.map((s) => s.space).join(", ")}. Bring it to this machine instead:`,
126
+ `not creating a new team: you're already in ${listTeams(waiting)}. ${teamsQuestion(waiting)}`,
116
127
  ...how,
117
- ` A new team as well, on purpose: pantheon start --space <its-real-name> --new-team (ask the person for the name — never make one up)`,
128
+ ` Only if the person says they want a separate, new team as well: pantheon start --space <the name they give> --new-team (never make a name up, and don't ask for one unless they want a new team)`,
118
129
  ] };
119
130
  }
120
131
  const a = ((await o.ask(` Create a new team anyway, instead of moving ${waiting.length === 1 ? "that seat" : "those seats"}? [y/N] `)) ?? "").trim().toLowerCase();