@vtxmacro/cli 2026.10.11 → 2026.10.13
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-mcp.js +312 -9
- package/bin/vtx-service-bootstrap.js +292 -8
- package/bin/vtx-service-launcher.js +291 -7
- package/bin/vtx.js +1181 -401
- package/package.json +1 -1
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.
|
|
116
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.13", 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,109 @@ 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
|
|
170
|
+
},
|
|
171
|
+
preferences: {
|
|
172
|
+
load_timeout_ms: 5e3,
|
|
173
|
+
initial_load_settle_ms: 100,
|
|
174
|
+
external_save_timeout_ms: 8e3,
|
|
175
|
+
guest_cookie_max_age_days: 9999
|
|
176
|
+
},
|
|
177
|
+
navigation_feedback: {
|
|
178
|
+
finish_fallback_ms: 2250
|
|
179
|
+
},
|
|
180
|
+
confirmation_notices: {
|
|
181
|
+
success_indicator_ms: 2e3,
|
|
182
|
+
byok_success_message_ms: 3e3
|
|
183
|
+
},
|
|
184
|
+
screener_runtime_config_retry: {
|
|
185
|
+
base_delay_ms: 1e3,
|
|
186
|
+
max_delay_ms: 3e4
|
|
187
|
+
},
|
|
188
|
+
advanced_chart: {
|
|
189
|
+
debug_log_throttle_ms: 1e3,
|
|
190
|
+
initial_history_stall_ms: 15e3,
|
|
191
|
+
initial_history_recovery_cooldown_ms: 3e4,
|
|
192
|
+
viewport_restore_settle_ms: 100,
|
|
193
|
+
symbol_price_wait_ms: 2e3,
|
|
194
|
+
layout_auto_save_delay_ms: 250
|
|
195
|
+
},
|
|
196
|
+
ai_panel: {
|
|
197
|
+
message_limit: 100,
|
|
198
|
+
post_execution_history_sync_delay_ms: 2e3,
|
|
199
|
+
runtime_error_attempt_group_window_seconds: 120,
|
|
200
|
+
debug_runtime_error_preview_chars: 180
|
|
201
|
+
},
|
|
202
|
+
insights_charts: {
|
|
203
|
+
max_charts: 3,
|
|
204
|
+
max_line_points: 160,
|
|
205
|
+
max_bars: 8
|
|
206
|
+
},
|
|
207
|
+
analysis_chat: {
|
|
208
|
+
new_message_scroll_delay_ms: 100
|
|
209
|
+
},
|
|
210
|
+
snapshot_selector: {
|
|
211
|
+
sync_resolution_pending_ms: 350,
|
|
212
|
+
own_broadcast_window_ms: 5e3,
|
|
213
|
+
seen_imported_ids_limit: 200,
|
|
214
|
+
post_import_reload_delay_ms: 1e3,
|
|
215
|
+
debug_value_chars: 220,
|
|
216
|
+
debug_fingerprint_head_chars: 64,
|
|
217
|
+
debug_head_snapshot_ids: 8,
|
|
218
|
+
debug_comparable_head_chars: 240,
|
|
219
|
+
debug_panel_comparable_head_chars: 120
|
|
220
|
+
},
|
|
221
|
+
debug_logs: {
|
|
222
|
+
snapshot_card_lines: 80,
|
|
223
|
+
render_debug_overlay_entries: 120,
|
|
224
|
+
render_debug_entry_data_chars: 2400,
|
|
225
|
+
analytics_dashboard_lines: 220,
|
|
226
|
+
analytics_metric_capture_interval_ms: 400,
|
|
227
|
+
system_profile_mode_lines: 120,
|
|
228
|
+
admin_text_chars: 160,
|
|
229
|
+
admin_analysis_run_id_chars: 32,
|
|
230
|
+
hyperliquid_balance_preview_count: 3,
|
|
231
|
+
model_picker_preview_count: 5
|
|
232
|
+
},
|
|
233
|
+
history_panels: {
|
|
234
|
+
display_batch_size: 50,
|
|
235
|
+
load_more_threshold_px: 100,
|
|
236
|
+
trade_history_fetch_page_size: 100,
|
|
237
|
+
ai_panel_interaction_window_ms: 2500,
|
|
238
|
+
ai_panel_defer_max_staleness_ms: 1e4,
|
|
239
|
+
ai_panel_defer_retry_ms: 1500
|
|
240
|
+
},
|
|
241
|
+
insights_access: {
|
|
242
|
+
initial_prompt_idea_count: 6,
|
|
243
|
+
section_preview_blocks: 2
|
|
244
|
+
},
|
|
245
|
+
marketing: {
|
|
246
|
+
arena_leaderboard_entries: 3
|
|
247
|
+
},
|
|
248
|
+
calendar: {
|
|
249
|
+
event_highlight_window_minutes: 60
|
|
250
|
+
},
|
|
251
|
+
system_page: {
|
|
252
|
+
hyperliquid_manual_refresh_cooldown_ms: 800
|
|
152
253
|
}
|
|
153
254
|
},
|
|
154
255
|
ai_dashboard: {
|
|
@@ -190,6 +291,9 @@ var init_runtime_policy_generated = __esm({
|
|
|
190
291
|
72,
|
|
191
292
|
168
|
|
192
293
|
]
|
|
294
|
+
},
|
|
295
|
+
defaults: {
|
|
296
|
+
max_chat_turns: 9999
|
|
193
297
|
}
|
|
194
298
|
},
|
|
195
299
|
trading: {
|
|
@@ -211,7 +315,12 @@ var init_runtime_policy_generated = __esm({
|
|
|
211
315
|
idle_recheck_seconds: 60,
|
|
212
316
|
attention_refresh_seconds: 60,
|
|
213
317
|
evidence_max_items: 32,
|
|
214
|
-
evidence_shared_read_seconds: 10
|
|
318
|
+
evidence_shared_read_seconds: 10,
|
|
319
|
+
retry_delay_seconds: 15
|
|
320
|
+
},
|
|
321
|
+
exchange_mutation: {
|
|
322
|
+
settlement_retry_milliseconds: 1e3,
|
|
323
|
+
settlement_retry_window_seconds: 120
|
|
215
324
|
},
|
|
216
325
|
protective_plan_set_lock: {
|
|
217
326
|
wait_seconds: 120
|
|
@@ -234,7 +343,15 @@ var init_runtime_policy_generated = __esm({
|
|
|
234
343
|
hyperliquid_snapshot: {
|
|
235
344
|
max_fills_per_execution: 20,
|
|
236
345
|
max_fill_payload_bytes: 32768
|
|
237
|
-
}
|
|
346
|
+
},
|
|
347
|
+
loop_early_return_retry_milliseconds: 5e3,
|
|
348
|
+
window_handoff_cleanup_retry_milliseconds: 1e3,
|
|
349
|
+
ai_schedule_pause_min_milliseconds: 1e3,
|
|
350
|
+
ai_schedule_pause_max_milliseconds: 36e5,
|
|
351
|
+
ai_schedule_pause_unknown_milliseconds: 6e4,
|
|
352
|
+
provider_failure_diagnostics_delay_milliseconds: 2500,
|
|
353
|
+
provider_failure_diagnostics_max_age_milliseconds: 3e4,
|
|
354
|
+
killswitch_timer_floor_milliseconds: 1e3
|
|
238
355
|
},
|
|
239
356
|
server_runtime: {
|
|
240
357
|
prompt_rescue: {
|
|
@@ -245,7 +362,14 @@ var init_runtime_policy_generated = __esm({
|
|
|
245
362
|
client_claim_retry_delay_milliseconds: 1e3,
|
|
246
363
|
client_failure_report_timeout_milliseconds: 2e3,
|
|
247
364
|
client_presence_heartbeat_interval_milliseconds: 3e4,
|
|
248
|
-
client_presence_http_timeout_milliseconds: 5e3
|
|
365
|
+
client_presence_http_timeout_milliseconds: 5e3,
|
|
366
|
+
client_claim_completion_buffer_milliseconds: 250,
|
|
367
|
+
client_max_concurrent_jobs_max: 32,
|
|
368
|
+
diagnostics_max_elapsed_ms: 12e4,
|
|
369
|
+
diagnostics_max_pending_reads: 1e3,
|
|
370
|
+
diagnostics_max_clock_offset_ms: 864e5,
|
|
371
|
+
failure_max_reported_weight: 1e6,
|
|
372
|
+
failure_max_retry_after_ms: 36e5
|
|
249
373
|
}
|
|
250
374
|
}
|
|
251
375
|
},
|
|
@@ -254,6 +378,10 @@ var init_runtime_policy_generated = __esm({
|
|
|
254
378
|
history_start_ms: 16409952e5,
|
|
255
379
|
device_read_deadline_seconds: 180,
|
|
256
380
|
device_recent_window_hours: 24
|
|
381
|
+
},
|
|
382
|
+
tradability: {
|
|
383
|
+
score_min: 1,
|
|
384
|
+
score_max: 10
|
|
257
385
|
}
|
|
258
386
|
},
|
|
259
387
|
agent_cli: {
|
|
@@ -278,11 +406,55 @@ var init_runtime_policy_generated = __esm({
|
|
|
278
406
|
restart_stable_uptime_ms: 6e4,
|
|
279
407
|
restart_backoff_base_ms: 1e3,
|
|
280
408
|
restart_backoff_max_ms: 3e4,
|
|
281
|
-
restart_exponent_max: 5
|
|
409
|
+
restart_exponent_max: 5,
|
|
410
|
+
cooperative_stop_timeout_ms: 75e3,
|
|
411
|
+
update_readiness_timeout_ms: 6e5,
|
|
412
|
+
rollback_confirmation_min_attempts: 100,
|
|
413
|
+
ready_consecutive_observations: 2,
|
|
414
|
+
control_lock_wait_attempts: 400,
|
|
415
|
+
control_lock_retry_interval_ms: 250,
|
|
416
|
+
supervisor_manifest_poll_interval_ms: 250,
|
|
417
|
+
worker_readiness_settle_ms: 500
|
|
282
418
|
},
|
|
283
419
|
claim_diagnostics: {
|
|
284
420
|
event_loop_sample_interval_ms: 100
|
|
285
|
-
}
|
|
421
|
+
},
|
|
422
|
+
host_runtime: {
|
|
423
|
+
advertisement_ttl_ms: 12e4,
|
|
424
|
+
advertisement_refresh_lead_ms: 3e4,
|
|
425
|
+
host_heartbeat_interval_ms: 3e3,
|
|
426
|
+
attempt_heartbeat_interval_ms: 3e3,
|
|
427
|
+
agent_heartbeat_interval_ms: 3e3,
|
|
428
|
+
agent_heartbeat_max_retry_delay_ms: 9e3,
|
|
429
|
+
provider_rate_limit_refresh_ms: 6e4,
|
|
430
|
+
drain_timeout_ms: 3e4,
|
|
431
|
+
remote_retry_limit: 3,
|
|
432
|
+
minimum_sleep_ms: 10,
|
|
433
|
+
heartbeat_gap_diagnostic_min_ms: 1e4,
|
|
434
|
+
heartbeat_gap_diagnostic_factor: 3,
|
|
435
|
+
agent_auth_cooldown_ms: 3e5,
|
|
436
|
+
agent_rate_limit_cooldown_ms: 6e4,
|
|
437
|
+
agent_transient_cooldown_ms: 5e3,
|
|
438
|
+
claim_start_window_min_ms: 5e3,
|
|
439
|
+
attempt_start_retry_delay_max_ms: 15e3,
|
|
440
|
+
claim_dispatch_batch_size: 16,
|
|
441
|
+
codex_quota_cooldown_max_ms: 6912e5,
|
|
442
|
+
attempt_start_retry_base_ms: 1e3,
|
|
443
|
+
attempt_start_retry_exponent_max: 4,
|
|
444
|
+
remote_retry_backoff_step_ms: 250,
|
|
445
|
+
remote_retry_backoff_max_ms: 1e3,
|
|
446
|
+
remote_retry_fallback_ms: 1e3,
|
|
447
|
+
access_token_refresh_lead_ms: 5e3,
|
|
448
|
+
rate_limit_read_timeout_max_ms: 2e3,
|
|
449
|
+
agent_idle_retry_ms: 1e3,
|
|
450
|
+
agent_idle_poll_ms: 5e3,
|
|
451
|
+
agent_turn_timeout_ms: 6e5,
|
|
452
|
+
codex_rate_limit_metadata_timeout_ms: 5e3,
|
|
453
|
+
codex_login_timeout_ms: 9e5,
|
|
454
|
+
codex_command_timeout_ms: 3e4
|
|
455
|
+
},
|
|
456
|
+
quota_membership_cooldown_seconds: 300,
|
|
457
|
+
transient_membership_cooldown_seconds: 30
|
|
286
458
|
},
|
|
287
459
|
desktop: {
|
|
288
460
|
runtime_watchdog: {
|
|
@@ -297,6 +469,9 @@ var init_runtime_policy_generated = __esm({
|
|
|
297
469
|
resource_scheduler: {
|
|
298
470
|
client_lock_ttl_milliseconds: 12e4,
|
|
299
471
|
client_poll_interval_milliseconds: 250
|
|
472
|
+
},
|
|
473
|
+
defaults: {
|
|
474
|
+
adaptive_schedule_enabled: true
|
|
300
475
|
}
|
|
301
476
|
},
|
|
302
477
|
deployment: {
|
|
@@ -415,6 +590,115 @@ var init_runtime_policy_generated = __esm({
|
|
|
415
590
|
benzinga: {
|
|
416
591
|
enabled: false
|
|
417
592
|
}
|
|
593
|
+
},
|
|
594
|
+
market_data: {
|
|
595
|
+
chart_interest: {
|
|
596
|
+
historical_backfill_candle_limit: 1e3,
|
|
597
|
+
heartbeat_retry_seconds: 15,
|
|
598
|
+
heartbeat_min_delay_ms: 1e3,
|
|
599
|
+
catch_up_candle_limit: 300
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
auth: {
|
|
603
|
+
tokens: {
|
|
604
|
+
email_2fa_code_length: 6,
|
|
605
|
+
totp_code_length: 6
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
android: {
|
|
609
|
+
app_host: {
|
|
610
|
+
profiles_refresh_interval_seconds: 60,
|
|
611
|
+
running_report_interval_seconds: 5,
|
|
612
|
+
page_identity_retry_seconds: 5,
|
|
613
|
+
profiles_read_timeout_seconds: 30
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
websocket: {
|
|
617
|
+
client_connection: {
|
|
618
|
+
reconnect_delay_ms: 3e3,
|
|
619
|
+
ping_interval_ms: 3e4,
|
|
620
|
+
message_flush_interval_ms: 16,
|
|
621
|
+
price_change_highlight_ms: 1e3,
|
|
622
|
+
debug_recent_channel_limit: 24
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
notifications: {
|
|
626
|
+
desktop: {
|
|
627
|
+
heartbeat_seconds: 20
|
|
628
|
+
},
|
|
629
|
+
telegram: {
|
|
630
|
+
connect_link_poll_ms: 3e3
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
validation: {
|
|
634
|
+
profile_handles: {
|
|
635
|
+
min_length: 3,
|
|
636
|
+
max_length: 20,
|
|
637
|
+
update_confirmation_ms: 3e3
|
|
638
|
+
}
|
|
639
|
+
},
|
|
640
|
+
profiles: {
|
|
641
|
+
limits: {
|
|
642
|
+
handle_changes_per_window: 2,
|
|
643
|
+
handle_change_window_days: 14
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
billing: {
|
|
647
|
+
credit_purchase: {
|
|
648
|
+
amount_usd_steps: [
|
|
649
|
+
10,
|
|
650
|
+
25,
|
|
651
|
+
50,
|
|
652
|
+
100,
|
|
653
|
+
500,
|
|
654
|
+
1e3
|
|
655
|
+
]
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
admin: {
|
|
659
|
+
page: {
|
|
660
|
+
credit_grant_amount_usd_steps: [
|
|
661
|
+
10,
|
|
662
|
+
25,
|
|
663
|
+
50,
|
|
664
|
+
100,
|
|
665
|
+
500,
|
|
666
|
+
1e3,
|
|
667
|
+
5e3,
|
|
668
|
+
1e4,
|
|
669
|
+
5e4,
|
|
670
|
+
1e5
|
|
671
|
+
],
|
|
672
|
+
user_lookup_blur_close_delay_ms: 200,
|
|
673
|
+
selected_user_refresh_delay_ms: 300,
|
|
674
|
+
handle_preview_count: 3
|
|
675
|
+
},
|
|
676
|
+
models: {
|
|
677
|
+
analytics: {
|
|
678
|
+
summary_failure_kinds: 3
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
user_search: {
|
|
682
|
+
min_query_length: 2
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
security: {
|
|
686
|
+
byok: {
|
|
687
|
+
max_provider_keys_per_provider: 5
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
analysis: {
|
|
691
|
+
live_request_candles: {
|
|
692
|
+
default_limit: 100
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
users: {
|
|
696
|
+
search: {
|
|
697
|
+
min_query_length: 2
|
|
698
|
+
}
|
|
699
|
+
},
|
|
700
|
+
referrals: {
|
|
701
|
+
code_max_length: 24
|
|
418
702
|
}
|
|
419
703
|
};
|
|
420
704
|
}
|
|
@@ -549,6 +833,24 @@ var init_config = __esm({
|
|
|
549
833
|
}
|
|
550
834
|
});
|
|
551
835
|
|
|
836
|
+
// lib/agent-core/stop-signals.ts
|
|
837
|
+
var HEADLESS_RUNTIME_STOP_SIGNALS, ignoreClosedTerminalWrites, dropWriteError;
|
|
838
|
+
var init_stop_signals = __esm({
|
|
839
|
+
"lib/agent-core/stop-signals.ts"() {
|
|
840
|
+
"use strict";
|
|
841
|
+
init_define_VTX_EXO_POLICY();
|
|
842
|
+
init_define_VTX_GROK_POLICY();
|
|
843
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
844
|
+
HEADLESS_RUNTIME_STOP_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
845
|
+
ignoreClosedTerminalWrites = () => {
|
|
846
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
847
|
+
if (!stream.listeners("error").includes(dropWriteError)) stream.on("error", dropWriteError);
|
|
848
|
+
}
|
|
849
|
+
};
|
|
850
|
+
dropWriteError = () => void 0;
|
|
851
|
+
}
|
|
852
|
+
});
|
|
853
|
+
|
|
552
854
|
// node_modules/smol-toml/dist/date.js
|
|
553
855
|
var DATE_TIME_RE, TomlDate;
|
|
554
856
|
var init_date = __esm({
|
|
@@ -1313,8 +1615,8 @@ import { lstat, mkdir as mkdir2, open, readdir as readdir2, readFile as readFile
|
|
|
1313
1615
|
import { homedir as homedir2 } from "node:os";
|
|
1314
1616
|
import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, relative, resolve, win32 as windowsPath } from "node:path";
|
|
1315
1617
|
function inferenceBaseDir(env) {
|
|
1316
|
-
const
|
|
1317
|
-
return
|
|
1618
|
+
const configured2 = String(env.VTX_INFERENCE_HOST_HOME || "").trim();
|
|
1619
|
+
return configured2 || join2(homedir2(), ".vtx", "inference-host");
|
|
1318
1620
|
}
|
|
1319
1621
|
function normalizeInferenceHostInstanceName(raw) {
|
|
1320
1622
|
const value = raw.trim().toLowerCase();
|
|
@@ -1807,32 +2109,32 @@ var init_config2 = __esm({
|
|
|
1807
2109
|
init_dist();
|
|
1808
2110
|
init_mcp_transport_config();
|
|
1809
2111
|
loadInferenceReceiptDurabilityTimeoutMs = async () => {
|
|
1810
|
-
let
|
|
2112
|
+
let configured2;
|
|
1811
2113
|
if (true) {
|
|
1812
|
-
|
|
2114
|
+
configured2 = 5e3;
|
|
1813
2115
|
} else {
|
|
1814
2116
|
const config2 = parse2(await readFile2(resolve(dirname2(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
1815
2117
|
const inference = config2.external_inference;
|
|
1816
|
-
|
|
2118
|
+
configured2 = Number(inference?.receipt_durability_timeout_seconds) * 1e3;
|
|
1817
2119
|
}
|
|
1818
|
-
if (!Number.isSafeInteger(
|
|
2120
|
+
if (!Number.isSafeInteger(configured2) || Number(configured2) < 1) {
|
|
1819
2121
|
throw new Error("Inference receipt durability timeout is missing or invalid.");
|
|
1820
2122
|
}
|
|
1821
|
-
return Number(
|
|
2123
|
+
return Number(configured2);
|
|
1822
2124
|
};
|
|
1823
2125
|
loadInferenceAgentDataRequestTimeoutMs = async () => {
|
|
1824
|
-
let
|
|
2126
|
+
let configured2;
|
|
1825
2127
|
if (true) {
|
|
1826
|
-
|
|
2128
|
+
configured2 = 9e4;
|
|
1827
2129
|
} else {
|
|
1828
2130
|
const config2 = parse2(await readFile2(resolve(dirname2(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
1829
2131
|
const mcp = config2.insights?.mcp;
|
|
1830
|
-
|
|
2132
|
+
configured2 = Number(mcp?.tool_timeout_seconds) * 1e3;
|
|
1831
2133
|
}
|
|
1832
|
-
if (!Number.isSafeInteger(
|
|
2134
|
+
if (!Number.isSafeInteger(configured2) || Number(configured2) < 1) {
|
|
1833
2135
|
throw new Error("Inference Agent data request timeout is missing or invalid.");
|
|
1834
2136
|
}
|
|
1835
|
-
return Number(
|
|
2137
|
+
return Number(configured2);
|
|
1836
2138
|
};
|
|
1837
2139
|
loadInferenceAgentCommandLockPolicy = async () => {
|
|
1838
2140
|
let waitTimeoutMs;
|
|
@@ -2764,6 +3066,7 @@ var init_updater = __esm({
|
|
|
2764
3066
|
init_agent_cli_release();
|
|
2765
3067
|
init_runtime_policy_generated();
|
|
2766
3068
|
init_config();
|
|
3069
|
+
init_stop_signals();
|
|
2767
3070
|
init_config2();
|
|
2768
3071
|
init_routing();
|
|
2769
3072
|
CLI_PACKAGE_NAME = "@vtxmacro/cli";
|
|
@@ -3076,11 +3379,11 @@ var init_updater = __esm({
|
|
|
3076
3379
|
};
|
|
3077
3380
|
cliAutoUpdateDisabled = (env) => /^(?:0|false|off|no)$/iu.test(String(env.VTX_CLI_AUTO_UPDATE ?? "").trim());
|
|
3078
3381
|
resolveRegistry = (env) => {
|
|
3079
|
-
const
|
|
3080
|
-
if (!
|
|
3382
|
+
const configured2 = String(env.VTX_CLI_UPDATE_REGISTRY || "").trim().replace(/\/+$/u, "");
|
|
3383
|
+
if (!configured2) return OFFICIAL_NPM_REGISTRY;
|
|
3081
3384
|
let url2;
|
|
3082
3385
|
try {
|
|
3083
|
-
url2 = new URL(
|
|
3386
|
+
url2 = new URL(configured2);
|
|
3084
3387
|
} catch {
|
|
3085
3388
|
throw new Error("VTX_CLI_UPDATE_REGISTRY is not a URL.");
|
|
3086
3389
|
}
|
|
@@ -3088,7 +3391,7 @@ var init_updater = __esm({
|
|
|
3088
3391
|
if (url2.protocol !== "https:" && !(url2.protocol === "http:" && loopback)) {
|
|
3089
3392
|
throw new Error("VTX_CLI_UPDATE_REGISTRY must be https, or http on loopback.");
|
|
3090
3393
|
}
|
|
3091
|
-
return
|
|
3394
|
+
return configured2;
|
|
3092
3395
|
};
|
|
3093
3396
|
validSelection = async (value, releasesPath) => {
|
|
3094
3397
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
@@ -3379,6 +3682,7 @@ var init_updater = __esm({
|
|
|
3379
3682
|
const stopped = new AbortController();
|
|
3380
3683
|
const tracker = {
|
|
3381
3684
|
stops: 0,
|
|
3685
|
+
hungUp: false,
|
|
3382
3686
|
child: null,
|
|
3383
3687
|
stopped: stopped.signal,
|
|
3384
3688
|
uninstall: () => void 0
|
|
@@ -3393,14 +3697,19 @@ var init_updater = __esm({
|
|
|
3393
3697
|
}
|
|
3394
3698
|
};
|
|
3395
3699
|
const forward = (signal) => () => {
|
|
3700
|
+
if (signal === "SIGHUP") {
|
|
3701
|
+
ignoreClosedTerminalWrites();
|
|
3702
|
+
if (tracker.stops === 0) tracker.hungUp = true;
|
|
3703
|
+
}
|
|
3396
3704
|
tracker.stops += 1;
|
|
3397
3705
|
stopped.abort();
|
|
3706
|
+
if (signal === "SIGHUP" && process.platform === "win32") return;
|
|
3398
3707
|
try {
|
|
3399
3708
|
tracker.child?.kill(signal);
|
|
3400
3709
|
} catch {
|
|
3401
3710
|
}
|
|
3402
3711
|
};
|
|
3403
|
-
const forwarded =
|
|
3712
|
+
const forwarded = HEADLESS_RUNTIME_STOP_SIGNALS.filter((signal) => signal !== "SIGINT").map((signal) => [signal, forward(signal)]);
|
|
3404
3713
|
process.on("SIGINT", onInterrupt);
|
|
3405
3714
|
for (const [signal, handler] of forwarded) process.on(signal, handler);
|
|
3406
3715
|
tracker.uninstall = () => {
|
|
@@ -3532,6 +3841,7 @@ var init_updater = __esm({
|
|
|
3532
3841
|
};
|
|
3533
3842
|
const stops = installStopTracker();
|
|
3534
3843
|
const endAfterStop = async (exitCode) => {
|
|
3844
|
+
if (stops.hungUp) return exitCode;
|
|
3535
3845
|
if (!await readRuntimeResume(supervisorEnv) || !dependencies.stopRuntimeBetweenChildren) return exitCode;
|
|
3536
3846
|
const stopExitCode = await dependencies.stopRuntimeBetweenChildren(supervisorEnv);
|
|
3537
3847
|
return stopExitCode === 0 ? exitCode : stopExitCode;
|
|
@@ -3775,6 +4085,84 @@ var init_updater = __esm({
|
|
|
3775
4085
|
}
|
|
3776
4086
|
});
|
|
3777
4087
|
|
|
4088
|
+
// lib/constants.ts
|
|
4089
|
+
var MS_PER_SECOND, SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, DAYS_PER_WEEK, MS_PER_MINUTE, SECONDS_PER_HOUR, SECONDS_PER_DAY, SECONDS_PER_WEEK, MINUTES_PER_DAY, MINUTES_PER_WEEK, MS_PER_HOUR, MS_PER_DAY, BACKOFF_GROWTH_FACTOR, HTTP_STATUS, HTTP_STATUS_MIN, HTTP_STATUS_MAX, HTTP_CLIENT_ERROR_MIN, HTTP_SERVER_ERROR_MIN, EXTERNAL_INFERENCE_LIMITS;
|
|
4090
|
+
var init_constants = __esm({
|
|
4091
|
+
"lib/constants.ts"() {
|
|
4092
|
+
"use strict";
|
|
4093
|
+
init_define_VTX_EXO_POLICY();
|
|
4094
|
+
init_define_VTX_GROK_POLICY();
|
|
4095
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
4096
|
+
MS_PER_SECOND = 1e3;
|
|
4097
|
+
SECONDS_PER_MINUTE = 60;
|
|
4098
|
+
MINUTES_PER_HOUR = 60;
|
|
4099
|
+
HOURS_PER_DAY = 24;
|
|
4100
|
+
DAYS_PER_WEEK = 7;
|
|
4101
|
+
MS_PER_MINUTE = MS_PER_SECOND * SECONDS_PER_MINUTE;
|
|
4102
|
+
SECONDS_PER_HOUR = SECONDS_PER_MINUTE * MINUTES_PER_HOUR;
|
|
4103
|
+
SECONDS_PER_DAY = SECONDS_PER_HOUR * HOURS_PER_DAY;
|
|
4104
|
+
SECONDS_PER_WEEK = SECONDS_PER_DAY * DAYS_PER_WEEK;
|
|
4105
|
+
MINUTES_PER_DAY = MINUTES_PER_HOUR * HOURS_PER_DAY;
|
|
4106
|
+
MINUTES_PER_WEEK = MINUTES_PER_DAY * DAYS_PER_WEEK;
|
|
4107
|
+
MS_PER_HOUR = MS_PER_MINUTE * MINUTES_PER_HOUR;
|
|
4108
|
+
MS_PER_DAY = MS_PER_HOUR * HOURS_PER_DAY;
|
|
4109
|
+
BACKOFF_GROWTH_FACTOR = 2;
|
|
4110
|
+
HTTP_STATUS = {
|
|
4111
|
+
BAD_REQUEST: 400,
|
|
4112
|
+
UNAUTHORIZED: 401,
|
|
4113
|
+
PAYMENT_REQUIRED: 402,
|
|
4114
|
+
FORBIDDEN: 403,
|
|
4115
|
+
NOT_FOUND: 404,
|
|
4116
|
+
REQUEST_TIMEOUT: 408,
|
|
4117
|
+
CONFLICT: 409,
|
|
4118
|
+
TOO_EARLY: 425,
|
|
4119
|
+
TOO_MANY_REQUESTS: 429,
|
|
4120
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
4121
|
+
BAD_GATEWAY: 502,
|
|
4122
|
+
SERVICE_UNAVAILABLE: 503,
|
|
4123
|
+
GATEWAY_TIMEOUT: 504
|
|
4124
|
+
};
|
|
4125
|
+
HTTP_STATUS_MIN = 100;
|
|
4126
|
+
HTTP_STATUS_MAX = 599;
|
|
4127
|
+
HTTP_CLIENT_ERROR_MIN = 400;
|
|
4128
|
+
HTTP_SERVER_ERROR_MIN = 500;
|
|
4129
|
+
EXTERNAL_INFERENCE_LIMITS = {
|
|
4130
|
+
max_prompt_bytes: 3e5,
|
|
4131
|
+
max_immutable_job_input_bytes: 3e5,
|
|
4132
|
+
max_candidate_plaintext_bytes: 3e5,
|
|
4133
|
+
// 300,000 bytes plus the AES-GCM tag encode to fewer than 700,000 base64url
|
|
4134
|
+
// characters, keeping completion requests below the global MCP request bound.
|
|
4135
|
+
max_ciphertext_chars: 7e5,
|
|
4136
|
+
max_status_hosts: 640,
|
|
4137
|
+
// A profile lane's account cascade (fallback inference hosts) after its
|
|
4138
|
+
// primary host. Published hosts compile it in, so it is a wire constant, not
|
|
4139
|
+
// the operator-tunable model_fallbacks.max_models.
|
|
4140
|
+
max_profile_fallbacks_per_lane: 127,
|
|
4141
|
+
// The immutable-input hash length-prefixes each field name and value as
|
|
4142
|
+
// big-endian unsigned integers of these sizes.
|
|
4143
|
+
hash_field_name_length_bytes: 2,
|
|
4144
|
+
hash_value_length_bytes: 8,
|
|
4145
|
+
max_job_claim_batch_size: 32,
|
|
4146
|
+
max_effective_models: 16,
|
|
4147
|
+
max_reasoning_efforts: 16,
|
|
4148
|
+
max_model_identities: 16,
|
|
4149
|
+
max_advertised_models: 64,
|
|
4150
|
+
// Largest provider-reported usage percentage accepted (overage can exceed 100).
|
|
4151
|
+
max_usage_percent: 1e6,
|
|
4152
|
+
// A provider's weekly quota reset or retry deadline lies at most this far ahead.
|
|
4153
|
+
provider_reset_max_days: 8,
|
|
4154
|
+
// Stderr bytes a host observes before truncating its diagnostics.
|
|
4155
|
+
stderr_observation_cap_bytes: 65536,
|
|
4156
|
+
// Tools a Grok tool-validation summary lists before truncating.
|
|
4157
|
+
max_grok_tool_summaries: 8,
|
|
4158
|
+
max_recent_failures: 32,
|
|
4159
|
+
max_status_bindings: 512,
|
|
4160
|
+
max_validation_error_codes: 128,
|
|
4161
|
+
max_discarded_fields: 128
|
|
4162
|
+
};
|
|
4163
|
+
}
|
|
4164
|
+
});
|
|
4165
|
+
|
|
3778
4166
|
// node_modules/zod/v4/core/core.js
|
|
3779
4167
|
// @__NO_SIDE_EFFECTS__
|
|
3780
4168
|
function $constructor(name, initializer3, params) {
|
|
@@ -18319,7 +18707,7 @@ var init_zod = __esm({
|
|
|
18319
18707
|
});
|
|
18320
18708
|
|
|
18321
18709
|
// lib/external-inference-contract.ts
|
|
18322
|
-
var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, grokToolValidationDiagnosticSchema, grokResponseIdentityDiagnosticSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostRuntimeRecoverySchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
18710
|
+
var EXTERNAL_INFERENCE_CONTRACT_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION, EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2, EXTERNAL_INFERENCE_ADVERTISEMENT_SCHEMA_VERSION, EXTERNAL_INFERENCE_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_COMPRESSED_INPUT_ENVELOPE_SCHEMA_VERSION, EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION, EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION, EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN, MAX_EXTERNAL_INFERENCE_STATUS_HOSTS, MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE, MAX_GENERATION, MAX_SAFE_INTEGER, MAX_PROMPT_BYTES, MAX_IMMUTABLE_JOB_INPUT_BYTES, MAX_CANDIDATE_PLAINTEXT_BYTES, MAX_CIPHERTEXT_CHARS, PROVIDER_RESET_MAX_MS, MAX_GROK_TOOL_SUMMARIES, STDERR_OBSERVATION_CAP_BYTES, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, rotateRight, sha256BytesHex, sha256Utf8Hex, computeImmutableJobInputSha256, identifierSchema, operationIdentifierSchema, sha256HexSchema, generationSchema, zeroBasedGenerationSchema, nonNegativeSafeIntegerSchema, positiveSafeIntegerSchema, sqlIntegerTokenCountSchema, timestampSchema, safeCodeSchema, processExitCodeSchema, externalInferenceAdapterIdSchema, reasoningEffortSchema, modelNameSchema, displayNameSchema, authenticatedAccountEmailSchema, protocolVersionSchema, base64UrlAlphabet, isCanonicalBase64Url, base64Url32BytesSchema, base64UrlNonceSchema, base64UrlCiphertextSchema, claimHandleSchema, boundedJsonTextSchema, boundedPromptTextSchema, laneSchema, botModeSchema, executionModeSchema, responseModeSchema, controlModeSchema, dispatchOutcomeSchema, responseOutcomeSchema, nativeModelControllerSchema, legacyExternalAgentModelControllerSchema, externalAgentModelControllerSchema, boundExternalAgentModelControllerSchema, externalAgentUnboundControllerSchema, externalAgentUnboundControllerV2Schema, orderedFallbackHostIdsSchema, externalInferenceFallbackHostIdsSchema, liveModelControllerSchema, snapshotModelControllerSchema, modelIdentityMappingSchema, advertisedModelSchema, hostAdvertisementSchema, envelopeAadSchema, validateEnvelopeAad, commonEnvelopeShape, sealedKeyWrapEnvelopeSchema, sealedInputEnvelopeSchema, sealedCandidateEnvelopeSchema, sealedEnvelopeSchema, screenerCandidateRuntimeBindingSchema, screenerClientLeaseBindingSchema, screenerRuntimeBindingSchema, serverRuntimeBindingSchema, clientRuntimeBindingSchema, runtimeBindingSchema, immutableJobInputSchema, canonicalizeJsonValue, serializeImmutableJobInput, reportedTokenUsageSchema, unavailableTokenUsageSchema, tokenUsageSchema, grokToolValidationDiagnosticSchema, grokResponseIdentityDiagnosticSchema, agentTurnReceiptSchema, agentConnectRequestSchema, agentNextRequestSchema, agentHeartbeatRequestSchema, emptyAgentNextResultSchema, claimedAgentNextResultSchema, agentNextResultSchema, agentCompleteRequestSchema, agentFailRequestSchema, requestedModelSelectionSchema, completedModelProvenanceSchema, attemptModelProvenanceSchema, providerWeeklyQuotaReadSchema, hostRuntimeRecoverySchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, controllerBindingStatusReadSchema, queueStatusReadSchema, outcomeStatusReadSchema, externalInferenceVolumeWindowReadSchema, externalInferenceFailureCountReadSchema, externalInferenceHostDiagnosticsReadSchema, externalInferenceProfileActivityReadSchema, externalInferenceStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
18323
18711
|
var init_external_inference_contract = __esm({
|
|
18324
18712
|
"lib/external-inference-contract.ts"() {
|
|
18325
18713
|
"use strict";
|
|
@@ -18327,6 +18715,7 @@ var init_external_inference_contract = __esm({
|
|
|
18327
18715
|
init_define_VTX_GROK_POLICY();
|
|
18328
18716
|
init_define_VTX_PI_MODEL_POLICY();
|
|
18329
18717
|
init_zod();
|
|
18718
|
+
init_constants();
|
|
18330
18719
|
EXTERNAL_INFERENCE_CONTRACT_VERSION = "external_inference.v1";
|
|
18331
18720
|
EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION = "external_inference_controller_v1";
|
|
18332
18721
|
EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2 = "external_inference_controller_v2";
|
|
@@ -18337,14 +18726,17 @@ var init_external_inference_contract = __esm({
|
|
|
18337
18726
|
LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION = "external_inference_job_input_v1";
|
|
18338
18727
|
EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION = "external_inference_usage_v1";
|
|
18339
18728
|
EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN = "vtx.external-inference.input-sha256.v1\0";
|
|
18340
|
-
MAX_EXTERNAL_INFERENCE_STATUS_HOSTS =
|
|
18341
|
-
MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE =
|
|
18729
|
+
MAX_EXTERNAL_INFERENCE_STATUS_HOSTS = EXTERNAL_INFERENCE_LIMITS.max_status_hosts;
|
|
18730
|
+
MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE = EXTERNAL_INFERENCE_LIMITS.max_profile_fallbacks_per_lane;
|
|
18342
18731
|
MAX_GENERATION = 2147483647;
|
|
18343
18732
|
MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
|
|
18344
|
-
MAX_PROMPT_BYTES =
|
|
18345
|
-
MAX_IMMUTABLE_JOB_INPUT_BYTES =
|
|
18346
|
-
MAX_CANDIDATE_PLAINTEXT_BYTES =
|
|
18347
|
-
MAX_CIPHERTEXT_CHARS =
|
|
18733
|
+
MAX_PROMPT_BYTES = EXTERNAL_INFERENCE_LIMITS.max_prompt_bytes;
|
|
18734
|
+
MAX_IMMUTABLE_JOB_INPUT_BYTES = EXTERNAL_INFERENCE_LIMITS.max_immutable_job_input_bytes;
|
|
18735
|
+
MAX_CANDIDATE_PLAINTEXT_BYTES = EXTERNAL_INFERENCE_LIMITS.max_candidate_plaintext_bytes;
|
|
18736
|
+
MAX_CIPHERTEXT_CHARS = EXTERNAL_INFERENCE_LIMITS.max_ciphertext_chars;
|
|
18737
|
+
PROVIDER_RESET_MAX_MS = EXTERNAL_INFERENCE_LIMITS.provider_reset_max_days * HOURS_PER_DAY * MINUTES_PER_HOUR * SECONDS_PER_MINUTE * MS_PER_SECOND;
|
|
18738
|
+
MAX_GROK_TOOL_SUMMARIES = EXTERNAL_INFERENCE_LIMITS.max_grok_tool_summaries;
|
|
18739
|
+
STDERR_OBSERVATION_CAP_BYTES = EXTERNAL_INFERENCE_LIMITS.stderr_observation_cap_bytes;
|
|
18348
18740
|
SHA256_INITIAL_STATE = new Uint32Array([
|
|
18349
18741
|
1779033703,
|
|
18350
18742
|
3144134277,
|
|
@@ -18501,12 +18893,12 @@ var init_external_inference_contract = __esm({
|
|
|
18501
18893
|
for (const [fieldName, value] of fields) {
|
|
18502
18894
|
const fieldNameBytes = encoder.encode(fieldName);
|
|
18503
18895
|
const valueBytes = encoder.encode(value);
|
|
18504
|
-
const fieldNameLength = new Uint8Array(
|
|
18896
|
+
const fieldNameLength = new Uint8Array(EXTERNAL_INFERENCE_LIMITS.hash_field_name_length_bytes);
|
|
18505
18897
|
new DataView(fieldNameLength.buffer).setUint16(0, fieldNameBytes.length, false);
|
|
18506
|
-
const valueLength = new Uint8Array(
|
|
18898
|
+
const valueLength = new Uint8Array(EXTERNAL_INFERENCE_LIMITS.hash_value_length_bytes);
|
|
18507
18899
|
const valueLengthView = new DataView(valueLength.buffer);
|
|
18508
18900
|
valueLengthView.setUint32(0, Math.floor(valueBytes.length / 4294967296), false);
|
|
18509
|
-
valueLengthView.setUint32(
|
|
18901
|
+
valueLengthView.setUint32(valueLength.length - Uint32Array.BYTES_PER_ELEMENT, valueBytes.length >>> 0, false);
|
|
18510
18902
|
chunks.push(fieldNameLength, fieldNameBytes, valueLength, valueBytes);
|
|
18511
18903
|
}
|
|
18512
18904
|
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
@@ -18643,7 +19035,7 @@ var init_external_inference_contract = __esm({
|
|
|
18643
19035
|
]);
|
|
18644
19036
|
modelIdentityMappingSchema = external_exports.strictObject({
|
|
18645
19037
|
requested_model: modelNameSchema,
|
|
18646
|
-
effective_models: external_exports.array(modelNameSchema).min(1).max(
|
|
19038
|
+
effective_models: external_exports.array(modelNameSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_effective_models)
|
|
18647
19039
|
}).superRefine((value, context) => {
|
|
18648
19040
|
if (new Set(value.effective_models).size !== value.effective_models.length) {
|
|
18649
19041
|
context.addIssue({
|
|
@@ -18658,11 +19050,11 @@ var init_external_inference_contract = __esm({
|
|
|
18658
19050
|
label: displayNameSchema,
|
|
18659
19051
|
adapter: externalInferenceAdapterIdSchema,
|
|
18660
19052
|
supported_lanes: external_exports.array(laneSchema).min(1).max(3),
|
|
18661
|
-
supported_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(
|
|
19053
|
+
supported_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_reasoning_efforts),
|
|
18662
19054
|
default_reasoning_effort: reasoningEffortSchema,
|
|
18663
19055
|
supported_response_modes: external_exports.array(responseModeSchema).min(1).max(2),
|
|
18664
19056
|
supported_control_modes: external_exports.array(controlModeSchema).min(1).max(2).optional(),
|
|
18665
|
-
allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(
|
|
19057
|
+
allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_model_identities),
|
|
18666
19058
|
structured_output: external_exports.boolean(),
|
|
18667
19059
|
same_attempt_recovery: external_exports.boolean(),
|
|
18668
19060
|
adapter_runtime_version: protocolVersionSchema
|
|
@@ -18714,7 +19106,7 @@ var init_external_inference_contract = __esm({
|
|
|
18714
19106
|
health: external_exports.enum(["healthy", "degraded", "draining"]),
|
|
18715
19107
|
advertised_at: timestampSchema,
|
|
18716
19108
|
expires_at: timestampSchema,
|
|
18717
|
-
models: external_exports.array(advertisedModelSchema).min(1).max(
|
|
19109
|
+
models: external_exports.array(advertisedModelSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_advertised_models)
|
|
18718
19110
|
}).superRefine((value, context) => {
|
|
18719
19111
|
if (value.provider_dispatch_freshness_contract !== void 0 && !/^\d+\.\d+\.\d+$/.test(value.host_runtime_version ?? "")) {
|
|
18720
19112
|
context.addIssue({ code: "custom", message: "Foreground freshness contract requires a numeric runtime version." });
|
|
@@ -18912,8 +19304,8 @@ var init_external_inference_contract = __esm({
|
|
|
18912
19304
|
controller: boundExternalAgentModelControllerSchema,
|
|
18913
19305
|
requested_model: modelNameSchema,
|
|
18914
19306
|
requested_reasoning_effort: reasoningEffortSchema,
|
|
18915
|
-
allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(
|
|
18916
|
-
allowed_effective_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(
|
|
19307
|
+
allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_model_identities),
|
|
19308
|
+
allowed_effective_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_reasoning_efforts),
|
|
18917
19309
|
response_mode: responseModeSchema,
|
|
18918
19310
|
output_schema_version: protocolVersionSchema,
|
|
18919
19311
|
parser_contract_version: protocolVersionSchema,
|
|
@@ -19102,12 +19494,12 @@ var init_external_inference_contract = __esm({
|
|
|
19102
19494
|
}).refine(
|
|
19103
19495
|
(tool) => tool.type === "redacted" === (tool.type_sha256 !== null) && tool.name === "redacted" === (tool.name_sha256 !== null),
|
|
19104
19496
|
{ message: "Only redacted tool identifiers require hashes." }
|
|
19105
|
-
)).max(
|
|
19497
|
+
)).max(MAX_GROK_TOOL_SUMMARIES),
|
|
19106
19498
|
tools_truncated: external_exports.boolean(),
|
|
19107
19499
|
prior_dispatch: external_exports.boolean(),
|
|
19108
19500
|
completed_response_count: nonNegativeSafeIntegerSchema
|
|
19109
19501
|
}).refine(
|
|
19110
|
-
(value) => value.tools_shape === "array" ? value.tool_count !== null && value.tools.length === Math.min(value.tool_count,
|
|
19502
|
+
(value) => value.tools_shape === "array" ? value.tool_count !== null && value.tools.length === Math.min(value.tool_count, MAX_GROK_TOOL_SUMMARIES) && value.tools_truncated === value.tool_count > MAX_GROK_TOOL_SUMMARIES : value.tool_count === null && value.tools.length === 0 && !value.tools_truncated,
|
|
19111
19503
|
{ message: "Grok tool diagnostic counts must match the observed shape." }
|
|
19112
19504
|
).refine(
|
|
19113
19505
|
(value) => value.prior_dispatch || value.completed_response_count === 0,
|
|
@@ -19327,13 +19719,13 @@ var init_external_inference_contract = __esm({
|
|
|
19327
19719
|
credits_available: external_exports.boolean().nullable().optional(),
|
|
19328
19720
|
rate_limit_reached: external_exports.boolean().nullable().optional(),
|
|
19329
19721
|
source: external_exports.literal("codex_app_server"),
|
|
19330
|
-
used_percent: external_exports.number().finite().min(0).max(
|
|
19722
|
+
used_percent: external_exports.number().finite().min(0).max(EXTERNAL_INFERENCE_LIMITS.max_usage_percent),
|
|
19331
19723
|
resets_at: timestampSchema,
|
|
19332
19724
|
observed_at: timestampSchema
|
|
19333
19725
|
}).superRefine((value, context) => {
|
|
19334
19726
|
const observedAt = Date.parse(value.observed_at);
|
|
19335
19727
|
const resetsAt = Date.parse(value.resets_at);
|
|
19336
|
-
if (resetsAt <= observedAt || resetsAt > observedAt +
|
|
19728
|
+
if (resetsAt <= observedAt || resetsAt > observedAt + PROVIDER_RESET_MAX_MS) {
|
|
19337
19729
|
context.addIssue({
|
|
19338
19730
|
code: "custom",
|
|
19339
19731
|
message: "weekly quota reset must follow observation within eight days",
|
|
@@ -19401,12 +19793,12 @@ var init_external_inference_contract = __esm({
|
|
|
19401
19793
|
external_exports.strictObject({
|
|
19402
19794
|
schema_version: external_exports.literal("external_inference_job_claim_v2"),
|
|
19403
19795
|
...jobClaimRequestBaseShape,
|
|
19404
|
-
maximum_jobs: external_exports.number().int().min(1).max(
|
|
19796
|
+
maximum_jobs: external_exports.number().int().min(1).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size)
|
|
19405
19797
|
}),
|
|
19406
19798
|
external_exports.strictObject({
|
|
19407
19799
|
schema_version: external_exports.literal("external_inference_job_claim_v3"),
|
|
19408
19800
|
...jobClaimRequestBaseShape,
|
|
19409
|
-
maximum_jobs: external_exports.number().int().min(1).max(
|
|
19801
|
+
maximum_jobs: external_exports.number().int().min(1).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size)
|
|
19410
19802
|
})
|
|
19411
19803
|
]);
|
|
19412
19804
|
emptyJobClaimSchema = external_exports.strictObject({
|
|
@@ -19461,14 +19853,14 @@ var init_external_inference_contract = __esm({
|
|
|
19461
19853
|
schema_version: external_exports.literal("external_inference_job_claim_result_v2"),
|
|
19462
19854
|
claim_state: external_exports.literal("batch"),
|
|
19463
19855
|
claim_request_id: operationIdentifierSchema,
|
|
19464
|
-
claims: external_exports.array(claimedDispatchIntentSchema).max(
|
|
19856
|
+
claims: external_exports.array(claimedDispatchIntentSchema).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size),
|
|
19465
19857
|
retry_after_ms: nonNegativeSafeIntegerSchema
|
|
19466
19858
|
});
|
|
19467
19859
|
timedBatchedJobClaimSchema = external_exports.strictObject({
|
|
19468
19860
|
schema_version: external_exports.literal("external_inference_job_claim_result_v3"),
|
|
19469
19861
|
claim_state: external_exports.literal("batch"),
|
|
19470
19862
|
claim_request_id: operationIdentifierSchema,
|
|
19471
|
-
claims: external_exports.array(claimedDispatchIntentSchema).max(
|
|
19863
|
+
claims: external_exports.array(claimedDispatchIntentSchema).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size),
|
|
19472
19864
|
retry_after_ms: nonNegativeSafeIntegerSchema,
|
|
19473
19865
|
server_processing_ms: nonNegativeSafeIntegerSchema
|
|
19474
19866
|
});
|
|
@@ -19619,7 +20011,7 @@ var init_external_inference_contract = __esm({
|
|
|
19619
20011
|
pending_request_count: nonNegativeSafeIntegerSchema.nullable(),
|
|
19620
20012
|
active_thread_count: nonNegativeSafeIntegerSchema.nullable(),
|
|
19621
20013
|
stderr_nonempty: external_exports.boolean().nullable(),
|
|
19622
|
-
stderr_bytes_observed: external_exports.number().int().min(0).max(
|
|
20014
|
+
stderr_bytes_observed: external_exports.number().int().min(0).max(STDERR_OBSERVATION_CAP_BYTES).nullable(),
|
|
19623
20015
|
stderr_truncated: external_exports.boolean().nullable(),
|
|
19624
20016
|
stderr_class: external_exports.enum([
|
|
19625
20017
|
"unknown",
|
|
@@ -19651,7 +20043,7 @@ var init_external_inference_contract = __esm({
|
|
|
19651
20043
|
} else if (value.stderr_bytes_observed === 0 || value.stderr_class === "none") {
|
|
19652
20044
|
context.addIssue({ code: "custom", message: "non-empty stderr diagnostics are inconsistent", path: ["stderr_nonempty"] });
|
|
19653
20045
|
}
|
|
19654
|
-
if (value.stderr_truncated && value.stderr_bytes_observed !==
|
|
20046
|
+
if (value.stderr_truncated && value.stderr_bytes_observed !== STDERR_OBSERVATION_CAP_BYTES) {
|
|
19655
20047
|
context.addIssue({ code: "custom", message: "truncated stderr diagnostics must report the observation cap", path: ["stderr_truncated"] });
|
|
19656
20048
|
}
|
|
19657
20049
|
});
|
|
@@ -19704,7 +20096,7 @@ var init_external_inference_contract = __esm({
|
|
|
19704
20096
|
if (value.provider_retry_at != null !== (value.provider_retry_source != null)) {
|
|
19705
20097
|
context.addIssue({ code: "custom", message: "provider retry deadline and source must be provided together", path: ["provider_retry_at"] });
|
|
19706
20098
|
}
|
|
19707
|
-
if (value.provider_retry_at != null && Date.parse(value.provider_retry_at) > Date.parse(value.failed_at) +
|
|
20099
|
+
if (value.provider_retry_at != null && Date.parse(value.provider_retry_at) > Date.parse(value.failed_at) + PROVIDER_RESET_MAX_MS) {
|
|
19708
20100
|
context.addIssue({ code: "custom", message: "provider retry deadline must be within eight days of failure", path: ["provider_retry_at"] });
|
|
19709
20101
|
}
|
|
19710
20102
|
if (value.outcome.response_outcome !== "none") {
|
|
@@ -19911,7 +20303,7 @@ var init_external_inference_contract = __esm({
|
|
|
19911
20303
|
advertisement_generation: generationSchema,
|
|
19912
20304
|
key_generation: generationSchema,
|
|
19913
20305
|
last_heartbeat_at: timestampSchema.nullable(),
|
|
19914
|
-
models: external_exports.array(advertisedModelSchema).max(
|
|
20306
|
+
models: external_exports.array(advertisedModelSchema).max(EXTERNAL_INFERENCE_LIMITS.max_advertised_models)
|
|
19915
20307
|
});
|
|
19916
20308
|
controllerBindingStatusReadSchema = external_exports.strictObject({
|
|
19917
20309
|
profile_name: external_exports.string().min(1).max(50),
|
|
@@ -19967,7 +20359,7 @@ var init_external_inference_contract = __esm({
|
|
|
19967
20359
|
last_hour: externalInferenceVolumeWindowReadSchema,
|
|
19968
20360
|
last_day: externalInferenceVolumeWindowReadSchema,
|
|
19969
20361
|
last_week: externalInferenceVolumeWindowReadSchema,
|
|
19970
|
-
recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(
|
|
20362
|
+
recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_recent_failures)
|
|
19971
20363
|
});
|
|
19972
20364
|
externalInferenceProfileActivityReadSchema = external_exports.strictObject({
|
|
19973
20365
|
last_hour: externalInferenceVolumeWindowReadSchema,
|
|
@@ -19980,7 +20372,7 @@ var init_external_inference_contract = __esm({
|
|
|
19980
20372
|
observed_at: timestampSchema,
|
|
19981
20373
|
catalog_generation: generationSchema,
|
|
19982
20374
|
hosts: external_exports.array(hostStatusReadSchema).max(MAX_EXTERNAL_INFERENCE_STATUS_HOSTS),
|
|
19983
|
-
bindings: external_exports.array(controllerBindingStatusReadSchema).max(
|
|
20375
|
+
bindings: external_exports.array(controllerBindingStatusReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_status_bindings),
|
|
19984
20376
|
binding_count: nonNegativeSafeIntegerSchema.optional().default(0),
|
|
19985
20377
|
bindings_truncated: external_exports.boolean().optional().default(false),
|
|
19986
20378
|
queue: queueStatusReadSchema,
|
|
@@ -20263,8 +20655,8 @@ var init_external_inference_contract = __esm({
|
|
|
20263
20655
|
parser_status: external_exports.enum(["not_run", "clean", "repaired", "fallback", "failed"]),
|
|
20264
20656
|
parsed_candidate_schema_version: protocolVersionSchema.nullable(),
|
|
20265
20657
|
parser_fallback_strategy: safeCodeSchema.nullable(),
|
|
20266
|
-
validation_error_codes: external_exports.array(safeCodeSchema).max(
|
|
20267
|
-
discarded_fields: external_exports.array(external_exports.string().min(1).max(128).regex(/^[A-Za-z0-9_.\[\]-]+$/)).max(
|
|
20658
|
+
validation_error_codes: external_exports.array(safeCodeSchema).max(EXTERNAL_INFERENCE_LIMITS.max_validation_error_codes),
|
|
20659
|
+
discarded_fields: external_exports.array(external_exports.string().min(1).max(128).regex(/^[A-Za-z0-9_.\[\]-]+$/)).max(EXTERNAL_INFERENCE_LIMITS.max_discarded_fields),
|
|
20268
20660
|
parsed_candidate_utf8: boundedJsonTextSchema.nullable(),
|
|
20269
20661
|
parsed_candidate_sha256: sha256HexSchema.nullable(),
|
|
20270
20662
|
disposition: external_exports.enum([
|
|
@@ -22121,7 +22513,10 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22121
22513
|
jitter_milliseconds: 750,
|
|
22122
22514
|
base_delay_milliseconds: 500,
|
|
22123
22515
|
min_delay_milliseconds: 250,
|
|
22124
|
-
max_delay_milliseconds: 1e4
|
|
22516
|
+
max_delay_milliseconds: 1e4,
|
|
22517
|
+
recovery_base_delay_milliseconds: 1e3,
|
|
22518
|
+
recovery_max_delay_milliseconds: 3e4,
|
|
22519
|
+
recovery_exponent_max: 5
|
|
22125
22520
|
},
|
|
22126
22521
|
trade_refresh_policy: {
|
|
22127
22522
|
server_config_stream_timeout_ms: 1e4,
|
|
@@ -22129,11 +22524,109 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22129
22524
|
copy_trading_status_poll_ms: 5e3,
|
|
22130
22525
|
post_execution_refresh_delay_ms: 3e3,
|
|
22131
22526
|
account_read_backoff_min_ms: 2e3,
|
|
22132
|
-
account_read_backoff_max_ms: 6e4
|
|
22527
|
+
account_read_backoff_max_ms: 6e4,
|
|
22528
|
+
ai_start_grace_min_ms: 45e3
|
|
22133
22529
|
},
|
|
22134
22530
|
deployment_reload_observability: {
|
|
22135
22531
|
bootstrap_max_error_events_per_page: 4,
|
|
22136
22532
|
bootstrap_max_profiles: 10
|
|
22533
|
+
},
|
|
22534
|
+
ws_fallback_polling: {
|
|
22535
|
+
screener_active_run_ms: 2500
|
|
22536
|
+
},
|
|
22537
|
+
deployment_reload: {
|
|
22538
|
+
version_poll_interval_seconds: 30,
|
|
22539
|
+
reload_delay_seconds: 5
|
|
22540
|
+
},
|
|
22541
|
+
profile_runtime_status: {
|
|
22542
|
+
sync_timeout_ms: 8e3,
|
|
22543
|
+
sync_concurrency: 3,
|
|
22544
|
+
refresh_interval_ms: 1e4,
|
|
22545
|
+
watchdog_interval_ms: 1e3,
|
|
22546
|
+
watchdog_grace_ms: 500
|
|
22547
|
+
},
|
|
22548
|
+
preferences: {
|
|
22549
|
+
load_timeout_ms: 5e3,
|
|
22550
|
+
initial_load_settle_ms: 100,
|
|
22551
|
+
external_save_timeout_ms: 8e3,
|
|
22552
|
+
guest_cookie_max_age_days: 9999
|
|
22553
|
+
},
|
|
22554
|
+
navigation_feedback: {
|
|
22555
|
+
finish_fallback_ms: 2250
|
|
22556
|
+
},
|
|
22557
|
+
confirmation_notices: {
|
|
22558
|
+
success_indicator_ms: 2e3,
|
|
22559
|
+
byok_success_message_ms: 3e3
|
|
22560
|
+
},
|
|
22561
|
+
screener_runtime_config_retry: {
|
|
22562
|
+
base_delay_ms: 1e3,
|
|
22563
|
+
max_delay_ms: 3e4
|
|
22564
|
+
},
|
|
22565
|
+
advanced_chart: {
|
|
22566
|
+
debug_log_throttle_ms: 1e3,
|
|
22567
|
+
initial_history_stall_ms: 15e3,
|
|
22568
|
+
initial_history_recovery_cooldown_ms: 3e4,
|
|
22569
|
+
viewport_restore_settle_ms: 100,
|
|
22570
|
+
symbol_price_wait_ms: 2e3,
|
|
22571
|
+
layout_auto_save_delay_ms: 250
|
|
22572
|
+
},
|
|
22573
|
+
ai_panel: {
|
|
22574
|
+
message_limit: 100,
|
|
22575
|
+
post_execution_history_sync_delay_ms: 2e3,
|
|
22576
|
+
runtime_error_attempt_group_window_seconds: 120,
|
|
22577
|
+
debug_runtime_error_preview_chars: 180
|
|
22578
|
+
},
|
|
22579
|
+
insights_charts: {
|
|
22580
|
+
max_charts: 3,
|
|
22581
|
+
max_line_points: 160,
|
|
22582
|
+
max_bars: 8
|
|
22583
|
+
},
|
|
22584
|
+
analysis_chat: {
|
|
22585
|
+
new_message_scroll_delay_ms: 100
|
|
22586
|
+
},
|
|
22587
|
+
snapshot_selector: {
|
|
22588
|
+
sync_resolution_pending_ms: 350,
|
|
22589
|
+
own_broadcast_window_ms: 5e3,
|
|
22590
|
+
seen_imported_ids_limit: 200,
|
|
22591
|
+
post_import_reload_delay_ms: 1e3,
|
|
22592
|
+
debug_value_chars: 220,
|
|
22593
|
+
debug_fingerprint_head_chars: 64,
|
|
22594
|
+
debug_head_snapshot_ids: 8,
|
|
22595
|
+
debug_comparable_head_chars: 240,
|
|
22596
|
+
debug_panel_comparable_head_chars: 120
|
|
22597
|
+
},
|
|
22598
|
+
debug_logs: {
|
|
22599
|
+
snapshot_card_lines: 80,
|
|
22600
|
+
render_debug_overlay_entries: 120,
|
|
22601
|
+
render_debug_entry_data_chars: 2400,
|
|
22602
|
+
analytics_dashboard_lines: 220,
|
|
22603
|
+
analytics_metric_capture_interval_ms: 400,
|
|
22604
|
+
system_profile_mode_lines: 120,
|
|
22605
|
+
admin_text_chars: 160,
|
|
22606
|
+
admin_analysis_run_id_chars: 32,
|
|
22607
|
+
hyperliquid_balance_preview_count: 3,
|
|
22608
|
+
model_picker_preview_count: 5
|
|
22609
|
+
},
|
|
22610
|
+
history_panels: {
|
|
22611
|
+
display_batch_size: 50,
|
|
22612
|
+
load_more_threshold_px: 100,
|
|
22613
|
+
trade_history_fetch_page_size: 100,
|
|
22614
|
+
ai_panel_interaction_window_ms: 2500,
|
|
22615
|
+
ai_panel_defer_max_staleness_ms: 1e4,
|
|
22616
|
+
ai_panel_defer_retry_ms: 1500
|
|
22617
|
+
},
|
|
22618
|
+
insights_access: {
|
|
22619
|
+
initial_prompt_idea_count: 6,
|
|
22620
|
+
section_preview_blocks: 2
|
|
22621
|
+
},
|
|
22622
|
+
marketing: {
|
|
22623
|
+
arena_leaderboard_entries: 3
|
|
22624
|
+
},
|
|
22625
|
+
calendar: {
|
|
22626
|
+
event_highlight_window_minutes: 60
|
|
22627
|
+
},
|
|
22628
|
+
system_page: {
|
|
22629
|
+
hyperliquid_manual_refresh_cooldown_ms: 800
|
|
22137
22630
|
}
|
|
22138
22631
|
},
|
|
22139
22632
|
ai_dashboard: {
|
|
@@ -22175,6 +22668,9 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22175
22668
|
72,
|
|
22176
22669
|
168
|
|
22177
22670
|
]
|
|
22671
|
+
},
|
|
22672
|
+
defaults: {
|
|
22673
|
+
max_chat_turns: 9999
|
|
22178
22674
|
}
|
|
22179
22675
|
},
|
|
22180
22676
|
trading: {
|
|
@@ -22196,7 +22692,12 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22196
22692
|
idle_recheck_seconds: 60,
|
|
22197
22693
|
attention_refresh_seconds: 60,
|
|
22198
22694
|
evidence_max_items: 32,
|
|
22199
|
-
evidence_shared_read_seconds: 10
|
|
22695
|
+
evidence_shared_read_seconds: 10,
|
|
22696
|
+
retry_delay_seconds: 15
|
|
22697
|
+
},
|
|
22698
|
+
exchange_mutation: {
|
|
22699
|
+
settlement_retry_milliseconds: 1e3,
|
|
22700
|
+
settlement_retry_window_seconds: 120
|
|
22200
22701
|
},
|
|
22201
22702
|
protective_plan_set_lock: {
|
|
22202
22703
|
wait_seconds: 120
|
|
@@ -22219,7 +22720,15 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22219
22720
|
hyperliquid_snapshot: {
|
|
22220
22721
|
max_fills_per_execution: 20,
|
|
22221
22722
|
max_fill_payload_bytes: 32768
|
|
22222
|
-
}
|
|
22723
|
+
},
|
|
22724
|
+
loop_early_return_retry_milliseconds: 5e3,
|
|
22725
|
+
window_handoff_cleanup_retry_milliseconds: 1e3,
|
|
22726
|
+
ai_schedule_pause_min_milliseconds: 1e3,
|
|
22727
|
+
ai_schedule_pause_max_milliseconds: 36e5,
|
|
22728
|
+
ai_schedule_pause_unknown_milliseconds: 6e4,
|
|
22729
|
+
provider_failure_diagnostics_delay_milliseconds: 2500,
|
|
22730
|
+
provider_failure_diagnostics_max_age_milliseconds: 3e4,
|
|
22731
|
+
killswitch_timer_floor_milliseconds: 1e3
|
|
22223
22732
|
},
|
|
22224
22733
|
server_runtime: {
|
|
22225
22734
|
prompt_rescue: {
|
|
@@ -22230,7 +22739,14 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22230
22739
|
client_claim_retry_delay_milliseconds: 1e3,
|
|
22231
22740
|
client_failure_report_timeout_milliseconds: 2e3,
|
|
22232
22741
|
client_presence_heartbeat_interval_milliseconds: 3e4,
|
|
22233
|
-
client_presence_http_timeout_milliseconds: 5e3
|
|
22742
|
+
client_presence_http_timeout_milliseconds: 5e3,
|
|
22743
|
+
client_claim_completion_buffer_milliseconds: 250,
|
|
22744
|
+
client_max_concurrent_jobs_max: 32,
|
|
22745
|
+
diagnostics_max_elapsed_ms: 12e4,
|
|
22746
|
+
diagnostics_max_pending_reads: 1e3,
|
|
22747
|
+
diagnostics_max_clock_offset_ms: 864e5,
|
|
22748
|
+
failure_max_reported_weight: 1e6,
|
|
22749
|
+
failure_max_retry_after_ms: 36e5
|
|
22234
22750
|
}
|
|
22235
22751
|
}
|
|
22236
22752
|
},
|
|
@@ -22239,6 +22755,10 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22239
22755
|
history_start_ms: 16409952e5,
|
|
22240
22756
|
device_read_deadline_seconds: 180,
|
|
22241
22757
|
device_recent_window_hours: 24
|
|
22758
|
+
},
|
|
22759
|
+
tradability: {
|
|
22760
|
+
score_min: 1,
|
|
22761
|
+
score_max: 10
|
|
22242
22762
|
}
|
|
22243
22763
|
},
|
|
22244
22764
|
agent_cli: {
|
|
@@ -22263,11 +22783,55 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22263
22783
|
restart_stable_uptime_ms: 6e4,
|
|
22264
22784
|
restart_backoff_base_ms: 1e3,
|
|
22265
22785
|
restart_backoff_max_ms: 3e4,
|
|
22266
|
-
restart_exponent_max: 5
|
|
22786
|
+
restart_exponent_max: 5,
|
|
22787
|
+
cooperative_stop_timeout_ms: 75e3,
|
|
22788
|
+
update_readiness_timeout_ms: 6e5,
|
|
22789
|
+
rollback_confirmation_min_attempts: 100,
|
|
22790
|
+
ready_consecutive_observations: 2,
|
|
22791
|
+
control_lock_wait_attempts: 400,
|
|
22792
|
+
control_lock_retry_interval_ms: 250,
|
|
22793
|
+
supervisor_manifest_poll_interval_ms: 250,
|
|
22794
|
+
worker_readiness_settle_ms: 500
|
|
22267
22795
|
},
|
|
22268
22796
|
claim_diagnostics: {
|
|
22269
22797
|
event_loop_sample_interval_ms: 100
|
|
22270
|
-
}
|
|
22798
|
+
},
|
|
22799
|
+
host_runtime: {
|
|
22800
|
+
advertisement_ttl_ms: 12e4,
|
|
22801
|
+
advertisement_refresh_lead_ms: 3e4,
|
|
22802
|
+
host_heartbeat_interval_ms: 3e3,
|
|
22803
|
+
attempt_heartbeat_interval_ms: 3e3,
|
|
22804
|
+
agent_heartbeat_interval_ms: 3e3,
|
|
22805
|
+
agent_heartbeat_max_retry_delay_ms: 9e3,
|
|
22806
|
+
provider_rate_limit_refresh_ms: 6e4,
|
|
22807
|
+
drain_timeout_ms: 3e4,
|
|
22808
|
+
remote_retry_limit: 3,
|
|
22809
|
+
minimum_sleep_ms: 10,
|
|
22810
|
+
heartbeat_gap_diagnostic_min_ms: 1e4,
|
|
22811
|
+
heartbeat_gap_diagnostic_factor: 3,
|
|
22812
|
+
agent_auth_cooldown_ms: 3e5,
|
|
22813
|
+
agent_rate_limit_cooldown_ms: 6e4,
|
|
22814
|
+
agent_transient_cooldown_ms: 5e3,
|
|
22815
|
+
claim_start_window_min_ms: 5e3,
|
|
22816
|
+
attempt_start_retry_delay_max_ms: 15e3,
|
|
22817
|
+
claim_dispatch_batch_size: 16,
|
|
22818
|
+
codex_quota_cooldown_max_ms: 6912e5,
|
|
22819
|
+
attempt_start_retry_base_ms: 1e3,
|
|
22820
|
+
attempt_start_retry_exponent_max: 4,
|
|
22821
|
+
remote_retry_backoff_step_ms: 250,
|
|
22822
|
+
remote_retry_backoff_max_ms: 1e3,
|
|
22823
|
+
remote_retry_fallback_ms: 1e3,
|
|
22824
|
+
access_token_refresh_lead_ms: 5e3,
|
|
22825
|
+
rate_limit_read_timeout_max_ms: 2e3,
|
|
22826
|
+
agent_idle_retry_ms: 1e3,
|
|
22827
|
+
agent_idle_poll_ms: 5e3,
|
|
22828
|
+
agent_turn_timeout_ms: 6e5,
|
|
22829
|
+
codex_rate_limit_metadata_timeout_ms: 5e3,
|
|
22830
|
+
codex_login_timeout_ms: 9e5,
|
|
22831
|
+
codex_command_timeout_ms: 3e4
|
|
22832
|
+
},
|
|
22833
|
+
quota_membership_cooldown_seconds: 300,
|
|
22834
|
+
transient_membership_cooldown_seconds: 30
|
|
22271
22835
|
},
|
|
22272
22836
|
desktop: {
|
|
22273
22837
|
runtime_watchdog: {
|
|
@@ -22282,6 +22846,9 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22282
22846
|
resource_scheduler: {
|
|
22283
22847
|
client_lock_ttl_milliseconds: 12e4,
|
|
22284
22848
|
client_poll_interval_milliseconds: 250
|
|
22849
|
+
},
|
|
22850
|
+
defaults: {
|
|
22851
|
+
adaptive_schedule_enabled: true
|
|
22285
22852
|
}
|
|
22286
22853
|
},
|
|
22287
22854
|
deployment: {
|
|
@@ -22400,6 +22967,115 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22400
22967
|
benzinga: {
|
|
22401
22968
|
enabled: false
|
|
22402
22969
|
}
|
|
22970
|
+
},
|
|
22971
|
+
market_data: {
|
|
22972
|
+
chart_interest: {
|
|
22973
|
+
historical_backfill_candle_limit: 1e3,
|
|
22974
|
+
heartbeat_retry_seconds: 15,
|
|
22975
|
+
heartbeat_min_delay_ms: 1e3,
|
|
22976
|
+
catch_up_candle_limit: 300
|
|
22977
|
+
}
|
|
22978
|
+
},
|
|
22979
|
+
auth: {
|
|
22980
|
+
tokens: {
|
|
22981
|
+
email_2fa_code_length: 6,
|
|
22982
|
+
totp_code_length: 6
|
|
22983
|
+
}
|
|
22984
|
+
},
|
|
22985
|
+
android: {
|
|
22986
|
+
app_host: {
|
|
22987
|
+
profiles_refresh_interval_seconds: 60,
|
|
22988
|
+
running_report_interval_seconds: 5,
|
|
22989
|
+
page_identity_retry_seconds: 5,
|
|
22990
|
+
profiles_read_timeout_seconds: 30
|
|
22991
|
+
}
|
|
22992
|
+
},
|
|
22993
|
+
websocket: {
|
|
22994
|
+
client_connection: {
|
|
22995
|
+
reconnect_delay_ms: 3e3,
|
|
22996
|
+
ping_interval_ms: 3e4,
|
|
22997
|
+
message_flush_interval_ms: 16,
|
|
22998
|
+
price_change_highlight_ms: 1e3,
|
|
22999
|
+
debug_recent_channel_limit: 24
|
|
23000
|
+
}
|
|
23001
|
+
},
|
|
23002
|
+
notifications: {
|
|
23003
|
+
desktop: {
|
|
23004
|
+
heartbeat_seconds: 20
|
|
23005
|
+
},
|
|
23006
|
+
telegram: {
|
|
23007
|
+
connect_link_poll_ms: 3e3
|
|
23008
|
+
}
|
|
23009
|
+
},
|
|
23010
|
+
validation: {
|
|
23011
|
+
profile_handles: {
|
|
23012
|
+
min_length: 3,
|
|
23013
|
+
max_length: 20,
|
|
23014
|
+
update_confirmation_ms: 3e3
|
|
23015
|
+
}
|
|
23016
|
+
},
|
|
23017
|
+
profiles: {
|
|
23018
|
+
limits: {
|
|
23019
|
+
handle_changes_per_window: 2,
|
|
23020
|
+
handle_change_window_days: 14
|
|
23021
|
+
}
|
|
23022
|
+
},
|
|
23023
|
+
billing: {
|
|
23024
|
+
credit_purchase: {
|
|
23025
|
+
amount_usd_steps: [
|
|
23026
|
+
10,
|
|
23027
|
+
25,
|
|
23028
|
+
50,
|
|
23029
|
+
100,
|
|
23030
|
+
500,
|
|
23031
|
+
1e3
|
|
23032
|
+
]
|
|
23033
|
+
}
|
|
23034
|
+
},
|
|
23035
|
+
admin: {
|
|
23036
|
+
page: {
|
|
23037
|
+
credit_grant_amount_usd_steps: [
|
|
23038
|
+
10,
|
|
23039
|
+
25,
|
|
23040
|
+
50,
|
|
23041
|
+
100,
|
|
23042
|
+
500,
|
|
23043
|
+
1e3,
|
|
23044
|
+
5e3,
|
|
23045
|
+
1e4,
|
|
23046
|
+
5e4,
|
|
23047
|
+
1e5
|
|
23048
|
+
],
|
|
23049
|
+
user_lookup_blur_close_delay_ms: 200,
|
|
23050
|
+
selected_user_refresh_delay_ms: 300,
|
|
23051
|
+
handle_preview_count: 3
|
|
23052
|
+
},
|
|
23053
|
+
models: {
|
|
23054
|
+
analytics: {
|
|
23055
|
+
summary_failure_kinds: 3
|
|
23056
|
+
}
|
|
23057
|
+
},
|
|
23058
|
+
user_search: {
|
|
23059
|
+
min_query_length: 2
|
|
23060
|
+
}
|
|
23061
|
+
},
|
|
23062
|
+
security: {
|
|
23063
|
+
byok: {
|
|
23064
|
+
max_provider_keys_per_provider: 5
|
|
23065
|
+
}
|
|
23066
|
+
},
|
|
23067
|
+
analysis: {
|
|
23068
|
+
live_request_candles: {
|
|
23069
|
+
default_limit: 100
|
|
23070
|
+
}
|
|
23071
|
+
},
|
|
23072
|
+
users: {
|
|
23073
|
+
search: {
|
|
23074
|
+
min_query_length: 2
|
|
23075
|
+
}
|
|
23076
|
+
},
|
|
23077
|
+
referrals: {
|
|
23078
|
+
code_max_length: 24
|
|
22403
23079
|
}
|
|
22404
23080
|
};
|
|
22405
23081
|
}
|
|
@@ -30090,6 +30766,8 @@ var init_codex_app_server = __esm({
|
|
|
30090
30766
|
init_define_VTX_EXO_POLICY();
|
|
30091
30767
|
init_define_VTX_GROK_POLICY();
|
|
30092
30768
|
init_define_VTX_PI_MODEL_POLICY();
|
|
30769
|
+
init_runtime_policy_generated();
|
|
30770
|
+
init_constants();
|
|
30093
30771
|
init_config2();
|
|
30094
30772
|
CODEX_INFERENCE_PERMISSION_PROFILE = "vtx_inference_readonly";
|
|
30095
30773
|
CODEX_AGENT_PERMISSION_PROFILE = "vtx_inference_agent";
|
|
@@ -30195,9 +30873,9 @@ var init_codex_app_server = __esm({
|
|
|
30195
30873
|
"workspace_owner_usage_limit_reached",
|
|
30196
30874
|
"workspace_member_usage_limit_reached"
|
|
30197
30875
|
];
|
|
30198
|
-
DEFAULT_CODEX_QUOTA_COOLDOWN_MS =
|
|
30199
|
-
MAX_CODEX_QUOTA_COOLDOWN_MS =
|
|
30200
|
-
CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS =
|
|
30876
|
+
DEFAULT_CODEX_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.quota_membership_cooldown_seconds * MS_PER_SECOND;
|
|
30877
|
+
MAX_CODEX_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.host_runtime.codex_quota_cooldown_max_ms;
|
|
30878
|
+
CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS = runtime_policy_generated_default.external_inference.transient_membership_cooldown_seconds * MS_PER_SECOND;
|
|
30201
30879
|
parseCreditsSnapshot = (value) => {
|
|
30202
30880
|
const candidate = objectOrNull(value);
|
|
30203
30881
|
if (!candidate || typeof candidate.hasCredits !== "boolean" || typeof candidate.unlimited !== "boolean" || candidate.balance != null && typeof candidate.balance !== "string") return null;
|
|
@@ -30242,7 +30920,7 @@ var init_codex_app_server = __esm({
|
|
|
30242
30920
|
);
|
|
30243
30921
|
for (const window2 of windows) {
|
|
30244
30922
|
if (window2.resetsAt === null) continue;
|
|
30245
|
-
const resetAtMs = window2.resetsAt *
|
|
30923
|
+
const resetAtMs = window2.resetsAt * MS_PER_SECOND;
|
|
30246
30924
|
if (!Number.isSafeInteger(resetAtMs)) continue;
|
|
30247
30925
|
if (window2.usedPercent >= 100) exhaustedResets.push(resetAtMs);
|
|
30248
30926
|
if (snapshot.rateLimitReachedType !== null || snapshot.spendControlReached === true) {
|
|
@@ -30371,8 +31049,8 @@ var init_codex_app_server = __esm({
|
|
|
30371
31049
|
if (!(variant in structured)) continue;
|
|
30372
31050
|
const details = objectOrNull(structured[variant]);
|
|
30373
31051
|
const rawStatus = details?.httpStatusCode;
|
|
30374
|
-
const httpStatusCode = Number.isSafeInteger(rawStatus) && Number(rawStatus) >=
|
|
30375
|
-
if (httpStatusCode ===
|
|
31052
|
+
const httpStatusCode = Number.isSafeInteger(rawStatus) && Number(rawStatus) >= HTTP_STATUS_MIN && Number(rawStatus) <= HTTP_STATUS_MAX ? Number(rawStatus) : null;
|
|
31053
|
+
if (httpStatusCode === HTTP_STATUS.UNAUTHORIZED) {
|
|
30376
31054
|
return {
|
|
30377
31055
|
code: "auth_expired",
|
|
30378
31056
|
category: "auth",
|
|
@@ -30380,7 +31058,7 @@ var init_codex_app_server = __esm({
|
|
|
30380
31058
|
httpStatusCode
|
|
30381
31059
|
};
|
|
30382
31060
|
}
|
|
30383
|
-
if (httpStatusCode ===
|
|
31061
|
+
if (httpStatusCode === HTTP_STATUS.TOO_MANY_REQUESTS) {
|
|
30384
31062
|
return {
|
|
30385
31063
|
code: "codex_rate_limited",
|
|
30386
31064
|
category: "adapter",
|
|
@@ -30388,9 +31066,9 @@ var init_codex_app_server = __esm({
|
|
|
30388
31066
|
httpStatusCode
|
|
30389
31067
|
};
|
|
30390
31068
|
}
|
|
30391
|
-
if (httpStatusCode !== null && httpStatusCode >=
|
|
31069
|
+
if (httpStatusCode !== null && httpStatusCode >= HTTP_CLIENT_ERROR_MIN && httpStatusCode < HTTP_SERVER_ERROR_MIN && httpStatusCode !== HTTP_STATUS.REQUEST_TIMEOUT && httpStatusCode !== HTTP_STATUS.TOO_EARLY) {
|
|
30392
31070
|
const semanticText = JSON.stringify(details || {}).toLowerCase();
|
|
30393
|
-
if (httpStatusCode ===
|
|
31071
|
+
if (httpStatusCode === HTTP_STATUS.PAYMENT_REQUIRED || /(quota|credit|spend|payment|subscription.*limit)/u.test(semanticText)) {
|
|
30394
31072
|
return {
|
|
30395
31073
|
code: "quota_exceeded",
|
|
30396
31074
|
category: "model",
|
|
@@ -30398,7 +31076,7 @@ var init_codex_app_server = __esm({
|
|
|
30398
31076
|
httpStatusCode
|
|
30399
31077
|
};
|
|
30400
31078
|
}
|
|
30401
|
-
if (httpStatusCode ===
|
|
31079
|
+
if (httpStatusCode === HTTP_STATUS.FORBIDDEN && /(auth|account|workspace|billing|entitlement)/u.test(semanticText)) {
|
|
30402
31080
|
return {
|
|
30403
31081
|
code: "auth_expired",
|
|
30404
31082
|
category: "auth",
|
|
@@ -30406,7 +31084,7 @@ var init_codex_app_server = __esm({
|
|
|
30406
31084
|
httpStatusCode
|
|
30407
31085
|
};
|
|
30408
31086
|
}
|
|
30409
|
-
if (httpStatusCode ===
|
|
31087
|
+
if (httpStatusCode === HTTP_STATUS.FORBIDDEN && /(policy|safety|cyber)/u.test(semanticText)) {
|
|
30410
31088
|
return {
|
|
30411
31089
|
code: "codex_policy_rejected",
|
|
30412
31090
|
category: "adapter",
|
|
@@ -30415,7 +31093,7 @@ var init_codex_app_server = __esm({
|
|
|
30415
31093
|
};
|
|
30416
31094
|
}
|
|
30417
31095
|
return {
|
|
30418
|
-
code: httpStatusCode ===
|
|
31096
|
+
code: httpStatusCode === HTTP_STATUS.BAD_REQUEST ? "codex_bad_request" : "codex_http_client_error",
|
|
30419
31097
|
category: "adapter",
|
|
30420
31098
|
retryable: false,
|
|
30421
31099
|
httpStatusCode
|
|
@@ -30424,7 +31102,7 @@ var init_codex_app_server = __esm({
|
|
|
30424
31102
|
return {
|
|
30425
31103
|
code,
|
|
30426
31104
|
category: "adapter",
|
|
30427
|
-
retryable: httpStatusCode === null ? true : httpStatusCode ===
|
|
31105
|
+
retryable: httpStatusCode === null ? true : httpStatusCode === HTTP_STATUS.REQUEST_TIMEOUT || httpStatusCode === HTTP_STATUS.TOO_EARLY || httpStatusCode >= HTTP_SERVER_ERROR_MIN,
|
|
30428
31106
|
httpStatusCode
|
|
30429
31107
|
};
|
|
30430
31108
|
}
|
|
@@ -30844,7 +31522,7 @@ child.once('close', async (code, signal) => {
|
|
|
30844
31522
|
});
|
|
30845
31523
|
}
|
|
30846
31524
|
static {
|
|
30847
|
-
this.STDERR_OBSERVATION_CAP_BYTES =
|
|
31525
|
+
this.STDERR_OBSERVATION_CAP_BYTES = EXTERNAL_INFERENCE_LIMITS.stderr_observation_cap_bytes;
|
|
30848
31526
|
}
|
|
30849
31527
|
static {
|
|
30850
31528
|
this.STDERR_CLASSIFICATION_TAIL_CHARS = 1024;
|
|
@@ -32221,13 +32899,13 @@ child.once('close', async (code, signal) => {
|
|
|
32221
32899
|
const observedUsage = threadUsage ?? rawResponseUsage;
|
|
32222
32900
|
let retryAtMs = null;
|
|
32223
32901
|
let observedRateLimits = null;
|
|
32224
|
-
if (failure2.code === "quota_exceeded" || failure2.httpStatusCode ===
|
|
32902
|
+
if (failure2.code === "quota_exceeded" || failure2.httpStatusCode === HTTP_STATUS.TOO_MANY_REQUESTS) {
|
|
32225
32903
|
const observedAtMs = Date.now();
|
|
32226
32904
|
let accountLimitReached = failure2.code === "quota_exceeded";
|
|
32227
32905
|
try {
|
|
32228
32906
|
const metadataDeadlineAtMs = Math.min(
|
|
32229
32907
|
request.deadlineAtMs,
|
|
32230
|
-
observedAtMs +
|
|
32908
|
+
observedAtMs + runtime_policy_generated_default.external_inference.host_runtime.codex_rate_limit_metadata_timeout_ms
|
|
32231
32909
|
);
|
|
32232
32910
|
if (metadataDeadlineAtMs <= observedAtMs) throw new Error("rate-limit deadline elapsed");
|
|
32233
32911
|
observedRateLimits = await this.readAccountRateLimits(
|
|
@@ -32930,13 +33608,15 @@ function createDefaultInferenceHostRunnerDependencies(options) {
|
|
|
32930
33608
|
envelopePublicKey: options.envelopePublicKey
|
|
32931
33609
|
};
|
|
32932
33610
|
}
|
|
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,
|
|
33611
|
+
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
33612
|
var init_runner = __esm({
|
|
32935
33613
|
"lib/inference-host/runner.ts"() {
|
|
32936
33614
|
"use strict";
|
|
32937
33615
|
init_define_VTX_EXO_POLICY();
|
|
32938
33616
|
init_define_VTX_GROK_POLICY();
|
|
32939
33617
|
init_define_VTX_PI_MODEL_POLICY();
|
|
33618
|
+
init_runtime_policy_generated();
|
|
33619
|
+
init_constants();
|
|
32940
33620
|
import_ajv = __toESM(require_ajv(), 1);
|
|
32941
33621
|
init_external_inference_contract();
|
|
32942
33622
|
init_config2();
|
|
@@ -32950,29 +33630,30 @@ var init_runner = __esm({
|
|
|
32950
33630
|
providerHttpStatus = (error48) => {
|
|
32951
33631
|
if (!(error48 instanceof CodexAppServerError)) return null;
|
|
32952
33632
|
const status = error48.httpStatusCode;
|
|
32953
|
-
return typeof status === "number" && Number.isInteger(status) && status >=
|
|
33633
|
+
return typeof status === "number" && Number.isInteger(status) && status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_STATUS_MAX ? status : null;
|
|
32954
33634
|
};
|
|
32955
33635
|
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
33636
|
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
33637
|
RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
|
|
32958
33638
|
ATTEMPT_RECEIPT_SCHEMA_VERSION = "vtx_inference_attempt_receipt_v1";
|
|
32959
|
-
|
|
32960
|
-
|
|
32961
|
-
|
|
32962
|
-
|
|
32963
|
-
|
|
32964
|
-
|
|
32965
|
-
|
|
32966
|
-
|
|
32967
|
-
|
|
32968
|
-
|
|
32969
|
-
|
|
32970
|
-
|
|
32971
|
-
|
|
32972
|
-
|
|
32973
|
-
|
|
32974
|
-
|
|
32975
|
-
|
|
33639
|
+
HOST_RUNTIME_POLICY = runtime_policy_generated_default.external_inference.host_runtime;
|
|
33640
|
+
CLAIM_DISPATCH_BATCH_SIZE = HOST_RUNTIME_POLICY.claim_dispatch_batch_size;
|
|
33641
|
+
DEFAULT_ADVERTISEMENT_TTL_MS = HOST_RUNTIME_POLICY.advertisement_ttl_ms;
|
|
33642
|
+
DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS = HOST_RUNTIME_POLICY.advertisement_refresh_lead_ms;
|
|
33643
|
+
DEFAULT_HOST_HEARTBEAT_MS = HOST_RUNTIME_POLICY.host_heartbeat_interval_ms;
|
|
33644
|
+
DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS = HOST_RUNTIME_POLICY.provider_rate_limit_refresh_ms;
|
|
33645
|
+
DEFAULT_ATTEMPT_HEARTBEAT_MS = HOST_RUNTIME_POLICY.attempt_heartbeat_interval_ms;
|
|
33646
|
+
DEFAULT_DRAIN_TIMEOUT_MS = HOST_RUNTIME_POLICY.drain_timeout_ms;
|
|
33647
|
+
DEFAULT_REMOTE_RETRY_LIMIT = HOST_RUNTIME_POLICY.remote_retry_limit;
|
|
33648
|
+
MIN_SLEEP_MS = HOST_RUNTIME_POLICY.minimum_sleep_ms;
|
|
33649
|
+
MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS = HOST_RUNTIME_POLICY.heartbeat_gap_diagnostic_min_ms;
|
|
33650
|
+
HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR = HOST_RUNTIME_POLICY.heartbeat_gap_diagnostic_factor;
|
|
33651
|
+
DEFAULT_QUOTA_COOLDOWN_MS = runtime_policy_generated_default.external_inference.quota_membership_cooldown_seconds * MS_PER_SECOND;
|
|
33652
|
+
DEFAULT_AGENT_AUTH_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_auth_cooldown_ms;
|
|
33653
|
+
DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_rate_limit_cooldown_ms;
|
|
33654
|
+
DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS = HOST_RUNTIME_POLICY.agent_transient_cooldown_ms;
|
|
33655
|
+
MIN_CLAIM_START_WINDOW_MS = HOST_RUNTIME_POLICY.claim_start_window_min_ms;
|
|
33656
|
+
MAX_ATTEMPT_START_RETRY_DELAY_MS = HOST_RUNTIME_POLICY.attempt_start_retry_delay_max_ms;
|
|
32976
33657
|
UNBOUNDED_AVAILABLE_SLOTS = Number.MAX_SAFE_INTEGER;
|
|
32977
33658
|
buildInferenceAdvertisedModels = (capabilities, adapterRuntimeVersion, adapter = "codex", structuredOutput = true, sameAttemptRecovery = adapter === "codex", supportedControlModes = ["provider"]) => {
|
|
32978
33659
|
const visible = capabilities.filter((capability) => !capability.hidden);
|
|
@@ -33276,7 +33957,7 @@ var init_runner = __esm({
|
|
|
33276
33957
|
providerWeeklyQuotaFromRateLimits = (rateLimits, observedAtMs, currentTimeMs = observedAtMs, includeCredits = true) => {
|
|
33277
33958
|
if (!rateLimits) return null;
|
|
33278
33959
|
for (const window2 of [rateLimits.rateLimits.primary, rateLimits.rateLimits.secondary]) {
|
|
33279
|
-
if (window2?.windowDurationMins !==
|
|
33960
|
+
if (window2?.windowDurationMins !== DAYS_PER_WEEK * HOURS_PER_DAY * MINUTES_PER_HOUR || window2.resetsAt === null || window2.resetsAt * MS_PER_SECOND <= currentTimeMs) continue;
|
|
33280
33961
|
return {
|
|
33281
33962
|
source: "codex_app_server",
|
|
33282
33963
|
...includeCredits ? {
|
|
@@ -33284,7 +33965,7 @@ var init_runner = __esm({
|
|
|
33284
33965
|
rate_limit_reached: codexAccountRateLimitReached(rateLimits)
|
|
33285
33966
|
} : {},
|
|
33286
33967
|
used_percent: window2.usedPercent,
|
|
33287
|
-
resets_at: isoAt(window2.resetsAt *
|
|
33968
|
+
resets_at: isoAt(window2.resetsAt * MS_PER_SECOND),
|
|
33288
33969
|
observed_at: isoAt(observedAtMs)
|
|
33289
33970
|
};
|
|
33290
33971
|
}
|
|
@@ -33294,7 +33975,7 @@ var init_runner = __esm({
|
|
|
33294
33975
|
const window2 = rateLimits.rateLimits[key];
|
|
33295
33976
|
const known = previous?.[key];
|
|
33296
33977
|
if (known && (!window2 || window2.windowDurationMins !== known.windowDurationMins)) return false;
|
|
33297
|
-
return window2 === null || window2.resetsAt !== null && window2.resetsAt *
|
|
33978
|
+
return window2 === null || window2.resetsAt !== null && window2.resetsAt * MS_PER_SECOND > nowMs2 && (window2.usedPercent < 100 || codexCreditsAvailable(rateLimits.rateLimits));
|
|
33298
33979
|
});
|
|
33299
33980
|
finitePositiveOption = (value, fallback, label2) => {
|
|
33300
33981
|
const result = value ?? fallback;
|
|
@@ -33572,7 +34253,7 @@ var init_runner = __esm({
|
|
|
33572
34253
|
};
|
|
33573
34254
|
publicServerFailureCode = (value) => value !== null && /^[a-z0-9][a-z0-9._-]{0,95}$/u.test(value) ? value : null;
|
|
33574
34255
|
attemptStartRetryFallbackMs = (retryCount) => Math.min(
|
|
33575
|
-
|
|
34256
|
+
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
34257
|
MAX_ATTEMPT_START_RETRY_DELAY_MS
|
|
33577
34258
|
);
|
|
33578
34259
|
exactJson2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
@@ -33831,7 +34512,7 @@ var init_runner = __esm({
|
|
|
33831
34512
|
assertLocalCredentialIdentity(localState, refreshed.credential);
|
|
33832
34513
|
credential = refreshed.credential;
|
|
33833
34514
|
access7 = refreshed;
|
|
33834
|
-
accessExpiresAt = now() + refreshed.expiresIn *
|
|
34515
|
+
accessExpiresAt = now() + refreshed.expiresIn * MS_PER_SECOND;
|
|
33835
34516
|
return refreshed.accessToken;
|
|
33836
34517
|
})();
|
|
33837
34518
|
try {
|
|
@@ -33843,7 +34524,7 @@ var init_runner = __esm({
|
|
|
33843
34524
|
await refreshAccessToken({ signal: this.options.signal });
|
|
33844
34525
|
const tokenSource = {
|
|
33845
34526
|
accessToken: async (requestOptions) => {
|
|
33846
|
-
if (!access7 || accessExpiresAt - now() <=
|
|
34527
|
+
if (!access7 || accessExpiresAt - now() <= HOST_RUNTIME_POLICY.access_token_refresh_lead_ms) {
|
|
33847
34528
|
return refreshAccessToken(requestOptions);
|
|
33848
34529
|
}
|
|
33849
34530
|
return access7.accessToken;
|
|
@@ -33944,7 +34625,7 @@ var init_runner = __esm({
|
|
|
33944
34625
|
const runtimeState = await readInferenceAgentRuntimeState(
|
|
33945
34626
|
agentRuntimeSettings.statePath
|
|
33946
34627
|
);
|
|
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" ?
|
|
34628
|
+
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
34629
|
await writeInferenceAgentFailureFence(agentRuntimeSettings.statePath, {
|
|
33949
34630
|
schema_version: "vtx_inference_agent_failure_fence_v1",
|
|
33950
34631
|
adapter_id: settings.adapterId,
|
|
@@ -33977,7 +34658,7 @@ var init_runner = __esm({
|
|
|
33977
34658
|
const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
|
|
33978
34659
|
const fence = await readInferenceAgentFailureFence(agentRuntimeSettings.statePath);
|
|
33979
34660
|
if (!fence || !canReplayFencedAgentTerminal(retained, fence)) return;
|
|
33980
|
-
await sleep4(
|
|
34661
|
+
await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch(() => void 0);
|
|
33981
34662
|
continue;
|
|
33982
34663
|
}
|
|
33983
34664
|
try {
|
|
@@ -33997,7 +34678,7 @@ var init_runner = __esm({
|
|
|
33997
34678
|
const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
|
|
33998
34679
|
if (!retained || retained.schema_version !== "vtx_inference_agent_runtime_v3" || !retained.pending_turn?.terminal_receipt) return;
|
|
33999
34680
|
if (this.options.once) return;
|
|
34000
|
-
await sleep4(
|
|
34681
|
+
await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
|
|
34001
34682
|
if (!quiesceRequested) throw error49;
|
|
34002
34683
|
});
|
|
34003
34684
|
continue;
|
|
@@ -34011,7 +34692,7 @@ var init_runner = __esm({
|
|
|
34011
34692
|
});
|
|
34012
34693
|
if (this.options.once) return;
|
|
34013
34694
|
try {
|
|
34014
|
-
await sleep4(
|
|
34695
|
+
await sleep4(HOST_RUNTIME_POLICY.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
|
|
34015
34696
|
if (!quiesceRequested) throw error49;
|
|
34016
34697
|
});
|
|
34017
34698
|
} catch {
|
|
@@ -34132,7 +34813,7 @@ var init_runner = __esm({
|
|
|
34132
34813
|
if (!retryableRemoteError(error48) || error48 instanceof ExternalInferenceMcpError && error48.definitivelyNotApplied || attempt === settings.remoteRetryLimit) throw error48;
|
|
34133
34814
|
const requestedRetryDelay = remoteRetryAfterMs(
|
|
34134
34815
|
error48,
|
|
34135
|
-
Math.min(
|
|
34816
|
+
Math.min(HOST_RUNTIME_POLICY.remote_retry_backoff_step_ms * attempt, HOST_RUNTIME_POLICY.remote_retry_backoff_max_ms)
|
|
34136
34817
|
);
|
|
34137
34818
|
const remaining = boundary.deadlineAtMs === void 0 ? Number.POSITIVE_INFINITY : Math.max(0, boundary.deadlineAtMs - now());
|
|
34138
34819
|
if (requestedRetryDelay < 1 || requestedRetryDelay >= remaining) {
|
|
@@ -34265,7 +34946,7 @@ var init_runner = __esm({
|
|
|
34265
34946
|
if (!wasRegistered && receipt.registered && (!receipt.advertisement_expires_at || Date.parse(receipt.advertisement_expires_at) - now() <= settings.advertisementRefreshLeadMs)) {
|
|
34266
34947
|
await publishAdvertisement("healthy", true);
|
|
34267
34948
|
}
|
|
34268
|
-
let providerRetryAtMs = this.options.codexRateLimits && codexAccountRateLimitReached(this.options.codexRateLimits) ? codexRateLimitRetryAtMs(this.options.codexRateLimits) ?? now() +
|
|
34949
|
+
let providerRetryAtMs = this.options.codexRateLimits && codexAccountRateLimitReached(this.options.codexRateLimits) ? codexRateLimitRetryAtMs(this.options.codexRateLimits) ?? now() + DEFAULT_QUOTA_COOLDOWN_MS : null;
|
|
34269
34950
|
let providerCooldownReason = providerRetryAtMs === null ? null : "provider_limit_snapshot";
|
|
34270
34951
|
let providerFailureRetryAtMs = 0;
|
|
34271
34952
|
let providerFailureCooldownReason = null;
|
|
@@ -34932,7 +35613,7 @@ var init_runner = __esm({
|
|
|
34932
35613
|
const refreshVersion = providerCooldownVersion;
|
|
34933
35614
|
const refreshStartedAt = now();
|
|
34934
35615
|
const refreshedRateLimits = await this.dependencies.codexAdapter.readAccountRateLimits(
|
|
34935
|
-
Date.now() + Math.min(
|
|
35616
|
+
Date.now() + Math.min(HOST_RUNTIME_POLICY.rate_limit_read_timeout_max_ms, settings.hostHeartbeatMs),
|
|
34936
35617
|
agentAbort.signal
|
|
34937
35618
|
);
|
|
34938
35619
|
if (agentAbort.signal.aborted || refreshVersion !== providerCooldownVersion) return;
|
|
@@ -34946,7 +35627,7 @@ var init_runner = __esm({
|
|
|
34946
35627
|
);
|
|
34947
35628
|
providerQuotaRecoveryObservedAtMs = usableSnapshot ? refreshStartedAt : null;
|
|
34948
35629
|
retainKnownQuotaWindows(providerRateLimits.rateLimits);
|
|
34949
|
-
const refreshedRetryAt = codexAccountRateLimitReached(providerRateLimits) ? codexRateLimitRetryAtMs(providerRateLimits) ?? refreshedAt +
|
|
35630
|
+
const refreshedRetryAt = codexAccountRateLimitReached(providerRateLimits) ? codexRateLimitRetryAtMs(providerRateLimits) ?? refreshedAt + DEFAULT_QUOTA_COOLDOWN_MS : null;
|
|
34950
35631
|
if (refreshedRetryAt !== null && refreshedRetryAt > refreshedAt) {
|
|
34951
35632
|
providerRetryAtMs = Math.max(providerRetryAtMs ?? 0, refreshedRetryAt);
|
|
34952
35633
|
providerCooldownReason = "provider_limit_snapshot";
|
|
@@ -35009,7 +35690,7 @@ var init_runner = __esm({
|
|
|
35009
35690
|
requestDrain("advertisement_failed");
|
|
35010
35691
|
break;
|
|
35011
35692
|
}
|
|
35012
|
-
nextAdvertisementAttemptAt = now() + remoteRetryAfterMs(error48,
|
|
35693
|
+
nextAdvertisementAttemptAt = now() + remoteRetryAfterMs(error48, HOST_RUNTIME_POLICY.remote_retry_fallback_ms);
|
|
35013
35694
|
nextClaimAt = Math.max(nextClaimAt, nextAdvertisementAttemptAt);
|
|
35014
35695
|
}
|
|
35015
35696
|
}
|
|
@@ -35129,7 +35810,7 @@ var init_runner = __esm({
|
|
|
35129
35810
|
}
|
|
35130
35811
|
} else if (!this.options.signal?.aborted && retryableRemoteError(error48)) {
|
|
35131
35812
|
const rejectedAtMs = now();
|
|
35132
|
-
const retryAtMs = rejectedAtMs + remoteRetryAfterMs(error48,
|
|
35813
|
+
const retryAtMs = rejectedAtMs + remoteRetryAfterMs(error48, HOST_RUNTIME_POLICY.remote_retry_fallback_ms);
|
|
35133
35814
|
if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "host_not_claimable") {
|
|
35134
35815
|
claimAvailabilityBackoff = { untilMs: retryAtMs, rejectedAtMs };
|
|
35135
35816
|
} else {
|
|
@@ -36488,7 +37169,7 @@ var init_runner = __esm({
|
|
|
36488
37169
|
);
|
|
36489
37170
|
}
|
|
36490
37171
|
state2 = await this.upgradeLegacyRuntimeState(recoveredState, signal);
|
|
36491
|
-
if (!state2) return this.now() + (this.options.idlePollMs ??
|
|
37172
|
+
if (!state2) return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36492
37173
|
} else if (recoveredState?.schema_version === "vtx_codex_agent_runtime_v2") {
|
|
36493
37174
|
if (this.options.adapterId !== "codex") {
|
|
36494
37175
|
throw new InferenceHostRunnerError(
|
|
@@ -36518,7 +37199,7 @@ var init_runner = __esm({
|
|
|
36518
37199
|
host_id: this.options.hostId,
|
|
36519
37200
|
requested_at: nowIso()
|
|
36520
37201
|
}, { signal });
|
|
36521
|
-
if (!assignment2) return this.now() + (this.options.idlePollMs ??
|
|
37202
|
+
if (!assignment2) return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36522
37203
|
state2 = {
|
|
36523
37204
|
schema_version: "vtx_inference_agent_runtime_v3",
|
|
36524
37205
|
adapter_id: this.options.adapterId,
|
|
@@ -36535,11 +37216,11 @@ var init_runner = __esm({
|
|
|
36535
37216
|
if (persistedWakeAtMs > this.now()) {
|
|
36536
37217
|
const wakeOutcome = await this.waitUntilWake(persistedWakeAtMs, signal);
|
|
36537
37218
|
if (wakeOutcome !== "ready") {
|
|
36538
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37219
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36539
37220
|
}
|
|
36540
37221
|
const rereadState = await readInferenceAgentRuntimeState(this.options.statePath);
|
|
36541
37222
|
if (rereadState?.schema_version !== "vtx_inference_agent_runtime_v3" || rereadState.adapter_id !== this.options.adapterId) {
|
|
36542
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37223
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36543
37224
|
}
|
|
36544
37225
|
state2 = rereadState;
|
|
36545
37226
|
}
|
|
@@ -36577,7 +37258,7 @@ var init_runner = __esm({
|
|
|
36577
37258
|
);
|
|
36578
37259
|
}
|
|
36579
37260
|
await this.releaseForHostStop(terminal.terminal_receipt.failure_code ?? "provider_failure");
|
|
36580
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37261
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36581
37262
|
}
|
|
36582
37263
|
if (!terminal.next_wake_at) {
|
|
36583
37264
|
throw new InferenceHostRunnerError(
|
|
@@ -36619,7 +37300,7 @@ var init_runner = __esm({
|
|
|
36619
37300
|
}, { signal });
|
|
36620
37301
|
if (preTurnHeartbeat.directive === "cancel") {
|
|
36621
37302
|
await this.handleCancelledAssignment(state2, signal);
|
|
36622
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37303
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36623
37304
|
}
|
|
36624
37305
|
if (this.options.quiesceSignal?.aborted) return this.now();
|
|
36625
37306
|
assignment = {
|
|
@@ -36650,7 +37331,7 @@ var init_runner = __esm({
|
|
|
36650
37331
|
}
|
|
36651
37332
|
latestLeaseExpiry = heartbeat.lease_expires_at;
|
|
36652
37333
|
await this.sleep(
|
|
36653
|
-
this.options.heartbeatIntervalMs ??
|
|
37334
|
+
this.options.heartbeatIntervalMs ?? HOST_RUNTIME_POLICY.agent_heartbeat_interval_ms,
|
|
36654
37335
|
turnAbort.signal
|
|
36655
37336
|
);
|
|
36656
37337
|
}
|
|
@@ -36658,7 +37339,7 @@ var init_runner = __esm({
|
|
|
36658
37339
|
if (!turnAbort.signal.aborted) turnAbort.abort(error48);
|
|
36659
37340
|
});
|
|
36660
37341
|
try {
|
|
36661
|
-
const deadlineAtMs = this.now() + (this.options.turnTimeoutMs ??
|
|
37342
|
+
const deadlineAtMs = this.now() + (this.options.turnTimeoutMs ?? HOST_RUNTIME_POLICY.agent_turn_timeout_ms);
|
|
36662
37343
|
const dataRequestTimeoutMs = this.options.dataRequestTimeoutMs ?? await loadInferenceAgentDataRequestTimeoutMs();
|
|
36663
37344
|
if (!Number.isSafeInteger(dataRequestTimeoutMs) || dataRequestTimeoutMs < 1) {
|
|
36664
37345
|
throw new InferenceHostRunnerError("invalid_configuration", "Agent data request timeout is invalid.");
|
|
@@ -36844,7 +37525,7 @@ var init_runner = __esm({
|
|
|
36844
37525
|
let nextWakeAtMs = null;
|
|
36845
37526
|
let wakeError;
|
|
36846
37527
|
try {
|
|
36847
|
-
nextWakeAtMs = wakeScheduledAtMs + parseInferenceAgentWake(result.turn.text, assignment) *
|
|
37528
|
+
nextWakeAtMs = wakeScheduledAtMs + parseInferenceAgentWake(result.turn.text, assignment) * MS_PER_SECOND;
|
|
36848
37529
|
} catch (error48) {
|
|
36849
37530
|
wakeError = error48;
|
|
36850
37531
|
}
|
|
@@ -36886,7 +37567,7 @@ var init_runner = __esm({
|
|
|
36886
37567
|
await writeInferenceAgentRuntimeState(this.options.statePath, state2);
|
|
36887
37568
|
await this.handleCancelledAssignment(state2);
|
|
36888
37569
|
}
|
|
36889
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37570
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36890
37571
|
}
|
|
36891
37572
|
latestLeaseExpiry = wakeHeartbeat.lease_expires_at;
|
|
36892
37573
|
state2 = {
|
|
@@ -36978,7 +37659,7 @@ var init_runner = __esm({
|
|
|
36978
37659
|
}
|
|
36979
37660
|
if (!cancelled) throw error48;
|
|
36980
37661
|
await this.handleCancelledAssignment(state2);
|
|
36981
|
-
return this.now() + (this.options.idlePollMs ??
|
|
37662
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY.agent_idle_poll_ms);
|
|
36982
37663
|
} finally {
|
|
36983
37664
|
heartbeatStopped = true;
|
|
36984
37665
|
turnAbort.abort();
|
|
@@ -37062,7 +37743,7 @@ var init_runner = __esm({
|
|
|
37062
37743
|
await clearInferenceAgentRuntimeState(this.options.statePath);
|
|
37063
37744
|
}
|
|
37064
37745
|
async waitUntilWake(nextWakeAtMs, signal) {
|
|
37065
|
-
const heartbeatIntervalMs = this.options.heartbeatIntervalMs ??
|
|
37746
|
+
const heartbeatIntervalMs = this.options.heartbeatIntervalMs ?? HOST_RUNTIME_POLICY.agent_heartbeat_interval_ms;
|
|
37066
37747
|
while (!this.stopped && !signal?.aborted && !this.options.quiesceSignal?.aborted && this.now() < nextWakeAtMs) {
|
|
37067
37748
|
const waitSignal = this.options.quiesceSignal ? AbortSignal.any([this.options.quiesceSignal, ...signal ? [signal] : []]) : signal;
|
|
37068
37749
|
try {
|
|
@@ -41184,7 +41865,7 @@ import {
|
|
|
41184
41865
|
getSupportedThinkingLevels,
|
|
41185
41866
|
InMemoryCredentialStore
|
|
41186
41867
|
} from "@earendil-works/pi-ai";
|
|
41187
|
-
var import_ajv2, PI_RUNTIME_VERSION,
|
|
41868
|
+
var import_ajv2, PI_RUNTIME_VERSION, effortToPi, effortToVtx, modelReference, object2, fail, sdkFailureCode, assertPiStructuredOutputSchema, privateRuntime, qualifiedModel, usageSum, PiAdapter, cleanupPiOwnedState;
|
|
41188
41869
|
var init_pi_adapter = __esm({
|
|
41189
41870
|
"lib/inference-host/pi-adapter.ts"() {
|
|
41190
41871
|
"use strict";
|
|
@@ -41193,10 +41874,10 @@ var init_pi_adapter = __esm({
|
|
|
41193
41874
|
init_define_VTX_PI_MODEL_POLICY();
|
|
41194
41875
|
import_ajv2 = __toESM(require_ajv(), 1);
|
|
41195
41876
|
init_codex_app_server();
|
|
41877
|
+
init_constants();
|
|
41196
41878
|
init_config2();
|
|
41197
41879
|
init_pi_transport();
|
|
41198
41880
|
PI_RUNTIME_VERSION = "0.85.1";
|
|
41199
|
-
MAX_TEXT_BYTES = 3e5;
|
|
41200
41881
|
effortToPi = (effort2) => effort2 === "none" ? "off" : effort2;
|
|
41201
41882
|
effortToVtx = (effort2) => effort2 === "off" ? "none" : effort2;
|
|
41202
41883
|
modelReference = (model) => `${model.provider}/${model.id}`;
|
|
@@ -41369,7 +42050,7 @@ var init_pi_adapter = __esm({
|
|
|
41369
42050
|
};
|
|
41370
42051
|
try {
|
|
41371
42052
|
checkBoundary();
|
|
41372
|
-
if (!input.systemPrompt.trim() || !input.userPrompt.trim() || Buffer.byteLength(input.systemPrompt) >
|
|
42053
|
+
if (!input.systemPrompt.trim() || !input.userPrompt.trim() || Buffer.byteLength(input.systemPrompt) > EXTERNAL_INFERENCE_LIMITS.max_prompt_bytes || Buffer.byteLength(input.userPrompt) > EXTERNAL_INFERENCE_LIMITS.max_prompt_bytes) throw fail("pi_prompt_invalid", "schema");
|
|
41373
42054
|
const schema = agent ? agent.outputSchema : object2(JSON.parse(input.outputSchemaJson));
|
|
41374
42055
|
if (agent && !agent.dataContract.length) throw fail("pi_data_contract_missing", "schema");
|
|
41375
42056
|
if (schema.type !== "object") throw fail("pi_output_schema_invalid", "schema");
|
|
@@ -41568,7 +42249,7 @@ var init_pi_adapter = __esm({
|
|
|
41568
42249
|
if (!last) throw fail("pi_result_missing");
|
|
41569
42250
|
if (last.stopReason !== "stop") throw fail("pi_terminal_incomplete");
|
|
41570
42251
|
const text = last.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
|
|
41571
|
-
if (!text.trim() || Buffer.byteLength(text) >
|
|
42252
|
+
if (!text.trim() || Buffer.byteLength(text) > EXTERNAL_INFERENCE_LIMITS.max_candidate_plaintext_bytes) throw fail("pi_output_invalid", "schema");
|
|
41572
42253
|
let output3;
|
|
41573
42254
|
try {
|
|
41574
42255
|
output3 = JSON.parse(text);
|
|
@@ -44543,7 +45224,7 @@ import { createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
|
44543
45224
|
import { access as access6, chmod as chmod4, mkdir as mkdir5, readFile as readFile12, rm as rm14, writeFile as writeFile5 } from "node:fs/promises";
|
|
44544
45225
|
import { homedir as homedir4 } from "node:os";
|
|
44545
45226
|
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,
|
|
45227
|
+
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
45228
|
var init_service = __esm({
|
|
44548
45229
|
"lib/inference-host/service.ts"() {
|
|
44549
45230
|
"use strict";
|
|
@@ -44553,13 +45234,15 @@ var init_service = __esm({
|
|
|
44553
45234
|
init_service_launcher_state();
|
|
44554
45235
|
init_agent_cli_release();
|
|
44555
45236
|
init_runtime_policy_generated();
|
|
45237
|
+
init_constants();
|
|
44556
45238
|
init_durable_adapter();
|
|
44557
45239
|
init_config2();
|
|
44558
45240
|
SERVICE_NAME = "VTX Macro Inference Host";
|
|
44559
45241
|
SYSTEMD_UNIT = "vtx-inference-host.service";
|
|
44560
45242
|
LAUNCHD_LABEL = "com.vtxmacro.inference-host";
|
|
44561
|
-
|
|
44562
|
-
|
|
45243
|
+
SERVICE_POLICY = runtime_policy_generated_default.external_inference.service;
|
|
45244
|
+
SERVICE_COOPERATIVE_STOP_SECONDS = Math.ceil(SERVICE_POLICY.cooperative_stop_timeout_ms / MS_PER_SECOND);
|
|
45245
|
+
pollAttemptsWithin = (milliseconds) => Math.ceil(milliseconds / SERVICE_POLICY.startup_poll_interval_ms);
|
|
44563
45246
|
INFERENCE_HOST_SERVICE_DRAIN_COMMAND = "vtx-inference-host-service-drain-v1";
|
|
44564
45247
|
INFERENCE_HOST_SERVICE_QUIESCE_COMMAND = "vtx-inference-host-service-quiesce-v1";
|
|
44565
45248
|
InferenceHostBootstrapRestartRequiredError = class extends Error {
|
|
@@ -44980,9 +45663,9 @@ WantedBy=default.target
|
|
|
44980
45663
|
this.sleep = dependencies.sleep ?? (async (milliseconds) => {
|
|
44981
45664
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
44982
45665
|
});
|
|
44983
|
-
this.stopWaitAttempts = dependencies.stopWaitAttempts ??
|
|
44984
|
-
this.startWaitAttempts = dependencies.startWaitAttempts ??
|
|
44985
|
-
this.reconcileWaitAttempts = dependencies.reconcileWaitAttempts ??
|
|
45666
|
+
this.stopWaitAttempts = dependencies.stopWaitAttempts ?? pollAttemptsWithin(SERVICE_POLICY.cooperative_stop_timeout_ms);
|
|
45667
|
+
this.startWaitAttempts = dependencies.startWaitAttempts ?? SERVICE_POLICY.startup_max_attempts;
|
|
45668
|
+
this.reconcileWaitAttempts = dependencies.reconcileWaitAttempts ?? pollAttemptsWithin(SERVICE_POLICY.cooperative_stop_timeout_ms);
|
|
44986
45669
|
this.confirmInitialReadiness = dependencies.confirmInitialReadiness ?? true;
|
|
44987
45670
|
this.acquireProcessLock = dependencies.acquireProcessLock ?? acquireInferenceHostProcessLock;
|
|
44988
45671
|
managerName(this.platform);
|
|
@@ -45024,17 +45707,17 @@ WantedBy=default.target
|
|
|
45024
45707
|
}
|
|
45025
45708
|
async withControlLock(operation) {
|
|
45026
45709
|
let lock2 = null;
|
|
45027
|
-
for (let attempt = 0; attempt <
|
|
45710
|
+
for (let attempt = 0; attempt < SERVICE_POLICY.control_lock_wait_attempts; attempt += 1) {
|
|
45028
45711
|
try {
|
|
45029
45712
|
lock2 = await this.acquireProcessLock(this.controlLockPath());
|
|
45030
45713
|
break;
|
|
45031
45714
|
} catch (error48) {
|
|
45032
45715
|
if (!/already owns/iu.test(error48 instanceof Error ? error48.message : "")) throw error48;
|
|
45033
|
-
await this.sleep(
|
|
45716
|
+
await this.sleep(SERVICE_POLICY.control_lock_retry_interval_ms);
|
|
45034
45717
|
}
|
|
45035
45718
|
}
|
|
45036
45719
|
if (!lock2) {
|
|
45037
|
-
throw new Error(
|
|
45720
|
+
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
45721
|
}
|
|
45039
45722
|
try {
|
|
45040
45723
|
return await operation();
|
|
@@ -45112,9 +45795,9 @@ WantedBy=default.target
|
|
|
45112
45795
|
for (let attempt = 0; attempt < this.startWaitAttempts; attempt += 1) {
|
|
45113
45796
|
const status = await this.status();
|
|
45114
45797
|
if (status.manager_active) return status;
|
|
45115
|
-
await this.sleep(
|
|
45798
|
+
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
45116
45799
|
}
|
|
45117
|
-
throw new Error(`Background service did not reach an active state within ${this.startWaitAttempts *
|
|
45800
|
+
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
45801
|
}
|
|
45119
45802
|
async restoreRunningSupervisor(manifest, preserveGeneration = false, targetInstanceName) {
|
|
45120
45803
|
const previousRuntime = await readRuntimeAcrossAtomicReplacement(this.runtimePath()).catch(() => null);
|
|
@@ -45176,7 +45859,7 @@ ${result.stderr}`)) {
|
|
|
45176
45859
|
const allReady = runtime.workers.every((worker) => worker.state === "running");
|
|
45177
45860
|
if (exactWorkerSet && (targetInstanceName ? target?.state === "running" : allReady)) {
|
|
45178
45861
|
consecutiveReadyObservations += 1;
|
|
45179
|
-
if (consecutiveReadyObservations >=
|
|
45862
|
+
if (consecutiveReadyObservations >= SERVICE_POLICY.ready_consecutive_observations) return runtime;
|
|
45180
45863
|
} else {
|
|
45181
45864
|
consecutiveReadyObservations = 0;
|
|
45182
45865
|
}
|
|
@@ -45189,7 +45872,7 @@ ${result.stderr}`)) {
|
|
|
45189
45872
|
if (runtime?.rejected_manifest_generation === manifest.generation) {
|
|
45190
45873
|
throw new Error("Inference-host supervisor rejected the updated worker set.");
|
|
45191
45874
|
}
|
|
45192
|
-
await this.sleep(
|
|
45875
|
+
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
45193
45876
|
}
|
|
45194
45877
|
throw new Error(
|
|
45195
45878
|
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 +45940,7 @@ ${started.stderr}`)) {
|
|
|
45257
45940
|
await this.waitForManifestApplied(
|
|
45258
45941
|
manifest,
|
|
45259
45942
|
targetInstanceName,
|
|
45260
|
-
Math.max(this.reconcileWaitAttempts,
|
|
45943
|
+
Math.max(this.reconcileWaitAttempts, pollAttemptsWithin(SERVICE_POLICY.update_readiness_timeout_ms))
|
|
45261
45944
|
);
|
|
45262
45945
|
}
|
|
45263
45946
|
}
|
|
@@ -45331,7 +46014,7 @@ ${cleanup.stderr}`)) {
|
|
|
45331
46014
|
// restores the previous manifest. Never give rollback less than
|
|
45332
46015
|
// a bounded 100-observation confirmation window, even when a
|
|
45333
46016
|
// caller intentionally shortens forward-readiness checks.
|
|
45334
|
-
Math.max(this.reconcileWaitAttempts,
|
|
46017
|
+
Math.max(this.reconcileWaitAttempts, SERVICE_POLICY.rollback_confirmation_min_attempts)
|
|
45335
46018
|
);
|
|
45336
46019
|
} catch (rollbackError) {
|
|
45337
46020
|
throw new Error(
|
|
@@ -45571,7 +46254,7 @@ ${result.stderr}`)) {
|
|
|
45571
46254
|
serviceReleased = true;
|
|
45572
46255
|
break;
|
|
45573
46256
|
}
|
|
45574
|
-
await this.sleep(
|
|
46257
|
+
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
45575
46258
|
}
|
|
45576
46259
|
if (!serviceReleased) {
|
|
45577
46260
|
throw new Error(
|
|
@@ -45796,7 +46479,7 @@ ${result.stderr}`)) {
|
|
|
45796
46479
|
cooperativeStopTimer = setTimeout(() => {
|
|
45797
46480
|
cooperativeStopTimedOut = true;
|
|
45798
46481
|
child.kill("SIGKILL");
|
|
45799
|
-
},
|
|
46482
|
+
}, SERVICE_POLICY.cooperative_stop_timeout_ms);
|
|
45800
46483
|
cooperativeStopTimer.unref();
|
|
45801
46484
|
};
|
|
45802
46485
|
if (signal.aborted) onAbort();
|
|
@@ -45977,7 +46660,7 @@ ${result.stderr}`)) {
|
|
|
45977
46660
|
if (readinessSignalled) return;
|
|
45978
46661
|
readinessSignalled = true;
|
|
45979
46662
|
readinessTask = (async () => {
|
|
45980
|
-
await sleep4(
|
|
46663
|
+
await sleep4(SERVICE_POLICY.worker_readiness_settle_ms);
|
|
45981
46664
|
if (!launchSettled && !attemptController.signal.aborted && !record5.controller.signal.aborted && !signal.aborted) {
|
|
45982
46665
|
await updateRecord(record5, "running");
|
|
45983
46666
|
}
|
|
@@ -46000,8 +46683,8 @@ ${result.stderr}`)) {
|
|
|
46000
46683
|
throw new Error("worker_cooperative_stop_timeout");
|
|
46001
46684
|
}
|
|
46002
46685
|
if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted || !await readDesiredAcrossAtomicReplacement(desiredPath)) break;
|
|
46003
|
-
failures = result.uptimeMs >=
|
|
46004
|
-
const retryAfterMs = Math.min(
|
|
46686
|
+
failures = result.uptimeMs >= SERVICE_POLICY.restart_stable_uptime_ms ? 0 : failures + 1;
|
|
46687
|
+
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
46688
|
await updateRecord(record5, "failed", "worker_exited");
|
|
46006
46689
|
await appendServiceLog(serviceManifest.log_path, "worker_exited", {
|
|
46007
46690
|
instance_name: record5.worker.instance_name,
|
|
@@ -46015,7 +46698,7 @@ ${result.stderr}`)) {
|
|
|
46015
46698
|
if (error48 instanceof Error && error48.message === "worker_cooperative_stop_timeout") throw error48;
|
|
46016
46699
|
if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted) break;
|
|
46017
46700
|
failures += 1;
|
|
46018
|
-
const retryAfterMs = Math.min(
|
|
46701
|
+
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
46702
|
await updateRecord(record5, "failed", "worker_launch_failed");
|
|
46020
46703
|
await appendServiceLog(serviceManifest.log_path, "worker_launch_failed", {
|
|
46021
46704
|
instance_name: record5.worker.instance_name,
|
|
@@ -46111,7 +46794,7 @@ ${result.stderr}`)) {
|
|
|
46111
46794
|
if (!storedNext) throw new Error("Inference-host service manifest is missing.");
|
|
46112
46795
|
const next = withServiceScript(storedNext);
|
|
46113
46796
|
if (next.generation !== appliedManifest.generation && next.generation !== rejectedManifestGeneration) await reconcile(next);
|
|
46114
|
-
await sleep4(
|
|
46797
|
+
await sleep4(SERVICE_POLICY.supervisor_manifest_poll_interval_ms);
|
|
46115
46798
|
}
|
|
46116
46799
|
if (quiesceSignal.aborted && !signal.aborted) {
|
|
46117
46800
|
let finished = false;
|
|
@@ -46120,7 +46803,7 @@ ${result.stderr}`)) {
|
|
|
46120
46803
|
return results;
|
|
46121
46804
|
});
|
|
46122
46805
|
while (!finished && !signal.aborted && await readDesiredAcrossAtomicReplacement(desiredPath)) {
|
|
46123
|
-
await Promise.race([completion, sleep4(
|
|
46806
|
+
await Promise.race([completion, sleep4(SERVICE_POLICY.supervisor_manifest_poll_interval_ms)]);
|
|
46124
46807
|
}
|
|
46125
46808
|
if (!finished) {
|
|
46126
46809
|
await drainWorkers();
|
|
@@ -46340,6 +47023,8 @@ var init_cli = __esm({
|
|
|
46340
47023
|
init_define_VTX_EXO_POLICY();
|
|
46341
47024
|
init_define_VTX_GROK_POLICY();
|
|
46342
47025
|
init_define_VTX_PI_MODEL_POLICY();
|
|
47026
|
+
init_runtime_policy_generated();
|
|
47027
|
+
init_constants();
|
|
46343
47028
|
init_external_inference_contract();
|
|
46344
47029
|
init_agent_cli_release();
|
|
46345
47030
|
init_reauthorize();
|
|
@@ -46377,8 +47062,8 @@ var init_cli = __esm({
|
|
|
46377
47062
|
foregroundHostLockPath = (config2) => `${config2.processLockPath}.foreground`;
|
|
46378
47063
|
credentialLifecycleLockPath = (config2) => `${inferenceHostCredentialContextPath(config2)}.lock`;
|
|
46379
47064
|
serviceRecoveryCommandLockPath = (config2) => `${config2.supervisorProcessLockPath}.service-recovery-command`;
|
|
46380
|
-
AGENT_HEARTBEAT_INTERVAL_MS =
|
|
46381
|
-
AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS =
|
|
47065
|
+
AGENT_HEARTBEAT_INTERVAL_MS = runtime_policy_generated_default.external_inference.host_runtime.agent_heartbeat_interval_ms;
|
|
47066
|
+
AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS = runtime_policy_generated_default.external_inference.host_runtime.agent_heartbeat_max_retry_delay_ms;
|
|
46382
47067
|
retryableAgentHeartbeatError = (error48) => {
|
|
46383
47068
|
if (!(error48 instanceof ExternalInferenceMcpError)) return false;
|
|
46384
47069
|
if (error48.code === "network_error" || error48.code === "request_timeout") return true;
|
|
@@ -47244,7 +47929,7 @@ Waiting for approval...
|
|
|
47244
47929
|
const status = await (dependencies.loginCodex ?? loginCodexSubscription)({
|
|
47245
47930
|
binary,
|
|
47246
47931
|
codexHome: config2.codexHomePath,
|
|
47247
|
-
deadlineAtMs: Date.now() +
|
|
47932
|
+
deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_login_timeout_ms,
|
|
47248
47933
|
signal: cancellation.signal,
|
|
47249
47934
|
onChallenge: async (challenge) => {
|
|
47250
47935
|
emitStdout(parsed.json ? `${JSON.stringify({
|
|
@@ -47294,7 +47979,7 @@ Waiting for approval...
|
|
|
47294
47979
|
await (dependencies.logoutCodex ?? logoutCodexSubscription)({
|
|
47295
47980
|
binary,
|
|
47296
47981
|
codexHome: config2.codexHomePath,
|
|
47297
|
-
deadlineAtMs: Date.now() +
|
|
47982
|
+
deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms,
|
|
47298
47983
|
signal: cancellation.signal
|
|
47299
47984
|
});
|
|
47300
47985
|
return {
|
|
@@ -47941,7 +48626,7 @@ Waiting for approval...
|
|
|
47941
48626
|
const preflight = await (dependencies.preflightCodex ?? preflightCodexSubscription)({
|
|
47942
48627
|
binary: verifiedBinary,
|
|
47943
48628
|
codexHome: config2.codexHomePath,
|
|
47944
|
-
deadlineAtMs: Date.now() +
|
|
48629
|
+
deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms,
|
|
47945
48630
|
signal: cancellation.signal
|
|
47946
48631
|
});
|
|
47947
48632
|
const summary = await (dependencies.runForeground ?? defaultRunForeground)({
|
|
@@ -48129,7 +48814,7 @@ Waiting for approval...
|
|
|
48129
48814
|
const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
|
|
48130
48815
|
await new Promise((resolve14) => setTimeout(resolve14, milliseconds));
|
|
48131
48816
|
});
|
|
48132
|
-
const stopAt = now().getTime() + parsed.waitSeconds *
|
|
48817
|
+
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
48133
48818
|
while (true) {
|
|
48134
48819
|
const result = await withAgentCommandLock(config2, async () => {
|
|
48135
48820
|
let state2 = await readInferenceForegroundAgentControlState(config2.statePath) ?? foregroundAgentControlState(session.localState.host_id, now().toISOString());
|
|
@@ -48655,7 +49340,7 @@ Waiting for approval...
|
|
|
48655
49340
|
pendingHeartbeatRequest = heartbeatRequest;
|
|
48656
49341
|
consecutiveHeartbeatFailures += 1;
|
|
48657
49342
|
retryDelayMs = Math.min(
|
|
48658
|
-
AGENT_HEARTBEAT_INTERVAL_MS *
|
|
49343
|
+
AGENT_HEARTBEAT_INTERVAL_MS * BACKOFF_GROWTH_FACTOR ** Math.max(0, consecutiveHeartbeatFailures - 1),
|
|
48659
49344
|
AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS
|
|
48660
49345
|
);
|
|
48661
49346
|
const message = `Agent-driven inference heartbeat was temporarily unavailable; retrying in ${retryDelayMs}ms.
|
|
@@ -48712,7 +49397,7 @@ Waiting for approval...
|
|
|
48712
49397
|
if (!retryableAgentHeartbeatError(error48)) throw error48;
|
|
48713
49398
|
consecutiveHeartbeatFailures += 1;
|
|
48714
49399
|
retryDelayMs = Math.min(
|
|
48715
|
-
AGENT_HEARTBEAT_INTERVAL_MS *
|
|
49400
|
+
AGENT_HEARTBEAT_INTERVAL_MS * BACKOFF_GROWTH_FACTOR ** Math.max(0, consecutiveHeartbeatFailures - 1),
|
|
48716
49401
|
AGENT_HEARTBEAT_MAX_RETRY_DELAY_MS
|
|
48717
49402
|
);
|
|
48718
49403
|
emitStderr(parsed.json ? `${JSON.stringify({
|
|
@@ -48761,7 +49446,7 @@ Waiting for approval...
|
|
|
48761
49446
|
const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
|
|
48762
49447
|
await new Promise((resolve14) => setTimeout(resolve14, milliseconds));
|
|
48763
49448
|
});
|
|
48764
|
-
const stopAt = now().getTime() + parsed.waitSeconds *
|
|
49449
|
+
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
48765
49450
|
while (true) {
|
|
48766
49451
|
let pending3 = await readInferenceAgentNextState(config2.statePath);
|
|
48767
49452
|
if (!pending3) {
|
|
@@ -49468,7 +50153,7 @@ Waiting for approval...
|
|
|
49468
50153
|
const preflight = await (dependencies.preflightCodex ?? preflightCodexSubscription)({
|
|
49469
50154
|
binary,
|
|
49470
50155
|
codexHome: config2.codexHomePath,
|
|
49471
|
-
deadlineAtMs: Date.now() +
|
|
50156
|
+
deadlineAtMs: Date.now() + runtime_policy_generated_default.external_inference.host_runtime.codex_command_timeout_ms
|
|
49472
50157
|
});
|
|
49473
50158
|
const status = await manager.install({
|
|
49474
50159
|
adapter: "codex",
|
|
@@ -50118,9 +50803,9 @@ function resolveBrowserApiUrl(hostname3, protocol, publicApiUrl, development) {
|
|
|
50118
50803
|
if (local) {
|
|
50119
50804
|
let port = "8000";
|
|
50120
50805
|
try {
|
|
50121
|
-
const
|
|
50122
|
-
if (
|
|
50123
|
-
port =
|
|
50806
|
+
const configured2 = new URL(publicApiUrl ?? "");
|
|
50807
|
+
if (configured2.port && (configured2.hostname === "localhost" || configured2.hostname === "127.0.0.1")) {
|
|
50808
|
+
port = configured2.port;
|
|
50124
50809
|
}
|
|
50125
50810
|
} catch {
|
|
50126
50811
|
}
|
|
@@ -50208,7 +50893,12 @@ function configureApiTransport(transport) {
|
|
|
50208
50893
|
if (!/^https?:\/\/[^/]/i.test(baseUrl)) {
|
|
50209
50894
|
throw new Error("VTX API transport requires an absolute http(s) base URL.");
|
|
50210
50895
|
}
|
|
50211
|
-
configuredApiTransport = {
|
|
50896
|
+
configuredApiTransport = {
|
|
50897
|
+
baseUrl,
|
|
50898
|
+
authorization: transport.authorization,
|
|
50899
|
+
sessionToken: transport.sessionToken,
|
|
50900
|
+
headers: transport.headers
|
|
50901
|
+
};
|
|
50212
50902
|
}
|
|
50213
50903
|
function getActiveProfileId() {
|
|
50214
50904
|
return activeProfileId;
|
|
@@ -50251,6 +50941,8 @@ var init_shared = __esm({
|
|
|
50251
50941
|
}
|
|
50252
50942
|
const authorization = transport.authorization();
|
|
50253
50943
|
if (authorization) headers.set("Authorization", authorization);
|
|
50944
|
+
const sessionToken = transport.sessionToken?.();
|
|
50945
|
+
if (sessionToken) headers.set("Cookie", `session_token=${sessionToken}`);
|
|
50254
50946
|
return fetch(input, { ...init2, headers, credentials: "omit" });
|
|
50255
50947
|
};
|
|
50256
50948
|
sleep = (ms) => new Promise((resolve14) => setTimeout(resolve14, ms));
|
|
@@ -50282,19 +50974,19 @@ var init_shared = __esm({
|
|
|
50282
50974
|
shareClientGetRequest = async (key, request, options) => {
|
|
50283
50975
|
if (!canUseClientGetRequestCache(options?.cookie)) {
|
|
50284
50976
|
if (options?.signal?.aborted) throw toAbortError(options.signal.reason);
|
|
50285
|
-
return raceWithAbortSignal(request(), options?.signal);
|
|
50977
|
+
return raceWithAbortSignal(request(options?.signal), options?.signal);
|
|
50286
50978
|
}
|
|
50287
50979
|
const now = Date.now();
|
|
50288
50980
|
const recent = recentClientGetResponses.get(key);
|
|
50289
50981
|
if (recent && recent.expiresAt > now) return recent.value;
|
|
50290
50982
|
if (recent) recentClientGetResponses.delete(key);
|
|
50291
50983
|
if (options?.signal?.aborted) throw toAbortError(options.signal.reason);
|
|
50292
|
-
if (options?.signal && !options.shareAbortScoped) return raceWithAbortSignal(request(), options.signal);
|
|
50984
|
+
if (options?.signal && !options.shareAbortScoped) return raceWithAbortSignal(request(options.signal), options.signal);
|
|
50293
50985
|
const existing = inFlightClientGetRequests.get(key);
|
|
50294
50986
|
if (existing) return raceWithAbortSignal(existing, options?.signal);
|
|
50295
50987
|
const requestGeneration = clientGetRequestGenerations.get(key) ?? 0;
|
|
50296
50988
|
initializedClientGetRequestKeys.add(key);
|
|
50297
|
-
const promise2 = request().then((value) => {
|
|
50989
|
+
const promise2 = request(void 0).then((value) => {
|
|
50298
50990
|
if ((clientGetRequestGenerations.get(key) ?? 0) === requestGeneration) {
|
|
50299
50991
|
recentClientGetResponses.set(key, {
|
|
50300
50992
|
expiresAt: Date.now() + (options?.ttlMs ?? CLIENT_GET_DEDUPE_TTL_MS),
|
|
@@ -50811,6 +51503,16 @@ var init_ai_status_auth_fallback_contract = __esm({
|
|
|
50811
51503
|
}
|
|
50812
51504
|
});
|
|
50813
51505
|
|
|
51506
|
+
// lib/navigation/same-origin.ts
|
|
51507
|
+
var init_same_origin = __esm({
|
|
51508
|
+
"lib/navigation/same-origin.ts"() {
|
|
51509
|
+
"use strict";
|
|
51510
|
+
init_define_VTX_EXO_POLICY();
|
|
51511
|
+
init_define_VTX_GROK_POLICY();
|
|
51512
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
51513
|
+
}
|
|
51514
|
+
});
|
|
51515
|
+
|
|
50814
51516
|
// lib/auth/google-auth-url.ts
|
|
50815
51517
|
var init_google_auth_url = __esm({
|
|
50816
51518
|
"lib/auth/google-auth-url.ts"() {
|
|
@@ -50818,6 +51520,7 @@ var init_google_auth_url = __esm({
|
|
|
50818
51520
|
init_define_VTX_EXO_POLICY();
|
|
50819
51521
|
init_define_VTX_GROK_POLICY();
|
|
50820
51522
|
init_define_VTX_PI_MODEL_POLICY();
|
|
51523
|
+
init_same_origin();
|
|
50821
51524
|
}
|
|
50822
51525
|
});
|
|
50823
51526
|
|
|
@@ -51674,7 +52377,7 @@ var init_local_breadcrumbs = __esm({
|
|
|
51674
52377
|
});
|
|
51675
52378
|
|
|
51676
52379
|
// 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;
|
|
52380
|
+
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
52381
|
var init_client_runtime_ownership_errors = __esm({
|
|
51679
52382
|
"lib/runtime/client-runtime-ownership-errors.ts"() {
|
|
51680
52383
|
"use strict";
|
|
@@ -51732,6 +52435,16 @@ var init_client_runtime_ownership_errors = __esm({
|
|
|
51732
52435
|
}
|
|
51733
52436
|
return (code === "runtime_owner_superseded" || code === "runtime_owner_released") && statusCode === 401;
|
|
51734
52437
|
};
|
|
52438
|
+
AUTHORITY_ENDED_CODES = /* @__PURE__ */ new Set([
|
|
52439
|
+
...LEASE_ENDED_CODES,
|
|
52440
|
+
"runtime_owner_superseded",
|
|
52441
|
+
"runtime_owner_released",
|
|
52442
|
+
"runtime_scheduler_instance_mismatch"
|
|
52443
|
+
]);
|
|
52444
|
+
clientRuntimeAuthorityEndedFromCode = (error48) => {
|
|
52445
|
+
const code = readClientRuntimeOwnershipErrorCode(error48);
|
|
52446
|
+
return code !== null && AUTHORITY_ENDED_CODES.has(code);
|
|
52447
|
+
};
|
|
51735
52448
|
ownershipLossReasonFromCode = (error48) => {
|
|
51736
52449
|
const code = readClientRuntimeOwnershipErrorCode(error48);
|
|
51737
52450
|
if (code === null) {
|
|
@@ -51796,7 +52509,7 @@ var init_billing = __esm({
|
|
|
51796
52509
|
async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_XBTUSD", timeframe = "1m", signal) {
|
|
51797
52510
|
const params = new URLSearchParams({ limit: limit.toString(), exchange, symbol: symbol2, timeframe });
|
|
51798
52511
|
const requestUrl = `${getApiUrl()}/candles/recent?${params.toString()}`;
|
|
51799
|
-
return shareClientGetRequest(`recent-candles:${params.toString()}`, async () => {
|
|
52512
|
+
return shareClientGetRequest(`recent-candles:${params.toString()}`, async (requestSignal) => {
|
|
51800
52513
|
const trace = startRuntimeNetworkDebugTrace({
|
|
51801
52514
|
kind: "runtime",
|
|
51802
52515
|
label: "market_data_api:candles_recent",
|
|
@@ -51808,7 +52521,7 @@ async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_X
|
|
|
51808
52521
|
try {
|
|
51809
52522
|
response = await apiFetch(requestUrl, {
|
|
51810
52523
|
cache: "no-store",
|
|
51811
|
-
signal:
|
|
52524
|
+
signal: requestSignal
|
|
51812
52525
|
});
|
|
51813
52526
|
if (!response.ok) {
|
|
51814
52527
|
const error48 = await buildMarketDataFetchError(response, "recent candles", "/candles/recent");
|
|
@@ -51836,7 +52549,7 @@ async function getRecentCandles(limit = 10, exchange = "kraken", symbol2 = "PI_X
|
|
|
51836
52549
|
}
|
|
51837
52550
|
async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal) {
|
|
51838
52551
|
const requestKey = `live-ticker:${symbol2}:${exchange}`;
|
|
51839
|
-
return shareClientGetRequest(requestKey, async () => {
|
|
52552
|
+
return shareClientGetRequest(requestKey, async (requestSignal) => {
|
|
51840
52553
|
const requestUrl = `${getApiUrl()}/ticker/live?symbol=${encodeURIComponent(symbol2)}&exchange=${encodeURIComponent(exchange)}`;
|
|
51841
52554
|
const trace = startRuntimeNetworkDebugTrace({
|
|
51842
52555
|
kind: "runtime",
|
|
@@ -51847,7 +52560,7 @@ async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal)
|
|
|
51847
52560
|
});
|
|
51848
52561
|
let response = null;
|
|
51849
52562
|
try {
|
|
51850
|
-
response = await apiFetch(requestUrl, { cache: "no-store", signal });
|
|
52563
|
+
response = await apiFetch(requestUrl, { cache: "no-store", signal: requestSignal });
|
|
51851
52564
|
if (!response.ok) {
|
|
51852
52565
|
const error48 = await buildMarketDataFetchError(response, "live ticker", "/ticker/live");
|
|
51853
52566
|
trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
|
|
@@ -51965,8 +52678,12 @@ function configureRuntimeHostStorage(storage3) {
|
|
|
51965
52678
|
}
|
|
51966
52679
|
function runtimeHostStorage() {
|
|
51967
52680
|
if (configuredStorage) return configuredStorage;
|
|
51968
|
-
|
|
51969
|
-
|
|
52681
|
+
try {
|
|
52682
|
+
if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
|
|
52683
|
+
return window.localStorage;
|
|
52684
|
+
}
|
|
52685
|
+
} catch {
|
|
52686
|
+
return null;
|
|
51970
52687
|
}
|
|
51971
52688
|
return null;
|
|
51972
52689
|
}
|
|
@@ -60339,7 +61056,7 @@ var init_strings = __esm({
|
|
|
60339
61056
|
});
|
|
60340
61057
|
|
|
60341
61058
|
// node_modules/ethers/lib.esm/constants/index.js
|
|
60342
|
-
var
|
|
61059
|
+
var init_constants2 = __esm({
|
|
60343
61060
|
"node_modules/ethers/lib.esm/constants/index.js"() {
|
|
60344
61061
|
init_define_VTX_EXO_POLICY();
|
|
60345
61062
|
init_define_VTX_GROK_POLICY();
|
|
@@ -60361,7 +61078,7 @@ var init_signature = __esm({
|
|
|
60361
61078
|
init_define_VTX_EXO_POLICY();
|
|
60362
61079
|
init_define_VTX_GROK_POLICY();
|
|
60363
61080
|
init_define_VTX_PI_MODEL_POLICY();
|
|
60364
|
-
|
|
61081
|
+
init_constants2();
|
|
60365
61082
|
init_utils();
|
|
60366
61083
|
BN_04 = BigInt(0);
|
|
60367
61084
|
BN_13 = BigInt(1);
|
|
@@ -64590,7 +65307,7 @@ var init_message = __esm({
|
|
|
64590
65307
|
init_define_VTX_GROK_POLICY();
|
|
64591
65308
|
init_define_VTX_PI_MODEL_POLICY();
|
|
64592
65309
|
init_crypto3();
|
|
64593
|
-
|
|
65310
|
+
init_constants2();
|
|
64594
65311
|
init_transaction2();
|
|
64595
65312
|
init_utils();
|
|
64596
65313
|
}
|
|
@@ -70198,7 +70915,7 @@ var init_ens_resolver = __esm({
|
|
|
70198
70915
|
init_define_VTX_GROK_POLICY();
|
|
70199
70916
|
init_define_VTX_PI_MODEL_POLICY();
|
|
70200
70917
|
init_address2();
|
|
70201
|
-
|
|
70918
|
+
init_constants2();
|
|
70202
70919
|
init_contract2();
|
|
70203
70920
|
init_hash();
|
|
70204
70921
|
init_utils();
|
|
@@ -71845,7 +72562,7 @@ var init_abstract_provider = __esm({
|
|
|
71845
72562
|
init_define_VTX_GROK_POLICY();
|
|
71846
72563
|
init_define_VTX_PI_MODEL_POLICY();
|
|
71847
72564
|
init_address2();
|
|
71848
|
-
|
|
72565
|
+
init_constants2();
|
|
71849
72566
|
init_contract2();
|
|
71850
72567
|
init_hash();
|
|
71851
72568
|
init_transaction2();
|
|
@@ -83444,7 +84161,7 @@ var init_ethers = __esm({
|
|
|
83444
84161
|
init_version();
|
|
83445
84162
|
init_abi();
|
|
83446
84163
|
init_address2();
|
|
83447
|
-
|
|
84164
|
+
init_constants2();
|
|
83448
84165
|
init_contract2();
|
|
83449
84166
|
init_crypto3();
|
|
83450
84167
|
init_hash();
|
|
@@ -84612,6 +85329,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84612
85329
|
init_order_identity();
|
|
84613
85330
|
init_hyperliquid_order_status();
|
|
84614
85331
|
init_runtime_policy_generated2();
|
|
85332
|
+
init_constants();
|
|
84615
85333
|
init_hyperliquid_public_read();
|
|
84616
85334
|
init_api2();
|
|
84617
85335
|
init_abort();
|
|
@@ -84836,9 +85554,9 @@ var init_hyperliquid_client = __esm({
|
|
|
84836
85554
|
if (explicit) {
|
|
84837
85555
|
return explicit;
|
|
84838
85556
|
}
|
|
84839
|
-
const
|
|
84840
|
-
if (
|
|
84841
|
-
return
|
|
85557
|
+
const configured2 = input.config?.client_runtime_exchange_endpoints?.hyperliquid_api_url?.trim();
|
|
85558
|
+
if (configured2) {
|
|
85559
|
+
return configured2;
|
|
84842
85560
|
}
|
|
84843
85561
|
throw new Error("Missing client runtime Hyperliquid API URL.");
|
|
84844
85562
|
};
|
|
@@ -86636,6 +87354,13 @@ var init_hyperliquid_client = __esm({
|
|
|
86636
87354
|
}
|
|
86637
87355
|
};
|
|
86638
87356
|
const settleDefinitiveSuccess = async (exchangeOrderId, orderMemberResults) => {
|
|
87357
|
+
const settlementPolicy = runtime_policy_generated_default2.trading.engine.client_runtime.exchange_mutation;
|
|
87358
|
+
const settlementDeadlineMs = globalThis.performance.now() + settlementPolicy.settlement_retry_window_seconds * MS_PER_SECOND;
|
|
87359
|
+
const handOffToReconciliation = () => {
|
|
87360
|
+
if (begunMutation != null && pinnedAuthority != null) {
|
|
87361
|
+
handOffClientExchangeMutationToReconciliation(begunMutation, pinnedAuthority);
|
|
87362
|
+
}
|
|
87363
|
+
};
|
|
86639
87364
|
while (true) {
|
|
86640
87365
|
try {
|
|
86641
87366
|
const settledMutation = await settleDurableMutation(
|
|
@@ -86651,15 +87376,14 @@ var init_hyperliquid_client = __esm({
|
|
|
86651
87376
|
}
|
|
86652
87377
|
return;
|
|
86653
87378
|
} catch (settlementError) {
|
|
87379
|
+
const settlementCause = settlementError.settlementCause;
|
|
86654
87380
|
if (input.signal?.aborted) {
|
|
87381
|
+
handOffToReconciliation();
|
|
86655
87382
|
throw input.signal.reason instanceof Error ? input.signal.reason : settlementError;
|
|
86656
87383
|
}
|
|
86657
|
-
|
|
86658
|
-
|
|
86659
|
-
|
|
86660
|
-
if (begunMutation != null && pinnedAuthority != null) {
|
|
86661
|
-
handOffClientExchangeMutationToReconciliation(begunMutation, pinnedAuthority);
|
|
86662
|
-
}
|
|
87384
|
+
const neverSettles = isClientExchangeMutationAuthorityConflict(settlementCause);
|
|
87385
|
+
if (neverSettles || globalThis.performance.now() + settlementPolicy.settlement_retry_milliseconds > settlementDeadlineMs) {
|
|
87386
|
+
handOffToReconciliation();
|
|
86663
87387
|
throw new RuntimeExecutionError(
|
|
86664
87388
|
"Exchange submission may have completed; durable reconciliation is pending.",
|
|
86665
87389
|
"outcome_unknown"
|
|
@@ -86674,7 +87398,10 @@ var init_hyperliquid_client = __esm({
|
|
|
86674
87398
|
input.signal?.removeEventListener("abort", finish);
|
|
86675
87399
|
resolve14();
|
|
86676
87400
|
};
|
|
86677
|
-
const timeoutId = globalThis.setTimeout(
|
|
87401
|
+
const timeoutId = globalThis.setTimeout(
|
|
87402
|
+
finish,
|
|
87403
|
+
settlementPolicy.settlement_retry_milliseconds
|
|
87404
|
+
);
|
|
86678
87405
|
input.signal?.addEventListener("abort", finish, { once: true });
|
|
86679
87406
|
});
|
|
86680
87407
|
}
|
|
@@ -87078,7 +87805,7 @@ async function getPreferences(cookie, profileId, signal, includeTradeLayouts = f
|
|
|
87078
87805
|
const schedulerInstanceId = String(runtimeAuthority?.schedulerInstanceId ?? "").trim() || void 0;
|
|
87079
87806
|
const baseRequestKey = clientPreferencesRequestKey(effectiveProfileId, includeTradeLayouts);
|
|
87080
87807
|
const requestKey = schedulerInstanceId ? `${baseRequestKey}:scheduler=${schedulerInstanceId}` : baseRequestKey;
|
|
87081
|
-
return shareClientGetRequest(requestKey, async () => {
|
|
87808
|
+
return shareClientGetRequest(requestKey, async (requestSignal) => {
|
|
87082
87809
|
const headers = getProfileHeaders({}, profileId);
|
|
87083
87810
|
if (cookie) {
|
|
87084
87811
|
headers["Cookie"] = cookie;
|
|
@@ -87101,7 +87828,7 @@ async function getPreferences(cookie, profileId, signal, includeTradeLayouts = f
|
|
|
87101
87828
|
credentials: "include",
|
|
87102
87829
|
cache: "no-store",
|
|
87103
87830
|
headers,
|
|
87104
|
-
signal:
|
|
87831
|
+
signal: requestSignal
|
|
87105
87832
|
});
|
|
87106
87833
|
if (!response.ok) {
|
|
87107
87834
|
throwUnauthorizedIfNeeded(response);
|
|
@@ -87261,7 +87988,7 @@ async function acknowledgeClientCopyTradingOrderAction(profileId, actionId, payl
|
|
|
87261
87988
|
}
|
|
87262
87989
|
async function getLLMConfig(cookie, profileId, signal) {
|
|
87263
87990
|
const effectiveProfileId = profileId ?? getActiveProfileId() ?? null;
|
|
87264
|
-
return shareClientGetRequest(clientGetRequestKey("llm-config", effectiveProfileId), async () => {
|
|
87991
|
+
return shareClientGetRequest(clientGetRequestKey("llm-config", effectiveProfileId), async (requestSignal) => {
|
|
87265
87992
|
const headers = getProfileHeaders({
|
|
87266
87993
|
"Content-Type": "application/json"
|
|
87267
87994
|
}, profileId);
|
|
@@ -87272,7 +87999,7 @@ async function getLLMConfig(cookie, profileId, signal) {
|
|
|
87272
87999
|
method: "GET",
|
|
87273
88000
|
headers,
|
|
87274
88001
|
credentials: "include",
|
|
87275
|
-
signal
|
|
88002
|
+
signal: requestSignal
|
|
87276
88003
|
});
|
|
87277
88004
|
if (!response.ok) {
|
|
87278
88005
|
const message = await getErrorMessageFromResponse(
|
|
@@ -88495,7 +89222,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
|
|
|
88495
89222
|
}
|
|
88496
89223
|
const viewer = resolveClientRuntimeStatusViewerHeaders(options?.runtimeViewer);
|
|
88497
89224
|
const requestKey = `client-runtime-statuses:${normalizedProfileIds.join(",")}${viewer.requestKey}`;
|
|
88498
|
-
return shareClientGetRequest(requestKey, async () => {
|
|
89225
|
+
return shareClientGetRequest(requestKey, async (requestSignal) => {
|
|
88499
89226
|
const headers = { ...viewer.headers };
|
|
88500
89227
|
const response = await apiFetch(
|
|
88501
89228
|
`${getApiUrl()}/trading/ai/runtime/statuses?${params.toString()}`,
|
|
@@ -88505,7 +89232,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
|
|
|
88505
89232
|
cache: "no-store",
|
|
88506
89233
|
headers,
|
|
88507
89234
|
// Without the browser's shared request a caller's abort ends the request too.
|
|
88508
|
-
signal:
|
|
89235
|
+
signal: requestSignal
|
|
88509
89236
|
}
|
|
88510
89237
|
);
|
|
88511
89238
|
if (!response.ok) {
|
|
@@ -89024,15 +89751,11 @@ var init_api2 = __esm({
|
|
|
89024
89751
|
CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH = "exchange_mutation_authority_mismatch";
|
|
89025
89752
|
isClientExchangeMutationAuthorityConflict = (error48) => {
|
|
89026
89753
|
const candidate = error48;
|
|
89754
|
+
if (clientRuntimeAuthorityEndedFromCode(error48)) return true;
|
|
89027
89755
|
if (Number(candidate?.status) !== 409) return false;
|
|
89028
|
-
|
|
89029
|
-
return /does not own this exchange mutation/i.test(String(candidate?.message ?? ""));
|
|
89756
|
+
return candidate?.code === CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH || /does not own this exchange mutation/i.test(String(candidate?.message ?? ""));
|
|
89030
89757
|
};
|
|
89031
|
-
handOffClientExchangeMutationToReconciliation = (mutation, authority) => scheduleClientExchangeMutationReconciliation(
|
|
89032
|
-
authority.numericProfileId,
|
|
89033
|
-
mutation,
|
|
89034
|
-
authority.requestOptions
|
|
89035
|
-
);
|
|
89758
|
+
handOffClientExchangeMutationToReconciliation = (mutation, authority) => scheduleClientExchangeMutationReconciliation(authority.numericProfileId, mutation, authority.requestOptions);
|
|
89036
89759
|
clientExchangeMutationAuthorityBody = (authority) => {
|
|
89037
89760
|
const schedulerInstanceId = String(authority.requestOptions.schedulerInstanceId ?? "").trim();
|
|
89038
89761
|
return {
|
|
@@ -89172,11 +89895,8 @@ var init_api2 = __esm({
|
|
|
89172
89895
|
const timer = globalThis.setTimeout(() => {
|
|
89173
89896
|
const scheduled = clientExchangeMutationReconciliationTimers.get(key);
|
|
89174
89897
|
clientExchangeMutationReconciliationTimers.delete(key);
|
|
89175
|
-
|
|
89176
|
-
|
|
89177
|
-
mutation.mutation_id,
|
|
89178
|
-
scheduled?.requestOptions ?? authority
|
|
89179
|
-
).catch(() => {
|
|
89898
|
+
const requestOptions2 = scheduled?.requestOptions ?? authority;
|
|
89899
|
+
void postClientExchangeMutationReconciliation(profileId, mutation.mutation_id, requestOptions2).catch((error48) => requestOptions2.runtimeLeaseToken && clientRuntimeAuthorityEndedFromCode(error48) ? postClientExchangeMutationReconciliation(profileId, mutation.mutation_id, { omitRuntimeLeaseToken: true }) : void 0).catch(() => {
|
|
89180
89900
|
});
|
|
89181
89901
|
}, Math.max(0, delayMs));
|
|
89182
89902
|
clientExchangeMutationReconciliationTimers.set(key, {
|
|
@@ -91546,10 +92266,10 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
91546
92266
|
};
|
|
91547
92267
|
listPerpDexsForAccountState = (config2, selectedDex, aggregatePerpDexs, perpDexScope) => {
|
|
91548
92268
|
if (aggregatePerpDexs) {
|
|
91549
|
-
const
|
|
91550
|
-
if (!perpDexScope) return
|
|
92269
|
+
const configured2 = listConfiguredPerpDexs(config2);
|
|
92270
|
+
if (!perpDexScope) return configured2;
|
|
91551
92271
|
const scope = new Set(perpDexScope.map(normalizePerpDexName));
|
|
91552
|
-
return
|
|
92272
|
+
return configured2.filter((dex) => scope.has(dex));
|
|
91553
92273
|
}
|
|
91554
92274
|
return selectedDex ? [selectedDex] : [];
|
|
91555
92275
|
};
|
|
@@ -93636,7 +94356,7 @@ function copiedTargetNow(reconciliation, recordedTarget, actualPosition) {
|
|
|
93636
94356
|
);
|
|
93637
94357
|
return { copiedNow, targetNow, kept: copiedTargetBesideOwnPosition(targetNow, copiedNow, actualPosition) };
|
|
93638
94358
|
}
|
|
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;
|
|
94359
|
+
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
94360
|
var init_runtime_execution = __esm({
|
|
93641
94361
|
"lib/runtime/runtime-execution.ts"() {
|
|
93642
94362
|
"use strict";
|
|
@@ -94698,6 +95418,18 @@ var init_runtime_execution = __esm({
|
|
|
94698
95418
|
input.executionContext.takeProfitMode === "usdc" ? input.executionContext.takeProfitUsdc : input.executionContext.takeProfitPct
|
|
94699
95419
|
) > 0);
|
|
94700
95420
|
protectiveAction = (leg) => leg.kind === "sl" ? "AUTO_SL" : "AUTO_TP";
|
|
95421
|
+
executedProtectiveReport = (input) => ({
|
|
95422
|
+
order_id: input.orderId,
|
|
95423
|
+
...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
|
|
95424
|
+
symbol: input.symbol,
|
|
95425
|
+
action: input.action,
|
|
95426
|
+
status: "executed",
|
|
95427
|
+
execution_metadata: {
|
|
95428
|
+
...input.metadata,
|
|
95429
|
+
protected_size: input.protectedSize,
|
|
95430
|
+
position_tpsl: input.positionTpsl
|
|
95431
|
+
}
|
|
95432
|
+
});
|
|
94701
95433
|
isExactClientPositionTpslPair = (legs) => legs.length === 2 && legs.every((leg) => leg.positionTpsl === true) && new Set(legs.map((leg) => leg.kind)).size === 2;
|
|
94702
95434
|
deviceOwnsClientProtectiveLegKind = (group, kind) => group.deviceOwnedLegKinds == null || group.deviceOwnedLegKinds.includes(kind);
|
|
94703
95435
|
isAdoptionNarrowedPositionTpslLeg = (group) => group.deviceOwnedLegKinds?.length === 1 && group.legs.length === 1 && group.legs[0].positionTpsl === true && group.legs[0].kind === group.deviceOwnedLegKinds[0];
|
|
@@ -94797,19 +95529,18 @@ var init_runtime_execution = __esm({
|
|
|
94797
95529
|
if (!terminalShapeMatches) {
|
|
94798
95530
|
throw new Error("Tracked protective order is absent without exact terminal shape evidence.");
|
|
94799
95531
|
}
|
|
94800
|
-
return {
|
|
94801
|
-
|
|
95532
|
+
return executedProtectiveReport({
|
|
95533
|
+
orderId: String(leg.orderId),
|
|
94802
95534
|
symbol: symbol2,
|
|
94803
95535
|
action: protectiveAction(leg),
|
|
94804
|
-
|
|
94805
|
-
|
|
95536
|
+
protectedSize: leg.size,
|
|
95537
|
+
positionTpsl: leg.positionTpsl === true || evidence.isPositionTpsl === true,
|
|
95538
|
+
metadata: {
|
|
94806
95539
|
trigger_price: leg.triggerPrice,
|
|
94807
95540
|
reason_code: reasonCode,
|
|
94808
|
-
terminal_order_status: evidence.orderStatus
|
|
94809
|
-
protected_size: leg.size,
|
|
94810
|
-
position_tpsl: leg.positionTpsl === true || evidence.isPositionTpsl === true
|
|
95541
|
+
terminal_order_status: evidence.orderStatus
|
|
94811
95542
|
}
|
|
94812
|
-
};
|
|
95543
|
+
});
|
|
94813
95544
|
}
|
|
94814
95545
|
if (!protectiveLiveShapeMatches({
|
|
94815
95546
|
shape: {
|
|
@@ -95456,20 +96187,19 @@ var init_runtime_execution = __esm({
|
|
|
95456
96187
|
const activeLegs = acknowledgedLegs.filter((_leg, index) => acknowledgements[index].state === "active");
|
|
95457
96188
|
const mixedPositionTpslAcknowledgement = positionTpsl && activeLegs.length === 1 && acknowledgements.some((acknowledgement) => acknowledgement.state === "fulfilled");
|
|
95458
96189
|
for (let index = 0; index < candidates.length; index += 1) {
|
|
95459
|
-
reports.push({
|
|
95460
|
-
|
|
95461
|
-
|
|
96190
|
+
reports.push(executedProtectiveReport({
|
|
96191
|
+
orderId: acknowledgements[index].orderId,
|
|
96192
|
+
clientMutationId: candidates[index].mutationId,
|
|
95462
96193
|
symbol: symbol2,
|
|
95463
96194
|
action: candidates[index].kind === "sl" ? "AUTO_SL" : "AUTO_TP",
|
|
95464
|
-
|
|
95465
|
-
|
|
96195
|
+
protectedSize: candidates[index].size,
|
|
96196
|
+
positionTpsl,
|
|
96197
|
+
metadata: {
|
|
95466
96198
|
trigger_price: candidates[index].triggerPrice,
|
|
95467
|
-
protected_size: candidates[index].size,
|
|
95468
96199
|
entry_filled_size: fill.filledSize,
|
|
95469
|
-
entry_average_price: fill.averagePrice
|
|
95470
|
-
position_tpsl: positionTpsl
|
|
96200
|
+
entry_average_price: fill.averagePrice
|
|
95471
96201
|
}
|
|
95472
|
-
});
|
|
96202
|
+
}));
|
|
95473
96203
|
}
|
|
95474
96204
|
const acknowledgedGroup = activeLegs.length > 0 ? {
|
|
95475
96205
|
...activeGroup,
|
|
@@ -96468,20 +97198,19 @@ var init_runtime_execution = __esm({
|
|
|
96468
97198
|
if (!retired) {
|
|
96469
97199
|
throw new Error("Terminal protective replacement could not be retired durably.");
|
|
96470
97200
|
}
|
|
96471
|
-
reports.push({
|
|
96472
|
-
|
|
96473
|
-
|
|
97201
|
+
reports.push(executedProtectiveReport({
|
|
97202
|
+
orderId: String(evidence.orderId ?? replacement.clientOrderId),
|
|
97203
|
+
clientMutationId: replacement.mutationId,
|
|
96474
97204
|
symbol: symbol2,
|
|
96475
97205
|
action: protectiveAction(leg),
|
|
96476
|
-
|
|
96477
|
-
|
|
97206
|
+
protectedSize: replacementLeg.size,
|
|
97207
|
+
positionTpsl: replacementLeg.positionTpsl === true,
|
|
97208
|
+
metadata: {
|
|
96478
97209
|
reason_code: "protective_replacement_terminal_reconciled",
|
|
96479
97210
|
previous_order_id: replacement.previousOrderId,
|
|
96480
|
-
order_status: evidence.orderStatus
|
|
96481
|
-
protected_size: replacementLeg.size,
|
|
96482
|
-
position_tpsl: replacementLeg.positionTpsl === true
|
|
97211
|
+
order_status: evidence.orderStatus
|
|
96483
97212
|
}
|
|
96484
|
-
});
|
|
97213
|
+
}));
|
|
96485
97214
|
continue;
|
|
96486
97215
|
}
|
|
96487
97216
|
const ambiguousPositionTpslAuthority = hasAmbiguousClientPositionTpslAuthority(group);
|
|
@@ -96525,20 +97254,19 @@ var init_runtime_execution = __esm({
|
|
|
96525
97254
|
if (!recovered) {
|
|
96526
97255
|
throw new Error("Ambiguous position-TPSL replacement could not be bound durably.");
|
|
96527
97256
|
}
|
|
96528
|
-
reports.push({
|
|
96529
|
-
|
|
96530
|
-
|
|
97257
|
+
reports.push(executedProtectiveReport({
|
|
97258
|
+
orderId: String(replacementOrderId),
|
|
97259
|
+
clientMutationId: replacement.mutationId,
|
|
96531
97260
|
symbol: symbol2,
|
|
96532
97261
|
action: protectiveAction(leg),
|
|
96533
|
-
|
|
96534
|
-
|
|
97262
|
+
protectedSize: replacement.size,
|
|
97263
|
+
positionTpsl: recoveredLeg.positionTpsl === true,
|
|
97264
|
+
metadata: {
|
|
96535
97265
|
reason_code: exactLivePositionTpsl ? "protective_replacement_reconciled_for_cleanup" : "protective_replacement_reconciled",
|
|
96536
97266
|
previous_order_id: replacement.previousOrderId,
|
|
96537
|
-
trigger_price: replacement.triggerPrice
|
|
96538
|
-
protected_size: replacement.size,
|
|
96539
|
-
position_tpsl: recoveredLeg.positionTpsl === true
|
|
97267
|
+
trigger_price: replacement.triggerPrice
|
|
96540
97268
|
}
|
|
96541
|
-
});
|
|
97269
|
+
}));
|
|
96542
97270
|
continue;
|
|
96543
97271
|
}
|
|
96544
97272
|
if (ambiguousPositionTpslAuthority && classifyHyperliquidOrderStatus(evidence.orderStatus) !== "filled") {
|
|
@@ -96571,20 +97299,19 @@ var init_runtime_execution = __esm({
|
|
|
96571
97299
|
throw new Error("Fulfilled protective replacement could not be resolved durably.");
|
|
96572
97300
|
}
|
|
96573
97301
|
removeTrackedTrailingStop(profileId, symbol2, replacement.previousOrderId);
|
|
96574
|
-
reports.push({
|
|
96575
|
-
|
|
96576
|
-
|
|
97302
|
+
reports.push(executedProtectiveReport({
|
|
97303
|
+
orderId: String(replacementOrderId),
|
|
97304
|
+
clientMutationId: replacement.mutationId,
|
|
96577
97305
|
symbol: symbol2,
|
|
96578
97306
|
action: protectiveAction(leg),
|
|
96579
|
-
|
|
96580
|
-
|
|
97307
|
+
protectedSize: replacement.size,
|
|
97308
|
+
positionTpsl: leg.positionTpsl === true,
|
|
97309
|
+
metadata: {
|
|
96581
97310
|
reason_code: "protective_replacement_fulfilled_reconciled",
|
|
96582
97311
|
previous_order_id: replacement.previousOrderId,
|
|
96583
|
-
trigger_price: replacement.triggerPrice
|
|
96584
|
-
protected_size: replacement.size,
|
|
96585
|
-
position_tpsl: leg.positionTpsl === true
|
|
97312
|
+
trigger_price: replacement.triggerPrice
|
|
96586
97313
|
}
|
|
96587
|
-
});
|
|
97314
|
+
}));
|
|
96588
97315
|
continue;
|
|
96589
97316
|
}
|
|
96590
97317
|
let shapeMatches = exactShapeMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open";
|
|
@@ -96626,21 +97353,20 @@ var init_runtime_execution = __esm({
|
|
|
96626
97353
|
if (replacementCleanup == null || !clearClientRuntimeVetoedProtectiveIntent(replacementCleanup)) {
|
|
96627
97354
|
throw new Error("Unapplied protective replacement could not be abandoned durably.");
|
|
96628
97355
|
}
|
|
96629
|
-
reports.push({
|
|
96630
|
-
|
|
96631
|
-
|
|
97356
|
+
reports.push(executedProtectiveReport({
|
|
97357
|
+
orderId: String(replacement.previousOrderId),
|
|
97358
|
+
clientMutationId: replacement.mutationId,
|
|
96632
97359
|
symbol: symbol2,
|
|
96633
97360
|
action: protectiveAction(effectiveLeg),
|
|
96634
|
-
|
|
96635
|
-
|
|
97361
|
+
protectedSize: effectiveLeg.size,
|
|
97362
|
+
positionTpsl: effectiveLeg.positionTpsl === true,
|
|
97363
|
+
metadata: {
|
|
96636
97364
|
reason_code: "protective_replacement_abandoned_original_filled",
|
|
96637
97365
|
previous_order_id: replacement.previousOrderId,
|
|
96638
97366
|
order_status: originalEvidence.orderStatus,
|
|
96639
|
-
trigger_price: effectiveLeg.triggerPrice
|
|
96640
|
-
protected_size: effectiveLeg.size,
|
|
96641
|
-
position_tpsl: effectiveLeg.positionTpsl === true
|
|
97367
|
+
trigger_price: effectiveLeg.triggerPrice
|
|
96642
97368
|
}
|
|
96643
|
-
});
|
|
97369
|
+
}));
|
|
96644
97370
|
continue;
|
|
96645
97371
|
}
|
|
96646
97372
|
}
|
|
@@ -96650,20 +97376,19 @@ var init_runtime_execution = __esm({
|
|
|
96650
97376
|
if (replacementCleanup == null || !clearClientRuntimeVetoedProtectiveIntent(replacementCleanup)) {
|
|
96651
97377
|
throw new Error("Undispatched protective replacement could not be abandoned durably.");
|
|
96652
97378
|
}
|
|
96653
|
-
reports.push({
|
|
96654
|
-
|
|
96655
|
-
|
|
97379
|
+
reports.push(executedProtectiveReport({
|
|
97380
|
+
orderId: String(replacement.previousOrderId),
|
|
97381
|
+
clientMutationId: replacement.mutationId,
|
|
96656
97382
|
symbol: symbol2,
|
|
96657
97383
|
action: protectiveAction(effectiveLeg),
|
|
96658
|
-
|
|
96659
|
-
|
|
97384
|
+
protectedSize: effectiveLeg.size,
|
|
97385
|
+
positionTpsl: effectiveLeg.positionTpsl === true,
|
|
97386
|
+
metadata: {
|
|
96660
97387
|
reason_code: "protective_replacement_abandoned_undispatched",
|
|
96661
97388
|
previous_order_id: replacement.previousOrderId,
|
|
96662
|
-
trigger_price: effectiveLeg.triggerPrice
|
|
96663
|
-
protected_size: effectiveLeg.size,
|
|
96664
|
-
position_tpsl: effectiveLeg.positionTpsl === true
|
|
97389
|
+
trigger_price: effectiveLeg.triggerPrice
|
|
96665
97390
|
}
|
|
96666
|
-
});
|
|
97391
|
+
}));
|
|
96667
97392
|
continue;
|
|
96668
97393
|
}
|
|
96669
97394
|
const replayReservation = replacementReservation;
|
|
@@ -96731,20 +97456,19 @@ var init_runtime_execution = __esm({
|
|
|
96731
97456
|
}
|
|
96732
97457
|
});
|
|
96733
97458
|
}
|
|
96734
|
-
reports.push({
|
|
96735
|
-
|
|
96736
|
-
|
|
97459
|
+
reports.push(executedProtectiveReport({
|
|
97460
|
+
orderId: String(replacementOrderId),
|
|
97461
|
+
clientMutationId: replacement.mutationId,
|
|
96737
97462
|
symbol: symbol2,
|
|
96738
97463
|
action: protectiveAction(effectiveLeg),
|
|
96739
|
-
|
|
96740
|
-
|
|
97464
|
+
protectedSize: replacement.size,
|
|
97465
|
+
positionTpsl: effectiveLeg.positionTpsl === true,
|
|
97466
|
+
metadata: {
|
|
96741
97467
|
reason_code: acknowledgement.state === "fulfilled" ? "protective_replacement_fulfilled_reconciled" : "protective_replacement_reconciled",
|
|
96742
97468
|
previous_order_id: replacement.previousOrderId,
|
|
96743
|
-
trigger_price: replacement.triggerPrice
|
|
96744
|
-
protected_size: replacement.size,
|
|
96745
|
-
position_tpsl: effectiveLeg.positionTpsl === true
|
|
97469
|
+
trigger_price: replacement.triggerPrice
|
|
96746
97470
|
}
|
|
96747
|
-
});
|
|
97471
|
+
}));
|
|
96748
97472
|
continue;
|
|
96749
97473
|
}
|
|
96750
97474
|
}
|
|
@@ -96770,20 +97494,19 @@ var init_runtime_execution = __esm({
|
|
|
96770
97494
|
if (!bound) {
|
|
96771
97495
|
throw new Error("Pending protective replacement could not be bound durably.");
|
|
96772
97496
|
}
|
|
96773
|
-
reports.push({
|
|
96774
|
-
|
|
96775
|
-
|
|
97497
|
+
reports.push(executedProtectiveReport({
|
|
97498
|
+
orderId: String(replacementOrderId),
|
|
97499
|
+
clientMutationId: replacement.mutationId,
|
|
96776
97500
|
symbol: symbol2,
|
|
96777
97501
|
action: protectiveAction(effectiveLeg),
|
|
96778
|
-
|
|
96779
|
-
|
|
97502
|
+
protectedSize: replacement.size,
|
|
97503
|
+
positionTpsl: canonicalReplacementLeg.positionTpsl === true,
|
|
97504
|
+
metadata: {
|
|
96780
97505
|
reason_code: "protective_replacement_reconciled",
|
|
96781
97506
|
previous_order_id: replacement.previousOrderId,
|
|
96782
|
-
trigger_price: replacement.triggerPrice
|
|
96783
|
-
protected_size: replacement.size,
|
|
96784
|
-
position_tpsl: canonicalReplacementLeg.positionTpsl === true
|
|
97507
|
+
trigger_price: replacement.triggerPrice
|
|
96785
97508
|
}
|
|
96786
|
-
});
|
|
97509
|
+
}));
|
|
96787
97510
|
} catch (error48) {
|
|
96788
97511
|
if (replayAttemptStarted && !replayDispatchBoundaryCompleted && replacementCleanup != null) {
|
|
96789
97512
|
if (isClientRuntimeWindowHandoffBeforePlanDispatch(error48)) {
|
|
@@ -96849,19 +97572,18 @@ var init_runtime_execution = __esm({
|
|
|
96849
97572
|
if (!replaceExactClientProtectiveGroup(profileId, symbol2, journalGroup, null)) {
|
|
96850
97573
|
throw new Error("Terminal replacement journal could not be retired durably.");
|
|
96851
97574
|
}
|
|
96852
|
-
reports.push({
|
|
96853
|
-
|
|
96854
|
-
|
|
97575
|
+
reports.push(executedProtectiveReport({
|
|
97576
|
+
orderId: String(evidence.orderId ?? journalLeg.orderId),
|
|
97577
|
+
clientMutationId: mutationId,
|
|
96855
97578
|
symbol: symbol2,
|
|
96856
97579
|
action: protectiveAction(journalLeg),
|
|
96857
|
-
|
|
96858
|
-
|
|
97580
|
+
protectedSize: journalLeg.size,
|
|
97581
|
+
positionTpsl: journalLeg.positionTpsl === true || evidence.isPositionTpsl === true,
|
|
97582
|
+
metadata: {
|
|
96859
97583
|
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
|
|
97584
|
+
order_status: evidence.orderStatus
|
|
96863
97585
|
}
|
|
96864
|
-
});
|
|
97586
|
+
}));
|
|
96865
97587
|
continue;
|
|
96866
97588
|
}
|
|
96867
97589
|
const liveShape = {
|
|
@@ -97653,22 +98375,21 @@ var init_runtime_execution = __esm({
|
|
|
97653
98375
|
return {
|
|
97654
98376
|
retain: bound ? placedLeg : provisionalLeg,
|
|
97655
98377
|
group: bound ? placedGroup : provisionalGroup,
|
|
97656
|
-
reports: [{
|
|
97657
|
-
|
|
97658
|
-
|
|
98378
|
+
reports: [executedProtectiveReport({
|
|
98379
|
+
orderId: String(placedOrderId),
|
|
98380
|
+
clientMutationId: mutationId,
|
|
97659
98381
|
symbol: symbol2,
|
|
97660
98382
|
action: protectiveAction(leg),
|
|
97661
|
-
|
|
97662
|
-
|
|
98383
|
+
protectedSize: decision.size,
|
|
98384
|
+
positionTpsl: false,
|
|
98385
|
+
metadata: {
|
|
97663
98386
|
reason_code: decision.reasonCode,
|
|
97664
98387
|
replaced_order_id: lostOrderId,
|
|
97665
98388
|
trigger_price: triggerPrice,
|
|
97666
|
-
protected_size: decision.size,
|
|
97667
98389
|
live_position_size: livePositionSize2,
|
|
97668
|
-
position_tpsl: false,
|
|
97669
98390
|
...acknowledgement.state === "fulfilled" ? { acknowledgement_state: "fulfilled" } : {}
|
|
97670
98391
|
}
|
|
97671
|
-
}]
|
|
98392
|
+
})]
|
|
97672
98393
|
};
|
|
97673
98394
|
};
|
|
97674
98395
|
groupLoop: for (let groupIndex = 0; groupIndex < inspectedGroups.length; groupIndex += 1) {
|
|
@@ -97967,19 +98688,18 @@ var init_runtime_execution = __esm({
|
|
|
97967
98688
|
} else {
|
|
97968
98689
|
removeTrackedTrailingStop(profileId, symbol2, leg.orderId);
|
|
97969
98690
|
}
|
|
97970
|
-
reports.push({
|
|
97971
|
-
|
|
97972
|
-
|
|
98691
|
+
reports.push(executedProtectiveReport({
|
|
98692
|
+
orderId: String(replacementOrderId),
|
|
98693
|
+
clientMutationId: _extractClientMutationId(response),
|
|
97973
98694
|
symbol: symbol2,
|
|
97974
98695
|
action: protectiveAction(leg),
|
|
97975
|
-
|
|
97976
|
-
|
|
98696
|
+
protectedSize: allowedSize,
|
|
98697
|
+
positionTpsl: replacementLeg.positionTpsl === true,
|
|
98698
|
+
metadata: {
|
|
97977
98699
|
reason_code: "protective_resized_to_live_exposure",
|
|
97978
|
-
previous_order_id: leg.orderId
|
|
97979
|
-
protected_size: allowedSize,
|
|
97980
|
-
position_tpsl: replacementLeg.positionTpsl === true
|
|
98700
|
+
previous_order_id: leg.orderId
|
|
97981
98701
|
}
|
|
97982
|
-
});
|
|
98702
|
+
}));
|
|
97983
98703
|
if (fulfilledDuringResize) {
|
|
97984
98704
|
reports.push({
|
|
97985
98705
|
order_id: String(replacementOrderId),
|
|
@@ -98429,20 +99149,19 @@ var init_runtime_execution = __esm({
|
|
|
98429
99149
|
}
|
|
98430
99150
|
});
|
|
98431
99151
|
}
|
|
98432
|
-
reports.push({
|
|
98433
|
-
|
|
98434
|
-
|
|
99152
|
+
reports.push(executedProtectiveReport({
|
|
99153
|
+
orderId: String(replacementOrderId),
|
|
99154
|
+
clientMutationId: _extractClientMutationId(modifyResponse),
|
|
98435
99155
|
symbol: symbol2,
|
|
98436
99156
|
action: "AUTO_TRAILING_SL",
|
|
98437
|
-
|
|
98438
|
-
|
|
99157
|
+
protectedSize: effectiveSize,
|
|
99158
|
+
positionTpsl: record5.positionTpsl === true,
|
|
99159
|
+
metadata: {
|
|
98439
99160
|
trigger_price: replacementTriggerPrice,
|
|
98440
99161
|
previous_trigger_price: record5.triggerPrice,
|
|
98441
|
-
previous_order_id: record5.orderId
|
|
98442
|
-
protected_size: effectiveSize,
|
|
98443
|
-
position_tpsl: record5.positionTpsl === true
|
|
99162
|
+
previous_order_id: record5.orderId
|
|
98444
99163
|
}
|
|
98445
|
-
});
|
|
99164
|
+
}));
|
|
98446
99165
|
} catch (error48) {
|
|
98447
99166
|
const cleanup = buildVetoedProtectiveReplacementCleanup(reservation);
|
|
98448
99167
|
if (!replacementDispatchBoundaryCompleted) {
|
|
@@ -100408,22 +101127,21 @@ var init_runtime_execution = __esm({
|
|
|
100408
101127
|
}
|
|
100409
101128
|
);
|
|
100410
101129
|
}
|
|
100411
|
-
executionReports.push({
|
|
100412
|
-
|
|
100413
|
-
|
|
101130
|
+
executionReports.push(executedProtectiveReport({
|
|
101131
|
+
orderId: String(triggerOrderId),
|
|
101132
|
+
clientMutationId: _extractClientMutationId(triggerResponse),
|
|
100414
101133
|
symbol: input.executionContext.symbol,
|
|
100415
101134
|
action: triggerInput.label,
|
|
100416
|
-
|
|
100417
|
-
|
|
101135
|
+
protectedSize: legSize,
|
|
101136
|
+
positionTpsl: leg.positionTpsl === true,
|
|
101137
|
+
metadata: {
|
|
100418
101138
|
trigger_price: triggerInput.triggerPrice,
|
|
100419
101139
|
is_take_profit: triggerInput.isTakeProfit,
|
|
100420
101140
|
entry_filled_size: protectionSize,
|
|
100421
|
-
protected_size: legSize,
|
|
100422
|
-
position_tpsl: leg.positionTpsl === true,
|
|
100423
101141
|
entry_average_price: protectionEntryPrice,
|
|
100424
101142
|
..._toExecutionMetadata(triggerResponse)
|
|
100425
101143
|
}
|
|
100426
|
-
});
|
|
101144
|
+
}));
|
|
100427
101145
|
appendRuntimeDebugEvent({
|
|
100428
101146
|
label: "execution_auto_sl_tp_submitted",
|
|
100429
101147
|
note: `symbol=${input.executionContext.symbol} kind=${triggerInput.isTakeProfit ? "tp" : "sl"} side=${exitSide} sizeAsset=${legSize} triggerPrice=${triggerInput.triggerPrice} order_id=${triggerOrderId}`
|
|
@@ -101085,7 +101803,7 @@ var init_protective_adoption_status = __esm({
|
|
|
101085
101803
|
});
|
|
101086
101804
|
|
|
101087
101805
|
// lib/runtime/protective-cutover.ts
|
|
101088
|
-
var ADOPTION_REQUEST_TIMEOUT_MS, ADOPTION_FAILURE_RETRY_MS, adoptWithinTimeout, adoptionRetryAt,
|
|
101806
|
+
var ADOPTION_REQUEST_TIMEOUT_MS, ADOPTION_FAILURE_RETRY_MS, adoptWithinTimeout, adoptionRetryAt, protectiveActionsPendingListeners, onClientProtectiveActionsPending, notifyClientProtectiveActionsPending, adoptionLegOutcomes, hasGroupsToAdopt, shouldSyncServerOwnedProtection, syncServerOwnedProtection;
|
|
101089
101807
|
var init_protective_cutover = __esm({
|
|
101090
101808
|
"lib/runtime/protective-cutover.ts"() {
|
|
101091
101809
|
"use strict";
|
|
@@ -101126,7 +101844,6 @@ var init_protective_cutover = __esm({
|
|
|
101126
101844
|
}
|
|
101127
101845
|
};
|
|
101128
101846
|
adoptionRetryAt = /* @__PURE__ */ new Map();
|
|
101129
|
-
CLIENT_PROTECTIVE_ACTIONS_EVENT = "vtx:client-protective-actions";
|
|
101130
101847
|
protectiveActionsPendingListeners = /* @__PURE__ */ new Set();
|
|
101131
101848
|
onClientProtectiveActionsPending = (listener) => {
|
|
101132
101849
|
protectiveActionsPendingListeners.add(listener);
|
|
@@ -101141,10 +101858,6 @@ var init_protective_cutover = __esm({
|
|
|
101141
101858
|
} catch {
|
|
101142
101859
|
}
|
|
101143
101860
|
}
|
|
101144
|
-
if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
|
|
101145
|
-
window.dispatchEvent(new CustomEvent(CLIENT_PROTECTIVE_ACTIONS_EVENT, {
|
|
101146
|
-
detail: { profileId: String(profileId) }
|
|
101147
|
-
}));
|
|
101148
101861
|
};
|
|
101149
101862
|
adoptionLegOutcomes = (groups, adoption) => {
|
|
101150
101863
|
if (Array.isArray(adoption.leg_outcomes)) return adoption.leg_outcomes;
|
|
@@ -102603,6 +103316,23 @@ var init_desktop_bridge = __esm({
|
|
|
102603
103316
|
}
|
|
102604
103317
|
});
|
|
102605
103318
|
|
|
103319
|
+
// lib/runtime/host/environment.ts
|
|
103320
|
+
function runtimeHostSurface() {
|
|
103321
|
+
if (configured) return configured.surface;
|
|
103322
|
+
return getDesktopBridge() ? "desktop" : "browser";
|
|
103323
|
+
}
|
|
103324
|
+
var configured;
|
|
103325
|
+
var init_environment = __esm({
|
|
103326
|
+
"lib/runtime/host/environment.ts"() {
|
|
103327
|
+
"use strict";
|
|
103328
|
+
init_define_VTX_EXO_POLICY();
|
|
103329
|
+
init_define_VTX_GROK_POLICY();
|
|
103330
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
103331
|
+
init_desktop_bridge();
|
|
103332
|
+
configured = null;
|
|
103333
|
+
}
|
|
103334
|
+
});
|
|
103335
|
+
|
|
102606
103336
|
// lib/runtime/client-ownership-arbitration-contract.ts
|
|
102607
103337
|
var deriveOwnershipLossReasonFromRuntimeError;
|
|
102608
103338
|
var init_client_ownership_arbitration_contract = __esm({
|
|
@@ -102624,15 +103354,17 @@ var init_client_runtime_device_id = __esm({
|
|
|
102624
103354
|
init_define_VTX_EXO_POLICY();
|
|
102625
103355
|
init_define_VTX_GROK_POLICY();
|
|
102626
103356
|
init_define_VTX_PI_MODEL_POLICY();
|
|
103357
|
+
init_host_storage();
|
|
102627
103358
|
CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY = "vtx_client_runtime_device_id";
|
|
102628
103359
|
createDeviceId = () => typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `device-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
102629
103360
|
getOrCreateClientRuntimeDeviceId = () => {
|
|
102630
|
-
|
|
103361
|
+
const storage3 = runtimeHostStorage();
|
|
103362
|
+
if (!storage3) return null;
|
|
102631
103363
|
try {
|
|
102632
|
-
const existing =
|
|
103364
|
+
const existing = storage3.getItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY)?.trim();
|
|
102633
103365
|
if (existing) return existing;
|
|
102634
103366
|
const created = createDeviceId();
|
|
102635
|
-
|
|
103367
|
+
storage3.setItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY, created);
|
|
102636
103368
|
return created;
|
|
102637
103369
|
} catch {
|
|
102638
103370
|
return createDeviceId();
|
|
@@ -104076,7 +104808,7 @@ var require_react = __commonJS({
|
|
|
104076
104808
|
});
|
|
104077
104809
|
|
|
104078
104810
|
// 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;
|
|
104811
|
+
var import_react, finiteOrNull2, readMode, orderKey, sameOwnerSeries, hasGenerations, compareClientRuntimeStatusOrder, sameGenerations, LIVENESS_CLOCK_FIELDS, sameValue, sameVisibleState, definedFields, readServerBackup, PROFILE_FIELDS, keepProfileFields, ClientRuntimeStatusStore, clientRuntimeStatusStore;
|
|
104080
104812
|
var init_client_runtime_status_store = __esm({
|
|
104081
104813
|
"lib/runtime/client-runtime-status-store.ts"() {
|
|
104082
104814
|
"use strict";
|
|
@@ -104139,6 +104871,17 @@ var init_client_runtime_status_store = __esm({
|
|
|
104139
104871
|
return true;
|
|
104140
104872
|
};
|
|
104141
104873
|
definedFields = (status) => Object.fromEntries(Object.entries(status).filter(([, value]) => value !== void 0));
|
|
104874
|
+
readServerBackup = (value) => value && typeof value === "object" && typeof value.active === "boolean" ? value : null;
|
|
104875
|
+
PROFILE_FIELDS = ["execution_mode", "server_backup"];
|
|
104876
|
+
keepProfileFields = (current, incoming) => {
|
|
104877
|
+
const kept = {};
|
|
104878
|
+
for (const field of PROFILE_FIELDS) {
|
|
104879
|
+
if (incoming[field] === void 0 && current[field] !== void 0) {
|
|
104880
|
+
kept[field] = current[field];
|
|
104881
|
+
}
|
|
104882
|
+
}
|
|
104883
|
+
return { ...kept, ...incoming };
|
|
104884
|
+
};
|
|
104142
104885
|
ClientRuntimeStatusStore = class {
|
|
104143
104886
|
constructor() {
|
|
104144
104887
|
this.entries = /* @__PURE__ */ new Map();
|
|
@@ -104163,7 +104906,7 @@ var init_client_runtime_status_store = __esm({
|
|
|
104163
104906
|
} else {
|
|
104164
104907
|
const order = compareClientRuntimeStatusOrder(incoming, current);
|
|
104165
104908
|
if (order < 0) return false;
|
|
104166
|
-
next = sameGenerations(incoming, current) || !hasGenerations(orderKey(incoming)) ? { ...current, ...incoming } : incoming;
|
|
104909
|
+
next = sameGenerations(incoming, current) || !hasGenerations(orderKey(incoming)) ? { ...current, ...incoming } : keepProfileFields(current, incoming);
|
|
104167
104910
|
if (sameVisibleState(next, current)) {
|
|
104168
104911
|
const clocks = Object.fromEntries(
|
|
104169
104912
|
Object.entries(next).filter(([field]) => LIVENESS_CLOCK_FIELDS.has(field))
|
|
@@ -104180,6 +104923,21 @@ var init_client_runtime_status_store = __esm({
|
|
|
104180
104923
|
this.emit();
|
|
104181
104924
|
return true;
|
|
104182
104925
|
}
|
|
104926
|
+
/**
|
|
104927
|
+
* Record the server's backup state from an answer that carries only that
|
|
104928
|
+
* (a readiness report's): it updates the profile's entry, and is dropped
|
|
104929
|
+
* when this browser has no status for the profile yet. Returns true when
|
|
104930
|
+
* the entry changed.
|
|
104931
|
+
*/
|
|
104932
|
+
recordServerBackup(profileId, backup) {
|
|
104933
|
+
const key = String(profileId ?? "").trim();
|
|
104934
|
+
const current = key ? this.entries.get(key) : void 0;
|
|
104935
|
+
const next = readServerBackup(backup);
|
|
104936
|
+
if (!current || !next || sameValue(current.server_backup, next)) return false;
|
|
104937
|
+
this.entries.set(key, { ...current, server_backup: next });
|
|
104938
|
+
this.emit();
|
|
104939
|
+
return true;
|
|
104940
|
+
}
|
|
104183
104941
|
get(profileId) {
|
|
104184
104942
|
const key = String(profileId ?? "").trim();
|
|
104185
104943
|
return key ? this.entries.get(key) ?? null : null;
|
|
@@ -104233,9 +104991,9 @@ var init_client_killswitch = __esm({
|
|
|
104233
104991
|
return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
|
|
104234
104992
|
};
|
|
104235
104993
|
firstConfiguredSymbol = (preferences, config2) => {
|
|
104236
|
-
const
|
|
104994
|
+
const configured2 = Array.isArray(preferences.trading_symbols) ? preferences.trading_symbols.map((value) => String(value || "").trim()).find(Boolean) : null;
|
|
104237
104995
|
const fallback = String(config2.default_chart_symbol || "").trim();
|
|
104238
|
-
const symbol2 =
|
|
104996
|
+
const symbol2 = configured2 || fallback;
|
|
104239
104997
|
if (!symbol2) {
|
|
104240
104998
|
throw new Error("Client killswitch requires a configured trading symbol.");
|
|
104241
104999
|
}
|
|
@@ -105203,13 +105961,14 @@ var init_candle_prompt_contract = __esm({
|
|
|
105203
105961
|
});
|
|
105204
105962
|
|
|
105205
105963
|
// lib/runtime/decision-contract.ts
|
|
105206
|
-
var JSON_FENCE_PATTERN, JSON_SIMPLE_ESCAPE_CHARS, JSON_HEX_ESCAPE_PATTERN, INTERNAL_REASONING_XML_BLOCK_PATTERN, INTERNAL_REASONING_BRACKET_BLOCK_PATTERN, INTERNAL_REASONING_DELIMITER_BLOCK_PATTERN, INTERNAL_REASONING_XML_OPEN_TAIL_PATTERN, INTERNAL_REASONING_BRACKET_OPEN_TAIL_PATTERN, INTERNAL_REASONING_DELIMITER_OPEN_TAIL_PATTERN, VISIBLE_REASONING_KEYS, VISIBLE_REASONING_KEY_SET, VISIBLE_REASONING_ALIAS_KEY_SET, isRecord5, isVisibleReasoningKey, sanitizeVisibleRuntimeText, resolveVisibleReasoningText, unwrapJsonMarkdownFence, repairJsonStringEscapes, repairJsonStringQuotes, repairJsonStringControlCharacters, repairJsonStringSyntax, decodeStrictDecisionPayload, extractJsonObjectCandidates, isLegacyScalarDecision, decisionSymbolKeysForCandidate, selectRankedDecisionCandidate, extractJsonObjectPayload, toCanonicalDecisionPayload, normalizeDecisionUnits, normalizeDecisionValue, normalizeTradabilityScore, extractNormalizedDecision, classifyDecisionParseOutcome;
|
|
105964
|
+
var JSON_FENCE_PATTERN, JSON_SIMPLE_ESCAPE_CHARS, JSON_HEX_ESCAPE_PATTERN, INTERNAL_REASONING_XML_BLOCK_PATTERN, INTERNAL_REASONING_BRACKET_BLOCK_PATTERN, INTERNAL_REASONING_DELIMITER_BLOCK_PATTERN, INTERNAL_REASONING_XML_OPEN_TAIL_PATTERN, INTERNAL_REASONING_BRACKET_OPEN_TAIL_PATTERN, INTERNAL_REASONING_DELIMITER_OPEN_TAIL_PATTERN, VISIBLE_REASONING_KEYS, VISIBLE_REASONING_KEY_SET, VISIBLE_REASONING_ALIAS_KEY_SET, isRecord5, isVisibleReasoningKey, sanitizeVisibleRuntimeText, resolveVisibleReasoningText, unwrapJsonMarkdownFence, repairJsonStringEscapes, repairJsonStringQuotes, repairJsonStringControlCharacters, repairJsonStringSyntax, decodeStrictDecisionPayload, extractJsonObjectCandidates, isLegacyScalarDecision, decisionSymbolKeysForCandidate, selectRankedDecisionCandidate, extractJsonObjectPayload, toCanonicalDecisionPayload, normalizeDecisionUnits, normalizeDecisionValue, TRADABILITY_SCORE_MIN, TRADABILITY_SCORE_MAX, isTradabilityScore, normalizeTradabilityScore, extractNormalizedDecision, classifyDecisionParseOutcome;
|
|
105207
105965
|
var init_decision_contract = __esm({
|
|
105208
105966
|
"lib/runtime/decision-contract.ts"() {
|
|
105209
105967
|
"use strict";
|
|
105210
105968
|
init_define_VTX_EXO_POLICY();
|
|
105211
105969
|
init_define_VTX_GROK_POLICY();
|
|
105212
105970
|
init_define_VTX_PI_MODEL_POLICY();
|
|
105971
|
+
init_runtime_policy_generated2();
|
|
105213
105972
|
JSON_FENCE_PATTERN = /^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i;
|
|
105214
105973
|
JSON_SIMPLE_ESCAPE_CHARS = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t"]);
|
|
105215
105974
|
JSON_HEX_ESCAPE_PATTERN = /^[0-9a-fA-F]{4}$/;
|
|
@@ -105581,15 +106340,15 @@ var init_decision_contract = __esm({
|
|
|
105581
106340
|
const decisionValue = String(rawDecision || "").trim().toUpperCase();
|
|
105582
106341
|
return decisionValue === "BUY" || decisionValue === "SELL" ? decisionValue : "HOLD";
|
|
105583
106342
|
};
|
|
106343
|
+
TRADABILITY_SCORE_MIN = runtime_policy_generated_default2.trading.tradability.score_min;
|
|
106344
|
+
TRADABILITY_SCORE_MAX = runtime_policy_generated_default2.trading.tradability.score_max;
|
|
106345
|
+
isTradabilityScore = (value) => typeof value === "number" && Number.isInteger(value) && value >= TRADABILITY_SCORE_MIN && value <= TRADABILITY_SCORE_MAX;
|
|
105584
106346
|
normalizeTradabilityScore = (rawTradability) => {
|
|
105585
106347
|
if (rawTradability === null || typeof rawTradability === "undefined" || typeof rawTradability === "boolean") {
|
|
105586
106348
|
return null;
|
|
105587
106349
|
}
|
|
105588
106350
|
const parsed = Number(rawTradability);
|
|
105589
|
-
|
|
105590
|
-
return null;
|
|
105591
|
-
}
|
|
105592
|
-
return parsed;
|
|
106351
|
+
return isTradabilityScore(parsed) ? parsed : null;
|
|
105593
106352
|
};
|
|
105594
106353
|
extractNormalizedDecision = (rawResponse, parsedDecision, symbol2) => {
|
|
105595
106354
|
const content = sanitizeVisibleRuntimeText(rawResponse || "");
|
|
@@ -106059,6 +106818,7 @@ var init_screener_resource_scheduler = __esm({
|
|
|
106059
106818
|
init_define_VTX_GROK_POLICY();
|
|
106060
106819
|
init_define_VTX_PI_MODEL_POLICY();
|
|
106061
106820
|
init_runtime_policy_generated2();
|
|
106821
|
+
init_host_storage();
|
|
106062
106822
|
STORAGE_KEY = "vtx_llm_resource_scheduler_v1";
|
|
106063
106823
|
CHANNEL_NAME = "vtx-llm-resource-scheduler";
|
|
106064
106824
|
LOCK_TTL_MS = runtime_policy_generated_default2.screener.resource_scheduler.client_lock_ttl_milliseconds;
|
|
@@ -106073,7 +106833,7 @@ var init_screener_resource_scheduler = __esm({
|
|
|
106073
106833
|
};
|
|
106074
106834
|
storage2 = () => {
|
|
106075
106835
|
try {
|
|
106076
|
-
return
|
|
106836
|
+
return runtimeHostStorage();
|
|
106077
106837
|
} catch {
|
|
106078
106838
|
return null;
|
|
106079
106839
|
}
|
|
@@ -111243,7 +112003,7 @@ var init_local_analysis = __esm({
|
|
|
111243
112003
|
const tradability = decision.tradability;
|
|
111244
112004
|
const reasoning = decision.reasoning;
|
|
111245
112005
|
if (!Number.isInteger(units)) errors.add("decision_units_invalid");
|
|
111246
|
-
if (!
|
|
112006
|
+
if (!isTradabilityScore(tradability)) {
|
|
111247
112007
|
errors.add("decision_tradability_invalid");
|
|
111248
112008
|
}
|
|
111249
112009
|
if (typeof reasoning !== "string" || reasoning.trim() === "" || reasoning.trim() === "-") {
|
|
@@ -113000,7 +113760,7 @@ ${reviewOutputContract}`;
|
|
|
113000
113760
|
const priceRaw = Number(source.price);
|
|
113001
113761
|
const price = Number.isFinite(priceRaw) && priceRaw > 0 ? priceRaw : null;
|
|
113002
113762
|
const tradabilityRaw = Number(source.tradability);
|
|
113003
|
-
const tradability =
|
|
113763
|
+
const tradability = isTradabilityScore(tradabilityRaw) ? tradabilityRaw : null;
|
|
113004
113764
|
const executedAtMsRaw = Number(source.executed_at_ms ?? 0);
|
|
113005
113765
|
const executedAtMs = Number.isFinite(executedAtMsRaw) && executedAtMsRaw > 0 ? Math.trunc(executedAtMsRaw) : 0;
|
|
113006
113766
|
return {
|
|
@@ -113063,7 +113823,7 @@ ${reviewOutputContract}`;
|
|
|
113063
113823
|
throw new Error(`Enabled behavior memory has invalid ${key} schema`);
|
|
113064
113824
|
}
|
|
113065
113825
|
if (key === "et") {
|
|
113066
|
-
if (!isExactEnumString(item.a, ["BUY", "SELL"]) || !(item.u === "-" || isNonnegativeInteger(item.u) && item.u > 0) || !(item.v === "-" || isFiniteNumber(item.v) && item.v > 0) || !(item.p === "-" || isFiniteNumber(item.p) && item.p > 0) || !(item.tr === "-" || isNonnegativeInteger(item.tr) && item.tr
|
|
113826
|
+
if (!isExactEnumString(item.a, ["BUY", "SELL"]) || !(item.u === "-" || isNonnegativeInteger(item.u) && item.u > 0) || !(item.v === "-" || isFiniteNumber(item.v) && item.v > 0) || !(item.p === "-" || isFiniteNumber(item.p) && item.p > 0) || !(item.tr === "-" || isNonnegativeInteger(item.tr) && isTradabilityScore(item.tr)) || !isNonnegativeInteger(item.age) || typeof item.r !== "string" || item.r.trim().length === 0 || item.r.trim() === "-") {
|
|
113067
113827
|
throw new Error("Enabled behavior memory has invalid et values");
|
|
113068
113828
|
}
|
|
113069
113829
|
return {
|
|
@@ -113078,7 +113838,7 @@ ${reviewOutputContract}`;
|
|
|
113078
113838
|
};
|
|
113079
113839
|
}
|
|
113080
113840
|
if (key === "pd") {
|
|
113081
|
-
if (!isExactEnumString(item.a, ["BUY", "SELL", "HOLD"]) || !isNonnegativeInteger(item.u) || !(item.tr === "-" || isNonnegativeInteger(item.tr) && item.tr
|
|
113841
|
+
if (!isExactEnumString(item.a, ["BUY", "SELL", "HOLD"]) || !isNonnegativeInteger(item.u) || !(item.tr === "-" || isNonnegativeInteger(item.tr) && isTradabilityScore(item.tr)) || !isNonnegativeInteger(item.age) || !isExactEnumString(item.ps, ["LONG", "SHORT", "FLAT"]) || !isExactEnumString(item.x, ["e", "b", "f", "n", "-"]) || !isNonemptyPromptText(item.r)) {
|
|
113082
113842
|
throw new Error("Enabled behavior memory has invalid pd values");
|
|
113083
113843
|
}
|
|
113084
113844
|
return {
|
|
@@ -116422,7 +117182,7 @@ ${reviewOutputContract}`;
|
|
|
116422
117182
|
});
|
|
116423
117183
|
|
|
116424
117184
|
// 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;
|
|
117185
|
+
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
117186
|
var init_engine = __esm({
|
|
116427
117187
|
"lib/runtime/engine.ts"() {
|
|
116428
117188
|
"use strict";
|
|
@@ -116430,6 +117190,8 @@ var init_engine = __esm({
|
|
|
116430
117190
|
init_define_VTX_GROK_POLICY();
|
|
116431
117191
|
init_define_VTX_PI_MODEL_POLICY();
|
|
116432
117192
|
init_protective_cutover();
|
|
117193
|
+
init_runtime_policy_generated2();
|
|
117194
|
+
init_constants();
|
|
116433
117195
|
init_periodic_schedule();
|
|
116434
117196
|
init_host_storage();
|
|
116435
117197
|
init_vault();
|
|
@@ -116444,7 +117206,7 @@ var init_engine = __esm({
|
|
|
116444
117206
|
init_browser_observability();
|
|
116445
117207
|
init_error_surface_contract();
|
|
116446
117208
|
init_render_debug();
|
|
116447
|
-
|
|
117209
|
+
init_environment();
|
|
116448
117210
|
init_client_ownership_arbitration_contract();
|
|
116449
117211
|
init_client_runtime_ownership_errors();
|
|
116450
117212
|
init_client_runtime_device_id();
|
|
@@ -116573,6 +117335,7 @@ var init_engine = __esm({
|
|
|
116573
117335
|
}
|
|
116574
117336
|
return null;
|
|
116575
117337
|
};
|
|
117338
|
+
CLIENT_RUNTIME_POLICY = runtime_policy_generated_default2.trading.engine.client_runtime;
|
|
116576
117339
|
getRecentProviderFailureDiagnostics = (reason) => {
|
|
116577
117340
|
const providerLabel = reason === void 0 ? null : getEventBoundProviderLabel(reason);
|
|
116578
117341
|
const traceId = reason === void 0 ? null : getEventBoundProviderTraceId(reason);
|
|
@@ -116580,7 +117343,7 @@ var init_engine = __esm({
|
|
|
116580
117343
|
return null;
|
|
116581
117344
|
}
|
|
116582
117345
|
const snapshot = getLatestRuntimeProviderFailureTelemetrySnapshot({
|
|
116583
|
-
maxAgeMs:
|
|
117346
|
+
maxAgeMs: CLIENT_RUNTIME_POLICY.provider_failure_diagnostics_max_age_milliseconds,
|
|
116584
117347
|
label: providerLabel,
|
|
116585
117348
|
traceId
|
|
116586
117349
|
});
|
|
@@ -116689,7 +117452,7 @@ var init_engine = __esm({
|
|
|
116689
117452
|
runtime_request_transient_network: record5.runtimeRequestTransientNetwork === true,
|
|
116690
117453
|
runtime_request_deadline_at_ms: numberOrNull(record5.runtimeRequestDeadlineAtMs),
|
|
116691
117454
|
runtime_request_deadline_exceeded: record5.runtimeRequestDeadlineExceeded === true,
|
|
116692
|
-
...record5.code === "snapshot_stale" && record5.runtimeRequestStatus ===
|
|
117455
|
+
...record5.code === "snapshot_stale" && record5.runtimeRequestStatus === HTTP_STATUS.CONFLICT ? {
|
|
116693
117456
|
runtime_rejection_reason_code: "snapshot_stale",
|
|
116694
117457
|
snapshot_age_seconds: numberOrNull(record5.runtimeSnapshotAgeSeconds),
|
|
116695
117458
|
snapshot_max_age_seconds: numberOrNull(record5.runtimeSnapshotMaxAgeSeconds)
|
|
@@ -116946,7 +117709,7 @@ var init_engine = __esm({
|
|
|
116946
117709
|
};
|
|
116947
117710
|
isTransientRuntimeConflictError = (error48) => {
|
|
116948
117711
|
const structured = error48;
|
|
116949
|
-
if (Number(structured?.status) ===
|
|
117712
|
+
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
117713
|
return true;
|
|
116951
117714
|
}
|
|
116952
117715
|
const hasStructuredMetadata = Number.isFinite(Number(structured?.status)) || typeof structured?.code === "string" || typeof structured?.retryable === "boolean";
|
|
@@ -117144,7 +117907,7 @@ var init_engine = __esm({
|
|
|
117144
117907
|
this._pendingProtectionRecoveryDispatched = false;
|
|
117145
117908
|
this._lastPendingProtectionRecoveryAtMs = null;
|
|
117146
117909
|
this._primaryAnalysisDisabled = false;
|
|
117147
|
-
this._loopEarlyReturnRetryDelayMs =
|
|
117910
|
+
this._loopEarlyReturnRetryDelayMs = CLIENT_RUNTIME_POLICY.loop_early_return_retry_milliseconds;
|
|
117148
117911
|
this._executionModeMismatchConsecutiveCount = 0;
|
|
117149
117912
|
this._expectedExecutionMode = "client";
|
|
117150
117913
|
this._settleUnreportedModelCalls = null;
|
|
@@ -117311,7 +118074,7 @@ var init_engine = __esm({
|
|
|
117311
118074
|
signal.removeEventListener("abort", finish);
|
|
117312
118075
|
resolve14();
|
|
117313
118076
|
};
|
|
117314
|
-
const timeoutId = globalThis.setTimeout(finish,
|
|
118077
|
+
const timeoutId = globalThis.setTimeout(finish, CLIENT_RUNTIME_POLICY.window_handoff_cleanup_retry_milliseconds);
|
|
117315
118078
|
signal.addEventListener("abort", finish, { once: true });
|
|
117316
118079
|
});
|
|
117317
118080
|
}
|
|
@@ -117396,7 +118159,7 @@ var init_engine = __esm({
|
|
|
117396
118159
|
return {
|
|
117397
118160
|
deviceId: this._deviceId,
|
|
117398
118161
|
sessionId: this._sessionId,
|
|
117399
|
-
surface:
|
|
118162
|
+
surface: runtimeHostSurface()
|
|
117400
118163
|
};
|
|
117401
118164
|
}
|
|
117402
118165
|
async _shouldStopForExecutionModeMismatch() {
|
|
@@ -117453,8 +118216,8 @@ var init_engine = __esm({
|
|
|
117453
118216
|
const phase = policy2.phase_seconds;
|
|
117454
118217
|
const interval = policy2.interval_seconds;
|
|
117455
118218
|
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 *
|
|
117457
|
-
const intervalMs = valid ? Math.round(interval *
|
|
118219
|
+
const phaseMs = valid ? Math.round(phase * MS_PER_SECOND) : null;
|
|
118220
|
+
const intervalMs = valid ? Math.round(interval * MS_PER_SECOND) : null;
|
|
117458
118221
|
const grace = Number(policy2.dispatch_grace_ms);
|
|
117459
118222
|
if (!Number.isFinite(grace) || grace < 0) throw new Error("Invalid periodic analysis dispatch grace.");
|
|
117460
118223
|
const intervalChanged = intervalMs != null && this._loopIntervalMs != null && this._loopIntervalMs !== intervalMs;
|
|
@@ -117465,7 +118228,7 @@ var init_engine = __esm({
|
|
|
117465
118228
|
phaseMs,
|
|
117466
118229
|
intervalMs,
|
|
117467
118230
|
dispatchGraceMs: grace,
|
|
117468
|
-
localMinusServerMs: sameAssignment ? previous.localMinusServerMs : valid ? observedAtMs - Number(status?.server_time) *
|
|
118231
|
+
localMinusServerMs: sameAssignment ? previous.localMinusServerMs : valid ? observedAtMs - Number(status?.server_time) * MS_PER_SECOND : 0
|
|
117469
118232
|
};
|
|
117470
118233
|
if (!sameAssignment) {
|
|
117471
118234
|
this._lastPeriodicSlotServerMs = null;
|
|
@@ -117689,7 +118452,7 @@ var init_engine = __esm({
|
|
|
117689
118452
|
payload: {
|
|
117690
118453
|
reason,
|
|
117691
118454
|
state: this._state,
|
|
117692
|
-
claim_surface:
|
|
118455
|
+
claim_surface: runtimeHostSurface(),
|
|
117693
118456
|
route_pathname: typeof window !== "undefined" ? window.location.pathname : null,
|
|
117694
118457
|
visibility_state: typeof document !== "undefined" ? document.visibilityState : null,
|
|
117695
118458
|
online: typeof navigator !== "undefined" ? navigator.onLine : null,
|
|
@@ -117802,7 +118565,7 @@ var init_engine = __esm({
|
|
|
117802
118565
|
lastStopProfileId: this._lastStopProfileId,
|
|
117803
118566
|
lastRunAt: this._lastRunAt,
|
|
117804
118567
|
nextRunAtMs: this._primaryAnalysisDisabled ? null : this._nextRunAtMs,
|
|
117805
|
-
loopIntervalSeconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs /
|
|
118568
|
+
loopIntervalSeconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND)),
|
|
117806
118569
|
schedulerPhase: this._getSchedulerPhase(),
|
|
117807
118570
|
primaryAnalysisDisabled: this._primaryAnalysisDisabled,
|
|
117808
118571
|
ownershipLossReason: this._ownershipLossReason,
|
|
@@ -117850,7 +118613,7 @@ var init_engine = __esm({
|
|
|
117850
118613
|
if (!Number.isFinite(parsedSeconds) || parsedSeconds <= 0) {
|
|
117851
118614
|
throw new Error(`Missing required ${errorLabel}.`);
|
|
117852
118615
|
}
|
|
117853
|
-
return Math.round(parsedSeconds *
|
|
118616
|
+
return Math.round(parsedSeconds * MS_PER_SECOND);
|
|
117854
118617
|
}
|
|
117855
118618
|
_resolveAnalysisStaleAfterMs(rawSeconds, defaultTimeoutSeconds) {
|
|
117856
118619
|
const parsedSeconds = Number(rawSeconds);
|
|
@@ -117861,7 +118624,7 @@ var init_engine = __esm({
|
|
|
117861
118624
|
if (Number.isFinite(parsedDefaultTimeoutSeconds) && parsedDefaultTimeoutSeconds > 0 && parsedSeconds < parsedDefaultTimeoutSeconds) {
|
|
117862
118625
|
throw new Error("Client runtime stale analysis timeout must be greater than or equal to the default timeout.");
|
|
117863
118626
|
}
|
|
117864
|
-
return Math.round(parsedSeconds *
|
|
118627
|
+
return Math.round(parsedSeconds * MS_PER_SECOND);
|
|
117865
118628
|
}
|
|
117866
118629
|
_resolveLoopIntervalMs(loopIntervalSeconds, minLoopIntervalSeconds) {
|
|
117867
118630
|
const parsedSeconds = Number(loopIntervalSeconds);
|
|
@@ -117875,7 +118638,7 @@ var init_engine = __esm({
|
|
|
117875
118638
|
if (parsedSeconds < parsedMinSeconds) {
|
|
117876
118639
|
throw new Error(`Client runtime loop interval must be at least ${parsedMinSeconds} seconds.`);
|
|
117877
118640
|
}
|
|
117878
|
-
return Math.round(parsedSeconds *
|
|
118641
|
+
return Math.round(parsedSeconds * MS_PER_SECOND);
|
|
117879
118642
|
}
|
|
117880
118643
|
_initializeNextRunAnchor(referenceMs = Date.now()) {
|
|
117881
118644
|
if (this._loopIntervalMs == null) {
|
|
@@ -118419,7 +119182,7 @@ var init_engine = __esm({
|
|
|
118419
119182
|
this._executionModeMismatchConsecutiveCount = 0;
|
|
118420
119183
|
const responseNextRunSeconds = Number(grant.runtime?.next_run);
|
|
118421
119184
|
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) *
|
|
119185
|
+
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
119186
|
const waitsForAssignedStartPhase = Boolean(this._periodicSchedule) || Number.isFinite(assignedNextRunAtMs) && assignedNextRunAtMs > Date.now();
|
|
118424
119187
|
if (waitsForAssignedStartPhase) {
|
|
118425
119188
|
if (this._periodicSchedule) this._initializeNextRunAnchor();
|
|
@@ -119119,7 +119882,7 @@ var init_engine = __esm({
|
|
|
119119
119882
|
const now = Date.now();
|
|
119120
119883
|
const observations = this._trailingObservations.filter(({ executionContext }) => {
|
|
119121
119884
|
const capturedAt = Date.parse(executionContext.decisionSnapshotCapturedAt ?? "");
|
|
119122
|
-
const maxAge = Number(executionContext.executionFreshnessMaxAgeSeconds) *
|
|
119885
|
+
const maxAge = Number(executionContext.executionFreshnessMaxAgeSeconds) * MS_PER_SECOND;
|
|
119123
119886
|
const age = now - capturedAt;
|
|
119124
119887
|
return Number.isFinite(age) && age >= 0 && Number.isFinite(maxAge) && maxAge > 0 && age <= maxAge;
|
|
119125
119888
|
});
|
|
@@ -119194,7 +119957,7 @@ var init_engine = __esm({
|
|
|
119194
119957
|
const config2 = await this.getExecutionConfig(profileId);
|
|
119195
119958
|
const pollSeconds = Number(config2.client_protective_recovery_poll_seconds);
|
|
119196
119959
|
if (!Number.isFinite(pollSeconds) || pollSeconds <= 0) return;
|
|
119197
|
-
if (this._lastPendingProtectionRecoveryAtMs != null && Date.now() - this._lastPendingProtectionRecoveryAtMs < pollSeconds *
|
|
119960
|
+
if (this._lastPendingProtectionRecoveryAtMs != null && Date.now() - this._lastPendingProtectionRecoveryAtMs < pollSeconds * MS_PER_SECOND) {
|
|
119198
119961
|
return;
|
|
119199
119962
|
}
|
|
119200
119963
|
this._lastPendingProtectionRecoveryAtMs = Date.now();
|
|
@@ -119448,7 +120211,7 @@ var init_engine = __esm({
|
|
|
119448
120211
|
});
|
|
119449
120212
|
return;
|
|
119450
120213
|
}
|
|
119451
|
-
this._emitLoopBoundaryTelemetry("client_execution_loop_early_return",
|
|
120214
|
+
this._emitLoopBoundaryTelemetry("client_execution_loop_early_return", `reason=analysis_in_flight retry_ms=${this._loopEarlyReturnRetryDelayMs}`, {
|
|
119452
120215
|
reason: "analysis_in_flight",
|
|
119453
120216
|
retry_ms: this._loopEarlyReturnRetryDelayMs
|
|
119454
120217
|
});
|
|
@@ -119743,9 +120506,12 @@ var init_engine = __esm({
|
|
|
119743
120506
|
const nowMs2 = Date.now();
|
|
119744
120507
|
const windowOpensAtMs = error48.nextChangeAtMs != null ? this._periodicNextSlot(error48.nextChangeAtMs, true) ?? error48.nextChangeAtMs : null;
|
|
119745
120508
|
aiSchedulePauseHasNext = windowOpensAtMs != null;
|
|
119746
|
-
aiSchedulePauseMs = windowOpensAtMs != null ? Math.max(
|
|
120509
|
+
aiSchedulePauseMs = windowOpensAtMs != null ? Math.max(
|
|
120510
|
+
CLIENT_RUNTIME_POLICY.ai_schedule_pause_min_milliseconds,
|
|
120511
|
+
Math.min(windowOpensAtMs - nowMs2, CLIENT_RUNTIME_POLICY.ai_schedule_pause_max_milliseconds)
|
|
120512
|
+
) : CLIENT_RUNTIME_POLICY.ai_schedule_pause_unknown_milliseconds;
|
|
119747
120513
|
if (runtimeMode === "trader" && this._loopIntervalMs != null) {
|
|
119748
|
-
aiSchedulePauseMs = Math.min(aiSchedulePauseMs, Math.max(
|
|
120514
|
+
aiSchedulePauseMs = Math.min(aiSchedulePauseMs, Math.max(CLIENT_RUNTIME_POLICY.ai_schedule_pause_min_milliseconds, this._loopIntervalMs));
|
|
119749
120515
|
}
|
|
119750
120516
|
this._nextRunAtMs = windowOpensAtMs;
|
|
119751
120517
|
if (!aiSchedulePauseContinuation) {
|
|
@@ -120035,7 +120801,7 @@ var init_engine = __esm({
|
|
|
120035
120801
|
await this._discardCycleOnContractMismatch("decision", decisionError);
|
|
120036
120802
|
return;
|
|
120037
120803
|
}
|
|
120038
|
-
if (decisionError instanceof Error && decisionError.status ===
|
|
120804
|
+
if (decisionError instanceof Error && decisionError.status === HTTP_STATUS.CONFLICT && (decisionError.code === "snapshot_stale" || decisionError.message.startsWith("Runtime decision rejected by constraints:"))) {
|
|
120039
120805
|
Object.assign(decisionError, {
|
|
120040
120806
|
runtimeInvocationAttempts: result.invocations?.map((attempt) => ({
|
|
120041
120807
|
...attempt,
|
|
@@ -120518,7 +121284,7 @@ var init_engine = __esm({
|
|
|
120518
121284
|
} catch (error48) {
|
|
120519
121285
|
const errorModelCalls = getCycleErrorModelCalls(error48);
|
|
120520
121286
|
if (errorModelCalls.length > 0) cycleModelCalls = errorModelCalls;
|
|
120521
|
-
const cycleElapsedSeconds = Math.max(0, (performance.now() - runStartedMonotonicMs) /
|
|
121287
|
+
const cycleElapsedSeconds = Math.max(0, (performance.now() - runStartedMonotonicMs) / MS_PER_SECOND);
|
|
120522
121288
|
cycleOutcome = "failed";
|
|
120523
121289
|
cycleReason = cycleObservation.reason_code ?? "runtime_failed";
|
|
120524
121290
|
if (isRuntimeAbortError(error48) || analysisAbortController.signal.aborted || this._isStopping || this._state === "stopped" || this._analysisRequestId !== requestId) {
|
|
@@ -120636,7 +121402,7 @@ var init_engine = __esm({
|
|
|
120636
121402
|
}
|
|
120637
121403
|
if (hasEventBoundProviderFailureEvidence(error48) && this._expectedExecutionMode === "server") {
|
|
120638
121404
|
const backoffSeconds = Number((await this.getExecutionConfig(profileId).catch(() => null))?.provider_failure_backoff_seconds);
|
|
120639
|
-
if (Number.isFinite(backoffSeconds) && backoffSeconds > 0) providerRetryDelayMs = backoffSeconds *
|
|
121405
|
+
if (Number.isFinite(backoffSeconds) && backoffSeconds > 0) providerRetryDelayMs = backoffSeconds * MS_PER_SECOND;
|
|
120640
121406
|
}
|
|
120641
121407
|
if (hasEventBoundProviderFailureEvidence(error48)) {
|
|
120642
121408
|
this.scheduleProviderFailureDiagnosticsTelemetry({
|
|
@@ -120823,7 +121589,7 @@ var init_engine = __esm({
|
|
|
120823
121589
|
if (!sessionId || !deviceId || !mode) {
|
|
120824
121590
|
return;
|
|
120825
121591
|
}
|
|
120826
|
-
const desktopRuntimeSurface =
|
|
121592
|
+
const desktopRuntimeSurface = runtimeHostSurface() === "desktop";
|
|
120827
121593
|
try {
|
|
120828
121594
|
await reportClientRuntimeLifecycleEvent(
|
|
120829
121595
|
profileId,
|
|
@@ -120849,7 +121615,7 @@ var init_engine = __esm({
|
|
|
120849
121615
|
runtime_live_status: "active",
|
|
120850
121616
|
runtime_running: true,
|
|
120851
121617
|
runtime_scheduler_phase: this._getSchedulerPhase(),
|
|
120852
|
-
runtime_loop_interval_seconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs /
|
|
121618
|
+
runtime_loop_interval_seconds: this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND)),
|
|
120853
121619
|
runtime_last_run_at: this._lastRunAt,
|
|
120854
121620
|
runtime_next_run_at: this._nextRunAtMs == null ? null : new Date(this._nextRunAtMs).toISOString(),
|
|
120855
121621
|
runtime_next_run_at_ms: this._nextRunAtMs,
|
|
@@ -120873,7 +121639,7 @@ var init_engine = __esm({
|
|
|
120873
121639
|
if (!profileId) {
|
|
120874
121640
|
return;
|
|
120875
121641
|
}
|
|
120876
|
-
const delayMs = Math.max(0, options.delayMs ??
|
|
121642
|
+
const delayMs = Math.max(0, options.delayMs ?? CLIENT_RUNTIME_POLICY.provider_failure_diagnostics_delay_milliseconds);
|
|
120877
121643
|
globalThis.setTimeout(() => {
|
|
120878
121644
|
const diagnostics = buildRuntimeErrorDiagnostics(options.reason);
|
|
120879
121645
|
const healthProbe = diagnostics.healthProbe && typeof diagnostics.healthProbe === "object" ? diagnostics.healthProbe : null;
|
|
@@ -120961,7 +121727,7 @@ var init_engine = __esm({
|
|
|
120961
121727
|
eventProvenance?.modelSource ?? providerSetup?.provider ?? options?.modelSource ?? ""
|
|
120962
121728
|
).trim().toLowerCase() || null;
|
|
120963
121729
|
const sanitizedReason = getSanitizedRuntimeErrorMessage(reason) || "Unknown runtime error.";
|
|
120964
|
-
const retrySeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs /
|
|
121730
|
+
const retrySeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND));
|
|
120965
121731
|
const executionProjection = options?.executionReasonCode ? projectExecutionErrorContract({
|
|
120966
121732
|
error: sanitizedReason,
|
|
120967
121733
|
symbol: options.executionSymbol,
|
|
@@ -121132,7 +121898,7 @@ var init_engine = __esm({
|
|
|
121132
121898
|
const heartbeatLifecycleGeneration = this._lifecycleGeneration;
|
|
121133
121899
|
const heartbeatLastRunAt = this._lastRunAt;
|
|
121134
121900
|
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 /
|
|
121901
|
+
const heartbeatLoopIntervalSeconds = this._loopIntervalMs == null ? null : Math.max(1, Math.round(this._loopIntervalMs / MS_PER_SECOND));
|
|
121136
121902
|
const heartbeatSchedulerPhase = this._getSchedulerPhase();
|
|
121137
121903
|
const heartbeatAnalysisRunId = this._primaryAnalysisDisabled || !this._isAnalysisInFlight() ? null : this._analysisRequestId;
|
|
121138
121904
|
const heartbeatIsAnalyzing = !this._primaryAnalysisDisabled && (this._isAnalysisInFlight() || this._startupPendingAnalysis && options?.confirmGrant !== true || this._isExecuting);
|
|
@@ -121375,7 +122141,7 @@ var init_engine = __esm({
|
|
|
121375
122141
|
}
|
|
121376
122142
|
this._killswitchIntervalId = setInterval(
|
|
121377
122143
|
() => void this._runClientKillswitchCheck(),
|
|
121378
|
-
Math.max(
|
|
122144
|
+
Math.max(CLIENT_RUNTIME_POLICY.killswitch_timer_floor_milliseconds, Math.round(pollIntervalSeconds * MS_PER_SECOND))
|
|
121379
122145
|
);
|
|
121380
122146
|
}
|
|
121381
122147
|
async _runClientKillswitchCheck() {
|
|
@@ -121416,7 +122182,7 @@ var init_engine = __esm({
|
|
|
121416
122182
|
new DOMException("Client killswitch check timed out.", "TimeoutError")
|
|
121417
122183
|
);
|
|
121418
122184
|
reject(new Error("Client killswitch check timed out."));
|
|
121419
|
-
}, Math.round(checkTimeoutSeconds *
|
|
122185
|
+
}, Math.round(checkTimeoutSeconds * MS_PER_SECOND));
|
|
121420
122186
|
})
|
|
121421
122187
|
]);
|
|
121422
122188
|
if (controller.signal.aborted || this._state !== "running" || this._mode !== "trader" || this._profileId !== profileId || this._sessionId !== sessionId || this._deviceId !== deviceId) {
|
|
@@ -121524,9 +122290,9 @@ var init_engine = __esm({
|
|
|
121524
122290
|
const activeExecutionLoop = this._executionLoopPromise;
|
|
121525
122291
|
if (activeExecutionLoop) {
|
|
121526
122292
|
const executionFenceTimeoutMs = Math.max(
|
|
121527
|
-
|
|
122293
|
+
CLIENT_RUNTIME_POLICY.killswitch_timer_floor_milliseconds,
|
|
121528
122294
|
Math.round(
|
|
121529
|
-
Number(config2.client_runtime_killswitch_close_timeout_seconds) *
|
|
122295
|
+
Number(config2.client_runtime_killswitch_close_timeout_seconds) * MS_PER_SECOND
|
|
121530
122296
|
)
|
|
121531
122297
|
);
|
|
121532
122298
|
let executionFenceTimeoutId = null;
|
|
@@ -121581,7 +122347,7 @@ var init_engine = __esm({
|
|
|
121581
122347
|
() => refreshController.abort(
|
|
121582
122348
|
new DOMException("Client killswitch position refresh timed out.", "TimeoutError")
|
|
121583
122349
|
),
|
|
121584
|
-
Math.round(closeTimeoutSeconds *
|
|
122350
|
+
Math.round(closeTimeoutSeconds * MS_PER_SECOND)
|
|
121585
122351
|
);
|
|
121586
122352
|
try {
|
|
121587
122353
|
freshPositions = (await fetchBrowserAccountState2({
|
|
@@ -122661,11 +123427,17 @@ async function runHeadlessRuntime(options) {
|
|
|
122661
123427
|
const engine = new ClientExecutionEngine();
|
|
122662
123428
|
const stopController = new AbortController();
|
|
122663
123429
|
const stop = () => stopController.abort();
|
|
123430
|
+
let hungUp = false;
|
|
123431
|
+
const hangUp = () => {
|
|
123432
|
+
ignoreClosedTerminalWrites();
|
|
123433
|
+
if (!stopController.signal.aborted && !options.once) hungUp = true;
|
|
123434
|
+
stop();
|
|
123435
|
+
};
|
|
122664
123436
|
if (options.signal?.aborted) stop();
|
|
122665
123437
|
options.signal?.addEventListener("abort", stop, { once: true });
|
|
122666
|
-
const
|
|
123438
|
+
const signalHandlers = HEADLESS_RUNTIME_STOP_SIGNALS.map((signal) => [signal, signal === "SIGHUP" ? hangUp : stop]);
|
|
122667
123439
|
if (options.stopOnSignals !== false) {
|
|
122668
|
-
for (const signalName of
|
|
123440
|
+
for (const [signalName, handler] of signalHandlers) process.on(signalName, handler);
|
|
122669
123441
|
}
|
|
122670
123442
|
const pending3 = [];
|
|
122671
123443
|
let wake = null;
|
|
@@ -122711,6 +123483,10 @@ async function runHeadlessRuntime(options) {
|
|
|
122711
123483
|
{ runtimeViewer: { deviceId: identity2.deviceId, sessionId: identity2.sessionId } }
|
|
122712
123484
|
)).statuses?.[String(options.profileId)] ?? null;
|
|
122713
123485
|
const stopRuntime = async (reason) => {
|
|
123486
|
+
if (hungUp && reason === "agent_cli:stop") {
|
|
123487
|
+
await leaveRuntime();
|
|
123488
|
+
return;
|
|
123489
|
+
}
|
|
122714
123490
|
if (engine.active) await engine.stop({ skipRemote: true, reason });
|
|
122715
123491
|
try {
|
|
122716
123492
|
await stopClientRuntimeSession(options.profileId, {
|
|
@@ -122732,6 +123508,9 @@ async function runHeadlessRuntime(options) {
|
|
|
122732
123508
|
}
|
|
122733
123509
|
await clearOwnState();
|
|
122734
123510
|
};
|
|
123511
|
+
const leaveRuntime = async () => {
|
|
123512
|
+
if (engine.active) await engine.stop({ skipRemote: true, reason: "agent_cli:hangup" });
|
|
123513
|
+
};
|
|
122735
123514
|
const releaseFailedStart = async (kind) => {
|
|
122736
123515
|
if (kind === "explicit" && engine.active) {
|
|
122737
123516
|
await stopRuntime("agent_cli:start_failed").catch(() => void 0);
|
|
@@ -123033,7 +123812,7 @@ async function runHeadlessRuntime(options) {
|
|
|
123033
123812
|
unsubscribeState();
|
|
123034
123813
|
options.signal?.removeEventListener("abort", stop);
|
|
123035
123814
|
if (options.stopOnSignals !== false) {
|
|
123036
|
-
for (const signalName of
|
|
123815
|
+
for (const [signalName, handler] of signalHandlers) process.removeListener(signalName, handler);
|
|
123037
123816
|
}
|
|
123038
123817
|
}
|
|
123039
123818
|
}
|
|
@@ -123056,6 +123835,7 @@ var init_headless_runtime = __esm({
|
|
|
123056
123835
|
init_engine();
|
|
123057
123836
|
init_server_runtime_lease();
|
|
123058
123837
|
init_reconcile();
|
|
123838
|
+
init_stop_signals();
|
|
123059
123839
|
init_local_ai_preflight();
|
|
123060
123840
|
HeadlessRuntimeTakeoverRequiredError = class extends Error {
|
|
123061
123841
|
constructor(response) {
|
|
@@ -123075,7 +123855,7 @@ var init_headless_runtime = __esm({
|
|
|
123075
123855
|
DEFAULT_MAX_CLAIM_WAITS = 10;
|
|
123076
123856
|
STOP_REQUEST_TIMEOUT_MS = 1e4;
|
|
123077
123857
|
PROTECTION_IDLE_RECHECK_MS = runtime_policy_generated_default2.trading.engine.client_runtime.protective_actions.idle_recheck_seconds * 1e3;
|
|
123078
|
-
PROTECTION_RETRY_MS =
|
|
123858
|
+
PROTECTION_RETRY_MS = runtime_policy_generated_default2.trading.engine.client_runtime.protective_actions.retry_delay_seconds * 1e3;
|
|
123079
123859
|
MAX_RESUMES_WITHOUT_A_CYCLE = 5;
|
|
123080
123860
|
RESUME_BACKOFF_MS = [1e3, 5e3, 15e3, 3e4, 6e4];
|
|
123081
123861
|
BACKUP_WAIT_TICK_MS = runtime_policy_generated_default2.trading.engine.client_runtime.reconcile.tick_interval_seconds * 1e3;
|