@reefclaw/connect 0.1.11 → 0.1.12

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 (397) hide show
  1. package/assets/bridge/gateway/heartbeat-cron.d.ts +27 -0
  2. package/assets/bridge/gateway/heartbeat-cron.js +85 -0
  3. package/assets/bridge/providers/gateway.d.ts +2 -0
  4. package/assets/bridge/providers/gateway.js +57 -16
  5. package/assets/bridge/setup.js +6 -51
  6. package/dist/deps.js +2 -2
  7. package/dist/plugin.js +35 -7
  8. package/package.json +1 -1
  9. package/assets/plugin/audit/mode-transition-audit.d.ts +0 -11
  10. package/assets/plugin/audit/mode-transition-audit.js +0 -29
  11. package/assets/plugin/balance-utils.d.ts +0 -36
  12. package/assets/plugin/balance-utils.js +0 -98
  13. package/assets/plugin/ccxt/binance-ban-gate.d.ts +0 -47
  14. package/assets/plugin/ccxt/binance-ban-gate.js +0 -420
  15. package/assets/plugin/ccxt/binance-private.d.ts +0 -346
  16. package/assets/plugin/ccxt/binance-private.js +0 -1525
  17. package/assets/plugin/ccxt/binance-public.d.ts +0 -34
  18. package/assets/plugin/ccxt/binance-public.js +0 -180
  19. package/assets/plugin/ccxt/intel-public.d.ts +0 -25
  20. package/assets/plugin/ccxt/intel-public.js +0 -80
  21. package/assets/plugin/ccxt/public-market-data-api.d.ts +0 -26
  22. package/assets/plugin/ccxt/public-market-data-api.js +0 -23
  23. package/assets/plugin/config/agent-config-client.d.ts +0 -77
  24. package/assets/plugin/config/agent-config-client.js +0 -188
  25. package/assets/plugin/config/agent-config-poller.d.ts +0 -32
  26. package/assets/plugin/config/agent-config-poller.js +0 -101
  27. package/assets/plugin/config/brackets-config.d.ts +0 -22
  28. package/assets/plugin/config/brackets-config.js +0 -58
  29. package/assets/plugin/config/entitlement-gate.d.ts +0 -51
  30. package/assets/plugin/config/entitlement-gate.js +0 -137
  31. package/assets/plugin/config/gate-store.d.ts +0 -18
  32. package/assets/plugin/config/gate-store.js +0 -61
  33. package/assets/plugin/config/plugin-config-io.d.ts +0 -222
  34. package/assets/plugin/config/plugin-config-io.js +0 -126
  35. package/assets/plugin/config/position-review-config.d.ts +0 -35
  36. package/assets/plugin/config/position-review-config.js +0 -105
  37. package/assets/plugin/config/tool-gate.d.ts +0 -53
  38. package/assets/plugin/config/tool-gate.js +0 -128
  39. package/assets/plugin/config/user-data-stream-config.d.ts +0 -89
  40. package/assets/plugin/config/user-data-stream-config.js +0 -239
  41. package/assets/plugin/connector-supervisor.d.ts +0 -36
  42. package/assets/plugin/connector-supervisor.js +0 -149
  43. package/assets/plugin/exchange-adapter.d.ts +0 -65
  44. package/assets/plugin/exchange-adapter.js +0 -4
  45. package/assets/plugin/index.d.ts +0 -30
  46. package/assets/plugin/index.js +0 -2756
  47. package/assets/plugin/ingest/pending-entry-metadata.d.ts +0 -74
  48. package/assets/plugin/ingest/pending-entry-metadata.js +0 -236
  49. package/assets/plugin/ingest/position-auto-capture.d.ts +0 -171
  50. package/assets/plugin/ingest/position-auto-capture.js +0 -709
  51. package/assets/plugin/ingest/position-decisions-client.d.ts +0 -327
  52. package/assets/plugin/ingest/position-decisions-client.js +0 -306
  53. package/assets/plugin/ingest/readiness-reporter.d.ts +0 -42
  54. package/assets/plugin/ingest/readiness-reporter.js +0 -163
  55. package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +0 -51
  56. package/assets/plugin/ingest/reconcile-db-vs-exchange.js +0 -170
  57. package/assets/plugin/ingest/reconciler-cleanup.d.ts +0 -37
  58. package/assets/plugin/ingest/reconciler-cleanup.js +0 -147
  59. package/assets/plugin/ingest/rest-gap-filler.d.ts +0 -191
  60. package/assets/plugin/ingest/rest-gap-filler.js +0 -565
  61. package/assets/plugin/ingest/touched-symbols-store.d.ts +0 -25
  62. package/assets/plugin/ingest/touched-symbols-store.js +0 -96
  63. package/assets/plugin/ingest/trade-store-client.d.ts +0 -40
  64. package/assets/plugin/ingest/trade-store-client.js +0 -125
  65. package/assets/plugin/ingest/ws-ingest.d.ts +0 -43
  66. package/assets/plugin/ingest/ws-ingest.js +0 -126
  67. package/assets/plugin/learning/setup-family.d.ts +0 -21
  68. package/assets/plugin/learning/setup-family.js +0 -103
  69. package/assets/plugin/lifecycle/install-signal-handlers.d.ts +0 -33
  70. package/assets/plugin/lifecycle/install-signal-handlers.js +0 -112
  71. package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +0 -43
  72. package/assets/plugin/lifecycle/shutdown-coordinator.js +0 -131
  73. package/assets/plugin/lifecycle/trading-operation-lock.d.ts +0 -17
  74. package/assets/plugin/lifecycle/trading-operation-lock.js +0 -14
  75. package/assets/plugin/live/bracket-id.d.ts +0 -26
  76. package/assets/plugin/live/bracket-id.js +0 -112
  77. package/assets/plugin/live/bracket-ledger.d.ts +0 -54
  78. package/assets/plugin/live/bracket-ledger.js +0 -267
  79. package/assets/plugin/live/bracket-manager.d.ts +0 -82
  80. package/assets/plugin/live/bracket-manager.js +0 -478
  81. package/assets/plugin/live/bracket-params.d.ts +0 -22
  82. package/assets/plugin/live/bracket-params.js +0 -124
  83. package/assets/plugin/live/bracket-reconciler.d.ts +0 -95
  84. package/assets/plugin/live/bracket-reconciler.js +0 -573
  85. package/assets/plugin/live/bracket-types.d.ts +0 -102
  86. package/assets/plugin/live/bracket-types.js +0 -8
  87. package/assets/plugin/live/deposit-tracker.d.ts +0 -62
  88. package/assets/plugin/live/deposit-tracker.js +0 -97
  89. package/assets/plugin/live/emergency-controls.d.ts +0 -32
  90. package/assets/plugin/live/emergency-controls.js +0 -226
  91. package/assets/plugin/live/exchange-errors.d.ts +0 -12
  92. package/assets/plugin/live/exchange-errors.js +0 -130
  93. package/assets/plugin/live/exchange-info-cache.d.ts +0 -37
  94. package/assets/plugin/live/exchange-info-cache.js +0 -134
  95. package/assets/plugin/live/fact-subscriber.d.ts +0 -78
  96. package/assets/plugin/live/fact-subscriber.js +0 -182
  97. package/assets/plugin/live/fill-price.d.ts +0 -13
  98. package/assets/plugin/live/fill-price.js +0 -37
  99. package/assets/plugin/live/intent-journal.d.ts +0 -42
  100. package/assets/plugin/live/intent-journal.js +0 -122
  101. package/assets/plugin/live/listen-key-manager.d.ts +0 -70
  102. package/assets/plugin/live/listen-key-manager.js +0 -169
  103. package/assets/plugin/live/live-adapter.d.ts +0 -319
  104. package/assets/plugin/live/live-adapter.js +0 -1906
  105. package/assets/plugin/live/live-balance-enricher.d.ts +0 -32
  106. package/assets/plugin/live/live-balance-enricher.js +0 -104
  107. package/assets/plugin/live/live-bracket-api.d.ts +0 -13
  108. package/assets/plugin/live/live-bracket-api.js +0 -20
  109. package/assets/plugin/live/live-state-store.d.ts +0 -194
  110. package/assets/plugin/live/live-state-store.js +0 -450
  111. package/assets/plugin/live/local-signal-service.d.ts +0 -57
  112. package/assets/plugin/live/local-signal-service.js +0 -151
  113. package/assets/plugin/live/local-strategy-evaluator.d.ts +0 -62
  114. package/assets/plugin/live/local-strategy-evaluator.js +0 -131
  115. package/assets/plugin/live/microstructure-assembler.d.ts +0 -54
  116. package/assets/plugin/live/microstructure-assembler.js +0 -148
  117. package/assets/plugin/live/order-poller.d.ts +0 -29
  118. package/assets/plugin/live/order-poller.js +0 -125
  119. package/assets/plugin/live/position-state-store.d.ts +0 -87
  120. package/assets/plugin/live/position-state-store.js +0 -237
  121. package/assets/plugin/live/proposal-decision-listener.d.ts +0 -70
  122. package/assets/plugin/live/proposal-decision-listener.js +0 -292
  123. package/assets/plugin/live/proposal-manager.d.ts +0 -76
  124. package/assets/plugin/live/proposal-manager.js +0 -140
  125. package/assets/plugin/live/rate-limiter.d.ts +0 -47
  126. package/assets/plugin/live/rate-limiter.js +0 -159
  127. package/assets/plugin/live/reconciler.d.ts +0 -39
  128. package/assets/plugin/live/reconciler.js +0 -175
  129. package/assets/plugin/live/setup-buckets.d.ts +0 -7
  130. package/assets/plugin/live/setup-buckets.js +0 -33
  131. package/assets/plugin/live/slippage-tracker.d.ts +0 -45
  132. package/assets/plugin/live/slippage-tracker.js +0 -78
  133. package/assets/plugin/live/stop-watcher.d.ts +0 -67
  134. package/assets/plugin/live/stop-watcher.js +0 -218
  135. package/assets/plugin/live/user-data-active-probe.d.ts +0 -54
  136. package/assets/plugin/live/user-data-active-probe.js +0 -180
  137. package/assets/plugin/live/user-data-stream-controller.d.ts +0 -200
  138. package/assets/plugin/live/user-data-stream-controller.js +0 -579
  139. package/assets/plugin/live/user-data-stream-ws.d.ts +0 -22
  140. package/assets/plugin/live/user-data-stream-ws.js +0 -63
  141. package/assets/plugin/live/user-data-stream.d.ts +0 -243
  142. package/assets/plugin/live/user-data-stream.js +0 -704
  143. package/assets/plugin/logger.d.ts +0 -2
  144. package/assets/plugin/logger.js +0 -2
  145. package/assets/plugin/mfe.d.ts +0 -21
  146. package/assets/plugin/mfe.js +0 -68
  147. package/assets/plugin/onboarding/mode-ladder.d.ts +0 -1
  148. package/assets/plugin/onboarding/mode-ladder.js +0 -3
  149. package/assets/plugin/onboarding/runtime.d.ts +0 -90
  150. package/assets/plugin/onboarding/runtime.js +0 -184
  151. package/assets/plugin/openclaw.plugin.json +0 -92
  152. package/assets/plugin/paper-adapter.d.ts +0 -24
  153. package/assets/plugin/paper-adapter.js +0 -91
  154. package/assets/plugin/persistence/state-manager.d.ts +0 -66
  155. package/assets/plugin/persistence/state-manager.js +0 -222
  156. package/assets/plugin/pinned-plan.d.ts +0 -9
  157. package/assets/plugin/pinned-plan.js +0 -23
  158. package/assets/plugin/portfolio/reentry-tracker.d.ts +0 -36
  159. package/assets/plugin/portfolio/reentry-tracker.js +0 -127
  160. package/assets/plugin/portfolio/wave9-admission.d.ts +0 -67
  161. package/assets/plugin/portfolio/wave9-admission.js +0 -262
  162. package/assets/plugin/portfolio/wave9-policy.d.ts +0 -36
  163. package/assets/plugin/portfolio/wave9-policy.js +0 -183
  164. package/assets/plugin/risk/pre-trade-check.d.ts +0 -38
  165. package/assets/plugin/risk/pre-trade-check.js +0 -345
  166. package/assets/plugin/risk/pre-trade-types.d.ts +0 -60
  167. package/assets/plugin/risk/pre-trade-types.js +0 -3
  168. package/assets/plugin/shadow/shadow-tracker.d.ts +0 -36
  169. package/assets/plugin/shadow/shadow-tracker.js +0 -151
  170. package/assets/plugin/shadow/types.d.ts +0 -42
  171. package/assets/plugin/shadow/types.js +0 -20
  172. package/assets/plugin/shared/indicators-extended.d.ts +0 -52
  173. package/assets/plugin/shared/indicators-extended.js +0 -291
  174. package/assets/plugin/shared/indicators.d.ts +0 -15
  175. package/assets/plugin/shared/indicators.js +0 -114
  176. package/assets/plugin/signals/conditions/registry.d.ts +0 -16
  177. package/assets/plugin/signals/conditions/registry.js +0 -1333
  178. package/assets/plugin/signals/conditions/types.d.ts +0 -1
  179. package/assets/plugin/signals/conditions/types.js +0 -4
  180. package/assets/plugin/signals/direction-rules.d.ts +0 -3
  181. package/assets/plugin/signals/direction-rules.js +0 -24
  182. package/assets/plugin/signals/entry-rules.d.ts +0 -6
  183. package/assets/plugin/signals/entry-rules.js +0 -33
  184. package/assets/plugin/signals/serialize-context.d.ts +0 -4
  185. package/assets/plugin/signals/serialize-context.js +0 -39
  186. package/assets/plugin/signals/stop-rules.d.ts +0 -3
  187. package/assets/plugin/signals/stop-rules.js +0 -48
  188. package/assets/plugin/signals/strategy-adapter.d.ts +0 -47
  189. package/assets/plugin/signals/strategy-adapter.js +0 -209
  190. package/assets/plugin/signals/types.d.ts +0 -1
  191. package/assets/plugin/signals/types.js +0 -8
  192. package/assets/plugin/simulator/exchange-simulator.d.ts +0 -105
  193. package/assets/plugin/simulator/exchange-simulator.js +0 -759
  194. package/assets/plugin/simulator/fill-engine.d.ts +0 -53
  195. package/assets/plugin/simulator/fill-engine.js +0 -280
  196. package/assets/plugin/simulator/paper-market-feed.d.ts +0 -26
  197. package/assets/plugin/simulator/paper-market-feed.js +0 -104
  198. package/assets/plugin/simulator/realistic-fills.d.ts +0 -59
  199. package/assets/plugin/simulator/realistic-fills.js +0 -175
  200. package/assets/plugin/simulator/types.d.ts +0 -228
  201. package/assets/plugin/simulator/types.js +0 -43
  202. package/assets/plugin/strategy/builtin-strategies.d.ts +0 -2
  203. package/assets/plugin/strategy/builtin-strategies.js +0 -113
  204. package/assets/plugin/strategy/condition-registry.d.ts +0 -3
  205. package/assets/plugin/strategy/condition-registry.js +0 -153
  206. package/assets/plugin/strategy/evaluator.d.ts +0 -70
  207. package/assets/plugin/strategy/evaluator.js +0 -98
  208. package/assets/plugin/tools/assessment-validation.d.ts +0 -141
  209. package/assets/plugin/tools/assessment-validation.js +0 -473
  210. package/assets/plugin/tools/attach-brackets.d.ts +0 -39
  211. package/assets/plugin/tools/attach-brackets.js +0 -564
  212. package/assets/plugin/tools/audit-bracket-protection.d.ts +0 -49
  213. package/assets/plugin/tools/audit-bracket-protection.js +0 -683
  214. package/assets/plugin/tools/bracket-control.d.ts +0 -12
  215. package/assets/plugin/tools/bracket-control.js +0 -35
  216. package/assets/plugin/tools/cancel-all-orders.d.ts +0 -9
  217. package/assets/plugin/tools/cancel-all-orders.js +0 -8
  218. package/assets/plugin/tools/cancel-order.d.ts +0 -14
  219. package/assets/plugin/tools/cancel-order.js +0 -60
  220. package/assets/plugin/tools/check-position-health.d.ts +0 -46
  221. package/assets/plugin/tools/check-position-health.js +0 -194
  222. package/assets/plugin/tools/clear-exchange-credentials.d.ts +0 -24
  223. package/assets/plugin/tools/clear-exchange-credentials.js +0 -70
  224. package/assets/plugin/tools/close-position.d.ts +0 -45
  225. package/assets/plugin/tools/close-position.js +0 -722
  226. package/assets/plugin/tools/create-order.d.ts +0 -82
  227. package/assets/plugin/tools/create-order.js +0 -1544
  228. package/assets/plugin/tools/exit-gate.d.ts +0 -58
  229. package/assets/plugin/tools/exit-gate.js +0 -162
  230. package/assets/plugin/tools/fetch-balance.d.ts +0 -5
  231. package/assets/plugin/tools/fetch-balance.js +0 -4
  232. package/assets/plugin/tools/fetch-ohlcv.d.ts +0 -11
  233. package/assets/plugin/tools/fetch-ohlcv.js +0 -8
  234. package/assets/plugin/tools/fetch-open-orders.d.ts +0 -7
  235. package/assets/plugin/tools/fetch-open-orders.js +0 -4
  236. package/assets/plugin/tools/fetch-positions.d.ts +0 -7
  237. package/assets/plugin/tools/fetch-positions.js +0 -4
  238. package/assets/plugin/tools/fetch-ticker.d.ts +0 -11
  239. package/assets/plugin/tools/fetch-ticker.js +0 -5
  240. package/assets/plugin/tools/get-agent-profile.d.ts +0 -4
  241. package/assets/plugin/tools/get-agent-profile.js +0 -6
  242. package/assets/plugin/tools/get-analytics.d.ts +0 -6
  243. package/assets/plugin/tools/get-analytics.js +0 -7
  244. package/assets/plugin/tools/get-backtest.d.ts +0 -12
  245. package/assets/plugin/tools/get-backtest.js +0 -91
  246. package/assets/plugin/tools/get-basis.d.ts +0 -7
  247. package/assets/plugin/tools/get-basis.js +0 -7
  248. package/assets/plugin/tools/get-bracket-config.d.ts +0 -11
  249. package/assets/plugin/tools/get-bracket-config.js +0 -24
  250. package/assets/plugin/tools/get-cascade-risk.d.ts +0 -7
  251. package/assets/plugin/tools/get-cascade-risk.js +0 -8
  252. package/assets/plugin/tools/get-crypto-metrics.d.ts +0 -18
  253. package/assets/plugin/tools/get-crypto-metrics.js +0 -62
  254. package/assets/plugin/tools/get-cvd.d.ts +0 -6
  255. package/assets/plugin/tools/get-cvd.js +0 -6
  256. package/assets/plugin/tools/get-divergences.d.ts +0 -6
  257. package/assets/plugin/tools/get-divergences.js +0 -6
  258. package/assets/plugin/tools/get-funding-context.d.ts +0 -6
  259. package/assets/plugin/tools/get-funding-context.js +0 -16
  260. package/assets/plugin/tools/get-liquidation-levels.d.ts +0 -7
  261. package/assets/plugin/tools/get-liquidation-levels.js +0 -7
  262. package/assets/plugin/tools/get-liquidation-pulse.d.ts +0 -9
  263. package/assets/plugin/tools/get-liquidation-pulse.js +0 -22
  264. package/assets/plugin/tools/get-market-breadth.d.ts +0 -6
  265. package/assets/plugin/tools/get-market-breadth.js +0 -8
  266. package/assets/plugin/tools/get-market-intel.d.ts +0 -19
  267. package/assets/plugin/tools/get-market-intel.js +0 -116
  268. package/assets/plugin/tools/get-market-structure.d.ts +0 -47
  269. package/assets/plugin/tools/get-market-structure.js +0 -198
  270. package/assets/plugin/tools/get-my-mined-patterns.d.ts +0 -20
  271. package/assets/plugin/tools/get-my-mined-patterns.js +0 -61
  272. package/assets/plugin/tools/get-my-proposed-learnings.d.ts +0 -20
  273. package/assets/plugin/tools/get-my-proposed-learnings.js +0 -55
  274. package/assets/plugin/tools/get-my-recent-reviews.d.ts +0 -22
  275. package/assets/plugin/tools/get-my-recent-reviews.js +0 -66
  276. package/assets/plugin/tools/get-orderbook.d.ts +0 -21
  277. package/assets/plugin/tools/get-orderbook.js +0 -32
  278. package/assets/plugin/tools/get-pattern-scan.d.ts +0 -7
  279. package/assets/plugin/tools/get-pattern-scan.js +0 -8
  280. package/assets/plugin/tools/get-regime.d.ts +0 -6
  281. package/assets/plugin/tools/get-regime.js +0 -7
  282. package/assets/plugin/tools/get-relevant-learnings.d.ts +0 -21
  283. package/assets/plugin/tools/get-relevant-learnings.js +0 -65
  284. package/assets/plugin/tools/get-resting-liquidity.d.ts +0 -6
  285. package/assets/plugin/tools/get-resting-liquidity.js +0 -11
  286. package/assets/plugin/tools/get-risk-scenario.d.ts +0 -29
  287. package/assets/plugin/tools/get-risk-scenario.js +0 -47
  288. package/assets/plugin/tools/get-risk-summary.d.ts +0 -51
  289. package/assets/plugin/tools/get-risk-summary.js +0 -118
  290. package/assets/plugin/tools/get-sentiment.d.ts +0 -4
  291. package/assets/plugin/tools/get-sentiment.js +0 -6
  292. package/assets/plugin/tools/get-session-review.d.ts +0 -7
  293. package/assets/plugin/tools/get-session-review.js +0 -8
  294. package/assets/plugin/tools/get-setup-detail.d.ts +0 -7
  295. package/assets/plugin/tools/get-setup-detail.js +0 -322
  296. package/assets/plugin/tools/get-signals.d.ts +0 -15
  297. package/assets/plugin/tools/get-signals.js +0 -54
  298. package/assets/plugin/tools/get-sizing.d.ts +0 -6
  299. package/assets/plugin/tools/get-sizing.js +0 -6
  300. package/assets/plugin/tools/get-trade-feedback.d.ts +0 -7
  301. package/assets/plugin/tools/get-trade-feedback.js +0 -8
  302. package/assets/plugin/tools/get-trade-flow.d.ts +0 -7
  303. package/assets/plugin/tools/get-trade-flow.js +0 -7
  304. package/assets/plugin/tools/get-volume-analysis.d.ts +0 -21
  305. package/assets/plugin/tools/get-volume-analysis.js +0 -74
  306. package/assets/plugin/tools/get-volume-profile.d.ts +0 -7
  307. package/assets/plugin/tools/get-volume-profile.js +0 -7
  308. package/assets/plugin/tools/get-wave9-status.d.ts +0 -127
  309. package/assets/plugin/tools/get-wave9-status.js +0 -796
  310. package/assets/plugin/tools/helpers.d.ts +0 -26
  311. package/assets/plugin/tools/helpers.js +0 -39
  312. package/assets/plugin/tools/intel-api.d.ts +0 -34
  313. package/assets/plugin/tools/intel-api.js +0 -119
  314. package/assets/plugin/tools/intel-cache.d.ts +0 -25
  315. package/assets/plugin/tools/intel-cache.js +0 -148
  316. package/assets/plugin/tools/list-strategies.d.ts +0 -17
  317. package/assets/plugin/tools/list-strategies.js +0 -23
  318. package/assets/plugin/tools/modify-stop.d.ts +0 -21
  319. package/assets/plugin/tools/modify-stop.js +0 -120
  320. package/assets/plugin/tools/modify-target.d.ts +0 -21
  321. package/assets/plugin/tools/modify-target.js +0 -110
  322. package/assets/plugin/tools/propose-learning.d.ts +0 -22
  323. package/assets/plugin/tools/propose-learning.js +0 -65
  324. package/assets/plugin/tools/query-review-outcomes.d.ts +0 -30
  325. package/assets/plugin/tools/query-review-outcomes.js +0 -64
  326. package/assets/plugin/tools/query-trades.d.ts +0 -21
  327. package/assets/plugin/tools/query-trades.js +0 -37
  328. package/assets/plugin/tools/record-position-reviews.d.ts +0 -38
  329. package/assets/plugin/tools/record-position-reviews.js +0 -147
  330. package/assets/plugin/tools/save-strategy.d.ts +0 -16
  331. package/assets/plugin/tools/save-strategy.js +0 -46
  332. package/assets/plugin/tools/scan-pairs.d.ts +0 -22
  333. package/assets/plugin/tools/scan-pairs.js +0 -234
  334. package/assets/plugin/tools/score-setup.d.ts +0 -31
  335. package/assets/plugin/tools/score-setup.js +0 -268
  336. package/assets/plugin/tools/set-bracket-requirement.d.ts +0 -18
  337. package/assets/plugin/tools/set-bracket-requirement.js +0 -81
  338. package/assets/plugin/tools/set-exchange-credentials.d.ts +0 -25
  339. package/assets/plugin/tools/set-exchange-credentials.js +0 -80
  340. package/assets/plugin/tools/set-trading-mode.d.ts +0 -26
  341. package/assets/plugin/tools/set-trading-mode.js +0 -135
  342. package/assets/plugin/tools/test-exchange-credentials.d.ts +0 -16
  343. package/assets/plugin/tools/test-exchange-credentials.js +0 -100
  344. package/assets/plugin/tools/toggle-strategy.d.ts +0 -8
  345. package/assets/plugin/tools/toggle-strategy.js +0 -15
  346. package/assets/plugin/trading-params-cache.d.ts +0 -26
  347. package/assets/plugin/trading-params-cache.js +0 -52
  348. package/assets/plugin/types.d.ts +0 -134
  349. package/assets/plugin/types.js +0 -7
  350. package/assets/plugin/util/plugin-paths.d.ts +0 -3
  351. package/assets/plugin/util/plugin-paths.js +0 -15
  352. package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +0 -116
  353. package/assets/plugin/venues/hyperliquid/hl-balance.js +0 -145
  354. package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.d.ts +0 -123
  355. package/assets/plugin/venues/hyperliquid/hl-bracket-coordinator.js +0 -533
  356. package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +0 -102
  357. package/assets/plugin/venues/hyperliquid/hl-brackets.js +0 -172
  358. package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +0 -22
  359. package/assets/plugin/venues/hyperliquid/hl-cloid.js +0 -82
  360. package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +0 -46
  361. package/assets/plugin/venues/hyperliquid/hl-info-cache.js +0 -125
  362. package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +0 -146
  363. package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +0 -728
  364. package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +0 -61
  365. package/assets/plugin/venues/hyperliquid/hl-precision.js +0 -176
  366. package/assets/plugin/venues/hyperliquid/hl-private.d.ts +0 -88
  367. package/assets/plugin/venues/hyperliquid/hl-private.js +0 -357
  368. package/assets/plugin/venues/hyperliquid/hl-public.d.ts +0 -79
  369. package/assets/plugin/venues/hyperliquid/hl-public.js +0 -436
  370. package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +0 -57
  371. package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +0 -220
  372. package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +0 -90
  373. package/assets/plugin/venues/hyperliquid/hl-user-stream.js +0 -220
  374. package/assets/plugin/venues/registry.d.ts +0 -38
  375. package/assets/plugin/venues/registry.js +0 -46
  376. package/assets/plugin/venues/symbols.d.ts +0 -43
  377. package/assets/plugin/venues/symbols.js +0 -107
  378. package/assets/plugin/wave9/live-account-capture.d.ts +0 -67
  379. package/assets/plugin/wave9/live-account-capture.js +0 -435
  380. package/assets/plugin/wave9/live-autonomous-protection.d.ts +0 -39
  381. package/assets/plugin/wave9/live-autonomous-protection.js +0 -112
  382. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +0 -33
  383. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +0 -115
  384. package/assets/plugin/wave9/live-execution-ledger.d.ts +0 -107
  385. package/assets/plugin/wave9/live-execution-ledger.js +0 -498
  386. package/assets/plugin/wave9/live-position-confirmation.d.ts +0 -18
  387. package/assets/plugin/wave9/live-position-confirmation.js +0 -111
  388. package/assets/plugin/wave9/live-residual-protection.d.ts +0 -18
  389. package/assets/plugin/wave9/live-residual-protection.js +0 -250
  390. package/assets/plugin/wave9/live-startup-reconciliation.d.ts +0 -38
  391. package/assets/plugin/wave9/live-startup-reconciliation.js +0 -454
  392. package/assets/plugin/wave9/live-symbol-ownership.d.ts +0 -20
  393. package/assets/plugin/wave9/live-symbol-ownership.js +0 -132
  394. package/assets/plugin/wave9/paper-admission-guard.d.ts +0 -199
  395. package/assets/plugin/wave9/paper-admission-guard.js +0 -650
  396. package/assets/plugin/wave9/usdm-evidence-provider.d.ts +0 -42
  397. package/assets/plugin/wave9/usdm-evidence-provider.js +0 -133
