dexbot 1.4.21 → 1.4.22

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 (595) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -1
  3. package/analysis/ama_fitting/analyze_ama_price_changes.ts +7 -3
  4. package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +3 -3
  5. package/analysis/ama_fitting/calibrate_convergence_er.ts +7 -5
  6. package/analysis/ama_fitting/fetch_lp_candles.ts +8 -3
  7. package/analysis/ama_fitting/generate_unified_comparison_chart.ts +30 -67
  8. package/analysis/ama_fitting/optimizer_high_resolution.ts +22 -13
  9. package/analysis/ama_fitting/package.json +1 -1
  10. package/analysis/analyze_derivatives.ts +4 -4
  11. package/analysis/analyze_dynamic_weight.ts +21 -5
  12. package/analysis/analyze_kalman.ts +54 -25
  13. package/analysis/analyze_regime.ts +2 -2
  14. package/analysis/analyze_regime_windows.ts +27 -19
  15. package/analysis/analyze_risk_profile.ts +3 -3
  16. package/analysis/analyze_trade_heatmap.ts +3 -3
  17. package/analysis/analyze_volatility.ts +2 -2
  18. package/analysis/bot_fitting/README.md +93 -19
  19. package/analysis/bot_fitting/backtest_ama_sweep.ts +316 -199
  20. package/analysis/bot_fitting/backtest_bot_fitting.ts +520 -85
  21. package/analysis/bot_fitting/shared_utils.ts +15 -9
  22. package/analysis/bot_key_utils.ts +13 -6
  23. package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
  24. package/analysis/bot_usage/kibana_bot_queries.ts +1 -1
  25. package/analysis/chart_css.ts +6 -4
  26. package/analysis/chart_ui.ts +0 -1
  27. package/analysis/chart_utils.ts +11 -2
  28. package/analysis/derivative_chart_generator.ts +2 -2
  29. package/analysis/price_sources.ts +8 -2
  30. package/analysis/resolve_source.ts +1 -1
  31. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
  32. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
  33. package/analysis/trade_profitability.ts +61 -28
  34. package/analysis/tradingview/analyze_tradingview.ts +1 -1
  35. package/analysis/tradingview/h-bts_tradingview.html +1570 -0
  36. package/analysis/tradingview/t-bts_tradingview.html +1570 -0
  37. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +302 -74
  38. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  39. package/analysis/trend_detection/derivative_analyzer.ts +12 -3
  40. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +25 -27
  41. package/analysis/trend_detection/hurst_analyzer.ts +1 -1
  42. package/analysis/trend_detection/kalman_chart_generator.ts +42 -14
  43. package/analysis/trend_detection/package.json +1 -1
  44. package/analysis/trend_detection/regime_chart_generator.ts +39 -19
  45. package/analysis/trend_detection/tests/test_kalman_trend.ts +1 -1
  46. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +1 -1
  47. package/analysis/trend_detection/volatility_chart_generator.ts +1 -1
  48. package/claw/index.ts +1 -1
  49. package/claw/modules/claw_bridge.ts +3 -3
  50. package/claw/modules/claw_catalog.ts +1 -1
  51. package/claw/modules/claw_launcher.ts +1 -1
  52. package/claw/modules/claw_skill_md.ts +7 -10
  53. package/claw/modules/credit_runtime_adapter.ts +1 -1
  54. package/claw/modules/decision_loop.ts +5 -9
  55. package/claw/modules/dexbot_bridge.ts +7 -7
  56. package/claw/modules/feed_price_source.ts +1 -1
  57. package/claw/modules/kibana_price_source.ts +1 -1
  58. package/claw/modules/launcher_mode_detector.ts +1 -1
  59. package/claw/modules/launcher_paths.ts +1 -1
  60. package/claw/modules/position_discovery.ts +1 -1
  61. package/claw/modules/position_health.ts +1 -1
  62. package/claw/package.json +3 -3
  63. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  64. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  65. package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
  66. package/claw/tests/package.json +1 -1
  67. package/claw/tests/test_claw_bridge.ts +45 -21
  68. package/claw/tests/test_claw_catalog_and_credentials.ts +8 -4
  69. package/claw/tests/test_claw_chain_layer.ts +39 -19
  70. package/claw/tests/test_claw_data_flow.ts +28 -20
  71. package/claw/tests/test_claw_domain_logic.ts +25 -19
  72. package/claw/tests/test_claw_manifest_and_matrix.ts +23 -3
  73. package/claw/tests/test_claw_mcp_transport.ts +13 -8
  74. package/claw/tests/test_claw_regressions.ts +254 -128
  75. package/claw/tests/test_claw_skill_generation.ts +1 -1
  76. package/claw/tests/test_nullclaw_tmp_integration.ts +2 -3
  77. package/claw/tests/test_position_health.ts +1 -77
  78. package/claw/tests/test_position_manager.ts +20 -18
  79. package/claw/tests/test_position_manager_watch_health.ts +39 -43
  80. package/claw/tests/test_short_mpa_strategy.ts +20 -17
  81. package/claw/tsconfig.json +4 -3
  82. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +7 -3
  83. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -1
  84. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +3 -3
  85. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
  86. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +7 -5
  87. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
  88. package/dist/analysis/ama_fitting/fetch_lp_candles.js +8 -3
  89. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -1
  90. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +2 -2
  91. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -1
  92. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +31 -75
  93. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -1
  94. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
  95. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +21 -13
  96. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
  97. package/dist/analysis/analyze_derivatives.d.ts +0 -18
  98. package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
  99. package/dist/analysis/analyze_derivatives.js +4 -4
  100. package/dist/analysis/analyze_derivatives.js.map +1 -1
  101. package/dist/analysis/analyze_dynamic_weight.d.ts +0 -11
  102. package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -1
  103. package/dist/analysis/analyze_dynamic_weight.js +19 -5
  104. package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
  105. package/dist/analysis/analyze_kalman.d.ts +0 -10
  106. package/dist/analysis/analyze_kalman.d.ts.map +1 -1
  107. package/dist/analysis/analyze_kalman.js +51 -26
  108. package/dist/analysis/analyze_kalman.js.map +1 -1
  109. package/dist/analysis/analyze_regime.d.ts +0 -17
  110. package/dist/analysis/analyze_regime.d.ts.map +1 -1
  111. package/dist/analysis/analyze_regime.js +2 -2
  112. package/dist/analysis/analyze_regime.js.map +1 -1
  113. package/dist/analysis/analyze_regime_windows.d.ts +0 -16
  114. package/dist/analysis/analyze_regime_windows.d.ts.map +1 -1
  115. package/dist/analysis/analyze_regime_windows.js +28 -21
  116. package/dist/analysis/analyze_regime_windows.js.map +1 -1
  117. package/dist/analysis/analyze_risk_profile.js +3 -3
  118. package/dist/analysis/analyze_risk_profile.js.map +1 -1
  119. package/dist/analysis/analyze_trade_heatmap.js +3 -3
  120. package/dist/analysis/analyze_trade_heatmap.js.map +1 -1
  121. package/dist/analysis/analyze_volatility.d.ts +0 -19
  122. package/dist/analysis/analyze_volatility.d.ts.map +1 -1
  123. package/dist/analysis/analyze_volatility.js +2 -2
  124. package/dist/analysis/analyze_volatility.js.map +1 -1
  125. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +30 -14
  126. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
  127. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +330 -193
  128. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
  129. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +136 -1
  130. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -1
  131. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +527 -83
  132. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
  133. package/dist/analysis/bot_fitting/shared_utils.d.ts +1 -1
  134. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
  135. package/dist/analysis/bot_fitting/shared_utils.js +14 -8
  136. package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
  137. package/dist/analysis/bot_key_utils.d.ts.map +1 -1
  138. package/dist/analysis/bot_key_utils.js +13 -6
  139. package/dist/analysis/bot_key_utils.js.map +1 -1
  140. package/dist/analysis/bot_usage/discover_bot_accounts.js +5 -3
  141. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
  142. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  143. package/dist/analysis/bot_usage/kibana_bot_queries.js +1 -1
  144. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  145. package/dist/analysis/chart_css.d.ts +3 -1
  146. package/dist/analysis/chart_css.d.ts.map +1 -1
  147. package/dist/analysis/chart_css.js +6 -3
  148. package/dist/analysis/chart_css.js.map +1 -1
  149. package/dist/analysis/chart_ui.d.ts.map +1 -1
  150. package/dist/analysis/chart_ui.js.map +1 -1
  151. package/dist/analysis/chart_utils.d.ts.map +1 -1
  152. package/dist/analysis/chart_utils.js +15 -2
  153. package/dist/analysis/chart_utils.js.map +1 -1
  154. package/dist/analysis/derivative_chart_generator.js +2 -2
  155. package/dist/analysis/derivative_chart_generator.js.map +1 -1
  156. package/dist/analysis/price_sources.d.ts +1 -0
  157. package/dist/analysis/price_sources.d.ts.map +1 -1
  158. package/dist/analysis/price_sources.js +8 -2
  159. package/dist/analysis/price_sources.js.map +1 -1
  160. package/dist/analysis/resolve_source.d.ts.map +1 -1
  161. package/dist/analysis/resolve_source.js +1 -1
  162. package/dist/analysis/resolve_source.js.map +1 -1
  163. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  164. package/dist/analysis/trade_profitability.js +58 -29
  165. package/dist/analysis/trade_profitability.js.map +1 -1
  166. package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
  167. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  168. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
  169. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +302 -74
  170. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
  171. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +1 -0
  172. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -1
  173. package/dist/analysis/trend_detection/derivative_analyzer.js +12 -3
  174. package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -1
  175. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
  176. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +26 -27
  177. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
  178. package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -1
  179. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
  180. package/dist/analysis/trend_detection/hurst_analyzer.js +1 -1
  181. package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
  182. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -1
  183. package/dist/analysis/trend_detection/kalman_chart_generator.js +41 -13
  184. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -1
  185. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -1
  186. package/dist/analysis/trend_detection/regime_chart_generator.js +38 -19
  187. package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -1
  188. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +1 -1
  189. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -1
  190. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +1 -1
  191. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -1
  192. package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -1
  193. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -1
  194. package/dist/bot.js +1 -1
  195. package/dist/bot.js.map +1 -1
  196. package/dist/credential-daemon.d.ts +1 -1
  197. package/dist/credential-daemon.js +1 -1
  198. package/dist/dexbot.d.ts.map +1 -1
  199. package/dist/dexbot.js +7 -8
  200. package/dist/dexbot.js.map +1 -1
  201. package/dist/market_adapter/ama_signal_runner.js +3 -1
  202. package/dist/market_adapter/ama_signal_runner.js.map +1 -1
  203. package/dist/market_adapter/candle_utils.d.ts +1 -3
  204. package/dist/market_adapter/candle_utils.d.ts.map +1 -1
  205. package/dist/market_adapter/candle_utils.js +1 -11
  206. package/dist/market_adapter/candle_utils.js.map +1 -1
  207. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
  208. package/dist/market_adapter/core/asymmetric_bounds.js +33 -30
  209. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
  210. package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
  211. package/dist/market_adapter/core/config_normalizers.js +10 -1
  212. package/dist/market_adapter/core/config_normalizers.js.map +1 -1
  213. package/dist/market_adapter/core/kibana_candles.d.ts +18 -42
  214. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
  215. package/dist/market_adapter/core/kibana_candles.js +101 -7
  216. package/dist/market_adapter/core/kibana_candles.js.map +1 -1
  217. package/dist/market_adapter/core/kibana_client.d.ts +0 -14
  218. package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
  219. package/dist/market_adapter/core/kibana_client.js +39 -6
  220. package/dist/market_adapter/core/kibana_client.js.map +1 -1
  221. package/dist/market_adapter/core/kibana_market_candles.d.ts +0 -27
  222. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
  223. package/dist/market_adapter/core/kibana_market_candles.js +1 -1
  224. package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
  225. package/dist/market_adapter/core/market_adapter_service.d.ts +21 -11
  226. package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
  227. package/dist/market_adapter/core/market_adapter_service.js +95 -37
  228. package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
  229. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
  230. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -1
  231. package/dist/market_adapter/core/signals/hurst_analyzer.js +28 -17
  232. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -1
  233. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts +5 -0
  234. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -1
  235. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +24 -24
  236. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -1
  237. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -1
  238. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js +5 -1
  239. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -1
  240. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -1
  241. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +20 -3
  242. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -1
  243. package/dist/market_adapter/core/strategies/ama.js +1 -1
  244. package/dist/market_adapter/core/strategies/ama.js.map +1 -1
  245. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
  246. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
  247. package/dist/market_adapter/core/strategies/ama_slope_model.js +16 -4
  248. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
  249. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +4 -3
  250. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
  251. package/dist/market_adapter/core/strategies/atr/calculator.js +16 -8
  252. package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
  253. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
  254. package/dist/market_adapter/core/strategies/collateral_manager.js +8 -3
  255. package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
  256. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +40 -1
  257. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -1
  258. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +116 -2
  259. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -1
  260. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
  261. package/dist/market_adapter/core/strategies/regime_gate.js +26 -20
  262. package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
  263. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -1
  264. package/dist/market_adapter/core/strategies/volatility_shift.js +3 -0
  265. package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -1
  266. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +69 -55
  267. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
  268. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +0 -26
  269. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  270. package/dist/market_adapter/inputs/fetch_lp_data.js +67 -14
  271. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  272. package/dist/market_adapter/inputs/kibana_source.d.ts +4 -28
  273. package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
  274. package/dist/market_adapter/inputs/kibana_source.js +5 -2
  275. package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
  276. package/dist/market_adapter/lp_chart_core.js +1 -1
  277. package/dist/market_adapter/lp_chart_core.js.map +1 -1
  278. package/dist/market_adapter/lp_chart_runner.d.ts +10 -1
  279. package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
  280. package/dist/market_adapter/lp_chart_runner.js +2 -2
  281. package/dist/market_adapter/lp_chart_runner.js.map +1 -1
  282. package/dist/market_adapter/lp_chart_strategy_loader.js +1 -1
  283. package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
  284. package/dist/market_adapter/market_adapter.d.ts +1 -2
  285. package/dist/market_adapter/market_adapter.d.ts.map +1 -1
  286. package/dist/market_adapter/market_adapter.js +3 -6
  287. package/dist/market_adapter/market_adapter.js.map +1 -1
  288. package/dist/market_adapter/test_helpers.d.ts +3 -3
  289. package/dist/market_adapter/test_helpers.d.ts.map +1 -1
  290. package/dist/market_adapter/test_helpers.js +3 -3
  291. package/dist/market_adapter/test_helpers.js.map +1 -1
  292. package/dist/market_adapter/utils/adapter_client.js +1 -1
  293. package/dist/market_adapter/utils/adapter_client.js.map +1 -1
  294. package/dist/market_adapter/utils/atomic_write.js +1 -1
  295. package/dist/market_adapter/utils/atomic_write.js.map +1 -1
  296. package/dist/market_adapter/utils/chain.d.ts +0 -2
  297. package/dist/market_adapter/utils/chain.d.ts.map +1 -1
  298. package/dist/market_adapter/utils/chain.js +2 -3
  299. package/dist/market_adapter/utils/chain.js.map +1 -1
  300. package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
  301. package/dist/market_adapter/utils/data_discovery.js +24 -8
  302. package/dist/market_adapter/utils/data_discovery.js.map +1 -1
  303. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
  304. package/dist/market_adapter/utils/dynamic_grid_snapshot.js +2 -5
  305. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
  306. package/dist/market_adapter/utils/file_lock.d.ts +4 -1
  307. package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
  308. package/dist/market_adapter/utils/file_lock.js +89 -25
  309. package/dist/market_adapter/utils/file_lock.js.map +1 -1
  310. package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
  311. package/dist/market_adapter/utils/native_history.js +5 -1
  312. package/dist/market_adapter/utils/native_history.js.map +1 -1
  313. package/dist/modules/account_bots.js +1 -1
  314. package/dist/modules/account_bots.js.map +1 -1
  315. package/dist/modules/authority_resolver.js +1 -1
  316. package/dist/modules/authority_resolver.js.map +1 -1
  317. package/dist/modules/bitshares-native/chain_client.js +1 -1
  318. package/dist/modules/bitshares-native/chain_client.js.map +1 -1
  319. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +0 -12
  320. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
  321. package/dist/modules/bitshares-native/crypto/ecc.browser.js +1 -1
  322. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
  323. package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -1
  324. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
  325. package/dist/modules/bitshares-native/index.d.ts.map +1 -1
  326. package/dist/modules/bitshares-native/index.js +1 -1
  327. package/dist/modules/bitshares-native/index.js.map +1 -1
  328. package/dist/modules/bitshares-native/lru_cache.js +1 -1
  329. package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
  330. package/dist/modules/bitshares-native/resolvers.d.ts +0 -2
  331. package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
  332. package/dist/modules/bitshares-native/resolvers.js +18 -4
  333. package/dist/modules/bitshares-native/resolvers.js.map +1 -1
  334. package/dist/modules/bitshares-native/serial/chain_constants.js +1 -1
  335. package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
  336. package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
  337. package/dist/modules/bitshares-native/serial/index.js +1 -1
  338. package/dist/modules/bitshares-native/serial/index.js.map +1 -1
  339. package/dist/modules/bitshares-native/serial/operations.js +1 -1
  340. package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
  341. package/dist/modules/bitshares-native/serial/serializer.js +1 -1
  342. package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
  343. package/dist/modules/bitshares-native/serial/types.js +1 -1
  344. package/dist/modules/bitshares-native/serial/types.js.map +1 -1
  345. package/dist/modules/bitshares-native/signing_client.js +2 -2
  346. package/dist/modules/bitshares-native/signing_client.js.map +1 -1
  347. package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
  348. package/dist/modules/bitshares-native/subscriptions.js +5 -14
  349. package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
  350. package/dist/modules/bitshares-native/transport.js +1 -1
  351. package/dist/modules/bitshares-native/transport.js.map +1 -1
  352. package/dist/modules/bitshares-native/tx/builder.js +1 -1
  353. package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
  354. package/dist/modules/bitshares-native/tx/tx_cache.d.ts +3 -2
  355. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
  356. package/dist/modules/bitshares-native/tx/tx_cache.js +7 -4
  357. package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
  358. package/dist/modules/bitshares_client.js +10 -10
  359. package/dist/modules/bitshares_client.js.map +1 -1
  360. package/dist/modules/bot_settings.d.ts.map +1 -1
  361. package/dist/modules/bot_settings.js +11 -18
  362. package/dist/modules/bot_settings.js.map +1 -1
  363. package/dist/modules/bots_file_lock.d.ts +1 -1
  364. package/dist/modules/bots_file_lock.js +1 -1
  365. package/dist/modules/broadcast_failure.d.ts +13 -0
  366. package/dist/modules/broadcast_failure.d.ts.map +1 -1
  367. package/dist/modules/broadcast_failure.js +0 -13
  368. package/dist/modules/broadcast_failure.js.map +1 -1
  369. package/dist/modules/chain_orders.d.ts.map +1 -1
  370. package/dist/modules/chain_orders.js +15 -17
  371. package/dist/modules/chain_orders.js.map +1 -1
  372. package/dist/modules/config.js +1 -1
  373. package/dist/modules/config.js.map +1 -1
  374. package/dist/modules/constants.d.ts +21 -20
  375. package/dist/modules/constants.d.ts.map +1 -1
  376. package/dist/modules/constants.js +53 -56
  377. package/dist/modules/constants.js.map +1 -1
  378. package/dist/modules/cr_planner.d.ts +1 -7
  379. package/dist/modules/cr_planner.d.ts.map +1 -1
  380. package/dist/modules/cr_planner.js +3 -77
  381. package/dist/modules/cr_planner.js.map +1 -1
  382. package/dist/modules/credential_policy.d.ts +0 -4
  383. package/dist/modules/credential_policy.d.ts.map +1 -1
  384. package/dist/modules/credential_policy.js +17 -2
  385. package/dist/modules/credential_policy.js.map +1 -1
  386. package/dist/modules/credit_runtime.d.ts +0 -7
  387. package/dist/modules/credit_runtime.d.ts.map +1 -1
  388. package/dist/modules/credit_runtime.js +21 -60
  389. package/dist/modules/credit_runtime.js.map +1 -1
  390. package/dist/modules/crypto/index.d.ts +0 -2
  391. package/dist/modules/crypto/index.d.ts.map +1 -1
  392. package/dist/modules/crypto/index.js +0 -2
  393. package/dist/modules/crypto/index.js.map +1 -1
  394. package/dist/modules/crypto/sync.js.map +1 -1
  395. package/dist/modules/daemon_node_health.js +1 -1
  396. package/dist/modules/daemon_node_health.js.map +1 -1
  397. package/dist/modules/dexbot_class.d.ts +8 -134
  398. package/dist/modules/dexbot_class.d.ts.map +1 -1
  399. package/dist/modules/dexbot_class.js +36 -197
  400. package/dist/modules/dexbot_class.js.map +1 -1
  401. package/dist/modules/dexbot_credential_client.js +1 -1
  402. package/dist/modules/dexbot_credential_client.js.map +1 -1
  403. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
  404. package/dist/modules/dexbot_fill_runtime.js +3 -6
  405. package/dist/modules/dexbot_fill_runtime.js.map +1 -1
  406. package/dist/modules/dexbot_maintenance_runtime.d.ts +6 -34
  407. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  408. package/dist/modules/dexbot_maintenance_runtime.js +27 -19
  409. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  410. package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
  411. package/dist/modules/dexbot_startup_runtime.js +31 -15
  412. package/dist/modules/dexbot_startup_runtime.js.map +1 -1
  413. package/dist/modules/dexbot_state_recovery.d.ts +2 -2
  414. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  415. package/dist/modules/dexbot_state_recovery.js +9 -6
  416. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  417. package/dist/modules/fund_registry.d.ts.map +1 -1
  418. package/dist/modules/fund_registry.js +19 -4
  419. package/dist/modules/fund_registry.js.map +1 -1
  420. package/dist/modules/general_settings.d.ts +1 -2
  421. package/dist/modules/general_settings.d.ts.map +1 -1
  422. package/dist/modules/general_settings.js +1 -2
  423. package/dist/modules/general_settings.js.map +1 -1
  424. package/dist/modules/graceful_shutdown.d.ts.map +1 -1
  425. package/dist/modules/graceful_shutdown.js +10 -1
  426. package/dist/modules/graceful_shutdown.js.map +1 -1
  427. package/dist/modules/grid_price_source.d.ts +19 -0
  428. package/dist/modules/grid_price_source.d.ts.map +1 -0
  429. package/dist/modules/grid_price_source.js +23 -0
  430. package/dist/modules/grid_price_source.js.map +1 -0
  431. package/dist/modules/key_store.d.ts +0 -5
  432. package/dist/modules/key_store.d.ts.map +1 -1
  433. package/dist/modules/key_store.js +1 -14
  434. package/dist/modules/key_store.js.map +1 -1
  435. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
  436. package/dist/modules/launcher/bot_supervisor.js +9 -19
  437. package/dist/modules/launcher/bot_supervisor.js.map +1 -1
  438. package/dist/modules/launcher/child_env.d.ts +1 -2
  439. package/dist/modules/launcher/child_env.d.ts.map +1 -1
  440. package/dist/modules/launcher/child_env.js +1 -1
  441. package/dist/modules/launcher/child_env.js.map +1 -1
  442. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
  443. package/dist/modules/launcher/foreign_cred_daemon.js +2 -14
  444. package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
  445. package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
  446. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
  447. package/dist/modules/launcher/market_adapter_runtime.js +3 -14
  448. package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
  449. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
  450. package/dist/modules/launcher/market_adapter_watchdog.js +3 -2
  451. package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
  452. package/dist/modules/launcher/monolithic_runtime.d.ts +0 -1
  453. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  454. package/dist/modules/launcher/monolithic_runtime.js +3 -18
  455. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  456. package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
  457. package/dist/modules/launcher/runtime_entry.js +4 -5
  458. package/dist/modules/launcher/runtime_entry.js.map +1 -1
  459. package/dist/modules/launcher/status_reporting.js +1 -1
  460. package/dist/modules/launcher/status_reporting.js.map +1 -1
  461. package/dist/modules/launcher/supervisor_control.js +1 -1
  462. package/dist/modules/launcher/supervisor_control.js.map +1 -1
  463. package/dist/modules/market_adapter_whitelist.d.ts +2 -2
  464. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  465. package/dist/modules/market_adapter_whitelist.js +12 -6
  466. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  467. package/dist/modules/node_failure_ledger.d.ts +23 -0
  468. package/dist/modules/node_failure_ledger.d.ts.map +1 -1
  469. package/dist/modules/node_failure_ledger.js +0 -23
  470. package/dist/modules/node_failure_ledger.js.map +1 -1
  471. package/dist/modules/node_manager.d.ts.map +1 -1
  472. package/dist/modules/node_manager.js +3 -3
  473. package/dist/modules/node_manager.js.map +1 -1
  474. package/dist/modules/order/accounting.js +1 -1
  475. package/dist/modules/order/accounting.js.map +1 -1
  476. package/dist/modules/order/async_lock.d.ts +6 -0
  477. package/dist/modules/order/async_lock.d.ts.map +1 -1
  478. package/dist/modules/order/async_lock.js +11 -0
  479. package/dist/modules/order/async_lock.js.map +1 -1
  480. package/dist/modules/order/export.d.ts +1 -1
  481. package/dist/modules/order/export.js +10 -10
  482. package/dist/modules/order/export.js.map +1 -1
  483. package/dist/modules/order/format.d.ts +1 -0
  484. package/dist/modules/order/format.d.ts.map +1 -1
  485. package/dist/modules/order/format.js +0 -6
  486. package/dist/modules/order/format.js.map +1 -1
  487. package/dist/modules/order/grid.d.ts +2 -12
  488. package/dist/modules/order/grid.d.ts.map +1 -1
  489. package/dist/modules/order/grid.js +23 -24
  490. package/dist/modules/order/grid.js.map +1 -1
  491. package/dist/modules/order/grid_reconcile.d.ts +1 -1
  492. package/dist/modules/order/grid_reconcile.js +1 -1
  493. package/dist/modules/order/grid_reconcile_internal.js +1 -1
  494. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  495. package/dist/modules/order/logger.d.ts +3 -0
  496. package/dist/modules/order/logger.d.ts.map +1 -1
  497. package/dist/modules/order/logger.js +22 -13
  498. package/dist/modules/order/logger.js.map +1 -1
  499. package/dist/modules/order/logger_state.d.ts +4 -9
  500. package/dist/modules/order/logger_state.d.ts.map +1 -1
  501. package/dist/modules/order/logger_state.js +5 -14
  502. package/dist/modules/order/logger_state.js.map +1 -1
  503. package/dist/modules/order/manager.d.ts +1 -4
  504. package/dist/modules/order/manager.d.ts.map +1 -1
  505. package/dist/modules/order/manager.js +34 -33
  506. package/dist/modules/order/manager.js.map +1 -1
  507. package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
  508. package/dist/modules/order/processed_fill_store.js +9 -3
  509. package/dist/modules/order/processed_fill_store.js.map +1 -1
  510. package/dist/modules/order/strategy.d.ts +6 -4
  511. package/dist/modules/order/strategy.d.ts.map +1 -1
  512. package/dist/modules/order/strategy.js +6 -4
  513. package/dist/modules/order/strategy.js.map +1 -1
  514. package/dist/modules/order/sync_engine.js +7 -7
  515. package/dist/modules/order/sync_engine.js.map +1 -1
  516. package/dist/modules/order/utils/order.d.ts.map +1 -1
  517. package/dist/modules/order/utils/order.js +1 -2
  518. package/dist/modules/order/utils/order.js.map +1 -1
  519. package/dist/modules/order/utils/system.d.ts +3 -8
  520. package/dist/modules/order/utils/system.d.ts.map +1 -1
  521. package/dist/modules/order/utils/system.js +14 -4
  522. package/dist/modules/order/utils/system.js.map +1 -1
  523. package/dist/modules/order/utils/validate.js +1 -1
  524. package/dist/modules/order/utils/validate.js.map +1 -1
  525. package/dist/modules/path_api.js +1 -1
  526. package/dist/modules/path_api.js.map +1 -1
  527. package/dist/modules/paths.d.ts +1 -7
  528. package/dist/modules/paths.d.ts.map +1 -1
  529. package/dist/modules/paths.js +1 -1
  530. package/dist/modules/paths.js.map +1 -1
  531. package/dist/modules/process_discovery.d.ts +3 -0
  532. package/dist/modules/process_discovery.d.ts.map +1 -1
  533. package/dist/modules/process_discovery.js +15 -1
  534. package/dist/modules/process_discovery.js.map +1 -1
  535. package/dist/modules/runtime_settings.js +1 -1
  536. package/dist/modules/runtime_settings.js.map +1 -1
  537. package/dist/modules/settings_merge.d.ts +5 -1
  538. package/dist/modules/settings_merge.d.ts.map +1 -1
  539. package/dist/modules/settings_merge.js +14 -3
  540. package/dist/modules/settings_merge.js.map +1 -1
  541. package/dist/modules/socket_json_client.d.ts.map +1 -1
  542. package/dist/modules/socket_json_client.js +12 -2
  543. package/dist/modules/socket_json_client.js.map +1 -1
  544. package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
  545. package/dist/modules/storage/browser_adapter.js +5 -3
  546. package/dist/modules/storage/browser_adapter.js.map +1 -1
  547. package/dist/modules/storage/index.d.ts +1 -1
  548. package/dist/modules/storage/index.js +1 -1
  549. package/dist/modules/types.d.ts +1 -1
  550. package/dist/modules/types.d.ts.map +1 -1
  551. package/dist/modules/validate_profiles.d.ts.map +1 -1
  552. package/dist/modules/validate_profiles.js +6 -8
  553. package/dist/modules/validate_profiles.js.map +1 -1
  554. package/dist/pm2.d.ts.map +1 -1
  555. package/dist/pm2.js +2 -3
  556. package/dist/pm2.js.map +1 -1
  557. package/dist/scripts/analyze-git.d.ts +1 -1
  558. package/dist/scripts/analyze-git.js +1 -1
  559. package/dist/scripts/analyze-orders.d.ts.map +1 -1
  560. package/dist/scripts/analyze-orders.js +35 -16
  561. package/dist/scripts/analyze-orders.js.map +1 -1
  562. package/dist/scripts/diagnose-pool-history.js +1 -1
  563. package/dist/scripts/divergence-calc.d.ts +1 -1
  564. package/dist/scripts/divergence-calc.js +3 -3
  565. package/dist/scripts/native_release_gates.js +4 -2
  566. package/dist/scripts/native_release_gates.js.map +1 -1
  567. package/dist/scripts/print_grid.d.ts +1 -1
  568. package/dist/scripts/print_grid.js +1 -1
  569. package/dist/scripts/run-tests.js +38 -19
  570. package/dist/scripts/run-tests.js.map +1 -1
  571. package/dist/scripts/runner.d.ts +3 -5
  572. package/dist/scripts/runner.d.ts.map +1 -1
  573. package/dist/scripts/runner.js +3 -5
  574. package/dist/scripts/runner.js.map +1 -1
  575. package/dist/scripts/sync-version.d.ts +2 -2
  576. package/dist/scripts/sync-version.js +2 -2
  577. package/dist/scripts/update.d.ts +1 -1
  578. package/dist/scripts/update.js +1 -1
  579. package/dist/scripts/validate_bots.d.ts +1 -1
  580. package/dist/scripts/validate_bots.js +1 -1
  581. package/dist/scripts/verify-browser-bundle.d.ts +1 -1
  582. package/dist/scripts/verify-browser-bundle.js +1 -1
  583. package/dist/unlock.js +4 -4
  584. package/dist/unlock.js.map +1 -1
  585. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +9 -9
  586. package/docs/DEXBOT_COMPARISON.md +4 -4
  587. package/docs/EVOLUTION.md +16 -43
  588. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
  589. package/docs/README.md +1 -1
  590. package/docs/architecture.md +5 -5
  591. package/docs/developer_guide.md +6 -6
  592. package/package.json +22 -14
  593. package/scripts/README.md +33 -7
  594. package/scripts/clean-dist.js +10 -2
  595. package/tests/README.md +4 -3
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /**
2
3
  * Position Discovery
3
4
  *
@@ -10,7 +11,6 @@
10
11
 
11
12
 
12
13
  import { roundTo } from '../../modules/order/utils/math.js';
13
- 'use strict';
14
14
 
15
15
  import { getAsset, getBackingAsset, getBitassetData, getFullAccount } from './chain_queries.js';
16
16
  import { computeCallOrderAmounts } from './mpa_utils.js';
@@ -1,3 +1,4 @@
1
+ 'use strict';
1
2
  /**
2
3
  * Position Health Assessment
3
4
  *
@@ -9,7 +10,6 @@
9
10
 
10
11
  import { CR_ZONES } from '../../modules/constants.js';
11
12
  import { roundToDecimals } from '../../modules/order/utils/math.js';
12
- 'use strict';
13
13
 
14
14
 
15
15
  const DEFAULT_PRICE_RANGE_RATIO = 3.0;
package/claw/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dexbot2-claw",
3
- "version": "1.4.21",
3
+ "version": "1.4.22",
4
4
  "private": true,
5
5
  "description": "Claw bridge and runtime integration layer for BitShares and DEXBot2.",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  ]
20
20
  },
21
21
  "scripts": {
22
- "build": "tsc -p tsconfig.json",
22
+ "build": "tsc -p tsconfig.json && cp tests/package.json ../dist/claw/tests/package.json",
23
23
  "example:connection": "npm run build && node ../dist/claw/examples/connection_test.js",
24
24
  "example:claw-infra": "npm run build && node ../dist/claw/examples/claw_infra_example.js",
25
25
  "example:claw-consumer": "npm run build && node ../dist/claw/examples/claw_consumer_example.js",
@@ -52,7 +52,7 @@
52
52
  "pm2:start": "npm run build && pm2 start ecosystem.config.cjs",
53
53
  "pm2:stop": "pm2 stop ecosystem.config.cjs",
54
54
  "report:honest-assets": "npm run build && node ../dist/claw/scripts/honest_assets_report.js",
55
- "test": "npm run build && npx tsx tests/test_claw_regressions.ts && npx tsx tests/test_claw_state_store.ts && npx tsx tests/test_dexbot_profiles.ts && npx tsx tests/test_position_manager_watch_health.ts && npx tsx tests/test_claw_bridge.ts && npx tsx tests/test_memu_bridge.ts && npx tsx tests/test_short_mpa_strategy.ts && npx tsx tests/test_position_health.ts && npx tsx tests/test_claw_chain_layer.ts && npx tsx tests/test_claw_domain_logic.ts && npx tsx tests/test_claw_catalog_and_credentials.ts && npx tsx tests/test_claw_data_flow.ts && npx tsx tests/test_position_manager.ts && npx tsx tests/test_claw_skill_generation.ts && npx tsx tests/test_claw_manifest_and_matrix.ts && npx tsx tests/test_claw_mcp_transport.ts && npx tsx tests/test_nullclaw_tmp_integration.ts",
55
+ "test": "npm run build && node ../dist/claw/tests/test_claw_regressions.js && node ../dist/claw/tests/test_claw_state_store.js && node ../dist/claw/tests/test_dexbot_profiles.js && node ../dist/claw/tests/test_position_manager_watch_health.js && node ../dist/claw/tests/test_claw_bridge.js && node ../dist/claw/tests/test_memu_bridge.js && node ../dist/claw/tests/test_short_mpa_strategy.js && node ../dist/claw/tests/test_position_health.js && node ../dist/claw/tests/test_claw_chain_layer.js && node ../dist/claw/tests/test_claw_domain_logic.js && node ../dist/claw/tests/test_claw_catalog_and_credentials.js && node ../dist/claw/tests/test_claw_data_flow.js && node ../dist/claw/tests/test_position_manager.js && node ../dist/claw/tests/test_claw_skill_generation.js && node ../dist/claw/tests/test_claw_manifest_and_matrix.js && node ../dist/claw/tests/test_claw_mcp_transport.js && node ../dist/claw/tests/test_nullclaw_tmp_integration.js",
56
56
  "check": "npm run build && node --input-type=module -e \"await import('../dist/claw/index.js')\" && node -c ecosystem.config.cjs && node -c ../dist/claw/runtimes/openclaw-plugin/index.js"
57
57
  }
58
58
  }
@@ -2,7 +2,7 @@
2
2
  "id": "bitshares-claw",
3
3
  "name": "BitShares Claw",
4
4
  "description": "Native BitShares and DEXBot2 tools from the DEXBot2 claw integration",
5
- "version": "1.4.21",
5
+ "version": "1.4.22",
6
6
  "skills": [
7
7
  "skills"
8
8
  ],
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bitshares-claw-openclaw-plugin",
3
3
  "private": true,
4
- "version": "1.4.21",
4
+ "version": "1.4.22",
5
5
  "type": "module",
6
6
  "main": "index.js"
7
7
  }
@@ -18,6 +18,6 @@ Use this reference for DEXBot2 startup and PM2 orchestration work.
18
18
 
19
19
  ## Validation
20
20
 
21
- - `node --import tsx tests/test_launcher_exports.ts`
22
- - `node --import tsx tests/test_pm2_logic.ts`
21
+ - `node dist/tests/test_launcher_exports.js`
22
+ - `node dist/tests/test_pm2_logic.js`
23
23
  - `npm test`
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "type": "commonjs"
3
- }
3
+ }
@@ -1,18 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  const assert = require('assert');
4
+ const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
4
5
 
5
- function clearModule(modulePath: string) {
6
- delete require.cache[modulePath];
6
+ // Compiled ESM graphs cannot be mocked via require.cache; the helper installs
7
+ // loader hooks (one child process per stage so fresh module instances load).
8
+ function clearModule(_modulePath: string) {
9
+ /* no-op under ESM hooks */
7
10
  }
