@vtxmacro/cli 2026.10.57 → 2026.10.59
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/exo-harness.ts +1 -0
- package/bin/vtx-mcp.js +2 -1
- package/bin/vtx-service-bootstrap.js +2 -1
- package/bin/vtx-service-launcher.js +1 -0
- package/bin/vtx.js +843 -568
- package/package.json +1 -1
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.
|
|
125
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.59", 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
|
|
|
@@ -1109,6 +1109,7 @@ var init_runtime_policy_generated = __esm({
|
|
|
1109
1109
|
model_catalog_read_lead_divisor: 2,
|
|
1110
1110
|
agent_wake_summary_max_chars: 2e3,
|
|
1111
1111
|
drain_timeout_ms: 3e4,
|
|
1112
|
+
undispatched_adapter_failure_restart_threshold: 3,
|
|
1112
1113
|
remote_retry_limit: 3,
|
|
1113
1114
|
minimum_sleep_ms: 10,
|
|
1114
1115
|
heartbeat_gap_diagnostic_min_ms: 1e4,
|
|
@@ -3087,7 +3088,7 @@ var init_shared_contracts_generated = __esm({
|
|
|
3087
3088
|
});
|
|
3088
3089
|
|
|
3089
3090
|
// lib/constants.ts
|
|
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;
|
|
3091
|
+
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, INFERENCE_HOST_TEMP_FOLDERS, INFERENCE_HOST_FAILURE_CAUSE_MAX_DEPTH, 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;
|
|
3091
3092
|
var init_constants = __esm({
|
|
3092
3093
|
"lib/constants.ts"() {
|
|
3093
3094
|
"use strict";
|
|
@@ -3357,6 +3358,15 @@ var init_constants = __esm({
|
|
|
3357
3358
|
BOOT_IDENTITY: 4096
|
|
3358
3359
|
};
|
|
3359
3360
|
CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS = 3;
|
|
3361
|
+
INFERENCE_HOST_TEMP_FOLDERS = {
|
|
3362
|
+
CODEX_WORKER_PREFIX: "vtx-codex-host-",
|
|
3363
|
+
CODEX_WORKER_JOBS: "workspaces",
|
|
3364
|
+
CODEX_HOSTED_JOB_PREFIX: "attempt-",
|
|
3365
|
+
CODEX_JOB_PREFIX: "vtx-codex-attempt-",
|
|
3366
|
+
COPILOT_JOB_PREFIX: "vtx-copilot-",
|
|
3367
|
+
DEEPSEEK_JOB_PREFIX: "vtx-deepseek-harness-"
|
|
3368
|
+
};
|
|
3369
|
+
INFERENCE_HOST_FAILURE_CAUSE_MAX_DEPTH = 8;
|
|
3360
3370
|
CODEX_GUARDIAN_PROCESS_TOKEN_BYTES = 32;
|
|
3361
3371
|
CODEX_RATE_LIMIT_EXHAUSTED_PERCENT = 100;
|
|
3362
3372
|
INFERENCE_HOST_PROXY_TOKEN_BYTES = 24;
|
|
@@ -3917,7 +3927,7 @@ function skipVoid(ctx, banNewLines, banComments) {
|
|
|
3917
3927
|
skipComment(ctx);
|
|
3918
3928
|
}
|
|
3919
3929
|
}
|
|
3920
|
-
function skipUntil(ctx,
|
|
3930
|
+
function skipUntil(ctx, sep4, end) {
|
|
3921
3931
|
let ptr = ctx.p;
|
|
3922
3932
|
if (!end) {
|
|
3923
3933
|
ptr = indexOfNewline(ctx.s, ptr);
|
|
@@ -3928,7 +3938,7 @@ function skipUntil(ctx, sep3, end) {
|
|
|
3928
3938
|
let c = ctx.s.charCodeAt(ctx.p);
|
|
3929
3939
|
if (c === 35) {
|
|
3930
3940
|
skipComment(ctx);
|
|
3931
|
-
} else if (c === end || c ===
|
|
3941
|
+
} else if (c === end || c === sep4) {
|
|
3932
3942
|
return;
|
|
3933
3943
|
}
|
|
3934
3944
|
}
|
|
@@ -4747,7 +4757,7 @@ async function syncInferenceDirectory(path, platform = process.platform) {
|
|
|
4747
4757
|
async function replaceAtomicInferencePrivateFile(temporaryPath, destinationPath, options = {}) {
|
|
4748
4758
|
const platform = options.platform ?? process.platform;
|
|
4749
4759
|
const renameFile = options.renameFile ?? rename;
|
|
4750
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
4760
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => setTimeout(resolve17, milliseconds)));
|
|
4751
4761
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_CORE_POLICY.private_file_replace_attempts);
|
|
4752
4762
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_CORE_POLICY.private_file_replace_retry_delay_ms);
|
|
4753
4763
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -5977,10 +5987,10 @@ var init_abort = __esm({
|
|
|
5977
5987
|
}
|
|
5978
5988
|
};
|
|
5979
5989
|
abortableSleep = async (ms, signal) => {
|
|
5980
|
-
await new Promise((
|
|
5990
|
+
await new Promise((resolve17, reject) => {
|
|
5981
5991
|
const timer = setTimeout(() => {
|
|
5982
5992
|
cleanup();
|
|
5983
|
-
|
|
5993
|
+
resolve17(void 0);
|
|
5984
5994
|
}, ms);
|
|
5985
5995
|
const cleanup = () => {
|
|
5986
5996
|
clearTimeout(timer);
|
|
@@ -22757,6 +22767,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22757
22767
|
model_catalog_read_lead_divisor: 2,
|
|
22758
22768
|
agent_wake_summary_max_chars: 2e3,
|
|
22759
22769
|
drain_timeout_ms: 3e4,
|
|
22770
|
+
undispatched_adapter_failure_restart_threshold: 3,
|
|
22760
22771
|
remote_retry_limit: 3,
|
|
22761
22772
|
minimum_sleep_ms: 10,
|
|
22762
22773
|
heartbeat_gap_diagnostic_min_ms: 1e4,
|
|
@@ -23189,7 +23200,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
23189
23200
|
});
|
|
23190
23201
|
|
|
23191
23202
|
// lib/external-inference-contract.ts
|
|
23192
|
-
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, MAX_TURN_DECISION_OPERATION_IDS, SHA256_K, 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, claimResolutionSchema, httpStatusCodeSchema, hostClaimTransportFailureSchema, hostClaimTransportFailureReportSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, BATCH_JOB_CLAIM_RESULT_VERSION, clockedBatchedJobClaimSchema, 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, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
23203
|
+
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, MAX_TURN_DECISION_OPERATION_IDS, SHA256_K, 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, claimResolutionSchema, httpStatusCodeSchema, hostClaimTransportFailureSchema, hostClaimTransportFailureReportSchema, hostHeartbeatRequestSchema, jobClaimRequestBaseShape, jobClaimRequestSchema, emptyJobClaimSchema, claimedJobSchema, claimedDispatchIntentSchema, batchedJobClaimSchema, timedBatchedJobClaimSchema, BATCH_JOB_CLAIM_RESULT_VERSION, clockedBatchedJobClaimSchema, jobClaimResultSchema, attemptStartRequestSchema, jobHeartbeatRequestSchema, continueHeartbeatDirectiveSchema, cancelHeartbeatDirectiveSchema, jobHeartbeatResultSchema, adapterOutcomeEvidenceSchema, completionBaseShape, validateCompletion, providerResponseCompletionSchema, decisionCandidateCompletionSchema, jobCompleteRequestSchema, codexProcessExitDiagnosticsSchema, EXTERNAL_INFERENCE_FAILURE_FOLDER_ROLES, externalInferenceFailureDetailSchema, jobFailRequestSchema, jobCancelRequestSchema, jobCancellationReceiptSchema, jobDeliveryRequestSchema, deliveryBaseShape, validateDeliveryCandidate, providerResponseDeliverySchema, decisionCandidateDeliverySchema, jobDeliveryResultSchema, jobConsumptionRequestSchema, jobConsumptionReceiptSchema, jobStateSchema, jobStatusReadSchema, hostStatusReadSchema, nativeResearchEvidenceSourceSchema, externalAgentResearchEvidenceSourceSchema, researchEvidenceSourceSchema, reportedResearchTokenUsageSchema, unavailableResearchTokenUsageSchema, researchTokenUsageSchema, externalInferenceProductLineageBaseShape, traderExternalInferenceProductLineageSchema, decisionChatExternalInferenceProductLineageSchema, screenerExternalInferenceProductLineageSchema, externalInferenceProductLineageSchema, normalProductLinkageSchema, evidenceMaterializationMarkerSchema, deliveredExternalAgentSourceIdentitySchema, deliveredRequestEvidenceSchema, researchEvidenceBaseShape, researchEvidenceBaseSchema, validateExactUtf8, validateResearchEvidence, providerResponseResearchEvidenceSchema, decisionCandidateResearchEvidenceSchema, researchEvidenceSchema;
|
|
23193
23204
|
var init_external_inference_contract = __esm({
|
|
23194
23205
|
"lib/external-inference-contract.ts"() {
|
|
23195
23206
|
"use strict";
|
|
@@ -24161,7 +24172,8 @@ var init_external_inference_contract = __esm({
|
|
|
24161
24172
|
"service_update",
|
|
24162
24173
|
"drain_timeout",
|
|
24163
24174
|
"provider_dispatch_watchdog_expired",
|
|
24164
|
-
"receipt_durability_timeout"
|
|
24175
|
+
"receipt_durability_timeout",
|
|
24176
|
+
"adapter_setup_failed"
|
|
24165
24177
|
]).nullable(),
|
|
24166
24178
|
failure_code: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,95}$/u).nullable(),
|
|
24167
24179
|
pending_attempts: nonNegativeSafeIntegerSchema,
|
|
@@ -24503,6 +24515,14 @@ var init_external_inference_contract = __esm({
|
|
|
24503
24515
|
context.addIssue({ code: "custom", message: "truncated stderr diagnostics must report the observation cap", path: ["stderr_truncated"] });
|
|
24504
24516
|
}
|
|
24505
24517
|
});
|
|
24518
|
+
EXTERNAL_INFERENCE_FAILURE_FOLDER_ROLES = ["worker_folder", "job_folder", "temp_root", "other"];
|
|
24519
|
+
externalInferenceFailureDetailSchema = external_exports.strictObject({
|
|
24520
|
+
schema_version: external_exports.literal("external_inference_failure_detail_v1"),
|
|
24521
|
+
error_class: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length).regex(/^[A-Za-z][A-Za-z0-9_]*$/u),
|
|
24522
|
+
errno_code: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length).regex(/^[A-Z][A-Z0-9_]*$/u).nullable(),
|
|
24523
|
+
syscall: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.label_length).regex(/^[a-z][a-z0-9_]*$/u).nullable(),
|
|
24524
|
+
folder_role: external_exports.enum(EXTERNAL_INFERENCE_FAILURE_FOLDER_ROLES).nullable()
|
|
24525
|
+
});
|
|
24506
24526
|
jobFailRequestSchema = external_exports.strictObject({
|
|
24507
24527
|
schema_version: external_exports.literal("external_inference_job_fail_v1"),
|
|
24508
24528
|
contract_version: external_exports.literal(EXTERNAL_INFERENCE_CONTRACT_VERSION),
|
|
@@ -24534,6 +24554,7 @@ var init_external_inference_contract = __esm({
|
|
|
24534
24554
|
provider_http_status: external_exports.number().int().min(HTTP_CLIENT_ERROR_MIN).max(HTTP_STATUS_MAX).optional(),
|
|
24535
24555
|
grok_tool_validation: grokToolValidationDiagnosticSchema.optional(),
|
|
24536
24556
|
grok_response_identity: grokResponseIdentityDiagnosticSchema.optional(),
|
|
24557
|
+
failure_detail: externalInferenceFailureDetailSchema.optional(),
|
|
24537
24558
|
membership_disposition: external_exports.enum([
|
|
24538
24559
|
"retry_same_host",
|
|
24539
24560
|
"cascade_cooldown",
|
|
@@ -25392,7 +25413,7 @@ var init_credential_store = __esm({
|
|
|
25392
25413
|
}
|
|
25393
25414
|
return;
|
|
25394
25415
|
}
|
|
25395
|
-
await new Promise((
|
|
25416
|
+
await new Promise((resolve17) => {
|
|
25396
25417
|
const terminator = spawn3(
|
|
25397
25418
|
"taskkill.exe",
|
|
25398
25419
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -25410,21 +25431,21 @@ var init_credential_store = __esm({
|
|
|
25410
25431
|
const timer = setTimeout(() => {
|
|
25411
25432
|
terminator.kill("SIGKILL");
|
|
25412
25433
|
child.kill("SIGKILL");
|
|
25413
|
-
|
|
25434
|
+
resolve17();
|
|
25414
25435
|
}, CREDENTIAL_COMMAND_TERMINATION_TIMEOUT_MS);
|
|
25415
25436
|
terminator.once("error", () => {
|
|
25416
25437
|
clearTimeout(timer);
|
|
25417
25438
|
child.kill("SIGKILL");
|
|
25418
|
-
|
|
25439
|
+
resolve17();
|
|
25419
25440
|
});
|
|
25420
25441
|
terminator.once("close", () => {
|
|
25421
25442
|
clearTimeout(timer);
|
|
25422
25443
|
if (child.exitCode === null) child.kill("SIGKILL");
|
|
25423
|
-
|
|
25444
|
+
resolve17();
|
|
25424
25445
|
});
|
|
25425
25446
|
});
|
|
25426
25447
|
};
|
|
25427
|
-
runCredentialCommand = async (command, options) => await new Promise((
|
|
25448
|
+
runCredentialCommand = async (command, options) => await new Promise((resolve17, reject) => {
|
|
25428
25449
|
const timeoutMs = options.timeoutMs ?? DEFAULT_CREDENTIAL_COMMAND_TIMEOUT_MS;
|
|
25429
25450
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
25430
25451
|
reject(new Error("OS credential command timeout must be a positive integer."));
|
|
@@ -25483,7 +25504,7 @@ var init_credential_store = __esm({
|
|
|
25483
25504
|
const transformedStdout = normalizedExitCode === 0 ? command.transformStdout?.(stdout) ?? stdout : stdout;
|
|
25484
25505
|
settled2 = true;
|
|
25485
25506
|
cleanup();
|
|
25486
|
-
|
|
25507
|
+
resolve17({
|
|
25487
25508
|
exitCode: normalizedExitCode,
|
|
25488
25509
|
stdout: transformedStdout
|
|
25489
25510
|
});
|
|
@@ -26643,11 +26664,11 @@ async function revokeInferenceCredential(options) {
|
|
|
26643
26664
|
}
|
|
26644
26665
|
}
|
|
26645
26666
|
async function listenLoopback(server) {
|
|
26646
|
-
await new Promise((
|
|
26667
|
+
await new Promise((resolve17, reject) => {
|
|
26647
26668
|
server.once("error", reject);
|
|
26648
26669
|
server.listen(0, CALLBACK_HOST, () => {
|
|
26649
26670
|
server.off("error", reject);
|
|
26650
|
-
|
|
26671
|
+
resolve17();
|
|
26651
26672
|
});
|
|
26652
26673
|
});
|
|
26653
26674
|
const address = server.address();
|
|
@@ -26658,7 +26679,7 @@ async function listenLoopback(server) {
|
|
|
26658
26679
|
}
|
|
26659
26680
|
async function closeServer(server) {
|
|
26660
26681
|
if (!server.listening) return;
|
|
26661
|
-
await new Promise((
|
|
26682
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
26662
26683
|
}
|
|
26663
26684
|
async function beginInferenceOAuthLogin(options) {
|
|
26664
26685
|
const loginTimeoutMs = options.timeoutMs ?? HOST_CORE_POLICY2.oauth_login_timeout_ms;
|
|
@@ -26714,7 +26735,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
26714
26735
|
});
|
|
26715
26736
|
let settled2 = false;
|
|
26716
26737
|
let rejectCompletion;
|
|
26717
|
-
const completion = new Promise((
|
|
26738
|
+
const completion = new Promise((resolve17, reject) => {
|
|
26718
26739
|
rejectCompletion = reject;
|
|
26719
26740
|
handler = async (requestUrl2, method, writeResponse) => {
|
|
26720
26741
|
if (settled2) {
|
|
@@ -26789,7 +26810,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
26789
26810
|
'<!doctype html><html><head><meta charset="utf-8"><title>VTX authorization complete</title></head><body><main><h1>VTX authorization complete</h1><p>The VTX CLI received your approval. You can close this tab and return to the terminal.</p></main></body></html>'
|
|
26790
26811
|
);
|
|
26791
26812
|
await closeServer(server);
|
|
26792
|
-
|
|
26813
|
+
resolve17({
|
|
26793
26814
|
accessToken: tokens.accessToken,
|
|
26794
26815
|
expiresIn: tokens.expiresIn,
|
|
26795
26816
|
credential,
|
|
@@ -27646,6 +27667,7 @@ var init_mcp_client = __esm({
|
|
|
27646
27667
|
#claimTransportFailureReportsSupported = false;
|
|
27647
27668
|
#providerQuotaCooldownSupported = false;
|
|
27648
27669
|
#providerHttpStatusTools = /* @__PURE__ */ new Set();
|
|
27670
|
+
#failureDetailSupported = false;
|
|
27649
27671
|
#grokToolValidationTools = /* @__PURE__ */ new Set();
|
|
27650
27672
|
#grokResponseIdentityTools = /* @__PURE__ */ new Set();
|
|
27651
27673
|
async close() {
|
|
@@ -27690,6 +27712,18 @@ var init_mcp_client = __esm({
|
|
|
27690
27712
|
supportsRuntimeRecoveryDiagnostics() {
|
|
27691
27713
|
return this.#runtimeRecoveryDiagnosticsSupported;
|
|
27692
27714
|
}
|
|
27715
|
+
supportsFailureDetail() {
|
|
27716
|
+
return this.#failureDetailSupported;
|
|
27717
|
+
}
|
|
27718
|
+
async refreshFailureDetailSupport(options = {}) {
|
|
27719
|
+
if (this.supportsFailureDetail()) return true;
|
|
27720
|
+
try {
|
|
27721
|
+
await this.initialize(options);
|
|
27722
|
+
} catch {
|
|
27723
|
+
return false;
|
|
27724
|
+
}
|
|
27725
|
+
return this.supportsFailureDetail();
|
|
27726
|
+
}
|
|
27693
27727
|
supportsClaimTransportFailureReports() {
|
|
27694
27728
|
return this.#claimTransportFailureReportsSupported;
|
|
27695
27729
|
}
|
|
@@ -27846,6 +27880,7 @@ var init_mcp_client = __esm({
|
|
|
27846
27880
|
}
|
|
27847
27881
|
return Array.isArray(node.anyOf) && node.anyOf.some((branch) => advertisesDiagnosticReceipt(branch, field, depth + 1));
|
|
27848
27882
|
};
|
|
27883
|
+
this.#failureDetailSupported = advertisesFields("inference.job.fail", ["failure_detail"]);
|
|
27849
27884
|
this.#providerHttpStatusTools.clear();
|
|
27850
27885
|
if (advertisesFields("inference.job.fail", ["provider_http_status"])) {
|
|
27851
27886
|
this.#providerHttpStatusTools.add("inference.job.fail");
|
|
@@ -28878,51 +28913,51 @@ var require_uri_all = __commonJS({
|
|
|
28878
28913
|
}
|
|
28879
28914
|
return uriTokens.join("");
|
|
28880
28915
|
}
|
|
28881
|
-
function resolveComponents(base2,
|
|
28916
|
+
function resolveComponents(base2, relative6) {
|
|
28882
28917
|
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
28883
28918
|
var skipNormalization = arguments[3];
|
|
28884
28919
|
var target = {};
|
|
28885
28920
|
if (!skipNormalization) {
|
|
28886
28921
|
base2 = parse5(serialize(base2, options), options);
|
|
28887
|
-
|
|
28922
|
+
relative6 = parse5(serialize(relative6, options), options);
|
|
28888
28923
|
}
|
|
28889
28924
|
options = options || {};
|
|
28890
|
-
if (!options.tolerant &&
|
|
28891
|
-
target.scheme =
|
|
28892
|
-
target.userinfo =
|
|
28893
|
-
target.host =
|
|
28894
|
-
target.port =
|
|
28895
|
-
target.path = removeDotSegments(
|
|
28896
|
-
target.query =
|
|
28925
|
+
if (!options.tolerant && relative6.scheme) {
|
|
28926
|
+
target.scheme = relative6.scheme;
|
|
28927
|
+
target.userinfo = relative6.userinfo;
|
|
28928
|
+
target.host = relative6.host;
|
|
28929
|
+
target.port = relative6.port;
|
|
28930
|
+
target.path = removeDotSegments(relative6.path || "");
|
|
28931
|
+
target.query = relative6.query;
|
|
28897
28932
|
} else {
|
|
28898
|
-
if (
|
|
28899
|
-
target.userinfo =
|
|
28900
|
-
target.host =
|
|
28901
|
-
target.port =
|
|
28902
|
-
target.path = removeDotSegments(
|
|
28903
|
-
target.query =
|
|
28933
|
+
if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
|
|
28934
|
+
target.userinfo = relative6.userinfo;
|
|
28935
|
+
target.host = relative6.host;
|
|
28936
|
+
target.port = relative6.port;
|
|
28937
|
+
target.path = removeDotSegments(relative6.path || "");
|
|
28938
|
+
target.query = relative6.query;
|
|
28904
28939
|
} else {
|
|
28905
|
-
if (!
|
|
28940
|
+
if (!relative6.path) {
|
|
28906
28941
|
target.path = base2.path;
|
|
28907
|
-
if (
|
|
28908
|
-
target.query =
|
|
28942
|
+
if (relative6.query !== void 0) {
|
|
28943
|
+
target.query = relative6.query;
|
|
28909
28944
|
} else {
|
|
28910
28945
|
target.query = base2.query;
|
|
28911
28946
|
}
|
|
28912
28947
|
} else {
|
|
28913
|
-
if (
|
|
28914
|
-
target.path = removeDotSegments(
|
|
28948
|
+
if (relative6.path.charAt(0) === "/") {
|
|
28949
|
+
target.path = removeDotSegments(relative6.path);
|
|
28915
28950
|
} else {
|
|
28916
28951
|
if ((base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0) && !base2.path) {
|
|
28917
|
-
target.path = "/" +
|
|
28952
|
+
target.path = "/" + relative6.path;
|
|
28918
28953
|
} else if (!base2.path) {
|
|
28919
|
-
target.path =
|
|
28954
|
+
target.path = relative6.path;
|
|
28920
28955
|
} else {
|
|
28921
|
-
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) +
|
|
28956
|
+
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative6.path;
|
|
28922
28957
|
}
|
|
28923
28958
|
target.path = removeDotSegments(target.path);
|
|
28924
28959
|
}
|
|
28925
|
-
target.query =
|
|
28960
|
+
target.query = relative6.query;
|
|
28926
28961
|
}
|
|
28927
28962
|
target.userinfo = base2.userinfo;
|
|
28928
28963
|
target.host = base2.host;
|
|
@@ -28930,10 +28965,10 @@ var require_uri_all = __commonJS({
|
|
|
28930
28965
|
}
|
|
28931
28966
|
target.scheme = base2.scheme;
|
|
28932
28967
|
}
|
|
28933
|
-
target.fragment =
|
|
28968
|
+
target.fragment = relative6.fragment;
|
|
28934
28969
|
return target;
|
|
28935
28970
|
}
|
|
28936
|
-
function
|
|
28971
|
+
function resolve17(baseURI, relativeURI, options) {
|
|
28937
28972
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
28938
28973
|
return serialize(resolveComponents(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
28939
28974
|
}
|
|
@@ -29198,7 +29233,7 @@ var require_uri_all = __commonJS({
|
|
|
29198
29233
|
exports2.removeDotSegments = removeDotSegments;
|
|
29199
29234
|
exports2.serialize = serialize;
|
|
29200
29235
|
exports2.resolveComponents = resolveComponents;
|
|
29201
|
-
exports2.resolve =
|
|
29236
|
+
exports2.resolve = resolve17;
|
|
29202
29237
|
exports2.normalize = normalize;
|
|
29203
29238
|
exports2.equal = equal;
|
|
29204
29239
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -29575,18 +29610,18 @@ var require_resolve = __commonJS({
|
|
|
29575
29610
|
var util = require_util();
|
|
29576
29611
|
var SchemaObject = require_schema_obj();
|
|
29577
29612
|
var traverse = require_json_schema_traverse();
|
|
29578
|
-
module.exports =
|
|
29579
|
-
|
|
29580
|
-
|
|
29581
|
-
|
|
29582
|
-
|
|
29583
|
-
|
|
29584
|
-
|
|
29585
|
-
function
|
|
29613
|
+
module.exports = resolve17;
|
|
29614
|
+
resolve17.normalizeId = normalizeId;
|
|
29615
|
+
resolve17.fullPath = getFullPath;
|
|
29616
|
+
resolve17.url = resolveUrl;
|
|
29617
|
+
resolve17.ids = resolveIds;
|
|
29618
|
+
resolve17.inlineRef = inlineRef;
|
|
29619
|
+
resolve17.schema = resolveSchema;
|
|
29620
|
+
function resolve17(compile, root, ref) {
|
|
29586
29621
|
var refVal = this._refs[ref];
|
|
29587
29622
|
if (typeof refVal == "string") {
|
|
29588
29623
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
29589
|
-
else return
|
|
29624
|
+
else return resolve17.call(this, compile, root, refVal);
|
|
29590
29625
|
}
|
|
29591
29626
|
refVal = refVal || this._schemas[ref];
|
|
29592
29627
|
if (refVal instanceof SchemaObject) {
|
|
@@ -29795,7 +29830,7 @@ var require_error_classes = __commonJS({
|
|
|
29795
29830
|
init_define_VTX_EXO_POLICY();
|
|
29796
29831
|
init_define_VTX_GROK_POLICY();
|
|
29797
29832
|
init_define_VTX_PI_MODEL_POLICY();
|
|
29798
|
-
var
|
|
29833
|
+
var resolve17 = require_resolve();
|
|
29799
29834
|
module.exports = {
|
|
29800
29835
|
Validation: errorSubclass(ValidationError),
|
|
29801
29836
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -29810,8 +29845,8 @@ var require_error_classes = __commonJS({
|
|
|
29810
29845
|
};
|
|
29811
29846
|
function MissingRefError(baseId, ref, message) {
|
|
29812
29847
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
29813
|
-
this.missingRef =
|
|
29814
|
-
this.missingSchema =
|
|
29848
|
+
this.missingRef = resolve17.url(baseId, ref);
|
|
29849
|
+
this.missingSchema = resolve17.normalizeId(resolve17.fullPath(this.missingRef));
|
|
29815
29850
|
}
|
|
29816
29851
|
function errorSubclass(Subclass) {
|
|
29817
29852
|
Subclass.prototype = Object.create(Error.prototype);
|
|
@@ -30351,7 +30386,7 @@ var require_compile = __commonJS({
|
|
|
30351
30386
|
init_define_VTX_EXO_POLICY();
|
|
30352
30387
|
init_define_VTX_GROK_POLICY();
|
|
30353
30388
|
init_define_VTX_PI_MODEL_POLICY();
|
|
30354
|
-
var
|
|
30389
|
+
var resolve17 = require_resolve();
|
|
30355
30390
|
var util = require_util();
|
|
30356
30391
|
var errorClasses = require_error_classes();
|
|
30357
30392
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -30413,7 +30448,7 @@ var require_compile = __commonJS({
|
|
|
30413
30448
|
RULES: RULES2,
|
|
30414
30449
|
validate: validateGenerator,
|
|
30415
30450
|
util,
|
|
30416
|
-
resolve:
|
|
30451
|
+
resolve: resolve17,
|
|
30417
30452
|
resolveRef: resolveRef2,
|
|
30418
30453
|
usePattern,
|
|
30419
30454
|
useDefault,
|
|
@@ -30475,7 +30510,7 @@ var require_compile = __commonJS({
|
|
|
30475
30510
|
return validate;
|
|
30476
30511
|
}
|
|
30477
30512
|
function resolveRef2(baseId2, ref, isRoot) {
|
|
30478
|
-
ref =
|
|
30513
|
+
ref = resolve17.url(baseId2, ref);
|
|
30479
30514
|
var refIndex = refs[ref];
|
|
30480
30515
|
var _refVal, refCode;
|
|
30481
30516
|
if (refIndex !== void 0) {
|
|
@@ -30492,11 +30527,11 @@ var require_compile = __commonJS({
|
|
|
30492
30527
|
}
|
|
30493
30528
|
}
|
|
30494
30529
|
refCode = addLocalRef(ref);
|
|
30495
|
-
var v2 =
|
|
30530
|
+
var v2 = resolve17.call(self2, localCompile, root, ref);
|
|
30496
30531
|
if (v2 === void 0) {
|
|
30497
30532
|
var localSchema = localRefs && localRefs[ref];
|
|
30498
30533
|
if (localSchema) {
|
|
30499
|
-
v2 =
|
|
30534
|
+
v2 = resolve17.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
|
|
30500
30535
|
}
|
|
30501
30536
|
}
|
|
30502
30537
|
if (v2 === void 0) {
|
|
@@ -34245,7 +34280,7 @@ var require_ajv = __commonJS({
|
|
|
34245
34280
|
init_define_VTX_GROK_POLICY();
|
|
34246
34281
|
init_define_VTX_PI_MODEL_POLICY();
|
|
34247
34282
|
var compileSchema = require_compile();
|
|
34248
|
-
var
|
|
34283
|
+
var resolve17 = require_resolve();
|
|
34249
34284
|
var Cache = require_cache();
|
|
34250
34285
|
var SchemaObject = require_schema_obj();
|
|
34251
34286
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -34327,7 +34362,7 @@ var require_ajv = __commonJS({
|
|
|
34327
34362
|
var id2 = this._getId(schema);
|
|
34328
34363
|
if (id2 !== void 0 && typeof id2 != "string")
|
|
34329
34364
|
throw new Error("schema id must be string");
|
|
34330
|
-
key =
|
|
34365
|
+
key = resolve17.normalizeId(key || id2);
|
|
34331
34366
|
checkUnique(this, key);
|
|
34332
34367
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
34333
34368
|
return this;
|
|
@@ -34371,7 +34406,7 @@ var require_ajv = __commonJS({
|
|
|
34371
34406
|
}
|
|
34372
34407
|
}
|
|
34373
34408
|
function _getSchemaFragment(self2, ref) {
|
|
34374
|
-
var res =
|
|
34409
|
+
var res = resolve17.schema.call(self2, { schema: {} }, ref);
|
|
34375
34410
|
if (res) {
|
|
34376
34411
|
var schema = res.schema, root = res.root, baseId = res.baseId;
|
|
34377
34412
|
var v = compileSchema.call(self2, schema, root, void 0, baseId);
|
|
@@ -34387,7 +34422,7 @@ var require_ajv = __commonJS({
|
|
|
34387
34422
|
}
|
|
34388
34423
|
}
|
|
34389
34424
|
function _getSchemaObj(self2, keyRef) {
|
|
34390
|
-
keyRef =
|
|
34425
|
+
keyRef = resolve17.normalizeId(keyRef);
|
|
34391
34426
|
return self2._schemas[keyRef] || self2._refs[keyRef] || self2._fragments[keyRef];
|
|
34392
34427
|
}
|
|
34393
34428
|
function removeSchema(schemaKeyRef) {
|
|
@@ -34414,7 +34449,7 @@ var require_ajv = __commonJS({
|
|
|
34414
34449
|
this._cache.del(cacheKey);
|
|
34415
34450
|
var id2 = this._getId(schemaKeyRef);
|
|
34416
34451
|
if (id2) {
|
|
34417
|
-
id2 =
|
|
34452
|
+
id2 = resolve17.normalizeId(id2);
|
|
34418
34453
|
delete this._schemas[id2];
|
|
34419
34454
|
delete this._refs[id2];
|
|
34420
34455
|
}
|
|
@@ -34438,13 +34473,13 @@ var require_ajv = __commonJS({
|
|
|
34438
34473
|
var cached2 = this._cache.get(cacheKey);
|
|
34439
34474
|
if (cached2) return cached2;
|
|
34440
34475
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
34441
|
-
var id2 =
|
|
34476
|
+
var id2 = resolve17.normalizeId(this._getId(schema));
|
|
34442
34477
|
if (id2 && shouldAddSchema) checkUnique(this, id2);
|
|
34443
34478
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
34444
34479
|
var recursiveMeta;
|
|
34445
|
-
if (willValidate && !(recursiveMeta = id2 && id2 ==
|
|
34480
|
+
if (willValidate && !(recursiveMeta = id2 && id2 == resolve17.normalizeId(schema.$schema)))
|
|
34446
34481
|
this.validateSchema(schema, true);
|
|
34447
|
-
var localRefs =
|
|
34482
|
+
var localRefs = resolve17.ids.call(this, schema);
|
|
34448
34483
|
var schemaObj = new SchemaObject({
|
|
34449
34484
|
id: id2,
|
|
34450
34485
|
schema,
|
|
@@ -35064,7 +35099,7 @@ var init_codex_app_server = __esm({
|
|
|
35064
35099
|
};
|
|
35065
35100
|
};
|
|
35066
35101
|
killWindowsProcessTree = async (pid) => {
|
|
35067
|
-
await new Promise((
|
|
35102
|
+
await new Promise((resolve17, reject) => {
|
|
35068
35103
|
const child = spawn4(
|
|
35069
35104
|
"taskkill.exe",
|
|
35070
35105
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -35089,7 +35124,7 @@ var init_codex_app_server = __esm({
|
|
|
35089
35124
|
});
|
|
35090
35125
|
child.once("close", (code) => {
|
|
35091
35126
|
clearTimeout(timer);
|
|
35092
|
-
if (code === 0 || code === WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE)
|
|
35127
|
+
if (code === 0 || code === WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE) resolve17();
|
|
35093
35128
|
else reject(new Error("Windows Codex process-tree cleanup failed."));
|
|
35094
35129
|
});
|
|
35095
35130
|
});
|
|
@@ -35289,7 +35324,7 @@ child.once('close', async (code, signal) => {
|
|
|
35289
35324
|
const platform = options.platform ?? process.platform;
|
|
35290
35325
|
const renameFile = options.renameFile ?? rename3;
|
|
35291
35326
|
const removeFile = options.removeFile ?? ((path) => rm4(path, { force: true }));
|
|
35292
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
35327
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => setTimeout(resolve17, milliseconds)));
|
|
35293
35328
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_attempts);
|
|
35294
35329
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_retry_ms);
|
|
35295
35330
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -35381,7 +35416,7 @@ child.once('close', async (code, signal) => {
|
|
|
35381
35416
|
throw new Error("Codex guardian terminated before app-server initialization.");
|
|
35382
35417
|
}
|
|
35383
35418
|
}
|
|
35384
|
-
await new Promise((
|
|
35419
|
+
await new Promise((resolve17) => setTimeout(resolve17, HOST_RUNTIME_POLICY.codex_guardian_state_poll_ms));
|
|
35385
35420
|
}
|
|
35386
35421
|
throw new Error(`Codex guardian ${expectedState} state was not confirmed.`);
|
|
35387
35422
|
};
|
|
@@ -35766,8 +35801,8 @@ child.once('close', async (code, signal) => {
|
|
|
35766
35801
|
dispatchOutcome: "not_dispatched"
|
|
35767
35802
|
});
|
|
35768
35803
|
}
|
|
35769
|
-
return await new Promise((
|
|
35770
|
-
const pending3 = { resolve:
|
|
35804
|
+
return await new Promise((resolve17, reject) => {
|
|
35805
|
+
const pending3 = { resolve: resolve17, reject, timer: null, abortCleanup: null };
|
|
35771
35806
|
pending3.timer = setTimeout(() => {
|
|
35772
35807
|
this.pending.delete(id2);
|
|
35773
35808
|
this.retireResponseId(id2, method);
|
|
@@ -36442,8 +36477,8 @@ child.once('close', async (code, signal) => {
|
|
|
36442
36477
|
const agentWebSearches = [];
|
|
36443
36478
|
let terminalResolve;
|
|
36444
36479
|
let terminalReject;
|
|
36445
|
-
const terminalPromise = new Promise((
|
|
36446
|
-
terminalResolve =
|
|
36480
|
+
const terminalPromise = new Promise((resolve17, reject) => {
|
|
36481
|
+
terminalResolve = resolve17;
|
|
36447
36482
|
terminalReject = reject;
|
|
36448
36483
|
});
|
|
36449
36484
|
void terminalPromise.catch(() => void 0);
|
|
@@ -37003,15 +37038,15 @@ child.once('close', async (code, signal) => {
|
|
|
37003
37038
|
).catch(() => void 0);
|
|
37004
37039
|
}
|
|
37005
37040
|
this.process.stdin.end();
|
|
37006
|
-
const exited = await new Promise((
|
|
37041
|
+
const exited = await new Promise((resolve17) => {
|
|
37007
37042
|
if (this.process.exitCode !== null) {
|
|
37008
|
-
|
|
37043
|
+
resolve17(true);
|
|
37009
37044
|
return;
|
|
37010
37045
|
}
|
|
37011
|
-
const timer = setTimeout(() =>
|
|
37046
|
+
const timer = setTimeout(() => resolve17(false), HOST_RUNTIME_POLICY.codex_close_exit_timeout_ms);
|
|
37012
37047
|
this.process.once("close", () => {
|
|
37013
37048
|
clearTimeout(timer);
|
|
37014
|
-
|
|
37049
|
+
resolve17(true);
|
|
37015
37050
|
});
|
|
37016
37051
|
});
|
|
37017
37052
|
if (exited) return;
|
|
@@ -37022,11 +37057,11 @@ child.once('close', async (code, signal) => {
|
|
|
37022
37057
|
else this.process.kill("SIGTERM");
|
|
37023
37058
|
} catch {
|
|
37024
37059
|
}
|
|
37025
|
-
const terminated = await new Promise((
|
|
37026
|
-
const timer = setTimeout(() =>
|
|
37060
|
+
const terminated = await new Promise((resolve17) => {
|
|
37061
|
+
const timer = setTimeout(() => resolve17(false), HOST_RUNTIME_POLICY.codex_close_terminate_timeout_ms);
|
|
37027
37062
|
this.process.once("close", () => {
|
|
37028
37063
|
clearTimeout(timer);
|
|
37029
|
-
|
|
37064
|
+
resolve17(true);
|
|
37030
37065
|
});
|
|
37031
37066
|
});
|
|
37032
37067
|
if (!terminated) {
|
|
@@ -37036,15 +37071,15 @@ child.once('close', async (code, signal) => {
|
|
|
37036
37071
|
else this.process.kill("SIGKILL");
|
|
37037
37072
|
} catch {
|
|
37038
37073
|
}
|
|
37039
|
-
await new Promise((
|
|
37074
|
+
await new Promise((resolve17) => {
|
|
37040
37075
|
if (this.process.exitCode !== null) {
|
|
37041
|
-
|
|
37076
|
+
resolve17();
|
|
37042
37077
|
return;
|
|
37043
37078
|
}
|
|
37044
|
-
const timer = setTimeout(
|
|
37079
|
+
const timer = setTimeout(resolve17, HOST_RUNTIME_POLICY.codex_close_kill_timeout_ms);
|
|
37045
37080
|
this.process.once("close", () => {
|
|
37046
37081
|
clearTimeout(timer);
|
|
37047
|
-
|
|
37082
|
+
resolve17();
|
|
37048
37083
|
});
|
|
37049
37084
|
});
|
|
37050
37085
|
if (this.process.exitCode === null) {
|
|
@@ -37602,6 +37637,178 @@ var init_provider_credit = __esm({
|
|
|
37602
37637
|
}
|
|
37603
37638
|
});
|
|
37604
37639
|
|
|
37640
|
+
// lib/inference-host/attempt-failure.ts
|
|
37641
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
37642
|
+
import { dirname as dirname5, isAbsolute as isAbsolute5, relative as relative3, resolve as resolve4, sep as sep2 } from "node:path";
|
|
37643
|
+
var providerHttpStatus, PROVIDER_COOLDOWN_FAILURE_CODES, isProviderCooldownFailureCode, isProviderAccountFailureCode, terminalFailureRequiresManualRecovery, ambiguousHeartbeatTransport, retryableRemoteError, membershipFailureDisposition, safeFailureCode, classifyFailure, ERROR_CLASS_PATTERN, ERRNO_CODE_PATTERN, SYSCALL_PATTERN, failureFolderRole, boundedToken, isUnclassifiedFailureCode, attemptFailureDetail, ADAPTER_SETUP_FAILED_DRAIN_REASON, createUndispatchedAdapterFailureStreak;
|
|
37644
|
+
var init_attempt_failure = __esm({
|
|
37645
|
+
"lib/inference-host/attempt-failure.ts"() {
|
|
37646
|
+
"use strict";
|
|
37647
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
37648
|
+
init_define_VTX_EXO_POLICY();
|
|
37649
|
+
init_define_VTX_GROK_POLICY();
|
|
37650
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
37651
|
+
init_runtime_policy_generated();
|
|
37652
|
+
init_constants();
|
|
37653
|
+
init_external_inference_contract();
|
|
37654
|
+
init_provider_credit();
|
|
37655
|
+
init_codex_app_server();
|
|
37656
|
+
init_mcp_client();
|
|
37657
|
+
providerHttpStatus = (error48) => {
|
|
37658
|
+
if (!(error48 instanceof CodexAppServerError)) return null;
|
|
37659
|
+
const status = error48.httpStatusCode;
|
|
37660
|
+
return typeof status === "number" && Number.isInteger(status) && status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_STATUS_MAX ? status : null;
|
|
37661
|
+
};
|
|
37662
|
+
PROVIDER_COOLDOWN_FAILURE_CODES = ["quota_exceeded", "codex_rate_limited", "provider_rate_limited"];
|
|
37663
|
+
isProviderCooldownFailureCode = (code) => PROVIDER_COOLDOWN_FAILURE_CODES.includes(code);
|
|
37664
|
+
isProviderAccountFailureCode = (code) => isProviderCooldownFailureCode(code) || code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE;
|
|
37665
|
+
terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null || error48.grokResponseIdentity != null) && !error48.retryable && error48.category !== "auth" && !isProviderAccountFailureCode(error48.code);
|
|
37666
|
+
ambiguousHeartbeatTransport = (error48) => {
|
|
37667
|
+
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "";
|
|
37668
|
+
return [
|
|
37669
|
+
"network_error",
|
|
37670
|
+
"transport_rejected",
|
|
37671
|
+
"server_rejected",
|
|
37672
|
+
"rate_limited",
|
|
37673
|
+
"invalid_response",
|
|
37674
|
+
"identity_mismatch",
|
|
37675
|
+
"request_timeout",
|
|
37676
|
+
"authentication_timeout"
|
|
37677
|
+
].includes(code);
|
|
37678
|
+
};
|
|
37679
|
+
retryableRemoteError = (error48) => {
|
|
37680
|
+
if (error48 instanceof ExternalInferenceMcpError) {
|
|
37681
|
+
return error48.retryable;
|
|
37682
|
+
}
|
|
37683
|
+
if (error48 && typeof error48 === "object" && "retryable" in error48) {
|
|
37684
|
+
return error48.retryable === true;
|
|
37685
|
+
}
|
|
37686
|
+
return false;
|
|
37687
|
+
};
|
|
37688
|
+
membershipFailureDisposition = (failure2) => {
|
|
37689
|
+
if (failure2.dispatchOutcome === "outcome_unknown") return "quarantine_ambiguous";
|
|
37690
|
+
if (failure2.category === "auth" || ["auth_expired", "managed_chatgpt_auth_required", "invalid_account_metadata"].includes(failure2.code)) return "cascade_disable";
|
|
37691
|
+
if (failure2.category === "quota" || isProviderAccountFailureCode(failure2.code)) return "cascade_cooldown";
|
|
37692
|
+
if (failure2.code === "codex_server_overloaded") return "cascade_cooldown";
|
|
37693
|
+
if (failure2.retryable && (["adapter", "network", "transport"].includes(failure2.category) || failure2.code === "rpc_timeout")) return "retry_same_host";
|
|
37694
|
+
if (["model_unavailable", "reasoning_effort_unavailable"].includes(failure2.code)) return "cascade_cooldown";
|
|
37695
|
+
if ([
|
|
37696
|
+
"codex_http_connection_failed",
|
|
37697
|
+
"codex_response_stream_connection_failed",
|
|
37698
|
+
"codex_response_stream_disconnected",
|
|
37699
|
+
"codex_provider_retry_exhausted"
|
|
37700
|
+
].includes(failure2.code)) return "cascade_cooldown";
|
|
37701
|
+
return "fail_request";
|
|
37702
|
+
};
|
|
37703
|
+
safeFailureCode = (value, fallback) => {
|
|
37704
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/gu, "_").slice(0, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.long_code_length);
|
|
37705
|
+
return /^[a-z0-9]/u.test(normalized) ? normalized : fallback;
|
|
37706
|
+
};
|
|
37707
|
+
classifyFailure = (error48, result) => {
|
|
37708
|
+
if (error48 instanceof CodexAppServerError) {
|
|
37709
|
+
const category2 = error48.code === "quota_exceeded" || error48.code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE ? "quota" : error48.category;
|
|
37710
|
+
return {
|
|
37711
|
+
category: safeFailureCode(category2, "adapter"),
|
|
37712
|
+
code: safeFailureCode(error48.code, "adapter_failure"),
|
|
37713
|
+
retryable: error48.retryable,
|
|
37714
|
+
dispatchOutcome: error48.dispatchOutcome,
|
|
37715
|
+
effectiveModel: result?.effectiveModel ?? null,
|
|
37716
|
+
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
37717
|
+
};
|
|
37718
|
+
}
|
|
37719
|
+
if (error48 instanceof ExternalInferenceMcpError) {
|
|
37720
|
+
const category2 = error48.code.startsWith("authentication") ? "auth" : [
|
|
37721
|
+
"network_error",
|
|
37722
|
+
"transport_rejected",
|
|
37723
|
+
"server_rejected",
|
|
37724
|
+
"rate_limited",
|
|
37725
|
+
"request_timeout"
|
|
37726
|
+
].includes(error48.code) ? "network" : "transport";
|
|
37727
|
+
return {
|
|
37728
|
+
category: category2,
|
|
37729
|
+
code: safeFailureCode(error48.code, "transport_failure"),
|
|
37730
|
+
retryable: retryableRemoteError(error48),
|
|
37731
|
+
dispatchOutcome: "not_dispatched",
|
|
37732
|
+
effectiveModel: null,
|
|
37733
|
+
effectiveEffort: null
|
|
37734
|
+
};
|
|
37735
|
+
}
|
|
37736
|
+
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "adapter_failure";
|
|
37737
|
+
const category = code.includes("model") ? "model" : code.includes("schema") || code.includes("output") ? "schema" : code.includes("cancel") ? "cancelled" : code.includes("timeout") || code.includes("deadline") ? "timeout" : code.includes("auth") ? "auth" : code.includes("quota") ? "quota" : code.includes("network") ? "network" : "adapter";
|
|
37738
|
+
return {
|
|
37739
|
+
category,
|
|
37740
|
+
code: safeFailureCode(code, "adapter_failure"),
|
|
37741
|
+
retryable: error48 && typeof error48 === "object" && "retryable" in error48 ? error48.retryable === true : false,
|
|
37742
|
+
dispatchOutcome: result ? "confirmed_dispatched" : "not_dispatched",
|
|
37743
|
+
effectiveModel: result?.effectiveModel ?? null,
|
|
37744
|
+
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
37745
|
+
};
|
|
37746
|
+
};
|
|
37747
|
+
ERROR_CLASS_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/u;
|
|
37748
|
+
ERRNO_CODE_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
|
|
37749
|
+
SYSCALL_PATTERN = /^[a-z][a-z0-9_]*$/u;
|
|
37750
|
+
failureFolderRole = (path, syscall) => {
|
|
37751
|
+
const scoped = relative3(resolve4(tmpdir2()), resolve4(syscall === "mkdtemp" ? dirname5(path) : path));
|
|
37752
|
+
if (scoped === "") return "temp_root";
|
|
37753
|
+
if (scoped === ".." || scoped.startsWith(`..${sep2}`) || isAbsolute5(scoped)) return "other";
|
|
37754
|
+
const parts = scoped.split(sep2);
|
|
37755
|
+
const [top = "", jobs, job = ""] = parts;
|
|
37756
|
+
if (top.startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_PREFIX)) {
|
|
37757
|
+
return parts.length >= CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS && jobs === INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS && job.startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_HOSTED_JOB_PREFIX) ? "job_folder" : "worker_folder";
|
|
37758
|
+
}
|
|
37759
|
+
return [
|
|
37760
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX,
|
|
37761
|
+
INFERENCE_HOST_TEMP_FOLDERS.COPILOT_JOB_PREFIX,
|
|
37762
|
+
INFERENCE_HOST_TEMP_FOLDERS.DEEPSEEK_JOB_PREFIX
|
|
37763
|
+
].some((prefix) => top.startsWith(prefix)) ? "job_folder" : "other";
|
|
37764
|
+
};
|
|
37765
|
+
boundedToken = (value, pattern, maxLength) => typeof value === "string" && value.length <= maxLength && pattern.test(value) ? value : null;
|
|
37766
|
+
isUnclassifiedFailureCode = (code) => typeof code === "string" && (code === "adapter_failure" || code.endsWith("_adapter_failure"));
|
|
37767
|
+
attemptFailureDetail = (error48) => {
|
|
37768
|
+
if (error48 instanceof ExternalInferenceMcpError) return null;
|
|
37769
|
+
if (error48 instanceof CodexAppServerError ? !isUnclassifiedFailureCode(error48.code) : error48 !== null && typeof error48 === "object" && typeof error48.code === "string" && /^[a-z]/u.test(error48.code)) return null;
|
|
37770
|
+
let cause = error48;
|
|
37771
|
+
const seen = /* @__PURE__ */ new Set([cause]);
|
|
37772
|
+
for (let depth = 0; depth < INFERENCE_HOST_FAILURE_CAUSE_MAX_DEPTH; depth += 1) {
|
|
37773
|
+
const next = cause instanceof Error ? cause.cause : void 0;
|
|
37774
|
+
if (next === void 0 || next === null || seen.has(next)) break;
|
|
37775
|
+
seen.add(next);
|
|
37776
|
+
cause = next;
|
|
37777
|
+
}
|
|
37778
|
+
if (cause instanceof CodexAppServerError || cause instanceof ExternalInferenceMcpError) return null;
|
|
37779
|
+
const record6 = cause !== null && typeof cause === "object" ? cause : {};
|
|
37780
|
+
const syscall = boundedToken(record6.syscall, SYSCALL_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.label_length);
|
|
37781
|
+
const parsed = externalInferenceFailureDetailSchema.safeParse({
|
|
37782
|
+
schema_version: "external_inference_failure_detail_v1",
|
|
37783
|
+
error_class: cause instanceof Error ? boundedToken(cause.constructor?.name, ERROR_CLASS_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length) ?? boundedToken(cause.name, ERROR_CLASS_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length) ?? "Error" : "NonError",
|
|
37784
|
+
errno_code: boundedToken(record6.code, ERRNO_CODE_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length),
|
|
37785
|
+
syscall,
|
|
37786
|
+
folder_role: typeof record6.path === "string" ? failureFolderRole(record6.path, syscall) : null
|
|
37787
|
+
});
|
|
37788
|
+
if (!parsed.success) return null;
|
|
37789
|
+
const { error_class: errorClass, errno_code: errnoCode, folder_role: folderRole } = parsed.data;
|
|
37790
|
+
return errorClass === "Error" && errnoCode === null && syscall === null && folderRole === null ? null : parsed.data;
|
|
37791
|
+
};
|
|
37792
|
+
ADAPTER_SETUP_FAILED_DRAIN_REASON = "adapter_setup_failed";
|
|
37793
|
+
createUndispatchedAdapterFailureStreak = (threshold2 = runtime_policy_generated_default.external_inference.host_runtime.undispatched_adapter_failure_restart_threshold) => {
|
|
37794
|
+
let count5 = 0;
|
|
37795
|
+
return {
|
|
37796
|
+
/** Records one finished attempt; true once the run reaches the threshold. */
|
|
37797
|
+
observe: (outcome) => {
|
|
37798
|
+
if (outcome.outcome === "completed" || typeof outcome.dispatch_outcome === "string" && outcome.dispatch_outcome !== "not_dispatched") {
|
|
37799
|
+
count5 = 0;
|
|
37800
|
+
return false;
|
|
37801
|
+
}
|
|
37802
|
+
if (outcome.outcome !== "failed" || outcome.failure_category !== "adapter" || !(isUnclassifiedFailureCode(outcome.failure_code) || (outcome.failure_detail ?? null) !== null)) return false;
|
|
37803
|
+
count5 += 1;
|
|
37804
|
+
return count5 >= threshold2;
|
|
37805
|
+
},
|
|
37806
|
+
count: () => count5
|
|
37807
|
+
};
|
|
37808
|
+
};
|
|
37809
|
+
}
|
|
37810
|
+
});
|
|
37811
|
+
|
|
37605
37812
|
// lib/inference-host/runner.ts
|
|
37606
37813
|
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
37607
37814
|
function createDefaultInferenceHostRunnerDependencies(options) {
|
|
@@ -37639,7 +37846,7 @@ function createDefaultInferenceHostRunnerDependencies(options) {
|
|
|
37639
37846
|
envelopePublicKey: options.envelopePublicKey
|
|
37640
37847
|
};
|
|
37641
37848
|
}
|
|
37642
|
-
var import_ajv,
|
|
37849
|
+
var import_ajv, canReplayFencedAgentTerminal, fencedTurnAwaitsAssignmentCheck, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, HOST_RUNTIME_POLICY2, CLAIM_DISPATCH_BATCH_SIZE, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_AUTH_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, usableProviderQuotaSnapshot, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
|
|
37643
37850
|
var init_runner = __esm({
|
|
37644
37851
|
"lib/inference-host/runner.ts"() {
|
|
37645
37852
|
"use strict";
|
|
@@ -37660,16 +37867,7 @@ var init_runner = __esm({
|
|
|
37660
37867
|
init_agent_answer();
|
|
37661
37868
|
init_config2();
|
|
37662
37869
|
init_oauth();
|
|
37663
|
-
|
|
37664
|
-
providerHttpStatus = (error48) => {
|
|
37665
|
-
if (!(error48 instanceof CodexAppServerError)) return null;
|
|
37666
|
-
const status = error48.httpStatusCode;
|
|
37667
|
-
return typeof status === "number" && Number.isInteger(status) && status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_STATUS_MAX ? status : null;
|
|
37668
|
-
};
|
|
37669
|
-
PROVIDER_COOLDOWN_FAILURE_CODES = ["quota_exceeded", "codex_rate_limited", "provider_rate_limited"];
|
|
37670
|
-
isProviderCooldownFailureCode = (code) => PROVIDER_COOLDOWN_FAILURE_CODES.includes(code);
|
|
37671
|
-
isProviderAccountFailureCode = (code) => isProviderCooldownFailureCode(code) || code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE;
|
|
37672
|
-
terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null || error48.grokResponseIdentity != null) && !error48.retryable && error48.category !== "auth" && !isProviderAccountFailureCode(error48.code);
|
|
37870
|
+
init_attempt_failure();
|
|
37673
37871
|
canReplayFencedAgentTerminal = (state2, fence) => state2?.schema_version === "vtx_inference_agent_runtime_v3" && state2.adapter_id === fence.adapter_id && state2.host_id === fence.host_id && state2.assignment.assignment_id === fence.assignment_id && state2.pending_turn?.terminal_receipt?.terminal_status === "failed" && state2.pending_turn.terminal_receipt.failure_code === fence.failure_code && (fence.dispatch_outcome !== "outcome_unknown" || (state2.pending_turn.terminal_receipt.grok_tool_validation?.prior_dispatch === true || state2.pending_turn.terminal_receipt.grok_response_identity != null || state2.pending_turn.terminal_receipt.provider_http_status !== void 0) && state2.pending_turn.terminal_receipt.dispatch_outcome === "outcome_unknown");
|
|
37674
37872
|
fencedTurnAwaitsAssignmentCheck = (state2, fence) => fence.failure_code === "agent_turn_outcome_unknown" && state2?.schema_version === "vtx_inference_agent_runtime_v3" && state2.adapter_id === fence.adapter_id && state2.host_id === fence.host_id && state2.assignment.assignment_id === fence.assignment_id && state2.pending_turn != null && !state2.pending_turn.terminal_receipt;
|
|
37675
37873
|
RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
|
|
@@ -37808,13 +38006,13 @@ var init_runner = __esm({
|
|
|
37808
38006
|
};
|
|
37809
38007
|
defaultSleep = async (milliseconds, signal) => {
|
|
37810
38008
|
if (signal?.aborted) throw abortError();
|
|
37811
|
-
await new Promise((
|
|
38009
|
+
await new Promise((resolve17, reject) => {
|
|
37812
38010
|
const finish = (callback) => {
|
|
37813
38011
|
signal?.removeEventListener("abort", onAbort);
|
|
37814
38012
|
callback();
|
|
37815
38013
|
};
|
|
37816
38014
|
const timer = setTimeout(
|
|
37817
|
-
() => finish(
|
|
38015
|
+
() => finish(resolve17),
|
|
37818
38016
|
Math.max(MIN_SLEEP_MS, milliseconds)
|
|
37819
38017
|
);
|
|
37820
38018
|
const onAbort = () => {
|
|
@@ -37840,9 +38038,9 @@ var init_runner = __esm({
|
|
|
37840
38038
|
let timer = null;
|
|
37841
38039
|
const settled2 = await Promise.race([
|
|
37842
38040
|
promise2.then(() => true, () => true),
|
|
37843
|
-
new Promise((
|
|
38041
|
+
new Promise((resolve17) => {
|
|
37844
38042
|
timer = setTimeout(
|
|
37845
|
-
() =>
|
|
38043
|
+
() => resolve17(false),
|
|
37846
38044
|
Math.max(MIN_SLEEP_MS, timeoutMs)
|
|
37847
38045
|
);
|
|
37848
38046
|
})
|
|
@@ -38107,15 +38305,6 @@ var init_runner = __esm({
|
|
|
38107
38305
|
);
|
|
38108
38306
|
}
|
|
38109
38307
|
};
|
|
38110
|
-
retryableRemoteError = (error48) => {
|
|
38111
|
-
if (error48 instanceof ExternalInferenceMcpError) {
|
|
38112
|
-
return error48.retryable;
|
|
38113
|
-
}
|
|
38114
|
-
if (error48 && typeof error48 === "object" && "retryable" in error48) {
|
|
38115
|
-
return error48.retryable === true;
|
|
38116
|
-
}
|
|
38117
|
-
return false;
|
|
38118
|
-
};
|
|
38119
38308
|
remoteRetryAfterMs = (error48, fallbackMs) => error48 instanceof ExternalInferenceMcpError && error48.retryAfterMs !== null && Number.isSafeInteger(error48.retryAfterMs) && error48.retryAfterMs >= 0 ? Math.max(fallbackMs, error48.retryAfterMs) : fallbackMs;
|
|
38120
38309
|
controlPlaneFatal = (error48) => {
|
|
38121
38310
|
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "";
|
|
@@ -38271,25 +38460,6 @@ var init_runner = __esm({
|
|
|
38271
38460
|
}
|
|
38272
38461
|
return notAfterMs;
|
|
38273
38462
|
};
|
|
38274
|
-
membershipFailureDisposition = (failure2) => {
|
|
38275
|
-
if (failure2.dispatchOutcome === "outcome_unknown") return "quarantine_ambiguous";
|
|
38276
|
-
if (failure2.category === "auth" || ["auth_expired", "managed_chatgpt_auth_required", "invalid_account_metadata"].includes(failure2.code)) return "cascade_disable";
|
|
38277
|
-
if (failure2.category === "quota" || isProviderAccountFailureCode(failure2.code)) return "cascade_cooldown";
|
|
38278
|
-
if (failure2.code === "codex_server_overloaded") return "cascade_cooldown";
|
|
38279
|
-
if (failure2.retryable && (["adapter", "network", "transport"].includes(failure2.category) || failure2.code === "rpc_timeout")) return "retry_same_host";
|
|
38280
|
-
if (["model_unavailable", "reasoning_effort_unavailable"].includes(failure2.code)) return "cascade_cooldown";
|
|
38281
|
-
if ([
|
|
38282
|
-
"codex_http_connection_failed",
|
|
38283
|
-
"codex_response_stream_connection_failed",
|
|
38284
|
-
"codex_response_stream_disconnected",
|
|
38285
|
-
"codex_provider_retry_exhausted"
|
|
38286
|
-
].includes(failure2.code)) return "cascade_cooldown";
|
|
38287
|
-
return "fail_request";
|
|
38288
|
-
};
|
|
38289
|
-
safeFailureCode = (value, fallback) => {
|
|
38290
|
-
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/gu, "_").slice(0, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.long_code_length);
|
|
38291
|
-
return /^[a-z0-9]/u.test(normalized) ? normalized : fallback;
|
|
38292
|
-
};
|
|
38293
38463
|
publicServerFailureCode = (value) => value !== null && /^[a-z0-9][a-z0-9._-]{0,95}$/u.test(value) ? value : null;
|
|
38294
38464
|
attemptStartRetryFallbackMs = (retryCount) => Math.min(
|
|
38295
38465
|
HOST_RUNTIME_POLICY2.attempt_start_retry_base_ms * BACKOFF_GROWTH_FACTOR ** Math.min(Math.max(0, retryCount - 1), HOST_RUNTIME_POLICY2.attempt_start_retry_exponent_max),
|
|
@@ -38333,59 +38503,6 @@ var init_runner = __esm({
|
|
|
38333
38503
|
}
|
|
38334
38504
|
};
|
|
38335
38505
|
isDefinitiveCompletionEvidenceExpiry = (error48, terminal) => terminal?.schema_version === "external_inference_job_complete_v1" && error48 instanceof ExternalInferenceMcpError && error48.code === "completion_evidence_expired" && error48.definitivelyNotApplied;
|
|
38336
|
-
classifyFailure = (error48, result) => {
|
|
38337
|
-
if (error48 instanceof CodexAppServerError) {
|
|
38338
|
-
const category2 = error48.code === "quota_exceeded" || error48.code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE ? "quota" : error48.category;
|
|
38339
|
-
return {
|
|
38340
|
-
category: safeFailureCode(category2, "adapter"),
|
|
38341
|
-
code: safeFailureCode(error48.code, "adapter_failure"),
|
|
38342
|
-
retryable: error48.retryable,
|
|
38343
|
-
dispatchOutcome: error48.dispatchOutcome,
|
|
38344
|
-
effectiveModel: result?.effectiveModel ?? null,
|
|
38345
|
-
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
38346
|
-
};
|
|
38347
|
-
}
|
|
38348
|
-
if (error48 instanceof ExternalInferenceMcpError) {
|
|
38349
|
-
const category2 = error48.code.startsWith("authentication") ? "auth" : [
|
|
38350
|
-
"network_error",
|
|
38351
|
-
"transport_rejected",
|
|
38352
|
-
"server_rejected",
|
|
38353
|
-
"rate_limited",
|
|
38354
|
-
"request_timeout"
|
|
38355
|
-
].includes(error48.code) ? "network" : "transport";
|
|
38356
|
-
return {
|
|
38357
|
-
category: category2,
|
|
38358
|
-
code: safeFailureCode(error48.code, "transport_failure"),
|
|
38359
|
-
retryable: retryableRemoteError(error48),
|
|
38360
|
-
dispatchOutcome: "not_dispatched",
|
|
38361
|
-
effectiveModel: null,
|
|
38362
|
-
effectiveEffort: null
|
|
38363
|
-
};
|
|
38364
|
-
}
|
|
38365
|
-
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "adapter_failure";
|
|
38366
|
-
const category = code.includes("model") ? "model" : code.includes("schema") || code.includes("output") ? "schema" : code.includes("cancel") ? "cancelled" : code.includes("timeout") || code.includes("deadline") ? "timeout" : code.includes("auth") ? "auth" : code.includes("quota") ? "quota" : code.includes("network") ? "network" : "adapter";
|
|
38367
|
-
return {
|
|
38368
|
-
category,
|
|
38369
|
-
code: safeFailureCode(code, "adapter_failure"),
|
|
38370
|
-
retryable: error48 && typeof error48 === "object" && "retryable" in error48 ? error48.retryable === true : false,
|
|
38371
|
-
dispatchOutcome: result ? "confirmed_dispatched" : "not_dispatched",
|
|
38372
|
-
effectiveModel: result?.effectiveModel ?? null,
|
|
38373
|
-
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
38374
|
-
};
|
|
38375
|
-
};
|
|
38376
|
-
ambiguousHeartbeatTransport = (error48) => {
|
|
38377
|
-
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "";
|
|
38378
|
-
return [
|
|
38379
|
-
"network_error",
|
|
38380
|
-
"transport_rejected",
|
|
38381
|
-
"server_rejected",
|
|
38382
|
-
"rate_limited",
|
|
38383
|
-
"invalid_response",
|
|
38384
|
-
"identity_mismatch",
|
|
38385
|
-
"request_timeout",
|
|
38386
|
-
"authentication_timeout"
|
|
38387
|
-
].includes(code);
|
|
38388
|
-
};
|
|
38389
38506
|
reportedTokenUsage = (usage, source = "codex_app_server") => ({
|
|
38390
38507
|
schema_version: EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION,
|
|
38391
38508
|
availability: "reported",
|
|
@@ -38420,10 +38537,19 @@ var init_runner = __esm({
|
|
|
38420
38537
|
let removeQuiesceListener = () => {
|
|
38421
38538
|
};
|
|
38422
38539
|
let quiesceRequested = Boolean(this.options.quiesceSignal?.aborted);
|
|
38540
|
+
let quiesceDrainReason = "service_update";
|
|
38423
38541
|
let wakeQuiesce;
|
|
38424
|
-
const quiesceWake = new Promise((
|
|
38425
|
-
wakeQuiesce =
|
|
38426
|
-
});
|
|
38542
|
+
const quiesceWake = new Promise((resolve17) => {
|
|
38543
|
+
wakeQuiesce = resolve17;
|
|
38544
|
+
});
|
|
38545
|
+
const quiesceAbort = new AbortController();
|
|
38546
|
+
const requestQuiesce = (reason) => {
|
|
38547
|
+
if (quiesceRequested) return;
|
|
38548
|
+
quiesceDrainReason = reason;
|
|
38549
|
+
quiesceRequested = true;
|
|
38550
|
+
quiesceAbort.abort();
|
|
38551
|
+
wakeQuiesce();
|
|
38552
|
+
};
|
|
38427
38553
|
let drainRequested = false;
|
|
38428
38554
|
let drainReason = "stopped";
|
|
38429
38555
|
let terminalRecoveryFailureCode = null;
|
|
@@ -38458,13 +38584,14 @@ var init_runner = __esm({
|
|
|
38458
38584
|
};
|
|
38459
38585
|
let hostHeartbeatLoop = Promise.resolve();
|
|
38460
38586
|
let providerDispatchWatchdogDrainRequested = false;
|
|
38587
|
+
const adapterFailureStreak = createUndispatchedAdapterFailureStreak();
|
|
38461
38588
|
const agentAbort = new AbortController();
|
|
38462
38589
|
let agentLoop = Promise.resolve();
|
|
38463
38590
|
let modelCatalogRefresh = null;
|
|
38464
38591
|
let providerRateLimitRefresh = null;
|
|
38465
38592
|
let wakeDrain;
|
|
38466
|
-
const drainSignal = new Promise((
|
|
38467
|
-
wakeDrain =
|
|
38593
|
+
const drainSignal = new Promise((resolve17) => {
|
|
38594
|
+
wakeDrain = resolve17;
|
|
38468
38595
|
});
|
|
38469
38596
|
const requestDrain = (reason) => {
|
|
38470
38597
|
const priority = (value) => {
|
|
@@ -38482,10 +38609,7 @@ var init_runner = __esm({
|
|
|
38482
38609
|
wakeDrain();
|
|
38483
38610
|
};
|
|
38484
38611
|
try {
|
|
38485
|
-
const onQuiesce = () =>
|
|
38486
|
-
quiesceRequested = true;
|
|
38487
|
-
wakeQuiesce();
|
|
38488
|
-
};
|
|
38612
|
+
const onQuiesce = () => requestQuiesce("service_update");
|
|
38489
38613
|
this.options.quiesceSignal?.addEventListener("abort", onQuiesce, { once: true });
|
|
38490
38614
|
removeQuiesceListener = () => this.options.quiesceSignal?.removeEventListener("abort", onQuiesce);
|
|
38491
38615
|
if (quiesceRequested) return { claimed, completed, failed: failed2, drain_reason: "service_update" };
|
|
@@ -38592,7 +38716,7 @@ var init_runner = __esm({
|
|
|
38592
38716
|
await mcp.initialize({ signal: this.options.signal });
|
|
38593
38717
|
if (settings.agentRuntime) {
|
|
38594
38718
|
const agentRuntimeSettings = settings.agentRuntime;
|
|
38595
|
-
const agentIdleSignal =
|
|
38719
|
+
const agentIdleSignal = AbortSignal.any([agentAbort.signal, quiesceAbort.signal]);
|
|
38596
38720
|
agentLoop = (async () => {
|
|
38597
38721
|
while (!agentAbort.signal.aborted && !quiesceRequested) {
|
|
38598
38722
|
const existingFence = await readInferenceAgentFailureFence(
|
|
@@ -38643,7 +38767,7 @@ var init_runner = __esm({
|
|
|
38643
38767
|
controlClient: createInferenceAgentControlClient(mcp),
|
|
38644
38768
|
adapter: agentRuntimeSettings.adapter,
|
|
38645
38769
|
dataRequestTimeoutMs: agentRuntimeSettings.dataRequestTimeoutMs,
|
|
38646
|
-
quiesceSignal:
|
|
38770
|
+
quiesceSignal: quiesceAbort.signal
|
|
38647
38771
|
});
|
|
38648
38772
|
try {
|
|
38649
38773
|
if (this.options.once) {
|
|
@@ -38839,8 +38963,8 @@ var init_runner = __esm({
|
|
|
38839
38963
|
receipt = result;
|
|
38840
38964
|
const revision = receiptRevision + 1;
|
|
38841
38965
|
receiptRevision = revision;
|
|
38842
|
-
const durable = new Promise((
|
|
38843
|
-
receiptDurabilityWaiters.push({ revision, resolve:
|
|
38966
|
+
const durable = new Promise((resolve17, reject) => {
|
|
38967
|
+
receiptDurabilityWaiters.push({ revision, resolve: resolve17, reject });
|
|
38844
38968
|
});
|
|
38845
38969
|
scheduleReceiptWriter();
|
|
38846
38970
|
await durable;
|
|
@@ -38956,8 +39080,8 @@ var init_runner = __esm({
|
|
|
38956
39080
|
const tool = receipt.registered ? "inference.host.advertise" : "inference.host.register";
|
|
38957
39081
|
let result;
|
|
38958
39082
|
let releaseAdvertisementHandoff;
|
|
38959
|
-
const currentAdvertisementHandoff = new Promise((
|
|
38960
|
-
releaseAdvertisementHandoff =
|
|
39083
|
+
const currentAdvertisementHandoff = new Promise((resolve17) => {
|
|
39084
|
+
releaseAdvertisementHandoff = resolve17;
|
|
38961
39085
|
});
|
|
38962
39086
|
advertisementHandoff = currentAdvertisementHandoff;
|
|
38963
39087
|
try {
|
|
@@ -39504,6 +39628,14 @@ var init_runner = __esm({
|
|
|
39504
39628
|
attempt_id: attemptId,
|
|
39505
39629
|
active_attempts: active.size
|
|
39506
39630
|
});
|
|
39631
|
+
if (!adapterFailureStreak.observe(outcome) || quiesceRequested) return;
|
|
39632
|
+
emitDiagnostic("worker_restart_requested", {
|
|
39633
|
+
reason: ADAPTER_SETUP_FAILED_DRAIN_REASON,
|
|
39634
|
+
consecutive_failures: adapterFailureStreak.count(),
|
|
39635
|
+
failure_code: outcome.failure_code,
|
|
39636
|
+
failure_detail: outcome.failure_detail ?? null
|
|
39637
|
+
});
|
|
39638
|
+
requestQuiesce(ADAPTER_SETUP_FAILED_DRAIN_REASON);
|
|
39507
39639
|
},
|
|
39508
39640
|
onProviderDispatch: (observation) => {
|
|
39509
39641
|
emitDiagnostic("provider_dispatch_freshness_passed", {
|
|
@@ -40153,7 +40285,7 @@ var init_runner = __esm({
|
|
|
40153
40285
|
}
|
|
40154
40286
|
if (quiesceRequested && !drainRequested) {
|
|
40155
40287
|
await Promise.race([Promise.allSettled([...active.values(), agentLoop]), drainSignal]);
|
|
40156
|
-
if (!drainRequested) requestDrain(
|
|
40288
|
+
if (!drainRequested) requestDrain(quiesceDrainReason);
|
|
40157
40289
|
}
|
|
40158
40290
|
stopHostHeartbeatLoop();
|
|
40159
40291
|
if (providerDispatchWatchdogDrainRequested) {
|
|
@@ -40312,8 +40444,8 @@ var init_runner = __esm({
|
|
|
40312
40444
|
let providerDispatchWatchdog = null;
|
|
40313
40445
|
let providerDispatchWatchdogExpired = false;
|
|
40314
40446
|
let resolveProviderDispatchWatchdog;
|
|
40315
|
-
const providerDispatchWatchdogSignal = new Promise((
|
|
40316
|
-
resolveProviderDispatchWatchdog =
|
|
40447
|
+
const providerDispatchWatchdogSignal = new Promise((resolve17) => {
|
|
40448
|
+
resolveProviderDispatchWatchdog = resolve17;
|
|
40317
40449
|
});
|
|
40318
40450
|
const clearProviderDispatchWatchdog = () => {
|
|
40319
40451
|
if (providerDispatchWatchdog !== null) clearTimeout(providerDispatchWatchdog);
|
|
@@ -40750,8 +40882,8 @@ var init_runner = __esm({
|
|
|
40750
40882
|
});
|
|
40751
40883
|
}
|
|
40752
40884
|
let resolveTerminalDispatchOutcome;
|
|
40753
|
-
const terminalDispatchOutcomeSignal = new Promise((
|
|
40754
|
-
resolveTerminalDispatchOutcome =
|
|
40885
|
+
const terminalDispatchOutcomeSignal = new Promise((resolve17) => {
|
|
40886
|
+
resolveTerminalDispatchOutcome = resolve17;
|
|
40755
40887
|
});
|
|
40756
40888
|
let terminalDispatchOutcomeObserved = false;
|
|
40757
40889
|
const adapterAttempt = this.dependencies.codexAdapter.runAttempt({
|
|
@@ -41055,6 +41187,8 @@ var init_runner = __esm({
|
|
|
41055
41187
|
signal,
|
|
41056
41188
|
deadlineAtMs: hostClockMs(jobInput.evidence_expires_at)
|
|
41057
41189
|
}) === true);
|
|
41190
|
+
const failureDetail = attemptFailureDetail(heartbeatFailure ?? effectiveError);
|
|
41191
|
+
const sendFailureDetail = failureDetail !== null && (mcp.supportsFailureDetail?.() === true || await mcp.refreshFailureDetailSupport?.({ signal, deadlineAtMs: hostClockMs(jobInput.evidence_expires_at) }) === true);
|
|
41058
41192
|
const failureRequest = jobFailRequestSchema.parse({
|
|
41059
41193
|
schema_version: "external_inference_job_fail_v1",
|
|
41060
41194
|
contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
|
|
@@ -41101,6 +41235,7 @@ var init_runner = __esm({
|
|
|
41101
41235
|
...sendHttpStatus ? { provider_http_status: httpStatus } : {},
|
|
41102
41236
|
...sendGrokDiagnostic ? { grok_tool_validation: grokDiagnostic } : {},
|
|
41103
41237
|
...sendIdentityDiagnostic ? { grok_response_identity: identityDiagnostic } : {},
|
|
41238
|
+
...sendFailureDetail ? { failure_detail: failureDetail } : {},
|
|
41104
41239
|
membership_disposition: membershipFailureDisposition({
|
|
41105
41240
|
...failure2,
|
|
41106
41241
|
dispatchOutcome
|
|
@@ -41136,6 +41271,7 @@ var init_runner = __esm({
|
|
|
41136
41271
|
failure_code: failureRequest.failure_code,
|
|
41137
41272
|
retryable: failureRequest.retryable,
|
|
41138
41273
|
process_exit: failureRequest.process_exit ?? null,
|
|
41274
|
+
failure_detail: failureDetail,
|
|
41139
41275
|
dispatch_outcome: failureRequest.outcome.dispatch_outcome,
|
|
41140
41276
|
response_outcome: failureRequest.outcome.response_outcome,
|
|
41141
41277
|
latency_ms: adapterResult?.latencyMs ?? null,
|
|
@@ -42447,8 +42583,8 @@ var init_owned_directory_removal = __esm({
|
|
|
42447
42583
|
TRANSIENT_REMOVAL_ERROR_CODES = /* @__PURE__ */ new Set(["EBUSY", "EMFILE", "ENFILE", "ENOTEMPTY", "EPERM"]);
|
|
42448
42584
|
removeOwnedDirectory = async (path, options = {}) => {
|
|
42449
42585
|
const removeDirectory = options.removeDirectory ?? rm5;
|
|
42450
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
42451
|
-
setTimeout(
|
|
42586
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => {
|
|
42587
|
+
setTimeout(resolve17, milliseconds);
|
|
42452
42588
|
}));
|
|
42453
42589
|
const maxAttempts = Math.max(1, options.maxAttempts ?? runtime_policy_generated_default.external_inference.host_core.owned_directory_removal_attempts);
|
|
42454
42590
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? runtime_policy_generated_default.external_inference.host_core.owned_directory_removal_retry_step_ms);
|
|
@@ -42490,7 +42626,7 @@ import { createHash as createHash6 } from "node:crypto";
|
|
|
42490
42626
|
import { constants as fsConstants } from "node:fs";
|
|
42491
42627
|
import { access as access2, readFile as readFile5, realpath as realpath3 } from "node:fs/promises";
|
|
42492
42628
|
import { createRequire } from "node:module";
|
|
42493
|
-
import { dirname as
|
|
42629
|
+
import { dirname as dirname6, join as join5 } from "node:path";
|
|
42494
42630
|
import { spawn as spawn5 } from "node:child_process";
|
|
42495
42631
|
var HOST_RUNTIME_POLICY3, PINNED_CODEX_CLI_VERSION, PINNED_CODEX_LINUX_X64_SHA256, PINNED_CODEX_WINDOWS_X64_SHA256, pinnedShaForPlatform, pinnedPackageForPlatform, resolvePinnedCodexPackageBinaryPath, readCodexVersion, verifyPinnedCodexBinary, resolvePinnedCodexBinary;
|
|
42496
42632
|
var init_codex_binary = __esm({
|
|
@@ -42534,14 +42670,14 @@ var init_codex_binary = __esm({
|
|
|
42534
42670
|
const spec = pinnedPackageForPlatform(platform, architecture);
|
|
42535
42671
|
const packageJsonPath = resolvePackage(`${spec.packageName}/package.json`);
|
|
42536
42672
|
return join5(
|
|
42537
|
-
|
|
42673
|
+
dirname6(packageJsonPath),
|
|
42538
42674
|
"vendor",
|
|
42539
42675
|
spec.target,
|
|
42540
42676
|
"bin",
|
|
42541
42677
|
spec.binaryName
|
|
42542
42678
|
);
|
|
42543
42679
|
};
|
|
42544
|
-
readCodexVersion = async (binaryPath) => await new Promise((
|
|
42680
|
+
readCodexVersion = async (binaryPath) => await new Promise((resolve17, reject) => {
|
|
42545
42681
|
const child = spawn5(binaryPath, ["--version"], {
|
|
42546
42682
|
stdio: ["ignore", "pipe", "pipe"],
|
|
42547
42683
|
windowsHide: true,
|
|
@@ -42580,7 +42716,7 @@ var init_codex_binary = __esm({
|
|
|
42580
42716
|
reject(new Error("Codex version probe failed."));
|
|
42581
42717
|
return;
|
|
42582
42718
|
}
|
|
42583
|
-
|
|
42719
|
+
resolve17(stdout.trim());
|
|
42584
42720
|
});
|
|
42585
42721
|
});
|
|
42586
42722
|
verifyPinnedCodexBinary = async (candidatePath, dependencies = {}) => {
|
|
@@ -42639,9 +42775,9 @@ import {
|
|
|
42639
42775
|
rm as rm6
|
|
42640
42776
|
} from "node:fs/promises";
|
|
42641
42777
|
import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
|
|
42642
|
-
import { tmpdir as
|
|
42643
|
-
import { isAbsolute as
|
|
42644
|
-
var MAX_PROMPT_BYTES2, HOST_RUNTIME_POLICY4, CODEX_MODEL_NAME_PATTERN, CODEX_REASONING_EFFORT_PATTERN, codexRecoveryCheckpointProcessFingerprint, proveCodexSameBootQuiescence, tokenUsageReceiptSchema, turnResultReceiptSchema, terminalReceiptSchema, recoveryCheckpointSchema, recoveryFileSchema, FileCodexAttemptRecoveryStore, utf8Bytes, assertAttemptActive, tomlString, permissionConfig, ensureDedicatedCodexHome, createIsolatedCodexAttemptResources, createIsolatedCodexHostResources, validateAttemptInput, isStrictDescendant, assertRecoveryResourceScope, removeRecoveredThread, confirmCodexGuardianTerminated, confirmGuardianTerminatedForRecovery, recoveredCodexProcessExit, reconcileCodexAttemptRecovery, CodexSubscriptionAdapter, CodexAgentSubscriptionAdapter;
|
|
42778
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
42779
|
+
import { isAbsolute as isAbsolute6, join as join6, relative as relative4, resolve as resolve5, sep as sep3 } from "node:path";
|
|
42780
|
+
var MAX_PROMPT_BYTES2, HOST_RUNTIME_POLICY4, CODEX_MODEL_NAME_PATTERN, CODEX_REASONING_EFFORT_PATTERN, codexRecoveryCheckpointProcessFingerprint, proveCodexSameBootQuiescence, tokenUsageReceiptSchema, turnResultReceiptSchema, terminalReceiptSchema, recoveryCheckpointSchema, recoveryFileSchema, FileCodexAttemptRecoveryStore, utf8Bytes, assertAttemptActive, tomlString, permissionConfig, ensureDedicatedCodexHome, createIsolatedCodexAttemptResources, isMissingPathError, createIsolatedCodexHostResources, validateAttemptInput, isStrictDescendant, assertRecoveryResourceScope, removeRecoveredThread, confirmCodexGuardianTerminated, confirmGuardianTerminatedForRecovery, recoveredCodexProcessExit, reconcileCodexAttemptRecovery, CodexSubscriptionAdapter, CodexAgentSubscriptionAdapter;
|
|
42645
42781
|
var init_codex_adapter = __esm({
|
|
42646
42782
|
"lib/inference-host/codex-adapter.ts"() {
|
|
42647
42783
|
"use strict";
|
|
@@ -42884,7 +43020,7 @@ var init_codex_adapter = __esm({
|
|
|
42884
43020
|
};
|
|
42885
43021
|
createIsolatedCodexAttemptResources = async (_attemptId, codexHome = resolveInferenceHostConfig().codexHomePath) => {
|
|
42886
43022
|
await ensureDedicatedCodexHome(codexHome);
|
|
42887
|
-
const root = await mkdtemp(join6(
|
|
43023
|
+
const root = await mkdtemp(join6(tmpdir3(), INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX));
|
|
42888
43024
|
await chmod3(root, OWNER_ONLY_DIRECTORY_MODE);
|
|
42889
43025
|
const workspacePath = join6(root, "workspace");
|
|
42890
43026
|
await mkdir4(workspacePath, { mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
@@ -42892,34 +43028,84 @@ var init_codex_adapter = __esm({
|
|
|
42892
43028
|
root,
|
|
42893
43029
|
codexHome,
|
|
42894
43030
|
workspacePath,
|
|
43031
|
+
// A folder something else already deleted is removed: its prompt bytes are gone.
|
|
42895
43032
|
cleanup: async () => {
|
|
42896
|
-
await removeOwnedDirectory(root
|
|
43033
|
+
await removeOwnedDirectory(root);
|
|
42897
43034
|
}
|
|
42898
43035
|
};
|
|
42899
43036
|
};
|
|
43037
|
+
isMissingPathError = (error48) => error48?.code === "ENOENT";
|
|
42900
43038
|
createIsolatedCodexHostResources = async (codexHome) => {
|
|
42901
43039
|
await ensureDedicatedCodexHome(codexHome);
|
|
42902
|
-
const
|
|
42903
|
-
|
|
42904
|
-
|
|
42905
|
-
|
|
43040
|
+
const mintWorkerFolder = async () => {
|
|
43041
|
+
const folder = await mkdtemp(join6(tmpdir3(), INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_PREFIX));
|
|
43042
|
+
try {
|
|
43043
|
+
await chmod3(folder, OWNER_ONLY_DIRECTORY_MODE);
|
|
43044
|
+
await mkdir4(join6(folder, INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS), { mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
43045
|
+
} catch (error48) {
|
|
43046
|
+
await removeOwnedDirectory(folder).catch(() => void 0);
|
|
43047
|
+
throw error48;
|
|
43048
|
+
}
|
|
43049
|
+
return folder;
|
|
43050
|
+
};
|
|
43051
|
+
const mintJobFolder = async (folder) => {
|
|
43052
|
+
const workspacePath = await mkdtemp(join6(
|
|
43053
|
+
folder,
|
|
43054
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS,
|
|
43055
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_HOSTED_JOB_PREFIX
|
|
43056
|
+
));
|
|
43057
|
+
await chmod3(workspacePath, OWNER_ONLY_DIRECTORY_MODE);
|
|
43058
|
+
return workspacePath;
|
|
43059
|
+
};
|
|
43060
|
+
let root = await mintWorkerFolder();
|
|
43061
|
+
const minted = [root];
|
|
43062
|
+
let replacement = null;
|
|
43063
|
+
const replaceVanished = async (vanished) => {
|
|
43064
|
+
if (root !== vanished) return root;
|
|
43065
|
+
replacement ??= mintWorkerFolder().then((folder) => {
|
|
43066
|
+
root = folder;
|
|
43067
|
+
minted.push(folder);
|
|
43068
|
+
return folder;
|
|
43069
|
+
}).finally(() => {
|
|
43070
|
+
replacement = null;
|
|
43071
|
+
});
|
|
43072
|
+
return await replacement;
|
|
43073
|
+
};
|
|
42906
43074
|
return {
|
|
42907
|
-
root
|
|
43075
|
+
get root() {
|
|
43076
|
+
return root;
|
|
43077
|
+
},
|
|
42908
43078
|
codexHome,
|
|
42909
43079
|
createAttemptResources: async () => {
|
|
42910
|
-
const
|
|
42911
|
-
|
|
43080
|
+
const folder = root;
|
|
43081
|
+
let workspacePath;
|
|
43082
|
+
let replacedVanishedWorkerFolder = false;
|
|
43083
|
+
try {
|
|
43084
|
+
workspacePath = await mintJobFolder(folder);
|
|
43085
|
+
} catch (error48) {
|
|
43086
|
+
if (!isMissingPathError(error48)) throw error48;
|
|
43087
|
+
workspacePath = await mintJobFolder(await replaceVanished(folder));
|
|
43088
|
+
replacedVanishedWorkerFolder = true;
|
|
43089
|
+
}
|
|
42912
43090
|
return {
|
|
42913
43091
|
root: workspacePath,
|
|
42914
43092
|
codexHome,
|
|
42915
43093
|
workspacePath,
|
|
43094
|
+
replacedVanishedWorkerFolder,
|
|
42916
43095
|
cleanup: async () => {
|
|
42917
|
-
await removeOwnedDirectory(workspacePath
|
|
43096
|
+
await removeOwnedDirectory(workspacePath);
|
|
42918
43097
|
}
|
|
42919
43098
|
};
|
|
42920
43099
|
},
|
|
43100
|
+
// Every folder this worker run made, including ones that vanished or were
|
|
43101
|
+
// left behind partly deleted; one already gone is already removed, and one
|
|
43102
|
+
// that fails does not stop the others.
|
|
42921
43103
|
cleanup: async () => {
|
|
42922
|
-
|
|
43104
|
+
const failures = [];
|
|
43105
|
+
for (const folder of minted) await removeOwnedDirectory(folder).catch((error48) => {
|
|
43106
|
+
failures.push(error48);
|
|
43107
|
+
});
|
|
43108
|
+
if (failures.length > 0) throw failures[0];
|
|
42923
43109
|
}
|
|
42924
43110
|
};
|
|
42925
43111
|
};
|
|
@@ -43025,27 +43211,27 @@ var init_codex_adapter = __esm({
|
|
|
43025
43211
|
};
|
|
43026
43212
|
};
|
|
43027
43213
|
isStrictDescendant = (candidate, parent) => {
|
|
43028
|
-
const parentPath =
|
|
43029
|
-
const candidatePath =
|
|
43030
|
-
const scoped =
|
|
43031
|
-
return scoped.length > 0 && !scoped.startsWith(`..${
|
|
43214
|
+
const parentPath = resolve5(parent);
|
|
43215
|
+
const candidatePath = resolve5(candidate);
|
|
43216
|
+
const scoped = relative4(parentPath, candidatePath);
|
|
43217
|
+
return scoped.length > 0 && !scoped.startsWith(`..${sep3}`) && scoped !== ".." && !isAbsolute6(scoped);
|
|
43032
43218
|
};
|
|
43033
43219
|
assertRecoveryResourceScope = (checkpoint) => {
|
|
43034
|
-
const temporaryRoot =
|
|
43035
|
-
const resourceRoot =
|
|
43036
|
-
const workspacePath =
|
|
43220
|
+
const temporaryRoot = resolve5(tmpdir3());
|
|
43221
|
+
const resourceRoot = resolve5(checkpoint.resourceRoot);
|
|
43222
|
+
const workspacePath = resolve5(checkpoint.workspacePath);
|
|
43037
43223
|
if (!isStrictDescendant(resourceRoot, temporaryRoot)) {
|
|
43038
43224
|
throw new Error("Codex recovery resource root crossed temporary scope.");
|
|
43039
43225
|
}
|
|
43040
|
-
const parts =
|
|
43041
|
-
const standalone = parts.length === 1 && parts[0].startsWith(
|
|
43042
|
-
const hosted = parts.length === CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS && parts[0].startsWith(
|
|
43226
|
+
const parts = relative4(temporaryRoot, resourceRoot).split(sep3);
|
|
43227
|
+
const standalone = parts.length === 1 && parts[0].startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX) && workspacePath === join6(resourceRoot, "workspace");
|
|
43228
|
+
const hosted = parts.length === CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS && parts[0].startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_PREFIX) && parts[1] === INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS && parts[2].startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_HOSTED_JOB_PREFIX) && workspacePath === resourceRoot;
|
|
43043
43229
|
if (!standalone && !hosted) {
|
|
43044
43230
|
throw new Error("Codex recovery resource layout is invalid.");
|
|
43045
43231
|
}
|
|
43046
43232
|
};
|
|
43047
43233
|
removeRecoveredThread = async (checkpoint, expectedCodexHome) => {
|
|
43048
|
-
if (
|
|
43234
|
+
if (resolve5(checkpoint.codexHome) !== resolve5(expectedCodexHome)) {
|
|
43049
43235
|
throw new Error("Codex recovery home crossed dedicated auth scope.");
|
|
43050
43236
|
}
|
|
43051
43237
|
if (checkpoint.threadId === null || checkpoint.threadPath === null) {
|
|
@@ -43054,7 +43240,7 @@ var init_codex_adapter = __esm({
|
|
|
43054
43240
|
}
|
|
43055
43241
|
}
|
|
43056
43242
|
const homeState = await lstat4(expectedCodexHome);
|
|
43057
|
-
if (!homeState.isDirectory() || homeState.isSymbolicLink() || process.platform !== "win32" && ((homeState.mode & GROUP_OTHER_PERMISSION_BITS) !== 0 || typeof process.getuid === "function" && homeState.uid !== process.getuid() || await realpath4(expectedCodexHome) !==
|
|
43243
|
+
if (!homeState.isDirectory() || homeState.isSymbolicLink() || process.platform !== "win32" && ((homeState.mode & GROUP_OTHER_PERMISSION_BITS) !== 0 || typeof process.getuid === "function" && homeState.uid !== process.getuid() || await realpath4(expectedCodexHome) !== resolve5(expectedCodexHome))) {
|
|
43058
43244
|
throw new Error("Codex recovery home is not a private owned directory.");
|
|
43059
43245
|
}
|
|
43060
43246
|
const threadPaths = /* @__PURE__ */ new Set();
|
|
@@ -43110,7 +43296,7 @@ var init_codex_adapter = __esm({
|
|
|
43110
43296
|
if (!event || typeof event !== "object" || Array.isArray(event)) continue;
|
|
43111
43297
|
const record6 = event;
|
|
43112
43298
|
const payload = record6.payload;
|
|
43113
|
-
if (record6.type === "session_meta" && payload && typeof payload === "object" && !Array.isArray(payload) &&
|
|
43299
|
+
if (record6.type === "session_meta" && payload && typeof payload === "object" && !Array.isArray(payload) && resolve5(String(payload.cwd || "")) === resolve5(checkpoint.workspacePath)) {
|
|
43114
43300
|
threadPaths.add(path);
|
|
43115
43301
|
break;
|
|
43116
43302
|
}
|
|
@@ -43118,7 +43304,7 @@ var init_codex_adapter = __esm({
|
|
|
43118
43304
|
}
|
|
43119
43305
|
}
|
|
43120
43306
|
if (checkpoint.threadPath !== null) {
|
|
43121
|
-
if (!
|
|
43307
|
+
if (!isAbsolute6(checkpoint.threadPath) || !isStrictDescendant(
|
|
43122
43308
|
checkpoint.threadPath,
|
|
43123
43309
|
sessionsRoot
|
|
43124
43310
|
) || !checkpoint.threadPath.endsWith(".jsonl")) {
|
|
@@ -43367,7 +43553,7 @@ var init_codex_adapter = __esm({
|
|
|
43367
43553
|
);
|
|
43368
43554
|
const bootIdentity = guardianManaged ? await (this.dependencies.readBootIdentity ?? readInferenceSystemBootIdentity)() : null;
|
|
43369
43555
|
const processToken = guardianManaged ? randomBytes4(CODEX_GUARDIAN_PROCESS_TOKEN_BYTES).toString("hex") : null;
|
|
43370
|
-
const guardianReceiptRoot = guardianManaged ? this.dependencies.guardianReceiptRoot ?? join6(
|
|
43556
|
+
const guardianReceiptRoot = guardianManaged ? this.dependencies.guardianReceiptRoot ?? join6(tmpdir3(), "vtx-codex-guardian-receipts") : null;
|
|
43371
43557
|
if (guardianReceiptRoot) await ensureInferencePrivateDirectory(guardianReceiptRoot);
|
|
43372
43558
|
const processReceiptPath = guardianReceiptRoot && processToken ? join6(guardianReceiptRoot, `${processToken}.json`) : null;
|
|
43373
43559
|
const session = await CodexAppServerSession.start({
|
|
@@ -43518,7 +43704,7 @@ var init_codex_adapter = __esm({
|
|
|
43518
43704
|
durableSession.session.requireModelCapability(capabilities, modelName, reasoningEffort);
|
|
43519
43705
|
}
|
|
43520
43706
|
async waitForCapabilities(preflight, deadlineAtMs, signal) {
|
|
43521
|
-
return await new Promise((
|
|
43707
|
+
return await new Promise((resolve17, reject) => {
|
|
43522
43708
|
let settled2 = false;
|
|
43523
43709
|
const finish = (callback) => {
|
|
43524
43710
|
if (settled2) return;
|
|
@@ -43545,7 +43731,7 @@ var init_codex_adapter = __esm({
|
|
|
43545
43731
|
return;
|
|
43546
43732
|
}
|
|
43547
43733
|
void preflight.then(
|
|
43548
|
-
(value) => finish(() =>
|
|
43734
|
+
(value) => finish(() => resolve17(value)),
|
|
43549
43735
|
(error48) => finish(() => reject(error48))
|
|
43550
43736
|
);
|
|
43551
43737
|
});
|
|
@@ -43656,8 +43842,8 @@ var init_codex_adapter = __esm({
|
|
|
43656
43842
|
if (recoveryHooks.loadAll) {
|
|
43657
43843
|
try {
|
|
43658
43844
|
const checkpoints = await recoveryHooks.loadAll();
|
|
43659
|
-
const receiptPath =
|
|
43660
|
-
sharedReceiptStillRequired = Object.values(checkpoints).some((candidate) => candidate.attemptId !== attemptId && !candidate.cleanupConfirmed && candidate.processReceiptPath !== null &&
|
|
43845
|
+
const receiptPath = resolve5(checkpoint.processReceiptPath);
|
|
43846
|
+
sharedReceiptStillRequired = Object.values(checkpoints).some((candidate) => candidate.attemptId !== attemptId && !candidate.cleanupConfirmed && candidate.processReceiptPath !== null && resolve5(candidate.processReceiptPath) === receiptPath);
|
|
43661
43847
|
} catch {
|
|
43662
43848
|
sharedReceiptStillRequired = true;
|
|
43663
43849
|
}
|
|
@@ -43704,7 +43890,7 @@ var init_codex_adapter = __esm({
|
|
|
43704
43890
|
try {
|
|
43705
43891
|
const checkpoints = await recoveryHooks.loadAll();
|
|
43706
43892
|
unconfirmedReceiptPaths = new Set(
|
|
43707
|
-
Object.values(checkpoints).filter((checkpoint) => !checkpoint.cleanupConfirmed && checkpoint.processReceiptPath !== null).map((checkpoint) =>
|
|
43893
|
+
Object.values(checkpoints).filter((checkpoint) => !checkpoint.cleanupConfirmed && checkpoint.processReceiptPath !== null).map((checkpoint) => resolve5(checkpoint.processReceiptPath))
|
|
43708
43894
|
);
|
|
43709
43895
|
} catch {
|
|
43710
43896
|
unconfirmedReceiptPaths = null;
|
|
@@ -43712,7 +43898,7 @@ var init_codex_adapter = __esm({
|
|
|
43712
43898
|
}
|
|
43713
43899
|
}
|
|
43714
43900
|
for (const session of sessions) {
|
|
43715
|
-
if (session.processReceiptPath && unconfirmedReceiptPaths !== null && !unconfirmedReceiptPaths.has(
|
|
43901
|
+
if (session.processReceiptPath && unconfirmedReceiptPaths !== null && !unconfirmedReceiptPaths.has(resolve5(session.processReceiptPath))) {
|
|
43716
43902
|
await rm6(session.processReceiptPath, { force: true });
|
|
43717
43903
|
await rm6(`${session.processReceiptPath}.shutdown-intent`, { force: true });
|
|
43718
43904
|
}
|
|
@@ -43792,6 +43978,9 @@ var init_codex_adapter = __esm({
|
|
|
43792
43978
|
attemptId,
|
|
43793
43979
|
this.dependencies.codexHome
|
|
43794
43980
|
)))(input.attemptId);
|
|
43981
|
+
if (resources.replacedVanishedWorkerFolder) {
|
|
43982
|
+
this.emitDiagnostic({ event: "codex_worker_folder_replaced", attempt_id: input.attemptId });
|
|
43983
|
+
}
|
|
43795
43984
|
await access3(resources.codexHome, fsConstants2.R_OK | fsConstants2.W_OK);
|
|
43796
43985
|
await access3(resources.workspacePath, fsConstants2.R_OK);
|
|
43797
43986
|
sessionLease = await this.acquireDurableSession(
|
|
@@ -44400,8 +44589,8 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44400
44589
|
|
|
44401
44590
|
// lib/inference-host/agent-thread-workspace.ts
|
|
44402
44591
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
44403
|
-
import { tmpdir as
|
|
44404
|
-
import { basename as basename2, dirname as
|
|
44592
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
44593
|
+
import { basename as basename2, dirname as dirname7 } from "node:path";
|
|
44405
44594
|
var ownedTempThreadWorkspace, removeRecordedTempThreadWorkspace;
|
|
44406
44595
|
var init_agent_thread_workspace = __esm({
|
|
44407
44596
|
"lib/inference-host/agent-thread-workspace.ts"() {
|
|
@@ -44414,8 +44603,8 @@ var init_agent_thread_workspace = __esm({
|
|
|
44414
44603
|
init_owned_directory_removal();
|
|
44415
44604
|
ownedTempThreadWorkspace = async (threadPath, prefix) => {
|
|
44416
44605
|
const resolved = await realpath5(threadPath);
|
|
44417
|
-
const temporaryRoot = await realpath5(
|
|
44418
|
-
return
|
|
44606
|
+
const temporaryRoot = await realpath5(tmpdir4());
|
|
44607
|
+
return dirname7(resolved) === temporaryRoot && basename2(resolved).startsWith(prefix) ? resolved : null;
|
|
44419
44608
|
};
|
|
44420
44609
|
removeRecordedTempThreadWorkspace = async (statePath, prefix) => {
|
|
44421
44610
|
let threadPath;
|
|
@@ -44441,7 +44630,7 @@ var init_agent_thread_workspace = __esm({
|
|
|
44441
44630
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
44442
44631
|
import { mkdtemp as mkdtemp2 } from "node:fs/promises";
|
|
44443
44632
|
import { createRequire as createRequire2 } from "node:module";
|
|
44444
|
-
import { tmpdir as
|
|
44633
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
44445
44634
|
import { join as join7 } from "node:path";
|
|
44446
44635
|
import {
|
|
44447
44636
|
CopilotClient,
|
|
@@ -44486,9 +44675,9 @@ var init_copilot_adapter = __esm({
|
|
|
44486
44675
|
}
|
|
44487
44676
|
throw new Error(`copilot_runtime_package_missing:${failures.join(";")}`);
|
|
44488
44677
|
};
|
|
44489
|
-
WORKSPACE_PREFIX =
|
|
44678
|
+
WORKSPACE_PREFIX = INFERENCE_HOST_TEMP_FOLDERS.COPILOT_JOB_PREFIX;
|
|
44490
44679
|
createPrivateWorkspace = async (removal = {}) => {
|
|
44491
|
-
const path = await mkdtemp2(join7(
|
|
44680
|
+
const path = await mkdtemp2(join7(tmpdir5(), WORKSPACE_PREFIX));
|
|
44492
44681
|
return {
|
|
44493
44682
|
path,
|
|
44494
44683
|
// client.stop() has already awaited the runtime's exit; retries cover the
|
|
@@ -45320,9 +45509,9 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
45320
45509
|
response.end();
|
|
45321
45510
|
}
|
|
45322
45511
|
});
|
|
45323
|
-
await new Promise((
|
|
45512
|
+
await new Promise((resolve17, reject) => {
|
|
45324
45513
|
this.server.once("error", reject);
|
|
45325
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
45514
|
+
this.server.listen(0, "127.0.0.1", () => resolve17());
|
|
45326
45515
|
});
|
|
45327
45516
|
const address = this.server.address();
|
|
45328
45517
|
if (!address || typeof address === "string") throw new Error("deepseek_proxy_bind_failed");
|
|
@@ -45334,7 +45523,7 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
45334
45523
|
this.server = null;
|
|
45335
45524
|
this.urlValue = null;
|
|
45336
45525
|
if (!server) return;
|
|
45337
|
-
await new Promise((
|
|
45526
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
45338
45527
|
}
|
|
45339
45528
|
};
|
|
45340
45529
|
}
|
|
@@ -45402,7 +45591,7 @@ var init_provider_refusal = __esm({
|
|
|
45402
45591
|
// lib/inference-host/deepseek-harness-adapter.ts
|
|
45403
45592
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
45404
45593
|
import { mkdtemp as mkdtemp3, rm as rm7 } from "node:fs/promises";
|
|
45405
|
-
import { tmpdir as
|
|
45594
|
+
import { tmpdir as tmpdir6 } from "node:os";
|
|
45406
45595
|
import { join as join8 } from "node:path";
|
|
45407
45596
|
import { Context } from "@deepseek-ai/cordis";
|
|
45408
45597
|
import * as AgentSpine from "@deepseek-ai/dsh-agent-spine-demo";
|
|
@@ -45570,9 +45759,9 @@ var init_deepseek_harness_adapter = __esm({
|
|
|
45570
45759
|
cause: options.error
|
|
45571
45760
|
});
|
|
45572
45761
|
};
|
|
45573
|
-
WORKSPACE_PREFIX2 =
|
|
45762
|
+
WORKSPACE_PREFIX2 = INFERENCE_HOST_TEMP_FOLDERS.DEEPSEEK_JOB_PREFIX;
|
|
45574
45763
|
createPrivateWorkspace2 = async () => {
|
|
45575
|
-
const path = await mkdtemp3(join8(
|
|
45764
|
+
const path = await mkdtemp3(join8(tmpdir6(), WORKSPACE_PREFIX2));
|
|
45576
45765
|
return { path, cleanup: async () => {
|
|
45577
45766
|
await removeOwnedDirectory(path);
|
|
45578
45767
|
} };
|
|
@@ -45950,11 +46139,11 @@ ${JSON.stringify(input.outputSchema)}`,
|
|
|
45950
46139
|
boundary.signal.throwIfAborted();
|
|
45951
46140
|
let checkpointReached = false;
|
|
45952
46141
|
let resolveCheckpoint;
|
|
45953
|
-
const checkpoint = new Promise((
|
|
45954
|
-
resolveCheckpoint =
|
|
46142
|
+
const checkpoint = new Promise((resolve17) => {
|
|
46143
|
+
resolveCheckpoint = resolve17;
|
|
45955
46144
|
});
|
|
45956
|
-
const dispatchGate = new Promise((
|
|
45957
|
-
releaseAgentDispatch =
|
|
46145
|
+
const dispatchGate = new Promise((resolve17) => {
|
|
46146
|
+
releaseAgentDispatch = resolve17;
|
|
45958
46147
|
});
|
|
45959
46148
|
ctx.on("llm/stream", (options, next) => {
|
|
45960
46149
|
if (String(options.sessionId ?? "") !== String(sessionId)) return next();
|
|
@@ -46275,7 +46464,7 @@ var init_pi_transport = __esm({
|
|
|
46275
46464
|
// lib/inference-host/pi-adapter.ts
|
|
46276
46465
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
46277
46466
|
import { lstat as lstat5, realpath as realpath6, rm as rm8, readdir as readdir5 } from "node:fs/promises";
|
|
46278
|
-
import { basename as basename3, dirname as
|
|
46467
|
+
import { basename as basename3, dirname as dirname8, join as join9, resolve as resolve6 } from "node:path";
|
|
46279
46468
|
import {
|
|
46280
46469
|
createAgentSession,
|
|
46281
46470
|
DefaultResourceLoader,
|
|
@@ -46439,8 +46628,8 @@ var init_pi_adapter = __esm({
|
|
|
46439
46628
|
}
|
|
46440
46629
|
async ownedThread(thread) {
|
|
46441
46630
|
const root = await realpath6(this.dependencies.stateRoot);
|
|
46442
|
-
const supplied =
|
|
46443
|
-
if (
|
|
46631
|
+
const supplied = resolve6(thread.threadPath);
|
|
46632
|
+
if (dirname8(supplied) !== root || basename3(supplied) !== `agent-${thread.threadId}` || !/^[a-f0-9-]{36}$/u.test(thread.threadId)) throw fail("pi_thread_not_owned");
|
|
46444
46633
|
const info = await lstat5(supplied);
|
|
46445
46634
|
if (info.isSymbolicLink() || !info.isDirectory()) throw fail("pi_thread_not_owned");
|
|
46446
46635
|
if (await realpath6(supplied) !== supplied) throw fail("pi_thread_not_owned");
|
|
@@ -46810,7 +46999,7 @@ import { spawn as spawn7 } from "node:child_process";
|
|
|
46810
46999
|
import { createHash as createHash8, randomUUID as randomUUID7 } from "node:crypto";
|
|
46811
47000
|
import { lstat as lstat6, readFile as readFile7, rename as rename4, rm as rm9, writeFile as writeFile3 } from "node:fs/promises";
|
|
46812
47001
|
import { createRequire as createRequire3 } from "node:module";
|
|
46813
|
-
import { dirname as
|
|
47002
|
+
import { dirname as dirname9, join as join10 } from "node:path";
|
|
46814
47003
|
import { brotliDecompress } from "node:zlib";
|
|
46815
47004
|
import { promisify } from "node:util";
|
|
46816
47005
|
var HOST_RUNTIME_POLICY8, decompress, pending, digest, verifyVersion, resolvePinnedGrokBinary;
|
|
@@ -46829,7 +47018,7 @@ var init_grok_binary = __esm({
|
|
|
46829
47018
|
decompress = promisify(brotliDecompress);
|
|
46830
47019
|
pending = /* @__PURE__ */ new Map();
|
|
46831
47020
|
digest = (bytes3) => createHash8("sha256").update(bytes3).digest("hex");
|
|
46832
|
-
verifyVersion = async (path) => new Promise((
|
|
47021
|
+
verifyVersion = async (path) => new Promise((resolve17, reject) => {
|
|
46833
47022
|
const child = spawn7(path, ["--version"], {
|
|
46834
47023
|
stdio: ["ignore", "pipe", "ignore"],
|
|
46835
47024
|
windowsHide: true,
|
|
@@ -46859,7 +47048,7 @@ var init_grok_binary = __esm({
|
|
|
46859
47048
|
clearTimeout(timer);
|
|
46860
47049
|
if (code !== 0 || /^grok\s+(\S+)/u.exec(stdout.trim())?.[1] !== agent_cli_release_default.grok_version) {
|
|
46861
47050
|
reject(new Error("Grok runtime version does not match its release."));
|
|
46862
|
-
} else
|
|
47051
|
+
} else resolve17();
|
|
46863
47052
|
});
|
|
46864
47053
|
});
|
|
46865
47054
|
resolvePinnedGrokBinary = async (stateRoot) => {
|
|
@@ -46890,7 +47079,7 @@ var init_grok_binary = __esm({
|
|
|
46890
47079
|
}
|
|
46891
47080
|
const manifest = JSON.parse(await readFile7(packagePath, "utf8"));
|
|
46892
47081
|
if (manifest.version !== agent_cli_release_default.grok_version) throw new Error("Grok package version mismatch.");
|
|
46893
|
-
const bytes3 = await decompress(await readFile7(join10(
|
|
47082
|
+
const bytes3 = await decompress(await readFile7(join10(dirname9(packagePath), "bin", `${spec.binary_name}.br`)), { maxOutputLength: HOST_RUNTIME_POLICY8.grok_binary_max_bytes });
|
|
46894
47083
|
if (digest(bytes3) !== spec.sha256) throw new Error("Grok package binary digest mismatch.");
|
|
46895
47084
|
const temporary = join10(directory2, `.${randomUUID7()}.tmp`);
|
|
46896
47085
|
try {
|
|
@@ -46916,7 +47105,7 @@ var init_grok_binary = __esm({
|
|
|
46916
47105
|
|
|
46917
47106
|
// lib/inference-host/grok-policy.ts
|
|
46918
47107
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
46919
|
-
import { dirname as
|
|
47108
|
+
import { dirname as dirname10, resolve as resolve7 } from "node:path";
|
|
46920
47109
|
import { fileURLToPath } from "node:url";
|
|
46921
47110
|
var validateGrokPolicy, loadGrokPolicy;
|
|
46922
47111
|
var init_grok_policy = __esm({
|
|
@@ -46946,7 +47135,7 @@ var init_grok_policy = __esm({
|
|
|
46946
47135
|
};
|
|
46947
47136
|
loadGrokPolicy = async () => {
|
|
46948
47137
|
if (typeof define_VTX_GROK_POLICY_default !== "undefined") return validateGrokPolicy(define_VTX_GROK_POLICY_default);
|
|
46949
|
-
const config2 = parse(await readFile8(
|
|
47138
|
+
const config2 = parse(await readFile8(resolve7(dirname10(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
46950
47139
|
return validateGrokPolicy(config2.external_inference?.grok_adapter);
|
|
46951
47140
|
};
|
|
46952
47141
|
}
|
|
@@ -47087,9 +47276,9 @@ var init_grok_transport_proxy = __esm({
|
|
|
47087
47276
|
this.server = createServer3((request, response) => {
|
|
47088
47277
|
void this.handle(request, response);
|
|
47089
47278
|
});
|
|
47090
|
-
await new Promise((
|
|
47279
|
+
await new Promise((resolve17, reject) => {
|
|
47091
47280
|
this.server.once("error", reject);
|
|
47092
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
47281
|
+
this.server.listen(0, "127.0.0.1", () => resolve17());
|
|
47093
47282
|
});
|
|
47094
47283
|
const address = this.server.address();
|
|
47095
47284
|
if (!address || typeof address === "string") throw new Error("grok_proxy_bind_failed");
|
|
@@ -47465,7 +47654,7 @@ var init_grok_transport_proxy = __esm({
|
|
|
47465
47654
|
this.urlValue = null;
|
|
47466
47655
|
if (!server) return;
|
|
47467
47656
|
server.closeAllConnections();
|
|
47468
|
-
await new Promise((
|
|
47657
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
47469
47658
|
}
|
|
47470
47659
|
};
|
|
47471
47660
|
createGrokTransportProxy = async (options) => {
|
|
@@ -47537,9 +47726,9 @@ var init_agent_tool_server = __esm({
|
|
|
47537
47726
|
response.writeHead(HTTP_STATUS.BAD_REQUEST).end();
|
|
47538
47727
|
}
|
|
47539
47728
|
});
|
|
47540
|
-
await new Promise((
|
|
47729
|
+
await new Promise((resolve17, reject) => {
|
|
47541
47730
|
server.once("error", reject);
|
|
47542
|
-
server.listen(0, "127.0.0.1",
|
|
47731
|
+
server.listen(0, "127.0.0.1", resolve17);
|
|
47543
47732
|
});
|
|
47544
47733
|
const address = server.address();
|
|
47545
47734
|
if (!address || typeof address === "string") throw new Error(code("listen_failed"));
|
|
@@ -47551,7 +47740,7 @@ var init_agent_tool_server = __esm({
|
|
|
47551
47740
|
descriptor: { type: "http", name: "vtx", url: `http://127.0.0.1:${address.port}/${token}`, headers: [] },
|
|
47552
47741
|
close: async () => {
|
|
47553
47742
|
server.closeAllConnections();
|
|
47554
|
-
await new Promise((
|
|
47743
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
47555
47744
|
}
|
|
47556
47745
|
};
|
|
47557
47746
|
};
|
|
@@ -47755,11 +47944,11 @@ var init_grok_runtime = __esm({
|
|
|
47755
47944
|
this.child.kill();
|
|
47756
47945
|
}
|
|
47757
47946
|
});
|
|
47758
|
-
this.exit = new Promise((
|
|
47947
|
+
this.exit = new Promise((resolve17) => {
|
|
47759
47948
|
this.child.once("error", () => this.fail(new Error("grok_process_start_failed")));
|
|
47760
47949
|
this.child.once("close", () => {
|
|
47761
47950
|
this.fail(new Error("grok_process_closed"));
|
|
47762
|
-
|
|
47951
|
+
resolve17();
|
|
47763
47952
|
});
|
|
47764
47953
|
});
|
|
47765
47954
|
}
|
|
@@ -47779,8 +47968,8 @@ var init_grok_runtime = __esm({
|
|
|
47779
47968
|
let timer;
|
|
47780
47969
|
let abort;
|
|
47781
47970
|
try {
|
|
47782
|
-
return await new Promise((
|
|
47783
|
-
this.pending.set(id2, { resolve:
|
|
47971
|
+
return await new Promise((resolve17, reject) => {
|
|
47972
|
+
this.pending.set(id2, { resolve: resolve17, reject });
|
|
47784
47973
|
timer = setTimeout(() => reject(new Error("grok_deadline_exceeded")), Math.max(1, deadlineAtMs - Date.now()));
|
|
47785
47974
|
abort = () => reject(new Error("grok_cancelled"));
|
|
47786
47975
|
signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -47814,7 +48003,7 @@ var init_grok_runtime = __esm({
|
|
|
47814
48003
|
// lib/inference-host/grok-state.ts
|
|
47815
48004
|
import { constants as constants2 } from "node:fs";
|
|
47816
48005
|
import { lstat as lstat8, mkdtemp as mkdtemp4, open as open3, readdir as readdir6, realpath as realpath7, rm as rm11, rmdir, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
47817
|
-
import { basename as basename4, dirname as
|
|
48006
|
+
import { basename as basename4, dirname as dirname11, join as join12, resolve as resolve8 } from "node:path";
|
|
47818
48007
|
var HOST_RUNTIME_POLICY10, markerName, ownedName, invalid, missing, sessionIdValid, directory, nativeDirectory, roots, owner, nativeFile, encodedCwd, nativeSession, removeEmptyNativeGroup, createGrokOwnedWorkspace, bindGrokOwnedSession, validateGrokOwnedThread, releaseGrokOwnedWorkspace, cleanupGrokOwnedState;
|
|
47819
48008
|
var init_grok_state = __esm({
|
|
47820
48009
|
"lib/inference-host/grok-state.ts"() {
|
|
@@ -47835,12 +48024,12 @@ var init_grok_state = __esm({
|
|
|
47835
48024
|
sessionIdValid = (id2) => /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(id2);
|
|
47836
48025
|
directory = async (path) => {
|
|
47837
48026
|
const info = await lstat8(path);
|
|
47838
|
-
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !==
|
|
48027
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !== resolve8(path)) throw invalid();
|
|
47839
48028
|
await ensureInferencePrivateDirectory(path);
|
|
47840
48029
|
};
|
|
47841
48030
|
nativeDirectory = async (path) => {
|
|
47842
48031
|
const info = await lstat8(path);
|
|
47843
|
-
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !==
|
|
48032
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !== resolve8(path)) throw invalid();
|
|
47844
48033
|
if (process.platform === "win32") {
|
|
47845
48034
|
await secureWindowsPrivatePath(path, "directory", "verify-owner");
|
|
47846
48035
|
await secureWindowsPrivatePath(path, "directory", "harden");
|
|
@@ -47848,15 +48037,15 @@ var init_grok_state = __esm({
|
|
|
47848
48037
|
await directory(path);
|
|
47849
48038
|
};
|
|
47850
48039
|
roots = async (options) => {
|
|
47851
|
-
const stateRoot =
|
|
47852
|
-
const grokHome =
|
|
48040
|
+
const stateRoot = resolve8(options.stateRoot);
|
|
48041
|
+
const grokHome = resolve8(options.grokHome);
|
|
47853
48042
|
await directory(stateRoot);
|
|
47854
48043
|
await directory(grokHome);
|
|
47855
48044
|
return { stateRoot, grokHome, workspaceRoot: join12(stateRoot, "grok-workspaces") };
|
|
47856
48045
|
};
|
|
47857
48046
|
owner = async (options, workspace) => {
|
|
47858
48047
|
const scope = await roots(options);
|
|
47859
|
-
if (workspace !==
|
|
48048
|
+
if (workspace !== resolve8(workspace) || dirname11(workspace) !== scope.workspaceRoot || !ownedName.test(basename4(workspace))) throw invalid();
|
|
47860
48049
|
await directory(scope.workspaceRoot);
|
|
47861
48050
|
await directory(workspace);
|
|
47862
48051
|
const raw = await readInferencePrivateFile(join12(workspace, markerName), "Grok workspace owner");
|
|
@@ -47902,7 +48091,7 @@ var init_grok_state = __esm({
|
|
|
47902
48091
|
for (const entry of await readdir6(sessions, { withFileTypes: true })) {
|
|
47903
48092
|
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
|
47904
48093
|
const group = join12(sessions, entry.name);
|
|
47905
|
-
if (await realpath7(group) !==
|
|
48094
|
+
if (await realpath7(group) !== resolve8(group)) throw invalid();
|
|
47906
48095
|
try {
|
|
47907
48096
|
if ((await nativeFile(join12(group, ".cwd"), HOST_RUNTIME_POLICY10.grok_cwd_marker_max_bytes)).trim() === value.workspace) groups2.push(group);
|
|
47908
48097
|
} catch (error48) {
|
|
@@ -48006,7 +48195,7 @@ var init_grok_state = __esm({
|
|
|
48006
48195
|
};
|
|
48007
48196
|
releaseGrokOwnedWorkspace = async (options, workspace, expectedSessionId) => {
|
|
48008
48197
|
const scope = await roots(options);
|
|
48009
|
-
if (workspace !==
|
|
48198
|
+
if (workspace !== resolve8(workspace) || dirname11(workspace) !== scope.workspaceRoot || !ownedName.test(basename4(workspace))) throw invalid();
|
|
48010
48199
|
await directory(scope.workspaceRoot);
|
|
48011
48200
|
try {
|
|
48012
48201
|
await lstat8(workspace);
|
|
@@ -48021,7 +48210,7 @@ var init_grok_state = __esm({
|
|
|
48021
48210
|
await owner(options, workspace);
|
|
48022
48211
|
if (await nativeSession(value, false) !== session) throw invalid();
|
|
48023
48212
|
await removeOwnedDirectory(session);
|
|
48024
|
-
await removeEmptyNativeGroup(
|
|
48213
|
+
await removeEmptyNativeGroup(dirname11(session), workspace);
|
|
48025
48214
|
}
|
|
48026
48215
|
await owner(options, workspace);
|
|
48027
48216
|
await removeOwnedDirectory(workspace);
|
|
@@ -48500,7 +48689,8 @@ var init_grok_adapter = __esm({
|
|
|
48500
48689
|
retryable: false,
|
|
48501
48690
|
dispatchOutcome: outcome,
|
|
48502
48691
|
grokToolValidation: proxy?.toolValidationFailure ?? null,
|
|
48503
|
-
grokResponseIdentity: proxy?.responseIdentityFailure ?? null
|
|
48692
|
+
grokResponseIdentity: proxy?.responseIdentityFailure ?? null,
|
|
48693
|
+
cause: error48
|
|
48504
48694
|
});
|
|
48505
48695
|
} finally {
|
|
48506
48696
|
try {
|
|
@@ -48610,7 +48800,7 @@ var init_claude_code_schema = __esm({
|
|
|
48610
48800
|
|
|
48611
48801
|
// lib/inference-host/claude-code-policy.ts
|
|
48612
48802
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
48613
|
-
import { dirname as
|
|
48803
|
+
import { dirname as dirname12, resolve as resolve9 } from "node:path";
|
|
48614
48804
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48615
48805
|
var CLAUDE_CODE_EFFORTS, turns, validateClaudeCodePolicy, loadClaudeCodePolicy, compareClaudeCodeVersions;
|
|
48616
48806
|
var init_claude_code_policy = __esm({
|
|
@@ -48642,7 +48832,7 @@ var init_claude_code_policy = __esm({
|
|
|
48642
48832
|
};
|
|
48643
48833
|
loadClaudeCodePolicy = async () => {
|
|
48644
48834
|
if (typeof define_VTX_CLAUDE_CODE_POLICY_default !== "undefined") return validateClaudeCodePolicy(define_VTX_CLAUDE_CODE_POLICY_default);
|
|
48645
|
-
const config2 = parse(await readFile9(
|
|
48835
|
+
const config2 = parse(await readFile9(resolve9(dirname12(fileURLToPath2(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
48646
48836
|
return validateClaudeCodePolicy(config2.external_inference?.claude_code_adapter);
|
|
48647
48837
|
};
|
|
48648
48838
|
compareClaudeCodeVersions = (left, right) => {
|
|
@@ -48661,7 +48851,7 @@ var init_claude_code_policy = __esm({
|
|
|
48661
48851
|
import { spawn as spawn9 } from "node:child_process";
|
|
48662
48852
|
import { access as access4, lstat as lstat9, readdir as readdir7, rm as rm12 } from "node:fs/promises";
|
|
48663
48853
|
import { constants as constants3 } from "node:fs";
|
|
48664
|
-
import { delimiter, isAbsolute as
|
|
48854
|
+
import { delimiter, isAbsolute as isAbsolute7, join as join14 } from "node:path";
|
|
48665
48855
|
var HOST_RUNTIME_POLICY12, BINARY_RECORD, stringOrNull, claudeCodeStateOptions, claudeCodeRuntimeEnvironment, claudeCodeLoginEnvironment, executableNames, executable, findClaudeCodeExecutable, runCommand, readVersion, resolveClaudeCodeBinary, prepareClaudeCodeConfigDir, readClaudeCodeAuthStatus, assertClaudeCodeSubscription, AUTHORIZE_URL, runClaudeCodeAuthentication, claudeCodeLogoutBinary, cleanupClaudeCodeOwnedState, SESSION_ID, claudeCodeSessionTranscriptExists, removeClaudeCodeSessionTranscript;
|
|
48666
48856
|
var init_claude_code_runtime = __esm({
|
|
48667
48857
|
"lib/inference-host/claude-code-runtime.ts"() {
|
|
@@ -48733,7 +48923,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48733
48923
|
findClaudeCodeExecutable = async (env = process.env) => {
|
|
48734
48924
|
const explicit = String(env.VTX_CLAUDE_CODE_BIN || "").trim();
|
|
48735
48925
|
if (explicit) {
|
|
48736
|
-
if (!
|
|
48926
|
+
if (!isAbsolute7(explicit) || !await executable(explicit)) throw new Error("VTX_CLAUDE_CODE_BIN must name an absolute, executable Claude Code CLI.");
|
|
48737
48927
|
return explicit;
|
|
48738
48928
|
}
|
|
48739
48929
|
for (const directory2 of String(env.PATH || "").split(delimiter).filter(Boolean)) {
|
|
@@ -48744,7 +48934,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48744
48934
|
}
|
|
48745
48935
|
throw new Error("Claude Code is not installed. Install it from https://code.claude.com, then run claude-login again.");
|
|
48746
48936
|
};
|
|
48747
|
-
runCommand = (binaryPath, args, options) => new Promise((
|
|
48937
|
+
runCommand = (binaryPath, args, options) => new Promise((resolve17, reject) => {
|
|
48748
48938
|
options.signal?.throwIfAborted();
|
|
48749
48939
|
const child = spawn9(binaryPath, args, { cwd: options.cwd, env: options.env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
48750
48940
|
let stdout = "";
|
|
@@ -48757,7 +48947,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48757
48947
|
clearTimeout(timer);
|
|
48758
48948
|
options.signal?.removeEventListener("abort", abort);
|
|
48759
48949
|
if (error48) reject(error48);
|
|
48760
|
-
else
|
|
48950
|
+
else resolve17(result);
|
|
48761
48951
|
};
|
|
48762
48952
|
const kill = (reason) => {
|
|
48763
48953
|
child.kill("SIGKILL");
|
|
@@ -48864,7 +49054,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48864
49054
|
throw new Error("No Claude Code CLI was found to sign this host out with. Install Claude Code and run claude-logout again, or run vtx inference-host revoke to remove this host.");
|
|
48865
49055
|
}
|
|
48866
49056
|
options.signal?.throwIfAborted();
|
|
48867
|
-
await new Promise((
|
|
49057
|
+
await new Promise((resolve17, reject) => {
|
|
48868
49058
|
const child = spawn9(binary.path, ["auth", action, ...action === "login" ? ["--claudeai"] : []], {
|
|
48869
49059
|
cwd: options.stateRoot,
|
|
48870
49060
|
env: action === "login" ? claudeCodeLoginEnvironment(options.configDir) : claudeCodeRuntimeEnvironment(options.configDir),
|
|
@@ -48921,7 +49111,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48921
49111
|
input?.removeListener("data", forward);
|
|
48922
49112
|
input?.pause();
|
|
48923
49113
|
if (failed2 || code !== 0) reject(new Error(action === "login" ? "Claude Code sign-in did not complete. Run claude-login again and finish signing in within the time limit." : "Claude Code logout did not complete."));
|
|
48924
|
-
else
|
|
49114
|
+
else resolve17();
|
|
48925
49115
|
});
|
|
48926
49116
|
});
|
|
48927
49117
|
return binary;
|
|
@@ -48995,7 +49185,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48995
49185
|
import { spawn as spawn10 } from "node:child_process";
|
|
48996
49186
|
import { createHash as createHash10, randomUUID as randomUUID10 } from "node:crypto";
|
|
48997
49187
|
import { lstat as lstat10, mkdtemp as mkdtemp5, realpath as realpath8, rm as rm13 } from "node:fs/promises";
|
|
48998
|
-
import { basename as basename5, dirname as
|
|
49188
|
+
import { basename as basename5, dirname as dirname13, join as join15, resolve as resolve10 } from "node:path";
|
|
48999
49189
|
var HOST_RUNTIME_POLICY13, object4, count3, AGENT_TOOLS, MCP_SERVER, OWNER_MARKER, WORKSPACES, OWNED_WORKSPACE, SESSION_ID2, notOwned, claudeCodeModelCapabilities, claudeCodeLimitRetryAtMs, claudeCodeUsage, claudeCodeEffectiveModel, resultLooksRateLimited, resultLooksUnauthenticated, claudeCodeAgentTools, requestRejectedBeforeInference, ClaudeCodeAdapter;
|
|
49000
49190
|
var init_claude_code_adapter = __esm({
|
|
49001
49191
|
"lib/inference-host/claude-code-adapter.ts"() {
|
|
@@ -49103,7 +49293,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49103
49293
|
this.options = options;
|
|
49104
49294
|
}
|
|
49105
49295
|
get workspaceRoot() {
|
|
49106
|
-
return join15(
|
|
49296
|
+
return join15(resolve10(this.options.stateRoot), WORKSPACES);
|
|
49107
49297
|
}
|
|
49108
49298
|
async binary() {
|
|
49109
49299
|
await ensureInferencePrivateDirectory(this.options.stateRoot);
|
|
@@ -49132,7 +49322,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49132
49322
|
`);
|
|
49133
49323
|
}
|
|
49134
49324
|
async owner(workspace) {
|
|
49135
|
-
if (workspace !==
|
|
49325
|
+
if (workspace !== resolve10(workspace) || dirname13(workspace) !== this.workspaceRoot || !OWNED_WORKSPACE.test(basename5(workspace))) throw notOwned();
|
|
49136
49326
|
const info = await lstat10(workspace);
|
|
49137
49327
|
if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(workspace) !== workspace) throw notOwned();
|
|
49138
49328
|
let value;
|
|
@@ -49159,7 +49349,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49159
49349
|
signal.throwIfAborted();
|
|
49160
49350
|
const status = await readClaudeCodeAuthStatus(binary, { ...this.options, signal });
|
|
49161
49351
|
try {
|
|
49162
|
-
assertClaudeCodeSubscription(status,
|
|
49352
|
+
assertClaudeCodeSubscription(status, resolve10(this.options.configDir));
|
|
49163
49353
|
} catch (error48) {
|
|
49164
49354
|
throw new CodexAppServerError({
|
|
49165
49355
|
message: error48.message,
|
|
@@ -49222,7 +49412,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49222
49412
|
}
|
|
49223
49413
|
const workspace = resumed?.threadPath ?? await this.createWorkspace(agent ? "agent" : "attempt");
|
|
49224
49414
|
const sessionId = resumed?.threadId ?? (agent ? randomUUID10() : null);
|
|
49225
|
-
const resumable = resumed !== null && await claudeCodeSessionTranscriptExists(
|
|
49415
|
+
const resumable = resumed !== null && await claudeCodeSessionTranscriptExists(resolve10(this.options.configDir), resumed.threadId);
|
|
49226
49416
|
let retained = Boolean(resumed);
|
|
49227
49417
|
let tools = null;
|
|
49228
49418
|
let child = null;
|
|
@@ -49349,7 +49539,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49349
49539
|
windowsHide: true
|
|
49350
49540
|
}));
|
|
49351
49541
|
provider?.onProviderDispatch?.();
|
|
49352
|
-
child = spawnProcess(binary.path, args, { cwd: workspace, env: claudeCodeRuntimeEnvironment(
|
|
49542
|
+
child = spawnProcess(binary.path, args, { cwd: workspace, env: claudeCodeRuntimeEnvironment(resolve10(this.options.configDir)) });
|
|
49353
49543
|
this.active.add(child);
|
|
49354
49544
|
const running = child;
|
|
49355
49545
|
const result = await new Promise((resolveResult, rejectResult) => {
|
|
@@ -49558,7 +49748,8 @@ var init_claude_code_adapter = __esm({
|
|
|
49558
49748
|
category: signal.aborted ? "cancelled" : Date.now() >= original.deadlineAtMs ? "timeout" : code === "claude_code_subscription_required" ? "auth" : "adapter",
|
|
49559
49749
|
code,
|
|
49560
49750
|
retryable: false,
|
|
49561
|
-
dispatchOutcome: outcome
|
|
49751
|
+
dispatchOutcome: outcome,
|
|
49752
|
+
cause: error48
|
|
49562
49753
|
});
|
|
49563
49754
|
} finally {
|
|
49564
49755
|
if (child) this.active.delete(child);
|
|
@@ -49610,7 +49801,7 @@ var init_grok_auth = __esm({
|
|
|
49610
49801
|
await prepareGrokHome(options.grokHome);
|
|
49611
49802
|
const binary = await resolvePinnedGrokBinary(options.stateRoot);
|
|
49612
49803
|
options.signal?.throwIfAborted();
|
|
49613
|
-
await new Promise((
|
|
49804
|
+
await new Promise((resolve17, reject) => {
|
|
49614
49805
|
const child = spawn11(binary.path, ["--no-auto-update", action, ...action === "login" ? ["--device-auth"] : []], {
|
|
49615
49806
|
cwd: options.grokHome,
|
|
49616
49807
|
env: grokRuntimeEnvironment(options.grokHome),
|
|
@@ -49672,7 +49863,7 @@ var init_grok_auth = __esm({
|
|
|
49672
49863
|
child.once("close", (code) => {
|
|
49673
49864
|
cleanup();
|
|
49674
49865
|
if (code !== 0 || failed2 || options.signal?.aborted) reject(new Error(`Grok ${action} did not complete. Run grok-${action} again.`));
|
|
49675
|
-
else
|
|
49866
|
+
else resolve17();
|
|
49676
49867
|
});
|
|
49677
49868
|
if (options.signal?.aborted) stop();
|
|
49678
49869
|
});
|
|
@@ -49685,7 +49876,7 @@ import { spawn as spawn12 } from "node:child_process";
|
|
|
49685
49876
|
import { randomUUID as randomUUID11, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
49686
49877
|
import { createServer as createServer5 } from "node:http";
|
|
49687
49878
|
import { access as access5, lstat as lstat11, readdir as readdir8, realpath as realpath9, rm as rm14 } from "node:fs/promises";
|
|
49688
|
-
import { basename as basename6, dirname as
|
|
49879
|
+
import { basename as basename6, dirname as dirname14, join as join16, resolve as resolve11 } from "node:path";
|
|
49689
49880
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
49690
49881
|
var import_ajv3, HOST_RUNTIME_POLICY15, failure, object5, validModel, receiptUsage, assertOwnedRuntime, cleanupExoOwnedState, ExoForegroundAdapter;
|
|
49691
49882
|
var init_exo_adapter = __esm({
|
|
@@ -49802,7 +49993,7 @@ var init_exo_adapter = __esm({
|
|
|
49802
49993
|
environment(runtimeRoot) {
|
|
49803
49994
|
return {
|
|
49804
49995
|
NODE_ENV: "production",
|
|
49805
|
-
PATH: `${
|
|
49996
|
+
PATH: `${dirname14(process.execPath)}:/usr/local/bin:/usr/bin:/bin`,
|
|
49806
49997
|
HOME: runtimeRoot,
|
|
49807
49998
|
XDG_CONFIG_HOME: join16(runtimeRoot, "config"),
|
|
49808
49999
|
TMPDIR: runtimeRoot,
|
|
@@ -49859,8 +50050,8 @@ var init_exo_adapter = __esm({
|
|
|
49859
50050
|
}
|
|
49860
50051
|
async ownedRoot(thread) {
|
|
49861
50052
|
const parent = await realpath9(this.options.stateRoot);
|
|
49862
|
-
const root =
|
|
49863
|
-
if (!/^[a-f0-9-]{36}$/u.test(thread.threadId) ||
|
|
50053
|
+
const root = resolve11(thread.threadPath);
|
|
50054
|
+
if (!/^[a-f0-9-]{36}$/u.test(thread.threadId) || dirname14(root) !== parent || basename6(root) !== `agent-${thread.threadId}`) throw failure("exo_thread_not_owned");
|
|
49864
50055
|
await assertOwnedRuntime(root, thread.threadId);
|
|
49865
50056
|
return root;
|
|
49866
50057
|
}
|
|
@@ -50099,7 +50290,7 @@ var init_exo_adapter = __esm({
|
|
|
50099
50290
|
|
|
50100
50291
|
// lib/inference-host/exo-policy.ts
|
|
50101
50292
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
50102
|
-
import { dirname as
|
|
50293
|
+
import { dirname as dirname15, resolve as resolve12 } from "node:path";
|
|
50103
50294
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
50104
50295
|
var validateExoPolicy, loadExoPolicy;
|
|
50105
50296
|
var init_exo_policy = __esm({
|
|
@@ -50134,7 +50325,7 @@ var init_exo_policy = __esm({
|
|
|
50134
50325
|
};
|
|
50135
50326
|
loadExoPolicy = async () => {
|
|
50136
50327
|
if (typeof define_VTX_EXO_POLICY_default !== "undefined") return validateExoPolicy(define_VTX_EXO_POLICY_default);
|
|
50137
|
-
const config2 = parse(await readFile10(
|
|
50328
|
+
const config2 = parse(await readFile10(resolve12(dirname15(fileURLToPath4(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
50138
50329
|
const endpoints = config2.llm?.openai_compatible?.endpoints;
|
|
50139
50330
|
return validateExoPolicy({
|
|
50140
50331
|
...config2.external_inference?.exo_adapter,
|
|
@@ -50312,7 +50503,7 @@ var init_exo_credential_store = __esm({
|
|
|
50312
50503
|
|
|
50313
50504
|
// lib/inference-host/pi-model-policy.ts
|
|
50314
50505
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
50315
|
-
import { dirname as
|
|
50506
|
+
import { dirname as dirname16, resolve as resolve13 } from "node:path";
|
|
50316
50507
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
50317
50508
|
var validatePiModelPolicy, loadPiModelPolicy;
|
|
50318
50509
|
var init_pi_model_policy = __esm({
|
|
@@ -50341,7 +50532,7 @@ var init_pi_model_policy = __esm({
|
|
|
50341
50532
|
if (typeof define_VTX_PI_MODEL_POLICY_default !== "undefined") {
|
|
50342
50533
|
return validatePiModelPolicy(define_VTX_PI_MODEL_POLICY_default);
|
|
50343
50534
|
}
|
|
50344
|
-
const config2 = parse(await readFile11(
|
|
50535
|
+
const config2 = parse(await readFile11(resolve13(dirname16(fileURLToPath5(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
50345
50536
|
const external = config2.external_inference;
|
|
50346
50537
|
const pi = external?.pi_adapter;
|
|
50347
50538
|
return validatePiModelPolicy(pi?.qualified_models);
|
|
@@ -50700,7 +50891,7 @@ var init_durable_adapter = __esm({
|
|
|
50700
50891
|
|
|
50701
50892
|
// lib/inference-host/service-launcher-state.ts
|
|
50702
50893
|
import { access as access6, readFile as readFile12, rm as rm15 } from "node:fs/promises";
|
|
50703
|
-
import { dirname as
|
|
50894
|
+
import { dirname as dirname17, isAbsolute as isAbsolute8, join as join17, relative as relative5, resolve as resolve14 } from "node:path";
|
|
50704
50895
|
var launcherSibling, launcherLockPath, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
|
|
50705
50896
|
var init_service_launcher_state = __esm({
|
|
50706
50897
|
"lib/inference-host/service-launcher-state.ts"() {
|
|
@@ -50716,13 +50907,13 @@ var init_service_launcher_state = __esm({
|
|
|
50716
50907
|
};
|
|
50717
50908
|
launcherLockPath = (manifest) => launcherSibling(manifest, ".service-launcher.lock");
|
|
50718
50909
|
within = (parent, child) => {
|
|
50719
|
-
const part =
|
|
50720
|
-
return Boolean(part) && !part.startsWith("..") && !
|
|
50910
|
+
const part = relative5(resolve14(parent), resolve14(child));
|
|
50911
|
+
return Boolean(part) && !part.startsWith("..") && !isAbsolute8(part);
|
|
50721
50912
|
};
|
|
50722
50913
|
launcherSelection = (manifest, value) => {
|
|
50723
50914
|
if (!value || typeof value !== "object") return null;
|
|
50724
50915
|
const r = value;
|
|
50725
|
-
if (r.schema_version !== "vtx_inference_service_release_v1" || r.package_name !== "@vtxmacro/cli" || typeof r.package_version !== "string" || !/^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(r.package_version) || typeof r.integrity !== "string" || typeof r.selected_at !== "string" || !Number.isFinite(Date.parse(r.selected_at)) || typeof r.script !== "string" || !
|
|
50916
|
+
if (r.schema_version !== "vtx_inference_service_release_v1" || r.package_name !== "@vtxmacro/cli" || typeof r.package_version !== "string" || !/^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(r.package_version) || typeof r.integrity !== "string" || typeof r.selected_at !== "string" || !Number.isFinite(Date.parse(r.selected_at)) || typeof r.script !== "string" || !isAbsolute8(r.script) || /[\r\n\0]/u.test(r.script) || !within(launcherSibling(manifest, ".service-releases"), r.script)) return null;
|
|
50726
50917
|
return r;
|
|
50727
50918
|
};
|
|
50728
50919
|
readLauncherSelection = async (manifest) => {
|
|
@@ -50746,9 +50937,9 @@ var init_service_launcher_state = __esm({
|
|
|
50746
50937
|
const target = (v) => {
|
|
50747
50938
|
if (!v || typeof v !== "object") return false;
|
|
50748
50939
|
const t = v;
|
|
50749
|
-
return typeof t.package_version === "string" && /^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(t.package_version) && typeof t.script === "string" &&
|
|
50940
|
+
return typeof t.package_version === "string" && /^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(t.package_version) && typeof t.script === "string" && isAbsolute8(t.script) && !/[\r\n\0]/u.test(t.script) && (within(launcherSibling(manifest, ".service-releases"), t.script) || resolve14(t.script) === resolve14(launcherSibling(manifest, ".service-bootstrap.previous.js"))) && (t.selection === null || (() => {
|
|
50750
50941
|
const selected = launcherSelection(manifest, t.selection);
|
|
50751
|
-
return Boolean(selected && selected.package_version === t.package_version && (
|
|
50942
|
+
return Boolean(selected && selected.package_version === t.package_version && (resolve14(t.script) === resolve14(join17(dirname17(selected.script), "vtx-service-bootstrap.js")) || resolve14(t.script) === resolve14(launcherSibling(manifest, ".service-bootstrap.previous.js"))));
|
|
50752
50943
|
})());
|
|
50753
50944
|
};
|
|
50754
50945
|
if (r.schema_version !== "vtx_inference_service_launcher_v1" || !target(r.active) || r.previous !== null && !target(r.previous) || typeof r.pending !== "boolean") {
|
|
@@ -50761,7 +50952,7 @@ var init_service_launcher_state = __esm({
|
|
|
50761
50952
|
`);
|
|
50762
50953
|
};
|
|
50763
50954
|
targetForSelection = async (selection) => {
|
|
50764
|
-
const script = join17(
|
|
50955
|
+
const script = join17(dirname17(selection.script), "vtx-service-bootstrap.js");
|
|
50765
50956
|
await access6(script);
|
|
50766
50957
|
return { package_version: selection.package_version, script, selection };
|
|
50767
50958
|
};
|
|
@@ -50774,7 +50965,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
50774
50965
|
import { createReadStream, createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
50775
50966
|
import { access as access7, appendFile as appendFile2, chmod as chmod4, mkdir as mkdir5, readFile as readFile13, rm as rm16, stat, truncate, writeFile as writeFile5 } from "node:fs/promises";
|
|
50776
50967
|
import { homedir as homedir4 } from "node:os";
|
|
50777
|
-
import { dirname as
|
|
50968
|
+
import { dirname as dirname18, join as join18, resolve as resolve15 } from "node:path";
|
|
50778
50969
|
import { Transform } from "node:stream";
|
|
50779
50970
|
import { pipeline } from "node:stream/promises";
|
|
50780
50971
|
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;
|
|
@@ -51209,10 +51400,10 @@ WantedBy=default.target
|
|
|
51209
51400
|
this.config = config2;
|
|
51210
51401
|
this.platform = dependencies.platform ?? process.platform;
|
|
51211
51402
|
this.home = dependencies.homedir ?? homedir4();
|
|
51212
|
-
this.executable =
|
|
51213
|
-
this.script =
|
|
51214
|
-
this.bootstrapScript =
|
|
51215
|
-
dependencies.bootstrapScript ?? join18(
|
|
51403
|
+
this.executable = resolve15(dependencies.executable ?? process.execPath);
|
|
51404
|
+
this.script = resolve15(dependencies.script ?? process.argv[1] ?? "");
|
|
51405
|
+
this.bootstrapScript = resolve15(
|
|
51406
|
+
dependencies.bootstrapScript ?? join18(dirname18(this.script), "vtx-service-launcher.js")
|
|
51216
51407
|
);
|
|
51217
51408
|
this.username = dependencies.username ?? ([process.env.USERDOMAIN, process.env.USERNAME].filter(Boolean).join("\\") || process.env.USER || "");
|
|
51218
51409
|
this.windowsDirectory = (dependencies.windowsDirectory ?? process.env.SystemRoot ?? process.env.WINDIR ?? "C:\\Windows").replace(/[\\/]+$/u, "");
|
|
@@ -51456,7 +51647,7 @@ ${result.stderr}`)) {
|
|
|
51456
51647
|
if (this.bootstrapScript.endsWith("vtx-service-launcher.js") && !existingRecovery) {
|
|
51457
51648
|
await probeInferenceHostLauncher(manifest.executable, this.serviceBootstrapPath(), launcherBytes, this.runCommand);
|
|
51458
51649
|
const core = launcherSibling(this.manifestPath(), ".service-bootstrap.previous.js");
|
|
51459
|
-
const coreBytes = await readFile13(join18(
|
|
51650
|
+
const coreBytes = await readFile13(join18(dirname18(this.bootstrapScript), "vtx-service-bootstrap.js"), "utf8");
|
|
51460
51651
|
await probeInferenceHostLauncher(manifest.executable, core, coreBytes, this.runCommand);
|
|
51461
51652
|
await writeAtomicInferencePrivateFile(core, coreBytes);
|
|
51462
51653
|
await writeLauncherState(this.manifestPath(), {
|
|
@@ -51468,7 +51659,7 @@ ${result.stderr}`)) {
|
|
|
51468
51659
|
}
|
|
51469
51660
|
if (!existingRecovery) await writeAtomicInferencePrivateFile(this.serviceBootstrapPath(), launcherBytes);
|
|
51470
51661
|
await chmod4(this.serviceBootstrapPath(), OWNER_ONLY_DIRECTORY_MODE);
|
|
51471
|
-
await mkdir5(
|
|
51662
|
+
await mkdir5(dirname18(this.definitionPath()), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
51472
51663
|
if (this.platform === "win32") {
|
|
51473
51664
|
await writeAtomicInferencePrivateFile(
|
|
51474
51665
|
this.windowsLauncherPath(),
|
|
@@ -51658,7 +51849,7 @@ ${cleanup.stderr}`)) {
|
|
|
51658
51849
|
}
|
|
51659
51850
|
if (this.config.credentialFilePath && otherWorkers.some((worker) => {
|
|
51660
51851
|
const otherPath = worker.runtime_environment.VTX_INFERENCE_HOST_CREDENTIAL_FILE;
|
|
51661
|
-
return otherPath &&
|
|
51852
|
+
return otherPath && resolve15(otherPath) === resolve15(this.config.credentialFilePath);
|
|
51662
51853
|
})) {
|
|
51663
51854
|
throw new Error(
|
|
51664
51855
|
"Each inference-host instance must use a different private credential file."
|
|
@@ -52056,7 +52247,7 @@ ${result.stderr}`)) {
|
|
|
52056
52247
|
const state2 = sink;
|
|
52057
52248
|
const write = state2.tail.then(async () => {
|
|
52058
52249
|
if (state2.bytes === null) {
|
|
52059
|
-
await mkdir5(
|
|
52250
|
+
await mkdir5(dirname18(path), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
52060
52251
|
state2.bytes = await serviceLogSize(path);
|
|
52061
52252
|
}
|
|
52062
52253
|
await appendFile2(path, text2, { encoding: "utf8", mode: OWNER_ONLY_FILE_MODE });
|
|
@@ -52209,7 +52400,7 @@ ${result.stderr}`)) {
|
|
|
52209
52400
|
runInferenceHostServiceSupervisor = async (manifestPath, options = {}) => {
|
|
52210
52401
|
const storedInitialManifest = await readInferenceHostServiceManifest(manifestPath);
|
|
52211
52402
|
if (!storedInitialManifest) throw new Error("Inference-host service manifest is missing.");
|
|
52212
|
-
const serviceScript = options.serviceScript ?
|
|
52403
|
+
const serviceScript = options.serviceScript ? resolve15(options.serviceScript) : null;
|
|
52213
52404
|
const withServiceScript = (manifest) => serviceScript ? { ...manifest, script: serviceScript } : manifest;
|
|
52214
52405
|
const initialManifest = withServiceScript(storedInitialManifest);
|
|
52215
52406
|
const desiredPath = manifestPath.replace(/\.service\.json$/u, ".service-desired.json");
|
|
@@ -52247,10 +52438,10 @@ ${result.stderr}`)) {
|
|
|
52247
52438
|
const current = await readManifestAcrossAtomicReplacement(manifestPath);
|
|
52248
52439
|
if (!current || current.generation !== appliedManifest.generation || !await readDesiredAcrossAtomicReplacement(desiredPath) || signal.aborted) return;
|
|
52249
52440
|
const selected = await readLauncherSelection(manifestPath);
|
|
52250
|
-
if (!selected || selected.package_version !== agent_cli_release_default.package_version ||
|
|
52441
|
+
if (!selected || selected.package_version !== agent_cli_release_default.package_version || resolve15(selected.script) !== serviceScript) return;
|
|
52251
52442
|
if (process.env.VTX_INFERENCE_HOST_LAUNCHER_PROTOCOL !== "1") {
|
|
52252
52443
|
const launcherPath = launcherSibling(manifestPath, ".service-bootstrap.js");
|
|
52253
|
-
const bytes3 = await readFile13(join18(
|
|
52444
|
+
const bytes3 = await readFile13(join18(dirname18(serviceScript), "vtx-service-launcher.js"), "utf8");
|
|
52254
52445
|
await (options.probeLauncher ?? probeInferenceHostLauncher)(current.executable, launcherPath, bytes3);
|
|
52255
52446
|
const existing = await readLauncherState(manifestPath);
|
|
52256
52447
|
if (!existing) throw new Error("Previous private service release is unavailable; refusing unsafe launcher migration.");
|
|
@@ -52533,7 +52724,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
52533
52724
|
import { spawn as spawn14 } from "node:child_process";
|
|
52534
52725
|
import { lstat as lstat12, realpath as realpath10, rm as rm17 } from "node:fs/promises";
|
|
52535
52726
|
import { hostname as osHostname } from "node:os";
|
|
52536
|
-
import { join as join19, resolve as
|
|
52727
|
+
import { join as join19, resolve as resolve16 } from "node:path";
|
|
52537
52728
|
async function runInferenceHostCli(argv2, env = process.env, dependencies = {}) {
|
|
52538
52729
|
const warnings = [];
|
|
52539
52730
|
try {
|
|
@@ -52962,7 +53153,7 @@ Durable service:
|
|
|
52962
53153
|
if (!raw?.trim()) throw new Error(`${argument} requires a value.`);
|
|
52963
53154
|
if (argument === "--adapter") adapter = raw.trim();
|
|
52964
53155
|
if (argument === "--provider") providerId = raw.trim();
|
|
52965
|
-
if (argument === "--exo-root") exoRoot =
|
|
53156
|
+
if (argument === "--exo-root") exoRoot = resolve16(raw.trim());
|
|
52966
53157
|
if (argument === "--model") modelId = raw.trim();
|
|
52967
53158
|
if (argument === "--model-label") modelLabel = raw.trim();
|
|
52968
53159
|
if (argument === "--effort") reasoningEffort = raw.trim();
|
|
@@ -52978,7 +53169,7 @@ Durable service:
|
|
|
52978
53169
|
throw new Error(`--lines must be an integer from 1 through ${HOST_RUNTIME_POLICY16.cli_log_lines_max}.`);
|
|
52979
53170
|
}
|
|
52980
53171
|
}
|
|
52981
|
-
if (argument === "--service-manifest") serviceManifestPath =
|
|
53172
|
+
if (argument === "--service-manifest") serviceManifestPath = resolve16(raw.trim());
|
|
52982
53173
|
if (argument === "--instance") {
|
|
52983
53174
|
instanceName = raw.trim();
|
|
52984
53175
|
instanceExplicit = true;
|
|
@@ -53205,7 +53396,7 @@ Durable service:
|
|
|
53205
53396
|
try {
|
|
53206
53397
|
const before = await lstat12(path);
|
|
53207
53398
|
const canonical = await realpath10(path);
|
|
53208
|
-
const isPrivate = before.isFile() && !before.isSymbolicLink() && canonical ===
|
|
53399
|
+
const isPrivate = before.isFile() && !before.isSymbolicLink() && canonical === resolve16(path) && before.size <= HOST_RUNTIME_POLICY16.codex_auth_file_max_bytes && (process.platform === "win32" || (before.mode & GROUP_OTHER_PERMISSION_BITS) === 0 && (typeof process.getuid !== "function" || before.uid === process.getuid()));
|
|
53209
53400
|
return { present: true, private: isPrivate };
|
|
53210
53401
|
} catch (error48) {
|
|
53211
53402
|
if (error48.code === "ENOENT") {
|
|
@@ -54553,7 +54744,7 @@ Waiting for approval...
|
|
|
54553
54744
|
const session = await agentSession(config2, dependencies, warnings);
|
|
54554
54745
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
54555
54746
|
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
54556
|
-
await new Promise((
|
|
54747
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
54557
54748
|
});
|
|
54558
54749
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
54559
54750
|
while (true) {
|
|
@@ -55156,7 +55347,7 @@ Waiting for approval...
|
|
|
55156
55347
|
}
|
|
55157
55348
|
if (parsed.once && !commandLock) break;
|
|
55158
55349
|
await (dependencies.sleep ?? (async (milliseconds) => {
|
|
55159
|
-
await new Promise((
|
|
55350
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
55160
55351
|
}))(retryDelayMs);
|
|
55161
55352
|
}
|
|
55162
55353
|
return {
|
|
@@ -55185,7 +55376,7 @@ Waiting for approval...
|
|
|
55185
55376
|
const session = await agentSession(config2, dependencies, warnings);
|
|
55186
55377
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
55187
55378
|
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
55188
|
-
await new Promise((
|
|
55379
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
55189
55380
|
});
|
|
55190
55381
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
55191
55382
|
while (true) {
|
|
@@ -55543,7 +55734,7 @@ Waiting for approval...
|
|
|
55543
55734
|
) || new Set(record6.cleanup_confirmed_attempt_ids).size !== record6.cleanup_confirmed_attempt_ids.length || [...record6.cleanup_confirmed_attempt_ids].sort().join("\0") !== record6.cleanup_confirmed_attempt_ids.join("\0") || typeof record6.started_at !== "string" || !Number.isFinite(Date.parse(record6.started_at)) || new Date(record6.started_at).toISOString() !== record6.started_at) {
|
|
55544
55735
|
throw new Error("Inference-host service recovery transaction is invalid.");
|
|
55545
55736
|
}
|
|
55546
|
-
if (
|
|
55737
|
+
if (resolve16(record6.recovery_backup_path) !== resolve16(recoveryBackupPath(config2, record6.transaction_id))) {
|
|
55547
55738
|
throw new Error("Inference-host service recovery backup path is invalid.");
|
|
55548
55739
|
}
|
|
55549
55740
|
return record6;
|
|
@@ -55825,7 +56016,7 @@ Waiting for approval...
|
|
|
55825
56016
|
{
|
|
55826
56017
|
signal: cancellation.signal,
|
|
55827
56018
|
quiesceSignal: cancellation.quiesceSignal,
|
|
55828
|
-
serviceScript:
|
|
56019
|
+
serviceScript: resolve16(process.argv[1] ?? ""),
|
|
55829
56020
|
controlLockPath: `${supervisorConfig.supervisorProcessLockPath}.service-control`
|
|
55830
56021
|
}
|
|
55831
56022
|
);
|
|
@@ -56051,7 +56242,7 @@ Waiting for approval...
|
|
|
56051
56242
|
...selectedEnv,
|
|
56052
56243
|
...retainedEnvironment
|
|
56053
56244
|
});
|
|
56054
|
-
if (
|
|
56245
|
+
if (resolve16(installedConfig.statePath) !== resolve16(baseConfig.statePath)) {
|
|
56055
56246
|
throw new Error(
|
|
56056
56247
|
"Installed inference-host service manifest does not match the requested local state path."
|
|
56057
56248
|
);
|
|
@@ -56478,7 +56669,7 @@ import {
|
|
|
56478
56669
|
writeFileSync
|
|
56479
56670
|
} from "node:fs";
|
|
56480
56671
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
56481
|
-
import { dirname as
|
|
56672
|
+
import { dirname as dirname19 } from "node:path";
|
|
56482
56673
|
function openClientRuntimeProtectionStorage(runtimeStatePath, profileId) {
|
|
56483
56674
|
const path = clientRuntimeProtectionStatePath(runtimeStatePath, profileId);
|
|
56484
56675
|
const storage3 = new FileBackedRuntimeStorage(path);
|
|
@@ -56548,7 +56739,7 @@ var init_protection_storage = __esm({
|
|
|
56548
56739
|
}
|
|
56549
56740
|
}
|
|
56550
56741
|
writeValues(values) {
|
|
56551
|
-
mkdirSync(
|
|
56742
|
+
mkdirSync(dirname19(this.path), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
56552
56743
|
const serialized = `${JSON.stringify(values)}
|
|
56553
56744
|
`;
|
|
56554
56745
|
const temporaryPath = `${this.path}.${process.pid}.${randomUUID15()}.tmp`;
|
|
@@ -59213,7 +59404,7 @@ var init_shared = __esm({
|
|
|
59213
59404
|
const readsGzip = noteRequestEncodings(input, response);
|
|
59214
59405
|
return sent !== init2 && refusedUnread(response, readsGzip) ? sendApiRequest(input, init2) : response;
|
|
59215
59406
|
};
|
|
59216
|
-
sleep = (ms) => new Promise((
|
|
59407
|
+
sleep = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
59217
59408
|
DEVICE_CLOCK_HEADER = "X-Device-Clock-Ms";
|
|
59218
59409
|
deviceClockHeader = () => ({ [DEVICE_CLOCK_HEADER]: String(Date.now()) });
|
|
59219
59410
|
API_NO_ROUTE_DETAIL = "Not Found";
|
|
@@ -59252,10 +59443,10 @@ var init_shared = __esm({
|
|
|
59252
59443
|
raceWithAbortSignal = async (promise2, signal) => {
|
|
59253
59444
|
if (!signal) return promise2;
|
|
59254
59445
|
if (signal.aborted) throw toAbortError(signal.reason);
|
|
59255
|
-
return new Promise((
|
|
59446
|
+
return new Promise((resolve17, reject) => {
|
|
59256
59447
|
const onAbort = () => reject(toAbortError(signal.reason));
|
|
59257
59448
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
59258
|
-
promise2.then(
|
|
59449
|
+
promise2.then(resolve17, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
59259
59450
|
});
|
|
59260
59451
|
};
|
|
59261
59452
|
shareClientGetRequest = async (key, request, options) => {
|
|
@@ -61252,14 +61443,14 @@ var init_runtime_event_batch = __esm({
|
|
|
61252
61443
|
);
|
|
61253
61444
|
}
|
|
61254
61445
|
};
|
|
61255
|
-
queueRuntimeEvent = (key, body, send) => new Promise((
|
|
61446
|
+
queueRuntimeEvent = (key, body, send) => new Promise((resolve17, reject) => {
|
|
61256
61447
|
let group = groups.get(key);
|
|
61257
61448
|
if (!group) {
|
|
61258
61449
|
group = { events: [], timer: null, sendBatch: send.batch, sendOne: send.one };
|
|
61259
61450
|
groups.set(key, group);
|
|
61260
61451
|
group.timer = setTimeout(() => flush(key), EVENT_BATCH.window_milliseconds);
|
|
61261
61452
|
}
|
|
61262
|
-
group.events.push({ body, resolve:
|
|
61453
|
+
group.events.push({ body, resolve: resolve17, reject });
|
|
61263
61454
|
if (group.events.length >= EVENT_BATCH.max_events) flush(key);
|
|
61264
61455
|
});
|
|
61265
61456
|
eventBody = (payload) => ({
|
|
@@ -62191,7 +62382,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62191
62382
|
checkAbort = (signal) => {
|
|
62192
62383
|
if (signal?.aborted) throw abortError2(signal);
|
|
62193
62384
|
};
|
|
62194
|
-
wait = (ms, signal) => new Promise((
|
|
62385
|
+
wait = (ms, signal) => new Promise((resolve17, reject) => {
|
|
62195
62386
|
checkAbort(signal);
|
|
62196
62387
|
const aborted2 = () => {
|
|
62197
62388
|
clearTimeout(timer);
|
|
@@ -62199,7 +62390,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62199
62390
|
};
|
|
62200
62391
|
const timer = setTimeout(() => {
|
|
62201
62392
|
signal?.removeEventListener("abort", aborted2);
|
|
62202
|
-
|
|
62393
|
+
resolve17();
|
|
62203
62394
|
}, Math.min(ms, SET_TIMEOUT_MAX_DELAY_MS));
|
|
62204
62395
|
signal?.addEventListener("abort", aborted2, { once: true });
|
|
62205
62396
|
});
|
|
@@ -62866,7 +63057,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62866
63057
|
if (!running) break;
|
|
62867
63058
|
promoteHyperliquidPublicPriority(running.priority, priority.value);
|
|
62868
63059
|
setPendingPhase("cache");
|
|
62869
|
-
await new Promise((
|
|
63060
|
+
await new Promise((resolve17, reject) => {
|
|
62870
63061
|
const promoteOwner = (next) => promoteHyperliquidPublicPriority(running.priority, next);
|
|
62871
63062
|
const cleanup = () => {
|
|
62872
63063
|
signal.removeEventListener("abort", aborted2);
|
|
@@ -62880,13 +63071,13 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62880
63071
|
signal.addEventListener("abort", aborted2, { once: true });
|
|
62881
63072
|
running.promise.then(() => {
|
|
62882
63073
|
cleanup();
|
|
62883
|
-
|
|
63074
|
+
resolve17();
|
|
62884
63075
|
});
|
|
62885
63076
|
});
|
|
62886
63077
|
checkAbort(signal);
|
|
62887
63078
|
}
|
|
62888
|
-
pending2.set(key, { promise: new Promise((
|
|
62889
|
-
settled2 =
|
|
63079
|
+
pending2.set(key, { promise: new Promise((resolve17) => {
|
|
63080
|
+
settled2 = resolve17;
|
|
62890
63081
|
}), priority });
|
|
62891
63082
|
}
|
|
62892
63083
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
@@ -63163,8 +63354,8 @@ var init_exchange_mutation_fence = __esm({
|
|
|
63163
63354
|
return operation();
|
|
63164
63355
|
}
|
|
63165
63356
|
let markSettled;
|
|
63166
|
-
const settlement = new Promise((
|
|
63167
|
-
markSettled =
|
|
63357
|
+
const settlement = new Promise((resolve17) => {
|
|
63358
|
+
markSettled = resolve17;
|
|
63168
63359
|
});
|
|
63169
63360
|
const activeSettlements = activeSettlementsByScope.get(normalizedScope) ?? /* @__PURE__ */ new Set();
|
|
63170
63361
|
activeSettlements.add(settlement);
|
|
@@ -65428,7 +65619,7 @@ function createGetUrl(options) {
|
|
|
65428
65619
|
request.write(Buffer.from(body));
|
|
65429
65620
|
}
|
|
65430
65621
|
request.end();
|
|
65431
|
-
return new Promise((
|
|
65622
|
+
return new Promise((resolve17, reject) => {
|
|
65432
65623
|
if (signal) {
|
|
65433
65624
|
signal.addListener(() => {
|
|
65434
65625
|
if (abort) {
|
|
@@ -65474,7 +65665,7 @@ function createGetUrl(options) {
|
|
|
65474
65665
|
if (headers2["content-encoding"] === "gzip" && body2) {
|
|
65475
65666
|
body2 = getBytes(gunzipSync3(body2));
|
|
65476
65667
|
}
|
|
65477
|
-
|
|
65668
|
+
resolve17({ statusCode, statusMessage, headers: headers2, body: body2 });
|
|
65478
65669
|
} catch (error48) {
|
|
65479
65670
|
reject(makeError("bad response data", "SERVER_ERROR", {
|
|
65480
65671
|
request: req,
|
|
@@ -65551,7 +65742,7 @@ function unpercent(value) {
|
|
|
65551
65742
|
}));
|
|
65552
65743
|
}
|
|
65553
65744
|
function wait2(delay3) {
|
|
65554
|
-
return new Promise((
|
|
65745
|
+
return new Promise((resolve17) => setTimeout(resolve17, delay3));
|
|
65555
65746
|
}
|
|
65556
65747
|
var MAX_ATTEMPTS, SLOT_INTERVAL, defaultGetUrlFunc, reData, reIpfs, locked, Gateways, fetchSignals, FetchCancelSignal, FetchRequest, FetchResponse;
|
|
65557
65748
|
var init_fetch = __esm({
|
|
@@ -79423,7 +79614,7 @@ var init_provider = __esm({
|
|
|
79423
79614
|
return null;
|
|
79424
79615
|
}
|
|
79425
79616
|
}
|
|
79426
|
-
const waiter = new Promise((
|
|
79617
|
+
const waiter = new Promise((resolve17, reject) => {
|
|
79427
79618
|
const cancellers = [];
|
|
79428
79619
|
const cancel = () => {
|
|
79429
79620
|
cancellers.forEach((c) => c());
|
|
@@ -79444,7 +79635,7 @@ var init_provider = __esm({
|
|
|
79444
79635
|
if (await receipt2.confirmations() >= confirms) {
|
|
79445
79636
|
cancel();
|
|
79446
79637
|
try {
|
|
79447
|
-
|
|
79638
|
+
resolve17(checkReceipt(receipt2));
|
|
79448
79639
|
} catch (error48) {
|
|
79449
79640
|
reject(error48);
|
|
79450
79641
|
}
|
|
@@ -80371,12 +80562,12 @@ var init_contract = __esm({
|
|
|
80371
80562
|
}
|
|
80372
80563
|
const provider = getProvider(this.runner);
|
|
80373
80564
|
assert2(provider != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" });
|
|
80374
|
-
return new Promise((
|
|
80565
|
+
return new Promise((resolve17, reject) => {
|
|
80375
80566
|
const checkCode = async () => {
|
|
80376
80567
|
try {
|
|
80377
80568
|
const code2 = await this.getDeployedCode();
|
|
80378
80569
|
if (code2 != null) {
|
|
80379
|
-
return
|
|
80570
|
+
return resolve17(this);
|
|
80380
80571
|
}
|
|
80381
80572
|
provider.once("block", checkCode);
|
|
80382
80573
|
} catch (error48) {
|
|
@@ -82736,7 +82927,7 @@ var init_abstract_provider = __esm({
|
|
|
82736
82927
|
return t.toLowerCase();
|
|
82737
82928
|
});
|
|
82738
82929
|
const blockHash = "blockHash" in filter ? filter.blockHash : void 0;
|
|
82739
|
-
const
|
|
82930
|
+
const resolve17 = (_address, fromBlock2, toBlock2) => {
|
|
82740
82931
|
let address2 = void 0;
|
|
82741
82932
|
switch (_address.length) {
|
|
82742
82933
|
case 0:
|
|
@@ -82791,10 +82982,10 @@ var init_abstract_provider = __esm({
|
|
|
82791
82982
|
}
|
|
82792
82983
|
if (address.filter((a) => typeof a !== "string").length || fromBlock != null && typeof fromBlock !== "string" || toBlock != null && typeof toBlock !== "string") {
|
|
82793
82984
|
return Promise.all([Promise.all(address), fromBlock, toBlock]).then((result) => {
|
|
82794
|
-
return
|
|
82985
|
+
return resolve17(result[0], result[1], result[2]);
|
|
82795
82986
|
});
|
|
82796
82987
|
}
|
|
82797
|
-
return
|
|
82988
|
+
return resolve17(address, fromBlock, toBlock);
|
|
82798
82989
|
}
|
|
82799
82990
|
/**
|
|
82800
82991
|
* Returns or resolves to a transaction for %%request%%, resolving
|
|
@@ -83168,14 +83359,14 @@ var init_abstract_provider = __esm({
|
|
|
83168
83359
|
if (confirms === 0) {
|
|
83169
83360
|
return this.getTransactionReceipt(hash5);
|
|
83170
83361
|
}
|
|
83171
|
-
return new Promise(async (
|
|
83362
|
+
return new Promise(async (resolve17, reject) => {
|
|
83172
83363
|
let timer = null;
|
|
83173
83364
|
const listener = (async (blockNumber) => {
|
|
83174
83365
|
try {
|
|
83175
83366
|
const receipt = await this.getTransactionReceipt(hash5);
|
|
83176
83367
|
if (receipt != null) {
|
|
83177
83368
|
if (blockNumber - receipt.blockNumber + 1 >= confirms) {
|
|
83178
|
-
|
|
83369
|
+
resolve17(receipt);
|
|
83179
83370
|
if (timer) {
|
|
83180
83371
|
clearTimeout(timer);
|
|
83181
83372
|
timer = null;
|
|
@@ -83949,8 +84140,8 @@ function deepCopy(value) {
|
|
|
83949
84140
|
throw new Error(`should not happen: ${value} (${typeof value})`);
|
|
83950
84141
|
}
|
|
83951
84142
|
function stall(duration3) {
|
|
83952
|
-
return new Promise((
|
|
83953
|
-
setTimeout(
|
|
84143
|
+
return new Promise((resolve17) => {
|
|
84144
|
+
setTimeout(resolve17, duration3);
|
|
83954
84145
|
});
|
|
83955
84146
|
}
|
|
83956
84147
|
function getLowerCase(value) {
|
|
@@ -84091,14 +84282,14 @@ var init_provider_jsonrpc = __esm({
|
|
|
84091
84282
|
async sendTransaction(tx) {
|
|
84092
84283
|
const blockNumber = await this.provider.getBlockNumber();
|
|
84093
84284
|
const hash5 = await this.sendUncheckedTransaction(tx);
|
|
84094
|
-
return await new Promise((
|
|
84285
|
+
return await new Promise((resolve17, reject) => {
|
|
84095
84286
|
const timeouts = [1e3, 100];
|
|
84096
84287
|
let invalids = 0;
|
|
84097
84288
|
const checkTx = async () => {
|
|
84098
84289
|
try {
|
|
84099
84290
|
const tx2 = await this.provider.getTransaction(hash5);
|
|
84100
84291
|
if (tx2 != null) {
|
|
84101
|
-
|
|
84292
|
+
resolve17(tx2.replaceableTransaction(blockNumber));
|
|
84102
84293
|
return;
|
|
84103
84294
|
}
|
|
84104
84295
|
} catch (error48) {
|
|
@@ -84215,7 +84406,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
84215
84406
|
try {
|
|
84216
84407
|
const result = await this._send(payload);
|
|
84217
84408
|
this.emit("debug", { action: "receiveRpcResult", result });
|
|
84218
|
-
for (const { resolve:
|
|
84409
|
+
for (const { resolve: resolve17, reject, payload: payload2 } of batch) {
|
|
84219
84410
|
if (this.destroyed) {
|
|
84220
84411
|
reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload2.method }));
|
|
84221
84412
|
continue;
|
|
@@ -84234,7 +84425,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
84234
84425
|
reject(this.getRpcError(payload2, resp));
|
|
84235
84426
|
continue;
|
|
84236
84427
|
}
|
|
84237
|
-
|
|
84428
|
+
resolve17(resp.result);
|
|
84238
84429
|
}
|
|
84239
84430
|
} catch (error48) {
|
|
84240
84431
|
this.emit("debug", { action: "receiveRpcError", error: error48 });
|
|
@@ -84255,11 +84446,11 @@ var init_provider_jsonrpc = __esm({
|
|
|
84255
84446
|
this.#network = null;
|
|
84256
84447
|
this.#pendingDetectNetwork = null;
|
|
84257
84448
|
{
|
|
84258
|
-
let
|
|
84449
|
+
let resolve17 = null;
|
|
84259
84450
|
const promise2 = new Promise((_resolve) => {
|
|
84260
|
-
|
|
84451
|
+
resolve17 = _resolve;
|
|
84261
84452
|
});
|
|
84262
|
-
this.#notReady = { promise: promise2, resolve:
|
|
84453
|
+
this.#notReady = { promise: promise2, resolve: resolve17 };
|
|
84263
84454
|
}
|
|
84264
84455
|
const staticNetwork = this._getOption("staticNetwork");
|
|
84265
84456
|
if (typeof staticNetwork === "boolean") {
|
|
@@ -84672,9 +84863,9 @@ var init_provider_jsonrpc = __esm({
|
|
|
84672
84863
|
return Promise.reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: method }));
|
|
84673
84864
|
}
|
|
84674
84865
|
const id2 = this.#nextId++;
|
|
84675
|
-
const promise2 = new Promise((
|
|
84866
|
+
const promise2 = new Promise((resolve17, reject) => {
|
|
84676
84867
|
this.#payloads.push({
|
|
84677
|
-
resolve:
|
|
84868
|
+
resolve: resolve17,
|
|
84678
84869
|
reject,
|
|
84679
84870
|
payload: { method, params, id: id2, jsonrpc: "2.0" }
|
|
84680
84871
|
});
|
|
@@ -89653,8 +89844,8 @@ var init_provider_socket = __esm({
|
|
|
89653
89844
|
}
|
|
89654
89845
|
async _send(payload) {
|
|
89655
89846
|
assertArgument(!Array.isArray(payload), "WebSocket does not support batch send", "payload", payload);
|
|
89656
|
-
const promise2 = new Promise((
|
|
89657
|
-
this.#callbacks.set(payload.id, { payload, resolve:
|
|
89847
|
+
const promise2 = new Promise((resolve17, reject) => {
|
|
89848
|
+
this.#callbacks.set(payload.id, { payload, resolve: resolve17, reject });
|
|
89658
89849
|
});
|
|
89659
89850
|
await this._waitUntilReady();
|
|
89660
89851
|
await this._write(JSON.stringify(payload));
|
|
@@ -90063,8 +90254,8 @@ function shuffle(array2) {
|
|
|
90063
90254
|
}
|
|
90064
90255
|
}
|
|
90065
90256
|
function stall2(duration3) {
|
|
90066
|
-
return new Promise((
|
|
90067
|
-
setTimeout(
|
|
90257
|
+
return new Promise((resolve17) => {
|
|
90258
|
+
setTimeout(resolve17, duration3);
|
|
90068
90259
|
});
|
|
90069
90260
|
}
|
|
90070
90261
|
function getTime3() {
|
|
@@ -90950,7 +91141,7 @@ var init_provider_browser = __esm({
|
|
|
90950
91141
|
if (timeout === 0) {
|
|
90951
91142
|
return null;
|
|
90952
91143
|
}
|
|
90953
|
-
return await new Promise((
|
|
91144
|
+
return await new Promise((resolve17, reject) => {
|
|
90954
91145
|
let found = [];
|
|
90955
91146
|
const addProvider = (event) => {
|
|
90956
91147
|
found.push(event.detail);
|
|
@@ -90964,9 +91155,9 @@ var init_provider_browser = __esm({
|
|
|
90964
91155
|
if (options && options.filter) {
|
|
90965
91156
|
const filtered = options.filter(found.map((i2) => Object.assign({}, i2.info)));
|
|
90966
91157
|
if (filtered == null) {
|
|
90967
|
-
|
|
91158
|
+
resolve17(null);
|
|
90968
91159
|
} else if (filtered instanceof _BrowserProvider) {
|
|
90969
|
-
|
|
91160
|
+
resolve17(filtered);
|
|
90970
91161
|
} else {
|
|
90971
91162
|
let match = null;
|
|
90972
91163
|
if (filtered.uuid) {
|
|
@@ -90975,7 +91166,7 @@ var init_provider_browser = __esm({
|
|
|
90975
91166
|
}
|
|
90976
91167
|
if (match) {
|
|
90977
91168
|
const { provider, info } = match;
|
|
90978
|
-
|
|
91169
|
+
resolve17(new _BrowserProvider(provider, void 0, {
|
|
90979
91170
|
providerInfo: info
|
|
90980
91171
|
}));
|
|
90981
91172
|
} else {
|
|
@@ -90986,12 +91177,12 @@ var init_provider_browser = __esm({
|
|
|
90986
91177
|
}
|
|
90987
91178
|
} else {
|
|
90988
91179
|
const { provider, info } = found[0];
|
|
90989
|
-
|
|
91180
|
+
resolve17(new _BrowserProvider(provider, void 0, {
|
|
90990
91181
|
providerInfo: info
|
|
90991
91182
|
}));
|
|
90992
91183
|
}
|
|
90993
91184
|
} else {
|
|
90994
|
-
|
|
91185
|
+
resolve17(null);
|
|
90995
91186
|
}
|
|
90996
91187
|
context.removeEventListener("eip6963:announceProvider", addProvider);
|
|
90997
91188
|
};
|
|
@@ -91445,10 +91636,10 @@ var init_base_wallet = __esm({
|
|
|
91445
91636
|
});
|
|
91446
91637
|
|
|
91447
91638
|
// node_modules/ethers/lib.esm/wordlists/decode-owl.js
|
|
91448
|
-
function unfold(words7,
|
|
91639
|
+
function unfold(words7, sep4) {
|
|
91449
91640
|
let initial = 97;
|
|
91450
91641
|
return words7.reduce((accum, word) => {
|
|
91451
|
-
if (word ===
|
|
91642
|
+
if (word === sep4) {
|
|
91452
91643
|
initial++;
|
|
91453
91644
|
} else if (word.match(Word)) {
|
|
91454
91645
|
accum.push(String.fromCharCode(initial) + word);
|
|
@@ -92425,9 +92616,9 @@ function decryptKeystoreJsonSync(json2, _password) {
|
|
|
92425
92616
|
return getAccount(data4, key);
|
|
92426
92617
|
}
|
|
92427
92618
|
function stall3(duration3) {
|
|
92428
|
-
return new Promise((
|
|
92619
|
+
return new Promise((resolve17) => {
|
|
92429
92620
|
setTimeout(() => {
|
|
92430
|
-
|
|
92621
|
+
resolve17();
|
|
92431
92622
|
}, duration3);
|
|
92432
92623
|
});
|
|
92433
92624
|
}
|
|
@@ -93059,9 +93250,9 @@ var init_json_crowdsale = __esm({
|
|
|
93059
93250
|
|
|
93060
93251
|
// node_modules/ethers/lib.esm/wallet/wallet.js
|
|
93061
93252
|
function stall4(duration3) {
|
|
93062
|
-
return new Promise((
|
|
93253
|
+
return new Promise((resolve17) => {
|
|
93063
93254
|
setTimeout(() => {
|
|
93064
|
-
|
|
93255
|
+
resolve17();
|
|
93065
93256
|
}, duration3);
|
|
93066
93257
|
});
|
|
93067
93258
|
}
|
|
@@ -96777,8 +96968,8 @@ var init_hyperliquid_client = __esm({
|
|
|
96777
96968
|
acknowledgementLookupPacing = () => ({
|
|
96778
96969
|
windowMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.window_milliseconds,
|
|
96779
96970
|
pollMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.poll_milliseconds,
|
|
96780
|
-
sleep: (ms) => new Promise((
|
|
96781
|
-
globalThis.setTimeout(
|
|
96971
|
+
sleep: (ms) => new Promise((resolve17) => {
|
|
96972
|
+
globalThis.setTimeout(resolve17, ms);
|
|
96782
96973
|
}),
|
|
96783
96974
|
// Monotonic: a wall-clock step must not stretch or cut the window.
|
|
96784
96975
|
nowMs: () => globalThis.performance.now()
|
|
@@ -97487,14 +97678,14 @@ var init_hyperliquid_client = __esm({
|
|
|
97487
97678
|
"outcome_unknown"
|
|
97488
97679
|
);
|
|
97489
97680
|
}
|
|
97490
|
-
await new Promise((
|
|
97681
|
+
await new Promise((resolve17) => {
|
|
97491
97682
|
let settled2 = false;
|
|
97492
97683
|
const finish = () => {
|
|
97493
97684
|
if (settled2) return;
|
|
97494
97685
|
settled2 = true;
|
|
97495
97686
|
globalThis.clearTimeout(timeoutId);
|
|
97496
97687
|
input.signal?.removeEventListener("abort", finish);
|
|
97497
|
-
|
|
97688
|
+
resolve17();
|
|
97498
97689
|
};
|
|
97499
97690
|
const timeoutId = globalThis.setTimeout(
|
|
97500
97691
|
finish,
|
|
@@ -97529,12 +97720,12 @@ var init_hyperliquid_client = __esm({
|
|
|
97529
97720
|
captureController.signal,
|
|
97530
97721
|
...durableMutationAuthorityArgs(durableMutation)
|
|
97531
97722
|
).then(() => void 0).catch(() => void 0);
|
|
97532
|
-
const captureDeadline = new Promise((
|
|
97723
|
+
const captureDeadline = new Promise((resolve17) => {
|
|
97533
97724
|
captureTimeout = globalThis.setTimeout(() => {
|
|
97534
97725
|
captureController.abort(
|
|
97535
97726
|
new DOMException("Execution attempt capture timed out.", "TimeoutError")
|
|
97536
97727
|
);
|
|
97537
|
-
|
|
97728
|
+
resolve17();
|
|
97538
97729
|
}, remainingBudgetMs);
|
|
97539
97730
|
});
|
|
97540
97731
|
await Promise.race([captureRequest, captureDeadline]);
|
|
@@ -100693,23 +100884,23 @@ var init_vault = __esm({
|
|
|
100693
100884
|
}
|
|
100694
100885
|
return output3.buffer.slice(output3.byteOffset, output3.byteOffset + output3.byteLength);
|
|
100695
100886
|
};
|
|
100696
|
-
openLegacyVaultDb = () => new Promise((
|
|
100887
|
+
openLegacyVaultDb = () => new Promise((resolve17) => {
|
|
100697
100888
|
if (!hasIndexedDb()) {
|
|
100698
|
-
|
|
100889
|
+
resolve17(null);
|
|
100699
100890
|
return;
|
|
100700
100891
|
}
|
|
100701
100892
|
let request;
|
|
100702
100893
|
try {
|
|
100703
100894
|
request = indexedDB.open(LEGACY_VAULT_DB_NAME, LEGACY_VAULT_DB_VERSION);
|
|
100704
100895
|
} catch {
|
|
100705
|
-
|
|
100896
|
+
resolve17(null);
|
|
100706
100897
|
return;
|
|
100707
100898
|
}
|
|
100708
|
-
request.onerror = () =>
|
|
100899
|
+
request.onerror = () => resolve17(null);
|
|
100709
100900
|
request.onupgradeneeded = () => {
|
|
100710
100901
|
request.transaction?.abort();
|
|
100711
100902
|
};
|
|
100712
|
-
request.onsuccess = () =>
|
|
100903
|
+
request.onsuccess = () => resolve17(request.result);
|
|
100713
100904
|
});
|
|
100714
100905
|
withLegacyStore = async (mode, fn) => {
|
|
100715
100906
|
const database = await openLegacyVaultDb();
|
|
@@ -100718,12 +100909,12 @@ var init_vault = __esm({
|
|
|
100718
100909
|
if (!database.objectStoreNames.contains(LEGACY_VAULT_KEY_STORE)) return null;
|
|
100719
100910
|
const transaction = database.transaction(LEGACY_VAULT_KEY_STORE, mode);
|
|
100720
100911
|
const request = fn(transaction.objectStore(LEGACY_VAULT_KEY_STORE));
|
|
100721
|
-
const result = await new Promise((
|
|
100912
|
+
const result = await new Promise((resolve17, reject) => {
|
|
100722
100913
|
request.onerror = () => reject(request.error ?? new Error("Legacy vault request failed."));
|
|
100723
|
-
request.onsuccess = () =>
|
|
100914
|
+
request.onsuccess = () => resolve17(request.result ?? null);
|
|
100724
100915
|
});
|
|
100725
|
-
await new Promise((
|
|
100726
|
-
transaction.oncomplete = () =>
|
|
100916
|
+
await new Promise((resolve17, reject) => {
|
|
100917
|
+
transaction.oncomplete = () => resolve17();
|
|
100727
100918
|
transaction.onerror = () => reject(transaction.error ?? new Error("Legacy vault transaction failed."));
|
|
100728
100919
|
transaction.onabort = () => reject(transaction.error ?? new Error("Legacy vault transaction aborted."));
|
|
100729
100920
|
});
|
|
@@ -102215,12 +102406,12 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
102215
102406
|
if (signal.aborted) {
|
|
102216
102407
|
throw createAbortError(abortMessage);
|
|
102217
102408
|
}
|
|
102218
|
-
return new Promise((
|
|
102409
|
+
return new Promise((resolve17, reject) => {
|
|
102219
102410
|
const onAbort = () => {
|
|
102220
102411
|
reject(createAbortError(abortMessage));
|
|
102221
102412
|
};
|
|
102222
102413
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
102223
|
-
promise2.then(
|
|
102414
|
+
promise2.then(resolve17, reject).finally(() => {
|
|
102224
102415
|
signal.removeEventListener("abort", onAbort);
|
|
102225
102416
|
});
|
|
102226
102417
|
});
|
|
@@ -103865,7 +104056,7 @@ var init_bounded_lock = __esm({
|
|
|
103865
104056
|
};
|
|
103866
104057
|
inProcessTails = /* @__PURE__ */ new Map();
|
|
103867
104058
|
abortReason = (signal) => signal.reason instanceof Error ? signal.reason : new DOMException("The operation was aborted.", "AbortError");
|
|
103868
|
-
waitBounded = (gate, waitMs, signal) => new Promise((
|
|
104059
|
+
waitBounded = (gate, waitMs, signal) => new Promise((resolve17, reject) => {
|
|
103869
104060
|
if (signal?.aborted) {
|
|
103870
104061
|
reject(abortReason(signal));
|
|
103871
104062
|
return;
|
|
@@ -103880,19 +104071,19 @@ var init_bounded_lock = __esm({
|
|
|
103880
104071
|
};
|
|
103881
104072
|
const timer = setTimeout(() => {
|
|
103882
104073
|
finish();
|
|
103883
|
-
|
|
104074
|
+
resolve17();
|
|
103884
104075
|
}, waitMs);
|
|
103885
104076
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
103886
104077
|
void gate.then(() => {
|
|
103887
104078
|
finish();
|
|
103888
|
-
|
|
104079
|
+
resolve17();
|
|
103889
104080
|
});
|
|
103890
104081
|
});
|
|
103891
104082
|
withInProcessLock = async (name, waitMs, work, signal) => {
|
|
103892
104083
|
const previous = inProcessTails.get(name) ?? Promise.resolve();
|
|
103893
104084
|
let release;
|
|
103894
|
-
const released = new Promise((
|
|
103895
|
-
release =
|
|
104085
|
+
const released = new Promise((resolve17) => {
|
|
104086
|
+
release = resolve17;
|
|
103896
104087
|
});
|
|
103897
104088
|
const tail = previous.then(() => released);
|
|
103898
104089
|
inProcessTails.set(name, tail);
|
|
@@ -105711,7 +105902,7 @@ var init_protective_leg_evidence = __esm({
|
|
|
105711
105902
|
});
|
|
105712
105903
|
|
|
105713
105904
|
// lib/runtime/protective-entry-cover.ts
|
|
105714
|
-
var
|
|
105905
|
+
var attachmentMemberNeverLanded, ownLegCanStillExist, liveProtectiveOrderShape, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, pageOrderById, protectiveLegCoverSize, resolveOwnStops, protectiveEntryLegSize;
|
|
105715
105906
|
var init_protective_entry_cover = __esm({
|
|
105716
105907
|
"lib/runtime/protective-entry-cover.ts"() {
|
|
105717
105908
|
"use strict";
|
|
@@ -105719,14 +105910,115 @@ var init_protective_entry_cover = __esm({
|
|
|
105719
105910
|
init_define_VTX_EXO_POLICY();
|
|
105720
105911
|
init_define_VTX_GROK_POLICY();
|
|
105721
105912
|
init_define_VTX_PI_MODEL_POLICY();
|
|
105722
|
-
|
|
105723
|
-
|
|
105724
|
-
|
|
105725
|
-
|
|
105726
|
-
|
|
105727
|
-
|
|
105913
|
+
attachmentMemberNeverLanded = (group, leg) => group.attachmentJournal?.members.some((member) => member.clientOrderId === leg.orderId && member.neverLandedAtMs != null) === true;
|
|
105914
|
+
ownLegCanStillExist = (group, leg) => leg.replaceJournal?.unknownOidObservedAtMs == null && !attachmentMemberNeverLanded(group, leg);
|
|
105915
|
+
liveProtectiveOrderShape = (order) => ({
|
|
105916
|
+
coin: order.coin,
|
|
105917
|
+
side: order.side,
|
|
105918
|
+
size: order.sz,
|
|
105919
|
+
reduceOnly: order.reduce_only,
|
|
105920
|
+
isTrigger: order.is_trigger,
|
|
105921
|
+
triggerKind: order.trigger_kind,
|
|
105922
|
+
triggerPrice: order.trigger_px,
|
|
105923
|
+
isPositionTpsl: order.is_position_tpsl
|
|
105924
|
+
});
|
|
105925
|
+
protectiveStableShapeMatches = (input) => {
|
|
105926
|
+
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
105927
|
+
const expectedSide = isLong ? ["a", "sell"] : ["b", "buy"];
|
|
105928
|
+
const observedSize = Number(shape.size);
|
|
105929
|
+
return String(shape.coin ?? "").trim().toUpperCase() === symbol2.trim().toUpperCase() && expectedSide.includes(String(shape.side ?? "").trim().toLowerCase()) && Number.isFinite(observedSize) && observedSize === leg.size && shape.reduceOnly === true && shape.triggerKind === leg.kind;
|
|
105930
|
+
};
|
|
105931
|
+
observedProtectiveGroupingMatches = (observed, storedPositionTpsl) => observed === false || observed === true && storedPositionTpsl === true;
|
|
105932
|
+
protectiveLiveShapeMatches = (input) => {
|
|
105933
|
+
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
105934
|
+
return protectiveStableShapeMatches({ shape, symbol: symbol2, isLong, leg }) && shape.isTrigger === true && Number.isFinite(Number(shape.triggerPrice)) && Number(shape.triggerPrice) === leg.triggerPrice && (input.requirePositionTpsl === false || observedProtectiveGroupingMatches(shape.isPositionTpsl, leg.positionTpsl));
|
|
105935
|
+
};
|
|
105936
|
+
pageOrderById = (orders, orderId) => orderId == null ? null : orders.find((order) => String(order.oid) === String(orderId)) ?? null;
|
|
105937
|
+
protectiveLegCoverSize = (leg, restingSize = leg.size) => leg.replacement != null && leg.replacement.size < restingSize ? leg.replacement.size : restingSize;
|
|
105938
|
+
resolveOwnStops = (input) => {
|
|
105939
|
+
const { symbol: symbol2, orders } = input;
|
|
105940
|
+
const entries = input.groups.flatMap((group) => group.legs.map((leg) => ({ group, leg })));
|
|
105941
|
+
const knownId = ({ leg }) => input.lookedUp?.get(String(leg.orderId)) ?? (typeof leg.orderId === "number" ? leg.orderId : null);
|
|
105942
|
+
const pendingIds = new Set(entries.flatMap(({ leg }) => leg.replacement?.clientOrderId ? [leg.replacement.clientOrderId] : []));
|
|
105943
|
+
const unbound = (entry) => knownId(entry) == null && !pendingIds.has(String(entry.leg.orderId)) && (input.canStillExist ?? ownLegCanStillExist)(entry.group, entry.leg);
|
|
105944
|
+
const claims = /* @__PURE__ */ new Map();
|
|
105945
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
105946
|
+
const claim = (entry, order) => {
|
|
105947
|
+
if (order == null || claimed.has(order) || claims.has(entry)) return;
|
|
105948
|
+
claims.set(entry, order);
|
|
105949
|
+
claimed.add(order);
|
|
105950
|
+
};
|
|
105951
|
+
const byShape = (entry, leg) => orders.find((order) => !claimed.has(order) && protectiveLiveShapeMatches({
|
|
105952
|
+
shape: liveProtectiveOrderShape(order),
|
|
105953
|
+
symbol: symbol2,
|
|
105954
|
+
isLong: entry.group.isLong,
|
|
105955
|
+
leg
|
|
105956
|
+
}));
|
|
105957
|
+
for (const entry of entries) claim(entry, pageOrderById(orders, knownId(entry)));
|
|
105958
|
+
const named = new Set(claimed);
|
|
105959
|
+
const leaving = new Set(input.groups.filter((group) => group.cleanupRequired === true || entries.some((entry) => entry.group === group && knownId(entry) != null && !claims.has(entry))));
|
|
105960
|
+
const waiting = entries.filter(unbound);
|
|
105961
|
+
const unread = (entry) => input.unresolved?.has(String(entry.leg.orderId)) === true;
|
|
105962
|
+
const staying = waiting.filter((entry) => !leaving.has(entry.group));
|
|
105963
|
+
for (const entry of [...waiting.filter((entry2) => leaving.has(entry2.group)), ...staying.filter(unread), ...staying.filter((entry2) => !unread(entry2))]) {
|
|
105964
|
+
claim(entry, byShape(entry, entry.leg));
|
|
105965
|
+
}
|
|
105966
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
105967
|
+
for (const entry of entries) {
|
|
105968
|
+
byKey.set(String(entry.leg.orderId), entry);
|
|
105969
|
+
if (knownId(entry) != null) byKey.set(String(knownId(entry)), entry);
|
|
105728
105970
|
}
|
|
105729
|
-
|
|
105971
|
+
const entryOf = (leg) => byKey.get(String(leg.orderId));
|
|
105972
|
+
const coverOf = (entry) => {
|
|
105973
|
+
const order = entry == null || leaving.has(entry.group) ? void 0 : claims.get(entry);
|
|
105974
|
+
const size = Number(order?.sz);
|
|
105975
|
+
return entry != null && size > 0 ? protectiveLegCoverSize(entry.leg, Math.min(entry.leg.size, size)) : 0;
|
|
105976
|
+
};
|
|
105977
|
+
const inFlightOf = (entry) => entry == null || leaving.has(entry.group) || claims.has(entry) || !unbound(entry) ? 0 : protectiveLegCoverSize(entry.leg);
|
|
105978
|
+
return {
|
|
105979
|
+
/** The leg is on its way out: it covers nothing and takes no share. */
|
|
105980
|
+
leaving: (leg) => {
|
|
105981
|
+
const entry = entryOf(leg);
|
|
105982
|
+
return entry != null && leaving.has(entry.group);
|
|
105983
|
+
},
|
|
105984
|
+
/** What the leg's order on the page covers (nothing on its way out or off the page). */
|
|
105985
|
+
cover: (leg) => coverOf(entryOf(leg)),
|
|
105986
|
+
/** What a leg whose order is on no page may still cover: its size while it is in flight. */
|
|
105987
|
+
inFlight: (leg) => inFlightOf(entryOf(leg)),
|
|
105988
|
+
/** Whether an order of exactly the leg's shape that no stored leg names rests on the page. */
|
|
105989
|
+
restsUnnamed: (group, leg) => orders.some((order) => !named.has(order) && protectiveLiveShapeMatches({
|
|
105990
|
+
shape: liveProtectiveOrderShape(order),
|
|
105991
|
+
symbol: symbol2,
|
|
105992
|
+
isLong: group.isLong,
|
|
105993
|
+
leg
|
|
105994
|
+
})),
|
|
105995
|
+
/** What the legs of one direction cover, by kind (a new entry's attach). */
|
|
105996
|
+
directionCover: (isLong) => {
|
|
105997
|
+
const cover = { sl: 0, tp: 0 };
|
|
105998
|
+
for (const entry of entries) {
|
|
105999
|
+
if (entry.group.isLong === isLong) cover[entry.leg.kind] += coverOf(entry) + inFlightOf(entry);
|
|
106000
|
+
}
|
|
106001
|
+
return cover;
|
|
106002
|
+
},
|
|
106003
|
+
/**
|
|
106004
|
+
* For a lost stop: the stop losses on the page closing the position, other
|
|
106005
|
+
* than the orders a status proved ended (`lost`) and those this pass placed
|
|
106006
|
+
* (`placed`, counted where they were placed), an order no leg names whole;
|
|
106007
|
+
* and, unseen, what the legs this pass could not read may still cover.
|
|
106008
|
+
*/
|
|
106009
|
+
lostStopCover: (positionSize, excluded) => {
|
|
106010
|
+
const isLong = positionSize > 0;
|
|
106011
|
+
const owners = new Map([...claims].map(([entry, order]) => [order, entry]));
|
|
106012
|
+
const placed = (entry) => excluded.placed.has(String(entry.leg.orderId)) || excluded.placed.has(String(knownId(entry)));
|
|
106013
|
+
const onPage = orders.filter((order) => !excluded.lost.has(String(order.oid)) && !excluded.placed.has(String(order.oid)) && String(order.coin).trim().toUpperCase() === symbol2.trim().toUpperCase() && order.reduce_only && order.is_trigger && order.trigger_kind === "sl" && (isLong ? ["a", "sell"] : ["b", "buy"]).includes(String(order.side).trim().toLowerCase())).reduce((total, order) => {
|
|
106014
|
+
const owner2 = owners.get(order);
|
|
106015
|
+
const size = Number(order.sz);
|
|
106016
|
+
return total + (owner2 != null ? placed(owner2) ? 0 : coverOf(owner2) : size > 0 ? size : 0);
|
|
106017
|
+
}, 0);
|
|
106018
|
+
const unseen = entries.filter((entry) => entry.leg.kind === "sl" && entry.group.isLong === isLong && !placed(entry) && input.unresolved?.has(String(entry.leg.orderId)) === true).reduce((total, entry) => total + inFlightOf(entry), 0);
|
|
106019
|
+
return { onPage, unseen };
|
|
106020
|
+
}
|
|
106021
|
+
};
|
|
105730
106022
|
};
|
|
105731
106023
|
protectiveEntryLegSize = (input) => Math.min(input.filledSize, Math.max(0, input.liveExposure - input.cover));
|
|
105732
106024
|
}
|
|
@@ -105757,6 +106049,7 @@ var init_protective_oversized_leg = __esm({
|
|
|
105757
106049
|
});
|
|
105758
106050
|
|
|
105759
106051
|
// lib/runtime/protective-report-entry.ts
|
|
106052
|
+
var executedProtectiveReport;
|
|
105760
106053
|
var init_protective_report_entry = __esm({
|
|
105761
106054
|
"lib/runtime/protective-report-entry.ts"() {
|
|
105762
106055
|
"use strict";
|
|
@@ -105764,6 +106057,18 @@ var init_protective_report_entry = __esm({
|
|
|
105764
106057
|
init_define_VTX_EXO_POLICY();
|
|
105765
106058
|
init_define_VTX_GROK_POLICY();
|
|
105766
106059
|
init_define_VTX_PI_MODEL_POLICY();
|
|
106060
|
+
executedProtectiveReport = (input) => ({
|
|
106061
|
+
order_id: input.orderId,
|
|
106062
|
+
...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
|
|
106063
|
+
symbol: input.symbol,
|
|
106064
|
+
action: input.action,
|
|
106065
|
+
status: "executed",
|
|
106066
|
+
execution_metadata: {
|
|
106067
|
+
...input.metadata,
|
|
106068
|
+
protected_size: input.protectedSize,
|
|
106069
|
+
position_tpsl: input.positionTpsl
|
|
106070
|
+
}
|
|
106071
|
+
});
|
|
105767
106072
|
}
|
|
105768
106073
|
});
|
|
105769
106074
|
|
|
@@ -107806,7 +108111,7 @@ var init_native_protection_device = __esm({
|
|
|
107806
108111
|
});
|
|
107807
108112
|
|
|
107808
108113
|
// lib/runtime/runtime-execution.ts
|
|
107809
|
-
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction,
|
|
108114
|
+
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, nativeSettingsOf, nativePassEnded, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, modifyClientTrailingLeg, trailingRatchetIo, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionListings, runtimeProtectionListing, resolveServerNativeEntry, SERVER_NATIVE_LEGACY_REFUSAL, isServerNativeLegacyRefusal, serverUserCancelLookup, serverModeProtectionOwner, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, nextClientTrailingStopDueAtMs, ratchetClientTrailingStopsBetweenCycles, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, listStoredClientProtectionSymbols, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked;
|
|
107810
108115
|
var init_runtime_execution = __esm({
|
|
107811
108116
|
"lib/runtime/runtime-execution.ts"() {
|
|
107812
108117
|
"use strict";
|
|
@@ -108864,38 +109169,10 @@ var init_runtime_execution = __esm({
|
|
|
108864
109169
|
input.executionContext.takeProfitMode === "usdc" ? input.executionContext.takeProfitUsdc : input.executionContext.takeProfitPct
|
|
108865
109170
|
) > 0);
|
|
108866
109171
|
protectiveAction = (leg) => leg.kind === "sl" ? "AUTO_SL" : "AUTO_TP";
|
|
108867
|
-
executedProtectiveReport = (input) => ({
|
|
108868
|
-
order_id: input.orderId,
|
|
108869
|
-
...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
|
|
108870
|
-
symbol: input.symbol,
|
|
108871
|
-
action: input.action,
|
|
108872
|
-
status: "executed",
|
|
108873
|
-
execution_metadata: {
|
|
108874
|
-
...input.metadata,
|
|
108875
|
-
protected_size: input.protectedSize,
|
|
108876
|
-
position_tpsl: input.positionTpsl
|
|
108877
|
-
}
|
|
108878
|
-
});
|
|
108879
109172
|
isExactClientPositionTpslPair = (legs) => legs.length === CLIENT_PROTECTIVE_TPSL_PAIR_LEGS && legs.every((leg) => leg.positionTpsl === true) && new Set(legs.map((leg) => leg.kind)).size === CLIENT_PROTECTIVE_TPSL_PAIR_LEGS;
|
|
108880
109173
|
deviceOwnsClientProtectiveLegKind = (group, kind) => group.deviceOwnedLegKinds == null || group.deviceOwnedLegKinds.includes(kind);
|
|
108881
109174
|
isAdoptionNarrowedPositionTpslLeg = (group) => group.deviceOwnedLegKinds?.length === 1 && group.legs.length === 1 && group.legs[0].positionTpsl === true && group.legs[0].kind === group.deviceOwnedLegKinds[0];
|
|
108882
109175
|
hasAmbiguousClientPositionTpslAuthority = (group) => group.legs.some((leg) => leg.positionTpsl === true) && !isExactClientPositionTpslPair(group.legs) && !isAdoptionNarrowedPositionTpslLeg(group);
|
|
108883
|
-
protectiveStableShapeMatches = (input) => {
|
|
108884
|
-
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
108885
|
-
const expectedSide = isLong ? ["a", "sell"] : ["b", "buy"];
|
|
108886
|
-
const observedSize = Number(shape.size);
|
|
108887
|
-
return String(shape.coin ?? "").trim().toUpperCase() === symbol2.trim().toUpperCase() && expectedSide.includes(String(shape.side ?? "").trim().toLowerCase()) && Number.isFinite(observedSize) && observedSize === leg.size && shape.reduceOnly === true && shape.triggerKind === leg.kind;
|
|
108888
|
-
};
|
|
108889
|
-
observedProtectiveGroupingMatches = (observed, storedPositionTpsl) => observed === false || observed === true && storedPositionTpsl === true;
|
|
108890
|
-
protectiveLiveShapeMatches = (input) => {
|
|
108891
|
-
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
108892
|
-
return protectiveStableShapeMatches({
|
|
108893
|
-
shape,
|
|
108894
|
-
symbol: symbol2,
|
|
108895
|
-
isLong,
|
|
108896
|
-
leg
|
|
108897
|
-
}) && shape.isTrigger === true && Number.isFinite(Number(shape.triggerPrice)) && Number(shape.triggerPrice) === leg.triggerPrice && (input.requirePositionTpsl === false || observedProtectiveGroupingMatches(shape.isPositionTpsl, leg.positionTpsl));
|
|
108898
|
-
};
|
|
108899
109176
|
protectiveTerminalShapeMatches = (input) => input.evidence.responseValid === true && input.evidence.orderMatches === true && input.evidence.terminal === true && protectiveStableShapeMatches({
|
|
108900
109177
|
shape: input.evidence,
|
|
108901
109178
|
symbol: input.symbol,
|
|
@@ -108947,7 +109224,7 @@ var init_runtime_execution = __esm({
|
|
|
108947
109224
|
}
|
|
108948
109225
|
}
|
|
108949
109226
|
const liveOrders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
108950
|
-
const liveOrder = liveOrders
|
|
109227
|
+
const liveOrder = pageOrderById(liveOrders, leg.orderId);
|
|
108951
109228
|
if (!liveOrder) {
|
|
108952
109229
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
108953
109230
|
publicRequestPriority: "trading_reduce",
|
|
@@ -109091,28 +109368,17 @@ var init_runtime_execution = __esm({
|
|
|
109091
109368
|
);
|
|
109092
109369
|
return { group, cleanup, persistedGroupSet: persistenceFailed ? null : nextGroups };
|
|
109093
109370
|
};
|
|
109094
|
-
attachmentMemberNeverLanded = (group, leg) => group.attachmentJournal?.members.some((member) => member.clientOrderId === leg.orderId && member.neverLandedAtMs != null) === true;
|
|
109095
109371
|
storedClientProtectiveCover = async (request, entryIsLong, groups2) => {
|
|
109096
|
-
const
|
|
109097
|
-
|
|
109098
|
-
|
|
109099
|
-
|
|
109100
|
-
orderId: typeof leg.orderId === "number" ? leg.orderId : null,
|
|
109101
|
-
canStillExist: !attachmentMemberNeverLanded(group, leg),
|
|
109102
|
-
beingCancelled: group.cleanupRequired === true
|
|
109103
|
-
})));
|
|
109104
|
-
const liveOrderIds = /* @__PURE__ */ new Set();
|
|
109105
|
-
if (storedLegs.some((leg) => !leg.beingCancelled)) {
|
|
109106
|
-
const symbol2 = request.executionContext.symbol.trim().toUpperCase();
|
|
109107
|
-
const orders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
109108
|
-
if (!Array.isArray(orders)) {
|
|
109109
|
-
throw new Error("Malformed live protective-order snapshot.");
|
|
109110
|
-
}
|
|
109111
|
-
for (const order of orders) {
|
|
109112
|
-
if (String(order.coin).trim().toUpperCase() === symbol2) liveOrderIds.add(String(order.oid));
|
|
109113
|
-
}
|
|
109372
|
+
const candidates = groups2.filter((group) => group.isLong === entryIsLong);
|
|
109373
|
+
const orders = candidates.some((group) => group.cleanupRequired !== true && group.legs.length > 0) ? await fetchClientRuntimeOpenOrders(request, "trading_reduce") : [];
|
|
109374
|
+
if (!Array.isArray(orders)) {
|
|
109375
|
+
throw new Error("Malformed live protective-order snapshot.");
|
|
109114
109376
|
}
|
|
109115
|
-
return
|
|
109377
|
+
return resolveOwnStops({
|
|
109378
|
+
symbol: request.executionContext.symbol,
|
|
109379
|
+
groups: candidates,
|
|
109380
|
+
orders
|
|
109381
|
+
}).directionCover(entryIsLong);
|
|
109116
109382
|
};
|
|
109117
109383
|
attachClientProtectivePlan = async (request, group, fill) => {
|
|
109118
109384
|
const reports = [];
|
|
@@ -109652,6 +109918,8 @@ var init_runtime_execution = __esm({
|
|
|
109652
109918
|
metadata: {
|
|
109653
109919
|
trigger_price: candidates[index].triggerPrice,
|
|
109654
109920
|
entry_order_id: fill.orderId,
|
|
109921
|
+
// Names the entry's row while VTX knows it only by its mutation (its outcome unknown).
|
|
109922
|
+
entry_mutation_id: plan.entryMutationId,
|
|
109655
109923
|
entry_filled_size: fill.filledSize,
|
|
109656
109924
|
entry_average_price: fill.averagePrice
|
|
109657
109925
|
}
|
|
@@ -109954,7 +110222,7 @@ var init_runtime_execution = __esm({
|
|
|
109954
110222
|
}
|
|
109955
110223
|
})));
|
|
109956
110224
|
}
|
|
109957
|
-
const
|
|
110225
|
+
const ownStops = resolveOwnStops({ symbol: symbol2, groups: readClientProtectiveGroups(profileId, symbol2), orders: liveOrders });
|
|
109958
110226
|
for (const journaledGroup of journaledGroups) {
|
|
109959
110227
|
let group = journaledGroup;
|
|
109960
110228
|
const plan = group.pendingEntry;
|
|
@@ -109969,7 +110237,7 @@ var init_runtime_execution = __esm({
|
|
|
109969
110237
|
inspected.push({ leg: provisionalLeg, state: "terminal", rested: false, neverLanded: true });
|
|
109970
110238
|
continue;
|
|
109971
110239
|
}
|
|
109972
|
-
let openOrder = liveOrders
|
|
110240
|
+
let openOrder = pageOrderById(liveOrders, provisionalLeg.orderId);
|
|
109973
110241
|
let canonicalLeg = provisionalLeg;
|
|
109974
110242
|
if (openOrder == null) {
|
|
109975
110243
|
try {
|
|
@@ -109999,12 +110267,7 @@ var init_runtime_execution = __esm({
|
|
|
109999
110267
|
throw new Error("Journaled protective order identity is unresolved.");
|
|
110000
110268
|
}
|
|
110001
110269
|
} else {
|
|
110002
|
-
const mayRestUnseen =
|
|
110003
|
-
shape: liveProtectiveOrderShape(order),
|
|
110004
|
-
symbol: symbol2,
|
|
110005
|
-
isLong: group.isLong,
|
|
110006
|
-
leg: provisionalLeg
|
|
110007
|
-
}));
|
|
110270
|
+
const mayRestUnseen = ownStops.restsUnnamed(group, provisionalLeg);
|
|
110008
110271
|
if (ledgerVerdict.proven && !mayRestUnseen) {
|
|
110009
110272
|
newlyNeverLanded.add(provisionalLeg.orderId);
|
|
110010
110273
|
inspected.push({ leg: provisionalLeg, state: "terminal", rested: false, neverLanded: true });
|
|
@@ -110017,7 +110280,7 @@ var init_runtime_execution = __esm({
|
|
|
110017
110280
|
throw new Error("Journaled protective order identity is unresolved.");
|
|
110018
110281
|
}
|
|
110019
110282
|
canonicalLeg = { ...provisionalLeg, orderId: resolvedOrderId };
|
|
110020
|
-
openOrder = liveOrders
|
|
110283
|
+
openOrder = pageOrderById(liveOrders, resolvedOrderId);
|
|
110021
110284
|
if (classifyHyperliquidOrderStatus(evidence.orderStatus) === "open" && openOrder != null) {
|
|
110022
110285
|
} else {
|
|
110023
110286
|
const terminalMatches = protectiveTerminalShapeMatches({
|
|
@@ -110949,7 +111212,7 @@ var init_runtime_execution = __esm({
|
|
|
110949
111212
|
let shapeMatches = exactShapeMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open";
|
|
110950
111213
|
if (!shapeMatches && evidence.reasonCode === "unknown_oid") {
|
|
110951
111214
|
const liveOrders = await fetchClientRuntimeOpenOrders(request);
|
|
110952
|
-
const originalOrder = liveOrders
|
|
111215
|
+
const originalOrder = pageOrderById(liveOrders, replacement.previousOrderId);
|
|
110953
111216
|
const originalLiveShape = originalOrder == null ? null : {
|
|
110954
111217
|
coin: originalOrder.coin,
|
|
110955
111218
|
side: originalOrder.side,
|
|
@@ -111272,23 +111535,13 @@ var init_runtime_execution = __esm({
|
|
|
111272
111535
|
}
|
|
111273
111536
|
return reports;
|
|
111274
111537
|
};
|
|
111275
|
-
liveProtectiveOrderShape = (order) => ({
|
|
111276
|
-
coin: order.coin,
|
|
111277
|
-
side: order.side,
|
|
111278
|
-
size: order.sz,
|
|
111279
|
-
reduceOnly: order.reduce_only,
|
|
111280
|
-
isTrigger: order.is_trigger,
|
|
111281
|
-
triggerKind: order.trigger_kind,
|
|
111282
|
-
triggerPrice: order.trigger_px,
|
|
111283
|
-
isPositionTpsl: order.is_position_tpsl
|
|
111284
|
-
});
|
|
111285
111538
|
observedStandaloneProtectiveGroup = (group, liveOrders, symbol2) => {
|
|
111286
111539
|
if (!group.legs.some((leg) => leg.positionTpsl === true) || group.legs.some((leg) => leg.replacement != null)) {
|
|
111287
111540
|
return null;
|
|
111288
111541
|
}
|
|
111289
111542
|
let standaloneObserved = false;
|
|
111290
111543
|
for (const leg of group.legs) {
|
|
111291
|
-
const liveOrder = liveOrders
|
|
111544
|
+
const liveOrder = pageOrderById(liveOrders, leg.orderId);
|
|
111292
111545
|
if (liveOrder == null) continue;
|
|
111293
111546
|
if (liveOrder.is_position_tpsl !== false) return null;
|
|
111294
111547
|
if (protectiveLiveShapeMatches({
|
|
@@ -111679,6 +111932,7 @@ var init_runtime_execution = __esm({
|
|
|
111679
111932
|
return { leg, notLanded: true, reports: [] };
|
|
111680
111933
|
};
|
|
111681
111934
|
const inspectedGroups = [];
|
|
111935
|
+
const lookedUp = /* @__PURE__ */ new Map();
|
|
111682
111936
|
const legsLiveSinceMs = protectiveReadStampMs();
|
|
111683
111937
|
for (const observedGroup of groups2) {
|
|
111684
111938
|
let group = observedGroup;
|
|
@@ -111710,7 +111964,7 @@ var init_runtime_execution = __esm({
|
|
|
111710
111964
|
let ambiguousPositionTpslAuthority = hasAmbiguousClientPositionTpslAuthority(group);
|
|
111711
111965
|
if (ambiguousPositionTpslAuthority) {
|
|
111712
111966
|
const singleLeg = group.legs.length === 1 ? group.legs[0] : null;
|
|
111713
|
-
const liveOrder = singleLeg == null ? null : liveOrders
|
|
111967
|
+
const liveOrder = singleLeg == null ? null : pageOrderById(liveOrders, singleLeg.orderId);
|
|
111714
111968
|
const liveShape = liveOrder == null ? null : {
|
|
111715
111969
|
coin: liveOrder.coin,
|
|
111716
111970
|
side: liveOrder.side,
|
|
@@ -111771,7 +112025,7 @@ var init_runtime_execution = __esm({
|
|
|
111771
112025
|
});
|
|
111772
112026
|
continue;
|
|
111773
112027
|
}
|
|
111774
|
-
const openOrder = liveOrders
|
|
112028
|
+
const openOrder = pageOrderById(liveOrders, leg.orderId);
|
|
111775
112029
|
if (openOrder != null) {
|
|
111776
112030
|
legs.push({ leg, openOrder, state: "open" });
|
|
111777
112031
|
continue;
|
|
@@ -111802,8 +112056,11 @@ var init_runtime_execution = __esm({
|
|
|
111802
112056
|
leg
|
|
111803
112057
|
});
|
|
111804
112058
|
const resolvedNumericOrderId = Number(evidence.orderId);
|
|
112059
|
+
if (evidence.responseValid && evidence.orderMatches && Number.isSafeInteger(resolvedNumericOrderId) && resolvedNumericOrderId > 0) {
|
|
112060
|
+
lookedUp.set(String(leg.orderId), resolvedNumericOrderId);
|
|
112061
|
+
}
|
|
111805
112062
|
const inspectedLeg = evidence.responseValid && evidence.orderMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open" && Number.isSafeInteger(resolvedNumericOrderId) && resolvedNumericOrderId > 0 ? { ...leg, orderId: resolvedNumericOrderId } : leg;
|
|
111806
|
-
const resolvedOpenOrder = inspectedLeg.orderId !== leg.orderId ? liveOrders
|
|
112063
|
+
const resolvedOpenOrder = inspectedLeg.orderId !== leg.orderId ? pageOrderById(liveOrders, inspectedLeg.orderId) : null;
|
|
111807
112064
|
legs.push({
|
|
111808
112065
|
leg: inspectedLeg,
|
|
111809
112066
|
openOrder: resolvedOpenOrder,
|
|
@@ -111874,10 +112131,9 @@ var init_runtime_execution = __esm({
|
|
|
111874
112131
|
};
|
|
111875
112132
|
const retainedGroups = expectedGroupSet.filter((group) => group.pendingEntry != null || isProtectiveReplacementJournalGroup(group));
|
|
111876
112133
|
let stopSizePlacedThisPass = 0;
|
|
111877
|
-
const
|
|
111878
|
-
const
|
|
111879
|
-
|
|
111880
|
-
);
|
|
112134
|
+
const placedThisPass = /* @__PURE__ */ new Set();
|
|
112135
|
+
const unresolvedLegIds = new Set(inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "unresolved").map((entry) => String(entry.leg.orderId)));
|
|
112136
|
+
const lostOrderIds = new Set(inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "terminal").flatMap(({ leg }) => [String(leg.orderId), String(lookedUp.get(String(leg.orderId)) ?? leg.orderId)]));
|
|
111881
112137
|
const lostStatuses = () => inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "terminal").map((entry) => ({ state: "terminal", receivedMs: entry.statusReceivedMs ?? null }));
|
|
111882
112138
|
const readQualifies = (sentMs) => lostLegMarketEvidence({
|
|
111883
112139
|
statuses: lostStatuses(),
|
|
@@ -111929,10 +112185,6 @@ var init_runtime_execution = __esm({
|
|
|
111929
112185
|
}
|
|
111930
112186
|
return { sentMs, freshOrders };
|
|
111931
112187
|
});
|
|
111932
|
-
const lostLegLiveStopSize = (freshOrders, positionSize) => {
|
|
111933
|
-
const freshIsLong = positionSize > 0;
|
|
111934
|
-
return freshOrders.filter((order) => !lostOrderIds.has(String(order.oid)) && String(order.coin).trim().toUpperCase() === symbol2.trim().toUpperCase() && order.reduce_only && order.is_trigger && order.trigger_kind === "sl" && (freshIsLong ? ["a", "sell"].includes(String(order.side).trim().toLowerCase()) : ["b", "buy"].includes(String(order.side).trim().toLowerCase()))).reduce((total, order) => total + (Number(order.sz) > 0 ? Number(order.sz) : 0), 0);
|
|
111935
|
-
};
|
|
111936
112188
|
const lostLegPositionEpisodeEnded = async (group, terminalStatus, positionSize, botCleanupInFlight, cancelledByUser) => {
|
|
111937
112189
|
if (terminalStatus == null || !episodeEndProofReachable({
|
|
111938
112190
|
orderStatus: terminalStatus.orderStatus,
|
|
@@ -112002,9 +112254,17 @@ var init_runtime_execution = __esm({
|
|
|
112002
112254
|
cancelledByUser,
|
|
112003
112255
|
terminalOrderStatus: terminalStatus?.orderStatus ?? null
|
|
112004
112256
|
});
|
|
112257
|
+
const stops = replaceReachable ? resolveOwnStops({
|
|
112258
|
+
symbol: symbol2,
|
|
112259
|
+
groups: expectedGroupSet,
|
|
112260
|
+
orders: (await readLostLegOrders()).freshOrders,
|
|
112261
|
+
lookedUp,
|
|
112262
|
+
unresolved: unresolvedLegIds
|
|
112263
|
+
}).lostStopCover(position.positionSize, { lost: lostOrderIds, placed: placedThisPass }) : null;
|
|
112005
112264
|
evidence = {
|
|
112006
112265
|
positionSize: position.positionSize,
|
|
112007
|
-
liveStopSize:
|
|
112266
|
+
liveStopSize: stops?.onPage ?? 0,
|
|
112267
|
+
unseenStopSize: stops?.unseen ?? 0,
|
|
112008
112268
|
markPrice: replaceReachable ? position.markPrice : null
|
|
112009
112269
|
};
|
|
112010
112270
|
} catch (error48) {
|
|
@@ -112029,7 +112289,7 @@ var init_runtime_execution = __esm({
|
|
|
112029
112289
|
positionSize: evidence.positionSize,
|
|
112030
112290
|
legSize: leg.size,
|
|
112031
112291
|
otherLiveStopSize: evidence.liveStopSize,
|
|
112032
|
-
inFlightStopSize:
|
|
112292
|
+
inFlightStopSize: evidence.unseenStopSize + stopSizePlacedThisPass,
|
|
112033
112293
|
sizeDecimals: request.executionContext.sizeDecimals,
|
|
112034
112294
|
triggerPrice: leg.triggerPrice,
|
|
112035
112295
|
alreadyReplaced: leg.replacedOrderId != null,
|
|
@@ -112138,6 +112398,7 @@ var init_runtime_execution = __esm({
|
|
|
112138
112398
|
};
|
|
112139
112399
|
}
|
|
112140
112400
|
stopSizePlacedThisPass += decision.size;
|
|
112401
|
+
placedThisPass.add(clientOrderId);
|
|
112141
112402
|
let dispatchMayHaveStarted = false;
|
|
112142
112403
|
let response;
|
|
112143
112404
|
try {
|
|
@@ -112169,6 +112430,7 @@ var init_runtime_execution = __esm({
|
|
|
112169
112430
|
if (error48 instanceof HyperliquidExchangeRejectionError) {
|
|
112170
112431
|
const rejectionProjection = projectExecutionErrorContract({ error: error48, symbol: symbol2 });
|
|
112171
112432
|
stopSizePlacedThisPass -= decision.size;
|
|
112433
|
+
placedThisPass.delete(clientOrderId);
|
|
112172
112434
|
const rejectedGroup = {
|
|
112173
112435
|
...provisionalGroup,
|
|
112174
112436
|
legs: provisionalGroup.legs.filter((candidate) => candidate.orderId !== clientOrderId)
|
|
@@ -112196,6 +112458,7 @@ var init_runtime_execution = __esm({
|
|
|
112196
112458
|
}
|
|
112197
112459
|
if (!dispatchMayHaveStarted) {
|
|
112198
112460
|
stopSizePlacedThisPass -= decision.size;
|
|
112461
|
+
placedThisPass.delete(clientOrderId);
|
|
112199
112462
|
const restored = transitionExactGroup(provisionalGroup, group);
|
|
112200
112463
|
if (restored && isClientRuntimeWindowHandoffBeforePlanDispatch(error48)) {
|
|
112201
112464
|
throw error48;
|
|
@@ -112251,6 +112514,7 @@ var init_runtime_execution = __esm({
|
|
|
112251
112514
|
}]
|
|
112252
112515
|
};
|
|
112253
112516
|
}
|
|
112517
|
+
placedThisPass.add(String(placedOrderId));
|
|
112254
112518
|
const { replaceJournal: _landedJournal, ...landedLeg } = provisionalLeg;
|
|
112255
112519
|
const placedLeg = { ...landedLeg, orderId: placedOrderId };
|
|
112256
112520
|
const placedGroup = {
|
|
@@ -112298,6 +112562,13 @@ var init_runtime_execution = __esm({
|
|
|
112298
112562
|
execution_metadata: { reason_code: "protective_lifecycle_persistence_failed" }
|
|
112299
112563
|
});
|
|
112300
112564
|
};
|
|
112565
|
+
const ownStops = resolveOwnStops({
|
|
112566
|
+
symbol: symbol2,
|
|
112567
|
+
groups: expectedGroupSet,
|
|
112568
|
+
orders: liveOrders,
|
|
112569
|
+
lookedUp,
|
|
112570
|
+
unresolved: unresolvedLegIds
|
|
112571
|
+
});
|
|
112301
112572
|
groupLoop: for (let groupIndex = 0; groupIndex < inspectedGroups.length; groupIndex += 1) {
|
|
112302
112573
|
const inspected = inspectedGroups[groupIndex];
|
|
112303
112574
|
let durableGroup = inspected.group;
|
|
@@ -112375,10 +112646,7 @@ var init_runtime_execution = __esm({
|
|
|
112375
112646
|
continue;
|
|
112376
112647
|
}
|
|
112377
112648
|
if (state2 !== "open" || openOrder == null) {
|
|
112378
|
-
remainingByKind[leg.kind] = Math.max(
|
|
112379
|
-
0,
|
|
112380
|
-
remainingByKind[leg.kind] - leg.size
|
|
112381
|
-
);
|
|
112649
|
+
remainingByKind[leg.kind] = Math.max(0, remainingByKind[leg.kind] - ownStops.cover(leg) - ownStops.inFlight(leg));
|
|
112382
112650
|
retainedLegs.push(leg);
|
|
112383
112651
|
continue;
|
|
112384
112652
|
}
|
|
@@ -112392,7 +112660,7 @@ var init_runtime_execution = __esm({
|
|
|
112392
112660
|
const reservedUntrustedExposure = Number.isFinite(liveOrderSize) && liveOrderSize > 0 ? Math.max(leg.size, liveOrderSize) : leg.size;
|
|
112393
112661
|
remainingByKind[leg.kind] = Math.max(
|
|
112394
112662
|
0,
|
|
112395
|
-
remainingByKind[leg.kind] - reservedUntrustedExposure
|
|
112663
|
+
remainingByKind[leg.kind] - (ownStops.leaving(leg) ? 0 : reservedUntrustedExposure)
|
|
112396
112664
|
);
|
|
112397
112665
|
retainedLegs.push(leg);
|
|
112398
112666
|
reports.push({
|
|
@@ -112406,11 +112674,15 @@ var init_runtime_execution = __esm({
|
|
|
112406
112674
|
});
|
|
112407
112675
|
continue;
|
|
112408
112676
|
}
|
|
112677
|
+
if (ownStops.leaving(leg)) {
|
|
112678
|
+
retainedLegs.push(leg);
|
|
112679
|
+
continue;
|
|
112680
|
+
}
|
|
112409
112681
|
const allowedSize = roundAssetSize(
|
|
112410
112682
|
Math.min(liveOrderSize, remainingByKind[leg.kind]),
|
|
112411
112683
|
request.executionContext.sizeDecimals
|
|
112412
112684
|
);
|
|
112413
|
-
remainingByKind[leg.kind] = Math.max(0, remainingByKind[leg.kind] - allowedSize);
|
|
112685
|
+
remainingByKind[leg.kind] = Math.max(0, remainingByKind[leg.kind] - Math.min(allowedSize, ownStops.cover(leg)));
|
|
112414
112686
|
if (allowedSize <= 0) {
|
|
112415
112687
|
const split3 = splitOversizedProtectiveLeg(expectedGroupSet, durableGroup, leg, exactClientProtectiveGroupSnapshot);
|
|
112416
112688
|
if (!replaceExactClientProtectiveGroupSet(profileId, symbol2, expectedGroupSet, split3.groups)) {
|
|
@@ -112923,7 +113195,10 @@ var init_runtime_execution = __esm({
|
|
|
112923
113195
|
"trading_reduce"
|
|
112924
113196
|
)).size),
|
|
112925
113197
|
openOrders: async () => observed.orders ?? await fetchClientRuntimeOpenOrders(request, "trading_reduce"),
|
|
112926
|
-
rests: (leg, isLong, orders) =>
|
|
113198
|
+
rests: (leg, isLong, orders) => {
|
|
113199
|
+
const order = Array.isArray(orders) ? pageOrderById(orders, leg.orderId) : null;
|
|
113200
|
+
return order != null && protectiveLiveShapeMatches({ shape: liveProtectiveOrderShape(order), symbol: symbol2, isLong, leg });
|
|
113201
|
+
},
|
|
112927
113202
|
markPrice: () => readTrailingMarkPrice({ config: request.config ?? null, signal: request.signal }, symbol2),
|
|
112928
113203
|
sizeDecimals: async () => Number.isInteger(request.executionContext.sizeDecimals) ? request.executionContext.sizeDecimals : resolveExchangeSizeDecimals(symbol2, request.config ?? void 0, "trading_reduce", profileId),
|
|
112929
113204
|
modify: (leg, change) => modifyClientTrailingLeg(request, leg, change),
|
|
@@ -113237,8 +113512,8 @@ var init_runtime_execution = __esm({
|
|
|
113237
113512
|
const previous = clientExecutionMutations.get(key) ?? Promise.resolve();
|
|
113238
113513
|
let abandoned = false;
|
|
113239
113514
|
let startTurn;
|
|
113240
|
-
const turn = new Promise((
|
|
113241
|
-
startTurn =
|
|
113515
|
+
const turn = new Promise((resolve17) => {
|
|
113516
|
+
startTurn = resolve17;
|
|
113242
113517
|
});
|
|
113243
113518
|
const pending3 = previous.catch(() => void 0).then(async () => {
|
|
113244
113519
|
if (abandoned) return void 0;
|
|
@@ -113252,7 +113527,7 @@ var init_runtime_execution = __esm({
|
|
|
113252
113527
|
clientExecutionMutations.set(key, pending3);
|
|
113253
113528
|
const waitMs = runtime_policy_generated_default2.trading.engine.client_runtime.execution_mutation_queue.wait_seconds * MS_PER_SECOND;
|
|
113254
113529
|
try {
|
|
113255
|
-
await new Promise((
|
|
113530
|
+
await new Promise((resolve17, reject) => {
|
|
113256
113531
|
const signal = request.signal;
|
|
113257
113532
|
const finish = () => {
|
|
113258
113533
|
clearTimeout(timer);
|
|
@@ -113274,7 +113549,7 @@ var init_runtime_execution = __esm({
|
|
|
113274
113549
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
113275
113550
|
void turn.then(() => {
|
|
113276
113551
|
finish();
|
|
113277
|
-
|
|
113552
|
+
resolve17();
|
|
113278
113553
|
});
|
|
113279
113554
|
});
|
|
113280
113555
|
return await pending3;
|
|
@@ -116397,7 +116672,7 @@ var init_browser_observability = __esm({
|
|
|
116397
116672
|
init_define_VTX_GROK_POLICY();
|
|
116398
116673
|
init_define_VTX_PI_MODEL_POLICY();
|
|
116399
116674
|
init_runtime_policy_generated2();
|
|
116400
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
116675
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "225d5dbd2325c78cdbd3920226658732f878832b".trim() && "225d5dbd2325c78cdbd3920226658732f878832b".trim() !== "unstamped" ? "225d5dbd2325c78cdbd3920226658732f878832b".trim() : null;
|
|
116401
116676
|
listenersInstalled = false;
|
|
116402
116677
|
state = {
|
|
116403
116678
|
loadedAtMs: Date.now(),
|
|
@@ -117670,21 +117945,21 @@ var require_react_development = __commonJS({
|
|
|
117670
117945
|
);
|
|
117671
117946
|
actScopeDepth = prevActScopeDepth;
|
|
117672
117947
|
}
|
|
117673
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
117948
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve17, reject) {
|
|
117674
117949
|
var queue = ReactSharedInternals.actQueue;
|
|
117675
117950
|
if (null !== queue)
|
|
117676
117951
|
if (0 !== queue.length)
|
|
117677
117952
|
try {
|
|
117678
117953
|
flushActQueue(queue);
|
|
117679
117954
|
enqueueTask(function() {
|
|
117680
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
117955
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve17, reject);
|
|
117681
117956
|
});
|
|
117682
117957
|
return;
|
|
117683
117958
|
} catch (error48) {
|
|
117684
117959
|
ReactSharedInternals.thrownErrors.push(error48);
|
|
117685
117960
|
}
|
|
117686
117961
|
else ReactSharedInternals.actQueue = null;
|
|
117687
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
117962
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve17(returnValue);
|
|
117688
117963
|
}
|
|
117689
117964
|
function flushActQueue(queue) {
|
|
117690
117965
|
if (!isFlushing) {
|
|
@@ -117871,7 +118146,7 @@ var require_react_development = __commonJS({
|
|
|
117871
118146
|
));
|
|
117872
118147
|
});
|
|
117873
118148
|
return {
|
|
117874
|
-
then: function(
|
|
118149
|
+
then: function(resolve17, reject) {
|
|
117875
118150
|
didAwaitActCall = true;
|
|
117876
118151
|
thenable.then(
|
|
117877
118152
|
function(returnValue) {
|
|
@@ -117881,7 +118156,7 @@ var require_react_development = __commonJS({
|
|
|
117881
118156
|
flushActQueue(queue), enqueueTask(function() {
|
|
117882
118157
|
return recursivelyFlushAsyncActWork(
|
|
117883
118158
|
returnValue,
|
|
117884
|
-
|
|
118159
|
+
resolve17,
|
|
117885
118160
|
reject
|
|
117886
118161
|
);
|
|
117887
118162
|
});
|
|
@@ -117895,7 +118170,7 @@ var require_react_development = __commonJS({
|
|
|
117895
118170
|
ReactSharedInternals.thrownErrors.length = 0;
|
|
117896
118171
|
reject(_thrownError);
|
|
117897
118172
|
}
|
|
117898
|
-
} else
|
|
118173
|
+
} else resolve17(returnValue);
|
|
117899
118174
|
},
|
|
117900
118175
|
function(error48) {
|
|
117901
118176
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
@@ -117917,15 +118192,15 @@ var require_react_development = __commonJS({
|
|
|
117917
118192
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
117918
118193
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
117919
118194
|
return {
|
|
117920
|
-
then: function(
|
|
118195
|
+
then: function(resolve17, reject) {
|
|
117921
118196
|
didAwaitActCall = true;
|
|
117922
118197
|
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
117923
118198
|
return recursivelyFlushAsyncActWork(
|
|
117924
118199
|
returnValue$jscomp$0,
|
|
117925
|
-
|
|
118200
|
+
resolve17,
|
|
117926
118201
|
reject
|
|
117927
118202
|
);
|
|
117928
|
-
})) :
|
|
118203
|
+
})) : resolve17(returnValue$jscomp$0);
|
|
117929
118204
|
}
|
|
117930
118205
|
};
|
|
117931
118206
|
};
|
|
@@ -119479,7 +119754,7 @@ var init_client_trade_readback = __esm({
|
|
|
119479
119754
|
close_fill_sync_retry_step_milliseconds: retryStepMs
|
|
119480
119755
|
} = runtime_policy_generated_default2.trading.engine.client_runtime;
|
|
119481
119756
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
119482
|
-
if (attempt2 > 0) await new Promise((
|
|
119757
|
+
if (attempt2 > 0) await new Promise((resolve17) => setTimeout(resolve17, attempt2 * retryStepMs));
|
|
119483
119758
|
try {
|
|
119484
119759
|
const { rawFills } = await fetchBrowserUserFills({
|
|
119485
119760
|
config: target.config,
|
|
@@ -120824,14 +121099,14 @@ var init_client_panel_reads = __esm({
|
|
|
120824
121099
|
const retryAfter = Number(error48.retryAfterMs);
|
|
120825
121100
|
return Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : runtime_policy_generated_default2.exchange.hyperliquid.public_recovery.queue_poll_ms;
|
|
120826
121101
|
};
|
|
120827
|
-
waitForCapacity = (ms, signal) => new Promise((
|
|
121102
|
+
waitForCapacity = (ms, signal) => new Promise((resolve17, reject) => {
|
|
120828
121103
|
if (signal?.aborted) {
|
|
120829
121104
|
reject(signal.reason);
|
|
120830
121105
|
return;
|
|
120831
121106
|
}
|
|
120832
121107
|
const done = () => {
|
|
120833
121108
|
signal?.removeEventListener("abort", aborted2);
|
|
120834
|
-
|
|
121109
|
+
resolve17();
|
|
120835
121110
|
};
|
|
120836
121111
|
const timer = setTimeout(done, Math.max(1, ms));
|
|
120837
121112
|
const aborted2 = () => {
|
|
@@ -122423,9 +122698,9 @@ var init_market_regime = __esm({
|
|
|
122423
122698
|
return token;
|
|
122424
122699
|
};
|
|
122425
122700
|
resolvePromptTimeframes = (activeTimeframes, fallbackTimeframes) => {
|
|
122426
|
-
const
|
|
122427
|
-
const resolved =
|
|
122428
|
-
return [...new Set(resolved.length > 0 ? resolved :
|
|
122701
|
+
const resolve17 = (values) => values.filter((value) => typeof value === "string").map(canonicalTimeframe).filter(Boolean);
|
|
122702
|
+
const resolved = resolve17(activeTimeframes);
|
|
122703
|
+
return [...new Set(resolved.length > 0 ? resolved : resolve17(fallbackTimeframes))];
|
|
122429
122704
|
};
|
|
122430
122705
|
scopeSymbolLines = (message, symbol2) => message.trim().split(LINE_BREAK).map((line) => line.trim()).filter((line) => line && !line.startsWith("---")).map((line) => {
|
|
122431
122706
|
if (line.startsWith("- [")) return line.replace("- [", `- [${symbol2} `);
|
|
@@ -123335,7 +123610,7 @@ var init_google_egress = __esm({
|
|
|
123335
123610
|
// lib/runtime/native-provider-budget.ts
|
|
123336
123611
|
function awaitProviderOperation(operation, signal) {
|
|
123337
123612
|
if (!signal) return operation;
|
|
123338
|
-
return new Promise((
|
|
123613
|
+
return new Promise((resolve17, reject) => {
|
|
123339
123614
|
const aborted2 = () => {
|
|
123340
123615
|
signal.removeEventListener("abort", aborted2);
|
|
123341
123616
|
reject(signal.reason ?? new DOMException("Cancelled", "AbortError"));
|
|
@@ -123343,7 +123618,7 @@ function awaitProviderOperation(operation, signal) {
|
|
|
123343
123618
|
operation.then((value) => {
|
|
123344
123619
|
signal.removeEventListener("abort", aborted2);
|
|
123345
123620
|
if (signal.aborted) aborted2();
|
|
123346
|
-
else
|
|
123621
|
+
else resolve17(value);
|
|
123347
123622
|
}, (error48) => {
|
|
123348
123623
|
signal.removeEventListener("abort", aborted2);
|
|
123349
123624
|
reject(signal.aborted ? signal.reason ?? error48 : error48);
|
|
@@ -123355,8 +123630,8 @@ function awaitProviderOperation(operation, signal) {
|
|
|
123355
123630
|
async function waitForProviderRetry(delayMs, signal) {
|
|
123356
123631
|
let timer;
|
|
123357
123632
|
try {
|
|
123358
|
-
await awaitProviderOperation(new Promise((
|
|
123359
|
-
timer = setTimeout(
|
|
123633
|
+
await awaitProviderOperation(new Promise((resolve17) => {
|
|
123634
|
+
timer = setTimeout(resolve17, delayMs);
|
|
123360
123635
|
}), signal);
|
|
123361
123636
|
} finally {
|
|
123362
123637
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -129202,9 +129477,9 @@ var init_local_analysis = __esm({
|
|
|
129202
129477
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
129203
129478
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
129204
129479
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
129205
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
129206
|
-
"
|
|
129207
|
-
) ? "
|
|
129480
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "225d5dbd2325c78cdbd3920226658732f878832b".trim() && !["unknown", "unstamped", "development"].includes(
|
|
129481
|
+
"225d5dbd2325c78cdbd3920226658732f878832b".trim().toLowerCase()
|
|
129482
|
+
) ? "225d5dbd2325c78cdbd3920226658732f878832b".trim() : null;
|
|
129208
129483
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
129209
129484
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
129210
129485
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|
|
@@ -131552,10 +131827,10 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
131552
131827
|
if (!Number.isFinite(ms) || ms <= 0) {
|
|
131553
131828
|
return;
|
|
131554
131829
|
}
|
|
131555
|
-
await new Promise((
|
|
131830
|
+
await new Promise((resolve17, reject) => {
|
|
131556
131831
|
const timeout = setTimeout(() => {
|
|
131557
131832
|
cleanup();
|
|
131558
|
-
|
|
131833
|
+
resolve17();
|
|
131559
131834
|
}, ms);
|
|
131560
131835
|
const cleanup = () => {
|
|
131561
131836
|
clearTimeout(timeout);
|
|
@@ -135640,7 +135915,7 @@ var init_engine = __esm({
|
|
|
135640
135915
|
}
|
|
135641
135916
|
async _awaitStartStage(operation, controller, stage) {
|
|
135642
135917
|
this._assertStartAttemptActive(controller, stage);
|
|
135643
|
-
return new Promise((
|
|
135918
|
+
return new Promise((resolve17, reject) => {
|
|
135644
135919
|
const rejectCancelled = () => {
|
|
135645
135920
|
reject(createRuntimeStartCancelledError("lifecycle_stop_requested", {
|
|
135646
135921
|
stage
|
|
@@ -135654,7 +135929,7 @@ var init_engine = __esm({
|
|
|
135654
135929
|
rejectCancelled();
|
|
135655
135930
|
return;
|
|
135656
135931
|
}
|
|
135657
|
-
|
|
135932
|
+
resolve17(value);
|
|
135658
135933
|
},
|
|
135659
135934
|
(error48) => {
|
|
135660
135935
|
controller.signal.removeEventListener("abort", rejectCancelled);
|
|
@@ -135749,14 +136024,14 @@ var init_engine = __esm({
|
|
|
135749
136024
|
note: `profile=${this._profileId || "none"} pending=${pending3.length}`,
|
|
135750
136025
|
outcome: "error"
|
|
135751
136026
|
});
|
|
135752
|
-
await new Promise((
|
|
136027
|
+
await new Promise((resolve17) => {
|
|
135753
136028
|
let settled2 = false;
|
|
135754
136029
|
const finish = () => {
|
|
135755
136030
|
if (settled2) return;
|
|
135756
136031
|
settled2 = true;
|
|
135757
136032
|
globalThis.clearTimeout(timeoutId);
|
|
135758
136033
|
signal.removeEventListener("abort", finish);
|
|
135759
|
-
|
|
136034
|
+
resolve17();
|
|
135760
136035
|
};
|
|
135761
136036
|
const timeoutId = globalThis.setTimeout(finish, CLIENT_RUNTIME_POLICY.window_handoff_cleanup_retry_milliseconds);
|
|
135762
136037
|
signal.addEventListener("abort", finish, { once: true });
|
|
@@ -136774,8 +137049,8 @@ var init_engine = __esm({
|
|
|
136774
137049
|
let timer;
|
|
136775
137050
|
const settled2 = await Promise.race([
|
|
136776
137051
|
loop.then(() => true, () => true),
|
|
136777
|
-
new Promise((
|
|
136778
|
-
timer = setTimeout(() =>
|
|
137052
|
+
new Promise((resolve17) => {
|
|
137053
|
+
timer = setTimeout(() => resolve17(false), timeoutMs);
|
|
136779
137054
|
})
|
|
136780
137055
|
]);
|
|
136781
137056
|
clearTimeout(timer);
|
|
@@ -137902,14 +138177,14 @@ var init_engine = __esm({
|
|
|
137902
138177
|
if (signal?.aborted) {
|
|
137903
138178
|
throw signal.reason ?? createStopAbortError("trade_sync_settlement_cancelled");
|
|
137904
138179
|
}
|
|
137905
|
-
await new Promise((
|
|
138180
|
+
await new Promise((resolve17) => {
|
|
137906
138181
|
let settled2 = false;
|
|
137907
138182
|
const finish = () => {
|
|
137908
138183
|
if (settled2) return;
|
|
137909
138184
|
settled2 = true;
|
|
137910
138185
|
globalThis.clearTimeout(timeoutId);
|
|
137911
138186
|
signal?.removeEventListener("abort", finish);
|
|
137912
|
-
|
|
138187
|
+
resolve17();
|
|
137913
138188
|
};
|
|
137914
138189
|
const timeoutId = globalThis.setTimeout(finish, this._loopEarlyReturnRetryDelayMs);
|
|
137915
138190
|
signal?.addEventListener("abort", finish, { once: true });
|
|
@@ -140326,8 +140601,8 @@ var init_engine = __esm({
|
|
|
140326
140601
|
try {
|
|
140327
140602
|
await Promise.race([
|
|
140328
140603
|
activeExecutionLoop,
|
|
140329
|
-
new Promise((
|
|
140330
|
-
executionFenceTimeoutId = setTimeout(
|
|
140604
|
+
new Promise((resolve17) => {
|
|
140605
|
+
executionFenceTimeoutId = setTimeout(resolve17, executionFenceTimeoutMs);
|
|
140331
140606
|
})
|
|
140332
140607
|
]);
|
|
140333
140608
|
} catch {
|
|
@@ -141512,8 +141787,8 @@ async function runHeadlessRuntime(options) {
|
|
|
141512
141787
|
};
|
|
141513
141788
|
const nextEvent = async () => {
|
|
141514
141789
|
while (pending3.length === 0) {
|
|
141515
|
-
await new Promise((
|
|
141516
|
-
wake =
|
|
141790
|
+
await new Promise((resolve17) => {
|
|
141791
|
+
wake = resolve17;
|
|
141517
141792
|
});
|
|
141518
141793
|
wake = null;
|
|
141519
141794
|
}
|
|
@@ -141643,9 +141918,9 @@ async function runHeadlessRuntime(options) {
|
|
|
141643
141918
|
const stored = await readRuntimeState(options.statePath).catch(() => null);
|
|
141644
141919
|
const ownDevices = new Set([identity3.deviceId, stored?.deviceId].filter(Boolean).map(String));
|
|
141645
141920
|
let offered = false;
|
|
141646
|
-
const stopped = new Promise((
|
|
141647
|
-
if (stopController.signal.aborted)
|
|
141648
|
-
else stopController.signal.addEventListener("abort", () =>
|
|
141921
|
+
const stopped = new Promise((resolve17) => {
|
|
141922
|
+
if (stopController.signal.aborted) resolve17(false);
|
|
141923
|
+
else stopController.signal.addEventListener("abort", () => resolve17(false), { once: true });
|
|
141649
141924
|
});
|
|
141650
141925
|
const withdraw = async () => {
|
|
141651
141926
|
if (!offered) return;
|
|
@@ -142600,7 +142875,7 @@ The CLI updates itself at start; set VTX_CLI_AUTO_UPDATE=0 to turn that off.
|
|
|
142600
142875
|
// Every BYOK provider's key field, from the one provider registry.
|
|
142601
142876
|
...BYOK_PROVIDERS.map((provider) => provider.apiKeyField)
|
|
142602
142877
|
]);
|
|
142603
|
-
delay2 = (ms) => new Promise((
|
|
142878
|
+
delay2 = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
142604
142879
|
}
|
|
142605
142880
|
});
|
|
142606
142881
|
|