opencode-swarm 6.27.1 → 8.0.0-beta.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 (281) hide show
  1. package/README.md +40 -1179
  2. package/dist/{agents/architect.d.ts → architect.d.ts} +1 -5
  3. package/dist/checkpoint.d.ts +7 -0
  4. package/dist/cli/index.js +11353 -20907
  5. package/dist/co-change-analyzer.d.ts +1 -0
  6. package/dist/compat.d.ts +12 -0
  7. package/dist/config-doctor.d.ts +1 -0
  8. package/dist/{config/loader.d.ts → config.d.ts} +6 -11
  9. package/dist/detector.d.ts +7 -0
  10. package/dist/diagnose-service.d.ts +1 -0
  11. package/dist/evidence-schema.d.ts +2 -0
  12. package/dist/evidence-service.d.ts +1 -0
  13. package/dist/export-service.d.ts +1 -0
  14. package/dist/handoff-service.d.ts +1 -0
  15. package/dist/history-service.d.ts +1 -0
  16. package/dist/hive-promoter.d.ts +2 -0
  17. package/dist/index.d.ts +1 -15
  18. package/dist/index.js +49007 -48213
  19. package/dist/knowledge-migrator.d.ts +2 -0
  20. package/dist/knowledge-store.d.ts +1 -0
  21. package/dist/knowledge-types.d.ts +1 -0
  22. package/dist/knowledge-validator.d.ts +2 -0
  23. package/dist/loader.d.ts +1 -0
  24. package/dist/manager.d.ts +1 -0
  25. package/dist/models.d.ts +1 -0
  26. package/dist/plan-service.d.ts +1 -0
  27. package/dist/preflight-service.d.ts +1 -0
  28. package/dist/profiles.d.ts +7 -0
  29. package/dist/register.d.ts +36 -0
  30. package/dist/schema.d.ts +2 -0
  31. package/dist/snapshot-writer.d.ts +1 -0
  32. package/dist/state.d.ts +1 -292
  33. package/dist/status-service.d.ts +15 -0
  34. package/dist/telemetry/src/events.d.ts +308 -0
  35. package/dist/telemetry/src/guards.d.ts +14 -0
  36. package/dist/telemetry/src/index.d.ts +4 -0
  37. package/dist/telemetry/src/version.d.ts +1 -0
  38. package/dist/utils.d.ts +1 -0
  39. package/dist/write-retro.d.ts +1 -0
  40. package/package.json +12 -13
  41. package/LICENSE +0 -21
  42. package/dist/__tests__/security-adversarial.test.d.ts +0 -1
  43. package/dist/agents/architect-permission.adversarial.test.d.ts +0 -5
  44. package/dist/agents/architect.turbo-banner.test.d.ts +0 -1
  45. package/dist/agents/coder.d.ts +0 -2
  46. package/dist/agents/critic.d.ts +0 -3
  47. package/dist/agents/designer.d.ts +0 -2
  48. package/dist/agents/docs.d.ts +0 -2
  49. package/dist/agents/explorer.d.ts +0 -3
  50. package/dist/agents/index.d.ts +0 -27
  51. package/dist/agents/reviewer.d.ts +0 -5
  52. package/dist/agents/sme.d.ts +0 -2
  53. package/dist/agents/test-engineer.adversarial.test.d.ts +0 -5
  54. package/dist/agents/test-engineer.d.ts +0 -2
  55. package/dist/agents/test-engineer.security.test.d.ts +0 -1
  56. package/dist/background/circuit-breaker.d.ts +0 -149
  57. package/dist/background/event-bus.d.ts +0 -60
  58. package/dist/background/evidence-summary-integration.d.ts +0 -73
  59. package/dist/background/index.d.ts +0 -22
  60. package/dist/background/manager.d.ts +0 -122
  61. package/dist/background/plan-sync-worker.d.ts +0 -122
  62. package/dist/background/queue.d.ts +0 -117
  63. package/dist/background/status-artifact.d.ts +0 -115
  64. package/dist/background/trigger.d.ts +0 -179
  65. package/dist/background/trigger.vulnerability.test.d.ts +0 -1
  66. package/dist/background/worker.d.ts +0 -92
  67. package/dist/cli/index.d.ts +0 -6
  68. package/dist/commands/checkpoint.d.ts +0 -5
  69. package/dist/commands/command-adapters.security.test.d.ts +0 -14
  70. package/dist/commands/commands.test.d.ts +0 -1
  71. package/dist/commands/config.d.ts +0 -5
  72. package/dist/commands/curate.test.d.ts +0 -1
  73. package/dist/commands/index.d.ts +0 -39
  74. package/dist/commands/turbo-registration.test.d.ts +0 -5
  75. package/dist/commands/turbo-sessionid.test.d.ts +0 -5
  76. package/dist/commands/turbo.regression.test.d.ts +0 -11
  77. package/dist/commands/turbo.test.d.ts +0 -5
  78. package/dist/config/constants.architect-whitelist.test.d.ts +0 -1
  79. package/dist/config/constants.d.ts +0 -37
  80. package/dist/config/evidence-schema.d.ts +0 -1152
  81. package/dist/config/index.d.ts +0 -9
  82. package/dist/config/plan-schema.d.ts +0 -151
  83. package/dist/config/schema.d.ts +0 -700
  84. package/dist/context/role-filter.d.ts +0 -27
  85. package/dist/context/zone-classifier.d.ts +0 -17
  86. package/dist/diff/ast-diff.d.ts +0 -20
  87. package/dist/evidence/index.d.ts +0 -2
  88. package/dist/evidence/manager.d.ts +0 -74
  89. package/dist/gate-evidence.d.ts +0 -70
  90. package/dist/gate-evidence.test.d.ts +0 -1
  91. package/dist/git/branch.d.ts +0 -50
  92. package/dist/git/index.d.ts +0 -22
  93. package/dist/git/pr.d.ts +0 -28
  94. package/dist/hooks/adversarial-detector.d.ts +0 -34
  95. package/dist/hooks/agent-activity.d.ts +0 -38
  96. package/dist/hooks/co-change-suggester.d.ts +0 -51
  97. package/dist/hooks/compaction-customizer.d.ts +0 -11
  98. package/dist/hooks/context-budget.d.ts +0 -34
  99. package/dist/hooks/context-scoring.d.ts +0 -70
  100. package/dist/hooks/curator-drift.d.ts +0 -30
  101. package/dist/hooks/curator-types.d.ts +0 -99
  102. package/dist/hooks/curator.d.ts +0 -70
  103. package/dist/hooks/dark-matter-detector.d.ts +0 -38
  104. package/dist/hooks/delegation-gate.d.ts +0 -53
  105. package/dist/hooks/delegation-gate.evidence.test.d.ts +0 -4
  106. package/dist/hooks/delegation-gate.plan-fallback-security.test.d.ts +0 -13
  107. package/dist/hooks/delegation-gate.plan-fallback.test.d.ts +0 -5
  108. package/dist/hooks/delegation-gate.seed-state.test.d.ts +0 -1
  109. package/dist/hooks/delegation-gate.turbo-evidence.test.d.ts +0 -8
  110. package/dist/hooks/delegation-sanitizer.d.ts +0 -24
  111. package/dist/hooks/delegation-tracker.d.ts +0 -14
  112. package/dist/hooks/extractors.d.ts +0 -53
  113. package/dist/hooks/guardrails.d.ts +0 -73
  114. package/dist/hooks/hive-promoter.d.ts +0 -40
  115. package/dist/hooks/index.d.ts +0 -16
  116. package/dist/hooks/knowledge-curator.d.ts +0 -22
  117. package/dist/hooks/knowledge-injector.d.ts +0 -20
  118. package/dist/hooks/knowledge-migrator.d.ts +0 -10
  119. package/dist/hooks/knowledge-reader.d.ts +0 -22
  120. package/dist/hooks/knowledge-store.d.ts +0 -20
  121. package/dist/hooks/knowledge-types.d.ts +0 -117
  122. package/dist/hooks/knowledge-validator.d.ts +0 -28
  123. package/dist/hooks/message-priority.d.ts +0 -105
  124. package/dist/hooks/messages-transform.d.ts +0 -13
  125. package/dist/hooks/model-limits.d.ts +0 -96
  126. package/dist/hooks/phase-monitor.d.ts +0 -22
  127. package/dist/hooks/pipeline-tracker.d.ts +0 -41
  128. package/dist/hooks/steering-consumed.d.ts +0 -30
  129. package/dist/hooks/system-enhancer.d.ts +0 -30
  130. package/dist/hooks/tool-summarizer.d.ts +0 -28
  131. package/dist/hooks/utils.d.ts +0 -20
  132. package/dist/index.adversarial-bootstrap.test.d.ts +0 -1
  133. package/dist/index.bootstrap-adversarial.test.d.ts +0 -1
  134. package/dist/index.bootstrap-directory.test.d.ts +0 -1
  135. package/dist/knowledge/identity.d.ts +0 -25
  136. package/dist/knowledge/index.d.ts +0 -2
  137. package/dist/lang/detector.d.ts +0 -20
  138. package/dist/lang/grammars/tree-sitter-dart.wasm +0 -0
  139. package/dist/lang/grammars/tree-sitter-kotlin.wasm +0 -0
  140. package/dist/lang/grammars/tree-sitter-swift.wasm +0 -0
  141. package/dist/lang/index.d.ts +0 -4
  142. package/dist/lang/profiles.d.ts +0 -71
  143. package/dist/lang/registry.d.ts +0 -24
  144. package/dist/lang/runtime.d.ts +0 -35
  145. package/dist/output/agent-writer.d.ts +0 -27
  146. package/dist/output/index.d.ts +0 -1
  147. package/dist/parallel/dependency-graph.d.ts +0 -34
  148. package/dist/parallel/file-locks.d.ts +0 -33
  149. package/dist/parallel/index.d.ts +0 -4
  150. package/dist/parallel/meta-indexer.d.ts +0 -32
  151. package/dist/parallel/review-router.d.ts +0 -29
  152. package/dist/plan/index.d.ts +0 -1
  153. package/dist/plan/manager.d.ts +0 -40
  154. package/dist/plan/manager.update-task-status.test.d.ts +0 -1
  155. package/dist/quality/index.d.ts +0 -1
  156. package/dist/quality/metrics.d.ts +0 -20
  157. package/dist/sast/rules/c.d.ts +0 -9
  158. package/dist/sast/rules/csharp.d.ts +0 -9
  159. package/dist/sast/rules/go.d.ts +0 -9
  160. package/dist/sast/rules/index.d.ts +0 -72
  161. package/dist/sast/rules/java.d.ts +0 -9
  162. package/dist/sast/rules/javascript.d.ts +0 -9
  163. package/dist/sast/rules/php.d.ts +0 -9
  164. package/dist/sast/rules/python.d.ts +0 -9
  165. package/dist/sast/semgrep.d.ts +0 -68
  166. package/dist/sast/semgrep.test.d.ts +0 -1
  167. package/dist/sbom/cyclonedx.d.ts +0 -101
  168. package/dist/sbom/detectors/dart.d.ts +0 -7
  169. package/dist/sbom/detectors/dotnet.d.ts +0 -7
  170. package/dist/sbom/detectors/go.d.ts +0 -7
  171. package/dist/sbom/detectors/index.d.ts +0 -53
  172. package/dist/sbom/detectors/java.d.ts +0 -7
  173. package/dist/sbom/detectors/nodejs.d.ts +0 -7
  174. package/dist/sbom/detectors/python.d.ts +0 -7
  175. package/dist/sbom/detectors/rust.d.ts +0 -7
  176. package/dist/sbom/detectors/swift.d.ts +0 -7
  177. package/dist/services/config-doctor.d.ts +0 -125
  178. package/dist/services/config-doctor.security.test.d.ts +0 -1
  179. package/dist/services/config-doctor.test.d.ts +0 -1
  180. package/dist/services/context-budget-service.d.ts +0 -101
  181. package/dist/services/decision-drift-analyzer.d.ts +0 -96
  182. package/dist/services/diagnose-service.d.ts +0 -31
  183. package/dist/services/evidence-service.d.ts +0 -65
  184. package/dist/services/evidence-summary-service.d.ts +0 -75
  185. package/dist/services/export-service.d.ts +0 -23
  186. package/dist/services/handoff-service.d.ts +0 -61
  187. package/dist/services/history-service.d.ts +0 -35
  188. package/dist/services/index.d.ts +0 -13
  189. package/dist/services/plan-service.d.ts +0 -25
  190. package/dist/services/preflight-integration.d.ts +0 -38
  191. package/dist/services/preflight-service.d.ts +0 -62
  192. package/dist/services/run-memory.d.ts +0 -66
  193. package/dist/services/status-service.d.ts +0 -29
  194. package/dist/services/status-service.turbo-indicator.test.d.ts +0 -5
  195. package/dist/session/snapshot-reader.d.ts +0 -37
  196. package/dist/session/snapshot-writer.d.ts +0 -89
  197. package/dist/skills/index.d.ts +0 -30
  198. package/dist/state.rehydrate.test.d.ts +0 -1
  199. package/dist/state.rehydration-adversarial.test.d.ts +0 -1
  200. package/dist/state.rehydration-integration.test.d.ts +0 -1
  201. package/dist/state.session-restart.test.d.ts +0 -7
  202. package/dist/summaries/index.d.ts +0 -2
  203. package/dist/summaries/manager.d.ts +0 -29
  204. package/dist/summaries/summarizer.d.ts +0 -38
  205. package/dist/tools/barrel-export-check-gate-status.test.d.ts +0 -6
  206. package/dist/tools/build-check.d.ts +0 -50
  207. package/dist/tools/check-gate-status.adversarial.test.d.ts +0 -1
  208. package/dist/tools/check-gate-status.d.ts +0 -7
  209. package/dist/tools/check-gate-status.gates.test.d.ts +0 -1
  210. package/dist/tools/check-gate-status.plugin-registration.test.d.ts +0 -1
  211. package/dist/tools/checkpoint.d.ts +0 -2
  212. package/dist/tools/co-change-analyzer.d.ts +0 -45
  213. package/dist/tools/complexity-hotspots.d.ts +0 -2
  214. package/dist/tools/declare-scope.d.ts +0 -49
  215. package/dist/tools/diff.d.ts +0 -18
  216. package/dist/tools/domain-detector.d.ts +0 -6
  217. package/dist/tools/evidence-check.d.ts +0 -8
  218. package/dist/tools/file-extractor.d.ts +0 -9
  219. package/dist/tools/gitingest.d.ts +0 -18
  220. package/dist/tools/imports.d.ts +0 -5
  221. package/dist/tools/index.d.ts +0 -31
  222. package/dist/tools/knowledge-query.d.ts +0 -5
  223. package/dist/tools/lint.d.ts +0 -50
  224. package/dist/tools/phase-complete.d.ts +0 -25
  225. package/dist/tools/pkg-audit.d.ts +0 -2
  226. package/dist/tools/placeholder-scan.d.ts +0 -26
  227. package/dist/tools/plugin-registration-adversarial.test.d.ts +0 -1
  228. package/dist/tools/pre-check-batch.d.ts +0 -56
  229. package/dist/tools/quality-budget.d.ts +0 -24
  230. package/dist/tools/retrieve-summary.d.ts +0 -2
  231. package/dist/tools/sast-scan.d.ts +0 -60
  232. package/dist/tools/save-plan.d.ts +0 -63
  233. package/dist/tools/sbom-generate.d.ts +0 -26
  234. package/dist/tools/schema-drift.d.ts +0 -2
  235. package/dist/tools/secretscan.d.ts +0 -35
  236. package/dist/tools/symbols.d.ts +0 -2
  237. package/dist/tools/syntax-check.d.ts +0 -35
  238. package/dist/tools/test-runner.d.ts +0 -49
  239. package/dist/tools/test-runner.security-adversarial.test.d.ts +0 -5
  240. package/dist/tools/todo-extract.d.ts +0 -2
  241. package/dist/tools/tool-names.d.ts +0 -10
  242. package/dist/tools/update-task-status.d.ts +0 -74
  243. package/dist/tools/update-task-status.gates.test.d.ts +0 -1
  244. package/dist/tools/update-task-status.turbo-bypass.test.d.ts +0 -1
  245. package/dist/tools/write-retro.d.ts +0 -53
  246. package/dist/types/delegation.d.ts +0 -24
  247. package/dist/types/events.d.ts +0 -55
  248. package/dist/utils/errors.d.ts +0 -33
  249. package/dist/utils/index.d.ts +0 -4
  250. package/dist/utils/logger.d.ts +0 -3
  251. package/dist/utils/merge.d.ts +0 -5
  252. package/dist/utils/regex.d.ts +0 -30
  253. package/dist/utils/tool-output.d.ts +0 -10
  254. /package/dist/{commands/agents.d.ts → agents.d.ts} +0 -0
  255. /package/dist/{commands/analyze.d.ts → analyze.d.ts} +0 -0
  256. /package/dist/{commands/archive.d.ts → archive.d.ts} +0 -0
  257. /package/dist/{commands/benchmark.d.ts → benchmark.d.ts} +0 -0
  258. /package/dist/{commands/clarify.d.ts → clarify.d.ts} +0 -0
  259. /package/dist/{tools/create-tool.d.ts → create-tool.d.ts} +0 -0
  260. /package/dist/{commands/curate.d.ts → curate.d.ts} +0 -0
  261. /package/dist/{commands/dark-matter.d.ts → dark-matter.d.ts} +0 -0
  262. /package/dist/{commands/diagnose.d.ts → diagnose.d.ts} +0 -0
  263. /package/dist/{build/discovery.d.ts → discovery.d.ts} +0 -0
  264. /package/dist/{commands/doctor.d.ts → doctor.d.ts} +0 -0
  265. /package/dist/{commands/evidence.d.ts → evidence.d.ts} +0 -0
  266. /package/dist/{commands/export.d.ts → export.d.ts} +0 -0
  267. /package/dist/{commands/handoff.d.ts → handoff.d.ts} +0 -0
  268. /package/dist/{commands/history.d.ts → history.d.ts} +0 -0
  269. /package/dist/{commands/knowledge.d.ts → knowledge.d.ts} +0 -0
  270. /package/dist/{commands/plan.d.ts → plan.d.ts} +0 -0
  271. /package/dist/{commands/preflight.d.ts → preflight.d.ts} +0 -0
  272. /package/dist/{commands/promote.d.ts → promote.d.ts} +0 -0
  273. /package/dist/{commands/reset.d.ts → reset.d.ts} +0 -0
  274. /package/dist/{commands/retrieve.d.ts → retrieve.d.ts} +0 -0
  275. /package/dist/{commands/rollback.d.ts → rollback.d.ts} +0 -0
  276. /package/dist/{commands/simulate.d.ts → simulate.d.ts} +0 -0
  277. /package/dist/{commands/specify.d.ts → specify.d.ts} +0 -0
  278. /package/dist/{commands/status.d.ts → status.d.ts} +0 -0
  279. /package/dist/{commands/sync-plan.d.ts → sync-plan.d.ts} +0 -0
  280. /package/dist/{commands/turbo.d.ts → turbo.d.ts} +0 -0
  281. /package/dist/{commands/write_retro.d.ts → write_retro.d.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ export type { MigrationResult } from '@opencode-swarm/core';
2
+ export { migrateContextToKnowledge } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export { appendKnowledge, appendRejectedLesson, computeConfidence, findNearDuplicate, getPlatformConfigDir, inferTags, jaccardBigram, normalize, readKnowledge, readRejectedLessons, resolveHiveKnowledgePath, resolveHiveRejectedPath, resolveSwarmKnowledgePath, resolveSwarmRejectedPath, rewriteKnowledge, wordBigrams, } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export type { HiveKnowledgeEntry, KnowledgeCategory, KnowledgeConfig, KnowledgeEntryBase, MessageInfo, MessagePart, PhaseConfirmationRecord, ProjectConfirmationRecord, RejectedLesson, RetrievalOutcome, SwarmKnowledgeEntry, } from '@opencode-swarm/core';
@@ -0,0 +1,2 @@
1
+ export type { EntryHealthResult, QuarantinedEntry, ValidationResult, } from '@opencode-swarm/core';
2
+ export { auditEntryHealth, DANGEROUS_COMMAND_PATTERNS, INJECTION_PATTERNS, quarantineEntry, restoreEntry, SECURITY_DEGRADING_PATTERNS, validateLesson, } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export { loadPluginConfig, loadPluginConfigWithMeta, loadRawConfigFromPath, MAX_CONFIG_FILE_BYTES, } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export { loadFullOutput } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_MODELS: Record<string, string>;
@@ -0,0 +1 @@
1
+ export { formatPlanMarkdown, getPlanData, handlePlanCommand, type PlanData, } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export { formatPreflightMarkdown, handlePreflightCommand, type PreflightCheckResult, type PreflightCheckType, type PreflightConfig, type PreflightReport, runPreflight, } from '@opencode-swarm/core';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Language Profiles Bridge
3
+ *
4
+ * Re-exports language profile registry and types from @opencode-swarm/core.
5
+ * Maintains compatibility for legacy import paths.
6
+ */
7
+ export { type BuildCommand, LANGUAGE_REGISTRY, type LanguageProfile, LanguageRegistry, type LintTool, type TestFramework, } from '@opencode-swarm/core';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * OpenCode Plugin Tool Registration
3
+ *
4
+ * Wraps core tool logic functions with createSwarmTool() for OpenCode plugin registration.
5
+ * Each tool:
6
+ * - Has plugin-compatible arg schema
7
+ * - Injects directory from plugin context
8
+ * - Returns serialized JSON/text consistent with current tool behavior
9
+ */
10
+ import type { tool } from '@opencode-ai/plugin';
11
+ type SwarmTool = ReturnType<typeof tool>;
12
+ export declare const check_gate_status: SwarmTool;
13
+ export declare const checkpoint: SwarmTool;
14
+ export declare const complexity_hotspots: SwarmTool;
15
+ export declare const declare_scope: SwarmTool;
16
+ export declare const detect_domains: SwarmTool;
17
+ export declare const diff: SwarmTool;
18
+ export declare const evidence_check: SwarmTool;
19
+ export declare const extract_code_blocks: SwarmTool;
20
+ export declare const gitingest: SwarmTool;
21
+ export declare const imports: SwarmTool;
22
+ export declare const knowledge_query: SwarmTool;
23
+ export declare const lint: SwarmTool;
24
+ export declare const phase_complete: SwarmTool;
25
+ export declare const pkg_audit: SwarmTool;
26
+ export declare const pre_check_batch: SwarmTool;
27
+ export declare const retrieve_summary: SwarmTool;
28
+ export declare const save_plan: SwarmTool;
29
+ export declare const schema_drift: SwarmTool;
30
+ export declare const secretscan: SwarmTool;
31
+ export declare const symbols: SwarmTool;
32
+ export declare const test_runner: SwarmTool;
33
+ export declare const todo_extract: SwarmTool;
34
+ export declare const update_task_status: SwarmTool;
35
+ export declare const write_retro: SwarmTool;
36
+ export {};
@@ -0,0 +1,2 @@
1
+ export type { GuardrailsConfig, KnowledgeConfig, PluginConfig, } from '@opencode-swarm/core';
2
+ export { KnowledgeConfigSchema } from '@opencode-swarm/core';
@@ -0,0 +1 @@
1
+ export { writeSnapshot } from '@opencode-swarm/core';
package/dist/state.d.ts CHANGED
@@ -1,292 +1 @@
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
- /**
10
- * Represents a single tool call entry for tracking purposes
11
- */
12
- export interface ToolCallEntry {
13
- tool: string;
14
- sessionID: string;
15
- callID: string;
16
- startTime: number;
17
- }
18
- /**
19
- * Aggregated statistics for a specific tool
20
- */
21
- export interface ToolAggregate {
22
- tool: string;
23
- count: number;
24
- successCount: number;
25
- failureCount: number;
26
- totalDuration: number;
27
- }
28
- /**
29
- * Represents a delegation from one agent to another
30
- */
31
- export interface DelegationEntry {
32
- from: string;
33
- to: string;
34
- timestamp: number;
35
- }
36
- /**
37
- * Per-task workflow state for gate progression tracking.
38
- * Transitions must be forward-only: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
39
- */
40
- export type TaskWorkflowState = 'idle' | 'coder_delegated' | 'pre_check_passed' | 'reviewer_run' | 'tests_run' | 'complete';
41
- /**
42
- * Represents per-session state for guardrail tracking.
43
- * Budget fields (toolCallCount, consecutiveErrors, etc.) have moved to InvocationWindow.
44
- * This interface now tracks session-level metadata and window management.
45
- */
46
- export interface AgentSessionState {
47
- /** Current agent identity for this session */
48
- agentName: string;
49
- /** Timestamp of most recent tool call (for session-level stale detection) */
50
- lastToolCallTime: number;
51
- /** Timestamp of most recent agent identity event (chat.message) */
52
- lastAgentEventTime: number;
53
- /** Whether active delegation is in progress for this session */
54
- delegationActive: boolean;
55
- /** Current active invocation ID for this agent */
56
- activeInvocationId: number;
57
- /** Last invocation ID by agent name (e.g., { "coder": 3, "reviewer": 1 }) */
58
- lastInvocationIdByAgent: Record<string, number>;
59
- /** Active invocation windows keyed by "${agentName}:${invId}" */
60
- windows: Record<string, InvocationWindow>;
61
- /** Last tool-call threshold at which a compaction hint was issued */
62
- lastCompactionHint: number;
63
- /** Count of architect direct writes to non-.swarm/ files */
64
- architectWriteCount: number;
65
- /** Last task ID that was delegated to coder (for zero-delegation detection) */
66
- lastCoderDelegationTaskId: string | null;
67
- /** Current task ID being worked on (set when coder delegation fires, used for per-task gate tracking) */
68
- currentTaskId: string | null;
69
- /** Gate names observed for current task (taskId → Set of gates) */
70
- gateLog: Map<string, Set<string>>;
71
- /** Reviewer delegations per phase (phaseNumber → count) */
72
- reviewerCallCount: Map<number, number>;
73
- /** Last gate failure for self-fix detection */
74
- lastGateFailure: {
75
- tool: string;
76
- taskId: string;
77
- timestamp: number;
78
- } | null;
79
- /** Task IDs for which partial gate warning has already been issued (prevents per-task spam) */
80
- partialGateWarningsIssuedForTask: Set<string>;
81
- /** Whether architect attempted self-fix write after gate failure */
82
- selfFixAttempted: boolean;
83
- /** Value of architectWriteCount at the time the self-coding warning was last injected.
84
- * Warning is suppressed unless architectWriteCount has increased since last injection. */
85
- selfCodingWarnedAtCount: number;
86
- /** Phases that have already received a catastrophic zero-reviewer warning */
87
- catastrophicPhaseWarnings: Set<number>;
88
- /** Number of consecutive coder delegations without reviewer/test_engineer between them */
89
- qaSkipCount: number;
90
- /** Task IDs skipped without QA (for audit trail), reset when reviewer/test_engineer fires */
91
- qaSkipTaskIds: string[];
92
- /** Per-task workflow state — taskId → current state */
93
- taskWorkflowStates: Map<string, TaskWorkflowState>;
94
- /** Last gate outcome for deliberation preamble injection */
95
- lastGateOutcome: {
96
- gate: string;
97
- taskId: string;
98
- passed: boolean;
99
- timestamp: number;
100
- } | null;
101
- /** Declared file scope for current coder task (null = no scope declared) */
102
- declaredCoderScope: string[] | null;
103
- /** Last scope violation message (null = no violation) */
104
- lastScopeViolation: string | null;
105
- /** Flag for one-shot scope violation warning injection in messagesTransform */
106
- scopeViolationDetected?: boolean;
107
- /** Files modified by the current coder task (populated by guardrails toolBefore/toolAfter, reset on new coder delegation) */
108
- modifiedFilesThisCoderTask: string[];
109
- /** Timestamp of most recent phase completion */
110
- lastPhaseCompleteTimestamp: number;
111
- /** Phase number of most recent phase completion */
112
- lastPhaseCompletePhase: number;
113
- /** Set of agents dispatched in current phase (normalized names) */
114
- phaseAgentsDispatched: Set<string>;
115
- /** Set of agents dispatched in the most recently completed phase (persisted across phase reset) */
116
- lastCompletedPhaseAgentsDispatched: Set<string>;
117
- /** Session-scoped Turbo Mode flag for controlling LLM inference speed */
118
- turboMode: boolean;
119
- }
120
- /**
121
- * Represents a single agent invocation window with isolated guardrail budgets.
122
- * Each time the architect delegates to an agent, a new window is created.
123
- * Architect never creates windows (unlimited).
124
- */
125
- export interface InvocationWindow {
126
- /** Unique ID for this invocation (increments per agent type) */
127
- id: number;
128
- /** Agent name (stripped of swarm prefix) */
129
- agentName: string;
130
- /** Timestamp when this invocation started */
131
- startedAtMs: number;
132
- /** Tool calls made in this invocation */
133
- toolCalls: number;
134
- /** Consecutive errors in this invocation */
135
- consecutiveErrors: number;
136
- /** Whether hard limit was hit for this invocation */
137
- hardLimitHit: boolean;
138
- /** Timestamp of most recent successful tool call */
139
- lastSuccessTimeMs: number;
140
- /** Circular buffer of recent tool calls (max 20) for repetition detection */
141
- recentToolCalls: Array<{
142
- tool: string;
143
- argsHash: number;
144
- timestamp: number;
145
- }>;
146
- /** Whether soft warning has been issued for this invocation */
147
- warningIssued: boolean;
148
- /** Human-readable warning reason */
149
- warningReason: string;
150
- }
151
- /**
152
- * Singleton state object for sharing data across hooks
153
- */
154
- export declare const swarmState: {
155
- /** Active tool calls — keyed by callID for before→after correlation */
156
- activeToolCalls: Map<string, ToolCallEntry>;
157
- /** Aggregated tool usage stats — keyed by tool name */
158
- toolAggregates: Map<string, ToolAggregate>;
159
- /** Active agent per session — keyed by sessionID, updated by chat.message hook */
160
- activeAgent: Map<string, string>;
161
- /** Delegation chains per session — keyed by sessionID */
162
- delegationChains: Map<string, DelegationEntry[]>;
163
- /** Number of events since last flush */
164
- pendingEvents: number;
165
- /** Per-session guardrail state — keyed by sessionID */
166
- agentSessions: Map<string, AgentSessionState>;
167
- };
168
- /**
169
- * Reset all state to initial values - useful for testing
170
- */
171
- export declare function resetSwarmState(): void;
172
- /**
173
- * Start a new agent session with initialized guardrail state.
174
- * Also removes any stale sessions older than staleDurationMs.
175
- * @param sessionId - The session identifier
176
- * @param agentName - The agent associated with this session
177
- * @param staleDurationMs - Age threshold for stale session eviction (default: 120 min)
178
- * @param directory - Optional project directory for rehydrating workflow state from disk
179
- */
180
- export declare function startAgentSession(sessionId: string, agentName: string, staleDurationMs?: number, directory?: string): void;
181
- /**
182
- * End an agent session by removing it from the state.
183
- * NOTE: Currently unused in production — no session lifecycle teardown is wired up.
184
- * Sessions accumulate for the process lifetime. Callers should integrate this into
185
- * a session TTL or idle-timeout mechanism to prevent unbounded Map growth.
186
- * @param sessionId - The session identifier to remove
187
- */
188
- export declare function endAgentSession(sessionId: string): void;
189
- /**
190
- * Get an agent session state by session ID.
191
- * @param sessionId - The session identifier
192
- * @returns The AgentSessionState or undefined if not found
193
- */
194
- export declare function getAgentSession(sessionId: string): AgentSessionState | undefined;
195
- /**
196
- * Ensure a guardrail session exists for the given sessionID.
197
- * If one exists and agentName is provided and different, update it.
198
- * If none exists, create one.
199
- * Always updates lastToolCallTime.
200
- * @param sessionId - The session identifier
201
- * @param agentName - Optional agent name (if known)
202
- * @param directory - Optional project directory for rehydrating workflow state from disk
203
- * @returns The AgentSessionState
204
- */
205
- export declare function ensureAgentSession(sessionId: string, agentName?: string, directory?: string): AgentSessionState;
206
- /**
207
- * Update only the agent event timestamp (for stale detection).
208
- * Does NOT change agent name or reset guardrail state.
209
- * @param sessionId - The session identifier
210
- */
211
- export declare function updateAgentEventTime(sessionId: string): void;
212
- /**
213
- * Begin a new invocation window for the given agent.
214
- * Increments invocation ID, creates fresh budget counters.
215
- * Returns null for architect (unlimited, no window).
216
- *
217
- * @param sessionId - Session identifier
218
- * @param agentName - Agent name (with or without swarm prefix)
219
- * @returns New window or null if architect
220
- */
221
- export declare function beginInvocation(sessionId: string, agentName: string): InvocationWindow | null;
222
- /**
223
- * Get the currently active invocation window for the session.
224
- * Returns undefined if no window exists (e.g., architect session).
225
- *
226
- * @param sessionId - Session identifier
227
- * @returns Active window or undefined
228
- */
229
- export declare function getActiveWindow(sessionId: string): InvocationWindow | undefined;
230
- /**
231
- * Prune old invocation windows to prevent unbounded memory growth.
232
- * Removes windows older than maxAgeMs and keeps only the most recent maxWindows.
233
- *
234
- * @param sessionId - Session identifier
235
- * @param maxAgeMs - Maximum age in milliseconds (default 24 hours)
236
- * @param maxWindows - Maximum number of windows to keep (default 50)
237
- */
238
- export declare function pruneOldWindows(sessionId: string, maxAgeMs?: number, maxWindows?: number): void;
239
- /**
240
- * Record an agent dispatch for phase completion tracking.
241
- * Normalizes the agent name via stripKnownSwarmPrefix before adding to phaseAgentsDispatched.
242
- * @param sessionId - Session identifier
243
- * @param agentName - Agent name to record (will be normalized)
244
- */
245
- export declare function recordPhaseAgentDispatch(sessionId: string, agentName: string): void;
246
- /**
247
- * Advance a task's workflow state. Validates forward-only transitions.
248
- * Throws 'INVALID_TASK_STATE_TRANSITION: [taskId] [current] → [requested]' on illegal transition.
249
- * Safely returns without mutating state when taskId is null, undefined, empty, or whitespace-only.
250
- *
251
- * Valid forward order: idle → coder_delegated → pre_check_passed → reviewer_run → tests_run → complete
252
- *
253
- * @param session - The agent session state
254
- * @param taskId - The task identifier
255
- * @param newState - The requested new state
256
- */
257
- export declare function advanceTaskState(session: AgentSessionState, taskId: string, newState: TaskWorkflowState): void;
258
- /**
259
- * Get the current workflow state for a task.
260
- * Returns 'idle' if no entry exists.
261
- * Returns 'idle' for invalid taskId (null, undefined, empty, or whitespace-only).
262
- * If taskWorkflowStates is missing/invalid, initializes it as a new Map.
263
- *
264
- * @param session - The agent session state
265
- * @param taskId - The task identifier
266
- * @returns Current task workflow state
267
- */
268
- export declare function getTaskState(session: AgentSessionState, taskId: string): TaskWorkflowState;
269
- /**
270
- * Rehydrates session workflow state from durable swarm files.
271
- *
272
- * Reads `.swarm/plan.json` and `.swarm/evidence/*.json` from the provided
273
- * project directory, derives task workflow states from this data, and merges
274
- * them into the target AgentSessionState.
275
- *
276
- * Merge rules:
277
- * - Evidence-derived progression wins over plan-only state
278
- * - Existing in-memory workflow states for the same task IDs are NOT downgraded
279
- * - Missing/malformed `.swarm` data is non-fatal (silently skipped)
280
- *
281
- * This helper is useful for session restart scenarios where in-memory state
282
- * is lost but durable files persist.
283
- *
284
- * @param directory - Project root containing .swarm/ subdirectory
285
- * @param session - Target AgentSessionState to merge rehydrated state into
286
- */
287
- export declare function rehydrateSessionFromDisk(directory: string, session: AgentSessionState): Promise<void>;
288
- /**
289
- * Check if ANY active session has Turbo Mode enabled.
290
- * @returns true if any session has turboMode: true
291
- */
292
- export declare function hasActiveTurboMode(): boolean;
1
+ export * from '@opencode-swarm/core';
@@ -0,0 +1,15 @@
1
+ import { formatStatusMarkdown, type StatusData } from '@opencode-swarm/core';
2
+ import type { AgentDefinition as OpenCodeAgentDefinition } from '../agents';
3
+ /**
4
+ * Get status data - adapts local OpenCode agents to core type.
5
+ * The core service only uses Object.keys(agents).length for counting,
6
+ * so a safe cast is acceptable.
7
+ */
8
+ export declare function getStatusData(directory: string, agents: Record<string, OpenCodeAgentDefinition>): Promise<StatusData>;
9
+ /**
10
+ * Handle status command - adapts local OpenCode agents to core type.
11
+ * The core service only uses Object.keys(agents).length for counting,
12
+ * so a safe cast is acceptable.
13
+ */
14
+ export declare function handleStatusCommand(directory: string, agents: Record<string, OpenCodeAgentDefinition>): Promise<string>;
15
+ export { formatStatusMarkdown, type StatusData };