opencode-swarm 7.0.0-beta.1 → 7.0.0

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 (541) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1265 -40
  3. package/dist/__tests__/acknowledge-spec-drift.test.d.ts +1 -0
  4. package/dist/__tests__/cli-version.adversarial.test.d.ts +1 -0
  5. package/dist/__tests__/cli-version.test.d.ts +1 -0
  6. package/dist/__tests__/conflict-resolution.test.d.ts +1 -0
  7. package/dist/__tests__/convene-general-council.test.d.ts +10 -0
  8. package/dist/__tests__/critic_drift_verifier-whitelist.test.d.ts +1 -0
  9. package/dist/__tests__/critic_hallucination_verifier-whitelist.test.d.ts +1 -0
  10. package/dist/__tests__/disagreement-detector.test.d.ts +7 -0
  11. package/dist/__tests__/evidence-lock.adversarial.test.d.ts +8 -0
  12. package/dist/__tests__/evidence-lock.test.d.ts +6 -0
  13. package/dist/__tests__/gate-evidence.adversarial.test.d.ts +7 -0
  14. package/dist/__tests__/general-council-service.test.d.ts +7 -0
  15. package/dist/__tests__/lint-spec.test.d.ts +1 -0
  16. package/dist/__tests__/preflight-phase.test.d.ts +1 -0
  17. package/dist/__tests__/qa-gate-hardening.test.d.ts +12 -0
  18. package/dist/__tests__/req-coverage.test.d.ts +1 -0
  19. package/dist/__tests__/security-adversarial.test.d.ts +1 -0
  20. package/dist/__tests__/sounding-board-parser.test.d.ts +1 -0
  21. package/dist/__tests__/spec-hash.test.d.ts +1 -0
  22. package/dist/__tests__/spec-schema.test.d.ts +1 -0
  23. package/dist/__tests__/web-search-provider.test.d.ts +6 -0
  24. package/dist/__tests__/write-drift-evidence-requirement-coverage.test.d.ts +4 -0
  25. package/dist/adversarial-tests.test.d.ts +1 -0
  26. package/dist/agents/architect-permission.adversarial.test.d.ts +5 -0
  27. package/dist/agents/architect.commands-list.adversarial.test.d.ts +1 -0
  28. package/dist/agents/architect.commands-list.test.d.ts +1 -0
  29. package/dist/agents/architect.d.ts +57 -0
  30. package/dist/agents/architect.dark-matter.test.d.ts +1 -0
  31. package/dist/agents/architect.designer-gate.test.d.ts +1 -0
  32. package/dist/agents/coder.d.ts +2 -0
  33. package/dist/agents/council-member.d.ts +30 -0
  34. package/dist/agents/council-member.test.d.ts +8 -0
  35. package/dist/agents/council-moderator.d.ts +20 -0
  36. package/dist/agents/critic.d.ts +34 -0
  37. package/dist/agents/curator-agent.d.ts +14 -0
  38. package/dist/agents/designer.d.ts +2 -0
  39. package/dist/agents/docs.d.ts +2 -0
  40. package/dist/agents/explorer-consumer-contract.test.d.ts +1 -0
  41. package/dist/agents/explorer-role-boundary.test.d.ts +1 -0
  42. package/dist/agents/explorer.d.ts +5 -0
  43. package/dist/agents/index.d.ts +52 -0
  44. package/dist/agents/reviewer.d.ts +5 -0
  45. package/dist/agents/sme.d.ts +2 -0
  46. package/dist/agents/test-engineer.adversarial.test.d.ts +5 -0
  47. package/dist/agents/test-engineer.d.ts +2 -0
  48. package/dist/agents/test-engineer.security.test.d.ts +1 -0
  49. package/dist/background/circuit-breaker.d.ts +149 -0
  50. package/dist/background/event-bus.d.ts +60 -0
  51. package/dist/background/evidence-summary-integration.d.ts +73 -0
  52. package/dist/background/index.d.ts +22 -0
  53. package/dist/background/manager.d.ts +122 -0
  54. package/dist/background/plan-sync-worker.d.ts +122 -0
  55. package/dist/background/queue.d.ts +117 -0
  56. package/dist/background/status-artifact.d.ts +115 -0
  57. package/dist/background/trigger.d.ts +179 -0
  58. package/dist/background/trigger.vulnerability.test.d.ts +1 -0
  59. package/dist/background/worker.d.ts +92 -0
  60. package/dist/cli/index.d.ts +7 -0
  61. package/dist/cli/index.js +31227 -11423
  62. package/dist/commands/acknowledge-spec-drift.d.ts +5 -0
  63. package/dist/commands/brainstorm.d.ts +13 -0
  64. package/dist/commands/brainstorm.test.d.ts +1 -0
  65. package/dist/commands/checkpoint.d.ts +5 -0
  66. package/dist/commands/close.d.ts +11 -0
  67. package/dist/commands/command-adapters.security.test.d.ts +14 -0
  68. package/dist/commands/commands.test.d.ts +1 -0
  69. package/dist/commands/config.d.ts +5 -0
  70. package/dist/commands/council.d.ts +17 -0
  71. package/dist/commands/council.test.d.ts +4 -0
  72. package/dist/commands/curate.test.d.ts +1 -0
  73. package/dist/commands/doctor.d.ts +17 -0
  74. package/dist/commands/full-auto-config-guard.test.d.ts +7 -0
  75. package/dist/commands/full-auto-discoverability.test.d.ts +8 -0
  76. package/dist/commands/full-auto-registration.test.d.ts +5 -0
  77. package/dist/commands/full-auto-sessionid.test.d.ts +5 -0
  78. package/dist/commands/full-auto.d.ts +10 -0
  79. package/dist/commands/full-auto.regression.test.d.ts +10 -0
  80. package/dist/commands/full-auto.test.d.ts +6 -0
  81. package/dist/commands/index.d.ts +50 -0
  82. package/dist/commands/index.help-text.test.d.ts +1 -0
  83. package/dist/commands/issue.d.ts +13 -0
  84. package/dist/{knowledge.d.ts → commands/knowledge.d.ts} +2 -0
  85. package/dist/commands/pr-review.d.ts +11 -0
  86. package/dist/commands/qa-gates.d.ts +15 -0
  87. package/dist/commands/qa-gates.test.d.ts +1 -0
  88. package/dist/commands/registry-documentation.test.d.ts +1 -0
  89. package/dist/commands/registry-type.test.d.ts +1 -0
  90. package/dist/commands/registry.d.ts +282 -0
  91. package/dist/commands/reset-session.d.ts +7 -0
  92. package/dist/commands/shortcut-routing.test.d.ts +11 -0
  93. package/dist/{sync-plan.d.ts → commands/sync-plan.d.ts} +3 -1
  94. package/dist/commands/turbo-registration.test.d.ts +5 -0
  95. package/dist/commands/turbo-sessionid.test.d.ts +5 -0
  96. package/dist/commands/turbo.regression.test.d.ts +11 -0
  97. package/dist/commands/turbo.test.d.ts +5 -0
  98. package/dist/config/agent-categories.d.ts +12 -0
  99. package/dist/config/cache-paths.d.ts +11 -0
  100. package/dist/config/constants.architect-whitelist.test.d.ts +1 -0
  101. package/dist/config/constants.d.ts +72 -0
  102. package/dist/config/evidence-schema.d.ts +1352 -0
  103. package/dist/config/index.d.ts +11 -0
  104. package/dist/{config.d.ts → config/loader.d.ts} +11 -6
  105. package/dist/config/plan-schema.d.ts +191 -0
  106. package/dist/config/schema.d.ts +1078 -0
  107. package/dist/config/spec-schema.d.ts +113 -0
  108. package/dist/context/role-filter.d.ts +27 -0
  109. package/dist/context/zone-classifier.d.ts +17 -0
  110. package/dist/council/__tests__/council-evidence-writer.adversarial.test.d.ts +6 -0
  111. package/dist/council/council-advisory.d.ts +46 -0
  112. package/dist/council/council-evidence-writer.d.ts +18 -0
  113. package/dist/council/council-service.d.ts +21 -0
  114. package/dist/council/criteria-store.d.ts +9 -0
  115. package/dist/council/disagreement-detector.d.ts +24 -0
  116. package/dist/council/general-council-advisory.d.ts +29 -0
  117. package/dist/council/general-council-service.d.ts +22 -0
  118. package/dist/council/general-council-types.d.ts +98 -0
  119. package/dist/council/types.d.ts +126 -0
  120. package/dist/council/web-search-provider.d.ts +35 -0
  121. package/dist/db/global-db.d.ts +22 -0
  122. package/dist/db/global-db.test.d.ts +7 -0
  123. package/dist/db/index.d.ts +13 -0
  124. package/dist/db/project-db.d.ts +40 -0
  125. package/dist/db/project-db.test.d.ts +4 -0
  126. package/dist/db/qa-gate-profile.d.ts +107 -0
  127. package/dist/db/qa-gate-profile.test.d.ts +4 -0
  128. package/dist/diff/__tests__/semantic-classifier.test.d.ts +1 -0
  129. package/dist/diff/__tests__/summary-generator.test.d.ts +1 -0
  130. package/dist/diff/ast-diff.d.ts +21 -0
  131. package/dist/diff/semantic-classifier.d.ts +59 -0
  132. package/dist/diff/summary-generator.d.ts +33 -0
  133. package/dist/environment/index.d.ts +3 -0
  134. package/dist/environment/profile.d.ts +50 -0
  135. package/dist/environment/prompt-renderer.d.ts +6 -0
  136. package/dist/evidence/index.d.ts +2 -0
  137. package/dist/evidence/lock.d.ts +36 -0
  138. package/dist/evidence/manager.d.ts +78 -0
  139. package/dist/gate-evidence.d.ts +69 -0
  140. package/dist/gate-evidence.test.d.ts +1 -0
  141. package/dist/git/branch.d.ts +70 -0
  142. package/dist/git/index.d.ts +22 -0
  143. package/dist/git/pr.d.ts +28 -0
  144. package/dist/graph/graph-builder.d.ts +39 -0
  145. package/dist/graph/graph-query.d.ts +42 -0
  146. package/dist/graph/graph-store.d.ts +27 -0
  147. package/dist/graph/import-extractor.d.ts +44 -0
  148. package/dist/graph/index.d.ts +16 -0
  149. package/dist/graph/symbol-extractor.d.ts +17 -0
  150. package/dist/graph/types.d.ts +84 -0
  151. package/dist/hooks/__tests__/semantic-diff-injection.test.d.ts +1 -0
  152. package/dist/hooks/adversarial-detector.d.ts +50 -0
  153. package/dist/hooks/agent-activity.d.ts +38 -0
  154. package/dist/hooks/co-change-suggester.d.ts +51 -0
  155. package/dist/hooks/compaction-customizer.d.ts +11 -0
  156. package/dist/hooks/conflict-resolution.d.ts +12 -0
  157. package/dist/hooks/context-budget.d.ts +34 -0
  158. package/dist/hooks/context-scoring.d.ts +70 -0
  159. package/dist/hooks/curator-drift-advisory.test.d.ts +1 -0
  160. package/dist/hooks/curator-drift.d.ts +30 -0
  161. package/dist/hooks/curator-llm-factory.d.ts +20 -0
  162. package/dist/hooks/curator-types.d.ts +103 -0
  163. package/dist/hooks/curator.d.ts +108 -0
  164. package/dist/hooks/dark-matter-detector.d.ts +38 -0
  165. package/dist/hooks/delegation-gate.d.ts +78 -0
  166. package/dist/hooks/delegation-gate.evidence.test.d.ts +4 -0
  167. package/dist/hooks/delegation-gate.getEvidenceTaskId.test.d.ts +20 -0
  168. package/dist/hooks/delegation-gate.plan-fallback-security.test.d.ts +13 -0
  169. package/dist/hooks/delegation-gate.plan-fallback.test.d.ts +5 -0
  170. package/dist/hooks/delegation-gate.seed-state.test.d.ts +1 -0
  171. package/dist/hooks/delegation-gate.turbo-evidence.test.d.ts +8 -0
  172. package/dist/hooks/delegation-gate.verify.test.d.ts +11 -0
  173. package/dist/hooks/delegation-ledger.d.ts +37 -0
  174. package/dist/hooks/delegation-ledger.test.d.ts +11 -0
  175. package/dist/hooks/delegation-sanitizer.d.ts +24 -0
  176. package/dist/hooks/delegation-tracker.d.ts +15 -0
  177. package/dist/hooks/diff-scope.d.ts +12 -0
  178. package/dist/hooks/diff-scope.test.d.ts +1 -0
  179. package/dist/hooks/extractors.d.ts +53 -0
  180. package/dist/hooks/full-auto-intercept.d.ts +77 -0
  181. package/dist/hooks/guardrails.d.ts +174 -0
  182. package/dist/hooks/hive-promoter.d.ts +40 -0
  183. package/dist/hooks/incremental-verify.d.ts +34 -0
  184. package/dist/hooks/incremental-verify.test.d.ts +1 -0
  185. package/dist/hooks/index.d.ts +20 -0
  186. package/dist/hooks/knowledge-curator.d.ts +27 -0
  187. package/dist/hooks/knowledge-injector.d.ts +20 -0
  188. package/dist/hooks/knowledge-migrator.d.ts +11 -0
  189. package/dist/hooks/knowledge-reader.d.ts +22 -0
  190. package/dist/hooks/knowledge-store.d.ts +30 -0
  191. package/dist/hooks/knowledge-types.d.ts +131 -0
  192. package/dist/hooks/knowledge-validator.d.ts +29 -0
  193. package/dist/hooks/loop-detector.d.ts +17 -0
  194. package/dist/hooks/loop-detector.test.d.ts +1 -0
  195. package/dist/hooks/message-priority.d.ts +105 -0
  196. package/dist/hooks/messages-transform.d.ts +13 -0
  197. package/dist/hooks/model-limits.d.ts +96 -0
  198. package/dist/hooks/normalize-tool-name.d.ts +25 -0
  199. package/dist/hooks/phase-monitor.d.ts +29 -0
  200. package/dist/hooks/pipeline-tracker.d.ts +41 -0
  201. package/dist/hooks/repo-graph-builder.d.ts +32 -0
  202. package/dist/hooks/repo-graph-injection.d.ts +45 -0
  203. package/dist/hooks/review-receipt.d.ts +189 -0
  204. package/dist/hooks/scope-guard-throw-behavior.test.d.ts +15 -0
  205. package/dist/hooks/scope-guard.adversarial.test.d.ts +1 -0
  206. package/dist/hooks/scope-guard.d.ts +43 -0
  207. package/dist/hooks/scope-guard.test.d.ts +14 -0
  208. package/dist/hooks/self-review.d.ts +14 -0
  209. package/dist/hooks/self-review.test.d.ts +14 -0
  210. package/dist/hooks/semantic-diff-injection.d.ts +24 -0
  211. package/dist/hooks/slop-detector.adversarial.test.d.ts +1 -0
  212. package/dist/hooks/slop-detector.d.ts +17 -0
  213. package/dist/hooks/slop-detector.test.d.ts +1 -0
  214. package/dist/hooks/spawn-helper.d.ts +5 -0
  215. package/dist/hooks/spawn-helper.test.d.ts +1 -0
  216. package/dist/hooks/steering-consumed.d.ts +30 -0
  217. package/dist/hooks/system-enhancer.d.ts +30 -0
  218. package/dist/hooks/tool-summarizer.d.ts +28 -0
  219. package/dist/hooks/trajectory-logger.d.ts +69 -0
  220. package/dist/hooks/utils.d.ts +20 -0
  221. package/dist/hooks/watchdog.integration.test.d.ts +9 -0
  222. package/dist/index.adversarial-bootstrap.test.d.ts +1 -0
  223. package/dist/index.bootstrap-adversarial.test.d.ts +1 -0
  224. package/dist/index.bootstrap-directory.test.d.ts +1 -0
  225. package/dist/index.d.ts +8 -1
  226. package/dist/index.js +74704 -47714
  227. package/dist/knowledge/identity.d.ts +25 -0
  228. package/dist/knowledge/index.d.ts +2 -0
  229. package/dist/lang/detector.d.ts +20 -0
  230. package/dist/lang/framework-detector.d.ts +98 -0
  231. package/dist/lang/grammars/tree-sitter-dart.wasm +0 -0
  232. package/dist/lang/grammars/tree-sitter-kotlin.wasm +0 -0
  233. package/dist/lang/grammars/tree-sitter-swift.wasm +0 -0
  234. package/dist/lang/grammars/tree-sitter.wasm +0 -0
  235. package/dist/lang/index.d.ts +4 -0
  236. package/dist/lang/profiles.d.ts +72 -0
  237. package/dist/lang/registry.d.ts +24 -0
  238. package/dist/lang/runtime.d.ts +35 -0
  239. package/dist/model-fallback.adversarial.test.d.ts +22 -0
  240. package/dist/model-fallback.test.d.ts +12 -0
  241. package/dist/mutation/__tests__/engine.adversarial.test.d.ts +1 -0
  242. package/dist/mutation/__tests__/engine.test.d.ts +1 -0
  243. package/dist/mutation/__tests__/equivalence.adversarial.test.d.ts +1 -0
  244. package/dist/mutation/__tests__/equivalence.test.d.ts +1 -0
  245. package/dist/mutation/__tests__/gate.adversarial.test.d.ts +1 -0
  246. package/dist/mutation/__tests__/gate.test.d.ts +1 -0
  247. package/dist/mutation/__tests__/generator.test.d.ts +1 -0
  248. package/dist/mutation/engine.d.ts +47 -0
  249. package/dist/mutation/equivalence.d.ts +35 -0
  250. package/dist/mutation/gate.d.ts +28 -0
  251. package/dist/mutation/generator.d.ts +16 -0
  252. package/dist/output/agent-writer.d.ts +27 -0
  253. package/dist/output/index.d.ts +1 -0
  254. package/dist/parallel/dependency-graph.d.ts +34 -0
  255. package/dist/parallel/dispatcher/index.d.ts +12 -0
  256. package/dist/parallel/dispatcher/noop-dispatcher.d.ts +18 -0
  257. package/dist/parallel/dispatcher/noop-dispatcher.test.d.ts +10 -0
  258. package/dist/parallel/dispatcher/parallel-dispatcher.d.ts +18 -0
  259. package/dist/parallel/dispatcher/types.d.ts +33 -0
  260. package/dist/parallel/file-locks.d.ts +40 -0
  261. package/dist/parallel/index.d.ts +5 -0
  262. package/dist/parallel/meta-indexer.d.ts +32 -0
  263. package/dist/parallel/review-router.d.ts +29 -0
  264. package/dist/plan/checkpoint.d.ts +25 -0
  265. package/dist/plan/checkpoint.test.d.ts +1 -0
  266. package/dist/plan/index.d.ts +1 -0
  267. package/dist/plan/ledger-integrity.test.d.ts +5 -0
  268. package/dist/plan/ledger-snapshot-adversarial.test.d.ts +1 -0
  269. package/dist/plan/ledger.d.ts +286 -0
  270. package/dist/plan/ledger.test.d.ts +1 -0
  271. package/dist/plan/manager.cas-backoff.test.d.ts +10 -0
  272. package/dist/plan/manager.d.ts +90 -0
  273. package/dist/plan/manager.ledger-aware.test.d.ts +1 -0
  274. package/dist/plan/manager.loadplan-validation-guard.test.d.ts +13 -0
  275. package/dist/plan/manager.update-task-status.test.d.ts +1 -0
  276. package/dist/plan/migration-revert.regression.test.d.ts +8 -0
  277. package/dist/prm/__tests__/course-correction.test.d.ts +1 -0
  278. package/dist/prm/__tests__/escalation-queue-drain.test.d.ts +1 -0
  279. package/dist/prm/__tests__/escalation.test.d.ts +1 -0
  280. package/dist/prm/__tests__/index.test.d.ts +1 -0
  281. package/dist/prm/__tests__/integration.test.d.ts +1 -0
  282. package/dist/prm/__tests__/pattern-detector.test.d.ts +5 -0
  283. package/dist/prm/__tests__/replay.test.d.ts +1 -0
  284. package/dist/prm/__tests__/trajectory-store.test.d.ts +7 -0
  285. package/dist/prm/course-correction.d.ts +20 -0
  286. package/dist/prm/escalation.d.ts +73 -0
  287. package/dist/prm/index.d.ts +58 -0
  288. package/dist/prm/pattern-detector.d.ts +71 -0
  289. package/dist/prm/replay.d.ts +44 -0
  290. package/dist/prm/trajectory-store.d.ts +66 -0
  291. package/dist/prm/types.d.ts +120 -0
  292. package/dist/quality/index.d.ts +1 -0
  293. package/dist/quality/metrics.d.ts +25 -0
  294. package/dist/sast/rules/c.d.ts +9 -0
  295. package/dist/sast/rules/csharp.d.ts +9 -0
  296. package/dist/sast/rules/go.d.ts +9 -0
  297. package/dist/sast/rules/index.d.ts +72 -0
  298. package/dist/sast/rules/java.d.ts +9 -0
  299. package/dist/sast/rules/javascript.d.ts +9 -0
  300. package/dist/sast/rules/php.d.ts +9 -0
  301. package/dist/sast/rules/python.d.ts +9 -0
  302. package/dist/sast/semgrep.d.ts +68 -0
  303. package/dist/sast/semgrep.test.d.ts +1 -0
  304. package/dist/sbom/cyclonedx.d.ts +101 -0
  305. package/dist/sbom/detectors/dart.d.ts +7 -0
  306. package/dist/sbom/detectors/dotnet.d.ts +7 -0
  307. package/dist/sbom/detectors/go.d.ts +7 -0
  308. package/dist/sbom/detectors/index.d.ts +53 -0
  309. package/dist/sbom/detectors/java.d.ts +7 -0
  310. package/dist/sbom/detectors/nodejs.d.ts +7 -0
  311. package/dist/sbom/detectors/python.d.ts +7 -0
  312. package/dist/sbom/detectors/rust.d.ts +7 -0
  313. package/dist/sbom/detectors/swift.d.ts +7 -0
  314. package/dist/scope/scope-persistence.d.ts +109 -0
  315. package/dist/scope/scope-persistence.test.d.ts +13 -0
  316. package/dist/services/compaction-service.d.ts +28 -0
  317. package/dist/services/compaction-service.test.d.ts +1 -0
  318. package/dist/services/config-doctor.d.ts +125 -0
  319. package/dist/services/config-doctor.security.test.d.ts +1 -0
  320. package/dist/services/config-doctor.test.d.ts +1 -0
  321. package/dist/services/context-budget-service.d.ts +101 -0
  322. package/dist/services/decision-drift-analyzer.d.ts +96 -0
  323. package/dist/services/diagnose-service.d.ts +41 -0
  324. package/dist/services/evidence-service.d.ts +65 -0
  325. package/dist/services/evidence-summary-service.d.ts +75 -0
  326. package/dist/services/export-service.d.ts +30 -0
  327. package/dist/services/handoff-service.d.ts +74 -0
  328. package/dist/services/history-service.d.ts +35 -0
  329. package/dist/services/index.d.ts +13 -0
  330. package/dist/services/plan-service.d.ts +25 -0
  331. package/dist/services/preflight-integration.d.ts +38 -0
  332. package/dist/services/preflight-service.d.ts +62 -0
  333. package/dist/services/run-memory.d.ts +66 -0
  334. package/dist/services/status-service.d.ts +35 -0
  335. package/dist/services/status-service.turbo-indicator.test.d.ts +5 -0
  336. package/dist/services/tool-doctor.d.ts +26 -0
  337. package/dist/services/tool-doctor.test.d.ts +1 -0
  338. package/dist/services/version-check.d.ts +28 -0
  339. package/dist/services/warning-buffer.d.ts +9 -0
  340. package/dist/session/snapshot-reader.d.ts +37 -0
  341. package/dist/session/snapshot-writer.d.ts +115 -0
  342. package/dist/skills/index.d.ts +30 -0
  343. package/dist/state/agent-run-context.d.ts +24 -0
  344. package/dist/state.agent-run-context.test.d.ts +10 -0
  345. package/dist/state.d.ts +501 -1
  346. package/dist/state.rehydrate.test.d.ts +1 -0
  347. package/dist/state.rehydration-adversarial.test.d.ts +1 -0
  348. package/dist/state.rehydration-integration.test.d.ts +1 -0
  349. package/dist/state.session-restart.test.d.ts +7 -0
  350. package/dist/summaries/index.d.ts +2 -0
  351. package/dist/summaries/manager.d.ts +29 -0
  352. package/dist/summaries/summarizer.d.ts +38 -0
  353. package/dist/telemetry.d.ts +59 -0
  354. package/dist/telemetry.test.d.ts +1 -0
  355. package/dist/test-impact/__tests__/analyzer-import-fix.adversarial.test.d.ts +1 -0
  356. package/dist/test-impact/__tests__/analyzer-import-fix.test.d.ts +1 -0
  357. package/dist/test-impact/__tests__/analyzer.adversarial.test.d.ts +1 -0
  358. package/dist/test-impact/__tests__/analyzer.test.d.ts +1 -0
  359. package/dist/test-impact/__tests__/council-fixes.test.d.ts +1 -0
  360. package/dist/test-impact/__tests__/failure-classifier.adversarial.test.d.ts +1 -0
  361. package/dist/test-impact/__tests__/failure-classifier.test.d.ts +1 -0
  362. package/dist/test-impact/__tests__/flaky-detector.adversarial.test.d.ts +1 -0
  363. package/dist/test-impact/__tests__/flaky-detector.test.d.ts +1 -0
  364. package/dist/test-impact/__tests__/history-store.adversarial.test.d.ts +1 -0
  365. package/dist/test-impact/__tests__/history-store.test.d.ts +1 -0
  366. package/dist/test-impact/__tests__/test-impact.adversarial.test.d.ts +1 -0
  367. package/dist/test-impact/__tests__/test-impact.test.d.ts +1 -0
  368. package/dist/test-impact/analyzer.d.ts +9 -0
  369. package/dist/test-impact/failure-classifier.d.ts +26 -0
  370. package/dist/test-impact/flaky-detector.d.ts +14 -0
  371. package/dist/test-impact/history-store.d.ts +15 -0
  372. package/dist/tools/__tests__/barrel-exports.test.d.ts +1 -0
  373. package/dist/tools/__tests__/diff-ast-fallback.test.d.ts +1 -0
  374. package/dist/tools/__tests__/diff-markdown-summary.test.d.ts +1 -0
  375. package/dist/tools/__tests__/diff-semantic.test.d.ts +1 -0
  376. package/dist/tools/__tests__/diff-summary.adversarial.test.d.ts +1 -0
  377. package/dist/tools/__tests__/diff-summary.test.d.ts +1 -0
  378. package/dist/tools/__tests__/mutation-test.adversarial.test.d.ts +1 -0
  379. package/dist/tools/__tests__/mutation-test.sourcefiles.test.d.ts +1 -0
  380. package/dist/tools/__tests__/mutation-test.test.d.ts +1 -0
  381. package/dist/tools/__tests__/test-runner-history.test.d.ts +1 -0
  382. package/dist/tools/__tests__/test-runner-impact.adversarial.test.d.ts +1 -0
  383. package/dist/tools/__tests__/test-runner-impact.test.d.ts +1 -0
  384. package/dist/tools/__tests__/test-runner-source-files.test.d.ts +1 -0
  385. package/dist/tools/barrel-export-check-gate-status.test.d.ts +6 -0
  386. package/dist/tools/batch-symbols.d.ts +24 -0
  387. package/dist/tools/batch-symbols.test.d.ts +1 -0
  388. package/dist/tools/build-check.d.ts +50 -0
  389. package/dist/tools/check-gate-status.adversarial.test.d.ts +1 -0
  390. package/dist/tools/check-gate-status.d.ts +7 -0
  391. package/dist/tools/check-gate-status.gates.test.d.ts +1 -0
  392. package/dist/tools/check-gate-status.plugin-registration.test.d.ts +1 -0
  393. package/dist/tools/checkpoint.d.ts +2 -0
  394. package/dist/tools/co-change-analyzer.d.ts +45 -0
  395. package/dist/tools/completion-verify.d.ts +25 -0
  396. package/dist/tools/complexity-hotspots.d.ts +2 -0
  397. package/dist/tools/convene-council.d.ts +53 -0
  398. package/dist/tools/convene-general-council.d.ts +25 -0
  399. package/dist/{create-tool.d.ts → tools/create-tool.d.ts} +13 -1
  400. package/dist/tools/curator-analyze.d.ts +7 -0
  401. package/dist/tools/curator-analyze.test.d.ts +1 -0
  402. package/dist/tools/declare-council-criteria.d.ts +14 -0
  403. package/dist/tools/declare-scope.d.ts +50 -0
  404. package/dist/tools/diff-summary.d.ts +12 -0
  405. package/dist/tools/diff.d.ts +24 -0
  406. package/dist/tools/doc-scan.d.ts +38 -0
  407. package/dist/tools/domain-detector.d.ts +6 -0
  408. package/dist/tools/evidence-check.d.ts +8 -0
  409. package/dist/tools/file-extractor.d.ts +9 -0
  410. package/dist/tools/generate-mutants.d.ts +15 -0
  411. package/dist/tools/get-approved-plan.d.ts +55 -0
  412. package/dist/tools/get-qa-gate-profile.d.ts +27 -0
  413. package/dist/tools/gitingest.d.ts +18 -0
  414. package/dist/tools/imports.d.ts +5 -0
  415. package/dist/tools/index.d.ts +66 -0
  416. package/dist/tools/knowledge-add.d.ts +2 -0
  417. package/dist/tools/knowledge-query.d.ts +5 -0
  418. package/dist/tools/knowledge-recall.d.ts +2 -0
  419. package/dist/tools/knowledge-remove.d.ts +2 -0
  420. package/dist/tools/knowledge-tools.integration.test.d.ts +1 -0
  421. package/dist/tools/lint-spec.d.ts +2 -0
  422. package/dist/tools/lint.d.ts +63 -0
  423. package/dist/tools/mutation-test.d.ts +2 -0
  424. package/dist/tools/mutation-test.security.test.d.ts +1 -0
  425. package/dist/tools/phase-complete.d.ts +25 -0
  426. package/dist/tools/pkg-audit.d.ts +2 -0
  427. package/dist/tools/placeholder-scan.d.ts +28 -0
  428. package/dist/tools/plugin-registration-adversarial.test.d.ts +1 -0
  429. package/dist/tools/pre-check-batch.d.ts +89 -0
  430. package/dist/tools/quality-budget.d.ts +26 -0
  431. package/dist/tools/repo-graph.d.ts +226 -0
  432. package/dist/tools/repo-map.d.ts +2 -0
  433. package/dist/tools/req-coverage.d.ts +47 -0
  434. package/dist/tools/resolve-working-directory.d.ts +35 -0
  435. package/dist/tools/resolve-working-directory.test.d.ts +1 -0
  436. package/dist/tools/retrieve-summary.d.ts +2 -0
  437. package/dist/tools/sast-baseline.d.ts +126 -0
  438. package/dist/tools/sast-scan.d.ts +87 -0
  439. package/dist/tools/save-plan.d.ts +95 -0
  440. package/dist/tools/save-plan.subdirectory-rejection.test.d.ts +1 -0
  441. package/dist/tools/sbom-generate.d.ts +26 -0
  442. package/dist/tools/schema-drift.d.ts +2 -0
  443. package/dist/tools/search.adversarial.test.d.ts +1 -0
  444. package/dist/tools/search.d.ts +29 -0
  445. package/dist/tools/search.test.d.ts +1 -0
  446. package/dist/tools/secretscan.d.ts +35 -0
  447. package/dist/tools/set-qa-gates.d.ts +40 -0
  448. package/dist/tools/suggest-patch.adversarial.test.d.ts +1 -0
  449. package/dist/tools/suggest-patch.d.ts +37 -0
  450. package/dist/tools/suggest-patch.test.d.ts +1 -0
  451. package/dist/tools/symbols.d.ts +21 -0
  452. package/dist/tools/syntax-check.d.ts +37 -0
  453. package/dist/tools/test-impact.d.ts +2 -0
  454. package/dist/tools/test-runner.d.ts +86 -0
  455. package/dist/tools/test-runner.security-adversarial.test.d.ts +5 -0
  456. package/dist/tools/todo-extract.d.ts +2 -0
  457. package/dist/tools/tool-names.d.ts +10 -0
  458. package/dist/tools/update-task-status.adversarial.test.d.ts +13 -0
  459. package/dist/tools/update-task-status.d.ts +114 -0
  460. package/dist/tools/update-task-status.gates.test.d.ts +1 -0
  461. package/dist/tools/update-task-status.test.d.ts +1 -0
  462. package/dist/tools/update-task-status.turbo-bypass.test.d.ts +1 -0
  463. package/dist/tools/verify-six-tools-registration.test.d.ts +9 -0
  464. package/dist/tools/web-search.d.ts +13 -0
  465. package/dist/tools/write-drift-evidence.d.ts +31 -0
  466. package/dist/tools/write-hallucination-evidence.d.ts +30 -0
  467. package/dist/tools/write-mutation-evidence.d.ts +34 -0
  468. package/dist/tools/write-mutation-evidence.test.d.ts +1 -0
  469. package/dist/tools/write-retro.d.ts +55 -0
  470. package/dist/transient-retry.test.d.ts +10 -0
  471. package/dist/types/delegation.d.ts +24 -0
  472. package/dist/types/events.d.ts +125 -0
  473. package/dist/utils/errors.d.ts +33 -0
  474. package/dist/utils/gitignore-warning.d.ts +17 -0
  475. package/dist/utils/index.d.ts +4 -0
  476. package/dist/utils/logger.d.ts +3 -0
  477. package/dist/utils/merge.d.ts +5 -0
  478. package/dist/utils/path-security.d.ts +36 -0
  479. package/dist/utils/regex.d.ts +30 -0
  480. package/dist/utils/spec-hash.d.ts +15 -0
  481. package/dist/utils/tool-output.d.ts +12 -0
  482. package/dist/validation/task-id.d.ts +43 -0
  483. package/package.json +21 -14
  484. package/dist/architect.d.ts +0 -7
  485. package/dist/checkpoint.d.ts +0 -7
  486. package/dist/co-change-analyzer.d.ts +0 -1
  487. package/dist/compat.d.ts +0 -12
  488. package/dist/config-doctor.d.ts +0 -1
  489. package/dist/detector.d.ts +0 -7
  490. package/dist/diagnose-service.d.ts +0 -1
  491. package/dist/doctor.d.ts +0 -5
  492. package/dist/evidence-schema.d.ts +0 -2
  493. package/dist/evidence-service.d.ts +0 -1
  494. package/dist/export-service.d.ts +0 -1
  495. package/dist/handoff-service.d.ts +0 -1
  496. package/dist/history-service.d.ts +0 -1
  497. package/dist/hive-promoter.d.ts +0 -2
  498. package/dist/knowledge-migrator.d.ts +0 -2
  499. package/dist/knowledge-store.d.ts +0 -1
  500. package/dist/knowledge-types.d.ts +0 -1
  501. package/dist/knowledge-validator.d.ts +0 -2
  502. package/dist/loader.d.ts +0 -1
  503. package/dist/manager.d.ts +0 -1
  504. package/dist/models.d.ts +0 -1
  505. package/dist/plan-service.d.ts +0 -1
  506. package/dist/preflight-service.d.ts +0 -1
  507. package/dist/profiles.d.ts +0 -7
  508. package/dist/register.d.ts +0 -36
  509. package/dist/schema.d.ts +0 -2
  510. package/dist/snapshot-writer.d.ts +0 -1
  511. package/dist/status-service.d.ts +0 -15
  512. package/dist/telemetry/src/events.d.ts +0 -308
  513. package/dist/telemetry/src/guards.d.ts +0 -14
  514. package/dist/telemetry/src/index.d.ts +0 -4
  515. package/dist/telemetry/src/version.d.ts +0 -1
  516. package/dist/utils.d.ts +0 -1
  517. package/dist/write-retro.d.ts +0 -1
  518. /package/dist/{discovery.d.ts → build/discovery.d.ts} +0 -0
  519. /package/dist/{agents.d.ts → commands/agents.d.ts} +0 -0
  520. /package/dist/{analyze.d.ts → commands/analyze.d.ts} +0 -0
  521. /package/dist/{archive.d.ts → commands/archive.d.ts} +0 -0
  522. /package/dist/{benchmark.d.ts → commands/benchmark.d.ts} +0 -0
  523. /package/dist/{clarify.d.ts → commands/clarify.d.ts} +0 -0
  524. /package/dist/{curate.d.ts → commands/curate.d.ts} +0 -0
  525. /package/dist/{dark-matter.d.ts → commands/dark-matter.d.ts} +0 -0
  526. /package/dist/{diagnose.d.ts → commands/diagnose.d.ts} +0 -0
  527. /package/dist/{evidence.d.ts → commands/evidence.d.ts} +0 -0
  528. /package/dist/{export.d.ts → commands/export.d.ts} +0 -0
  529. /package/dist/{handoff.d.ts → commands/handoff.d.ts} +0 -0
  530. /package/dist/{history.d.ts → commands/history.d.ts} +0 -0
  531. /package/dist/{plan.d.ts → commands/plan.d.ts} +0 -0
  532. /package/dist/{preflight.d.ts → commands/preflight.d.ts} +0 -0
  533. /package/dist/{promote.d.ts → commands/promote.d.ts} +0 -0
  534. /package/dist/{reset.d.ts → commands/reset.d.ts} +0 -0
  535. /package/dist/{retrieve.d.ts → commands/retrieve.d.ts} +0 -0
  536. /package/dist/{rollback.d.ts → commands/rollback.d.ts} +0 -0
  537. /package/dist/{simulate.d.ts → commands/simulate.d.ts} +0 -0
  538. /package/dist/{specify.d.ts → commands/specify.d.ts} +0 -0
  539. /package/dist/{status.d.ts → commands/status.d.ts} +0 -0
  540. /package/dist/{turbo.d.ts → commands/turbo.d.ts} +0 -0
  541. /package/dist/{write_retro.d.ts → commands/write-retro.d.ts} +0 -0
