claude-flow 3.25.6 → 3.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.claude/helpers/hook-handler.cjs +129 -0
  2. package/.claude/helpers/intelligence.cjs +10 -0
  3. package/.claude/helpers/statusline.cjs +310 -123
  4. package/.claude/proven-config.json +1 -1
  5. package/.claude/security-scans/scan-all-standard.json +321 -0
  6. package/.claude/security-scans/scan-code-deep.json +1209 -0
  7. package/.claude/security-scans/scan-deps-full.json +14 -0
  8. package/package.json +3 -1
  9. package/v3/@claude-flow/cli/catalog-manifest.json +12 -0
  10. package/v3/@claude-flow/cli/dist/src/commands/advisor.d.ts +15 -0
  11. package/v3/@claude-flow/cli/dist/src/commands/advisor.js +94 -0
  12. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +77 -3
  13. package/v3/@claude-flow/cli/dist/src/commands/funnel.d.ts +13 -0
  14. package/v3/@claude-flow/cli/dist/src/commands/funnel.js +103 -0
  15. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +112 -46
  16. package/v3/@claude-flow/cli/dist/src/commands/index.js +10 -0
  17. package/v3/@claude-flow/cli/dist/src/commands/init.js +44 -0
  18. package/v3/@claude-flow/cli/dist/src/commands/proxy.d.ts +21 -0
  19. package/v3/@claude-flow/cli/dist/src/commands/proxy.js +310 -0
  20. package/v3/@claude-flow/cli/dist/src/commands/security.js +29 -0
  21. package/v3/@claude-flow/cli/dist/src/commands/settings.d.ts +19 -0
  22. package/v3/@claude-flow/cli/dist/src/commands/settings.js +180 -0
  23. package/v3/@claude-flow/cli/dist/src/commands/version.d.ts +42 -0
  24. package/v3/@claude-flow/cli/dist/src/commands/version.js +106 -0
  25. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.d.ts +58 -0
  26. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.js +92 -0
  27. package/v3/@claude-flow/cli/dist/src/funnel/attribution.d.ts +37 -0
  28. package/v3/@claude-flow/cli/dist/src/funnel/attribution.js +101 -0
  29. package/v3/@claude-flow/cli/dist/src/funnel/consent.d.ts +22 -0
  30. package/v3/@claude-flow/cli/dist/src/funnel/consent.js +55 -0
  31. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.d.ts +31 -0
  32. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.js +88 -0
  33. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.d.ts +44 -0
  34. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.js +74 -0
  35. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.d.ts +46 -0
  36. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.js +97 -0
  37. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.d.ts +36 -0
  38. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.js +64 -0
  39. package/v3/@claude-flow/cli/dist/src/funnel/environment.d.ts +17 -0
  40. package/v3/@claude-flow/cli/dist/src/funnel/environment.js +39 -0
  41. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.d.ts +51 -0
  42. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.js +199 -0
  43. package/v3/@claude-flow/cli/dist/src/funnel/events.d.ts +42 -0
  44. package/v3/@claude-flow/cli/dist/src/funnel/events.js +150 -0
  45. package/v3/@claude-flow/cli/dist/src/funnel/index.d.ts +20 -0
  46. package/v3/@claude-flow/cli/dist/src/funnel/index.js +20 -0
  47. package/v3/@claude-flow/cli/dist/src/funnel/insights.d.ts +49 -0
  48. package/v3/@claude-flow/cli/dist/src/funnel/insights.js +120 -0
  49. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.d.ts +15 -0
  50. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +68 -0
  51. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.d.ts +51 -0
  52. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.js +149 -0
  53. package/v3/@claude-flow/cli/dist/src/funnel/messages.d.ts +55 -0
  54. package/v3/@claude-flow/cli/dist/src/funnel/messages.js +160 -0
  55. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.d.ts +44 -0
  56. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.js +92 -0
  57. package/v3/@claude-flow/cli/dist/src/funnel/precedence.d.ts +16 -0
  58. package/v3/@claude-flow/cli/dist/src/funnel/precedence.js +85 -0
  59. package/v3/@claude-flow/cli/dist/src/funnel/promo.d.ts +41 -0
  60. package/v3/@claude-flow/cli/dist/src/funnel/promo.js +144 -0
  61. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.d.ts +55 -0
  62. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.js +102 -0
  63. package/v3/@claude-flow/cli/dist/src/funnel/rotation.d.ts +19 -0
  64. package/v3/@claude-flow/cli/dist/src/funnel/rotation.js +70 -0
  65. package/v3/@claude-flow/cli/dist/src/funnel/state.d.ts +13 -0
  66. package/v3/@claude-flow/cli/dist/src/funnel/state.js +52 -0
  67. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.d.ts +17 -0
  68. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.js +32 -0
  69. package/v3/@claude-flow/cli/dist/src/funnel/types.d.ts +86 -0
  70. package/v3/@claude-flow/cli/dist/src/funnel/types.js +26 -0
  71. package/v3/@claude-flow/cli/dist/src/init/executor.js +9 -3
  72. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.d.ts +33 -2
  73. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.js +102 -12
  74. package/v3/@claude-flow/cli/dist/src/init/helpers-generator.js +52 -0
  75. package/v3/@claude-flow/cli/dist/src/init/statusline-generator.js +292 -116
  76. package/v3/@claude-flow/cli/dist/src/services/daemon-autostart.js +28 -5
  77. package/v3/@claude-flow/cli/dist/src/services/fable-harness.d.ts +39 -0
  78. package/v3/@claude-flow/cli/dist/src/services/fable-harness.js +41 -0
  79. package/v3/@claude-flow/cli/package.json +13 -4
  80. package/.claude/coordinator/config.json +0 -24
  81. package/.claude/coordinator/state.json +0 -37
  82. package/.claude/coordinator/tick-log/tick-01.json +0 -17
  83. package/.claude/coordinator/tick-log/tick-02.json +0 -17
  84. package/.claude/coordinator/tick-log/tick-03.json +0 -17
  85. package/.claude/coordinator/tick-log/tick-04.json +0 -14
  86. package/.claude/coordinator/tick-log/tick-05.json +0 -16
  87. package/.claude/settings.local.json +0 -11
  88. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.d.ts +0 -14
  89. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.js +0 -144
  90. package/v3/@claude-flow/guidance/dist/adversarial.d.ts +0 -284
  91. package/v3/@claude-flow/guidance/dist/adversarial.js +0 -572
  92. package/v3/@claude-flow/guidance/dist/analyzer.d.ts +0 -530
  93. package/v3/@claude-flow/guidance/dist/analyzer.js +0 -2587
  94. package/v3/@claude-flow/guidance/dist/artifacts.d.ts +0 -283
  95. package/v3/@claude-flow/guidance/dist/artifacts.js +0 -356
  96. package/v3/@claude-flow/guidance/dist/authority.d.ts +0 -290
  97. package/v3/@claude-flow/guidance/dist/authority.js +0 -558
  98. package/v3/@claude-flow/guidance/dist/capabilities.d.ts +0 -209
  99. package/v3/@claude-flow/guidance/dist/capabilities.js +0 -485
  100. package/v3/@claude-flow/guidance/dist/coherence.d.ts +0 -233
  101. package/v3/@claude-flow/guidance/dist/coherence.js +0 -372
  102. package/v3/@claude-flow/guidance/dist/compiler.d.ts +0 -87
  103. package/v3/@claude-flow/guidance/dist/compiler.js +0 -410
  104. package/v3/@claude-flow/guidance/dist/conformance-kit.d.ts +0 -225
  105. package/v3/@claude-flow/guidance/dist/conformance-kit.js +0 -629
  106. package/v3/@claude-flow/guidance/dist/continue-gate.d.ts +0 -214
  107. package/v3/@claude-flow/guidance/dist/continue-gate.js +0 -353
  108. package/v3/@claude-flow/guidance/dist/crypto-utils.d.ts +0 -17
  109. package/v3/@claude-flow/guidance/dist/crypto-utils.js +0 -24
  110. package/v3/@claude-flow/guidance/dist/evolution.d.ts +0 -282
  111. package/v3/@claude-flow/guidance/dist/evolution.js +0 -500
  112. package/v3/@claude-flow/guidance/dist/gates.d.ts +0 -79
  113. package/v3/@claude-flow/guidance/dist/gates.js +0 -302
  114. package/v3/@claude-flow/guidance/dist/gateway.d.ts +0 -206
  115. package/v3/@claude-flow/guidance/dist/gateway.js +0 -452
  116. package/v3/@claude-flow/guidance/dist/generators.d.ts +0 -153
  117. package/v3/@claude-flow/guidance/dist/generators.js +0 -682
  118. package/v3/@claude-flow/guidance/dist/headless.d.ts +0 -177
  119. package/v3/@claude-flow/guidance/dist/headless.js +0 -342
  120. package/v3/@claude-flow/guidance/dist/hooks.d.ts +0 -109
  121. package/v3/@claude-flow/guidance/dist/hooks.js +0 -347
  122. package/v3/@claude-flow/guidance/dist/index.d.ts +0 -205
  123. package/v3/@claude-flow/guidance/dist/index.js +0 -321
  124. package/v3/@claude-flow/guidance/dist/ledger.d.ts +0 -162
  125. package/v3/@claude-flow/guidance/dist/ledger.js +0 -375
  126. package/v3/@claude-flow/guidance/dist/manifest-validator.d.ts +0 -289
  127. package/v3/@claude-flow/guidance/dist/manifest-validator.js +0 -838
  128. package/v3/@claude-flow/guidance/dist/memory-gate.d.ts +0 -222
  129. package/v3/@claude-flow/guidance/dist/memory-gate.js +0 -382
  130. package/v3/@claude-flow/guidance/dist/meta-governance.d.ts +0 -265
  131. package/v3/@claude-flow/guidance/dist/meta-governance.js +0 -348
  132. package/v3/@claude-flow/guidance/dist/optimizer.d.ts +0 -104
  133. package/v3/@claude-flow/guidance/dist/optimizer.js +0 -329
  134. package/v3/@claude-flow/guidance/dist/persistence.d.ts +0 -189
  135. package/v3/@claude-flow/guidance/dist/persistence.js +0 -464
  136. package/v3/@claude-flow/guidance/dist/proof.d.ts +0 -185
  137. package/v3/@claude-flow/guidance/dist/proof.js +0 -238
  138. package/v3/@claude-flow/guidance/dist/retriever.d.ts +0 -172
  139. package/v3/@claude-flow/guidance/dist/retriever.js +0 -596
  140. package/v3/@claude-flow/guidance/dist/ruvbot-integration.d.ts +0 -370
  141. package/v3/@claude-flow/guidance/dist/ruvbot-integration.js +0 -738
  142. package/v3/@claude-flow/guidance/dist/temporal.d.ts +0 -426
  143. package/v3/@claude-flow/guidance/dist/temporal.js +0 -658
  144. package/v3/@claude-flow/guidance/dist/trust.d.ts +0 -283
  145. package/v3/@claude-flow/guidance/dist/trust.js +0 -473
  146. package/v3/@claude-flow/guidance/dist/truth-anchors.d.ts +0 -276
  147. package/v3/@claude-flow/guidance/dist/truth-anchors.js +0 -488
  148. package/v3/@claude-flow/guidance/dist/types.d.ts +0 -378
  149. package/v3/@claude-flow/guidance/dist/types.js +0 -10
  150. package/v3/@claude-flow/guidance/dist/uncertainty.d.ts +0 -372
  151. package/v3/@claude-flow/guidance/dist/uncertainty.js +0 -619
  152. package/v3/@claude-flow/guidance/dist/wasm-kernel.d.ts +0 -48
  153. package/v3/@claude-flow/guidance/dist/wasm-kernel.js +0 -158
  154. package/v3/@claude-flow/shared/dist/core/config/defaults.d.ts +0 -41
  155. package/v3/@claude-flow/shared/dist/core/config/defaults.js +0 -186
  156. package/v3/@claude-flow/shared/dist/core/config/index.d.ts +0 -8
  157. package/v3/@claude-flow/shared/dist/core/config/index.js +0 -12
  158. package/v3/@claude-flow/shared/dist/core/config/loader.d.ts +0 -45
  159. package/v3/@claude-flow/shared/dist/core/config/loader.js +0 -238
  160. package/v3/@claude-flow/shared/dist/core/config/schema.d.ts +0 -1728
  161. package/v3/@claude-flow/shared/dist/core/config/schema.js +0 -160
  162. package/v3/@claude-flow/shared/dist/core/config/validator.d.ts +0 -92
  163. package/v3/@claude-flow/shared/dist/core/config/validator.js +0 -147
  164. package/v3/@claude-flow/shared/dist/core/event-bus.d.ts +0 -31
  165. package/v3/@claude-flow/shared/dist/core/event-bus.js +0 -197
  166. package/v3/@claude-flow/shared/dist/core/index.d.ts +0 -15
  167. package/v3/@claude-flow/shared/dist/core/index.js +0 -19
  168. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.d.ts +0 -200
  169. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.js +0 -6
  170. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.d.ts +0 -310
  171. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.js +0 -7
  172. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.d.ts +0 -224
  173. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.js +0 -46
  174. package/v3/@claude-flow/shared/dist/core/interfaces/index.d.ts +0 -10
  175. package/v3/@claude-flow/shared/dist/core/interfaces/index.js +0 -15
  176. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.d.ts +0 -298
  177. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.js +0 -7
  178. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.d.ts +0 -185
  179. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.js +0 -6
  180. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.d.ts +0 -35
  181. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.js +0 -101
  182. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.d.ts +0 -60
  183. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.js +0 -166
  184. package/v3/@claude-flow/shared/dist/core/orchestrator/index.d.ts +0 -46
  185. package/v3/@claude-flow/shared/dist/core/orchestrator/index.js +0 -64
  186. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.d.ts +0 -56
  187. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.js +0 -195
  188. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.d.ts +0 -83
  189. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.js +0 -193
  190. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.d.ts +0 -49
  191. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.js +0 -253
  192. package/v3/@claude-flow/shared/dist/events/domain-events.d.ts +0 -282
  193. package/v3/@claude-flow/shared/dist/events/domain-events.js +0 -165
  194. package/v3/@claude-flow/shared/dist/events/event-store.d.ts +0 -126
  195. package/v3/@claude-flow/shared/dist/events/event-store.js +0 -427
  196. package/v3/@claude-flow/shared/dist/events/event-store.test.d.ts +0 -8
  197. package/v3/@claude-flow/shared/dist/events/event-store.test.js +0 -293
  198. package/v3/@claude-flow/shared/dist/events/example-usage.d.ts +0 -10
  199. package/v3/@claude-flow/shared/dist/events/example-usage.js +0 -193
  200. package/v3/@claude-flow/shared/dist/events/index.d.ts +0 -21
  201. package/v3/@claude-flow/shared/dist/events/index.js +0 -22
  202. package/v3/@claude-flow/shared/dist/events/projections.d.ts +0 -177
  203. package/v3/@claude-flow/shared/dist/events/projections.js +0 -421
  204. package/v3/@claude-flow/shared/dist/events/rvf-event-log.d.ts +0 -82
  205. package/v3/@claude-flow/shared/dist/events/rvf-event-log.js +0 -340
  206. package/v3/@claude-flow/shared/dist/events/state-reconstructor.d.ts +0 -101
  207. package/v3/@claude-flow/shared/dist/events/state-reconstructor.js +0 -263
  208. package/v3/@claude-flow/shared/dist/events.d.ts +0 -80
  209. package/v3/@claude-flow/shared/dist/events.js +0 -249
  210. package/v3/@claude-flow/shared/dist/hooks/example-usage.d.ts +0 -42
  211. package/v3/@claude-flow/shared/dist/hooks/example-usage.js +0 -351
  212. package/v3/@claude-flow/shared/dist/hooks/executor.d.ts +0 -100
  213. package/v3/@claude-flow/shared/dist/hooks/executor.js +0 -267
  214. package/v3/@claude-flow/shared/dist/hooks/hooks.test.d.ts +0 -9
  215. package/v3/@claude-flow/shared/dist/hooks/hooks.test.js +0 -322
  216. package/v3/@claude-flow/shared/dist/hooks/index.d.ts +0 -52
  217. package/v3/@claude-flow/shared/dist/hooks/index.js +0 -51
  218. package/v3/@claude-flow/shared/dist/hooks/registry.d.ts +0 -133
  219. package/v3/@claude-flow/shared/dist/hooks/registry.js +0 -277
  220. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.d.ts +0 -105
  221. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.js +0 -481
  222. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.d.ts +0 -144
  223. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.js +0 -328
  224. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.d.ts +0 -158
  225. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.js +0 -450
  226. package/v3/@claude-flow/shared/dist/hooks/safety/index.d.ts +0 -17
  227. package/v3/@claude-flow/shared/dist/hooks/safety/index.js +0 -17
  228. package/v3/@claude-flow/shared/dist/hooks/session-hooks.d.ts +0 -234
  229. package/v3/@claude-flow/shared/dist/hooks/session-hooks.js +0 -334
  230. package/v3/@claude-flow/shared/dist/hooks/task-hooks.d.ts +0 -163
  231. package/v3/@claude-flow/shared/dist/hooks/task-hooks.js +0 -326
  232. package/v3/@claude-flow/shared/dist/hooks/types.d.ts +0 -267
  233. package/v3/@claude-flow/shared/dist/hooks/types.js +0 -62
  234. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.d.ts +0 -9
  235. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.js +0 -93
  236. package/v3/@claude-flow/shared/dist/index.d.ts +0 -20
  237. package/v3/@claude-flow/shared/dist/index.js +0 -50
  238. package/v3/@claude-flow/shared/dist/mcp/connection-pool.d.ts +0 -98
  239. package/v3/@claude-flow/shared/dist/mcp/connection-pool.js +0 -364
  240. package/v3/@claude-flow/shared/dist/mcp/index.d.ts +0 -69
  241. package/v3/@claude-flow/shared/dist/mcp/index.js +0 -84
  242. package/v3/@claude-flow/shared/dist/mcp/server.d.ts +0 -166
  243. package/v3/@claude-flow/shared/dist/mcp/server.js +0 -590
  244. package/v3/@claude-flow/shared/dist/mcp/session-manager.d.ts +0 -136
  245. package/v3/@claude-flow/shared/dist/mcp/session-manager.js +0 -335
  246. package/v3/@claude-flow/shared/dist/mcp/tool-registry.d.ts +0 -178
  247. package/v3/@claude-flow/shared/dist/mcp/tool-registry.js +0 -439
  248. package/v3/@claude-flow/shared/dist/mcp/transport/http.d.ts +0 -104
  249. package/v3/@claude-flow/shared/dist/mcp/transport/http.js +0 -476
  250. package/v3/@claude-flow/shared/dist/mcp/transport/index.d.ts +0 -102
  251. package/v3/@claude-flow/shared/dist/mcp/transport/index.js +0 -238
  252. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.d.ts +0 -104
  253. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.js +0 -263
  254. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +0 -133
  255. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.js +0 -396
  256. package/v3/@claude-flow/shared/dist/mcp/types.d.ts +0 -436
  257. package/v3/@claude-flow/shared/dist/mcp/types.js +0 -54
  258. package/v3/@claude-flow/shared/dist/plugin-interface.d.ts +0 -544
  259. package/v3/@claude-flow/shared/dist/plugin-interface.js +0 -23
  260. package/v3/@claude-flow/shared/dist/plugin-loader.d.ts +0 -139
  261. package/v3/@claude-flow/shared/dist/plugin-loader.js +0 -434
  262. package/v3/@claude-flow/shared/dist/plugin-registry.d.ts +0 -183
  263. package/v3/@claude-flow/shared/dist/plugin-registry.js +0 -457
  264. package/v3/@claude-flow/shared/dist/plugins/index.d.ts +0 -10
  265. package/v3/@claude-flow/shared/dist/plugins/index.js +0 -10
  266. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.d.ts +0 -106
  267. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.js +0 -241
  268. package/v3/@claude-flow/shared/dist/plugins/official/index.d.ts +0 -10
  269. package/v3/@claude-flow/shared/dist/plugins/official/index.js +0 -10
  270. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.d.ts +0 -121
  271. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.js +0 -355
  272. package/v3/@claude-flow/shared/dist/plugins/types.d.ts +0 -93
  273. package/v3/@claude-flow/shared/dist/plugins/types.js +0 -9
  274. package/v3/@claude-flow/shared/dist/resilience/bulkhead.d.ts +0 -105
  275. package/v3/@claude-flow/shared/dist/resilience/bulkhead.js +0 -206
  276. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.d.ts +0 -132
  277. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.js +0 -233
  278. package/v3/@claude-flow/shared/dist/resilience/index.d.ts +0 -19
  279. package/v3/@claude-flow/shared/dist/resilience/index.js +0 -19
  280. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.d.ts +0 -168
  281. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.js +0 -314
  282. package/v3/@claude-flow/shared/dist/resilience/retry.d.ts +0 -91
  283. package/v3/@claude-flow/shared/dist/resilience/retry.js +0 -159
  284. package/v3/@claude-flow/shared/dist/security/index.d.ts +0 -10
  285. package/v3/@claude-flow/shared/dist/security/index.js +0 -12
  286. package/v3/@claude-flow/shared/dist/security/input-validation.d.ts +0 -73
  287. package/v3/@claude-flow/shared/dist/security/input-validation.js +0 -201
  288. package/v3/@claude-flow/shared/dist/security/secure-random.d.ts +0 -92
  289. package/v3/@claude-flow/shared/dist/security/secure-random.js +0 -142
  290. package/v3/@claude-flow/shared/dist/services/index.d.ts +0 -7
  291. package/v3/@claude-flow/shared/dist/services/index.js +0 -7
  292. package/v3/@claude-flow/shared/dist/services/v3-progress.service.d.ts +0 -124
  293. package/v3/@claude-flow/shared/dist/services/v3-progress.service.js +0 -402
  294. package/v3/@claude-flow/shared/dist/types/agent.types.d.ts +0 -137
  295. package/v3/@claude-flow/shared/dist/types/agent.types.js +0 -6
  296. package/v3/@claude-flow/shared/dist/types/index.d.ts +0 -11
  297. package/v3/@claude-flow/shared/dist/types/index.js +0 -17
  298. package/v3/@claude-flow/shared/dist/types/mcp.types.d.ts +0 -266
  299. package/v3/@claude-flow/shared/dist/types/mcp.types.js +0 -7
  300. package/v3/@claude-flow/shared/dist/types/memory.types.d.ts +0 -236
  301. package/v3/@claude-flow/shared/dist/types/memory.types.js +0 -7
  302. package/v3/@claude-flow/shared/dist/types/swarm.types.d.ts +0 -186
  303. package/v3/@claude-flow/shared/dist/types/swarm.types.js +0 -65
  304. package/v3/@claude-flow/shared/dist/types/task.types.d.ts +0 -178
  305. package/v3/@claude-flow/shared/dist/types/task.types.js +0 -32
  306. package/v3/@claude-flow/shared/dist/types.d.ts +0 -197
  307. package/v3/@claude-flow/shared/dist/types.js +0 -21
  308. package/v3/@claude-flow/shared/dist/utils/secure-logger.d.ts +0 -69
  309. package/v3/@claude-flow/shared/dist/utils/secure-logger.js +0 -208
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Promo-row orchestrator — the single entry point the statusline hook calls
3
+ * (ADR-301). Applies, in order:
4
+ *
5
+ * 1. Control precedence (env / enterprise / user / project / remote) —
6
+ * any disable → nothing renders, ever.
7
+ * 2. Environment gates — CI never sees funnel content.
8
+ * 3. Disclosure gate — an upgraded install shows the disclosure text
9
+ * (with the disable instruction) before any message; promotional
10
+ * content only after the grace window.
11
+ * 4. ADR-313 sponsored-downtime override — preempts everything below
12
+ * while rate-limited (unconditional, not slot-based).
13
+ * 5. Local insight ticker (insights.ts) — a reserved 1-in-5 slot shows an
14
+ * environment/task-aware suggestion (CVEs, uncommitted changes,
15
+ * power-saver state) when one exists; otherwise falls through.
16
+ * 6. Rotation — 4:1 educational:promotional, 30-min promo repeat cap.
17
+ *
18
+ * Output is plain text (no ANSI — the renderer applies its own fixed
19
+ * style), ≤ 80 columns, already sanitized by the message pipeline.
20
+ */
21
+ import { resolveFunnelEnabled } from './precedence.js';
22
+ import { isCI } from './environment.js';
23
+ import { getDisclosure, promoEligible, recordDisclosureShown, selectDisclosureMessage, } from './disclosure.js';
24
+ import { clickTrackedUrl } from './attribution.js';
25
+ import { selectMessage, ROTATION_SLOT_MS } from './rotation.js';
26
+ import { recordFunnelEvent } from './events.js';
27
+ import { getInstalledCliVersion } from '../init/helper-refresh.js';
28
+ import { hasConsent } from './consent.js';
29
+ import { readRateLimitStatus } from './rate-limit-notifier.js';
30
+ import { selectLocalInsight } from './insights.js';
31
+ /**
32
+ * ADR-313 priority override: when the user has manually flagged a Claude
33
+ * usage limit (ADR-312 Phase 0), preempt normal rotation with a dedicated
34
+ * CTA — same precedent as ADR-303's credit-exhaustion recovery surface.
35
+ * Two states depending on whether sponsored-downtime consent is granted:
36
+ * - not yet enabled: an actionable CTA to enable it
37
+ * - already enabled: a quiet status line confirming it's active
38
+ * Both message strings use the exact " · manage: " anchor the renderer
39
+ * already splits on (statusline-generator.ts getPromoRow) — no renderer
40
+ * change needed; the command portion renders bold, never as a fake link.
41
+ * Returns null when the rate-limit flag isn't set (no override).
42
+ */
43
+ function getSponsoredDowntimeOverride(now) {
44
+ const status = readRateLimitStatus(now);
45
+ if (!status.limited)
46
+ return null;
47
+ if (hasConsent('sponsored-downtime')) {
48
+ return {
49
+ text: '⚡ Running on sponsored Cognitum capacity · manage: ruflo proxy sponsor-disable',
50
+ kind: 'promotional',
51
+ };
52
+ }
53
+ return {
54
+ text: '⚡ Free Cognitum capacity while you wait · manage: ruflo proxy sponsor-enable',
55
+ kind: 'promotional',
56
+ };
57
+ }
58
+ /** 1 in 5 slots, a different phase than rotation.ts's promo slot (slot%5==4)
59
+ * so the two never collide — reserved for a local insight IF one exists;
60
+ * otherwise falls through to the normal remote rotation untouched. This is
61
+ * the "ticker" cadence: insights appear periodically, never permanently
62
+ * take over the row, and never appear at all when nothing is actionable. */
63
+ const INSIGHT_SLOT_MODULO = 5;
64
+ const INSIGHT_SLOT_PHASE = 2;
65
+ function isInsightSlot(now) {
66
+ const slot = Math.floor(now.getTime() / ROTATION_SLOT_MS);
67
+ return slot % INSIGHT_SLOT_MODULO === INSIGHT_SLOT_PHASE;
68
+ }
69
+ export function getFunnelPromo(ctx) {
70
+ const env = ctx.env ?? process.env;
71
+ const now = ctx.now ?? new Date();
72
+ if (!ctx.interactive)
73
+ return null;
74
+ if (isCI(env))
75
+ return null;
76
+ const decision = resolveFunnelEnabled(ctx.cwd ?? process.cwd(), env);
77
+ if (!decision.enabled)
78
+ return null;
79
+ const release = getInstalledCliVersion();
80
+ // Disclosure gate: never a message before the disclosure has been shown
81
+ // and its grace window has passed. The disclosure MESSAGE itself is now
82
+ // remote-sourced (ADR-311) — selectDisclosureMessage() returns null when
83
+ // the remote pool hasn't populated yet (cold start / outage), and per the
84
+ // "zero local promo content" design, null means show nothing this cycle.
85
+ const disclosure = getDisclosure();
86
+ if (disclosure.state === 'never_seen') {
87
+ const msg = selectDisclosureMessage(now);
88
+ if (!msg)
89
+ return null; // fail-closed: no remote disclosure cached yet
90
+ recordDisclosureShown(now);
91
+ recordFunnelEvent('disclosure_shown', 'statusline', release, { now, messageId: msg.id });
92
+ const url = msg.url ? clickTrackedUrl(msg.id, msg.url, {
93
+ medium: 'statusline', campaign: 'disclosure', content: msg.id, now,
94
+ }) : undefined;
95
+ return { text: msg.text, kind: 'disclosure', url };
96
+ }
97
+ if (!promoEligible(now)) {
98
+ if (disclosure.state === 'disclosed_enabled') {
99
+ const msg = selectDisclosureMessage(now);
100
+ if (!msg)
101
+ return null; // fail-closed
102
+ const url = msg.url ? clickTrackedUrl(msg.id, msg.url, {
103
+ medium: 'statusline', campaign: 'disclosure', content: msg.id, now,
104
+ }) : undefined;
105
+ return { text: msg.text, kind: 'disclosure', url };
106
+ }
107
+ return null; // disclosed_disabled is caught by precedence, but stay fail-closed
108
+ }
109
+ // ADR-313 priority override: a self-reported usage-limit flag preempts
110
+ // normal rotation, exactly the way ADR-303's credit-exhaustion recovery
111
+ // is designed to preempt it. Only reachable here — i.e. only after the
112
+ // disclosure invariant (ADR-301 "no promotional content before
113
+ // disclosure") has already been satisfied above.
114
+ const override = getSponsoredDowntimeOverride(now);
115
+ if (override)
116
+ return override;
117
+ // Local insight ticker: on its reserved 1-in-5 slot, show the highest-
118
+ // priority environment/task insight if one exists — CVEs pending,
119
+ // uncommitted changes, power-saver active, etc. (insights.ts). No
120
+ // insight this render (or no context passed) → fall straight through to
121
+ // the untouched remote rotation below, same as any other slot.
122
+ if (ctx.localInsights && isInsightSlot(now)) {
123
+ const insight = selectLocalInsight(ctx.localInsights);
124
+ if (insight)
125
+ return { text: insight.text, kind: 'insight' };
126
+ }
127
+ const msg = selectMessage(now, release);
128
+ if (!msg)
129
+ return null;
130
+ // Any message carrying a URL (educational tips included) routes through
131
+ // the server click-redirect so `promo_open` + coarse geo are captured
132
+ // before 302ing to the real target — click counting is uniform across
133
+ // the whole rotation, not just the promotional slot. If the click
134
+ // endpoint chain rejects the URL for any reason, fall back to the
135
+ // UTM-decorated direct link so the click still lands where it should.
136
+ let url;
137
+ if (msg.url) {
138
+ url = clickTrackedUrl(msg.id, msg.url, {
139
+ medium: 'statusline', campaign: msg.class, content: msg.id, now,
140
+ });
141
+ }
142
+ return { text: msg.text, kind: msg.class, url };
143
+ }
144
+ //# sourceMappingURL=promo.js.map
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Rate-limit notifier — ADR-312 Phase 0 out-of-band signal path.
3
+ *
4
+ * Structural mirror of credit-notifier.ts. This is NOT automatic detection
5
+ * — ADR-312 established that Claude Code does not currently expose any way
6
+ * to detect its own usage-limit state from outside its process (verified
7
+ * against the actual installed CLI source, not assumed). This module is the
8
+ * MANUAL, self-reported alternative: the user tells ruflo they've hit a
9
+ * limit, ruflo remembers it, and the funnel promo row can react.
10
+ *
11
+ * State is cheap and durable:
12
+ * ~/.ruflo/rate-limit-status.json = { limited: bool, since: ISO, cleared: ISO|null }
13
+ *
14
+ * A TTL (default 6h) auto-expires a forgotten flag so a stale manual mark
15
+ * doesn't linger indefinitely if the user forgets to clear it — Claude
16
+ * usage limits reset on hours-to-days cadences (five_hour / seven_day per
17
+ * ADR-312's grounded research), so 6h is a reasonable "the user probably
18
+ * forgot to clear this" bound without requiring per-type precision we
19
+ * don't have.
20
+ */
21
+ export declare const RATE_LIMIT_STATUS_FILE = "rate-limit-status.json";
22
+ /** Auto-expire a forgotten manual flag after 6h (see module doc). */
23
+ export declare const RATE_LIMIT_TTL_MS: number;
24
+ export interface RateLimitStatus {
25
+ limited: boolean;
26
+ since: string | null;
27
+ cleared: string | null;
28
+ /** ADR-314 §D1 — last time `limited` actually changed value; gates the toggle cooldown. */
29
+ lastToggleAt: string | null;
30
+ }
31
+ /** Read the current rate-limit status. Never throws. Applies the TTL. */
32
+ export declare function readRateLimitStatus(now?: Date): RateLimitStatus;
33
+ /**
34
+ * Mark as rate-limited — idempotent. Sets `since` on the first mark, leaves
35
+ * it alone on subsequent marks so the user sees a stable "since" timestamp
36
+ * until they clear it or the TTL expires. Refuses to flip false→true inside
37
+ * the ADR-314 §D1 cooldown window (returns false; a no-op re-mark of an
38
+ * already-true flag is unaffected — that's not a state change).
39
+ */
40
+ export declare function markRateLimited(now?: Date): boolean;
41
+ /**
42
+ * Clear rate-limited status. Called via `ruflo settings notices
43
+ * rate-limited --clear`, automatically by the TTL, or once a real Phase 1/2
44
+ * signal (ADR-312) confirms the limit has reset. Refuses to flip true→false
45
+ * inside the cooldown window (returns false); clearing an already-clear
46
+ * flag is always allowed (not a state change, and TTL auto-clear must never
47
+ * be blocked by a cooldown it didn't itself trigger).
48
+ */
49
+ export declare function clearRateLimitStatus(now?: Date): boolean;
50
+ /**
51
+ * User-facing single-line summary — plain text, no ANSI. Callers style it
52
+ * themselves. Returns null when not rate-limited (no surface).
53
+ */
54
+ export declare function rateLimitNotice(now?: Date): string | null;
55
+ //# sourceMappingURL=rate-limit-notifier.d.ts.map
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Rate-limit notifier — ADR-312 Phase 0 out-of-band signal path.
3
+ *
4
+ * Structural mirror of credit-notifier.ts. This is NOT automatic detection
5
+ * — ADR-312 established that Claude Code does not currently expose any way
6
+ * to detect its own usage-limit state from outside its process (verified
7
+ * against the actual installed CLI source, not assumed). This module is the
8
+ * MANUAL, self-reported alternative: the user tells ruflo they've hit a
9
+ * limit, ruflo remembers it, and the funnel promo row can react.
10
+ *
11
+ * State is cheap and durable:
12
+ * ~/.ruflo/rate-limit-status.json = { limited: bool, since: ISO, cleared: ISO|null }
13
+ *
14
+ * A TTL (default 6h) auto-expires a forgotten flag so a stale manual mark
15
+ * doesn't linger indefinitely if the user forgets to clear it — Claude
16
+ * usage limits reset on hours-to-days cadences (five_hour / seven_day per
17
+ * ADR-312's grounded research), so 6h is a reasonable "the user probably
18
+ * forgot to clear this" bound without requiring per-type precision we
19
+ * don't have.
20
+ */
21
+ import { readStateJson, writeStateJson } from './state.js';
22
+ import { cooldownActive } from './toggle-cooldown.js';
23
+ export const RATE_LIMIT_STATUS_FILE = 'rate-limit-status.json';
24
+ /** Auto-expire a forgotten manual flag after 6h (see module doc). */
25
+ export const RATE_LIMIT_TTL_MS = 6 * 60 * 60 * 1000;
26
+ /** Read the current rate-limit status. Never throws. Applies the TTL. */
27
+ export function readRateLimitStatus(now = new Date()) {
28
+ const raw = readStateJson(RATE_LIMIT_STATUS_FILE);
29
+ const status = {
30
+ limited: raw?.limited ?? false,
31
+ since: raw?.since ?? null,
32
+ cleared: raw?.cleared ?? null,
33
+ lastToggleAt: raw?.lastToggleAt ?? null,
34
+ };
35
+ if (status.limited && status.since) {
36
+ const since = Date.parse(status.since);
37
+ if (!Number.isNaN(since) && now.getTime() - since >= RATE_LIMIT_TTL_MS) {
38
+ return { limited: false, since: status.since, cleared: now.toISOString(), lastToggleAt: status.lastToggleAt };
39
+ }
40
+ }
41
+ return status;
42
+ }
43
+ /**
44
+ * Mark as rate-limited — idempotent. Sets `since` on the first mark, leaves
45
+ * it alone on subsequent marks so the user sees a stable "since" timestamp
46
+ * until they clear it or the TTL expires. Refuses to flip false→true inside
47
+ * the ADR-314 §D1 cooldown window (returns false; a no-op re-mark of an
48
+ * already-true flag is unaffected — that's not a state change).
49
+ */
50
+ export function markRateLimited(now = new Date()) {
51
+ const current = readRateLimitStatus(now);
52
+ if (current.limited && current.since)
53
+ return true; // already flagged, not a change
54
+ if (cooldownActive(current.lastToggleAt, now))
55
+ return false;
56
+ writeStateJson(RATE_LIMIT_STATUS_FILE, {
57
+ limited: true,
58
+ since: current.since ?? now.toISOString(),
59
+ cleared: null,
60
+ lastToggleAt: now.toISOString(),
61
+ });
62
+ return true;
63
+ }
64
+ /**
65
+ * Clear rate-limited status. Called via `ruflo settings notices
66
+ * rate-limited --clear`, automatically by the TTL, or once a real Phase 1/2
67
+ * signal (ADR-312) confirms the limit has reset. Refuses to flip true→false
68
+ * inside the cooldown window (returns false); clearing an already-clear
69
+ * flag is always allowed (not a state change, and TTL auto-clear must never
70
+ * be blocked by a cooldown it didn't itself trigger).
71
+ */
72
+ export function clearRateLimitStatus(now = new Date()) {
73
+ const current = readRateLimitStatus(now);
74
+ if (!current.limited)
75
+ return true; // already clear, not a change
76
+ if (cooldownActive(current.lastToggleAt, now))
77
+ return false;
78
+ writeStateJson(RATE_LIMIT_STATUS_FILE, {
79
+ limited: false,
80
+ since: current.since,
81
+ cleared: now.toISOString(),
82
+ lastToggleAt: now.toISOString(),
83
+ });
84
+ return true;
85
+ }
86
+ /**
87
+ * User-facing single-line summary — plain text, no ANSI. Callers style it
88
+ * themselves. Returns null when not rate-limited (no surface).
89
+ */
90
+ export function rateLimitNotice(now = new Date()) {
91
+ const status = readRateLimitStatus(now);
92
+ if (!status.limited)
93
+ return null;
94
+ const since = status.since ? Date.parse(status.since) : NaN;
95
+ if (Number.isNaN(since)) {
96
+ return 'Claude usage limit flagged · run: ruflo proxy sponsor-enable';
97
+ }
98
+ const ageMin = Math.max(0, Math.round((now.getTime() - since) / (60 * 1000)));
99
+ const when = ageMin < 1 ? 'just now' : ageMin < 60 ? `${ageMin}m ago` : `${Math.round(ageMin / 60)}h ago`;
100
+ return `Claude usage limit flagged (${when}) · run: ruflo proxy sponsor-enable`;
101
+ }
102
+ //# sourceMappingURL=rate-limit-notifier.js.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Rotation scheduler — ADR-301 content ratio, enforced structurally.
3
+ *
4
+ * - Educational: at least 4 of every 5 rotation slots.
5
+ * - Promotional: at most 1 of every 5 slots (slot % 5 === 4), and only
6
+ * when no promotion has shown in the last 30 minutes.
7
+ * - Deterministic: selection is a pure function of (time slot, registry,
8
+ * last-promo state) — no Math.random, so renders are reproducible and
9
+ * the statusline cache can't skew the ratio.
10
+ */
11
+ import type { FunnelMessage } from './types.js';
12
+ /** One rotation slot — ADR-301 allows 15–30s; 20s sits inside the band. */
13
+ export declare const ROTATION_SLOT_MS = 20000;
14
+ /** The same promotion appears at most once every 30 minutes (ADR-301). */
15
+ export declare const PROMO_REPEAT_CAP_MS: number;
16
+ /** 1 promotional slot per 5 (ADR-301: ≤ 1 in 5 rotations). */
17
+ export declare const PROMO_SLOT_MODULO = 5;
18
+ export declare function selectMessage(now?: Date, release?: string): FunnelMessage | null;
19
+ //# sourceMappingURL=rotation.d.ts.map
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Rotation scheduler — ADR-301 content ratio, enforced structurally.
3
+ *
4
+ * - Educational: at least 4 of every 5 rotation slots.
5
+ * - Promotional: at most 1 of every 5 slots (slot % 5 === 4), and only
6
+ * when no promotion has shown in the last 30 minutes.
7
+ * - Deterministic: selection is a pure function of (time slot, registry,
8
+ * last-promo state) — no Math.random, so renders are reproducible and
9
+ * the statusline cache can't skew the ratio.
10
+ */
11
+ import { MESSAGES, eligibleMessagesFromPools } from './messages.js';
12
+ import { getRemoteMessages, refreshRemoteMessages } from './message-transport.js';
13
+ import { readStateJson, writeStateJson } from './state.js';
14
+ import { recordFunnelEvent } from './events.js';
15
+ const ROTATION_FILE = 'funnel-rotation.json';
16
+ /** One rotation slot — ADR-301 allows 15–30s; 20s sits inside the band. */
17
+ export const ROTATION_SLOT_MS = 20_000;
18
+ /** The same promotion appears at most once every 30 minutes (ADR-301). */
19
+ export const PROMO_REPEAT_CAP_MS = 30 * 60 * 1000;
20
+ /** 1 promotional slot per 5 (ADR-301: ≤ 1 in 5 rotations). */
21
+ export const PROMO_SLOT_MODULO = 5;
22
+ export function selectMessage(now = new Date(), release = 'unknown') {
23
+ // Kick a background refresh — never awaited, never blocks render. The
24
+ // remote pool becomes visible on subsequent selects once cached.
25
+ void refreshRemoteMessages();
26
+ // Merge: remote pool authoritative, in-code pool fallback (by id).
27
+ const pool = eligibleMessagesFromPools(MESSAGES, getRemoteMessages(), now);
28
+ const educational = pool.filter((m) => m.class === 'educational');
29
+ const promotional = pool.filter((m) => m.class === 'promotional');
30
+ if (educational.length === 0 && promotional.length === 0)
31
+ return null;
32
+ const slot = Math.floor(now.getTime() / ROTATION_SLOT_MS);
33
+ const promoSlot = slot % PROMO_SLOT_MODULO === PROMO_SLOT_MODULO - 1;
34
+ let selected = null;
35
+ if (promoSlot && promotional.length > 0 && promoCapClear(now)) {
36
+ selected = promotional[Math.floor(slot / PROMO_SLOT_MODULO) % promotional.length];
37
+ recordPromoShown(selected, now);
38
+ }
39
+ else if (educational.length > 0) {
40
+ selected = educational[slot % educational.length];
41
+ }
42
+ // Fire an impression event for whichever message was selected. Consent-gated
43
+ // (recordFunnelEvent no-ops without telemetry consent). Idempotency across
44
+ // renders in the same slot is handled by the same-slot deduplication in
45
+ // the events transport — we don't try to dedupe here because the slot
46
+ // math already returns the same id for the same slot, giving downstream
47
+ // aggregation a per-slot boolean.
48
+ if (selected) {
49
+ recordFunnelEvent('promo_impression', 'statusline', release, {
50
+ now, messageId: selected.id,
51
+ });
52
+ }
53
+ return selected;
54
+ }
55
+ function promoCapClear(now) {
56
+ const state = readStateJson(ROTATION_FILE);
57
+ if (!state?.lastPromoAt)
58
+ return true;
59
+ const last = Date.parse(state.lastPromoAt);
60
+ if (Number.isNaN(last))
61
+ return true;
62
+ return now.getTime() - last >= PROMO_REPEAT_CAP_MS;
63
+ }
64
+ function recordPromoShown(msg, now) {
65
+ writeStateJson(ROTATION_FILE, {
66
+ lastPromoAt: now.toISOString(),
67
+ lastPromoId: msg.id,
68
+ });
69
+ }
70
+ //# sourceMappingURL=rotation.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Funnel state storage — user-level JSON files under ~/.ruflo (ADR-302/305).
3
+ *
4
+ * User-level (not project-level) so dismissals, consent, and disclosure
5
+ * persist across projects. Files are written 0600 and never committed.
6
+ * RUFLO_STATE_DIR overrides the directory (tests, unusual $HOME setups).
7
+ */
8
+ export declare function funnelStateDir(): string;
9
+ export declare function statePath(name: string): string;
10
+ export declare function readStateJson<T>(name: string): T | null;
11
+ export declare function writeStateJson(name: string, value: unknown): boolean;
12
+ export declare function deleteStateFile(name: string): void;
13
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Funnel state storage — user-level JSON files under ~/.ruflo (ADR-302/305).
3
+ *
4
+ * User-level (not project-level) so dismissals, consent, and disclosure
5
+ * persist across projects. Files are written 0600 and never committed.
6
+ * RUFLO_STATE_DIR overrides the directory (tests, unusual $HOME setups).
7
+ */
8
+ import * as fs from 'fs';
9
+ import * as os from 'os';
10
+ import * as path from 'path';
11
+ export function funnelStateDir() {
12
+ const override = process.env.RUFLO_STATE_DIR;
13
+ if (override && override.trim())
14
+ return override;
15
+ return path.join(os.homedir(), '.ruflo');
16
+ }
17
+ export function statePath(name) {
18
+ return path.join(funnelStateDir(), name);
19
+ }
20
+ export function readStateJson(name) {
21
+ try {
22
+ const raw = fs.readFileSync(statePath(name), 'utf-8');
23
+ return JSON.parse(raw);
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ }
29
+ export function writeStateJson(name, value) {
30
+ try {
31
+ const dir = funnelStateDir();
32
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
33
+ const target = statePath(name);
34
+ // Write-then-rename so a crash never leaves a truncated state file.
35
+ const tmp = `${target}.tmp`;
36
+ fs.writeFileSync(tmp, JSON.stringify(value, null, 2), { encoding: 'utf-8', mode: 0o600 });
37
+ fs.renameSync(tmp, target);
38
+ return true;
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ export function deleteStateFile(name) {
45
+ try {
46
+ fs.unlinkSync(statePath(name));
47
+ }
48
+ catch {
49
+ // already absent — fine
50
+ }
51
+ }
52
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared toggle cooldown — ADR-314 §D1.
3
+ *
4
+ * Self-reported flags (rate-limited, quota-low) have zero server-side
5
+ * verification (ADR-312's Phase 0 constraint carries over unchanged). A
6
+ * cooldown on how often the flag can actually CHANGE state is cheap,
7
+ * purely client-side friction against casual "always on" gaming or a
8
+ * scripted flip-flop loop — it does not stop a determined abuser (that
9
+ * needs the per-identity server-side quota ADR-314 flags as the real fix),
10
+ * but it raises the bar above "one line in a shell script."
11
+ */
12
+ export declare const TOGGLE_COOLDOWN_MS: number;
13
+ /** True when `lastToggleAt` is within the cooldown window of `now`. */
14
+ export declare function cooldownActive(lastToggleAt: string | null, now: Date): boolean;
15
+ /** Minutes remaining in the cooldown window — for user-facing messages. */
16
+ export declare function cooldownRemainingMin(lastToggleAt: string | null, now: Date): number;
17
+ //# sourceMappingURL=toggle-cooldown.d.ts.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Shared toggle cooldown — ADR-314 §D1.
3
+ *
4
+ * Self-reported flags (rate-limited, quota-low) have zero server-side
5
+ * verification (ADR-312's Phase 0 constraint carries over unchanged). A
6
+ * cooldown on how often the flag can actually CHANGE state is cheap,
7
+ * purely client-side friction against casual "always on" gaming or a
8
+ * scripted flip-flop loop — it does not stop a determined abuser (that
9
+ * needs the per-identity server-side quota ADR-314 flags as the real fix),
10
+ * but it raises the bar above "one line in a shell script."
11
+ */
12
+ export const TOGGLE_COOLDOWN_MS = 10 * 60 * 1000;
13
+ /** True when `lastToggleAt` is within the cooldown window of `now`. */
14
+ export function cooldownActive(lastToggleAt, now) {
15
+ if (!lastToggleAt)
16
+ return false;
17
+ const t = Date.parse(lastToggleAt);
18
+ if (Number.isNaN(t))
19
+ return false;
20
+ return now.getTime() - t < TOGGLE_COOLDOWN_MS;
21
+ }
22
+ /** Minutes remaining in the cooldown window — for user-facing messages. */
23
+ export function cooldownRemainingMin(lastToggleAt, now) {
24
+ if (!lastToggleAt)
25
+ return 0;
26
+ const t = Date.parse(lastToggleAt);
27
+ if (Number.isNaN(t))
28
+ return 0;
29
+ const remainingMs = TOGGLE_COOLDOWN_MS - (now.getTime() - t);
30
+ return Math.max(0, Math.ceil(remainingMs / (60 * 1000)));
31
+ }
32
+ //# sourceMappingURL=toggle-cooldown.js.map
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Funnel type definitions — ADR-301..310.
3
+ *
4
+ * The funnel is the ruflo → Cognitum lifecycle system: promotional status
5
+ * surface (ADR-301), post-init enrollment (ADR-302), credit-exhaustion
6
+ * recovery (ADR-303), governed by consent receipts (ADR-302), control
7
+ * precedence (ADR-305), and the governance/privacy rules of ADR-309.
8
+ *
9
+ * Everything in this module is local-only: no code path here performs
10
+ * network I/O. Events are queued locally and only when telemetry consent
11
+ * is granted (ADR-308 failure policy: telemetry never blocks the CLI).
12
+ */
13
+ export type FunnelDisclosureState = 'never_seen' | 'disclosed_enabled' | 'disclosed_disabled';
14
+ export interface DisclosureRecord {
15
+ state: FunnelDisclosureState;
16
+ /** ISO timestamp of the first render of the disclosure text. */
17
+ firstShownAt: string | null;
18
+ }
19
+ export type FunnelMessageClass = 'educational' | 'promotional' | 'disclosure';
20
+ export interface FunnelMessage {
21
+ id: string;
22
+ schemaVersion: 1;
23
+ text: string;
24
+ /** Optional link; must pass the in-code host allowlist or the message is dropped. */
25
+ url?: string;
26
+ class: FunnelMessageClass;
27
+ /** ISO timestamp; expired messages leave the rotation immediately. */
28
+ expiresAt?: string;
29
+ }
30
+ export interface PromoRow {
31
+ text: string;
32
+ kind: 'disclosure' | FunnelMessageClass | 'insight';
33
+ url?: string;
34
+ }
35
+ export type ConsentDomain = 'account' | 'proxy-install' | 'telemetry' | 'cloud-routing' | 'hosted-memory' | 'sponsored-downtime' | 'power-saver' | 'training-data-sharing' | 'advisor-tips';
36
+ export interface ConsentReceipt {
37
+ granted: boolean;
38
+ policyVersion: number;
39
+ /** ISO timestamp of the decision; null = never asked. */
40
+ at: string | null;
41
+ surface: string | null;
42
+ }
43
+ export type ConsentFile = Partial<Record<ConsentDomain, ConsentReceipt>>;
44
+ /** Bump when the meaning of a consent domain changes materially (ADR-302). */
45
+ export declare const CONSENT_POLICY_VERSION = 1;
46
+ export type FunnelDecisionSource = 'env' | 'enterprise-policy' | 'user-config' | 'project-config' | 'package-default' | 'remote-policy' | 'disclosure-declined';
47
+ export interface FunnelEnabledDecision {
48
+ enabled: boolean;
49
+ decidedBy: FunnelDecisionSource;
50
+ }
51
+ export declare enum CreditErrorCode {
52
+ /** Cognitum ledger says balance is spent — the ONLY funnel trigger. */
53
+ COGNITUM_CREDIT_EXHAUSTED = "COGNITUM_CREDIT_EXHAUSTED",
54
+ /** Upstream provider's own quota, not Cognitum credits. */
55
+ PROVIDER_QUOTA_EXHAUSTED = "PROVIDER_QUOTA_EXHAUSTED",
56
+ PROVIDER_RATE_LIMITED = "PROVIDER_RATE_LIMITED",
57
+ AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED",
58
+ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE"
59
+ }
60
+ export interface NormalizedCreditError {
61
+ code: CreditErrorCode | null;
62
+ /** 1 only when an explicit machine-readable provider code mapped; else 0. */
63
+ confidence: 0 | 1;
64
+ retryable: boolean;
65
+ /** Original provider error, preserved verbatim for --verbose paths. */
66
+ cause?: unknown;
67
+ }
68
+ export type FunnelEventName = 'disclosure_shown' | 'funnel_disabled' | 'signup_opened' | 'account_created' | 'proxy_activated' | 'promo_impression' | 'promo_open' | 'sponsor_mode_enabled' | 'sponsor_mode_disabled' | 'sponsor_capacity_exhausted' | 'power_saver_enabled' | 'power_saver_disabled' | 'toggle_cooldown_blocked' | 'training_share_enabled' | 'training_share_disabled' | 'advisor_tip_enabled' | 'advisor_tip_disabled';
69
+ export type FunnelSurface = 'statusline' | 'init' | 'credit_exhaustion';
70
+ export interface FunnelEvent {
71
+ schemaVersion: 1;
72
+ event: FunnelEventName;
73
+ surface: FunnelSurface;
74
+ release: string;
75
+ region?: string;
76
+ pseudonymousId?: string;
77
+ /**
78
+ * Message id for promo_impression / promo_open — lets the analyst
79
+ * attribute clicks + impressions to a specific rotation entry without
80
+ * carrying prompt/URL/PII data.
81
+ */
82
+ messageId?: string;
83
+ /** Daily bucket ("2026-07-10") — full timestamps are never recorded. */
84
+ timestampBucket: string;
85
+ }
86
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Funnel type definitions — ADR-301..310.
3
+ *
4
+ * The funnel is the ruflo → Cognitum lifecycle system: promotional status
5
+ * surface (ADR-301), post-init enrollment (ADR-302), credit-exhaustion
6
+ * recovery (ADR-303), governed by consent receipts (ADR-302), control
7
+ * precedence (ADR-305), and the governance/privacy rules of ADR-309.
8
+ *
9
+ * Everything in this module is local-only: no code path here performs
10
+ * network I/O. Events are queued locally and only when telemetry consent
11
+ * is granted (ADR-308 failure policy: telemetry never blocks the CLI).
12
+ */
13
+ /** Bump when the meaning of a consent domain changes materially (ADR-302). */
14
+ export const CONSENT_POLICY_VERSION = 1;
15
+ // ─── ADR-303: credit error taxonomy ─────────────────────────────────────────
16
+ export var CreditErrorCode;
17
+ (function (CreditErrorCode) {
18
+ /** Cognitum ledger says balance is spent — the ONLY funnel trigger. */
19
+ CreditErrorCode["COGNITUM_CREDIT_EXHAUSTED"] = "COGNITUM_CREDIT_EXHAUSTED";
20
+ /** Upstream provider's own quota, not Cognitum credits. */
21
+ CreditErrorCode["PROVIDER_QUOTA_EXHAUSTED"] = "PROVIDER_QUOTA_EXHAUSTED";
22
+ CreditErrorCode["PROVIDER_RATE_LIMITED"] = "PROVIDER_RATE_LIMITED";
23
+ CreditErrorCode["AUTHENTICATION_FAILED"] = "AUTHENTICATION_FAILED";
24
+ CreditErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
25
+ })(CreditErrorCode || (CreditErrorCode = {}));
26
+ //# sourceMappingURL=types.js.map
@@ -341,7 +341,11 @@ function mergeSettingsForUpgrade(existing) {
341
341
  // load the ONNX model on every fire (~1s); Claude Code times out and hides
342
342
  // the status bar (#2450). The migration replaces the whole command with
343
343
  // NEW_STATUSLINE_CMD which invokes the local helper directly via `node -e`.
344
- const BROKEN_STATUSLINE_RE = /(?:npx\s+(?:--?\S+\s+)*)?@?claude-flow(?:\/cli)?(?:@\S+)?\s+hooks\s+statusline/;
344
+ // Flag-list repetition bounded at 10 (real invocations never carry more) —
345
+ // an unbounded `*` here is exponential-backtracking-prone (CodeQL
346
+ // js/redos): a crafted settings.json command string with dozens of
347
+ // dash-token repetitions can hang this check for minutes.
348
+ const BROKEN_STATUSLINE_RE = /(?:npx\s+(?:--?\S+\s+){0,10})?@?claude-flow(?:\/cli)?(?:@\S+)?\s+hooks\s+statusline/;
345
349
  const existingStatusLine = existing.statusLine;
346
350
  if (existingStatusLine) {
347
351
  const existingCmd = typeof existingStatusLine.command === 'string' ? existingStatusLine.command : '';
@@ -361,7 +365,8 @@ function mergeSettingsForUpgrade(existing) {
361
365
  // We walk each hook event's `hooks[]` and swap any command matching the
362
366
  // broken pattern for the local-helper form. Idempotent: re-running this
363
367
  // migration on already-correct settings is a no-op.
364
- const BROKEN_HOOK_RE = /npx\s+(?:--?\S+\s+)*@?claude-flow\/cli@latest\s+hooks\s+(\S+)/;
368
+ // Bounded for the same reason as BROKEN_STATUSLINE_RE above (CodeQL js/redos).
369
+ const BROKEN_HOOK_RE = /npx\s+(?:--?\S+\s+){0,10}@?claude-flow\/cli@latest\s+hooks\s+(\S+)/;
365
370
  const localHookCmd = (sub) => {
366
371
  // POSIX form mirrors settings-generator.ts::hookCmd() exactly.
367
372
  // Windows users hit a separate code path (cmd /c …) — Claude Code on
@@ -456,7 +461,8 @@ export async function executeUpgrade(targetDir, upgradeSettings = false) {
456
461
  // 0. ALWAYS update critical helpers (force overwrite)
457
462
  const sourceHelpersForUpgrade = findSourceHelpersDir();
458
463
  if (sourceHelpersForUpgrade) {
459
- const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs'];
464
+ // Keep in sync with helper-refresh.ts:CRITICAL_HELPERS.
465
+ const criticalHelpers = ['auto-memory-hook.mjs', 'hook-handler.cjs', 'intelligence.cjs', 'statusline.cjs'];
460
466
  for (const helperName of criticalHelpers) {
461
467
  const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
462
468
  const sourcePath = path.join(sourceHelpersForUpgrade, helperName);