@aragon-agent/cli 0.6.48 → 0.6.50

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 (72) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -0
  3. package/dist/agent/controller.d.ts +21 -0
  4. package/dist/agent/controller.js +35 -8
  5. package/dist/agent/governance-wiring.d.ts +2 -0
  6. package/dist/agent/governance-wiring.js +4 -0
  7. package/dist/app/App.d.ts +2 -4
  8. package/dist/app/App.js +279 -522
  9. package/dist/cli.js +8 -150
  10. package/dist/commands/catalog.d.ts +17 -0
  11. package/dist/commands/catalog.js +52 -0
  12. package/dist/commands/create-registry.d.ts +13 -0
  13. package/dist/commands/create-registry.js +19 -0
  14. package/dist/commands/governance-command.js +5 -1
  15. package/dist/commands/skills.js +18 -67
  16. package/dist/config/env.d.ts +2 -0
  17. package/dist/config/env.js +11 -1
  18. package/dist/config/load.js +4 -0
  19. package/dist/fast/review-call.d.ts +6 -0
  20. package/dist/fast/review-call.js +10 -0
  21. package/dist/governance/engine/budget.d.ts +18 -6
  22. package/dist/governance/engine/budget.js +61 -19
  23. package/dist/governance/engine/engine-core.d.ts +10 -0
  24. package/dist/governance/engine/engine-core.js +56 -9
  25. package/dist/governance/engine/engine.d.ts +1 -0
  26. package/dist/governance/engine/engine.js +9 -10
  27. package/dist/governance/engine/inspector.js +4 -3
  28. package/dist/governance/engine/lifecycle.js +4 -2
  29. package/dist/governance/engine/report.js +7 -1
  30. package/dist/governance/engine/run-digest.js +2 -1
  31. package/dist/governance/engine/stage-runner.js +1 -1
  32. package/dist/governance/engine/submissions.d.ts +2 -0
  33. package/dist/governance/engine/submissions.js +22 -3
  34. package/dist/governance/engine/visibility.d.ts +10 -0
  35. package/dist/governance/engine/visibility.js +28 -0
  36. package/dist/governance/rules/settlement.d.ts +7 -0
  37. package/dist/governance/rules/settlement.js +24 -0
  38. package/dist/governance/tools/shared-tools.d.ts +2 -0
  39. package/dist/governance/tools/shared-tools.js +15 -1
  40. package/dist/governance/tools/submit-tools.js +14 -7
  41. package/dist/host/commands.d.ts +18 -0
  42. package/dist/host/commands.js +30 -0
  43. package/dist/host/controller-factory.d.ts +109 -0
  44. package/dist/host/controller-factory.js +159 -0
  45. package/dist/host/controller-feed.d.ts +122 -0
  46. package/dist/host/controller-feed.js +356 -0
  47. package/dist/host/index-build.d.ts +23 -0
  48. package/dist/host/index-build.js +35 -0
  49. package/dist/host/index.d.ts +21 -0
  50. package/dist/host/index.js +21 -0
  51. package/dist/host/interaction.d.ts +58 -0
  52. package/dist/host/interaction.js +165 -0
  53. package/dist/host/logging.d.ts +7 -0
  54. package/dist/host/logging.js +7 -0
  55. package/dist/host/prompts.d.ts +10 -0
  56. package/dist/host/prompts.js +9 -0
  57. package/dist/host/sessions.d.ts +87 -0
  58. package/dist/host/sessions.js +234 -0
  59. package/dist/host/settings.d.ts +104 -0
  60. package/dist/host/settings.js +235 -0
  61. package/dist/host/skills.d.ts +19 -0
  62. package/dist/host/skills.js +38 -0
  63. package/dist/skills/command-names.d.ts +19 -0
  64. package/dist/skills/command-names.js +28 -0
  65. package/dist/skills/invoke.d.ts +38 -0
  66. package/dist/skills/invoke.js +65 -0
  67. package/dist/team/overseer.d.ts +25 -1
  68. package/dist/team/overseer.js +38 -1
  69. package/dist/team/runtime.d.ts +2 -0
  70. package/dist/team/runtime.js +10 -7
  71. package/dist/team/subagent.js +6 -4
  72. package/package.json +3 -3
