@join-pantheon/cli 0.37.3 → 0.38.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/README.md +10 -2
- package/dist/admin-founder.js +5 -2
- package/dist/admin-pages.js +29 -2
- package/dist/agent-check.js +9 -0
- package/dist/agents.js +8 -1
- package/dist/claude-confine.js +1 -0
- package/dist/cli.js +368 -43
- package/dist/crash-loop.js +207 -0
- package/dist/doctor.js +38 -1
- package/dist/finish-line.js +14 -7
- package/dist/folder-ask.js +104 -0
- package/dist/founder-stats.js +24 -1
- package/dist/home-guard.js +21 -0
- package/dist/home-safety.js +2 -0
- package/dist/install-stats.js +314 -0
- package/dist/machine.js +2 -0
- package/dist/mcp.js +52 -6
- package/dist/notice.js +107 -0
- package/dist/notifier.js +206 -16
- package/dist/notify.js +14 -2
- package/dist/onboard-copy.js +3 -0
- package/dist/pending.js +11 -3
- package/dist/pickup.js +11 -3
- package/dist/quickstart.js +41 -21
- package/dist/relay.js +59 -7
- package/dist/service.js +5 -0
- package/dist/setup-changes.js +13 -0
- package/dist/setup-guide.js +25 -4
- package/dist/spend.js +12 -0
- package/dist/status-engine.js +1 -1
- package/dist/tray.js +9 -2
- package/dist/version-health.js +288 -0
- package/dist/win-host.js +2 -0
- package/dist/worker-policy.js +105 -3
- package/dist/worker.js +274 -37
- package/helper/macos/prebuilt/manifest.json +2 -2
- package/helper/macos/prebuilt/pantheon-hud +0 -0
- package/npm-shrinkwrap.json +13 -2
- package/package.json +2 -1
package/dist/cli.js
CHANGED
|
@@ -21,13 +21,13 @@ import { install, launcher, installForUser, windowsRepoOverrides, agentAsksOnce
|
|
|
21
21
|
import { Relay } from "./relay.js";
|
|
22
22
|
import { runMcp } from "./mcp.js";
|
|
23
23
|
import { Worker } from "./worker.js";
|
|
24
|
-
import { DEFAULT_REMINDER_MS, ensureNativeNotifier, HumanNotifier, hudBinaryPath, openInHere, runNotifiers, sendDesktopNotification } from "./notifier.js";
|
|
24
|
+
import { DEFAULT_REMINDER_MS, ensureNativeNotifier, HumanNotifier, hudBinaryPath, onlyNetworkFailures, openInHere, runNotifiers, sendDesktopNotification } from "./notifier.js";
|
|
25
25
|
import { linuxDesktopReachable } from "./notice-linux.js";
|
|
26
26
|
import { desktopUnavailable, hostEnv } from "./host-env.js";
|
|
27
27
|
import { commandState } from "./command-state.js";
|
|
28
|
-
import { AGENT_SURFACES, applyProfileInit, setupChosen, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
|
|
28
|
+
import { AGENT_SURFACES, applyProfileInit, decisionAlertsOn, setupChosen, cleanList, dropCatchAllClaims, isAgentSurface, loadProfile, organizationProfile, profileInitialized, profilePath, saveProfile, teamProfile, wakeDefault, wakeMode } from "./profile.js";
|
|
29
29
|
import { runGuide, terminalIO, questionOrNull, parseSetupFlags, questionnaire, optOutsFrom, decisionAreasProblem, ALERT_WORDS, AUTOPILOT_WAKE_OFF } from "./setup-guide.js";
|
|
30
|
-
import { APPROVED_ENV, unsandboxedRisk, beginApproval, agentLabel, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, whoIsAsking } from "./setup-changes.js";
|
|
30
|
+
import { APPROVED_ENV, unsandboxedRisk, beginApproval, agentLabel, changeLabel, composeSetupAlert, dropPending, findPending, gateChanges, lastChangeLine, loadPending, logChanges, machineSetUp, markFirstSetup, askedByLabel, pendingSaid, turnedOff, whoIsAsking } from "./setup-changes.js";
|
|
31
31
|
import { selectActs, formatAct, resolveRef } from "./history-view.js";
|
|
32
32
|
import { doctor, ownProcesses, render, shareBlock } from "./doctor.js";
|
|
33
33
|
import { FEEDBACK_ADDRESS } from "./feedback.js";
|
|
@@ -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";
|
|
@@ -93,7 +93,7 @@ if (PROMPTLESS) {
|
|
|
93
93
|
}
|
|
94
94
|
catch { }
|
|
95
95
|
}
|
|
96
|
-
const JSON_OUT = argv.includes("--json") && ["join", "start", "doctor", "status", "check"].includes(cmd);
|
|
96
|
+
const JSON_OUT = argv.includes("--json") && ["join", "start", "doctor", "status", "check", "setup"].includes(cmd) && !(cmd === "setup" && argv.includes("--questions"));
|
|
97
97
|
let jsonSaid = false;
|
|
98
98
|
function sayJson(o) {
|
|
99
99
|
if (jsonSaid)
|
|
@@ -669,12 +669,17 @@ async function workerAfterBinding(how) {
|
|
|
669
669
|
if (how === "off")
|
|
670
670
|
return;
|
|
671
671
|
const j = load();
|
|
672
|
-
|
|
672
|
+
const team = j?.spaceId;
|
|
673
|
+
if (!j || !team || wakeMode(loadProfile(j)) === "no")
|
|
673
674
|
return;
|
|
674
675
|
const { serviceInstalled, servicesUnavailable } = await import("./service.js");
|
|
675
676
|
if (servicesUnavailable(process.platform) || serviceInstalled("worker"))
|
|
676
677
|
return;
|
|
677
|
-
|
|
678
|
+
if (workerOffByPerson()) {
|
|
679
|
+
console.error(D(` your worker stays off, as you set it — teammates' requests wait for you. To turn it on: pantheon service install worker`));
|
|
680
|
+
return;
|
|
681
|
+
}
|
|
682
|
+
const ws = (await import("./worker-fleet.js")).teamWorkspaces(loadAll(), team);
|
|
678
683
|
if (!ws.length)
|
|
679
684
|
return;
|
|
680
685
|
try {
|
|
@@ -683,49 +688,163 @@ async function workerAfterBinding(how) {
|
|
|
683
688
|
const { notLoadedWhy } = await import("./setup-guide.js");
|
|
684
689
|
const why = notLoadedWhy(installService("worker", ws[0].path, commandsOn ? ["--allow-bash"] : []));
|
|
685
690
|
if (why) {
|
|
686
|
-
console.error(`\x1b[33m ! the worker is installed but not running (${why}) — teammates' requests wait for you until it runs: pantheon service restart worker\x1b[0m`);
|
|
691
|
+
console.error(`\x1b[33m ! the worker is installed but not running (${why}) — teammates' requests wait for you until it runs: pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
687
692
|
return;
|
|
688
693
|
}
|
|
689
694
|
console.error(` ${C("✓")} worker on — serves ${ws.map((w) => w.name).join(", ")} while you are away${wakeMode(loadProfile(j)) === "approved" ? "; you are asked the first time each teammate needs it" : ""}${commandsOn ? "; a run may run tests, commit and push to its own branch (edits only: pantheon setup --commands no)" : ""}`);
|
|
695
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
696
|
+
if (selfUpgrade)
|
|
697
|
+
console.error(D(` ${selfUpgrade}`));
|
|
690
698
|
}
|
|
691
699
|
catch (e) {
|
|
692
700
|
console.error(D(` the worker did not install: ${e.message} — pantheon service install worker`));
|
|
693
701
|
}
|
|
694
702
|
}
|
|
695
|
-
|
|
703
|
+
function workerOffByPerson() {
|
|
704
|
+
try {
|
|
705
|
+
return turnedOff("worker") && !(borrowedHome() ? false : serviceState("worker").running);
|
|
706
|
+
}
|
|
707
|
+
catch {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
const SANDBOX_NOTE = " (coding agent: ask your person to approve running this outside your sandbox — a sandbox can't start background services)";
|
|
712
|
+
let folderChoicesFound = null;
|
|
713
|
+
async function choicesFor(m, all) {
|
|
714
|
+
if (folderChoicesFound?.team === m.id)
|
|
715
|
+
return folderChoicesFound.choices;
|
|
716
|
+
const { folderChoices } = await import("./folder-ask.js");
|
|
717
|
+
let choices = [];
|
|
718
|
+
try {
|
|
719
|
+
choices = folderChoices({ cwd: process.cwd(), all, spaceId: m.id });
|
|
720
|
+
}
|
|
721
|
+
catch { }
|
|
722
|
+
folderChoicesFound = { team: m.id, choices };
|
|
723
|
+
return choices;
|
|
724
|
+
}
|
|
725
|
+
async function folderAskFor(m, all) {
|
|
726
|
+
const { folderAsk, notLinkedWhy } = await import("./folder-ask.js");
|
|
696
727
|
const cwd = process.cwd();
|
|
697
|
-
|
|
728
|
+
const refused = folderRefusalHere(cwd);
|
|
729
|
+
const why = notLinkedWhy(refused) ?? (repoInfo(cwd) ? null : (await import("./repo-find.js")).holdsRepo(cwd) ? "This folder holds repos" : null);
|
|
730
|
+
return folderAsk({ team: m.name, choices: await choicesFor(m, all), why, command: (rest) => pantheonCommand(managedLayout()?.launcher, rest) });
|
|
731
|
+
}
|
|
732
|
+
async function askProjectFolder(cfgIn) {
|
|
733
|
+
const cwd = process.cwd();
|
|
734
|
+
if (repoInfo(cwd))
|
|
698
735
|
return;
|
|
699
|
-
const all = loadAll(), j = load();
|
|
736
|
+
const all = loadAll(), j = cfgIn ?? load();
|
|
700
737
|
const m = all && j ? findMembership(all, j.spaceId ?? j.space) ?? findMembership(all, j.space) : null;
|
|
701
738
|
if (!all || !m)
|
|
702
739
|
return;
|
|
703
|
-
|
|
740
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
741
|
+
if (teamLinked(all, m.id))
|
|
704
742
|
return;
|
|
743
|
+
const ask = await folderAskFor(m, all);
|
|
744
|
+
if (!process.stdin.isTTY) {
|
|
745
|
+
console.error(`\n${B("Your project folder.")}`);
|
|
746
|
+
for (const l of ask.lines)
|
|
747
|
+
console.error(` ${l}`);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
const choices = await choicesFor(m, all);
|
|
705
751
|
const line = pantheonCommand(managedLayout()?.launcher, `use ${m.name} --here`);
|
|
706
752
|
const later = () => {
|
|
707
|
-
console.error(`
|
|
708
|
-
console.error(D(`
|
|
753
|
+
console.error(` Later, from the folder you work in (a repo, or a folder of documents), run: ${C(line)}`);
|
|
754
|
+
console.error(D(` Until then teammates' requests can't be taken here while you're away, and agents opened there do not speak for "${m.name}" yet.`));
|
|
709
755
|
};
|
|
710
|
-
|
|
711
|
-
${B("Your project folder.")} ${D(
|
|
712
|
-
if (
|
|
713
|
-
|
|
714
|
-
|
|
756
|
+
const why = ask.lines[0] && !ask.lines[0].startsWith("This computer") ? ask.lines[0] : `Nothing on this computer is linked to "${m.name}" yet.`;
|
|
757
|
+
console.error(`\n${B("Your project folder.")} ${D(why)}`);
|
|
758
|
+
if (choices.length) {
|
|
759
|
+
console.error(D(` Found on this computer:`));
|
|
760
|
+
choices.forEach((c, i) => console.error(` ${String(i + 1).padStart(2)}. ${c.name.padEnd(18)} ${D(c.shown)}`));
|
|
715
761
|
}
|
|
762
|
+
console.error(D(` A folder of documents works too: your worker answers teammates' questions from a copy of it, and keeps anything it writes as drafts for you.`));
|
|
716
763
|
for (let tries = 0; tries < 3; tries++) {
|
|
717
|
-
const
|
|
718
|
-
const a = ((await questionOrNull(rl, ` The folder you work in for "${m.name}" — a repo or a docs folder (Enter to skip): `)) ?? "").trim();
|
|
719
|
-
rl.close();
|
|
764
|
+
const a = ((await askOnce(` The folder you work in for "${m.name}" — ${choices.length ? "a number above, or " : ""}a repo or a folder of documents (Enter to skip): `)) ?? "").trim();
|
|
720
765
|
if (!a)
|
|
721
766
|
break;
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
767
|
+
const n = /^\d+$/.test(a) ? Number(a) : NaN;
|
|
768
|
+
if (Number.isInteger(n) && choices.length && (n < 1 || n > choices.length)) {
|
|
769
|
+
console.error(D(` pick 1 to ${choices.length}, or type a folder — or press Enter to skip`));
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const dir = Number.isInteger(n) && choices[n - 1] ? choices[n - 1].path : projectFolderAnswer(a, homedir(), cwd);
|
|
773
|
+
const why2 = await bindProjectFolder(dir, m);
|
|
774
|
+
if (!why2)
|
|
724
775
|
return;
|
|
725
|
-
console.error(D(` ${
|
|
776
|
+
console.error(D(` ${why2} — try another, or press Enter to skip`));
|
|
726
777
|
}
|
|
727
778
|
later();
|
|
728
779
|
}
|
|
780
|
+
async function workerWithFirstLink(all, m) {
|
|
781
|
+
if (argv.includes("--no-worker") || inWokenRun())
|
|
782
|
+
return false;
|
|
783
|
+
try {
|
|
784
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
785
|
+
if (teamLinked(all, m.id))
|
|
786
|
+
return false;
|
|
787
|
+
const cfg = configFor(all, m, null);
|
|
788
|
+
if (wakeMode(loadProfile(cfg)) === "no")
|
|
789
|
+
return false;
|
|
790
|
+
if (servicesUnavailable(process.platform) || serviceInstalled("worker"))
|
|
791
|
+
return false;
|
|
792
|
+
return !workerOffByPerson();
|
|
793
|
+
}
|
|
794
|
+
catch {
|
|
795
|
+
return false;
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
async function afterLinking(m, wantWorker) {
|
|
799
|
+
const all = loadAll();
|
|
800
|
+
if (!all)
|
|
801
|
+
return;
|
|
802
|
+
if (wantWorker) {
|
|
803
|
+
const { teamWorkspaces } = await import("./worker-fleet.js");
|
|
804
|
+
const ws = teamWorkspaces(all, m.id);
|
|
805
|
+
if (ws.length) {
|
|
806
|
+
try {
|
|
807
|
+
const { commandsChosen } = await import("./profile.js");
|
|
808
|
+
const commandsOn = ws.some((w) => w.kind === "repo") && commandsChosen() !== false;
|
|
809
|
+
const { notLoadedWhy } = await import("./setup-guide.js");
|
|
810
|
+
const why = notLoadedWhy(installService("worker", ws[0].path, commandsOn ? ["--allow-bash"] : []));
|
|
811
|
+
if (why)
|
|
812
|
+
console.error(`\x1b[33m ! Your worker is installed but not running (${why}), so this computer can't take teammates' requests yet.\n → pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
813
|
+
else {
|
|
814
|
+
console.error(` ${C("✓")} worker on — this computer takes teammates' requests for "${m.name}" while you're away${commandsOn ? "; a run may run tests, commit and push to its own branch (edits only: pantheon setup --commands no)" : ""}`);
|
|
815
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
816
|
+
if (selfUpgrade)
|
|
817
|
+
console.error(D(` ${selfUpgrade}`));
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
catch (e) {
|
|
821
|
+
console.error(`\x1b[33m ! The worker did not install (${e.message.split("\n")[0]}), so this computer can't take teammates' requests yet.\n → pantheon service install worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
else if (!argv.includes("--no-worker") && !serviceInstalled("worker") && workerOffByPerson()) {
|
|
826
|
+
console.error(D(` your worker stays off, as you set it — teammates' requests wait for you. To turn it on: pantheon service install worker`));
|
|
827
|
+
}
|
|
828
|
+
else if (serviceInstalled("worker") && !borrowedHome()) {
|
|
829
|
+
try {
|
|
830
|
+
if (!serviceState("worker").running)
|
|
831
|
+
console.error(`\x1b[33m ! Your worker is installed but not running, so this computer can't take teammates' requests yet.\n → pantheon service restart worker${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
832
|
+
}
|
|
833
|
+
catch { }
|
|
834
|
+
}
|
|
835
|
+
try {
|
|
836
|
+
if (servicesUnavailable(process.platform) || borrowedHome() || turnedOff("alerts"))
|
|
837
|
+
return;
|
|
838
|
+
const { decisionAlertsOn } = await import("./profile.js");
|
|
839
|
+
if (!decisionAlertsOn())
|
|
840
|
+
return;
|
|
841
|
+
if (!serviceInstalled("notifier"))
|
|
842
|
+
console.error(D(` Desktop alerts are off on this computer, so you won't hear when a teammate needs you. To turn them on: pantheon service install notifier`));
|
|
843
|
+
else if (!serviceState("notifier").running)
|
|
844
|
+
console.error(`\x1b[33m ! Desktop alerts are installed but not running, so you won't hear when a teammate needs you.\n → pantheon service restart notifier${process.stdin.isTTY ? "" : SANDBOX_NOTE}\x1b[0m`);
|
|
845
|
+
}
|
|
846
|
+
catch { }
|
|
847
|
+
}
|
|
729
848
|
async function bindProjectFolder(dir, m) {
|
|
730
849
|
try {
|
|
731
850
|
if (!statSync(dir).isDirectory())
|
|
@@ -2140,6 +2259,7 @@ async function finishLine(tools, o) {
|
|
|
2140
2259
|
catch {
|
|
2141
2260
|
return null;
|
|
2142
2261
|
} })();
|
|
2262
|
+
let takesWork = false;
|
|
2143
2263
|
const gather = async () => {
|
|
2144
2264
|
let wakeOn = false, ready = null, served = null, pending = 0;
|
|
2145
2265
|
try {
|
|
@@ -2165,13 +2285,24 @@ async function finishLine(tools, o) {
|
|
|
2165
2285
|
catch {
|
|
2166
2286
|
pending = 0;
|
|
2167
2287
|
}
|
|
2168
|
-
const workerWanted = wakeOn && !argv.includes("--no-worker");
|
|
2288
|
+
const workerWanted = wakeOn && !argv.includes("--no-worker") && !workerOffByPerson();
|
|
2289
|
+
takesWork = workerWanted && (served ?? 0) > 0;
|
|
2290
|
+
let linkLine = null;
|
|
2291
|
+
if (workerWanted && served === 0 && cfg) {
|
|
2292
|
+
try {
|
|
2293
|
+
const { NAMED_FOLDER } = await import("./folder-ask.js");
|
|
2294
|
+
linkLine = pantheonCommand(managedLayout()?.launcher, `use ${cfg.space} --here --folder '${NAMED_FOLDER}'`);
|
|
2295
|
+
}
|
|
2296
|
+
catch {
|
|
2297
|
+
linkLine = null;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2169
2300
|
const workerRowFailed = tools.some((t) => t.tool === "worker" && /^(failed|could not)/i.test(t.status));
|
|
2170
2301
|
const alertsOn = tools.some((t) => t.tool === "notifications" && /^on\b/i.test(t.status));
|
|
2171
2302
|
return [...(o.extra ?? []), ...finishItems({ tools, readiness: ready, team: cfg?.space ?? "<team>", workerWanted, served, windows, pending,
|
|
2172
2303
|
worker: workerWanted && (served ?? 0) > 0 && !workerRowFailed ? await workerHeld() : null,
|
|
2173
2304
|
alerts: alertsOn ? await alertsHeld() : null,
|
|
2174
|
-
agentShell: !process.stdin.isTTY })];
|
|
2305
|
+
agentShell: !process.stdin.isTTY, linkLine })];
|
|
2175
2306
|
};
|
|
2176
2307
|
let items = await gather();
|
|
2177
2308
|
if (guideAsks(o.preset)) {
|
|
@@ -2249,8 +2380,22 @@ async function finishLine(tools, o) {
|
|
|
2249
2380
|
}
|
|
2250
2381
|
if (JSON_OUT) {
|
|
2251
2382
|
const plain = (t) => t.replace(/\x1b\[[0-9;]*m/g, "").trim();
|
|
2383
|
+
let ask = {};
|
|
2384
|
+
if (items.some((it) => it.needsFolder) && cfg) {
|
|
2385
|
+
try {
|
|
2386
|
+
const all = loadAll();
|
|
2387
|
+
const m = all ? findMembership(all, cfg.spaceId ?? cfg.space) ?? findMembership(all, cfg.space) : null;
|
|
2388
|
+
if (all && m) {
|
|
2389
|
+
const a = (await folderAskFor(m, all)).json;
|
|
2390
|
+
ask = { reason: a.reason, needs: a.needs, message: a.message, folders: a.folders, other_folder: a.other_folder, skip: a.skip };
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
catch { }
|
|
2394
|
+
}
|
|
2252
2395
|
sayJson({
|
|
2253
|
-
status: items.length ? "left" : "ready",
|
|
2396
|
+
status: ask.needs ? "needs_person" : items.length ? "left" : "ready",
|
|
2397
|
+
...ask,
|
|
2398
|
+
can_take_requests: takesWork && !items.some((it) => it.blocks),
|
|
2254
2399
|
code: typeof process.exitCode === "number" ? process.exitCode : 0,
|
|
2255
2400
|
team: cfg?.space ?? null,
|
|
2256
2401
|
member: cfg?.member ?? null,
|
|
@@ -2342,6 +2487,8 @@ ${B("control")}
|
|
|
2342
2487
|
pantheon policy what this machine's worker may do, in one screen (grant/revoke self-upgrade)
|
|
2343
2488
|
pantheon policy set run-minutes <5-180> how long one woken run may take here (default 60)
|
|
2344
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)
|
|
2345
2492
|
pantheon persona how a woken worker should behave: list / init <name> / show <name>
|
|
2346
2493
|
pantheon notifier alert you when a task requires your decision
|
|
2347
2494
|
pantheon menubar the menu bar item: status at a glance, pause/resume, decisions
|
|
@@ -2404,6 +2551,32 @@ ${B("less common")}
|
|
|
2404
2551
|
`;
|
|
2405
2552
|
let workerAlerts = null;
|
|
2406
2553
|
let workerAlertsSaid = false;
|
|
2554
|
+
async function trackServiceStart(kind, noNotify) {
|
|
2555
|
+
try {
|
|
2556
|
+
const { trackService, composeCrashLoop, loopLine } = await import("./crash-loop.js");
|
|
2557
|
+
trackService(kind, {
|
|
2558
|
+
onLoop: (loop) => {
|
|
2559
|
+
console.error(`! ${loopLine(kind, loop)}`);
|
|
2560
|
+
if (kind === "worker") {
|
|
2561
|
+
try {
|
|
2562
|
+
writeFileSync(join(CONFIG_DIR, "worker-state.json"), JSON.stringify({ at: Date.now(), state: "restarting", detail: `keeps stopping — restarted ${loop.starts} times in a few minutes; pantheon doctor shows why` }) + "\n");
|
|
2563
|
+
}
|
|
2564
|
+
catch { }
|
|
2565
|
+
}
|
|
2566
|
+
if (noNotify || !decisionAlertsOn())
|
|
2567
|
+
return;
|
|
2568
|
+
const n = composeCrashLoop(kind, loop);
|
|
2569
|
+
if (kind === "worker") {
|
|
2570
|
+
if (workerCanAlert())
|
|
2571
|
+
notifyFromWorker(n);
|
|
2572
|
+
}
|
|
2573
|
+
else
|
|
2574
|
+
void Promise.resolve(sendDesktopNotification(n)).catch(() => false);
|
|
2575
|
+
},
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
catch { }
|
|
2579
|
+
}
|
|
2407
2580
|
function notifyFromWorker(n) {
|
|
2408
2581
|
if (process.platform === "linux") {
|
|
2409
2582
|
if (!workerAlerts || Date.now() - workerAlerts.at > 60_000)
|
|
@@ -2478,13 +2651,13 @@ const COMMAND_FLAGS = {
|
|
|
2478
2651
|
check: "--json (runs your agent once, as it runs for teammates while you're away — up to a minute)",
|
|
2479
2652
|
status: "--clear-safety (once the safety warnings it shows are handled) --json",
|
|
2480
2653
|
relay: "--port <n> --host <address> --data <dir> (relay leftovers --data <dir> [--json]: read-only report)",
|
|
2481
|
-
use: "<team> --here --yes · pantheon use --unbind (this folder or repo bound to no team again)",
|
|
2654
|
+
use: "<team> --here [--folder <path> (that folder, not this one)] --yes --no-worker · pantheon use --unbind (this folder or repo bound to no team again)",
|
|
2482
2655
|
repo: "add [--base <branch>] | list [--all] | find [<folder>] [--recents] [--yes]",
|
|
2483
2656
|
login: "--email <address> --relay <url> --label <device name>",
|
|
2484
2657
|
signin: "--relay <url>",
|
|
2485
2658
|
signup: "--email <address> --username <name> --relay <url> --label <device name>",
|
|
2486
2659
|
audit: "--space <team> --since <hours> --json",
|
|
2487
|
-
setup: "--questions --mode <autopilot|here> --agent <claude-code|codex|cursor|copilot|kiro> (which agent answers teammates' requests here) (and every answer as a flag, with --yes)",
|
|
2660
|
+
setup: "--questions --mode <autopilot|here> --agent <claude-code|codex|cursor|copilot|kiro> (which agent answers teammates' requests here) --json (and every answer as a flag, with --yes)",
|
|
2488
2661
|
mode: "[autopilot | here]",
|
|
2489
2662
|
changes: "[list | review | approve <id> | keep <id>] --history",
|
|
2490
2663
|
board: "--open --url --watch --keep --stop --focus <id> [--space <team>]",
|
|
@@ -2573,8 +2746,8 @@ const EXTRA_FLAGS = "--action-id --agent-cmd --approve-all --ask-before-sending
|
|
|
2573
2746
|
" --keep-tray-quit --direct" +
|
|
2574
2747
|
" --headless";
|
|
2575
2748
|
const FLAG_COMMANDS = {
|
|
2576
|
-
json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay"],
|
|
2577
|
-
agent: ["join", "start", "setup", "worker", "service", "init"],
|
|
2749
|
+
json: ["join", "start", "doctor", "status", "history", "usage", "audit", "pending", "rewire", "relay", "setup"],
|
|
2750
|
+
agent: ["join", "start", "setup", "worker", "service", "init", "policy"],
|
|
2578
2751
|
};
|
|
2579
2752
|
const KNOWN_FLAGS = new Set([...`${Object.values(COMMAND_FLAGS).join(" ")} ${EXTRA_FLAGS}`.matchAll(/--([a-z][a-z0-9-]*)/g)].map((m) => m[1]));
|
|
2580
2753
|
function refuseUnknownFlags() {
|
|
@@ -2798,8 +2971,8 @@ async function main() {
|
|
|
2798
2971
|
console.error(D(` ${r.reach.hint}`));
|
|
2799
2972
|
}
|
|
2800
2973
|
if (r.claimed) {
|
|
2801
|
-
await bindProjectFromScratch();
|
|
2802
2974
|
await bindReposHere(argv.includes("--yes"));
|
|
2975
|
+
await askProjectFolder();
|
|
2803
2976
|
await workerAfterBinding(wp.how);
|
|
2804
2977
|
windowsOverridesForBoundRepos();
|
|
2805
2978
|
await applyAgentChoice(load() ?? r.cfg, agentWant);
|
|
@@ -3123,7 +3296,7 @@ async function main() {
|
|
|
3123
3296
|
await findAndBindRepos(all, m, teamRepos, { auto: !process.stdin.isTTY, recents: false, ...(inRepo ? { askFolder: false, quiet: true } : {}) }).catch(() => { });
|
|
3124
3297
|
}
|
|
3125
3298
|
}
|
|
3126
|
-
await
|
|
3299
|
+
await askProjectFolder();
|
|
3127
3300
|
await workerAfterBinding(wp.how);
|
|
3128
3301
|
windowsOverridesForBoundRepos();
|
|
3129
3302
|
const joined = load();
|
|
@@ -3335,8 +3508,34 @@ async function main() {
|
|
|
3335
3508
|
sayAgentReadiness(load() ?? cfg);
|
|
3336
3509
|
return;
|
|
3337
3510
|
}
|
|
3511
|
+
const wakeNow = () => { try {
|
|
3512
|
+
return wakeMode(loadProfile(load() ?? cfg));
|
|
3513
|
+
}
|
|
3514
|
+
catch {
|
|
3515
|
+
return "anyone";
|
|
3516
|
+
} };
|
|
3517
|
+
if (guideAsks(preset) && !inWokenRun() && wakeNow() !== "no")
|
|
3518
|
+
await askProjectFolder(cfg);
|
|
3338
3519
|
await guidedSetup(cfg, repoInfo(process.cwd())?.root ?? null, { force: true, preset, command: "setup" });
|
|
3339
3520
|
sayAgentReadiness(load() ?? cfg);
|
|
3521
|
+
if (!guideAsks(preset) && !inWokenRun() && wakeNow() !== "no" && !argv.includes("--no-worker")) {
|
|
3522
|
+
const all = loadAll();
|
|
3523
|
+
const m = all ? findMembership(all, cfg.spaceId ?? cfg.space) ?? findMembership(all, cfg.space) : null;
|
|
3524
|
+
const { teamLinked } = await import("./folder-ask.js");
|
|
3525
|
+
if (all && m && !teamLinked(all, m.id)) {
|
|
3526
|
+
const ask = await folderAskFor(m, all);
|
|
3527
|
+
console.error("");
|
|
3528
|
+
if (process.stdin.isTTY) {
|
|
3529
|
+
console.error(`\x1b[33m ${ask.lines.find((l) => l.startsWith("This computer"))}\x1b[0m`);
|
|
3530
|
+
console.error(` → from the folder you work in (a repo, or a folder of documents): ${C(pantheonCommand(managedLayout()?.launcher, `use ${m.name} --here`))}`);
|
|
3531
|
+
}
|
|
3532
|
+
else
|
|
3533
|
+
for (const l of ask.lines)
|
|
3534
|
+
console.error(` ${l}`);
|
|
3535
|
+
if (JSON_OUT)
|
|
3536
|
+
sayJson({ status: "needs_person", code: 0, ...ask.json });
|
|
3537
|
+
}
|
|
3538
|
+
}
|
|
3340
3539
|
return;
|
|
3341
3540
|
}
|
|
3342
3541
|
case "version": {
|
|
@@ -3392,7 +3591,7 @@ async function main() {
|
|
|
3392
3591
|
console.log(` ${p.online ? C("●") : D("○")} ${p.id.padEnd(14)} ${D(p.agent.padEnd(12))} ${reach}`);
|
|
3393
3592
|
{
|
|
3394
3593
|
const est = pickupEstimate(p, { now: client.relayNow() });
|
|
3395
|
-
if (est.kind === "unavailable")
|
|
3594
|
+
if (est.kind === "unavailable" || est.kind === "not-set-up")
|
|
3396
3595
|
console.log(` ${" ".repeat(16)}\x1b[33m${termSafe(est.says)}\x1b[0m`);
|
|
3397
3596
|
}
|
|
3398
3597
|
}
|
|
@@ -5910,7 +6109,7 @@ async function main() {
|
|
|
5910
6109
|
return;
|
|
5911
6110
|
}
|
|
5912
6111
|
case "policy": {
|
|
5913
|
-
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");
|
|
6112
|
+
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");
|
|
5914
6113
|
const { COMMAND_GRANT_SCOPE } = await import("./agents.js");
|
|
5915
6114
|
const sub = argv[1];
|
|
5916
6115
|
{
|
|
@@ -5951,6 +6150,53 @@ async function main() {
|
|
|
5951
6150
|
}
|
|
5952
6151
|
if (sub === "set") {
|
|
5953
6152
|
const key = argv[2];
|
|
6153
|
+
if (key === "model") {
|
|
6154
|
+
if (inWokenRun())
|
|
6155
|
+
die("a woken run cannot change the model runs use — a person has to run this here");
|
|
6156
|
+
const agent = flag("agent") ?? "claude-code";
|
|
6157
|
+
if (!RUN_MODEL_AGENTS.includes(agent))
|
|
6158
|
+
die(`unknown agent "${agent}" — one of: ${RUN_MODEL_AGENTS.join(", ")}`);
|
|
6159
|
+
const raw = argv[3];
|
|
6160
|
+
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}`}`;
|
|
6161
|
+
if (!raw)
|
|
6162
|
+
die(usage);
|
|
6163
|
+
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}`);
|
|
6164
|
+
const before = loadPolicy();
|
|
6165
|
+
const was = effectiveRunModel(agent, before);
|
|
6166
|
+
const p = loadPolicy();
|
|
6167
|
+
const models = { ...(p.models ?? {}) };
|
|
6168
|
+
if (next === null)
|
|
6169
|
+
delete models[agent];
|
|
6170
|
+
else
|
|
6171
|
+
models[agent] = next;
|
|
6172
|
+
const now = effectiveRunModel(agent, { models });
|
|
6173
|
+
await protectOrStop([{ setting: "model", about: agent, from: was.model ?? OWN_MODEL, to: now.model ?? OWN_MODEL }]);
|
|
6174
|
+
if (Object.keys(models).length)
|
|
6175
|
+
p.models = models;
|
|
6176
|
+
else
|
|
6177
|
+
delete p.models;
|
|
6178
|
+
savePolicy(p);
|
|
6179
|
+
console.log(`${C("set")} model — ${agent} runs for teammates use ${describeRunModel(now)} ${D("— from the next run, no restart")}`);
|
|
6180
|
+
if (now.from === "own" && agent === "claude-code")
|
|
6181
|
+
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`));
|
|
6182
|
+
return;
|
|
6183
|
+
}
|
|
6184
|
+
if (key === "goal-runs") {
|
|
6185
|
+
if (inWokenRun())
|
|
6186
|
+
die("a woken run cannot change how many runs a goal may take — a person has to run this here");
|
|
6187
|
+
const raw = argv[3];
|
|
6188
|
+
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)`);
|
|
6189
|
+
const was = effectiveGoalRuns(loadPolicy()).runs;
|
|
6190
|
+
await protectOrStop([{ setting: "goal-runs", from: String(was), to: String(next) }]);
|
|
6191
|
+
const p = loadPolicy();
|
|
6192
|
+
if (raw === "default")
|
|
6193
|
+
delete p.goalRuns;
|
|
6194
|
+
else
|
|
6195
|
+
p.goalRuns = next;
|
|
6196
|
+
savePolicy(p);
|
|
6197
|
+
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")}`);
|
|
6198
|
+
return;
|
|
6199
|
+
}
|
|
5954
6200
|
if (key !== "run-minutes" && key !== "idle-seconds")
|
|
5955
6201
|
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)`);
|
|
5956
6202
|
if (key === "idle-seconds") {
|
|
@@ -6060,7 +6306,7 @@ async function main() {
|
|
|
6060
6306
|
return;
|
|
6061
6307
|
}
|
|
6062
6308
|
if (sub && sub !== "show")
|
|
6063
|
-
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(", ")}`);
|
|
6309
|
+
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(", ")}`);
|
|
6064
6310
|
const p = loadPolicy();
|
|
6065
6311
|
const w = workerProc();
|
|
6066
6312
|
console.log(`${B("What this machine's worker may do")}\n`);
|
|
@@ -6098,6 +6344,35 @@ async function main() {
|
|
|
6098
6344
|
console.log(` ${D(`ignored "${r.line}" — ${r.why}`)}`);
|
|
6099
6345
|
}
|
|
6100
6346
|
console.log(` runs ${D("12/hour, 40/day, one at a time, 2 failed attempts then parked (defaults; personas only lower them)")}`);
|
|
6347
|
+
{
|
|
6348
|
+
const gr = effectiveGoalRuns(p);
|
|
6349
|
+
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}>)`)}`);
|
|
6350
|
+
const runAgent = (() => {
|
|
6351
|
+
try {
|
|
6352
|
+
const args = installedServiceArgs("worker") ?? [];
|
|
6353
|
+
const at = args.indexOf("--agent");
|
|
6354
|
+
const pinned = at >= 0 ? args[at + 1] : undefined;
|
|
6355
|
+
const c = load();
|
|
6356
|
+
return chooseAgent(pinned, { ...(c ? { prefer: loadProfile(c).agent.primary_surface } : {}), check: null }).backend.id;
|
|
6357
|
+
}
|
|
6358
|
+
catch {
|
|
6359
|
+
return null;
|
|
6360
|
+
}
|
|
6361
|
+
})();
|
|
6362
|
+
const LABEL = { "claude-code": "Claude Code", codex: "Codex", cursor: "Cursor", copilot: "Copilot", kiro: "Kiro" };
|
|
6363
|
+
const shown = runAgent && RUN_MODEL_AGENTS.includes(runAgent) ? runAgent : "claude-code";
|
|
6364
|
+
const routing = claudeRouting();
|
|
6365
|
+
const cm = effectiveRunModel(shown, p, shown === "claude-code" ? routing : null);
|
|
6366
|
+
const how = shown !== "claude-code"
|
|
6367
|
+
? ` ${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})`)}`
|
|
6368
|
+
: 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>)"
|
|
6369
|
+
: cm.from === "provider" ? ` — your Claude Code is set up through ${routing}, so runs keep its own model (choose one: pantheon policy set model <name>)`
|
|
6370
|
+
: " (back to the default: pantheon policy set model default)");
|
|
6371
|
+
console.log(` model ${LABEL[shown]} runs use ${describeRunModel(cm)}${how}`);
|
|
6372
|
+
for (const a of RUN_MODEL_AGENTS)
|
|
6373
|
+
if (a !== shown && (p.models?.[a] || a === "claude-code"))
|
|
6374
|
+
console.log(` ${D(`${LABEL[a]} runs use ${describeRunModel(effectiveRunModel(a, p, a === "claude-code" ? routing : null))}`)}`);
|
|
6375
|
+
}
|
|
6101
6376
|
{
|
|
6102
6377
|
const lim = effectiveRunMinutes({ policy: p });
|
|
6103
6378
|
const lowered = pers.filter((x) => x.maxRunMinutes !== undefined && x.maxRunMinutes < lim.minutes);
|
|
@@ -7359,6 +7634,7 @@ async function main() {
|
|
|
7359
7634
|
}
|
|
7360
7635
|
const runMinutesFlag = flag("run-minutes") === undefined ? undefined : (await import("./worker-policy.js")).parseRunMinutes(flag("run-minutes")) ?? die((await import("./worker-policy.js")).runMinutesProblem(flag("run-minutes")).replace("pantheon policy set run-minutes default", "leave --run-minutes off"));
|
|
7361
7636
|
(await import("./machine.js")).recordWorkerPid();
|
|
7637
|
+
await trackServiceStart("worker", argv.includes("--no-notify"));
|
|
7362
7638
|
const allCfg = loadAll();
|
|
7363
7639
|
const bindings = Object.values(allCfg?.bindings ?? {});
|
|
7364
7640
|
if (!flag("project")) {
|
|
@@ -7653,6 +7929,17 @@ async function main() {
|
|
|
7653
7929
|
const m = await import("./machine.js");
|
|
7654
7930
|
m.recordWorkerPid(m.notifierPidFile());
|
|
7655
7931
|
}
|
|
7932
|
+
await trackServiceStart("notifier", false);
|
|
7933
|
+
const { VersionWatch } = await import("./version-health.js");
|
|
7934
|
+
const versionWatch = new VersionWatch({
|
|
7935
|
+
relays: () => cfgs.map((c) => c.relay),
|
|
7936
|
+
send: (n) => sendDesktopNotification(n),
|
|
7937
|
+
log: (line) => console.error(line),
|
|
7938
|
+
policy: () => loadPolicy(),
|
|
7939
|
+
workerRunning: () => serviceInstalled("worker") && workerProc().running,
|
|
7940
|
+
alertsOn: () => decisionAlertsOn(),
|
|
7941
|
+
});
|
|
7942
|
+
versionWatch.start();
|
|
7656
7943
|
if (process.platform === "win32") {
|
|
7657
7944
|
try {
|
|
7658
7945
|
const { ensureUriHandler } = await import("./notice-windows.js");
|
|
@@ -7666,9 +7953,14 @@ async function main() {
|
|
|
7666
7953
|
n.stop(); process.exit(0); };
|
|
7667
7954
|
process.on("SIGINT", stopAll);
|
|
7668
7955
|
process.on("SIGTERM", stopAll);
|
|
7669
|
-
|
|
7670
|
-
|
|
7956
|
+
let networkOnly = false;
|
|
7957
|
+
const ok = await runNotifiers(notifiers.map((n, i) => ({ label: cfgs[i].space, run: () => n.run(), stopped: () => n.isStopped })), { log: (line) => console.error(line), onGiveUp: (errors) => { networkOnly = onlyNetworkFailures(errors); } });
|
|
7958
|
+
versionWatch.stop();
|
|
7959
|
+
if (!ok) {
|
|
7960
|
+
if (networkOnly)
|
|
7961
|
+
(await import("./crash-loop.js")).expectServiceExit();
|
|
7671
7962
|
process.exit(1);
|
|
7963
|
+
}
|
|
7672
7964
|
return;
|
|
7673
7965
|
}
|
|
7674
7966
|
case "doctor": {
|
|
@@ -7811,12 +8103,19 @@ async function main() {
|
|
|
7811
8103
|
const next = argv.includes("--fresh") ? extra : keepServiceFlags(now, extra);
|
|
7812
8104
|
extra.splice(0, extra.length, ...next);
|
|
7813
8105
|
const { describeWorkerFlags } = await import("./setup-changes.js");
|
|
7814
|
-
|
|
8106
|
+
const { selfUpgradeSetupDue } = await import("./worker-policy.js");
|
|
8107
|
+
await protectOrStop([now === null ? { setting: "worker", from: "off", to: "on" } : { setting: "worker", from: describeWorkerFlags(now), to: describeWorkerFlags(next) },
|
|
8108
|
+
...(selfUpgradeSetupDue() ? [{ setting: "self-upgrade", from: "off", to: "on" }] : [])]);
|
|
7815
8109
|
}
|
|
7816
8110
|
console.error(`${B("installing the pantheon worker as a background service")}`);
|
|
7817
8111
|
console.error(D(flag("project") ? ` project ${project} (this checkout only)` : ` serves every repo and folder bound to a team on this machine`));
|
|
7818
8112
|
for (const l of installService(kind, project, extra))
|
|
7819
8113
|
console.error(l);
|
|
8114
|
+
{
|
|
8115
|
+
const selfUpgrade = (await import("./worker-policy.js")).grantSelfUpgradeAtSetup();
|
|
8116
|
+
if (selfUpgrade)
|
|
8117
|
+
console.error(`\n${D(selfUpgrade)}`);
|
|
8118
|
+
}
|
|
7820
8119
|
{
|
|
7821
8120
|
const { wakeChosen } = await import("./profile.js");
|
|
7822
8121
|
const w = wakeChosen();
|
|
@@ -7854,6 +8153,22 @@ async function main() {
|
|
|
7854
8153
|
}
|
|
7855
8154
|
case "use": {
|
|
7856
8155
|
await membershipGate();
|
|
8156
|
+
if (argv.includes("--folder")) {
|
|
8157
|
+
const given = flag("folder");
|
|
8158
|
+
if (!given || given.startsWith("--"))
|
|
8159
|
+
die("usage: pantheon use <team> --here --folder <the folder you work in>");
|
|
8160
|
+
if (!argv.includes("--here"))
|
|
8161
|
+
die("usage: --folder goes with --here: pantheon use <team> --here --folder <the folder you work in>");
|
|
8162
|
+
const dir = projectFolderAnswer(given, homedir(), process.cwd());
|
|
8163
|
+
try {
|
|
8164
|
+
if (!statSync(dir).isDirectory())
|
|
8165
|
+
die(`${dir} is not a folder — nothing was linked`);
|
|
8166
|
+
}
|
|
8167
|
+
catch {
|
|
8168
|
+
die(`there is no folder at ${dir} — nothing was linked`);
|
|
8169
|
+
}
|
|
8170
|
+
process.chdir(dir);
|
|
8171
|
+
}
|
|
7857
8172
|
const all = loadAll() ?? die("not configured. Run `pantheon signup` first.");
|
|
7858
8173
|
if (argv.includes("--unbind")) {
|
|
7859
8174
|
const { folderBinding } = await import("./config.js");
|
|
@@ -7875,6 +8190,7 @@ async function main() {
|
|
|
7875
8190
|
const m = findMembership(all, ref) ?? die(`you are not in a team called "${ref}". Yours: ${Object.values(all.spaces ?? {}).map((x) => x.name).join(", ") || "none"}`);
|
|
7876
8191
|
if (argv.includes("--here")) {
|
|
7877
8192
|
const r = repoInfo(process.cwd());
|
|
8193
|
+
const wantWorker = await workerWithFirstLink(all, m);
|
|
7878
8194
|
const askFolder = async () => {
|
|
7879
8195
|
const { folderBinding } = await import("./config.js");
|
|
7880
8196
|
const cur = r ? all.bindings?.[r.fingerprint] : folderBinding(all, process.cwd());
|
|
@@ -7884,9 +8200,14 @@ async function main() {
|
|
|
7884
8200
|
catch {
|
|
7885
8201
|
return process.cwd();
|
|
7886
8202
|
} })();
|
|
7887
|
-
|
|
8203
|
+
const { selfUpgradeSetupDue } = await import("./worker-policy.js");
|
|
8204
|
+
const worker = wantWorker ? [{ setting: "worker", from: "off", to: "on" }, ...(selfUpgradeSetupDue() ? [{ setting: "self-upgrade", from: "off", to: "on" }] : [])] : [];
|
|
8205
|
+
if (cur && here && cur.space === m.id) {
|
|
8206
|
+
if (worker.length)
|
|
8207
|
+
await protectOrStop(worker);
|
|
7888
8208
|
return;
|
|
7889
|
-
|
|
8209
|
+
}
|
|
8210
|
+
await protectOrStop([{ setting: "folder", about: r ? (r.origin ?? r.root) : process.cwd(), from: cur && here ? `bound to ${findMembership(all, cur.space)?.name ?? cur.space}` : "not bound", to: `bound to ${m.name}` }, ...worker]);
|
|
7890
8211
|
};
|
|
7891
8212
|
if (!r) {
|
|
7892
8213
|
for (let d = resolve(process.cwd());; d = dirname(d)) {
|
|
@@ -7909,11 +8230,14 @@ async function main() {
|
|
|
7909
8230
|
console.error(D(` nothing bound — the folder itself is not bound, since it holds repos`));
|
|
7910
8231
|
else
|
|
7911
8232
|
console.error(D(` Agents opened in those repos now speak as you in "${m.name}". Restart any that are open.`));
|
|
8233
|
+
if (n)
|
|
8234
|
+
await afterLinking(m, wantWorker);
|
|
7912
8235
|
return;
|
|
7913
8236
|
}
|
|
7914
8237
|
const { replaced } = bindFolder(process.cwd(), m.id);
|
|
7915
8238
|
console.error(`${B("bound")} this folder → "${m.name}"${replaced ? D(` (was: ${findMembership(all, replaced.space)?.name ?? replaced.space})`) : ""}`);
|
|
7916
8239
|
console.error(D(` Agents opened here, or in any folder below, now speak as you in "${m.name}". Restart any that are open.`));
|
|
8240
|
+
await afterLinking(m, wantWorker);
|
|
7917
8241
|
return;
|
|
7918
8242
|
}
|
|
7919
8243
|
await askFolder();
|
|
@@ -7930,6 +8254,7 @@ async function main() {
|
|
|
7930
8254
|
}
|
|
7931
8255
|
windowsOverridesForBoundRepos();
|
|
7932
8256
|
console.error(D(` Agents opened in this repo now speak as you in "${m.name}". Restart any that are open.`));
|
|
8257
|
+
await afterLinking(m, wantWorker);
|
|
7933
8258
|
}
|
|
7934
8259
|
else {
|
|
7935
8260
|
setDefaultSpace(m.id);
|