@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
@@ -0,0 +1,217 @@
1
+ /**
2
+ * Tool-gene validation T1-T7 (gene-bank spec 10.7.2, 11.4; RV-1, I-15, I-25, TH-1, TH-13).
3
+ *
4
+ * ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
5
+ *
6
+ * T1 schema input / output schemas the in-house validator can honour, argv placeholders
7
+ * that replace whole elements and name a declared input, versions in order
8
+ * T2 risk RECOMPUTED by the static screen; the model's own claim is ignored. `high`
9
+ * waits for a person
10
+ * T3 permission the declared permissions must cover the derived ones; `network` only when the
11
+ * user allows tool genes the network
12
+ * T4 example run by `probe.ts` ONLY for a read-only whitelisted command; every other kind
13
+ * waits for a person who read the full text (RV-1). Never "static screen passed"
14
+ * T5 env commands resolvable on PATH, os matches
15
+ * T6 contract the actual output parses under `outputSchema` (needs a probe run)
16
+ * T7 composite built-in tool names only, never `gene_run`, <= 6 steps; NEVER executed here
17
+ *
18
+ * Nothing in this file spawns a process: execution is `probe.ts`'s monopoly, and this module only
19
+ * calls it and folds the answer into checks.
20
+ */
21
+ import { canonicalJson } from '@aragon-agent/tui/model/gene/validate';
22
+ import { checkSchemaShape, validateAgainstSchema } from '../../schema-lite.js';
23
+ import { missingPermissions, screenToolExec } from '../../tool-screen.js';
24
+ import { autoProbe } from '../probe.js';
25
+ import { failCheck, okCheck, skippedCheck, splitIssues, staticCheck, trustCheck } from './common.js';
26
+ const WHOLE_PLACEHOLDER = /^\{\{([A-Za-z_][A-Za-z0-9_]{0,40})\}\}$/;
27
+ const ANY_PLACEHOLDER = /\{\{[^}]*\}\}/;
28
+ function toolPayload(content) {
29
+ const raw = content.payload;
30
+ if (typeof raw !== 'object' || raw === null)
31
+ return null;
32
+ const p = raw;
33
+ return typeof p.exec === 'object' && p.exec !== null ? p : null;
34
+ }
35
+ // ---------------------------------------------------------------------------
36
+ // T1 - schema
37
+ // ---------------------------------------------------------------------------
38
+ function placeholderProblems(payload) {
39
+ const problems = [];
40
+ const argv = payload.exec.kind === 'command' ? payload.exec.argv : payload.exec.kind === 'script' ? payload.exec.args : [];
41
+ const declared = payload.inputSchema?.properties ?? {};
42
+ for (const element of argv) {
43
+ const whole = WHOLE_PLACEHOLDER.exec(element);
44
+ if (whole === null && ANY_PLACEHOLDER.test(element))
45
+ problems.push('a placeholder is part of a larger argument');
46
+ else if (whole !== null && !(whole[1] in declared))
47
+ problems.push('a placeholder names no declared input');
48
+ }
49
+ return problems;
50
+ }
51
+ function versionProblems(payload, previous) {
52
+ if (previous === null || typeof previous.interfaceVersion !== 'number')
53
+ return [];
54
+ if (payload.interfaceVersion < previous.interfaceVersion)
55
+ return ['interfaceVersion went down'];
56
+ const changed = canonicalJson(payload.inputSchema) !== canonicalJson(previous.inputSchema) ||
57
+ canonicalJson(payload.outputSchema) !== canonicalJson(previous.outputSchema);
58
+ return changed && payload.interfaceVersion === previous.interfaceVersion
59
+ ? ['a schema changed without an interfaceVersion bump']
60
+ : [];
61
+ }
62
+ function checkSchemas(ctx, payload, owned, at) {
63
+ if (payload === null)
64
+ return failCheck('TOOL_SCHEMA_INVALID', at, 'T1 payload.exec is missing');
65
+ const problems = [
66
+ ...owned.map((i) => i.path),
67
+ ...checkSchemaShape(payload.inputSchema).map((i) => `inputSchema: ${i.message}`),
68
+ ...checkSchemaShape(payload.outputSchema).map((i) => `outputSchema: ${i.message}`),
69
+ ...placeholderProblems(payload),
70
+ ...versionProblems(payload, ctx.target?.content ? toolPayload(ctx.target.content) : null),
71
+ ];
72
+ const unique = [...new Set(problems)];
73
+ return unique.length === 0 ? okCheck('T1', at) : failCheck('TOOL_SCHEMA_INVALID', at, `T1 ${unique.slice(0, 5).join('; ')}`);
74
+ }
75
+ // ---------------------------------------------------------------------------
76
+ // T2 / T3 - risk and permissions
77
+ // ---------------------------------------------------------------------------
78
+ function deriveFacts(payload, scriptText) {
79
+ const screened = screenToolExec(payload.exec, scriptText);
80
+ return { risk: screened.risk, permissions: screened.permissions, reasons: screened.reasons };
81
+ }
82
+ function checkRisk(payload, derived, at) {
83
+ if (derived.risk === 'high') {
84
+ return failCheck('GENE_TOOL_HIGH_RISK', at, `T2 derived risk is high (${derived.reasons.slice(0, 3).join(', ')})`);
85
+ }
86
+ const claimed = payload.risk === derived.risk ? '' : `; claimed ${String(payload.risk)} corrected`;
87
+ return okCheck('T2', at, `derived risk ${derived.risk}${claimed}`);
88
+ }
89
+ function checkPermissions(ctx, payload, derived, at) {
90
+ const declared = Array.isArray(payload.requiredPermissions) ? payload.requiredPermissions : [];
91
+ const wantsNetwork = derived.permissions.includes('network') || declared.includes('network');
92
+ if (wantsNetwork && !ctx.ports.config.toolsAllowNetwork) {
93
+ return [failCheck('TOOL_NETWORK_FORBIDDEN', at, 'T3 the tool needs the network and gene.toolsAllowNetwork is off')];
94
+ }
95
+ const missing = missingPermissions(declared, derived.permissions);
96
+ if (missing.length > 0) {
97
+ return [failCheck('TOOL_PERMISSION_UNDECLARED', at, `T3 undeclared permission(s): ${missing.join(', ')}`)];
98
+ }
99
+ return [okCheck('T3', at)];
100
+ }
101
+ // ---------------------------------------------------------------------------
102
+ // T5 - environment
103
+ // ---------------------------------------------------------------------------
104
+ function narrowedOs(content, envOs) {
105
+ if (envOs === undefined || envOs.length === 0)
106
+ return undefined;
107
+ const current = content.applicability?.os;
108
+ const within = current !== undefined && current.length > 0 && current.every((o) => envOs.includes(o));
109
+ return within ? undefined : [...envOs];
110
+ }
111
+ function checkEnvironment(ctx, payload, at) {
112
+ const env = payload.env ?? {};
113
+ if (env.os !== undefined && env.os.length > 0 && !env.os.includes(ctx.ports.env.os)) {
114
+ return [failCheck('TOOL_ENV_MISSING', at, `T5 the tool does not support ${ctx.ports.env.os}`)];
115
+ }
116
+ const commands = [...(env.commands ?? [])];
117
+ if (payload.exec.kind === 'command' && typeof payload.exec.argv[0] === 'string')
118
+ commands.push(payload.exec.argv[0]);
119
+ if (commands.length === 0)
120
+ return [okCheck('T5', at)];
121
+ const onPath = ctx.ports.commandOnPath;
122
+ if (onPath === undefined)
123
+ return [skippedCheck('T5', at, 'no_path_probe')];
124
+ const absent = [...new Set(commands)].filter((cmd) => !onPath(cmd));
125
+ return absent.length === 0
126
+ ? [okCheck('T5', at)]
127
+ : [failCheck('TOOL_ENV_MISSING', at, `T5 ${absent.length} required command(s) not on PATH`)];
128
+ }
129
+ // ---------------------------------------------------------------------------
130
+ // T7 - composite
131
+ // ---------------------------------------------------------------------------
132
+ function compositeProblems(ctx, steps) {
133
+ const known = ctx.ports.hostToolNames;
134
+ if (known === undefined)
135
+ return ['the host tool list is unavailable, so the steps cannot be verified'];
136
+ const problems = [];
137
+ if (steps.length > 6)
138
+ problems.push('more than 6 steps');
139
+ for (const step of steps) {
140
+ if (step.tool === 'gene_run')
141
+ problems.push('a step calls gene_run (recursion)');
142
+ else if (!known.includes(step.tool))
143
+ problems.push('a step names a tool that is not built in');
144
+ const schema = ctx.ports.hostToolSchema?.(step.tool);
145
+ if (schema !== undefined && validateAgainstSchema(schema, step.args).length > 0) {
146
+ problems.push('a step argument does not fit its tool');
147
+ }
148
+ }
149
+ return [...new Set(problems)];
150
+ }
151
+ function checkComposite(ctx, payload, at) {
152
+ if (payload.exec.kind !== 'composite')
153
+ return skippedCheck('T7', at, 'not_a_composite');
154
+ const problems = compositeProblems(ctx, payload.exec.steps);
155
+ return problems.length === 0 ? okCheck('T7', at) : failCheck('TOOL_SCHEMA_INVALID', at, `T7 ${problems.join('; ')}`);
156
+ }
157
+ async function runProbe(ctx, content, at) {
158
+ const subject = {
159
+ geneId: ctx.geneId ?? 'x',
160
+ content,
161
+ ...(ctx.scriptText === undefined ? {} : { scriptText: ctx.scriptText }),
162
+ };
163
+ const outcome = await autoProbe(subject, ctx.ports.config, ctx.probeDeps ?? {});
164
+ if (outcome.ok)
165
+ return { checks: outcome.run.checks, autoProbed: true };
166
+ const detail = `T4 waits for a person to approve a live probe (${outcome.reasons.slice(0, 2).join(', ')})`;
167
+ return {
168
+ checks: [failCheck('GENE_PROBE_NEEDS_APPROVAL', at, detail), skippedCheck('T6', at, 'awaiting_probe')],
169
+ needsHuman: outcome.needsHuman,
170
+ autoProbed: false,
171
+ };
172
+ }
173
+ // ---------------------------------------------------------------------------
174
+ // Entry point
175
+ // ---------------------------------------------------------------------------
176
+ const isPayloadSchemaIssue = (issue) => issue.code === 'GENE_INVALID_CONTENT' && issue.path.startsWith('payload');
177
+ export async function validateTool(ctx, report) {
178
+ const at = ctx.ports.now();
179
+ const { picked, rest } = splitIssues(report.issues, isPayloadSchemaIssue);
180
+ const payload = toolPayload(ctx.content);
181
+ const checks = [staticCheck(rest, at), checkSchemas(ctx, payload, picked, at)];
182
+ const usage = { in: 0, out: 0 };
183
+ const trust = trustCheck(ctx.evidence, at);
184
+ if (payload === null)
185
+ return { checks: [...checks, trust.check], usage };
186
+ const derived = deriveFacts(payload, ctx.scriptText);
187
+ const os = narrowedOs(ctx.content, payload.env?.os);
188
+ if (os !== undefined)
189
+ derived.applicabilityOs = os;
190
+ const risk = checkRisk(payload, derived, at);
191
+ checks.push(risk, ...checkPermissions(ctx, payload, derived, at), ...checkEnvironment(ctx, payload, at), checkComposite(ctx, payload, at));
192
+ const blocked = checks.some((c) => !c.ok && c.code !== 'GENE_TOOL_HIGH_RISK');
193
+ const result = { checks, usage, derived, autoProbed: false };
194
+ if (blocked) {
195
+ checks.push(skippedCheck('T4', at, 'an earlier check failed'));
196
+ }
197
+ else {
198
+ const probe = await runProbe(ctx, ctx.content, at);
199
+ checks.push(...probe.checks);
200
+ result.autoProbed = probe.autoProbed;
201
+ if (probe.needsHuman !== undefined)
202
+ result.needsHuman = probe.needsHuman;
203
+ }
204
+ if (derived.risk === 'high')
205
+ result.needsHuman = 'high_risk_tool';
206
+ checks.push(trust.check);
207
+ if (trust.needsHuman !== undefined && result.needsHuman === undefined)
208
+ result.needsHuman = trust.needsHuman;
209
+ return result;
210
+ }
211
+ /** The content with the RECOMPUTED risk written over the model's claim (T2). */
212
+ export function withDerivedRisk(content, derived) {
213
+ const payload = toolPayload(content);
214
+ if (payload === null)
215
+ return content;
216
+ return { ...content, payload: { ...payload, risk: derived.risk } };
217
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * The input and output shapes of candidate validation (gene-bank spec 10.7).
3
+ *
4
+ * ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`. TYPES ONLY.
5
+ *
6
+ * ONE CONTEXT IN, ONE PLAIN-DATA OUTCOME OUT. `CandidateContext` carries everything a validator
7
+ * may look at (the draft, the evidence snapshotted at enqueue, the ports); `CandidateOutcome`
8
+ * carries the per-check results and the routing the curator must follow. Nothing here holds a
9
+ * handle: an outcome can be logged, stored or compared as it is.
10
+ *
11
+ * THE VERDICT IS A ROUTING FACT, NOT A SUMMARY OF `validation.ok`. A candidate that waits for a
12
+ * person (`needs_human`) or that must become a merge / revise instead of a create (`convert`)
13
+ * also has `validation.ok === false`, so a caller that ignores the verdict still cannot publish
14
+ * it; the verdict only tells the curator which door to use instead of the reject door.
15
+ */
16
+ import type { GeneClass, GeneContent, GeneEvidence, GeneHead, GeneNeedsHuman, GenePermission, GeneProbation, GeneScope, GeneToolRisk, GeneType, GeneValidation } from '@aragon-agent/tui/model/gene/types';
17
+ import type { ConflictDecision } from '../conflicts.js';
18
+ import type { ProbeDeps } from '../probe.js';
19
+ import type { ValidatorPorts } from './ports.js';
20
+ export interface CandidateContext {
21
+ ports: ValidatorPorts;
22
+ type: GeneType;
23
+ scope: GeneScope;
24
+ /** The draft after the curator completed it. Never mutated. */
25
+ content: GeneContent;
26
+ /**
27
+ * The evidence snapshotted when the proposal was enqueued, refs already minted (K2 corpus).
28
+ * The validators never touch the filesystem to find it.
29
+ */
30
+ evidence: readonly GeneEvidence[];
31
+ /** The existing id for a revise, the minted id for a create; used for self-exclusion. */
32
+ geneId?: string;
33
+ /** The class the draft asked for. Anything but `standard` is demoted for an agent author. */
34
+ requestedClass?: GeneClass;
35
+ /** For a revise: the head being replaced and, when known, its served content. */
36
+ target?: {
37
+ head: GeneHead;
38
+ content?: GeneContent;
39
+ };
40
+ /** Tier-3 text of a `script` tool (the impl evidence), for the risk screen and the probe. */
41
+ scriptText?: string;
42
+ /** S3 task texts: positives come from the source task, negatives from unrelated work. */
43
+ triggerProbe?: {
44
+ positives: readonly string[];
45
+ negatives?: readonly string[];
46
+ };
47
+ /** Test seams for the one module that executes anything. Production passes nothing. */
48
+ probeDeps?: ProbeDeps;
49
+ }
50
+ /** What one type's validator returns; `index.ts` folds it into a `CandidateOutcome`. */
51
+ export interface TypeResult {
52
+ checks: GeneValidation['checks'];
53
+ needsHuman?: GeneNeedsHuman['reason'];
54
+ conflict?: ConflictDecision;
55
+ probation?: GeneProbation;
56
+ forceProbation?: boolean;
57
+ derived?: DerivedTool;
58
+ autoProbed?: boolean;
59
+ usage: {
60
+ in: number;
61
+ out: number;
62
+ };
63
+ }
64
+ /** Facts the validators RECOMPUTED, so the curator can overwrite what the model claimed. */
65
+ export interface DerivedTool {
66
+ risk: GeneToolRisk;
67
+ permissions: GenePermission[];
68
+ /** `applicability.os` narrowed to the tool's own `env.os` (T5), when that differs. */
69
+ applicabilityOs?: Array<'win32' | 'darwin' | 'linux'>;
70
+ reasons: string[];
71
+ }
72
+ export type CandidateVerdict = 'pass' | 'fail' | 'needs_human' | 'convert';
73
+ export interface CandidateOutcome {
74
+ validation: GeneValidation;
75
+ verdict: CandidateVerdict;
76
+ needsHuman?: GeneNeedsHuman['reason'];
77
+ conflict?: ConflictDecision;
78
+ probation?: GeneProbation;
79
+ /** A model check could not run for lack of positives / a model: the gene must be on probation. */
80
+ forceProbation: boolean;
81
+ /** The class the gene will be stored with (an agent draft of `oversight` is demoted). */
82
+ class: GeneClass;
83
+ derived?: DerivedTool;
84
+ /** True when the tool was executed by the curator itself (read-only whitelist). */
85
+ autoProbed: boolean;
86
+ usage: {
87
+ in: number;
88
+ out: number;
89
+ };
90
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Building the validators' ports from what the curator already has (gene-bank spec 10.7).
3
+ *
4
+ * ASCII ONLY - the whole `gene/` tree is in `glyphs.test.ts::inScope`.
5
+ *
6
+ * The validators reach the world only through `ValidatorPorts` (so they stay testable with
7
+ * nothing else in the process). This file is the production binding: library reads for evidence,
8
+ * lookups and neighbours; the model port for the four model checks; and the EFFECTIVE config for
9
+ * the two settings the validators read (`toolsAllowNetwork`, `probeMode`).
10
+ *
11
+ * THE CONFIG IS READ PER CALL, through the switch guard, so a user who turns `probeMode` off in
12
+ * another process stops the next probe, and `toolsAllowNetwork` can only be tightened by the
13
+ * persisted file, never widened (`stricterGeneConfig`).
14
+ *
15
+ * NO MODEL PORT, NO MODEL CHECK. When the port has no `completeJson`, `modelJson` is left out and
16
+ * the validators record K4 / K5 / S3 / S4 as SKIPPED - never as passed (10.7). A skipped model
17
+ * check is how a missing fast model degrades validation instead of blocking it.
18
+ */
19
+ import type { EnvFingerprint, GeneScope } from '@aragon-agent/tui/model/gene/types';
20
+ import type { CuratorModelPort } from './agent.js';
21
+ import type { CuratorLibrary } from './library.js';
22
+ import type { SwitchGuard } from './switches.js';
23
+ import type { CuratorTaskContext } from './task-context.js';
24
+ import type { ValidatorPorts } from './validate/index.js';
25
+ export interface ValidatorPortsDeps {
26
+ library: CuratorLibrary;
27
+ model: Pick<CuratorModelPort, 'completeJson'>;
28
+ switches: Pick<SwitchGuard, 'effective'>;
29
+ env(): EnvFingerprint;
30
+ now(): number;
31
+ knownSecrets(): readonly string[];
32
+ commandOnPath?(command: string): boolean;
33
+ hostToolNames?(): readonly string[];
34
+ hostToolSchema?(name: string): unknown;
35
+ projectRoot?(scope: GeneScope): string | undefined;
36
+ projectLabels?(): readonly string[];
37
+ }
38
+ export declare function createValidatorPortsFactory(deps: ValidatorPortsDeps): (ctx: CuratorTaskContext) => Promise<ValidatorPorts>;
@@ -0,0 +1,29 @@
1
+ export function createValidatorPortsFactory(deps) {
2
+ return async () => {
3
+ const config = await deps.switches.effective();
4
+ const complete = deps.model.completeJson;
5
+ const hostToolNames = deps.hostToolNames?.();
6
+ const ports = {
7
+ now: deps.now,
8
+ readEvidence: (scope, geneId, ref) => deps.library.readEvidence(scope, geneId, ref),
9
+ async lookupGene(id) {
10
+ const found = await deps.library.findHead(id);
11
+ if (found === null || found.read.head.currentVersion === null)
12
+ return null;
13
+ const version = await deps.library.readVersion(found.scope, id, found.read.head.currentVersion);
14
+ return version === null ? null : { head: found.read.head, version };
15
+ },
16
+ neighbours: (scope, type, brief, k) => deps.library.neighbours(scope, type, brief, k),
17
+ config: { toolsAllowNetwork: config.toolsAllowNetwork, probeMode: config.probeMode },
18
+ env: deps.env(),
19
+ knownSecrets: deps.knownSecrets(),
20
+ ...(complete === undefined ? {} : { modelJson: (request) => complete.call(deps.model, request) }),
21
+ ...(deps.commandOnPath === undefined ? {} : { commandOnPath: deps.commandOnPath }),
22
+ ...(hostToolNames === undefined ? {} : { hostToolNames }),
23
+ ...(deps.hostToolSchema === undefined ? {} : { hostToolSchema: deps.hostToolSchema }),
24
+ ...(deps.projectRoot === undefined ? {} : { projectRoot: deps.projectRoot }),
25
+ ...(deps.projectLabels === undefined ? {} : { projectLabels: deps.projectLabels() }),
26
+ };
27
+ return ports;
28
+ };
29
+ }
@@ -0,0 +1,209 @@
1
+ import type { GeneConfig } from '@aragon-agent/tui/model/config/schema';
2
+ import type { GeneType } from '@aragon-agent/tui/model/gene/types';
3
+ import type { ManagerCore } from './manager-context.js';
4
+ declare const CONFIG_SOURCES: readonly ["default", "file", "env"];
5
+ declare const POLICY_SOURCES: readonly ["none", "user", "repo", "unreadable"];
6
+ type ConfigSource = (typeof CONFIG_SOURCES)[number];
7
+ type ConfigKey = Exclude<keyof GeneConfig, 'teamPath'>;
8
+ /**
9
+ * Every string a bundle may hold other than a `projectRef` / `holderRef`. The tests assert that a
10
+ * generated bundle uses nothing outside this set, which keeps the vocabulary the single place a
11
+ * new word has to be added.
12
+ */
13
+ export declare const DIAG_STRING_VOCABULARY: ReadonlySet<string>;
14
+ /** The last eight hex characters of a project key (`<slug>-<8 hex>`), or null. */
15
+ export declare function projectRefOf(key: string): string | null;
16
+ export interface DiagProjectPolicy {
17
+ /** Eight hex characters. A full key or a label is dropped, not shortened. */
18
+ projectRef: string;
19
+ learn: boolean;
20
+ source: (typeof POLICY_SOURCES)[number];
21
+ }
22
+ /** What the collector hands over: loosely typed on purpose, because the serializer validates. */
23
+ export interface DiagFacts {
24
+ now: number;
25
+ versions: {
26
+ cli?: unknown;
27
+ core?: unknown;
28
+ tui?: unknown;
29
+ node?: unknown;
30
+ };
31
+ platform: {
32
+ os?: unknown;
33
+ arch?: unknown;
34
+ };
35
+ config: {
36
+ values?: Partial<Record<ConfigKey, unknown>>;
37
+ sources?: Partial<Record<ConfigKey, unknown>>;
38
+ teamPathSet?: unknown;
39
+ };
40
+ envKillSwitch?: unknown;
41
+ projectPolicy?: Partial<DiagProjectPolicy> | null;
42
+ scopes?: DiagScopeFacts[];
43
+ scopesOmitted?: unknown;
44
+ library?: {
45
+ published?: unknown;
46
+ pinned?: unknown;
47
+ candidates?: unknown;
48
+ archivedBytes?: unknown;
49
+ };
50
+ queue?: {
51
+ pending?: unknown;
52
+ claimed?: unknown;
53
+ dead?: unknown;
54
+ done?: unknown;
55
+ oldestPendingAgeSec?: unknown;
56
+ oldestClaimedAgeSec?: unknown;
57
+ };
58
+ curator?: {
59
+ lease?: unknown;
60
+ holderPid?: unknown;
61
+ kind?: unknown;
62
+ heartbeatAgeSec?: unknown;
63
+ };
64
+ tokens?: {
65
+ today?: unknown;
66
+ budget?: unknown;
67
+ };
68
+ recent?: Array<{
69
+ t?: unknown;
70
+ ev?: unknown;
71
+ type?: unknown;
72
+ }>;
73
+ orphans?: {
74
+ orphanScopes?: unknown;
75
+ unrecordedScopes?: unknown;
76
+ };
77
+ unavailable?: readonly string[];
78
+ }
79
+ export interface DiagScopeFacts {
80
+ kind?: unknown;
81
+ /** Only the project key is ever looked at, and only to cut its last eight characters. */
82
+ projectKey?: unknown;
83
+ /** How many scopes of this kind were merged into the entry (tasks and teams are merged). */
84
+ scopeCount?: unknown;
85
+ current?: unknown;
86
+ published?: unknown;
87
+ pinned?: unknown;
88
+ candidates?: unknown;
89
+ archived?: unknown;
90
+ archivedBytes?: unknown;
91
+ index?: {
92
+ present?: unknown;
93
+ generation?: unknown;
94
+ rows?: unknown;
95
+ journalBytes?: unknown;
96
+ builtAgeSec?: unknown;
97
+ };
98
+ }
99
+ export interface DiagBundle {
100
+ schema: 1;
101
+ generatedAt: number;
102
+ versions: Record<'cli' | 'core' | 'tui' | 'node', [number, number, number] | null>;
103
+ platform: {
104
+ os: string;
105
+ arch: string;
106
+ };
107
+ config: {
108
+ values: Record<string, number | boolean | string>;
109
+ sources: Record<string, ConfigSource>;
110
+ teamPathSet: boolean;
111
+ };
112
+ switches: {
113
+ envKillSwitch: boolean;
114
+ };
115
+ projectPolicy: DiagProjectPolicy | null;
116
+ library: {
117
+ published: Record<GeneType, number>;
118
+ pinned: Record<GeneType, number>;
119
+ candidates: Record<GeneType, number>;
120
+ archivedBytes: number;
121
+ };
122
+ scopes: Array<{
123
+ kind: string;
124
+ projectRef: string | null;
125
+ scopeCount: number;
126
+ current: boolean;
127
+ published: Record<GeneType, number>;
128
+ pinned: Record<GeneType, number>;
129
+ candidates: number;
130
+ archived: number;
131
+ archivedBytes: number;
132
+ index: {
133
+ present: boolean;
134
+ generation: number;
135
+ rows: number;
136
+ journalBytes: number;
137
+ builtAgeSec: number | null;
138
+ };
139
+ }>;
140
+ scopesOmitted: number;
141
+ queue: {
142
+ pending: number;
143
+ claimed: number;
144
+ dead: number;
145
+ done: number;
146
+ oldestPendingAgeSec: number | null;
147
+ oldestClaimedAgeSec: number | null;
148
+ };
149
+ curator: {
150
+ lease: string;
151
+ holderRef: string | null;
152
+ kind: string | null;
153
+ heartbeatAgeSec: number | null;
154
+ };
155
+ tokens: {
156
+ today: number;
157
+ budget: number;
158
+ };
159
+ recent: Array<{
160
+ t: number;
161
+ ev: string;
162
+ type: string | null;
163
+ }>;
164
+ orphans: {
165
+ orphanScopes: number;
166
+ unrecordedScopes: number;
167
+ };
168
+ unavailable: string[];
169
+ notes: string[];
170
+ }
171
+ /**
172
+ * Build the bundle from collected facts. PURE. Every value in the result went through a coercer
173
+ * above; see the file header for what that rules out.
174
+ */
175
+ export declare function buildDiagBundle(facts: DiagFacts): DiagBundle;
176
+ /** The text that is written to the file: stable key order, two-space indent, trailing newline. */
177
+ export declare function renderDiagBundle(bundle: DiagBundle): string;
178
+ export declare const RECENT_RUNS = 50;
179
+ /** Project scopes listed individually; the rest are only counted. */
180
+ export declare const SCOPES_LISTED_MAX = 50;
181
+ export interface DiagOptions {
182
+ /** This session's project policy (I3-5). Optional: absent = no policy information. */
183
+ projectPolicy?: DiagProjectPolicy | null;
184
+ /** The `gene` object of the persisted config file, to tell file values from defaults. */
185
+ configFile?: () => Record<string, unknown> | null;
186
+ /** Installed versions as `x.y.z` strings. Default: read from the installed packages. */
187
+ versions?: () => DiagFacts['versions'];
188
+ /** Is the `ARAGON_GENE=0` kill switch set? Default: read the environment. */
189
+ envKillSwitch?: () => boolean;
190
+ }
191
+ /** Gather the facts of a bundle from the live library. Never throws, never writes. */
192
+ export declare function collectDiagFacts(core: ManagerCore, options?: DiagOptions): Promise<DiagFacts>;
193
+ /** Collect and serialise in one step. */
194
+ export declare function createDiagBundle(core: ManagerCore, options?: DiagOptions): Promise<DiagBundle>;
195
+ export type DiagWrite = {
196
+ ok: true;
197
+ path: string;
198
+ } | {
199
+ ok: false;
200
+ reason: 'exists' | 'io';
201
+ };
202
+ /** `<genes>/diag/gene-diag.json`: where `/gene diag` writes when no file is named. */
203
+ export declare function defaultDiagFile(root?: string): string;
204
+ /**
205
+ * Write the bundle to `path`. A file somebody else named is never overwritten unless `overwrite`:
206
+ * `--out README.md` must not destroy a README. Never throws.
207
+ */
208
+ export declare function writeDiagFile(path: string, bundle: DiagBundle, overwrite: boolean): Promise<DiagWrite>;
209
+ export {};