@su-record/vibe 3.0.0 → 3.1.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 (341) hide show
  1. package/hooks/scripts/__tests__/.vibe/command-log.txt +3 -78
  2. package/hooks/scripts/__tests__/.vibe/memories/memories.db +0 -0
  3. package/hooks/scripts/__tests__/.vibe/memories/memories.db-shm +0 -0
  4. package/hooks/scripts/__tests__/.vibe/memories/memories.db-wal +0 -0
  5. package/hooks/scripts/__tests__/clone-behaviors.test.js +64 -0
  6. package/hooks/scripts/__tests__/clone-merge-responsive.test.js +106 -0
  7. package/hooks/scripts/clone-extract.js +242 -28
  8. package/hooks/scripts/clone-merge-responsive.js +184 -0
  9. package/hooks/scripts/clone-spec.js +33 -8
  10. package/hooks/scripts/clone-validate.js +15 -9
  11. package/package.json +5 -2
  12. package/skills/clone/SKILL.md +132 -55
  13. package/skills/vibe.clone/SKILL.md +39 -19
  14. package/dist/cli/llm/gemini-commands.d.ts +0 -25
  15. package/dist/cli/llm/gemini-commands.d.ts.map +0 -1
  16. package/dist/cli/llm/gemini-commands.js +0 -143
  17. package/dist/cli/llm/gemini-commands.js.map +0 -1
  18. package/dist/cli/postinstall/codex-agents.d.ts +0 -24
  19. package/dist/cli/postinstall/codex-agents.d.ts.map +0 -1
  20. package/dist/cli/postinstall/codex-agents.js +0 -114
  21. package/dist/cli/postinstall/codex-agents.js.map +0 -1
  22. package/dist/cli/postinstall/codex-instruction.d.ts +0 -10
  23. package/dist/cli/postinstall/codex-instruction.d.ts.map +0 -1
  24. package/dist/cli/postinstall/codex-instruction.js +0 -56
  25. package/dist/cli/postinstall/codex-instruction.js.map +0 -1
  26. package/dist/cli/postinstall/gemini-agents.d.ts +0 -12
  27. package/dist/cli/postinstall/gemini-agents.d.ts.map +0 -1
  28. package/dist/cli/postinstall/gemini-agents.js +0 -80
  29. package/dist/cli/postinstall/gemini-agents.js.map +0 -1
  30. package/dist/cli/postinstall/gemini-instruction.d.ts +0 -10
  31. package/dist/cli/postinstall/gemini-instruction.d.ts.map +0 -1
  32. package/dist/cli/postinstall/gemini-instruction.js +0 -59
  33. package/dist/cli/postinstall/gemini-instruction.js.map +0 -1
  34. package/dist/infra/lib/ContextCompressor.d.ts +0 -104
  35. package/dist/infra/lib/ContextCompressor.d.ts.map +0 -1
  36. package/dist/infra/lib/ContextCompressor.js +0 -297
  37. package/dist/infra/lib/ContextCompressor.js.map +0 -1
  38. package/dist/infra/lib/ContextCompressor.test.d.ts +0 -2
  39. package/dist/infra/lib/ContextCompressor.test.d.ts.map +0 -1
  40. package/dist/infra/lib/ContextCompressor.test.js +0 -25
  41. package/dist/infra/lib/ContextCompressor.test.js.map +0 -1
  42. package/dist/infra/lib/ProgressTracker.d.ts +0 -73
  43. package/dist/infra/lib/ProgressTracker.d.ts.map +0 -1
  44. package/dist/infra/lib/ProgressTracker.js +0 -267
  45. package/dist/infra/lib/ProgressTracker.js.map +0 -1
  46. package/dist/infra/lib/TokenBudgetTracker.d.ts +0 -68
  47. package/dist/infra/lib/TokenBudgetTracker.d.ts.map +0 -1
  48. package/dist/infra/lib/TokenBudgetTracker.js +0 -191
  49. package/dist/infra/lib/TokenBudgetTracker.js.map +0 -1
  50. package/dist/infra/lib/autonomy/AuditStore.d.ts +0 -63
  51. package/dist/infra/lib/autonomy/AuditStore.d.ts.map +0 -1
  52. package/dist/infra/lib/autonomy/AuditStore.js +0 -185
  53. package/dist/infra/lib/autonomy/AuditStore.js.map +0 -1
  54. package/dist/infra/lib/autonomy/AutonomyConfig.d.ts +0 -84
  55. package/dist/infra/lib/autonomy/AutonomyConfig.d.ts.map +0 -1
  56. package/dist/infra/lib/autonomy/AutonomyConfig.js +0 -49
  57. package/dist/infra/lib/autonomy/AutonomyConfig.js.map +0 -1
  58. package/dist/infra/lib/autonomy/AutonomyOrchestrator.d.ts +0 -78
  59. package/dist/infra/lib/autonomy/AutonomyOrchestrator.d.ts.map +0 -1
  60. package/dist/infra/lib/autonomy/AutonomyOrchestrator.js +0 -246
  61. package/dist/infra/lib/autonomy/AutonomyOrchestrator.js.map +0 -1
  62. package/dist/infra/lib/autonomy/BackgroundMonitor.d.ts +0 -36
  63. package/dist/infra/lib/autonomy/BackgroundMonitor.d.ts.map +0 -1
  64. package/dist/infra/lib/autonomy/BackgroundMonitor.js +0 -138
  65. package/dist/infra/lib/autonomy/BackgroundMonitor.js.map +0 -1
  66. package/dist/infra/lib/autonomy/CollaborationProtocol.d.ts +0 -56
  67. package/dist/infra/lib/autonomy/CollaborationProtocol.d.ts.map +0 -1
  68. package/dist/infra/lib/autonomy/CollaborationProtocol.js +0 -122
  69. package/dist/infra/lib/autonomy/CollaborationProtocol.js.map +0 -1
  70. package/dist/infra/lib/autonomy/ConfirmationManager.d.ts +0 -42
  71. package/dist/infra/lib/autonomy/ConfirmationManager.d.ts.map +0 -1
  72. package/dist/infra/lib/autonomy/ConfirmationManager.js +0 -200
  73. package/dist/infra/lib/autonomy/ConfirmationManager.js.map +0 -1
  74. package/dist/infra/lib/autonomy/ConfirmationStore.d.ts +0 -55
  75. package/dist/infra/lib/autonomy/ConfirmationStore.d.ts.map +0 -1
  76. package/dist/infra/lib/autonomy/ConfirmationStore.js +0 -130
  77. package/dist/infra/lib/autonomy/ConfirmationStore.js.map +0 -1
  78. package/dist/infra/lib/autonomy/EventBus.d.ts +0 -20
  79. package/dist/infra/lib/autonomy/EventBus.d.ts.map +0 -1
  80. package/dist/infra/lib/autonomy/EventBus.js +0 -119
  81. package/dist/infra/lib/autonomy/EventBus.js.map +0 -1
  82. package/dist/infra/lib/autonomy/EventOutbox.d.ts +0 -32
  83. package/dist/infra/lib/autonomy/EventOutbox.d.ts.map +0 -1
  84. package/dist/infra/lib/autonomy/EventOutbox.js +0 -152
  85. package/dist/infra/lib/autonomy/EventOutbox.js.map +0 -1
  86. package/dist/infra/lib/autonomy/NotificationDispatcher.d.ts +0 -24
  87. package/dist/infra/lib/autonomy/NotificationDispatcher.d.ts.map +0 -1
  88. package/dist/infra/lib/autonomy/NotificationDispatcher.js +0 -112
  89. package/dist/infra/lib/autonomy/NotificationDispatcher.js.map +0 -1
  90. package/dist/infra/lib/autonomy/PolicyEngine.d.ts +0 -76
  91. package/dist/infra/lib/autonomy/PolicyEngine.d.ts.map +0 -1
  92. package/dist/infra/lib/autonomy/PolicyEngine.js +0 -208
  93. package/dist/infra/lib/autonomy/PolicyEngine.js.map +0 -1
  94. package/dist/infra/lib/autonomy/ProactiveAnalyzer.d.ts +0 -61
  95. package/dist/infra/lib/autonomy/ProactiveAnalyzer.d.ts.map +0 -1
  96. package/dist/infra/lib/autonomy/ProactiveAnalyzer.js +0 -236
  97. package/dist/infra/lib/autonomy/ProactiveAnalyzer.js.map +0 -1
  98. package/dist/infra/lib/autonomy/RiskClassifier.d.ts +0 -35
  99. package/dist/infra/lib/autonomy/RiskClassifier.d.ts.map +0 -1
  100. package/dist/infra/lib/autonomy/RiskClassifier.js +0 -147
  101. package/dist/infra/lib/autonomy/RiskClassifier.js.map +0 -1
  102. package/dist/infra/lib/autonomy/SecuritySentinel.d.ts +0 -51
  103. package/dist/infra/lib/autonomy/SecuritySentinel.d.ts.map +0 -1
  104. package/dist/infra/lib/autonomy/SecuritySentinel.js +0 -162
  105. package/dist/infra/lib/autonomy/SecuritySentinel.js.map +0 -1
  106. package/dist/infra/lib/autonomy/SuggestionStore.d.ts +0 -54
  107. package/dist/infra/lib/autonomy/SuggestionStore.d.ts.map +0 -1
  108. package/dist/infra/lib/autonomy/SuggestionStore.js +0 -144
  109. package/dist/infra/lib/autonomy/SuggestionStore.js.map +0 -1
  110. package/dist/infra/lib/autonomy/TaskDecomposer.d.ts +0 -38
  111. package/dist/infra/lib/autonomy/TaskDecomposer.d.ts.map +0 -1
  112. package/dist/infra/lib/autonomy/TaskDecomposer.js +0 -175
  113. package/dist/infra/lib/autonomy/TaskDecomposer.js.map +0 -1
  114. package/dist/infra/lib/autonomy/__tests__/audit-store.test.d.ts +0 -2
  115. package/dist/infra/lib/autonomy/__tests__/audit-store.test.d.ts.map +0 -1
  116. package/dist/infra/lib/autonomy/__tests__/audit-store.test.js +0 -198
  117. package/dist/infra/lib/autonomy/__tests__/audit-store.test.js.map +0 -1
  118. package/dist/infra/lib/autonomy/__tests__/event-bus.test.d.ts +0 -2
  119. package/dist/infra/lib/autonomy/__tests__/event-bus.test.d.ts.map +0 -1
  120. package/dist/infra/lib/autonomy/__tests__/event-bus.test.js +0 -225
  121. package/dist/infra/lib/autonomy/__tests__/event-bus.test.js.map +0 -1
  122. package/dist/infra/lib/autonomy/__tests__/event-core.test.d.ts +0 -2
  123. package/dist/infra/lib/autonomy/__tests__/event-core.test.d.ts.map +0 -1
  124. package/dist/infra/lib/autonomy/__tests__/event-core.test.js +0 -194
  125. package/dist/infra/lib/autonomy/__tests__/event-core.test.js.map +0 -1
  126. package/dist/infra/lib/autonomy/__tests__/governance.test.d.ts +0 -2
  127. package/dist/infra/lib/autonomy/__tests__/governance.test.d.ts.map +0 -1
  128. package/dist/infra/lib/autonomy/__tests__/governance.test.js +0 -540
  129. package/dist/infra/lib/autonomy/__tests__/governance.test.js.map +0 -1
  130. package/dist/infra/lib/autonomy/__tests__/integration.test.d.ts +0 -2
  131. package/dist/infra/lib/autonomy/__tests__/integration.test.d.ts.map +0 -1
  132. package/dist/infra/lib/autonomy/__tests__/integration.test.js +0 -480
  133. package/dist/infra/lib/autonomy/__tests__/integration.test.js.map +0 -1
  134. package/dist/infra/lib/autonomy/__tests__/proactive.test.d.ts +0 -2
  135. package/dist/infra/lib/autonomy/__tests__/proactive.test.d.ts.map +0 -1
  136. package/dist/infra/lib/autonomy/__tests__/proactive.test.js +0 -410
  137. package/dist/infra/lib/autonomy/__tests__/proactive.test.js.map +0 -1
  138. package/dist/infra/lib/autonomy/__tests__/sentinel.test.d.ts +0 -2
  139. package/dist/infra/lib/autonomy/__tests__/sentinel.test.d.ts.map +0 -1
  140. package/dist/infra/lib/autonomy/__tests__/sentinel.test.js +0 -486
  141. package/dist/infra/lib/autonomy/__tests__/sentinel.test.js.map +0 -1
  142. package/dist/infra/lib/autonomy/index.d.ts +0 -18
  143. package/dist/infra/lib/autonomy/index.d.ts.map +0 -1
  144. package/dist/infra/lib/autonomy/index.js +0 -22
  145. package/dist/infra/lib/autonomy/index.js.map +0 -1
  146. package/dist/infra/lib/autonomy/schemas.d.ts +0 -317
  147. package/dist/infra/lib/autonomy/schemas.d.ts.map +0 -1
  148. package/dist/infra/lib/autonomy/schemas.js +0 -90
  149. package/dist/infra/lib/autonomy/schemas.js.map +0 -1
  150. package/dist/infra/lib/claude/index.d.ts +0 -5
  151. package/dist/infra/lib/claude/index.d.ts.map +0 -1
  152. package/dist/infra/lib/claude/index.js +0 -5
  153. package/dist/infra/lib/claude/index.js.map +0 -1
  154. package/dist/infra/lib/claude/storage.d.ts +0 -12
  155. package/dist/infra/lib/claude/storage.d.ts.map +0 -1
  156. package/dist/infra/lib/claude/storage.js +0 -54
  157. package/dist/infra/lib/claude/storage.js.map +0 -1
  158. package/dist/infra/lib/gemini/auth.d.ts +0 -18
  159. package/dist/infra/lib/gemini/auth.d.ts.map +0 -1
  160. package/dist/infra/lib/gemini/auth.js +0 -32
  161. package/dist/infra/lib/gemini/auth.js.map +0 -1
  162. package/dist/infra/lib/gemini/capabilities.d.ts +0 -28
  163. package/dist/infra/lib/gemini/capabilities.d.ts.map +0 -1
  164. package/dist/infra/lib/gemini/capabilities.js +0 -178
  165. package/dist/infra/lib/gemini/capabilities.js.map +0 -1
  166. package/dist/infra/lib/gemini/chat.d.ts +0 -35
  167. package/dist/infra/lib/gemini/chat.d.ts.map +0 -1
  168. package/dist/infra/lib/gemini/chat.js +0 -161
  169. package/dist/infra/lib/gemini/chat.js.map +0 -1
  170. package/dist/infra/lib/gemini/completion.d.ts +0 -12
  171. package/dist/infra/lib/gemini/completion.d.ts.map +0 -1
  172. package/dist/infra/lib/gemini/completion.js +0 -13
  173. package/dist/infra/lib/gemini/completion.js.map +0 -1
  174. package/dist/infra/lib/gemini/constants.d.ts +0 -8
  175. package/dist/infra/lib/gemini/constants.d.ts.map +0 -1
  176. package/dist/infra/lib/gemini/constants.js +0 -11
  177. package/dist/infra/lib/gemini/constants.js.map +0 -1
  178. package/dist/infra/lib/gemini/index.d.ts +0 -13
  179. package/dist/infra/lib/gemini/index.d.ts.map +0 -1
  180. package/dist/infra/lib/gemini/index.js +0 -12
  181. package/dist/infra/lib/gemini/index.js.map +0 -1
  182. package/dist/infra/lib/gemini/models.d.ts +0 -11
  183. package/dist/infra/lib/gemini/models.d.ts.map +0 -1
  184. package/dist/infra/lib/gemini/models.js +0 -38
  185. package/dist/infra/lib/gemini/models.js.map +0 -1
  186. package/dist/infra/lib/gemini/orchestration.d.ts +0 -33
  187. package/dist/infra/lib/gemini/orchestration.d.ts.map +0 -1
  188. package/dist/infra/lib/gemini/orchestration.js +0 -62
  189. package/dist/infra/lib/gemini/orchestration.js.map +0 -1
  190. package/dist/infra/lib/gemini/types.d.ts +0 -115
  191. package/dist/infra/lib/gemini/types.d.ts.map +0 -1
  192. package/dist/infra/lib/gemini/types.js +0 -5
  193. package/dist/infra/lib/gemini/types.js.map +0 -1
  194. package/dist/infra/orchestrator/AgentAnnouncer.d.ts +0 -64
  195. package/dist/infra/orchestrator/AgentAnnouncer.d.ts.map +0 -1
  196. package/dist/infra/orchestrator/AgentAnnouncer.js +0 -127
  197. package/dist/infra/orchestrator/AgentAnnouncer.js.map +0 -1
  198. package/dist/infra/orchestrator/AgentAnnouncer.test.d.ts +0 -5
  199. package/dist/infra/orchestrator/AgentAnnouncer.test.d.ts.map +0 -1
  200. package/dist/infra/orchestrator/AgentAnnouncer.test.js +0 -119
  201. package/dist/infra/orchestrator/AgentAnnouncer.test.js.map +0 -1
  202. package/dist/infra/orchestrator/AgentExecutor.d.ts +0 -22
  203. package/dist/infra/orchestrator/AgentExecutor.d.ts.map +0 -1
  204. package/dist/infra/orchestrator/AgentExecutor.js +0 -272
  205. package/dist/infra/orchestrator/AgentExecutor.js.map +0 -1
  206. package/dist/infra/orchestrator/AgentManager.d.ts +0 -72
  207. package/dist/infra/orchestrator/AgentManager.d.ts.map +0 -1
  208. package/dist/infra/orchestrator/AgentManager.js +0 -183
  209. package/dist/infra/orchestrator/AgentManager.js.map +0 -1
  210. package/dist/infra/orchestrator/AgentManifestCache.d.ts +0 -54
  211. package/dist/infra/orchestrator/AgentManifestCache.d.ts.map +0 -1
  212. package/dist/infra/orchestrator/AgentManifestCache.js +0 -191
  213. package/dist/infra/orchestrator/AgentManifestCache.js.map +0 -1
  214. package/dist/infra/orchestrator/AgentRegistry.d.ts +0 -76
  215. package/dist/infra/orchestrator/AgentRegistry.d.ts.map +0 -1
  216. package/dist/infra/orchestrator/AgentRegistry.js +0 -217
  217. package/dist/infra/orchestrator/AgentRegistry.js.map +0 -1
  218. package/dist/infra/orchestrator/AgentRegistry.test.d.ts +0 -5
  219. package/dist/infra/orchestrator/AgentRegistry.test.d.ts.map +0 -1
  220. package/dist/infra/orchestrator/AgentRegistry.test.js +0 -122
  221. package/dist/infra/orchestrator/AgentRegistry.test.js.map +0 -1
  222. package/dist/infra/orchestrator/BackgroundManager.d.ts +0 -128
  223. package/dist/infra/orchestrator/BackgroundManager.d.ts.map +0 -1
  224. package/dist/infra/orchestrator/BackgroundManager.js +0 -620
  225. package/dist/infra/orchestrator/BackgroundManager.js.map +0 -1
  226. package/dist/infra/orchestrator/BackgroundManager.test.d.ts +0 -6
  227. package/dist/infra/orchestrator/BackgroundManager.test.d.ts.map +0 -1
  228. package/dist/infra/orchestrator/BackgroundManager.test.js +0 -162
  229. package/dist/infra/orchestrator/BackgroundManager.test.js.map +0 -1
  230. package/dist/infra/orchestrator/CheckpointManager.d.ts +0 -54
  231. package/dist/infra/orchestrator/CheckpointManager.d.ts.map +0 -1
  232. package/dist/infra/orchestrator/CheckpointManager.js +0 -121
  233. package/dist/infra/orchestrator/CheckpointManager.js.map +0 -1
  234. package/dist/infra/orchestrator/CodexAgentRuntime.d.ts +0 -12
  235. package/dist/infra/orchestrator/CodexAgentRuntime.d.ts.map +0 -1
  236. package/dist/infra/orchestrator/CodexAgentRuntime.js +0 -94
  237. package/dist/infra/orchestrator/CodexAgentRuntime.js.map +0 -1
  238. package/dist/infra/orchestrator/CodexAgentRuntime.test.d.ts +0 -2
  239. package/dist/infra/orchestrator/CodexAgentRuntime.test.d.ts.map +0 -1
  240. package/dist/infra/orchestrator/CodexAgentRuntime.test.js +0 -37
  241. package/dist/infra/orchestrator/CodexAgentRuntime.test.js.map +0 -1
  242. package/dist/infra/orchestrator/LLMCluster.d.ts +0 -82
  243. package/dist/infra/orchestrator/LLMCluster.d.ts.map +0 -1
  244. package/dist/infra/orchestrator/LLMCluster.js +0 -146
  245. package/dist/infra/orchestrator/LLMCluster.js.map +0 -1
  246. package/dist/infra/orchestrator/MultiLlmResearch.d.ts +0 -31
  247. package/dist/infra/orchestrator/MultiLlmResearch.d.ts.map +0 -1
  248. package/dist/infra/orchestrator/MultiLlmResearch.js +0 -160
  249. package/dist/infra/orchestrator/MultiLlmResearch.js.map +0 -1
  250. package/dist/infra/orchestrator/PhasePipeline.d.ts +0 -122
  251. package/dist/infra/orchestrator/PhasePipeline.d.ts.map +0 -1
  252. package/dist/infra/orchestrator/PhasePipeline.js +0 -385
  253. package/dist/infra/orchestrator/PhasePipeline.js.map +0 -1
  254. package/dist/infra/orchestrator/PhaseResultStore.d.ts +0 -39
  255. package/dist/infra/orchestrator/PhaseResultStore.d.ts.map +0 -1
  256. package/dist/infra/orchestrator/PhaseResultStore.js +0 -151
  257. package/dist/infra/orchestrator/PhaseResultStore.js.map +0 -1
  258. package/dist/infra/orchestrator/SessionStore.d.ts +0 -40
  259. package/dist/infra/orchestrator/SessionStore.d.ts.map +0 -1
  260. package/dist/infra/orchestrator/SessionStore.js +0 -116
  261. package/dist/infra/orchestrator/SessionStore.js.map +0 -1
  262. package/dist/infra/orchestrator/SmartRouter.d.ts +0 -90
  263. package/dist/infra/orchestrator/SmartRouter.d.ts.map +0 -1
  264. package/dist/infra/orchestrator/SmartRouter.js +0 -277
  265. package/dist/infra/orchestrator/SmartRouter.js.map +0 -1
  266. package/dist/infra/orchestrator/SmartRouter.test.d.ts +0 -5
  267. package/dist/infra/orchestrator/SmartRouter.test.d.ts.map +0 -1
  268. package/dist/infra/orchestrator/SmartRouter.test.js +0 -484
  269. package/dist/infra/orchestrator/SmartRouter.test.js.map +0 -1
  270. package/dist/infra/orchestrator/SwarmOrchestrator.d.ts +0 -143
  271. package/dist/infra/orchestrator/SwarmOrchestrator.d.ts.map +0 -1
  272. package/dist/infra/orchestrator/SwarmOrchestrator.js +0 -378
  273. package/dist/infra/orchestrator/SwarmOrchestrator.js.map +0 -1
  274. package/dist/infra/orchestrator/SwarmOrchestrator.test.d.ts +0 -5
  275. package/dist/infra/orchestrator/SwarmOrchestrator.test.d.ts.map +0 -1
  276. package/dist/infra/orchestrator/SwarmOrchestrator.test.js +0 -95
  277. package/dist/infra/orchestrator/SwarmOrchestrator.test.js.map +0 -1
  278. package/dist/infra/orchestrator/agentDiscovery.d.ts +0 -26
  279. package/dist/infra/orchestrator/agentDiscovery.d.ts.map +0 -1
  280. package/dist/infra/orchestrator/agentDiscovery.js +0 -175
  281. package/dist/infra/orchestrator/agentDiscovery.js.map +0 -1
  282. package/dist/infra/orchestrator/backgroundAgent.d.ts +0 -9
  283. package/dist/infra/orchestrator/backgroundAgent.d.ts.map +0 -1
  284. package/dist/infra/orchestrator/backgroundAgent.js +0 -10
  285. package/dist/infra/orchestrator/backgroundAgent.js.map +0 -1
  286. package/dist/infra/orchestrator/index.d.ts +0 -207
  287. package/dist/infra/orchestrator/index.d.ts.map +0 -1
  288. package/dist/infra/orchestrator/index.js +0 -362
  289. package/dist/infra/orchestrator/index.js.map +0 -1
  290. package/dist/infra/orchestrator/orchestrator.d.ts +0 -60
  291. package/dist/infra/orchestrator/orchestrator.d.ts.map +0 -1
  292. package/dist/infra/orchestrator/orchestrator.js +0 -214
  293. package/dist/infra/orchestrator/orchestrator.js.map +0 -1
  294. package/dist/infra/orchestrator/parallelResearch.d.ts +0 -27
  295. package/dist/infra/orchestrator/parallelResearch.d.ts.map +0 -1
  296. package/dist/infra/orchestrator/parallelResearch.js +0 -285
  297. package/dist/infra/orchestrator/parallelResearch.js.map +0 -1
  298. package/dist/infra/orchestrator/types.d.ts +0 -205
  299. package/dist/infra/orchestrator/types.d.ts.map +0 -1
  300. package/dist/infra/orchestrator/types.js +0 -87
  301. package/dist/infra/orchestrator/types.js.map +0 -1
  302. package/dist/infra/orchestrator/types.test.d.ts +0 -2
  303. package/dist/infra/orchestrator/types.test.d.ts.map +0 -1
  304. package/dist/infra/orchestrator/types.test.js +0 -57
  305. package/dist/infra/orchestrator/types.test.js.map +0 -1
  306. package/dist/tools/semantic/analyzeDependencyGraph.d.ts +0 -12
  307. package/dist/tools/semantic/analyzeDependencyGraph.d.ts.map +0 -1
  308. package/dist/tools/semantic/analyzeDependencyGraph.js +0 -359
  309. package/dist/tools/semantic/analyzeDependencyGraph.js.map +0 -1
  310. package/dist/tools/semantic/astGrep.d.ts +0 -25
  311. package/dist/tools/semantic/astGrep.d.ts.map +0 -1
  312. package/dist/tools/semantic/astGrep.js +0 -324
  313. package/dist/tools/semantic/astGrep.js.map +0 -1
  314. package/dist/tools/semantic/astGrep.test.d.ts +0 -2
  315. package/dist/tools/semantic/astGrep.test.d.ts.map +0 -1
  316. package/dist/tools/semantic/astGrep.test.js +0 -74
  317. package/dist/tools/semantic/astGrep.test.js.map +0 -1
  318. package/dist/tools/semantic/findReferences.d.ts +0 -9
  319. package/dist/tools/semantic/findReferences.d.ts.map +0 -1
  320. package/dist/tools/semantic/findReferences.js +0 -200
  321. package/dist/tools/semantic/findReferences.js.map +0 -1
  322. package/dist/tools/semantic/findSymbol.d.ts +0 -8
  323. package/dist/tools/semantic/findSymbol.d.ts.map +0 -1
  324. package/dist/tools/semantic/findSymbol.js +0 -204
  325. package/dist/tools/semantic/findSymbol.js.map +0 -1
  326. package/dist/tools/semantic/index.d.ts +0 -9
  327. package/dist/tools/semantic/index.d.ts.map +0 -1
  328. package/dist/tools/semantic/index.js +0 -11
  329. package/dist/tools/semantic/index.js.map +0 -1
  330. package/dist/tools/semantic/lsp.d.ts +0 -68
  331. package/dist/tools/semantic/lsp.d.ts.map +0 -1
  332. package/dist/tools/semantic/lsp.js +0 -561
  333. package/dist/tools/semantic/lsp.js.map +0 -1
  334. package/dist/tools/spec/e2eTestGenerator.d.ts +0 -61
  335. package/dist/tools/spec/e2eTestGenerator.d.ts.map +0 -1
  336. package/dist/tools/spec/e2eTestGenerator.js +0 -255
  337. package/dist/tools/spec/e2eTestGenerator.js.map +0 -1
  338. package/dist/tools/spec/specVersioning.d.ts +0 -76
  339. package/dist/tools/spec/specVersioning.d.ts.map +0 -1
  340. package/dist/tools/spec/specVersioning.js +0 -236
  341. package/dist/tools/spec/specVersioning.js.map +0 -1
