@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/dist/worker.js CHANGED
@@ -21,8 +21,9 @@ import { activeOutages, detectOutage, earliest, isSignOut, outagePredicate, when
21
21
  import { agentSpawn, CmdLineUnsafe } from "./which.js";
22
22
  import { VERSION } from "./version.js";
23
23
  import { composeUpgradeFailed, fetchRelayPkg, recordRelayPkg, upgradeFailedOnce } from "./version-health.js";
24
+ import { heldBack, markRolledBackTold, rolledBackSentence } from "./upgrade-probation.js";
24
25
  import { noteServiceConnected } from "./crash-loop.js";
25
- import { applyAnswer, ASK_EXPIRY_MS, policyUnreadable, CAPABILITY_ARGS, CARRY_REASON, carryOverWakers, dropLedgerGrants, hasWakeOnce, isApprovedWaker, mayAskWake, takeWakeOnce, OLD_RELAY_WAKE, relayKnowsAdmitters, loadPolicy, mayAsk, needsSelfUpgrade, parseGrantAnswer, recordAsk, savePolicy, useGrant, WOKEN_RUN_ENV, takeTeamFlagOnYes, unsandboxedAllowed, policyPath, isNewer, RUN_MINUTES, effectiveRunMinutes, effectiveIdleSeconds, readinessRecheckPath, policyHome, describeRunMinutes, parseRunMinutes, currentMode, wakeSettled, } from "./worker-policy.js";
26
+ import { applyAnswer, ASK_EXPIRY_MS, policyUnreadable, CAPABILITY_ARGS, CARRY_REASON, carryOverWakers, dropLedgerGrants, hasWakeOnce, isApprovedWaker, mayAskWake, takeWakeOnce, OLD_RELAY_WAKE, relayKnowsAdmitters, loadPolicy, mayAsk, needsSelfUpgrade, parseGrantAnswer, recordAsk, savePolicy, useGrant, WOKEN_RUN_ENV, takeTeamFlagOnYes, unsandboxedAllowed, policyPath, isNewer, RUN_MINUTES, effectiveRunMinutes, effectiveIdleSeconds, readinessRecheckPath, policyHome, describeRunMinutes, parseRunMinutes, currentMode, wakeSettled, effectiveRunModel, describeRunModel, effectiveGoalRuns, claudeRouting, } from "./worker-policy.js";
26
27
  import { readinessAlerts } from "./readiness-alert.js";
27
28
  import { clearDeclined, markDeclined, personsOwnThread, pruneDeclined } from "./declined.js";
28
29
  import { loadRunStops, markStopTold, pruneRunStops, requestRunStop, stopFor, stopNote } from "./run-control.js";
@@ -30,7 +31,7 @@ import { runtimeNodeVersion } from "./managed.js";
30
31
  import { removalWords, removedLine, removedNotice, takeTold } from "./removed.js";
31
32
  import { agentHookStates, repairHook, repairNote } from "./notify.js";
32
33
  import { fence, assess } from "./untrusted.js";
33
- import { allowed, closeStartedRun, finishRun, recordRun, startRun } from "./spend.js";
34
+ import { allowed, closeStartedRun, finishRun, goalAllowed, recordRun, startRun } from "./spend.js";
34
35
  import { handledIn, liveReadAt, loadContinued, markContinued, storedIn, storedKey, unmarkContinued, wakeAlertedKey, WORKER_MARK } from "./continued.js";
35
36
  import { decisionAlertsOn, loadProfile, profileForTeam, reservedDecisionsNote, saveProfile, wakeMode } from "./profile.js";
36
37
  import { clip } from "./brief.js";
@@ -941,7 +942,7 @@ DO THIS
941
942
  There is no human in this session. Do not ask for approval; you will not get an answer.
942
943
  Keep going until you have replied, then finish.`;
943
944
  }
944
- export function buildContinuationBrief(act, trigger, branch, persona, canPush = false) {
945
+ export function buildContinuationBrief(act, trigger, branch, persona, canPush = false, more = []) {
945
946
  const placed = branch
946
947
  ? `in an isolated git worktree on branch ${branch}`
947
948
  : `in a scratch directory (your human's workspace is not a git repo, so nothing can be DELIVERED from here)`;
@@ -968,7 +969,7 @@ WHY YOU WERE WOKEN
968
969
  This ${kind} (id ${id}) is addressed to your side and creates no formal obligation —
969
970
  nothing else on this machine will act on it. The continuation lock is already held for this
970
971
  run: do NOT call pantheon_claim.
971
- ${persona ? personaBrief(persona) : ""}
972
+ ${persona ? personaBrief(persona) : ""}${moreRepliesBrief(more)}
972
973
  DO THIS
973
974
  1. pantheon_status, then pantheon_history${inGoal("for")} — if the thread shows your side
974
975
  already responded after this ${kind}, STOP and send nothing; it was handled live.
@@ -982,6 +983,19 @@ DO THIS
982
983
  There is no human in this session. Do not ask for approval; you will not get an answer.
983
984
  Act, reply if a reply is owed, then finish.`;
984
985
  }
986
+ export function moreRepliesBrief(more) {
987
+ if (!more.length)
988
+ return "";
989
+ const blocks = more.map((m) => `${fence("your peer", actLine(m))}\n${riskNote(assess(actLine(m)), "what arrived")}`.trimEnd());
990
+ return `
991
+ ALSO ARRIVED FOR YOU — ${more.length} more ${more.length === 1 ? "reply" : "replies"} with the ball in your court, each already
992
+ locked for this run (do NOT call pantheon_claim for ${more.length === 1 ? "it" : "them"}). Handle each in its OWN goal, after the
993
+ one above, the same way: use the answer; pantheon_send CLOSE in that goal if it settles it, otherwise the
994
+ one act that moves it forward. If one needs code work, do it only if it belongs on this branch; otherwise
995
+ reply in its goal and leave the code for a run of its own. One you leave untouched gets a run of its own.
996
+ ${blocks.join("\n\n")}
997
+ `;
998
+ }
985
999
  export function autopilotBrief(who) {
986
1000
  return `
987
1001
 
@@ -1076,6 +1090,7 @@ export function composePickups(items, space) {
1076
1090
  export const UNSANDBOXED_RUN = `\n\nTHIS RUN HAS NO SANDBOX. Never run code a teammate wrote: their branch, a patch or a script they sent, or a\ntest they changed. Read and review it, then ESCALATE to your human to run it. The repo's own commands on your\nown changes are fine.`;
1077
1091
  export const TASK_POINTER = "Your task for this run is in the file .pantheon-task.md in the current directory. Read that file first and follow it: it is the whole brief.";
1078
1092
  let fleetLock = null;
1093
+ let rolledBackSaid = null;
1079
1094
  export const RUN_TIMEOUT_MS = RUN_MINUTES.default * 60_000;
1080
1095
  export const RUN_TIMEOUT_MAX_MS = RUN_MINUTES.max * 60_000;
1081
1096
  function recordLimitMs(r) {
@@ -1472,6 +1487,9 @@ const HELD_BACKOFF_MS = 60_000;
1472
1487
  const HELD_BACKOFF_MAX_MS = 30 * 60_000;
1473
1488
  export const EXIT_GRACE_MS = 3_000;
1474
1489
  const CONTINUATION_HORIZON_MS = 24 * 60 * 60_000;
1490
+ export const GATHER_MAX_MS = 10 * 60_000;
1491
+ export const SWEEP_SPAN_MS = 3 * 60_000;
1492
+ export const FOLD_MAX = 5;
1475
1493
  const HELD_CONTINUATIONS_MAX = 20;
1476
1494
  export function answerWindow(askSeq, hint, fullScanDue) {
1477
1495
  if (askSeq !== null)
@@ -3437,6 +3455,13 @@ export class Worker {
3437
3455
  }
3438
3456
  continue;
3439
3457
  }
3458
+ const gc = this.escalationAnswer(client, o) ? null : this.goalCapped(o.goal);
3459
+ if (gc) {
3460
+ this.decline(o.ref, `its goal has had ${gc.n} runs here today`, `Your worker has done ${gc.n} runs on this goal today — it's yours, or it'll take it after ${whenWords(gc.freeAt)}`);
3461
+ await this.sayGoalCapped(client, o.goal, gc, null);
3462
+ await this.tellAskerDeclined(client, o, reqAct, `it has done ${gc.n} runs on this goal today; it can take it after ${whenWords(gc.freeAt)}`, "goal_cap");
3463
+ continue;
3464
+ }
3440
3465
  return { i, o, act: reqAct, persona: sel.persona };
3441
3466
  }
3442
3467
  return null;
@@ -3489,6 +3514,11 @@ export class Worker {
3489
3514
  body: `${act.act} from ${act.from}: ${act.body.split("\n")[0]?.slice(0, 120) ?? ""}`,
3490
3515
  }, held, false);
3491
3516
  }
3517
+ else if (this.goalCapped(pick.continuation.goal)) {
3518
+ const act = pick.continuation, gc = this.goalCapped(act.goal);
3519
+ this.requeueContinuation(act, Math.max(5_000, gc.freeAt - Date.now()));
3520
+ await this.sayGoalCapped(client, act.goal, gc, act.from);
3521
+ }
3492
3522
  else
3493
3523
  ({ continuation, persona } = pick);
3494
3524
  }