@@ -0,0 +1,356 @@
1
+ /**
2
+ * Controller event -> `ViewAction` feed, independent of any UI framework.
3
+ *
4
+ * MOVED OUT OF `App.tsx`, NOT REWRITTEN (desktop-electron-app Phase 0). The terminal and the
5
+ * desktop host must turn the same engine events into the same view actions, or one of them
6
+ * silently renders a different conversation. Each `attach*Channel` below is the body of one
7
+ * former `useEffect` in `App.tsx`, with its original comments, and `App.tsx` now calls it.
8
+ *
9
+ * WHAT STAYS IN APP: follow-through, the forced-dispatch gate, interrupt gestures, run
10
+ * metrics and the human-request overlay are TUI interaction policy, not mapping. They plug
11
+ * in through {@link AgentChannelHooks} at the exact points the inline code used to run.
12
+ *
13
+ * NO INK, NO TTY, NO REACT (layering gate L9).
14
+ */
15
+ import { mergeDeltas } from '../agent/coalesce.js';
16
+ import { reduceEvent, } from '@aragon-agent/tui/model/agent/reducer';
17
+ import { priceTeamUsage } from '@aragon-agent/tui/model/team/model';
18
+ import { computeCost } from '@aragon-agent/tui/model/agent/usage';
19
+ /**
20
+ * The streaming coalescer. Text / thinking / tool-output deltas arrive at pipe speed and
21
+ * are buffered then merged; everything else is dispatched immediately (the callers decide
22
+ * which is which). `intervalMs` is read AT ARM TIME so a governor that retunes the interval
23
+ * moves the next flush, not only the next mount.
24
+ */
25
+ export class ActionCoalescer {
26
+ dispatch;
27
+ intervalMs;
28
+ pending = [];
29
+ timer = null;
30
+ constructor(dispatch, intervalMs) {
31
+ this.dispatch = dispatch;
32
+ this.intervalMs = intervalMs;
33
+ }
34
+ /** Buffer one action and arm the flush timer if it is not already armed. */
35
+ push(action) {
36
+ this.pending.push(action);
37
+ if (!this.timer)
38
+ this.timer = setTimeout(() => this.flush(), this.intervalMs());
39
+ }
40
+ /** Merge and dispatch everything buffered. Safe to call when empty. */
41
+ flush() {
42
+ if (this.timer) {
43
+ clearTimeout(this.timer);
44
+ this.timer = null;
45
+ }
46
+ if (this.pending.length === 0)
47
+ return;
48
+ const merged = mergeDeltas(this.pending);
49
+ this.pending = [];
50
+ for (const action of merged)
51
+ this.dispatch(action);
52
+ }
53
+ }
54
+ /**
55
+ * The main run stream: generation guard, reduce, coalesce.
56
+ *
57
+ * THE GENERATION GUARD (I-7 / P1-7): `forceStop()` bumps the controller's generation, and
58
+ * everything the engine emits while it unwinds belongs to the run the user abandoned.
59
+ * `generation` is a LOCAL `let`, RE-READ on every event rather than captured once, so a
60
+ * force-stop makes stale events inert WITHOUT making the next run's events inert too.
61
+ */
62
+ export function attachAgentChannel(controller, deps) {
63
+ const { dispatch, coalescer, patchSource, hooks } = deps;
64
+ let generation = controller.runGeneration;
65
+ const unsubscribe = controller.subscribe((event) => {
66
+ // Receipts describe committed history even when force-stop invalidated the run.
67
+ if (event.type === 'steering_accepted') {
68
+ dispatch({ type: 'steeringAccepted', ids: event.ids });
69
+ return;
70
+ }
71
+ if (controller.runGeneration !== generation) {
72
+ // Adopt the new generation only once the engine finished unwinding, so a late
73
+ // `agent_end` cannot be mistaken for the next run's.
74
+ if (event.type === 'agent_end')
75
+ generation = controller.runGeneration;
76
+ return;
77
+ }
78
+ hooks?.beforeEvent?.(event);
79
+ const cost = controller.getModelInfo().cost;
80
+ for (const action of reduceEvent(event, cost, patchSource)) {
81
+ hooks?.onAction?.(action);
82
+ if (action.type === 'textDelta' || action.type === 'thinkingDelta') {
83
+ coalescer.push(action);
84
+ }
85
+ else {
86
+ coalescer.flush();
87
+ dispatch(action);
88
+ }
89
+ }
90
+ if (event.type === 'agent_end')
91
+ hooks?.afterAgentEnd?.();
92
+ });
93
+ return () => {
94
+ coalescer.flush();
95
+ unsubscribe();
96
+ };
97
+ }
98
+ /** Background services. `onService` lets the TUI keep its own id -> snapshot map. */
99
+ export function attachProcChannel(controller, dispatch, onService) {
100
+ return controller.subscribeProc((event) => {
101
+ const service = event.service;
102
+ onService?.(service);
103
+ if (event.type === 'started') {
104
+ dispatch({ type: 'serviceStart', service });
105
+ return;
106
+ }
107
+ if (event.type === 'exited' || event.type === 'stopped') {
108
+ dispatch({ type: 'serviceEnd', service });
109
+ return;
110
+ }
111
+ dispatch({ type: 'serviceUpdate', service });
112
+ });
113
+ }
114
+ /**
115
+ * Team-mode event stream (team-subagents). A SEPARATE SUBSCRIPTION: `TeamEvent` is
116
+ * deliberately not a member of core's `AgentEvent`. Not routed through the coalescer -
117
+ * `agent_update` is already coalesced at the source at 120 ms per child.
118
+ */
119
+ export function attachTeamChannel(controller, dispatch) {
120
+ return controller.subscribeTeam((event) => {
121
+ switch (event.type) {
122
+ case 'dispatch_start':
123
+ dispatch({
124
+ type: 'teamStart',
125
+ dispatchId: event.dispatchId,
126
+ requested: event.requested,
127
+ specs: event.specs,
128
+ });
129
+ break;
130
+ case 'agent_update':
131
+ case 'message': {
132
+ const snapshot = controller.getTeamSnapshot();
133
+ if (snapshot)
134
+ dispatch({ type: 'teamUpdate', snapshot });
135
+ break;
136
+ }
137
+ case 'overseer': {
138
+ // A supervisor decision was applied. The roster already refreshed through the
139
+ // agent_update the runtime publishes with it; re-read so the panel cannot miss it.
140
+ const snap = controller.getTeamSnapshot();
141
+ if (snap)
142
+ dispatch({ type: 'teamUpdate', snapshot: snap });
143
+ // A TERMINAL verdict is the one decision the user must not discover from the final
144
+ // report - it removes work they watched running. wait and nudge stay panel-only.
145
+ if (event.decision.action === 'replace' || event.decision.action === 'abandon') {
146
+ const verb = event.decision.action === 'replace' ? 'replaced' : 'abandoned';
147
+ const level = event.decision.action === 'replace' ? 'info' : 'warn';
148
+ const reason = event.decision.reason.slice(0, 120);
149
+ dispatch({
150
+ type: 'notice',
151
+ level,
152
+ text: `team supervisor ${verb} ${event.label} - ${reason}`,
153
+ });
154
+ }
155
+ break;
156
+ }
157
+ case 'usage': {
158
+ // Child spend is REAL SPEND and must reach the status bar. PRICED AT THE MODEL THE
159
+ // CHILDREN RAN, through the same resolution the dispatch report prices with: under
160
+ // `fast` / `profile` the lead's table would over-report by up to an order of
161
+ // magnitude, and an unpriced child model must read as unknown (ZERO), not as the
162
+ // lead's. Read from the controller, never from a captured config.
163
+ const costDelta = priceTeamUsage(controller.subagentModelResolution(), event.usage, {
164
+ mainCost: controller.getModelInfo().cost,
165
+ isPriced: (ref) => controller.isPricedModel(ref),
166
+ costFor: (ref) => controller.getModelInfoFor(ref).cost,
167
+ });
168
+ dispatch({ type: 'teamUsage', usage: event.usage, costDelta });
169
+ break;
170
+ }
171
+ case 'dispatch_end': {
172
+ // The supervisor's own calls never emit a usage event (they go through the fast
173
+ // registry directly), so their spend reaches the readout HERE, once per dispatch,
174
+ // at the fast tier's price.
175
+ const spend = event.outcome.overseerUsage;
176
+ if (spend !== undefined && (spend.inputTokens > 0 || spend.outputTokens > 0)) {
177
+ const tier = controller.getFastStatus().tier;
178
+ const costDelta = tier.ok && controller.isPricedModel(tier.ref)
179
+ ? computeCost(spend, controller.getModelInfoFor(tier.ref).cost)
180
+ : 0;
181
+ dispatch({ type: 'fastUsage', usage: spend, costDelta });
182
+ }
183
+ dispatch({ type: 'teamEnd', outcome: event.outcome });
184
+ break;
185
+ }
186
+ }
187
+ });
188
+ }
189
+ /**
190
+ * Governance event stream. CLI-LOCAL for the reason the team one is: `GovernanceEvent` is
191
+ * not a member of `AgentEvent`. Folds snapshots into the view, appends the four settlement
192
+ * cards (charter, phase, escalation, final) and clears the live snapshot when the run ends.
193
+ */
194
+ export function attachGovernanceChannel(controller, dispatch) {
195
+ return controller.subscribeGovernance((event) => {
196
+ dispatch({ type: 'govSnapshot', snapshot: event.snapshot });
197
+ const card = event.type === 'run_started' || event.type === 'stage_ended' ? event.card
198
+ : event.type === 'escalation' || event.type === 'run_closed' ? event.card
199
+ : null;
200
+ if (card)
201
+ dispatch({ type: 'governanceCard', card });
202
+ if (event.type === 'run_closed')
203
+ dispatch({ type: 'govEnd' });
204
+ });
205
+ }
206
+ /**
207
+ * Todo event stream. NOT through the coalescer: a `todo_write` is one deliberate act per
208
+ * step, and delaying the one surface the user watches a long task through is backwards.
209
+ */
210
+ export function attachTodosChannel(controller, dispatch) {
211
+ return controller.subscribeTodos((event) => {
212
+ switch (event.type) {
213
+ case 'updated':
214
+ dispatch({ type: 'todoUpdate', snapshot: event.snapshot });
215
+ break;
216
+ case 'cleared':
217
+ dispatch({ type: 'todoCleared' });
218
+ break;
219
+ case 'rejected':
220
+ // THE COMPENSATING PATH FOR SUPPRESSING THE TOOL CARD: without it, the one case
221
+ // where `todo_write` produces nothing visible would be the case that most needs to be.
222
+ dispatch({ type: 'notice', level: 'warn', text: event.reason });
223
+ break;
224
+ }
225
+ });
226
+ }
227
+ /**
228
+ * Fast-tier event stream. `subscribeFast` returns a no-op unsubscribe when the tier was off
229
+ * at construction, so this can subscribe unconditionally. Seeds the chip from the tier
230
+ * resolved at construction so a fast-enabled session shows it on the first frame.
231
+ */
232
+ export function attachFastChannel(controller, dispatch) {
233
+ const initial = controller.getFastStatus();
234
+ if (initial.registered)
235
+ dispatch({ type: 'fastTier', snapshot: initial.snapshot });
236
+ return controller.subscribeFast((event) => {
237
+ switch (event.type) {
238
+ case 'review_start':
239
+ dispatch({
240
+ type: 'fastStart',
241
+ index: event.index,
242
+ turn: event.turn,
243
+ model: controller.getFastStatus().snapshot.model,
244
+ });
245
+ break;
246
+ case 'review_end':
247
+ dispatch({ type: 'fastEnd', review: event.review });
248
+ // The card settled, so the chip's `inFlight` and the session totals both moved.
249
+ dispatch({ type: 'fastTier', snapshot: controller.getFastStatus().snapshot });
250
+ break;
251
+ case 'usage': {
252
+ // Review spend is REAL SPEND at the FAST model's price.
253
+ const ref = controller.getFastStatus().tier;
254
+ const costDelta = ref.ok && controller.isPricedModel(ref.ref)
255
+ ? computeCost(event.usage, controller.getModelInfoFor(ref.ref).cost)
256
+ : 0;
257
+ dispatch({ type: 'fastUsage', usage: event.usage, costDelta });
258
+ break;
259
+ }
260
+ case 'tier_changed':
261
+ dispatch({ type: 'fastTier', snapshot: event.snapshot });
262
+ break;
263
+ }
264
+ });
265
+ }
266
+ /**
267
+ * Context occupancy: THE SOLE DISPATCHER OF `contextUsage`. The gauge used to be written
268
+ * from three reducer branches fed by two upstreams, which is what let a stale snapshot
269
+ * bounce the bar back to the pre-compaction figure one statement after a compaction
270
+ * correctly dropped it. One writer makes that unrepresentable. Seeded on attach so a
271
+ * resumed session shows a real occupancy on frame 1.
272
+ */
273
+ export function attachContextUsageChannel(controller, dispatch) {
274
+ dispatch({ type: 'contextUsage', snapshot: controller.getContextUsage() });
275
+ return controller.subscribeContextUsage((snapshot) => {
276
+ dispatch({ type: 'contextUsage', snapshot });
277
+ });
278
+ }
279
+ /**
280
+ * Compaction event stream: THE SOLE DISPATCHER OF THE FIVE COMPACTION ACTIONS. One
281
+ * compaction arriving through two channels is two transcript cards and a doubled
282
+ * `tokensReclaimed`. Priced at the SUMMARIZER's model, which may be neither the lead's nor
283
+ * the fast tier's, so the ref is asked for rather than assumed.
284
+ */
285
+ export function attachCompactionChannel(controller, dispatch, hooks = {}) {
286
+ // Seed the chip and the gauge marks so a compaction-enabled session shows them on the
287
+ // FIRST frame rather than after the first turn.
288
+ if (controller.isCompactionRegistered()) {
289
+ dispatch({ type: 'compactionSnapshot', snapshot: controller.getCompactionSnapshot() });
290
+ }
291
+ return controller.subscribeCompaction((event) => {
292
+ switch (event.type) {
293
+ case 'compaction_start':
294
+ hooks.onStart?.();
295
+ dispatch({
296
+ type: 'compactionStart',
297
+ index: event.index,
298
+ trigger: event.trigger,
299
+ model: event.model,
300
+ });
301
+ break;
302
+ case 'compaction_end':
303
+ hooks.onEnd?.();
304
+ // THE CARD, AND NOTHING ELSE: the gauge has one writer, `ContextMeter`.
305
+ dispatch({ type: 'compactionEnd', record: event.record });
306
+ break;
307
+ case 'phase':
308
+ // Dispatch is unconditional; the reducer ignores a phase for an already-settled card.
309
+ dispatch({ type: 'compactionPhase', index: event.index, phase: event.phase });
310
+ break;
311
+ case 'usage': {
312
+ const snapshot = controller.getCompactionSnapshot();
313
+ const ref = event.modelRef ?? controller.getCompactionSummarizerRef();
314
+ const costDelta = (event.pricingUnknown ?? snapshot.pricingUnknown)
315
+ ? 0
316
+ : event.costUsd ?? (ref
317
+ ? computeCost(event.usage, controller.getModelInfoFor(ref).cost) : 0);
318
+ dispatch({ type: 'compactionUsage', usage: event.usage, costDelta });
319
+ break;
320
+ }
321
+ case 'snapshot':
322
+ // The occupancy riding on `snapshot.pressure` is deliberately NOT dispatched here:
323
+ // the meter publishes it on its own channel, and a second dispatch of the same
324
+ // number is the second writer this design removed.
325
+ dispatch({ type: 'compactionSnapshot', snapshot: event.snapshot });
326
+ break;
327
+ }
328
+ });
329
+ }
330
+ /**
331
+ * Live tool output: a STREAM at pipe speed, so it goes THROUGH THE COALESCER (it pushes and
332
+ * arms the timer itself - there is no "buffered path for every other action" to fall into).
333
+ * `Date.now()` is read here, in the listener, which is what keeps `viewReducer` pure.
334
+ */
335
+ export function attachToolOutputChannel(controller, coalescer) {
336
+ return controller.subscribeToolOutput(({ toolCallId, rows }) => {
337
+ coalescer.push({ type: 'toolOutputDelta', toolCallId, rows, at: Date.now() });
338
+ });
339
+ }
340
+ /**
341
+ * The long wait's live view. Through the coalescer, like the tool tail: two updates landing
342
+ * in one frame should commit once. `begin` and `update` are the same action; `end` needs
343
+ * none (`toolExecEnd` and every idle path clear the view). OPTIONAL CALL: a duck-typed
344
+ * controller predates this channel and has nothing to subscribe to.
345
+ */
346
+ export function attachWaitChannel(controller, coalescer) {
347
+ return controller.subscribeWait?.((event) => {
348
+ if (event.type === 'end')
349
+ return;
350
+ coalescer.push({ type: 'waitUpdate', toolCallId: event.toolCallId, view: event.view });
351
+ });
352
+ }
353
+ /** The CLI-local diff side channel: `reduceEvent` TAKES a patch, the store is consume-once. */
354
+ export function makePatchSource(controller) {
355
+ return { take: (id) => controller.takeFilePatch(id) };
356
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * "Build the project index" for a host without a keyboard: the desktop equivalent of Ctrl+I.
3
+ *
4
+ * Same words, same skill, same lifecycle as the terminal: the message is the bundled
5
+ * `project-indexer` skill run through `prepareSkillInvocation`, and the sentence handed to it is
6
+ * the one `indexBuildInvocationArgs` writes (which the invocation card recognises as machine
7
+ * text, not as something the user typed). The terminal asks for confirmation in an overlay; the
8
+ * desktop asks in its own dialog BEFORE sending this, so it is not repeated here.
9
+ *
10
+ * Refuses rather than queues when the agent is busy: a queued skill body would arrive as
11
+ * steering in the middle of a run, which is not what "build the index" means.
12
+ */
13
+ import type { AgentController } from '../agent/controller.js';
14
+ import type { InteractionCoordinator } from './interaction.js';
15
+ export type IndexBuildOutcome = {
16
+ ok: true;
17
+ rebuild: boolean;
18
+ } | {
19
+ ok: false;
20
+ code: 'busy' | 'skills_disabled' | 'skill_unavailable' | 'rejected';
21
+ message: string;
22
+ };
23
+ export declare function startIndexBuild(controller: AgentController, interaction: InteractionCoordinator): IndexBuildOutcome;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * "Build the project index" for a host without a keyboard: the desktop equivalent of Ctrl+I.
3
+ *
4
+ * Same words, same skill, same lifecycle as the terminal: the message is the bundled
5
+ * `project-indexer` skill run through `prepareSkillInvocation`, and the sentence handed to it is
6
+ * the one `indexBuildInvocationArgs` writes (which the invocation card recognises as machine
7
+ * text, not as something the user typed). The terminal asks for confirmation in an overlay; the
8
+ * desktop asks in its own dialog BEFORE sending this, so it is not repeated here.
9
+ *
10
+ * Refuses rather than queues when the agent is busy: a queued skill body would arrive as
11
+ * steering in the middle of a run, which is not what "build the index" means.
12
+ */
13
+ import { hasProjectIndex, indexBuildInvocationArgs, INDEX_SKILL_NAME } from '../commands/index-build.js';
14
+ import { prepareSkillInvocation } from '../skills/invoke.js';
15
+ export function startIndexBuild(controller, interaction) {
16
+ if (controller.isRunning() || interaction.phase !== 'idle') {
17
+ return { ok: false, code: 'busy', message: 'The agent is busy. Let it finish before building the index.' };
18
+ }
19
+ if (!controller.getConfig().skills.enabled) {
20
+ return { ok: false, code: 'skills_disabled', message: 'Skills are disabled; the project index needs the bundled skill.' };
21
+ }
22
+ const service = controller.getSkillService();
23
+ const record = service.get(INDEX_SKILL_NAME);
24
+ if (!record || record.disabled || record.invalid) {
25
+ return { ok: false, code: 'skill_unavailable', message: `Skill "${INDEX_SKILL_NAME}" is not available.` };
26
+ }
27
+ const rebuild = hasProjectIndex(controller.getCwd());
28
+ const prepared = prepareSkillInvocation(record, indexBuildInvocationArgs(rebuild), service, () => controller.listTools().map((tool) => tool.name));
29
+ if (!prepared.ok)
30
+ return { ok: false, code: 'rejected', message: prepared.error };
31
+ const outcome = interaction.submit(prepared.message, { invocation: prepared.card });
32
+ return outcome.accepted
33
+ ? { ok: true, rebuild }
34
+ : { ok: false, code: 'rejected', message: outcome.reason ?? 'The request was not accepted.' };
35
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The ONLY surface a GUI host (the Electron desktop app) may depend on.
3
+ *
4
+ * Every module re-exported here is in the import closure that the layering gate (L9) keeps
5
+ * free of `ink`, `react` and `@aragon-agent/tui/ui/**`: a host process has no TTY, and Ink
6
+ * caches its CI detection on first import. Add an export here only if its own imports pass
7
+ * `npm run verify:layering`.
8
+ *
9
+ * Consumers import the individual modules (`@aragon-agent/cli/dist/host/settings.js`, with the
10
+ * extension - cli has no `exports` map) so the main process loads only what it needs.
11
+ */
12
+ export * from './controller-factory.js';
13
+ export * from './controller-feed.js';
14
+ export * from './interaction.js';
15
+ export * from './logging.js';
16
+ export * from './prompts.js';
17
+ export * from './sessions.js';
18
+ export * from './settings.js';
19
+ export * from './commands.js';
20
+ export * from './skills.js';
21
+ export * from './index-build.js';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The ONLY surface a GUI host (the Electron desktop app) may depend on.
3
+ *
4
+ * Every module re-exported here is in the import closure that the layering gate (L9) keeps
5
+ * free of `ink`, `react` and `@aragon-agent/tui/ui/**`: a host process has no TTY, and Ink
6
+ * caches its CI detection on first import. Add an export here only if its own imports pass
7
+ * `npm run verify:layering`.
8
+ *
9
+ * Consumers import the individual modules (`@aragon-agent/cli/dist/host/settings.js`, with the
10
+ * extension - cli has no `exports` map) so the main process loads only what it needs.
11
+ */
12
+ export * from './controller-factory.js';
13
+ export * from './controller-feed.js';
14
+ export * from './interaction.js';
15
+ export * from './logging.js';
16
+ export * from './prompts.js';
17
+ export * from './sessions.js';
18
+ export * from './settings.js';
19
+ export * from './commands.js';
20
+ export * from './skills.js';
21
+ export * from './index-build.js';
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Submit / interrupt state machine for a host that has no Ink `App`.
3
+ *
4
+ * THE DECISION TABLE IS `App.tsx::submitMessage` AND THE ESC HANDLER, restated without React
5
+ * refs. It is a RESTATEMENT, not an extraction: those two functions are woven through the
6
+ * TUI's refs (follow-through timers, nudge budget, run metrics), so moving them would have
7
+ * meant rewriting the TUI's own submit path. `interaction.test.ts` pins the branches this
8
+ * class shares with it (restart guard, starting guard, queue-while-running, preflight
9
+ * failure, `not-started` outcome, double-Esc ladder) so the two cannot drift silently.
10
+ *
11
+ * NOT HERE, ON PURPOSE: the todo follow-through and the forced-dispatch nudge. Both are
12
+ * TUI-initiated continuations; a desktop host that wants them calls `submit(...,
13
+ * { userInitiated: false })` itself after `onAgentEnd`.
14
+ *
15
+ * NO INK, NO TTY (layering gate L9).
16
+ */
17
+ import type { AgentController } from '../agent/controller.js';
18
+ import type { SubmitMessageOptions } from '../agent/prompt-options.js';
19
+ import type { FeedDispatch } from './controller-feed.js';
20
+ export type InteractionPhase = 'idle' | 'starting' | 'running';
21
+ export interface SubmitOutcome {
22
+ accepted: boolean;
23
+ /** Present when `accepted` is false; a sentence the UI may show verbatim. */
24
+ reason?: string;
25
+ }
26
+ export interface InteractionPorts {
27
+ controller: AgentController;
28
+ dispatch: FeedDispatch;
29
+ /** Surface a message the user must see (a notice card or a toast, the host decides). */
30
+ notify(level: 'info' | 'warn' | 'error', text: string): void;
31
+ }
32
+ export declare class InteractionCoordinator {
33
+ private readonly ports;
34
+ private phaseValue;
35
+ private sequence;
36
+ private gesture;
37
+ private disposed;
38
+ constructor(ports: InteractionPorts);
39
+ get phase(): InteractionPhase;
40
+ /** Feed `agent_start` / `agent_end` here so `phase` follows the engine. */
41
+ onAgentStart(): void;
42
+ /**
43
+ * `agent_end`: the run is over, so a deferred `plan -> build` (or any posture change that
44
+ * waited for a governed stage) becomes real here and nowhere else.
45
+ */
46
+ onAgentEnd(): void;
47
+ /** Send a message to the agent, bypassing slash parsing. */
48
+ submit(message: string, opts?: SubmitMessageOptions): SubmitOutcome;
49
+ /**
50
+ * One Esc / Stop press. First press arms and returns `hint`; a second inside the window
51
+ * aborts; a third (or any press while stopping) force-stops. A press while still
52
+ * `starting` cancels the pending run outright, because there is nothing to unwind.
53
+ */
54
+ interrupt(now?: number): 'hint' | 'abort' | 'force-stop';
55
+ /** Any other input disarms a pending first Esc but cannot undo a requested stop. */
56
+ cancelInterruptConfirmation(): void;
57
+ dispose(): void;
58
+ }