@join-pantheon/cli 0.34.3 → 0.35.0-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.
package/dist/cli.js CHANGED
@@ -15,6 +15,7 @@ import { agentSpawn, CmdLineUnsafe } from "./which.js";
15
15
  import { fromInvite, looksLikeInviteCode, resolveInviteCode, load, save, toInvite, toJoinLink, resolveFor, loadAll, identity, repoInfo, bindRepo, bindFolder, unbindRepo, findMembership, matchMembership, setDefaultSpace, removeMembership, configFor, CONFIG_DIR, CONFIG_PATH, DEFAULT_RELAY, resolveForHook } from "./config.js";
16
16
  import { fmtLimit, lastSlotNotice, ownedTeamsIn, spaceLimitAdvice } from "./plans.js";
17
17
  import { validEmail, validUsername } from "./accounts.js";
18
+ import { clipWords, goalStateWord, OWED_WORDS, plainError, plainRequest } from "./plain.js";
18
19
  import { install, launcher, installForUser, windowsRepoOverrides, agentAsksOnce } from "./install.js";
19
20
  import { Relay } from "./relay.js";
20
21
  import { runMcp } from "./mcp.js";
@@ -374,7 +375,7 @@ function keywordFlag(raw) {
374
375
  return out;
375
376
  }
376
377
  function die(msg) {
377
- console.error(`pantheon: ${msg}`);
378
+ console.error(`pantheon: ${plainError(msg)}`);
378
379
  process.exit(1);
379
380
  }
