claude-flow 3.25.6 → 3.26.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 (311) hide show
  1. package/.claude/helpers/.helpers-version +1 -1
  2. package/.claude/helpers/helpers.manifest.json +5 -4
  3. package/.claude/helpers/hook-handler.cjs +129 -0
  4. package/.claude/helpers/intelligence.cjs +10 -0
  5. package/.claude/helpers/statusline.cjs +300 -123
  6. package/.claude/proven-config.json +1 -1
  7. package/.claude/security-scans/scan-all-standard.json +321 -0
  8. package/.claude/security-scans/scan-code-deep.json +1209 -0
  9. package/.claude/security-scans/scan-deps-full.json +14 -0
  10. package/package.json +3 -1
  11. package/v3/@claude-flow/cli/catalog-manifest.json +12 -0
  12. package/v3/@claude-flow/cli/dist/src/commands/advisor.d.ts +15 -0
  13. package/v3/@claude-flow/cli/dist/src/commands/advisor.js +94 -0
  14. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +77 -3
  15. package/v3/@claude-flow/cli/dist/src/commands/funnel.d.ts +13 -0
  16. package/v3/@claude-flow/cli/dist/src/commands/funnel.js +103 -0
  17. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +112 -46
  18. package/v3/@claude-flow/cli/dist/src/commands/index.js +10 -0
  19. package/v3/@claude-flow/cli/dist/src/commands/init.js +44 -0
  20. package/v3/@claude-flow/cli/dist/src/commands/proxy.d.ts +21 -0
  21. package/v3/@claude-flow/cli/dist/src/commands/proxy.js +310 -0
  22. package/v3/@claude-flow/cli/dist/src/commands/security.js +29 -0
  23. package/v3/@claude-flow/cli/dist/src/commands/settings.d.ts +19 -0
  24. package/v3/@claude-flow/cli/dist/src/commands/settings.js +180 -0
  25. package/v3/@claude-flow/cli/dist/src/commands/version.d.ts +42 -0
  26. package/v3/@claude-flow/cli/dist/src/commands/version.js +106 -0
  27. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.d.ts +58 -0
  28. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.js +92 -0
  29. package/v3/@claude-flow/cli/dist/src/funnel/attribution.d.ts +37 -0
  30. package/v3/@claude-flow/cli/dist/src/funnel/attribution.js +101 -0
  31. package/v3/@claude-flow/cli/dist/src/funnel/consent.d.ts +22 -0
  32. package/v3/@claude-flow/cli/dist/src/funnel/consent.js +55 -0
  33. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.d.ts +31 -0
  34. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.js +88 -0
  35. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.d.ts +44 -0
  36. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.js +74 -0
  37. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.d.ts +46 -0
  38. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.js +97 -0
  39. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.d.ts +36 -0
  40. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.js +64 -0
  41. package/v3/@claude-flow/cli/dist/src/funnel/environment.d.ts +17 -0
  42. package/v3/@claude-flow/cli/dist/src/funnel/environment.js +39 -0
  43. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.d.ts +51 -0
  44. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.js +199 -0
  45. package/v3/@claude-flow/cli/dist/src/funnel/events.d.ts +42 -0
  46. package/v3/@claude-flow/cli/dist/src/funnel/events.js +150 -0
  47. package/v3/@claude-flow/cli/dist/src/funnel/index.d.ts +20 -0
  48. package/v3/@claude-flow/cli/dist/src/funnel/index.js +20 -0
  49. package/v3/@claude-flow/cli/dist/src/funnel/insights.d.ts +49 -0
  50. package/v3/@claude-flow/cli/dist/src/funnel/insights.js +120 -0
  51. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.d.ts +15 -0
  52. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +68 -0
  53. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.d.ts +51 -0
  54. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.js +149 -0
  55. package/v3/@claude-flow/cli/dist/src/funnel/messages.d.ts +55 -0
  56. package/v3/@claude-flow/cli/dist/src/funnel/messages.js +160 -0
  57. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.d.ts +44 -0
  58. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.js +92 -0
  59. package/v3/@claude-flow/cli/dist/src/funnel/precedence.d.ts +16 -0
  60. package/v3/@claude-flow/cli/dist/src/funnel/precedence.js +85 -0
  61. package/v3/@claude-flow/cli/dist/src/funnel/promo.d.ts +41 -0
  62. package/v3/@claude-flow/cli/dist/src/funnel/promo.js +144 -0
  63. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.d.ts +55 -0
  64. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.js +102 -0
  65. package/v3/@claude-flow/cli/dist/src/funnel/rotation.d.ts +19 -0
  66. package/v3/@claude-flow/cli/dist/src/funnel/rotation.js +70 -0
  67. package/v3/@claude-flow/cli/dist/src/funnel/state.d.ts +13 -0
  68. package/v3/@claude-flow/cli/dist/src/funnel/state.js +52 -0
  69. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.d.ts +17 -0
  70. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.js +32 -0
  71. package/v3/@claude-flow/cli/dist/src/funnel/types.d.ts +86 -0
  72. package/v3/@claude-flow/cli/dist/src/funnel/types.js +26 -0
  73. package/v3/@claude-flow/cli/dist/src/init/executor.js +9 -3
  74. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.d.ts +33 -2
  75. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.js +102 -12
  76. package/v3/@claude-flow/cli/dist/src/init/helpers-generator.js +52 -0
  77. package/v3/@claude-flow/cli/dist/src/init/statusline-generator.js +282 -116
  78. package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.js +28 -5
  79. package/v3/@claude-flow/cli/dist/src/services/fable-harness.d.ts +39 -0
  80. package/v3/@claude-flow/cli/dist/src/services/fable-harness.js +41 -0
  81. package/v3/@claude-flow/cli/package.json +13 -4
  82. package/.claude/coordinator/config.json +0 -24
  83. package/.claude/coordinator/state.json +0 -37
  84. package/.claude/coordinator/tick-log/tick-01.json +0 -17
  85. package/.claude/coordinator/tick-log/tick-02.json +0 -17
  86. package/.claude/coordinator/tick-log/tick-03.json +0 -17
  87. package/.claude/coordinator/tick-log/tick-04.json +0 -14
  88. package/.claude/coordinator/tick-log/tick-05.json +0 -16
  89. package/.claude/settings.local.json +0 -11
  90. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.d.ts +0 -14
  91. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.js +0 -144
  92. package/v3/@claude-flow/guidance/dist/adversarial.d.ts +0 -284
  93. package/v3/@claude-flow/guidance/dist/adversarial.js +0 -572
  94. package/v3/@claude-flow/guidance/dist/analyzer.d.ts +0 -530
  95. package/v3/@claude-flow/guidance/dist/analyzer.js +0 -2587
  96. package/v3/@claude-flow/guidance/dist/artifacts.d.ts +0 -283
  97. package/v3/@claude-flow/guidance/dist/artifacts.js +0 -356
  98. package/v3/@claude-flow/guidance/dist/authority.d.ts +0 -290
  99. package/v3/@claude-flow/guidance/dist/authority.js +0 -558
  100. package/v3/@claude-flow/guidance/dist/capabilities.d.ts +0 -209
  101. package/v3/@claude-flow/guidance/dist/capabilities.js +0 -485
  102. package/v3/@claude-flow/guidance/dist/coherence.d.ts +0 -233
  103. package/v3/@claude-flow/guidance/dist/coherence.js +0 -372
  104. package/v3/@claude-flow/guidance/dist/compiler.d.ts +0 -87
  105. package/v3/@claude-flow/guidance/dist/compiler.js +0 -410
  106. package/v3/@claude-flow/guidance/dist/conformance-kit.d.ts +0 -225
  107. package/v3/@claude-flow/guidance/dist/conformance-kit.js +0 -629
  108. package/v3/@claude-flow/guidance/dist/continue-gate.d.ts +0 -214
  109. package/v3/@claude-flow/guidance/dist/continue-gate.js +0 -353
  110. package/v3/@claude-flow/guidance/dist/crypto-utils.d.ts +0 -17
  111. package/v3/@claude-flow/guidance/dist/crypto-utils.js +0 -24
  112. package/v3/@claude-flow/guidance/dist/evolution.d.ts +0 -282
  113. package/v3/@claude-flow/guidance/dist/evolution.js +0 -500
  114. package/v3/@claude-flow/guidance/dist/gates.d.ts +0 -79
  115. package/v3/@claude-flow/guidance/dist/gates.js +0 -302
  116. package/v3/@claude-flow/guidance/dist/gateway.d.ts +0 -206
  117. package/v3/@claude-flow/guidance/dist/gateway.js +0 -452
  118. package/v3/@claude-flow/guidance/dist/generators.d.ts +0 -153
  119. package/v3/@claude-flow/guidance/dist/generators.js +0 -682
  120. package/v3/@claude-flow/guidance/dist/headless.d.ts +0 -177
  121. package/v3/@claude-flow/guidance/dist/headless.js +0 -342
  122. package/v3/@claude-flow/guidance/dist/hooks.d.ts +0 -109
  123. package/v3/@claude-flow/guidance/dist/hooks.js +0 -347
  124. package/v3/@claude-flow/guidance/dist/index.d.ts +0 -205
  125. package/v3/@claude-flow/guidance/dist/index.js +0 -321
  126. package/v3/@claude-flow/guidance/dist/ledger.d.ts +0 -162
  127. package/v3/@claude-flow/guidance/dist/ledger.js +0 -375
  128. package/v3/@claude-flow/guidance/dist/manifest-validator.d.ts +0 -289
  129. package/v3/@claude-flow/guidance/dist/manifest-validator.js +0 -838
  130. package/v3/@claude-flow/guidance/dist/memory-gate.d.ts +0 -222
  131. package/v3/@claude-flow/guidance/dist/memory-gate.js +0 -382
  132. package/v3/@claude-flow/guidance/dist/meta-governance.d.ts +0 -265
  133. package/v3/@claude-flow/guidance/dist/meta-governance.js +0 -348
  134. package/v3/@claude-flow/guidance/dist/optimizer.d.ts +0 -104
  135. package/v3/@claude-flow/guidance/dist/optimizer.js +0 -329
  136. package/v3/@claude-flow/guidance/dist/persistence.d.ts +0 -189
  137. package/v3/@claude-flow/guidance/dist/persistence.js +0 -464
  138. package/v3/@claude-flow/guidance/dist/proof.d.ts +0 -185
  139. package/v3/@claude-flow/guidance/dist/proof.js +0 -238
  140. package/v3/@claude-flow/guidance/dist/retriever.d.ts +0 -172
  141. package/v3/@claude-flow/guidance/dist/retriever.js +0 -596
  142. package/v3/@claude-flow/guidance/dist/ruvbot-integration.d.ts +0 -370
  143. package/v3/@claude-flow/guidance/dist/ruvbot-integration.js +0 -738
  144. package/v3/@claude-flow/guidance/dist/temporal.d.ts +0 -426
  145. package/v3/@claude-flow/guidance/dist/temporal.js +0 -658
  146. package/v3/@claude-flow/guidance/dist/trust.d.ts +0 -283
  147. package/v3/@claude-flow/guidance/dist/trust.js +0 -473
  148. package/v3/@claude-flow/guidance/dist/truth-anchors.d.ts +0 -276
  149. package/v3/@claude-flow/guidance/dist/truth-anchors.js +0 -488
  150. package/v3/@claude-flow/guidance/dist/types.d.ts +0 -378
  151. package/v3/@claude-flow/guidance/dist/types.js +0 -10
  152. package/v3/@claude-flow/guidance/dist/uncertainty.d.ts +0 -372
  153. package/v3/@claude-flow/guidance/dist/uncertainty.js +0 -619
  154. package/v3/@claude-flow/guidance/dist/wasm-kernel.d.ts +0 -48
  155. package/v3/@claude-flow/guidance/dist/wasm-kernel.js +0 -158
  156. package/v3/@claude-flow/shared/dist/core/config/defaults.d.ts +0 -41
  157. package/v3/@claude-flow/shared/dist/core/config/defaults.js +0 -186
  158. package/v3/@claude-flow/shared/dist/core/config/index.d.ts +0 -8
  159. package/v3/@claude-flow/shared/dist/core/config/index.js +0 -12
  160. package/v3/@claude-flow/shared/dist/core/config/loader.d.ts +0 -45
  161. package/v3/@claude-flow/shared/dist/core/config/loader.js +0 -238
  162. package/v3/@claude-flow/shared/dist/core/config/schema.d.ts +0 -1728
  163. package/v3/@claude-flow/shared/dist/core/config/schema.js +0 -160
  164. package/v3/@claude-flow/shared/dist/core/config/validator.d.ts +0 -92
  165. package/v3/@claude-flow/shared/dist/core/config/validator.js +0 -147
  166. package/v3/@claude-flow/shared/dist/core/event-bus.d.ts +0 -31
  167. package/v3/@claude-flow/shared/dist/core/event-bus.js +0 -197
  168. package/v3/@claude-flow/shared/dist/core/index.d.ts +0 -15
  169. package/v3/@claude-flow/shared/dist/core/index.js +0 -19
  170. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.d.ts +0 -200
  171. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.js +0 -6
  172. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.d.ts +0 -310
  173. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.js +0 -7
  174. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.d.ts +0 -224
  175. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.js +0 -46
  176. package/v3/@claude-flow/shared/dist/core/interfaces/index.d.ts +0 -10
  177. package/v3/@claude-flow/shared/dist/core/interfaces/index.js +0 -15
  178. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.d.ts +0 -298
  179. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.js +0 -7
  180. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.d.ts +0 -185
  181. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.js +0 -6
  182. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.d.ts +0 -35
  183. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.js +0 -101
  184. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.d.ts +0 -60
  185. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.js +0 -166
  186. package/v3/@claude-flow/shared/dist/core/orchestrator/index.d.ts +0 -46
  187. package/v3/@claude-flow/shared/dist/core/orchestrator/index.js +0 -64
  188. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.d.ts +0 -56
  189. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.js +0 -195
  190. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.d.ts +0 -83
  191. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.js +0 -193
  192. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.d.ts +0 -49
  193. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.js +0 -253
  194. package/v3/@claude-flow/shared/dist/events/domain-events.d.ts +0 -282
  195. package/v3/@claude-flow/shared/dist/events/domain-events.js +0 -165
  196. package/v3/@claude-flow/shared/dist/events/event-store.d.ts +0 -126
  197. package/v3/@claude-flow/shared/dist/events/event-store.js +0 -427
  198. package/v3/@claude-flow/shared/dist/events/event-store.test.d.ts +0 -8
  199. package/v3/@claude-flow/shared/dist/events/event-store.test.js +0 -293
  200. package/v3/@claude-flow/shared/dist/events/example-usage.d.ts +0 -10
  201. package/v3/@claude-flow/shared/dist/events/example-usage.js +0 -193
  202. package/v3/@claude-flow/shared/dist/events/index.d.ts +0 -21
  203. package/v3/@claude-flow/shared/dist/events/index.js +0 -22
  204. package/v3/@claude-flow/shared/dist/events/projections.d.ts +0 -177
  205. package/v3/@claude-flow/shared/dist/events/projections.js +0 -421
  206. package/v3/@claude-flow/shared/dist/events/rvf-event-log.d.ts +0 -82
  207. package/v3/@claude-flow/shared/dist/events/rvf-event-log.js +0 -340
  208. package/v3/@claude-flow/shared/dist/events/state-reconstructor.d.ts +0 -101
  209. package/v3/@claude-flow/shared/dist/events/state-reconstructor.js +0 -263
  210. package/v3/@claude-flow/shared/dist/events.d.ts +0 -80
  211. package/v3/@claude-flow/shared/dist/events.js +0 -249
  212. package/v3/@claude-flow/shared/dist/hooks/example-usage.d.ts +0 -42
  213. package/v3/@claude-flow/shared/dist/hooks/example-usage.js +0 -351
  214. package/v3/@claude-flow/shared/dist/hooks/executor.d.ts +0 -100
  215. package/v3/@claude-flow/shared/dist/hooks/executor.js +0 -267
  216. package/v3/@claude-flow/shared/dist/hooks/hooks.test.d.ts +0 -9
  217. package/v3/@claude-flow/shared/dist/hooks/hooks.test.js +0 -322
  218. package/v3/@claude-flow/shared/dist/hooks/index.d.ts +0 -52
  219. package/v3/@claude-flow/shared/dist/hooks/index.js +0 -51
  220. package/v3/@claude-flow/shared/dist/hooks/registry.d.ts +0 -133
  221. package/v3/@claude-flow/shared/dist/hooks/registry.js +0 -277
  222. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.d.ts +0 -105
  223. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.js +0 -481
  224. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.d.ts +0 -144
  225. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.js +0 -328
  226. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.d.ts +0 -158
  227. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.js +0 -450
  228. package/v3/@claude-flow/shared/dist/hooks/safety/index.d.ts +0 -17
  229. package/v3/@claude-flow/shared/dist/hooks/safety/index.js +0 -17
  230. package/v3/@claude-flow/shared/dist/hooks/session-hooks.d.ts +0 -234
  231. package/v3/@claude-flow/shared/dist/hooks/session-hooks.js +0 -334
  232. package/v3/@claude-flow/shared/dist/hooks/task-hooks.d.ts +0 -163
  233. package/v3/@claude-flow/shared/dist/hooks/task-hooks.js +0 -326
  234. package/v3/@claude-flow/shared/dist/hooks/types.d.ts +0 -267
  235. package/v3/@claude-flow/shared/dist/hooks/types.js +0 -62
  236. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.d.ts +0 -9
  237. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.js +0 -93
  238. package/v3/@claude-flow/shared/dist/index.d.ts +0 -20
  239. package/v3/@claude-flow/shared/dist/index.js +0 -50
  240. package/v3/@claude-flow/shared/dist/mcp/connection-pool.d.ts +0 -98
  241. package/v3/@claude-flow/shared/dist/mcp/connection-pool.js +0 -364
  242. package/v3/@claude-flow/shared/dist/mcp/index.d.ts +0 -69
  243. package/v3/@claude-flow/shared/dist/mcp/index.js +0 -84
  244. package/v3/@claude-flow/shared/dist/mcp/server.d.ts +0 -166
  245. package/v3/@claude-flow/shared/dist/mcp/server.js +0 -590
  246. package/v3/@claude-flow/shared/dist/mcp/session-manager.d.ts +0 -136
  247. package/v3/@claude-flow/shared/dist/mcp/session-manager.js +0 -335
  248. package/v3/@claude-flow/shared/dist/mcp/tool-registry.d.ts +0 -178
  249. package/v3/@claude-flow/shared/dist/mcp/tool-registry.js +0 -439
  250. package/v3/@claude-flow/shared/dist/mcp/transport/http.d.ts +0 -104
  251. package/v3/@claude-flow/shared/dist/mcp/transport/http.js +0 -476
  252. package/v3/@claude-flow/shared/dist/mcp/transport/index.d.ts +0 -102
  253. package/v3/@claude-flow/shared/dist/mcp/transport/index.js +0 -238
  254. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.d.ts +0 -104
  255. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.js +0 -263
  256. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +0 -133
  257. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.js +0 -396
  258. package/v3/@claude-flow/shared/dist/mcp/types.d.ts +0 -436
  259. package/v3/@claude-flow/shared/dist/mcp/types.js +0 -54
  260. package/v3/@claude-flow/shared/dist/plugin-interface.d.ts +0 -544
  261. package/v3/@claude-flow/shared/dist/plugin-interface.js +0 -23
  262. package/v3/@claude-flow/shared/dist/plugin-loader.d.ts +0 -139
  263. package/v3/@claude-flow/shared/dist/plugin-loader.js +0 -434
  264. package/v3/@claude-flow/shared/dist/plugin-registry.d.ts +0 -183
  265. package/v3/@claude-flow/shared/dist/plugin-registry.js +0 -457
  266. package/v3/@claude-flow/shared/dist/plugins/index.d.ts +0 -10
  267. package/v3/@claude-flow/shared/dist/plugins/index.js +0 -10
  268. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.d.ts +0 -106
  269. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.js +0 -241
  270. package/v3/@claude-flow/shared/dist/plugins/official/index.d.ts +0 -10
  271. package/v3/@claude-flow/shared/dist/plugins/official/index.js +0 -10
  272. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.d.ts +0 -121
  273. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.js +0 -355
  274. package/v3/@claude-flow/shared/dist/plugins/types.d.ts +0 -93
  275. package/v3/@claude-flow/shared/dist/plugins/types.js +0 -9
  276. package/v3/@claude-flow/shared/dist/resilience/bulkhead.d.ts +0 -105
  277. package/v3/@claude-flow/shared/dist/resilience/bulkhead.js +0 -206
  278. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.d.ts +0 -132
  279. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.js +0 -233
  280. package/v3/@claude-flow/shared/dist/resilience/index.d.ts +0 -19
  281. package/v3/@claude-flow/shared/dist/resilience/index.js +0 -19
  282. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.d.ts +0 -168
  283. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.js +0 -314
  284. package/v3/@claude-flow/shared/dist/resilience/retry.d.ts +0 -91
  285. package/v3/@claude-flow/shared/dist/resilience/retry.js +0 -159
  286. package/v3/@claude-flow/shared/dist/security/index.d.ts +0 -10
  287. package/v3/@claude-flow/shared/dist/security/index.js +0 -12
  288. package/v3/@claude-flow/shared/dist/security/input-validation.d.ts +0 -73
  289. package/v3/@claude-flow/shared/dist/security/input-validation.js +0 -201
  290. package/v3/@claude-flow/shared/dist/security/secure-random.d.ts +0 -92
  291. package/v3/@claude-flow/shared/dist/security/secure-random.js +0 -142
  292. package/v3/@claude-flow/shared/dist/services/index.d.ts +0 -7
  293. package/v3/@claude-flow/shared/dist/services/index.js +0 -7
  294. package/v3/@claude-flow/shared/dist/services/v3-progress.service.d.ts +0 -124
  295. package/v3/@claude-flow/shared/dist/services/v3-progress.service.js +0 -402
  296. package/v3/@claude-flow/shared/dist/types/agent.types.d.ts +0 -137
  297. package/v3/@claude-flow/shared/dist/types/agent.types.js +0 -6
  298. package/v3/@claude-flow/shared/dist/types/index.d.ts +0 -11
  299. package/v3/@claude-flow/shared/dist/types/index.js +0 -17
  300. package/v3/@claude-flow/shared/dist/types/mcp.types.d.ts +0 -266
  301. package/v3/@claude-flow/shared/dist/types/mcp.types.js +0 -7
  302. package/v3/@claude-flow/shared/dist/types/memory.types.d.ts +0 -236
  303. package/v3/@claude-flow/shared/dist/types/memory.types.js +0 -7
  304. package/v3/@claude-flow/shared/dist/types/swarm.types.d.ts +0 -186
  305. package/v3/@claude-flow/shared/dist/types/swarm.types.js +0 -65
  306. package/v3/@claude-flow/shared/dist/types/task.types.d.ts +0 -178
  307. package/v3/@claude-flow/shared/dist/types/task.types.js +0 -32
  308. package/v3/@claude-flow/shared/dist/types.d.ts +0 -197
  309. package/v3/@claude-flow/shared/dist/types.js +0 -21
  310. package/v3/@claude-flow/shared/dist/utils/secure-logger.d.ts +0 -69
  311. package/v3/@claude-flow/shared/dist/utils/secure-logger.js +0 -208
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Credit-exhaustion notifier — writes a marker file so the ADR-303 recovery
3
+ * surface fires on the next appropriate command render, and keeps a short
4
+ * user-visible notification in `~/.ruflo/credit-status.json`.
5
+ *
6
+ * This is NOT the ADR-303 credit-error classifier — that lives in
7
+ * `credit-errors.ts` and reads provider error codes to decide when a
8
+ * credit surface fires *during* a command. This module is the OUT-OF-BAND
9
+ * signal path: the analytics transport detected a credit-exhausted
10
+ * response (HTTP 402 or ADR-303 machine-readable code), and we need to
11
+ * warn the user asynchronously.
12
+ *
13
+ * State is cheap and durable:
14
+ * ~/.ruflo/credit-status.json = { exhausted: bool, since: ISO, cleared: ISO|null }
15
+ *
16
+ * Cleared automatically when the user opens the enrollment / signup
17
+ * surface, or explicitly via `ruflo funnel credit-clear`.
18
+ */
19
+ export declare const CREDIT_STATUS_FILE = "credit-status.json";
20
+ export interface CreditStatus {
21
+ exhausted: boolean;
22
+ since: string | null;
23
+ cleared: string | null;
24
+ }
25
+ /** Read the current credit status. Never throws. */
26
+ export declare function readCreditStatus(): CreditStatus;
27
+ /**
28
+ * Mark credit as exhausted — idempotent. Sets `since` on the first mark,
29
+ * leaves it alone on subsequent marks so the user sees a stable "since"
30
+ * timestamp until they clear it.
31
+ */
32
+ export declare function markCreditExhausted(now?: Date): void;
33
+ /**
34
+ * Clear credit-exhaustion status. Called when the user completes signup or
35
+ * runs `ruflo funnel credit-clear`. `cleared` is stamped so the previous
36
+ * `since` remains inspectable for one recovery cycle.
37
+ */
38
+ export declare function clearCreditStatus(now?: Date): void;
39
+ /**
40
+ * User-facing single-line summary — plain text, no ANSI. Callers style it
41
+ * themselves. Returns null when credit isn't exhausted (no surface).
42
+ */
43
+ export declare function creditExhaustedNotice(now?: Date): string | null;
44
+ //# sourceMappingURL=credit-notifier.d.ts.map
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Credit-exhaustion notifier — writes a marker file so the ADR-303 recovery
3
+ * surface fires on the next appropriate command render, and keeps a short
4
+ * user-visible notification in `~/.ruflo/credit-status.json`.
5
+ *
6
+ * This is NOT the ADR-303 credit-error classifier — that lives in
7
+ * `credit-errors.ts` and reads provider error codes to decide when a
8
+ * credit surface fires *during* a command. This module is the OUT-OF-BAND
9
+ * signal path: the analytics transport detected a credit-exhausted
10
+ * response (HTTP 402 or ADR-303 machine-readable code), and we need to
11
+ * warn the user asynchronously.
12
+ *
13
+ * State is cheap and durable:
14
+ * ~/.ruflo/credit-status.json = { exhausted: bool, since: ISO, cleared: ISO|null }
15
+ *
16
+ * Cleared automatically when the user opens the enrollment / signup
17
+ * surface, or explicitly via `ruflo funnel credit-clear`.
18
+ */
19
+ import { readStateJson, writeStateJson } from './state.js';
20
+ export const CREDIT_STATUS_FILE = 'credit-status.json';
21
+ /** Read the current credit status. Never throws. */
22
+ export function readCreditStatus() {
23
+ const raw = readStateJson(CREDIT_STATUS_FILE);
24
+ return {
25
+ exhausted: raw?.exhausted ?? false,
26
+ since: raw?.since ?? null,
27
+ cleared: raw?.cleared ?? null,
28
+ };
29
+ }
30
+ /**
31
+ * Mark credit as exhausted — idempotent. Sets `since` on the first mark,
32
+ * leaves it alone on subsequent marks so the user sees a stable "since"
33
+ * timestamp until they clear it.
34
+ */
35
+ export function markCreditExhausted(now = new Date()) {
36
+ const current = readCreditStatus();
37
+ if (current.exhausted && current.since)
38
+ return; // already flagged
39
+ writeStateJson(CREDIT_STATUS_FILE, {
40
+ exhausted: true,
41
+ since: current.since ?? now.toISOString(),
42
+ cleared: null,
43
+ });
44
+ }
45
+ /**
46
+ * Clear credit-exhaustion status. Called when the user completes signup or
47
+ * runs `ruflo funnel credit-clear`. `cleared` is stamped so the previous
48
+ * `since` remains inspectable for one recovery cycle.
49
+ */
50
+ export function clearCreditStatus(now = new Date()) {
51
+ const current = readCreditStatus();
52
+ writeStateJson(CREDIT_STATUS_FILE, {
53
+ exhausted: false,
54
+ since: current.since,
55
+ cleared: now.toISOString(),
56
+ });
57
+ }
58
+ /**
59
+ * User-facing single-line summary — plain text, no ANSI. Callers style it
60
+ * themselves. Returns null when credit isn't exhausted (no surface).
61
+ */
62
+ export function creditExhaustedNotice(now = new Date()) {
63
+ const status = readCreditStatus();
64
+ if (!status.exhausted)
65
+ return null;
66
+ const since = status.since ? Date.parse(status.since) : NaN;
67
+ if (Number.isNaN(since)) {
68
+ return 'Cognitum credits exhausted · run: ruflo funnel signup';
69
+ }
70
+ const ageHours = Math.max(0, Math.round((now.getTime() - since) / (60 * 60 * 1000)));
71
+ const when = ageHours < 1 ? 'just now' : ageHours < 24 ? `${ageHours}h ago` : `${Math.round(ageHours / 24)}d ago`;
72
+ return `Cognitum credits exhausted (${when}) · run: ruflo funnel signup`;
73
+ }
74
+ //# sourceMappingURL=credit-notifier.js.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Existing-install disclosure gate — ADR-301, amended by ADR-311 to source
3
+ * the disclosure MESSAGE itself from the remote feed rather than hardcoding
4
+ * it in the CLI. Everything about WHETHER/WHEN to show a disclosure stays
5
+ * local (state machine below); everything about WHAT it says comes from
6
+ * the same remote pool as tips/promos, validated through the identical
7
+ * ADR-301 content pipeline (isValidMessage in messages.ts).
8
+ *
9
+ * Invariants (release-blocking, tested):
10
+ * - No promotional content before disclosure.
11
+ * - The manage instruction appears in the disclosure text itself.
12
+ * - Shown once per user (user-level receipt), not once per project.
13
+ * - Declining disables all funnel surfaces (enforced in precedence.ts).
14
+ * - Fail-closed: if the remote feed has never successfully populated a
15
+ * disclosure-class message, there is nothing to show — no local
16
+ * fallback text exists (ADR-311 "zero local promo content").
17
+ *
18
+ * The disclosure text stays on the promo row for a grace window after its
19
+ * first render so a single flash can't count as "the user was told"; only
20
+ * after the window do promotional messages become eligible.
21
+ */
22
+ import type { DisclosureRecord, FunnelMessage } from './types.js';
23
+ /** How long the disclosure text keeps the row before promo becomes eligible. */
24
+ export declare const DISCLOSURE_GRACE_MS: number;
25
+ export declare const DISCLOSURE_ROTATION_SLOT_MS: number;
26
+ /**
27
+ * Deterministic slot-based selection over the remote disclosure pool — no
28
+ * RNG so the choice is reproducible for a given wall-clock instant. Returns
29
+ * null when the pool is empty (cold start before first fetch, or the remote
30
+ * feed is unreachable) — the caller must treat null as "show nothing".
31
+ */
32
+ export declare function selectDisclosureMessage(now?: Date): FunnelMessage | null;
33
+ export declare function getDisclosure(): DisclosureRecord;
34
+ /** Record that the disclosure text was rendered (idempotent). */
35
+ export declare function recordDisclosureShown(now?: Date): DisclosureRecord;
36
+ /** User explicitly declined (e.g. `ruflo funnel disable`). */
37
+ export declare function recordDisclosureDeclined(now?: Date): DisclosureRecord;
38
+ /** Re-enable after a prior decline (explicit user action only). */
39
+ export declare function recordDisclosureReenabled(now?: Date): DisclosureRecord;
40
+ /**
41
+ * Whether promotional/educational messages may render. True only after the
42
+ * disclosure was shown AND its grace window has elapsed. While the window is
43
+ * open the row must carry the disclosure text itself.
44
+ */
45
+ export declare function promoEligible(now?: Date): boolean;
46
+ //# sourceMappingURL=disclosure.d.ts.map
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Existing-install disclosure gate — ADR-301, amended by ADR-311 to source
3
+ * the disclosure MESSAGE itself from the remote feed rather than hardcoding
4
+ * it in the CLI. Everything about WHETHER/WHEN to show a disclosure stays
5
+ * local (state machine below); everything about WHAT it says comes from
6
+ * the same remote pool as tips/promos, validated through the identical
7
+ * ADR-301 content pipeline (isValidMessage in messages.ts).
8
+ *
9
+ * Invariants (release-blocking, tested):
10
+ * - No promotional content before disclosure.
11
+ * - The manage instruction appears in the disclosure text itself.
12
+ * - Shown once per user (user-level receipt), not once per project.
13
+ * - Declining disables all funnel surfaces (enforced in precedence.ts).
14
+ * - Fail-closed: if the remote feed has never successfully populated a
15
+ * disclosure-class message, there is nothing to show — no local
16
+ * fallback text exists (ADR-311 "zero local promo content").
17
+ *
18
+ * The disclosure text stays on the promo row for a grace window after its
19
+ * first render so a single flash can't count as "the user was told"; only
20
+ * after the window do promotional messages become eligible.
21
+ */
22
+ import { readStateJson, writeStateJson } from './state.js';
23
+ import { getRemoteMessages } from './message-transport.js';
24
+ const DISCLOSURE_FILE = 'funnel-disclosure.json';
25
+ /** How long the disclosure text keeps the row before promo becomes eligible. */
26
+ export const DISCLOSURE_GRACE_MS = 24 * 60 * 60 * 1000; // 24h
27
+ // One disclosure variant per 5-minute wall-clock slot. Longer than the
28
+ // 20-second rotation cadence so a user watching the statusline sees the
29
+ // same variant long enough to read it, but short enough that a fresh
30
+ // session gets a different one than the previous one did.
31
+ export const DISCLOSURE_ROTATION_SLOT_MS = 5 * 60 * 1000;
32
+ /** Remote-cached messages tagged class==='disclosure' — the only source. */
33
+ function getDisclosureMessagePool() {
34
+ return getRemoteMessages().filter((m) => m.class === 'disclosure');
35
+ }
36
+ /**
37
+ * Deterministic slot-based selection over the remote disclosure pool — no
38
+ * RNG so the choice is reproducible for a given wall-clock instant. Returns
39
+ * null when the pool is empty (cold start before first fetch, or the remote
40
+ * feed is unreachable) — the caller must treat null as "show nothing".
41
+ */
42
+ export function selectDisclosureMessage(now = new Date()) {
43
+ const pool = getDisclosureMessagePool();
44
+ if (pool.length === 0)
45
+ return null;
46
+ const slot = Math.floor(now.getTime() / DISCLOSURE_ROTATION_SLOT_MS);
47
+ return pool[slot % pool.length];
48
+ }
49
+ export function getDisclosure() {
50
+ const rec = readStateJson(DISCLOSURE_FILE);
51
+ if (rec && isValidState(rec.state))
52
+ return rec;
53
+ return { state: 'never_seen', firstShownAt: null };
54
+ }
55
+ function isValidState(s) {
56
+ return s === 'never_seen' || s === 'disclosed_enabled' || s === 'disclosed_disabled';
57
+ }
58
+ /** Record that the disclosure text was rendered (idempotent). */
59
+ export function recordDisclosureShown(now = new Date()) {
60
+ const current = getDisclosure();
61
+ if (current.state !== 'never_seen')
62
+ return current;
63
+ const rec = { state: 'disclosed_enabled', firstShownAt: now.toISOString() };
64
+ writeStateJson(DISCLOSURE_FILE, rec);
65
+ return rec;
66
+ }
67
+ /** User explicitly declined (e.g. `ruflo funnel disable`). */
68
+ export function recordDisclosureDeclined(now = new Date()) {
69
+ const current = getDisclosure();
70
+ const rec = {
71
+ state: 'disclosed_disabled',
72
+ firstShownAt: current.firstShownAt ?? now.toISOString(),
73
+ };
74
+ writeStateJson(DISCLOSURE_FILE, rec);
75
+ return rec;
76
+ }
77
+ /** Re-enable after a prior decline (explicit user action only). */
78
+ export function recordDisclosureReenabled(now = new Date()) {
79
+ const rec = { state: 'disclosed_enabled', firstShownAt: now.toISOString() };
80
+ writeStateJson(DISCLOSURE_FILE, rec);
81
+ return rec;
82
+ }
83
+ /**
84
+ * Whether promotional/educational messages may render. True only after the
85
+ * disclosure was shown AND its grace window has elapsed. While the window is
86
+ * open the row must carry the disclosure text itself.
87
+ */
88
+ export function promoEligible(now = new Date()) {
89
+ const rec = getDisclosure();
90
+ if (rec.state !== 'disclosed_enabled' || !rec.firstShownAt)
91
+ return false;
92
+ const first = Date.parse(rec.firstShownAt);
93
+ if (Number.isNaN(first))
94
+ return false;
95
+ return now.getTime() - first >= DISCLOSURE_GRACE_MS;
96
+ }
97
+ //# sourceMappingURL=disclosure.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Post-initialization capability enrollment — ADR-302.
3
+ *
4
+ * One-time, non-blocking, skippable. Gates, all of which must pass:
5
+ * - interactive TTY (never in CI / piped / automation)
6
+ * - not skipped via --no-signup
7
+ * - funnel enabled under the ADR-305 precedence chain
8
+ * - never shown before (user-level record, not per-project)
9
+ *
10
+ * Accepting authorizes exactly ONE thing: a pointer to `ruflo auth login`.
11
+ * It does not install the proxy, does not enable telemetry, and does not
12
+ * enable cloud routing (separate consent domains — ADR-302). The enrollment
13
+ * outcome never affects init's exit code.
14
+ */
15
+ interface EnrollmentRecord {
16
+ shownAt: string;
17
+ outcome: 'accepted' | 'skipped';
18
+ }
19
+ export declare function getEnrollmentRecord(): EnrollmentRecord | null;
20
+ export declare const ENROLLMENT_SCREEN: string;
21
+ export declare const ENROLLMENT_SKIP_TEXT = "You can enable later:\n ruflo auth login";
22
+ export interface EnrollmentGateContext {
23
+ noSignup: boolean;
24
+ cwd?: string;
25
+ env?: NodeJS.ProcessEnv;
26
+ }
27
+ /** All ADR-302 gates. Pure check — does not write state. */
28
+ export declare function shouldOfferEnrollment(ctx: EnrollmentGateContext): boolean;
29
+ /**
30
+ * Record the user's decision. Both accept and skip are terminal — the
31
+ * prompt never reappears (ADR-302). Accepting records the `account`
32
+ * consent receipt; skipping records the decline.
33
+ */
34
+ export declare function recordEnrollmentOutcome(accepted: boolean, now?: Date): void;
35
+ export {};
36
+ //# sourceMappingURL=enrollment.d.ts.map
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Post-initialization capability enrollment — ADR-302.
3
+ *
4
+ * One-time, non-blocking, skippable. Gates, all of which must pass:
5
+ * - interactive TTY (never in CI / piped / automation)
6
+ * - not skipped via --no-signup
7
+ * - funnel enabled under the ADR-305 precedence chain
8
+ * - never shown before (user-level record, not per-project)
9
+ *
10
+ * Accepting authorizes exactly ONE thing: a pointer to `ruflo auth login`.
11
+ * It does not install the proxy, does not enable telemetry, and does not
12
+ * enable cloud routing (separate consent domains — ADR-302). The enrollment
13
+ * outcome never affects init's exit code.
14
+ */
15
+ import { isCI, isInteractive } from './environment.js';
16
+ import { resolveFunnelEnabled } from './precedence.js';
17
+ import { recordConsent } from './consent.js';
18
+ import { readStateJson, writeStateJson } from './state.js';
19
+ const ENROLLMENT_FILE = 'enrollment.json';
20
+ export function getEnrollmentRecord() {
21
+ return readStateJson(ENROLLMENT_FILE);
22
+ }
23
+ export const ENROLLMENT_SCREEN = [
24
+ '────────────────────────────',
25
+ 'Unlock additional capabilities?',
26
+ '',
27
+ ' ✓ Local Meta LLM Proxy',
28
+ ' ✓ Multi-model routing',
29
+ ' ✓ Hosted memory',
30
+ ' ✓ Enterprise rate limits',
31
+ ' ✓ Premium agents',
32
+ ' ✓ Cloud synchronization',
33
+ '',
34
+ 'Free account: https://cognitum.one',
35
+ ].join('\n');
36
+ export const ENROLLMENT_SKIP_TEXT = 'You can enable later:\n ruflo auth login';
37
+ /** All ADR-302 gates. Pure check — does not write state. */
38
+ export function shouldOfferEnrollment(ctx) {
39
+ const env = ctx.env ?? process.env;
40
+ if (ctx.noSignup)
41
+ return false;
42
+ if (isCI(env))
43
+ return false;
44
+ if (!isInteractive())
45
+ return false;
46
+ if (!resolveFunnelEnabled(ctx.cwd ?? process.cwd(), env).enabled)
47
+ return false;
48
+ if (getEnrollmentRecord() !== null)
49
+ return false; // one-time only
50
+ return true;
51
+ }
52
+ /**
53
+ * Record the user's decision. Both accept and skip are terminal — the
54
+ * prompt never reappears (ADR-302). Accepting records the `account`
55
+ * consent receipt; skipping records the decline.
56
+ */
57
+ export function recordEnrollmentOutcome(accepted, now = new Date()) {
58
+ writeStateJson(ENROLLMENT_FILE, {
59
+ shownAt: now.toISOString(),
60
+ outcome: accepted ? 'accepted' : 'skipped',
61
+ });
62
+ recordConsent('account', accepted, 'post-init', now);
63
+ }
64
+ //# sourceMappingURL=enrollment.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Environment gates for funnel surfaces (ADR-301/302).
3
+ *
4
+ * CI and non-interactive environments never see funnel content; reduced
5
+ * motion / screen readers get static text only (which is all the funnel
6
+ * renders anyway — there is deliberately no animation path in this module).
7
+ */
8
+ export declare function isCI(env?: NodeJS.ProcessEnv): boolean;
9
+ export declare function isInteractive(): boolean;
10
+ /**
11
+ * Statusline invocations are spawned by an interactive host (Claude Code)
12
+ * with piped stdio, so isTTY is false there even though the session is
13
+ * interactive. Surfaces pass their own interactivity signal; this helper is
14
+ * the strict check used by directly-invoked prompts (init enrollment).
15
+ */
16
+ export declare function reducedMotion(env?: NodeJS.ProcessEnv): boolean;
17
+ //# sourceMappingURL=environment.d.ts.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Environment gates for funnel surfaces (ADR-301/302).
3
+ *
4
+ * CI and non-interactive environments never see funnel content; reduced
5
+ * motion / screen readers get static text only (which is all the funnel
6
+ * renders anyway — there is deliberately no animation path in this module).
7
+ */
8
+ const CI_ENV_VARS = [
9
+ 'CI',
10
+ 'GITHUB_ACTIONS',
11
+ 'GITLAB_CI',
12
+ 'CIRCLECI',
13
+ 'TRAVIS',
14
+ 'BUILDKITE',
15
+ 'JENKINS_URL',
16
+ 'TEAMCITY_VERSION',
17
+ 'TF_BUILD', // Azure Pipelines
18
+ ];
19
+ export function isCI(env = process.env) {
20
+ return CI_ENV_VARS.some((v) => {
21
+ const val = env[v];
22
+ return val !== undefined && val !== '' && val !== '0' && val.toLowerCase?.() !== 'false';
23
+ });
24
+ }
25
+ export function isInteractive() {
26
+ return Boolean(process.stdout.isTTY && process.stdin.isTTY);
27
+ }
28
+ /**
29
+ * Statusline invocations are spawned by an interactive host (Claude Code)
30
+ * with piped stdio, so isTTY is false there even though the session is
31
+ * interactive. Surfaces pass their own interactivity signal; this helper is
32
+ * the strict check used by directly-invoked prompts (init enrollment).
33
+ */
34
+ export function reducedMotion(env = process.env) {
35
+ return Boolean(env.NO_COLOR !== undefined ||
36
+ env.RUFLO_REDUCED_MOTION === '1' ||
37
+ env.TERM === 'dumb');
38
+ }
39
+ //# sourceMappingURL=environment.js.map
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Event transport — batches the local funnel event queue and posts it to the
3
+ * Cognitum analytics Cloud Function (ADR-308 endpoint contract).
4
+ *
5
+ * Design discipline (ADR-308 client failure policy — all normative):
6
+ * 1. Telemetry never blocks the CLI. Every network call is best-effort,
7
+ * capped by a short timeout, and swallows every error path.
8
+ * 2. Events are LOCAL FIRST. The queue in `events.ts` accumulates
9
+ * regardless of API reachability. This transport is the flush layer.
10
+ * 3. Idempotency: every batch carries a UUIDv4 idempotency key so a retry
11
+ * never double-counts (ADR-308 idempotent-batches invariant).
12
+ * 4. Exponential backoff on transient failures. Successful flushes stamp
13
+ * a "last flush" timestamp so we don't hammer the API each render.
14
+ * 5. Consent-gated. Zero network activity when telemetry consent is off.
15
+ * 6. Bounded. Never send more than MAX_BATCH events at once, so a large
16
+ * backlog doesn't blow the endpoint request-size limit.
17
+ * 7. Credit-exhaustion detection. If the endpoint replies 402 (Payment
18
+ * Required) or the body carries the ADR-303
19
+ * `COGNITUM_CREDIT_EXHAUSTED` code, we surface via `credit-notifier.ts`
20
+ * — the same recovery UX ADR-303 already ships.
21
+ */
22
+ /**
23
+ * Default endpoint — the ruflo-funnel-analytics endpoint on the ruv.io
24
+ * domain, mapped via Cloud Run domain mapping to the cognitum-analytics
25
+ * Cloud Function on cognitum-20260110. Overridable by env for staging or
26
+ * self-hosted deploys. The domain choice is deliberate: an rUv-authored
27
+ * OSS project's telemetry endpoint belongs on rUv's own domain, not on
28
+ * cognitum.one — that keeps the CLI attribution honest.
29
+ */
30
+ export declare const DEFAULT_ENDPOINT: string;
31
+ /** Cap per POST — server enforces its own limits too; this is a safety net. */
32
+ export declare const MAX_BATCH = 100;
33
+ /** Min interval between flushes (ms). Rate limits the client from within. */
34
+ export declare const MIN_FLUSH_INTERVAL_MS = 60000;
35
+ /** POST timeout — telemetry must not stall the CLI. */
36
+ export declare const FLUSH_TIMEOUT_MS = 4000;
37
+ /**
38
+ * Best-effort flush of the local event queue to the endpoint. Returns a
39
+ * summary the CLI can log at --verbose; the caller should never fail on it.
40
+ */
41
+ export declare function flushEvents(opts?: {
42
+ endpoint?: string;
43
+ release?: string;
44
+ force?: boolean;
45
+ now?: Date;
46
+ }): Promise<{
47
+ flushed: number;
48
+ skipped: string | null;
49
+ status?: number;
50
+ }>;
51
+ //# sourceMappingURL=event-transport.d.ts.map
@@ -0,0 +1,199 @@
1
+ /**
2
+ * Event transport — batches the local funnel event queue and posts it to the
3
+ * Cognitum analytics Cloud Function (ADR-308 endpoint contract).
4
+ *
5
+ * Design discipline (ADR-308 client failure policy — all normative):
6
+ * 1. Telemetry never blocks the CLI. Every network call is best-effort,
7
+ * capped by a short timeout, and swallows every error path.
8
+ * 2. Events are LOCAL FIRST. The queue in `events.ts` accumulates
9
+ * regardless of API reachability. This transport is the flush layer.
10
+ * 3. Idempotency: every batch carries a UUIDv4 idempotency key so a retry
11
+ * never double-counts (ADR-308 idempotent-batches invariant).
12
+ * 4. Exponential backoff on transient failures. Successful flushes stamp
13
+ * a "last flush" timestamp so we don't hammer the API each render.
14
+ * 5. Consent-gated. Zero network activity when telemetry consent is off.
15
+ * 6. Bounded. Never send more than MAX_BATCH events at once, so a large
16
+ * backlog doesn't blow the endpoint request-size limit.
17
+ * 7. Credit-exhaustion detection. If the endpoint replies 402 (Payment
18
+ * Required) or the body carries the ADR-303
19
+ * `COGNITUM_CREDIT_EXHAUSTED` code, we surface via `credit-notifier.ts`
20
+ * — the same recovery UX ADR-303 already ships.
21
+ */
22
+ import * as fs from 'fs';
23
+ import * as https from 'https';
24
+ import { URL as NodeUrl } from 'url';
25
+ import { randomUUID } from 'crypto';
26
+ import { hasConsent } from './consent.js';
27
+ import { readStateJson, statePath, writeStateJson } from './state.js';
28
+ import { markCreditExhausted } from './credit-notifier.js';
29
+ const EVENTS_FILE = 'funnel-events.jsonl';
30
+ const FLUSH_STATE_FILE = 'funnel-events-flush.json';
31
+ /**
32
+ * Default endpoint — the ruflo-funnel-analytics endpoint on the ruv.io
33
+ * domain, mapped via Cloud Run domain mapping to the cognitum-analytics
34
+ * Cloud Function on cognitum-20260110. Overridable by env for staging or
35
+ * self-hosted deploys. The domain choice is deliberate: an rUv-authored
36
+ * OSS project's telemetry endpoint belongs on rUv's own domain, not on
37
+ * cognitum.one — that keeps the CLI attribution honest.
38
+ */
39
+ export const DEFAULT_ENDPOINT = process.env.RUFLO_FUNNEL_EVENTS_ENDPOINT ?? 'https://funnel.ruv.io/v1/events';
40
+ /** Cap per POST — server enforces its own limits too; this is a safety net. */
41
+ export const MAX_BATCH = 100;
42
+ /** Min interval between flushes (ms). Rate limits the client from within. */
43
+ export const MIN_FLUSH_INTERVAL_MS = 60_000; // 1 min
44
+ /** POST timeout — telemetry must not stall the CLI. */
45
+ export const FLUSH_TIMEOUT_MS = 4_000;
46
+ /** Read the current flush bookkeeping state (never throws). */
47
+ function readFlushState() {
48
+ const raw = readStateJson(FLUSH_STATE_FILE);
49
+ return {
50
+ lastFlushAt: raw?.lastFlushAt ?? null,
51
+ consecutiveFailures: raw?.consecutiveFailures ?? 0,
52
+ lastError: raw?.lastError,
53
+ };
54
+ }
55
+ /** Persist flush bookkeeping. Never throws. */
56
+ function writeFlushState(state) {
57
+ writeStateJson(FLUSH_STATE_FILE, state);
58
+ }
59
+ /** Read the local event queue as JSON lines. Returns [] when absent. */
60
+ function readQueue() {
61
+ try {
62
+ const raw = fs.readFileSync(statePath(EVENTS_FILE), 'utf-8');
63
+ return raw
64
+ .split('\n')
65
+ .filter(Boolean)
66
+ .map((line) => {
67
+ try {
68
+ return JSON.parse(line);
69
+ }
70
+ catch {
71
+ return null;
72
+ }
73
+ })
74
+ .filter((x) => x !== null);
75
+ }
76
+ catch {
77
+ return [];
78
+ }
79
+ }
80
+ /** Overwrite the local queue with the survivors (events we didn't flush). */
81
+ function writeQueue(events) {
82
+ try {
83
+ const body = events.length === 0 ? '' : events.map((e) => JSON.stringify(e)).join('\n') + '\n';
84
+ fs.writeFileSync(statePath(EVENTS_FILE), body, { encoding: 'utf-8', mode: 0o600 });
85
+ }
86
+ catch {
87
+ /* telemetry must never block */
88
+ }
89
+ }
90
+ /** Exponential backoff — cap at 30 minutes. */
91
+ function backoffElapsed(state, now) {
92
+ if (!state.lastFlushAt)
93
+ return true;
94
+ const last = Date.parse(state.lastFlushAt);
95
+ if (Number.isNaN(last))
96
+ return true;
97
+ const base = MIN_FLUSH_INTERVAL_MS;
98
+ const factor = Math.min(2 ** state.consecutiveFailures, 30); // cap at 30x → ~30 min
99
+ const nextAllowed = last + base * factor;
100
+ return now.getTime() >= nextAllowed;
101
+ }
102
+ /**
103
+ * POST a batch to the endpoint. Resolves to { ok, status } — never rejects.
104
+ * Kept internal so callers can't hand it a URL that dodges the allowlist.
105
+ */
106
+ function postBatch(endpoint, batch) {
107
+ return new Promise((resolve) => {
108
+ let target;
109
+ try {
110
+ target = new NodeUrl(endpoint);
111
+ }
112
+ catch {
113
+ resolve({ ok: false, status: 0, body: 'bad-endpoint' });
114
+ return;
115
+ }
116
+ if (target.protocol !== 'https:') {
117
+ resolve({ ok: false, status: 0, body: 'non-https-endpoint' });
118
+ return;
119
+ }
120
+ const body = JSON.stringify(batch);
121
+ const req = https.request({
122
+ hostname: target.hostname,
123
+ port: target.port || 443,
124
+ path: target.pathname + target.search,
125
+ method: 'POST',
126
+ headers: {
127
+ 'Content-Type': 'application/json',
128
+ 'Content-Length': Buffer.byteLength(body),
129
+ 'Idempotency-Key': batch.batchId,
130
+ 'User-Agent': `ruflo-funnel/${batch.release}`,
131
+ },
132
+ }, (res) => {
133
+ let chunks = '';
134
+ res.setEncoding('utf-8');
135
+ res.on('data', (chunk) => { chunks += chunk; });
136
+ res.on('end', () => {
137
+ const status = res.statusCode ?? 0;
138
+ resolve({ ok: status >= 200 && status < 300, status, body: chunks });
139
+ });
140
+ });
141
+ req.setTimeout(FLUSH_TIMEOUT_MS, () => {
142
+ req.destroy();
143
+ resolve({ ok: false, status: 0, body: 'timeout' });
144
+ });
145
+ req.on('error', (err) => resolve({ ok: false, status: 0, body: String(err) }));
146
+ req.write(body);
147
+ req.end();
148
+ });
149
+ }
150
+ /**
151
+ * Best-effort flush of the local event queue to the endpoint. Returns a
152
+ * summary the CLI can log at --verbose; the caller should never fail on it.
153
+ */
154
+ export async function flushEvents(opts) {
155
+ const now = opts?.now ?? new Date();
156
+ const endpoint = opts?.endpoint ?? DEFAULT_ENDPOINT;
157
+ if (!hasConsent('telemetry'))
158
+ return { flushed: 0, skipped: 'no-consent' };
159
+ const state = readFlushState();
160
+ if (!opts?.force && !backoffElapsed(state, now)) {
161
+ return { flushed: 0, skipped: 'backoff' };
162
+ }
163
+ const queue = readQueue();
164
+ if (queue.length === 0) {
165
+ // Nothing to send — record the check anyway so we don't retry every render.
166
+ writeFlushState({ ...state, lastFlushAt: now.toISOString() });
167
+ return { flushed: 0, skipped: 'empty-queue' };
168
+ }
169
+ const batchEvents = queue.slice(0, MAX_BATCH);
170
+ const batch = {
171
+ batchId: randomUUID(),
172
+ events: batchEvents,
173
+ release: opts?.release ?? 'unknown',
174
+ emittedAt: now.toISOString(),
175
+ };
176
+ const res = await postBatch(endpoint, batch);
177
+ // Credit-exhaustion detection (ADR-303 route in).
178
+ // 402 Payment Required → out of Cognitum credits.
179
+ // Body carrying the exact ADR-303 machine-readable code → same.
180
+ if (res.status === 402 || (typeof res.body === 'string' && res.body.includes('COGNITUM_CREDIT_EXHAUSTED'))) {
181
+ markCreditExhausted(now);
182
+ }
183
+ if (res.ok) {
184
+ // Drop the sent events; keep survivors.
185
+ writeQueue(queue.slice(batchEvents.length));
186
+ writeFlushState({
187
+ lastFlushAt: now.toISOString(),
188
+ consecutiveFailures: 0,
189
+ });
190
+ return { flushed: batchEvents.length, skipped: null, status: res.status };
191
+ }
192
+ writeFlushState({
193
+ lastFlushAt: now.toISOString(),
194
+ consecutiveFailures: state.consecutiveFailures + 1,
195
+ lastError: `HTTP ${res.status}`,
196
+ });
197
+ return { flushed: 0, skipped: `transport-failed`, status: res.status };
198
+ }
199
+ //# sourceMappingURL=event-transport.js.map