8
11
 
9
12
  function registerMock(modulePath: string, exports: any) {
10
- require.cache[modulePath] = {
11
- id: modulePath,
12
- filename: modulePath,
13
- loaded: true,
14
- exports
15
- } as any;
13
+ defineEsmMockAbs(modulePath, Object.keys(exports), exports);
16
14
  }
17
15
 
18
16
  function createBridgeHarness() {
@@ -225,9 +223,30 @@ function createBridgeHarness() {
225
223
  }
226
224
  });
227
225
 
228
- // Snapshot the real validator before the mock replaces the module: claw
229
- // bridge delegates memu-* argument validation to it.
230
- const realMemuBridge = require(memuBridgePath);
226
+ // The mock replicates the real validator's required-args table: under ESM
227
+ // hooks the real module cannot be require()d here (that would bypass the
228
+ // mock and poison the module cache with the real instance).
229
+ const memuRequiredArgs = {
230
+ 'memorize': { groups: [['resourceUrl'], ['modality']], message: 'memorize requires resourceUrl and modality' },
231
+ 'retrieve': { groups: [['queries']], message: 'retrieve requires queries' },
232
+ 'create-item': { groups: [['categoryId', 'categoryName', 'category'], ['summary']], message: 'create-item requires categoryId or categoryName, plus summary' },
233
+ 'update-item': { groups: [['itemId'], ['updates']], message: 'update-item requires itemId and updates' },
234
+ 'delete-item': { groups: [['itemId']], message: 'delete-item requires itemId' },
235
+ 'memorize-conversation': { groups: [['messages']], message: 'memorize-conversation requires messages array' },
236
+ 'memorize-trading-context': { groups: [['context']], message: 'memorize-trading-context requires context' },
237
+ 'retrieve-trading-context': { groups: [['query']], message: 'retrieve-trading-context requires query' }
238
+ };
239
+ function validateMemuCommandArgs(command: string, options: any) {
240
+ const spec = (memuRequiredArgs as any)[command];
241
+ if (!spec) return;
242
+ const satisfied = spec.groups.every(
243
+ (group: string[]) => group.some((field) => options[field])
244
+ );
245
+ if (!satisfied) {
246
+ throw new Error(spec.message);
247
+ }
248
+ }
249
+
231
250
  registerMock(memuBridgePath, {
232
251
  describeMemuBridge: (options: any) => ({
233
252
  options,
@@ -242,7 +261,7 @@ function createBridgeHarness() {
242
261
  source: 'memu'
243
262
  };
244
263
  },
245
- validateMemuCommandArgs: realMemuBridge.validateMemuCommandArgs
264
+ validateMemuCommandArgs
246
265
  });
247
266
 
248
267
  clearModule(bridgePath);
@@ -535,12 +554,17 @@ async function testRunClawCommandDispatchMatrix() {
535
554
  console.log(' PASS');
536
555
  }
537
556
 
538
- async function main() {
539
- await testCreateClawBridgeSanitizesPrivateKey();
540
- await testRunClawCommandDispatchMatrix();
541
- }
542
-
543
- main().catch((error) => {
544
- console.error(error);
545
- process.exitCode = 1;
546
- });
557
+ runEsmMockStages(
558
+ ['sanitizes-private-key', 'dispatch-matrix'],
559
+ async (stage: string) => {
560
+ if (stage === 'sanitizes-private-key') {
561
+ await testCreateClawBridgeSanitizesPrivateKey();
562
+ return;
563
+ }
564
+ if (stage === 'dispatch-matrix') {
565
+ await testRunClawCommandDispatchMatrix();
566
+ return;
567
+ }
568
+ throw new Error(`Unknown stage: ${stage}`);
569
+ }
570
+ );
@@ -54,8 +54,8 @@ function testClawCatalog() {
54
54
  catalogCopy[0].command = 'mutated';
55
55
  assert.notStrictEqual(catalog.getClawToolCatalog()[0].command, 'mutated');
56
56
 
57
- const examples = catalog.buildClawCommandExamples('tsx scripts/claw_bridge.ts');
58
- assert.ok(examples.some((line: any) => line.startsWith('tsx scripts/claw_bridge.ts manifest')));
57
+ const examples = catalog.buildClawCommandExamples('node dist/claw/scripts/claw_bridge.js');
58
+ assert.ok(examples.some((line: any) => line.startsWith('node dist/claw/scripts/claw_bridge.js manifest')));
59
59
  assert.ok(examples.some((line: any) => line.includes('bot-settings-apply')));
60
60
  }
61
61
 
@@ -134,9 +134,13 @@ async function testCredentialDaemonClient() {
134
134
 
135
135
  function testDexbotBridgeRootResolution() {
136
136
  const bridge = require('../modules/dexbot_bridge');
137
- const expectedRoot = path.resolve(__dirname, '..', '..');
137
+ const root = bridge.getDexbot2Root();
138
138
 
139
- assert.strictEqual(bridge.getDexbot2Root(), expectedRoot);
139
+ // The resolved root must be a real DEXBot2 checkout that contains this
140
+ // test's compiled location and the module tree the bridge resolves against.
141
+ const rel = path.relative(root, __dirname);
142
+ assert.ok(!rel.startsWith('..') && !path.isAbsolute(rel), 'resolved DEXBot2 root must contain this test');
143
+ assert.ok(fs.existsSync(path.join(root, 'package.json')), 'resolved DEXBot2 root must contain package.json');
140
144
  }
141
145
 
142
146
  async function main() {
@@ -1,18 +1,16 @@
1
1
  'use strict';
2
2
 
3
3
  const assert = require('assert');
4
+ const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
4
5
 
5
- function clearModule(modulePath: string) {
6
- delete require.cache[modulePath];
6
+ // Compiled ESM graphs cannot be mocked via require.cache; the helper installs
7
+ // loader hooks (one child process per stage so fresh module instances load).
8
+ function clearModule(_modulePath: string) {
9
+ /* no-op under ESM hooks */
7
10
  }
8
11
 
9
12
  function registerMock(modulePath: string, exports: any) {
10
- require.cache[modulePath] = {
11
- id: modulePath,
12
- filename: modulePath,
13
- loaded: true,
14
- exports
15
- } as any;
13
+ defineEsmMockAbs(modulePath, Object.keys(exports), exports);
16
14
  }
17
15
 
18
16
  const { clone } = require('../modules/utils');
@@ -254,7 +252,22 @@ function createBroadcastHarness() {
254
252
  }
255
253
  });
256
254
 
255
+ // ESM hooks turn mock keys into synthetic named re-exports, so every name
256
+ // chain_broadcast statically imports must exist here. The error class is a
257
+ // minimal inline replica of the real one (requiring the real module would
258
+ // poison the module cache and bypass the mock).
259
+ class BroadcastUncertainError extends Error {
260
+ code: string;
261
+ constructor(message: string) {
262
+ super(message);
263
+ this.name = 'BroadcastUncertainError';
264
+ this.code = 'BROADCAST_UNCERTAIN';
265
+ }
266
+ }
267
+
257
268
  registerMock(credentialClientPath, {
269
+ BroadcastUncertainError,
270
+ DEFAULT_BROADCAST_TIMEOUT_MS: 30000,
258
271
  isCredentialDaemonReady: () => calls.daemonReady,
259
272
  broadcastOperationViaCredentialDaemon: async (accountName: any, operation: any, options: any) => {
260
273
  calls.daemon.broadcast.push({ accountName, operation, options });
@@ -706,14 +719,21 @@ async function testChainActions() {
706
719
  console.log(' PASS');
707
720
  }
708
721
 
709
- async function main() {
710
- await testChainQueries();
711
- await testChainBroadcast();
712
- await testChainActions();
713
- console.log('claw chain layer tests passed');
714
- }
715
-
716
- main().catch((err) => {
717
- console.error(err);
718
- process.exit(1);
719
- });
722
+ runEsmMockStages(
723
+ ['chain-queries', 'chain-broadcast', 'chain-actions'],
724
+ async (stage: string) => {
725
+ if (stage === 'chain-queries') {
726
+ await testChainQueries();
727
+ return;
728
+ }
729
+ if (stage === 'chain-broadcast') {
730
+ await testChainBroadcast();
731
+ return;
732
+ }
733
+ if (stage === 'chain-actions') {
734
+ await testChainActions();
735
+ return;
736
+ }
737
+ throw new Error(`Unknown stage: ${stage}`);
738
+ }
739
+ );
@@ -2,18 +2,16 @@
2
2
 
3
3
  const assert = require('assert');
4
4
  const Module = require('module');
5
+ const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
5
6
 
6
- function clearModule(modulePath: string) {
7
- delete require.cache[modulePath];
7
+ // Compiled ESM graphs cannot be mocked via require.cache; the helper installs
8
+ // loader hooks (one child process per stage so fresh module instances load).
9
+ function clearModule(_modulePath: string) {
10
+ /* no-op under ESM hooks */
8
11
  }
9
12
 
10
13
  function registerMock(modulePath: string, exports: any) {
11
- require.cache[modulePath] = {
12
- id: modulePath,
13
- filename: modulePath,
14
- loaded: true,
15
- exports
16
- } as any;
14
+ defineEsmMockAbs(modulePath, Object.keys(exports), exports);
17
15
  }
18
16
 
19
17
  const { clone } = require('../modules/utils');
@@ -503,15 +501,25 @@ function testLiquidityPoolsWrapper() {
503
501
  console.log(' PASS');
504
502
  }
505
503
 
506
- async function main() {
507
- await testPositionDiscoveryAndFeedSource();
508
- await testDecisionLoop();
509
- await testKibanaPriceSource();
510
- testLiquidityPoolsWrapper();
511
- console.log('claw data flow tests passed');
512
- }
513
-
514
- main().catch((err) => {
515
- console.error(err);
516
- process.exit(1);
517
- });
504
+ runEsmMockStages(
505
+ ['discovery-feed', 'decision-loop', 'kibana', 'liquidity-pools'],
506
+ async (stage: string) => {
507
+ if (stage === 'discovery-feed') {
508
+ await testPositionDiscoveryAndFeedSource();
509
+ return;
510
+ }
511
+ if (stage === 'decision-loop') {
512
+ await testDecisionLoop();
513
+ return;
514
+ }
515
+ if (stage === 'kibana') {
516
+ await testKibanaPriceSource();
517
+ return;
518
+ }
519
+ if (stage === 'liquidity-pools') {
520
+ testLiquidityPoolsWrapper();
521
+ return;
522
+ }
523
+ throw new Error(`Unknown stage: ${stage}`);
524
+ }
525
+ );
@@ -4,18 +4,16 @@ const assert = require('assert');
4
4
  const fs = require('fs/promises');
5
5
  const os = require('os');
6
6
  const path = require('path');
7
+ const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
7
8
 
8
- function clearModule(modulePath: string) {
9
- delete require.cache[modulePath];
9
+ // Compiled ESM graphs cannot be mocked via require.cache; the helper installs
10
+ // loader hooks (one child process per stage so fresh module instances load).
11
+ function clearModule(_modulePath: string) {
12
+ /* no-op under ESM hooks */
10
13
  }
11
14
 
12
15
  function registerMock(modulePath: string, exports: any) {
13
- require.cache[modulePath] = {
14
- id: modulePath,
15
- filename: modulePath,
16
- loaded: true,
17
- exports
18
- } as any;
16
+ defineEsmMockAbs(modulePath, Object.keys(exports), exports);
19
17
  }
20
18
 
21
19
  const { clone } = require('../modules/utils');
@@ -98,6 +96,7 @@ function createHonestHarness(options: any = {}) {
98
96
  calls.getCallOrders.push({ assetId, limit });
99
97
  return [{ id: `${assetId}-call-1` }];
100
98
  },
99
+ getObjects: async () => [],
101
100
  listAssets: async (lowerBound: string, limit: any) => {
102
101
  calls.listAssets.push({ lowerBound, limit });
103
102
  return listAssetPages.shift() || [];
@@ -452,14 +451,21 @@ async function testPositionManager() {
452
451
  console.log(' PASS');
453
452
  }
454
453
 
455
- async function main() {
456
- await testHonestEcosystem();
457
- await testHonestEcosystemPaginationAndUnresolvedPair();
458
- await testPositionManager();
459
- console.log('claw domain logic tests passed');
460
- }
461
-
462
- main().catch((err) => {
463
- console.error(err);
464
- process.exit(1);
465
- });
454
+ runEsmMockStages(
455
+ ['honest', 'honest-pagination', 'position-manager'],
456
+ async (stage: string) => {
457
+ if (stage === 'honest') {
458
+ await testHonestEcosystem();
459
+ return;
460
+ }
461
+ if (stage === 'honest-pagination') {
462
+ await testHonestEcosystemPaginationAndUnresolvedPair();
463
+ return;
464
+ }
465
+ if (stage === 'position-manager') {
466
+ await testPositionManager();
467
+ return;
468
+ }
469
+ throw new Error(`Unknown stage: ${stage}`);
470
+ }
471
+ );
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const assert = require('assert');
4
+ const fs = require('fs');
4
5
  const path = require('path');
5
6
 
6
7
  // ---------------------------------------------------------------------------
@@ -154,6 +155,25 @@ function testClawManifest() {
154
155
  // dexbot_bridge — getDexbot2Root branching only
155
156
  // ---------------------------------------------------------------------------
156
157
 
158
+ // Repo root located independently of the compiled layout: compiled tests run
159
+ // from <repo>/dist/claw/tests, so a fixed __dirname offset would point at
160
+ // dist/ instead of the repo. The repo root is the nearest ancestor holding
161
+ // package.json plus both the modules/ and claw/ source trees.
162
+ function findRepoRoot(startDir: string) {
163
+ let dir = startDir;
164
+ for (let i = 0; i < 10; i++) {
165
+ if (
166
+ fs.existsSync(path.join(dir, 'package.json')) &&
167
+ fs.existsSync(path.join(dir, 'modules')) &&
168
+ fs.existsSync(path.join(dir, 'claw'))
169
+ ) {
170
+ return dir;
171
+ }
172
+ dir = path.dirname(dir);
173
+ }
174
+ throw new Error('Unable to locate DEXBot2 repo root');
175
+ }
176
+
157
177
  function testDexbotBridgeRootResolution() {
158
178
  const bridgePath = require.resolve('../modules/dexbot_bridge');
159
179
  const { Config } = require('../../modules/config');
@@ -173,14 +193,14 @@ function testDexbotBridgeRootResolution() {
173
193
  }
174
194
 
175
195
  // --- Branch 2: no DEXBOT2_ROOT, auto-detected local repo layout ---
176
- // The test is already running inside the DEXBot2 repo, so the existsSync
177
- // check for modules/order/index.ts should resolve to the repo root.
196
+ // The test runs inside the DEXBot2 repo, so the existsSync candidate check
197
+ // (dist/modules/order/index.js) should resolve to the repo root itself.
178
198
  delete require.cache[bridgePath];
179
199
  Config.DEXBOT2_ROOT = undefined;
180
200
  try {
181
201
  const bridge = require('../modules/dexbot_bridge');
182
202
  const root = bridge.getDexbot2Root();
183
- const expectedRoot = path.resolve(__dirname, '..', '..');
203
+ const expectedRoot = findRepoRoot(__dirname);
184
204
  assert.strictEqual(root, expectedRoot);
185
205
  } finally {
186
206
  Config.DEXBOT2_ROOT = savedRoot;
@@ -6,7 +6,6 @@ const os = require('os');
6
6
  const { getErrorMessage } = require('../../modules/utils/errors');
7
7
  const { spawnSync } = require('child_process');
8
8
  const path = require('path');
9
- const { isDistCodeRoot } = require('../../modules/launcher/runtime_entry');
10
9
  const mcpServer = require('../scripts/claw_mcp_server');
11
10
 
12
11
  function encodeNewlineMessage(message: any) {
@@ -31,7 +30,7 @@ async function testParserAcceptsJsonlAcrossChunksAndSingleBuffer() {
31
30
  capabilities: {},
32
31
  clientInfo: {
33
32
  name: 'claw-mcp-transport-test',
34
- version: '1.4.21'
33
+ version: '1.4.22'
35
34
  },
36
35
  protocolVersion: '2024-11-05'
37
36
  }
@@ -143,10 +142,17 @@ async function testHandleRequestEmitsNewlineJson() {
143
142
  }
144
143
 
145
144
  function runServerProcess(input: any) {
146
- const repoRoot = path.resolve(__dirname, '..', '..');
145
+ // Resolve the real checkout root (works from both the source tree and the
146
+ // compiled dist/claw/tests location) and prefer the compiled server script.
147
+ let repoRoot = path.resolve(__dirname, '..', '..');
148
+ while (!fs.existsSync(path.join(repoRoot, 'package.json'))) {
149
+ const parent = path.dirname(repoRoot);
150
+ if (parent === repoRoot) throw new Error('Unable to locate DEXBot2 checkout root');
151
+ repoRoot = parent;
152
+ }
147
153
  const clawRoot = path.resolve(__dirname, '..');
148
- const _isDist = isDistCodeRoot(path.dirname(__dirname));
149
- const scriptPath = path.join(clawRoot, 'scripts', 'claw_mcp_server' + (_isDist ? '.js' : '.ts'));
154
+ const scriptBase = path.join(clawRoot, 'scripts', 'claw_mcp_server');
155
+ const scriptPath = fs.existsSync(`${scriptBase}.js`) ? `${scriptBase}.js` : `${scriptBase}.ts`;
150
156
  const scriptRel = path.relative(repoRoot, scriptPath);
151
157
 
152
158
  const tmpRoot = fs.mkdtempSync(path.join(os.tmpdir(), 'claw-mcp-transport-'));
@@ -155,8 +161,7 @@ function runServerProcess(input: any) {
155
161
  fs.writeFileSync(inputPath, input, 'utf8');
156
162
 
157
163
  try {
158
- const loaderArgs = _isDist ? '' : '--import tsx ';
159
- const shellCommand = `cat ${shellQuote(inputPath)} | ${shellQuote(process.execPath)} --no-warnings ${loaderArgs}${shellQuote(scriptRel)} --profile-root ${shellQuote(repoRoot)} > ${shellQuote(outputPath)}`;
164
+ const shellCommand = `cat ${shellQuote(inputPath)} | ${shellQuote(process.execPath)} --no-warnings ${shellQuote(scriptRel)} --profile-root ${shellQuote(repoRoot)} > ${shellQuote(outputPath)}`;
160
165
  const run = spawnSync('/bin/sh', ['-lc', shellCommand], {
161
166
  cwd: repoRoot,
162
167
  encoding: 'utf8'
@@ -182,7 +187,7 @@ async function testMainEntrypointHandlesRealProcessInitialize() {
182
187
  capabilities: {},
183
188
  clientInfo: {
184
189
  name: 'claw-mcp-transport-test',
185
- version: '1.4.21'
190
+ version: '1.4.22'
186
191
  },
187
192
  protocolVersion: '2024-11-05'
188
193
  }