380
381
  function sameHost(a, b) {
@@ -2612,7 +2613,7 @@ async function main() {
2612
2613
  ? "delivered, but no read-receipt — no wake-up hook on their machine"
2613
2614
  : "no wake-up hook on their machine — nothing surfaces until their human types")
2614
2615
  : behind > 0
2615
- ? `\x1b[33m${recent ? `their agent has not seen your last ${behind} act${behind === 1 ? "" : "s"}` : `their agent is ${behind} act${behind === 1 ? "" : "s"} behind the team`}\x1b[0m`
2616
+ ? `\x1b[33m${recent ? `their agent has not seen your last ${behind} message${behind === 1 ? "" : "s"}` : `their agent is ${behind} message${behind === 1 ? "" : "s"} behind the team`}\x1b[0m`
2616
2617
  : lag > 0 ? D("their agent has seen everything you sent") : D("their agent is caught up");
2617
2618
  console.log(` ${p.online ? C("●") : D("○")} ${p.id.padEnd(14)} ${D(p.agent.padEnd(12))} ${reach}`);
2618
2619
  {
@@ -2626,7 +2627,7 @@ async function main() {
2626
2627
  if (!goals.length)
2627
2628
  console.log(` ${D("(none)")}`);
2628
2629
  for (const g of goals) {
2629
- console.log(` ${g.state.padEnd(8)} ${String(g.acts).padStart(3)}/${g.budget} ${g.title}${g.kind === "worklist" ? D(" [worklist]") : ""} ${D(g.id)}`);
2630
+ console.log(` ${goalStateWord(g.state).padEnd(10)} ${g.title}${g.kind === "worklist" ? D(" [your list]") : ""} ${D(`${g.acts} of ${g.budget} messages · ${g.id}`)}`);
2630
2631
  }
2631
2632
  const owed = client.obligations;
2632
2633
  const ageOf = (t) => {
@@ -2635,7 +2636,7 @@ async function main() {
2635
2636
  };
2636
2637
  const human = owed.filter((o) => o.kind === "HUMAN");
2637
2638
  const between = owed.filter((o) => o.kind !== "HUMAN");
2638
- console.log(`\n${B("needs a human")}`);
2639
+ console.log(`\n${B("waiting on a person")}`);
2639
2640
  if (!human.length)
2640
2641
  console.log(` ${D("(nothing waiting on you)")}`);
2641
2642
  for (const o of human) {
@@ -2647,22 +2648,22 @@ async function main() {
2647
2648
  console.log(` ${who.padEnd(14)}${ageOf(o.created_at).padEnd(6)} ${D(`is being asked on their machine whether ${wakeAsk === cfg.member ? "you" : wakeAsk} may start work there while they are away`)}`);
2648
2649
  continue;
2649
2650
  }
2650
- console.log(` ${stale ? "\x1b[33m" : C("")}${who.padEnd(14)}${ageOf(o.created_at).padEnd(6)}\x1b[0m ${o.body.split("\n")[0].slice(0, 110)} ${D(o.ref)}`);
2651
+ console.log(` ${stale ? "\x1b[33m" : C("")}${who.padEnd(14)}${ageOf(o.created_at).padEnd(6)}\x1b[0m ${clipWords(plainRequest(o.body.split("\n")[0], cfg.member, who), 150)} ${D(o.ref)}`);
2651
2652
  if (who === cfg.member)
2652
- console.log(` ${D("your peer was told this decision was coming — answer it or say it is dropped")}`);
2653
+ console.log(` ${D("yours to answer: pantheon approvals")}`);
2653
2654
  }
2654
- console.log(`\n${B("between delegates")}`);
2655
+ console.log(`\n${B("waiting between agents")}`);
2655
2656
  if (!between.length)
2656
2657
  console.log(` ${D("(nothing owed)")}`);
2657
2658
  const myMayWake = client.members.find((m) => m.member === cfg.member)?.may_wake;
2658
2659
  for (const o of between) {
2659
- console.log(` ${o.kind.padEnd(7)} ${o.owner.padEnd(14)}${ageOf(o.created_at).padEnd(6)} ${o.body.split("\n")[0].slice(0, 110)} ${D(o.ref)}`);
2660
+ console.log(` ${o.owner.padEnd(14)}${ageOf(o.created_at).padEnd(6)} owes ${OWED_WORDS[o.kind] ?? o.kind.toLowerCase()}: ${clipWords(plainRequest(o.body.split("\n")[0], cfg.member), 130)} ${D(o.ref)}`);
2660
2661
  const peer = o.owner !== cfg.member && o.kind !== "DELIVER" ? client.roster.find((m) => m.id === o.owner) ?? { id: o.owner, sessions: [] } : null;
2661
2662
  if (peer)
2662
- console.log(` ${" ".repeat(7)} ${D(termSafe(pickupEstimate(peer, { now: client.relayNow(), about: { ref: o.ref, goal: o.goal }, ...(myMayWake !== undefined ? { mayWake: myMayWake } : {}) }).says))}`);
2663
+ console.log(` ${" ".repeat(20)} ${D(termSafe(pickupEstimate(peer, { now: client.relayNow(), about: { ref: o.ref, goal: o.goal }, ...(myMayWake !== undefined ? { mayWake: myMayWake } : {}) }).says))}`);
2663
2664
  }
2664
2665
  if (human.length || between.length || goals.some((g) => g.state !== "CLOSED")) {
2665
- console.log(D(`\n read in full: pantheon show <id> · a thread: pantheon history --goal <goal> · reply: pantheon say ANSWER "…" --ref <id>`));
2666
+ console.log(D(`\n read one in full: pantheon show <id> · reply: pantheon say ANSWER "…" --ref <id> · a whole goal: pantheon history --goal <id>`));
2666
2667
  }
2667
2668
  client.close();
2668
2669
  };
@@ -2853,6 +2854,14 @@ async function main() {
2853
2854
  const deadline = dl ? Date.parse(dl) : undefined;
2854
2855
  if (dl && !Number.isFinite(deadline))
2855
2856
  die(`--deadline takes a time like 2026-10-01T17:00:00Z, not "${dl}"`);
2857
+ {
2858
+ const { refuseOutbound } = await import("./outbound-guard.js");
2859
+ const leak = refuseOutbound(cfg, { title, acceptance: flag("acceptance") });
2860
+ if (leak) {
2861
+ client.close();
2862
+ die(leak.replace(/^pantheon: /, ""));
2863
+ }
2864
+ }
2856
2865
  const g = await client.openGoal({ title, acceptance: flag("acceptance") ?? "", ...(withs.length ? { invite: withs } : {}),
2857
2866
  ...(deadline ? { deadline } : {}), ...(argv.includes("--list") ? { kind: "worklist" } : {}) }).catch((e) => die(e.message));
2858
2867
  console.log(`opened ${g.id} "${title}"${withs.length ? ` with ${withs.join(", ")}` : ""}`);
@@ -2862,6 +2871,14 @@ async function main() {
2862
2871
  if (sub === "close") {
2863
2872
  const id = argv[2] ?? die('usage: pantheon goal close <goal id> "<what was done>"');
2864
2873
  const summary = argv.slice(3).filter((a) => !a.startsWith("--")).join(" ").trim() || die("say what was done: it is the goal's record");
2874
+ {
2875
+ const { refuseOutbound } = await import("./outbound-guard.js");
2876
+ const leak = refuseOutbound(cfg, { summary });
2877
+ if (leak) {
2878
+ client.close();
2879
+ die(leak.replace(/^pantheon: /, ""));
2880
+ }
2881
+ }
2865
2882
  const r = await client.send({ act: "CLOSE", body: summary, goal: id }).catch((e) => die(e.message));
2866
2883
  console.log(`closed ${id} (act ${r.id})`);
2867
2884
  return;
@@ -2891,6 +2908,12 @@ async function main() {
2891
2908
  die(`${stray} is not a flag of say, so it reads as part of your message — and the message would have stopped before it. Put the whole message in quotes: pantheon say ${act} "…"`);
2892
2909
  }
2893
2910
  const summary = flag("summary");
2911
+ {
2912
+ const { refuseOutbound } = await import("./outbound-guard.js");
2913
+ const leak = refuseOutbound(cfg, { body, summary, branch: flag("branch"), commit: flag("commit"), remote: flag("remote"), to: flag("to") });
2914
+ if (leak)
2915
+ die(leak.replace(/^pantheon: /, ""));
2916
+ }
2894
2917
  const client = new PantheonClient(cfg, undefined, { role: "cli" });
2895
2918
  await client.connect().catch((e) => die(connectFailure(e, cfg.relay)));
2896
2919
  const to = flag("to");
@@ -2937,6 +2960,16 @@ async function main() {
2937
2960
  ref = rr.id;
2938
2961
  goalArg = goalArg ?? rr.goal;
2939
2962
  }
2963
+ let questionNote = "";
2964
+ let questionGoal = null;
2965
+ if (act === "ASK" && !goalArg && !ref && to) {
2966
+ const who = to.split(",").map((s) => s.trim()).filter(Boolean);
2967
+ const { questionTitle } = await import("./worklist.js");
2968
+ const g = await client.openGoal({ title: questionTitle(summary ?? body), acceptance: `${who.join(", ")} answers`, invite: who })
2969
+ .catch((e) => { client.close(); return die(e.message); });
2970
+ goalArg = questionGoal = g.id;
2971
+ questionNote = `in a goal of its own — once answered, close it: pantheon say CLOSE "answered" --goal ${g.id}`;
2972
+ }
2940
2973
  const r = await client.send({
2941
2974
  act: act, body,
2942
2975
  goal: goalArg,
@@ -2944,13 +2977,19 @@ async function main() {
2944
2977
  ref,
2945
2978
  ...(summary ? { summary } : {}),
2946
2979
  ...(Object.keys(meta).length ? { meta } : {}),
2947
- }).catch((e) => die(/SUMMARY_REQUIRED/.test(e.message) ? `${e.message}\n Add one: --summary 'the point they must not miss'`
2948
- : /UNVERIFIABLE_DELIVERY/.test(e.message) ? `${e.message}\n From here: pantheon say DELIVERED "…" --branch <the pushed branch> --commit <its sha>`
2949
- : /BAD_REF/.test(e.message) ? `${e.message}\n pantheon history lists the acts with their ids and [sequence numbers]; --ref takes either, or "last"`
2950
- : /TO_REQUIRED/.test(e.message) ? `${e.message}\n Name who owes it: --to <member> (pantheon team lists them)`
2951
- : /GOAL_REQUIRED|NO_SUCH_GOAL|GOAL_CLOSED/.test(e.message) ? `${e.message.replace(/ — open one with pantheon_open_goal/, "").replace(/pantheon_open_goal/g, "pantheon goal open")}\n Open one from here: pantheon goal open "<what it is about>" --with <member> then add --goal <id> (pantheon goal list shows the open ones)`
2952
- : e.message));
2980
+ }).catch(async (e) => {
2981
+ if (questionGoal)
2982
+ await client.send({ act: "CLOSE", goal: questionGoal, body: "Not sent — the question was refused, so this goal holds nothing.", after_seq: client.seq }).catch(() => { });
2983
+ return die(/SUMMARY_REQUIRED/.test(e.message) ? `${e.message}\n Add one: --summary 'the point they must not miss'`
2984
+ : /UNVERIFIABLE_DELIVERY/.test(e.message) ? `${e.message}\n From here: pantheon say DELIVERED "…" --branch <the pushed branch> --commit <its sha>`
2985
+ : /BAD_REF/.test(e.message) ? `${e.message}\n pantheon history lists the acts with their ids and [sequence numbers]; --ref takes either, or "last"`
2986
+ : /TO_REQUIRED/.test(e.message) ? `${e.message}\n Name who owes it: --to <member> (pantheon team lists them)`
2987
+ : /GOAL_REQUIRED|NO_SUCH_GOAL|GOAL_CLOSED/.test(e.message) ? `${e.message.replace(/ — open one with pantheon_open_goal/, "").replace(/pantheon_open_goal/g, "pantheon goal open")}\n Open one from here: pantheon goal open "<what it is about>" --with <member> then add --goal <id> (pantheon goal list shows the open ones)`
2988
+ : e.message);
2989
+ });
2953
2990
  console.log(`sent ${act} id=${r.id} seq=${r.seq}`);
2991
+ if (questionNote)
2992
+ console.error(D(` ${questionNote}`));
2954
2993
  {
2955
2994
  const note = (await import("./secret-guard.js")).privateLinkNote(body, summary);
2956
2995
  if (note)
@@ -4765,13 +4804,13 @@ async function main() {
4765
4804
  if (!inWokenRun())
4766
4805
  await protectOrStop([{ setting: "waker", about: who, from: was ? "allowed" : "not allowed", to: sub === "allow" ? "allowed" : "not allowed" }]);
4767
4806
  }
4768
- const r = setLocalWaker([cfg.spaceId, cfg.space], who, sub === "allow");
4807
+ const r = setLocalWaker([cfg.spaceId, cfg.space], who, sub === "allow", undefined, process.env, { no: sub === "deny" });
4769
4808
  if (!r.ok)
4770
4809
  die(r.why);
4771
4810
  const mode = wakeMode(loadProfile(cfg));
4772
4811
  console.log(sub === "allow"
4773
4812
  ? `${C(who)} may wake this machine in ${cfg.space}${r.changed ? "" : D(" (already could)")}`
4774
- : `${C(who)} can no longer wake this machine in ${cfg.space}${r.changed ? "" : D(" (could not before either)")}`);
4813
+ : `${C(who)} can no longer wake this machine in ${cfg.space}${r.changed ? "" : D(" (could not before either)")} — and you won't be asked about them again`);
4775
4814
  console.log(D(` Recorded on this machine only — nothing was sent to the team. Undo: pantheon wake ${sub === "allow" ? "deny" : "allow"} ${who}${flag("space") ? ` --space ${cfg.space}` : ""}`));
4776
4815
  if (unchecked)
4777
4816
  console.log(D(` The relay did not answer, so "${who}" was not checked against the team's members — check the spelling (pantheon team).`));
@@ -4807,6 +4846,11 @@ async function main() {
4807
4846
  ? "when the worker last checked, the team's relay was older than 0.30 — until it is upgraded and the worker reconnects, the team's may_wake decides"
4808
4847
  : "from before 0.30 and not carried over yet — the worker does that when it next connects to a 0.30 relay; until then the team's may_wake decides";
4809
4848
  console.log(` ${t.space.padEnd(16)} ${names.length ? names.join(", ") : D("nobody")}${pending ? D(` (${why})`) : ""}`);
4849
+ const noes = Object.keys(pol.wakeNo ?? {}).filter((k) => k.startsWith(`${key}|`) || k.startsWith(`${t.space}|`)).map((k) => k.slice(k.indexOf("|") + 1));
4850
+ for (const who of [...new Set(noes)].sort()) {
4851
+ const final = pol.finalNo?.includes(`wake:${key}|${who}`) || pol.finalNo?.includes(`wake:${t.space}|${who}`);
4852
+ console.log(D(` ${" ".repeat(16)} said no to ${who}${final ? " — not asked again" : " — may be asked again after a month"}; to allow: pantheon wake allow ${who}`));
4853
+ }
4810
4854
  }
4811
4855
  const mode = wakeMode(loadProfile(teams[0]));
4812
4856
  console.log(`\n ${D("setting")} ${mode === "approved" ? "only the people listed above" : mode === "anyone" ? "anyone the team lets wake workers (the list is kept for if you choose \"approved\")" : "nobody — this machine is set not to be woken"}${D(" (pantheon setup to change)")}`);
@@ -5006,7 +5050,9 @@ async function main() {
5006
5050
  const cs = commandState({ project: resolve(".") });
5007
5051
  const { commandCaveat } = await import("./command-state.js");
5008
5052
  const caveat = cs.level !== "off" ? commandCaveat() : "";
5009
- console.log(` run-commands ${rc ? C(rc.mode === "always" ? "granted" : "granted once") : D("not granted")}${rc ? D(` (${rc.by}, ${new Date(rc.at).toLocaleDateString()})`) : cs.allowBash ? D(" — not needed: the worker runs with --allow-bash") : D(" — woken runs edit files only; it asks when a run needed more")}`);
5053
+ console.log(` run-commands ${rc ? C(rc.mode === "always" ? "granted" : "granted once") : D("not granted")}${rc ? D(` (${rc.by}, ${new Date(rc.at).toLocaleDateString()})`) : cs.allowBash ? D(" — not needed: the worker runs with --allow-bash")
5054
+ : p.denied.run_commands !== undefined && p.finalNo?.includes("cap:run_commands") ? D(` — you said no on ${new Date(p.denied.run_commands).toLocaleDateString()}; it won't ask again. To allow: pantheon policy grant run-commands`)
5055
+ : D(" — woken runs edit files only; it asks when a run needed more")}`);
5010
5056
  const ur = p.grants.unsandboxed_runs;
5011
5057
  const { unsandboxedAllowed } = await import("./worker-policy.js");
5012
5058
  console.log(` unsandboxed ${unsandboxedAllowed(p)
@@ -5378,7 +5424,7 @@ async function main() {
5378
5424
  if (!cmd)
5379
5425
  continue;
5380
5426
  console.error(D(`\n$ ${cmd}`));
5381
- const r = spawnSync("sh", ["-lc", cmd], { cwd: dir, stdio: "inherit" });
5427
+ const r = spawnSync("sh", ["-lc", cmd], { cwd: dir, stdio: "inherit", env: (await import("./which.js")).loginShellEnv() });
5382
5428
  if (r.status !== 0) {
5383
5429
  console.error(`\n${B("stopped")} — "${cmd}" exited ${r.status}. The rest is yours.`);
5384
5430
  return;
@@ -5394,9 +5440,15 @@ async function main() {
5394
5440
  if (hud?.action === "reply") {
5395
5441
  const notSent = (why) => { console.log(`not sent: ${why.split("\n")[0]}`); process.exit(1); };
5396
5442
  const kind = hud.kind ?? "NOTE";
5397
- const body = (hud.body ?? "").trim();
5443
+ let body = (hud.body ?? "").trim();
5398
5444
  if (!body)
5399
5445
  notSent("nothing to send");
5446
+ {
5447
+ const { refuseOutbound } = await import("./outbound-guard.js");
5448
+ const leak = refuseOutbound(cfg, { body });
5449
+ if (leak)
5450
+ notSent(leak.replace(/^pantheon: NOT sent — /, ""));
5451
+ }
5400
5452
  const c2 = new PantheonClient(cfg, undefined, { role: "cli" });
5401
5453
  await c2.connect().catch((e) => notSent(connectFailure(e, cfg.relay)));
5402
5454
  const o = hud.decision ? c2.obligations.find((x) => x.id === hud.decision) : undefined;
@@ -5407,23 +5459,31 @@ async function main() {
5407
5459
  c2.close();
5408
5460
  notSent("that decision is no longer waiting — nothing to answer");
5409
5461
  }
5410
- if (goal && c2.goals.get(goal)?.state === "CLOSED") {
5411
- if (kind === "ASK") {
5412
- c2.close();
5413
- notSent("that goal is closed — open a new one to ask more");
5414
- }
5462
+ if (goal && c2.goals.get(goal)?.state === "CLOSED")
5415
5463
  goal = null;
5416
- }
5417
- const ref = kind === "ANSWER" ? (o?.ref ?? target?.id ?? null) : kind === "ASK" ? (target?.id ?? null) : null;
5418
5464
  const to = kind === "ASK" ? (target && target.from !== cfg.member ? [target.from] : null) : null;
5419
5465
  if (kind === "ASK" && !to) {
5420
5466
  c2.close();
5421
- notSent("cannot tell who raised this — use Show the thread and reply from there");
5467
+ notSent("can't tell who raised this — use Show the thread and reply from there");
5468
+ }
5469
+ let ownThread = false;
5470
+ if (kind === "ASK" && !goal && to) {
5471
+ const { questionTitle } = await import("./worklist.js");
5472
+ const g = await c2.openGoal({ title: questionTitle(body), acceptance: `${to.join(", ")} answers`, invite: to })
5473
+ .catch((e) => notSent(plainError(e.message)));
5474
+ goal = g.id;
5475
+ ownThread = true;
5476
+ const about = target?.summary ?? target?.body.split("\n")[0] ?? o?.body;
5477
+ if (about) {
5478
+ const { decisionTitle } = await import("./decision-ui.js");
5479
+ body = `About "${decisionTitle(about, 120)}": ${body}`;
5480
+ }
5422
5481
  }
5482
+ const ref = kind === "ANSWER" ? (o?.ref ?? target?.id ?? null) : kind === "ASK" && !ownThread ? (target?.id ?? null) : null;
5423
5483
  const summary = body.length > LIMITS.summaryRequiredOver
5424
5484
  ? (body.split(/\n|(?<=[.!?])\s/)[0] ?? body).trim().slice(0, LIMITS.summaryChars) : undefined;
5425
5485
  const sent = await c2.send({ act: kind, body, goal, ref, to, after_seq: c2.readSeq, meta: { surface: "menubar" }, ...(summary ? { summary } : {}) })
5426
- .catch((e) => notSent(e.message));
5486
+ .catch((e) => notSent(plainError(e.message)));
5427
5487
  c2.close();
5428
5488
  console.log(`sent ${kind} id=${sent.id} seq=${sent.seq}`);
5429
5489
  if (kind === "ANSWER") {
@@ -5441,7 +5501,7 @@ async function main() {
5441
5501
  const c2 = new PantheonClient(cfg, undefined, { role: "cli" });
5442
5502
  await c2.connect().catch((e) => notSent(connectFailure(e, cfg.relay)));
5443
5503
  const sent = await c2.send({ act: "RETRACT", body: "Retracted from the menu bar.", goal: null, ref: hud.act, to: null, meta: { surface: "menubar" } })
5444
- .catch((e) => notSent(e.message));
5504
+ .catch((e) => notSent(plainError(e.message)));
5445
5505
  c2.close();
5446
5506
  console.log(`sent RETRACT id=${sent.id} seq=${sent.seq}`);
5447
5507
  return;
@@ -5463,7 +5523,7 @@ async function main() {
5463
5523
  if (![cfg.spaceId, cfg.space].includes(wa.team))
5464
5524
  notSent(`that question is about the team "${wa.team}", not "${hud.space ?? cfg.space}" — answer it from that team's board`);
5465
5525
  const allow = hud.allow === true;
5466
- const r = setLocalWaker(allow ? [wa.team] : [wa.team, cfg.spaceId, cfg.space], wa.member, allow);
5526
+ const r = setLocalWaker(allow ? [wa.team] : [wa.team, cfg.spaceId, cfg.space], wa.member, allow, undefined, process.env, { no: !allow });
5467
5527
  if (!r.ok)
5468
5528
  notSent(r.why);
5469
5529
  if (allow && wa.teamBlocked)
@@ -5493,27 +5553,35 @@ async function main() {
5493
5553
  const tries = hud.space ? [cfg] : (() => { const f = loadAll(); const all = f ? Object.values(f.spaces ?? {}).map((m) => configFor(f, m, null)) : []; return all.length ? all : [cfg]; })();
5494
5554
  let c2 = null;
5495
5555
  let o;
5556
+ const unreached = [];
5557
+ let doneCfg = cfg;
5496
5558
  for (const tc of tries) {
5497
5559
  const c = new PantheonClient(tc, undefined, { role: "cli" });
5498
5560
  const ok = await c.connect().then(() => true, (e) => { if (tries.length === 1)
5499
- die(connectFailure(e, tc.relay)); return false; });
5561
+ die(connectFailure(e, tc.relay)); if (!refusalOf(e))
5562
+ unreached.push(tc.space); return false; });
5500
5563
  const hit = ok && hud.decision ? c.obligations.find((x) => x.id === hud.decision) : undefined;
5501
5564
  if (hit) {
5502
5565
  c2 = c;
5503
5566
  o = hit;
5567
+ doneCfg = tc;
5504
5568
  break;
5505
5569
  }
5506
5570
  c.close();
5507
5571
  }
5572
+ if ((!c2 || !o) && unreached.length) {
5573
+ console.log(`not sent: couldn't reach ${unreached.join(", ")} to mark it done — try again in a moment`);
5574
+ process.exit(1);
5575
+ }
5508
5576
  if (!c2 || !o) {
5509
5577
  console.error(D("that decision is no longer waiting on you"));
5510
5578
  return;
5511
5579
  }
5512
5580
  const open = o.goal && c2.goals.get(o.goal)?.state !== "CLOSED" ? o.goal : null;
5513
- const doneBody = "Marked done from the alert — handled outside this thread.";
5581
+ const doneBody = `${doneCfg.member} marked this handled — dealt with outside Pantheon.`;
5514
5582
  await c2.send({ act: "ANSWER", ref: o.ref, goal: open, after_seq: c2.readSeq, body: doneBody }).catch((e) => die(e.message));
5515
5583
  c2.close();
5516
- console.error(D(`done — ${o.id} is no longer waiting on you`));
5584
+ console.error(D(`done — that decision is no longer waiting on you`));
5517
5585
  return;
5518
5586
  }
5519
5587
  if (hud?.action === "details") {
@@ -5651,6 +5719,14 @@ async function main() {
5651
5719
  console.error(D(" nothing sent"));
5652
5720
  continue;
5653
5721
  }
5722
+ {
5723
+ const { refuseOutbound } = await import("./outbound-guard.js");
5724
+ const leak = refuseOutbound(cfg, { reply: text });
5725
+ if (leak) {
5726
+ console.error(` ${leak.replace(/^pantheon: /, "")}`);
5727
+ continue;
5728
+ }
5729
+ }
5654
5730
  const c3 = new PantheonClient(cfg, undefined, { role: "cli" });
5655
5731
  try {
5656
5732
  await c3.connect();
@@ -5845,18 +5921,50 @@ async function main() {
5845
5921
  }
5846
5922
  const closeAll = () => { for (const c of conns)
5847
5923
  c.client.close(); };
5848
- const all = conns.flatMap(({ cfg, client }) => client.obligations.filter((o) => o.kind === "HUMAN" && o.owner === `human:${cfg.member}`).map((o) => ({ o, cfg, client })));
5849
- const find = (want) => all.find((x) => x.o.id === want) ?? all.find((x) => x.o.ref === want);
5924
+ const all = conns.flatMap(({ cfg, client }) => client.obligations.filter((o) => o.kind === "HUMAN" && o.owner === `human:${cfg.member}`).map((o) => ({ o, cfg, client })))
5925
+ .sort((a, b) => a.o.created_at - b.o.created_at);
5926
+ const lastFile = join(CONFIG_DIR, "approvals-last.json");
5927
+ const lastIds = () => { try {
5928
+ const j = JSON.parse(readFileSync(lastFile, "utf8"));
5929
+ return Array.isArray(j.ids) ? j.ids.filter((x) => typeof x === "string") : [];
5930
+ }
5931
+ catch {
5932
+ return [];
5933
+ } };
5934
+ const isNumber = (want) => /^\d{1,3}$/.test(want);
5935
+ const find = (want) => isNumber(want)
5936
+ ? (() => { const id = lastIds()[Number(want) - 1]; return id ? all.find((x) => x.o.id === id) : undefined; })()
5937
+ : all.find((x) => x.o.id === want) ?? all.find((x) => x.o.ref === want);
5938
+ const notWaiting = (want) => {
5939
+ const open = `run pantheon approvals to see the open ones${all.length ? ` (${all.length} now)` : " (none now)"}`;
5940
+ if (isNumber(want)) {
5941
+ return lastIds()[Number(want) - 1]
5942
+ ? `Decision ${want} from your last list is no longer waiting on you — it was answered or withdrawn. What to do: ${open}.`
5943
+ : `There is no decision ${want} in your last list. What to do: ${open}.`;
5944
+ }
5945
+ return `No decision ${want} is waiting on you${conns.length > 1 ? ` in any of your ${conns.length} teams` : ""}. What to do: ${open}.`;
5946
+ };
5850
5947
  if (sub === "answer") {
5851
5948
  if (!id)
5852
- die("usage: pantheon approvals answer <obligation-id> <decision> [--summary 'one line']");
5853
- const hit = find(id) ?? die(`no decision ${id} is waiting on you${conns.length > 1 ? ` in any of your ${conns.length} teams` : ""}`);
5949
+ die("usage: pantheon approvals answer <number> \"your answer\" [--summary 'one line'] (the number from pantheon approvals)");
5950
+ const hit = find(id) ?? die(notWaiting(id));
5854
5951
  const stopAt = argv.findIndex((a, i) => i >= 3 && a.startsWith("--"));
5855
- const answer = argv.slice(3, stopAt === -1 ? undefined : stopAt).join(" ").trim() || die("state the decision; it will be written to the audit ledger");
5952
+ const answer = argv.slice(3, stopAt === -1 ? undefined : stopAt).join(" ").trim() || die(`your answer goes after the number, e.g. pantheon approvals answer ${id} "yes, go ahead"`);
5856
5953
  const summary = flag("summary");
5954
+ {
5955
+ const { refuseOutbound } = await import("./outbound-guard.js");
5956
+ const leak = refuseOutbound(hit.cfg, { answer, summary });
5957
+ if (leak) {
5958
+ closeAll();
5959
+ die(leak.replace(/^pantheon: /, ""));
5960
+ }
5961
+ }
5857
5962
  const sent = await hit.client.send({ act: "ANSWER", body: answer, goal: null, ref: hit.o.ref, after_seq: hit.client.readSeq, ...(summary ? { summary } : {}) })
5858
5963
  .catch((e) => { closeAll(); return die(/SUMMARY_REQUIRED/.test(e.message) ? `${e.message}\n Add one: --summary 'the point they must not miss'` : e.message); });
5859
- console.log(`${C("answered")} ${id}${conns.length > 1 ? ` in ${B(hit.cfg.space)}` : ""} — ledger act ${sent.id}`);
5964
+ const asker = hit.client.seenAct(hit.o.ref)?.from;
5965
+ const { decisionTitle } = await import("./decision-ui.js");
5966
+ console.log(`${C("answered")}${conns.length > 1 ? ` in ${B(hit.cfg.space)}` : ""}: ${decisionTitle(hit.o.body, 90)}` +
5967
+ `${asker ? (asker === hit.cfg.member ? " — your agent is told" : ` — ${asker} is told`) : ""} ${D(sent.id)}`);
5860
5968
  const { applyLocalAnswer, describeLocalAnswer } = await import("./worker-policy.js");
5861
5969
  const g = applyLocalAnswer(hit.o.ref, answer);
5862
5970
  if (g)
@@ -5866,11 +5974,11 @@ async function main() {
5866
5974
  }
5867
5975
  if (sub === "show") {
5868
5976
  if (!id)
5869
- die("usage: pantheon approvals show <obligation-id>");
5870
- const hit = find(id) ?? die(`no decision ${id} is waiting on you`);
5871
- console.log(`${B("Decision required")} ${hit.o.id}${conns.length > 1 ? ` ${D("in " + hit.cfg.space)}` : ""}`);
5977
+ die("usage: pantheon approvals show <number> (the number from pantheon approvals)");
5978
+ const hit = find(id) ?? die(notWaiting(id));
5979
+ console.log(`${B("Your decision")}${conns.length > 1 ? ` ${D("in " + hit.cfg.space)}` : ""} ${D(hit.o.id)}`);
5872
5980
  const full = hit.client.seenAct(hit.o.ref) ?? (await fetchAct(hit.cfg, hit.o.ref, 4000).catch(() => null))?.act;
5873
- console.log(` ${hit.o.body}`);
5981
+ console.log(` ${plainRequest(hit.o.body, hit.cfg.member)}`);
5874
5982
  if (full?.body && full.body.trim() !== hit.o.body.trim())
5875
5983
  console.log(`\n${full.body.split("\n").map((l) => ` ${l}`).join("\n")}`);
5876
5984
  if (hit.o.goal)
@@ -5882,20 +5990,30 @@ async function main() {
5882
5990
  for (const c of choices)
5883
5991
  console.log(` ${c.label.padEnd(16)} ${C(`pantheon approvals answer ${hit.o.id} ${c.answer}`)}`);
5884
5992
  }
5885
- else
5886
- console.log(`\nAnswer: ${C(`pantheon approvals answer ${hit.o.id} 'your decision and rationale'`)}`);
5993
+ else {
5994
+ const n = lastIds().indexOf(hit.o.id) + 1;
5995
+ console.log(`\nAnswer: ${C(`pantheon approvals answer ${n > 0 ? n : hit.o.id} "your answer"`)}`);
5996
+ }
5887
5997
  closeAll();
5888
5998
  return;
5889
5999
  }
5890
6000
  if (sub !== "list")
5891
- die("usage: pantheon approvals [list | show <id> | answer <id> <decision>]");
6001
+ die("usage: pantheon approvals [list | show <number> | answer <number> \"your answer\"]");
5892
6002
  if (!all.length)
5893
6003
  console.log(D(conns.length > 1 ? `no decisions waiting on you in any of your ${conns.length} teams` : "no decisions waiting on you"));
5894
6004
  const { localChoices: lc } = await import("./tray.js");
5895
- for (const { o, cfg, client } of all) {
6005
+ for (const [i, { o, cfg, client }] of all.entries()) {
5896
6006
  const ch = lc(o.ref);
5897
- console.log(`${C(o.id)} ${conns.length > 1 ? D(`[${cfg.space}] `) : ""}${client.goals.get(o.goal ?? "")?.title ?? (ch ? "This machine" : "No goal")}\n ${o.body}${ch ? D(`\n answer: ${ch.map((c) => c.answer).join(" / ")} (pantheon approvals show ${o.id})`) : ""}`);
6007
+ const where = client.goals.get(o.goal ?? "")?.title ?? (ch ? "this computer" : "");
6008
+ console.log(`${B(`${i + 1}.`)} ${plainRequest(o.body, cfg.member)}\n ${D([conns.length > 1 ? cfg.space : "", where ? `in "${where}"` : "", o.id].filter(Boolean).join(" · "))}` +
6009
+ `${ch ? `\n answer: ${ch.map((c) => c.answer).join(" / ")}` : ""}`);
5898
6010
  }
6011
+ if (all.length)
6012
+ console.log(D(`\n read one in full: pantheon approvals show <number> · answer: pantheon approvals answer <number> "your answer"`));
6013
+ try {
6014
+ writeFileSync(lastFile, JSON.stringify({ at: Date.now(), ids: all.map((x) => x.o.id) }) + "\n", { mode: 0o600 });
6015
+ }
6016
+ catch { }
5899
6017
  closeAll();
5900
6018
  return;
5901
6019
  }
package/dist/client.js CHANGED
@@ -2,8 +2,8 @@ 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 { markContinued } from "./continued.js";
6
- import { markAnswered, nonceOf } from "./nonces.js";
5
+ import { loadContinued, markContinued, unmarkContinued } from "./continued.js";
6
+ import { isAnsweredId, markAnswered, nonceOf, unmarkAnswered } from "./nonces.js";
7
7
  import { signedRead } from "./reads.js";
8
8
  import { repoName } from "./repo-route.js";
9
9
  import { signChallenge, signBytes, actPayload, goalPayload, newActId, newActNonce, canonicalJson } from "./identity.js";
@@ -13,6 +13,12 @@ import { trusted, verifyAct, verifyGoal, vouchedMove } from "./verify-act.js";
13
13
  import { newId, UPKEEP_AGENT } from "./protocol.js";
14
14
  import { VERSION } from "./version.js";
15
15
  import { describeNetError, explainNetError, noteRelayAnswered, settleSystemFallback, systemFallbackPending, trySystemFallback, wsOptions } from "./network.js";
16
+ const REFUSED_BEFORE_STORING = new Set([
17
+ "SUMMARY_REQUIRED", "STALE_VIEW", "RATE_LIMIT", "PEER_TURN", "BUDGET_SPENT", "GOAL_CLOSED", "GOAL_REQUIRED",
18
+ "NOT_IN_GOAL", "NO_SUCH_GOAL", "NO_SUCH_MEMBER", "TO_REQUIRED", "BAD_REF", "REF_REQUIRED", "REF_OTHER_GOAL",
19
+ "BAD_MESSAGE", "BAD_META", "META_TOO_LARGE", "BAD_ACT_SIGNATURE", "SIGNED_ONLY", "UNVERIFIABLE_DELIVERY",
20
+ "REPO_REQUIRED", "REPO_MISMATCH", "NOT_ADMITTED", "NOTHING_OWED", "NOT_FOR_A_RUN", "BAD_BRANCH", "BAD_COMMIT", "BAD_BASE", "BAD_REMOTE",
21
+ ]);
16
22
  export class PantheonClient {
17
23
  cfg;
18
24
  onEvent;
@@ -637,7 +643,7 @@ export class PantheonClient {
637
643
  this.acks.set(cid, (v) => {
638
644
  clearTimeout(timer);
639
645
  if ("error" in v)
640
- reject(new Error(v.error));
646
+ reject(Object.assign(new Error(v.error), { refused: true }));
641
647
  else
642
648
  resolve(v);
643
649
  });
@@ -681,7 +687,18 @@ export class PantheonClient {
681
687
  async postAct(p) {
682
688
  const { t: _t, id, sig: _s, repo: _r, ...a } = p;
683
689
  let unrecorded = false, unsignedRef = false;
690
+ let marked = null;
684
691
  if (a.ref && this.ws?.readyState === WebSocket.OPEN && (a.act === "ANSWER" || a.act === "ACCEPT" || a.act === "OBJECT" || a.act === "DELIVERED")) {
692
+ let hadHandled = true, hadAnswered = true;
693
+ try {
694
+ hadHandled = loadContinued(this.pinTeam).has(`handled:${a.ref}`);
695
+ }
696
+ catch { }
697
+ try {
698
+ hadAnswered = isAnsweredId(this.pinTeam, a.ref);
699
+ }
700
+ catch { }
701
+ marked = { handled: !hadHandled, answered: !hadAnswered };
685
702
  try {
686
703
  markContinued(this.pinTeam, `handled:${a.ref}`);
687
704
  }
@@ -690,7 +707,27 @@ export class PantheonClient {
690
707
  unrecorded = noted === false && this.signaturesExpected();
691
708
  unsignedRef = noted === "unsigned";
692
709
  }
693
- const r = await this.rpc(p);
710
+ let r;
711
+ try {
712
+ r = await this.rpc(p);
713
+ }
714
+ catch (e) {
715
+ if (marked && a.ref && e.refused && REFUSED_BEFORE_STORING.has(/^([A-Z_]+):/.exec(e.message)?.[1] ?? "")) {
716
+ if (marked.handled) {
717
+ try {
718
+ unmarkContinued(this.pinTeam, `handled:${a.ref}`);
719
+ }
720
+ catch { }
721
+ }
722
+ if (marked.answered) {
723
+ try {
724
+ unmarkAnswered(this.pinTeam, a.ref);
725
+ }
726
+ catch { }
727
+ }
728
+ }
729
+ throw e;
730
+ }
694
731
  let sentId = r.id === id ? id : null;
695
732
  if (r.id !== id && this.features.includes("act-sig")) {
696
733
  let prior = this.seen.get(r.id) ?? null;
@@ -1,3 +1,4 @@
1
+ import { clipWords } from "./plain.js";
1
2
  const oneLine = (value) => value.replace(/\s+/g, " ").trim();
2
3
  export function namedMarker(from, meta, passed) {
3
4
  if (meta?.authority !== "named")
@@ -12,7 +13,7 @@ export function namedMarkerIn(text) {
12
13
  const LAYERS = [
13
14
  /^([a-z0-9._-]+)\s+escalated\s*:\s*/i,
14
15
  /^([a-z0-9._-]+)\s+needs? a decision\s*:\s*/i,
15
- /^([a-z0-9._-]+)\s+(?:asked|asks|said|says|wrote|reported)\s*:\s*/i,
16
+ /^([a-z0-9._-]+)\s+(?:asked|asks|said|says|wrote|reported|proposed|objected)\s*:\s*/i,
16
17
  /^([a-z0-9._-]+)\s+is\s+(?:asking|saying|reporting)(?:\s+that)?\s*:\s*/i,
17
18
  /^decision (?:for|required for|needed from)\s+(?:you|[a-z0-9._-]+)\s*(?:\([^)]*\))?\s*[:—-]\s*/i,
18
19
  /^(?:action|input|answer|decision)\s+(?:required|needed)\s*(?:\([^)]*\))?\s*(?:from|for)?\s*(?:you|[a-z0-9._-]+)?\s*[:—-]\s*/i,
@@ -42,6 +43,8 @@ export function decisionTitle(body, max = 96) {
42
43
  let text = stripCeremony(body).text
43
44
  .replace(/\(\s*goal\s+g_[a-z0-9]+\s*,\s*/gi, "(")
44
45
  .replace(/\s*\b(?:of|in|for|on|from)?\s*\(?\bgoal\s+g_[a-z0-9]+\)?/gi, "")
46
+ .replace(/\s+—\s+ACCEPT or OBJECT$/i, "")
47
+ .replace(/^"(.+)" spent its act budget without closing$/, '"$1" reached its message limit — let it continue, or close it')
45
48
  .replace(/\s{2,}/g, " ")
46
49
  .trim();
47
50
  const blockedAsk = text.match(/^cannot answer (.+?)\s+ask\s*:/i);
@@ -56,7 +59,7 @@ export function decisionTitle(body, max = 96) {
56
59
  if (!text)
57
60
  text = "Review this decision";
58
61
  text = text[0].toUpperCase() + text.slice(1);
59
- return text.length <= max ? text : `${text.slice(0, max - 1).trimEnd()}…`;
62
+ return clipWords(text, max);
60
63
  }
61
64
  export function decisionPrompt(id, title) {
62
65
  const head = title?.trim() ? `Pantheon decision: ${title.trim()}
package/dist/doctor.js CHANGED
@@ -17,7 +17,7 @@ import { PKG_NAME } from "./upgrade.js";
17
17
  import { PantheonClient } from "./client.js";
18
18
  import { load, resolveFor, loadAll, configFor, CONFIG_PATH } from "./config.js";
19
19
  import { fingerprint, signChallenge, verifyChallenge } from "./identity.js";
20
- import { approvalSummary, chosenApproval, copilotMcpConfigFile, kiroMcpConfigFile, onPath } from "./install.js";
20
+ import { approvalSummary, briefState, chosenApproval, copilotMcpConfigFile, kiroMcpConfigFile, onPath } from "./install.js";
21
21
  import { hookState, readIntent, agentHookStates, repairNote } from "./notify.js";
22
22
  import { loadPersonas, olderTeammatesNote } from "./persona.js";
23
23
  import { workerProc, menubarProc, notifierProc, workerFlagRunMinutes } from "./machine.js";
@@ -276,6 +276,9 @@ export async function doctor(projectDir) {
276
276
  }
277
277
  add("warn", "removed", `${w.by ? `${w.by} removed you` : "you were removed"} from "${w.name}" (${new Date(record.at).toISOString().slice(0, 10)}) — this machine stopped connecting to it and checks now and then (at most every 6 hours)`, `to come back, you need a new invite from someone in "${w.name}" (pantheon join <invite>) or for a member to let you back in (pantheon admit ${w.member}); to forget it here: ${w.leave}`, "removed from a team");
278
278
  }
279
+ if (here.reason === "binding" && here.cfg && briefState(here.repo?.root ?? projectDir, here.cfg) === "older") {
280
+ add("warn", "team brief", "the Pantheon section in this repo's CLAUDE.md / AGENTS.md is from an older version", "pantheon install (here; it rewrites that section only — commit it so teammates get it too)", "team brief older");
281
+ }
279
282
  if (here.repo && !here.repo.shared)
280
283
  add("warn", "team", "this repo has no origin remote", "DELIVERED must name a commit a teammate can fetch; add a remote before delivering", "repo has no origin remote");
281
284
  const nonce = "doctor-selftest";
@@ -408,13 +411,17 @@ export async function doctor(projectDir) {
408
411
  add("warn", "worker agent", e.message, "pantheon setup --agent <claude-code|codex|cursor|copilot|kiro> names one that is installed", "could not be chosen");
409
412
  }
410
413
  try {
411
- const { signedOutNow, SIGNED_OUT_AGENTS } = await import("./signed-out.js");
414
+ const { signedOutNow, signedOutChecking, SIGNED_OUT_AGENTS } = await import("./signed-out.js");
412
415
  const { SIGN_IN_FIX } = await import("./run-failure.js");
413
416
  const { claudeTokenForRun } = await import("./agent-token.js");
414
417
  for (const id of SIGNED_OUT_AGENTS) {
415
418
  const m = signedOutNow(id);
416
- if (!m)
419
+ if (!m) {
420
+ const c = signedOutChecking(id);
421
+ if (c)
422
+ add("pass", "worker agent", `${agentById(id)?.label ?? id} was found signed out ("${c.says}"); the worker tries it again with the next request`, undefined, `${agentById(id)?.label ?? id} being re-checked`);
417
423
  continue;
424
+ }
418
425
  const label = agentById(id)?.label ?? id;
419
426
  const token = id === "claude-code" && !!claudeTokenForRun(undefined, {});
420
427
  add("warn", "worker agent", `a run here at ${new Date(m.at).toISOString().slice(0, 16).replace("T", " ")} UTC found ${label} ${token ? "refusing the saved worker token" : "signed out"} ("${m.says}"), so teammates' requests wait`, token ? "make a new token (claude setup-token, then pantheon worker token), or remove it to use your own sign-in: pantheon worker token --remove"
@@ -710,8 +717,11 @@ export async function doctor(projectDir) {
710
717
  const caveat = cs.level !== "off" ? commandCaveat() : "";
711
718
  if (caveat)
712
719
  add("warn", "commands", `woken runs: ${cs.summary} — ${caveat}`, undefined, "how woken runs here use commands");
713
- else
714
- add("pass", "commands", `woken runs: ${cs.summary}`, undefined, cs.level === "off" ? "woken runs edit files only" : `woken runs may run commands (${cs.allowBash ? "--allow-bash" : "granted here"})`);
720
+ else {
721
+ const pol = cs.level === "off" ? loadPolicy() : undefined;
722
+ const saidNo = pol?.finalNo?.includes("cap:run_commands") ? pol.denied.run_commands : undefined;
723
+ add("pass", "commands", `woken runs: ${cs.summary}${saidNo !== undefined ? ` — you said no on ${new Date(saidNo).toLocaleDateString()}, so it won't ask again` : ""}`, saidNo !== undefined ? "to allow it: pantheon policy grant run-commands" : undefined, cs.level === "off" ? "woken runs edit files only" : `woken runs may run commands (${cs.allowBash ? "--allow-bash" : "granted here"})`);
724
+ }
715
725
  }
716
726
  {
717
727
  const { loadPolicy, effectiveRunMinutes, describeRunMinutes, effectiveIdleSeconds, describeIdleSeconds, effectiveMode, MODE_LABELS } = await import("./worker-policy.js");