dexbot 1.4.20 → 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 (674) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +23 -13
  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 +8 -6
  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 +16 -10
  22. package/analysis/bot_key_utils.ts +14 -11
  23. package/analysis/bot_usage/discover_bot_accounts.ts +5 -3
  24. package/analysis/bot_usage/kibana_bot_queries.ts +2 -257
  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/math_utils.ts +1 -8
  30. package/analysis/price_sources.ts +8 -2
  31. package/analysis/resolve_source.ts +1 -1
  32. package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +2455 -0
  33. package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +218 -0
  34. package/analysis/trade_profitability.ts +61 -28
  35. package/analysis/tradingview/analyze_tradingview.ts +1 -1
  36. package/analysis/tradingview/h-bts_tradingview.html +1570 -0
  37. package/analysis/tradingview/t-bts_tradingview.html +1570 -0
  38. package/analysis/tradingview/tradingview_uplot_chart_generator.ts +302 -74
  39. package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
  40. package/analysis/trend_detection/derivative_analyzer.ts +12 -3
  41. package/analysis/trend_detection/dynamic_weight_chart_generator.ts +25 -27
  42. package/analysis/trend_detection/hurst_analyzer.ts +1 -1
  43. package/analysis/trend_detection/kalman_chart_generator.ts +42 -14
  44. package/analysis/trend_detection/package.json +1 -1
  45. package/analysis/trend_detection/regime_chart_generator.ts +39 -19
  46. package/analysis/trend_detection/tests/test_kalman_trend.ts +1 -1
  47. package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +1 -1
  48. package/analysis/trend_detection/volatility_chart_generator.ts +1 -1
  49. package/claw/ecosystem.config.cjs +2 -3
  50. package/claw/examples/memu_integration_example.ts +17 -17
  51. package/claw/index.ts +1 -1
  52. package/claw/modules/chain_actions.ts +51 -54
  53. package/claw/modules/chain_broadcast.ts +66 -104
  54. package/claw/modules/claw_bridge.ts +63 -83
  55. package/claw/modules/claw_catalog.ts +48 -17
  56. package/claw/modules/claw_infra.ts +1 -5
  57. package/claw/modules/claw_launcher.ts +48 -50
  58. package/claw/modules/claw_skill_md.ts +15 -21
  59. package/claw/modules/credit_runtime_adapter.ts +3 -19
  60. package/claw/modules/decision_loop.ts +9 -9
  61. package/claw/modules/dexbot_bridge.ts +8 -8
  62. package/claw/modules/dexbot_profiles.ts +5 -21
  63. package/claw/modules/feed_price_source.ts +1 -1
  64. package/claw/modules/honest_ecosystem.ts +24 -8
  65. package/claw/modules/kibana_price_source.ts +1 -1
  66. package/claw/modules/launcher_mode_detector.ts +1 -1
  67. package/claw/modules/launcher_paths.ts +1 -1
  68. package/claw/modules/liquidity_pools.ts +10 -3
  69. package/claw/modules/mcp_utils.ts +109 -0
  70. package/claw/modules/memu_bridge.ts +76 -54
  71. package/claw/modules/mpa_utils.ts +26 -3
  72. package/claw/modules/position_discovery.ts +17 -28
  73. package/claw/modules/position_health.ts +1 -1
  74. package/claw/modules/position_manager.ts +32 -41
  75. package/claw/modules/position_manager_watch.ts +3 -2
  76. package/claw/modules/short_mpa_strategy.ts +1 -9
  77. package/claw/modules/skill_utils.ts +5 -3
  78. package/claw/modules/utils.ts +9 -1
  79. package/claw/package.json +3 -3
  80. package/claw/runtimes/openclaw-plugin/index.ts +27 -10
  81. package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
  82. package/claw/runtimes/openclaw-plugin/package.json +1 -1
  83. package/claw/scripts/claw_bridge.ts +1 -1
  84. package/claw/scripts/claw_mcp_server.ts +19 -78
  85. package/claw/scripts/honest_assets_report.ts +19 -84
  86. package/claw/scripts/memu_mcp_server.ts +57 -155
  87. package/claw/skills/launcher-ops/references/launcher-workflow.md +2 -2
  88. package/claw/tests/package.json +1 -1
  89. package/claw/tests/test_claw_bridge.ts +47 -19
  90. package/claw/tests/test_claw_catalog_and_credentials.ts +8 -4
  91. package/claw/tests/test_claw_chain_layer.ts +39 -19
  92. package/claw/tests/test_claw_data_flow.ts +28 -20
  93. package/claw/tests/test_claw_domain_logic.ts +25 -19
  94. package/claw/tests/test_claw_manifest_and_matrix.ts +23 -3
  95. package/claw/tests/test_claw_mcp_transport.ts +13 -8
  96. package/claw/tests/test_claw_regressions.ts +254 -128
  97. package/claw/tests/test_claw_skill_generation.ts +1 -1
  98. package/claw/tests/test_nullclaw_tmp_integration.ts +2 -3
  99. package/claw/tests/test_position_health.ts +1 -77
  100. package/claw/tests/test_position_manager.ts +20 -18
  101. package/claw/tests/test_position_manager_watch_health.ts +39 -43
  102. package/claw/tests/test_short_mpa_strategy.ts +20 -17
  103. package/claw/tsconfig.json +4 -3
  104. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +7 -3
  105. package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -1
  106. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +3 -3
  107. package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -1
  108. package/dist/analysis/ama_fitting/calibrate_convergence_er.js +8 -6
  109. package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -1
  110. package/dist/analysis/ama_fitting/fetch_lp_candles.js +8 -3
  111. package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -1
  112. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +2 -2
  113. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -1
  114. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +31 -75
  115. package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -1
  116. package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -1
  117. package/dist/analysis/ama_fitting/optimizer_high_resolution.js +21 -13
  118. package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -1
  119. package/dist/analysis/analyze_derivatives.d.ts +0 -18
  120. package/dist/analysis/analyze_derivatives.d.ts.map +1 -1
  121. package/dist/analysis/analyze_derivatives.js +4 -4
  122. package/dist/analysis/analyze_derivatives.js.map +1 -1
  123. package/dist/analysis/analyze_dynamic_weight.d.ts +0 -11
  124. package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -1
  125. package/dist/analysis/analyze_dynamic_weight.js +19 -5
  126. package/dist/analysis/analyze_dynamic_weight.js.map +1 -1
  127. package/dist/analysis/analyze_kalman.d.ts +0 -10
  128. package/dist/analysis/analyze_kalman.d.ts.map +1 -1
  129. package/dist/analysis/analyze_kalman.js +51 -26
  130. package/dist/analysis/analyze_kalman.js.map +1 -1
  131. package/dist/analysis/analyze_regime.d.ts +0 -17
  132. package/dist/analysis/analyze_regime.d.ts.map +1 -1
  133. package/dist/analysis/analyze_regime.js +2 -2
  134. package/dist/analysis/analyze_regime.js.map +1 -1
  135. package/dist/analysis/analyze_regime_windows.d.ts +0 -16
  136. package/dist/analysis/analyze_regime_windows.d.ts.map +1 -1
  137. package/dist/analysis/analyze_regime_windows.js +28 -21
  138. package/dist/analysis/analyze_regime_windows.js.map +1 -1
  139. package/dist/analysis/analyze_risk_profile.js +3 -3
  140. package/dist/analysis/analyze_risk_profile.js.map +1 -1
  141. package/dist/analysis/analyze_trade_heatmap.js +3 -3
  142. package/dist/analysis/analyze_trade_heatmap.js.map +1 -1
  143. package/dist/analysis/analyze_volatility.d.ts +0 -19
  144. package/dist/analysis/analyze_volatility.d.ts.map +1 -1
  145. package/dist/analysis/analyze_volatility.js +2 -2
  146. package/dist/analysis/analyze_volatility.js.map +1 -1
  147. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +30 -14
  148. package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -1
  149. package/dist/analysis/bot_fitting/backtest_ama_sweep.js +330 -193
  150. package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -1
  151. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +136 -1
  152. package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -1
  153. package/dist/analysis/bot_fitting/backtest_bot_fitting.js +527 -83
  154. package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -1
  155. package/dist/analysis/bot_fitting/shared_utils.d.ts +2 -13
  156. package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -1
  157. package/dist/analysis/bot_fitting/shared_utils.js +15 -9
  158. package/dist/analysis/bot_fitting/shared_utils.js.map +1 -1
  159. package/dist/analysis/bot_key_utils.d.ts +1 -1
  160. package/dist/analysis/bot_key_utils.d.ts.map +1 -1
  161. package/dist/analysis/bot_key_utils.js +14 -11
  162. package/dist/analysis/bot_key_utils.js.map +1 -1
  163. package/dist/analysis/bot_usage/discover_bot_accounts.js +5 -3
  164. package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -1
  165. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -337
  166. package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -1
  167. package/dist/analysis/bot_usage/kibana_bot_queries.js +2 -242
  168. package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -1
  169. package/dist/analysis/chart_css.d.ts +2 -14
  170. package/dist/analysis/chart_css.d.ts.map +1 -1
  171. package/dist/analysis/chart_css.js +6 -3
  172. package/dist/analysis/chart_css.js.map +1 -1
  173. package/dist/analysis/chart_ui.d.ts.map +1 -1
  174. package/dist/analysis/chart_ui.js.map +1 -1
  175. package/dist/analysis/chart_utils.d.ts.map +1 -1
  176. package/dist/analysis/chart_utils.js +15 -2
  177. package/dist/analysis/chart_utils.js.map +1 -1
  178. package/dist/analysis/derivative_chart_generator.js +2 -2
  179. package/dist/analysis/derivative_chart_generator.js.map +1 -1
  180. package/dist/analysis/math_utils.d.ts +3 -5
  181. package/dist/analysis/math_utils.d.ts.map +1 -1
  182. package/dist/analysis/math_utils.js +3 -5
  183. package/dist/analysis/math_utils.js.map +1 -1
  184. package/dist/analysis/price_sources.d.ts +1 -0
  185. package/dist/analysis/price_sources.d.ts.map +1 -1
  186. package/dist/analysis/price_sources.js +8 -2
  187. package/dist/analysis/price_sources.js.map +1 -1
  188. package/dist/analysis/resolve_source.d.ts.map +1 -1
  189. package/dist/analysis/resolve_source.js +1 -1
  190. package/dist/analysis/resolve_source.js.map +1 -1
  191. package/dist/analysis/trade_profitability.d.ts.map +1 -1
  192. package/dist/analysis/trade_profitability.js +58 -29
  193. package/dist/analysis/trade_profitability.js.map +1 -1
  194. package/dist/analysis/tradingview/analyze_tradingview.js +1 -1
  195. package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -1
  196. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
  197. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +302 -74
  198. package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
  199. package/dist/analysis/trend_detection/derivative_analyzer.d.ts +1 -0
  200. package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -1
  201. package/dist/analysis/trend_detection/derivative_analyzer.js +12 -3
  202. package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -1
  203. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -1
  204. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +26 -27
  205. package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -1
  206. package/dist/analysis/trend_detection/hurst_analyzer.d.ts +1 -1
  207. package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -1
  208. package/dist/analysis/trend_detection/hurst_analyzer.js +1 -1
  209. package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
  210. package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -1
  211. package/dist/analysis/trend_detection/kalman_chart_generator.js +41 -13
  212. package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -1
  213. package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -1
  214. package/dist/analysis/trend_detection/regime_chart_generator.js +38 -19
  215. package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -1
  216. package/dist/analysis/trend_detection/tests/test_kalman_trend.js +1 -1
  217. package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -1
  218. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +1 -1
  219. package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -1
  220. package/dist/analysis/trend_detection/volatility_chart_generator.js +1 -1
  221. package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -1
  222. package/dist/bot.js +3 -3
  223. package/dist/bot.js.map +1 -1
  224. package/dist/credential-daemon.d.ts +1 -1
  225. package/dist/credential-daemon.js +2 -2
  226. package/dist/credential-daemon.js.map +1 -1
  227. package/dist/dexbot.d.ts.map +1 -1
  228. package/dist/dexbot.js +25 -22
  229. package/dist/dexbot.js.map +1 -1
  230. package/dist/market_adapter/ama_signal_runner.js +6 -4
  231. package/dist/market_adapter/ama_signal_runner.js.map +1 -1
  232. package/dist/market_adapter/candle_utils.d.ts +1 -3
  233. package/dist/market_adapter/candle_utils.d.ts.map +1 -1
  234. package/dist/market_adapter/candle_utils.js +1 -11
  235. package/dist/market_adapter/candle_utils.js.map +1 -1
  236. package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -1
  237. package/dist/market_adapter/core/asymmetric_bounds.js +33 -30
  238. package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
  239. package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -1
  240. package/dist/market_adapter/core/config_normalizers.js +10 -1
  241. package/dist/market_adapter/core/config_normalizers.js.map +1 -1
  242. package/dist/market_adapter/core/kibana_candles.d.ts +18 -42
  243. package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -1
  244. package/dist/market_adapter/core/kibana_candles.js +101 -7
  245. package/dist/market_adapter/core/kibana_candles.js.map +1 -1
  246. package/dist/market_adapter/core/kibana_client.d.ts +1 -17
  247. package/dist/market_adapter/core/kibana_client.d.ts.map +1 -1
  248. package/dist/market_adapter/core/kibana_client.js +40 -7
  249. package/dist/market_adapter/core/kibana_client.js.map +1 -1
  250. package/dist/market_adapter/core/kibana_market_candles.d.ts +0 -27
  251. package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -1
  252. package/dist/market_adapter/core/kibana_market_candles.js +1 -1
  253. package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
  254. package/dist/market_adapter/core/market_adapter_service.d.ts +22 -13
  255. package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
  256. package/dist/market_adapter/core/market_adapter_service.js +96 -38
  257. package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
  258. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts +10 -1
  259. package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +1 -1
  260. package/dist/market_adapter/core/signals/hurst_analyzer.js +28 -17
  261. package/dist/market_adapter/core/signals/hurst_analyzer.js.map +1 -1
  262. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts +5 -0
  263. package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +1 -1
  264. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js +24 -24
  265. package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +1 -1
  266. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +1 -1
  267. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js +5 -1
  268. package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +1 -1
  269. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +1 -1
  270. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js +20 -3
  271. package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +1 -1
  272. package/dist/market_adapter/core/strategies/ama.js +1 -1
  273. package/dist/market_adapter/core/strategies/ama.js.map +1 -1
  274. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +2 -2
  275. package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -1
  276. package/dist/market_adapter/core/strategies/ama_slope_model.js +16 -4
  277. package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
  278. package/dist/market_adapter/core/strategies/atr/calculator.d.ts +4 -3
  279. package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -1
  280. package/dist/market_adapter/core/strategies/atr/calculator.js +16 -8
  281. package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
  282. package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -1
  283. package/dist/market_adapter/core/strategies/collateral_manager.js +8 -3
  284. package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
  285. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +40 -1
  286. package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +1 -1
  287. package/dist/market_adapter/core/strategies/dynamic_weight_series.js +116 -2
  288. package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +1 -1
  289. package/dist/market_adapter/core/strategies/regime_gate.d.ts +1 -2
  290. package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -1
  291. package/dist/market_adapter/core/strategies/regime_gate.js +27 -21
  292. package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
  293. package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +1 -1
  294. package/dist/market_adapter/core/strategies/volatility_shift.js +3 -0
  295. package/dist/market_adapter/core/strategies/volatility_shift.js.map +1 -1
  296. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +71 -57
  297. package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
  298. package/dist/market_adapter/inputs/fetch_lp_data.d.ts +0 -26
  299. package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
  300. package/dist/market_adapter/inputs/fetch_lp_data.js +72 -19
  301. package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
  302. package/dist/market_adapter/inputs/kibana_source.d.ts +5 -30
  303. package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -1
  304. package/dist/market_adapter/inputs/kibana_source.js +6 -3
  305. package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
  306. package/dist/market_adapter/lp_chart_core.js +1 -1
  307. package/dist/market_adapter/lp_chart_core.js.map +1 -1
  308. package/dist/market_adapter/lp_chart_runner.d.ts +10 -1
  309. package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
  310. package/dist/market_adapter/lp_chart_runner.js +2 -2
  311. package/dist/market_adapter/lp_chart_runner.js.map +1 -1
  312. package/dist/market_adapter/lp_chart_strategy_loader.d.ts +1 -2
  313. package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -1
  314. package/dist/market_adapter/lp_chart_strategy_loader.js +5 -5
  315. package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
  316. package/dist/market_adapter/market_adapter.d.ts +1 -2
  317. package/dist/market_adapter/market_adapter.d.ts.map +1 -1
  318. package/dist/market_adapter/market_adapter.js +5 -7
  319. package/dist/market_adapter/market_adapter.js.map +1 -1
  320. package/dist/market_adapter/test_helpers.d.ts +3 -3
  321. package/dist/market_adapter/test_helpers.d.ts.map +1 -1
  322. package/dist/market_adapter/test_helpers.js +3 -3
  323. package/dist/market_adapter/test_helpers.js.map +1 -1
  324. package/dist/market_adapter/utils/adapter_client.js +1 -1
  325. package/dist/market_adapter/utils/adapter_client.js.map +1 -1
  326. package/dist/market_adapter/utils/atomic_write.js +1 -1
  327. package/dist/market_adapter/utils/atomic_write.js.map +1 -1
  328. package/dist/market_adapter/utils/chain.d.ts +0 -2
  329. package/dist/market_adapter/utils/chain.d.ts.map +1 -1
  330. package/dist/market_adapter/utils/chain.js +2 -3
  331. package/dist/market_adapter/utils/chain.js.map +1 -1
  332. package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -1
  333. package/dist/market_adapter/utils/data_discovery.js +24 -8
  334. package/dist/market_adapter/utils/data_discovery.js.map +1 -1
  335. package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
  336. package/dist/market_adapter/utils/dynamic_grid_snapshot.js +2 -5
  337. package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
  338. package/dist/market_adapter/utils/file_lock.d.ts +4 -1
  339. package/dist/market_adapter/utils/file_lock.d.ts.map +1 -1
  340. package/dist/market_adapter/utils/file_lock.js +89 -25
  341. package/dist/market_adapter/utils/file_lock.js.map +1 -1
  342. package/dist/market_adapter/utils/native_history.d.ts.map +1 -1
  343. package/dist/market_adapter/utils/native_history.js +5 -1
  344. package/dist/market_adapter/utils/native_history.js.map +1 -1
  345. package/dist/modules/account_bots.d.ts +3 -0
  346. package/dist/modules/account_bots.d.ts.map +1 -1
  347. package/dist/modules/account_bots.js +157 -47
  348. package/dist/modules/account_bots.js.map +1 -1
  349. package/dist/modules/account_orders.d.ts +1 -7
  350. package/dist/modules/account_orders.d.ts.map +1 -1
  351. package/dist/modules/account_orders.js +9 -17
  352. package/dist/modules/account_orders.js.map +1 -1
  353. package/dist/modules/authority_resolver.js +1 -1
  354. package/dist/modules/authority_resolver.js.map +1 -1
  355. package/dist/modules/bitshares-native/chain_client.js +1 -1
  356. package/dist/modules/bitshares-native/chain_client.js.map +1 -1
  357. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +0 -12
  358. package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -1
  359. package/dist/modules/bitshares-native/crypto/ecc.browser.js +1 -1
  360. package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
  361. package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -1
  362. package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
  363. package/dist/modules/bitshares-native/index.d.ts.map +1 -1
  364. package/dist/modules/bitshares-native/index.js +1 -1
  365. package/dist/modules/bitshares-native/index.js.map +1 -1
  366. package/dist/modules/bitshares-native/lru_cache.js +1 -1
  367. package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
  368. package/dist/modules/bitshares-native/resolvers.d.ts +0 -2
  369. package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -1
  370. package/dist/modules/bitshares-native/resolvers.js +18 -4
  371. package/dist/modules/bitshares-native/resolvers.js.map +1 -1
  372. package/dist/modules/bitshares-native/serial/chain_constants.js +1 -1
  373. package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
  374. package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
  375. package/dist/modules/bitshares-native/serial/index.js +1 -1
  376. package/dist/modules/bitshares-native/serial/index.js.map +1 -1
  377. package/dist/modules/bitshares-native/serial/operations.js +1 -1
  378. package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
  379. package/dist/modules/bitshares-native/serial/serializer.js +1 -1
  380. package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
  381. package/dist/modules/bitshares-native/serial/types.js +1 -1
  382. package/dist/modules/bitshares-native/serial/types.js.map +1 -1
  383. package/dist/modules/bitshares-native/signing_client.js +2 -2
  384. package/dist/modules/bitshares-native/signing_client.js.map +1 -1
  385. package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
  386. package/dist/modules/bitshares-native/subscriptions.js +5 -14
  387. package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
  388. package/dist/modules/bitshares-native/transport.js +1 -1
  389. package/dist/modules/bitshares-native/transport.js.map +1 -1
  390. package/dist/modules/bitshares-native/tx/builder.js +1 -1
  391. package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
  392. package/dist/modules/bitshares-native/tx/tx_cache.d.ts +3 -2
  393. package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +1 -1
  394. package/dist/modules/bitshares-native/tx/tx_cache.js +7 -4
  395. package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
  396. package/dist/modules/bitshares_client.d.ts +2 -14
  397. package/dist/modules/bitshares_client.d.ts.map +1 -1
  398. package/dist/modules/bitshares_client.js +32 -41
  399. package/dist/modules/bitshares_client.js.map +1 -1
  400. package/dist/modules/bot_settings.d.ts.map +1 -1
  401. package/dist/modules/bot_settings.js +12 -19
  402. package/dist/modules/bot_settings.js.map +1 -1
  403. package/dist/modules/bots_file_lock.d.ts +1 -1
  404. package/dist/modules/bots_file_lock.js +1 -1
  405. package/dist/modules/broadcast_failure.d.ts +13 -0
  406. package/dist/modules/broadcast_failure.d.ts.map +1 -1
  407. package/dist/modules/broadcast_failure.js +0 -13
  408. package/dist/modules/broadcast_failure.js.map +1 -1
  409. package/dist/modules/chain_keys.js +2 -2
  410. package/dist/modules/chain_keys.js.map +1 -1
  411. package/dist/modules/chain_orders.d.ts +2 -3
  412. package/dist/modules/chain_orders.d.ts.map +1 -1
  413. package/dist/modules/chain_orders.js +23 -42
  414. package/dist/modules/chain_orders.js.map +1 -1
  415. package/dist/modules/config.d.ts.map +1 -1
  416. package/dist/modules/config.js +5 -2
  417. package/dist/modules/config.js.map +1 -1
  418. package/dist/modules/constants.d.ts +21 -21
  419. package/dist/modules/constants.d.ts.map +1 -1
  420. package/dist/modules/constants.js +53 -60
  421. package/dist/modules/constants.js.map +1 -1
  422. package/dist/modules/cr_planner.d.ts +1 -7
  423. package/dist/modules/cr_planner.d.ts.map +1 -1
  424. package/dist/modules/cr_planner.js +3 -77
  425. package/dist/modules/cr_planner.js.map +1 -1
  426. package/dist/modules/credential_policy.d.ts +0 -4
  427. package/dist/modules/credential_policy.d.ts.map +1 -1
  428. package/dist/modules/credential_policy.js +18 -3
  429. package/dist/modules/credential_policy.js.map +1 -1
  430. package/dist/modules/credit_runtime.d.ts +0 -7
  431. package/dist/modules/credit_runtime.d.ts.map +1 -1
  432. package/dist/modules/credit_runtime.js +21 -60
  433. package/dist/modules/credit_runtime.js.map +1 -1
  434. package/dist/modules/crypto/index.d.ts +0 -2
  435. package/dist/modules/crypto/index.d.ts.map +1 -1
  436. package/dist/modules/crypto/index.js +0 -2
  437. package/dist/modules/crypto/index.js.map +1 -1
  438. package/dist/modules/crypto/sync.js.map +1 -1
  439. package/dist/modules/daemon_node_health.js +1 -1
  440. package/dist/modules/daemon_node_health.js.map +1 -1
  441. package/dist/modules/dexbot_class.d.ts +8 -134
  442. package/dist/modules/dexbot_class.d.ts.map +1 -1
  443. package/dist/modules/dexbot_class.js +39 -199
  444. package/dist/modules/dexbot_class.js.map +1 -1
  445. package/dist/modules/dexbot_credential_client.js +1 -1
  446. package/dist/modules/dexbot_credential_client.js.map +1 -1
  447. package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
  448. package/dist/modules/dexbot_fill_runtime.js +3 -6
  449. package/dist/modules/dexbot_fill_runtime.js.map +1 -1
  450. package/dist/modules/dexbot_maintenance_runtime.d.ts +6 -34
  451. package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
  452. package/dist/modules/dexbot_maintenance_runtime.js +27 -19
  453. package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
  454. package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
  455. package/dist/modules/dexbot_startup_runtime.js +31 -15
  456. package/dist/modules/dexbot_startup_runtime.js.map +1 -1
  457. package/dist/modules/dexbot_state_recovery.d.ts +2 -2
  458. package/dist/modules/dexbot_state_recovery.d.ts.map +1 -1
  459. package/dist/modules/dexbot_state_recovery.js +11 -7
  460. package/dist/modules/dexbot_state_recovery.js.map +1 -1
  461. package/dist/modules/fund_registry.d.ts.map +1 -1
  462. package/dist/modules/fund_registry.js +24 -6
  463. package/dist/modules/fund_registry.js.map +1 -1
  464. package/dist/modules/general_settings.d.ts +1 -2
  465. package/dist/modules/general_settings.d.ts.map +1 -1
  466. package/dist/modules/general_settings.js +1 -2
  467. package/dist/modules/general_settings.js.map +1 -1
  468. package/dist/modules/graceful_shutdown.d.ts.map +1 -1
  469. package/dist/modules/graceful_shutdown.js +10 -1
  470. package/dist/modules/graceful_shutdown.js.map +1 -1
  471. package/dist/modules/grid_price_source.d.ts +19 -0
  472. package/dist/modules/grid_price_source.d.ts.map +1 -0
  473. package/dist/modules/grid_price_source.js +23 -0
  474. package/dist/modules/grid_price_source.js.map +1 -0
  475. package/dist/modules/key_store.d.ts +0 -5
  476. package/dist/modules/key_store.d.ts.map +1 -1
  477. package/dist/modules/key_store.js +1 -14
  478. package/dist/modules/key_store.js.map +1 -1
  479. package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
  480. package/dist/modules/launcher/bot_supervisor.js +15 -26
  481. package/dist/modules/launcher/bot_supervisor.js.map +1 -1
  482. package/dist/modules/launcher/child_env.d.ts +1 -2
  483. package/dist/modules/launcher/child_env.d.ts.map +1 -1
  484. package/dist/modules/launcher/child_env.js +1 -1
  485. package/dist/modules/launcher/child_env.js.map +1 -1
  486. package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -1
  487. package/dist/modules/launcher/foreign_cred_daemon.js +7 -13
  488. package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
  489. package/dist/modules/launcher/market_adapter_runtime.d.ts +3 -4
  490. package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
  491. package/dist/modules/launcher/market_adapter_runtime.js +10 -29
  492. package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
  493. package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
  494. package/dist/modules/launcher/market_adapter_watchdog.js +3 -2
  495. package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
  496. package/dist/modules/launcher/monolithic_runtime.d.ts +0 -1
  497. package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
  498. package/dist/modules/launcher/monolithic_runtime.js +4 -18
  499. package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
  500. package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
  501. package/dist/modules/launcher/runtime_entry.js +4 -5
  502. package/dist/modules/launcher/runtime_entry.js.map +1 -1
  503. package/dist/modules/launcher/status_reporting.d.ts +1 -2
  504. package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
  505. package/dist/modules/launcher/status_reporting.js +2 -5
  506. package/dist/modules/launcher/status_reporting.js.map +1 -1
  507. package/dist/modules/launcher/supervisor_control.js +1 -1
  508. package/dist/modules/launcher/supervisor_control.js.map +1 -1
  509. package/dist/modules/market_adapter_whitelist.d.ts +2 -2
  510. package/dist/modules/market_adapter_whitelist.d.ts.map +1 -1
  511. package/dist/modules/market_adapter_whitelist.js +12 -6
  512. package/dist/modules/market_adapter_whitelist.js.map +1 -1
  513. package/dist/modules/node_failure_ledger.d.ts +23 -0
  514. package/dist/modules/node_failure_ledger.d.ts.map +1 -1
  515. package/dist/modules/node_failure_ledger.js +0 -23
  516. package/dist/modules/node_failure_ledger.js.map +1 -1
  517. package/dist/modules/node_manager.d.ts.map +1 -1
  518. package/dist/modules/node_manager.js +3 -3
  519. package/dist/modules/node_manager.js.map +1 -1
  520. package/dist/modules/order/accounting.js +3 -3
  521. package/dist/modules/order/accounting.js.map +1 -1
  522. package/dist/modules/order/async_lock.d.ts +6 -0
  523. package/dist/modules/order/async_lock.d.ts.map +1 -1
  524. package/dist/modules/order/async_lock.js +11 -0
  525. package/dist/modules/order/async_lock.js.map +1 -1
  526. package/dist/modules/order/export.d.ts +1 -1
  527. package/dist/modules/order/export.js +10 -10
  528. package/dist/modules/order/export.js.map +1 -1
  529. package/dist/modules/order/format.d.ts +1 -8
  530. package/dist/modules/order/format.d.ts.map +1 -1
  531. package/dist/modules/order/format.js +0 -14
  532. package/dist/modules/order/format.js.map +1 -1
  533. package/dist/modules/order/grid.d.ts +2 -12
  534. package/dist/modules/order/grid.d.ts.map +1 -1
  535. package/dist/modules/order/grid.js +23 -24
  536. package/dist/modules/order/grid.js.map +1 -1
  537. package/dist/modules/order/grid_reconcile.d.ts +1 -1
  538. package/dist/modules/order/grid_reconcile.js +1 -1
  539. package/dist/modules/order/grid_reconcile_internal.js +1 -1
  540. package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
  541. package/dist/modules/order/logger.d.ts +3 -0
  542. package/dist/modules/order/logger.d.ts.map +1 -1
  543. package/dist/modules/order/logger.js +23 -14
  544. package/dist/modules/order/logger.js.map +1 -1
  545. package/dist/modules/order/logger_state.d.ts +5 -22
  546. package/dist/modules/order/logger_state.d.ts.map +1 -1
  547. package/dist/modules/order/logger_state.js +6 -25
  548. package/dist/modules/order/logger_state.js.map +1 -1
  549. package/dist/modules/order/manager.d.ts +1 -4
  550. package/dist/modules/order/manager.d.ts.map +1 -1
  551. package/dist/modules/order/manager.js +34 -33
  552. package/dist/modules/order/manager.js.map +1 -1
  553. package/dist/modules/order/processed_fill_store.d.ts +0 -5
  554. package/dist/modules/order/processed_fill_store.d.ts.map +1 -1
  555. package/dist/modules/order/processed_fill_store.js +10 -15
  556. package/dist/modules/order/processed_fill_store.js.map +1 -1
  557. package/dist/modules/order/strategy.d.ts +6 -4
  558. package/dist/modules/order/strategy.d.ts.map +1 -1
  559. package/dist/modules/order/strategy.js +6 -4
  560. package/dist/modules/order/strategy.js.map +1 -1
  561. package/dist/modules/order/sync_engine.d.ts.map +1 -1
  562. package/dist/modules/order/sync_engine.js +17 -10
  563. package/dist/modules/order/sync_engine.js.map +1 -1
  564. package/dist/modules/order/utils/math.d.ts +7 -1
  565. package/dist/modules/order/utils/math.d.ts.map +1 -1
  566. package/dist/modules/order/utils/math.js +19 -1
  567. package/dist/modules/order/utils/math.js.map +1 -1
  568. package/dist/modules/order/utils/order.d.ts.map +1 -1
  569. package/dist/modules/order/utils/order.js +11 -4
  570. package/dist/modules/order/utils/order.js.map +1 -1
  571. package/dist/modules/order/utils/system.d.ts +3 -8
  572. package/dist/modules/order/utils/system.d.ts.map +1 -1
  573. package/dist/modules/order/utils/system.js +14 -4
  574. package/dist/modules/order/utils/system.js.map +1 -1
  575. package/dist/modules/order/utils/validate.js +1 -1
  576. package/dist/modules/order/utils/validate.js.map +1 -1
  577. package/dist/modules/path_api.js +1 -1
  578. package/dist/modules/path_api.js.map +1 -1
  579. package/dist/modules/paths.d.ts +1 -7
  580. package/dist/modules/paths.d.ts.map +1 -1
  581. package/dist/modules/paths.js +1 -1
  582. package/dist/modules/paths.js.map +1 -1
  583. package/dist/modules/process_discovery.d.ts +3 -0
  584. package/dist/modules/process_discovery.d.ts.map +1 -1
  585. package/dist/modules/process_discovery.js +15 -1
  586. package/dist/modules/process_discovery.js.map +1 -1
  587. package/dist/modules/runtime_settings.js +4 -2
  588. package/dist/modules/runtime_settings.js.map +1 -1
  589. package/dist/modules/settings_merge.d.ts +5 -1
  590. package/dist/modules/settings_merge.d.ts.map +1 -1
  591. package/dist/modules/settings_merge.js +17 -4
  592. package/dist/modules/settings_merge.js.map +1 -1
  593. package/dist/modules/socket_json_client.d.ts.map +1 -1
  594. package/dist/modules/socket_json_client.js +12 -2
  595. package/dist/modules/socket_json_client.js.map +1 -1
  596. package/dist/modules/storage/browser_adapter.d.ts +8 -3
  597. package/dist/modules/storage/browser_adapter.d.ts.map +1 -1
  598. package/dist/modules/storage/browser_adapter.js +58 -7
  599. package/dist/modules/storage/browser_adapter.js.map +1 -1
  600. package/dist/modules/storage/index.d.ts +1 -1
  601. package/dist/modules/storage/index.js +1 -1
  602. package/dist/modules/types.d.ts +1 -1
  603. package/dist/modules/types.d.ts.map +1 -1
  604. package/dist/modules/utils/sanitize_key.d.ts +7 -0
  605. package/dist/modules/utils/sanitize_key.d.ts.map +1 -0
  606. package/dist/modules/utils/sanitize_key.js +15 -0
  607. package/dist/modules/utils/sanitize_key.js.map +1 -0
  608. package/dist/modules/validate_profiles.d.ts.map +1 -1
  609. package/dist/modules/validate_profiles.js +6 -8
  610. package/dist/modules/validate_profiles.js.map +1 -1
  611. package/dist/pm2.d.ts.map +1 -1
  612. package/dist/pm2.js +8 -9
  613. package/dist/pm2.js.map +1 -1
  614. package/dist/scripts/analyze-git.d.ts +1 -1
  615. package/dist/scripts/analyze-git.js +1 -1
  616. package/dist/scripts/analyze-orders.d.ts +2 -2
  617. package/dist/scripts/analyze-orders.d.ts.map +1 -1
  618. package/dist/scripts/analyze-orders.js +39 -28
  619. package/dist/scripts/analyze-orders.js.map +1 -1
  620. package/dist/scripts/diagnose-pool-history.js +1 -1
  621. package/dist/scripts/divergence-calc.d.ts +1 -1
  622. package/dist/scripts/divergence-calc.js +3 -3
  623. package/dist/scripts/native_release_gates.js +4 -2
  624. package/dist/scripts/native_release_gates.js.map +1 -1
  625. package/dist/scripts/print_grid.d.ts +1 -1
  626. package/dist/scripts/print_grid.js +1 -1
  627. package/dist/scripts/run-tests.js +38 -19
  628. package/dist/scripts/run-tests.js.map +1 -1
  629. package/dist/scripts/runner.d.ts +3 -5
  630. package/dist/scripts/runner.d.ts.map +1 -1
  631. package/dist/scripts/runner.js +4 -6
  632. package/dist/scripts/runner.js.map +1 -1
  633. package/dist/scripts/sync-version.d.ts +2 -2
  634. package/dist/scripts/sync-version.js +2 -2
  635. package/dist/scripts/update.d.ts +1 -1
  636. package/dist/scripts/update.js +2 -2
  637. package/dist/scripts/update.js.map +1 -1
  638. package/dist/scripts/validate_bots.d.ts +1 -1
  639. package/dist/scripts/validate_bots.js +1 -1
  640. package/dist/scripts/verify-browser-bundle.d.ts +1 -1
  641. package/dist/scripts/verify-browser-bundle.js +1 -1
  642. package/dist/unlock.js +4 -4
  643. package/dist/unlock.js.map +1 -1
  644. package/docs/BITSHARES_ONBOARDING.md +63 -18
  645. package/docs/COPY_ON_WRITE_MASTER_PLAN.md +14 -23
  646. package/docs/COW_INVARIANTS.md +4 -4
  647. package/docs/CREDENTIAL_SECURITY.md +0 -11
  648. package/docs/DEXBOT_COMPARISON.md +12 -12
  649. package/docs/EVOLUTION.md +17 -43
  650. package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +27 -83
  651. package/docs/GRID_RECALCULATION.md +1 -13
  652. package/docs/GRID_RECONCILE.md +24 -24
  653. package/docs/LIFECYCLE.md +4 -4
  654. package/docs/LOGGING.md +1 -1
  655. package/docs/MPA_CREDIT_USAGE.md +3 -3
  656. package/docs/README.md +2 -2
  657. package/docs/WORKFLOW.md +2 -2
  658. package/docs/architecture.md +48 -43
  659. package/docs/developer_guide.md +22 -24
  660. package/market_adapter/README.md +0 -2
  661. package/modules/README.md +2 -1
  662. package/package.json +22 -14
  663. package/scripts/README.md +34 -8
  664. package/scripts/clean-dist.js +10 -2
  665. package/tests/README.md +4 -3
  666. package/claw/openclaw.plugin.json +0 -13
  667. package/dist/market_adapter/merge_lp_data.d.ts +0 -3
  668. package/dist/market_adapter/merge_lp_data.d.ts.map +0 -1
  669. package/dist/market_adapter/merge_lp_data.js +0 -125
  670. package/dist/market_adapter/merge_lp_data.js.map +0 -1
  671. package/dist/market_adapter/utils/paths.d.ts +0 -3
  672. package/dist/market_adapter/utils/paths.d.ts.map +0 -1
  673. package/dist/market_adapter/utils/paths.js +0 -5
  674. package/dist/market_adapter/utils/paths.js.map +0 -1
