@vtxmacro/cli 2026.10.58 → 2026.10.60
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 +14 -0
- package/bin/vtx-mcp.js +15 -1
- package/bin/vtx-service-bootstrap.js +15 -1
- package/bin/vtx-service-launcher.js +14 -0
- package/bin/vtx.js +1250 -729
- 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.60", 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,
|
|
@@ -1535,6 +1536,19 @@ var init_runtime_policy_generated = __esm({
|
|
|
1535
1536
|
error_details: {
|
|
1536
1537
|
review_failure_message_max_length: 220
|
|
1537
1538
|
}
|
|
1539
|
+
},
|
|
1540
|
+
llm: {
|
|
1541
|
+
provider_diagnostics: {
|
|
1542
|
+
reply_body_max_chars: 65536,
|
|
1543
|
+
reply_max_headers: 64,
|
|
1544
|
+
reply_header_name_parts: [
|
|
1545
|
+
"retry-after",
|
|
1546
|
+
"ratelimit",
|
|
1547
|
+
"rate-limit",
|
|
1548
|
+
"quota",
|
|
1549
|
+
"balance"
|
|
1550
|
+
]
|
|
1551
|
+
}
|
|
1538
1552
|
}
|
|
1539
1553
|
};
|
|
1540
1554
|
}
|
|
@@ -3087,7 +3101,7 @@ var init_shared_contracts_generated = __esm({
|
|
|
3087
3101
|
});
|
|
3088
3102
|
|
|
3089
3103
|
// 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;
|
|
3104
|
+
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
3105
|
var init_constants = __esm({
|
|
3092
3106
|
"lib/constants.ts"() {
|
|
3093
3107
|
"use strict";
|
|
@@ -3357,6 +3371,15 @@ var init_constants = __esm({
|
|
|
3357
3371
|
BOOT_IDENTITY: 4096
|
|
3358
3372
|
};
|
|
3359
3373
|
CODEX_HOSTED_ATTEMPT_PATH_SEGMENTS = 3;
|
|
3374
|
+
INFERENCE_HOST_TEMP_FOLDERS = {
|
|
3375
|
+
CODEX_WORKER_PREFIX: "vtx-codex-host-",
|
|
3376
|
+
CODEX_WORKER_JOBS: "workspaces",
|
|
3377
|
+
CODEX_HOSTED_JOB_PREFIX: "attempt-",
|
|
3378
|
+
CODEX_JOB_PREFIX: "vtx-codex-attempt-",
|
|
3379
|
+
COPILOT_JOB_PREFIX: "vtx-copilot-",
|
|
3380
|
+
DEEPSEEK_JOB_PREFIX: "vtx-deepseek-harness-"
|
|
3381
|
+
};
|
|
3382
|
+
INFERENCE_HOST_FAILURE_CAUSE_MAX_DEPTH = 8;
|
|
3360
3383
|
CODEX_GUARDIAN_PROCESS_TOKEN_BYTES = 32;
|
|
3361
3384
|
CODEX_RATE_LIMIT_EXHAUSTED_PERCENT = 100;
|
|
3362
3385
|
INFERENCE_HOST_PROXY_TOKEN_BYTES = 24;
|
|
@@ -3917,7 +3940,7 @@ function skipVoid(ctx, banNewLines, banComments) {
|
|
|
3917
3940
|
skipComment(ctx);
|
|
3918
3941
|
}
|
|
3919
3942
|
}
|
|
3920
|
-
function skipUntil(ctx,
|
|
3943
|
+
function skipUntil(ctx, sep4, end) {
|
|
3921
3944
|
let ptr = ctx.p;
|
|
3922
3945
|
if (!end) {
|
|
3923
3946
|
ptr = indexOfNewline(ctx.s, ptr);
|
|
@@ -3928,7 +3951,7 @@ function skipUntil(ctx, sep3, end) {
|
|
|
3928
3951
|
let c = ctx.s.charCodeAt(ctx.p);
|
|
3929
3952
|
if (c === 35) {
|
|
3930
3953
|
skipComment(ctx);
|
|
3931
|
-
} else if (c === end || c ===
|
|
3954
|
+
} else if (c === end || c === sep4) {
|
|
3932
3955
|
return;
|
|
3933
3956
|
}
|
|
3934
3957
|
}
|
|
@@ -4747,7 +4770,7 @@ async function syncInferenceDirectory(path, platform = process.platform) {
|
|
|
4747
4770
|
async function replaceAtomicInferencePrivateFile(temporaryPath, destinationPath, options = {}) {
|
|
4748
4771
|
const platform = options.platform ?? process.platform;
|
|
4749
4772
|
const renameFile = options.renameFile ?? rename;
|
|
4750
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
4773
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => setTimeout(resolve17, milliseconds)));
|
|
4751
4774
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_CORE_POLICY.private_file_replace_attempts);
|
|
4752
4775
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_CORE_POLICY.private_file_replace_retry_delay_ms);
|
|
4753
4776
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -5977,10 +6000,10 @@ var init_abort = __esm({
|
|
|
5977
6000
|
}
|
|
5978
6001
|
};
|
|
5979
6002
|
abortableSleep = async (ms, signal) => {
|
|
5980
|
-
await new Promise((
|
|
6003
|
+
await new Promise((resolve17, reject) => {
|
|
5981
6004
|
const timer = setTimeout(() => {
|
|
5982
6005
|
cleanup();
|
|
5983
|
-
|
|
6006
|
+
resolve17(void 0);
|
|
5984
6007
|
}, ms);
|
|
5985
6008
|
const cleanup = () => {
|
|
5986
6009
|
clearTimeout(timer);
|
|
@@ -22757,6 +22780,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22757
22780
|
model_catalog_read_lead_divisor: 2,
|
|
22758
22781
|
agent_wake_summary_max_chars: 2e3,
|
|
22759
22782
|
drain_timeout_ms: 3e4,
|
|
22783
|
+
undispatched_adapter_failure_restart_threshold: 3,
|
|
22760
22784
|
remote_retry_limit: 3,
|
|
22761
22785
|
minimum_sleep_ms: 10,
|
|
22762
22786
|
heartbeat_gap_diagnostic_min_ms: 1e4,
|
|
@@ -23183,13 +23207,26 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
23183
23207
|
error_details: {
|
|
23184
23208
|
review_failure_message_max_length: 220
|
|
23185
23209
|
}
|
|
23210
|
+
},
|
|
23211
|
+
llm: {
|
|
23212
|
+
provider_diagnostics: {
|
|
23213
|
+
reply_body_max_chars: 65536,
|
|
23214
|
+
reply_max_headers: 64,
|
|
23215
|
+
reply_header_name_parts: [
|
|
23216
|
+
"retry-after",
|
|
23217
|
+
"ratelimit",
|
|
23218
|
+
"rate-limit",
|
|
23219
|
+
"quota",
|
|
23220
|
+
"balance"
|
|
23221
|
+
]
|
|
23222
|
+
}
|
|
23186
23223
|
}
|
|
23187
23224
|
};
|
|
23188
23225
|
}
|
|
23189
23226
|
});
|
|
23190
23227
|
|
|
23191
23228
|
// 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;
|
|
23229
|
+
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
23230
|
var init_external_inference_contract = __esm({
|
|
23194
23231
|
"lib/external-inference-contract.ts"() {
|
|
23195
23232
|
"use strict";
|
|
@@ -24161,7 +24198,8 @@ var init_external_inference_contract = __esm({
|
|
|
24161
24198
|
"service_update",
|
|
24162
24199
|
"drain_timeout",
|
|
24163
24200
|
"provider_dispatch_watchdog_expired",
|
|
24164
|
-
"receipt_durability_timeout"
|
|
24201
|
+
"receipt_durability_timeout",
|
|
24202
|
+
"adapter_setup_failed"
|
|
24165
24203
|
]).nullable(),
|
|
24166
24204
|
failure_code: external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,95}$/u).nullable(),
|
|
24167
24205
|
pending_attempts: nonNegativeSafeIntegerSchema,
|
|
@@ -24503,6 +24541,14 @@ var init_external_inference_contract = __esm({
|
|
|
24503
24541
|
context.addIssue({ code: "custom", message: "truncated stderr diagnostics must report the observation cap", path: ["stderr_truncated"] });
|
|
24504
24542
|
}
|
|
24505
24543
|
});
|
|
24544
|
+
EXTERNAL_INFERENCE_FAILURE_FOLDER_ROLES = ["worker_folder", "job_folder", "temp_root", "other"];
|
|
24545
|
+
externalInferenceFailureDetailSchema = external_exports.strictObject({
|
|
24546
|
+
schema_version: external_exports.literal("external_inference_failure_detail_v1"),
|
|
24547
|
+
error_class: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length).regex(/^[A-Za-z][A-Za-z0-9_]*$/u),
|
|
24548
|
+
errno_code: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length).regex(/^[A-Z][A-Z0-9_]*$/u).nullable(),
|
|
24549
|
+
syscall: external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.label_length).regex(/^[a-z][a-z0-9_]*$/u).nullable(),
|
|
24550
|
+
folder_role: external_exports.enum(EXTERNAL_INFERENCE_FAILURE_FOLDER_ROLES).nullable()
|
|
24551
|
+
});
|
|
24506
24552
|
jobFailRequestSchema = external_exports.strictObject({
|
|
24507
24553
|
schema_version: external_exports.literal("external_inference_job_fail_v1"),
|
|
24508
24554
|
contract_version: external_exports.literal(EXTERNAL_INFERENCE_CONTRACT_VERSION),
|
|
@@ -24534,6 +24580,7 @@ var init_external_inference_contract = __esm({
|
|
|
24534
24580
|
provider_http_status: external_exports.number().int().min(HTTP_CLIENT_ERROR_MIN).max(HTTP_STATUS_MAX).optional(),
|
|
24535
24581
|
grok_tool_validation: grokToolValidationDiagnosticSchema.optional(),
|
|
24536
24582
|
grok_response_identity: grokResponseIdentityDiagnosticSchema.optional(),
|
|
24583
|
+
failure_detail: externalInferenceFailureDetailSchema.optional(),
|
|
24537
24584
|
membership_disposition: external_exports.enum([
|
|
24538
24585
|
"retry_same_host",
|
|
24539
24586
|
"cascade_cooldown",
|
|
@@ -25392,7 +25439,7 @@ var init_credential_store = __esm({
|
|
|
25392
25439
|
}
|
|
25393
25440
|
return;
|
|
25394
25441
|
}
|
|
25395
|
-
await new Promise((
|
|
25442
|
+
await new Promise((resolve17) => {
|
|
25396
25443
|
const terminator = spawn3(
|
|
25397
25444
|
"taskkill.exe",
|
|
25398
25445
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -25410,21 +25457,21 @@ var init_credential_store = __esm({
|
|
|
25410
25457
|
const timer = setTimeout(() => {
|
|
25411
25458
|
terminator.kill("SIGKILL");
|
|
25412
25459
|
child.kill("SIGKILL");
|
|
25413
|
-
|
|
25460
|
+
resolve17();
|
|
25414
25461
|
}, CREDENTIAL_COMMAND_TERMINATION_TIMEOUT_MS);
|
|
25415
25462
|
terminator.once("error", () => {
|
|
25416
25463
|
clearTimeout(timer);
|
|
25417
25464
|
child.kill("SIGKILL");
|
|
25418
|
-
|
|
25465
|
+
resolve17();
|
|
25419
25466
|
});
|
|
25420
25467
|
terminator.once("close", () => {
|
|
25421
25468
|
clearTimeout(timer);
|
|
25422
25469
|
if (child.exitCode === null) child.kill("SIGKILL");
|
|
25423
|
-
|
|
25470
|
+
resolve17();
|
|
25424
25471
|
});
|
|
25425
25472
|
});
|
|
25426
25473
|
};
|
|
25427
|
-
runCredentialCommand = async (command, options) => await new Promise((
|
|
25474
|
+
runCredentialCommand = async (command, options) => await new Promise((resolve17, reject) => {
|
|
25428
25475
|
const timeoutMs = options.timeoutMs ?? DEFAULT_CREDENTIAL_COMMAND_TIMEOUT_MS;
|
|
25429
25476
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
25430
25477
|
reject(new Error("OS credential command timeout must be a positive integer."));
|
|
@@ -25483,7 +25530,7 @@ var init_credential_store = __esm({
|
|
|
25483
25530
|
const transformedStdout = normalizedExitCode === 0 ? command.transformStdout?.(stdout) ?? stdout : stdout;
|
|
25484
25531
|
settled2 = true;
|
|
25485
25532
|
cleanup();
|
|
25486
|
-
|
|
25533
|
+
resolve17({
|
|
25487
25534
|
exitCode: normalizedExitCode,
|
|
25488
25535
|
stdout: transformedStdout
|
|
25489
25536
|
});
|
|
@@ -26643,11 +26690,11 @@ async function revokeInferenceCredential(options) {
|
|
|
26643
26690
|
}
|
|
26644
26691
|
}
|
|
26645
26692
|
async function listenLoopback(server) {
|
|
26646
|
-
await new Promise((
|
|
26693
|
+
await new Promise((resolve17, reject) => {
|
|
26647
26694
|
server.once("error", reject);
|
|
26648
26695
|
server.listen(0, CALLBACK_HOST, () => {
|
|
26649
26696
|
server.off("error", reject);
|
|
26650
|
-
|
|
26697
|
+
resolve17();
|
|
26651
26698
|
});
|
|
26652
26699
|
});
|
|
26653
26700
|
const address = server.address();
|
|
@@ -26658,7 +26705,7 @@ async function listenLoopback(server) {
|
|
|
26658
26705
|
}
|
|
26659
26706
|
async function closeServer(server) {
|
|
26660
26707
|
if (!server.listening) return;
|
|
26661
|
-
await new Promise((
|
|
26708
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
26662
26709
|
}
|
|
26663
26710
|
async function beginInferenceOAuthLogin(options) {
|
|
26664
26711
|
const loginTimeoutMs = options.timeoutMs ?? HOST_CORE_POLICY2.oauth_login_timeout_ms;
|
|
@@ -26714,7 +26761,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
26714
26761
|
});
|
|
26715
26762
|
let settled2 = false;
|
|
26716
26763
|
let rejectCompletion;
|
|
26717
|
-
const completion = new Promise((
|
|
26764
|
+
const completion = new Promise((resolve17, reject) => {
|
|
26718
26765
|
rejectCompletion = reject;
|
|
26719
26766
|
handler = async (requestUrl2, method, writeResponse) => {
|
|
26720
26767
|
if (settled2) {
|
|
@@ -26789,7 +26836,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
26789
26836
|
'<!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
26837
|
);
|
|
26791
26838
|
await closeServer(server);
|
|
26792
|
-
|
|
26839
|
+
resolve17({
|
|
26793
26840
|
accessToken: tokens.accessToken,
|
|
26794
26841
|
expiresIn: tokens.expiresIn,
|
|
26795
26842
|
credential,
|
|
@@ -26935,7 +26982,7 @@ var init_mcp_transport = __esm({
|
|
|
26935
26982
|
});
|
|
26936
26983
|
|
|
26937
26984
|
// lib/inference-host/mcp-client.ts
|
|
26938
|
-
var EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION, EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS, EXTERNAL_INFERENCE_OPERATIONAL_TOOLS, ClaimTiming, ExternalInferenceMcpError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_AFTER_MS, SSE_DATA_FIELD_PREFIX, PUBLIC_TOOL_ERROR_PREFIX, parseRetryAfterMs, identifierSchema2, safeCodeSchema2, publicFailureCodeSchema, publicToolErrorSchema, structuredPublicToolErrorSchema, MAX_REJECTION_REASON_CHARS, CONTROL_CHARACTERS, publicRejectionReason, parsePublicToolError, hostMutationResultSchema, attemptStartResultSchema, agentConnectResultSchema, agentHeartbeatResultSchema, timestampSchema2, positiveGenerationSchema, jsonObjectSchema, agentAssignmentNextArgumentsSchema, agentDataCapabilityDescriptorSchema, agentAssignmentNextResultSchema, agentAssignmentHeartbeatArgumentsSchema, agentAssignmentHeartbeatResultSchema, agentDataCallArgumentsSchema, agentDataCallResultSchema, agentDecisionTimingSchema, agentDecisionSubmitArgumentsSchema, agentDecisionSubmitResultSchema, agentDecisionStatusArgumentsSchema, agentDecisionStatusResultSchema, agentAssignmentReleaseArgumentsSchema, agentAssignmentReleaseResultSchema, jobCompletionResultSchema, jobFailureResultSchema, toolContracts, discoveryResultSchema, toolListResultSchema, inlineStructuredContentSchema, protocolMeta, parseJsonDocument, parseSseDocuments, parseResponseDocuments, exactOperationalInventory, exactJson, invalidBoundResult, verifyToolResult, ExternalInferenceMcpClient;
|
|
26985
|
+
var EXTERNAL_INFERENCE_MCP_PROTOCOL_VERSION, EXTERNAL_INFERENCE_AUTOMATED_HOST_TOOLS, EXTERNAL_INFERENCE_OPERATIONAL_TOOLS, ClaimTiming, ExternalInferenceMcpError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_RETRY_AFTER_MS, SSE_DATA_FIELD_PREFIX, PUBLIC_TOOL_ERROR_PREFIX, parseRetryAfterMs, identifierSchema2, safeCodeSchema2, serverReasonCodeSchema, publicFailureCodeSchema, publicToolErrorSchema, structuredPublicToolErrorSchema, MAX_REJECTION_REASON_CHARS, CONTROL_CHARACTERS, publicRejectionReason, parsePublicToolError, hostMutationResultSchema, attemptStartResultSchema, agentConnectResultSchema, agentHeartbeatResultSchema, timestampSchema2, positiveGenerationSchema, jsonObjectSchema, agentAssignmentNextArgumentsSchema, agentDataCapabilityDescriptorSchema, agentAssignmentNextResultSchema, agentAssignmentHeartbeatArgumentsSchema, agentAssignmentHeartbeatResultSchema, agentDataCallArgumentsSchema, agentDataCallResultSchema, agentDecisionTimingSchema, agentDecisionSubmitArgumentsSchema, agentDecisionSubmitResultSchema, agentDecisionStatusArgumentsSchema, agentDecisionStatusResultSchema, agentAssignmentReleaseArgumentsSchema, agentAssignmentReleaseResultSchema, jobCompletionResultSchema, jobFailureResultSchema, toolContracts, discoveryResultSchema, toolListResultSchema, inlineStructuredContentSchema, protocolMeta, parseJsonDocument, parseSseDocuments, parseResponseDocuments, exactOperationalInventory, exactJson, invalidBoundResult, verifyToolResult, ExternalInferenceMcpClient;
|
|
26939
26986
|
var init_mcp_client = __esm({
|
|
26940
26987
|
"lib/inference-host/mcp-client.ts"() {
|
|
26941
26988
|
"use strict";
|
|
@@ -27087,6 +27134,7 @@ var init_mcp_client = __esm({
|
|
|
27087
27134
|
this.httpStatusCode = options.httpStatusCode ?? null;
|
|
27088
27135
|
this.retryAfterMs = options.retryAfterMs ?? null;
|
|
27089
27136
|
this.serverFailureCode = options.serverFailureCode ?? null;
|
|
27137
|
+
this.serverReasonCode = options.serverReasonCode ?? null;
|
|
27090
27138
|
this.retryable = options.retryable ?? [
|
|
27091
27139
|
"network_error",
|
|
27092
27140
|
"transport_rejected",
|
|
@@ -27112,6 +27160,7 @@ var init_mcp_client = __esm({
|
|
|
27112
27160
|
};
|
|
27113
27161
|
identifierSchema2 = external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.identifier_length);
|
|
27114
27162
|
safeCodeSchema2 = external_exports.string().min(1).max(EXTERNAL_INFERENCE_SCHEMA_BOUNDS.long_code_length);
|
|
27163
|
+
serverReasonCodeSchema = safeCodeSchema2.regex(/^[a-z0-9][a-z0-9._-]*$/u);
|
|
27115
27164
|
publicFailureCodeSchema = external_exports.string().regex(/^[a-z0-9][a-z0-9._-]{0,95}$/u);
|
|
27116
27165
|
publicToolErrorSchema = external_exports.object({
|
|
27117
27166
|
failure_code: publicFailureCodeSchema,
|
|
@@ -27646,6 +27695,7 @@ var init_mcp_client = __esm({
|
|
|
27646
27695
|
#claimTransportFailureReportsSupported = false;
|
|
27647
27696
|
#providerQuotaCooldownSupported = false;
|
|
27648
27697
|
#providerHttpStatusTools = /* @__PURE__ */ new Set();
|
|
27698
|
+
#failureDetailSupported = false;
|
|
27649
27699
|
#grokToolValidationTools = /* @__PURE__ */ new Set();
|
|
27650
27700
|
#grokResponseIdentityTools = /* @__PURE__ */ new Set();
|
|
27651
27701
|
async close() {
|
|
@@ -27690,6 +27740,18 @@ var init_mcp_client = __esm({
|
|
|
27690
27740
|
supportsRuntimeRecoveryDiagnostics() {
|
|
27691
27741
|
return this.#runtimeRecoveryDiagnosticsSupported;
|
|
27692
27742
|
}
|
|
27743
|
+
supportsFailureDetail() {
|
|
27744
|
+
return this.#failureDetailSupported;
|
|
27745
|
+
}
|
|
27746
|
+
async refreshFailureDetailSupport(options = {}) {
|
|
27747
|
+
if (this.supportsFailureDetail()) return true;
|
|
27748
|
+
try {
|
|
27749
|
+
await this.initialize(options);
|
|
27750
|
+
} catch {
|
|
27751
|
+
return false;
|
|
27752
|
+
}
|
|
27753
|
+
return this.supportsFailureDetail();
|
|
27754
|
+
}
|
|
27693
27755
|
supportsClaimTransportFailureReports() {
|
|
27694
27756
|
return this.#claimTransportFailureReportsSupported;
|
|
27695
27757
|
}
|
|
@@ -27846,6 +27908,7 @@ var init_mcp_client = __esm({
|
|
|
27846
27908
|
}
|
|
27847
27909
|
return Array.isArray(node.anyOf) && node.anyOf.some((branch) => advertisesDiagnosticReceipt(branch, field, depth + 1));
|
|
27848
27910
|
};
|
|
27911
|
+
this.#failureDetailSupported = advertisesFields("inference.job.fail", ["failure_detail"]);
|
|
27849
27912
|
this.#providerHttpStatusTools.clear();
|
|
27850
27913
|
if (advertisesFields("inference.job.fail", ["provider_http_status"])) {
|
|
27851
27914
|
this.#providerHttpStatusTools.add("inference.job.fail");
|
|
@@ -27929,6 +27992,7 @@ var init_mcp_client = __esm({
|
|
|
27929
27992
|
// the exact request unless the server proves it was not applied.
|
|
27930
27993
|
retryable: retryableInfrastructureRejection || retryableClaimRejection || retryableHeartbeatClockSkew || retryableAdvertisementClockSkew,
|
|
27931
27994
|
serverFailureCode: publicToolError?.failure_code ?? null,
|
|
27995
|
+
serverReasonCode: serverReasonCodeSchema.safeParse(publicToolError?.reason_code).data ?? null,
|
|
27932
27996
|
retryAfterMs: hostNotClaimable ? publicToolError?.retry_after_ms ?? null : null
|
|
27933
27997
|
}
|
|
27934
27998
|
);
|
|
@@ -28878,51 +28942,51 @@ var require_uri_all = __commonJS({
|
|
|
28878
28942
|
}
|
|
28879
28943
|
return uriTokens.join("");
|
|
28880
28944
|
}
|
|
28881
|
-
function resolveComponents(base2,
|
|
28945
|
+
function resolveComponents(base2, relative6) {
|
|
28882
28946
|
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
28883
28947
|
var skipNormalization = arguments[3];
|
|
28884
28948
|
var target = {};
|
|
28885
28949
|
if (!skipNormalization) {
|
|
28886
28950
|
base2 = parse5(serialize(base2, options), options);
|
|
28887
|
-
|
|
28951
|
+
relative6 = parse5(serialize(relative6, options), options);
|
|
28888
28952
|
}
|
|
28889
28953
|
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 =
|
|
28954
|
+
if (!options.tolerant && relative6.scheme) {
|
|
28955
|
+
target.scheme = relative6.scheme;
|
|
28956
|
+
target.userinfo = relative6.userinfo;
|
|
28957
|
+
target.host = relative6.host;
|
|
28958
|
+
target.port = relative6.port;
|
|
28959
|
+
target.path = removeDotSegments(relative6.path || "");
|
|
28960
|
+
target.query = relative6.query;
|
|
28897
28961
|
} else {
|
|
28898
|
-
if (
|
|
28899
|
-
target.userinfo =
|
|
28900
|
-
target.host =
|
|
28901
|
-
target.port =
|
|
28902
|
-
target.path = removeDotSegments(
|
|
28903
|
-
target.query =
|
|
28962
|
+
if (relative6.userinfo !== void 0 || relative6.host !== void 0 || relative6.port !== void 0) {
|
|
28963
|
+
target.userinfo = relative6.userinfo;
|
|
28964
|
+
target.host = relative6.host;
|
|
28965
|
+
target.port = relative6.port;
|
|
28966
|
+
target.path = removeDotSegments(relative6.path || "");
|
|
28967
|
+
target.query = relative6.query;
|
|
28904
28968
|
} else {
|
|
28905
|
-
if (!
|
|
28969
|
+
if (!relative6.path) {
|
|
28906
28970
|
target.path = base2.path;
|
|
28907
|
-
if (
|
|
28908
|
-
target.query =
|
|
28971
|
+
if (relative6.query !== void 0) {
|
|
28972
|
+
target.query = relative6.query;
|
|
28909
28973
|
} else {
|
|
28910
28974
|
target.query = base2.query;
|
|
28911
28975
|
}
|
|
28912
28976
|
} else {
|
|
28913
|
-
if (
|
|
28914
|
-
target.path = removeDotSegments(
|
|
28977
|
+
if (relative6.path.charAt(0) === "/") {
|
|
28978
|
+
target.path = removeDotSegments(relative6.path);
|
|
28915
28979
|
} else {
|
|
28916
28980
|
if ((base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0) && !base2.path) {
|
|
28917
|
-
target.path = "/" +
|
|
28981
|
+
target.path = "/" + relative6.path;
|
|
28918
28982
|
} else if (!base2.path) {
|
|
28919
|
-
target.path =
|
|
28983
|
+
target.path = relative6.path;
|
|
28920
28984
|
} else {
|
|
28921
|
-
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) +
|
|
28985
|
+
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative6.path;
|
|
28922
28986
|
}
|
|
28923
28987
|
target.path = removeDotSegments(target.path);
|
|
28924
28988
|
}
|
|
28925
|
-
target.query =
|
|
28989
|
+
target.query = relative6.query;
|
|
28926
28990
|
}
|
|
28927
28991
|
target.userinfo = base2.userinfo;
|
|
28928
28992
|
target.host = base2.host;
|
|
@@ -28930,10 +28994,10 @@ var require_uri_all = __commonJS({
|
|
|
28930
28994
|
}
|
|
28931
28995
|
target.scheme = base2.scheme;
|
|
28932
28996
|
}
|
|
28933
|
-
target.fragment =
|
|
28997
|
+
target.fragment = relative6.fragment;
|
|
28934
28998
|
return target;
|
|
28935
28999
|
}
|
|
28936
|
-
function
|
|
29000
|
+
function resolve17(baseURI, relativeURI, options) {
|
|
28937
29001
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
28938
29002
|
return serialize(resolveComponents(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
28939
29003
|
}
|
|
@@ -29198,7 +29262,7 @@ var require_uri_all = __commonJS({
|
|
|
29198
29262
|
exports2.removeDotSegments = removeDotSegments;
|
|
29199
29263
|
exports2.serialize = serialize;
|
|
29200
29264
|
exports2.resolveComponents = resolveComponents;
|
|
29201
|
-
exports2.resolve =
|
|
29265
|
+
exports2.resolve = resolve17;
|
|
29202
29266
|
exports2.normalize = normalize;
|
|
29203
29267
|
exports2.equal = equal;
|
|
29204
29268
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -29575,18 +29639,18 @@ var require_resolve = __commonJS({
|
|
|
29575
29639
|
var util = require_util();
|
|
29576
29640
|
var SchemaObject = require_schema_obj();
|
|
29577
29641
|
var traverse = require_json_schema_traverse();
|
|
29578
|
-
module.exports =
|
|
29579
|
-
|
|
29580
|
-
|
|
29581
|
-
|
|
29582
|
-
|
|
29583
|
-
|
|
29584
|
-
|
|
29585
|
-
function
|
|
29642
|
+
module.exports = resolve17;
|
|
29643
|
+
resolve17.normalizeId = normalizeId;
|
|
29644
|
+
resolve17.fullPath = getFullPath;
|
|
29645
|
+
resolve17.url = resolveUrl;
|
|
29646
|
+
resolve17.ids = resolveIds;
|
|
29647
|
+
resolve17.inlineRef = inlineRef;
|
|
29648
|
+
resolve17.schema = resolveSchema;
|
|
29649
|
+
function resolve17(compile, root, ref) {
|
|
29586
29650
|
var refVal = this._refs[ref];
|
|
29587
29651
|
if (typeof refVal == "string") {
|
|
29588
29652
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
29589
|
-
else return
|
|
29653
|
+
else return resolve17.call(this, compile, root, refVal);
|
|
29590
29654
|
}
|
|
29591
29655
|
refVal = refVal || this._schemas[ref];
|
|
29592
29656
|
if (refVal instanceof SchemaObject) {
|
|
@@ -29795,7 +29859,7 @@ var require_error_classes = __commonJS({
|
|
|
29795
29859
|
init_define_VTX_EXO_POLICY();
|
|
29796
29860
|
init_define_VTX_GROK_POLICY();
|
|
29797
29861
|
init_define_VTX_PI_MODEL_POLICY();
|
|
29798
|
-
var
|
|
29862
|
+
var resolve17 = require_resolve();
|
|
29799
29863
|
module.exports = {
|
|
29800
29864
|
Validation: errorSubclass(ValidationError),
|
|
29801
29865
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -29810,8 +29874,8 @@ var require_error_classes = __commonJS({
|
|
|
29810
29874
|
};
|
|
29811
29875
|
function MissingRefError(baseId, ref, message) {
|
|
29812
29876
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
29813
|
-
this.missingRef =
|
|
29814
|
-
this.missingSchema =
|
|
29877
|
+
this.missingRef = resolve17.url(baseId, ref);
|
|
29878
|
+
this.missingSchema = resolve17.normalizeId(resolve17.fullPath(this.missingRef));
|
|
29815
29879
|
}
|
|
29816
29880
|
function errorSubclass(Subclass) {
|
|
29817
29881
|
Subclass.prototype = Object.create(Error.prototype);
|
|
@@ -30351,7 +30415,7 @@ var require_compile = __commonJS({
|
|
|
30351
30415
|
init_define_VTX_EXO_POLICY();
|
|
30352
30416
|
init_define_VTX_GROK_POLICY();
|
|
30353
30417
|
init_define_VTX_PI_MODEL_POLICY();
|
|
30354
|
-
var
|
|
30418
|
+
var resolve17 = require_resolve();
|
|
30355
30419
|
var util = require_util();
|
|
30356
30420
|
var errorClasses = require_error_classes();
|
|
30357
30421
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -30413,7 +30477,7 @@ var require_compile = __commonJS({
|
|
|
30413
30477
|
RULES: RULES2,
|
|
30414
30478
|
validate: validateGenerator,
|
|
30415
30479
|
util,
|
|
30416
|
-
resolve:
|
|
30480
|
+
resolve: resolve17,
|
|
30417
30481
|
resolveRef: resolveRef2,
|
|
30418
30482
|
usePattern,
|
|
30419
30483
|
useDefault,
|
|
@@ -30475,7 +30539,7 @@ var require_compile = __commonJS({
|
|
|
30475
30539
|
return validate;
|
|
30476
30540
|
}
|
|
30477
30541
|
function resolveRef2(baseId2, ref, isRoot) {
|
|
30478
|
-
ref =
|
|
30542
|
+
ref = resolve17.url(baseId2, ref);
|
|
30479
30543
|
var refIndex = refs[ref];
|
|
30480
30544
|
var _refVal, refCode;
|
|
30481
30545
|
if (refIndex !== void 0) {
|
|
@@ -30492,11 +30556,11 @@ var require_compile = __commonJS({
|
|
|
30492
30556
|
}
|
|
30493
30557
|
}
|
|
30494
30558
|
refCode = addLocalRef(ref);
|
|
30495
|
-
var v2 =
|
|
30559
|
+
var v2 = resolve17.call(self2, localCompile, root, ref);
|
|
30496
30560
|
if (v2 === void 0) {
|
|
30497
30561
|
var localSchema = localRefs && localRefs[ref];
|
|
30498
30562
|
if (localSchema) {
|
|
30499
|
-
v2 =
|
|
30563
|
+
v2 = resolve17.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
|
|
30500
30564
|
}
|
|
30501
30565
|
}
|
|
30502
30566
|
if (v2 === void 0) {
|
|
@@ -34245,7 +34309,7 @@ var require_ajv = __commonJS({
|
|
|
34245
34309
|
init_define_VTX_GROK_POLICY();
|
|
34246
34310
|
init_define_VTX_PI_MODEL_POLICY();
|
|
34247
34311
|
var compileSchema = require_compile();
|
|
34248
|
-
var
|
|
34312
|
+
var resolve17 = require_resolve();
|
|
34249
34313
|
var Cache = require_cache();
|
|
34250
34314
|
var SchemaObject = require_schema_obj();
|
|
34251
34315
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -34327,7 +34391,7 @@ var require_ajv = __commonJS({
|
|
|
34327
34391
|
var id2 = this._getId(schema);
|
|
34328
34392
|
if (id2 !== void 0 && typeof id2 != "string")
|
|
34329
34393
|
throw new Error("schema id must be string");
|
|
34330
|
-
key =
|
|
34394
|
+
key = resolve17.normalizeId(key || id2);
|
|
34331
34395
|
checkUnique(this, key);
|
|
34332
34396
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
34333
34397
|
return this;
|
|
@@ -34371,7 +34435,7 @@ var require_ajv = __commonJS({
|
|
|
34371
34435
|
}
|
|
34372
34436
|
}
|
|
34373
34437
|
function _getSchemaFragment(self2, ref) {
|
|
34374
|
-
var res =
|
|
34438
|
+
var res = resolve17.schema.call(self2, { schema: {} }, ref);
|
|
34375
34439
|
if (res) {
|
|
34376
34440
|
var schema = res.schema, root = res.root, baseId = res.baseId;
|
|
34377
34441
|
var v = compileSchema.call(self2, schema, root, void 0, baseId);
|
|
@@ -34387,7 +34451,7 @@ var require_ajv = __commonJS({
|
|
|
34387
34451
|
}
|
|
34388
34452
|
}
|
|
34389
34453
|
function _getSchemaObj(self2, keyRef) {
|
|
34390
|
-
keyRef =
|
|
34454
|
+
keyRef = resolve17.normalizeId(keyRef);
|
|
34391
34455
|
return self2._schemas[keyRef] || self2._refs[keyRef] || self2._fragments[keyRef];
|
|
34392
34456
|
}
|
|
34393
34457
|
function removeSchema(schemaKeyRef) {
|
|
@@ -34414,7 +34478,7 @@ var require_ajv = __commonJS({
|
|
|
34414
34478
|
this._cache.del(cacheKey);
|
|
34415
34479
|
var id2 = this._getId(schemaKeyRef);
|
|
34416
34480
|
if (id2) {
|
|
34417
|
-
id2 =
|
|
34481
|
+
id2 = resolve17.normalizeId(id2);
|
|
34418
34482
|
delete this._schemas[id2];
|
|
34419
34483
|
delete this._refs[id2];
|
|
34420
34484
|
}
|
|
@@ -34438,13 +34502,13 @@ var require_ajv = __commonJS({
|
|
|
34438
34502
|
var cached2 = this._cache.get(cacheKey);
|
|
34439
34503
|
if (cached2) return cached2;
|
|
34440
34504
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
34441
|
-
var id2 =
|
|
34505
|
+
var id2 = resolve17.normalizeId(this._getId(schema));
|
|
34442
34506
|
if (id2 && shouldAddSchema) checkUnique(this, id2);
|
|
34443
34507
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
34444
34508
|
var recursiveMeta;
|
|
34445
|
-
if (willValidate && !(recursiveMeta = id2 && id2 ==
|
|
34509
|
+
if (willValidate && !(recursiveMeta = id2 && id2 == resolve17.normalizeId(schema.$schema)))
|
|
34446
34510
|
this.validateSchema(schema, true);
|
|
34447
|
-
var localRefs =
|
|
34511
|
+
var localRefs = resolve17.ids.call(this, schema);
|
|
34448
34512
|
var schemaObj = new SchemaObject({
|
|
34449
34513
|
id: id2,
|
|
34450
34514
|
schema,
|
|
@@ -34668,7 +34732,7 @@ async function logoutCodexSubscription(options) {
|
|
|
34668
34732
|
await session.close();
|
|
34669
34733
|
}
|
|
34670
34734
|
}
|
|
34671
|
-
var CODEX_INFERENCE_PERMISSION_PROFILE, CODEX_AGENT_PERMISSION_PROFILE, CODEX_REASONING_CONTENT_MAX_UTF8_BYTES, CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES, utf8Prefix, reasoningContentPrefix, HOST_RUNTIME_POLICY, CODEX_ACCOUNT_PLAN_TYPES, CODEX_AGENT_DYNAMIC_TOOLS, CodexAppServerError, objectOrNull, finiteToken, tokenUsageFromBreakdown, usageFromNotification, validPlanType, nonnegativeSafeIntegerOrNull, nonnegativeFiniteNumberOrNull, parseRateLimitWindow, RATE_LIMIT_REACHED_TYPES, DEFAULT_CODEX_QUOTA_COOLDOWN_MS, MAX_CODEX_QUOTA_COOLDOWN_MS, CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS, parseCreditsSnapshot, codexCreditsAvailable, parseRateLimitSnapshot, codexRateLimitRetryAtMs, codexAccountRateLimitReached, forbiddenMethod, forbiddenTerminalItem, forbiddenAgentMethod, forbiddenAgentTerminalItem, createCodexAgentToolSpecs, classifyCodexTurnFailure, scrubbedCodexEnvironment, killWindowsProcessTree, appServerArgs, GUARDIAN_SCRIPT, WINDOWS_RECEIPT_REPLACE_ERROR_CODES, MAX_RETIRED_RESPONSE_IDS, LATE_RESPONSE_SAFE_METHODS, replaceCodexGuardianReceiptFile, writeCodexGuardianSpawnIntent, parseGuardianReceipt, readCodexGuardianReceipt, waitForCodexGuardianState, defaultSpawn, CodexAppServerSession;
|
|
34735
|
+
var CODEX_INFERENCE_PERMISSION_PROFILE, CODEX_AGENT_PERMISSION_PROFILE, CODEX_REASONING_CONTENT_MAX_UTF8_BYTES, CODEX_REASONING_SUMMARY_MAX_UTF8_BYTES, utf8Prefix, reasoningContentPrefix, HOST_RUNTIME_POLICY, CODEX_ACCOUNT_PLAN_TYPES, CODEX_AGENT_DYNAMIC_TOOLS, CodexAppServerError, objectOrNull, finiteToken, tokenUsageFromBreakdown, usageFromNotification, validPlanType, nonnegativeSafeIntegerOrNull, nonnegativeFiniteNumberOrNull, parseRateLimitWindow, RATE_LIMIT_REACHED_TYPES, DEFAULT_CODEX_QUOTA_COOLDOWN_MS, MAX_CODEX_QUOTA_COOLDOWN_MS, CODEX_TRANSIENT_RATE_LIMIT_COOLDOWN_MS, parseCreditsSnapshot, parseCodexAccountRateLimits, codexCreditsAvailable, parseRateLimitSnapshot, codexRateLimitRetryAtMs, codexAccountRateLimitReached, forbiddenMethod, forbiddenTerminalItem, forbiddenAgentMethod, forbiddenAgentTerminalItem, createCodexAgentToolSpecs, classifyCodexTurnFailure, scrubbedCodexEnvironment, killWindowsProcessTree, appServerArgs, GUARDIAN_SCRIPT, WINDOWS_RECEIPT_REPLACE_ERROR_CODES, MAX_RETIRED_RESPONSE_IDS, LATE_RESPONSE_SAFE_METHODS, replaceCodexGuardianReceiptFile, writeCodexGuardianSpawnIntent, parseGuardianReceipt, readCodexGuardianReceipt, waitForCodexGuardianState, defaultSpawn, CodexAppServerSession;
|
|
34672
34736
|
var init_codex_app_server = __esm({
|
|
34673
34737
|
"lib/inference-host/codex-app-server.ts"() {
|
|
34674
34738
|
"use strict";
|
|
@@ -34808,6 +34872,23 @@ var init_codex_app_server = __esm({
|
|
|
34808
34872
|
balance: candidate.balance ?? null
|
|
34809
34873
|
};
|
|
34810
34874
|
};
|
|
34875
|
+
parseCodexAccountRateLimits = (value) => {
|
|
34876
|
+
const candidate = objectOrNull(value);
|
|
34877
|
+
if (!candidate) throw new Error("invalid account rate limits");
|
|
34878
|
+
const rateLimits = parseRateLimitSnapshot(candidate.rateLimits);
|
|
34879
|
+
const rawByLimitId = candidate.rateLimitsByLimitId;
|
|
34880
|
+
let rateLimitsByLimitId = null;
|
|
34881
|
+
if (rawByLimitId !== null && rawByLimitId !== void 0) {
|
|
34882
|
+
const byLimitId = objectOrNull(rawByLimitId);
|
|
34883
|
+
if (!byLimitId) throw new Error("invalid rate-limit bucket map");
|
|
34884
|
+
rateLimitsByLimitId = {};
|
|
34885
|
+
for (const [limitId, snapshot] of Object.entries(byLimitId)) {
|
|
34886
|
+
if (!limitId.trim()) throw new Error("invalid rate-limit bucket identity");
|
|
34887
|
+
rateLimitsByLimitId[limitId] = parseRateLimitSnapshot(snapshot);
|
|
34888
|
+
}
|
|
34889
|
+
}
|
|
34890
|
+
return { rateLimits, rateLimitsByLimitId };
|
|
34891
|
+
};
|
|
34811
34892
|
codexCreditsAvailable = (snapshot) => {
|
|
34812
34893
|
const credits = parseCreditsSnapshot(snapshot.credits);
|
|
34813
34894
|
return credits !== null && (credits.hasCredits || credits.unlimited);
|
|
@@ -35064,7 +35145,7 @@ var init_codex_app_server = __esm({
|
|
|
35064
35145
|
};
|
|
35065
35146
|
};
|
|
35066
35147
|
killWindowsProcessTree = async (pid) => {
|
|
35067
|
-
await new Promise((
|
|
35148
|
+
await new Promise((resolve17, reject) => {
|
|
35068
35149
|
const child = spawn4(
|
|
35069
35150
|
"taskkill.exe",
|
|
35070
35151
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -35089,7 +35170,7 @@ var init_codex_app_server = __esm({
|
|
|
35089
35170
|
});
|
|
35090
35171
|
child.once("close", (code) => {
|
|
35091
35172
|
clearTimeout(timer);
|
|
35092
|
-
if (code === 0 || code === WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE)
|
|
35173
|
+
if (code === 0 || code === WINDOWS_TASKKILL_PROCESS_NOT_FOUND_EXIT_CODE) resolve17();
|
|
35093
35174
|
else reject(new Error("Windows Codex process-tree cleanup failed."));
|
|
35094
35175
|
});
|
|
35095
35176
|
});
|
|
@@ -35289,7 +35370,7 @@ child.once('close', async (code, signal) => {
|
|
|
35289
35370
|
const platform = options.platform ?? process.platform;
|
|
35290
35371
|
const renameFile = options.renameFile ?? rename3;
|
|
35291
35372
|
const removeFile = options.removeFile ?? ((path) => rm4(path, { force: true }));
|
|
35292
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
35373
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => setTimeout(resolve17, milliseconds)));
|
|
35293
35374
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_attempts);
|
|
35294
35375
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_retry_ms);
|
|
35295
35376
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -35381,7 +35462,7 @@ child.once('close', async (code, signal) => {
|
|
|
35381
35462
|
throw new Error("Codex guardian terminated before app-server initialization.");
|
|
35382
35463
|
}
|
|
35383
35464
|
}
|
|
35384
|
-
await new Promise((
|
|
35465
|
+
await new Promise((resolve17) => setTimeout(resolve17, HOST_RUNTIME_POLICY.codex_guardian_state_poll_ms));
|
|
35385
35466
|
}
|
|
35386
35467
|
throw new Error(`Codex guardian ${expectedState} state was not confirmed.`);
|
|
35387
35468
|
};
|
|
@@ -35766,8 +35847,8 @@ child.once('close', async (code, signal) => {
|
|
|
35766
35847
|
dispatchOutcome: "not_dispatched"
|
|
35767
35848
|
});
|
|
35768
35849
|
}
|
|
35769
|
-
return await new Promise((
|
|
35770
|
-
const pending3 = { resolve:
|
|
35850
|
+
return await new Promise((resolve17, reject) => {
|
|
35851
|
+
const pending3 = { resolve: resolve17, reject, timer: null, abortCleanup: null };
|
|
35771
35852
|
pending3.timer = setTimeout(() => {
|
|
35772
35853
|
this.pending.delete(id2);
|
|
35773
35854
|
this.retireResponseId(id2, method);
|
|
@@ -35941,19 +36022,7 @@ child.once('close', async (code, signal) => {
|
|
|
35941
36022
|
signal
|
|
35942
36023
|
});
|
|
35943
36024
|
try {
|
|
35944
|
-
|
|
35945
|
-
const rawByLimitId = result.rateLimitsByLimitId;
|
|
35946
|
-
let rateLimitsByLimitId = null;
|
|
35947
|
-
if (rawByLimitId !== null && rawByLimitId !== void 0) {
|
|
35948
|
-
const byLimitId = objectOrNull(rawByLimitId);
|
|
35949
|
-
if (!byLimitId) throw new Error("invalid rate-limit bucket map");
|
|
35950
|
-
rateLimitsByLimitId = {};
|
|
35951
|
-
for (const [limitId, snapshot] of Object.entries(byLimitId)) {
|
|
35952
|
-
if (!limitId.trim()) throw new Error("invalid rate-limit bucket identity");
|
|
35953
|
-
rateLimitsByLimitId[limitId] = parseRateLimitSnapshot(snapshot);
|
|
35954
|
-
}
|
|
35955
|
-
}
|
|
35956
|
-
return { rateLimits, rateLimitsByLimitId };
|
|
36025
|
+
return parseCodexAccountRateLimits(result);
|
|
35957
36026
|
} catch (error48) {
|
|
35958
36027
|
throw new CodexAppServerError({
|
|
35959
36028
|
message: "Codex returned invalid account rate-limit metadata.",
|
|
@@ -36442,8 +36511,8 @@ child.once('close', async (code, signal) => {
|
|
|
36442
36511
|
const agentWebSearches = [];
|
|
36443
36512
|
let terminalResolve;
|
|
36444
36513
|
let terminalReject;
|
|
36445
|
-
const terminalPromise = new Promise((
|
|
36446
|
-
terminalResolve =
|
|
36514
|
+
const terminalPromise = new Promise((resolve17, reject) => {
|
|
36515
|
+
terminalResolve = resolve17;
|
|
36447
36516
|
terminalReject = reject;
|
|
36448
36517
|
});
|
|
36449
36518
|
void terminalPromise.catch(() => void 0);
|
|
@@ -37003,15 +37072,15 @@ child.once('close', async (code, signal) => {
|
|
|
37003
37072
|
).catch(() => void 0);
|
|
37004
37073
|
}
|
|
37005
37074
|
this.process.stdin.end();
|
|
37006
|
-
const exited = await new Promise((
|
|
37075
|
+
const exited = await new Promise((resolve17) => {
|
|
37007
37076
|
if (this.process.exitCode !== null) {
|
|
37008
|
-
|
|
37077
|
+
resolve17(true);
|
|
37009
37078
|
return;
|
|
37010
37079
|
}
|
|
37011
|
-
const timer = setTimeout(() =>
|
|
37080
|
+
const timer = setTimeout(() => resolve17(false), HOST_RUNTIME_POLICY.codex_close_exit_timeout_ms);
|
|
37012
37081
|
this.process.once("close", () => {
|
|
37013
37082
|
clearTimeout(timer);
|
|
37014
|
-
|
|
37083
|
+
resolve17(true);
|
|
37015
37084
|
});
|
|
37016
37085
|
});
|
|
37017
37086
|
if (exited) return;
|
|
@@ -37022,11 +37091,11 @@ child.once('close', async (code, signal) => {
|
|
|
37022
37091
|
else this.process.kill("SIGTERM");
|
|
37023
37092
|
} catch {
|
|
37024
37093
|
}
|
|
37025
|
-
const terminated = await new Promise((
|
|
37026
|
-
const timer = setTimeout(() =>
|
|
37094
|
+
const terminated = await new Promise((resolve17) => {
|
|
37095
|
+
const timer = setTimeout(() => resolve17(false), HOST_RUNTIME_POLICY.codex_close_terminate_timeout_ms);
|
|
37027
37096
|
this.process.once("close", () => {
|
|
37028
37097
|
clearTimeout(timer);
|
|
37029
|
-
|
|
37098
|
+
resolve17(true);
|
|
37030
37099
|
});
|
|
37031
37100
|
});
|
|
37032
37101
|
if (!terminated) {
|
|
@@ -37036,15 +37105,15 @@ child.once('close', async (code, signal) => {
|
|
|
37036
37105
|
else this.process.kill("SIGKILL");
|
|
37037
37106
|
} catch {
|
|
37038
37107
|
}
|
|
37039
|
-
await new Promise((
|
|
37108
|
+
await new Promise((resolve17) => {
|
|
37040
37109
|
if (this.process.exitCode !== null) {
|
|
37041
|
-
|
|
37110
|
+
resolve17();
|
|
37042
37111
|
return;
|
|
37043
37112
|
}
|
|
37044
|
-
const timer = setTimeout(
|
|
37113
|
+
const timer = setTimeout(resolve17, HOST_RUNTIME_POLICY.codex_close_kill_timeout_ms);
|
|
37045
37114
|
this.process.once("close", () => {
|
|
37046
37115
|
clearTimeout(timer);
|
|
37047
|
-
|
|
37116
|
+
resolve17();
|
|
37048
37117
|
});
|
|
37049
37118
|
});
|
|
37050
37119
|
if (this.process.exitCode === null) {
|
|
@@ -37602,6 +37671,239 @@ var init_provider_credit = __esm({
|
|
|
37602
37671
|
}
|
|
37603
37672
|
});
|
|
37604
37673
|
|
|
37674
|
+
// lib/inference-host/attempt-failure.ts
|
|
37675
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
37676
|
+
import { dirname as dirname5, isAbsolute as isAbsolute5, relative as relative3, resolve as resolve4, sep as sep2 } from "node:path";
|
|
37677
|
+
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;
|
|
37678
|
+
var init_attempt_failure = __esm({
|
|
37679
|
+
"lib/inference-host/attempt-failure.ts"() {
|
|
37680
|
+
"use strict";
|
|
37681
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
37682
|
+
init_define_VTX_EXO_POLICY();
|
|
37683
|
+
init_define_VTX_GROK_POLICY();
|
|
37684
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
37685
|
+
init_runtime_policy_generated();
|
|
37686
|
+
init_constants();
|
|
37687
|
+
init_external_inference_contract();
|
|
37688
|
+
init_provider_credit();
|
|
37689
|
+
init_codex_app_server();
|
|
37690
|
+
init_mcp_client();
|
|
37691
|
+
providerHttpStatus = (error48) => {
|
|
37692
|
+
if (!(error48 instanceof CodexAppServerError)) return null;
|
|
37693
|
+
const status = error48.httpStatusCode;
|
|
37694
|
+
return typeof status === "number" && Number.isInteger(status) && status >= HTTP_CLIENT_ERROR_MIN && status <= HTTP_STATUS_MAX ? status : null;
|
|
37695
|
+
};
|
|
37696
|
+
PROVIDER_COOLDOWN_FAILURE_CODES = ["quota_exceeded", "codex_rate_limited", "provider_rate_limited"];
|
|
37697
|
+
isProviderCooldownFailureCode = (code) => PROVIDER_COOLDOWN_FAILURE_CODES.includes(code);
|
|
37698
|
+
isProviderAccountFailureCode = (code) => isProviderCooldownFailureCode(code) || code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE;
|
|
37699
|
+
terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null || error48.grokResponseIdentity != null) && !error48.retryable && error48.category !== "auth" && !isProviderAccountFailureCode(error48.code);
|
|
37700
|
+
ambiguousHeartbeatTransport = (error48) => {
|
|
37701
|
+
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "";
|
|
37702
|
+
return [
|
|
37703
|
+
"network_error",
|
|
37704
|
+
"transport_rejected",
|
|
37705
|
+
"server_rejected",
|
|
37706
|
+
"rate_limited",
|
|
37707
|
+
"invalid_response",
|
|
37708
|
+
"identity_mismatch",
|
|
37709
|
+
"request_timeout",
|
|
37710
|
+
"authentication_timeout"
|
|
37711
|
+
].includes(code);
|
|
37712
|
+
};
|
|
37713
|
+
retryableRemoteError = (error48) => {
|
|
37714
|
+
if (error48 instanceof ExternalInferenceMcpError) {
|
|
37715
|
+
return error48.retryable;
|
|
37716
|
+
}
|
|
37717
|
+
if (error48 && typeof error48 === "object" && "retryable" in error48) {
|
|
37718
|
+
return error48.retryable === true;
|
|
37719
|
+
}
|
|
37720
|
+
return false;
|
|
37721
|
+
};
|
|
37722
|
+
membershipFailureDisposition = (failure2) => {
|
|
37723
|
+
if (failure2.dispatchOutcome === "outcome_unknown") return "quarantine_ambiguous";
|
|
37724
|
+
if (failure2.category === "auth" || ["auth_expired", "managed_chatgpt_auth_required", "invalid_account_metadata"].includes(failure2.code)) return "cascade_disable";
|
|
37725
|
+
if (failure2.category === "quota" || isProviderAccountFailureCode(failure2.code)) return "cascade_cooldown";
|
|
37726
|
+
if (failure2.code === "codex_server_overloaded") return "cascade_cooldown";
|
|
37727
|
+
if (failure2.retryable && (["adapter", "network", "transport"].includes(failure2.category) || failure2.code === "rpc_timeout")) return "retry_same_host";
|
|
37728
|
+
if (["model_unavailable", "reasoning_effort_unavailable"].includes(failure2.code)) return "cascade_cooldown";
|
|
37729
|
+
if ([
|
|
37730
|
+
"codex_http_connection_failed",
|
|
37731
|
+
"codex_response_stream_connection_failed",
|
|
37732
|
+
"codex_response_stream_disconnected",
|
|
37733
|
+
"codex_provider_retry_exhausted"
|
|
37734
|
+
].includes(failure2.code)) return "cascade_cooldown";
|
|
37735
|
+
return "fail_request";
|
|
37736
|
+
};
|
|
37737
|
+
safeFailureCode = (value, fallback) => {
|
|
37738
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/gu, "_").slice(0, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.long_code_length);
|
|
37739
|
+
return /^[a-z0-9]/u.test(normalized) ? normalized : fallback;
|
|
37740
|
+
};
|
|
37741
|
+
classifyFailure = (error48, result) => {
|
|
37742
|
+
if (error48 instanceof CodexAppServerError) {
|
|
37743
|
+
const category2 = error48.code === "quota_exceeded" || error48.code === PROVIDER_OUT_OF_CREDIT_FAILURE_CODE ? "quota" : error48.category;
|
|
37744
|
+
return {
|
|
37745
|
+
category: safeFailureCode(category2, "adapter"),
|
|
37746
|
+
code: safeFailureCode(error48.code, "adapter_failure"),
|
|
37747
|
+
retryable: error48.retryable,
|
|
37748
|
+
dispatchOutcome: error48.dispatchOutcome,
|
|
37749
|
+
effectiveModel: result?.effectiveModel ?? null,
|
|
37750
|
+
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
37751
|
+
};
|
|
37752
|
+
}
|
|
37753
|
+
if (error48 instanceof ExternalInferenceMcpError) {
|
|
37754
|
+
const category2 = error48.code.startsWith("authentication") ? "auth" : [
|
|
37755
|
+
"network_error",
|
|
37756
|
+
"transport_rejected",
|
|
37757
|
+
"server_rejected",
|
|
37758
|
+
"rate_limited",
|
|
37759
|
+
"request_timeout"
|
|
37760
|
+
].includes(error48.code) ? "network" : "transport";
|
|
37761
|
+
return {
|
|
37762
|
+
category: category2,
|
|
37763
|
+
code: safeFailureCode(error48.code, "transport_failure"),
|
|
37764
|
+
retryable: retryableRemoteError(error48),
|
|
37765
|
+
dispatchOutcome: "not_dispatched",
|
|
37766
|
+
effectiveModel: null,
|
|
37767
|
+
effectiveEffort: null
|
|
37768
|
+
};
|
|
37769
|
+
}
|
|
37770
|
+
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "adapter_failure";
|
|
37771
|
+
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";
|
|
37772
|
+
return {
|
|
37773
|
+
category,
|
|
37774
|
+
code: safeFailureCode(code, "adapter_failure"),
|
|
37775
|
+
retryable: error48 && typeof error48 === "object" && "retryable" in error48 ? error48.retryable === true : false,
|
|
37776
|
+
dispatchOutcome: result ? "confirmed_dispatched" : "not_dispatched",
|
|
37777
|
+
effectiveModel: result?.effectiveModel ?? null,
|
|
37778
|
+
effectiveEffort: result?.effectiveReasoningEffort ?? null
|
|
37779
|
+
};
|
|
37780
|
+
};
|
|
37781
|
+
ERROR_CLASS_PATTERN = /^[A-Za-z][A-Za-z0-9_]*$/u;
|
|
37782
|
+
ERRNO_CODE_PATTERN = /^[A-Z][A-Z0-9_]*$/u;
|
|
37783
|
+
SYSCALL_PATTERN = /^[a-z][a-z0-9_]*$/u;
|
|
37784
|
+
failureFolderRole = (path, syscall) => {
|
|
37785
|
+
const scoped = relative3(resolve4(tmpdir2()), resolve4(syscall === "mkdtemp" ? dirname5(path) : path));
|
|
37786
|
+
if (scoped === "") return "temp_root";
|
|
37787
|
+
if (scoped === ".." || scoped.startsWith(`..${sep2}`) || isAbsolute5(scoped)) return "other";
|
|
37788
|
+
const parts = scoped.split(sep2);
|
|
37789
|
+
const [top = "", jobs, job = ""] = parts;
|
|
37790
|
+
if (top.startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_PREFIX)) {
|
|
37791
|
+
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";
|
|
37792
|
+
}
|
|
37793
|
+
return [
|
|
37794
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX,
|
|
37795
|
+
INFERENCE_HOST_TEMP_FOLDERS.COPILOT_JOB_PREFIX,
|
|
37796
|
+
INFERENCE_HOST_TEMP_FOLDERS.DEEPSEEK_JOB_PREFIX
|
|
37797
|
+
].some((prefix) => top.startsWith(prefix)) ? "job_folder" : "other";
|
|
37798
|
+
};
|
|
37799
|
+
boundedToken = (value, pattern, maxLength) => typeof value === "string" && value.length <= maxLength && pattern.test(value) ? value : null;
|
|
37800
|
+
isUnclassifiedFailureCode = (code) => typeof code === "string" && (code === "adapter_failure" || code.endsWith("_adapter_failure"));
|
|
37801
|
+
attemptFailureDetail = (error48) => {
|
|
37802
|
+
if (error48 instanceof ExternalInferenceMcpError) return null;
|
|
37803
|
+
if (error48 instanceof CodexAppServerError ? !isUnclassifiedFailureCode(error48.code) : error48 !== null && typeof error48 === "object" && typeof error48.code === "string" && /^[a-z]/u.test(error48.code)) return null;
|
|
37804
|
+
let cause = error48;
|
|
37805
|
+
const seen = /* @__PURE__ */ new Set([cause]);
|
|
37806
|
+
for (let depth = 0; depth < INFERENCE_HOST_FAILURE_CAUSE_MAX_DEPTH; depth += 1) {
|
|
37807
|
+
const next = cause instanceof Error ? cause.cause : void 0;
|
|
37808
|
+
if (next === void 0 || next === null || seen.has(next)) break;
|
|
37809
|
+
seen.add(next);
|
|
37810
|
+
cause = next;
|
|
37811
|
+
}
|
|
37812
|
+
if (cause instanceof CodexAppServerError || cause instanceof ExternalInferenceMcpError) return null;
|
|
37813
|
+
const record6 = cause !== null && typeof cause === "object" ? cause : {};
|
|
37814
|
+
const syscall = boundedToken(record6.syscall, SYSCALL_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.label_length);
|
|
37815
|
+
const parsed = externalInferenceFailureDetailSchema.safeParse({
|
|
37816
|
+
schema_version: "external_inference_failure_detail_v1",
|
|
37817
|
+
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",
|
|
37818
|
+
errno_code: boundedToken(record6.code, ERRNO_CODE_PATTERN, EXTERNAL_INFERENCE_SCHEMA_BOUNDS.code_length),
|
|
37819
|
+
syscall,
|
|
37820
|
+
folder_role: typeof record6.path === "string" ? failureFolderRole(record6.path, syscall) : null
|
|
37821
|
+
});
|
|
37822
|
+
if (!parsed.success) return null;
|
|
37823
|
+
const { error_class: errorClass, errno_code: errnoCode, folder_role: folderRole } = parsed.data;
|
|
37824
|
+
return errorClass === "Error" && errnoCode === null && syscall === null && folderRole === null ? null : parsed.data;
|
|
37825
|
+
};
|
|
37826
|
+
ADAPTER_SETUP_FAILED_DRAIN_REASON = "adapter_setup_failed";
|
|
37827
|
+
createUndispatchedAdapterFailureStreak = (threshold2 = runtime_policy_generated_default.external_inference.host_runtime.undispatched_adapter_failure_restart_threshold) => {
|
|
37828
|
+
let count5 = 0;
|
|
37829
|
+
return {
|
|
37830
|
+
/** Records one finished attempt; true once the run reaches the threshold. */
|
|
37831
|
+
observe: (outcome) => {
|
|
37832
|
+
if (outcome.outcome === "completed" || typeof outcome.dispatch_outcome === "string" && outcome.dispatch_outcome !== "not_dispatched") {
|
|
37833
|
+
count5 = 0;
|
|
37834
|
+
return false;
|
|
37835
|
+
}
|
|
37836
|
+
if (outcome.outcome !== "failed" || outcome.failure_category !== "adapter" || !(isUnclassifiedFailureCode(outcome.failure_code) || (outcome.failure_detail ?? null) !== null)) return false;
|
|
37837
|
+
count5 += 1;
|
|
37838
|
+
return count5 >= threshold2;
|
|
37839
|
+
},
|
|
37840
|
+
count: () => count5
|
|
37841
|
+
};
|
|
37842
|
+
};
|
|
37843
|
+
}
|
|
37844
|
+
});
|
|
37845
|
+
|
|
37846
|
+
// lib/inference-host/claim-answer.ts
|
|
37847
|
+
var claimDeferral, quotaRecoveryMayLiftRefusal, createClaimDeferralLog, recordClaimFailure;
|
|
37848
|
+
var init_claim_answer = __esm({
|
|
37849
|
+
"lib/inference-host/claim-answer.ts"() {
|
|
37850
|
+
"use strict";
|
|
37851
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
37852
|
+
init_define_VTX_EXO_POLICY();
|
|
37853
|
+
init_define_VTX_GROK_POLICY();
|
|
37854
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
37855
|
+
init_mcp_client();
|
|
37856
|
+
claimDeferral = (error48, staleReplay) => {
|
|
37857
|
+
if (!(error48 instanceof ExternalInferenceMcpError)) return null;
|
|
37858
|
+
if (error48.serverFailureCode === "host_not_claimable" && error48.retryable) {
|
|
37859
|
+
return { reason: error48.serverReasonCode ?? error48.serverFailureCode, retry_after_ms: error48.retryAfterMs };
|
|
37860
|
+
}
|
|
37861
|
+
if (error48.definitivelyNotApplied && staleReplay && error48.code === "tool_rejected") {
|
|
37862
|
+
return { reason: error48.serverReasonCode ?? error48.serverFailureCode ?? error48.code, retry_after_ms: null };
|
|
37863
|
+
}
|
|
37864
|
+
return null;
|
|
37865
|
+
};
|
|
37866
|
+
quotaRecoveryMayLiftRefusal = (error48) => !(error48 instanceof ExternalInferenceMcpError && error48.serverReasonCode === "provider_cooldown_fixed");
|
|
37867
|
+
createClaimDeferralLog = () => {
|
|
37868
|
+
const last = /* @__PURE__ */ new Map();
|
|
37869
|
+
return {
|
|
37870
|
+
changed: (deferral) => {
|
|
37871
|
+
if (last.has(deferral.reason) && last.get(deferral.reason) === deferral.retry_after_ms) return false;
|
|
37872
|
+
last.set(deferral.reason, deferral.retry_after_ms);
|
|
37873
|
+
return true;
|
|
37874
|
+
},
|
|
37875
|
+
/** A claim the server served (or found nothing for) ends every deferral. */
|
|
37876
|
+
reset: () => {
|
|
37877
|
+
last.clear();
|
|
37878
|
+
}
|
|
37879
|
+
};
|
|
37880
|
+
};
|
|
37881
|
+
recordClaimFailure = (claimFailures, failure2) => {
|
|
37882
|
+
const open4 = claimFailures.find((record6) => record6.resolution === void 0 && record6.claim_request_id === failure2.claimRequestId);
|
|
37883
|
+
const responseBodyBytes = failure2.timing?.response_body_bytes ?? null;
|
|
37884
|
+
const bodyCut = failure2.failureCode === "network_error" && (responseBodyBytes ?? 0) > 0;
|
|
37885
|
+
if (open4) {
|
|
37886
|
+
open4.attempts = Math.min(Number.MAX_SAFE_INTEGER, open4.attempts + 1);
|
|
37887
|
+
if (bodyCut) open4.body_cut = true;
|
|
37888
|
+
if (responseBodyBytes !== null) {
|
|
37889
|
+
open4.response_body_bytes = Math.max(open4.response_body_bytes ?? 0, responseBodyBytes);
|
|
37890
|
+
}
|
|
37891
|
+
return false;
|
|
37892
|
+
}
|
|
37893
|
+
claimFailures.push({
|
|
37894
|
+
claim_request_id: failure2.claimRequestId,
|
|
37895
|
+
failed_at: failure2.failedAt,
|
|
37896
|
+
failure_code: failure2.failureCode,
|
|
37897
|
+
http_status_code: failure2.httpStatusCode,
|
|
37898
|
+
response_body_bytes: responseBodyBytes,
|
|
37899
|
+
body_cut: bodyCut,
|
|
37900
|
+
attempts: 1
|
|
37901
|
+
});
|
|
37902
|
+
return true;
|
|
37903
|
+
};
|
|
37904
|
+
}
|
|
37905
|
+
});
|
|
37906
|
+
|
|
37605
37907
|
// lib/inference-host/runner.ts
|
|
37606
37908
|
import { createHash as createHash5, randomUUID as randomUUID2 } from "node:crypto";
|
|
37607
37909
|
function createDefaultInferenceHostRunnerDependencies(options) {
|
|
@@ -37639,7 +37941,7 @@ function createDefaultInferenceHostRunnerDependencies(options) {
|
|
|
37639
37941
|
envelopePublicKey: options.envelopePublicKey
|
|
37640
37942
|
};
|
|
37641
37943
|
}
|
|
37642
|
-
var import_ajv,
|
|
37944
|
+
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
37945
|
var init_runner = __esm({
|
|
37644
37946
|
"lib/inference-host/runner.ts"() {
|
|
37645
37947
|
"use strict";
|
|
@@ -37660,16 +37962,8 @@ var init_runner = __esm({
|
|
|
37660
37962
|
init_agent_answer();
|
|
37661
37963
|
init_config2();
|
|
37662
37964
|
init_oauth();
|
|
37663
|
-
|
|
37664
|
-
|
|
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);
|
|
37965
|
+
init_attempt_failure();
|
|
37966
|
+
init_claim_answer();
|
|
37673
37967
|
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
37968
|
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
37969
|
RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
|
|
@@ -37808,13 +38102,13 @@ var init_runner = __esm({
|
|
|
37808
38102
|
};
|
|
37809
38103
|
defaultSleep = async (milliseconds, signal) => {
|
|
37810
38104
|
if (signal?.aborted) throw abortError();
|
|
37811
|
-
await new Promise((
|
|
38105
|
+
await new Promise((resolve17, reject) => {
|
|
37812
38106
|
const finish = (callback) => {
|
|
37813
38107
|
signal?.removeEventListener("abort", onAbort);
|
|
37814
38108
|
callback();
|
|
37815
38109
|
};
|
|
37816
38110
|
const timer = setTimeout(
|
|
37817
|
-
() => finish(
|
|
38111
|
+
() => finish(resolve17),
|
|
37818
38112
|
Math.max(MIN_SLEEP_MS, milliseconds)
|
|
37819
38113
|
);
|
|
37820
38114
|
const onAbort = () => {
|
|
@@ -37840,9 +38134,9 @@ var init_runner = __esm({
|
|
|
37840
38134
|
let timer = null;
|
|
37841
38135
|
const settled2 = await Promise.race([
|
|
37842
38136
|
promise2.then(() => true, () => true),
|
|
37843
|
-
new Promise((
|
|
38137
|
+
new Promise((resolve17) => {
|
|
37844
38138
|
timer = setTimeout(
|
|
37845
|
-
() =>
|
|
38139
|
+
() => resolve17(false),
|
|
37846
38140
|
Math.max(MIN_SLEEP_MS, timeoutMs)
|
|
37847
38141
|
);
|
|
37848
38142
|
})
|
|
@@ -38107,15 +38401,6 @@ var init_runner = __esm({
|
|
|
38107
38401
|
);
|
|
38108
38402
|
}
|
|
38109
38403
|
};
|
|
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
38404
|
remoteRetryAfterMs = (error48, fallbackMs) => error48 instanceof ExternalInferenceMcpError && error48.retryAfterMs !== null && Number.isSafeInteger(error48.retryAfterMs) && error48.retryAfterMs >= 0 ? Math.max(fallbackMs, error48.retryAfterMs) : fallbackMs;
|
|
38120
38405
|
controlPlaneFatal = (error48) => {
|
|
38121
38406
|
const code = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "";
|
|
@@ -38271,25 +38556,6 @@ var init_runner = __esm({
|
|
|
38271
38556
|
}
|
|
38272
38557
|
return notAfterMs;
|
|
38273
38558
|
};
|
|
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
38559
|
publicServerFailureCode = (value) => value !== null && /^[a-z0-9][a-z0-9._-]{0,95}$/u.test(value) ? value : null;
|
|
38294
38560
|
attemptStartRetryFallbackMs = (retryCount) => Math.min(
|
|
38295
38561
|
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 +38599,6 @@ var init_runner = __esm({
|
|
|
38333
38599
|
}
|
|
38334
38600
|
};
|
|
38335
38601
|
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
38602
|
reportedTokenUsage = (usage, source = "codex_app_server") => ({
|
|
38390
38603
|
schema_version: EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION,
|
|
38391
38604
|
availability: "reported",
|
|
@@ -38420,15 +38633,25 @@ var init_runner = __esm({
|
|
|
38420
38633
|
let removeQuiesceListener = () => {
|
|
38421
38634
|
};
|
|
38422
38635
|
let quiesceRequested = Boolean(this.options.quiesceSignal?.aborted);
|
|
38636
|
+
let quiesceDrainReason = "service_update";
|
|
38423
38637
|
let wakeQuiesce;
|
|
38424
|
-
const quiesceWake = new Promise((
|
|
38425
|
-
wakeQuiesce =
|
|
38426
|
-
});
|
|
38638
|
+
const quiesceWake = new Promise((resolve17) => {
|
|
38639
|
+
wakeQuiesce = resolve17;
|
|
38640
|
+
});
|
|
38641
|
+
const quiesceAbort = new AbortController();
|
|
38642
|
+
const requestQuiesce = (reason) => {
|
|
38643
|
+
if (quiesceRequested) return;
|
|
38644
|
+
quiesceDrainReason = reason;
|
|
38645
|
+
quiesceRequested = true;
|
|
38646
|
+
quiesceAbort.abort();
|
|
38647
|
+
wakeQuiesce();
|
|
38648
|
+
};
|
|
38427
38649
|
let drainRequested = false;
|
|
38428
38650
|
let drainReason = "stopped";
|
|
38429
38651
|
let terminalRecoveryFailureCode = null;
|
|
38430
38652
|
let acknowledgedRecoveryDiagnostic = null;
|
|
38431
38653
|
const claimFailures = [];
|
|
38654
|
+
const claimDeferralLog = createClaimDeferralLog();
|
|
38432
38655
|
let claimFailuresDropped = 0;
|
|
38433
38656
|
const boundClaimFailures = () => {
|
|
38434
38657
|
while (claimFailures.length > EXTERNAL_INFERENCE_LIMITS.max_heartbeat_claim_failures) {
|
|
@@ -38458,13 +38681,14 @@ var init_runner = __esm({
|
|
|
38458
38681
|
};
|
|
38459
38682
|
let hostHeartbeatLoop = Promise.resolve();
|
|
38460
38683
|
let providerDispatchWatchdogDrainRequested = false;
|
|
38684
|
+
const adapterFailureStreak = createUndispatchedAdapterFailureStreak();
|
|
38461
38685
|
const agentAbort = new AbortController();
|
|
38462
38686
|
let agentLoop = Promise.resolve();
|
|
38463
38687
|
let modelCatalogRefresh = null;
|
|
38464
38688
|
let providerRateLimitRefresh = null;
|
|
38465
38689
|
let wakeDrain;
|
|
38466
|
-
const drainSignal = new Promise((
|
|
38467
|
-
wakeDrain =
|
|
38690
|
+
const drainSignal = new Promise((resolve17) => {
|
|
38691
|
+
wakeDrain = resolve17;
|
|
38468
38692
|
});
|
|
38469
38693
|
const requestDrain = (reason) => {
|
|
38470
38694
|
const priority = (value) => {
|
|
@@ -38482,10 +38706,7 @@ var init_runner = __esm({
|
|
|
38482
38706
|
wakeDrain();
|
|
38483
38707
|
};
|
|
38484
38708
|
try {
|
|
38485
|
-
const onQuiesce = () =>
|
|
38486
|
-
quiesceRequested = true;
|
|
38487
|
-
wakeQuiesce();
|
|
38488
|
-
};
|
|
38709
|
+
const onQuiesce = () => requestQuiesce("service_update");
|
|
38489
38710
|
this.options.quiesceSignal?.addEventListener("abort", onQuiesce, { once: true });
|
|
38490
38711
|
removeQuiesceListener = () => this.options.quiesceSignal?.removeEventListener("abort", onQuiesce);
|
|
38491
38712
|
if (quiesceRequested) return { claimed, completed, failed: failed2, drain_reason: "service_update" };
|
|
@@ -38592,7 +38813,7 @@ var init_runner = __esm({
|
|
|
38592
38813
|
await mcp.initialize({ signal: this.options.signal });
|
|
38593
38814
|
if (settings.agentRuntime) {
|
|
38594
38815
|
const agentRuntimeSettings = settings.agentRuntime;
|
|
38595
|
-
const agentIdleSignal =
|
|
38816
|
+
const agentIdleSignal = AbortSignal.any([agentAbort.signal, quiesceAbort.signal]);
|
|
38596
38817
|
agentLoop = (async () => {
|
|
38597
38818
|
while (!agentAbort.signal.aborted && !quiesceRequested) {
|
|
38598
38819
|
const existingFence = await readInferenceAgentFailureFence(
|
|
@@ -38643,7 +38864,7 @@ var init_runner = __esm({
|
|
|
38643
38864
|
controlClient: createInferenceAgentControlClient(mcp),
|
|
38644
38865
|
adapter: agentRuntimeSettings.adapter,
|
|
38645
38866
|
dataRequestTimeoutMs: agentRuntimeSettings.dataRequestTimeoutMs,
|
|
38646
|
-
quiesceSignal:
|
|
38867
|
+
quiesceSignal: quiesceAbort.signal
|
|
38647
38868
|
});
|
|
38648
38869
|
try {
|
|
38649
38870
|
if (this.options.once) {
|
|
@@ -38839,8 +39060,8 @@ var init_runner = __esm({
|
|
|
38839
39060
|
receipt = result;
|
|
38840
39061
|
const revision = receiptRevision + 1;
|
|
38841
39062
|
receiptRevision = revision;
|
|
38842
|
-
const durable = new Promise((
|
|
38843
|
-
receiptDurabilityWaiters.push({ revision, resolve:
|
|
39063
|
+
const durable = new Promise((resolve17, reject) => {
|
|
39064
|
+
receiptDurabilityWaiters.push({ revision, resolve: resolve17, reject });
|
|
38844
39065
|
});
|
|
38845
39066
|
scheduleReceiptWriter();
|
|
38846
39067
|
await durable;
|
|
@@ -38956,8 +39177,8 @@ var init_runner = __esm({
|
|
|
38956
39177
|
const tool = receipt.registered ? "inference.host.advertise" : "inference.host.register";
|
|
38957
39178
|
let result;
|
|
38958
39179
|
let releaseAdvertisementHandoff;
|
|
38959
|
-
const currentAdvertisementHandoff = new Promise((
|
|
38960
|
-
releaseAdvertisementHandoff =
|
|
39180
|
+
const currentAdvertisementHandoff = new Promise((resolve17) => {
|
|
39181
|
+
releaseAdvertisementHandoff = resolve17;
|
|
38961
39182
|
});
|
|
38962
39183
|
advertisementHandoff = currentAdvertisementHandoff;
|
|
38963
39184
|
try {
|
|
@@ -39139,7 +39360,7 @@ var init_runner = __esm({
|
|
|
39139
39360
|
);
|
|
39140
39361
|
throw error48;
|
|
39141
39362
|
}
|
|
39142
|
-
if (claimAvailabilityBackoff
|
|
39363
|
+
if (claimAvailabilityBackoff?.liftable === true && result.host.status === "online" && request.provider_quota_recovery != null && Date.parse(request.provider_quota_recovery.observed_at) >= claimAvailabilityBackoff.rejectedAtMs) {
|
|
39143
39364
|
claimAvailabilityBackoff = null;
|
|
39144
39365
|
}
|
|
39145
39366
|
};
|
|
@@ -39504,6 +39725,14 @@ var init_runner = __esm({
|
|
|
39504
39725
|
attempt_id: attemptId,
|
|
39505
39726
|
active_attempts: active.size
|
|
39506
39727
|
});
|
|
39728
|
+
if (!adapterFailureStreak.observe(outcome) || quiesceRequested) return;
|
|
39729
|
+
emitDiagnostic("worker_restart_requested", {
|
|
39730
|
+
reason: ADAPTER_SETUP_FAILED_DRAIN_REASON,
|
|
39731
|
+
consecutive_failures: adapterFailureStreak.count(),
|
|
39732
|
+
failure_code: outcome.failure_code,
|
|
39733
|
+
failure_detail: outcome.failure_detail ?? null
|
|
39734
|
+
});
|
|
39735
|
+
requestQuiesce(ADAPTER_SETUP_FAILED_DRAIN_REASON);
|
|
39507
39736
|
},
|
|
39508
39737
|
onProviderDispatch: (observation) => {
|
|
39509
39738
|
emitDiagnostic("provider_dispatch_freshness_passed", {
|
|
@@ -39839,6 +40068,7 @@ var init_runner = __esm({
|
|
|
39839
40068
|
}
|
|
39840
40069
|
);
|
|
39841
40070
|
assertClaimResult(request, claim);
|
|
40071
|
+
claimDeferralLog.reset();
|
|
39842
40072
|
resolveClaimFailures(
|
|
39843
40073
|
"replayed",
|
|
39844
40074
|
(record6) => record6.claim_request_id === request.claim_request_id
|
|
@@ -39849,35 +40079,25 @@ var init_runner = __esm({
|
|
|
39849
40079
|
"claim_failed"
|
|
39850
40080
|
);
|
|
39851
40081
|
const httpStatusCode = error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null;
|
|
39852
|
-
|
|
39853
|
-
|
|
39854
|
-
|
|
39855
|
-
|
|
39856
|
-
|
|
39857
|
-
|
|
39858
|
-
|
|
39859
|
-
|
|
39860
|
-
|
|
39861
|
-
|
|
39862
|
-
|
|
39863
|
-
open4.attempts = Math.min(Number.MAX_SAFE_INTEGER, open4.attempts + 1);
|
|
39864
|
-
if (bodyCut) open4.body_cut = true;
|
|
39865
|
-
if (responseBodyBytes !== null) {
|
|
39866
|
-
open4.response_body_bytes = Math.max(open4.response_body_bytes ?? 0, responseBodyBytes);
|
|
39867
|
-
}
|
|
39868
|
-
} else {
|
|
39869
|
-
claimFailures.push({
|
|
39870
|
-
claim_request_id: request.claim_request_id,
|
|
39871
|
-
failed_at: isoAt(claimCallStartedAtMs),
|
|
39872
|
-
failure_code: failureCode,
|
|
39873
|
-
http_status_code: httpStatusCode,
|
|
39874
|
-
response_body_bytes: responseBodyBytes,
|
|
39875
|
-
body_cut: bodyCut,
|
|
39876
|
-
attempts: 1
|
|
39877
|
-
});
|
|
39878
|
-
boundClaimFailures();
|
|
39879
|
-
}
|
|
40082
|
+
const deferral = claimDeferral(error48, request.advertisement_generation < receipt.advertisement_generation);
|
|
40083
|
+
if (deferral && claimDeferralLog.changed(deferral)) {
|
|
40084
|
+
emitDiagnostic("claim_deferred", { claim_request_id: request.claim_request_id, ...deferral });
|
|
40085
|
+
} else if (!deferral && claimTiming) {
|
|
40086
|
+
emitDiagnostic("claim_request_failed", {
|
|
40087
|
+
claim_request_id: request.claim_request_id,
|
|
40088
|
+
failure_code: failureCode,
|
|
40089
|
+
http_status_code: httpStatusCode,
|
|
40090
|
+
server_failure_code: error48 instanceof ExternalInferenceMcpError ? error48.serverFailureCode : null,
|
|
40091
|
+
client_timing: claimTiming
|
|
40092
|
+
});
|
|
39880
40093
|
}
|
|
40094
|
+
if (!deferral && !this.options.signal?.aborted && recordClaimFailure(claimFailures, {
|
|
40095
|
+
claimRequestId: request.claim_request_id,
|
|
40096
|
+
failedAt: isoAt(claimCallStartedAtMs),
|
|
40097
|
+
failureCode,
|
|
40098
|
+
httpStatusCode,
|
|
40099
|
+
timing: claimTiming
|
|
40100
|
+
})) boundClaimFailures();
|
|
39881
40101
|
if (!this.options.signal?.aborted && request.schema_version === "external_inference_job_claim_v4" && error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "schema_validation") {
|
|
39882
40102
|
batchClaimVersion = INFERENCE_JOB_CLAIM_SCHEMA_VERSION.V3;
|
|
39883
40103
|
await mutateReceipt((current) => ({
|
|
@@ -39969,7 +40189,7 @@ var init_runner = __esm({
|
|
|
39969
40189
|
const rejectedAtMs = now();
|
|
39970
40190
|
const retryAtMs = rejectedAtMs + remoteRetryAfterMs(error48, HOST_RUNTIME_POLICY2.remote_retry_fallback_ms);
|
|
39971
40191
|
if (error48 instanceof ExternalInferenceMcpError && error48.serverFailureCode === "host_not_claimable") {
|
|
39972
|
-
claimAvailabilityBackoff = { untilMs: retryAtMs, rejectedAtMs };
|
|
40192
|
+
claimAvailabilityBackoff = { untilMs: retryAtMs, rejectedAtMs, liftable: quotaRecoveryMayLiftRefusal(error48) };
|
|
39973
40193
|
} else {
|
|
39974
40194
|
nextClaimAt = retryAtMs;
|
|
39975
40195
|
}
|
|
@@ -40153,7 +40373,7 @@ var init_runner = __esm({
|
|
|
40153
40373
|
}
|
|
40154
40374
|
if (quiesceRequested && !drainRequested) {
|
|
40155
40375
|
await Promise.race([Promise.allSettled([...active.values(), agentLoop]), drainSignal]);
|
|
40156
|
-
if (!drainRequested) requestDrain(
|
|
40376
|
+
if (!drainRequested) requestDrain(quiesceDrainReason);
|
|
40157
40377
|
}
|
|
40158
40378
|
stopHostHeartbeatLoop();
|
|
40159
40379
|
if (providerDispatchWatchdogDrainRequested) {
|
|
@@ -40312,8 +40532,8 @@ var init_runner = __esm({
|
|
|
40312
40532
|
let providerDispatchWatchdog = null;
|
|
40313
40533
|
let providerDispatchWatchdogExpired = false;
|
|
40314
40534
|
let resolveProviderDispatchWatchdog;
|
|
40315
|
-
const providerDispatchWatchdogSignal = new Promise((
|
|
40316
|
-
resolveProviderDispatchWatchdog =
|
|
40535
|
+
const providerDispatchWatchdogSignal = new Promise((resolve17) => {
|
|
40536
|
+
resolveProviderDispatchWatchdog = resolve17;
|
|
40317
40537
|
});
|
|
40318
40538
|
const clearProviderDispatchWatchdog = () => {
|
|
40319
40539
|
if (providerDispatchWatchdog !== null) clearTimeout(providerDispatchWatchdog);
|
|
@@ -40750,8 +40970,8 @@ var init_runner = __esm({
|
|
|
40750
40970
|
});
|
|
40751
40971
|
}
|
|
40752
40972
|
let resolveTerminalDispatchOutcome;
|
|
40753
|
-
const terminalDispatchOutcomeSignal = new Promise((
|
|
40754
|
-
resolveTerminalDispatchOutcome =
|
|
40973
|
+
const terminalDispatchOutcomeSignal = new Promise((resolve17) => {
|
|
40974
|
+
resolveTerminalDispatchOutcome = resolve17;
|
|
40755
40975
|
});
|
|
40756
40976
|
let terminalDispatchOutcomeObserved = false;
|
|
40757
40977
|
const adapterAttempt = this.dependencies.codexAdapter.runAttempt({
|
|
@@ -41055,6 +41275,8 @@ var init_runner = __esm({
|
|
|
41055
41275
|
signal,
|
|
41056
41276
|
deadlineAtMs: hostClockMs(jobInput.evidence_expires_at)
|
|
41057
41277
|
}) === true);
|
|
41278
|
+
const failureDetail = attemptFailureDetail(heartbeatFailure ?? effectiveError);
|
|
41279
|
+
const sendFailureDetail = failureDetail !== null && (mcp.supportsFailureDetail?.() === true || await mcp.refreshFailureDetailSupport?.({ signal, deadlineAtMs: hostClockMs(jobInput.evidence_expires_at) }) === true);
|
|
41058
41280
|
const failureRequest = jobFailRequestSchema.parse({
|
|
41059
41281
|
schema_version: "external_inference_job_fail_v1",
|
|
41060
41282
|
contract_version: EXTERNAL_INFERENCE_CONTRACT_VERSION,
|
|
@@ -41101,6 +41323,7 @@ var init_runner = __esm({
|
|
|
41101
41323
|
...sendHttpStatus ? { provider_http_status: httpStatus } : {},
|
|
41102
41324
|
...sendGrokDiagnostic ? { grok_tool_validation: grokDiagnostic } : {},
|
|
41103
41325
|
...sendIdentityDiagnostic ? { grok_response_identity: identityDiagnostic } : {},
|
|
41326
|
+
...sendFailureDetail ? { failure_detail: failureDetail } : {},
|
|
41104
41327
|
membership_disposition: membershipFailureDisposition({
|
|
41105
41328
|
...failure2,
|
|
41106
41329
|
dispatchOutcome
|
|
@@ -41136,6 +41359,7 @@ var init_runner = __esm({
|
|
|
41136
41359
|
failure_code: failureRequest.failure_code,
|
|
41137
41360
|
retryable: failureRequest.retryable,
|
|
41138
41361
|
process_exit: failureRequest.process_exit ?? null,
|
|
41362
|
+
failure_detail: failureDetail,
|
|
41139
41363
|
dispatch_outcome: failureRequest.outcome.dispatch_outcome,
|
|
41140
41364
|
response_outcome: failureRequest.outcome.response_outcome,
|
|
41141
41365
|
latency_ms: adapterResult?.latencyMs ?? null,
|
|
@@ -42447,8 +42671,8 @@ var init_owned_directory_removal = __esm({
|
|
|
42447
42671
|
TRANSIENT_REMOVAL_ERROR_CODES = /* @__PURE__ */ new Set(["EBUSY", "EMFILE", "ENFILE", "ENOTEMPTY", "EPERM"]);
|
|
42448
42672
|
removeOwnedDirectory = async (path, options = {}) => {
|
|
42449
42673
|
const removeDirectory = options.removeDirectory ?? rm5;
|
|
42450
|
-
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((
|
|
42451
|
-
setTimeout(
|
|
42674
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve17) => {
|
|
42675
|
+
setTimeout(resolve17, milliseconds);
|
|
42452
42676
|
}));
|
|
42453
42677
|
const maxAttempts = Math.max(1, options.maxAttempts ?? runtime_policy_generated_default.external_inference.host_core.owned_directory_removal_attempts);
|
|
42454
42678
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? runtime_policy_generated_default.external_inference.host_core.owned_directory_removal_retry_step_ms);
|
|
@@ -42490,7 +42714,7 @@ import { createHash as createHash6 } from "node:crypto";
|
|
|
42490
42714
|
import { constants as fsConstants } from "node:fs";
|
|
42491
42715
|
import { access as access2, readFile as readFile5, realpath as realpath3 } from "node:fs/promises";
|
|
42492
42716
|
import { createRequire } from "node:module";
|
|
42493
|
-
import { dirname as
|
|
42717
|
+
import { dirname as dirname6, join as join5 } from "node:path";
|
|
42494
42718
|
import { spawn as spawn5 } from "node:child_process";
|
|
42495
42719
|
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
42720
|
var init_codex_binary = __esm({
|
|
@@ -42534,14 +42758,14 @@ var init_codex_binary = __esm({
|
|
|
42534
42758
|
const spec = pinnedPackageForPlatform(platform, architecture);
|
|
42535
42759
|
const packageJsonPath = resolvePackage(`${spec.packageName}/package.json`);
|
|
42536
42760
|
return join5(
|
|
42537
|
-
|
|
42761
|
+
dirname6(packageJsonPath),
|
|
42538
42762
|
"vendor",
|
|
42539
42763
|
spec.target,
|
|
42540
42764
|
"bin",
|
|
42541
42765
|
spec.binaryName
|
|
42542
42766
|
);
|
|
42543
42767
|
};
|
|
42544
|
-
readCodexVersion = async (binaryPath) => await new Promise((
|
|
42768
|
+
readCodexVersion = async (binaryPath) => await new Promise((resolve17, reject) => {
|
|
42545
42769
|
const child = spawn5(binaryPath, ["--version"], {
|
|
42546
42770
|
stdio: ["ignore", "pipe", "pipe"],
|
|
42547
42771
|
windowsHide: true,
|
|
@@ -42580,7 +42804,7 @@ var init_codex_binary = __esm({
|
|
|
42580
42804
|
reject(new Error("Codex version probe failed."));
|
|
42581
42805
|
return;
|
|
42582
42806
|
}
|
|
42583
|
-
|
|
42807
|
+
resolve17(stdout.trim());
|
|
42584
42808
|
});
|
|
42585
42809
|
});
|
|
42586
42810
|
verifyPinnedCodexBinary = async (candidatePath, dependencies = {}) => {
|
|
@@ -42639,9 +42863,9 @@ import {
|
|
|
42639
42863
|
rm as rm6
|
|
42640
42864
|
} from "node:fs/promises";
|
|
42641
42865
|
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;
|
|
42866
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
42867
|
+
import { isAbsolute as isAbsolute6, join as join6, relative as relative4, resolve as resolve5, sep as sep3 } from "node:path";
|
|
42868
|
+
var MAX_PROMPT_BYTES2, HOST_RUNTIME_POLICY4, CODEX_MODEL_NAME_PATTERN, CODEX_REASONING_EFFORT_PATTERN, codexRecoveryCheckpointProcessFingerprint, proveCodexSameBootQuiescence, tokenUsageReceiptSchema, turnResultReceiptSchema, terminalReceiptSchema, recoveryAccountLimitsSchema, recoveryCheckpointSchema, recoveryFileSchema, FileCodexAttemptRecoveryStore, utf8Bytes, assertAttemptActive, tomlString, permissionConfig, ensureDedicatedCodexHome, createIsolatedCodexAttemptResources, isMissingPathError, createIsolatedCodexHostResources, validateAttemptInput, isStrictDescendant, assertRecoveryResourceScope, removeRecoveredThread, confirmCodexGuardianTerminated, confirmGuardianTerminatedForRecovery, recoveredCodexProcessExit, reconcileCodexAttemptRecovery, CodexSubscriptionAdapter, CodexAgentSubscriptionAdapter;
|
|
42645
42869
|
var init_codex_adapter = __esm({
|
|
42646
42870
|
"lib/inference-host/codex-adapter.ts"() {
|
|
42647
42871
|
"use strict";
|
|
@@ -42734,6 +42958,23 @@ var init_codex_adapter = __esm({
|
|
|
42734
42958
|
})
|
|
42735
42959
|
})
|
|
42736
42960
|
]);
|
|
42961
|
+
recoveryAccountLimitsSchema = external_exports.strictObject({
|
|
42962
|
+
schema_version: external_exports.literal("vtx_codex_recovery_account_limits_v1"),
|
|
42963
|
+
attempts: external_exports.record(external_exports.string(), external_exports.strictObject({
|
|
42964
|
+
// The exact failure the limits were read with: input, code and retry time.
|
|
42965
|
+
inputSha256: external_exports.string().regex(/^[0-9a-f]{64}$/u),
|
|
42966
|
+
code: external_exports.string().min(1).max(CODEX_RECOVERY_RECEIPT_MAX_CHARS.ERROR_CODE),
|
|
42967
|
+
retryAtMs: external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable(),
|
|
42968
|
+
rateLimits: external_exports.custom((value) => {
|
|
42969
|
+
try {
|
|
42970
|
+
parseCodexAccountRateLimits(value);
|
|
42971
|
+
return true;
|
|
42972
|
+
} catch {
|
|
42973
|
+
return false;
|
|
42974
|
+
}
|
|
42975
|
+
})
|
|
42976
|
+
}))
|
|
42977
|
+
});
|
|
42737
42978
|
recoveryCheckpointSchema = external_exports.strictObject({
|
|
42738
42979
|
schemaVersion: external_exports.literal("vtx_codex_attempt_recovery_v1"),
|
|
42739
42980
|
attemptId: identifierSchema,
|
|
@@ -42771,6 +43012,10 @@ var init_codex_adapter = __esm({
|
|
|
42771
43012
|
this.path = path;
|
|
42772
43013
|
this.queue = Promise.resolve();
|
|
42773
43014
|
}
|
|
43015
|
+
/** The account limits file beside the recovery file (recoveryAccountLimitsSchema). */
|
|
43016
|
+
get accountLimitsPath() {
|
|
43017
|
+
return `${this.path}.account-limits.json`;
|
|
43018
|
+
}
|
|
42774
43019
|
async readAll() {
|
|
42775
43020
|
const raw = await readInferencePrivateFile(this.path, "Codex attempt recovery file");
|
|
42776
43021
|
if (raw === null) return {};
|
|
@@ -42788,44 +43033,116 @@ var init_codex_adapter = __esm({
|
|
|
42788
43033
|
}
|
|
42789
43034
|
return document2.attempts;
|
|
42790
43035
|
}
|
|
43036
|
+
async readAccountLimits() {
|
|
43037
|
+
try {
|
|
43038
|
+
const raw = await readInferencePrivateFile(this.accountLimitsPath, "Codex recovery account limits file");
|
|
43039
|
+
return raw === null ? {} : recoveryAccountLimitsSchema.parse(JSON.parse(raw)).attempts;
|
|
43040
|
+
} catch {
|
|
43041
|
+
return {};
|
|
43042
|
+
}
|
|
43043
|
+
}
|
|
43044
|
+
// Limits reach only the exact failure they were read with.
|
|
43045
|
+
withAccountLimits(checkpoint, limits) {
|
|
43046
|
+
const entry = limits[checkpoint.attemptId];
|
|
43047
|
+
const terminal = checkpoint.terminal;
|
|
43048
|
+
if (terminal?.kind !== "failed" || entry?.inputSha256 !== checkpoint.inputSha256 || entry.code !== terminal.error.code || entry.retryAtMs !== (terminal.error.retryAtMs ?? null)) return checkpoint;
|
|
43049
|
+
return { ...checkpoint, terminal: { kind: "failed", error: { ...terminal.error, rateLimits: entry.rateLimits } } };
|
|
43050
|
+
}
|
|
43051
|
+
// The limits file is written first (a crash between the writes leaves limits
|
|
43052
|
+
// no failure matches, never a failure missing them) and only when its entries
|
|
43053
|
+
// change, and never at the recovery file's expense: a limits file that cannot
|
|
43054
|
+
// be written costs only the limits. Entries of attempts the recovery file no
|
|
43055
|
+
// longer holds (cleared by this or an older release) go.
|
|
43056
|
+
async writeAll(attempts, limits, previous) {
|
|
43057
|
+
const kept = Object.fromEntries(Object.entries(limits).filter(([attemptId]) => attemptId in attempts));
|
|
43058
|
+
if (Object.keys(attempts).length === 0 || JSON.stringify(kept) !== JSON.stringify(previous)) {
|
|
43059
|
+
try {
|
|
43060
|
+
if (Object.keys(kept).length === 0) {
|
|
43061
|
+
await clearInferencePrivateFile(this.accountLimitsPath, "Codex recovery account limits file");
|
|
43062
|
+
} else {
|
|
43063
|
+
await writeAtomicInferencePrivateFile(this.accountLimitsPath, `${JSON.stringify({
|
|
43064
|
+
schema_version: "vtx_codex_recovery_account_limits_v1",
|
|
43065
|
+
attempts: kept
|
|
43066
|
+
}, null, JSON_INDENT_SPACES)}
|
|
43067
|
+
`);
|
|
43068
|
+
}
|
|
43069
|
+
} catch {
|
|
43070
|
+
}
|
|
43071
|
+
}
|
|
43072
|
+
if (Object.keys(attempts).length === 0) {
|
|
43073
|
+
await clearInferencePrivateFile(this.path, "Codex attempt recovery file");
|
|
43074
|
+
return;
|
|
43075
|
+
}
|
|
43076
|
+
await writeAtomicInferencePrivateFile(this.path, `${JSON.stringify({
|
|
43077
|
+
schema_version: "vtx_codex_recovery_file_v1",
|
|
43078
|
+
attempts
|
|
43079
|
+
}, null, JSON_INDENT_SPACES)}
|
|
43080
|
+
`);
|
|
43081
|
+
}
|
|
42791
43082
|
enqueue(operation) {
|
|
42792
43083
|
const pending3 = this.queue.then(operation, operation);
|
|
42793
43084
|
this.queue = pending3.then(() => void 0, () => void 0);
|
|
42794
43085
|
return pending3;
|
|
42795
43086
|
}
|
|
43087
|
+
/** One attempt for its same-attempt recovery, with the account limits its failure was read with. */
|
|
42796
43088
|
async load(attemptId) {
|
|
42797
43089
|
await this.queue;
|
|
42798
|
-
|
|
43090
|
+
const checkpoint = (await this.readAll())[attemptId];
|
|
43091
|
+
return checkpoint ? this.withAccountLimits(checkpoint, await this.readAccountLimits()) : null;
|
|
42799
43092
|
}
|
|
43093
|
+
/**
|
|
43094
|
+
* Every attempt exactly as the recovery file holds it, without account
|
|
43095
|
+
* limits: the service recovery compares these with a raw copy of the file.
|
|
43096
|
+
*/
|
|
42800
43097
|
async loadAll() {
|
|
42801
43098
|
await this.queue;
|
|
42802
43099
|
return await this.readAll();
|
|
42803
43100
|
}
|
|
43101
|
+
/**
|
|
43102
|
+
* A failure's own rateLimits (or null) replaces its stored limits; a
|
|
43103
|
+
* checkpoint saved without that field (one loadAll returned) keeps them.
|
|
43104
|
+
*/
|
|
42804
43105
|
async save(checkpoint) {
|
|
42805
|
-
const
|
|
43106
|
+
const terminal = checkpoint.terminal;
|
|
43107
|
+
let stored = checkpoint;
|
|
43108
|
+
let limitsUpdate = null;
|
|
43109
|
+
if (terminal?.kind === "failed" && "rateLimits" in terminal.error) {
|
|
43110
|
+
const { rateLimits, ...error48 } = terminal.error;
|
|
43111
|
+
limitsUpdate = { rateLimits: rateLimits ?? null };
|
|
43112
|
+
stored = { ...checkpoint, terminal: { kind: "failed", error: error48 } };
|
|
43113
|
+
}
|
|
43114
|
+
const validated = recoveryCheckpointSchema.parse(stored);
|
|
42806
43115
|
await this.enqueue(async () => {
|
|
42807
43116
|
const attempts = await this.readAll();
|
|
42808
43117
|
attempts[validated.attemptId] = validated;
|
|
42809
|
-
await
|
|
42810
|
-
|
|
42811
|
-
|
|
42812
|
-
|
|
42813
|
-
|
|
43118
|
+
const previous = await this.readAccountLimits();
|
|
43119
|
+
const limits = { ...previous };
|
|
43120
|
+
if (limitsUpdate?.rateLimits && validated.terminal?.kind === "failed") {
|
|
43121
|
+
limits[validated.attemptId] = {
|
|
43122
|
+
inputSha256: validated.inputSha256,
|
|
43123
|
+
code: validated.terminal.error.code,
|
|
43124
|
+
retryAtMs: validated.terminal.error.retryAtMs ?? null,
|
|
43125
|
+
rateLimits: limitsUpdate.rateLimits
|
|
43126
|
+
};
|
|
43127
|
+
} else if (limitsUpdate) {
|
|
43128
|
+
delete limits[validated.attemptId];
|
|
43129
|
+
}
|
|
43130
|
+
await this.writeAll(attempts, limits, previous);
|
|
42814
43131
|
});
|
|
42815
43132
|
}
|
|
42816
43133
|
async clear(attemptId) {
|
|
42817
43134
|
await this.enqueue(async () => {
|
|
42818
43135
|
const attempts = await this.readAll();
|
|
42819
43136
|
delete attempts[attemptId];
|
|
42820
|
-
|
|
42821
|
-
|
|
42822
|
-
|
|
42823
|
-
|
|
42824
|
-
|
|
42825
|
-
|
|
42826
|
-
|
|
42827
|
-
|
|
42828
|
-
|
|
43137
|
+
const previous = await this.readAccountLimits();
|
|
43138
|
+
await this.writeAll(attempts, previous, previous);
|
|
43139
|
+
});
|
|
43140
|
+
}
|
|
43141
|
+
/** Removes the recovery file and its account limits (logout and revoke). */
|
|
43142
|
+
async discard() {
|
|
43143
|
+
await this.enqueue(async () => {
|
|
43144
|
+
await clearInferencePrivateFile(this.accountLimitsPath, "Codex recovery account limits file").catch(() => void 0);
|
|
43145
|
+
await clearInferencePrivateFile(this.path, "Codex attempt recovery file");
|
|
42829
43146
|
});
|
|
42830
43147
|
}
|
|
42831
43148
|
};
|
|
@@ -42884,7 +43201,7 @@ var init_codex_adapter = __esm({
|
|
|
42884
43201
|
};
|
|
42885
43202
|
createIsolatedCodexAttemptResources = async (_attemptId, codexHome = resolveInferenceHostConfig().codexHomePath) => {
|
|
42886
43203
|
await ensureDedicatedCodexHome(codexHome);
|
|
42887
|
-
const root = await mkdtemp(join6(
|
|
43204
|
+
const root = await mkdtemp(join6(tmpdir3(), INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX));
|
|
42888
43205
|
await chmod3(root, OWNER_ONLY_DIRECTORY_MODE);
|
|
42889
43206
|
const workspacePath = join6(root, "workspace");
|
|
42890
43207
|
await mkdir4(workspacePath, { mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
@@ -42892,34 +43209,84 @@ var init_codex_adapter = __esm({
|
|
|
42892
43209
|
root,
|
|
42893
43210
|
codexHome,
|
|
42894
43211
|
workspacePath,
|
|
43212
|
+
// A folder something else already deleted is removed: its prompt bytes are gone.
|
|
42895
43213
|
cleanup: async () => {
|
|
42896
|
-
await removeOwnedDirectory(root
|
|
43214
|
+
await removeOwnedDirectory(root);
|
|
42897
43215
|
}
|
|
42898
43216
|
};
|
|
42899
43217
|
};
|
|
43218
|
+
isMissingPathError = (error48) => error48?.code === "ENOENT";
|
|
42900
43219
|
createIsolatedCodexHostResources = async (codexHome) => {
|
|
42901
43220
|
await ensureDedicatedCodexHome(codexHome);
|
|
42902
|
-
const
|
|
42903
|
-
|
|
42904
|
-
|
|
42905
|
-
|
|
43221
|
+
const mintWorkerFolder = async () => {
|
|
43222
|
+
const folder = await mkdtemp(join6(tmpdir3(), INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_PREFIX));
|
|
43223
|
+
try {
|
|
43224
|
+
await chmod3(folder, OWNER_ONLY_DIRECTORY_MODE);
|
|
43225
|
+
await mkdir4(join6(folder, INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS), { mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
43226
|
+
} catch (error48) {
|
|
43227
|
+
await removeOwnedDirectory(folder).catch(() => void 0);
|
|
43228
|
+
throw error48;
|
|
43229
|
+
}
|
|
43230
|
+
return folder;
|
|
43231
|
+
};
|
|
43232
|
+
const mintJobFolder = async (folder) => {
|
|
43233
|
+
const workspacePath = await mkdtemp(join6(
|
|
43234
|
+
folder,
|
|
43235
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_WORKER_JOBS,
|
|
43236
|
+
INFERENCE_HOST_TEMP_FOLDERS.CODEX_HOSTED_JOB_PREFIX
|
|
43237
|
+
));
|
|
43238
|
+
await chmod3(workspacePath, OWNER_ONLY_DIRECTORY_MODE);
|
|
43239
|
+
return workspacePath;
|
|
43240
|
+
};
|
|
43241
|
+
let root = await mintWorkerFolder();
|
|
43242
|
+
const minted = [root];
|
|
43243
|
+
let replacement = null;
|
|
43244
|
+
const replaceVanished = async (vanished) => {
|
|
43245
|
+
if (root !== vanished) return root;
|
|
43246
|
+
replacement ??= mintWorkerFolder().then((folder) => {
|
|
43247
|
+
root = folder;
|
|
43248
|
+
minted.push(folder);
|
|
43249
|
+
return folder;
|
|
43250
|
+
}).finally(() => {
|
|
43251
|
+
replacement = null;
|
|
43252
|
+
});
|
|
43253
|
+
return await replacement;
|
|
43254
|
+
};
|
|
42906
43255
|
return {
|
|
42907
|
-
root
|
|
43256
|
+
get root() {
|
|
43257
|
+
return root;
|
|
43258
|
+
},
|
|
42908
43259
|
codexHome,
|
|
42909
43260
|
createAttemptResources: async () => {
|
|
42910
|
-
const
|
|
42911
|
-
|
|
43261
|
+
const folder = root;
|
|
43262
|
+
let workspacePath;
|
|
43263
|
+
let replacedVanishedWorkerFolder = false;
|
|
43264
|
+
try {
|
|
43265
|
+
workspacePath = await mintJobFolder(folder);
|
|
43266
|
+
} catch (error48) {
|
|
43267
|
+
if (!isMissingPathError(error48)) throw error48;
|
|
43268
|
+
workspacePath = await mintJobFolder(await replaceVanished(folder));
|
|
43269
|
+
replacedVanishedWorkerFolder = true;
|
|
43270
|
+
}
|
|
42912
43271
|
return {
|
|
42913
43272
|
root: workspacePath,
|
|
42914
43273
|
codexHome,
|
|
42915
43274
|
workspacePath,
|
|
43275
|
+
replacedVanishedWorkerFolder,
|
|
42916
43276
|
cleanup: async () => {
|
|
42917
|
-
await removeOwnedDirectory(workspacePath
|
|
43277
|
+
await removeOwnedDirectory(workspacePath);
|
|
42918
43278
|
}
|
|
42919
43279
|
};
|
|
42920
43280
|
},
|
|
43281
|
+
// Every folder this worker run made, including ones that vanished or were
|
|
43282
|
+
// left behind partly deleted; one already gone is already removed, and one
|
|
43283
|
+
// that fails does not stop the others.
|
|
42921
43284
|
cleanup: async () => {
|
|
42922
|
-
|
|
43285
|
+
const failures = [];
|
|
43286
|
+
for (const folder of minted) await removeOwnedDirectory(folder).catch((error48) => {
|
|
43287
|
+
failures.push(error48);
|
|
43288
|
+
});
|
|
43289
|
+
if (failures.length > 0) throw failures[0];
|
|
42923
43290
|
}
|
|
42924
43291
|
};
|
|
42925
43292
|
};
|
|
@@ -43025,27 +43392,27 @@ var init_codex_adapter = __esm({
|
|
|
43025
43392
|
};
|
|
43026
43393
|
};
|
|
43027
43394
|
isStrictDescendant = (candidate, parent) => {
|
|
43028
|
-
const parentPath =
|
|
43029
|
-
const candidatePath =
|
|
43030
|
-
const scoped =
|
|
43031
|
-
return scoped.length > 0 && !scoped.startsWith(`..${
|
|
43395
|
+
const parentPath = resolve5(parent);
|
|
43396
|
+
const candidatePath = resolve5(candidate);
|
|
43397
|
+
const scoped = relative4(parentPath, candidatePath);
|
|
43398
|
+
return scoped.length > 0 && !scoped.startsWith(`..${sep3}`) && scoped !== ".." && !isAbsolute6(scoped);
|
|
43032
43399
|
};
|
|
43033
43400
|
assertRecoveryResourceScope = (checkpoint) => {
|
|
43034
|
-
const temporaryRoot =
|
|
43035
|
-
const resourceRoot =
|
|
43036
|
-
const workspacePath =
|
|
43401
|
+
const temporaryRoot = resolve5(tmpdir3());
|
|
43402
|
+
const resourceRoot = resolve5(checkpoint.resourceRoot);
|
|
43403
|
+
const workspacePath = resolve5(checkpoint.workspacePath);
|
|
43037
43404
|
if (!isStrictDescendant(resourceRoot, temporaryRoot)) {
|
|
43038
43405
|
throw new Error("Codex recovery resource root crossed temporary scope.");
|
|
43039
43406
|
}
|
|
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(
|
|
43407
|
+
const parts = relative4(temporaryRoot, resourceRoot).split(sep3);
|
|
43408
|
+
const standalone = parts.length === 1 && parts[0].startsWith(INFERENCE_HOST_TEMP_FOLDERS.CODEX_JOB_PREFIX) && workspacePath === join6(resourceRoot, "workspace");
|
|
43409
|
+
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
43410
|
if (!standalone && !hosted) {
|
|
43044
43411
|
throw new Error("Codex recovery resource layout is invalid.");
|
|
43045
43412
|
}
|
|
43046
43413
|
};
|
|
43047
43414
|
removeRecoveredThread = async (checkpoint, expectedCodexHome) => {
|
|
43048
|
-
if (
|
|
43415
|
+
if (resolve5(checkpoint.codexHome) !== resolve5(expectedCodexHome)) {
|
|
43049
43416
|
throw new Error("Codex recovery home crossed dedicated auth scope.");
|
|
43050
43417
|
}
|
|
43051
43418
|
if (checkpoint.threadId === null || checkpoint.threadPath === null) {
|
|
@@ -43054,7 +43421,7 @@ var init_codex_adapter = __esm({
|
|
|
43054
43421
|
}
|
|
43055
43422
|
}
|
|
43056
43423
|
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) !==
|
|
43424
|
+
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
43425
|
throw new Error("Codex recovery home is not a private owned directory.");
|
|
43059
43426
|
}
|
|
43060
43427
|
const threadPaths = /* @__PURE__ */ new Set();
|
|
@@ -43110,7 +43477,7 @@ var init_codex_adapter = __esm({
|
|
|
43110
43477
|
if (!event || typeof event !== "object" || Array.isArray(event)) continue;
|
|
43111
43478
|
const record6 = event;
|
|
43112
43479
|
const payload = record6.payload;
|
|
43113
|
-
if (record6.type === "session_meta" && payload && typeof payload === "object" && !Array.isArray(payload) &&
|
|
43480
|
+
if (record6.type === "session_meta" && payload && typeof payload === "object" && !Array.isArray(payload) && resolve5(String(payload.cwd || "")) === resolve5(checkpoint.workspacePath)) {
|
|
43114
43481
|
threadPaths.add(path);
|
|
43115
43482
|
break;
|
|
43116
43483
|
}
|
|
@@ -43118,7 +43485,7 @@ var init_codex_adapter = __esm({
|
|
|
43118
43485
|
}
|
|
43119
43486
|
}
|
|
43120
43487
|
if (checkpoint.threadPath !== null) {
|
|
43121
|
-
if (!
|
|
43488
|
+
if (!isAbsolute6(checkpoint.threadPath) || !isStrictDescendant(
|
|
43122
43489
|
checkpoint.threadPath,
|
|
43123
43490
|
sessionsRoot
|
|
43124
43491
|
) || !checkpoint.threadPath.endsWith(".jsonl")) {
|
|
@@ -43367,7 +43734,7 @@ var init_codex_adapter = __esm({
|
|
|
43367
43734
|
);
|
|
43368
43735
|
const bootIdentity = guardianManaged ? await (this.dependencies.readBootIdentity ?? readInferenceSystemBootIdentity)() : null;
|
|
43369
43736
|
const processToken = guardianManaged ? randomBytes4(CODEX_GUARDIAN_PROCESS_TOKEN_BYTES).toString("hex") : null;
|
|
43370
|
-
const guardianReceiptRoot = guardianManaged ? this.dependencies.guardianReceiptRoot ?? join6(
|
|
43737
|
+
const guardianReceiptRoot = guardianManaged ? this.dependencies.guardianReceiptRoot ?? join6(tmpdir3(), "vtx-codex-guardian-receipts") : null;
|
|
43371
43738
|
if (guardianReceiptRoot) await ensureInferencePrivateDirectory(guardianReceiptRoot);
|
|
43372
43739
|
const processReceiptPath = guardianReceiptRoot && processToken ? join6(guardianReceiptRoot, `${processToken}.json`) : null;
|
|
43373
43740
|
const session = await CodexAppServerSession.start({
|
|
@@ -43518,7 +43885,7 @@ var init_codex_adapter = __esm({
|
|
|
43518
43885
|
durableSession.session.requireModelCapability(capabilities, modelName, reasoningEffort);
|
|
43519
43886
|
}
|
|
43520
43887
|
async waitForCapabilities(preflight, deadlineAtMs, signal) {
|
|
43521
|
-
return await new Promise((
|
|
43888
|
+
return await new Promise((resolve17, reject) => {
|
|
43522
43889
|
let settled2 = false;
|
|
43523
43890
|
const finish = (callback) => {
|
|
43524
43891
|
if (settled2) return;
|
|
@@ -43545,7 +43912,7 @@ var init_codex_adapter = __esm({
|
|
|
43545
43912
|
return;
|
|
43546
43913
|
}
|
|
43547
43914
|
void preflight.then(
|
|
43548
|
-
(value) => finish(() =>
|
|
43915
|
+
(value) => finish(() => resolve17(value)),
|
|
43549
43916
|
(error48) => finish(() => reject(error48))
|
|
43550
43917
|
);
|
|
43551
43918
|
});
|
|
@@ -43656,8 +44023,8 @@ var init_codex_adapter = __esm({
|
|
|
43656
44023
|
if (recoveryHooks.loadAll) {
|
|
43657
44024
|
try {
|
|
43658
44025
|
const checkpoints = await recoveryHooks.loadAll();
|
|
43659
|
-
const receiptPath =
|
|
43660
|
-
sharedReceiptStillRequired = Object.values(checkpoints).some((candidate) => candidate.attemptId !== attemptId && !candidate.cleanupConfirmed && candidate.processReceiptPath !== null &&
|
|
44026
|
+
const receiptPath = resolve5(checkpoint.processReceiptPath);
|
|
44027
|
+
sharedReceiptStillRequired = Object.values(checkpoints).some((candidate) => candidate.attemptId !== attemptId && !candidate.cleanupConfirmed && candidate.processReceiptPath !== null && resolve5(candidate.processReceiptPath) === receiptPath);
|
|
43661
44028
|
} catch {
|
|
43662
44029
|
sharedReceiptStillRequired = true;
|
|
43663
44030
|
}
|
|
@@ -43704,7 +44071,7 @@ var init_codex_adapter = __esm({
|
|
|
43704
44071
|
try {
|
|
43705
44072
|
const checkpoints = await recoveryHooks.loadAll();
|
|
43706
44073
|
unconfirmedReceiptPaths = new Set(
|
|
43707
|
-
Object.values(checkpoints).filter((checkpoint) => !checkpoint.cleanupConfirmed && checkpoint.processReceiptPath !== null).map((checkpoint) =>
|
|
44074
|
+
Object.values(checkpoints).filter((checkpoint) => !checkpoint.cleanupConfirmed && checkpoint.processReceiptPath !== null).map((checkpoint) => resolve5(checkpoint.processReceiptPath))
|
|
43708
44075
|
);
|
|
43709
44076
|
} catch {
|
|
43710
44077
|
unconfirmedReceiptPaths = null;
|
|
@@ -43712,7 +44079,7 @@ var init_codex_adapter = __esm({
|
|
|
43712
44079
|
}
|
|
43713
44080
|
}
|
|
43714
44081
|
for (const session of sessions) {
|
|
43715
|
-
if (session.processReceiptPath && unconfirmedReceiptPaths !== null && !unconfirmedReceiptPaths.has(
|
|
44082
|
+
if (session.processReceiptPath && unconfirmedReceiptPaths !== null && !unconfirmedReceiptPaths.has(resolve5(session.processReceiptPath))) {
|
|
43716
44083
|
await rm6(session.processReceiptPath, { force: true });
|
|
43717
44084
|
await rm6(`${session.processReceiptPath}.shutdown-intent`, { force: true });
|
|
43718
44085
|
}
|
|
@@ -43760,7 +44127,8 @@ var init_codex_adapter = __esm({
|
|
|
43760
44127
|
httpStatusCode: recovered.httpStatusCode,
|
|
43761
44128
|
retryAtMs: recovered.retryAtMs,
|
|
43762
44129
|
usage: recovered.usage,
|
|
43763
|
-
processExit: recovered.processExit
|
|
44130
|
+
processExit: recovered.processExit,
|
|
44131
|
+
rateLimits: recovered.rateLimits ?? null
|
|
43764
44132
|
});
|
|
43765
44133
|
}
|
|
43766
44134
|
throw new CodexAppServerError({
|
|
@@ -43792,6 +44160,9 @@ var init_codex_adapter = __esm({
|
|
|
43792
44160
|
attemptId,
|
|
43793
44161
|
this.dependencies.codexHome
|
|
43794
44162
|
)))(input.attemptId);
|
|
44163
|
+
if (resources.replacedVanishedWorkerFolder) {
|
|
44164
|
+
this.emitDiagnostic({ event: "codex_worker_folder_replaced", attempt_id: input.attemptId });
|
|
44165
|
+
}
|
|
43795
44166
|
await access3(resources.codexHome, fsConstants2.R_OK | fsConstants2.W_OK);
|
|
43796
44167
|
await access3(resources.workspacePath, fsConstants2.R_OK);
|
|
43797
44168
|
sessionLease = await this.acquireDurableSession(
|
|
@@ -43918,7 +44289,8 @@ var init_codex_adapter = __esm({
|
|
|
43918
44289
|
httpStatusCode: error48.httpStatusCode,
|
|
43919
44290
|
retryAtMs: error48.retryAtMs,
|
|
43920
44291
|
usage: error48.usage,
|
|
43921
|
-
processExit: error48.processExit
|
|
44292
|
+
processExit: error48.processExit,
|
|
44293
|
+
rateLimits: error48.rateLimits
|
|
43922
44294
|
}
|
|
43923
44295
|
}
|
|
43924
44296
|
};
|
|
@@ -43935,6 +44307,7 @@ var init_codex_adapter = __esm({
|
|
|
43935
44307
|
retryAtMs: error48.retryAtMs,
|
|
43936
44308
|
usage: error48.usage,
|
|
43937
44309
|
processExit: error48.processExit,
|
|
44310
|
+
rateLimits: error48.rateLimits,
|
|
43938
44311
|
cause: error48
|
|
43939
44312
|
});
|
|
43940
44313
|
}
|
|
@@ -44400,8 +44773,8 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44400
44773
|
|
|
44401
44774
|
// lib/inference-host/agent-thread-workspace.ts
|
|
44402
44775
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
44403
|
-
import { tmpdir as
|
|
44404
|
-
import { basename as basename2, dirname as
|
|
44776
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
44777
|
+
import { basename as basename2, dirname as dirname7 } from "node:path";
|
|
44405
44778
|
var ownedTempThreadWorkspace, removeRecordedTempThreadWorkspace;
|
|
44406
44779
|
var init_agent_thread_workspace = __esm({
|
|
44407
44780
|
"lib/inference-host/agent-thread-workspace.ts"() {
|
|
@@ -44414,8 +44787,8 @@ var init_agent_thread_workspace = __esm({
|
|
|
44414
44787
|
init_owned_directory_removal();
|
|
44415
44788
|
ownedTempThreadWorkspace = async (threadPath, prefix) => {
|
|
44416
44789
|
const resolved = await realpath5(threadPath);
|
|
44417
|
-
const temporaryRoot = await realpath5(
|
|
44418
|
-
return
|
|
44790
|
+
const temporaryRoot = await realpath5(tmpdir4());
|
|
44791
|
+
return dirname7(resolved) === temporaryRoot && basename2(resolved).startsWith(prefix) ? resolved : null;
|
|
44419
44792
|
};
|
|
44420
44793
|
removeRecordedTempThreadWorkspace = async (statePath, prefix) => {
|
|
44421
44794
|
let threadPath;
|
|
@@ -44441,7 +44814,7 @@ var init_agent_thread_workspace = __esm({
|
|
|
44441
44814
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
44442
44815
|
import { mkdtemp as mkdtemp2 } from "node:fs/promises";
|
|
44443
44816
|
import { createRequire as createRequire2 } from "node:module";
|
|
44444
|
-
import { tmpdir as
|
|
44817
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
44445
44818
|
import { join as join7 } from "node:path";
|
|
44446
44819
|
import {
|
|
44447
44820
|
CopilotClient,
|
|
@@ -44486,9 +44859,9 @@ var init_copilot_adapter = __esm({
|
|
|
44486
44859
|
}
|
|
44487
44860
|
throw new Error(`copilot_runtime_package_missing:${failures.join(";")}`);
|
|
44488
44861
|
};
|
|
44489
|
-
WORKSPACE_PREFIX =
|
|
44862
|
+
WORKSPACE_PREFIX = INFERENCE_HOST_TEMP_FOLDERS.COPILOT_JOB_PREFIX;
|
|
44490
44863
|
createPrivateWorkspace = async (removal = {}) => {
|
|
44491
|
-
const path = await mkdtemp2(join7(
|
|
44864
|
+
const path = await mkdtemp2(join7(tmpdir5(), WORKSPACE_PREFIX));
|
|
44492
44865
|
return {
|
|
44493
44866
|
path,
|
|
44494
44867
|
// client.stop() has already awaited the runtime's exit; retries cover the
|
|
@@ -45320,9 +45693,9 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
45320
45693
|
response.end();
|
|
45321
45694
|
}
|
|
45322
45695
|
});
|
|
45323
|
-
await new Promise((
|
|
45696
|
+
await new Promise((resolve17, reject) => {
|
|
45324
45697
|
this.server.once("error", reject);
|
|
45325
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
45698
|
+
this.server.listen(0, "127.0.0.1", () => resolve17());
|
|
45326
45699
|
});
|
|
45327
45700
|
const address = this.server.address();
|
|
45328
45701
|
if (!address || typeof address === "string") throw new Error("deepseek_proxy_bind_failed");
|
|
@@ -45334,7 +45707,7 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
45334
45707
|
this.server = null;
|
|
45335
45708
|
this.urlValue = null;
|
|
45336
45709
|
if (!server) return;
|
|
45337
|
-
await new Promise((
|
|
45710
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
45338
45711
|
}
|
|
45339
45712
|
};
|
|
45340
45713
|
}
|
|
@@ -45402,7 +45775,7 @@ var init_provider_refusal = __esm({
|
|
|
45402
45775
|
// lib/inference-host/deepseek-harness-adapter.ts
|
|
45403
45776
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
45404
45777
|
import { mkdtemp as mkdtemp3, rm as rm7 } from "node:fs/promises";
|
|
45405
|
-
import { tmpdir as
|
|
45778
|
+
import { tmpdir as tmpdir6 } from "node:os";
|
|
45406
45779
|
import { join as join8 } from "node:path";
|
|
45407
45780
|
import { Context } from "@deepseek-ai/cordis";
|
|
45408
45781
|
import * as AgentSpine from "@deepseek-ai/dsh-agent-spine-demo";
|
|
@@ -45570,9 +45943,9 @@ var init_deepseek_harness_adapter = __esm({
|
|
|
45570
45943
|
cause: options.error
|
|
45571
45944
|
});
|
|
45572
45945
|
};
|
|
45573
|
-
WORKSPACE_PREFIX2 =
|
|
45946
|
+
WORKSPACE_PREFIX2 = INFERENCE_HOST_TEMP_FOLDERS.DEEPSEEK_JOB_PREFIX;
|
|
45574
45947
|
createPrivateWorkspace2 = async () => {
|
|
45575
|
-
const path = await mkdtemp3(join8(
|
|
45948
|
+
const path = await mkdtemp3(join8(tmpdir6(), WORKSPACE_PREFIX2));
|
|
45576
45949
|
return { path, cleanup: async () => {
|
|
45577
45950
|
await removeOwnedDirectory(path);
|
|
45578
45951
|
} };
|
|
@@ -45950,11 +46323,11 @@ ${JSON.stringify(input.outputSchema)}`,
|
|
|
45950
46323
|
boundary.signal.throwIfAborted();
|
|
45951
46324
|
let checkpointReached = false;
|
|
45952
46325
|
let resolveCheckpoint;
|
|
45953
|
-
const checkpoint = new Promise((
|
|
45954
|
-
resolveCheckpoint =
|
|
46326
|
+
const checkpoint = new Promise((resolve17) => {
|
|
46327
|
+
resolveCheckpoint = resolve17;
|
|
45955
46328
|
});
|
|
45956
|
-
const dispatchGate = new Promise((
|
|
45957
|
-
releaseAgentDispatch =
|
|
46329
|
+
const dispatchGate = new Promise((resolve17) => {
|
|
46330
|
+
releaseAgentDispatch = resolve17;
|
|
45958
46331
|
});
|
|
45959
46332
|
ctx.on("llm/stream", (options, next) => {
|
|
45960
46333
|
if (String(options.sessionId ?? "") !== String(sessionId)) return next();
|
|
@@ -46275,7 +46648,7 @@ var init_pi_transport = __esm({
|
|
|
46275
46648
|
// lib/inference-host/pi-adapter.ts
|
|
46276
46649
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
46277
46650
|
import { lstat as lstat5, realpath as realpath6, rm as rm8, readdir as readdir5 } from "node:fs/promises";
|
|
46278
|
-
import { basename as basename3, dirname as
|
|
46651
|
+
import { basename as basename3, dirname as dirname8, join as join9, resolve as resolve6 } from "node:path";
|
|
46279
46652
|
import {
|
|
46280
46653
|
createAgentSession,
|
|
46281
46654
|
DefaultResourceLoader,
|
|
@@ -46439,8 +46812,8 @@ var init_pi_adapter = __esm({
|
|
|
46439
46812
|
}
|
|
46440
46813
|
async ownedThread(thread) {
|
|
46441
46814
|
const root = await realpath6(this.dependencies.stateRoot);
|
|
46442
|
-
const supplied =
|
|
46443
|
-
if (
|
|
46815
|
+
const supplied = resolve6(thread.threadPath);
|
|
46816
|
+
if (dirname8(supplied) !== root || basename3(supplied) !== `agent-${thread.threadId}` || !/^[a-f0-9-]{36}$/u.test(thread.threadId)) throw fail("pi_thread_not_owned");
|
|
46444
46817
|
const info = await lstat5(supplied);
|
|
46445
46818
|
if (info.isSymbolicLink() || !info.isDirectory()) throw fail("pi_thread_not_owned");
|
|
46446
46819
|
if (await realpath6(supplied) !== supplied) throw fail("pi_thread_not_owned");
|
|
@@ -46810,7 +47183,7 @@ import { spawn as spawn7 } from "node:child_process";
|
|
|
46810
47183
|
import { createHash as createHash8, randomUUID as randomUUID7 } from "node:crypto";
|
|
46811
47184
|
import { lstat as lstat6, readFile as readFile7, rename as rename4, rm as rm9, writeFile as writeFile3 } from "node:fs/promises";
|
|
46812
47185
|
import { createRequire as createRequire3 } from "node:module";
|
|
46813
|
-
import { dirname as
|
|
47186
|
+
import { dirname as dirname9, join as join10 } from "node:path";
|
|
46814
47187
|
import { brotliDecompress } from "node:zlib";
|
|
46815
47188
|
import { promisify } from "node:util";
|
|
46816
47189
|
var HOST_RUNTIME_POLICY8, decompress, pending, digest, verifyVersion, resolvePinnedGrokBinary;
|
|
@@ -46829,7 +47202,7 @@ var init_grok_binary = __esm({
|
|
|
46829
47202
|
decompress = promisify(brotliDecompress);
|
|
46830
47203
|
pending = /* @__PURE__ */ new Map();
|
|
46831
47204
|
digest = (bytes3) => createHash8("sha256").update(bytes3).digest("hex");
|
|
46832
|
-
verifyVersion = async (path) => new Promise((
|
|
47205
|
+
verifyVersion = async (path) => new Promise((resolve17, reject) => {
|
|
46833
47206
|
const child = spawn7(path, ["--version"], {
|
|
46834
47207
|
stdio: ["ignore", "pipe", "ignore"],
|
|
46835
47208
|
windowsHide: true,
|
|
@@ -46859,7 +47232,7 @@ var init_grok_binary = __esm({
|
|
|
46859
47232
|
clearTimeout(timer);
|
|
46860
47233
|
if (code !== 0 || /^grok\s+(\S+)/u.exec(stdout.trim())?.[1] !== agent_cli_release_default.grok_version) {
|
|
46861
47234
|
reject(new Error("Grok runtime version does not match its release."));
|
|
46862
|
-
} else
|
|
47235
|
+
} else resolve17();
|
|
46863
47236
|
});
|
|
46864
47237
|
});
|
|
46865
47238
|
resolvePinnedGrokBinary = async (stateRoot) => {
|
|
@@ -46890,7 +47263,7 @@ var init_grok_binary = __esm({
|
|
|
46890
47263
|
}
|
|
46891
47264
|
const manifest = JSON.parse(await readFile7(packagePath, "utf8"));
|
|
46892
47265
|
if (manifest.version !== agent_cli_release_default.grok_version) throw new Error("Grok package version mismatch.");
|
|
46893
|
-
const bytes3 = await decompress(await readFile7(join10(
|
|
47266
|
+
const bytes3 = await decompress(await readFile7(join10(dirname9(packagePath), "bin", `${spec.binary_name}.br`)), { maxOutputLength: HOST_RUNTIME_POLICY8.grok_binary_max_bytes });
|
|
46894
47267
|
if (digest(bytes3) !== spec.sha256) throw new Error("Grok package binary digest mismatch.");
|
|
46895
47268
|
const temporary = join10(directory2, `.${randomUUID7()}.tmp`);
|
|
46896
47269
|
try {
|
|
@@ -46916,7 +47289,7 @@ var init_grok_binary = __esm({
|
|
|
46916
47289
|
|
|
46917
47290
|
// lib/inference-host/grok-policy.ts
|
|
46918
47291
|
import { readFile as readFile8 } from "node:fs/promises";
|
|
46919
|
-
import { dirname as
|
|
47292
|
+
import { dirname as dirname10, resolve as resolve7 } from "node:path";
|
|
46920
47293
|
import { fileURLToPath } from "node:url";
|
|
46921
47294
|
var validateGrokPolicy, loadGrokPolicy;
|
|
46922
47295
|
var init_grok_policy = __esm({
|
|
@@ -46946,7 +47319,7 @@ var init_grok_policy = __esm({
|
|
|
46946
47319
|
};
|
|
46947
47320
|
loadGrokPolicy = async () => {
|
|
46948
47321
|
if (typeof define_VTX_GROK_POLICY_default !== "undefined") return validateGrokPolicy(define_VTX_GROK_POLICY_default);
|
|
46949
|
-
const config2 = parse(await readFile8(
|
|
47322
|
+
const config2 = parse(await readFile8(resolve7(dirname10(fileURLToPath(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
46950
47323
|
return validateGrokPolicy(config2.external_inference?.grok_adapter);
|
|
46951
47324
|
};
|
|
46952
47325
|
}
|
|
@@ -47087,9 +47460,9 @@ var init_grok_transport_proxy = __esm({
|
|
|
47087
47460
|
this.server = createServer3((request, response) => {
|
|
47088
47461
|
void this.handle(request, response);
|
|
47089
47462
|
});
|
|
47090
|
-
await new Promise((
|
|
47463
|
+
await new Promise((resolve17, reject) => {
|
|
47091
47464
|
this.server.once("error", reject);
|
|
47092
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
47465
|
+
this.server.listen(0, "127.0.0.1", () => resolve17());
|
|
47093
47466
|
});
|
|
47094
47467
|
const address = this.server.address();
|
|
47095
47468
|
if (!address || typeof address === "string") throw new Error("grok_proxy_bind_failed");
|
|
@@ -47465,7 +47838,7 @@ var init_grok_transport_proxy = __esm({
|
|
|
47465
47838
|
this.urlValue = null;
|
|
47466
47839
|
if (!server) return;
|
|
47467
47840
|
server.closeAllConnections();
|
|
47468
|
-
await new Promise((
|
|
47841
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
47469
47842
|
}
|
|
47470
47843
|
};
|
|
47471
47844
|
createGrokTransportProxy = async (options) => {
|
|
@@ -47537,9 +47910,9 @@ var init_agent_tool_server = __esm({
|
|
|
47537
47910
|
response.writeHead(HTTP_STATUS.BAD_REQUEST).end();
|
|
47538
47911
|
}
|
|
47539
47912
|
});
|
|
47540
|
-
await new Promise((
|
|
47913
|
+
await new Promise((resolve17, reject) => {
|
|
47541
47914
|
server.once("error", reject);
|
|
47542
|
-
server.listen(0, "127.0.0.1",
|
|
47915
|
+
server.listen(0, "127.0.0.1", resolve17);
|
|
47543
47916
|
});
|
|
47544
47917
|
const address = server.address();
|
|
47545
47918
|
if (!address || typeof address === "string") throw new Error(code("listen_failed"));
|
|
@@ -47551,7 +47924,7 @@ var init_agent_tool_server = __esm({
|
|
|
47551
47924
|
descriptor: { type: "http", name: "vtx", url: `http://127.0.0.1:${address.port}/${token}`, headers: [] },
|
|
47552
47925
|
close: async () => {
|
|
47553
47926
|
server.closeAllConnections();
|
|
47554
|
-
await new Promise((
|
|
47927
|
+
await new Promise((resolve17) => server.close(() => resolve17()));
|
|
47555
47928
|
}
|
|
47556
47929
|
};
|
|
47557
47930
|
};
|
|
@@ -47755,11 +48128,11 @@ var init_grok_runtime = __esm({
|
|
|
47755
48128
|
this.child.kill();
|
|
47756
48129
|
}
|
|
47757
48130
|
});
|
|
47758
|
-
this.exit = new Promise((
|
|
48131
|
+
this.exit = new Promise((resolve17) => {
|
|
47759
48132
|
this.child.once("error", () => this.fail(new Error("grok_process_start_failed")));
|
|
47760
48133
|
this.child.once("close", () => {
|
|
47761
48134
|
this.fail(new Error("grok_process_closed"));
|
|
47762
|
-
|
|
48135
|
+
resolve17();
|
|
47763
48136
|
});
|
|
47764
48137
|
});
|
|
47765
48138
|
}
|
|
@@ -47779,8 +48152,8 @@ var init_grok_runtime = __esm({
|
|
|
47779
48152
|
let timer;
|
|
47780
48153
|
let abort;
|
|
47781
48154
|
try {
|
|
47782
|
-
return await new Promise((
|
|
47783
|
-
this.pending.set(id2, { resolve:
|
|
48155
|
+
return await new Promise((resolve17, reject) => {
|
|
48156
|
+
this.pending.set(id2, { resolve: resolve17, reject });
|
|
47784
48157
|
timer = setTimeout(() => reject(new Error("grok_deadline_exceeded")), Math.max(1, deadlineAtMs - Date.now()));
|
|
47785
48158
|
abort = () => reject(new Error("grok_cancelled"));
|
|
47786
48159
|
signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -47814,7 +48187,7 @@ var init_grok_runtime = __esm({
|
|
|
47814
48187
|
// lib/inference-host/grok-state.ts
|
|
47815
48188
|
import { constants as constants2 } from "node:fs";
|
|
47816
48189
|
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
|
|
48190
|
+
import { basename as basename4, dirname as dirname11, join as join12, resolve as resolve8 } from "node:path";
|
|
47818
48191
|
var HOST_RUNTIME_POLICY10, markerName, ownedName, invalid, missing, sessionIdValid, directory, nativeDirectory, roots, owner, nativeFile, encodedCwd, nativeSession, removeEmptyNativeGroup, createGrokOwnedWorkspace, bindGrokOwnedSession, validateGrokOwnedThread, releaseGrokOwnedWorkspace, cleanupGrokOwnedState;
|
|
47819
48192
|
var init_grok_state = __esm({
|
|
47820
48193
|
"lib/inference-host/grok-state.ts"() {
|
|
@@ -47835,12 +48208,12 @@ var init_grok_state = __esm({
|
|
|
47835
48208
|
sessionIdValid = (id2) => /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/u.test(id2);
|
|
47836
48209
|
directory = async (path) => {
|
|
47837
48210
|
const info = await lstat8(path);
|
|
47838
|
-
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !==
|
|
48211
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !== resolve8(path)) throw invalid();
|
|
47839
48212
|
await ensureInferencePrivateDirectory(path);
|
|
47840
48213
|
};
|
|
47841
48214
|
nativeDirectory = async (path) => {
|
|
47842
48215
|
const info = await lstat8(path);
|
|
47843
|
-
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !==
|
|
48216
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await realpath7(path) !== resolve8(path)) throw invalid();
|
|
47844
48217
|
if (process.platform === "win32") {
|
|
47845
48218
|
await secureWindowsPrivatePath(path, "directory", "verify-owner");
|
|
47846
48219
|
await secureWindowsPrivatePath(path, "directory", "harden");
|
|
@@ -47848,15 +48221,15 @@ var init_grok_state = __esm({
|
|
|
47848
48221
|
await directory(path);
|
|
47849
48222
|
};
|
|
47850
48223
|
roots = async (options) => {
|
|
47851
|
-
const stateRoot =
|
|
47852
|
-
const grokHome =
|
|
48224
|
+
const stateRoot = resolve8(options.stateRoot);
|
|
48225
|
+
const grokHome = resolve8(options.grokHome);
|
|
47853
48226
|
await directory(stateRoot);
|
|
47854
48227
|
await directory(grokHome);
|
|
47855
48228
|
return { stateRoot, grokHome, workspaceRoot: join12(stateRoot, "grok-workspaces") };
|
|
47856
48229
|
};
|
|
47857
48230
|
owner = async (options, workspace) => {
|
|
47858
48231
|
const scope = await roots(options);
|
|
47859
|
-
if (workspace !==
|
|
48232
|
+
if (workspace !== resolve8(workspace) || dirname11(workspace) !== scope.workspaceRoot || !ownedName.test(basename4(workspace))) throw invalid();
|
|
47860
48233
|
await directory(scope.workspaceRoot);
|
|
47861
48234
|
await directory(workspace);
|
|
47862
48235
|
const raw = await readInferencePrivateFile(join12(workspace, markerName), "Grok workspace owner");
|
|
@@ -47902,7 +48275,7 @@ var init_grok_state = __esm({
|
|
|
47902
48275
|
for (const entry of await readdir6(sessions, { withFileTypes: true })) {
|
|
47903
48276
|
if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
|
|
47904
48277
|
const group = join12(sessions, entry.name);
|
|
47905
|
-
if (await realpath7(group) !==
|
|
48278
|
+
if (await realpath7(group) !== resolve8(group)) throw invalid();
|
|
47906
48279
|
try {
|
|
47907
48280
|
if ((await nativeFile(join12(group, ".cwd"), HOST_RUNTIME_POLICY10.grok_cwd_marker_max_bytes)).trim() === value.workspace) groups2.push(group);
|
|
47908
48281
|
} catch (error48) {
|
|
@@ -48006,7 +48379,7 @@ var init_grok_state = __esm({
|
|
|
48006
48379
|
};
|
|
48007
48380
|
releaseGrokOwnedWorkspace = async (options, workspace, expectedSessionId) => {
|
|
48008
48381
|
const scope = await roots(options);
|
|
48009
|
-
if (workspace !==
|
|
48382
|
+
if (workspace !== resolve8(workspace) || dirname11(workspace) !== scope.workspaceRoot || !ownedName.test(basename4(workspace))) throw invalid();
|
|
48010
48383
|
await directory(scope.workspaceRoot);
|
|
48011
48384
|
try {
|
|
48012
48385
|
await lstat8(workspace);
|
|
@@ -48021,7 +48394,7 @@ var init_grok_state = __esm({
|
|
|
48021
48394
|
await owner(options, workspace);
|
|
48022
48395
|
if (await nativeSession(value, false) !== session) throw invalid();
|
|
48023
48396
|
await removeOwnedDirectory(session);
|
|
48024
|
-
await removeEmptyNativeGroup(
|
|
48397
|
+
await removeEmptyNativeGroup(dirname11(session), workspace);
|
|
48025
48398
|
}
|
|
48026
48399
|
await owner(options, workspace);
|
|
48027
48400
|
await removeOwnedDirectory(workspace);
|
|
@@ -48500,7 +48873,8 @@ var init_grok_adapter = __esm({
|
|
|
48500
48873
|
retryable: false,
|
|
48501
48874
|
dispatchOutcome: outcome,
|
|
48502
48875
|
grokToolValidation: proxy?.toolValidationFailure ?? null,
|
|
48503
|
-
grokResponseIdentity: proxy?.responseIdentityFailure ?? null
|
|
48876
|
+
grokResponseIdentity: proxy?.responseIdentityFailure ?? null,
|
|
48877
|
+
cause: error48
|
|
48504
48878
|
});
|
|
48505
48879
|
} finally {
|
|
48506
48880
|
try {
|
|
@@ -48610,7 +48984,7 @@ var init_claude_code_schema = __esm({
|
|
|
48610
48984
|
|
|
48611
48985
|
// lib/inference-host/claude-code-policy.ts
|
|
48612
48986
|
import { readFile as readFile9 } from "node:fs/promises";
|
|
48613
|
-
import { dirname as
|
|
48987
|
+
import { dirname as dirname12, resolve as resolve9 } from "node:path";
|
|
48614
48988
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
48615
48989
|
var CLAUDE_CODE_EFFORTS, turns, validateClaudeCodePolicy, loadClaudeCodePolicy, compareClaudeCodeVersions;
|
|
48616
48990
|
var init_claude_code_policy = __esm({
|
|
@@ -48642,7 +49016,7 @@ var init_claude_code_policy = __esm({
|
|
|
48642
49016
|
};
|
|
48643
49017
|
loadClaudeCodePolicy = async () => {
|
|
48644
49018
|
if (typeof define_VTX_CLAUDE_CODE_POLICY_default !== "undefined") return validateClaudeCodePolicy(define_VTX_CLAUDE_CODE_POLICY_default);
|
|
48645
|
-
const config2 = parse(await readFile9(
|
|
49019
|
+
const config2 = parse(await readFile9(resolve9(dirname12(fileURLToPath2(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
48646
49020
|
return validateClaudeCodePolicy(config2.external_inference?.claude_code_adapter);
|
|
48647
49021
|
};
|
|
48648
49022
|
compareClaudeCodeVersions = (left, right) => {
|
|
@@ -48661,7 +49035,7 @@ var init_claude_code_policy = __esm({
|
|
|
48661
49035
|
import { spawn as spawn9 } from "node:child_process";
|
|
48662
49036
|
import { access as access4, lstat as lstat9, readdir as readdir7, rm as rm12 } from "node:fs/promises";
|
|
48663
49037
|
import { constants as constants3 } from "node:fs";
|
|
48664
|
-
import { delimiter, isAbsolute as
|
|
49038
|
+
import { delimiter, isAbsolute as isAbsolute7, join as join14 } from "node:path";
|
|
48665
49039
|
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
49040
|
var init_claude_code_runtime = __esm({
|
|
48667
49041
|
"lib/inference-host/claude-code-runtime.ts"() {
|
|
@@ -48733,7 +49107,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48733
49107
|
findClaudeCodeExecutable = async (env = process.env) => {
|
|
48734
49108
|
const explicit = String(env.VTX_CLAUDE_CODE_BIN || "").trim();
|
|
48735
49109
|
if (explicit) {
|
|
48736
|
-
if (!
|
|
49110
|
+
if (!isAbsolute7(explicit) || !await executable(explicit)) throw new Error("VTX_CLAUDE_CODE_BIN must name an absolute, executable Claude Code CLI.");
|
|
48737
49111
|
return explicit;
|
|
48738
49112
|
}
|
|
48739
49113
|
for (const directory2 of String(env.PATH || "").split(delimiter).filter(Boolean)) {
|
|
@@ -48744,7 +49118,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48744
49118
|
}
|
|
48745
49119
|
throw new Error("Claude Code is not installed. Install it from https://code.claude.com, then run claude-login again.");
|
|
48746
49120
|
};
|
|
48747
|
-
runCommand = (binaryPath, args, options) => new Promise((
|
|
49121
|
+
runCommand = (binaryPath, args, options) => new Promise((resolve17, reject) => {
|
|
48748
49122
|
options.signal?.throwIfAborted();
|
|
48749
49123
|
const child = spawn9(binaryPath, args, { cwd: options.cwd, env: options.env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
48750
49124
|
let stdout = "";
|
|
@@ -48757,7 +49131,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48757
49131
|
clearTimeout(timer);
|
|
48758
49132
|
options.signal?.removeEventListener("abort", abort);
|
|
48759
49133
|
if (error48) reject(error48);
|
|
48760
|
-
else
|
|
49134
|
+
else resolve17(result);
|
|
48761
49135
|
};
|
|
48762
49136
|
const kill = (reason) => {
|
|
48763
49137
|
child.kill("SIGKILL");
|
|
@@ -48864,7 +49238,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48864
49238
|
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
49239
|
}
|
|
48866
49240
|
options.signal?.throwIfAborted();
|
|
48867
|
-
await new Promise((
|
|
49241
|
+
await new Promise((resolve17, reject) => {
|
|
48868
49242
|
const child = spawn9(binary.path, ["auth", action, ...action === "login" ? ["--claudeai"] : []], {
|
|
48869
49243
|
cwd: options.stateRoot,
|
|
48870
49244
|
env: action === "login" ? claudeCodeLoginEnvironment(options.configDir) : claudeCodeRuntimeEnvironment(options.configDir),
|
|
@@ -48921,7 +49295,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48921
49295
|
input?.removeListener("data", forward);
|
|
48922
49296
|
input?.pause();
|
|
48923
49297
|
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
|
|
49298
|
+
else resolve17();
|
|
48925
49299
|
});
|
|
48926
49300
|
});
|
|
48927
49301
|
return binary;
|
|
@@ -48995,7 +49369,7 @@ var init_claude_code_runtime = __esm({
|
|
|
48995
49369
|
import { spawn as spawn10 } from "node:child_process";
|
|
48996
49370
|
import { createHash as createHash10, randomUUID as randomUUID10 } from "node:crypto";
|
|
48997
49371
|
import { lstat as lstat10, mkdtemp as mkdtemp5, realpath as realpath8, rm as rm13 } from "node:fs/promises";
|
|
48998
|
-
import { basename as basename5, dirname as
|
|
49372
|
+
import { basename as basename5, dirname as dirname13, join as join15, resolve as resolve10 } from "node:path";
|
|
48999
49373
|
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
49374
|
var init_claude_code_adapter = __esm({
|
|
49001
49375
|
"lib/inference-host/claude-code-adapter.ts"() {
|
|
@@ -49103,7 +49477,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49103
49477
|
this.options = options;
|
|
49104
49478
|
}
|
|
49105
49479
|
get workspaceRoot() {
|
|
49106
|
-
return join15(
|
|
49480
|
+
return join15(resolve10(this.options.stateRoot), WORKSPACES);
|
|
49107
49481
|
}
|
|
49108
49482
|
async binary() {
|
|
49109
49483
|
await ensureInferencePrivateDirectory(this.options.stateRoot);
|
|
@@ -49132,7 +49506,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49132
49506
|
`);
|
|
49133
49507
|
}
|
|
49134
49508
|
async owner(workspace) {
|
|
49135
|
-
if (workspace !==
|
|
49509
|
+
if (workspace !== resolve10(workspace) || dirname13(workspace) !== this.workspaceRoot || !OWNED_WORKSPACE.test(basename5(workspace))) throw notOwned();
|
|
49136
49510
|
const info = await lstat10(workspace);
|
|
49137
49511
|
if (!info.isDirectory() || info.isSymbolicLink() || await realpath8(workspace) !== workspace) throw notOwned();
|
|
49138
49512
|
let value;
|
|
@@ -49159,7 +49533,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49159
49533
|
signal.throwIfAborted();
|
|
49160
49534
|
const status = await readClaudeCodeAuthStatus(binary, { ...this.options, signal });
|
|
49161
49535
|
try {
|
|
49162
|
-
assertClaudeCodeSubscription(status,
|
|
49536
|
+
assertClaudeCodeSubscription(status, resolve10(this.options.configDir));
|
|
49163
49537
|
} catch (error48) {
|
|
49164
49538
|
throw new CodexAppServerError({
|
|
49165
49539
|
message: error48.message,
|
|
@@ -49222,7 +49596,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49222
49596
|
}
|
|
49223
49597
|
const workspace = resumed?.threadPath ?? await this.createWorkspace(agent ? "agent" : "attempt");
|
|
49224
49598
|
const sessionId = resumed?.threadId ?? (agent ? randomUUID10() : null);
|
|
49225
|
-
const resumable = resumed !== null && await claudeCodeSessionTranscriptExists(
|
|
49599
|
+
const resumable = resumed !== null && await claudeCodeSessionTranscriptExists(resolve10(this.options.configDir), resumed.threadId);
|
|
49226
49600
|
let retained = Boolean(resumed);
|
|
49227
49601
|
let tools = null;
|
|
49228
49602
|
let child = null;
|
|
@@ -49349,7 +49723,7 @@ var init_claude_code_adapter = __esm({
|
|
|
49349
49723
|
windowsHide: true
|
|
49350
49724
|
}));
|
|
49351
49725
|
provider?.onProviderDispatch?.();
|
|
49352
|
-
child = spawnProcess(binary.path, args, { cwd: workspace, env: claudeCodeRuntimeEnvironment(
|
|
49726
|
+
child = spawnProcess(binary.path, args, { cwd: workspace, env: claudeCodeRuntimeEnvironment(resolve10(this.options.configDir)) });
|
|
49353
49727
|
this.active.add(child);
|
|
49354
49728
|
const running = child;
|
|
49355
49729
|
const result = await new Promise((resolveResult, rejectResult) => {
|
|
@@ -49558,7 +49932,8 @@ var init_claude_code_adapter = __esm({
|
|
|
49558
49932
|
category: signal.aborted ? "cancelled" : Date.now() >= original.deadlineAtMs ? "timeout" : code === "claude_code_subscription_required" ? "auth" : "adapter",
|
|
49559
49933
|
code,
|
|
49560
49934
|
retryable: false,
|
|
49561
|
-
dispatchOutcome: outcome
|
|
49935
|
+
dispatchOutcome: outcome,
|
|
49936
|
+
cause: error48
|
|
49562
49937
|
});
|
|
49563
49938
|
} finally {
|
|
49564
49939
|
if (child) this.active.delete(child);
|
|
@@ -49610,7 +49985,7 @@ var init_grok_auth = __esm({
|
|
|
49610
49985
|
await prepareGrokHome(options.grokHome);
|
|
49611
49986
|
const binary = await resolvePinnedGrokBinary(options.stateRoot);
|
|
49612
49987
|
options.signal?.throwIfAborted();
|
|
49613
|
-
await new Promise((
|
|
49988
|
+
await new Promise((resolve17, reject) => {
|
|
49614
49989
|
const child = spawn11(binary.path, ["--no-auto-update", action, ...action === "login" ? ["--device-auth"] : []], {
|
|
49615
49990
|
cwd: options.grokHome,
|
|
49616
49991
|
env: grokRuntimeEnvironment(options.grokHome),
|
|
@@ -49672,7 +50047,7 @@ var init_grok_auth = __esm({
|
|
|
49672
50047
|
child.once("close", (code) => {
|
|
49673
50048
|
cleanup();
|
|
49674
50049
|
if (code !== 0 || failed2 || options.signal?.aborted) reject(new Error(`Grok ${action} did not complete. Run grok-${action} again.`));
|
|
49675
|
-
else
|
|
50050
|
+
else resolve17();
|
|
49676
50051
|
});
|
|
49677
50052
|
if (options.signal?.aborted) stop();
|
|
49678
50053
|
});
|
|
@@ -49685,7 +50060,7 @@ import { spawn as spawn12 } from "node:child_process";
|
|
|
49685
50060
|
import { randomUUID as randomUUID11, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
49686
50061
|
import { createServer as createServer5 } from "node:http";
|
|
49687
50062
|
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
|
|
50063
|
+
import { basename as basename6, dirname as dirname14, join as join16, resolve as resolve11 } from "node:path";
|
|
49689
50064
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
49690
50065
|
var import_ajv3, HOST_RUNTIME_POLICY15, failure, object5, validModel, receiptUsage, assertOwnedRuntime, cleanupExoOwnedState, ExoForegroundAdapter;
|
|
49691
50066
|
var init_exo_adapter = __esm({
|
|
@@ -49802,7 +50177,7 @@ var init_exo_adapter = __esm({
|
|
|
49802
50177
|
environment(runtimeRoot) {
|
|
49803
50178
|
return {
|
|
49804
50179
|
NODE_ENV: "production",
|
|
49805
|
-
PATH: `${
|
|
50180
|
+
PATH: `${dirname14(process.execPath)}:/usr/local/bin:/usr/bin:/bin`,
|
|
49806
50181
|
HOME: runtimeRoot,
|
|
49807
50182
|
XDG_CONFIG_HOME: join16(runtimeRoot, "config"),
|
|
49808
50183
|
TMPDIR: runtimeRoot,
|
|
@@ -49859,8 +50234,8 @@ var init_exo_adapter = __esm({
|
|
|
49859
50234
|
}
|
|
49860
50235
|
async ownedRoot(thread) {
|
|
49861
50236
|
const parent = await realpath9(this.options.stateRoot);
|
|
49862
|
-
const root =
|
|
49863
|
-
if (!/^[a-f0-9-]{36}$/u.test(thread.threadId) ||
|
|
50237
|
+
const root = resolve11(thread.threadPath);
|
|
50238
|
+
if (!/^[a-f0-9-]{36}$/u.test(thread.threadId) || dirname14(root) !== parent || basename6(root) !== `agent-${thread.threadId}`) throw failure("exo_thread_not_owned");
|
|
49864
50239
|
await assertOwnedRuntime(root, thread.threadId);
|
|
49865
50240
|
return root;
|
|
49866
50241
|
}
|
|
@@ -50099,7 +50474,7 @@ var init_exo_adapter = __esm({
|
|
|
50099
50474
|
|
|
50100
50475
|
// lib/inference-host/exo-policy.ts
|
|
50101
50476
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
50102
|
-
import { dirname as
|
|
50477
|
+
import { dirname as dirname15, resolve as resolve12 } from "node:path";
|
|
50103
50478
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
50104
50479
|
var validateExoPolicy, loadExoPolicy;
|
|
50105
50480
|
var init_exo_policy = __esm({
|
|
@@ -50134,7 +50509,7 @@ var init_exo_policy = __esm({
|
|
|
50134
50509
|
};
|
|
50135
50510
|
loadExoPolicy = async () => {
|
|
50136
50511
|
if (typeof define_VTX_EXO_POLICY_default !== "undefined") return validateExoPolicy(define_VTX_EXO_POLICY_default);
|
|
50137
|
-
const config2 = parse(await readFile10(
|
|
50512
|
+
const config2 = parse(await readFile10(resolve12(dirname15(fileURLToPath4(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
50138
50513
|
const endpoints = config2.llm?.openai_compatible?.endpoints;
|
|
50139
50514
|
return validateExoPolicy({
|
|
50140
50515
|
...config2.external_inference?.exo_adapter,
|
|
@@ -50312,7 +50687,7 @@ var init_exo_credential_store = __esm({
|
|
|
50312
50687
|
|
|
50313
50688
|
// lib/inference-host/pi-model-policy.ts
|
|
50314
50689
|
import { readFile as readFile11 } from "node:fs/promises";
|
|
50315
|
-
import { dirname as
|
|
50690
|
+
import { dirname as dirname16, resolve as resolve13 } from "node:path";
|
|
50316
50691
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
50317
50692
|
var validatePiModelPolicy, loadPiModelPolicy;
|
|
50318
50693
|
var init_pi_model_policy = __esm({
|
|
@@ -50341,7 +50716,7 @@ var init_pi_model_policy = __esm({
|
|
|
50341
50716
|
if (typeof define_VTX_PI_MODEL_POLICY_default !== "undefined") {
|
|
50342
50717
|
return validatePiModelPolicy(define_VTX_PI_MODEL_POLICY_default);
|
|
50343
50718
|
}
|
|
50344
|
-
const config2 = parse(await readFile11(
|
|
50719
|
+
const config2 = parse(await readFile11(resolve13(dirname16(fileURLToPath5(import.meta.url)), "../../../config.toml"), "utf8"));
|
|
50345
50720
|
const external = config2.external_inference;
|
|
50346
50721
|
const pi = external?.pi_adapter;
|
|
50347
50722
|
return validatePiModelPolicy(pi?.qualified_models);
|
|
@@ -50700,7 +51075,7 @@ var init_durable_adapter = __esm({
|
|
|
50700
51075
|
|
|
50701
51076
|
// lib/inference-host/service-launcher-state.ts
|
|
50702
51077
|
import { access as access6, readFile as readFile12, rm as rm15 } from "node:fs/promises";
|
|
50703
|
-
import { dirname as
|
|
51078
|
+
import { dirname as dirname17, isAbsolute as isAbsolute8, join as join17, relative as relative5, resolve as resolve14 } from "node:path";
|
|
50704
51079
|
var launcherSibling, launcherLockPath, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
|
|
50705
51080
|
var init_service_launcher_state = __esm({
|
|
50706
51081
|
"lib/inference-host/service-launcher-state.ts"() {
|
|
@@ -50716,13 +51091,13 @@ var init_service_launcher_state = __esm({
|
|
|
50716
51091
|
};
|
|
50717
51092
|
launcherLockPath = (manifest) => launcherSibling(manifest, ".service-launcher.lock");
|
|
50718
51093
|
within = (parent, child) => {
|
|
50719
|
-
const part =
|
|
50720
|
-
return Boolean(part) && !part.startsWith("..") && !
|
|
51094
|
+
const part = relative5(resolve14(parent), resolve14(child));
|
|
51095
|
+
return Boolean(part) && !part.startsWith("..") && !isAbsolute8(part);
|
|
50721
51096
|
};
|
|
50722
51097
|
launcherSelection = (manifest, value) => {
|
|
50723
51098
|
if (!value || typeof value !== "object") return null;
|
|
50724
51099
|
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" || !
|
|
51100
|
+
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
51101
|
return r;
|
|
50727
51102
|
};
|
|
50728
51103
|
readLauncherSelection = async (manifest) => {
|
|
@@ -50746,9 +51121,9 @@ var init_service_launcher_state = __esm({
|
|
|
50746
51121
|
const target = (v) => {
|
|
50747
51122
|
if (!v || typeof v !== "object") return false;
|
|
50748
51123
|
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" &&
|
|
51124
|
+
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
51125
|
const selected = launcherSelection(manifest, t.selection);
|
|
50751
|
-
return Boolean(selected && selected.package_version === t.package_version && (
|
|
51126
|
+
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
51127
|
})());
|
|
50753
51128
|
};
|
|
50754
51129
|
if (r.schema_version !== "vtx_inference_service_launcher_v1" || !target(r.active) || r.previous !== null && !target(r.previous) || typeof r.pending !== "boolean") {
|
|
@@ -50761,7 +51136,7 @@ var init_service_launcher_state = __esm({
|
|
|
50761
51136
|
`);
|
|
50762
51137
|
};
|
|
50763
51138
|
targetForSelection = async (selection) => {
|
|
50764
|
-
const script = join17(
|
|
51139
|
+
const script = join17(dirname17(selection.script), "vtx-service-bootstrap.js");
|
|
50765
51140
|
await access6(script);
|
|
50766
51141
|
return { package_version: selection.package_version, script, selection };
|
|
50767
51142
|
};
|
|
@@ -50774,7 +51149,7 @@ import { randomUUID as randomUUID12 } from "node:crypto";
|
|
|
50774
51149
|
import { createReadStream, createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
50775
51150
|
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
51151
|
import { homedir as homedir4 } from "node:os";
|
|
50777
|
-
import { dirname as
|
|
51152
|
+
import { dirname as dirname18, join as join18, resolve as resolve15 } from "node:path";
|
|
50778
51153
|
import { Transform } from "node:stream";
|
|
50779
51154
|
import { pipeline } from "node:stream/promises";
|
|
50780
51155
|
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 +51584,10 @@ WantedBy=default.target
|
|
|
51209
51584
|
this.config = config2;
|
|
51210
51585
|
this.platform = dependencies.platform ?? process.platform;
|
|
51211
51586
|
this.home = dependencies.homedir ?? homedir4();
|
|
51212
|
-
this.executable =
|
|
51213
|
-
this.script =
|
|
51214
|
-
this.bootstrapScript =
|
|
51215
|
-
dependencies.bootstrapScript ?? join18(
|
|
51587
|
+
this.executable = resolve15(dependencies.executable ?? process.execPath);
|
|
51588
|
+
this.script = resolve15(dependencies.script ?? process.argv[1] ?? "");
|
|
51589
|
+
this.bootstrapScript = resolve15(
|
|
51590
|
+
dependencies.bootstrapScript ?? join18(dirname18(this.script), "vtx-service-launcher.js")
|
|
51216
51591
|
);
|
|
51217
51592
|
this.username = dependencies.username ?? ([process.env.USERDOMAIN, process.env.USERNAME].filter(Boolean).join("\\") || process.env.USER || "");
|
|
51218
51593
|
this.windowsDirectory = (dependencies.windowsDirectory ?? process.env.SystemRoot ?? process.env.WINDIR ?? "C:\\Windows").replace(/[\\/]+$/u, "");
|
|
@@ -51456,7 +51831,7 @@ ${result.stderr}`)) {
|
|
|
51456
51831
|
if (this.bootstrapScript.endsWith("vtx-service-launcher.js") && !existingRecovery) {
|
|
51457
51832
|
await probeInferenceHostLauncher(manifest.executable, this.serviceBootstrapPath(), launcherBytes, this.runCommand);
|
|
51458
51833
|
const core = launcherSibling(this.manifestPath(), ".service-bootstrap.previous.js");
|
|
51459
|
-
const coreBytes = await readFile13(join18(
|
|
51834
|
+
const coreBytes = await readFile13(join18(dirname18(this.bootstrapScript), "vtx-service-bootstrap.js"), "utf8");
|
|
51460
51835
|
await probeInferenceHostLauncher(manifest.executable, core, coreBytes, this.runCommand);
|
|
51461
51836
|
await writeAtomicInferencePrivateFile(core, coreBytes);
|
|
51462
51837
|
await writeLauncherState(this.manifestPath(), {
|
|
@@ -51468,7 +51843,7 @@ ${result.stderr}`)) {
|
|
|
51468
51843
|
}
|
|
51469
51844
|
if (!existingRecovery) await writeAtomicInferencePrivateFile(this.serviceBootstrapPath(), launcherBytes);
|
|
51470
51845
|
await chmod4(this.serviceBootstrapPath(), OWNER_ONLY_DIRECTORY_MODE);
|
|
51471
|
-
await mkdir5(
|
|
51846
|
+
await mkdir5(dirname18(this.definitionPath()), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
51472
51847
|
if (this.platform === "win32") {
|
|
51473
51848
|
await writeAtomicInferencePrivateFile(
|
|
51474
51849
|
this.windowsLauncherPath(),
|
|
@@ -51658,7 +52033,7 @@ ${cleanup.stderr}`)) {
|
|
|
51658
52033
|
}
|
|
51659
52034
|
if (this.config.credentialFilePath && otherWorkers.some((worker) => {
|
|
51660
52035
|
const otherPath = worker.runtime_environment.VTX_INFERENCE_HOST_CREDENTIAL_FILE;
|
|
51661
|
-
return otherPath &&
|
|
52036
|
+
return otherPath && resolve15(otherPath) === resolve15(this.config.credentialFilePath);
|
|
51662
52037
|
})) {
|
|
51663
52038
|
throw new Error(
|
|
51664
52039
|
"Each inference-host instance must use a different private credential file."
|
|
@@ -51901,9 +52276,9 @@ ${result.stderr}`)) {
|
|
|
51901
52276
|
}
|
|
51902
52277
|
}
|
|
51903
52278
|
async status(confirmedRuntime) {
|
|
51904
|
-
const manifest = await
|
|
52279
|
+
const manifest = await readManifestAcrossAtomicReplacement(this.manifestPath());
|
|
51905
52280
|
const runtime = confirmedRuntime?.manifest_generation === manifest?.generation ? confirmedRuntime : await readRuntimeAcrossAtomicReplacement(this.runtimePath()).catch(() => null);
|
|
51906
|
-
const desired = await
|
|
52281
|
+
const desired = await readDesiredAcrossAtomicReplacement(this.desiredPath());
|
|
51907
52282
|
const result = await this.managerCommand("status");
|
|
51908
52283
|
const output3 = result.stdout.trim();
|
|
51909
52284
|
const managerActive = result.exitCode === 0 && (this.platform === "linux" ? /(?:^|\n)ActiveState=active(?:\n|$)/u.test(output3) : this.platform === "win32" ? output3.trim() === "4" : /\bstate\s*=\s*running\b/iu.test(output3));
|
|
@@ -52056,7 +52431,7 @@ ${result.stderr}`)) {
|
|
|
52056
52431
|
const state2 = sink;
|
|
52057
52432
|
const write = state2.tail.then(async () => {
|
|
52058
52433
|
if (state2.bytes === null) {
|
|
52059
|
-
await mkdir5(
|
|
52434
|
+
await mkdir5(dirname18(path), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
52060
52435
|
state2.bytes = await serviceLogSize(path);
|
|
52061
52436
|
}
|
|
52062
52437
|
await appendFile2(path, text2, { encoding: "utf8", mode: OWNER_ONLY_FILE_MODE });
|
|
@@ -52209,7 +52584,7 @@ ${result.stderr}`)) {
|
|
|
52209
52584
|
runInferenceHostServiceSupervisor = async (manifestPath, options = {}) => {
|
|
52210
52585
|
const storedInitialManifest = await readInferenceHostServiceManifest(manifestPath);
|
|
52211
52586
|
if (!storedInitialManifest) throw new Error("Inference-host service manifest is missing.");
|
|
52212
|
-
const serviceScript = options.serviceScript ?
|
|
52587
|
+
const serviceScript = options.serviceScript ? resolve15(options.serviceScript) : null;
|
|
52213
52588
|
const withServiceScript = (manifest) => serviceScript ? { ...manifest, script: serviceScript } : manifest;
|
|
52214
52589
|
const initialManifest = withServiceScript(storedInitialManifest);
|
|
52215
52590
|
const desiredPath = manifestPath.replace(/\.service\.json$/u, ".service-desired.json");
|
|
@@ -52247,10 +52622,10 @@ ${result.stderr}`)) {
|
|
|
52247
52622
|
const current = await readManifestAcrossAtomicReplacement(manifestPath);
|
|
52248
52623
|
if (!current || current.generation !== appliedManifest.generation || !await readDesiredAcrossAtomicReplacement(desiredPath) || signal.aborted) return;
|
|
52249
52624
|
const selected = await readLauncherSelection(manifestPath);
|
|
52250
|
-
if (!selected || selected.package_version !== agent_cli_release_default.package_version ||
|
|
52625
|
+
if (!selected || selected.package_version !== agent_cli_release_default.package_version || resolve15(selected.script) !== serviceScript) return;
|
|
52251
52626
|
if (process.env.VTX_INFERENCE_HOST_LAUNCHER_PROTOCOL !== "1") {
|
|
52252
52627
|
const launcherPath = launcherSibling(manifestPath, ".service-bootstrap.js");
|
|
52253
|
-
const bytes3 = await readFile13(join18(
|
|
52628
|
+
const bytes3 = await readFile13(join18(dirname18(serviceScript), "vtx-service-launcher.js"), "utf8");
|
|
52254
52629
|
await (options.probeLauncher ?? probeInferenceHostLauncher)(current.executable, launcherPath, bytes3);
|
|
52255
52630
|
const existing = await readLauncherState(manifestPath);
|
|
52256
52631
|
if (!existing) throw new Error("Previous private service release is unavailable; refusing unsafe launcher migration.");
|
|
@@ -52533,7 +52908,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
52533
52908
|
import { spawn as spawn14 } from "node:child_process";
|
|
52534
52909
|
import { lstat as lstat12, realpath as realpath10, rm as rm17 } from "node:fs/promises";
|
|
52535
52910
|
import { hostname as osHostname } from "node:os";
|
|
52536
|
-
import { join as join19, resolve as
|
|
52911
|
+
import { join as join19, resolve as resolve16 } from "node:path";
|
|
52537
52912
|
async function runInferenceHostCli(argv2, env = process.env, dependencies = {}) {
|
|
52538
52913
|
const warnings = [];
|
|
52539
52914
|
try {
|
|
@@ -52962,7 +53337,7 @@ Durable service:
|
|
|
52962
53337
|
if (!raw?.trim()) throw new Error(`${argument} requires a value.`);
|
|
52963
53338
|
if (argument === "--adapter") adapter = raw.trim();
|
|
52964
53339
|
if (argument === "--provider") providerId = raw.trim();
|
|
52965
|
-
if (argument === "--exo-root") exoRoot =
|
|
53340
|
+
if (argument === "--exo-root") exoRoot = resolve16(raw.trim());
|
|
52966
53341
|
if (argument === "--model") modelId = raw.trim();
|
|
52967
53342
|
if (argument === "--model-label") modelLabel = raw.trim();
|
|
52968
53343
|
if (argument === "--effort") reasoningEffort = raw.trim();
|
|
@@ -52978,7 +53353,7 @@ Durable service:
|
|
|
52978
53353
|
throw new Error(`--lines must be an integer from 1 through ${HOST_RUNTIME_POLICY16.cli_log_lines_max}.`);
|
|
52979
53354
|
}
|
|
52980
53355
|
}
|
|
52981
|
-
if (argument === "--service-manifest") serviceManifestPath =
|
|
53356
|
+
if (argument === "--service-manifest") serviceManifestPath = resolve16(raw.trim());
|
|
52982
53357
|
if (argument === "--instance") {
|
|
52983
53358
|
instanceName = raw.trim();
|
|
52984
53359
|
instanceExplicit = true;
|
|
@@ -53205,7 +53580,7 @@ Durable service:
|
|
|
53205
53580
|
try {
|
|
53206
53581
|
const before = await lstat12(path);
|
|
53207
53582
|
const canonical = await realpath10(path);
|
|
53208
|
-
const isPrivate = before.isFile() && !before.isSymbolicLink() && canonical ===
|
|
53583
|
+
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
53584
|
return { present: true, private: isPrivate };
|
|
53210
53585
|
} catch (error48) {
|
|
53211
53586
|
if (error48.code === "ENOENT") {
|
|
@@ -53226,10 +53601,7 @@ Durable service:
|
|
|
53226
53601
|
"Inference host runtime receipt file"
|
|
53227
53602
|
);
|
|
53228
53603
|
await rm17(codexGuardianReceiptRoot(config2), { recursive: true, force: true });
|
|
53229
|
-
await
|
|
53230
|
-
codexRecoveryPath(config2),
|
|
53231
|
-
"Codex attempt recovery file"
|
|
53232
|
-
);
|
|
53604
|
+
await new FileCodexAttemptRecoveryStore(codexRecoveryPath(config2)).discard();
|
|
53233
53605
|
await clearInferenceAgentAttemptState(config2.statePath);
|
|
53234
53606
|
await clearInferenceAgentNextState(config2.statePath);
|
|
53235
53607
|
await clearInferenceForegroundAgentControlState(config2.statePath);
|
|
@@ -54553,7 +54925,7 @@ Waiting for approval...
|
|
|
54553
54925
|
const session = await agentSession(config2, dependencies, warnings);
|
|
54554
54926
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
54555
54927
|
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
54556
|
-
await new Promise((
|
|
54928
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
54557
54929
|
});
|
|
54558
54930
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
54559
54931
|
while (true) {
|
|
@@ -55156,7 +55528,7 @@ Waiting for approval...
|
|
|
55156
55528
|
}
|
|
55157
55529
|
if (parsed.once && !commandLock) break;
|
|
55158
55530
|
await (dependencies.sleep ?? (async (milliseconds) => {
|
|
55159
|
-
await new Promise((
|
|
55531
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
55160
55532
|
}))(retryDelayMs);
|
|
55161
55533
|
}
|
|
55162
55534
|
return {
|
|
@@ -55185,7 +55557,7 @@ Waiting for approval...
|
|
|
55185
55557
|
const session = await agentSession(config2, dependencies, warnings);
|
|
55186
55558
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
55187
55559
|
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
55188
|
-
await new Promise((
|
|
55560
|
+
await new Promise((resolve17) => setTimeout(resolve17, milliseconds));
|
|
55189
55561
|
});
|
|
55190
55562
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
55191
55563
|
while (true) {
|
|
@@ -55543,7 +55915,7 @@ Waiting for approval...
|
|
|
55543
55915
|
) || 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
55916
|
throw new Error("Inference-host service recovery transaction is invalid.");
|
|
55545
55917
|
}
|
|
55546
|
-
if (
|
|
55918
|
+
if (resolve16(record6.recovery_backup_path) !== resolve16(recoveryBackupPath(config2, record6.transaction_id))) {
|
|
55547
55919
|
throw new Error("Inference-host service recovery backup path is invalid.");
|
|
55548
55920
|
}
|
|
55549
55921
|
return record6;
|
|
@@ -55825,7 +56197,7 @@ Waiting for approval...
|
|
|
55825
56197
|
{
|
|
55826
56198
|
signal: cancellation.signal,
|
|
55827
56199
|
quiesceSignal: cancellation.quiesceSignal,
|
|
55828
|
-
serviceScript:
|
|
56200
|
+
serviceScript: resolve16(process.argv[1] ?? ""),
|
|
55829
56201
|
controlLockPath: `${supervisorConfig.supervisorProcessLockPath}.service-control`
|
|
55830
56202
|
}
|
|
55831
56203
|
);
|
|
@@ -56051,7 +56423,7 @@ Waiting for approval...
|
|
|
56051
56423
|
...selectedEnv,
|
|
56052
56424
|
...retainedEnvironment
|
|
56053
56425
|
});
|
|
56054
|
-
if (
|
|
56426
|
+
if (resolve16(installedConfig.statePath) !== resolve16(baseConfig.statePath)) {
|
|
56055
56427
|
throw new Error(
|
|
56056
56428
|
"Installed inference-host service manifest does not match the requested local state path."
|
|
56057
56429
|
);
|
|
@@ -56478,7 +56850,7 @@ import {
|
|
|
56478
56850
|
writeFileSync
|
|
56479
56851
|
} from "node:fs";
|
|
56480
56852
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
56481
|
-
import { dirname as
|
|
56853
|
+
import { dirname as dirname19 } from "node:path";
|
|
56482
56854
|
function openClientRuntimeProtectionStorage(runtimeStatePath, profileId) {
|
|
56483
56855
|
const path = clientRuntimeProtectionStatePath(runtimeStatePath, profileId);
|
|
56484
56856
|
const storage3 = new FileBackedRuntimeStorage(path);
|
|
@@ -56548,7 +56920,7 @@ var init_protection_storage = __esm({
|
|
|
56548
56920
|
}
|
|
56549
56921
|
}
|
|
56550
56922
|
writeValues(values) {
|
|
56551
|
-
mkdirSync(
|
|
56923
|
+
mkdirSync(dirname19(this.path), { recursive: true, mode: OWNER_ONLY_DIRECTORY_MODE });
|
|
56552
56924
|
const serialized = `${JSON.stringify(values)}
|
|
56553
56925
|
`;
|
|
56554
56926
|
const temporaryPath = `${this.path}.${process.pid}.${randomUUID15()}.tmp`;
|
|
@@ -59213,7 +59585,7 @@ var init_shared = __esm({
|
|
|
59213
59585
|
const readsGzip = noteRequestEncodings(input, response);
|
|
59214
59586
|
return sent !== init2 && refusedUnread(response, readsGzip) ? sendApiRequest(input, init2) : response;
|
|
59215
59587
|
};
|
|
59216
|
-
sleep = (ms) => new Promise((
|
|
59588
|
+
sleep = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
59217
59589
|
DEVICE_CLOCK_HEADER = "X-Device-Clock-Ms";
|
|
59218
59590
|
deviceClockHeader = () => ({ [DEVICE_CLOCK_HEADER]: String(Date.now()) });
|
|
59219
59591
|
API_NO_ROUTE_DETAIL = "Not Found";
|
|
@@ -59252,10 +59624,10 @@ var init_shared = __esm({
|
|
|
59252
59624
|
raceWithAbortSignal = async (promise2, signal) => {
|
|
59253
59625
|
if (!signal) return promise2;
|
|
59254
59626
|
if (signal.aborted) throw toAbortError(signal.reason);
|
|
59255
|
-
return new Promise((
|
|
59627
|
+
return new Promise((resolve17, reject) => {
|
|
59256
59628
|
const onAbort = () => reject(toAbortError(signal.reason));
|
|
59257
59629
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
59258
|
-
promise2.then(
|
|
59630
|
+
promise2.then(resolve17, reject).finally(() => signal.removeEventListener("abort", onAbort));
|
|
59259
59631
|
});
|
|
59260
59632
|
};
|
|
59261
59633
|
shareClientGetRequest = async (key, request, options) => {
|
|
@@ -61252,14 +61624,14 @@ var init_runtime_event_batch = __esm({
|
|
|
61252
61624
|
);
|
|
61253
61625
|
}
|
|
61254
61626
|
};
|
|
61255
|
-
queueRuntimeEvent = (key, body, send) => new Promise((
|
|
61627
|
+
queueRuntimeEvent = (key, body, send) => new Promise((resolve17, reject) => {
|
|
61256
61628
|
let group = groups.get(key);
|
|
61257
61629
|
if (!group) {
|
|
61258
61630
|
group = { events: [], timer: null, sendBatch: send.batch, sendOne: send.one };
|
|
61259
61631
|
groups.set(key, group);
|
|
61260
61632
|
group.timer = setTimeout(() => flush(key), EVENT_BATCH.window_milliseconds);
|
|
61261
61633
|
}
|
|
61262
|
-
group.events.push({ body, resolve:
|
|
61634
|
+
group.events.push({ body, resolve: resolve17, reject });
|
|
61263
61635
|
if (group.events.length >= EVENT_BATCH.max_events) flush(key);
|
|
61264
61636
|
});
|
|
61265
61637
|
eventBody = (payload) => ({
|
|
@@ -62191,7 +62563,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62191
62563
|
checkAbort = (signal) => {
|
|
62192
62564
|
if (signal?.aborted) throw abortError2(signal);
|
|
62193
62565
|
};
|
|
62194
|
-
wait = (ms, signal) => new Promise((
|
|
62566
|
+
wait = (ms, signal) => new Promise((resolve17, reject) => {
|
|
62195
62567
|
checkAbort(signal);
|
|
62196
62568
|
const aborted2 = () => {
|
|
62197
62569
|
clearTimeout(timer);
|
|
@@ -62199,7 +62571,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62199
62571
|
};
|
|
62200
62572
|
const timer = setTimeout(() => {
|
|
62201
62573
|
signal?.removeEventListener("abort", aborted2);
|
|
62202
|
-
|
|
62574
|
+
resolve17();
|
|
62203
62575
|
}, Math.min(ms, SET_TIMEOUT_MAX_DELAY_MS));
|
|
62204
62576
|
signal?.addEventListener("abort", aborted2, { once: true });
|
|
62205
62577
|
});
|
|
@@ -62866,7 +63238,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62866
63238
|
if (!running) break;
|
|
62867
63239
|
promoteHyperliquidPublicPriority(running.priority, priority.value);
|
|
62868
63240
|
setPendingPhase("cache");
|
|
62869
|
-
await new Promise((
|
|
63241
|
+
await new Promise((resolve17, reject) => {
|
|
62870
63242
|
const promoteOwner = (next) => promoteHyperliquidPublicPriority(running.priority, next);
|
|
62871
63243
|
const cleanup = () => {
|
|
62872
63244
|
signal.removeEventListener("abort", aborted2);
|
|
@@ -62880,13 +63252,13 @@ var init_hyperliquid_public_read = __esm({
|
|
|
62880
63252
|
signal.addEventListener("abort", aborted2, { once: true });
|
|
62881
63253
|
running.promise.then(() => {
|
|
62882
63254
|
cleanup();
|
|
62883
|
-
|
|
63255
|
+
resolve17();
|
|
62884
63256
|
});
|
|
62885
63257
|
});
|
|
62886
63258
|
checkAbort(signal);
|
|
62887
63259
|
}
|
|
62888
|
-
pending2.set(key, { promise: new Promise((
|
|
62889
|
-
settled2 =
|
|
63260
|
+
pending2.set(key, { promise: new Promise((resolve17) => {
|
|
63261
|
+
settled2 = resolve17;
|
|
62890
63262
|
}), priority });
|
|
62891
63263
|
}
|
|
62892
63264
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
@@ -63163,8 +63535,8 @@ var init_exchange_mutation_fence = __esm({
|
|
|
63163
63535
|
return operation();
|
|
63164
63536
|
}
|
|
63165
63537
|
let markSettled;
|
|
63166
|
-
const settlement = new Promise((
|
|
63167
|
-
markSettled =
|
|
63538
|
+
const settlement = new Promise((resolve17) => {
|
|
63539
|
+
markSettled = resolve17;
|
|
63168
63540
|
});
|
|
63169
63541
|
const activeSettlements = activeSettlementsByScope.get(normalizedScope) ?? /* @__PURE__ */ new Set();
|
|
63170
63542
|
activeSettlements.add(settlement);
|
|
@@ -63217,7 +63589,7 @@ var init_runtime_handoff = __esm({
|
|
|
63217
63589
|
});
|
|
63218
63590
|
|
|
63219
63591
|
// lib/runtime/provider-observability.ts
|
|
63220
|
-
var MAX_DIAGNOSTIC_LIST_ITEMS, record5, ERROR_TOKEN, ERROR_DOMAIN, ERROR_INPUT, ERROR_ECHO_REDACTIONS, ERROR_PROSE_REDACTIONS, CONTROL_CHARACTER_RUN, WHITESPACE_RUN, collapseProse, settled, REDACTED_MARKER_START, boundedMessage, normalizeProviderError, identifier, count4, normalizeProviderDiagnostics, providerRequestId, hash2, googleCredentialDiagnostics, withExecutionMode, retryAfterDiagnostics, extractProviderDiagnostics, estimateRequestInputTokens;
|
|
63592
|
+
var MAX_DIAGNOSTIC_LIST_ITEMS, record5, ERROR_TOKEN, ERROR_DOMAIN, ERROR_INPUT, ERROR_ECHO_REDACTIONS, ERROR_PROSE_REDACTIONS, CONTROL_CHARACTER_RUN, UNSTORABLE_TEXT, WHITESPACE_RUN, collapseProse, settled, REDACTED_MARKER_START, cutOutsideMarker, boundedMessage, normalizeProviderError, REPLY_POLICY, REPLY_HEADER_NAME, isProviderReplyHeaderName, boundedReplyText, normalizeProviderReply, identifier, count4, normalizeProviderDiagnostics, providerRequestId, hash2, googleCredentialDiagnostics, withExecutionMode, retryAfterDiagnostics, extractProviderDiagnostics, estimateRequestInputTokens;
|
|
63221
63593
|
var init_provider_observability = __esm({
|
|
63222
63594
|
"lib/runtime/provider-observability.ts"() {
|
|
63223
63595
|
"use strict";
|
|
@@ -63227,6 +63599,7 @@ var init_provider_observability = __esm({
|
|
|
63227
63599
|
init_define_VTX_PI_MODEL_POLICY();
|
|
63228
63600
|
init_constants();
|
|
63229
63601
|
init_runtime_redaction();
|
|
63602
|
+
init_runtime_policy_generated2();
|
|
63230
63603
|
MAX_DIAGNOSTIC_LIST_ITEMS = PROVIDER_DIAGNOSTIC_LIMITS.MAX_LIST_ITEMS;
|
|
63231
63604
|
record5 = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
63232
63605
|
ERROR_TOKEN = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
@@ -63247,6 +63620,7 @@ var init_provider_observability = __esm({
|
|
|
63247
63620
|
[/"[^"]*"|'[^'\r\n]*'/g, "[REDACTED]"]
|
|
63248
63621
|
];
|
|
63249
63622
|
CONTROL_CHARACTER_RUN = /[\x00-\x1f\x7f]+/g;
|
|
63623
|
+
UNSTORABLE_TEXT = /\u0000|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
63250
63624
|
WHITESPACE_RUN = new RegExp(`${WHITESPACE_CLASS}+`, "g");
|
|
63251
63625
|
collapseProse = (value) => value.replace(CONTROL_CHARACTER_RUN, " ").replace(WHITESPACE_RUN, " ").trim();
|
|
63252
63626
|
settled = (value) => {
|
|
@@ -63260,12 +63634,14 @@ var init_provider_observability = __esm({
|
|
|
63260
63634
|
return current;
|
|
63261
63635
|
};
|
|
63262
63636
|
REDACTED_MARKER_START = "[REDACTED";
|
|
63637
|
+
cutOutsideMarker = (full, cut) => {
|
|
63638
|
+
const opened = cut.lastIndexOf("[");
|
|
63639
|
+
return opened !== -1 && full.startsWith(REDACTED_MARKER_START, opened) && full.indexOf("]", opened) >= cut.length ? cut.slice(0, opened) : cut;
|
|
63640
|
+
};
|
|
63263
63641
|
boundedMessage = (value) => {
|
|
63264
63642
|
const characters = Array.from(value);
|
|
63265
63643
|
if (characters.length <= PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_MESSAGE_CHARS) return value;
|
|
63266
|
-
|
|
63267
|
-
const marker2 = cut.lastIndexOf(REDACTED_MARKER_START);
|
|
63268
|
-
if (marker2 !== -1 && value.indexOf("]", marker2) >= cut.length) cut = cut.slice(0, marker2);
|
|
63644
|
+
const cut = cutOutsideMarker(value, characters.slice(0, PROVIDER_DIAGNOSTIC_LIMITS.MAX_ERROR_MESSAGE_CHARS).join(""));
|
|
63269
63645
|
return cut.replace(/ +$/, "");
|
|
63270
63646
|
};
|
|
63271
63647
|
normalizeProviderError = (value) => {
|
|
@@ -63282,6 +63658,7 @@ var init_provider_observability = __esm({
|
|
|
63282
63658
|
message = sanitizeRuntimeDiagnosticValue(message);
|
|
63283
63659
|
for (const [pattern, replacement] of ERROR_PROSE_REDACTIONS) message = message.replace(pattern, replacement);
|
|
63284
63660
|
message = settled(sanitizeRuntimeDiagnosticValue(collapseProse(sanitizeRuntimeDiagnosticValue(message))));
|
|
63661
|
+
message = message.replace(UNSTORABLE_TEXT, "\uFFFD");
|
|
63285
63662
|
}
|
|
63286
63663
|
const fullLength = Array.from(message).length;
|
|
63287
63664
|
let bounded = boundedMessage(message);
|
|
@@ -63301,6 +63678,35 @@ var init_provider_observability = __esm({
|
|
|
63301
63678
|
}
|
|
63302
63679
|
return result;
|
|
63303
63680
|
};
|
|
63681
|
+
REPLY_POLICY = runtime_policy_generated_default2.llm.provider_diagnostics;
|
|
63682
|
+
REPLY_HEADER_NAME = /^[a-z0-9][a-z0-9-]{0,127}$/;
|
|
63683
|
+
isProviderReplyHeaderName = (name) => {
|
|
63684
|
+
const lowered = name.toLowerCase();
|
|
63685
|
+
return REPLY_HEADER_NAME.test(lowered) && REPLY_POLICY.reply_header_name_parts.some((part) => lowered.includes(part));
|
|
63686
|
+
};
|
|
63687
|
+
boundedReplyText = (value) => {
|
|
63688
|
+
const masked = sanitizeRuntimeDiagnosticValue(value.replace(UNSTORABLE_TEXT, "\uFFFD"));
|
|
63689
|
+
const characters = Array.from(masked);
|
|
63690
|
+
if (characters.length <= REPLY_POLICY.reply_body_max_chars) return { text: masked, truncated: false };
|
|
63691
|
+
let cut = cutOutsideMarker(masked, characters.slice(0, REPLY_POLICY.reply_body_max_chars).join(""));
|
|
63692
|
+
while (sanitizeRuntimeDiagnosticValue(cut) !== cut) cut = Array.from(cut).slice(0, -1).join("");
|
|
63693
|
+
return { text: cut, truncated: true };
|
|
63694
|
+
};
|
|
63695
|
+
normalizeProviderReply = (value) => {
|
|
63696
|
+
const raw = record5(value);
|
|
63697
|
+
const result = {};
|
|
63698
|
+
if (typeof raw.status === "number" && Number.isInteger(raw.status) && raw.status >= HTTP_STATUS_MIN && raw.status <= HTTP_STATUS_MAX) result.status = raw.status;
|
|
63699
|
+
if (typeof raw.body === "string" && raw.body) {
|
|
63700
|
+
const { text: text2, truncated } = boundedReplyText(raw.body);
|
|
63701
|
+
if (text2) {
|
|
63702
|
+
result.body = text2;
|
|
63703
|
+
if (truncated || raw.body_truncated === true) result.body_truncated = true;
|
|
63704
|
+
}
|
|
63705
|
+
}
|
|
63706
|
+
const headers = Object.entries(record5(raw.headers)).filter((entry) => typeof entry[1] === "string" && entry[0] === entry[0].toLowerCase() && isProviderReplyHeaderName(entry[0])).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0).slice(0, REPLY_POLICY.reply_max_headers);
|
|
63707
|
+
if (headers.length) result.headers = Object.fromEntries(headers.map(([name, text2]) => [name, boundedReplyText(text2).text]));
|
|
63708
|
+
return result;
|
|
63709
|
+
};
|
|
63304
63710
|
identifier = (v) => typeof v === "string" && /^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,255}$/.test(v) ? v : void 0;
|
|
63305
63711
|
count4 = (v) => {
|
|
63306
63712
|
if (typeof v !== "number" && (typeof v !== "string" || !v.trim())) return void 0;
|
|
@@ -63340,6 +63746,8 @@ var init_provider_observability = __esm({
|
|
|
63340
63746
|
}).filter((v) => Object.keys(v).length > 0);
|
|
63341
63747
|
if (violations.length) result.quota_violations = violations;
|
|
63342
63748
|
}
|
|
63749
|
+
const providerReply = normalizeProviderReply(raw.provider_reply);
|
|
63750
|
+
if (Object.keys(providerReply).length) result.provider_reply = providerReply;
|
|
63343
63751
|
const outputValidation = record5(raw.output_validation);
|
|
63344
63752
|
if (Array.isArray(outputValidation.expected_symbols)) {
|
|
63345
63753
|
const symbols = outputValidation.expected_symbols.slice(0, MAX_DIAGNOSTIC_LIST_ITEMS).map(identifier).filter((symbol2) => symbol2 !== void 0);
|
|
@@ -65428,7 +65836,7 @@ function createGetUrl(options) {
|
|
|
65428
65836
|
request.write(Buffer.from(body));
|
|
65429
65837
|
}
|
|
65430
65838
|
request.end();
|
|
65431
|
-
return new Promise((
|
|
65839
|
+
return new Promise((resolve17, reject) => {
|
|
65432
65840
|
if (signal) {
|
|
65433
65841
|
signal.addListener(() => {
|
|
65434
65842
|
if (abort) {
|
|
@@ -65474,7 +65882,7 @@ function createGetUrl(options) {
|
|
|
65474
65882
|
if (headers2["content-encoding"] === "gzip" && body2) {
|
|
65475
65883
|
body2 = getBytes(gunzipSync3(body2));
|
|
65476
65884
|
}
|
|
65477
|
-
|
|
65885
|
+
resolve17({ statusCode, statusMessage, headers: headers2, body: body2 });
|
|
65478
65886
|
} catch (error48) {
|
|
65479
65887
|
reject(makeError("bad response data", "SERVER_ERROR", {
|
|
65480
65888
|
request: req,
|
|
@@ -65551,7 +65959,7 @@ function unpercent(value) {
|
|
|
65551
65959
|
}));
|
|
65552
65960
|
}
|
|
65553
65961
|
function wait2(delay3) {
|
|
65554
|
-
return new Promise((
|
|
65962
|
+
return new Promise((resolve17) => setTimeout(resolve17, delay3));
|
|
65555
65963
|
}
|
|
65556
65964
|
var MAX_ATTEMPTS, SLOT_INTERVAL, defaultGetUrlFunc, reData, reIpfs, locked, Gateways, fetchSignals, FetchCancelSignal, FetchRequest, FetchResponse;
|
|
65557
65965
|
var init_fetch = __esm({
|
|
@@ -79423,7 +79831,7 @@ var init_provider = __esm({
|
|
|
79423
79831
|
return null;
|
|
79424
79832
|
}
|
|
79425
79833
|
}
|
|
79426
|
-
const waiter = new Promise((
|
|
79834
|
+
const waiter = new Promise((resolve17, reject) => {
|
|
79427
79835
|
const cancellers = [];
|
|
79428
79836
|
const cancel = () => {
|
|
79429
79837
|
cancellers.forEach((c) => c());
|
|
@@ -79444,7 +79852,7 @@ var init_provider = __esm({
|
|
|
79444
79852
|
if (await receipt2.confirmations() >= confirms) {
|
|
79445
79853
|
cancel();
|
|
79446
79854
|
try {
|
|
79447
|
-
|
|
79855
|
+
resolve17(checkReceipt(receipt2));
|
|
79448
79856
|
} catch (error48) {
|
|
79449
79857
|
reject(error48);
|
|
79450
79858
|
}
|
|
@@ -80371,12 +80779,12 @@ var init_contract = __esm({
|
|
|
80371
80779
|
}
|
|
80372
80780
|
const provider = getProvider(this.runner);
|
|
80373
80781
|
assert2(provider != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" });
|
|
80374
|
-
return new Promise((
|
|
80782
|
+
return new Promise((resolve17, reject) => {
|
|
80375
80783
|
const checkCode = async () => {
|
|
80376
80784
|
try {
|
|
80377
80785
|
const code2 = await this.getDeployedCode();
|
|
80378
80786
|
if (code2 != null) {
|
|
80379
|
-
return
|
|
80787
|
+
return resolve17(this);
|
|
80380
80788
|
}
|
|
80381
80789
|
provider.once("block", checkCode);
|
|
80382
80790
|
} catch (error48) {
|
|
@@ -82736,7 +83144,7 @@ var init_abstract_provider = __esm({
|
|
|
82736
83144
|
return t.toLowerCase();
|
|
82737
83145
|
});
|
|
82738
83146
|
const blockHash = "blockHash" in filter ? filter.blockHash : void 0;
|
|
82739
|
-
const
|
|
83147
|
+
const resolve17 = (_address, fromBlock2, toBlock2) => {
|
|
82740
83148
|
let address2 = void 0;
|
|
82741
83149
|
switch (_address.length) {
|
|
82742
83150
|
case 0:
|
|
@@ -82791,10 +83199,10 @@ var init_abstract_provider = __esm({
|
|
|
82791
83199
|
}
|
|
82792
83200
|
if (address.filter((a) => typeof a !== "string").length || fromBlock != null && typeof fromBlock !== "string" || toBlock != null && typeof toBlock !== "string") {
|
|
82793
83201
|
return Promise.all([Promise.all(address), fromBlock, toBlock]).then((result) => {
|
|
82794
|
-
return
|
|
83202
|
+
return resolve17(result[0], result[1], result[2]);
|
|
82795
83203
|
});
|
|
82796
83204
|
}
|
|
82797
|
-
return
|
|
83205
|
+
return resolve17(address, fromBlock, toBlock);
|
|
82798
83206
|
}
|
|
82799
83207
|
/**
|
|
82800
83208
|
* Returns or resolves to a transaction for %%request%%, resolving
|
|
@@ -83168,14 +83576,14 @@ var init_abstract_provider = __esm({
|
|
|
83168
83576
|
if (confirms === 0) {
|
|
83169
83577
|
return this.getTransactionReceipt(hash5);
|
|
83170
83578
|
}
|
|
83171
|
-
return new Promise(async (
|
|
83579
|
+
return new Promise(async (resolve17, reject) => {
|
|
83172
83580
|
let timer = null;
|
|
83173
83581
|
const listener = (async (blockNumber) => {
|
|
83174
83582
|
try {
|
|
83175
83583
|
const receipt = await this.getTransactionReceipt(hash5);
|
|
83176
83584
|
if (receipt != null) {
|
|
83177
83585
|
if (blockNumber - receipt.blockNumber + 1 >= confirms) {
|
|
83178
|
-
|
|
83586
|
+
resolve17(receipt);
|
|
83179
83587
|
if (timer) {
|
|
83180
83588
|
clearTimeout(timer);
|
|
83181
83589
|
timer = null;
|
|
@@ -83949,8 +84357,8 @@ function deepCopy(value) {
|
|
|
83949
84357
|
throw new Error(`should not happen: ${value} (${typeof value})`);
|
|
83950
84358
|
}
|
|
83951
84359
|
function stall(duration3) {
|
|
83952
|
-
return new Promise((
|
|
83953
|
-
setTimeout(
|
|
84360
|
+
return new Promise((resolve17) => {
|
|
84361
|
+
setTimeout(resolve17, duration3);
|
|
83954
84362
|
});
|
|
83955
84363
|
}
|
|
83956
84364
|
function getLowerCase(value) {
|
|
@@ -84091,14 +84499,14 @@ var init_provider_jsonrpc = __esm({
|
|
|
84091
84499
|
async sendTransaction(tx) {
|
|
84092
84500
|
const blockNumber = await this.provider.getBlockNumber();
|
|
84093
84501
|
const hash5 = await this.sendUncheckedTransaction(tx);
|
|
84094
|
-
return await new Promise((
|
|
84502
|
+
return await new Promise((resolve17, reject) => {
|
|
84095
84503
|
const timeouts = [1e3, 100];
|
|
84096
84504
|
let invalids = 0;
|
|
84097
84505
|
const checkTx = async () => {
|
|
84098
84506
|
try {
|
|
84099
84507
|
const tx2 = await this.provider.getTransaction(hash5);
|
|
84100
84508
|
if (tx2 != null) {
|
|
84101
|
-
|
|
84509
|
+
resolve17(tx2.replaceableTransaction(blockNumber));
|
|
84102
84510
|
return;
|
|
84103
84511
|
}
|
|
84104
84512
|
} catch (error48) {
|
|
@@ -84215,7 +84623,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
84215
84623
|
try {
|
|
84216
84624
|
const result = await this._send(payload);
|
|
84217
84625
|
this.emit("debug", { action: "receiveRpcResult", result });
|
|
84218
|
-
for (const { resolve:
|
|
84626
|
+
for (const { resolve: resolve17, reject, payload: payload2 } of batch) {
|
|
84219
84627
|
if (this.destroyed) {
|
|
84220
84628
|
reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload2.method }));
|
|
84221
84629
|
continue;
|
|
@@ -84234,7 +84642,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
84234
84642
|
reject(this.getRpcError(payload2, resp));
|
|
84235
84643
|
continue;
|
|
84236
84644
|
}
|
|
84237
|
-
|
|
84645
|
+
resolve17(resp.result);
|
|
84238
84646
|
}
|
|
84239
84647
|
} catch (error48) {
|
|
84240
84648
|
this.emit("debug", { action: "receiveRpcError", error: error48 });
|
|
@@ -84255,11 +84663,11 @@ var init_provider_jsonrpc = __esm({
|
|
|
84255
84663
|
this.#network = null;
|
|
84256
84664
|
this.#pendingDetectNetwork = null;
|
|
84257
84665
|
{
|
|
84258
|
-
let
|
|
84666
|
+
let resolve17 = null;
|
|
84259
84667
|
const promise2 = new Promise((_resolve) => {
|
|
84260
|
-
|
|
84668
|
+
resolve17 = _resolve;
|
|
84261
84669
|
});
|
|
84262
|
-
this.#notReady = { promise: promise2, resolve:
|
|
84670
|
+
this.#notReady = { promise: promise2, resolve: resolve17 };
|
|
84263
84671
|
}
|
|
84264
84672
|
const staticNetwork = this._getOption("staticNetwork");
|
|
84265
84673
|
if (typeof staticNetwork === "boolean") {
|
|
@@ -84672,9 +85080,9 @@ var init_provider_jsonrpc = __esm({
|
|
|
84672
85080
|
return Promise.reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: method }));
|
|
84673
85081
|
}
|
|
84674
85082
|
const id2 = this.#nextId++;
|
|
84675
|
-
const promise2 = new Promise((
|
|
85083
|
+
const promise2 = new Promise((resolve17, reject) => {
|
|
84676
85084
|
this.#payloads.push({
|
|
84677
|
-
resolve:
|
|
85085
|
+
resolve: resolve17,
|
|
84678
85086
|
reject,
|
|
84679
85087
|
payload: { method, params, id: id2, jsonrpc: "2.0" }
|
|
84680
85088
|
});
|
|
@@ -89653,8 +90061,8 @@ var init_provider_socket = __esm({
|
|
|
89653
90061
|
}
|
|
89654
90062
|
async _send(payload) {
|
|
89655
90063
|
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:
|
|
90064
|
+
const promise2 = new Promise((resolve17, reject) => {
|
|
90065
|
+
this.#callbacks.set(payload.id, { payload, resolve: resolve17, reject });
|
|
89658
90066
|
});
|
|
89659
90067
|
await this._waitUntilReady();
|
|
89660
90068
|
await this._write(JSON.stringify(payload));
|
|
@@ -90063,8 +90471,8 @@ function shuffle(array2) {
|
|
|
90063
90471
|
}
|
|
90064
90472
|
}
|
|
90065
90473
|
function stall2(duration3) {
|
|
90066
|
-
return new Promise((
|
|
90067
|
-
setTimeout(
|
|
90474
|
+
return new Promise((resolve17) => {
|
|
90475
|
+
setTimeout(resolve17, duration3);
|
|
90068
90476
|
});
|
|
90069
90477
|
}
|
|
90070
90478
|
function getTime3() {
|
|
@@ -90950,7 +91358,7 @@ var init_provider_browser = __esm({
|
|
|
90950
91358
|
if (timeout === 0) {
|
|
90951
91359
|
return null;
|
|
90952
91360
|
}
|
|
90953
|
-
return await new Promise((
|
|
91361
|
+
return await new Promise((resolve17, reject) => {
|
|
90954
91362
|
let found = [];
|
|
90955
91363
|
const addProvider = (event) => {
|
|
90956
91364
|
found.push(event.detail);
|
|
@@ -90964,9 +91372,9 @@ var init_provider_browser = __esm({
|
|
|
90964
91372
|
if (options && options.filter) {
|
|
90965
91373
|
const filtered = options.filter(found.map((i2) => Object.assign({}, i2.info)));
|
|
90966
91374
|
if (filtered == null) {
|
|
90967
|
-
|
|
91375
|
+
resolve17(null);
|
|
90968
91376
|
} else if (filtered instanceof _BrowserProvider) {
|
|
90969
|
-
|
|
91377
|
+
resolve17(filtered);
|
|
90970
91378
|
} else {
|
|
90971
91379
|
let match = null;
|
|
90972
91380
|
if (filtered.uuid) {
|
|
@@ -90975,7 +91383,7 @@ var init_provider_browser = __esm({
|
|
|
90975
91383
|
}
|
|
90976
91384
|
if (match) {
|
|
90977
91385
|
const { provider, info } = match;
|
|
90978
|
-
|
|
91386
|
+
resolve17(new _BrowserProvider(provider, void 0, {
|
|
90979
91387
|
providerInfo: info
|
|
90980
91388
|
}));
|
|
90981
91389
|
} else {
|
|
@@ -90986,12 +91394,12 @@ var init_provider_browser = __esm({
|
|
|
90986
91394
|
}
|
|
90987
91395
|
} else {
|
|
90988
91396
|
const { provider, info } = found[0];
|
|
90989
|
-
|
|
91397
|
+
resolve17(new _BrowserProvider(provider, void 0, {
|
|
90990
91398
|
providerInfo: info
|
|
90991
91399
|
}));
|
|
90992
91400
|
}
|
|
90993
91401
|
} else {
|
|
90994
|
-
|
|
91402
|
+
resolve17(null);
|
|
90995
91403
|
}
|
|
90996
91404
|
context.removeEventListener("eip6963:announceProvider", addProvider);
|
|
90997
91405
|
};
|
|
@@ -91445,10 +91853,10 @@ var init_base_wallet = __esm({
|
|
|
91445
91853
|
});
|
|
91446
91854
|
|
|
91447
91855
|
// node_modules/ethers/lib.esm/wordlists/decode-owl.js
|
|
91448
|
-
function unfold(words7,
|
|
91856
|
+
function unfold(words7, sep4) {
|
|
91449
91857
|
let initial = 97;
|
|
91450
91858
|
return words7.reduce((accum, word) => {
|
|
91451
|
-
if (word ===
|
|
91859
|
+
if (word === sep4) {
|
|
91452
91860
|
initial++;
|
|
91453
91861
|
} else if (word.match(Word)) {
|
|
91454
91862
|
accum.push(String.fromCharCode(initial) + word);
|
|
@@ -92425,9 +92833,9 @@ function decryptKeystoreJsonSync(json2, _password) {
|
|
|
92425
92833
|
return getAccount(data4, key);
|
|
92426
92834
|
}
|
|
92427
92835
|
function stall3(duration3) {
|
|
92428
|
-
return new Promise((
|
|
92836
|
+
return new Promise((resolve17) => {
|
|
92429
92837
|
setTimeout(() => {
|
|
92430
|
-
|
|
92838
|
+
resolve17();
|
|
92431
92839
|
}, duration3);
|
|
92432
92840
|
});
|
|
92433
92841
|
}
|
|
@@ -93059,9 +93467,9 @@ var init_json_crowdsale = __esm({
|
|
|
93059
93467
|
|
|
93060
93468
|
// node_modules/ethers/lib.esm/wallet/wallet.js
|
|
93061
93469
|
function stall4(duration3) {
|
|
93062
|
-
return new Promise((
|
|
93470
|
+
return new Promise((resolve17) => {
|
|
93063
93471
|
setTimeout(() => {
|
|
93064
|
-
|
|
93472
|
+
resolve17();
|
|
93065
93473
|
}, duration3);
|
|
93066
93474
|
});
|
|
93067
93475
|
}
|
|
@@ -96777,8 +97185,8 @@ var init_hyperliquid_client = __esm({
|
|
|
96777
97185
|
acknowledgementLookupPacing = () => ({
|
|
96778
97186
|
windowMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.window_milliseconds,
|
|
96779
97187
|
pollMs: runtime_policy_generated_default2.exchange.hyperliquid.acknowledgement_lookup.poll_milliseconds,
|
|
96780
|
-
sleep: (ms) => new Promise((
|
|
96781
|
-
globalThis.setTimeout(
|
|
97188
|
+
sleep: (ms) => new Promise((resolve17) => {
|
|
97189
|
+
globalThis.setTimeout(resolve17, ms);
|
|
96782
97190
|
}),
|
|
96783
97191
|
// Monotonic: a wall-clock step must not stretch or cut the window.
|
|
96784
97192
|
nowMs: () => globalThis.performance.now()
|
|
@@ -97487,14 +97895,14 @@ var init_hyperliquid_client = __esm({
|
|
|
97487
97895
|
"outcome_unknown"
|
|
97488
97896
|
);
|
|
97489
97897
|
}
|
|
97490
|
-
await new Promise((
|
|
97898
|
+
await new Promise((resolve17) => {
|
|
97491
97899
|
let settled2 = false;
|
|
97492
97900
|
const finish = () => {
|
|
97493
97901
|
if (settled2) return;
|
|
97494
97902
|
settled2 = true;
|
|
97495
97903
|
globalThis.clearTimeout(timeoutId);
|
|
97496
97904
|
input.signal?.removeEventListener("abort", finish);
|
|
97497
|
-
|
|
97905
|
+
resolve17();
|
|
97498
97906
|
};
|
|
97499
97907
|
const timeoutId = globalThis.setTimeout(
|
|
97500
97908
|
finish,
|
|
@@ -97529,12 +97937,12 @@ var init_hyperliquid_client = __esm({
|
|
|
97529
97937
|
captureController.signal,
|
|
97530
97938
|
...durableMutationAuthorityArgs(durableMutation)
|
|
97531
97939
|
).then(() => void 0).catch(() => void 0);
|
|
97532
|
-
const captureDeadline = new Promise((
|
|
97940
|
+
const captureDeadline = new Promise((resolve17) => {
|
|
97533
97941
|
captureTimeout = globalThis.setTimeout(() => {
|
|
97534
97942
|
captureController.abort(
|
|
97535
97943
|
new DOMException("Execution attempt capture timed out.", "TimeoutError")
|
|
97536
97944
|
);
|
|
97537
|
-
|
|
97945
|
+
resolve17();
|
|
97538
97946
|
}, remainingBudgetMs);
|
|
97539
97947
|
});
|
|
97540
97948
|
await Promise.race([captureRequest, captureDeadline]);
|
|
@@ -100693,23 +101101,23 @@ var init_vault = __esm({
|
|
|
100693
101101
|
}
|
|
100694
101102
|
return output3.buffer.slice(output3.byteOffset, output3.byteOffset + output3.byteLength);
|
|
100695
101103
|
};
|
|
100696
|
-
openLegacyVaultDb = () => new Promise((
|
|
101104
|
+
openLegacyVaultDb = () => new Promise((resolve17) => {
|
|
100697
101105
|
if (!hasIndexedDb()) {
|
|
100698
|
-
|
|
101106
|
+
resolve17(null);
|
|
100699
101107
|
return;
|
|
100700
101108
|
}
|
|
100701
101109
|
let request;
|
|
100702
101110
|
try {
|
|
100703
101111
|
request = indexedDB.open(LEGACY_VAULT_DB_NAME, LEGACY_VAULT_DB_VERSION);
|
|
100704
101112
|
} catch {
|
|
100705
|
-
|
|
101113
|
+
resolve17(null);
|
|
100706
101114
|
return;
|
|
100707
101115
|
}
|
|
100708
|
-
request.onerror = () =>
|
|
101116
|
+
request.onerror = () => resolve17(null);
|
|
100709
101117
|
request.onupgradeneeded = () => {
|
|
100710
101118
|
request.transaction?.abort();
|
|
100711
101119
|
};
|
|
100712
|
-
request.onsuccess = () =>
|
|
101120
|
+
request.onsuccess = () => resolve17(request.result);
|
|
100713
101121
|
});
|
|
100714
101122
|
withLegacyStore = async (mode, fn) => {
|
|
100715
101123
|
const database = await openLegacyVaultDb();
|
|
@@ -100718,12 +101126,12 @@ var init_vault = __esm({
|
|
|
100718
101126
|
if (!database.objectStoreNames.contains(LEGACY_VAULT_KEY_STORE)) return null;
|
|
100719
101127
|
const transaction = database.transaction(LEGACY_VAULT_KEY_STORE, mode);
|
|
100720
101128
|
const request = fn(transaction.objectStore(LEGACY_VAULT_KEY_STORE));
|
|
100721
|
-
const result = await new Promise((
|
|
101129
|
+
const result = await new Promise((resolve17, reject) => {
|
|
100722
101130
|
request.onerror = () => reject(request.error ?? new Error("Legacy vault request failed."));
|
|
100723
|
-
request.onsuccess = () =>
|
|
101131
|
+
request.onsuccess = () => resolve17(request.result ?? null);
|
|
100724
101132
|
});
|
|
100725
|
-
await new Promise((
|
|
100726
|
-
transaction.oncomplete = () =>
|
|
101133
|
+
await new Promise((resolve17, reject) => {
|
|
101134
|
+
transaction.oncomplete = () => resolve17();
|
|
100727
101135
|
transaction.onerror = () => reject(transaction.error ?? new Error("Legacy vault transaction failed."));
|
|
100728
101136
|
transaction.onabort = () => reject(transaction.error ?? new Error("Legacy vault transaction aborted."));
|
|
100729
101137
|
});
|
|
@@ -102215,12 +102623,12 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
102215
102623
|
if (signal.aborted) {
|
|
102216
102624
|
throw createAbortError(abortMessage);
|
|
102217
102625
|
}
|
|
102218
|
-
return new Promise((
|
|
102626
|
+
return new Promise((resolve17, reject) => {
|
|
102219
102627
|
const onAbort = () => {
|
|
102220
102628
|
reject(createAbortError(abortMessage));
|
|
102221
102629
|
};
|
|
102222
102630
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
102223
|
-
promise2.then(
|
|
102631
|
+
promise2.then(resolve17, reject).finally(() => {
|
|
102224
102632
|
signal.removeEventListener("abort", onAbort);
|
|
102225
102633
|
});
|
|
102226
102634
|
});
|
|
@@ -103865,7 +104273,7 @@ var init_bounded_lock = __esm({
|
|
|
103865
104273
|
};
|
|
103866
104274
|
inProcessTails = /* @__PURE__ */ new Map();
|
|
103867
104275
|
abortReason = (signal) => signal.reason instanceof Error ? signal.reason : new DOMException("The operation was aborted.", "AbortError");
|
|
103868
|
-
waitBounded = (gate, waitMs, signal) => new Promise((
|
|
104276
|
+
waitBounded = (gate, waitMs, signal) => new Promise((resolve17, reject) => {
|
|
103869
104277
|
if (signal?.aborted) {
|
|
103870
104278
|
reject(abortReason(signal));
|
|
103871
104279
|
return;
|
|
@@ -103880,19 +104288,19 @@ var init_bounded_lock = __esm({
|
|
|
103880
104288
|
};
|
|
103881
104289
|
const timer = setTimeout(() => {
|
|
103882
104290
|
finish();
|
|
103883
|
-
|
|
104291
|
+
resolve17();
|
|
103884
104292
|
}, waitMs);
|
|
103885
104293
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
103886
104294
|
void gate.then(() => {
|
|
103887
104295
|
finish();
|
|
103888
|
-
|
|
104296
|
+
resolve17();
|
|
103889
104297
|
});
|
|
103890
104298
|
});
|
|
103891
104299
|
withInProcessLock = async (name, waitMs, work, signal) => {
|
|
103892
104300
|
const previous = inProcessTails.get(name) ?? Promise.resolve();
|
|
103893
104301
|
let release;
|
|
103894
|
-
const released = new Promise((
|
|
103895
|
-
release =
|
|
104302
|
+
const released = new Promise((resolve17) => {
|
|
104303
|
+
release = resolve17;
|
|
103896
104304
|
});
|
|
103897
104305
|
const tail = previous.then(() => released);
|
|
103898
104306
|
inProcessTails.set(name, tail);
|
|
@@ -105133,7 +105541,7 @@ var init_execution_capacity = __esm({
|
|
|
105133
105541
|
});
|
|
105134
105542
|
|
|
105135
105543
|
// lib/runtime/owed-protection-warnings.ts
|
|
105136
|
-
var storageKey, isWarning, identity2, owesProtectionRecord, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
|
|
105544
|
+
var storageKey, configuredStorage2, owedStorage, isWarning, identity2, owesProtectionRecord, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
|
|
105137
105545
|
var init_owed_protection_warnings = __esm({
|
|
105138
105546
|
"lib/runtime/owed-protection-warnings.ts"() {
|
|
105139
105547
|
"use strict";
|
|
@@ -105143,6 +105551,8 @@ var init_owed_protection_warnings = __esm({
|
|
|
105143
105551
|
init_define_VTX_PI_MODEL_POLICY();
|
|
105144
105552
|
init_host_storage();
|
|
105145
105553
|
storageKey = (profileId) => `vtx:protection-warning-outbox:${String(profileId ?? "").trim()}`;
|
|
105554
|
+
configuredStorage2 = null;
|
|
105555
|
+
owedStorage = () => configuredStorage2 ?? runtimeHostStorage();
|
|
105146
105556
|
isWarning = (value) => {
|
|
105147
105557
|
const record6 = value;
|
|
105148
105558
|
return record6 != null && typeof record6 === "object" && typeof record6.symbol === "string" && typeof record6.action === "string" && typeof record6.status === "string" && (record6.order_id === null || typeof record6.order_id === "string") && record6.execution_metadata != null && typeof record6.execution_metadata === "object";
|
|
@@ -105160,7 +105570,7 @@ var init_owed_protection_warnings = __esm({
|
|
|
105160
105570
|
};
|
|
105161
105571
|
owedProtectionWarnings = (profileId) => {
|
|
105162
105572
|
try {
|
|
105163
|
-
const parsed = JSON.parse(
|
|
105573
|
+
const parsed = JSON.parse(owedStorage()?.getItem(storageKey(profileId)) ?? "[]");
|
|
105164
105574
|
return Array.isArray(parsed) ? parsed.filter(isWarning) : [];
|
|
105165
105575
|
} catch {
|
|
105166
105576
|
return [];
|
|
@@ -105168,7 +105578,7 @@ var init_owed_protection_warnings = __esm({
|
|
|
105168
105578
|
};
|
|
105169
105579
|
store = (profileId, warnings) => {
|
|
105170
105580
|
try {
|
|
105171
|
-
const storage3 =
|
|
105581
|
+
const storage3 = owedStorage();
|
|
105172
105582
|
if (warnings.length > 0) storage3?.setItem(storageKey(profileId), JSON.stringify(warnings));
|
|
105173
105583
|
else storage3?.removeItem(storageKey(profileId));
|
|
105174
105584
|
} catch {
|
|
@@ -105711,7 +106121,7 @@ var init_protective_leg_evidence = __esm({
|
|
|
105711
106121
|
});
|
|
105712
106122
|
|
|
105713
106123
|
// lib/runtime/protective-entry-cover.ts
|
|
105714
|
-
var
|
|
106124
|
+
var attachmentMemberNeverLanded, ownLegCanStillExist, liveProtectiveOrderShape, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, pageOrderById, protectiveLegCoverSize, resolveOwnStops, protectiveEntryLegSize;
|
|
105715
106125
|
var init_protective_entry_cover = __esm({
|
|
105716
106126
|
"lib/runtime/protective-entry-cover.ts"() {
|
|
105717
106127
|
"use strict";
|
|
@@ -105719,39 +106129,115 @@ var init_protective_entry_cover = __esm({
|
|
|
105719
106129
|
init_define_VTX_EXO_POLICY();
|
|
105720
106130
|
init_define_VTX_GROK_POLICY();
|
|
105721
106131
|
init_define_VTX_PI_MODEL_POLICY();
|
|
105722
|
-
|
|
105723
|
-
|
|
105724
|
-
|
|
105725
|
-
|
|
105726
|
-
|
|
105727
|
-
|
|
105728
|
-
|
|
105729
|
-
|
|
105730
|
-
|
|
105731
|
-
|
|
105732
|
-
|
|
105733
|
-
|
|
105734
|
-
|
|
106132
|
+
attachmentMemberNeverLanded = (group, leg) => group.attachmentJournal?.members.some((member) => member.clientOrderId === leg.orderId && member.neverLandedAtMs != null) === true;
|
|
106133
|
+
ownLegCanStillExist = (group, leg) => leg.replaceJournal?.unknownOidObservedAtMs == null && !attachmentMemberNeverLanded(group, leg);
|
|
106134
|
+
liveProtectiveOrderShape = (order) => ({
|
|
106135
|
+
coin: order.coin,
|
|
106136
|
+
side: order.side,
|
|
106137
|
+
size: order.sz,
|
|
106138
|
+
reduceOnly: order.reduce_only,
|
|
106139
|
+
isTrigger: order.is_trigger,
|
|
106140
|
+
triggerKind: order.trigger_kind,
|
|
106141
|
+
triggerPrice: order.trigger_px,
|
|
106142
|
+
isPositionTpsl: order.is_position_tpsl
|
|
106143
|
+
});
|
|
106144
|
+
protectiveStableShapeMatches = (input) => {
|
|
106145
|
+
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
106146
|
+
const expectedSide = isLong ? ["a", "sell"] : ["b", "buy"];
|
|
106147
|
+
const observedSize = Number(shape.size);
|
|
106148
|
+
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;
|
|
106149
|
+
};
|
|
106150
|
+
observedProtectiveGroupingMatches = (observed, storedPositionTpsl) => observed === false || observed === true && storedPositionTpsl === true;
|
|
106151
|
+
protectiveLiveShapeMatches = (input) => {
|
|
106152
|
+
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
106153
|
+
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));
|
|
105735
106154
|
};
|
|
105736
|
-
|
|
105737
|
-
|
|
105738
|
-
|
|
105739
|
-
|
|
105740
|
-
|
|
105741
|
-
|
|
105742
|
-
|
|
105743
|
-
group
|
|
105744
|
-
|
|
105745
|
-
|
|
105746
|
-
const
|
|
105747
|
-
|
|
105748
|
-
|
|
105749
|
-
|
|
105750
|
-
|
|
105751
|
-
|
|
105752
|
-
|
|
105753
|
-
|
|
105754
|
-
|
|
106155
|
+
pageOrderById = (orders, orderId) => orderId == null ? null : orders.find((order) => String(order.oid) === String(orderId)) ?? null;
|
|
106156
|
+
protectiveLegCoverSize = (leg, restingSize = leg.size) => leg.replacement != null && leg.replacement.size < restingSize ? leg.replacement.size : restingSize;
|
|
106157
|
+
resolveOwnStops = (input) => {
|
|
106158
|
+
const { symbol: symbol2, orders } = input;
|
|
106159
|
+
const entries = input.groups.flatMap((group) => group.legs.map((leg) => ({ group, leg })));
|
|
106160
|
+
const knownId = ({ leg }) => input.lookedUp?.get(String(leg.orderId)) ?? (typeof leg.orderId === "number" ? leg.orderId : null);
|
|
106161
|
+
const pendingIds = new Set(entries.flatMap(({ leg }) => leg.replacement?.clientOrderId ? [leg.replacement.clientOrderId] : []));
|
|
106162
|
+
const unbound = (entry) => knownId(entry) == null && !pendingIds.has(String(entry.leg.orderId)) && (input.canStillExist ?? ownLegCanStillExist)(entry.group, entry.leg);
|
|
106163
|
+
const claims = /* @__PURE__ */ new Map();
|
|
106164
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
106165
|
+
const claim = (entry, order) => {
|
|
106166
|
+
if (order == null || claimed.has(order) || claims.has(entry)) return;
|
|
106167
|
+
claims.set(entry, order);
|
|
106168
|
+
claimed.add(order);
|
|
106169
|
+
};
|
|
106170
|
+
const byShape = (entry, leg) => orders.find((order) => !claimed.has(order) && protectiveLiveShapeMatches({
|
|
106171
|
+
shape: liveProtectiveOrderShape(order),
|
|
106172
|
+
symbol: symbol2,
|
|
106173
|
+
isLong: entry.group.isLong,
|
|
106174
|
+
leg
|
|
106175
|
+
}));
|
|
106176
|
+
for (const entry of entries) claim(entry, pageOrderById(orders, knownId(entry)));
|
|
106177
|
+
const named = new Set(claimed);
|
|
106178
|
+
const leaving = new Set(input.groups.filter((group) => group.cleanupRequired === true || entries.some((entry) => entry.group === group && knownId(entry) != null && !claims.has(entry))));
|
|
106179
|
+
const waiting = entries.filter(unbound);
|
|
106180
|
+
const unread = (entry) => input.unresolved?.has(String(entry.leg.orderId)) === true;
|
|
106181
|
+
const staying = waiting.filter((entry) => !leaving.has(entry.group));
|
|
106182
|
+
for (const entry of [...waiting.filter((entry2) => leaving.has(entry2.group)), ...staying.filter(unread), ...staying.filter((entry2) => !unread(entry2))]) {
|
|
106183
|
+
claim(entry, byShape(entry, entry.leg));
|
|
106184
|
+
}
|
|
106185
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
106186
|
+
for (const entry of entries) {
|
|
106187
|
+
byKey.set(String(entry.leg.orderId), entry);
|
|
106188
|
+
if (knownId(entry) != null) byKey.set(String(knownId(entry)), entry);
|
|
106189
|
+
}
|
|
106190
|
+
const entryOf = (leg) => byKey.get(String(leg.orderId));
|
|
106191
|
+
const coverOf = (entry) => {
|
|
106192
|
+
const order = entry == null || leaving.has(entry.group) ? void 0 : claims.get(entry);
|
|
106193
|
+
const size = Number(order?.sz);
|
|
106194
|
+
return entry != null && size > 0 ? protectiveLegCoverSize(entry.leg, Math.min(entry.leg.size, size)) : 0;
|
|
106195
|
+
};
|
|
106196
|
+
const inFlightOf = (entry) => entry == null || leaving.has(entry.group) || claims.has(entry) || !unbound(entry) ? 0 : protectiveLegCoverSize(entry.leg);
|
|
106197
|
+
return {
|
|
106198
|
+
/** The leg is on its way out: it covers nothing and takes no share. */
|
|
106199
|
+
leaving: (leg) => {
|
|
106200
|
+
const entry = entryOf(leg);
|
|
106201
|
+
return entry != null && leaving.has(entry.group);
|
|
106202
|
+
},
|
|
106203
|
+
/** What the leg's order on the page covers (nothing on its way out or off the page). */
|
|
106204
|
+
cover: (leg) => coverOf(entryOf(leg)),
|
|
106205
|
+
/** What a leg whose order is on no page may still cover: its size while it is in flight. */
|
|
106206
|
+
inFlight: (leg) => inFlightOf(entryOf(leg)),
|
|
106207
|
+
/** Whether an order of exactly the leg's shape that no stored leg names rests on the page. */
|
|
106208
|
+
restsUnnamed: (group, leg) => orders.some((order) => !named.has(order) && protectiveLiveShapeMatches({
|
|
106209
|
+
shape: liveProtectiveOrderShape(order),
|
|
106210
|
+
symbol: symbol2,
|
|
106211
|
+
isLong: group.isLong,
|
|
106212
|
+
leg
|
|
106213
|
+
})),
|
|
106214
|
+
/** What the legs of one direction cover, by kind (a new entry's attach). */
|
|
106215
|
+
directionCover: (isLong) => {
|
|
106216
|
+
const cover = { sl: 0, tp: 0 };
|
|
106217
|
+
for (const entry of entries) {
|
|
106218
|
+
if (entry.group.isLong === isLong) cover[entry.leg.kind] += coverOf(entry) + inFlightOf(entry);
|
|
106219
|
+
}
|
|
106220
|
+
return cover;
|
|
106221
|
+
},
|
|
106222
|
+
/**
|
|
106223
|
+
* For a lost stop: the stop losses on the page closing the position, other
|
|
106224
|
+
* than the orders a status proved ended (`lost`) and those this pass placed
|
|
106225
|
+
* (`placed`, counted where they were placed), an order no leg names whole;
|
|
106226
|
+
* and, unseen, what the legs this pass could not read may still cover.
|
|
106227
|
+
*/
|
|
106228
|
+
lostStopCover: (positionSize, excluded) => {
|
|
106229
|
+
const isLong = positionSize > 0;
|
|
106230
|
+
const owners = new Map([...claims].map(([entry, order]) => [order, entry]));
|
|
106231
|
+
const placed = (entry) => excluded.placed.has(String(entry.leg.orderId)) || excluded.placed.has(String(knownId(entry)));
|
|
106232
|
+
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) => {
|
|
106233
|
+
const owner2 = owners.get(order);
|
|
106234
|
+
const size = Number(order.sz);
|
|
106235
|
+
return total + (owner2 != null ? placed(owner2) ? 0 : coverOf(owner2) : size > 0 ? size : 0);
|
|
106236
|
+
}, 0);
|
|
106237
|
+
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);
|
|
106238
|
+
return { onPage, unseen };
|
|
106239
|
+
}
|
|
106240
|
+
};
|
|
105755
106241
|
};
|
|
105756
106242
|
protectiveEntryLegSize = (input) => Math.min(input.filledSize, Math.max(0, input.liveExposure - input.cover));
|
|
105757
106243
|
}
|
|
@@ -107844,7 +108330,7 @@ var init_native_protection_device = __esm({
|
|
|
107844
108330
|
});
|
|
107845
108331
|
|
|
107846
108332
|
// lib/runtime/runtime-execution.ts
|
|
107847
|
-
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,
|
|
108333
|
+
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;
|
|
107848
108334
|
var init_runtime_execution = __esm({
|
|
107849
108335
|
"lib/runtime/runtime-execution.ts"() {
|
|
107850
108336
|
"use strict";
|
|
@@ -108906,22 +109392,6 @@ var init_runtime_execution = __esm({
|
|
|
108906
109392
|
deviceOwnsClientProtectiveLegKind = (group, kind) => group.deviceOwnedLegKinds == null || group.deviceOwnedLegKinds.includes(kind);
|
|
108907
109393
|
isAdoptionNarrowedPositionTpslLeg = (group) => group.deviceOwnedLegKinds?.length === 1 && group.legs.length === 1 && group.legs[0].positionTpsl === true && group.legs[0].kind === group.deviceOwnedLegKinds[0];
|
|
108908
109394
|
hasAmbiguousClientPositionTpslAuthority = (group) => group.legs.some((leg) => leg.positionTpsl === true) && !isExactClientPositionTpslPair(group.legs) && !isAdoptionNarrowedPositionTpslLeg(group);
|
|
108909
|
-
protectiveStableShapeMatches = (input) => {
|
|
108910
|
-
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
108911
|
-
const expectedSide = isLong ? ["a", "sell"] : ["b", "buy"];
|
|
108912
|
-
const observedSize = Number(shape.size);
|
|
108913
|
-
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;
|
|
108914
|
-
};
|
|
108915
|
-
observedProtectiveGroupingMatches = (observed, storedPositionTpsl) => observed === false || observed === true && storedPositionTpsl === true;
|
|
108916
|
-
protectiveLiveShapeMatches = (input) => {
|
|
108917
|
-
const { shape, symbol: symbol2, isLong, leg } = input;
|
|
108918
|
-
return protectiveStableShapeMatches({
|
|
108919
|
-
shape,
|
|
108920
|
-
symbol: symbol2,
|
|
108921
|
-
isLong,
|
|
108922
|
-
leg
|
|
108923
|
-
}) && shape.isTrigger === true && Number.isFinite(Number(shape.triggerPrice)) && Number(shape.triggerPrice) === leg.triggerPrice && (input.requirePositionTpsl === false || observedProtectiveGroupingMatches(shape.isPositionTpsl, leg.positionTpsl));
|
|
108924
|
-
};
|
|
108925
109395
|
protectiveTerminalShapeMatches = (input) => input.evidence.responseValid === true && input.evidence.orderMatches === true && input.evidence.terminal === true && protectiveStableShapeMatches({
|
|
108926
109396
|
shape: input.evidence,
|
|
108927
109397
|
symbol: input.symbol,
|
|
@@ -108973,7 +109443,7 @@ var init_runtime_execution = __esm({
|
|
|
108973
109443
|
}
|
|
108974
109444
|
}
|
|
108975
109445
|
const liveOrders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
108976
|
-
const liveOrder = liveOrders
|
|
109446
|
+
const liveOrder = pageOrderById(liveOrders, leg.orderId);
|
|
108977
109447
|
if (!liveOrder) {
|
|
108978
109448
|
const evidence = await fetchBrowserOrderStatusEvidence({
|
|
108979
109449
|
publicRequestPriority: "trading_reduce",
|
|
@@ -109117,25 +109587,17 @@ var init_runtime_execution = __esm({
|
|
|
109117
109587
|
);
|
|
109118
109588
|
return { group, cleanup, persistedGroupSet: persistenceFailed ? null : nextGroups };
|
|
109119
109589
|
};
|
|
109120
|
-
attachmentMemberNeverLanded = (group, leg) => group.attachmentJournal?.members.some((member) => member.clientOrderId === leg.orderId && member.neverLandedAtMs != null) === true;
|
|
109121
109590
|
storedClientProtectiveCover = async (request, entryIsLong, groups2) => {
|
|
109122
|
-
const
|
|
109123
|
-
|
|
109124
|
-
|
|
109125
|
-
(
|
|
109126
|
-
);
|
|
109127
|
-
const liveOrderIds = /* @__PURE__ */ new Set();
|
|
109128
|
-
if (storedLegs.some((leg) => !leg.beingCancelled)) {
|
|
109129
|
-
const symbol2 = request.executionContext.symbol.trim().toUpperCase();
|
|
109130
|
-
const orders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
|
|
109131
|
-
if (!Array.isArray(orders)) {
|
|
109132
|
-
throw new Error("Malformed live protective-order snapshot.");
|
|
109133
|
-
}
|
|
109134
|
-
for (const order of orders) {
|
|
109135
|
-
if (String(order.coin).trim().toUpperCase() === symbol2) liveOrderIds.add(String(order.oid));
|
|
109136
|
-
}
|
|
109591
|
+
const candidates = groups2.filter((group) => group.isLong === entryIsLong);
|
|
109592
|
+
const orders = candidates.some((group) => group.cleanupRequired !== true && group.legs.length > 0) ? await fetchClientRuntimeOpenOrders(request, "trading_reduce") : [];
|
|
109593
|
+
if (!Array.isArray(orders)) {
|
|
109594
|
+
throw new Error("Malformed live protective-order snapshot.");
|
|
109137
109595
|
}
|
|
109138
|
-
return
|
|
109596
|
+
return resolveOwnStops({
|
|
109597
|
+
symbol: request.executionContext.symbol,
|
|
109598
|
+
groups: candidates,
|
|
109599
|
+
orders
|
|
109600
|
+
}).directionCover(entryIsLong);
|
|
109139
109601
|
};
|
|
109140
109602
|
attachClientProtectivePlan = async (request, group, fill) => {
|
|
109141
109603
|
const reports = [];
|
|
@@ -109979,7 +110441,7 @@ var init_runtime_execution = __esm({
|
|
|
109979
110441
|
}
|
|
109980
110442
|
})));
|
|
109981
110443
|
}
|
|
109982
|
-
const
|
|
110444
|
+
const ownStops = resolveOwnStops({ symbol: symbol2, groups: readClientProtectiveGroups(profileId, symbol2), orders: liveOrders });
|
|
109983
110445
|
for (const journaledGroup of journaledGroups) {
|
|
109984
110446
|
let group = journaledGroup;
|
|
109985
110447
|
const plan = group.pendingEntry;
|
|
@@ -109994,7 +110456,7 @@ var init_runtime_execution = __esm({
|
|
|
109994
110456
|
inspected.push({ leg: provisionalLeg, state: "terminal", rested: false, neverLanded: true });
|
|
109995
110457
|
continue;
|
|
109996
110458
|
}
|
|
109997
|
-
let openOrder = liveOrders
|
|
110459
|
+
let openOrder = pageOrderById(liveOrders, provisionalLeg.orderId);
|
|
109998
110460
|
let canonicalLeg = provisionalLeg;
|
|
109999
110461
|
if (openOrder == null) {
|
|
110000
110462
|
try {
|
|
@@ -110024,12 +110486,7 @@ var init_runtime_execution = __esm({
|
|
|
110024
110486
|
throw new Error("Journaled protective order identity is unresolved.");
|
|
110025
110487
|
}
|
|
110026
110488
|
} else {
|
|
110027
|
-
const mayRestUnseen =
|
|
110028
|
-
shape: liveProtectiveOrderShape(order),
|
|
110029
|
-
symbol: symbol2,
|
|
110030
|
-
isLong: group.isLong,
|
|
110031
|
-
leg: provisionalLeg
|
|
110032
|
-
}));
|
|
110489
|
+
const mayRestUnseen = ownStops.restsUnnamed(group, provisionalLeg);
|
|
110033
110490
|
if (ledgerVerdict.proven && !mayRestUnseen) {
|
|
110034
110491
|
newlyNeverLanded.add(provisionalLeg.orderId);
|
|
110035
110492
|
inspected.push({ leg: provisionalLeg, state: "terminal", rested: false, neverLanded: true });
|
|
@@ -110042,7 +110499,7 @@ var init_runtime_execution = __esm({
|
|
|
110042
110499
|
throw new Error("Journaled protective order identity is unresolved.");
|
|
110043
110500
|
}
|
|
110044
110501
|
canonicalLeg = { ...provisionalLeg, orderId: resolvedOrderId };
|
|
110045
|
-
openOrder = liveOrders
|
|
110502
|
+
openOrder = pageOrderById(liveOrders, resolvedOrderId);
|
|
110046
110503
|
if (classifyHyperliquidOrderStatus(evidence.orderStatus) === "open" && openOrder != null) {
|
|
110047
110504
|
} else {
|
|
110048
110505
|
const terminalMatches = protectiveTerminalShapeMatches({
|
|
@@ -110974,7 +111431,7 @@ var init_runtime_execution = __esm({
|
|
|
110974
111431
|
let shapeMatches = exactShapeMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open";
|
|
110975
111432
|
if (!shapeMatches && evidence.reasonCode === "unknown_oid") {
|
|
110976
111433
|
const liveOrders = await fetchClientRuntimeOpenOrders(request);
|
|
110977
|
-
const originalOrder = liveOrders
|
|
111434
|
+
const originalOrder = pageOrderById(liveOrders, replacement.previousOrderId);
|
|
110978
111435
|
const originalLiveShape = originalOrder == null ? null : {
|
|
110979
111436
|
coin: originalOrder.coin,
|
|
110980
111437
|
side: originalOrder.side,
|
|
@@ -111297,23 +111754,13 @@ var init_runtime_execution = __esm({
|
|
|
111297
111754
|
}
|
|
111298
111755
|
return reports;
|
|
111299
111756
|
};
|
|
111300
|
-
liveProtectiveOrderShape = (order) => ({
|
|
111301
|
-
coin: order.coin,
|
|
111302
|
-
side: order.side,
|
|
111303
|
-
size: order.sz,
|
|
111304
|
-
reduceOnly: order.reduce_only,
|
|
111305
|
-
isTrigger: order.is_trigger,
|
|
111306
|
-
triggerKind: order.trigger_kind,
|
|
111307
|
-
triggerPrice: order.trigger_px,
|
|
111308
|
-
isPositionTpsl: order.is_position_tpsl
|
|
111309
|
-
});
|
|
111310
111757
|
observedStandaloneProtectiveGroup = (group, liveOrders, symbol2) => {
|
|
111311
111758
|
if (!group.legs.some((leg) => leg.positionTpsl === true) || group.legs.some((leg) => leg.replacement != null)) {
|
|
111312
111759
|
return null;
|
|
111313
111760
|
}
|
|
111314
111761
|
let standaloneObserved = false;
|
|
111315
111762
|
for (const leg of group.legs) {
|
|
111316
|
-
const liveOrder = liveOrders
|
|
111763
|
+
const liveOrder = pageOrderById(liveOrders, leg.orderId);
|
|
111317
111764
|
if (liveOrder == null) continue;
|
|
111318
111765
|
if (liveOrder.is_position_tpsl !== false) return null;
|
|
111319
111766
|
if (protectiveLiveShapeMatches({
|
|
@@ -111704,6 +112151,7 @@ var init_runtime_execution = __esm({
|
|
|
111704
112151
|
return { leg, notLanded: true, reports: [] };
|
|
111705
112152
|
};
|
|
111706
112153
|
const inspectedGroups = [];
|
|
112154
|
+
const lookedUp = /* @__PURE__ */ new Map();
|
|
111707
112155
|
const legsLiveSinceMs = protectiveReadStampMs();
|
|
111708
112156
|
for (const observedGroup of groups2) {
|
|
111709
112157
|
let group = observedGroup;
|
|
@@ -111735,7 +112183,7 @@ var init_runtime_execution = __esm({
|
|
|
111735
112183
|
let ambiguousPositionTpslAuthority = hasAmbiguousClientPositionTpslAuthority(group);
|
|
111736
112184
|
if (ambiguousPositionTpslAuthority) {
|
|
111737
112185
|
const singleLeg = group.legs.length === 1 ? group.legs[0] : null;
|
|
111738
|
-
const liveOrder = singleLeg == null ? null : liveOrders
|
|
112186
|
+
const liveOrder = singleLeg == null ? null : pageOrderById(liveOrders, singleLeg.orderId);
|
|
111739
112187
|
const liveShape = liveOrder == null ? null : {
|
|
111740
112188
|
coin: liveOrder.coin,
|
|
111741
112189
|
side: liveOrder.side,
|
|
@@ -111796,7 +112244,7 @@ var init_runtime_execution = __esm({
|
|
|
111796
112244
|
});
|
|
111797
112245
|
continue;
|
|
111798
112246
|
}
|
|
111799
|
-
const openOrder = liveOrders
|
|
112247
|
+
const openOrder = pageOrderById(liveOrders, leg.orderId);
|
|
111800
112248
|
if (openOrder != null) {
|
|
111801
112249
|
legs.push({ leg, openOrder, state: "open" });
|
|
111802
112250
|
continue;
|
|
@@ -111827,8 +112275,11 @@ var init_runtime_execution = __esm({
|
|
|
111827
112275
|
leg
|
|
111828
112276
|
});
|
|
111829
112277
|
const resolvedNumericOrderId = Number(evidence.orderId);
|
|
112278
|
+
if (evidence.responseValid && evidence.orderMatches && Number.isSafeInteger(resolvedNumericOrderId) && resolvedNumericOrderId > 0) {
|
|
112279
|
+
lookedUp.set(String(leg.orderId), resolvedNumericOrderId);
|
|
112280
|
+
}
|
|
111830
112281
|
const inspectedLeg = evidence.responseValid && evidence.orderMatches && classifyHyperliquidOrderStatus(evidence.orderStatus) === "open" && Number.isSafeInteger(resolvedNumericOrderId) && resolvedNumericOrderId > 0 ? { ...leg, orderId: resolvedNumericOrderId } : leg;
|
|
111831
|
-
const resolvedOpenOrder = inspectedLeg.orderId !== leg.orderId ? liveOrders
|
|
112282
|
+
const resolvedOpenOrder = inspectedLeg.orderId !== leg.orderId ? pageOrderById(liveOrders, inspectedLeg.orderId) : null;
|
|
111832
112283
|
legs.push({
|
|
111833
112284
|
leg: inspectedLeg,
|
|
111834
112285
|
openOrder: resolvedOpenOrder,
|
|
@@ -111899,10 +112350,9 @@ var init_runtime_execution = __esm({
|
|
|
111899
112350
|
};
|
|
111900
112351
|
const retainedGroups = expectedGroupSet.filter((group) => group.pendingEntry != null || isProtectiveReplacementJournalGroup(group));
|
|
111901
112352
|
let stopSizePlacedThisPass = 0;
|
|
111902
|
-
const
|
|
111903
|
-
const
|
|
111904
|
-
|
|
111905
|
-
);
|
|
112353
|
+
const placedThisPass = /* @__PURE__ */ new Set();
|
|
112354
|
+
const unresolvedLegIds = new Set(inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "unresolved").map((entry) => String(entry.leg.orderId)));
|
|
112355
|
+
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)]));
|
|
111906
112356
|
const lostStatuses = () => inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "terminal").map((entry) => ({ state: "terminal", receivedMs: entry.statusReceivedMs ?? null }));
|
|
111907
112357
|
const readQualifies = (sentMs) => lostLegMarketEvidence({
|
|
111908
112358
|
statuses: lostStatuses(),
|
|
@@ -112023,15 +112473,17 @@ var init_runtime_execution = __esm({
|
|
|
112023
112473
|
cancelledByUser,
|
|
112024
112474
|
terminalOrderStatus: terminalStatus?.orderStatus ?? null
|
|
112025
112475
|
});
|
|
112476
|
+
const stops = replaceReachable ? resolveOwnStops({
|
|
112477
|
+
symbol: symbol2,
|
|
112478
|
+
groups: expectedGroupSet,
|
|
112479
|
+
orders: (await readLostLegOrders()).freshOrders,
|
|
112480
|
+
lookedUp,
|
|
112481
|
+
unresolved: unresolvedLegIds
|
|
112482
|
+
}).lostStopCover(position.positionSize, { lost: lostOrderIds, placed: placedThisPass }) : null;
|
|
112026
112483
|
evidence = {
|
|
112027
112484
|
positionSize: position.positionSize,
|
|
112028
|
-
liveStopSize:
|
|
112029
|
-
|
|
112030
|
-
symbol: symbol2,
|
|
112031
|
-
positionSize: position.positionSize,
|
|
112032
|
-
excludedOrderIds: lostOrderIds,
|
|
112033
|
-
groups: expectedGroupSet
|
|
112034
|
-
}) : 0,
|
|
112485
|
+
liveStopSize: stops?.onPage ?? 0,
|
|
112486
|
+
unseenStopSize: stops?.unseen ?? 0,
|
|
112035
112487
|
markPrice: replaceReachable ? position.markPrice : null
|
|
112036
112488
|
};
|
|
112037
112489
|
} catch (error48) {
|
|
@@ -112056,7 +112508,7 @@ var init_runtime_execution = __esm({
|
|
|
112056
112508
|
positionSize: evidence.positionSize,
|
|
112057
112509
|
legSize: leg.size,
|
|
112058
112510
|
otherLiveStopSize: evidence.liveStopSize,
|
|
112059
|
-
inFlightStopSize:
|
|
112511
|
+
inFlightStopSize: evidence.unseenStopSize + stopSizePlacedThisPass,
|
|
112060
112512
|
sizeDecimals: request.executionContext.sizeDecimals,
|
|
112061
112513
|
triggerPrice: leg.triggerPrice,
|
|
112062
112514
|
alreadyReplaced: leg.replacedOrderId != null,
|
|
@@ -112165,6 +112617,7 @@ var init_runtime_execution = __esm({
|
|
|
112165
112617
|
};
|
|
112166
112618
|
}
|
|
112167
112619
|
stopSizePlacedThisPass += decision.size;
|
|
112620
|
+
placedThisPass.add(clientOrderId);
|
|
112168
112621
|
let dispatchMayHaveStarted = false;
|
|
112169
112622
|
let response;
|
|
112170
112623
|
try {
|
|
@@ -112196,6 +112649,7 @@ var init_runtime_execution = __esm({
|
|
|
112196
112649
|
if (error48 instanceof HyperliquidExchangeRejectionError) {
|
|
112197
112650
|
const rejectionProjection = projectExecutionErrorContract({ error: error48, symbol: symbol2 });
|
|
112198
112651
|
stopSizePlacedThisPass -= decision.size;
|
|
112652
|
+
placedThisPass.delete(clientOrderId);
|
|
112199
112653
|
const rejectedGroup = {
|
|
112200
112654
|
...provisionalGroup,
|
|
112201
112655
|
legs: provisionalGroup.legs.filter((candidate) => candidate.orderId !== clientOrderId)
|
|
@@ -112223,6 +112677,7 @@ var init_runtime_execution = __esm({
|
|
|
112223
112677
|
}
|
|
112224
112678
|
if (!dispatchMayHaveStarted) {
|
|
112225
112679
|
stopSizePlacedThisPass -= decision.size;
|
|
112680
|
+
placedThisPass.delete(clientOrderId);
|
|
112226
112681
|
const restored = transitionExactGroup(provisionalGroup, group);
|
|
112227
112682
|
if (restored && isClientRuntimeWindowHandoffBeforePlanDispatch(error48)) {
|
|
112228
112683
|
throw error48;
|
|
@@ -112278,6 +112733,7 @@ var init_runtime_execution = __esm({
|
|
|
112278
112733
|
}]
|
|
112279
112734
|
};
|
|
112280
112735
|
}
|
|
112736
|
+
placedThisPass.add(String(placedOrderId));
|
|
112281
112737
|
const { replaceJournal: _landedJournal, ...landedLeg } = provisionalLeg;
|
|
112282
112738
|
const placedLeg = { ...landedLeg, orderId: placedOrderId };
|
|
112283
112739
|
const placedGroup = {
|
|
@@ -112325,6 +112781,13 @@ var init_runtime_execution = __esm({
|
|
|
112325
112781
|
execution_metadata: { reason_code: "protective_lifecycle_persistence_failed" }
|
|
112326
112782
|
});
|
|
112327
112783
|
};
|
|
112784
|
+
const ownStops = resolveOwnStops({
|
|
112785
|
+
symbol: symbol2,
|
|
112786
|
+
groups: expectedGroupSet,
|
|
112787
|
+
orders: liveOrders,
|
|
112788
|
+
lookedUp,
|
|
112789
|
+
unresolved: unresolvedLegIds
|
|
112790
|
+
});
|
|
112328
112791
|
groupLoop: for (let groupIndex = 0; groupIndex < inspectedGroups.length; groupIndex += 1) {
|
|
112329
112792
|
const inspected = inspectedGroups[groupIndex];
|
|
112330
112793
|
let durableGroup = inspected.group;
|
|
@@ -112402,10 +112865,7 @@ var init_runtime_execution = __esm({
|
|
|
112402
112865
|
continue;
|
|
112403
112866
|
}
|
|
112404
112867
|
if (state2 !== "open" || openOrder == null) {
|
|
112405
|
-
remainingByKind[leg.kind] = Math.max(
|
|
112406
|
-
0,
|
|
112407
|
-
remainingByKind[leg.kind] - protectiveLegCoverSize(leg)
|
|
112408
|
-
);
|
|
112868
|
+
remainingByKind[leg.kind] = Math.max(0, remainingByKind[leg.kind] - ownStops.cover(leg) - ownStops.inFlight(leg));
|
|
112409
112869
|
retainedLegs.push(leg);
|
|
112410
112870
|
continue;
|
|
112411
112871
|
}
|
|
@@ -112419,7 +112879,7 @@ var init_runtime_execution = __esm({
|
|
|
112419
112879
|
const reservedUntrustedExposure = Number.isFinite(liveOrderSize) && liveOrderSize > 0 ? Math.max(leg.size, liveOrderSize) : leg.size;
|
|
112420
112880
|
remainingByKind[leg.kind] = Math.max(
|
|
112421
112881
|
0,
|
|
112422
|
-
remainingByKind[leg.kind] - reservedUntrustedExposure
|
|
112882
|
+
remainingByKind[leg.kind] - (ownStops.leaving(leg) ? 0 : reservedUntrustedExposure)
|
|
112423
112883
|
);
|
|
112424
112884
|
retainedLegs.push(leg);
|
|
112425
112885
|
reports.push({
|
|
@@ -112433,14 +112893,15 @@ var init_runtime_execution = __esm({
|
|
|
112433
112893
|
});
|
|
112434
112894
|
continue;
|
|
112435
112895
|
}
|
|
112896
|
+
if (ownStops.leaving(leg)) {
|
|
112897
|
+
retainedLegs.push(leg);
|
|
112898
|
+
continue;
|
|
112899
|
+
}
|
|
112436
112900
|
const allowedSize = roundAssetSize(
|
|
112437
112901
|
Math.min(liveOrderSize, remainingByKind[leg.kind]),
|
|
112438
112902
|
request.executionContext.sizeDecimals
|
|
112439
112903
|
);
|
|
112440
|
-
remainingByKind[leg.kind] = Math.max(
|
|
112441
|
-
0,
|
|
112442
|
-
remainingByKind[leg.kind] - Math.min(allowedSize, protectiveLegCoverSize(leg, liveOrderSize))
|
|
112443
|
-
);
|
|
112904
|
+
remainingByKind[leg.kind] = Math.max(0, remainingByKind[leg.kind] - Math.min(allowedSize, ownStops.cover(leg)));
|
|
112444
112905
|
if (allowedSize <= 0) {
|
|
112445
112906
|
const split3 = splitOversizedProtectiveLeg(expectedGroupSet, durableGroup, leg, exactClientProtectiveGroupSnapshot);
|
|
112446
112907
|
if (!replaceExactClientProtectiveGroupSet(profileId, symbol2, expectedGroupSet, split3.groups)) {
|
|
@@ -112953,7 +113414,10 @@ var init_runtime_execution = __esm({
|
|
|
112953
113414
|
"trading_reduce"
|
|
112954
113415
|
)).size),
|
|
112955
113416
|
openOrders: async () => observed.orders ?? await fetchClientRuntimeOpenOrders(request, "trading_reduce"),
|
|
112956
|
-
rests: (leg, isLong, orders) =>
|
|
113417
|
+
rests: (leg, isLong, orders) => {
|
|
113418
|
+
const order = Array.isArray(orders) ? pageOrderById(orders, leg.orderId) : null;
|
|
113419
|
+
return order != null && protectiveLiveShapeMatches({ shape: liveProtectiveOrderShape(order), symbol: symbol2, isLong, leg });
|
|
113420
|
+
},
|
|
112957
113421
|
markPrice: () => readTrailingMarkPrice({ config: request.config ?? null, signal: request.signal }, symbol2),
|
|
112958
113422
|
sizeDecimals: async () => Number.isInteger(request.executionContext.sizeDecimals) ? request.executionContext.sizeDecimals : resolveExchangeSizeDecimals(symbol2, request.config ?? void 0, "trading_reduce", profileId),
|
|
112959
113423
|
modify: (leg, change) => modifyClientTrailingLeg(request, leg, change),
|
|
@@ -113267,8 +113731,8 @@ var init_runtime_execution = __esm({
|
|
|
113267
113731
|
const previous = clientExecutionMutations.get(key) ?? Promise.resolve();
|
|
113268
113732
|
let abandoned = false;
|
|
113269
113733
|
let startTurn;
|
|
113270
|
-
const turn = new Promise((
|
|
113271
|
-
startTurn =
|
|
113734
|
+
const turn = new Promise((resolve17) => {
|
|
113735
|
+
startTurn = resolve17;
|
|
113272
113736
|
});
|
|
113273
113737
|
const pending3 = previous.catch(() => void 0).then(async () => {
|
|
113274
113738
|
if (abandoned) return void 0;
|
|
@@ -113282,7 +113746,7 @@ var init_runtime_execution = __esm({
|
|
|
113282
113746
|
clientExecutionMutations.set(key, pending3);
|
|
113283
113747
|
const waitMs = runtime_policy_generated_default2.trading.engine.client_runtime.execution_mutation_queue.wait_seconds * MS_PER_SECOND;
|
|
113284
113748
|
try {
|
|
113285
|
-
await new Promise((
|
|
113749
|
+
await new Promise((resolve17, reject) => {
|
|
113286
113750
|
const signal = request.signal;
|
|
113287
113751
|
const finish = () => {
|
|
113288
113752
|
clearTimeout(timer);
|
|
@@ -113304,7 +113768,7 @@ var init_runtime_execution = __esm({
|
|
|
113304
113768
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
113305
113769
|
void turn.then(() => {
|
|
113306
113770
|
finish();
|
|
113307
|
-
|
|
113771
|
+
resolve17();
|
|
113308
113772
|
});
|
|
113309
113773
|
});
|
|
113310
113774
|
return await pending3;
|
|
@@ -116427,7 +116891,7 @@ var init_browser_observability = __esm({
|
|
|
116427
116891
|
init_define_VTX_GROK_POLICY();
|
|
116428
116892
|
init_define_VTX_PI_MODEL_POLICY();
|
|
116429
116893
|
init_runtime_policy_generated2();
|
|
116430
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
116894
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim() && "1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim() !== "unstamped" ? "1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim() : null;
|
|
116431
116895
|
listenersInstalled = false;
|
|
116432
116896
|
state = {
|
|
116433
116897
|
loadedAtMs: Date.now(),
|
|
@@ -117700,21 +118164,21 @@ var require_react_development = __commonJS({
|
|
|
117700
118164
|
);
|
|
117701
118165
|
actScopeDepth = prevActScopeDepth;
|
|
117702
118166
|
}
|
|
117703
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
118167
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve17, reject) {
|
|
117704
118168
|
var queue = ReactSharedInternals.actQueue;
|
|
117705
118169
|
if (null !== queue)
|
|
117706
118170
|
if (0 !== queue.length)
|
|
117707
118171
|
try {
|
|
117708
118172
|
flushActQueue(queue);
|
|
117709
118173
|
enqueueTask(function() {
|
|
117710
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
118174
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve17, reject);
|
|
117711
118175
|
});
|
|
117712
118176
|
return;
|
|
117713
118177
|
} catch (error48) {
|
|
117714
118178
|
ReactSharedInternals.thrownErrors.push(error48);
|
|
117715
118179
|
}
|
|
117716
118180
|
else ReactSharedInternals.actQueue = null;
|
|
117717
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
118181
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve17(returnValue);
|
|
117718
118182
|
}
|
|
117719
118183
|
function flushActQueue(queue) {
|
|
117720
118184
|
if (!isFlushing) {
|
|
@@ -117901,7 +118365,7 @@ var require_react_development = __commonJS({
|
|
|
117901
118365
|
));
|
|
117902
118366
|
});
|
|
117903
118367
|
return {
|
|
117904
|
-
then: function(
|
|
118368
|
+
then: function(resolve17, reject) {
|
|
117905
118369
|
didAwaitActCall = true;
|
|
117906
118370
|
thenable.then(
|
|
117907
118371
|
function(returnValue) {
|
|
@@ -117911,7 +118375,7 @@ var require_react_development = __commonJS({
|
|
|
117911
118375
|
flushActQueue(queue), enqueueTask(function() {
|
|
117912
118376
|
return recursivelyFlushAsyncActWork(
|
|
117913
118377
|
returnValue,
|
|
117914
|
-
|
|
118378
|
+
resolve17,
|
|
117915
118379
|
reject
|
|
117916
118380
|
);
|
|
117917
118381
|
});
|
|
@@ -117925,7 +118389,7 @@ var require_react_development = __commonJS({
|
|
|
117925
118389
|
ReactSharedInternals.thrownErrors.length = 0;
|
|
117926
118390
|
reject(_thrownError);
|
|
117927
118391
|
}
|
|
117928
|
-
} else
|
|
118392
|
+
} else resolve17(returnValue);
|
|
117929
118393
|
},
|
|
117930
118394
|
function(error48) {
|
|
117931
118395
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
@@ -117947,15 +118411,15 @@ var require_react_development = __commonJS({
|
|
|
117947
118411
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
117948
118412
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
117949
118413
|
return {
|
|
117950
|
-
then: function(
|
|
118414
|
+
then: function(resolve17, reject) {
|
|
117951
118415
|
didAwaitActCall = true;
|
|
117952
118416
|
0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
117953
118417
|
return recursivelyFlushAsyncActWork(
|
|
117954
118418
|
returnValue$jscomp$0,
|
|
117955
|
-
|
|
118419
|
+
resolve17,
|
|
117956
118420
|
reject
|
|
117957
118421
|
);
|
|
117958
|
-
})) :
|
|
118422
|
+
})) : resolve17(returnValue$jscomp$0);
|
|
117959
118423
|
}
|
|
117960
118424
|
};
|
|
117961
118425
|
};
|
|
@@ -119509,7 +119973,7 @@ var init_client_trade_readback = __esm({
|
|
|
119509
119973
|
close_fill_sync_retry_step_milliseconds: retryStepMs
|
|
119510
119974
|
} = runtime_policy_generated_default2.trading.engine.client_runtime;
|
|
119511
119975
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
119512
|
-
if (attempt2 > 0) await new Promise((
|
|
119976
|
+
if (attempt2 > 0) await new Promise((resolve17) => setTimeout(resolve17, attempt2 * retryStepMs));
|
|
119513
119977
|
try {
|
|
119514
119978
|
const { rawFills } = await fetchBrowserUserFills({
|
|
119515
119979
|
config: target.config,
|
|
@@ -120854,14 +121318,14 @@ var init_client_panel_reads = __esm({
|
|
|
120854
121318
|
const retryAfter = Number(error48.retryAfterMs);
|
|
120855
121319
|
return Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : runtime_policy_generated_default2.exchange.hyperliquid.public_recovery.queue_poll_ms;
|
|
120856
121320
|
};
|
|
120857
|
-
waitForCapacity = (ms, signal) => new Promise((
|
|
121321
|
+
waitForCapacity = (ms, signal) => new Promise((resolve17, reject) => {
|
|
120858
121322
|
if (signal?.aborted) {
|
|
120859
121323
|
reject(signal.reason);
|
|
120860
121324
|
return;
|
|
120861
121325
|
}
|
|
120862
121326
|
const done = () => {
|
|
120863
121327
|
signal?.removeEventListener("abort", aborted2);
|
|
120864
|
-
|
|
121328
|
+
resolve17();
|
|
120865
121329
|
};
|
|
120866
121330
|
const timer = setTimeout(done, Math.max(1, ms));
|
|
120867
121331
|
const aborted2 = () => {
|
|
@@ -122453,9 +122917,9 @@ var init_market_regime = __esm({
|
|
|
122453
122917
|
return token;
|
|
122454
122918
|
};
|
|
122455
122919
|
resolvePromptTimeframes = (activeTimeframes, fallbackTimeframes) => {
|
|
122456
|
-
const
|
|
122457
|
-
const resolved =
|
|
122458
|
-
return [...new Set(resolved.length > 0 ? resolved :
|
|
122920
|
+
const resolve17 = (values) => values.filter((value) => typeof value === "string").map(canonicalTimeframe).filter(Boolean);
|
|
122921
|
+
const resolved = resolve17(activeTimeframes);
|
|
122922
|
+
return [...new Set(resolved.length > 0 ? resolved : resolve17(fallbackTimeframes))];
|
|
122459
122923
|
};
|
|
122460
122924
|
scopeSymbolLines = (message, symbol2) => message.trim().split(LINE_BREAK).map((line) => line.trim()).filter((line) => line && !line.startsWith("---")).map((line) => {
|
|
122461
122925
|
if (line.startsWith("- [")) return line.replace("- [", `- [${symbol2} `);
|
|
@@ -123365,7 +123829,7 @@ var init_google_egress = __esm({
|
|
|
123365
123829
|
// lib/runtime/native-provider-budget.ts
|
|
123366
123830
|
function awaitProviderOperation(operation, signal) {
|
|
123367
123831
|
if (!signal) return operation;
|
|
123368
|
-
return new Promise((
|
|
123832
|
+
return new Promise((resolve17, reject) => {
|
|
123369
123833
|
const aborted2 = () => {
|
|
123370
123834
|
signal.removeEventListener("abort", aborted2);
|
|
123371
123835
|
reject(signal.reason ?? new DOMException("Cancelled", "AbortError"));
|
|
@@ -123373,7 +123837,7 @@ function awaitProviderOperation(operation, signal) {
|
|
|
123373
123837
|
operation.then((value) => {
|
|
123374
123838
|
signal.removeEventListener("abort", aborted2);
|
|
123375
123839
|
if (signal.aborted) aborted2();
|
|
123376
|
-
else
|
|
123840
|
+
else resolve17(value);
|
|
123377
123841
|
}, (error48) => {
|
|
123378
123842
|
signal.removeEventListener("abort", aborted2);
|
|
123379
123843
|
reject(signal.aborted ? signal.reason ?? error48 : error48);
|
|
@@ -123385,8 +123849,8 @@ function awaitProviderOperation(operation, signal) {
|
|
|
123385
123849
|
async function waitForProviderRetry(delayMs, signal) {
|
|
123386
123850
|
let timer;
|
|
123387
123851
|
try {
|
|
123388
|
-
await awaitProviderOperation(new Promise((
|
|
123389
|
-
timer = setTimeout(
|
|
123852
|
+
await awaitProviderOperation(new Promise((resolve17) => {
|
|
123853
|
+
timer = setTimeout(resolve17, delayMs);
|
|
123390
123854
|
}), signal);
|
|
123391
123855
|
} finally {
|
|
123392
123856
|
if (timer !== void 0) clearTimeout(timer);
|
|
@@ -123416,6 +123880,122 @@ var init_native_provider_budget = __esm({
|
|
|
123416
123880
|
}
|
|
123417
123881
|
});
|
|
123418
123882
|
|
|
123883
|
+
// lib/runtime/provider-reply.ts
|
|
123884
|
+
var PROVIDER_LIMIT_HEADERS_HEADER, providerResponseSignals, replyBodies, rememberProviderReplyBody, readProviderPayload, rawProviderTextForDebug, extractProviderErrorDetail, extractProviderErrorWords, providerReplyHeaders, providerReplyDiagnostics;
|
|
123885
|
+
var init_provider_reply = __esm({
|
|
123886
|
+
"lib/runtime/provider-reply.ts"() {
|
|
123887
|
+
"use strict";
|
|
123888
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
123889
|
+
init_define_VTX_EXO_POLICY();
|
|
123890
|
+
init_define_VTX_GROK_POLICY();
|
|
123891
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
123892
|
+
init_native_provider_budget();
|
|
123893
|
+
init_provider_credit();
|
|
123894
|
+
init_runtime_redaction();
|
|
123895
|
+
init_provider_observability();
|
|
123896
|
+
init_constants();
|
|
123897
|
+
PROVIDER_LIMIT_HEADERS_HEADER = "X-VTX-Provider-Limit-Headers";
|
|
123898
|
+
providerResponseSignals = /* @__PURE__ */ new WeakMap();
|
|
123899
|
+
replyBodies = /* @__PURE__ */ new WeakMap();
|
|
123900
|
+
rememberProviderReplyBody = (response, body) => {
|
|
123901
|
+
replyBodies.set(response, body);
|
|
123902
|
+
};
|
|
123903
|
+
readProviderPayload = async (response) => {
|
|
123904
|
+
if (typeof response?.text === "function") {
|
|
123905
|
+
const raw = await awaitProviderOperation(response.text(), providerResponseSignals.get(response));
|
|
123906
|
+
if (typeof raw === "string" && raw) replyBodies.set(response, raw);
|
|
123907
|
+
const normalizedRaw = typeof raw === "string" ? raw.trim() : "";
|
|
123908
|
+
if (!normalizedRaw) {
|
|
123909
|
+
return { payload: {}, rawText: "" };
|
|
123910
|
+
}
|
|
123911
|
+
try {
|
|
123912
|
+
return {
|
|
123913
|
+
payload: JSON.parse(normalizedRaw),
|
|
123914
|
+
rawText: normalizedRaw
|
|
123915
|
+
};
|
|
123916
|
+
} catch {
|
|
123917
|
+
return {
|
|
123918
|
+
payload: {},
|
|
123919
|
+
rawText: normalizedRaw
|
|
123920
|
+
};
|
|
123921
|
+
}
|
|
123922
|
+
}
|
|
123923
|
+
const payload = await awaitProviderOperation(response.json(), providerResponseSignals.get(response));
|
|
123924
|
+
return {
|
|
123925
|
+
payload,
|
|
123926
|
+
rawText: ""
|
|
123927
|
+
};
|
|
123928
|
+
};
|
|
123929
|
+
rawProviderTextForDebug = (payload, rawText) => {
|
|
123930
|
+
if (!rawText) {
|
|
123931
|
+
return null;
|
|
123932
|
+
}
|
|
123933
|
+
if (!payload || typeof payload === "object" && !Array.isArray(payload) && Object.keys(payload).length === 0) {
|
|
123934
|
+
return rawText;
|
|
123935
|
+
}
|
|
123936
|
+
return null;
|
|
123937
|
+
};
|
|
123938
|
+
extractProviderErrorDetail = (payload, rawText) => {
|
|
123939
|
+
const words7 = extractProviderErrorWords(payload, rawText);
|
|
123940
|
+
const outOfCreditCode = providerOutOfCreditErrorCode(payload);
|
|
123941
|
+
return outOfCreditCode && !words7.toLowerCase().includes(outOfCreditCode.toLowerCase()) ? `${words7}${words7 ? " " : ""}[${outOfCreditCode}]` : words7;
|
|
123942
|
+
};
|
|
123943
|
+
extractProviderErrorWords = (payload, rawText) => {
|
|
123944
|
+
const errorNode = payload?.error;
|
|
123945
|
+
if (typeof errorNode === "string" && errorNode.trim()) {
|
|
123946
|
+
return errorNode.trim();
|
|
123947
|
+
}
|
|
123948
|
+
if (typeof errorNode?.message === "string" && errorNode.message.trim()) {
|
|
123949
|
+
return errorNode.message.trim();
|
|
123950
|
+
}
|
|
123951
|
+
if (typeof errorNode?.detail === "string" && errorNode.detail.trim()) {
|
|
123952
|
+
return errorNode.detail.trim();
|
|
123953
|
+
}
|
|
123954
|
+
if (typeof payload?.detail === "string" && payload.detail.trim()) {
|
|
123955
|
+
return payload.detail.trim();
|
|
123956
|
+
}
|
|
123957
|
+
if (typeof payload?.message === "string" && payload.message.trim()) {
|
|
123958
|
+
return payload.message.trim();
|
|
123959
|
+
}
|
|
123960
|
+
if (rawText) {
|
|
123961
|
+
return sanitizeRuntimeDiagnosticValue(rawText).replace(/\s+/g, " ").slice(0, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS);
|
|
123962
|
+
}
|
|
123963
|
+
return "";
|
|
123964
|
+
};
|
|
123965
|
+
providerReplyHeaders = (response) => {
|
|
123966
|
+
const headers = {};
|
|
123967
|
+
const read = response?.headers;
|
|
123968
|
+
if (!read || typeof read.forEach !== "function") return headers;
|
|
123969
|
+
try {
|
|
123970
|
+
const relayed = JSON.parse(read.get(PROVIDER_LIMIT_HEADERS_HEADER) || "{}");
|
|
123971
|
+
if (relayed && typeof relayed === "object" && !Array.isArray(relayed)) {
|
|
123972
|
+
for (const [name, value] of Object.entries(relayed)) {
|
|
123973
|
+
if (typeof value === "string" && isProviderReplyHeaderName(name)) headers[name.toLowerCase()] = value;
|
|
123974
|
+
}
|
|
123975
|
+
}
|
|
123976
|
+
} catch {
|
|
123977
|
+
}
|
|
123978
|
+
read.forEach((value, name) => {
|
|
123979
|
+
if (isProviderReplyHeaderName(name)) headers[name.toLowerCase()] = value;
|
|
123980
|
+
});
|
|
123981
|
+
return headers;
|
|
123982
|
+
};
|
|
123983
|
+
providerReplyDiagnostics = (response, body) => {
|
|
123984
|
+
if (!response) return {};
|
|
123985
|
+
const text2 = typeof body === "string" && body ? body : replyBodies.get(response);
|
|
123986
|
+
const headers = providerReplyHeaders(response);
|
|
123987
|
+
if (!text2 && !Object.keys(headers).length) return {};
|
|
123988
|
+
return {
|
|
123989
|
+
provider_reply: {
|
|
123990
|
+
...typeof response.status === "number" ? { status: response.status } : {},
|
|
123991
|
+
...text2 ? { body: text2 } : {},
|
|
123992
|
+
...Object.keys(headers).length ? { headers } : {}
|
|
123993
|
+
}
|
|
123994
|
+
};
|
|
123995
|
+
};
|
|
123996
|
+
}
|
|
123997
|
+
});
|
|
123998
|
+
|
|
123419
123999
|
// lib/screener-resource-scheduler.ts
|
|
123420
124000
|
var STORAGE_KEY, CHANNEL_NAME, LOCK_TTL_MS, nowMs, stableHash, storage2, readStore, writeStore, prune2, buildLlmResourceKey, registerTraderProviderCallStarted, registerTraderProviderCallFinished;
|
|
123421
124001
|
var init_screener_resource_scheduler = __esm({
|
|
@@ -123682,7 +124262,7 @@ var init_native_request_parameters = __esm({
|
|
|
123682
124262
|
});
|
|
123683
124263
|
|
|
123684
124264
|
// lib/runtime/provider-client.ts
|
|
123685
|
-
var mapOpenAiCompatibleNativeRequestPath, isRetryableProviderFailureForFallback, extractRuntimeProviderFailureStatusCode, isModelSpecificProviderFailure, emptyProviderContentError, isEmptyProviderContentFailure, emptyReplyForInternalAttempt, isEmptyProviderMessageFailure, isRetryableProviderAttemptFailure, providerRejectedRequestError, OPTIONAL_CONTRACT_PARAMETER_TOKENS, OPTIONAL_CONTRACT_REJECTION_TOKENS, OPTIONAL_CONTRACT_GRAMMAR_TOKENS, isOptionalContractParameterRejection, isTemperatureRefusal, PROVIDER_ROUTE_REFUSAL_PHRASE, isProviderRouteRefusal, OPTIONAL_CONTRACT_REQUEST_KEYS, OPTIONAL_CONTRACT_EXTRA_BODY_KEYS, resolveEmptyContentRetryPolicy, resolveStreamRetryPolicy, isKeySpecificOrTransientProviderFailure, providerDispatchClockMs, beginProviderDispatch, providerDispatchLatencyMs, attachProviderDispatchFailure, attachProviderFailureTrace, toRuntimeExecutionMode, buildNoneReasoningPayload, normalizeLevelValue, buildRuntimeReasoningPayload, resolveProviderReasoningParameters, requestedReasoningParameters, usesReasoningCompletionTokens, shouldRequestReasoningTrace, runtimeProviderForByokProvider, findByokProviderForRuntime, findModelOption, findNativeRequestParametersForModel, modelHasNativeRequestApiSurface, asRequestRecord, setDottedRequestValue, normalizeProviderMaxTokens, applyRuntimeRequestContract, normalizeProvider2, requireProviderEndpoint, SSE_DATA_FIELD_PREFIX2, estimateTokenCount, normalizeUsageCount, buildOpenAiUsagePayload, buildAnthropicUsagePayload, buildGoogleUsagePayload, normalizeProviderUsageMetrics,
|
|
124265
|
+
var mapOpenAiCompatibleNativeRequestPath, isRetryableProviderFailureForFallback, extractRuntimeProviderFailureStatusCode, isModelSpecificProviderFailure, emptyProviderContentError, isEmptyProviderContentFailure, emptyReplyForInternalAttempt, isEmptyProviderMessageFailure, isRetryableProviderAttemptFailure, providerRejectedRequestError, OPTIONAL_CONTRACT_PARAMETER_TOKENS, OPTIONAL_CONTRACT_REJECTION_TOKENS, OPTIONAL_CONTRACT_GRAMMAR_TOKENS, isOptionalContractParameterRejection, isTemperatureRefusal, PROVIDER_ROUTE_REFUSAL_PHRASE, isProviderRouteRefusal, OPTIONAL_CONTRACT_REQUEST_KEYS, OPTIONAL_CONTRACT_EXTRA_BODY_KEYS, resolveEmptyContentRetryPolicy, resolveStreamRetryPolicy, isKeySpecificOrTransientProviderFailure, providerDispatchClockMs, beginProviderDispatch, providerDispatchLatencyMs, attachProviderDispatchFailure, attachProviderFailureTrace, toRuntimeExecutionMode, buildNoneReasoningPayload, normalizeLevelValue, buildRuntimeReasoningPayload, resolveProviderReasoningParameters, requestedReasoningParameters, usesReasoningCompletionTokens, shouldRequestReasoningTrace, runtimeProviderForByokProvider, findByokProviderForRuntime, findModelOption, findNativeRequestParametersForModel, modelHasNativeRequestApiSurface, asRequestRecord, setDottedRequestValue, normalizeProviderMaxTokens, applyRuntimeRequestContract, normalizeProvider2, requireProviderEndpoint, SSE_DATA_FIELD_PREFIX2, estimateTokenCount, normalizeUsageCount, buildOpenAiUsagePayload, buildAnthropicUsagePayload, buildGoogleUsagePayload, normalizeProviderUsageMetrics, fetchProvider, emitRuntimeDelta, readProviderTextStream, readProviderJsonEventStream, providerStreamError, extractOpenAiCompatibleDeltaText, readOpenAiCompatibleTextStream, buildProviderFailureDiagnostic, buildCanonicalProviderFailureMessage, providerRefusal, toProviderNetworkDebugError, REASONING_ONLY_CONTENT_TYPES, extractOpenAiContentPartText, extractOpenAiReasoningPartText, extractOpenAiMessageContent, extractOpenAiMessageReasoningContent, extractOpenAiCompatibleText, normalizeRuntimeChatHistory, calculateProviderCost, resolveVeniceRequestContract, callOpenAiCompatible, extractOpenAiResponsesText, extractOpenAiResponsesReasoning, readOpenAiResponsesStream, internalDispatchAttempt, callOpenAiResponses, extractAnthropicMessageText, extractAnthropicReasoningContent, readAnthropicMessageStream, callAnthropic, isAqGoogleKey, googleKeySurfaceRef, resolveGoogleKeySurface, googlePublicModelIdRegexes, shouldUseGooglePublicEndpointForModel, normalizeGoogleModelId, shouldRetryGoogleVertexRequestPublicly, GOOGLE_VERTEX_PUBLIC_RETRY_NOTE, buildGoogleRequest, GOOGLE_JSON_MODE_REFUSAL_PHRASES, googleTradeResponseMimeType, providerRequestFailure, isGoogleJsonModeRefusal, isGoogleReasoningPart, extractGoogleMessageText, extractGoogleReasoningContent, extractGoogleSafetyMetadata, GOOGLE_BLOCKED_FINISH_REASONS, googleProviderBlockReason, readGoogleGenerateStream, callGoogle, resolveRuntimeProvider, defaultInvocationContext, defaultProviderTransport, invocationFailureCode, buildBrowserInvocation, resolveProviderSecretKey, resolveNativeProviderCredentialSlots, resolveProviderSecretKeySlots, requireOpenAiCompatibleRuntimeBaseUrl, runtimeSubscriptionPlan, runtimeKeySlotSupportsModel, invokeRuntimeProviderAttempt, invokeRuntimeProvider;
|
|
123686
124266
|
var init_provider_client = __esm({
|
|
123687
124267
|
"lib/runtime/provider-client.ts"() {
|
|
123688
124268
|
"use strict";
|
|
@@ -123693,6 +124273,7 @@ var init_provider_client = __esm({
|
|
|
123693
124273
|
init_google_egress();
|
|
123694
124274
|
init_native_provider_budget();
|
|
123695
124275
|
init_retired_model_source();
|
|
124276
|
+
init_provider_reply();
|
|
123696
124277
|
init_provider_observability();
|
|
123697
124278
|
init_api2();
|
|
123698
124279
|
init_network_debug();
|
|
@@ -123840,7 +124421,8 @@ var init_provider_client = __esm({
|
|
|
123840
124421
|
sanitizedError.runtimeProviderRequestId = providerRequestId(response);
|
|
123841
124422
|
sanitizedError.runtimeProviderDiagnostics = {
|
|
123842
124423
|
...marker2?.providerDiagnostics ?? {},
|
|
123843
|
-
...error48 instanceof NativeModelTimeoutError && error48.attemptCapExpired ? { timeout_bound: "attempt_cap" } : {}
|
|
124424
|
+
...error48 instanceof NativeModelTimeoutError && error48.attemptCapExpired ? { timeout_bound: "attempt_cap" } : {},
|
|
124425
|
+
...providerReplyDiagnostics(response, error48?.runtimeProviderReplyBody)
|
|
123844
124426
|
};
|
|
123845
124427
|
sanitizedError.runtimeRetryAfterSeconds = retryAfterDiagnostics(response).retry_after_seconds ?? null;
|
|
123846
124428
|
if (marker2?.googleQuotaFailure) sanitizedError.runtimeGoogleQuotaFailure = true;
|
|
@@ -124325,38 +124907,12 @@ var init_provider_client = __esm({
|
|
|
124325
124907
|
completionTokens: usage.completionTokens,
|
|
124326
124908
|
totalTokens: usage.totalTokens
|
|
124327
124909
|
});
|
|
124328
|
-
providerResponseSignals = /* @__PURE__ */ new WeakMap();
|
|
124329
124910
|
fetchProvider = async (url2, init2) => {
|
|
124330
124911
|
if (init2.signal?.aborted) throw init2.signal.reason ?? new DOMException("Cancelled", "AbortError");
|
|
124331
124912
|
const response = await awaitProviderOperation(startLongRequest(() => fetch(url2, init2)), init2.signal);
|
|
124332
124913
|
if (init2.signal) providerResponseSignals.set(response, init2.signal);
|
|
124333
124914
|
return response;
|
|
124334
124915
|
};
|
|
124335
|
-
readProviderPayload = async (response) => {
|
|
124336
|
-
if (typeof response?.text === "function") {
|
|
124337
|
-
const raw = await awaitProviderOperation(response.text(), providerResponseSignals.get(response));
|
|
124338
|
-
const normalizedRaw = typeof raw === "string" ? raw.trim() : "";
|
|
124339
|
-
if (!normalizedRaw) {
|
|
124340
|
-
return { payload: {}, rawText: "" };
|
|
124341
|
-
}
|
|
124342
|
-
try {
|
|
124343
|
-
return {
|
|
124344
|
-
payload: JSON.parse(normalizedRaw),
|
|
124345
|
-
rawText: normalizedRaw
|
|
124346
|
-
};
|
|
124347
|
-
} catch {
|
|
124348
|
-
return {
|
|
124349
|
-
payload: {},
|
|
124350
|
-
rawText: normalizedRaw
|
|
124351
|
-
};
|
|
124352
|
-
}
|
|
124353
|
-
}
|
|
124354
|
-
const payload = await awaitProviderOperation(response.json(), providerResponseSignals.get(response));
|
|
124355
|
-
return {
|
|
124356
|
-
payload,
|
|
124357
|
-
rawText: ""
|
|
124358
|
-
};
|
|
124359
|
-
};
|
|
124360
124916
|
emitRuntimeDelta = (onDelta, value) => {
|
|
124361
124917
|
if (typeof onDelta !== "function" || typeof value !== "string" || !value) {
|
|
124362
124918
|
return;
|
|
@@ -124410,10 +124966,10 @@ var init_provider_client = __esm({
|
|
|
124410
124966
|
}
|
|
124411
124967
|
onData(payload);
|
|
124412
124968
|
});
|
|
124413
|
-
providerStreamError = (payload, fallback) => {
|
|
124969
|
+
providerStreamError = (payload, fallback, event = payload) => {
|
|
124414
124970
|
const detail = extractProviderErrorDetail(payload, "") || fallback;
|
|
124415
124971
|
const diagnostic = sanitizeRuntimeDiagnosticValue(`Provider request failed: ${detail}`);
|
|
124416
|
-
return providerRejectedRequestError(diagnostic, detail, diagnostic);
|
|
124972
|
+
return Object.assign(providerRejectedRequestError(diagnostic, detail, diagnostic), { runtimeProviderReplyBody: JSON.stringify(event) });
|
|
124417
124973
|
};
|
|
124418
124974
|
extractOpenAiCompatibleDeltaText = (payload) => {
|
|
124419
124975
|
const choice = Array.isArray(payload?.choices) ? payload.choices[0] : null;
|
|
@@ -124462,6 +125018,7 @@ var init_provider_client = __esm({
|
|
|
124462
125018
|
} catch {
|
|
124463
125019
|
return;
|
|
124464
125020
|
}
|
|
125021
|
+
if (payload?.error) rememberProviderReplyBody(response, dataText);
|
|
124465
125022
|
onPayload?.(payload);
|
|
124466
125023
|
lastPayload = payload;
|
|
124467
125024
|
if (typeof payload?.model === "string") {
|
|
@@ -124515,42 +125072,6 @@ var init_provider_client = __esm({
|
|
|
124515
125072
|
}
|
|
124516
125073
|
};
|
|
124517
125074
|
};
|
|
124518
|
-
rawProviderTextForDebug = (payload, rawText) => {
|
|
124519
|
-
if (!rawText) {
|
|
124520
|
-
return null;
|
|
124521
|
-
}
|
|
124522
|
-
if (!payload || typeof payload === "object" && !Array.isArray(payload) && Object.keys(payload).length === 0) {
|
|
124523
|
-
return rawText;
|
|
124524
|
-
}
|
|
124525
|
-
return null;
|
|
124526
|
-
};
|
|
124527
|
-
extractProviderErrorDetail = (payload, rawText) => {
|
|
124528
|
-
const words7 = extractProviderErrorWords(payload, rawText);
|
|
124529
|
-
const outOfCreditCode = providerOutOfCreditErrorCode(payload);
|
|
124530
|
-
return outOfCreditCode && !words7.toLowerCase().includes(outOfCreditCode.toLowerCase()) ? `${words7}${words7 ? " " : ""}[${outOfCreditCode}]` : words7;
|
|
124531
|
-
};
|
|
124532
|
-
extractProviderErrorWords = (payload, rawText) => {
|
|
124533
|
-
const errorNode = payload?.error;
|
|
124534
|
-
if (typeof errorNode === "string" && errorNode.trim()) {
|
|
124535
|
-
return errorNode.trim();
|
|
124536
|
-
}
|
|
124537
|
-
if (typeof errorNode?.message === "string" && errorNode.message.trim()) {
|
|
124538
|
-
return errorNode.message.trim();
|
|
124539
|
-
}
|
|
124540
|
-
if (typeof errorNode?.detail === "string" && errorNode.detail.trim()) {
|
|
124541
|
-
return errorNode.detail.trim();
|
|
124542
|
-
}
|
|
124543
|
-
if (typeof payload?.detail === "string" && payload.detail.trim()) {
|
|
124544
|
-
return payload.detail.trim();
|
|
124545
|
-
}
|
|
124546
|
-
if (typeof payload?.message === "string" && payload.message.trim()) {
|
|
124547
|
-
return payload.message.trim();
|
|
124548
|
-
}
|
|
124549
|
-
if (rawText) {
|
|
124550
|
-
return sanitizeRuntimeDiagnosticValue(rawText).replace(/\s+/g, " ").slice(0, PROVIDER_ERROR_RAW_TEXT_MAX_CHARS);
|
|
124551
|
-
}
|
|
124552
|
-
return "";
|
|
124553
|
-
};
|
|
124554
125075
|
buildProviderFailureDiagnostic = ({ response, detail }) => {
|
|
124555
125076
|
const statusLabel = response.status ? ` (HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""})` : "";
|
|
124556
125077
|
return sanitizeRuntimeDiagnosticValue(
|
|
@@ -125137,9 +125658,9 @@ var init_provider_client = __esm({
|
|
|
125137
125658
|
} else if (type === "response.completed" || type === "response.incomplete") {
|
|
125138
125659
|
completed = event.response ?? null;
|
|
125139
125660
|
} else if (type === "response.failed") {
|
|
125140
|
-
failure2 ??= providerStreamError(event.response, "OpenAI Responses stream failed");
|
|
125661
|
+
failure2 ??= providerStreamError(event.response, "OpenAI Responses stream failed", event);
|
|
125141
125662
|
} else if (type === "error") {
|
|
125142
|
-
failure2 ??= providerStreamError({ error: event }, "OpenAI Responses stream failed");
|
|
125663
|
+
failure2 ??= providerStreamError({ error: event }, "OpenAI Responses stream failed", event);
|
|
125143
125664
|
}
|
|
125144
125665
|
});
|
|
125145
125666
|
if (failure2) throw failure2;
|
|
@@ -125152,7 +125673,7 @@ var init_provider_client = __esm({
|
|
|
125152
125673
|
latencyMs: providerDispatchLatencyMs(marker2),
|
|
125153
125674
|
transport,
|
|
125154
125675
|
requestInputTokens: marker2.requestInputTokens,
|
|
125155
|
-
providerDiagnostics: marker2.providerDiagnostics,
|
|
125676
|
+
providerDiagnostics: { ...marker2.providerDiagnostics, ...providerReplyDiagnostics(response) },
|
|
125156
125677
|
providerRequestId: providerRequestId(response),
|
|
125157
125678
|
errorDetail: getSanitizedRuntimeErrorMessage(error48) || "Provider compatibility dispatch failed.",
|
|
125158
125679
|
// An empty reply is an unknown outcome with no status.
|
|
@@ -125787,7 +126308,7 @@ var init_provider_client = __esm({
|
|
|
125787
126308
|
latencyMs: providerDispatchLatencyMs(marker2),
|
|
125788
126309
|
transport: "google_generate_content_rest",
|
|
125789
126310
|
requestInputTokens: marker2.requestInputTokens,
|
|
125790
|
-
providerDiagnostics: { ...credentialDiagnostics, ...await extractProviderDiagnostics(payloadJson, answered) },
|
|
126311
|
+
providerDiagnostics: { ...credentialDiagnostics, ...await extractProviderDiagnostics(payloadJson, answered), ...providerReplyDiagnostics(answered) },
|
|
125791
126312
|
providerRequestId: providerRequestId(answered),
|
|
125792
126313
|
errorDetail,
|
|
125793
126314
|
statusCode: answered.status,
|
|
@@ -129232,9 +129753,9 @@ var init_local_analysis = __esm({
|
|
|
129232
129753
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
129233
129754
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
129234
129755
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
129235
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
129236
|
-
"
|
|
129237
|
-
) ? "
|
|
129756
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim() && !["unknown", "unstamped", "development"].includes(
|
|
129757
|
+
"1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim().toLowerCase()
|
|
129758
|
+
) ? "1fbd5d0b063d9c340fde67bbac63073001dc6b56".trim() : null;
|
|
129238
129759
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
129239
129760
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
129240
129761
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|
|
@@ -131582,10 +132103,10 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
131582
132103
|
if (!Number.isFinite(ms) || ms <= 0) {
|
|
131583
132104
|
return;
|
|
131584
132105
|
}
|
|
131585
|
-
await new Promise((
|
|
132106
|
+
await new Promise((resolve17, reject) => {
|
|
131586
132107
|
const timeout = setTimeout(() => {
|
|
131587
132108
|
cleanup();
|
|
131588
|
-
|
|
132109
|
+
resolve17();
|
|
131589
132110
|
}, ms);
|
|
131590
132111
|
const cleanup = () => {
|
|
131591
132112
|
clearTimeout(timeout);
|
|
@@ -135670,7 +136191,7 @@ var init_engine = __esm({
|
|
|
135670
136191
|
}
|
|
135671
136192
|
async _awaitStartStage(operation, controller, stage) {
|
|
135672
136193
|
this._assertStartAttemptActive(controller, stage);
|
|
135673
|
-
return new Promise((
|
|
136194
|
+
return new Promise((resolve17, reject) => {
|
|
135674
136195
|
const rejectCancelled = () => {
|
|
135675
136196
|
reject(createRuntimeStartCancelledError("lifecycle_stop_requested", {
|
|
135676
136197
|
stage
|
|
@@ -135684,7 +136205,7 @@ var init_engine = __esm({
|
|
|
135684
136205
|
rejectCancelled();
|
|
135685
136206
|
return;
|
|
135686
136207
|
}
|
|
135687
|
-
|
|
136208
|
+
resolve17(value);
|
|
135688
136209
|
},
|
|
135689
136210
|
(error48) => {
|
|
135690
136211
|
controller.signal.removeEventListener("abort", rejectCancelled);
|
|
@@ -135779,14 +136300,14 @@ var init_engine = __esm({
|
|
|
135779
136300
|
note: `profile=${this._profileId || "none"} pending=${pending3.length}`,
|
|
135780
136301
|
outcome: "error"
|
|
135781
136302
|
});
|
|
135782
|
-
await new Promise((
|
|
136303
|
+
await new Promise((resolve17) => {
|
|
135783
136304
|
let settled2 = false;
|
|
135784
136305
|
const finish = () => {
|
|
135785
136306
|
if (settled2) return;
|
|
135786
136307
|
settled2 = true;
|
|
135787
136308
|
globalThis.clearTimeout(timeoutId);
|
|
135788
136309
|
signal.removeEventListener("abort", finish);
|
|
135789
|
-
|
|
136310
|
+
resolve17();
|
|
135790
136311
|
};
|
|
135791
136312
|
const timeoutId = globalThis.setTimeout(finish, CLIENT_RUNTIME_POLICY.window_handoff_cleanup_retry_milliseconds);
|
|
135792
136313
|
signal.addEventListener("abort", finish, { once: true });
|
|
@@ -136804,8 +137325,8 @@ var init_engine = __esm({
|
|
|
136804
137325
|
let timer;
|
|
136805
137326
|
const settled2 = await Promise.race([
|
|
136806
137327
|
loop.then(() => true, () => true),
|
|
136807
|
-
new Promise((
|
|
136808
|
-
timer = setTimeout(() =>
|
|
137328
|
+
new Promise((resolve17) => {
|
|
137329
|
+
timer = setTimeout(() => resolve17(false), timeoutMs);
|
|
136809
137330
|
})
|
|
136810
137331
|
]);
|
|
136811
137332
|
clearTimeout(timer);
|
|
@@ -137932,14 +138453,14 @@ var init_engine = __esm({
|
|
|
137932
138453
|
if (signal?.aborted) {
|
|
137933
138454
|
throw signal.reason ?? createStopAbortError("trade_sync_settlement_cancelled");
|
|
137934
138455
|
}
|
|
137935
|
-
await new Promise((
|
|
138456
|
+
await new Promise((resolve17) => {
|
|
137936
138457
|
let settled2 = false;
|
|
137937
138458
|
const finish = () => {
|
|
137938
138459
|
if (settled2) return;
|
|
137939
138460
|
settled2 = true;
|
|
137940
138461
|
globalThis.clearTimeout(timeoutId);
|
|
137941
138462
|
signal?.removeEventListener("abort", finish);
|
|
137942
|
-
|
|
138463
|
+
resolve17();
|
|
137943
138464
|
};
|
|
137944
138465
|
const timeoutId = globalThis.setTimeout(finish, this._loopEarlyReturnRetryDelayMs);
|
|
137945
138466
|
signal?.addEventListener("abort", finish, { once: true });
|
|
@@ -140356,8 +140877,8 @@ var init_engine = __esm({
|
|
|
140356
140877
|
try {
|
|
140357
140878
|
await Promise.race([
|
|
140358
140879
|
activeExecutionLoop,
|
|
140359
|
-
new Promise((
|
|
140360
|
-
executionFenceTimeoutId = setTimeout(
|
|
140880
|
+
new Promise((resolve17) => {
|
|
140881
|
+
executionFenceTimeoutId = setTimeout(resolve17, executionFenceTimeoutMs);
|
|
140361
140882
|
})
|
|
140362
140883
|
]);
|
|
140363
140884
|
} catch {
|
|
@@ -141542,8 +142063,8 @@ async function runHeadlessRuntime(options) {
|
|
|
141542
142063
|
};
|
|
141543
142064
|
const nextEvent = async () => {
|
|
141544
142065
|
while (pending3.length === 0) {
|
|
141545
|
-
await new Promise((
|
|
141546
|
-
wake =
|
|
142066
|
+
await new Promise((resolve17) => {
|
|
142067
|
+
wake = resolve17;
|
|
141547
142068
|
});
|
|
141548
142069
|
wake = null;
|
|
141549
142070
|
}
|
|
@@ -141673,9 +142194,9 @@ async function runHeadlessRuntime(options) {
|
|
|
141673
142194
|
const stored = await readRuntimeState(options.statePath).catch(() => null);
|
|
141674
142195
|
const ownDevices = new Set([identity3.deviceId, stored?.deviceId].filter(Boolean).map(String));
|
|
141675
142196
|
let offered = false;
|
|
141676
|
-
const stopped = new Promise((
|
|
141677
|
-
if (stopController.signal.aborted)
|
|
141678
|
-
else stopController.signal.addEventListener("abort", () =>
|
|
142197
|
+
const stopped = new Promise((resolve17) => {
|
|
142198
|
+
if (stopController.signal.aborted) resolve17(false);
|
|
142199
|
+
else stopController.signal.addEventListener("abort", () => resolve17(false), { once: true });
|
|
141679
142200
|
});
|
|
141680
142201
|
const withdraw = async () => {
|
|
141681
142202
|
if (!offered) return;
|
|
@@ -142630,7 +143151,7 @@ The CLI updates itself at start; set VTX_CLI_AUTO_UPDATE=0 to turn that off.
|
|
|
142630
143151
|
// Every BYOK provider's key field, from the one provider registry.
|
|
142631
143152
|
...BYOK_PROVIDERS.map((provider) => provider.apiKeyField)
|
|
142632
143153
|
]);
|
|
142633
|
-
delay2 = (ms) => new Promise((
|
|
143154
|
+
delay2 = (ms) => new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
142634
143155
|
}
|
|
142635
143156
|
});
|
|
142636
143157
|
|