@aragon-agent/cli 0.6.66 → 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.
Files changed (36) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +25 -3
  3. package/dist/agent/controller.d.ts +22 -0
  4. package/dist/agent/controller.js +34 -0
  5. package/dist/agent/governance-wiring.js +2 -0
  6. package/dist/app/App.js +31 -2
  7. package/dist/app/use-governance-rounds.d.ts +44 -0
  8. package/dist/app/use-governance-rounds.js +71 -0
  9. package/dist/commands/governance-command.js +45 -3
  10. package/dist/config/cli-commands.d.ts +1 -1
  11. package/dist/config/cli-commands.js +26 -0
  12. package/dist/gene/hub.d.ts +10 -1
  13. package/dist/gene/hub.js +25 -7
  14. package/dist/governance/copy.d.ts +8 -0
  15. package/dist/governance/copy.js +16 -1
  16. package/dist/governance/engine/cards.js +9 -1
  17. package/dist/governance/engine/digest.js +6 -2
  18. package/dist/governance/engine/engine-core.d.ts +12 -0
  19. package/dist/governance/engine/engine-core.js +29 -0
  20. package/dist/governance/engine/engine.d.ts +1 -0
  21. package/dist/governance/engine/engine.js +4 -1
  22. package/dist/governance/engine/lifecycle.d.ts +36 -1
  23. package/dist/governance/engine/lifecycle.js +185 -2
  24. package/dist/governance/engine/report.d.ts +8 -0
  25. package/dist/governance/engine/report.js +17 -0
  26. package/dist/governance/engine/stage-runner.js +48 -3
  27. package/dist/governance/engine/state-machine.d.ts +27 -2
  28. package/dist/governance/engine/state-machine.js +146 -20
  29. package/dist/governance/prompts/orchestrator-block.d.ts +2 -0
  30. package/dist/governance/prompts/orchestrator-block.js +25 -0
  31. package/dist/governance/store/events-log.d.ts +4 -2
  32. package/dist/governance/store/events-log.js +4 -2
  33. package/dist/governance/tools/inspector-tools.js +4 -0
  34. package/dist/governance/tools/lead-tools.d.ts +1 -1
  35. package/dist/governance/tools/lead-tools.js +14 -2
  36. package/package.json +3 -3
@@ -15,11 +15,17 @@
15
15
  * The current phase is the FIRST phase with `integrated === false`; stages only ever act
16
16
  * on it. `dropped` and `integrated` WPs never block anything.
17
17
  */
18
- import { type Escalation, type PhaseState, type ResolveDisposition, type RunState, type StageKind, type WorkPackage } from '@aragon-agent/tui/model/governance/types';
18
+ import { type Escalation, type PhaseState, type ResolveDisposition, type RoundBudget, type RunState, type StageKind, type WorkPackage } from '@aragon-agent/tui/model/governance/types';
19
19
  export declare const NOT_ACCEPTED = "NOT ACCEPTED:";
20
20
  export interface StageCheckOptions {
21
21
  /** `min(team.maxSubagents, hardMaxSubagents)`; defaults to the structural maximum. */
22
22
  teamCeiling?: number;
23
+ /**
24
+ * The run's effective round limit (`roundsLimit()`), read from the LIVE config by the
25
+ * caller. ABSENT = no round gate at all, which is what keeps every pre-existing caller
26
+ * and test of `checkStage` byte-identical (governance-round-budget D-4).
27
+ */
28
+ roundsLimit?: number;
23
29
  }
