@reefclaw/connect 0.1.10 → 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 (396) hide show
  1. package/assets/bridge/gateway/event-parser.d.ts +6 -1
  2. package/assets/bridge/gateway/event-parser.js +19 -2
  3. package/assets/bridge/gateway/heartbeat-cron.d.ts +27 -0
  4. package/assets/bridge/gateway/heartbeat-cron.js +85 -0
  5. package/assets/bridge/gateway/poller.d.ts +1 -0
  6. package/assets/bridge/gateway/poller.js +14 -2
  7. package/assets/bridge/providers/gateway.d.ts +24 -2
  8. package/assets/bridge/providers/gateway.js +124 -25
  9. package/assets/bridge/setup.js +6 -51
  10. package/assets/shared/signals/conditions/registry.js +11 -2
  11. package/assets/shared/signals/strategy-adapter.js +17 -7
  12. package/assets/skill/SKILL.md +2 -0
  13. package/dist/deps.js +2 -2
  14. package/dist/plugin.js +35 -7
  15. package/package.json +1 -1
  16. package/assets/plugin/audit/mode-transition-audit.d.ts +0 -11
  17. package/assets/plugin/audit/mode-transition-audit.js +0 -29
  18. package/assets/plugin/balance-utils.d.ts +0 -36
  19. package/assets/plugin/balance-utils.js +0 -98
  20. package/assets/plugin/ccxt/binance-ban-gate.d.ts +0 -47
  21. package/assets/plugin/ccxt/binance-ban-gate.js +0 -420
  22. package/assets/plugin/ccxt/binance-private.d.ts +0 -346
  23. package/assets/plugin/ccxt/binance-private.js +0 -1525
  24. package/assets/plugin/ccxt/binance-public.d.ts +0 -34
  25. package/assets/plugin/ccxt/binance-public.js +0 -180
  26. package/assets/plugin/ccxt/intel-public.d.ts +0 -25
  27. package/assets/plugin/ccxt/intel-public.js +0 -80
  28. package/assets/plugin/ccxt/public-market-data-api.d.ts +0 -12
  29. package/assets/plugin/ccxt/public-market-data-api.js +0 -9
  30. package/assets/plugin/config/agent-config-client.d.ts +0 -77
  31. package/assets/plugin/config/agent-config-client.js +0 -188
  32. package/assets/plugin/config/agent-config-poller.d.ts +0 -32
  33. package/assets/plugin/config/agent-config-poller.js +0 -101
  34. package/assets/plugin/config/brackets-config.d.ts +0 -22
  35. package/assets/plugin/config/brackets-config.js +0 -58
  36. package/assets/plugin/config/entitlement-gate.d.ts +0 -51
  37. package/assets/plugin/config/entitlement-gate.js +0 -137
  38. package/assets/plugin/config/gate-store.d.ts +0 -18
  39. package/assets/plugin/config/gate-store.js +0 -61
  40. package/assets/plugin/config/plugin-config-io.d.ts +0 -215
  41. package/assets/plugin/config/plugin-config-io.js +0 -111
  42. package/assets/plugin/config/position-review-config.d.ts +0 -35
  43. package/assets/plugin/config/position-review-config.js +0 -105
  44. package/assets/plugin/config/tool-gate.d.ts +0 -53
  45. package/assets/plugin/config/tool-gate.js +0 -128
  46. package/assets/plugin/config/user-data-stream-config.d.ts +0 -89
  47. package/assets/plugin/config/user-data-stream-config.js +0 -239
  48. package/assets/plugin/connector-supervisor.d.ts +0 -36
  49. package/assets/plugin/connector-supervisor.js +0 -149
  50. package/assets/plugin/exchange-adapter.d.ts +0 -65
  51. package/assets/plugin/exchange-adapter.js +0 -4
  52. package/assets/plugin/index.d.ts +0 -30
  53. package/assets/plugin/index.js +0 -2678
  54. package/assets/plugin/ingest/pending-entry-metadata.d.ts +0 -74
  55. package/assets/plugin/ingest/pending-entry-metadata.js +0 -236
  56. package/assets/plugin/ingest/position-auto-capture.d.ts +0 -103
  57. package/assets/plugin/ingest/position-auto-capture.js +0 -411
  58. package/assets/plugin/ingest/position-decisions-client.d.ts +0 -322
  59. package/assets/plugin/ingest/position-decisions-client.js +0 -296
  60. package/assets/plugin/ingest/readiness-reporter.d.ts +0 -42
  61. package/assets/plugin/ingest/readiness-reporter.js +0 -163
  62. package/assets/plugin/ingest/reconcile-db-vs-exchange.d.ts +0 -13
  63. package/assets/plugin/ingest/reconcile-db-vs-exchange.js +0 -114
  64. package/assets/plugin/ingest/reconciler-cleanup.d.ts +0 -37
  65. package/assets/plugin/ingest/reconciler-cleanup.js +0 -147
  66. package/assets/plugin/ingest/rest-gap-filler.d.ts +0 -191
  67. package/assets/plugin/ingest/rest-gap-filler.js +0 -565
  68. package/assets/plugin/ingest/touched-symbols-store.d.ts +0 -25
  69. package/assets/plugin/ingest/touched-symbols-store.js +0 -96
  70. package/assets/plugin/ingest/trade-store-client.d.ts +0 -40
  71. package/assets/plugin/ingest/trade-store-client.js +0 -125
  72. package/assets/plugin/ingest/ws-ingest.d.ts +0 -43
  73. package/assets/plugin/ingest/ws-ingest.js +0 -126
  74. package/assets/plugin/learning/setup-family.d.ts +0 -21
  75. package/assets/plugin/learning/setup-family.js +0 -103
  76. package/assets/plugin/lifecycle/install-signal-handlers.d.ts +0 -33
  77. package/assets/plugin/lifecycle/install-signal-handlers.js +0 -112
  78. package/assets/plugin/lifecycle/shutdown-coordinator.d.ts +0 -43
  79. package/assets/plugin/lifecycle/shutdown-coordinator.js +0 -131
  80. package/assets/plugin/lifecycle/trading-operation-lock.d.ts +0 -17
  81. package/assets/plugin/lifecycle/trading-operation-lock.js +0 -14
  82. package/assets/plugin/live/bracket-id.d.ts +0 -26
  83. package/assets/plugin/live/bracket-id.js +0 -112
  84. package/assets/plugin/live/bracket-ledger.d.ts +0 -54
  85. package/assets/plugin/live/bracket-ledger.js +0 -267
  86. package/assets/plugin/live/bracket-manager.d.ts +0 -82
  87. package/assets/plugin/live/bracket-manager.js +0 -478
  88. package/assets/plugin/live/bracket-params.d.ts +0 -22
  89. package/assets/plugin/live/bracket-params.js +0 -124
  90. package/assets/plugin/live/bracket-reconciler.d.ts +0 -95
  91. package/assets/plugin/live/bracket-reconciler.js +0 -573
  92. package/assets/plugin/live/bracket-types.d.ts +0 -102
  93. package/assets/plugin/live/bracket-types.js +0 -8
  94. package/assets/plugin/live/deposit-tracker.d.ts +0 -62
  95. package/assets/plugin/live/deposit-tracker.js +0 -97
  96. package/assets/plugin/live/emergency-controls.d.ts +0 -32
  97. package/assets/plugin/live/emergency-controls.js +0 -226
  98. package/assets/plugin/live/exchange-errors.d.ts +0 -12
  99. package/assets/plugin/live/exchange-errors.js +0 -130
  100. package/assets/plugin/live/exchange-info-cache.d.ts +0 -37
  101. package/assets/plugin/live/exchange-info-cache.js +0 -134
  102. package/assets/plugin/live/fact-subscriber.d.ts +0 -78
  103. package/assets/plugin/live/fact-subscriber.js +0 -182
  104. package/assets/plugin/live/intent-journal.d.ts +0 -42
  105. package/assets/plugin/live/intent-journal.js +0 -122
  106. package/assets/plugin/live/listen-key-manager.d.ts +0 -70
  107. package/assets/plugin/live/listen-key-manager.js +0 -169
  108. package/assets/plugin/live/live-adapter.d.ts +0 -287
  109. package/assets/plugin/live/live-adapter.js +0 -1777
  110. package/assets/plugin/live/live-balance-enricher.d.ts +0 -32
  111. package/assets/plugin/live/live-balance-enricher.js +0 -104
  112. package/assets/plugin/live/live-bracket-api.d.ts +0 -13
  113. package/assets/plugin/live/live-bracket-api.js +0 -20
  114. package/assets/plugin/live/live-state-store.d.ts +0 -194
  115. package/assets/plugin/live/live-state-store.js +0 -450
  116. package/assets/plugin/live/local-signal-service.d.ts +0 -57
  117. package/assets/plugin/live/local-signal-service.js +0 -151
  118. package/assets/plugin/live/local-strategy-evaluator.d.ts +0 -62
  119. package/assets/plugin/live/local-strategy-evaluator.js +0 -131
  120. package/assets/plugin/live/microstructure-assembler.d.ts +0 -54
  121. package/assets/plugin/live/microstructure-assembler.js +0 -148
  122. package/assets/plugin/live/order-poller.d.ts +0 -29
  123. package/assets/plugin/live/order-poller.js +0 -125
  124. package/assets/plugin/live/position-state-store.d.ts +0 -83
  125. package/assets/plugin/live/position-state-store.js +0 -237
  126. package/assets/plugin/live/proposal-decision-listener.d.ts +0 -70
  127. package/assets/plugin/live/proposal-decision-listener.js +0 -292
  128. package/assets/plugin/live/proposal-manager.d.ts +0 -76
  129. package/assets/plugin/live/proposal-manager.js +0 -140
  130. package/assets/plugin/live/rate-limiter.d.ts +0 -47
  131. package/assets/plugin/live/rate-limiter.js +0 -159
  132. package/assets/plugin/live/reconciler.d.ts +0 -39
  133. package/assets/plugin/live/reconciler.js +0 -175
  134. package/assets/plugin/live/setup-buckets.d.ts +0 -7
  135. package/assets/plugin/live/setup-buckets.js +0 -33
  136. package/assets/plugin/live/slippage-tracker.d.ts +0 -45
  137. package/assets/plugin/live/slippage-tracker.js +0 -78
  138. package/assets/plugin/live/stop-watcher.d.ts +0 -60
  139. package/assets/plugin/live/stop-watcher.js +0 -215
  140. package/assets/plugin/live/user-data-active-probe.d.ts +0 -54
  141. package/assets/plugin/live/user-data-active-probe.js +0 -180
  142. package/assets/plugin/live/user-data-stream-controller.d.ts +0 -200
  143. package/assets/plugin/live/user-data-stream-controller.js +0 -579
  144. package/assets/plugin/live/user-data-stream-ws.d.ts +0 -22
  145. package/assets/plugin/live/user-data-stream-ws.js +0 -63
  146. package/assets/plugin/live/user-data-stream.d.ts +0 -243
  147. package/assets/plugin/live/user-data-stream.js +0 -704
  148. package/assets/plugin/logger.d.ts +0 -2
  149. package/assets/plugin/logger.js +0 -2
  150. package/assets/plugin/mfe.d.ts +0 -21
  151. package/assets/plugin/mfe.js +0 -68
  152. package/assets/plugin/onboarding/mode-ladder.d.ts +0 -1
  153. package/assets/plugin/onboarding/mode-ladder.js +0 -3
  154. package/assets/plugin/onboarding/runtime.d.ts +0 -84
  155. package/assets/plugin/onboarding/runtime.js +0 -173
  156. package/assets/plugin/openclaw.plugin.json +0 -92
  157. package/assets/plugin/paper-adapter.d.ts +0 -24
  158. package/assets/plugin/paper-adapter.js +0 -91
  159. package/assets/plugin/persistence/state-manager.d.ts +0 -66
  160. package/assets/plugin/persistence/state-manager.js +0 -222
  161. package/assets/plugin/pinned-plan.d.ts +0 -9
  162. package/assets/plugin/pinned-plan.js +0 -23
  163. package/assets/plugin/portfolio/wave9-admission.d.ts +0 -67
  164. package/assets/plugin/portfolio/wave9-admission.js +0 -262
  165. package/assets/plugin/portfolio/wave9-policy.d.ts +0 -36
  166. package/assets/plugin/portfolio/wave9-policy.js +0 -183
  167. package/assets/plugin/risk/pre-trade-check.d.ts +0 -38
  168. package/assets/plugin/risk/pre-trade-check.js +0 -345
  169. package/assets/plugin/risk/pre-trade-types.d.ts +0 -60
  170. package/assets/plugin/risk/pre-trade-types.js +0 -3
  171. package/assets/plugin/shadow/shadow-tracker.d.ts +0 -36
  172. package/assets/plugin/shadow/shadow-tracker.js +0 -151
  173. package/assets/plugin/shadow/types.d.ts +0 -42
  174. package/assets/plugin/shadow/types.js +0 -20
  175. package/assets/plugin/shared/indicators-extended.d.ts +0 -52
  176. package/assets/plugin/shared/indicators-extended.js +0 -291
  177. package/assets/plugin/shared/indicators.d.ts +0 -15
  178. package/assets/plugin/shared/indicators.js +0 -114
  179. package/assets/plugin/signals/conditions/registry.d.ts +0 -16
  180. package/assets/plugin/signals/conditions/registry.js +0 -1324
  181. package/assets/plugin/signals/conditions/types.d.ts +0 -1
  182. package/assets/plugin/signals/conditions/types.js +0 -4
  183. package/assets/plugin/signals/direction-rules.d.ts +0 -3
  184. package/assets/plugin/signals/direction-rules.js +0 -24
  185. package/assets/plugin/signals/entry-rules.d.ts +0 -6
  186. package/assets/plugin/signals/entry-rules.js +0 -33
  187. package/assets/plugin/signals/serialize-context.d.ts +0 -4
  188. package/assets/plugin/signals/serialize-context.js +0 -39
  189. package/assets/plugin/signals/stop-rules.d.ts +0 -3
  190. package/assets/plugin/signals/stop-rules.js +0 -48
  191. package/assets/plugin/signals/strategy-adapter.d.ts +0 -47
  192. package/assets/plugin/signals/strategy-adapter.js +0 -199
  193. package/assets/plugin/signals/types.d.ts +0 -1
  194. package/assets/plugin/signals/types.js +0 -8
  195. package/assets/plugin/simulator/exchange-simulator.d.ts +0 -93
  196. package/assets/plugin/simulator/exchange-simulator.js +0 -689
  197. package/assets/plugin/simulator/fill-engine.d.ts +0 -53
  198. package/assets/plugin/simulator/fill-engine.js +0 -280
  199. package/assets/plugin/simulator/paper-market-feed.d.ts +0 -26
  200. package/assets/plugin/simulator/paper-market-feed.js +0 -104
  201. package/assets/plugin/simulator/realistic-fills.d.ts +0 -59
  202. package/assets/plugin/simulator/realistic-fills.js +0 -175
  203. package/assets/plugin/simulator/types.d.ts +0 -224
  204. package/assets/plugin/simulator/types.js +0 -43
  205. package/assets/plugin/strategy/builtin-strategies.d.ts +0 -2
  206. package/assets/plugin/strategy/builtin-strategies.js +0 -113
  207. package/assets/plugin/strategy/condition-registry.d.ts +0 -3
  208. package/assets/plugin/strategy/condition-registry.js +0 -153
  209. package/assets/plugin/strategy/evaluator.d.ts +0 -70
  210. package/assets/plugin/strategy/evaluator.js +0 -98
  211. package/assets/plugin/tools/assessment-validation.d.ts +0 -120
  212. package/assets/plugin/tools/assessment-validation.js +0 -415
  213. package/assets/plugin/tools/attach-brackets.d.ts +0 -39
  214. package/assets/plugin/tools/attach-brackets.js +0 -399
  215. package/assets/plugin/tools/audit-bracket-protection.d.ts +0 -49
  216. package/assets/plugin/tools/audit-bracket-protection.js +0 -527
  217. package/assets/plugin/tools/cancel-all-orders.d.ts +0 -9
  218. package/assets/plugin/tools/cancel-all-orders.js +0 -8
  219. package/assets/plugin/tools/cancel-order.d.ts +0 -14
  220. package/assets/plugin/tools/cancel-order.js +0 -60
  221. package/assets/plugin/tools/check-position-health.d.ts +0 -46
  222. package/assets/plugin/tools/check-position-health.js +0 -194
  223. package/assets/plugin/tools/clear-exchange-credentials.d.ts +0 -24
  224. package/assets/plugin/tools/clear-exchange-credentials.js +0 -70
  225. package/assets/plugin/tools/close-position.d.ts +0 -45
  226. package/assets/plugin/tools/close-position.js +0 -722
  227. package/assets/plugin/tools/create-order.d.ts +0 -82
  228. package/assets/plugin/tools/create-order.js +0 -1516
  229. package/assets/plugin/tools/exit-gate.d.ts +0 -58
  230. package/assets/plugin/tools/exit-gate.js +0 -162
  231. package/assets/plugin/tools/fetch-balance.d.ts +0 -5
  232. package/assets/plugin/tools/fetch-balance.js +0 -4
  233. package/assets/plugin/tools/fetch-ohlcv.d.ts +0 -11
  234. package/assets/plugin/tools/fetch-ohlcv.js +0 -8
  235. package/assets/plugin/tools/fetch-open-orders.d.ts +0 -7
  236. package/assets/plugin/tools/fetch-open-orders.js +0 -4
  237. package/assets/plugin/tools/fetch-positions.d.ts +0 -7
  238. package/assets/plugin/tools/fetch-positions.js +0 -4
  239. package/assets/plugin/tools/fetch-ticker.d.ts +0 -11
  240. package/assets/plugin/tools/fetch-ticker.js +0 -5
  241. package/assets/plugin/tools/get-agent-profile.d.ts +0 -4
  242. package/assets/plugin/tools/get-agent-profile.js +0 -6
  243. package/assets/plugin/tools/get-analytics.d.ts +0 -6
  244. package/assets/plugin/tools/get-analytics.js +0 -7
  245. package/assets/plugin/tools/get-backtest.d.ts +0 -12
  246. package/assets/plugin/tools/get-backtest.js +0 -91
  247. package/assets/plugin/tools/get-basis.d.ts +0 -7
  248. package/assets/plugin/tools/get-basis.js +0 -7
  249. package/assets/plugin/tools/get-bracket-config.d.ts +0 -11
  250. package/assets/plugin/tools/get-bracket-config.js +0 -24
  251. package/assets/plugin/tools/get-cascade-risk.d.ts +0 -7
  252. package/assets/plugin/tools/get-cascade-risk.js +0 -8
  253. package/assets/plugin/tools/get-crypto-metrics.d.ts +0 -18
  254. package/assets/plugin/tools/get-crypto-metrics.js +0 -62
  255. package/assets/plugin/tools/get-cvd.d.ts +0 -6
  256. package/assets/plugin/tools/get-cvd.js +0 -6
  257. package/assets/plugin/tools/get-divergences.d.ts +0 -6
  258. package/assets/plugin/tools/get-divergences.js +0 -6
  259. package/assets/plugin/tools/get-funding-context.d.ts +0 -6
  260. package/assets/plugin/tools/get-funding-context.js +0 -16
  261. package/assets/plugin/tools/get-liquidation-levels.d.ts +0 -7
  262. package/assets/plugin/tools/get-liquidation-levels.js +0 -7
  263. package/assets/plugin/tools/get-liquidation-pulse.d.ts +0 -9
  264. package/assets/plugin/tools/get-liquidation-pulse.js +0 -22
  265. package/assets/plugin/tools/get-market-breadth.d.ts +0 -6
  266. package/assets/plugin/tools/get-market-breadth.js +0 -8
  267. package/assets/plugin/tools/get-market-intel.d.ts +0 -19
  268. package/assets/plugin/tools/get-market-intel.js +0 -116
  269. package/assets/plugin/tools/get-market-structure.d.ts +0 -47
  270. package/assets/plugin/tools/get-market-structure.js +0 -198
  271. package/assets/plugin/tools/get-my-mined-patterns.d.ts +0 -20
  272. package/assets/plugin/tools/get-my-mined-patterns.js +0 -61
  273. package/assets/plugin/tools/get-my-proposed-learnings.d.ts +0 -20
  274. package/assets/plugin/tools/get-my-proposed-learnings.js +0 -55
  275. package/assets/plugin/tools/get-my-recent-reviews.d.ts +0 -22
  276. package/assets/plugin/tools/get-my-recent-reviews.js +0 -66
  277. package/assets/plugin/tools/get-orderbook.d.ts +0 -21
  278. package/assets/plugin/tools/get-orderbook.js +0 -32
  279. package/assets/plugin/tools/get-pattern-scan.d.ts +0 -7
  280. package/assets/plugin/tools/get-pattern-scan.js +0 -8
  281. package/assets/plugin/tools/get-regime.d.ts +0 -6
  282. package/assets/plugin/tools/get-regime.js +0 -7
  283. package/assets/plugin/tools/get-relevant-learnings.d.ts +0 -21
  284. package/assets/plugin/tools/get-relevant-learnings.js +0 -65
  285. package/assets/plugin/tools/get-resting-liquidity.d.ts +0 -6
  286. package/assets/plugin/tools/get-resting-liquidity.js +0 -11
  287. package/assets/plugin/tools/get-risk-scenario.d.ts +0 -29
  288. package/assets/plugin/tools/get-risk-scenario.js +0 -47
  289. package/assets/plugin/tools/get-risk-summary.d.ts +0 -51
  290. package/assets/plugin/tools/get-risk-summary.js +0 -118
  291. package/assets/plugin/tools/get-sentiment.d.ts +0 -4
  292. package/assets/plugin/tools/get-sentiment.js +0 -6
  293. package/assets/plugin/tools/get-session-review.d.ts +0 -7
  294. package/assets/plugin/tools/get-session-review.js +0 -8
  295. package/assets/plugin/tools/get-setup-detail.d.ts +0 -7
  296. package/assets/plugin/tools/get-setup-detail.js +0 -311
  297. package/assets/plugin/tools/get-signals.d.ts +0 -15
  298. package/assets/plugin/tools/get-signals.js +0 -54
  299. package/assets/plugin/tools/get-sizing.d.ts +0 -6
  300. package/assets/plugin/tools/get-sizing.js +0 -6
  301. package/assets/plugin/tools/get-trade-feedback.d.ts +0 -7
  302. package/assets/plugin/tools/get-trade-feedback.js +0 -8
  303. package/assets/plugin/tools/get-trade-flow.d.ts +0 -7
  304. package/assets/plugin/tools/get-trade-flow.js +0 -7
  305. package/assets/plugin/tools/get-volume-analysis.d.ts +0 -21
  306. package/assets/plugin/tools/get-volume-analysis.js +0 -74
  307. package/assets/plugin/tools/get-volume-profile.d.ts +0 -7
  308. package/assets/plugin/tools/get-volume-profile.js +0 -7
  309. package/assets/plugin/tools/get-wave9-status.d.ts +0 -127
  310. package/assets/plugin/tools/get-wave9-status.js +0 -796
  311. package/assets/plugin/tools/helpers.d.ts +0 -26
  312. package/assets/plugin/tools/helpers.js +0 -39
  313. package/assets/plugin/tools/intel-api.d.ts +0 -34
  314. package/assets/plugin/tools/intel-api.js +0 -119
  315. package/assets/plugin/tools/intel-cache.d.ts +0 -25
  316. package/assets/plugin/tools/intel-cache.js +0 -148
  317. package/assets/plugin/tools/list-strategies.d.ts +0 -17
  318. package/assets/plugin/tools/list-strategies.js +0 -23
  319. package/assets/plugin/tools/modify-stop.d.ts +0 -21
  320. package/assets/plugin/tools/modify-stop.js +0 -120
  321. package/assets/plugin/tools/modify-target.d.ts +0 -21
  322. package/assets/plugin/tools/modify-target.js +0 -110
  323. package/assets/plugin/tools/propose-learning.d.ts +0 -22
  324. package/assets/plugin/tools/propose-learning.js +0 -65
  325. package/assets/plugin/tools/query-review-outcomes.d.ts +0 -30
  326. package/assets/plugin/tools/query-review-outcomes.js +0 -64
  327. package/assets/plugin/tools/query-trades.d.ts +0 -21
  328. package/assets/plugin/tools/query-trades.js +0 -37
  329. package/assets/plugin/tools/record-position-reviews.d.ts +0 -38
  330. package/assets/plugin/tools/record-position-reviews.js +0 -147
  331. package/assets/plugin/tools/save-strategy.d.ts +0 -16
  332. package/assets/plugin/tools/save-strategy.js +0 -46
  333. package/assets/plugin/tools/scan-pairs.d.ts +0 -18
  334. package/assets/plugin/tools/scan-pairs.js +0 -231
  335. package/assets/plugin/tools/score-setup.d.ts +0 -31
  336. package/assets/plugin/tools/score-setup.js +0 -268
  337. package/assets/plugin/tools/set-bracket-requirement.d.ts +0 -18
  338. package/assets/plugin/tools/set-bracket-requirement.js +0 -81
  339. package/assets/plugin/tools/set-exchange-credentials.d.ts +0 -25
  340. package/assets/plugin/tools/set-exchange-credentials.js +0 -80
  341. package/assets/plugin/tools/set-trading-mode.d.ts +0 -26
  342. package/assets/plugin/tools/set-trading-mode.js +0 -135
  343. package/assets/plugin/tools/test-exchange-credentials.d.ts +0 -16
  344. package/assets/plugin/tools/test-exchange-credentials.js +0 -100
  345. package/assets/plugin/tools/toggle-strategy.d.ts +0 -8
  346. package/assets/plugin/tools/toggle-strategy.js +0 -15
  347. package/assets/plugin/trading-params-cache.d.ts +0 -26
  348. package/assets/plugin/trading-params-cache.js +0 -52
  349. package/assets/plugin/types.d.ts +0 -134
  350. package/assets/plugin/types.js +0 -7
  351. package/assets/plugin/util/plugin-paths.d.ts +0 -3
  352. package/assets/plugin/util/plugin-paths.js +0 -15
  353. package/assets/plugin/venues/hyperliquid/hl-balance.d.ts +0 -116
  354. package/assets/plugin/venues/hyperliquid/hl-balance.js +0 -145
  355. package/assets/plugin/venues/hyperliquid/hl-brackets.d.ts +0 -102
  356. package/assets/plugin/venues/hyperliquid/hl-brackets.js +0 -172
  357. package/assets/plugin/venues/hyperliquid/hl-cloid.d.ts +0 -22
  358. package/assets/plugin/venues/hyperliquid/hl-cloid.js +0 -82
  359. package/assets/plugin/venues/hyperliquid/hl-info-cache.d.ts +0 -46
  360. package/assets/plugin/venues/hyperliquid/hl-info-cache.js +0 -125
  361. package/assets/plugin/venues/hyperliquid/hl-live-adapter.d.ts +0 -88
  362. package/assets/plugin/venues/hyperliquid/hl-live-adapter.js +0 -353
  363. package/assets/plugin/venues/hyperliquid/hl-precision.d.ts +0 -61
  364. package/assets/plugin/venues/hyperliquid/hl-precision.js +0 -176
  365. package/assets/plugin/venues/hyperliquid/hl-private.d.ts +0 -88
  366. package/assets/plugin/venues/hyperliquid/hl-private.js +0 -357
  367. package/assets/plugin/venues/hyperliquid/hl-public.d.ts +0 -79
  368. package/assets/plugin/venues/hyperliquid/hl-public.js +0 -429
  369. package/assets/plugin/venues/hyperliquid/hl-rate-gate.d.ts +0 -57
  370. package/assets/plugin/venues/hyperliquid/hl-rate-gate.js +0 -220
  371. package/assets/plugin/venues/hyperliquid/hl-user-stream.d.ts +0 -90
  372. package/assets/plugin/venues/hyperliquid/hl-user-stream.js +0 -220
  373. package/assets/plugin/venues/registry.d.ts +0 -38
  374. package/assets/plugin/venues/registry.js +0 -46
  375. package/assets/plugin/venues/symbols.d.ts +0 -43
  376. package/assets/plugin/venues/symbols.js +0 -107
  377. package/assets/plugin/wave9/live-account-capture.d.ts +0 -67
  378. package/assets/plugin/wave9/live-account-capture.js +0 -435
  379. package/assets/plugin/wave9/live-autonomous-protection.d.ts +0 -39
  380. package/assets/plugin/wave9/live-autonomous-protection.js +0 -112
  381. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.d.ts +0 -33
  382. package/assets/plugin/wave9/live-durable-reconciliation-scheduler.js +0 -115
  383. package/assets/plugin/wave9/live-execution-ledger.d.ts +0 -107
  384. package/assets/plugin/wave9/live-execution-ledger.js +0 -498
  385. package/assets/plugin/wave9/live-position-confirmation.d.ts +0 -18
  386. package/assets/plugin/wave9/live-position-confirmation.js +0 -111
  387. package/assets/plugin/wave9/live-residual-protection.d.ts +0 -18
  388. package/assets/plugin/wave9/live-residual-protection.js +0 -250
  389. package/assets/plugin/wave9/live-startup-reconciliation.d.ts +0 -38
  390. package/assets/plugin/wave9/live-startup-reconciliation.js +0 -454
  391. package/assets/plugin/wave9/live-symbol-ownership.d.ts +0 -20
  392. package/assets/plugin/wave9/live-symbol-ownership.js +0 -132
  393. package/assets/plugin/wave9/paper-admission-guard.d.ts +0 -199
  394. package/assets/plugin/wave9/paper-admission-guard.js +0 -650
  395. package/assets/plugin/wave9/usdm-evidence-provider.d.ts +0 -42
  396. package/assets/plugin/wave9/usdm-evidence-provider.js +0 -133
