dexbot 1.4.10 → 1.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/analysis/chart_utils.d.ts.map +1 -1
- package/dist/analysis/chart_utils.js +9 -18
- package/dist/analysis/chart_utils.js.map +1 -1
- package/dist/analysis/math_utils.d.ts.map +1 -1
- package/dist/analysis/math_utils.js +6 -16
- package/dist/analysis/math_utils.js.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +1 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +31 -38
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +1 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js +7 -10
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js +10 -14
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +1 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js +10 -15
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +1 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js +7 -10
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +4 -12
- package/dist/bot.js.map +1 -1
- package/dist/credential-daemon.d.ts +0 -1
- package/dist/credential-daemon.d.ts.map +1 -1
- package/dist/credential-daemon.js +3 -123
- package/dist/credential-daemon.js.map +1 -1
- package/dist/dexbot.d.ts +0 -87
- package/dist/dexbot.d.ts.map +1 -1
- package/dist/dexbot.js +54 -23
- package/dist/dexbot.js.map +1 -1
- package/dist/market_adapter/ama_signal_runner.js +8 -9
- package/dist/market_adapter/ama_signal_runner.js.map +1 -1
- package/dist/market_adapter/candle_utils.js +1 -7
- package/dist/market_adapter/candle_utils.js.map +1 -1
- package/dist/market_adapter/core/asymmetric_bounds.js +1 -4
- package/dist/market_adapter/core/asymmetric_bounds.js.map +1 -1
- package/dist/market_adapter/core/config_normalizers.js +5 -9
- package/dist/market_adapter/core/config_normalizers.js.map +1 -1
- package/dist/market_adapter/core/kibana_candles.js +8 -15
- package/dist/market_adapter/core/kibana_candles.js.map +1 -1
- package/dist/market_adapter/core/kibana_client.js +7 -13
- package/dist/market_adapter/core/kibana_client.js.map +1 -1
- package/dist/market_adapter/core/kibana_market_candles.js +6 -12
- package/dist/market_adapter/core/kibana_market_candles.js.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts +2 -0
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +1 -1
- package/dist/market_adapter/core/market_adapter_service.js +100 -101
- package/dist/market_adapter/core/market_adapter_service.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama.js +5 -10
- package/dist/market_adapter/core/strategies/ama.js.map +1 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +21 -24
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +1 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js +3 -5
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +1 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +4 -6
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +1 -1
- package/dist/market_adapter/core/strategies/regime_gate.js +15 -22
- package/dist/market_adapter/core/strategies/regime_gate.js.map +1 -1
- package/dist/market_adapter/index.d.ts +23 -23
- package/dist/market_adapter/index.d.ts.map +1 -1
- package/dist/market_adapter/index.js +24 -82
- package/dist/market_adapter/index.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +2 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +1 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js +59 -98
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +1 -1
- package/dist/market_adapter/inputs/kibana_source.js +11 -17
- package/dist/market_adapter/inputs/kibana_source.js.map +1 -1
- package/dist/market_adapter/interval_utils.js +1 -2
- package/dist/market_adapter/interval_utils.js.map +1 -1
- package/dist/market_adapter/log_format.js +1 -7
- package/dist/market_adapter/log_format.js.map +1 -1
- package/dist/market_adapter/lp_chart_core.js +20 -22
- package/dist/market_adapter/lp_chart_core.js.map +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts +1 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +1 -1
- package/dist/market_adapter/lp_chart_runner.js +41 -57
- package/dist/market_adapter/lp_chart_runner.js.map +1 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js +30 -34
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +1 -1
- package/dist/market_adapter/market_adapter.d.ts +2 -2
- package/dist/market_adapter/market_adapter.d.ts.map +1 -1
- package/dist/market_adapter/market_adapter.js +163 -222
- package/dist/market_adapter/market_adapter.js.map +1 -1
- package/dist/market_adapter/merge_lp_data.js +17 -18
- package/dist/market_adapter/merge_lp_data.js.map +1 -1
- package/dist/market_adapter/test_helpers.js +3 -14
- package/dist/market_adapter/test_helpers.js.map +1 -1
- package/dist/market_adapter/utils/adapter_client.js +7 -16
- package/dist/market_adapter/utils/adapter_client.js.map +1 -1
- package/dist/market_adapter/utils/atomic_write.js +3 -5
- package/dist/market_adapter/utils/atomic_write.js.map +1 -1
- package/dist/market_adapter/utils/chain.d.ts.map +1 -1
- package/dist/market_adapter/utils/chain.js +9 -17
- package/dist/market_adapter/utils/chain.js.map +1 -1
- package/dist/market_adapter/utils/data_discovery.js +8 -10
- package/dist/market_adapter/utils/data_discovery.js.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +1 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js +11 -14
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +1 -1
- package/dist/market_adapter/utils/file_lock.js +14 -19
- package/dist/market_adapter/utils/file_lock.js.map +1 -1
- package/dist/market_adapter/utils/native_history.js +8 -14
- package/dist/market_adapter/utils/native_history.js.map +1 -1
- package/dist/market_adapter/utils/paths.js +3 -6
- package/dist/market_adapter/utils/paths.js.map +1 -1
- package/dist/modules/account_bots.d.ts +1 -1
- package/dist/modules/account_bots.d.ts.map +1 -1
- package/dist/modules/account_bots.js +90 -97
- package/dist/modules/account_bots.js.map +1 -1
- package/dist/modules/account_orders.d.ts +0 -9
- package/dist/modules/account_orders.d.ts.map +1 -1
- package/dist/modules/account_orders.js +26 -121
- package/dist/modules/account_orders.js.map +1 -1
- package/dist/modules/authority_resolver.js +12 -18
- package/dist/modules/authority_resolver.js.map +1 -1
- package/dist/modules/bitshares-native/chain_client.js +16 -21
- package/dist/modules/bitshares-native/chain_client.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +12 -72
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -40
- package/dist/modules/bitshares-native/crypto/ecc.js.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +1 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +5 -6
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +1 -1
- package/dist/modules/bitshares-native/index.d.ts +8 -8
- package/dist/modules/bitshares-native/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/index.js +11 -68
- package/dist/modules/bitshares-native/index.js.map +1 -1
- package/dist/modules/bitshares-native/lru_cache.js +3 -6
- package/dist/modules/bitshares-native/lru_cache.js.map +1 -1
- package/dist/modules/bitshares-native/resolvers.js +9 -11
- package/dist/modules/bitshares-native/resolvers.js.map +1 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js +3 -28
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +1 -1
- package/dist/modules/bitshares-native/serial/index.d.ts +4 -4
- package/dist/modules/bitshares-native/serial/index.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/index.js +5 -46
- package/dist/modules/bitshares-native/serial/index.js.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts +98 -98
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +1 -1
- package/dist/modules/bitshares-native/serial/operations.js +372 -473
- package/dist/modules/bitshares-native/serial/operations.js.map +1 -1
- package/dist/modules/bitshares-native/serial/serializer.js +3 -8
- package/dist/modules/bitshares-native/serial/serializer.js.map +1 -1
- package/dist/modules/bitshares-native/serial/types.js +9 -74
- package/dist/modules/bitshares-native/serial/types.js.map +1 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +1 -1
- package/dist/modules/bitshares-native/signing_client.js +11 -48
- package/dist/modules/bitshares-native/signing_client.js.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +1 -1
- package/dist/modules/bitshares-native/subscriptions.js +24 -27
- package/dist/modules/bitshares-native/subscriptions.js.map +1 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +1 -1
- package/dist/modules/bitshares-native/transport.js +14 -26
- package/dist/modules/bitshares-native/transport.js.map +1 -1
- package/dist/modules/bitshares-native/tx/builder.js +29 -72
- package/dist/modules/bitshares-native/tx/builder.js.map +1 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js +12 -21
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +1 -1
- package/dist/modules/bitshares_client.d.ts +21 -0
- package/dist/modules/bitshares_client.d.ts.map +1 -1
- package/dist/modules/bitshares_client.js +32 -86
- package/dist/modules/bitshares_client.js.map +1 -1
- package/dist/modules/bot_settings.d.ts.map +1 -1
- package/dist/modules/bot_settings.js +30 -49
- package/dist/modules/bot_settings.js.map +1 -1
- package/dist/modules/bots_file_lock.d.ts.map +1 -1
- package/dist/modules/bots_file_lock.js +5 -13
- package/dist/modules/bots_file_lock.js.map +1 -1
- package/dist/modules/broadcast_failure.js +1 -3
- package/dist/modules/broadcast_failure.js.map +1 -1
- package/dist/modules/chain_keys.d.ts +4 -9
- package/dist/modules/chain_keys.d.ts.map +1 -1
- package/dist/modules/chain_keys.js +77 -182
- package/dist/modules/chain_keys.js.map +1 -1
- package/dist/modules/chain_orders.d.ts +2 -2
- package/dist/modules/chain_orders.d.ts.map +1 -1
- package/dist/modules/chain_orders.js +81 -144
- package/dist/modules/chain_orders.js.map +1 -1
- package/dist/modules/config.d.ts.map +1 -1
- package/dist/modules/config.js +23 -28
- package/dist/modules/config.js.map +1 -1
- package/dist/modules/constants.d.ts +4 -14
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +46 -78
- package/dist/modules/constants.js.map +1 -1
- package/dist/modules/cr_planner.js +15 -26
- package/dist/modules/cr_planner.js.map +1 -1
- package/dist/modules/credential_policy.d.ts +3 -6
- package/dist/modules/credential_policy.d.ts.map +1 -1
- package/dist/modules/credential_policy.js +62 -153
- package/dist/modules/credential_policy.js.map +1 -1
- package/dist/modules/credential_runtime.d.ts +1 -1
- package/dist/modules/credential_runtime.d.ts.map +1 -1
- package/dist/modules/credential_runtime.js +34 -41
- package/dist/modules/credential_runtime.js.map +1 -1
- package/dist/modules/credential_session_cache.d.ts +1 -1
- package/dist/modules/credential_session_cache.d.ts.map +1 -1
- package/dist/modules/credential_session_cache.js +5 -42
- package/dist/modules/credential_session_cache.js.map +1 -1
- package/dist/modules/credit_runtime.d.ts.map +1 -1
- package/dist/modules/credit_runtime.js +126 -162
- package/dist/modules/credit_runtime.js.map +1 -1
- package/dist/modules/crypto/browser_provider.d.ts +1 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +1 -1
- package/dist/modules/crypto/browser_provider.js +7 -11
- package/dist/modules/crypto/browser_provider.js.map +1 -1
- package/dist/modules/crypto/index.d.ts +6 -6
- package/dist/modules/crypto/index.d.ts.map +1 -1
- package/dist/modules/crypto/index.js +12 -30
- package/dist/modules/crypto/index.js.map +1 -1
- package/dist/modules/crypto/node_provider.d.ts +1 -1
- package/dist/modules/crypto/node_provider.d.ts.map +1 -1
- package/dist/modules/crypto/node_provider.js +3 -5
- package/dist/modules/crypto/node_provider.js.map +1 -1
- package/dist/modules/crypto/provider.js +1 -2
- package/dist/modules/crypto/pure_ripemd160.js +1 -3
- package/dist/modules/crypto/pure_ripemd160.js.map +1 -1
- package/dist/modules/crypto/pure_scrypt.js +1 -4
- package/dist/modules/crypto/pure_scrypt.js.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts +1 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +1 -1
- package/dist/modules/crypto/pure_secp256k1.js +1 -16
- package/dist/modules/crypto/pure_secp256k1.js.map +1 -1
- package/dist/modules/crypto/sync.d.ts.map +1 -1
- package/dist/modules/crypto/sync.js +16 -17
- package/dist/modules/crypto/sync.js.map +1 -1
- package/dist/modules/daemon_node_health.js +14 -16
- package/dist/modules/daemon_node_health.js.map +1 -1
- package/dist/modules/dexbot_class.d.ts +19 -14
- package/dist/modules/dexbot_class.d.ts.map +1 -1
- package/dist/modules/dexbot_class.js +127 -164
- package/dist/modules/dexbot_class.js.map +1 -1
- package/dist/modules/dexbot_cow_runtime.d.ts +28 -27
- package/dist/modules/dexbot_cow_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_cow_runtime.js +55 -45
- package/dist/modules/dexbot_cow_runtime.js.map +1 -1
- package/dist/modules/dexbot_credential_client.d.ts +6 -2
- package/dist/modules/dexbot_credential_client.d.ts.map +1 -1
- package/dist/modules/dexbot_credential_client.js +21 -31
- package/dist/modules/dexbot_credential_client.js.map +1 -1
- package/dist/modules/dexbot_fill_runtime.d.ts +23 -23
- package/dist/modules/dexbot_fill_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_fill_runtime.js +119 -77
- package/dist/modules/dexbot_fill_runtime.js.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts +46 -38
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_maintenance_runtime.js +81 -81
- package/dist/modules/dexbot_maintenance_runtime.js.map +1 -1
- package/dist/modules/dexbot_startup_runtime.d.ts +3 -3
- package/dist/modules/dexbot_startup_runtime.d.ts.map +1 -1
- package/dist/modules/dexbot_startup_runtime.js +43 -81
- package/dist/modules/dexbot_startup_runtime.js.map +1 -1
- package/dist/modules/dexbot_state_recovery.d.ts +11 -11
- package/dist/modules/dexbot_state_recovery.js +32 -78
- package/dist/modules/dexbot_state_recovery.js.map +1 -1
- package/dist/modules/env.js +3 -7
- package/dist/modules/env.js.map +1 -1
- package/dist/modules/fund_registry.d.ts.map +1 -1
- package/dist/modules/fund_registry.js +12 -24
- package/dist/modules/fund_registry.js.map +1 -1
- package/dist/modules/general_settings.js +10 -16
- package/dist/modules/general_settings.js.map +1 -1
- package/dist/modules/graceful_shutdown.d.ts.map +1 -1
- package/dist/modules/graceful_shutdown.js +12 -19
- package/dist/modules/graceful_shutdown.js.map +1 -1
- package/dist/modules/key_store.d.ts.map +1 -1
- package/dist/modules/key_store.js +27 -65
- package/dist/modules/key_store.js.map +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts +1 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +1 -1
- package/dist/modules/launcher/bot_supervisor.js +89 -118
- package/dist/modules/launcher/bot_supervisor.js.map +1 -1
- package/dist/modules/launcher/child_env.js +1 -5
- package/dist/modules/launcher/child_env.js.map +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +22 -31
- package/dist/modules/launcher/credential_bootstrap.js.map +1 -1
- package/dist/modules/launcher/credential_daemon.js +37 -75
- package/dist/modules/launcher/credential_daemon.js.map +1 -1
- package/dist/modules/launcher/credential_secret.js +2 -37
- package/dist/modules/launcher/credential_secret.js.map +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.js +25 -31
- package/dist/modules/launcher/foreign_cred_daemon.js.map +1 -1
- package/dist/modules/launcher/headless_password.js +10 -12
- package/dist/modules/launcher/headless_password.js.map +1 -1
- package/dist/modules/launcher/launch_modes.js +3 -9
- package/dist/modules/launcher/launch_modes.js.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts +1 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_runtime.js +25 -35
- package/dist/modules/launcher/market_adapter_runtime.js.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +1 -1
- package/dist/modules/launcher/market_adapter_watchdog.js +42 -45
- package/dist/modules/launcher/market_adapter_watchdog.js.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts +3 -2
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +97 -138
- package/dist/modules/launcher/monolithic_runtime.js.map +1 -1
- package/dist/modules/launcher/runtime_entry.d.ts +1 -11
- package/dist/modules/launcher/runtime_entry.d.ts.map +1 -1
- package/dist/modules/launcher/runtime_entry.js +12 -15
- package/dist/modules/launcher/runtime_entry.js.map +1 -1
- package/dist/modules/launcher/status_reporting.d.ts +1 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +1 -1
- package/dist/modules/launcher/status_reporting.js +15 -36
- package/dist/modules/launcher/status_reporting.js.map +1 -1
- package/dist/modules/launcher/supervisor_control.js +4 -9
- package/dist/modules/launcher/supervisor_control.js.map +1 -1
- package/dist/modules/logger.d.ts +1 -1
- package/dist/modules/logger.d.ts.map +1 -1
- package/dist/modules/logger.js +3 -38
- package/dist/modules/logger.js.map +1 -1
- package/dist/modules/market_adapter_whitelist.js +9 -18
- package/dist/modules/market_adapter_whitelist.js.map +1 -1
- package/dist/modules/node_failure_ledger.js +1 -3
- package/dist/modules/node_failure_ledger.js.map +1 -1
- package/dist/modules/node_health_cache.d.ts.map +1 -1
- package/dist/modules/node_health_cache.js +15 -25
- package/dist/modules/node_health_cache.js.map +1 -1
- package/dist/modules/node_manager.d.ts +1 -1
- package/dist/modules/node_manager.d.ts.map +1 -1
- package/dist/modules/node_manager.js +44 -43
- package/dist/modules/node_manager.js.map +1 -1
- package/dist/modules/order/accounting.d.ts.map +1 -1
- package/dist/modules/order/accounting.js +102 -118
- package/dist/modules/order/accounting.js.map +1 -1
- package/dist/modules/order/async_lock.d.ts +3 -15
- package/dist/modules/order/async_lock.d.ts.map +1 -1
- package/dist/modules/order/async_lock.js +6 -26
- package/dist/modules/order/async_lock.js.map +1 -1
- package/dist/modules/order/export.js +34 -75
- package/dist/modules/order/export.js.map +1 -1
- package/dist/modules/order/format.d.ts +1 -3
- package/dist/modules/order/format.d.ts.map +1 -1
- package/dist/modules/order/format.js +4 -24
- package/dist/modules/order/format.js.map +1 -1
- package/dist/modules/order/grid.d.ts +8 -8
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +254 -266
- package/dist/modules/order/grid.js.map +1 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile.js +77 -94
- package/dist/modules/order/grid_reconcile.js.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +1 -1
- package/dist/modules/order/grid_reconcile_internal.js +117 -149
- package/dist/modules/order/grid_reconcile_internal.js.map +1 -1
- package/dist/modules/order/index.d.ts.map +1 -1
- package/dist/modules/order/index.js +11 -45
- package/dist/modules/order/index.js.map +1 -1
- package/dist/modules/order/logger.d.ts +0 -8
- package/dist/modules/order/logger.d.ts.map +1 -1
- package/dist/modules/order/logger.js +28 -141
- package/dist/modules/order/logger.js.map +1 -1
- package/dist/modules/order/logger_state.d.ts.map +1 -1
- package/dist/modules/order/logger_state.js +3 -4
- package/dist/modules/order/logger_state.js.map +1 -1
- package/dist/modules/order/manager.d.ts +10 -79
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -247
- package/dist/modules/order/manager.js.map +1 -1
- package/dist/modules/order/processed_fill_store.js +2 -7
- package/dist/modules/order/processed_fill_store.js.map +1 -1
- package/dist/modules/order/strategy.js +23 -25
- package/dist/modules/order/strategy.js.map +1 -1
- package/dist/modules/order/sync_engine.d.ts +27 -0
- package/dist/modules/order/sync_engine.d.ts.map +1 -1
- package/dist/modules/order/sync_engine.js +232 -181
- package/dist/modules/order/sync_engine.js.map +1 -1
- package/dist/modules/order/utils/math.d.ts +1 -25
- package/dist/modules/order/utils/math.d.ts.map +1 -1
- package/dist/modules/order/utils/math.js +49 -172
- package/dist/modules/order/utils/math.js.map +1 -1
- package/dist/modules/order/utils/order.d.ts +46 -2
- package/dist/modules/order/utils/order.d.ts.map +1 -1
- package/dist/modules/order/utils/order.js +165 -143
- package/dist/modules/order/utils/order.js.map +1 -1
- package/dist/modules/order/utils/system.d.ts +3 -1
- package/dist/modules/order/utils/system.d.ts.map +1 -1
- package/dist/modules/order/utils/system.js +152 -211
- package/dist/modules/order/utils/system.js.map +1 -1
- package/dist/modules/order/utils/timeout.js +1 -4
- package/dist/modules/order/utils/timeout.js.map +1 -1
- package/dist/modules/order/utils/validate.js +91 -142
- package/dist/modules/order/utils/validate.js.map +1 -1
- package/dist/modules/order/utils/withPoolRef.js +21 -61
- package/dist/modules/order/utils/withPoolRef.js.map +1 -1
- package/dist/modules/order/working_grid.js +6 -9
- package/dist/modules/order/working_grid.js.map +1 -1
- package/dist/modules/path_api.d.ts.map +1 -1
- package/dist/modules/path_api.js +8 -11
- package/dist/modules/path_api.js.map +1 -1
- package/dist/modules/paths.d.ts.map +1 -1
- package/dist/modules/paths.js +61 -67
- package/dist/modules/paths.js.map +1 -1
- package/dist/modules/process_discovery.d.ts.map +1 -1
- package/dist/modules/process_discovery.js +14 -23
- package/dist/modules/process_discovery.js.map +1 -1
- package/dist/modules/runtime.js +7 -11
- package/dist/modules/runtime.js.map +1 -1
- package/dist/modules/runtime_settings.d.ts.map +1 -1
- package/dist/modules/runtime_settings.js +14 -16
- package/dist/modules/runtime_settings.js.map +1 -1
- package/dist/modules/settings_merge.js +1 -3
- package/dist/modules/settings_merge.js.map +1 -1
- package/dist/modules/socket_json_client.js +3 -5
- package/dist/modules/socket_json_client.js.map +1 -1
- package/dist/modules/storage/browser_adapter.js +1 -4
- package/dist/modules/storage/browser_adapter.js.map +1 -1
- package/dist/modules/storage/index.d.ts +3 -2
- package/dist/modules/storage/index.d.ts.map +1 -1
- package/dist/modules/storage/index.js +5 -8
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/modules/storage/node_adapter.d.ts +3 -4
- package/dist/modules/storage/node_adapter.d.ts.map +1 -1
- package/dist/modules/storage/node_adapter.js +12 -16
- package/dist/modules/storage/node_adapter.js.map +1 -1
- package/dist/modules/storage/types.js +1 -2
- package/dist/modules/types.d.ts +0 -6
- package/dist/modules/types.d.ts.map +1 -1
- package/dist/modules/types.js +1 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/modules/utils/base58check.js +8 -15
- package/dist/modules/utils/base58check.js.map +1 -1
- package/dist/modules/utils/build_dir.js +3 -7
- package/dist/modules/utils/build_dir.js.map +1 -1
- package/dist/modules/utils/errors.js +1 -5
- package/dist/modules/utils/errors.js.map +1 -1
- package/dist/modules/utils/math_utils.d.ts +1 -1
- package/dist/modules/utils/math_utils.d.ts.map +1 -1
- package/dist/modules/utils/math_utils.js +2 -7
- package/dist/modules/utils/math_utils.js.map +1 -1
- package/dist/modules/validate_profiles.d.ts.map +1 -1
- package/dist/modules/validate_profiles.js +18 -25
- package/dist/modules/validate_profiles.js.map +1 -1
- package/dist/pm2.d.ts +4 -70
- package/dist/pm2.d.ts.map +1 -1
- package/dist/pm2.js +106 -132
- package/dist/pm2.js.map +1 -1
- package/dist/scripts/analyze-git.js +13 -17
- package/dist/scripts/analyze-git.js.map +1 -1
- package/dist/scripts/analyze-orders.d.ts.map +1 -1
- package/dist/scripts/analyze-orders.js +48 -63
- package/dist/scripts/analyze-orders.js.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +1 -1
- package/dist/scripts/diagnose-kibana-candles.js +2 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +1 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +1 -1
- package/dist/scripts/diagnose-pool-history.js +2 -1
- package/dist/scripts/diagnose-pool-history.js.map +1 -1
- package/dist/scripts/divergence-calc.d.ts.map +1 -1
- package/dist/scripts/divergence-calc.js +2 -2
- package/dist/scripts/divergence-calc.js.map +1 -1
- package/dist/scripts/fix-err-message.js +17 -22
- package/dist/scripts/fix-err-message.js.map +1 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +1 -1
- package/dist/scripts/generate_lp_chart.js +7 -15
- package/dist/scripts/generate_lp_chart.js.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +1 -1
- package/dist/scripts/generate_mainnet_corpus_report.js +3 -2
- package/dist/scripts/generate_mainnet_corpus_report.js.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.d.ts.map +1 -1
- package/dist/scripts/generate_market_adapter_whitelist.js +18 -24
- package/dist/scripts/generate_market_adapter_whitelist.js.map +1 -1
- package/dist/scripts/native_release_gates.js +15 -19
- package/dist/scripts/native_release_gates.js.map +1 -1
- package/dist/scripts/print_grid.d.ts.map +1 -1
- package/dist/scripts/print_grid.js +2 -2
- package/dist/scripts/print_grid.js.map +1 -1
- package/dist/scripts/run-tests.js +12 -17
- package/dist/scripts/run-tests.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +18 -20
- package/dist/scripts/runner.js.map +1 -1
- package/dist/scripts/sync-version.js +2 -2
- package/dist/scripts/sync-version.js.map +1 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +1 -1
- package/dist/scripts/test-credit-renewal.js +4 -3
- package/dist/scripts/test-credit-renewal.js.map +1 -1
- package/dist/scripts/update.js +93 -95
- package/dist/scripts/update.js.map +1 -1
- package/dist/scripts/validate_bots.d.ts.map +1 -1
- package/dist/scripts/validate_bots.js +2 -2
- package/dist/scripts/validate_bots.js.map +1 -1
- package/dist/scripts/verify-browser-bundle.js +12 -17
- package/dist/scripts/verify-browser-bundle.js.map +1 -1
- package/dist/unlock.d.ts +0 -30
- package/dist/unlock.d.ts.map +1 -1
- package/dist/unlock.js +258 -222
- package/dist/unlock.js.map +1 -1
- package/package.json +5 -8
- package/scripts/README.md +1 -1
- package/scripts/create-bot-symlinks.sh +2 -2
- package/dist/modules/utils/fs_utils.d.ts +0 -18
- package/dist/modules/utils/fs_utils.d.ts.map +0 -1
- package/dist/modules/utils/fs_utils.js +0 -32
- package/dist/modules/utils/fs_utils.js.map +0 -1
- package/dist/scripts/migrate_bot_keys.d.ts +0 -3
- package/dist/scripts/migrate_bot_keys.d.ts.map +0 -1
- package/dist/scripts/migrate_bot_keys.js +0 -225
- package/dist/scripts/migrate_bot_keys.js.map +0 -1
package/dist/unlock.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { dirname as _esmDirname } from 'node:path';
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = _esmDirname(__filename);
|
|
3
7
|
// node-only entry point — credential daemon launcher (Unix socket, child_process, fs)
|
|
4
8
|
/**
|
|
5
9
|
* unlock.ts - Credential Daemon Launcher
|
|
@@ -31,96 +35,43 @@
|
|
|
31
35
|
* BOT_NAME Fallback bot name when none is given as positional arg
|
|
32
36
|
* DEXBOT_MASTER_PASSWORD Master password for --headless mode (less secure than file)
|
|
33
37
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
63
|
-
__setModuleDefault(result, mod);
|
|
64
|
-
return result;
|
|
65
|
-
};
|
|
66
|
-
})();
|
|
67
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
68
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
69
|
-
};
|
|
70
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
|
-
exports.waitForChildSpawn = exports.pidMatchesScriptCandidates = exports.isLikelyCredentialDaemonProcess = exports.findCredentialSocketOwnerPid = exports.ensureNoForeignCredentialDaemon = exports.candidateRuntimeScriptPaths = exports.buildDexbotStartArgs = void 0;
|
|
72
|
-
exports.main = main;
|
|
73
|
-
exports.waitForStableChildStartup = waitForStableChildStartup;
|
|
74
|
-
const config_1 = require("./modules/config");
|
|
75
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
76
|
-
const path_api_1 = require("./modules/path_api");
|
|
77
|
-
const storage_1 = require("./modules/storage");
|
|
78
|
-
const node_child_process_1 = require("node:child_process");
|
|
79
|
-
const credential_daemon_1 = require("./modules/launcher/credential_daemon");
|
|
80
|
-
const child_env_1 = require("./modules/launcher/child_env");
|
|
81
|
-
const launch_modes_1 = require("./modules/launcher/launch_modes");
|
|
82
|
-
const constants_1 = require("./modules/constants");
|
|
83
|
-
const runtime_1 = require("./modules/runtime");
|
|
84
|
-
const paths_1 = require("./modules/paths");
|
|
85
|
-
const runtime_entry_1 = require("./modules/launcher/runtime_entry");
|
|
86
|
-
const supervisor_control_1 = require("./modules/launcher/supervisor_control");
|
|
87
|
-
const graceful_shutdown_1 = require("./modules/graceful_shutdown");
|
|
88
|
-
const bot_settings_1 = require("./modules/bot_settings");
|
|
89
|
-
const chainKeys = __importStar(require("./modules/chain_keys"));
|
|
90
|
-
const credentialPolicy = __importStar(require("./modules/credential_policy"));
|
|
91
|
-
const market_adapter_whitelist_1 = require("./modules/market_adapter_whitelist");
|
|
92
|
-
const fs_utils_1 = require("./modules/utils/fs_utils");
|
|
93
|
-
const market_adapter_watchdog_1 = require("./modules/launcher/market_adapter_watchdog");
|
|
94
|
-
const market_adapter_runtime_1 = require("./modules/launcher/market_adapter_runtime");
|
|
95
|
-
const config_2 = require("./modules/config");
|
|
96
|
-
const migrate_bot_keys_1 = require("./scripts/migrate_bot_keys");
|
|
97
|
-
const errors_1 = require("./modules/utils/errors");
|
|
98
|
-
const timeout_1 = require("./modules/order/utils/timeout");
|
|
99
|
-
(0, config_1.setUmask)(0o077);
|
|
100
|
-
const storage = (0, storage_1.getStorage)();
|
|
38
|
+
import { createRequire } from 'node:module';
|
|
39
|
+
const require = createRequire(import.meta.url);
|
|
40
|
+
import { setUmask } from './modules/config.js';
|
|
41
|
+
import fs from 'node:fs';
|
|
42
|
+
import { path } from './modules/path_api.js';
|
|
43
|
+
import { getStorage } from './modules/storage/index.js';
|
|
44
|
+
import { spawn } from 'node:child_process';
|
|
45
|
+
import { createCredentialDaemonController } from './modules/launcher/credential_daemon.js';
|
|
46
|
+
import { buildScopedChildEnv } from './modules/launcher/child_env.js';
|
|
47
|
+
import { parseUnlockArgs } from './modules/launcher/launch_modes.js';
|
|
48
|
+
import { UPDATER, LAUNCHER } from './modules/constants.js';
|
|
49
|
+
import { runtime } from './modules/runtime.js';
|
|
50
|
+
import { PATHS } from './modules/paths.js';
|
|
51
|
+
import { buildRuntimeScriptArgs } from './modules/launcher/runtime_entry.js';
|
|
52
|
+
import { sendControlCommand } from './modules/launcher/supervisor_control.js';
|
|
53
|
+
import { registerCleanup, setupGracefulShutdown } from './modules/graceful_shutdown.js';
|
|
54
|
+
import { normalizeBotEntry, resolveRawBotEntries, loadSettingsFile } from './modules/bot_settings.js';
|
|
55
|
+
import * as chainKeys from './modules/chain_keys.js';
|
|
56
|
+
import * as credentialPolicy from './modules/credential_policy.js';
|
|
57
|
+
import { getWhitelistFlags } from './modules/market_adapter_whitelist.js';
|
|
58
|
+
import { createMarketAdapterWatchdog } from './modules/launcher/market_adapter_watchdog.js';
|
|
59
|
+
import { isLikelyMarketAdapterProcess } from './modules/launcher/market_adapter_runtime.js';
|
|
60
|
+
import { Config } from './modules/config.js';
|
|
61
|
+
import { getErrorMessage } from './modules/utils/errors.js';
|
|
62
|
+
import { withTimeout } from './modules/order/utils/timeout.js';
|
|
63
|
+
setUmask(0o077);
|
|
64
|
+
const storage = getStorage();
|
|
65
|
+
const { ensureDir } = storage;
|
|
101
66
|
const { createBotSupervisor, SOCKET_PATH, forwardSignal, isPidAlive, waitForPidExit, readMarketAdapterLockPid, stopMarketAdapterFromLock, usesAmaGridPrice, waitForChildSpawn, pidMatchesScriptCandidates, candidateRuntimeScriptPaths, } = require('./modules/launcher/bot_supervisor');
|
|
102
|
-
exports.waitForChildSpawn = waitForChildSpawn;
|
|
103
|
-
exports.pidMatchesScriptCandidates = pidMatchesScriptCandidates;
|
|
104
|
-
exports.candidateRuntimeScriptPaths = candidateRuntimeScriptPaths;
|
|
105
67
|
const { statusTitle, statusLabel, statusBool, statusActiveBotName, statusSuccess, statusError, colorStatus, STATUS_COLORS, readProcStat, readProcMemMB, readProcCpuTime, readProcCpuPercent, readProcUptime, formatMemoryWithUptime, printControlStatus, } = require('./modules/launcher/status_reporting');
|
|
106
|
-
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, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isExpectedMonolithicBotPid, stopCredentialDaemonPid, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, readCredentialDaemonStatus, ensureLogDir: ensureMonolithicLogDir, buildDexbotStartArgs, createUpdateScheduler, listConfiguredBots, getControlBotNames, getControlActionLabel, getControlServiceNames, printControlActionSummary, formatBotCount, } = require('./modules/launcher/monolithic_runtime');
|
|
107
|
-
exports.isLikelyCredentialDaemonProcess = isLikelyCredentialDaemonProcess;
|
|
108
|
-
exports.ensureNoForeignCredentialDaemon = ensureNoForeignCredentialDaemon;
|
|
109
|
-
exports.findCredentialSocketOwnerPid = findCredentialSocketOwnerPid;
|
|
110
|
-
exports.buildDexbotStartArgs = buildDexbotStartArgs;
|
|
111
|
-
// Auto-migrate bot state files from old stable-ID key format to sanitized-name format
|
|
112
|
-
try {
|
|
113
|
-
(0, migrate_bot_keys_1.runMigration)();
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
console.error(`Migration error: ${(0, errors_1.getErrorMessage)(err)}`);
|
|
117
|
-
}
|
|
68
|
+
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, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isExpectedMonolithicBotPid, isProcessInDstate, stopCredentialDaemonPid, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, cleanupCredentialRuntimeFiles, readCredentialDaemonStatus, ensureLogDir: ensureMonolithicLogDir, buildDexbotStartArgs, createUpdateScheduler, listConfiguredBots, getControlBotNames, getControlActionLabel, getControlServiceNames, printControlActionSummary, formatBotCount, } = require('./modules/launcher/monolithic_runtime');
|
|
118
69
|
const CODE_ROOT = __dirname;
|
|
119
|
-
const BOTS_FILE =
|
|
120
|
-
const LOGS_DIR =
|
|
121
|
-
const SUPERVISOR_OUT_LOG =
|
|
122
|
-
const SUPERVISOR_ERROR_LOG =
|
|
123
|
-
const controller =
|
|
70
|
+
const BOTS_FILE = PATHS.PROFILES.BOTS_JSON;
|
|
71
|
+
const LOGS_DIR = PATHS.LOGS_DIR;
|
|
72
|
+
const SUPERVISOR_OUT_LOG = path.join(LOGS_DIR, 'supervisor.log');
|
|
73
|
+
const SUPERVISOR_ERROR_LOG = path.join(LOGS_DIR, 'supervisor-error.log');
|
|
74
|
+
const controller = createCredentialDaemonController({ root: PATHS.PROJECT_ROOT, codeRoot: CODE_ROOT });
|
|
124
75
|
const DEFAULT_STARTUP_GRACE_MS = 750;
|
|
125
76
|
const botProcessRef = { current: null };
|
|
126
77
|
function printLauncherHeader({ botName = null, clawOnly = false, creditOnly = false, isolated = false, dryrun = false, headless = false } = {}) {
|
|
@@ -220,14 +171,14 @@ function waitForStableChildStartup(child, { label = 'child process', timeoutMs =
|
|
|
220
171
|
});
|
|
221
172
|
}
|
|
222
173
|
function resolveBotEntryForName(botName) {
|
|
223
|
-
const { config } =
|
|
224
|
-
const raw =
|
|
174
|
+
const { config } = loadSettingsFile(BOTS_FILE);
|
|
175
|
+
const raw = resolveRawBotEntries(config);
|
|
225
176
|
const match = raw.find((b) => b && b.name === botName);
|
|
226
177
|
if (!match)
|
|
227
178
|
return null;
|
|
228
179
|
const entryCopy = JSON.parse(JSON.stringify(match));
|
|
229
180
|
entryCopy.active = true;
|
|
230
|
-
return
|
|
181
|
+
return normalizeBotEntry(entryCopy);
|
|
231
182
|
}
|
|
232
183
|
function getLaunchedBotNames(botName) {
|
|
233
184
|
return botName
|
|
@@ -236,7 +187,7 @@ function getLaunchedBotNames(botName) {
|
|
|
236
187
|
}
|
|
237
188
|
// ── Isolated supervisor mode ───────────────────────────────────────
|
|
238
189
|
function isSupervisorTransientError(err) {
|
|
239
|
-
const msg = String(err &&
|
|
190
|
+
const msg = String(err && getErrorMessage(err) || '');
|
|
240
191
|
return msg.includes('No supervisor socket found') || msg.includes('Connection timed out');
|
|
241
192
|
}
|
|
242
193
|
function waitForSupervisorReady({ child = null, timeoutMs = 15000, intervalMs = 250 } = {}) {
|
|
@@ -255,7 +206,7 @@ function waitForSupervisorReady({ child = null, timeoutMs = 15000, intervalMs =
|
|
|
255
206
|
const startedAt = Date.now();
|
|
256
207
|
const poll = async () => {
|
|
257
208
|
try {
|
|
258
|
-
await
|
|
209
|
+
await sendControlCommand({ cmd: 'status' });
|
|
259
210
|
finish(resolve, true);
|
|
260
211
|
}
|
|
261
212
|
catch (err) {
|
|
@@ -283,12 +234,12 @@ function waitForSupervisorReady({ child = null, timeoutMs = 15000, intervalMs =
|
|
|
283
234
|
}
|
|
284
235
|
function ensureSupervisorLogDir() {
|
|
285
236
|
if (!storage.exists(LOGS_DIR)) {
|
|
286
|
-
|
|
237
|
+
ensureDir(LOGS_DIR);
|
|
287
238
|
}
|
|
288
239
|
}
|
|
289
240
|
async function sendIsolatedDeleteIfAvailable() {
|
|
290
241
|
try {
|
|
291
|
-
const resp = await
|
|
242
|
+
const resp = await sendControlCommand({ cmd: 'delete' });
|
|
292
243
|
if (resp.ok && resp.status) {
|
|
293
244
|
printControlStatus(resp.status);
|
|
294
245
|
}
|
|
@@ -306,28 +257,28 @@ async function sendIsolatedDeleteIfAvailable() {
|
|
|
306
257
|
}
|
|
307
258
|
async function launchDetachedSupervisor({ botName = null, credentialDaemonPid = null } = {}) {
|
|
308
259
|
try {
|
|
309
|
-
await
|
|
310
|
-
throw new Error(`another isolated supervisor is already running at ${
|
|
260
|
+
await sendControlCommand({ cmd: 'status' });
|
|
261
|
+
throw new Error(`another isolated supervisor is already running at ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
|
|
311
262
|
}
|
|
312
263
|
catch (err) {
|
|
313
|
-
if (!String(err &&
|
|
264
|
+
if (!String(err && getErrorMessage(err) || '').includes('No supervisor socket found')) {
|
|
314
265
|
throw err;
|
|
315
266
|
}
|
|
316
267
|
}
|
|
317
268
|
ensureSupervisorLogDir();
|
|
318
269
|
const stdoutFd = storage.open(SUPERVISOR_OUT_LOG, 'a', 0o600);
|
|
319
270
|
const stderrFd = storage.open(SUPERVISOR_ERROR_LOG, 'a', 0o600);
|
|
320
|
-
const args =
|
|
271
|
+
const args = buildRuntimeScriptArgs({
|
|
321
272
|
codeRoot: CODE_ROOT,
|
|
322
273
|
scriptSegments: ['unlock'],
|
|
323
274
|
scriptArgs: ['--isolated', ...(botName ? [botName] : [])],
|
|
324
275
|
});
|
|
325
276
|
let child = null;
|
|
326
277
|
try {
|
|
327
|
-
child =
|
|
328
|
-
cwd:
|
|
278
|
+
child = spawn(Config.EXEC_PATH, args, {
|
|
279
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
329
280
|
detached: true,
|
|
330
|
-
env:
|
|
281
|
+
env: buildScopedChildEnv({
|
|
331
282
|
extra: {
|
|
332
283
|
DEXBOT_ISOLATED_CHILD: '1',
|
|
333
284
|
...(credentialDaemonPid ? { DEXBOT_MANAGED_CRED_PID: String(credentialDaemonPid) } : {}),
|
|
@@ -345,7 +296,7 @@ async function launchDetachedSupervisor({ botName = null, credentialDaemonPid =
|
|
|
345
296
|
catch (err) {
|
|
346
297
|
if (child && child.pid) {
|
|
347
298
|
try {
|
|
348
|
-
|
|
299
|
+
runtime.kill(child.pid, 'SIGTERM');
|
|
349
300
|
}
|
|
350
301
|
catch (_) { }
|
|
351
302
|
}
|
|
@@ -374,7 +325,7 @@ async function runIsolated({ botName, botEntry = null, stayResident = false, sta
|
|
|
374
325
|
else {
|
|
375
326
|
supervisor = createBotSupervisor();
|
|
376
327
|
}
|
|
377
|
-
|
|
328
|
+
registerCleanup('Bot supervisor', () => supervisor.shutdown());
|
|
378
329
|
await supervisor.start();
|
|
379
330
|
await supervisor.waitForStableStartup({ timeoutMs: startupGraceMs });
|
|
380
331
|
printLauncherStartupSummary({ botNames: getLaunchedBotNames(botName || null), mode: 'isolated' });
|
|
@@ -409,7 +360,7 @@ async function runIsolated({ botName, botEntry = null, stayResident = false, sta
|
|
|
409
360
|
return;
|
|
410
361
|
}
|
|
411
362
|
const elapsedMs = Date.now() - pollStartedAt;
|
|
412
|
-
if (elapsedMs >=
|
|
363
|
+
if (elapsedMs >= LAUNCHER.MONOLITHIC.SUPERVISOR_POLL_TIMEOUT_MS) {
|
|
413
364
|
clearInterval(interval);
|
|
414
365
|
cleanupSignalHandlers();
|
|
415
366
|
reject(new Error(`Supervisor poll timeout after ${Math.ceil(elapsedMs / 1000)}s: ` +
|
|
@@ -429,11 +380,11 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
429
380
|
if (typeof chainKeys.checkKeysFileSecurity === 'function')
|
|
430
381
|
chainKeys.checkKeysFileSecurity();
|
|
431
382
|
if (typeof credentialPolicy.checkPolicyFileSecurity === 'function')
|
|
432
|
-
credentialPolicy.checkPolicyFileSecurity(
|
|
433
|
-
const parsed =
|
|
434
|
-
const isDetachedSupervisorChild =
|
|
435
|
-
const forceForegroundIsolated =
|
|
436
|
-
const isMonolithicBgChild =
|
|
383
|
+
credentialPolicy.checkPolicyFileSecurity(PATHS.PROFILES.DAEMON_POLICIES_JSON);
|
|
384
|
+
const parsed = parseUnlockArgs(argv);
|
|
385
|
+
const isDetachedSupervisorChild = Config.DEXBOT_ISOLATED_CHILD;
|
|
386
|
+
const forceForegroundIsolated = Config.DEXBOT_ISOLATED_FOREGROUND;
|
|
387
|
+
const isMonolithicBgChild = Config.DEXBOT_MONOLITHIC_BG;
|
|
437
388
|
const forceForeground = argv.includes('--foreground');
|
|
438
389
|
if (parsed.control) {
|
|
439
390
|
await handleControl({ cmd: parsed.control.cmd, target: parsed.control.target ?? undefined });
|
|
@@ -548,8 +499,8 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
548
499
|
catch (_) { }
|
|
549
500
|
throw _e;
|
|
550
501
|
}
|
|
551
|
-
const child =
|
|
552
|
-
cwd:
|
|
502
|
+
const child = spawn(Config.EXEC_PATH, [__filename, ...argv.slice(2)], {
|
|
503
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
553
504
|
detached: true,
|
|
554
505
|
env: {
|
|
555
506
|
...process.env,
|
|
@@ -587,17 +538,17 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
587
538
|
daemonReleased = true;
|
|
588
539
|
printLauncherStartupSummary({ botNames: launchedBotNames, mode: 'isolated' });
|
|
589
540
|
console.log(`Supervisor PID: ${supervisorPid}`);
|
|
590
|
-
console.log(`Control socket: ${
|
|
541
|
+
console.log(`Control socket: ${Config.DEXBOT_SUPERVISOR_SOCKET || SOCKET_PATH}`);
|
|
591
542
|
console.log(`Supervisor logs: ${SUPERVISOR_OUT_LOG}`);
|
|
592
543
|
process.exitCode = 0;
|
|
593
544
|
return;
|
|
594
545
|
}
|
|
595
546
|
// Monolithic foreground mode — spawn and supervise the bot process directly
|
|
596
|
-
const updater =
|
|
547
|
+
const updater = UPDATER.ACTIVE ? createUpdateScheduler({ botProcessRef }) : null;
|
|
597
548
|
const cancelUpdater = updater ? updater.cancel : () => { };
|
|
598
|
-
const watchdog =
|
|
549
|
+
const watchdog = createMarketAdapterWatchdog({
|
|
599
550
|
codeRoot: CODE_ROOT,
|
|
600
|
-
root:
|
|
551
|
+
root: PATHS.PROJECT_ROOT,
|
|
601
552
|
logsDir: LOGS_DIR,
|
|
602
553
|
});
|
|
603
554
|
const cancelWatchdog = watchdog.schedule(MONOLITHIC_ERROR_LOG);
|
|
@@ -618,8 +569,8 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
618
569
|
do {
|
|
619
570
|
launchedBotNames = getLaunchedBotNames(effectiveBotName || botName);
|
|
620
571
|
const dexbotArgs = buildDexbotStartArgs(effectiveBotName || botName, dryrun);
|
|
621
|
-
const botProcess =
|
|
622
|
-
cwd:
|
|
572
|
+
const botProcess = spawn(Config.EXEC_PATH, dexbotArgs, {
|
|
573
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
623
574
|
env: process.env,
|
|
624
575
|
stdio: isMonolithicBgChild ? 'pipe' : 'inherit',
|
|
625
576
|
});
|
|
@@ -636,8 +587,8 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
636
587
|
catch (_) { }
|
|
637
588
|
}
|
|
638
589
|
if (isMonolithicBgChild && botProcess.stdout) {
|
|
639
|
-
const outStream =
|
|
640
|
-
const errStream =
|
|
590
|
+
const outStream = fs.createWriteStream(MONOLITHIC_OUT_LOG, { flags: 'a' });
|
|
591
|
+
const errStream = fs.createWriteStream(MONOLITHIC_ERROR_LOG, { flags: 'a' });
|
|
641
592
|
botProcess.stdout.pipe(outStream);
|
|
642
593
|
botProcess.stderr.pipe(errStream);
|
|
643
594
|
botProcess.stdout.on('error', () => { });
|
|
@@ -684,18 +635,18 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
684
635
|
}
|
|
685
636
|
else if (exitCode !== 0) {
|
|
686
637
|
const uptime = Date.now() - lastStartTime;
|
|
687
|
-
if (uptime >=
|
|
638
|
+
if (uptime >= LAUNCHER.MONOLITHIC.minUptimeMs) {
|
|
688
639
|
restartCount = 0;
|
|
689
640
|
}
|
|
690
641
|
restartCount++;
|
|
691
|
-
if (restartCount >
|
|
692
|
-
console.error(statusError(`Bot crashed ${
|
|
642
|
+
if (restartCount > LAUNCHER.MONOLITHIC.maxRestarts) {
|
|
643
|
+
console.error(statusError(`Bot crashed ${LAUNCHER.MONOLITHIC.maxRestarts} times without stable uptime. Exiting.`));
|
|
693
644
|
process.exitCode = exitCode || 1;
|
|
694
645
|
keepRunning = false;
|
|
695
646
|
}
|
|
696
647
|
else {
|
|
697
|
-
console.log(`Bot crashed (exit ${exitCode}), restarting in ${
|
|
698
|
-
await new Promise((r) => setTimeout(r,
|
|
648
|
+
console.log(`Bot crashed (exit ${exitCode}), restarting in ${LAUNCHER.MONOLITHIC.restartDelayMs / 1000}s (attempt ${restartCount}/${LAUNCHER.MONOLITHIC.maxRestarts})...`);
|
|
649
|
+
await new Promise((r) => setTimeout(r, LAUNCHER.MONOLITHIC.restartDelayMs));
|
|
699
650
|
}
|
|
700
651
|
}
|
|
701
652
|
else {
|
|
@@ -723,6 +674,94 @@ async function main({ argv = process.argv, startupGraceMs = DEFAULT_STARTUP_GRAC
|
|
|
723
674
|
}
|
|
724
675
|
}
|
|
725
676
|
// ── Control command handling ───────────────────────────────────────
|
|
677
|
+
/**
|
|
678
|
+
* Resolve the live credential daemon PID (owned or foreign) for status
|
|
679
|
+
* reporting. Falls back to the socket owner when the tracked PID file is
|
|
680
|
+
* missing or stale.
|
|
681
|
+
*/
|
|
682
|
+
function resolveCredentialDaemonForStatus() {
|
|
683
|
+
let credPid = null;
|
|
684
|
+
let credForeign = false;
|
|
685
|
+
try {
|
|
686
|
+
const raw = storage.readFile(MONOLITHIC_CRED_PID_FILE).trim();
|
|
687
|
+
const n = Number(raw);
|
|
688
|
+
if (Number.isInteger(n) && n > 0)
|
|
689
|
+
credPid = n;
|
|
690
|
+
}
|
|
691
|
+
catch (_) { }
|
|
692
|
+
if (!credPid && storage.exists(CREDENTIAL_SOCKET_FILE)) {
|
|
693
|
+
const ownerPid = findCredentialSocketOwnerPid();
|
|
694
|
+
if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
|
|
695
|
+
credPid = ownerPid;
|
|
696
|
+
credForeign = true;
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
return { pid: credPid, foreign: credForeign };
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Print the "Credential daemon:" status block for a resolved daemon PID.
|
|
703
|
+
*/
|
|
704
|
+
async function printCredentialDaemonStatusBlock(credPid, credForeign) {
|
|
705
|
+
const credStatus = await readCredentialDaemonStatus(credPid);
|
|
706
|
+
console.log(` ${statusTitle('Credential daemon:')}`);
|
|
707
|
+
if (credPid && credForeign) {
|
|
708
|
+
console.log(` ${statusLabel('PID:')} ${credPid} ${colorStatus('(foreign/unowned)', STATUS_COLORS.warn)}`);
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
console.log(` ${statusLabel('PID:')} ${credPid || '-'}`);
|
|
712
|
+
}
|
|
713
|
+
if (credPid && isPidAlive(credPid) && isLikelyCredentialDaemonProcess(credPid)) {
|
|
714
|
+
const credUptime = readProcUptime(credPid);
|
|
715
|
+
const credMem = readProcMemMB(credPid);
|
|
716
|
+
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(credMem, credUptime)}`);
|
|
717
|
+
console.log(` ${statusLabel('Alive:')} ${statusBool(true)}`);
|
|
718
|
+
}
|
|
719
|
+
else {
|
|
720
|
+
console.log(` ${statusLabel('Alive:')} ${statusBool(false)}`);
|
|
721
|
+
}
|
|
722
|
+
console.log(` ${statusLabel('Ready:')} ${statusBool(credStatus.ready)}`);
|
|
723
|
+
console.log(` ${statusLabel('Socket:')} ${statusBool(credStatus.socket)}`);
|
|
724
|
+
if (credForeign) {
|
|
725
|
+
console.log(` ${colorStatus('Rerun `dexbot unlock` to detach the foreign daemon and unlock with a fresh master password.', STATUS_COLORS.warn)}`);
|
|
726
|
+
}
|
|
727
|
+
return credStatus;
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Print the "Market adapter:" status block for the running adapter (or note
|
|
731
|
+
* that it is not running).
|
|
732
|
+
*/
|
|
733
|
+
function printMarketAdapterStatusBlock() {
|
|
734
|
+
const adapterPid = readMarketAdapterLockPid();
|
|
735
|
+
const adapterAlive = adapterPid > 0 && isLikelyMarketAdapterProcess(adapterPid);
|
|
736
|
+
console.log(` ${statusTitle('Market adapter:')}`);
|
|
737
|
+
if (adapterAlive) {
|
|
738
|
+
console.log(` ${statusLabel('PID:')} ${adapterPid}`);
|
|
739
|
+
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(readProcMemMB(adapterPid), readProcUptime(adapterPid))}`);
|
|
740
|
+
}
|
|
741
|
+
else if (adapterPid > 0) {
|
|
742
|
+
console.log(` ${colorStatus('(offline)', STATUS_COLORS.warn)}`);
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
else {
|
|
746
|
+
console.log(` ${colorStatus('(not running)', STATUS_COLORS.muted)}`);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
const amaBots = listConfiguredBots().filter((b) => b.active && usesAmaGridPrice(b));
|
|
750
|
+
function botKeyFromName(name) {
|
|
751
|
+
return String(name).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
752
|
+
}
|
|
753
|
+
console.log(` ${statusLabel('Active:')} ${formatBotCount(amaBots.length)}`);
|
|
754
|
+
for (const b of amaBots) {
|
|
755
|
+
const flags = getWhitelistFlags(botKeyFromName(b.name));
|
|
756
|
+
const indicators = [];
|
|
757
|
+
if (flags.asymmetricBounds)
|
|
758
|
+
indicators.push('range');
|
|
759
|
+
if (flags.dynamicWeight)
|
|
760
|
+
indicators.push('weight');
|
|
761
|
+
const suffix = indicators.length > 0 ? `, ${indicators.join(', ')}` : '';
|
|
762
|
+
console.log(` - ${colorStatus(b.name, STATUS_COLORS.ok)} (${b.gridPrice}${suffix})`);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
726
765
|
async function handleControl({ cmd, target }) {
|
|
727
766
|
const effectiveCmd = cmd === 'shutdown' ? 'delete' : cmd === 'stat' ? 'status' : cmd;
|
|
728
767
|
const actionLabel = getControlActionLabel(cmd);
|
|
@@ -732,18 +771,35 @@ async function handleControl({ cmd, target }) {
|
|
|
732
771
|
const summaryBotNames = getControlBotNames(undefined, true);
|
|
733
772
|
const summaryServiceNames = getControlServiceNames(effectiveCmd, summaryBotNames);
|
|
734
773
|
if (effectiveCmd === 'restart-all') {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
774
|
+
if (process.stdin.isTTY) {
|
|
775
|
+
const credResult = await stopCredentialDaemon();
|
|
776
|
+
if (credResult.signaled) {
|
|
777
|
+
console.log('Stop signal sent to credential daemon');
|
|
778
|
+
}
|
|
779
|
+
const daemonOpts = { detached: true };
|
|
780
|
+
const unlockedNow = await controller.ensureCredentialDaemon(daemonOpts);
|
|
781
|
+
if (unlockedNow) {
|
|
782
|
+
console.log(statusSuccess('✓ Authentication successful'));
|
|
783
|
+
}
|
|
784
|
+
const newCredPid = controller.getManagedDaemonPid();
|
|
785
|
+
if (newCredPid) {
|
|
786
|
+
try {
|
|
787
|
+
storage.writeFile(MONOLITHIC_CRED_PID_FILE, String(newCredPid), { mode: 0o600 });
|
|
788
|
+
}
|
|
789
|
+
catch (_) { }
|
|
790
|
+
}
|
|
791
|
+
controller.releaseManagedDaemon();
|
|
738
792
|
}
|
|
793
|
+
await stopMarketAdapterFromLock();
|
|
739
794
|
try {
|
|
740
|
-
|
|
795
|
+
runtime.kill(pid, 'SIGUSR2');
|
|
741
796
|
}
|
|
742
797
|
catch (err) {
|
|
743
798
|
if (err.code !== 'ESRCH')
|
|
744
799
|
throw err;
|
|
745
800
|
}
|
|
746
801
|
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
802
|
+
process.exit(0);
|
|
747
803
|
return;
|
|
748
804
|
}
|
|
749
805
|
if (effectiveCmd === 'status') {
|
|
@@ -775,23 +831,6 @@ async function handleControl({ cmd, target }) {
|
|
|
775
831
|
displayedBots = [{ name: String(botInfo.botName) }];
|
|
776
832
|
}
|
|
777
833
|
}
|
|
778
|
-
let credPid = null;
|
|
779
|
-
let credForeign = false;
|
|
780
|
-
try {
|
|
781
|
-
const raw = storage.readFile(MONOLITHIC_CRED_PID_FILE).trim();
|
|
782
|
-
const n = Number(raw);
|
|
783
|
-
if (Number.isInteger(n) && n > 0)
|
|
784
|
-
credPid = n;
|
|
785
|
-
}
|
|
786
|
-
catch (_) { }
|
|
787
|
-
if (!credPid && storage.exists(CREDENTIAL_SOCKET_FILE)) {
|
|
788
|
-
const ownerPid = findCredentialSocketOwnerPid();
|
|
789
|
-
if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
|
|
790
|
-
credPid = ownerPid;
|
|
791
|
-
credForeign = true;
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
const credStatus = await readCredentialDaemonStatus(credPid);
|
|
795
834
|
console.log(statusTitle('Monolithic bot'));
|
|
796
835
|
console.log(` ${statusLabel('PID:')} ${targetPid}`);
|
|
797
836
|
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(mem, uptime)}`);
|
|
@@ -800,73 +839,32 @@ async function handleControl({ cmd, target }) {
|
|
|
800
839
|
for (const b of displayedBots) {
|
|
801
840
|
console.log(` - ${statusActiveBotName(b.name)}`);
|
|
802
841
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
else {
|
|
808
|
-
console.log(` ${statusLabel('PID:')} ${credPid || '-'}`);
|
|
809
|
-
}
|
|
810
|
-
if (credPid && isPidAlive(credPid) && isLikelyCredentialDaemonProcess(credPid)) {
|
|
811
|
-
const credUptime = readProcUptime(credPid);
|
|
812
|
-
const credMem = readProcMemMB(credPid);
|
|
813
|
-
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(credMem, credUptime)}`);
|
|
814
|
-
console.log(` ${statusLabel('Alive:')} ${statusBool(true)}`);
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
console.log(` ${statusLabel('Alive:')} ${statusBool(false)}`);
|
|
818
|
-
}
|
|
819
|
-
console.log(` ${statusLabel('Ready:')} ${statusBool(credStatus.ready)}`);
|
|
820
|
-
console.log(` ${statusLabel('Socket:')} ${statusBool(credStatus.socket)}`);
|
|
821
|
-
if (credForeign) {
|
|
822
|
-
console.log(` ${colorStatus('Rerun `dexbot unlock` to detach the foreign daemon and unlock with a fresh master password.', STATUS_COLORS.warn)}`);
|
|
823
|
-
}
|
|
824
|
-
const adapterPid = readMarketAdapterLockPid();
|
|
825
|
-
const adapterAlive = adapterPid > 0 && (0, market_adapter_runtime_1.isLikelyMarketAdapterProcess)(adapterPid);
|
|
826
|
-
const amaBots = listConfiguredBots().filter((b) => b.active && usesAmaGridPrice(b));
|
|
827
|
-
console.log(` ${statusTitle('Market adapter:')}`);
|
|
828
|
-
if (adapterAlive) {
|
|
829
|
-
console.log(` ${statusLabel('PID:')} ${adapterPid}`);
|
|
830
|
-
console.log(` ${statusLabel('Memory:')} ${formatMemoryWithUptime(readProcMemMB(adapterPid), readProcUptime(adapterPid))}`);
|
|
831
|
-
}
|
|
832
|
-
else if (adapterPid > 0) {
|
|
833
|
-
console.log(` ${statusLabel('PID:')} ${adapterPid} ${colorStatus('(not alive)', STATUS_COLORS.warn)}`);
|
|
834
|
-
}
|
|
835
|
-
else {
|
|
836
|
-
console.log(` ${colorStatus('(not running)', STATUS_COLORS.muted)}`);
|
|
837
|
-
}
|
|
838
|
-
function botKeyFromName(name) {
|
|
839
|
-
return String(name).trim().toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'bot';
|
|
840
|
-
}
|
|
841
|
-
console.log(` ${statusLabel('Active:')} ${formatBotCount(amaBots.length)}`);
|
|
842
|
-
for (const b of amaBots) {
|
|
843
|
-
const flags = (0, market_adapter_whitelist_1.getWhitelistFlags)(botKeyFromName(b.name));
|
|
844
|
-
const indicators = [];
|
|
845
|
-
if (flags.asymmetricBounds)
|
|
846
|
-
indicators.push('range');
|
|
847
|
-
if (flags.dynamicWeight)
|
|
848
|
-
indicators.push('weight');
|
|
849
|
-
const suffix = indicators.length > 0 ? `, ${indicators.join(', ')}` : '';
|
|
850
|
-
console.log(` - ${colorStatus(b.name, STATUS_COLORS.ok)} (${b.gridPrice}${suffix})`);
|
|
851
|
-
}
|
|
842
|
+
const { pid: credPid, foreign: credForeign } = resolveCredentialDaemonForStatus();
|
|
843
|
+
await printCredentialDaemonStatusBlock(credPid, credForeign);
|
|
844
|
+
printMarketAdapterStatusBlock();
|
|
852
845
|
return;
|
|
853
846
|
}
|
|
854
847
|
let monolithicExited = false;
|
|
855
848
|
try {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
if (!monolithicExited && effectiveCmd === 'delete') {
|
|
860
|
-
runtime_1.runtime.kill(pid, 'SIGKILL');
|
|
861
|
-
monolithicExited = await waitForPidExit(pid, 2000);
|
|
862
|
-
if (!monolithicExited) {
|
|
863
|
-
throw new Error(`monolithic wrapper PID ${pid} did not exit after SIGKILL`);
|
|
864
|
-
}
|
|
849
|
+
if (isProcessInDstate(pid)) {
|
|
850
|
+
console.warn(`monolithic wrapper PID ${pid} is in uninterruptible sleep (D-state), cannot kill. Cleaning up state.`);
|
|
851
|
+
monolithicExited = true;
|
|
865
852
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
853
|
+
else {
|
|
854
|
+
runtime.kill(pid, 'SIGTERM');
|
|
855
|
+
const timeoutMs = effectiveCmd === 'delete' ? LAUNCHER.MONOLITHIC.controlStopTimeoutMs : 5000;
|
|
856
|
+
monolithicExited = await waitForPidExit(pid, timeoutMs);
|
|
857
|
+
if (!monolithicExited && effectiveCmd === 'delete') {
|
|
858
|
+
if (isProcessInDstate(pid)) {
|
|
859
|
+
console.warn(`monolithic wrapper PID ${pid} is in D-state, skipping SIGKILL.`);
|
|
860
|
+
}
|
|
861
|
+
else {
|
|
862
|
+
runtime.kill(pid, 'SIGKILL');
|
|
863
|
+
monolithicExited = await waitForPidExit(pid, 2000);
|
|
864
|
+
if (!monolithicExited) {
|
|
865
|
+
console.warn(`monolithic wrapper PID ${pid} did not exit after SIGKILL (may be in uninterruptible sleep). Cleaning up state.`);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
870
868
|
}
|
|
871
869
|
}
|
|
872
870
|
}
|
|
@@ -876,10 +874,16 @@ async function handleControl({ cmd, target }) {
|
|
|
876
874
|
monolithicExited = true;
|
|
877
875
|
}
|
|
878
876
|
finally {
|
|
879
|
-
if (effectiveCmd
|
|
877
|
+
if (effectiveCmd === 'delete' || monolithicExited) {
|
|
880
878
|
cleanupStateFiles();
|
|
881
879
|
}
|
|
882
880
|
}
|
|
881
|
+
if (effectiveCmd === 'delete') {
|
|
882
|
+
const credResult = await stopCredentialDaemon();
|
|
883
|
+
if (credResult.signaled) {
|
|
884
|
+
console.log('Stop signal sent to credential daemon');
|
|
885
|
+
}
|
|
886
|
+
}
|
|
883
887
|
printControlActionSummary(actionLabel, summaryBotNames, summaryServiceNames);
|
|
884
888
|
return;
|
|
885
889
|
}
|
|
@@ -898,6 +902,22 @@ async function handleControl({ cmd, target }) {
|
|
|
898
902
|
console.log(effectiveCmd === 'delete' ? 'Removed stale monolithic PID file' : 'Monolithic bot not running (stale PID file)');
|
|
899
903
|
return;
|
|
900
904
|
}
|
|
905
|
+
else if (effectiveCmd === 'status') {
|
|
906
|
+
// The monolithic runtime is stopped (bots + market adapter down),
|
|
907
|
+
// but the credential daemon may still be running — a `dexbot stop`
|
|
908
|
+
// leaves it alive for faster re-unlock. Report that state instead of
|
|
909
|
+
// falling through to an isolated supervisor socket that is absent.
|
|
910
|
+
const daemon = resolveCredentialDaemonForStatus();
|
|
911
|
+
if (daemon.pid && isPidAlive(daemon.pid) && isLikelyCredentialDaemonProcess(daemon.pid)) {
|
|
912
|
+
console.log(statusTitle('Monolithic bot'));
|
|
913
|
+
console.log(` ${colorStatus('(offline)', STATUS_COLORS.warn)}`);
|
|
914
|
+
console.log();
|
|
915
|
+
await printCredentialDaemonStatusBlock(daemon.pid, daemon.foreign);
|
|
916
|
+
console.log();
|
|
917
|
+
printMarketAdapterStatusBlock();
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
901
921
|
}
|
|
902
922
|
if (effectiveCmd === 'delete' && !target && storage.exists(MONOLITHIC_CRED_PID_FILE)) {
|
|
903
923
|
await sendIsolatedDeleteIfAvailable();
|
|
@@ -915,8 +935,22 @@ async function handleControl({ cmd, target }) {
|
|
|
915
935
|
const controlCmd = { cmd: effectiveCmd };
|
|
916
936
|
if (target)
|
|
917
937
|
controlCmd.bot = target;
|
|
938
|
+
// Restart credential daemon for restart-all (no target) in isolated mode
|
|
939
|
+
if (!target && effectiveCmd === 'restart-all' && process.stdin.isTTY) {
|
|
940
|
+
const ownerPid = findCredentialSocketOwnerPid();
|
|
941
|
+
if (ownerPid > 0 && isLikelyCredentialDaemonProcess(ownerPid)) {
|
|
942
|
+
await stopCredentialDaemonPid(ownerPid);
|
|
943
|
+
}
|
|
944
|
+
cleanupCredentialRuntimeFiles();
|
|
945
|
+
const daemonOpts = { detached: true };
|
|
946
|
+
const unlockedNow = await controller.ensureCredentialDaemon(daemonOpts);
|
|
947
|
+
if (unlockedNow) {
|
|
948
|
+
console.log(statusSuccess('✓ Authentication successful'));
|
|
949
|
+
}
|
|
950
|
+
controller.releaseManagedDaemon();
|
|
951
|
+
}
|
|
918
952
|
try {
|
|
919
|
-
const resp = await
|
|
953
|
+
const resp = await sendControlCommand(controlCmd);
|
|
920
954
|
if (resp.ok && resp.status) {
|
|
921
955
|
printControlStatus(resp.status);
|
|
922
956
|
}
|
|
@@ -934,39 +968,41 @@ async function handleControl({ cmd, target }) {
|
|
|
934
968
|
console.log('No runtime processes found.');
|
|
935
969
|
return;
|
|
936
970
|
}
|
|
937
|
-
console.error(statusError(`control ${cmd}: ${
|
|
971
|
+
console.error(statusError(`control ${cmd}: ${getErrorMessage(err)}`));
|
|
938
972
|
process.exitCode = 1;
|
|
939
973
|
}
|
|
974
|
+
process.exit(0);
|
|
940
975
|
}
|
|
941
976
|
// ── Bootstrap ──────────────────────────────────────────────────────
|
|
942
|
-
const isUnlockStartDirectRun =
|
|
943
|
-
|
|
977
|
+
const isUnlockStartDirectRun = !!process.argv[1] && (import.meta.url === pathToFileURL(process.argv[1]).href ||
|
|
978
|
+
path.parse(process.argv[1]).name === 'unlock');
|
|
944
979
|
if (isUnlockStartDirectRun) {
|
|
945
|
-
|
|
946
|
-
if (
|
|
947
|
-
|
|
980
|
+
setupGracefulShutdown();
|
|
981
|
+
if (Config.DEXBOT_ISOLATED_CHILD) {
|
|
982
|
+
registerCleanup('Credential daemon', () => stopCredentialDaemonPid(Config.DEXBOT_MANAGED_CRED_PID));
|
|
948
983
|
}
|
|
949
|
-
else if (
|
|
950
|
-
|
|
951
|
-
|
|
984
|
+
else if (Config.DEXBOT_MONOLITHIC_BG) {
|
|
985
|
+
registerCleanup('PID files', cleanupStateFiles);
|
|
986
|
+
registerCleanup('Bot process', async () => {
|
|
952
987
|
const bot = botProcessRef.current;
|
|
953
988
|
if (bot && !bot.killed) {
|
|
954
989
|
forwardSignal(bot, 'SIGTERM');
|
|
955
|
-
await
|
|
990
|
+
await withTimeout(new Promise((resolve) => bot.once('close', resolve)), LAUNCHER.MONOLITHIC.SHUTDOWN_GRACE_MS, { onTimeout: 'resolve', defaultValue: undefined });
|
|
956
991
|
}
|
|
957
992
|
});
|
|
958
993
|
}
|
|
959
994
|
else {
|
|
960
|
-
|
|
995
|
+
registerCleanup('Credential daemon', () => controller.stopManagedDaemon());
|
|
961
996
|
}
|
|
962
997
|
(async () => {
|
|
963
998
|
try {
|
|
964
999
|
await main();
|
|
965
1000
|
}
|
|
966
1001
|
catch (err) {
|
|
967
|
-
console.error(statusError(`unlock failed: ${
|
|
1002
|
+
console.error(statusError(`unlock failed: ${getErrorMessage(err) || err}`));
|
|
968
1003
|
process.exit(1);
|
|
969
1004
|
}
|
|
970
1005
|
})();
|
|
971
1006
|
}
|
|
1007
|
+
export { buildDexbotStartArgs, candidateRuntimeScriptPaths, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, isLikelyCredentialDaemonProcess, main, pidMatchesScriptCandidates, waitForChildSpawn, waitForStableChildStartup };
|
|
972
1008
|
//# sourceMappingURL=unlock.js.map
|