@aragon-agent/cli 0.6.64 → 0.6.68
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/CHANGELOG.md +79 -0
- package/README.md +79 -4
- package/dist/agent/controller.d.ts +75 -0
- package/dist/agent/controller.js +128 -1
- package/dist/agent/governance-wiring.js +2 -0
- package/dist/agent/headless.js +24 -3
- package/dist/agent/reconnect-memory.d.ts +68 -0
- package/dist/agent/reconnect-memory.js +82 -0
- package/dist/app/App.js +116 -3
- package/dist/app/use-governance-rounds.d.ts +44 -0
- package/dist/app/use-governance-rounds.js +71 -0
- package/dist/commands/builtins.js +8 -72
- package/dist/commands/catalog.js +1 -1
- package/dist/commands/governance-command.js +45 -3
- package/dist/commands/retry-command.d.ts +52 -0
- package/dist/commands/retry-command.js +225 -0
- package/dist/config/cli-commands.d.ts +2 -2
- package/dist/config/cli-commands.js +54 -0
- package/dist/exec/events.d.ts +12 -0
- package/dist/exec/runner.js +6 -0
- package/dist/gene/cli-commands.js +30 -1
- package/dist/gene/command-report.js +5 -1
- package/dist/gene/curator/budget.d.ts +24 -1
- package/dist/gene/curator/budget.js +67 -14
- package/dist/gene/curator/curator.d.ts +10 -0
- package/dist/gene/curator/curator.js +35 -5
- package/dist/gene/curator/task-context.d.ts +8 -0
- package/dist/gene/curator/task-context.js +10 -0
- package/dist/gene/curator/task-runner.js +16 -5
- package/dist/gene/hub.d.ts +10 -1
- package/dist/gene/hub.js +30 -7
- package/dist/gene/import-plan.js +8 -5
- package/dist/gene/learn/learner.js +7 -3
- package/dist/gene/queue.d.ts +8 -0
- package/dist/gene/queue.js +38 -2
- package/dist/governance/copy.d.ts +8 -0
- package/dist/governance/copy.js +16 -1
- package/dist/governance/engine/cards.js +9 -1
- package/dist/governance/engine/digest.js +6 -2
- package/dist/governance/engine/engine-core.d.ts +12 -0
- package/dist/governance/engine/engine-core.js +29 -0
- package/dist/governance/engine/engine.d.ts +1 -0
- package/dist/governance/engine/engine.js +4 -1
- package/dist/governance/engine/lifecycle.d.ts +36 -1
- package/dist/governance/engine/lifecycle.js +185 -2
- package/dist/governance/engine/report.d.ts +8 -0
- package/dist/governance/engine/report.js +17 -0
- package/dist/governance/engine/stage-runner.js +48 -3
- package/dist/governance/engine/state-machine.d.ts +27 -2
- package/dist/governance/engine/state-machine.js +146 -20
- package/dist/governance/prompts/orchestrator-block.d.ts +2 -0
- package/dist/governance/prompts/orchestrator-block.js +25 -0
- package/dist/governance/store/events-log.d.ts +4 -2
- package/dist/governance/store/events-log.js +4 -2
- package/dist/governance/tools/inspector-tools.js +4 -0
- package/dist/governance/tools/lead-tools.d.ts +1 -1
- package/dist/governance/tools/lead-tools.js +14 -2
- package/dist/host/controller-factory.js +6 -0
- package/dist/logging/install.d.ts +3 -0
- package/dist/logging/install.js +8 -0
- package/dist/session/persist.js +8 -1
- package/dist/session/validate-session.js +15 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -27,9 +27,35 @@ were written.
|
|
|
27
27
|
with any other input cancelling. **Migration:** use `team_stop` (or `/team stop all`) to end a team
|
|
28
28
|
that outlived its turn, because a later `Esc` no longer does it. Both changes are deliberate: one `Esc`
|
|
29
29
|
used to mean "clear my mind", and it must not be able to throw away two hours of work.
|
|
30
|
+
- **The Gene Bank's token budget no longer rations anything: it only meters.** `gene.dailyTokens`
|
|
31
|
+
(rolling 24 h) and `gene.curatorTaskTokens` (per task) used to be hard gates, and a nine-minute burst of
|
|
32
|
+
killed attempts could freeze the whole pipeline - the reviewer included - for a day, so experience that
|
|
33
|
+
happened meanwhile was never reviewed and the queue sat parked until the window slid. Adding, revising
|
|
34
|
+
and retiring genes now never waits for a budget. A positive `gene.dailyTokens` / `gene.curatorTaskTokens`
|
|
35
|
+
is **ignored** (including the old `800000` / `80000` an earlier build wrote into your `config.json`),
|
|
36
|
+
`/gene status` shows `Tokens: N used in the last 24 hours (no daily limit)`, and every token is still
|
|
37
|
+
recorded in the run log. What still stops a runaway is unchanged or internal: 20 turns and 240 s per
|
|
38
|
+
task, an internal 400 000-token valve per task (not a setting), the three-failure circuit breaker, and at
|
|
39
|
+
most two attempts for a task that keeps overrunning. **Migration:** `gene.dailyTokens = 0` still means
|
|
40
|
+
"do not spend anything" and still pauses learning. If you deliberately lowered either number to cap
|
|
41
|
+
spending, set `ARAGON_GENE_BUDGET_ENFORCED=1` in the environment to bring the old ceilings back (it is
|
|
42
|
+
an environment variable on purpose, not a setting). Proposals an old build had parked for a budget window
|
|
43
|
+
are woken the first time a curator takes the lease.
|
|
30
44
|
|
|
31
45
|
### Fixed
|
|
32
46
|
|
|
47
|
+
- **Ctrl+Q no longer says "No genes yet" about a library that holds genes.** The default view is your user
|
|
48
|
+
scope plus the current project, published genes only; with 20 genes in the library (3 published in other
|
|
49
|
+
projects, 17 rejected) it showed an empty list and invited you to write the first one. The empty state now
|
|
50
|
+
says what the whole library holds of that type and in which statuses, what this view shows, the way to
|
|
51
|
+
see the rest, and why the curator is paused when it is. `A` switches the list between this project and
|
|
52
|
+
every project (the title says which), the key reference lists it, and the desktop gene list offers
|
|
53
|
+
"Show all projects" and "Include rejected and archived" in the same place. `aragon gene list` marks any
|
|
54
|
+
non-published row with its status (`(rejected)`, `(archived)`), and a plain listing that finds nothing says
|
|
55
|
+
where the genes are instead of "No genes.".
|
|
56
|
+
- **A pause left in the log by one curator no longer outlives it.** A budget pause written by an old holder
|
|
57
|
+
stayed on the activity chip until some item was claimed, so an empty queue showed `curator paused` for good;
|
|
58
|
+
a new lease holder now clears it and logs its own pause if one applies.
|
|
33
59
|
- **A team run that hit `[Agent] idle watchdog fired` no longer stays dead.** When the model went quiet for
|
|
34
60
|
the whole idle window (210 s by default), or the retry ladder gave up on a transport failure, the run was
|
|
35
61
|
over and nothing started another one: the screen said `N steps left; the run ended with an error.
|
|
@@ -98,6 +124,59 @@ were written.
|
|
|
98
124
|
|
|
99
125
|
### Added
|
|
100
126
|
|
|
127
|
+
- **A governed run now has a ROUND BUDGET, and it can be auto.** A round is one failure-driven
|
|
128
|
+
repeat dispatch - a `fix` stage, or a `dev` stage that reworks a work package - so a clean pass
|
|
129
|
+
through dev / review / test / settle / integrate costs nothing. `governance.rounds` is either a
|
|
130
|
+
number (0-24, yours alone to raise) or `auto`, where the engine derives it from the plan (one
|
|
131
|
+
round per phase plus one per two work packages, floored at 2, capped at 24) and the orchestrator
|
|
132
|
+
may ask for one more with a written reason, twice per run (`gov_run {"action":"rounds",
|
|
133
|
+
"reason":"..."}`). When the budget is spent the engine stops retrying and escalates with a card
|
|
134
|
+
that offers `retry` (grant one more round - this works on a fixed budget too, because the number
|
|
135
|
+
is the user's), `accept_as_is` / `accept_failing`, or `drop`. New entry points: `/gov rounds
|
|
136
|
+
[<n>|auto]`, `Ctrl+Up / Ctrl+Down` in a governance posture with no run in flight
|
|
137
|
+
(`governance.arrowRounds`, on by default - everywhere else the keys still set the team size), a
|
|
138
|
+
`RND` status chip, a `Rounds` chip in the desktop composer, a `Round budget` row in Settings >
|
|
139
|
+
Governance, `aragon config set governance.rounds auto|6`, and the GOV chip's widest rung now
|
|
140
|
+
reads `GOV p2/3 REVIEW R3/5`. Two costs are deliberate and documented: **a pause spends a round**
|
|
141
|
+
(an `Esc` then `/gov resume` re-dispatches the interrupted rework, which is a dispatch like any
|
|
142
|
+
other), and the default (auto) budget is TIGHTER than the old "retry until `maxRework` runs out"
|
|
143
|
+
behaviour - raise it with `/gov rounds`, or rule `retry` on the card.
|
|
144
|
+
|
|
145
|
+
- **Tiered reconnect: a dropped connection now has three gears instead of one.** Ten fast
|
|
146
|
+
retries and then a dead run was the old behaviour, and it is the wrong shape for the outages
|
|
147
|
+
people actually have. The ladder is now fast, then steady, then a hold: **tier 1** is the fast
|
|
148
|
+
ladder exactly as it shipped (10 tries, 1 s doubling to 30 s, equal jitter, 240 s budget, no
|
|
149
|
+
number changed); **tier 2** takes over when tier 1 gives up and tries once a minute, ten
|
|
150
|
+
times; **tier 3** takes over when tier 2 gives up and tries every five minutes, forever — until it reconnects, you press `Esc`, you send a message, or an
|
|
151
|
+
optional cap you set is reached. The hand-over happens INSIDE one request, so nothing is
|
|
152
|
+
replayed and nothing is re-planned: the conversation, the tool results, the todo list and the
|
|
153
|
+
context stay exactly where they were, and the cost is one re-sent request instead of a re-run
|
|
154
|
+
turn.
|
|
155
|
+
|
|
156
|
+
What you see changed with it: the retry card says which tier it is in (`slow retry 2/10`,
|
|
157
|
+
`attempt 4` with no denominator in the last tier), a long countdown reads `4m12s` instead of
|
|
158
|
+
`252s`, the status line carries a live clock (`Reconnecting 2/10 in 42s`), one notice is
|
|
159
|
+
written when each tier starts (and says "then it gives up" rather than promising a tier that
|
|
160
|
+
`bounded` mode does not have), and a run that recovers across tiers settles as
|
|
161
|
+
`recovered after 13 retries`. Tier 3 offers `Esc to stop waiting`, because by then there is no
|
|
162
|
+
request to cancel — only a wait.
|
|
163
|
+
|
|
164
|
+
Six new keys and three new `/retry` verbs: `retry.reconnect` (`auto` | `full` | `bounded` |
|
|
165
|
+
`off`), `retry.slowIntervalMs`, `retry.slowAttempts`, `retry.holdIntervalMs`,
|
|
166
|
+
`retry.holdMaxMinutes` (`0` = no cap, the default) and `retry.stickyRung` (off by default:
|
|
167
|
+
a request that just recovered in a slow tier starts there for the next two minutes, so a
|
|
168
|
+
twenty-minute outage does not cost four minutes of fast retries on every turn);
|
|
169
|
+
`/retry reconnect <mode>`, `/retry slow <secs>`, `/retry hold <minutes>`, and a `/retry show`
|
|
170
|
+
that reads every number it prints from the live config. **No CLI flag was added**: the shape
|
|
171
|
+
of the ladder is a lasting preference, not a per-invocation one, and `--no-retry` /
|
|
172
|
+
`retry.reconnect: off` remain the two ways to say "one tier, as before".
|
|
173
|
+
|
|
174
|
+
Deliberate boundaries: `aragon -p` and `aragon exec` default to **two** tiers (nobody is there
|
|
175
|
+
to press `Esc`, and a pipeline that waits forever is a worse failure than a clear error);
|
|
176
|
+
subagents **never** escalate, because their requests never carry a ladder and a stuck child
|
|
177
|
+
must not hold a whole fan-out open; every attempt is billed, so the README, `/retry show` and
|
|
178
|
+
the desktop hints all say that a long outage costs close to full price.
|
|
179
|
+
|
|
101
180
|
- **Prompt profiles: the red team block's wording now lives in an editable Markdown file.** The
|
|
102
181
|
`<redteam_mode>` block was two halves in one place; now it is two halves in two homes. The **fact**
|
|
103
182
|
half - the authorization line, `What this mode changes`, the closing boundary sentence - stays in
|
package/README.md
CHANGED
|
@@ -957,11 +957,11 @@ ignores them rather than rejecting the library):
|
|
|
957
957
|
| `/resume [file]` | Load a saved session. This session moves to a NEW id, and the spend counter restarts |
|
|
958
958
|
| `/session [copy\|pin]` | Report this session's id, file and branch parent; `copy` puts `aragon --resume <id>` on the clipboard; `pin` makes `sessions prune` skip the file forever |
|
|
959
959
|
| `/plan [on\|off\|status]` | Toggle plan mode (and leave governance) - the keyboard-free equivalent of `Shift+Tab` |
|
|
960
|
-
| `/gov [status\|on\|plan\|off\|board\|runs\|report [id]\|resume [id]\|pause [cancel]\|abort\|budget <n\|off>\|help]` | **Governance mode**: a governed engineering team (dev / review / test / inspector) with a GT scoring economy. `on` = GOVERN, `plan` = PLAN+GOVERN (interview first), `board` opens the full-screen overview, `runs` lists past runs with phase / health / tokens / cost, `report` re-reads a run's report, `pause` stops at the end of the running stage (nothing is killed), `abort` stops the running stage at once (the run is resumable). See [Governance mode](#governance-mode) |
|
|
960
|
+
| `/gov [status\|on\|plan\|off\|board\|runs\|report [id]\|resume [id]\|pause [cancel]\|abort\|budget <n\|off>\|rounds <n\|auto>\|help]` | **Governance mode**: a governed engineering team (dev / review / test / inspector) with a GT scoring economy. `on` = GOVERN, `plan` = PLAN+GOVERN (interview first), `board` opens the full-screen overview, `runs` lists past runs with phase / health / tokens / cost, `report` re-reads a run's report, `pause` stops at the end of the running stage (nothing is killed), `abort` stops the running stage at once (the run is resumable). See [Governance mode](#governance-mode) |
|
|
961
961
|
| `/redteam [status\|on\|off\|scope <one line>\|prompt [...]]` | **Red team / security mode.** `/redteam status` prints five lines (effective state, scope, what the confirmation gate is doing, what this mode does NOT lift, and which prompt profile is supplying the wording) in any session, including `--no-redteam`. `on` needs the liability waiver accepted first (`Ctrl+R` opens it); a turn in flight defers the arming to its end, while `off` takes effect immediately and is never refused. `scope` declares the engagement boundary in one line (refused above 200 characters or across lines); no argument clears it. `prompt` manages the editable prompt profile: `status`, `builtin`, `<slug>`, `<path>`, `reload`, `validate [<path>]`, `init [<slug>]`. See [Red team and security mode](#red-team-and-security-mode) and [Prompt profiles](#prompt-profiles) |
|
|
962
962
|
| `/team [on [n]\|off\|status]` / `/team [-n <n>] [--parts a,b,c] [--read-only] <brief>` | **Force team mode and start now.** `/team <brief>` arms forced team mode and submits that work as a normal turn: the lead analyses and plans it, then calls `task` — the directive, the `<forced_team_mode>` prompt block and a mechanical end-of-turn gate all say so. `/team on [n]` arms (optionally with a count) without submitting, `/team off` leaves - both take effect when the turn ends if one is running - and `/team` reports. The configuration it used to carry (team switch, width, concurrency, supervisor, subagent model) lives in `Settings > Team` |
|
|
963
963
|
| `/todo [on\|off\|panel on\|off\|follow <mode>\|acceptance on\|off\|reset\|clear\|continue]` | Todo planning: status, the on/off switch, the rail, follow-through, acceptance criteria, and picking an unfinished plan back up |
|
|
964
|
-
| `/retry [show\|on\|off\|max <n>]` | API retry: the effective ladder, the on/off switch, the retry count. Takes effect **in the running session**, children included |
|
|
964
|
+
| `/retry [show\|on\|off\|max <n>\|reconnect <mode>\|slow <secs>\|hold <minutes>]` | API retry: the effective ladder (all three tiers, read from the live config), the on/off switch, the fast-tier retry count, the ladder's shape, the slow tier's interval and the optional whole-ladder cap. Takes effect **in the running session**, children included |
|
|
965
965
|
| `/fast [on\|off\|model <id>\|provider <id>\|same\|review <n\|off>]` | Fast model tier: status and this session's totals, the on/off switch, which model, the review cadence |
|
|
966
966
|
| `/compact [status\|on\|off\|threshold <n>\|keep <n>\|history\|show <n>\|<instructions>]` | Context compaction: occupancy and this session's totals, the on/off switch, when it fires, how much it keeps. With free text, compacts now and tells the summarizer what to pay attention to |
|
|
967
967
|
| `/context` | What the context gauge is showing: occupancy split into measured and estimated, the window and **where it came from**, how stale the measurement is, compaction's actual state, and what the session-spend readout includes |
|
|
@@ -1009,7 +1009,7 @@ completes, `Up` / `Down` moves the selection, `Esc` closes it.
|
|
|
1009
1009
|
| `Ctrl+R` | **Red team / security mode on / off.** Arms only after the liability waiver is accepted (first press opens it); while armed the status bar shows `RT armed`, the composer border is drawn in the red team colour and the system prompt carries a `<redteam_mode>` block. Session state, never saved; the scope is never saved either. `Ctrl+R` no longer repaints - see the row below, and [Red team and security mode](#red-team-and-security-mode) |
|
|
1010
1010
|
| `Alt+R` | Redraw the frame. This was `Ctrl+R` until red team mode took that key; the recovery key keeps working in every configuration, including `--no-redteam` |
|
|
1011
1011
|
| `Ctrl+T` | **Team mode on / off.** While on, every message fans out to subagents (the forced mode `/team` arms); the status bar shows the switch. Session state, never saved. See [The team mode switch](#the-team-mode-switch) |
|
|
1012
|
-
| `Ctrl+Up` / `Ctrl+Down` | **Team size**: one more / one fewer subagent per message, between 1 and `team.maxSubagents` (no wrap). Only while team mode is on. Inside the prompt library overlay these keys reorder prompts instead |
|
|
1012
|
+
| `Ctrl+Up` / `Ctrl+Down` | **Team size**: one more / one fewer subagent per message, between 1 and `team.maxSubagents` (no wrap). Only while team mode is on. In a governance posture with **no run in flight** the same keys step the **round budget** instead (`governance.arrowRounds`). Inside the prompt library overlay these keys reorder prompts instead |
|
|
1013
1013
|
| `Alt+T` | Show / hide thinking (**off by default**) for the entire session. This was `Ctrl+T`. On macOS Terminal.app turn on *Use Option as Meta key* or `Option+T` types `†` |
|
|
1014
1014
|
| `Ctrl+O` | Expand / collapse the most recent tool, team, compaction or **service** card — including a diff or a service's log tail. In native scroll mode printed rows cannot change, so it **prints an expanded copy** below instead. When no card is asking for the key it re-prints the **last finished answer** in full — the same escape hatch for a reply taller than the region |
|
|
1015
1015
|
| Terminal scrolling (native mode, the default) | The wheel, the scrollbar, `Shift+PgUp` / `Shift+PgDn`, text selection and in-terminal search are all your terminal's own — see [Scrolling](#scrolling) |
|
|
@@ -1768,6 +1768,27 @@ pauses at once. `/gov pause cancel` withdraws a request that has not fired, and
|
|
|
1768
1768
|
continues a paused run. Unlike `Esc`, it never throws away work in progress. A run that is waiting
|
|
1769
1769
|
on your ruling is left as it is.
|
|
1770
1770
|
|
|
1771
|
+
**How many rounds may a run take?** A *round* is one **failure-driven repeat dispatch**: a `fix`
|
|
1772
|
+
stage, or a `dev` stage that includes a work package in `rework` (or blocked at dev). A clean pass
|
|
1773
|
+
through dev -> review -> test -> settle -> integrate costs none, so a normal six-phase run does not
|
|
1774
|
+
eat the budget it is given. The budget has two forms: a **number** you set (`/gov rounds 6`), which
|
|
1775
|
+
only you may raise mid-run, and **auto**, where the engine derives it from the plan (one round per
|
|
1776
|
+
phase plus one per two work packages, floored at 2 and capped at 24) and the orchestrator may ask for
|
|
1777
|
+
one more round with a written reason, twice per run. When it is spent the engine stops retrying and
|
|
1778
|
+
escalates: the card offers `retry` (grant one more round - this works on a fixed budget too, because
|
|
1779
|
+
the number is yours), `accept_as_is` / `accept_failing`, or `drop`. Two consequences worth knowing:
|
|
1780
|
+
every round grant is written to `events.jsonl` with its reason, and **a pause costs a round** - an
|
|
1781
|
+
`Esc` followed by `/gov resume` re-dispatches the interrupted rework, which is a dispatch like any
|
|
1782
|
+
other (D-11). Raise or lower the budget with `/gov rounds <n|auto>`, **Settings > Governance > Round
|
|
1783
|
+
budget**, or `aragon config set governance.rounds auto|6` (`config get` prints `auto` for the `null`
|
|
1784
|
+
the file stores: two presentations of one value).
|
|
1785
|
+
|
|
1786
|
+
**The arrow keys.** In a governance posture, with **no run in flight**, `Ctrl+Up / Ctrl+Down` steps
|
|
1787
|
+
the round budget (`governance.arrowRounds`, on by default); everywhere else - BUILD, PLAN, and any
|
|
1788
|
+
live run - the same keys still set the team size, because a budget you cannot use yet is not worth
|
|
1789
|
+
the key while agents need sizing. `/gov rounds` reads it, `/keys rounds` finds both meanings, and
|
|
1790
|
+
`governance.arrowRounds: false` hands the keys back to team size permanently.
|
|
1791
|
+
|
|
1771
1792
|
**Cost before you start.** The charter, `/gov status` and the `gov_run start` result carry a
|
|
1772
1793
|
dispatch plan: how many `gov_dispatch` calls a clean run needs (stages wider than
|
|
1773
1794
|
`team.maxSubagents` are split, which adds calls), how many one more rework round or fix cycle adds,
|
|
@@ -1782,7 +1803,8 @@ transcript, up to 120 lines and the path of the full file. Nothing is regenerate
|
|
|
1782
1803
|
Limits and switches (`aragon config set governance.<key> <value>`, or **Settings > Governance**): `enabled`, `shiftTab`,
|
|
1783
1804
|
`panel`, `profile` (`general` / `ml` / `product` / `api-security`), `maxWorkPackages` (<= 8),
|
|
1784
1805
|
`maxPhases` (<= 6), `maxRework` (<= 5), `maxFixCycles` (<= 5), `minAskRounds` (0-5),
|
|
1785
|
-
`
|
|
1806
|
+
`rounds` (0-24, `auto` = the engine decides), `arrowRounds`, `budgetTokens` (team tokens only;
|
|
1807
|
+
0 = unlimited), `confirmCharter`. `ARAGON_GOVERNANCE=0` and
|
|
1786
1808
|
`--no-governance` disable it; `--govern` / `--plan-govern` start in a governed posture. It is not
|
|
1787
1809
|
available in `aragon exec` / `-p`. Governed agents are team agents: each one spends tokens, so a
|
|
1788
1810
|
run costs several times a single-agent turn - watch the status-bar chip and set `budgetTokens`.
|
|
@@ -3881,6 +3903,12 @@ env / `.env` → CLI flags**.
|
|
|
3881
3903
|
| `retry.resumeRun` | `true` | Re-run a run the **engine** interrupted - the idle watchdog fired (`[Agent] idle watchdog fired`) or the retry ladder gave up on a transport failure - instead of leaving it dead. Host-side: it redoes a **run** (`controller.continue()`, no message added) where the ladder above retries a **request**, so it never reaches the engine's `RetryPolicy`. Needs no todo plan and ignores `todo.followThrough`. Waits 15 s, then 45 s, then 120 s (cancel with `Esc`), announces the stall and its stage, and is switched off by `retry.enabled: false` / `retry.maxRetries: 0` as well. A rate limit, a rejected key, a context overflow, a run you stopped with `Esc` and a stall that began while a tool was running (unpaired tool calls in the history) are never recovered. `aragon -p` / `aragon exec` get one recovery, 15 s grace. |
|
|
3882
3904
|
| `retry.maxRunResumes` | `3` | Back-to-back recoveries before control goes back to you, clamped to `[0, 10]`. Cleared by any run that ends without an error. `0` disables recovery and is a real value here, not a typo for the default. |
|
|
3883
3905
|
| `retry.maxRunResumesPerPrompt` | `10` | Recoveries per prompt, clamped to `[0, 50]`, however well the runs in between went. Cleared **only** by you typing, so a link that dies every other turn still reaches it. `0` disables recovery. |
|
|
3906
|
+
| `retry.reconnect` | `"auto"` | The shape of the reconnect ladder. `auto` = the full three tiers in the app and two tiers under `aragon -p` / `aragon exec`; `full` and `bounded` pin it either way; `off` keeps the fast tier and refuses to escalate. `/retry reconnect <mode>` changes it for the running session. |
|
|
3907
|
+
| `retry.slowIntervalMs` | `60000` | Tier 2's interval, clamped to `[15000, 900000]`. Flat — no multiplier, no jitter — so the countdown on the card is exactly the wait that happens. |
|
|
3908
|
+
| `retry.slowAttempts` | `10` | Tier 2's attempts, clamped to `[0, 30]`. The first attempt of a tier waits too, so `10` means ten waits. `0` is a real value here: it means **do not escalate at all**. |
|
|
3909
|
+
| `retry.holdIntervalMs` | `300000` | Tier 3's interval, clamped to `[60000, 900000]`. Below a minute it would just be tier 2 again, so that is the floor. |
|
|
3910
|
+
| `retry.holdMaxMinutes` | `0` | Cap on the **whole ladder's** wall clock, in minutes, clamped to `[0, 1440]`, counted from the request's first failure — so it **includes** the ~14 minutes the first two tiers can spend. `0` (the default) means no cap: keep trying every five minutes until it reconnects. `/retry hold <minutes>` sets it; `/retry hold 0` clears it. |
|
|
3911
|
+
| `retry.stickyRung` | `false` | Start a request that just recovered in a slow tier at that tier instead of at the fast one, for a two-minute window. Off by default: it changes the rhythm you see, so it ships disabled. |
|
|
3884
3912
|
| `skills.enabled` | `true` | Master switch for the skill system. |
|
|
3885
3913
|
| `skills.requireApproval` | `true` | Require a human to approve `skill_install` / `skill_create`. |
|
|
3886
3914
|
| `skills.catalogMaxBytes` | `6000` | Level 1 catalog ceiling, in UTF-8 **bytes**, clamped to `[500, 40000]`. |
|
|
@@ -3900,6 +3928,53 @@ env / `.env` → CLI flags**.
|
|
|
3900
3928
|
| `log.redactSecrets` | `true` | Run every record through redaction. Setting it to `false` is the one way to get credentials onto disk, so it prints a warning and has no settings-screen entry. |
|
|
3901
3929
|
| `log.previewChars` | `512` | How much user content `debug` keeps per field, clamped to `[0, 8192]`. `trace` is never truncated. |
|
|
3902
3930
|
|
|
3931
|
+
#### The reconnect ladder
|
|
3932
|
+
|
|
3933
|
+
A dropped connection used to mean ten fast retries and then a dead run. The retries
|
|
3934
|
+
are now **tiered**, and each tier answers a different kind of outage:
|
|
3935
|
+
|
|
3936
|
+
| Tier | Pace | Ends after | Answers |
|
|
3937
|
+
|---|---|---|---|
|
|
3938
|
+
| 1 (fast) | 1 s doubling to 30 s, with jitter | 10 tries or a 240 s budget | a blip: a WiFi hand-off, a 529, a proxy restart |
|
|
3939
|
+
| 2 (slow) | one try every `retry.slowIntervalMs` (1 min) | `retry.slowAttempts` tries (10) | a short outage: a base-station swap, an office proxy reboot |
|
|
3940
|
+
| 3 (hold) | one try every `retry.holdIntervalMs` (5 min) | never — until it reconnects, you press `Esc`, you send a message, or the optional `retry.holdMaxMinutes` cap is reached | a long outage that outlasts a laptop lid |
|
|
3941
|
+
|
|
3942
|
+
The hand-over happens **inside one request**: nothing is replayed and nothing is
|
|
3943
|
+
re-planned, so the conversation, the tool results, the todo list and the context all
|
|
3944
|
+
stay exactly where they were. The worst case before the slow tier starts is about
|
|
3945
|
+
14 minutes (≈181 s + 660 s); after that it is one attempt every five minutes,
|
|
3946
|
+
forever.
|
|
3947
|
+
|
|
3948
|
+
Three consequences worth knowing before you rely on it:
|
|
3949
|
+
|
|
3950
|
+
- **It is not free.** Every attempt re-sends the request and is billed again. Long
|
|
3951
|
+
outages are charged close to full price — do not count on prompt caching, whose
|
|
3952
|
+
TTL is five minutes and therefore sits on the boundary of tier 3's interval. Set
|
|
3953
|
+
`retry.holdMaxMinutes` if you want a hard ceiling; `0` (the default) means "keep
|
|
3954
|
+
trying until it works".
|
|
3955
|
+
- **`Esc` and a new message both stop a wait.** A run stuck in tier 2 or 3 can end
|
|
3956
|
+
the wait two ways: `Esc` aborts the run, and typing a message stops the wait and
|
|
3957
|
+
sends that message immediately (it is not queued — a queue would deliver it only
|
|
3958
|
+
after the wait, which could be five minutes).
|
|
3959
|
+
- **Pipelines get two tiers.** `aragon -p` and `aragon exec` default to `bounded`
|
|
3960
|
+
because nobody is there to press `Esc`, and a CI job that waits forever on a
|
|
3961
|
+
regional outage is a worse failure than a clear error. Subagents never escalate at
|
|
3962
|
+
all: they share the lead's provider registry but their requests never carry a
|
|
3963
|
+
ladder, so a stuck child cannot hold a whole fan-out open.
|
|
3964
|
+
|
|
3965
|
+
Two more details, both off by default or invisible until you need them:
|
|
3966
|
+
|
|
3967
|
+
- **`retry.stickyRung`** remembers the tier a request recovered in and starts the
|
|
3968
|
+
next request there for two minutes (`retry.stickyRung: true`). Without it, a link
|
|
3969
|
+
that stays down for twenty minutes costs four minutes of already-known-useless
|
|
3970
|
+
fast retries on *every* turn. It is off by default because it changes the rhythm
|
|
3971
|
+
you see, and a recovery on the fast ladder clears it immediately.
|
|
3972
|
+
- **The card and the status line say which tier you are in** — `slow retry 2/10`,
|
|
3973
|
+
then `attempt 4` with no denominator once waiting has no end — and `/retry show`
|
|
3974
|
+
prints the whole ladder from your live config, so it can never describe a
|
|
3975
|
+
configuration you do not have.
|
|
3976
|
+
|
|
3977
|
+
|
|
3903
3978
|
Byte, not character: `ToolExecutor` truncates at 100 000 **bytes**, so a
|
|
3904
3979
|
character-based budget would be roughly triple its nominal size for CJK text
|
|
3905
3980
|
and would get cut mid-tag.
|
|
@@ -56,6 +56,7 @@ import type { CompactionEventListener, CompactionSnapshot, ContextUsageSnapshot
|
|
|
56
56
|
import type { AcceptanceItem, TodoEventListener, TodoSnapshot } from '@aragon-agent/tui/model/todo/types';
|
|
57
57
|
import { GovernanceWiring } from './governance-wiring.js';
|
|
58
58
|
import { type GovernanceConfig } from '@aragon-agent/tui/model/config/governance-config';
|
|
59
|
+
import type { RoundBudget, RunStatus } from '@aragon-agent/tui/model/governance/types';
|
|
59
60
|
import { type Posture } from '@aragon-agent/tui/model/governance/posture';
|
|
60
61
|
import type { GovernanceAvailability } from '../governance/copy.js';
|
|
61
62
|
import type { PauseOutcome } from '../governance/engine/pause.js';
|
|
@@ -126,6 +127,19 @@ export interface ControllerDeps {
|
|
|
126
127
|
* mid-run, and the sentence is guidance rather than a contract.
|
|
127
128
|
*/
|
|
128
129
|
todoPanelCapable?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Which host is running, for the ONE decision that genuinely depends on it: how
|
|
132
|
+
* many retry tiers a request gets (tiered-reconnect §4.4 / D-6).
|
|
133
|
+
*
|
|
134
|
+
* `'interactive'` (the default) = the full ladder, because a human can press Esc
|
|
135
|
+
* or type. `'headless'` = two tiers, because nobody is there — a CI job that
|
|
136
|
+
* waits forever on a regional outage is a worse failure than a clear error.
|
|
137
|
+
*
|
|
138
|
+
* NOT a second config system: the six `retry.*` keys still decide the shape; this
|
|
139
|
+
* only answers the `'auto'` case. `-p` and `exec` pass `'headless'`; everything
|
|
140
|
+
* else keeps the default, so every existing caller is byte-identical.
|
|
141
|
+
*/
|
|
142
|
+
reconnectMode?: 'interactive' | 'headless';
|
|
129
143
|
/**
|
|
130
144
|
* The `aragon exec` tool policy (cli-integration-surface §4.2).
|
|
131
145
|
*
|
|
@@ -469,6 +483,37 @@ export declare class AgentController {
|
|
|
469
483
|
* answer cannot change between the tool array and the prompt that describes it.
|
|
470
484
|
*/
|
|
471
485
|
private readonly toolImagesEnabled;
|
|
486
|
+
/**
|
|
487
|
+
* Which host this controller serves, for the ladder's SHAPE only
|
|
488
|
+
* (tiered-reconnect §4.4). Read once, at construction: a session does not change
|
|
489
|
+
* hosts, and a value that could change mid-run would make "two tiers" mean
|
|
490
|
+
* different things in two requests of one conversation.
|
|
491
|
+
*/
|
|
492
|
+
private readonly reconnectMode;
|
|
493
|
+
/**
|
|
494
|
+
* Which tier the last request recovered in (tiered-reconnect §4.9), so the NEXT
|
|
495
|
+
* request does not spend four minutes re-learning that the fast ladder is not
|
|
496
|
+
* working. Process-local, read only when `retry.stickyRung` is on.
|
|
497
|
+
*/
|
|
498
|
+
private readonly reconnectMemory;
|
|
499
|
+
/** The tier the CURRENT request is retrying in; 1 until an escalation happens. */
|
|
500
|
+
private retryTierThisRun;
|
|
501
|
+
/**
|
|
502
|
+
* The provider/model pair a sticky memory belongs to (tiered-reconnect §4.9).
|
|
503
|
+
* Comparing it is what makes a switch of model invalidate the memory instead of
|
|
504
|
+
* starting the new model at the old model's tier.
|
|
505
|
+
*/
|
|
506
|
+
private currentModelRef;
|
|
507
|
+
/**
|
|
508
|
+
* Follow the ladder one stream event at a time, so a RECOVERY knows which tier it
|
|
509
|
+
* happened in (tiered-reconnect §4.9).
|
|
510
|
+
*
|
|
511
|
+
* CORE SENDS NO "recovered" EVENT — a successful request simply ends in `done` —
|
|
512
|
+
* so the tier of a recovery has to be remembered from the last `retry_scheduled`
|
|
513
|
+
* of the same request. That is the same derivation the reducer uses for its
|
|
514
|
+
* card, done here because the sticky memory belongs to the process, not to a view.
|
|
515
|
+
*/
|
|
516
|
+
private observeRetryTier;
|
|
472
517
|
/**
|
|
473
518
|
* What the CURRENT prompt's `<image_input>` block was written for: the model and the support
|
|
474
519
|
* answer together (`provider/model:support`). The block names the model, so a switch between
|
|
@@ -854,6 +899,27 @@ export declare class AgentController {
|
|
|
854
899
|
/** `/gov resume`: the run id to hand to the orchestrator, or null when none exists. */
|
|
855
900
|
findResumableGovernanceRun(runId?: string): Promise<string | null>;
|
|
856
901
|
getGovernanceConfig(): GovernanceConfig;
|
|
902
|
+
/** The live round budget (`null` = auto): the ONE policy source the arbiter and UI read. */
|
|
903
|
+
getGovernanceRounds(): RoundBudget;
|
|
904
|
+
/**
|
|
905
|
+
* The live run's status, or null. Read from the same snapshot the panel uses, so this can
|
|
906
|
+
* never become a second view of "is a run in flight" (governance-round-budget 4.5b).
|
|
907
|
+
*/
|
|
908
|
+
getGovernanceRunStatus(): RunStatus | null;
|
|
909
|
+
/** The run's effective round limit; the structural maximum when nothing runs. */
|
|
910
|
+
roundsLimit(): number;
|
|
911
|
+
/**
|
|
912
|
+
* One ladder step of the round budget (governance-round-budget 4.5a).
|
|
913
|
+
*
|
|
914
|
+
* THE CONTROLLER DOES NOT WRITE TO DISK. `setGovernanceConfig` clamps, updates memory and
|
|
915
|
+
* re-renders the system prompt - exactly like `/gov budget` - and persisting is the
|
|
916
|
+
* CALLER's second call (`persistConfig`). A controller that persisted here would be a
|
|
917
|
+
* second write path around the App's `updatePersistedConfig`.
|
|
918
|
+
*/
|
|
919
|
+
stepGovernanceRounds(delta: 1 | -1): {
|
|
920
|
+
value: RoundBudget;
|
|
921
|
+
toast: string;
|
|
922
|
+
};
|
|
857
923
|
/** Adopt a governance config patch for this session and re-render (the block quotes limits). */
|
|
858
924
|
setGovernanceConfig(patch: Partial<GovernanceConfig>): GovernanceConfig;
|
|
859
925
|
/** `submit_plan` approval: PLAN+GOVERN hands over to the team, plain PLAN goes to BUILD. */
|
|
@@ -1326,6 +1392,15 @@ export declare class AgentController {
|
|
|
1326
1392
|
*/
|
|
1327
1393
|
clearTodos(): void;
|
|
1328
1394
|
getRetryConfig(): RetryConfig;
|
|
1395
|
+
/**
|
|
1396
|
+
* Which ladder shape this host gets (tiered-reconnect §4.4 / D-6).
|
|
1397
|
+
*
|
|
1398
|
+
* READ-ONLY, and it exists so the difference between a terminal and a pipeline is
|
|
1399
|
+
* OBSERVABLE: `-p` / `exec` are bounded, the TUI and the desktop are full, and the
|
|
1400
|
+
* failure this prevents (a CI job waiting forever on a regional outage) has no
|
|
1401
|
+
* other symptom. `/retry show` and the desktop's diagnostics can also report it.
|
|
1402
|
+
*/
|
|
1403
|
+
getReconnectMode(): 'interactive' | 'headless';
|
|
1329
1404
|
/**
|
|
1330
1405
|
* Adopt a new retry config for this session AND PUSH IT INTO THE REGISTRY.
|
|
1331
1406
|
*
|
package/dist/agent/controller.js
CHANGED
|
@@ -11,6 +11,8 @@ import { buildImageInputBlock } from './image-input-prompt.js';
|
|
|
11
11
|
import { isImageCapabilityRefusal } from '@aragon-agent/tui/model/agent/image-refusal';
|
|
12
12
|
import { Agent, IMAGE_TOKEN_ESTIMATE, initProviders, ModelRegistry, } from '@aragon-agent/core';
|
|
13
13
|
import { clampCompactionConfig, clampFastConfig, clampRetryConfig, clampGeneConfig, clampMemoryConfig, clampTeamConfig, clampTodoConfig, isAdapterProvider, toRetryPolicy, } from '@aragon-agent/tui/model/config/schema';
|
|
14
|
+
import { resolveEscalationPolicy } from '@aragon-agent/tui/model/config/reconnect';
|
|
15
|
+
import { ReconnectMemory } from './reconnect-memory.js';
|
|
14
16
|
import { resolveModelProfileState } from '@aragon-agent/tui/model/config/model-profile-resolution';
|
|
15
17
|
import { makeGetApiKey } from '../config/load.js';
|
|
16
18
|
import { updatePersistedConfig } from '../config/store.js';
|
|
@@ -80,6 +82,8 @@ import { buildTodoBlock } from '../todo/prompt.js';
|
|
|
80
82
|
import { createPlanTools } from '../tools/plan-tools.js';
|
|
81
83
|
import { GovernanceWiring } from './governance-wiring.js';
|
|
82
84
|
import { clampGovernanceConfig } from '@aragon-agent/tui/model/config/governance-config';
|
|
85
|
+
import { GOV_LIMITS } from '@aragon-agent/tui/model/governance/limits';
|
|
86
|
+
import { roundsStepToast, stepRoundBudget } from '@aragon-agent/tui/model/governance/rounds';
|
|
83
87
|
import { decidePostureTransition } from '../governance/posture-transition.js';
|
|
84
88
|
import { composePosture, splitPosture } from '@aragon-agent/tui/model/governance/posture';
|
|
85
89
|
import { APPROVED_GOVERN_RESULT } from '../governance/prompts/refusals.js';
|
|
@@ -446,6 +450,53 @@ export class AgentController {
|
|
|
446
450
|
* answer cannot change between the tool array and the prompt that describes it.
|
|
447
451
|
*/
|
|
448
452
|
toolImagesEnabled = process.env.ARAGON_TOOL_IMAGES !== '0';
|
|
453
|
+
/**
|
|
454
|
+
* Which host this controller serves, for the ladder's SHAPE only
|
|
455
|
+
* (tiered-reconnect §4.4). Read once, at construction: a session does not change
|
|
456
|
+
* hosts, and a value that could change mid-run would make "two tiers" mean
|
|
457
|
+
* different things in two requests of one conversation.
|
|
458
|
+
*/
|
|
459
|
+
reconnectMode;
|
|
460
|
+
/**
|
|
461
|
+
* Which tier the last request recovered in (tiered-reconnect §4.9), so the NEXT
|
|
462
|
+
* request does not spend four minutes re-learning that the fast ladder is not
|
|
463
|
+
* working. Process-local, read only when `retry.stickyRung` is on.
|
|
464
|
+
*/
|
|
465
|
+
reconnectMemory = new ReconnectMemory();
|
|
466
|
+
/** The tier the CURRENT request is retrying in; 1 until an escalation happens. */
|
|
467
|
+
retryTierThisRun = 1;
|
|
468
|
+
/**
|
|
469
|
+
* The provider/model pair a sticky memory belongs to (tiered-reconnect §4.9).
|
|
470
|
+
* Comparing it is what makes a switch of model invalidate the memory instead of
|
|
471
|
+
* starting the new model at the old model's tier.
|
|
472
|
+
*/
|
|
473
|
+
currentModelRef() {
|
|
474
|
+
return { providerId: this.config.provider, modelId: this.config.model };
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Follow the ladder one stream event at a time, so a RECOVERY knows which tier it
|
|
478
|
+
* happened in (tiered-reconnect §4.9).
|
|
479
|
+
*
|
|
480
|
+
* CORE SENDS NO "recovered" EVENT — a successful request simply ends in `done` —
|
|
481
|
+
* so the tier of a recovery has to be remembered from the last `retry_scheduled`
|
|
482
|
+
* of the same request. That is the same derivation the reducer uses for its
|
|
483
|
+
* card, done here because the sticky memory belongs to the process, not to a view.
|
|
484
|
+
*/
|
|
485
|
+
observeRetryTier(event) {
|
|
486
|
+
if (event.type === 'retry_scheduled') {
|
|
487
|
+
if (event.tier !== undefined)
|
|
488
|
+
this.retryTierThisRun = event.tier;
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
if (event.type !== 'done')
|
|
492
|
+
return;
|
|
493
|
+
// `stickyRung` off means nobody asked for a memory, so nothing is recorded: a
|
|
494
|
+
// session that never flips the switch pays nothing for this feature.
|
|
495
|
+
if (!this.config.retry.stickyRung)
|
|
496
|
+
return;
|
|
497
|
+
this.reconnectMemory.recordRecovery(this.currentModelRef(), this.retryTierThisRun);
|
|
498
|
+
this.retryTierThisRun = 1;
|
|
499
|
+
}
|
|
449
500
|
/**
|
|
450
501
|
* What the CURRENT prompt's `<image_input>` block was written for: the model and the support
|
|
451
502
|
* answer together (`provider/model:support`). The block names the model, so a switch between
|
|
@@ -561,6 +612,9 @@ export class AgentController {
|
|
|
561
612
|
this.todoRegistered = config.todo.enabled;
|
|
562
613
|
this.todoEnabled = config.todo.enabled;
|
|
563
614
|
this.todoPanelCapable = deps.todoPanelCapable === true;
|
|
615
|
+
// Default `'interactive'`: a host that never heard of this dep keeps the full
|
|
616
|
+
// ladder, which is what the TUI and the desktop both want.
|
|
617
|
+
this.reconnectMode = deps.reconnectMode === 'headless' ? 'headless' : 'interactive';
|
|
564
618
|
this.todos = this.todoRegistered
|
|
565
619
|
? new TodoStore(Date.now, () => this.isTodoAcceptanceEnabled())
|
|
566
620
|
: null;
|
|
@@ -1381,6 +1435,32 @@ export class AgentController {
|
|
|
1381
1435
|
...(this.governance.isRegistered() ? { gov_dispatch: 0 } : {}),
|
|
1382
1436
|
},
|
|
1383
1437
|
},
|
|
1438
|
+
// TIERED RECONNECT (tiered-reconnect §4.4). THE ONLY PLACE IN THE WHOLE
|
|
1439
|
+
// REPOSITORY THAT WRITES THIS FIELD (AC-12 pins it with a source scan, and
|
|
1440
|
+
// `team/subagent.ts` is asserted to have neither this nor `retryEscalation`).
|
|
1441
|
+
//
|
|
1442
|
+
// A CLOSURE, NOT A VALUE, and that is the difference from `setRetryPolicy`
|
|
1443
|
+
// next door: the tier-1 policy is pushed twice because it is a VALUE the
|
|
1444
|
+
// registry stores, while this is a FUNCTION the engine calls once per run, so
|
|
1445
|
+
// `/retry reconnect off` takes effect on the next request with no restart and
|
|
1446
|
+
// no second push.
|
|
1447
|
+
//
|
|
1448
|
+
// `deps.reconnectMode === 'headless'` is what makes `-p` / `exec` bounded by
|
|
1449
|
+
// default: two tiers, because nobody is there to press Esc.
|
|
1450
|
+
resolveEscalation: () => {
|
|
1451
|
+
const policy = resolveEscalationPolicy(this.config.retry, {
|
|
1452
|
+
headless: this.reconnectMode === 'headless',
|
|
1453
|
+
});
|
|
1454
|
+
if (policy === null)
|
|
1455
|
+
return null;
|
|
1456
|
+
// STICKY START TIER (§4.9). Off by default, and its absence is what makes a
|
|
1457
|
+
// session that never turns it on byte-identical to one without the feature:
|
|
1458
|
+
// `startRung === undefined` means "begin at tier 1", which is the default.
|
|
1459
|
+
const startRung = this.config.retry.stickyRung
|
|
1460
|
+
? this.reconnectMemory.startRungFor(this.currentModelRef())
|
|
1461
|
+
: undefined;
|
|
1462
|
+
return startRung === undefined ? { policy } : { policy, startRung };
|
|
1463
|
+
},
|
|
1384
1464
|
});
|
|
1385
1465
|
// --- Context compaction, part 2: AFTER the Agent exists -----------------
|
|
1386
1466
|
//
|
|
@@ -1434,8 +1514,12 @@ export class AgentController {
|
|
|
1434
1514
|
// The Gene Bank's feed (learner ledger, usage, evaluation). Never throws.
|
|
1435
1515
|
// `abortRequested` is still in force here: it is cleared at the NEXT `agent_start`.
|
|
1436
1516
|
this.gene?.onAgentEvent(event, this.abortRequested);
|
|
1437
|
-
if (event.type === 'agent_start')
|
|
1517
|
+
if (event.type === 'agent_start') {
|
|
1438
1518
|
this.abortRequested = false;
|
|
1519
|
+
this.retryTierThisRun = 1;
|
|
1520
|
+
}
|
|
1521
|
+
if (event.type === 'message_update')
|
|
1522
|
+
this.observeRetryTier(event.streamEvent);
|
|
1439
1523
|
if (event.type === 'message_update' && event.streamEvent.type === 'error') {
|
|
1440
1524
|
this.learnImageRefusal(event.streamEvent.error);
|
|
1441
1525
|
}
|
|
@@ -2444,6 +2528,38 @@ export class AgentController {
|
|
|
2444
2528
|
getGovernanceConfig() {
|
|
2445
2529
|
return clampGovernanceConfig(this.config.governance);
|
|
2446
2530
|
}
|
|
2531
|
+
/** The live round budget (`null` = auto): the ONE policy source the arbiter and UI read. */
|
|
2532
|
+
getGovernanceRounds() {
|
|
2533
|
+
return this.getGovernanceConfig().rounds;
|
|
2534
|
+
}
|
|
2535
|
+
/**
|
|
2536
|
+
* The live run's status, or null. Read from the same snapshot the panel uses, so this can
|
|
2537
|
+
* never become a second view of "is a run in flight" (governance-round-budget 4.5b).
|
|
2538
|
+
*/
|
|
2539
|
+
getGovernanceRunStatus() {
|
|
2540
|
+
return this.getGovernanceSnapshot()?.status ?? null;
|
|
2541
|
+
}
|
|
2542
|
+
/** The run's effective round limit; the structural maximum when nothing runs. */
|
|
2543
|
+
roundsLimit() {
|
|
2544
|
+
return this.getGovernanceSnapshot()?.rounds.limit ?? GOV_LIMITS.hardMaxRounds;
|
|
2545
|
+
}
|
|
2546
|
+
/**
|
|
2547
|
+
* One ladder step of the round budget (governance-round-budget 4.5a).
|
|
2548
|
+
*
|
|
2549
|
+
* THE CONTROLLER DOES NOT WRITE TO DISK. `setGovernanceConfig` clamps, updates memory and
|
|
2550
|
+
* re-renders the system prompt - exactly like `/gov budget` - and persisting is the
|
|
2551
|
+
* CALLER's second call (`persistConfig`). A controller that persisted here would be a
|
|
2552
|
+
* second write path around the App's `updatePersistedConfig`.
|
|
2553
|
+
*/
|
|
2554
|
+
stepGovernanceRounds(delta) {
|
|
2555
|
+
const step = stepRoundBudget(this.getGovernanceRounds(), delta);
|
|
2556
|
+
const adopted = this.setGovernanceConfig({ rounds: step.value });
|
|
2557
|
+
const live = this.getGovernanceSnapshot()?.rounds ?? null;
|
|
2558
|
+
return {
|
|
2559
|
+
value: adopted.rounds,
|
|
2560
|
+
toast: roundsStepToast(adopted.rounds, live ?? undefined, live === null ? undefined : live.limit, step.at),
|
|
2561
|
+
};
|
|
2562
|
+
}
|
|
2447
2563
|
/** Adopt a governance config patch for this session and re-render (the block quotes limits). */
|
|
2448
2564
|
setGovernanceConfig(patch) {
|
|
2449
2565
|
const governance = clampGovernanceConfig({ ...this.getGovernanceConfig(), ...patch });
|
|
@@ -3472,6 +3588,17 @@ export class AgentController {
|
|
|
3472
3588
|
getRetryConfig() {
|
|
3473
3589
|
return this.config.retry;
|
|
3474
3590
|
}
|
|
3591
|
+
/**
|
|
3592
|
+
* Which ladder shape this host gets (tiered-reconnect §4.4 / D-6).
|
|
3593
|
+
*
|
|
3594
|
+
* READ-ONLY, and it exists so the difference between a terminal and a pipeline is
|
|
3595
|
+
* OBSERVABLE: `-p` / `exec` are bounded, the TUI and the desktop are full, and the
|
|
3596
|
+
* failure this prevents (a CI job waiting forever on a regional outage) has no
|
|
3597
|
+
* other symptom. `/retry show` and the desktop's diagnostics can also report it.
|
|
3598
|
+
*/
|
|
3599
|
+
getReconnectMode() {
|
|
3600
|
+
return this.reconnectMode;
|
|
3601
|
+
}
|
|
3475
3602
|
/**
|
|
3476
3603
|
* Adopt a new retry config for this session AND PUSH IT INTO THE REGISTRY.
|
|
3477
3604
|
*
|
|
@@ -195,6 +195,7 @@ export class GovernanceWiring {
|
|
|
195
195
|
maxRework: gov.maxRework,
|
|
196
196
|
maxFixCycles: gov.maxFixCycles,
|
|
197
197
|
budgetTokens: gov.budgetTokens,
|
|
198
|
+
rounds: gov.rounds,
|
|
198
199
|
},
|
|
199
200
|
});
|
|
200
201
|
}
|
|
@@ -456,6 +457,7 @@ export class GovernanceWiring {
|
|
|
456
457
|
close: (summary) => e().close(summary),
|
|
457
458
|
abandon: (reason) => e().abandon(reason),
|
|
458
459
|
resolve: (input) => e().resolve(input),
|
|
460
|
+
rounds: (input) => e().rounds(input),
|
|
459
461
|
snapshot: () => this.snapshot(),
|
|
460
462
|
isStageRunning: () => this.isStageRunning(),
|
|
461
463
|
abortStage: () => this.abortStage(),
|
package/dist/agent/headless.js
CHANGED
|
@@ -16,6 +16,20 @@ import { advanceBudget, chargeResume, decideFollowThrough, emptyBudget, emptyRes
|
|
|
16
16
|
function pauseMs(ms) {
|
|
17
17
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The wait, as a piped consumer reads it: `8s`, `1m00s`, `5m00s`.
|
|
21
|
+
*
|
|
22
|
+
* Minutes matter now that a wait can be five of them (tiered-reconnect §4.6.7):
|
|
23
|
+
* `waiting 300s` is technically true and useless, and the CLI's other duration
|
|
24
|
+
* formatter is a `Glyphs`-aware UI module this file deliberately does not import.
|
|
25
|
+
*/
|
|
26
|
+
function formatWait(ms) {
|
|
27
|
+
const seconds = Math.max(0, Math.round(ms / 1000));
|
|
28
|
+
if (seconds < 60)
|
|
29
|
+
return `${seconds}s`;
|
|
30
|
+
const minutes = Math.floor(seconds / 60);
|
|
31
|
+
return `${minutes}m${String(seconds % 60).padStart(2, '0')}s`;
|
|
32
|
+
}
|
|
19
33
|
/** Run a single prompt headlessly and resolve with the process exit code. */
|
|
20
34
|
export async function runHeadless(controller, prompt, options = {}) {
|
|
21
35
|
const out = options.stdout ?? process.stdout;
|
|
@@ -59,12 +73,19 @@ export async function runHeadless(controller, prompt, options = {}) {
|
|
|
59
73
|
// `aragon -p | jq`; a retry line on it would corrupt every consumer.
|
|
60
74
|
// Not `--quiet`-gated, unlike the tool lines: a three-minute pause with
|
|
61
75
|
// no explanation anywhere is not a "compact" run, it is a hang.
|
|
62
|
-
|
|
76
|
+
//
|
|
77
|
+
// THE CUMULATIVE COUNT (tiered-reconnect §4.6.7 / P2-7), not `attempt`:
|
|
78
|
+
// `attempt` restarts at 1 in every tier, so a recovery in tier 2 would
|
|
79
|
+
// otherwise be reported as "2 retries" after eleven minutes of waiting.
|
|
80
|
+
retryCount = se.totalAttempts ?? se.attempt;
|
|
81
|
+
// The tier rides the same line, because `[retry 2/10]` alone cannot say
|
|
82
|
+
// WHICH 2/10 - the fast tier's or the one-minute tier's.
|
|
83
|
+
const tierTag = se.tier !== undefined && se.tier > 1 ? ` tier ${se.tier}` : '';
|
|
63
84
|
// The em dash is a literal because `agent/headless.ts` is the CLI's one
|
|
64
85
|
// documented glyph-scanner exemption: `aragon -p` does no capability
|
|
65
86
|
// probe, so there is no `Glyphs` set to read here.
|
|
66
|
-
err.write(`\n[retry ${se.attempt}/${se.maxRetries}] ${se.errorType} — ` +
|
|
67
|
-
`waiting ${
|
|
87
|
+
err.write(`\n[retry ${se.attempt}/${se.maxRetries}${tierTag}] ${se.errorType} — ` +
|
|
88
|
+
`waiting ${formatWait(se.delayMs)}\n`);
|
|
68
89
|
}
|
|
69
90
|
else if (se.type === 'stream_restart') {
|
|
70
91
|
// The partial answer already on stdout is about to be replayed. Saying so
|