@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,12 +0,0 @@
1
- import type { IExchangeAdapter } from '../exchange-adapter.js';
2
- import type { BracketLedger } from '../live/bracket-ledger.js';
3
- export interface BracketControl {
4
- venue: 'binance' | 'hyperliquid';
5
- ledger: BracketLedger;
6
- modifyStop(symbol: string, newStopPrice: number): Promise<void>;
7
- modifyTarget(symbol: string, newTargetPrice: number): Promise<void>;
8
- }
9
- /** Resolve the venue's bracket-mutation surface, or null when brackets are
10
- * not enabled (Binance with brackets.mode=off; never null on HL live —
11
- * exchange-side legs are HL live's ONLY protection, so they are always on). */
12
- export declare function resolveBracketControl(adapter: IExchangeAdapter): BracketControl | null;
@@ -1,35 +0,0 @@
1
- // Venue dispatch for the bracket-mutating tools (issue #209).
2
- //
3
- // modify_stop / modify_target need one seam: "give me the thing that can move
4
- // a leg, plus the ledger that knows the current geometry". On Binance that is
5
- // BracketManager (+ LiveAdapter's ledger); on Hyperliquid it is the
6
- // HlBracketCoordinator (which owns its own venue-distinct ledger). The tools
7
- // must never know which venue they are on beyond this resolver — the
8
- // hard-cast-to-LiveAdapter pattern is exactly what left the HL arm returning
9
- // "Bracket orders are not enabled" on every call (the #209 recovery gap).
10
- import { HyperliquidLiveAdapter } from '../venues/hyperliquid/hl-live-adapter.js';
11
- /** Resolve the venue's bracket-mutation surface, or null when brackets are
12
- * not enabled (Binance with brackets.mode=off; never null on HL live —
13
- * exchange-side legs are HL live's ONLY protection, so they are always on). */
14
- export function resolveBracketControl(adapter) {
15
- if (adapter instanceof HyperliquidLiveAdapter) {
16
- const coordinator = adapter.getHlBracketCoordinator();
17
- return {
18
- venue: 'hyperliquid',
19
- ledger: coordinator.getLedger(),
20
- modifyStop: (symbol, px) => coordinator.modifyStop(symbol, px),
21
- modifyTarget: (symbol, px) => coordinator.modifyTarget(symbol, px),
22
- };
23
- }
24
- const live = adapter;
25
- const mgr = live.getBracketManager?.();
26
- const ledger = live.getBracketLedger?.();
27
- if (!mgr || !ledger)
28
- return null;
29
- return {
30
- venue: 'binance',
31
- ledger,
32
- modifyStop: (symbol, px) => mgr.modifyStop(symbol, px),
33
- modifyTarget: (symbol, px) => mgr.modifyTarget(symbol, px),
34
- };
35
- }
@@ -1,9 +0,0 @@
1
- import type { IExchangeAdapter } from '../exchange-adapter.js';
2
- import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
3
- import type { CcxtOrder } from '../types.js';
4
- export declare function cancelAllOrdersTool(args: {
5
- symbol?: string;
6
- }, deps: {
7
- adapter: IExchangeAdapter;
8
- operationLock?: TradingOperationLock;
9
- }): Promise<CcxtOrder[]>;
@@ -1,8 +0,0 @@
1
- // Tool: cancel_all_orders — cancel all open orders (paper or live)
2
- // NO readiness gate — emergency control (kill switch), must always work.
3
- export async function cancelAllOrdersTool(args, deps) {
4
- const cancel = () => deps.adapter.cancelAllOrders(args.symbol);
5
- return deps.adapter.isLive && deps.operationLock
6
- ? deps.operationLock.withAccountLock(`generic-cancel-all-orders-final:${args.symbol ?? 'all'}`, cancel)
7
- : cancel();
8
- }
@@ -1,14 +0,0 @@
1
- import type { IExchangeAdapter } from '../exchange-adapter.js';
2
- import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
3
- import type { CcxtOrder } from '../types.js';
4
- import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
5
- export declare function cancelOrderTool(args: {
6
- id: string;
7
- symbol?: string;
8
- }, deps: {
9
- adapter: IExchangeAdapter;
10
- operationLock?: TradingOperationLock;
11
- checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
12
- }): Promise<CcxtOrder | {
13
- error: string;
14
- }>;
@@ -1,60 +0,0 @@
1
- // Tool: cancel_order — cancel a single order (paper or live).
2
- // There is no readiness gate, but LIVE cancellation cannot individually strip
3
- // candidate-bound Wave 9 protection. The emergency escape is an explicit
4
- // operator close, which reduces exposure instead of leaving it naked.
5
- import { formatError } from '../logger.js';
6
- export async function cancelOrderTool(args, deps) {
7
- if (!args.id) {
8
- return { error: 'Order ID is required.' };
9
- }
10
- if (!deps.adapter.isLive) {
11
- try {
12
- return await deps.adapter.cancelOrder(args.id, args.symbol);
13
- }
14
- catch (err) {
15
- return { error: formatError(err) };
16
- }
17
- }
18
- if (deps.checkWave9LiveSymbolOwnership && !deps.operationLock) {
19
- return {
20
- error: 'Live cancel_order refused: the shared trading operation lock is required ' +
21
- 'while Wave 9 LIVE ownership checks are enabled.',
22
- };
23
- }
24
- const cancelLive = async () => {
25
- let symbol = args.symbol?.trim();
26
- if (!symbol) {
27
- const matches = (await deps.adapter.getOpenOrders())
28
- .filter((order) => order.id === args.id);
29
- if (matches.length !== 1 || !matches[0].symbol) {
30
- throw new Error(`cancel_order refused: order ${args.id} could not be resolved to exactly one ` +
31
- `trusted open-order symbol (matches=${matches.length}).`);
32
- }
33
- symbol = matches[0].symbol;
34
- }
35
- if (deps.checkWave9LiveSymbolOwnership) {
36
- let ownership;
37
- try {
38
- ownership = await deps.checkWave9LiveSymbolOwnership(symbol);
39
- }
40
- catch (err) {
41
- throw new Error(`cancel_order refused at mutation boundary: Wave 9 LIVE ownership check failed ` +
42
- `for ${symbol} (${formatError(err)}).`);
43
- }
44
- if (ownership.status === 'owned' || ownership.status === 'ambiguous') {
45
- throw new Error(`cancel_order refused at mutation boundary: ${symbol} has ` +
46
- `${ownership.status} Wave 9 LIVE ownership (${ownership.reason}). ` +
47
- 'Use operator_command to close the position instead of stripping candidate-bound protection.');
48
- }
49
- }
50
- return deps.adapter.cancelOrder(args.id, symbol);
51
- };
52
- try {
53
- return deps.operationLock
54
- ? await deps.operationLock.withAccountLock(`generic-cancel-order-final:${args.id}`, cancelLive)
55
- : await cancelLive();
56
- }
57
- catch (err) {
58
- return { error: formatError(err) };
59
- }
60
- }
@@ -1,46 +0,0 @@
1
- interface PositionInput {
2
- symbol: string;
3
- side: 'LONG' | 'SHORT';
4
- entry_price: number;
5
- current_price: number;
6
- stop_price: number;
7
- target_price?: number;
8
- quantity: number;
9
- entry_time: string;
10
- }
11
- interface CheckHealthArgs {
12
- positions: PositionInput[];
13
- account_balance: number;
14
- }
15
- interface PositionHealth {
16
- symbol: string;
17
- side: string;
18
- pnl: number;
19
- pnlPercent: number;
20
- pnlR: number;
21
- distanceToStopPercent: number;
22
- distanceToStopR: number;
23
- stopStatus: 'SAFE' | 'CLOSE' | 'CRITICAL' | 'BREACHED';
24
- distanceToTargetPercent: number | null;
25
- distanceToTargetR: number | null;
26
- targetReached: boolean;
27
- heatPercent: number;
28
- notionalPercent: number;
29
- timeInTradeMinutes: number;
30
- timeInTradeFormatted: string;
31
- timeStatus: 'FRESH' | 'NORMAL' | 'EXTENDED' | 'STALE';
32
- alerts: string[];
33
- }
34
- interface HealthSummary {
35
- positions: PositionHealth[];
36
- portfolio: {
37
- totalHeat: number;
38
- totalNotional: number;
39
- totalPnl: number;
40
- positionCount: number;
41
- heatStatus: 'LOW' | 'MODERATE' | 'ELEVATED' | 'HIGH' | 'CRITICAL';
42
- alerts: string[];
43
- };
44
- }
45
- export declare function checkPositionHealthTool(args: CheckHealthArgs): HealthSummary;
46
- export {};
@@ -1,194 +0,0 @@
1
- // Tool: check_position_health — Real-time position health monitor.
2
- // Computes heat, stop proximity, time-in-trade, and risk flags for open positions.
3
- // Pure local computation — no API calls needed.
4
- export function checkPositionHealthTool(args) {
5
- const { positions, account_balance } = args;
6
- if (!positions || positions.length === 0) {
7
- return {
8
- positions: [],
9
- portfolio: {
10
- totalHeat: 0,
11
- totalNotional: 0,
12
- totalPnl: 0,
13
- positionCount: 0,
14
- heatStatus: 'LOW',
15
- alerts: [],
16
- },
17
- };
18
- }
19
- if (account_balance <= 0) {
20
- return {
21
- positions: [],
22
- portfolio: {
23
- totalHeat: 0,
24
- totalNotional: 0,
25
- totalPnl: 0,
26
- positionCount: 0,
27
- heatStatus: 'CRITICAL',
28
- alerts: ['Account balance is zero or negative'],
29
- },
30
- };
31
- }
32
- const now = Date.now();
33
- const portfolioAlerts = [];
34
- let totalHeat = 0;
35
- let totalNotional = 0;
36
- let totalPnl = 0;
37
- const healthResults = positions.map((pos) => {
38
- const alerts = [];
39
- const dirMul = pos.side === 'LONG' ? 1 : -1;
40
- // ── P&L ──
41
- const pnl = (pos.current_price - pos.entry_price) * pos.quantity * dirMul;
42
- const notional = pos.entry_price * pos.quantity;
43
- const pnlPercent = notional > 0 ? (pnl / notional) * 100 : 0;
44
- // Risk per unit = distance from entry to stop
45
- const riskPerUnit = Math.abs(pos.entry_price - pos.stop_price);
46
- const riskAmount = riskPerUnit * pos.quantity;
47
- const pnlR = riskAmount > 0 ? pnl / riskAmount : 0;
48
- // ── Stop tracking ──
49
- const distToStop = pos.side === 'LONG'
50
- ? pos.current_price - pos.stop_price
51
- : pos.stop_price - pos.current_price;
52
- const distanceToStopPercent = pos.current_price > 0 ? (distToStop / pos.current_price) * 100 : 0;
53
- const distanceToStopR = riskPerUnit > 0 ? distToStop / riskPerUnit : 0;
54
- let stopStatus;
55
- if (distToStop <= 0) {
56
- stopStatus = 'BREACHED';
57
- alerts.push(`STOP BREACHED — price has passed stop level ($${pos.stop_price})`);
58
- }
59
- else if (distanceToStopR < 0.3) {
60
- stopStatus = 'CRITICAL';
61
- alerts.push(`Stop critically close (${distanceToStopR.toFixed(2)}R away)`);
62
- }
63
- else if (distanceToStopR < 0.7) {
64
- stopStatus = 'CLOSE';
65
- alerts.push(`Stop approaching (${distanceToStopR.toFixed(2)}R away)`);
66
- }
67
- else {
68
- stopStatus = 'SAFE';
69
- }
70
- // ── Target tracking ──
71
- let distanceToTargetPercent = null;
72
- let distanceToTargetR = null;
73
- let targetReached = false;
74
- if (pos.target_price != null) {
75
- const distToTarget = pos.side === 'LONG'
76
- ? pos.target_price - pos.current_price
77
- : pos.current_price - pos.target_price;
78
- distanceToTargetPercent = pos.current_price > 0 ? (distToTarget / pos.current_price) * 100 : 0;
79
- distanceToTargetR = riskPerUnit > 0 ? distToTarget / riskPerUnit : 0;
80
- targetReached = distToTarget <= 0;
81
- if (targetReached) {
82
- alerts.push('TARGET REACHED — consider taking profit');
83
- }
84
- }
85
- // If past target but still holding
86
- if (pnlR >= 2 && !targetReached) {
87
- alerts.push(`At ${pnlR.toFixed(1)}R profit — consider trailing stop or partial take-profit`);
88
- }
89
- // ── Heat (position risk as % of account) ──
90
- const heatPercent = (riskAmount / account_balance) * 100;
91
- const notionalPercent = (notional / account_balance) * 100;
92
- if (heatPercent > 5) {
93
- alerts.push(`High heat: ${heatPercent.toFixed(1)}% of account at risk in this position`);
94
- }
95
- else if (heatPercent > 3) {
96
- alerts.push(`Elevated heat: ${heatPercent.toFixed(1)}% of account at risk`);
97
- }
98
- totalHeat += heatPercent;
99
- totalNotional += notional;
100
- totalPnl += pnl;
101
- // ── Time in trade ──
102
- const entryMs = new Date(pos.entry_time).getTime();
103
- const elapsed = Math.max(0, now - entryMs);
104
- const minutes = Math.floor(elapsed / 60_000);
105
- const hours = Math.floor(minutes / 60);
106
- let timeFormatted;
107
- if (hours >= 24) {
108
- const days = Math.floor(hours / 24);
109
- timeFormatted = `${days}d ${hours % 24}h`;
110
- }
111
- else if (hours > 0) {
112
- timeFormatted = `${hours}h ${minutes % 60}m`;
113
- }
114
- else {
115
- timeFormatted = `${minutes}m`;
116
- }
117
- let timeStatus;
118
- if (minutes < 15)
119
- timeStatus = 'FRESH';
120
- else if (minutes < 240)
121
- timeStatus = 'NORMAL';
122
- else if (minutes < 720) {
123
- timeStatus = 'EXTENDED';
124
- if (pnlR < 0)
125
- alerts.push(`Held ${timeFormatted} underwater — review thesis`);
126
- }
127
- else {
128
- timeStatus = 'STALE';
129
- alerts.push(`Position held ${timeFormatted} — is original thesis still valid?`);
130
- }
131
- // Underwater for too long
132
- if (pnlR < -0.5 && minutes > 60) {
133
- alerts.push(`Underwater (${pnlR.toFixed(1)}R) for ${timeFormatted} — thesis may be invalid`);
134
- }
135
- return {
136
- symbol: pos.symbol,
137
- side: pos.side,
138
- pnl: +pnl.toFixed(2),
139
- pnlPercent: +pnlPercent.toFixed(2),
140
- pnlR: +pnlR.toFixed(2),
141
- distanceToStopPercent: +distanceToStopPercent.toFixed(2),
142
- distanceToStopR: +distanceToStopR.toFixed(2),
143
- stopStatus,
144
- distanceToTargetPercent: distanceToTargetPercent != null ? +distanceToTargetPercent.toFixed(2) : null,
145
- distanceToTargetR: distanceToTargetR != null ? +distanceToTargetR.toFixed(2) : null,
146
- targetReached,
147
- heatPercent: +heatPercent.toFixed(2),
148
- notionalPercent: +notionalPercent.toFixed(2),
149
- timeInTradeMinutes: minutes,
150
- timeInTradeFormatted: timeFormatted,
151
- timeStatus,
152
- alerts,
153
- };
154
- });
155
- // ── Portfolio-level assessment ──
156
- let heatStatus;
157
- if (totalHeat >= 15) {
158
- heatStatus = 'CRITICAL';
159
- portfolioAlerts.push(`CRITICAL portfolio heat: ${totalHeat.toFixed(1)}% — reduce exposure immediately`);
160
- }
161
- else if (totalHeat >= 10) {
162
- heatStatus = 'HIGH';
163
- portfolioAlerts.push(`High portfolio heat: ${totalHeat.toFixed(1)}% — no new positions`);
164
- }
165
- else if (totalHeat >= 6) {
166
- heatStatus = 'ELEVATED';
167
- portfolioAlerts.push(`Elevated portfolio heat: ${totalHeat.toFixed(1)}% — be cautious with new entries`);
168
- }
169
- else if (totalHeat >= 3) {
170
- heatStatus = 'MODERATE';
171
- }
172
- else {
173
- heatStatus = 'LOW';
174
- }
175
- const breachedCount = healthResults.filter(p => p.stopStatus === 'BREACHED').length;
176
- if (breachedCount > 0) {
177
- portfolioAlerts.push(`${breachedCount} position(s) past stop level — exit immediately`);
178
- }
179
- const criticalCount = healthResults.filter(p => p.stopStatus === 'CRITICAL').length;
180
- if (criticalCount > 0) {
181
- portfolioAlerts.push(`${criticalCount} position(s) critically close to stop`);
182
- }
183
- return {
184
- positions: healthResults,
185
- portfolio: {
186
- totalHeat: +totalHeat.toFixed(2),
187
- totalNotional: +totalNotional.toFixed(2),
188
- totalPnl: +totalPnl.toFixed(2),
189
- positionCount: positions.length,
190
- heatStatus,
191
- alerts: portfolioAlerts,
192
- },
193
- };
194
- }
@@ -1,24 +0,0 @@
1
- import type { PluginRuntime } from '../onboarding/runtime.js';
2
- import type { IExchangeAdapter } from '../exchange-adapter.js';
3
- import type { TradingMode } from '../types.js';
4
- export interface ClearExchangeCredentialsArgs {
5
- /** Must be `true`. Required so the skill's tool-discovery probe (which
6
- * passes empty args) never accidentally wipes credentials on startup. */
7
- confirm?: boolean;
8
- }
9
- export interface ClearExchangeCredentialsResult {
10
- ok: boolean;
11
- message: string;
12
- modeBefore: TradingMode;
13
- mode: TradingMode;
14
- rolledBackToPaper: boolean;
15
- readiness: string;
16
- }
17
- export interface ClearExchangeCredentialsDeps {
18
- runtime: PluginRuntime;
19
- adapterDeps: {
20
- adapter: IExchangeAdapter;
21
- };
22
- configPath?: string;
23
- }
24
- export declare function clearExchangeCredentialsTool(args: ClearExchangeCredentialsArgs, deps: ClearExchangeCredentialsDeps): Promise<ClearExchangeCredentialsResult>;
@@ -1,70 +0,0 @@
1
- // clear_exchange_credentials — operator-only plugin tool.
2
- //
3
- // Removes the `exchange` section from ~/.reefclaw/plugin-config.json and,
4
- // if the plugin is currently running in a mode that requires credentials
5
- // (SHADOW, MICRO_LIVE, LIVE), de-escalates to PAPER via runtime.reconnect().
6
- // This is the "pull the plug" button for when the operator wants to
7
- // remove Binance keys from the machine entirely.
8
- //
9
- // Security:
10
- // - Does NOT accept a new secret — pure delete.
11
- // - Always de-escalates to PAPER on mode rollback; never stays in a
12
- // live mode without credentials (would crash the adapter on first
13
- // order anyway).
14
- import { updatePluginConfig } from '../config/plugin-config-io.js';
15
- import { logger } from '../logger.js';
16
- const TAG = 'clear-exchange-credentials';
17
- export async function clearExchangeCredentialsTool(args, deps) {
18
- const modeBefore = deps.runtime.mode;
19
- if (args?.confirm !== true) {
20
- return {
21
- ok: false,
22
- message: 'clear_exchange_credentials requires confirm: true (prevents accidental probe wipes)',
23
- modeBefore,
24
- mode: modeBefore,
25
- rolledBackToPaper: false,
26
- readiness: deps.runtime.adapter.readiness,
27
- };
28
- }
29
- try {
30
- updatePluginConfig({ exchange: undefined }, deps.configPath);
31
- }
32
- catch (err) {
33
- const msg = err instanceof Error ? err.message : String(err);
34
- logger.error(TAG, `Failed to clear credentials: ${msg}`);
35
- return {
36
- ok: false,
37
- message: `Failed to remove credentials from config: ${msg}`,
38
- modeBefore,
39
- mode: modeBefore,
40
- rolledBackToPaper: false,
41
- readiness: deps.runtime.adapter.readiness,
42
- };
43
- }
44
- logger.info(TAG, 'Exchange credentials cleared from plugin-config.json');
45
- // If we were in a live mode, fall back to PAPER — running SHADOW or
46
- // MICRO_LIVE without credentials is a guaranteed broken state.
47
- let rolledBackToPaper = false;
48
- if (modeBefore !== 'PAPER') {
49
- try {
50
- // Also persist the mode downgrade so a subsequent restart doesn't
51
- // try to bring up a live adapter with no credentials.
52
- updatePluginConfig({ tradingMode: 'PAPER' }, deps.configPath);
53
- }
54
- catch (err) {
55
- logger.warn(TAG, `Failed to persist PAPER fallback: ${err instanceof Error ? err.message : String(err)}`);
56
- }
57
- await deps.runtime.reconnect({ mode: 'PAPER', exchange: null }, { adapterDeps: deps.adapterDeps });
58
- rolledBackToPaper = true;
59
- }
60
- return {
61
- ok: true,
62
- message: rolledBackToPaper
63
- ? `Credentials cleared and trading mode rolled back from ${modeBefore} to PAPER`
64
- : 'Credentials cleared',
65
- modeBefore,
66
- mode: deps.runtime.mode,
67
- rolledBackToPaper,
68
- readiness: deps.runtime.adapter.readiness,
69
- };
70
- }
@@ -1,45 +0,0 @@
1
- import type { PublicMarketDataApi } from '../ccxt/public-market-data-api.js';
2
- import type { IExchangeAdapter } from '../exchange-adapter.js';
3
- import type { CcxtOrder } from '../types.js';
4
- import { type ClosePositionArgs } from './assessment-validation.js';
5
- import { type AutoCaptureContext } from '../ingest/position-auto-capture.js';
6
- import { type ExitGateMode } from '../config/position-review-config.js';
7
- import type { TradingOperationLock } from '../lifecycle/trading-operation-lock.js';
8
- import type { Wave9LiveExecutionLedger } from '../wave9/live-execution-ledger.js';
9
- import type { Wave9LiveSymbolOwnershipCheck } from '../wave9/live-symbol-ownership.js';
10
- import { type Wave9LiveResidualProtectionResult } from '../wave9/live-residual-protection.js';
11
- import { type Wave9PaperAdmissionGuard } from '../wave9/paper-admission-guard.js';
12
- export declare function closePositionTool(args: ClosePositionArgs, deps: {
13
- binanceApi: PublicMarketDataApi;
14
- adapter: IExchangeAdapter;
15
- autoCapture?: AutoCaptureContext;
16
- /** Override for tests — production reads from plugin-config.json on each
17
- * call so the flag can be flipped without a restart. */
18
- exitGateMode?: ExitGateMode;
19
- wave9AdmissionGuard?: Wave9PaperAdmissionGuard;
20
- refreshPaperState?: () => void;
21
- wave9TradingModeCheck?: () => string;
22
- wave9VenueCheck?: () => string;
23
- captureWave9PositionFingerprint?: (symbol: string) => Promise<{
24
- fingerprint: string;
25
- position: {
26
- candidateId?: string;
27
- missionId?: string;
28
- setupType?: string;
29
- side: 'long' | 'short';
30
- };
31
- }>;
32
- wave9LiveLedger?: Wave9LiveExecutionLedger;
33
- checkWave9LiveSymbolOwnership?: Wave9LiveSymbolOwnershipCheck;
34
- reprotectWave9LiveResidual?: (adapter: IExchangeAdapter, ledger: Wave9LiveExecutionLedger, candidateId: string, symbol: string) => Promise<Wave9LiveResidualProtectionResult>;
35
- operationLock?: TradingOperationLock;
36
- operationLockHeld?: boolean;
37
- }): Promise<CcxtOrder | {
38
- error: string;
39
- }>;
40
- /** Test seam — clears the circuit-breaker state between unit tests. */
41
- export declare const __testing__: {
42
- resetCircuitBreaker(): void;
43
- /** Inspect current circuit-breaker state — for assertions. */
44
- getCircuitBreakerCount(): number;
45
- };