claude-flow 3.25.5 → 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 (312) 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/statusline.cjs +300 -123
  5. package/.claude/proven-config.json +1 -1
  6. package/.claude/security-scans/scan-all-standard.json +321 -0
  7. package/.claude/security-scans/scan-code-deep.json +1209 -0
  8. package/.claude/security-scans/scan-deps-full.json +14 -0
  9. package/package.json +3 -1
  10. package/v3/@claude-flow/cli/catalog-manifest.json +12 -0
  11. package/v3/@claude-flow/cli/dist/src/commands/advisor.d.ts +15 -0
  12. package/v3/@claude-flow/cli/dist/src/commands/advisor.js +94 -0
  13. package/v3/@claude-flow/cli/dist/src/commands/doctor.js +151 -32
  14. package/v3/@claude-flow/cli/dist/src/commands/funnel.d.ts +13 -0
  15. package/v3/@claude-flow/cli/dist/src/commands/funnel.js +103 -0
  16. package/v3/@claude-flow/cli/dist/src/commands/hooks.js +112 -46
  17. package/v3/@claude-flow/cli/dist/src/commands/index.js +10 -0
  18. package/v3/@claude-flow/cli/dist/src/commands/init.js +44 -0
  19. package/v3/@claude-flow/cli/dist/src/commands/proxy.d.ts +21 -0
  20. package/v3/@claude-flow/cli/dist/src/commands/proxy.js +310 -0
  21. package/v3/@claude-flow/cli/dist/src/commands/security.js +29 -0
  22. package/v3/@claude-flow/cli/dist/src/commands/settings.d.ts +19 -0
  23. package/v3/@claude-flow/cli/dist/src/commands/settings.js +180 -0
  24. package/v3/@claude-flow/cli/dist/src/commands/version.d.ts +42 -0
  25. package/v3/@claude-flow/cli/dist/src/commands/version.js +106 -0
  26. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.d.ts +58 -0
  27. package/v3/@claude-flow/cli/dist/src/funnel/advisor-tip.js +92 -0
  28. package/v3/@claude-flow/cli/dist/src/funnel/attribution.d.ts +37 -0
  29. package/v3/@claude-flow/cli/dist/src/funnel/attribution.js +101 -0
  30. package/v3/@claude-flow/cli/dist/src/funnel/consent.d.ts +22 -0
  31. package/v3/@claude-flow/cli/dist/src/funnel/consent.js +55 -0
  32. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.d.ts +31 -0
  33. package/v3/@claude-flow/cli/dist/src/funnel/credit-errors.js +88 -0
  34. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.d.ts +44 -0
  35. package/v3/@claude-flow/cli/dist/src/funnel/credit-notifier.js +74 -0
  36. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.d.ts +46 -0
  37. package/v3/@claude-flow/cli/dist/src/funnel/disclosure.js +97 -0
  38. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.d.ts +36 -0
  39. package/v3/@claude-flow/cli/dist/src/funnel/enrollment.js +64 -0
  40. package/v3/@claude-flow/cli/dist/src/funnel/environment.d.ts +17 -0
  41. package/v3/@claude-flow/cli/dist/src/funnel/environment.js +39 -0
  42. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.d.ts +51 -0
  43. package/v3/@claude-flow/cli/dist/src/funnel/event-transport.js +199 -0
  44. package/v3/@claude-flow/cli/dist/src/funnel/events.d.ts +42 -0
  45. package/v3/@claude-flow/cli/dist/src/funnel/events.js +150 -0
  46. package/v3/@claude-flow/cli/dist/src/funnel/index.d.ts +20 -0
  47. package/v3/@claude-flow/cli/dist/src/funnel/index.js +20 -0
  48. package/v3/@claude-flow/cli/dist/src/funnel/insights.d.ts +49 -0
  49. package/v3/@claude-flow/cli/dist/src/funnel/insights.js +120 -0
  50. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.d.ts +15 -0
  51. package/v3/@claude-flow/cli/dist/src/funnel/local-signals.js +68 -0
  52. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.d.ts +51 -0
  53. package/v3/@claude-flow/cli/dist/src/funnel/message-transport.js +149 -0
  54. package/v3/@claude-flow/cli/dist/src/funnel/messages.d.ts +55 -0
  55. package/v3/@claude-flow/cli/dist/src/funnel/messages.js +160 -0
  56. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.d.ts +44 -0
  57. package/v3/@claude-flow/cli/dist/src/funnel/power-saver-notifier.js +92 -0
  58. package/v3/@claude-flow/cli/dist/src/funnel/precedence.d.ts +16 -0
  59. package/v3/@claude-flow/cli/dist/src/funnel/precedence.js +85 -0
  60. package/v3/@claude-flow/cli/dist/src/funnel/promo.d.ts +41 -0
  61. package/v3/@claude-flow/cli/dist/src/funnel/promo.js +144 -0
  62. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.d.ts +55 -0
  63. package/v3/@claude-flow/cli/dist/src/funnel/rate-limit-notifier.js +102 -0
  64. package/v3/@claude-flow/cli/dist/src/funnel/rotation.d.ts +19 -0
  65. package/v3/@claude-flow/cli/dist/src/funnel/rotation.js +70 -0
  66. package/v3/@claude-flow/cli/dist/src/funnel/state.d.ts +13 -0
  67. package/v3/@claude-flow/cli/dist/src/funnel/state.js +52 -0
  68. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.d.ts +17 -0
  69. package/v3/@claude-flow/cli/dist/src/funnel/toggle-cooldown.js +32 -0
  70. package/v3/@claude-flow/cli/dist/src/funnel/types.d.ts +86 -0
  71. package/v3/@claude-flow/cli/dist/src/funnel/types.js +26 -0
  72. package/v3/@claude-flow/cli/dist/src/init/executor.js +25 -19
  73. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.d.ts +33 -2
  74. package/v3/@claude-flow/cli/dist/src/init/helper-refresh.js +102 -12
  75. package/v3/@claude-flow/cli/dist/src/init/helpers-generator.js +52 -0
  76. package/v3/@claude-flow/cli/dist/src/init/mcp-generator.js +11 -6
  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 +16 -4
  82. package/v3/README.md +493 -0
  83. package/.claude/coordinator/config.json +0 -24
  84. package/.claude/coordinator/state.json +0 -37
  85. package/.claude/coordinator/tick-log/tick-01.json +0 -17
  86. package/.claude/coordinator/tick-log/tick-02.json +0 -17
  87. package/.claude/coordinator/tick-log/tick-03.json +0 -17
  88. package/.claude/coordinator/tick-log/tick-04.json +0 -14
  89. package/.claude/coordinator/tick-log/tick-05.json +0 -16
  90. package/.claude/settings.local.json +0 -11
  91. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.d.ts +0 -14
  92. package/v3/@claude-flow/cli/dist/src/ruvector/lattice-wasm.js +0 -144
  93. package/v3/@claude-flow/guidance/dist/adversarial.d.ts +0 -284
  94. package/v3/@claude-flow/guidance/dist/adversarial.js +0 -572
  95. package/v3/@claude-flow/guidance/dist/analyzer.d.ts +0 -530
  96. package/v3/@claude-flow/guidance/dist/analyzer.js +0 -2587
  97. package/v3/@claude-flow/guidance/dist/artifacts.d.ts +0 -283
  98. package/v3/@claude-flow/guidance/dist/artifacts.js +0 -356
  99. package/v3/@claude-flow/guidance/dist/authority.d.ts +0 -290
  100. package/v3/@claude-flow/guidance/dist/authority.js +0 -558
  101. package/v3/@claude-flow/guidance/dist/capabilities.d.ts +0 -209
  102. package/v3/@claude-flow/guidance/dist/capabilities.js +0 -485
  103. package/v3/@claude-flow/guidance/dist/coherence.d.ts +0 -233
  104. package/v3/@claude-flow/guidance/dist/coherence.js +0 -372
  105. package/v3/@claude-flow/guidance/dist/compiler.d.ts +0 -87
  106. package/v3/@claude-flow/guidance/dist/compiler.js +0 -410
  107. package/v3/@claude-flow/guidance/dist/conformance-kit.d.ts +0 -225
  108. package/v3/@claude-flow/guidance/dist/conformance-kit.js +0 -629
  109. package/v3/@claude-flow/guidance/dist/continue-gate.d.ts +0 -214
  110. package/v3/@claude-flow/guidance/dist/continue-gate.js +0 -353
  111. package/v3/@claude-flow/guidance/dist/crypto-utils.d.ts +0 -17
  112. package/v3/@claude-flow/guidance/dist/crypto-utils.js +0 -24
  113. package/v3/@claude-flow/guidance/dist/evolution.d.ts +0 -282
  114. package/v3/@claude-flow/guidance/dist/evolution.js +0 -500
  115. package/v3/@claude-flow/guidance/dist/gates.d.ts +0 -79
  116. package/v3/@claude-flow/guidance/dist/gates.js +0 -302
  117. package/v3/@claude-flow/guidance/dist/gateway.d.ts +0 -206
  118. package/v3/@claude-flow/guidance/dist/gateway.js +0 -452
  119. package/v3/@claude-flow/guidance/dist/generators.d.ts +0 -153
  120. package/v3/@claude-flow/guidance/dist/generators.js +0 -682
  121. package/v3/@claude-flow/guidance/dist/headless.d.ts +0 -177
  122. package/v3/@claude-flow/guidance/dist/headless.js +0 -342
  123. package/v3/@claude-flow/guidance/dist/hooks.d.ts +0 -109
  124. package/v3/@claude-flow/guidance/dist/hooks.js +0 -347
  125. package/v3/@claude-flow/guidance/dist/index.d.ts +0 -205
  126. package/v3/@claude-flow/guidance/dist/index.js +0 -321
  127. package/v3/@claude-flow/guidance/dist/ledger.d.ts +0 -162
  128. package/v3/@claude-flow/guidance/dist/ledger.js +0 -375
  129. package/v3/@claude-flow/guidance/dist/manifest-validator.d.ts +0 -289
  130. package/v3/@claude-flow/guidance/dist/manifest-validator.js +0 -838
  131. package/v3/@claude-flow/guidance/dist/memory-gate.d.ts +0 -222
  132. package/v3/@claude-flow/guidance/dist/memory-gate.js +0 -382
  133. package/v3/@claude-flow/guidance/dist/meta-governance.d.ts +0 -265
  134. package/v3/@claude-flow/guidance/dist/meta-governance.js +0 -348
  135. package/v3/@claude-flow/guidance/dist/optimizer.d.ts +0 -104
  136. package/v3/@claude-flow/guidance/dist/optimizer.js +0 -329
  137. package/v3/@claude-flow/guidance/dist/persistence.d.ts +0 -189
  138. package/v3/@claude-flow/guidance/dist/persistence.js +0 -464
  139. package/v3/@claude-flow/guidance/dist/proof.d.ts +0 -185
  140. package/v3/@claude-flow/guidance/dist/proof.js +0 -238
  141. package/v3/@claude-flow/guidance/dist/retriever.d.ts +0 -172
  142. package/v3/@claude-flow/guidance/dist/retriever.js +0 -596
  143. package/v3/@claude-flow/guidance/dist/ruvbot-integration.d.ts +0 -370
  144. package/v3/@claude-flow/guidance/dist/ruvbot-integration.js +0 -738
  145. package/v3/@claude-flow/guidance/dist/temporal.d.ts +0 -426
  146. package/v3/@claude-flow/guidance/dist/temporal.js +0 -658
  147. package/v3/@claude-flow/guidance/dist/trust.d.ts +0 -283
  148. package/v3/@claude-flow/guidance/dist/trust.js +0 -473
  149. package/v3/@claude-flow/guidance/dist/truth-anchors.d.ts +0 -276
  150. package/v3/@claude-flow/guidance/dist/truth-anchors.js +0 -488
  151. package/v3/@claude-flow/guidance/dist/types.d.ts +0 -378
  152. package/v3/@claude-flow/guidance/dist/types.js +0 -10
  153. package/v3/@claude-flow/guidance/dist/uncertainty.d.ts +0 -372
  154. package/v3/@claude-flow/guidance/dist/uncertainty.js +0 -619
  155. package/v3/@claude-flow/guidance/dist/wasm-kernel.d.ts +0 -48
  156. package/v3/@claude-flow/guidance/dist/wasm-kernel.js +0 -158
  157. package/v3/@claude-flow/shared/dist/core/config/defaults.d.ts +0 -41
  158. package/v3/@claude-flow/shared/dist/core/config/defaults.js +0 -186
  159. package/v3/@claude-flow/shared/dist/core/config/index.d.ts +0 -8
  160. package/v3/@claude-flow/shared/dist/core/config/index.js +0 -12
  161. package/v3/@claude-flow/shared/dist/core/config/loader.d.ts +0 -45
  162. package/v3/@claude-flow/shared/dist/core/config/loader.js +0 -238
  163. package/v3/@claude-flow/shared/dist/core/config/schema.d.ts +0 -1728
  164. package/v3/@claude-flow/shared/dist/core/config/schema.js +0 -160
  165. package/v3/@claude-flow/shared/dist/core/config/validator.d.ts +0 -92
  166. package/v3/@claude-flow/shared/dist/core/config/validator.js +0 -147
  167. package/v3/@claude-flow/shared/dist/core/event-bus.d.ts +0 -31
  168. package/v3/@claude-flow/shared/dist/core/event-bus.js +0 -197
  169. package/v3/@claude-flow/shared/dist/core/index.d.ts +0 -15
  170. package/v3/@claude-flow/shared/dist/core/index.js +0 -19
  171. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.d.ts +0 -200
  172. package/v3/@claude-flow/shared/dist/core/interfaces/agent.interface.js +0 -6
  173. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.d.ts +0 -310
  174. package/v3/@claude-flow/shared/dist/core/interfaces/coordinator.interface.js +0 -7
  175. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.d.ts +0 -224
  176. package/v3/@claude-flow/shared/dist/core/interfaces/event.interface.js +0 -46
  177. package/v3/@claude-flow/shared/dist/core/interfaces/index.d.ts +0 -10
  178. package/v3/@claude-flow/shared/dist/core/interfaces/index.js +0 -15
  179. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.d.ts +0 -298
  180. package/v3/@claude-flow/shared/dist/core/interfaces/memory.interface.js +0 -7
  181. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.d.ts +0 -185
  182. package/v3/@claude-flow/shared/dist/core/interfaces/task.interface.js +0 -6
  183. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.d.ts +0 -35
  184. package/v3/@claude-flow/shared/dist/core/orchestrator/event-coordinator.js +0 -101
  185. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.d.ts +0 -60
  186. package/v3/@claude-flow/shared/dist/core/orchestrator/health-monitor.js +0 -166
  187. package/v3/@claude-flow/shared/dist/core/orchestrator/index.d.ts +0 -46
  188. package/v3/@claude-flow/shared/dist/core/orchestrator/index.js +0 -64
  189. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.d.ts +0 -56
  190. package/v3/@claude-flow/shared/dist/core/orchestrator/lifecycle-manager.js +0 -195
  191. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.d.ts +0 -83
  192. package/v3/@claude-flow/shared/dist/core/orchestrator/session-manager.js +0 -193
  193. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.d.ts +0 -49
  194. package/v3/@claude-flow/shared/dist/core/orchestrator/task-manager.js +0 -253
  195. package/v3/@claude-flow/shared/dist/events/domain-events.d.ts +0 -282
  196. package/v3/@claude-flow/shared/dist/events/domain-events.js +0 -165
  197. package/v3/@claude-flow/shared/dist/events/event-store.d.ts +0 -126
  198. package/v3/@claude-flow/shared/dist/events/event-store.js +0 -427
  199. package/v3/@claude-flow/shared/dist/events/event-store.test.d.ts +0 -8
  200. package/v3/@claude-flow/shared/dist/events/event-store.test.js +0 -293
  201. package/v3/@claude-flow/shared/dist/events/example-usage.d.ts +0 -10
  202. package/v3/@claude-flow/shared/dist/events/example-usage.js +0 -193
  203. package/v3/@claude-flow/shared/dist/events/index.d.ts +0 -21
  204. package/v3/@claude-flow/shared/dist/events/index.js +0 -22
  205. package/v3/@claude-flow/shared/dist/events/projections.d.ts +0 -177
  206. package/v3/@claude-flow/shared/dist/events/projections.js +0 -421
  207. package/v3/@claude-flow/shared/dist/events/rvf-event-log.d.ts +0 -82
  208. package/v3/@claude-flow/shared/dist/events/rvf-event-log.js +0 -340
  209. package/v3/@claude-flow/shared/dist/events/state-reconstructor.d.ts +0 -101
  210. package/v3/@claude-flow/shared/dist/events/state-reconstructor.js +0 -263
  211. package/v3/@claude-flow/shared/dist/events.d.ts +0 -80
  212. package/v3/@claude-flow/shared/dist/events.js +0 -249
  213. package/v3/@claude-flow/shared/dist/hooks/example-usage.d.ts +0 -42
  214. package/v3/@claude-flow/shared/dist/hooks/example-usage.js +0 -351
  215. package/v3/@claude-flow/shared/dist/hooks/executor.d.ts +0 -100
  216. package/v3/@claude-flow/shared/dist/hooks/executor.js +0 -267
  217. package/v3/@claude-flow/shared/dist/hooks/hooks.test.d.ts +0 -9
  218. package/v3/@claude-flow/shared/dist/hooks/hooks.test.js +0 -322
  219. package/v3/@claude-flow/shared/dist/hooks/index.d.ts +0 -52
  220. package/v3/@claude-flow/shared/dist/hooks/index.js +0 -51
  221. package/v3/@claude-flow/shared/dist/hooks/registry.d.ts +0 -133
  222. package/v3/@claude-flow/shared/dist/hooks/registry.js +0 -277
  223. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.d.ts +0 -105
  224. package/v3/@claude-flow/shared/dist/hooks/safety/bash-safety.js +0 -481
  225. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.d.ts +0 -144
  226. package/v3/@claude-flow/shared/dist/hooks/safety/file-organization.js +0 -328
  227. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.d.ts +0 -158
  228. package/v3/@claude-flow/shared/dist/hooks/safety/git-commit.js +0 -450
  229. package/v3/@claude-flow/shared/dist/hooks/safety/index.d.ts +0 -17
  230. package/v3/@claude-flow/shared/dist/hooks/safety/index.js +0 -17
  231. package/v3/@claude-flow/shared/dist/hooks/session-hooks.d.ts +0 -234
  232. package/v3/@claude-flow/shared/dist/hooks/session-hooks.js +0 -334
  233. package/v3/@claude-flow/shared/dist/hooks/task-hooks.d.ts +0 -163
  234. package/v3/@claude-flow/shared/dist/hooks/task-hooks.js +0 -326
  235. package/v3/@claude-flow/shared/dist/hooks/types.d.ts +0 -267
  236. package/v3/@claude-flow/shared/dist/hooks/types.js +0 -62
  237. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.d.ts +0 -9
  238. package/v3/@claude-flow/shared/dist/hooks/verify-exports.test.js +0 -93
  239. package/v3/@claude-flow/shared/dist/index.d.ts +0 -20
  240. package/v3/@claude-flow/shared/dist/index.js +0 -50
  241. package/v3/@claude-flow/shared/dist/mcp/connection-pool.d.ts +0 -98
  242. package/v3/@claude-flow/shared/dist/mcp/connection-pool.js +0 -364
  243. package/v3/@claude-flow/shared/dist/mcp/index.d.ts +0 -69
  244. package/v3/@claude-flow/shared/dist/mcp/index.js +0 -84
  245. package/v3/@claude-flow/shared/dist/mcp/server.d.ts +0 -166
  246. package/v3/@claude-flow/shared/dist/mcp/server.js +0 -590
  247. package/v3/@claude-flow/shared/dist/mcp/session-manager.d.ts +0 -136
  248. package/v3/@claude-flow/shared/dist/mcp/session-manager.js +0 -335
  249. package/v3/@claude-flow/shared/dist/mcp/tool-registry.d.ts +0 -178
  250. package/v3/@claude-flow/shared/dist/mcp/tool-registry.js +0 -439
  251. package/v3/@claude-flow/shared/dist/mcp/transport/http.d.ts +0 -104
  252. package/v3/@claude-flow/shared/dist/mcp/transport/http.js +0 -476
  253. package/v3/@claude-flow/shared/dist/mcp/transport/index.d.ts +0 -102
  254. package/v3/@claude-flow/shared/dist/mcp/transport/index.js +0 -238
  255. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.d.ts +0 -104
  256. package/v3/@claude-flow/shared/dist/mcp/transport/stdio.js +0 -263
  257. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.d.ts +0 -133
  258. package/v3/@claude-flow/shared/dist/mcp/transport/websocket.js +0 -396
  259. package/v3/@claude-flow/shared/dist/mcp/types.d.ts +0 -436
  260. package/v3/@claude-flow/shared/dist/mcp/types.js +0 -54
  261. package/v3/@claude-flow/shared/dist/plugin-interface.d.ts +0 -544
  262. package/v3/@claude-flow/shared/dist/plugin-interface.js +0 -23
  263. package/v3/@claude-flow/shared/dist/plugin-loader.d.ts +0 -139
  264. package/v3/@claude-flow/shared/dist/plugin-loader.js +0 -434
  265. package/v3/@claude-flow/shared/dist/plugin-registry.d.ts +0 -183
  266. package/v3/@claude-flow/shared/dist/plugin-registry.js +0 -457
  267. package/v3/@claude-flow/shared/dist/plugins/index.d.ts +0 -10
  268. package/v3/@claude-flow/shared/dist/plugins/index.js +0 -10
  269. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.d.ts +0 -106
  270. package/v3/@claude-flow/shared/dist/plugins/official/hive-mind-plugin.js +0 -241
  271. package/v3/@claude-flow/shared/dist/plugins/official/index.d.ts +0 -10
  272. package/v3/@claude-flow/shared/dist/plugins/official/index.js +0 -10
  273. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.d.ts +0 -121
  274. package/v3/@claude-flow/shared/dist/plugins/official/maestro-plugin.js +0 -355
  275. package/v3/@claude-flow/shared/dist/plugins/types.d.ts +0 -93
  276. package/v3/@claude-flow/shared/dist/plugins/types.js +0 -9
  277. package/v3/@claude-flow/shared/dist/resilience/bulkhead.d.ts +0 -105
  278. package/v3/@claude-flow/shared/dist/resilience/bulkhead.js +0 -206
  279. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.d.ts +0 -132
  280. package/v3/@claude-flow/shared/dist/resilience/circuit-breaker.js +0 -233
  281. package/v3/@claude-flow/shared/dist/resilience/index.d.ts +0 -19
  282. package/v3/@claude-flow/shared/dist/resilience/index.js +0 -19
  283. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.d.ts +0 -168
  284. package/v3/@claude-flow/shared/dist/resilience/rate-limiter.js +0 -314
  285. package/v3/@claude-flow/shared/dist/resilience/retry.d.ts +0 -91
  286. package/v3/@claude-flow/shared/dist/resilience/retry.js +0 -159
  287. package/v3/@claude-flow/shared/dist/security/index.d.ts +0 -10
  288. package/v3/@claude-flow/shared/dist/security/index.js +0 -12
  289. package/v3/@claude-flow/shared/dist/security/input-validation.d.ts +0 -73
  290. package/v3/@claude-flow/shared/dist/security/input-validation.js +0 -201
  291. package/v3/@claude-flow/shared/dist/security/secure-random.d.ts +0 -92
  292. package/v3/@claude-flow/shared/dist/security/secure-random.js +0 -142
  293. package/v3/@claude-flow/shared/dist/services/index.d.ts +0 -7
  294. package/v3/@claude-flow/shared/dist/services/index.js +0 -7
  295. package/v3/@claude-flow/shared/dist/services/v3-progress.service.d.ts +0 -124
  296. package/v3/@claude-flow/shared/dist/services/v3-progress.service.js +0 -402
  297. package/v3/@claude-flow/shared/dist/types/agent.types.d.ts +0 -137
  298. package/v3/@claude-flow/shared/dist/types/agent.types.js +0 -6
  299. package/v3/@claude-flow/shared/dist/types/index.d.ts +0 -11
  300. package/v3/@claude-flow/shared/dist/types/index.js +0 -17
  301. package/v3/@claude-flow/shared/dist/types/mcp.types.d.ts +0 -266
  302. package/v3/@claude-flow/shared/dist/types/mcp.types.js +0 -7
  303. package/v3/@claude-flow/shared/dist/types/memory.types.d.ts +0 -236
  304. package/v3/@claude-flow/shared/dist/types/memory.types.js +0 -7
  305. package/v3/@claude-flow/shared/dist/types/swarm.types.d.ts +0 -186
  306. package/v3/@claude-flow/shared/dist/types/swarm.types.js +0 -65
  307. package/v3/@claude-flow/shared/dist/types/task.types.d.ts +0 -178
  308. package/v3/@claude-flow/shared/dist/types/task.types.js +0 -32
  309. package/v3/@claude-flow/shared/dist/types.d.ts +0 -197
  310. package/v3/@claude-flow/shared/dist/types.js +0 -21
  311. package/v3/@claude-flow/shared/dist/utils/secure-logger.d.ts +0 -69
  312. package/v3/@claude-flow/shared/dist/utils/secure-logger.js +0 -208
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Control precedence resolver — ADR-305 (normative).
3
+ *
4
+ * 1. RUFLO_FUNNEL=0 (environment)
5
+ * 2. Enterprise managed policy
6
+ * 3. User config (funnel.enabled — user-level and project-level)
7
+ * 4. Package default
8
+ * 5. Remote signed policy (only when the freshness feed is enabled)
9
+ *
10
+ * A lower-precedence source must never re-enable a higher-precedence
11
+ * disable — implemented as a strict AND chain: every source can veto,
12
+ * none can override a veto above it.
13
+ */
14
+ import * as fs from 'fs';
15
+ import * as path from 'path';
16
+ import { readStateJson } from './state.js';
17
+ import { getDisclosure } from './disclosure.js';
18
+ function envDisabled(env) {
19
+ const v = env.RUFLO_FUNNEL;
20
+ return v !== undefined && /^(0|false|off|no)$/i.test(v.trim());
21
+ }
22
+ function enterprisePolicyDisabled(env) {
23
+ const candidates = [];
24
+ if (env.RUFLO_ENTERPRISE_POLICY)
25
+ candidates.push(env.RUFLO_ENTERPRISE_POLICY);
26
+ if (process.platform === 'win32') {
27
+ if (env.ProgramData)
28
+ candidates.push(path.join(env.ProgramData, 'ruflo', 'policy.json'));
29
+ }
30
+ else {
31
+ candidates.push('/etc/ruflo/policy.json');
32
+ }
33
+ for (const p of candidates) {
34
+ try {
35
+ const policy = JSON.parse(fs.readFileSync(p, 'utf-8'));
36
+ if (policy?.funnel?.enabled === false)
37
+ return true;
38
+ }
39
+ catch {
40
+ // unreadable/absent policy is not a policy
41
+ }
42
+ }
43
+ return false;
44
+ }
45
+ function userConfigDisabled() {
46
+ const cfg = readStateJson('funnel.json');
47
+ return cfg?.enabled === false;
48
+ }
49
+ function projectConfigDisabled(cwd) {
50
+ try {
51
+ const cfg = JSON.parse(fs.readFileSync(path.join(cwd, 'claude-flow.config.json'), 'utf-8'));
52
+ return cfg?.funnel?.enabled === false;
53
+ }
54
+ catch {
55
+ return false;
56
+ }
57
+ }
58
+ /**
59
+ * Remote signed policy (ADR-305 freshness kill switch). The feed is opt-in
60
+ * and OFF by default; when a validated policy has been stored locally it can
61
+ * only disable — sitting at the bottom of the chain guarantees it can never
62
+ * re-enable anything a higher source turned off.
63
+ */
64
+ function remotePolicyDisabled() {
65
+ const policy = readStateJson('funnel-remote-policy.json');
66
+ return policy?.funnelEnabled === false;
67
+ }
68
+ export function resolveFunnelEnabled(cwd = process.cwd(), env = process.env) {
69
+ if (envDisabled(env))
70
+ return { enabled: false, decidedBy: 'env' };
71
+ if (enterprisePolicyDisabled(env))
72
+ return { enabled: false, decidedBy: 'enterprise-policy' };
73
+ if (userConfigDisabled())
74
+ return { enabled: false, decidedBy: 'user-config' };
75
+ if (projectConfigDisabled(cwd))
76
+ return { enabled: false, decidedBy: 'project-config' };
77
+ // Declining the disclosure disables all funnel surfaces (ADR-301 invariant).
78
+ if (getDisclosure().state === 'disclosed_disabled') {
79
+ return { enabled: false, decidedBy: 'disclosure-declined' };
80
+ }
81
+ if (remotePolicyDisabled())
82
+ return { enabled: false, decidedBy: 'remote-policy' };
83
+ return { enabled: true, decidedBy: 'package-default' };
84
+ }
85
+ //# sourceMappingURL=precedence.js.map
@@ -0,0 +1,41 @@
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 type { PromoRow } from './types.js';
22
+ import { type LocalInsightContext } from './insights.js';
23
+ export interface PromoContext {
24
+ cwd?: string;
25
+ env?: NodeJS.ProcessEnv;
26
+ now?: Date;
27
+ /**
28
+ * Whether the calling surface is an interactive session. The statusline
29
+ * hook is spawned with piped stdio by an interactive host, so the caller
30
+ * asserts interactivity; directly-run non-TTY invocations pass false.
31
+ */
32
+ interactive: boolean;
33
+ /**
34
+ * Local environment/task signal for the insight ticker (insights.ts) —
35
+ * optional and additive. Callers that don't pass it simply never see a
36
+ * local insight; the remote rotation is entirely unaffected either way.
37
+ */
38
+ localInsights?: LocalInsightContext;
39
+ }
40
+ export declare function getFunnelPromo(ctx: PromoContext): PromoRow | null;
41
+ //# sourceMappingURL=promo.d.ts.map
@@ -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