dexbot 1.6.7 → 1.6.8
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 +49 -1
- package/README.md +3 -3
- package/analysis/README.md +2 -3
- package/analysis/tradingview/README.md +78 -1
- package/analysis/trend_detection/DYNAMIC_WEIGHT_RESEARCH.md +1 -1
- 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/tradingview/analyze_tradingview.d.ts +4 -0
- package/dist/analysis/tradingview/analyze_tradingview.js +55 -0
- package/dist/analysis/tradingview/grid_reset_config.d.ts +61 -0
- package/dist/analysis/tradingview/grid_reset_config.js +235 -0
- package/dist/analysis/tradingview/grid_reset_sim.d.ts +67 -0
- package/dist/analysis/tradingview/grid_reset_sim.js +307 -0
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js +419 -3
- package/dist/dexbot.js +22 -6
- package/dist/market_adapter/core/market_adapter_service.js +14 -2
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts +8 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js +5 -1
- package/dist/market_adapter/inputs/window_cache.d.ts +97 -19
- package/dist/market_adapter/inputs/window_cache.js +302 -48
- package/dist/market_adapter/market_adapter.d.ts +8 -1
- package/dist/market_adapter/market_adapter.js +22 -4
- package/dist/modules/account_bots.js +10 -0
- package/dist/modules/account_orders.d.ts +24 -2
- package/dist/modules/account_orders.js +41 -4
- package/dist/modules/bot_settings.js +10 -1
- package/dist/modules/config.d.ts +1 -0
- package/dist/modules/config.js +1 -0
- package/dist/modules/constants.d.ts +11 -3
- package/dist/modules/constants.js +116 -37
- package/dist/modules/dexbot_class.d.ts +6 -76
- package/dist/modules/dexbot_class.js +0 -32
- package/dist/modules/dexbot_cow_runtime.d.ts +3 -58
- package/dist/modules/dexbot_cow_runtime.js +4 -87
- package/dist/modules/dexbot_maintenance_runtime.d.ts +15 -1
- package/dist/modules/dexbot_maintenance_runtime.js +59 -11
- package/dist/modules/dexbot_startup_runtime.js +73 -20
- package/dist/modules/dexbot_state_recovery.d.ts +6 -0
- package/dist/modules/dexbot_state_recovery.js +21 -0
- package/dist/modules/order/async_lock.d.ts +8 -0
- package/dist/modules/order/async_lock.js +15 -0
- package/dist/modules/order/genesis_policy.d.ts +162 -0
- package/dist/modules/order/genesis_policy.js +267 -0
- package/dist/modules/order/grid.js +76 -134
- package/dist/modules/order/grid_reconcile.d.ts +9 -0
- package/dist/modules/order/grid_reconcile.js +13 -4
- package/dist/modules/order/grid_reconcile_internal.js +2 -2
- package/dist/modules/order/manager.d.ts +4 -0
- package/dist/modules/order/manager.js +14 -1
- package/dist/modules/order/sync_engine.d.ts +19 -0
- package/dist/modules/order/sync_engine.js +284 -344
- package/dist/modules/order/utils/math.d.ts +22 -1
- package/dist/modules/order/utils/math.js +64 -1
- package/dist/modules/order/utils/order.d.ts +43 -58
- package/dist/modules/order/utils/order.js +220 -197
- package/dist/modules/order/utils/system.js +8 -1
- package/dist/modules/paths.d.ts +1 -0
- package/dist/modules/paths.js +1 -0
- package/dist/modules/version_notice.d.ts +165 -0
- package/dist/modules/version_notice.js +364 -0
- package/dist/pm2.js +9 -0
- package/dist/unlock.js +28 -0
- package/docs/BITSHARES_ONBOARDING.md +8 -1
- package/docs/COW_INVARIANTS.md +3 -2
- package/docs/DEXBOT_COMPARISON.md +4 -4
- package/docs/EVOLUTION.md +20 -19
- package/docs/FUND_MOVEMENT_AND_ACCOUNTING.md +1 -1
- package/docs/GRID_PRICE_INVARIANT.md +149 -31
- package/docs/GRID_RECALCULATION.md +12 -0
- package/docs/README.md +3 -1
- package/docs/WORKFLOW.md +16 -5
- package/market_adapter/README.md +1 -1
- package/modules/README.md +18 -1
- package/package.json +13 -5
- package/scripts/README.md +28 -2
- package/scripts/clear-all.sh +13 -4
- package/scripts/clear-logs.sh +13 -4
- package/scripts/clear-market-adapter.sh +6 -0
- package/scripts/clear-orders.sh +5 -0
- package/scripts/lib/dexbot-paths.sh +108 -0
- package/tests/README.md +11 -3
- package/analysis/account_resolver.ts +0 -161
- package/analysis/ama_fitting/analyze_ama_price_changes.ts +0 -155
- package/analysis/ama_fitting/analyze_lambda_vs_slow.ts +0 -404
- package/analysis/ama_fitting/calibrate_convergence_er.ts +0 -201
- package/analysis/ama_fitting/fetch_lp_candles.ts +0 -184
- package/analysis/ama_fitting/generate_unified_comparison_chart.ts +0 -232
- package/analysis/ama_fitting/optimizer_high_resolution.ts +0 -802
- package/analysis/analyze_dynamic_weight.ts +0 -243
- package/analysis/analyze_kalman.ts +0 -157
- package/analysis/analyze_regime.ts +0 -158
- package/analysis/analyze_regime_windows.ts +0 -470
- package/analysis/analyze_risk_profile.ts +0 -199
- package/analysis/analyze_trade_heatmap.ts +0 -362
- package/analysis/analyze_volatility.ts +0 -182
- package/analysis/bot_fitting/backtest_ama_sweep.ts +0 -934
- package/analysis/bot_fitting/backtest_bot_fitting.ts +0 -861
- package/analysis/bot_fitting/shared_utils.ts +0 -52
- package/analysis/bot_key_utils.ts +0 -426
- package/analysis/bot_usage/discover_bot_accounts.ts +0 -635
- package/analysis/bot_usage/kibana_bot_queries.ts +0 -211
- package/analysis/chain_pool.ts +0 -47
- package/analysis/chart_css.ts +0 -62
- package/analysis/chart_ui.ts +0 -105
- package/analysis/chart_utils.ts +0 -210
- package/analysis/fills_source.ts +0 -228
- package/analysis/grid_correction_check.ts +0 -786
- package/analysis/math_utils.ts +0 -53
- package/analysis/price_sources.ts +0 -136
- package/analysis/resolve_bot_accounts.ts +0 -199
- package/analysis/resolve_source.ts +0 -99
- package/analysis/results/ama_sweep_results_lp_pool_133_1h.json +0 -2455
- package/analysis/results/bot_fitting_results_lp_pool_133_1h.json +0 -218
- package/analysis/trade_profitability.ts +0 -1335
- package/analysis/tradingview/analyze_tradingview.ts +0 -280
- package/analysis/tradingview/h-bts_tradingview.html +0 -1570
- package/analysis/tradingview/t-bts_tradingview.html +0 -1570
- package/analysis/tradingview/tradingview_uplot_chart_generator.ts +0 -3268
- package/analysis/trend_detection/dynamic_weight_chart_generator.ts +0 -1481
- package/analysis/trend_detection/hurst_analyzer.ts +0 -7
- package/analysis/trend_detection/kalman_chart_generator.ts +0 -398
- package/analysis/trend_detection/kalman_trend_analyzer.ts +0 -9
- package/analysis/trend_detection/kalman_velocity_smoothing.ts +0 -7
- package/analysis/trend_detection/package.json +0 -23
- package/analysis/trend_detection/permutation_entropy_analyzer.ts +0 -7
- package/analysis/trend_detection/regime_chart_generator.ts +0 -338
- package/analysis/trend_detection/tests/test_kalman_trend.ts +0 -153
- package/analysis/trend_detection/tests/test_kalman_velocity_smoothing.ts +0 -64
- package/analysis/trend_detection/volatility_chart_generator.ts +0 -654
- package/analysis/tsconfig.json +0 -29
- package/claw/tests/package.json +0 -3
- package/claw/tests/test_claw_bridge.ts +0 -570
- package/claw/tests/test_claw_catalog_and_credentials.ts +0 -156
- package/claw/tests/test_claw_chain_layer.ts +0 -739
- package/claw/tests/test_claw_data_flow.ts +0 -525
- package/claw/tests/test_claw_domain_logic.ts +0 -471
- package/claw/tests/test_claw_manifest_and_matrix.ts +0 -222
- package/claw/tests/test_claw_mcp_transport.ts +0 -243
- package/claw/tests/test_claw_regressions.ts +0 -711
- package/claw/tests/test_claw_skill_generation.ts +0 -103
- package/claw/tests/test_claw_state_store.ts +0 -44
- package/claw/tests/test_dexbot_profiles.ts +0 -654
- package/claw/tests/test_memu_bridge.ts +0 -189
- package/claw/tests/test_nullclaw_tmp_integration.ts +0 -57
- package/claw/tests/test_position_health.ts +0 -343
- package/claw/tests/test_position_manager.ts +0 -429
- package/claw/tests/test_position_manager_watch_health.ts +0 -100
- package/claw/tests/test_short_mpa_strategy.ts +0 -232
- package/dist/analysis/account_resolver.d.ts.map +0 -1
- package/dist/analysis/account_resolver.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_ama_price_changes.js.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/analyze_lambda_vs_slow.js.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/calibrate_convergence_er.js.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/fetch_lp_candles.js.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/generate_unified_comparison_chart.js.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.d.ts.map +0 -1
- package/dist/analysis/ama_fitting/optimizer_high_resolution.js.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.d.ts.map +0 -1
- package/dist/analysis/analyze_dynamic_weight.js.map +0 -1
- package/dist/analysis/analyze_kalman.d.ts.map +0 -1
- package/dist/analysis/analyze_kalman.js.map +0 -1
- package/dist/analysis/analyze_regime.d.ts.map +0 -1
- package/dist/analysis/analyze_regime.js.map +0 -1
- package/dist/analysis/analyze_regime_windows.d.ts.map +0 -1
- package/dist/analysis/analyze_regime_windows.js.map +0 -1
- package/dist/analysis/analyze_risk_profile.d.ts.map +0 -1
- package/dist/analysis/analyze_risk_profile.js.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.d.ts.map +0 -1
- package/dist/analysis/analyze_trade_heatmap.js.map +0 -1
- package/dist/analysis/analyze_volatility.d.ts.map +0 -1
- package/dist/analysis/analyze_volatility.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_ama_sweep.js.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/backtest_bot_fitting.js.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.d.ts.map +0 -1
- package/dist/analysis/bot_fitting/shared_utils.js.map +0 -1
- package/dist/analysis/bot_key_utils.d.ts.map +0 -1
- package/dist/analysis/bot_key_utils.js.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/bot_usage/discover_bot_accounts.js.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.d.ts.map +0 -1
- package/dist/analysis/bot_usage/kibana_bot_queries.js.map +0 -1
- package/dist/analysis/chain_pool.d.ts.map +0 -1
- package/dist/analysis/chain_pool.js.map +0 -1
- package/dist/analysis/chart_css.d.ts.map +0 -1
- package/dist/analysis/chart_css.js.map +0 -1
- package/dist/analysis/chart_ui.d.ts.map +0 -1
- package/dist/analysis/chart_ui.js.map +0 -1
- package/dist/analysis/chart_utils.d.ts.map +0 -1
- package/dist/analysis/chart_utils.js.map +0 -1
- package/dist/analysis/fills_source.d.ts.map +0 -1
- package/dist/analysis/fills_source.js.map +0 -1
- package/dist/analysis/grid_correction_check.d.ts.map +0 -1
- package/dist/analysis/grid_correction_check.js.map +0 -1
- package/dist/analysis/math_utils.d.ts.map +0 -1
- package/dist/analysis/math_utils.js.map +0 -1
- package/dist/analysis/price_sources.d.ts.map +0 -1
- package/dist/analysis/price_sources.js.map +0 -1
- package/dist/analysis/resolve_bot_accounts.d.ts.map +0 -1
- package/dist/analysis/resolve_bot_accounts.js.map +0 -1
- package/dist/analysis/resolve_source.d.ts.map +0 -1
- package/dist/analysis/resolve_source.js.map +0 -1
- package/dist/analysis/trade_profitability.d.ts.map +0 -1
- package/dist/analysis/trade_profitability.js.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.d.ts.map +0 -1
- package/dist/analysis/tradingview/analyze_tradingview.js.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.d.ts.map +0 -1
- package/dist/analysis/tradingview/tradingview_uplot_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/dynamic_weight_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/hurst_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_trend_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/analysis/trend_detection/permutation_entropy_analyzer.js.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/regime_chart_generator.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_trend.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js +0 -128
- package/dist/analysis/trend_detection/tests/test_kalman_trend.js.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts +0 -2
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js +0 -37
- package/dist/analysis/trend_detection/tests/test_kalman_velocity_smoothing.js.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.d.ts.map +0 -1
- package/dist/analysis/trend_detection/volatility_chart_generator.js.map +0 -1
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js.map +0 -1
- package/dist/credential-daemon.d.ts.map +0 -1
- package/dist/credential-daemon.js.map +0 -1
- package/dist/dexbot.d.ts.map +0 -1
- package/dist/dexbot.js.map +0 -1
- package/dist/market_adapter/ama_signal_runner.d.ts.map +0 -1
- package/dist/market_adapter/ama_signal_runner.js.map +0 -1
- package/dist/market_adapter/candle_utils.d.ts.map +0 -1
- package/dist/market_adapter/candle_utils.js.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.d.ts.map +0 -1
- package/dist/market_adapter/core/asymmetric_bounds.js.map +0 -1
- package/dist/market_adapter/core/config_normalizers.d.ts.map +0 -1
- package/dist/market_adapter/core/config_normalizers.js.map +0 -1
- package/dist/market_adapter/core/kibana_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_candles.js.map +0 -1
- package/dist/market_adapter/core/kibana_client.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_client.js.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.d.ts.map +0 -1
- package/dist/market_adapter/core/kibana_market_candles.js.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.d.ts.map +0 -1
- package/dist/market_adapter/core/market_adapter_service.js.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/hurst_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_trend_analyzer.js.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/kalman_velocity_smoothing.js.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.d.ts.map +0 -1
- package/dist/market_adapter/core/signals/permutation_entropy_analyzer.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama.js.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/ama_slope_model.js.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/atr/calculator.js.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/collateral_manager.js.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/dynamic_weight_series.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_gate.js.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/regime_interp.js.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.d.ts.map +0 -1
- package/dist/market_adapter/core/strategies/volatility_shift.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_book_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_cex_synthetic_data.js.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.d.ts.map +0 -1
- package/dist/market_adapter/inputs/fetch_lp_data.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_feed_source.js.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.d.ts.map +0 -1
- package/dist/market_adapter/inputs/kibana_source.js.map +0 -1
- package/dist/market_adapter/inputs/window_cache.d.ts.map +0 -1
- package/dist/market_adapter/inputs/window_cache.js.map +0 -1
- package/dist/market_adapter/interval_utils.d.ts.map +0 -1
- package/dist/market_adapter/interval_utils.js.map +0 -1
- package/dist/market_adapter/log_format.d.ts.map +0 -1
- package/dist/market_adapter/log_format.js.map +0 -1
- package/dist/market_adapter/lp_chart_core.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_core.js.map +0 -1
- package/dist/market_adapter/lp_chart_runner.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_runner.js.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.d.ts.map +0 -1
- package/dist/market_adapter/lp_chart_strategy_loader.js.map +0 -1
- package/dist/market_adapter/market_adapter.d.ts.map +0 -1
- package/dist/market_adapter/market_adapter.js.map +0 -1
- package/dist/market_adapter/test_helpers.d.ts.map +0 -1
- package/dist/market_adapter/test_helpers.js.map +0 -1
- package/dist/market_adapter/utils/adapter_client.d.ts.map +0 -1
- package/dist/market_adapter/utils/adapter_client.js.map +0 -1
- package/dist/market_adapter/utils/atomic_write.d.ts.map +0 -1
- package/dist/market_adapter/utils/atomic_write.js.map +0 -1
- package/dist/market_adapter/utils/chain.d.ts.map +0 -1
- package/dist/market_adapter/utils/chain.js.map +0 -1
- package/dist/market_adapter/utils/data_discovery.d.ts.map +0 -1
- package/dist/market_adapter/utils/data_discovery.js.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.d.ts.map +0 -1
- package/dist/market_adapter/utils/dynamic_grid_snapshot.js.map +0 -1
- package/dist/market_adapter/utils/file_lock.d.ts.map +0 -1
- package/dist/market_adapter/utils/file_lock.js.map +0 -1
- package/dist/market_adapter/utils/native_history.d.ts.map +0 -1
- package/dist/market_adapter/utils/native_history.js.map +0 -1
- package/dist/modules/account_bots.d.ts.map +0 -1
- package/dist/modules/account_bots.js.map +0 -1
- package/dist/modules/account_orders.d.ts.map +0 -1
- package/dist/modules/account_orders.js.map +0 -1
- package/dist/modules/authority_resolver.d.ts.map +0 -1
- package/dist/modules/authority_resolver.js.map +0 -1
- package/dist/modules/bitshares-native/chain_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/chain_client.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.browser.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc.js.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.d.ts.map +0 -1
- package/dist/modules/bitshares-native/crypto/ecc_selector.js.map +0 -1
- package/dist/modules/bitshares-native/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/index.js.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/lru_cache.js.map +0 -1
- package/dist/modules/bitshares-native/resolvers.d.ts.map +0 -1
- package/dist/modules/bitshares-native/resolvers.js.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/chain_constants.js.map +0 -1
- package/dist/modules/bitshares-native/serial/index.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/index.js.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/operations.js.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/serializer.js.map +0 -1
- package/dist/modules/bitshares-native/serial/types.d.ts.map +0 -1
- package/dist/modules/bitshares-native/serial/types.js.map +0 -1
- package/dist/modules/bitshares-native/signing_client.d.ts.map +0 -1
- package/dist/modules/bitshares-native/signing_client.js.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.d.ts.map +0 -1
- package/dist/modules/bitshares-native/subscriptions.js.map +0 -1
- package/dist/modules/bitshares-native/transport.d.ts.map +0 -1
- package/dist/modules/bitshares-native/transport.js.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/builder.js.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.d.ts.map +0 -1
- package/dist/modules/bitshares-native/tx/tx_cache.js.map +0 -1
- package/dist/modules/bitshares_client.d.ts.map +0 -1
- package/dist/modules/bitshares_client.js.map +0 -1
- package/dist/modules/bot_defaults.d.ts.map +0 -1
- package/dist/modules/bot_defaults.js.map +0 -1
- package/dist/modules/bot_settings.d.ts.map +0 -1
- package/dist/modules/bot_settings.js.map +0 -1
- package/dist/modules/bots_file_lock.d.ts.map +0 -1
- package/dist/modules/bots_file_lock.js.map +0 -1
- package/dist/modules/broadcast_failure.d.ts.map +0 -1
- package/dist/modules/broadcast_failure.js.map +0 -1
- package/dist/modules/chain_keys.d.ts.map +0 -1
- package/dist/modules/chain_keys.js.map +0 -1
- package/dist/modules/chain_orders.d.ts.map +0 -1
- package/dist/modules/chain_orders.js.map +0 -1
- package/dist/modules/cli_colors.d.ts.map +0 -1
- package/dist/modules/cli_colors.js.map +0 -1
- package/dist/modules/cli_start_onboarding.d.ts.map +0 -1
- package/dist/modules/cli_start_onboarding.js.map +0 -1
- package/dist/modules/cli_start_output.d.ts.map +0 -1
- package/dist/modules/cli_start_output.js.map +0 -1
- package/dist/modules/config.d.ts.map +0 -1
- package/dist/modules/config.js.map +0 -1
- package/dist/modules/constants.d.ts.map +0 -1
- package/dist/modules/constants.js.map +0 -1
- package/dist/modules/cr_planner.d.ts.map +0 -1
- package/dist/modules/cr_planner.js.map +0 -1
- package/dist/modules/credential_policy.d.ts.map +0 -1
- package/dist/modules/credential_policy.js.map +0 -1
- package/dist/modules/credential_runtime.d.ts.map +0 -1
- package/dist/modules/credential_runtime.js.map +0 -1
- package/dist/modules/credential_session_cache.d.ts.map +0 -1
- package/dist/modules/credential_session_cache.js.map +0 -1
- package/dist/modules/credit_pricing.d.ts.map +0 -1
- package/dist/modules/credit_pricing.js.map +0 -1
- package/dist/modules/credit_runtime.d.ts.map +0 -1
- package/dist/modules/credit_runtime.js.map +0 -1
- package/dist/modules/crypto/browser_provider.d.ts.map +0 -1
- package/dist/modules/crypto/browser_provider.js.map +0 -1
- package/dist/modules/crypto/index.d.ts.map +0 -1
- package/dist/modules/crypto/index.js.map +0 -1
- package/dist/modules/crypto/node_provider.d.ts.map +0 -1
- package/dist/modules/crypto/node_provider.js.map +0 -1
- package/dist/modules/crypto/provider.d.ts.map +0 -1
- package/dist/modules/crypto/provider.js.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.d.ts.map +0 -1
- package/dist/modules/crypto/pure_ripemd160.js.map +0 -1
- package/dist/modules/crypto/pure_scrypt.d.ts.map +0 -1
- package/dist/modules/crypto/pure_scrypt.js.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.d.ts.map +0 -1
- package/dist/modules/crypto/pure_secp256k1.js.map +0 -1
- package/dist/modules/crypto/sync.d.ts.map +0 -1
- package/dist/modules/crypto/sync.js.map +0 -1
- package/dist/modules/daemon_node_health.d.ts.map +0 -1
- package/dist/modules/daemon_node_health.js.map +0 -1
- package/dist/modules/dexbot_class.d.ts.map +0 -1
- package/dist/modules/dexbot_class.js.map +0 -1
- package/dist/modules/dexbot_cow_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_cow_runtime.js.map +0 -1
- package/dist/modules/dexbot_credential_client.d.ts.map +0 -1
- package/dist/modules/dexbot_credential_client.js.map +0 -1
- package/dist/modules/dexbot_fill_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_fill_runtime.js.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_maintenance_runtime.js.map +0 -1
- package/dist/modules/dexbot_startup_runtime.d.ts.map +0 -1
- package/dist/modules/dexbot_startup_runtime.js.map +0 -1
- package/dist/modules/dexbot_state_recovery.d.ts.map +0 -1
- package/dist/modules/dexbot_state_recovery.js.map +0 -1
- package/dist/modules/env.d.ts.map +0 -1
- package/dist/modules/env.js.map +0 -1
- package/dist/modules/fund_registry.d.ts.map +0 -1
- package/dist/modules/fund_registry.js.map +0 -1
- package/dist/modules/general_settings.d.ts.map +0 -1
- package/dist/modules/general_settings.js.map +0 -1
- package/dist/modules/graceful_shutdown.d.ts.map +0 -1
- package/dist/modules/graceful_shutdown.js.map +0 -1
- package/dist/modules/grid_price_source.d.ts.map +0 -1
- package/dist/modules/grid_price_source.js.map +0 -1
- package/dist/modules/key_store.d.ts.map +0 -1
- package/dist/modules/key_store.js.map +0 -1
- package/dist/modules/launcher/adapter_requirement.d.ts.map +0 -1
- package/dist/modules/launcher/adapter_requirement.js.map +0 -1
- package/dist/modules/launcher/bot_supervisor.d.ts.map +0 -1
- package/dist/modules/launcher/bot_supervisor.js.map +0 -1
- package/dist/modules/launcher/child_env.d.ts.map +0 -1
- package/dist/modules/launcher/child_env.js.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.d.ts.map +0 -1
- package/dist/modules/launcher/credential_bootstrap.js.map +0 -1
- package/dist/modules/launcher/credential_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/credential_daemon.js.map +0 -1
- package/dist/modules/launcher/credential_secret.d.ts.map +0 -1
- package/dist/modules/launcher/credential_secret.js.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.d.ts.map +0 -1
- package/dist/modules/launcher/foreign_cred_daemon.js.map +0 -1
- package/dist/modules/launcher/headless_password.d.ts.map +0 -1
- package/dist/modules/launcher/headless_password.js.map +0 -1
- package/dist/modules/launcher/launch_modes.d.ts.map +0 -1
- package/dist/modules/launcher/launch_modes.js.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_runtime.js.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.d.ts.map +0 -1
- package/dist/modules/launcher/market_adapter_watchdog.js.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.d.ts.map +0 -1
- package/dist/modules/launcher/monolithic_runtime.js.map +0 -1
- package/dist/modules/launcher/runtime_entry.d.ts.map +0 -1
- package/dist/modules/launcher/runtime_entry.js.map +0 -1
- package/dist/modules/launcher/status_reporting.d.ts.map +0 -1
- package/dist/modules/launcher/status_reporting.js.map +0 -1
- package/dist/modules/launcher/supervisor_control.d.ts.map +0 -1
- package/dist/modules/launcher/supervisor_control.js.map +0 -1
- package/dist/modules/market_adapter_whitelist.d.ts.map +0 -1
- package/dist/modules/market_adapter_whitelist.js.map +0 -1
- package/dist/modules/node_connect_policy.d.ts.map +0 -1
- package/dist/modules/node_connect_policy.js.map +0 -1
- package/dist/modules/node_failure_ledger.d.ts.map +0 -1
- package/dist/modules/node_failure_ledger.js.map +0 -1
- package/dist/modules/node_health_cache.d.ts.map +0 -1
- package/dist/modules/node_health_cache.js.map +0 -1
- package/dist/modules/node_manager.d.ts.map +0 -1
- package/dist/modules/node_manager.js.map +0 -1
- package/dist/modules/order/accounting.d.ts.map +0 -1
- package/dist/modules/order/accounting.js.map +0 -1
- package/dist/modules/order/async_lock.d.ts.map +0 -1
- package/dist/modules/order/async_lock.js.map +0 -1
- package/dist/modules/order/export.d.ts.map +0 -1
- package/dist/modules/order/export.js.map +0 -1
- package/dist/modules/order/format.d.ts.map +0 -1
- package/dist/modules/order/format.js.map +0 -1
- package/dist/modules/order/grid.d.ts.map +0 -1
- package/dist/modules/order/grid.js.map +0 -1
- package/dist/modules/order/grid_reconcile.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile.js.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.d.ts.map +0 -1
- package/dist/modules/order/grid_reconcile_internal.js.map +0 -1
- package/dist/modules/order/index.d.ts.map +0 -1
- package/dist/modules/order/index.js.map +0 -1
- package/dist/modules/order/logger.d.ts.map +0 -1
- package/dist/modules/order/logger.js.map +0 -1
- package/dist/modules/order/logger_state.d.ts.map +0 -1
- package/dist/modules/order/logger_state.js.map +0 -1
- package/dist/modules/order/manager.d.ts.map +0 -1
- package/dist/modules/order/manager.js.map +0 -1
- package/dist/modules/order/processed_fill_store.d.ts.map +0 -1
- package/dist/modules/order/processed_fill_store.js.map +0 -1
- package/dist/modules/order/strategy.d.ts.map +0 -1
- package/dist/modules/order/strategy.js.map +0 -1
- package/dist/modules/order/sync_engine.d.ts.map +0 -1
- package/dist/modules/order/sync_engine.js.map +0 -1
- package/dist/modules/order/utils/math.d.ts.map +0 -1
- package/dist/modules/order/utils/math.js.map +0 -1
- package/dist/modules/order/utils/order.d.ts.map +0 -1
- package/dist/modules/order/utils/order.js.map +0 -1
- package/dist/modules/order/utils/slot.d.ts.map +0 -1
- package/dist/modules/order/utils/slot.js.map +0 -1
- package/dist/modules/order/utils/system.d.ts.map +0 -1
- package/dist/modules/order/utils/system.js.map +0 -1
- package/dist/modules/order/utils/timeout.d.ts.map +0 -1
- package/dist/modules/order/utils/timeout.js.map +0 -1
- package/dist/modules/order/utils/validate.d.ts.map +0 -1
- package/dist/modules/order/utils/validate.js.map +0 -1
- package/dist/modules/order/utils/withPoolRef.d.ts.map +0 -1
- package/dist/modules/order/utils/withPoolRef.js.map +0 -1
- package/dist/modules/order/working_grid.d.ts.map +0 -1
- package/dist/modules/order/working_grid.js.map +0 -1
- package/dist/modules/path_api.d.ts.map +0 -1
- package/dist/modules/path_api.js.map +0 -1
- package/dist/modules/paths.d.ts.map +0 -1
- package/dist/modules/paths.js.map +0 -1
- package/dist/modules/process_discovery.d.ts.map +0 -1
- package/dist/modules/process_discovery.js.map +0 -1
- package/dist/modules/runtime.d.ts.map +0 -1
- package/dist/modules/runtime.js.map +0 -1
- package/dist/modules/runtime_settings.d.ts.map +0 -1
- package/dist/modules/runtime_settings.js.map +0 -1
- package/dist/modules/settings_merge.d.ts.map +0 -1
- package/dist/modules/settings_merge.js.map +0 -1
- package/dist/modules/socket_json_client.d.ts.map +0 -1
- package/dist/modules/socket_json_client.js.map +0 -1
- package/dist/modules/storage/browser_adapter.d.ts.map +0 -1
- package/dist/modules/storage/browser_adapter.js.map +0 -1
- package/dist/modules/storage/index.d.ts.map +0 -1
- package/dist/modules/storage/index.js.map +0 -1
- package/dist/modules/storage/node_adapter.d.ts.map +0 -1
- package/dist/modules/storage/node_adapter.js.map +0 -1
- package/dist/modules/storage/types.d.ts.map +0 -1
- package/dist/modules/storage/types.js.map +0 -1
- package/dist/modules/types.d.ts.map +0 -1
- package/dist/modules/types.js.map +0 -1
- package/dist/modules/utils/base58check.d.ts.map +0 -1
- package/dist/modules/utils/base58check.js.map +0 -1
- package/dist/modules/utils/build_dir.d.ts.map +0 -1
- package/dist/modules/utils/build_dir.js.map +0 -1
- package/dist/modules/utils/chain_logs.d.ts.map +0 -1
- package/dist/modules/utils/chain_logs.js.map +0 -1
- package/dist/modules/utils/errors.d.ts.map +0 -1
- package/dist/modules/utils/errors.js.map +0 -1
- package/dist/modules/utils/sanitize_key.d.ts.map +0 -1
- package/dist/modules/utils/sanitize_key.js.map +0 -1
- package/dist/modules/utils/text_width.d.ts.map +0 -1
- package/dist/modules/utils/text_width.js.map +0 -1
- package/dist/modules/validate_profiles.d.ts.map +0 -1
- package/dist/modules/validate_profiles.js.map +0 -1
- package/dist/pm2.d.ts.map +0 -1
- package/dist/pm2.js.map +0 -1
- package/dist/scripts/analyze-credit.d.ts.map +0 -1
- package/dist/scripts/analyze-credit.js.map +0 -1
- package/dist/scripts/analyze-git.d.ts.map +0 -1
- package/dist/scripts/analyze-git.js.map +0 -1
- package/dist/scripts/analyze-orders.d.ts.map +0 -1
- package/dist/scripts/analyze-orders.js.map +0 -1
- package/dist/scripts/chart_command.d.ts.map +0 -1
- package/dist/scripts/chart_command.js.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.d.ts.map +0 -1
- package/dist/scripts/diagnose-kibana-candles.js.map +0 -1
- package/dist/scripts/diagnose-pool-history.d.ts.map +0 -1
- package/dist/scripts/diagnose-pool-history.js.map +0 -1
- package/dist/scripts/divergence-calc.d.ts.map +0 -1
- package/dist/scripts/divergence-calc.js.map +0 -1
- package/dist/scripts/dw.d.ts.map +0 -1
- package/dist/scripts/dw.js.map +0 -1
- package/dist/scripts/generate_lp_chart.d.ts.map +0 -1
- package/dist/scripts/generate_lp_chart.js.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.d.ts.map +0 -1
- package/dist/scripts/generate_mainnet_corpus_report.js.map +0 -1
- package/dist/scripts/native_release_gates.d.ts.map +0 -1
- package/dist/scripts/native_release_gates.js.map +0 -1
- package/dist/scripts/print_grid.d.ts.map +0 -1
- package/dist/scripts/print_grid.js.map +0 -1
- package/dist/scripts/run-tests.d.ts.map +0 -1
- package/dist/scripts/run-tests.js.map +0 -1
- package/dist/scripts/runner.d.ts.map +0 -1
- package/dist/scripts/runner.js.map +0 -1
- package/dist/scripts/sync-version.d.ts.map +0 -1
- package/dist/scripts/sync-version.js.map +0 -1
- package/dist/scripts/test-credit-renewal.d.ts.map +0 -1
- package/dist/scripts/test-credit-renewal.js.map +0 -1
- package/dist/scripts/tv.d.ts.map +0 -1
- package/dist/scripts/tv.js.map +0 -1
- package/dist/scripts/update.d.ts.map +0 -1
- package/dist/scripts/update.js.map +0 -1
- package/dist/scripts/update_dist_freshness.d.ts.map +0 -1
- package/dist/scripts/update_dist_freshness.js.map +0 -1
- package/dist/scripts/validate_bots.d.ts.map +0 -1
- package/dist/scripts/validate_bots.js.map +0 -1
- package/dist/scripts/verify-browser-bundle.d.ts.map +0 -1
- package/dist/scripts/verify-browser-bundle.js.map +0 -1
- package/dist/unlock.d.ts.map +0 -1
- package/dist/unlock.js.map +0 -1
|
@@ -1423,7 +1423,8 @@ export async function applyGridDivergenceCorrections(manager, accountOrders, _bo
|
|
|
1423
1423
|
edgeAnchors: {
|
|
1424
1424
|
buy: OrderUtils.resolveLiveReserveEdgeAnchorPrice(manager, 'buy'),
|
|
1425
1425
|
sell: OrderUtils.resolveLiveReserveEdgeAnchorPrice(manager, 'sell')
|
|
1426
|
-
}
|
|
1426
|
+
},
|
|
1427
|
+
manager
|
|
1427
1428
|
});
|
|
1428
1429
|
// Build COW result with all actions
|
|
1429
1430
|
if (actions.length > 0) {
|
|
@@ -1916,6 +1917,12 @@ export async function applyPersistedPendingCrawls(bot, options = {}) {
|
|
|
1916
1917
|
}
|
|
1917
1918
|
catch { /* best-effort */ }
|
|
1918
1919
|
}
|
|
1920
|
+
else if (result?.reason === 'restore-failed') {
|
|
1921
|
+
// consumePendingFillCrawls deliberately does NOT clear the ledger
|
|
1922
|
+
// on a restore failure, so these records are retained and retried —
|
|
1923
|
+
// they were not dropped.
|
|
1924
|
+
log(`[BOUNDARY] Pending fill crawls retained (${result.reason}); restored boundary kept`, 'warn');
|
|
1925
|
+
}
|
|
1919
1926
|
else if (result?.reason && result.reason !== 'nothing-owed'
|
|
1920
1927
|
&& result.reason !== 'no-op' && result.reason !== 'null-boundary') {
|
|
1921
1928
|
log(`[BOUNDARY] Pending fill crawls dropped (${result.reason})`, 'warn');
|
package/dist/modules/paths.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ declare const PATHS: {
|
|
|
109
109
|
FUND_REGISTRY_JSON: string;
|
|
110
110
|
NODE_BLACKLIST_JSON: string;
|
|
111
111
|
NODE_HEALTH_CACHE_JSON: string;
|
|
112
|
+
VERSION_CHECK_JSON: string;
|
|
112
113
|
MARKET_ADAPTER_WHITELIST_JSON: () => string;
|
|
113
114
|
ECOSYSTEM_CONFIG_JS: string;
|
|
114
115
|
SUPERVISOR_SOCK: string;
|
package/dist/modules/paths.js
CHANGED
|
@@ -309,6 +309,7 @@ const PATHS = {
|
|
|
309
309
|
FUND_REGISTRY_JSON: path.join(PROFILES_DIR, 'fund_registry.json'),
|
|
310
310
|
NODE_BLACKLIST_JSON: path.join(PROFILES_DIR, 'node_blacklist.json'),
|
|
311
311
|
NODE_HEALTH_CACHE_JSON: path.join(PROFILES_DIR, 'node_health_cache.json'),
|
|
312
|
+
VERSION_CHECK_JSON: path.join(PROFILES_DIR, 'version_check.json'),
|
|
312
313
|
MARKET_ADAPTER_WHITELIST_JSON: () => Config.DEXBOT_TEST_MARKET_ADAPTER_WHITELIST_FILE || path.join(PROFILES_DIR, 'market_adapter_whitelist.json'),
|
|
313
314
|
ECOSYSTEM_CONFIG_JS: path.join(PROFILES_DIR, 'ecosystem.config.cjs'),
|
|
314
315
|
SUPERVISOR_SOCK: path.join(PROFILES_DIR, 'supervisor.sock'),
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/version_notice.ts - Passive version status + "new version" notice.
|
|
3
|
+
*
|
|
4
|
+
* Reports the INSTALLED version against the published `latest` on every start
|
|
5
|
+
* and in `dexbot stat`, and prints a one-time hint when a newer DEXBot2 release
|
|
6
|
+
* exists — without ever changing code on its own. This is deliberately
|
|
7
|
+
* ORTHOGONAL to `UPDATER.ACTIVE` (the automated updater, default OFF): a bot
|
|
8
|
+
* handling real funds must never silently change its own code, but the
|
|
9
|
+
* operator still deserves to KNOW a fix or a breaking change landed. The
|
|
10
|
+
* opt-out lives in `UPDATER.NOTICE_ENABLED` so it can be tuned independently of
|
|
11
|
+
* the updater.
|
|
12
|
+
*
|
|
13
|
+
* ===============================================================================
|
|
14
|
+
* DESIGN CONSTRAINTS
|
|
15
|
+
* ===============================================================================
|
|
16
|
+
*
|
|
17
|
+
* 1. NEVER BLOCKS STARTUP. `startVersionStatusCheck()` returns a promise
|
|
18
|
+
* immediately and resolves with a `VersionStatus` (or null when the check is
|
|
19
|
+
* disabled). Callers start it early and `await` it late, so the round-trip
|
|
20
|
+
* overlaps work that is already happening (BitShares connection, password
|
|
21
|
+
* prompt).
|
|
22
|
+
* 2. NEVER THROWS. Every failure path — offline, DNS failure, slow registry,
|
|
23
|
+
* unreadable cache, browser — resolves to `null`.
|
|
24
|
+
* 3. NO SUBPROCESSES. The registry is queried with a single HTTPS GET and a
|
|
25
|
+
* hard timeout. `execSync('npm view ...')` (as used by `dexbot update`)
|
|
26
|
+
* costs 1-3s of spawn and hard-depends on the npm CLI, neither of which is
|
|
27
|
+
* acceptable on the launcher critical path.
|
|
28
|
+
* 4. THROTTLED + NOTIFY-ONCE. A check runs at most once per
|
|
29
|
+
* `UPDATER.NOTICE_INTERVAL_MS`, and the same version is announced only once
|
|
30
|
+
* (`notifiedVersion` in the cache) so an ignored notice does not nag on
|
|
31
|
+
* every restart. A new published version resets that latch. The latch is
|
|
32
|
+
* committed by `printVersionStatus` only AFTER the notice is displayed, so a
|
|
33
|
+
* launcher path that returns without printing cannot silently consume it —
|
|
34
|
+
* it is re-offered once the throttle window expires. A throttled run still
|
|
35
|
+
* reports a status (from the cached observation) so `dexbot stat` answers
|
|
36
|
+
* "am I current?" without spending a request.
|
|
37
|
+
* 4b. ONE IMPLEMENTATION. Every consumer (`unlock`, `pm2`, `dexbot stat`) goes
|
|
38
|
+
* through `startVersionStatusCheck` → `printVersionStatus`; the colour of the
|
|
39
|
+
* status line, the hint wording and the latch all live here, so no caller can
|
|
40
|
+
* drift from another.
|
|
41
|
+
* 5. SILENT WHEN DISABLED. `Config.DEXBOT_SKIP_VERSION_NOTICE=1` (tests, CI,
|
|
42
|
+
* automation) or `UPDATER.NOTICE_ENABLED: false` short-circuits before any
|
|
43
|
+
* network or filesystem work.
|
|
44
|
+
*
|
|
45
|
+
* Cache layout mirrors `modules/node_health_cache.ts` and lives in the profiles
|
|
46
|
+
* dir (never in the package dir — npm reinstalls wipe that).
|
|
47
|
+
*/
|
|
48
|
+
/** How the running copy was installed — selects the hint text. */
|
|
49
|
+
export type InstallKind = 'npm-global' | 'git' | 'other';
|
|
50
|
+
/**
|
|
51
|
+
* The pending one-time announcement: what the operator is told when a newer
|
|
52
|
+
* release exists and has not been displayed yet. It carries DATA only — the
|
|
53
|
+
* wording and colour are rendered by `printVersionStatus`, so there is exactly
|
|
54
|
+
* one place that decides how a version verdict looks.
|
|
55
|
+
*/
|
|
56
|
+
export interface VersionNotice {
|
|
57
|
+
currentVersion: string;
|
|
58
|
+
latestVersion: string;
|
|
59
|
+
installKind: InstallKind;
|
|
60
|
+
/** Cache file `printVersionStatus` advances once the notice is displayed.
|
|
61
|
+
* Internal plumbing; callers should not read it. */
|
|
62
|
+
cacheFile: string;
|
|
63
|
+
}
|
|
64
|
+
/** Green when current, orange when a newer release exists, gray when unknown. */
|
|
65
|
+
export type VersionState = 'up-to-date' | 'update-available' | 'unknown';
|
|
66
|
+
export interface VersionStatus {
|
|
67
|
+
/** Installed version — `Config.VERSION` unless overridden. */
|
|
68
|
+
currentVersion: string;
|
|
69
|
+
/** Latest version observed this run, or from the throttle cache. Null when
|
|
70
|
+
* the probe failed, which renders as `unknown`. */
|
|
71
|
+
latestVersion: string | null;
|
|
72
|
+
installKind: InstallKind;
|
|
73
|
+
state: VersionState;
|
|
74
|
+
/** Cache file backing the throttle. Plumbing; callers should not read it. */
|
|
75
|
+
cacheFile: string;
|
|
76
|
+
/** Present only when a NEWER version exists AND it has not been announced
|
|
77
|
+
* yet. Carries the one-time hint; `printVersionStatus` is the only path
|
|
78
|
+
* that latches it. */
|
|
79
|
+
notice: VersionNotice | null;
|
|
80
|
+
}
|
|
81
|
+
export interface VersionNoticeOptions {
|
|
82
|
+
/** Override the installed version (defaults to `Config.VERSION`). */
|
|
83
|
+
currentVersion?: string;
|
|
84
|
+
/** Override the cache location (tests). */
|
|
85
|
+
cacheFile?: string;
|
|
86
|
+
/** Override the throttle window in ms; `< 0` forces a check. */
|
|
87
|
+
intervalMs?: number;
|
|
88
|
+
/** Override the registry URL (tests). Pass '' to model an unconfigured setup. */
|
|
89
|
+
registryUrl?: string;
|
|
90
|
+
/** Override `UPDATER.NOTICE_ENABLED` (tests). */
|
|
91
|
+
enabled?: boolean;
|
|
92
|
+
/** Override install-kind detection (tests). */
|
|
93
|
+
installKind?: InstallKind;
|
|
94
|
+
/** Injectable fetch, for offline/hermetic tests. */
|
|
95
|
+
fetchImpl?: (url: string, init: any) => Promise<any>;
|
|
96
|
+
/** Injected clock (tests). */
|
|
97
|
+
now?: number;
|
|
98
|
+
/** Ignore the throttle window. */
|
|
99
|
+
force?: boolean;
|
|
100
|
+
/** Override the network timeout in ms (tests; a shorter `dexbot status`). */
|
|
101
|
+
timeoutMs?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Minimal semver comparison for `major.minor.patch` strings.
|
|
105
|
+
* Returns negative when a < b, 0 when equal, positive when a > b.
|
|
106
|
+
*
|
|
107
|
+
* Prerelease and build metadata are stripped: `1.6.7-beta.1` and `1.6.7`
|
|
108
|
+
* compare EQUAL. That is the intended reading for an update hint — a locally
|
|
109
|
+
* built prerelease is not "older" than the published release, and comparing it
|
|
110
|
+
* as `1.6.7.1 > 1.6.7` would permanently hide real updates from anyone
|
|
111
|
+
* running a source checkout. A non-numeric segment degrades to 0 rather than
|
|
112
|
+
* producing NaN ordering.
|
|
113
|
+
*/
|
|
114
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
115
|
+
/** Classify the running install without spawning anything. */
|
|
116
|
+
export declare function detectInstallKind(projectRoot?: string): InstallKind;
|
|
117
|
+
/**
|
|
118
|
+
* The single status line, shared by `dexbot stat` and every launcher start.
|
|
119
|
+
*
|
|
120
|
+
* GREEN when the install matches the registry, ORANGE when a newer release
|
|
121
|
+
* exists, GRAY when the probe could not answer (offline / throttled with no
|
|
122
|
+
* prior observation) — an unknown answer must never be rendered as "up to
|
|
123
|
+
* date". The installed version is always named, so a caller never needs a
|
|
124
|
+
* second "DEXBot2 vX.Y.Z" header of its own.
|
|
125
|
+
*/
|
|
126
|
+
export declare function formatVersionStatusLine(status: Pick<VersionStatus, 'currentVersion' | 'latestVersion' | 'state'>): string;
|
|
127
|
+
/**
|
|
128
|
+
* Start the check. Resolves with the installed-vs-published status, plus a
|
|
129
|
+
* `notice` when a NEWER version exists and that version has not been
|
|
130
|
+
* announced yet. Resolves null only when the whole feature is switched off.
|
|
131
|
+
* Rejects never.
|
|
132
|
+
*/
|
|
133
|
+
export declare function startVersionStatusCheck(options?: VersionNoticeOptions): Promise<VersionStatus | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Print the status line (plus the install hint when a NEW, unannounced
|
|
136
|
+
* version exists) and commit the notify-once latch for that hint. The single
|
|
137
|
+
* print path for every caller, so latching cannot drift from display.
|
|
138
|
+
*/
|
|
139
|
+
export declare function printVersionStatus(status: VersionStatus | null | undefined, options?: {
|
|
140
|
+
indent?: string;
|
|
141
|
+
surround?: boolean;
|
|
142
|
+
}): void;
|
|
143
|
+
/**
|
|
144
|
+
* Run the check and print the status/notice to stdout. Convenience wrapper
|
|
145
|
+
* for call sites with nothing to overlap (e.g. `dexbot status`). Returns the
|
|
146
|
+
* status that was printed, or null when the feature is switched off.
|
|
147
|
+
*/
|
|
148
|
+
export declare function maybePrintVersionStatus(options?: VersionNoticeOptions & {
|
|
149
|
+
indent?: string;
|
|
150
|
+
surround?: boolean;
|
|
151
|
+
}): Promise<VersionStatus | null>;
|
|
152
|
+
/**
|
|
153
|
+
* Await an already-started check and print its status. The single flush path
|
|
154
|
+
* for callers (`unlock.ts`, `pm2.ts`) that start the probe early and surface it
|
|
155
|
+
* only at a terminal point, so the await+print pair is not reimplemented per
|
|
156
|
+
* call site.
|
|
157
|
+
*/
|
|
158
|
+
export declare function flushVersionStatus(pending: Promise<VersionStatus | null>): Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* Print the status when the probe settles, WITHOUT awaiting it. For launch
|
|
161
|
+
* paths that must never delay the bot start — the resident process outlives the
|
|
162
|
+
* probe, so there is no `process.exit()` to truncate it.
|
|
163
|
+
*/
|
|
164
|
+
export declare function printVersionStatusWhenReady(pending: Promise<VersionStatus | null>): void;
|
|
165
|
+
//# sourceMappingURL=version_notice.d.ts.map
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* modules/version_notice.ts - Passive version status + "new version" notice.
|
|
3
|
+
*
|
|
4
|
+
* Reports the INSTALLED version against the published `latest` on every start
|
|
5
|
+
* and in `dexbot stat`, and prints a one-time hint when a newer DEXBot2 release
|
|
6
|
+
* exists — without ever changing code on its own. This is deliberately
|
|
7
|
+
* ORTHOGONAL to `UPDATER.ACTIVE` (the automated updater, default OFF): a bot
|
|
8
|
+
* handling real funds must never silently change its own code, but the
|
|
9
|
+
* operator still deserves to KNOW a fix or a breaking change landed. The
|
|
10
|
+
* opt-out lives in `UPDATER.NOTICE_ENABLED` so it can be tuned independently of
|
|
11
|
+
* the updater.
|
|
12
|
+
*
|
|
13
|
+
* ===============================================================================
|
|
14
|
+
* DESIGN CONSTRAINTS
|
|
15
|
+
* ===============================================================================
|
|
16
|
+
*
|
|
17
|
+
* 1. NEVER BLOCKS STARTUP. `startVersionStatusCheck()` returns a promise
|
|
18
|
+
* immediately and resolves with a `VersionStatus` (or null when the check is
|
|
19
|
+
* disabled). Callers start it early and `await` it late, so the round-trip
|
|
20
|
+
* overlaps work that is already happening (BitShares connection, password
|
|
21
|
+
* prompt).
|
|
22
|
+
* 2. NEVER THROWS. Every failure path — offline, DNS failure, slow registry,
|
|
23
|
+
* unreadable cache, browser — resolves to `null`.
|
|
24
|
+
* 3. NO SUBPROCESSES. The registry is queried with a single HTTPS GET and a
|
|
25
|
+
* hard timeout. `execSync('npm view ...')` (as used by `dexbot update`)
|
|
26
|
+
* costs 1-3s of spawn and hard-depends on the npm CLI, neither of which is
|
|
27
|
+
* acceptable on the launcher critical path.
|
|
28
|
+
* 4. THROTTLED + NOTIFY-ONCE. A check runs at most once per
|
|
29
|
+
* `UPDATER.NOTICE_INTERVAL_MS`, and the same version is announced only once
|
|
30
|
+
* (`notifiedVersion` in the cache) so an ignored notice does not nag on
|
|
31
|
+
* every restart. A new published version resets that latch. The latch is
|
|
32
|
+
* committed by `printVersionStatus` only AFTER the notice is displayed, so a
|
|
33
|
+
* launcher path that returns without printing cannot silently consume it —
|
|
34
|
+
* it is re-offered once the throttle window expires. A throttled run still
|
|
35
|
+
* reports a status (from the cached observation) so `dexbot stat` answers
|
|
36
|
+
* "am I current?" without spending a request.
|
|
37
|
+
* 4b. ONE IMPLEMENTATION. Every consumer (`unlock`, `pm2`, `dexbot stat`) goes
|
|
38
|
+
* through `startVersionStatusCheck` → `printVersionStatus`; the colour of the
|
|
39
|
+
* status line, the hint wording and the latch all live here, so no caller can
|
|
40
|
+
* drift from another.
|
|
41
|
+
* 5. SILENT WHEN DISABLED. `Config.DEXBOT_SKIP_VERSION_NOTICE=1` (tests, CI,
|
|
42
|
+
* automation) or `UPDATER.NOTICE_ENABLED: false` short-circuits before any
|
|
43
|
+
* network or filesystem work.
|
|
44
|
+
*
|
|
45
|
+
* Cache layout mirrors `modules/node_health_cache.ts` and lives in the profiles
|
|
46
|
+
* dir (never in the package dir — npm reinstalls wipe that).
|
|
47
|
+
*/
|
|
48
|
+
import { path } from './path_api.js';
|
|
49
|
+
import { UPDATER } from './constants.js';
|
|
50
|
+
import { PATHS, isGlobalNpmPackageDir } from './paths.js';
|
|
51
|
+
import { Config } from './config.js';
|
|
52
|
+
import { hasProcess } from './env.js';
|
|
53
|
+
import { getStorage } from './storage/index.js';
|
|
54
|
+
import { writeJsonFileAtomic } from './bots_file_lock.js';
|
|
55
|
+
import { CLI_COLORS } from './cli_colors.js';
|
|
56
|
+
const storage = getStorage();
|
|
57
|
+
const { readJSON } = storage;
|
|
58
|
+
const CACHE_VERSION = 1;
|
|
59
|
+
/** Matches UPDATER.NOTICE_TIMEOUT_MS default; kept local so a malformed
|
|
60
|
+
* general.settings.json can never turn the probe into an open-ended hang. */
|
|
61
|
+
const MAX_TIMEOUT_MS = 10_000;
|
|
62
|
+
/**
|
|
63
|
+
* Minimal semver comparison for `major.minor.patch` strings.
|
|
64
|
+
* Returns negative when a < b, 0 when equal, positive when a > b.
|
|
65
|
+
*
|
|
66
|
+
* Prerelease and build metadata are stripped: `1.6.7-beta.1` and `1.6.7`
|
|
67
|
+
* compare EQUAL. That is the intended reading for an update hint — a locally
|
|
68
|
+
* built prerelease is not "older" than the published release, and comparing it
|
|
69
|
+
* as `1.6.7.1 > 1.6.7` would permanently hide real updates from anyone
|
|
70
|
+
* running a source checkout. A non-numeric segment degrades to 0 rather than
|
|
71
|
+
* producing NaN ordering.
|
|
72
|
+
*/
|
|
73
|
+
export function compareVersions(a, b) {
|
|
74
|
+
const parse = (v) => String(v ?? '').trim().split(/[-+]/)[0].split('.').map((n) => parseInt(n, 10) || 0);
|
|
75
|
+
const na = parse(a);
|
|
76
|
+
const nb = parse(b);
|
|
77
|
+
const len = Math.max(na.length, nb.length);
|
|
78
|
+
for (let i = 0; i < len; i++) {
|
|
79
|
+
const va = na[i] ?? 0;
|
|
80
|
+
const vb = nb[i] ?? 0;
|
|
81
|
+
if (va !== vb)
|
|
82
|
+
return va < vb ? -1 : 1;
|
|
83
|
+
}
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
/** Classify the running install without spawning anything. */
|
|
87
|
+
export function detectInstallKind(projectRoot = PATHS.PROJECT_ROOT) {
|
|
88
|
+
if (isGlobalNpmPackageDir(projectRoot))
|
|
89
|
+
return 'npm-global';
|
|
90
|
+
try {
|
|
91
|
+
if (storage.exists(path.join(projectRoot, '.git')))
|
|
92
|
+
return 'git';
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
/* fall through to 'other' */
|
|
96
|
+
}
|
|
97
|
+
return 'other';
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The single status line, shared by `dexbot stat` and every launcher start.
|
|
101
|
+
*
|
|
102
|
+
* GREEN when the install matches the registry, ORANGE when a newer release
|
|
103
|
+
* exists, GRAY when the probe could not answer (offline / throttled with no
|
|
104
|
+
* prior observation) — an unknown answer must never be rendered as "up to
|
|
105
|
+
* date". The installed version is always named, so a caller never needs a
|
|
106
|
+
* second "DEXBot2 vX.Y.Z" header of its own.
|
|
107
|
+
*/
|
|
108
|
+
export function formatVersionStatusLine(status) {
|
|
109
|
+
const c = CLI_COLORS;
|
|
110
|
+
const current = `DEXBot2 v${status.currentVersion}`;
|
|
111
|
+
if (status.state === 'up-to-date') {
|
|
112
|
+
return `${current} ${c.brightGreen}✓${c.reset} ${c.greenBold}Your version is up to date.${c.reset}`;
|
|
113
|
+
}
|
|
114
|
+
if (status.state === 'update-available') {
|
|
115
|
+
return `${current} ${c.orange}⬆${c.reset} ${c.orange}A new version is available: v${status.latestVersion}.${c.reset}`;
|
|
116
|
+
}
|
|
117
|
+
return `${current} ${c.gray}? Could not check for a newer version.${c.reset}`;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Hint text. `dexbot update` is the correct verb for BOTH layouts: the npm
|
|
121
|
+
* flow does `npm install -g <pkg>@<latest>`, the git flow does
|
|
122
|
+
* `fetch` + `pull` + rebuild + runtime restart. `update` is only complete
|
|
123
|
+
* once active bots have been restarted onto the new code, which a bare
|
|
124
|
+
* `git pull` in a terminal would not do.
|
|
125
|
+
*/
|
|
126
|
+
function formatVersionHint(installKind) {
|
|
127
|
+
return installKind === 'git'
|
|
128
|
+
? `Run \`dexbot update\` to pull it and restart your bots.`
|
|
129
|
+
: `Run \`dexbot update\` to install it and restart your bots.`;
|
|
130
|
+
}
|
|
131
|
+
function readCache(file) {
|
|
132
|
+
try {
|
|
133
|
+
const payload = readJSON(file);
|
|
134
|
+
if (!payload || payload.version !== CACHE_VERSION)
|
|
135
|
+
return null;
|
|
136
|
+
if (!Number.isFinite(payload.lastCheckMs))
|
|
137
|
+
return null;
|
|
138
|
+
// Reject a foreign schema rather than trusting hand-edited types: a
|
|
139
|
+
// non-string version would otherwise flow into compareVersions.
|
|
140
|
+
if (payload.latestVersion != null && typeof payload.latestVersion !== 'string')
|
|
141
|
+
return null;
|
|
142
|
+
if (payload.notifiedVersion != null && typeof payload.notifiedVersion !== 'string')
|
|
143
|
+
return null;
|
|
144
|
+
return payload;
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function writeCache(file, cache) {
|
|
151
|
+
try {
|
|
152
|
+
writeJsonFileAtomic(file, cache);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
// A read-only or full profiles dir must never fail a startup.
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function resolveTimeoutMs(override) {
|
|
159
|
+
const raw = override !== undefined ? Number(override) : Number(UPDATER?.NOTICE_TIMEOUT_MS);
|
|
160
|
+
if (!Number.isFinite(raw) || raw <= 0)
|
|
161
|
+
return 2_000;
|
|
162
|
+
return Math.min(raw, MAX_TIMEOUT_MS);
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Fetch the published `latest` version. Returns null on ANY failure — an
|
|
166
|
+
* offline node, a proxy, a 404, a malformed body. Never throws.
|
|
167
|
+
*/
|
|
168
|
+
async function fetchLatestVersion(registryUrl, timeoutMs, fetchImpl) {
|
|
169
|
+
const doFetch = fetchImpl || (typeof fetch === 'function' ? fetch : null);
|
|
170
|
+
if (!doFetch)
|
|
171
|
+
return null;
|
|
172
|
+
const controller = typeof AbortController === 'function' ? new AbortController() : null;
|
|
173
|
+
// The attempt never rejects, so racing it cannot leak an unhandled
|
|
174
|
+
// rejection. The enclosing timeout is a HARD backstop: it resolves even
|
|
175
|
+
// when no AbortController exists or a custom fetch ignores the signal, so
|
|
176
|
+
// the "never blocks startup" guarantee does not depend on either. Without
|
|
177
|
+
// it, a hung registry socket could stall a terminal `flushVersionStatus`
|
|
178
|
+
// ahead of `process.exit()` and freeze `dexbot start`.
|
|
179
|
+
const attempt = (async () => {
|
|
180
|
+
try {
|
|
181
|
+
const res = await doFetch(registryUrl, {
|
|
182
|
+
method: 'GET',
|
|
183
|
+
headers: { accept: 'application/json' },
|
|
184
|
+
signal: controller?.signal,
|
|
185
|
+
});
|
|
186
|
+
if (!res || res.ok === false)
|
|
187
|
+
return null;
|
|
188
|
+
const body = await res.json();
|
|
189
|
+
const version = body?.version;
|
|
190
|
+
if (typeof version !== 'string' || !version.trim())
|
|
191
|
+
return null;
|
|
192
|
+
return version.trim();
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
})();
|
|
198
|
+
let timer = null;
|
|
199
|
+
const timeout = new Promise((resolve) => {
|
|
200
|
+
timer = setTimeout(() => {
|
|
201
|
+
try {
|
|
202
|
+
controller?.abort();
|
|
203
|
+
}
|
|
204
|
+
catch { /* best-effort cancel */ }
|
|
205
|
+
resolve(null);
|
|
206
|
+
}, timeoutMs);
|
|
207
|
+
});
|
|
208
|
+
try {
|
|
209
|
+
return await Promise.race([attempt, timeout]);
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
if (timer)
|
|
213
|
+
clearTimeout(timer);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Assemble a status; `includeNotice` is false on the throttled path, which
|
|
217
|
+
* reports the cached observation but never re-announces. */
|
|
218
|
+
function buildVersionStatus(currentVersion, latestVersion, installKind, cacheFile, includeNotice) {
|
|
219
|
+
const state = !latestVersion
|
|
220
|
+
? 'unknown'
|
|
221
|
+
: compareVersions(currentVersion, latestVersion) < 0 ? 'update-available' : 'up-to-date';
|
|
222
|
+
const notice = state === 'update-available' && includeNotice && latestVersion
|
|
223
|
+
? { currentVersion, latestVersion, installKind, cacheFile }
|
|
224
|
+
: null;
|
|
225
|
+
return { currentVersion, latestVersion, installKind, state, cacheFile, notice };
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Start the check. Resolves with the installed-vs-published status, plus a
|
|
229
|
+
* `notice` when a NEWER version exists and that version has not been
|
|
230
|
+
* announced yet. Resolves null only when the whole feature is switched off.
|
|
231
|
+
* Rejects never.
|
|
232
|
+
*/
|
|
233
|
+
export function startVersionStatusCheck(options = {}) {
|
|
234
|
+
// Every early return is a resolved null so callers can always await.
|
|
235
|
+
const done = (value) => Promise.resolve(value ?? null);
|
|
236
|
+
if (!hasProcess())
|
|
237
|
+
return done(null);
|
|
238
|
+
if (Config.DEXBOT_SKIP_VERSION_NOTICE)
|
|
239
|
+
return done(null);
|
|
240
|
+
const noticeEnabled = options.enabled ?? UPDATER?.NOTICE_ENABLED !== false;
|
|
241
|
+
if (!noticeEnabled)
|
|
242
|
+
return done(null);
|
|
243
|
+
const cacheFile = options.cacheFile || PATHS.PROFILES.VERSION_CHECK_JSON;
|
|
244
|
+
const now = options.now ?? Date.now();
|
|
245
|
+
const intervalMs = options.intervalMs ?? Number(UPDATER?.NOTICE_INTERVAL_MS ?? 0);
|
|
246
|
+
const previous = readCache(cacheFile);
|
|
247
|
+
// `??` (not `||`) so an explicitly empty current version is reported as
|
|
248
|
+
// "unknown" and stays silent rather than falling back to a real version.
|
|
249
|
+
const currentVersion = options.currentVersion ?? Config.VERSION;
|
|
250
|
+
if (!currentVersion)
|
|
251
|
+
return done(null);
|
|
252
|
+
// `!== undefined` (not `||`) so an explicit empty string models a
|
|
253
|
+
// deliberately unconfigured registry instead of falling back to UPDATER.
|
|
254
|
+
const registryUrl = options.registryUrl !== undefined ? options.registryUrl : UPDATER?.REGISTRY_URL;
|
|
255
|
+
if (!registryUrl) {
|
|
256
|
+
// No registry configured — do not even write a cache entry, so
|
|
257
|
+
// enabling it later takes effect on the very next start.
|
|
258
|
+
return done(null);
|
|
259
|
+
}
|
|
260
|
+
const installKind = options.installKind || detectInstallKind();
|
|
261
|
+
// Throttle: a recent probe (successful OR failed) means stay quiet, so an
|
|
262
|
+
// offline node never pays the timeout on every single restart. The cached
|
|
263
|
+
// observation still answers "am I current?" without spending a request.
|
|
264
|
+
if (!options.force && Number.isFinite(intervalMs) && intervalMs > 0 && previous) {
|
|
265
|
+
if (now - previous.lastCheckMs < intervalMs) {
|
|
266
|
+
return done(buildVersionStatus(currentVersion, previous.latestVersion, installKind, cacheFile, false));
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return (async () => {
|
|
270
|
+
const latestVersion = await fetchLatestVersion(registryUrl, resolveTimeoutMs(options.timeoutMs), options.fetchImpl);
|
|
271
|
+
// Record the observation but DO NOT latch here: `notifiedVersion` is
|
|
272
|
+
// advanced by `printVersionStatus` only once the hint is displayed.
|
|
273
|
+
const base = {
|
|
274
|
+
version: CACHE_VERSION,
|
|
275
|
+
updatedAt: new Date(now).toISOString(),
|
|
276
|
+
lastCheckMs: now,
|
|
277
|
+
latestVersion: latestVersion ?? null,
|
|
278
|
+
notifiedVersion: previous?.notifiedVersion ?? null,
|
|
279
|
+
};
|
|
280
|
+
writeCache(cacheFile, base);
|
|
281
|
+
const status = buildVersionStatus(currentVersion, latestVersion, installKind, cacheFile, true);
|
|
282
|
+
// Same version already announced: keep reporting the state, drop only
|
|
283
|
+
// the one-time hint.
|
|
284
|
+
if (status.notice && previous?.notifiedVersion === status.notice.latestVersion) {
|
|
285
|
+
return { ...status, notice: null };
|
|
286
|
+
}
|
|
287
|
+
return status;
|
|
288
|
+
})().catch(() => null);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Advance the notify-once latch for a notice that was actually displayed.
|
|
292
|
+
* Separate from the probe so a notice the caller never surfaces cannot be
|
|
293
|
+
* silently consumed — the next launcher run re-offers it. The latch only ever
|
|
294
|
+
* moves forward, so a registry that briefly serves an older `latest`
|
|
295
|
+
* (dist-tag rollback) cannot make an already-announced version reappear.
|
|
296
|
+
*/
|
|
297
|
+
function latchVersionNotice(notice) {
|
|
298
|
+
try {
|
|
299
|
+
const existing = readCache(notice.cacheFile);
|
|
300
|
+
const announced = existing?.notifiedVersion ?? null;
|
|
301
|
+
if (announced && compareVersions(announced, notice.latestVersion) >= 0)
|
|
302
|
+
return;
|
|
303
|
+
const next = {
|
|
304
|
+
version: CACHE_VERSION,
|
|
305
|
+
updatedAt: existing?.updatedAt ?? new Date().toISOString(),
|
|
306
|
+
lastCheckMs: existing?.lastCheckMs ?? 0,
|
|
307
|
+
latestVersion: existing?.latestVersion ?? notice.latestVersion,
|
|
308
|
+
notifiedVersion: notice.latestVersion,
|
|
309
|
+
};
|
|
310
|
+
writeCache(notice.cacheFile, next);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
// Best-effort: a read-only profiles dir must never fail a startup.
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Print the status line (plus the install hint when a NEW, unannounced
|
|
318
|
+
* version exists) and commit the notify-once latch for that hint. The single
|
|
319
|
+
* print path for every caller, so latching cannot drift from display.
|
|
320
|
+
*/
|
|
321
|
+
export function printVersionStatus(status, options = {}) {
|
|
322
|
+
if (!status)
|
|
323
|
+
return;
|
|
324
|
+
const c = CLI_COLORS;
|
|
325
|
+
const indent = options.indent ?? ' ';
|
|
326
|
+
const surround = options.surround !== false;
|
|
327
|
+
if (surround)
|
|
328
|
+
console.log();
|
|
329
|
+
console.log(`${indent}${formatVersionStatusLine(status)}`);
|
|
330
|
+
if (status.notice) {
|
|
331
|
+
console.log(`${indent} ${c.gray}${formatVersionHint(status.installKind)}${c.reset}`);
|
|
332
|
+
latchVersionNotice(status.notice);
|
|
333
|
+
}
|
|
334
|
+
if (surround)
|
|
335
|
+
console.log();
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Run the check and print the status/notice to stdout. Convenience wrapper
|
|
339
|
+
* for call sites with nothing to overlap (e.g. `dexbot status`). Returns the
|
|
340
|
+
* status that was printed, or null when the feature is switched off.
|
|
341
|
+
*/
|
|
342
|
+
export async function maybePrintVersionStatus(options = {}) {
|
|
343
|
+
const status = await startVersionStatusCheck(options);
|
|
344
|
+
printVersionStatus(status, { indent: options.indent, surround: options.surround });
|
|
345
|
+
return status;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Await an already-started check and print its status. The single flush path
|
|
349
|
+
* for callers (`unlock.ts`, `pm2.ts`) that start the probe early and surface it
|
|
350
|
+
* only at a terminal point, so the await+print pair is not reimplemented per
|
|
351
|
+
* call site.
|
|
352
|
+
*/
|
|
353
|
+
export async function flushVersionStatus(pending) {
|
|
354
|
+
printVersionStatus(await pending);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Print the status when the probe settles, WITHOUT awaiting it. For launch
|
|
358
|
+
* paths that must never delay the bot start — the resident process outlives the
|
|
359
|
+
* probe, so there is no `process.exit()` to truncate it.
|
|
360
|
+
*/
|
|
361
|
+
export function printVersionStatusWhenReady(pending) {
|
|
362
|
+
void pending.then(printVersionStatus, () => { });
|
|
363
|
+
}
|
|
364
|
+
//# sourceMappingURL=version_notice.js.map
|
package/dist/pm2.js
CHANGED
|
@@ -98,6 +98,7 @@ import * as readline from 'node:readline';
|
|
|
98
98
|
import { getErrorMessage } from './modules/utils/errors.js';
|
|
99
99
|
import { isSameBotName } from './modules/utils/sanitize_key.js';
|
|
100
100
|
import { muteChainLogs } from './modules/utils/chain_logs.js';
|
|
101
|
+
import { startVersionStatusCheck, printVersionStatus } from './modules/version_notice.js';
|
|
101
102
|
import { CLI_COLORS } from './modules/cli_colors.js';
|
|
102
103
|
import { getStorage } from './modules/storage/index.js';
|
|
103
104
|
import { usesAmaGridPrice } from './modules/dexbot_maintenance_runtime.js';
|
|
@@ -423,6 +424,13 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
423
424
|
}
|
|
424
425
|
console.log('='.repeat(50));
|
|
425
426
|
console.log();
|
|
427
|
+
// Start the passive version check immediately but do not await it: the
|
|
428
|
+
// BitShares connect in Step 0 (and the PM2 work below) takes seconds, which
|
|
429
|
+
// fully hides the registry round-trip. The installed-vs-published status is
|
|
430
|
+
// printed in the success block at the end, below the banner, so it can
|
|
431
|
+
// never be mistaken for part of the startup status. The promise never
|
|
432
|
+
// rejects.
|
|
433
|
+
const versionStatus = startVersionStatusCheck();
|
|
426
434
|
if (!clawOnly) {
|
|
427
435
|
// Step 0: Wait for BitShares connection. The native chain stack
|
|
428
436
|
// ([Transport]/[NodeManager]/[bitshares_client]) logs straight to
|
|
@@ -468,6 +476,7 @@ async function main({ botNameFilter = null, clawOnly = false, headless = false,
|
|
|
468
476
|
console.log('If dexbot-cred stops, rerun `dexbot pm2` to unlock it again.');
|
|
469
477
|
console.log('='.repeat(50));
|
|
470
478
|
console.log();
|
|
479
|
+
printVersionStatus(await versionStatus);
|
|
471
480
|
}
|
|
472
481
|
function startPM2Process(args, env = buildScopedChildEnv()) {
|
|
473
482
|
return new Promise((resolve, reject) => {
|