@aragon-agent/cli 0.6.63 → 0.6.66

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +131 -2
  2. package/README.md +98 -21
  3. package/dist/agent/controller.d.ts +119 -14
  4. package/dist/agent/controller.js +385 -82
  5. package/dist/agent/headless.d.ts +16 -0
  6. package/dist/agent/headless.js +68 -6
  7. package/dist/agent/reconnect-memory.d.ts +68 -0
  8. package/dist/agent/reconnect-memory.js +82 -0
  9. package/dist/agent/team-notices.d.ts +57 -7
  10. package/dist/agent/team-notices.js +93 -10
  11. package/dist/app/App.js +284 -78
  12. package/dist/cli.js +4 -1
  13. package/dist/commands/builtins.js +8 -72
  14. package/dist/commands/catalog.js +1 -1
  15. package/dist/commands/retry-command.d.ts +52 -0
  16. package/dist/commands/retry-command.js +225 -0
  17. package/dist/config/cli-commands.d.ts +1 -1
  18. package/dist/config/cli-commands.js +39 -0
  19. package/dist/exec/events.d.ts +12 -0
  20. package/dist/exec/index.js +2 -0
  21. package/dist/exec/runner.js +16 -1
  22. package/dist/gene/cli-commands.js +30 -1
  23. package/dist/gene/command-report.js +5 -1
  24. package/dist/gene/commit-prepare.js +27 -1
  25. package/dist/gene/curator/budget.d.ts +24 -1
  26. package/dist/gene/curator/budget.js +67 -14
  27. package/dist/gene/curator/curator.d.ts +25 -0
  28. package/dist/gene/curator/curator.js +61 -7
  29. package/dist/gene/curator/scripted-lane.d.ts +12 -0
  30. package/dist/gene/curator/scripted-lane.js +101 -0
  31. package/dist/gene/curator/task-context.d.ts +29 -0
  32. package/dist/gene/curator/task-context.js +43 -0
  33. package/dist/gene/curator/task-runner.d.ts +10 -1
  34. package/dist/gene/curator/task-runner.js +52 -6
  35. package/dist/gene/curator/tool-support.js +11 -4
  36. package/dist/gene/curator/toolkit.d.ts +13 -0
  37. package/dist/gene/curator/toolkit.js +23 -1
  38. package/dist/gene/curator/tools-verify.js +2 -2
  39. package/dist/gene/curator/tools-write.js +6 -1
  40. package/dist/gene/curator/validate/evidence-tokens.js +133 -22
  41. package/dist/gene/curator/validate/knowledge.d.ts +41 -1
  42. package/dist/gene/curator/validate/knowledge.js +74 -11
  43. package/dist/gene/curator/validate/prompts.d.ts +10 -2
  44. package/dist/gene/curator/validate/prompts.js +2 -2
  45. package/dist/gene/hub.js +5 -0
  46. package/dist/gene/import-plan.js +8 -5
  47. package/dist/gene/learn/draft-guard.d.ts +17 -0
  48. package/dist/gene/learn/draft-guard.js +113 -0
  49. package/dist/gene/learn/learn-prompt.d.ts +22 -1
  50. package/dist/gene/learn/learn-prompt.js +27 -2
  51. package/dist/gene/learn/learner.js +27 -5
  52. package/dist/gene/queue.d.ts +24 -0
  53. package/dist/gene/queue.js +80 -1
  54. package/dist/governance/store/run-store.d.ts +20 -0
  55. package/dist/governance/store/run-store.js +54 -8
  56. package/dist/host/controller-factory.js +6 -0
  57. package/dist/host/index.d.ts +1 -0
  58. package/dist/host/index.js +1 -0
  59. package/dist/host/interaction.d.ts +8 -17
  60. package/dist/host/interaction.js +50 -72
  61. package/dist/host/team-wake-driver.d.ts +90 -0
  62. package/dist/host/team-wake-driver.js +114 -0
  63. package/dist/logging/install.d.ts +35 -1
  64. package/dist/logging/install.js +23 -0
  65. package/dist/session/persist.js +8 -1
  66. package/dist/session/validate-session.js +15 -5
  67. package/dist/team/console-tools.d.ts +12 -0
  68. package/dist/team/console-tools.js +20 -3
  69. package/dist/team/console-view.js +11 -1
  70. package/dist/team/notices.d.ts +81 -4
  71. package/dist/team/notices.js +187 -22
  72. package/dist/team/prompt.js +1 -1
  73. package/dist/team/runtime.d.ts +67 -24
  74. package/dist/team/runtime.js +250 -31
  75. package/dist/team/stall-watch.d.ts +54 -0
  76. package/dist/team/stall-watch.js +119 -0
  77. package/dist/team/task-tool.js +2 -2
  78. package/dist/team/wake.d.ts +176 -0
  79. package/dist/team/wake.js +444 -0
  80. package/package.json +81 -81
