@join-pantheon/cli 0.35.0 → 0.35.1-rc.2

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.
Files changed (52) hide show
  1. package/dist/agent-outage.js +165 -35
  2. package/dist/agent-token.js +5 -3
  3. package/dist/agents.js +6 -4
  4. package/dist/approvals-list.js +87 -0
  5. package/dist/board.js +491 -88
  6. package/dist/brief.js +17 -0
  7. package/dist/cli.js +687 -95
  8. package/dist/client.js +159 -19
  9. package/dist/config.js +3 -2
  10. package/dist/continued.js +56 -1
  11. package/dist/decision-ui.js +5 -3
  12. package/dist/doctor.js +84 -16
  13. package/dist/file-lock.js +40 -5
  14. package/dist/flow-stats.js +18 -1
  15. package/dist/home-guard.js +336 -54
  16. package/dist/home-safety.js +2 -0
  17. package/dist/hud-queue.js +91 -0
  18. package/dist/install.js +15 -1
  19. package/dist/mcp-instructions.js +67 -28
  20. package/dist/mcp.js +129 -24
  21. package/dist/notice-linux.js +15 -4
  22. package/dist/notice-windows.js +2 -2
  23. package/dist/notifier.js +2 -1
  24. package/dist/notify.js +28 -9
  25. package/dist/open-in.js +4 -3
  26. package/dist/pickup.js +17 -0
  27. package/dist/plain.js +139 -3
  28. package/dist/profile.js +12 -8
  29. package/dist/protocol.js +1 -1
  30. package/dist/question-goal.js +74 -0
  31. package/dist/readiness-alert.js +24 -3
  32. package/dist/refusal.js +2 -2
  33. package/dist/relay.js +143 -28
  34. package/dist/removed.js +4 -4
  35. package/dist/run-control.js +4 -3
  36. package/dist/run-failure.js +67 -10
  37. package/dist/setup-changes.js +7 -6
  38. package/dist/signed-out.js +144 -21
  39. package/dist/spend.js +5 -4
  40. package/dist/tray.js +24 -6
  41. package/dist/update-check.js +2 -1
  42. package/dist/uri-handler.js +10 -2
  43. package/dist/which.js +2 -0
  44. package/dist/worker-policy.js +212 -10
  45. package/dist/worker.js +942 -133
  46. package/dist/worklist.js +31 -1
  47. package/helper/macos/main.swift +42 -3
  48. package/helper/macos/menubar.swift +482 -87
  49. package/helper/macos/prebuilt/manifest.json +5 -5
  50. package/helper/macos/prebuilt/pantheon-hud +0 -0
  51. package/helper/macos/prebuilt/pantheon-tray +0 -0
  52. package/package.json +1 -1
@@ -163,7 +163,7 @@ export class LinuxAlerts {
163
163
  run,
164
164
  cli,
165
165
  log: deps.log ?? ((l) => console.error(l)),
166
- openBoard: deps.openBoard ?? ((env, focus) => openBoardWith(cli, env, focus)),
166
+ openBoard: deps.openBoard ?? ((env, focus, team) => openBoardWith(cli, env, focus, team)),
167
167
  sessionEnv: deps.sessionEnv ?? realSessionEnv,
168
168
  };
169
169
  }
