@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
@@ -1,26 +0,0 @@
1
- import type { PublicMarketDataApi } from '../ccxt/public-market-data-api.js';
2
- import type { ExchangeSimulator } from '../simulator/exchange-simulator.js';
3
- import type { CcxtTicker } from '../types.js';
4
- /**
5
- * Fetch the latest ticker from the configured market-data source (Binance, or
6
- * intel in paper mode on a geo-blocked host) and update the simulator.
7
- * Returns the ticker on success, or an error object on failure.
8
- */
9
- export declare function fetchCurrentPrice(symbol: string, deps: {
10
- binanceApi: PublicMarketDataApi;
11
- simulator: ExchangeSimulator;
12
- }): Promise<CcxtTicker | {
13
- error: string;
14
- }>;
15
- /**
16
- * Fetch the latest order book from Binance and cache in simulator.
17
- * Best-effort: never throws. Skips fetch if cached book is fresh enough.
18
- */
19
- export declare function fetchOrderBook(symbol: string, deps: {
20
- binanceApi: PublicMarketDataApi;
21
- simulator: ExchangeSimulator;
22
- }): Promise<void>;
23
- /** Type guard: check if the result is an error object */
24
- export declare function isError(result: unknown): result is {
25
- error: string;
26
- };
@@ -1,39 +0,0 @@
1
- // Shared helpers for tool implementations.
2
- /**
3
- * Fetch the latest ticker from the configured market-data source (Binance, or
4
- * intel in paper mode on a geo-blocked host) and update the simulator.
5
- * Returns the ticker on success, or an error object on failure.
6
- */
7
- export async function fetchCurrentPrice(symbol, deps) {
8
- const ticker = await deps.binanceApi.fetchTicker(symbol);
9
- if (!ticker) {
10
- return { error: `Failed to fetch current price for ${symbol}` };
11
- }
12
- deps.simulator.updateTicker(ticker);
13
- return ticker;
14
- }
15
- /** Default TTL for cached orderbook: 5 seconds. */
16
- const ORDERBOOK_TTL_MS = 5_000;
17
- /**
18
- * Fetch the latest order book from Binance and cache in simulator.
19
- * Best-effort: never throws. Skips fetch if cached book is fresh enough.
20
- */
21
- export async function fetchOrderBook(symbol, deps) {
22
- try {
23
- // Skip if cached book is still fresh
24
- const cached = deps.simulator.getLastOrderBook(symbol);
25
- if (cached && Date.now() - cached.timestamp < ORDERBOOK_TTL_MS)
26
- return;
27
- const orderbook = await deps.binanceApi.fetchOrderBook(symbol, 20);
28
- if (orderbook) {
29
- deps.simulator.updateOrderBook(symbol, orderbook);
30
- }
31
- }
32
- catch {
33
- // Best-effort: fill engine falls back to random slippage
34
- }
35
- }
36
- /** Type guard: check if the result is an error object */
37
- export function isError(result) {
38
- return typeof result === 'object' && result !== null && 'error' in result;
39
- }
@@ -1,34 +0,0 @@
1
- import { type VenueId } from '../venues/symbols.js';
2
- export interface IntelApiDeps {
3
- connectionToken: string;
4
- intelligenceUrl: string;
5
- /** Trading venue of this box (HYPERLIQUID_INTEGRATION_PLAN §5.3). Absent =
6
- * binance, so every pre-venue caller is byte-identical. */
7
- venue?: VenueId;
8
- }
9
- /** Agent-facing symbol → the intel DB symbol for this deps' venue.
10
- * binance/absent: 'BTC/USDT' → 'BTCUSDT'; slashless input passes through
11
- * verbatim (today's working raw inputs stay byte-identical).
12
- * hyperliquid: 'BTC/USDC' → 'HL_BTC' (case preserved — 'kPEPE' is real,
13
- * 'KPEPE' is not); 'HL_X' passes through; concatenated 'BTCUSDC' → 'HL_BTC'. */
14
- export declare function resolveIntelSymbol(deps: IntelApiDeps, symbol: string): string;
15
- /** Intel DB symbol → the symbol the agent should see and trade.
16
- * binance: verbatim ('BTCUSDT' stays 'BTCUSDT' — the historical shape the
17
- * agent already translates). hyperliquid: 'HL_BTC' → 'BTC/USDC'. */
18
- export declare function presentIntelSymbol(deps: IntelApiDeps, intelSymbol: string): string;
19
- /** Does this intel symbol belong to this deps' venue? Venue-scopes the scan
20
- * universe: an HL box must never rank Binance USDT candidates it cannot
21
- * trade (2026-07-13 wisekid: every setup died at the order-path price
22
- * fetch), and a Binance box must never rank HL_ rows once intel serves
23
- * them (INTEL_HL_FACTS). */
24
- export declare function intelSymbolOnVenue(deps: IntelApiDeps, intelSymbol: string): boolean;
25
- export interface FetchOptions {
26
- method?: 'GET' | 'POST' | 'PUT' | 'DELETE';
27
- body?: unknown;
28
- timeoutMs?: number;
29
- }
30
- /** Encode a value for safe use in a URL path segment */
31
- export declare const enc: typeof encodeURIComponent;
32
- export declare function fetchIntelApi(path: string, deps: IntelApiDeps, options?: FetchOptions): Promise<Record<string, unknown> | {
33
- error: string;
34
- }>;
@@ -1,119 +0,0 @@
1
- // Shared helper for Intelligence API calls.
2
- // All intelligence tools use Bearer token auth against intel.reefclaw.com.
3
- import { HL_INTEL_PREFIX, fromIntelSymbol, toIntelSymbol } from '../venues/symbols.js';
4
- // ─── Venue-aware intel-symbol mapping (plan §5.3: the agent keeps using
5
- // canonical symbols like BTC/USDC; these helpers translate at the intel
6
- // boundary). All three FAIL OPEN — unmappable input passes through
7
- // verbatim so intel answers "no data for <echo>", which is honest and
8
- // debuggable; never throw here. ─────────────────────────────────────────
9
- /** Strip a ccxt settle suffix ('BTC/USDC:USDC' → 'BTC/USDC'). */
10
- function stripSettle(s) {
11
- return s.replace(/:[A-Za-z]+$/, '');
12
- }
13
- /** Agent-facing symbol → the intel DB symbol for this deps' venue.
14
- * binance/absent: 'BTC/USDT' → 'BTCUSDT'; slashless input passes through
15
- * verbatim (today's working raw inputs stay byte-identical).
16
- * hyperliquid: 'BTC/USDC' → 'HL_BTC' (case preserved — 'kPEPE' is real,
17
- * 'KPEPE' is not); 'HL_X' passes through; concatenated 'BTCUSDC' → 'HL_BTC'. */
18
- export function resolveIntelSymbol(deps, symbol) {
19
- const venue = deps.venue ?? 'binance';
20
- const s = stripSettle(String(symbol ?? '').trim());
21
- if (venue === 'hyperliquid') {
22
- if (s.startsWith(HL_INTEL_PREFIX))
23
- return s;
24
- if (s.includes('/')) {
25
- try {
26
- return toIntelSymbol('hyperliquid', s);
27
- }
28
- catch {
29
- return s;
30
- }
31
- }
32
- if (s.length > 4 && s.endsWith('USDC'))
33
- return `${HL_INTEL_PREFIX}${s.slice(0, -4)}`;
34
- return s;
35
- }
36
- if (s.includes('/')) {
37
- try {
38
- return toIntelSymbol('binance', s);
39
- }
40
- catch {
41
- return s;
42
- }
43
- }
44
- return s;
45
- }
46
- /** Intel DB symbol → the symbol the agent should see and trade.
47
- * binance: verbatim ('BTCUSDT' stays 'BTCUSDT' — the historical shape the
48
- * agent already translates). hyperliquid: 'HL_BTC' → 'BTC/USDC'. */
49
- export function presentIntelSymbol(deps, intelSymbol) {
50
- if ((deps.venue ?? 'binance') !== 'hyperliquid')
51
- return intelSymbol;
52
- if (!intelSymbol.startsWith(HL_INTEL_PREFIX))
53
- return intelSymbol;
54
- try {
55
- return fromIntelSymbol(intelSymbol).canonical;
56
- }
57
- catch {
58
- return intelSymbol;
59
- }
60
- }
61
- /** Does this intel symbol belong to this deps' venue? Venue-scopes the scan
62
- * universe: an HL box must never rank Binance USDT candidates it cannot
63
- * trade (2026-07-13 wisekid: every setup died at the order-path price
64
- * fetch), and a Binance box must never rank HL_ rows once intel serves
65
- * them (INTEL_HL_FACTS). */
66
- export function intelSymbolOnVenue(deps, intelSymbol) {
67
- const isHl = intelSymbol.startsWith(HL_INTEL_PREFIX);
68
- return (deps.venue ?? 'binance') === 'hyperliquid' ? isHl : !isHl;
69
- }
70
- /** Encode a value for safe use in a URL path segment */
71
- export const enc = encodeURIComponent;
72
- export async function fetchIntelApi(path, deps, options) {
73
- const { connectionToken, intelligenceUrl } = deps;
74
- if (!connectionToken) {
75
- return { error: 'No ReefClaw connection token configured. Intelligence features require a reefclaw.com account.' };
76
- }
77
- if (!intelligenceUrl) {
78
- return { error: 'No intelligence URL configured. Set intelligenceUrl in openclaw.json plugin config.' };
79
- }
80
- const url = `${intelligenceUrl}${path}`;
81
- const headers = { Authorization: `Bearer ${connectionToken}` };
82
- const fetchInit = {
83
- method: options?.method ?? 'GET',
84
- headers,
85
- signal: AbortSignal.timeout(options?.timeoutMs ?? 20_000),
86
- };
87
- if (options?.body !== undefined) {
88
- headers['Content-Type'] = 'application/json';
89
- fetchInit.body = JSON.stringify(options.body);
90
- }
91
- try {
92
- const res = await fetch(url, fetchInit);
93
- if (res.status === 401) {
94
- return { error: 'Invalid or expired ReefClaw connection token.' };
95
- }
96
- if (res.status === 503) {
97
- return { error: 'Intelligence service not ready. The regime classifier may still be loading.' };
98
- }
99
- if (!res.ok) {
100
- // Try to extract the server's error message for actionable feedback
101
- let detail = `Intelligence API returned ${res.status}`;
102
- try {
103
- const errBody = (await res.json());
104
- if (errBody.error)
105
- detail = errBody.error;
106
- }
107
- catch { /* ignore parse failures */ }
108
- return { error: detail };
109
- }
110
- return (await res.json());
111
- }
112
- catch (err) {
113
- if (err instanceof Error && err.name === 'TimeoutError') {
114
- const timeoutSec = Math.round((options?.timeoutMs ?? 20_000) / 1000);
115
- return { error: `Intelligence API request timed out (${timeoutSec}s). Try again later.` };
116
- }
117
- return { error: `Intelligence API call failed: ${err instanceof Error ? err.message : String(err)}` };
118
- }
119
- }
@@ -1,25 +0,0 @@
1
- import type { IntelApiDeps } from './intel-api.js';
2
- import { type SymbolFact, type StrategyConfig, type StrategyRow } from '../strategy/evaluator.js';
3
- export declare function getAllFactsCached(deps: IntelApiDeps): Promise<SymbolFact[] | {
4
- error: string;
5
- }>;
6
- /** Look up a single symbol's fact, preferring the shared all-facts snapshot.
7
- * Falls back to the single-symbol endpoint when the all-facts snapshot is
8
- * cold or the symbol is missing from it (e.g., a watchlist symbol not in
9
- * the default 20-pair set). */
10
- export declare function getFactBySymbolCached(rawSymbol: string, deps: IntelApiDeps): Promise<SymbolFact | {
11
- error: string;
12
- }>;
13
- /** Fetch active strategy rows, caching the full row shape. Both
14
- * getStrategiesCached and this share the same rows cache so a warm cache
15
- * from either entry point services the other without a second fetch. */
16
- export declare function getStrategyRowsCached(deps: IntelApiDeps): Promise<StrategyRow[] | {
17
- error: string;
18
- }>;
19
- /** Backwards-compatible configs-only view, derived from the rows cache. */
20
- export declare function getStrategiesCached(deps: IntelApiDeps): Promise<StrategyConfig[] | {
21
- error: string;
22
- }>;
23
- export declare const __testing__: {
24
- resetCaches(): void;
25
- };
@@ -1,148 +0,0 @@
1
- // Shared TTL cache for intelligence facts + strategies.
2
- //
3
- // Why this module exists: scan_pairs and get_setup_detail used to maintain
4
- // independent caches. scan_pairs cached the all-facts endpoint with a 30s
5
- // TTL; get_setup_detail had no cache and hit the single-symbol endpoint on
6
- // every call. When the fact-computer recomputed between the two calls,
7
- // scan_pairs and get_setup_detail saw different facts for the same symbol —
8
- // regime, chosen strategy, and entry/stop geometry could all diverge. The
9
- // 2026-05-15 session showed this repeatedly: scan ranks AVAX as TREND_DOWN
10
- // short, drill-down returns a LONG ladder, agent rejects setup as
11
- // "directionally inconsistent." Sharing the cache eliminates the divergence.
12
- //
13
- // API:
14
- // getAllFactsCached(deps) — populates the all-facts cache
15
- // getFactBySymbolCached(symbol, deps) — reads from all-facts cache when
16
- // warm; otherwise falls back to
17
- // single-symbol fetch + populates
18
- // per-symbol cache
19
- // getStrategiesCached(deps) — strategies cache
20
- // __testing__.resetCaches() — clears all caches between tests
21
- import { fetchIntelApi, enc, resolveIntelSymbol } from './intel-api.js';
22
- import { isDeclarativeStrategyConfig, } from '../strategy/evaluator.js';
23
- // facts refresh every 5 min server-side; 30s client cache is safe
24
- const FACTS_TTL_MS = 30_000;
25
- // strategies are slow-changing user state
26
- const STRAT_TTL_MS = 60_000;
27
- let allFactsCache = null;
28
- // Single rows cache backs BOTH the configs-only and rows views — keeping them
29
- // independent caused divergent fetches (scan_pairs warmed configs but
30
- // get_setup_detail's rows lookup missed and re-fetched, returning undefined
31
- // on test mocks). One cache, two derived views.
32
- let stratRowCache = null;
33
- // per-symbol cache for cases where the all-facts cache hasn't been populated
34
- // in this heartbeat (e.g., the agent called get_setup_detail directly without
35
- // running scan_pairs first).
36
- const symbolFactCache = new Map();
37
- function normalizeSymbol(raw) {
38
- return raw.toUpperCase().replace(/[^A-Z0-9]/g, '');
39
- }
40
- export async function getAllFactsCached(deps) {
41
- const now = Date.now();
42
- if (allFactsCache && now < allFactsCache.expiry)
43
- return allFactsCache.value;
44
- // HL_ facts are opt-in server-side (?venue=hyperliquid) so venue-blind
45
- // plugin builds can never receive them; binance sends the historical bare
46
- // path — byte-identical. One process = one venue, so the module-global
47
- // cache needs no venue key.
48
- const factsPath = (deps.venue ?? 'binance') === 'hyperliquid'
49
- ? '/api/facts?venue=hyperliquid'
50
- : '/api/facts';
51
- const resp = await fetchIntelApi(factsPath, deps, { timeoutMs: 30_000 });
52
- if (!resp || typeof resp !== 'object') {
53
- return { error: 'Intelligence /api/facts returned no response.' };
54
- }
55
- if ('error' in resp)
56
- return { error: resp.error };
57
- const value = (resp.facts ?? []);
58
- allFactsCache = { value, expiry: now + FACTS_TTL_MS };
59
- // Seed the per-symbol cache so a subsequent getFactBySymbolCached call
60
- // for any symbol in this snapshot hits a cache without a round-trip.
61
- const seedExpiry = now + FACTS_TTL_MS;
62
- for (const f of value) {
63
- if (!f.symbol)
64
- continue;
65
- symbolFactCache.set(normalizeSymbol(f.symbol), { value: f, expiry: seedExpiry });
66
- }
67
- return value;
68
- }
69
- /** Look up a single symbol's fact, preferring the shared all-facts snapshot.
70
- * Falls back to the single-symbol endpoint when the all-facts snapshot is
71
- * cold or the symbol is missing from it (e.g., a watchlist symbol not in
72
- * the default 20-pair set). */
73
- export async function getFactBySymbolCached(rawSymbol, deps) {
74
- const symbol = normalizeSymbol(rawSymbol);
75
- const now = Date.now();
76
- // 1. Try the per-symbol cache (seeded by getAllFactsCached or by a prior
77
- // single-symbol fetch).
78
- const cached = symbolFactCache.get(symbol);
79
- if (cached && now < cached.expiry)
80
- return cached.value;
81
- // 2. If the all-facts cache is warm and contains the symbol, use it. This
82
- // is the path that closes the scan_pairs / get_setup_detail divergence —
83
- // after a heartbeat scan, every drill-down hits the same snapshot the
84
- // scan saw.
85
- if (allFactsCache && now < allFactsCache.expiry) {
86
- const hit = allFactsCache.value.find(f => normalizeSymbol(f.symbol) === symbol);
87
- if (hit) {
88
- symbolFactCache.set(symbol, { value: hit, expiry: allFactsCache.expiry });
89
- return hit;
90
- }
91
- }
92
- // 3. Fall back to the single-symbol endpoint (symbol not in default scan
93
- // set, or both caches cold). Populate the per-symbol cache so a repeat
94
- // call in the same heartbeat is free. The FETCH form must preserve the
95
- // venue namespace and case ('HL_kPEPE' — the normalized cache key would
96
- // mangle it to 'HLKPEPE'); binance keeps fetching the normalized form
97
- // byte-identically.
98
- const fetchSym = (deps.venue ?? 'binance') === 'hyperliquid'
99
- ? resolveIntelSymbol(deps, rawSymbol)
100
- : symbol;
101
- const resp = await fetchIntelApi(`/api/facts/${enc(fetchSym)}`, deps, { timeoutMs: 30_000 });
102
- if (!resp || typeof resp !== 'object') {
103
- return { error: `Intelligence /api/facts/${symbol} returned no response.` };
104
- }
105
- if ('error' in resp)
106
- return { error: resp.error };
107
- const fact = resp;
108
- if (!fact.symbol) {
109
- return { error: `No facts available for ${symbol}` };
110
- }
111
- symbolFactCache.set(symbol, { value: fact, expiry: now + FACTS_TTL_MS });
112
- return fact;
113
- }
114
- /** Fetch active strategy rows, caching the full row shape. Both
115
- * getStrategiesCached and this share the same rows cache so a warm cache
116
- * from either entry point services the other without a second fetch. */
117
- export async function getStrategyRowsCached(deps) {
118
- const now = Date.now();
119
- if (stratRowCache && now < stratRowCache.expiry)
120
- return stratRowCache.value;
121
- const resp = await fetchIntelApi('/api/strategies?active=true', deps, { timeoutMs: 20_000 });
122
- // The mocked fetch may return undefined when no more responses are queued;
123
- // guard explicitly rather than relying on `'error' in resp` (the `in`
124
- // operator throws on undefined).
125
- if (!resp || typeof resp !== 'object') {
126
- return { error: 'Intelligence /api/strategies returned no response.' };
127
- }
128
- if ('error' in resp)
129
- return { error: resp.error };
130
- const rows = (resp.strategies ?? [])
131
- .filter((row) => row?.config && isDeclarativeStrategyConfig(row.config));
132
- stratRowCache = { value: rows, expiry: now + STRAT_TTL_MS };
133
- return rows;
134
- }
135
- /** Backwards-compatible configs-only view, derived from the rows cache. */
136
- export async function getStrategiesCached(deps) {
137
- const rows = await getStrategyRowsCached(deps);
138
- if ('error' in rows)
139
- return rows;
140
- return rows.map(r => r.config);
141
- }
142
- export const __testing__ = {
143
- resetCaches() {
144
- allFactsCache = null;
145
- stratRowCache = null;
146
- symbolFactCache.clear();
147
- },
148
- };
@@ -1,17 +0,0 @@
1
- import type { IntelApiDeps } from './intel-api.js';
2
- export interface ListStrategiesArgs {
3
- active_only: boolean;
4
- }
5
- /**
6
- * Canonicalize model-produced arguments before OpenClaw validates them.
7
- *
8
- * OpenClaw's production validator coerces a JSON null to boolean false. That
9
- * would turn a malformed/omitted active-only request into an all-strategies
10
- * request. Only a genuine boolean false therefore opts into inactive rows;
11
- * every missing, null, string, array, or otherwise malformed input fails safe
12
- * to the active strategies requested by the operator-status workflow.
13
- */
14
- export declare function prepareListStrategiesArgs(raw: unknown): ListStrategiesArgs;
15
- export declare function listStrategiesTool(args: ListStrategiesArgs, deps: IntelApiDeps): Promise<Record<string, unknown> | {
16
- error: string;
17
- }>;
@@ -1,23 +0,0 @@
1
- // Tool: list_strategies — list all strategies in the Strategy Box.
2
- import { fetchIntelApi } from './intel-api.js';
3
- /**
4
- * Canonicalize model-produced arguments before OpenClaw validates them.
5
- *
6
- * OpenClaw's production validator coerces a JSON null to boolean false. That
7
- * would turn a malformed/omitted active-only request into an all-strategies
8
- * request. Only a genuine boolean false therefore opts into inactive rows;
9
- * every missing, null, string, array, or otherwise malformed input fails safe
10
- * to the active strategies requested by the operator-status workflow.
11
- */
12
- export function prepareListStrategiesArgs(raw) {
13
- if (!raw || typeof raw !== 'object' || Array.isArray(raw)) {
14
- return { active_only: true };
15
- }
16
- return {
17
- active_only: raw.active_only === false ? false : true,
18
- };
19
- }
20
- export async function listStrategiesTool(args, deps) {
21
- const query = args.active_only ? '?active=true' : '';
22
- return fetchIntelApi(`/api/strategies${query}`, deps);
23
- }
@@ -1,21 +0,0 @@
1
- import type { IExchangeAdapter } from '../exchange-adapter.js';
2
- import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
3
- import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
4
- interface ModifyStopArgs {
5
- symbol: string;
6
- new_stop_price: number;
7
- }
8
- interface ModifyStopResult {
9
- ok: true;
10
- symbol: string;
11
- old_stop_price: number | null;
12
- new_stop_price: number;
13
- }
14
- export declare function modifyStopTool(args: ModifyStopArgs, deps: {
15
- adapter: IExchangeAdapter;
16
- operationLock?: TradingOperationLock;
17
- checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
18
- }): Promise<ModifyStopResult | {
19
- error: string;
20
- }>;
21
- export {};
@@ -1,120 +0,0 @@
1
- // Tool: modify_stop — move the exchange-side stop-loss on an open live
2
- // position. Implemented as cancel-then-resubmit inside BracketManager, with
3
- // automatic rollback if the new submit fails.
4
- //
5
- // Paper mode: moves the position's metadata.stopPrice in place (the paper
6
- // stop-watcher reads it), so BE/trail works without a close+reopen round-trip.
7
- // Live mode without brackets enabled: error asking operator to enable.
8
- import { resolveBracketControl } from './bracket-control.js';
9
- import { validateStopDirection } from '../live/bracket-params.js';
10
- import { formatError } from '../logger.js';
11
- import { isWave9ManagedPosition } from '../wave9/paper-admission-guard.js';
12
- export async function modifyStopTool(args, deps) {
13
- if (!args.symbol)
14
- return { error: 'symbol is required.' };
15
- if (!Number.isFinite(args.new_stop_price) || args.new_stop_price <= 0) {
16
- return { error: 'new_stop_price must be a positive number.' };
17
- }
18
- if (!deps.adapter.isLive) {
19
- return modifyStopPaper(deps.adapter, args);
20
- }
21
- if (deps.checkWave9LiveSymbolOwnership && !deps.operationLock) {
22
- return {
23
- error: 'Live modify_stop refused: the shared trading operation lock is required ' +
24
- 'while Wave 9 LIVE ownership checks are enabled.',
25
- };
26
- }
27
- const modifyLive = async () => {
28
- if (deps.checkWave9LiveSymbolOwnership) {
29
- let ownership;
30
- try {
31
- ownership = await deps.checkWave9LiveSymbolOwnership(args.symbol);
32
- }
33
- catch (err) {
34
- return {
35
- error: `modify_stop refused at mutation boundary: Wave 9 LIVE ownership check failed ` +
36
- `for ${args.symbol} (${formatError(err)}).`,
37
- };
38
- }
39
- if (ownership.status === 'owned' || ownership.status === 'ambiguous') {
40
- return {
41
- error: `modify_stop refused at mutation boundary: ${args.symbol} has ` +
42
- `${ownership.status} Wave 9 LIVE ownership (${ownership.reason}). ` +
43
- 'Wave 9 uses its frozen initial 3x ATR emergency stop.',
44
- };
45
- }
46
- }
47
- const control = resolveBracketControl(deps.adapter);
48
- if (!control) {
49
- return { error: 'Bracket orders are not enabled. Set brackets.mode in plugin-config.json to "observe" or "enforce".' };
50
- }
51
- const entry = control.ledger.getBySymbol(args.symbol);
52
- if (!entry) {
53
- return { error: `No active bracket for ${args.symbol}.` };
54
- }
55
- // Direction check — catch flipped sign before burning a cancel+resubmit cycle
56
- const refPrice = entry.stopPrice && entry.targetPrice
57
- ? (entry.stopPrice + entry.targetPrice) / 2
58
- : await deps.adapter.getLastPrice(args.symbol);
59
- if (refPrice != null && refPrice > 0) {
60
- const msg = validateStopDirection(entry.entrySide, refPrice, args.new_stop_price);
61
- if (msg)
62
- return { error: msg };
63
- }
64
- try {
65
- await control.modifyStop(args.symbol, args.new_stop_price);
66
- return {
67
- ok: true,
68
- symbol: args.symbol,
69
- old_stop_price: entry.stopPrice ?? null,
70
- new_stop_price: args.new_stop_price,
71
- };
72
- }
73
- catch (err) {
74
- return { error: formatError(err) };
75
- }
76
- };
77
- try {
78
- return deps.operationLock
79
- ? await deps.operationLock.withAccountLock(`generic-modify-stop-final:${args.symbol}`, modifyLive)
80
- : await modifyLive();
81
- }
82
- catch (err) {
83
- return { error: formatError(err) };
84
- }
85
- }
86
- /** Paper: move the stop on the open position's metadata in place. Validates the
87
- * same direction geometry live does (stop on the losing side of the current
88
- * mark), then writes metadata.stopPrice — no fee, no entry/R reset. */
89
- function modifyStopPaper(adapter, args) {
90
- const sim = adapter.getSimulator();
91
- const pos = sim.getPositions(args.symbol)[0];
92
- if (!pos) {
93
- return { error: `No open position for ${args.symbol}.` };
94
- }
95
- if (isWave9ManagedPosition(pos)) {
96
- return { error: 'modify_stop refused: Wave 9 uses its frozen initial 3x ATR emergency stop.' };
97
- }
98
- // Validate against the current mark (permits breakeven / trailing — the stop
99
- // just has to stay on the losing side of where price is now).
100
- const refPrice = pos.markPrice;
101
- const entrySide = pos.side === 'long' ? 'buy' : 'sell';
102
- if (Number.isFinite(refPrice) && refPrice > 0) {
103
- const msg = validateStopDirection(entrySide, refPrice, args.new_stop_price);
104
- if (msg)
105
- return { error: msg };
106
- }
107
- const oldStop = pos.stopPrice ?? null;
108
- try {
109
- sim.updatePositionMetadata(args.symbol, { stopPrice: args.new_stop_price });
110
- }
111
- catch (err) {
112
- return { error: formatError(err) };
113
- }
114
- return {
115
- ok: true,
116
- symbol: args.symbol,
117
- old_stop_price: oldStop,
118
- new_stop_price: args.new_stop_price,
119
- };
120
- }
@@ -1,21 +0,0 @@
1
- import type { IExchangeAdapter } from '../exchange-adapter.js';
2
- import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
3
- import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
4
- interface ModifyTargetArgs {
5
- symbol: string;
6
- new_target_price: number;
7
- }
8
- interface ModifyTargetResult {
9
- ok: true;
10
- symbol: string;
11
- old_target_price: number | null;
12
- new_target_price: number;
13
- }
14
- export declare function modifyTargetTool(args: ModifyTargetArgs, deps: {
15
- adapter: IExchangeAdapter;
16
- operationLock?: TradingOperationLock;
17
- checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
18
- }): Promise<ModifyTargetResult | {
19
- error: string;
20
- }>;
21
- export {};