@aragon-agent/cli 0.6.54 → 0.6.56

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 (346) hide show
  1. package/CHANGELOG.md +2912 -2838
  2. package/README.md +4226 -4042
  3. package/dist/agent/controller.d.ts +119 -0
  4. package/dist/agent/controller.js +365 -2
  5. package/dist/agent/governance-wiring.js +8 -1
  6. package/dist/agent/redteam-prompt.d.ts +47 -0
  7. package/dist/agent/redteam-prompt.js +161 -0
  8. package/dist/agent/redteam-wiring.d.ts +159 -0
  9. package/dist/agent/redteam-wiring.js +349 -0
  10. package/dist/agent/system-prompt.d.ts +39 -0
  11. package/dist/agent/system-prompt.js +18 -0
  12. package/dist/app/App.d.ts +10 -1
  13. package/dist/app/App.js +233 -24
  14. package/dist/app/use-redteam-mode.d.ts +56 -0
  15. package/dist/app/use-redteam-mode.js +121 -0
  16. package/dist/cli.js +82 -4
  17. package/dist/commands/builtins.js +43 -1
  18. package/dist/commands/catalog.js +5 -0
  19. package/dist/commands/index-build.js +2 -1
  20. package/dist/commands/redteam-command.d.ts +22 -0
  21. package/dist/commands/redteam-command.js +141 -0
  22. package/dist/commands/registry.d.ts +8 -0
  23. package/dist/config/app-paths.d.ts +10 -0
  24. package/dist/config/app-paths.js +12 -0
  25. package/dist/config/cli-commands.d.ts +29 -0
  26. package/dist/config/cli-commands.js +76 -1
  27. package/dist/config/env.d.ts +3 -1
  28. package/dist/config/env.js +23 -1
  29. package/dist/config/load.d.ts +22 -0
  30. package/dist/config/load.js +22 -2
  31. package/dist/config/redteam-launch.d.ts +77 -0
  32. package/dist/config/redteam-launch.js +58 -0
  33. package/dist/config/store.js +21 -1
  34. package/dist/config/ui-state.d.ts +44 -0
  35. package/dist/config/ui-state.js +38 -0
  36. package/dist/exec/bridge/server.d.ts +7 -0
  37. package/dist/exec/bridge/server.js +6 -2
  38. package/dist/exec/cli-commands.js +4 -0
  39. package/dist/exec/index.js +2 -0
  40. package/dist/exec/options.d.ts +11 -0
  41. package/dist/exec/options.js +21 -1
  42. package/dist/gene/block.d.ts +33 -0
  43. package/dist/gene/block.js +51 -0
  44. package/dist/gene/capacity.d.ts +74 -0
  45. package/dist/gene/capacity.js +169 -0
  46. package/dist/gene/catalog-reconcile.d.ts +13 -0
  47. package/dist/gene/catalog-reconcile.js +105 -0
  48. package/dist/gene/catalog-stats.d.ts +27 -0
  49. package/dist/gene/catalog-stats.js +89 -0
  50. package/dist/gene/catalog-sync.d.ts +82 -0
  51. package/dist/gene/catalog-sync.js +324 -0
  52. package/dist/gene/catalog.d.ts +160 -0
  53. package/dist/gene/catalog.js +433 -0
  54. package/dist/gene/cli-commands.d.ts +50 -0
  55. package/dist/gene/cli-commands.js +500 -0
  56. package/dist/gene/command-report.d.ts +40 -0
  57. package/dist/gene/command-report.js +246 -0
  58. package/dist/gene/command.d.ts +29 -0
  59. package/dist/gene/command.js +561 -0
  60. package/dist/gene/commit-apply-types.d.ts +13 -0
  61. package/dist/gene/commit-apply-types.js +1 -0
  62. package/dist/gene/commit-compound.d.ts +34 -0
  63. package/dist/gene/commit-compound.js +212 -0
  64. package/dist/gene/commit-counts.d.ts +41 -0
  65. package/dist/gene/commit-counts.js +70 -0
  66. package/dist/gene/commit-exec.d.ts +42 -0
  67. package/dist/gene/commit-exec.js +134 -0
  68. package/dist/gene/commit-head.d.ts +52 -0
  69. package/dist/gene/commit-head.js +97 -0
  70. package/dist/gene/commit-plan.d.ts +95 -0
  71. package/dist/gene/commit-plan.js +68 -0
  72. package/dist/gene/commit-prepare.d.ts +63 -0
  73. package/dist/gene/commit-prepare.js +159 -0
  74. package/dist/gene/commit-types.d.ts +234 -0
  75. package/dist/gene/commit-types.js +3 -0
  76. package/dist/gene/curator/agent.d.ts +137 -0
  77. package/dist/gene/curator/agent.js +203 -0
  78. package/dist/gene/curator/budget.d.ts +69 -0
  79. package/dist/gene/curator/budget.js +131 -0
  80. package/dist/gene/curator/conflicts.d.ts +54 -0
  81. package/dist/gene/curator/conflicts.js +143 -0
  82. package/dist/gene/curator/curator.d.ts +170 -0
  83. package/dist/gene/curator/curator.js +617 -0
  84. package/dist/gene/curator/deps.d.ts +34 -0
  85. package/dist/gene/curator/deps.js +48 -0
  86. package/dist/gene/curator/deterministic.d.ts +62 -0
  87. package/dist/gene/curator/deterministic.js +287 -0
  88. package/dist/gene/curator/executors.d.ts +36 -0
  89. package/dist/gene/curator/executors.js +379 -0
  90. package/dist/gene/curator/lanes.d.ts +52 -0
  91. package/dist/gene/curator/lanes.js +99 -0
  92. package/dist/gene/curator/lease.d.ts +76 -0
  93. package/dist/gene/curator/lease.js +171 -0
  94. package/dist/gene/curator/library.d.ts +36 -0
  95. package/dist/gene/curator/library.js +169 -0
  96. package/dist/gene/curator/lifecycle.d.ts +52 -0
  97. package/dist/gene/curator/lifecycle.js +109 -0
  98. package/dist/gene/curator/maintenance.d.ts +71 -0
  99. package/dist/gene/curator/maintenance.js +213 -0
  100. package/dist/gene/curator/probation.d.ts +51 -0
  101. package/dist/gene/curator/probation.js +71 -0
  102. package/dist/gene/curator/probe.d.ts +131 -0
  103. package/dist/gene/curator/probe.js +534 -0
  104. package/dist/gene/curator/prompt.d.ts +18 -0
  105. package/dist/gene/curator/prompt.js +128 -0
  106. package/dist/gene/curator/publish.d.ts +64 -0
  107. package/dist/gene/curator/publish.js +113 -0
  108. package/dist/gene/curator/recheck.d.ts +55 -0
  109. package/dist/gene/curator/recheck.js +103 -0
  110. package/dist/gene/curator/run-events.d.ts +63 -0
  111. package/dist/gene/curator/run-events.js +55 -0
  112. package/dist/gene/curator/similarity.d.ts +13 -0
  113. package/dist/gene/curator/similarity.js +46 -0
  114. package/dist/gene/curator/switches.d.ts +78 -0
  115. package/dist/gene/curator/switches.js +146 -0
  116. package/dist/gene/curator/task-context.d.ts +93 -0
  117. package/dist/gene/curator/task-context.js +63 -0
  118. package/dist/gene/curator/task-runner.d.ts +56 -0
  119. package/dist/gene/curator/task-runner.js +257 -0
  120. package/dist/gene/curator/tool-support.d.ts +112 -0
  121. package/dist/gene/curator/tool-support.js +197 -0
  122. package/dist/gene/curator/toolkit.d.ts +49 -0
  123. package/dist/gene/curator/toolkit.js +104 -0
  124. package/dist/gene/curator/tools-read.d.ts +4 -0
  125. package/dist/gene/curator/tools-read.js +177 -0
  126. package/dist/gene/curator/tools-release.d.ts +73 -0
  127. package/dist/gene/curator/tools-release.js +287 -0
  128. package/dist/gene/curator/tools-verify.d.ts +47 -0
  129. package/dist/gene/curator/tools-verify.js +202 -0
  130. package/dist/gene/curator/tools-write.d.ts +26 -0
  131. package/dist/gene/curator/tools-write.js +394 -0
  132. package/dist/gene/curator/tools.d.ts +23 -0
  133. package/dist/gene/curator/tools.js +21 -0
  134. package/dist/gene/curator/validate/common.d.ts +87 -0
  135. package/dist/gene/curator/validate/common.js +132 -0
  136. package/dist/gene/curator/validate/evidence-tokens.d.ts +36 -0
  137. package/dist/gene/curator/validate/evidence-tokens.js +139 -0
  138. package/dist/gene/curator/validate/index.d.ts +23 -0
  139. package/dist/gene/curator/validate/index.js +62 -0
  140. package/dist/gene/curator/validate/knowledge.d.ts +25 -0
  141. package/dist/gene/curator/validate/knowledge.js +216 -0
  142. package/dist/gene/curator/validate/live-check.d.ts +14 -0
  143. package/dist/gene/curator/validate/live-check.js +144 -0
  144. package/dist/gene/curator/validate/ports.d.ts +67 -0
  145. package/dist/gene/curator/validate/ports.js +1 -0
  146. package/dist/gene/curator/validate/prompts.d.ts +41 -0
  147. package/dist/gene/curator/validate/prompts.js +161 -0
  148. package/dist/gene/curator/validate/skill.d.ts +15 -0
  149. package/dist/gene/curator/validate/skill.js +251 -0
  150. package/dist/gene/curator/validate/tool.d.ts +6 -0
  151. package/dist/gene/curator/validate/tool.js +217 -0
  152. package/dist/gene/curator/validate/types.d.ts +90 -0
  153. package/dist/gene/curator/validate/types.js +1 -0
  154. package/dist/gene/curator/validator-ports.d.ts +38 -0
  155. package/dist/gene/curator/validator-ports.js +29 -0
  156. package/dist/gene/diag.d.ts +209 -0
  157. package/dist/gene/diag.js +549 -0
  158. package/dist/gene/env.d.ts +10 -0
  159. package/dist/gene/env.js +214 -0
  160. package/dist/gene/eval-recorder.d.ts +84 -0
  161. package/dist/gene/eval-recorder.js +222 -0
  162. package/dist/gene/explain-transport.d.ts +3 -0
  163. package/dist/gene/explain-transport.js +39 -0
  164. package/dist/gene/explain.d.ts +96 -0
  165. package/dist/gene/explain.js +293 -0
  166. package/dist/gene/fs.d.ts +39 -0
  167. package/dist/gene/fs.js +139 -0
  168. package/dist/gene/fsck.d.ts +68 -0
  169. package/dist/gene/fsck.js +134 -0
  170. package/dist/gene/gc-library-sweeps.d.ts +9 -0
  171. package/dist/gene/gc-library-sweeps.js +220 -0
  172. package/dist/gene/gc-rejected-set.d.ts +15 -0
  173. package/dist/gene/gc-rejected-set.js +63 -0
  174. package/dist/gene/gc-safe.d.ts +12 -0
  175. package/dist/gene/gc-safe.js +74 -0
  176. package/dist/gene/gc-scope-sweeps.d.ts +18 -0
  177. package/dist/gene/gc-scope-sweeps.js +297 -0
  178. package/dist/gene/gc-types.d.ts +55 -0
  179. package/dist/gene/gc-types.js +26 -0
  180. package/dist/gene/gc.d.ts +42 -0
  181. package/dist/gene/gc.js +129 -0
  182. package/dist/gene/gene-errors.d.ts +23 -0
  183. package/dist/gene/gene-errors.js +29 -0
  184. package/dist/gene/hints.d.ts +91 -0
  185. package/dist/gene/hints.js +394 -0
  186. package/dist/gene/hub.d.ts +149 -0
  187. package/dist/gene/hub.js +371 -0
  188. package/dist/gene/import-plan.d.ts +80 -0
  189. package/dist/gene/import-plan.js +294 -0
  190. package/dist/gene/import-proposal.d.ts +23 -0
  191. package/dist/gene/import-proposal.js +101 -0
  192. package/dist/gene/import-skill-port.d.ts +6 -0
  193. package/dist/gene/import-skill-port.js +53 -0
  194. package/dist/gene/import-sources.d.ts +48 -0
  195. package/dist/gene/import-sources.js +140 -0
  196. package/dist/gene/index-writer.d.ts +36 -0
  197. package/dist/gene/index-writer.js +101 -0
  198. package/dist/gene/learn/learn-call.d.ts +63 -0
  199. package/dist/gene/learn/learn-call.js +157 -0
  200. package/dist/gene/learn/learn-prompt.d.ts +51 -0
  201. package/dist/gene/learn/learn-prompt.js +245 -0
  202. package/dist/gene/learn/learner.d.ts +181 -0
  203. package/dist/gene/learn/learner.js +426 -0
  204. package/dist/gene/learn/ledger.d.ts +220 -0
  205. package/dist/gene/learn/ledger.js +394 -0
  206. package/dist/gene/learn/proposal-build.d.ts +83 -0
  207. package/dist/gene/learn/proposal-build.js +211 -0
  208. package/dist/gene/learn/proposal-guard.d.ts +43 -0
  209. package/dist/gene/learn/proposal-guard.js +37 -0
  210. package/dist/gene/learn/signals-port.d.ts +47 -0
  211. package/dist/gene/learn/signals-port.js +86 -0
  212. package/dist/gene/maintenance-paths.d.ts +7 -0
  213. package/dist/gene/maintenance-paths.js +20 -0
  214. package/dist/gene/maintenance-probation.d.ts +33 -0
  215. package/dist/gene/maintenance-probation.js +127 -0
  216. package/dist/gene/maintenance-proposals.d.ts +24 -0
  217. package/dist/gene/maintenance-proposals.js +68 -0
  218. package/dist/gene/maintenance-runner.d.ts +92 -0
  219. package/dist/gene/maintenance-runner.js +262 -0
  220. package/dist/gene/maintenance-tasks.d.ts +37 -0
  221. package/dist/gene/maintenance-tasks.js +95 -0
  222. package/dist/gene/manager-actions.d.ts +12 -0
  223. package/dist/gene/manager-actions.js +279 -0
  224. package/dist/gene/manager-approve.d.ts +29 -0
  225. package/dist/gene/manager-approve.js +84 -0
  226. package/dist/gene/manager-context.d.ts +90 -0
  227. package/dist/gene/manager-context.js +201 -0
  228. package/dist/gene/manager-detail.d.ts +17 -0
  229. package/dist/gene/manager-detail.js +313 -0
  230. package/dist/gene/manager-gc.d.ts +13 -0
  231. package/dist/gene/manager-gc.js +81 -0
  232. package/dist/gene/manager-library.d.ts +39 -0
  233. package/dist/gene/manager-library.js +90 -0
  234. package/dist/gene/manager-list.d.ts +27 -0
  235. package/dist/gene/manager-list.js +170 -0
  236. package/dist/gene/manager-queue.d.ts +16 -0
  237. package/dist/gene/manager-queue.js +124 -0
  238. package/dist/gene/manager-stats.d.ts +28 -0
  239. package/dist/gene/manager-stats.js +53 -0
  240. package/dist/gene/manager-view.d.ts +27 -0
  241. package/dist/gene/manager-view.js +124 -0
  242. package/dist/gene/manager.d.ts +56 -0
  243. package/dist/gene/manager.js +179 -0
  244. package/dist/gene/orphan-scopes.d.ts +37 -0
  245. package/dist/gene/orphan-scopes.js +150 -0
  246. package/dist/gene/paths.d.ts +73 -0
  247. package/dist/gene/paths.js +239 -0
  248. package/dist/gene/plan-content.d.ts +73 -0
  249. package/dist/gene/plan-content.js +522 -0
  250. package/dist/gene/plan-lifecycle.d.ts +29 -0
  251. package/dist/gene/plan-lifecycle.js +310 -0
  252. package/dist/gene/policy.d.ts +71 -0
  253. package/dist/gene/policy.js +313 -0
  254. package/dist/gene/project-learning.d.ts +25 -0
  255. package/dist/gene/project-learning.js +54 -0
  256. package/dist/gene/propagation.d.ts +48 -0
  257. package/dist/gene/propagation.js +45 -0
  258. package/dist/gene/queue-lock.d.ts +22 -0
  259. package/dist/gene/queue-lock.js +99 -0
  260. package/dist/gene/queue-record.d.ts +57 -0
  261. package/dist/gene/queue-record.js +145 -0
  262. package/dist/gene/queue.d.ts +235 -0
  263. package/dist/gene/queue.js +764 -0
  264. package/dist/gene/read.d.ts +61 -0
  265. package/dist/gene/read.js +252 -0
  266. package/dist/gene/runlog.d.ts +101 -0
  267. package/dist/gene/runlog.js +404 -0
  268. package/dist/gene/schema-lite.d.ts +24 -0
  269. package/dist/gene/schema-lite.js +159 -0
  270. package/dist/gene/scope-guard.d.ts +23 -0
  271. package/dist/gene/scope-guard.js +9 -0
  272. package/dist/gene/scope-lock.d.ts +48 -0
  273. package/dist/gene/scope-lock.js +222 -0
  274. package/dist/gene/scope-verify.d.ts +63 -0
  275. package/dist/gene/scope-verify.js +123 -0
  276. package/dist/gene/secrets.d.ts +43 -0
  277. package/dist/gene/secrets.js +161 -0
  278. package/dist/gene/service-context.d.ts +43 -0
  279. package/dist/gene/service-context.js +79 -0
  280. package/dist/gene/service-prepare.d.ts +25 -0
  281. package/dist/gene/service-prepare.js +219 -0
  282. package/dist/gene/service-types.d.ts +196 -0
  283. package/dist/gene/service-types.js +1 -0
  284. package/dist/gene/service-view.d.ts +41 -0
  285. package/dist/gene/service-view.js +69 -0
  286. package/dist/gene/service.d.ts +114 -0
  287. package/dist/gene/service.js +761 -0
  288. package/dist/gene/session-start.d.ts +36 -0
  289. package/dist/gene/session-start.js +212 -0
  290. package/dist/gene/store-port.d.ts +88 -0
  291. package/dist/gene/store-port.js +10 -0
  292. package/dist/gene/store-rows.d.ts +36 -0
  293. package/dist/gene/store-rows.js +72 -0
  294. package/dist/gene/store.d.ts +125 -0
  295. package/dist/gene/store.js +622 -0
  296. package/dist/gene/tombstones.d.ts +47 -0
  297. package/dist/gene/tombstones.js +61 -0
  298. package/dist/gene/tool-runner.d.ts +47 -0
  299. package/dist/gene/tool-runner.js +154 -0
  300. package/dist/gene/tool-screen.d.ts +41 -0
  301. package/dist/gene/tool-screen.js +227 -0
  302. package/dist/gene/tools.d.ts +112 -0
  303. package/dist/gene/tools.js +539 -0
  304. package/dist/gene/transfer.d.ts +85 -0
  305. package/dist/gene/transfer.js +433 -0
  306. package/dist/gene/ui-hints.d.ts +15 -0
  307. package/dist/gene/ui-hints.js +67 -0
  308. package/dist/gene/usage-fold-cursor.d.ts +24 -0
  309. package/dist/gene/usage-fold-cursor.js +115 -0
  310. package/dist/gene/usage-fold.d.ts +49 -0
  311. package/dist/gene/usage-fold.js +397 -0
  312. package/dist/gene/usage.d.ts +67 -0
  313. package/dist/gene/usage.js +231 -0
  314. package/dist/gene/version-service.d.ts +118 -0
  315. package/dist/gene/version-service.js +453 -0
  316. package/dist/gene/wiring-events.d.ts +43 -0
  317. package/dist/gene/wiring-events.js +113 -0
  318. package/dist/gene/wiring-models.d.ts +46 -0
  319. package/dist/gene/wiring-models.js +81 -0
  320. package/dist/gene/wiring.d.ts +200 -0
  321. package/dist/gene/wiring.js +764 -0
  322. package/dist/governance/prompts/orchestrator-block.js +3 -2
  323. package/dist/host/controller-factory.d.ts +8 -0
  324. package/dist/host/controller-factory.js +7 -0
  325. package/dist/host/gene.d.ts +26 -0
  326. package/dist/host/gene.js +24 -0
  327. package/dist/host/index.d.ts +1 -0
  328. package/dist/host/index.js +1 -0
  329. package/dist/session/checkpoint.d.ts +15 -0
  330. package/dist/session/checkpoint.js +18 -0
  331. package/dist/session/persist.d.ts +21 -0
  332. package/dist/session/persist.js +10 -0
  333. package/dist/session/startup-session.d.ts +11 -2
  334. package/dist/session/startup-session.js +12 -2
  335. package/dist/session/validate-session.js +31 -0
  336. package/dist/team/runtime.d.ts +16 -0
  337. package/dist/team/runtime.js +29 -0
  338. package/dist/team/subagent.d.ts +55 -0
  339. package/dist/team/subagent.js +46 -2
  340. package/dist/tools/index.d.ts +60 -2
  341. package/dist/tools/index.js +68 -10
  342. package/package.json +3 -3
  343. package/skills/project-indexer/SKILL.md +275 -147
  344. package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -0
  345. package/skills/project-indexer/templates/config-template.md +12 -0
  346. package/skills/project-indexer/templates/index-template.md +4 -0