@@ -305,7 +305,7 @@ export class LinuxAlerts {
305
305
  else if (action === "board" || action === "default") {
306
306
  const display = this.d.env.DISPLAY || this.d.env.WAYLAND_DISPLAY ? {} : pickDisplay(this.d.sessionEnv());
307
307
  const env = { ...this.d.env, ...display, ...(token ? { XDG_ACTIVATION_TOKEN: token, DESKTOP_STARTUP_ID: token } : {}) };
308
- const opening = this.d.openBoard(env, s.notice.focus).catch(() => false).then(async (opened) => {
308
+ const opening = this.d.openBoard(env, s.notice.focus, s.notice.space).catch(() => false).then(async (opened) => {
309
309
  if (!opened)
310
310
  await this.note("Open the board in a terminal", "Run pantheon board (or pantheon brief) to see everything that needs you.");
311
311
  });
@@ -339,6 +339,16 @@ export class LinuxAlerts {
339
339
  this.forget(id);
340
340
  }
341
341
  else {
342
+ if (/^unconfirmed:/.test(said)) {
343
+ this.d.log(`alerts: Done not confirmed (${said})`);
344
+ await this.note("Not confirmed — check the thread", said.replace(/^unconfirmed:\s*/, ""));
345
+ return;
346
+ }
347
+ if (hud.action !== "run" && !/^not sent:/.test(said)) {
348
+ this.d.log(`alerts: Done not confirmed (${said || `exit ${r.code}`})`);
349
+ await this.note("Not confirmed — check the thread", said || "It may have been marked done — open the board to check it.");
350
+ return;
351
+ }
342
352
  this.d.log(`alerts: Done was not sent (${said || `exit ${r.code}`})`);
343
353
  await this.note(hud.action === "run" ? "Not sent" : "Not marked done", said.replace(/^not sent:\s*/, "") || "Open the board to answer it there.");
344
354
  }
@@ -445,7 +455,7 @@ export function writeHudAction(home, hud) {
445
455
  renameSync(tmp, f);
446
456
  return f;
447
457
  }
448
- function openBoardWith(cli, env, focus) {
458
+ function openBoardWith(cli, env, focus, team) {
449
459
  return new Promise((done) => {
450
460
  const [file, ...args] = cli;
451
461
  let settled = false;
@@ -454,7 +464,8 @@ function openBoardWith(cli, env, focus) {
454
464
  done(v);
455
465
  } };
456
466
  let child;
457
- const at = focus && /^[ao]_[A-Za-z0-9]{6,48}$/.test(focus) ? ["--focus", focus] : [];
467
+ const at = focus && /^[ao]_[A-Za-z0-9]{6,48}$/.test(focus)
468
+ ? ["--focus", focus, ...(team && /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(team) ? ["--space", team] : [])] : [];
458
469
  try {
459
470
  child = spawn(file, [...args, "board", "--open", ...at], { env, stdio: "ignore", detached: true });
460
471
  }
@@ -56,7 +56,7 @@ export function toastButtons(notice, key) {
56
56
  else if (d.act) {
57
57
  add("Show details", buildUri("details", { act: d.act, decision: d.decision, space }, key));
58
58
  }
59
- add(notice.focus ? "Approve or decline" : "Open board", buildUri("board", notice.focus ? { focus: notice.focus } : {}, key));
59
+ add(notice.focus ? "Approve or decline" : "Open board", buildUri("board", notice.focus ? { focus: notice.focus, space } : {}, key));
60
60
  return out;
61
61
  }
62
62
  export function toastTag(notice) {
@@ -74,7 +74,7 @@ export function toastFields(notice, key) {
74
74
  return {
75
75
  lines,
76
76
  who: toastText(notice.who, TOAST_CAPS.who),
77
- launch: (notice.focus && buildUri("board", { focus: notice.focus }, key)) || buildUri("board", {}, key),
77
+ launch: (notice.focus && buildUri("board", { focus: notice.focus, space: notice.space }, key)) || buildUri("board", {}, key),
78
78
  buttons: toastButtons(notice, key).map((b) => ({ content: toastText(b.content, TOAST_CAPS.button), uri: b.uri })),
79
79
  scenario: notice.ttl === 0 ? "reminder" : "",
80
80
  duration: notice.ttl !== 0 && notice.ttl > 7 ? "long" : "",
package/dist/notifier.js CHANGED
@@ -333,8 +333,9 @@ export class HumanNotifier {
333
333
  this.opts.log(`> ${obligation.id}: the worker alerted this one itself (may ${wake.member} start work here)`);
334
334
  continue;
335
335
  }
336
+ const wakeBody = wake ? (act?.body ?? (await client.storedAct(obligation.ref).catch(() => null))?.body ?? obligation.body) : "";
336
337
  const notice = wake
337
- ? withLabel(composeWakeAsk({ member: wake.member, what: wakeAskWhat(act?.body ?? obligation.body), space: this.opts.label ? "" : this.cfg.space, focus: obligation.ref, mac: platform() === "darwin" }))
338
+ ? withLabel(composeWakeAsk({ member: wake.member, what: wakeAskWhat(wakeBody), space: this.opts.label ? "" : this.cfg.space, focus: obligation.ref, mac: platform() === "darwin" }))
338
339
  : withLabel(composeDecision(obligation, act, obligation.goal ? client.goals.get(obligation.goal) : undefined, peerOf(act?.from), { tools, preferred: preferredTool(profile, tools), now: now(), member: this.cfg.member }));
339
340
  const ok = await send(notice);
340
341
  if (ok) {
package/dist/notify.js CHANGED
@@ -13,23 +13,34 @@ import { detectForHooks, agentById } from "./agents.js";
13
13
  import { codexHookState, cursorHookState, copilotHookState, kiroHookState, installCodexHooks, installCursorHooks, installCopilotHooks, installKiroHooks, removeCodexHooks, removeCursorHooks, removeCopilotHooks, removeKiroHooks, } from "./hooks-install.js";
14
14
  export const HOOK_MARKER = "pantheon hook";
15
15
  export const HOOK_RE = /(?:pantheon(?:\.cmd|\.exe|\.bat)?["']?\s+hook\s|cli\.js["']?\s+hook\s+(?:stop|prompt|end|codex-stop|copilot-stop|cursor-stop|kiro-stop|kiro-prompt)\b)/i;
16
- export const isOurHookCommand = (cmd) => !!cmd && (cmd.includes(HOOK_MARKER) || HOOK_RE.test(cmd));
17
- export const hookBin = (bin) => (/\s/.test(bin) ? `"${bin}"` : bin);
16
+ const LAUNCH_BIN = /^(?:"(?:[^"]*[\\/])?pantheon(?:\.cmd|\.exe|\.bat)?"|'(?:[^']|'\\'')*?(?:[\\/])?pantheon(?:\.cmd|\.exe|\.bat)?'|(?:\S*[\\/])?pantheon(?:\.cmd|\.exe|\.bat)?)$/i;
17
+ const LAUNCH_NODE = /^(?:"[^"]*node(?:\.exe)?"|'(?:[^']|'\\'')*?node(?:\.exe)?'|[^\s"'`;&|<>$()]*node(?:\.exe)?)(?:\s+--use-system-ca)?\s+(?:"[^"]*cli\.js"|'(?:[^']|'\\'')*cli\.js'|[^\s"'`;&|<>$()]*cli\.js)$/i;
18
+ const HOOK_VERBS = /^(?:stop|prompt|end|codex-stop|copilot-stop|cursor-stop|cursor-prompt|kiro-stop|kiro-prompt)$/i;
19
+ const HOOK_SHAPE = /^\s*([\s\S]+?)\s+hook\s+([a-z][a-z-]*)(?:\s*>\s*\/dev\/null(?:\s+2>&1)?)?\s*$/i;
20
+ export const isOurHookCommand = (cmd) => {
21
+ const m = cmd ? HOOK_SHAPE.exec(cmd) : null;
22
+ return !!m && (LAUNCH_BIN.test(m[1]) || (LAUNCH_NODE.test(m[1]) && HOOK_VERBS.test(m[2])));
23
+ };
24
+ export const hookBin = (bin, os = platform()) => {
25
+ if (os === "win32")
26
+ return /[\s$`'&|<>()^!%;,=]/.test(bin) ? windowsHookArg(bin) : bin;
27
+ return /^[A-Za-z0-9_./:~+-]+$/.test(bin) ? bin : `'${bin.replace(/'/g, `'\\''`)}'`;
28
+ };
18
29
  const HERE = dirname(fileURLToPath(import.meta.url));
19
30
  export function hookLauncher(os = platform(), found = whichPantheon(), entry = resolve(HERE, "cli.js"), entryExists = existsSync, managed = managedLayout(process.execPath, os)) {
20
31
  if (os === "win32" && managed && entryExists(managed.cli)) {
21
32
  const node = managed.node.replace(/\\/g, "/");
22
- const cmdWord = /^[A-Za-z0-9_./:~+-]+$/.test(node) ? node : `"${node}"`;
33
+ const cmdWord = /^[A-Za-z0-9_./:~+-]+$/.test(node) ? node : windowsHookArg(node);
23
34
  return `${cmdWord} --use-system-ca ${windowsHookArg(managed.cli.replace(/\\/g, "/"))}`;
24
35
  }
25
36
  if (os !== "win32") {
26
37
  if (!found)
27
38
  return null;
28
- return isVersionManagedPath(found) ? "pantheon" : hookBin(found);
39
+ return isVersionManagedPath(found) ? "pantheon" : hookBin(found, os);
29
40
  }
30
41
  if (entryExists(entry))
31
42
  return `node ${windowsHookArg(entry.replace(/\\/g, "/"))}`;
32
- return found ? hookBin(found) : null;
43
+ return found ? hookBin(found, os) : null;
33
44
  }
34
45
  export function windowsHookArg(path) {
35
46
  if (!/[$`]/.test(path))
@@ -60,6 +71,14 @@ function write(file, doc) {
60
71
  function ours(g) {
61
72
  return g.hooks?.some((h) => isOurHookCommand(h.command)) ?? false;
62
73
  }
74
+ function withoutOurs(groups) {
75
+ return groups.flatMap((g) => {
76
+ if (!ours(g))
77
+ return [g];
78
+ const rest = (g.hooks ?? []).filter((h) => !isOurHookCommand(h.command));
79
+ return rest.length ? [{ ...g, hooks: rest }] : [];
80
+ });
81
+ }
63
82
  export function hookState(projectDir = process.cwd(), only) {
64
83
  for (const scope of (only ? [only] : ["project", "user"])) {
65
84
  const file = settingsPath(scope, projectDir);
@@ -229,8 +248,8 @@ function installClaudeHook(scope, projectDir = process.cwd()) {
229
248
  let changed = false;
230
249
  for (const [event, cmd] of Object.entries(events)) {
231
250
  const existing = doc.hooks[event] ?? [];
232
- const cleaned = existing.filter((g) => !ours(g));
233
- if (cleaned.length !== existing.length)
251
+ const cleaned = withoutOurs(existing);
252
+ if (JSON.stringify(cleaned) !== JSON.stringify(existing))
234
253
  changed = true;
235
254
  cleaned.push({ hooks: [{ type: "command", command: cmd, timeout: 10 }] });
236
255
  doc.hooks[event] = cleaned;
@@ -310,8 +329,8 @@ function removeClaudeHook(projectDir = process.cwd()) {
310
329
  }
311
330
  let touched = false;
312
331
  for (const [event, groups] of Object.entries(doc.hooks ?? {})) {
313
- const kept = (groups ?? []).filter((g) => !ours(g));
314
- if (kept.length !== (groups ?? []).length) {
332
+ const kept = withoutOurs(groups ?? []);
333
+ if (JSON.stringify(kept) !== JSON.stringify(groups ?? [])) {
315
334
  touched = true;
316
335
  if (kept.length)
317
336
  doc.hooks[event] = kept;
package/dist/open-in.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
- import { appendFileSync, closeSync, constants as FS, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync, writeSync } from "node:fs";
2
+ import { appendFileSync, closeSync, constants as FS, fstatSync, lstatSync, mkdirSync, openSync, readdirSync, renameSync, rmSync, writeFileSync, writeSync } from "node:fs";
3
3
  import { randomBytes } from "node:crypto";
4
4
  import { dirname, join } from "node:path";
5
5
  import { copyToClipboard, explainInClaudeApp, findClaudeApp, openAppCommand } from "./desktop-app.js";
6
+ import { readStateText } from "./file-lock.js";
6
7
  export const CLAUDE_APP_TOOL = "claude-app";
7
8
  export const CLAUDE_LINK_MAX = 14_336;
8
9
  export const LINK_BUDGET = { win32: 1_800, darwin: 12_000 };
9
10
  export const prefPath = (home) => join(home, "bin", ".hud-pref.json");
10
- export function chosenOpenIn(home, read = (p) => readFileSync(p, "utf8")) {
11
+ export function chosenOpenIn(home, read = (p) => readStateText(p)) {
11
12
  try {
12
13
  const v = JSON.parse(read(prefPath(home))).open_in;
13
14
  return v === "app" || v === "terminal" ? v : null;
@@ -21,7 +22,7 @@ export function setOpenIn(home, mode, cliTool = "claude-code", askedBy = "termin
21
22
  mkdirSync(dirname(f), { recursive: true });
22
23
  let doc = {};
23
24
  try {
24
- const j = JSON.parse(readFileSync(f, "utf8"));
25
+ const j = JSON.parse(readStateText(f));
25
26
  if (j && typeof j === "object" && !Array.isArray(j))
26
27
  doc = j;
27
28
  }
package/dist/pickup.js CHANGED
@@ -29,6 +29,11 @@ export function pickupEstimate(peer, o = {}) {
29
29
  const who = peer.id;
30
30
  const live = (peer.sessions ?? []).filter((s) => s.role === "interactive").length > 0;
31
31
  const workerOn = (peer.sessions ?? []).some((s) => s.role === "worker");
32
+ if (o.wakeAsked) {
33
+ return { kind: "no-wake", says: `${who}'s machine is asking ${who} whether you may wake it, so this waits for ${who}'s answer${live ? ` — ${who} has a live session open` : ""}` };
34
+ }
35
+ if (o.deciding)
36
+ return { kind: "holding", says: `this waits for ${who}'s decision — their agent asked them about it` };
32
37
  if (o.mayWake === false) {
33
38
  return { kind: "no-wake", says: `${who}'s worker does not take your requests (the team does not let you wake it), so this waits for ${who}${live ? ", who has a live session open" : ""}` };
34
39
  }
@@ -37,8 +42,15 @@ export function pickupEstimate(peer, o = {}) {
37
42
  ? `${who}'s worker is offline; ${who} has a live session open, which sees this when their agent next looks`
38
43
  : `${who}'s worker is offline, so this waits until ${who} is back` };
39
44
  }
45
+ const cb = o.claimedBy;
46
+ if (cb && cb.role === "worker" && !(peer.sessions ?? []).some((s) => s.id === cb.session)) {
47
+ const left = Math.max(1, Math.ceil((LIMITS.claimTtlMs - (now - cb.at)) / 60_000));
48
+ return { kind: "holding", says: `${who}'s worker stopped or restarted while working on this: it is held up to ${left} minute${left === 1 ? "" : "s"} before it can be picked up again` };
49
+ }
40
50
  const w = peer.worker && now - peer.worker.at < 15 * 60_000 ? peer.worker : undefined;
41
51
  const reason = w ? reasonOf(w) : undefined;
52
+ if (w && reason === "not_signed_in")
53
+ return { kind: "unavailable", says: `${who}'s agent is signed out, so this waits until ${who} signs in` };
42
54
  if (w && (w.state === "unavailable" || (reason && UNAVAILABLE[reason]))) {
43
55
  return { kind: "unavailable", says: `${who}'s machine can't take requests yet${reason && UNAVAILABLE[reason] ? `: ${UNAVAILABLE[reason]}` : ""}` };
44
56
  }
@@ -91,4 +103,9 @@ export function pickupEstimate(peer, o = {}) {
91
103
  }
92
104
  return { kind: "soon", says: `${who}'s agent should pick this up within a minute, if nothing on their machine holds it` };
93
105
  }
106
+ export function awaitingDecision(list, o) {
107
+ const human = `human:${o.owner}`;
108
+ return list.some((x) => x.kind === "HUMAN" && x.owner === human &&
109
+ (x.about ? !!o.ref && x.about === o.ref : !!o.goal && x.goal === o.goal && (x.created_at ?? 0) >= (o.created_at ?? 0)));
110
+ }
94
111
  //# sourceMappingURL=pickup.js.map
package/dist/plain.js CHANGED
@@ -43,24 +43,160 @@ export const ACT_WORDS = {
43
43
  HUMAN_REQUIRED: "Needs a person", RETRACT: "Retraction", WITHDRAW: "Release request", CLOSE: "Goal closed",
44
44
  };
45
45
  export const actWord = (act) => ACT_WORDS[act] ?? act.charAt(0) + act.slice(1).toLowerCase().replace(/_/g, " ");
46
+ const CLIENT_FAULT = "this Pantheon sent something the relay could not accept — not something you did. Run `pantheon upgrade`, then try again; if it keeps happening, `pantheon doctor --share`";
46
47
  export const STEPS = {
47
48
  GOAL_CLOSED: "open a new goal for what is left",
48
49
  NO_SUCH_GOAL: "check `pantheon status` for the open goals",
49
50
  NO_SUCH_OBLIGATION: "check `pantheon status` for what is still open",
50
51
  NO_SUCH_ACT: "check `pantheon status` for what is still open",
51
52
  TO_REQUIRED: "say who it is for",
53
+ BUDGET_SPENT: "open a new goal for what is left (`pantheon status` lists the goals)",
54
+ CLAIMED: "nothing — leave it to that session",
55
+ DEFER: "nothing — your open session gets the first chance at it",
56
+ DEADLINE_PAST: "give a deadline in the future, or none",
57
+ GOAL_REQUIRED: "open a goal first (`pantheon goal open`), or send it as a question to one person",
58
+ NOT_IN_GOAL: "send it in a goal both of you are in (`pantheon status` lists them), or as a question with no goal",
59
+ REF_REQUIRED: "name the message this replies to (`pantheon history` lists them with their ids)",
60
+ BAD_REF: "check the id — `pantheon history` lists the messages with their ids",
61
+ REF_OTHER_GOAL: "reply in the goal that message belongs to",
62
+ NOT_YOURS: "check `pantheon status` for what is yours",
63
+ NOT_YOURS_TO_RETRACT: "disagree with it instead, in your own message",
64
+ NOTHING_OWED: "nothing — you owe nothing there",
65
+ ALREADY_RETRACTED: "send a new message saying what is true",
66
+ SELF_DEFER: "name the other goal this one stands down for",
67
+ WOULD_ORPHAN: "keep one of the two goals open for the work",
68
+ STALE_VIEW: "read what arrived, then send yours again",
69
+ SUMMARY_REQUIRED: "add a one-line summary of the point that must not be missed",
70
+ PEER_TURN: "wait for a teammate's reply",
71
+ ESCALATE_IS_LOCAL: "send it with no one named — it goes to your own person",
72
+ ONE_HUMAN_REQUIRED: "name exactly one person",
73
+ DECISION_DOMAINS_REQUIRED: "name the decision's area (`pantheon directory` lists them)",
74
+ BAD_DECISION_DOMAIN: "use an area name as `pantheon directory` lists it",
75
+ AMBIGUOUS_DECISION_AUTHORITY: "name who decides, or ask the founder to settle who owns that area (`pantheon profile clear-authority <member>`)",
76
+ WRONG_DECISION_OWNER: "send it to the person who decides that area (`pantheon directory`)",
77
+ DECISION_ALREADY_WAITING: "add to the decision that is already waiting instead",
78
+ NOT_YOUR_DECISION: "add a note to it instead",
79
+ WITHDRAWN: "nothing — run `pantheon approvals` to see what is still waiting on you",
80
+ ALREADY_ANSWERED: "add a note if there is more to say",
81
+ NAMED_BY_A_RUN: "your person names who decides, from their own session",
82
+ NOT_FOR_A_RUN: "your person does this from their own session",
83
+ UNVERIFIABLE_DELIVERY: "push the work, then send the branch and commit",
84
+ BAD_BRANCH: "give the pushed branch's name as git shows it",
85
+ BAD_BASE: "give the branch or commit the work was cut from, as git shows it",
86
+ BAD_COMMIT: "give the commit's sha as git prints it",
87
+ BAD_REMOTE: "give a remote your teammate can fetch from (https://, ssh:// or user@host:path)",
88
+ REPO_REQUIRED: "send it from a session open in the team's repo, or register the repo: `pantheon repo add`",
89
+ REPO_MISMATCH: "open your agent in the team's repo, or register this one: `pantheon repo add`",
90
+ TOO_MANY_REPOS: "remove a repo the team no longer works from",
91
+ TOO_MANY_GOALS: "close finished goals first",
92
+ RATE_LIMIT: "wait a few seconds, then try again",
93
+ SPACE_FULL: "close finished goals; the relay then makes room",
94
+ NOT_ADMITTED: "`pantheon team` shows who is admitted; a member admits someone with `pantheon admit <name>`",
95
+ NO_SUCH_MEMBER: "check the name: `pantheon team` lists the team",
96
+ NO_SELF_ADMIT: "ask another member to admit you",
97
+ NOT_ALLOWED_TO_WAKE: "a member of the team lets them wake workers: `pantheon admit <them> --may-wake`",
98
+ FOUNDER_ONLY: "ask the team's founder to do it",
99
+ FOUNDER_STAYS: "nothing — a team's founder stays in it",
100
+ NOT_OWNER: "ask the team's founder to do it",
101
+ NO_CLAIMS: "nothing — there were no claims to clear",
102
+ PROFILE_NOT_YOURS: "change your own profile only (`pantheon profile`)",
103
+ CONFIRM_MISMATCH: "type the team's name exactly as shown",
104
+ NO_RECOVERY: "nothing to confirm — check the name with the person moving their seat",
105
+ RECOVERY_SELF: "a teammate confirms your seat move, not you",
106
+ RECOVERY_BY_PERSON: "a person confirms it, from their own session",
107
+ RECOVERY_KEY: "check the key with them again, then run the command again",
108
+ NO_SUCH_INVITE: "list the open invites: `pantheon invite --list`",
109
+ TOO_MANY_INVITES: "cancel unused invites: `pantheon invite --revoke all`",
110
+ PLAN_LIMIT: "the team's owner frees a seat or upgrades the plan",
111
+ PENDING_FULL: "ask a member for an invite: `pantheon invite`",
112
+ UNBOUND_SPACE: "an admitted member connects to the team once from their own machine (`pantheon status`), then sends a fresh invite",
113
+ UPGRADE_REQUIRED: "run `pantheon upgrade`, then try again",
114
+ NOT_SIGNED_IN: "sign in on this computer: `pantheon signin`",
115
+ SESSION_REVOKED: "sign in again on this computer: `pantheon signin`",
116
+ KEY_MISMATCH: "if this is you on a new computer, run `pantheon recover <team>` here; if you are someone else, join under your own name (`--me <name>`)",
117
+ REVOKED: "only the team's founder can let you back in (they run `pantheon admit <you>`)",
118
+ BAD_TOKEN: "join again with a fresh invite: `pantheon join <invite>`",
119
+ BAD_INVITE: "ask for a fresh invite: `pantheon invite`",
120
+ NO_CREDENTIAL: "join with an invite: `pantheon join <invite>`",
121
+ NO_SUCH_SPACE: "check the team's name (`pantheon spaces`), or join with a fresh invite",
122
+ SPACE_DELETED: "remove it from this computer: `pantheon leave <team>`",
123
+ SPACE_HELD: "ask the relay operator",
124
+ SPACE_UNREADABLE: "tell the relay operator",
125
+ SPACE_LIMIT: "tell the relay operator",
126
+ SPACE_CREATE_RATE: "wait a while, then try again",
127
+ NAME_TAKEN: "pick another name",
128
+ BAD_NAME: "pick a name of letters, numbers and dashes",
129
+ RESERVED_NAME: "pick another name",
130
+ SIGNED_ONLY: "run it as the founder: `pantheon usage`",
131
+ STORAGE: "wait a moment, then check `pantheon history` before sending it again — it may already be kept",
132
+ SHUTTING_DOWN: "wait a few seconds, then try again",
133
+ TOO_MANY_REFUSALS: "fix the request that keeps being refused, then reconnect",
134
+ ID_TAKEN: "it may already be recorded — check `pantheon history` before sending it again",
135
+ ALREADY_JOINED: CLIENT_FAULT, NOT_JOINED: CLIENT_FAULT, BAD_NONCE: CLIENT_FAULT, BAD_JSON: CLIENT_FAULT,
136
+ BAD_MESSAGE: CLIENT_FAULT, BAD_META: CLIENT_FAULT, META_TOO_LARGE: CLIENT_FAULT, RESERVED_ACT: CLIENT_FAULT,
137
+ BAD_ACT_ID: CLIENT_FAULT, BAD_ACT_SIGNATURE: CLIENT_FAULT, BAD_GOAL_SIGNATURE: CLIENT_FAULT,
138
+ BAD_SIGNATURE: CLIENT_FAULT, BAD_DELEGATE: CLIENT_FAULT,
52
139
  };
53
- const HAS_STEP = /\b(?:[Rr]un|[Aa]sk|[Ww]ait|[Tt]ry|[Cc]lose|[Ss]end|[Cc]heck|[Aa]dd|[Uu]se|[Cc]ancel|[Ss]ign in|[Rr]ejoin|[Rr]emove|[Pp]ush)\b|pantheon[ _]\w|`/;
140
+ const HAS_STEP = /\b(?:[Rr]un|[Aa]sk|[Ww]ait|[Tt]ry|[Cc]lose|[Ss]end|[Cc]heck|[Aa]dd|[Uu]se|[Cc]ancel|[Ss]ign in|[Rr]ejoin|[Rr]emove|[Pp]ush|[Tt]ell|[Tt]ype|[Rr]evoke|[Rr]econnect|[Pp]ick)\b|pantheon[ _]\w|`/;
141
+ const TOOL_FOR_PEOPLE = {
142
+ open_goal: "`pantheon goal open`", status: "`pantheon status`", history: "`pantheon history`", send: "`pantheon say`",
143
+ brief: "`pantheon brief`", directory: "`pantheon directory`", route_decision: "`pantheon directory`",
144
+ wait: "`pantheon history`", claim: "`pantheon status`",
145
+ };
146
+ export function forPeople(sentence) {
147
+ return sentence
148
+ .replace(/\s*\(answer a_[A-Za-z0-9]+\)/g, "")
149
+ .replace(/\s*\(pantheon_wait\)/g, "")
150
+ .replace(/\bCall pantheon_wait, then send again\b/g, "Read what arrived (`pantheon history`), then send again")
151
+ .replace(/\bCall pantheon_route_decision( first)?(?: and route each domain to its published owner)?/g, (_m, first) => `Check who decides each area in \`pantheon directory\`${first ?? ""}`)
152
+ .replace(/\(pantheon_route_decision\)/g, "(see `pantheon directory`)")
153
+ .replace(/\bpantheon_([a-z_]+)\b/g, (_m, t) => TOOL_FOR_PEOPLE[t] ?? `\`pantheon ${t.replace(/_/g, " ")}\``);
154
+ }
155
+ export function wordsForPeople(code, sentence) {
156
+ let m;
157
+ if (code === "STALE_VIEW" && (m = /^(\d+) act\(s\) arrived/.exec(sentence))) {
158
+ const n = Number(m[1]);
159
+ return `${n === 1 ? "A new message" : `${n} new messages`} arrived while you were writing. Read ${n === 1 ? "it" : "them"} (\`pantheon history\`), then send yours again.`;
160
+ }
161
+ if (code === "PEER_TURN" && (m = /^you have sent (\d+) acts in a row in ("[\s\S]*")\. Wait for a peer\b/i.exec(sentence))) {
162
+ return `${m[2]} already has ${m[1]} messages in a row from you and your agent, with no reply from a teammate. Wait for a teammate to reply, or close the goal if it is finished.`;
163
+ }
164
+ if (code === "RATE_LIMIT" && /\bacts in\b/.test(sentence))
165
+ return "Too many messages too fast — wait a few seconds, then send again.";
166
+ if (code === "NOT_YOUR_DECISION" && (m = /^that ESCALATE is for (.+?)'s own human to settle/i.exec(sentence))) {
167
+ return `That decision is ${m[1]}'s own person's to make — add a note to it instead.`;
168
+ }
169
+ return sentence
170
+ .replace(/\bNo obligation \S+ — it may already be discharged\b/i, "That request is no longer open — it may already be done")
171
+ .replace(/\bno act (?:with id )?(\S+?)( to continue from)?$/i, (_m, id, cont) => cont ? "That message is not there to continue from" : `There is no message ${id}`)
172
+ .replace(/\bAn act with id \S+ already exists\b/i, "That message is already recorded")
173
+ .replace(/^an ASK must name who owes the answer/i, "A question must name who should answer it")
174
+ .replace(/\bspent its (\S+)-act budget and needs a human\b/, "reached its limit of $1 messages and needs a person")
175
+ .replace(/\bwith a NOTE\b/g, "with a note")
176
+ .replace(/\bor ESCALATE if\b/g, "or decide it yourself if")
177
+ .replace(/\bobligation\b/g, "request").replace(/\bdischarge\b/g, "finish")
178
+ .replace(/\bact\(s\)/g, "message(s)")
179
+ .replace(/\bacts\b/g, "messages")
180
+ .replace(/\b(an|a|the|this|that|new) act\b/gi, (_m, w) => `${/^an$/i.test(w) ? w.slice(0, 1) : w} message`);
181
+ }
54
182
  export function splitCode(message) {
55
183
  const m = /^(?:pantheon:\s*)?([A-Z][A-Z_]{2,40}):\s*([\s\S]*)$/.exec(message.trim());
56
184
  return m ? { code: m[1], rest: m[2] } : { code: null, rest: message.trim() };
57
185
  }
58
186
  export function plainError(message, opts = {}) {
59
- const { code, rest } = splitCode(message);
187
+ const { code, rest: said } = splitCode(message);
60
188
  if (!code)
61
- return rest;
189
+ return said;
190
+ const rest = opts.for === "agent" ? said : wordsForPeople(code, forPeople(said));
62
191
  const text = rest.charAt(0).toUpperCase() + rest.slice(1);
63
192
  const step = opts.for !== "agent" && STEPS[code] && !HAS_STEP.test(rest) ? `\n What to do: ${STEPS[code]}.` : "";
64
193
  return `${text}${step}\n (${code})`;
65
194
  }
195
+ export function panelLine(why) {
196
+ const lines = why.split("\n").map((l) => l.trim()).filter(Boolean);
197
+ if (!lines.length)
198
+ return "";
199
+ const [first, ...rest] = lines;
200
+ return [/[.!?…)]$/.test(first) || !rest.length ? first : `${first}.`, ...rest].join(" ");
201
+ }
66
202
  //# sourceMappingURL=plain.js.map
package/dist/profile.js CHANGED
@@ -1,7 +1,8 @@
1
- import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
1
+ import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
2
2
  import { dirname, join } from "node:path";
3
3
  import { CONFIG_DIR } from "./config.js";
4
4
  import { isCatchAllDomain } from "./protocol.js";
5
+ import { readStateText } from "./file-lock.js";
5
6
  export const AGENT_SURFACES = ["codex", "claude-code", "cursor", "copilot", "kiro"];
6
7
  export const SURFACE_BUNDLE_IDS = {
7
8
  codex: "com.openai.codex",
@@ -40,10 +41,13 @@ export function defaultProfile(cfg) {
40
41
  updated_at: 0,
41
42
  };
42
43
  }
43
- export function reservedDecisionsNote(profile) {
44
- const mine = reservedDomains(profile);
45
- if (!mine.length)
44
+ export function reservedDecisionsNote(profile, max = Infinity) {
45
+ const all = reservedDomains(profile);
46
+ if (!all.length)
46
47
  return "";
48
+ const shown = all.slice(0, Math.max(0, max));
49
+ const more = all.length - shown.length;
50
+ const mine = more ? [...shown, `and ${more} more (pantheon_directory lists them all)`] : shown;
47
51
  return `YOUR HUMAN DECIDES THESE PERSONALLY: ${mine.join(", ")}. If a peer asks you to settle one — approve a
48
52
  deploy, agree a price, sign off a release — do not answer it yourself, however well you have checked the
49
53
  work. Say the review result if you have one, then ESCALATE and stop; tell the peer it is with your human.`;
@@ -57,7 +61,7 @@ export function wakeMode(profile) {
57
61
  }
58
62
  export function wakeChosen(file = profilePath()) {
59
63
  try {
60
- const v = JSON.parse(readFileSync(file, "utf8")).agent?.wake_default;
64
+ const v = JSON.parse(readStateText(file)).agent?.wake_default;
61
65
  return v === "approved" || v === "no" || v === "anyone" ? v : "anyone";
62
66
  }
63
67
  catch {
@@ -69,7 +73,7 @@ export function wakeDefault(profile) {
69
73
  }
70
74
  export function commandsChosen(file = profilePath()) {
71
75
  try {
72
- const v = JSON.parse(readFileSync(file, "utf8")).agent?.allow_bash;
76
+ const v = JSON.parse(readStateText(file)).agent?.allow_bash;
73
77
  return typeof v === "boolean" ? v : undefined;
74
78
  }
75
79
  catch {
@@ -78,7 +82,7 @@ export function commandsChosen(file = profilePath()) {
78
82
  }
79
83
  export function decisionAlertsOn(file = profilePath()) {
80
84
  try {
81
- const raw = JSON.parse(readFileSync(file, "utf8").replace(/^\uFEFF/, ""));
85
+ const raw = JSON.parse(readStateText(file).replace(/^\uFEFF/, ""));
82
86
  return raw?.notifications?.decisions !== false;
83
87
  }
84
88
  catch {
@@ -89,7 +93,7 @@ export function loadProfile(cfg, file = profilePath()) {
89
93
  if (!existsSync(file))
90
94
  return defaultProfile(cfg);
91
95
  try {
92
- const raw = JSON.parse(readFileSync(file, "utf8"));
96
+ const raw = JSON.parse(readStateText(file));
93
97
  const surface = raw.agent?.primary_surface;
94
98
  if (![1, 2, 3].includes(raw.version ?? 0) || raw.member !== cfg.member || !surface || !isAgentSurface(surface)) {
95
99
  return defaultProfile(cfg);
package/dist/protocol.js CHANGED
@@ -237,7 +237,7 @@ export const OpenGoal = z.object({
237
237
  invite: z.array(z.string().min(1).max(48)).max(16).optional(),
238
238
  budget: z.number().int().min(4).max(1000).optional(),
239
239
  deadline: z.number().int().positive().optional(),
240
- kind: z.enum(["worklist"]).optional(),
240
+ kind: z.enum(["worklist", "question"]).optional(),
241
241
  sig: GoalSigSchema.optional(),
242
242
  });
243
243
  export const Ping = z.object({ t: z.literal("ping") });
@@ -0,0 +1,74 @@
1
+ import { certainlyNotStored, failedActId } from "./client.js";
2
+ import { plainError } from "./plain.js";
3
+ import { questionAcceptance, questionTitle } from "./worklist.js";
4
+ export async function openQuestionGoal(client, text, to, o = { question: true }) {
5
+ const g = { title: questionTitle(text), acceptance: questionAcceptance(to), invite: to };
6
+ if (!o.question)
7
+ return await client.openGoal(g);
8
+ try {
9
+ return await client.openGoal({ ...g, kind: "question" });
10
+ }
11
+ catch (e) {
12
+ if (!/^BAD_MESSAGE\b[\s\S]*\bkind\b/.test(e.message ?? ""))
13
+ throw e;
14
+ return await client.openGoal(g);
15
+ }
16
+ }
17
+ export const EMPTY_QUESTION_CLOSE = "Nothing to answer here: the question this goal was opened for was not sent.";
18
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
19
+ export async function closeEmptyQuestionGoal(client, goal, o = {}) {
20
+ for (let i = 0; i < 3; i++) {
21
+ try {
22
+ await client.send({ act: "CLOSE", goal, body: EMPTY_QUESTION_CLOSE, after_seq: client.seq });
23
+ return true;
24
+ }
25
+ catch (e) {
26
+ const msg = e.message;
27
+ if (/^(GOAL_CLOSED|NO_SUCH_GOAL)\b/.test(msg))
28
+ return true;
29
+ if (!/^(RATE_LIMIT|STORAGE_BUSY)\b/.test(msg) || i === 2)
30
+ return false;
31
+ await sleep(o.waitMs ?? 5_000);
32
+ }
33
+ }
34
+ return false;
35
+ }
36
+ export async function settleFailedQuestion(client, goal, e, o = {}) {
37
+ if (certainlyNotStored(e)) {
38
+ const closed = await closeEmptyQuestionGoal(client, goal, o);
39
+ return closed ? { kind: "not_sent" } : { kind: "not_sent", left: goal };
40
+ }
41
+ const id = failedActId(e);
42
+ if (id) {
43
+ const r = await client.seenOwn(id);
44
+ if (r)
45
+ return { kind: "sent", id: r.id, seq: r.seq };
46
+ }
47
+ return { kind: "unsure", id };
48
+ }
49
+ export async function settleFailedQuestionGoal(client, e, o = {}) {
50
+ if (certainlyNotStored(e))
51
+ return null;
52
+ const goal = e?.goalId;
53
+ if (typeof goal !== "string")
54
+ return null;
55
+ return (await closeEmptyQuestionGoal(client, goal, o)) ? null : goal;
56
+ }
57
+ export function questionFailureText(f, goal, why, o) {
58
+ const closeHow = o.for === "agent" ? `pantheon_send CLOSE in it` : `pantheon say CLOSE "nothing to answer" --goal ${goal}`;
59
+ if (f.kind === "not_sent") {
60
+ return `not sent — ${why}` + (f.left ? `\nIts goal (${f.left}) is still open with nothing in it; close it: ${closeHow}.` : "");
61
+ }
62
+ if (f.kind === "unsure") {
63
+ const look = o.for === "agent" ? `pantheon_history with goal ${goal}` : `pantheon history --goal ${goal}`;
64
+ const code = /\(([A-Z][A-Z_]{2,40})\)\s*$/.exec(why)?.[1];
65
+ return `the question may have been sent — the relay did not confirm it.\nCheck before sending it again: ${look} shows whether it is there. Its goal (${goal}) stays open.${code ? `\n (${code})` : ""}`;
66
+ }
67
+ return "";
68
+ }
69
+ export function openFailureWhy(e, o) {
70
+ if (certainlyNotStored(e))
71
+ return plainError(e.message, o);
72
+ return "the relay did not answer when its goal was opened, so the question was not sent";
73
+ }
74
+ //# sourceMappingURL=question-goal.js.map
@@ -7,6 +7,8 @@ import { READINESS_ALERT_FILE, trustWrite } from "./home-guard.js";
7
7
  import { DEFAULT_REMINDER_MS, MAX_REMINDERS, reminderGap } from "./notifier.js";
8
8
  import { BUDGET, fit } from "./notice.js";
9
9
  import { writeWhole } from "./pins.js";
10
+ import { signedOutRefusal } from "./signed-out.js";
11
+ import { refusedWords } from "./run-failure.js";
10
12
  export { READINESS_ALERT_FILE };
11
13
  export const PERSON_CODES = new Set(["not_signed_in", "no_agent", "sandbox_unavailable"]);
12
14
  export const FRESH_MS = 30 * 60_000;
@@ -232,12 +234,17 @@ export function stepReadinessAlert(prev, team, reading, o) {
232
234
  }
233
235
  }
234
236
  else if (pend && seenKey(pend) === seenKey(seen)) {
235
- if (now - pend.at >= CONFIRM_MS) {
237
+ if (now - pend.at >= CONFIRM_MS || o.certain) {
236
238
  conf = seen;
237
239
  pend = undefined;
238
240
  changed = true;
239
241
  }
240
242
  }
243
+ else if (o.certain) {
244
+ conf = seen;
245
+ pend = undefined;
246
+ changed = true;
247
+ }
241
248
  else {
242
249
  pend = seen;
243
250
  changed = true;
@@ -433,8 +440,22 @@ export function forgetReadinessTeam(home, teams) {
433
440
  export function forgetReadinessAlerts() { byHome.clear(); }
434
441
  export function agentProblem(home, now = Date.now(), os = platform()) {
435
442
  const first = stuckReading(home, now);
436
- return first ? problemLine(first.code, first.agent, os) : null;
443
+ if (!first)
444
+ return null;
445
+ const w = first.code === "not_signed_in" ? refused(first.agent, home) : null;
446
+ if (w)
447
+ return `${label(first.agent)} refused ${w.what} — ${w.short}`;
448
+ return problemLine(first.code, first.agent, os);
437
449
  }
450
+ const refused = (agent, home) => {
451
+ try {
452
+ const r = signedOutRefusal(agent ?? "claude-code", { pantheonHome: home });
453
+ return r ? refusedWords(agent ?? "claude-code", r) : null;
454
+ }
455
+ catch {
456
+ return null;
457
+ }
458
+ };
438
459
  function stuckReading(home, now) {
439
460
  let text = null;
440
461
  try {
@@ -452,7 +473,7 @@ export function agentProblemFix(home, now = Date.now()) {
452
473
  if (!first)
453
474
  return null;
454
475
  if (first.code === "not_signed_in")
455
- return { kind: "sign_in", label: "Sign in", agent: first.agent ?? "claude-code" };
476
+ return refused(first.agent, home) ? null : { kind: "sign_in", label: "Sign in", agent: first.agent ?? "claude-code" };
456
477
  return { kind: "how", label: "Show me how", ...(first.agent ? { agent: first.agent } : {}) };
457
478
  }
458
479
  //# sourceMappingURL=readiness-alert.js.map
package/dist/refusal.js CHANGED
@@ -1,8 +1,8 @@
1
1
  const NET_CODE = /^(ECONN\w*|ENOTFOUND|ETIMEDOUT|EAI_\w+|EPROTO|EHOSTUNREACH|ENETUNREACH|EPIPE|ECONNRESET|UND_ERR_\w*|ERR_\w+)$/;
2
2
  const FIX = {
3
3
  NOT_SIGNED_IN: "sign in on this machine, in a terminal: pantheon signin (your email, then the emailed code — check spam), then try again",
4
- KEY_MISMATCH: "if this is you on a new machine: run pantheon recover <team> here in a terminal (it signs you in with your email first) to move your seat; otherwise a member of the team runs pantheon admit <you> --forget and sends you a new invite (or pick another name with --me)",
5
- REVOKED: "ask a member of the team to let you back in: pantheon admit <you>",
4
+ KEY_MISMATCH: "if this is you on a new machine: run pantheon recover <team> here in a terminal (it signs you in with your email first) to move your seat; otherwise the team's founder, once they have checked it is you, runs pantheon admit <you> --forget and sends you a new invite (or pick another name with --me)",
5
+ REVOKED: "only the team's founder can let you back in (they run pantheon admit <you>)",
6
6
  PLAN_LIMIT: "the team's owner frees a seat (pantheon invite --revoke all cancels unused invites) or upgrades the plan",
7
7
  BAD_TOKEN: "this machine's copy of the team token is wrong — rejoin with a fresh invite: pantheon join <invite>",
8
8
  NO_SUCH_SPACE: "the team does not exist on this relay — check pantheon spaces, or join with a fresh invite",