package/CHANGELOG.md CHANGED
@@ -12,9 +12,9 @@ were written.
12
12
  - **`task` no longer returns the final report in an interactive session.** It returns "started" — the
13
13
  dispatch id, the labels it created and a one-line cheat sheet of the control tools — and the dispatch
14
14
  then belongs to the runtime, not to a tool call. The report arrives once, at the end, as a transcript
15
- notice plus **at most one** summary turn in which the lead restates it in its own words
15
+ notice and - while the lead is idle - a **wake** that starts a turn for it
16
16
  (`team.autoResume`, default `auto`; `team.settleGraceMs`, default 3000 ms, is the window in which your
17
- next message cancels that turn). `aragon -p`, `aragon exec` and governance mode keep the blocking
17
+ next message cancels that turn; see the lead wake signals below). `aragon -p`, `aragon exec` and governance mode keep the blocking
18
18
  behaviour and the byte-identical report, so scripts, hosts and `schemaVersion` are untouched.
19
19
  **Migration:** read the notice, call `team_collect` when you need the report synchronously, or set
20
20
  `team.detachDispatch: false` (`aragon config set team.detachDispatch false`) to restore the old
@@ -27,9 +27,138 @@ 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.
44
+
45
+ ### Fixed
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.
59
+ - **A team run that hit `[Agent] idle watchdog fired` no longer stays dead.** When the model went quiet for
60
+ the whole idle window (210 s by default), or the retry ladder gave up on a transport failure, the run was
61
+ over and nothing started another one: the screen said `N steps left; the run ended with an error.
62
+ /todo continue to retry...`, and the only recovery was you typing something - 12 seconds later, or 89
63
+ minutes later on an unattended run. The host now **re-runs the interrupted run itself**
64
+ (`controller.continue()`: the history is asked again, no message is added) after a grace window you can
65
+ cancel with `Esc` - 15 s, then 45 s, then 120 s - and says why: `The model stopped responding for 3m 30s
66
+ while writing a tool call (task). The last response was discarded; retrying automatically in 15s
67
+ (attempt 1/3) - Esc to cancel.` It needs no todo plan (a lead that dies while composing its first
68
+ dispatch has none) and is independent of `todo.followThrough`.
69
+ Bounded twice: `retry.maxRunResumes` (default 3) back-to-back recoveries, and
70
+ `retry.maxRunResumesPerPrompt` (default 10) per prompt, which only **you typing** refills - so a link
71
+ that dies every other turn still stops. Only the engine's own transient verdicts are recovered
72
+ (idle watchdog, `network_error`, `timeout`, `overloaded`, `server_error`); a rate limit, a rejected key,
73
+ a context overflow and anything the provider calls non-retryable are not, neither is a run you
74
+ stopped with `Esc`, and neither is a stall that began while a **tool was running** (the history then ends
75
+ in tool calls with no results, which the provider would reject, so a retry could only fail).
76
+ A pending team-wake countdown keeps the timer slot (it redoes the same turn and delivers a real signal),
77
+ and a recovery that already holds it makes a later wake answer `busy`.
78
+ `retry.resumeRun: false` (or `/retry off`, or `retry.maxRetries: 0`) restores the old behaviour exactly.
79
+ `aragon -p` and the one-shot `aragon exec` path get **one** recovery, 15 s grace, and exit 1 when it does
80
+ not end in an answer; text already streamed to stdout before the stall is not retracted (the retry line on
81
+ stderr says so), as with the ladder's own `stream_restart`.
82
+
83
+ - **A watchdog death now says where it went quiet.** `run_end` in the log carries `stall`: the phase
84
+ (`awaiting_response`, `thinking`, `text`, `tool_input`, `tool_running`, `between_turns`), the last event,
85
+ the tool being written or run, and the silence on **both** the monotonic and the wall clock - they diverge
86
+ by the length of a suspend, which is how a sleeping laptop is told apart from a quiet network. Nothing is
87
+ added to an `agent_end` that did not die of the watchdog.
88
+
89
+ - **The Gene Bank publishes again: four days of learning produced one gene.** The reviewer was running, but
90
+ the bank stayed empty for four reasons, all fixed. (1) The source check (K2) read grammar and prose as
91
+ facts - `/dev/null`, `2>&1`, `deploy/update/roll`, whole backticked command lines, a localized message,
92
+ `YYYY` placeholders - and vetoed a gene for any one of them; it now ignores those shapes, checks a command
93
+ word by word, and vetoes only when **most** of a draft's specifics (more than half, or more than eight)
94
+ cannot be found in its evidence. A minority is recorded as `KNOWLEDGE_EVIDENCE_UNVERIFIED` and the gene
95
+ goes in **on probation**; `recheck` shares the rule. On the 15 stored candidates K2 passes 13 instead of 3.
96
+ (2) A skill or tool draft could never be created (17 of 17 skills, 1 of 1 tools): the reviewer was never
97
+ told the contract, and a refusal named one issue at a time. Refusals now list every problem, `gene_toolkit
98
+ load author` states the knowledge / skill / preference contract once, and the reviewer prompt (`v3-2026-11`)
99
+ asks for it, never proposes a tool and may propose one skill per reply. Drafts the curator cannot create
100
+ are refused at enqueue, and the ones already queued are moved to `dead/` once an hour (reversible).
101
+ (3) A task that hit its token, turn or finish ceiling was retried four times; it now gets two. (4) A
102
+ reviewer proposal with a complete knowledge draft that passes the checks needing no model is written and
103
+ validated by code and published on probation without starting an agent loop (`resume_validation`, the
104
+ path that produced the only gene so far); any doubt falls back to the agent loop before anything is
105
+ written. The run log now says how many turns, which tools and which refusals a stopped task used.
106
+ **Migration:** none. Kill switches: `ARAGON_GENE_DRAFT_GUARD=0` (enqueue guard and sweep),
107
+ `ARAGON_GENE_SCRIPTED_LANE=0` (scripted lane). A TUI session that holds the curator lease must be restarted
108
+ to load the fix.
109
+ - **In team mode the lead no longer sits idle forever after its subagents finish.** The old follow-up
110
+ turn was judged once, on the lead's own `agent_end`, and a dispatch that ends while the lead is idle
111
+ never produces one - so the report waited for you to type. The runtime now owes the lead a wake as a
112
+ *state*, re-checked whenever a signal arrives, the lead goes idle, a retry beat fires or the host answers.
113
+ Three signals, all raised from runtime facts: the dispatch **ended**, a subagent **failed for good**
114
+ (after the supervisor's post-mortem had its chance to replace it), and the team **stalled**
115
+ (`team.stallSignalMs`, default 180 s, `0` turns it off). The wake text states facts only
116
+ (`<team_signal>`); what the lead does with it is its own call. A dispatch that fails before it can
117
+ even start (a subagent that cannot be built) now reports a failed row per subagent instead of
118
+ vanishing; a failed child no longer downgrades the wake to a notice; a report that could not be
119
+ delivered into the turn it ended in is no longer lost; a report is no longer delivered twice; and the
120
+ first turn after an `Esc` receives the report too. The wake is bounded (3 attempts per notice,
121
+ 4 live-signal wakes per dispatch) and never silent: giving up prints a line. The terminal and the
122
+ desktop run the same driver. **Migration:** none; `team.autoResume` keeps its three values but now
123
+ covers failures and stalls as well as the end, and `at most one summary turn` is no longer a rule.
30
124
 
31
125
  ### Added
32
126
 
127
+ - **Tiered reconnect: a dropped connection now has three gears instead of one.** Ten fast
128
+ retries and then a dead run was the old behaviour, and it is the wrong shape for the outages
129
+ people actually have. The ladder is now fast, then steady, then a hold: **tier 1** is the fast
130
+ ladder exactly as it shipped (10 tries, 1 s doubling to 30 s, equal jitter, 240 s budget, no
131
+ number changed); **tier 2** takes over when tier 1 gives up and tries once a minute, ten
132
+ 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
133
+ optional cap you set is reached. The hand-over happens INSIDE one request, so nothing is
134
+ replayed and nothing is re-planned: the conversation, the tool results, the todo list and the
135
+ context stay exactly where they were, and the cost is one re-sent request instead of a re-run
136
+ turn.
137
+
138
+ What you see changed with it: the retry card says which tier it is in (`slow retry 2/10`,
139
+ `attempt 4` with no denominator in the last tier), a long countdown reads `4m12s` instead of
140
+ `252s`, the status line carries a live clock (`Reconnecting 2/10 in 42s`), one notice is
141
+ written when each tier starts (and says "then it gives up" rather than promising a tier that
142
+ `bounded` mode does not have), and a run that recovers across tiers settles as
143
+ `recovered after 13 retries`. Tier 3 offers `Esc to stop waiting`, because by then there is no
144
+ request to cancel — only a wait.
145
+
146
+ Six new keys and three new `/retry` verbs: `retry.reconnect` (`auto` | `full` | `bounded` |
147
+ `off`), `retry.slowIntervalMs`, `retry.slowAttempts`, `retry.holdIntervalMs`,
148
+ `retry.holdMaxMinutes` (`0` = no cap, the default) and `retry.stickyRung` (off by default:
149
+ a request that just recovered in a slow tier starts there for the next two minutes, so a
150
+ twenty-minute outage does not cost four minutes of fast retries on every turn);
151
+ `/retry reconnect <mode>`, `/retry slow <secs>`, `/retry hold <minutes>`, and a `/retry show`
152
+ that reads every number it prints from the live config. **No CLI flag was added**: the shape
153
+ of the ladder is a lasting preference, not a per-invocation one, and `--no-retry` /
154
+ `retry.reconnect: off` remain the two ways to say "one tier, as before".
155
+
156
+ Deliberate boundaries: `aragon -p` and `aragon exec` default to **two** tiers (nobody is there
157
+ to press `Esc`, and a pipeline that waits forever is a worse failure than a clear error);
158
+ subagents **never** escalate, because their requests never carry a ladder and a stuck child
159
+ must not hold a whole fan-out open; every attempt is billed, so the README, `/retry show` and
160
+ the desktop hints all say that a long outage costs close to full price.
161
+
33
162
  - **Prompt profiles: the red team block's wording now lives in an editable Markdown file.** The
34
163
  `<redteam_mode>` block was two halves in one place; now it is two halves in two homes. The **fact**
35
164
  half - the authorization line, `What this mode changes`, the closing boundary sentence - stays in
package/README.md CHANGED
@@ -961,7 +961,7 @@ ignores them rather than rejecting the library):
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 |
@@ -2632,29 +2632,50 @@ dispatch started with, so the key can never turn a live team into an awaited too
2632
2632
  call or the other way round. `-p`, `aragon exec` and governance mode always