@@ -3529,11 +3559,7 @@ export class Worker {
3529
3559
  continue;
3530
3560
  }
3531
3561
  if (continuation && me?.work && !me.work.busy && me.work.idle_since !== null && this.liveThread(client, continuation)) {
3532
- const asked = continuation.ref ? client.seenAct(continuation.ref)?.session : undefined;
3533
- const open = new Set(me.sessions.map((s) => s.id));
3534
- const shown = asked && open.has(asked) ? (this.opts.home !== undefined ? [this.opts.home, undefined] : [undefined])
3535
- .flatMap((h) => liveReadAt(this.contKeys(), continuation.id, h)).filter((m) => m.session === asked) : [];
3536
- if (shown.some((m) => me.work.idle_since >= m.at)) {
3562
+ if (this.shownToAsker(client, me, continuation)) {
3537
3563
  this.markDone(continuation.id);
3538
3564
  this.forgetQueued(continuation.id);
3539
3565
  this.opts.log(`- not continuing from ${continuation.act} ${continuation.id}: the window that asked was shown it, and its turn ended after that`);
@@ -3556,6 +3582,8 @@ export class Worker {
3556
3582
  maxRunsPerDay: this.opts.maxRunsPerDay,
3557
3583
  });
3558
3584
  const slot = this.takeSlot();
3585
+ let folded = [];
3586
+ let foldedSince = 0;
3559
3587
  if ("held" in slot) {
3560
3588
  this.writeState("watching", `waiting: ${slot.held}`);
3561
3589
  this.tickHold = slot.held === PERSON_ANSWERING
@@ -3615,6 +3643,10 @@ export class Worker {
3615
3643
  this.opts.log(`- not continuing from ${continuation.id}: the worker is stopping`);
3616
3644
  break;
3617
3645
  }
3646
+ folded = await this.foldContinuations(client, continuation, persona, me, !!me && shouldDeferToHuman(me.sessions, me.work, {
3647
+ idleMs: this.idleMs(), busyTtlMs, busySince: this.busyObservedSince, hooksInstalled,
3648
+ }));
3649
+ foldedSince = client.relayNow();
3618
3650
  }
3619
3651
  if (this.readiness && !this.readiness.ok)
3620
3652
  this.checkReadiness(true);
@@ -3624,7 +3656,7 @@ export class Worker {
3624
3656
  try {
3625
3657
  job = candidate
3626
3658
  ? await this.handle(client, candidate, persona, policy, candidateAct)
3627
- : await this.handleContinuation(client, continuation, persona, policy);
3659
+ : await this.handleContinuation(client, continuation, persona, policy, folded);
3628
3660
  }
3629
3661
  catch (e) {
3630
3662
  const msg = e?.message?.split("\n")[0] ?? String(e);
@@ -3750,6 +3782,8 @@ export class Worker {
3750
3782
  }
3751
3783
  }
3752
3784
  this.endAttempt();
3785
+ if (folded.length)
3786
+ this.settleFolded(client, folded, foldedSince);
3753
3787
  this.giveSlot(slot.token);
3754
3788
  if (continuation)
3755
3789
  client.forgetClaim(`cont:${continuation.id}`);
@@ -4053,19 +4087,19 @@ export class Worker {
4053
4087
  const decided = await this.decisionFor(client, o);
4054
4088
  return this.runJob(client, o, persona, policy, (branch, canPush) => buildBrief(o, trigger, branch, persona, canPush, decided), true, needs, trigger, act);
4055
4089
  }
4056
- async handleContinuation(client, act, persona, policy) {
4090
+ async handleContinuation(client, act, persona, policy, more = []) {
4057
4091
  this.markDone(act.id);
4058
4092
  const o = {
4059
4093
  id: `cont:${act.id}`, kind: "CONTINUE", owner: this.cfg.member,
4060
4094
  ref: act.id, goal: act.goal, created_at: act.ts,
4061
4095
  body: `${act.act} from ${act.from}: ${act.body.split("\n")[0]?.slice(0, 120) ?? ""}`,
4062
4096
  };
4063
- this.opts.log(`> continuing from ${act.act} ${act.id} by ${act.from}${persona ? ` — persona "${persona.name}"` : ""}`);
4097
+ this.opts.log(`> continuing from ${act.act} ${act.id} by ${act.from}${persona ? ` — persona "${persona.name}"` : ""}${more.length ? ` — with ${more.length} more ${more.length === 1 ? "reply" : "replies"} in the same run: ${more.map((m) => `${m.act} ${m.id} by ${m.from}`).join(", ")}` : ""}`);
4064
4098
  this.lastHold = "";
4065
4099
  this.report("running", `${act.act} ${act.id}`, undefined, { ref: act.id, ...(act.goal ? { goal: act.goal } : {}) });
4066
4100
  const trigger = actLine(act);
4067
4101
  const needs = workNeedsCommands("CONTINUE", trigger, act.act);
4068
- return this.runJob(client, o, persona, policy, (branch, canPush) => buildContinuationBrief(act, trigger, branch, persona, canPush), false, needs, trigger, act);
4102
+ return this.runJob(client, o, persona, policy, (branch, canPush) => buildContinuationBrief(act, trigger, branch, persona, canPush, more), false, needs || more.some((m) => workNeedsCommands("CONTINUE", actLine(m), m.act)), trigger, act);
4069
4103
  }
4070
4104
  spentOnce = {};
4071
4105
  policyBytes() { try {
@@ -4279,6 +4313,20 @@ export class Worker {
4279
4313
  this.lastFeaturesSaid = said;
4280
4314
  }
4281
4315
  }
4316
+ const routing = agentId === "claude-code" ? claudeRouting(process.env, this.opts.home ?? homedir()) : null;
4317
+ const runModel = (() => { try {
4318
+ return effectiveRunModel(agentId, loadPolicy(this.opts.home), routing);
4319
+ }
4320
+ catch {
4321
+ return effectiveRunModel(agentId, null, routing);
4322
+ } })();
4323
+ {
4324
+ const said = `${agentId ?? "agent"}: ${describeRunModel(runModel)}`;
4325
+ if (said !== this.lastModelSaid) {
4326
+ this.opts.log(` model ${said}${runModel.from === "default" ? " — pantheon policy set model <name|own> to change it" : ""}`);
4327
+ this.lastModelSaid = said;
4328
+ }
4329
+ }
4282
4330
  const codexReadOnly = place.kind === "folder" && agentId === "codex" && !this.opts.agentCmd;
4283
4331
  const byCli = !!this.opts.agentCmd && !!this.opts.agentCmdFromCli;
4284
4332
  const noCommandsHere = features?.unknown ? "unknown"
@@ -4469,6 +4517,7 @@ export class Worker {
4469
4517
  const plan = headlessSpawn({
4470
4518
  backend, binary, prompt: brief, worktree, cfg: runCfg, branch, allowBash, runHome,
4471
4519
  ...(claudeToken ? { claudeToken } : {}),
4520
+ ...(runModel.model ? { model: runModel.model } : {}),
4472
4521
  ...(attached.length ? { readOnlyDirs: attached.map((a) => a.path) } : {}),
4473
4522
  ...(baseSha ? { base: baseSha } : {}), ...(tipSha ? { commandsRev: tipSha } : {}), goal,
4474
4523
  ...(features ? { claude: { features, pantheonHome: this.stateDir(), home: personHome, userSettings: join(personHome, ".claude", "settings.json"), ...(() => { const c = adoptedCommon(worktree); return c ? { gitCommon: c } : {}; })() } } : {}),
@@ -4846,6 +4895,7 @@ export class Worker {
4846
4895
  }
4847
4896
  }
4848
4897
  lastFeaturesSaid = "";
4898
+ lastModelSaid = "";
4849
4899
  notesSaid = new Set();
4850
4900
  restoreHomeAfterRun(before, o) {
4851
4901
  let changes = [];
@@ -5865,10 +5915,119 @@ export class Worker {
5865
5915
  }
5866
5916
  continue;
5867
5917
  }
5918
+ if (this.gathering(client, r)) {
5919
+ this.contQueue.push({ act: r, notBefore: now + Math.min(15_000, this.opts.gatherMs ?? GATHER_MAX_MS) });
5920
+ if (!this.skipLogged.has(`gather:${r.id}`)) {
5921
+ this.skipLogged.add(`gather:${r.id}`);
5922
+ this.opts.log(`- waiting with ${r.act} ${r.id}: other teammates asked at the same time have not answered yet — up to ${Math.round((this.opts.gatherMs ?? GATHER_MAX_MS) / 60_000)} min, so their answers share one run`);
5923
+ }
5924
+ continue;
5925
+ }
5868
5926
  return { continuation: r, ...(sel.persona ? { persona: sel.persona } : {}) };
5869
5927
  }
5870
5928
  return undefined;
5871
5929
  }
5930
+ shownToAsker(client, me, r) {
5931
+ if (!me?.work || me.work.busy || me.work.idle_since === null || !this.liveThread(client, r))
5932
+ return false;
5933
+ const asked = r.ref ? client.seenAct(r.ref)?.session : undefined;
5934
+ const open = new Set(me.sessions.map((s) => s.id));
5935
+ const shown = asked && open.has(asked) ? (this.opts.home !== undefined ? [this.opts.home, undefined] : [undefined])
5936
+ .flatMap((h) => liveReadAt(this.contKeys(), r.id, h)).filter((m) => m.session === asked) : [];
5937
+ return shown.some((m) => me.work.idle_since >= m.at);
5938
+ }
5939
+ gatherSince = new Map();
5940
+ myAsk(client, r) {
5941
+ if (r.act !== "ANSWER" || !r.ref)
5942
+ return null;
5943
+ const ask = client.seenAct(r.ref);
5944
+ return ask && ask.act === "ASK" && ask.from === this.cfg.member ? ask : null;
5945
+ }
5946
+ sameSweep(a, b) {
5947
+ return a.id === b.id || Math.abs(a.ts - b.ts) <= SWEEP_SPAN_MS;
5948
+ }
5949
+ gathering(client, r) {
5950
+ const ask = this.myAsk(client, r);
5951
+ if (!ask)
5952
+ return false;
5953
+ const max = this.opts.gatherMs ?? GATHER_MAX_MS;
5954
+ const since = this.gatherSince.get(r.id) ?? Date.now();
5955
+ if (!this.gatherSince.has(r.id)) {
5956
+ this.gatherSince.set(r.id, since);
5957
+ if (this.gatherSince.size > 500)
5958
+ this.gatherSince.delete(this.gatherSince.keys().next().value);
5959
+ }
5960
+ if (Date.now() - since >= max)
5961
+ return false;
5962
+ return client.obligations.some((o) => {
5963
+ if (o.kind !== "ANSWER" || o.owner === this.cfg.member || o.owner.startsWith("human:"))
5964
+ return false;
5965
+ const other = client.seenAct(o.ref);
5966
+ return !!other && other.act === "ASK" && other.from === this.cfg.member && this.sameSweep(ask, other);
5967
+ });
5968
+ }
5969
+ async foldContinuations(client, primary, persona, me, personPresent) {
5970
+ const ask = this.myAsk(client, primary);
5971
+ const fits = (r) => {
5972
+ if (r.id === primary.id || r.act !== "ANSWER")
5973
+ return false;
5974
+ if (primary.goal && r.goal === primary.goal)
5975
+ return true;
5976
+ const other = ask ? this.myAsk(client, r) : null;
5977
+ return !!ask && !!other && this.sameSweep(ask, other);
5978
+ };
5979
+ const out = [];
5980
+ for (const c of [...this.contQueue]) {
5981
+ if (out.length >= FOLD_MAX)
5982
+ break;
5983
+ const r = c.act;
5984
+ if (!fits(r) || this.contDone.has(r.id))
5985
+ continue;
5986
+ const g = r.goal ? client.goals.get(r.goal) : undefined;
5987
+ if (g?.state === "CLOSED" || stopFor(`cont:${r.id}`, this.opts.home))
5988
+ continue;
5989
+ if (settledReply(r, client.mineSince(r.ts, r.goal), (id) => client.seenAct(id), this.cfg.member))
5990
+ continue;
5991
+ if (this.shownToAsker(client, me, r))
5992
+ continue;
5993
+ if (personPresent && !this.workerThread(client, r))
5994
+ continue;
5995
+ if (this.goalCapped(r.goal))
5996
+ continue;
5997
+ const sel = this.selectPersona(client, { id: `cont:${r.id}`, kind: "CONTINUE", owner: this.cfg.member, ref: r.id, goal: r.goal, created_at: r.ts, body: r.body.slice(0, 120) }, r.from);
5998
+ if (sel.skip || sel.persona?.name !== persona?.name)
5999
+ continue;
6000
+ if (await this.requestTrust(client, null, r))
6001
+ continue;
6002
+ if (await this.wakeRefusal(client, r.id, { from: r.from, role: r.role }))
6003
+ continue;
6004
+ if (this.heldForSandbox(sel.persona?.agent ?? this.opts.agent))
6005
+ continue;
6006
+ try {
6007
+ await client.claim(`cont:${r.id}`);
6008
+ }
6009
+ catch {
6010
+ continue;
6011
+ }
6012
+ this.contQueue = this.contQueue.filter((x) => x.act.id !== r.id);
6013
+ out.push(r);
6014
+ }
6015
+ return out;
6016
+ }
6017
+ settleFolded(client, folded, since) {
6018
+ for (const r of folded) {
6019
+ client.forgetClaim(`cont:${r.id}`);
6020
+ const acted = client.mineSince(since).some((a) => a.ref === r.id || (!!r.goal && a.goal === r.goal));
6021
+ if (acted) {
6022
+ this.markDone(r.id);
6023
+ this.forgetQueued(r.id);
6024
+ continue;
6025
+ }
6026
+ this.opts.log(`- ${r.act} ${r.id} rode along but nothing was sent about it — it gets a run of its own`);
6027
+ void client.releaseClaim(`cont:${r.id}`).catch(() => false);
6028
+ this.requeueContinuation(r, 0);
6029
+ }
6030
+ }
5872
6031
  lastHealthCheck = 0;
5873
6032
  async maintain(client, arrived) {
5874
6033
  const home = this.opts.home;
@@ -5917,6 +6076,32 @@ export class Worker {
5917
6076
  const lastAttempt = policy.attempts.self_upgrade ?? null;
5918
6077
  if (!needsSelfUpgrade(VERSION, relayPkg, lastAttempt))
5919
6078
  return;
6079
+ const back = this.opts.selfUpgrade?.rolledBack ? this.opts.selfUpgrade.rolledBack.read(relayPkg) : heldBack(relayPkg);
6080
+ if (back) {
6081
+ const key = `${back.version}@${back.at}`;
6082
+ if (!back.told_at && rolledBackSaid !== key) {
6083
+ rolledBackSaid = key;
6084
+ const line = rolledBackSentence(back);
6085
+ this.opts.log(`! ${line}`);
6086
+ const canAlert = !!this.opts.notify && decisionAlertsOn() && (() => { try {
6087
+ return !this.opts.canAlert || this.opts.canAlert();
6088
+ }
6089
+ catch {
6090
+ return false;
6091
+ } })();
6092
+ if (canAlert) {
6093
+ try {
6094
+ this.opts.notify?.({ kind: "worker", who: "Pantheon · this computer", heading: `Pantheon went back to ${back.back_to}`, context: this.cfg.space, body: line, ttl: 0, sound: false });
6095
+ }
6096
+ catch { }
6097
+ }
6098
+ if (this.opts.selfUpgrade?.rolledBack)
6099
+ this.opts.selfUpgrade.rolledBack.told();
6100
+ else
6101
+ markRolledBackTold();
6102
+ }
6103
+ return;
6104
+ }
5920
6105
  const nodeNow = this.opts.selfUpgrade?.node ?? (() => runtimeNodeVersion());
5921
6106
  const held = policy.upgradeHeld;
5922
6107
  if (held && held.version === relayPkg && held.node === nodeNow())
@@ -6391,6 +6576,49 @@ export class Worker {
6391
6576
  }, Math.max(PICKUP_COALESCE_MS, b.shownAt + PICKUP_MIN_GAP_MS - now));
6392
6577
  b.timer.unref?.();
6393
6578
  }
6579
+ goalCapped(goal) {
6580
+ if (!goal)
6581
+ return null;
6582
+ let cap = effectiveGoalRuns(null).runs;
6583
+ try {
6584
+ cap = effectiveGoalRuns(loadPolicy(this.opts.home)).runs;
6585
+ }
6586
+ catch { }
6587
+ const g = goalAllowed(goal, cap, this.opts.home);
6588
+ return g.ok ? null : { n: g.n, cap, freeAt: g.freeAt };
6589
+ }
6590
+ async sayGoalCapped(client, goal, gc, peer) {
6591
+ const key = `goal-cap-said:${goal}:${Math.floor(Date.now() / 86_400_000)}`;
6592
+ this.loadContinued();
6593
+ if (this.contDone.has(key) || this.continuedHas(key))
6594
+ return;
6595
+ this.markDone(key);
6596
+ const title = client.goals.get(goal)?.title ?? "one goal";
6597
+ const when = whenWords(gc.freeAt);
6598
+ this.opts.log(`! goal ${goal}: ${gc.n} runs in the last 24 hours, its limit is ${gc.cap} — what arrives in it waits for you until ${when} (pantheon policy set goal-runs <n> to change the limit)`);
6599
+ try {
6600
+ this.opts.notify?.({
6601
+ kind: "worker", who: "Your worker", heading: "Paused one goal for today", context: title,
6602
+ body: `Your worker has done ${gc.n} runs on this goal in a day, so it stops there until ${when}: two agents may be answering each other. What arrives in it waits for you — nothing is lost.`,
6603
+ ttl: 0, sound: false,
6604
+ });
6605
+ }
6606
+ catch { }
6607
+ if (!peer || peer === this.cfg.member)
6608
+ return;
6609
+ try {
6610
+ await client.send({
6611
+ act: "NOTE", goal, after_seq: Math.max(client.readSeq, client.seq), to: [peer],
6612
+ summary: `${this.cfg.member}'s agent has paused this goal for today — it's with ${this.cfg.member}`,
6613
+ body: `${this.cfg.member}'s agent has done ${gc.n} runs on this goal in a day, so it won't start another on its own until ${when} — it's with ${this.cfg.member} until then. Nothing is lost: what you sent is still there. If it can't wait, remind ${this.cfg.member}.`,
6614
+ meta: { declined: "goal_cap" },
6615
+ });
6616
+ this.opts.log(`* told ${peer} that goal ${goal} waits for ${this.cfg.member} until ${when}`);
6617
+ }
6618
+ catch (e) {
6619
+ this.opts.log(`! could not tell ${peer} that goal ${goal} is paused: ${e.message.split("\n")[0]}`);
6620
+ }
6621
+ }
6394
6622
  async tellAskerDeclined(client, o, act, why, code) {
6395
6623
  const peer = act?.from ?? client.recentFrom(o.ref);
6396
6624
  if (!peer || peer === this.cfg.member)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "format": 1,
3
- "built_at": "2026-11-05T07:13:40.757Z",
3
+ "built_at": "2026-11-15T08:35:44.857Z",
4
4
  "swiftc": "Apple Swift version 6.4.2 (swiftlang-6.4.2.1.9 clang-2100.4.1.1)",
5
5
  "helpers": {
6
6
  "pantheon-tray": {
@@ -17,7 +17,7 @@
17
17
  "pantheon-hud": {
18
18
  "source": "main.swift",
19
19
  "source_sha256": "4976c00b5d4bd0d8c509d2d284d9c6e2d70a1b3db952de5f11108dfff4951a82",
20
- "sha256": "4f41cf800c322ef947945ca7905bbae5faaa9d344594428dbdb09bb4ab20d734",
20
+ "sha256": "7ea1f02fcab4d53b1fd081ce7bef33c73bd092fcf310bef1619a10ac8611c808",
21
21
  "archs": [
22
22
  "arm64",
23
23
  "x86_64"
Binary file
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@join-pantheon/cli",
3
- "version": "0.38.0",
3
+ "version": "0.38.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@join-pantheon/cli",
9
- "version": "0.38.0",
9
+ "version": "0.38.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@modelcontextprotocol/sdk": "^1.32.1",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@join-pantheon/cli",
3
- "version": "0.38.0",
3
+ "version": "0.38.2",
4
4
  "description": "Let your coding agent collaborate directly with your teammates' agents — ask, agree an interface, and deliver, without a human relaying messages.",
5
5
  "type": "module",
6
6
  "bin": {