@@ -1,169 +0,0 @@
1
- // ListenKeyManager — owns the Binance Futures user-data listenKey lifecycle.
2
- //
3
- // Flow:
4
- // 1. `start()` — POST /fapi/v1/listenKey → emit 'keyMinted' with the listenKey.
5
- // 2. Schedule PUT /fapi/v1/listenKey every `refreshIntervalMs` (default 25 min).
6
- // Binance expires idle keys at 60 min; 25 min gives a 2x safety margin.
7
- // 3. On failed keep-alive, re-mint (POST) a fresh key and emit 'keyRotated'.
8
- // Binance returns the SAME listenKey for repeat POSTs from the same API
9
- // key, so "re-mint" is effectively a probe that the key is still valid.
10
- // If the probe succeeds, we accept its answer; if it fails, we emit
11
- // 'keyKeepAliveFailed' and stop — the parent UserDataStream schedules
12
- // a reconnect that re-enters `start()`.
13
- // 4. `stop()` — clear timer + DELETE /fapi/v1/listenKey (best-effort).
14
- //
15
- // Why this is a separate component:
16
- // - Testable in isolation with fake timers + a mock API.
17
- // - UserDataStream can stay focused on frame parsing + reconnect logic.
18
- // - Graduated alert thresholds live here (3 failed refreshes = WARN,
19
- // 10 = ERROR) rather than being spread through the WS state machine.
20
- import { EventEmitter } from 'node:events';
21
- import { logger, formatError } from '../logger.js';
22
- const TAG = 'listen-key-manager';
23
- const REAL_TIMER_DEPS = {
24
- setTimeout: (fn, ms) => setTimeout(fn, ms),
25
- clearTimeout: (h) => clearTimeout(h),
26
- now: () => Date.now(),
27
- };
28
- /** Lightweight typed emitter — EventEmitter with a phantom type. */
29
- export class ListenKeyManager extends EventEmitter {
30
- api;
31
- refreshIntervalMs;
32
- maxConsecutiveFailures;
33
- timers;
34
- currentKey = null;
35
- keyMintedAt = null;
36
- refreshTimer = null;
37
- consecutiveFailures = 0;
38
- running = false;
39
- constructor(api, options = {}) {
40
- super();
41
- this.api = api;
42
- this.refreshIntervalMs = options.refreshIntervalMs ?? 25 * 60_000;
43
- this.maxConsecutiveFailures = options.maxConsecutiveFailures ?? 3;
44
- this.timers = {
45
- setTimeout: options.timers?.setTimeout ?? REAL_TIMER_DEPS.setTimeout,
46
- clearTimeout: options.timers?.clearTimeout ?? REAL_TIMER_DEPS.clearTimeout,
47
- now: options.timers?.now ?? REAL_TIMER_DEPS.now,
48
- };
49
- }
50
- /** Mint a listenKey and start the refresh loop. Returns the minted key.
51
- * Throws if the first POST fails — caller decides how to back off. */
52
- async start() {
53
- if (this.running) {
54
- throw new Error('ListenKeyManager already started');
55
- }
56
- const key = await this.api.createListenKey();
57
- this.currentKey = key;
58
- this.keyMintedAt = this.timers.now();
59
- this.consecutiveFailures = 0;
60
- this.running = true;
61
- this.emit('keyMinted', key);
62
- this.scheduleRefresh();
63
- logger.info(TAG, `listenKey minted (hash=${hashKey(key)}), refresh every ${this.refreshIntervalMs / 1000}s`);
64
- return key;
65
- }
66
- /** Stop the refresh loop and best-effort close the key. Idempotent.
67
- * For GRACEFUL shutdown only — a reconnect-driven teardown must use
68
- * `stopKeepAlive()` instead (see below). */
69
- async stop() {
70
- if (!this.running)
71
- return;
72
- this.running = false;
73
- if (this.refreshTimer) {
74
- this.timers.clearTimeout(this.refreshTimer);
75
- this.refreshTimer = null;
76
- }
77
- if (this.currentKey) {
78
- try {
79
- await this.api.closeListenKey();
80
- }
81
- catch (err) {
82
- // Not worth retrying on shutdown — Binance expires idle keys anyway.
83
- logger.warn(TAG, `closeListenKey failed on stop (non-fatal): ${formatError(err)}`);
84
- }
85
- this.currentKey = null;
86
- this.keyMintedAt = null;
87
- }
88
- }
89
- /** Stop the refresh loop WITHOUT the DELETE — for reconnect-driven closes.
90
- * Binance returns the SAME active listenKey on a re-POST and merely
91
- * extends its validity (doc-verified 2026-07-02: "Doing a POST on an
92
- * account with an active listenKey will return the currently active
93
- * listenKey and extend its validity for 60 minutes"), so an in-flight
94
- * DELETE racing the reconnect's POST can land AFTER it and invalidate the
95
- * key the fresh socket just authenticated with — a silent dead stream.
96
- * Skipping the DELETE is safe: an unused key expires on its own after
97
- * 60 min of no keep-alive. Synchronous + idempotent. */
98
- stopKeepAlive() {
99
- if (!this.running)
100
- return;
101
- this.running = false;
102
- if (this.refreshTimer) {
103
- this.timers.clearTimeout(this.refreshTimer);
104
- this.refreshTimer = null;
105
- }
106
- this.currentKey = null;
107
- this.keyMintedAt = null;
108
- }
109
- /** Current listenKey, or null if stopped. */
110
- getKey() {
111
- return this.currentKey;
112
- }
113
- /** Age in ms since the key was last minted. Null if stopped. Useful for
114
- * observability dashboards — a key far beyond refreshIntervalMs but still
115
- * alive means Binance is tolerating us past the nominal window. */
116
- getKeyAge() {
117
- if (this.keyMintedAt == null)
118
- return null;
119
- return this.timers.now() - this.keyMintedAt;
120
- }
121
- /** Number of consecutive failed keep-alive probes. Exposed for diagnostics. */
122
- getConsecutiveFailures() {
123
- return this.consecutiveFailures;
124
- }
125
- // ---- Internal ----
126
- scheduleRefresh() {
127
- if (!this.running)
128
- return;
129
- this.refreshTimer = this.timers.setTimeout(() => {
130
- this.refreshTimer = null;
131
- void this.refresh();
132
- }, this.refreshIntervalMs);
133
- }
134
- async refresh() {
135
- if (!this.running)
136
- return;
137
- try {
138
- await this.api.keepAliveListenKey();
139
- this.consecutiveFailures = 0;
140
- this.emit('keyRefreshed');
141
- logger.info(TAG, `listenKey refreshed (age=${Math.round((this.getKeyAge() ?? 0) / 1000)}s)`);
142
- this.scheduleRefresh();
143
- }
144
- catch (err) {
145
- this.consecutiveFailures += 1;
146
- const reason = formatError(err);
147
- if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
148
- // Stream is dead. Don't reschedule — parent will restart us.
149
- logger.error(TAG, `listenKey keep-alive failed ${this.consecutiveFailures} times (last: ${reason}) — giving up`);
150
- this.running = false;
151
- if (this.refreshTimer) {
152
- this.timers.clearTimeout(this.refreshTimer);
153
- this.refreshTimer = null;
154
- }
155
- this.emit('keyKeepAliveFailed', reason);
156
- return;
157
- }
158
- // Transient — log and retry on the normal cadence. We deliberately do
159
- // NOT shrink the interval on failure; the keep-alive window is 60 min
160
- // so we can afford up to 2 more tries before the key expires.
161
- logger.warn(TAG, `listenKey keep-alive failed (${this.consecutiveFailures}/${this.maxConsecutiveFailures}): ${reason}`);
162
- this.scheduleRefresh();
163
- }
164
- }
165
- }
166
- /** First 8 chars of a listenKey for log correlation without leaking the key. */
167
- function hashKey(key) {
168
- return key.length > 8 ? key.slice(0, 8) : '(short)';
169
- }
@@ -1,287 +0,0 @@
1
- import { EventEmitter } from 'node:events';
2
- import type { IExchangeAdapter, AdapterReadiness, ClientOrderResolution, OrderOptions } from '../exchange-adapter.js';
3
- import { BinancePrivateApi } from '../ccxt/binance-private.js';
4
- import type { BinanceAlgoOrderProof } from '../ccxt/binance-private.js';
5
- import type { CcxtOrder, CcxtBalance, CcxtPosition, TradingMode, ExchangeConfig } from '../types.js';
6
- import type { PositionMetadata, CloseReason } from '../simulator/types.js';
7
- import { ExchangeInfoCache } from './exchange-info-cache.js';
8
- import { BinanceRateLimiter } from './rate-limiter.js';
9
- import { IntentJournal } from './intent-journal.js';
10
- import { OrderPoller } from './order-poller.js';
11
- import { SlippageTracker } from './slippage-tracker.js';
12
- import { PositionReconciler } from './reconciler.js';
13
- import { LiveBalanceEnricher } from './live-balance-enricher.js';
14
- import { DepositTracker } from './deposit-tracker.js';
15
- import { BracketLedger } from './bracket-ledger.js';
16
- import { BracketManager } from './bracket-manager.js';
17
- import { type BracketMode } from '../config/brackets-config.js';
18
- import { type UserDataStreamMode, type UserDataStreamTunables } from '../config/user-data-stream-config.js';
19
- import { UserDataStreamController } from './user-data-stream-controller.js';
20
- import type { AutoCaptureContext } from '../ingest/position-auto-capture.js';
21
- import type { TradeStoreClient } from '../ingest/trade-store-client.js';
22
- /** Optional audit-trail wiring (TRADE_AUDIT_TRAIL_PLAN Phase 1). Caller
23
- * passes this only when userDataStream.dbWrite='on' AND the WEBAPP_INGEST_TOKEN
24
- * + REEFCLAW_USER_ID env vars are present. Forwarded into the controller
25
- * which spins up a WsIngest alongside the existing read path. */
26
- export interface TradeIngestWiring {
27
- client: TradeStoreClient;
28
- userId: string;
29
- exchange?: string;
30
- }
31
- export interface Wave9ProtectionLossEvent {
32
- source: 'algo_canceled' | 'algo_rejected' | 'reconciler_missing';
33
- symbol: string;
34
- bracketId: string;
35
- entryClientOrderId: string;
36
- entrySide: 'buy' | 'sell';
37
- stopClientOrderId?: string;
38
- detail: string;
39
- }
40
- export type Wave9ProtectionLossHandler = (event: Wave9ProtectionLossEvent) => Promise<void> | void;
41
- /**
42
- * Backfill `balance.free[cur] = total[cur]` for currencies where Binance's CCXT
43
- * response left the per-currency `free` and `used` at zero despite a non-zero
44
- * total. Only safe when `used` is zero — otherwise the exchange really is
45
- * reserving margin and we must not inflate availability.
46
- */
47
- export declare function repairFreeFromTotal(balance: CcxtBalance): void;
48
- export declare class LiveAdapter extends EventEmitter implements IExchangeAdapter {
49
- readonly mode: TradingMode;
50
- readonly isLive = true;
51
- private api;
52
- private sizeCapMultiplier;
53
- private maxPositionUSDT;
54
- private exchangeInfo;
55
- private isHedgeMode;
56
- private getOpenOrdersUnavailableUntil;
57
- private static readonly OPEN_ORDERS_RL_COOLDOWN_MS;
58
- private rateLimiter;
59
- private intentJournal;
60
- private orderPoller;
61
- private slippageTracker;
62
- private reconciler;
63
- private enricher;
64
- private depositTracker;
65
- private readonly bracketMode;
66
- private bracketLedger;
67
- private bracketManager;
68
- private bracketReconciler;
69
- private wave9ProtectionLossHandler?;
70
- private readonly wave9ProtectionLossInFlight;
71
- private readonly pendingWave9ProtectionLossBySymbol;
72
- private static readonly PENDING_WAVE9_PROTECTION_LOSS_CAP;
73
- private readonly userDataStreamMode;
74
- private userDataStream;
75
- private readonly wsAlgoStatusByCid;
76
- private static readonly WS_ALGO_STATUS_CAP;
77
- private static readonly WS_LIVE_LEG_MAX_AGE_MS;
78
- private _sessionStartNav;
79
- private lastIncomeRefreshMs;
80
- private incomeAnchorUtcDay;
81
- private liveMetadata;
82
- private _readiness;
83
- get readiness(): AdapterReadiness;
84
- /** Session-start NAV, captured once at initialization. Used for drawdown calculation. */
85
- getSessionStartNav(): number | null;
86
- constructor(config: ExchangeConfig, mode: 'MICRO_LIVE' | 'LIVE', microLiveConfig?: {
87
- sizeCapPercent?: number;
88
- maxPositionUSDT?: number;
89
- }, bracketMode?: BracketMode, userDataStreamMode?: UserDataStreamMode, userDataStreamTunables?: UserDataStreamTunables,
90
- /** TRADE_AUDIT_TRAIL_PLAN Phase 1 — optional audit-trail wiring. Wired
91
- * through to UserDataStreamController. Absent today on every existing
92
- * call site (default off); operator-driven once activation is approved. */
93
- tradeIngest?: TradeIngestWiring,
94
- /** Position-decision auto-capture wiring. When provided alongside
95
- * tradeIngest, ws-ingest also routes every TRADE event through
96
- * `onWsFillObserved` to capture limit-order entries + scale-ins
97
- * (PR1 deferral resolution, 2026-05-03). Optional for back-compat. */
98
- autoCapture?: AutoCaptureContext);
99
- /** Get the underlying BinancePrivateApi (for advanced queries like fetchTicker). */
100
- getApi(): BinancePrivateApi;
101
- /** Get the exchange info cache (for symbol rules). */
102
- getExchangeInfo(): ExchangeInfoCache;
103
- /** Whether the account is in hedge mode. */
104
- getIsHedgeMode(): boolean;
105
- /** Get safety modules for external access (dashboard, tools, etc.). */
106
- getRateLimiter(): BinanceRateLimiter;
107
- getIntentJournal(): IntentJournal;
108
- getOrderPoller(): OrderPoller;
109
- getSlippageTracker(): SlippageTracker;
110
- getReconciler(): PositionReconciler;
111
- getEnricher(): LiveBalanceEnricher;
112
- getDepositTracker(): DepositTracker;
113
- /** Active user-data-stream mode. `'off'` when the feature flag is disabled. */
114
- getUserDataStreamMode(): UserDataStreamMode;
115
- /** User-data stream controller, or null if mode='off'. Used by dashboards
116
- * and diagnostic tools to read the live-state store + health. */
117
- getUserDataStream(): UserDataStreamController | null;
118
- /**
119
- * Post-registration async initialization.
120
- * Must complete before create_order is allowed (readiness gate).
121
- * Emergency controls (cancel, close) work regardless of readiness.
122
- */
123
- initialize(): Promise<void>;
124
- /**
125
- * Acknowledge existing positions on startup.
126
- * Transitions DEGRADED → READY. Exchange info + position mode are already loaded
127
- * (they're loaded before the position check in initialize()).
128
- */
129
- acknowledgePositions(): Promise<void>;
130
- /**
131
- * Tear down background loops so the adapter can be replaced at runtime
132
- * (e.g. when the operator changes credentials or trading mode from the
133
- * dashboard). Must be called before discarding the LiveAdapter reference
134
- * or the poller + reconciler timers will keep firing against stale state.
135
- *
136
- * Idempotent — safe to call multiple times.
137
- */
138
- shutdown(): void;
139
- createOrder(symbol: string, side: 'buy' | 'sell', type: 'market' | 'limit', amount: number, price?: number, metadata?: PositionMetadata, options?: OrderOptions): Promise<CcxtOrder>;
140
- /**
141
- * Attach brackets in the background. Auto-flattens on failure per locked
142
- * decision #2. Never throws — errors are surfaced via emitted events and
143
- * the subsequent flatten.
144
- */
145
- private attachBracketsAsync;
146
- /** Install the Wave 9-only autonomous recovery bridge. With no handler,
147
- * every generic bracket lifecycle remains byte-for-byte behaviorally
148
- * unchanged. Runtime reapplies this setter after adapter reconnects. */
149
- setWave9ProtectionLossHandler(handler?: Wave9ProtectionLossHandler): void;
150
- private notifyWave9ProtectionLoss;
151
- /**
152
- * AUTHORITATIVE bracket-lifecycle handler — Binance's ALGO_UPDATE push.
153
- *
154
- * Why this exists (2026-05-15 RCA, doc-verified): pre-fix the plugin
155
- * learned bracket state by REST-polling `audit_bracket_protection` /
156
- * `fetchOpenOrders` and *guessing* — under a 429 storm that produced the
157
- * audit→re-attach→cancel spiral that flushed live positions. Binance
158
- * already PUSHES authoritative conditional-order lifecycle. Doc-exact
159
- * status semantics (developers.binance.com → Event Algo Order Update):
160
- *
161
- * EXPIRED = SYSTEM cancel. The canonical trigger is "GTE_GTC
162
- * conditional + position closed → Binance auto-cancels the
163
- * surviving sibling". So EXPIRED on our bracket cid ⇒ the
164
- * position just closed by a non-close_position path (bracket
165
- * fill, manual, opposite-side). EXPECTED — not a fault.
166
- * TRIGGERED / FINISHED = the bracket fired (SL/TP hit) → position closed.
167
- * CANCELED = MANUAL cancel (an explicit cancelOrder from us). Post the
168
- * bracket-reconciler fix we should NOT be doing this while a
169
- * position is open; if we see it, it's the canary that some
170
- * *other* path still strips protection — WARN loudly.
171
- *
172
- * For EXPIRED/TRIGGERED/FINISHED we (a) mark the ledger terminal so the
173
- * attach-brackets re-attach loop STOPS chasing a bracket Binance already
174
- * removed, and (b) emit the SAME `drift_detected` shape the position
175
- * reconciler emits, so the existing, tested close-bypass cleanup
176
- * (`onReconcilerObservedClose` in index.ts) runs immediately instead of
177
- * up to 60 s later — which is what clears the stale state-store entry and
178
- * stops the NEXT entry on the symbol being mis-classified as a scale-in
179
- * (the bug that left fresh positions naked). No auto-flatten here: that
180
- * stays deferred until this signal has soaked.
181
- */
182
- private onAlgoUpdate;
183
- /** Expose the bracket manager for agent-facing tools (modify_stop, etc.).
184
- * Returns null when bracket mode is 'off'. */
185
- getBracketManager(): BracketManager | null;
186
- /** Expose the bracket ledger for reconciliation + admin queries. */
187
- getBracketLedger(): BracketLedger | null;
188
- /** Is the user-data WS store currently trusted (seeded + fresh + no gap)?
189
- * The Tier-1 gate for resolveBracketLegLiveness — when false the WS
190
- * per-cid signal is NOT consulted (a stale/gapped stream that missed a
191
- * CANCELED would otherwise yield a false 'live' on a naked leg — the exact
192
- * flaw the layered design exists to prevent). Null stream (mode=off) ⇒
193
- * never trusted ⇒ always the REST authority. */
194
- isUserDataStoreTrusted(): boolean;
195
- /** Authoritative per-bracket-leg liveness — the Phase 2 disambiguator that
196
- * replaces inferring presence/absence from a broad openOrders snapshot
197
- * (the SOL/INJ spiral root: a *successful* empty /fapi/v1/openAlgoOrders
198
- * is NOT proof a leg is gone).
199
- *
200
- * Precedence (the agreed layering):
201
- * 1. WS fast-path — ONLY behind isUserDataStoreTrusted(): the real
202
- * per-cid ALGO_UPDATE status (incl. CANCELED, which the ledger does
203
- * NOT record). Zero weight, sub-second. No record for the cid ⇒ no
204
- * WS opinion ⇒ fall through (never infer from absence).
205
- * 2. REST authority — queryAlgoOrderStatus(cid): a DIRECT weight-1
206
- * question about that exact order id. Used when WS is untrusted or
207
- * silent on the cid.
208
- * 3. 'unknown' — both unavailable. The d59e51b safe floor: callers MUST
209
- * refuse destructive action and retry; NEVER treat 'unknown' as
210
- * 'terminal'/'stale'.
211
- *
212
- * 'live' = leg is on the exchange (do NOT reattach/clobber).
213
- * 'terminal' = positively confirmed gone (CANCELED/EXPIRED/REJECTED) or
214
- * fired (TRIGGERED/FINISHED) — only this licenses repair.
215
- * 'unknown' = could not get an answer — safe-wait. */
216
- resolveBracketLegLiveness(cid: string): Promise<'live' | 'terminal' | 'unknown'>;
217
- /** Immediate full-shape proof for one exact native conditional order. */
218
- resolveBracketLegProof(cid: string): Promise<BinanceAlgoOrderProof | null>;
219
- /** Symbol-scoped generalization of the trusted-WS fast-path — the
220
- * authoritative action-layer guard for the 2026-05-16 INJ bracket spiral.
221
- *
222
- * `resolveBracketLegLiveness(cid)` answers about ONE cid. The spiral is:
223
- * a prior `attach_brackets` reattach placed a FRESH bracket that is live
224
- * on the exchange under a NEW cid, while the ledger row still holds the
225
- * PREVIOUS, genuinely-terminal cids. Classifying only the ledger's cids
226
- * yields a false 'stale' → clear+reattach cancels the live fresh bracket
227
- * → naked → audit unprotected → attach → spiral (prod: INJ/USDT cancelled
228
- * every ~15-40s for hours). This asks the question the ledger cids can't:
229
- * "is ANY rc-* bracket leg for this symbol live RIGHT NOW, under any cid?"
230
- *
231
- * Trust model (identical to resolveBracketLegLiveness Tier-1): the WS map
232
- * is consulted ONLY when `isUserDataStoreTrusted()` (seeded + fresh +
233
- * no-gap — the property that guarantees no missed CANCELED, so a record
234
- * reading 'live' really is live). When the store is NOT trusted this
235
- * returns `{ trusted:false, liveCids:[] }` and the caller must NOT infer
236
- * "no live leg" from it — it falls back to the per-leg REST authority and,
237
- * failing that, refuses the destructive action (the d59e51b safe floor).
238
- * A record older than WS_LIVE_LEG_MAX_AGE_MS is ignored (caller falls back
239
- * too) so a stale 'live' can never suppress a genuine repair forever. */
240
- findTrustedLiveBracketCidsForSymbol(symbol: string): {
241
- trusted: boolean;
242
- liveCids: string[];
243
- };
244
- /** Cancel every bracket-tagged (SL or TP) open order for a symbol. Used by
245
- * the `attach_brackets` recovery tool to clear stale bracket orders before
246
- * re-attaching a fresh pair. Does not touch non-bracket orders. Returns
247
- * the number successfully cancelled. Errors are logged + swallowed —
248
- * "already gone" is treated as success by the underlying cancel path. */
249
- cancelSymbolBracketOrders(symbol: string): Promise<number>;
250
- cancelOrder(orderId: string, symbol?: string): Promise<CcxtOrder>;
251
- cancelAllOrders(symbol?: string): Promise<CcxtOrder[]>;
252
- closePosition(symbol: string, closeReason?: CloseReason): Promise<CcxtOrder>;
253
- /** Re-arm protection on a position whose closePosition flow cancelled the
254
- * brackets and then failed every market-close attempt. Reuses the normal
255
- * attach machinery: re-register the ledger row (terminal row → fresh
256
- * pending_entry with the SAME stop/target levels) and run the standard
257
- * 3-retry attach. Never throws — this runs on the already-failing close
258
- * path; on any failure it emits the reconciler's `position_unprotected`
259
- * drift shape (re-emitted upstream as `bracket_drift`) plus a loud log so
260
- * the operator knows re-protection is required. */
261
- private reattachBracketsAfterFailedClose;
262
- getBalance(): Promise<CcxtBalance>;
263
- /** Re-anchor the realized-today seed + sessionStartNav from /fapi/v1/income.
264
- * Throttled to {@link INCOME_REFRESH_MIN_INTERVAL_MS}; UTC date rollover
265
- * forces an immediate refresh. Best-effort — failures are logged and
266
- * swallowed so a transient income-endpoint blip never blocks a balance
267
- * read. Called from getBalance() with the fresh quote wallet so we don't
268
- * fetch balance twice.
269
- */
270
- private refreshIncomeAnchor;
271
- getPositions(symbol?: string): Promise<CcxtPosition[]>;
272
- getPositionsOrNull(symbol?: string): Promise<CcxtPosition[] | null>;
273
- /** Merge agent-supplied entry metadata + ratchet MFE state into the raw
274
- * CCXT position list. Side effect: drops metadata for symbols no longer
275
- * in the open-positions snapshot (only when called without a symbol filter
276
- * — symbol-scoped calls skip cleanup so we don't lose context for other
277
- * open positions). */
278
- private decoratePositionsWithMetadata;
279
- getOpenOrders(symbol?: string): Promise<CcxtOrder[]>;
280
- fetchOrder(orderId: string, symbol?: string): Promise<CcxtOrder | null>;
281
- resolveOrderByClientId(clientOrderId: string, symbol: string): Promise<ClientOrderResolution>;
282
- getLastPrice(symbol: string): Promise<number | null>;
283
- /** Sync rate limiter from exchange response headers after every private API call. */
284
- private syncRateLimits;
285
- private loadExchangeInfo;
286
- private detectPositionMode;
287
- }