24
30
  export type StageCheck = {
25
31
  ok: true;
@@ -28,6 +34,7 @@ export type StageCheck = {
28
34
  } | {
29
35
  ok: false;
30
36
  message: string;
37
+ code?: 'rounds_exhausted';
31
38
  };
32
39
  /** Index of the first phase that is not integrated, or null when all are. */
33
40
  export declare function currentPhaseIndex(run: RunState): number | null;
@@ -54,11 +61,26 @@ export declare function stageChunkSize(stage: StageKind, ceiling: number): numbe
54
61
  export declare function dispatchCall(stage: StageKind, wps?: readonly string[]): string;
55
62
  /** Render actions as the trailing `NEXT:` block every `gov_*` result ends with (D-16). */
56
63
  export declare function formatNext(actions: readonly string[]): string;
64
+ /**
65
+ * Which dispositions a kind accepts. A FUNCTION, not a table, because `rounds_exhausted`
66
+ * carries two shapes: with a `wpId` it is a rework question, without one it is an
67
+ * integration question. The three older kinds return exactly what the old table returned.
68
+ */
69
+ export declare function dispositionsFor(escalation: Pick<Escalation, 'kind' | 'wpId'>): readonly ResolveDisposition[];
57
70
  /**
58
71
  * Ordered legal next calls for the run's current state. Pure. Stage width beyond
59
72
  * `teamCeiling` is split into chunk calls (D-24), each independently legal.
60
73
  */
61
74
  export declare function nextActions(run: RunState, options?: StageCheckOptions): string[];
75
+ /**
76
+ * THE round-budget decision, and the ONLY one (governance-round-budget RV-P1-1).
77
+ *
78
+ * `checkStage` and `stageCalls` both call it, because `stageCalls` builds `NEXT` straight
79
+ * from `evaluateStage` and never passes through `checkStage`: gating only the former would
80
+ * print a `gov_dispatch` in `NEXT` that the very next call refuses, which teaches the
81
+ * orchestrator that `NEXT` lies. Returns the refusal sentence, or null to let the stage run.
82
+ */
83
+ export declare function roundsGate(run: RunState, stage: StageKind, wpIds: readonly string[], options?: StageCheckOptions): string | null;
62
84
  /**
63
85
  * The single legality gate for `gov_dispatch` (I-G6). `wps` omitted means "every eligible
64
86
  * WP of the current phase". On success `wpIds` is the validated list the stage will run.
@@ -97,5 +119,8 @@ export type ResolveApplyResult = {
97
119
  * Apply the user's `disposition` for an escalation (spec 7.2 table). Mismatched or
98
120
  * over-cap dispositions are refused with a reason; no disposition changes nothing.
99
121
  * Mutates `run`; does NOT mark the escalation resolved (`closeEscalation` does).
122
+ *
123
+ * `budget` is the LIVE `governance.rounds` value (`core.config().rounds`): a round grant
124
+ * must judge against the number in force right now, not against one frozen at run start.
100
125
  */
101
- export declare function applyResolveDisposition(run: RunState, escalation: Escalation, disposition?: ResolveDisposition): ResolveApplyResult;
126
+ export declare function applyResolveDisposition(run: RunState, escalation: Escalation, disposition?: ResolveDisposition, budget?: RoundBudget): ResolveApplyResult;
@@ -17,6 +17,7 @@
17
17
  */
18
18
  import { TEAM_LIMITS } from '@aragon-agent/tui/model/team/limits';
19
19
  import { GOV_LIMITS } from '@aragon-agent/tui/model/governance/limits';
20
+ import { ensureRunRounds, grantRound, roundGrantRefusal, wouldStartRound, } from '@aragon-agent/tui/model/governance/rounds';
20
21
  import { STAGE_KINDS, } from '@aragon-agent/tui/model/governance/types';
21
22
  export const NOT_ACCEPTED = 'NOT ACCEPTED:';
22
23
  // ---------------------------------------------------------------------------
@@ -250,15 +251,27 @@ export function formatNext(actions) {
250
251
  return 'NEXT: (none)';
251
252
  return `NEXT:\n${actions.map((action) => `- ${action}`).join('\n')}`;
252
253
  }
253
- const DISPOSITIONS_BY_KIND = {
254
- wp_rework_cap: ['retry', 'accept_as_is', 'drop'],
255
- integration_exhausted: ['retry', 'accept_failing'],
256
- dispute: [],
257
- };
254
+ /**
255
+ * Which dispositions a kind accepts. A FUNCTION, not a table, because `rounds_exhausted`
256
+ * carries two shapes: with a `wpId` it is a rework question, without one it is an
257
+ * integration question. The three older kinds return exactly what the old table returned.
258
+ */
259
+ export function dispositionsFor(escalation) {
260
+ switch (escalation.kind) {
261
+ case 'wp_rework_cap':
262
+ return ['retry', 'accept_as_is', 'drop'];
263
+ case 'integration_exhausted':
264
+ return ['retry', 'accept_failing'];
265
+ case 'rounds_exhausted':
266
+ return escalation.wpId ? ['retry', 'accept_as_is', 'drop'] : ['retry', 'accept_failing'];
267
+ case 'dispute':
268
+ return [];
269
+ }
270
+ }
258
271
  function escalationActions(escalations) {
259
272
  const actions = [];
260
273
  for (const esc of escalations.filter((e) => e.status === 'open')) {
261
- const allowed = DISPOSITIONS_BY_KIND[esc.kind];
274
+ const allowed = dispositionsFor(esc);
262
275
  const disposition = allowed.length > 0 ? `,"disposition":"${allowed.join('|')}"` : '';
263
276
  actions.push(`ask_user: put ${esc.id} (${esc.kind}) to the user: ${esc.topic}`);
264
277
  const ruling = '"ruling":"<user ruling>"';
@@ -266,13 +279,17 @@ function escalationActions(escalations) {
266
279
  }
267
280
  return actions;
268
281
  }
269
- function stageCalls(run, stage, ceiling) {
282
+ function stageCalls(run, stage, options) {
270
283
  const evaluation = evaluateStage(run, stage, undefined);
271
284
  if (!evaluation.ok)
272
285
  return [];
286
+ // The SAME gate `checkStage` applies, so `NEXT` never lists a dispatch that would be
287
+ // refused for the round budget (RV-P1-1).
288
+ if (roundsGate(run, stage, evaluation.wpIds, options) !== null)
289
+ return [];
273
290
  if (stage === 'settle' || stage === 'integrate' || stage === 'fix')
274
291
  return [dispatchCall(stage)];
275
- const groups = chunk(evaluation.wpIds, stageChunkSize(stage, ceiling));
292
+ const groups = chunk(evaluation.wpIds, stageChunkSize(stage, ceilingOf(options)));
276
293
  return groups.map((ids) => dispatchCall(stage, ids));
277
294
  }
278
295
  function dropHints(run) {
@@ -288,10 +305,10 @@ function dropHints(run) {
288
305
  'gov_run {"action":"abandon","reason":"..."} and restart with a revised plan',
289
306
  ];
290
307
  }
291
- function executingActions(run, ceiling) {
308
+ function executingActions(run, options) {
292
309
  if (canClose(run))
293
310
  return ['gov_run {"action":"close","summary":"<what was delivered>"}'];
294
- const calls = STAGE_KINDS.flatMap((stage) => stageCalls(run, stage, ceiling));
311
+ const calls = STAGE_KINDS.flatMap((stage) => stageCalls(run, stage, options));
295
312
  const phase = currentPhase(run);
296
313
  if (calls.length === 0 && phase && isIntegrationExhausted(run, phase)) {
297
314
  return [
@@ -300,16 +317,31 @@ function executingActions(run, ceiling) {
300
317
  ];
301
318
  }
302
319
  const hints = dropHints(run);
303
- if (calls.length === 0 && hints.length === 0)
320
+ if (calls.length === 0 && hints.length === 0) {
321
+ // No legal call is left. Say WHICH cap closed the door: with the round budget spent the
322
+ // next loop-back escalates instead of running, and (in auto mode) the orchestrator may
323
+ // ask for one more round with a reason - which is the one thing a `gov_run status` here
324
+ // must not hide.
325
+ const rounds = roundsHint(run, options);
326
+ if (rounds !== null)
327
+ return [rounds];
304
328
  return ['gov_run {"action":"status"}'];
329
+ }
305
330
  return [...calls, ...hints];
306
331
  }
332
+ /** The "the round budget is spent" hint, or null when that is not what is blocking. */
333
+ function roundsHint(run, options) {
334
+ const spent = roundsSpent(run, options);
335
+ if (spent === null)
336
+ return null;
337
+ return ('the round budget is spent; the next loop-back round escalates ' +
338
+ '(auto mode: gov_run {"action":"rounds","reason":"..."})');
339
+ }
307
340
  /**
308
341
  * Ordered legal next calls for the run's current state. Pure. Stage width beyond
309
342
  * `teamCeiling` is split into chunk calls (D-24), each independently legal.
310
343
  */
311
344
  export function nextActions(run, options) {
312
- const ceiling = ceilingOf(options);
313
345
  switch (run.status) {
314
346
  case 'closed':
315
347
  case 'abandoned':
@@ -321,16 +353,50 @@ export function nextActions(run, options) {
321
353
  case 'executing':
322
354
  return run.stage?.status === 'running'
323
355
  ? ['a stage is running; wait for it to finish, then gov_run {"action":"status"}']
324
- : executingActions(run, ceiling);
356
+ : executingActions(run, options);
325
357
  }
326
358
  }
327
359
  // ---------------------------------------------------------------------------
328
360
  // checkStage
329
361
  // ---------------------------------------------------------------------------
330
- function refuse(run, reason, options, head) {
362
+ /**
363
+ * THE round-budget decision, and the ONLY one (governance-round-budget RV-P1-1).
364
+ *
365
+ * `checkStage` and `stageCalls` both call it, because `stageCalls` builds `NEXT` straight
366
+ * from `evaluateStage` and never passes through `checkStage`: gating only the former would
367
+ * print a `gov_dispatch` in `NEXT` that the very next call refuses, which teaches the
368
+ * orchestrator that `NEXT` lies. Returns the refusal sentence, or null to let the stage run.
369
+ */
370
+ export function roundsGate(run, stage, wpIds, options) {
371
+ if (!wouldStartRound(run, stage, wpIds))
372
+ return null;
373
+ const spent = roundsSpent(run, options);
374
+ if (spent === null)
375
+ return null;
376
+ return (`the round budget is spent (${spent.used}/${spent.limit}): ` +
377
+ 'this stage would start a loop-back round.');
378
+ }
379
+ /**
380
+ * `used` and `limit` when the budget is SPENT, else null - and the ONE place that comparison
381
+ * is made. `roundsGate` asks it before refusing a stage and `roundsHint` asks it before
382
+ * choosing the `NEXT` line, so the two can never disagree about whether the cap has been hit
383
+ * (the reason `roundsLimit` shows up twice in this file is that both callers pass it in).
384
+ */
385
+ function roundsSpent(run, options) {
386
+ const limit = options?.roundsLimit;
387
+ if (limit === undefined)
388
+ return null;
389
+ const rounds = ensureRunRounds(run);
390
+ return rounds.used < limit ? null : { used: rounds.used, limit };
391
+ }
392
+ function refuse(run, reason, options, head, code) {
331
393
  const first = head ?? reason;
332
394
  const next = formatNext(nextActions(run, options));
333
- return { ok: false, message: `${NOT_ACCEPTED} ${first}\n${next}` };
395
+ return {
396
+ ok: false,
397
+ message: `${NOT_ACCEPTED} ${first}\n${next}`,
398
+ ...(code === undefined ? {} : { code }),
399
+ };
334
400
  }
335
401
  function runLevelRefusal(run) {
336
402
  switch (run.status) {
@@ -379,6 +445,11 @@ export function checkStage(run, stage, wps, options) {
379
445
  `dispatch at most ${size} WPs per call.\n${formatNext(calls)}`,
380
446
  };
381
447
  }
448
+ // LAST, after legality and width: a stage that is illegal or too wide is refused for that
449
+ // reason first, and only a stage that COULD run is charged against the round budget.
450
+ const spent = roundsGate(run, stage, evaluation.wpIds, options);
451
+ if (spent !== null)
452
+ return refuse(run, spent, options, undefined, 'rounds_exhausted');
382
453
  return { ok: true, phase: evaluation.phase.index, wpIds: evaluation.wpIds };
383
454
  }
384
455
  /** Stages that are legal right now (ignores `teamCeiling`; chunking is not legality). */
@@ -558,12 +629,62 @@ function applyIntegrationDisposition(run, escalation, disposition) {
558
629
  affectedDependents: [],
559
630
  };
560
631
  }
632
+ /**
633
+ * The `rounds_exhausted` ruling. `retry` grants ONE more round - and it succeeds for a
634
+ * FIXED budget too, because the number on a fixed budget is the USER's, and the user is the
635
+ * one ruling here (RV-P0-1). The rework/fix counters are deliberately untouched: those are
636
+ * the per-WP and per-phase gates, and a round grant must not silently raise them as well.
637
+ */
638
+ function applyRoundsDisposition(run, escalation, disposition, budget) {
639
+ if (disposition === 'accept_as_is') {
640
+ const wp = escalation.wpId ? run.workPackages[escalation.wpId] : undefined;
641
+ return wp
642
+ ? acceptAsIs(wp)
643
+ : resolveFailure(`escalation ${escalation.id} names no work package.`);
644
+ }
645
+ if (disposition === 'drop') {
646
+ const wp = escalation.wpId ? run.workPackages[escalation.wpId] : undefined;
647
+ return wp
648
+ ? dropWorkPackage(run, wp)
649
+ : resolveFailure(`escalation ${escalation.id} names no work package.`);
650
+ }
651
+ if (disposition === 'accept_failing') {
652
+ return applyIntegrationDisposition(run, escalation, 'accept_failing');
653
+ }
654
+ return grantRoundForEscalation(run, escalation, budget);
655
+ }
656
+ function grantRoundForEscalation(run, escalation, budget) {
657
+ const rounds = ensureRunRounds(run);
658
+ const granted = grantRound(rounds, 'user', budget);
659
+ if (!granted.ok)
660
+ return resolveFailure(roundGrantRefusal(granted.reason, rounds, budget));
661
+ run.rounds = granted.rounds;
662
+ if (escalation.wpId)
663
+ unblockRework(run, escalation.wpId);
664
+ const where = escalation.wpId ? ` '${escalation.wpId}' is back in rework.` : '';
665
+ return {
666
+ ok: true,
667
+ message: `one more round granted (limit now ${granted.limit}).${where}`,
668
+ affectedDependents: [],
669
+ };
670
+ }
671
+ /** Put a WP back into `rework` without touching `reworkGrants` (that is `grantRework`'s job). */
672
+ function unblockRework(run, wpId) {
673
+ const wp = run.workPackages[wpId];
674
+ if (wp === undefined)
675
+ return;
676
+ wp.status = 'rework';
677
+ delete wp.blockedAt;
678
+ }
561
679
  /**
562
680
  * Apply the user's `disposition` for an escalation (spec 7.2 table). Mismatched or
563
681
  * over-cap dispositions are refused with a reason; no disposition changes nothing.
564
682
  * Mutates `run`; does NOT mark the escalation resolved (`closeEscalation` does).
683
+ *
684
+ * `budget` is the LIVE `governance.rounds` value (`core.config().rounds`): a round grant
685
+ * must judge against the number in force right now, not against one frozen at run start.
565
686
  */
566
- export function applyResolveDisposition(run, escalation, disposition) {
687
+ export function applyResolveDisposition(run, escalation, disposition, budget = null) {
567
688
  if (escalation.status === 'resolved') {
568
689
  return resolveFailure(`escalation ${escalation.id} is already resolved.`);
569
690
  }
@@ -574,13 +695,18 @@ export function applyResolveDisposition(run, escalation, disposition) {
574
695
  affectedDependents: [],
575
696
  };
576
697
  }
577
- const allowed = DISPOSITIONS_BY_KIND[escalation.kind];
698
+ const allowed = dispositionsFor(escalation);
578
699
  if (!allowed.includes(disposition)) {
579
700
  const list = allowed.length > 0 ? allowed.join(', ') : 'none';
580
701
  return resolveFailure(`disposition '${disposition}' does not apply to a ${escalation.kind} escalation ` +
581
702
  `(allowed: ${list}).`);
582
703
  }
583
- return escalation.kind === 'wp_rework_cap'
584
- ? applyReworkDisposition(run, escalation, disposition)
585
- : applyIntegrationDisposition(run, escalation, disposition);
704
+ switch (escalation.kind) {
705
+ case 'wp_rework_cap':
706
+ return applyReworkDisposition(run, escalation, disposition);
707
+ case 'rounds_exhausted':
708
+ return applyRoundsDisposition(run, escalation, disposition, budget);
709
+ default:
710
+ return applyIntegrationDisposition(run, escalation, disposition);
711
+ }
586
712
  }
@@ -26,6 +26,8 @@ export interface OrchestratorLimits {
26
26
  maxFixCycles: number;
27
27
  /** Team token budget; 0 or absent means unlimited. */
28
28
  budgetTokens?: number;
29
+ /** Round budget: `null` = auto (the engine derives it and may extend on request). */
30
+ rounds?: number | null;
29
31
  }
30
32
  export interface OrchestratorBlockOptions {
31
33
  posture: Posture;
@@ -48,6 +48,31 @@ function limitsLines(limits) {
48
48
  `reworked ${rework} times and a phase gets ${fixes} integration fix cycles before the engine`,
49
49
  `escalates to the user; at most ${GOV_LIMITS.hardMaxDispatches} gov_dispatch calls per run.`,
50
50
  budgetText,
51
+ ...roundsLines(limits.rounds),
52
+ ];
53
+ }
54
+ /**
55
+ * How the round budget is worded for the model. A clean pass costs nothing - only a rework
56
+ * loop or a fix stage does - so the paragraph names the counting rule, what happens at the
57
+ * cap, and the two ways out. In fixed mode the ONLY way out is the user: the model must not
58
+ * promise itself a round the user did not grant.
59
+ */
60
+ function roundsLines(rounds) {
61
+ const head = 'Round budget: a round is one loop-back dispatch (a dev stage that reworks a work ' +
62
+ 'package, or a fix stage); a clean run costs none.';
63
+ if (rounds === null || rounds === undefined) {
64
+ return [
65
+ `${head} It is AUTO here: the engine derives it from the plan and you may ask for more`,
66
+ 'with gov_run {action:"rounds",reason:"..."} (a real reason, at most ' +
67
+ `${GOV_LIMITS.autoRoundExtensionsPerRun} times per run).`,
68
+ 'When it runs out the engine escalates to the user instead of retrying.',
69
+ ];
70
+ }
71
+ const fixed = clampInt(rounds, 0, GOV_LIMITS.hardMaxRounds);
72
+ return [
73
+ `${head} It is FIXED at ${fixed} by the user: do not ask for more - only the user can`,
74
+ 'raise it (they may rule "retry" on the escalation card, or use /gov rounds <n>).',
75
+ 'When it runs out the engine escalates to the user instead of retrying.',
51
76
  ];
52
77
  }
53
78
  function powersSection() {
@@ -14,8 +14,10 @@
14
14
  * `ruling` and `resolution` rows, each of which changes the replayed ledger or run state,
15
15
  * so a literal reading would make a compacted log replay to a DIFFERENT ledger than its
16
16
  * checkpoint (breaks I-G2). The kept set therefore includes every type that replay folds;
17
- * what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget` and
18
- * `submission` (the submission itself lives in the artifact store).
17
+ * what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget`,
18
+ * `rounds_granted` and `submission` (the submission itself lives in the artifact store).
19
+ * `rounds_granted` is audit by construction: a round is a flow resource, not a ledger
20
+ * claim (governance-round-budget D-10), so replay never folds it.
19
21
  */
20
22
  import type { StoredEvent, StoredEventType } from '@aragon-agent/tui/model/governance/types';
21
23
  /** Types that survive once `events.jsonl` has passed `GOV_LIMITS.eventsFileBytes`. */
@@ -14,8 +14,10 @@
14
14
  * `ruling` and `resolution` rows, each of which changes the replayed ledger or run state,
15
15
  * so a literal reading would make a compacted log replay to a DIFFERENT ledger than its
16
16
  * checkpoint (breaks I-G2). The kept set therefore includes every type that replay folds;
17
- * what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget` and
18
- * `submission` (the submission itself lives in the artifact store).
17
+ * what is dropped are the audit-only rows: `view_*`, `ownership_violation`, `budget`,
18
+ * `rounds_granted` and `submission` (the submission itself lives in the artifact store).
19
+ * `rounds_granted` is audit by construction: a round is a flow resource, not a ledger
20
+ * claim (governance-round-budget D-10), so replay never folds it.
19
21
  */
20
22
  /** Types that survive once `events.jsonl` has passed `GOV_LIMITS.eventsFileBytes`. */
21
23
  export const EVENTS_KEPT_AFTER_CAP = new Set([
@@ -39,6 +39,10 @@ const MISS_KINDS = ['review_integration', 'test_defect', 'test_boundary'];
39
39
  const ESCALATION_KINDS = [
40
40
  'wp_rework_cap',
41
41
  'integration_exhausted',
42
+ // A handwritten list, so adding a kind to the union does NOT fail to compile - it only
43
+ // makes the inspector refuse a `rounds_exhausted` escalation SILENTLY, which is the
44
+ // worst kind of omission (governance-round-budget RV-P1-3).
45
+ 'rounds_exhausted',
42
46
  'dispute',
43
47
  ];
44
48
  function argsOf(raw, issues, expected) {
@@ -19,7 +19,7 @@
19
19
  import { type AgentTool } from '@aragon-agent/core';
20
20
  import type { GovernanceEngineApi } from '@aragon-agent/tui/model/governance/types';
21
21
  /** The `gov_run` actions, in the order the description lists them. */
22
- export declare const GOV_RUN_ACTIONS: readonly ["start", "status", "resume", "close", "abandon", "resolve"];
22
+ export declare const GOV_RUN_ACTIONS: readonly ["start", "status", "resume", "close", "abandon", "resolve", "rounds"];
23
23
  export type GovRunAction = (typeof GOV_RUN_ACTIONS)[number];
24
24
  /** Text returned when the tool call's signal was already aborted at entry. */
25
25
  export declare const DISPATCH_ABORTED_AT_ENTRY: string;
@@ -26,6 +26,7 @@ export const GOV_RUN_ACTIONS = [
26
26
  'close',
27
27
  'abandon',
28
28
  'resolve',
29
+ 'rounds',
29
30
  ];
30
31
  const GOV_RUN_DESCRIPTION = 'Define and manage the governed run. action: ' +
31
32
  '"start" (needs goal, spec, workPackages; optional contracts, integrationCommands, ' +
@@ -34,7 +35,10 @@ const GOV_RUN_DESCRIPTION = 'Define and manage the governed run. action: ' +
34
35
  '(optional summary) finishes a fully integrated run; "abandon" (needs reason) gives up the ' +
35
36
  'whole run; "resolve" (needs escalationId and ruling, optional favor and disposition) ' +
36
37
  'records the user\'s decision on an ESCALATION and can dispose of the escalated object ' +
37
- '(disposition: retry, accept_as_is, drop or accept_failing, matching the escalation kind). ' +
38
+ '(disposition: retry, accept_as_is, drop or accept_failing, matching the escalation kind); ' +
39
+ '"rounds" prints the round budget (used / limit / grants left), or with a reason of at ' +
40
+ `least ${GOV_LIMITS.roundsReasonMinChars} chars asks for ONE more round - the engine decides ` +
41
+ 'whether that is allowed (auto mode only: a budget the user fixed is theirs to raise). ' +
38
42
  `Sizes: goal <= ${GOV_LIMITS.goalChars} chars, spec <= ${GOV_LIMITS.specChars} chars; ` +
39
43
  `each work package: id <= ${GOV_LIMITS.wpIdChars} chars, title <= ${GOV_LIMITS.wpTitleChars}, ` +
40
44
  `goal <= ${GOV_LIMITS.wpGoalChars}, <= ${GOV_LIMITS.wpFilesMax} files (include its test ` +
@@ -128,6 +132,11 @@ async function runAction(engine, action, params, signal) {
128
132
  }
129
133
  case 'resolve':
130
134
  return textResult(await engine.resolve(payload));
135
+ case 'rounds':
136
+ // Read-only without a `reason`; with one, the orchestrator asks for one more round.
137
+ // `reason` is reused (no new field) and NOT length-constrained by the schema: the
138
+ // engine enforces `roundsReasonMinChars`, which is where policy belongs.
139
+ return textResult(await engine.rounds(payload));
131
140
  }
132
141
  }
133
142
  /**
@@ -157,7 +166,10 @@ export function makeGovRunTool(engine) {
157
166
  },
158
167
  runId: { type: 'string', description: 'resume: a specific run id.' },
159
168
  summary: { type: 'string', description: 'close: closing note.' },
160
- reason: { type: 'string', description: 'abandon: why.' },
169
+ reason: {
170
+ type: 'string',
171
+ description: 'abandon: why. rounds: why one more round is needed.',
172
+ },
161
173
  escalationId: { type: 'string', description: 'resolve: the ESC id.' },
162
174
  ruling: { type: 'string', description: 'resolve: the user\'s ruling.' },
163
175
  favor: { type: 'string', description: 'resolve: whom the ruling favors.' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aragon-agent/cli",
3
- "version": "0.6.66",
3
+ "version": "0.6.68",
4
4
  "description": "AragonAgent CLI — a Claude-Code / Codex-style interactive terminal UI (TUI) on top of the @aragon-agent/core engine. Installable and runnable via npm / npx.",
5
5
  "license": "MIT",
6
6
  "author": "AragonAgent contributors",
@@ -58,8 +58,8 @@
58
58
  "prepublishOnly": "npm run build"
59
59
  },
60
60
  "dependencies": {
61
- "@aragon-agent/core": "^0.2.78",
62
- "@aragon-agent/tui": "0.0.19",
61
+ "@aragon-agent/core": "^0.2.80",
62
+ "@aragon-agent/tui": "0.0.21",
63
63
  "commander": "^12.1.0",
64
64
  "dotenv": "^16.6.1",
65
65
  "env-paths": "^3.0.0",