@vtxmacro/cli 2026.10.12 → 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.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.12", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
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
 
@@ -167,6 +167,89 @@ var init_runtime_policy_generated = __esm({
167
167
  refresh_interval_ms: 1e4,
168
168
  watchdog_interval_ms: 1e3,
169
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
170
253
  }
171
254
  },
172
255
  ai_dashboard: {
@@ -208,6 +291,9 @@ var init_runtime_policy_generated = __esm({
208
291
  72,
209
292
  168
210
293
  ]
294
+ },
295
+ defaults: {
296
+ max_chat_turns: 9999
211
297
  }
212
298
  },
213
299
  trading: {
@@ -276,7 +362,14 @@ var init_runtime_policy_generated = __esm({
276
362
  client_claim_retry_delay_milliseconds: 1e3,
277
363
  client_failure_report_timeout_milliseconds: 2e3,
278
364
  client_presence_heartbeat_interval_milliseconds: 3e4,
279
- 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
280
373
  }
281
374
  }
282
375
  },
@@ -285,6 +378,10 @@ var init_runtime_policy_generated = __esm({
285
378
  history_start_ms: 16409952e5,
286
379
  device_read_deadline_seconds: 180,
287
380
  device_recent_window_hours: 24
381
+ },
382
+ tradability: {
383
+ score_min: 1,
384
+ score_max: 10
288
385
  }
289
386
  },
