dexbot 1.4.11 → 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 +4 -4
- 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 +11 -14
- 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.js +92 -102
- 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 +157 -221
- 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 +2 -9
- package/dist/modules/constants.d.ts.map +1 -1
- package/dist/modules/constants.js +38 -73
- 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 +1 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +1 -1
- package/dist/modules/launcher/monolithic_runtime.js +67 -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 +3 -3
- package/dist/modules/order/grid.d.ts.map +1 -1
- package/dist/modules/order/grid.js +206 -262
- 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.js +28 -69
- 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 -0
- package/dist/modules/order/manager.d.ts.map +1 -1
- package/dist/modules/order/manager.js +131 -151
- 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.js +13 -21
- 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 +77 -89
- 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 +95 -143
- 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/pm2.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 — PM2 process orchestration (spawn, exec, fs, os)
|
|
4
8
|
/**
|
|
5
9
|
* pm2.ts - PM2 Orchestration Launcher
|
|
@@ -46,7 +50,7 @@
|
|
|
46
50
|
*
|
|
47
51
|
* Step 2: ECOSYSTEM CONFIGURATION GENERATION
|
|
48
52
|
* - Reads bot definitions from profiles/bots.json for bot mode
|
|
49
|
-
* - Generates profiles/ecosystem.config.
|
|
53
|
+
* - Generates profiles/ecosystem.config.cjs with absolute paths
|
|
50
54
|
* - Filters only active bots (active !== false)
|
|
51
55
|
* - If bot-name provided, filters to only that bot
|
|
52
56
|
* - In claw-only mode, generates only the credential daemon app
|
|
@@ -68,73 +72,42 @@
|
|
|
68
72
|
* - Credential daemon is started as a PM2 app after one-shot bootstrap
|
|
69
73
|
* - Bots request private keys from credential daemon via Unix socket
|
|
70
74
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
96
|
-
return function (mod) {
|
|
97
|
-
if (mod && mod.__esModule) return mod;
|
|
98
|
-
var result = {};
|
|
99
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
100
|
-
__setModuleDefault(result, mod);
|
|
101
|
-
return result;
|
|
102
|
-
};
|
|
103
|
-
})();
|
|
104
|
-
const config_1 = require("./modules/config");
|
|
105
|
-
const path_api_1 = require("./modules/path_api");
|
|
106
|
-
const node_child_process_1 = require("node:child_process");
|
|
107
|
-
const system_1 = require("./modules/order/utils/system");
|
|
108
|
-
const bots_file_lock_1 = require("./modules/bots_file_lock");
|
|
109
|
-
const bot_settings_1 = require("./modules/bot_settings");
|
|
110
|
-
const chainKeys = __importStar(require("./modules/chain_keys"));
|
|
111
|
-
const credentialPolicy = __importStar(require("./modules/credential_policy"));
|
|
112
|
-
const headless_password_1 = require("./modules/launcher/headless_password");
|
|
113
|
-
const child_env_1 = require("./modules/launcher/child_env");
|
|
114
|
-
const credential_bootstrap_1 = require("./modules/launcher/credential_bootstrap");
|
|
115
|
-
const launch_modes_1 = require("./modules/launcher/launch_modes");
|
|
116
|
-
const graceful_shutdown_1 = require("./modules/graceful_shutdown");
|
|
117
|
-
const constants_1 = require("./modules/constants");
|
|
118
|
-
const paths_1 = require("./modules/paths");
|
|
119
|
-
const runtime_entry_1 = require("./modules/launcher/runtime_entry");
|
|
120
|
-
const storage_1 = require("./modules/storage");
|
|
121
|
-
const fs_utils_1 = require("./modules/utils/fs_utils");
|
|
122
|
-
const config_2 = require("./modules/config");
|
|
123
|
-
const bitshares_client_1 = require("./modules/bitshares_client");
|
|
124
|
-
const readline = __importStar(require("node:readline"));
|
|
125
|
-
const errors_1 = require("./modules/utils/errors");
|
|
126
|
-
(0, config_1.setUmask)(0o077);
|
|
75
|
+
import { createRequire } from 'node:module';
|
|
76
|
+
const require = createRequire(import.meta.url);
|
|
77
|
+
import { setUmask } from './modules/config.js';
|
|
78
|
+
import { path } from './modules/path_api.js';
|
|
79
|
+
import { spawn, execSync } from 'node:child_process';
|
|
80
|
+
import { parseJsonWithComments } from './modules/order/utils/system.js';
|
|
81
|
+
import { readBotsFileWithLock } from './modules/bots_file_lock.js';
|
|
82
|
+
import { loadSettingsFile, selectActiveBotEntries } from './modules/bot_settings.js';
|
|
83
|
+
import * as chainKeys from './modules/chain_keys.js';
|
|
84
|
+
import * as credentialPolicy from './modules/credential_policy.js';
|
|
85
|
+
import { readHeadlessPassword } from './modules/launcher/headless_password.js';
|
|
86
|
+
import { buildScopedChildEnv } from './modules/launcher/child_env.js';
|
|
87
|
+
import { createPasswordBootstrapServer } from './modules/launcher/credential_bootstrap.js';
|
|
88
|
+
import { parsePm2Args } from './modules/launcher/launch_modes.js';
|
|
89
|
+
import { setupGracefulShutdown } from './modules/graceful_shutdown.js';
|
|
90
|
+
import { UPDATER, TIMING } from './modules/constants.js';
|
|
91
|
+
import { PATHS } from './modules/paths.js';
|
|
92
|
+
import { isDistCodeRoot, buildRuntimeScriptPath } from './modules/launcher/runtime_entry.js';
|
|
93
|
+
import { Config } from './modules/config.js';
|
|
94
|
+
import { waitForConnected } from './modules/bitshares_client.js';
|
|
95
|
+
import * as readline from 'node:readline';
|
|
96
|
+
import { getErrorMessage } from './modules/utils/errors.js';
|
|
97
|
+
import { getStorage } from './modules/storage/index.js';
|
|
98
|
+
setUmask(0o077);
|
|
127
99
|
const { ensureCredentialRuntimeDirSync, getCredentialReadyFilePath, getCredentialSocketPath, } = require('./modules/credential_runtime');
|
|
128
|
-
const storage =
|
|
100
|
+
const storage = getStorage();
|
|
101
|
+
const { ensureDir, unlink: safeUnlink } = storage;
|
|
129
102
|
// Setup graceful shutdown handlers
|
|
130
|
-
|
|
103
|
+
setupGracefulShutdown();
|
|
131
104
|
const PM2_COLORS = {
|
|
132
105
|
reset: '\x1b[0m',
|
|
133
106
|
ok: '\x1b[1;92m',
|
|
134
107
|
error: '\x1b[1;31m',
|
|
135
108
|
};
|
|
136
109
|
function colorPm2Output(text, color, stream = process.stdout) {
|
|
137
|
-
return stream.isTTY && !
|
|
110
|
+
return stream.isTTY && !Config.NO_COLOR
|
|
138
111
|
? `${color}${text}${PM2_COLORS.reset}`
|
|
139
112
|
: text;
|
|
140
113
|
}
|
|
@@ -145,15 +118,15 @@ function pm2Error(text) {
|
|
|
145
118
|
return colorPm2Output(text, PM2_COLORS.error, process.stderr);
|
|
146
119
|
}
|
|
147
120
|
const CODE_ROOT = __dirname;
|
|
148
|
-
const BOTS_JSON =
|
|
149
|
-
const ECOSYSTEM_FILE =
|
|
150
|
-
const POLICY_CONFIG_FILE =
|
|
151
|
-
const LOGS_DIR =
|
|
121
|
+
const BOTS_JSON = PATHS.PROFILES.BOTS_JSON;
|
|
122
|
+
const ECOSYSTEM_FILE = PATHS.PROFILES.ECOSYSTEM_CONFIG_JS;
|
|
123
|
+
const POLICY_CONFIG_FILE = PATHS.PROFILES.DAEMON_POLICIES_JSON;
|
|
124
|
+
const LOGS_DIR = PATHS.LOGS_DIR;
|
|
152
125
|
const CREDENTIAL_DAEMON_APP_NAME = 'dexbot-cred';
|
|
153
|
-
const CREDENTIAL_SOCKET_PATH = getCredentialSocketPath({ root:
|
|
154
|
-
const CREDENTIAL_READY_FILE = getCredentialReadyFilePath({ root:
|
|
126
|
+
const CREDENTIAL_SOCKET_PATH = getCredentialSocketPath({ root: PATHS.PROJECT_ROOT });
|
|
127
|
+
const CREDENTIAL_READY_FILE = getCredentialReadyFilePath({ root: PATHS.PROJECT_ROOT });
|
|
155
128
|
function runtimeScript(...segments) {
|
|
156
|
-
return
|
|
129
|
+
return path.join(CODE_ROOT, ...segments);
|
|
157
130
|
}
|
|
158
131
|
function usesAmaGridPrice(bot) {
|
|
159
132
|
const gridPrice = typeof bot?.gridPrice === 'string' ? bot.gridPrice.trim().toLowerCase() : '';
|
|
@@ -223,14 +196,14 @@ function buildEcosystemApps(bots, { includeUpdater = true } = {}) {
|
|
|
223
196
|
const botName = bot.name || `bot-${index}`;
|
|
224
197
|
return {
|
|
225
198
|
name: botName,
|
|
226
|
-
script:
|
|
199
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['bot']),
|
|
227
200
|
args: botName,
|
|
228
|
-
cwd:
|
|
201
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
229
202
|
max_memory_restart: '250M',
|
|
230
203
|
watch: false,
|
|
231
204
|
autorestart: true,
|
|
232
|
-
error_file:
|
|
233
|
-
out_file:
|
|
205
|
+
error_file: path.join(LOGS_DIR, `${botName}-error.log`),
|
|
206
|
+
out_file: path.join(LOGS_DIR, `${botName}.log`),
|
|
234
207
|
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
235
208
|
merge_logs: false,
|
|
236
209
|
combine_logs: true,
|
|
@@ -243,13 +216,13 @@ function buildEcosystemApps(bots, { includeUpdater = true } = {}) {
|
|
|
243
216
|
if (needsMarketAdapter(bots)) {
|
|
244
217
|
apps.unshift({
|
|
245
218
|
name: 'dexbot-adapter',
|
|
246
|
-
script:
|
|
247
|
-
cwd:
|
|
219
|
+
script: buildRuntimeScriptPath(CODE_ROOT, ['market_adapter', 'market_adapter']),
|
|
220
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
248
221
|
watch: false,
|
|
249
222
|
autorestart: true,
|
|
250
223
|
max_memory_restart: '150M',
|
|
251
|
-
error_file:
|
|
252
|
-
out_file:
|
|
224
|
+
error_file: path.join(LOGS_DIR, 'dexbot-adapter-error.log'),
|
|
225
|
+
out_file: path.join(LOGS_DIR, 'dexbot-adapter.log'),
|
|
253
226
|
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
254
227
|
merge_logs: false,
|
|
255
228
|
combine_logs: true,
|
|
@@ -257,18 +230,18 @@ function buildEcosystemApps(bots, { includeUpdater = true } = {}) {
|
|
|
257
230
|
max_restarts: 13,
|
|
258
231
|
min_uptime: 60000,
|
|
259
232
|
restart_delay: 3000,
|
|
260
|
-
...(
|
|
233
|
+
...(isDistCodeRoot(CODE_ROOT) ? {} : { node_args: ['--import', 'tsx'] })
|
|
261
234
|
});
|
|
262
235
|
}
|
|
263
|
-
if (includeUpdater &&
|
|
236
|
+
if (includeUpdater && UPDATER.ACTIVE) {
|
|
264
237
|
apps.push({
|
|
265
238
|
name: "dexbot-update",
|
|
266
239
|
script: runtimeScript('scripts', 'update.js'),
|
|
267
|
-
cwd:
|
|
240
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
268
241
|
autorestart: false,
|
|
269
|
-
cron_restart:
|
|
270
|
-
error_file:
|
|
271
|
-
out_file:
|
|
242
|
+
cron_restart: UPDATER.SCHEDULE,
|
|
243
|
+
error_file: path.join(LOGS_DIR, `dexbot-update-error.log`),
|
|
244
|
+
out_file: path.join(LOGS_DIR, `dexbot-update.log`),
|
|
272
245
|
log_date_format: "YY-MM-DD HH:mm:ss.SSS",
|
|
273
246
|
max_size: '100M'
|
|
274
247
|
});
|
|
@@ -279,10 +252,10 @@ function buildCredentialDaemonApp({ credentialEnv = {} } = {}) {
|
|
|
279
252
|
return {
|
|
280
253
|
name: CREDENTIAL_DAEMON_APP_NAME,
|
|
281
254
|
script: runtimeScript('credential-daemon.js'),
|
|
282
|
-
cwd:
|
|
255
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
283
256
|
autorestart: false,
|
|
284
|
-
error_file:
|
|
285
|
-
out_file:
|
|
257
|
+
error_file: path.join(LOGS_DIR, 'dexbot-cred-error.log'),
|
|
258
|
+
out_file: path.join(LOGS_DIR, 'dexbot-cred.log'),
|
|
286
259
|
log_date_format: 'YY-MM-DD HH:mm:ss.SSS',
|
|
287
260
|
merge_logs: false,
|
|
288
261
|
combine_logs: true,
|
|
@@ -295,7 +268,7 @@ function buildCredentialDaemonApp({ credentialEnv = {} } = {}) {
|
|
|
295
268
|
};
|
|
296
269
|
}
|
|
297
270
|
/**
|
|
298
|
-
* Generate ecosystem.config.
|
|
271
|
+
* Generate ecosystem.config.cjs from bots.json or claw-only mode.
|
|
299
272
|
* @param {Object} [options={}] - Generation options.
|
|
300
273
|
* @param {string|null} [options.botNameFilter=null] - Optional bot name to filter by.
|
|
301
274
|
* @param {boolean} [options.clawOnly=false] - Generate no managed bot apps.
|
|
@@ -312,14 +285,14 @@ function generateEcosystemConfig({ botNameFilter = null, clawOnly = false, exitO
|
|
|
312
285
|
}
|
|
313
286
|
// Ensure logs directory exists
|
|
314
287
|
if (!storage.exists(LOGS_DIR)) {
|
|
315
|
-
|
|
288
|
+
ensureDir(LOGS_DIR);
|
|
316
289
|
}
|
|
317
290
|
try {
|
|
318
291
|
if (clawOnly) {
|
|
319
292
|
const appsClaw = [];
|
|
320
293
|
const ecosystemContent = `// Auto-generated by pm2.js - DO NOT EDIT
|
|
321
294
|
// Regenerate with: dexbot pm2 or node dist/dexbot.js pm2
|
|
322
|
-
|
|
295
|
+
module.exports = { apps: ${JSON.stringify(appsClaw, null, 2)} }
|
|
323
296
|
`;
|
|
324
297
|
storage.writeFile(ECOSYSTEM_FILE, ecosystemContent);
|
|
325
298
|
return appsClaw;
|
|
@@ -327,8 +300,8 @@ export default { apps: ${JSON.stringify(appsClaw, null, 2)} }
|
|
|
327
300
|
if (!storage.exists(BOTS_JSON)) {
|
|
328
301
|
fail('profiles/bots.json not found. Run: dexbot bot');
|
|
329
302
|
}
|
|
330
|
-
const { config } =
|
|
331
|
-
const bots =
|
|
303
|
+
const { config } = loadSettingsFile(BOTS_JSON, { exitOnError });
|
|
304
|
+
const bots = selectActiveBotEntries(config);
|
|
332
305
|
if (botNameFilter) {
|
|
333
306
|
const filtered = bots.filter((b) => b.name === botNameFilter);
|
|
334
307
|
if (filtered.length === 0) {
|
|
@@ -354,7 +327,7 @@ module.exports = { apps: ${JSON.stringify(apps, null, 2)} };
|
|
|
354
327
|
return apps;
|
|
355
328
|
}
|
|
356
329
|
catch (err) {
|
|
357
|
-
fail(`Error reading bots.json: ${
|
|
330
|
+
fail(`Error reading bots.json: ${getErrorMessage(err)}`);
|
|
358
331
|
}
|
|
359
332
|
}
|
|
360
333
|
async function runManagedAppsPm2Action(action, { regenerate = false } = {}) {
|
|
@@ -368,15 +341,15 @@ async function runManagedAppsPm2Action(action, { regenerate = false } = {}) {
|
|
|
368
341
|
}
|
|
369
342
|
function cleanupStaleCredentialDaemonFiles() {
|
|
370
343
|
try {
|
|
371
|
-
|
|
372
|
-
|
|
344
|
+
safeUnlink(CREDENTIAL_SOCKET_PATH);
|
|
345
|
+
safeUnlink(CREDENTIAL_READY_FILE);
|
|
373
346
|
}
|
|
374
347
|
catch (e) {
|
|
375
348
|
// Socket files already cleaned, that's fine
|
|
376
349
|
}
|
|
377
350
|
}
|
|
378
351
|
async function ensureCredentialDaemonPM2({ forceRefresh = false, headless = false, passwordFile = null } = {}) {
|
|
379
|
-
ensureCredentialRuntimeDirSync({ root:
|
|
352
|
+
ensureCredentialRuntimeDirSync({ root: PATHS.PROJECT_ROOT, socketPath: CREDENTIAL_SOCKET_PATH, readyFilePath: CREDENTIAL_READY_FILE });
|
|
380
353
|
credentialPolicy.ensurePolicyConfig(POLICY_CONFIG_FILE);
|
|
381
354
|
const daemonReady = await chainKeys.isDaemonResponsive({
|
|
382
355
|
socketPath: CREDENTIAL_SOCKET_PATH,
|
|
@@ -392,12 +365,12 @@ async function ensureCredentialDaemonPM2({ forceRefresh = false, headless = fals
|
|
|
392
365
|
try {
|
|
393
366
|
let vaultSecret;
|
|
394
367
|
if (headless) {
|
|
395
|
-
vaultSecret = chainKeys.unlockWithPassword(
|
|
368
|
+
vaultSecret = chainKeys.unlockWithPassword(readHeadlessPassword({ passwordFile }));
|
|
396
369
|
}
|
|
397
370
|
else {
|
|
398
371
|
vaultSecret = await chainKeys.authenticate();
|
|
399
372
|
}
|
|
400
|
-
bootstrap = await
|
|
373
|
+
bootstrap = await createPasswordBootstrapServer({ secret: vaultSecret });
|
|
401
374
|
console.log(pm2Success('✓ Authentication successful'));
|
|
402
375
|
await startManagedRuntimePM2({ apps: [], bootstrap });
|
|
403
376
|
return true;
|
|
@@ -410,17 +383,17 @@ async function ensureCredentialDaemonPM2({ forceRefresh = false, headless = fals
|
|
|
410
383
|
}
|
|
411
384
|
async function assertActiveBotTarget(target) {
|
|
412
385
|
try {
|
|
413
|
-
const { config } = await
|
|
414
|
-
const botExists =
|
|
386
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
387
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
415
388
|
if (!botExists) {
|
|
416
389
|
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
417
390
|
}
|
|
418
391
|
}
|
|
419
392
|
catch (err) {
|
|
420
|
-
if (String(err &&
|
|
393
|
+
if (String(err && getErrorMessage(err) || '').includes('not found or not active')) {
|
|
421
394
|
throw err;
|
|
422
395
|
}
|
|
423
|
-
throw new Error(`Failed to read bots configuration: ${
|
|
396
|
+
throw new Error(`Failed to read bots configuration: ${getErrorMessage(err)}`);
|
|
424
397
|
}
|
|
425
398
|
}
|
|
426
399
|
/**
|
|
@@ -434,7 +407,7 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
434
407
|
if (typeof chainKeys.checkKeysFileSecurity === 'function')
|
|
435
408
|
chainKeys.checkKeysFileSecurity();
|
|
436
409
|
if (typeof credentialPolicy.checkPolicyFileSecurity === 'function')
|
|
437
|
-
credentialPolicy.checkPolicyFileSecurity(
|
|
410
|
+
credentialPolicy.checkPolicyFileSecurity(PATHS.PROFILES.DAEMON_POLICIES_JSON);
|
|
438
411
|
console.log('='.repeat(50));
|
|
439
412
|
console.log('DEXBot2 PM2 Launcher');
|
|
440
413
|
if (clawOnly) {
|
|
@@ -460,7 +433,7 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
460
433
|
originalLog(...args);
|
|
461
434
|
}
|
|
462
435
|
};
|
|
463
|
-
await
|
|
436
|
+
await waitForConnected(TIMING.CONNECTION_TIMEOUT_MS);
|
|
464
437
|
}
|
|
465
438
|
finally {
|
|
466
439
|
// Always restore console output, even if waitForConnected throws
|
|
@@ -481,7 +454,7 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
481
454
|
await ensureCredentialDaemonPM2({ headless, passwordFile });
|
|
482
455
|
}
|
|
483
456
|
catch (error) {
|
|
484
|
-
console.error(pm2Error(`\n❌ ${
|
|
457
|
+
console.error(pm2Error(`\n❌ ${getErrorMessage(error)}`));
|
|
485
458
|
process.exit(1);
|
|
486
459
|
}
|
|
487
460
|
// Step 3: Generate ecosystem config
|
|
@@ -502,10 +475,10 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
502
475
|
console.log('='.repeat(50));
|
|
503
476
|
console.log();
|
|
504
477
|
}
|
|
505
|
-
function startPM2Process(args, env =
|
|
478
|
+
function startPM2Process(args, env = buildScopedChildEnv()) {
|
|
506
479
|
return new Promise((resolve, reject) => {
|
|
507
|
-
const pm2 =
|
|
508
|
-
cwd:
|
|
480
|
+
const pm2 = spawn('pm2', args, {
|
|
481
|
+
cwd: PATHS.PROJECT_ROOT,
|
|
509
482
|
env,
|
|
510
483
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
511
484
|
detached: false,
|
|
@@ -553,7 +526,7 @@ function startCredentialDaemonPM2({ credentialEnv = {} } = {}) {
|
|
|
553
526
|
'--log-date-format', app.log_date_format,
|
|
554
527
|
'--no-autorestart',
|
|
555
528
|
];
|
|
556
|
-
return startPM2Process(args,
|
|
529
|
+
return startPM2Process(args, buildScopedChildEnv({ extra: app.env }))
|
|
557
530
|
.then(() => {
|
|
558
531
|
console.log(`[PM2] App [${CREDENTIAL_DAEMON_APP_NAME}] launched`);
|
|
559
532
|
});
|
|
@@ -566,12 +539,12 @@ async function startManagedRuntimePM2({ apps, bootstrap } = {}) {
|
|
|
566
539
|
// PM2-persisted env var. Once consumed the file is deleted, so a
|
|
567
540
|
// future `pm2 restart dexbot-cred` or `pm2 resurrect` will not
|
|
568
541
|
// find it and will fall through to interactive auth.
|
|
569
|
-
const bootstrapPathFile =
|
|
542
|
+
const bootstrapPathFile = path.join(path.dirname(CREDENTIAL_SOCKET_PATH), '.dexbot-cred-bootstrap-path');
|
|
570
543
|
try {
|
|
571
544
|
storage.writeFile(bootstrapPathFile, bootstrap.socketPath, { mode: 0o600 });
|
|
572
545
|
}
|
|
573
546
|
catch (err) {
|
|
574
|
-
throw new Error(`Cannot write bootstrap path file at ${bootstrapPathFile}: ${
|
|
547
|
+
throw new Error(`Cannot write bootstrap path file at ${bootstrapPathFile}: ${getErrorMessage(err)}. ` +
|
|
575
548
|
`The daemon needs this file to find the bootstrap socket.`);
|
|
576
549
|
}
|
|
577
550
|
// Start the daemon WITHOUT DEXBOT_CRED_BOOTSTRAP_SOCKET so PM2 never
|
|
@@ -584,7 +557,7 @@ async function startManagedRuntimePM2({ apps, bootstrap } = {}) {
|
|
|
584
557
|
await startCredentialDaemonPM2({ credentialEnv: daemonEnv });
|
|
585
558
|
await Promise.all([
|
|
586
559
|
bootstrap.waitForTransfer(),
|
|
587
|
-
chainKeys.waitForDaemon(
|
|
560
|
+
chainKeys.waitForDaemon(TIMING.DAEMON_STARTUP_TIMEOUT_MS, {
|
|
588
561
|
socketPath: CREDENTIAL_SOCKET_PATH,
|
|
589
562
|
readyFilePath: CREDENTIAL_READY_FILE,
|
|
590
563
|
}),
|
|
@@ -604,7 +577,7 @@ function checkPM2Installed() {
|
|
|
604
577
|
catch (e) {
|
|
605
578
|
// Check if pm2 is available in PATH
|
|
606
579
|
try {
|
|
607
|
-
|
|
580
|
+
execSync('pm2 --version', { stdio: 'ignore' });
|
|
608
581
|
return true;
|
|
609
582
|
}
|
|
610
583
|
catch (err) {
|
|
@@ -632,7 +605,7 @@ async function installPM2() {
|
|
|
632
605
|
// Helper to run installation command
|
|
633
606
|
const runInstall = (command, args) => {
|
|
634
607
|
return new Promise((res, rej) => {
|
|
635
|
-
const proc =
|
|
608
|
+
const proc = spawn(command, args, {
|
|
636
609
|
stdio: 'inherit',
|
|
637
610
|
shell: process.platform === 'win32'
|
|
638
611
|
});
|
|
@@ -717,7 +690,7 @@ async function execPM2Command(action, target, { suppressStderrOnError = false, s
|
|
|
717
690
|
if (target) {
|
|
718
691
|
args.push(target);
|
|
719
692
|
}
|
|
720
|
-
const pm2 =
|
|
693
|
+
const pm2 = spawn('pm2', args, {
|
|
721
694
|
stdio: 'pipe',
|
|
722
695
|
shell: process.platform === 'win32'
|
|
723
696
|
});
|
|
@@ -756,7 +729,7 @@ async function execPM2CommandIgnoreMissing(action, target, options = {}) {
|
|
|
756
729
|
return true;
|
|
757
730
|
}
|
|
758
731
|
catch (error) {
|
|
759
|
-
const message = String(error &&
|
|
732
|
+
const message = String(error && getErrorMessage(error) ? getErrorMessage(error) : error);
|
|
760
733
|
if (message.includes('Process or Namespace') || message.includes('not found') || message.includes('does not exist')) {
|
|
761
734
|
return false;
|
|
762
735
|
}
|
|
@@ -785,7 +758,7 @@ async function stopPM2Processes(target) {
|
|
|
785
758
|
await runManagedAppsPm2Action('stop', { regenerate: true });
|
|
786
759
|
}
|
|
787
760
|
catch (err) {
|
|
788
|
-
console.warn(`Skipping managed bot stop: ${
|
|
761
|
+
console.warn(`Skipping managed bot stop: ${getErrorMessage(err)}`);
|
|
789
762
|
}
|
|
790
763
|
}
|
|
791
764
|
console.log('');
|
|
@@ -799,14 +772,14 @@ async function stopPM2Processes(target) {
|
|
|
799
772
|
}
|
|
800
773
|
// Validate bot exists in configuration before stopping (with lock protection)
|
|
801
774
|
try {
|
|
802
|
-
const { config } = await
|
|
803
|
-
const botExists =
|
|
775
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
776
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
804
777
|
if (!botExists) {
|
|
805
778
|
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
806
779
|
}
|
|
807
780
|
}
|
|
808
781
|
catch (err) {
|
|
809
|
-
throw new Error(`Failed to read bots configuration: ${
|
|
782
|
+
throw new Error(`Failed to read bots configuration: ${getErrorMessage(err)}`);
|
|
810
783
|
}
|
|
811
784
|
// Stop specific bot by name
|
|
812
785
|
await execPM2Command('stop', target);
|
|
@@ -831,7 +804,7 @@ async function deletePM2Processes(target) {
|
|
|
831
804
|
await runManagedAppsPm2Action('delete', { regenerate: true });
|
|
832
805
|
}
|
|
833
806
|
catch (err) {
|
|
834
|
-
console.warn(`Skipping managed bot delete: ${
|
|
807
|
+
console.warn(`Skipping managed bot delete: ${getErrorMessage(err)}`);
|
|
835
808
|
}
|
|
836
809
|
}
|
|
837
810
|
console.log('');
|
|
@@ -846,14 +819,14 @@ async function deletePM2Processes(target) {
|
|
|
846
819
|
}
|
|
847
820
|
// Validate bot exists in configuration before deleting (with lock protection)
|
|
848
821
|
try {
|
|
849
|
-
const { config } = await
|
|
850
|
-
const botExists =
|
|
822
|
+
const { config } = await readBotsFileWithLock(BOTS_JSON, parseJsonWithComments);
|
|
823
|
+
const botExists = selectActiveBotEntries(config).some((b) => b.name === target);
|
|
851
824
|
if (!botExists) {
|
|
852
825
|
throw new Error(`Bot '${target}' not found or not active in profiles/bots.json`);
|
|
853
826
|
}
|
|
854
827
|
}
|
|
855
828
|
catch (err) {
|
|
856
|
-
throw new Error(`Failed to read bots configuration: ${
|
|
829
|
+
throw new Error(`Failed to read bots configuration: ${getErrorMessage(err)}`);
|
|
857
830
|
}
|
|
858
831
|
// Delete specific bot by name
|
|
859
832
|
await execPM2Command('delete', target);
|
|
@@ -921,11 +894,11 @@ Repo-root users can run \`./pm2\` instead.
|
|
|
921
894
|
`);
|
|
922
895
|
}
|
|
923
896
|
// Run if called directly or via the root-level pm2.js shim
|
|
924
|
-
const isPm2DirectRun =
|
|
925
|
-
|
|
897
|
+
const isPm2DirectRun = !!process.argv[1] && (import.meta.url === pathToFileURL(process.argv[1]).href ||
|
|
898
|
+
path.basename(process.argv[1]).replace(/\.js$/, '') === 'pm2');
|
|
926
899
|
if (isPm2DirectRun) {
|
|
927
900
|
// Parse command line arguments
|
|
928
|
-
const { command, target, clawOnly, headless, passwordFile } =
|
|
901
|
+
const { command, target, clawOnly, headless, passwordFile } = parsePm2Args(process.argv);
|
|
929
902
|
(async () => {
|
|
930
903
|
try {
|
|
931
904
|
if (!command) {
|
|
@@ -945,7 +918,7 @@ if (isPm2DirectRun) {
|
|
|
945
918
|
process.exit(0);
|
|
946
919
|
}
|
|
947
920
|
else if (command === 'update') {
|
|
948
|
-
const update =
|
|
921
|
+
const update = spawn(Config.EXEC_PATH, [runtimeScript('scripts', 'update.js')], { stdio: 'inherit' });
|
|
949
922
|
update.on('close', (code) => process.exit(code));
|
|
950
923
|
}
|
|
951
924
|
else if (command === 'stop') {
|
|
@@ -959,7 +932,7 @@ if (isPm2DirectRun) {
|
|
|
959
932
|
process.exit(0);
|
|
960
933
|
}
|
|
961
934
|
catch (err) {
|
|
962
|
-
console.error(pm2Error(`Failed to stop processes: ${
|
|
935
|
+
console.error(pm2Error(`Failed to stop processes: ${getErrorMessage(err)}`));
|
|
963
936
|
process.exit(1);
|
|
964
937
|
}
|
|
965
938
|
}
|
|
@@ -974,7 +947,7 @@ if (isPm2DirectRun) {
|
|
|
974
947
|
process.exit(0);
|
|
975
948
|
}
|
|
976
949
|
catch (err) {
|
|
977
|
-
console.error(pm2Error(`Failed to delete processes: ${
|
|
950
|
+
console.error(pm2Error(`Failed to delete processes: ${getErrorMessage(err)}`));
|
|
978
951
|
process.exit(1);
|
|
979
952
|
}
|
|
980
953
|
}
|
|
@@ -989,7 +962,7 @@ if (isPm2DirectRun) {
|
|
|
989
962
|
process.exit(0);
|
|
990
963
|
}
|
|
991
964
|
catch (err) {
|
|
992
|
-
console.error(pm2Error(`Failed to restart processes: ${
|
|
965
|
+
console.error(pm2Error(`Failed to restart processes: ${getErrorMessage(err)}`));
|
|
993
966
|
process.exit(1);
|
|
994
967
|
}
|
|
995
968
|
}
|
|
@@ -1004,15 +977,16 @@ if (isPm2DirectRun) {
|
|
|
1004
977
|
}
|
|
1005
978
|
}
|
|
1006
979
|
catch (err) {
|
|
1007
|
-
console.error(pm2Error(`Error: ${
|
|
980
|
+
console.error(pm2Error(`Error: ${getErrorMessage(err)}`));
|
|
1008
981
|
process.exit(1);
|
|
1009
982
|
}
|
|
1010
983
|
})();
|
|
1011
984
|
}
|
|
1012
|
-
|
|
985
|
+
export { buildCredentialDaemonApp, buildEcosystemApps, buildScopedChildEnv, countManagedBots, deletePM2Processes, ensureCredentialDaemonPM2, generateEcosystemConfig, isServiceApp, main, needsMarketAdapter, restartPM2Processes, stopPM2Processes, startManagedRuntimePM2, usesAmaGridPrice };
|
|
986
|
+
export default {
|
|
1013
987
|
buildCredentialDaemonApp,
|
|
1014
988
|
buildEcosystemApps,
|
|
1015
|
-
buildScopedChildEnv
|
|
989
|
+
buildScopedChildEnv,
|
|
1016
990
|
countManagedBots,
|
|
1017
991
|
deletePM2Processes,
|
|
1018
992
|
ensureCredentialDaemonPM2,
|