dexbot 1.1.10
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.
- package/LICENSE +21 -0
- package/README.md +287 -0
- package/claw/README.md +513 -0
- package/claw/scripts/memu_runner.py +385 -0
- package/claw/skills/bitshares-guide/SKILL.md +14 -0
- package/claw/skills/bitshares-guide/references/example-skill-shells.md +18 -0
- package/claw/skills/bitshares-guide/references/presentation-patterns.md +19 -0
- package/claw/skills/bitshares-guide/references/scope-guardrails.md +9 -0
- package/claw/skills/launcher-ops/SKILL.md +18 -0
- package/claw/skills/launcher-ops/references/launcher-workflow.md +23 -0
- package/claw/skills/margin-trading/SKILL.md +23 -0
- package/claw/skills/margin-trading/references/honest-asset-list.md +74 -0
- package/claw/skills/margin-trading/references/honest-assets.md +44 -0
- package/claw/skills/margin-trading/references/position-management.md +203 -0
- package/claw/skills/margin-trading/references/trading-concepts.md +80 -0
- package/claw/skills/memu-memory/SKILL.md +218 -0
- package/claw/skills/shared/references/js-automation-overview.md +24 -0
- package/claw/skills/shared/references/safety-and-staleness.md +11 -0
- package/claw/skills/shared/references/skill-boundaries.md +17 -0
- package/claw/skills/trend-detection/SKILL.md +33 -0
- package/claw/skills/trend-detection/agents/openai.yaml +3 -0
- package/claw/skills/trend-detection/references/service.md +45 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +149 -0
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts +3 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +387 -0
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts +3 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +200 -0
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts +3 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +212 -0
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +31 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +249 -0
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts +2 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +1 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +782 -0
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +1 -0
- package/dist/analysis/analyze_derivatives.d.ts +95 -0
- package/dist/analysis/analyze_derivatives.d.ts.map +1 -0
- package/dist/analysis/analyze_derivatives.js +295 -0
- package/dist/analysis/analyze_derivatives.js.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts +14 -0
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +1 -0
- package/dist/analysis/analyze_dynamic_weight.js +208 -0
- package/dist/analysis/analyze_dynamic_weight.js.map +1 -0
- package/dist/analysis/analyze_kalman.d.ts +13 -0
- package/dist/analysis/analyze_kalman.d.ts.map +1 -0
- package/dist/analysis/analyze_kalman.js +123 -0
- package/dist/analysis/analyze_kalman.js.map +1 -0
- package/dist/analysis/analyze_regime.d.ts +20 -0
- package/dist/analysis/analyze_regime.d.ts.map +1 -0
- package/dist/analysis/analyze_regime.js +139 -0
- package/dist/analysis/analyze_regime.js.map +1 -0
- package/dist/analysis/analyze_regime_windows.d.ts +19 -0
- package/dist/analysis/analyze_regime_windows.d.ts.map +1 -0
- package/dist/analysis/analyze_regime_windows.js +413 -0
- package/dist/analysis/analyze_regime_windows.js.map +1 -0
- package/dist/analysis/analyze_risk_profile.d.ts +3 -0
- package/dist/analysis/analyze_risk_profile.d.ts.map +1 -0
- package/dist/analysis/analyze_risk_profile.js +159 -0
- package/dist/analysis/analyze_risk_profile.js.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts +3 -0
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +1 -0
- package/dist/analysis/analyze_trade_heatmap.js +367 -0
- package/dist/analysis/analyze_trade_heatmap.js.map +1 -0
- package/dist/analysis/analyze_volatility.d.ts +22 -0
- package/dist/analysis/analyze_volatility.d.ts.map +1 -0
- package/dist/analysis/analyze_volatility.js +172 -0
- package/dist/analysis/analyze_volatility.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +99 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +804 -0
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +2 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +347 -0
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts +15 -0
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +1 -0
- package/dist/analysis/bot_fitting/shared_utils.js +48 -0
- package/dist/analysis/bot_fitting/shared_utils.js.map +1 -0
- package/dist/analysis/bot_key_utils.d.ts +16 -0
- package/dist/analysis/bot_key_utils.d.ts.map +1 -0
- package/dist/analysis/bot_key_utils.js +61 -0
- package/dist/analysis/bot_key_utils.js.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts +3 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +1 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js +498 -0
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +546 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +1 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js +427 -0
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +1 -0
- package/dist/analysis/chart_utils.d.ts +13 -0
- package/dist/analysis/chart_utils.d.ts.map +1 -0
- package/dist/analysis/chart_utils.js +142 -0
- package/dist/analysis/chart_utils.js.map +1 -0
- package/dist/analysis/derivative_chart_generator.d.ts +18 -0
- package/dist/analysis/derivative_chart_generator.d.ts.map +1 -0
- package/dist/analysis/derivative_chart_generator.js +896 -0
- package/dist/analysis/derivative_chart_generator.js.map +1 -0
- package/dist/analysis/math_utils.d.ts +35 -0
- package/dist/analysis/math_utils.d.ts.map +1 -0
- package/dist/analysis/math_utils.js +121 -0
- package/dist/analysis/math_utils.js.map +1 -0
- package/dist/analysis/price_sources.d.ts +34 -0
- package/dist/analysis/price_sources.d.ts.map +1 -0
- package/dist/analysis/price_sources.js +103 -0
- package/dist/analysis/price_sources.js.map +1 -0
- package/dist/analysis/trade_profitability.d.ts +115 -0
- package/dist/analysis/trade_profitability.d.ts.map +1 -0
- package/dist/analysis/trade_profitability.js +1247 -0
- package/dist/analysis/trade_profitability.js.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +38 -0
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +1 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +212 -0
- package/dist/analysis/tradingview/analyze_tradingview.js.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +9 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +1717 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts +250 -0
- package/dist/analysis/trend_detection/derivative_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js +903 -0
- package/dist/analysis/trend_detection/derivative_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +1449 -0
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts +42 -0
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js +159 -0
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js +408 -0
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts +103 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +229 -0
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts +34 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +89 -0
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts +39 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +1 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +132 -0
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js +345 -0
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +130 -0
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +2 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +1 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +38 -0
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +6 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +1 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js +732 -0
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +1 -0
- package/dist/bot.d.ts +49 -0
- package/dist/bot.d.ts.map +1 -0
- package/dist/bot.js +221 -0
- package/dist/bot.js.map +1 -0
- package/dist/credential-daemon.d.ts +64 -0
- package/dist/credential-daemon.d.ts.map +1 -0
- package/dist/credential-daemon.js +987 -0
- package/dist/credential-daemon.js.map +1 -0
- package/dist/dexbot.d.ts +87 -0
- package/dist/dexbot.d.ts.map +1 -0
- package/dist/dexbot.js +1222 -0
- package/dist/dexbot.js.map +1 -0
- package/dist/market_adapter/ama_signal_runner.d.ts +3 -0
- package/dist/market_adapter/ama_signal_runner.d.ts.map +1 -0
- package/dist/market_adapter/ama_signal_runner.js +175 -0
- package/dist/market_adapter/ama_signal_runner.js.map +1 -0
- package/dist/market_adapter/candle_utils.d.ts +57 -0
- package/dist/market_adapter/candle_utils.d.ts.map +1 -0
- package/dist/market_adapter/candle_utils.js +252 -0
- package/dist/market_adapter/candle_utils.js.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +20 -0
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +1 -0
- package/dist/market_adapter/core/asymmetric_bounds.js +88 -0
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -0
- package/dist/market_adapter/core/config_normalizers.d.ts +10 -0
- package/dist/market_adapter/core/config_normalizers.d.ts.map +1 -0
- package/dist/market_adapter/core/config_normalizers.js +24 -0
- package/dist/market_adapter/core/config_normalizers.js.map +1 -0
- package/dist/market_adapter/core/kibana_candles.d.ts +74 -0
- package/dist/market_adapter/core/kibana_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_candles.js +249 -0
- package/dist/market_adapter/core/kibana_candles.js.map +1 -0
- package/dist/market_adapter/core/kibana_client.d.ts +27 -0
- package/dist/market_adapter/core/kibana_client.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_client.js +120 -0
- package/dist/market_adapter/core/kibana_client.js.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts +143 -0
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +1 -0
- package/dist/market_adapter/core/kibana_market_candles.js +170 -0
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts +210 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -0
- package/dist/market_adapter/core/market_adapter_service.js +2328 -0
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama.d.ts +2 -0
- package/dist/market_adapter/core/strategies/ama.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama.js +138 -0
- package/dist/market_adapter/core/strategies/ama.js.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +50 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js +143 -0
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +12 -0
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js +47 -0
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +32 -0
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js +68 -0
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +66 -0
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +1 -0
- package/dist/market_adapter/core/strategies/regime_gate.js +189 -0
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -0
- package/dist/market_adapter/index.d.ts +10 -0
- package/dist/market_adapter/index.d.ts.map +1 -0
- package/dist/market_adapter/index.js +71 -0
- package/dist/market_adapter/index.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts +3 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +1165 -0
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +54 -0
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js +743 -0
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts +68 -0
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +1 -0
- package/dist/market_adapter/inputs/kibana_source.js +143 -0
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -0
- package/dist/market_adapter/interval_utils.d.ts +6 -0
- package/dist/market_adapter/interval_utils.d.ts.map +1 -0
- package/dist/market_adapter/interval_utils.js +14 -0
- package/dist/market_adapter/interval_utils.js.map +1 -0
- package/dist/market_adapter/log_format.d.ts +16 -0
- package/dist/market_adapter/log_format.d.ts.map +1 -0
- package/dist/market_adapter/log_format.js +72 -0
- package/dist/market_adapter/log_format.js.map +1 -0
- package/dist/market_adapter/lp_chart_core.d.ts +6 -0
- package/dist/market_adapter/lp_chart_core.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_core.js +874 -0
- package/dist/market_adapter/lp_chart_core.js.map +1 -0
- package/dist/market_adapter/lp_chart_runner.d.ts +135 -0
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_runner.js +337 -0
- package/dist/market_adapter/lp_chart_runner.js.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +23 -0
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +1 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js +169 -0
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -0
- package/dist/market_adapter/market_adapter.d.ts +133 -0
- package/dist/market_adapter/market_adapter.d.ts.map +1 -0
- package/dist/market_adapter/market_adapter.js +1331 -0
- package/dist/market_adapter/market_adapter.js.map +1 -0
- package/dist/market_adapter/merge_lp_data.d.ts +3 -0
- package/dist/market_adapter/merge_lp_data.d.ts.map +1 -0
- package/dist/market_adapter/merge_lp_data.js +125 -0
- package/dist/market_adapter/merge_lp_data.js.map +1 -0
- package/dist/market_adapter/test_helpers.d.ts +14 -0
- package/dist/market_adapter/test_helpers.d.ts.map +1 -0
- package/dist/market_adapter/test_helpers.js +22 -0
- package/dist/market_adapter/test_helpers.js.map +1 -0
- package/dist/market_adapter/utils/adapter_client.d.ts +20 -0
- package/dist/market_adapter/utils/adapter_client.d.ts.map +1 -0
- package/dist/market_adapter/utils/adapter_client.js +88 -0
- package/dist/market_adapter/utils/adapter_client.js.map +1 -0
- package/dist/market_adapter/utils/atomic_write.d.ts +9 -0
- package/dist/market_adapter/utils/atomic_write.d.ts.map +1 -0
- package/dist/market_adapter/utils/atomic_write.js +13 -0
- package/dist/market_adapter/utils/atomic_write.js.map +1 -0
- package/dist/market_adapter/utils/chain.d.ts +50 -0
- package/dist/market_adapter/utils/chain.d.ts.map +1 -0
- package/dist/market_adapter/utils/chain.js +196 -0
- package/dist/market_adapter/utils/chain.js.map +1 -0
- package/dist/market_adapter/utils/data_discovery.d.ts +6 -0
- package/dist/market_adapter/utils/data_discovery.d.ts.map +1 -0
- package/dist/market_adapter/utils/data_discovery.js +35 -0
- package/dist/market_adapter/utils/data_discovery.js.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +15 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +60 -0
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -0
- package/dist/market_adapter/utils/file_lock.d.ts +19 -0
- package/dist/market_adapter/utils/file_lock.d.ts.map +1 -0
- package/dist/market_adapter/utils/file_lock.js +191 -0
- package/dist/market_adapter/utils/file_lock.js.map +1 -0
- package/dist/market_adapter/utils/native_history.d.ts +19 -0
- package/dist/market_adapter/utils/native_history.d.ts.map +1 -0
- package/dist/market_adapter/utils/native_history.js +172 -0
- package/dist/market_adapter/utils/native_history.js.map +1 -0
- package/dist/market_adapter/utils/paths.d.ts +5 -0
- package/dist/market_adapter/utils/paths.d.ts.map +1 -0
- package/dist/market_adapter/utils/paths.js +7 -0
- package/dist/market_adapter/utils/paths.js.map +1 -0
- package/dist/modules/account_bots.d.ts +112 -0
- package/dist/modules/account_bots.d.ts.map +1 -0
- package/dist/modules/account_bots.js +1259 -0
- package/dist/modules/account_bots.js.map +1 -0
- package/dist/modules/account_orders.d.ts +273 -0
- package/dist/modules/account_orders.d.ts.map +1 -0
- package/dist/modules/account_orders.js +662 -0
- package/dist/modules/account_orders.js.map +1 -0
- package/dist/modules/authority_resolver.d.ts +2 -0
- package/dist/modules/authority_resolver.d.ts.map +1 -0
- package/dist/modules/authority_resolver.js +231 -0
- package/dist/modules/authority_resolver.js.map +1 -0
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -0
- package/dist/modules/bitshares-native/chain_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/chain_client.js +322 -0
- package/dist/modules/bitshares-native/chain_client.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts +59 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +456 -0
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts +66 -0
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc.js +557 -0
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +20 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -0
- package/dist/modules/bitshares-native/index.d.ts +3 -0
- package/dist/modules/bitshares-native/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/index.js +32 -0
- package/dist/modules/bitshares-native/index.js.map +1 -0
- package/dist/modules/bitshares-native/resolvers.d.ts +40 -0
- package/dist/modules/bitshares-native/resolvers.d.ts.map +1 -0
- package/dist/modules/bitshares-native/resolvers.js +161 -0
- package/dist/modules/bitshares-native/resolvers.js.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts +56 -0
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js +92 -0
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -0
- package/dist/modules/bitshares-native/serial/index.d.ts +10 -0
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/index.js +14 -0
- package/dist/modules/bitshares-native/serial/index.js.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +102 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/operations.js +615 -0
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts +64 -0
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/serializer.js +252 -0
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -0
- package/dist/modules/bitshares-native/serial/types.d.ts +120 -0
- package/dist/modules/bitshares-native/serial/types.d.ts.map +1 -0
- package/dist/modules/bitshares-native/serial/types.js +837 -0
- package/dist/modules/bitshares-native/serial/types.js.map +1 -0
- package/dist/modules/bitshares-native/signing_client.d.ts +6 -0
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -0
- package/dist/modules/bitshares-native/signing_client.js +141 -0
- package/dist/modules/bitshares-native/signing_client.js.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts +6 -0
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -0
- package/dist/modules/bitshares-native/subscriptions.js +865 -0
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -0
- package/dist/modules/bitshares-native/transport.d.ts +51 -0
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -0
- package/dist/modules/bitshares-native/transport.js +447 -0
- package/dist/modules/bitshares-native/transport.js.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts +30 -0
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +1 -0
- package/dist/modules/bitshares-native/tx/builder.js +262 -0
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -0
- package/dist/modules/bitshares_client.d.ts +129 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -0
- package/dist/modules/bitshares_client.js +627 -0
- package/dist/modules/bitshares_client.js.map +1 -0
- package/dist/modules/bot_settings.d.ts +33 -0
- package/dist/modules/bot_settings.d.ts.map +1 -0
- package/dist/modules/bot_settings.js +328 -0
- package/dist/modules/bot_settings.js.map +1 -0
- package/dist/modules/bots_file_lock.d.ts +88 -0
- package/dist/modules/bots_file_lock.d.ts.map +1 -0
- package/dist/modules/bots_file_lock.js +161 -0
- package/dist/modules/bots_file_lock.js.map +1 -0
- package/dist/modules/chain_keys.d.ts +302 -0
- package/dist/modules/chain_keys.d.ts.map +1 -0
- package/dist/modules/chain_keys.js +1095 -0
- package/dist/modules/chain_keys.js.map +1 -0
- package/dist/modules/chain_orders.d.ts +423 -0
- package/dist/modules/chain_orders.d.ts.map +1 -0
- package/dist/modules/chain_orders.js +1201 -0
- package/dist/modules/chain_orders.js.map +1 -0
- package/dist/modules/cli_whitelist_args.d.ts +6 -0
- package/dist/modules/cli_whitelist_args.d.ts.map +1 -0
- package/dist/modules/cli_whitelist_args.js +13 -0
- package/dist/modules/cli_whitelist_args.js.map +1 -0
- package/dist/modules/config.d.ts +57 -0
- package/dist/modules/config.d.ts.map +1 -0
- package/dist/modules/config.js +107 -0
- package/dist/modules/config.js.map +1 -0
- package/dist/modules/constants.d.ts +635 -0
- package/dist/modules/constants.d.ts.map +1 -0
- package/dist/modules/constants.js +1464 -0
- package/dist/modules/constants.js.map +1 -0
- package/dist/modules/cr_planner.d.ts +51 -0
- package/dist/modules/cr_planner.d.ts.map +1 -0
- package/dist/modules/cr_planner.js +299 -0
- package/dist/modules/cr_planner.js.map +1 -0
- package/dist/modules/credential_policy.d.ts +188 -0
- package/dist/modules/credential_policy.d.ts.map +1 -0
- package/dist/modules/credential_policy.js +1452 -0
- package/dist/modules/credential_policy.js.map +1 -0
- package/dist/modules/credential_runtime.d.ts +42 -0
- package/dist/modules/credential_runtime.d.ts.map +1 -0
- package/dist/modules/credential_runtime.js +148 -0
- package/dist/modules/credential_runtime.js.map +1 -0
- package/dist/modules/credential_session_cache.d.ts +36 -0
- package/dist/modules/credential_session_cache.d.ts.map +1 -0
- package/dist/modules/credential_session_cache.js +106 -0
- package/dist/modules/credential_session_cache.js.map +1 -0
- package/dist/modules/credit_runtime.d.ts +412 -0
- package/dist/modules/credit_runtime.d.ts.map +1 -0
- package/dist/modules/credit_runtime.js +2866 -0
- package/dist/modules/credit_runtime.js.map +1 -0
- package/dist/modules/crypto/browser_provider.d.ts +15 -0
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -0
- package/dist/modules/crypto/browser_provider.js +113 -0
- package/dist/modules/crypto/browser_provider.js.map +1 -0
- package/dist/modules/crypto/index.d.ts +9 -0
- package/dist/modules/crypto/index.d.ts.map +1 -0
- package/dist/modules/crypto/index.js +44 -0
- package/dist/modules/crypto/index.js.map +1 -0
- package/dist/modules/crypto/node_provider.d.ts +15 -0
- package/dist/modules/crypto/node_provider.d.ts.map +1 -0
- package/dist/modules/crypto/node_provider.js +74 -0
- package/dist/modules/crypto/node_provider.js.map +1 -0
- package/dist/modules/crypto/provider.d.ts +34 -0
- package/dist/modules/crypto/provider.d.ts.map +1 -0
- package/dist/modules/crypto/provider.js +3 -0
- package/dist/modules/crypto/provider.js.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts +8 -0
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +1 -0
- package/dist/modules/crypto/pure_ripemd160.js +142 -0
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -0
- package/dist/modules/crypto/pure_scrypt.d.ts +23 -0
- package/dist/modules/crypto/pure_scrypt.d.ts.map +1 -0
- package/dist/modules/crypto/pure_scrypt.js +161 -0
- package/dist/modules/crypto/pure_scrypt.js.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts +29 -0
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -0
- package/dist/modules/crypto/pure_secp256k1.js +195 -0
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -0
- package/dist/modules/crypto/sync.d.ts +13 -0
- package/dist/modules/crypto/sync.d.ts.map +1 -0
- package/dist/modules/crypto/sync.js +37 -0
- package/dist/modules/crypto/sync.js.map +1 -0
- package/dist/modules/dexbot_class.d.ts +1074 -0
- package/dist/modules/dexbot_class.d.ts.map +1 -0
- package/dist/modules/dexbot_class.js +4613 -0
- package/dist/modules/dexbot_class.js.map +1 -0
- package/dist/modules/dexbot_credential_client.d.ts +71 -0
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -0
- package/dist/modules/dexbot_credential_client.js +224 -0
- package/dist/modules/dexbot_credential_client.js.map +1 -0
- package/dist/modules/dexbot_fill_runtime.d.ts +173 -0
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_fill_runtime.js +217 -0
- package/dist/modules/dexbot_fill_runtime.js.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts +279 -0
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -0
- package/dist/modules/dexbot_maintenance_runtime.js +1613 -0
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -0
- package/dist/modules/env.d.ts +12 -0
- package/dist/modules/env.d.ts.map +1 -0
- package/dist/modules/env.js +57 -0
- package/dist/modules/env.js.map +1 -0
- package/dist/modules/fund_registry.d.ts +96 -0
- package/dist/modules/fund_registry.d.ts.map +1 -0
- package/dist/modules/fund_registry.js +261 -0
- package/dist/modules/fund_registry.js.map +1 -0
- package/dist/modules/general_settings.d.ts +36 -0
- package/dist/modules/general_settings.d.ts.map +1 -0
- package/dist/modules/general_settings.js +63 -0
- package/dist/modules/general_settings.js.map +1 -0
- package/dist/modules/graceful_shutdown.d.ts +86 -0
- package/dist/modules/graceful_shutdown.d.ts.map +1 -0
- package/dist/modules/graceful_shutdown.js +164 -0
- package/dist/modules/graceful_shutdown.js.map +1 -0
- package/dist/modules/key_store.d.ts +60 -0
- package/dist/modules/key_store.d.ts.map +1 -0
- package/dist/modules/key_store.js +215 -0
- package/dist/modules/key_store.js.map +1 -0
- package/dist/modules/launcher/bot_supervisor.d.ts +84 -0
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -0
- package/dist/modules/launcher/bot_supervisor.js +1067 -0
- package/dist/modules/launcher/bot_supervisor.js.map +1 -0
- package/dist/modules/launcher/child_env.d.ts +9 -0
- package/dist/modules/launcher/child_env.d.ts.map +1 -0
- package/dist/modules/launcher/child_env.js +78 -0
- package/dist/modules/launcher/child_env.js.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts +22 -0
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +1 -0
- package/dist/modules/launcher/credential_bootstrap.js +303 -0
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -0
- package/dist/modules/launcher/credential_daemon.d.ts +32 -0
- package/dist/modules/launcher/credential_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/credential_daemon.js +173 -0
- package/dist/modules/launcher/credential_daemon.js.map +1 -0
- package/dist/modules/launcher/credential_secret.d.ts +6 -0
- package/dist/modules/launcher/credential_secret.d.ts.map +1 -0
- package/dist/modules/launcher/credential_secret.js +15 -0
- package/dist/modules/launcher/credential_secret.js.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -0
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +1 -0
- package/dist/modules/launcher/foreign_cred_daemon.js +166 -0
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -0
- package/dist/modules/launcher/headless_password.d.ts +8 -0
- package/dist/modules/launcher/headless_password.d.ts.map +1 -0
- package/dist/modules/launcher/headless_password.js +33 -0
- package/dist/modules/launcher/headless_password.js.map +1 -0
- package/dist/modules/launcher/launch_modes.d.ts +36 -0
- package/dist/modules/launcher/launch_modes.d.ts.map +1 -0
- package/dist/modules/launcher/launch_modes.js +129 -0
- package/dist/modules/launcher/launch_modes.js.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts +43 -0
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_runtime.js +217 -0
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +26 -0
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -0
- package/dist/modules/launcher/market_adapter_watchdog.js +214 -0
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +89 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -0
- package/dist/modules/launcher/monolithic_runtime.js +425 -0
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -0
- package/dist/modules/launcher/runtime_entry.d.ts +26 -0
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -0
- package/dist/modules/launcher/runtime_entry.js +49 -0
- package/dist/modules/launcher/runtime_entry.js.map +1 -0
- package/dist/modules/launcher/status_reporting.d.ts +48 -0
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -0
- package/dist/modules/launcher/status_reporting.js +113 -0
- package/dist/modules/launcher/status_reporting.js.map +1 -0
- package/dist/modules/launcher/supervisor_control.d.ts +6 -0
- package/dist/modules/launcher/supervisor_control.d.ts.map +1 -0
- package/dist/modules/launcher/supervisor_control.js +59 -0
- package/dist/modules/launcher/supervisor_control.js.map +1 -0
- package/dist/modules/logger.d.ts +2 -0
- package/dist/modules/logger.d.ts.map +1 -0
- package/dist/modules/logger.js +71 -0
- package/dist/modules/logger.js.map +1 -0
- package/dist/modules/market_adapter_whitelist.d.ts +22 -0
- package/dist/modules/market_adapter_whitelist.d.ts.map +1 -0
- package/dist/modules/market_adapter_whitelist.js +82 -0
- package/dist/modules/market_adapter_whitelist.js.map +1 -0
- package/dist/modules/node_health_cache.d.ts +55 -0
- package/dist/modules/node_health_cache.d.ts.map +1 -0
- package/dist/modules/node_health_cache.js +134 -0
- package/dist/modules/node_health_cache.js.map +1 -0
- package/dist/modules/node_manager.d.ts +215 -0
- package/dist/modules/node_manager.d.ts.map +1 -0
- package/dist/modules/node_manager.js +628 -0
- package/dist/modules/node_manager.js.map +1 -0
- package/dist/modules/order/accounting.d.ts +349 -0
- package/dist/modules/order/accounting.d.ts.map +1 -0
- package/dist/modules/order/accounting.js +1191 -0
- package/dist/modules/order/accounting.js.map +1 -0
- package/dist/modules/order/async_lock.d.ts +126 -0
- package/dist/modules/order/async_lock.d.ts.map +1 -0
- package/dist/modules/order/async_lock.js +195 -0
- package/dist/modules/order/async_lock.js.map +1 -0
- package/dist/modules/order/export.d.ts +129 -0
- package/dist/modules/order/export.d.ts.map +1 -0
- package/dist/modules/order/export.js +316 -0
- package/dist/modules/order/export.js.map +1 -0
- package/dist/modules/order/format.d.ts +158 -0
- package/dist/modules/order/format.d.ts.map +1 -0
- package/dist/modules/order/format.js +232 -0
- package/dist/modules/order/format.js.map +1 -0
- package/dist/modules/order/grid.d.ts +549 -0
- package/dist/modules/order/grid.d.ts.map +1 -0
- package/dist/modules/order/grid.js +1746 -0
- package/dist/modules/order/grid.js.map +1 -0
- package/dist/modules/order/grid_reconcile.d.ts +154 -0
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -0
- package/dist/modules/order/grid_reconcile.js +1192 -0
- package/dist/modules/order/grid_reconcile.js.map +1 -0
- package/dist/modules/order/index.d.ts +55 -0
- package/dist/modules/order/index.d.ts.map +1 -0
- package/dist/modules/order/index.js +79 -0
- package/dist/modules/order/index.js.map +1 -0
- package/dist/modules/order/logger.d.ts +136 -0
- package/dist/modules/order/logger.d.ts.map +1 -0
- package/dist/modules/order/logger.js +614 -0
- package/dist/modules/order/logger.js.map +1 -0
- package/dist/modules/order/logger_state.d.ts +133 -0
- package/dist/modules/order/logger_state.d.ts.map +1 -0
- package/dist/modules/order/logger_state.js +170 -0
- package/dist/modules/order/logger_state.js.map +1 -0
- package/dist/modules/order/manager.d.ts +413 -0
- package/dist/modules/order/manager.d.ts.map +1 -0
- package/dist/modules/order/manager.js +1605 -0
- package/dist/modules/order/manager.js.map +1 -0
- package/dist/modules/order/processed_fill_store.d.ts +135 -0
- package/dist/modules/order/processed_fill_store.d.ts.map +1 -0
- package/dist/modules/order/processed_fill_store.js +288 -0
- package/dist/modules/order/processed_fill_store.js.map +1 -0
- package/dist/modules/order/runner.d.ts +70 -0
- package/dist/modules/order/runner.d.ts.map +1 -0
- package/dist/modules/order/runner.js +140 -0
- package/dist/modules/order/runner.js.map +1 -0
- package/dist/modules/order/strategy.d.ts +196 -0
- package/dist/modules/order/strategy.d.ts.map +1 -0
- package/dist/modules/order/strategy.js +398 -0
- package/dist/modules/order/strategy.js.map +1 -0
- package/dist/modules/order/sync_engine.d.ts +386 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -0
- package/dist/modules/order/sync_engine.js +1459 -0
- package/dist/modules/order/sync_engine.js.map +1 -0
- package/dist/modules/order/utils/math.d.ts +677 -0
- package/dist/modules/order/utils/math.d.ts.map +1 -0
- package/dist/modules/order/utils/math.js +1172 -0
- package/dist/modules/order/utils/math.js.map +1 -0
- package/dist/modules/order/utils/order.d.ts +572 -0
- package/dist/modules/order/utils/order.d.ts.map +1 -0
- package/dist/modules/order/utils/order.js +1145 -0
- package/dist/modules/order/utils/order.js.map +1 -0
- package/dist/modules/order/utils/system.d.ts +268 -0
- package/dist/modules/order/utils/system.d.ts.map +1 -0
- package/dist/modules/order/utils/system.js +1261 -0
- package/dist/modules/order/utils/system.js.map +1 -0
- package/dist/modules/order/utils/validate.d.ts +280 -0
- package/dist/modules/order/utils/validate.d.ts.map +1 -0
- package/dist/modules/order/utils/validate.js +918 -0
- package/dist/modules/order/utils/validate.js.map +1 -0
- package/dist/modules/order/working_grid.d.ts +212 -0
- package/dist/modules/order/working_grid.d.ts.map +1 -0
- package/dist/modules/order/working_grid.js +279 -0
- package/dist/modules/order/working_grid.js.map +1 -0
- package/dist/modules/path_api.d.ts +32 -0
- package/dist/modules/path_api.d.ts.map +1 -0
- package/dist/modules/path_api.js +148 -0
- package/dist/modules/path_api.js.map +1 -0
- package/dist/modules/paths.d.ts +58 -0
- package/dist/modules/paths.d.ts.map +1 -0
- package/dist/modules/paths.js +82 -0
- package/dist/modules/paths.js.map +1 -0
- package/dist/modules/process_discovery.d.ts +58 -0
- package/dist/modules/process_discovery.d.ts.map +1 -0
- package/dist/modules/process_discovery.js +265 -0
- package/dist/modules/process_discovery.js.map +1 -0
- package/dist/modules/runtime.d.ts +34 -0
- package/dist/modules/runtime.d.ts.map +1 -0
- package/dist/modules/runtime.js +98 -0
- package/dist/modules/runtime.js.map +1 -0
- package/dist/modules/runtime_settings.d.ts +12 -0
- package/dist/modules/runtime_settings.d.ts.map +1 -0
- package/dist/modules/runtime_settings.js +122 -0
- package/dist/modules/runtime_settings.js.map +1 -0
- package/dist/modules/settings_merge.d.ts +38 -0
- package/dist/modules/settings_merge.d.ts.map +1 -0
- package/dist/modules/settings_merge.js +246 -0
- package/dist/modules/settings_merge.js.map +1 -0
- package/dist/modules/storage/browser_adapter.d.ts +56 -0
- package/dist/modules/storage/browser_adapter.d.ts.map +1 -0
- package/dist/modules/storage/browser_adapter.js +231 -0
- package/dist/modules/storage/browser_adapter.js.map +1 -0
- package/dist/modules/storage/index.d.ts +28 -0
- package/dist/modules/storage/index.d.ts.map +1 -0
- package/dist/modules/storage/index.js +52 -0
- package/dist/modules/storage/index.js.map +1 -0
- package/dist/modules/storage/node_adapter.d.ts +49 -0
- package/dist/modules/storage/node_adapter.d.ts.map +1 -0
- package/dist/modules/storage/node_adapter.js +167 -0
- package/dist/modules/storage/node_adapter.js.map +1 -0
- package/dist/modules/storage/types.d.ts +92 -0
- package/dist/modules/storage/types.d.ts.map +1 -0
- package/dist/modules/storage/types.js +3 -0
- package/dist/modules/storage/types.js.map +1 -0
- package/dist/modules/types.d.ts +1382 -0
- package/dist/modules/types.d.ts.map +1 -0
- package/dist/modules/types.js +11 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/modules/utils/base58check.d.ts +12 -0
- package/dist/modules/utils/base58check.d.ts.map +1 -0
- package/dist/modules/utils/base58check.js +112 -0
- package/dist/modules/utils/base58check.js.map +1 -0
- package/dist/modules/utils/build_dir.d.ts +7 -0
- package/dist/modules/utils/build_dir.d.ts.map +1 -0
- package/dist/modules/utils/build_dir.js +8 -0
- package/dist/modules/utils/build_dir.js.map +1 -0
- package/dist/modules/utils/fs_utils.d.ts +25 -0
- package/dist/modules/utils/fs_utils.d.ts.map +1 -0
- package/dist/modules/utils/fs_utils.js +27 -0
- package/dist/modules/utils/fs_utils.js.map +1 -0
- package/dist/modules/utils/math_utils.d.ts +10 -0
- package/dist/modules/utils/math_utils.d.ts.map +1 -0
- package/dist/modules/utils/math_utils.js +17 -0
- package/dist/modules/utils/math_utils.js.map +1 -0
- package/dist/modules/validate_profiles.d.ts +37 -0
- package/dist/modules/validate_profiles.d.ts.map +1 -0
- package/dist/modules/validate_profiles.js +369 -0
- package/dist/modules/validate_profiles.js.map +1 -0
- package/dist/pm2.d.ts +167 -0
- package/dist/pm2.d.ts.map +1 -0
- package/dist/pm2.js +998 -0
- package/dist/pm2.js.map +1 -0
- package/dist/scripts/analyze-git.d.ts +11 -0
- package/dist/scripts/analyze-git.d.ts.map +1 -0
- package/dist/scripts/analyze-git.js +851 -0
- package/dist/scripts/analyze-git.js.map +1 -0
- package/dist/scripts/analyze-orders.d.ts +17 -0
- package/dist/scripts/analyze-orders.d.ts.map +1 -0
- package/dist/scripts/analyze-orders.js +1568 -0
- package/dist/scripts/analyze-orders.js.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts +3 -0
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -0
- package/dist/scripts/diagnose-kibana-candles.js +82 -0
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -0
- package/dist/scripts/diagnose-pool-history.d.ts +3 -0
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -0
- package/dist/scripts/diagnose-pool-history.js +296 -0
- package/dist/scripts/diagnose-pool-history.js.map +1 -0
- package/dist/scripts/divergence-calc.d.ts +26 -0
- package/dist/scripts/divergence-calc.d.ts.map +1 -0
- package/dist/scripts/divergence-calc.js +119 -0
- package/dist/scripts/divergence-calc.js.map +1 -0
- package/dist/scripts/generate_lp_chart.d.ts +31 -0
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -0
- package/dist/scripts/generate_lp_chart.js +92 -0
- package/dist/scripts/generate_lp_chart.js.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts +24 -0
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -0
- package/dist/scripts/generate_mainnet_corpus_report.js +237 -0
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts +2 -0
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -0
- package/dist/scripts/generate_market_adapter_whitelist.js +111 -0
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -0
- package/dist/scripts/migrate_bot_keys.d.ts +6 -0
- package/dist/scripts/migrate_bot_keys.d.ts.map +1 -0
- package/dist/scripts/migrate_bot_keys.js +301 -0
- package/dist/scripts/migrate_bot_keys.js.map +1 -0
- package/dist/scripts/native_release_gates.d.ts +3 -0
- package/dist/scripts/native_release_gates.d.ts.map +1 -0
- package/dist/scripts/native_release_gates.js +52 -0
- package/dist/scripts/native_release_gates.js.map +1 -0
- package/dist/scripts/print_grid.d.ts +16 -0
- package/dist/scripts/print_grid.d.ts.map +1 -0
- package/dist/scripts/print_grid.js +80 -0
- package/dist/scripts/print_grid.js.map +1 -0
- package/dist/scripts/run-tests.d.ts +2 -0
- package/dist/scripts/run-tests.d.ts.map +1 -0
- package/dist/scripts/run-tests.js +49 -0
- package/dist/scripts/run-tests.js.map +1 -0
- package/dist/scripts/sync-version.d.ts +14 -0
- package/dist/scripts/sync-version.d.ts.map +1 -0
- package/dist/scripts/sync-version.js +158 -0
- package/dist/scripts/sync-version.js.map +1 -0
- package/dist/scripts/test-credit-renewal.d.ts +2 -0
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -0
- package/dist/scripts/test-credit-renewal.js +329 -0
- package/dist/scripts/test-credit-renewal.js.map +1 -0
- package/dist/scripts/update.d.ts +24 -0
- package/dist/scripts/update.d.ts.map +1 -0
- package/dist/scripts/update.js +650 -0
- package/dist/scripts/update.js.map +1 -0
- package/dist/scripts/validate_bots.d.ts +16 -0
- package/dist/scripts/validate_bots.d.ts.map +1 -0
- package/dist/scripts/validate_bots.js +106 -0
- package/dist/scripts/validate_bots.js.map +1 -0
- package/dist/scripts/verify-browser-bundle.d.ts +22 -0
- package/dist/scripts/verify-browser-bundle.d.ts.map +1 -0
- package/dist/scripts/verify-browser-bundle.js +339 -0
- package/dist/scripts/verify-browser-bundle.js.map +1 -0
- package/dist/unlock.d.ts +48 -0
- package/dist/unlock.d.ts.map +1 -0
- package/dist/unlock.js +925 -0
- package/dist/unlock.js.map +1 -0
- package/package.json +112 -0
- package/scripts/README.md +356 -0
- package/scripts/clear-all.sh +195 -0
- package/scripts/clear-logs.sh +95 -0
- package/scripts/clear-market-adapter.sh +196 -0
- package/scripts/clear-orders.sh +113 -0
- package/scripts/create-bot-symlinks.sh +51 -0
- package/scripts/postinstall.js +9 -0
- package/scripts/reset-settings.sh +118 -0
package/dist/pm2.js
ADDED
|
@@ -0,0 +1,998 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// node-only entry point — PM2 process orchestration (spawn, exec, fs, os)
|
|
4
|
+
/**
|
|
5
|
+
* pm2.ts - PM2 Orchestration Launcher
|
|
6
|
+
*
|
|
7
|
+
* Unified PM2 launcher for DEXBot2 multi-bot system.
|
|
8
|
+
* One-command startup with all setup required before starting bots.
|
|
9
|
+
* Handles process management, configuration generation, and daemon startup.
|
|
10
|
+
*
|
|
11
|
+
* ===============================================================================
|
|
12
|
+
* COMMANDS
|
|
13
|
+
* ===============================================================================
|
|
14
|
+
*
|
|
15
|
+
* node pm2 - Default: unlock keystore and start all bots
|
|
16
|
+
* node pm2 <bot> - Unlock keystore and start specific bot
|
|
17
|
+
* node pm2 claw-only - Credential daemon only, managed by PM2
|
|
18
|
+
* node pm2 update - Run the update script immediately
|
|
19
|
+
* node pm2 stop all - Stop all dexbot PM2 processes
|
|
20
|
+
* node pm2 stop <bot-name> - Stop specific bot process
|
|
21
|
+
* node pm2 delete all - Delete all dexbot processes from PM2
|
|
22
|
+
* node pm2 delete <bot-name> - Delete specific bot from PM2
|
|
23
|
+
* node pm2 restart all - Restart managed apps; re-unlock dexbot-cred only if needed
|
|
24
|
+
* node pm2 restart <target> - Restart a bot or safely re-unlock dexbot-cred
|
|
25
|
+
|
|
26
|
+
* node pm2 --headless - Non-interactive unlock with env var
|
|
27
|
+
* node pm2 --headless --password-file <path>
|
|
28
|
+
* - Non-interactive unlock with password file
|
|
29
|
+
* node pm2 help - Show help message
|
|
30
|
+
*
|
|
31
|
+
* ===============================================================================
|
|
32
|
+
* SETUP SEQUENCE
|
|
33
|
+
* ===============================================================================
|
|
34
|
+
*
|
|
35
|
+
* Step 0: BITSHARES CONNECTION VERIFICATION
|
|
36
|
+
* - Waits for BitShares blockchain network connection
|
|
37
|
+
* - Suppresses debug output to keep terminal clean
|
|
38
|
+
* - Validates node availability before proceeding
|
|
39
|
+
*
|
|
40
|
+
* Step 1: PM2 INSTALLATION CHECK
|
|
41
|
+
* - Detects local and global PM2 installations
|
|
42
|
+
* - Prompts to install PM2 if missing
|
|
43
|
+
* - Validates PM2 is available before proceeding
|
|
44
|
+
*
|
|
45
|
+
* Step 2: ECOSYSTEM CONFIGURATION GENERATION
|
|
46
|
+
* - Reads bot definitions from profiles/bots.json for bot mode
|
|
47
|
+
* - Generates profiles/ecosystem.config.js with absolute paths
|
|
48
|
+
* - Filters only active bots (active !== false)
|
|
49
|
+
* - If bot-name provided, filters to only that bot
|
|
50
|
+
* - In claw-only mode, generates only the credential daemon app
|
|
51
|
+
* - Each bot configured with:
|
|
52
|
+
* * Unique app name
|
|
53
|
+
* * Log file paths
|
|
54
|
+
* * Restart/memory policies
|
|
55
|
+
*
|
|
56
|
+
* Step 3: AUTHENTICATION & CLEANUP
|
|
57
|
+
* - Cleans up stale daemon socket files
|
|
58
|
+
* - Prompts interactively for the unlock secret once at startup
|
|
59
|
+
* - Authenticates against profiles/keys.json
|
|
60
|
+
* - Uses a one-shot local bootstrap channel for credential-daemon only
|
|
61
|
+
*
|
|
62
|
+
* Step 4: PM2 DAEMON STARTUP
|
|
63
|
+
* - Starts PM2 daemon if not already running
|
|
64
|
+
* - Waits for PM2 to be ready
|
|
65
|
+
* - Starts each configured bot as PM2 app
|
|
66
|
+
* - Credential daemon is started as a PM2 app after one-shot bootstrap
|
|
67
|
+
* - Bots request private keys from credential daemon via Unix socket
|
|
68
|
+
*/
|
|
69
|
+
const { setUmask } = require('./modules/config');
|
|
70
|
+
setUmask(0o077);
|
|
71
|
+
const fs = require('fs');
|
|
72
|
+
const { path } = require('./modules/path_api');
|
|
73
|
+
const { spawn, exec } = require('child_process');
|
|
74
|
+
const { promisify } = require('util');
|
|
75
|
+
const { parseJsonWithComments } = require('./modules/order/utils/system');
|
|
76
|
+
const { readBotsFileWithLock } = require('./modules/bots_file_lock');
|
|
77
|
+
const { loadSettingsFile, selectActiveBotEntries } = require('./modules/bot_settings');
|
|
78
|
+
const chainKeys = require('./modules/chain_keys');
|
|
79
|
+
const credentialPolicy = require('./modules/credential_policy');
|
|
80
|
+
const { readHeadlessPassword } = require('./modules/launcher/headless_password');
|
|
81
|
+
const { ensureCredentialRuntimeDirSync, getCredentialReadyFilePath, getCredentialSocketPath, } = require('./modules/credential_runtime');
|
|
82
|
+
const { buildScopedChildEnv } = require('./modules/launcher/child_env');
|
|
83
|
+
const { createPasswordBootstrapServer } = require('./modules/launcher/credential_bootstrap');
|
|
84
|
+
const { parsePm2Args } = require('./modules/launcher/launch_modes');
|
|
85
|
+
const { setupGracefulShutdown } = require('./modules/graceful_shutdown');
|
|
86
|
+
const { UPDATER, TIMING } = require('./modules/constants');
|
|
87
|
+
const { PATHS } = require('./modules/paths');
|
|
88
|
+
const { isDistCodeRoot, buildRuntimeScriptPath } = require('./modules/launcher/runtime_entry');
|
|
89
|
+
const { getStorage } = require('./modules/storage');
|
|
90
|
+
const storage = getStorage();
|
|
91
|
+
const { ensureDir, safeUnlink } = require('./modules/utils/fs_utils');
|
|
92
|
+
const { Config } = require('./modules/config');
|
|
93
|
+
// Setup graceful shutdown handlers
|
|
94
|
+
setupGracefulShutdown();
|
|
95
|
+
const execAsync = promisify(exec);
|
|
96
|
+
const PM2_COLORS = {
|
|
97
|
+
reset: '\x1b[0m',
|
|
98
|
+
ok: '\x1b[1;92m',
|
|
99
|
+
error: '\x1b[1;31m',
|
|
100
|
+
};
|
|
101
|
+
function colorPm2Output(text, color, stream = process.stdout) {
|
|
102
|
+
return stream.isTTY && !Config.NO_COLOR
|
|
103
|
+
? `${color}${text}${PM2_COLORS.reset}`
|
|
104
|
+
: text;
|
|
105
|
+
}
|
|
106
|
+
function pm2Success(text) {
|
|
107
|
+
return colorPm2Output(text, PM2_COLORS.ok);
|
|
108
|
+
}
|
|
109
|
+
function pm2Error(text) {
|
|
110
|
+
return colorPm2Output(text, PM2_COLORS.error, process.stderr);
|
|
111
|
+
}
|
|
112
|
+
const CODE_ROOT = __dirname;
|
|
113
|
+
const ROOT = PATHS.PROJECT_ROOT;
|
|
114
|
+
const BOTS_JSON = PATHS.PROFILES.BOTS_JSON;
|
|
115
|
+
const ECOSYSTEM_FILE = PATHS.PROFILES.ECOSYSTEM_CONFIG_JS;
|
|
116
|
+
const POLICY_CONFIG_FILE = PATHS.PROFILES.DAEMON_POLICIES_JSON;
|
|
117
|
+
const LOGS_DIR = PATHS.LOGS_DIR;
|
|
118
|
+
const CREDENTIAL_DAEMON_APP_NAME = 'dexbot-cred';
|
|
119
|
+
const CREDENTIAL_SOCKET_PATH = getCredentialSocketPath({ root: PATHS.PROJECT_ROOT });
|
|
120
|
+
const CREDENTIAL_READY_FILE = getCredentialReadyFilePath({ root: PATHS.PROJECT_ROOT });
|
|
121
|
+
function runtimeScript(...segments) {
|
|
122
|
+
return path.join(CODE_ROOT, ...segments);
|
|
123
|
+
}
|
|
124
|
+
function usesAmaGridPrice(bot) {
|
|
125
|
+
const gridPrice = typeof bot?.gridPrice === 'string' ? bot.gridPrice.trim().toLowerCase() : '';
|
|
126
|
+
return /^ama(?:[1-4])?$/.test(gridPrice);
|
|
127
|
+
}
|
|
128
|
+
function needsMarketAdapter(bots) {
|
|
129
|
+
return (bots || []).some((bot) => usesAmaGridPrice(bot));
|
|
130
|
+
}
|
|
131
|
+
function isServiceApp(app) {
|
|
132
|
+
const name = String(app?.name || '');
|
|
133
|
+
return name === 'dexbot-update' || name === CREDENTIAL_DAEMON_APP_NAME || name === 'dexbot-adapter';
|
|
134
|
+
}
|
|
135
|
+
function countManagedBots(apps) {
|
|
136
|
+
return (apps || []).filter((app) => !isServiceApp(app)).length;
|
|
137
|
+
}
|
|
138
|
+
function isPm2TableLine(line) {
|
|
139
|
+
const trimmed = String(line || '').trim();
|
|
140
|
+
if (!trimmed)
|
|
141
|
+
return true;
|
|
142
|
+
return /^[┌┬│├┤└┴─\s]+$/.test(trimmed) || /^[┌┬│├┤└┴]/.test(trimmed);
|
|
143
|
+
}
|
|
144
|
+
function transformPm2Line(line) {
|
|
145
|
+
const trimmed = String(line || '').trim();
|
|
146
|
+
if (!trimmed)
|
|
147
|
+
return null;
|
|
148
|
+
if (isPm2TableLine(trimmed))
|
|
149
|
+
return null;
|
|
150
|
+
if (/^\[PM2\] Starting\b/.test(trimmed))
|
|
151
|
+
return null;
|
|
152
|
+
if (trimmed === '[PM2] Done.')
|
|
153
|
+
return null;
|
|
154
|
+
if (/^\[PM2\] cron restart at /.test(trimmed))
|
|
155
|
+
return null;
|
|
156
|
+
if (/^\[PM2\]\[WARN\] Applications .* not running, starting\.\.\.$/.test(trimmed))
|
|
157
|
+
return null;
|
|
158
|
+
if (/^\[PM2\] Applying action /.test(trimmed))
|
|
159
|
+
return null;
|
|
160
|
+
return trimmed.replace(/\s+\(\d+ instances?\)$/, '');
|
|
161
|
+
}
|
|
162
|
+
function flushPm2Buffer(buffer, writer, { final = false } = {}) {
|
|
163
|
+
if (!buffer)
|
|
164
|
+
return '';
|
|
165
|
+
const lines = buffer.split(/\r?\n/);
|
|
166
|
+
const trailing = lines.pop();
|
|
167
|
+
for (const line of lines) {
|
|
168
|
+
const transformed = transformPm2Line(line);
|
|
169
|
+
if (transformed)
|
|
170
|
+
writer(transformed);
|
|
171
|
+
}
|
|
172
|
+
if (final && trailing && trailing.trim()) {
|
|
173
|
+
const transformed = transformPm2Line(trailing);
|
|
174
|
+
if (transformed)
|
|
175
|
+
writer(transformed);
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
return trailing || '';
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Build PM2 app definitions for the current runtime.
|
|
182
|
+
* @param {Array<Object>} bots - Active bot entries.
|
|
183
|
+
* @param {Object} [options] - Build options.
|
|
184
|
+
* @param {boolean} [options.includeUpdater=true] - Whether to add the updater service.
|
|
185
|
+
* @returns {Array<Object>} PM2 app definitions.
|
|
186
|
+
*/
|
|
187
|
+
function buildEcosystemApps(bots, { includeUpdater = true } = {}) {
|
|
188
|
+
const apps = (bots || []).map((bot, index) => {
|
|
189
|
+
const botName = bot.name || `bot-${index}`;
|
|
190
|
+
return {
|
|
191
|
+
name: botName,
|
|
192
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['bot']),
|
|
193
|
+
args: botName,
|
|
194
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
195
|
+
max_memory_restart: '250M',
|
|
196
|
+
watch: false,
|
|
197
|
+
autorestart: true,
|
|
198
|
+
error_file: path.join(LOGS_DIR, `${botName}-error.log`),
|
|
199
|
+
out_file: path.join(LOGS_DIR, `${botName}.log`),
|
|
200
|
+
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
201
|
+
merge_logs: false,
|
|
202
|
+
combine_logs: true,
|
|
203
|
+
max_size: '100M',
|
|
204
|
+
max_restarts: 13,
|
|
205
|
+
min_uptime: 86400000,
|
|
206
|
+
restart_delay: 3000
|
|
207
|
+
};
|
|
208
|
+
});
|
|
209
|
+
if (needsMarketAdapter(bots)) {
|
|
210
|
+
apps.unshift({
|
|
211
|
+
name: 'dexbot-adapter',
|
|
212
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['market_adapter', 'market_adapter']),
|
|
213
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
214
|
+
watch: false,
|
|
215
|
+
autorestart: true,
|
|
216
|
+
max_memory_restart: '150M',
|
|
217
|
+
error_file: path.join(LOGS_DIR, 'dexbot-adapter-error.log'),
|
|
218
|
+
out_file: path.join(LOGS_DIR, 'dexbot-adapter.log'),
|
|
219
|
+
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
220
|
+
merge_logs: false,
|
|
221
|
+
combine_logs: true,
|
|
222
|
+
max_size: '100M',
|
|
223
|
+
max_restarts: 13,
|
|
224
|
+
min_uptime: 60000,
|
|
225
|
+
restart_delay: 3000,
|
|
226
|
+
...(isDistCodeRoot(CODE_ROOT) ? {} : { node_args: ['--import', 'tsx'] })
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
if (includeUpdater && UPDATER.ACTIVE) {
|
|
230
|
+
apps.push({
|
|
231
|
+
name: "dexbot-update",
|
|
232
|
+
script: runtimeScript('scripts', 'update.js'),
|
|
233
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
234
|
+
autorestart: false,
|
|
235
|
+
cron_restart: UPDATER.SCHEDULE,
|
|
236
|
+
error_file: path.join(LOGS_DIR, `dexbot-update-error.log`),
|
|
237
|
+
out_file: path.join(LOGS_DIR, `dexbot-update.log`),
|
|
238
|
+
log_date_format: "YY-MM-DD HH:mm:ss.SSS",
|
|
239
|
+
max_size: '100M'
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
return apps;
|
|
243
|
+
}
|
|
244
|
+
function buildCredentialDaemonApp({ credentialEnv = {} } = {}) {
|
|
245
|
+
return {
|
|
246
|
+
name: CREDENTIAL_DAEMON_APP_NAME,
|
|
247
|
+
script: runtimeScript('credential-daemon.js'),
|
|
248
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
249
|
+
autorestart: false,
|
|
250
|
+
error_file: path.join(LOGS_DIR, 'dexbot-cred-error.log'),
|
|
251
|
+
out_file: path.join(LOGS_DIR, 'dexbot-cred.log'),
|
|
252
|
+
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
253
|
+
merge_logs: false,
|
|
254
|
+
combine_logs: true,
|
|
255
|
+
max_size: '100M',
|
|
256
|
+
env: {
|
|
257
|
+
DEXBOT_CRED_DAEMON_SOCKET: CREDENTIAL_SOCKET_PATH,
|
|
258
|
+
DEXBOT_CRED_DAEMON_READY_FILE: CREDENTIAL_READY_FILE,
|
|
259
|
+
...credentialEnv,
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Generate ecosystem.config.js from bots.json or claw-only mode.
|
|
265
|
+
* @param {Object} [options={}] - Generation options.
|
|
266
|
+
* @param {string|null} [options.botNameFilter=null] - Optional bot name to filter by.
|
|
267
|
+
* @param {boolean} [options.clawOnly=false] - Generate no managed bot apps.
|
|
268
|
+
* @param {boolean} [options.exitOnError=true] - If true, calls process.exit(1) instead of throwing
|
|
269
|
+
* @returns {Array<Object>} The generated app configurations.
|
|
270
|
+
*/
|
|
271
|
+
function generateEcosystemConfig({ botNameFilter = null, clawOnly = false, exitOnError = true } = {}) {
|
|
272
|
+
function fail(message) {
|
|
273
|
+
if (exitOnError) {
|
|
274
|
+
console.error(pm2Error(String(message)));
|
|
275
|
+
process.exit(1);
|
|
276
|
+
}
|
|
277
|
+
throw new Error(message);
|
|
278
|
+
}
|
|
279
|
+
// Ensure logs directory exists
|
|
280
|
+
if (!storage.exists(LOGS_DIR)) {
|
|
281
|
+
ensureDir(LOGS_DIR);
|
|
282
|
+
}
|
|
283
|
+
try {
|
|
284
|
+
if (clawOnly) {
|
|
285
|
+
const appsClaw = [];
|
|
286
|
+
const ecosystemContent = `// Auto-generated by pm2.js - DO NOT EDIT
|
|
287
|
+
// Regenerate with: node pm2 or node dist/dexbot.js pm2
|
|
288
|
+
module.exports = { apps: ${JSON.stringify(appsClaw, null, 2)} };
|
|
289
|
+
`;
|
|
290
|
+
storage.writeFile(ECOSYSTEM_FILE, ecosystemContent);
|
|
291
|
+
return appsClaw;
|
|
292
|
+
}
|
|
293
|
+
if (!storage.exists(BOTS_JSON)) {
|
|
294
|
+
fail('profiles/bots.json not found. Run: dexbot bots');
|
|
295
|
+
}
|
|
296
|
+
const { config } = loadSettingsFile(BOTS_JSON, { exitOnError });
|
|
297
|
+
const bots = selectActiveBotEntries(config);
|
|
298
|
+
if (botNameFilter) {
|
|
299
|
+
const filtered = bots.filter((b) => b.name === botNameFilter);
|
|
300
|
+
if (filtered.length === 0) {
|
|
301
|
+
fail(`Bot '${botNameFilter}' not found or not active in profiles/bots.json`);
|
|
302
|
+
}
|
|
303
|
+
const apps = buildEcosystemApps(filtered, { includeUpdater: false });
|
|
304
|
+
const ecosystemContent = `// Auto-generated by pm2.js - DO NOT EDIT
|
|
305
|
+
// Regenerate with: node pm2 or node dist/dexbot.js pm2
|
|
306
|
+
module.exports = { apps: ${JSON.stringify(apps, null, 2)} };
|
|
307
|
+
`;
|
|
308
|
+
storage.writeFile(ECOSYSTEM_FILE, ecosystemContent);
|
|
309
|
+
return apps;
|
|
310
|
+
}
|
|
311
|
+
if (bots.length === 0) {
|
|
312
|
+
fail('No active bots found in profiles/bots.json');
|
|
313
|
+
}
|
|
314
|
+
const apps = buildEcosystemApps(bots, { includeUpdater: true });
|
|
315
|
+
const ecosystemContent = `// Auto-generated by pm2.js - DO NOT EDIT
|
|
316
|
+
// Regenerate with: node pm2 or node dist/dexbot.js pm2
|
|
317
|
+
module.exports = { apps: ${JSON.stringify(apps, null, 2)} };
|
|
318
|
+
`;
|
|
319
|
+
storage.writeFile(ECOSYSTEM_FILE, ecosystemContent);
|
|
320
|
+
return apps;
|
|
321
|
+
}
|
|
322
|
+
catch (err) {
|
|
323
|
+
fail(`Error reading bots.json: ${err.message}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
async function runManagedAppsPm2Action(action, { regenerate = false } = {}) {
|
|
327
|
+
if (regenerate) {
|
|
328
|
+
generateEcosystemConfig({ clawOnly: false, exitOnError: false });
|
|
329
|
+
}
|
|
330
|
+
if (!storage.exists(ECOSYSTEM_FILE)) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
return execPM2CommandIgnoreMissing(action, ECOSYSTEM_FILE);
|
|
334
|
+
}
|
|
335
|
+
function cleanupStaleCredentialDaemonFiles() {
|
|
336
|
+
try {
|
|
337
|
+
safeUnlink(CREDENTIAL_SOCKET_PATH);
|
|
338
|
+
safeUnlink(CREDENTIAL_READY_FILE);
|
|
339
|
+
}
|
|
340
|
+
catch (e) {
|
|
341
|
+
// Socket files already cleaned, that's fine
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
async function ensureCredentialDaemonPM2({ forceRefresh = false, logReuse, headless = false, passwordFile = null } = {}) {
|
|
345
|
+
ensureCredentialRuntimeDirSync({ root: PATHS.PROJECT_ROOT, socketPath: CREDENTIAL_SOCKET_PATH, readyFilePath: CREDENTIAL_READY_FILE });
|
|
346
|
+
credentialPolicy.ensurePolicyConfig(POLICY_CONFIG_FILE);
|
|
347
|
+
const daemonReady = await chainKeys.isDaemonResponsive({
|
|
348
|
+
socketPath: CREDENTIAL_SOCKET_PATH,
|
|
349
|
+
readyFilePath: CREDENTIAL_READY_FILE,
|
|
350
|
+
});
|
|
351
|
+
if (daemonReady && !forceRefresh) {
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
if (!daemonReady) {
|
|
355
|
+
cleanupStaleCredentialDaemonFiles();
|
|
356
|
+
}
|
|
357
|
+
let bootstrap = null;
|
|
358
|
+
try {
|
|
359
|
+
let vaultSecret;
|
|
360
|
+
if (headless) {
|
|
361
|
+
vaultSecret = chainKeys.unlockWithPassword(readHeadlessPassword({ passwordFile }));
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
vaultSecret = await chainKeys.authenticate();
|
|
365
|
+
}
|
|
366
|
+
bootstrap = await createPasswordBootstrapServer({ secret: vaultSecret });
|
|
367
|
+
console.log(pm2Success('✓ Authentication successful'));
|
|
368
|
+
await startManagedRuntimePM2({ apps: [], bootstrap });
|
|
369
|
+
return true;
|
|
370
|
+
}
|
|
371
|
+
catch (error) {
|
|
372
|
+
if (bootstrap)
|
|
373
|
+
bootstrap.close();
|
|
374
|
+
throw error;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
async function assertActiveBotTarget(target) {
|
|
378
|
+
try {
|
|
379
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
380
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
381
|
+
if (!botExists) {
|
|
382
|
+
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
catch (err) {
|
|
386
|
+
if (String(err && err.message || '').includes('not found or not active')) {
|
|
387
|
+
throw err;
|
|
388
|
+
}
|
|
389
|
+
throw new Error(`Failed to read bots configuration: ${err.message}`);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Main application entry point for PM2 orchestration.
|
|
394
|
+
* @param {Object} [options={}] - Launcher options.
|
|
395
|
+
* @param {string|null} [options.botNameFilter=null] - Optional bot name to start.
|
|
396
|
+
* @param {boolean} [options.clawOnly=false] - Start the credential daemon only.
|
|
397
|
+
* @returns {Promise<void>}
|
|
398
|
+
*/
|
|
399
|
+
async function main({ botNameFilter = null, clawOnly = false, headless = false, passwordFile = null } = {}) {
|
|
400
|
+
if (typeof chainKeys.checkKeysFileSecurity === 'function')
|
|
401
|
+
chainKeys.checkKeysFileSecurity();
|
|
402
|
+
if (typeof credentialPolicy.checkPolicyFileSecurity === 'function')
|
|
403
|
+
credentialPolicy.checkPolicyFileSecurity(PATHS.PROFILES.DAEMON_POLICIES_JSON);
|
|
404
|
+
console.log('='.repeat(50));
|
|
405
|
+
console.log('DEXBot2 PM2 Launcher');
|
|
406
|
+
if (clawOnly) {
|
|
407
|
+
console.log('Starting credential daemon only');
|
|
408
|
+
}
|
|
409
|
+
if (botNameFilter) {
|
|
410
|
+
console.log(`Starting bot: ${botNameFilter}`);
|
|
411
|
+
}
|
|
412
|
+
if (headless) {
|
|
413
|
+
console.log('Mode: headless (non-interactive password)');
|
|
414
|
+
}
|
|
415
|
+
console.log('='.repeat(50));
|
|
416
|
+
console.log();
|
|
417
|
+
if (!clawOnly) {
|
|
418
|
+
// Step 0: Wait for BitShares connection (suppress BitShares client logs)
|
|
419
|
+
const { waitForConnected } = require('./modules/bitshares_client');
|
|
420
|
+
// Suppress BitShares console output during connection
|
|
421
|
+
const originalLog = console.log;
|
|
422
|
+
try {
|
|
423
|
+
console.log = (...args) => {
|
|
424
|
+
// Only suppress BitShares-specific messages
|
|
425
|
+
const msg = args.join(' ');
|
|
426
|
+
if (!msg.includes('bitshares_client') && !msg.includes('modules/')) {
|
|
427
|
+
originalLog(...args);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
await waitForConnected(TIMING.CONNECTION_TIMEOUT_MS);
|
|
431
|
+
}
|
|
432
|
+
finally {
|
|
433
|
+
// Always restore console output, even if waitForConnected throws
|
|
434
|
+
console.log = originalLog;
|
|
435
|
+
}
|
|
436
|
+
console.log(pm2Success('Connected to BitShares'));
|
|
437
|
+
}
|
|
438
|
+
else {
|
|
439
|
+
console.log();
|
|
440
|
+
}
|
|
441
|
+
// Step 1: Check PM2
|
|
442
|
+
if (!checkPM2Installed()) {
|
|
443
|
+
console.error(pm2Error('PM2 is not installed'));
|
|
444
|
+
await installPM2();
|
|
445
|
+
}
|
|
446
|
+
// Step 2: Ensure credential daemon availability
|
|
447
|
+
try {
|
|
448
|
+
await ensureCredentialDaemonPM2({ headless, passwordFile });
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
451
|
+
console.error(pm2Error(`\n❌ ${error.message}`));
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
// Step 3: Generate ecosystem config
|
|
455
|
+
const apps = generateEcosystemConfig({
|
|
456
|
+
botNameFilter,
|
|
457
|
+
clawOnly,
|
|
458
|
+
});
|
|
459
|
+
const botCount = countManagedBots(apps);
|
|
460
|
+
console.log(`Number active bots: ${botCount}`);
|
|
461
|
+
console.log();
|
|
462
|
+
// Step 4: Start PM2
|
|
463
|
+
console.log(clawOnly ? 'Starting PM2 with credential daemon only...' : 'Starting PM2 with all services...');
|
|
464
|
+
await startManagedAppsPM2(apps);
|
|
465
|
+
console.log();
|
|
466
|
+
console.log('='.repeat(50));
|
|
467
|
+
console.log(pm2Success('DEXBot2 started successfully!'));
|
|
468
|
+
console.log('If dexbot-cred stops, rerun `node pm2` to unlock it again.');
|
|
469
|
+
console.log('='.repeat(50));
|
|
470
|
+
console.log();
|
|
471
|
+
}
|
|
472
|
+
function startPM2Process(args, env = buildScopedChildEnv()) {
|
|
473
|
+
return new Promise((resolve, reject) => {
|
|
474
|
+
const pm2 = spawn('pm2', args, {
|
|
475
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
476
|
+
env,
|
|
477
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
478
|
+
detached: false,
|
|
479
|
+
shell: process.platform === 'win32'
|
|
480
|
+
});
|
|
481
|
+
let stdoutBuffer = '';
|
|
482
|
+
let stderrBuffer = '';
|
|
483
|
+
pm2.stdout.on('data', (data) => {
|
|
484
|
+
stdoutBuffer += data.toString();
|
|
485
|
+
stdoutBuffer = flushPm2Buffer(stdoutBuffer, (line) => console.log(line));
|
|
486
|
+
});
|
|
487
|
+
pm2.stderr.on('data', (data) => {
|
|
488
|
+
stderrBuffer += data.toString();
|
|
489
|
+
stderrBuffer = flushPm2Buffer(stderrBuffer, (line) => console.error(line));
|
|
490
|
+
});
|
|
491
|
+
pm2.on('close', (code) => {
|
|
492
|
+
stdoutBuffer = flushPm2Buffer(stdoutBuffer, (line) => console.log(line), { final: true });
|
|
493
|
+
stderrBuffer = flushPm2Buffer(stderrBuffer, (line) => console.error(line), { final: true });
|
|
494
|
+
if (code === 0) {
|
|
495
|
+
// Ensure we disconnect from PM2's file descriptors
|
|
496
|
+
setImmediate(resolve);
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
reject(new Error(`PM2 exited with code ${code}`));
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
pm2.on('error', reject);
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function startManagedAppsPM2(apps) {
|
|
506
|
+
if (!apps || apps.length === 0) {
|
|
507
|
+
return Promise.resolve();
|
|
508
|
+
}
|
|
509
|
+
return startPM2Process(['start', ECOSYSTEM_FILE]);
|
|
510
|
+
}
|
|
511
|
+
function startCredentialDaemonPM2({ credentialEnv = {} } = {}) {
|
|
512
|
+
const app = buildCredentialDaemonApp({ credentialEnv });
|
|
513
|
+
const args = [
|
|
514
|
+
'start',
|
|
515
|
+
app.script,
|
|
516
|
+
'--name', app.name,
|
|
517
|
+
'--cwd', app.cwd,
|
|
518
|
+
'--output', app.out_file,
|
|
519
|
+
'--error', app.error_file,
|
|
520
|
+
'--log-date-format', app.log_date_format,
|
|
521
|
+
'--no-autorestart',
|
|
522
|
+
];
|
|
523
|
+
return startPM2Process(args, buildScopedChildEnv({ extra: app.env }))
|
|
524
|
+
.then(() => {
|
|
525
|
+
console.log(`[PM2] App [${CREDENTIAL_DAEMON_APP_NAME}] launched`);
|
|
526
|
+
});
|
|
527
|
+
}
|
|
528
|
+
async function startManagedRuntimePM2({ apps, bootstrap = null } = {}) {
|
|
529
|
+
if (bootstrap) {
|
|
530
|
+
await execPM2CommandIgnoreMissing('delete', CREDENTIAL_DAEMON_APP_NAME);
|
|
531
|
+
// Write the bootstrap socket path to a stable file in the runtime dir.
|
|
532
|
+
// The credential daemon reads this file instead of relying on a
|
|
533
|
+
// PM2-persisted env var. Once consumed the file is deleted, so a
|
|
534
|
+
// future `pm2 restart dexbot-cred` or `pm2 resurrect` will not
|
|
535
|
+
// find it and will fall through to interactive auth.
|
|
536
|
+
const bootstrapPathFile = path.join(path.dirname(CREDENTIAL_SOCKET_PATH), '.dexbot-cred-bootstrap-path');
|
|
537
|
+
try {
|
|
538
|
+
storage.writeFile(bootstrapPathFile, bootstrap.socketPath, { mode: 0o600 });
|
|
539
|
+
}
|
|
540
|
+
catch (err) {
|
|
541
|
+
throw new Error(`Cannot write bootstrap path file at ${bootstrapPathFile}: ${err.message}. ` +
|
|
542
|
+
`The daemon needs this file to find the bootstrap socket.`);
|
|
543
|
+
}
|
|
544
|
+
// Start the daemon WITHOUT DEXBOT_CRED_BOOTSTRAP_SOCKET so PM2 never
|
|
545
|
+
// persists the one-shot temp socket path.
|
|
546
|
+
const daemonEnv = {
|
|
547
|
+
DEXBOT_CRED_DAEMON_SOCKET: CREDENTIAL_SOCKET_PATH,
|
|
548
|
+
DEXBOT_CRED_DAEMON_READY_FILE: CREDENTIAL_READY_FILE,
|
|
549
|
+
DEXBOT_CRED_BOOTSTRAP_PATH_FILE: bootstrapPathFile,
|
|
550
|
+
};
|
|
551
|
+
await startCredentialDaemonPM2({ credentialEnv: daemonEnv });
|
|
552
|
+
await Promise.all([
|
|
553
|
+
bootstrap.waitForTransfer(),
|
|
554
|
+
chainKeys.waitForDaemon(TIMING.DAEMON_STARTUP_TIMEOUT_MS, {
|
|
555
|
+
socketPath: CREDENTIAL_SOCKET_PATH,
|
|
556
|
+
readyFilePath: CREDENTIAL_READY_FILE,
|
|
557
|
+
}),
|
|
558
|
+
]);
|
|
559
|
+
}
|
|
560
|
+
await startManagedAppsPM2(apps);
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Check if PM2 is installed locally or globally.
|
|
564
|
+
* @returns {boolean} True if PM2 is found.
|
|
565
|
+
*/
|
|
566
|
+
function checkPM2Installed() {
|
|
567
|
+
try {
|
|
568
|
+
require.resolve('pm2');
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
571
|
+
catch (e) {
|
|
572
|
+
// Check if pm2 is available in PATH
|
|
573
|
+
const { execSync } = require('child_process');
|
|
574
|
+
try {
|
|
575
|
+
execSync('pm2 --version', { stdio: 'ignore' });
|
|
576
|
+
return true;
|
|
577
|
+
}
|
|
578
|
+
catch (err) {
|
|
579
|
+
return false;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Prompt the user to install PM2 globally.
|
|
585
|
+
* @returns {Promise<void>}
|
|
586
|
+
*/
|
|
587
|
+
async function installPM2() {
|
|
588
|
+
const readline = require('readline');
|
|
589
|
+
const { spawn } = require('child_process');
|
|
590
|
+
const rl = readline.createInterface({
|
|
591
|
+
input: process.stdin,
|
|
592
|
+
output: process.stdout
|
|
593
|
+
});
|
|
594
|
+
return new Promise((resolve, reject) => {
|
|
595
|
+
rl.question('PM2 is not installed. Install now? (Y/n): ', (answer) => {
|
|
596
|
+
rl.close();
|
|
597
|
+
if (answer.toLowerCase() === 'n') {
|
|
598
|
+
console.log('PM2 installation cancelled. Run: npm install -g pm2');
|
|
599
|
+
process.exit(1);
|
|
600
|
+
}
|
|
601
|
+
console.log('Installing PM2...');
|
|
602
|
+
// Helper to run installation command
|
|
603
|
+
const runInstall = (command, args) => {
|
|
604
|
+
return new Promise((res, rej) => {
|
|
605
|
+
const proc = spawn(command, args, {
|
|
606
|
+
stdio: 'inherit',
|
|
607
|
+
shell: process.platform === 'win32'
|
|
608
|
+
});
|
|
609
|
+
proc.on('close', (code) => {
|
|
610
|
+
if (code === 0)
|
|
611
|
+
res();
|
|
612
|
+
else
|
|
613
|
+
rej(code);
|
|
614
|
+
});
|
|
615
|
+
proc.on('error', (err) => rej(err));
|
|
616
|
+
});
|
|
617
|
+
};
|
|
618
|
+
// Try standard install first
|
|
619
|
+
runInstall('npm', ['install', '-g', 'pm2'])
|
|
620
|
+
.then(() => {
|
|
621
|
+
console.log(pm2Success('PM2 installed successfully!'));
|
|
622
|
+
resolve();
|
|
623
|
+
})
|
|
624
|
+
.catch((err) => {
|
|
625
|
+
// If failed and not on Windows, try sudo
|
|
626
|
+
if (process.platform !== 'win32') {
|
|
627
|
+
console.log('\nStandard installation failed (likely permissions). Trying with sudo...');
|
|
628
|
+
console.log('This covers Linux and macOS. Please enter your password if prompted:');
|
|
629
|
+
runInstall('sudo', ['npm', 'install', '-g', 'pm2'])
|
|
630
|
+
.then(() => {
|
|
631
|
+
console.log(pm2Success('PM2 installed successfully with sudo!'));
|
|
632
|
+
resolve();
|
|
633
|
+
})
|
|
634
|
+
.catch((finalErr) => {
|
|
635
|
+
reject(new Error('PM2 installation failed even with sudo'));
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
// Windows handling
|
|
640
|
+
console.log('\nStandard installation failed (likely permissions).');
|
|
641
|
+
console.log('Attempting to install with Administrator privileges...');
|
|
642
|
+
console.log('Please accept the UAC dialog to proceed.');
|
|
643
|
+
// Run npm install in a new elevated window
|
|
644
|
+
// We use timeout so the user can see the result before window closes
|
|
645
|
+
const psCommand = "Start-Process cmd -ArgumentList '/c npm install -g pm2 & echo. & echo Installation complete. Closing in 5 seconds... & timeout /t 5' -Verb RunAs -Wait";
|
|
646
|
+
runInstall('powershell', ['-Command', psCommand])
|
|
647
|
+
.then(() => {
|
|
648
|
+
// Verify installation succeeded since we can't easily get the exit code from the elevated process
|
|
649
|
+
if (checkPM2Installed()) {
|
|
650
|
+
console.log(pm2Success('PM2 installed successfully (Elevated)!'));
|
|
651
|
+
resolve();
|
|
652
|
+
}
|
|
653
|
+
else {
|
|
654
|
+
reject(new Error('PM2 installation failed or was cancelled in the elevated window.'));
|
|
655
|
+
}
|
|
656
|
+
})
|
|
657
|
+
.catch((winErr) => {
|
|
658
|
+
console.error(pm2Error('\nFailed to elevate permissions.'));
|
|
659
|
+
console.error(pm2Error('Please manually run "npm install -g pm2" as Administrator.'));
|
|
660
|
+
reject(new Error('PM2 installation failed.'));
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Execute a PM2 command safely.
|
|
669
|
+
* @param {string} action - PM2 action (start, stop, etc.).
|
|
670
|
+
* @param {string} [target] - The target process name or configuration file.
|
|
671
|
+
* @param {Object} [options] - Execution options
|
|
672
|
+
* @param {boolean} [options.suppressStderrOnError=false] - Suppress stderr on failure
|
|
673
|
+
* @param {boolean} [options.silent=false] - Suppress stdout output
|
|
674
|
+
* @returns {Promise<Object>} Command result.
|
|
675
|
+
* @throws {Error} If action is invalid or command fails.
|
|
676
|
+
*/
|
|
677
|
+
async function execPM2Command(action, target, { suppressStderrOnError = false, silent = false } = {}) {
|
|
678
|
+
// Validate action to prevent injection
|
|
679
|
+
const validActions = ['start', 'stop', 'delete', 'restart'];
|
|
680
|
+
if (!validActions.includes(action)) {
|
|
681
|
+
throw new Error(`Invalid PM2 action: ${action}`);
|
|
682
|
+
}
|
|
683
|
+
// Use spawn instead of shell to avoid injection vulnerabilities
|
|
684
|
+
// spawn passes arguments as array, preventing shell interpretation
|
|
685
|
+
return new Promise((resolve, reject) => {
|
|
686
|
+
const args = [action];
|
|
687
|
+
if (target) {
|
|
688
|
+
args.push(target);
|
|
689
|
+
}
|
|
690
|
+
const { spawn } = require('child_process');
|
|
691
|
+
const pm2 = spawn('pm2', args, {
|
|
692
|
+
stdio: 'pipe',
|
|
693
|
+
shell: process.platform === 'win32'
|
|
694
|
+
});
|
|
695
|
+
let stdout = '';
|
|
696
|
+
let stderr = '';
|
|
697
|
+
let stdoutBuffer = '';
|
|
698
|
+
pm2.stdout.on('data', (data) => {
|
|
699
|
+
stdout += data.toString();
|
|
700
|
+
if (!silent) {
|
|
701
|
+
stdoutBuffer += data.toString();
|
|
702
|
+
stdoutBuffer = flushPm2Buffer(stdoutBuffer, (line) => console.log(line));
|
|
703
|
+
}
|
|
704
|
+
});
|
|
705
|
+
pm2.stderr.on('data', (data) => {
|
|
706
|
+
stderr += data.toString();
|
|
707
|
+
});
|
|
708
|
+
pm2.on('close', (code) => {
|
|
709
|
+
if (!silent) {
|
|
710
|
+
stdoutBuffer = flushPm2Buffer(stdoutBuffer, (line) => console.log(line), { final: true });
|
|
711
|
+
}
|
|
712
|
+
if (code === 0) {
|
|
713
|
+
resolve({ success: true, stdout, stderr });
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
if (stderr && !suppressStderrOnError)
|
|
717
|
+
console.error(stderr);
|
|
718
|
+
reject(new Error(`PM2 command failed with code ${code}: ${stderr || stdout}`));
|
|
719
|
+
}
|
|
720
|
+
});
|
|
721
|
+
pm2.on('error', reject);
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
async function execPM2CommandIgnoreMissing(action, target, options = {}) {
|
|
725
|
+
try {
|
|
726
|
+
await execPM2Command(action, target, { suppressStderrOnError: true, ...options });
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
catch (error) {
|
|
730
|
+
const message = String(error && error.message ? error.message : error);
|
|
731
|
+
if (message.includes('Process or Namespace') || message.includes('not found') || message.includes('does not exist')) {
|
|
732
|
+
return false;
|
|
733
|
+
}
|
|
734
|
+
throw error;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Stop PM2 processes based on target.
|
|
739
|
+
* @param {string} target - 'all' or specific bot name.
|
|
740
|
+
* @returns {Promise<void>}
|
|
741
|
+
* @throws {Error} If target not found or stopping fails.
|
|
742
|
+
*/
|
|
743
|
+
async function stopPM2Processes(target) {
|
|
744
|
+
console.log(`Stopping PM2 processes: ${target}`);
|
|
745
|
+
if (target === 'all') {
|
|
746
|
+
console.log('');
|
|
747
|
+
// Stop credential daemon first — it holds the only handle to keys.
|
|
748
|
+
// If managed apps were stopped first they'd lose key access; this order
|
|
749
|
+
// ensures the daemon is the last process released.
|
|
750
|
+
await execPM2CommandIgnoreMissing('stop', CREDENTIAL_DAEMON_APP_NAME);
|
|
751
|
+
if (storage.exists(ECOSYSTEM_FILE)) {
|
|
752
|
+
await runManagedAppsPm2Action('stop');
|
|
753
|
+
}
|
|
754
|
+
else if (storage.exists(BOTS_JSON)) {
|
|
755
|
+
try {
|
|
756
|
+
await runManagedAppsPm2Action('stop', { regenerate: true });
|
|
757
|
+
}
|
|
758
|
+
catch (err) {
|
|
759
|
+
console.warn(`Skipping managed bot stop: ${err.message}`);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
console.log('');
|
|
763
|
+
console.log('All dexbot PM2 processes stopped.');
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (target === CREDENTIAL_DAEMON_APP_NAME) {
|
|
767
|
+
await execPM2CommandIgnoreMissing('stop', CREDENTIAL_DAEMON_APP_NAME);
|
|
768
|
+
console.log(`PM2 process '${target}' stopped.`);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
// Validate bot exists in configuration before stopping (with lock protection)
|
|
772
|
+
try {
|
|
773
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
774
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
775
|
+
if (!botExists) {
|
|
776
|
+
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
catch (err) {
|
|
780
|
+
throw new Error(`Failed to read bots configuration: ${err.message}`);
|
|
781
|
+
}
|
|
782
|
+
// Stop specific bot by name
|
|
783
|
+
await execPM2Command('stop', target);
|
|
784
|
+
console.log(`PM2 process '${target}' stopped.`);
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* Delete PM2 processes based on target.
|
|
788
|
+
* @param {string} target - 'all' or specific bot name.
|
|
789
|
+
* @returns {Promise<void>}
|
|
790
|
+
* @throws {Error} If target not found or deleting fails.
|
|
791
|
+
*/
|
|
792
|
+
async function deletePM2Processes(target) {
|
|
793
|
+
console.log(`Deleting PM2 processes: ${target}`);
|
|
794
|
+
if (target === 'all') {
|
|
795
|
+
console.log('');
|
|
796
|
+
await execPM2CommandIgnoreMissing('delete', CREDENTIAL_DAEMON_APP_NAME);
|
|
797
|
+
if (storage.exists(ECOSYSTEM_FILE)) {
|
|
798
|
+
await runManagedAppsPm2Action('delete');
|
|
799
|
+
}
|
|
800
|
+
else if (storage.exists(BOTS_JSON)) {
|
|
801
|
+
try {
|
|
802
|
+
await runManagedAppsPm2Action('delete', { regenerate: true });
|
|
803
|
+
}
|
|
804
|
+
catch (err) {
|
|
805
|
+
console.warn(`Skipping managed bot delete: ${err.message}`);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
console.log('');
|
|
809
|
+
console.log('All dexbot PM2 processes deleted.');
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
else {
|
|
813
|
+
if (target === CREDENTIAL_DAEMON_APP_NAME) {
|
|
814
|
+
await execPM2CommandIgnoreMissing('delete', CREDENTIAL_DAEMON_APP_NAME);
|
|
815
|
+
console.log(`PM2 process '${target}' deleted.`);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
// Validate bot exists in configuration before deleting (with lock protection)
|
|
819
|
+
try {
|
|
820
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
821
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
822
|
+
if (!botExists) {
|
|
823
|
+
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
catch (err) {
|
|
827
|
+
throw new Error(`Failed to read bots configuration: ${err.message}`);
|
|
828
|
+
}
|
|
829
|
+
// Delete specific bot by name
|
|
830
|
+
await execPM2Command('delete', target);
|
|
831
|
+
console.log(`PM2 process '${target}' deleted.`);
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
async function restartPM2Processes(target, { headless = false, passwordFile = null } = {}) {
|
|
835
|
+
console.log(`Restarting PM2 processes: ${target}`);
|
|
836
|
+
if (target === 'all') {
|
|
837
|
+
generateEcosystemConfig({ clawOnly: false, exitOnError: false });
|
|
838
|
+
await ensureCredentialDaemonPM2({ logReuse: false, headless, passwordFile });
|
|
839
|
+
await runManagedAppsPm2Action('restart');
|
|
840
|
+
console.log('Managed dexbot PM2 apps restarted. dexbot-cred was left on the safe wrapper path.');
|
|
841
|
+
return;
|
|
842
|
+
}
|
|
843
|
+
if (target === CREDENTIAL_DAEMON_APP_NAME) {
|
|
844
|
+
await ensureCredentialDaemonPM2({ forceRefresh: true, logReuse: false, headless, passwordFile });
|
|
845
|
+
console.log(`Credential daemon '${target}' restarted with a fresh unlock.`);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
await assertActiveBotTarget(target);
|
|
849
|
+
await ensureCredentialDaemonPM2({ logReuse: false, headless, passwordFile });
|
|
850
|
+
await execPM2Command('restart', target);
|
|
851
|
+
console.log(`PM2 process '${target}' restarted.`);
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Show help text for PM2 CLI usage.
|
|
855
|
+
*/
|
|
856
|
+
function showPM2Help() {
|
|
857
|
+
console.log(`
|
|
858
|
+
Usage: node pm2 [--headless] [--password-file <path>] [<target>]
|
|
859
|
+
|
|
860
|
+
Commands:
|
|
861
|
+
(default) Unlock keystore and start all bots with PM2
|
|
862
|
+
claw-only Start only the credential daemon with PM2
|
|
863
|
+
update Run the update script immediately
|
|
864
|
+
stop <bot-name|all> Stop PM2 process(es) - only dexbot processes
|
|
865
|
+
delete <bot-name|all> Delete PM2 process(es) - only dexbot processes
|
|
866
|
+
restart <bot-name|all|dexbot-cred>
|
|
867
|
+
Restart managed apps safely; dexbot-cred uses fresh unlock flow
|
|
868
|
+
help Show this help message
|
|
869
|
+
|
|
870
|
+
Flags:
|
|
871
|
+
--headless Non-interactive unlock (requires DEXBOT_MASTER_PASSWORD env var
|
|
872
|
+
or --password-file)
|
|
873
|
+
--password-file <path> Read master password from file (first line)
|
|
874
|
+
|
|
875
|
+
Examples:
|
|
876
|
+
node pm2 # Start all bots (unlock + start)
|
|
877
|
+
node pm2 claw-only # Start only the credential daemon
|
|
878
|
+
node pm2 <bot-name> # Start a single bot
|
|
879
|
+
node pm2 --headless # Start all bots (non-interactive)
|
|
880
|
+
node pm2 --password-file /run/secrets/bot-password
|
|
881
|
+
# Start all bots with password from file
|
|
882
|
+
node pm2 stop all # Stop all dexbot processes
|
|
883
|
+
node pm2 stop XRP-BTS # Stop specific bot
|
|
884
|
+
node pm2 delete all # Delete all dexbot processes from PM2
|
|
885
|
+
node pm2 delete XRP-BTS # Delete specific bot from PM2
|
|
886
|
+
node pm2 restart all # Safe restart path for managed apps
|
|
887
|
+
node pm2 restart dexbot-cred # Re-unlock credential daemon
|
|
888
|
+
|
|
889
|
+
node pm2 help # Show help
|
|
890
|
+
`);
|
|
891
|
+
}
|
|
892
|
+
// Run if called directly or via the root-level pm2.js shim
|
|
893
|
+
const isPm2DirectRun = require.main === module || (process.argv[1] &&
|
|
894
|
+
path.basename(process.argv[1]).replace(/\.js$/, '') === 'pm2');
|
|
895
|
+
if (isPm2DirectRun) {
|
|
896
|
+
// Parse command line arguments
|
|
897
|
+
const { command, target, clawOnly, headless, passwordFile } = parsePm2Args(process.argv);
|
|
898
|
+
(async () => {
|
|
899
|
+
try {
|
|
900
|
+
if (!command) {
|
|
901
|
+
// Full setup: unlock, generate config, authenticate, start PM2
|
|
902
|
+
// Optional: filter to specific bot if provided
|
|
903
|
+
await main({ botNameFilter: target || null, clawOnly, headless, passwordFile });
|
|
904
|
+
// Close stdin to prevent hanging
|
|
905
|
+
if (process.stdin)
|
|
906
|
+
process.stdin.destroy();
|
|
907
|
+
process.exit(0);
|
|
908
|
+
}
|
|
909
|
+
else if (command === 'claw-only') {
|
|
910
|
+
await main({ clawOnly: true, headless, passwordFile });
|
|
911
|
+
// Close stdin to prevent hanging
|
|
912
|
+
if (process.stdin)
|
|
913
|
+
process.stdin.destroy();
|
|
914
|
+
process.exit(0);
|
|
915
|
+
}
|
|
916
|
+
else if (command === 'update') {
|
|
917
|
+
const { spawn } = require('child_process');
|
|
918
|
+
const update = spawn(Config.EXEC_PATH, [runtimeScript('scripts', 'update.js')], { stdio: 'inherit' });
|
|
919
|
+
update.on('close', (code) => process.exit(code));
|
|
920
|
+
}
|
|
921
|
+
else if (command === 'stop') {
|
|
922
|
+
if (!target) {
|
|
923
|
+
console.error(pm2Error('Error: Target required. Specify bot name or "all".'));
|
|
924
|
+
showPM2Help();
|
|
925
|
+
process.exit(1);
|
|
926
|
+
}
|
|
927
|
+
try {
|
|
928
|
+
await stopPM2Processes(target);
|
|
929
|
+
process.exit(0);
|
|
930
|
+
}
|
|
931
|
+
catch (err) {
|
|
932
|
+
console.error(pm2Error(`Failed to stop processes: ${err.message}`));
|
|
933
|
+
process.exit(1);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
else if (command === 'delete') {
|
|
937
|
+
if (!target) {
|
|
938
|
+
console.error(pm2Error('Error: Target required. Specify bot name or "all".'));
|
|
939
|
+
showPM2Help();
|
|
940
|
+
process.exit(1);
|
|
941
|
+
}
|
|
942
|
+
try {
|
|
943
|
+
await deletePM2Processes(target);
|
|
944
|
+
process.exit(0);
|
|
945
|
+
}
|
|
946
|
+
catch (err) {
|
|
947
|
+
console.error(pm2Error(`Failed to delete processes: ${err.message}`));
|
|
948
|
+
process.exit(1);
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
else if (command === 'restart') {
|
|
952
|
+
if (!target) {
|
|
953
|
+
console.error(pm2Error('Error: Target required. Specify bot name, "dexbot-cred", or "all".'));
|
|
954
|
+
showPM2Help();
|
|
955
|
+
process.exit(1);
|
|
956
|
+
}
|
|
957
|
+
try {
|
|
958
|
+
await restartPM2Processes(target, { headless, passwordFile });
|
|
959
|
+
process.exit(0);
|
|
960
|
+
}
|
|
961
|
+
catch (err) {
|
|
962
|
+
console.error(pm2Error(`Failed to restart processes: ${err.message}`));
|
|
963
|
+
process.exit(1);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
else if (command === 'help') {
|
|
967
|
+
showPM2Help();
|
|
968
|
+
process.exit(0);
|
|
969
|
+
}
|
|
970
|
+
else {
|
|
971
|
+
console.error(pm2Error(`Unknown command: ${command}`));
|
|
972
|
+
showPM2Help();
|
|
973
|
+
process.exit(1);
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
catch (err) {
|
|
977
|
+
console.error(pm2Error(`Error: ${err.message}`));
|
|
978
|
+
process.exit(1);
|
|
979
|
+
}
|
|
980
|
+
})();
|
|
981
|
+
}
|
|
982
|
+
module.exports = {
|
|
983
|
+
buildCredentialDaemonApp,
|
|
984
|
+
buildEcosystemApps,
|
|
985
|
+
buildScopedChildEnv,
|
|
986
|
+
countManagedBots,
|
|
987
|
+
deletePM2Processes,
|
|
988
|
+
ensureCredentialDaemonPM2,
|
|
989
|
+
generateEcosystemConfig,
|
|
990
|
+
isServiceApp,
|
|
991
|
+
main,
|
|
992
|
+
needsMarketAdapter,
|
|
993
|
+
restartPM2Processes,
|
|
994
|
+
stopPM2Processes,
|
|
995
|
+
startManagedRuntimePM2,
|
|
996
|
+
usesAmaGridPrice
|
|
997
|
+
};
|
|
998
|
+
//# sourceMappingURL=pm2.js.map
|