290
387
  agent_cli: {
@@ -372,6 +469,9 @@ var init_runtime_policy_generated = __esm({
372
469
  resource_scheduler: {
373
470
  client_lock_ttl_milliseconds: 12e4,
374
471
  client_poll_interval_milliseconds: 250
472
+ },
473
+ defaults: {
474
+ adaptive_schedule_enabled: true
375
475
  }
376
476
  },
377
477
  deployment: {
@@ -493,7 +593,10 @@ var init_runtime_policy_generated = __esm({
493
593
  },
494
594
  market_data: {
495
595
  chart_interest: {
496
- historical_backfill_candle_limit: 1e3
596
+ historical_backfill_candle_limit: 1e3,
597
+ heartbeat_retry_seconds: 15,
598
+ heartbeat_min_delay_ms: 1e3,
599
+ catch_up_candle_limit: 300
497
600
  }
498
601
  },
499
602
  auth: {
@@ -502,6 +605,14 @@ var init_runtime_policy_generated = __esm({
502
605
  totp_code_length: 6
503
606
  }
504
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
+ },
505
616
  websocket: {
506
617
  client_connection: {
507
618
  reconnect_delay_ms: 3e3,
@@ -514,6 +625,9 @@ var init_runtime_policy_generated = __esm({
514
625
  notifications: {
515
626
  desktop: {
516
627
  heartbeat_seconds: 20
628
+ },
629
+ telegram: {
630
+ connect_link_poll_ms: 3e3
517
631
  }
518
632
  },
519
633
  validation: {
@@ -528,6 +642,63 @@ var init_runtime_policy_generated = __esm({
528
642
  handle_changes_per_window: 2,
529
643
  handle_change_window_days: 14
530
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
531
702
  }
532
703
  };
533
704
  }
@@ -662,6 +833,24 @@ var init_config = __esm({
662
833
  }
663
834
  });
664
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
+
665
854
  // node_modules/smol-toml/dist/date.js
666
855
  var DATE_TIME_RE, TomlDate;
667
856
  var init_date = __esm({
@@ -1426,8 +1615,8 @@ import { lstat, mkdir as mkdir2, open, readdir as readdir2, readFile as readFile
1426
1615
  import { homedir as homedir2 } from "node:os";
1427
1616
  import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, relative, resolve, win32 as windowsPath } from "node:path";
1428
1617
  function inferenceBaseDir(env) {
1429
- const configured = String(env.VTX_INFERENCE_HOST_HOME || "").trim();
1430
- return configured || join2(homedir2(), ".vtx", "inference-host");
1618
+ const configured2 = String(env.VTX_INFERENCE_HOST_HOME || "").trim();
1619
+ return configured2 || join2(homedir2(), ".vtx", "inference-host");
1431
1620
  }
1432
1621
  function normalizeInferenceHostInstanceName(raw) {
1433
1622
  const value = raw.trim().toLowerCase();
@@ -1920,32 +2109,32 @@ var init_config2 = __esm({
1920
2109
  init_dist();
1921
2110
  init_mcp_transport_config();
1922
2111
  loadInferenceReceiptDurabilityTimeoutMs = async () => {
1923
- let configured;
2112
+ let configured2;
1924
2113
  if (true) {
1925
- configured = 5e3;
2114
+ configured2 = 5e3;
1926
2115
  } else {
1927
2116
  const config2 = parse2(await readFile2(resolve(dirname2(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
1928
2117
  const inference = config2.external_inference;
1929
- configured = Number(inference?.receipt_durability_timeout_seconds) * 1e3;
2118
+ configured2 = Number(inference?.receipt_durability_timeout_seconds) * 1e3;
1930
2119
  }
1931
- if (!Number.isSafeInteger(configured) || Number(configured) < 1) {
2120
+ if (!Number.isSafeInteger(configured2) || Number(configured2) < 1) {
1932
2121
  throw new Error("Inference receipt durability timeout is missing or invalid.");
1933
2122
  }
1934
- return Number(configured);
2123
+ return Number(configured2);
1935
2124
  };
1936
2125
  loadInferenceAgentDataRequestTimeoutMs = async () => {
1937
- let configured;
2126
+ let configured2;
1938
2127
  if (true) {
1939
- configured = 9e4;
2128
+ configured2 = 9e4;
1940
2129
  } else {
1941
2130
  const config2 = parse2(await readFile2(resolve(dirname2(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
1942
2131
  const mcp = config2.insights?.mcp;
1943
- configured = Number(mcp?.tool_timeout_seconds) * 1e3;
2132
+ configured2 = Number(mcp?.tool_timeout_seconds) * 1e3;
1944
2133
  }
1945
- if (!Number.isSafeInteger(configured) || Number(configured) < 1) {
2134
+ if (!Number.isSafeInteger(configured2) || Number(configured2) < 1) {
1946
2135
  throw new Error("Inference Agent data request timeout is missing or invalid.");
1947
2136
  }
1948
- return Number(configured);
2137
+ return Number(configured2);
1949
2138
  };
1950
2139
  loadInferenceAgentCommandLockPolicy = async () => {
1951
2140
  let waitTimeoutMs;
@@ -2877,6 +3066,7 @@ var init_updater = __esm({
2877
3066
  init_agent_cli_release();
2878
3067
  init_runtime_policy_generated();
2879
3068
  init_config();
3069
+ init_stop_signals();
2880
3070
  init_config2();
2881
3071
  init_routing();
2882
3072
  CLI_PACKAGE_NAME = "@vtxmacro/cli";
@@ -3189,11 +3379,11 @@ var init_updater = __esm({
3189
3379
  };
3190
3380
  cliAutoUpdateDisabled = (env) => /^(?:0|false|off|no)$/iu.test(String(env.VTX_CLI_AUTO_UPDATE ?? "").trim());
3191
3381
  resolveRegistry = (env) => {
3192
- const configured = String(env.VTX_CLI_UPDATE_REGISTRY || "").trim().replace(/\/+$/u, "");
3193
- if (!configured) return OFFICIAL_NPM_REGISTRY;
3382
+ const configured2 = String(env.VTX_CLI_UPDATE_REGISTRY || "").trim().replace(/\/+$/u, "");
3383
+ if (!configured2) return OFFICIAL_NPM_REGISTRY;
3194
3384
  let url2;
3195
3385
  try {
3196
- url2 = new URL(configured);
3386
+ url2 = new URL(configured2);
3197
3387
  } catch {
3198
3388
  throw new Error("VTX_CLI_UPDATE_REGISTRY is not a URL.");
3199
3389
  }
@@ -3201,7 +3391,7 @@ var init_updater = __esm({
3201
3391
  if (url2.protocol !== "https:" && !(url2.protocol === "http:" && loopback)) {
3202
3392
  throw new Error("VTX_CLI_UPDATE_REGISTRY must be https, or http on loopback.");
3203
3393
  }
3204
- return configured;
3394
+ return configured2;
3205
3395
  };
3206
3396
  validSelection = async (value, releasesPath) => {
3207
3397
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
@@ -3492,6 +3682,7 @@ var init_updater = __esm({
3492
3682
  const stopped = new AbortController();
3493
3683
  const tracker = {
3494
3684
  stops: 0,
3685
+ hungUp: false,
3495
3686
  child: null,
3496
3687
  stopped: stopped.signal,
3497
3688
  uninstall: () => void 0
@@ -3506,14 +3697,19 @@ var init_updater = __esm({
3506
3697
  }
3507
3698
  };
3508
3699
  const forward = (signal) => () => {
3700
+ if (signal === "SIGHUP") {
3701
+ ignoreClosedTerminalWrites();
3702
+ if (tracker.stops === 0) tracker.hungUp = true;
3703
+ }
3509
3704
  tracker.stops += 1;
3510
3705
  stopped.abort();
3706
+ if (signal === "SIGHUP" && process.platform === "win32") return;
3511
3707
  try {
3512
3708
  tracker.child?.kill(signal);
3513
3709
  } catch {
3514
3710
  }
3515
3711
  };
3516
- const forwarded = ["SIGTERM", "SIGHUP"].map((signal) => [signal, forward(signal)]);
3712
+ const forwarded = HEADLESS_RUNTIME_STOP_SIGNALS.filter((signal) => signal !== "SIGINT").map((signal) => [signal, forward(signal)]);
3517
3713
  process.on("SIGINT", onInterrupt);
3518
3714
  for (const [signal, handler] of forwarded) process.on(signal, handler);
3519
3715
  tracker.uninstall = () => {
@@ -3645,6 +3841,7 @@ var init_updater = __esm({
3645
3841
  };
3646
3842
  const stops = installStopTracker();
3647
3843
  const endAfterStop = async (exitCode) => {
3844
+ if (stops.hungUp) return exitCode;
3648
3845
  if (!await readRuntimeResume(supervisorEnv) || !dependencies.stopRuntimeBetweenChildren) return exitCode;
3649
3846
  const stopExitCode = await dependencies.stopRuntimeBetweenChildren(supervisorEnv);
3650
3847
  return stopExitCode === 0 ? exitCode : stopExitCode;
@@ -3889,7 +4086,7 @@ var init_updater = __esm({
3889
4086
  });
3890
4087
 
3891
4088
  // lib/constants.ts
3892
- var MS_PER_SECOND, SECONDS_PER_MINUTE, MINUTES_PER_HOUR, HOURS_PER_DAY, DAYS_PER_WEEK, MS_PER_MINUTE, BACKOFF_GROWTH_FACTOR, HTTP_STATUS, HTTP_STATUS_MIN, HTTP_STATUS_MAX, HTTP_CLIENT_ERROR_MIN, HTTP_SERVER_ERROR_MIN;
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;
3893
4090
  var init_constants = __esm({
3894
4091
  "lib/constants.ts"() {
3895
4092
  "use strict";
@@ -3902,6 +4099,13 @@ var init_constants = __esm({
3902
4099
  HOURS_PER_DAY = 24;
3903
4100
  DAYS_PER_WEEK = 7;
3904
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;
3905
4109
  BACKOFF_GROWTH_FACTOR = 2;
3906
4110
  HTTP_STATUS = {
3907
4111
  BAD_REQUEST: 400,
@@ -3922,6 +4126,40 @@ var init_constants = __esm({
3922
4126
  HTTP_STATUS_MAX = 599;
3923
4127
  HTTP_CLIENT_ERROR_MIN = 400;
3924
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
+ };
3925
4163
  }
3926
4164
  });
3927
4165
 
@@ -18469,7 +18707,7 @@ var init_zod = __esm({
18469
18707
  });
18470
18708
 
18471
18709
  // lib/external-inference-contract.ts
18472
- 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;
18473
18711
  var init_external_inference_contract = __esm({
18474
18712
  "lib/external-inference-contract.ts"() {
18475
18713
  "use strict";
@@ -18477,6 +18715,7 @@ var init_external_inference_contract = __esm({
18477
18715
  init_define_VTX_GROK_POLICY();
18478
18716
  init_define_VTX_PI_MODEL_POLICY();
18479
18717
  init_zod();
18718
+ init_constants();
18480
18719
  EXTERNAL_INFERENCE_CONTRACT_VERSION = "external_inference.v1";
18481
18720
  EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION = "external_inference_controller_v1";
18482
18721
  EXTERNAL_INFERENCE_CONTROLLER_SCHEMA_VERSION_V2 = "external_inference_controller_v2";
@@ -18487,14 +18726,17 @@ var init_external_inference_contract = __esm({
18487
18726
  LEGACY_EXTERNAL_INFERENCE_JOB_INPUT_SCHEMA_VERSION = "external_inference_job_input_v1";
18488
18727
  EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION = "external_inference_usage_v1";
18489
18728
  EXTERNAL_INFERENCE_INPUT_HASH_DOMAIN = "vtx.external-inference.input-sha256.v1\0";
18490
- MAX_EXTERNAL_INFERENCE_STATUS_HOSTS = 640;
18491
- MAX_PROFILE_EXTERNAL_INFERENCE_FALLBACKS_PER_LANE = 127;
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;
18492
18731
  MAX_GENERATION = 2147483647;
18493
18732
  MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER;
18494
- MAX_PROMPT_BYTES = 3e5;
18495
- MAX_IMMUTABLE_JOB_INPUT_BYTES = 3e5;
18496
- MAX_CANDIDATE_PLAINTEXT_BYTES = 3e5;
18497
- MAX_CIPHERTEXT_CHARS = 7e5;
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;
18498
18740
  SHA256_INITIAL_STATE = new Uint32Array([
18499
18741
  1779033703,
18500
18742
  3144134277,
@@ -18651,12 +18893,12 @@ var init_external_inference_contract = __esm({
18651
18893
  for (const [fieldName, value] of fields) {
18652
18894
  const fieldNameBytes = encoder.encode(fieldName);
18653
18895
  const valueBytes = encoder.encode(value);
18654
- const fieldNameLength = new Uint8Array(2);
18896
+ const fieldNameLength = new Uint8Array(EXTERNAL_INFERENCE_LIMITS.hash_field_name_length_bytes);
18655
18897
  new DataView(fieldNameLength.buffer).setUint16(0, fieldNameBytes.length, false);
18656
- const valueLength = new Uint8Array(8);
18898
+ const valueLength = new Uint8Array(EXTERNAL_INFERENCE_LIMITS.hash_value_length_bytes);
18657
18899
  const valueLengthView = new DataView(valueLength.buffer);
18658
18900
  valueLengthView.setUint32(0, Math.floor(valueBytes.length / 4294967296), false);
18659
- valueLengthView.setUint32(4, valueBytes.length >>> 0, false);
18901
+ valueLengthView.setUint32(valueLength.length - Uint32Array.BYTES_PER_ELEMENT, valueBytes.length >>> 0, false);
18660
18902
  chunks.push(fieldNameLength, fieldNameBytes, valueLength, valueBytes);
18661
18903
  }
18662
18904
  const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
@@ -18793,7 +19035,7 @@ var init_external_inference_contract = __esm({
18793
19035
  ]);
18794
19036
  modelIdentityMappingSchema = external_exports.strictObject({
18795
19037
  requested_model: modelNameSchema,
18796
- effective_models: external_exports.array(modelNameSchema).min(1).max(16)
19038
+ effective_models: external_exports.array(modelNameSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_effective_models)
18797
19039
  }).superRefine((value, context) => {
18798
19040
  if (new Set(value.effective_models).size !== value.effective_models.length) {
18799
19041
  context.addIssue({
@@ -18808,11 +19050,11 @@ var init_external_inference_contract = __esm({
18808
19050
  label: displayNameSchema,
18809
19051
  adapter: externalInferenceAdapterIdSchema,
18810
19052
  supported_lanes: external_exports.array(laneSchema).min(1).max(3),
18811
- supported_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(16),
19053
+ supported_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_reasoning_efforts),
18812
19054
  default_reasoning_effort: reasoningEffortSchema,
18813
19055
  supported_response_modes: external_exports.array(responseModeSchema).min(1).max(2),
18814
19056
  supported_control_modes: external_exports.array(controlModeSchema).min(1).max(2).optional(),
18815
- allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(16),
19057
+ allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_model_identities),
18816
19058
  structured_output: external_exports.boolean(),
18817
19059
  same_attempt_recovery: external_exports.boolean(),
18818
19060
  adapter_runtime_version: protocolVersionSchema
@@ -18864,7 +19106,7 @@ var init_external_inference_contract = __esm({
18864
19106
  health: external_exports.enum(["healthy", "degraded", "draining"]),
18865
19107
  advertised_at: timestampSchema,
18866
19108
  expires_at: timestampSchema,
18867
- models: external_exports.array(advertisedModelSchema).min(1).max(64)
19109
+ models: external_exports.array(advertisedModelSchema).min(1).max(EXTERNAL_INFERENCE_LIMITS.max_advertised_models)
18868
19110
  }).superRefine((value, context) => {
18869
19111
  if (value.provider_dispatch_freshness_contract !== void 0 && !/^\d+\.\d+\.\d+$/.test(value.host_runtime_version ?? "")) {
18870
19112
  context.addIssue({ code: "custom", message: "Foreground freshness contract requires a numeric runtime version." });
@@ -19062,8 +19304,8 @@ var init_external_inference_contract = __esm({
19062
19304
  controller: boundExternalAgentModelControllerSchema,
19063
19305
  requested_model: modelNameSchema,
19064
19306
  requested_reasoning_effort: reasoningEffortSchema,
19065
- allowed_model_identities: external_exports.array(modelIdentityMappingSchema).min(1).max(16),
19066
- allowed_effective_reasoning_efforts: external_exports.array(reasoningEffortSchema).min(1).max(16),
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),
19067
19309
  response_mode: responseModeSchema,
19068
19310
  output_schema_version: protocolVersionSchema,
19069
19311
  parser_contract_version: protocolVersionSchema,
@@ -19252,12 +19494,12 @@ var init_external_inference_contract = __esm({
19252
19494
  }).refine(
19253
19495
  (tool) => tool.type === "redacted" === (tool.type_sha256 !== null) && tool.name === "redacted" === (tool.name_sha256 !== null),
19254
19496
  { message: "Only redacted tool identifiers require hashes." }
19255
- )).max(8),
19497
+ )).max(MAX_GROK_TOOL_SUMMARIES),
19256
19498
  tools_truncated: external_exports.boolean(),
19257
19499
  prior_dispatch: external_exports.boolean(),
19258
19500
  completed_response_count: nonNegativeSafeIntegerSchema
19259
19501
  }).refine(
19260
- (value) => value.tools_shape === "array" ? value.tool_count !== null && value.tools.length === Math.min(value.tool_count, 8) && value.tools_truncated === value.tool_count > 8 : value.tool_count === null && value.tools.length === 0 && !value.tools_truncated,
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,
19261
19503
  { message: "Grok tool diagnostic counts must match the observed shape." }
19262
19504
  ).refine(
19263
19505
  (value) => value.prior_dispatch || value.completed_response_count === 0,
@@ -19477,13 +19719,13 @@ var init_external_inference_contract = __esm({
19477
19719
  credits_available: external_exports.boolean().nullable().optional(),
19478
19720
  rate_limit_reached: external_exports.boolean().nullable().optional(),
19479
19721
  source: external_exports.literal("codex_app_server"),
19480
- used_percent: external_exports.number().finite().min(0).max(1e6),
19722
+ used_percent: external_exports.number().finite().min(0).max(EXTERNAL_INFERENCE_LIMITS.max_usage_percent),
19481
19723
  resets_at: timestampSchema,
19482
19724
  observed_at: timestampSchema
19483
19725
  }).superRefine((value, context) => {
19484
19726
  const observedAt = Date.parse(value.observed_at);
19485
19727
  const resetsAt = Date.parse(value.resets_at);
19486
- if (resetsAt <= observedAt || resetsAt > observedAt + 8 * 24 * 60 * 60 * 1e3) {
19728
+ if (resetsAt <= observedAt || resetsAt > observedAt + PROVIDER_RESET_MAX_MS) {
19487
19729
  context.addIssue({
19488
19730
  code: "custom",
19489
19731
  message: "weekly quota reset must follow observation within eight days",
@@ -19551,12 +19793,12 @@ var init_external_inference_contract = __esm({
19551
19793
  external_exports.strictObject({
19552
19794
  schema_version: external_exports.literal("external_inference_job_claim_v2"),
19553
19795
  ...jobClaimRequestBaseShape,
19554
- maximum_jobs: external_exports.number().int().min(1).max(32)
19796
+ maximum_jobs: external_exports.number().int().min(1).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size)
19555
19797
  }),
19556
19798
  external_exports.strictObject({
19557
19799
  schema_version: external_exports.literal("external_inference_job_claim_v3"),
19558
19800
  ...jobClaimRequestBaseShape,
19559
- maximum_jobs: external_exports.number().int().min(1).max(32)
19801
+ maximum_jobs: external_exports.number().int().min(1).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size)
19560
19802
  })
19561
19803
  ]);
19562
19804
  emptyJobClaimSchema = external_exports.strictObject({
@@ -19611,14 +19853,14 @@ var init_external_inference_contract = __esm({
19611
19853
  schema_version: external_exports.literal("external_inference_job_claim_result_v2"),
19612
19854
  claim_state: external_exports.literal("batch"),
19613
19855
  claim_request_id: operationIdentifierSchema,
19614
- claims: external_exports.array(claimedDispatchIntentSchema).max(32),
19856
+ claims: external_exports.array(claimedDispatchIntentSchema).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size),
19615
19857
  retry_after_ms: nonNegativeSafeIntegerSchema
19616
19858
  });
19617
19859
  timedBatchedJobClaimSchema = external_exports.strictObject({
19618
19860
  schema_version: external_exports.literal("external_inference_job_claim_result_v3"),
19619
19861
  claim_state: external_exports.literal("batch"),
19620
19862
  claim_request_id: operationIdentifierSchema,
19621
- claims: external_exports.array(claimedDispatchIntentSchema).max(32),
19863
+ claims: external_exports.array(claimedDispatchIntentSchema).max(EXTERNAL_INFERENCE_LIMITS.max_job_claim_batch_size),
19622
19864
  retry_after_ms: nonNegativeSafeIntegerSchema,
19623
19865
  server_processing_ms: nonNegativeSafeIntegerSchema
19624
19866
  });
@@ -19769,7 +20011,7 @@ var init_external_inference_contract = __esm({
19769
20011
  pending_request_count: nonNegativeSafeIntegerSchema.nullable(),
19770
20012
  active_thread_count: nonNegativeSafeIntegerSchema.nullable(),
19771
20013
  stderr_nonempty: external_exports.boolean().nullable(),
19772
- stderr_bytes_observed: external_exports.number().int().min(0).max(65536).nullable(),
20014
+ stderr_bytes_observed: external_exports.number().int().min(0).max(STDERR_OBSERVATION_CAP_BYTES).nullable(),
19773
20015
  stderr_truncated: external_exports.boolean().nullable(),
19774
20016
  stderr_class: external_exports.enum([
19775
20017
  "unknown",
@@ -19801,7 +20043,7 @@ var init_external_inference_contract = __esm({
19801
20043
  } else if (value.stderr_bytes_observed === 0 || value.stderr_class === "none") {
19802
20044
  context.addIssue({ code: "custom", message: "non-empty stderr diagnostics are inconsistent", path: ["stderr_nonempty"] });
19803
20045
  }
19804
- if (value.stderr_truncated && value.stderr_bytes_observed !== 65536) {
20046
+ if (value.stderr_truncated && value.stderr_bytes_observed !== STDERR_OBSERVATION_CAP_BYTES) {
19805
20047
  context.addIssue({ code: "custom", message: "truncated stderr diagnostics must report the observation cap", path: ["stderr_truncated"] });
19806
20048
  }
19807
20049
  });
@@ -19854,7 +20096,7 @@ var init_external_inference_contract = __esm({
19854
20096
  if (value.provider_retry_at != null !== (value.provider_retry_source != null)) {
19855
20097
  context.addIssue({ code: "custom", message: "provider retry deadline and source must be provided together", path: ["provider_retry_at"] });
19856
20098
  }
19857
- if (value.provider_retry_at != null && Date.parse(value.provider_retry_at) > Date.parse(value.failed_at) + 8 * 24 * 60 * 60 * 1e3) {
20099
+ if (value.provider_retry_at != null && Date.parse(value.provider_retry_at) > Date.parse(value.failed_at) + PROVIDER_RESET_MAX_MS) {
19858
20100
  context.addIssue({ code: "custom", message: "provider retry deadline must be within eight days of failure", path: ["provider_retry_at"] });
19859
20101
  }
19860
20102
  if (value.outcome.response_outcome !== "none") {
@@ -20061,7 +20303,7 @@ var init_external_inference_contract = __esm({
20061
20303
  advertisement_generation: generationSchema,
20062
20304
  key_generation: generationSchema,
20063
20305
  last_heartbeat_at: timestampSchema.nullable(),
20064
- models: external_exports.array(advertisedModelSchema).max(64)
20306
+ models: external_exports.array(advertisedModelSchema).max(EXTERNAL_INFERENCE_LIMITS.max_advertised_models)
20065
20307
  });
20066
20308
  controllerBindingStatusReadSchema = external_exports.strictObject({
20067
20309
  profile_name: external_exports.string().min(1).max(50),
@@ -20117,7 +20359,7 @@ var init_external_inference_contract = __esm({
20117
20359
  last_hour: externalInferenceVolumeWindowReadSchema,
20118
20360
  last_day: externalInferenceVolumeWindowReadSchema,
20119
20361
  last_week: externalInferenceVolumeWindowReadSchema,
20120
- recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(32)
20362
+ recent_failures: external_exports.array(externalInferenceFailureCountReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_recent_failures)
20121
20363
  });
20122
20364
  externalInferenceProfileActivityReadSchema = external_exports.strictObject({
20123
20365
  last_hour: externalInferenceVolumeWindowReadSchema,
@@ -20130,7 +20372,7 @@ var init_external_inference_contract = __esm({
20130
20372
  observed_at: timestampSchema,
20131
20373
  catalog_generation: generationSchema,
20132
20374
  hosts: external_exports.array(hostStatusReadSchema).max(MAX_EXTERNAL_INFERENCE_STATUS_HOSTS),
20133
- bindings: external_exports.array(controllerBindingStatusReadSchema).max(512),
20375
+ bindings: external_exports.array(controllerBindingStatusReadSchema).max(EXTERNAL_INFERENCE_LIMITS.max_status_bindings),
20134
20376
  binding_count: nonNegativeSafeIntegerSchema.optional().default(0),
20135
20377
  bindings_truncated: external_exports.boolean().optional().default(false),
20136
20378
  queue: queueStatusReadSchema,
@@ -20413,8 +20655,8 @@ var init_external_inference_contract = __esm({
20413
20655
  parser_status: external_exports.enum(["not_run", "clean", "repaired", "fallback", "failed"]),
20414
20656
  parsed_candidate_schema_version: protocolVersionSchema.nullable(),
20415
20657
  parser_fallback_strategy: safeCodeSchema.nullable(),
20416
- validation_error_codes: external_exports.array(safeCodeSchema).max(128),
20417
- discarded_fields: external_exports.array(external_exports.string().min(1).max(128).regex(/^[A-Za-z0-9_.\[\]-]+$/)).max(128),
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),
20418
20660
  parsed_candidate_utf8: boundedJsonTextSchema.nullable(),
20419
20661
  parsed_candidate_sha256: sha256HexSchema.nullable(),
20420
20662
  disposition: external_exports.enum([
@@ -22302,6 +22544,89 @@ var init_runtime_policy_generated2 = __esm({
22302
22544
  refresh_interval_ms: 1e4,
22303
22545
  watchdog_interval_ms: 1e3,
22304
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
22305
22630
  }
22306
22631
  },
22307
22632
  ai_dashboard: {
@@ -22343,6 +22668,9 @@ var init_runtime_policy_generated2 = __esm({
22343
22668
  72,
22344
22669
  168
22345
22670
  ]
22671
+ },
22672
+ defaults: {
22673
+ max_chat_turns: 9999
22346
22674
  }
22347
22675
  },
22348
22676
  trading: {
@@ -22411,7 +22739,14 @@ var init_runtime_policy_generated2 = __esm({
22411
22739
  client_claim_retry_delay_milliseconds: 1e3,
22412
22740
  client_failure_report_timeout_milliseconds: 2e3,
22413
22741
  client_presence_heartbeat_interval_milliseconds: 3e4,
22414
- 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
22415
22750
  }
22416
22751
  }
22417
22752
  },
@@ -22420,6 +22755,10 @@ var init_runtime_policy_generated2 = __esm({
22420
22755
  history_start_ms: 16409952e5,
22421
22756
  device_read_deadline_seconds: 180,
22422
22757
  device_recent_window_hours: 24
22758
+ },
22759
+ tradability: {
22760
+ score_min: 1,
22761
+ score_max: 10
22423
22762
  }
22424
22763
  },
22425
22764
  agent_cli: {
@@ -22507,6 +22846,9 @@ var init_runtime_policy_generated2 = __esm({
22507
22846
  resource_scheduler: {
22508
22847
  client_lock_ttl_milliseconds: 12e4,
22509
22848
  client_poll_interval_milliseconds: 250
22849
+ },
22850
+ defaults: {
22851
+ adaptive_schedule_enabled: true
22510
22852
  }
22511
22853
  },
22512
22854
  deployment: {
@@ -22628,7 +22970,10 @@ var init_runtime_policy_generated2 = __esm({
22628
22970
  },
22629
22971
  market_data: {
22630
22972
  chart_interest: {
22631
- historical_backfill_candle_limit: 1e3
22973
+ historical_backfill_candle_limit: 1e3,
22974
+ heartbeat_retry_seconds: 15,
22975
+ heartbeat_min_delay_ms: 1e3,
22976
+ catch_up_candle_limit: 300
22632
22977
  }
22633
22978
  },
22634
22979
  auth: {
@@ -22637,6 +22982,14 @@ var init_runtime_policy_generated2 = __esm({
22637
22982
  totp_code_length: 6
22638
22983
  }
22639
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
+ },
22640
22993
  websocket: {
22641
22994
  client_connection: {
22642
22995
  reconnect_delay_ms: 3e3,
@@ -22649,6 +23002,9 @@ var init_runtime_policy_generated2 = __esm({
22649
23002
  notifications: {
22650
23003
  desktop: {
22651
23004
  heartbeat_seconds: 20
23005
+ },
23006
+ telegram: {
23007
+ connect_link_poll_ms: 3e3
22652
23008
  }
22653
23009
  },
22654
23010
  validation: {
@@ -22663,6 +23019,63 @@ var init_runtime_policy_generated2 = __esm({
22663
23019
  handle_changes_per_window: 2,
22664
23020
  handle_change_window_days: 14
22665
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
22666
23079
  }
22667
23080
  };
22668
23081
  }
@@ -31109,7 +31522,7 @@ child.once('close', async (code, signal) => {
31109
31522
  });
31110
31523
  }
31111
31524
  static {
31112
- this.STDERR_OBSERVATION_CAP_BYTES = 65536;
31525
+ this.STDERR_OBSERVATION_CAP_BYTES = EXTERNAL_INFERENCE_LIMITS.stderr_observation_cap_bytes;
31113
31526
  }
31114
31527
  static {
31115
31528
  this.STDERR_CLASSIFICATION_TAIL_CHARS = 1024;
@@ -41452,7 +41865,7 @@ import {
41452
41865
  getSupportedThinkingLevels,
41453
41866
  InMemoryCredentialStore
41454
41867
  } from "@earendil-works/pi-ai";
41455
- var import_ajv2, PI_RUNTIME_VERSION, MAX_TEXT_BYTES, effortToPi, effortToVtx, modelReference, object2, fail, sdkFailureCode, assertPiStructuredOutputSchema, privateRuntime, qualifiedModel, usageSum, PiAdapter, cleanupPiOwnedState;
41868
+ var import_ajv2, PI_RUNTIME_VERSION, effortToPi, effortToVtx, modelReference, object2, fail, sdkFailureCode, assertPiStructuredOutputSchema, privateRuntime, qualifiedModel, usageSum, PiAdapter, cleanupPiOwnedState;
41456
41869
  var init_pi_adapter = __esm({
41457
41870
  "lib/inference-host/pi-adapter.ts"() {
41458
41871
  "use strict";
@@ -41461,10 +41874,10 @@ var init_pi_adapter = __esm({
41461
41874
  init_define_VTX_PI_MODEL_POLICY();
41462
41875
  import_ajv2 = __toESM(require_ajv(), 1);
41463
41876
  init_codex_app_server();
41877
+ init_constants();
41464
41878
  init_config2();
41465
41879
  init_pi_transport();
41466
41880
  PI_RUNTIME_VERSION = "0.85.1";
41467
- MAX_TEXT_BYTES = 3e5;
41468
41881
  effortToPi = (effort2) => effort2 === "none" ? "off" : effort2;
41469
41882
  effortToVtx = (effort2) => effort2 === "off" ? "none" : effort2;
41470
41883
  modelReference = (model) => `${model.provider}/${model.id}`;
@@ -41637,7 +42050,7 @@ var init_pi_adapter = __esm({
41637
42050
  };
41638
42051
  try {
41639
42052
  checkBoundary();
41640
- if (!input.systemPrompt.trim() || !input.userPrompt.trim() || Buffer.byteLength(input.systemPrompt) > MAX_TEXT_BYTES || Buffer.byteLength(input.userPrompt) > MAX_TEXT_BYTES) throw fail("pi_prompt_invalid", "schema");
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");
41641
42054
  const schema = agent ? agent.outputSchema : object2(JSON.parse(input.outputSchemaJson));
41642
42055
  if (agent && !agent.dataContract.length) throw fail("pi_data_contract_missing", "schema");
41643
42056
  if (schema.type !== "object") throw fail("pi_output_schema_invalid", "schema");
@@ -41836,7 +42249,7 @@ var init_pi_adapter = __esm({
41836
42249
  if (!last) throw fail("pi_result_missing");
41837
42250
  if (last.stopReason !== "stop") throw fail("pi_terminal_incomplete");
41838
42251
  const text = last.content.flatMap((part) => part.type === "text" ? [part.text] : []).join("");
41839
- if (!text.trim() || Buffer.byteLength(text) > MAX_TEXT_BYTES) throw fail("pi_output_invalid", "schema");
42252
+ if (!text.trim() || Buffer.byteLength(text) > EXTERNAL_INFERENCE_LIMITS.max_candidate_plaintext_bytes) throw fail("pi_output_invalid", "schema");
41840
42253
  let output3;
41841
42254
  try {
41842
42255
  output3 = JSON.parse(text);
@@ -50390,9 +50803,9 @@ function resolveBrowserApiUrl(hostname3, protocol, publicApiUrl, development) {
50390
50803
  if (local) {
50391
50804
  let port = "8000";
50392
50805
  try {
50393
- const configured = new URL(publicApiUrl ?? "");
50394
- if (configured.port && (configured.hostname === "localhost" || configured.hostname === "127.0.0.1")) {
50395
- port = configured.port;
50806
+ const configured2 = new URL(publicApiUrl ?? "");
50807
+ if (configured2.port && (configured2.hostname === "localhost" || configured2.hostname === "127.0.0.1")) {
50808
+ port = configured2.port;
50396
50809
  }
50397
50810
  } catch {
50398
50811
  }
@@ -50480,7 +50893,12 @@ function configureApiTransport(transport) {
50480
50893
  if (!/^https?:\/\/[^/]/i.test(baseUrl)) {
50481
50894
  throw new Error("VTX API transport requires an absolute http(s) base URL.");
50482
50895
  }
50483
- configuredApiTransport = { baseUrl, authorization: transport.authorization, headers: transport.headers };
50896
+ configuredApiTransport = {
50897
+ baseUrl,
50898
+ authorization: transport.authorization,
50899
+ sessionToken: transport.sessionToken,
50900
+ headers: transport.headers
50901
+ };
50484
50902
  }
50485
50903
  function getActiveProfileId() {
50486
50904
  return activeProfileId;
@@ -50523,6 +50941,8 @@ var init_shared = __esm({
50523
50941
  }
50524
50942
  const authorization = transport.authorization();
50525
50943
  if (authorization) headers.set("Authorization", authorization);
50944
+ const sessionToken = transport.sessionToken?.();
50945
+ if (sessionToken) headers.set("Cookie", `session_token=${sessionToken}`);
50526
50946
  return fetch(input, { ...init2, headers, credentials: "omit" });
50527
50947
  };
50528
50948
  sleep = (ms) => new Promise((resolve14) => setTimeout(resolve14, ms));
@@ -52258,8 +52678,12 @@ function configureRuntimeHostStorage(storage3) {
52258
52678
  }
52259
52679
  function runtimeHostStorage() {
52260
52680
  if (configuredStorage) return configuredStorage;
52261
- if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
52262
- return window.localStorage;
52681
+ try {
52682
+ if (typeof window !== "undefined" && typeof window.localStorage !== "undefined") {
52683
+ return window.localStorage;
52684
+ }
52685
+ } catch {
52686
+ return null;
52263
52687
  }
52264
52688
  return null;
52265
52689
  }
@@ -85130,9 +85554,9 @@ var init_hyperliquid_client = __esm({
85130
85554
  if (explicit) {
85131
85555
  return explicit;
85132
85556
  }
85133
- const configured = input.config?.client_runtime_exchange_endpoints?.hyperliquid_api_url?.trim();
85134
- if (configured) {
85135
- return configured;
85557
+ const configured2 = input.config?.client_runtime_exchange_endpoints?.hyperliquid_api_url?.trim();
85558
+ if (configured2) {
85559
+ return configured2;
85136
85560
  }
85137
85561
  throw new Error("Missing client runtime Hyperliquid API URL.");
85138
85562
  };
@@ -91842,10 +92266,10 @@ var init_hyperliquid_account_state_adapter = __esm({
91842
92266
  };
91843
92267
  listPerpDexsForAccountState = (config2, selectedDex, aggregatePerpDexs, perpDexScope) => {
91844
92268
  if (aggregatePerpDexs) {
91845
- const configured = listConfiguredPerpDexs(config2);
91846
- if (!perpDexScope) return configured;
92269
+ const configured2 = listConfiguredPerpDexs(config2);
92270
+ if (!perpDexScope) return configured2;
91847
92271
  const scope = new Set(perpDexScope.map(normalizePerpDexName));
91848
- return configured.filter((dex) => scope.has(dex));
92272
+ return configured2.filter((dex) => scope.has(dex));
91849
92273
  }
91850
92274
  return selectedDex ? [selectedDex] : [];
91851
92275
  };
@@ -101379,7 +101803,7 @@ var init_protective_adoption_status = __esm({
101379
101803
  });
101380
101804
 
101381
101805
  // lib/runtime/protective-cutover.ts
101382
- var ADOPTION_REQUEST_TIMEOUT_MS, ADOPTION_FAILURE_RETRY_MS, adoptWithinTimeout, adoptionRetryAt, CLIENT_PROTECTIVE_ACTIONS_EVENT, protectiveActionsPendingListeners, onClientProtectiveActionsPending, notifyClientProtectiveActionsPending, adoptionLegOutcomes, hasGroupsToAdopt, shouldSyncServerOwnedProtection, syncServerOwnedProtection;
101806
+ var ADOPTION_REQUEST_TIMEOUT_MS, ADOPTION_FAILURE_RETRY_MS, adoptWithinTimeout, adoptionRetryAt, protectiveActionsPendingListeners, onClientProtectiveActionsPending, notifyClientProtectiveActionsPending, adoptionLegOutcomes, hasGroupsToAdopt, shouldSyncServerOwnedProtection, syncServerOwnedProtection;
101383
101807
  var init_protective_cutover = __esm({
101384
101808
  "lib/runtime/protective-cutover.ts"() {
101385
101809
  "use strict";
@@ -101420,7 +101844,6 @@ var init_protective_cutover = __esm({
101420
101844
  }
101421
101845
  };
101422
101846
  adoptionRetryAt = /* @__PURE__ */ new Map();
101423
- CLIENT_PROTECTIVE_ACTIONS_EVENT = "vtx:client-protective-actions";
101424
101847
  protectiveActionsPendingListeners = /* @__PURE__ */ new Set();
101425
101848
  onClientProtectiveActionsPending = (listener) => {
101426
101849
  protectiveActionsPendingListeners.add(listener);
@@ -101435,10 +101858,6 @@ var init_protective_cutover = __esm({
101435
101858
  } catch {
101436
101859
  }
101437
101860
  }
101438
- if (typeof window === "undefined" || typeof window.dispatchEvent !== "function") return;
101439
- window.dispatchEvent(new CustomEvent(CLIENT_PROTECTIVE_ACTIONS_EVENT, {
101440
- detail: { profileId: String(profileId) }
101441
- }));
101442
101861
  };
101443
101862
  adoptionLegOutcomes = (groups, adoption) => {
101444
101863
  if (Array.isArray(adoption.leg_outcomes)) return adoption.leg_outcomes;
@@ -102897,6 +103316,23 @@ var init_desktop_bridge = __esm({
102897
103316
  }
102898
103317
  });
102899
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
+
102900
103336
  // lib/runtime/client-ownership-arbitration-contract.ts
102901
103337
  var deriveOwnershipLossReasonFromRuntimeError;
102902
103338
  var init_client_ownership_arbitration_contract = __esm({
@@ -102918,15 +103354,17 @@ var init_client_runtime_device_id = __esm({
102918
103354
  init_define_VTX_EXO_POLICY();
102919
103355
  init_define_VTX_GROK_POLICY();
102920
103356
  init_define_VTX_PI_MODEL_POLICY();
103357
+ init_host_storage();
102921
103358
  CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY = "vtx_client_runtime_device_id";
102922
103359
  createDeviceId = () => typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `device-${Date.now()}-${Math.random().toString(16).slice(2)}`;
102923
103360
  getOrCreateClientRuntimeDeviceId = () => {
102924
- if (typeof window === "undefined") return null;
103361
+ const storage3 = runtimeHostStorage();
103362
+ if (!storage3) return null;
102925
103363
  try {
102926
- const existing = window.localStorage.getItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY)?.trim();
103364
+ const existing = storage3.getItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY)?.trim();
102927
103365
  if (existing) return existing;
102928
103366
  const created = createDeviceId();
102929
- window.localStorage.setItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY, created);
103367
+ storage3.setItem(CLIENT_RUNTIME_DEVICE_ID_STORAGE_KEY, created);
102930
103368
  return created;
102931
103369
  } catch {
102932
103370
  return createDeviceId();
@@ -104553,9 +104991,9 @@ var init_client_killswitch = __esm({
104553
104991
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
104554
104992
  };
104555
104993
  firstConfiguredSymbol = (preferences, config2) => {
104556
- const configured = Array.isArray(preferences.trading_symbols) ? preferences.trading_symbols.map((value) => String(value || "").trim()).find(Boolean) : null;
104994
+ const configured2 = Array.isArray(preferences.trading_symbols) ? preferences.trading_symbols.map((value) => String(value || "").trim()).find(Boolean) : null;
104557
104995
  const fallback = String(config2.default_chart_symbol || "").trim();
104558
- const symbol2 = configured || fallback;
104996
+ const symbol2 = configured2 || fallback;
104559
104997
  if (!symbol2) {
104560
104998
  throw new Error("Client killswitch requires a configured trading symbol.");
104561
104999
  }
@@ -105523,13 +105961,14 @@ var init_candle_prompt_contract = __esm({
105523
105961
  });
105524
105962
 
105525
105963
  // lib/runtime/decision-contract.ts
105526
- 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;
105527
105965
  var init_decision_contract = __esm({
105528
105966
  "lib/runtime/decision-contract.ts"() {
105529
105967
  "use strict";
105530
105968
  init_define_VTX_EXO_POLICY();
105531
105969
  init_define_VTX_GROK_POLICY();
105532
105970
  init_define_VTX_PI_MODEL_POLICY();
105971
+ init_runtime_policy_generated2();
105533
105972
  JSON_FENCE_PATTERN = /^```(?:json)?\s*\n?([\s\S]*?)\n?```$/i;
105534
105973
  JSON_SIMPLE_ESCAPE_CHARS = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t"]);
105535
105974
  JSON_HEX_ESCAPE_PATTERN = /^[0-9a-fA-F]{4}$/;
@@ -105901,15 +106340,15 @@ var init_decision_contract = __esm({
105901
106340
  const decisionValue = String(rawDecision || "").trim().toUpperCase();
105902
106341
  return decisionValue === "BUY" || decisionValue === "SELL" ? decisionValue : "HOLD";
105903
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;
105904
106346
  normalizeTradabilityScore = (rawTradability) => {
105905
106347
  if (rawTradability === null || typeof rawTradability === "undefined" || typeof rawTradability === "boolean") {
105906
106348
  return null;
105907
106349
  }
105908
106350
  const parsed = Number(rawTradability);
105909
- if (!Number.isInteger(parsed) || parsed < 1 || parsed > 10) {
105910
- return null;
105911
- }
105912
- return parsed;
106351
+ return isTradabilityScore(parsed) ? parsed : null;
105913
106352
  };
105914
106353
  extractNormalizedDecision = (rawResponse, parsedDecision, symbol2) => {
105915
106354
  const content = sanitizeVisibleRuntimeText(rawResponse || "");
@@ -106379,6 +106818,7 @@ var init_screener_resource_scheduler = __esm({
106379
106818
  init_define_VTX_GROK_POLICY();
106380
106819
  init_define_VTX_PI_MODEL_POLICY();
106381
106820
  init_runtime_policy_generated2();
106821
+ init_host_storage();
106382
106822
  STORAGE_KEY = "vtx_llm_resource_scheduler_v1";
106383
106823
  CHANNEL_NAME = "vtx-llm-resource-scheduler";
106384
106824
  LOCK_TTL_MS = runtime_policy_generated_default2.screener.resource_scheduler.client_lock_ttl_milliseconds;
@@ -106393,7 +106833,7 @@ var init_screener_resource_scheduler = __esm({
106393
106833
  };
106394
106834
  storage2 = () => {
106395
106835
  try {
106396
- return typeof window !== "undefined" ? window.localStorage : null;
106836
+ return runtimeHostStorage();
106397
106837
  } catch {
106398
106838
  return null;
106399
106839
  }
@@ -111563,7 +112003,7 @@ var init_local_analysis = __esm({
111563
112003
  const tradability = decision.tradability;
111564
112004
  const reasoning = decision.reasoning;
111565
112005
  if (!Number.isInteger(units)) errors.add("decision_units_invalid");
111566
- if (!Number.isInteger(tradability) || Number(tradability) < 1 || Number(tradability) > 10) {
112006
+ if (!isTradabilityScore(tradability)) {
111567
112007
  errors.add("decision_tradability_invalid");
111568
112008
  }
111569
112009
  if (typeof reasoning !== "string" || reasoning.trim() === "" || reasoning.trim() === "-") {
@@ -113320,7 +113760,7 @@ ${reviewOutputContract}`;
113320
113760
  const priceRaw = Number(source.price);
113321
113761
  const price = Number.isFinite(priceRaw) && priceRaw > 0 ? priceRaw : null;
113322
113762
  const tradabilityRaw = Number(source.tradability);
113323
- const tradability = Number.isInteger(tradabilityRaw) && tradabilityRaw >= 1 && tradabilityRaw <= 10 ? tradabilityRaw : null;
113763
+ const tradability = isTradabilityScore(tradabilityRaw) ? tradabilityRaw : null;
113324
113764
  const executedAtMsRaw = Number(source.executed_at_ms ?? 0);
113325
113765
  const executedAtMs = Number.isFinite(executedAtMsRaw) && executedAtMsRaw > 0 ? Math.trunc(executedAtMsRaw) : 0;
113326
113766
  return {
@@ -113383,7 +113823,7 @@ ${reviewOutputContract}`;
113383
113823
  throw new Error(`Enabled behavior memory has invalid ${key} schema`);
113384
113824
  }
113385
113825
  if (key === "et") {
113386
- 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 >= 1 && item.tr <= 10) || !isNonnegativeInteger(item.age) || typeof item.r !== "string" || item.r.trim().length === 0 || item.r.trim() === "-") {
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() === "-") {
113387
113827
  throw new Error("Enabled behavior memory has invalid et values");
113388
113828
  }
113389
113829
  return {
@@ -113398,7 +113838,7 @@ ${reviewOutputContract}`;
113398
113838
  };
113399
113839
  }
113400
113840
  if (key === "pd") {
113401
- if (!isExactEnumString(item.a, ["BUY", "SELL", "HOLD"]) || !isNonnegativeInteger(item.u) || !(item.tr === "-" || isNonnegativeInteger(item.tr) && item.tr >= 1 && item.tr <= 10) || !isNonnegativeInteger(item.age) || !isExactEnumString(item.ps, ["LONG", "SHORT", "FLAT"]) || !isExactEnumString(item.x, ["e", "b", "f", "n", "-"]) || !isNonemptyPromptText(item.r)) {
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)) {
113402
113842
  throw new Error("Enabled behavior memory has invalid pd values");
113403
113843
  }
113404
113844
  return {
@@ -116766,7 +117206,7 @@ var init_engine = __esm({
116766
117206
  init_browser_observability();
116767
117207
  init_error_surface_contract();
116768
117208
  init_render_debug();
116769
- init_desktop_bridge();
117209
+ init_environment();
116770
117210
  init_client_ownership_arbitration_contract();
116771
117211
  init_client_runtime_ownership_errors();
116772
117212
  init_client_runtime_device_id();
@@ -117719,7 +118159,7 @@ var init_engine = __esm({
117719
118159
  return {
117720
118160
  deviceId: this._deviceId,
117721
118161
  sessionId: this._sessionId,
117722
- surface: getDesktopBridge() ? "desktop" : "browser"
118162
+ surface: runtimeHostSurface()
117723
118163
  };
117724
118164
  }
117725
118165
  async _shouldStopForExecutionModeMismatch() {
@@ -118012,7 +118452,7 @@ var init_engine = __esm({
118012
118452
  payload: {
118013
118453
  reason,
118014
118454
  state: this._state,
118015
- claim_surface: getDesktopBridge() ? "desktop" : "browser",
118455
+ claim_surface: runtimeHostSurface(),
118016
118456
  route_pathname: typeof window !== "undefined" ? window.location.pathname : null,
118017
118457
  visibility_state: typeof document !== "undefined" ? document.visibilityState : null,
118018
118458
  online: typeof navigator !== "undefined" ? navigator.onLine : null,
@@ -121149,7 +121589,7 @@ var init_engine = __esm({
121149
121589
  if (!sessionId || !deviceId || !mode) {
121150
121590
  return;
121151
121591
  }
121152
- const desktopRuntimeSurface = Boolean(getDesktopBridge());
121592
+ const desktopRuntimeSurface = runtimeHostSurface() === "desktop";
121153
121593
  try {
121154
121594
  await reportClientRuntimeLifecycleEvent(
121155
121595
  profileId,
@@ -122987,11 +123427,17 @@ async function runHeadlessRuntime(options) {
122987
123427
  const engine = new ClientExecutionEngine();
122988
123428
  const stopController = new AbortController();
122989
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
+ };
122990
123436
  if (options.signal?.aborted) stop();
122991
123437
  options.signal?.addEventListener("abort", stop, { once: true });
122992
- const signalNames = ["SIGINT", "SIGTERM"];
123438
+ const signalHandlers = HEADLESS_RUNTIME_STOP_SIGNALS.map((signal) => [signal, signal === "SIGHUP" ? hangUp : stop]);
122993
123439
  if (options.stopOnSignals !== false) {
122994
- for (const signalName of signalNames) process.on(signalName, stop);
123440
+ for (const [signalName, handler] of signalHandlers) process.on(signalName, handler);
122995
123441
  }
122996
123442
  const pending3 = [];
122997
123443
  let wake = null;
@@ -123037,6 +123483,10 @@ async function runHeadlessRuntime(options) {
123037
123483
  { runtimeViewer: { deviceId: identity2.deviceId, sessionId: identity2.sessionId } }
123038
123484
  )).statuses?.[String(options.profileId)] ?? null;
123039
123485
  const stopRuntime = async (reason) => {
123486
+ if (hungUp && reason === "agent_cli:stop") {
123487
+ await leaveRuntime();
123488
+ return;
123489
+ }
123040
123490
  if (engine.active) await engine.stop({ skipRemote: true, reason });
123041
123491
  try {
123042
123492
  await stopClientRuntimeSession(options.profileId, {
@@ -123058,6 +123508,9 @@ async function runHeadlessRuntime(options) {
123058
123508
  }
123059
123509
  await clearOwnState();
123060
123510
  };
123511
+ const leaveRuntime = async () => {
123512
+ if (engine.active) await engine.stop({ skipRemote: true, reason: "agent_cli:hangup" });
123513
+ };
123061
123514
  const releaseFailedStart = async (kind) => {
123062
123515
  if (kind === "explicit" && engine.active) {
123063
123516
  await stopRuntime("agent_cli:start_failed").catch(() => void 0);
@@ -123359,7 +123812,7 @@ async function runHeadlessRuntime(options) {
123359
123812
  unsubscribeState();
123360
123813
  options.signal?.removeEventListener("abort", stop);
123361
123814
  if (options.stopOnSignals !== false) {
123362
- for (const signalName of signalNames) process.removeListener(signalName, stop);
123815
+ for (const [signalName, handler] of signalHandlers) process.removeListener(signalName, handler);
123363
123816
  }
123364
123817
  }
123365
123818
  }
@@ -123382,6 +123835,7 @@ var init_headless_runtime = __esm({
123382
123835
  init_engine();
123383
123836
  init_server_runtime_lease();
123384
123837
  init_reconcile();
123838
+ init_stop_signals();
123385
123839
  init_local_ai_preflight();
123386
123840
  HeadlessRuntimeTakeoverRequiredError = class extends Error {
123387
123841
  constructor(response) {