@@ -106,6 +106,16 @@ export declare const GOVERNANCE_CONFIG_SET_KEYS: readonly ["governance.enabled",
106
106
  * Every key is writable and ONE level deep, so `runConfigGet`'s single-dot split resolves it.
107
107
  */
108
108
  export declare const MEMORY_CONFIG_SET_KEYS: readonly ["memory.enabled", "memory.autoload", "memory.agentWrites", "memory.indexMaxChars", "memory.bodyBudgetChars", "memory.perBodyMaxChars"];
109
+ /**
110
+ * Config keys under `gene.` that `aragon config set` accepts (gene-bank spec 14.1).
111
+ *
112
+ * EVERY KEY OF `GeneConfig` IS LISTED, strings and enums included, and ONE level deep so
113
+ * `runConfigGet`'s single-dot split resolves it. `gene-config.test.ts` pins this set against
114
+ * `Object.keys(DEFAULT_GENE_CONFIG)`: a key added to the section and forgotten here is
115
+ * visible in `config list` and refused by `config set` as "Unknown config key" - the gap
116
+ * `COMPACTION_CONFIG_SET_KEYS` records at length.
117
+ */
118
+ export declare const GENE_CONFIG_SET_KEYS: readonly ["gene.enabled", "gene.use", "gene.autoLearn", "gene.capPerType", "gene.pinnedMax", "gene.candidateMax", "gene.versionsKept", "gene.archiveMaxMB", "gene.reviewerMaxItems", "gene.reviewerMaxTokens", "gene.mainMaxItems", "gene.mainMaxTokens", "gene.subagentMaxItems", "gene.subagentMaxTokens", "gene.hints", "gene.reviewerModel", "gene.curatorModel", "gene.curatorConcurrency", "gene.curatorTaskTokens", "gene.dailyTokens", "gene.learnMinIntervalSec", "gene.learnMaxPerSession", "gene.toolsAllowNetwork", "gene.probeMode", "gene.teamPath", "gene.teamTrusted", "gene.key", "gene.explainLanguage", "gene.holdoutPercent", "gene.importMaxItems"];
109
119
  /**
110
120
  * Translate a `log.*` dotted key into a patch, or `null` for anything else.
111
121
  *
@@ -164,6 +174,25 @@ export declare function applyGovernanceConfigSet(key: string, value: string): Pa
164
174
  * `memory` (the tenth time that trap is recorded in `store.ts`).
165
175
  */
166
176
  export declare function applyMemoryConfigSet(key: string, value: string): Partial<PersistedConfig> | null;
177
+ /**
178
+ * Translate a `gene.*` dotted key into a patch, or `null` for anything else.
179
+ *
180
+ * EVERY KEY ROUTES THROUGH `clampGeneConfig`, so `config set gene.probeMode all` stores
181
+ * `readonly` (the safe direction; there is no wider value) and the caller echoes the STORED
182
+ * value. Booleans, numbers and strings are typed by the DEFAULT's runtime type; an unparseable
183
+ * number becomes `NaN`, which the clamp repairs to the default - the "typo changes nothing"
184
+ * rule.
185
+ *
186
+ * ONE CROSS-FIELD CASE: `pinnedMax` is clamped against `capPerType`, and this function does
187
+ * not know the STORED `capPerType`. Clamping against the default's 5000 would refuse
188
+ * `pinnedMax 20000` for a user whose stored cap is 50000, so that key is validated against the
189
+ * loosest cap here and the real bound is applied by `updatePersistedConfig`, which re-clamps
190
+ * the merged section (the second half of the two-direction gate).
191
+ *
192
+ * The patch is a PARTIAL section, safe only because `updatePersistedConfig` deep-merges
193
+ * `gene` (the twelfth time that trap is recorded in `store.ts`).
194
+ */
195
+ export declare function applyGeneConfigSet(key: string, value: string): Partial<PersistedConfig> | null;
167
196
  /**
168
197
  * Translate a `team.*` dotted key into a patch, or `null` for anything else.
169
198
  *
@@ -14,7 +14,7 @@ import { getConfigBackupPath, getConfigPath, getHomeRoot, getLogsDir, getPromptH
14
14
  import { getHomeMigrationBreadcrumbPath } from './migrate-home.js';
15
15
  import { loadPersistedConfig, updatePersistedConfig } from './store.js';
16
16
  import { normalizeModelProfiles, validateModelProfiles } from '@aragon-agent/tui/model/config/model-profiles';
17
- import { clampFastConfig, clampRetryConfig, clampCompactionConfig, clampTeamConfig, parseThresholdInput, clampUpdateConfig, coercePositiveInt, maskSecret, DEFAULT_FAST_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TEAM_CONFIG, DEFAULT_COMPACTION_CONFIG, DEFAULT_UPDATE_CONFIG, DEFAULT_JOBS_CONFIG, clampJobsConfig, clampGovernanceConfig, clampMemoryConfig, DEFAULT_GOVERNANCE_CONFIG, DEFAULT_MEMORY_CONFIG, } from '@aragon-agent/tui/model/config/schema';
17
+ import { clampFastConfig, clampRetryConfig, clampCompactionConfig, clampTeamConfig, parseThresholdInput, clampUpdateConfig, coercePositiveInt, maskSecret, DEFAULT_FAST_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TEAM_CONFIG, DEFAULT_COMPACTION_CONFIG, DEFAULT_UPDATE_CONFIG, DEFAULT_JOBS_CONFIG, clampJobsConfig, clampGovernanceConfig, clampMemoryConfig, clampGeneConfig, DEFAULT_GOVERNANCE_CONFIG, DEFAULT_MEMORY_CONFIG, DEFAULT_GENE_CONFIG, } from '@aragon-agent/tui/model/config/schema';
18
18
  import { clampLogLevel } from '@aragon-agent/tui/model/logging/levels';
19
19
  /** Config keys under `log.` that `aragon config set` accepts. */
20
20
  export const LOG_CONFIG_SET_KEYS = [
@@ -196,6 +196,47 @@ export const MEMORY_CONFIG_SET_KEYS = [
196
196
  'memory.bodyBudgetChars',
197
197
  'memory.perBodyMaxChars',
198
198
  ];
199
+ /**
200
+ * Config keys under `gene.` that `aragon config set` accepts (gene-bank spec 14.1).
201
+ *
202
+ * EVERY KEY OF `GeneConfig` IS LISTED, strings and enums included, and ONE level deep so
203
+ * `runConfigGet`'s single-dot split resolves it. `gene-config.test.ts` pins this set against
204
+ * `Object.keys(DEFAULT_GENE_CONFIG)`: a key added to the section and forgotten here is
205
+ * visible in `config list` and refused by `config set` as "Unknown config key" - the gap
206
+ * `COMPACTION_CONFIG_SET_KEYS` records at length.
207
+ */
208
+ export const GENE_CONFIG_SET_KEYS = [
209
+ 'gene.enabled',
210
+ 'gene.use',
211
+ 'gene.autoLearn',
212
+ 'gene.capPerType',
213
+ 'gene.pinnedMax',
214
+ 'gene.candidateMax',
215
+ 'gene.versionsKept',
216
+ 'gene.archiveMaxMB',
217
+ 'gene.reviewerMaxItems',
218
+ 'gene.reviewerMaxTokens',
219
+ 'gene.mainMaxItems',
220
+ 'gene.mainMaxTokens',
221
+ 'gene.subagentMaxItems',
222
+ 'gene.subagentMaxTokens',
223
+ 'gene.hints',
224
+ 'gene.reviewerModel',
225
+ 'gene.curatorModel',
226
+ 'gene.curatorConcurrency',
227
+ 'gene.curatorTaskTokens',
228
+ 'gene.dailyTokens',
229
+ 'gene.learnMinIntervalSec',
230
+ 'gene.learnMaxPerSession',
231
+ 'gene.toolsAllowNetwork',
232
+ 'gene.probeMode',
233
+ 'gene.teamPath',
234
+ 'gene.teamTrusted',
235
+ 'gene.key',
236
+ 'gene.explainLanguage',
237
+ 'gene.holdoutPercent',
238
+ 'gene.importMaxItems',
239
+ ];
199
240
  function isTrue(value) {
200
241
  return value === 'true' || value === '1';
201
242
  }
@@ -323,6 +364,40 @@ export function applyMemoryConfigSet(key, value) {
323
364
  const clamped = clampMemoryConfig({ ...DEFAULT_MEMORY_CONFIG, [field]: typed });
324
365
  return { memory: { [field]: clamped[field] } };
325
366
  }
367
+ /** The loosest `capPerType` the clamp accepts; see `applyGeneConfigSet`'s `pinnedMax` note. */
368
+ const GENE_CAP_PER_TYPE_CEILING = 50_000;
369
+ /**
370
+ * Translate a `gene.*` dotted key into a patch, or `null` for anything else.
371
+ *
372
+ * EVERY KEY ROUTES THROUGH `clampGeneConfig`, so `config set gene.probeMode all` stores
373
+ * `readonly` (the safe direction; there is no wider value) and the caller echoes the STORED
374
+ * value. Booleans, numbers and strings are typed by the DEFAULT's runtime type; an unparseable
375
+ * number becomes `NaN`, which the clamp repairs to the default - the "typo changes nothing"
376
+ * rule.
377
+ *
378
+ * ONE CROSS-FIELD CASE: `pinnedMax` is clamped against `capPerType`, and this function does
379
+ * not know the STORED `capPerType`. Clamping against the default's 5000 would refuse
380
+ * `pinnedMax 20000` for a user whose stored cap is 50000, so that key is validated against the
381
+ * loosest cap here and the real bound is applied by `updatePersistedConfig`, which re-clamps
382
+ * the merged section (the second half of the two-direction gate).
383
+ *
384
+ * The patch is a PARTIAL section, safe only because `updatePersistedConfig` deep-merges
385
+ * `gene` (the twelfth time that trap is recorded in `store.ts`).
386
+ */
387
+ export function applyGeneConfigSet(key, value) {
388
+ if (!GENE_CONFIG_SET_KEYS.includes(key))
389
+ return null;
390
+ const field = key.slice('gene.'.length);
391
+ const trimmed = value.trim();
392
+ const kind = typeof DEFAULT_GENE_CONFIG[field];
393
+ const typed = kind === 'boolean' ? isTrue(trimmed) : kind === 'number' ? (trimmed === '' ? Number.NaN : Number(trimmed)) : trimmed;
394
+ const clamped = clampGeneConfig({
395
+ ...DEFAULT_GENE_CONFIG,
396
+ ...(field === 'pinnedMax' ? { capPerType: GENE_CAP_PER_TYPE_CEILING } : {}),
397
+ [field]: typed,
398
+ });
399
+ return { gene: { [field]: clamped[field] } };
400
+ }
326
401
  function parseGovernanceArgument(field, value) {
327
402
  const kind = typeof DEFAULT_GOVERNANCE_CONFIG[field];
328
403
  const trimmed = value.trim();
@@ -23,7 +23,9 @@
23
23
  * ARAGON_JOBS_PERSIST_LOG, ARAGON_JOBS_NOTICE_STEER,
24
24
  * ARAGON_PROMPTS (the quick-prompt library's `enabled` switch, and only that),
25
25
  * ARAGON_MEMORY (agent memory's kill switch: `0` turns it off, nothing turns it on),
26
- * ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it).
26
+ * ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it),
27
+ * ARAGON_REDTEAM (a KILL switch: `0` disables red team mode, nothing enables it),
28
+ * ARAGON_GENE (a KILL switch: `0` disables the Gene Bank, nothing enables it).
27
29
  *
28
30
  * READ ELSEWHERE, ON PURPOSE: `ARAGON_UPDATE_REGISTRY` and `npm_config_registry`
29
31
  * are resolved by `update/registry.ts::resolveRegistryUrl`, NOT here, because
@@ -23,7 +23,9 @@
23
23
  * ARAGON_JOBS_PERSIST_LOG, ARAGON_JOBS_NOTICE_STEER,
24
24
  * ARAGON_PROMPTS (the quick-prompt library's `enabled` switch, and only that),
25
25
  * ARAGON_MEMORY (agent memory's kill switch: `0` turns it off, nothing turns it on),
26
- * ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it).
26
+ * ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it),
27
+ * ARAGON_REDTEAM (a KILL switch: `0` disables red team mode, nothing enables it),
28
+ * ARAGON_GENE (a KILL switch: `0` disables the Gene Bank, nothing enables it).
27
29
  *
28
30
  * READ ELSEWHERE, ON PURPOSE: `ARAGON_UPDATE_REGISTRY` and `npm_config_registry`
29
31
  * are resolved by `update/registry.ts::resolveRegistryUrl`, NOT here, because
@@ -348,6 +350,26 @@ export function readEnvConfig() {
348
350
  if (memory === '0' || memory === 'false' || memory === 'off' || memory === 'no') {
349
351
  partial.memory = { enabled: false };
350
352
  }
353
+ // ARAGON_REDTEAM=0 is red team mode's KILL switch (red-team-security-mode 4.8 / D-15): it
354
+ // can only switch `enabled` OFF, and it outranks the config file. Like ARAGON_MEMORY it is
355
+ // not a toggle - `ARAGON_REDTEAM=1` writes nothing - and that asymmetry is the point: an
356
+ // environment must never be able to put a user into a liability posture the user's own
357
+ // config or `--no-redteam` turned off, because the waiver lives in the user's session, not
358
+ // in the shell that launched it.
359
+ const redteam = process.env.ARAGON_REDTEAM?.trim().toLowerCase();
360
+ if (redteam === '0' || redteam === 'false' || redteam === 'off' || redteam === 'no') {
361
+ partial.redteam = { enabled: false };
362
+ }
363
+ // ARAGON_GENE=0 is the Gene Bank KILL switch (gene-bank spec 14.3): it can only switch
364
+ // `enabled` OFF, and it outranks the config file. Like ARAGON_MEMORY it is not a toggle -
365
+ // `ARAGON_GENE=1` writes nothing, so an environment variable can never re-enable what the
366
+ // user's config or `--no-gene` turned off, and it can never reach `use` or `autoLearn`: those
367
+ // are the user's own runtime switches, and an env var that flipped them would be a second,
368
+ // invisible owner of a setting the Settings page claims to own.
369
+ const gene = process.env.ARAGON_GENE?.trim().toLowerCase();
370
+ if (gene === '0' || gene === 'false' || gene === 'off' || gene === 'no') {
371
+ partial.gene = { enabled: false };
372
+ }
351
373
  // ARAGON_TASK_SUMMARY is the header label's kill switch
352
374
  // (tui-shortcut-drawer-and-task-summary §4.8 / P2-7), and it maps `enabled` and
353
375
  // NOTHING ELSE - the same wording and the same reason as the block above. A
@@ -261,6 +261,27 @@ export interface CliFlags {
261
261
  * `undefined` for silence. Launch-only: never written to the store.
262
262
  */
263
263
  memory?: boolean;
264
+ /**
265
+ * `--redteam` / `--no-redteam` (red-team-security-mode 4.8), carried as a PAIR for the
266
+ * reason `--compaction` above records: `redteam.enabled` is persisted and defaults to
267
+ * `true`, so a lone `--no-redteam` would make commander default the option to `true`, and
268
+ * the flag would then overwrite a stored `false` on every run that passed no flag at all.
269
+ * `cli.tsx` forwards `undefined` for silence.
270
+ *
271
+ * BOTH ARE LAUNCH-ONLY: neither is written to the store. `--redteam` additionally means
272
+ * "start armed", which is session state and is resolved by `redteam-launch.ts`.
273
+ */
274
+ redteam?: boolean;
275
+ noRedteam?: boolean;
276
+ /**
277
+ * `--no-gene` (gene-bank spec 14.3), carried as `true` ONLY. A lone negative flag makes
278
+ * commander default its option (`opts.gene`) to `true`, so `cli.tsx` translates the explicit
279
+ * `false` into `noGene: true` and forwards `undefined` for silence - the polarity is reversed
280
+ * from `memory` above on purpose, so that the field reads as the thing it does (switch OFF)
281
+ * and a future positive `--gene` cannot be mistaken for it. Launch-only: never written to the
282
+ * store.
283
+ */
284
+ noGene?: boolean;
264
285
  /**
265
286
  * `--resume <id|path>` - continue a saved session under a NEW id
266
287
  * (tui-session-id-resume 4).
@@ -283,6 +304,7 @@ export interface CliFlags {
283
304
  */
284
305
  export declare function loadConfig(flags?: CliFlags, options?: {
285
306
  interactive?: boolean;
307
+ quiet?: boolean;
286
308
  }): CliConfig;
287
309
  /**
288
310
  * Build the `getApiKey(providerId)` resolver the core `Agent` consumes.
@@ -6,7 +6,7 @@
6
6
  * legitimately long single tool run can never be watchdog-killed.
7
7
  */
8
8
  import process from 'node:process';
9
- import { DEFAULT_CONFIG, DEFAULT_SCROLL_MODE, IDLE_TIMEOUT_MARGIN_MS, clampDensity, clampHumanTimeout, clampCompactionConfig, clampLogConfig, clampFastConfig, clampRetryConfig, clampSkillsConfig, clampTeamConfig, clampTodoConfig, clampBashConfig, clampJobsConfig, clampPromptsConfig, clampMemoryConfig, clampTaskSummaryConfig, clampUpdateConfig, clampTheme, clampThinkingLevel, clampContextWindow, clampMaxTokens, clampMaxRenderInterval, clampScrollMode, clampScrollResumeMs, clampTranscriptRetain, clampTranscriptWindow, coercePositiveInt, isAutoToken, isSkillsToolPolicyMode, legacyTeamCeilingPatch, legacyTeamFanoutPatch, LEGACY_TEAM_FANOUT_DEFAULTS, parseThresholdInput, } from '@aragon-agent/tui/model/config/schema';
9
+ import { DEFAULT_CONFIG, DEFAULT_SCROLL_MODE, IDLE_TIMEOUT_MARGIN_MS, clampDensity, clampHumanTimeout, clampCompactionConfig, clampLogConfig, clampFastConfig, clampRetryConfig, clampSkillsConfig, clampTeamConfig, clampTodoConfig, clampBashConfig, clampJobsConfig, clampPromptsConfig, clampMemoryConfig, clampRedTeamConfig, clampGeneConfig, clampTaskSummaryConfig, clampUpdateConfig, clampTheme, clampThinkingLevel, clampContextWindow, clampMaxTokens, clampMaxRenderInterval, clampScrollMode, clampScrollResumeMs, clampTranscriptRetain, clampTranscriptWindow, coercePositiveInt, isAutoToken, isSkillsToolPolicyMode, legacyTeamCeilingPatch, legacyTeamFanoutPatch, LEGACY_TEAM_FANOUT_DEFAULTS, parseThresholdInput, } from '@aragon-agent/tui/model/config/schema';
10
10
  import { loadDotenv, readEnvConfig, readEnvDisabledSkills } from './env.js';
11
11
  import { readConfigFile, updatePersistedConfig } from './store.js';
12
12
  import { projectModelProfiles, resolveModelProfileState, resolveModelRoleKey, } from '@aragon-agent/tui/model/config/model-profile-resolution';
@@ -806,6 +806,24 @@ export function loadConfig(flags = {}, options = {}) {
806
806
  ...(env.partial.memory ?? {}),
807
807
  ...(flags.memory === false ? { enabled: false } : {}),
808
808
  }),
809
+ // Red team / security mode: file < env kill switch < `--no-redteam`, clamped like every
810
+ // section. The kill switches can only switch `enabled` OFF and are applied AFTER the file
811
+ // so they outrank it - an environment must never be able to switch the mode ON (D-15).
812
+ redteam: clampRedTeamConfig({
813
+ ...DEFAULT_CONFIG.redteam,
814
+ ...(file.redteam ?? {}),
815
+ ...(env.partial.redteam ?? {}),
816
+ ...(flags.noRedteam === true ? { enabled: false } : {}),
817
+ }),
818
+ // Gene Bank: file < env kill switch < `--no-gene`, clamped like every section. The kill
819
+ // switches can only switch `enabled` OFF and are applied AFTER the file so they outrank
820
+ // it; `use` and `autoLearn` come from the file alone (spec 14.2: the user's own switches).
821
+ gene: clampGeneConfig({
822
+ ...DEFAULT_CONFIG.gene,
823
+ ...(file.gene ?? {}),
824
+ ...(env.partial.gene ?? {}),
825
+ ...(flags.noGene === true ? { enabled: false } : {}),
826
+ }),
809
827
  initialPosture,
810
828
  cwd,
811
829
  color,
@@ -817,7 +835,9 @@ export function loadConfig(flags = {}, options = {}) {
817
835
  if (config.apiKeyOverride && (config.modelProfiles?.mainId || config.modelProfiles?.fastId)) {
818
836
  config.apiKeyOverrideTarget = { provider, baseUrl: baseUrl?.trim() || null };
819
837
  }
820
- recordResolvedConfig(config);
838
+ // `quiet`: a background reader (the Gene Bank's explanation) must not add a startup record.
839
+ if (options.quiet !== true)
840
+ recordResolvedConfig(config);
821
841
  return config;
822
842
  }
823
843
  /**
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Command-line validation for `--redteam` / `--no-redteam` (red-team-security-mode 4.8).
3
+ *
4
+ * PURE, AND OUT OF `cli.tsx` ON PURPOSE: that file is far past the size limit, and these
5
+ * rules are the kind that regress silently - a missing headless rule ships a "start armed"
6
+ * flag into `aragon exec`, where nobody can accept a waiver. `cli.tsx` gathers the facts and
7
+ * prints the message.
8
+ *
9
+ * TWO RULES, AND THE ONE THAT IS ABSENT IS THE POINT (RV-1 / D-20). v1 refused
10
+ * `--redteam --confirm`; that was backwards. `--confirm` is the NARROWER authorization - a
11
+ * user who enters red team mode with the confirmation gate switched on is a configuration
12
+ * this very feature supports (`redteam.bypassConfirm=false`) - so the pair is ALLOWED and the
13
+ * banner and `/redteam status` say what happened to the gate.
14
+ *
15
+ * ASCII ONLY: `src/config/**` is inside the glyph scanner's scope.
16
+ */
17
+ export interface RedTeamLaunchInput {
18
+ /** `--redteam`: start this session armed. */
19
+ redTeam?: boolean;
20
+ /** `--no-redteam`: unregister the whole chain for this launch. */
21
+ noRedTeam?: boolean;
22
+ /** `ARAGON_REDTEAM=0` or `redteam.enabled: false` in the resolved config. */
23
+ unavailable?: boolean;
24
+ /** The waiver version `state.json` holds; `0` means never accepted. */
25
+ waiverVersion: number;
26
+ /**
27
+ * The run cannot reach a human: `-p/--print`, the `exec` subcommand, piped stdin or a
28
+ * non-TTY stdout. A waiver cannot be accepted there, and a posture nobody can leave is
29
+ * worse than no posture.
30
+ */
31
+ headless: boolean;
32
+ }
33
+ export interface RedTeamLaunchDecision {
34
+ /** The chain exists in this session at all. */
35
+ available: boolean;
36
+ /** Start with the mode armed. */
37
+ startArmed: boolean;
38
+ /** `--redteam` was asked for and will NOT be honoured; the reason was already reported. */
39
+ ignored: boolean;
40
+ }
41
+ export type RedTeamLaunchCheck = {
42
+ ok: true;
43
+ decision: RedTeamLaunchDecision;
44
+ } | {
45
+ ok: false;
46
+ message: string;
47
+ };
48
+ export declare const REDTEAM_HEADLESS_MESSAGE = "--redteam is a terminal session posture; it is not available in print or exec mode.";
49
+ export declare const REDTEAM_UNAVAILABLE_MESSAGE: string;
50
+ /** `--redteam needs the disclaimer accepted first.` - the message names the exact next step. */
51
+ export declare const REDTEAM_WAIVER_MESSAGE = "--redteam needs the disclaimer accepted first. Run aragon, press Ctrl+R and accept it.";
52
+ /**
53
+ * Resolve the launch. ORDER IS THE CONTRACT, and it is the order of the two things a user
54
+ * cannot fix by dropping another flag: headless first (no terminal, so no waiver and no way
55
+ * out), then the waiver itself.
56
+ *
57
+ * `--no-redteam` and an unavailable config are NOT errors even when `--redteam` was also
58
+ * passed: the negative wins, the session starts disarmed, and the caller reports it once.
59
+ * Making that combination fatal would punish a wrapper script that always passes
60
+ * `--redteam` and sometimes adds `--no-redteam`.
61
+ */
62
+ export declare function validateRedTeamLaunch(input: RedTeamLaunchInput): RedTeamLaunchCheck;
63
+ /** The root-level options these rules read, as commander materialises them. */
64
+ export interface RedTeamRootOptions {
65
+ /** `--redteam` is declared alone, so an absent flag reads `undefined`. */
66
+ redteam?: boolean;
67
+ /** `--no-redteam` is declared alone: `false` when given. */
68
+ noRedteamFlag?: boolean;
69
+ }
70
+ export interface RedTeamCommandContext {
71
+ commandName: string;
72
+ isRootAction: boolean;
73
+ stdinIsTty: boolean;
74
+ stdoutIsTty: boolean;
75
+ }
76
+ /** The `preAction` hook's decision: `exec` is always headless, the root action is when piped. */
77
+ export declare function checkRedTeamCommandLine(options: RedTeamRootOptions, context: RedTeamCommandContext, waiverVersion: number, unavailable: boolean): RedTeamLaunchCheck;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Command-line validation for `--redteam` / `--no-redteam` (red-team-security-mode 4.8).
3
+ *
4
+ * PURE, AND OUT OF `cli.tsx` ON PURPOSE: that file is far past the size limit, and these
5
+ * rules are the kind that regress silently - a missing headless rule ships a "start armed"
6
+ * flag into `aragon exec`, where nobody can accept a waiver. `cli.tsx` gathers the facts and
7
+ * prints the message.
8
+ *
9
+ * TWO RULES, AND THE ONE THAT IS ABSENT IS THE POINT (RV-1 / D-20). v1 refused
10
+ * `--redteam --confirm`; that was backwards. `--confirm` is the NARROWER authorization - a
11
+ * user who enters red team mode with the confirmation gate switched on is a configuration
12
+ * this very feature supports (`redteam.bypassConfirm=false`) - so the pair is ALLOWED and the
13
+ * banner and `/redteam status` say what happened to the gate.
14
+ *
15
+ * ASCII ONLY: `src/config/**` is inside the glyph scanner's scope.
16
+ */
17
+ import { REDTEAM_DISCLAIMER_VERSION } from '@aragon-agent/tui/model/redteam/limits';
18
+ export const REDTEAM_HEADLESS_MESSAGE = '--redteam is a terminal session posture; it is not available in print or exec mode.';
19
+ export const REDTEAM_UNAVAILABLE_MESSAGE = '--redteam was requested, but red team mode is off for this launch '
20
+ + '(--no-redteam, redteam.enabled=false or ARAGON_REDTEAM=0).';
21
+ /** `--redteam needs the disclaimer accepted first.` - the message names the exact next step. */
22
+ export const REDTEAM_WAIVER_MESSAGE = '--redteam needs the disclaimer accepted first. Run aragon, press Ctrl+R and accept it.';
23
+ /**
24
+ * Resolve the launch. ORDER IS THE CONTRACT, and it is the order of the two things a user
25
+ * cannot fix by dropping another flag: headless first (no terminal, so no waiver and no way
26
+ * out), then the waiver itself.
27
+ *
28
+ * `--no-redteam` and an unavailable config are NOT errors even when `--redteam` was also
29
+ * passed: the negative wins, the session starts disarmed, and the caller reports it once.
30
+ * Making that combination fatal would punish a wrapper script that always passes
31
+ * `--redteam` and sometimes adds `--no-redteam`.
32
+ */
33
+ export function validateRedTeamLaunch(input) {
34
+ const unavailable = input.unavailable === true || input.noRedTeam === true;
35
+ const requested = input.redTeam === true && !unavailable;
36
+ if (!requested) {
37
+ return { ok: true, decision: { available: !unavailable, startArmed: false, ignored: false } };
38
+ }
39
+ if (input.headless)
40
+ return { ok: false, message: REDTEAM_HEADLESS_MESSAGE };
41
+ if (input.waiverVersion < REDTEAM_DISCLAIMER_VERSION) {
42
+ return { ok: false, message: REDTEAM_WAIVER_MESSAGE };
43
+ }
44
+ return { ok: true, decision: { available: true, startArmed: true, ignored: false } };
45
+ }
46
+ /** The `preAction` hook's decision: `exec` is always headless, the root action is when piped. */
47
+ export function checkRedTeamCommandLine(options, context, waiverVersion, unavailable) {
48
+ const headless = context.commandName === 'exec'
49
+ || (context.isRootAction
50
+ && (options.redteam === true && (!context.stdinIsTty || !context.stdoutIsTty)));
51
+ return validateRedTeamLaunch({
52
+ ...(options.redteam === true ? { redTeam: true } : {}),
53
+ ...(options.noRedteamFlag === false ? { noRedTeam: true } : {}),
54
+ unavailable,
55
+ waiverVersion,
56
+ headless,
57
+ });
58
+ }
@@ -17,7 +17,7 @@ import { getConfigPath, getSessionsDir } from './app-paths.js';
17
17
  import { registerProfileSecrets, registerSecretsFrom } from '@aragon-agent/tui/model/logging/secret-registry';
18
18
  import { adaptLegacyConnectionPatch, ModelProfileConfigError, readModelSettingsDisk } from './model-profile-store.js';
19
19
  import { normalizeModelProfiles } from '@aragon-agent/tui/model/config/model-profiles';
20
- import { clampBashConfig, clampJobsConfig, clampPromptsConfig, clampTaskSummaryConfig, CONFIG_VERSION, DEFAULT_CONFIG, clampCompactionConfig, clampFastConfig, clampGovernanceConfig, clampLogConfig, clampMemoryConfig, clampMaxTokens, clampRetryConfig, clampSkillsConfig, clampTeamConfig, clampTodoConfig, clampContextWindow, clampUpdateConfig, isAutoToken, stripLegacyStateKeys, stripRetiredConfigKeys, } from '@aragon-agent/tui/model/config/schema';
20
+ import { clampBashConfig, clampJobsConfig, clampPromptsConfig, clampTaskSummaryConfig, CONFIG_VERSION, DEFAULT_CONFIG, clampCompactionConfig, clampFastConfig, clampGeneConfig, clampGovernanceConfig, clampLogConfig, clampMemoryConfig, clampRedTeamConfig, clampMaxTokens, clampRetryConfig, clampSkillsConfig, clampTeamConfig, clampTodoConfig, clampContextWindow, clampUpdateConfig, isAutoToken, stripLegacyStateKeys, stripRetiredConfigKeys, } from '@aragon-agent/tui/model/config/schema';
21
21
  /**
22
22
  * Normalize `maxTokens` for both directions of the config file.
23
23
  *
@@ -224,6 +224,15 @@ export function normalizePersistedConfig(input) {
224
224
  // section, and a hand-edited one is clamped: the file cannot carry a budget the
225
225
  // planner would refuse or an `agentWrites` that is neither of the three values.
226
226
  memory: clampMemoryConfig({ ...DEFAULT_CONFIG.memory, ...(partial.memory ?? {}) }),
227
+ // And the sixteenth. A `config.json` predating red team mode must resolve a whole
228
+ // section - and this one, unlike most, has a direction that matters: `enabled` defaults
229
+ // to `true`, so an absent section here would arrive with the mode switched OFF for every
230
+ // existing user in exactly the session where `Ctrl+R` is expected to work.
231
+ redteam: clampRedTeamConfig({ ...DEFAULT_CONFIG.redteam, ...(partial.redteam ?? {}) }),
232
+ // And the seventeenth. A `config.json` predating the Gene Bank must resolve a whole
233
+ // section, and a hand-edited one is clamped: the file cannot carry a `probeMode` wider
234
+ // than the engine allows, a relative `teamPath`, or a `pinnedMax` the library cannot hold.
235
+ gene: clampGeneConfig({ ...DEFAULT_CONFIG.gene, ...(partial.gene ?? {}) }),
227
236
  };
228
237
  }
229
238
  /**
@@ -356,6 +365,17 @@ export function mergePersistedConfig(current, patch) {
356
365
  // without this merge the shallow spread REPLACES the section and `agentWrites` is
357
366
  // written absent - which must never read back as anything but `ask`.
358
367
  memory: clampMemoryConfig({ ...current.memory, ...(patch.memory ?? {}) }),
368
+ // The sixteenth section, and the eleventh time this file records the same trap.
369
+ // `aragon config set redteam.bypassConfirm false` sends `{ redteam: { bypassConfirm:
370
+ // false } }`; without this merge the shallow spread REPLACES the section and `enabled` is
371
+ // written absent, which reads back as the default rather than as the user's switch.
372
+ redteam: clampRedTeamConfig({ ...current.redteam, ...(patch.redteam ?? {}) }),
373
+ // The seventeenth section, and the twelfth time this file records the same trap.
374
+ // `aragon config set gene.use false` sends `{ gene: { use: false } }`; without this merge
375
+ // the shallow spread REPLACES the section, `enabled` and `autoLearn` are written absent
376
+ // and read back as their defaults - i.e. turning off one of the two user switches would
377
+ // silently turn the other one back on.
378
+ gene: clampGeneConfig({ ...current.gene, ...(patch.gene ?? {}) }),
359
379
  };
360
380
  return merged;
361
381
  }
@@ -113,6 +113,23 @@ export interface UiState {
113
113
  * it as `false`, which is exactly the first-run behaviour wanted.
114
114
  */
115
115
  governanceIntroSeen: boolean;
116
+ /**
117
+ * The red team waiver version this machine has accepted; `0` = never (red-team-security-mode
118
+ * 4.3 / D-3).
119
+ *
120
+ * IT LIVES HERE, NOT IN `config.json`, and that is a design decision rather than a storage
121
+ * detail: "this machine's user agreed to version N of this text" is a MACHINE FACT about a
122
+ * one-time act, exactly like the notice versions above, while `config.json` is the user's
123
+ * POLICY. `migrateStateOutOfConfig` was written because those two got mixed once already.
124
+ *
125
+ * `>= REDTEAM_DISCLAIMER_VERSION` counts as accepted, so raising the constant asks every
126
+ * user again - which is the only way a one-time acceptance can ever reach new text (RV-20).
127
+ *
128
+ * A NEW SCALAR AND NOT A SCHEMA BUMP, for the fourth time in this file: a schema bump makes
129
+ * `readFromDisk` discard the whole object, resetting every user's `submitCount` to re-ask
130
+ * one question.
131
+ */
132
+ redTeamWaiverVersion: number;
116
133
  }
117
134
  /** Read the state, caching it for the life of the process. Never throws. */
118
135
  export declare function loadUiState(): UiState;
@@ -136,6 +153,33 @@ export declare function setPromptKeyNoticeVersion(version: number): void;
136
153
  /** `false` until the one-time GOVERN explainer has been shown; persisted across launches. */
137
154
  export declare function getGovernanceIntroSeen(): boolean;
138
155
  export declare function setGovernanceIntroSeen(seen: boolean): void;
156
+ /**
157
+ * The accepted red team waiver version; `0` on a file written before the field existed.
158
+ *
159
+ * A READER, NOT A DECISION: whether `0` is "accepted" is
160
+ * `version >= REDTEAM_DISCLAIMER_VERSION`, and that comparison lives in `RedTeamWiring` so the
161
+ * constant has exactly one consumer (I-3).
162
+ */
163
+ export declare function getRedTeamWaiverVersion(): number;
164
+ /**
165
+ * Record the acceptance and RETURN WHAT LANDED ON DISK, read back rather than trusted.
166
+ *
167
+ * It goes through `update` - the same atomic write every state field uses - so a failed write
168
+ * leaves the in-memory value intact and the disk unchanged, and the caller's `disclaimer
169
+ * accepted` claim is never based on a value the process only hopes it wrote (T-A1).
170
+ * `askEveryArm` re-asking goes through THIS function too, which is what makes a re-acceptance
171
+ * idempotent: it re-writes the same number (RV-21).
172
+ */
173
+ export declare function acceptRedTeamWaiver(version: number): number;
174
+ /**
175
+ * `ARAGON_REDTEAM=0` in its kill-switch spellings, read from the LIVE environment.
176
+ *
177
+ * A SECOND READER OF THE SAME RULE, and only for `cli.tsx`'s `preAction` hook, which runs
178
+ * BEFORE `loadConfig` (so the folded `redteam.enabled` does not exist yet) and must refuse
179
+ * `--redteam` in a session the environment killed. `config/env.ts` remains the place the value
180
+ * lands in the resolved config; the two agree because the value set here is the one it accepts.
181
+ */
182
+ export declare function isRedTeamEnvOff(env?: Readonly<Record<string, string | undefined>>): boolean;
139
183
  /**
140
184
  * Migration-only: fill in fields that are still at their default, and never
141
185
  * overwrite a value already here. A second import — after a half-finished
@@ -40,6 +40,7 @@ const DEFAULT_UI_STATE = {
40
40
  scrollModeNoticeVersion: 0,
41
41
  promptKeyNoticeVersion: 0,
42
42
  governanceIntroSeen: false,
43
+ redTeamWaiverVersion: 0,
43
44
  };
44
45
  let memory = null;
45
46
  /** Non-negative integer or `fallback`; shared by both numeric fields. */
@@ -77,6 +78,7 @@ function readFromDisk() {
77
78
  governanceIntroSeen: typeof parsed.governanceIntroSeen === 'boolean'
78
79
  ? parsed.governanceIntroSeen
79
80
  : DEFAULT_UI_STATE.governanceIntroSeen,
81
+ redTeamWaiverVersion: coerceCount(parsed.redTeamWaiverVersion, DEFAULT_UI_STATE.redTeamWaiverVersion),
80
82
  };
81
83
  }
82
84
  catch {
@@ -171,6 +173,42 @@ export function getGovernanceIntroSeen() {
171
173
  export function setGovernanceIntroSeen(seen) {
172
174
  update({ governanceIntroSeen: seen });
173
175
  }
176
+ /**
177
+ * The accepted red team waiver version; `0` on a file written before the field existed.
178
+ *
179
+ * A READER, NOT A DECISION: whether `0` is "accepted" is
180
+ * `version >= REDTEAM_DISCLAIMER_VERSION`, and that comparison lives in `RedTeamWiring` so the
181
+ * constant has exactly one consumer (I-3).
182
+ */
183
+ export function getRedTeamWaiverVersion() {
184
+ return loadUiState().redTeamWaiverVersion;
185
+ }
186
+ /**
187
+ * Record the acceptance and RETURN WHAT LANDED ON DISK, read back rather than trusted.
188
+ *
189
+ * It goes through `update` - the same atomic write every state field uses - so a failed write
190
+ * leaves the in-memory value intact and the disk unchanged, and the caller's `disclaimer
191
+ * accepted` claim is never based on a value the process only hopes it wrote (T-A1).
192
+ * `askEveryArm` re-asking goes through THIS function too, which is what makes a re-acceptance
193
+ * idempotent: it re-writes the same number (RV-21).
194
+ */
195
+ export function acceptRedTeamWaiver(version) {
196
+ const whole = Number.isFinite(version) ? Math.max(0, Math.floor(version)) : 0;
197
+ const next = update({ redTeamWaiverVersion: whole });
198
+ return loadUiState().redTeamWaiverVersion === whole ? whole : next.redTeamWaiverVersion;
199
+ }
200
+ /**
201
+ * `ARAGON_REDTEAM=0` in its kill-switch spellings, read from the LIVE environment.
202
+ *
203
+ * A SECOND READER OF THE SAME RULE, and only for `cli.tsx`'s `preAction` hook, which runs
204
+ * BEFORE `loadConfig` (so the folded `redteam.enabled` does not exist yet) and must refuse
205
+ * `--redteam` in a session the environment killed. `config/env.ts` remains the place the value
206
+ * lands in the resolved config; the two agree because the value set here is the one it accepts.
207
+ */
208
+ export function isRedTeamEnvOff(env = process.env) {
209
+ const value = env.ARAGON_REDTEAM?.trim().toLowerCase();
210
+ return value === '0' || value === 'false' || value === 'off' || value === 'no';
211
+ }
174
212
  /**
175
213
  * Migration-only: fill in fields that are still at their default, and never
176
214
  * overwrite a value already here. A second import — after a half-finished
@@ -90,6 +90,13 @@ export interface BridgeServerOptions {
90
90
  ports: BridgeServerPorts;
91
91
  /** Names a caller tool may not shadow. Defaults to host + subagent tool names. */
92
92
  reservedToolNames?: ReadonlySet<string>;
93
+ /**
94
+ * `--gene` / `--gene-learn` (gene-bank RV-13): this run registers the four `gene_*` tools, so
95
+ * their names are reserved like any other host tool. Absent (the default) the names are free: a
96
+ * headless run does not enable the library, and rejecting a caller tool called `gene_search`
97
+ * would break an integration that existed before the feature did.
98
+ */
99
+ geneEnabled?: boolean;
93
100
  /**
94
101
  * The one structured audit line per decision (headless-host-bridge section 2.5).
95
102
  *
@@ -23,7 +23,7 @@
23
23
  * model cannot see it and the caller can.
24
24
  */
25
25
  import { errorResult } from '@aragon-agent/core';
26
- import { HOST_TOOL_NAMES, MEMORY_TOOL_NAMES } from '../../tools/index.js';
26
+ import { GENE_TOOL_NAMES, HOST_TOOL_NAMES, MEMORY_TOOL_NAMES } from '../../tools/index.js';
27
27
  import { TEAM_SUBAGENT_TOOL_NAMES } from '@aragon-agent/tui/model/team/limits';
28
28
  import { BRIDGE_LIMITS } from './limits.js';
29
29
  import { createPendingTable } from './pending.js';
@@ -38,9 +38,13 @@ export function createBridgeServer(options) {
38
38
  // run NEVER registers them (agent-memory D-20), so reserving their names would only reject a
39
39
  // caller tool called `memory_search` - a perfectly legitimate integration (RV-5).
40
40
  const memoryNames = new Set(MEMORY_TOOL_NAMES);
41
+ // The gene tools are in `HOST_TOOL_NAMES` too (the partition test in `tools.test.ts` forces it),
42
+ // but `aragon exec` registers them ONLY under `--gene`; by default they are subtracted exactly
43
+ // as the memory names are, and `--gene` leaves them reserved (RV-13).
44
+ const geneNames = new Set(options.geneEnabled === true ? [] : GENE_TOOL_NAMES);
41
45
  const reserved = options.reservedToolNames ??
42
46
  new Set([
43
- ...HOST_TOOL_NAMES.filter((name) => !memoryNames.has(name)),
47
+ ...HOST_TOOL_NAMES.filter((name) => !memoryNames.has(name) && !geneNames.has(name)),
44
48
  ...TEAM_SUBAGENT_TOOL_NAMES,
45
49
  ]);
46
50
  let open = true;
@@ -66,6 +66,10 @@ export function registerExecCommand(program, toFlags, deps) {
66
66
  .option('--on-hook-timeout <mode>', 'deny | allow | error: what an unanswered hook means (bridge only; default deny)')
67
67
  .option('--allow-tool <names>', 'Add tools to the baseline (repeatable; comma-separated accepted)', collect)
68
68
  .option('--deny-tool <names>', 'Remove tools; wins over --allow-tool (repeatable; comma-separated accepted)', collect)
69
+ // OPT-IN, NEVER DEFAULT (gene-bank D-40): an automation path has to be reproducible, so the
70
+ // library and its learning are off unless asked for. `--gene-learn` implies `--gene`.
71
+ .option('--gene', 'Enable the Gene Bank (read-only use) for this run')
72
+ .option('--gene-learn', 'Enable the Gene Bank and let this run learn (implies --gene)')
69
73
  .option('--append-system-prompt <text>', 'Append text to the builtin system prompt')
70
74
  .option('--append-system-prompt-file <path>', 'Append the contents of a file')
71
75
  // HIDDEN, AND KEPT ONLY SO A GUESS IS NOT PUNISHED (P2-1 / D-16). The root
@@ -296,6 +296,8 @@ function createBridgeRuntime(args) {
296
296
  sessionId: args.sessionId,
297
297
  decisionTimeoutMs: args.options.decisionTimeoutMs,
298
298
  callerToolTimeoutMs: args.options.callerToolTimeoutMs,
299
+ // `--gene` registers the four gene tools, so a caller tool may not shadow their names (RV-13).
300
+ ...(args.options.gene ? { geneEnabled: true } : {}),
299
301
  ports: {
300
302
  applyCallerTools: (specs) => {
301
303
  const target = box.server;