2633
2633
  dispatch in await mode — the machine contract does not change for this feature.
2634
2634
 
2635
- ### When the report comes back: one notice, at most one summary turn
2635
+ ### When the team needs the lead: three signals, one wake
2636
+
2637
+ The runtime needs the lead in exactly three situations, and in no others: the dispatch
2638
+ **ended** (every child finished - all of them succeeded or some failed), a subagent
2639
+ **failed for good** while the others keep running, or the team **stalled** (nobody is doing
2640
+ real work and somebody is waiting on somebody else). Each becomes a notice that reaches the
2641
+ lead exactly once, and while the lead is idle the runtime also **wakes** it - so a team that
2642
+ finishes at 3 a.m. does not sit there until you type. A single success, a message from a
2643
+ child or a pause is not a signal; those ride along with the next one.
2636
2644
 
2637
2645
  | Key | Values | What it does |
2638
2646
  |---|---|---|
2639
- | `team.autoResume` | `auto` (default) / `notify` / `off` | `auto` gives the lead one bounded turn to summarise the finished dispatch; `notify` only announces it in the transcript; `off` says nothing at all |
2640
- | `team.settleGraceMs` | 500-30000 ms, default 3000 | How long that summary turn waits before it runs, so your next keystroke can cancel it |
2641
-
2642
- The rules are narrow on purpose:
2643
-
2644
- - **At most one summary turn per dispatch.** A second one is never armed.
2645
- - **Any user input cancels it.** The grace window exists for exactly that: a
2646
- message you send inside it becomes the turn, and the notice rides along with
2647
- it instead of costing a second turn.
2648
- - **It never repeats the report.** The summary turn points at the report; the
2649
- report itself is the notice, and `team_collect` returns the same string, byte
2650
- for byte, so the readers cannot drift apart.
2651
- - **It degrades to a plain notice** when the dispatch was aborted or errored,
2652
- when it settled inside the turn that started it, when you already have an
2653
- unread message, when a TODO follow-through or a forced-dispatch nudge already
2654
- owns the follow timer, or when `autoResume` is `notify`.
2655
- - **Notices are delivered exactly once** — idempotent per
2656
- `dispatch:label:status`, and re-sent from a ledger if the fast reviewer's queue
2657
- clear swallowed one.
2647
+ | `team.autoResume` | `auto` (default) / `notify` / `off` | `auto` wakes an idle lead for any of the three signals; `notify` only prints one line; `off` says nothing. With `notify` and `off` the signal still reaches the lead with your next message |
2648
+ | `team.settleGraceMs` | 500-30000 ms, default 3000 | How long a wake waits before it runs, so your next keystroke or `Esc` can cancel it |
2649
+ | `team.stallSignalMs` | `0`, or 60000-3600000 ms; default 180000 | How long nobody may do real work before the lead is told the team stalled. `0` switches only this signal off - the end-of-dispatch and failure wakes are unaffected |
2650
+
2651
+ **What the lead does once it is awake is the lead's call.** The wake carries facts and nothing
2652
+ else: a `<team_signal>` block with the counts, the labels, the first line of each error, who
2653
+ stopped whom and how long things were quiet, plus one provenance line saying it is automatic and
2654
+ not a message from you. It never tells the lead to summarise, retry, replace or stop anything -
2655
+ it can do any of those, or none.
2656
+
2657
+ The rules are there to make the signal reliable without making it a loop:
2658
+
2659
+ - **It always reaches the lead.** A dispatch that ends while the lead is idle wakes it; one that
2660
+ ends mid-turn but could not be delivered into that turn wakes it when the turn ends; a dispatch
2661
+ that dies before its children even start (a model profile that cannot be built) reports a failed
2662
+ row per subagent. A failure no longer downgrades the wake to a plain notice.
2663
+ - **It cannot loop.** A notice gets at most three attempts and then a visible "could not wake the
2664
+ lead" line; failures and stalls wake the lead at most four times per dispatch and at least a
2665
+ minute apart (the fifth is announced instead); the end of a dispatch is always allowed.
2666
+ - **You come first.** A message or `Esc` during the countdown cancels it and the report goes with
2667
+ your message. A turn you interrupt is not restarted behind your back. A later signal still wakes
2668
+ the lead after you cancelled an earlier one.
2669
+ - **A stop you ordered is not news.** Ending the team yourself (or having the lead do it) does not
2670
+ wake the lead for it; the report is still delivered with the next turn.
2671
+ - **Only dispatches the lead is free during.** Blocking dispatches (`-p`, `aragon exec`,
2672
+ governance mode, `team.detachDispatch: false`) return the report in the `task` result and produce
2673
+ no notice and no wake - exactly as before.
2674
+ - **Delivered exactly once** - each notice is acknowledged per steer by Core's receipt, a notice a
2675
+ fast-reviewer queue clear swallowed goes back in the queue, and `team_collect` returning the
2676
+ report removes the notice that would have repeated it.
2677
+ - **`team_status` shows a stall** (`no progress for 3m (blocked: ...)`), and `team_collect` stops
2678
+ waiting the moment a signal arrives.
2658
2679
 
