@aragon-agent/cli 0.6.44 → 0.6.46

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 (255) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +120 -2
  3. package/dist/agent/controller.d.ts +69 -0
  4. package/dist/agent/controller.js +224 -11
  5. package/dist/agent/governance-view.d.ts +40 -0
  6. package/dist/agent/governance-view.js +40 -0
  7. package/dist/agent/governance-wiring.d.ts +162 -0
  8. package/dist/agent/governance-wiring.js +470 -0
  9. package/dist/agent/invocation-card.d.ts +77 -0
  10. package/dist/agent/invocation-card.js +169 -0
  11. package/dist/agent/plan-prompt.d.ts +7 -0
  12. package/dist/agent/plan-prompt.js +2 -1
  13. package/dist/agent/prompt-options.d.ts +6 -0
  14. package/dist/agent/queued-messages.d.ts +3 -0
  15. package/dist/agent/queued-messages.js +4 -1
  16. package/dist/agent/reducer.d.ts +38 -1
  17. package/dist/agent/reducer.js +57 -12
  18. package/dist/agent/system-prompt.d.ts +19 -0
  19. package/dist/agent/system-prompt.js +9 -1
  20. package/dist/cli.js +45 -1
  21. package/dist/commands/builtins.js +22 -4
  22. package/dist/commands/governance-command.d.ts +35 -0
  23. package/dist/commands/governance-command.js +304 -0
  24. package/dist/commands/governance-runs-table.d.ts +40 -0
  25. package/dist/commands/governance-runs-table.js +130 -0
  26. package/dist/commands/index-build.d.ts +8 -0
  27. package/dist/commands/index-build.js +11 -0
  28. package/dist/commands/registry.d.ts +35 -0
  29. package/dist/commands/registry.js +20 -7
  30. package/dist/commands/skills.js +36 -2
  31. package/dist/commands/subagent-command.js +3 -1
  32. package/dist/commands/team-command.d.ts +6 -0
  33. package/dist/commands/team-command.js +40 -3
  34. package/dist/config/app-paths.d.ts +10 -0
  35. package/dist/config/app-paths.js +12 -0
  36. package/dist/config/cli-commands.d.ts +18 -0
  37. package/dist/config/cli-commands.js +47 -1
  38. package/dist/config/env.d.ts +2 -1
  39. package/dist/config/env.js +10 -1
  40. package/dist/config/governance-config.d.ts +125 -0
  41. package/dist/config/governance-config.js +164 -0
  42. package/dist/config/governance-launch.d.ts +71 -0
  43. package/dist/config/governance-launch.js +58 -0
  44. package/dist/config/load.d.ts +15 -0
  45. package/dist/config/load.js +26 -1
  46. package/dist/config/model-profile-store.d.ts +4 -2
  47. package/dist/config/schema.d.ts +22 -0
  48. package/dist/config/schema.js +6 -0
  49. package/dist/config/store.js +14 -1
  50. package/dist/config/ui-state.d.ts +11 -0
  51. package/dist/config/ui-state.js +11 -0
  52. package/dist/diagnostics/doctor.js +20 -0
  53. package/dist/governance/card-normalize.d.ts +24 -0
  54. package/dist/governance/card-normalize.js +76 -0
  55. package/dist/governance/copy.d.ts +109 -0
  56. package/dist/governance/copy.js +223 -0
  57. package/dist/governance/engine/aftermath.d.ts +49 -0
  58. package/dist/governance/engine/aftermath.js +134 -0
  59. package/dist/governance/engine/artifact-persist.d.ts +35 -0
  60. package/dist/governance/engine/artifact-persist.js +86 -0
  61. package/dist/governance/engine/budget.d.ts +52 -0
  62. package/dist/governance/engine/budget.js +112 -0
  63. package/dist/governance/engine/cards.d.ts +18 -0
  64. package/dist/governance/engine/cards.js +186 -0
  65. package/dist/governance/engine/digest.d.ts +32 -0
  66. package/dist/governance/engine/digest.js +63 -0
  67. package/dist/governance/engine/engine-core.d.ts +219 -0
  68. package/dist/governance/engine/engine-core.js +562 -0
  69. package/dist/governance/engine/engine.d.ts +68 -0
  70. package/dist/governance/engine/engine.js +314 -0
  71. package/dist/governance/engine/estimate.d.ts +38 -0
  72. package/dist/governance/engine/estimate.js +46 -0
  73. package/dist/governance/engine/inspector.d.ts +16 -0
  74. package/dist/governance/engine/inspector.js +396 -0
  75. package/dist/governance/engine/integration.d.ts +35 -0
  76. package/dist/governance/engine/integration.js +220 -0
  77. package/dist/governance/engine/lifecycle.d.ts +29 -0
  78. package/dist/governance/engine/lifecycle.js +656 -0
  79. package/dist/governance/engine/pause.d.ts +56 -0
  80. package/dist/governance/engine/pause.js +107 -0
  81. package/dist/governance/engine/phase-members.d.ts +15 -0
  82. package/dist/governance/engine/phase-members.js +34 -0
  83. package/dist/governance/engine/phase-planner.d.ts +53 -0
  84. package/dist/governance/engine/phase-planner.js +282 -0
  85. package/dist/governance/engine/rebuild.d.ts +27 -0
  86. package/dist/governance/engine/rebuild.js +57 -0
  87. package/dist/governance/engine/report.d.ts +66 -0
  88. package/dist/governance/engine/report.js +220 -0
  89. package/dist/governance/engine/run-digest.d.ts +20 -0
  90. package/dist/governance/engine/run-digest.js +42 -0
  91. package/dist/governance/engine/spec-builder.d.ts +117 -0
  92. package/dist/governance/engine/spec-builder.js +321 -0
  93. package/dist/governance/engine/stage-runner.d.ts +22 -0
  94. package/dist/governance/engine/stage-runner.js +664 -0
  95. package/dist/governance/engine/start-input.d.ts +19 -0
  96. package/dist/governance/engine/start-input.js +111 -0
  97. package/dist/governance/engine/state-machine.d.ts +101 -0
  98. package/dist/governance/engine/state-machine.js +586 -0
  99. package/dist/governance/engine/submission-queries.d.ts +42 -0
  100. package/dist/governance/engine/submission-queries.js +97 -0
  101. package/dist/governance/engine/submission-render.d.ts +12 -0
  102. package/dist/governance/engine/submission-render.js +92 -0
  103. package/dist/governance/engine/submissions.d.ts +27 -0
  104. package/dist/governance/engine/submissions.js +455 -0
  105. package/dist/governance/engine/visibility.d.ts +104 -0
  106. package/dist/governance/engine/visibility.js +223 -0
  107. package/dist/governance/governed-dispatch.d.ts +19 -0
  108. package/dist/governance/governed-dispatch.js +17 -0
  109. package/dist/governance/limits.d.ts +107 -0
  110. package/dist/governance/limits.js +131 -0
  111. package/dist/governance/posture-transition.d.ts +38 -0
  112. package/dist/governance/posture-transition.js +44 -0
  113. package/dist/governance/posture.d.ts +35 -0
  114. package/dist/governance/posture.js +59 -0
  115. package/dist/governance/profiles.d.ts +48 -0
  116. package/dist/governance/profiles.js +140 -0
  117. package/dist/governance/prompts/orchestrator-block.d.ts +40 -0
  118. package/dist/governance/prompts/orchestrator-block.js +128 -0
  119. package/dist/governance/prompts/plan-addendum.d.ts +22 -0
  120. package/dist/governance/prompts/plan-addendum.js +60 -0
  121. package/dist/governance/prompts/refusals.d.ts +48 -0
  122. package/dist/governance/prompts/refusals.js +82 -0
  123. package/dist/governance/prompts/role-blocks.d.ts +40 -0
  124. package/dist/governance/prompts/role-blocks.js +255 -0
  125. package/dist/governance/report-reader.d.ts +31 -0
  126. package/dist/governance/report-reader.js +57 -0
  127. package/dist/governance/roles.d.ts +83 -0
  128. package/dist/governance/roles.js +142 -0
  129. package/dist/governance/rules/claims.d.ts +83 -0
  130. package/dist/governance/rules/claims.js +250 -0
  131. package/dist/governance/rules/elimination.d.ts +66 -0
  132. package/dist/governance/rules/elimination.js +105 -0
  133. package/dist/governance/rules/events-table.d.ts +46 -0
  134. package/dist/governance/rules/events-table.js +94 -0
  135. package/dist/governance/rules/failure-analysis.d.ts +28 -0
  136. package/dist/governance/rules/failure-analysis.js +93 -0
  137. package/dist/governance/rules/ledger-replay.d.ts +53 -0
  138. package/dist/governance/rules/ledger-replay.js +53 -0
  139. package/dist/governance/rules/ledger-state.d.ts +85 -0
  140. package/dist/governance/rules/ledger-state.js +175 -0
  141. package/dist/governance/rules/ledger.d.ts +228 -0
  142. package/dist/governance/rules/ledger.js +560 -0
  143. package/dist/governance/rules/rca.d.ts +68 -0
  144. package/dist/governance/rules/rca.js +220 -0
  145. package/dist/governance/rules/settlement.d.ts +129 -0
  146. package/dist/governance/rules/settlement.js +363 -0
  147. package/dist/governance/rules/suspicion.d.ts +66 -0
  148. package/dist/governance/rules/suspicion.js +169 -0
  149. package/dist/governance/store/artifacts.d.ts +81 -0
  150. package/dist/governance/store/artifacts.js +173 -0
  151. package/dist/governance/store/atomic.d.ts +79 -0
  152. package/dist/governance/store/atomic.js +119 -0
  153. package/dist/governance/store/events-log.d.ts +35 -0
  154. package/dist/governance/store/events-log.js +86 -0
  155. package/dist/governance/store/run-lock.d.ts +51 -0
  156. package/dist/governance/store/run-lock.js +122 -0
  157. package/dist/governance/store/run-store.d.ts +229 -0
  158. package/dist/governance/store/run-store.js +644 -0
  159. package/dist/governance/store/scoreboard-export.d.ts +53 -0
  160. package/dist/governance/store/scoreboard-export.js +65 -0
  161. package/dist/governance/tools/child-tools.d.ts +31 -0
  162. package/dist/governance/tools/child-tools.js +65 -0
  163. package/dist/governance/tools/guard.d.ts +71 -0
  164. package/dist/governance/tools/guard.js +194 -0
  165. package/dist/governance/tools/inspector-tools.d.ts +63 -0
  166. package/dist/governance/tools/inspector-tools.js +424 -0
  167. package/dist/governance/tools/lead-tools.d.ts +42 -0
  168. package/dist/governance/tools/lead-tools.js +226 -0
  169. package/dist/governance/tools/normalize-util.d.ts +101 -0
  170. package/dist/governance/tools/normalize-util.js +230 -0
  171. package/dist/governance/tools/scan-incomplete.d.ts +79 -0
  172. package/dist/governance/tools/scan-incomplete.js +486 -0
  173. package/dist/governance/tools/shared-tools.d.ts +44 -0
  174. package/dist/governance/tools/shared-tools.js +125 -0
  175. package/dist/governance/tools/submit-normalizers.d.ts +28 -0
  176. package/dist/governance/tools/submit-normalizers.js +474 -0
  177. package/dist/governance/tools/submit-tools.d.ts +26 -0
  178. package/dist/governance/tools/submit-tools.js +171 -0
  179. package/dist/governance/types.d.ts +661 -0
  180. package/dist/governance/types.js +27 -0
  181. package/dist/session/persist.js +10 -0
  182. package/dist/session/validate-session.js +36 -3
  183. package/dist/team/forced-mode.d.ts +19 -0
  184. package/dist/team/forced-mode.js +42 -20
  185. package/dist/team/runtime.d.ts +8 -0
  186. package/dist/team/runtime.js +9 -0
  187. package/dist/team/subagent.d.ts +23 -0
  188. package/dist/team/subagent.js +14 -3
  189. package/dist/team/types.d.ts +6 -0
  190. package/dist/tools/index.d.ts +30 -7
  191. package/dist/tools/index.js +14 -0
  192. package/dist/tools/plan-tools.d.ts +14 -2
  193. package/dist/tools/plan-tools.js +5 -2
  194. package/dist/ui/App.js +170 -31
  195. package/dist/ui/BottomStatusRow.js +1 -1
  196. package/dist/ui/Composer.d.ts +7 -1
  197. package/dist/ui/Composer.js +9 -6
  198. package/dist/ui/GovernancePanel.d.ts +50 -0
  199. package/dist/ui/GovernancePanel.js +77 -0
  200. package/dist/ui/GovernanceRun.d.ts +18 -0
  201. package/dist/ui/GovernanceRun.js +11 -0
  202. package/dist/ui/StatusBar.d.ts +15 -2
  203. package/dist/ui/StatusBar.js +10 -4
  204. package/dist/ui/Transcript.js +7 -1
  205. package/dist/ui/entries/GovernanceCard.d.ts +30 -0
  206. package/dist/ui/entries/GovernanceCard.js +32 -0
  207. package/dist/ui/entries/InvocationCard.d.ts +20 -0
  208. package/dist/ui/entries/InvocationCard.js +32 -0
  209. package/dist/ui/governance-copy.d.ts +69 -0
  210. package/dist/ui/governance-copy.js +104 -0
  211. package/dist/ui/governance-status.d.ts +145 -0
  212. package/dist/ui/governance-status.js +326 -0
  213. package/dist/ui/interaction-copy.d.ts +4 -0
  214. package/dist/ui/interaction-copy.js +5 -0
  215. package/dist/ui/interaction-hints.d.ts +17 -0
  216. package/dist/ui/interaction-hints.js +14 -2
  217. package/dist/ui/layout/governance-board.d.ts +121 -0
  218. package/dist/ui/layout/governance-board.js +382 -0
  219. package/dist/ui/layout/governance-card.d.ts +53 -0
  220. package/dist/ui/layout/governance-card.js +134 -0
  221. package/dist/ui/layout/governance-chip.d.ts +38 -0
  222. package/dist/ui/layout/governance-chip.js +64 -0
  223. package/dist/ui/layout/governance-panel.d.ts +85 -0
  224. package/dist/ui/layout/governance-panel.js +358 -0
  225. package/dist/ui/layout/governance-roster.d.ts +65 -0
  226. package/dist/ui/layout/governance-roster.js +275 -0
  227. package/dist/ui/layout/invocation-card.d.ts +41 -0
  228. package/dist/ui/layout/invocation-card.js +91 -0
  229. package/dist/ui/layout/status-detail-layout.js +3 -3
  230. package/dist/ui/layout/status-layout.d.ts +5 -2
  231. package/dist/ui/layout/status-layout.js +10 -6
  232. package/dist/ui/layout/virtual-window.js +22 -1
  233. package/dist/ui/overlays/GovernanceBoardOverlay.d.ts +41 -0
  234. package/dist/ui/overlays/GovernanceBoardOverlay.js +76 -0
  235. package/dist/ui/overlays/GovernanceSettingsPage.d.ts +48 -0
  236. package/dist/ui/overlays/GovernanceSettingsPage.js +93 -0
  237. package/dist/ui/overlays/HelpOverlay.js +4 -3
  238. package/dist/ui/overlays/QuestionOverlay.d.ts +9 -1
  239. package/dist/ui/overlays/QuestionOverlay.js +4 -2
  240. package/dist/ui/overlays/SettingsScreen.d.ts +7 -0
  241. package/dist/ui/overlays/SettingsScreen.js +21 -1
  242. package/dist/ui/overlays/governance-settings.d.ts +79 -0
  243. package/dist/ui/overlays/governance-settings.js +140 -0
  244. package/dist/ui/overlays/model-profile-state.d.ts +6 -1
  245. package/dist/ui/overlays/model-profile-state.js +10 -0
  246. package/dist/ui/palettes.d.ts +17 -0
  247. package/dist/ui/palettes.js +9 -0
  248. package/dist/ui/scrollback/live-preview.js +2 -0
  249. package/dist/ui/scrollback/settled-boundary.js +3 -0
  250. package/dist/ui/shortcuts.js +2 -2
  251. package/dist/ui/theme.d.ts +7 -0
  252. package/dist/ui/theme.js +1 -0
  253. package/dist/ui/transcript-text.js +13 -1
  254. package/dist/ui/use-wheel-routing.js +3 -1
  255. package/package.json +2 -2
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The governance slice of the view model: the small pure folds `reducer.ts` delegates to
3
+ * (governance-mode section 14.4).
4
+ *
5
+ * Pure: no React, no I/O. ASCII ONLY (`agent/` is glyph-scanned).
6
+ *
7
+ * WHY A FILE OF ITS OWN. `reducer.ts` is already past the file-size ceiling and the repo
8
+ * rule is "wiring-style growth only": each governance `case` in the reducer is a line or
9
+ * two that calls a function here, so the logic is unit-testable without a `ViewState`.
10
+ */
11
+ import type { AgentMode } from './agent-mode.js';
12
+ import type { GovernanceSnapshot } from '../governance/types.js';
13
+ import { type Posture } from '../governance/posture.js';
14
+ /** The posture half of a `setAgentMode` action. */
15
+ export interface AdoptedPostureInput {
16
+ mode: AgentMode;
17
+ pending: AgentMode | null;
18
+ /** Written from the controller's adopted state; absent for callers that predate postures. */
19
+ posture?: Posture;
20
+ pendingPosture?: Posture | null;
21
+ }
22
+ /**
23
+ * The pair of posture fields one `setAgentMode` dispatch writes.
24
+ *
25
+ * "NEVER DISPATCH THE REQUESTED VALUE, ONLY THE ADOPTED ONE" (spec 4.3): the controller
26
+ * reports all four values together and the reducer mirrors them, so the badge and the gate
27
+ * cannot disagree. A dispatch that carries only the gate mode (every pre-governance call
28
+ * site) keeps the governance dimension the view already has and swaps the mode half, which
29
+ * is exactly what such a caller meant.
30
+ */
31
+ export declare function adoptPosture(current: Posture, action: AdoptedPostureInput): {
32
+ posture: Posture;
33
+ pendingPosture: Posture | null;
34
+ };
35
+ /**
36
+ * Fold a pushed snapshot into the view: a snapshot OLDER than the one held, for the same
37
+ * run, is dropped (the wiring throttles, and a late flush must not roll the panel back).
38
+ * Returns the held object unchanged when nothing should change.
39
+ */
40
+ export declare function foldGovernanceSnapshot(held: GovernanceSnapshot | null, incoming: GovernanceSnapshot): GovernanceSnapshot;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The governance slice of the view model: the small pure folds `reducer.ts` delegates to
3
+ * (governance-mode section 14.4).
4
+ *
5
+ * Pure: no React, no I/O. ASCII ONLY (`agent/` is glyph-scanned).
6
+ *
7
+ * WHY A FILE OF ITS OWN. `reducer.ts` is already past the file-size ceiling and the repo
8
+ * rule is "wiring-style growth only": each governance `case` in the reducer is a line or
9
+ * two that calls a function here, so the logic is unit-testable without a `ViewState`.
10
+ */
11
+ import { composePosture, isGovernancePosture } from '../governance/posture.js';
12
+ /**
13
+ * The pair of posture fields one `setAgentMode` dispatch writes.
14
+ *
15
+ * "NEVER DISPATCH THE REQUESTED VALUE, ONLY THE ADOPTED ONE" (spec 4.3): the controller
16
+ * reports all four values together and the reducer mirrors them, so the badge and the gate
17
+ * cannot disagree. A dispatch that carries only the gate mode (every pre-governance call
18
+ * site) keeps the governance dimension the view already has and swaps the mode half, which
19
+ * is exactly what such a caller meant.
20
+ */
21
+ export function adoptPosture(current, action) {
22
+ const governed = isGovernancePosture(current);
23
+ const posture = action.posture ?? composePosture(action.mode, governed);
24
+ const pendingPosture = action.pendingPosture !== undefined
25
+ ? action.pendingPosture
26
+ : action.pending === null
27
+ ? null
28
+ : composePosture(action.pending, governed);
29
+ return { posture, pendingPosture };
30
+ }
31
+ /**
32
+ * Fold a pushed snapshot into the view: a snapshot OLDER than the one held, for the same
33
+ * run, is dropped (the wiring throttles, and a late flush must not roll the panel back).
34
+ * Returns the held object unchanged when nothing should change.
35
+ */
36
+ export function foldGovernanceSnapshot(held, incoming) {
37
+ if (held !== null && held.runId === incoming.runId && incoming.rev < held.rev)
38
+ return held;
39
+ return incoming;
40
+ }
@@ -0,0 +1,162 @@
1
+ /**
2
+ * GovernanceWiring - the host side of governance mode (governance-mode 3.2, 14.2).
3
+ *
4
+ * ASCII ONLY (`agent/` is inside the glyph scanner's scope).
5
+ *
6
+ * `AgentController` is 3000+ lines over the repo's file limit, so every governance decision
7
+ * it needs lives here and the controller only forwards: registration, availability, the
8
+ * Orchestrator and role prompt blocks, the PLAN+GOVERN interview gate, the approved-plan
9
+ * stash, the engine's lifecycle, the child tool hooks. The posture TRANSITION rule is a
10
+ * pure function in `governance/posture-transition.ts` for the same reason.
11
+ *
12
+ * TWO LAYERS OF "CAN I USE THIS" (D-22 / RV-1 / RV-14), and they are not the same thing:
13
+ *
14
+ * - REGISTERED is decided ONCE, in the constructor, from inputs that cannot change
15
+ * afterwards: team tools exist, `governance.enabled`, the env kill switch, and the
16
+ * channel's STATIC `neverPrompts` (NOT the live `canPrompt()`: at construction the App
17
+ * has not attached its human channel yet, so `canPrompt()` is false for every TUI
18
+ * session and keying off it would register nothing, silently, forever). The tool array
19
+ * is immutable after `new Agent(...)`, so this is irreversible for the session.
20
+ * - AVAILABLE is live: registered AND `team.enabled` AND an API key. It is what `/gov`,
21
+ * `doctor` and the key cycle ask.
22
+ */
23
+ import type { AgentTool, ModelCost } from '@aragon-agent/core';
24
+ import type { CliConfig } from '../config/schema.js';
25
+ import { type GovernanceAvailability } from '../governance/copy.js';
26
+ import type { TeamRuntimeLike } from '../governance/engine/engine-core.js';
27
+ import type { PauseOutcome } from '../governance/engine/pause.js';
28
+ import { type Posture } from '../governance/posture.js';
29
+ import { type RunReportResult } from '../governance/report-reader.js';
30
+ import { type IndexEntry } from '../governance/store/run-store.js';
31
+ import type { GovernanceEventListener, GovernanceSnapshot, LedgerState, RunState } from '../governance/types.js';
32
+ import type { SubagentSpec } from '../team/types.js';
33
+ import type { HumanInputGate, NormalizedPlan, NormalizedQuestion } from '../tools/human-input.js';
34
+ import type { AgentMode } from './agent-mode.js';
35
+ export interface WiringDeps {
36
+ /** `config.team.enabled` at construction: whether `task` (and a TeamRuntime) exist. */
37
+ teamRegistered: boolean;
38
+ config: () => CliConfig;
39
+ gate: HumanInputGate;
40
+ getCwd: () => string;
41
+ /** The gate mode (`build` | `plan`); the controller owns it. */
42
+ getGateMode: () => AgentMode;
43
+ getSessionId?: () => string | undefined;
44
+ withPausedWatchdog: <T>(fn: () => Promise<T>) => Promise<T>;
45
+ withHumanWait: <T>(fn: () => Promise<T>) => Promise<T>;
46
+ hasApiKey: () => boolean;
47
+ modelCost: () => ModelCost | undefined;
48
+ getRuntime: () => TeamRuntimeLike | null;
49
+ env?: Readonly<Record<string, string | undefined>>;
50
+ now?: () => number;
51
+ }
52
+ /** Render the approved plan as the run specification (<= `specChars`). */
53
+ export declare function renderPlanAsSpec(plan: NormalizedPlan): string;
54
+ /** What `/gov runs` shows per run: the index row without the cwd / session plumbing. */
55
+ export type GovernanceRunRow = Pick<IndexEntry, 'runId' | 'goal' | 'status' | 'updatedAt' | 'digest'>;
56
+ export declare class GovernanceWiring {
57
+ private readonly deps;
58
+ private readonly registered;
59
+ private readonly enabledAtStart;
60
+ private readonly env;
61
+ private governOn;
62
+ private pendingPosture;
63
+ private engine;
64
+ private store;
65
+ private readonly listeners;
66
+ private engineUnsubscribe;
67
+ private approvedPlan;
68
+ private answeredRounds;
69
+ private readonly coveredTopics;
70
+ /** A lazy facade: tools are built before the engine exists and the engine needs the runtime. */
71
+ private readonly api;
72
+ constructor(deps: WiringDeps);
73
+ /** Whether governance tools were registered at construction. Never changes. */
74
+ isRegistered(): boolean;
75
+ /** The live answer, with the precise reason when it is no. */
76
+ isAvailable(): GovernanceAvailability;
77
+ private unregisteredReason;
78
+ /** The exact sentence for the current unavailability, or null when available. */
79
+ unavailableText(): string | null;
80
+ /** Shift+Tab cycle: four states when usable and `governance.shiftTab`, else the classic two. */
81
+ postureCycle(): readonly Posture[];
82
+ isGovernOn(): boolean;
83
+ setGovernOn(on: boolean): void;
84
+ getPendingPosture(): Posture | null;
85
+ setPendingPosture(pending: Posture | null): void;
86
+ /** Entering PLAN+GOVERN starts a fresh interview and drops any older plan (9.3). */
87
+ onPostureAdopted(posture: Posture, previous: Posture): void;
88
+ isStageRunning(): boolean;
89
+ /**
90
+ * `''` unless governance is on, registered and available (closed state: byte-equal).
91
+ *
92
+ * `config` is the config the prompt is being composed FOR. A settings save composes the
93
+ * prompt from the candidate BEFORE it becomes live, so reading the live config here would
94
+ * quote the limits from before the save (governance-mode-v1-1 IF-3).
95
+ */
96
+ orchestratorBlock(posture: Posture, config?: CliConfig): string;
97
+ /** `''` unless PLAN+GOVERN. */
98
+ planAddendum(posture: Posture, config?: CliConfig): string;
99
+ roleBlockFor(spec: SubagentSpec): string;
100
+ /** Called from the controller's `noteAnswered`: one real, answered, non-duplicate round. */
101
+ noteAnsweredRound(questions?: readonly NormalizedQuestion[]): void;
102
+ answeredRoundCount(): number;
103
+ /** `submit_plan` pre-check: a refusal text, or null to proceed. */
104
+ beforeSubmitPlan(): string | null;
105
+ /** Stash the approved plan when governance is on. Returns which way the session goes. */
106
+ handlePlanApproved(plan: NormalizedPlan): 'govern' | 'build';
107
+ /** `gov_run start` consumes the stash exactly once. */
108
+ takeApprovedPlan(): string | null;
109
+ /** `[]` when not registered, which is the byte-identical closed path. */
110
+ leadTools(): AgentTool[];
111
+ leadPolicyExempt(): ReadonlySet<string>;
112
+ childPolicyExempt(): ReadonlySet<string>;
113
+ /** Role tools for a governed child; `[]` for anything else. */
114
+ childToolsFor(spec: SubagentSpec): AgentTool[];
115
+ /**
116
+ * Narrow a governed child's finished tool array: the inspector loses its write tools and
117
+ * gets the restricted shell, and every read-class tool gets the store tripwire.
118
+ *
119
+ * This runs on the factory's RESULT (see `SubagentDeps.narrowToolsFor`) because it has to
120
+ * see the built-in `bash` to replace it, while the role tools had to go IN through the
121
+ * factory. A non-governed spec comes back untouched.
122
+ */
123
+ narrowToolsFor(spec: SubagentSpec, tools: AgentTool[]): AgentTool[];
124
+ /** The engine is created on first use: a session that never governs never opens a store. */
125
+ private ensureEngine;
126
+ /** `confirmCharter` through the EXISTING plan-review overlay; no new overlay kind (RV-10). */
127
+ private confirmCharter;
128
+ /** Subscribe to the governance event stream (works before the engine exists). */
129
+ subscribe(listener: GovernanceEventListener): () => void;
130
+ snapshot(): GovernanceSnapshot | null;
131
+ /** Run + ledger for the `/gov board` overlay (read-only views of live memory). */
132
+ boardInput(): {
133
+ run: RunState;
134
+ ledger: LedgerState;
135
+ boardPath: string;
136
+ } | null;
137
+ abortStage(): void;
138
+ /**
139
+ * Recent runs for `/gov runs`, newest first. Opens the store lazily; `[]` when governance
140
+ * is unusable. `RunStore.listRuns()` is ALREADY newest-first: the previous
141
+ * `slice(-10).reverse()` therefore returned the OLDEST ten once there were more than ten.
142
+ */
143
+ listRuns(): Promise<GovernanceRunRow[]>;
144
+ /** `/gov report [runId]`: a stored report, read-only (governance-mode-v1-1 7.2). */
145
+ readReport(runId?: string): Promise<RunReportResult | {
146
+ kind: 'no_run';
147
+ }>;
148
+ /** `/gov pause`: the engine's verdict, or `no_run` when no engine was ever created. */
149
+ requestPause(): Promise<PauseOutcome>;
150
+ cancelPause(): boolean;
151
+ /** The dispatch-plan line for the live run (`/gov status`), or null without one. */
152
+ dispatchPlanText(): string | null;
153
+ /**
154
+ * The run `/gov resume [runId]` should hand to the orchestrator: the named one when it
155
+ * exists, else the newest resumable run for this directory. `null` when there is none.
156
+ */
157
+ findResumableRun(runId?: string): Promise<string | null>;
158
+ dispose(): void;
159
+ private buildLazyApi;
160
+ /** Posture helper for callers that only hold the gate mode. */
161
+ currentPosture(mode: AgentMode): Posture;
162
+ }