@@ -1,55 +0,0 @@
1
- import type Database from 'better-sqlite3';
2
- declare const VALID_STATUSES: readonly ["pending", "approved", "rejected", "expired", "cancelled"];
3
- type ConfirmationStatus = (typeof VALID_STATUSES)[number];
4
- export declare class InvalidTransitionError extends Error {
5
- constructor(from: string, to: string);
6
- }
7
- export interface ConfirmationRow {
8
- id: string;
9
- correlationId: string;
10
- actionType: string;
11
- actionSummary: string;
12
- riskLevel: string;
13
- riskScore: number;
14
- riskFactors: string;
15
- status: string;
16
- channel: string | null;
17
- notifiedAt: string | null;
18
- respondedAt: string | null;
19
- ownerResponse: string | null;
20
- expiresAt: string;
21
- idempotencyKey: string | null;
22
- createdAt: string;
23
- }
24
- export interface CreateConfirmationInput {
25
- correlationId: string;
26
- actionType: string;
27
- actionSummary: string;
28
- riskLevel: string;
29
- riskScore: number;
30
- riskFactors: string[];
31
- timeoutSeconds?: number;
32
- idempotencyKey?: string;
33
- }
34
- interface StorageProvider {
35
- getDatabase(): Database.Database;
36
- }
37
- export declare class ConfirmationStore {
38
- private readonly db;
39
- private readonly insertStmt;
40
- private readonly resolveStmt;
41
- private readonly getByIdStmt;
42
- constructor(storage: StorageProvider);
43
- private initTables;
44
- create(input: CreateConfirmationInput): ConfirmationRow;
45
- resolve(id: string, status: ConfirmationStatus, response?: string): ConfirmationRow;
46
- getById(id: string): ConfirmationRow | null;
47
- getExpired(): ConfirmationRow[];
48
- getPending(): ConfirmationRow[];
49
- getByCorrelation(correlationId: string): ConfirmationRow[];
50
- updateChannel(id: string, channel: string): void;
51
- getPendingCount(): number;
52
- private getByIdempotencyKey;
53
- }
54
- export {};
55
- //# sourceMappingURL=ConfirmationStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfirmationStore.d.ts","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/ConfirmationStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAG3C,QAAA,MAAM,cAAc,sEAAuE,CAAC;AAC5F,KAAK,kBAAkB,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAW1D,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM;CAIrC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG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elled'];
3
- const TERMINAL_STATUSES = new Set(['approved', 'rejected', 'expired', 'cancelled']);
4
- const VALID_TRANSITIONS = {
5
- pending: new Set(['approved', 'rejected', 'expired', 'cancelled']),
6
- };
7
- const DEFAULT_TIMEOUT_S = 300;
8
- const MAX_TIMEOUT_S = 3600;
9
- export class InvalidTransitionError extends Error {
10
- constructor(from, to) {
11
- super(`Invalid state transition: ${from} → ${to}`);
12
- this.name = 'InvalidTransitionError';
13
- }
14
- }
15
- export class ConfirmationStore {
16
- db;
17
- insertStmt;
18
- resolveStmt;
19
- getByIdStmt;
20
- constructor(storage) {
21
- this.db = storage.getDatabase();
22
- this.initTables();
23
- this.insertStmt = this.db.prepare(`
24
- INSERT INTO confirmations
25
- (id, correlationId, actionType, actionSummary, riskLevel, riskScore, riskFactors,
26
- status, expiresAt, idempotencyKey, createdAt)
27
- VALUES (?, ?, ?, ?, ?, ?, ?, 'pending', ?, ?, ?)
28
- `);
29
- this.resolveStmt = this.db.prepare(`
30
- UPDATE confirmations SET status = ?, respondedAt = ?, ownerResponse = ?
31
- WHERE id = ? AND status = 'pending'
32
- `);
33
- this.getByIdStmt = this.db.prepare('SELECT * FROM confirmations WHERE id = ?');
34
- }
35
- initTables() {
36
- this.db.exec(`
37
- CREATE TABLE IF NOT EXISTS confirmations (
38
- id TEXT PRIMARY KEY,
39
- correlationId TEXT NOT NULL,
40
- actionType TEXT NOT NULL,
41
- actionSummary TEXT NOT NULL,
42
- riskLevel TEXT NOT NULL,
43
- riskScore INTEGER NOT NULL,
44
- riskFactors TEXT NOT NULL,
45
- status TEXT NOT NULL DEFAULT 'pending'
46
- CHECK(status IN ('pending', 'approved', 'rejected', 'expired', 'cancelled')),
47
- channel TEXT,
48
- notifiedAt TEXT,
49
- respondedAt TEXT,
50
- ownerResponse TEXT,
51
- expiresAt TEXT NOT NULL,
52
- idempotencyKey TEXT UNIQUE,
53
- createdAt TEXT NOT NULL
54
- );
55
- CREATE INDEX IF NOT EXISTS idx_confirmation_status_expires ON confirmations(status, expiresAt);
56
- CREATE INDEX IF NOT EXISTS idx_confirmation_correlation ON confirmations(correlationId);
57
- CREATE INDEX IF NOT EXISTS idx_confirmation_idempotency ON confirmations(idempotencyKey);
58
- `);
59
- }
60
- create(input) {
61
- if (input.idempotencyKey) {
62
- const existing = this.getByIdempotencyKey(input.idempotencyKey);
63
- if (existing)
64
- return existing;
65
- }
66
- const id = uuidv7();
67
- const now = new Date().toISOString();
68
- const timeout = Math.min(input.timeoutSeconds ?? DEFAULT_TIMEOUT_S, MAX_TIMEOUT_S);
69
- const expiresAt = new Date(Date.now() + timeout * 1000).toISOString();
70
- this.insertStmt.run(id, input.correlationId, input.actionType, input.actionSummary, input.riskLevel, input.riskScore, JSON.stringify(input.riskFactors), expiresAt, input.idempotencyKey ?? null, now);
71
- return this.getById(id);
72
- }
73
- resolve(id, status, response) {
74
- const current = this.getById(id);
75
- if (!current) {
76
- throw new Error(`Confirmation not found: ${id}`);
77
- }
78
- const currentStatus = current.status;
79
- if (TERMINAL_STATUSES.has(currentStatus)) {
80
- throw new InvalidTransitionError(currentStatus, status);
81
- }
82
- const allowed = VALID_TRANSITIONS[currentStatus];
83
- if (!allowed || !allowed.has(status)) {
84
- throw new InvalidTransitionError(currentStatus, status);
85
- }
86
- const result = this.db.transaction(() => {
87
- const changes = this.resolveStmt.run(status, new Date().toISOString(), response ?? null, id);
88
- if (changes.changes === 0) {
89
- throw new InvalidTransitionError(currentStatus, status);
90
- }
91
- return this.getById(id);
92
- })();
93
- return result;
94
- }
95
- getById(id) {
96
- return this.getByIdStmt.get(id) ?? null;
97
- }
98
- getExpired() {
99
- const now = new Date().toISOString();
100
- return this.db
101
- .prepare("SELECT * FROM confirmations WHERE status = 'pending' AND expiresAt <= ?")
102
- .all(now);
103
- }
104
- getPending() {
105
- return this.db
106
- .prepare("SELECT * FROM confirmations WHERE status = 'pending' ORDER BY createdAt ASC")
107
- .all();
108
- }
109
- getByCorrelation(correlationId) {
110
- return this.db
111
- .prepare('SELECT * FROM confirmations WHERE correlationId = ? ORDER BY createdAt ASC')
112
- .all(correlationId);
113
- }
114
- updateChannel(id, channel) {
115
- this.db
116
- .prepare('UPDATE confirmations SET channel = ?, notifiedAt = ? WHERE id = ?')
117
- .run(channel, new Date().toISOString(), id);
118
- }
119
- getPendingCount() {
120
- return this.db
121
- .prepare("SELECT COUNT(*) as count FROM confirmations WHERE status = 'pending'")
122
- .get().count;
123
- }
124
- getByIdempotencyKey(key) {
125
- return this.db
126
- .prepare('SELECT * FROM confirmations WHERE idempotencyKey = ?')
127
- .get(key) ?? null;
128
- }
129
- }
130
- //# sourceMappingURL=ConfirmationStore.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfirmationStore.js","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/ConfirmationStore.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAU,CAAC;AAG5F,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;AAExG,MAAM,iBAAiB,GAA4C;IACjE,OAAO,EAAE,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;CACnE,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,IAAY,EAAE,EAAU;QAClC,KAAK,CAAC,6BAA6B,IAAI,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAmCD,MAAM,OAAO,iBAAiB;IACX,EAAE,CAAoB;I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AAC,OAAO,CAAC,EAAE,CAAE,CAAC;QAC3B,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,EAAU;QAChB,OAAQ,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAqB,IAAI,IAAI,CAAC;IAC/D,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,OAAO,IAAI,CAAC,EAAE;aACX,OAAO,CAAC,yEAAyE,CAAC;aAClF,GAAG,CAAC,GAAG,CAAsB,CAAC;IACnC,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,EAAE;aACX,OAAO,CAAC,6EAA6E,CAAC;aACtF,GAAG,EAAuB,CAAC;IAChC,CAAC;IAED,gBAAgB,CAAC,aAAqB;QACpC,OAAO,IAAI,CAAC,EAAE;aACX,OAAO,CAAC,4EAA4E,CAAC;aACrF,GAAG,CAAC,aAAa,CAAsB,CAAC;IAC7C,CAAC;IAED,aAAa,CAAC,EAAU,EAAE,OAAe;QACvC,IAAI,CAAC,EAAE;aACJ,OAAO,CAAC,mEAAmE,CAAC;aAC5E,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,eAAe;QACb,OACE,IAAI,CAAC,EAAE;aACJ,OAAO,CAAC,sEAAsE,CAAC;aAC/E,GAAG,EACP,CAAC,KAAK,CAAC;IACV,CAAC;IAEO,mBAAmB,CAAC,GAAW;QACrC,OACE,IAAI,CAAC,EAAE;aACJ,OAAO,CAAC,sDAAsD,CAAC;aAC/D,GAAG,CAAC,GAAG,CACX,IAAI,IAAI,CAAC;IACZ,CAAC;CACF"}
@@ -1,20 +0,0 @@
1
- import { type AutonomyEventType, type EventPayload, type EventInput, type EnrichedEvent } from './schemas.js';
2
- export type EventListener<T extends AutonomyEventType> = (event: EnrichedEvent<EventPayload<T>>) => void | Promise<void>;
3
- export declare class EventBus {
4
- private readonly listeners;
5
- private totalListenerCount;
6
- private readonly dedupCache;
7
- private readonly dedupOrder;
8
- private lastSyncErrors;
9
- on<T extends AutonomyEventType>(eventType: T, listener: EventListener<T>): void;
10
- off<T extends AutonomyEventType>(eventType: T, listener: EventListener<T>): void;
11
- emit<T extends AutonomyEventType>(eventType: T, payload: EventInput<T>): EnrichedEvent<EventPayload<T>>;
12
- emitIdempotent<T extends AutonomyEventType>(eventId: string, eventType: T, payload: EventInput<T>): EnrichedEvent<EventPayload<T>> | null;
13
- getListenerCount(eventType?: AutonomyEventType): number;
14
- getLastSyncErrors(): ReadonlyArray<Error>;
15
- removeAllListeners(eventType?: AutonomyEventType): void;
16
- private dispatch;
17
- private handleListenerError;
18
- private trackDedup;
19
- }
20
- //# sourceMappingURL=EventBus.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventBus.d.ts","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/EventBus.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAKtB,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,iBAAiB,IAAI,CACvD,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAClC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAM1B,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAChE,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,OAAO,CAAC,cAAc,CAAe;IAErC,EAAE,CAAC,CAAC,SAAS,iBAAiB,EAC5B,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,IAAI;IAUP,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAC7B,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,IAAI;IAYP,IAAI,CAAC,CAAC,SAAS,iBAAiB,EAC9B,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAmBjC,cAAc,CAAC,CAAC,SAAS,iBAAiB,EACxC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,CAAC,EACZ,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAWxC,gBAAgB,CAAC,SAAS,CAAC,EAAE,iBAAiB,GAAG,MAAM;IAOvD,iBAAiB,IAAI,aAAa,CAAC,KAAK,CAAC;IAIzC,kBAAkB,CAAC,SAAS,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAavD,OAAO,CAAC,QAAQ;IAiBhB,OAAO,CAAC,mBAAmB;IAyB3B,OAAO,CAAC,UAAU;CAQnB"}
@@ -1,119 +0,0 @@
1
- import { uuidv7 } from 'uuidv7';
2
- import { EventSchemaMap, } from './schemas.js';
3
- const MAX_LISTENERS = 50;
4
- const MAX_DEDUP_CACHE = 1000;
5
- export class EventBus {
6
- listeners = new Map();
7
- totalListenerCount = 0;
8
- dedupCache = new Set();
9
- dedupOrder = [];
10
- lastSyncErrors = [];
11
- on(eventType, listener) {
12
- if (this.totalListenerCount >= MAX_LISTENERS) {
13
- throw new Error(`Maximum listener limit (${MAX_LISTENERS}) reached`);
14
- }
15
- const list = this.listeners.get(eventType) || [];
16
- list.push({ fn: listener });
17
- this.listeners.set(eventType, list);
18
- this.totalListenerCount++;
19
- }
20
- off(eventType, listener) {
21
- const list = this.listeners.get(eventType);
22
- if (!list)
23
- return;
24
- const idx = list.findIndex((e) => e.fn === listener);
25
- if (idx !== -1) {
26
- list.splice(idx, 1);
27
- this.totalListenerCount--;
28
- }
29
- }
30
- emit(eventType, payload) {
31
- const schema = EventSchemaMap[eventType];
32
- const validated = schema.parse(payload);
33
- const enriched = {
34
- ...validated,
35
- correlationId: validated.correlationId || uuidv7(),
36
- timestamp: validated.timestamp || new Date().toISOString(),
37
- };
38
- if (eventType !== 'error') {
39
- this.lastSyncErrors = [];
40
- }
41
- this.dispatch(eventType, enriched);
42
- return enriched;
43
- }
44
- emitIdempotent(eventId, eventType, payload) {
45
- if (this.dedupCache.has(eventId)) {
46
- return null;
47
- }
48
- const result = this.emit(eventType, payload);
49
- if (this.lastSyncErrors.length === 0) {
50
- this.trackDedup(eventId);
51
- }
52
- return result;
53
- }
54
- getListenerCount(eventType) {
55
- if (eventType) {
56
- return (this.listeners.get(eventType) || []).length;
57
- }
58
- return this.totalListenerCount;
59
- }
60
- getLastSyncErrors() {
61
- return this.lastSyncErrors;
62
- }
63
- removeAllListeners(eventType) {
64
- if (eventType) {
65
- const list = this.listeners.get(eventType);
66
- if (list) {
67
- this.totalListenerCount -= list.length;
68
- this.listeners.delete(eventType);
69
- }
70
- }
71
- else {
72
- this.listeners.clear();
73
- this.totalListenerCount = 0;
74
- }
75
- }
76
- dispatch(eventType, event) {
77
- const list = this.listeners.get(eventType) || [];
78
- for (let i = 0; i < list.length; i++) {
79
- try {
80
- const result = list[i].fn(event);
81
- if (result && typeof result.catch === 'function') {
82
- result.catch((err) => {
83
- this.handleListenerError(eventType, i, err);
84
- });
85
- }
86
- }
87
- catch (err) {
88
- this.lastSyncErrors.push(err instanceof Error ? err : new Error(String(err)));
89
- this.handleListenerError(eventType, i, err);
90
- }
91
- }
92
- }
93
- handleListenerError(eventType, listenerIndex, err) {
94
- if (eventType === 'error') {
95
- process.stderr.write(`[EventBus] Error in error listener: ${err instanceof Error ? err.message : String(err)}\n`);
96
- return;
97
- }
98
- try {
99
- this.emit('error', {
100
- originalEventType: eventType,
101
- listenerIndex,
102
- error: err instanceof Error ? err.message : String(err),
103
- stack: err instanceof Error ? err.stack : undefined,
104
- });
105
- }
106
- catch {
107
- process.stderr.write(`[EventBus] Failed to emit error event: ${err instanceof Error ? err.message : String(err)}\n`);
108
- }
109
- }
110
- trackDedup(eventId) {
111
- this.dedupCache.add(eventId);
112
- this.dedupOrder.push(eventId);
113
- if (this.dedupOrder.length > MAX_DEDUP_CACHE) {
114
- const oldest = this.dedupOrder.shift();
115
- this.dedupCache.delete(oldest);
116
- }
117
- }
118
- }
119
- //# sourceMappingURL=EventBus.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventBus.js","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/EventBus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAEL,cAAc,GAIf,MAAM,cAAc,CAAC;AAEtB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,eAAe,GAAG,IAAI,CAAC;AAU7B,MAAM,OAAO,QAAQ;IACF,SAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;IACxD,kBAAkB,GAAG,CAAC,CAAC;IACd,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,UAAU,GAAa,EAAE,CAAC;IACnC,cAAc,GAAY,EAAE,CAAC;IAErC,EAAE,CACA,SAAY,EACZ,QAA0B;QAE1B,IAAI,IAAI,CAAC,kBAAkB,IAAI,aAAa,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,2BAA2B,aAAa,WAAW,CAAC,CAAC;QACvE,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QACjD,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,QAAoD,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,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;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,0CAA0C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAC/F,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,OAAe;QAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC9B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,eAAe,EAAE,CAAC;YAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAG,CAAC;YACxC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;CACF"}
@@ -1,32 +0,0 @@
1
- import type Database from 'better-sqlite3';
2
- import type { EventBus } from './EventBus.js';
3
- interface StorageProvider {
4
- getDatabase(): Database.Database;
5
- }
6
- export declare class EventOutbox {
7
- private readonly db;
8
- private readonly eventBus;
9
- private readonly enqueueStmt;
10
- private readonly markProcessingStmt;
11
- private readonly markPublishedStmt;
12
- private readonly markPendingRetryStmt;
13
- private readonly markFailedStmt;
14
- private readonly moveToDeadLetterStmt;
15
- private intervalId;
16
- private processing;
17
- constructor(storage: StorageProvider, eventBus: EventBus);
18
- private initTables;
19
- enqueue(event: {
20
- eventType: string;
21
- payload: Record<string, unknown>;
22
- }): string;
23
- start(): void;
24
- stop(): void;
25
- processOutbox(): void;
26
- getPendingCount(): number;
27
- getDeadLetterCount(): number;
28
- private processOne;
29
- private recoverProcessing;
30
- }
31
- export {};
32
- //# sourceMappingURL=EventOutbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventOutbox.d.ts","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/EventOutbox.ts"],"names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ueStmt;
10
- markProcessingStmt;
11
- markPublishedStmt;
12
- markPendingRetryStmt;
13
- markFailedStmt;
14
- moveToDeadLetterStmt;
15
- intervalId = null;
16
- processing = false;
17
- constructor(storage, eventBus) {
18
- this.db = storage.getDatabase();
19
- this.eventBus = eventBus;
20
- this.initTables();
21
- this.enqueueStmt = this.db.prepare(`
22
- INSERT INTO event_outbox (id, eventType, payload, status, retryCount, createdAt)
23
- VALUES (?, ?, ?, 'pending', 0, ?)
24
- `);
25
- this.markProcessingStmt = this.db.prepare(`
26
- UPDATE event_outbox SET status = 'processing' WHERE id = ? AND status = 'pending'
27
- `);
28
- this.markPublishedStmt = this.db.prepare(`
29
- UPDATE event_outbox SET status = 'published', publishedAt = ? WHERE id = ?
30
- `);
31
- this.markPendingRetryStmt = this.db.prepare(`
32
- UPDATE event_outbox SET status = 'pending', retryCount = retryCount + 1, lastRetryAt = ? WHERE id = ?
33
- `);
34
- this.markFailedStmt = this.db.prepare(`
35
- UPDATE event_outbox SET status = 'failed' WHERE id = ?
36
- `);
37
- this.moveToDeadLetterStmt = this.db.prepare(`
38
- INSERT INTO dead_letter_events (id, originalEventId, eventType, payload, error, retryCount, failedAt)
39
- VALUES (?, ?, ?, ?, ?, ?, ?)
40
- `);
41
- }
42
- initTables() {
43
- this.db.exec(`
44
- CREATE TABLE IF NOT EXISTS event_outbox (
45
- id TEXT PRIMARY KEY,
46
- eventType TEXT NOT NULL,
47
- payload TEXT NOT NULL,
48
- status TEXT DEFAULT 'pending' CHECK(status IN ('pending', 'processing', 'published', 'failed')),
49
- retryCount INTEGER DEFAULT 0,
50
- lastRetryAt TEXT,
51
- createdAt TEXT NOT NULL,
52
- publishedAt TEXT
53
- );
54
- CREATE INDEX IF NOT EXISTS idx_outbox_status ON event_outbox(status, createdAt);
55
-
56
- CREATE TABLE IF NOT EXISTS dead_letter_events (
57
- id TEXT PRIMARY KEY,
58
- originalEventId TEXT NOT NULL,
59
- eventType TEXT NOT NULL,
60
- payload TEXT NOT NULL,
61
- error TEXT NOT NULL,
62
- retryCount INTEGER NOT NULL,
63
- failedAt TEXT NOT NULL,
64
- resolvedAt TEXT,
65
- status TEXT DEFAULT 'failed' CHECK(status IN ('failed', 'retried', 'discarded'))
66
- );
67
- `);
68
- }
69
- enqueue(event) {
70
- const id = uuidv7();
71
- this.enqueueStmt.run(id, event.eventType, JSON.stringify(event.payload), new Date().toISOString());
72
- return id;
73
- }
74
- start() {
75
- this.recoverProcessing();
76
- this.intervalId = setInterval(() => {
77
- if (!this.processing) {
78
- this.processOutbox();
79
- }
80
- }, POLL_INTERVAL_MS);
81
- }
82
- stop() {
83
- if (this.intervalId) {
84
- clearInterval(this.intervalId);
85
- this.intervalId = null;
86
- }
87
- }
88
- processOutbox() {
89
- this.processing = true;
90
- try {
91
- const pending = this.db
92
- .prepare(`SELECT * FROM event_outbox WHERE status = 'pending' ORDER BY createdAt ASC LIMIT ?`)
93
- .all(BATCH_SIZE);
94
- for (const row of pending) {
95
- if (row.retryCount > 0 && row.lastRetryAt) {
96
- const backoff = BACKOFF_MS[Math.min(row.retryCount - 1, BACKOFF_MS.length - 1)];
97
- const elapsed = Date.now() - new Date(row.lastRetryAt).getTime();
98
- if (elapsed < backoff)
99
- continue;
100
- }
101
- this.processOne(row);
102
- }
103
- }
104
- finally {
105
- this.processing = false;
106
- }
107
- }
108
- getPendingCount() {
109
- return this.db
110
- .prepare(`SELECT COUNT(*) as count FROM event_outbox WHERE status = 'pending'`)
111
- .get().count;
112
- }
113
- getDeadLetterCount() {
114
- return this.db
115
- .prepare(`SELECT COUNT(*) as count FROM dead_letter_events WHERE status = 'failed'`)
116
- .get().count;
117
- }
118
- processOne(row) {
119
- const changed = this.markProcessingStmt.run(row.id);
120
- if (changed.changes === 0)
121
- return;
122
- try {
123
- const payload = JSON.parse(row.payload);
124
- this.eventBus.emitIdempotent(row.id, row.eventType, payload);
125
- const syncErrors = this.eventBus.getLastSyncErrors();
126
- if (syncErrors.length > 0) {
127
- throw syncErrors[0];
128
- }
129
- this.markPublishedStmt.run(new Date().toISOString(), row.id);
130
- }
131
- catch (err) {
132
- const now = new Date().toISOString();
133
- const newRetryCount = row.retryCount + 1;
134
- if (newRetryCount >= MAX_RETRY) {
135
- this.db.transaction(() => {
136
- this.markFailedStmt.run(row.id);
137
- this.moveToDeadLetterStmt.run(uuidv7(), row.id, row.eventType, row.payload, err instanceof Error ? err.message : String(err), newRetryCount, now);
138
- })();
139
- process.stderr.write(`[EventOutbox] Event ${row.id} moved to dead letter after ${newRetryCount} retries\n`);
140
- }
141
- else {
142
- this.markPendingRetryStmt.run(now, row.id);
143
- }
144
- }
145
- }
146
- recoverProcessing() {
147
- this.db
148
- .prepare(`UPDATE event_outbox SET status = 'pending' WHERE status = 'processing'`)
149
- .run();
150
- }
151
- }
152
- //# sourceMappingURL=EventOutbox.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EventOutbox.js","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/EventOutbox.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAiBvC,MAAM,OAAO,WAAW;IACL,EAAE,CAAoB;IACtB,QAAQ,CAAW;IACnB,WAAW,CAAqB;IAChC,kBAAkB,CAAqB;IACvC,iBAAiB,CAAqB;IACtC,oBAAoB,CAAqB;IACzC,cAAc,CAAqB;IACnC,oBAAoB,CAAqB;IAClD,UAAU,GAA0C,IAAI,CAAC;IACzD,UAAU,GAAG,KAAK,CAAC;IAE3B,YAAY,OAAwB,EAAE,QAAkB;QACtD,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG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AC;gBACJ,CAAC,CAAC,EAAE,CAAC;gBACL,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,uBAAuB,GAAG,CAAC,EAAE,+BAA+B,aAAa,YAAY,CACtF,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,EAAE;aACJ,OAAO,CAAC,wEAAwE,CAAC;aACjF,GAAG,EAAE,CAAC;IACX,CAAC;CACF"}
@@ -1,24 +0,0 @@
1
- import type { ConfirmationRow } from './ConfirmationStore.js';
2
- export interface NotificationChannel {
3
- readonly name: string;
4
- send(confirmation: ConfirmationRow, message: string): Promise<boolean>;
5
- }
6
- export interface NotificationResult {
7
- success: boolean;
8
- channel: string | null;
9
- error?: string;
10
- }
11
- export declare class NotificationDispatcher {
12
- private readonly channels;
13
- private readonly dedupeMap;
14
- constructor(channels: NotificationChannel[]);
15
- notify(confirmation: ConfirmationRow): Promise<NotificationResult>;
16
- formatMessage(confirmation: ConfirmationRow): string;
17
- getChannelCount(): number;
18
- private sendWithTimeout;
19
- private isSpam;
20
- private trackSend;
21
- private parseFactors;
22
- private calculateExpiresIn;
23
- }
24
- //# sourceMappingURL=NotificationDispatcher.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NotificationDispatcher.d.ts","sourceRoot":"","sources":["../../../../src/infra/lib/autonomy/NotificationDispatcher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAM9D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAOD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkC;gBAEhD,QAAQ,EAAE,mBAAmB,EAAE;IAIrC,MAAM,CAAC,YAAY,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA+BxE,aAAa,CAAC,YAAY,EAAE,eAAe,GAAG,MAAM;IAiBpD,eAAe,IAAI,MAAM;YAIX,eAAe;IAuB7B,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,SAAS;IASjB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,kBAAkB;CAQ3B"}