@join-pantheon/cli 0.35.1-rc.3 → 0.35.2-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/README.md CHANGED
@@ -485,7 +485,7 @@ spelled in its own dialect:
485
485
 
486
486
  | backend | bash gated (`--commands no`) | with commands (setup's default in a repo, `run-commands` or `--allow-bash`) |
487
487
  |---|---|---|
488
- | claude-code | `acceptEdits`, no shell, reads held to the worktree, `~/.ssh` `~/.aws` `~/.config/gh` `~/.pantheon` and similar denied; the repo's own `.claude` settings never load (`--setting-sources user`) | the same file rules, plus Claude Code's OS sandbox (macOS/Linux): commands may write only the worktree, its git data and temp dirs, may not read the secret paths, and a run whose sandbox cannot start does not start. Commands: git subcommands (with its run-a-program options denied), the repo's scripts via npm/pnpm/yarn/bun, make, cargo, go, pytest, mvn/gradle, dotnet, plus the committed `.pantheon/commands` on the base branch (one per line; shells, wrappers, package runners like `npx`, and inline code are refused — use `./node_modules/.bin/vitest`). The run names any command it needed that was refused. On Windows, or a Claude Code older than 2.1.83, commands run from that same list without the OS sandbox (`pantheon setup --unsandboxed no` keeps those runs to edits) |
488
+ | claude-code | `acceptEdits`, no shell, reads held to the worktree, `~/.ssh` `~/.aws` `~/.config/gh` `~/.pantheon` and similar denied; the repo's own `.claude` settings never load (`--setting-sources user`) | the same file rules, plus Claude Code's OS sandbox (macOS/Linux): commands may write only the worktree, its git data and temp dirs, may not read the secret paths, and a run whose sandbox cannot start does not start. Commands: git subcommands (with its run-a-program options denied), the repo's scripts via npm/pnpm/yarn/bun, make, cargo, go, pytest, mvn/gradle, dotnet, flutter build/test/analyze/pub get, dart test/analyze/pub get, plus the committed `.pantheon/commands` on the base branch (one per line; shells, wrappers, package runners like `npx`, and inline code are refused — use `./node_modules/.bin/vitest`). The run names any command it needed that was refused. On Windows, or a Claude Code older than 2.1.83, commands run from that same list without the OS sandbox (`pantheon setup --unsandboxed no` keeps those runs to edits) |
489
489
  | codex | `--sandbox read-only` (codex has no edits-without-shell mode; reads are not restricted) | `--approve-for-me` (Codex's workspace-write sandbox, its auto-reviewer approves; any command) |
490
490
  | cursor | proposes edits, never applies (`-p` without `--force`) | `--force` (any command, no allowlist, no sandbox) |
491
491
  | copilot | `--allow-tool=pantheon-worker --allow-tool=write` (edits without shell, Copilot's `write` kind) | `--allow-all-tools` (any command, no allowlist, no sandbox) |
@@ -1,6 +1,7 @@
1
1
  import { ACT_KEY, MARK, SEAL, actChip, actWords, cap, esc, head, longDay, pct, plural, rangeSeg, rangeWords, script, secbar, spark, split, stackedColumns, when } from "./admin-ui.js";
2
2
  import { FOUNDER_CSS, definitionsSection, founderSections } from "./admin-founder.js";
3
3
  import { GOAL_CSS, goalDiagram, goalSummary } from "./goal-flow.js";
4
+ import { carriedSection, handoffsRow } from "./flow-visuals.js";
4
5
  import { dur, median, refusalWords } from "./flow-stats.js";
5
6
  export function stateNoteHtml(n, viewer = false) {
6
7
  if (!n)
@@ -121,7 +122,10 @@ export function needsALook(d) {
121
122
  const m = owed.t.members.find((x) => x.name === owed.o.owner);
122
123
  const who = esc(cap(owed.o.owner));
123
124
  const seen = m?.online ? `${who} is online` : m?.lastSeen ? `${who} was last seen ${when(m.lastSeen, "full")}${m.build ? ` on ${esc(m.build)}` : ""}` : `${who} has not been seen`;
124
- const wk = !m?.worker ? "No worker is connected, so nothing picks this up until they open a session." : m.worker.state === "unavailable" ? `Their worker can't take it: ${esc(workerWords(m.worker.reason))}.` : `Their worker says it is ${esc(m.worker.state)}.`;
125
+ const asker = owed.o.from ? owed.t.members.find((x) => x.name === owed.o.from) : undefined;
126
+ const wk = owed.o.handedBackAt ? `Their agent handed it back to them to decide (${when(owed.o.handedBackAt, "time")}), so it waits on them.`
127
+ : asker && !asker.mayWake ? `The team does not let ${esc(cap(asker.name))} start work on workers, so it waits for them in person.`
128
+ : !m?.worker ? "No worker is connected, so nothing picks this up until they open a session." : m.worker.state === "unavailable" ? `Their worker can't take it: ${esc(workerWords(m.worker.reason))}.` : `Their worker says it is ${esc(m.worker.state)}.`;
125
129
  out.push({ rank: 0, ic: "!", html: `<b>${who} has owed ${esc(cap(owed.o.from ?? "someone"))} ${owed.o.kind === "answer" ? "an answer" : `a ${owed.o.kind}`} for ${dur(owed.o.ageMs)}</b> in ${teamLink(owed.t.name)}.`, sub: `${seen}. ${wk}` });
126
130
  }
127
131
  const dec = d.teams.flatMap((t) => t.flow.waiting.map((o) => ({ t, o }))).sort((a, b) => b.o.ageMs - a.o.ageMs);
@@ -546,7 +550,7 @@ export function inlineReadScript(nonce) {
546
550
  </script>`;
547
551
  }
548
552
  const KIND_LABEL = { answer: "Answer", accept: "Accept", revise: "Revise", decision: "Decision", deliver: "Deliver" };
549
- export function rightNow(o, m, now) {
553
+ export function rightNow(o, m, now, asker) {
550
554
  void now;
551
555
  const who = esc(cap(o.owner));
552
556
  const seen = (m?.lastSeen ? `; last seen ${when(m.lastSeen, "time")}` : "");
@@ -554,8 +558,13 @@ export function rightNow(o, m, now) {
554
558
  return o.claimed.by === "worker" ? `${who}'s worker is working on it now (started ${when(o.claimed.at, "time")})` : `Claimed by ${who}'s agent window ${when(o.claimed.at, "time")}`;
555
559
  if (!m)
556
560
  return `${who} is not on this team any more`;
561
+ const where = m.online ? `${who} is online${m.windows ? "" : " in a worker only"}` : `${who} is offline${seen}`;
557
562
  if (o.human)
558
- return m.online ? `${who} is online${m.windows ? "" : " in a worker only"}` : `${who} is offline${seen}`;
563
+ return `Waits for ${who} to decide, since ${when(o.since, "time")}. ${where}`;
564
+ if (o.handedBackAt)
565
+ return `Handed back to ${who}: their agent asked them to decide about it ${when(o.handedBackAt, "time")}, and it waits on them. ${where}`;
566
+ if (asker && !asker.mayWake && o.from)
567
+ return `Waits for ${who} in person: the team does not let ${esc(cap(o.from))} start work on workers. ${where}`;
559
568
  if (m.worker?.state === "holding")
560
569
  return `${who}'s worker is holding: ${esc(workerWords(m.worker.reason) || "it says it will wait")}`;
561
570
  if (m.worker?.state === "unavailable")
@@ -623,6 +632,10 @@ export function renderTeamUnreadable(o) {
623
632
  </main>`,
624
633
  });
625
634
  }
635
+ function noReport(since) {
636
+ const why = "Hooks report which messages reached the agent. The relay keeps these reports in memory, so they start again when it restarts or wakes this team.";
637
+ return since ? `<span class="quiet" title="${esc(why)}">none reported since ${when(since, "time")}</span>` : `<span class="quiet" title="${esc(why)}">no report</span>`;
638
+ }
626
639
  export function renderTeam(d) {
627
640
  const f = d.flow, range = rangeWords(d.days);
628
641
  const enc = encodeURIComponent(d.name);
@@ -637,14 +650,13 @@ export function renderTeam(d) {
637
650
  <td class="span">${o.human ? `${SEAL} ` : ""}<span class="chip plain mono">${KIND_LABEL[o.kind]}</span> <b class="who">${esc(cap(o.owner))}</b> <span class="muted">${how}</span><span class="sub wrapc">${esc(d.gist(o.ref))}</span></td>
638
651
  <td data-l="Goal">${o.goalTitle ? esc(o.goalTitle) : `<span class="quiet">no goal</span>`}</td>
639
652
  <td data-l="Waiting" class="agewrap">${ageMeter(o.ageMs)}<span class="num">${dur(o.ageMs)}</span></td>
640
- <td data-l="Right now" class="span">${rightNow(o, memberOf.get(o.owner), d.now)}</td>
653
+ <td data-l="Right now" class="span">${rightNow(o, memberOf.get(o.owner), d.now, o.from ? memberOf.get(o.from) : undefined)}</td>
641
654
  </tr>`;
642
655
  }).join("");
643
- const carriedRows = f.carried.map((c) => `<tr><td class="span"><b class="who">${esc(cap(c.who))}</b><span class="sub">${esc(c.agent)}</span></td><td data-l="Asked" class="r num">${c.asked}</td><td data-l="Answered by">${split(c.byWorker, c.byPerson, c.asked, 110)}<span class="sub num">${c.byWorker} worker · ${c.byPerson} in person</span></td><td data-l="Median" class="r num">${c.medianMs !== null ? dur(c.medianMs) : `<span class="quiet">none</span>`}</td><td data-l="Open" class="r num">${c.open || `<span class="quiet">0</span>`}</td></tr>`).join("");
644
656
  const memberRows = d.members.map((m) => {
645
657
  const chips = [m.windows ? `<span class="chip plain">window · ${m.busy ? "busy" : m.busy === false ? "idle" : "open"}</span>` : "", m.worker ? `<span class="chip ${m.worker.state === "running" ? "" : m.worker.state === "unavailable" ? "line" : "plain"}">worker · ${esc(m.worker.state)}</span>` : ""].filter(Boolean).join(" ")
646
658
  || (m.online ? `<span class="chip plain">connected</span>` : `<span class="quiet">offline</span>`);
647
- return `<tr><td class="span"><b class="who">${esc(cap(m.name))}</b>${m.founder ? ` <span class="chip plain">founder</span>` : ""}${m.admitted ? "" : ` <span class="chip line">waiting to be admitted</span>`}<span class="sub">${esc(m.agent || "agent unknown")}${m.mayWake ? "" : " · may not wake workers"}</span></td><td data-l="Connected now" class="span">${chips}${m.worker?.state === "unavailable" || m.worker?.state === "holding" ? `<span class="sub">${esc(workerWords(m.worker.reason))}</span>` : ""}</td><td data-l="Build">${m.build ? `<span class="mono">${esc(m.build)}</span><span class="sub">${m.behind ? "missed the self-upgrade" : "current"}</span>` : `<span class="quiet">unknown</span>`}</td><td data-l="Last seen">${m.online ? "now" : when(m.lastSeen, "full")}</td><td data-l="Delivered, not yet seen" class="r num">${m.unseen === null ? `<span class="quiet">no hooks</span>` : m.unseen ? m.unseen : `<span class="quiet">0</span>`}</td></tr>`;
659
+ return `<tr><td class="span"><b class="who">${esc(cap(m.name))}</b>${m.founder ? ` <span class="chip plain">founder</span>` : ""}${m.admitted ? "" : ` <span class="chip line">waiting to be admitted</span>`}<span class="sub">${esc(m.agent || "agent unknown")}${m.mayWake ? "" : " · may not wake workers"}</span></td><td data-l="Connected now" class="span">${chips}${m.worker?.state === "unavailable" || m.worker?.state === "holding" ? `<span class="sub">${esc(workerWords(m.worker.reason))}</span>` : ""}</td><td data-l="Build">${m.build ? `<span class="mono">${esc(m.build)}</span><span class="sub">${m.behind ? "missed the self-upgrade" : "current"}</span>` : `<span class="quiet">unknown</span>`}</td><td data-l="Last seen">${m.online ? "now" : when(m.lastSeen, "full")}</td><td data-l="Delivered, not yet seen" class="r num">${m.unseen === null ? noReport(m.reportsSince) : m.unseen ? m.unseen : `<span class="quiet">0</span>`}</td></tr>`;
648
660
  }).join("");
649
661
  const goalRows = f.goals.map((g) => `<tr><td class="span"><b>${esc(g.title)}</b>${g.worklist ? ` <span class="chip plain">worklist</span>` : ""}<span class="sub">${g.why ? esc(g.why) : g.closedAt ? `closed ${when(g.closedAt, "full")}` : ""}</span><a class="more seeflow" href="/admin/goal?space=${enc}&amp;id=${esc(encodeURIComponent(g.id))}">See how it moved</a></td>
650
662
  <td data-l="State">${g.state === "OPEN" ? `<span class="chip">open</span>` : g.state === "CLOSED" ? `<span class="chip plain">closed</span>` : g.state === "STALLED" ? `<span class="chip line">${SEAL} out of acts</span>` : `<span class="chip line">${SEAL} blocked</span>`}</td>
@@ -681,7 +693,8 @@ export function renderTeam(d) {
681
693
  body: `${topbar({ crumbs: `<a href="/admin">Relay admin</a><span class="sep">/</span><a href="/admin#teams">Teams</a><span class="sep">/</span><b style="color:var(--text)">${esc(d.name)}</b>`, secbar: secbar([
682
694
  { id: "summary", label: "Summary" },
683
695
  { id: "open", label: "Open", n: d.stateNote?.kind === "rebuild" ? null : f.open.length },
684
- { id: "carried", label: "Who answered" },
696
+ { id: "handoffs", label: "Who asked whom" },
697
+ { id: "carried", label: "Who carried the work" },
685
698
  { id: "people", label: "People", n: admitted.length },
686
699
  { id: "goals", label: "Goals", n: d.stateNote?.kind === "rebuild" ? null : f.goals.filter((g) => g.state !== "CLOSED").length },
687
700
  { id: "conversation", label: "Messages", n: f.messages.total },
@@ -718,16 +731,9 @@ export function renderTeam(d) {
718
731
  ${f.open.length > openShown.length ? `<p class="note">The oldest ${openShown.length} of ${f.open.length} are shown, and ${f.open.length - openShown.length} more. <a href="/admin/space?name=${enc}${d.days !== 7 ? `&amp;range=${d.days}` : ""}&amp;open=all#open">Show all ${f.open.length}</a> (a long page).</p>` : ""}
719
732
  </section>
720
733
 
721
- <div class="grid2 even sec" id="carried">
722
- <section class="card" aria-labelledby="h-carry">
723
- <div class="sechead cardhead" style="margin-bottom:0"><h2 id="h-carry">Who was asked, and who answered</h2><p>${range}</p></div>
724
- <table class="rt"><thead><tr><th>Asked of</th><th class="r">Asked</th><th>Answered by</th><th class="r">Median</th><th class="r">Open</th></tr></thead><tbody>${carriedRows || `<tr><td colspan="5" class="empty">Nobody was asked anything ${range}.</td></tr>`}</tbody></table>
725
- </section>
726
- <section class="card pad" aria-labelledby="h-daily">
727
- <div class="sechead" style="margin-bottom:4px"><h2 id="h-daily">Messages per day</h2><p>the last 14 UTC days</p></div>
728
- ${stackedColumns({ days: d.series14, width: 620, height: 190, step: 3, label: `Messages per day for 14 days. ${f.messages.total} ${range}, ${f.messages.worker} by workers.` })}
729
- </section>
730
- </div>
734
+ ${handoffsRow(f, d.series14, range)}
735
+
736
+ ${carriedSection(f, range)}
731
737
 
732
738
  <section class="sec" id="people" aria-labelledby="h-people">
733
739
  <div class="sechead"><h2 id="h-people">People</h2><p>${admitted.length} admitted · ${plural(d.pending, "waiting to be admitted", "waiting to be admitted")} · ${plural(d.invites.length, "unused invite")}</p></div>
@@ -735,7 +741,7 @@ export function renderTeam(d) {
735
741
  <thead><tr><th>Member</th><th>Connected now</th><th>Build</th><th>Last seen</th><th class="r">Delivered, not yet seen</th></tr></thead>
736
742
  <tbody>${memberRows || `<tr><td colspan="5" class="empty">Nobody yet.</td></tr>`}</tbody>
737
743
  </table></div>
738
- <p class="note">"Delivered, not yet seen" counts acts the relay pushed to a member's machine that their wake-up hook has not reported reaching an agent, for example because the agent is mid-turn.</p>
744
+ <p class="note">"Delivered, not yet seen" counts acts the relay pushed to a member's machine that their wake-up hook has not reported reaching an agent, for example because the agent is mid-turn. The relay keeps those reports in memory only: after it restarts, a member reads "none reported since" until their agent next works.</p>
739
745
  </section>
740
746
 
741
747
  <section class="sec" id="goals" aria-labelledby="h-goals">
@@ -9,6 +9,7 @@ const LIMIT = "its usage limit is reached";
9
9
  const SIGNIN = "its sign-in was refused";
10
10
  export const SIGNIN_REFUSED = SIGNIN;
11
11
  const OVERLOAD = "its service is overloaded";
12
+ const REFRESH_RACE = "another Claude Code process was refreshing its sign-in";
12
13
  const COPILOT_VAR = "(COPILOT_GITHUB_TOKEN|GH_TOKEN|GITHUB_TOKEN)";
13
14
  const copilotVar = (env) => ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"].find((k) => isSet(env[k]) && !(k === "GITHUB_TOKEN" && env["CODESPACES"] === "true"));
14
15
  function claudeCred(line, env, st) {
@@ -37,11 +38,13 @@ const KINDS = {
37
38
  "claude-code": [
38
39
  { re: /^Your organization has disabled Claude subscription access for Claude Code\b/, why: PLAN, wait: 6 * HOUR },
39
40
  { re: /^(?:Claude AI usage limit reached\|\d{10}|(?:5-hour|Weekly|Opus|Session) limit reached [·∙] resets \S.*|You(?:'|’)ve hit your (?:usage )?limit [·∙] resets \S.*|You(?:'|’)re out of extra usage [·∙] resets \S.*|Credit balance is too low)$/, why: LIMIT, wait: HOUR },
40
- { re: /^(?:(?:Invalid API key|Not logged in|Login expired|OAuth token (?:has expired|revoked)) [·∙] Please run \/login|Invalid API key [·∙] Fix external API key|Failed to authenticate\. API Error: 401 (?:OAuth access token is invalid\.|\{"type":"error","error":\{"type":"authentication_error".*\})(?: [·∙] Please run \/login)?|API Error: 401 \{"type":"error","error":\{"type":"authentication_error".*\} [·∙] Please run \/login)$/, why: SIGNIN, wait: HOUR,
41
+ { re: /^(?:(?:Invalid API key|Not logged in|Login expired|OAuth token (?:has expired|revoked)) [·∙] Please run \/login|Invalid API key [·∙] Fix external API key|Failed to authenticate: (?:OAuth session expired and could not be refreshed\.?|OAuth token revoked\. Please log in again or contact your administrator\.)|Failed to authenticate\. API Error: 401 (?:OAuth access token is invalid\.|\{"type":"error","error":\{"type":"authentication_error".*\})(?: [·∙] Please run \/login)?|API Error: 401 \{"type":"error","error":\{"type":"authentication_error".*\} [·∙] Please run \/login)$/, why: SIGNIN, wait: HOUR,
41
42
  claude: claudeCred },
42
43
  { re: /^Your apiKeyHelper script is failing [·∙] This usually means you need to re-authenticate with your provider [·∙] Run \/status to see the script's error output$/, why: SIGNIN, wait: HOUR,
43
44
  trailer: [/^apiKeyHelper failed: .+$/], claude: claudeCred },
44
45
  { re: /^API Error: 529 \{"type":"error","error":\{"type":"overloaded_error"/, why: OVERLOAD, wait: 15 * MIN },
46
+ { re: /^(?:Failed to refresh OAuth token: another Claude Code process is refreshing it or exited mid-refresh\.(?: This is usually transient; retry in a minute, and if it persists close other Claude Code processes or sign in again\.?)?|Could not refresh your login because another Claude Code process is refreshing it \(or exited mid-refresh\) [·∙] Try again in a minute; if it keeps happening, close other Claude Code windows or sign in again with \/login)$/,
47
+ why: REFRESH_RACE, wait: 5 * MIN, brief: true },
45
48
  ],
46
49
  codex: [
47
50
  { re: new RegExp(`^ERROR: (?:${CODEX_LIMIT})$`), why: LIMIT, wait: HOUR },
@@ -94,10 +97,10 @@ export function refusalOf(agent, tail, only, env, claudeSettings) {
94
97
  continue;
95
98
  if (k.claude) {
96
99
  const c = env !== undefined ? k.claude(line, env, claudeSettings ?? { env: [], apiKeyHelper: false }) : (/^Your apiKeyHelper/.test(line) ? { helper: true, settings: true } : undefined);
97
- return { why: k.why, wait: k.wait, line, ...(c?.env ? { env: c.env } : {}), ...(c?.settings ? { settings: true } : {}), ...(c?.helper ? { helper: true } : {}) };
100
+ return { why: k.why, wait: k.wait, line, ...(k.brief ? { brief: true } : {}), ...(c?.env ? { env: c.env } : {}), ...(c?.settings ? { settings: true } : {}), ...(c?.helper ? { helper: true } : {}) };
98
101
  }
99
102
  const via = k.env?.(line, after, env ?? {});
100
- return { why: k.why, wait: k.wait, line, ...(via ? { env: via } : {}) };
103
+ return { why: k.why, wait: k.wait, line, ...(k.brief ? { brief: true } : {}), ...(via ? { env: via } : {}) };
101
104
  }
102
105
  }
103
106
  return null;
@@ -191,7 +194,7 @@ export function detectOutage(agent, tail, now = Date.now()) {
191
194
  const until = !named || named.t <= now ? now + r.wait
192
195
  : named.dated ? (named.t - now <= MAX_DATED_WAIT_MS ? named.t : now + r.wait)
193
196
  : Math.min(named.t, now + MAX_TEXT_WAIT_MS);
194
- return { why: r.why, until: Math.max(until, now + 5 * MIN), ...(r.why === SIGNIN ? { signIn: true } : {}) };
197
+ return { why: r.why, until: Math.max(until, now + 5 * MIN), ...(r.why === SIGNIN ? { signIn: true } : {}), ...(r.brief ? { brief: true } : {}) };
195
198
  }
196
199
  export const isSignOut = (out) => out.signIn === true || out.why === SIGNIN;
197
200
  export function outagePredicate(why) {
@@ -200,6 +203,7 @@ export function outagePredicate(why) {
200
203
  case LIMIT: return "has reached its usage limit";
201
204
  case SIGNIN: return "refused its sign-in";
202
205
  case OVERLOAD: return "is overloaded";
206
+ case REFRESH_RACE: return "could not refresh its sign-in: another Claude Code process on this machine was refreshing it at the same time, or quit partway through";
203
207
  default: return why;
204
208
  }
205
209
  }
package/dist/agents.js CHANGED
@@ -507,6 +507,7 @@ export const COMMAND_ALLOWLIST = [
507
507
  "npm test", "npm run", "npm ci", "pnpm test", "pnpm run", "yarn test", "yarn run", "bun test", "bun run",
508
508
  "make", "cargo build", "cargo test", "cargo check", "go build", "go test", "go vet",
509
509
  "pytest", "python -m pytest", "python3 -m pytest", "mvn", "gradle", "./gradlew", "dotnet build", "dotnet test",
510
+ "flutter build", "flutter test", "flutter analyze", "flutter pub get", "dart test", "dart analyze", "dart pub get",
510
511
  ];
511
512
  export const COMMAND_EXACT = ["npm install", "pnpm install", "yarn install", "bun install"];
512
513
  export const claudeCommandRules = (extra = []) => [
@@ -530,11 +531,11 @@ const FETCH_AND_RUN = new Set(["npx", "pnpx", "bunx", "uvx", "pipx"]);
530
531
  const FETCH_AND_RUN_SUB = {
531
532
  npm: /^(?:exec|x)$/, pnpm: /^(?:dlx|exec)$/, yarn: /^(?:dlx|exec)$/, bun: /^x$/, uv: /^tool$/, poetry: /^run$/, pipenv: /^run$/, pdm: /^run$/,
532
533
  };
533
- const MANY_VERBS = new Set(["npm", "pnpm", "yarn", "bun", "uv", "poetry", "pipenv", "pdm", "go", "cargo", "dotnet", "deno", "docker", "podman", "nerdctl", "kubectl", "gradle", "mvn", "make", "just", "task", "rake",
534
+ const MANY_VERBS = new Set(["npm", "pnpm", "yarn", "bun", "uv", "poetry", "pipenv", "pdm", "go", "cargo", "dotnet", "deno", "flutter", "dart", "docker", "podman", "nerdctl", "kubectl", "gradle", "mvn", "make", "just", "task", "rake",
534
535
  "pip", "pip3", "gem", "brew"]);
535
536
  const RUNS_NEXT = /^(?:run|exec|x|dlx|tool|eval|start|create|compose|container|debug|attach|install|add|i)$/;
536
537
  const INTERPRETER = /^(?:node|nodejs|python[0-9.]*|pythonw|pypy[0-9.]*|perl[0-9.]*|ruby|php|deno|bun|lua[0-9.]*|luajit|rscript|tclsh|wish|java|kotlin|groovy|scala|elixir|erl|julia|swift|ts-node|tsx)$/;
537
- const SCRIPT_PATH = /^(?!\/|~|.*\.\.)(?:[\w@.+\-/]+\.(?:c?js|mjs|cts|mts|ts|tsx|jsx|py|rb|pl|php|lua|r|jar|kts?|groovy|exs?|jl|swift)$|[\w@.+\-]+\/[\w@.+\-/]+$)/i;
538
+ const SCRIPT_PATH = /^(?!\/|~|.*\.\.)(?:[\w@.+\-/]+\.(?:c?js|mjs|cts|mts|ts|tsx|jsx|py|rb|pl|php|lua|r|jar|kts?|groovy|exs?|jl|swift|dart)$|[\w@.+\-]+\/[\w@.+\-/]+$)/i;
538
539
  export const programName = (word) => word.replace(/^.*[\\/]/, "").toLowerCase().replace(/\.(?:exe|cmd|bat|com|ps1)$/, "");
539
540
  export function checkRepoCommand(line) {
540
541
  const t = line.trim();
@@ -552,13 +553,30 @@ export function checkRepoCommand(line) {
552
553
  return `${first} fetches and runs packages, so it would run whatever it is given`;
553
554
  const plain = words.slice(1).filter((w) => !w.startsWith("-"));
554
555
  const sub = FETCH_AND_RUN_SUB[first];
555
- if (sub && plain[0] && sub.test(plain[0].toLowerCase()))
556
- return `${first} ${plain[0]} runs whatever it is given`;
556
+ const runner = sub ? plain.find((w) => sub.test(w.toLowerCase())) : undefined;
557
+ if (runner)
558
+ return `${first} ${runner} runs whatever it is given`;
559
+ if ((first === "dart" || first === "flutter") && plain[0]?.toLowerCase() === "pub" && plain[1]?.toLowerCase() !== "get") {
560
+ return `${first} pub ${plain[1] ?? ""}`.trim() + " is not one a woken run may be given — only pub get";
561
+ }
562
+ if (first === "dart" && plain[0] && /[\\/.]/.test(plain[0]) && !SCRIPT_PATH.test(plain[0])) {
563
+ return `dart runs the file it is given — name one inside the repo (dart tool/check.dart)`;
564
+ }
557
565
  if (MANY_VERBS.has(first) && !plain.length && !["make", "just", "task", "rake", "gradle", "mvn"].includes(first)) {
558
566
  return `${first} alone would allow every ${first} subcommand, one that runs anything included — name it (${first} test, ${first} run lint)`;
559
567
  }
560
568
  const last = words[words.length - 1].toLowerCase();
561
- const own = words.length === 2 || (words.length === 3 && /^(?:compose|container)$/i.test(words[1]));
569
+ let named = false;
570
+ for (let i = 1; i < words.length - 1; i++) {
571
+ const w = words[i];
572
+ if (w.startsWith("-")) {
573
+ if (!w.includes("=") && i + 1 < words.length - 1 && !words[i + 1].startsWith("-"))
574
+ i++;
575
+ }
576
+ else if (!/^(?:compose|container)$/i.test(w))
577
+ named = true;
578
+ }
579
+ const own = words.length === 2 || !named;
562
580
  if (MANY_VERBS.has(first) && own && RUNS_NEXT.test(last) && !(["poetry", "pdm", "pipenv"].includes(first) && last === "install")) {
563
581
  return `it ends on "${last}", so the run would choose what that ${/^(?:install|add|i)$/.test(last) ? "installs" : "runs"} — name it (${words.join(" ")} <the program or target>)`;
564
582
  }
@@ -622,15 +640,23 @@ export const REPO_RULES_ARGV_MAX = 3_000;
622
640
  export const COMMAND_GRANT_SCOPE = "a run with commands works in its own worktree on a pantheon/* branch: it runs your tests and builds, commits, pushes its own branch for your review, and never merges. " +
623
641
  "Claude Code (macOS and Linux) runs those commands inside its OS sandbox: they write only the run's worktree, its git data and the temp dirs, stay clear of your keys and credentials " +
624
642
  "(~/.ssh, ~/.aws, ~/.config/gh, ~/.gnupg, ~/.netrc, ~/.docker/config.json, ~/.kube, ~/.git-credentials, ~/.pantheon), and use git, the repo's scripts through npm/pnpm/yarn/bun, " +
625
- "make, cargo, go, pytest, mvn/gradle and dotnet, plus whatever the committed .pantheon/commands on the base branch lists. " +
643
+ "make, cargo, go, pytest, mvn/gradle, dotnet and flutter/dart, plus whatever the committed .pantheon/commands on the base branch lists. " +
626
644
  "Codex runs them in its own workspace-write sandbox, approved by its auto-reviewer. " +
627
645
  "Cursor and Copilot run any command without asking, as you and with no sandbox; Claude Code on Windows or before 2.1.83 runs its listed commands the same way, without its sandbox. " +
628
646
  "After every run Pantheon checks its own settings and puts back any change a run made to them; " +
629
647
  "pantheon setup --unsandboxed no leaves those requests for you instead. Kiro answers in your live sessions. " +
630
648
  "Turn commands off any time: pantheon policy revoke run-commands.";
631
649
  export const WOKEN_INSTRUCTIONS_ROOM = 8192;
650
+ export function runLauncher(execPath = process.execPath, exists = existsSync, findNode = () => which("node", platform(), process.env, { login: () => null })) {
651
+ const own = launcher("local");
652
+ if (own.command !== execPath || exists(own.command))
653
+ return own;
654
+ const cli = own.args.find((a) => /[\\/]cli\.js$/.test(a));
655
+ const node = findNode();
656
+ return node && exists(node) && cli && exists(cli) ? { ...own, command: node } : launcher("portable");
657
+ }
632
658
  export function headlessSpawn(opts) {
633
- const l = launcher();
659
+ const l = runLauncher();
634
660
  const identity = {
635
661
  PANTHEON_RELAY: opts.cfg.relay,
636
662
  PANTHEON_SPACE: opts.cfg.space,
package/dist/board.js CHANGED
@@ -1276,7 +1276,16 @@ const retracting = new Set(); // keyOf(item) of a retract in flight
1276
1276
  // Any other action in flight on a decision — a choice, an option, Mark done, Approve (0.35.1 review,
1277
1277
  // item 5): one action per decision at a time, so two clicks never put two answers on the record.
1278
1278
  const acting = new Set(); // keyOf(item)
1279
- const busyOn = (k) => inFlight.has(k) || acting.has(k);
1279
+ // A Retract on its way is an action on the decision too (0.35.2 review): nothing is sent while it goes —
1280
+ // when it lands the decision comes back under a new id, and a reply sent meanwhile would follow it there.
1281
+ const busyOn = (k) => inFlight.has(k) || acting.has(k) || retracting.has(k);
1282
+ // What is on its way on a decision, in words: a typed Note or Ask is not "your last answer" (rc.3 check).
1283
+ const sendingWhat = (k) => { const f = inFlight.get(k); return !f || f.kind === "ANSWER" ? "answer" : f.kind === "ASK" ? "question" : "note"; };
1284
+ const stillSending = (k, tail) => (!inFlight.has(k) && !acting.has(k) && retracting.has(k) ? "Still retracting your answer to this — " : "Still sending your last " + sendingWhat(k) + " to this — ") + tail;
1285
+ // "Reply as" shows the kind of the words in the box (rc.3 check): words put back after a failed send,
1286
+ // or a reply still on its way, bring the kind they were going as — never the menu's default, Answer,
1287
+ // so a refused Note sent again never settles the decision.
1288
+ function showKind(kind) { const m = $("d-kind"); if ([...m.options].some((o) => o.value === kind)) m.value = kind; }
1280
1289
  // Words just sent, still at the front of the box (round two): a Send of them again asks once first.
1281
1290
  const resendGuard = new Map(); // keyOf(item) -> the words sent
1282
1291
  // A decision answered from here: a second Send as an ANSWER would be refused (ALREADY_ANSWERED);
@@ -1621,7 +1630,7 @@ async function act(body, btn, okText, item) {
1621
1630
  const k = item ? keyOf(item) : null;
1622
1631
  const named = (msg) => (item && keyOf(current) !== k ? "“" + nameOf(item) + "”: " + msg : msg);
1623
1632
  // One action per decision at a time (0.35.1 review, item 5) — said, never a second answer.
1624
- if (k && busyOn(k)) { toast(named("Still sending your last answer to this — wait for it to land.")); return null; }
1633
+ if (k && busyOn(k)) { toast(named(stillSending(k, "wait for it to land."))); return null; }
1625
1634
  if (k) acting.add(k);
1626
1635
  if (btn) btn.disabled = true;
1627
1636
  if (k && keyOf(current) === k) syncControls();
@@ -1687,10 +1696,12 @@ async function openDetail(item, focusReply) {
1687
1696
  ch.hidden = !(item.wake || (item.choices && item.choices.length));
1688
1697
  const kind = $("d-kind"); kind.replaceChildren();
1689
1698
  for (const [v, label] of (item.kind === "decision" ? [["ANSWER", "Answer"], ["NOTE", "Note"], ["ASK", "Ask back"]] : [["NOTE", "Note"], ["ASK", "Ask back"]])) { const o = el("option", "", label); o.value = v; kind.append(o); }
1690
- { const dr = drafts.get(keyOf(item)); $("d-text").value = dr ? dr.text : ""; if (dr && dr.kind && [...$("d-kind").options].some((o) => o.value === dr.kind)) $("d-kind").value = dr.kind; }
1699
+ { const dr = drafts.get(keyOf(item)); $("d-text").value = dr ? dr.text : ""; if (dr && dr.kind && [...$("d-kind").options].some((o) => o.value === dr.kind)) $("d-kind").value = dr.kind;
1700
+ // Opened again (or reloaded) while its reply is on the way, nothing typed since: the menu shows that reply's kind.
1701
+ const fl = inFlight.get(keyOf(item)); if (fl && !(dr && dr.text.trim())) showKind(fl.kind); }
1691
1702
  {
1692
1703
  const k = keyOf(item), note = notes.get(k);
1693
- if (busyOn(k)) setStatus("Still sending your last answer to this — Send works again once it lands.");
1704
+ if (busyOn(k)) setStatus(stillSending(k, "Send works again once it lands."));
1694
1705
  else if (note) { notes.delete(k); setStatus(note); }
1695
1706
  else setStatus("");
1696
1707
  }
@@ -1760,7 +1771,8 @@ function putBack(k, text, kind) {
1760
1771
  saveLocal();
1761
1772
  if (keyOf(current) === k) {
1762
1773
  const box = $("d-text"), v = box.value.trim();
1763
- if (!v) box.value = text; else if (!startsWithSent(v, text)) box.value = text + "\\n\\n" + box.value;
1774
+ // The box holds only the words put back: the menu goes back to the kind they were sent as.
1775
+ if (!v) { box.value = text; showKind(kind); } else if (!startsWithSent(v, text)) box.value = text + "\\n\\n" + box.value;
1764
1776
  }
1765
1777
  }
1766
1778
  /** What is left of v once the words that were sent are taken off its front (item 7): a follow-up typed onto them. */
@@ -1817,7 +1829,7 @@ async function send() {
1817
1829
  const k = keyOf(item);
1818
1830
  // One send per decision at a time: a second press, the same decision opened again, or the tab
1819
1831
  // reloaded while its reply is on the way — never sends the words twice (#105), and says why.
1820
- if (busyOn(k)) { setStatus("Still sending your last answer to this — Send works again once it lands."); return; }
1832
+ if (busyOn(k)) { setStatus(stillSending(k, "Send works again once it lands.")); return; }
1821
1833
  const text = $("d-text").value.trim();
1822
1834
  if (!text) { setStatus("Type your reply first."); return; }
1823
1835
  if ($("d-kind").value === "ANSWER" && answeredHere.has(k)) {
@@ -1907,6 +1919,8 @@ async function retract() {
1907
1919
  return;
1908
1920
  }
1909
1921
  if (retracting.has(k)) return;
1922
+ // A reply or an action still on its way on this decision: the Retract waits for it (0.35.2 review).
1923
+ if (inFlight.has(k) || acting.has(k)) { setStatus(stillSending(k, "Retract works once it lands.")); return; }
1910
1924
  retracting.add(k);
1911
1925
  syncControls();
1912
1926
  setStatus("Retracting…");
@@ -1941,6 +1955,8 @@ function followMoved() {
1941
1955
  && (i.who || "") === (was.who || "") && (i.decider || "") === (was.decider || "");
1942
1956
  for (const [k, was] of [...retracted]) {
1943
1957
  if (onBoard.has(k)) continue;
1958
+ // Something still on its way on the old id is told there first; the next refresh follows (0.35.2 review).
1959
+ if (busyOn(k)) continue;
1944
1960
  const next = items.find((i) => keyOf(i) !== k && same(was, i));
1945
1961
  if (!next) continue;
1946
1962
  const k2 = keyOf(next);
@@ -1950,8 +1966,9 @@ function followMoved() {
1950
1966
  if (current && keyOf(current) === k) {
1951
1967
  // Its buttons are the old id's: the dialog is drawn again for the new one, keeping what is in
1952
1968
  // the box and on the status line.
1953
- const text = $("d-text").value, said = $("d-status").textContent, open = $("detail").open;
1954
- if (open) { openDetail(next); $("d-text").value = text; setStatus(said); } else current = next;
1969
+ const text = $("d-text").value, said = $("d-status").textContent, open = $("detail").open, kindWas = $("d-kind").value;
1970
+ // ... and "Reply as": drawn again, the menu would go back to its default, Answer (0.35.2 review).
1971
+ if (open) { openDetail(next); $("d-text").value = text; showKind(kindWas); setStatus(said); } else current = next;
1955
1972
  syncControls();
1956
1973
  }
1957
1974
  }
@@ -413,6 +413,7 @@ export function sandboxCacheEnv(runTmp) {
413
413
  YARN_CACHE_FOLDER: join(runTmp, "yarn-cache"),
414
414
  PIP_CACHE_DIR: join(runTmp, "pip-cache"),
415
415
  GOCACHE: join(runTmp, "go-build"),
416
+ PUB_CACHE: join(runTmp, "pub-cache"),
416
417
  XDG_CACHE_HOME: join(runTmp, "cache"),
417
418
  };
418
419
  }
package/dist/continued.js CHANGED
@@ -4,7 +4,7 @@ import { CONFIG_DIR } from "./config.js";
4
4
  import { readStateFile, withFileLock } from "./file-lock.js";
5
5
  import { writeWhole } from "./pins.js";
6
6
  const KEEP = 500;
7
- export const WORKER_MARK = /^(parked|parked-nc|parked2|parked-ns|parked2-ns|unparked|failed1|stuck|stuck-safety|stuck-safety-due|refused|esc-for|decided-for)(@[^:]+)?:/;
7
+ export const WORKER_MARK = /^(parked|parked-nc|parked2|parked-ns|parked2-ns|unparked|failed1|stuck|stuck-safety|stuck-safety-due|refused|esc-for|decided-for|held-for|run-for|stuck-note)(@[^:]+)?:/;
8
8
  const KEEP_WORKER = 2_000;
9
9
  export const markedHere = new Set();
10
10
  function capped(list) {
@@ -216,4 +216,126 @@ export function welcomeEmailText(to) {
216
216
  "joinpantheon.network · Privacy: https://www.joinpantheon.network/privacy",
217
217
  ].join("\n");
218
218
  }
219
+ const MONO = "'Space Mono',Menlo,Consolas,'Liberation Mono',monospace";
220
+ const DISPLAY = "'Archivo Black','Arial Black',Arial,sans-serif";
221
+ function viewerFrame(o) {
222
+ return `<!doctype html>
223
+ <html lang="en">
224
+ <head>
225
+ <meta charset="utf-8">
226
+ <meta name="viewport" content="width=device-width,initial-scale=1">
227
+ <meta name="color-scheme" content="light">
228
+ <meta name="supported-color-schemes" content="light">
229
+ <title>${o.title}</title>
230
+ <style>@media (max-width:620px){.px{padding-left:22px!important;padding-right:22px!important}.h1{font-size:30px!important}}</style>
231
+ </head>
232
+ <body style="margin:0;padding:0;background:#ebe2d0">
233
+ <div style="display:none;max-height:0;overflow:hidden;opacity:0">${o.preheader}&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;</div>
234
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:#ebe2d0">
235
+ <tr><td align="center" style="padding:32px 12px 40px">
236
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="max-width:600px;width:100%">
237
+ <tr><td style="padding:0 4px 18px">
238
+ <img src="https://www.joinpantheon.network/email/mark-coral.png" width="26" height="26" alt="" style="display:inline-block;vertical-align:middle;border:0">
239
+ <span style="display:inline-block;vertical-align:middle;padding-left:8px;font-family:${DISPLAY};font-size:20px;color:#1b1917">Pantheon</span>
240
+ </td></tr>
241
+ <tr><td style="background:#f6efe1;border-radius:14px;box-shadow:0 2px 0 #ddd0b6">
242
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
243
+ ${o.rows}
244
+ <tr><td style="line-height:0;font-size:0"><img src="https://www.joinpantheon.network/email/keyband.png" width="600" height="28" alt="" style="display:block;width:100%;max-width:600px;height:auto;border:0"></td></tr>
245
+ </table>
246
+ </td></tr>
247
+ <tr><td class="px" style="padding:20px 6px 0;font-family:${MONO};font-size:11.5px;line-height:1.7;color:#6b6257">
248
+ ${o.why}<br>
249
+ <a href="https://www.joinpantheon.network" style="color:#6b6257">joinpantheon.network</a>
250
+ <span style="color:#e0aa3e;padding:0 6px">&middot;</span>
251
+ <a href="https://www.joinpantheon.network/privacy" style="color:#6b6257">Privacy</a>
252
+ <span style="color:#e0aa3e;padding:0 6px">&middot;</span>
253
+ <a href="https://www.joinpantheon.network/security" style="color:#6b6257">Security</a>
254
+ </td></tr>
255
+ </table>
256
+ </td></tr>
257
+ </table>
258
+ </body>
259
+ </html>`;
260
+ }
261
+ const para = (html, top = 18) => `<p style="margin:${top}px 0 0;font-family:${MONO};font-size:15px;line-height:1.65;color:#26221f">${html}</p>`;
262
+ const small = (html) => `<p style="margin:0;padding-top:18px;border-top:1px solid #ddd0b6;font-family:${MONO};font-size:13px;line-height:1.65;color:#6b6257">${html}</p>`;
263
+ export const viewerInviteSubject = (team) => `You can now see how the team "${team}" works on Pantheon`;
264
+ export function viewerInviteEmailHtml(o) {
265
+ const team = esc(o.team), until = esc(o.until);
266
+ const url = o.viewUrl ? esc(o.viewUrl) : null;
267
+ const by = o.relayName ? `The operator of the Pantheon relay <b>${esc(o.relayName)}</b>` : "The operator of a Pantheon relay";
268
+ const button = url ? `
269
+ <tr><td class="px" style="padding:22px 40px 0"><table role="presentation" cellpadding="0" cellspacing="0" border="0"><tr>
270
+ <td style="background:#e36f55;border-radius:8px"><a href="${url}" style="display:inline-block;padding:14px 22px;font-family:${MONO};font-size:15px;font-weight:700;color:#1b1917;text-decoration:none">Open the team view</a></td>
271
+ </tr></table>
272
+ <p style="margin:12px 0 0;font-family:${MONO};font-size:12.5px;line-height:1.6;color:#6b6257;word-break:break-all">Or paste this address into your browser: <a href="${url}" style="color:#6b6257">${url}</a></p></td></tr>` : "";
273
+ const rows = `
274
+ <tr><td class="px" style="padding:34px 40px 6px">
275
+ <p style="margin:0 0 12px;font-family:${MONO};font-size:12px;letter-spacing:.16em;text-transform:uppercase;color:#6b6257">Read-only team view</p>
276
+ <h1 class="h1" style="margin:0;font-family:${DISPLAY};font-weight:400;font-size:36px;line-height:1.05;color:#1b1917">See how ${team} works</h1>
277
+ ${para(`${by} gave you read-only access to the team <b>${team}</b> until <b>${until}</b>.`, 20)}
278
+ ${para("You can see who handed work to whom, who picked it up and how long it took. Message text, code and files stay with the team. The team was told.")}
279
+ ${para(url ? "Sign in with a code sent to this address — no password, no account." : "Sign in at the relay's /view page with a code sent to this address — no password, no account.")}
280
+ </td></tr>${button}
281
+ <tr><td class="px" style="padding:26px 40px 32px">
282
+ ${small(`The access ends on ${until}, or sooner if the operator ends it.<br>Not expecting this? Ignore it: nobody can see anything as you without a code sent here.`)}
283
+ </td></tr>`;
284
+ return viewerFrame({
285
+ title: esc(viewerInviteSubject(o.team)),
286
+ preheader: `Read-only access to ${team} until ${until}. Sign in with a code sent to this address.`,
287
+ rows,
288
+ why: `You're getting this because the operator of this relay gave this address read-only access to a team.`,
289
+ });
290
+ }
291
+ export function viewerInviteEmailText(o) {
292
+ return [
293
+ `${o.relayName ? `The operator of the Pantheon relay ${o.relayName}` : "The operator of a Pantheon relay"} gave you read-only access to the team "${o.team}" until ${o.until}.`,
294
+ ``,
295
+ `You can see who handed work to whom, who picked it up and how long it took. Message text, code and files stay with the team. The team was told.`,
296
+ ``,
297
+ o.viewUrl ? `Open the team view and sign in with a code sent to this address:\n ${o.viewUrl}` : `Sign in at the relay's /view page with a code sent to this address.`,
298
+ ``,
299
+ `The access ends on ${o.until}, or sooner if the operator ends it. Not expecting this? Ignore it: nobody can see anything as you without a code sent here.`,
300
+ ``,
301
+ `joinpantheon.network — your AI can talk to theirs`,
302
+ ].join("\n");
303
+ }
304
+ export const viewerCodeSubject = (code) => `Your Pantheon team view code: ${code}`;
305
+ export function viewerCodeEmailHtml(code) {
306
+ code = esc(code);
307
+ const rows = `
308
+ <tr><td class="px" style="padding:34px 40px 6px">
309
+ <p style="margin:0 0 12px;font-family:${MONO};font-size:12px;letter-spacing:.16em;text-transform:uppercase;color:#6b6257">Team view sign-in</p>
310
+ <h1 class="h1" style="margin:0;font-family:${DISPLAY};font-weight:400;font-size:36px;line-height:1.05;color:#1b1917">Your code</h1>
311
+ <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:20px"><tr>
312
+ <td align="center" style="background:#1b1917;border-radius:10px;padding:22px 12px">
313
+ <span style="font-family:${MONO};font-size:38px;line-height:1.1;letter-spacing:.26em;font-weight:700;color:#f1e7d3">${code}</span>
314
+ </td>
315
+ </tr></table>
316
+ ${para("Enter it on the page that asked for it, in the same browser, to see your team's work read-only.", 22)}
317
+ </td></tr>
318
+ <tr><td class="px" style="padding:22px 40px 32px">
319
+ ${small("Expires in 10 minutes. Works once, in that browser.<br>Didn't ask for it? Ignore this email: nobody can sign in without the code.")}
320
+ </td></tr>`;
321
+ return viewerFrame({
322
+ title: esc(viewerCodeSubject(code)),
323
+ preheader: `Your code is ${code}. It expires in 10 minutes.`,
324
+ rows,
325
+ why: "You're getting this because someone asked to see a team's work with this address.",
326
+ });
327
+ }
328
+ export function viewerCodeEmailText(code) {
329
+ return [
330
+ `Pantheon — team view sign-in`,
331
+ ``,
332
+ `Your code is ${code}.`,
333
+ ``,
334
+ `Enter it on the page that asked for it, in the same browser, to see your team's work read-only.`,
335
+ ``,
336
+ `It expires in 10 minutes and works once. If you did not ask for it, ignore this email: nobody can sign in without the code.`,
337
+ ``,
338
+ `joinpantheon.network — your AI can talk to theirs`,
339
+ ].join("\n");
340
+ }
219
341
  //# sourceMappingURL=email-templates.js.map
package/dist/email.js CHANGED
@@ -1,4 +1,4 @@
1
- import { codeEmailHtml, WELCOME_REPLY_TO, WELCOME_SUBJECT, welcomeEmailHtml, welcomeEmailText } from "./email-templates.js";
1
+ import { codeEmailHtml, viewerCodeEmailHtml, viewerCodeEmailText, viewerCodeSubject, viewerInviteEmailHtml, viewerInviteEmailText, viewerInviteSubject, WELCOME_REPLY_TO, WELCOME_SUBJECT, welcomeEmailHtml, welcomeEmailText } from "./email-templates.js";
2
2
  function subjectAndBody(code, purpose) {
3
3
  const action = purpose === "signup" ? "confirm your email and finish signing up" : "add this device to your account";
4
4
  const eyebrow = purpose === "signup" ? "Confirm your email" : "New device sign-in";
@@ -64,6 +64,29 @@ class ResendSender {
64
64
  return false;
65
65
  }
66
66
  }
67
+ async sendViewerInvite(to, o) {
68
+ return this.post("viewer invite", to, { subject: viewerInviteSubject(o.team), text: viewerInviteEmailText(o), html: viewerInviteEmailHtml(o), reply_to: "sid@joinpantheon.network" });
69
+ }
70
+ async sendViewerCode(to, code) {
71
+ return this.post("viewer code", to, { subject: viewerCodeSubject(code), text: viewerCodeEmailText(code), html: viewerCodeEmailHtml(code) });
72
+ }
73
+ async post(what, to, mail) {
74
+ try {
75
+ const res = await fetch("https://api.resend.com/emails", {
76
+ method: "POST",
77
+ headers: { "content-type": "application/json", authorization: `Bearer ${this.apiKey}` },
78
+ body: JSON.stringify({ from: this.from, to, ...mail }),
79
+ signal: AbortSignal.timeout(10_000),
80
+ });
81
+ if (!res.ok)
82
+ this.log(`! ${what} email failed (${res.status}) to ${maskEmail(to)}`);
83
+ return res.ok;
84
+ }
85
+ catch (e) {
86
+ this.log(`! ${what} email errored to ${maskEmail(to)}: ${e.message}`);
87
+ return false;
88
+ }
89
+ }
67
90
  async sendNotice(to, subject, text) {
68
91
  try {
69
92
  const res = await fetch("https://api.resend.com/emails", {
@@ -100,6 +123,14 @@ class LogSender {
100
123
  this.log(` [no email provider] notice to ${maskEmail(to)}: ${subject}`);
101
124
  return true;
102
125
  }
126
+ async sendViewerInvite(to, o) {
127
+ this.log(` [no email provider] viewer invite to ${maskEmail(to)} for "${o.team}"${o.viewUrl ? ` — ${o.viewUrl}` : ""}`);
128
+ return true;
129
+ }
130
+ async sendViewerCode(to, code) {
131
+ this.log(` [no email provider] viewer code for ${to}: ${code} (set RESEND_API_KEY + PANTHEON_EMAIL_FROM to send real email)`);
132
+ return true;
133
+ }
103
134
  }
104
135
  export function maskEmail(email) {
105
136
  const [user, domain] = email.split("@");
@@ -26,6 +26,7 @@ export function toFlowObligations(obligations, firstClaims = new Map(), claimLiv
26
26
  ref: o.ref, goal: o.goal ?? null, created_at: o.created_at,
27
27
  claimed: live ? { by: o.claimed_by.role === "worker" ? "worker" : "person", at: o.claimed_by.at } : null,
28
28
  first_claimed_at: firstClaims.get(o.id)?.at ?? null,
29
+ ...(human && o.about ? { about: o.about } : {}),
29
30
  });
30
31
  }
31
32
  return out;
@@ -221,6 +222,7 @@ function* flowSteps(input) {
221
222
  }
222
223
  }
223
224
  }
225
+ const decisions = input.obligations.filter((o) => o.human);
224
226
  const open = input.obligations.map((o) => {
225
227
  const src = byId.get(o.ref) ?? null;
226
228
  const g = o.goal ? goalOf.get(o.goal) : undefined;
@@ -231,6 +233,7 @@ function* flowSteps(input) {
231
233
  since: o.created_at, ageMs: Math.max(0, now - o.created_at), claimed: o.claimed,
232
234
  pickupMs: o.first_claimed_at !== null ? Math.max(0, o.first_claimed_at - o.created_at) : null,
233
235
  blocksGoal: o.human && !!g && g.state === "BLOCKED",
236
+ handedBackAt: o.human ? null : handedBackAt(decisions, o, (id) => byId.get(id)?.act),
234
237
  };
235
238
  }).sort((a, b) => a.since - b.since || (byId.get(a.ref)?.seq ?? 0) - (byId.get(b.ref)?.seq ?? 0));
236
239
  const waiting = open.filter((o) => o.human);
@@ -398,6 +401,17 @@ function* flowSteps(input) {
398
401
  askStatus,
399
402
  };
400
403
  }
404
+ function handedBackAt(list, o, actOf) {
405
+ let at = null;
406
+ for (const x of list) {
407
+ if (!x.human || x.owner !== o.owner)
408
+ continue;
409
+ const about = x.about ? x.about === o.ref : !!o.goal && x.goal === o.goal && x.created_at >= o.created_at && actOf(x.ref) === "ESCALATE";
410
+ if (about && (at === null || x.created_at < at))
411
+ at = x.created_at;
412
+ }
413
+ return at;
414
+ }
401
415
  const stateRank = (s) => (s === "BLOCKED" ? 0 : s === "STALLED" ? 1 : s === "OPEN" ? 2 : 3);
402
416
  const cap = (s) => (s ? s[0].toUpperCase() + s.slice(1) : s);
403
417
  export function dur(ms) {