@@ -1,37 +1,45 @@
1
+ 'use strict';
2
+
1
3
  const assert = require('assert');
2
- const Module = require('module');
3
4
  const path = require('path');
4
- const { setCachedModule, restoreCachedModule } = require('../../tests/helpers/module_cache_stub');
5
+ const { runEsmMockStages, defineEsmMockAbs } = require('../../tests/helpers/esm_mocks');
6
+
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 */
11
+ }
5
12
 
6
- function clearModule(modulePath: string) {
7
- delete require.cache[modulePath];
13
+ function registerMock(modulePath: string, exports: any) {
14
+ defineEsmMockAbs(modulePath, Object.keys(exports), exports);
8
15
  }
9
16
 
10
17
  async function testClawBitsharesClientNativePathAndConnection() {
18
+ console.log(' bitshares_client native path and connection...');
19
+
11
20
  const clawBitsharesPath = require.resolve('../modules/bitshares_client');
21
+ clearModule(clawBitsharesPath);
12
22
 
13
- try {
14
- clearModule(clawBitsharesPath);
15
- const clawBitshares = require('../modules/bitshares_client');
16
-
17
- assert.strictEqual(clawBitshares.isConnected(), false, 'initial state should not be connected');
18
- assert.strictEqual(typeof clawBitshares.BitShares, 'object', 'BitShares proxy should exist');
19
- assert.strictEqual(typeof clawBitshares.createAccountClient, 'function');
20
- await assert.rejects(() => clawBitshares.createAccountClient('', 'wif'), /accountName is required/);
21
- await assert.rejects(() => clawBitshares.createAccountClient('alice', ''), /privateKey is required/);
22
- } finally {
23
- clearModule(clawBitsharesPath);
24
- }
23
+ const clawBitshares = require('../modules/bitshares_client');
24
+
25
+ assert.strictEqual(clawBitshares.isConnected(), false, 'initial state should not be connected');
26
+ assert.strictEqual(typeof clawBitshares.BitShares, 'object', 'BitShares proxy should exist');
27
+ assert.strictEqual(typeof clawBitshares.createAccountClient, 'function');
28
+ await assert.rejects(() => clawBitshares.createAccountClient('', 'wif'), /accountName is required/);
29
+ await assert.rejects(() => clawBitshares.createAccountClient('alice', ''), /privateKey is required/);
30
+
31
+ console.log(' PASS');
25
32
  }
26
33
 
27
34
  async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
28
- const clawBitsharesPath = require.resolve('../modules/bitshares_client');
35
+ console.log(' bitshares_client waitForConnected lazy connect...');
36
+
29
37
  const nativePath = require.resolve('../../modules/bitshares-native');
30
38
  let connectCalls = 0;
31
39
  let nodes: any[] = [];
32
40
  let connected = false;
33
41
 
34
- const originalNativeEntry = setCachedModule(nativePath, {
42
+ registerMock(nativePath, {
35
43
  createChainClient: ({ onStatusChange }: any) => ({
36
44
  connect: async () => {
37
45
  connectCalls += 1;
@@ -55,24 +63,24 @@ async function testClawBitsharesClientWaitForConnectedTriggersNativeConnect() {
55
63
  subscribe: async () => () => {},
56
64
  unsubscribe: async () => {},
57
65
  }),
58
- } as any);
66
+ });
59
67
 
60
- try {
61
- clearModule(clawBitsharesPath);
62
- const clawBitshares = require('../modules/bitshares_client');
68
+ const clawBitsharesPath = require.resolve('../modules/bitshares_client');
69
+ clearModule(clawBitsharesPath);
70
+ const clawBitshares = require('../modules/bitshares_client');
63
71
 
64
- await clawBitshares.waitForConnected(200);
72
+ await clawBitshares.waitForConnected(200);
65
73
 
66
- assert.strictEqual(connectCalls, 1, 'waitForConnected should initiate a native connect when idle');
67
- assert.strictEqual(clawBitshares.isConnected(), true, 'client should report connected after lazy connect');
68
- assert.ok(Array.isArray(clawBitshares.BitShares.node) && clawBitshares.BitShares.node.length > 0, 'default node list should be populated');
69
- } finally {
70
- clearModule(clawBitsharesPath);
71
- restoreCachedModule(nativePath, originalNativeEntry);
72
- }
74
+ assert.strictEqual(connectCalls, 1, 'waitForConnected should initiate a native connect when idle');
75
+ assert.strictEqual(clawBitshares.isConnected(), true, 'client should report connected after lazy connect');
76
+ assert.ok(Array.isArray(clawBitshares.BitShares.node) && clawBitshares.BitShares.node.length > 0, 'default node list should be populated');
77
+
78
+ console.log(' PASS');
73
79
  }
74
80
 
75
81
  function testClawRootExportsAvoidSilentCollisions() {
82
+ console.log(' claw root exports...');
83
+
76
84
  const clawIndexPath = require.resolve('..');
77
85
  clearModule(clawIndexPath);
78
86
 
@@ -91,42 +99,20 @@ function testClawRootExportsAvoidSilentCollisions() {
91
99
  assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
92
100
  assert.strictEqual(openclawManifest.options.runtimeName, 'openclaw');
93
101
  assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
94
- assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
102
+ assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
95
103
  assert.strictEqual(openfangManifest.options.runtimeName, 'openfang');
96
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
104
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
97
105
  assert.strictEqual(nullManifest.options.runtimeName, 'nullclaw');
98
- assert.strictEqual(nullManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
106
+ assert.strictEqual(nullManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
99
107
  assert.strictEqual(manifest.options.runtimeName, 'zeroclaw');
100
- assert.strictEqual(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
101
- }
102
-
103
- function testClawCommandInjectsRuntimeNameViaOption() {
104
- const clawBridgePath = require.resolve('../modules/claw_bridge');
105
- const clawInfraPath = require.resolve('../modules/claw_infra');
106
-
107
- let capturedOptions: any = null;
108
- const originalClawInfra = setCachedModule(clawInfraPath, {
109
- createClawInfrastructure: (opts: any) => {
110
- capturedOptions = opts;
111
- return {
112
- runtime: { name: opts.runtime?.name || 'claw-bridge', accountName: null },
113
- profiles: {},
114
- market: {}
115
- };
116
- }
117
- } as any);
118
-
119
- clearModule(clawBridgePath);
120
- const { runClawCommand } = require('../modules/claw_bridge');
108
+ assert.strictEqual(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
121
109
 
122
- runClawCommand('runtime', { runtimeName: 'openfang' });
123
- assert.strictEqual(capturedOptions.runtime.name, 'openfang', 'runtimeName option should propagate to runtime.name');
124
-
125
- clearModule(clawBridgePath);
126
- restoreCachedModule(clawInfraPath, originalClawInfra);
110
+ console.log(' PASS');
127
111
  }
128
112
 
129
113
  function testRuntimeSkillTomlQuotesPayloadPlaceholders() {
114
+ console.log(' runtime skill toml quoting...');
115
+
130
116
  const { buildRuntimeSkillToml } = require('../modules/claw_skill_md');
131
117
 
132
118
  const toml = buildRuntimeSkillToml(
@@ -143,9 +129,13 @@ function testRuntimeSkillTomlQuotesPayloadPlaceholders() {
143
129
  toml.includes("'--profile-root' '/tmp/profile root'"),
144
130
  'generated skill commands must shell-quote profile roots with spaces'
145
131
  );
132
+
133
+ console.log(' PASS');
146
134
  }
147
135
 
148
136
  function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
137
+ console.log(' liquidity_pools shared client injection...');
138
+
149
139
  const bitsharesPath = require.resolve('../modules/bitshares_client');
150
140
  const dexbotBridgePath = require.resolve('../modules/dexbot_bridge');
151
141
  const liquidityPoolsPath = require.resolve('../modules/liquidity_pools');
@@ -153,8 +143,8 @@ function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
153
143
  let capturedPoolArgs = null;
154
144
  let capturedPriceArgs = null;
155
145
 
156
- const originalBitshares = setCachedModule(bitsharesPath, { BitShares: sharedBitShares } as any);
157
- const originalDexbotBridge = setCachedModule(dexbotBridgePath, {
146
+ registerMock(bitsharesPath, { BitShares: sharedBitShares } as any);
147
+ registerMock(dexbotBridgePath, {
158
148
  getDexbot2Root: () => '/tmp',
159
149
  loadDexbotOrderSystemUtils: () => ({
160
150
  cloneMap: (value: any) => value,
@@ -190,12 +180,12 @@ function testLiquidityPoolWrapperInjectsSharedBitSharesClient() {
190
180
  'derivePrice wrapper must inject the shared BitShares client'
191
181
  );
192
182
 
193
- clearModule(liquidityPoolsPath);
194
- restoreCachedModule(dexbotBridgePath, originalDexbotBridge);
195
- restoreCachedModule(bitsharesPath, originalBitshares);
183
+ console.log(' PASS');
196
184
  }
197
185
 
198
186
  async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
187
+ console.log(' decision_loop analyzer state reuse...');
188
+
199
189
  const decisionLoopPath = require.resolve('../modules/decision_loop');
200
190
  const discoveryPath = require.resolve('../modules/position_discovery');
201
191
  const healthPath = require.resolve('../modules/position_health');
@@ -230,20 +220,20 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
230
220
  }
231
221
  }
232
222
 
233
- const originalDiscovery = setCachedModule(discoveryPath, {
223
+ registerMock(discoveryPath, {
234
224
  discoverPositions: async () => ([
235
225
  { id: 'pos-1', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 5 } },
236
226
  { id: 'pos-2', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 3 } }
237
227
  ])
238
228
  } as any);
239
- const originalHealth = setCachedModule(healthPath, {
229
+ registerMock(healthPath, {
240
230
  assessPosition: (position: any, trendSignal: any) => ({
241
231
  actions: [],
242
232
  positionId: position.id,
243
233
  trend: trendSignal
244
234
  })
245
235
  } as any);
246
- const originalFeedPriceSource = setCachedModule(feedPriceSourcePath, {
236
+ registerMock(feedPriceSourcePath, {
247
237
  fetchTrendInput: async () => {
248
238
  trendFetchCount += 1;
249
239
  return {
@@ -253,7 +243,7 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
253
243
  };
254
244
  }
255
245
  } as any);
256
- const originalTrendAnalyzer = setCachedModule(trendAnalyzerPath, { KalmanTrendAnalyzer: FakeTrendAnalyzer } as any);
246
+ registerMock(trendAnalyzerPath, { KalmanTrendAnalyzer: FakeTrendAnalyzer } as any);
257
247
  clearModule(decisionLoopPath);
258
248
 
259
249
  const { evaluate, resetAnalyzers } = require('../modules/decision_loop');
@@ -266,14 +256,13 @@ async function testDecisionLoopReusesAnalyzerStateForDuplicateMarkets() {
266
256
  assert.strictEqual(result.positions[1].trend.premium, -5, 'reused trend signal should come from cached analyzer state');
267
257
 
268
258
  resetAnalyzers();
269
- clearModule(decisionLoopPath);
270
- restoreCachedModule(trendAnalyzerPath, originalTrendAnalyzer);
271
- restoreCachedModule(feedPriceSourcePath, originalFeedPriceSource);
272
- restoreCachedModule(healthPath, originalHealth);
273
- restoreCachedModule(discoveryPath, originalDiscovery);
259
+
260
+ console.log(' PASS');
274
261
  }
275
262
 
276
263
  async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
264
+ console.log(' decision_loop analyzer config replacement...');
265
+
277
266
  const decisionLoopPath = require.resolve('../modules/decision_loop');
278
267
  const discoveryPath = require.resolve('../modules/position_discovery');
279
268
  const healthPath = require.resolve('../modules/position_health');
@@ -297,18 +286,18 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
297
286
  }
298
287
  }
299
288
 
300
- const originalDiscovery = setCachedModule(discoveryPath, {
289
+ registerMock(discoveryPath, {
301
290
  discoverPositions: async () => ([
302
291
  { id: 'pos-1', market: 'HONEST.USD/BTS', mpaSymbol: 'HONEST.USD', onChain: { debtAmount: 5 } }
303
292
  ])
304
293
  } as any);
305
- const originalHealth = setCachedModule(healthPath, {
294
+ registerMock(healthPath, {
306
295
  assessPosition: (position: any, trendSignal: any) => ({ actions: [], positionId: position.id, trend: trendSignal })
307
296
  } as any);
308
- const originalFeedPriceSource = setCachedModule(feedPriceSourcePath, {
297
+ registerMock(feedPriceSourcePath, {
309
298
  fetchTrendInput: async () => ({ feedPrice: 100, marketPrice: 95, premium: -5 })
310
299
  } as any);
311
- const originalTrendAnalyzer = setCachedModule(trendAnalyzerPath, { KalmanTrendAnalyzer: ConfigTrackingAnalyzer } as any);
300
+ registerMock(trendAnalyzerPath, { KalmanTrendAnalyzer: ConfigTrackingAnalyzer } as any);
312
301
  clearModule(decisionLoopPath);
313
302
 
314
303
  const { evaluate, resetAnalyzers } = require('../modules/decision_loop');
@@ -323,18 +312,50 @@ async function testDecisionLoopReplacesAnalyzerOnConfigChange() {
323
312
  assert.strictEqual(constructionCount, 2, 'changed config should replace the analyzer');
324
313
 
325
314
  resetAnalyzers();
326
- clearModule(decisionLoopPath);
327
- restoreCachedModule(trendAnalyzerPath, originalTrendAnalyzer);
328
- restoreCachedModule(feedPriceSourcePath, originalFeedPriceSource);
329
- restoreCachedModule(healthPath, originalHealth);
330
- restoreCachedModule(discoveryPath, originalDiscovery);
315
+
316
+ console.log(' PASS');
331
317
  }
332
318
 
333
319
  async function testPositionManagerEntryExposesSellPriceInBts() {
320
+ console.log(' position_manager entry sellPriceInBts...');
321
+
334
322
  const positionManagerPath = require.resolve('../modules/position_manager');
335
323
  const mpaUtilsPath = require.resolve('../modules/mpa_utils');
336
324
 
337
- const originalMpaUtils = setCachedModule(mpaUtilsPath, {
325
+ // ESM hooks turn mock keys into synthetic named re-exports, so every name
326
+ // position_manager statically imports from mpa_utils must exist here. The
327
+ // two helpers beside requireBtsBackedMpa are minimal inline replicas of the
328
+ // real ones (requiring the real module would bypass the mock and poison
329
+ // the module cache with the real instance).
330
+ const blockchainToFloat = (amount: any, precision: any) => Number(amount) / (10 ** precision);
331
+ const computeBtsPerMpa = (settlementPrice: any, mpaAsset: any, backingAsset: any) => {
332
+ const base = settlementPrice?.base;
333
+ const quote = settlementPrice?.quote;
334
+ if (!base || !quote) return null;
335
+ const baseAmount = blockchainToFloat(base.amount, base.asset_id === mpaAsset.id ? mpaAsset.precision : backingAsset.precision);
336
+ const quoteAmount = blockchainToFloat(quote.amount, quote.asset_id === mpaAsset.id ? mpaAsset.precision : backingAsset.precision);
337
+ if (!baseAmount || !quoteAmount) return null;
338
+ if (base.asset_id === backingAsset.id && quote.asset_id === mpaAsset.id) return baseAmount / quoteAmount;
339
+ if (base.asset_id === mpaAsset.id && quote.asset_id === backingAsset.id) return quoteAmount / baseAmount;
340
+ return null;
341
+ };
342
+
343
+ registerMock(mpaUtilsPath, {
344
+ computeCallOrderAmounts: (callOrder: any, mpaAsset: any, backingAsset: any, bitassetData: any) => {
345
+ const debtAmount = blockchainToFloat(callOrder.debt, mpaAsset.precision);
346
+ const collateralAmount = blockchainToFloat(callOrder.collateral, backingAsset.precision);
347
+ const btsPerMpa = computeBtsPerMpa(bitassetData?.current_feed?.settlement_price, mpaAsset, backingAsset);
348
+ const debtValueInBts = debtAmount && btsPerMpa ? debtAmount * btsPerMpa : 0;
349
+ const collateralRatio = debtValueInBts > 0 ? collateralAmount / debtValueInBts : null;
350
+ return {
351
+ btsPerMpa,
352
+ collateralAmount: collateralAmount || 0,
353
+ collateralRatio,
354
+ debtAmount: debtAmount || 0,
355
+ debtValueInBts
356
+ };
357
+ },
358
+ getBlockchainToFloat: () => blockchainToFloat,
338
359
  requireBtsBackedMpa: async (sym: string) => ({
339
360
  backingAsset: { id: '1.3.0', symbol: 'BTS', precision: 5 },
340
361
  mpaAsset: { id: `1.3.${sym.length}`, symbol: sym, precision: 5, bitasset_data_id: '2.4.1' }
@@ -361,16 +382,17 @@ async function testPositionManagerEntryExposesSellPriceInBts() {
361
382
  assert.strictEqual(position.entry.sellPriceInBts, 1000, 'entry must expose sellPriceInBts for openShort');
362
383
  assert.strictEqual(position.entry.priceInBts, 1000, 'entry must also have generic priceInBts from createOrderTracking');
363
384
 
364
- clearModule(positionManagerPath);
365
- restoreCachedModule(mpaUtilsPath, originalMpaUtils);
385
+ console.log(' PASS');
366
386
  }
367
387
 
368
388
  function testClawBridgeRespectsRuntimeNameOption() {
389
+ console.log(' claw_bridge runtime name option...');
390
+
369
391
  const clawBridgePath = require.resolve('../modules/claw_bridge');
370
392
  const clawInfraPath = require.resolve('../modules/claw_infra');
371
393
 
372
394
  let capturedOptions: any = null;
373
- const originalClawInfra = setCachedModule(clawInfraPath, {
395
+ registerMock(clawInfraPath, {
374
396
  createClawInfrastructure: (opts: any) => {
375
397
  capturedOptions = opts;
376
398
  return {
@@ -393,11 +415,12 @@ function testClawBridgeRespectsRuntimeNameOption() {
393
415
  createClawBridge({});
394
416
  assert.strictEqual(capturedOptions.runtime.name, 'claw-bridge', 'should fall back to claw-bridge');
395
417
 
396
- clearModule(clawBridgePath);
397
- restoreCachedModule(clawInfraPath, originalClawInfra);
418
+ console.log(' PASS');
398
419
  }
399
420
 
400
421
  function testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors() {
422
+ console.log(' claw_bridge script manifest descriptors...');
423
+
401
424
  const scriptPath = require.resolve('../scripts/claw_bridge');
402
425
  clearModule(scriptPath);
403
426
 
@@ -405,48 +428,50 @@ function testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors() {
405
428
 
406
429
  const hermesManifest = describeRuntimeManifest('hermes', {});
407
430
  assert.strictEqual(hermesManifest.compatibility.name, 'Hermes');
408
- assert.strictEqual(hermesManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
431
+ assert.strictEqual(hermesManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
409
432
 
410
433
  const openclawManifest = describeRuntimeManifest('openclaw', {});
411
434
  assert.strictEqual(openclawManifest.compatibility.name, 'OpenClaw');
412
- assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
435
+ assert.strictEqual(openclawManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
413
436
 
414
437
  const openfangManifest = describeRuntimeManifest('openfang', {});
415
438
  assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
416
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
439
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
417
440
 
418
441
  const nanoclawManifest = describeRuntimeManifest('nanoclaw', {});
419
442
  assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
420
- assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
443
+ assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
421
444
 
422
445
  const nullclawManifest = describeRuntimeManifest('nullclaw', {});
423
446
  assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
424
- assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
447
+ assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
425
448
 
426
449
  const zeroclawManifest = describeRuntimeManifest('zeroclaw', {});
427
450
  assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
428
- assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
451
+ assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
429
452
 
430
453
  const genericManifest = describeRuntimeManifest(null, {});
431
454
  assert.strictEqual(genericManifest.compatibility.name, 'Claw');
432
- assert.strictEqual(genericManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
455
+ assert.strictEqual(genericManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
433
456
 
434
457
  const payloadSelectedManifest = describeRuntimeManifest(null, { runtimeName: 'openfang' });
435
458
  assert.strictEqual(payloadSelectedManifest.compatibility.name, 'OpenFang');
436
- assert.strictEqual(payloadSelectedManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
459
+ assert.strictEqual(payloadSelectedManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
437
460
 
438
461
  const normalizedPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' OpenFang ' });
439
462
  assert.strictEqual(normalizedPayloadManifest.compatibility.name, 'OpenFang');
440
- assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
463
+ assert.strictEqual(normalizedPayloadManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
441
464
 
442
465
  const hermesPayloadManifest = describeRuntimeManifest(null, { runtimeName: ' Hermes ' });
443
466
  assert.strictEqual(hermesPayloadManifest.compatibility.name, 'Hermes');
444
- assert.strictEqual(hermesPayloadManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.ts')), true);
467
+ assert.strictEqual(hermesPayloadManifest.commandExamples.some((example: any) => example.includes('scripts/claw_bridge.js')), true);
445
468
 
446
- clearModule(scriptPath);
469
+ console.log(' PASS');
447
470
  }
448
471
 
449
472
  async function testRuntimeCommandManifestUsesRuntimeSpecificDescriptors() {
473
+ console.log(' runClawCommand manifest descriptors...');
474
+
450
475
  const { runClawCommand } = require('../modules/claw_bridge');
451
476
 
452
477
  const hermesManifest = await runClawCommand('manifest', { runtimeName: 'hermes' });
@@ -456,22 +481,53 @@ async function testRuntimeCommandManifestUsesRuntimeSpecificDescriptors() {
456
481
 
457
482
  const openfangManifest = await runClawCommand('manifest', { runtimeName: 'openfang' });
458
483
  assert.strictEqual(openfangManifest.compatibility.name, 'OpenFang');
459
- assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
484
+ assert.strictEqual(openfangManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
460
485
 
461
486
  const nanoclawManifest = await runClawCommand('manifest', { runtimeName: 'nanoclaw' });
462
487
  assert.strictEqual(nanoclawManifest.compatibility.name, 'NanoClaw');
463
- assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
488
+ assert.strictEqual(nanoclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
464
489
 
465
490
  const nullclawManifest = await runClawCommand('manifest', { runtimeName: 'nullclaw' });
466
491
  assert.strictEqual(nullclawManifest.compatibility.name, 'NullClaw');
467
- assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
492
+ assert.strictEqual(nullclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
468
493
 
469
494
  const zeroclawManifest = await runClawCommand('manifest', { runtimeName: 'zeroclaw' });
470
495
  assert.strictEqual(zeroclawManifest.compatibility.name, 'ZeroClaw');
471
- assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')), true);
496
+ assert.strictEqual(zeroclawManifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')), true);
497
+
498
+ console.log(' PASS');
499
+ }
500
+
501
+ function testClawCommandInjectsRuntimeNameViaOption() {
502
+ console.log(' runClawCommand runtime name injection...');
503
+
504
+ const clawBridgePath = require.resolve('../modules/claw_bridge');
505
+ const clawInfraPath = require.resolve('../modules/claw_infra');
506
+
507
+ let capturedOptions: any = null;
508
+ registerMock(clawInfraPath, {
509
+ createClawInfrastructure: (opts: any) => {
510
+ capturedOptions = opts;
511
+ return {
512
+ runtime: { name: opts.runtime?.name || 'claw-bridge', accountName: null },
513
+ profiles: {},
514
+ market: {}
515
+ };
516
+ }
517
+ } as any);
518
+
519
+ clearModule(clawBridgePath);
520
+ const { runClawCommand } = require('../modules/claw_bridge');
521
+
522
+ runClawCommand('runtime', { runtimeName: 'openfang' });
523
+ assert.strictEqual(capturedOptions.runtime.name, 'openfang', 'runtimeName option should propagate to runtime.name');
524
+
525
+ console.log(' PASS');
472
526
  }
473
527
 
474
528
  function testAccountOrdersBotKeyFallsBackToAssetIds() {
529
+ console.log(' account_orders botKey fallback...');
530
+
475
531
  const { createBotKey } = require('../../modules/account_orders');
476
532
 
477
533
  const idOnlyBot = { assetAId: '1.3.1', assetBId: '1.3.0' };
@@ -489,11 +545,13 @@ function testAccountOrdersBotKeyFallsBackToAssetIds() {
489
545
  const clawProfiles = require('../modules/dexbot_profiles');
490
546
  const clawKey = clawProfiles.createBotKey(idOnlyBot, 0);
491
547
  assert.strictEqual(key, clawKey, `account_orders and claw botKey must match for same input, got: ${key} vs ${clawKey}`);
492
- }
493
-
494
548
 
549
+ console.log(' PASS');
550
+ }
495
551
 
496
552
  function testBuildQueryScopesAnyPoolByReceivedAsset() {
553
+ console.log(' kibana query pool scoping...');
554
+
497
555
  const { buildDirectionalDocumentQuery } = require('../../market_adapter/core/kibana_candles');
498
556
  const fieldMap = {
499
557
  soldAssetField: 'operation_history.op_object.amount_to_sell.asset_id.keyword',
@@ -540,10 +598,17 @@ function testBuildQueryScopesAnyPoolByReceivedAsset() {
540
598
  pairFilters.some((f: any) => f.term?.['operation_history.op_object.min_to_receive.asset_id.keyword'] === '1.3.1'),
541
599
  'any-pool query should filter by received asset ID'
542
600
  );
601
+
602
+ console.log(' PASS');
543
603
  }
544
604
 
545
605
  function testClawDefaultDataPathsStayInsideClawFolder() {
546
- const clawDataDir = path.join(__dirname, '..', 'data');
606
+ console.log(' claw default data paths...');
607
+
608
+ // modules/paths.ts resolveClawDirs keeps claw state inside the repo's
609
+ // claw/ folder regardless of where the code runs from (dist or source),
610
+ // so anchor expectations to that folder rather than to this test file.
611
+ const clawDataDir = path.join(__dirname, '..', '..', '..', 'claw', 'data');
547
612
  const clawStateDir = path.join(clawDataDir, 'state');
548
613
  const clawInfra = require('../modules/claw_infra');
549
614
  const { DEFAULT_STATE_PATH } = require('../modules/position_manager');
@@ -558,28 +623,89 @@ function testClawDefaultDataPathsStayInsideClawFolder() {
558
623
 
559
624
  const stateStore = clawInfra.createStateStore();
560
625
  assert.strictEqual(stateStore.filePath, path.join(clawStateDir, 'claw-state.json'));
561
- }
562
626
 
563
- async function main() {
564
- await testClawBitsharesClientNativePathAndConnection();
565
- await testClawBitsharesClientWaitForConnectedTriggersNativeConnect();
566
- testClawRootExportsAvoidSilentCollisions();
567
- testRuntimeSkillTomlQuotesPayloadPlaceholders();
568
- testLiquidityPoolWrapperInjectsSharedBitSharesClient();
569
- await testDecisionLoopReusesAnalyzerStateForDuplicateMarkets();
570
- await testDecisionLoopReplacesAnalyzerOnConfigChange();
571
- await testPositionManagerEntryExposesSellPriceInBts();
572
- testClawBridgeRespectsRuntimeNameOption();
573
- testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors();
574
- await testRuntimeCommandManifestUsesRuntimeSpecificDescriptors();
575
- testClawCommandInjectsRuntimeNameViaOption();
576
- testAccountOrdersBotKeyFallsBackToAssetIds();
577
- testBuildQueryScopesAnyPoolByReceivedAsset();
578
- testClawDefaultDataPathsStayInsideClawFolder();
579
- console.log('claw regression tests passed');
627
+ console.log(' PASS');
580
628
  }
581
629
 
582
- main().catch((error) => {
583
- console.error(error);
584
- process.exit(1);
585
- });
630
+ runEsmMockStages(
631
+ [
632
+ 'native-path',
633
+ 'wait-connected',
634
+ 'root-exports',
635
+ 'skill-toml',
636
+ 'liquidity-pools',
637
+ 'analyzer-reuse',
638
+ 'analyzer-replace',
639
+ 'position-manager',
640
+ 'bridge-runtime-name',
641
+ 'script-manifest',
642
+ 'runtime-manifest',
643
+ 'command-runtime-name',
644
+ 'account-orders-bot-key',
645
+ 'kibana-query-scopes',
646
+ 'default-data-paths'
647
+ ],
648
+ async (stage: string) => {
649
+ if (stage === 'native-path') {
650
+ await testClawBitsharesClientNativePathAndConnection();
651
+ return;
652
+ }
653
+ if (stage === 'wait-connected') {
654
+ await testClawBitsharesClientWaitForConnectedTriggersNativeConnect();
655
+ return;
656
+ }
657
+ if (stage === 'root-exports') {
658
+ testClawRootExportsAvoidSilentCollisions();
659
+ return;
660
+ }
661
+ if (stage === 'skill-toml') {
662
+ testRuntimeSkillTomlQuotesPayloadPlaceholders();
663
+ return;
664
+ }
665
+ if (stage === 'liquidity-pools') {
666
+ testLiquidityPoolWrapperInjectsSharedBitSharesClient();
667
+ return;
668
+ }
669
+ if (stage === 'analyzer-reuse') {
670
+ await testDecisionLoopReusesAnalyzerStateForDuplicateMarkets();
671
+ return;
672
+ }
673
+ if (stage === 'analyzer-replace') {
674
+ await testDecisionLoopReplacesAnalyzerOnConfigChange();
675
+ return;
676
+ }
677
+ if (stage === 'position-manager') {
678
+ await testPositionManagerEntryExposesSellPriceInBts();
679
+ return;
680
+ }
681
+ if (stage === 'bridge-runtime-name') {
682
+ testClawBridgeRespectsRuntimeNameOption();
683
+ return;
684
+ }
685
+ if (stage === 'script-manifest') {
686
+ testClawBridgeScriptManifestUsesRuntimeSpecificDescriptors();
687
+ return;
688
+ }
689
+ if (stage === 'runtime-manifest') {
690
+ await testRuntimeCommandManifestUsesRuntimeSpecificDescriptors();
691
+ return;
692
+ }
693
+ if (stage === 'command-runtime-name') {
694
+ testClawCommandInjectsRuntimeNameViaOption();
695
+ return;
696
+ }
697
+ if (stage === 'account-orders-bot-key') {
698
+ testAccountOrdersBotKeyFallsBackToAssetIds();
699
+ return;
700
+ }
701
+ if (stage === 'kibana-query-scopes') {
702
+ testBuildQueryScopesAnyPoolByReceivedAsset();
703
+ return;
704
+ }
705
+ if (stage === 'default-data-paths') {
706
+ testClawDefaultDataPathsStayInsideClawFolder();
707
+ return;
708
+ }
709
+ throw new Error(`Unknown stage: ${stage}`);
710
+ }
711
+ );
@@ -66,7 +66,7 @@ async function testRuntimeSkillToml() {
66
66
  assert.ok(toml.includes('name = "bitshares-claw"'));
67
67
  const displayName = runtimeName.charAt(0).toUpperCase() + runtimeName.slice(1);
68
68
  assert.ok(toml.includes(`${displayName} bridge to the AI-Bot / DEXBot2 BitShares layer`));
69
- assert.ok(toml.includes('claw_bridge.ts'));
69
+ assert.ok(toml.includes('claw_bridge.js'));
70
70
  assert.ok(toml.includes('--profile-root'));
71
71
  assert.ok(toml.includes('[[tools]]'));
72
72
 
@@ -27,7 +27,7 @@ async function main() {
27
27
  assert.ok(skillText.includes('name = "bitshares-claw"'));
28
28
  assert.ok(skillText.includes('NullClaw bridge to the AI-Bot / DEXBot2 BitShares layer'));
29
29
  assert.ok(skillText.includes('nullclaw'));
30
- assert.ok(skillText.includes('claw_bridge.ts'));
30
+ assert.ok(skillText.includes('claw_bridge.js'));
31
31
 
32
32
  const bridge = createClawBridge({
33
33
  runtime: {
@@ -42,7 +42,7 @@ async function main() {
42
42
  assert.strictEqual(manifest.options.runtimeName, 'nullclaw');
43
43
  assert.strictEqual(manifest.options.profileRoot, dexbotRoot);
44
44
  assert.strictEqual(manifest.compatibility.recommendedTransport, 'skill-toml-or-mcp');
45
- assert.ok(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.ts')));
45
+ assert.ok(manifest.commandExamples.some((example: any) => example.includes('claw_bridge.js')));
46
46
  assert.ok(Array.isArray(manifest.tools.catalog));
47
47
  assert.strictEqual(runtime.name, 'nullclaw');
48
48
  assert.strictEqual(runtime.profileRoot, dexbotRoot);
@@ -55,4 +55,3 @@ main().catch((err) => {
55
55
  console.error(err && err.stack ? err.stack : getErrorMessage(err));
56
56
  process.exit(1);
57
57
  });
58
- export {};