@join-pantheon/cli 0.38.0 → 0.38.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 +10 -2
- package/bin/pantheon.js +16 -1
- package/bin/upgrade-guard.js +273 -0
- package/dist/agent-check.js +9 -0
- package/dist/agents.js +8 -1
- package/dist/claude-confine.js +1 -0
- package/dist/cli.js +103 -6
- package/dist/crash-loop.js +22 -5
- package/dist/file-lock.js +19 -4
- package/dist/flow-stats.js +1 -0
- package/dist/home-safety.js +5 -0
- package/dist/leftovers.js +1 -1
- package/dist/mcp.js +23 -6
- package/dist/notice.js +2 -1
- package/dist/notify.js +14 -2
- package/dist/pending.js +11 -3
- package/dist/plain.js +1 -0
- package/dist/relay.js +103 -22
- package/dist/setup-changes.js +8 -0
- package/dist/spend.js +12 -0
- package/dist/store.js +100 -2
- package/dist/upgrade-probation.js +130 -0
- package/dist/upgrade.js +13 -0
- package/dist/version-health.js +8 -1
- package/dist/win-host.js +2 -1
- package/dist/worker-policy.js +61 -1
- package/dist/worker.js +241 -13
- package/helper/macos/prebuilt/manifest.json +2 -2
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -410,7 +410,15 @@ peer's machine was answered in **31 seconds with no human involved**, and:
|
|
|
410
410
|
stop it even when both are installed; `pantheon doctor` starts it once and says what failed and the
|
|
411
411
|
likely fix, and teammates are told "its Linux sandbox can't start". Pantheon never runs commands
|
|
412
412
|
outside the sandbox instead
|
|
413
|
-
- one run at a time, capped at 12/hour by default
|
|
413
|
+
- one run at a time, capped at 12/hour by default, and at **12 runs per goal in 24 hours** so two
|
|
414
|
+
agents answering each other cannot use up your plan on one thread (`pantheon policy set goal-runs
|
|
415
|
+
<1-100>`); past it, that goal's requests and replies wait for you and are taken again once the
|
|
416
|
+
window frees — the teammate is told, nothing is dropped
|
|
417
|
+
- Claude Code runs use **Sonnet**, not the model you chose for your own windows (often Opus):
|
|
418
|
+
`pantheon policy set model <name|own|default>` (own = your own default). Codex, Cursor, Copilot
|
|
419
|
+
and Kiro keep their own default unless you name one with `--agent <id>`
|
|
420
|
+
- replies to questions your agent sent several teammates at once (a check-in) are handled in one run
|
|
421
|
+
as they come in, not one run each
|
|
414
422
|
- each run may take **60 minutes** by default; one still going then is stopped (with everything it
|
|
415
423
|
started), tried once more in the same worktree, then handed to you with the limit named. Set it
|
|
416
424
|
on your machine with `pantheon policy set run-minutes <5-180>` (read at the next run, so the
|
|
@@ -643,7 +651,7 @@ never in a prompt: a prompt can be argued out of its instructions.
|
|
|
643
651
|
| Invites | single-use, expiring | a leaked link is inert once redeemed or timed out |
|
|
644
652
|
| Claims | one session per obligation | parallel Conductor workspaces cannot duplicate work |
|
|
645
653
|
| Wake rights | `pantheon wake allow`, per machine; `--may-wake`, per member for the team | under "anyone" (the default): every peer the team lets wake; under "approved": only those you also approved here. Checked by the worker before a run starts, and by the relay at its claim |
|
|
646
|
-
| Run budget | 12/hour, 1 concurrent, 60 minutes each | a peer cannot drain your tokens; `pantheon policy set run-minutes` (5–180) |
|
|
654
|
+
| Run budget | 12/hour, 12 per goal a day, 1 concurrent, 60 minutes each, Sonnet for Claude Code | a peer cannot drain your tokens; `pantheon policy set run-minutes` (5–180), `goal-runs` (1–100), `model` |
|
|
647
655
|
| Personas | tighten-only | a persona file — even one a teammate committed — can lower caps and turn bash off, never the reverse |
|
|
648
656
|
| Signed acts | every act and goal, ed25519, since 0.31 | checked on each receiving machine against the key it pinned for the sender: the relay cannot forge, alter, re-file or replay a teammate's request without that machine noticing, and a worker runs only requests that check out. A teammate's changed key is held back until you confirm it (`pantheon trust`) |
|
|
649
657
|
| Worktree hygiene | no secrets on disk | credentials reach a woken run through its environment only; run scratch files are git-excluded |
|
package/bin/pantheon.js
CHANGED
|
@@ -37,9 +37,24 @@ if (!existsSync(entry)) {
|
|
|
37
37
|
process.exit(1);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
// After an upgrade, a release on probation is watched from here, before any of
|
|
41
|
+
// its own code loads, and the kept version is put back when it keeps failing
|
|
42
|
+
// (upgrade-guard.js, #124). The guard never stops pantheon starting.
|
|
43
|
+
let guarded = { entry, importFailed: () => null };
|
|
44
|
+
try { guarded = (await import("./upgrade-guard.js")).guard(root); } catch { /* no guard: start as before */ }
|
|
45
|
+
|
|
40
46
|
// A path is not a URL, and on Windows that is fatal rather than pedantic: an
|
|
41
47
|
// absolute POSIX path happens to work as an import specifier, while `D:\...`
|
|
42
48
|
// is read as the scheme "d:" and Node refuses it — so `pantheon --version`,
|
|
43
49
|
// the first command anyone runs, died with ERR_UNSUPPORTED_ESM_URL_SCHEME on
|
|
44
50
|
// every Windows machine. A real Windows runner is what said so.
|
|
45
|
-
|
|
51
|
+
try {
|
|
52
|
+
await import(pathToFileURL(guarded.entry).href);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
// A release whose code will not even load: counted, and when that was the
|
|
55
|
+
// last failure allowed, the version put back runs this command instead — in
|
|
56
|
+
// a process of its own, since this one has the failed release's modules
|
|
57
|
+
// loaded under the same paths (upgrade-guard.js rerun).
|
|
58
|
+
if (!guarded.importFailed()) throw e;
|
|
59
|
+
process.exitCode = (await import("./upgrade-guard.js")).rerun(process.argv.slice(1));
|
|
60
|
+
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The probation after an upgrade, and the way back (issue #124).
|
|
3
|
+
*
|
|
4
|
+
* A release that answers `--version` but whose worker throws at start, or can
|
|
5
|
+
* never finish the handshake, used to crash-loop on every machine that took it:
|
|
6
|
+
* launchd's KeepAlive, systemd's Restart=always and the Windows host restarted it
|
|
7
|
+
* for ever, and a broken worker can never fetch the release that fixes it.
|
|
8
|
+
*
|
|
9
|
+
* So the upgrade (src/upgrade.ts stagedManagedUpgrade) leaves a mark beside the
|
|
10
|
+
* runtime, runtime/upgrade-probation.json, naming the version it put in place
|
|
11
|
+
* and the one it kept in runtime/cli.prev. Until that version has been seen to
|
|
12
|
+
* work (a worker that reached the relay and stayed a minute: src/crash-loop.ts),
|
|
13
|
+
* or two hours have passed, this file watches it:
|
|
14
|
+
*
|
|
15
|
+
* - a worker run that ends with a code no stop gives (0, 129, 130, 143), or
|
|
16
|
+
* that vanished without ending (killed hard, crashed in native code), counts;
|
|
17
|
+
* - so does any command whose code cannot even be loaded, or that dies of an
|
|
18
|
+
* exception nobody caught (a Kiro prompt hook, say);
|
|
19
|
+
* - so does a worker that the relay answers but that never came online
|
|
20
|
+
* (src/upgrade-probation.ts writes `never_online`).
|
|
21
|
+
*
|
|
22
|
+
* FAILS_TO_ROLL_BACK of those, and the next `pantheon` to start puts the kept
|
|
23
|
+
* version back — two renames, as the upgrade made them — writes
|
|
24
|
+
* runtime/upgrade-held.json so that release is not taken again on this machine
|
|
25
|
+
* (a newer one is), and carries on as the version put back. Nothing here needs
|
|
26
|
+
* the relay, the network or any of the release's own compiled code: it runs in
|
|
27
|
+
* bin/pantheon.js, before dist/cli.js is loaded, from the stable entry the
|
|
28
|
+
* launcher, launchd, systemd and the Windows host all start.
|
|
29
|
+
*
|
|
30
|
+
* Anything that goes wrong in here is swallowed: the guard must never be the
|
|
31
|
+
* reason pantheon does not start.
|
|
32
|
+
*
|
|
33
|
+
* Plain JavaScript, no dependencies, only node: built-ins, sync file calls.
|
|
34
|
+
* The file names and fields are shared with src/upgrade-probation.ts (a test
|
|
35
|
+
* holds the two together).
|
|
36
|
+
*/
|
|
37
|
+
import { spawnSync } from "node:child_process";
|
|
38
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
39
|
+
import { homedir } from "node:os";
|
|
40
|
+
import { basename, dirname, join } from "node:path";
|
|
41
|
+
|
|
42
|
+
export const PROBATION_FILE = "upgrade-probation.json";
|
|
43
|
+
export const HELD_FILE = "upgrade-held.json";
|
|
44
|
+
export const PROBATION_MS = 2 * 3600_000;
|
|
45
|
+
export const FAILS_TO_ROLL_BACK = 3;
|
|
46
|
+
/** exit codes a run ends with when it was told to stop (crash-loop.ts EXPECTED_EXIT_CODES) */
|
|
47
|
+
export const EXPECTED_EXIT_CODES = [0, 129, 130, 143];
|
|
48
|
+
const KEEP_RUNS = 20;
|
|
49
|
+
|
|
50
|
+
const pidAlive = (pid) => {
|
|
51
|
+
if (!(pid > 0)) return false;
|
|
52
|
+
try { process.kill(pid, 0); return true; } catch (e) { return e && e.code === "EPERM"; }
|
|
53
|
+
};
|
|
54
|
+
const pause = (ms) => { try { Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms); } catch { /* */ } };
|
|
55
|
+
const readJson = (f) => { try { const v = JSON.parse(readFileSync(f, "utf8")); return v && typeof v === "object" ? v : null; } catch { return null; } };
|
|
56
|
+
const writeJson = (f, v) => {
|
|
57
|
+
const tmp = `${f}.${process.pid}.${Math.random().toString(16).slice(2, 10)}.tmp`;
|
|
58
|
+
writeFileSync(tmp, JSON.stringify(v, null, 2) + "\n", { mode: 0o600 });
|
|
59
|
+
try { renameSync(tmp, f); } catch (e) { try { rmSync(tmp, { force: true }); } catch { /* */ } throw e; }
|
|
60
|
+
};
|
|
61
|
+
const versionOf = (dir) => { const p = readJson(join(dir, "package.json")); return p && typeof p.version === "string" ? p.version : null; };
|
|
62
|
+
/** a whole CLI folder: its manifest, its entry and its build (upgrade.ts `whole`) */
|
|
63
|
+
const whole = (dir) => ["package.json", join("bin", "pantheon.js"), join("dist", "cli.js")].every((f) => existsSync(join(dir, f)));
|
|
64
|
+
const isTime = (v) => typeof v === "number" && Number.isFinite(v) && v > 0;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The runtime folder a managed install's CLI sits in, from the CLI's own folder,
|
|
68
|
+
* or null when this is any other install (npm's global, a checkout):
|
|
69
|
+
* <runtime>/node/lib/node_modules/@join-pantheon/cli macOS, Linux
|
|
70
|
+
* <runtime>\node\node_modules\@join-pantheon\cli Windows
|
|
71
|
+
*/
|
|
72
|
+
export function runtimeOf(pkgDir) {
|
|
73
|
+
const scope = dirname(pkgDir), nm = dirname(scope);
|
|
74
|
+
if (basename(pkgDir) !== "cli" || basename(scope) !== "@join-pantheon" || basename(nm) !== "node_modules") return null;
|
|
75
|
+
const up = dirname(nm);
|
|
76
|
+
const node = basename(up) === "lib" ? dirname(up) : up;
|
|
77
|
+
const runtime = dirname(node);
|
|
78
|
+
return basename(node) === "node" && basename(runtime) === "runtime" ? runtime : null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The probation file, every field checked (anything odd: no probation). */
|
|
82
|
+
export function readProbation(runtime) {
|
|
83
|
+
const p = readJson(join(runtime, PROBATION_FILE));
|
|
84
|
+
if (!p || typeof p.to !== "string" || !isTime(p.at)) return null;
|
|
85
|
+
return {
|
|
86
|
+
v: 1, to: p.to, at: p.at,
|
|
87
|
+
...(typeof p.from === "string" ? { from: p.from } : {}),
|
|
88
|
+
runs: Array.isArray(p.runs) ? p.runs.filter((r) => r && Number.isInteger(r.pid) && isTime(r.at)).slice(-KEEP_RUNS) : [],
|
|
89
|
+
fails: Array.isArray(p.fails) ? p.fails.filter(isTime).slice(-KEEP_RUNS) : [],
|
|
90
|
+
...(isTime(p.never_online) ? { never_online: p.never_online } : {}),
|
|
91
|
+
...(isTime(p.stop_expected_at) ? { stop_expected_at: p.stop_expected_at } : {}),
|
|
92
|
+
...(isTime(p.stuck) ? { stuck: p.stuck, ...(typeof p.stuck_why === "string" ? { stuck_why: p.stuck_why } : {}) } : {}),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Read, changed, written back; null when there is no probation (or it could not be written). */
|
|
97
|
+
function change(runtime, fn) {
|
|
98
|
+
const p = readProbation(runtime);
|
|
99
|
+
if (!p) return null;
|
|
100
|
+
fn(p);
|
|
101
|
+
try { writeJson(join(runtime, PROBATION_FILE), p); } catch { return null; }
|
|
102
|
+
return p;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Worker runs that vanished without saying how they ended — their process gone,
|
|
107
|
+
* started before no expected stop — become failures.
|
|
108
|
+
*/
|
|
109
|
+
function foldLost(p, self, alive) {
|
|
110
|
+
for (const r of p.runs) {
|
|
111
|
+
if (r.end !== undefined || r.pid === self || alive(r.pid)) continue;
|
|
112
|
+
r.end = "lost";
|
|
113
|
+
if (!(isTime(p.stop_expected_at) && p.stop_expected_at >= r.at)) p.fails.push(r.at);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Take the upgrade's own lock folder (upgrade.ts realSwapIo.lock): an upgrade under way is never raced. */
|
|
118
|
+
function takeLock(dir, alive) {
|
|
119
|
+
for (let i = 0; i < 2; i++) {
|
|
120
|
+
try { mkdirSync(dir); writeFileSync(join(dir, "pid"), String(process.pid)); return true; }
|
|
121
|
+
catch (e) {
|
|
122
|
+
if (!e || e.code !== "EEXIST") return false;
|
|
123
|
+
let pid = 0, age = 0;
|
|
124
|
+
try { pid = Number(readFileSync(join(dir, "pid"), "utf8").trim()); } catch { /* */ }
|
|
125
|
+
try { age = Date.now() - statSync(dir).mtimeMs; } catch { continue; }
|
|
126
|
+
if (alive(pid) ? age < 20 * 60_000 : !pid && age < 10_000) return false;
|
|
127
|
+
const gone = `${dir}.stale-${process.pid}`;
|
|
128
|
+
try { renameSync(dir, gone); rmSync(gone, { recursive: true, force: true }); } catch { /* the next try says */ }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
function dropLock(dir) {
|
|
134
|
+
try { if (Number(readFileSync(join(dir, "pid"), "utf8").trim()) === process.pid) rmSync(dir, { recursive: true, force: true }); } catch { /* */ }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A rename retried for a few seconds: Windows refuses one while a scanner holds a file. */
|
|
138
|
+
function renameRetry(a, b, io) {
|
|
139
|
+
for (let i = 0; i < 6; i++) {
|
|
140
|
+
try { io.rename(a, b); return true; } catch { if (i < 5) io.sleep(300); }
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The crash-loop record (crash-loop.ts) told the worker's next start is not a failure: the start after a way back is a fresh one. */
|
|
146
|
+
function clearWorkerStarts(home) {
|
|
147
|
+
try {
|
|
148
|
+
const f = join(home, "service-starts.json");
|
|
149
|
+
const s = readJson(f);
|
|
150
|
+
if (s && s.worker && Array.isArray(s.worker.starts) && s.worker.starts.length) { s.worker.starts = []; writeJson(f, s); }
|
|
151
|
+
} catch { /* counted once more, at worst */ }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Put the kept version back. Returns the path of its dist/cli.js when it is in
|
|
156
|
+
* place, else null (and the version on probation keeps running; the next start
|
|
157
|
+
* tries again, or says why it cannot).
|
|
158
|
+
*/
|
|
159
|
+
export function rollBack(pkgDir, runtime, p, o = {}) {
|
|
160
|
+
const io = { rename: renameSync, sleep: pause, ...(o.io || {}) };
|
|
161
|
+
const alive = o.alive || pidAlive;
|
|
162
|
+
const now = (o.now || Date.now)();
|
|
163
|
+
const log = o.log || ((line) => { try { process.stderr.write(`${line}\n`); } catch { /* */ } });
|
|
164
|
+
const prev = join(runtime, "cli.prev"), failed = join(runtime, "cli.failed"), lock = join(runtime, ".upgrade.lock");
|
|
165
|
+
const held = join(runtime, HELD_FILE);
|
|
166
|
+
if (!takeLock(lock, alive)) return null;
|
|
167
|
+
try {
|
|
168
|
+
const back = whole(prev) ? versionOf(prev) : null;
|
|
169
|
+
if (!back || back === p.to) {
|
|
170
|
+
// Nothing to go back to: said once (here and in the file doctor reads), and not tried again.
|
|
171
|
+
const why = !back ? "no previous version is kept beside it" : "the version kept beside it is the same release";
|
|
172
|
+
change(runtime, (q) => { q.stuck = now; q.stuck_why = why; });
|
|
173
|
+
log(`! pantheon ${p.to} is not working on this computer and cannot go back by itself (${why}). Run the installer again to repair it`);
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
// Written first: cut off between the renames below, the launcher (or the
|
|
177
|
+
// Windows host) moves cli.prev into place by itself, and this says why.
|
|
178
|
+
try { writeJson(held, { v: 1, version: p.to, back_to: back, at: now, why: p.never_online ? "never_online" : "failed_starts" }); } catch { /* the swap still helps */ }
|
|
179
|
+
if (existsSync(failed)) { try { rmSync(failed, { recursive: true, force: true }); } catch { /* */ } }
|
|
180
|
+
if (existsSync(failed) || !renameRetry(pkgDir, failed, io)) {
|
|
181
|
+
try { rmSync(held, { force: true }); } catch { /* */ }
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
if (!renameRetry(prev, pkgDir, io)) {
|
|
185
|
+
// The release on probation goes back where it was; if even that is refused,
|
|
186
|
+
// the folder is missing and the launcher puts cli.prev in on the next start.
|
|
187
|
+
if (renameRetry(failed, pkgDir, io)) { try { rmSync(held, { force: true }); } catch { /* */ } }
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
try { rmSync(join(runtime, PROBATION_FILE), { force: true }); } catch { /* */ }
|
|
191
|
+
try { rmSync(failed, { recursive: true, force: true }); } catch { /* the next upgrade removes it */ }
|
|
192
|
+
clearWorkerStarts(o.home || process.env.PANTHEON_HOME || join(homedir(), ".pantheon"));
|
|
193
|
+
log(`! pantheon ${p.to} did not work on this computer, so it went back to ${back} by itself. It updates again when a newer release is out`);
|
|
194
|
+
return join(pkgDir, "dist", "cli.js");
|
|
195
|
+
} finally { dropLock(lock); }
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Called by bin/pantheon.js before the CLI is loaded. Returns:
|
|
200
|
+
* entry the dist/cli.js to load (the version put back, after a way back)
|
|
201
|
+
* importFailed() the CLI would not load: counted; true when that was the last
|
|
202
|
+
* failure allowed and the version put back is in place (run it
|
|
203
|
+
* with rerun(): never in this process)
|
|
204
|
+
*/
|
|
205
|
+
export function guard(pkgDir, argv = process.argv.slice(2), o = {}) {
|
|
206
|
+
const own = join(pkgDir, "dist", "cli.js");
|
|
207
|
+
const none = { entry: own, importFailed: () => false };
|
|
208
|
+
const runtime = o.runtime === undefined ? runtimeOf(pkgDir) : o.runtime;
|
|
209
|
+
if (!runtime || !existsSync(join(runtime, PROBATION_FILE))) return none;
|
|
210
|
+
const alive = o.alive || pidAlive;
|
|
211
|
+
const now = o.now || Date.now;
|
|
212
|
+
const p0 = readProbation(runtime);
|
|
213
|
+
const version = versionOf(pkgDir);
|
|
214
|
+
if (!p0 || !version || p0.to !== version) return none; // not the release on probation (the one put back, or a later one)
|
|
215
|
+
if (p0.stuck) return none;
|
|
216
|
+
if (now() - p0.at > PROBATION_MS) { try { rmSync(join(runtime, PROBATION_FILE), { force: true }); } catch { /* */ } return none; }
|
|
217
|
+
const due = (p) => !!p.never_online || p.fails.length >= FAILS_TO_ROLL_BACK;
|
|
218
|
+
const back = (p) => rollBack(pkgDir, runtime, p, o);
|
|
219
|
+
|
|
220
|
+
const p = change(runtime, (q) => foldLost(q, process.pid, alive)) || p0;
|
|
221
|
+
if (due(p)) { const e = back(p); if (e) return { entry: e, importFailed: () => false }; }
|
|
222
|
+
|
|
223
|
+
const worker = argv[0] === "worker" && argv[1] !== "token";
|
|
224
|
+
let counted = false;
|
|
225
|
+
const fail = () => { if (counted) return; counted = true; change(runtime, (q) => { q.fails.push(now()); }); };
|
|
226
|
+
if (worker) change(runtime, (q) => { q.runs.push({ pid: process.pid, at: now() }); q.runs = q.runs.slice(-KEEP_RUNS); });
|
|
227
|
+
if (!o.passive) {
|
|
228
|
+
let crashed = false;
|
|
229
|
+
try { process.on("uncaughtExceptionMonitor", () => { crashed = true; }); } catch { /* */ }
|
|
230
|
+
process.on("exit", (code) => {
|
|
231
|
+
try {
|
|
232
|
+
const expected = EXPECTED_EXIT_CODES.includes(code) || globalThis.__pantheonExpectedExit === true;
|
|
233
|
+
if (worker) {
|
|
234
|
+
change(runtime, (q) => {
|
|
235
|
+
const r = q.runs.find((x) => x.pid === process.pid && x.end === undefined);
|
|
236
|
+
if (r) r.end = code;
|
|
237
|
+
if (!counted && (crashed || !expected)) { counted = true; q.fails.push(now()); }
|
|
238
|
+
});
|
|
239
|
+
} else if (crashed && !counted) fail();
|
|
240
|
+
} catch { /* never in the way of an exit */ }
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
entry: own,
|
|
245
|
+
importFailed: () => {
|
|
246
|
+
try {
|
|
247
|
+
fail();
|
|
248
|
+
const q = readProbation(runtime);
|
|
249
|
+
if (q && q.to === version && due(q)) return !!back(q);
|
|
250
|
+
} catch { /* */ }
|
|
251
|
+
return false;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Services the service manager starts again by itself: ended, so it starts the version put back. */
|
|
257
|
+
const SERVICES = ["worker", "notifier", "host", "menubar", "relay"];
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* The command again, on the version put back, after the release failed to load
|
|
261
|
+
* in this process. Node keeps a module that failed — and every module of that
|
|
262
|
+
* release that did load — under its path, which is now the version put back's:
|
|
263
|
+
* loading it here would mix the two. A service ends instead (its manager starts
|
|
264
|
+
* it again, on the version put back); any other command — an agent's hook that
|
|
265
|
+
* would otherwise block every prompt — runs once more as a child, its input and
|
|
266
|
+
* output its own. Returns the exit code.
|
|
267
|
+
*/
|
|
268
|
+
export function rerun(argv, o = {}) {
|
|
269
|
+
const cmd = argv[1];
|
|
270
|
+
if (SERVICES.includes(cmd)) return 1;
|
|
271
|
+
const r = (o.spawn || spawnSync)(process.execPath, [...process.execArgv, ...argv], { stdio: "inherit", windowsHide: true });
|
|
272
|
+
return typeof r.status === "number" ? r.status : 1;
|
|
273
|
+
}
|
package/dist/agent-check.js
CHANGED
|
@@ -10,6 +10,7 @@ import { CONFIG_DIR } from "./config.js";
|
|
|
10
10
|
import { proxyEnvFor } from "./network.js";
|
|
11
11
|
import { agentSpawn } from "./which.js";
|
|
12
12
|
import { agentBaseEnv } from "./worker.js";
|
|
13
|
+
import { claudeRouting, effectiveRunModel, loadPolicy } from "./worker-policy.js";
|
|
13
14
|
export const CHECK_TIMEOUT_MS = 60_000;
|
|
14
15
|
export const CHECK_PROMPT = "This is Pantheon's setup check. Call the pantheon_status tool once, then reply with exactly the text it returned and nothing else.";
|
|
15
16
|
function runIt(s, cwd, timeoutMs) {
|
|
@@ -86,9 +87,17 @@ export async function checkAgent(cfg, deps) {
|
|
|
86
87
|
const token = backend.id === "claude-code" ? claudeTokenForRun() : null;
|
|
87
88
|
const features = backend.id === "claude-code" ? (deps.claudeFeatures ?? detectClaudeFeatures)(binary) : null;
|
|
88
89
|
const home = homedir();
|
|
90
|
+
const routing = backend.id === "claude-code" ? claudeRouting() : null;
|
|
91
|
+
const model = deps.model !== undefined ? deps.model : (() => { try {
|
|
92
|
+
return effectiveRunModel(backend.id, loadPolicy(), routing).model;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return effectiveRunModel(backend.id, null, routing).model;
|
|
96
|
+
} })();
|
|
89
97
|
const s = headlessSpawn({
|
|
90
98
|
backend, binary, prompt: CHECK_PROMPT, worktree: work, cfg, branch: "pantheon-check", allowBash: false, selfTest: word, runHome,
|
|
91
99
|
...(token ? { claudeToken: token } : {}),
|
|
100
|
+
...(model ? { model } : {}),
|
|
92
101
|
...(features ? { claude: { features, pantheonHome: CONFIG_DIR, home, userSettings: join(home, ".claude", "settings.json") } } : {}),
|
|
93
102
|
});
|
|
94
103
|
materializeSpawnFiles(work, s, runHome);
|
package/dist/agents.js
CHANGED
|
@@ -737,6 +737,10 @@ export function headlessSpawn(opts) {
|
|
|
737
737
|
notes.push("no --settings on this Claude Code: no deny rules and no sandbox — the command list is not a boundary");
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
|
+
if (opts.model && (f.model || f.unknown))
|
|
741
|
+
extra.push("--model", opts.model);
|
|
742
|
+
else if (opts.model)
|
|
743
|
+
notes.push(`no --model on this Claude Code: the run uses the person's own default model, not ${opts.model}`);
|
|
740
744
|
if (rulesOnArgv.length) {
|
|
741
745
|
const fixed = claudeCommandRules().length;
|
|
742
746
|
let used = 0;
|
|
@@ -775,6 +779,7 @@ export function headlessSpawn(opts) {
|
|
|
775
779
|
? ["--approve-for-me"]
|
|
776
780
|
: ["--sandbox", "read-only"]),
|
|
777
781
|
"--skip-git-repo-check",
|
|
782
|
+
...(opts.model ? ["--model", opts.model] : []),
|
|
778
783
|
"--ignore-user-config",
|
|
779
784
|
"-c", `mcp_servers.pantheon.command=${str(entry.command)}`,
|
|
780
785
|
"-c", `mcp_servers.pantheon.args=${list(entry.args)}`,
|
|
@@ -798,6 +803,7 @@ export function headlessSpawn(opts) {
|
|
|
798
803
|
"-p", opts.prompt, "-s",
|
|
799
804
|
"--no-auto-update", "--no-ask-user", "--disable-builtin-mcps",
|
|
800
805
|
"--disable-mcp-server", "pantheon",
|
|
806
|
+
...(opts.model ? ["--model", opts.model] : []),
|
|
801
807
|
...(opts.allowBash ? ["--allow-all-tools"] : [`--allow-tool=${COPILOT_WORKER_SERVER}`, "--allow-tool=write"]),
|
|
802
808
|
],
|
|
803
809
|
env: { ...procEnv, COPILOT_HOME: home },
|
|
@@ -818,7 +824,7 @@ export function headlessSpawn(opts) {
|
|
|
818
824
|
const settings = join(kiroHome(), "settings", "cli.json");
|
|
819
825
|
return {
|
|
820
826
|
command: opts.binary,
|
|
821
|
-
args: ["chat", "--no-interactive", "--agent", agentName, "--require-mcp-startup", "--wrap", "never", opts.prompt],
|
|
827
|
+
args: ["chat", "--no-interactive", "--agent", agentName, "--require-mcp-startup", "--wrap", "never", ...(opts.model ? ["--model", opts.model] : []), opts.prompt],
|
|
822
828
|
env: { ...procEnv, KIRO_HOME: home, KIRO_NO_AUTO_UPDATE: "1" },
|
|
823
829
|
writeFiles: [{
|
|
824
830
|
path: join(home, "agents", `${KIRO_WORKER_AGENT}.json`),
|
|
@@ -842,6 +848,7 @@ export function headlessSpawn(opts) {
|
|
|
842
848
|
"--output-format", "text",
|
|
843
849
|
"--trust",
|
|
844
850
|
"--approve-mcps",
|
|
851
|
+
...(opts.model ? ["--model", opts.model] : []),
|
|
845
852
|
...(opts.allowBash ? ["--force"] : []),
|
|
846
853
|
],
|
|
847
854
|
env: procEnv,
|
package/dist/claude-confine.js
CHANGED
|
@@ -17,6 +17,7 @@ export function parseClaudeHelp(help, version = null) {
|
|
|
17
17
|
settingSources: /(^|\s)--setting-sources\b/m.test(help),
|
|
18
18
|
disallowedTools: /(^|\s)--disallowed-?tools\b/im.test(help),
|
|
19
19
|
addDir: /(^|\s)--add-dir\b/m.test(help),
|
|
20
|
+
model: /(^|\s)--model\b/m.test(help),
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
23
|
export function versionAtLeast(a, b) {
|
package/dist/cli.js
CHANGED
|
@@ -43,7 +43,7 @@ import { removeHook, decideStop, writeIntent, clearIntent, readIntent, repairNot
|
|
|
43
43
|
import { pending, render as renderPending } from "./pending.js";
|
|
44
44
|
import { signedRead } from "./reads.js";
|
|
45
45
|
import { start as qsStart, join as qsJoin, wireUp, teamNameFor, deviceLabel, bindableFolder, startReconnects } from "./quickstart.js";
|
|
46
|
-
import { agentsNeedingUnsandboxed as agentsNeedingUnsandboxedSync, recordedAgent, unattendedReadiness } from "./agents.js";
|
|
46
|
+
import { agentsNeedingUnsandboxed as agentsNeedingUnsandboxedSync, chooseAgent, recordedAgent, unattendedReadiness } from "./agents.js";
|
|
47
47
|
import { agentProblem, PROBLEM_LEAD } from "./readiness-alert.js";
|
|
48
48
|
import { stripControls } from "./notice.js";
|
|
49
49
|
import { awaitingDecision, pickupEstimate } from "./pickup.js";
|
|
@@ -51,7 +51,7 @@ import { loadPolicy, requestReadinessRecheck, unsandboxedAllowed, savePolicy, MO
|
|
|
51
51
|
import { alreadyMemberLine, askedLine, configureLines, fetchSeats, inUseLine, offerSeats, recoverCommand, seatsForTeam, seatsToMove, startGate, RECOVER_WAITING_EXIT } from "./recover-offer.js";
|
|
52
52
|
import { hyphenateSpaces, shellArg, teamNameProblem } from "./team-name.js";
|
|
53
53
|
import { folderRefusalHere, isTemporaryRefusal, projectFolderAnswer } from "./folder-guard.js";
|
|
54
|
-
import { borrowedHome, installService, serviceInstalled, serviceLogFile, serviceState, servicesUnavailable, uninstallService } from "./service.js";
|
|
54
|
+
import { borrowedHome, installService, installedServiceArgs, serviceInstalled, serviceLogFile, serviceState, servicesUnavailable, uninstallService } from "./service.js";
|
|
55
55
|
import { LEGACY_TASK_NAME, hostAlive, hostFiles, readHostState, recordedTaskName } from "./win-host.js";
|
|
56
56
|
import { ACTS, LIMITS } from "./protocol.js";
|
|
57
57
|
import { loadPersonas, personaByName, describePersona, initPersona, personaDir, olderTeammatesNote } from "./persona.js";
|
|
@@ -2487,6 +2487,8 @@ ${B("control")}
|
|
|
2487
2487
|
pantheon policy what this machine's worker may do, in one screen (grant/revoke self-upgrade)
|
|
2488
2488
|
pantheon policy set run-minutes <5-180> how long one woken run may take here (default 60)
|
|
2489
2489
|
pantheon policy set idle-seconds <0-900> how long your session must be quiet before your worker takes a request (default 120)
|
|
2490
|
+
pantheon policy set model <name|own> the model your worker's runs use (Claude Code default: sonnet; own = your own default)
|
|
2491
|
+
pantheon policy set goal-runs <1-100> how many runs one goal may take in 24 hours (default 12)
|
|
2490
2492
|
pantheon persona how a woken worker should behave: list / init <name> / show <name>
|
|
2491
2493
|
pantheon notifier alert you when a task requires your decision
|
|
2492
2494
|
pantheon menubar the menu bar item: status at a glance, pause/resume, decisions
|
|
@@ -2551,8 +2553,27 @@ let workerAlerts = null;
|
|
|
2551
2553
|
let workerAlertsSaid = false;
|
|
2552
2554
|
async function trackServiceStart(kind, noNotify) {
|
|
2553
2555
|
try {
|
|
2554
|
-
const { trackService, composeCrashLoop, loopLine } = await import("./crash-loop.js");
|
|
2556
|
+
const { trackService, composeCrashLoop, loopLine, serviceConnected } = await import("./crash-loop.js");
|
|
2557
|
+
const probation = await import("./upgrade-probation.js");
|
|
2558
|
+
if (kind === "worker") {
|
|
2559
|
+
const relay = (() => { try {
|
|
2560
|
+
return load()?.relay ?? null;
|
|
2561
|
+
}
|
|
2562
|
+
catch {
|
|
2563
|
+
return null;
|
|
2564
|
+
} })();
|
|
2565
|
+
if (relay) {
|
|
2566
|
+
probation.watchNeverOnline({
|
|
2567
|
+
version: VERSION, connected: serviceConnected,
|
|
2568
|
+
relayAnswers: async () => (await (await import("./version-health.js")).fetchRelayPkg(relay, 5000)) !== null,
|
|
2569
|
+
exit: () => { process.exit(1); },
|
|
2570
|
+
log: (line) => console.error(line),
|
|
2571
|
+
});
|
|
2572
|
+
}
|
|
2573
|
+
}
|
|
2555
2574
|
trackService(kind, {
|
|
2575
|
+
onConnectedHealthy: () => { if (probation.probationPassed(VERSION))
|
|
2576
|
+
console.error(D(` pantheon ${VERSION} works here: the upgrade is kept`)); },
|
|
2556
2577
|
onLoop: (loop) => {
|
|
2557
2578
|
console.error(`! ${loopLine(kind, loop)}`);
|
|
2558
2579
|
if (kind === "worker") {
|
|
@@ -2745,7 +2766,7 @@ const EXTRA_FLAGS = "--action-id --agent-cmd --approve-all --ask-before-sending
|
|
|
2745
2766
|
" --headless";
|
|
2746
2767
|
const FLAG_COMMANDS = {
|
|
2747
2768
|
json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay", "setup"],
|
|
2748
|
-
agent: ["join", "start", "setup", "worker", "service", "init"],
|
|
2769
|
+
agent: ["join", "start", "setup", "worker", "service", "init", "policy"],
|
|
2749
2770
|
};
|
|
2750
2771
|
const KNOWN_FLAGS = new Set([...`${Object.values(COMMAND_FLAGS).join(" ")} ${EXTRA_FLAGS}`.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]));
|
|
2751
2772
|
function refuseUnknownFlags() {
|
|
@@ -6107,7 +6128,7 @@ async function main() {
|
|
|
6107
6128
|
return;
|
|
6108
6129
|
}
|
|
6109
6130
|
case "policy": {
|
|
6110
|
-
const { loadPolicy, savePolicy, grant, revoke, inWokenRun, CAPABILITY_ARGS, parseRunMinutes, runMinutesProblem, effectiveRunMinutes, describeRunMinutes, RUN_MINUTES, parseIdleSeconds, idleSecondsProblem, effectiveIdleSeconds, describeIdleSeconds, IDLE_SECONDS } = await import("./worker-policy.js");
|
|
6131
|
+
const { loadPolicy, savePolicy, grant, revoke, inWokenRun, CAPABILITY_ARGS, parseRunMinutes, runMinutesProblem, effectiveRunMinutes, describeRunMinutes, RUN_MINUTES, parseIdleSeconds, idleSecondsProblem, effectiveIdleSeconds, describeIdleSeconds, IDLE_SECONDS, parseModelName, effectiveRunModel, describeRunModel, claudeRouting, OWN_MODEL, RUN_MODEL_AGENTS, DEFAULT_RUN_MODEL, GOAL_RUNS, parseGoalRuns, effectiveGoalRuns } = await import("./worker-policy.js");
|
|
6111
6132
|
const { COMMAND_GRANT_SCOPE } = await import("./agents.js");
|
|
6112
6133
|
const sub = argv[1];
|
|
6113
6134
|
{
|
|
@@ -6148,6 +6169,53 @@ async function main() {
|
|
|
6148
6169
|
}
|
|
6149
6170
|
if (sub === "set") {
|
|
6150
6171
|
const key = argv[2];
|
|
6172
|
+
if (key === "model") {
|
|
6173
|
+
if (inWokenRun())
|
|
6174
|
+
die("a woken run cannot change the model runs use — a person has to run this here");
|
|
6175
|
+
const agent = flag("agent") ?? "claude-code";
|
|
6176
|
+
if (!RUN_MODEL_AGENTS.includes(agent))
|
|
6177
|
+
die(`unknown agent "${agent}" — one of: ${RUN_MODEL_AGENTS.join(", ")}`);
|
|
6178
|
+
const raw = argv[3];
|
|
6179
|
+
const usage = `usage: pantheon policy set model <name | own | default> [--agent ${RUN_MODEL_AGENTS.join("|")}]\n name a model the agent takes, e.g. sonnet, opus, haiku for Claude Code\n own the agent's own default model (for Claude Code: what you chose for your own windows)\n default back to ${DEFAULT_RUN_MODEL[agent] ? `${DEFAULT_RUN_MODEL[agent]} for ${agent}` : `the agent's own default for ${agent}`}`;
|
|
6180
|
+
if (!raw)
|
|
6181
|
+
die(usage);
|
|
6182
|
+
const next = raw === "default" ? null : raw === OWN_MODEL ? OWN_MODEL : parseModelName(raw) ?? die(`"${raw}" is not a model name — letters, digits and . _ - : / [ ] only\n${usage}`);
|
|
6183
|
+
const before = loadPolicy();
|
|
6184
|
+
const was = effectiveRunModel(agent, before);
|
|
6185
|
+
const p = loadPolicy();
|
|
6186
|
+
const models = { ...(p.models ?? {}) };
|
|
6187
|
+
if (next === null)
|
|
6188
|
+
delete models[agent];
|
|
6189
|
+
else
|
|
6190
|
+
models[agent] = next;
|
|
6191
|
+
const now = effectiveRunModel(agent, { models });
|
|
6192
|
+
await protectOrStop([{ setting: "model", about: agent, from: was.model ?? OWN_MODEL, to: now.model ?? OWN_MODEL }]);
|
|
6193
|
+
if (Object.keys(models).length)
|
|
6194
|
+
p.models = models;
|
|
6195
|
+
else
|
|
6196
|
+
delete p.models;
|
|
6197
|
+
savePolicy(p);
|
|
6198
|
+
console.log(`${C("set")} model — ${agent} runs for teammates use ${describeRunModel(now)} ${D("— from the next run, no restart")}`);
|
|
6199
|
+
if (now.from === "own" && agent === "claude-code")
|
|
6200
|
+
console.log(D(` they follow your own Claude Code default — if that is Opus, a teammate's question spends your plan at Opus rates. Back to ${DEFAULT_RUN_MODEL[agent]}: pantheon policy set model default`));
|
|
6201
|
+
return;
|
|
6202
|
+
}
|
|
6203
|
+
if (key === "goal-runs") {
|
|
6204
|
+
if (inWokenRun())
|
|
6205
|
+
die("a woken run cannot change how many runs a goal may take — a person has to run this here");
|
|
6206
|
+
const raw = argv[3];
|
|
6207
|
+
const next = raw === "default" ? GOAL_RUNS.default : parseGoalRuns(raw) ?? die(`"${raw ?? ""}" is not a per-goal limit — give a whole number of runs from ${GOAL_RUNS.min} to ${GOAL_RUNS.max} (the default is ${GOAL_RUNS.default}; back to it: pantheon policy set goal-runs default)`);
|
|
6208
|
+
const was = effectiveGoalRuns(loadPolicy()).runs;
|
|
6209
|
+
await protectOrStop([{ setting: "goal-runs", from: String(was), to: String(next) }]);
|
|
6210
|
+
const p = loadPolicy();
|
|
6211
|
+
if (raw === "default")
|
|
6212
|
+
delete p.goalRuns;
|
|
6213
|
+
else
|
|
6214
|
+
p.goalRuns = next;
|
|
6215
|
+
savePolicy(p);
|
|
6216
|
+
console.log(`${C("set")} per-goal limit — ${next} runs per goal in 24 hours${raw === "default" ? " (the default)" : ""} ${D("— past it, a goal's requests wait for you instead of starting another run")}`);
|
|
6217
|
+
return;
|
|
6218
|
+
}
|
|
6151
6219
|
if (key !== "run-minutes" && key !== "idle-seconds")
|
|
6152
6220
|
die(`usage: pantheon policy set run-minutes <${RUN_MINUTES.min}-${RUN_MINUTES.max} | default> (how long one woken run may take on this machine)\n pantheon policy set idle-seconds <${IDLE_SECONDS.min}-${IDLE_SECONDS.max} | default> (how long your session must be quiet before your worker takes a request)`);
|
|
6153
6221
|
if (key === "idle-seconds") {
|
|
@@ -6257,7 +6325,7 @@ async function main() {
|
|
|
6257
6325
|
return;
|
|
6258
6326
|
}
|
|
6259
6327
|
if (sub && sub !== "show")
|
|
6260
|
-
die(`usage: pantheon policy [show | grant <capability> | revoke <capability> | set run-minutes <${RUN_MINUTES.min}-${RUN_MINUTES.max}|default> | set idle-seconds <${IDLE_SECONDS.min}-${IDLE_SECONDS.max}|default>] capabilities: ${caps.map((c) => CAPABILITY_ARGS[c]).join(", ")}`);
|
|
6328
|
+
die(`usage: pantheon policy [show | grant <capability> | revoke <capability> | set run-minutes <${RUN_MINUTES.min}-${RUN_MINUTES.max}|default> | set idle-seconds <${IDLE_SECONDS.min}-${IDLE_SECONDS.max}|default> | set model <name|own|default> [--agent <id>] | set goal-runs <${GOAL_RUNS.min}-${GOAL_RUNS.max}|default>] capabilities: ${caps.map((c) => CAPABILITY_ARGS[c]).join(", ")}`);
|
|
6261
6329
|
const p = loadPolicy();
|
|
6262
6330
|
const w = workerProc();
|
|
6263
6331
|
console.log(`${B("What this machine's worker may do")}\n`);
|
|
@@ -6295,6 +6363,35 @@ async function main() {
|
|
|
6295
6363
|
console.log(` ${D(`ignored "${r.line}" — ${r.why}`)}`);
|
|
6296
6364
|
}
|
|
6297
6365
|
console.log(` runs ${D("12/hour, 40/day, one at a time, 2 failed attempts then parked (defaults; personas only lower them)")}`);
|
|
6366
|
+
{
|
|
6367
|
+
const gr = effectiveGoalRuns(p);
|
|
6368
|
+
console.log(` per goal ${gr.runs} runs in 24 hours${D(` (${gr.from === "default" ? "the default" : "set on this machine"}) — so two agents answering each other can't use up your plan; past it, that goal waits for you (change: pantheon policy set goal-runs <${GOAL_RUNS.min}-${GOAL_RUNS.max}>)`)}`);
|
|
6369
|
+
const runAgent = (() => {
|
|
6370
|
+
try {
|
|
6371
|
+
const args = installedServiceArgs("worker") ?? [];
|
|
6372
|
+
const at = args.indexOf("--agent");
|
|
6373
|
+
const pinned = at >= 0 ? args[at + 1] : undefined;
|
|
6374
|
+
const c = load();
|
|
6375
|
+
return chooseAgent(pinned, { ...(c ? { prefer: loadProfile(c).agent.primary_surface } : {}), check: null }).backend.id;
|
|
6376
|
+
}
|
|
6377
|
+
catch {
|
|
6378
|
+
return null;
|
|
6379
|
+
}
|
|
6380
|
+
})();
|
|
6381
|
+
const LABEL = { "claude-code": "Claude Code", codex: "Codex", cursor: "Cursor", copilot: "Copilot", kiro: "Kiro" };
|
|
6382
|
+
const shown = runAgent && RUN_MODEL_AGENTS.includes(runAgent) ? runAgent : "claude-code";
|
|
6383
|
+
const routing = claudeRouting();
|
|
6384
|
+
const cm = effectiveRunModel(shown, p, shown === "claude-code" ? routing : null);
|
|
6385
|
+
const how = shown !== "claude-code"
|
|
6386
|
+
? ` ${cm.from === "own" ? D(`— what you chose in ${LABEL[shown]} for yourself; Pantheon only sets Sonnet for Claude Code runs (change: pantheon policy set model <name> --agent ${shown})`) : D(`(back to its own default: pantheon policy set model default --agent ${shown})`)}`
|
|
6387
|
+
: D(cm.from === "default" ? " — not your own default, so a teammate's request never runs on Opus by accident (change: pantheon policy set model <name|own>)"
|
|
6388
|
+
: cm.from === "provider" ? ` — your Claude Code is set up through ${routing}, so runs keep its own model (choose one: pantheon policy set model <name>)`
|
|
6389
|
+
: " (back to the default: pantheon policy set model default)");
|
|
6390
|
+
console.log(` model ${LABEL[shown]} runs use ${describeRunModel(cm)}${how}`);
|
|
6391
|
+
for (const a of RUN_MODEL_AGENTS)
|
|
6392
|
+
if (a !== shown && (p.models?.[a] || a === "claude-code"))
|
|
6393
|
+
console.log(` ${D(`${LABEL[a]} runs use ${describeRunModel(effectiveRunModel(a, p, a === "claude-code" ? routing : null))}`)}`);
|
|
6394
|
+
}
|
|
6298
6395
|
{
|
|
6299
6396
|
const lim = effectiveRunMinutes({ policy: p });
|
|
6300
6397
|
const lowered = pers.filter((x) => x.maxRunMinutes !== undefined && x.maxRunMinutes < lim.minutes);
|
package/dist/crash-loop.js
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { readStateText, withFileLock } from "./file-lock.js";
|
|
4
4
|
import { atomicWrite } from "./worker-policy.js";
|
|
5
5
|
import { BUDGET } from "./notice.js";
|
|
6
|
+
import { probationStopExpected } from "./upgrade-probation.js";
|
|
6
7
|
export const WATCHED = ["worker", "notifier"];
|
|
7
8
|
export const LOOP_WINDOW_MS = 10 * 60_000;
|
|
8
9
|
export const LOOP_STARTS = 3;
|
|
@@ -115,6 +116,12 @@ export function markExpectedExit(kind, o = {}) {
|
|
|
115
116
|
export function stopIsExpected(kind, o = {}) {
|
|
116
117
|
if (kind === "worker" || kind === "notifier")
|
|
117
118
|
markExpectedExit(kind, o);
|
|
119
|
+
if (kind === "worker") {
|
|
120
|
+
try {
|
|
121
|
+
probationStopExpected();
|
|
122
|
+
}
|
|
123
|
+
catch { }
|
|
124
|
+
}
|
|
118
125
|
}
|
|
119
126
|
export function activeLoop(kind, o = {}) {
|
|
120
127
|
const loop = (o.file ?? readStarts(o.home))[kind]?.loop;
|
|
@@ -157,7 +164,7 @@ export function trackService(kind, o = {}) {
|
|
|
157
164
|
r = recordStart(kind, { ...(o.home ? { home: o.home } : {}), now: now() });
|
|
158
165
|
}
|
|
159
166
|
catch { }
|
|
160
|
-
tracking = { kind, ...(o.home ? { home: o.home } : {}), startedAt: now(), healthy: false, expectExit: false, connected: false, timers: [] };
|
|
167
|
+
tracking = { kind, ...(o.home ? { home: o.home } : {}), startedAt: now(), healthy: false, expectExit: false, connected: false, ...(o.onConnectedHealthy ? { onConnectedHealthy: o.onConnectedHealthy } : {}), timers: [] };
|
|
161
168
|
const t = tracking;
|
|
162
169
|
if (!o.passive) {
|
|
163
170
|
const steady = setTimeout(() => healthyNow(t), STEADY_AFTER_MS);
|
|
@@ -192,15 +199,25 @@ function healthyNow(t) {
|
|
|
192
199
|
}
|
|
193
200
|
export function noteServiceConnected() {
|
|
194
201
|
const t = tracking;
|
|
195
|
-
if (!t || t.
|
|
202
|
+
if (!t || t.connected)
|
|
196
203
|
return;
|
|
197
204
|
t.connected = true;
|
|
198
|
-
const timer = setTimeout(() =>
|
|
205
|
+
const timer = setTimeout(() => {
|
|
206
|
+
healthyNow(t);
|
|
207
|
+
try {
|
|
208
|
+
t.onConnectedHealthy?.();
|
|
209
|
+
}
|
|
210
|
+
catch { }
|
|
211
|
+
}, HEALTHY_AFTER_CONNECT_MS);
|
|
199
212
|
timer.unref?.();
|
|
200
213
|
t.timers.push(timer);
|
|
201
214
|
}
|
|
202
|
-
export function
|
|
203
|
-
|
|
215
|
+
export function serviceConnected() { return !!tracking?.connected; }
|
|
216
|
+
export function expectServiceExit() {
|
|
217
|
+
if (tracking)
|
|
218
|
+
tracking.expectExit = true;
|
|
219
|
+
globalThis.__pantheonExpectedExit = true;
|
|
220
|
+
}
|
|
204
221
|
export function resetServiceTracking() { if (tracking)
|
|
205
222
|
for (const t of tracking.timers)
|
|
206
223
|
clearTimeout(t); tracking = null; }
|