@@ -0,0 +1,27 @@
1
+ export declare const HEARTBEAT_CRON_NAME = "reefclaw-heartbeat";
2
+ export declare const HEARTBEAT_EVERY_MS: number;
3
+ export declare const HEARTBEAT_MESSAGE: string;
4
+ export interface CronRpcClient {
5
+ sendRpc(method: string, params?: Record<string, unknown>): Promise<unknown>;
6
+ }
7
+ /**
8
+ * Whether an existing cron job counts as "the heartbeat already exists".
9
+ * Union of the two matchers already in the codebase: the old setup path
10
+ * matched /reefclaw/, while resolveHeartbeatSeconds() (the cadence reader that
11
+ * drives the dashboard header) matches /heart\s*beat/. A job satisfying either
12
+ * must suppress creation — prod/wisekid boxes carry heartbeat jobs whose names
13
+ * predate the reefclaw- prefix, and a duplicate 15m heartbeat would double the
14
+ * agent's token burn.
15
+ */
16
+ export declare function isHeartbeatLikeName(name: unknown): boolean;
17
+ export type EnsureHeartbeatOutcome = 'already_ensured' | 'found_existing' | 'created' | 'failed';
18
+ /**
19
+ * Ensure a heartbeat cron exists. Non-fatal by contract: every failure path
20
+ * returns 'failed' rather than throwing, and only success writes the marker so
21
+ * a transient gateway error retries on the next boot.
22
+ */
23
+ export declare function ensureHeartbeatCron(opts: {
24
+ rpc: CronRpcClient;
25
+ markerPath: string;
26
+ log: (msg: string) => void;
27
+ }): Promise<EnsureHeartbeatOutcome>;
@@ -0,0 +1,85 @@
1
+ // Ensures the ReefClaw heartbeat cron job exists — once per install — via
2
+ // gateway RPC (`cron.list` / `cron.add`).
3
+ //
4
+ // This replaces the old setup-time shell-out to the openclaw CLI. The CLI's
5
+ // cron commands are themselves gateway RPC clients, so shelling out bought
6
+ // nothing except a subprocess + PATH dependency — and it ran at
7
+ // setup time, when the gateway is typically NOT up yet (setup's printed next
8
+ // step is "Start your OpenClaw agent"), which is why creation silently
9
+ // no-op'd on fresh installs without a running gateway. The bridge holds an
10
+ // authenticated gateway WS by construction, so the ensure runs there instead.
11
+ //
12
+ // Once-per-install semantics: a marker file records that the ensure has run to
13
+ // completion. Without it, a user who deliberately deleted their heartbeat cron
14
+ // would get it resurrected on every bridge boot — the old setup-time path ran
15
+ // once, and that operator-override behaviour must be preserved.
16
+ import { existsSync, mkdirSync, writeFileSync } from 'fs';
17
+ import { dirname } from 'path';
18
+ export const HEARTBEAT_CRON_NAME = 'reefclaw-heartbeat';
19
+ export const HEARTBEAT_EVERY_MS = 15 * 60 * 1000;
20
+ // Byte-identical to the message the setup-time CLI path created, so new jobs
21
+ // match every existing install's job.
22
+ export const HEARTBEAT_MESSAGE = 'Heartbeat. Run SESSION START mandatory checks, then the full Decision Loop (Steps 0-9) from SKILL.md. ' +
23
+ 'Check tradingMode from fetch_balance — it is your source of truth for paper vs live. ' +
24
+ 'Use tools in parallel where possible.';
25
+ /**
26
+ * Whether an existing cron job counts as "the heartbeat already exists".
27
+ * Union of the two matchers already in the codebase: the old setup path
28
+ * matched /reefclaw/, while resolveHeartbeatSeconds() (the cadence reader that
29
+ * drives the dashboard header) matches /heart\s*beat/. A job satisfying either
30
+ * must suppress creation — prod/wisekid boxes carry heartbeat jobs whose names
31
+ * predate the reefclaw- prefix, and a duplicate 15m heartbeat would double the
32
+ * agent's token burn.
33
+ */
34
+ export function isHeartbeatLikeName(name) {
35
+ return typeof name === 'string' && /reefclaw|heart\s*beat/i.test(name);
36
+ }
37
+ /**
38
+ * Ensure a heartbeat cron exists. Non-fatal by contract: every failure path
39
+ * returns 'failed' rather than throwing, and only success writes the marker so
40
+ * a transient gateway error retries on the next boot.
41
+ */
42
+ export async function ensureHeartbeatCron(opts) {
43
+ const { rpc, markerPath, log } = opts;
44
+ try {
45
+ if (existsSync(markerPath))
46
+ return 'already_ensured';
47
+ // includeDisabled: a job the user disabled still means "exists" — re-adding
48
+ // a duplicate next to a deliberately-disabled one is worse than doing nothing.
49
+ const listResp = (await rpc.sendRpc('cron.list', { includeDisabled: true }));
50
+ const jobs = Array.isArray(listResp?.jobs) ? listResp.jobs : null;
51
+ if (!jobs) {
52
+ log('Heartbeat cron: skipped (cron.list returned no job list)');
53
+ return 'failed';
54
+ }
55
+ const existing = jobs.find((j) => isHeartbeatLikeName(j?.name));
56
+ if (existing) {
57
+ writeMarker(markerPath, { ensuredAt: new Date().toISOString(), found: String(existing.name) });
58
+ log(`Heartbeat cron: already exists (${String(existing.name)})`);
59
+ return 'found_existing';
60
+ }
61
+ // Parity with the params the CLI built for the old setup command
62
+ // (`openclaw cron add --name reefclaw-heartbeat --every 15m --session isolated --message ...`):
63
+ // isolated agentTurn defaults to delivery announce on the 'last' channel.
64
+ await rpc.sendRpc('cron.add', {
65
+ name: HEARTBEAT_CRON_NAME,
66
+ enabled: true,
67
+ schedule: { kind: 'every', everyMs: HEARTBEAT_EVERY_MS },
68
+ sessionTarget: 'isolated',
69
+ wakeMode: 'now',
70
+ payload: { kind: 'agentTurn', message: HEARTBEAT_MESSAGE },
71
+ delivery: { mode: 'announce', channel: 'last' },
72
+ });
73
+ writeMarker(markerPath, { ensuredAt: new Date().toISOString(), created: HEARTBEAT_CRON_NAME });
74
+ log(`Heartbeat cron: created (${HEARTBEAT_CRON_NAME}, every 15m)`);
75
+ return 'created';
76
+ }
77
+ catch (err) {
78
+ log(`Heartbeat cron: skipped (${err instanceof Error ? err.message.split('\n')[0] : String(err)})`);
79
+ return 'failed';
80
+ }
81
+ }
82
+ function writeMarker(markerPath, data) {
83
+ mkdirSync(dirname(markerPath), { recursive: true });
84
+ writeFileSync(markerPath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
85
+ }
@@ -29,6 +29,8 @@ export declare class GatewayProvider implements OpenClawProvider {
29
29
  private agentIdentity;
30
30
  /** Emit the one-time rollout probe (gateway response shape) only on the first attempt. */
31
31
  private loggedAgentIdentityProbe;
32
+ /** One-shot latch for the boot-time heartbeat-cron ensure (re-armed on failure). */
33
+ private heartbeatCronEnsureStarted;
32
34
  /** Live heartbeat cadence (seconds), read from the OpenClaw cron store; cached 60s. */
33
35
  private heartbeatSeconds?;
34
36
  private heartbeatReadAtMs;
@@ -11,16 +11,26 @@ import { GatewayWsClient } from '../gateway/gateway-ws-client.js';
11
11
  import { discoverTools } from '../gateway/tool-discovery.js';
12
12
  import { EventParser, mapCcxtBalance, mapCcxtOrder, extractLiquidationFields, extractBracketField, } from '../gateway/event-parser.js';
13
13
  import { Poller } from '../gateway/poller.js';
14
+ import { ensureHeartbeatCron } from '../gateway/heartbeat-cron.js';
14
15
  import { computeEquity as _computeEquity, computePositionNotional as _computePositionNotional, computeRiskMetrics as _computeRiskMetrics, DEFAULT_RISK_LIMITS, } from './risk-calculator.js';
15
16
  import { executeKill as _executeKill, executeFlatten as _executeFlatten, executePause as _executePause, executeResume as _executeResume, } from './emergency-commands.js';
16
17
  import { executeSetTradingMode, executeGetBracketConfig, executeSetBracketRequirement, executeSetExchangeCredentials, executeTestExchangeCredentials, executeClearExchangeCredentials, } from './onboarding-commands.js';
17
18
  const TAG = 'gateway';
18
- // ---- Session NAV persistence ----
19
- // Persists sessionStartNav per date so Day P&L survives skill restarts.
20
- const SESSION_NAV_FILENAME = 'session-nav.json';
19
+ // ---- Day-start NAV persistence ----
20
+ // Persists sessionStartNav (the UTC-day P&L anchor) per date so Day P&L
21
+ // survives skill restarts. The file was historically named session-nav.json;
22
+ // renamed to day-start-nav.json 2026-07-22 — "session" was a misnomer (the
23
+ // value anchors the trading DAY, not any auth/session state) and tripped
24
+ // ClawHub's sensitive-file-read heuristic. Reads fall back to the legacy name
25
+ // once, writes go to the new name only.
26
+ const DAY_NAV_FILENAME = 'day-start-nav.json';
27
+ const LEGACY_DAY_NAV_FILENAME = 'session-nav.json';
21
28
  const TRADING_MODE_FILENAME = 'trading-mode.json';
22
- function getSessionNavPath() {
23
- return join(homedir(), '.openclaw', 'workspace', SESSION_NAV_FILENAME);
29
+ function getDayNavPath() {
30
+ return join(homedir(), '.openclaw', 'workspace', DAY_NAV_FILENAME);
31
+ }
32
+ function getLegacyDayNavPath() {
33
+ return join(homedir(), '.openclaw', 'workspace', LEGACY_DAY_NAV_FILENAME);
24
34
  }
25
35
  function getTradingModePath() {
26
36
  return join(homedir(), '.openclaw', 'workspace', TRADING_MODE_FILENAME);
@@ -40,17 +50,20 @@ export function shouldAnchorSessionNav(args) {
40
50
  return args.mode === 'PAPER' && args.sessionDate !== args.today; // paper midnight rollover
41
51
  }
42
52
  function loadSessionStartNav() {
43
- try {
44
- const raw = readFileSync(getSessionNavPath(), 'utf-8');
45
- const data = JSON.parse(raw);
46
- if (data.date === todayDateStr() && typeof data.sessionStartNav === 'number' && data.sessionStartNav > 0) {
47
- return data.sessionStartNav;
53
+ for (const path of [getDayNavPath(), getLegacyDayNavPath()]) {
54
+ try {
55
+ const raw = readFileSync(path, 'utf-8');
56
+ const data = JSON.parse(raw);
57
+ if (data.date === todayDateStr() && typeof data.sessionStartNav === 'number' && data.sessionStartNav > 0) {
58
+ return data.sessionStartNav;
59
+ }
60
+ return null; // Different day or invalid — don't let a stale legacy file shadow it
61
+ }
62
+ catch {
63
+ /* missing or corrupt — try the legacy name */
48
64
  }
49
- return null; // Different day or invalid
50
- }
51
- catch {
52
- return null; // File doesn't exist or is corrupt
53
65
  }
66
+ return null;
54
67
  }
55
68
  /**
56
69
  * Persisted across skill restarts so the FIRST snapshot the gateway emits
@@ -90,7 +103,11 @@ function saveSessionStartNav(nav) {
90
103
  const dir = join(homedir(), '.openclaw', 'workspace');
91
104
  mkdirSync(dir, { recursive: true });
92
105
  const data = { date: todayDateStr(), sessionStartNav: nav };
93
- writeFileSync(getSessionNavPath(), JSON.stringify(data, null, 2), 'utf-8');
106
+ writeFileSync(getDayNavPath(), JSON.stringify(data, null, 2), 'utf-8');
107
+ try {
108
+ unlinkSync(getLegacyDayNavPath());
109
+ }
110
+ catch { /* legacy file already gone */ }
94
111
  }
95
112
  catch (err) {
96
113
  logger.warn(TAG, `Failed to save session NAV: ${err instanceof Error ? err.message : String(err)}`);
@@ -122,6 +139,8 @@ export class GatewayProvider {
122
139
  agentIdentity = {};
123
140
  /** Emit the one-time rollout probe (gateway response shape) only on the first attempt. */
124
141
  loggedAgentIdentityProbe = false;
142
+ /** One-shot latch for the boot-time heartbeat-cron ensure (re-armed on failure). */
143
+ heartbeatCronEnsureStarted = false;
125
144
  /** Live heartbeat cadence (seconds), read from the OpenClaw cron store; cached 60s. */
126
145
  heartbeatSeconds;
127
146
  heartbeatReadAtMs = 0;
@@ -1070,6 +1089,24 @@ export class GatewayProvider {
1070
1089
  // every (re)connect so a model swap — which restarts the gateway and drops
1071
1090
  // this socket — is reflected on the next handshake.
1072
1091
  void this.refreshAgentIdentity();
1092
+ // Ensure the heartbeat cron exists — via gateway RPC, once per install
1093
+ // (marker-file guarded; a deliberate operator delete is never resurrected).
1094
+ // Lives here instead of setup because setup runs before the gateway is up.
1095
+ if (!this.heartbeatCronEnsureStarted) {
1096
+ this.heartbeatCronEnsureStarted = true;
1097
+ const ws = this.wsClient;
1098
+ if (ws) {
1099
+ void ensureHeartbeatCron({
1100
+ rpc: ws,
1101
+ markerPath: join(homedir(), '.openclaw', 'workspace', 'heartbeat-cron-ensured.json'),
1102
+ log: (msg) => logger.info(TAG, msg),
1103
+ }).then((outcome) => {
1104
+ // A transient failure retries on the next (re)connect, not just next boot.
1105
+ if (outcome === 'failed')
1106
+ this.heartbeatCronEnsureStarted = false;
1107
+ });
1108
+ }
1109
+ }
1073
1110
  // Start periodic agent state emission (every 5s)
1074
1111
  if (!this.agentStateInterval) {
1075
1112
  this.agentStateInterval = setInterval(() => {
@@ -1589,7 +1626,11 @@ export class GatewayProvider {
1589
1626
  this.hasReceivedPositions = false;
1590
1627
  this.pendingEmptyPoll = false;
1591
1628
  try {
1592
- unlinkSync(getSessionNavPath());
1629
+ unlinkSync(getDayNavPath());
1630
+ }
1631
+ catch { /* ok if missing */ }
1632
+ try {
1633
+ unlinkSync(getLegacyDayNavPath());
1593
1634
  }
1594
1635
  catch { /* ok if missing */ }
1595
1636
  logger.info(TAG, `Session start NAV reset on mode change (${prevMode} → ${this.tradingMode})`);
@@ -1,7 +1,6 @@
1
1
  // Interactive setup helper for the ReefClaw skill.
2
2
  // Validates token format, tests relay connection, saves to OpenClaw config.
3
3
  import WebSocket from 'ws';
4
- import { execSync } from 'node:child_process';
5
4
  import { writeOpenClawConfig } from './config.js';
6
5
  import { logger } from './logger.js';
7
6
  const TAG = 'setup';
@@ -149,8 +148,12 @@ export async function runSetup(tokenOrBundle, userId, relayUrl) {
149
148
  }
150
149
  // Save to config
151
150
  writeOpenClawConfig(token, resolvedUserId, resolvedRelayUrl);
152
- // Create heartbeat cron job if none exists
153
- ensureHeartbeatCron();
151
+ // Heartbeat cron is ensured by the bridge at first gateway connect (via
152
+ // cron.list/cron.add RPC — see gateway/heartbeat-cron.ts). Setup can't do it:
153
+ // the gateway isn't running yet at this point, which is also why the old
154
+ // setup-time shell-out to the openclaw CLI silently no-op'd on fresh
155
+ // installs (the CLI's cron commands are gateway RPC clients too).
156
+ console.log(' Heartbeat cron: created automatically when the agent first connects (every 15m)');
154
157
  console.log('');
155
158
  console.log(' Setup complete! Token saved to ~/.openclaw/config.json');
156
159
  console.log('');
@@ -161,54 +164,6 @@ export async function runSetup(tokenOrBundle, userId, relayUrl) {
161
164
  console.log(' 4. Your agent checks the market every 15 minutes (adjustable via chat)');
162
165
  console.log('');
163
166
  }
164
- // ---- Heartbeat cron ----
165
- /**
166
- * Ensures a heartbeat cron job exists for ReefClaw.
167
- * Checks `openclaw cron list` for an existing job with "reefclaw" in the name.
168
- * If none found, creates one with 15m default interval.
169
- * Non-fatal — if openclaw CLI isn't available or cron fails, setup still succeeds.
170
- */
171
- function ensureHeartbeatCron() {
172
- try {
173
- // Check if a reefclaw cron already exists
174
- const listOutput = execSync('openclaw cron list --json 2>/dev/null', {
175
- encoding: 'utf-8',
176
- timeout: 15_000,
177
- });
178
- // Look for any job with "reefclaw" in the name
179
- try {
180
- const jobs = JSON.parse(listOutput);
181
- const existing = (Array.isArray(jobs) ? jobs : []).find((j) => j.name?.toLowerCase().includes('reefclaw'));
182
- if (existing) {
183
- console.log(` Heartbeat cron: already exists (${existing.name})`);
184
- return;
185
- }
186
- }
187
- catch {
188
- // JSON parse failed — maybe not JSON output, check raw text
189
- if (listOutput.toLowerCase().includes('reefclaw')) {
190
- console.log(' Heartbeat cron: already exists');
191
- return;
192
- }
193
- }
194
- // No existing job — create one
195
- console.log(' Creating heartbeat cron (every 15m)...');
196
- execSync('openclaw cron add --name reefclaw-heartbeat --every 15m --session isolated ' +
197
- "--message 'Heartbeat. Run SESSION START mandatory checks, then the full Decision Loop (Steps 0-9) from SKILL.md. Check tradingMode from fetch_balance — it is your source of truth for paper vs live. Use tools in parallel where possible.' 2>&1", { encoding: 'utf-8', timeout: 15_000 });
198
- console.log(' Heartbeat cron: created (every 15 minutes)');
199
- console.log(' Tip: Ask your agent "change heartbeat to 10 minutes" to adjust');
200
- }
201
- catch (err) {
202
- // Non-fatal — user can create cron manually or agent can create it on first session
203
- const msg = err instanceof Error ? err.message : String(err);
204
- if (msg.includes('not found') || msg.includes('ENOENT')) {
205
- console.log(' Heartbeat cron: skipped (openclaw CLI not in PATH)');
206
- }
207
- else {
208
- console.log(` Heartbeat cron: skipped (${msg.split('\n')[0]})`);
209
- }
210
- }
211
- }
212
167
  function printSetupInstructions() {
213
168
  console.log(' To connect your OpenClaw agent to ReefClaw:');
214
169
  console.log('');
package/dist/deps.js CHANGED
@@ -5,10 +5,10 @@
5
5
  import { writeFileSync, cpSync, mkdirSync, existsSync } from 'node:fs';
6
6
  import { join } from 'node:path';
7
7
  import { run } from './exec.js';
8
- export function writePackageJson(dir, name, deps, extra = {}) {
8
+ export function writePackageJson(dir, name, deps, extra = {}, version = '0.1.0') {
9
9
  const pkg = {
10
10
  name,
11
- version: '0.1.0',
11
+ version,
12
12
  private: true,
13
13
  type: 'module',
14
14
  main: 'index.js',
package/dist/plugin.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // Install + register the ReefClaw trading plugin (reefclaw-paper-trading) into
2
2
  // the user's OpenClaw. Mirrors deploy-full.py: place dist, install deps, vendor
3
3
  // shared, then `openclaw plugins install --link`.
4
+ import { readFileSync } from 'node:fs';
4
5
  import { join } from 'node:path';
5
6
  import { PLUGIN_DIR, assetsDir, ASSET_PLUGIN, ASSET_SHARED } from './paths.js';
6
7
  import { copyAsset, writePackageJson, npmInstall, vendorShared } from './deps.js';
@@ -8,6 +9,21 @@ import { run, which } from './exec.js';
8
9
  import { step, ok, info, warn, fail } from './ui.js';
9
10
  // Plugin runtime deps (mirror plugin/package.json). ws + ccxt; ccxt is large.
10
11
  const PLUGIN_DEPS = { ccxt: '^4.4.0', ws: '^8.18.0' };
12
+ /** Version for the placed package.json — read from the bundled manifest (which
13
+ * bundle-assets stamps from the published plugin version). Falls back to the
14
+ * historical 0.1.0 placeholder so a missing/old manifest can't break installs. */
15
+ function readBundledManifestVersion(pluginDir) {
16
+ try {
17
+ const manifest = JSON.parse(readFileSync(join(pluginDir, 'openclaw.plugin.json'), 'utf-8'));
18
+ if (typeof manifest.version === 'string' && manifest.version.length > 0) {
19
+ return manifest.version;
20
+ }
21
+ }
22
+ catch {
23
+ /* fall through to placeholder */
24
+ }
25
+ return '0.1.0';
26
+ }
11
27
  export function installPlugin() {
12
28
  step('Installing the ReefClaw trading plugin');
13
29
  const assets = assetsDir();
@@ -17,9 +33,10 @@ export function installPlugin() {
17
33
  // (2026.6+ hard-fails without it). The placed dir holds the built dist at top
18
34
  // level, so the entry is ./index.js — NOT ./src/index.ts like the repo's
19
35
  // plugin/package.json (see CLAUDE.md "dist/package.json's openclaw entry").
20
- writePackageJson(PLUGIN_DIR, 'reefclaw-paper-trading', PLUGIN_DEPS, {
21
- openclaw: { extensions: ['./index.js'] },
22
- });
36
+ // Version comes from the bundled manifest (stamped at bundle time from the
37
+ // published plugin version) so package.json and openclaw.plugin.json agree —
38
+ // the same package/manifest coherence ClawHub validates on the npm channel.
39
+ writePackageJson(PLUGIN_DIR, 'reefclaw-paper-trading', PLUGIN_DEPS, { openclaw: { extensions: ['./index.js'] } }, readBundledManifestVersion(PLUGIN_DIR));
23
40
  info('installing plugin dependencies (this can take a minute — ccxt is large)…');
24
41
  if (!npmInstall(PLUGIN_DIR)) {
25
42
  warn('npm install reported a problem; the plugin may still work if deps resolved.');
@@ -31,16 +48,27 @@ export function installPlugin() {
31
48
  const cli = which('openclaw');
32
49
  if (!cli) {
33
50
  fail('the `openclaw` CLI is not on your PATH — cannot register the plugin.');
34
- info(`Once OpenClaw is on PATH, run: openclaw plugins install --link ${PLUGIN_DIR}`);
51
+ info(`Once OpenClaw is on PATH, run: openclaw plugins install --force --link ${PLUGIN_DIR}`);
35
52
  return { registered: false };
36
53
  }
54
+ // --force is REQUIRED on openclaw >= 2026.7.2 (issue #216): non-ClawHub
55
+ // sources (incl. local paths) need an acknowledgement, and in a non-TTY
56
+ // context the install is cancelled with "rerun with --force" instead of
57
+ // prompting. Acknowledging is correct here — the "source" is our own bundled
58
+ // plugin the user explicitly chose to install by running this installer.
59
+ // On <= 2026.7.1, --force only means overwrite-an-existing-install, which
60
+ // also makes installer re-runs idempotent instead of failing on the exists
61
+ // check. Verified against both dists' plugins-install command + the beta's
62
+ // confirmNonClawHubInstall (install cancelled when !TTY && !force).
37
63
  info('registering the plugin with OpenClaw…');
38
- const r = run('openclaw', ['plugins', 'install', '--link', PLUGIN_DIR], { timeoutMs: 300_000 });
64
+ const r = run('openclaw', ['plugins', 'install', '--force', '--link', PLUGIN_DIR], {
65
+ timeoutMs: 300_000,
66
+ });
39
67
  if (!r.ok) {
40
- warn('`openclaw plugins install --link` returned non-zero:');
68
+ warn('`openclaw plugins install --force --link` returned non-zero:');
41
69
  if (r.stderr.trim())
42
70
  info(r.stderr.trim().split('\n').slice(-3).join('\n'));
43
- info(`Retry manually: openclaw plugins install --link ${PLUGIN_DIR}`);
71
+ info(`Retry manually: openclaw plugins install --force --link ${PLUGIN_DIR}`);
44
72
  return { registered: false };
45
73
  }
46
74
  ok('plugin registered with OpenClaw');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reefclaw/connect",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "One-command installer that connects your OpenClaw agent to ReefClaw (paper trading, no exchange keys).",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,11 +0,0 @@
1
- import type { TradingMode } from '../types.js';
2
- export interface ModeTransitionAuditEntry {
3
- ts: string;
4
- previousMode: TradingMode;
5
- targetMode: TradingMode;
6
- acknowledged: boolean;
7
- ok: boolean;
8
- reason?: string;
9
- testnet?: boolean;
10
- }
11
- export declare function recordModeTransition(entry: Omit<ModeTransitionAuditEntry, 'ts'>, pluginId?: string): void;
@@ -1,29 +0,0 @@
1
- // Mode-transition audit — append-only JSONL record of every set_trading_mode call.
2
- //
3
- // Written BEFORE the adapter swap (so even a crashed transition leaves a trail)
4
- // and updated with the outcome. Intended for post-incident review and regulatory
5
- // defence ("the operator acknowledged the LIVE transition at 2026-04-20T14:32:11Z").
6
- //
7
- // Path: ~/.openclaw/plugins/<pluginId>/mode-transitions.jsonl
8
- // Append-only; never truncated. One JSON object per line.
9
- import { appendFileSync, existsSync, mkdirSync } from 'node:fs';
10
- import { join } from 'node:path';
11
- import { logger, formatError } from '../logger.js';
12
- import { resolvePluginsBaseDir } from '../util/plugin-paths.js';
13
- const TAG = 'mode-audit';
14
- function resolvePath(pluginId) {
15
- const dir = join(resolvePluginsBaseDir(), pluginId ?? 'reefclaw-paper-trading');
16
- if (!existsSync(dir))
17
- mkdirSync(dir, { recursive: true });
18
- return join(dir, 'mode-transitions.jsonl');
19
- }
20
- export function recordModeTransition(entry, pluginId) {
21
- const full = { ts: new Date().toISOString(), ...entry };
22
- try {
23
- appendFileSync(resolvePath(pluginId), JSON.stringify(full) + '\n', 'utf8');
24
- logger.info(TAG, `${full.previousMode} → ${full.targetMode} ok=${full.ok} ack=${full.acknowledged}`);
25
- }
26
- catch (err) {
27
- logger.error(TAG, `Failed to write audit entry: ${formatError(err)}`);
28
- }
29
- }
@@ -1,36 +0,0 @@
1
- import type { CcxtBalance } from './types.js';
2
- /**
3
- * Read the total quote-currency balance from a CCXT balance map.
4
- *
5
- * Uses the PRIMARY funded currency only — whichever of USDT/USDC has
6
- * the larger balance. Summing both was incorrect because Binance
7
- * cross-margin accounting reports position margin/value as a phantom
8
- * balance in the settlement currency (e.g., opening an ATOM/USDT
9
- * position with a USDC-funded account creates a USDT "balance" entry
10
- * equal to the position's notional, inflating getQuoteBalance by the
11
- * position value and causing the KPI to double-count).
12
- *
13
- * For wallet/equity/NAV reads on Binance Futures, prefer
14
- * `getQuoteWalletBalance(balance)` — it handles BNFCR.
15
- */
16
- export declare function getQuoteBalance(balanceMap: Record<string, number> | undefined): number;
17
- /**
18
- * Read the effective wallet-equivalent quote balance from a Binance Futures
19
- * fetchBalance response, including the BNFCR realized-PnL accumulator.
20
- *
21
- * Why this exists: Binance multi-asset accounts settle realized PnL into
22
- * BNFCR (negative when net-loss, positive when net-gain). CCXT's `total`
23
- * map carries `marginBalance` (= walletBalance + uPnl), so the BNFCR line
24
- * mixes uPnl into the total, which double-counts when the caller adds
25
- * position uPnl on top. This helper reads `info.assets[i].walletBalance`
26
- * directly, which excludes uPnl by construction.
27
- *
28
- * Returns max(USDT_wallet, USDC_wallet) + BNFCR_wallet. BNFCR is added
29
- * (not max'd) because it is independent of the funded stablecoin — a
30
- * USDC-funded account with cumulative losses shows USDC unchanged plus
31
- * BNFCR negative; the user's true wallet is the sum.
32
- *
33
- * Falls back to `getQuoteBalance(balance.total)` when `info.assets` is
34
- * absent (mock balances in unit tests, non-Binance exchanges).
35
- */
36
- export declare function getQuoteWalletBalance(balance: CcxtBalance | null | undefined): number;
@@ -1,98 +0,0 @@
1
- // Utility for reading quote-currency balance from CCXT balance objects.
2
- // Binance USDⓈ-M Futures settles in USDT or USDC — accounts may hold either or both.
3
- // On multi-asset accounts a third asset, BNFCR, accumulates realized PnL as a
4
- // signed wallet line (negative = cumulative loss, positive = cumulative gain).
5
- /**
6
- * Read the total quote-currency balance from a CCXT balance map.
7
- *
8
- * Uses the PRIMARY funded currency only — whichever of USDT/USDC has
9
- * the larger balance. Summing both was incorrect because Binance
10
- * cross-margin accounting reports position margin/value as a phantom
11
- * balance in the settlement currency (e.g., opening an ATOM/USDT
12
- * position with a USDC-funded account creates a USDT "balance" entry
13
- * equal to the position's notional, inflating getQuoteBalance by the
14
- * position value and causing the KPI to double-count).
15
- *
16
- * For wallet/equity/NAV reads on Binance Futures, prefer
17
- * `getQuoteWalletBalance(balance)` — it handles BNFCR.
18
- */
19
- export function getQuoteBalance(balanceMap) {
20
- if (!balanceMap)
21
- return 0;
22
- const usdt = balanceMap.USDT ?? 0;
23
- const usdc = balanceMap.USDC ?? 0;
24
- // Use whichever currency has the larger wallet balance (the funded one).
25
- // If both are zero, return 0. If both are funded, use the larger.
26
- return Math.max(usdt, usdc);
27
- }
28
- /**
29
- * Read the effective wallet-equivalent quote balance from a Binance Futures
30
- * fetchBalance response, including the BNFCR realized-PnL accumulator.
31
- *
32
- * Why this exists: Binance multi-asset accounts settle realized PnL into
33
- * BNFCR (negative when net-loss, positive when net-gain). CCXT's `total`
34
- * map carries `marginBalance` (= walletBalance + uPnl), so the BNFCR line
35
- * mixes uPnl into the total, which double-counts when the caller adds
36
- * position uPnl on top. This helper reads `info.assets[i].walletBalance`
37
- * directly, which excludes uPnl by construction.
38
- *
39
- * Returns max(USDT_wallet, USDC_wallet) + BNFCR_wallet. BNFCR is added
40
- * (not max'd) because it is independent of the funded stablecoin — a
41
- * USDC-funded account with cumulative losses shows USDC unchanged plus
42
- * BNFCR negative; the user's true wallet is the sum.
43
- *
44
- * Falls back to `getQuoteBalance(balance.total)` when `info.assets` is
45
- * absent (mock balances in unit tests, non-Binance exchanges).
46
- */
47
- export function getQuoteWalletBalance(balance) {
48
- if (!balance)
49
- return 0;
50
- // Prefer Binance's own account-level wallet aggregate when present.
51
- // `/fapi/v3/account` (CCXT passes it through verbatim at `info`) returns
52
- // `totalWalletBalance` — in Multi-Assets Mode this is the USD-denominated
53
- // sum across all margin assets, with each non-USD collateral valued at
54
- // Binance's live index price (verified against developers.binance.com →
55
- // Account Information V3, 2026-05-16). It also excludes uPnL by
56
- // construction (marginBalance = walletBalance + uPnL), matching this
57
- // function's "wallet, uPnL added by caller" contract.
58
- //
59
- // Why this beats the per-asset reconstruction below: summing
60
- // `max(USDT,USDC) + BNFCR` values USDC at FACE 1.0000, but Binance values
61
- // USDC collateral at the live USDC/USD index (~0.9998). That made the
62
- // dashboard wallet permanently ~$0.2 high vs the Binance app on this
63
- // account (always-on, same-sign, slowly varying with the USDC peg —
64
- // 2026-05-16 "figures slightly off always"). totalWalletBalance is the
65
- // exact number the app's Futures "Wallet Balance" shows. The read path is
66
- // already REST (`LiveAdapter.getBalance` → `fetchBalance()` every poll),
67
- // so this is zero freshness regression — same cadence, correct value.
68
- const info = balance?.info;
69
- if (info && info.totalWalletBalance != null) {
70
- const twb = parseFloat(String(info.totalWalletBalance));
71
- if (Number.isFinite(twb))
72
- return twb;
73
- }
74
- // Fallback (no Binance aggregate — non-Binance exchange, mock balances in
75
- // unit tests, or a WS-store-derived balance object): the legacy
76
- // face-value per-asset reconstruction. Carries the documented ~USDC-index
77
- // drift but is the best available when the aggregate is absent.
78
- const assets = balance?.info?.assets;
79
- if (!Array.isArray(assets))
80
- return getQuoteBalance(balance.total);
81
- let usdt = 0;
82
- let usdc = 0;
83
- let bnfcr = 0;
84
- for (const a of assets) {
85
- if (!a || typeof a.asset !== 'string')
86
- continue;
87
- const wb = parseFloat(String(a.walletBalance ?? 0));
88
- if (!Number.isFinite(wb))
89
- continue;
90
- if (a.asset === 'USDT')
91
- usdt = wb;
92
- else if (a.asset === 'USDC')
93
- usdc = wb;
94
- else if (a.asset === 'BNFCR')
95
- bnfcr = wb;
96
- }
97
- return Math.max(usdt, usdc) + bnfcr;
98
- }
@@ -1,47 +0,0 @@
1
- /** Thrown by `assertNotBanned` while the gate is closed. Carries the
2
- * remaining cooldown so callers/telemetry can reason about it. Methods
3
- * catch this in their existing catch block — it is NOT meant to escape
4
- * the API layer with special handling; it degrades to the method's normal
5
- * failure contract. */
6
- export declare class BinanceBannedError extends Error {
7
- readonly retryAfterMs: number;
8
- constructor(retryAfterMs: number, context: string);
9
- }
10
- /** Thrown by the proactive weight pacer. Subclass of BinanceBannedError so
11
- * every `instanceof BinanceBannedError` check and every method's existing
12
- * catch keep working unchanged — it degrades to the same null/[]/throw
13
- * contract (treated exactly like a transient fetch failure). The distinct
14
- * name lets journal/telemetry tell prevention apart from a real IP ban. */
15
- export declare class BinanceWeightPacedError extends BinanceBannedError {
16
- constructor(retryAfterMs: number, context: string);
17
- }
18
- /** Fast pre-flight check. Call as the first line inside a Binance call's
19
- * try-block. Throws `BinanceBannedError` (no network) while the gate is
20
- * open. */
21
- export declare function assertNotBanned(context: string): void;
22
- /** Inspect a failed call's error and arm/extend the gate on a Binance
23
- * rate-limit signal. Non-rate-limit errors are ignored (normal transient
24
- * handling stays in the caller). Safe to call with any error shape. */
25
- export declare function noteBinanceError(err: unknown): void;
26
- /** Relax the soft-429 ladder after a clean call. (A hard 418 window is NOT
27
- * shortened by this — only Binance's stated expiry clears it.) */
28
- export declare function noteSuccess(): void;
29
- /** Reconcile the local weight estimate against Binance truth from a response
30
- * header (`x-mbx-used-weight-1m`). Best-effort: callers pass whatever header
31
- * bag they have; absent/garbage values are ignored. The local estimate
32
- * leads (counts in-flight calls Binance hasn't tallied yet), so we take the
33
- * MAX within the window — never let a lagging header lower our guard. A
34
- * header far BELOW the estimate means Binance's minute rolled; re-anchor the
35
- * window to Binance's clock so we don't shed for a stale local total. */
36
- export declare function noteResponseWeight(headers: Record<string, string> | undefined | null): void;
37
- /** Test/diagnostic helper — current gate state. */
38
- export declare function getBanGateState(): {
39
- banUntilMs: number;
40
- remainingMs: number;
41
- rateLimitStep: number;
42
- weightUsed: number;
43
- weightCeiling: number;
44
- cosmeticCeiling: number;
45
- };
46
- /** Test-only reset. Not used in production code paths. */
47
- export declare function __resetBanGateForTests(): void;