@vtxmacro/cli 2026.10.11 → 2026.10.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/bin/vtx.js CHANGED
@@ -113,7 +113,7 @@ var init_routing = __esm({
113
113
  var agent_cli_release_default;
114
114
  var init_agent_cli_release = __esm({
115
115
  "agent-cli-release.json"() {
116
- agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.11", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
116
+ agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.12", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
117
117
  }
118
118
  });
119
119
 
@@ -136,7 +136,10 @@ var init_runtime_policy_generated = __esm({
136
136
  jitter_milliseconds: 750,
137
137
  base_delay_milliseconds: 500,
138
138
  min_delay_milliseconds: 250,
139
- max_delay_milliseconds: 1e4
139
+ max_delay_milliseconds: 1e4,
140
+ recovery_base_delay_milliseconds: 1e3,
141
+ recovery_max_delay_milliseconds: 3e4,
142
+ recovery_exponent_max: 5
140
143
  },
141
144
  trade_refresh_policy: {
142
145
  server_config_stream_timeout_ms: 1e4,
@@ -144,11 +147,26 @@ var init_runtime_policy_generated = __esm({
144
147
  copy_trading_status_poll_ms: 5e3,
145
148
  post_execution_refresh_delay_ms: 3e3,
146
149
  account_read_backoff_min_ms: 2e3,
147
- account_read_backoff_max_ms: 6e4
150
+ account_read_backoff_max_ms: 6e4,
151
+ ai_start_grace_min_ms: 45e3
148
152
  },
149
153
  deployment_reload_observability: {
150
154
  bootstrap_max_error_events_per_page: 4,
151
155
  bootstrap_max_profiles: 10
156
+ },
157
+ ws_fallback_polling: {
158
+ screener_active_run_ms: 2500
159
+ },
160
+ deployment_reload: {
161
+ version_poll_interval_seconds: 30,
162
+ reload_delay_seconds: 5
163
+ },
164
+ profile_runtime_status: {
165
+ sync_timeout_ms: 8e3,
166
+ sync_concurrency: 3,
167
+ refresh_interval_ms: 1e4,
168
+ watchdog_interval_ms: 1e3,
169
+ watchdog_grace_ms: 500
152
170
  }
153
171
  },
154
172
  ai_dashboard: {
@@ -211,7 +229,12 @@ var init_runtime_policy_generated = __esm({
211
229
  idle_recheck_seconds: 60,
212
230
  attention_refresh_seconds: 60,
213
231
  evidence_max_items: 32,
214
- evidence_shared_read_seconds: 10
232
+ evidence_shared_read_seconds: 10,
233
+ retry_delay_seconds: 15
234
+ },
235
+ exchange_mutation: {
236
+ settlement_retry_milliseconds: 1e3,
237
+ settlement_retry_window_seconds: 120
215
238
  },
216
239
  protective_plan_set_lock: {
217
240
  wait_seconds: 120
@@ -234,7 +257,15 @@ var init_runtime_policy_generated = __esm({
234
257
  hyperliquid_snapshot: {
235
258
  max_fills_per_execution: 20,
236
259
  max_fill_payload_bytes: 32768
237
- }
260
+ },
261
+ loop_early_return_retry_milliseconds: 5e3,
262
+ window_handoff_cleanup_retry_milliseconds: 1e3,
263
+ ai_schedule_pause_min_milliseconds: 1e3,
264
+ ai_schedule_pause_max_milliseconds: 36e5,
265
+ ai_schedule_pause_unknown_milliseconds: 6e4,
266
+ provider_failure_diagnostics_delay_milliseconds: 2500,
267
+ provider_failure_diagnostics_max_age_milliseconds: 3e4,
268
+ killswitch_timer_floor_milliseconds: 1e3
238
269
  },
239
270
  server_runtime: {
240
271
  prompt_rescue: {
@@ -278,11 +309,55 @@ var init_runtime_policy_generated = __esm({
278
309
  restart_stable_uptime_ms: 6e4,
279
310
  restart_backoff_base_ms: 1e3,
280
311
  restart_backoff_max_ms: 3e4,
281
- restart_exponent_max: 5
312
+ restart_exponent_max: 5,
313
+ cooperative_stop_timeout_ms: 75e3,
314
+ update_readiness_timeout_ms: 6e5,
315
+ rollback_confirmation_min_attempts: 100,
316
+ ready_consecutive_observations: 2,
317
+ control_lock_wait_attempts: 400,
318
+ control_lock_retry_interval_ms: 250,
319
+ supervisor_manifest_poll_interval_ms: 250,
320
+ worker_readiness_settle_ms: 500
282
321
  },
283
322
  claim_diagnostics: {
284
323
  event_loop_sample_interval_ms: 100
285
- }
324
+ },
325
+ host_runtime: {
326
+ advertisement_ttl_ms: 12e4,
327
+ advertisement_refresh_lead_ms: 3e4,
328
+ host_heartbeat_interval_ms: 3e3,
329
+ attempt_heartbeat_interval_ms: 3e3,
330
+ agent_heartbeat_interval_ms: 3e3,
331
+ agent_heartbeat_max_retry_delay_ms: 9e3,
332
+ provider_rate_limit_refresh_ms: 6e4,
333
+ drain_timeout_ms: 3e4,
334
+ remote_retry_limit: 3,
335
+ minimum_sleep_ms: 10,
336
+ heartbeat_gap_diagnostic_min_ms: 1e4,
337
+ heartbeat_gap_diagnostic_factor: 3,
338
+ agent_auth_cooldown_ms: 3e5,
339
+ agent_rate_limit_cooldown_ms: 6e4,
340
+ agent_transient_cooldown_ms: 5e3,
341
+ claim_start_window_min_ms: 5e3,
342
+ attempt_start_retry_delay_max_ms: 15e3,
343
+ claim_dispatch_batch_size: 16,
344
+ codex_quota_cooldown_max_ms: 6912e5,
345
+ attempt_start_retry_base_ms: 1e3,
346
+ attempt_start_retry_exponent_max: 4,
347
+ remote_retry_backoff_step_ms: 250,
348
+ remote_retry_backoff_max_ms: 1e3,
349
+ remote_retry_fallback_ms: 1e3,
350
+ access_token_refresh_lead_ms: 5e3,
351
+ rate_limit_read_timeout_max_ms: 2e3,
352
+ agent_idle_retry_ms: 1e3,
353
+ agent_idle_poll_ms: 5e3,
354
+ agent_turn_timeout_ms: 6e5,
355
+ codex_rate_limit_metadata_timeout_ms: 5e3,
356
+ codex_login_timeout_ms: 9e5,
357
+ codex_command_timeout_ms: 3e4
358
+ },
359
+ quota_membership_cooldown_seconds: 300,
360
+ transient_membership_cooldown_seconds: 30
286
361
  },
287
362
  desktop: {
288
363
  runtime_watchdog: {
@@ -415,6 +490,44 @@ var init_runtime_policy_generated = __esm({
415
490
  benzinga: {
416
491
  enabled: false
417
492
  }
493
+ },
494
+ market_data: {
495
+ chart_interest: {
496
+ historical_backfill_candle_limit: 1e3
497
+ }
498
+ },
499
+ auth: {
500
+ tokens: {
501
+ email_2fa_code_length: 6,
502
+ totp_code_length: 6
503
+ }
504
+ },
505
+ websocket: {
506
+ client_connection: {
507
+ reconnect_delay_ms: 3e3,
508
+ ping_interval_ms: 3e4,
509
+ message_flush_interval_ms: 16,
510
+ price_change_highlight_ms: 1e3,
511
+ debug_recent_channel_limit: 24
512
+ }
513
+ },
514
+ notifications: {
515
+ desktop: {
516
+ heartbeat_seconds: 20
517
+ }
518
+ },
519
+ validation: {
520
+ profile_handles: {
521
+ min_length: 3,
522
+ max_length: 20,
523
+ update_confirmation_ms: 3e3
524
+ }
525
+ },
526
+ profiles: {
527
+ limits: {
528
+ handle_changes_per_window: 2,
529
+ handle_change_window_days: 14
530
+ }
418
531
  }
419
532
  };
420
533
  }
@@ -3775,6 +3888,43 @@ var init_updater = __esm({
3775
3888
  }
3776
3889
  });
3777
3890
 
3891
+ // lib/constants.ts
3892
+ var MS_PER_SECOND, SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, DAYS_PER_WEEK, MS_PER_MINUTE, BACKOFF_GROWTH_FACTOR, HTTP_STATUS, HTTP_STATUS_MIN, HTTP_STATUS_MAX, HTTP_CLIENT_ERROR_MIN, HTTP_SERVER_ERROR_MIN;
3893
+ var init_constants = __esm({
3894
+ "lib/constants.ts"() {
3895
+ "use strict";
3896
+ init_define_VTX_EXO_POLICY();
3897
+ init_define_VTX_GROK_POLICY();
3898
+ init_define_VTX_PI_MODEL_POLICY();
3899
+ MS_PER_SECOND = 1e3;
3900
+ SECONDS_PER_MINUTE = 60;
3901
+ MINUTES_PER_HOUR = 60;
3902
+ HOURS_PER_DAY = 24;
3903
+ DAYS_PER_WEEK = 7;
3904
+ MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
3905
+ BACKOFF_GROWTH_FACTOR = 2;
3906
+ HTTP_STATUS = {
3907
+ BAD_REQUEST: 400,
3908
+ UNAUTHORIZED: 401,
3909
+ PAYMENT_REQUIRED: 402,
3910
+ FORBIDDEN: 403,
3911
+ NOT_FOUND: 404,
3912
+ REQUEST_TIMEOUT: 408,
3913
+ CONFLICT: 409,
3914
+ TOO_EARLY: 425,
3915
+ TOO_MANY_REQUESTS: 429,
3916
+ INTERNAL_SERVER_ERROR: 500,
3917
+ BAD_GATEWAY: 502,
3918
+ SERVICE_UNAVAILABLE: 503,
3919
+ GATEWAY_TIMEOUT: 504
3920
+ };
3921
+ HTTP_STATUS_MIN = 100;
3922
+ HTTP_STATUS_MAX = 599;
3923
+ HTTP_CLIENT_ERROR_MIN = 400;
3924
+ HTTP_SERVER_ERROR_MIN = 500;
3925
+ }
3926
+ });
3927
+
3778
3928
  // node_modules/zod/v4/core/core.js
3779
3929
  // @__NO_SIDE_EFFECTS__
3780
3930
  function $constructor(name, initializer3, params) {
@@ -22121,7 +22271,10 @@ var init_runtime_policy_generated2 = __esm({
22121
22271
  jitter_milliseconds: 750,
22122
22272
  base_delay_milliseconds: 500,
22123
22273
  min_delay_milliseconds: 250,
22124
- max_delay_milliseconds: 1e4
22274
+ max_delay_milliseconds: 1e4,
22275
+ recovery_base_delay_milliseconds: 1e3,
22276
+ recovery_max_delay_milliseconds: 3e4,
22277
+ recovery_exponent_max: 5
22125
22278
  },
22126
22279
  trade_refresh_policy: {
22127
22280
  server_config_stream_timeout_ms: 1e4,
@@ -22129,11 +22282,26 @@ var init_runtime_policy_generated2 = __esm({
22129
22282
  copy_trading_status_poll_ms: 5e3,
22130
22283
  post_execution_refresh_delay_ms: 3e3,
22131
22284
  account_read_backoff_min_ms: 2e3,
22132
- account_read_backoff_max_ms: 6e4
22285
+ account_read_backoff_max_ms: 6e4,
22286
+ ai_start_grace_min_ms: 45e3
22133
22287
  },
22134
22288
  deployment_reload_observability: {
22135
22289
  bootstrap_max_error_events_per_page: 4,
22136
22290
  bootstrap_max_profiles: 10
22291
+ },
22292
+ ws_fallback_polling: {
22293
+ screener_active_run_ms: 2500
22294
+ },
22295
+ deployment_reload: {
22296
+ version_poll_interval_seconds: 30,
22297
+ reload_delay_seconds: 5
22298
+ },
22299
+ profile_runtime_status: {
22300
+ sync_timeout_ms: 8e3,
22301
+ sync_concurrency: 3,
22302
+ refresh_interval_ms: 1e4,
22303
+ watchdog_interval_ms: 1e3,
22304
+ watchdog_grace_ms: 500
22137
22305
  }
22138
22306
  },
22139
22307
  ai_dashboard: {
@@ -22196,7 +22364,12 @@ var init_runtime_policy_generated2 = __esm({
22196
22364
  idle_recheck_seconds: 60,
22197
22365
  attention_refresh_seconds: 60,
22198
22366
  evidence_max_items: 32,
22199
- evidence_shared_read_seconds: 10
22367
+ evidence_shared_read_seconds: 10,
22368
+ retry_delay_seconds: 15
22369
+ },
22370
+ exchange_mutation: {
22371
+ settlement_retry_milliseconds: 1e3,
22372
+ settlement_retry_window_seconds: 120
22200
22373
  },
22201
22374
  protective_plan_set_lock: {
22202
22375
  wait_seconds: 120
@@ -22219,7 +22392,15 @@ var init_runtime_policy_generated2 = __esm({
22219
22392
  hyperliquid_snapshot: {
22220
22393
  max_fills_per_execution: 20,
22221
22394
  max_fill_payload_bytes: 32768
22222
- }
22395
+ },
22396
+ loop_early_return_retry_milliseconds: 5e3,
22397
+ window_handoff_cleanup_retry_milliseconds: 1e3,
22398
+ ai_schedule_pause_min_milliseconds: 1e3,
22399
+ ai_schedule_pause_max_milliseconds: 36e5,
22400
+ ai_schedule_pause_unknown_milliseconds: 6e4,
22401
+ provider_failure_diagnostics_delay_milliseconds: 2500,
22402
+ provider_failure_diagnostics_max_age_milliseconds: 3e4,
22403
+ killswitch_timer_floor_milliseconds: 1e3
22223
22404
  },
22224
22405
  server_runtime: {
22225
22406
  prompt_rescue: {
@@ -22263,11 +22444,55 @@ var init_runtime_policy_generated2 = __esm({
22263
22444
  restart_stable_uptime_ms: 6e4,
22264
22445
  restart_backoff_base_ms: 1e3,
22265
22446
  restart_backoff_max_ms: 3e4,
22266
- restart_exponent_max: 5
22447
+ restart_exponent_max: 5,
22448
+ cooperative_stop_timeout_ms: 75e3,
22449
+ update_readiness_timeout_ms: 6e5,
22450
+ rollback_confirmation_min_attempts: 100,
22451
+ ready_consecutive_observations: 2,
22452
+ control_lock_wait_attempts: 400,
22453
+ control_lock_retry_interval_ms: 250,
22454
+ supervisor_manifest_poll_interval_ms: 250,
22455
+ worker_readiness_settle_ms: 500
22267
22456
  },
22268
22457
  claim_diagnostics: {
22269
22458
  event_loop_sample_interval_ms: 100
22270
- }
22459
+ },
22460
+ host_runtime: {
22461
+ advertisement_ttl_ms: 12e4,
22462
+ advertisement_refresh_lead_ms: 3e4,
22463
+ host_heartbeat_interval_ms: 3e3,
22464
+ attempt_heartbeat_interval_ms: 3e3,
22465
+ agent_heartbeat_interval_ms: 3e3,
22466
+ agent_heartbeat_max_retry_delay_ms: 9e3,
22467
+ provider_rate_limit_refresh_ms: 6e4,
22468
+ drain_timeout_ms: 3e4,
22469
+ remote_retry_limit: 3,
22470
+ minimum_sleep_ms: 10,
22471
+ heartbeat_gap_diagnostic_min_ms: 1e4,
22472
+ heartbeat_gap_diagnostic_factor: 3,
22473
+ agent_auth_cooldown_ms: 3e5,
22474
+ agent_rate_limit_cooldown_ms: 6e4,
22475
+ agent_transient_cooldown_ms: 5e3,
22476
+ claim_start_window_min_ms: 5e3,
22477
+ attempt_start_retry_delay_max_ms: 15e3,
22478
+ claim_dispatch_batch_size: 16,
22479
+ codex_quota_cooldown_max_ms: 6912e5,
22480
+ attempt_start_retry_base_ms: 1e3,
22481
+ attempt_start_retry_exponent_max: 4,
22482
+ remote_retry_backoff_step_ms: 250,
22483
+ remote_retry_backoff_max_ms: 1e3,
22484
+ remote_retry_fallback_ms: 1e3,
22485
+ access_token_refresh_lead_ms: 5e3,
22486
+ rate_limit_read_timeout_max_ms: 2e3,
22487
+ agent_idle_retry_ms: 1e3,
22488
+ agent_idle_poll_ms: 5e3,
22489
+ agent_turn_timeout_ms: 6e5,
22490
+ codex_rate_limit_metadata_timeout_ms: 5e3,
22491
+ codex_login_timeout_ms: 9e5,
22492
+ codex_command_timeout_ms: 3e4
22493
+ },
22494
+ quota_membership_cooldown_seconds: 300,
22495
+ transient_membership_cooldown_seconds: 30
22271
22496
  },
22272
22497
  desktop: {
22273
22498
  runtime_watchdog: {
@@ -22400,6 +22625,44 @@ var init_runtime_policy_generated2 = __esm({
22400
22625
  benzinga: {
22401
22626
  enabled: false
22402
22627
  }
22628
+ },
22629
+ market_data: {
22630
+ chart_interest: {
22631
+ historical_backfill_candle_limit: 1e3
22632
+ }
22633
+ },
22634
+ auth: {
22635
+ tokens: {
22636
+ email_2fa_code_length: 6,
22637
+ totp_code_length: 6
22638
+ }
22639
+ },
22640
+ websocket: {
22641
+ client_connection: {
22642
+ reconnect_delay_ms: 3e3,
22643
+ ping_interval_ms: 3e4,
22644
+ message_flush_interval_ms: 16,
22645
+ price_change_highlight_ms: 1e3,
22646
+ debug_recent_channel_limit: 24
22647
+ }
22648
+ },
22649
+ notifications: {
22650
+ desktop: {
22651
+ heartbeat_seconds: 20
22652
+ }
22653
+ },
22654
+ validation: {
22655
+ profile_handles: {
22656
+ min_length: 3,
22657
+ max_length: 20,
22658
+ update_confirmation_ms: 3e3
22659
+ }
22660
+ },
22661
+ profiles: {
22662
+ limits: {
22663
+ handle_changes_per_window: 2,
22664
+ handle_change_window_days: 14
22665
+ }
22403
22666
  }
22404
22667
  };
22405
22668
  }
@@ -30090,6 +30353,8 @@ var init_codex_app_server = __esm({
30090
30353
  init_define_VTX_EXO_POLICY();
30091
30354
  init_define_VTX_GROK_POLICY();
30092
30355
  init_define_VTX_PI_MODEL_POLICY();
30356
+ init_runtime_policy_generated();
30357
+ init_constants();
30093
30358
  init_config2();
30094
30359
  CODEX_INFERENCE_PERMISSION_PROFILE = "vtx_inference_readonly";
30095
30360
  CODEX_AGENT_PERMISSION_PROFILE = "vtx_inference_agent";
@@ -30195,9 +30460,9 @@ var init_codex_app_server = __esm({
30195
30460
  "workspace_owner_usage_limit_reached",
30196
30461
  "workspace_member_usage_limit_reached"
30197
30462
  ];
30198
- DEFAULT_CODEX_QUOTA_COOLDOWN_MS = 5 * 60 * 1e3;
30199
- MAX_CODEX_QUOTA_COOLDOWN_MS = 8 * 24 * 60 * 60 * 1e3;
30200
- CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS = 30 * 1e3;
30463
+ DEFAULT_CODEX_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.quota_membership_cooldown_seconds * MS_PER_SECOND;
30464
+ MAX_CODEX_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.host_runtime.codex_quota_cooldown_max_ms;
30465
+ CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS = runtime_policy_generated_default.external_inference.transient_membership_cooldown_seconds * MS_PER_SECOND;
30201
30466
  parseCreditsSnapshot = (value) => {
30202
30467
  const candidate = objectOrNull(value);
30203
30468
  if (!candidate || typeof candidate.hasCredits !== "boolean" || typeof candidate.unlimited !== "boolean" || candidate.balance != null && typeof candidate.balance !== "string") return null;
@@ -30242,7 +30507,7 @@ var init_codex_app_server = __esm({
30242
30507
  );
30243
30508
  for (const window2 of windows) {
30244
30509
  if (window2.resetsAt === null) continue;
30245
- const resetAtMs = window2.resetsAt * 1e3;
30510
+ const resetAtMs = window2.resetsAt * MS_PER_SECOND;
30246
30511
  if (!Number.isSafeInteger(resetAtMs)) continue;
30247
30512
  if (window2.usedPercent >= 100) exhaustedResets.push(resetAtMs);
30248
30513
  if (snapshot.rateLimitReachedType !== null || snapshot.spendControlReached === true) {
@@ -30371,8 +30636,8 @@ var init_codex_app_server = __esm({
30371
30636
  if (!(variant in structured)) continue;
30372
30637
  const details = objectOrNull(structured[variant]);
30373
30638
  const rawStatus = details?.httpStatusCode;
30374
- const httpStatusCode = Number.isSafeInteger(rawStatus) && Number(rawStatus) >= 100 && Number(rawStatus) <= 599 ? Number(rawStatus) : null;
30375
- if (httpStatusCode === 401) {
30639
+ const httpStatusCode = Number.isSafeInteger(rawStatus) && Number(rawStatus) >= HTTP_STATUS_MIN && Number(rawStatus) <= HTTP_STATUS_MAX ? Number(rawStatus) : null;
30640
+ if (httpStatusCode === HTTP_STATUS.UNAUTHORIZED) {
30376
30641
  return {
30377
30642
  code: "auth_expired",
30378
30643
  category: "auth",
@@ -30380,7 +30645,7 @@ var init_codex_app_server = __esm({
30380
30645
  httpStatusCode
30381
30646
  };
30382
30647
  }
30383
- if (httpStatusCode === 429) {
30648
+ if (httpStatusCode === HTTP_STATUS.TOO_MANY_REQUESTS) {
30384
30649
  return {
30385
30650
  code: "codex_rate_limited",
30386
30651
  category: "adapter",
@@ -30388,9 +30653,9 @@ var init_codex_app_server = __esm({
30388
30653
  httpStatusCode
30389
30654
  };
30390
30655
  }
30391
- if (httpStatusCode !== null && httpStatusCode >= 400 && httpStatusCode < 500 && httpStatusCode !== 408 && httpStatusCode !== 425) {
30656
+ if (httpStatusCode !== null && httpStatusCode >= HTTP_CLIENT_ERROR_MIN && httpStatusCode < HTTP_SERVER_ERROR_MIN && httpStatusCode !== HTTP_STATUS.REQUEST_TIMEOUT && httpStatusCode !== HTTP_STATUS.TOO_EARLY) {
30392
30657
  const semanticText = JSON.stringify(details || {}).toLowerCase();
30393
- if (httpStatusCode === 402 || /(quota|credit|spend|payment|subscription.*limit)/u.test(semanticText)) {
30658
+ if (httpStatusCode === HTTP_STATUS.PAYMENT_REQUIRED || /(quota|credit|spend|payment|subscription.*limit)/u.test(semanticText)) {
30394
30659
  return {
30395
30660
  code: "quota_exceeded",
30396
30661
  category: "model",
@@ -30398,7 +30663,7 @@ var init_codex_app_server = __esm({
30398
30663
  httpStatusCode
30399
30664
  };
30400
30665
  }
30401
- if (httpStatusCode === 403 && /(auth|account|workspace|billing|entitlement)/u.test(semanticText)) {
30666
+ if (httpStatusCode === HTTP_STATUS.FORBIDDEN && /(auth|account|workspace|billing|entitlement)/u.test(semanticText)) {
30402
30667
  return {
30403
30668
  code: "auth_expired",
30404
30669
  category: "auth",
@@ -30406,7 +30671,7 @@ var init_codex_app_server = __esm({
30406
30671
  httpStatusCode
30407
30672
  };
30408
30673
  }
30409
- if (httpStatusCode === 403 && /(policy|safety|cyber)/u.test(semanticText)) {
30674
+ if (httpStatusCode === HTTP_STATUS.FORBIDDEN && /(policy|safety|cyber)/u.test(semanticText)) {
30410
30675
  return {
30411
30676
  code: "codex_policy_rejected",
30412
30677
  category: "adapter",
@@ -30415,7 +30680,7 @@ var init_codex_app_server = __esm({
30415
30680
  };
30416
30681
  }
30417
30682
  return {
30418
- code: httpStatusCode === 400 ? "codex_bad_request" : "codex_http_client_error",
30683
+ code: httpStatusCode === HTTP_STATUS.BAD_REQUEST ? "codex_bad_request" : "codex_http_client_error",
30419
30684
  category: "adapter",
30420
30685
  retryable: false,
30421
30686
  httpStatusCode
@@ -30424,7 +30689,7 @@ var init_codex_app_server = __esm({
30424
30689
  return {
30425
30690
  code,
30426
30691
  category: "adapter",
30427
- retryable: httpStatusCode === null ? true : httpStatusCode === 408 || httpStatusCode === 425 || httpStatusCode >= 500,
30692
+ retryable: httpStatusCode === null ? true : httpStatusCode === HTTP_STATUS.REQUEST_TIMEOUT || httpStatusCode === HTTP_STATUS.TOO_EARLY || httpStatusCode >= HTTP_SERVER_ERROR_MIN,
30428
30693
  httpStatusCode
30429
30694
  };
30430
30695
  }
@@ -32221,13 +32486,13 @@ child.once('close', async (code, signal) => {
32221
32486
  const observedUsage = threadUsage ?? rawResponseUsage;
32222
32487
  let retryAtMs = null;
32223
32488
  let observedRateLimits = null;
32224
- if (failure2.code === "quota_exceeded" || failure2.httpStatusCode === 429) {
32489
+ if (failure2.code === "quota_exceeded" || failure2.httpStatusCode === HTTP_STATUS.TOO_MANY_REQUESTS) {
32225
32490
  const observedAtMs = Date.now();
32226
32491
  let accountLimitReached = failure2.code === "quota_exceeded";
32227
32492
  try {
32228
32493
  const metadataDeadlineAtMs = Math.min(
32229
32494
  request.deadlineAtMs,
32230
- observedAtMs + 5e3
32495
+ observedAtMs + runtime_policy_generated_default.external_inference.host_runtime.codex_rate_limit_metadata_timeout_ms
32231
32496
  );
32232
32497
  if (metadataDeadlineAtMs <= observedAtMs) throw new Error("rate-limit deadline elapsed");
32233
32498
  observedRateLimits = await this.readAccountRateLimits(
@@ -32930,13 +33195,15 @@ function createDefaultInferenceHostRunnerDependencies(options) {
32930
33195
  envelopePublicKey: options.envelopePublicKey
32931
33196
  };
32932
33197
  }
32933
- var import_ajv, providerHttpStatus, terminalFailureRequiresManualRecovery, canReplayFencedAgentTerminal, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, CLAIM_DISPATCH_BATCH_SIZE, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, usableProviderQuotaSnapshot, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
33198
+ var import_ajv, providerHttpStatus, terminalFailureRequiresManualRecovery, canReplayFencedAgentTerminal, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, HOST_RUNTIME_POLICY, CLAIM_DISPATCH_BATCH_SIZE, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_AUTH_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, usableProviderQuotaSnapshot, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
32934
33199
  var init_runner = __esm({
32935
33200
  "lib/inference-host/runner.ts"() {
32936
33201
  "use strict";
32937
33202
  init_define_VTX_EXO_POLICY();
32938
33203
  init_define_VTX_GROK_POLICY();
32939
33204
  init_define_VTX_PI_MODEL_POLICY();
33205
+ init_runtime_policy_generated();
33206
+ init_constants();
32940
33207
  import_ajv = __toESM(require_ajv(), 1);
32941
33208
  init_external_inference_contract();
32942
33209
  init_config2();
@@ -32950,29 +33217,30 @@ var init_runner = __esm({
32950
33217
  providerHttpStatus = (error48) => {
32951
33218
  if (!(error48 instanceof CodexAppServerError)) return null;
32952
33219
  const status = error48.httpStatusCode;
32953
- return typeof status === "number" && Number.isInteger(status) && status >= 400 && status <= 599 ? status : null;
33220
+ return typeof status === "number" && Number.isInteger(status) && status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_STATUS_MAX ? status : null;
32954
33221
  };
32955
33222
  terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null || error48.grokResponseIdentity != null) && !error48.retryable && error48.category !== "auth" && !["quota_exceeded", "codex_rate_limited", "provider_rate_limited"].includes(error48.code);
32956
33223
  canReplayFencedAgentTerminal = (state2, fence) => state2?.schema_version === "vtx_inference_agent_runtime_v3" && state2.adapter_id === fence.adapter_id && state2.host_id === fence.host_id && state2.assignment.assignment_id === fence.assignment_id && state2.pending_turn?.terminal_receipt?.terminal_status === "failed" && state2.pending_turn.terminal_receipt.failure_code === fence.failure_code && (fence.dispatch_outcome !== "outcome_unknown" || (state2.pending_turn.terminal_receipt.grok_tool_validation?.prior_dispatch === true || state2.pending_turn.terminal_receipt.grok_response_identity != null || state2.pending_turn.terminal_receipt.provider_http_status !== void 0) && state2.pending_turn.terminal_receipt.dispatch_outcome === "outcome_unknown");
32957
33224
  RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
32958
33225
  ATTEMPT_RECEIPT_SCHEMA_VERSION = "vtx_inference_attempt_receipt_v1";
32959
- CLAIM_DISPATCH_BATCH_SIZE = 16;
32960
- DEFAULT_ADVERTISEMENT_TTL_MS = 12e4;
32961
- DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS = 3e4;
32962
- DEFAULT_HOST_HEARTBEAT_MS = 3e3;
32963
- DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS = 6e4;
32964
- DEFAULT_ATTEMPT_HEARTBEAT_MS = 3e3;
32965
- DEFAULT_DRAIN_TIMEOUT_MS = 3e4;
32966
- DEFAULT_REMOTE_RETRY_LIMIT = 3;
32967
- MIN_SLEEP_MS = 10;
32968
- MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS = 1e4;
32969
- HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR = 3;
32970
- DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS = 5 * 60 * 1e3;
32971
- DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS = 6e4;
32972
- DEFAULT_AGENT_QUOTA_COOLDOWN_MS = 5 * 60 * 1e3;
32973
- DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS = 5e3;
32974
- MIN_CLAIM_START_WINDOW_MS = 5e3;
32975
- MAX_ATTEMPT_START_RETRY_DELAY_MS = 15e3;
33226
+ HOST_RUNTIME_POLICY = runtime_policy_generated_default.external_inference.host_runtime;
33227
+ CLAIM_DISPATCH_BATCH_SIZE = HOST_RUNTIME_POLICY.claim_dispatch_batch_size;
33228
+ DEFAULT_ADVERTISEMENT_TTL_MS = HOST_RUNTIME_POLICY.advertisement_ttl_ms;
33229
+ DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS = HOST_RUNTIME_POLICY.advertisement_refresh_lead_ms;
33230
+ DEFAULT_HOST_HEARTBEAT_MS = HOST_RUNTIME_POLICY.host_heartbeat_interval_ms;
33231
+ DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS = HOST_RUNTIME_POLICY.provider_rate_limit_refresh_ms;
33232
+ DEFAULT_ATTEMPT_HEARTBEAT_MS = HOST_RUNTIME_POLICY.attempt_heartbeat_interval_ms;
33233
+ DEFAULT_DRAIN_TIMEOUT_MS = HOST_RUNTIME_POLICY.drain_timeout_ms;
33234
+ DEFAULT_REMOTE_RETRY_LIMIT = HOST_RUNTIME_POLICY.remote_retry_limit;
33235
+ MIN_SLEEP_MS = HOST_RUNTIME_POLICY.minimum_sleep_ms;
33236
+ MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS = HOST_RUNTIME_POLICY.heartbeat_gap_diagnostic_min_ms;
33237
+ HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR = HOST_RUNTIME_POLICY.heartbeat_gap_diagnostic_factor;
33238
+ DEFAULT_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.quota_membership_cooldown_seconds * MS_PER_SECOND;
33239
+ DEFAULT_AGENT_AUTH_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_auth_cooldown_ms;
33240
+ DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_rate_limit_cooldown_ms;
33241
+ DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_transient_cooldown_ms;
33242
+ MIN_CLAIM_START_WINDOW_MS = HOST_RUNTIME_POLICY.claim_start_window_min_ms;
33243
+ MAX_ATTEMPT_START_RETRY_DELAY_MS = HOST_RUNTIME_POLICY.attempt_start_retry_delay_max_ms;
32976
33244
  UNBOUNDED_AVAILABLE_SLOTS = Number.MAX_SAFE_INTEGER;
32977
33245
  buildInferenceAdvertisedModels = (capabilities, adapterRuntimeVersion, adapter = "codex", structuredOutput = true, sameAttemptRecovery = adapter === "codex", supportedControlModes = ["provider"]) => {
32978
33246
  const visible = capabilities.filter((capability) => !capability.hidden);
@@ -33276,7 +33544,7 @@ var init_runner = __esm({
33276
33544
  providerWeeklyQuotaFromRateLimits = (rateLimits, observedAtMs, currentTimeMs = observedAtMs, includeCredits = true) => {
33277
33545
  if (!rateLimits) return null;
33278
33546
  for (const window2 of [rateLimits.rateLimits.primary, rateLimits.rateLimits.secondary]) {
33279
- if (window2?.windowDurationMins !== 7 * 24 * 60 || window2.resetsAt === null || window2.resetsAt * 1e3 <= currentTimeMs) continue;
33547
+ if (window2?.windowDurationMins !== DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR || window2.resetsAt === null || window2.resetsAt * MS_PER_SECOND <= currentTimeMs) continue;
33280
33548
  return {
33281
33549
  source: "codex_app_server",
33282
33550
  ...includeCredits ? {
@@ -33284,7 +33552,7 @@ var init_runner = __esm({
33284
33552
  rate_limit_reached: codexAccountRateLimitReached(rateLimits)
33285
33553
  } : {},
33286
33554
  used_percent: window2.usedPercent,
33287
- resets_at: isoAt(window2.resetsAt * 1e3),
33555
+ resets_at: isoAt(window2.resetsAt * MS_PER_SECOND),
33288
33556
  observed_at: isoAt(observedAtMs)
33289
33557
  };
33290
33558
  }
@@ -33294,7 +33562,7 @@ var init_runner = __esm({
33294
33562
  const window2 = rateLimits.rateLimits[key];
33295
33563
  const known = previous?.[key];
33296
33564
  if (known && (!window2 || window2.windowDurationMins !== known.windowDurationMins)) return false;
33297
- return window2 === null || window2.resetsAt !== null && window2.resetsAt * 1e3 > nowMs2 && (window2.usedPercent < 100 || codexCreditsAvailable(rateLimits.rateLimits));
33565
+ return window2 === null || window2.resetsAt !== null && window2.resetsAt * MS_PER_SECOND > nowMs2 && (window2.usedPercent < 100 || codexCreditsAvailable(rateLimits.rateLimits));
33298
33566
  });
33299
33567
  finitePositiveOption = (value, fallback, label2) => {
33300
33568
  const result = value ?? fallback;
@@ -33572,7 +33840,7 @@ var init_runner = __esm({
33572
33840
  };
33573
33841
  publicServerFailureCode = (value) => value !== null && /^[a-z0-9][a-z0-9._-]{0,95}$/u.test(value) ? value : null;
33574
33842
  attemptStartRetryFallbackMs = (retryCount) => Math.min(
33575
- 1e3 * 2 ** Math.min(Math.max(0, retryCount - 1), 4),
33843
+ HOST_RUNTIME_POLICY.attempt_start_retry_base_ms * BACKOFF_GROWTH_FACTOR ** Math.min(Math.max(0, retryCount - 1), HOST_RUNTIME_POLICY.attempt_start_retry_exponent_max),
33576
33844
  MAX_ATTEMPT_START_RETRY_DELAY_MS
33577
33845
  );
33578
33846
  exactJson2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
@@ -33831,7 +34099,7 @@ var init_runner = __esm({
33831
34099
  assertLocalCredentialIdentity(localState, refreshed.credential);
33832
34100
  credential = refreshed.credential;
33833
34101
  access7 = refreshed;
33834
- accessExpiresAt = now() + refreshed.expiresIn * 1e3;
34102
+ accessExpiresAt = now() + refreshed.expiresIn * MS_PER_SECOND;
33835
34103
  return refreshed.accessToken;
33836
34104
  })();
33837
34105
  try {
@@ -33843,7 +34111,7 @@ var init_runner = __esm({
33843
34111
  await refreshAccessToken({ signal: this.options.signal });
33844
34112
  const tokenSource = {
33845
34113
  accessToken: async (requestOptions) => {
33846
- if (!access7 || accessExpiresAt - now() <= 5e3) {
34114
+ if (!access7 || accessExpiresAt - now() <= HOST_RUNTIME_POLICY.access_token_refresh_lead_ms) {
33847
34115
  return refreshAccessToken(requestOptions);
33848
34116
  }
33849
34117
  return access7.accessToken;
@@ -33944,7 +34212,7 @@ var init_runner = __esm({
33944
34212
  const runtimeState = await readInferenceAgentRuntimeState(
33945
34213
  agentRuntimeSettings.statePath
33946
34214
  );
33947
- const retryAtMs = failure2.dispatchOutcome === "outcome_unknown" || failure2.category === "auth" && settings.adapterId === "deepseek-harness" ? null : error48.retryAtMs !== null && error48.retryAtMs > now() ? error48.retryAtMs : now() + (failure2.category === "quota" || failure2.code === "quota_exceeded" ? DEFAULT_AGENT_QUOTA_COOLDOWN_MS : failure2.category === "auth" ? DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS : failure2.code === "provider_rate_limited" || failure2.code === "codex_rate_limited" ? DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS : DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS);
34215
+ const retryAtMs = failure2.dispatchOutcome === "outcome_unknown" || failure2.category === "auth" && settings.adapterId === "deepseek-harness" ? null : error48.retryAtMs !== null && error48.retryAtMs > now() ? error48.retryAtMs : now() + (failure2.category === "quota" || failure2.code === "quota_exceeded" ? DEFAULT_QUOTA_COOLDOWN_MS : failure2.category === "auth" ? DEFAULT_AGENT_AUTH_COOLDOWN_MS : failure2.code === "provider_rate_limited" || failure2.code === "codex_rate_limited" ? DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS : DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS);
33948
34216
  await writeInferenceAgentFailureFence(agentRuntimeSettings.statePath, {
33949
34217
  schema_version: "vtx_inference_agent_failure_fence_v1",
33950
34218
  adapter_id: settings.adapterId,
@@ -33977,7 +34245,7 @@ var init_runner = __esm({
33977
34245
  const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
33978
34246
  const fence = await readInferenceAgentFailureFence(agentRuntimeSettings.statePath);
33979
34247
  if (!fence || !canReplayFencedAgentTerminal(retained, fence)) return;
33980
- await sleep4(1e3, agentIdleSignal).catch(() => void 0);
34248
+ await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch(() => void 0);
33981
34249
  continue;
33982
34250
  }
33983
34251
  try {
@@ -33997,7 +34265,7 @@ var init_runner = __esm({
33997
34265
  const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
33998
34266
  if (!retained || retained.schema_version !== "vtx_inference_agent_runtime_v3" || !retained.pending_turn?.terminal_receipt) return;
33999
34267
  if (this.options.once) return;
34000
- await sleep4(1e3, agentIdleSignal).catch((error49) => {
34268
+ await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
34001
34269
  if (!quiesceRequested) throw error49;
34002
34270
  });
34003
34271
  continue;
@@ -34011,7 +34279,7 @@ var init_runner = __esm({
34011
34279
  });
34012
34280
  if (this.options.once) return;
34013
34281
  try {
34014
- await sleep4(1e3, agentIdleSignal).catch((error49) => {
34282
+ await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
34015
34283
  if (!quiesceRequested) throw error49;
34016
34284
  });
34017
34285
  } catch {
@@ -34132,7 +34400,7 @@ var init_runner = __esm({
34132
34400
  if (!retryableRemoteError(error48) || error48 instanceof ExternalInferenceMcpError && error48.definitivelyNotApplied || attempt === settings.remoteRetryLimit) throw error48;
34133
34401
  const requestedRetryDelay = remoteRetryAfterMs(
34134
34402
  error48,
34135
- Math.min(250 * attempt, 1e3)
34403
+ Math.min(HOST_RUNTIME_POLICY.remote_retry_backoff_step_ms * attempt, HOST_RUNTIME_POLICY.remote_retry_backoff_max_ms)
34136
34404
  );
34137
34405
  const remaining = boundary.deadlineAtMs === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, boundary.deadlineAtMs - now());
34138
34406
  if (requestedRetryDelay < 1 || requestedRetryDelay >= remaining) {
@@ -34265,7 +34533,7 @@ var init_runner = __esm({
34265
34533
  if (!wasRegistered && receipt.registered && (!receipt.advertisement_expires_at || Date.parse(receipt.advertisement_expires_at) - now() <= settings.advertisementRefreshLeadMs)) {
34266
34534
  await publishAdvertisement("healthy", true);
34267
34535
  }
34268
- let providerRetryAtMs = this.options.codexRateLimits && codexAccountRateLimitReached(this.options.codexRateLimits) ? codexRateLimitRetryAtMs(this.options.codexRateLimits) ?? now() + DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS : null;
34536
+ let providerRetryAtMs = this.options.codexRateLimits && codexAccountRateLimitReached(this.options.codexRateLimits) ? codexRateLimitRetryAtMs(this.options.codexRateLimits) ?? now() + DEFAULT_QUOTA_COOLDOWN_MS : null;
34269
34537
  let providerCooldownReason = providerRetryAtMs === null ? null : "provider_limit_snapshot";
34270
34538
  let providerFailureRetryAtMs = 0;
34271
34539
  let providerFailureCooldownReason = null;
@@ -34932,7 +35200,7 @@ var init_runner = __esm({
34932
35200
  const refreshVersion = providerCooldownVersion;
34933
35201
  const refreshStartedAt = now();
34934
35202
  const refreshedRateLimits = await this.dependencies.codexAdapter.readAccountRateLimits(
34935
- Date.now() + Math.min(2e3, settings.hostHeartbeatMs),
35203
+ Date.now() + Math.min(HOST_RUNTIME_POLICY.rate_limit_read_timeout_max_ms, settings.hostHeartbeatMs),
34936
35204
  agentAbort.signal
34937
35205
  );
34938
35206
  if (agentAbort.signal.aborted || refreshVersion !== providerCooldownVersion) return;
@@ -34946,7 +35214,7 @@ var init_runner = __esm({
34946
35214
  );
34947
35215
  providerQuotaRecoveryObservedAtMs = usableSnapshot ? refreshStartedAt : null;
34948
35216
  retainKnownQuotaWindows(providerRateLimits.rateLimits);
34949
- const refreshedRetryAt = codexAccountRateLimitReached(providerRateLimits) ? codexRateLimitRetryAtMs(providerRateLimits) ?? refreshedAt + DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS : null;
35217
+ const refreshedRetryAt = codexAccountRateLimitReached(providerRateLimits) ? codexRateLimitRetryAtMs(providerRateLimits) ?? refreshedAt + DEFAULT_QUOTA_COOLDOWN_MS : null;
34950
35218
  if (refreshedRetryAt !== null && refreshedRetryAt > refreshedAt) {
34951
35219
  providerRetryAtMs = Math.max(providerRetryAtMs ?? 0, refreshedRetryAt);
34952
35220
  providerCooldownReason = "provider_limit_snapshot";
@@ -35009,7 +35277,7 @@ var init_runner = __esm({
35009
35277
  requestDrain("advertisement_failed");
35010
35278
  break;
35011
35279
  }
35012
- nextAdvertisementAttemptAt = now() + remoteRetryAfterMs(error48, 1e3);
35280
+ nextAdvertisementAttemptAt = now() + remoteRetryAfterMs(error48, HOST_RUNTIME_POLICY.remote_retry_fallback_ms);
35013
35281
  nextClaimAt = Math.max(nextClaimAt, nextAdvertisementAttemptAt);
35014
35282
  }
35015
35283
  }
@@ -35129,7 +35397,7 @@ var init_runner = __esm({
35129
35397
  }
35130
35398
  } else if (!this.options.signal?.aborted && retryableRemoteError(error48)) {
35131
35399
  const rejectedAtMs = now();
35132
- const retryAtMs = rejectedAtMs + remoteRetryAfterMs(error48, 1e3);
35400
+ const retryAtMs = rejectedAtMs + remoteRetryAfterMs(error48, HOST_RUNTIME_POLICY.remote_retry_fallback_ms);
35133
35401
  if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "host_not_claimable") {
35134
35402
  claimAvailabilityBackoff = { untilMs: retryAtMs, rejectedAtMs };
35135
35403
  } else {
@@ -36488,7 +36756,7 @@ var init_runner = __esm({
36488
36756
  );
36489
36757
  }
36490
36758
  state2 = await this.upgradeLegacyRuntimeState(recoveredState, signal);
36491
- if (!state2) return this.now() + (this.options.idlePollMs ?? 5e3);
36759
+ if (!state2) return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36492
36760
  } else if (recoveredState?.schema_version === "vtx_codex_agent_runtime_v2") {
36493
36761
  if (this.options.adapterId !== "codex") {
36494
36762
  throw new InferenceHostRunnerError(
@@ -36518,7 +36786,7 @@ var init_runner = __esm({
36518
36786
  host_id: this.options.hostId,
36519
36787
  requested_at: nowIso()
36520
36788
  }, { signal });
36521
- if (!assignment2) return this.now() + (this.options.idlePollMs ?? 5e3);
36789
+ if (!assignment2) return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36522
36790
  state2 = {
36523
36791
  schema_version: "vtx_inference_agent_runtime_v3",
36524
36792
  adapter_id: this.options.adapterId,
@@ -36535,11 +36803,11 @@ var init_runner = __esm({
36535
36803
  if (persistedWakeAtMs > this.now()) {
36536
36804
  const wakeOutcome = await this.waitUntilWake(persistedWakeAtMs, signal);
36537
36805
  if (wakeOutcome !== "ready") {
36538
- return this.now() + (this.options.idlePollMs ?? 5e3);
36806
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36539
36807
  }
36540
36808
  const rereadState = await readInferenceAgentRuntimeState(this.options.statePath);
36541
36809
  if (rereadState?.schema_version !== "vtx_inference_agent_runtime_v3" || rereadState.adapter_id !== this.options.adapterId) {
36542
- return this.now() + (this.options.idlePollMs ?? 5e3);
36810
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36543
36811
  }
36544
36812
  state2 = rereadState;
36545
36813
  }
@@ -36577,7 +36845,7 @@ var init_runner = __esm({
36577
36845
  );
36578
36846
  }
36579
36847
  await this.releaseForHostStop(terminal.terminal_receipt.failure_code ?? "provider_failure");
36580
- return this.now() + (this.options.idlePollMs ?? 5e3);
36848
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36581
36849
  }
36582
36850
  if (!terminal.next_wake_at) {
36583
36851
  throw new InferenceHostRunnerError(
@@ -36619,7 +36887,7 @@ var init_runner = __esm({
36619
36887
  }, { signal });
36620
36888
  if (preTurnHeartbeat.directive === "cancel") {
36621
36889
  await this.handleCancelledAssignment(state2, signal);
36622
- return this.now() + (this.options.idlePollMs ?? 5e3);
36890
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36623
36891
  }
36624
36892
  if (this.options.quiesceSignal?.aborted) return this.now();
36625
36893
  assignment = {
@@ -36650,7 +36918,7 @@ var init_runner = __esm({
36650
36918
  }
36651
36919
  latestLeaseExpiry = heartbeat.lease_expires_at;
36652
36920
  await this.sleep(
36653
- this.options.heartbeatIntervalMs ?? 3e3,
36921
+ this.options.heartbeatIntervalMs ?? HOST_RUNTIME_POLICY.agent_heartbeat_interval_ms,
36654
36922
  turnAbort.signal
36655
36923
  );
36656
36924
  }
@@ -36658,7 +36926,7 @@ var init_runner = __esm({
36658
36926
  if (!turnAbort.signal.aborted) turnAbort.abort(error48);
36659
36927
  });
36660
36928
  try {
36661
- const deadlineAtMs = this.now() + (this.options.turnTimeoutMs ?? 10 * 6e4);
36929
+ const deadlineAtMs = this.now() + (this.options.turnTimeoutMs ?? HOST_RUNTIME_POLICY.agent_turn_timeout_ms);
36662
36930
  const dataRequestTimeoutMs = this.options.dataRequestTimeoutMs ?? await loadInferenceAgentDataRequestTimeoutMs();
36663
36931
  if (!Number.isSafeInteger(dataRequestTimeoutMs) || dataRequestTimeoutMs < 1) {
36664
36932
  throw new InferenceHostRunnerError("invalid_configuration", "Agent data request timeout is invalid.");
@@ -36844,7 +37112,7 @@ var init_runner = __esm({
36844
37112
  let nextWakeAtMs = null;
36845
37113
  let wakeError;
36846
37114
  try {
36847
- nextWakeAtMs = wakeScheduledAtMs + parseInferenceAgentWake(result.turn.text, assignment) * 1e3;
37115
+ nextWakeAtMs = wakeScheduledAtMs + parseInferenceAgentWake(result.turn.text, assignment) * MS_PER_SECOND;
36848
37116
  } catch (error48) {
36849
37117
  wakeError = error48;
36850
37118
  }
@@ -36886,7 +37154,7 @@ var init_runner = __esm({
36886
37154
  await writeInferenceAgentRuntimeState(this.options.statePath, state2);
36887
37155
  await this.handleCancelledAssignment(state2);
36888
37156
  }
36889
- return this.now() + (this.options.idlePollMs ?? 5e3);
37157
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36890
37158
  }
36891
37159
  latestLeaseExpiry = wakeHeartbeat.lease_expires_at;
36892
37160
  state2 = {
@@ -36978,7 +37246,7 @@ var init_runner = __esm({
36978
37246
  }
36979
37247
  if (!cancelled) throw error48;
36980
37248
  await this.handleCancelledAssignment(state2);
36981
- return this.now() + (this.options.idlePollMs ?? 5e3);
37249
+ return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
36982
37250
  } finally {
36983
37251
  heartbeatStopped = true;
36984
37252
  turnAbort.abort();
@@ -37062,7 +37330,7 @@ var init_runner = __esm({
37062
37330
  await clearInferenceAgentRuntimeState(this.options.statePath);
37063
37331
  }
37064
37332
  async waitUntilWake(nextWakeAtMs, signal) {
37065
- const heartbeatIntervalMs = this.options.heartbeatIntervalMs ?? 3e3;
37333
+ const heartbeatIntervalMs = this.options.heartbeatIntervalMs ?? HOST_RUNTIME_POLICY.agent_heartbeat_interval_ms;
37066
37334
  while (!this.stopped && !signal?.aborted && !this.options.quiesceSignal?.aborted && this.now() < nextWakeAtMs) {
37067
37335
  const waitSignal = this.options.quiesceSignal ? AbortSignal.any([this.options.quiesceSignal, ...signal ? [signal] : []]) : signal;
37068
37336
  try {
@@ -44543,7 +44811,7 @@ import { createWriteStream, readFileSync as readFileSync2 } from "node:fs";
44543
44811
  import { access as access6, chmod as chmod4, mkdir as mkdir5, readFile as readFile12, rm as rm14, writeFile as writeFile5 } from "node:fs/promises";
44544
44812
  import { homedir as homedir4 } from "node:os";
44545
44813
  import { dirname as dirname15, join as join16, resolve as resolve12 } from "node:path";
44546
- var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_COOPERATIVE_STOP_SECONDS, SERVICE_UPDATE_STARTUP_SECONDS, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
44814
+ var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
44547
44815
  var init_service = __esm({
44548
44816
  "lib/inference-host/service.ts"() {
44549
44817
  "use strict";
@@ -44553,13 +44821,15 @@ var init_service = __esm({
44553
44821
  init_service_launcher_state();
44554
44822
  init_agent_cli_release();
44555
44823
  init_runtime_policy_generated();
44824
+ init_constants();
44556
44825
  init_durable_adapter();
44557
44826
  init_config2();
44558
44827
  SERVICE_NAME = "VTX Macro Inference Host";
44559
44828
  SYSTEMD_UNIT = "vtx-inference-host.service";
44560
44829
  LAUNCHD_LABEL = "com.vtxmacro.inference-host";
44561
- SERVICE_COOPERATIVE_STOP_SECONDS = 75;
44562
- SERVICE_UPDATE_STARTUP_SECONDS = 600;
44830
+ SERVICE_POLICY = runtime_policy_generated_default.external_inference.service;
44831
+ SERVICE_COOPERATIVE_STOP_SECONDS = Math.ceil(SERVICE_POLICY.cooperative_stop_timeout_ms / MS_PER_SECOND);
44832
+ pollAttemptsWithin = (milliseconds) => Math.ceil(milliseconds / SERVICE_POLICY.startup_poll_interval_ms);
44563
44833
  INFERENCE_HOST_SERVICE_DRAIN_COMMAND = "vtx-inference-host-service-drain-v1";
44564
44834
  INFERENCE_HOST_SERVICE_QUIESCE_COMMAND = "vtx-inference-host-service-quiesce-v1";
44565
44835
  InferenceHostBootstrapRestartRequiredError = class extends Error {
@@ -44980,9 +45250,9 @@ WantedBy=default.target
44980
45250
  this.sleep = dependencies.sleep ?? (async (milliseconds) => {
44981
45251
  await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
44982
45252
  });
44983
- this.stopWaitAttempts = dependencies.stopWaitAttempts ?? SERVICE_COOPERATIVE_STOP_SECONDS * 4;
44984
- this.startWaitAttempts = dependencies.startWaitAttempts ?? runtime_policy_generated_default.external_inference.service.startup_max_attempts;
44985
- this.reconcileWaitAttempts = dependencies.reconcileWaitAttempts ?? SERVICE_COOPERATIVE_STOP_SECONDS * 4;
45253
+ this.stopWaitAttempts = dependencies.stopWaitAttempts ?? pollAttemptsWithin(SERVICE_POLICY.cooperative_stop_timeout_ms);
45254
+ this.startWaitAttempts = dependencies.startWaitAttempts ?? SERVICE_POLICY.startup_max_attempts;
45255
+ this.reconcileWaitAttempts = dependencies.reconcileWaitAttempts ?? pollAttemptsWithin(SERVICE_POLICY.cooperative_stop_timeout_ms);
44986
45256
  this.confirmInitialReadiness = dependencies.confirmInitialReadiness ?? true;
44987
45257
  this.acquireProcessLock = dependencies.acquireProcessLock ?? acquireInferenceHostProcessLock;
44988
45258
  managerName(this.platform);
@@ -45024,17 +45294,17 @@ WantedBy=default.target
45024
45294
  }
45025
45295
  async withControlLock(operation) {
45026
45296
  let lock2 = null;
45027
- for (let attempt = 0; attempt < 400; attempt += 1) {
45297
+ for (let attempt = 0; attempt < SERVICE_POLICY.control_lock_wait_attempts; attempt += 1) {
45028
45298
  try {
45029
45299
  lock2 = await this.acquireProcessLock(this.controlLockPath());
45030
45300
  break;
45031
45301
  } catch (error48) {
45032
45302
  if (!/already owns/iu.test(error48 instanceof Error ? error48.message : "")) throw error48;
45033
- await this.sleep(250);
45303
+ await this.sleep(SERVICE_POLICY.control_lock_retry_interval_ms);
45034
45304
  }
45035
45305
  }
45036
45306
  if (!lock2) {
45037
- throw new Error("Another inference-host service control operation did not finish within 100 seconds.");
45307
+ throw new Error(`Another inference-host service control operation did not finish within ${SERVICE_POLICY.control_lock_wait_attempts * SERVICE_POLICY.control_lock_retry_interval_ms / MS_PER_SECOND} seconds.`);
45038
45308
  }
45039
45309
  try {
45040
45310
  return await operation();
@@ -45112,9 +45382,9 @@ WantedBy=default.target
45112
45382
  for (let attempt = 0; attempt < this.startWaitAttempts; attempt += 1) {
45113
45383
  const status = await this.status();
45114
45384
  if (status.manager_active) return status;
45115
- await this.sleep(runtime_policy_generated_default.external_inference.service.startup_poll_interval_ms);
45385
+ await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
45116
45386
  }
45117
- throw new Error(`Background service did not reach an active state within ${this.startWaitAttempts * runtime_policy_generated_default.external_inference.service.startup_poll_interval_ms / 1e3} seconds.`);
45387
+ throw new Error(`Background service did not reach an active state within ${this.startWaitAttempts * SERVICE_POLICY.startup_poll_interval_ms / MS_PER_SECOND} seconds.`);
45118
45388
  }
45119
45389
  async restoreRunningSupervisor(manifest, preserveGeneration = false, targetInstanceName) {
45120
45390
  const previousRuntime = await readRuntimeAcrossAtomicReplacement(this.runtimePath()).catch(() => null);
@@ -45176,7 +45446,7 @@ ${result.stderr}`)) {
45176
45446
  const allReady = runtime.workers.every((worker) => worker.state === "running");
45177
45447
  if (exactWorkerSet && (targetInstanceName ? target?.state === "running" : allReady)) {
45178
45448
  consecutiveReadyObservations += 1;
45179
- if (consecutiveReadyObservations >= 2) return runtime;
45449
+ if (consecutiveReadyObservations >= SERVICE_POLICY.ready_consecutive_observations) return runtime;
45180
45450
  } else {
45181
45451
  consecutiveReadyObservations = 0;
45182
45452
  }
@@ -45189,7 +45459,7 @@ ${result.stderr}`)) {
45189
45459
  if (runtime?.rejected_manifest_generation === manifest.generation) {
45190
45460
  throw new Error("Inference-host supervisor rejected the updated worker set.");
45191
45461
  }
45192
- await this.sleep(250);
45462
+ await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
45193
45463
  }
45194
45464
  throw new Error(
45195
45465
  targetInstanceName ? `Inference-host supervisor did not confirm worker ${targetInstanceName} ready before timeout.` : "Inference-host supervisor did not confirm the updated worker set before timeout."
@@ -45257,7 +45527,7 @@ ${started.stderr}`)) {
45257
45527
  await this.waitForManifestApplied(
45258
45528
  manifest,
45259
45529
  targetInstanceName,
45260
- Math.max(this.reconcileWaitAttempts, SERVICE_UPDATE_STARTUP_SECONDS * 4)
45530
+ Math.max(this.reconcileWaitAttempts, pollAttemptsWithin(SERVICE_POLICY.update_readiness_timeout_ms))
45261
45531
  );
45262
45532
  }
45263
45533
  }
@@ -45331,7 +45601,7 @@ ${cleanup.stderr}`)) {
45331
45601
  // restores the previous manifest. Never give rollback less than
45332
45602
  // a bounded 100-observation confirmation window, even when a
45333
45603
  // caller intentionally shortens forward-readiness checks.
45334
- Math.max(this.reconcileWaitAttempts, 100)
45604
+ Math.max(this.reconcileWaitAttempts, SERVICE_POLICY.rollback_confirmation_min_attempts)
45335
45605
  );
45336
45606
  } catch (rollbackError) {
45337
45607
  throw new Error(
@@ -45571,7 +45841,7 @@ ${result.stderr}`)) {
45571
45841
  serviceReleased = true;
45572
45842
  break;
45573
45843
  }
45574
- await this.sleep(250);
45844
+ await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
45575
45845
  }
45576
45846
  if (!serviceReleased) {
45577
45847
  throw new Error(
@@ -45796,7 +46066,7 @@ ${result.stderr}`)) {
45796
46066
  cooperativeStopTimer = setTimeout(() => {
45797
46067
  cooperativeStopTimedOut = true;
45798
46068
  child.kill("SIGKILL");
45799
- }, SERVICE_COOPERATIVE_STOP_SECONDS * 1e3);
46069
+ }, SERVICE_POLICY.cooperative_stop_timeout_ms);
45800
46070
  cooperativeStopTimer.unref();
45801
46071
  };
45802
46072
  if (signal.aborted) onAbort();
@@ -45977,7 +46247,7 @@ ${result.stderr}`)) {
45977
46247
  if (readinessSignalled) return;
45978
46248
  readinessSignalled = true;
45979
46249
  readinessTask = (async () => {
45980
- await sleep4(500);
46250
+ await sleep4(SERVICE_POLICY.worker_readiness_settle_ms);
45981
46251
  if (!launchSettled && !attemptController.signal.aborted && !record5.controller.signal.aborted && !signal.aborted) {
45982
46252
  await updateRecord(record5, "running");
45983
46253
  }
@@ -46000,8 +46270,8 @@ ${result.stderr}`)) {
46000
46270
  throw new Error("worker_cooperative_stop_timeout");
46001
46271
  }
46002
46272
  if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted || !await readDesiredAcrossAtomicReplacement(desiredPath)) break;
46003
- failures = result.uptimeMs >= runtime_policy_generated_default.external_inference.service.restart_stable_uptime_ms ? 0 : failures + 1;
46004
- const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
46273
+ failures = result.uptimeMs >= SERVICE_POLICY.restart_stable_uptime_ms ? 0 : failures + 1;
46274
+ const retryAfterMs = Math.min(SERVICE_POLICY.restart_backoff_base_ms * BACKOFF_GROWTH_FACTOR ** Math.min(failures, SERVICE_POLICY.restart_exponent_max), SERVICE_POLICY.restart_backoff_max_ms);
46005
46275
  await updateRecord(record5, "failed", "worker_exited");
46006
46276
  await appendServiceLog(serviceManifest.log_path, "worker_exited", {
46007
46277
  instance_name: record5.worker.instance_name,
@@ -46015,7 +46285,7 @@ ${result.stderr}`)) {
46015
46285
  if (error48 instanceof Error && error48.message === "worker_cooperative_stop_timeout") throw error48;
46016
46286
  if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted) break;
46017
46287
  failures += 1;
46018
- const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
46288
+ const retryAfterMs = Math.min(SERVICE_POLICY.restart_backoff_base_ms * BACKOFF_GROWTH_FACTOR ** Math.min(failures, SERVICE_POLICY.restart_exponent_max), SERVICE_POLICY.restart_backoff_max_ms);
46019
46289
  await updateRecord(record5, "failed", "worker_launch_failed");
46020
46290
  await appendServiceLog(serviceManifest.log_path, "worker_launch_failed", {
46021
46291
  instance_name: record5.worker.instance_name,
@@ -46111,7 +46381,7 @@ ${result.stderr}`)) {
46111
46381
  if (!storedNext) throw new Error("Inference-host service manifest is missing.");
46112
46382
  const next = withServiceScript(storedNext);
46113
46383
  if (next.generation !== appliedManifest.generation && next.generation !== rejectedManifestGeneration) await reconcile(next);
46114
- await sleep4(250);
46384
+ await sleep4(SERVICE_POLICY.supervisor_manifest_poll_interval_ms);
46115
46385
  }
46116
46386
  if (quiesceSignal.aborted && !signal.aborted) {
46117
46387
  let finished = false;
@@ -46120,7 +46390,7 @@ ${result.stderr}`)) {
46120
46390
  return results;
46121
46391
  });
46122
46392
  while (!finished && !signal.aborted && await readDesiredAcrossAtomicReplacement(desiredPath)) {
46123
- await Promise.race([completion, sleep4(250)]);
46393
+ await Promise.race([completion, sleep4(SERVICE_POLICY.supervisor_manifest_poll_interval_ms)]);
46124
46394
  }
46125
46395
  if (!finished) {
46126
46396
  await drainWorkers();
@@ -46340,6 +46610,8 @@ var init_cli = __esm({
46340
46610
  init_define_VTX_EXO_POLICY();
46341
46611
  init_define_VTX_GROK_POLICY();
46342
46612
  init_define_VTX_PI_MODEL_POLICY();
46613
+ init_runtime_policy_generated();
46614
+ init_constants();
46343
46615
  init_external_inference_contract();
46344
46616
  init_agent_cli_release();
46345
46617
  init_reauthorize();
@@ -46377,8 +46649,8 @@ var init_cli = __esm({
46377
46649
  foregroundHostLockPath = (config2) => `${config2.processLockPath}.foreground`;
46378
46650
  credentialLifecycleLockPath = (config2) => `${inferenceHostCredentialContextPath(config2)}.lock`;
46379
46651
  serviceRecoveryCommandLockPath = (config2) => `${config2.supervisorProcessLockPath}.service-recovery-command`;
46380
- AGENT_HEARTBEAT_INTERVAL_MS = 3e3;
46381
- AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS = 9e3;
46652
+ AGENT_HEARTBEAT_INTERVAL_MS = runtime_policy_generated_default.external_inference.host_runtime.agent_heartbeat_interval_ms;
46653
+ AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS = runtime_policy_generated_default.external_inference.host_runtime.agent_heartbeat_max_retry_delay_ms;
46382
46654
  retryableAgentHeartbeatError = (error48) => {
46383
46655
  if (!(error48 instanceof ExternalInferenceMcpError)) return false;
46384
46656
  if (error48.code === "network_error" || error48.code === "request_timeout") return true;
@@ -47244,7 +47516,7 @@ Waiting for approval...
47244
47516
  const status = await (dependencies.loginCodex ?? loginCodexSubscription)({
47245
47517
  binary,
47246
47518
  codexHome: config2.codexHomePath,
47247
- deadlineAtMs: Date.now() + 15 * 6e4,
47519
+ deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_login_timeout_ms,
47248
47520
  signal: cancellation.signal,
47249
47521
  onChallenge: async (challenge) => {
47250
47522
  emitStdout(parsed.json ? `${JSON.stringify({
@@ -47294,7 +47566,7 @@ Waiting for approval...
47294
47566
  await (dependencies.logoutCodex ?? logoutCodexSubscription)({
47295
47567
  binary,
47296
47568
  codexHome: config2.codexHomePath,
47297
- deadlineAtMs: Date.now() + 3e4,
47569
+ deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms,
47298
47570
  signal: cancellation.signal
47299
47571
  });
47300
47572
  return {
@@ -47941,7 +48213,7 @@ Waiting for approval...
47941
48213
  const preflight = await (dependencies.preflightCodex ?? preflightCodexSubscription)({
47942
48214
  binary: verifiedBinary,
47943
48215
  codexHome: config2.codexHomePath,
47944
- deadlineAtMs: Date.now() + 3e4,
48216
+ deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms,
47945
48217
  signal: cancellation.signal
47946
48218
  });
47947
48219
  const summary = await (dependencies.runForeground ?? defaultRunForeground)({
@@ -48129,7 +48401,7 @@ Waiting for approval...
48129
48401
  const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
48130
48402
  await new Promise((resolve14) => setTimeout(resolve14, milliseconds));
48131
48403
  });
48132
- const stopAt = now().getTime() + parsed.waitSeconds * 1e3;
48404
+ const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
48133
48405
  while (true) {
48134
48406
  const result = await withAgentCommandLock(config2, async () => {
48135
48407
  let state2 = await readInferenceForegroundAgentControlState(config2.statePath) ?? foregroundAgentControlState(session.localState.host_id, now().toISOString());
@@ -48655,7 +48927,7 @@ Waiting for approval...
48655
48927
  pendingHeartbeatRequest = heartbeatRequest;
48656
48928
  consecutiveHeartbeatFailures += 1;
48657
48929
  retryDelayMs = Math.min(
48658
- AGENT_HEARTBEAT_INTERVAL_MS * 2 ** Math.max(0, consecutiveHeartbeatFailures - 1),
48930
+ AGENT_HEARTBEAT_INTERVAL_MS * BACKOFF_GROWTH_FACTOR ** Math.max(0, consecutiveHeartbeatFailures - 1),
48659
48931
  AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS
48660
48932
  );
48661
48933
  const message = `Agent-driven inference heartbeat was temporarily unavailable; retrying in ${retryDelayMs}ms.
@@ -48712,7 +48984,7 @@ Waiting for approval...
48712
48984
  if (!retryableAgentHeartbeatError(error48)) throw error48;
48713
48985
  consecutiveHeartbeatFailures += 1;
48714
48986
  retryDelayMs = Math.min(
48715
- AGENT_HEARTBEAT_INTERVAL_MS * 2 ** Math.max(0, consecutiveHeartbeatFailures - 1),
48987
+ AGENT_HEARTBEAT_INTERVAL_MS * BACKOFF_GROWTH_FACTOR ** Math.max(0, consecutiveHeartbeatFailures - 1),
48716
48988
  AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS
48717
48989
  );
48718
48990
  emitStderr(parsed.json ? `${JSON.stringify({
@@ -48761,7 +49033,7 @@ Waiting for approval...
48761
49033
  const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
48762
49034
  await new Promise((resolve14) => setTimeout(resolve14, milliseconds));
48763
49035
  });
48764
- const stopAt = now().getTime() + parsed.waitSeconds * 1e3;
49036
+ const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
48765
49037
  while (true) {
48766
49038
  let pending3 = await readInferenceAgentNextState(config2.statePath);
48767
49039
  if (!pending3) {
@@ -49468,7 +49740,7 @@ Waiting for approval...
49468
49740
  const preflight = await (dependencies.preflightCodex ?? preflightCodexSubscription)({
49469
49741
  binary,
49470
49742
  codexHome: config2.codexHomePath,
49471
- deadlineAtMs: Date.now() + 3e4
49743
+ deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms
49472
49744
  });
49473
49745
  const status = await manager.install({
49474
49746
  adapter: "codex",
@@ -50282,19 +50554,19 @@ var init_shared = __esm({
50282
50554
  shareClientGetRequest = async (key, request, options) => {
50283
50555
  if (!canUseClientGetRequestCache(options?.cookie)) {
50284
50556
  if (options?.signal?.aborted) throw toAbortError(options.signal.reason);
50285
- return raceWithAbortSignal(request(), options?.signal);
50557
+ return raceWithAbortSignal(request(options?.signal), options?.signal);
50286
50558
  }
50287
50559
  const now = Date.now();
50288
50560
  const recent = recentClientGetResponses.get(key);
50289
50561
  if (recent && recent.expiresAt > now) return recent.value;
50290
50562
  if (recent) recentClientGetResponses.delete(key);
50291
50563
  if (options?.signal?.aborted) throw toAbortError(options.signal.reason);
50292
- if (options?.signal && !options.shareAbortScoped) return raceWithAbortSignal(request(), options.signal);
50564
+ if (options?.signal && !options.shareAbortScoped) return raceWithAbortSignal(request(options.signal), options.signal);
50293
50565
  const existing = inFlightClientGetRequests.get(key);
50294
50566
  if (existing) return raceWithAbortSignal(existing, options?.signal);
50295
50567
  const requestGeneration = clientGetRequestGenerations.get(key) ?? 0;
50296
50568
  initializedClientGetRequestKeys.add(key);
50297
- const promise2 = request().then((value) => {
50569
+ const promise2 = request(void 0).then((value) => {
50298
50570
  if ((clientGetRequestGenerations.get(key) ?? 0) === requestGeneration) {
50299
50571
  recentClientGetResponses.set(key, {
50300
50572
  expiresAt: Date.now() + (options?.ttlMs ?? CLIENT_GET_DEDUPE_TTL_MS),
@@ -50811,6 +51083,16 @@ var init_ai_status_auth_fallback_contract = __esm({
50811
51083
  }
50812
51084
  });
50813
51085
 
51086
+ // lib/navigation/same-origin.ts
51087
+ var init_same_origin = __esm({
51088
+ "lib/navigation/same-origin.ts"() {
51089
+ "use strict";
51090
+ init_define_VTX_EXO_POLICY();
51091
+ init_define_VTX_GROK_POLICY();
51092
+ init_define_VTX_PI_MODEL_POLICY();
51093
+ }
51094
+ });
51095
+
50814
51096
  // lib/auth/google-auth-url.ts
50815
51097
  var init_google_auth_url = __esm({
50816
51098
  "lib/auth/google-auth-url.ts"() {
@@ -50818,6 +51100,7 @@ var init_google_auth_url = __esm({
50818
51100
  init_define_VTX_EXO_POLICY();
50819
51101
  init_define_VTX_GROK_POLICY();
50820
51102
  init_define_VTX_PI_MODEL_POLICY();
51103
+ init_same_origin();
50821
51104
  }
50822
51105
  });
50823
51106
 
@@ -51674,7 +51957,7 @@ var init_local_breadcrumbs = __esm({
51674
51957
  });
51675
51958
 
51676
51959
  // lib/runtime/client-runtime-ownership-errors.ts
51677
- var CLIENT_RUNTIME_OWNERSHIP_ERROR_CODES, OWNERSHIP_CODE_SET, readField, readClientRuntimeOwnershipErrorCode, readClientRuntimeOwnershipLossScope, readStatus, LEASE_ENDED_CODES, clientRuntimeLeaseEndedFromCode, ownershipLossReasonFromCode, clientRuntimeReleasedFromCode, clientRuntimeSessionStoppedFromCode;
51960
+ var CLIENT_RUNTIME_OWNERSHIP_ERROR_CODES, OWNERSHIP_CODE_SET, readField, readClientRuntimeOwnershipErrorCode, readClientRuntimeOwnershipLossScope, readStatus, LEASE_ENDED_CODES, clientRuntimeLeaseEndedFromCode, AUTHORITY_ENDED_CODES, clientRuntimeAuthorityEndedFromCode, ownershipLossReasonFromCode, clientRuntimeReleasedFromCode, clientRuntimeSessionStoppedFromCode;
51678
51961
  var init_client_runtime_ownership_errors = __esm({
51679
51962
  "lib/runtime/client-runtime-ownership-errors.ts"() {
51680
51963
  "use strict";
@@ -51732,6 +52015,16 @@ var init_client_runtime_ownership_errors = __esm({
51732
52015
  }
51733
52016
  return (code === "runtime_owner_superseded" || code === "runtime_owner_released") && statusCode === 401;
51734
52017
  };
52018
+ AUTHORITY_ENDED_CODES = /* @__PURE__ */ new Set([
52019
+ ...LEASE_ENDED_CODES,
52020
+ "runtime_owner_superseded",
52021
+ "runtime_owner_released",
52022
+ "runtime_scheduler_instance_mismatch"
52023
+ ]);
52024
+ clientRuntimeAuthorityEndedFromCode = (error48) => {
52025
+ const code = readClientRuntimeOwnershipErrorCode(error48);
52026
+ return code !== null && AUTHORITY_ENDED_CODES.has(code);
52027
+ };
51735
52028
  ownershipLossReasonFromCode = (error48) => {
51736
52029
  const code = readClientRuntimeOwnershipErrorCode(error48);
51737
52030
  if (code === null) {
@@ -51796,7 +52089,7 @@ var init_billing = __esm({
51796
52089
  async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_XBTUSD", timeframe = "1m", signal) {
51797
52090
  const params = new URLSearchParams({ limit: limit.toString(), exchange, symbol: symbol2, timeframe });
51798
52091
  const requestUrl = `${getApiUrl()}/candles/recent?${params.toString()}`;
51799
- return shareClientGetRequest(`recent-candles:${params.toString()}`, async () => {
52092
+ return shareClientGetRequest(`recent-candles:${params.toString()}`, async (requestSignal) => {
51800
52093
  const trace = startRuntimeNetworkDebugTrace({
51801
52094
  kind: "runtime",
51802
52095
  label: "market_data_api:candles_recent",
@@ -51808,7 +52101,7 @@ async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_X
51808
52101
  try {
51809
52102
  response = await apiFetch(requestUrl, {
51810
52103
  cache: "no-store",
51811
- signal: typeof window === "undefined" ? signal : void 0
52104
+ signal: requestSignal
51812
52105
  });
51813
52106
  if (!response.ok) {
51814
52107
  const error48 = await buildMarketDataFetchError(response, "recent candles", "/candles/recent");
@@ -51836,7 +52129,7 @@ async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_X
51836
52129
  }
51837
52130
  async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal) {
51838
52131
  const requestKey = `live-ticker:${symbol2}:${exchange}`;
51839
- return shareClientGetRequest(requestKey, async () => {
52132
+ return shareClientGetRequest(requestKey, async (requestSignal) => {
51840
52133
  const requestUrl = `${getApiUrl()}/ticker/live?symbol=${encodeURIComponent(symbol2)}&exchange=${encodeURIComponent(exchange)}`;
51841
52134
  const trace = startRuntimeNetworkDebugTrace({
51842
52135
  kind: "runtime",
@@ -51847,7 +52140,7 @@ async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal)
51847
52140
  });
51848
52141
  let response = null;
51849
52142
  try {
51850
- response = await apiFetch(requestUrl, { cache: "no-store", signal });
52143
+ response = await apiFetch(requestUrl, { cache: "no-store", signal: requestSignal });
51851
52144
  if (!response.ok) {
51852
52145
  const error48 = await buildMarketDataFetchError(response, "live ticker", "/ticker/live");
51853
52146
  trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
@@ -60339,7 +60632,7 @@ var init_strings = __esm({
60339
60632
  });
60340
60633
 
60341
60634
  // node_modules/ethers/lib.esm/constants/index.js
60342
- var init_constants = __esm({
60635
+ var init_constants2 = __esm({
60343
60636
  "node_modules/ethers/lib.esm/constants/index.js"() {
60344
60637
  init_define_VTX_EXO_POLICY();
60345
60638
  init_define_VTX_GROK_POLICY();
@@ -60361,7 +60654,7 @@ var init_signature = __esm({
60361
60654
  init_define_VTX_EXO_POLICY();
60362
60655
  init_define_VTX_GROK_POLICY();
60363
60656
  init_define_VTX_PI_MODEL_POLICY();
60364
- init_constants();
60657
+ init_constants2();
60365
60658
  init_utils();
60366
60659
  BN_04 = BigInt(0);
60367
60660
  BN_13 = BigInt(1);
@@ -64590,7 +64883,7 @@ var init_message = __esm({
64590
64883
  init_define_VTX_GROK_POLICY();
64591
64884
  init_define_VTX_PI_MODEL_POLICY();
64592
64885
  init_crypto3();
64593
- init_constants();
64886
+ init_constants2();
64594
64887
  init_transaction2();
64595
64888
  init_utils();
64596
64889
  }
@@ -70198,7 +70491,7 @@ var init_ens_resolver = __esm({
70198
70491
  init_define_VTX_GROK_POLICY();
70199
70492
  init_define_VTX_PI_MODEL_POLICY();
70200
70493
  init_address2();
70201
- init_constants();
70494
+ init_constants2();
70202
70495
  init_contract2();
70203
70496
  init_hash();
70204
70497
  init_utils();
@@ -71845,7 +72138,7 @@ var init_abstract_provider = __esm({
71845
72138
  init_define_VTX_GROK_POLICY();
71846
72139
  init_define_VTX_PI_MODEL_POLICY();
71847
72140
  init_address2();
71848
- init_constants();
72141
+ init_constants2();
71849
72142
  init_contract2();
71850
72143
  init_hash();
71851
72144
  init_transaction2();
@@ -83444,7 +83737,7 @@ var init_ethers = __esm({
83444
83737
  init_version();
83445
83738
  init_abi();
83446
83739
  init_address2();
83447
- init_constants();
83740
+ init_constants2();
83448
83741
  init_contract2();
83449
83742
  init_crypto3();
83450
83743
  init_hash();
@@ -84612,6 +84905,7 @@ var init_hyperliquid_client = __esm({
84612
84905
  init_order_identity();
84613
84906
  init_hyperliquid_order_status();
84614
84907
  init_runtime_policy_generated2();
84908
+ init_constants();
84615
84909
  init_hyperliquid_public_read();
84616
84910
  init_api2();
84617
84911
  init_abort();
@@ -86636,6 +86930,13 @@ var init_hyperliquid_client = __esm({
86636
86930
  }
86637
86931
  };
86638
86932
  const settleDefinitiveSuccess = async (exchangeOrderId, orderMemberResults) => {
86933
+ const settlementPolicy = runtime_policy_generated_default2.trading.engine.client_runtime.exchange_mutation;
86934
+ const settlementDeadlineMs = globalThis.performance.now() + settlementPolicy.settlement_retry_window_seconds * MS_PER_SECOND;
86935
+ const handOffToReconciliation = () => {
86936
+ if (begunMutation != null && pinnedAuthority != null) {
86937
+ handOffClientExchangeMutationToReconciliation(begunMutation, pinnedAuthority);
86938
+ }
86939
+ };
86639
86940
  while (true) {
86640
86941
  try {
86641
86942
  const settledMutation = await settleDurableMutation(
@@ -86651,15 +86952,14 @@ var init_hyperliquid_client = __esm({
86651
86952
  }
86652
86953
  return;
86653
86954
  } catch (settlementError) {
86955
+ const settlementCause = settlementError.settlementCause;
86654
86956
  if (input.signal?.aborted) {
86957
+ handOffToReconciliation();
86655
86958
  throw input.signal.reason instanceof Error ? input.signal.reason : settlementError;
86656
86959
  }
86657
- if (isClientExchangeMutationAuthorityConflict(
86658
- settlementError.settlementCause
86659
- )) {
86660
- if (begunMutation != null && pinnedAuthority != null) {
86661
- handOffClientExchangeMutationToReconciliation(begunMutation, pinnedAuthority);
86662
- }
86960
+ const neverSettles = isClientExchangeMutationAuthorityConflict(settlementCause);
86961
+ if (neverSettles || globalThis.performance.now() + settlementPolicy.settlement_retry_milliseconds > settlementDeadlineMs) {
86962
+ handOffToReconciliation();
86663
86963
  throw new RuntimeExecutionError(
86664
86964
  "Exchange submission may have completed; durable reconciliation is pending.",
86665
86965
  "outcome_unknown"
@@ -86674,7 +86974,10 @@ var init_hyperliquid_client = __esm({
86674
86974
  input.signal?.removeEventListener("abort", finish);
86675
86975
  resolve14();
86676
86976
  };
86677
- const timeoutId = globalThis.setTimeout(finish, 1e3);
86977
+ const timeoutId = globalThis.setTimeout(
86978
+ finish,
86979
+ settlementPolicy.settlement_retry_milliseconds
86980
+ );
86678
86981
  input.signal?.addEventListener("abort", finish, { once: true });
86679
86982
  });
86680
86983
  }
@@ -87078,7 +87381,7 @@ async function getPreferences(cookie, profileId, signal, includeTradeLayouts = f
87078
87381
  const schedulerInstanceId = String(runtimeAuthority?.schedulerInstanceId ?? "").trim() || void 0;
87079
87382
  const baseRequestKey = clientPreferencesRequestKey(effectiveProfileId, includeTradeLayouts);
87080
87383
  const requestKey = schedulerInstanceId ? `${baseRequestKey}:scheduler=${schedulerInstanceId}` : baseRequestKey;
87081
- return shareClientGetRequest(requestKey, async () => {
87384
+ return shareClientGetRequest(requestKey, async (requestSignal) => {
87082
87385
  const headers = getProfileHeaders({}, profileId);
87083
87386
  if (cookie) {
87084
87387
  headers["Cookie"] = cookie;
@@ -87101,7 +87404,7 @@ async function getPreferences(cookie, profileId, signal, includeTradeLayouts = f
87101
87404
  credentials: "include",
87102
87405
  cache: "no-store",
87103
87406
  headers,
87104
- signal: typeof window === "undefined" ? signal : void 0
87407
+ signal: requestSignal
87105
87408
  });
87106
87409
  if (!response.ok) {
87107
87410
  throwUnauthorizedIfNeeded(response);
@@ -87261,7 +87564,7 @@ async function acknowledgeClientCopyTradingOrderAction(profileId, actionId, payl
87261
87564
  }
87262
87565
  async function getLLMConfig(cookie, profileId, signal) {
87263
87566
  const effectiveProfileId = profileId ?? getActiveProfileId() ?? null;
87264
- return shareClientGetRequest(clientGetRequestKey("llm-config", effectiveProfileId), async () => {
87567
+ return shareClientGetRequest(clientGetRequestKey("llm-config", effectiveProfileId), async (requestSignal) => {
87265
87568
  const headers = getProfileHeaders({
87266
87569
  "Content-Type": "application/json"
87267
87570
  }, profileId);
@@ -87272,7 +87575,7 @@ async function getLLMConfig(cookie, profileId, signal) {
87272
87575
  method: "GET",
87273
87576
  headers,
87274
87577
  credentials: "include",
87275
- signal
87578
+ signal: requestSignal
87276
87579
  });
87277
87580
  if (!response.ok) {
87278
87581
  const message = await getErrorMessageFromResponse(
@@ -88495,7 +88798,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
88495
88798
  }
88496
88799
  const viewer = resolveClientRuntimeStatusViewerHeaders(options?.runtimeViewer);
88497
88800
  const requestKey = `client-runtime-statuses:${normalizedProfileIds.join(",")}${viewer.requestKey}`;
88498
- return shareClientGetRequest(requestKey, async () => {
88801
+ return shareClientGetRequest(requestKey, async (requestSignal) => {
88499
88802
  const headers = { ...viewer.headers };
88500
88803
  const response = await apiFetch(
88501
88804
  `${getApiUrl()}/trading/ai/runtime/statuses?${params.toString()}`,
@@ -88505,7 +88808,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
88505
88808
  cache: "no-store",
88506
88809
  headers,
88507
88810
  // Without the browser's shared request a caller's abort ends the request too.
88508
- signal: typeof window === "undefined" ? signal : void 0
88811
+ signal: requestSignal
88509
88812
  }
88510
88813
  );
88511
88814
  if (!response.ok) {
@@ -89024,15 +89327,11 @@ var init_api2 = __esm({
89024
89327
  CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH = "exchange_mutation_authority_mismatch";
89025
89328
  isClientExchangeMutationAuthorityConflict = (error48) => {
89026
89329
  const candidate = error48;
89330
+ if (clientRuntimeAuthorityEndedFromCode(error48)) return true;
89027
89331
  if (Number(candidate?.status) !== 409) return false;
89028
- if (candidate?.code === CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH) return true;
89029
- return /does not own this exchange mutation/i.test(String(candidate?.message ?? ""));
89332
+ return candidate?.code === CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH || /does not own this exchange mutation/i.test(String(candidate?.message ?? ""));
89030
89333
  };
89031
- handOffClientExchangeMutationToReconciliation = (mutation, authority) => scheduleClientExchangeMutationReconciliation(
89032
- authority.numericProfileId,
89033
- mutation,
89034
- authority.requestOptions
89035
- );
89334
+ handOffClientExchangeMutationToReconciliation = (mutation, authority) => scheduleClientExchangeMutationReconciliation(authority.numericProfileId, mutation, authority.requestOptions);
89036
89335
  clientExchangeMutationAuthorityBody = (authority) => {
89037
89336
  const schedulerInstanceId = String(authority.requestOptions.schedulerInstanceId ?? "").trim();
89038
89337
  return {
@@ -89172,11 +89471,8 @@ var init_api2 = __esm({
89172
89471
  const timer = globalThis.setTimeout(() => {
89173
89472
  const scheduled = clientExchangeMutationReconciliationTimers.get(key);
89174
89473
  clientExchangeMutationReconciliationTimers.delete(key);
89175
- void postClientExchangeMutationReconciliation(
89176
- profileId,
89177
- mutation.mutation_id,
89178
- scheduled?.requestOptions ?? authority
89179
- ).catch(() => {
89474
+ const requestOptions2 = scheduled?.requestOptions ?? authority;
89475
+ void postClientExchangeMutationReconciliation(profileId, mutation.mutation_id, requestOptions2).catch((error48) => requestOptions2.runtimeLeaseToken && clientRuntimeAuthorityEndedFromCode(error48) ? postClientExchangeMutationReconciliation(profileId, mutation.mutation_id, { omitRuntimeLeaseToken: true }) : void 0).catch(() => {
89180
89476
  });
89181
89477
  }, Math.max(0, delayMs));
89182
89478
  clientExchangeMutationReconciliationTimers.set(key, {
@@ -93636,7 +93932,7 @@ function copiedTargetNow(reconciliation, recordedTarget, actualPosition) {
93636
93932
  );
93637
93933
  return { copiedNow, targetNow, kept: copiedTargetBesideOwnPosition(targetNow, copiedNow, actualPosition) };
93638
93934
  }
93639
- var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, recoverJournaledClientProtectiveAttachments, readPendingEntryMutation, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
93935
+ var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, recoverJournaledClientProtectiveAttachments, readPendingEntryMutation, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
93640
93936
  var init_runtime_execution = __esm({
93641
93937
  "lib/runtime/runtime-execution.ts"() {
93642
93938
  "use strict";
@@ -94698,6 +94994,18 @@ var init_runtime_execution = __esm({
94698
94994
  input.executionContext.takeProfitMode === "usdc" ? input.executionContext.takeProfitUsdc : input.executionContext.takeProfitPct
94699
94995
  ) > 0);
94700
94996
  protectiveAction = (leg) => leg.kind === "sl" ? "AUTO_SL" : "AUTO_TP";
94997
+ executedProtectiveReport = (input) => ({
94998
+ order_id: input.orderId,
94999
+ ...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
95000
+ symbol: input.symbol,
95001
+ action: input.action,
95002
+ status: "executed",
95003
+ execution_metadata: {
95004
+ ...input.metadata,
95005
+ protected_size: input.protectedSize,
95006
+ position_tpsl: input.positionTpsl
95007
+ }
95008
+ });
94701
95009
  isExactClientPositionTpslPair = (legs) => legs.length === 2 && legs.every((leg) => leg.positionTpsl === true) && new Set(legs.map((leg) => leg.kind)).size === 2;
94702
95010
  deviceOwnsClientProtectiveLegKind = (group, kind) => group.deviceOwnedLegKinds == null || group.deviceOwnedLegKinds.includes(kind);
94703
95011
  isAdoptionNarrowedPositionTpslLeg = (group) => group.deviceOwnedLegKinds?.length === 1 && group.legs.length === 1 && group.legs[0].positionTpsl === true && group.legs[0].kind === group.deviceOwnedLegKinds[0];
@@ -94797,19 +95105,18 @@ var init_runtime_execution = __esm({
94797
95105
  if (!terminalShapeMatches) {
94798
95106
  throw new Error("Tracked protective order is absent without exact terminal shape evidence.");
94799
95107
  }
94800
- return {
94801
- order_id: String(leg.orderId),
95108
+ return executedProtectiveReport({
95109
+ orderId: String(leg.orderId),
94802
95110
  symbol: symbol2,
94803
95111
  action: protectiveAction(leg),
94804
- status: "executed",
94805
- execution_metadata: {
95112
+ protectedSize: leg.size,
95113
+ positionTpsl: leg.positionTpsl === true || evidence.isPositionTpsl === true,
95114
+ metadata: {
94806
95115
  trigger_price: leg.triggerPrice,
94807
95116
  reason_code: reasonCode,
94808
- terminal_order_status: evidence.orderStatus,
94809
- protected_size: leg.size,
94810
- position_tpsl: leg.positionTpsl === true || evidence.isPositionTpsl === true
95117
+ terminal_order_status: evidence.orderStatus
94811
95118
  }
94812
- };
95119
+ });
94813
95120
  }
94814
95121
  if (!protectiveLiveShapeMatches({
94815
95122
  shape: {
@@ -95456,20 +95763,19 @@ var init_runtime_execution = __esm({
95456
95763
  const activeLegs = acknowledgedLegs.filter((_leg, index) => acknowledgements[index].state === "active");
95457
95764
  const mixedPositionTpslAcknowledgement = positionTpsl && activeLegs.length === 1 && acknowledgements.some((acknowledgement) => acknowledgement.state === "fulfilled");
95458
95765
  for (let index = 0; index < candidates.length; index += 1) {
95459
- reports.push({
95460
- order_id: acknowledgements[index].orderId,
95461
- client_mutation_id: candidates[index].mutationId,
95766
+ reports.push(executedProtectiveReport({
95767
+ orderId: acknowledgements[index].orderId,
95768
+ clientMutationId: candidates[index].mutationId,
95462
95769
  symbol: symbol2,
95463
95770
  action: candidates[index].kind === "sl" ? "AUTO_SL" : "AUTO_TP",
95464
- status: "executed",
95465
- execution_metadata: {
95771
+ protectedSize: candidates[index].size,
95772
+ positionTpsl,
95773
+ metadata: {
95466
95774
  trigger_price: candidates[index].triggerPrice,
95467
- protected_size: candidates[index].size,
95468
95775
  entry_filled_size: fill.filledSize,
95469
- entry_average_price: fill.averagePrice,
95470
- position_tpsl: positionTpsl
95776
+ entry_average_price: fill.averagePrice
95471
95777
  }
95472
- });
95778
+ }));
95473
95779
  }
95474
95780
  const acknowledgedGroup = activeLegs.length > 0 ? {
95475
95781
  ...activeGroup,
@@ -96468,20 +96774,19 @@ var init_runtime_execution = __esm({
96468
96774
  if (!retired) {
96469
96775
  throw new Error("Terminal protective replacement could not be retired durably.");
96470
96776
  }
96471
- reports.push({
96472
- order_id: String(evidence.orderId ?? replacement.clientOrderId),
96473
- client_mutation_id: replacement.mutationId,
96777
+ reports.push(executedProtectiveReport({
96778
+ orderId: String(evidence.orderId ?? replacement.clientOrderId),
96779
+ clientMutationId: replacement.mutationId,
96474
96780
  symbol: symbol2,
96475
96781
  action: protectiveAction(leg),
96476
- status: "executed",
96477
- execution_metadata: {
96782
+ protectedSize: replacementLeg.size,
96783
+ positionTpsl: replacementLeg.positionTpsl === true,
96784
+ metadata: {
96478
96785
  reason_code: "protective_replacement_terminal_reconciled",
96479
96786
  previous_order_id: replacement.previousOrderId,
96480
- order_status: evidence.orderStatus,
96481
- protected_size: replacementLeg.size,
96482
- position_tpsl: replacementLeg.positionTpsl === true
96787
+ order_status: evidence.orderStatus
96483
96788
  }
96484
- });
96789
+ }));
96485
96790
  continue;
96486
96791
  }
96487
96792
  const ambiguousPositionTpslAuthority = hasAmbiguousClientPositionTpslAuthority(group);
@@ -96525,20 +96830,19 @@ var init_runtime_execution = __esm({
96525
96830
  if (!recovered) {
96526
96831
  throw new Error("Ambiguous position-TPSL replacement could not be bound durably.");
96527
96832
  }
96528
- reports.push({
96529
- order_id: String(replacementOrderId),
96530
- client_mutation_id: replacement.mutationId,
96833
+ reports.push(executedProtectiveReport({
96834
+ orderId: String(replacementOrderId),
96835
+ clientMutationId: replacement.mutationId,
96531
96836
  symbol: symbol2,
96532
96837
  action: protectiveAction(leg),
96533
- status: "executed",
96534
- execution_metadata: {
96838
+ protectedSize: replacement.size,
96839
+ positionTpsl: recoveredLeg.positionTpsl === true,
96840
+ metadata: {
96535
96841
  reason_code: exactLivePositionTpsl ? "protective_replacement_reconciled_for_cleanup" : "protective_replacement_reconciled",
96536
96842
  previous_order_id: replacement.previousOrderId,
96537
- trigger_price: replacement.triggerPrice,
96538
- protected_size: replacement.size,
96539
- position_tpsl: recoveredLeg.positionTpsl === true
96843
+ trigger_price: replacement.triggerPrice
96540
96844
  }
96541
- });
96845
+ }));
96542
96846
  continue;
96543
96847
  }
96544
96848
  if (ambiguousPositionTpslAuthority && classifyHyperliquidOrderStatus(evidence.orderStatus) !== "filled") {
@@ -96571,20 +96875,19 @@ var init_runtime_execution = __esm({
96571
96875
  throw new Error("Fulfilled protective replacement could not be resolved durably.");
96572
96876
  }
96573
96877
  removeTrackedTrailingStop(profileId, symbol2, replacement.previousOrderId);
96574
- reports.push({
96575
- order_id: String(replacementOrderId),
96576
- client_mutation_id: replacement.mutationId,
96878
+ reports.push(executedProtectiveReport({
96879
+ orderId: String(replacementOrderId),
96880
+ clientMutationId: replacement.mutationId,
96577
96881
  symbol: symbol2,
96578
96882
  action: protectiveAction(leg),
96579
- status: "executed",
96580
- execution_metadata: {
96883
+ protectedSize: replacement.size,
96884
+ positionTpsl: leg.positionTpsl === true,
96885
+ metadata: {
96581
96886
  reason_code: "protective_replacement_fulfilled_reconciled",
96582
96887
  previous_order_id: replacement.previousOrderId,
96583
- trigger_price: replacement.triggerPrice,
96584
- protected_size: replacement.size,
96585
- position_tpsl: leg.positionTpsl === true
96888
+ trigger_price: replacement.triggerPrice
96586
96889
  }
96587
- });
96890
+ }));
96588
96891
  continue;
96589
96892
  }
96590
96893
  let shapeMatches = exactShapeMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open";
@@ -96626,21 +96929,20 @@ var init_runtime_execution = __esm({
96626
96929
  if (replacementCleanup == null || !clearClientRuntimeVetoedProtectiveIntent(replacementCleanup)) {
96627
96930
  throw new Error("Unapplied protective replacement could not be abandoned durably.");
96628
96931
  }
96629
- reports.push({
96630
- order_id: String(replacement.previousOrderId),
96631
- client_mutation_id: replacement.mutationId,
96932
+ reports.push(executedProtectiveReport({
96933
+ orderId: String(replacement.previousOrderId),
96934
+ clientMutationId: replacement.mutationId,
96632
96935
  symbol: symbol2,
96633
96936
  action: protectiveAction(effectiveLeg),
96634
- status: "executed",
96635
- execution_metadata: {
96937
+ protectedSize: effectiveLeg.size,
96938
+ positionTpsl: effectiveLeg.positionTpsl === true,
96939
+ metadata: {
96636
96940
  reason_code: "protective_replacement_abandoned_original_filled",
96637
96941
  previous_order_id: replacement.previousOrderId,
96638
96942
  order_status: originalEvidence.orderStatus,
96639
- trigger_price: effectiveLeg.triggerPrice,
96640
- protected_size: effectiveLeg.size,
96641
- position_tpsl: effectiveLeg.positionTpsl === true
96943
+ trigger_price: effectiveLeg.triggerPrice
96642
96944
  }
96643
- });
96945
+ }));
96644
96946
  continue;
96645
96947
  }
96646
96948
  }
@@ -96650,20 +96952,19 @@ var init_runtime_execution = __esm({
96650
96952
  if (replacementCleanup == null || !clearClientRuntimeVetoedProtectiveIntent(replacementCleanup)) {
96651
96953
  throw new Error("Undispatched protective replacement could not be abandoned durably.");
96652
96954
  }
96653
- reports.push({
96654
- order_id: String(replacement.previousOrderId),
96655
- client_mutation_id: replacement.mutationId,
96955
+ reports.push(executedProtectiveReport({
96956
+ orderId: String(replacement.previousOrderId),
96957
+ clientMutationId: replacement.mutationId,
96656
96958
  symbol: symbol2,
96657
96959
  action: protectiveAction(effectiveLeg),
96658
- status: "executed",
96659
- execution_metadata: {
96960
+ protectedSize: effectiveLeg.size,
96961
+ positionTpsl: effectiveLeg.positionTpsl === true,
96962
+ metadata: {
96660
96963
  reason_code: "protective_replacement_abandoned_undispatched",
96661
96964
  previous_order_id: replacement.previousOrderId,
96662
- trigger_price: effectiveLeg.triggerPrice,
96663
- protected_size: effectiveLeg.size,
96664
- position_tpsl: effectiveLeg.positionTpsl === true
96965
+ trigger_price: effectiveLeg.triggerPrice
96665
96966
  }
96666
- });
96967
+ }));
96667
96968
  continue;
96668
96969
  }
96669
96970
  const replayReservation = replacementReservation;
@@ -96731,20 +97032,19 @@ var init_runtime_execution = __esm({
96731
97032
  }
96732
97033
  });
96733
97034
  }
96734
- reports.push({
96735
- order_id: String(replacementOrderId),
96736
- client_mutation_id: replacement.mutationId,
97035
+ reports.push(executedProtectiveReport({
97036
+ orderId: String(replacementOrderId),
97037
+ clientMutationId: replacement.mutationId,
96737
97038
  symbol: symbol2,
96738
97039
  action: protectiveAction(effectiveLeg),
96739
- status: "executed",
96740
- execution_metadata: {
97040
+ protectedSize: replacement.size,
97041
+ positionTpsl: effectiveLeg.positionTpsl === true,
97042
+ metadata: {
96741
97043
  reason_code: acknowledgement.state === "fulfilled" ? "protective_replacement_fulfilled_reconciled" : "protective_replacement_reconciled",
96742
97044
  previous_order_id: replacement.previousOrderId,
96743
- trigger_price: replacement.triggerPrice,
96744
- protected_size: replacement.size,
96745
- position_tpsl: effectiveLeg.positionTpsl === true
97045
+ trigger_price: replacement.triggerPrice
96746
97046
  }
96747
- });
97047
+ }));
96748
97048
  continue;
96749
97049
  }
96750
97050
  }
@@ -96770,20 +97070,19 @@ var init_runtime_execution = __esm({
96770
97070
  if (!bound) {
96771
97071
  throw new Error("Pending protective replacement could not be bound durably.");
96772
97072
  }
96773
- reports.push({
96774
- order_id: String(replacementOrderId),
96775
- client_mutation_id: replacement.mutationId,
97073
+ reports.push(executedProtectiveReport({
97074
+ orderId: String(replacementOrderId),
97075
+ clientMutationId: replacement.mutationId,
96776
97076
  symbol: symbol2,
96777
97077
  action: protectiveAction(effectiveLeg),
96778
- status: "executed",
96779
- execution_metadata: {
97078
+ protectedSize: replacement.size,
97079
+ positionTpsl: canonicalReplacementLeg.positionTpsl === true,
97080
+ metadata: {
96780
97081
  reason_code: "protective_replacement_reconciled",
96781
97082
  previous_order_id: replacement.previousOrderId,
96782
- trigger_price: replacement.triggerPrice,
96783
- protected_size: replacement.size,
96784
- position_tpsl: canonicalReplacementLeg.positionTpsl === true
97083
+ trigger_price: replacement.triggerPrice
96785
97084
  }
96786
- });
97085
+ }));
96787
97086
  } catch (error48) {
96788
97087
  if (replayAttemptStarted && !replayDispatchBoundaryCompleted && replacementCleanup != null) {
96789
97088
  if (isClientRuntimeWindowHandoffBeforePlanDispatch(error48)) {
@@ -96849,19 +97148,18 @@ var init_runtime_execution = __esm({
96849
97148
  if (!replaceExactClientProtectiveGroup(profileId, symbol2, journalGroup, null)) {
96850
97149
  throw new Error("Terminal replacement journal could not be retired durably.");
96851
97150
  }
96852
- reports.push({
96853
- order_id: String(evidence.orderId ?? journalLeg.orderId),
96854
- client_mutation_id: mutationId,
97151
+ reports.push(executedProtectiveReport({
97152
+ orderId: String(evidence.orderId ?? journalLeg.orderId),
97153
+ clientMutationId: mutationId,
96855
97154
  symbol: symbol2,
96856
97155
  action: protectiveAction(journalLeg),
96857
- status: "executed",
96858
- execution_metadata: {
97156
+ protectedSize: journalLeg.size,
97157
+ positionTpsl: journalLeg.positionTpsl === true || evidence.isPositionTpsl === true,
97158
+ metadata: {
96859
97159
  reason_code: "protective_replacement_terminal_reconciled",
96860
- order_status: evidence.orderStatus,
96861
- protected_size: journalLeg.size,
96862
- position_tpsl: journalLeg.positionTpsl === true || evidence.isPositionTpsl === true
97160
+ order_status: evidence.orderStatus
96863
97161
  }
96864
- });
97162
+ }));
96865
97163
  continue;
96866
97164
  }
96867
97165
  const liveShape = {
@@ -97653,22 +97951,21 @@ var init_runtime_execution = __esm({
97653
97951
  return {
97654
97952
  retain: bound ? placedLeg : provisionalLeg,
97655
97953
  group: bound ? placedGroup : provisionalGroup,
97656
- reports: [{
97657
- order_id: String(placedOrderId),
97658
- client_mutation_id: mutationId,
97954
+ reports: [executedProtectiveReport({
97955
+ orderId: String(placedOrderId),
97956
+ clientMutationId: mutationId,
97659
97957
  symbol: symbol2,
97660
97958
  action: protectiveAction(leg),
97661
- status: "executed",
97662
- execution_metadata: {
97959
+ protectedSize: decision.size,
97960
+ positionTpsl: false,
97961
+ metadata: {
97663
97962
  reason_code: decision.reasonCode,
97664
97963
  replaced_order_id: lostOrderId,
97665
97964
  trigger_price: triggerPrice,
97666
- protected_size: decision.size,
97667
97965
  live_position_size: livePositionSize2,
97668
- position_tpsl: false,
97669
97966
  ...acknowledgement.state === "fulfilled" ? { acknowledgement_state: "fulfilled" } : {}
97670
97967
  }
97671
- }]
97968
+ })]
97672
97969
  };
97673
97970
  };
97674
97971
  groupLoop: for (let groupIndex = 0; groupIndex < inspectedGroups.length; groupIndex += 1) {
@@ -97967,19 +98264,18 @@ var init_runtime_execution = __esm({
97967
98264
  } else {
97968
98265
  removeTrackedTrailingStop(profileId, symbol2, leg.orderId);
97969
98266
  }
97970
- reports.push({
97971
- order_id: String(replacementOrderId),
97972
- client_mutation_id: _extractClientMutationId(response),
98267
+ reports.push(executedProtectiveReport({
98268
+ orderId: String(replacementOrderId),
98269
+ clientMutationId: _extractClientMutationId(response),
97973
98270
  symbol: symbol2,
97974
98271
  action: protectiveAction(leg),
97975
- status: "executed",
97976
- execution_metadata: {
98272
+ protectedSize: allowedSize,
98273
+ positionTpsl: replacementLeg.positionTpsl === true,
98274
+ metadata: {
97977
98275
  reason_code: "protective_resized_to_live_exposure",
97978
- previous_order_id: leg.orderId,
97979
- protected_size: allowedSize,
97980
- position_tpsl: replacementLeg.positionTpsl === true
98276
+ previous_order_id: leg.orderId
97981
98277
  }
97982
- });
98278
+ }));
97983
98279
  if (fulfilledDuringResize) {
97984
98280
  reports.push({
97985
98281
  order_id: String(replacementOrderId),
@@ -98429,20 +98725,19 @@ var init_runtime_execution = __esm({
98429
98725
  }
98430
98726
  });
98431
98727
  }
98432
- reports.push({
98433
- order_id: String(replacementOrderId),
98434
- client_mutation_id: _extractClientMutationId(modifyResponse),
98728
+ reports.push(executedProtectiveReport({
98729
+ orderId: String(replacementOrderId),
98730
+ clientMutationId: _extractClientMutationId(modifyResponse),
98435
98731
  symbol: symbol2,
98436
98732
  action: "AUTO_TRAILING_SL",
98437
- status: "executed",
98438
- execution_metadata: {
98733
+ protectedSize: effectiveSize,
98734
+ positionTpsl: record5.positionTpsl === true,
98735
+ metadata: {
98439
98736
  trigger_price: replacementTriggerPrice,
98440
98737
  previous_trigger_price: record5.triggerPrice,
98441
- previous_order_id: record5.orderId,
98442
- protected_size: effectiveSize,
98443
- position_tpsl: record5.positionTpsl === true
98738
+ previous_order_id: record5.orderId
98444
98739
  }
98445
- });
98740
+ }));
98446
98741
  } catch (error48) {
98447
98742
  const cleanup = buildVetoedProtectiveReplacementCleanup(reservation);
98448
98743
  if (!replacementDispatchBoundaryCompleted) {
@@ -100408,22 +100703,21 @@ var init_runtime_execution = __esm({
100408
100703
  }
100409
100704
  );
100410
100705
  }
100411
- executionReports.push({
100412
- order_id: String(triggerOrderId),
100413
- client_mutation_id: _extractClientMutationId(triggerResponse),
100706
+ executionReports.push(executedProtectiveReport({
100707
+ orderId: String(triggerOrderId),
100708
+ clientMutationId: _extractClientMutationId(triggerResponse),
100414
100709
  symbol: input.executionContext.symbol,
100415
100710
  action: triggerInput.label,
100416
- status: "executed",
100417
- execution_metadata: {
100711
+ protectedSize: legSize,
100712
+ positionTpsl: leg.positionTpsl === true,
100713
+ metadata: {
100418
100714
  trigger_price: triggerInput.triggerPrice,
100419
100715
  is_take_profit: triggerInput.isTakeProfit,
100420
100716
  entry_filled_size: protectionSize,
100421
- protected_size: legSize,
100422
- position_tpsl: leg.positionTpsl === true,
100423
100717
  entry_average_price: protectionEntryPrice,
100424
100718
  ..._toExecutionMetadata(triggerResponse)
100425
100719
  }
100426
- });
100720
+ }));
100427
100721
  appendRuntimeDebugEvent({
100428
100722
  label: "execution_auto_sl_tp_submitted",
100429
100723
  note: `symbol=${input.executionContext.symbol} kind=${triggerInput.isTakeProfit ? "tp" : "sl"} side=${exitSide} sizeAsset=${legSize} triggerPrice=${triggerInput.triggerPrice} order_id=${triggerOrderId}`
@@ -104076,7 +104370,7 @@ var require_react = __commonJS({
104076
104370
  });
104077
104371
 
104078
104372
  // lib/runtime/client-runtime-status-store.ts
104079
- var import_react, finiteOrNull2, readMode, orderKey, sameOwnerSeries, hasGenerations, compareClientRuntimeStatusOrder, sameGenerations, LIVENESS_CLOCK_FIELDS, sameValue, sameVisibleState, definedFields, ClientRuntimeStatusStore, clientRuntimeStatusStore;
104373
+ var import_react, finiteOrNull2, readMode, orderKey, sameOwnerSeries, hasGenerations, compareClientRuntimeStatusOrder, sameGenerations, LIVENESS_CLOCK_FIELDS, sameValue, sameVisibleState, definedFields, readServerBackup, PROFILE_FIELDS, keepProfileFields, ClientRuntimeStatusStore, clientRuntimeStatusStore;
104080
104374
  var init_client_runtime_status_store = __esm({
104081
104375
  "lib/runtime/client-runtime-status-store.ts"() {
104082
104376
  "use strict";
@@ -104139,6 +104433,17 @@ var init_client_runtime_status_store = __esm({
104139
104433
  return true;
104140
104434
  };
104141
104435
  definedFields = (status) => Object.fromEntries(Object.entries(status).filter(([, value]) => value !== void 0));
104436
+ readServerBackup = (value) => value && typeof value === "object" && typeof value.active === "boolean" ? value : null;
104437
+ PROFILE_FIELDS = ["execution_mode", "server_backup"];
104438
+ keepProfileFields = (current, incoming) => {
104439
+ const kept = {};
104440
+ for (const field of PROFILE_FIELDS) {
104441
+ if (incoming[field] === void 0 && current[field] !== void 0) {
104442
+ kept[field] = current[field];
104443
+ }
104444
+ }
104445
+ return { ...kept, ...incoming };
104446
+ };
104142
104447
  ClientRuntimeStatusStore = class {
104143
104448
  constructor() {
104144
104449
  this.entries = /* @__PURE__ */ new Map();
@@ -104163,7 +104468,7 @@ var init_client_runtime_status_store = __esm({
104163
104468
  } else {
104164
104469
  const order = compareClientRuntimeStatusOrder(incoming, current);
104165
104470
  if (order < 0) return false;
104166
- next = sameGenerations(incoming, current) || !hasGenerations(orderKey(incoming)) ? { ...current, ...incoming } : incoming;
104471
+ next = sameGenerations(incoming, current) || !hasGenerations(orderKey(incoming)) ? { ...current, ...incoming } : keepProfileFields(current, incoming);
104167
104472
  if (sameVisibleState(next, current)) {
104168
104473
  const clocks = Object.fromEntries(
104169
104474
  Object.entries(next).filter(([field]) => LIVENESS_CLOCK_FIELDS.has(field))
@@ -104180,6 +104485,21 @@ var init_client_runtime_status_store = __esm({
104180
104485
  this.emit();
104181
104486
  return true;
104182
104487
  }
104488
+ /**
104489
+ * Record the server's backup state from an answer that carries only that
104490
+ * (a readiness report's): it updates the profile's entry, and is dropped
104491
+ * when this browser has no status for the profile yet. Returns true when
104492
+ * the entry changed.
104493
+ */
104494
+ recordServerBackup(profileId, backup) {
104495
+ const key = String(profileId ?? "").trim();
104496
+ const current = key ? this.entries.get(key) : void 0;
104497
+ const next = readServerBackup(backup);
104498
+ if (!current || !next || sameValue(current.server_backup, next)) return false;
104499
+ this.entries.set(key, { ...current, server_backup: next });
104500
+ this.emit();
104501
+ return true;
104502
+ }
104183
104503
  get(profileId) {
104184
104504
  const key = String(profileId ?? "").trim();
104185
104505
  return key ? this.entries.get(key) ?? null : null;
@@ -116422,7 +116742,7 @@ ${reviewOutputContract}`;
116422
116742
  });
116423
116743
 
116424
116744
  // lib/runtime/engine.ts
116425
- var localAnalysis, getExchangeFailureDiagnostics, getRuntimeFallbackAttempts, sentInvocationAttemptCount, boundRuntimeFallbackAttempts, isProviderFailureDiagnosticsCandidate, getEventBoundProviderLabel, getEventBoundProviderTraceId, getRecentProviderFailureDiagnostics, getClientRuntimeErrorProvenance, getRuntimeProviderSetupDiagnostics, buildProviderSetupErrorDiagnosticFields, buildClientRuntimeErrorProvenanceDiagnosticFields, buildRuntimeRequestErrorDiagnosticFields, getCycleErrorModelCalls, isReturnedModelCall, hasEventBoundProviderFailureEvidence, endsWithNeverSentAttempt, classifyRuntimeErrorStage, buildHyperliquidPublicReadDiagnosticFields, buildRuntimeErrorDiagnostics, positiveNumber, resolveRuntimeEngineOptions, withServerPositionEvents, CLIENT_KILLSWITCH_BLOCK_STORAGE_PREFIX, getClientKillswitchBlockStorageKey, isClientRuntimeKillswitchBlocked, persistClientRuntimeKillswitchBlock, clearClientRuntimeKillswitchBlock, hashRuntimeDebugText2, createRuntimeUuid2, getRuntimeContractIdentityToken, getRuntimeStatusContractIdentityToken, getRuntimeContractBindingTokenFromCycleResult, getRuntimeContractBindingTupleToken, getRuntimeStatusContractBindingTupleToken, isTransientRuntimeConflictError, createRuntimeStartCancelledError, isRuntimeContractMismatchError, isClientExecutionModeMismatchError, isClientRuntimeSessionStoppedError, isClientRuntimeLeaseAuthError, isClientRuntimeReleasedError, deriveFailedStartCleanupOwnershipLossReason, isRuntimeAbortError, isExplicitClientExecutionMode, createStopAbortError, isRuntimeContractIdentityAdvancedAbort, CLIENT_RUNTIME_NO_DECISION_RECOVERY_REASON, sanitizeSettingsSnapshotForFallback, preflightClientRuntime, ClientExecutionEngine, createStoppedRuntimeSnapshot, ClientRuntimeRegistry, botEngine;
116745
+ var localAnalysis, getExchangeFailureDiagnostics, getRuntimeFallbackAttempts, sentInvocationAttemptCount, boundRuntimeFallbackAttempts, isProviderFailureDiagnosticsCandidate, getEventBoundProviderLabel, getEventBoundProviderTraceId, CLIENT_RUNTIME_POLICY, getRecentProviderFailureDiagnostics, getClientRuntimeErrorProvenance, getRuntimeProviderSetupDiagnostics, buildProviderSetupErrorDiagnosticFields, buildClientRuntimeErrorProvenanceDiagnosticFields, buildRuntimeRequestErrorDiagnosticFields, getCycleErrorModelCalls, isReturnedModelCall, hasEventBoundProviderFailureEvidence, endsWithNeverSentAttempt, classifyRuntimeErrorStage, buildHyperliquidPublicReadDiagnosticFields, buildRuntimeErrorDiagnostics, positiveNumber, resolveRuntimeEngineOptions, withServerPositionEvents, CLIENT_KILLSWITCH_BLOCK_STORAGE_PREFIX, getClientKillswitchBlockStorageKey, isClientRuntimeKillswitchBlocked, persistClientRuntimeKillswitchBlock, clearClientRuntimeKillswitchBlock, hashRuntimeDebugText2, createRuntimeUuid2, getRuntimeContractIdentityToken, getRuntimeStatusContractIdentityToken, getRuntimeContractBindingTokenFromCycleResult, getRuntimeContractBindingTupleToken, getRuntimeStatusContractBindingTupleToken, isTransientRuntimeConflictError, createRuntimeStartCancelledError, isRuntimeContractMismatchError, isClientExecutionModeMismatchError, isClientRuntimeSessionStoppedError, isClientRuntimeLeaseAuthError, isClientRuntimeReleasedError, deriveFailedStartCleanupOwnershipLossReason, isRuntimeAbortError, isExplicitClientExecutionMode, createStopAbortError, isRuntimeContractIdentityAdvancedAbort, CLIENT_RUNTIME_NO_DECISION_RECOVERY_REASON, sanitizeSettingsSnapshotForFallback, preflightClientRuntime, ClientExecutionEngine, createStoppedRuntimeSnapshot, ClientRuntimeRegistry, botEngine;
116426
116746
  var init_engine = __esm({
116427
116747
  "lib/runtime/engine.ts"() {
116428
116748
  "use strict";
@@ -116430,6 +116750,8 @@ var init_engine = __esm({
116430
116750
  init_define_VTX_GROK_POLICY();
116431
116751
  init_define_VTX_PI_MODEL_POLICY();
116432
116752
  init_protective_cutover();
116753
+ init_runtime_policy_generated2();
116754
+ init_constants();
116433
116755
  init_periodic_schedule();
116434
116756
  init_host_storage();
116435
116757
  init_vault();
@@ -116573,6 +116895,7 @@ var init_engine = __esm({
116573
116895
  }
116574
116896
  return null;
116575
116897
  };
116898
+ CLIENT_RUNTIME_POLICY = runtime_policy_generated_default2.trading.engine.client_runtime;
116576
116899
  getRecentProviderFailureDiagnostics = (reason) => {
116577
116900
  const providerLabel = reason === void 0 ? null : getEventBoundProviderLabel(reason);
116578
116901
  const traceId = reason === void 0 ? null : getEventBoundProviderTraceId(reason);
@@ -116580,7 +116903,7 @@ var init_engine = __esm({
116580
116903
  return null;
116581
116904
  }
116582
116905
  const snapshot = getLatestRuntimeProviderFailureTelemetrySnapshot({
116583
- maxAgeMs: 3e4,
116906
+ maxAgeMs: CLIENT_RUNTIME_POLICY.provider_failure_diagnostics_max_age_milliseconds,
116584
116907
  label: providerLabel,
116585
116908
  traceId
116586
116909
  });
@@ -116689,7 +117012,7 @@ var init_engine = __esm({
116689
117012
  runtime_request_transient_network: record5.runtimeRequestTransientNetwork === true,
116690
117013
  runtime_request_deadline_at_ms: numberOrNull(record5.runtimeRequestDeadlineAtMs),
116691
117014
  runtime_request_deadline_exceeded: record5.runtimeRequestDeadlineExceeded === true,
116692
- ...record5.code === "snapshot_stale" && record5.runtimeRequestStatus === 409 ? {
117015
+ ...record5.code === "snapshot_stale" && record5.runtimeRequestStatus === HTTP_STATUS.CONFLICT ? {
116693
117016
  runtime_rejection_reason_code: "snapshot_stale",
116694
117017
  snapshot_age_seconds: numberOrNull(record5.runtimeSnapshotAgeSeconds),
116695
117018
  snapshot_max_age_seconds: numberOrNull(record5.runtimeSnapshotMaxAgeSeconds)
@@ -116946,7 +117269,7 @@ var init_engine = __esm({
116946
117269
  };
116947
117270
  isTransientRuntimeConflictError = (error48) => {
116948
117271
  const structured = error48;
116949
- if (Number(structured?.status) === 409 && structured?.retryable === true && (structured?.code === "profile_runtime_contract_busy" || structured?.code === "runtime_decision_finalizing" || structured?.code === "runtime_trade_sync_finalizing")) {
117272
+ if (Number(structured?.status) === HTTP_STATUS.CONFLICT && structured?.retryable === true && (structured?.code === "profile_runtime_contract_busy" || structured?.code === "runtime_decision_finalizing" || structured?.code === "runtime_trade_sync_finalizing")) {
116950
117273
  return true;
116951
117274
  }
116952
117275
  const hasStructuredMetadata = Number.isFinite(Number(structured?.status)) || typeof structured?.code === "string" || typeof structured?.retryable === "boolean";
@@ -117144,7 +117467,7 @@ var init_engine = __esm({
117144
117467
  this._pendingProtectionRecoveryDispatched = false;
117145
117468
  this._lastPendingProtectionRecoveryAtMs = null;
117146
117469
  this._primaryAnalysisDisabled = false;
117147
- this._loopEarlyReturnRetryDelayMs = 5e3;
117470
+ this._loopEarlyReturnRetryDelayMs = CLIENT_RUNTIME_POLICY.loop_early_return_retry_milliseconds;
117148
117471
  this._executionModeMismatchConsecutiveCount = 0;
117149
117472
  this._expectedExecutionMode = "client";
117150
117473
  this._settleUnreportedModelCalls = null;
@@ -117311,7 +117634,7 @@ var init_engine = __esm({
117311
117634
  signal.removeEventListener("abort", finish);
117312
117635
  resolve14();
117313
117636
  };
117314
- const timeoutId = globalThis.setTimeout(finish, 1e3);
117637
+ const timeoutId = globalThis.setTimeout(finish, CLIENT_RUNTIME_POLICY.window_handoff_cleanup_retry_milliseconds);
117315
117638
  signal.addEventListener("abort", finish, { once: true });
117316
117639
  });
117317
117640
  }
@@ -117453,8 +117776,8 @@ var init_engine = __esm({
117453
117776
  const phase = policy2.phase_seconds;
117454
117777
  const interval = policy2.interval_seconds;
117455
117778
  const valid = phase != null && interval != null && Number.isFinite(phase) && Number.isFinite(interval) && interval > 0 && phase >= 0 && phase < interval && Number.isFinite(status?.server_time) && Number(status?.server_time) > 0;
117456
- const phaseMs = valid ? Math.round(phase * 1e3) : null;
117457
- const intervalMs = valid ? Math.round(interval * 1e3) : null;
117779
+ const phaseMs = valid ? Math.round(phase * MS_PER_SECOND) : null;
117780
+ const intervalMs = valid ? Math.round(interval * MS_PER_SECOND) : null;
117458
117781
  const grace = Number(policy2.dispatch_grace_ms);
117459
117782
  if (!Number.isFinite(grace) || grace < 0) throw new Error("Invalid periodic analysis dispatch grace.");
117460
117783
  const intervalChanged = intervalMs != null && this._loopIntervalMs != null && this._loopIntervalMs !== intervalMs;
@@ -117465,7 +117788,7 @@ var init_engine = __esm({
117465
117788
  phaseMs,
117466
117789
  intervalMs,
117467
117790
  dispatchGraceMs: grace,
117468
- localMinusServerMs: sameAssignment ? previous.localMinusServerMs : valid ? observedAtMs - Number(status?.server_time) * 1e3 : 0
117791
+ localMinusServerMs: sameAssignment ? previous.localMinusServerMs : valid ? observedAtMs - Number(status?.server_time) * MS_PER_SECOND : 0
117469
117792
  };
117470
117793
  if (!sameAssignment) {
117471
117794
  this._lastPeriodicSlotServerMs = null;
@@ -117802,7 +118125,7 @@ var init_engine = __esm({
117802
118125
  lastStopProfileId: this._lastStopProfileId,
117803
118126
  lastRunAt: this._lastRunAt,
117804
118127
  nextRunAtMs: this._primaryAnalysisDisabled ? null : this._nextRunAtMs,
117805
- loopIntervalSeconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / 1e3)),
118128
+ loopIntervalSeconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND)),
117806
118129
  schedulerPhase: this._getSchedulerPhase(),
117807
118130
  primaryAnalysisDisabled: this._primaryAnalysisDisabled,
117808
118131
  ownershipLossReason: this._ownershipLossReason,
@@ -117850,7 +118173,7 @@ var init_engine = __esm({
117850
118173
  if (!Number.isFinite(parsedSeconds) || parsedSeconds <= 0) {
117851
118174
  throw new Error(`Missing required ${errorLabel}.`);
117852
118175
  }
117853
- return Math.round(parsedSeconds * 1e3);
118176
+ return Math.round(parsedSeconds * MS_PER_SECOND);
117854
118177
  }
117855
118178
  _resolveAnalysisStaleAfterMs(rawSeconds, defaultTimeoutSeconds) {
117856
118179
  const parsedSeconds = Number(rawSeconds);
@@ -117861,7 +118184,7 @@ var init_engine = __esm({
117861
118184
  if (Number.isFinite(parsedDefaultTimeoutSeconds) && parsedDefaultTimeoutSeconds > 0 && parsedSeconds < parsedDefaultTimeoutSeconds) {
117862
118185
  throw new Error("Client runtime stale analysis timeout must be greater than or equal to the default timeout.");
117863
118186
  }
117864
- return Math.round(parsedSeconds * 1e3);
118187
+ return Math.round(parsedSeconds * MS_PER_SECOND);
117865
118188
  }
117866
118189
  _resolveLoopIntervalMs(loopIntervalSeconds, minLoopIntervalSeconds) {
117867
118190
  const parsedSeconds = Number(loopIntervalSeconds);
@@ -117875,7 +118198,7 @@ var init_engine = __esm({
117875
118198
  if (parsedSeconds < parsedMinSeconds) {
117876
118199
  throw new Error(`Client runtime loop interval must be at least ${parsedMinSeconds} seconds.`);
117877
118200
  }
117878
- return Math.round(parsedSeconds * 1e3);
118201
+ return Math.round(parsedSeconds * MS_PER_SECOND);
117879
118202
  }
117880
118203
  _initializeNextRunAnchor(referenceMs = Date.now()) {
117881
118204
  if (this._loopIntervalMs == null) {
@@ -118419,7 +118742,7 @@ var init_engine = __esm({
118419
118742
  this._executionModeMismatchConsecutiveCount = 0;
118420
118743
  const responseNextRunSeconds = Number(grant.runtime?.next_run);
118421
118744
  const responseServerTimeSeconds = Number(grant.runtime?.server_time);
118422
- const assignedNextRunAtMs = grant.runtime?.server_time != null && Number.isFinite(responseServerTimeSeconds) && responseServerTimeSeconds > 0 && Number.isFinite(responseNextRunSeconds) && responseNextRunSeconds > responseServerTimeSeconds ? Date.now() + (responseNextRunSeconds - responseServerTimeSeconds) * 1e3 : responseNextRunSeconds * 1e3;
118745
+ const assignedNextRunAtMs = grant.runtime?.server_time != null && Number.isFinite(responseServerTimeSeconds) && responseServerTimeSeconds > 0 && Number.isFinite(responseNextRunSeconds) && responseNextRunSeconds > responseServerTimeSeconds ? Date.now() + (responseNextRunSeconds - responseServerTimeSeconds) * MS_PER_SECOND : responseNextRunSeconds * MS_PER_SECOND;
118423
118746
  const waitsForAssignedStartPhase = Boolean(this._periodicSchedule) || Number.isFinite(assignedNextRunAtMs) && assignedNextRunAtMs > Date.now();
118424
118747
  if (waitsForAssignedStartPhase) {
118425
118748
  if (this._periodicSchedule) this._initializeNextRunAnchor();
@@ -119119,7 +119442,7 @@ var init_engine = __esm({
119119
119442
  const now = Date.now();
119120
119443
  const observations = this._trailingObservations.filter(({ executionContext }) => {
119121
119444
  const capturedAt = Date.parse(executionContext.decisionSnapshotCapturedAt ?? "");
119122
- const maxAge = Number(executionContext.executionFreshnessMaxAgeSeconds) * 1e3;
119445
+ const maxAge = Number(executionContext.executionFreshnessMaxAgeSeconds) * MS_PER_SECOND;
119123
119446
  const age = now - capturedAt;
119124
119447
  return Number.isFinite(age) && age >= 0 && Number.isFinite(maxAge) && maxAge > 0 && age <= maxAge;
119125
119448
  });
@@ -119194,7 +119517,7 @@ var init_engine = __esm({
119194
119517
  const config2 = await this.getExecutionConfig(profileId);
119195
119518
  const pollSeconds = Number(config2.client_protective_recovery_poll_seconds);
119196
119519
  if (!Number.isFinite(pollSeconds) || pollSeconds <= 0) return;
119197
- if (this._lastPendingProtectionRecoveryAtMs != null && Date.now() - this._lastPendingProtectionRecoveryAtMs < pollSeconds * 1e3) {
119520
+ if (this._lastPendingProtectionRecoveryAtMs != null && Date.now() - this._lastPendingProtectionRecoveryAtMs < pollSeconds * MS_PER_SECOND) {
119198
119521
  return;
119199
119522
  }
119200
119523
  this._lastPendingProtectionRecoveryAtMs = Date.now();
@@ -119448,7 +119771,7 @@ var init_engine = __esm({
119448
119771
  });
119449
119772
  return;
119450
119773
  }
119451
- this._emitLoopBoundaryTelemetry("client_execution_loop_early_return", "reason=analysis_in_flight retry_ms=5000", {
119774
+ this._emitLoopBoundaryTelemetry("client_execution_loop_early_return", `reason=analysis_in_flight retry_ms=${this._loopEarlyReturnRetryDelayMs}`, {
119452
119775
  reason: "analysis_in_flight",
119453
119776
  retry_ms: this._loopEarlyReturnRetryDelayMs
119454
119777
  });
@@ -119743,9 +120066,12 @@ var init_engine = __esm({
119743
120066
  const nowMs2 = Date.now();
119744
120067
  const windowOpensAtMs = error48.nextChangeAtMs != null ? this._periodicNextSlot(error48.nextChangeAtMs, true) ?? error48.nextChangeAtMs : null;
119745
120068
  aiSchedulePauseHasNext = windowOpensAtMs != null;
119746
- aiSchedulePauseMs = windowOpensAtMs != null ? Math.max(1e3, Math.min(windowOpensAtMs - nowMs2, 36e5)) : 6e4;
120069
+ aiSchedulePauseMs = windowOpensAtMs != null ? Math.max(
120070
+ CLIENT_RUNTIME_POLICY.ai_schedule_pause_min_milliseconds,
120071
+ Math.min(windowOpensAtMs - nowMs2, CLIENT_RUNTIME_POLICY.ai_schedule_pause_max_milliseconds)
120072
+ ) : CLIENT_RUNTIME_POLICY.ai_schedule_pause_unknown_milliseconds;
119747
120073
  if (runtimeMode === "trader" && this._loopIntervalMs != null) {
119748
- aiSchedulePauseMs = Math.min(aiSchedulePauseMs, Math.max(1e3, this._loopIntervalMs));
120074
+ aiSchedulePauseMs = Math.min(aiSchedulePauseMs, Math.max(CLIENT_RUNTIME_POLICY.ai_schedule_pause_min_milliseconds, this._loopIntervalMs));
119749
120075
  }
119750
120076
  this._nextRunAtMs = windowOpensAtMs;
119751
120077
  if (!aiSchedulePauseContinuation) {
@@ -120035,7 +120361,7 @@ var init_engine = __esm({
120035
120361
  await this._discardCycleOnContractMismatch("decision", decisionError);
120036
120362
  return;
120037
120363
  }
120038
- if (decisionError instanceof Error && decisionError.status === 409 && (decisionError.code === "snapshot_stale" || decisionError.message.startsWith("Runtime decision rejected by constraints:"))) {
120364
+ if (decisionError instanceof Error && decisionError.status === HTTP_STATUS.CONFLICT && (decisionError.code === "snapshot_stale" || decisionError.message.startsWith("Runtime decision rejected by constraints:"))) {
120039
120365
  Object.assign(decisionError, {
120040
120366
  runtimeInvocationAttempts: result.invocations?.map((attempt) => ({
120041
120367
  ...attempt,
@@ -120518,7 +120844,7 @@ var init_engine = __esm({
120518
120844
  } catch (error48) {
120519
120845
  const errorModelCalls = getCycleErrorModelCalls(error48);
120520
120846
  if (errorModelCalls.length > 0) cycleModelCalls = errorModelCalls;
120521
- const cycleElapsedSeconds = Math.max(0, (performance.now() - runStartedMonotonicMs) / 1e3);
120847
+ const cycleElapsedSeconds = Math.max(0, (performance.now() - runStartedMonotonicMs) / MS_PER_SECOND);
120522
120848
  cycleOutcome = "failed";
120523
120849
  cycleReason = cycleObservation.reason_code ?? "runtime_failed";
120524
120850
  if (isRuntimeAbortError(error48) || analysisAbortController.signal.aborted || this._isStopping || this._state === "stopped" || this._analysisRequestId !== requestId) {
@@ -120636,7 +120962,7 @@ var init_engine = __esm({
120636
120962
  }
120637
120963
  if (hasEventBoundProviderFailureEvidence(error48) && this._expectedExecutionMode === "server") {
120638
120964
  const backoffSeconds = Number((await this.getExecutionConfig(profileId).catch(() => null))?.provider_failure_backoff_seconds);
120639
- if (Number.isFinite(backoffSeconds) && backoffSeconds > 0) providerRetryDelayMs = backoffSeconds * 1e3;
120965
+ if (Number.isFinite(backoffSeconds) && backoffSeconds > 0) providerRetryDelayMs = backoffSeconds * MS_PER_SECOND;
120640
120966
  }
120641
120967
  if (hasEventBoundProviderFailureEvidence(error48)) {
120642
120968
  this.scheduleProviderFailureDiagnosticsTelemetry({
@@ -120849,7 +121175,7 @@ var init_engine = __esm({
120849
121175
  runtime_live_status: "active",
120850
121176
  runtime_running: true,
120851
121177
  runtime_scheduler_phase: this._getSchedulerPhase(),
120852
- runtime_loop_interval_seconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / 1e3)),
121178
+ runtime_loop_interval_seconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND)),
120853
121179
  runtime_last_run_at: this._lastRunAt,
120854
121180
  runtime_next_run_at: this._nextRunAtMs == null ? null : new Date(this._nextRunAtMs).toISOString(),
120855
121181
  runtime_next_run_at_ms: this._nextRunAtMs,
@@ -120873,7 +121199,7 @@ var init_engine = __esm({
120873
121199
  if (!profileId) {
120874
121200
  return;
120875
121201
  }
120876
- const delayMs = Math.max(0, options.delayMs ?? 2500);
121202
+ const delayMs = Math.max(0, options.delayMs ?? CLIENT_RUNTIME_POLICY.provider_failure_diagnostics_delay_milliseconds);
120877
121203
  globalThis.setTimeout(() => {
120878
121204
  const diagnostics = buildRuntimeErrorDiagnostics(options.reason);
120879
121205
  const healthProbe = diagnostics.healthProbe && typeof diagnostics.healthProbe === "object" ? diagnostics.healthProbe : null;
@@ -120961,7 +121287,7 @@ var init_engine = __esm({
120961
121287
  eventProvenance?.modelSource ?? providerSetup?.provider ?? options?.modelSource ?? ""
120962
121288
  ).trim().toLowerCase() || null;
120963
121289
  const sanitizedReason = getSanitizedRuntimeErrorMessage(reason) || "Unknown runtime error.";
120964
- const retrySeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / 1e3));
121290
+ const retrySeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND));
120965
121291
  const executionProjection = options?.executionReasonCode ? projectExecutionErrorContract({
120966
121292
  error: sanitizedReason,
120967
121293
  symbol: options.executionSymbol,
@@ -121132,7 +121458,7 @@ var init_engine = __esm({
121132
121458
  const heartbeatLifecycleGeneration = this._lifecycleGeneration;
121133
121459
  const heartbeatLastRunAt = this._lastRunAt;
121134
121460
  const heartbeatNextRunAt = !this._primaryAnalysisDisabled && typeof this._nextRunAtMs === "number" && Number.isFinite(this._nextRunAtMs) ? new Date(this._nextRunAtMs).toISOString() : null;
121135
- const heartbeatLoopIntervalSeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / 1e3));
121461
+ const heartbeatLoopIntervalSeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND));
121136
121462
  const heartbeatSchedulerPhase = this._getSchedulerPhase();
121137
121463
  const heartbeatAnalysisRunId = this._primaryAnalysisDisabled || !this._isAnalysisInFlight() ? null : this._analysisRequestId;
121138
121464
  const heartbeatIsAnalyzing = !this._primaryAnalysisDisabled && (this._isAnalysisInFlight() || this._startupPendingAnalysis && options?.confirmGrant !== true || this._isExecuting);
@@ -121375,7 +121701,7 @@ var init_engine = __esm({
121375
121701
  }
121376
121702
  this._killswitchIntervalId = setInterval(
121377
121703
  () => void this._runClientKillswitchCheck(),
121378
- Math.max(1e3, Math.round(pollIntervalSeconds * 1e3))
121704
+ Math.max(CLIENT_RUNTIME_POLICY.killswitch_timer_floor_milliseconds, Math.round(pollIntervalSeconds * MS_PER_SECOND))
121379
121705
  );
121380
121706
  }
121381
121707
  async _runClientKillswitchCheck() {
@@ -121416,7 +121742,7 @@ var init_engine = __esm({
121416
121742
  new DOMException("Client killswitch check timed out.", "TimeoutError")
121417
121743
  );
121418
121744
  reject(new Error("Client killswitch check timed out."));
121419
- }, Math.round(checkTimeoutSeconds * 1e3));
121745
+ }, Math.round(checkTimeoutSeconds * MS_PER_SECOND));
121420
121746
  })
121421
121747
  ]);
121422
121748
  if (controller.signal.aborted || this._state !== "running" || this._mode !== "trader" || this._profileId !== profileId || this._sessionId !== sessionId || this._deviceId !== deviceId) {
@@ -121524,9 +121850,9 @@ var init_engine = __esm({
121524
121850
  const activeExecutionLoop = this._executionLoopPromise;
121525
121851
  if (activeExecutionLoop) {
121526
121852
  const executionFenceTimeoutMs = Math.max(
121527
- 1e3,
121853
+ CLIENT_RUNTIME_POLICY.killswitch_timer_floor_milliseconds,
121528
121854
  Math.round(
121529
- Number(config2.client_runtime_killswitch_close_timeout_seconds) * 1e3
121855
+ Number(config2.client_runtime_killswitch_close_timeout_seconds) * MS_PER_SECOND
121530
121856
  )
121531
121857
  );
121532
121858
  let executionFenceTimeoutId = null;
@@ -121581,7 +121907,7 @@ var init_engine = __esm({
121581
121907
  () => refreshController.abort(
121582
121908
  new DOMException("Client killswitch position refresh timed out.", "TimeoutError")
121583
121909
  ),
121584
- Math.round(closeTimeoutSeconds * 1e3)
121910
+ Math.round(closeTimeoutSeconds * MS_PER_SECOND)
121585
121911
  );
121586
121912
  try {
121587
121913
  freshPositions = (await fetchBrowserAccountState2({
@@ -123075,7 +123401,7 @@ var init_headless_runtime = __esm({
123075
123401
  DEFAULT_MAX_CLAIM_WAITS = 10;
123076
123402
  STOP_REQUEST_TIMEOUT_MS = 1e4;
123077
123403
  PROTECTION_IDLE_RECHECK_MS = runtime_policy_generated_default2.trading.engine.client_runtime.protective_actions.idle_recheck_seconds * 1e3;
123078
- PROTECTION_RETRY_MS = 15e3;
123404
+ PROTECTION_RETRY_MS = runtime_policy_generated_default2.trading.engine.client_runtime.protective_actions.retry_delay_seconds * 1e3;
123079
123405
  MAX_RESUMES_WITHOUT_A_CYCLE = 5;
123080
123406
  RESUME_BACKOFF_MS = [1e3, 5e3, 15e3, 3e4, 6e4];
123081
123407
  BACKUP_WAIT_TICK_MS = runtime_policy_generated_default2.trading.engine.client_runtime.reconcile.tick_interval_seconds * 1e3;