2659
2680
  ### The lead's console: seven control tools
2660
2681
 
@@ -3857,6 +3878,15 @@ env / `.env` → CLI flags**.
3857
3878
  | `retry.respectRetryAfter` | `true` | Honour `Retry-After` (and the provider rate-limit reset headers) as a **floor**, never a replacement — a `Retry-After: 1` on the ninth retry does not undo eight retries of backoff. A stated wait above 60 s is surfaced immediately instead of waited out. |
3858
3879
  | `retry.maxElapsedMs` | `240000` | Wall-clock budget from the first failure, clamped to `[10000, 1800000]`. Under the legacy regime (`team.overseer: false`) with `team.subagentTimeoutMs` positive, keep this below it: an equal budget means a subagent is killed at the same instant its ladder ends, and the user is then told "subagent timed out" for what was a provider outage. |
3859
3880
  | `retry.onPartialStream` | `true` | Allow a restart after content has already streamed to the transcript. The view is rewound and the discarded tool cards removed; engine history is provably clean at that point, because it is only written on a completed turn. `false` refuses the whole path. |
3881
+ | `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
+ | `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
+ | `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. |
3884
+ | `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. |
3885
+ | `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. |
3886
+ | `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**. |
3887
+ | `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. |
3888
+ | `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. |
3889
+ | `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. |
3860
3890
  | `skills.enabled` | `true` | Master switch for the skill system. |
3861
3891
  | `skills.requireApproval` | `true` | Require a human to approve `skill_install` / `skill_create`. |
3862
3892
  | `skills.catalogMaxBytes` | `6000` | Level 1 catalog ceiling, in UTF-8 **bytes**, clamped to `[500, 40000]`. |
@@ -3876,6 +3906,53 @@ env / `.env` → CLI flags**.
3876
3906
  | `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. |
