dexbot 1.6.11 → 1.6.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/CHANGELOG.md +35 -4
- package/README.md +2 -1
- package/analysis/README.md +2 -0
- package/analysis/tradingview/README.md +1 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +3 -3
- package/claw/docs/DEXBOT2_TUNING_CHEAT_SHEET.md +4 -3
- package/claw/modules/chain_broadcast.ts +7 -1
- package/claw/modules/claw_launcher.ts +1 -1
- package/claw/modules/launcher_mode_detector.ts +9 -2
- package/claw/package.json +1 -1
- package/claw/runtimes/openclaw-plugin/openclaw.plugin.json +1 -1
- package/claw/runtimes/openclaw-plugin/package.json +1 -1
- package/dist/analysis/account_resolver.d.ts +1 -1
- package/dist/analysis/account_resolver.js +2 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js +3 -4
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js +2 -7
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js +4 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts +20 -4
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js +9 -6
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js +16 -12
- package/dist/analysis/analyze_args.d.ts +31 -0
- package/dist/analysis/analyze_args.js +41 -0
- package/dist/analysis/analyze_dynamic_weight.js +7 -17
- package/dist/analysis/analyze_kalman.js +7 -17
- package/dist/analysis/analyze_regime.js +7 -17
- package/dist/analysis/analyze_regime_windows.js +8 -18
- package/dist/analysis/analyze_risk_profile.js +8 -18
- package/dist/analysis/analyze_trade_heatmap.js +7 -17
- package/dist/analysis/analyze_volatility.js +7 -17
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts +220 -12
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js +6 -5
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts +34 -4
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js +11 -63
- package/dist/analysis/bot_fitting/shared_utils.d.ts +7 -7
- package/dist/analysis/bot_fitting/shared_utils.js +2 -2
- package/dist/analysis/bot_key_utils.d.ts +18 -10
- package/dist/analysis/bot_key_utils.js +7 -4
- package/dist/analysis/bot_usage/discover_bot_accounts.js +44 -47
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts +1 -21
- package/dist/analysis/chain_pool.d.ts +3 -1
- package/dist/analysis/chart_ui.d.ts +5 -2
- package/dist/analysis/chart_ui.js +6 -3
- package/dist/analysis/chart_utils.d.ts +5 -5
- package/dist/analysis/chart_utils.js +9 -0
- package/dist/analysis/fills_cache.d.ts +1 -1
- package/dist/analysis/fills_source.d.ts +2 -2
- package/dist/analysis/fills_source.js +14 -12
- package/dist/analysis/grid_correction_check.d.ts +1 -1
- package/dist/analysis/grid_correction_check.js +12 -11
- package/dist/analysis/math_utils.d.ts +7 -6
- package/dist/analysis/math_utils.js +5 -8
- package/dist/analysis/pnl_report.js +29 -29
- package/dist/analysis/price_sources.d.ts +8 -8
- package/dist/analysis/price_sources.js +5 -4
- package/dist/analysis/resolve_bot_accounts.js +2 -2
- package/dist/analysis/resolve_source.d.ts +1 -1
- package/dist/analysis/trade_profitability.d.ts +23 -2
- package/dist/analysis/trade_profitability.js +50 -50
- package/dist/analysis/tradingview/analyze_tradingview.d.ts +17 -6
- package/dist/analysis/tradingview/analyze_tradingview.js +6 -5
- package/dist/analysis/tradingview/grid_reset_config.d.ts +41 -32
- package/dist/analysis/tradingview/grid_reset_config.js +23 -11
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +75 -9
- package/dist/analysis/tradingview/grid_reset_sim.js +4 -3
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts +69 -4
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +18 -19
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.d.ts +1 -1
- package/dist/analysis/trend_detection/backtest_ama_slope_huber.js +5 -5
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts +63 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js +5 -4
- package/dist/analysis/trend_detection/huber_scale_variants.d.ts +9 -3
- package/dist/analysis/trend_detection/huber_scale_variants.js +4 -4
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts +30 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js +3 -3
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts +31 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js +2 -2
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts +33 -1
- package/dist/credential-daemon.js +34 -20
- package/dist/dexbot.js +11 -11
- package/dist/market_adapter/candle_utils.d.ts +22 -18
- package/dist/market_adapter/candle_utils.js +24 -20
- package/dist/market_adapter/core/asymmetric_bounds.d.ts +13 -4
- package/dist/market_adapter/core/config_normalizers.d.ts +3 -3
- package/dist/market_adapter/core/kibana_candles.d.ts +53 -18
- package/dist/market_adapter/core/kibana_candles.js +9 -7
- package/dist/market_adapter/core/kibana_client.d.ts +9 -1
- package/dist/market_adapter/core/kibana_client.js +8 -7
- package/dist/market_adapter/core/kibana_market_candles.d.ts +3 -2
- package/dist/market_adapter/core/market_adapter_service.d.ts +284 -117
- package/dist/market_adapter/core/market_adapter_service.js +137 -113
- package/dist/market_adapter/core/strategies/ama.d.ts +10 -2
- package/dist/market_adapter/core/strategies/ama.js +2 -4
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts +14 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js +12 -34
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts +7 -2
- package/dist/market_adapter/core/strategies/atr/calculator.js +2 -34
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts +7 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js +0 -22
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +34 -6
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +7 -7
- package/dist/market_adapter/core/strategies/regime_gate.d.ts +24 -15
- package/dist/market_adapter/core/strategies/regime_gate.js +4 -31
- package/dist/market_adapter/core/strategies/regime_interp.d.ts +7 -1
- package/dist/market_adapter/core/strategies/regime_interp.js +14 -22
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts +11 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js +0 -13
- package/dist/market_adapter/inputs/cex_candle_parsing.d.ts +29 -0
- package/dist/market_adapter/inputs/cex_candle_parsing.js +52 -0
- package/dist/market_adapter/inputs/fetch_book_data.d.ts +20 -4
- package/dist/market_adapter/inputs/fetch_book_data.js +3 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js +96 -224
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts +42 -7
- package/dist/market_adapter/inputs/fetch_lp_data.js +22 -15
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts +74 -15
- package/dist/market_adapter/inputs/kibana_feed_source.js +29 -22
- package/dist/market_adapter/inputs/kibana_source.d.ts +25 -3
- package/dist/market_adapter/inputs/kibana_source.js +2 -2
- package/dist/market_adapter/inputs/window_cache.d.ts +99 -94
- package/dist/market_adapter/inputs/window_cache.js +8 -8
- package/dist/market_adapter/interval_utils.d.ts +4 -4
- package/dist/market_adapter/log_format.d.ts +6 -6
- package/dist/market_adapter/log_format.js +28 -21
- package/dist/market_adapter/lp_chart_core.d.ts +22 -1
- package/dist/market_adapter/lp_chart_core.js +26 -192
- package/dist/market_adapter/lp_chart_runner.d.ts +7 -7
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts +41 -6
- package/dist/market_adapter/lp_chart_strategy_loader.js +8 -7
- package/dist/market_adapter/market_adapter.d.ts +94 -32
- package/dist/market_adapter/market_adapter.js +67 -48
- package/dist/market_adapter/utils/adapter_client.d.ts +3 -3
- package/dist/market_adapter/utils/adapter_client.js +2 -2
- package/dist/market_adapter/utils/atomic_write.d.ts +8 -1
- package/dist/market_adapter/utils/chain.d.ts +50 -41
- package/dist/market_adapter/utils/chain.js +40 -46
- package/dist/market_adapter/utils/data_discovery.d.ts +4 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts +12 -3
- package/dist/market_adapter/utils/file_json_cache.d.ts +2 -2
- package/dist/market_adapter/utils/file_lock.d.ts +28 -14
- package/dist/market_adapter/utils/file_lock.js +36 -32
- package/dist/market_adapter/utils/native_history.d.ts +9 -2
- package/dist/market_adapter/utils/native_history.js +35 -28
- package/dist/modules/account_bots.d.ts +577 -21
- package/dist/modules/account_bots.js +182 -158
- package/dist/modules/account_orders.d.ts +66 -30
- package/dist/modules/account_orders.js +22 -20
- package/dist/modules/authority_resolver.d.ts +12 -2
- package/dist/modules/authority_resolver.js +15 -8
- package/dist/modules/bitshares-native/chain_client.d.ts +38 -3
- package/dist/modules/bitshares-native/chain_client.js +45 -46
- package/dist/modules/bitshares-native/crypto/ecc.browser.js +11 -171
- package/dist/modules/bitshares-native/crypto/ecc.js +13 -176
- package/dist/modules/bitshares-native/crypto/ecc_core.d.ts +33 -0
- package/dist/modules/bitshares-native/crypto/ecc_core.js +213 -0
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts +2 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js +1 -13
- package/dist/modules/bitshares-native/index.d.ts +1 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts +7 -7
- package/dist/modules/bitshares-native/resolvers.d.ts +18 -6
- package/dist/modules/bitshares-native/serial/lazy_buffer.d.ts +4 -0
- package/dist/modules/bitshares-native/serial/lazy_buffer.js +21 -0
- package/dist/modules/bitshares-native/serial/operations.d.ts +1 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts +16 -12
- package/dist/modules/bitshares-native/serial/serializer.js +7 -13
- package/dist/modules/bitshares-native/serial/types.d.ts +25 -16
- package/dist/modules/bitshares-native/serial/types.js +55 -62
- package/dist/modules/bitshares-native/signing_client.d.ts +32 -2
- package/dist/modules/bitshares-native/signing_client.js +19 -14
- package/dist/modules/bitshares-native/subscriptions.d.ts +81 -1
- package/dist/modules/bitshares-native/subscriptions.js +12 -12
- package/dist/modules/bitshares-native/transport.d.ts +5 -4
- package/dist/modules/bitshares-native/transport.js +5 -4
- package/dist/modules/bitshares-native/tx/builder.d.ts +40 -5
- package/dist/modules/bitshares-native/tx/builder.js +4 -3
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts +4 -4
- package/dist/modules/bitshares_client.d.ts +45 -13
- package/dist/modules/bitshares_client.js +28 -19
- package/dist/modules/bot_defaults.d.ts +6 -15
- package/dist/modules/bot_defaults.js +1 -5
- package/dist/modules/bot_settings.d.ts +44 -10
- package/dist/modules/bot_settings.js +11 -8
- package/dist/modules/bots_file_lock.d.ts +6 -6
- package/dist/modules/bots_file_lock.js +16 -12
- package/dist/modules/broadcast_failure.d.ts +2 -2
- package/dist/modules/broadcast_failure.js +5 -4
- package/dist/modules/chain_keys.d.ts +42 -40
- package/dist/modules/chain_keys.js +53 -45
- package/dist/modules/chain_orders.d.ts +93 -59
- package/dist/modules/chain_orders.js +31 -23
- package/dist/modules/constants.d.ts +527 -31
- package/dist/modules/constants.js +15 -47
- package/dist/modules/cr_planner.d.ts +40 -2
- package/dist/modules/credential_policy.d.ts +68 -8
- package/dist/modules/credential_policy.js +37 -31
- package/dist/modules/credential_session_cache.d.ts +2 -2
- package/dist/modules/credit_pricing.d.ts +42 -6
- package/dist/modules/credit_pricing.js +44 -30
- package/dist/modules/credit_runtime.d.ts +276 -118
- package/dist/modules/credit_runtime.js +462 -165
- package/dist/modules/crypto/browser_provider.js +6 -4
- package/dist/modules/crypto/node_provider.js +1 -1
- package/dist/modules/crypto/pure_scrypt.js +35 -4
- package/dist/modules/crypto/pure_secp256k1.js +72 -26
- package/dist/modules/crypto/sync.d.ts +9 -9
- package/dist/modules/crypto/sync.js +16 -9
- package/dist/modules/dexbot_class.d.ts +195 -139
- package/dist/modules/dexbot_class.js +78 -28
- package/dist/modules/dexbot_cow_runtime.d.ts +167 -87
- package/dist/modules/dexbot_cow_runtime.js +248 -206
- package/dist/modules/dexbot_credential_client.d.ts +19 -11
- package/dist/modules/dexbot_fill_runtime.d.ts +63 -48
- package/dist/modules/dexbot_fill_runtime.js +48 -41
- package/dist/modules/dexbot_maintenance_runtime.d.ts +109 -70
- package/dist/modules/dexbot_maintenance_runtime.js +108 -83
- package/dist/modules/dexbot_startup_runtime.d.ts +11 -10
- package/dist/modules/dexbot_startup_runtime.js +43 -43
- package/dist/modules/dexbot_state_recovery.d.ts +13 -12
- package/dist/modules/dexbot_state_recovery.js +18 -13
- package/dist/modules/fund_registry.d.ts +4 -2
- package/dist/modules/fund_registry.js +10 -10
- package/dist/modules/general_settings.d.ts +30 -4
- package/dist/modules/graceful_shutdown.d.ts +3 -3
- package/dist/modules/graceful_shutdown.js +2 -2
- package/dist/modules/grid_price_source.d.ts +1 -1
- package/dist/modules/key_store.d.ts +14 -8
- package/dist/modules/key_store.js +7 -6
- package/dist/modules/launcher/adapter_requirement.d.ts +11 -5
- package/dist/modules/launcher/adapter_requirement.js +5 -5
- package/dist/modules/launcher/bot_supervisor.d.ts +106 -24
- package/dist/modules/launcher/bot_supervisor.js +12 -11
- package/dist/modules/launcher/credential_bootstrap.d.ts +1 -1
- package/dist/modules/launcher/credential_bootstrap.js +1 -1
- package/dist/modules/launcher/credential_daemon.d.ts +4 -4
- package/dist/modules/launcher/credential_daemon.js +2 -2
- package/dist/modules/launcher/credential_secret.d.ts +1 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts +2 -2
- package/dist/modules/launcher/market_adapter_runtime.d.ts +61 -6
- package/dist/modules/launcher/market_adapter_watchdog.d.ts +10 -2
- package/dist/modules/launcher/market_adapter_watchdog.js +4 -0
- package/dist/modules/launcher/monolithic_runtime.d.ts +18 -16
- package/dist/modules/launcher/status_reporting.d.ts +22 -14
- package/dist/modules/launcher/supervisor_control.d.ts +8 -1
- package/dist/modules/launcher/supervisor_control.js +4 -2
- package/dist/modules/market_adapter_whitelist.d.ts +9 -3
- package/dist/modules/market_adapter_whitelist.js +15 -3
- package/dist/modules/node_manager.d.ts +41 -11
- package/dist/modules/node_manager.js +5 -4
- package/dist/modules/order/accounting.d.ts +53 -24
- package/dist/modules/order/accounting.js +16 -15
- package/dist/modules/order/async_lock.d.ts +5 -2
- package/dist/modules/order/async_lock.js +1 -1
- package/dist/modules/order/export.d.ts +7 -6
- package/dist/modules/order/export.js +1 -7
- package/dist/modules/order/format.d.ts +4 -4
- package/dist/modules/order/genesis_policy.d.ts +21 -18
- package/dist/modules/order/genesis_policy.js +12 -8
- package/dist/modules/order/grid.d.ts +142 -36
- package/dist/modules/order/grid.js +148 -123
- package/dist/modules/order/grid_reconcile.d.ts +21 -20
- package/dist/modules/order/grid_reconcile.js +13 -12
- package/dist/modules/order/grid_reconcile_internal.d.ts +85 -72
- package/dist/modules/order/grid_reconcile_internal.js +28 -19
- package/dist/modules/order/index.d.ts +263 -1
- package/dist/modules/order/logger.d.ts +45 -11
- package/dist/modules/order/logger.js +38 -40
- package/dist/modules/order/logger_state.d.ts +4 -4
- package/dist/modules/order/manager.d.ts +225 -180
- package/dist/modules/order/manager.js +80 -83
- package/dist/modules/order/processed_fill_store.d.ts +18 -3
- package/dist/modules/order/processed_fill_store.js +16 -27
- package/dist/modules/order/strategy.d.ts +21 -13
- package/dist/modules/order/strategy.js +5 -6
- package/dist/modules/order/sync_engine.d.ts +91 -33
- package/dist/modules/order/sync_engine.js +84 -53
- package/dist/modules/order/utils/math.d.ts +157 -102
- package/dist/modules/order/utils/math.js +77 -38
- package/dist/modules/order/utils/order.d.ts +310 -110
- package/dist/modules/order/utils/order.js +122 -99
- package/dist/modules/order/utils/slot.d.ts +1 -1
- package/dist/modules/order/utils/system.d.ts +176 -26
- package/dist/modules/order/utils/system.js +86 -69
- package/dist/modules/order/utils/validate.d.ts +89 -41
- package/dist/modules/order/utils/validate.js +24 -22
- package/dist/modules/order/utils/withPoolRef.d.ts +4 -3
- package/dist/modules/order/utils/withPoolRef.js +18 -12
- package/dist/modules/order/working_grid.d.ts +14 -13
- package/dist/modules/paths.d.ts +1 -4
- package/dist/modules/paths.js +1 -27
- package/dist/modules/process_discovery.d.ts +1 -1
- package/dist/modules/process_discovery.js +2 -1
- package/dist/modules/runtime.d.ts +7 -3
- package/dist/modules/runtime.js +4 -3
- package/dist/modules/runtime_settings.d.ts +15 -10
- package/dist/modules/runtime_settings.js +30 -24
- package/dist/modules/settings_merge.d.ts +29 -3
- package/dist/modules/settings_merge.js +56 -78
- package/dist/modules/socket_json_client.d.ts +7 -4
- package/dist/modules/storage/browser_adapter.d.ts +38 -53
- package/dist/modules/storage/browser_adapter.js +7 -30
- package/dist/modules/storage/index.d.ts +1 -1
- package/dist/modules/storage/node_adapter.d.ts +45 -27
- package/dist/modules/storage/node_adapter.js +9 -9
- package/dist/modules/storage/types.d.ts +5 -4
- package/dist/modules/types.d.ts +1071 -2
- package/dist/modules/types.js +4 -1
- package/dist/modules/utils/asset_symbols.d.ts +2 -1
- package/dist/modules/utils/asset_symbols.js +2 -1
- package/dist/modules/utils/errors.d.ts +9 -0
- package/dist/modules/utils/errors.js +23 -1
- package/dist/modules/utils/time_range.d.ts +1 -12
- package/dist/modules/utils/time_range.js +1 -1
- package/dist/modules/validate_profiles.js +53 -43
- package/dist/modules/version_notice.d.ts +14 -3
- package/dist/modules/version_notice.js +6 -4
- package/dist/pm2.d.ts +29 -27
- package/dist/pm2.js +5 -5
- package/dist/scripts/analyze-credit.d.ts +2 -1
- package/dist/scripts/analyze-credit.js +23 -24
- package/dist/scripts/analyze-orders.d.ts +77 -9
- package/dist/scripts/analyze-orders.js +65 -40
- package/dist/scripts/chart_command.d.ts +27 -18
- package/dist/scripts/chart_command.js +13 -11
- package/dist/scripts/check_any.d.ts +18 -0
- package/dist/scripts/check_any.js +126 -0
- package/dist/scripts/diagnose-pool-history.js +12 -7
- package/dist/scripts/print_grid.js +0 -1
- package/dist/scripts/run-tests.js +39 -7
- package/dist/scripts/runner.js +1 -1
- package/dist/scripts/test-credit-renewal.js +30 -21
- package/dist/scripts/update.d.ts +10 -5
- package/dist/scripts/update.js +168 -103
- package/dist/scripts/update_dist_freshness.js +1 -0
- package/dist/scripts/update_layout.d.ts +61 -0
- package/dist/scripts/update_layout.js +180 -0
- package/dist/scripts/validate_bots.js +2 -1
- package/dist/scripts/verify-browser-bundle.js +8 -0
- package/dist/unlock.d.ts +28 -3
- package/dist/unlock.js +63 -35
- package/docs/BITSHARES_ONBOARDING.md +2 -0
- package/docs/COPY_ON_WRITE_MASTER_PLAN.md +1 -1
- package/docs/COW_INVARIANTS.md +13 -6
- package/docs/DEXBOT_COMPARISON.md +8 -8
- package/docs/EVOLUTION.md +10 -9
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +5 -5
- package/docs/GRID_RECALCULATION.md +4 -2
- package/docs/GRID_RECONCILE.md +14 -3
- package/docs/LIFECYCLE.md +11 -11
- package/docs/MPA_CREDIT_USAGE.md +22 -3
- package/docs/README.md +14 -3
- package/docs/architecture.md +12 -9
- package/docs/developer_guide.md +6 -6
- package/market_adapter/README.md +6 -1
- package/modules/README.md +4 -1
- package/package.json +4 -1
|
@@ -95,14 +95,15 @@ export class DaemonKeyStore {
|
|
|
95
95
|
return chainKeys.isDaemonSigningToken(key);
|
|
96
96
|
}
|
|
97
97
|
async executeOperations(accountName, operations, signingKey, extraOptions = {}) {
|
|
98
|
+
const daemonKey = signingKey;
|
|
98
99
|
if (this.isDaemonSigningKey(signingKey)) {
|
|
99
|
-
if (!
|
|
100
|
+
if (!daemonKey.botHmacSecret) {
|
|
100
101
|
keyStoreLogger.error(`Daemon signing token for ${accountName} has no botHmacSecret — the daemon will reject this request ` +
|
|
101
102
|
`(Strict Mode). This happens when a broadcast is attempted after the bot shut down or the token lost ` +
|
|
102
103
|
`its secret. Restarting the bot resolves it.`);
|
|
103
104
|
}
|
|
104
105
|
try {
|
|
105
|
-
const result = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(
|
|
106
|
+
const result = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(daemonKey, extraOptions));
|
|
106
107
|
return normalizeDaemonResult(result);
|
|
107
108
|
}
|
|
108
109
|
catch (err) {
|
|
@@ -123,19 +124,19 @@ export class DaemonKeyStore {
|
|
|
123
124
|
catch { }
|
|
124
125
|
}
|
|
125
126
|
const newSessionId = await chainKeys.probeAccountInDaemon(accountName);
|
|
126
|
-
|
|
127
|
+
daemonKey.sessionId = newSessionId;
|
|
127
128
|
if (isSourceAuthError) {
|
|
128
129
|
try {
|
|
129
130
|
const freshSecret = credentialPolicy.loadBotHmacSecret(accountName, PATHS.PROFILES.DAEMON_POLICIES_JSON, { quiet: true });
|
|
130
|
-
if (freshSecret && freshSecret !==
|
|
131
|
-
|
|
131
|
+
if (freshSecret && freshSecret !== daemonKey.botHmacSecret) {
|
|
132
|
+
daemonKey.botHmacSecret = freshSecret;
|
|
132
133
|
keyStoreLogger.warn(`Reloaded botHmacSecret from disk for ${accountName} before retry`);
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
catch (_) { }
|
|
136
137
|
await sleep(500);
|
|
137
138
|
}
|
|
138
|
-
const retryResult = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(
|
|
139
|
+
const retryResult = await executeOperationsViaCredentialDaemon(accountName, operations, buildDaemonBroadcastOptions(daemonKey, extraOptions, daemonKey.sessionId ?? undefined));
|
|
139
140
|
return normalizeDaemonResult(retryResult);
|
|
140
141
|
}
|
|
141
142
|
throw err;
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
interface AdapterBotConfig {
|
|
2
|
+
name?: string;
|
|
3
|
+
gridPrice?: unknown;
|
|
4
|
+
active?: boolean;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
1
7
|
/**
|
|
2
8
|
* Check whether the unlock wrapper owns the market adapter lifecycle.
|
|
3
9
|
* Bots skip their own adapter sync/poll when this is true.
|
|
4
10
|
* @param {NodeJS.ProcessEnv} [env=process.env] - Environment to inspect
|
|
5
11
|
* @returns {boolean} True when running as a wrapper-supervised bot child
|
|
6
12
|
*/
|
|
7
|
-
declare function isWrapperAdapterOwner(env?:
|
|
13
|
+
declare function isWrapperAdapterOwner(env?: Record<string, string | undefined>): boolean;
|
|
8
14
|
/**
|
|
9
15
|
* Build the semantic adapter fingerprint for an active-bot list.
|
|
10
16
|
* Only AMA-priced bots contribute; sorted so bot order is irrelevant.
|
|
11
|
-
* @param {
|
|
17
|
+
* @param {unknown[]} activeBots - Bots with active !== false
|
|
12
18
|
* @returns {string} Fingerprint ('' when no AMA bot is active)
|
|
13
19
|
*/
|
|
14
|
-
declare function buildAdapterFingerprint(activeBots:
|
|
20
|
+
declare function buildAdapterFingerprint(activeBots: AdapterBotConfig[]): string;
|
|
15
21
|
/**
|
|
16
22
|
* Read bots.json and summarize the market-adapter requirement.
|
|
17
23
|
* Never throws: missing/empty files report exists:false, unparseable files
|
|
@@ -24,8 +30,8 @@ declare function buildAdapterFingerprint(activeBots: any[]): string;
|
|
|
24
30
|
declare function readAdapterRequirement(botsFile?: string): {
|
|
25
31
|
exists: boolean;
|
|
26
32
|
fingerprint: string;
|
|
27
|
-
config:
|
|
28
|
-
activeBots:
|
|
33
|
+
config: unknown;
|
|
34
|
+
activeBots: AdapterBotConfig[];
|
|
29
35
|
needsMarketAdapter: boolean;
|
|
30
36
|
corrupt?: boolean;
|
|
31
37
|
readError?: boolean;
|
|
@@ -65,7 +65,7 @@ function normalizeGridPrice(value) {
|
|
|
65
65
|
/**
|
|
66
66
|
* Build the semantic adapter fingerprint for an active-bot list.
|
|
67
67
|
* Only AMA-priced bots contribute; sorted so bot order is irrelevant.
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {unknown[]} activeBots - Bots with active !== false
|
|
69
69
|
* @returns {string} Fingerprint ('' when no AMA bot is active)
|
|
70
70
|
*/
|
|
71
71
|
function buildAdapterFingerprint(activeBots) {
|
|
@@ -78,13 +78,13 @@ function buildAdapterFingerprint(activeBots) {
|
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Summarize parsed bots.json content for adapter decisions.
|
|
81
|
-
* @param {
|
|
81
|
+
* @param {unknown} parsed - Parsed bots.json object
|
|
82
82
|
* @returns {{activeBots: any[], needsMarketAdapter: boolean, fingerprint: string}}
|
|
83
83
|
*/
|
|
84
84
|
function summarizeBotsConfig(parsed) {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
const rec = parsed;
|
|
86
|
+
const rawBots = Array.isArray(rec?.bots) ? rec.bots : [];
|
|
87
|
+
const bots = rawBots.filter(Boolean);
|
|
88
88
|
const activeBots = bots.filter((bot) => bot && bot.active !== false);
|
|
89
89
|
return {
|
|
90
90
|
activeBots,
|
|
@@ -1,37 +1,119 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import type { ChildProcess, ChildProcessByStdio } from 'node:child_process';
|
|
3
|
+
import type { Readable } from 'node:stream';
|
|
4
|
+
import { buildScopedChildEnv } from './child_env.js';
|
|
5
|
+
import { type BotEntry } from '../bot_settings.js';
|
|
1
6
|
import { formatUptime } from '../process_discovery.js';
|
|
7
|
+
import type { Socket } from 'net';
|
|
2
8
|
import { usesAmaGridPrice } from '../grid_price_source.js';
|
|
3
9
|
declare const SOCKET_PATH: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
type SupervisedChild = ChildProcessByStdio<null, Readable, Readable>;
|
|
11
|
+
interface SupervisedApp {
|
|
12
|
+
kind: 'bot' | 'service' | 'job';
|
|
13
|
+
name: string;
|
|
14
|
+
script: string;
|
|
15
|
+
args?: string | string[];
|
|
16
|
+
cwd: string;
|
|
17
|
+
max_memory_restart?: string;
|
|
18
|
+
error_file?: string;
|
|
19
|
+
out_file?: string;
|
|
20
|
+
max_restarts?: number;
|
|
21
|
+
min_uptime?: number;
|
|
22
|
+
restart_delay?: number;
|
|
23
|
+
autorestart?: boolean;
|
|
24
|
+
bulk_control?: boolean;
|
|
25
|
+
cron_schedule?: string;
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
interface CronSchedule {
|
|
30
|
+
minute: Set<number> | null;
|
|
31
|
+
hour: Set<number> | null;
|
|
32
|
+
dayOfMonth: Set<number> | null;
|
|
33
|
+
month: Set<number> | null;
|
|
34
|
+
dayOfWeek: Set<number> | null;
|
|
35
|
+
}
|
|
36
|
+
interface BotRuntimeState {
|
|
37
|
+
name: string;
|
|
38
|
+
appEntry: SupervisedApp | null;
|
|
39
|
+
child: SupervisedChild | null;
|
|
40
|
+
restartCount: number;
|
|
41
|
+
lastStartTime: number;
|
|
42
|
+
status: string;
|
|
43
|
+
pendingRestart: boolean;
|
|
44
|
+
bulkControl: boolean;
|
|
45
|
+
cronExpression: string | null;
|
|
46
|
+
cronSchedule: CronSchedule | null;
|
|
47
|
+
nextScheduledAt: number;
|
|
48
|
+
scheduledRunTimer: ReturnType<typeof setTimeout> | null;
|
|
49
|
+
autorestart?: boolean;
|
|
50
|
+
maxRestarts: number;
|
|
51
|
+
minUptimeMs: number;
|
|
52
|
+
restartDelayMs: number;
|
|
53
|
+
memoryLimitBytes: number | null;
|
|
54
|
+
stoppedByUser: boolean;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
interface SupervisorOptions {
|
|
58
|
+
bots?: BotEntry[] | null;
|
|
59
|
+
buildEnv?: typeof buildScopedChildEnv;
|
|
60
|
+
spawnFn?: typeof spawn;
|
|
61
|
+
log?: (...args: unknown[]) => void;
|
|
62
|
+
logError?: (...args: unknown[]) => void;
|
|
63
|
+
controlSocket?: boolean;
|
|
64
|
+
getChildRss?: (child: SupervisedChild) => number;
|
|
65
|
+
memoryCheckIntervalMs?: number;
|
|
66
|
+
statusLogIntervalMs?: number;
|
|
67
|
+
staggerDelayMs?: number;
|
|
68
|
+
setTimeoutFn?: typeof setTimeout;
|
|
69
|
+
clearTimeoutFn?: typeof clearTimeout;
|
|
70
|
+
nowFn?: () => number;
|
|
71
|
+
stopMarketAdapter?: () => Promise<{
|
|
72
|
+
pid: number | null;
|
|
73
|
+
stopped: boolean;
|
|
74
|
+
}>;
|
|
75
|
+
updaterActive?: boolean;
|
|
76
|
+
}
|
|
77
|
+
declare function parseCronExpression(expression: unknown): CronSchedule;
|
|
78
|
+
declare function getNextCronDate(schedule: CronSchedule, fromDate?: Date): Date;
|
|
79
|
+
declare function forwardSignal(child: ChildProcess | null | undefined, signal: NodeJS.Signals): void;
|
|
80
|
+
declare function isPidAlive(pid: number): boolean;
|
|
81
|
+
declare function waitForPidExit(pid: number, timeoutMs: number): Promise<boolean>;
|
|
82
|
+
declare function candidateRuntimeScriptPaths(scriptSegments: string[]): Set<string>;
|
|
83
|
+
declare function pidMatchesScriptCandidates(pid: number, expectedPaths: Set<string> | null | undefined): boolean;
|
|
84
|
+
declare function isNodeProcessWithExactScript(pid: number, scriptSegments: string[]): boolean;
|
|
18
85
|
declare function readMarketAdapterLockPid(): number | null;
|
|
19
|
-
declare function stopMarketAdapterFromLock(timeoutMs?:
|
|
86
|
+
declare function stopMarketAdapterFromLock(timeoutMs?: number): Promise<{
|
|
20
87
|
pid: number | null;
|
|
21
88
|
stopped: boolean;
|
|
22
89
|
}>;
|
|
23
|
-
declare function waitForChildSpawn(child:
|
|
24
|
-
declare function createBotSupervisor({ bots, buildEnv, spawnFn, log, logError, controlSocket, getChildRss, memoryCheckIntervalMs, statusLogIntervalMs, staggerDelayMs, setTimeoutFn, clearTimeoutFn, nowFn, stopMarketAdapter, updaterActive, }?:
|
|
25
|
-
start: () => Promise<Map<
|
|
26
|
-
shutdown: ({ preserveSockets }?:
|
|
27
|
-
|
|
28
|
-
|
|
90
|
+
declare function waitForChildSpawn(child: ChildProcess): Promise<void>;
|
|
91
|
+
declare function createBotSupervisor({ bots, buildEnv, spawnFn, log, logError, controlSocket, getChildRss, memoryCheckIntervalMs, statusLogIntervalMs, staggerDelayMs, setTimeoutFn, clearTimeoutFn, nowFn, stopMarketAdapter, updaterActive, }?: SupervisorOptions): {
|
|
92
|
+
start: () => Promise<Map<string, BotRuntimeState>>;
|
|
93
|
+
shutdown: ({ preserveSockets }?: {
|
|
94
|
+
preserveSockets?: Socket[];
|
|
95
|
+
}) => Promise<void>;
|
|
96
|
+
shutdownSignalHandler: (signal: NodeJS.Signals) => void;
|
|
97
|
+
getStatus: () => Record<string, {
|
|
98
|
+
status: string;
|
|
99
|
+
pid: number | null;
|
|
100
|
+
restarts: number;
|
|
101
|
+
uptimeMs: number;
|
|
102
|
+
nextScheduledAt: number;
|
|
103
|
+
}>;
|
|
29
104
|
printStatusSummary: () => void;
|
|
30
|
-
restartAll: ({ logAction }?:
|
|
31
|
-
|
|
105
|
+
restartAll: ({ logAction }?: {
|
|
106
|
+
logAction?: string;
|
|
107
|
+
}) => Promise<void>;
|
|
108
|
+
restartRunning: ({ logAction }?: {
|
|
109
|
+
logAction?: boolean;
|
|
110
|
+
}) => Promise<void>;
|
|
32
111
|
stopAll: () => void;
|
|
33
112
|
hasUserStopped: () => boolean;
|
|
34
|
-
waitForStableStartup: ({ timeoutMs, pollIntervalMs }?:
|
|
113
|
+
waitForStableStartup: ({ timeoutMs, pollIntervalMs }?: {
|
|
114
|
+
timeoutMs?: number;
|
|
115
|
+
pollIntervalMs?: number;
|
|
116
|
+
}) => Promise<void>;
|
|
35
117
|
};
|
|
36
118
|
export { createBotSupervisor, SOCKET_PATH, parseCronExpression, getNextCronDate, forwardSignal, isPidAlive, waitForPidExit, candidateRuntimeScriptPaths, pidMatchesScriptCandidates, isNodeProcessWithExactScript, readMarketAdapterLockPid, stopMarketAdapterFromLock, usesAmaGridPrice, waitForChildSpawn, formatUptime };
|
|
37
119
|
//# sourceMappingURL=bot_supervisor.d.ts.map
|
|
@@ -17,7 +17,7 @@ import { sleep } from '../order/utils/system.js';
|
|
|
17
17
|
const storage = getStorage();
|
|
18
18
|
const { ensureDir, readJSON, unlink: safeUnlink } = storage;
|
|
19
19
|
import { buildRuntimeScriptPath, SCRIPTS_ROOT as CODE_ROOT } from './runtime_entry.js';
|
|
20
|
-
import { getErrorMessage } from '../utils/errors.js';
|
|
20
|
+
import { getErrorMessage, getErrorCode } from '../utils/errors.js';
|
|
21
21
|
import { usesAmaGridPrice } from '../grid_price_source.js';
|
|
22
22
|
const BOT_SCRIPT = buildRuntimeScriptPath(CODE_ROOT, ['bot']);
|
|
23
23
|
const SOCKET_PATH = Config.DEXBOT_SUPERVISOR_SOCKET || PATHS.PROFILES.SUPERVISOR_SOCK;
|
|
@@ -209,7 +209,7 @@ function forwardSignal(child, signal) {
|
|
|
209
209
|
child.kill(signal);
|
|
210
210
|
}
|
|
211
211
|
catch (err) {
|
|
212
|
-
if (err
|
|
212
|
+
if (getErrorCode(err) !== 'ESRCH')
|
|
213
213
|
throw err;
|
|
214
214
|
}
|
|
215
215
|
}
|
|
@@ -232,13 +232,14 @@ function readProcCwd(pid) {
|
|
|
232
232
|
return getProcessDiscovery().readCwd(pid);
|
|
233
233
|
}
|
|
234
234
|
function normalizeProcScriptArg(arg, cwd) {
|
|
235
|
-
|
|
235
|
+
const argStr = arg == null ? '' : String(arg);
|
|
236
|
+
if (!argStr || argStr.startsWith('-'))
|
|
236
237
|
return '';
|
|
237
|
-
if (!/\.(?:[cm]?js|ts)$/i.test(
|
|
238
|
+
if (!/\.(?:[cm]?js|ts)$/i.test(argStr))
|
|
238
239
|
return '';
|
|
239
|
-
return path.isAbsolute(
|
|
240
|
-
? path.normalize(
|
|
241
|
-
: path.resolve(cwd || PATHS.PROJECT_ROOT,
|
|
240
|
+
return path.isAbsolute(argStr)
|
|
241
|
+
? path.normalize(argStr)
|
|
242
|
+
: path.resolve(cwd || PATHS.PROJECT_ROOT, argStr);
|
|
242
243
|
}
|
|
243
244
|
function scriptPathForRoot(root, scriptSegments, ext) {
|
|
244
245
|
const segments = [...scriptSegments];
|
|
@@ -421,7 +422,7 @@ function createBotSupervisor({ bots = null, buildEnv = buildScopedChildEnv, spaw
|
|
|
421
422
|
}
|
|
422
423
|
log(`Starting scheduled job: ${state.name}`);
|
|
423
424
|
try {
|
|
424
|
-
const child = spawnApp(state.appEntry);
|
|
425
|
+
const child = state.appEntry ? spawnApp(state.appEntry) : null;
|
|
425
426
|
if (child) {
|
|
426
427
|
await waitForChildSpawn(child);
|
|
427
428
|
}
|
|
@@ -612,7 +613,7 @@ function createBotSupervisor({ bots = null, buildEnv = buildScopedChildEnv, spaw
|
|
|
612
613
|
state.pendingRestart = false;
|
|
613
614
|
state.stoppedByUser = true;
|
|
614
615
|
try {
|
|
615
|
-
state.child
|
|
616
|
+
state.child?.kill('SIGTERM');
|
|
616
617
|
}
|
|
617
618
|
catch (_) { }
|
|
618
619
|
userStopped = true;
|
|
@@ -749,7 +750,7 @@ function createBotSupervisor({ bots = null, buildEnv = buildScopedChildEnv, spaw
|
|
|
749
750
|
}
|
|
750
751
|
catch (_) {
|
|
751
752
|
enqueueSocketResponse(() => new Promise((resolve) => {
|
|
752
|
-
socket.write(JSON.stringify({ error: 'invalid JSON' }) + '\n', resolve);
|
|
753
|
+
socket.write(JSON.stringify({ error: 'invalid JSON' }) + '\n', () => resolve());
|
|
753
754
|
}));
|
|
754
755
|
continue;
|
|
755
756
|
}
|
|
@@ -760,7 +761,7 @@ function createBotSupervisor({ bots = null, buildEnv = buildScopedChildEnv, spaw
|
|
|
760
761
|
enqueueSocketResponse(async () => {
|
|
761
762
|
const resp = await handleSocketCommand({ ...cmd, preserveSockets: [socket] });
|
|
762
763
|
await new Promise((resolve) => {
|
|
763
|
-
socket.write(JSON.stringify(resp) + '\n', resolve);
|
|
764
|
+
socket.write(JSON.stringify(resp) + '\n', () => resolve());
|
|
764
765
|
});
|
|
765
766
|
if (cmd.cmd === 'delete') {
|
|
766
767
|
socket.end();
|
|
@@ -7,7 +7,7 @@ declare function fetchBootstrapPassword({ socketPath, timeoutMs, retries, }?: {
|
|
|
7
7
|
}): Promise<unknown>;
|
|
8
8
|
declare function createPasswordBootstrapServer({ password, secret, timeoutMs, }?: {
|
|
9
9
|
password?: string;
|
|
10
|
-
secret?:
|
|
10
|
+
secret?: unknown;
|
|
11
11
|
timeoutMs?: number;
|
|
12
12
|
}): Promise<{
|
|
13
13
|
socketPath: string;
|
|
@@ -72,7 +72,7 @@ async function cleanupStaleBootstrapDirs() {
|
|
|
72
72
|
const socketPath = path.join(dirPath, 'bootstrap.sock');
|
|
73
73
|
try {
|
|
74
74
|
const socketStat = storage.stat(socketPath);
|
|
75
|
-
if (socketStat.isSocket()) {
|
|
75
|
+
if (socketStat.isSocket?.()) {
|
|
76
76
|
// Probe the socket with a short connect. If it succeeds the
|
|
77
77
|
// server is (or was very recently) listening — do not delete.
|
|
78
78
|
const probeResult = await probeBootstrapSocket(socketPath, 300);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { StdioOptions } from 'child_process';
|
|
2
2
|
declare const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
3
|
-
declare function waitForExit(child:
|
|
3
|
+
declare function waitForExit(child: import('node:child_process').ChildProcess): Promise<number | null>;
|
|
4
4
|
declare function createCredentialDaemonController({ root, codeRoot, socketPath, readyFilePath, pollIntervalMs, }?: {
|
|
5
5
|
root?: string | undefined;
|
|
6
6
|
codeRoot?: string | undefined;
|
|
@@ -15,11 +15,11 @@ declare function createCredentialDaemonController({ root, codeRoot, socketPath,
|
|
|
15
15
|
passwordFile?: string | null;
|
|
16
16
|
}) => Promise<boolean>;
|
|
17
17
|
forwardSignal: (signal: string) => void;
|
|
18
|
-
getManagedDaemonPid: () =>
|
|
19
|
-
isDaemonReady: () => Promise<
|
|
18
|
+
getManagedDaemonPid: () => number | null;
|
|
19
|
+
isDaemonReady: () => Promise<boolean>;
|
|
20
20
|
releaseManagedDaemon: () => void;
|
|
21
21
|
stopManagedDaemon: () => Promise<void>;
|
|
22
|
-
waitForManagedDaemon: () => Promise<
|
|
22
|
+
waitForManagedDaemon: () => Promise<number | null>;
|
|
23
23
|
};
|
|
24
24
|
export { createCredentialDaemonController, DEFAULT_POLL_INTERVAL_MS, waitForExit };
|
|
25
25
|
//# sourceMappingURL=credential_daemon.d.ts.map
|
|
@@ -15,7 +15,7 @@ const storage = getStorage();
|
|
|
15
15
|
const { unlink: safeUnlink } = storage;
|
|
16
16
|
import { assertPrivatePathSecurity, ensureCredentialRuntimeDirSync, getCredentialReadyFilePath, getCredentialSocketPath, } from '../credential_runtime.js';
|
|
17
17
|
import { buildRuntimeScriptArgs, SCRIPTS_ROOT as DEFAULT_CODE_ROOT } from './runtime_entry.js';
|
|
18
|
-
import { getErrorMessage } from '../utils/errors.js';
|
|
18
|
+
import { getErrorMessage, getErrorCode } from '../utils/errors.js';
|
|
19
19
|
const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
20
20
|
function waitForExit(child) {
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
@@ -58,7 +58,7 @@ function createCredentialDaemonController({ root = PATHS.PROJECT_ROOT, codeRoot
|
|
|
58
58
|
daemonProcess.kill(signal);
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
61
|
-
if (err
|
|
61
|
+
if (getErrorCode(err) === 'ESRCH')
|
|
62
62
|
return;
|
|
63
63
|
throw err;
|
|
64
64
|
}
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* and lets the caller fall through to the normal "prompt for master
|
|
16
16
|
* password" path.
|
|
17
17
|
*/
|
|
18
|
-
declare function readCredentialSocketInode(socketPath:
|
|
19
|
-
declare function findCredentialSocketOwnerPid(socketPath:
|
|
18
|
+
declare function readCredentialSocketInode(socketPath: string): number;
|
|
19
|
+
declare function findCredentialSocketOwnerPid(socketPath: string, isLikelyProcess: ((pid: number) => boolean) | null | undefined): number;
|
|
20
20
|
/**
|
|
21
21
|
* Detect and clean up a credential daemon that is listening on our socket
|
|
22
22
|
* but was NOT started by the current unlock session.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { buildScopedChildEnv } from './child_env.js';
|
|
2
2
|
import { spawn } from 'node:child_process';
|
|
3
3
|
import { isLikelyMarketAdapterProcess } from '../../market_adapter/utils/file_lock.js';
|
|
4
|
-
declare function loadLockInfo(lockPath: string):
|
|
4
|
+
declare function loadLockInfo(lockPath: string): Record<string, unknown>;
|
|
5
5
|
declare function isLockStale(lockPath?: string, _staleAfterMs?: number, isAdapterProcess?: typeof isLikelyMarketAdapterProcess): boolean;
|
|
6
6
|
declare function createMarketAdapterRuntime({ root, script, lockFile, spawnFn, buildEnv, }?: {
|
|
7
7
|
root?: string | undefined;
|
|
@@ -14,17 +14,72 @@ declare function createMarketAdapterRuntime({ root, script, lockFile, spawnFn, b
|
|
|
14
14
|
activeBotCount: number;
|
|
15
15
|
botIds: unknown[];
|
|
16
16
|
hasOwnedChild: boolean;
|
|
17
|
-
ownedPid:
|
|
17
|
+
ownedPid: number | null;
|
|
18
18
|
runningExternally: boolean;
|
|
19
|
-
lockInfo:
|
|
19
|
+
lockInfo: Record<string, unknown>;
|
|
20
20
|
};
|
|
21
|
-
releaseBot: (botId: string) => Promise<
|
|
21
|
+
releaseBot: (botId: string) => Promise<{
|
|
22
|
+
running: boolean;
|
|
23
|
+
stopped: boolean;
|
|
24
|
+
} | {
|
|
25
|
+
running: boolean;
|
|
26
|
+
owned: boolean;
|
|
27
|
+
stopped: boolean;
|
|
28
|
+
}>;
|
|
22
29
|
shutdown: () => Promise<{
|
|
23
30
|
running: boolean;
|
|
24
31
|
stopped: boolean;
|
|
25
32
|
}>;
|
|
26
|
-
syncBot: (botId: string, shouldRun: boolean) => Promise<
|
|
33
|
+
syncBot: (botId: string, shouldRun: boolean) => Promise<{
|
|
34
|
+
running: boolean;
|
|
35
|
+
owned: boolean;
|
|
36
|
+
started: boolean;
|
|
37
|
+
external?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
running: boolean;
|
|
40
|
+
owned: boolean;
|
|
41
|
+
external: boolean;
|
|
42
|
+
started: boolean;
|
|
43
|
+
} | {
|
|
44
|
+
running: boolean;
|
|
45
|
+
stopped: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
|
48
|
+
declare function getSharedMarketAdapterRuntime(options?: {}): {
|
|
49
|
+
getStatus: () => {
|
|
50
|
+
activeBotCount: number;
|
|
51
|
+
botIds: unknown[];
|
|
52
|
+
hasOwnedChild: boolean;
|
|
53
|
+
ownedPid: number | null;
|
|
54
|
+
runningExternally: boolean;
|
|
55
|
+
lockInfo: Record<string, unknown>;
|
|
56
|
+
};
|
|
57
|
+
releaseBot: (botId: string) => Promise<{
|
|
58
|
+
running: boolean;
|
|
59
|
+
stopped: boolean;
|
|
60
|
+
} | {
|
|
61
|
+
running: boolean;
|
|
62
|
+
owned: boolean;
|
|
63
|
+
stopped: boolean;
|
|
64
|
+
}>;
|
|
65
|
+
shutdown: () => Promise<{
|
|
66
|
+
running: boolean;
|
|
67
|
+
stopped: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
syncBot: (botId: string, shouldRun: boolean) => Promise<{
|
|
70
|
+
running: boolean;
|
|
71
|
+
owned: boolean;
|
|
72
|
+
started: boolean;
|
|
73
|
+
external?: undefined;
|
|
74
|
+
} | {
|
|
75
|
+
running: boolean;
|
|
76
|
+
owned: boolean;
|
|
77
|
+
external: boolean;
|
|
78
|
+
started: boolean;
|
|
79
|
+
} | {
|
|
80
|
+
running: boolean;
|
|
81
|
+
stopped: boolean;
|
|
82
|
+
}>;
|
|
27
83
|
};
|
|
28
|
-
declare function getSharedMarketAdapterRuntime(options?: {}): any;
|
|
29
84
|
export { createMarketAdapterRuntime, getSharedMarketAdapterRuntime, isLikelyMarketAdapterProcess, isLockStale, loadLockInfo };
|
|
30
85
|
//# sourceMappingURL=market_adapter_runtime.d.ts.map
|
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
interface WatchdogOptions {
|
|
2
|
+
codeRoot?: string;
|
|
3
|
+
root?: string;
|
|
4
|
+
lockFile?: string;
|
|
5
|
+
botsFile?: string;
|
|
6
|
+
logWarn?: (...args: unknown[]) => void;
|
|
7
|
+
logError?: (...args: unknown[]) => void;
|
|
8
|
+
}
|
|
9
|
+
declare function createMarketAdapterWatchdog({ codeRoot, root, lockFile, botsFile, logWarn, logError, }?: WatchdogOptions): {
|
|
10
|
+
schedule: (errorLog: string) => () => void;
|
|
3
11
|
stop: () => Promise<void>;
|
|
4
12
|
isLikelyRunning: () => boolean;
|
|
5
13
|
readAdapterStatus: () => {
|
|
@@ -58,6 +58,10 @@ function createMarketAdapterWatchdog({ codeRoot = DEFAULT_CODE_ROOT, root = PATH
|
|
|
58
58
|
}
|
|
59
59
|
catch (_) { }
|
|
60
60
|
const exited = await withTimeout(new Promise((resolve) => {
|
|
61
|
+
if (!_child) {
|
|
62
|
+
resolve(true);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
61
65
|
_child.once('close', () => resolve(true));
|
|
62
66
|
}), LAUNCHER.SUPERVISOR.SHUTDOWN_TIMEOUT_MS, { onTimeout: 'resolve', defaultValue: false });
|
|
63
67
|
if (!exited && _child && _child.exitCode == null) {
|
|
@@ -7,15 +7,15 @@ declare const MONOLITHIC_OUT_LOG: string;
|
|
|
7
7
|
declare const MONOLITHIC_ERROR_LOG: string;
|
|
8
8
|
declare const CREDENTIAL_SOCKET_FILE: string;
|
|
9
9
|
declare const CREDENTIAL_READY_FILE: string;
|
|
10
|
-
declare function formatBotCount(count:
|
|
10
|
+
declare function formatBotCount(count: number): string;
|
|
11
11
|
declare function cleanupStateFiles(): void;
|
|
12
12
|
declare function readLiveMonolithicPid(): {
|
|
13
13
|
pid: number;
|
|
14
14
|
stale: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare function readMonolithicBotInfo(): any;
|
|
17
|
-
declare function isLikelyCredentialDaemonProcess(pid:
|
|
18
|
-
declare function isExpectedMonolithicBotPid(pid:
|
|
17
|
+
declare function isLikelyCredentialDaemonProcess(pid: number): boolean;
|
|
18
|
+
declare function isExpectedMonolithicBotPid(pid: number, botInfo: Record<string, unknown> | null): boolean;
|
|
19
19
|
declare function isProcessInDstate(pid: number): boolean;
|
|
20
20
|
declare function stopCredentialDaemonPid(pid: string | number): Promise<void>;
|
|
21
21
|
declare function cleanupCredentialRuntimeFiles(): void;
|
|
@@ -23,7 +23,9 @@ declare function stopCredentialDaemon(): Promise<{
|
|
|
23
23
|
signaled: boolean;
|
|
24
24
|
cleaned: boolean;
|
|
25
25
|
}>;
|
|
26
|
-
declare function ensureNoForeignCredentialDaemon({ verbose }?:
|
|
26
|
+
declare function ensureNoForeignCredentialDaemon({ verbose }?: {
|
|
27
|
+
verbose?: boolean;
|
|
28
|
+
}): Promise<boolean>;
|
|
27
29
|
declare function findCredentialSocketOwnerPid(): number;
|
|
28
30
|
declare function readCredentialDaemonStatus(pid: number | null): Promise<{
|
|
29
31
|
alive: boolean;
|
|
@@ -31,25 +33,25 @@ declare function readCredentialDaemonStatus(pid: number | null): Promise<{
|
|
|
31
33
|
socket: boolean;
|
|
32
34
|
}>;
|
|
33
35
|
declare function ensureLogDir(): void;
|
|
34
|
-
declare function buildDexbotStartArgs(botName:
|
|
36
|
+
declare function buildDexbotStartArgs(botName: string | null | undefined, dryrun?: boolean): string[];
|
|
35
37
|
declare function createUpdateScheduler({ botProcessRef, warn }?: {
|
|
36
38
|
botProcessRef?: {
|
|
37
|
-
current:
|
|
39
|
+
current: import('node:child_process').ChildProcess | null;
|
|
38
40
|
};
|
|
39
|
-
warn?: (...data:
|
|
41
|
+
warn?: (...data: unknown[]) => void;
|
|
40
42
|
}): {
|
|
41
43
|
cancel: () => void;
|
|
42
44
|
pendingRestart: boolean;
|
|
43
45
|
};
|
|
44
|
-
declare function listConfiguredBots(botsFile?:
|
|
45
|
-
name:
|
|
46
|
+
declare function listConfiguredBots(botsFile?: string): Array<{
|
|
47
|
+
name: string;
|
|
46
48
|
active: boolean;
|
|
47
|
-
gridPrice:
|
|
48
|
-
}
|
|
49
|
-
declare function getActiveAmaBotFingerprint(botsFile?:
|
|
50
|
-
declare function getControlBotNames(target:
|
|
51
|
-
declare function getControlActionLabel(cmd:
|
|
52
|
-
declare function getControlServiceNames(cmd:
|
|
53
|
-
declare function printControlActionSummary(action:
|
|
49
|
+
gridPrice: string;
|
|
50
|
+
}>;
|
|
51
|
+
declare function getActiveAmaBotFingerprint(botsFile?: string): string;
|
|
52
|
+
declare function getControlBotNames(target: string | null | undefined, wholeRuntime?: boolean): string[];
|
|
53
|
+
declare function getControlActionLabel(cmd: string): "shutting down" | "restarting" | "reloading" | "stopping";
|
|
54
|
+
declare function getControlServiceNames(cmd: string, botNames: string[]): string[];
|
|
55
|
+
declare function printControlActionSummary(action: string, botNames: string[], serviceNames?: string[]): void;
|
|
54
56
|
export { MONOLITHIC_PID_FILE, MONOLITHIC_BOT_PID_FILE, MONOLITHIC_BOT_INFO_FILE, MONOLITHIC_CRED_PID_FILE, MONOLITHIC_OUT_LOG, MONOLITHIC_ERROR_LOG, CREDENTIAL_SOCKET_FILE, CREDENTIAL_READY_FILE, cleanupStateFiles, readLiveMonolithicPid, readMonolithicBotInfo, isLikelyCredentialDaemonProcess, isExpectedMonolithicBotPid, readProcStat, isProcessInDstate, stopCredentialDaemonPid, cleanupCredentialRuntimeFiles, stopCredentialDaemon, ensureNoForeignCredentialDaemon, findCredentialSocketOwnerPid, readCredentialDaemonStatus, ensureLogDir, buildDexbotStartArgs, createUpdateScheduler, getActiveAmaBotFingerprint, listConfiguredBots, getControlBotNames, getControlActionLabel, getControlServiceNames, printControlActionSummary, formatBotCount };
|
|
55
57
|
//# sourceMappingURL=monolithic_runtime.d.ts.map
|
|
@@ -6,19 +6,27 @@ declare const STATUS_COLORS: {
|
|
|
6
6
|
warn: "\u001B[1;31m";
|
|
7
7
|
muted: "\u001B[97m";
|
|
8
8
|
};
|
|
9
|
-
declare function colorStatus(text: string, color: string, stream?:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
declare function
|
|
13
|
-
declare function
|
|
14
|
-
declare function
|
|
15
|
-
declare function
|
|
16
|
-
declare function
|
|
17
|
-
declare function
|
|
18
|
-
declare function
|
|
19
|
-
declare function
|
|
20
|
-
declare function
|
|
21
|
-
declare function
|
|
22
|
-
declare function
|
|
9
|
+
declare function colorStatus(text: string, color: string, stream?: {
|
|
10
|
+
isTTY?: boolean;
|
|
11
|
+
}): string;
|
|
12
|
+
declare function statusTitle(text: string): string;
|
|
13
|
+
declare function statusLabel(text: string): string;
|
|
14
|
+
declare function statusBool(value: unknown): string;
|
|
15
|
+
declare function statusActiveBotName(name: string): string;
|
|
16
|
+
declare function statusSuccess(text: string): string;
|
|
17
|
+
declare function statusError(text: string): string;
|
|
18
|
+
declare function readProcStat(pid: number): import("../process_discovery.js").ProcessStat | null;
|
|
19
|
+
declare function readProcMemMB(pid: number): string;
|
|
20
|
+
declare function readProcCpuTime(pid: number): string;
|
|
21
|
+
declare function readProcCpuPercent(pid: number, samples?: number, intervalMs?: number): Promise<string>;
|
|
22
|
+
declare function readProcUptime(pid: number): string;
|
|
23
|
+
declare function formatMemoryWithUptime(memory: string, uptime: string | null | undefined): string;
|
|
24
|
+
interface ControlBotStatus {
|
|
25
|
+
uptimeMs?: number;
|
|
26
|
+
status?: string;
|
|
27
|
+
pid?: number;
|
|
28
|
+
restarts?: number;
|
|
29
|
+
}
|
|
30
|
+
declare function printControlStatus(status: Record<string, ControlBotStatus>): void;
|
|
23
31
|
export { STATUS_COLORS, colorStatus, statusTitle, statusLabel, statusBool, statusActiveBotName, statusSuccess, statusError, readProcStat, readProcMemMB, readProcCpuTime, readProcCpuPercent, readProcUptime, formatMemoryWithUptime, printControlStatus };
|
|
24
32
|
//# sourceMappingURL=status_reporting.d.ts.map
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UnknownRecord } from '../types.js';
|
|
2
|
+
interface ControlResponse {
|
|
3
|
+
ok?: boolean;
|
|
4
|
+
status?: unknown;
|
|
5
|
+
error?: string;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare function sendControlCommand(cmd: UnknownRecord): Promise<ControlResponse>;
|
|
2
9
|
export { sendControlCommand };
|
|
3
10
|
//# sourceMappingURL=supervisor_control.d.ts.map
|