package/dist/state.d.ts CHANGED
@@ -1 +1,501 @@
1
- export * from '@opencode-swarm/core';
1
+ /**
2
+ * Shared state module for OpenCode Swarm plugin.
3
+ * Provides a module-scoped singleton for cross-hook state sharing.
4
+ *
5
+ * This module is used by multiple hooks (tool.execute.before, tool.execute.after,
6
+ * chat.message, system-enhancer) to share state like active agents, tool call tracking,
7
+ * and delegation chains.
8
+ */
9
+ import type { OpencodeClient } from '@opencode-ai/sdk';
10
+ import { type QaGates } from './db/qa-gate-profile.js';
11
+ import { type EnvironmentProfile } from './environment/profile.js';
12
+ import type { EscalationTracker } from './prm/escalation.js';
13
+ import type { PatternMatch } from './prm/types.js';
14
+ import { AgentRunContext } from './state/agent-run-context.js';
15
+ export { AgentRunContext } from './state/agent-run-context.js';
16
+ /**
17
+ * Represents a single tool call entry for tracking purposes
18
+ */
19
+ export interface ToolCallEntry {
20
+ tool: string;
21
+ sessionID: string;
22
+ callID: string;
23
+ startTime: number;
24
+ }
25
+ /**
26
+ * Aggregated statistics for a specific tool
27
+ */
28
+ export interface ToolAggregate {
29
+ tool: string;
30
+ count: number;
31
+ successCount: number;
32
+ failureCount: number;
33
+ totalDuration: number;
34
+ }
35
+ /**
36
+ * Represents a delegation from one agent to another
37
+ */
38
+ export interface DelegationEntry {
39
+ from: string;
40
+ to: string;
41
+ timestamp: number;
42
+ }
43
+ /**
44
+ * Reason a non-architect agent was activated during delegation tracking.
45
+ * Used by delegation-tracker.ts to record why a delegation occurred.
46
+ */
47
+ export type DelegationReason = 'normal_delegation' | 'review_rejected' | 'critic_consultation' | 'retry_circuit_breaker' | 'conflict_escalation' | 'stale_recovery';
48
+ /**
49
+ * Per-task workflow state for gate progression tracking.
50
+ * Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
51
+ */
52
+ export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'complete';
53
+ /**
54
+ * Represents per-session state for guardrail tracking.
55
+ * Budget fields (toolCallCount, consecutiveErrors, etc.) have moved to InvocationWindow.
56
+ * This interface now tracks session-level metadata and window management.
57
+ */
58
+ export interface AgentSessionState {
59
+ /** Current agent identity for this session */
60
+ agentName: string;
61
+ /** Timestamp of most recent tool call (for session-level stale detection) */
62
+ lastToolCallTime: number;
63
+ /** Timestamp of most recent agent identity event (chat.message) */
64
+ lastAgentEventTime: number;
65
+ /** Whether active delegation is in progress for this session */
66
+ delegationActive: boolean;
67
+ /** Reason the most recent non-architect agent was activated */
68
+ lastDelegationReason?: DelegationReason;
69
+ /** Current active invocation ID for this agent */
70
+ activeInvocationId: number;
71
+ /** Last invocation ID by agent name (e.g., { "coder": 3, "reviewer": 1 }) */
72
+ lastInvocationIdByAgent: Record<string, number>;
73
+ /** Active invocation windows keyed by "${agentName}:${invId}" */
74
+ windows: Record<string, InvocationWindow>;
75
+ /** Last tool-call threshold at which a compaction hint was issued */
76
+ lastCompactionHint: number;
77
+ /** Count of architect direct writes to non-.swarm/ files */
78
+ architectWriteCount: number;
79
+ /** Last task ID that was delegated to coder (for zero-delegation detection) */
80
+ lastCoderDelegationTaskId: string | null;
81
+ /** Current task ID being worked on (set when coder delegation fires, used for per-task gate tracking) */
82
+ currentTaskId: string | null;
83
+ /** Gate names observed for current task (taskId → Set of gates) */
84
+ gateLog: Map<string, Set<string>>;
85
+ /** Reviewer delegations per phase (phaseNumber → count) */
86
+ reviewerCallCount: Map<number, number>;
87
+ /** Last gate failure for self-fix detection */
88
+ lastGateFailure: {
89
+ tool: string;
90
+ taskId: string;
91
+ timestamp: number;
92
+ } | null;
93
+ /** Task IDs for which partial gate warning has already been issued (prevents per-task spam) */
94
+ partialGateWarningsIssuedForTask: Set<string>;
95
+ /** Whether architect attempted self-fix write after gate failure */
96
+ selfFixAttempted: boolean;
97
+ /** Value of architectWriteCount at the time the self-coding warning was last injected.
98
+ * Warning is suppressed unless architectWriteCount has increased since last injection. */
99
+ selfCodingWarnedAtCount: number;
100
+ /** Phases that have already received a catastrophic zero-reviewer warning */
101
+ catastrophicPhaseWarnings: Set<number>;
102
+ /** Number of consecutive coder delegations without reviewer/test_engineer between them */
103
+ qaSkipCount: number;
104
+ /** Task IDs skipped without QA (for audit trail), reset when reviewer/test_engineer fires */
105
+ qaSkipTaskIds: string[];
106
+ /** Per-task workflow state — taskId → current state */
107
+ taskWorkflowStates: Map<string, TaskWorkflowState>;
108
+ /**
109
+ * PR 2 Stage B barrier: per-task set of completed Stage B agents.
110
+ * Order-independent — either 'reviewer' or 'test_engineer' may complete first.
111
+ * When both are present, the task may advance to tests_run regardless of order.
112
+ * Only populated when parallelization.stageB.parallel.enabled = true.
113
+ */
114
+ stageBCompletion?: Map<string, Set<'reviewer' | 'test_engineer'>>;
115
+ /** v6.71+ Council mode: per-task council verdict, recorded by delegation-gate when submit_council_verdicts resolves. */
116
+ taskCouncilApproved?: Map<string, {
117
+ verdict: 'APPROVE' | 'REJECT' | 'CONCERNS';
118
+ roundNumber: number;
119
+ /**
120
+ * Distinct council members that voted on this verdict.
121
+ * Validated by the council fast-path against `council.minimumMembers`
122
+ * (default 3). Old evidence files without this field rehydrate as
123
+ * quorumSize: 1 — conservative; forces a fresh council run.
124
+ */
125
+ quorumSize: number;
126
+ }>;
127
+ /** Last gate outcome for deliberation preamble injection */
128
+ lastGateOutcome: {
129
+ gate: string;
130
+ taskId: string;
131
+ passed: boolean;
132
+ timestamp: number;
133
+ } | null;
134
+ /** Declared file scope for current coder task (null = no scope declared) */
135
+ declaredCoderScope: string[] | null;
136
+ /** Last scope violation message (null = no violation) */
137
+ lastScopeViolation: string | null;
138
+ /** Flag for one-shot scope violation warning injection in messagesTransform */
139
+ scopeViolationDetected?: boolean;
140
+ /** Files modified by the current coder task (populated by guardrails toolBefore/toolAfter, reset on new coder delegation) */
141
+ modifiedFilesThisCoderTask: string[];
142
+ /** Number of coder revisions in the current task (incremented on each coder delegation completion) */
143
+ coderRevisions: number;
144
+ /** Flag set when coder revisions hit the configured ceiling */
145
+ revisionLimitHit: boolean;
146
+ /** Timestamp of most recent phase completion */
147
+ lastPhaseCompleteTimestamp: number;
148
+ /** Phase number of most recent phase completion */
149
+ lastPhaseCompletePhase: number;
150
+ /** Set of agents dispatched in current phase (normalized names) */
151
+ phaseAgentsDispatched: Set<string>;
152
+ /** Set of agents dispatched in the most recently completed phase (persisted across phase reset) */
153
+ lastCompletedPhaseAgentsDispatched: Set<string>;
154
+ /** Current index into the fallback_models array (0 = primary model, incremented on transient failure) */
155
+ model_fallback_index: number;
156
+ /** Flag set when all fallback models have been exhausted */
157
+ modelFallbackExhausted: boolean;
158
+ /** Session-scoped Turbo Mode flag for controlling LLM inference speed */
159
+ turboMode: boolean;
160
+ /** Session-level QA gate overrides layered on top of the spec-level profile.
161
+ * Overrides can only enable gates (true); false values are ignored by
162
+ * getEffectiveGates. Cleared on session reset. Optional for backwards
163
+ * compatibility with pre-existing session state fixtures; consumers
164
+ * should read via `session.qaGateSessionOverrides ?? {}`. */
165
+ qaGateSessionOverrides?: Partial<QaGates>;
166
+ /** Session-scoped Full Auto flag for autonomous multi-agent oversight */
167
+ fullAutoMode: boolean;
168
+ /** Count of full-auto interactions this phase (for max_interactions_per_phase limit) */
169
+ fullAutoInteractionCount: number;
170
+ /** Count of detected deadlocks (repeated identical questions) in full-auto mode */
171
+ fullAutoDeadlockCount: number;
172
+ /** Hash of last question asked (for deadlock detection via hash comparison) */
173
+ fullAutoLastQuestionHash: string | null;
174
+ /** Sliding window of last 10 Task delegation hashes for loop detection */
175
+ loopDetectionWindow?: Array<{
176
+ hash: string;
177
+ timestamp: number;
178
+ }>;
179
+ /** Pending loop warning message to inject into next messagesTransform (cleared after injection) */
180
+ loopWarningPending?: {
181
+ agent: string;
182
+ message: string;
183
+ timestamp: number;
184
+ };
185
+ /** Flag to track if the 50% context pressure warning has been sent this session */
186
+ contextPressureWarningSent?: boolean;
187
+ /** Queue of advisory messages (e.g., SLOP, context pressure) pending injection into next messagesTransform */
188
+ pendingAdvisoryMessages?: string[];
189
+ /** Timestamp when session was rehydrated from snapshot (0 if never rehydrated) */
190
+ sessionRehydratedAt: number;
191
+ /** Pattern type to detection count mapping */
192
+ prmPatternCounts: Map<string, number>;
193
+ /** Current escalation level (0=none, 1=guidance, 2=strong guidance, 3=hard stop) */
194
+ prmEscalationLevel: number;
195
+ /** Last pattern detected (if any) */
196
+ prmLastPatternDetected: PatternMatch | null;
197
+ /** Current trajectory step counter */
198
+ prmTrajectoryStep: number;
199
+ /** Whether a hard stop has been triggered */
200
+ prmHardStopPending: boolean;
201
+ /** Per-session escalation tracker instance (set lazily by PRM hook) */
202
+ prmEscalationTracker?: EscalationTracker;
203
+ }
204
+ /**
205
+ * Represents a single agent invocation window with isolated guardrail budgets.
206
+ * Each time the architect delegates to an agent, a new window is created.
207
+ * Architect never creates windows (unlimited).
208
+ */
209
+ export interface InvocationWindow {
210
+ /** Unique ID for this invocation (increments per agent type) */
211
+ id: number;
212
+ /** Agent name (stripped of swarm prefix) */
213
+ agentName: string;
214
+ /** Timestamp when this invocation started */
215
+ startedAtMs: number;
216
+ /** Tool calls made in this invocation */
217
+ toolCalls: number;
218
+ /** Consecutive errors in this invocation */
219
+ consecutiveErrors: number;
220
+ /** Whether hard limit was hit for this invocation */
221
+ hardLimitHit: boolean;
222
+ /** Timestamp of most recent successful tool call */
223
+ lastSuccessTimeMs: number;
224
+ /** Circular buffer of recent tool calls (max 20) for repetition detection */
225
+ recentToolCalls: Array<{
226
+ tool: string;
227
+ argsHash: number;
228
+ timestamp: number;
229
+ }>;
230
+ /** Whether soft warning has been issued for this invocation */
231
+ warningIssued: boolean;
232
+ /** Human-readable warning reason */
233
+ warningReason: string;
234
+ /** Transient model error retry count for this invocation (resets per window) */
235
+ transientRetryCount: number;
236
+ }
237
+ /**
238
+ * Default run context — the single active run for current single-threaded behavior.
239
+ * PR 2 will create additional contexts for parallel dispatcher slots.
240
+ */
241
+ export declare const defaultRunContext: AgentRunContext<ToolCallEntry, ToolAggregate, DelegationEntry, AgentSessionState, EnvironmentProfile>;
242
+ /**
243
+ * Return the AgentRunContext for the given runId.
244
+ * No argument or unknown runId returns defaultRunContext (single-run semantics preserved).
245
+ */
246
+ export declare function getRunContext(runId?: string): typeof defaultRunContext;
247
+ /**
248
+ * Singleton state object for sharing data across hooks.
249
+ * Per-run maps are backed by defaultRunContext so that swarmState references
250
+ * stay valid and single-run behavior is unchanged.
251
+ */
252
+ export declare const swarmState: {
253
+ /** Active tool calls — keyed by callID for before→after correlation */
254
+ activeToolCalls: Map<string, ToolCallEntry>;
255
+ /** Aggregated tool usage stats — process-global accumulator */
256
+ toolAggregates: Map<string, ToolAggregate>;
257
+ /** Active agent per session — keyed by sessionID, updated by chat.message hook */
258
+ activeAgent: Map<string, string>;
259
+ /** Delegation chains per session — keyed by sessionID */
260
+ delegationChains: Map<string, DelegationEntry[]>;
261
+ /** Number of events since last flush */
262
+ pendingEvents: number;
263
+ /** SDK client — set at plugin init for curator LLM delegation */
264
+ opencodeClient: OpencodeClient | null;
265
+ /** All registered curator agent names across all swarms (with their swarm prefix).
266
+ * e.g. ['curator_init'] for a single default swarm, or
267
+ * ['swarm1_curator_init', 'swarm2_curator_init', ...] for multiple named swarms.
268
+ * Set at plugin init after agents are built. The factory resolves the correct
269
+ * name at call time by matching the active session's agent prefix. */
270
+ curatorInitAgentNames: string[];
271
+ curatorPhaseAgentNames: string[];
272
+ /** Last known context budget percentage (0-100), updated by system-enhancer */
273
+ lastBudgetPct: number;
274
+ /** Per-session guardrail state — keyed by sessionID */
275
+ agentSessions: Map<string, AgentSessionState>;
276
+ /** In-flight rehydration promises — awaited by rehydrateState before clearing agentSessions */
277
+ pendingRehydrations: Set<Promise<void>>;
278
+ /** Whether full-auto mode is enabled in config */
279
+ fullAutoEnabledInConfig: boolean;
280
+ /** Per-session environment profiles — keyed by sessionID */
281
+ environmentProfiles: Map<string, EnvironmentProfile>;
282
+ };
283
+ /**
284
+ * Reset all state to initial values - useful for testing
285
+ */
286
+ export declare function resetSwarmState(): void;
287
+ /**
288
+ * Start a new agent session with initialized guardrail state.
289
+ * Also removes any stale sessions older than staleDurationMs.
290
+ * @param sessionId - The session identifier
291
+ * @param agentName - The agent associated with this session
292
+ * @param staleDurationMs - Age threshold for stale session eviction (default: 120 min)
293
+ * @param directory - Optional project directory for rehydrating workflow state from disk
294
+ */
295
+ export declare function startAgentSession(sessionId: string, agentName: string, staleDurationMs?: number, directory?: string): void;
296
+ /**
297
+ * End an agent session by removing it from the state.
298
+ * NOTE: Currently unused in production — no session lifecycle teardown is wired up.
299
+ * Sessions accumulate for the process lifetime. Callers should integrate this into
300
+ * a session TTL or idle-timeout mechanism to prevent unbounded Map growth.
301
+ * @param sessionId - The session identifier to remove
302
+ */
303
+ export declare function endAgentSession(sessionId: string): void;
304
+ /**
305
+ * Get an agent session state by session ID.
306
+ * @param sessionId - The session identifier
307
+ * @returns The AgentSessionState or undefined if not found
308
+ */
309
+ export declare function getAgentSession(sessionId: string): AgentSessionState | undefined;
310
+ /**
311
+ * Ensure a guardrail session exists for the given sessionID.
312
+ * If one exists and agentName is provided and different, update it.
313
+ * If none exists, create one.
314
+ * Always updates lastToolCallTime.
315
+ * @param sessionId - The session identifier
316
+ * @param agentName - Optional agent name (if known)
317
+ * @returns The AgentSessionState
318
+ */
319
+ export declare function ensureAgentSession(sessionId: string, agentName?: string, directory?: string): AgentSessionState;
320
+ /**
321
+ * Update only the agent event timestamp (for stale detection).
322
+ * Does NOT change agent name or reset guardrail state.
323
+ * @param sessionId - The session identifier
324
+ */
325
+ export declare function updateAgentEventTime(sessionId: string): void;
326
+ /**
327
+ * Begin a new invocation window for the given agent.
328
+ * Increments invocation ID, creates fresh budget counters.
329
+ * Returns null for architect (unlimited, no window).
330
+ *
331
+ * @param sessionId - Session identifier
332
+ * @param agentName - Agent name (with or without swarm prefix)
333
+ * @returns New window or null if architect
334
+ */
335
+ export declare function beginInvocation(sessionId: string, agentName: string): InvocationWindow | null;
336
+ /**
337
+ * Get the currently active invocation window for the session.
338
+ * Returns undefined if no window exists (e.g., architect session).
339
+ *
340
+ * @param sessionId - Session identifier
341
+ * @returns Active window or undefined
342
+ */
343
+ export declare function getActiveWindow(sessionId: string): InvocationWindow | undefined;
344
+ /**
345
+ * Prune old invocation windows to prevent unbounded memory growth.
346
+ * Removes windows older than maxAgeMs and keeps only the most recent maxWindows.
347
+ *
348
+ * @param sessionId - Session identifier
349
+ * @param maxAgeMs - Maximum age in milliseconds (default 24 hours)
350
+ * @param maxWindows - Maximum number of windows to keep (default 50)
351
+ */
352
+ export declare function pruneOldWindows(sessionId: string, maxAgeMs?: number, maxWindows?: number): void;
353
+ /**
354
+ * Record an agent dispatch for phase completion tracking.
355
+ * Normalizes the agent name via stripKnownSwarmPrefix before adding to phaseAgentsDispatched.
356
+ * @param sessionId - Session identifier
357
+ * @param agentName - Agent name to record (will be normalized)
358
+ */
359
+ export declare function recordPhaseAgentDispatch(sessionId: string, agentName: string): void;
360
+ /**
361
+ * Advance a task's workflow state. Validates forward-only transitions.
362
+ * Throws 'INVALID_TASK_STATE_TRANSITION: [taskId] [current] → [requested]' on illegal transition.
363
+ * Safely returns without mutating state when taskId is null, undefined, empty, or whitespace-only.
364
+ *
365
+ * Valid forward order: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
366
+ *
367
+ * @param session - The agent session state
368
+ * @param taskId - The task identifier
369
+ * @param newState - The requested new state
370
+ */
371
+ export declare function advanceTaskState(session: AgentSessionState, taskId: string, newState: TaskWorkflowState, councilConfig?: {
372
+ minimumMembers?: number;
373
+ requireAllMembers?: boolean;
374
+ }): void;
375
+ /**
376
+ * Advance the per-task workflow state machine AND persist the corresponding
377
+ * plan.json status at meaningful workflow boundaries.
378
+ *
379
+ * The two-layer model splits in-memory workflow state (Layer 1, fast, used by
380
+ * gates) from the durable plan (Layer 2, projected to plan.md). Without this
381
+ * bridge, council APPROVE → 'complete' updates Layer 1 only and plan.md goes
382
+ * stale. This helper closes the gap by mapping:
383
+ * - 'coder_delegated' → plan.json status 'in_progress'
384
+ * - 'complete' → plan.json status 'completed'
385
+ * Other transitions are in-memory only (the task is already in_progress on disk
386
+ * once coder_delegated has fired).
387
+ *
388
+ * Persistence errors are logged and swallowed so a transient disk failure does
389
+ * not break the in-memory state machine — matches the existing defensive
390
+ * pattern around advanceTaskState call sites.
391
+ */
392
+ export declare function advanceTaskStateAndPersist(session: AgentSessionState, taskId: string, newState: TaskWorkflowState, directory: string, councilConfig?: {
393
+ minimumMembers?: number;
394
+ requireAllMembers?: boolean;
395
+ }): Promise<void>;
396
+ /**
397
+ * Get the current workflow state for a task.
398
+ * Returns 'idle' if no entry exists.
399
+ * Returns 'idle' for invalid taskId (null, undefined, empty, or whitespace-only).
400
+ * If taskWorkflowStates is missing/invalid, initializes it as a new Map.
401
+ *
402
+ * @param session - The agent session state
403
+ * @param taskId - The task identifier
404
+ * @returns Current task workflow state
405
+ */
406
+ export declare function getTaskState(session: AgentSessionState, taskId: string): TaskWorkflowState;
407
+ /**
408
+ * PR 2 Stage B barrier: record that a Stage B agent has completed for a task.
409
+ * Order-independent — either 'reviewer' or 'test_engineer' may complete first.
410
+ * Initializes the per-task set on first write.
411
+ *
412
+ * @param session - The agent session state
413
+ * @param taskId - The task identifier
414
+ * @param agent - Which Stage B agent completed ('reviewer' or 'test_engineer')
415
+ */
416
+ export declare function recordStageBCompletion(session: AgentSessionState, taskId: string, agent: 'reviewer' | 'test_engineer'): void;
417
+ /**
418
+ * PR 2 Stage B barrier: returns true iff both 'reviewer' and 'test_engineer' have
419
+ * been recorded for the given task in this session.
420
+ *
421
+ * @param session - The agent session state
422
+ * @param taskId - The task identifier
423
+ * @returns true when both Stage B agents have completed
424
+ */
425
+ export declare function hasBothStageBCompletions(session: AgentSessionState, taskId: string): boolean;
426
+ /**
427
+ * Returns true iff council is authoritative for the current plan.
428
+ *
429
+ * AND semantics: council is authoritative when BOTH `pluginConfig.council.enabled === true`
430
+ * AND `QaGates.council_mode === true` for the plan associated with this directory.
431
+ *
432
+ * If exactly one of the two flags is true, a one-time warning is logged per plan_id
433
+ * (so operators can see the deadlock case) and the function falls back to `false`,
434
+ * which keeps Stage B running as the default.
435
+ *
436
+ * Returns false when the plan or QA gate profile cannot be loaded — when the plan
437
+ * is missing the council cannot meaningfully be "authoritative".
438
+ */
439
+ export declare function isCouncilGateActive(directory: string, council: {
440
+ enabled?: boolean;
441
+ } | undefined): Promise<boolean>;
442
+ /**
443
+ * Test-only helper: clear the warn-once memo so each test can observe a fresh
444
+ * disagreement warning. Not part of the public surface.
445
+ */
446
+ export declare function _resetCouncilDisagreementWarnings(): void;
447
+ /**
448
+ * Rehydrates session workflow state from durable swarm files.
449
+ *
450
+ * Reads `.swarm/plan.json` and `.swarm/evidence/*.json` from the provided
451
+ * project directory, derives task workflow states from this data, and merges
452
+ * them into the target AgentSessionState.
453
+ *
454
+ * Merge rules:
455
+ * - Evidence-derived progression wins over plan-only state
456
+ * - Existing in-memory workflow states for the same task IDs are NOT downgraded
457
+ * - Missing/malformed `.swarm` data is non-fatal (silently skipped)
458
+ *
459
+ * This helper is useful for session restart scenarios where in-memory state
460
+ * is lost but durable files persist.
461
+ *
462
+ * @param directory - Project root containing .swarm/ subdirectory
463
+ * @param session - Target AgentSessionState to merge rehydrated state into
464
+ */
465
+ /**
466
+ * Reads plan.json + evidence/*.json from the project directory and populates the
467
+ * module-level _rehydrationCache. Called once at plugin init by loadSnapshot().
468
+ * Non-fatal: missing/malformed files leave an empty cache.
469
+ */
470
+ export declare function buildRehydrationCache(directory: string): Promise<void>;
471
+ /**
472
+ * Synchronously applies the cached plan+evidence data to a session.
473
+ * Merge rules:
474
+ * - evidence-derived state: only applied if it advances past existing state
475
+ * - plan-only derived state: only applied if it advances past existing state
476
+ * No-op when the cache has not been built yet.
477
+ */
478
+ export declare function applyRehydrationCache(session: AgentSessionState): void;
479
+ /**
480
+ * Rehydrates session workflow state from durable swarm files.
481
+ * Builds (or refreshes) the rehydration cache from disk, then applies it
482
+ * to the target session.
483
+ */
484
+ export declare function rehydrateSessionFromDisk(directory: string, session: AgentSessionState): Promise<void>;
485
+ /**
486
+ * Check if Turbo Mode is enabled for a specific session or ANY session.
487
+ * @param sessionID - Optional session ID to check. If provided, checks only that session.
488
+ * If omitted, checks all sessions (backward-compatible global behavior).
489
+ * @returns true if the specified session has turboMode: true, or if any session has turboMode: true when no sessionID provided
490
+ */
491
+ export declare function hasActiveTurboMode(sessionID?: string): boolean;
492
+ /**
493
+ * Check if Full Auto Mode is enabled for a specific session or ANY session.
494
+ * @param sessionID - Optional session ID to check. If provided, checks only that session.
495
+ * If omitted, checks all sessions (backward-compatible global behavior).
496
+ * @returns true if the specified session has fullAutoMode: true (model validation is advisory-only).
497
+ */
498
+ export declare function hasActiveFullAuto(sessionID?: string): boolean;
499
+ export declare function setSessionEnvironment(sessionId: string, profile: EnvironmentProfile): void;
500
+ export declare function getSessionEnvironment(sessionId: string): EnvironmentProfile | undefined;
501
+ export declare function ensureSessionEnvironment(sessionId: string): EnvironmentProfile;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Adversarial security tests for Task 2.15: Session restart rehydration
3
+ *
4
+ * ONLY attack vectors - malformed inputs, oversized payloads, injection attempts, boundary violations
5
+ * Tests the security hardening of rehydrateSessionFromDisk, readPlanFromDisk, and readGateEvidenceFromDisk
6
+ */
7
+ export {};
@@ -0,0 +1,2 @@
1
+ export { cleanupSummaries, listSummaries, loadFullOutput, storeSummary, } from './manager';
2
+ export { createSummary, detectContentType, HYSTERESIS_FACTOR, shouldSummarize, } from './summarizer';
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Validate and sanitize summary ID.
3
+ * Must match regex ^S\d+$ (e.g., S1, S2, S99)
4
+ * Rejects: empty string, null bytes, control characters, path traversal, non-matching patterns
5
+ * @throws Error with descriptive message on failure
6
+ */
7
+ export declare function sanitizeSummaryId(id: string): string;
8
+ /**
9
+ * Store a summary entry to .swarm/summaries/{id}.json.
10
+ * Performs atomic write via temp file + rename.
11
+ * @throws Error if summary ID is invalid or size limit would be exceeded
12
+ */
13
+ export declare function storeSummary(directory: string, id: string, fullOutput: string, summaryText: string, maxStoredBytes: number): Promise<void>;
14
+ /**
15
+ * Load fullOutput from a summary entry.
16
+ * Returns null if file doesn't exist or validation fails.
17
+ */
18
+ export declare function loadFullOutput(directory: string, id: string): Promise<string | null>;
19
+ /**
20
+ * List all summary IDs that have summary entries.
21
+ * Returns sorted array of valid summary IDs.
22
+ * Returns empty array if summaries directory doesn't exist.
23
+ */
24
+ export declare function listSummaries(directory: string): Promise<string[]>;
25
+ /**
26
+ * Delete summaries older than retentionDays.
27
+ * Returns array of deleted summary IDs.
28
+ */
29
+ export declare function cleanupSummaries(directory: string, retentionDays: number): Promise<string[]>;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Summarization engine for tool outputs.
3
+ * Provides content type detection, summarization decision logic, and structured summary creation.
4
+ */
5
+ /**
6
+ * Hysteresis factor to prevent churn for outputs near the threshold.
7
+ * An output must be 25% larger than the threshold to be summarized.
8
+ */
9
+ export declare const HYSTERESIS_FACTOR = 1.25;
10
+ /**
11
+ * Content type classification for tool outputs.
12
+ */
13
+ type ContentType = 'json' | 'code' | 'text' | 'binary';
14
+ /**
15
+ * Heuristic-based content type detection.
16
+ * @param output - The tool output string to analyze
17
+ * @param toolName - The name of the tool that produced the output
18
+ * @returns The detected content type: 'json', 'code', 'text', or 'binary'
19
+ */
20
+ export declare function detectContentType(output: string, toolName: string): ContentType;
21
+ /**
22
+ * Determines whether output should be summarized based on size and hysteresis.
23
+ * Uses hysteresis to prevent repeated summarization decisions for outputs near the threshold.
24
+ * @param output - The tool output string to check
25
+ * @param thresholdBytes - The threshold in bytes
26
+ * @returns true if the output should be summarized
27
+ */
28
+ export declare function shouldSummarize(output: string, thresholdBytes: number): boolean;
29
+ /**
30
+ * Creates a structured summary string from tool output.
31
+ * @param output - The full tool output string
32
+ * @param toolName - The name of the tool that produced the output
33
+ * @param summaryId - Unique identifier for this summary
34
+ * @param maxSummaryChars - Maximum characters allowed for the preview
35
+ * @returns Formatted summary string
36
+ */
37
+ export declare function createSummary(output: string, toolName: string, summaryId: string, maxSummaryChars: number): string;
38
+ export {};
@@ -0,0 +1,59 @@
1
+ export type TelemetryEvent = 'session_started' | 'session_ended' | 'agent_activated' | 'delegation_begin' | 'delegation_end' | 'task_state_changed' | 'gate_passed' | 'gate_failed' | 'phase_changed' | 'budget_updated' | 'model_fallback' | 'hard_limit_hit' | 'revision_limit_hit' | 'loop_detected' | 'scope_violation' | 'qa_skip_violation' | 'heartbeat' | 'turbo_mode_changed' | 'auto_oversight_escalation' | 'environment_detected' | 'evidence_lock_acquired' | 'evidence_lock_contended' | 'evidence_lock_stale_recovered' | 'plan_ledger_cas_retry' | 'plan_md_write_failed' | 'prm_pattern_detected' | 'prm_course_correction_injected' | 'prm_escalation_triggered' | 'prm_hard_stop';
2
+ export type TelemetryListener = (event: TelemetryEvent, data: Record<string, unknown>) => void;
3
+ /** @internal - For testing only */
4
+ export declare function resetTelemetryForTesting(): void;
5
+ /**
6
+ * Initialize telemetry with the project directory.
7
+ * Creates `.swarm/` if it doesn't exist and opens `telemetry.jsonl` for appending.
8
+ * Idempotent — calling multiple times has no effect after the first successful call.
9
+ * @param projectDirectory - Absolute path to the project root
10
+ */
11
+ export declare function initTelemetry(projectDirectory: string): void;
12
+ /**
13
+ * Emit a telemetry event.
14
+ * Writes a JSONL line to `.swarm/telemetry.jsonl` and notifies all registered listeners.
15
+ * Fire-and-forget — errors are silently swallowed and never propagate to the caller.
16
+ * @param event - The event type
17
+ * @param data - Arbitrary event payload (sessionId always required by convention)
18
+ */
19
+ export declare function emit(event: TelemetryEvent, data: Record<string, unknown>): void;
20
+ /**
21
+ * Register a listener for telemetry events.
22
+ * Listeners receive every event that is emitted (if telemetry is not disabled).
23
+ * Listener errors are silently swallowed — they never break execution.
24
+ * @param callback - Function called with (event, data) on each emit
25
+ */
26
+ export declare function addTelemetryListener(callback: TelemetryListener): void;
27
+ /**
28
+ * Rotate telemetry file if it exceeds maxBytes.
29
+ * Renames `telemetry.jsonl` → `telemetry.jsonl.1` and reopens a fresh stream.
30
+ * Errors are silently swallowed.
31
+ * @param maxBytes - Size threshold in bytes (default: 10MB)
32
+ */
33
+ export declare function rotateTelemetryIfNeeded(maxBytes?: number): void;
34
+ export declare const telemetry: {
35
+ sessionStarted(sessionId: string, agentName: string): void;
36
+ sessionEnded(sessionId: string, reason: string): void;
37
+ agentActivated(sessionId: string, agentName: string, oldName?: string): void;
38
+ delegationBegin(sessionId: string, agentName: string, taskId: string): void;
39
+ delegationEnd(sessionId: string, agentName: string, taskId: string, result: string): void;
40
+ taskStateChanged(sessionId: string, taskId: string, newState: string, oldState?: string): void;
41
+ gatePassed(sessionId: string, gate: string, taskId: string): void;
42
+ gateFailed(sessionId: string, gate: string, taskId: string, reason: string): void;
43
+ phaseChanged(sessionId: string, oldPhase: number, newPhase: number): void;
44
+ budgetUpdated(sessionId: string, budgetPct: number, agentName: string): void;
45
+ modelFallback(sessionId: string, agentName: string, fromModel: string, toModel: string, reason: string): void;
46
+ hardLimitHit(sessionId: string, agentName: string, limitType: string, value: number): void;
47
+ revisionLimitHit(sessionId: string, agentName: string): void;
48
+ loopDetected(sessionId: string, agentName: string, loopType: string): void;
49
+ scopeViolation(sessionId: string, agentName: string, file: string, reason: string): void;
50
+ qaSkipViolation(sessionId: string, agentName: string, skipCount: number): void;
51
+ heartbeat(sessionId: string): void;
52
+ turboModeChanged(sessionId: string, enabled: boolean, agentName: string): void;
53
+ autoOversightEscalation(sessionId: string, reason: string, interactionCount: number, deadlockCount: number, phase?: number): void;
54
+ environmentDetected(sessionId: string, hostOS: string, shellFamily: string, executionMode: string): void;
55
+ prmPatternDetected(sessionId: string, pattern: string, severity: string, category: string, stepRange: [number, number]): void;
56
+ prmCourseCorrectionInjected(sessionId: string, pattern: string, level: number): void;
57
+ prmEscalationTriggered(sessionId: string, pattern: string, level: number, occurrenceCount: number): void;
58
+ prmHardStop(sessionId: string, pattern: string, level: number, occurrenceCount: number): void;
59
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};