3877
3907
  | `log.previewChars` | `512` | How much user content `debug` keeps per field, clamped to `[0, 8192]`. `trace` is never truncated. |
3878
3908
 
3909
+ #### The reconnect ladder
3910
+
3911
+ A dropped connection used to mean ten fast retries and then a dead run. The retries
3912
+ are now **tiered**, and each tier answers a different kind of outage:
3913
+
3914
+ | Tier | Pace | Ends after | Answers |
3915
+ |---|---|---|---|
3916
+ | 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 |
3917
+ | 2 (slow) | one try every `retry.slowIntervalMs` (1 min) | `retry.slowAttempts` tries (10) | a short outage: a base-station swap, an office proxy reboot |
3918
+ | 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 |
3919
+
3920
+ The hand-over happens **inside one request**: nothing is replayed and nothing is
3921
+ re-planned, so the conversation, the tool results, the todo list and the context all
3922
+ stay exactly where they were. The worst case before the slow tier starts is about
3923
+ 14 minutes (≈181 s + 660 s); after that it is one attempt every five minutes,
3924
+ forever.
3925
+
3926
+ Three consequences worth knowing before you rely on it:
3927
+
3928
+ - **It is not free.** Every attempt re-sends the request and is billed again. Long
3929
+ outages are charged close to full price — do not count on prompt caching, whose
3930
+ TTL is five minutes and therefore sits on the boundary of tier 3's interval. Set
3931
+ `retry.holdMaxMinutes` if you want a hard ceiling; `0` (the default) means "keep
3932
+ trying until it works".
3933
+ - **`Esc` and a new message both stop a wait.** A run stuck in tier 2 or 3 can end
3934
+ the wait two ways: `Esc` aborts the run, and typing a message stops the wait and
3935
+ sends that message immediately (it is not queued — a queue would deliver it only
3936
+ after the wait, which could be five minutes).
3937
+ - **Pipelines get two tiers.** `aragon -p` and `aragon exec` default to `bounded`
3938
+ because nobody is there to press `Esc`, and a CI job that waits forever on a
3939
+ regional outage is a worse failure than a clear error. Subagents never escalate at
3940
+ all: they share the lead's provider registry but their requests never carry a
3941
+ ladder, so a stuck child cannot hold a whole fan-out open.
3942
+
3943
+ Two more details, both off by default or invisible until you need them:
3944
+
3945
+ - **`retry.stickyRung`** remembers the tier a request recovered in and starts the
3946
+ next request there for two minutes (`retry.stickyRung: true`). Without it, a link
3947
+ that stays down for twenty minutes costs four minutes of already-known-useless
3948
+ fast retries on *every* turn. It is off by default because it changes the rhythm
3949
+ you see, and a recovery on the fast ladder clears it immediately.
3950
+ - **The card and the status line say which tier you are in** — `slow retry 2/10`,
3951
+ then `attempt 4` with no denominator once waiting has no end — and `/retry show`
3952
+ prints the whole ladder from your live config, so it can never describe a
3953
+ configuration you do not have.
3954
+
3955
+
3879
3956
  Byte, not character: `ToolExecutor` truncates at 100 000 **bytes**, so a
