@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,231 +0,0 @@
1
- // Tool: scan_pairs — scan all symbols for strategy setups.
2
- // Fetches pre-computed facts from intelligence, evaluates user's active strategies,
3
- // ranks by confluence score, returns concise summary (~300 tokens).
4
- //
5
- // Caching: facts and strategies share a process-wide cache with get_setup_detail
6
- // (see intel-cache.ts). The shared cache eliminates the 2026-05-15 scan vs
7
- // drill-down divergence — after a heartbeat scan, every get_setup_detail call
8
- // for a symbol in the scan set sees the same snapshot the scan ranked it from.
9
- //
10
- // Learning pre-filter (2026-05-15): when decisionsDeps are wired, the scan
11
- // fetches the user's confirmed entry-time learnings and splits results into
12
- // `rankings` (no matching learning) and `vetoed_setups` (matching learning
13
- // surfaced inline with the directive). The agent's eye lands on actionable
14
- // candidates first; vetoed candidates are still visible so the agent can
15
- // apply override conditions if the directive allows. Saves the drill-in
16
- // round-trip on the ~6 macd_oversold_reversal-style candidates per
17
- // heartbeat the agent was rejecting post-scorecard pre-fix.
18
- import { intelSymbolOnVenue, presentIntelSymbol, resolveIntelSymbol } from './intel-api.js';
19
- import { scanAllPairs } from '../strategy/evaluator.js';
20
- import { getAllFactsCached, getStrategiesCached, __testing__ as cacheTesting } from './intel-cache.js';
21
- import { normalizeSetupFamily, resolveTriggerFamilies } from '../learning/setup-family.js';
22
- const LEARNINGS_TTL_MS = 60_000;
23
- const entryLearningsCache = new Map();
24
- /** Family-keying gate (2026-06-22). Off by default → byte-identical exact-match
25
- * behaviour. On → scan veto matches by stable setup_family, surviving the agent's
26
- * free-text setup_type drift. See docs/CLAUDE/learning-loop.md. */
27
- function familyKeyingEnabled() {
28
- return process.env.RC_LEARNING_FAMILY_KEYING === 'on';
29
- }
30
- async function getEntryLearningsCached(client, userId) {
31
- const now = Date.now();
32
- const cached = entryLearningsCache.get(userId);
33
- if (cached && now < cached.expiry)
34
- return cached.value;
35
- // No setup_type / regime filter — we want ALL the user's entry-time
36
- // learnings so we can match them against every candidate locally.
37
- let resp;
38
- try {
39
- resp = await client.getRelevantLearnings(userId, { appliesAt: 'entry' });
40
- }
41
- catch {
42
- return [];
43
- }
44
- const value = resp?.learnings ?? [];
45
- entryLearningsCache.set(userId, { value, expiry: now + LEARNINGS_TTL_MS });
46
- return value;
47
- }
48
- /** True iff the learning's triggerCondition applies to the (setup, regime)
49
- * pair, with rules tightened for scan-time pre-filter use.
50
- *
51
- * Two key differences vs the looser webapp matcher in
52
- * /api/internal/learnings:
53
- *
54
- * 1. CAMEL/SNAKE TOLERANCE. The pattern miner emits `setupType` (camelCase)
55
- * into mined_patterns.match_conditions, which is copied verbatim into
56
- * learnings.trigger_condition on operator confirm. The webapp matcher
57
- * reads `setup_type` only, so every confirmed learning silently falls
58
- * through to the "missing key = wildcard" branch and matches every
59
- * query. That broke scan_pairs' vetoed_setups bucket on the first live
60
- * soak after the 2026-05-15 deploy — every candidate got pushed into
61
- * vetoed because every learning was matching every candidate. We
62
- * accept both forms here so the transition + write-side fix can land
63
- * without bricking the matcher in between.
64
- *
65
- * 2. NO WILDCARD MATCH AT SCAN TIME. A learning with empty / missing
66
- * trigger keys is intended as "applies broadly — remember this rule"
67
- * at decision time (entry/heartbeat/close), NOT as "veto every scan
68
- * candidate". For scan_pairs specifically, we require the trigger to
69
- * pin AT LEAST ONE of {setup, regime} explicitly. Otherwise scan
70
- * produces zero rankings and the agent has to bypass the scanner
71
- * entirely — which is what the 2026-05-15 16:53 UTC heartbeat reported.
72
- */
73
- function learningMatches(learning, setupType, regime) {
74
- const t = learning.triggerCondition;
75
- if (!t || typeof t !== 'object')
76
- return false; // no constraints → not a scan veto
77
- const tObj = t;
78
- // Accept either snake_case or camelCase from the JSONB. Snake_case is the
79
- // canonical form (matches plugin tool args, SKILL.md, validator); camelCase
80
- // is the transitional form the pattern miner emitted pre-2026-05-15.
81
- const tSetup = tObj.setup_type ?? tObj.setupType;
82
- const tRegime = tObj.regime ?? tObj.regimeKey;
83
- const tFamily = tObj.setup_family ?? tObj.setupFamily;
84
- if (familyKeyingEnabled()) {
85
- // Family-aware scan veto (2026-06-22): match by stable setup_family so a
86
- // confirmed "avoid X" learning keeps vetoing the family as the agent renames
87
- // its setups. resolveTriggerFamilies normalizes setup_type → family, or uses
88
- // an explicit setup_family from the family-keyed miner.
89
- const targetFamilies = resolveTriggerFamilies(tFamily, tSetup);
90
- // Still require at least one constraint (setup family OR regime) — an empty
91
- // trigger must NOT veto every candidate (the 2026-05-15 wildcard bug).
92
- if (targetFamilies == null && tRegime == null)
93
- return false;
94
- if (targetFamilies != null &&
95
- !targetFamilies.includes(normalizeSetupFamily(setupType))) {
96
- return false;
97
- }
98
- if (tRegime != null) {
99
- if (Array.isArray(tRegime)) {
100
- if (!tRegime.includes(regime))
101
- return false;
102
- }
103
- else if (tRegime !== regime)
104
- return false;
105
- }
106
- return true;
107
- }
108
- // Legacy exact-match veto (default).
109
- // Require at least one constraint to count as a scan-time veto.
110
- if (tSetup == null && tRegime == null)
111
- return false;
112
- if (tSetup != null) {
113
- if (Array.isArray(tSetup)) {
114
- if (!tSetup.includes(setupType))
115
- return false;
116
- }
117
- else if (tSetup !== setupType)
118
- return false;
119
- }
120
- if (tRegime != null) {
121
- if (Array.isArray(tRegime)) {
122
- if (!tRegime.includes(regime))
123
- return false;
124
- }
125
- else if (tRegime !== regime)
126
- return false;
127
- }
128
- return true;
129
- }
130
- export async function scanPairsTool(args, deps, decisionsDeps) {
131
- const minScore = args.min_score ?? 4;
132
- // 1. Fetch all symbol facts (cached, shared with get_setup_detail)
133
- const factsRes = await getAllFactsCached(deps);
134
- if ('error' in factsRes)
135
- return factsRes;
136
- // Venue scope: only rank symbols this box can actually trade. Without this
137
- // an HL box ranks Binance USDT candidates that die at the order-path price
138
- // fetch (2026-07-13 wisekid), and a Binance box would rank HL_ rows once
139
- // intel serves them. No-op on binance today (facts carry no HL_ rows yet).
140
- let facts = factsRes.filter(f => intelSymbolOnVenue(deps, f.symbol));
141
- // Optional symbols filter — narrows the scan to a watchlist. Accepts both
142
- // the raw intel form (legacy, case-insensitive) and the agent-facing
143
- // canonical form ('BTC/USDC' → HL_BTC), which is what scan output shows on
144
- // a non-binance venue.
145
- if (Array.isArray(args.symbols) && args.symbols.length > 0) {
146
- const wl = new Set(args.symbols.map(s => s.toUpperCase()));
147
- const wlResolved = new Set(args.symbols.map(s => resolveIntelSymbol(deps, s)));
148
- facts = facts.filter(f => wl.has(f.symbol.toUpperCase()) || wlResolved.has(f.symbol));
149
- }
150
- if (facts.length === 0) {
151
- return {
152
- error: args.symbols && args.symbols.length > 0
153
- ? `No facts available for the requested symbols (${args.symbols.join(', ')}). Intelligence may still be computing initial data, or the symbols are unsupported.`
154
- : 'No symbol facts available. Intelligence service may still be computing initial data.',
155
- };
156
- }
157
- // 2. Fetch user's active strategies (cached, shared with get_setup_detail)
158
- const stratRes = await getStrategiesCached(deps);
159
- if ('error' in stratRes)
160
- return stratRes;
161
- const strategies = stratRes;
162
- if (strategies.length === 0) {
163
- return {
164
- timestamp: new Date().toISOString(),
165
- pairs_scanned: facts.length,
166
- setups_found: 0,
167
- note: 'No active strategies — the agent scans every heartbeat but can NEVER enter a trade until one is active. If you have not already done so this session, tell the operator (chat) and offer next steps: list_strategies to see the available templates, toggle_strategy to activate one, or save_strategy to build a custom one.',
168
- rankings: [],
169
- no_setup: facts.map(f => presentIntelSymbol(deps, f.symbol)),
170
- };
171
- }
172
- // 3. Evaluate all strategies against all facts
173
- const results = scanAllPairs(strategies, facts, minScore);
174
- // 4. Fetch user's confirmed entry-time learnings (optional path — fail
175
- // quietly when the decisions client isn't wired, e.g. in dev or in
176
- // tests that exercise the pre-learning behaviour).
177
- let entryLearnings = [];
178
- if (decisionsDeps?.decisionsClient && decisionsDeps.userId) {
179
- entryLearnings = await getEntryLearningsCached(decisionsDeps.decisionsClient, decisionsDeps.userId);
180
- }
181
- const rankings = [];
182
- const vetoed = [];
183
- for (const r of results) {
184
- const matches = entryLearnings.filter(l => learningMatches(l, r.strategy, r.regime));
185
- const out = {
186
- // Agent-facing form: on hyperliquid the agent must see the symbol it
187
- // can hand straight to create_order ('BTC/USDC'), never 'HL_BTC'.
188
- symbol: presentIntelSymbol(deps, r.symbol),
189
- score: r.score,
190
- regime: r.regime,
191
- strategy: r.strategy,
192
- conditions: `${r.conditionsMet}/${r.conditionsTotal} met: ${r.conditions.filter(c => c.met).map(c => c.name).join(', ')}`,
193
- summary: r.summary,
194
- };
195
- if (matches.length === 0) {
196
- rankings.push(out);
197
- }
198
- else {
199
- vetoed.push({
200
- ...out,
201
- matched_learnings: matches.map(l => ({
202
- id: l.id, title: l.title, directive: l.directive,
203
- })),
204
- });
205
- }
206
- if (rankings.length >= 10)
207
- break;
208
- }
209
- // 6. Build concise response
210
- const setupSymbols = new Set(results.map(r => r.symbol));
211
- const noSetup = facts
212
- .filter(f => !setupSymbols.has(f.symbol))
213
- .map(f => presentIntelSymbol(deps, f.symbol));
214
- return {
215
- timestamp: new Date().toISOString(),
216
- pairs_scanned: facts.length,
217
- setups_found: results.length,
218
- rankings,
219
- vetoed_setups: vetoed.length > 0 ? vetoed : undefined,
220
- no_setup: noSetup.length > 5
221
- ? [...noSetup.slice(0, 5), `...${noSetup.length - 5} others`]
222
- : noSetup,
223
- };
224
- }
225
- // Test-only — clears the shared in-memory TTL caches between unit tests.
226
- export const __testing__ = {
227
- resetCaches() {
228
- cacheTesting.resetCaches();
229
- entryLearningsCache.clear();
230
- },
231
- };
@@ -1,31 +0,0 @@
1
- import type { IntelApiDeps } from './intel-api.js';
2
- interface ScoreSetupArgs {
3
- symbol: string;
4
- direction: 'LONG' | 'SHORT';
5
- setup_type: string;
6
- entry_price: number;
7
- stop_price: number;
8
- target_price: number;
9
- }
10
- interface DimensionScore {
11
- score: number;
12
- detail: string;
13
- pass: boolean;
14
- }
15
- interface ScorecardResult {
16
- composite: number;
17
- verdict: 'STRONG_GO' | 'GO' | 'MARGINAL' | 'NO_GO';
18
- dimensions: {
19
- riskReward: DimensionScore;
20
- regimeAlignment: DimensionScore;
21
- regimeConfidence: DimensionScore;
22
- setupEdge: DimensionScore;
23
- flowAlignment: DimensionScore;
24
- };
25
- flags: string[];
26
- recommendation: string;
27
- }
28
- export declare function scoreSetupTool(args: ScoreSetupArgs, deps: IntelApiDeps): Promise<ScorecardResult | {
29
- error: string;
30
- }>;
31
- export {};
@@ -1,268 +0,0 @@
1
- // Tool: score_setup — Pre-trade setup scorecard.
2
- // Consolidates regime, feedback, and flow data into a single scored verdict.
3
- // Forces the agent to only trade high-quality setups.
4
- import { fetchIntelApi, enc } from './intel-api.js';
5
- import { getTradingParams } from '../trading-params-cache.js';
6
- export async function scoreSetupTool(args, deps) {
7
- const { symbol, direction, setup_type, entry_price, stop_price, target_price } = args;
8
- // Validate inputs
9
- if (direction === 'LONG' && stop_price >= entry_price) {
10
- return { error: 'For LONG: stop_price must be below entry_price' };
11
- }
12
- if (direction === 'SHORT' && stop_price <= entry_price) {
13
- return { error: 'For SHORT: stop_price must be above entry_price' };
14
- }
15
- // Fetch all intelligence data + trading params in parallel
16
- const s = enc(symbol);
17
- const [regimeData, feedbackData, flowData, tp] = await Promise.all([
18
- fetchIntelApi(`/api/regime/${s}`, deps),
19
- fetchIntelApi(`/api/analytics/${s}/feedback`, deps),
20
- fetchIntelApi(`/api/trade-flow/${s}?minutes=5`, deps),
21
- getTradingParams(deps),
22
- ]);
23
- const flags = [];
24
- // ── Dimension 1: Risk/Reward ──
25
- const risk = Math.abs(entry_price - stop_price);
26
- const reward = Math.abs(target_price - entry_price);
27
- const rr = risk > 0 ? reward / risk : 0;
28
- let rrScore;
29
- if (rr >= 3)
30
- rrScore = 10;
31
- else if (rr >= 2.5)
32
- rrScore = 9;
33
- else if (rr >= 2)
34
- rrScore = 8;
35
- else if (rr >= 1.5)
36
- rrScore = 6;
37
- else if (rr >= 1)
38
- rrScore = 4;
39
- else
40
- rrScore = 2;
41
- if (rr < tp.rrWarningThreshold)
42
- flags.push(`Poor R:R (${rr.toFixed(2)}:1) — minimum ${tp.rrWarningThreshold}:1 recommended`);
43
- const riskReward = {
44
- score: rrScore,
45
- detail: `R:R ${rr.toFixed(2)}:1 (risk $${risk.toFixed(2)}, reward $${reward.toFixed(2)})`,
46
- pass: rrScore >= 5,
47
- };
48
- // ── Dimension 2: Regime Alignment ──
49
- let regimeScore = 5; // neutral default
50
- let regimeDetail = 'Regime data unavailable';
51
- if (!('error' in regimeData)) {
52
- const regime = String(regimeData.regime ?? '').toUpperCase();
53
- const confidence = Number(regimeData.confidence ?? 0);
54
- const bullishRegimes = ['TREND_UP', 'VOLATILITY_EXPANSION'];
55
- const bearishRegimes = ['TREND_DOWN'];
56
- const neutralRegimes = ['RANGE_TIGHT', 'RANGE_WIDE'];
57
- const avoidRegimes = ['AVOID', 'UNKNOWN'];
58
- if (avoidRegimes.includes(regime)) {
59
- regimeScore = 1;
60
- regimeDetail = `Regime ${regime} — NO trading recommended`;
61
- flags.push(`Regime is ${regime} — do not trade`);
62
- }
63
- else if (direction === 'LONG' && bullishRegimes.includes(regime)) {
64
- regimeScore = 9;
65
- regimeDetail = `${regime} aligns with LONG direction`;
66
- }
67
- else if (direction === 'SHORT' && bearishRegimes.includes(regime)) {
68
- regimeScore = 9;
69
- regimeDetail = `${regime} aligns with SHORT direction`;
70
- }
71
- else if (direction === 'LONG' && bearishRegimes.includes(regime)) {
72
- regimeScore = 2;
73
- regimeDetail = `${regime} opposes LONG direction`;
74
- flags.push(`Trading LONG against ${regime} regime`);
75
- }
76
- else if (direction === 'SHORT' && bullishRegimes.includes(regime)) {
77
- regimeScore = 2;
78
- regimeDetail = `${regime} opposes SHORT direction`;
79
- flags.push(`Trading SHORT against ${regime} regime`);
80
- }
81
- else if (neutralRegimes.includes(regime)) {
82
- regimeScore = 5;
83
- regimeDetail = `${regime} — neutral for ${direction}. Mean reversion setups preferred.`;
84
- }
85
- // Adjust for confidence — only penalize below user-configured threshold
86
- if (confidence < tp.confidencePenaltyThreshold && !avoidRegimes.includes(regime)) {
87
- regimeScore = Math.max(3, regimeScore - 2);
88
- flags.push(`Low regime confidence (${(confidence * 100).toFixed(0)}%) — treat with caution`);
89
- }
90
- }
91
- const regimeAlignment = {
92
- score: regimeScore,
93
- detail: regimeDetail,
94
- pass: regimeScore >= 5,
95
- };
96
- // ── Dimension 3: Regime Confidence ──
97
- let confScore = 5;
98
- let confDetail = 'Regime confidence unavailable';
99
- if (!('error' in regimeData)) {
100
- const confidence = Number(regimeData.confidence ?? 0);
101
- confScore = Math.round(confidence * 10);
102
- confDetail = `Regime confidence: ${(confidence * 100).toFixed(0)}%`;
103
- if (confidence < tp.confidencePenaltyThreshold) {
104
- flags.push(`Regime classifier uncertain (${(confidence * 100).toFixed(0)}%)`);
105
- }
106
- }
107
- const regimeConfidence = {
108
- score: confScore,
109
- detail: confDetail,
110
- pass: confScore >= 5,
111
- };
112
- // ── Dimension 4: Setup Edge (from feedback) ──
113
- let edgeScore = 5;
114
- let edgeDetail = 'No feedback data for this setup type';
115
- if (!('error' in feedbackData)) {
116
- const fb = feedbackData;
117
- const bySetup = fb.bySetupType;
118
- if (bySetup) {
119
- const match = bySetup.find((s) => String(s.setupType).toLowerCase() === setup_type.toLowerCase());
120
- if (match) {
121
- const verdict = String(match.verdict ?? '');
122
- const edgeTrend = String(match.edgeTrend ?? 'insufficient_data');
123
- const winRate = Number(match.winRate ?? 0);
124
- const winRate20 = match.winRate20 != null ? Number(match.winRate20) : null;
125
- const trades = Number(match.trades ?? 0);
126
- if (verdict === 'STRONG')
127
- edgeScore = 9;
128
- else if (verdict === 'WORKING')
129
- edgeScore = 7;
130
- else if (verdict === 'MARGINAL')
131
- edgeScore = 4;
132
- else if (verdict === 'FAILING') {
133
- edgeScore = 2;
134
- flags.push(`Setup "${setup_type}" is FAILING — use half size or skip`);
135
- }
136
- // Adjust for edge trend
137
- if (edgeTrend === 'declining') {
138
- edgeScore = Math.max(1, edgeScore - 2);
139
- flags.push(`Setup "${setup_type}" edge is declining — reduce size`);
140
- }
141
- else if (edgeTrend === 'improving') {
142
- edgeScore = Math.min(10, edgeScore + 1);
143
- }
144
- const wrStr = winRate20 != null
145
- ? `${(winRate20 * 100).toFixed(0)}% (last 20) / ${(winRate * 100).toFixed(0)}% (all)`
146
- : `${(winRate * 100).toFixed(0)}%`;
147
- edgeDetail = `${setup_type}: ${verdict} (${wrStr}, ${trades} trades, trend: ${edgeTrend})`;
148
- }
149
- else {
150
- edgeScore = tp.unprovenSetupScore;
151
- edgeDetail = `No history for "${setup_type}" — new setup, proceed with reduced size`;
152
- flags.push(`First time using setup "${setup_type}" — reduce size`);
153
- }
154
- }
155
- }
156
- const setupEdge = {
157
- score: edgeScore,
158
- detail: edgeDetail,
159
- pass: edgeScore >= 5,
160
- };
161
- // ── Dimension 5: Institutional Flow Alignment ──
162
- let flowScore = 5;
163
- let flowDetail = 'Flow data unavailable';
164
- if (!('error' in flowData)) {
165
- const flow = flowData;
166
- const pressure = String(flow.whalePressure ?? 'neutral').toLowerCase();
167
- const ratio = Number(flow.buySellRatio ?? 1);
168
- const largeRatio = Number(flow.largeTradeRatio ?? 0);
169
- const bullishFlow = pressure === 'strong_buy' || pressure === 'buy';
170
- const bearishFlow = pressure === 'strong_sell' || pressure === 'sell';
171
- if (direction === 'LONG') {
172
- if (pressure === 'strong_buy')
173
- flowScore = 10;
174
- else if (pressure === 'buy')
175
- flowScore = 8;
176
- else if (pressure === 'neutral')
177
- flowScore = 5;
178
- else if (pressure === 'sell')
179
- flowScore = 3;
180
- else if (pressure === 'strong_sell') {
181
- flowScore = 1;
182
- flags.push('Institutional flow strongly AGAINST your LONG direction');
183
- }
184
- }
185
- else {
186
- if (pressure === 'strong_sell')
187
- flowScore = 10;
188
- else if (pressure === 'sell')
189
- flowScore = 8;
190
- else if (pressure === 'neutral')
191
- flowScore = 5;
192
- else if (pressure === 'buy')
193
- flowScore = 3;
194
- else if (pressure === 'strong_buy') {
195
- flowScore = 1;
196
- flags.push('Institutional flow strongly AGAINST your SHORT direction');
197
- }
198
- }
199
- // Bonus for high institutional activity
200
- if (largeRatio > 0.15 && ((direction === 'LONG' && bullishFlow) || (direction === 'SHORT' && bearishFlow))) {
201
- flowScore = Math.min(10, flowScore + 1);
202
- }
203
- flowDetail = `Whale pressure: ${pressure}, buy/sell ratio: ${ratio.toFixed(2)}, institutional volume: ${(largeRatio * 100).toFixed(1)}%`;
204
- }
205
- const flowAlignment = {
206
- score: flowScore,
207
- detail: flowDetail,
208
- pass: flowScore >= 5,
209
- };
210
- // ── Composite Score (weighted average) ──
211
- const weights = {
212
- riskReward: 2, // R:R is fundamental
213
- regimeAlignment: 3, // regime is the most important filter
214
- regimeConfidence: 1, // confidence matters but less than alignment
215
- setupEdge: 2.5, // your track record with this setup
216
- flowAlignment: 1.5, // institutional confirmation
217
- };
218
- const totalWeight = weights.riskReward + weights.regimeAlignment + weights.regimeConfidence + weights.setupEdge + weights.flowAlignment;
219
- const composite = (riskReward.score * weights.riskReward +
220
- regimeAlignment.score * weights.regimeAlignment +
221
- regimeConfidence.score * weights.regimeConfidence +
222
- setupEdge.score * weights.setupEdge +
223
- flowAlignment.score * weights.flowAlignment) / totalWeight;
224
- // ── Verdict ──
225
- let verdict;
226
- if (composite >= tp.scorecardStrongGoThreshold)
227
- verdict = 'STRONG_GO';
228
- else if (composite >= tp.scorecardGoThreshold)
229
- verdict = 'GO';
230
- else if (composite >= tp.scorecardMarginalThreshold)
231
- verdict = 'MARGINAL';
232
- else
233
- verdict = 'NO_GO';
234
- // Hard vetoes — any critical failure overrides composite
235
- if (regimeScore <= 2)
236
- verdict = 'NO_GO';
237
- if (edgeScore <= 1)
238
- verdict = 'NO_GO';
239
- // ── Recommendation ──
240
- let recommendation;
241
- switch (verdict) {
242
- case 'STRONG_GO':
243
- recommendation = `High-quality setup. ${setup_type} ${direction} with ${rr.toFixed(1)}:1 R:R — all dimensions aligned.`;
244
- break;
245
- case 'GO':
246
- recommendation = `Acceptable setup. Proceed with standard sizing. Watch: ${flags.length > 0 ? flags[0] : 'no concerns'}.`;
247
- break;
248
- case 'MARGINAL':
249
- recommendation = `Borderline setup. If you trade this, use half size. Issues: ${flags.join('; ') || 'multiple dimensions below threshold'}.`;
250
- break;
251
- case 'NO_GO':
252
- recommendation = `Do not trade. ${flags.join('; ') || 'Multiple critical failures'}.`;
253
- break;
254
- }
255
- return {
256
- composite: +composite.toFixed(1),
257
- verdict,
258
- dimensions: {
259
- riskReward,
260
- regimeAlignment,
261
- regimeConfidence,
262
- setupEdge,
263
- flowAlignment,
264
- },
265
- flags,
266
- recommendation,
267
- };
268
- }
@@ -1,18 +0,0 @@
1
- export type BracketRequirementFlag = 'requireStopLoss' | 'requireTakeProfit';
2
- export interface SetBracketRequirementArgs {
3
- flag: BracketRequirementFlag;
4
- value: boolean;
5
- }
6
- export interface SetBracketRequirementResult {
7
- ok: boolean;
8
- flag: BracketRequirementFlag;
9
- previousValue: boolean;
10
- value: boolean;
11
- warning?: string;
12
- error?: string;
13
- }
14
- export interface SetBracketRequirementDeps {
15
- /** Override the config file path — tests use this. */
16
- configPath?: string;
17
- }
18
- export declare function setBracketRequirementTool(args: SetBracketRequirementArgs, deps?: SetBracketRequirementDeps): SetBracketRequirementResult;
@@ -1,81 +0,0 @@
1
- // set_bracket_requirement — operator-only plugin tool.
2
- //
3
- // Flips requireStopLoss or requireTakeProfit in plugin-config.json. The
4
- // dashboard's Trading Parameters panel calls this when the operator toggles
5
- // one of the TP/SL checkboxes.
6
- //
7
- // Design decisions:
8
- // - No adapter swap needed — the pre-trade gate reads flags via
9
- // loadBracketRequirements() on every create_order call, so changes take
10
- // effect on the very next order.
11
- // - Disabling either flag returns `warning: true` + a human message so the
12
- // UI can render the confirmation banner ("you are accepting unprotected
13
- // trades").
14
- // - Default refusal: the agent must NOT call this — the skill layer is
15
- // expected to guard with operator-only scope. This handler stays
16
- // functional but unguarded for parity with set_trading_mode.
17
- import { readPluginConfig, updatePluginConfig } from '../config/plugin-config-io.js';
18
- import { getBracketRequirements } from '../config/brackets-config.js';
19
- import { formatError } from '../logger.js';
20
- export function setBracketRequirementTool(args, deps = {}) {
21
- if (!args || (args.flag !== 'requireStopLoss' && args.flag !== 'requireTakeProfit')) {
22
- return {
23
- ok: false,
24
- flag: args?.flag ?? 'requireStopLoss',
25
- previousValue: true,
26
- value: true,
27
- error: `Invalid flag. Must be 'requireStopLoss' or 'requireTakeProfit'.`,
28
- };
29
- }
30
- if (typeof args.value !== 'boolean') {
31
- return {
32
- ok: false,
33
- flag: args.flag,
34
- previousValue: true,
35
- value: true,
36
- error: `value must be a boolean.`,
37
- };
38
- }
39
- let previousValue;
40
- try {
41
- const current = readPluginConfig(deps.configPath);
42
- previousValue = getBracketRequirements(current)[args.flag];
43
- }
44
- catch (err) {
45
- return {
46
- ok: false,
47
- flag: args.flag,
48
- previousValue: true,
49
- value: args.value,
50
- error: `Cannot read config: ${formatError(err)}`,
51
- };
52
- }
53
- try {
54
- updatePluginConfig({ brackets: { [args.flag]: args.value } }, deps.configPath);
55
- }
56
- catch (err) {
57
- return {
58
- ok: false,
59
- flag: args.flag,
60
- previousValue,
61
- value: args.value,
62
- error: `Cannot write config: ${formatError(err)}`,
63
- };
64
- }
65
- const result = {
66
- ok: true,
67
- flag: args.flag,
68
- previousValue,
69
- value: args.value,
70
- };
71
- // Warning copy surfaces in the dashboard as a confirmation banner.
72
- if (!args.value) {
73
- if (args.flag === 'requireStopLoss') {
74
- result.warning = 'Stop-loss requirement disabled. Live trades may be submitted without a stop — downside is unbounded on adverse moves. Re-enable as soon as you are done with the override.';
75
- }
76
- else {
77
- result.warning = 'Take-profit requirement disabled. Live trades may run without a target — operator must monitor exits manually.';
78
- }
79
- }
80
- return result;
81
- }
@@ -1,25 +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 SetExchangeCredentialsArgs {
5
- apiKey: string;
6
- secret: string;
7
- testnet?: boolean;
8
- }
9
- export interface SetExchangeCredentialsResult {
10
- ok: boolean;
11
- message: string;
12
- fingerprint: string;
13
- reconnected: boolean;
14
- mode: TradingMode;
15
- readiness: string;
16
- }
17
- export interface SetExchangeCredentialsDeps {
18
- runtime: PluginRuntime;
19
- adapterDeps: {
20
- adapter: IExchangeAdapter;
21
- };
22
- /** Override the config file path — tests use this. */
23
- configPath?: string;
24
- }
25
- export declare function setExchangeCredentialsTool(args: SetExchangeCredentialsArgs, deps: SetExchangeCredentialsDeps): Promise<SetExchangeCredentialsResult>;