@aragon-agent/cli 0.6.3 → 0.6.7
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 +142 -0
- package/README.md +203 -13
- package/dist/agent/controller.d.ts +158 -2
- package/dist/agent/controller.js +400 -1
- package/dist/agent/reducer.d.ts +102 -19
- package/dist/agent/reducer.js +162 -71
- package/dist/agent/system-prompt.d.ts +14 -0
- package/dist/agent/system-prompt.js +2 -0
- package/dist/agent/usage.d.ts +34 -0
- package/dist/agent/usage.js +43 -0
- package/dist/cli.js +132 -23
- package/dist/commands/builtins.js +101 -1
- package/dist/compaction/child.js +5 -0
- package/dist/compaction/command.js +14 -1
- package/dist/compaction/compactor.d.ts +94 -24
- package/dist/compaction/compactor.js +247 -98
- package/dist/compaction/context-command.d.ts +33 -0
- package/dist/compaction/context-command.js +166 -0
- package/dist/compaction/meter.d.ts +251 -0
- package/dist/compaction/meter.js +428 -0
- package/dist/compaction/pressure.d.ts +6 -0
- package/dist/compaction/pressure.js +4 -0
- package/dist/compaction/types.d.ts +77 -0
- package/dist/compaction/wiring.d.ts +56 -0
- package/dist/compaction/wiring.js +107 -25
- package/dist/config/cli-commands.js +5 -0
- package/dist/config/env.d.ts +1 -1
- package/dist/config/env.js +63 -2
- package/dist/config/load.d.ts +28 -0
- package/dist/config/load.js +83 -1
- package/dist/config/schema.d.ts +129 -0
- package/dist/config/schema.js +69 -0
- package/dist/config/store.js +47 -1
- package/dist/exec/events.d.ts +138 -1
- package/dist/exec/events.js +42 -0
- package/dist/exec/index.js +43 -6
- package/dist/exec/progress-reporter.d.ts +23 -0
- package/dist/exec/progress-reporter.js +88 -0
- package/dist/exec/runner.d.ts +34 -0
- package/dist/exec/runner.js +137 -25
- package/dist/fast/reviewer.d.ts +19 -1
- package/dist/fast/reviewer.js +22 -0
- package/dist/fast/types.d.ts +15 -0
- package/dist/fast/wiring.d.ts +10 -1
- package/dist/fast/wiring.js +18 -1
- package/dist/input/limits.d.ts +72 -0
- package/dist/input/limits.js +63 -0
- package/dist/input/paste-parse.d.ts +71 -0
- package/dist/input/paste-parse.js +95 -0
- package/dist/input/stdin-filter.d.ts +81 -0
- package/dist/input/stdin-filter.js +379 -0
- package/dist/logging/install.d.ts +2 -0
- package/dist/logging/install.js +53 -1
- package/dist/proc/classify.d.ts +52 -0
- package/dist/proc/classify.js +143 -0
- package/dist/proc/kill-tree.d.ts +42 -0
- package/dist/proc/kill-tree.js +119 -0
- package/dist/proc/limits.d.ts +84 -0
- package/dist/proc/limits.js +84 -0
- package/dist/proc/log-ring.d.ts +68 -0
- package/dist/proc/log-ring.js +102 -0
- package/dist/proc/prompt.d.ts +24 -0
- package/dist/proc/prompt.js +49 -0
- package/dist/proc/readiness.d.ts +102 -0
- package/dist/proc/readiness.js +219 -0
- package/dist/proc/supervisor.d.ts +103 -0
- package/dist/proc/supervisor.js +465 -0
- package/dist/proc/types.d.ts +175 -0
- package/dist/proc/types.js +15 -0
- package/dist/session/persist.js +36 -1
- package/dist/todo/limits.d.ts +4 -17
- package/dist/todo/limits.js +4 -17
- package/dist/todo/panel-rows.d.ts +8 -6
- package/dist/todo/panel-rows.js +19 -6
- package/dist/tools/bash-tool.d.ts +51 -2
- package/dist/tools/bash-tool.js +321 -51
- package/dist/tools/fs-tools.d.ts +17 -0
- package/dist/tools/index.d.ts +55 -2
- package/dist/tools/index.js +39 -1
- package/dist/tools/proc-tools.d.ts +25 -0
- package/dist/tools/proc-tools.js +102 -0
- package/dist/ui/App.d.ts +15 -2
- package/dist/ui/App.js +330 -69
- package/dist/ui/AutocompletePopup.d.ts +3 -1
- package/dist/ui/AutocompletePopup.js +9 -11
- package/dist/ui/BottomStatusRow.d.ts +1 -1
- package/dist/ui/Composer.d.ts +56 -1
- package/dist/ui/Composer.js +50 -6
- package/dist/ui/PromptInput.d.ts +52 -3
- package/dist/ui/PromptInput.js +201 -55
- package/dist/ui/StatusBar.d.ts +40 -15
- package/dist/ui/StatusBar.js +51 -9
- package/dist/ui/TeamPanel.d.ts +3 -1
- package/dist/ui/TeamPanel.js +13 -9
- package/dist/ui/TodoPanel.d.ts +5 -5
- package/dist/ui/TodoPanel.js +56 -24
- package/dist/ui/Transcript.js +29 -1
- package/dist/ui/UpdateLine.d.ts +1 -1
- package/dist/ui/capabilities.js +5 -5
- package/dist/ui/composer-limits.d.ts +31 -0
- package/dist/ui/composer-limits.js +50 -0
- package/dist/ui/composer-rows.d.ts +73 -0
- package/dist/ui/composer-rows.js +201 -0
- package/dist/ui/editor-reducer.d.ts +37 -0
- package/dist/ui/editor-reducer.js +88 -12
- package/dist/ui/entries/ServiceCard.d.ts +66 -0
- package/dist/ui/entries/ServiceCard.js +116 -0
- package/dist/ui/entries/UserEntry.d.ts +17 -3
- package/dist/ui/entries/UserEntry.js +34 -5
- package/dist/ui/exit-snapshot.d.ts +9 -0
- package/dist/ui/layout/ScrollViewport.d.ts +1 -1
- package/dist/ui/layout/autocomplete.d.ts +18 -0
- package/dist/ui/layout/autocomplete.js +26 -0
- package/dist/ui/layout/budget.d.ts +34 -6
- package/dist/ui/layout/budget.js +32 -7
- package/dist/ui/layout/rail.d.ts +4 -53
- package/dist/ui/layout/rail.js +10 -62
- package/dist/ui/layout/team-panel.d.ts +18 -0
- package/dist/ui/layout/team-panel.js +22 -0
- package/dist/ui/layout/todo-layout.d.ts +24 -0
- package/dist/ui/layout/todo-layout.js +27 -0
- package/dist/ui/layout/virtual-window.js +51 -1
- package/dist/ui/overlays/HelpOverlay.js +3 -0
- package/dist/ui/overlays/PlanReviewOverlay.js +10 -2
- package/dist/ui/overlays/QuestionOverlay.js +5 -1
- package/dist/ui/overlays/SettingsScreen.js +14 -1
- package/dist/ui/paste-frames.d.ts +87 -0
- package/dist/ui/paste-frames.js +112 -0
- package/dist/ui/paste-tokens.d.ts +90 -0
- package/dist/ui/paste-tokens.js +147 -0
- package/dist/ui/screen.d.ts +16 -0
- package/dist/ui/screen.js +45 -2
- package/dist/ui/selection/selection-controller.d.ts +1 -1
- package/dist/ui/transcript-text.js +55 -2
- package/dist/ui/use-wheel-routing.d.ts +1 -1
- package/package.json +2 -2
- package/dist/input/stdin-mouse-filter.d.ts +0 -47
- package/dist/input/stdin-mouse-filter.js +0 -153
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
import { type Message, type ModelInfo, type ModelRef, type TokenUsage, type AssistantMessage, type CompactionContext, type CompactionOutcome, type CompactionProbe, type ContextManager, type LLMRequest } from '@aragon-agent/core';
|
|
13
13
|
import type { CliConfig } from '../config/schema.js';
|
|
14
14
|
import type { NoticeLevel } from '../agent/reducer.js';
|
|
15
|
+
import { ContextMeter } from './meter.js';
|
|
15
16
|
import type { CompactionEvent, Pressure } from './types.js';
|
|
16
17
|
export interface CompactorDeps {
|
|
17
18
|
/** Read LIVE on every call — the controller replaces the object on mutation. */
|
|
@@ -42,6 +43,24 @@ export interface CompactorDeps {
|
|
|
42
43
|
complete: (providerId: string, request: LLMRequest) => Promise<AssistantMessage>;
|
|
43
44
|
emit: (event: CompactionEvent) => void;
|
|
44
45
|
notify: (level: NoticeLevel, text: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* The ONE owner of occupancy measurement (context-usage-gauge-accuracy W1).
|
|
48
|
+
*
|
|
49
|
+
* THE COMPACTOR NO LONGER MEASURES. It used to hold `estimateOffset`,
|
|
50
|
+
* `measuredPrefixLength` and `lastPressure` itself, which locked the only
|
|
51
|
+
* measuring code in the process behind `compaction.enabled` - and a session
|
|
52
|
+
* that turned compaction OFF is exactly the one whose gauge then had a single
|
|
53
|
+
* sample per turn and nothing else. Reading a meter the controller owns makes
|
|
54
|
+
* "the trigger and the gauge read one number" a STRUCTURAL fact rather than a
|
|
55
|
+
* discipline (§3.3).
|
|
56
|
+
*
|
|
57
|
+
* OPTIONAL SO EVERY EXISTING CONSTRUCTION SITE COMPILES (R-1), and lazily
|
|
58
|
+
* replaced by a private one built from the deps already here. PRODUCTION MUST
|
|
59
|
+
* INJECT: `context-gauge-wiring.test.ts` asserts one instance per process
|
|
60
|
+
* (`controller.getContextMeter()` is the same object the wiring forwards), and
|
|
61
|
+
* two meters in one session means two answers to one question.
|
|
62
|
+
*/
|
|
63
|
+
meter?: ContextMeter;
|
|
45
64
|
/**
|
|
46
65
|
* Publish the occupancy this checkpoint measured (hardening §3.2.4 / DH-15).
|
|
47
66
|
*
|
|
@@ -78,6 +97,15 @@ export declare class Compactor implements ContextManager {
|
|
|
78
97
|
private compactionsThisRun;
|
|
79
98
|
private lastCompactionTurn;
|
|
80
99
|
private compactions;
|
|
100
|
+
/**
|
|
101
|
+
* How many `compact()` calls returned WITHOUT announcing (quiet-noop D-9).
|
|
102
|
+
*
|
|
103
|
+
* A SESSION TOTAL, LIKE `compactions`, and reset by neither `onRunStart()` nor
|
|
104
|
+
* `clearSelfDisable()`: `/compact on` overrides a guard, it does not rewrite
|
|
105
|
+
* history. `/compact status` is its only reader, and it is the whole of what
|
|
106
|
+
* keeps a decline reportable once the transcript stops carrying one.
|
|
107
|
+
*/
|
|
108
|
+
private declined;
|
|
81
109
|
private tokensReclaimed;
|
|
82
110
|
private sessionUsage;
|
|
83
111
|
private pricingUnknown;
|
|
@@ -87,18 +115,15 @@ export declare class Compactor implements ContextManager {
|
|
|
87
115
|
private selfDisabledReason;
|
|
88
116
|
private pendingManual;
|
|
89
117
|
private generation;
|
|
90
|
-
/** Calibration for every ESTIMATED figure (D-23). Recomputed on every turn_end. */
|
|
91
|
-
private estimateOffset;
|
|
92
|
-
/** The last pressure computed, so the status bar and `/compact status` agree. */
|
|
93
|
-
private lastPressure;
|
|
94
118
|
/**
|
|
95
|
-
* The
|
|
119
|
+
* The fallback meter, built on first use when no host injected one (R-1).
|
|
96
120
|
*
|
|
97
|
-
* `
|
|
98
|
-
*
|
|
99
|
-
*
|
|
121
|
+
* `estimateOffset`, `measuredPrefixLength` and `lastPressure` used to be
|
|
122
|
+
* FIELDS HERE. They moved to `ContextMeter` wholesale
|
|
123
|
+
* (context-usage-gauge-accuracy W1), because keeping them here is what put the
|
|
124
|
+
* only measurement in the process behind `compaction.enabled`.
|
|
100
125
|
*/
|
|
101
|
-
private
|
|
126
|
+
private ownMeter;
|
|
102
127
|
/**
|
|
103
128
|
* The messages the last splice dropped, held ONLY until the wiring collects
|
|
104
129
|
* them for the archive (W4 / RV-3).
|
|
@@ -120,21 +145,17 @@ export declare class Compactor implements ContextManager {
|
|
|
120
145
|
/** `agent_start` — the per-run cap resets, the session totals do not. */
|
|
121
146
|
onRunStart(): void;
|
|
122
147
|
/**
|
|
123
|
-
* `turn_end`
|
|
148
|
+
* `turn_end` - recompute the calibration offset (D-23).
|
|
124
149
|
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
|
|
128
|
-
onTurnEnd(usage: TokenUsage, messages: readonly Message[], systemPrompt: string): void;
|
|
129
|
-
/**
|
|
130
|
-
* Any host-side history mutation that is NOT an append (hardening §3.2.3).
|
|
150
|
+
* A THIN FORWARDER since context-usage-gauge-accuracy W1. The meter subscribes
|
|
151
|
+
* to `turn_end` itself, so BOTH PATHS MUST BE IDEMPOTENT: this one recomputes
|
|
152
|
+
* exactly what the other one did from the same inputs, which it is.
|
|
131
153
|
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* costs accuracy - the number degrades to round 1's - and never correctness.
|
|
154
|
+
* `messages` / `systemPrompt` stay in the signature and are ignored: the meter
|
|
155
|
+
* reads them from its own lazy deps, and every existing caller and test keeps
|
|
156
|
+
* compiling.
|
|
136
157
|
*/
|
|
137
|
-
|
|
158
|
+
onTurnEnd(usage: TokenUsage, _messages: readonly Message[], _systemPrompt: string): void;
|
|
138
159
|
/**
|
|
139
160
|
* The dropped messages, released as they are returned (W4 / RV-3).
|
|
140
161
|
*
|
|
@@ -175,6 +196,29 @@ export declare class Compactor implements ContextManager {
|
|
|
175
196
|
*/
|
|
176
197
|
shouldCompact(probe: CompactionProbe): boolean;
|
|
177
198
|
compact(ctx: CompactionContext): Promise<CompactionOutcome>;
|
|
199
|
+
/**
|
|
200
|
+
* Open the card (quiet-noop §3.2).
|
|
201
|
+
*
|
|
202
|
+
* THE ONLY EMITTER OF `compaction_start`, AND THE ONLY PLACE `this.compactions`
|
|
203
|
+
* ADVANCES. A compaction that never reaches an announce point is a DECLINE: it
|
|
204
|
+
* changed nothing, called nothing and spent nothing, and it is deliberately
|
|
205
|
+
* indistinguishable - on every human surface except `/compact status`'s
|
|
206
|
+
* `declined` count (D-9) - from a turn at which `shouldCompact` returned false.
|
|
207
|
+
* `finish` is the other half of that rule.
|
|
208
|
+
*
|
|
209
|
+
* IT RETURNS THE ANNOUNCEMENT RATHER THAN STORING IT (P1-1), and the caller
|
|
210
|
+
* keeps it in a LOCAL for the lifetime of one `runCompaction` call - the same
|
|
211
|
+
* slot `index` occupied before this change. An instance field would have needed
|
|
212
|
+
* a no-re-entrancy argument, and the obvious one is WRONG: guard 1 lives in
|
|
213
|
+
* `shouldCompact`, while the idle `/compact` path calls `compact()` straight
|
|
214
|
+
* through `wiring.compactNow()` without consulting it. What actually keeps two
|
|
215
|
+
* compactions apart is that `command.ts` QUEUES instead of calling `compactNow`
|
|
216
|
+
* while the loop runs - a property of a different file, which is exactly why
|
|
217
|
+
* this one must not depend on it. A clobbered field would leave `finish` unable
|
|
218
|
+
* to settle the card it opened, and a card that never settles pins
|
|
219
|
+
* `Transcript`'s monotonic boundary for the rest of the session.
|
|
220
|
+
*/
|
|
221
|
+
private announce;
|
|
178
222
|
private runCompaction;
|
|
179
223
|
/** Tail relief against this session's window (hardening §3.3.3 / W2). */
|
|
180
224
|
private relieveInPlace;
|
|
@@ -223,20 +267,36 @@ export declare class Compactor implements ContextManager {
|
|
|
223
267
|
private noteNoProgress;
|
|
224
268
|
private finish;
|
|
225
269
|
/**
|
|
226
|
-
* The pressure the trigger and the gauge both read.
|
|
270
|
+
* The pressure the trigger and the gauge both read - MEASURED NOW.
|
|
227
271
|
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
272
|
+
* A FORWARDER since W1: the decision point supplies its own authoritative
|
|
273
|
+
* `lastUsage` (the probe's), and the meter owns everything else. `messages` /
|
|
274
|
+
* `systemPrompt` stay in the signature and are ignored, because the meter
|
|
275
|
+
* reads the LIVE history through its own deps - which is strictly better than
|
|
276
|
+
* a caller that could pass `[]` and get a 0 % reading (the old default here).
|
|
230
277
|
*/
|
|
231
278
|
measure(probe: Pick<CompactionProbe, 'lastUsage'> & {
|
|
232
279
|
messages?: readonly Message[];
|
|
233
280
|
systemPrompt?: string;
|
|
234
281
|
}): Pressure;
|
|
282
|
+
/**
|
|
283
|
+
* The last pressure PUBLISHED. NEVER re-measured - `lastPublished`, not
|
|
284
|
+
* `current` (I-10 / RV-3).
|
|
285
|
+
*
|
|
286
|
+
* `finish()` below reads this for `tokensBefore`, which is the sole upstream of
|
|
287
|
+
* `tokensReclaimed`, the card's "reclaimed N tokens" and `/compact status`'s
|
|
288
|
+
* session total. All three want the occupancy BEFORE the splice. Point this at
|
|
289
|
+
* `meter.current()` and the moment the meter is dirty - which after a splice it
|
|
290
|
+
* always is - `tokensBefore` becomes the POST-compaction figure, `reclaimed`
|
|
291
|
+
* collapses to 0, and the card renders that with nothing logging a fault.
|
|
292
|
+
*/
|
|
235
293
|
lastMeasured(): Pressure | null;
|
|
236
294
|
/** Written by the wiring once the engine has reported its verdict. */
|
|
237
295
|
recordApplied(tokensBefore: number, tokensAfter: number): void;
|
|
238
296
|
sessionTotals(): {
|
|
239
297
|
compactions: number;
|
|
298
|
+
/** Checkpoints that declined before committing to any work (quiet-noop D-9). */
|
|
299
|
+
declined: number;
|
|
240
300
|
tokensReclaimed: number;
|
|
241
301
|
usage: TokenUsage;
|
|
242
302
|
pricingUnknown: boolean;
|
|
@@ -261,6 +321,16 @@ export declare class Compactor implements ContextManager {
|
|
|
261
321
|
* entire run, and the spend is on the card with the summarizer's own price.
|
|
262
322
|
*/
|
|
263
323
|
resolveSummarizer(): SummarizerChoice | null;
|
|
324
|
+
/**
|
|
325
|
+
* The meter this compactor reads, injected or private (R-1).
|
|
326
|
+
*
|
|
327
|
+
* MEMOIZED, because a fresh meter on every call would have no `estimateOffset`
|
|
328
|
+
* and no cached pressure - `lastMeasured()` would answer `null` forever and
|
|
329
|
+
* `tokensReclaimed` would sit at 0. The fallback exists so the ten existing
|
|
330
|
+
* `compaction-*.test.ts` construction sites compile unchanged; production
|
|
331
|
+
* injects, and `context-gauge-wiring.test.ts` asserts the single instance.
|
|
332
|
+
*/
|
|
333
|
+
private meter;
|
|
264
334
|
private mainRef;
|
|
265
335
|
private modelInfo;
|
|
266
336
|
private effectiveMaxOutputTokens;
|