3880
3957
  character-based budget would be roughly triple its nominal size for CJK text
3881
3958
  and would get cut mid-tag.
@@ -26,7 +26,8 @@ import type { ToolHookRunner } from '../exec/hooks/tool-wrapper.js';
26
26
  import type { ToolPermission } from '../exec/permission.js';
27
27
  import { type ToolOutputListener } from '@aragon-agent/tui/model/tools/tool-output-store';
28
28
  import type { FilePatch } from '@aragon-agent/tui/model/tools/patch';
29
- import { TeamRuntime } from '../team/runtime.js';
29
+ import { type TeamWakeAck, type TeamWakeBegin, type TeamWakeRequest } from '../team/wake.js';
30
+ export type { TeamWakeAck, TeamWakeBegin, TeamWakeRequest } from '../team/wake.js';
30
31
  import type { ReportOptions } from '../team/report.js';
31
32
  import type { DispatchHandle, DispatchInspection } from '../team/runtime.js';
32
33
  import type { TeamControlRequest } from '../team/console-view.js';
@@ -125,6 +126,19 @@ export interface ControllerDeps {
125
126
  * mid-run, and the sentence is guidance rather than a contract.
126
127
  */
127
128
  todoPanelCapable?: boolean;
129
+ /**
130
+ * Which host is running, for the ONE decision that genuinely depends on it: how
131
+ * many retry tiers a request gets (tiered-reconnect §4.4 / D-6).
132
+ *
133
+ * `'interactive'` (the default) = the full ladder, because a human can press Esc
134
+ * or type. `'headless'` = two tiers, because nobody is there — a CI job that
135
+ * waits forever on a regional outage is a worse failure than a clear error.
136
+ *
137
+ * NOT a second config system: the six `retry.*` keys still decide the shape; this
138
+ * only answers the `'auto'` case. `-p` and `exec` pass `'headless'`; everything
139
+ * else keeps the default, so every existing caller is byte-identical.
140
+ */
141
+ reconnectMode?: 'interactive' | 'headless';
128
142
  /**
129
143
  * The `aragon exec` tool policy (cli-integration-surface §4.2).
130
144
  *
@@ -468,6 +482,37 @@ export declare class AgentController {
468
482
  * answer cannot change between the tool array and the prompt that describes it.
469
483
  */
470
484
  private readonly toolImagesEnabled;
485
+ /**
486
+ * Which host this controller serves, for the ladder's SHAPE only
487
+ * (tiered-reconnect §4.4). Read once, at construction: a session does not change
488
+ * hosts, and a value that could change mid-run would make "two tiers" mean
489
+ * different things in two requests of one conversation.
490
+ */
491
+ private readonly reconnectMode;
492
+ /**
493
+ * Which tier the last request recovered in (tiered-reconnect §4.9), so the NEXT
494
+ * request does not spend four minutes re-learning that the fast ladder is not
495
+ * working. Process-local, read only when `retry.stickyRung` is on.
496
+ */
497
+ private readonly reconnectMemory;
498
+ /** The tier the CURRENT request is retrying in; 1 until an escalation happens. */
499
+ private retryTierThisRun;
500
+ /**
501
+ * The provider/model pair a sticky memory belongs to (tiered-reconnect §4.9).
502
+ * Comparing it is what makes a switch of model invalidate the memory instead of
503
+ * starting the new model at the old model's tier.
504
+ */
505
+ private currentModelRef;
506
+ /**
507
+ * Follow the ladder one stream event at a time, so a RECOVERY knows which tier it
508
+ * happened in (tiered-reconnect §4.9).
509
+ *
510
+ * CORE SENDS NO "recovered" EVENT — a successful request simply ends in `done` —
511
+ * so the tier of a recovery has to be remembered from the last `retry_scheduled`
512
+ * of the same request. That is the same derivation the reducer uses for its
513
+ * card, done here because the sticky memory belongs to the process, not to a view.
514
+ */
515
+ private observeRetryTier;
471
516
  /**
472
517
  * What the CURRENT prompt's `<image_input>` block was written for: the model and the support
473
518
  * answer together (`provider/model:support`). The block names the model, so a switch between
@@ -501,6 +546,22 @@ export declare class AgentController {
501
546
  */
502
547
  private readonly teamNotices;
503
548
  private teamRelay;
549
+ /**
550
+ * The wake governor (team-lead-wake-signals): "the team needs the lead - is now the
551
+ * moment to start a turn?". Level-triggered over the relay's ledger, so a dispatch
552
+ * that ends while the lead is idle still wakes it. Built next to the relay.
553
+ */
554
+ private teamWake;
555
+ /** Dispatches started DETACHED; only these produce notices and wakes (I-WK3). */
556
+ private readonly detachedDispatches;
557
+ /**
558
+ * `prompt()` / `continue()` calls between entry and exit. The engine's own
559
+ * `isRunning()` is false for the whole `gene.planForTurn` await, but a turn is
560
+ * certainly starting then; the governor must not start a second one (RV-P2-10).
561
+ */
562
+ private promptInFlight;
563
+ /** Distinguishes one notice steer's receipt id from the next. */
564
+ private noticeSequence;
504
565
  /**
505
566
  * The monotonic turn counter behind `I-DD11`.
506
567
  *
@@ -715,6 +776,15 @@ export declare class AgentController {
715
776
  steer(text: string): void;
716
777
  /** Return the opaque ID used by the view to match Core's acceptance receipt. */
717
778
  queueUserMessage(text: string, parts?: ContentPart[]): string;
779
+ /**
780
+ * `receipt` (notices only, team-lead-wake-signals) asks for an id WITHOUT making the
781
+ * steer a user message: Core echoes `steering_accepted` for any steer that has one,
782
+ * and the team relay needs that echo. It is deliberately NOT written to
783
+ * `pendingUserSteering` - `hasPendingUserMessages()`, `withdrawQueuedUserMessage()`,
784
+ * `continue()` and `fast`'s `userSteerCount` all read that map and mean "the user is
785
+ * waiting for an answer". The `notice:` prefix keeps every other receipt consumer
786
+ * treating it as an unknown id.
787
+ */
718
788
  private enqueueSteering;
719
789
  /**
720
790
  * Withdraw a queued user message by the id `queueUserMessage` returned.
@@ -1148,20 +1218,33 @@ export declare class AgentController {
1148
1218
  /** Whether a dispatch is live AND was started by an earlier turn. */
1149
1219
  teamOutlivesTurn(): boolean;
1150
1220
  /**
1151
- * The settle facts for the live-or-last dispatch, for the follow-up decision.
1152
- *
1153
- * THE ID TRAVELS WITH THE FACTS. The host spends the continuation with
1154
- * `markTeamContinued()`, and the facts are by definition read AFTER settlement,
1155
- * when `TeamRuntime.live()` already answers `null` - so an id re-derived from
1156
- * `live()` was always null, `session.continued` was never set, and every later
1157
- * `agent_end` earned the same follow-up turn: an unbounded model loop that
1158
- * never lets the user type.
1221
+ * Every attention notice the lead has not been PROVEN to have: the queue plus the
1222
+ * relay's ledger, oldest first. The governor's one input.
1223
+ */
1224
+ private owedAttention;
1225
+ /**
1226
+ * Register THE host of wake requests (one at a time). The terminal app and the
1227
+ * desktop coordinator both do it through `host/team-wake-driver.ts`.
1159
1228
  */
1160
- teamSettleFacts(): (NonNullable<ReturnType<TeamRuntime['settleFacts']>> & {
1161
- dispatchId: string;
1162
- }) | null;
1163
- /** Spend the one follow-up turn of the current dispatch (at most one). */
1164
- markTeamContinued(dispatchId: string): void;
1229
+ subscribeTeamWake(listener: (request: TeamWakeRequest) => void): () => void;
1230
+ /**
1231
+ * The fire-time re-check: still owed, lead still idle, no user message waiting - and
1232
+ * the `<team_signal>` text to submit, rendered NOW so anything that arrived during
1233
+ * the countdown is in it. Synchronous and never throws (I-WK10).
1234
+ */
1235
+ confirmTeamWake(requestId: string): TeamWakeBegin;
1236
+ ackTeamWake(requestId: string, result: TeamWakeAck): void;
1237
+ /** Whether any attention notice is undelivered. `team_collect` stops waiting on it. */
1238
+ hasPendingTeamAttention(): boolean;
1239
+ /**
1240
+ * `team_collect` has just put this dispatch's report in a tool result, so the settle
1241
+ * notice must not deliver it again (RC-8).
1242
+ */
1243
+ acknowledgeTeamSettle(dispatchId: string): void;
1244
+ /** The runtime's live roster as `still running` count: queued + running + paused. */
1245
+ private stillRunningCount;
1246
+ /** Forget everything the team owed the previous conversation. */
1247
+ private resetTeamSignals;
1165
1248
  /**
1166
1249
  * Turn one runtime event into a notice (section 5.3.1).
1167
1250
  *
@@ -1169,8 +1252,21 @@ export declare class AgentController {
1169
1252
  * queue must agree about what happened, and the only way to guarantee that is for
1170
1253
  * all three to read the same event. The queue adds nothing but the "exactly once"
1171
1254
  * bookkeeping.
1255
+ *
1256
+ * ONLY DETACHED DISPATCHES (I-WK3). A blocking dispatch already returns its report
1257
+ * in the `task` result, so a notice about it would deliver the same report twice -
1258
+ * and, now that notices wake the lead, would also start a turn for nothing. The one
1259
+ * exception to "seen `dispatch_start` first" is `dispatch_end.detached`, which the
1260
+ * runtime sets itself so a dispatch that died before it could announce its start
1261
+ * still reaches the lead (I-WK15).
1172
1262
  */
1173
1263
  private onTeamEvent;
1264
+ /** `done` / `aborted` are chatter; `failed` is a SIGNAL and arrives as `child_failed`. */
1265
+ private noteChildSettled;
1266
+ private noteChildFailed;
1267
+ private noteStalled;
1268
+ private noteDispatchEnd;
1269
+ private raiseSignal;
1174
1270
  /** Refused mid-dispatch by `/team`; half a dispatch under two ceilings is not
1175
1271
  * a result anything can afterwards explain (the reasoning `/reload` uses). */
1176
1272
  isTeamBusy(): boolean;
@@ -1274,6 +1370,15 @@ export declare class AgentController {
1274
1370
  */
1275
1371
  clearTodos(): void;
1276
1372
  getRetryConfig(): RetryConfig;
1373
+ /**
1374
+ * Which ladder shape this host gets (tiered-reconnect §4.4 / D-6).
1375
+ *
1376
+ * READ-ONLY, and it exists so the difference between a terminal and a pipeline is
1377
+ * OBSERVABLE: `-p` / `exec` are bounded, the TUI and the desktop are full, and the
1378
+ * failure this prevents (a CI job waiting forever on a regional outage) has no
1379
+ * other symptom. `/retry show` and the desktop's diagnostics can also report it.
1380
+ */
1381
+ getReconnectMode(): 'interactive' | 'headless';
1277
1382
  /**
1278
1383
  * Adopt a new retry config for this session AND PUSH IT INTO THE REGISTRY.
1279
1384
  *