@vtxmacro/cli 2026.10.55 → 2026.10.57

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
@@ -122,7 +122,7 @@ var init_routing = __esm({
122
122
  var agent_cli_release_default;
123
123
  var init_agent_cli_release = __esm({
124
124
  "agent-cli-release.json"() {
125
- agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.55", 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" } } };
125
+ agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.57", 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" } } };
126
126
  }
127
127
  });
128
128
 
@@ -1518,6 +1518,11 @@ var init_runtime_policy_generated = __esm({
1518
1518
  min_query_length: 2
1519
1519
  }
1520
1520
  },
1521
+ insights: {
1522
+ privileged_admin_settings: {
1523
+ access_token_ttl_seconds: 900
1524
+ }
1525
+ },
1521
1526
  referrals: {
1522
1527
  code_max_length: 24,
1523
1528
  dashboard_default_limit: 20
@@ -3082,7 +3087,7 @@ var init_shared_contracts_generated = __esm({
3082
3087
  });
3083
3088
 
3084
3089
  // lib/constants.ts
3085
- 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, READ_STAMP_TIE_MS, READ_STAMP_STEP_BACK_MS, CLOCK_FIELD_DIGITS, BACKOFF_GROWTH_FACTOR, BYTES_PER_KIB, BYTES_PER_MIB, BITS_PER_BYTE, BYTE_MASK, OWNER_ONLY_FILE_MODE, OWNER_ONLY_DIRECTORY_MODE, GROUP_OTHER_PERMISSION_BITS, DECIMAL_RADIX, HEX_RADIX, BASE36_RADIX, BYTE_HEX_DIGITS, UINT32_HEX_DIGITS, RANDOM_FRACTION_PREFIX_LENGTH, PERCENT_SCALE, MIDPOINT_DIVISOR, FNV1A_32_OFFSET_BASIS, FNV1A_32_PRIME, JSON_INDENT_SPACES, INT32_MIN, INT32_MAX, SET_TIMEOUT_MAX_DELAY_MS, FLOAT_EQUALITY_EPSILON, POSITION_SIZE_EPSILON, HTTP_STATUS, HTTP_STATUS_MIN, HTTP_STATUS_MAX, HTTP_CLIENT_ERROR_MIN, HTTP_SERVER_ERROR_MIN, PROMPT_RESCUE_ASKS_PER_CYCLE_BUILD, AI_COST_ESTIMATE_PERIOD_DAYS, SECONDS_PER_AI_COST_ESTIMATE_PERIOD, DATE_FIELD_DIGITS, NODE_ARGV_COMMAND_ARGS_START, EXIT_CODE_TEMPFAIL, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, SHA256, UINT64_HIGH_WORD_DIVISOR, CANONICAL_BASE64URL, INFERENCE_ENVELOPE_CRYPTO, JSON_RPC_ERROR_CODES, INFERENCE_MCP_SCHEMA_PROBE_MAX_DEPTH, INFERENCE_HOST_PROCESS_LOCK_RECORD_SCHEMA_VERSION, NATIVE_PROTECTION_RECORD_WITH_LOTS_VERSION, INFERENCE_HOST_RECLAIM_GUARD_CREATE_PASSES, LINUX_PROC_STAT_COMM_TERMINATOR_CHARS, INFERENCE_HOST_RANDOM_BYTES, INFERENCE_OAUTH_TOKEN_MAX_LENGTH, INFERENCE_CREDENTIAL_WINDOWS_NOT_FOUND_EXIT_CODE, MACOS_SECURITY_ITEM_NOT_FOUND_EXIT_CODE, INFERENCE_CREDENTIAL_LABEL_ACCOUNT_KEY_CHARS, INFERENCE_HOST_STABLE_OPERATION_ID_HASH_CHARS, INFERENCE_HOST_DRAIN_PRIORITY, INFERENCE_JOB_CLAIM_SCHEMA_VERSION, INFERENCE_HOST_WINDOWS_TASK_IDENTITY_MAX_CHARS, INFERENCE_HOST_OWNER_ONLY_EXECUTABLE_MODE, WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE, INFERENCE_HOST_CLI_MAX_SERVICE_POSITIONALS, INFERENCE_HOST_CLI_MAX_COMMAND_POSITIONALS, INFERENCE_HOST_DISPLAY_NAME_MAX_CHARS, INFERENCE_HOST_REVOCATION_CHECKPOINT_MAX_CHARS, INFERENCE_HOST_MODEL_ID_MAX_CHARS, CODEX_RECOVERY_RECEIPT_MAX_CHARS, CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS, CODEX_GUARDIAN_PROCESS_TOKEN_BYTES, CODEX_RATE_LIMIT_EXHAUSTED_PERCENT, INFERENCE_HOST_PROXY_TOKEN_BYTES, AGENT_TOOL_SERVER_TOKEN_BYTES, GROK_NATIVE_SESSION_GROUP_NAME_MAX_CHARS, GROK_POLICY_TRANSPORT_MAX_BYTES, EXO_POLICY_MAX_TOOL_ROUNDS, EXO_POLICY_MAX_MODELS, EXO_POLICY_MODEL_NAME_MAX_CHARS, CLAUDE_CODE_POLICY_MAX_MODELS, CLAUDE_CODE_POLICY_MODEL_NAME_MAX_CHARS, CLAUDE_CODE_POLICY_MAX_TURNS, ANTHROPIC_SCHEMA_PROPERTY_NAME_MAX_CHARS, EXO_RUNTIME_VERSION_COMMIT_CHARS, PI_QUALIFIED_MODEL_ID_MAX_CHARS, PI_STRUCTURED_OUTPUT_MAX_DEPTH, PI_STRUCTURED_OUTPUT_MAX_PROPERTIES, INFERENCE_HOST_API_KEY_MIN_CHARS, INFERENCE_HOST_API_KEY_MAX_BYTES, INFERENCE_HOST_API_KEY_IDENTITY_HEX_CHARS, DEEPSEEK_HARNESS_NODE_LTS_MAJOR, DEEPSEEK_HARNESS_NODE_LTS_MIN_MINOR, DEEPSEEK_HARNESS_NODE_CURRENT_MAJOR, PROMPT_FIXED_DIGITS, PROMPT_SIGNIFICANT_DIGITS, PROMPT_NUMBER_MAX_DIGITS, PROMPT_RELATIVE_VOLUME_DIGITS, BINARY_RADIX, PROMPT_PRICE_INTEGER_THRESHOLD, PROMPT_MARGIN_UTILIZATION_DECIMALS, PROMPT_SYMBOL_MAX_CHARS, PROMPT_PARTIAL_UNIT_ROUND_UP_FRACTION, HALF_UP_ROUNDING_OFFSET, PROMPT_ENTRY_PRICE_MATCH_ABS_TOLERANCE, PROMPT_ENTRY_PRICE_MATCH_REL_TOLERANCE, DECISION_OUTPUT_EXAMPLE_TRADABILITY, IEEE754_MANTISSA_BITS, IEEE754_EXPONENT_BIAS, IEEE754_EXPONENT_MASK, IEEE754_HIGH_MANTISSA_MASK, IEEE754_HIGH_WORD_EXPONENT_SHIFT, IEEE754_SIGN_BIT_SHIFT, UINT32_RANGE, PYTHON_SQRT_BIT_WIDTH, PYTHON_REPR_EXPONENT_MIN_DECPT, PYTHON_REPR_EXPONENT_MAX_DECPT, PYTHON_REPR_MIN_EXPONENT_DIGITS, TO_FIXED_MAX_MAGNITUDE, UNICODE_DEFAULT_IGNORABLE_RANGES_OUTSIDE_CATEGORIES, CALENDAR_FIELD_MAX_CHARS, INDICATOR_RSI_PERIOD, INDICATOR_ATR_PERIOD, INDICATOR_MACD_FAST_PERIOD, INDICATOR_MACD_SLOW_PERIOD, INDICATOR_MACD_SIGNAL_PERIOD, INDICATOR_BOLLINGER_PERIOD, INDICATOR_BOLLINGER_STD_DEV, INDICATOR_OSCILLATOR_MAX, PROMPT_METRIC_DECIMALS, CENT_DECIMALS, REGIME_ADX_CHOP_DECIMALS, FILL_SIZE_MATCH_TOLERANCE, PERFORMANCE_HOLD_MINUTES_DECIMALS, SERIES_CHANGE_MIN_POINTS, INDICATOR_ADX_PERIOD, INDICATOR_CHOP_PERIOD, ADX_WARMUP_PERIODS, WINDOW_FEATURES_MIN_CANDLES, WINDOW_FEATURES_PIVOT_NEIGHBOR_DISTANCE, FRACTAL_SIDES, REGRESSION_MIN_POINTS, SAMPLE_STDEV_MIN_POINTS, WINDOW_FEATURES_SLOPE_DECIMALS, WINDOW_FEATURES_R_SQUARED_DECIMALS, WINDOW_FEATURES_Z_SCORE_DECIMALS, WINDOW_FEATURES_GREEN_RATIO_DECIMALS, WINDOW_FEATURES_ATR_PERCENT_DECIMALS, EMA_SMOOTHING_NUMERATOR, PROMPT_EMA_PERIODS, JSON_UNICODE_ESCAPE_PREFIX_LENGTH, JSON_UNICODE_ESCAPE_HEX_DIGITS, ASCII_FIRST_PRINTABLE_CODE, ASCII_LAST_PRINTABLE_CODE, JSON_CONTROL_CHARACTER_MAX, RUNTIME_DEBUG_SNIPPET_CHARS, RUNTIME_DEBUG_PROMPT_SNIPPET_CHARS, RUNTIME_DEBUG_TOKEN_PREFIX_CHARS, RUNTIME_DEBUG_USD_DECIMALS, RUNTIME_LATENCY_SECONDS_DECIMALS, AI_SCHEDULE_CLOCK_PARTS, ESTIMATED_CHARS_PER_TOKEN, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS, AI_CALL_COST_DECIMALS, PROVIDER_DIAGNOSTIC_LIMITS, AI_INVOCATION_CONTRACT_VERSION, AI_INVOCATION_TELEMETRY_LIMITS, PROVIDER_USAGE_DETAIL_LIMITS, HYPERLIQUID_TIF_GTC, HYPERLIQUID_TPSL_BATCH_MIN_ORDERS, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, HYPERLIQUID_CANDLE_SNAPSHOT_BASE_WEIGHT, HYPERLIQUID_CANDLE_SNAPSHOT_ROWS_PER_WEIGHT, HYPERLIQUID_CANDLE_SNAPSHOT_MAX_ROWS, HYPERLIQUID_ROW_WEIGHTED_INFO_REQUESTS, HYPERLIQUID_ROW_WEIGHTED_INFO_BASE_WEIGHT, HYPERLIQUID_INFO_ROWS_PER_EXTRA_WEIGHT, HYPERLIQUID_PUBLIC_READ_WINDOWS_KEPT, CLIENT_RUNTIME_NOTE_GAP_MAX_LOOPS, HYPERLIQUID_META_AND_ASSET_CTXS_PARTS, HYPERLIQUID_SIDE_PAIR_LENGTH, HYPERLIQUID_SIGNED_SIZE_MATCH_EXTRA_DECIMALS, HYPERLIQUID_OPEN_ORDERS_MAX_NESTING_DEPTH, ACCOUNT_PAYLOAD_MODE_SEARCH_MAX_DEPTH, HYPERLIQUID_ACCOUNT_ROUNDING_DECIMALS, HYPERLIQUID_UNREALIZED_PNL_ZERO_TOLERANCE, HYPERLIQUID_MAX_DEPLOYER_FEE_SCALE, HYPERLIQUID_DEPLOYER_FEE_SCALE_MULTIPLIER, HYPERLIQUID_GROWTH_MODE_FEE_FACTOR, HYPERLIQUID_ALIGNED_QUOTE_NON_DEPLOYER_FEE_FACTOR, HYPERLIQUID_CLOSE_SIZE_RELATIVE_TOLERANCE, HYPERLIQUID_POSITION_SIZE_MATCH_ABS_TOLERANCE, HYPERLIQUID_POSITION_SIZE_MATCH_RELATIVE_TOLERANCE, HYPERLIQUID_LOT_FLOOR_NOISE_DECIMALS, HYPERLIQUID_RECOVERY_BACKOFF_MAX_EXPONENT, HYPERLIQUID_RECOVERY_CONCURRENCY_GROWTH_FACTOR, UUID_BYTES, UUID_HEX_GROUP_ENDS, MSGPACK, CLIENT_RUNTIME_PROVIDER_ATTEMPT_SUMMARY_MAX_CHARS, CLIENT_RUNTIME_HL_REQUEST_TYPE_MAX_CHARS, CLIENT_RUNTIME_DRAWDOWN_DEBUG_DECIMALS, CLIENT_PROTECTIVE_GROUP_VERSION, CLIENT_PROTECTIVE_TPSL_PAIR_LEGS, CLIENT_PROTECTIVE_FILL_MATCH_ABS_TOLERANCE, CLIENT_PROTECTIVE_FILL_MATCH_REL_TOLERANCE, CLIENT_CLOSE_FILL_EPSILON_ULPS, COPY_TRADING_SIZE_EPSILON, COPY_TRADING_RELATIVE_SIZE_TOLERANCE, COPY_TRADING_NOTIONAL_CAP_TOLERANCE_USD, CLIENT_ACCOUNT_PNL_NONZERO_MIN_USD, RUNTIME_PORTFOLIO_PERIOD_ENTRY_LENGTH, CLIENT_EXCHANGE_RECONCILIATION_MAX_DELAY_MS, RFC1918_172_BLOCK_SECOND_OCTET, AGENT_CLI_TAKEOVER_REQUIRED_EXIT_CODE, EXIT_CODE_INTERRUPTED, EXIT_CODE_SIGNAL_BASE, AI_SNAPSHOT_COMPACT_TRANSPORT_VERSION, CLIENT_PROTECTION_CAPABILITY_VERSION, AI_SNAPSHOT_PACKED_FIELDS, AI_SNAPSHOT_PACKED_ENTRY_FIELDS, TOKENS_PER_MILLION, RENDER_DEBUG_ID_RANDOM_CHARS;
3090
+ 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, READ_STAMP_TIE_MS, READ_STAMP_STEP_BACK_MS, CLOCK_FIELD_DIGITS, BACKOFF_GROWTH_FACTOR, BYTES_PER_KIB, BYTES_PER_MIB, BITS_PER_BYTE, BYTE_MASK, OWNER_ONLY_FILE_MODE, OWNER_ONLY_DIRECTORY_MODE, GROUP_OTHER_PERMISSION_BITS, DECIMAL_RADIX, HEX_RADIX, BASE36_RADIX, BYTE_HEX_DIGITS, UINT32_HEX_DIGITS, RANDOM_FRACTION_PREFIX_LENGTH, PERCENT_SCALE, MIDPOINT_DIVISOR, FNV1A_32_OFFSET_BASIS, FNV1A_32_PRIME, JSON_INDENT_SPACES, INT32_MIN, INT32_MAX, SET_TIMEOUT_MAX_DELAY_MS, FLOAT_EQUALITY_EPSILON, POSITION_SIZE_EPSILON, HTTP_STATUS, HTTP_STATUS_MIN, HTTP_STATUS_MAX, HTTP_CLIENT_ERROR_MIN, HTTP_SERVER_ERROR_MIN, PROMPT_RESCUE_ASKS_PER_CYCLE_BUILD, AI_COST_ESTIMATE_PERIOD_DAYS, SECONDS_PER_AI_COST_ESTIMATE_PERIOD, DATE_FIELD_DIGITS, NODE_ARGV_COMMAND_ARGS_START, EXIT_CODE_TEMPFAIL, SHA256_INITIAL_STATE, SHA256_ROUND_CONSTANTS, SHA256, UINT64_HIGH_WORD_DIVISOR, CANONICAL_BASE64URL, INFERENCE_ENVELOPE_CRYPTO, JSON_RPC_ERROR_CODES, INFERENCE_MCP_SCHEMA_PROBE_MAX_DEPTH, INFERENCE_HOST_PROCESS_LOCK_RECORD_SCHEMA_VERSION, NATIVE_PROTECTION_RECORD_WITH_LOTS_VERSION, INFERENCE_HOST_RECLAIM_GUARD_CREATE_PASSES, LINUX_PROC_STAT_COMM_TERMINATOR_CHARS, INFERENCE_HOST_RANDOM_BYTES, INFERENCE_OAUTH_TOKEN_MAX_LENGTH, INFERENCE_CREDENTIAL_WINDOWS_NOT_FOUND_EXIT_CODE, MACOS_SECURITY_ITEM_NOT_FOUND_EXIT_CODE, INFERENCE_CREDENTIAL_LABEL_ACCOUNT_KEY_CHARS, INFERENCE_HOST_STABLE_OPERATION_ID_HASH_CHARS, INFERENCE_HOST_DRAIN_PRIORITY, INFERENCE_JOB_CLAIM_SCHEMA_VERSION, INFERENCE_HOST_WINDOWS_TASK_IDENTITY_MAX_CHARS, INFERENCE_HOST_OWNER_ONLY_EXECUTABLE_MODE, WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE, INFERENCE_HOST_CLI_MAX_SERVICE_POSITIONALS, INFERENCE_HOST_CLI_MAX_COMMAND_POSITIONALS, INFERENCE_HOST_DISPLAY_NAME_MAX_CHARS, INFERENCE_HOST_REVOCATION_CHECKPOINT_MAX_CHARS, INFERENCE_HOST_MODEL_ID_MAX_CHARS, CODEX_RECOVERY_RECEIPT_MAX_CHARS, CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS, CODEX_GUARDIAN_PROCESS_TOKEN_BYTES, CODEX_RATE_LIMIT_EXHAUSTED_PERCENT, INFERENCE_HOST_PROXY_TOKEN_BYTES, AGENT_TOOL_SERVER_TOKEN_BYTES, GROK_NATIVE_SESSION_GROUP_NAME_MAX_CHARS, GROK_POLICY_TRANSPORT_MAX_BYTES, EXO_POLICY_MAX_TOOL_ROUNDS, EXO_POLICY_MAX_MODELS, EXO_POLICY_MODEL_NAME_MAX_CHARS, CLAUDE_CODE_POLICY_MAX_MODELS, CLAUDE_CODE_POLICY_MODEL_NAME_MAX_CHARS, CLAUDE_CODE_POLICY_MAX_TURNS, ANTHROPIC_SCHEMA_PROPERTY_NAME_MAX_CHARS, EXO_RUNTIME_VERSION_COMMIT_CHARS, PI_QUALIFIED_MODEL_ID_MAX_CHARS, PI_STRUCTURED_OUTPUT_MAX_DEPTH, PI_STRUCTURED_OUTPUT_MAX_PROPERTIES, INFERENCE_HOST_API_KEY_MIN_CHARS, INFERENCE_HOST_API_KEY_MAX_BYTES, INFERENCE_HOST_API_KEY_IDENTITY_HEX_CHARS, DEEPSEEK_HARNESS_NODE_LTS_MAJOR, DEEPSEEK_HARNESS_NODE_LTS_MIN_MINOR, DEEPSEEK_HARNESS_NODE_CURRENT_MAJOR, PROMPT_FIXED_DIGITS, PROMPT_SIGNIFICANT_DIGITS, PROMPT_NUMBER_MAX_DIGITS, PROMPT_RELATIVE_VOLUME_DIGITS, BINARY_RADIX, PROMPT_PRICE_INTEGER_THRESHOLD, PROMPT_MARGIN_UTILIZATION_DECIMALS, PROMPT_SYMBOL_MAX_CHARS, HALF_UP_ROUNDING_OFFSET, PROMPT_ENTRY_PRICE_MATCH_ABS_TOLERANCE, PROMPT_ENTRY_PRICE_MATCH_REL_TOLERANCE, DECISION_OUTPUT_EXAMPLE_TRADABILITY, IEEE754_MANTISSA_BITS, IEEE754_EXPONENT_BIAS, IEEE754_EXPONENT_MASK, IEEE754_HIGH_MANTISSA_MASK, IEEE754_HIGH_WORD_EXPONENT_SHIFT, IEEE754_SIGN_BIT_SHIFT, UINT32_RANGE, PYTHON_SQRT_BIT_WIDTH, PYTHON_REPR_EXPONENT_MIN_DECPT, PYTHON_REPR_EXPONENT_MAX_DECPT, PYTHON_REPR_MIN_EXPONENT_DIGITS, TO_FIXED_MAX_MAGNITUDE, UNICODE_DEFAULT_IGNORABLE_RANGES_OUTSIDE_CATEGORIES, CALENDAR_FIELD_MAX_CHARS, INDICATOR_RSI_PERIOD, INDICATOR_ATR_PERIOD, INDICATOR_MACD_FAST_PERIOD, INDICATOR_MACD_SLOW_PERIOD, INDICATOR_MACD_SIGNAL_PERIOD, INDICATOR_BOLLINGER_PERIOD, INDICATOR_BOLLINGER_STD_DEV, INDICATOR_OSCILLATOR_MAX, PROMPT_METRIC_DECIMALS, CENT_DECIMALS, REGIME_ADX_CHOP_DECIMALS, FILL_SIZE_MATCH_TOLERANCE, PERFORMANCE_HOLD_MINUTES_DECIMALS, SERIES_CHANGE_MIN_POINTS, INDICATOR_ADX_PERIOD, INDICATOR_CHOP_PERIOD, ADX_WARMUP_PERIODS, WINDOW_FEATURES_MIN_CANDLES, WINDOW_FEATURES_PIVOT_NEIGHBOR_DISTANCE, FRACTAL_SIDES, REGRESSION_MIN_POINTS, SAMPLE_STDEV_MIN_POINTS, WINDOW_FEATURES_SLOPE_DECIMALS, WINDOW_FEATURES_R_SQUARED_DECIMALS, WINDOW_FEATURES_Z_SCORE_DECIMALS, WINDOW_FEATURES_GREEN_RATIO_DECIMALS, WINDOW_FEATURES_ATR_PERCENT_DECIMALS, EMA_SMOOTHING_NUMERATOR, PROMPT_EMA_PERIODS, JSON_UNICODE_ESCAPE_PREFIX_LENGTH, JSON_UNICODE_ESCAPE_HEX_DIGITS, ASCII_FIRST_PRINTABLE_CODE, ASCII_LAST_PRINTABLE_CODE, JSON_CONTROL_CHARACTER_MAX, RUNTIME_DEBUG_SNIPPET_CHARS, RUNTIME_DEBUG_PROMPT_SNIPPET_CHARS, RUNTIME_DEBUG_TOKEN_PREFIX_CHARS, RUNTIME_DEBUG_USD_DECIMALS, RUNTIME_LATENCY_SECONDS_DECIMALS, AI_SCHEDULE_CLOCK_PARTS, ESTIMATED_CHARS_PER_TOKEN, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS, AI_CALL_COST_DECIMALS, PROVIDER_DIAGNOSTIC_LIMITS, AI_INVOCATION_CONTRACT_VERSION, AI_INVOCATION_TELEMETRY_LIMITS, PROVIDER_USAGE_DETAIL_LIMITS, HYPERLIQUID_TIF_GTC, HYPERLIQUID_TPSL_BATCH_MIN_ORDERS, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, HYPERLIQUID_CANDLE_SNAPSHOT_BASE_WEIGHT, HYPERLIQUID_CANDLE_SNAPSHOT_ROWS_PER_WEIGHT, HYPERLIQUID_CANDLE_SNAPSHOT_MAX_ROWS, HYPERLIQUID_ROW_WEIGHTED_INFO_REQUESTS, HYPERLIQUID_ROW_WEIGHTED_INFO_BASE_WEIGHT, HYPERLIQUID_INFO_ROWS_PER_EXTRA_WEIGHT, HYPERLIQUID_PUBLIC_READ_WINDOWS_KEPT, CLIENT_RUNTIME_NOTE_GAP_MAX_LOOPS, HYPERLIQUID_META_AND_ASSET_CTXS_PARTS, HYPERLIQUID_SIDE_PAIR_LENGTH, HYPERLIQUID_SIGNED_SIZE_MATCH_EXTRA_DECIMALS, HYPERLIQUID_OPEN_ORDERS_MAX_NESTING_DEPTH, ACCOUNT_PAYLOAD_MODE_SEARCH_MAX_DEPTH, HYPERLIQUID_ACCOUNT_ROUNDING_DECIMALS, HYPERLIQUID_UNREALIZED_PNL_ZERO_TOLERANCE, HYPERLIQUID_MAX_DEPLOYER_FEE_SCALE, HYPERLIQUID_DEPLOYER_FEE_SCALE_MULTIPLIER, HYPERLIQUID_GROWTH_MODE_FEE_FACTOR, HYPERLIQUID_ALIGNED_QUOTE_NON_DEPLOYER_FEE_FACTOR, HYPERLIQUID_CLOSE_SIZE_RELATIVE_TOLERANCE, HYPERLIQUID_POSITION_SIZE_MATCH_ABS_TOLERANCE, HYPERLIQUID_POSITION_SIZE_MATCH_RELATIVE_TOLERANCE, HYPERLIQUID_LOT_FLOOR_NOISE_DECIMALS, HYPERLIQUID_RECOVERY_BACKOFF_MAX_EXPONENT, HYPERLIQUID_RECOVERY_CONCURRENCY_GROWTH_FACTOR, UUID_BYTES, UUID_HEX_GROUP_ENDS, MSGPACK, CLIENT_RUNTIME_PROVIDER_ATTEMPT_SUMMARY_MAX_CHARS, CLIENT_RUNTIME_HL_REQUEST_TYPE_MAX_CHARS, CLIENT_RUNTIME_DRAWDOWN_DEBUG_DECIMALS, CLIENT_PROTECTIVE_GROUP_VERSION, CLIENT_PROTECTIVE_TPSL_PAIR_LEGS, CLIENT_PROTECTIVE_FILL_MATCH_ABS_TOLERANCE, CLIENT_PROTECTIVE_FILL_MATCH_REL_TOLERANCE, CLIENT_CLOSE_FILL_EPSILON_ULPS, COPY_TRADING_SIZE_EPSILON, COPY_TRADING_RELATIVE_SIZE_TOLERANCE, COPY_TRADING_NOTIONAL_CAP_TOLERANCE_USD, CLIENT_ACCOUNT_PNL_NONZERO_MIN_USD, RUNTIME_PORTFOLIO_PERIOD_ENTRY_LENGTH, CLIENT_EXCHANGE_RECONCILIATION_MAX_DELAY_MS, RFC1918_172_BLOCK_SECOND_OCTET, AGENT_CLI_TAKEOVER_REQUIRED_EXIT_CODE, EXIT_CODE_INTERRUPTED, EXIT_CODE_SIGNAL_BASE, AI_SNAPSHOT_COMPACT_TRANSPORT_VERSION, CLIENT_PROTECTION_CAPABILITY_VERSION, AI_SNAPSHOT_PACKED_FIELDS, AI_SNAPSHOT_PACKED_ENTRY_FIELDS, TOKENS_PER_MILLION, RENDER_DEBUG_ID_RANDOM_CHARS;
3086
3091
  var init_constants = __esm({
3087
3092
  "lib/constants.ts"() {
3088
3093
  "use strict";
@@ -3383,7 +3388,6 @@ var init_constants = __esm({
3383
3388
  PROMPT_PRICE_INTEGER_THRESHOLD = 1e5;
3384
3389
  PROMPT_MARGIN_UTILIZATION_DECIMALS = 1;
3385
3390
  PROMPT_SYMBOL_MAX_CHARS = 100;
3386
- PROMPT_PARTIAL_UNIT_ROUND_UP_FRACTION = 0.5;
3387
3391
  HALF_UP_ROUNDING_OFFSET = 0.5;
3388
3392
  PROMPT_ENTRY_PRICE_MATCH_ABS_TOLERANCE = 1e-8;
3389
3393
  PROMPT_ENTRY_PRICE_MATCH_REL_TOLERANCE = 1e-6;
@@ -4907,15 +4911,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
4907
4911
  const probes = {
4908
4912
  currentBootIdentity: dependencies.currentBootIdentity ?? (() => readInferenceSystemBootIdentity()),
4909
4913
  observeIdentity: dependencies.processIdentity ?? defaultProcessIdentity,
4910
- isProcessAlive: dependencies.processAlive ?? ((pid) => {
4911
- try {
4912
- process.kill(pid, 0);
4913
- return true;
4914
- } catch (error48) {
4915
- if (error48.code === "ESRCH") return false;
4916
- throw error48;
4917
- }
4918
- })
4914
+ isProcessAlive: dependencies.processAlive ?? processExists
4919
4915
  };
4920
4916
  const [ownerIdentity, bootIdentity] = await Promise.all([
4921
4917
  (dependencies.currentProcessIdentity ?? defaultCurrentProcessIdentity)(),
@@ -4987,7 +4983,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
4987
4983
  }
4988
4984
  };
4989
4985
  }
4990
- var HOST_CORE_POLICY, loadInferenceReceiptDurabilityTimeoutMs, loadInferenceAgentDataRequestTimeoutMs, loadInferenceAgentCommandLockPolicy, InferenceHostProcessLockBusyError, INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, WINDOWS_PRIVATE_ACL_MODES, WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS, WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS, SMALL_IDENTITY_COMMAND_TIMEOUT_MS, windowsPowerShellEnvironment, windowsPrivateAclBrokerInvocation, WindowsPrivateAclBroker, defaultWindowsPrivateAclBroker, runWindowsPrivateAcl, windowsAclCache, windowsAclIdentity, aclCacheKey, secureWindowsPrivatePath, invalidateWindowsAclCache, rebindHardenedWindowsAclAfterRename, rebindHardenedWindowsDirectoryAfterOwnedMutation, isWindowsPrivateAclVerificationFailure, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentityInvocation, windowsBootIdentityInvocation, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, cachedCurrentProcessIdentity, defaultCurrentProcessIdentity, readInferenceHostProcessLockStatus, processLockObservationCache, inferenceProcessIdentitiesMatch, resolveInferenceHostApiUrl, inferenceHostSupervisorServiceManifestPath, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig, WINDOWS_PRIVATE_FILE_REPLACE_ERROR_CODES, PROCESS_LOCK_PUBLICATION_GRACE_MS, PROCESS_LOCK_MAX_RECORD_BYTES, PROCESS_LOCK_GUARD_ELECTION_LEASE_MS, PROCESS_LOCK_GUARD_ELECTION_STALE_MS, PROCESS_LOCK_GUARD_ELECTION_ATTEMPTS, PROCESS_LOCK_GUARD_ELECTION_BACKOFF_MS, PROCESS_LOCK_LABEL, PROCESS_LOCK_GUARD_LABEL, sameProcessLockFile, openExclusiveProcessLockFile, inspectProcessLockFile, removeVerifiedStaleProcessLockFile, removeStaleProcessLockReclaimGuard, acquireProcessLockReclaimGuard;
4986
+ var HOST_CORE_POLICY, loadInferenceReceiptDurabilityTimeoutMs, loadInferenceAgentDataRequestTimeoutMs, loadInferenceAgentCommandLockPolicy, InferenceHostProcessLockBusyError, INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, WINDOWS_PRIVATE_ACL_MODES, WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS, WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS, SMALL_IDENTITY_COMMAND_TIMEOUT_MS, windowsPowerShellEnvironment, windowsPrivateAclBrokerInvocation, WindowsPrivateAclBroker, defaultWindowsPrivateAclBroker, runWindowsPrivateAcl, windowsAclCache, windowsAclIdentity, aclCacheKey, secureWindowsPrivatePath, invalidateWindowsAclCache, rebindHardenedWindowsAclAfterRename, rebindHardenedWindowsDirectoryAfterOwnedMutation, isWindowsPrivateAclVerificationFailure, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentityInvocation, windowsBootIdentityInvocation, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, cachedCurrentProcessIdentity, defaultCurrentProcessIdentity, processExists, readInferenceHostProcessLockStatus, processLockObservationCache, inferenceProcessIdentitiesMatch, resolveInferenceHostApiUrl, inferenceHostSupervisorServiceManifestPath, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig, WINDOWS_PRIVATE_FILE_REPLACE_ERROR_CODES, PROCESS_LOCK_PUBLICATION_GRACE_MS, PROCESS_LOCK_MAX_RECORD_BYTES, PROCESS_LOCK_GUARD_ELECTION_LEASE_MS, PROCESS_LOCK_GUARD_ELECTION_STALE_MS, PROCESS_LOCK_GUARD_ELECTION_ATTEMPTS, PROCESS_LOCK_GUARD_ELECTION_BACKOFF_MS, PROCESS_LOCK_LABEL, PROCESS_LOCK_GUARD_LABEL, sameProcessLockFile, openExclusiveProcessLockFile, inspectProcessLockFile, removeVerifiedStaleProcessLockFile, removeStaleProcessLockReclaimGuard, acquireProcessLockReclaimGuard;
4991
4987
  var init_config2 = __esm({
4992
4988
  "lib/inference-host/config.ts"() {
4993
4989
  "use strict";
@@ -5605,6 +5601,15 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
5605
5601
  throw error48;
5606
5602
  }
5607
5603
  };
5604
+ processExists = (pid) => {
5605
+ try {
5606
+ process.kill(pid, 0);
5607
+ return true;
5608
+ } catch (error48) {
5609
+ if (error48.code === "ESRCH") return false;
5610
+ throw error48;
5611
+ }
5612
+ };
5608
5613
  readInferenceHostProcessLockStatus = async (path) => {
5609
5614
  const raw = await readInferencePrivateFile(path, "Inference host process lock");
5610
5615
  if (raw === null) return { state: "not_running" };
@@ -5618,7 +5623,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
5618
5623
  readInferenceSystemBootIdentity()
5619
5624
  ]);
5620
5625
  if (boot !== owner2.boot_identity) return { state: "stale" };
5621
- if (identity3 === null) return { state: "unknown" };
5626
+ if (identity3 === null) return { state: processExists(owner2.pid) ? "unknown" : "stale" };
5622
5627
  return { state: identity3 === owner2.process_identity ? "running" : "stale" };
5623
5628
  } catch {
5624
5629
  return { state: "unknown" };
@@ -5736,6 +5741,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
5736
5741
  const cached2 = processLockObservationCache.get(cacheKey);
5737
5742
  const observedIdentity = cached2 && cached2.dev === stat2.dev && cached2.ino === stat2.ino && cached2.pid === ownerPid && cached2.storedIdentity === storedIdentity && Date.now() - cached2.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached2.observedIdentity : await probes.observeIdentity(ownerPid);
5738
5743
  if (!observedIdentity) {
5744
+ if (!probes.isProcessAlive(ownerPid)) {
5745
+ stale = true;
5746
+ return { state: "stale", handle, stat: stat2 };
5747
+ }
5739
5748
  throw new Error("Inference host could not verify the existing lock owner identity.");
5740
5749
  }
5741
5750
  processLockObservationCache.set(cacheKey, {
@@ -23157,6 +23166,11 @@ var init_runtime_policy_generated2 = __esm({
23157
23166
  min_query_length: 2
23158
23167
  }
23159
23168
  },
23169
+ insights: {
23170
+ privileged_admin_settings: {
23171
+ access_token_ttl_seconds: 900
23172
+ }
23173
+ },
23160
23174
  referrals: {
23161
23175
  code_max_length: 24,
23162
23176
  dashboard_default_limit: 20
@@ -44354,7 +44368,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
44354
44368
  }
44355
44369
  }
44356
44370
  if ((options.platform ?? process.platform) !== "win32") {
44357
- const processExists = options.processExists ?? ((pid) => {
44371
+ const processExists2 = options.processExists ?? ((pid) => {
44358
44372
  try {
44359
44373
  process.kill(pid, 0);
44360
44374
  return true;
@@ -44362,7 +44376,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
44362
44376
  return error48.code !== "ESRCH";
44363
44377
  }
44364
44378
  });
44365
- if ([...pids].some((pid) => processExists(pid)) || processExists(-options.guardianPid)) {
44379
+ if ([...pids].some((pid) => processExists2(pid)) || processExists2(-options.guardianPid)) {
44366
44380
  throw new Error("Codex guardian process tree is still running; recovery evidence was preserved.");
44367
44381
  }
44368
44382
  return;
@@ -50687,7 +50701,7 @@ var init_durable_adapter = __esm({
50687
50701
  // lib/inference-host/service-launcher-state.ts
50688
50702
  import { access as access6, readFile as readFile12, rm as rm15 } from "node:fs/promises";
50689
50703
  import { dirname as dirname16, isAbsolute as isAbsolute7, join as join17, relative as relative4, resolve as resolve13 } from "node:path";
50690
- var launcherSibling, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
50704
+ var launcherSibling, launcherLockPath, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
50691
50705
  var init_service_launcher_state = __esm({
50692
50706
  "lib/inference-host/service-launcher-state.ts"() {
50693
50707
  "use strict";
@@ -50700,6 +50714,7 @@ var init_service_launcher_state = __esm({
50700
50714
  if (!manifest.endsWith(".service.json")) throw new Error("Invalid service manifest path.");
50701
50715
  return `${manifest.slice(0, -".service.json".length)}${suffix}`;
50702
50716
  };
50717
+ launcherLockPath = (manifest) => launcherSibling(manifest, ".service-launcher.lock");
50703
50718
  within = (parent, child) => {
50704
50719
  const part = relative4(resolve13(parent), resolve13(child));
50705
50720
  return Boolean(part) && !part.startsWith("..") && !isAbsolute7(part);
@@ -50762,7 +50777,7 @@ import { homedir as homedir4 } from "node:os";
50762
50777
  import { dirname as dirname17, join as join18, resolve as resolve14 } from "node:path";
50763
50778
  import { Transform } from "node:stream";
50764
50779
  import { pipeline } from "node:stream/promises";
50765
- var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, ATOMIC_REPLACEMENT_READ_ATTEMPTS, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRotatedLogPath, 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, serviceLogSinks, serviceLogSize, rotateServiceLog, writeServiceLog, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
50780
+ var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, ATOMIC_REPLACEMENT_READ_ATTEMPTS, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, lockStillHeld, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRotatedLogPath, 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, serviceLogSinks, serviceLogSize, rotateServiceLog, writeServiceLog, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
50766
50781
  var init_service = __esm({
50767
50782
  "lib/inference-host/service.ts"() {
50768
50783
  "use strict";
@@ -50784,6 +50799,7 @@ var init_service = __esm({
50784
50799
  ATOMIC_REPLACEMENT_READ_ATTEMPTS = runtime_policy_generated_default.external_inference.host_core.atomic_replacement_read_attempts;
50785
50800
  SERVICE_COOPERATIVE_STOP_SECONDS = Math.ceil(SERVICE_POLICY.cooperative_stop_timeout_ms / MS_PER_SECOND);
50786
50801
  pollAttemptsWithin = (milliseconds) => Math.ceil(milliseconds / SERVICE_POLICY.startup_poll_interval_ms);
50802
+ lockStillHeld = (error48) => error48 instanceof Error && (error48.message.includes("Another inference host process already owns") || error48.message.includes("could not verify the existing lock owner identity"));
50787
50803
  INFERENCE_HOST_SERVICE_DRAIN_COMMAND = "vtx-inference-host-service-drain-v1";
50788
50804
  INFERENCE_HOST_SERVICE_QUIESCE_COMMAND = "vtx-inference-host-service-quiesce-v1";
50789
50805
  InferenceHostBootstrapRestartRequiredError = class extends Error {
@@ -51349,6 +51365,7 @@ WantedBy=default.target
51349
51365
  generation: randomUUID12(),
51350
51366
  installed_at: this.now().toISOString()
51351
51367
  });
51368
+ await this.awaitNoLauncherFinishingStop();
51352
51369
  await writeAtomicInferencePrivateFile(
51353
51370
  this.manifestPath(),
51354
51371
  `${JSON.stringify(restoredManifest, null, JSON_INDENT_SPACES)}
@@ -51428,6 +51445,7 @@ ${result.stderr}`)) {
51428
51445
  this.serviceBootstrapLockPath()
51429
51446
  );
51430
51447
  const definition = this.platform === "win32" ? windowsTaskXml(this.windowsLauncherPath(), this.windowsDirectory, this.username) : this.platform === "darwin" ? launchAgentPlist(manifest.executable, args, manifest.log_path) : systemdUnit(manifest.executable, args);
51448
+ if (desiredRunning) await this.awaitNoLauncherFinishingStop();
51431
51449
  const existingRecovery = await readLauncherState(this.manifestPath());
51432
51450
  let managerInstallAttempted = false;
51433
51451
  try {
@@ -51573,10 +51591,11 @@ ${cleanup.stderr}`)) {
51573
51591
  }
51574
51592
  if (previous) {
51575
51593
  try {
51576
- await this.uninstallUnlocked(true);
51594
+ await this.uninstallUnlocked({ reconfiguring: true });
51577
51595
  } catch (error48) {
51596
+ const restored = await readInferenceHostServiceDesired(this.desiredPath()).catch(() => false);
51578
51597
  throw new Error(
51579
- "Inference-host service reconfiguration could not stop the previous supervisor; its desired state was restored.",
51598
+ restored ? "Inference-host service reconfiguration could not stop the previous supervisor; its desired state was restored." : "Inference-host service reconfiguration could not stop the previous supervisor; it stays stopped.",
51580
51599
  { cause: error48 }
51581
51600
  );
51582
51601
  }
@@ -51684,6 +51703,7 @@ ${cleanup.stderr}`)) {
51684
51703
  if (!await readInferenceHostServiceManifest(this.manifestPath())) {
51685
51704
  throw new Error("Inference-host service is not installed.");
51686
51705
  }
51706
+ await this.awaitNoLauncherFinishingStop();
51687
51707
  await writeDesired(this.desiredPath(), true, this.now());
51688
51708
  const result = await this.managerCommand("start");
51689
51709
  if (result.exitCode !== 0 && !/already running|in progress/iu.test(`${result.stdout}
@@ -51699,7 +51719,7 @@ ${result.stderr}`)) {
51699
51719
  }
51700
51720
  }
51701
51721
  async stop() {
51702
- return await this.withControlLock(async () => await this.stopUnlocked());
51722
+ return await this.withControlLock(async () => await this.stopUnlocked({ restoreOnFailure: false }));
51703
51723
  }
51704
51724
  /**
51705
51725
  * Quiesce the complete installed worker boundary while one exact instance's
@@ -51723,7 +51743,7 @@ ${result.stderr}`)) {
51723
51743
  await options.prepare?.(context);
51724
51744
  const before = await this.status();
51725
51745
  if (recordedDesiredRunning || before.manager_active) {
51726
- await this.stopUnlocked(true);
51746
+ await this.stopUnlocked({ restoreOnFailure: true, preserveManifestGeneration: true });
51727
51747
  } else {
51728
51748
  await writeDesired(this.desiredPath(), false, this.now());
51729
51749
  }
@@ -51765,44 +51785,98 @@ ${result.stderr}`)) {
51765
51785
  return { result, status: restoredStatus };
51766
51786
  });
51767
51787
  }
51768
- async stopUnlocked(preserveManifestGenerationOnFailure = false) {
51788
+ /**
51789
+ * True once no process holds any of these locks, false when one still does
51790
+ * after the cooperative-stop window.
51791
+ */
51792
+ async processLocksReleased(lockPaths) {
51793
+ for (let attempt2 = 0; attempt2 < this.stopWaitAttempts; attempt2 += 1) {
51794
+ let allReleased = true;
51795
+ for (const lockPath of lockPaths) {
51796
+ try {
51797
+ const probe = await this.acquireProcessLock(lockPath);
51798
+ await probe.release();
51799
+ } catch (error48) {
51800
+ if (lockStillHeld(error48)) {
51801
+ allReleased = false;
51802
+ break;
51803
+ }
51804
+ throw error48;
51805
+ }
51806
+ }
51807
+ if (allReleased) return true;
51808
+ await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
51809
+ }
51810
+ return false;
51811
+ }
51812
+ /**
51813
+ * A stop is no verdict on a release whose readiness attempt it ended. A
51814
+ * stable launcher installed before that rule (it is never replaced) leaves
51815
+ * the attempt pending when it stops, and its next start then rolls the
51816
+ * release back as if it had crashed. Once the stop has outlasted the
51817
+ * launcher, end that attempt here, under the launcher's own lock.
51818
+ */
51819
+ async endLauncherAttemptForStop() {
51820
+ let lock2 = null;
51821
+ for (let attempt2 = 0; attempt2 < this.stopWaitAttempts && !lock2; attempt2 += 1) {
51822
+ try {
51823
+ lock2 = await this.acquireProcessLock(launcherLockPath(this.manifestPath()));
51824
+ } catch (error48) {
51825
+ if (!lockStillHeld(error48)) throw error48;
51826
+ await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
51827
+ }
51828
+ }
51829
+ if (!lock2) return;
51830
+ try {
51831
+ const state2 = await readLauncherState(this.manifestPath()).catch(() => null);
51832
+ if (state2?.pending) await writeLauncherState(this.manifestPath(), { ...state2, pending: false });
51833
+ } finally {
51834
+ await lock2.release();
51835
+ }
51836
+ }
51837
+ /**
51838
+ * Desired-running goes back to true only once no launcher is still finishing
51839
+ * a stop. A launcher judges its core's exit by the desired state it reads
51840
+ * afterwards, and the stable launcher an older release installed (it is
51841
+ * never replaced) reads a true there as its ready release failing and rolls
51842
+ * it back.
51843
+ */
51844
+ async awaitNoLauncherFinishingStop() {
51845
+ if (await readInferenceHostServiceDesired(this.desiredPath())) return;
51846
+ if (!await this.processLocksReleased([launcherLockPath(this.manifestPath())])) {
51847
+ throw new Error(
51848
+ `Inference-host service launcher was still finishing a stop after ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; start the service once it has stopped.`
51849
+ );
51850
+ }
51851
+ }
51852
+ /**
51853
+ * A requested stop (`service stop`, uninstall) fences automatic restart: if
51854
+ * it cannot finish cooperatively it says so and leaves desired-running
51855
+ * false, so the service finishes its in-flight work and stays stopped. Only
51856
+ * the internal quiesces (guarded recovery, a reconfiguration that replaces
51857
+ * the definition) restore the supervisor they paused.
51858
+ */
51859
+ async stopUnlocked(options) {
51769
51860
  const manifest = await readInferenceHostServiceManifest(this.manifestPath());
51770
51861
  if (!manifest) {
51771
51862
  throw new Error("Inference-host service is not installed.");
51772
51863
  }
51773
- const restoreOnFailure = await readInferenceHostServiceDesired(this.desiredPath());
51864
+ const restoreOnFailure = options.restoreOnFailure && await readInferenceHostServiceDesired(this.desiredPath());
51865
+ const launcherStatus = await readInferenceHostProcessLockStatus(launcherLockPath(this.manifestPath())).catch(() => ({ state: "unknown" }));
51866
+ const launcherWasRunning = launcherStatus.state === "running" || launcherStatus.state === "unknown";
51774
51867
  await writeDesired(this.desiredPath(), false, this.now());
51775
51868
  try {
51776
- const serviceLockPaths = [
51869
+ const serviceReleased = await this.processLocksReleased([
51777
51870
  `${this.config.supervisorProcessLockPath}.service`,
51778
- this.serviceBootstrapLockPath()
51779
- ];
51780
- let serviceReleased = false;
51781
- for (let attempt2 = 0; attempt2 < this.stopWaitAttempts; attempt2 += 1) {
51782
- let allReleased = true;
51783
- for (const serviceLockPath of serviceLockPaths) {
51784
- try {
51785
- const probe = await this.acquireProcessLock(serviceLockPath);
51786
- await probe.release();
51787
- } catch (error48) {
51788
- if (error48 instanceof Error && error48.message.includes("Another inference host process already owns")) {
51789
- allReleased = false;
51790
- break;
51791
- }
51792
- throw error48;
51793
- }
51794
- }
51795
- if (allReleased) {
51796
- serviceReleased = true;
51797
- break;
51798
- }
51799
- await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
51800
- }
51871
+ this.serviceBootstrapLockPath(),
51872
+ launcherLockPath(this.manifestPath())
51873
+ ]);
51801
51874
  if (!serviceReleased) {
51802
51875
  throw new Error(
51803
51876
  `Inference-host updater or workers did not stop cooperatively within ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; refusing forced termination while cleanup may be pending.`
51804
51877
  );
51805
51878
  }
51879
+ if (launcherWasRunning) await this.endLauncherAttemptForStop();
51806
51880
  const result = await this.managerCommand("stop");
51807
51881
  if (result.exitCode !== 0 && !/not running|not found|does not exist|not loaded|cannot find|no such process/iu.test(`${result.stdout}
51808
51882
  ${result.stderr}`)) {
@@ -51816,7 +51890,7 @@ ${result.stderr}`)) {
51816
51890
  } catch (error48) {
51817
51891
  if (!restoreOnFailure) throw error48;
51818
51892
  try {
51819
- await this.restoreRunningSupervisor(manifest, preserveManifestGenerationOnFailure);
51893
+ await this.restoreRunningSupervisor(manifest, options.preserveManifestGeneration ?? false);
51820
51894
  } catch (restoreError) {
51821
51895
  throw new Error(
51822
51896
  "Inference-host stop failed and the previous supervisor could not be restored.",
@@ -51901,12 +51975,14 @@ ${result.stderr}`)) {
51901
51975
  async uninstall() {
51902
51976
  return await this.withControlLock(async () => await this.uninstallUnlocked());
51903
51977
  }
51904
- async uninstallUnlocked(preserveRecovery = false) {
51978
+ /** A reconfiguration keeps the recovery files and restores the supervisor it could not stop. */
51979
+ async uninstallUnlocked(options = { reconfiguring: false }) {
51980
+ const preserveRecovery = options.reconfiguring;
51905
51981
  const manifest = await readInferenceHostServiceManifest(this.manifestPath());
51906
51982
  if (!manifest) throw new Error("Inference-host service is not installed.");
51907
51983
  const current = await this.status();
51908
51984
  if (current.desired_running || current.manager_active) {
51909
- await this.stopUnlocked();
51985
+ await this.stopUnlocked({ restoreOnFailure: options.reconfiguring });
51910
51986
  } else {
51911
51987
  await writeDesired(this.desiredPath(), false, this.now());
51912
51988
  }
@@ -103890,6 +103966,73 @@ var init_client_exchange_mutations = __esm({
103890
103966
  }
103891
103967
  });
103892
103968
 
103969
+ // lib/runtime/prompt-number-contract.ts
103970
+ var finiteNumber2, roundPromptFixed, roundPromptSignificant, roundPromptRelativeVolume, roundPromptNonnegativeUnits;
103971
+ var init_prompt_number_contract = __esm({
103972
+ "lib/runtime/prompt-number-contract.ts"() {
103973
+ "use strict";
103974
+ init_define_VTX_CLAUDE_CODE_POLICY();
103975
+ init_define_VTX_EXO_POLICY();
103976
+ init_define_VTX_GROK_POLICY();
103977
+ init_define_VTX_PI_MODEL_POLICY();
103978
+ init_constants();
103979
+ finiteNumber2 = (value) => {
103980
+ const numeric2 = Number(value);
103981
+ return Number.isFinite(numeric2) ? numeric2 : null;
103982
+ };
103983
+ roundPromptFixed = (value, digits = PROMPT_FIXED_DIGITS) => {
103984
+ const numeric2 = finiteNumber2(value);
103985
+ if (numeric2 == null) {
103986
+ return 0;
103987
+ }
103988
+ if (!Number.isInteger(digits) || digits < 0 || digits > PROMPT_NUMBER_MAX_DIGITS) {
103989
+ throw new Error("prompt fixed digits must be between 0 and 100");
103990
+ }
103991
+ const rounded = Number(numeric2.toFixed(digits));
103992
+ return Object.is(rounded, -0) ? 0 : rounded;
103993
+ };
103994
+ roundPromptSignificant = (value, digits = PROMPT_SIGNIFICANT_DIGITS) => {
103995
+ const numeric2 = finiteNumber2(value);
103996
+ if (numeric2 == null || numeric2 === 0) {
103997
+ return 0;
103998
+ }
103999
+ if (!Number.isInteger(digits) || digits < 1 || digits > PROMPT_NUMBER_MAX_DIGITS) {
104000
+ throw new Error("prompt significant digits must be between 1 and 100");
104001
+ }
104002
+ const rounded = Number(numeric2.toPrecision(digits));
104003
+ return Object.is(rounded, -0) ? 0 : rounded;
104004
+ };
104005
+ roundPromptRelativeVolume = (value) => {
104006
+ if (value === null || value === void 0 || typeof value === "boolean") {
104007
+ return null;
104008
+ }
104009
+ if (typeof value === "string" && !value.trim()) {
104010
+ return null;
104011
+ }
104012
+ const numeric2 = finiteNumber2(value);
104013
+ if (numeric2 == null) {
104014
+ return null;
104015
+ }
104016
+ const digits = PROMPT_RELATIVE_VOLUME_DIGITS;
104017
+ const awayFromZero = numeric2.toFixed(digits);
104018
+ const tieNumerator = numeric2 * BINARY_RADIX ** (digits + 1);
104019
+ if (!Number.isInteger(tieNumerator) || Math.abs(tieNumerator) % BINARY_RADIX !== 1) {
104020
+ return Number(awayFromZero);
104021
+ }
104022
+ const towardZero = numeric2.toFixed(digits + 1).slice(0, -1);
104023
+ const towardZeroIsEven = Number(towardZero.at(-1)) % BINARY_RADIX === 0;
104024
+ return Number(towardZeroIsEven ? towardZero : awayFromZero);
104025
+ };
104026
+ roundPromptNonnegativeUnits = (value) => {
104027
+ const numeric2 = finiteNumber2(value);
104028
+ if (numeric2 == null || numeric2 <= 0) {
104029
+ return 0;
104030
+ }
104031
+ return Math.max(0, Math.round(numeric2));
104032
+ };
104033
+ }
104034
+ });
104035
+
103893
104036
  // lib/runtime/execution-guard-contract.ts
103894
104037
  var unitsFromPosition, signedUnitsFromPosition, signedUnitsFromEntryPosition, classifyExecutionIntent, reductionFirstOrder, orderMetadataRetryReason, copyClosingSize, copyOrderClosingSize, copyOrderNotionalCap, resolveExecutionTarget, decisionOrderSizeAsset, flipExecutionLegs, executedOrderPositionEvent;
103895
104038
  var init_execution_guard_contract = __esm({
@@ -103900,6 +104043,7 @@ var init_execution_guard_contract = __esm({
103900
104043
  init_define_VTX_GROK_POLICY();
103901
104044
  init_define_VTX_PI_MODEL_POLICY();
103902
104045
  init_constants();
104046
+ init_prompt_number_contract();
103903
104047
  unitsFromPosition = (size, price, unitSizeUsdc) => {
103904
104048
  const sizeValue = Number(size ?? 0);
103905
104049
  const priceValue = Number(price ?? 0);
@@ -103910,7 +104054,7 @@ var init_execution_guard_contract = __esm({
103910
104054
  if (sizeValue === 0 || priceValue <= 0 || unitSizeValue <= 0) {
103911
104055
  return 0;
103912
104056
  }
103913
- return Math.round(Math.abs(sizeValue * priceValue) / unitSizeValue);
104057
+ return Math.max(1, roundPromptNonnegativeUnits(Math.abs(sizeValue * priceValue) / unitSizeValue));
103914
104058
  };
103915
104059
  signedUnitsFromPosition = (size, price, unitSizeUsdc) => {
103916
104060
  const units = unitsFromPosition(size, price, unitSizeUsdc);
@@ -104900,73 +105044,6 @@ var init_constraint_contract = __esm({
104900
105044
  }
104901
105045
  });
104902
105046
 
104903
- // lib/runtime/prompt-number-contract.ts
104904
- var finiteNumber2, roundPromptFixed, roundPromptSignificant, roundPromptRelativeVolume, roundPromptNonnegativeUnits;
104905
- var init_prompt_number_contract = __esm({
104906
- "lib/runtime/prompt-number-contract.ts"() {
104907
- "use strict";
104908
- init_define_VTX_CLAUDE_CODE_POLICY();
104909
- init_define_VTX_EXO_POLICY();
104910
- init_define_VTX_GROK_POLICY();
104911
- init_define_VTX_PI_MODEL_POLICY();
104912
- init_constants();
104913
- finiteNumber2 = (value) => {
104914
- const numeric2 = Number(value);
104915
- return Number.isFinite(numeric2) ? numeric2 : null;
104916
- };
104917
- roundPromptFixed = (value, digits = PROMPT_FIXED_DIGITS) => {
104918
- const numeric2 = finiteNumber2(value);
104919
- if (numeric2 == null) {
104920
- return 0;
104921
- }
104922
- if (!Number.isInteger(digits) || digits < 0 || digits > PROMPT_NUMBER_MAX_DIGITS) {
104923
- throw new Error("prompt fixed digits must be between 0 and 100");
104924
- }
104925
- const rounded = Number(numeric2.toFixed(digits));
104926
- return Object.is(rounded, -0) ? 0 : rounded;
104927
- };
104928
- roundPromptSignificant = (value, digits = PROMPT_SIGNIFICANT_DIGITS) => {
104929
- const numeric2 = finiteNumber2(value);
104930
- if (numeric2 == null || numeric2 === 0) {
104931
- return 0;
104932
- }
104933
- if (!Number.isInteger(digits) || digits < 1 || digits > PROMPT_NUMBER_MAX_DIGITS) {
104934
- throw new Error("prompt significant digits must be between 1 and 100");
104935
- }
104936
- const rounded = Number(numeric2.toPrecision(digits));
104937
- return Object.is(rounded, -0) ? 0 : rounded;
104938
- };
104939
- roundPromptRelativeVolume = (value) => {
104940
- if (value === null || value === void 0 || typeof value === "boolean") {
104941
- return null;
104942
- }
104943
- if (typeof value === "string" && !value.trim()) {
104944
- return null;
104945
- }
104946
- const numeric2 = finiteNumber2(value);
104947
- if (numeric2 == null) {
104948
- return null;
104949
- }
104950
- const digits = PROMPT_RELATIVE_VOLUME_DIGITS;
104951
- const awayFromZero = numeric2.toFixed(digits);
104952
- const tieNumerator = numeric2 * BINARY_RADIX ** (digits + 1);
104953
- if (!Number.isInteger(tieNumerator) || Math.abs(tieNumerator) % BINARY_RADIX !== 1) {
104954
- return Number(awayFromZero);
104955
- }
104956
- const towardZero = numeric2.toFixed(digits + 1).slice(0, -1);
104957
- const towardZeroIsEven = Number(towardZero.at(-1)) % BINARY_RADIX === 0;
104958
- return Number(towardZeroIsEven ? towardZero : awayFromZero);
104959
- };
104960
- roundPromptNonnegativeUnits = (value) => {
104961
- const numeric2 = finiteNumber2(value);
104962
- if (numeric2 == null || numeric2 <= 0) {
104963
- return 0;
104964
- }
104965
- return Math.max(0, Math.round(numeric2));
104966
- };
104967
- }
104968
- });
104969
-
104970
105047
  // lib/runtime/execution-capacity.ts
104971
105048
  var capacityUnitsUsedForPosition, openCapacityRoom, allocatePlanCapacity, withCapacityTrim;
104972
105049
  var init_execution_capacity = __esm({
@@ -104976,27 +105053,10 @@ var init_execution_capacity = __esm({
104976
105053
  init_define_VTX_EXO_POLICY();
104977
105054
  init_define_VTX_GROK_POLICY();
104978
105055
  init_define_VTX_PI_MODEL_POLICY();
104979
- init_constants();
104980
105056
  init_constraint_contract();
104981
105057
  init_execution_guard_contract();
104982
105058
  init_hyperliquid_market_symbol();
104983
- init_prompt_number_contract();
104984
- capacityUnitsUsedForPosition = (size, entryPrice, unitSize) => {
104985
- const sizeFloat = Number(size);
104986
- const entryPriceFloat = Number(entryPrice);
104987
- if (!Number.isFinite(sizeFloat) || sizeFloat === 0) {
104988
- return 0;
104989
- }
104990
- const notional = Math.abs(sizeFloat * (Number.isFinite(entryPriceFloat) ? entryPriceFloat : 0));
104991
- let unitsUsed = roundPromptNonnegativeUnits(notional / unitSize);
104992
- if (unitsUsed < 1 && notional > unitSize * PROMPT_PARTIAL_UNIT_ROUND_UP_FRACTION) {
104993
- unitsUsed = 1;
104994
- }
104995
- if (unitsUsed < 1) {
104996
- unitsUsed = 0;
104997
- }
104998
- return Math.max(0, unitsUsed);
104999
- };
105059
+ capacityUnitsUsedForPosition = (size, entryPrice, unitSize) => unitsFromPosition(size, entryPrice, unitSize);
105000
105060
  openCapacityRoom = (positions, limits) => {
105001
105061
  let globalUnits = 0;
105002
105062
  const exchangeUsage = /* @__PURE__ */ new Map();
@@ -105073,7 +105133,7 @@ var init_execution_capacity = __esm({
105073
105133
  });
105074
105134
 
105075
105135
  // lib/runtime/owed-protection-warnings.ts
105076
- var storageKey, isWarning, identity2, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
105136
+ var storageKey, isWarning, identity2, owesProtectionRecord, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
105077
105137
  var init_owed_protection_warnings = __esm({
105078
105138
  "lib/runtime/owed-protection-warnings.ts"() {
105079
105139
  "use strict";
@@ -105088,6 +105148,7 @@ var init_owed_protection_warnings = __esm({
105088
105148
  return record6 != null && typeof record6 === "object" && typeof record6.symbol === "string" && typeof record6.action === "string" && typeof record6.status === "string" && (record6.order_id === null || typeof record6.order_id === "string") && record6.execution_metadata != null && typeof record6.execution_metadata === "object";
105089
105149
  };
105090
105150
  identity2 = (warning) => JSON.stringify(warning);
105151
+ owesProtectionRecord = (report) => report.status === "executed" && report.order_id != null && (report.execution_metadata?.entry_order_id != null || report.execution_metadata?.previous_order_id != null);
105091
105152
  distinctProtectionWarnings = (warnings) => {
105092
105153
  const seen = /* @__PURE__ */ new Set();
105093
105154
  return warnings.filter((warning) => {
@@ -105695,6 +105756,17 @@ var init_protective_oversized_leg = __esm({
105695
105756
  }
105696
105757
  });
105697
105758
 
105759
+ // lib/runtime/protective-report-entry.ts
105760
+ var init_protective_report_entry = __esm({
105761
+ "lib/runtime/protective-report-entry.ts"() {
105762
+ "use strict";
105763
+ init_define_VTX_CLAUDE_CODE_POLICY();
105764
+ init_define_VTX_EXO_POLICY();
105765
+ init_define_VTX_GROK_POLICY();
105766
+ init_define_VTX_PI_MODEL_POLICY();
105767
+ }
105768
+ });
105769
+
105698
105770
  // lib/runtime/native-position-protection.ts
105699
105771
  var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, FIRED_TRIGGER_CONDITION, TRAILING_ORDER_TYPE, closingSide, DECIMAL_PATTERN, decimalUnits2, fractionDigits, nativePlaceCover, positiveOrderId, nativeRearmDecision, nativeLostStopCrossed, readListedProtectiveRow, explainAbsentProtectiveOrder, readServerNativeProtectionState, nativeFillOpenedPosition, nativePositionEndedSince, flatReadEndsPosition;
105700
105772
  var init_native_position_protection = __esm({
@@ -106000,7 +106072,7 @@ var init_native_protection_device = __esm({
106000
106072
  ...member.pendingModify ? { pendingClientOrderId: member.pendingModify.clientOrderId } : {}
106001
106073
  }
106002
106074
  });
106003
- warningKey = (member, fill) => member?.noticeKey ?? (member?.orderId != null ? String(member.orderId) : fill ?? void 0);
106075
+ warningKey = (member, fill) => member == null ? fill ?? void 0 : member.noticeKey ?? (member.orderId != null ? String(member.orderId) : member.clientOrderId);
106004
106076
  moveMade = (member) => {
106005
106077
  const { pendingMove: _made, ...rest } = member;
106006
106078
  return rest;
@@ -106240,14 +106312,23 @@ var init_native_protection_device = __esm({
106240
106312
  if (!stopLoss?.trailing || !(Number(size) > 0)) return null;
106241
106313
  return nativeTrailingRetracement({ mode: stopLoss.mode, value: stopLoss.value, lotSize: Number(size), sizeDecimals });
106242
106314
  };
106243
- lotReport = (symbol2, lot, status, metadata) => ({
106244
- order_id: lot.orderId == null ? null : String(lot.orderId),
106245
- symbol: symbol2,
106246
- // The lot is the trailing stop; the whole-position stop stays AUTO_SL (protective_fill_attribution.leg_action).
106247
- action: "AUTO_TRAILING_SL",
106248
- status,
106249
- execution_metadata: { trailing_lot: true, protected_size: lot.size, retracement: lot.retracement, ...metadata }
106250
- });
106315
+ lotReport = (symbol2, lot, status, metadata) => {
106316
+ const entry = status === "executed" ? lotFillOrderId(lot) : null;
106317
+ return {
106318
+ order_id: lot.orderId == null ? null : String(lot.orderId),
106319
+ symbol: symbol2,
106320
+ // The lot is the trailing stop; the whole-position stop stays AUTO_SL (protective_fill_attribution.leg_action).
106321
+ action: "AUTO_TRAILING_SL",
106322
+ status,
106323
+ execution_metadata: {
106324
+ trailing_lot: true,
106325
+ protected_size: lot.size,
106326
+ retracement: lot.retracement,
106327
+ ...metadata,
106328
+ ...entry != null ? { entry_order_id: entry } : {}
106329
+ }
106330
+ };
106331
+ };
106251
106332
  sendTrailingLot = async (args) => {
106252
106333
  const { io } = args;
106253
106334
  if (!io.placeTrailingLot) return { lot: args.lot, report: null };
@@ -106546,7 +106627,8 @@ var init_native_protection_device = __esm({
106546
106627
  trigger_price: trigger,
106547
106628
  position_tpsl: true,
106548
106629
  protected_size: args.protectedSize,
106549
- ...newOrderId != null ? { replaced_order_id: String(orderId) } : {}
106630
+ // The same stop: VTX records it under its predecessor's decision.
106631
+ ...newOrderId != null ? { replaced_order_id: String(orderId), previous_order_id: String(orderId) } : {}
106550
106632
  }
106551
106633
  }
106552
106634
  };
@@ -106838,7 +106920,7 @@ var init_native_protection_device = __esm({
106838
106920
  sentAtMs,
106839
106921
  replacedOnce: existing?.replacedOnce ?? false,
106840
106922
  ...io.vtxSigns ? {} : { unlandedPlaces: unlandedPlaces + 1 },
106841
- ...existing?.noticeKey ? { noticeKey: existing.noticeKey } : {}
106923
+ ...noticeKey ? { noticeKey } : {}
106842
106924
  };
106843
106925
  const before = [...members];
106844
106926
  if (index >= 0) members[index] = journaled;
@@ -107086,7 +107168,7 @@ var init_native_protection_device = __esm({
107086
107168
  });
107087
107169
  if (cover.decision !== "place") return args.member;
107088
107170
  const unlandedPlaces = args.member.unlandedPlaces ?? 0;
107089
- const noticeKey = warningKey(args.member, record6.positionOrderId ?? record6.entryClientOrderId);
107171
+ const noticeKey = warningKey(args.member, null);
107090
107172
  if (unlandedPlaces >= MAX_PLACE_ATTEMPTS) {
107091
107173
  reports.push({
107092
107174
  order_id: null,
@@ -107113,7 +107195,7 @@ var init_native_protection_device = __esm({
107113
107195
  sentAtMs,
107114
107196
  replacedOnce: args.replacedOnce,
107115
107197
  ...io.vtxSigns ? {} : { unlandedPlaces: unlandedPlaces + 1 },
107116
- ...args.member.noticeKey ? { noticeKey: args.member.noticeKey } : {}
107198
+ ...noticeKey ? { noticeKey } : {}
107117
107199
  };
107118
107200
  if (!io.persist({
107119
107201
  ...record6,
@@ -107190,7 +107272,7 @@ var init_native_protection_device = __esm({
107190
107272
  retiredReason
107191
107273
  } : placedOrderId != null ? { ...landed, orderId: placedOrderId } : journaled;
107192
107274
  reports.push({
107193
- // A warning names its stop by the fill it protects alone (noticeKey).
107275
+ // A warning names its stop by its streak's key alone (noticeKey).
107194
107276
  order_id: refused || placed.orderId == null ? null : String(placed.orderId),
107195
107277
  symbol: symbol2,
107196
107278
  action: actionOf(args.member.kind),
@@ -107198,6 +107280,9 @@ var init_native_protection_device = __esm({
107198
107280
  execution_metadata: {
107199
107281
  reason_code: retried ? "protective_place_rejected" : refused ? retiredReason : args.reasonCode,
107200
107282
  ...args.member.orderId != null ? { replaced_order_id: String(args.member.orderId) } : {},
107283
+ // A lost stop placed again as the same stop (not a re-arm on a new
107284
+ // position): VTX records it under its predecessor's decision.
107285
+ ...!refused && args.member.orderId != null && args.reasonCode === "protective_stop_replaced" ? { previous_order_id: String(args.member.orderId) } : {},
107201
107286
  trigger_price: args.trigger,
107202
107287
  position_tpsl: true,
107203
107288
  protected_size: Math.abs(position.size),
@@ -107756,6 +107841,7 @@ var init_runtime_execution = __esm({
107756
107841
  init_protective_stop_replacement();
107757
107842
  init_protective_entry_cover();
107758
107843
  init_protective_oversized_leg();
107844
+ init_protective_report_entry();
107759
107845
  init_error_surface_contract();
107760
107846
  init_native_position_protection();
107761
107847
  init_native_protection_device();
@@ -109565,6 +109651,7 @@ var init_runtime_execution = __esm({
109565
109651
  positionTpsl,
109566
109652
  metadata: {
109567
109653
  trigger_price: candidates[index].triggerPrice,
109654
+ entry_order_id: fill.orderId,
109568
109655
  entry_filled_size: fill.filledSize,
109569
109656
  entry_average_price: fill.averagePrice
109570
109657
  }
@@ -112193,6 +112280,7 @@ var init_runtime_execution = __esm({
112193
112280
  metadata: {
112194
112281
  reason_code: decision.reasonCode,
112195
112282
  replaced_order_id: lostOrderId,
112283
+ entry_order_id: group.entryOrderId,
112196
112284
  trigger_price: triggerPrice,
112197
112285
  live_position_size: livePositionSize2,
112198
112286
  ...acknowledgement.state === "fulfilled" ? { acknowledgement_state: "fulfilled" } : {}
@@ -112796,7 +112884,8 @@ var init_runtime_execution = __esm({
112796
112884
  metadata: {
112797
112885
  trigger_price: replacementTriggerPrice,
112798
112886
  previous_trigger_price: leg.triggerPrice,
112799
- previous_order_id: orderId
112887
+ previous_order_id: orderId,
112888
+ entry_order_id: reservation.sourceGroup.entryOrderId
112800
112889
  }
112801
112890
  }));
112802
112891
  return { reports, stop: false };
@@ -114177,24 +114266,6 @@ var init_runtime_execution = __esm({
114177
114266
  };
114178
114267
  }
114179
114268
  }
114180
- if (!targetResolution.closeOpposingPosition && classified.reduceOnly !== true && !await serverEntryLeverageAlreadyHeld(input)) {
114181
- throwIfAborted(input.signal);
114182
- await executeClientLeverageUpdate({
114183
- profileId: input.profileId,
114184
- runtimeSessionId: input.sessionId || "__missing_runtime_session__",
114185
- runtimeLeaseToken: input.runtimeLeaseToken,
114186
- runtimeDeviceId: input.runtimeDeviceId,
114187
- schedulerInstanceId: input.schedulerInstanceId,
114188
- walletAddress: input.executionContext.walletAddress,
114189
- config: input.config ?? null,
114190
- signal: input.signal,
114191
- signingKey: input.signingKey,
114192
- symbol: input.executionContext.symbol,
114193
- leverage: input.executionContext.leverage,
114194
- isCross: input.executionContext.marginMode !== "isolated"
114195
- });
114196
- throwIfAborted(input.signal);
114197
- }
114198
114269
  if (classified.intent === "close") {
114199
114270
  throwIfAborted(input.signal);
114200
114271
  const closeMutationId = await decisionLegMutationId("close");
@@ -114407,21 +114478,6 @@ var init_runtime_execution = __esm({
114407
114478
  );
114408
114479
  await waitForFlipCloseFreshness(input);
114409
114480
  throwIfAborted(input.signal);
114410
- await executeClientLeverageUpdate({
114411
- profileId: input.profileId,
114412
- runtimeSessionId: input.sessionId || "__missing_runtime_session__",
114413
- runtimeLeaseToken: input.runtimeLeaseToken,
114414
- runtimeDeviceId: input.runtimeDeviceId,
114415
- schedulerInstanceId: input.schedulerInstanceId,
114416
- walletAddress: input.executionContext.walletAddress,
114417
- config: input.config ?? null,
114418
- signal: input.signal,
114419
- signingKey: input.signingKey,
114420
- symbol: input.executionContext.symbol,
114421
- leverage: input.executionContext.leverage,
114422
- isCross: input.executionContext.marginMode !== "isolated"
114423
- });
114424
- throwIfAborted(input.signal);
114425
114481
  if (serverOrder) executionPrice = await readServerOrderMarkPrice(input);
114426
114482
  }
114427
114483
  const actualUnits = targetResolution.orderUnits;
@@ -114462,41 +114518,6 @@ var init_runtime_execution = __esm({
114462
114518
  executionSnapshotCapturedAt
114463
114519
  };
114464
114520
  }
114465
- const entryRequiresFlatAbsenceProof = Number.isFinite(currentPositionSize) && currentPositionSize === 0 || targetResolution.closeOpposingPosition;
114466
- if (entryRequiresFlatAbsenceProof) {
114467
- const finalProtectionObservation = await verifyNoLiveClientProtectiveTriggers(
114468
- input,
114469
- classified.side
114470
- );
114471
- executionReports.push(...finalProtectionObservation.reports);
114472
- if (finalProtectionObservation.blocksEntry) {
114473
- const blockedAfterConfirmedClose = targetResolution.closeOpposingPosition;
114474
- executionReports.push({
114475
- order_id: null,
114476
- symbol: input.executionContext.symbol,
114477
- action: blockedAfterConfirmedClose ? "FLIP_OPEN" : "PROTECTIVE_RECONCILIATION",
114478
- status: "blocked",
114479
- execution_metadata: {
114480
- reason_code: "protective_reconciliation_unresolved",
114481
- execution_stage: "entry_dispatch_precondition"
114482
- }
114483
- });
114484
- return {
114485
- status: blockedAfterConfirmedClose ? "executed" : "skipped",
114486
- intent: classified.intent,
114487
- side: classified.side,
114488
- reduceOnly: classified.reduceOnly,
114489
- requestedUnits: classified.requestedUnits,
114490
- targetSignedUnits: classified.targetSignedUnits,
114491
- executedSizeAsset: blockedAfterConfirmedClose ? Math.abs(currentPositionSize) : 0,
114492
- executionReports,
114493
- message: blockedAfterConfirmedClose ? "Closed the opposing position, but blocked the new flip entry because a live protective trigger appeared before dispatch." : "Blocked new exposure because a live protective trigger appeared before dispatch.",
114494
- reasonCode: "protective_reconciliation_unresolved",
114495
- executionSnapshotId,
114496
- executionSnapshotCapturedAt
114497
- };
114498
- }
114499
- }
114500
114521
  const shouldAttachSlTp = input.executionContext.tpSlEnabled === true && classified.reduceOnly !== true && (classified.intent === "open" || classified.intent === "add" || classified.intent === "flip") && isConfiguredProtectionRequested(input);
114501
114522
  let pendingProtectiveGroup = null;
114502
114523
  let persistedProtectiveGroupSet = null;
@@ -114540,6 +114561,7 @@ var init_runtime_execution = __esm({
114540
114561
  if (entryMutationId) entryClientOrderId = clientOrderIdForMutation(entryMutationId);
114541
114562
  let nativeOpen = null;
114542
114563
  let nativeAddRecord = null;
114564
+ let nativeJournal = null;
114543
114565
  let nativePendingLotKey = null;
114544
114566
  const nativeProfileId = String(input.profileId).trim();
114545
114567
  const nativeBlocked = (reasonCode, message) => ({
@@ -114590,12 +114612,7 @@ var init_runtime_execution = __esm({
114590
114612
  sizeHint: sizeAsset,
114591
114613
  nowMs: journaledAt
114592
114614
  }), { clientOrderId: entryClientOrderId, nowMs: journaledAt });
114593
- if (nativeAddRecord !== existingNative.record && !writeNativeProtectionRecord(nativeProfileId, input.executionContext.symbol, nativeAddRecord)) {
114594
- return nativeBlocked(
114595
- "protective_lifecycle_persistence_failed",
114596
- "Blocked new exposure because its position protection could not be stored."
114597
- );
114598
- }
114615
+ if (nativeAddRecord !== existingNative.record) nativeJournal = nativeAddRecord;
114599
114616
  }
114600
114617
  } else if (existingNative.kind === "record") {
114601
114618
  return nativeBlocked(
@@ -114624,12 +114641,7 @@ var init_runtime_execution = __esm({
114624
114641
  newMutationId: () => createRuntimeId().toLowerCase(),
114625
114642
  nowMs: Date.now()
114626
114643
  });
114627
- if (nativeOpen != null && !writeNativeProtectionRecord(nativeProfileId, input.executionContext.symbol, nativeOpen.record)) {
114628
- return nativeBlocked(
114629
- "protective_lifecycle_persistence_failed",
114630
- "Blocked new exposure because its position protection could not be stored."
114631
- );
114632
- }
114644
+ nativeJournal = nativeOpen?.record ?? null;
114633
114645
  }
114634
114646
  }
114635
114647
  const nativeProtection = nativeOpen != null || nativeAddRecord != null;
@@ -114640,6 +114652,65 @@ var init_runtime_execution = __esm({
114640
114652
  entrySize: sizeAsset,
114641
114653
  positionBefore: targetResolution.closeOpposingPosition ? 0 : currentPositionSize
114642
114654
  }) : null;
114655
+ if (classified.reduceOnly !== true && (targetResolution.closeOpposingPosition || !await serverEntryLeverageAlreadyHeld(input))) {
114656
+ throwIfAborted(input.signal);
114657
+ await executeClientLeverageUpdate({
114658
+ profileId: input.profileId,
114659
+ runtimeSessionId: input.sessionId || "__missing_runtime_session__",
114660
+ runtimeLeaseToken: input.runtimeLeaseToken,
114661
+ runtimeDeviceId: input.runtimeDeviceId,
114662
+ schedulerInstanceId: input.schedulerInstanceId,
114663
+ walletAddress: input.executionContext.walletAddress,
114664
+ config: input.config ?? null,
114665
+ signal: input.signal,
114666
+ signingKey: input.signingKey,
114667
+ symbol: input.executionContext.symbol,
114668
+ leverage: input.executionContext.leverage,
114669
+ isCross: input.executionContext.marginMode !== "isolated"
114670
+ });
114671
+ throwIfAborted(input.signal);
114672
+ }
114673
+ const entryRequiresFlatAbsenceProof = Number.isFinite(currentPositionSize) && currentPositionSize === 0 || targetResolution.closeOpposingPosition;
114674
+ if (entryRequiresFlatAbsenceProof) {
114675
+ const finalProtectionObservation = await verifyNoLiveClientProtectiveTriggers(
114676
+ input,
114677
+ classified.side
114678
+ );
114679
+ executionReports.push(...finalProtectionObservation.reports);
114680
+ if (finalProtectionObservation.blocksEntry) {
114681
+ const blockedAfterConfirmedClose = targetResolution.closeOpposingPosition;
114682
+ executionReports.push({
114683
+ order_id: null,
114684
+ symbol: input.executionContext.symbol,
114685
+ action: blockedAfterConfirmedClose ? "FLIP_OPEN" : "PROTECTIVE_RECONCILIATION",
114686
+ status: "blocked",
114687
+ execution_metadata: {
114688
+ reason_code: "protective_reconciliation_unresolved",
114689
+ execution_stage: "entry_dispatch_precondition"
114690
+ }
114691
+ });
114692
+ return {
114693
+ status: blockedAfterConfirmedClose ? "executed" : "skipped",
114694
+ intent: classified.intent,
114695
+ side: classified.side,
114696
+ reduceOnly: classified.reduceOnly,
114697
+ requestedUnits: classified.requestedUnits,
114698
+ targetSignedUnits: classified.targetSignedUnits,
114699
+ executedSizeAsset: blockedAfterConfirmedClose ? Math.abs(currentPositionSize) : 0,
114700
+ executionReports,
114701
+ message: blockedAfterConfirmedClose ? "Closed the opposing position, but blocked the new flip entry because a live protective trigger appeared before dispatch." : "Blocked new exposure because a live protective trigger appeared before dispatch.",
114702
+ reasonCode: "protective_reconciliation_unresolved",
114703
+ executionSnapshotId,
114704
+ executionSnapshotCapturedAt
114705
+ };
114706
+ }
114707
+ }
114708
+ if (nativeJournal != null && !writeNativeProtectionRecord(nativeProfileId, input.executionContext.symbol, nativeJournal)) {
114709
+ return nativeBlocked(
114710
+ "protective_lifecycle_persistence_failed",
114711
+ "Blocked new exposure because its position protection could not be stored."
114712
+ );
114713
+ }
114643
114714
  if (localProtection && !nativeProtection) {
114644
114715
  entryMutationId ??= createRuntimeId().toLowerCase();
114645
114716
  entryClientOrderId = clientOrderIdForMutation(entryMutationId);
@@ -115781,9 +115852,11 @@ var init_protection_warning_delivery = __esm({
115781
115852
  owesWarning = (report) => report.status === "failed" && (report.action === "AUTO_SL" || report.action === "AUTO_TP") && report.execution_metadata?.manual_intervention === true;
115782
115853
  hasPendingClientProtection = (profileId) => hasPendingClientProtectiveGroups(profileId) || owedProtectionWarnings(profileId).length > 0;
115783
115854
  deliverProtectionWarnings = async (profileId, results, signal) => {
115855
+ const reports = results.flatMap((result) => result.reports);
115856
+ oweProtectionWarnings(profileId, reports.filter(owesProtectionRecord));
115784
115857
  const pending3 = distinctProtectionWarnings([
115785
115858
  ...owedProtectionWarnings(profileId),
115786
- ...results.flatMap(({ reports }) => reports).filter(owesWarning)
115859
+ ...reports.filter((report) => owesWarning(report) || owesProtectionRecord(report))
115787
115860
  ]);
115788
115861
  for (let start = 0; start < pending3.length; start += REPORTS_PER_REQUEST) {
115789
115862
  const chunk = pending3.slice(start, start + REPORTS_PER_REQUEST);
@@ -116324,7 +116397,7 @@ var init_browser_observability = __esm({
116324
116397
  init_define_VTX_GROK_POLICY();
116325
116398
  init_define_VTX_PI_MODEL_POLICY();
116326
116399
  init_runtime_policy_generated2();
116327
- CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "127ff79320ec1b24389d2a839c44d944c698ed0e".trim() && "127ff79320ec1b24389d2a839c44d944c698ed0e".trim() !== "unstamped" ? "127ff79320ec1b24389d2a839c44d944c698ed0e".trim() : null;
116400
+ CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim() && "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim() !== "unstamped" ? "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim() : null;
116328
116401
  listenersInstalled = false;
116329
116402
  state = {
116330
116403
  loadedAtMs: Date.now(),
@@ -120030,6 +120103,7 @@ var init_device_trailing_maintenance = __esm({
120030
120103
  init_api2();
120031
120104
  init_constants();
120032
120105
  init_network_debug();
120106
+ init_protection_warning_delivery();
120033
120107
  init_runtime_redaction();
120034
120108
  init_runtime_execution();
120035
120109
  init_runtime_handoff();
@@ -120084,6 +120158,7 @@ var init_device_trailing_maintenance = __esm({
120084
120158
  outcome: failed2 > 0 ? "error" : "ok"
120085
120159
  });
120086
120160
  }
120161
+ await deliverProtectionWarnings(input.profileId, results, input.signal);
120087
120162
  const nextDueAtMs = nextClientTrailingStopDueAtMs(input.profileId, input.intervalMs);
120088
120163
  return { recheckAtMs: nextDueAtMs == null ? null : Math.max(nextDueAtMs, ranAtMs + pollMs) };
120089
120164
  };
@@ -129127,9 +129202,9 @@ var init_local_analysis = __esm({
129127
129202
  RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
129128
129203
  DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
129129
129204
  CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
129130
- CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "127ff79320ec1b24389d2a839c44d944c698ed0e".trim() && !["unknown", "unstamped", "development"].includes(
129131
- "127ff79320ec1b24389d2a839c44d944c698ed0e".trim().toLowerCase()
129132
- ) ? "127ff79320ec1b24389d2a839c44d944c698ed0e".trim() : null;
129205
+ CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim() && !["unknown", "unstamped", "development"].includes(
129206
+ "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim().toLowerCase()
129207
+ ) ? "6e697ce34f8b8c49c59cd6ba767c041fbee06d58".trim() : null;
129133
129208
  CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
129134
129209
  CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
129135
129210
  resolveEffectivePromptRuntimeProvenance = (input) => ({
@@ -134303,7 +134378,7 @@ ${indentText.repeat(depth)}${brackets[1]}`;
134303
134378
  });
134304
134379
 
134305
134380
  // lib/runtime/copy-review-prompt.ts
134306
- var COPY_REVIEW_PRIMARY_MODEL, metadataOf, copyReviewProposedDecision, inferIntentFromPositionDelta, pythonFloatOf, copyReviewDestinationIntent, copyReviewProposedTrade, text, copyReviewPromptContext, copyReviewPrimaryReasoning, copyReviewPromptSymbols, copyReviewPromptSize, promptJsonValue, renderCopyReviewPrompts;
134381
+ var COPY_REVIEW_PRIMARY_MODEL, COPY_TRADE_PROPOSAL, COPY_POSITION_REPAIR, metadataOf, copyReviewIsGapRepair, copyReviewProposedDecision, inferIntentFromPositionDelta, pythonFloatOf, copyReviewDestinationIntent, copyReviewObserved, copyReviewProposedTrade, text, gapRepairTemplates, copyReviewPromptContext, copyReviewPrimaryReasoning, copyReviewPromptSymbols, copyReviewPromptSize, promptJsonValue, renderCopyReviewPrompts;
134307
134382
  var init_copy_review_prompt = __esm({
134308
134383
  "lib/runtime/copy-review-prompt.ts"() {
134309
134384
  "use strict";
@@ -134321,7 +134396,10 @@ var init_copy_review_prompt = __esm({
134321
134396
  init_python_json();
134322
134397
  init_runtime_error_reason_rules();
134323
134398
  COPY_REVIEW_PRIMARY_MODEL = "Copy Trading";
134399
+ COPY_TRADE_PROPOSAL = "copy_trade_proposal";
134400
+ COPY_POSITION_REPAIR = "copy_position_repair";
134324
134401
  metadataOf = (event) => event.sanitized_metadata && typeof event.sanitized_metadata === "object" && !Array.isArray(event.sanitized_metadata) ? event.sanitized_metadata : {};
134402
+ copyReviewIsGapRepair = (event) => metadataOf(event).source_fill_gap_reconciliation === true;
134325
134403
  copyReviewProposedDecision = (event) => {
134326
134404
  const side = String(event.destination_side || event.source_side || "").trim().toLowerCase();
134327
134405
  if (side === "buy") return "BUY";
@@ -134352,16 +134430,13 @@ var init_copy_review_prompt = __esm({
134352
134430
  const delta = String(event.destination_side || "").trim().toLowerCase() === "buy" ? size : -size;
134353
134431
  return inferIntentFromPositionDelta(previous, previous + delta);
134354
134432
  };
134355
- copyReviewProposedTrade = (event, source) => ({
134356
- type: "copy_trade_proposal",
134357
- source: {
134358
- type: source.source_type,
134359
- identifier: source.source_identifier,
134360
- display_name: source.source_display_name,
134361
- wallet_address: source.source_wallet_address
134362
- },
134363
- symbol: event.symbol,
134364
- decision: copyReviewProposedDecision(event),
134433
+ copyReviewObserved = (event) => copyReviewIsGapRepair(event) ? {
134434
+ source_position: {
134435
+ side: event.source_size ? event.source_side : null,
134436
+ size: pythonFloat(event.source_size),
134437
+ time: event.source_time
134438
+ }
134439
+ } : {
134365
134440
  source_fill: {
134366
134441
  side: event.source_side,
134367
134442
  size: pythonFloat(event.source_size),
@@ -134370,7 +134445,19 @@ var init_copy_review_prompt = __esm({
134370
134445
  oid: event.source_oid,
134371
134446
  hash: event.source_hash,
134372
134447
  fingerprint: event.source_event_fingerprint
134448
+ }
134449
+ };
134450
+ copyReviewProposedTrade = (event, source) => ({
134451
+ type: copyReviewIsGapRepair(event) ? COPY_POSITION_REPAIR : COPY_TRADE_PROPOSAL,
134452
+ source: {
134453
+ type: source.source_type,
134454
+ identifier: source.source_identifier,
134455
+ display_name: source.source_display_name,
134456
+ wallet_address: source.source_wallet_address
134373
134457
  },
134458
+ symbol: event.symbol,
134459
+ decision: copyReviewProposedDecision(event),
134460
+ ...copyReviewObserved(event),
134374
134461
  destination_order: {
134375
134462
  side: event.destination_side,
134376
134463
  size: pythonFloat(event.destination_size),
@@ -134387,13 +134474,22 @@ var init_copy_review_prompt = __esm({
134387
134474
  }
134388
134475
  });
134389
134476
  text = (value) => ({ kind: "str", value });
134390
- copyReviewPromptContext = (proposedTrade, templates) => formatGuidanceTemplate(templates.context, {
134391
- observed_event: text(templates.source_fill.observed_event),
134392
- proposal_kind: text(templates.source_fill.proposal_kind),
134393
- observed_source: text(templates.source_fill.observed_source),
134394
- copy_trade_proposal_json: text(pythonJsonDumps(proposedTrade, { sortKeys: true }))
134395
- });
134396
- copyReviewPrimaryReasoning = (proposedTrade, templates) => formatGuidanceTemplate(templates.primary_reasoning, {
134477
+ gapRepairTemplates = (templates) => {
134478
+ if (!templates.gap_repair) {
134479
+ throw new RuntimeReasonError("Missing prompts config: copy_trading_review.gap_repair", "runtime_config_missing");
134480
+ }
134481
+ return templates.gap_repair;
134482
+ };
134483
+ copyReviewPromptContext = (proposedTrade, templates) => {
134484
+ const observed = proposedTrade.type === COPY_POSITION_REPAIR ? gapRepairTemplates(templates) : templates.source_fill;
134485
+ return formatGuidanceTemplate(templates.context, {
134486
+ observed_event: text(observed.observed_event),
134487
+ proposal_kind: text(observed.proposal_kind),
134488
+ observed_source: text(observed.observed_source),
134489
+ copy_trade_proposal_json: text(pythonJsonDumps(proposedTrade, { sortKeys: true }))
134490
+ });
134491
+ };
134492
+ copyReviewPrimaryReasoning = (proposedTrade, templates) => formatGuidanceTemplate(proposedTrade.type === COPY_POSITION_REPAIR ? gapRepairTemplates(templates).primary_reasoning : templates.primary_reasoning, {
134397
134493
  copy_trade_proposal_json: text(pythonJsonDumps(
134398
134494
  { copy_trade_proposal: proposedTrade },
134399
134495
  { sortKeys: true, indent: JSON_INDENT_SPACES }