opencode-swarm 6.27.0 → 7.0.0-beta.1

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 +48739 -47886
  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
@@ -1,60 +0,0 @@
1
- /**
2
- * Typed Event Bus for Internal Automation Events
3
- *
4
- * Provides a type-safe event system for background automation.
5
- * Events flow through the system without external dependencies.
6
- */
7
- /** Automation event types */
8
- export type AutomationEventType = 'queue.item.enqueued' | 'queue.item.dequeued' | 'queue.item.completed' | 'queue.item.failed' | 'queue.item.retry scheduled' | 'worker.started' | 'worker.stopped' | 'worker.error' | 'circuit.breaker.opened' | 'circuit.breaker.half-open' | 'circuit.breaker.closed' | 'loop.protection.triggered' | 'automation.started' | 'automation.stopped' | 'preflight.requested' | 'preflight.triggered' | 'preflight.skipped' | 'preflight.completed' | 'phase.boundary.detected' | 'phase.status.checked' | 'task.completed' | 'evidence.summary.generated' | 'evidence.summary.error' | 'curator.init.completed' | 'curator.phase.completed' | 'curator.drift.completed' | 'curator.error';
9
- /** Base automation event */
10
- export interface AutomationEvent<T = unknown> {
11
- type: AutomationEventType;
12
- timestamp: number;
13
- payload: T;
14
- source?: string;
15
- }
16
- /** Event listener type */
17
- export type EventListener<T = unknown> = (event: AutomationEvent<T>) => void | Promise<void>;
18
- /**
19
- * Type-safe event bus for automation events
20
- */
21
- export declare class AutomationEventBus {
22
- private listeners;
23
- private eventHistory;
24
- private readonly maxHistorySize;
25
- constructor(options?: {
26
- maxHistorySize?: number;
27
- });
28
- /**
29
- * Subscribe to an event type
30
- */
31
- subscribe<T>(type: AutomationEventType, listener: EventListener<T>): () => void;
32
- /**
33
- * Publish an event to all subscribers
34
- */
35
- publish<T>(type: AutomationEventType, payload: T, source?: string): Promise<void>;
36
- /**
37
- * Get recent event history
38
- */
39
- getHistory(types?: AutomationEventType[]): AutomationEvent[];
40
- /**
41
- * Clear event history
42
- */
43
- clearHistory(): void;
44
- /**
45
- * Get listener count for an event type
46
- */
47
- getListenerCount(type: AutomationEventType): number;
48
- /**
49
- * Check if any listeners exist for a type
50
- */
51
- hasListeners(type: AutomationEventType): boolean;
52
- }
53
- /**
54
- * Get or create the global event bus instance
55
- */
56
- export declare function getGlobalEventBus(): AutomationEventBus;
57
- /**
58
- * Reset the global event bus (for testing)
59
- */
60
- export declare function resetGlobalEventBus(): void;
@@ -1,73 +0,0 @@
1
- /**
2
- * Evidence Summary Background Integration
3
- *
4
- * Wires the evidence summary service to background automation:
5
- * - Subscribes to preflight and phase boundary events
6
- * - Generates evidence summaries automatically
7
- * - Persists artifacts under .swarm/ for GUI consumption
8
- * - Respects feature flags (evidence_auto_summaries) with default-off safety
9
- */
10
- import type { AutomationConfig } from '../config/schema';
11
- import { type EvidenceSummaryArtifact } from '../services/evidence-summary-service';
12
- /** Evidence summary integration configuration */
13
- export interface EvidenceSummaryIntegrationConfig {
14
- /** Automation configuration for feature flag gating */
15
- automationConfig: AutomationConfig;
16
- /** Directory to run evidence analysis in */
17
- directory: string;
18
- /** Swarm directory for persisting summary artifacts */
19
- swarmDir: string;
20
- /** Filename for the summary artifact (default: evidence-summary.json) */
21
- summaryFilename?: string;
22
- }
23
- /** Event types that can trigger evidence summary generation */
24
- export type EvidenceSummaryTriggerEvent = 'preflight.completed' | 'phase.boundary.detected' | 'phase.status.checked' | 'task.completed';
25
- /** Payload for evidence summary trigger events */
26
- export interface EvidenceSummaryTriggerPayload {
27
- trigger: EvidenceSummaryTriggerEvent;
28
- phase: number;
29
- reason: string;
30
- metadata?: Record<string, unknown>;
31
- }
32
- /**
33
- * Evidence Summary Integration
34
- *
35
- * Automatically generates and persists evidence summaries on relevant events.
36
- */
37
- export declare class EvidenceSummaryIntegration {
38
- private readonly config;
39
- private readonly eventBus;
40
- private unsubscribes;
41
- constructor(config: EvidenceSummaryIntegrationConfig);
42
- /**
43
- * Check if auto-summaries are enabled
44
- */
45
- isEnabled(): boolean;
46
- /**
47
- * Initialize the integration by subscribing to trigger events
48
- * Only subscribes if enabled via feature flags
49
- */
50
- initialize(): void;
51
- /**
52
- * Subscribe to an event type
53
- */
54
- private subscribeToEvent;
55
- /**
56
- * Generate and persist evidence summary
57
- */
58
- generateSummary(phase: number, trigger: EvidenceSummaryTriggerEvent): Promise<EvidenceSummaryArtifact | null>;
59
- /**
60
- * Manually trigger summary generation (for CLI or testing)
61
- */
62
- triggerManual(phase?: number): Promise<EvidenceSummaryArtifact | null>;
63
- /**
64
- * Cleanup subscriptions
65
- */
66
- cleanup(): void;
67
- }
68
- /**
69
- * Create evidence summary integration
70
- *
71
- * Factory function that creates and optionally initializes the integration.
72
- */
73
- export declare function createEvidenceSummaryIntegration(config: EvidenceSummaryIntegrationConfig, autoInitialize?: boolean): EvidenceSummaryIntegration;
@@ -1,22 +0,0 @@
1
- /**
2
- * Background Automation Framework
3
- *
4
- * Provides infrastructure for v6.7 background-first automation:
5
- * - Typed event bus for internal automation events
6
- * - Lightweight in-process queue with priorities and retry metadata
7
- * - Worker lifecycle manager (start/stop/register handlers)
8
- * - Circuit breaker + loop protection primitives
9
- * - Phase-boundary trigger detection and preflight request plumbing
10
- * - Passive status artifact writer for GUI visibility
11
- *
12
- * Gated behind Task 5.2 automation feature flags and default-off behavior.
13
- */
14
- export { CircuitBreaker, type CircuitBreakerConfig, type CircuitBreakerState, LoopProtection, } from './circuit-breaker';
15
- export { type AutomationEvent, AutomationEventBus, type AutomationEventType, } from './event-bus';
16
- export { createEvidenceSummaryIntegration, type EvidenceSummaryIntegrationConfig, type EvidenceSummaryTriggerEvent, type EvidenceSummaryTriggerPayload, } from './evidence-summary-integration';
17
- export { type AutomationFrameworkConfig, BackgroundAutomationManager, createAutomationManager, } from './manager';
18
- export { PlanSyncWorker, type PlanSyncWorkerOptions, type PlanSyncWorkerStatus, } from './plan-sync-worker';
19
- export { AutomationQueue, type QueueItem, type QueuePriority, type RetryMetadata, } from './queue';
20
- export { AutomationStatusArtifact, type AutomationStatusSnapshot, } from './status-artifact';
21
- export { type PhaseBoundaryResult, PhaseBoundaryTrigger, type PreflightHandler, type PreflightRequest, type PreflightRequestPayload, type PreflightTriggerConfig, type PreflightTriggerEventType, PreflightTriggerManager, } from './trigger';
22
- export { type WorkerHandler, WorkerManager, type WorkerRegistration, } from './worker';
@@ -1,122 +0,0 @@
1
- /**
2
- * Background Automation Manager
3
- *
4
- * Main entry point for the background automation framework.
5
- * Handles feature flag gating and orchestrates all components.
6
- */
7
- import type { AutomationConfig } from '../config/schema';
8
- import { CircuitBreaker, type CircuitBreakerConfig, LoopProtection, type LoopProtectionConfig } from './circuit-breaker';
9
- import { type AutomationEvent, type AutomationEventType } from './event-bus';
10
- import { AutomationQueue } from './queue';
11
- import { WorkerManager, type WorkerRegistration } from './worker';
12
- /** Framework configuration */
13
- export interface AutomationFrameworkConfig {
14
- /** Enable/disable the entire framework */
15
- enabled: boolean;
16
- /** Max queue size */
17
- maxQueueSize?: number;
18
- /** Max retries for failed items */
19
- maxRetries?: number;
20
- /** Circuit breaker config */
21
- circuitBreaker?: Partial<CircuitBreakerConfig>;
22
- /** Loop protection config */
23
- loopProtection?: Partial<LoopProtectionConfig>;
24
- }
25
- /**
26
- * Background Automation Manager
27
- *
28
- * Provides a unified interface for background automation with feature flag gating.
29
- * All components are optional and only activated when enabled.
30
- */
31
- export declare class BackgroundAutomationManager {
32
- private readonly config;
33
- private readonly eventBus;
34
- private readonly workerManager;
35
- private readonly queues;
36
- private readonly circuitBreakers;
37
- private readonly loopProtections;
38
- private isInitialized;
39
- private isRunning;
40
- constructor(config: AutomationFrameworkConfig);
41
- /**
42
- * Initialize the automation framework
43
- * Only performs work if enabled
44
- */
45
- initialize(): void;
46
- /**
47
- * Start the automation framework
48
- */
49
- start(): void;
50
- /**
51
- * Stop the automation framework
52
- */
53
- stop(): void;
54
- /**
55
- * Check if framework is enabled
56
- */
57
- isEnabled(): boolean;
58
- /**
59
- * Check if framework is running
60
- */
61
- isActive(): boolean;
62
- /**
63
- * Create or get a named queue
64
- */
65
- getOrCreateQueue<T>(name: string): AutomationQueue<T>;
66
- /**
67
- * Register a worker with the framework
68
- */
69
- registerWorker(registration: WorkerRegistration): void;
70
- /**
71
- * Start a specific worker
72
- */
73
- startWorker(name: string): boolean;
74
- /**
75
- * Stop a specific worker
76
- */
77
- stopWorker(name: string): boolean;
78
- /**
79
- * Get or create a circuit breaker
80
- */
81
- getOrCreateCircuitBreaker(name: string): CircuitBreaker;
82
- /**
83
- * Get or create loop protection
84
- */
85
- getOrCreateLoopProtection(operationKey: string): LoopProtection;
86
- /**
87
- * Subscribe to automation events
88
- */
89
- subscribe<T>(type: AutomationEventType, listener: (event: AutomationEvent<T>) => void | Promise<void>): () => void;
90
- /**
91
- * Publish an event to the automation event bus
92
- */
93
- publish<T>(type: AutomationEventType, payload: T, source?: string): Promise<void>;
94
- /**
95
- * Get framework statistics
96
- */
97
- getStats(): {
98
- enabled: boolean;
99
- initialized: boolean;
100
- running: boolean;
101
- queues: Record<string, ReturnType<AutomationQueue['getStats']>>;
102
- workers: Record<string, ReturnType<WorkerManager['getStats']>>;
103
- circuitBreakers: Record<string, ReturnType<CircuitBreaker['getStats']>>;
104
- loopProtections: string[];
105
- };
106
- /**
107
- * Reset the framework (for testing)
108
- */
109
- reset(): void;
110
- }
111
- /**
112
- * Get or create the global automation manager
113
- */
114
- export declare function getAutomationManager(config?: AutomationFrameworkConfig): BackgroundAutomationManager;
115
- /**
116
- * Initialize automation manager from plugin config
117
- */
118
- export declare function createAutomationManager(automationConfig: AutomationConfig | undefined): BackgroundAutomationManager;
119
- /**
120
- * Reset the global manager (for testing)
121
- */
122
- export declare function resetAutomationManager(): void;
@@ -1,122 +0,0 @@
1
- /**
2
- * Plan Sync Worker
3
- *
4
- * Watches .swarm/plan.json for changes and syncs plan.md accordingly.
5
- * Uses fs.watch with polling fallback for cross-platform reliability.
6
- */
7
- /** Configuration options for PlanSyncWorker */
8
- export interface PlanSyncWorkerOptions {
9
- /** Directory containing .swarm folder (defaults to cwd) */
10
- directory?: string;
11
- /** Debounce delay in ms (default: 300ms) */
12
- debounceMs?: number;
13
- /** Polling interval in ms when fs.watch fails (default: 2000ms) */
14
- pollIntervalMs?: number;
15
- /** Sync operation timeout in ms (default: 30000ms) - prevents runaway hangs */
16
- syncTimeoutMs?: number;
17
- /** Called on sync completion (success or failure) */
18
- onSyncComplete?: (success: boolean, error?: Error) => void;
19
- }
20
- /** Worker status */
21
- export type PlanSyncWorkerStatus = 'stopped' | 'starting' | 'running' | 'stopping';
22
- /**
23
- * Plan Sync Worker
24
- *
25
- * Standalone class that watches plan.json and triggers plan.md regeneration.
26
- * Handles cross-platform fs.watch reliability issues with polling fallback.
27
- */
28
- export declare class PlanSyncWorker {
29
- private readonly directory;
30
- private readonly debounceMs;
31
- private readonly pollIntervalMs;
32
- private readonly syncTimeoutMs;
33
- private readonly onSyncComplete?;
34
- private status;
35
- private watcher;
36
- private pollTimer;
37
- private debounceTimer;
38
- /** In-flight sync lock */
39
- private syncing;
40
- /** Pending sync requested while in-flight */
41
- private pendingSync;
42
- /** Last known plan.json stat to detect changes */
43
- private lastStat;
44
- /** Track if we've been disposed */
45
- private disposed;
46
- constructor(options?: PlanSyncWorkerOptions);
47
- /**
48
- * Get the swarm directory path
49
- */
50
- private getSwarmDir;
51
- /**
52
- * Get the plan.json file path
53
- */
54
- private getPlanJsonPath;
55
- /**
56
- * Start watching for plan.json changes
57
- */
58
- start(): void;
59
- /**
60
- * Stop watching and clean up resources
61
- */
62
- stop(): void;
63
- /**
64
- * Dispose of the worker - stop and prevent further use
65
- */
66
- dispose(): void;
67
- /**
68
- * Get current status
69
- */
70
- getStatus(): PlanSyncWorkerStatus;
71
- /**
72
- * Check if worker is running
73
- */
74
- isRunning(): boolean;
75
- /**
76
- * Initialize the stat tracking for change detection
77
- */
78
- private initializeStat;
79
- /**
80
- * Set up native fs.watch on the swarm directory
81
- * Returns true if successful, false if unavailable
82
- */
83
- private setupNativeWatcher;
84
- /**
85
- * Set up polling fallback
86
- */
87
- private setupPolling;
88
- /**
89
- * Check for changes via polling
90
- */
91
- private pollCheck;
92
- /**
93
- * Debounced sync - prevents rapid successive syncs
94
- */
95
- private debouncedSync;
96
- /**
97
- * Clear debounce timer
98
- */
99
- private clearDebounce;
100
- /**
101
- * Trigger a sync operation with overlap protection
102
- */
103
- private triggerSync;
104
- /**
105
- * Execute the sync operation with timeout protection
106
- */
107
- private executeSync;
108
- /**
109
- * Safely invoke onSyncComplete callback, catching any exceptions
110
- * to prevent callback errors from affecting worker stability
111
- */
112
- private safeCallback;
113
- /**
114
- * Advisory: check for unauthorized writes to plan.json outside of save_plan/savePlan
115
- * Logs a warning if plan.json appears to have been modified after the write marker
116
- */
117
- private checkForUnauthorizedWrite;
118
- /**
119
- * Wrap a promise with a timeout
120
- */
121
- private withTimeout;
122
- }
@@ -1,117 +0,0 @@
1
- /**
2
- * Lightweight In-Process Queue with Priorities and Retry Metadata
3
- *
4
- * Provides a simple but powerful queue abstraction for background automation.
5
- * Supports priorities, retry logic, and in-memory persistence only.
6
- * NOTE: This queue does NOT persist across restarts — all items are lost when the process exits.
7
- */
8
- /** Queue priority levels */
9
- export type QueuePriority = 'critical' | 'high' | 'normal' | 'low';
10
- /** Retry metadata for failed items */
11
- export interface RetryMetadata {
12
- attempts: number;
13
- maxAttempts: number;
14
- lastAttempt?: number;
15
- nextAttemptAt?: number;
16
- backoffMs: number;
17
- maxBackoffMs: number;
18
- }
19
- /** Queue item structure */
20
- export interface QueueItem<T = unknown> {
21
- id: string;
22
- priority: QueuePriority;
23
- payload: T;
24
- createdAt: number;
25
- metadata?: Record<string, unknown>;
26
- retry?: RetryMetadata;
27
- }
28
- /** Queue configuration */
29
- export interface QueueConfig {
30
- priorityLevels?: QueuePriority[];
31
- maxSize?: number;
32
- defaultMaxRetries?: number;
33
- defaultBackoffMs?: number;
34
- maxBackoffMs?: number;
35
- }
36
- /**
37
- * In-process queue with priority support and retry metadata
38
- */
39
- export declare class AutomationQueue<T = unknown> {
40
- private items;
41
- private readonly maxSize;
42
- private readonly defaultMaxRetries;
43
- private readonly defaultBackoffMs;
44
- private readonly maxBackoffMs;
45
- private readonly eventBus;
46
- private itemCounter;
47
- constructor(config?: QueueConfig);
48
- /**
49
- * Generate unique item ID
50
- */
51
- private generateId;
52
- /**
53
- * Enqueue an item with priority
54
- */
55
- enqueue(payload: T, priority?: QueuePriority, metadata?: Record<string, unknown>): string;
56
- /**
57
- * Dequeue the highest priority item
58
- */
59
- dequeue(): QueueItem<T> | undefined;
60
- /**
61
- * Peek at the highest priority item without removing
62
- */
63
- peek(): QueueItem<T> | undefined;
64
- /**
65
- * Get item by ID
66
- */
67
- get(id: string): QueueItem<T> | undefined;
68
- /**
69
- * Remove specific item by ID
70
- */
71
- remove(id: string): boolean;
72
- /**
73
- * Mark item as completed and remove from queue
74
- */
75
- complete(id: string): boolean;
76
- /**
77
- * Mark item as failed and schedule retry if possible
78
- */
79
- retry(id: string, _error?: unknown): boolean;
80
- /**
81
- * Get items due for retry
82
- */
83
- getRetryableItems(): QueueItem<T>[];
84
- /**
85
- * Get current queue size
86
- */
87
- size(): number;
88
- /**
89
- * Check if queue is empty
90
- */
91
- isEmpty(): boolean;
92
- /**
93
- * Check if queue is full
94
- */
95
- isFull(): boolean;
96
- /**
97
- * Clear all items from queue
98
- */
99
- clear(): void;
100
- /**
101
- * Get all items (for debugging/inspection)
102
- */
103
- getAll(): QueueItem<T>[];
104
- /**
105
- * Get items by priority
106
- */
107
- getByPriority(priority: QueuePriority): QueueItem<T>[];
108
- /**
109
- * Get queue statistics
110
- */
111
- getStats(): {
112
- size: number;
113
- maxSize: number;
114
- byPriority: Record<QueuePriority, number>;
115
- retryable: number;
116
- };
117
- }
@@ -1,115 +0,0 @@
1
- /**
2
- * Passive Status Artifact Writer
3
- *
4
- * Writes automation status snapshots to .swarm/ for GUI visibility.
5
- * Provides passive, read-only status information without affecting workflow.
6
- */
7
- /** Automation status snapshot structure */
8
- export interface AutomationStatusSnapshot {
9
- /** When this snapshot was generated */
10
- timestamp: number;
11
- /** Current automation mode */
12
- mode: 'manual' | 'hybrid' | 'auto';
13
- /** Whether automation is enabled */
14
- enabled: boolean;
15
- /** Current phase */
16
- currentPhase: number;
17
- /** Last trigger information */
18
- lastTrigger: {
19
- triggeredAt: number | null;
20
- triggeredPhase: number | null;
21
- source: string | null;
22
- reason: string | null;
23
- } | null;
24
- /** Pending actions count */
25
- pendingActions: number;
26
- /** Last outcome state */
27
- lastOutcome: {
28
- state: 'success' | 'failure' | 'skipped' | 'none';
29
- phase: number | null;
30
- outcomeAt: number | null;
31
- message: string | null;
32
- } | null;
33
- /** Feature flags status */
34
- capabilities: {
35
- plan_sync: boolean;
36
- phase_preflight: boolean;
37
- config_doctor_on_startup: boolean;
38
- config_doctor_autofix: boolean;
39
- evidence_auto_summaries: boolean;
40
- decision_drift_detection: boolean;
41
- };
42
- }
43
- /**
44
- * Automation Status Artifact Manager
45
- *
46
- * Writes passive status snapshots to .swarm/automation-status.json
47
- */
48
- export declare class AutomationStatusArtifact {
49
- private readonly swarmDir;
50
- private readonly filename;
51
- private currentSnapshot;
52
- constructor(swarmDir: string, filename?: string);
53
- /**
54
- * Get the full path to the status file
55
- */
56
- private getFilePath;
57
- /**
58
- * Load existing snapshot from disk
59
- */
60
- load(): AutomationStatusSnapshot | null;
61
- /**
62
- * Write snapshot to disk
63
- */
64
- private write;
65
- /**
66
- * Get current snapshot (in-memory)
67
- */
68
- getSnapshot(): AutomationStatusSnapshot;
69
- /**
70
- * Read snapshot from disk (forces reload)
71
- */
72
- read(): AutomationStatusSnapshot;
73
- /**
74
- * Update mode and capabilities
75
- */
76
- updateConfig(mode: 'manual' | 'hybrid' | 'auto', capabilities: AutomationStatusSnapshot['capabilities']): void;
77
- /**
78
- * Update current phase
79
- */
80
- updatePhase(phase: number): void;
81
- /**
82
- * Record a trigger event
83
- */
84
- recordTrigger(triggeredAt: number, triggeredPhase: number, source: string, reason: string): void;
85
- /**
86
- * Update pending actions count
87
- */
88
- updatePendingActions(count: number): void;
89
- /**
90
- * Record an outcome
91
- */
92
- recordOutcome(state: 'success' | 'failure' | 'skipped', phase: number, message?: string): void;
93
- /**
94
- * Clear the last outcome (reset to none)
95
- */
96
- clearOutcome(): void;
97
- /**
98
- * Check if automation is enabled (mode != manual)
99
- */
100
- isEnabled(): boolean;
101
- /**
102
- * Check if a specific capability is enabled
103
- */
104
- hasCapability(capability: keyof AutomationStatusSnapshot['capabilities']): boolean;
105
- /**
106
- * Get summary for GUI display
107
- */
108
- getGuiSummary(): {
109
- status: string;
110
- phase: number;
111
- lastTrigger: string | null;
112
- pending: number;
113
- outcome: string | null;
114
- };
115
- }