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/unlock.js
ADDED
|
@@ -0,0 +1,925 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// node-only entry point — credential daemon launcher (Unix socket, child_process, fs)
|
|
4
|
+
/**
|
|
5
|
+
* unlock.ts - Credential Daemon Launcher
|
|
6
|
+
*
|
|
7
|
+
* Starts credential daemon with master password and launches the bot process.
|
|
8
|
+
*
|
|
9
|
+
* Default mode: daemonizes to background and auto-restarts on crash.
|
|
10
|
+
* Use --foreground to run in terminal (no auto-restart).
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* node unlock Background + auto-restart (default)
|
|
14
|
+
* node unlock --foreground Terminal mode (no auto-restart)
|
|
15
|
+
* node unlock claw-only
|
|
16
|
+
* node unlock --claw-only
|
|
17
|
+
* node unlock --isolated
|
|
18
|
+
* node unlock --isolated <botName>
|
|
19
|
+
* node unlock --dryrun
|
|
20
|
+
* node unlock --dryrun <botName>
|
|
21
|
+
* node unlock --headless Non-interactive (requires env var or --password-file)
|
|
22
|
+
* node unlock --headless --password-file <path>
|
|
23
|
+
* node unlock status, stat
|
|
24
|
+
* node unlock stop
|
|
25
|
+
* node unlock restart
|
|
26
|
+
* node unlock delete
|
|
27
|
+
*
|
|
28
|
+
* Environment:
|
|
29
|
+
* BOT_NAME Fallback bot name when none is given as positional arg
|
|
30
|
+
* DEXBOT_MASTER_PASSWORD Master password for --headless mode (less secure than file)
|
|
31
|
+
*/
|
|
32
|
+
const { setUmask } = require('./modules/config');
|
|
33
|
+
setUmask(0o077);
|
|
34
|
+
const fs = require('fs');
|
|
35
|
+
const { path } = require('./modules/path_api');
|
|
36
|
+
const { getStorage } = require('./modules/storage');
|
|
37
|
+
const storage = getStorage();
|
|
38
|
+
const { spawn } = require('child_process');
|
|
39
|
+
const { createCredentialDaemonController } = require('./modules/launcher/credential_daemon');
|
|
40
|
+
const { buildScopedChildEnv } = require('./modules/launcher/child_env');
|
|
41
|
+
const { parseUnlockArgs } = require('./modules/launcher/launch_modes');
|
|
42
|
+
const { UPDATER, LAUNCHER, MARKET_ADAPTER, BUILD_DIR } = require('./modules/constants');
|
|
43
|
+
const { runtime } = require('./modules/runtime');
|
|
44
|
+
const { PATHS } = require('./modules/paths');
|
|
45
|
+
const { buildRuntimeScriptArgs, buildRuntimeScriptPath } = require('./modules/launcher/runtime_entry');
|
|
46
|
+
const { createBotSupervisor, SOCKET_PATH, forwardSignal, isPidAlive, waitForPidExit, readProcArgs, readProcCwd, normalizeProcScriptArg, isNodeProcessWithExactScript, candidateRuntimeScriptPaths, scriptPathForRoot, readMarketAdapterLockPid, stopMarketAdapterFromLock, usesAmaGridPrice, waitForChildSpawn, getChildRSS, formatUptime, } = require('./modules/launcher/bot_supervisor');
|
|
47
|
+
const { sendControlCommand } = require('./modules/launcher/supervisor_control');
|
|
48
|
+
const { registerCleanup, setupGracefulShutdown } = require('./modules/graceful_shutdown');
|
|
49
|
+
const { getCredentialReadyFilePath, getCredentialSocketPath } = require('./modules/credential_runtime');
|
|
50
|
+
const foreignCredDaemon = require('./modules/launcher/foreign_cred_daemon');
|
|
51
|
+
const { normalizeBotEntry, resolveRawBotEntries, loadSettingsFile } = require('./modules/bot_settings');
|
|
52
|
+
const chainKeys = require('./modules/chain_keys');
|
|
53
|
+
const credentialPolicy = require('./modules/credential_policy');
|
|
54
|
+
const { getWhitelistFlags } = require('./modules/market_adapter_whitelist');
|
|
55
|
+
const { ensureDir, readJSON, safeUnlink, writeJSON } = require('./modules/utils/fs_utils');
|
|
56
|
+
const { createMarketAdapterWatchdog } = require('./modules/launcher/market_adapter_watchdog');
|
|
57
|
+
const { isLikelyMarketAdapterProcess } = require('./modules/launcher/market_adapter_runtime');
|
|
58
|
+
const { statusTitle, statusLabel, statusBool, statusActiveBotName, statusSuccess, statusError, colorStatus, STATUS_COLORS, readProcStat, readProcMemMB, readProcCpuTime, readProcCpuPercent, readProcCmdline, readProcUptime, formatControlUptime, formatMemoryWithUptime, printControlStatus, } = require('./modules/launcher/status_reporting');
|
|
59
|
+
const { MONOLITHIC_PID_FILE, MONOLITHIC_BOT_PID_FILE, MONOLITHIC_BOT_INFO_FILE, MONOLITHIC_CRED_PID_FILE, MONOLITHIC_OUT_LOG, MONOLITHIC_ERROR_LOG, CREDENTIAL_SOCKET_FILE, CREDENTIAL_READY_FILE, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isLikelyUnlockProcess, isLikelyDexbotProcess, isExpectedMonolithicBotPid, isExpectedProcessStarttime, stopCredentialDaemonPid, cleanupCredentialRuntimeFiles, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, readCredentialDaemonStatus, ensureLogDir: ensureMonolithicLogDir, buildDexbotStartArgs, createUpdateScheduler, listConfiguredBots, getAllControlBotNames, getControlBotNames, getControlActionLabel, getControlServiceNames, printControlActionSummary, formatBotCount, } = require('./modules/launcher/monolithic_runtime');
|
|
60
|
+
const { Config } = require('./modules/config');
|
|
61
|
+
// Auto-migrate bot state files from old stable-ID key format to sanitized-name format
|
|
62
|
+
try {
|
|
63
|
+
const { runMigration } = require('./scripts/migrate_bot_keys');
|
|
64
|
+
runMigration();
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
console.error(`Migration error: ${err?.message || err}`);
|
|
68
|
+
}
|
|
69
|
+
const CODE_ROOT = __dirname;
|
|
70
|
+
const ROOT = PATHS.PROJECT_ROOT;
|
|
71
|
+
const BOTS_FILE = PATHS.PROFILES.BOTS_JSON;
|
|
72
|
+
const LOGS_DIR = PATHS.LOGS_DIR;
|
|
73
|
+
const SUPERVISOR_OUT_LOG = path.join(LOGS_DIR, 'supervisor.log');
|
|
74
|
+
const SUPERVISOR_ERROR_LOG = path.join(LOGS_DIR, 'supervisor-error.log');
|
|
75
|
+
const controller = createCredentialDaemonController({ root: PATHS.PROJECT_ROOT, codeRoot: CODE_ROOT });
|
|
76
|
+
const DEFAULT_STARTUP_GRACE_MS = 750;
|
|
77
|
+
const botProcessRef = { current: null };
|
|
78
|
+
function printLauncherHeader({ botName = null, clawOnly = false, isolated = false, dryrun = false, headless = false } = {}) {
|
|
79
|
+
console.log('='.repeat(50));
|
|
80
|
+
console.log('DEXBot2 Unlock Launcher');
|
|
81
|
+
if (dryrun)
|
|
82
|
+
console.log('Mode: dryrun (no transactions)');
|
|
83
|
+
if (isolated)
|
|
84
|
+
console.log('Mode: isolated (per-bot processes)');
|
|
85
|
+
if (headless)
|
|
86
|
+
console.log('Mode: headless (non-interactive password)');
|
|
87
|
+
if (clawOnly) {
|
|
88
|
+
console.log('Starting credential daemon only');
|
|
89
|
+
}
|
|
90
|
+
else if (botName) {
|
|
91
|
+
console.log(`Starting bot: ${botName}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
console.log('Starting all bots');
|
|
95
|
+
}
|
|
96
|
+
console.log('='.repeat(50));
|
|
97
|
+
console.log();
|
|
98
|
+
}
|
|
99
|
+
function printLauncherStartupSummary({ botNames, mode }) {
|
|
100
|
+
console.log('='.repeat(50));
|
|
101
|
+
console.log(`DEXBot2 started ${formatBotCount(botNames.length)} in ${mode}`);
|
|
102
|
+
console.log();
|
|
103
|
+
for (const botName of botNames) {
|
|
104
|
+
console.log(`- ${statusActiveBotName(botName)}`);
|
|
105
|
+
}
|
|
106
|
+
console.log('='.repeat(50));
|
|
107
|
+
}
|
|
108
|
+
function printLauncherSuccess({ botName = null, clawOnly = false, isolated = false } = {}) {
|
|
109
|
+
console.log();
|
|
110
|
+
console.log('='.repeat(50));
|
|
111
|
+
if (clawOnly) {
|
|
112
|
+
console.log(statusSuccess('DEXBot2 credential daemon started successfully!'));
|
|
113
|
+
console.log('If the daemon stops, rerun `node unlock --claw-only` to unlock it again.');
|
|
114
|
+
}
|
|
115
|
+
else if (botName) {
|
|
116
|
+
console.log(statusSuccess('DEXBot2 started successfully!'));
|
|
117
|
+
const cmd = isolated ? `node unlock --isolated ${botName}` : `node unlock ${botName}`;
|
|
118
|
+
console.log(`If the bot stops, rerun \`${cmd}\` to unlock it again.`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.log(statusSuccess('DEXBot2 started successfully!'));
|
|
122
|
+
const cmd = isolated ? 'node unlock --isolated' : 'node unlock';
|
|
123
|
+
console.log(`If the bot stops, rerun \`${cmd}\` to unlock it again.`);
|
|
124
|
+
}
|
|
125
|
+
console.log('='.repeat(50));
|
|
126
|
+
console.log();
|
|
127
|
+
}
|
|
128
|
+
function makeFinishGuard(cleanup) {
|
|
129
|
+
let settled = false;
|
|
130
|
+
let timer = null;
|
|
131
|
+
const finish = (fn, value) => {
|
|
132
|
+
if (settled)
|
|
133
|
+
return;
|
|
134
|
+
settled = true;
|
|
135
|
+
if (timer) {
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
timer = null;
|
|
138
|
+
}
|
|
139
|
+
cleanup();
|
|
140
|
+
fn(value);
|
|
141
|
+
};
|
|
142
|
+
return { finish, getTimer: () => timer, setTimer: (t) => { timer = t; } };
|
|
143
|
+
}
|
|
144
|
+
function waitForStableChildStartup(child, { label = 'child process', timeoutMs = DEFAULT_STARTUP_GRACE_MS } = {}) {
|
|
145
|
+
if (timeoutMs <= 0) {
|
|
146
|
+
return waitForChildSpawn(child);
|
|
147
|
+
}
|
|
148
|
+
return new Promise((resolve, reject) => {
|
|
149
|
+
const handleSpawn = () => {
|
|
150
|
+
const t = setTimeout(() => finish(resolve), timeoutMs);
|
|
151
|
+
if (t && typeof t.unref === 'function') {
|
|
152
|
+
t.unref();
|
|
153
|
+
}
|
|
154
|
+
setTimer(t);
|
|
155
|
+
};
|
|
156
|
+
const handleError = (error) => finish(reject, error);
|
|
157
|
+
const handleClose = (code, signal) => {
|
|
158
|
+
finish(reject, new Error(`${label} exited during startup (exit ${code}${signal ? `, signal ${signal}` : ''})`));
|
|
159
|
+
};
|
|
160
|
+
const cleanup = () => {
|
|
161
|
+
child.off('spawn', handleSpawn);
|
|
162
|
+
child.off('error', handleError);
|
|
163
|
+
child.off('close', handleClose);
|
|
164
|
+
};
|
|
165
|
+
const { finish, setTimer } = makeFinishGuard(cleanup);
|
|
166
|
+
child.once('spawn', handleSpawn);
|
|
167
|
+
child.once('error', handleError);
|
|
168
|
+
child.once('close', handleClose);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function resolveBotEntryForName(botName) {
|
|
172
|
+
const { config } = loadSettingsFile(BOTS_FILE);
|
|
173
|
+
const raw = resolveRawBotEntries(config);
|
|
174
|
+
const match = raw.find((b) => b && b.name === botName);
|
|
175
|
+
if (!match)
|
|
176
|
+
return null;
|
|
177
|
+
const entryCopy = JSON.parse(JSON.stringify(match));
|
|
178
|
+
entryCopy.active = true;
|
|
179
|
+
return normalizeBotEntry(entryCopy);
|
|
180
|
+
}
|
|
181
|
+
function getLaunchedBotNames(botName) {
|
|
182
|
+
return botName
|
|
183
|
+
? [botName]
|
|
184
|
+
: listConfiguredBots().filter((b) => b.active).map((b) => b.name);
|
|
185
|
+
}
|
|
186
|
+
// ── Isolated supervisor mode ───────────────────────────────────────
|
|
187
|
+
function isSupervisorTransientError(err) {
|
|
188
|
+
const msg = String(err && err.message || '');
|
|
189
|
+
return msg.includes('No supervisor socket found') || msg.includes('Connection timed out');
|
|
190
|
+
}
|
|
191
|
+
function waitForSupervisorReady({ child = null, timeoutMs = 15000, intervalMs = 250 } = {}) {
|
|
192
|
+
return new Promise((resolve, reject) => {
|
|
193
|
+
const handleClose = (code, signal) => {
|
|
194
|
+
finish(reject, new Error(`supervisor exited before becoming ready (exit ${code}${signal ? `, signal ${signal}` : ''})`));
|
|
195
|
+
};
|
|
196
|
+
const handleError = (error) => finish(reject, error);
|
|
197
|
+
const cleanup = () => {
|
|
198
|
+
if (child) {
|
|
199
|
+
child.off('close', handleClose);
|
|
200
|
+
child.off('error', handleError);
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
const { finish, setTimer } = makeFinishGuard(cleanup);
|
|
204
|
+
const startedAt = Date.now();
|
|
205
|
+
const poll = async () => {
|
|
206
|
+
try {
|
|
207
|
+
await sendControlCommand({ cmd: 'status' });
|
|
208
|
+
finish(resolve, true);
|
|
209
|
+
}
|
|
210
|
+
catch (err) {
|
|
211
|
+
if (!isSupervisorTransientError(err)) {
|
|
212
|
+
finish(reject, err);
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if ((Date.now() - startedAt) >= timeoutMs) {
|
|
216
|
+
finish(resolve, false);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const t = setTimeout(poll, intervalMs);
|
|
220
|
+
if (t && typeof t.unref === 'function') {
|
|
221
|
+
t.unref();
|
|
222
|
+
}
|
|
223
|
+
setTimer(t);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
if (child) {
|
|
227
|
+
child.once('close', handleClose);
|
|
228
|
+
child.once('error', handleError);
|
|
229
|
+
}
|
|
230
|
+
poll().catch((error) => finish(reject, error));
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function ensureSupervisorLogDir() {
|
|
234
|
+
if (!storage.exists(LOGS_DIR)) {
|
|
235
|
+
ensureDir(LOGS_DIR);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
async function sendIsolatedDeleteIfAvailable() {
|
|
239
|
+
try {
|
|
240
|
+
const resp = await sendControlCommand({ cmd: 'delete' });
|
|
241
|
+
if (resp.ok && resp.status) {
|
|
242
|
+
printControlStatus(resp.status);
|
|
243
|
+
}
|
|
244
|
+
else if (resp.ok) {
|
|
245
|
+
console.log('OK');
|
|
246
|
+
}
|
|
247
|
+
return !!resp.ok;
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
if (isSupervisorTransientError(err)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
throw err;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
async function launchDetachedSupervisor({ botName = null, credentialDaemonPid = null } = {}) {
|
|
257
|
+
try {
|
|
258
|
+
await sendControlCommand({ cmd: 'status' });
|
|
259
|
+
throw new Error(`another isolated supervisor is already running at ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
if (!String(err && err.message || '').includes('No supervisor socket found')) {
|
|
263
|
+
throw err;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
ensureSupervisorLogDir();
|
|
267
|
+
const stdoutFd = storage.open(SUPERVISOR_OUT_LOG, 'a', 0o600);
|
|
268
|
+
const stderrFd = storage.open(SUPERVISOR_ERROR_LOG, 'a', 0o600);
|
|
269
|
+
const args = buildRuntimeScriptArgs({
|
|
270
|
+
codeRoot: CODE_ROOT,
|
|
271
|
+
scriptSegments: ['unlock'],
|
|
272
|
+
scriptArgs: ['--isolated', ...(botName ? [botName] : [])],
|
|
273
|
+
});
|
|
274
|
+
let child = null;
|
|
275
|
+
try {
|
|
276
|
+
child = spawn(Config.EXEC_PATH, args, {
|
|
277
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
278
|
+
detached: true,
|
|
279
|
+
env: buildScopedChildEnv({
|
|
280
|
+
extra: {
|
|
281
|
+
DEXBOT_ISOLATED_CHILD: '1',
|
|
282
|
+
...(credentialDaemonPid ? { DEXBOT_MANAGED_CRED_PID: String(credentialDaemonPid) } : {}),
|
|
283
|
+
},
|
|
284
|
+
}),
|
|
285
|
+
stdio: ['ignore', stdoutFd, stderrFd],
|
|
286
|
+
});
|
|
287
|
+
child.unref();
|
|
288
|
+
const ready = await waitForSupervisorReady({ child });
|
|
289
|
+
if (!ready) {
|
|
290
|
+
throw new Error(`supervisor did not become ready. Check ${SUPERVISOR_OUT_LOG} and ${SUPERVISOR_ERROR_LOG}`);
|
|
291
|
+
}
|
|
292
|
+
return child.pid || 0;
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
if (child && child.pid) {
|
|
296
|
+
try {
|
|
297
|
+
runtime.kill(child.pid, 'SIGTERM');
|
|
298
|
+
}
|
|
299
|
+
catch (_) { }
|
|
300
|
+
}
|
|
301
|
+
throw err;
|
|
302
|
+
}
|
|
303
|
+
finally {
|
|
304
|
+
try {
|
|
305
|
+
storage.close(stdoutFd);
|
|
306
|
+
}
|
|
307
|
+
catch (_) { }
|
|
308
|
+
try {
|
|
309
|
+
storage.close(stderrFd);
|
|
310
|
+
}
|
|
311
|
+
catch (_) { }
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
async function runIsolated({ botName, botEntry = null, stayResident = false, startupGraceMs = DEFAULT_STARTUP_GRACE_MS } = {}) {
|
|
315
|
+
let supervisor;
|
|
316
|
+
if (botName) {
|
|
317
|
+
const bot = botEntry || resolveBotEntryForName(botName);
|
|
318
|
+
if (!bot) {
|
|
319
|
+
throw new Error(`Bot '${botName}' not found in bots.json`);
|
|
320
|
+
}
|
|
321
|
+
supervisor = createBotSupervisor({ bots: [bot] });
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
supervisor = createBotSupervisor();
|
|
325
|
+
}
|
|
326
|
+
registerCleanup('Bot supervisor', () => supervisor.shutdown());
|
|
327
|
+
await supervisor.start();
|
|
328
|
+
await supervisor.waitForStableStartup({ timeoutMs: startupGraceMs });
|
|
329
|
+
printLauncherStartupSummary({ botNames: getLaunchedBotNames(botName || null), mode: 'isolated' });
|
|
330
|
+
const sigintHandler = () => supervisor.shutdownSignalHandler('SIGINT');
|
|
331
|
+
const sigtermHandler = () => supervisor.shutdownSignalHandler('SIGTERM');
|
|
332
|
+
const sigusr1Handler = () => supervisor.printStatusSummary();
|
|
333
|
+
const sigusr2Handler = () => supervisor.restartRunning();
|
|
334
|
+
process.on('SIGINT', sigintHandler);
|
|
335
|
+
process.on('SIGTERM', sigtermHandler);
|
|
336
|
+
process.on('SIGUSR1', sigusr1Handler);
|
|
337
|
+
process.on('SIGUSR2', sigusr2Handler);
|
|
338
|
+
const cleanupSignalHandlers = () => {
|
|
339
|
+
process.off('SIGINT', sigintHandler);
|
|
340
|
+
process.off('SIGTERM', sigtermHandler);
|
|
341
|
+
process.off('SIGUSR1', sigusr1Handler);
|
|
342
|
+
process.off('SIGUSR2', sigusr2Handler);
|
|
343
|
+
};
|
|
344
|
+
if (stayResident) {
|
|
345
|
+
return new Promise(() => { });
|
|
346
|
+
}
|
|
347
|
+
return new Promise((resolve, reject) => {
|
|
348
|
+
const pollStartedAt = Date.now();
|
|
349
|
+
const interval = setInterval(async () => {
|
|
350
|
+
try {
|
|
351
|
+
const status = supervisor.getStatus();
|
|
352
|
+
const running = Object.values(status).some((s) => s.status === 'running' || s.status === 'restarting' || s.status === 'starting');
|
|
353
|
+
if (!running && !supervisor.hasUserStopped()) {
|
|
354
|
+
clearInterval(interval);
|
|
355
|
+
cleanupSignalHandlers();
|
|
356
|
+
await supervisor.shutdown();
|
|
357
|
+
resolve(0);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
const elapsedMs = Date.now() - pollStartedAt;
|
|
361
|
+
if (elapsedMs >= LAUNCHER.MONOLITHIC.SUPERVISOR_POLL_TIMEOUT_MS) {
|
|
362
|
+
clearInterval(interval);
|
|
363
|
+
cleanupSignalHandlers();
|
|
364
|
+
reject(new Error(`Supervisor poll timeout after ${Math.ceil(elapsedMs / 1000)}s: ` +
|
|
365
|
+
`one or more bots are still in running/restarting/starting state`));
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
catch (err) {
|
|
369
|
+
clearInterval(interval);
|
|
370
|
+
cleanupSignalHandlers();
|
|
371
|
+
reject(err);
|
|
372
|
+
}
|
|
373
|
+
}, 1000);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
// ── Main entry point ───────────────────────────────────────────────
|
|
377
|
+
async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRACE_MS } = {}) {
|
|
378
|
+
if (typeof chainKeys.checkKeysFileSecurity === 'function')
|
|
379
|
+
chainKeys.checkKeysFileSecurity();
|
|
380
|
+
if (typeof credentialPolicy.checkPolicyFileSecurity === 'function')
|
|
381
|
+
credentialPolicy.checkPolicyFileSecurity(PATHS.PROFILES.DAEMON_POLICIES_JSON);
|
|
382
|
+
const parsed = parseUnlockArgs(argv);
|
|
383
|
+
const isDetachedSupervisorChild = Config.DEXBOT_ISOLATED_CHILD;
|
|
384
|
+
const forceForegroundIsolated = Config.DEXBOT_ISOLATED_FOREGROUND;
|
|
385
|
+
const isMonolithicBgChild = Config.DEXBOT_MONOLITHIC_BG;
|
|
386
|
+
const forceForeground = argv.includes('--foreground');
|
|
387
|
+
if (parsed.control) {
|
|
388
|
+
await handleControl(parsed.control);
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
const { botName, clawOnly, isolated, dryrun, headless, passwordFile } = parsed;
|
|
392
|
+
const selectedBot = botName ? resolveBotEntryForName(botName) : null;
|
|
393
|
+
let launchedBotNames = getLaunchedBotNames(botName);
|
|
394
|
+
const shouldStartMonolithicBackground = !clawOnly && !isolated && !isDetachedSupervisorChild && !isMonolithicBgChild && !forceForeground;
|
|
395
|
+
let daemonReleased = false;
|
|
396
|
+
if (botName && !selectedBot) {
|
|
397
|
+
throw new Error(`Bot '${botName}' not found in bots.json`);
|
|
398
|
+
}
|
|
399
|
+
if (shouldStartMonolithicBackground) {
|
|
400
|
+
const { pid } = readLiveMonolithicPid();
|
|
401
|
+
if (pid > 0) {
|
|
402
|
+
printLauncherHeader({ botName, clawOnly, isolated, dryrun, headless });
|
|
403
|
+
console.log(`DEXBot2 already running in background (PID ${pid}).`);
|
|
404
|
+
console.log('Use `node unlock stat` to inspect it, or `node unlock restart` to restart it.');
|
|
405
|
+
process.exitCode = 0;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
try {
|
|
410
|
+
if (!isDetachedSupervisorChild) {
|
|
411
|
+
printLauncherHeader({ botName, clawOnly, isolated, dryrun, headless });
|
|
412
|
+
await ensureNoForeignCredentialDaemon();
|
|
413
|
+
const daemonOpts = { detached: isolated && !forceForegroundIsolated };
|
|
414
|
+
let daemonOutFd = null;
|
|
415
|
+
let daemonErrFd = null;
|
|
416
|
+
if (!clawOnly && !isolated && !forceForeground) {
|
|
417
|
+
ensureMonolithicLogDir();
|
|
418
|
+
daemonOutFd = storage.open(MONOLITHIC_OUT_LOG, 'a', 0o600);
|
|
419
|
+
try {
|
|
420
|
+
daemonErrFd = storage.open(MONOLITHIC_ERROR_LOG, 'a', 0o600);
|
|
421
|
+
}
|
|
422
|
+
catch (_e) {
|
|
423
|
+
try {
|
|
424
|
+
storage.close(daemonOutFd);
|
|
425
|
+
}
|
|
426
|
+
catch (_) { }
|
|
427
|
+
daemonOutFd = null;
|
|
428
|
+
throw _e;
|
|
429
|
+
}
|
|
430
|
+
daemonOpts.stdio = ['ignore', daemonOutFd, daemonErrFd];
|
|
431
|
+
}
|
|
432
|
+
try {
|
|
433
|
+
const unlockedNow = await controller.ensureCredentialDaemon({
|
|
434
|
+
...daemonOpts,
|
|
435
|
+
headless,
|
|
436
|
+
passwordFile,
|
|
437
|
+
});
|
|
438
|
+
if (unlockedNow) {
|
|
439
|
+
console.log(statusSuccess('✓ Authentication successful'));
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
finally {
|
|
443
|
+
if (daemonOutFd !== null)
|
|
444
|
+
try {
|
|
445
|
+
storage.close(daemonOutFd);
|
|
446
|
+
}
|
|
447
|
+
catch (_) { }
|
|
448
|
+
if (daemonErrFd !== null)
|
|
449
|
+
try {
|
|
450
|
+
storage.close(daemonErrFd);
|
|
451
|
+
}
|
|
452
|
+
catch (_) { }
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
else if (!(await controller.isDaemonReady())) {
|
|
456
|
+
throw new Error('credential daemon is not ready for isolated supervisor startup');
|
|
457
|
+
}
|
|
458
|
+
// Background daemonization for monolithic mode (default)
|
|
459
|
+
if (shouldStartMonolithicBackground) {
|
|
460
|
+
const { pid } = readLiveMonolithicPid();
|
|
461
|
+
if (pid > 0) {
|
|
462
|
+
console.log(`DEXBot2 already running in background (PID ${pid}).`);
|
|
463
|
+
console.log('Use `node unlock stat` to inspect it, or `node unlock restart` to restart it.');
|
|
464
|
+
process.exitCode = 0;
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const credentialDaemonPid = controller.getManagedDaemonPid();
|
|
468
|
+
if (credentialDaemonPid) {
|
|
469
|
+
try {
|
|
470
|
+
storage.writeFile(MONOLITHIC_CRED_PID_FILE, String(credentialDaemonPid), { mode: 0o600 });
|
|
471
|
+
}
|
|
472
|
+
catch (_) { }
|
|
473
|
+
}
|
|
474
|
+
controller.releaseManagedDaemon();
|
|
475
|
+
daemonReleased = true;
|
|
476
|
+
ensureMonolithicLogDir();
|
|
477
|
+
const stdoutFd = storage.open(MONOLITHIC_OUT_LOG, 'a', 0o600);
|
|
478
|
+
let stderrFd;
|
|
479
|
+
try {
|
|
480
|
+
stderrFd = storage.open(MONOLITHIC_ERROR_LOG, 'a', 0o600);
|
|
481
|
+
}
|
|
482
|
+
catch (_e) {
|
|
483
|
+
try {
|
|
484
|
+
storage.close(stdoutFd);
|
|
485
|
+
}
|
|
486
|
+
catch (_) { }
|
|
487
|
+
throw _e;
|
|
488
|
+
}
|
|
489
|
+
const child = spawn(Config.EXEC_PATH, [__filename, ...argv.slice(2)], {
|
|
490
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
491
|
+
detached: true,
|
|
492
|
+
env: {
|
|
493
|
+
...process.env,
|
|
494
|
+
DEXBOT_MONOLITHIC_BG: '1',
|
|
495
|
+
...(credentialDaemonPid ? { DEXBOT_MANAGED_CRED_PID: String(credentialDaemonPid) } : {}),
|
|
496
|
+
},
|
|
497
|
+
stdio: ['ignore', stdoutFd, stderrFd],
|
|
498
|
+
});
|
|
499
|
+
child.unref();
|
|
500
|
+
storage.writeFile(MONOLITHIC_PID_FILE, String(child.pid), { mode: 0o600 });
|
|
501
|
+
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'background' });
|
|
502
|
+
process.exit(0);
|
|
503
|
+
}
|
|
504
|
+
if (clawOnly) {
|
|
505
|
+
printLauncherSuccess({ clawOnly });
|
|
506
|
+
const exitCode = await controller.waitForManagedDaemon();
|
|
507
|
+
process.exitCode = exitCode || 0;
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (isolated) {
|
|
511
|
+
if (isDetachedSupervisorChild || forceForegroundIsolated) {
|
|
512
|
+
process.exitCode = await runIsolated({
|
|
513
|
+
botName,
|
|
514
|
+
botEntry: selectedBot,
|
|
515
|
+
stayResident: isDetachedSupervisorChild,
|
|
516
|
+
startupGraceMs,
|
|
517
|
+
});
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const supervisorPid = await launchDetachedSupervisor({
|
|
521
|
+
botName,
|
|
522
|
+
credentialDaemonPid: controller.getManagedDaemonPid(),
|
|
523
|
+
});
|
|
524
|
+
controller.releaseManagedDaemon();
|
|
525
|
+
daemonReleased = true;
|
|
526
|
+
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'isolated' });
|
|
527
|
+
console.log(`Supervisor PID: ${supervisorPid}`);
|
|
528
|
+
console.log(`Control socket: ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
|
|
529
|
+
console.log(`Supervisor logs: ${SUPERVISOR_OUT_LOG}`);
|
|
530
|
+
process.exitCode = 0;
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
// Monolithic foreground mode — spawn and supervise the bot process directly
|
|
534
|
+
const updater = UPDATER.ACTIVE ? createUpdateScheduler({ botProcessRef }) : null;
|
|
535
|
+
const cancelUpdater = updater ? updater.cancel : () => { };
|
|
536
|
+
const watchdog = createMarketAdapterWatchdog({
|
|
537
|
+
codeRoot: CODE_ROOT,
|
|
538
|
+
root: PATHS.PROJECT_ROOT,
|
|
539
|
+
logsDir: LOGS_DIR,
|
|
540
|
+
});
|
|
541
|
+
const cancelWatchdog = watchdog.schedule(MONOLITHIC_ERROR_LOG);
|
|
542
|
+
let restartCount = 0;
|
|
543
|
+
let lastStartTime = 0;
|
|
544
|
+
let keepRunning = true;
|
|
545
|
+
let monolithicRestartSignalRegistered = false;
|
|
546
|
+
let pendingRestart = false;
|
|
547
|
+
const onSigusr2 = () => {
|
|
548
|
+
pendingRestart = true;
|
|
549
|
+
if (updater)
|
|
550
|
+
updater.pendingRestart = true;
|
|
551
|
+
forwardSignal(botProcessRef.current, 'SIGTERM');
|
|
552
|
+
};
|
|
553
|
+
process.on('SIGUSR2', onSigusr2);
|
|
554
|
+
monolithicRestartSignalRegistered = true;
|
|
555
|
+
try {
|
|
556
|
+
do {
|
|
557
|
+
launchedBotNames = getLaunchedBotNames(botName);
|
|
558
|
+
const dexbotArgs = buildDexbotStartArgs(botName, dryrun);
|
|
559
|
+
const botProcess = spawn(Config.EXEC_PATH, dexbotArgs, {
|
|
560
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
561
|
+
env: process.env,
|
|
562
|
+
stdio: isMonolithicBgChild ? 'pipe' : 'inherit',
|
|
563
|
+
});
|
|
564
|
+
botProcessRef.current = botProcess;
|
|
565
|
+
if (isMonolithicBgChild) {
|
|
566
|
+
try {
|
|
567
|
+
storage.writeFile(MONOLITHIC_BOT_PID_FILE, String(botProcess.pid), { mode: 0o600 });
|
|
568
|
+
}
|
|
569
|
+
catch (_) { }
|
|
570
|
+
const botStat = botProcess.pid ? readProcStat(botProcess.pid) : null;
|
|
571
|
+
try {
|
|
572
|
+
storage.writeFile(MONOLITHIC_BOT_INFO_FILE, JSON.stringify({ botName, botNames: launchedBotNames, pid: botProcess.pid, starttime: botStat?.starttime ?? null }), { mode: 0o600 });
|
|
573
|
+
}
|
|
574
|
+
catch (_) { }
|
|
575
|
+
}
|
|
576
|
+
if (isMonolithicBgChild && botProcess.stdout) {
|
|
577
|
+
const outStream = fs.createWriteStream(MONOLITHIC_OUT_LOG, { flags: 'a' });
|
|
578
|
+
const errStream = fs.createWriteStream(MONOLITHIC_ERROR_LOG, { flags: 'a' });
|
|
579
|
+
botProcess.stdout.pipe(outStream);
|
|
580
|
+
botProcess.stderr.pipe(errStream);
|
|
581
|
+
botProcess.stdout.on('error', () => { });
|
|
582
|
+
botProcess.stderr.on('error', () => { });
|
|
583
|
+
botProcess.once('close', () => {
|
|
584
|
+
try {
|
|
585
|
+
outStream.end();
|
|
586
|
+
}
|
|
587
|
+
catch (_) { }
|
|
588
|
+
try {
|
|
589
|
+
errStream.end();
|
|
590
|
+
}
|
|
591
|
+
catch (_) { }
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
lastStartTime = Date.now();
|
|
595
|
+
await waitForStableChildStartup(botProcess, { label: 'DEXBot', timeoutMs: startupGraceMs });
|
|
596
|
+
if (!updater?.pendingRestart) {
|
|
597
|
+
if (!isMonolithicBgChild) {
|
|
598
|
+
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'foreground' });
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
const onSigint = () => forwardSignal(botProcess, 'SIGINT');
|
|
602
|
+
const onSigterm = () => forwardSignal(botProcess, 'SIGTERM');
|
|
603
|
+
process.on('SIGINT', onSigint);
|
|
604
|
+
process.on('SIGTERM', onSigterm);
|
|
605
|
+
const cleanupBotHandlers = () => {
|
|
606
|
+
process.off('SIGINT', onSigint);
|
|
607
|
+
process.off('SIGTERM', onSigterm);
|
|
608
|
+
};
|
|
609
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
610
|
+
botProcess.on('error', reject);
|
|
611
|
+
botProcess.on('close', (code) => resolve(code));
|
|
612
|
+
}).catch((err) => {
|
|
613
|
+
cleanupBotHandlers();
|
|
614
|
+
throw err;
|
|
615
|
+
});
|
|
616
|
+
cleanupBotHandlers();
|
|
617
|
+
if (pendingRestart || updater?.pendingRestart) {
|
|
618
|
+
pendingRestart = false;
|
|
619
|
+
if (updater)
|
|
620
|
+
updater.pendingRestart = false;
|
|
621
|
+
console.log('Update applied, restarting bot...');
|
|
622
|
+
}
|
|
623
|
+
else if (exitCode !== 0) {
|
|
624
|
+
const uptime = Date.now() - lastStartTime;
|
|
625
|
+
if (uptime >= LAUNCHER.MONOLITHIC.minUptimeMs) {
|
|
626
|
+
restartCount = 0;
|
|
627
|
+
}
|
|
628
|
+
restartCount++;
|
|
629
|
+
if (restartCount > LAUNCHER.MONOLITHIC.maxRestarts) {
|
|
630
|
+
console.error(statusError(`Bot crashed ${LAUNCHER.MONOLITHIC.maxRestarts} times without stable uptime. Exiting.`));
|
|
631
|
+
process.exitCode = exitCode || 1;
|
|
632
|
+
keepRunning = false;
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
console.log(`Bot crashed (exit ${exitCode}), restarting in ${LAUNCHER.MONOLITHIC.restartDelayMs / 1000}s (attempt ${restartCount}/${LAUNCHER.MONOLITHIC.maxRestarts})...`);
|
|
636
|
+
await new Promise((r) => setTimeout(r, LAUNCHER.MONOLITHIC.restartDelayMs));
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
process.exitCode = 0;
|
|
641
|
+
keepRunning = false;
|
|
642
|
+
}
|
|
643
|
+
} while (keepRunning);
|
|
644
|
+
}
|
|
645
|
+
finally {
|
|
646
|
+
if (monolithicRestartSignalRegistered) {
|
|
647
|
+
process.off('SIGUSR2', onSigusr2);
|
|
648
|
+
}
|
|
649
|
+
cancelUpdater();
|
|
650
|
+
cancelWatchdog();
|
|
651
|
+
await watchdog.stop();
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
finally {
|
|
655
|
+
if (isMonolithicBgChild) {
|
|
656
|
+
cleanupStateFiles();
|
|
657
|
+
}
|
|
658
|
+
if (!isDetachedSupervisorChild && !daemonReleased) {
|
|
659
|
+
await controller.stopManagedDaemon();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
// ── Control command handling ───────────────────────────────────────
|
|
664
|
+
async function handleControl({ cmd, target }) {
|
|
665
|
+
const effectiveCmd = cmd === 'shutdown' ? 'delete' : cmd === 'stat' ? 'status' : cmd;
|
|
666
|
+
const actionLabel = getControlActionLabel(cmd);
|
|
667
|
+
if ((effectiveCmd === 'stop-all' || effectiveCmd === 'delete' || effectiveCmd === 'status' || effectiveCmd === 'restart-all') && !target) {
|
|
668
|
+
const { pid, stale } = readLiveMonolithicPid();
|
|
669
|
+
if (pid > 0) {
|
|
670
|
+
const summaryBotNames = getControlBotNames(undefined, true);
|
|
671
|
+
const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
|
|
672
|
+
if (effectiveCmd === 'restart-all') {
|
|
673
|
+
const adapterResult = await stopMarketAdapterFromLock();
|
|
674
|
+
if (adapterResult.stopped) {
|
|
675
|
+
console.log(`Stop signal sent to market adapter PID ${adapterResult.pid}`);
|
|
676
|
+
}
|
|
677
|
+
try {
|
|
678
|
+
runtime.kill(pid, 'SIGUSR2');
|
|
679
|
+
}
|
|
680
|
+
catch (err) {
|
|
681
|
+
if (err.code !== 'ESRCH')
|
|
682
|
+
throw err;
|
|
683
|
+
}
|
|
684
|
+
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (effectiveCmd === 'status') {
|
|
688
|
+
const botInfo = readMonolithicBotInfo();
|
|
689
|
+
let targetPid = pid;
|
|
690
|
+
let botPidRaw = null;
|
|
691
|
+
try {
|
|
692
|
+
botPidRaw = storage.readFile(MONOLITHIC_BOT_PID_FILE).trim();
|
|
693
|
+
}
|
|
694
|
+
catch (_) { }
|
|
695
|
+
if (botPidRaw) {
|
|
696
|
+
const bp = Number(botPidRaw);
|
|
697
|
+
if (isExpectedMonolithicBotPid(bp, botInfo)) {
|
|
698
|
+
targetPid = bp;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
const mem = readProcMemMB(targetPid);
|
|
702
|
+
const cpuTime = readProcCpuTime(targetPid);
|
|
703
|
+
const cpuPct = await readProcCpuPercent(targetPid);
|
|
704
|
+
const uptime = readProcUptime(targetPid);
|
|
705
|
+
// Prefer live bots.json (current intent) over the startup snapshot.
|
|
706
|
+
// Shows what the user configured, even if the wrapper hasn't respawned yet.
|
|
707
|
+
let displayedBots = listConfiguredBots().filter(b => b.active);
|
|
708
|
+
if (displayedBots.length === 0) {
|
|
709
|
+
if (Array.isArray(botInfo?.botNames)) {
|
|
710
|
+
displayedBots = botInfo.botNames.map((name) => ({ name: String(name) }));
|
|
711
|
+
}
|
|
712
|
+
else if (botInfo?.botName) {
|
|
713
|
+
displayedBots = [{ name: String(botInfo.botName) }];
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
let credPid = null;
|
|
717
|
+
let credForeign = false;
|
|
718
|
+
try {
|
|
719
|
+
const raw = storage.readFile(MONOLITHIC_CRED_PID_FILE).trim();
|
|
720
|
+
const n = Number(raw);
|
|
721
|
+
if (Number.isInteger(n) && n > 0)
|
|
722
|
+
credPid = n;
|
|
723
|
+
}
|
|
724
|
+
catch (_) { }
|
|
725
|
+
if (!credPid && storage.exists(CREDENTIAL_SOCKET_FILE)) {
|
|
726
|
+
const ownerPid = findCredentialSocketOwnerPid();
|
|
727
|
+
if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
|
|
728
|
+
credPid = ownerPid;
|
|
729
|
+
credForeign = true;
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
const credStatus = await readCredentialDaemonStatus(credPid);
|
|
733
|
+
console.log(statusTitle('Monolithic bot'));
|
|
734
|
+
console.log(` ${statusLabel('PID:')} ${targetPid}`);
|
|
735
|
+
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(mem, uptime)}`);
|
|
736
|
+
console.log(` ${statusLabel('CPU:')} ${cpuPct} (${statusLabel('cumulative:')} ${cpuTime})`);
|
|
737
|
+
console.log(` ${statusLabel('Bots:')} ${displayedBots.length} active`);
|
|
738
|
+
for (const b of displayedBots) {
|
|
739
|
+
console.log(` - ${statusActiveBotName(b.name)}`);
|
|
740
|
+
}
|
|
741
|
+
console.log(` ${statusTitle('Credential daemon:')}`);
|
|
742
|
+
if (credPid && credForeign) {
|
|
743
|
+
console.log(` ${statusLabel('PID:')} ${credPid} ${colorStatus('(foreign/unowned)', STATUS_COLORS.warn)}`);
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
console.log(` ${statusLabel('PID:')} ${credPid || '-'}`);
|
|
747
|
+
}
|
|
748
|
+
if (credPid && isPidAlive(credPid) && isLikelyCredentialDaemonProcess(credPid)) {
|
|
749
|
+
const credUptime = readProcUptime(credPid);
|
|
750
|
+
const credMem = readProcMemMB(credPid);
|
|
751
|
+
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(credMem, credUptime)}`);
|
|
752
|
+
console.log(` ${statusLabel('Alive:')} ${statusBool(true)}`);
|
|
753
|
+
}
|
|
754
|
+
else {
|
|
755
|
+
console.log(` ${statusLabel('Alive:')} ${statusBool(false)}`);
|
|
756
|
+
}
|
|
757
|
+
console.log(` ${statusLabel('Ready:')} ${statusBool(credStatus.ready)}`);
|
|
758
|
+
console.log(` ${statusLabel('Socket:')} ${statusBool(credStatus.socket)}`);
|
|
759
|
+
if (credForeign) {
|
|
760
|
+
console.log(` ${colorStatus('Rerun `node unlock` to detach the foreign daemon and unlock with a fresh master password.', STATUS_COLORS.warn)}`);
|
|
761
|
+
}
|
|
762
|
+
const adapterPid = readMarketAdapterLockPid();
|
|
763
|
+
const adapterAlive = adapterPid > 0 && isLikelyMarketAdapterProcess(adapterPid);
|
|
764
|
+
const amaBots = listConfiguredBots().filter(b => b.active && usesAmaGridPrice(b));
|
|
765
|
+
console.log(` ${statusTitle('Market adapter:')}`);
|
|
766
|
+
if (adapterAlive) {
|
|
767
|
+
console.log(` ${statusLabel('PID:')} ${adapterPid}`);
|
|
768
|
+
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(readProcMemMB(adapterPid), readProcUptime(adapterPid))}`);
|
|
769
|
+
}
|
|
770
|
+
else if (adapterPid > 0) {
|
|
771
|
+
console.log(` ${statusLabel('PID:')} ${adapterPid} ${colorStatus('(not alive)', STATUS_COLORS.warn)}`);
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
console.log(` ${colorStatus('(not running)', STATUS_COLORS.muted)}`);
|
|
775
|
+
}
|
|
776
|
+
function botKeyFromName(name) {
|
|
777
|
+
return String(name).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
778
|
+
}
|
|
779
|
+
console.log(` ${statusLabel('Active:')} ${formatBotCount(amaBots.length)}`);
|
|
780
|
+
for (const b of amaBots) {
|
|
781
|
+
const flags = getWhitelistFlags(botKeyFromName(b.name));
|
|
782
|
+
const indicators = [];
|
|
783
|
+
if (flags.asymmetricBounds)
|
|
784
|
+
indicators.push('range');
|
|
785
|
+
if (flags.dynamicWeight)
|
|
786
|
+
indicators.push('weight');
|
|
787
|
+
const suffix = indicators.length > 0 ? `, ${indicators.join(', ')}` : '';
|
|
788
|
+
console.log(` - ${colorStatus(b.name, STATUS_COLORS.ok)} (${b.gridPrice}${suffix})`);
|
|
789
|
+
}
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
let monolithicExited = false;
|
|
793
|
+
try {
|
|
794
|
+
runtime.kill(pid, 'SIGTERM');
|
|
795
|
+
const timeoutMs = effectiveCmd === 'delete' ? LAUNCHER.MONOLITHIC.controlStopTimeoutMs : 5000;
|
|
796
|
+
monolithicExited = await waitForPidExit(pid, timeoutMs);
|
|
797
|
+
if (!monolithicExited && effectiveCmd === 'delete') {
|
|
798
|
+
runtime.kill(pid, 'SIGKILL');
|
|
799
|
+
monolithicExited = await waitForPidExit(pid, 2000);
|
|
800
|
+
if (!monolithicExited) {
|
|
801
|
+
throw new Error(`monolithic wrapper PID ${pid} did not exit after SIGKILL`);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (effectiveCmd === 'delete') {
|
|
805
|
+
const credResult = await stopCredentialDaemon();
|
|
806
|
+
if (credResult.signaled) {
|
|
807
|
+
console.log('Stop signal sent to credential daemon');
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
catch (err) {
|
|
812
|
+
if (err.code !== 'ESRCH')
|
|
813
|
+
throw err;
|
|
814
|
+
monolithicExited = true;
|
|
815
|
+
}
|
|
816
|
+
finally {
|
|
817
|
+
if (effectiveCmd !== 'delete' || monolithicExited) {
|
|
818
|
+
cleanupStateFiles();
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
else if (stale) {
|
|
825
|
+
if (effectiveCmd === 'delete') {
|
|
826
|
+
const summaryBotNames = getControlBotNames(undefined, true);
|
|
827
|
+
const isolatedDeleted = await sendIsolatedDeleteIfAvailable();
|
|
828
|
+
const credResult = await stopCredentialDaemon();
|
|
829
|
+
if (credResult.signaled) {
|
|
830
|
+
console.log('Stop signal sent to credential daemon');
|
|
831
|
+
}
|
|
832
|
+
printControlActionSummary(actionLabel, summaryBotNames, getControlServiceNames(effectiveCmd, summaryBotNames));
|
|
833
|
+
if (isolatedDeleted || credResult.cleaned)
|
|
834
|
+
return;
|
|
835
|
+
}
|
|
836
|
+
console.log(effectiveCmd === 'delete' ? 'Removed stale monolithic PID file' : 'Monolithic bot not running (stale PID file)');
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
if (effectiveCmd === 'delete' && !target && storage.exists(MONOLITHIC_CRED_PID_FILE)) {
|
|
841
|
+
await sendIsolatedDeleteIfAvailable();
|
|
842
|
+
const credResult = await stopCredentialDaemon();
|
|
843
|
+
if (credResult.signaled) {
|
|
844
|
+
console.log('Stop signal sent to credential daemon');
|
|
845
|
+
}
|
|
846
|
+
if (credResult.cleaned) {
|
|
847
|
+
const summaryBotNames = getControlBotNames(undefined, true);
|
|
848
|
+
printControlActionSummary(actionLabel, summaryBotNames, getControlServiceNames(effectiveCmd, summaryBotNames));
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
// Fall through to isolated supervisor socket
|
|
853
|
+
const controlCmd = { cmd: effectiveCmd };
|
|
854
|
+
if (target)
|
|
855
|
+
controlCmd.bot = target;
|
|
856
|
+
try {
|
|
857
|
+
const resp = await sendControlCommand(controlCmd);
|
|
858
|
+
if (resp.ok && resp.status) {
|
|
859
|
+
printControlStatus(resp.status);
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
if (target || effectiveCmd === 'stop-all' || effectiveCmd === 'restart-all' || effectiveCmd === 'delete') {
|
|
863
|
+
const summaryBotNames = getControlBotNames(target, !target && (effectiveCmd === 'stop-all' || effectiveCmd === 'restart-all' || effectiveCmd === 'delete'));
|
|
864
|
+
const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
|
|
865
|
+
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
866
|
+
}
|
|
867
|
+
console.log('OK');
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
catch (err) {
|
|
871
|
+
if (effectiveCmd === 'delete' && !target && isSupervisorTransientError(err)) {
|
|
872
|
+
console.log('No runtime processes found.');
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
console.error(statusError(`control ${cmd}: ${err.message}`));
|
|
876
|
+
process.exitCode = 1;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
// ── Bootstrap ──────────────────────────────────────────────────────
|
|
880
|
+
const isUnlockStartDirectRun = require.main === module || (process.argv[1] &&
|
|
881
|
+
path.parse(process.argv[1]).name === 'unlock');
|
|
882
|
+
if (isUnlockStartDirectRun) {
|
|
883
|
+
setupGracefulShutdown();
|
|
884
|
+
if (Config.DEXBOT_ISOLATED_CHILD) {
|
|
885
|
+
registerCleanup('Credential daemon', () => stopCredentialDaemonPid(Config.DEXBOT_MANAGED_CRED_PID));
|
|
886
|
+
}
|
|
887
|
+
else if (Config.DEXBOT_MONOLITHIC_BG) {
|
|
888
|
+
registerCleanup('PID files', cleanupStateFiles);
|
|
889
|
+
registerCleanup('Bot process', async () => {
|
|
890
|
+
const bot = botProcessRef.current;
|
|
891
|
+
if (bot && !bot.killed) {
|
|
892
|
+
forwardSignal(bot, 'SIGTERM');
|
|
893
|
+
await Promise.race([
|
|
894
|
+
new Promise((resolve) => bot.once('close', resolve)),
|
|
895
|
+
new Promise((resolve) => setTimeout(resolve, 10000)),
|
|
896
|
+
]);
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
else {
|
|
901
|
+
registerCleanup('Credential daemon', () => controller.stopManagedDaemon());
|
|
902
|
+
}
|
|
903
|
+
(async () => {
|
|
904
|
+
try {
|
|
905
|
+
await main();
|
|
906
|
+
}
|
|
907
|
+
catch (err) {
|
|
908
|
+
console.error(statusError(`unlock failed: ${err.message || err}`));
|
|
909
|
+
process.exit(1);
|
|
910
|
+
}
|
|
911
|
+
})();
|
|
912
|
+
}
|
|
913
|
+
module.exports = {
|
|
914
|
+
buildDexbotStartArgs,
|
|
915
|
+
buildUnlockArgs: require('./modules/launcher/monolithic_runtime').buildUnlockArgs,
|
|
916
|
+
candidateRuntimeScriptPaths: require('./modules/launcher/bot_supervisor').candidateRuntimeScriptPaths,
|
|
917
|
+
ensureNoForeignCredentialDaemon,
|
|
918
|
+
findCredentialSocketOwnerPid,
|
|
919
|
+
isLikelyCredentialDaemonProcess,
|
|
920
|
+
main,
|
|
921
|
+
pidMatchesScriptCandidates: require('./modules/launcher/bot_supervisor').pidMatchesScriptCandidates,
|
|
922
|
+
waitForChildSpawn,
|
|
923
|
+
waitForStableChildStartup,
|
|
924
|
+
};
|
|
925
|
+
//# sourceMappingURL=unlock.js.map
|