@join-pantheon/cli 0.33.10-rc.1 → 0.33.11-rc.1
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/board.js +53 -6
- package/dist/claude-confine.js +9 -2
- package/dist/cli.js +674 -34
- package/dist/client.js +14 -1
- package/dist/continued.js +4 -0
- package/dist/declined.js +67 -0
- package/dist/doctor.js +19 -3
- package/dist/home-guard.js +256 -5
- package/dist/home-safety.js +6 -1
- package/dist/mcp-instructions.js +15 -7
- package/dist/notice-linux.js +36 -10
- package/dist/notice-windows.js +21 -2
- package/dist/notifier.js +16 -2
- package/dist/pending.js +90 -7
- package/dist/pickup.js +6 -0
- package/dist/protocol.js +3 -1
- package/dist/quickstart.js +6 -3
- package/dist/relay.js +33 -3
- package/dist/run-control.js +72 -0
- package/dist/service.js +47 -0
- package/dist/setup-changes.js +521 -0
- package/dist/setup-guide.js +119 -17
- package/dist/spend.js +17 -2
- package/dist/tray.js +77 -6
- package/dist/uri-handler.js +20 -3
- package/dist/worker-policy.js +28 -0
- package/dist/worker.js +670 -65
- package/helper/macos/main.swift +209 -18
- package/helper/macos/menubar.swift +87 -3
- package/helper/macos/prebuilt/manifest.json +5 -5
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/helper/macos/prebuilt/pantheon-tray +0 -0
- package/helper/windows/pantheon-notice.ps1 +6 -2
- package/helper/windows/pantheon-tray.ps1 +68 -5
- package/package.json +1 -1
package/dist/setup-guide.js
CHANGED
|
@@ -5,11 +5,12 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { applyProfileInit, dropCatchAllClaims, loadProfile, profilePath, saveProfile, spaceOverride, teamProfile, wakeMode } from "./profile.js";
|
|
7
7
|
import { isCatchAllDomain } from "./protocol.js";
|
|
8
|
-
import { installService as realInstall, uninstallService as realUninstall, serviceInstalled as realInstalled } from "./service.js";
|
|
8
|
+
import { installService as realInstall, uninstallService as realUninstall, serviceInstalled as realInstalled, installedServiceArgs, keepServiceFlags } from "./service.js";
|
|
9
|
+
import { unsandboxedRisk } from "./setup-changes.js";
|
|
9
10
|
import { personaDir } from "./persona.js";
|
|
10
11
|
import { hudBinaryPath } from "./notifier.js";
|
|
11
12
|
import { hostEnv } from "./host-env.js";
|
|
12
|
-
import { grant, inWokenRun, loadPolicy, revoke, savePolicy, unsandboxedAllowed } from "./worker-policy.js";
|
|
13
|
+
import { AUTOPILOT_PLAN_NOTE, effectiveMode, grant, inWokenRun, loadPolicy, MODE_LABELS, revoke, savePolicy, unsandboxedAllowed, WORK_MODES } from "./worker-policy.js";
|
|
13
14
|
export const DECISION_AREAS = [
|
|
14
15
|
{ id: "product", label: "Product — what we build, for whom, and what goes in a release" },
|
|
15
16
|
{ id: "engineering", label: "Engineering — architecture, and changes that cross team lines" },
|
|
@@ -26,6 +27,11 @@ export const WAKE_OPTIONS = [
|
|
|
26
27
|
{ id: "approved", label: "Only people I approve — I am asked the first time each one's request needs this machine, or approve ahead with pantheon wake allow <name>; invites never grant it." },
|
|
27
28
|
{ id: "no", label: "No — this machine only works while I am at it." },
|
|
28
29
|
];
|
|
30
|
+
export const AUTOPILOT_WAKE_OFF = "Autopilot needs your worker; with wake off nothing takes teammates' requests — to turn it on: pantheon setup --wake anyone (or approved)";
|
|
31
|
+
export const MODE_OPTIONS = [
|
|
32
|
+
{ id: "autopilot", label: `${MODE_LABELS.autopilot} — my agent takes every teammate's request at once and finishes it on its own, even while I work, and asks me only when it truly can't go on. It runs beside my own agent window on the same plan, so the two share its usage limits.` },
|
|
33
|
+
{ id: "here", label: `${MODE_LABELS.here} — requests wait while I'm at my computer, and my agent takes them when I'm away.` },
|
|
34
|
+
];
|
|
29
35
|
export const ALERT_OPTIONS = [
|
|
30
36
|
{ id: "decisions", label: "Only decisions that need me (recommended) — never for ordinary agent traffic." },
|
|
31
37
|
{ id: "deliveries", label: "Decisions, and when a teammate delivers work to me." },
|
|
@@ -72,18 +78,58 @@ export function detectBaseBranch(project) {
|
|
|
72
78
|
const cur = git("rev-parse", "--abbrev-ref", "HEAD");
|
|
73
79
|
return cur && cur !== "HEAD" ? cur : null;
|
|
74
80
|
}
|
|
75
|
-
export
|
|
81
|
+
export const ALERT_WORDS = {
|
|
82
|
+
decisions: "decisions that need you",
|
|
83
|
+
deliveries: "decisions and deliveries",
|
|
84
|
+
worker: "decisions, deliveries and your worker's finished runs",
|
|
85
|
+
none: "none",
|
|
86
|
+
};
|
|
87
|
+
export function guideChanges(before, a, o) {
|
|
88
|
+
const out = [];
|
|
89
|
+
const b = before.answers;
|
|
90
|
+
if (a.mode !== undefined && a.mode !== before.mode)
|
|
91
|
+
out.push({ setting: "mode", from: before.mode, to: a.mode });
|
|
92
|
+
if (a.wake !== b.wake)
|
|
93
|
+
out.push({ setting: "wake", from: b.wake, to: a.wake });
|
|
94
|
+
if ((!before.commandsDecided || a.commands !== b.commands) && !(a.wake === "no" && !a.commands && b.wake !== "no"))
|
|
95
|
+
out.push({ setting: "commands", from: before.commandsDecided ? (b.commands ? "on" : "off") : "not chosen", to: a.commands ? "on" : "off" });
|
|
96
|
+
if (a.unsandboxed !== undefined && a.unsandboxed !== before.unsandboxed)
|
|
97
|
+
out.push({ setting: "unsandboxed", ...(before.awayAgents?.length ? { about: andList(before.awayAgents) } : {}), from: before.unsandboxed ? "on" : "off", to: a.unsandboxed ? "on" : "off" });
|
|
98
|
+
for (const d of a.decides.filter((x) => !b.decides.includes(x)))
|
|
99
|
+
out.push({ setting: "decides", about: d, from: "agents", to: "yours" });
|
|
100
|
+
if (o.replaceDecides)
|
|
101
|
+
for (const d of b.decides.filter((x) => !a.decides.includes(x)))
|
|
102
|
+
out.push({ setting: "decides", about: d, from: "yours", to: "agents" });
|
|
103
|
+
if (a.notifications !== b.notifications)
|
|
104
|
+
out.push({ setting: "alerts", from: ALERT_WORDS[b.notifications], to: ALERT_WORDS[a.notifications] });
|
|
105
|
+
if (a.persona && o.project && !before.playbook && a.wake !== "no")
|
|
106
|
+
out.push({ setting: "persona", about: "playbook", from: "your setup alone", to: "a starter playbook" });
|
|
107
|
+
if (a.base && a.base !== (before.base ?? undefined))
|
|
108
|
+
out.push({ setting: "base", from: before.base ?? "the branch it uses now", to: a.base });
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
export function questionnaire(o = {}) {
|
|
76
112
|
const opt = (flag, id, label) => ` ${label} → --${flag} ${id}`;
|
|
113
|
+
const who = o.name || "your human";
|
|
114
|
+
const intro = o.setUp ? [
|
|
115
|
+
`THIS MACHINE IS SET UP ALREADY. Do not change ${who}'s setup yourself, and take no defaults for them.`,
|
|
116
|
+
`Only if ${who} asked you to change something: pass exactly that answer, nothing else. Anything not passed stays`,
|
|
117
|
+
`as it is. The change is not made by your command — ${who} is asked to confirm it on this computer, and`,
|
|
118
|
+
"`pantheon changes` shows what waits. What is set now: pantheon status, pantheon mode, pantheon policy.",
|
|
119
|
+
] : [
|
|
120
|
+
"Only 3, 4 and 10 need the person. The rest have defaults you may take and say out loud:",
|
|
121
|
+
" --wake anyone --commands yes --decides none --alerts decisions --playbook yes --base <what origin calls its default> --approve-all",
|
|
122
|
+
"--wake anyone (the default) means any teammate the team lets wake workers can start a run here while they are away; --commands yes (the default in a repo) means that run may run tests, commit and push to its own branch.",
|
|
123
|
+
"Codex, Cursor and Copilot answer those requests too, so teammates are never kept waiting; --unsandboxed no makes them wait for the person instead.",
|
|
124
|
+
`Tell the person plainly: ${unsandboxedRisk()}`,
|
|
125
|
+
"--commands, --playbook and --base are about a repo: skip them where nothing bound here is one (a docs folder), and say so.",
|
|
126
|
+
];
|
|
77
127
|
return [
|
|
78
128
|
"pantheon setup — the questions, and the flag for each answer.",
|
|
79
129
|
"Ask your human in plain words, then pass the answers as flags — to `pantheon setup --yes`, or straight to",
|
|
80
130
|
"`pantheon start` / `pantheon join`, which apply them the moment the team exists.",
|
|
81
131
|
"",
|
|
82
|
-
|
|
83
|
-
" --wake anyone --commands yes --decides none --alerts decisions --playbook yes --base <what origin calls its default> --approve-all",
|
|
84
|
-
"--wake anyone (the default) means any teammate the team lets wake workers can start a run here while they are away; --commands yes (the default in a repo) means that run may run tests, commit and push to its own branch.",
|
|
85
|
-
"Codex, Cursor and Copilot answer those requests too, so teammates are never kept waiting; --unsandboxed no makes them wait for the person instead.",
|
|
86
|
-
"--commands, --playbook and --base are about a repo: skip them where nothing bound here is one (a docs folder), and say so.",
|
|
132
|
+
...intro,
|
|
87
133
|
"",
|
|
88
134
|
"1. While they're away, may teammates hand work to this machine? (their agent runs here on its own,",
|
|
89
135
|
" in a separate copy of the repo, and delivers on a branch for review)",
|
|
@@ -111,8 +157,12 @@ export function questionnaire() {
|
|
|
111
157
|
" These are switches: pass --approve-all or --ask-before-sending with no value. Either way the install",
|
|
112
158
|
" output prints the exact line written to ~/.codex/config.toml, and pantheon leave removes it.",
|
|
113
159
|
"",
|
|
160
|
+
"10. Who finishes teammates' requests? Ask this one plainly; there is no default to take for them",
|
|
161
|
+
" (a machine that never chose stays on \"here\").",
|
|
162
|
+
...MODE_OPTIONS.map((o) => opt("mode", o.id, o.label)),
|
|
163
|
+
"",
|
|
114
164
|
"Example: pantheon setup --yes --wake approved --commands yes --name \"Praneet Sinha\" --title Founder \\",
|
|
115
|
-
" --decides deployment --alerts decisions --playbook yes --base main",
|
|
165
|
+
" --decides deployment --alerts decisions --playbook yes --base main --mode autopilot",
|
|
116
166
|
].join("\n");
|
|
117
167
|
}
|
|
118
168
|
export function parseSetupFlags(argv) {
|
|
@@ -123,6 +173,13 @@ export function parseSetupFlags(argv) {
|
|
|
123
173
|
return undefined; if (/^(yes|true|on|1)$/i.test(v))
|
|
124
174
|
return true; if (/^(no|false|off|0)$/i.test(v))
|
|
125
175
|
return false; errors.push(`--${name} takes yes or no, not "${v}"`); return undefined; };
|
|
176
|
+
const mode = val("mode");
|
|
177
|
+
if (mode !== undefined) {
|
|
178
|
+
if (WORK_MODES.includes(mode))
|
|
179
|
+
preset.mode = mode;
|
|
180
|
+
else
|
|
181
|
+
errors.push(`--mode takes ${WORK_MODES.join(" or ")}, not "${mode}"`);
|
|
182
|
+
}
|
|
126
183
|
const wake = val("wake");
|
|
127
184
|
if (wake !== undefined) {
|
|
128
185
|
if (WAKE_OPTIONS.some((o) => o.id === wake))
|
|
@@ -218,14 +275,21 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
218
275
|
a.commands = false;
|
|
219
276
|
a.persona = false;
|
|
220
277
|
}
|
|
278
|
+
const setUp = !!ctx.setUp;
|
|
279
|
+
const playbookDir = ctx.project ? personaDir("project", ctx.project, deps.home) : null;
|
|
280
|
+
const playbookExists = !!playbookDir && existsSync(join(playbookDir, "default.md"));
|
|
221
281
|
const applied = [], warnings = [];
|
|
222
282
|
const awayAgents = deps.unsandboxedAgents?.() ?? [];
|
|
283
|
+
let riskSaid = false;
|
|
223
284
|
if (io) {
|
|
224
285
|
io.say("A few questions, then one screen of defaults. Enter keeps the suggested answer.\n");
|
|
225
286
|
a.name = (await io.ask("Your name, as teammates will see it", d.name)).trim() || d.name;
|
|
226
287
|
const known = TITLE_OPTIONS.findIndex((t) => t.toLowerCase() === d.title.toLowerCase());
|
|
227
288
|
const t = await io.choose("Your role, in a word — it goes on the team directory", TITLE_OPTIONS, known >= 0 ? known : d.title || !ctx.founder ? TITLE_OPTIONS.length - 1 : 0);
|
|
228
289
|
a.title = t === TITLE_OPTIONS.length - 1 ? (await io.ask("Your role", d.title)).trim() || d.title || "Member" : TITLE_OPTIONS[t];
|
|
290
|
+
const nowMode = preset.mode ?? effectiveMode(loadPolicy(deps.policyHome));
|
|
291
|
+
const m = await io.choose("Who finishes teammates' requests?", MODE_OPTIONS.map((o) => o.label), Math.max(0, MODE_OPTIONS.findIndex((o) => o.id === nowMode)));
|
|
292
|
+
a.mode = MODE_OPTIONS[m].id;
|
|
229
293
|
const askCommands = async () => {
|
|
230
294
|
const undecided = profile.agent.allow_bash === undefined && preset.commands === undefined;
|
|
231
295
|
const c = await io.choose("Teammates can hand work to this machine while you're away. It runs in a separate copy of the repo and delivers on a branch you review. May a run also run your tests, commit and push, so the work arrives ready to review?", ["Yes — run tests, commit, and push work for review (recommended)",
|
|
@@ -235,7 +299,7 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
235
299
|
const detected = ctx.project && deps.setRepoBase ? detectBaseBranch(ctx.project) : null;
|
|
236
300
|
const suggestedBase = detected ? (preset.base ?? detected) : undefined;
|
|
237
301
|
if (a.wake !== "no" && ctx.project)
|
|
238
|
-
a.persona = preset.persona ?? true;
|
|
302
|
+
a.persona = preset.persona ?? (setUp ? playbookExists : true);
|
|
239
303
|
const shortAlert = (id) => ALERT_OPTIONS.find((o) => o.id === id).label.split(" — ")[0].replace(/ \(recommended\)/, "");
|
|
240
304
|
io.say("\nThe rest has defaults. Change them now, or any time with `pantheon setup`:");
|
|
241
305
|
io.say(` • Wake: ${a.wake === "no" ? "off — this machine only works while you are at it"
|
|
@@ -253,9 +317,12 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
253
317
|
if (a.wake !== "no" && serves?.repos) {
|
|
254
318
|
io.say(` • Commands: ${a.commands ? "work runs your tests, commits, and pushes to its own branch, so it arrives ready for your review" : "edits and answers only — turn commands on to have work arrive tested and ready to review"}`);
|
|
255
319
|
if (awayAgents.length && unsandboxedAllowed(loadPolicy(deps.policyHome))) {
|
|
256
|
-
io.say(` • Agent: ${andList(awayAgents)} ${awayAgents.length === 1 ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you`);
|
|
320
|
+
io.say(` • Agent: ${andList(awayAgents)} ${awayAgents.length === 1 ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you.\n ${unsandboxedRisk(andList(awayAgents))}`);
|
|
321
|
+
riskSaid = true;
|
|
257
322
|
}
|
|
258
323
|
}
|
|
324
|
+
if (a.mode === "autopilot")
|
|
325
|
+
io.say(` • Autopilot: your agent takes teammates' requests even while you work. ${AUTOPILOT_PLAN_NOTE}`);
|
|
259
326
|
io.say(` • Alerts: ${shortAlert(a.notifications).toLowerCase()}`);
|
|
260
327
|
io.say(` • Approval: ${a.approval === "approve"
|
|
261
328
|
? "your agent sends to teammates in your name without asking each time (Claude Code, Cursor, Codex, and Kiro's IDE and pantheon agent; Copilot asks once per tool per folder)"
|
|
@@ -267,7 +334,7 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
267
334
|
io.say(` • Base branch: ${suggestedBase}${suggestedBase === detected ? " (what origin calls its default)" : ""}`);
|
|
268
335
|
const keep = await io.choose("Keep these?", ["Keep them (recommended)", "Change some"], 0);
|
|
269
336
|
if (keep === 0) {
|
|
270
|
-
if (suggestedBase)
|
|
337
|
+
if (suggestedBase && (!setUp || preset.base))
|
|
271
338
|
a.base = suggestedBase;
|
|
272
339
|
}
|
|
273
340
|
else {
|
|
@@ -280,7 +347,7 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
280
347
|
else if (serves?.repos) {
|
|
281
348
|
await askCommands();
|
|
282
349
|
if (ctx.project)
|
|
283
|
-
a.persona = preset.persona ?? true;
|
|
350
|
+
a.persona = preset.persona ?? (setUp ? playbookExists : true);
|
|
284
351
|
}
|
|
285
352
|
const picks = await io.chooseMany("Which of these do you decide personally? Agents — yours and your teammates' — will stop and ask you before acting on them. Pick any number, or none.", DECISION_AREAS.map((x) => x.label), a.decides.map((id) => DECISION_AREAS.findIndex((x) => x.id === id)).filter((i) => i >= 0));
|
|
286
353
|
a.decides = [...new Set(picks.map((i) => DECISION_AREAS[i].id))];
|
|
@@ -292,12 +359,25 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
292
359
|
}
|
|
293
360
|
if (suggestedBase) {
|
|
294
361
|
const b = await io.choose("Which branch should your worker start from, and deliveries be checked against? Usually the branch this project deploys or releases from.", [`${suggestedBase}${suggestedBase === detected ? " (what origin calls its default)" : ""}`, "A different branch"], 0);
|
|
295
|
-
a.base = b === 0 ? suggestedBase : ((await io.ask("Branch name", suggestedBase)).trim() || suggestedBase);
|
|
362
|
+
a.base = b === 0 ? (setUp && !preset.base ? undefined : suggestedBase) : ((await io.ask("Branch name", suggestedBase)).trim() || suggestedBase);
|
|
296
363
|
}
|
|
297
364
|
const ap = await io.choose("Should your agent ask you before each message it sends to a teammate in your name? Reading the board and waiting for peers never prompt either way.", ["No — coordinate for me without stopping to ask (recommended)", "Yes — show me each send, goal and claim first"], a.approval === "approve" ? 0 : 1);
|
|
298
365
|
a.approval = ap === 0 ? "approve" : "ask-before-sending";
|
|
299
366
|
}
|
|
300
367
|
}
|
|
368
|
+
{
|
|
369
|
+
const pol = loadPolicy(deps.policyHome);
|
|
370
|
+
const before = { answers: guideDefaults(profile, ctx.cfg), mode: effectiveMode(pol), unsandboxed: unsandboxedAllowed(pol),
|
|
371
|
+
commandsDecided: profile.agent.allow_bash !== undefined, playbook: playbookExists, base: ctx.base ?? null, awayAgents };
|
|
372
|
+
const changes = guideChanges(before, a, { replaceDecides: !!io || preset.decides !== undefined, project: !!ctx.project });
|
|
373
|
+
const same = [
|
|
374
|
+
...(a.mode !== undefined && a.mode === before.mode ? [{ setting: "mode", from: a.mode, to: a.mode }] : []),
|
|
375
|
+
...(a.wake === before.answers.wake ? [{ setting: "wake", from: a.wake, to: a.wake }] : []),
|
|
376
|
+
...(a.notifications === before.answers.notifications ? [{ setting: "alerts", from: ALERT_WORDS[a.notifications], to: ALERT_WORDS[a.notifications] }] : []),
|
|
377
|
+
];
|
|
378
|
+
if (deps.gate && (changes.length || same.length) && !(await deps.gate([...changes, ...same], a)))
|
|
379
|
+
return { answers: a, applied: [], warnings: [], held: true, changes };
|
|
380
|
+
}
|
|
301
381
|
let next = a.title ? applyProfileInit(profile, { name: a.name, title: a.title }) : { ...profile, human: { ...profile.human, display_name: a.name } };
|
|
302
382
|
const vague = dropCatchAllClaims(next);
|
|
303
383
|
next = vague.profile;
|
|
@@ -341,6 +421,27 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
341
421
|
warnings.push(`profile saved but not published (${e.message}) — run \`pantheon profile publish\` when the relay is reachable`);
|
|
342
422
|
}
|
|
343
423
|
}
|
|
424
|
+
if (a.mode !== undefined) {
|
|
425
|
+
if (inWokenRun())
|
|
426
|
+
warnings.push("a woken run cannot change how teammates' requests are handled here — a person has to choose it");
|
|
427
|
+
else {
|
|
428
|
+
try {
|
|
429
|
+
const pol = loadPolicy(deps.policyHome);
|
|
430
|
+
if (pol.mode !== a.mode) {
|
|
431
|
+
pol.mode = a.mode;
|
|
432
|
+
savePolicy(pol, deps.policyHome);
|
|
433
|
+
}
|
|
434
|
+
if (a.mode === "autopilot" && a.wake === "no")
|
|
435
|
+
warnings.push(AUTOPILOT_WAKE_OFF);
|
|
436
|
+
applied.push(a.mode === "autopilot"
|
|
437
|
+
? `mode: autopilot ("${MODE_LABELS.autopilot}"): your worker takes every teammate's request at once and finishes it on its own, even while you work. ${AUTOPILOT_PLAN_NOTE} (Back to waiting for you: pantheon setup --mode here)`
|
|
438
|
+
: `mode: here ("${MODE_LABELS.here}"): teammates' requests wait while you're at your computer, and your worker takes them when you're away (Everything to your agent: pantheon setup --mode autopilot)`);
|
|
439
|
+
}
|
|
440
|
+
catch (e) {
|
|
441
|
+
warnings.push(`could not save how teammates' requests are handled: ${e.message}`);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
344
445
|
const wiring = deps.applyAgentWiring ?? ((ap) => installForUser(ap, undefined, { direct: true }).map((t) => ({ tool: t.tool, status: t.status })));
|
|
345
446
|
try {
|
|
346
447
|
const rows = wiring(a.approval);
|
|
@@ -376,7 +477,8 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
376
477
|
}
|
|
377
478
|
else if (serves) {
|
|
378
479
|
try {
|
|
379
|
-
|
|
480
|
+
const now = (deps.installedArgs ?? (deps.installService ? () => null : installedServiceArgs))("worker");
|
|
481
|
+
install("worker", serves.path, keepServiceFlags(now, a.commands ? ["--allow-bash"] : [], ["--allow-bash"]));
|
|
380
482
|
applied.push(!serves.repos
|
|
381
483
|
? "worker on — a teammate's question is answered from your folder, which a run reads and never changes; anything it writes is a draft for you"
|
|
382
484
|
: a.commands
|
|
@@ -407,7 +509,7 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
407
509
|
revoke(pol, "unsandboxed_runs");
|
|
408
510
|
savePolicy(pol, deps.policyHome);
|
|
409
511
|
applied.push(a.unsandboxed
|
|
410
|
-
? `${names} ${one ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you — to have them wait for you instead: pantheon setup --unsandboxed no`
|
|
512
|
+
? `${names} ${one ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you — to have them wait for you instead: pantheon setup --unsandboxed no${riskSaid ? "" : `. ${unsandboxedRisk(names)}`}`
|
|
411
513
|
: `${names} ${one ? "leaves" : "leave"} teammates' requests for you to pick up when you're back — to have ${names} answer them while you're away: pantheon setup --unsandboxed yes`);
|
|
412
514
|
}
|
|
413
515
|
catch (e) {
|
|
@@ -417,7 +519,7 @@ export async function runGuide(io, ctx, deps = {}, preset = {}) {
|
|
|
417
519
|
}
|
|
418
520
|
else if (awayAgents.length && a.wake !== "no" && serves?.repos) {
|
|
419
521
|
if (unsandboxedAllowed(loadPolicy(deps.policyHome)))
|
|
420
|
-
applied.push(`${names} ${one ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you — to have them wait for you instead: pantheon setup --unsandboxed no`);
|
|
522
|
+
applied.push(`${names} ${one ? "answers" : "answer"} teammates' requests while you're away, so nobody waits on you — to have them wait for you instead: pantheon setup --unsandboxed no${riskSaid ? "" : `. ${unsandboxedRisk(names)}`}`);
|
|
421
523
|
}
|
|
422
524
|
const waitIn = mac ? "pantheon status, approvals, and the menu bar" : "pantheon status and pantheon approvals";
|
|
423
525
|
const chosenAlerts = ALERT_OPTIONS.find((o) => o.id === a.notifications).label.split(" — ")[0].replace(/ \(recommended\)/, "");
|
package/dist/spend.js
CHANGED
|
@@ -96,17 +96,32 @@ export function recentRuns(ms, home, limit = 12, only) {
|
|
|
96
96
|
.filter((r) => !only || (!!r.space && teams.includes(r.space) && (!r.member || r.member === only.member)))
|
|
97
97
|
.sort((a, b) => b.at - a.at).slice(0, limit);
|
|
98
98
|
}
|
|
99
|
+
function freeAt(ms, cap, home) {
|
|
100
|
+
if (cap <= 0)
|
|
101
|
+
return undefined;
|
|
102
|
+
const from = Date.now() - ms;
|
|
103
|
+
const ats = read(home).runs.filter((r) => r.at > from).map((r) => r.at).sort((a, b) => a - b);
|
|
104
|
+
return ats.length >= cap ? ats[ats.length - cap] + ms : undefined;
|
|
105
|
+
}
|
|
106
|
+
function bothFree(caps, home) {
|
|
107
|
+
if (caps.perHour <= 0 || caps.perDay <= 0)
|
|
108
|
+
return undefined;
|
|
109
|
+
const at = [freeAt(3_600_000, caps.perHour, home), freeAt(86_400_000, caps.perDay, home)].filter((x) => x !== undefined);
|
|
110
|
+
return at.length ? Math.max(...at) : undefined;
|
|
111
|
+
}
|
|
99
112
|
export function allowed(caps, home) {
|
|
100
113
|
const book = read(home);
|
|
101
114
|
if (book.broken)
|
|
102
115
|
return { ok: false, broken: true, why: `the spend book ${bookPath(home)} cannot be read (${book.broken}) — repair or delete it; unattended runs wait until then` };
|
|
103
116
|
const hour = since(3_600_000, home).runs;
|
|
104
117
|
if (hour >= caps.perHour) {
|
|
105
|
-
|
|
118
|
+
const at = bothFree(caps, home);
|
|
119
|
+
return { ok: false, why: `${hour} runs in the last hour, cap is ${caps.perHour}`, cap: { per: "hour", n: caps.perHour }, ...(at ? { freeAt: at } : {}) };
|
|
106
120
|
}
|
|
107
121
|
const day = since(86_400_000, home).runs;
|
|
108
122
|
if (day >= caps.perDay) {
|
|
109
|
-
|
|
123
|
+
const at = bothFree(caps, home);
|
|
124
|
+
return { ok: false, why: `${day} runs in the last 24h, cap is ${caps.perDay}`, cap: { per: "day", n: caps.perDay }, ...(at ? { freeAt: at } : {}) };
|
|
110
125
|
}
|
|
111
126
|
return { ok: true };
|
|
112
127
|
}
|
package/dist/tray.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import { loadPolicy } from "./worker-policy.js";
|
|
1
|
+
import { effectiveMode, loadPolicy } from "./worker-policy.js";
|
|
2
|
+
import { askedByName, changeLabel, consequence, loadPending } from "./setup-changes.js";
|
|
3
|
+
import { buildUri, uriKey } from "./uri-handler.js";
|
|
4
|
+
import { stopFor } from "./run-control.js";
|
|
5
|
+
import { declinedLine, loadDeclined } from "./declined.js";
|
|
2
6
|
import { helperStale, installHelper } from "./helpers-build.js";
|
|
3
7
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
8
|
import { platform } from "node:os";
|
|
@@ -56,10 +60,10 @@ export function writeTrayCommands(home = CONFIG_DIR) {
|
|
|
56
60
|
return out;
|
|
57
61
|
}
|
|
58
62
|
const WEEK_MS = 7 * 24 * 3600_000;
|
|
59
|
-
const RANK = (i) => (i.kind === "decision" ? 0 : 1);
|
|
63
|
+
const RANK = (i) => (i.kind === "decision" || i.kind === "change" ? 0 : 1);
|
|
60
64
|
export const boardOrder = (a, b) => RANK(a) - RANK(b) || a.when - b.when;
|
|
61
65
|
export function arrangeBoard(items, o) {
|
|
62
|
-
const fallback = o.fallbackMs ?? LIMITS.workerFallbackMs;
|
|
66
|
+
const fallback = o.autopilot && o.workerRunning ? Infinity : o.fallbackMs ?? LIMITS.workerFallbackMs;
|
|
63
67
|
const out = items.map((i) => ({ ...i }));
|
|
64
68
|
const spaceOf = (i) => i.space ?? "";
|
|
65
69
|
const asked = new Map();
|
|
@@ -67,7 +71,7 @@ export function arrangeBoard(items, o) {
|
|
|
67
71
|
if (d.kind === "decision" && d.about && (d.who === "your agent" || d.choices))
|
|
68
72
|
asked.set(`${spaceOf(d)}|${d.about}`, d);
|
|
69
73
|
for (const i of out) {
|
|
70
|
-
if (i.kind === "decision") {
|
|
74
|
+
if (i.kind === "decision" || i.kind === "change") {
|
|
71
75
|
i.lane = "now";
|
|
72
76
|
continue;
|
|
73
77
|
}
|
|
@@ -75,6 +79,10 @@ export function arrangeBoard(items, o) {
|
|
|
75
79
|
i.lane = "waiting";
|
|
76
80
|
continue;
|
|
77
81
|
}
|
|
82
|
+
if (i.stopped || i.declined) {
|
|
83
|
+
i.lane = "now";
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
78
86
|
const d = i.ref ? asked.get(`${spaceOf(i)}|${i.ref}`) : undefined;
|
|
79
87
|
if (d) {
|
|
80
88
|
d.context ??= i.headline;
|
|
@@ -172,6 +180,34 @@ async function signedObligations(cfg, removed = null) {
|
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
export async function trayStatus(cfg = load(), f = loadAll()) {
|
|
183
|
+
return withLocal(await trayStatusAll(cfg, f));
|
|
184
|
+
}
|
|
185
|
+
export function withLocal(st, _home = CONFIG_DIR) {
|
|
186
|
+
try {
|
|
187
|
+
const list = loadPending();
|
|
188
|
+
if (!list.length)
|
|
189
|
+
return st;
|
|
190
|
+
const cards = list.map((p) => {
|
|
191
|
+
const labels = p.changes.map((c) => changeLabel(c));
|
|
192
|
+
return {
|
|
193
|
+
id: p.id, kind: "change", lane: "now",
|
|
194
|
+
title: labels.length === 1 ? `Confirm a change to your setup: ${labels[0]}` : `Confirm ${labels.length} changes to your setup`,
|
|
195
|
+
headline: labels.length === 1 ? `Confirm a change to your setup: ${labels[0]}` : `Confirm ${labels.length} changes to your setup: ${labels.join("; ")}`,
|
|
196
|
+
detail: p.changes.map((c) => `${changeLabel(c)}\n${consequence(c)}`).join("\n\n"),
|
|
197
|
+
prompt: "", who: askedByName(p.asked_by), when: p.at,
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
...st,
|
|
202
|
+
...(st.configured ? { items: [...cards, ...(st.items ?? [])].sort(boardOrder) } : {}),
|
|
203
|
+
pending_changes: list.map((p) => ({ id: p.id, label: p.changes.map((c) => changeLabel(c)).join(", ").slice(0, 120) })),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
catch {
|
|
207
|
+
return st;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function trayStatusAll(cfg, f) {
|
|
175
211
|
const ms = Object.values(f?.spaces ?? {});
|
|
176
212
|
if (f && ms.length > 1) {
|
|
177
213
|
const parts = await Promise.all(ms.map((m) => trayStatusOne(configFor(f, m, null), m.id)));
|
|
@@ -252,6 +288,18 @@ async function trayStatusOne(cfg, membershipId) {
|
|
|
252
288
|
...(typeof o.about === "string" && o.about ? { about: o.about } : {}),
|
|
253
289
|
});
|
|
254
290
|
const owed = all.filter((o) => o.owner === cfg.member);
|
|
291
|
+
const autopilotNow = (() => { try {
|
|
292
|
+
return effectiveMode(loadPolicy()) === "autopilot";
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return false;
|
|
296
|
+
} })();
|
|
297
|
+
const declinedNow = autopilotNow ? (() => { try {
|
|
298
|
+
return loadDeclined();
|
|
299
|
+
}
|
|
300
|
+
catch {
|
|
301
|
+
return {};
|
|
302
|
+
} })() : {};
|
|
255
303
|
const waiting = all.filter((o) => o.owner !== cfg.member && o.owner !== `human:${cfg.member}`);
|
|
256
304
|
const items = [
|
|
257
305
|
...mineHuman.map((o) => {
|
|
@@ -262,7 +310,14 @@ async function trayStatusOne(cfg, membershipId) {
|
|
|
262
310
|
const wake = localWakeAsk(o.ref);
|
|
263
311
|
return { ...r, detail: o.body.replace(own, ""), decider: cfg.member, ...(choices ? { choices } : {}), ...(wake ? { wake } : {}) };
|
|
264
312
|
}),
|
|
265
|
-
...owed.map((o) =>
|
|
313
|
+
...owed.map((o) => {
|
|
314
|
+
const r = row(o, "owed", "you", owedPrompt(decisionTitle(o.body), o.goal));
|
|
315
|
+
const st = o.ref ? stopFor(o.ref) : null;
|
|
316
|
+
if (st)
|
|
317
|
+
return { ...r, stopped: st.how };
|
|
318
|
+
const dec = autopilotNow && o.ref ? declinedNow[o.ref] : undefined;
|
|
319
|
+
return dec ? { ...r, declined: dec.reason, detail: `${declinedLine(dec.reason)}.\n\n${r.detail}` } : r;
|
|
320
|
+
}),
|
|
266
321
|
...waiting.map((o) => {
|
|
267
322
|
const who = o.owner.replace(/^human:/, "");
|
|
268
323
|
const r0 = row(o, "waiting", who, waitingPrompt(who, decisionTitle(o.body), o.goal));
|
|
@@ -275,7 +330,23 @@ async function trayStatusOne(cfg, membershipId) {
|
|
|
275
330
|
}),
|
|
276
331
|
];
|
|
277
332
|
const workerRunning = workerProc().running;
|
|
278
|
-
const board = arrangeBoard(items, { now: Date.now(), workerRunning
|
|
333
|
+
const board = arrangeBoard(items, { now: Date.now(), workerRunning, autopilot: (() => { try {
|
|
334
|
+
return effectiveMode(loadPolicy()) === "autopilot";
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
return false;
|
|
338
|
+
} })() });
|
|
339
|
+
const key = process.platform === "win32" ? (() => { try {
|
|
340
|
+
return uriKey(CONFIG_DIR);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
return null;
|
|
344
|
+
} })() : null;
|
|
345
|
+
for (const i of board) {
|
|
346
|
+
if (i.lane !== "handling" || i.kind !== "owed" || i.promise || !i.ref || !/^a_/.test(i.ref))
|
|
347
|
+
continue;
|
|
348
|
+
i.run = { ref: i.ref, ...(key ? { takeover: buildUri("work", { ref: i.ref, do: "takeover", space: cfg.space }, key) ?? undefined, stop: buildUri("work", { ref: i.ref, do: "stop", space: cfg.space }, key) ?? undefined } : {}) };
|
|
349
|
+
}
|
|
279
350
|
return {
|
|
280
351
|
configured: true,
|
|
281
352
|
version: VERSION,
|
package/dist/uri-handler.js
CHANGED
|
@@ -3,12 +3,15 @@ import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
|
3
3
|
import { appendFileSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { join, win32 } from "node:path";
|
|
5
5
|
export const URI_SCHEME = "pantheon";
|
|
6
|
-
export const URI_HOSTS = ["board", "done", "explain", "details"];
|
|
6
|
+
export const URI_HOSTS = ["board", "done", "explain", "details", "change", "work", "changes"];
|
|
7
7
|
const FORMS = {
|
|
8
8
|
board: { required: [], optional: ["focus"] },
|
|
9
9
|
done: { required: ["decision", "k"], optional: ["act", "space"] },
|
|
10
10
|
explain: { required: ["decision", "k"], optional: ["act", "space"] },
|
|
11
11
|
details: { required: ["act", "k"], optional: ["decision", "space"] },
|
|
12
|
+
change: { required: ["id", "answer", "k"], optional: [] },
|
|
13
|
+
work: { required: ["ref", "do", "k"], optional: ["space"] },
|
|
14
|
+
changes: { required: [], optional: [] },
|
|
12
15
|
};
|
|
13
16
|
export const URI_VALUE = {
|
|
14
17
|
decision: /^o_[a-z0-9]{6,48}$/,
|
|
@@ -16,6 +19,10 @@ export const URI_VALUE = {
|
|
|
16
19
|
space: /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,
|
|
17
20
|
k: /^[0-9a-f]{32}$/,
|
|
18
21
|
focus: /^[ao]_[A-Za-z0-9]{6,48}$/,
|
|
22
|
+
id: /^c_[0-9a-f]{8}$/,
|
|
23
|
+
answer: /^(approve|keep)$/,
|
|
24
|
+
ref: /^(cont:)?a_[A-Za-z0-9]{6,48}$/,
|
|
25
|
+
do: /^(stop|takeover)$/,
|
|
19
26
|
};
|
|
20
27
|
export const MAX_URI = 400;
|
|
21
28
|
function canonical(host, params) {
|
|
@@ -62,10 +69,10 @@ export function parseUri(raw) {
|
|
|
62
69
|
return { ok: false, why: "the link holds characters a Pantheon link never has" };
|
|
63
70
|
const m = /^pantheon:\/\/([A-Za-z]+)\/?(?:\?(.*))?$/i.exec(raw);
|
|
64
71
|
if (!m)
|
|
65
|
-
return { ok: false, why: "not a Pantheon alert link (expected pantheon://board, done, explain or
|
|
72
|
+
return { ok: false, why: "not a Pantheon alert link (expected pantheon://board, done, explain, details, change, work or changes)" };
|
|
66
73
|
const host = m[1].toLowerCase();
|
|
67
74
|
if (!URI_HOSTS.includes(host))
|
|
68
|
-
return { ok: false, why: `"${m[1]}" is not something a Pantheon link can do (board, done, explain or
|
|
75
|
+
return { ok: false, why: `"${m[1]}" is not something a Pantheon link can do (board, done, explain, details, change, work or changes)` };
|
|
69
76
|
const form = FORMS[host];
|
|
70
77
|
const params = {};
|
|
71
78
|
const query = m[2];
|
|
@@ -118,6 +125,10 @@ export function hudActionFor(p) {
|
|
|
118
125
|
return { action: "open", decision: decision, ...(act ? { act } : {}), ...extra };
|
|
119
126
|
if (p.host === "details")
|
|
120
127
|
return { action: "details", act: act, ...(decision ? { decision } : {}), ...extra };
|
|
128
|
+
if (p.host === "change")
|
|
129
|
+
return { action: "change", change: p.params.id, answer: p.params.answer, by: "alert" };
|
|
130
|
+
if (p.host === "work")
|
|
131
|
+
return { action: "run", ref: p.params.ref, run: p.params.do, ...extra };
|
|
121
132
|
return null;
|
|
122
133
|
}
|
|
123
134
|
export const uriKeyPath = (home) => join(home, "uri-key");
|
|
@@ -198,6 +209,12 @@ export async function handleUri(args, d) {
|
|
|
198
209
|
if (!verifyUri(p, uriKey(d.home, false))) {
|
|
199
210
|
return refuse("this link was not made by Pantheon on this machine (it acts only on links from its own alerts)", describeUri(p));
|
|
200
211
|
}
|
|
212
|
+
if (p.host === "changes") {
|
|
213
|
+
logUri(d.home, "changes: review", now());
|
|
214
|
+
const code = d.runReview ? await d.runReview() : 1;
|
|
215
|
+
await d.pause();
|
|
216
|
+
return code;
|
|
217
|
+
}
|
|
201
218
|
if (p.host === "board") {
|
|
202
219
|
if (d.openBoard) {
|
|
203
220
|
let ok = false;
|
package/dist/worker-policy.js
CHANGED
|
@@ -4,6 +4,32 @@ import { CONFIG_PATH } from "./config.js";
|
|
|
4
4
|
import { trustWrite } from "./home-guard.js";
|
|
5
5
|
import { parseJsonText } from "./text-file.js";
|
|
6
6
|
import { compareVersions, isVersion } from "./installer.js";
|
|
7
|
+
export const WORK_MODES = ["autopilot", "here"];
|
|
8
|
+
export const MODE_LABELS = {
|
|
9
|
+
autopilot: "My agent handles everything",
|
|
10
|
+
here: "I answer when I'm here",
|
|
11
|
+
};
|
|
12
|
+
export const AUTOPILOT_PLAN_NOTE = "In autopilot your worker and your own Claude window can run at the same time on the same Claude plan and share its usage limits.";
|
|
13
|
+
export function effectiveMode(p) {
|
|
14
|
+
return p?.mode === "autopilot" ? "autopilot" : "here";
|
|
15
|
+
}
|
|
16
|
+
export function currentMode(home) {
|
|
17
|
+
try {
|
|
18
|
+
return effectiveMode(loadPolicy(home));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return "here";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function parseMode(raw) {
|
|
25
|
+
const s = String(raw ?? "").trim().toLowerCase();
|
|
26
|
+
return WORK_MODES.includes(s) ? s : null;
|
|
27
|
+
}
|
|
28
|
+
export function describeMode(m) {
|
|
29
|
+
return m === "autopilot"
|
|
30
|
+
? `autopilot ("${MODE_LABELS.autopilot}"): your worker takes teammates' requests at once, even while you work, and finishes them on its own`
|
|
31
|
+
: `here ("${MODE_LABELS.here}"): teammates' requests wait while you're at your computer, and your worker takes them when you're away`;
|
|
32
|
+
}
|
|
7
33
|
export const IDLE_SECONDS = { default: 120, min: 0, max: 900 };
|
|
8
34
|
export function parseIdleSeconds(raw) {
|
|
9
35
|
if (raw === undefined || raw === null)
|
|
@@ -129,6 +155,8 @@ export function loadPolicy(home) {
|
|
|
129
155
|
? { upgradeHeld: { version: raw.upgradeHeld.version, node: raw.upgradeHeld.node, at: Number(raw.upgradeHeld.at) || 0, why: String(raw.upgradeHeld.why ?? "") } } : {}),
|
|
130
156
|
...(typeof raw.runMinutes === "number" && parseRunMinutes(raw.runMinutes) !== null ? { runMinutes: raw.runMinutes } : {}),
|
|
131
157
|
...(typeof raw.idleSeconds === "number" && parseIdleSeconds(raw.idleSeconds) !== null ? { idleSeconds: raw.idleSeconds } : {}),
|
|
158
|
+
...(typeof raw.mode === "string" && parseMode(raw.mode) ? { mode: raw.mode } : {}),
|
|
159
|
+
...(typeof raw.modeToldAt === "number" ? { modeToldAt: raw.modeToldAt } : {}),
|
|
132
160
|
};
|
|
133
161
|
}
|
|
134
162
|
catch {
|