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
|
@@ -1,53 +1,17 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
1
3
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.DirectKeyStore = exports.DaemonKeyStore = void 0;
|
|
37
|
-
exports.setKeyStore = setKeyStore;
|
|
38
|
-
exports.resetKeyStore = resetKeyStore;
|
|
39
|
-
exports.getKeyStore = getKeyStore;
|
|
40
|
-
const chainKeys = __importStar(require("./chain_keys"));
|
|
41
|
-
const credentialPolicy = __importStar(require("./credential_policy"));
|
|
42
|
-
const credentialRuntime = __importStar(require("./credential_runtime"));
|
|
43
|
-
const dexbot_credential_client_1 = require("./dexbot_credential_client");
|
|
44
|
-
const constants_1 = require("./constants");
|
|
45
|
-
const paths_1 = require("./paths");
|
|
46
|
-
const storage_1 = require("./storage");
|
|
47
|
-
const runtime_1 = require("./runtime");
|
|
48
|
-
const system_1 = require("./order/utils/system");
|
|
49
|
-
const errors_1 = require("./utils/errors");
|
|
50
|
-
const storage = (0, storage_1.getStorage)();
|
|
4
|
+
import * as chainKeys from './chain_keys.js';
|
|
5
|
+
import * as credentialPolicy from './credential_policy.js';
|
|
6
|
+
import * as credentialRuntime from './credential_runtime.js';
|
|
7
|
+
import { executeOperationsViaCredentialDaemon, BroadcastUncertainError, } from './dexbot_credential_client.js';
|
|
8
|
+
import { DAEMON_ERRORS } from './constants.js';
|
|
9
|
+
import { PATHS } from './paths.js';
|
|
10
|
+
import { getStorage } from './storage/index.js';
|
|
11
|
+
import { runtime } from './runtime.js';
|
|
12
|
+
import { sleep } from './order/utils/system.js';
|
|
13
|
+
import { getErrorMessage } from './utils/errors.js';
|
|
14
|
+
const storage = getStorage();
|
|
51
15
|
function buildDaemonBroadcastOptions(signingKey, extraOptions, sessionIdOverride) {
|
|
52
16
|
return {
|
|
53
17
|
socketPath: signingKey.socketPath,
|
|
@@ -84,7 +48,7 @@ async function broadcastViaChainOrders(accountName, operations, signingKey) {
|
|
|
84
48
|
await broadcastTxWithClassification(tx, accountName, operations);
|
|
85
49
|
return { success: true };
|
|
86
50
|
}
|
|
87
|
-
class DaemonKeyStore {
|
|
51
|
+
export class DaemonKeyStore {
|
|
88
52
|
async resolveSigningKey(accountName, vaultSecret, chainClient) {
|
|
89
53
|
if (vaultSecret) {
|
|
90
54
|
return chainKeys.resolvePrivateKey(accountName, vaultSecret, chainClient);
|
|
@@ -92,7 +56,7 @@ class DaemonKeyStore {
|
|
|
92
56
|
if (await chainKeys.isDaemonResponsive()) {
|
|
93
57
|
try {
|
|
94
58
|
const sessionId = await chainKeys.probeAccountInDaemon(accountName);
|
|
95
|
-
const botHmacSecret = credentialPolicy.loadBotHmacSecret(accountName,
|
|
59
|
+
const botHmacSecret = credentialPolicy.loadBotHmacSecret(accountName, PATHS.PROFILES.DAEMON_POLICIES_JSON, { quiet: true });
|
|
96
60
|
return chainKeys.createDaemonSigningToken(accountName, { sessionId, botHmacSecret });
|
|
97
61
|
}
|
|
98
62
|
catch {
|
|
@@ -109,21 +73,21 @@ class DaemonKeyStore {
|
|
|
109
73
|
async executeOperations(accountName, operations, signingKey, extraOptions = {}) {
|
|
110
74
|
if (this.isDaemonSigningKey(signingKey)) {
|
|
111
75
|
try {
|
|
112
|
-
const result = await
|
|
76
|
+
const result = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(signingKey, extraOptions));
|
|
113
77
|
return normalizeDaemonResult(result);
|
|
114
78
|
}
|
|
115
79
|
catch (err) {
|
|
116
|
-
if (err instanceof
|
|
80
|
+
if (err instanceof BroadcastUncertainError)
|
|
117
81
|
throw err;
|
|
118
|
-
if (
|
|
119
|
-
const isSourceAuthError =
|
|
82
|
+
if (getErrorMessage(err) && (getErrorMessage(err).includes(DAEMON_ERRORS.SESSION_EXPIRED) || getErrorMessage(err).includes(DAEMON_ERRORS.SOURCE_AUTH_DENIED))) {
|
|
83
|
+
const isSourceAuthError = getErrorMessage(err).includes(DAEMON_ERRORS.SOURCE_AUTH_DENIED);
|
|
120
84
|
if (isSourceAuthError) {
|
|
121
85
|
try {
|
|
122
|
-
const readyFile = credentialRuntime.getCredentialReadyFilePath({ root:
|
|
86
|
+
const readyFile = credentialRuntime.getCredentialReadyFilePath({ root: PATHS.PROJECT_ROOT });
|
|
123
87
|
if (storage.exists(readyFile)) {
|
|
124
88
|
const daemonInfo = storage.readJSON(readyFile);
|
|
125
89
|
if (daemonInfo && typeof daemonInfo.pid === 'number') {
|
|
126
|
-
|
|
90
|
+
runtime.kill(daemonInfo.pid, 'SIGHUP');
|
|
127
91
|
}
|
|
128
92
|
}
|
|
129
93
|
}
|
|
@@ -132,9 +96,9 @@ class DaemonKeyStore {
|
|
|
132
96
|
const newSessionId = await chainKeys.probeAccountInDaemon(accountName);
|
|
133
97
|
signingKey.sessionId = newSessionId;
|
|
134
98
|
if (isSourceAuthError) {
|
|
135
|
-
await
|
|
99
|
+
await sleep(500);
|
|
136
100
|
}
|
|
137
|
-
const retryResult = await
|
|
101
|
+
const retryResult = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(signingKey, extraOptions, signingKey.sessionId));
|
|
138
102
|
return normalizeDaemonResult(retryResult);
|
|
139
103
|
}
|
|
140
104
|
throw err;
|
|
@@ -143,8 +107,7 @@ class DaemonKeyStore {
|
|
|
143
107
|
return broadcastViaChainOrders(accountName, operations, signingKey);
|
|
144
108
|
}
|
|
145
109
|
}
|
|
146
|
-
|
|
147
|
-
class DirectKeyStore {
|
|
110
|
+
export class DirectKeyStore {
|
|
148
111
|
async resolveSigningKey(accountName, vaultSecret, chainClient) {
|
|
149
112
|
if (vaultSecret) {
|
|
150
113
|
return chainKeys.resolvePrivateKey(accountName, vaultSecret, chainClient);
|
|
@@ -157,15 +120,14 @@ class DirectKeyStore {
|
|
|
157
120
|
return broadcastViaChainOrders(accountName, operations, signingKey);
|
|
158
121
|
}
|
|
159
122
|
}
|
|
160
|
-
exports.DirectKeyStore = DirectKeyStore;
|
|
161
123
|
let _instance = null;
|
|
162
|
-
function setKeyStore(impl) {
|
|
124
|
+
export function setKeyStore(impl) {
|
|
163
125
|
_instance = impl;
|
|
164
126
|
}
|
|
165
|
-
function resetKeyStore() {
|
|
127
|
+
export function resetKeyStore() {
|
|
166
128
|
_instance = null;
|
|
167
129
|
}
|
|
168
|
-
function getKeyStore() {
|
|
130
|
+
export function getKeyStore() {
|
|
169
131
|
if (!_instance) {
|
|
170
132
|
_instance = new DaemonKeyStore();
|
|
171
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key_store.js","sourceRoot":"","sources":["../../modules/key_store.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"key_store.js","sourceRoot":"","sources":["../../modules/key_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,YAAY,CAAC;AAEb,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,iBAAiB,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACH,oCAAoC,EACpC,uBAAuB,GAC1B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;AAc7B,SAAS,2BAA2B,CAAC,UAAe,EAAE,YAAi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ACpD,OAAO,SAAS,CAAC,iBAAiB,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAC/E,CAAC;IAED,kBAAkB,CAAC,IAAS,IAAa,OAAO,KAAK,CAAC,CAAC,CAAC;IAExD,KAAK,CAAC,iBAAiB,CAAC,WAAmB,EAAE,UAAiB,EAAE,UAAe;QAC3E,OAAO,uBAAuB,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IACxE,CAAC;CACJ;AAED,IAAI,SAAS,GAAoB,IAAI,CAAC;AAEtC,MAAM,UAAU,WAAW,CAAC,IAAqB;IAC7C,SAAS,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,aAAa;IACzB,SAAS,GAAG,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,WAAW;IACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,SAAS,GAAG,IAAI,cAAc,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot_supervisor.d.ts","sourceRoot":"","sources":["../../../modules/launcher/bot_supervisor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bot_supervisor.d.ts","sourceRoot":"","sources":["../../../modules/launcher/bot_supervisor.ts"],"names":[],"mappings":"AAcA,OAAO,EAAuB,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAY5E,QAAA,MAAM,WAAW,QAAoE,CAAC;AAiBtF,iBAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,WAGjC;AAgID,iBAAS,mBAAmB,CAAC,UAAU,EAAE,GAAG;;;;;;EAY3C;AAqBD,iBAAS,eAAe,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,GAAE,GAAgB,QAYjE;AAqBD,iBAAS,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,QAO7C;AAED,iBAAS,UAAU,CA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AE,iBAAiB,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,50 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exports.scriptPathForRoot = scriptPathForRoot;
|
|
17
|
-
exports.candidateRuntimeScriptPaths = candidateRuntimeScriptPaths;
|
|
18
|
-
exports.pidMatchesScriptCandidates = pidMatchesScriptCandidates;
|
|
19
|
-
exports.isNodeProcessWithExactScript = isNodeProcessWithExactScript;
|
|
20
|
-
exports.readMarketAdapterLockPid = readMarketAdapterLockPid;
|
|
21
|
-
exports.stopMarketAdapterFromLock = stopMarketAdapterFromLock;
|
|
22
|
-
exports.usesAmaGridPrice = usesAmaGridPrice;
|
|
23
|
-
exports.waitForChildSpawn = waitForChildSpawn;
|
|
24
|
-
exports.getChildRSS = getChildRSS;
|
|
25
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
26
|
-
const path_api_1 = require("../path_api");
|
|
27
|
-
const node_net_1 = __importDefault(require("node:net"));
|
|
28
|
-
const storage_1 = require("../storage");
|
|
29
|
-
const node_child_process_1 = require("node:child_process");
|
|
30
|
-
const child_env_1 = require("./child_env");
|
|
31
|
-
const paths_1 = require("../paths");
|
|
32
|
-
const bot_settings_1 = require("../bot_settings");
|
|
33
|
-
const constants_1 = require("../constants");
|
|
34
|
-
const fs_utils_1 = require("../utils/fs_utils");
|
|
35
|
-
const config_1 = require("../config");
|
|
36
|
-
const process_discovery_1 = require("../process_discovery");
|
|
37
|
-
Object.defineProperty(exports, "formatUptime", { enumerable: true, get: function () { return process_discovery_1.formatUptime; } });
|
|
38
|
-
const runtime_1 = require("../runtime");
|
|
39
|
-
const system_1 = require("../order/utils/system");
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { path } from '../path_api.js';
|
|
5
|
+
import net from 'node:net';
|
|
6
|
+
import { getStorage } from '../storage/index.js';
|
|
7
|
+
import { spawn } from 'node:child_process';
|
|
8
|
+
import { buildScopedChildEnv } from './child_env.js';
|
|
9
|
+
import { PATHS } from '../paths.js';
|
|
10
|
+
import { normalizeBotEntries, resolveRawBotEntries, loadSettingsFile } from '../bot_settings.js';
|
|
11
|
+
import { UPDATER, BUILD_DIR, LAUNCHER } from '../constants.js';
|
|
12
|
+
import { Config } from '../config.js';
|
|
13
|
+
import { getProcessDiscovery, formatUptime } from '../process_discovery.js';
|
|
14
|
+
import { runtime } from '../runtime.js';
|
|
15
|
+
import { sleep } from '../order/utils/system.js';
|
|
40
16
|
'use strict';
|
|
41
|
-
const storage =
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
const { MAX_RESTARTS, MIN_UPTIME_MS, RESTART_DELAY_MS, SHUTDOWN_TIMEOUT_MS, STAGGER_DELAY_MS, MAX_MEMORY_MB, MEMORY_CHECK_INTERVAL_MS, STATUS_LOG_INTERVAL_MS, MAX_CRON_LOOKAHEAD_MINUTES, } =
|
|
17
|
+
const storage = getStorage();
|
|
18
|
+
const { ensureDir, readJSON, unlink: safeUnlink } = storage;
|
|
19
|
+
import { buildRuntimeScriptPath, isDistCodeRoot, SCRIPTS_ROOT as CODE_ROOT } from './runtime_entry.js';
|
|
20
|
+
import { getErrorMessage } from '../utils/errors.js';
|
|
21
|
+
const BOT_SCRIPT = buildRuntimeScriptPath(CODE_ROOT, ['bot']);
|
|
22
|
+
const SOCKET_PATH = Config.DEXBOT_SUPERVISOR_SOCKET || PATHS.PROFILES.SUPERVISOR_SOCK;
|
|
23
|
+
const { MAX_RESTARTS, MIN_UPTIME_MS, RESTART_DELAY_MS, SHUTDOWN_TIMEOUT_MS, STAGGER_DELAY_MS, MAX_MEMORY_MB, MEMORY_CHECK_INTERVAL_MS, STATUS_LOG_INTERVAL_MS, MAX_CRON_LOOKAHEAD_MINUTES, } = LAUNCHER.SUPERVISOR;
|
|
48
24
|
const MAX_MEMORY_BYTES = MAX_MEMORY_MB * 1024 * 1024;
|
|
49
25
|
const SUPERVISOR_PREFIX = '[supervisor]';
|
|
50
26
|
function usesAmaGridPrice(bot) {
|
|
@@ -59,16 +35,16 @@ function isServiceApp(app) {
|
|
|
59
35
|
return name === 'dexbot-update' || name === 'dexbot-adapter';
|
|
60
36
|
}
|
|
61
37
|
function ensureLogDir() {
|
|
62
|
-
if (!storage.exists(
|
|
63
|
-
|
|
38
|
+
if (!storage.exists(PATHS.LOGS_DIR)) {
|
|
39
|
+
ensureDir(PATHS.LOGS_DIR);
|
|
64
40
|
}
|
|
65
41
|
}
|
|
66
42
|
function loadActiveBots(explicitBots) {
|
|
67
43
|
if (explicitBots)
|
|
68
44
|
return explicitBots;
|
|
69
|
-
const { config } =
|
|
70
|
-
const raw =
|
|
71
|
-
return
|
|
45
|
+
const { config } = loadSettingsFile(PATHS.PROFILES.BOTS_JSON);
|
|
46
|
+
const raw = resolveRawBotEntries(config);
|
|
47
|
+
return normalizeBotEntries(raw).filter((b) => b.active !== false);
|
|
72
48
|
}
|
|
73
49
|
function buildSupervisedApps(bots, updaterActive) {
|
|
74
50
|
const apps = (bots || []).map((bot, index) => {
|
|
@@ -78,40 +54,40 @@ function buildSupervisedApps(bots, updaterActive) {
|
|
|
78
54
|
name: botName,
|
|
79
55
|
script: BOT_SCRIPT,
|
|
80
56
|
args: botName,
|
|
81
|
-
cwd:
|
|
57
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
82
58
|
max_memory_restart: '250M',
|
|
83
|
-
error_file:
|
|
84
|
-
out_file:
|
|
85
|
-
max_restarts:
|
|
86
|
-
min_uptime:
|
|
87
|
-
restart_delay:
|
|
59
|
+
error_file: path.join(PATHS.LOGS_DIR, `${botName}-error.log`),
|
|
60
|
+
out_file: path.join(PATHS.LOGS_DIR, `${botName}.log`),
|
|
61
|
+
max_restarts: MAX_RESTARTS,
|
|
62
|
+
min_uptime: MIN_UPTIME_MS,
|
|
63
|
+
restart_delay: RESTART_DELAY_MS,
|
|
88
64
|
};
|
|
89
65
|
});
|
|
90
66
|
if (needsMarketAdapter(bots)) {
|
|
91
67
|
apps.unshift({
|
|
92
68
|
kind: 'service',
|
|
93
69
|
name: 'dexbot-adapter',
|
|
94
|
-
script:
|
|
95
|
-
cwd:
|
|
70
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['market_adapter', 'market_adapter']),
|
|
71
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
96
72
|
max_memory_restart: '150M',
|
|
97
|
-
error_file:
|
|
98
|
-
out_file:
|
|
99
|
-
max_restarts:
|
|
73
|
+
error_file: path.join(PATHS.LOGS_DIR, 'dexbot-adapter-error.log'),
|
|
74
|
+
out_file: path.join(PATHS.LOGS_DIR, 'dexbot-adapter.log'),
|
|
75
|
+
max_restarts: MAX_RESTARTS,
|
|
100
76
|
min_uptime: 60000,
|
|
101
|
-
restart_delay:
|
|
77
|
+
restart_delay: RESTART_DELAY_MS,
|
|
102
78
|
});
|
|
103
79
|
}
|
|
104
80
|
if (updaterActive) {
|
|
105
81
|
apps.push({
|
|
106
82
|
kind: 'job',
|
|
107
83
|
name: 'dexbot-update',
|
|
108
|
-
script:
|
|
109
|
-
cwd:
|
|
110
|
-
error_file:
|
|
111
|
-
out_file:
|
|
84
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['scripts', 'update']),
|
|
85
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
86
|
+
error_file: path.join(PATHS.LOGS_DIR, 'dexbot-update-error.log'),
|
|
87
|
+
out_file: path.join(PATHS.LOGS_DIR, 'dexbot-update.log'),
|
|
112
88
|
autorestart: false,
|
|
113
89
|
bulk_control: false,
|
|
114
|
-
cron_schedule:
|
|
90
|
+
cron_schedule: UPDATER.SCHEDULE,
|
|
115
91
|
});
|
|
116
92
|
}
|
|
117
93
|
return apps;
|
|
@@ -242,52 +218,46 @@ function forwardSignal(child, signal) {
|
|
|
242
218
|
}
|
|
243
219
|
}
|
|
244
220
|
function isPidAlive(pid) {
|
|
245
|
-
return
|
|
221
|
+
return getProcessDiscovery().isAlive(pid);
|
|
246
222
|
}
|
|
247
223
|
async function waitForPidExit(pid, timeoutMs) {
|
|
248
224
|
const started = Date.now();
|
|
249
225
|
while (Date.now() - started < timeoutMs) {
|
|
250
226
|
if (!isPidAlive(pid))
|
|
251
227
|
return true;
|
|
252
|
-
await
|
|
228
|
+
await sleep(200);
|
|
253
229
|
}
|
|
254
230
|
return !isPidAlive(pid);
|
|
255
231
|
}
|
|
256
232
|
function readProcArgs(pid) {
|
|
257
|
-
return
|
|
233
|
+
return getProcessDiscovery().readArgs(pid);
|
|
258
234
|
}
|
|
259
235
|
function readProcCwd(pid) {
|
|
260
|
-
return
|
|
236
|
+
return getProcessDiscovery().readCwd(pid);
|
|
261
237
|
}
|
|
262
238
|
function normalizeProcScriptArg(arg, cwd) {
|
|
263
239
|
if (!arg || String(arg).startsWith('-'))
|
|
264
240
|
return '';
|
|
265
241
|
if (!/\.(?:[cm]?js|ts)$/i.test(String(arg)))
|
|
266
242
|
return '';
|
|
267
|
-
return
|
|
268
|
-
?
|
|
269
|
-
:
|
|
243
|
+
return path.isAbsolute(arg)
|
|
244
|
+
? path.normalize(arg)
|
|
245
|
+
: path.resolve(cwd || PATHS.PROJECT_ROOT, arg);
|
|
270
246
|
}
|
|
271
247
|
function scriptPathForRoot(root, scriptSegments, ext) {
|
|
272
248
|
const segments = [...scriptSegments];
|
|
273
249
|
const last = segments.pop();
|
|
274
250
|
segments.push(String(last).replace(/\.(?:[cm]?js|ts)$/i, '') + ext);
|
|
275
|
-
return
|
|
251
|
+
return path.join(root, ...segments);
|
|
276
252
|
}
|
|
277
253
|
function candidateRuntimeScriptPaths(scriptSegments) {
|
|
278
254
|
const candidates = new Set([
|
|
279
|
-
|
|
280
|
-
scriptPathForRoot(
|
|
281
|
-
scriptPathForRoot(
|
|
255
|
+
buildRuntimeScriptPath(CODE_ROOT, scriptSegments),
|
|
256
|
+
scriptPathForRoot(PATHS.PROJECT_ROOT, scriptSegments, '.ts'),
|
|
257
|
+
scriptPathForRoot(path.join(PATHS.PROJECT_ROOT, BUILD_DIR), scriptSegments, '.js'),
|
|
282
258
|
]);
|
|
283
259
|
if (scriptSegments.length === 1) {
|
|
284
|
-
candidates.add(scriptPathForRoot(
|
|
285
|
-
}
|
|
286
|
-
// Compatibility for wrappers already running from before the unlock-start -> unlock rename.
|
|
287
|
-
if (scriptSegments.length === 1 && scriptSegments[0] === 'unlock') {
|
|
288
|
-
candidates.add(scriptPathForRoot(paths_1.PATHS.PROJECT_ROOT, ['unlock-start'], '.js'));
|
|
289
|
-
candidates.add(scriptPathForRoot(paths_1.PATHS.PROJECT_ROOT, ['unlock-start'], '.ts'));
|
|
290
|
-
candidates.add(scriptPathForRoot(path_api_1.path.join(paths_1.PATHS.PROJECT_ROOT, constants_1.BUILD_DIR), ['unlock-start'], '.js'));
|
|
260
|
+
candidates.add(scriptPathForRoot(PATHS.PROJECT_ROOT, scriptSegments, '.js'));
|
|
291
261
|
}
|
|
292
262
|
return candidates;
|
|
293
263
|
}
|
|
@@ -295,7 +265,7 @@ function pidMatchesScriptCandidates(pid, expectedPaths) {
|
|
|
295
265
|
if (!expectedPaths || expectedPaths.size === 0)
|
|
296
266
|
return false;
|
|
297
267
|
const args = readProcArgs(pid);
|
|
298
|
-
if (!args.some((arg) =>
|
|
268
|
+
if (!args.some((arg) => path.basename(String(arg)).includes('node'))) {
|
|
299
269
|
return false;
|
|
300
270
|
}
|
|
301
271
|
const cwd = readProcCwd(pid);
|
|
@@ -312,7 +282,7 @@ function isNodeProcessWithExactScript(pid, scriptSegments) {
|
|
|
312
282
|
}
|
|
313
283
|
function readMarketAdapterLockPid() {
|
|
314
284
|
try {
|
|
315
|
-
const info =
|
|
285
|
+
const info = readJSON(PATHS.MARKET_ADAPTER.LOCK_FILE);
|
|
316
286
|
const pid = Number(info.pid);
|
|
317
287
|
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
318
288
|
}
|
|
@@ -326,10 +296,10 @@ async function stopMarketAdapterFromLock(timeoutMs = 5000) {
|
|
|
326
296
|
return { pid, stopped: false };
|
|
327
297
|
}
|
|
328
298
|
try {
|
|
329
|
-
|
|
299
|
+
runtime.kill(pid, 'SIGTERM');
|
|
330
300
|
let stopped = await waitForPidExit(pid, timeoutMs);
|
|
331
301
|
if (!stopped && isNodeProcessWithExactScript(pid, ['market_adapter', 'market_adapter'])) {
|
|
332
|
-
|
|
302
|
+
runtime.kill(pid, 'SIGKILL');
|
|
333
303
|
stopped = await waitForPidExit(pid, 2000);
|
|
334
304
|
}
|
|
335
305
|
return { pid, stopped };
|
|
@@ -345,12 +315,12 @@ function getChildRSS(child) {
|
|
|
345
315
|
if (!child || !child.pid)
|
|
346
316
|
return -1;
|
|
347
317
|
try {
|
|
348
|
-
if (
|
|
349
|
-
const bytes =
|
|
318
|
+
if (Config.PLATFORM === 'linux') {
|
|
319
|
+
const bytes = getProcessDiscovery().readRSSBytes(child.pid);
|
|
350
320
|
if (bytes > 0)
|
|
351
321
|
return bytes;
|
|
352
322
|
}
|
|
353
|
-
else if (
|
|
323
|
+
else if (Config.PLATFORM === 'darwin') {
|
|
354
324
|
const { execSync } = require('child_process');
|
|
355
325
|
const out = execSync(`ps -o rss= -p ${child.pid}`, { encoding: 'utf8', timeout: 3000 });
|
|
356
326
|
const rssKB = parseInt(out.trim(), 10);
|
|
@@ -386,7 +356,7 @@ function waitForChildSpawn(child) {
|
|
|
386
356
|
child.once('error', handleError);
|
|
387
357
|
});
|
|
388
358
|
}
|
|
389
|
-
function createBotSupervisor({ bots = null, buildEnv =
|
|
359
|
+
function createBotSupervisor({ bots = null, buildEnv = buildScopedChildEnv, spawnFn = spawn, log = (...args) => console.log(SUPERVISOR_PREFIX, ...args), logError = (...args) => console.error(SUPERVISOR_PREFIX, ...args), controlSocket = !Config.DEXBOT_DISABLE_SUPERVISOR_SOCKET, getChildRss = getChildRSS, memoryCheckIntervalMs = MEMORY_CHECK_INTERVAL_MS, statusLogIntervalMs = STATUS_LOG_INTERVAL_MS, staggerDelayMs = STAGGER_DELAY_MS, setTimeoutFn = setTimeout, clearTimeoutFn = clearTimeout, nowFn = () => Date.now(), stopMarketAdapter = stopMarketAdapterFromLock, updaterActive = UPDATER.ACTIVE, } = {}) {
|
|
390
360
|
const botStates = new Map();
|
|
391
361
|
let shuttingDown = false;
|
|
392
362
|
let shutdownResolve = null;
|
|
@@ -416,7 +386,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
416
386
|
for (const [name, state] of botStates) {
|
|
417
387
|
const pid = state.child?.pid || '-';
|
|
418
388
|
const uptime = state.lastStartTime && state.status === 'running'
|
|
419
|
-
?
|
|
389
|
+
? formatUptime(nowFn() - state.lastStartTime)
|
|
420
390
|
: '-';
|
|
421
391
|
let mem = '-';
|
|
422
392
|
if (state.status === 'running' && state.child) {
|
|
@@ -469,7 +439,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
469
439
|
}
|
|
470
440
|
}
|
|
471
441
|
catch (err) {
|
|
472
|
-
logError(`Failed to start scheduled job ${state.name}:`,
|
|
442
|
+
logError(`Failed to start scheduled job ${state.name}:`, getErrorMessage(err));
|
|
473
443
|
state.status = 'crashed';
|
|
474
444
|
}
|
|
475
445
|
finally {
|
|
@@ -481,7 +451,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
481
451
|
}
|
|
482
452
|
}
|
|
483
453
|
catch (err) {
|
|
484
|
-
logError(`Invalid cron schedule for ${state.name}: ${
|
|
454
|
+
logError(`Invalid cron schedule for ${state.name}: ${getErrorMessage(err)}`);
|
|
485
455
|
}
|
|
486
456
|
}
|
|
487
457
|
function runMemoryCheck() {
|
|
@@ -519,28 +489,28 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
519
489
|
return null;
|
|
520
490
|
}
|
|
521
491
|
ensureLogDir();
|
|
522
|
-
const outFile = app.out_file ||
|
|
523
|
-
const errorFile = app.error_file ||
|
|
524
|
-
const outStream =
|
|
525
|
-
const errStream =
|
|
492
|
+
const outFile = app.out_file || path.join(PATHS.LOGS_DIR, `${appName}.log`);
|
|
493
|
+
const errorFile = app.error_file || path.join(PATHS.LOGS_DIR, `${appName}-error.log`);
|
|
494
|
+
const outStream = fs.createWriteStream(outFile, { flags: 'a' });
|
|
495
|
+
const errStream = fs.createWriteStream(errorFile, { flags: 'a' });
|
|
526
496
|
const isBot = !isServiceApp(app);
|
|
527
497
|
const extraEnv = {
|
|
528
498
|
...(app.env || {}),
|
|
529
499
|
DEXBOT_LAUNCH_MODE: 'isolated',
|
|
530
500
|
...(isBot ? { LIVE_BOT_NAME: appName } : {}),
|
|
531
501
|
};
|
|
532
|
-
const runtimeArgs =
|
|
502
|
+
const runtimeArgs = isDistCodeRoot(CODE_ROOT)
|
|
533
503
|
? [app.script || BOT_SCRIPT, ...normalizeAppArgs(app.args)]
|
|
534
504
|
: ['--import', 'tsx', app.script || BOT_SCRIPT, ...normalizeAppArgs(app.args)];
|
|
535
|
-
const child = spawnFn(
|
|
536
|
-
cwd: app.cwd ||
|
|
505
|
+
const child = spawnFn(Config.EXEC_PATH, runtimeArgs, {
|
|
506
|
+
cwd: app.cwd || PATHS.PROJECT_ROOT,
|
|
537
507
|
env: buildEnv({ extra: extraEnv }),
|
|
538
508
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
539
509
|
});
|
|
540
510
|
child.stdout.pipe(outStream);
|
|
541
|
-
child.stdout.pipe(
|
|
511
|
+
child.stdout.pipe(runtime.stdout);
|
|
542
512
|
child.stderr.pipe(errStream);
|
|
543
|
-
child.stderr.pipe(
|
|
513
|
+
child.stderr.pipe(runtime.stderr);
|
|
544
514
|
child.stdout.on('error', () => { });
|
|
545
515
|
child.stderr.on('error', () => { });
|
|
546
516
|
outStream.on('error', () => { });
|
|
@@ -611,7 +581,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
611
581
|
}, restartDelay);
|
|
612
582
|
});
|
|
613
583
|
child.on('error', (err) => {
|
|
614
|
-
logError(`${appName} spawn error:`,
|
|
584
|
+
logError(`${appName} spawn error:`, getErrorMessage(err));
|
|
615
585
|
});
|
|
616
586
|
return child;
|
|
617
587
|
}
|
|
@@ -704,7 +674,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
704
674
|
}
|
|
705
675
|
}
|
|
706
676
|
catch (err) {
|
|
707
|
-
return { error:
|
|
677
|
+
return { error: getErrorMessage(err) };
|
|
708
678
|
}
|
|
709
679
|
}
|
|
710
680
|
function startSocketServer() {
|
|
@@ -716,7 +686,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
716
686
|
settled = true;
|
|
717
687
|
fn(value);
|
|
718
688
|
};
|
|
719
|
-
const testSocket =
|
|
689
|
+
const testSocket = net.createConnection(SOCKET_PATH);
|
|
720
690
|
testSocket.on('connect', () => {
|
|
721
691
|
testSocket.end();
|
|
722
692
|
settle(reject, new Error('Another supervisor instance is already running (socket exists). Stop it first or use a different profile.'));
|
|
@@ -732,8 +702,8 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
732
702
|
}
|
|
733
703
|
function startSocketServerInternal() {
|
|
734
704
|
return new Promise((resolve, reject) => {
|
|
735
|
-
|
|
736
|
-
socketServer =
|
|
705
|
+
safeUnlink(SOCKET_PATH);
|
|
706
|
+
socketServer = net.createServer((socket) => {
|
|
737
707
|
socketConnections.add(socket);
|
|
738
708
|
let buffer = '';
|
|
739
709
|
let commandQueue = Promise.resolve();
|
|
@@ -743,7 +713,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
743
713
|
.then(handler)
|
|
744
714
|
.catch((err) => {
|
|
745
715
|
try {
|
|
746
|
-
socket.write(JSON.stringify({ error:
|
|
716
|
+
socket.write(JSON.stringify({ error: getErrorMessage(err) }) + '\n');
|
|
747
717
|
}
|
|
748
718
|
catch (_) { }
|
|
749
719
|
});
|
|
@@ -793,14 +763,14 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
793
763
|
});
|
|
794
764
|
});
|
|
795
765
|
const onError = (err) => {
|
|
796
|
-
logError(`Socket server error: ${
|
|
766
|
+
logError(`Socket server error: ${getErrorMessage(err)}`);
|
|
797
767
|
reject(err);
|
|
798
768
|
};
|
|
799
769
|
socketServer.once('error', onError);
|
|
800
770
|
socketServer.listen(SOCKET_PATH, () => {
|
|
801
771
|
socketServer.off('error', onError);
|
|
802
772
|
socketServer.on('error', (err) => {
|
|
803
|
-
logError(`Socket server error: ${
|
|
773
|
+
logError(`Socket server error: ${getErrorMessage(err)}`);
|
|
804
774
|
});
|
|
805
775
|
try {
|
|
806
776
|
storage.chmod(SOCKET_PATH, 0o600);
|
|
@@ -810,7 +780,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
810
780
|
resolve(undefined);
|
|
811
781
|
});
|
|
812
782
|
process.once('exit', () => {
|
|
813
|
-
|
|
783
|
+
safeUnlink(SOCKET_PATH);
|
|
814
784
|
});
|
|
815
785
|
});
|
|
816
786
|
}
|
|
@@ -832,7 +802,7 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
832
802
|
catch (_) { }
|
|
833
803
|
}
|
|
834
804
|
socketConnections = new Set([...socketConnections].filter((sock) => preserved.has(sock)));
|
|
835
|
-
|
|
805
|
+
safeUnlink(SOCKET_PATH);
|
|
836
806
|
}
|
|
837
807
|
async function start() {
|
|
838
808
|
const activeBots = loadActiveBots(bots);
|
|
@@ -884,14 +854,14 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
884
854
|
}
|
|
885
855
|
}
|
|
886
856
|
catch (err) {
|
|
887
|
-
logError(`Failed to start ${app.name}:`,
|
|
857
|
+
logError(`Failed to start ${app.name}:`, getErrorMessage(err));
|
|
888
858
|
const state = botStates.get(app.name);
|
|
889
859
|
if (state) {
|
|
890
860
|
state.status = 'crashed';
|
|
891
861
|
}
|
|
892
862
|
}
|
|
893
863
|
if (i < activeApps.length - 1) {
|
|
894
|
-
await
|
|
864
|
+
await sleep(staggerDelayMs);
|
|
895
865
|
}
|
|
896
866
|
}
|
|
897
867
|
for (const [, state] of botStates) {
|
|
@@ -1049,4 +1019,5 @@ function createBotSupervisor({ bots = null, buildEnv = child_env_1.buildScopedCh
|
|
|
1049
1019
|
waitForStableStartup,
|
|
1050
1020
|
};
|
|
1051
1021
|
}
|
|
1022
|
+
export { createBotSupervisor, SOCKET_PATH, parseCronExpression, getNextCronDate, forwardSignal, isPidAlive, waitForPidExit, readProcArgs, readProcCwd, normalizeProcScriptArg, scriptPathForRoot, candidateRuntimeScriptPaths, pidMatchesScriptCandidates, isNodeProcessWithExactScript, readMarketAdapterLockPid, stopMarketAdapterFromLock, usesAmaGridPrice, waitForChildSpawn, getChildRSS, formatUptime };
|
|
1052
1023
|
//# sourceMappingURL=bot_supervisor.js.map
|