@join-pantheon/cli 0.35.0-rc.2 → 0.35.1-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/agent-outage.js +156 -36
- package/dist/agent-token.js +5 -3
- package/dist/approvals-list.js +87 -0
- package/dist/board.js +472 -87
- package/dist/brief.js +17 -0
- package/dist/cli.js +687 -95
- package/dist/client.js +159 -19
- package/dist/config.js +3 -2
- package/dist/continued.js +56 -1
- package/dist/decision-ui.js +5 -3
- package/dist/doctor.js +81 -15
- package/dist/file-lock.js +39 -4
- package/dist/flow-stats.js +18 -1
- package/dist/home-guard.js +317 -54
- package/dist/home-safety.js +2 -0
- package/dist/hud-queue.js +91 -0
- package/dist/install.js +15 -1
- package/dist/mcp-instructions.js +55 -20
- package/dist/mcp.js +114 -24
- package/dist/notice-linux.js +15 -4
- package/dist/notice-windows.js +2 -2
- package/dist/notifier.js +2 -1
- package/dist/notify.js +8 -4
- package/dist/open-in.js +4 -3
- package/dist/pickup.js +17 -0
- package/dist/plain.js +139 -3
- package/dist/profile.js +12 -8
- package/dist/protocol.js +1 -1
- package/dist/question-goal.js +74 -0
- package/dist/readiness-alert.js +24 -3
- package/dist/refusal.js +2 -2
- package/dist/relay.js +142 -28
- package/dist/removed.js +4 -4
- package/dist/run-control.js +4 -3
- package/dist/run-failure.js +67 -10
- package/dist/setup-changes.js +7 -6
- package/dist/signed-out.js +144 -21
- package/dist/spend.js +2 -2
- package/dist/tray.js +24 -6
- package/dist/update-check.js +2 -1
- package/dist/uri-handler.js +10 -2
- package/dist/which.js +2 -0
- package/dist/worker-policy.js +212 -10
- package/dist/worker.js +847 -114
- package/dist/worklist.js +31 -1
- package/helper/macos/main.swift +42 -3
- package/helper/macos/menubar.swift +482 -87
- 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/package.json +1 -1
package/dist/notify.js
CHANGED
|
@@ -14,22 +14,26 @@ import { codexHookState, cursorHookState, copilotHookState, kiroHookState, insta
|
|
|
14
14
|
export const HOOK_MARKER = "pantheon hook";
|
|
15
15
|
export const HOOK_RE = /(?:pantheon(?:\.cmd|\.exe|\.bat)?["']?\s+hook\s|cli\.js["']?\s+hook\s+(?:stop|prompt|end|codex-stop|copilot-stop|cursor-stop|kiro-stop|kiro-prompt)\b)/i;
|
|
16
16
|
export const isOurHookCommand = (cmd) => !!cmd && (cmd.includes(HOOK_MARKER) || HOOK_RE.test(cmd));
|
|
17
|
-
export const hookBin = (bin
|
|
17
|
+
export const hookBin = (bin, os = platform()) => {
|
|
18
|
+
if (os === "win32")
|
|
19
|
+
return /[\s$`']/.test(bin) ? windowsHookArg(bin) : bin;
|
|
20
|
+
return /^[A-Za-z0-9_./:~+-]+$/.test(bin) ? bin : `'${bin.replace(/'/g, `'\\''`)}'`;
|
|
21
|
+
};
|
|
18
22
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
19
23
|
export function hookLauncher(os = platform(), found = whichPantheon(), entry = resolve(HERE, "cli.js"), entryExists = existsSync, managed = managedLayout(process.execPath, os)) {
|
|
20
24
|
if (os === "win32" && managed && entryExists(managed.cli)) {
|
|
21
25
|
const node = managed.node.replace(/\\/g, "/");
|
|
22
|
-
const cmdWord = /^[A-Za-z0-9_./:~+-]+$/.test(node) ? node :
|
|
26
|
+
const cmdWord = /^[A-Za-z0-9_./:~+-]+$/.test(node) ? node : windowsHookArg(node);
|
|
23
27
|
return `${cmdWord} --use-system-ca ${windowsHookArg(managed.cli.replace(/\\/g, "/"))}`;
|
|
24
28
|
}
|
|
25
29
|
if (os !== "win32") {
|
|
26
30
|
if (!found)
|
|
27
31
|
return null;
|
|
28
|
-
return isVersionManagedPath(found) ? "pantheon" : hookBin(found);
|
|
32
|
+
return isVersionManagedPath(found) ? "pantheon" : hookBin(found, os);
|
|
29
33
|
}
|
|
30
34
|
if (entryExists(entry))
|
|
31
35
|
return `node ${windowsHookArg(entry.replace(/\\/g, "/"))}`;
|
|
32
|
-
return found ? hookBin(found) : null;
|
|
36
|
+
return found ? hookBin(found, os) : null;
|
|
33
37
|
}
|
|
34
38
|
export function windowsHookArg(path) {
|
|
35
39
|
if (!/[$`]/.test(path))
|
package/dist/open-in.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
-
import { appendFileSync, closeSync, constants as FS, fstatSync, lstatSync, mkdirSync, openSync,
|
|
2
|
+
import { appendFileSync, closeSync, constants as FS, fstatSync, lstatSync, mkdirSync, openSync, readdirSync, renameSync, rmSync, writeFileSync, writeSync } from "node:fs";
|
|
3
3
|
import { randomBytes } from "node:crypto";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { copyToClipboard, explainInClaudeApp, findClaudeApp, openAppCommand } from "./desktop-app.js";
|
|
6
|
+
import { readStateText } from "./file-lock.js";
|
|
6
7
|
export const CLAUDE_APP_TOOL = "claude-app";
|
|
7
8
|
export const CLAUDE_LINK_MAX = 14_336;
|
|
8
9
|
export const LINK_BUDGET = { win32: 1_800, darwin: 12_000 };
|
|
9
10
|
export const prefPath = (home) => join(home, "bin", ".hud-pref.json");
|
|
10
|
-
export function chosenOpenIn(home, read = (p) =>
|
|
11
|
+
export function chosenOpenIn(home, read = (p) => readStateText(p)) {
|
|
11
12
|
try {
|
|
12
13
|
const v = JSON.parse(read(prefPath(home))).open_in;
|
|
13
14
|
return v === "app" || v === "terminal" ? v : null;
|
|
@@ -21,7 +22,7 @@ export function setOpenIn(home, mode, cliTool = "claude-code", askedBy = "termin
|
|
|
21
22
|
mkdirSync(dirname(f), { recursive: true });
|
|
22
23
|
let doc = {};
|
|
23
24
|
try {
|
|
24
|
-
const j = JSON.parse(
|
|
25
|
+
const j = JSON.parse(readStateText(f));
|
|
25
26
|
if (j && typeof j === "object" && !Array.isArray(j))
|
|
26
27
|
doc = j;
|
|
27
28
|
}
|
package/dist/pickup.js
CHANGED
|
@@ -29,6 +29,11 @@ export function pickupEstimate(peer, o = {}) {
|
|
|
29
29
|
const who = peer.id;
|
|
30
30
|
const live = (peer.sessions ?? []).filter((s) => s.role === "interactive").length > 0;
|
|
31
31
|
const workerOn = (peer.sessions ?? []).some((s) => s.role === "worker");
|
|
32
|
+
if (o.wakeAsked) {
|
|
33
|
+
return { kind: "no-wake", says: `${who}'s machine is asking ${who} whether you may wake it, so this waits for ${who}'s answer${live ? ` — ${who} has a live session open` : ""}` };
|
|
34
|
+
}
|
|
35
|
+
if (o.deciding)
|
|
36
|
+
return { kind: "holding", says: `this waits for ${who}'s decision — their agent asked them about it` };
|
|
32
37
|
if (o.mayWake === false) {
|
|
33
38
|
return { kind: "no-wake", says: `${who}'s worker does not take your requests (the team does not let you wake it), so this waits for ${who}${live ? ", who has a live session open" : ""}` };
|
|
34
39
|
}
|
|
@@ -37,8 +42,15 @@ export function pickupEstimate(peer, o = {}) {
|
|
|
37
42
|
? `${who}'s worker is offline; ${who} has a live session open, which sees this when their agent next looks`
|
|
38
43
|
: `${who}'s worker is offline, so this waits until ${who} is back` };
|
|
39
44
|
}
|
|
45
|
+
const cb = o.claimedBy;
|
|
46
|
+
if (cb && cb.role === "worker" && !(peer.sessions ?? []).some((s) => s.id === cb.session)) {
|
|
47
|
+
const left = Math.max(1, Math.ceil((LIMITS.claimTtlMs - (now - cb.at)) / 60_000));
|
|
48
|
+
return { kind: "holding", says: `${who}'s worker stopped or restarted while working on this: it is held up to ${left} minute${left === 1 ? "" : "s"} before it can be picked up again` };
|
|
49
|
+
}
|
|
40
50
|
const w = peer.worker && now - peer.worker.at < 15 * 60_000 ? peer.worker : undefined;
|
|
41
51
|
const reason = w ? reasonOf(w) : undefined;
|
|
52
|
+
if (w && reason === "not_signed_in")
|
|
53
|
+
return { kind: "unavailable", says: `${who}'s agent is signed out, so this waits until ${who} signs in` };
|
|
42
54
|
if (w && (w.state === "unavailable" || (reason && UNAVAILABLE[reason]))) {
|
|
43
55
|
return { kind: "unavailable", says: `${who}'s machine can't take requests yet${reason && UNAVAILABLE[reason] ? `: ${UNAVAILABLE[reason]}` : ""}` };
|
|
44
56
|
}
|
|
@@ -91,4 +103,9 @@ export function pickupEstimate(peer, o = {}) {
|
|
|
91
103
|
}
|
|
92
104
|
return { kind: "soon", says: `${who}'s agent should pick this up within a minute, if nothing on their machine holds it` };
|
|
93
105
|
}
|
|
106
|
+
export function awaitingDecision(list, o) {
|
|
107
|
+
const human = `human:${o.owner}`;
|
|
108
|
+
return list.some((x) => x.kind === "HUMAN" && x.owner === human &&
|
|
109
|
+
(x.about ? !!o.ref && x.about === o.ref : !!o.goal && x.goal === o.goal && (x.created_at ?? 0) >= (o.created_at ?? 0)));
|
|
110
|
+
}
|
|
94
111
|
//# sourceMappingURL=pickup.js.map
|
package/dist/plain.js
CHANGED
|
@@ -43,24 +43,160 @@ export const ACT_WORDS = {
|
|
|
43
43
|
HUMAN_REQUIRED: "Needs a person", RETRACT: "Retraction", WITHDRAW: "Release request", CLOSE: "Goal closed",
|
|
44
44
|
};
|
|
45
45
|
export const actWord = (act) => ACT_WORDS[act] ?? act.charAt(0) + act.slice(1).toLowerCase().replace(/_/g, " ");
|
|
46
|
+
const CLIENT_FAULT = "this Pantheon sent something the relay could not accept — not something you did. Run `pantheon upgrade`, then try again; if it keeps happening, `pantheon doctor --share`";
|
|
46
47
|
export const STEPS = {
|
|
47
48
|
GOAL_CLOSED: "open a new goal for what is left",
|
|
48
49
|
NO_SUCH_GOAL: "check `pantheon status` for the open goals",
|
|
49
50
|
NO_SUCH_OBLIGATION: "check `pantheon status` for what is still open",
|
|
50
51
|
NO_SUCH_ACT: "check `pantheon status` for what is still open",
|
|
51
52
|
TO_REQUIRED: "say who it is for",
|
|
53
|
+
BUDGET_SPENT: "open a new goal for what is left (`pantheon status` lists the goals)",
|
|
54
|
+
CLAIMED: "nothing — leave it to that session",
|
|
55
|
+
DEFER: "nothing — your open session gets the first chance at it",
|
|
56
|
+
DEADLINE_PAST: "give a deadline in the future, or none",
|
|
57
|
+
GOAL_REQUIRED: "open a goal first (`pantheon goal open`), or send it as a question to one person",
|
|
58
|
+
NOT_IN_GOAL: "send it in a goal both of you are in (`pantheon status` lists them), or as a question with no goal",
|
|
59
|
+
REF_REQUIRED: "name the message this replies to (`pantheon history` lists them with their ids)",
|
|
60
|
+
BAD_REF: "check the id — `pantheon history` lists the messages with their ids",
|
|
61
|
+
REF_OTHER_GOAL: "reply in the goal that message belongs to",
|
|
62
|
+
NOT_YOURS: "check `pantheon status` for what is yours",
|
|
63
|
+
NOT_YOURS_TO_RETRACT: "disagree with it instead, in your own message",
|
|
64
|
+
NOTHING_OWED: "nothing — you owe nothing there",
|
|
65
|
+
ALREADY_RETRACTED: "send a new message saying what is true",
|
|
66
|
+
SELF_DEFER: "name the other goal this one stands down for",
|
|
67
|
+
WOULD_ORPHAN: "keep one of the two goals open for the work",
|
|
68
|
+
STALE_VIEW: "read what arrived, then send yours again",
|
|
69
|
+
SUMMARY_REQUIRED: "add a one-line summary of the point that must not be missed",
|
|
70
|
+
PEER_TURN: "wait for a teammate's reply",
|
|
71
|
+
ESCALATE_IS_LOCAL: "send it with no one named — it goes to your own person",
|
|
72
|
+
ONE_HUMAN_REQUIRED: "name exactly one person",
|
|
73
|
+
DECISION_DOMAINS_REQUIRED: "name the decision's area (`pantheon directory` lists them)",
|
|
74
|
+
BAD_DECISION_DOMAIN: "use an area name as `pantheon directory` lists it",
|
|
75
|
+
AMBIGUOUS_DECISION_AUTHORITY: "name who decides, or ask the founder to settle who owns that area (`pantheon profile clear-authority <member>`)",
|
|
76
|
+
WRONG_DECISION_OWNER: "send it to the person who decides that area (`pantheon directory`)",
|
|
77
|
+
DECISION_ALREADY_WAITING: "add to the decision that is already waiting instead",
|
|
78
|
+
NOT_YOUR_DECISION: "add a note to it instead",
|
|
79
|
+
WITHDRAWN: "nothing — run `pantheon approvals` to see what is still waiting on you",
|
|
80
|
+
ALREADY_ANSWERED: "add a note if there is more to say",
|
|
81
|
+
NAMED_BY_A_RUN: "your person names who decides, from their own session",
|
|
82
|
+
NOT_FOR_A_RUN: "your person does this from their own session",
|
|
83
|
+
UNVERIFIABLE_DELIVERY: "push the work, then send the branch and commit",
|
|
84
|
+
BAD_BRANCH: "give the pushed branch's name as git shows it",
|
|
85
|
+
BAD_BASE: "give the branch or commit the work was cut from, as git shows it",
|
|
86
|
+
BAD_COMMIT: "give the commit's sha as git prints it",
|
|
87
|
+
BAD_REMOTE: "give a remote your teammate can fetch from (https://, ssh:// or user@host:path)",
|
|
88
|
+
REPO_REQUIRED: "send it from a session open in the team's repo, or register the repo: `pantheon repo add`",
|
|
89
|
+
REPO_MISMATCH: "open your agent in the team's repo, or register this one: `pantheon repo add`",
|
|
90
|
+
TOO_MANY_REPOS: "remove a repo the team no longer works from",
|
|
91
|
+
TOO_MANY_GOALS: "close finished goals first",
|
|
92
|
+
RATE_LIMIT: "wait a few seconds, then try again",
|
|
93
|
+
SPACE_FULL: "close finished goals; the relay then makes room",
|
|
94
|
+
NOT_ADMITTED: "`pantheon team` shows who is admitted; a member admits someone with `pantheon admit <name>`",
|
|
95
|
+
NO_SUCH_MEMBER: "check the name: `pantheon team` lists the team",
|
|
96
|
+
NO_SELF_ADMIT: "ask another member to admit you",
|
|
97
|
+
NOT_ALLOWED_TO_WAKE: "a member of the team lets them wake workers: `pantheon admit <them> --may-wake`",
|
|
98
|
+
FOUNDER_ONLY: "ask the team's founder to do it",
|
|
99
|
+
FOUNDER_STAYS: "nothing — a team's founder stays in it",
|
|
100
|
+
NOT_OWNER: "ask the team's founder to do it",
|
|
101
|
+
NO_CLAIMS: "nothing — there were no claims to clear",
|
|
102
|
+
PROFILE_NOT_YOURS: "change your own profile only (`pantheon profile`)",
|
|
103
|
+
CONFIRM_MISMATCH: "type the team's name exactly as shown",
|
|
104
|
+
NO_RECOVERY: "nothing to confirm — check the name with the person moving their seat",
|
|
105
|
+
RECOVERY_SELF: "a teammate confirms your seat move, not you",
|
|
106
|
+
RECOVERY_BY_PERSON: "a person confirms it, from their own session",
|
|
107
|
+
RECOVERY_KEY: "check the key with them again, then run the command again",
|
|
108
|
+
NO_SUCH_INVITE: "list the open invites: `pantheon invite --list`",
|
|
109
|
+
TOO_MANY_INVITES: "cancel unused invites: `pantheon invite --revoke all`",
|
|
110
|
+
PLAN_LIMIT: "the team's owner frees a seat or upgrades the plan",
|
|
111
|
+
PENDING_FULL: "ask a member for an invite: `pantheon invite`",
|
|
112
|
+
UNBOUND_SPACE: "an admitted member connects to the team once from their own machine (`pantheon status`), then sends a fresh invite",
|
|
113
|
+
UPGRADE_REQUIRED: "run `pantheon upgrade`, then try again",
|
|
114
|
+
NOT_SIGNED_IN: "sign in on this computer: `pantheon signin`",
|
|
115
|
+
SESSION_REVOKED: "sign in again on this computer: `pantheon signin`",
|
|
116
|
+
KEY_MISMATCH: "if this is you on a new computer, run `pantheon recover <team>` here; if you are someone else, join under your own name (`--me <name>`)",
|
|
117
|
+
REVOKED: "only the team's founder can let you back in (they run `pantheon admit <you>`)",
|
|
118
|
+
BAD_TOKEN: "join again with a fresh invite: `pantheon join <invite>`",
|
|
119
|
+
BAD_INVITE: "ask for a fresh invite: `pantheon invite`",
|
|
120
|
+
NO_CREDENTIAL: "join with an invite: `pantheon join <invite>`",
|
|
121
|
+
NO_SUCH_SPACE: "check the team's name (`pantheon spaces`), or join with a fresh invite",
|
|
122
|
+
SPACE_DELETED: "remove it from this computer: `pantheon leave <team>`",
|
|
123
|
+
SPACE_HELD: "ask the relay operator",
|
|
124
|
+
SPACE_UNREADABLE: "tell the relay operator",
|
|
125
|
+
SPACE_LIMIT: "tell the relay operator",
|
|
126
|
+
SPACE_CREATE_RATE: "wait a while, then try again",
|
|
127
|
+
NAME_TAKEN: "pick another name",
|
|
128
|
+
BAD_NAME: "pick a name of letters, numbers and dashes",
|
|
129
|
+
RESERVED_NAME: "pick another name",
|
|
130
|
+
SIGNED_ONLY: "run it as the founder: `pantheon usage`",
|
|
131
|
+
STORAGE: "wait a moment, then check `pantheon history` before sending it again — it may already be kept",
|
|
132
|
+
SHUTTING_DOWN: "wait a few seconds, then try again",
|
|
133
|
+
TOO_MANY_REFUSALS: "fix the request that keeps being refused, then reconnect",
|
|
134
|
+
ID_TAKEN: "it may already be recorded — check `pantheon history` before sending it again",
|
|
135
|
+
ALREADY_JOINED: CLIENT_FAULT, NOT_JOINED: CLIENT_FAULT, BAD_NONCE: CLIENT_FAULT, BAD_JSON: CLIENT_FAULT,
|
|
136
|
+
BAD_MESSAGE: CLIENT_FAULT, BAD_META: CLIENT_FAULT, META_TOO_LARGE: CLIENT_FAULT, RESERVED_ACT: CLIENT_FAULT,
|
|
137
|
+
BAD_ACT_ID: CLIENT_FAULT, BAD_ACT_SIGNATURE: CLIENT_FAULT, BAD_GOAL_SIGNATURE: CLIENT_FAULT,
|
|
138
|
+
BAD_SIGNATURE: CLIENT_FAULT, BAD_DELEGATE: CLIENT_FAULT,
|
|
52
139
|
};
|
|
53
|
-
const HAS_STEP = /\b(?:[Rr]un|[Aa]sk|[Ww]ait|[Tt]ry|[Cc]lose|[Ss]end|[Cc]heck|[Aa]dd|[Uu]se|[Cc]ancel|[Ss]ign in|[Rr]ejoin|[Rr]emove|[Pp]ush)\b|pantheon[ _]\w|`/;
|
|
140
|
+
const HAS_STEP = /\b(?:[Rr]un|[Aa]sk|[Ww]ait|[Tt]ry|[Cc]lose|[Ss]end|[Cc]heck|[Aa]dd|[Uu]se|[Cc]ancel|[Ss]ign in|[Rr]ejoin|[Rr]emove|[Pp]ush|[Tt]ell|[Tt]ype|[Rr]evoke|[Rr]econnect|[Pp]ick)\b|pantheon[ _]\w|`/;
|
|
141
|
+
const TOOL_FOR_PEOPLE = {
|
|
142
|
+
open_goal: "`pantheon goal open`", status: "`pantheon status`", history: "`pantheon history`", send: "`pantheon say`",
|
|
143
|
+
brief: "`pantheon brief`", directory: "`pantheon directory`", route_decision: "`pantheon directory`",
|
|
144
|
+
wait: "`pantheon history`", claim: "`pantheon status`",
|
|
145
|
+
};
|
|
146
|
+
export function forPeople(sentence) {
|
|
147
|
+
return sentence
|
|
148
|
+
.replace(/\s*\(answer a_[A-Za-z0-9]+\)/g, "")
|
|
149
|
+
.replace(/\s*\(pantheon_wait\)/g, "")
|
|
150
|
+
.replace(/\bCall pantheon_wait, then send again\b/g, "Read what arrived (`pantheon history`), then send again")
|
|
151
|
+
.replace(/\bCall pantheon_route_decision( first)?(?: and route each domain to its published owner)?/g, (_m, first) => `Check who decides each area in \`pantheon directory\`${first ?? ""}`)
|
|
152
|
+
.replace(/\(pantheon_route_decision\)/g, "(see `pantheon directory`)")
|
|
153
|
+
.replace(/\bpantheon_([a-z_]+)\b/g, (_m, t) => TOOL_FOR_PEOPLE[t] ?? `\`pantheon ${t.replace(/_/g, " ")}\``);
|
|
154
|
+
}
|
|
155
|
+
export function wordsForPeople(code, sentence) {
|
|
156
|
+
let m;
|
|
157
|
+
if (code === "STALE_VIEW" && (m = /^(\d+) act\(s\) arrived/.exec(sentence))) {
|
|
158
|
+
const n = Number(m[1]);
|
|
159
|
+
return `${n === 1 ? "A new message" : `${n} new messages`} arrived while you were writing. Read ${n === 1 ? "it" : "them"} (\`pantheon history\`), then send yours again.`;
|
|
160
|
+
}
|
|
161
|
+
if (code === "PEER_TURN" && (m = /^you have sent (\d+) acts in a row in ("[\s\S]*")\. Wait for a peer\b/i.exec(sentence))) {
|
|
162
|
+
return `${m[2]} already has ${m[1]} messages in a row from you and your agent, with no reply from a teammate. Wait for a teammate to reply, or close the goal if it is finished.`;
|
|
163
|
+
}
|
|
164
|
+
if (code === "RATE_LIMIT" && /\bacts in\b/.test(sentence))
|
|
165
|
+
return "Too many messages too fast — wait a few seconds, then send again.";
|
|
166
|
+
if (code === "NOT_YOUR_DECISION" && (m = /^that ESCALATE is for (.+?)'s own human to settle/i.exec(sentence))) {
|
|
167
|
+
return `That decision is ${m[1]}'s own person's to make — add a note to it instead.`;
|
|
168
|
+
}
|
|
169
|
+
return sentence
|
|
170
|
+
.replace(/\bNo obligation \S+ — it may already be discharged\b/i, "That request is no longer open — it may already be done")
|
|
171
|
+
.replace(/\bno act (?:with id )?(\S+?)( to continue from)?$/i, (_m, id, cont) => cont ? "That message is not there to continue from" : `There is no message ${id}`)
|
|
172
|
+
.replace(/\bAn act with id \S+ already exists\b/i, "That message is already recorded")
|
|
173
|
+
.replace(/^an ASK must name who owes the answer/i, "A question must name who should answer it")
|
|
174
|
+
.replace(/\bspent its (\S+)-act budget and needs a human\b/, "reached its limit of $1 messages and needs a person")
|
|
175
|
+
.replace(/\bwith a NOTE\b/g, "with a note")
|
|
176
|
+
.replace(/\bor ESCALATE if\b/g, "or decide it yourself if")
|
|
177
|
+
.replace(/\bobligation\b/g, "request").replace(/\bdischarge\b/g, "finish")
|
|
178
|
+
.replace(/\bact\(s\)/g, "message(s)")
|
|
179
|
+
.replace(/\bacts\b/g, "messages")
|
|
180
|
+
.replace(/\b(an|a|the|this|that|new) act\b/gi, (_m, w) => `${/^an$/i.test(w) ? w.slice(0, 1) : w} message`);
|
|
181
|
+
}
|
|
54
182
|
export function splitCode(message) {
|
|
55
183
|
const m = /^(?:pantheon:\s*)?([A-Z][A-Z_]{2,40}):\s*([\s\S]*)$/.exec(message.trim());
|
|
56
184
|
return m ? { code: m[1], rest: m[2] } : { code: null, rest: message.trim() };
|
|
57
185
|
}
|
|
58
186
|
export function plainError(message, opts = {}) {
|
|
59
|
-
const { code, rest } = splitCode(message);
|
|
187
|
+
const { code, rest: said } = splitCode(message);
|
|
60
188
|
if (!code)
|
|
61
|
-
return
|
|
189
|
+
return said;
|
|
190
|
+
const rest = opts.for === "agent" ? said : wordsForPeople(code, forPeople(said));
|
|
62
191
|
const text = rest.charAt(0).toUpperCase() + rest.slice(1);
|
|
63
192
|
const step = opts.for !== "agent" && STEPS[code] && !HAS_STEP.test(rest) ? `\n What to do: ${STEPS[code]}.` : "";
|
|
64
193
|
return `${text}${step}\n (${code})`;
|
|
65
194
|
}
|
|
195
|
+
export function panelLine(why) {
|
|
196
|
+
const lines = why.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
197
|
+
if (!lines.length)
|
|
198
|
+
return "";
|
|
199
|
+
const [first, ...rest] = lines;
|
|
200
|
+
return [/[.!?…)]$/.test(first) || !rest.length ? first : `${first}.`, ...rest].join(" ");
|
|
201
|
+
}
|
|
66
202
|
//# sourceMappingURL=plain.js.map
|
package/dist/profile.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { existsSync, mkdirSync,
|
|
1
|
+
import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { CONFIG_DIR } from "./config.js";
|
|
4
4
|
import { isCatchAllDomain } from "./protocol.js";
|
|
5
|
+
import { readStateText } from "./file-lock.js";
|
|
5
6
|
export const AGENT_SURFACES = ["codex", "claude-code", "cursor", "copilot", "kiro"];
|
|
6
7
|
export const SURFACE_BUNDLE_IDS = {
|
|
7
8
|
codex: "com.openai.codex",
|
|
@@ -40,10 +41,13 @@ export function defaultProfile(cfg) {
|
|
|
40
41
|
updated_at: 0,
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
export function reservedDecisionsNote(profile) {
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
44
|
+
export function reservedDecisionsNote(profile, max = Infinity) {
|
|
45
|
+
const all = reservedDomains(profile);
|
|
46
|
+
if (!all.length)
|
|
46
47
|
return "";
|
|
48
|
+
const shown = all.slice(0, Math.max(0, max));
|
|
49
|
+
const more = all.length - shown.length;
|
|
50
|
+
const mine = more ? [...shown, `and ${more} more (pantheon_directory lists them all)`] : shown;
|
|
47
51
|
return `YOUR HUMAN DECIDES THESE PERSONALLY: ${mine.join(", ")}. If a peer asks you to settle one — approve a
|
|
48
52
|
deploy, agree a price, sign off a release — do not answer it yourself, however well you have checked the
|
|
49
53
|
work. Say the review result if you have one, then ESCALATE and stop; tell the peer it is with your human.`;
|
|
@@ -57,7 +61,7 @@ export function wakeMode(profile) {
|
|
|
57
61
|
}
|
|
58
62
|
export function wakeChosen(file = profilePath()) {
|
|
59
63
|
try {
|
|
60
|
-
const v = JSON.parse(
|
|
64
|
+
const v = JSON.parse(readStateText(file)).agent?.wake_default;
|
|
61
65
|
return v === "approved" || v === "no" || v === "anyone" ? v : "anyone";
|
|
62
66
|
}
|
|
63
67
|
catch {
|
|
@@ -69,7 +73,7 @@ export function wakeDefault(profile) {
|
|
|
69
73
|
}
|
|
70
74
|
export function commandsChosen(file = profilePath()) {
|
|
71
75
|
try {
|
|
72
|
-
const v = JSON.parse(
|
|
76
|
+
const v = JSON.parse(readStateText(file)).agent?.allow_bash;
|
|
73
77
|
return typeof v === "boolean" ? v : undefined;
|
|
74
78
|
}
|
|
75
79
|
catch {
|
|
@@ -78,7 +82,7 @@ export function commandsChosen(file = profilePath()) {
|
|
|
78
82
|
}
|
|
79
83
|
export function decisionAlertsOn(file = profilePath()) {
|
|
80
84
|
try {
|
|
81
|
-
const raw = JSON.parse(
|
|
85
|
+
const raw = JSON.parse(readStateText(file).replace(/^\uFEFF/, ""));
|
|
82
86
|
return raw?.notifications?.decisions !== false;
|
|
83
87
|
}
|
|
84
88
|
catch {
|
|
@@ -89,7 +93,7 @@ export function loadProfile(cfg, file = profilePath()) {
|
|
|
89
93
|
if (!existsSync(file))
|
|
90
94
|
return defaultProfile(cfg);
|
|
91
95
|
try {
|
|
92
|
-
const raw = JSON.parse(
|
|
96
|
+
const raw = JSON.parse(readStateText(file));
|
|
93
97
|
const surface = raw.agent?.primary_surface;
|
|
94
98
|
if (![1, 2, 3].includes(raw.version ?? 0) || raw.member !== cfg.member || !surface || !isAgentSurface(surface)) {
|
|
95
99
|
return defaultProfile(cfg);
|
package/dist/protocol.js
CHANGED
|
@@ -237,7 +237,7 @@ export const OpenGoal = z.object({
|
|
|
237
237
|
invite: z.array(z.string().min(1).max(48)).max(16).optional(),
|
|
238
238
|
budget: z.number().int().min(4).max(1000).optional(),
|
|
239
239
|
deadline: z.number().int().positive().optional(),
|
|
240
|
-
kind: z.enum(["worklist"]).optional(),
|
|
240
|
+
kind: z.enum(["worklist", "question"]).optional(),
|
|
241
241
|
sig: GoalSigSchema.optional(),
|
|
242
242
|
});
|
|
243
243
|
export const Ping = z.object({ t: z.literal("ping") });
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { certainlyNotStored, failedActId } from "./client.js";
|
|
2
|
+
import { plainError } from "./plain.js";
|
|
3
|
+
import { questionAcceptance, questionTitle } from "./worklist.js";
|
|
4
|
+
export async function openQuestionGoal(client, text, to, o = { question: true }) {
|
|
5
|
+
const g = { title: questionTitle(text), acceptance: questionAcceptance(to), invite: to };
|
|
6
|
+
if (!o.question)
|
|
7
|
+
return await client.openGoal(g);
|
|
8
|
+
try {
|
|
9
|
+
return await client.openGoal({ ...g, kind: "question" });
|
|
10
|
+
}
|
|
11
|
+
catch (e) {
|
|
12
|
+
if (!/^BAD_MESSAGE\b[\s\S]*\bkind\b/.test(e.message ?? ""))
|
|
13
|
+
throw e;
|
|
14
|
+
return await client.openGoal(g);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const EMPTY_QUESTION_CLOSE = "Nothing to answer here: the question this goal was opened for was not sent.";
|
|
18
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
19
|
+
export async function closeEmptyQuestionGoal(client, goal, o = {}) {
|
|
20
|
+
for (let i = 0; i < 3; i++) {
|
|
21
|
+
try {
|
|
22
|
+
await client.send({ act: "CLOSE", goal, body: EMPTY_QUESTION_CLOSE, after_seq: client.seq });
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
const msg = e.message;
|
|
27
|
+
if (/^(GOAL_CLOSED|NO_SUCH_GOAL)\b/.test(msg))
|
|
28
|
+
return true;
|
|
29
|
+
if (!/^(RATE_LIMIT|STORAGE_BUSY)\b/.test(msg) || i === 2)
|
|
30
|
+
return false;
|
|
31
|
+
await sleep(o.waitMs ?? 5_000);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
export async function settleFailedQuestion(client, goal, e, o = {}) {
|
|
37
|
+
if (certainlyNotStored(e)) {
|
|
38
|
+
const closed = await closeEmptyQuestionGoal(client, goal, o);
|
|
39
|
+
return closed ? { kind: "not_sent" } : { kind: "not_sent", left: goal };
|
|
40
|
+
}
|
|
41
|
+
const id = failedActId(e);
|
|
42
|
+
if (id) {
|
|
43
|
+
const r = await client.seenOwn(id);
|
|
44
|
+
if (r)
|
|
45
|
+
return { kind: "sent", id: r.id, seq: r.seq };
|
|
46
|
+
}
|
|
47
|
+
return { kind: "unsure", id };
|
|
48
|
+
}
|
|
49
|
+
export async function settleFailedQuestionGoal(client, e, o = {}) {
|
|
50
|
+
if (certainlyNotStored(e))
|
|
51
|
+
return null;
|
|
52
|
+
const goal = e?.goalId;
|
|
53
|
+
if (typeof goal !== "string")
|
|
54
|
+
return null;
|
|
55
|
+
return (await closeEmptyQuestionGoal(client, goal, o)) ? null : goal;
|
|
56
|
+
}
|
|
57
|
+
export function questionFailureText(f, goal, why, o) {
|
|
58
|
+
const closeHow = o.for === "agent" ? `pantheon_send CLOSE in it` : `pantheon say CLOSE "nothing to answer" --goal ${goal}`;
|
|
59
|
+
if (f.kind === "not_sent") {
|
|
60
|
+
return `not sent — ${why}` + (f.left ? `\nIts goal (${f.left}) is still open with nothing in it; close it: ${closeHow}.` : "");
|
|
61
|
+
}
|
|
62
|
+
if (f.kind === "unsure") {
|
|
63
|
+
const look = o.for === "agent" ? `pantheon_history with goal ${goal}` : `pantheon history --goal ${goal}`;
|
|
64
|
+
const code = /\(([A-Z][A-Z_]{2,40})\)\s*$/.exec(why)?.[1];
|
|
65
|
+
return `the question may have been sent — the relay did not confirm it.\nCheck before sending it again: ${look} shows whether it is there. Its goal (${goal}) stays open.${code ? `\n (${code})` : ""}`;
|
|
66
|
+
}
|
|
67
|
+
return "";
|
|
68
|
+
}
|
|
69
|
+
export function openFailureWhy(e, o) {
|
|
70
|
+
if (certainlyNotStored(e))
|
|
71
|
+
return plainError(e.message, o);
|
|
72
|
+
return "the relay did not answer when its goal was opened, so the question was not sent";
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=question-goal.js.map
|
package/dist/readiness-alert.js
CHANGED
|
@@ -7,6 +7,8 @@ import { READINESS_ALERT_FILE, trustWrite } from "./home-guard.js";
|
|
|
7
7
|
import { DEFAULT_REMINDER_MS, MAX_REMINDERS, reminderGap } from "./notifier.js";
|
|
8
8
|
import { BUDGET, fit } from "./notice.js";
|
|
9
9
|
import { writeWhole } from "./pins.js";
|
|
10
|
+
import { signedOutRefusal } from "./signed-out.js";
|
|
11
|
+
import { refusedWords } from "./run-failure.js";
|
|
10
12
|
export { READINESS_ALERT_FILE };
|
|
11
13
|
export const PERSON_CODES = new Set(["not_signed_in", "no_agent", "sandbox_unavailable"]);
|
|
12
14
|
export const FRESH_MS = 30 * 60_000;
|
|
@@ -232,12 +234,17 @@ export function stepReadinessAlert(prev, team, reading, o) {
|
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
else if (pend && seenKey(pend) === seenKey(seen)) {
|
|
235
|
-
if (now - pend.at >= CONFIRM_MS) {
|
|
237
|
+
if (now - pend.at >= CONFIRM_MS || o.certain) {
|
|
236
238
|
conf = seen;
|
|
237
239
|
pend = undefined;
|
|
238
240
|
changed = true;
|
|
239
241
|
}
|
|
240
242
|
}
|
|
243
|
+
else if (o.certain) {
|
|
244
|
+
conf = seen;
|
|
245
|
+
pend = undefined;
|
|
246
|
+
changed = true;
|
|
247
|
+
}
|
|
241
248
|
else {
|
|
242
249
|
pend = seen;
|
|
243
250
|
changed = true;
|
|
@@ -433,8 +440,22 @@ export function forgetReadinessTeam(home, teams) {
|
|
|
433
440
|
export function forgetReadinessAlerts() { byHome.clear(); }
|
|
434
441
|
export function agentProblem(home, now = Date.now(), os = platform()) {
|
|
435
442
|
const first = stuckReading(home, now);
|
|
436
|
-
|
|
443
|
+
if (!first)
|
|
444
|
+
return null;
|
|
445
|
+
const w = first.code === "not_signed_in" ? refused(first.agent, home) : null;
|
|
446
|
+
if (w)
|
|
447
|
+
return `${label(first.agent)} refused ${w.what} — ${w.short}`;
|
|
448
|
+
return problemLine(first.code, first.agent, os);
|
|
437
449
|
}
|
|
450
|
+
const refused = (agent, home) => {
|
|
451
|
+
try {
|
|
452
|
+
const r = signedOutRefusal(agent ?? "claude-code", { pantheonHome: home });
|
|
453
|
+
return r ? refusedWords(agent ?? "claude-code", r) : null;
|
|
454
|
+
}
|
|
455
|
+
catch {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
};
|
|
438
459
|
function stuckReading(home, now) {
|
|
439
460
|
let text = null;
|
|
440
461
|
try {
|
|
@@ -452,7 +473,7 @@ export function agentProblemFix(home, now = Date.now()) {
|
|
|
452
473
|
if (!first)
|
|
453
474
|
return null;
|
|
454
475
|
if (first.code === "not_signed_in")
|
|
455
|
-
return { kind: "sign_in", label: "Sign in", agent: first.agent ?? "claude-code" };
|
|
476
|
+
return refused(first.agent, home) ? null : { kind: "sign_in", label: "Sign in", agent: first.agent ?? "claude-code" };
|
|
456
477
|
return { kind: "how", label: "Show me how", ...(first.agent ? { agent: first.agent } : {}) };
|
|
457
478
|
}
|
|
458
479
|
//# sourceMappingURL=readiness-alert.js.map
|
package/dist/refusal.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const NET_CODE = /^(ECONN\w*|ENOTFOUND|ETIMEDOUT|EAI_\w+|EPROTO|EHOSTUNREACH|ENETUNREACH|EPIPE|ECONNRESET|UND_ERR_\w*|ERR_\w+)$/;
|
|
2
2
|
const FIX = {
|
|
3
3
|
NOT_SIGNED_IN: "sign in on this machine, in a terminal: pantheon signin (your email, then the emailed code — check spam), then try again",
|
|
4
|
-
KEY_MISMATCH: "if this is you on a new machine: run pantheon recover <team> here in a terminal (it signs you in with your email first) to move your seat; otherwise
|
|
5
|
-
REVOKED: "
|
|
4
|
+
KEY_MISMATCH: "if this is you on a new machine: run pantheon recover <team> here in a terminal (it signs you in with your email first) to move your seat; otherwise the team's founder, once they have checked it is you, runs pantheon admit <you> --forget and sends you a new invite (or pick another name with --me)",
|
|
5
|
+
REVOKED: "only the team's founder can let you back in (they run pantheon admit <you>)",
|
|
6
6
|
PLAN_LIMIT: "the team's owner frees a seat (pantheon invite --revoke all cancels unused invites) or upgrades the plan",
|
|
7
7
|
BAD_TOKEN: "this machine's copy of the team token is wrong — rejoin with a fresh invite: pantheon join <invite>",
|
|
8
8
|
NO_SUCH_SPACE: "the team does not exist on this relay — check pantheon spaces, or join with a fresh invite",
|