@vtxmacro/cli 2026.10.69 → 2026.10.70
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 +2 -1
- package/bin/vtx-mcp.js +3 -2
- package/bin/vtx-service-bootstrap.js +3 -2
- package/bin/vtx-service-launcher.js +2 -1
- package/bin/vtx.js +495 -336
- 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.70", 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
|
|
|
@@ -999,7 +999,8 @@ var init_runtime_policy_generated = __esm({
|
|
|
999
999
|
base_delay_milliseconds: 300,
|
|
1000
1000
|
max_delay_milliseconds: 8e3,
|
|
1001
1001
|
min_retry_after_milliseconds: 250,
|
|
1002
|
-
deadline_attempt_spacing_milliseconds: 250
|
|
1002
|
+
deadline_attempt_spacing_milliseconds: 250,
|
|
1003
|
+
market_data_max_attempts: 2
|
|
1003
1004
|
}
|
|
1004
1005
|
},
|
|
1005
1006
|
server_runtime: {
|
|
@@ -3233,7 +3234,7 @@ var init_shared_contracts_generated = __esm({
|
|
|
3233
3234
|
});
|
|
3234
3235
|
|
|
3235
3236
|
// lib/constants.ts
|
|
3236
|
-
var MS_PER_SECOND, MICROSECONDS_PER_MS, MICROSECONDS_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,
|
|
3237
|
+
var MS_PER_SECOND, MICROSECONDS_PER_MS, MICROSECONDS_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, POSITION_SIZE_EPSILON, HYPERLIQUID_WEBSOCKET_MAX_USERS_PER_IP, 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_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, AI_SNAPSHOT_PACKED_FIELDS, AI_SNAPSHOT_PACKED_ENTRY_FIELDS, TOKENS_PER_MILLION, RENDER_DEBUG_ID_RANDOM_CHARS, BASE32_BITS_PER_CHARACTER, MT5_CLIENT_ID_MAX_LENGTH, MT5_SYNTHETIC_LEG_ID_BASE, MT5_SYNTHETIC_LEG_KINDS, MT5_SYNTHETIC_LEG_KEY_BITS, FNV1A_64_BITS, FNV1A_64_OFFSET_BASIS, FNV1A_64_PRIME, MT5_GRID_TOLERANCE;
|
|
3237
3238
|
var init_constants = __esm({
|
|
3238
3239
|
"lib/constants.ts"() {
|
|
3239
3240
|
"use strict";
|
|
@@ -3282,7 +3283,6 @@ var init_constants = __esm({
|
|
|
3282
3283
|
INT32_MIN = -(2 ** 31);
|
|
3283
3284
|
INT32_MAX = 2 ** 31 - 1;
|
|
3284
3285
|
SET_TIMEOUT_MAX_DELAY_MS = INT32_MAX;
|
|
3285
|
-
FLOAT_EQUALITY_EPSILON = 1e-12;
|
|
3286
3286
|
POSITION_SIZE_EPSILON = 1e-5;
|
|
3287
3287
|
HYPERLIQUID_WEBSOCKET_MAX_USERS_PER_IP = 10;
|
|
3288
3288
|
HTTP_STATUS = {
|
|
@@ -22839,7 +22839,8 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22839
22839
|
base_delay_milliseconds: 300,
|
|
22840
22840
|
max_delay_milliseconds: 8e3,
|
|
22841
22841
|
min_retry_after_milliseconds: 250,
|
|
22842
|
-
deadline_attempt_spacing_milliseconds: 250
|
|
22842
|
+
deadline_attempt_spacing_milliseconds: 250,
|
|
22843
|
+
market_data_max_attempts: 2
|
|
22843
22844
|
}
|
|
22844
22845
|
},
|
|
22845
22846
|
server_runtime: {
|
|
@@ -60005,6 +60006,28 @@ var init_runtime_error_wording = __esm({
|
|
|
60005
60006
|
}
|
|
60006
60007
|
});
|
|
60007
60008
|
|
|
60009
|
+
// lib/rate-limit-text.ts
|
|
60010
|
+
var RATE_LIMIT_TEXT, COOLDOWN_SECONDS, RETRY_IN_SECONDS, APP_RATE_LIMIT_WORDING, isRateLimitErrorText, rateLimitMessage;
|
|
60011
|
+
var init_rate_limit_text = __esm({
|
|
60012
|
+
"lib/rate-limit-text.ts"() {
|
|
60013
|
+
"use strict";
|
|
60014
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
60015
|
+
init_define_VTX_EXO_POLICY();
|
|
60016
|
+
init_define_VTX_GROK_POLICY();
|
|
60017
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
60018
|
+
RATE_LIMIT_TEXT = /rate\s*limit|(?:^|[^\w.]|[^\d.]\.)429(?![\w]|\.\d)|cooling\s*down/i;
|
|
60019
|
+
COOLDOWN_SECONDS = /cooling\s*down\s*for\s*([0-9]+(?:\.[0-9]+)?)s/i;
|
|
60020
|
+
RETRY_IN_SECONDS = /retry\s*in\s*~?\s*([0-9]+(?:\.[0-9]+)?)s/i;
|
|
60021
|
+
APP_RATE_LIMIT_WORDING = "Hyperliquid is rate-limited.";
|
|
60022
|
+
isRateLimitErrorText = (text2) => RATE_LIMIT_TEXT.test(String(text2 || ""));
|
|
60023
|
+
rateLimitMessage = (raw) => {
|
|
60024
|
+
const text2 = String(raw || "");
|
|
60025
|
+
const match = text2.match(COOLDOWN_SECONDS) ?? text2.match(RETRY_IN_SECONDS);
|
|
60026
|
+
return match ? `${APP_RATE_LIMIT_WORDING} Please retry in ~${match[1]}s.` : `${APP_RATE_LIMIT_WORDING} Please wait a moment and retry.`;
|
|
60027
|
+
};
|
|
60028
|
+
}
|
|
60029
|
+
});
|
|
60030
|
+
|
|
60008
60031
|
// lib/api/shared.ts
|
|
60009
60032
|
function configureApiTransport(transport) {
|
|
60010
60033
|
if (transport === null) {
|
|
@@ -60032,7 +60055,7 @@ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
|
60032
60055
|
if (profileId) headers["x-profile-id"] = profileId.toString();
|
|
60033
60056
|
return headers;
|
|
60034
60057
|
}
|
|
60035
|
-
var configuredApiTransport, getApiUrl, withoutContentType, browserRequestInit, sendApiRequest, apiFetch, sleep, DEVICE_CLOCK_HEADER, deviceClockHeader, API_NO_ROUTE_DETAIL, isMissingApiRoute, sendExchangeMutationReport, inFlightClientGetRequests, recentClientGetResponses, clientGetRequestGenerations, initializedClientGetRequestKeys, CLIENT_GET_DEDUPE_TTL_MS, CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS, CLIENT_LLM_CONFIG_PRIME_TTL_MS, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, singleUserHostCache, canUseClientGetRequestCache, clientGetRequestCacheActive, invalidateClientGetRequestCache, raceWithAbortSignal, shareClientGetRequest, clientGetRequestKey, clientPreferencesRequestKey, invalidateClientPreferencesCache, parseRetryAfterMs2, resolveAuthBootstrapRetryDelayMs, fetchAuthBootstrapGetWithRetry, annotateMarketDataRequestError, buildMarketDataFetchError, buildMarketDataNetworkError, buildMarketDataResponseBodyError, NODE_FETCH_NETWORK_CAUSE_CODES, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, throwUnauthorizedIfNeeded, activeProfileId, PROFILE_STORAGE_KEY;
|
|
60058
|
+
var configuredApiTransport, getApiUrl, withoutContentType, browserRequestInit, sendApiRequest, apiFetch, sleep, DEVICE_CLOCK_HEADER, deviceClockHeader, API_NO_ROUTE_DETAIL, isMissingApiRoute, sendExchangeMutationReport, inFlightClientGetRequests, recentClientGetResponses, clientGetRequestGenerations, initializedClientGetRequestKeys, CLIENT_GET_DEDUPE_TTL_MS, CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS, CLIENT_LLM_CONFIG_PRIME_TTL_MS, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, singleUserHostCache, canUseClientGetRequestCache, clientGetRequestCacheActive, invalidateClientGetRequestCache, raceWithAbortSignal, shareClientGetRequest, clientGetRequestKey, clientPreferencesRequestKey, invalidateClientPreferencesCache, parseRetryAfterMs2, resolveClientRuntimeRetryDelayMs, resolveAuthBootstrapRetryDelayMs, fetchAuthBootstrapGetWithRetry, annotateMarketDataRequestError, readMarketDataWithRetry, buildMarketDataFetchError, buildMarketDataNetworkError, buildMarketDataResponseBodyError, NODE_FETCH_NETWORK_CAUSE_CODES, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, throwUnauthorizedIfNeeded, activeProfileId, PROFILE_STORAGE_KEY;
|
|
60036
60059
|
var init_shared = __esm({
|
|
60037
60060
|
"lib/api/shared.ts"() {
|
|
60038
60061
|
"use strict";
|
|
@@ -60048,6 +60071,7 @@ var init_shared = __esm({
|
|
|
60048
60071
|
init_abort();
|
|
60049
60072
|
init_runtime_redaction();
|
|
60050
60073
|
init_runtime_error_wording();
|
|
60074
|
+
init_rate_limit_text();
|
|
60051
60075
|
configuredApiTransport = null;
|
|
60052
60076
|
getApiUrl = () => {
|
|
60053
60077
|
if (configuredApiTransport) return configuredApiTransport.baseUrl;
|
|
@@ -60201,6 +60225,14 @@ var init_shared = __esm({
|
|
|
60201
60225
|
if (Number.isFinite(retryAtMs)) return Math.max(0, retryAtMs - Date.now());
|
|
60202
60226
|
return null;
|
|
60203
60227
|
};
|
|
60228
|
+
resolveClientRuntimeRetryDelayMs = (attempt2, retryAfterHeader) => {
|
|
60229
|
+
const policy3 = runtime_policy_generated_default2.trading.engine.client_runtime.request_retry;
|
|
60230
|
+
const retryAfterMs = parseRetryAfterMs2(retryAfterHeader);
|
|
60231
|
+
if (retryAfterMs != null) {
|
|
60232
|
+
return Math.min(policy3.max_delay_milliseconds, Math.max(policy3.min_retry_after_milliseconds, retryAfterMs));
|
|
60233
|
+
}
|
|
60234
|
+
return Math.min(policy3.max_delay_milliseconds, policy3.base_delay_milliseconds * BACKOFF_GROWTH_FACTOR ** (attempt2 - 1));
|
|
60235
|
+
};
|
|
60204
60236
|
resolveAuthBootstrapRetryDelayMs = (response, attempt2) => {
|
|
60205
60237
|
const retryAfterMs = parseRetryAfterMs2(response.headers.get("Retry-After"));
|
|
60206
60238
|
const baseDelayMs = retryAfterMs ?? runtime_policy_generated_default2.ui.auth_bootstrap_retry.base_delay_milliseconds * BACKOFF_GROWTH_FACTOR ** (attempt2 - 1);
|
|
@@ -60224,8 +60256,26 @@ var init_shared = __esm({
|
|
|
60224
60256
|
runtimeRequestMaxAttempts: 1,
|
|
60225
60257
|
runtimeRequestStatus: status,
|
|
60226
60258
|
runtimeRequestErrorKind: kind,
|
|
60227
|
-
runtimeRequestTransientNetwork: kind === "network" && isTransientNetworkFetchError(error48)
|
|
60259
|
+
runtimeRequestTransientNetwork: kind === "network" && isTransientNetworkFetchError(error48) || kind === "response_body" && isTransientNetworkFetchError(error48.cause)
|
|
60228
60260
|
});
|
|
60261
|
+
readMarketDataWithRetry = async (signal, read) => {
|
|
60262
|
+
const maxAttempts = runtime_policy_generated_default2.trading.engine.client_runtime.request_retry.market_data_max_attempts;
|
|
60263
|
+
for (let attempt2 = 1; ; attempt2 += 1) {
|
|
60264
|
+
try {
|
|
60265
|
+
return await read();
|
|
60266
|
+
} catch (error48) {
|
|
60267
|
+
const transient = error48?.runtimeRequestTransientNetwork === true;
|
|
60268
|
+
if (transient && attempt2 < maxAttempts) {
|
|
60269
|
+
await abortableSleep(resolveClientRuntimeRetryDelayMs(attempt2, null), signal);
|
|
60270
|
+
continue;
|
|
60271
|
+
}
|
|
60272
|
+
if (error48 instanceof Error && "runtimeRequestPath" in error48) {
|
|
60273
|
+
Object.assign(error48, { runtimeRequestAttempt: attempt2, runtimeRequestMaxAttempts: maxAttempts });
|
|
60274
|
+
}
|
|
60275
|
+
throw error48;
|
|
60276
|
+
}
|
|
60277
|
+
}
|
|
60278
|
+
};
|
|
60229
60279
|
buildMarketDataFetchError = async (response, label2, path) => {
|
|
60230
60280
|
let responseText = "";
|
|
60231
60281
|
try {
|
|
@@ -60280,11 +60330,7 @@ var init_shared = __esm({
|
|
|
60280
60330
|
};
|
|
60281
60331
|
getErrorMessage = (error48, defaultMessage) => {
|
|
60282
60332
|
if (typeof error48?.detail_in_android_app === "string" && isAndroidAppPage()) return error48.detail_in_android_app;
|
|
60283
|
-
const extractRateLimitMessage = (raw) =>
|
|
60284
|
-
if (!/rate\s*limit|429|cooling\s*down/i.test(raw)) return null;
|
|
60285
|
-
const match = raw.match(/cooling\s*down\s*for\s*([0-9]+(?:\.[0-9]+)?)s/i);
|
|
60286
|
-
return match ? `Hyperliquid is rate-limited. Please retry in ~${match[1]}s.` : "Hyperliquid is rate-limited. Please wait a moment and retry.";
|
|
60287
|
-
};
|
|
60333
|
+
const extractRateLimitMessage = (raw) => isRateLimitErrorText(raw) ? rateLimitMessage(raw) : null;
|
|
60288
60334
|
if (isTransientNetworkFetchError(error48 instanceof Error ? error48 : error48?.message)) {
|
|
60289
60335
|
return "Network error. Please check your connection.";
|
|
60290
60336
|
}
|
|
@@ -61879,7 +61925,7 @@ async function getRecentCandlesForProfile(profileId, limit, exchange, symbol2, t
|
|
|
61879
61925
|
}
|
|
61880
61926
|
async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal) {
|
|
61881
61927
|
const requestKey = `live-ticker:${symbol2}:${exchange}`;
|
|
61882
|
-
return shareClientGetRequest(requestKey, async (
|
|
61928
|
+
return shareClientGetRequest(requestKey, (requestSignal) => readMarketDataWithRetry(requestSignal, async () => {
|
|
61883
61929
|
const requestUrl2 = `${getApiUrl()}/ticker/live?symbol=${encodeURIComponent(symbol2)}&exchange=${encodeURIComponent(exchange)}`;
|
|
61884
61930
|
const trace = startRuntimeNetworkDebugTrace({
|
|
61885
61931
|
kind: "runtime",
|
|
@@ -61912,7 +61958,7 @@ async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal)
|
|
|
61912
61958
|
if (isAbortLikeError(error48)) throw error48;
|
|
61913
61959
|
throw buildMarketDataNetworkError(error48, "live ticker", "/ticker/live");
|
|
61914
61960
|
}
|
|
61915
|
-
}, { signal });
|
|
61961
|
+
}), { signal });
|
|
61916
61962
|
}
|
|
61917
61963
|
async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
61918
61964
|
const params = new URLSearchParams();
|
|
@@ -61971,7 +62017,7 @@ var init_market_data = __esm({
|
|
|
61971
62017
|
const params = new URLSearchParams({ limit: limit.toString(), exchange, symbol: symbol2, timeframe });
|
|
61972
62018
|
const requestUrl2 = `${getApiUrl()}/candles/recent?${params.toString()}`;
|
|
61973
62019
|
const forProfile = profileId === null ? {} : { credentials: "include", headers: getProfileHeaders(persistedRuntimeLeaseHeaders(profileId), profileId) };
|
|
61974
|
-
return shareClientGetRequest(`recent-candles:${profileId ?? "none"}:${params.toString()}`, async (
|
|
62020
|
+
return shareClientGetRequest(`recent-candles:${profileId ?? "none"}:${params.toString()}`, (requestSignal) => readMarketDataWithRetry(requestSignal, async () => {
|
|
61975
62021
|
const trace = startRuntimeNetworkDebugTrace({
|
|
61976
62022
|
kind: "runtime",
|
|
61977
62023
|
label: "market_data_api:candles_recent",
|
|
@@ -62013,7 +62059,7 @@ var init_market_data = __esm({
|
|
|
62013
62059
|
if (isAbortLikeError(error48)) throw error48;
|
|
62014
62060
|
throw buildMarketDataNetworkError(error48, "recent candles", "/candles/recent");
|
|
62015
62061
|
}
|
|
62016
|
-
}, { signal, shareAbortScoped: true });
|
|
62062
|
+
}), { signal, shareAbortScoped: true });
|
|
62017
62063
|
};
|
|
62018
62064
|
ExecutionAssetMetadataRequestError = class extends Error {
|
|
62019
62065
|
constructor(message, status, retryAfterMs, code = null) {
|
|
@@ -64126,6 +64172,11 @@ var init_hyperliquid_public_read = __esm({
|
|
|
64126
64172
|
checkAbort(signal);
|
|
64127
64173
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
64128
64174
|
hostTransport?.onPublicInfoSent?.(body);
|
|
64175
|
+
} else {
|
|
64176
|
+
try {
|
|
64177
|
+
hostTransport?.onPrivateInfoSent?.(body);
|
|
64178
|
+
} catch {
|
|
64179
|
+
}
|
|
64129
64180
|
}
|
|
64130
64181
|
outcome = "failure";
|
|
64131
64182
|
let transportAborted;
|
|
@@ -100051,7 +100102,8 @@ async function fetchClientRuntimePromptMetadata(profileId, payload, options) {
|
|
|
100051
100102
|
return postClientRuntime(
|
|
100052
100103
|
"/runtime/prompt-contract/metadata",
|
|
100053
100104
|
profileId,
|
|
100054
|
-
buildClientRuntimeBody(payload),
|
|
100105
|
+
buildClientRuntimeBody(payload, { renders_prompt_field_legends: true }),
|
|
100106
|
+
// builds each {<block>_legend} line
|
|
100055
100107
|
options
|
|
100056
100108
|
);
|
|
100057
100109
|
}
|
|
@@ -100059,8 +100111,8 @@ async function fetchClientRuntimePromptDerivedContext(profileId, payload, option
|
|
|
100059
100111
|
return postClientRuntime(
|
|
100060
100112
|
"/runtime/prompt-contract/derived-context",
|
|
100061
100113
|
profileId,
|
|
100062
|
-
|
|
100063
|
-
|
|
100114
|
+
// The engine renders the blocks (prompt_inputs) and builds each {<block>_legend} line.
|
|
100115
|
+
buildClientRuntimeBody(payload, { renders_derived_prompts: true, renders_prompt_field_legends: true }),
|
|
100064
100116
|
options
|
|
100065
100117
|
);
|
|
100066
100118
|
}
|
|
@@ -100268,7 +100320,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
|
|
|
100268
100320
|
ttlMs: viewer.requestKey ? 0 : CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS
|
|
100269
100321
|
});
|
|
100270
100322
|
}
|
|
100271
|
-
var clientRuntimeSecretHeaders, preferencesWriteQueue, getCopyTradingRuntimeLeaseToken, getCopyTradingSchedulerInstanceId, AI_TRADE_HISTORY_BY_ORDER_IDS_MAX_BATCH, AI_TRADE_HISTORY_BY_ORDER_IDS_MAX_CONCURRENCY, resolveClientRuntimeStatusViewerHeaders, CLIENT_SUPPORTED_PROMPT_CONTRACT_VERSION, completedDeferredClientRuntimeStops, rememberCompletedDeferredClientRuntimeStop, consumeCompletedDeferredClientRuntimeStop, toNumericProfileId, buildClientRuntimeBody, shouldAttachRuntimeIdempotencyKey, attachRuntimeLeaseHeader, attachRuntimeSchedulerInstanceHeader, resolveRuntimeLeaseToken, resolveSchedulerBoundRuntimeLeaseToken, persistRuntimeLeaseFromPayload, persistRuntimeLeaseStatusMetadata, shouldClearPersistedRuntimeLeaseOnError, readRetryableRuntimeRefusalDelayMs, createRuntimeRequestError, parseClientRuntimeRequestContext, recordRuntimeAuthFailureBreadcrumb, classifyRuntimeRequestError, annotateRuntimeRequestError, CLIENT_RUNTIME_RETRYABLE_STATUSES, isRetryableClientRuntimeStatus, shouldRetryClientRuntimeHttpStatus, isRuntimeIdempotencyInProgressError, isRetryableRuntimeConflictError,
|
|
100323
|
+
var clientRuntimeSecretHeaders, preferencesWriteQueue, getCopyTradingRuntimeLeaseToken, getCopyTradingSchedulerInstanceId, AI_TRADE_HISTORY_BY_ORDER_IDS_MAX_BATCH, AI_TRADE_HISTORY_BY_ORDER_IDS_MAX_CONCURRENCY, resolveClientRuntimeStatusViewerHeaders, CLIENT_SUPPORTED_PROMPT_CONTRACT_VERSION, completedDeferredClientRuntimeStops, rememberCompletedDeferredClientRuntimeStop, consumeCompletedDeferredClientRuntimeStop, toNumericProfileId, buildClientRuntimeBody, shouldAttachRuntimeIdempotencyKey, attachRuntimeLeaseHeader, attachRuntimeSchedulerInstanceHeader, resolveRuntimeLeaseToken, resolveSchedulerBoundRuntimeLeaseToken, persistRuntimeLeaseFromPayload, persistRuntimeLeaseStatusMetadata, shouldClearPersistedRuntimeLeaseOnError, readRetryableRuntimeRefusalDelayMs, createRuntimeRequestError, parseClientRuntimeRequestContext, recordRuntimeAuthFailureBreadcrumb, classifyRuntimeRequestError, annotateRuntimeRequestError, CLIENT_RUNTIME_RETRYABLE_STATUSES, isRetryableClientRuntimeStatus, shouldRetryClientRuntimeHttpStatus, isRuntimeIdempotencyInProgressError, isRetryableRuntimeConflictError, reconcilePendingClientExchangeMutation, CLIENT_RUNTIME_CLAIM_EXCHANGE_MUTATION_WAIT_CODES, resolveClientExchangeMutationAuthority, pinClientExchangeMutationAuthority, CLIENT_EXCHANGE_MUTATION_AUTHORITY_MISMATCH, isClientExchangeMutationAuthorityConflict, handOffClientExchangeMutationToReconciliation, clientExchangeMutationAuthorityBody, isPendingClientExchangeMutationError, isMissingActiveClientExchangeMutationError, clientExchangeMutationReconciliationTimers, ClientExchangeMutationRebuildRequiredError, isTerminalClientExchangeMutation, clientExchangeMutationReconciliationKey, clearScheduledClientExchangeMutationReconciliation, snapshotClientExchangeMutationReconciliationAuthority, completeClientExchangeMutationReconciliation, postClientExchangeMutationReconciliation, scheduleClientExchangeMutationReconciliation, postClientDeviceReport, reportClientTradeMarketRead;
|
|
100272
100324
|
var init_api2 = __esm({
|
|
100273
100325
|
"lib/api.ts"() {
|
|
100274
100326
|
"use strict";
|
|
@@ -100670,14 +100722,6 @@ var init_api2 = __esm({
|
|
|
100670
100722
|
};
|
|
100671
100723
|
isRuntimeIdempotencyInProgressError = (status, message) => status === HTTP_STATUS.CONFLICT && (message.toLowerCase().includes("duplicate request already in progress") || message.toLowerCase().includes("duplicate request in-flight"));
|
|
100672
100724
|
isRetryableRuntimeConflictError = (status, error48) => status === HTTP_STATUS.CONFLICT && error48.retryable === true && (error48.code === "profile_runtime_contract_busy" || error48.code === "runtime_decision_finalizing" || error48.code === "runtime_trade_sync_finalizing" || error48.code === "runtime_decision_unconfirmed");
|
|
100673
|
-
resolveClientRuntimeRetryDelayMs = (attempt2, retryAfterHeader) => {
|
|
100674
|
-
const policy3 = runtime_policy_generated_default2.trading.engine.client_runtime.request_retry;
|
|
100675
|
-
const retryAfterMs = parseRetryAfterMs2(retryAfterHeader);
|
|
100676
|
-
if (retryAfterMs != null) {
|
|
100677
|
-
return Math.min(policy3.max_delay_milliseconds, Math.max(policy3.min_retry_after_milliseconds, retryAfterMs));
|
|
100678
|
-
}
|
|
100679
|
-
return Math.min(policy3.max_delay_milliseconds, policy3.base_delay_milliseconds * BACKOFF_GROWTH_FACTOR ** (attempt2 - 1));
|
|
100680
|
-
};
|
|
100681
100725
|
reconcilePendingClientExchangeMutation = async (profileId, requestOptions) => {
|
|
100682
100726
|
let reconciliation;
|
|
100683
100727
|
try {
|
|
@@ -104523,6 +104567,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
104523
104567
|
init_hyperliquid_perp_dex_config();
|
|
104524
104568
|
init_device_account_state_store();
|
|
104525
104569
|
init_runtime_policy_generated2();
|
|
104570
|
+
init_rate_limit_text();
|
|
104526
104571
|
init_constants();
|
|
104527
104572
|
init_hyperliquid_clearinghouse_state();
|
|
104528
104573
|
browserUserFillsCache = /* @__PURE__ */ new Map();
|
|
@@ -104811,7 +104856,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
104811
104856
|
return true;
|
|
104812
104857
|
}
|
|
104813
104858
|
const detail = normalizeHyperliquidErrorDetail(error48).toLowerCase();
|
|
104814
|
-
return
|
|
104859
|
+
return isRateLimitErrorText(detail) || detail.includes("rate-limited") || detail.includes("cooldown");
|
|
104815
104860
|
};
|
|
104816
104861
|
servesStaleObservation = (error48, priority) => isRateLimitError(error48) || isHyperliquidReadRefusal(error48) && isHeldBackHyperliquidPriority(priority);
|
|
104817
104862
|
createAbortError = (message) => {
|
|
@@ -118660,7 +118705,7 @@ var init_browser_observability = __esm({
|
|
|
118660
118705
|
init_define_VTX_GROK_POLICY();
|
|
118661
118706
|
init_define_VTX_PI_MODEL_POLICY();
|
|
118662
118707
|
init_runtime_policy_generated2();
|
|
118663
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
118708
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "68890025dbd4546782da81b71404334ad74799f8".trim() && "68890025dbd4546782da81b71404334ad74799f8".trim() !== "unstamped" ? "68890025dbd4546782da81b71404334ad74799f8".trim() : null;
|
|
118664
118709
|
listenersInstalled = false;
|
|
118665
118710
|
state = {
|
|
118666
118711
|
loadedAtMs: Date.now(),
|
|
@@ -120703,6 +120748,7 @@ async function fetchCopyReviewPromptContract(profileId, payload, options) {
|
|
|
120703
120748
|
profileId,
|
|
120704
120749
|
buildClientRuntimeBody(payload, {
|
|
120705
120750
|
renders_derived_prompts: true,
|
|
120751
|
+
renders_prompt_field_legends: true,
|
|
120706
120752
|
copy_review_symbol: payload.copyReviewSymbol,
|
|
120707
120753
|
copy_review_symbols: payload.copyReviewSymbols
|
|
120708
120754
|
}),
|
|
@@ -123650,6 +123696,57 @@ var init_prompt_json_contract = __esm({
|
|
|
123650
123696
|
}
|
|
123651
123697
|
});
|
|
123652
123698
|
|
|
123699
|
+
// lib/runtime/prompt-field-visibility.ts
|
|
123700
|
+
var NO_FIELDS, LEGEND_TOKEN, isRecord7, readHidden, resolveHiddenPromptFields, hiddenFieldsOf, withoutHiddenFields, renderBlockLegend, renderPromptFieldLegends;
|
|
123701
|
+
var init_prompt_field_visibility = __esm({
|
|
123702
|
+
"lib/runtime/prompt-field-visibility.ts"() {
|
|
123703
|
+
"use strict";
|
|
123704
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
123705
|
+
init_define_VTX_EXO_POLICY();
|
|
123706
|
+
init_define_VTX_GROK_POLICY();
|
|
123707
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
123708
|
+
init_runtime_error_reason_rules();
|
|
123709
|
+
NO_FIELDS = /* @__PURE__ */ new Set();
|
|
123710
|
+
LEGEND_TOKEN = /\{([a-z_]+)_legend\}/g;
|
|
123711
|
+
isRecord7 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
123712
|
+
readHidden = (value, source) => Object.fromEntries(Object.entries(value).map(([block, fields]) => {
|
|
123713
|
+
if (!Array.isArray(fields) || fields.some((field) => typeof field !== "string")) {
|
|
123714
|
+
throw new RuntimeReasonError(`Invalid ${source}.${block}: must be a list of field names.`, "internal_data_error");
|
|
123715
|
+
}
|
|
123716
|
+
return [block, new Set(fields)];
|
|
123717
|
+
}));
|
|
123718
|
+
resolveHiddenPromptFields = (defaults, setting2) => {
|
|
123719
|
+
if (isRecord7(setting2)) return readHidden(setting2, "hidden_prompt_fields");
|
|
123720
|
+
if (defaults === void 0) return {};
|
|
123721
|
+
if (!isRecord7(defaults)) {
|
|
123722
|
+
throw new RuntimeReasonError("Invalid client runtime config: default_hidden_prompt_fields must be an object.", "runtime_config_missing");
|
|
123723
|
+
}
|
|
123724
|
+
return readHidden(defaults, "default_hidden_prompt_fields");
|
|
123725
|
+
};
|
|
123726
|
+
hiddenFieldsOf = (hidden, block) => hidden?.[block] ?? NO_FIELDS;
|
|
123727
|
+
withoutHiddenFields = (record6, hidden) => hidden.size === 0 ? record6 : Object.fromEntries(Object.entries(record6).filter(([key]) => !hidden.has(key)));
|
|
123728
|
+
renderBlockLegend = (block, catalog, hidden) => {
|
|
123729
|
+
if (!Array.isArray(catalog.keys) || !Array.isArray(catalog.legend)) {
|
|
123730
|
+
throw new RuntimeReasonError(`Missing prompts config key: instructions.data_format.fields.${block}`, "runtime_config_missing");
|
|
123731
|
+
}
|
|
123732
|
+
const keys = catalog.keys.filter((key) => !hidden.has(key)).map((key) => catalog.shapes?.[key] ?? key).join(",");
|
|
123733
|
+
return catalog.legend.map((part) => {
|
|
123734
|
+
const fields = part.fields ?? [];
|
|
123735
|
+
const visible = fields.filter((field) => !hidden.has(field));
|
|
123736
|
+
if (fields.length > 0 && visible.length === 0) return "";
|
|
123737
|
+
return part.text.replaceAll("{keys}", keys).replaceAll("{visible}", visible.join(","));
|
|
123738
|
+
}).join("");
|
|
123739
|
+
};
|
|
123740
|
+
renderPromptFieldLegends = (legend, catalogs, hidden) => legend.replace(LEGEND_TOKEN, (_token, block) => {
|
|
123741
|
+
const catalog = isRecord7(catalogs) ? catalogs[block] : void 0;
|
|
123742
|
+
if (!isRecord7(catalog)) {
|
|
123743
|
+
throw new RuntimeReasonError(`Missing prompts config key: instructions.data_format.fields.${block}`, "runtime_config_missing");
|
|
123744
|
+
}
|
|
123745
|
+
return renderBlockLegend(block, catalog, hiddenFieldsOf(hidden, block));
|
|
123746
|
+
});
|
|
123747
|
+
}
|
|
123748
|
+
});
|
|
123749
|
+
|
|
123653
123750
|
// lib/runtime/derived-context/guidance.ts
|
|
123654
123751
|
var FIELD_NAME, FIXED_SPEC, formatField, formatGuidanceTemplate, requireTemplates, requireTemplate, pythonFloatOrNull, threshold, pythonTruthy, enabled, finiteOrNull3, thresholdState, PERFORMANCE_CHECKS, REGIME_CHECKS, stateMessage, assemble, performanceGuidanceMessage, marketRegimeGuidanceMessage;
|
|
123655
123752
|
var init_guidance = __esm({
|
|
@@ -123918,6 +124015,7 @@ var init_calendar = __esm({
|
|
|
123918
124015
|
init_define_VTX_PI_MODEL_POLICY();
|
|
123919
124016
|
init_constants();
|
|
123920
124017
|
init_prompt_json_contract();
|
|
124018
|
+
init_prompt_field_visibility();
|
|
123921
124019
|
init_guidance();
|
|
123922
124020
|
init_python_text();
|
|
123923
124021
|
init_runtime_error_reason_rules();
|
|
@@ -124024,7 +124122,8 @@ var init_calendar = __esm({
|
|
|
124024
124122
|
if (activeEvents.length === 0) {
|
|
124025
124123
|
return "";
|
|
124026
124124
|
}
|
|
124027
|
-
const
|
|
124125
|
+
const hiddenFields = input.hiddenFields ?? /* @__PURE__ */ new Set();
|
|
124126
|
+
const block = `<calendar>${stringifyPromptJson(activeEvents.map((event) => withoutHiddenFields(event, hiddenFields)))}</calendar>`;
|
|
124028
124127
|
const header = output3.header;
|
|
124029
124128
|
const scope = output3.scope;
|
|
124030
124129
|
if (typeof header !== "string" || !header.trim() || typeof scope !== "string" || !scope.trim()) {
|
|
@@ -124073,7 +124172,7 @@ var init_interval = __esm({
|
|
|
124073
124172
|
});
|
|
124074
124173
|
|
|
124075
124174
|
// lib/runtime/derived-context/market-context.ts
|
|
124076
|
-
var calculateSlopeR2, calculateZScore, countPivots, formatCandleSpan, extractWindowFeatures, calculateRelativeVolumeRatio, buildMarketContext, marketCandleFromRow, marketContextInputFromPayload;
|
|
124175
|
+
var calculateSlopeR2, calculateZScore, countPivots, formatCandleSpan, extractWindowFeatures, calculateRelativeVolumeRatio, shownStats, buildMarketContext, marketCandleFromRow, marketContextInputFromPayload;
|
|
124077
124176
|
var init_market_context = __esm({
|
|
124078
124177
|
"lib/runtime/derived-context/market-context.ts"() {
|
|
124079
124178
|
"use strict";
|
|
@@ -124089,6 +124188,7 @@ var init_market_context = __esm({
|
|
|
124089
124188
|
init_python_numbers();
|
|
124090
124189
|
init_python_text();
|
|
124091
124190
|
init_runtime_error_reason_rules();
|
|
124191
|
+
init_prompt_field_visibility();
|
|
124092
124192
|
calculateSlopeR2 = (values) => {
|
|
124093
124193
|
const count5 = values.length;
|
|
124094
124194
|
if (count5 < REGRESSION_MIN_POINTS) {
|
|
@@ -124205,6 +124305,13 @@ var init_market_context = __esm({
|
|
|
124205
124305
|
}
|
|
124206
124306
|
return recentDollarVolume / baselineDollarVolume;
|
|
124207
124307
|
};
|
|
124308
|
+
shownStats = (stats, hidden) => hidden && hidden.size > 0 ? Object.fromEntries(Object.entries(stats).map(([symbol2, byTimeframe]) => [
|
|
124309
|
+
symbol2,
|
|
124310
|
+
Object.fromEntries(Object.entries(byTimeframe).map(([timeframe, features]) => [
|
|
124311
|
+
timeframe,
|
|
124312
|
+
withoutHiddenFields(features, hidden)
|
|
124313
|
+
]))
|
|
124314
|
+
])) : stats;
|
|
124208
124315
|
buildMarketContext = (input) => {
|
|
124209
124316
|
const timeframes = [...new Set(input.timeframes)].sort(compareCandleTimeframes);
|
|
124210
124317
|
const stats = {};
|
|
@@ -124258,7 +124365,7 @@ var init_market_context = __esm({
|
|
|
124258
124365
|
}
|
|
124259
124366
|
const cleanStats = Object.fromEntries(Object.entries(stats).filter(([, value]) => Object.keys(value).length > 0));
|
|
124260
124367
|
const marketStats = Object.keys(cleanStats).length > 0 ? `<market_stats>
|
|
124261
|
-
${stringifyPromptJson(cleanStats)}
|
|
124368
|
+
${stringifyPromptJson(shownStats(cleanStats, input.hiddenStatFields))}
|
|
124262
124369
|
</market_stats>` : "";
|
|
124263
124370
|
const expected = input.symbols.flatMap((rawSymbol) => {
|
|
124264
124371
|
const symbol2 = String(rawSymbol).trim();
|
|
@@ -124311,6 +124418,7 @@ var init_market_regime = __esm({
|
|
|
124311
124418
|
init_constants();
|
|
124312
124419
|
init_candle_timeframes();
|
|
124313
124420
|
init_prompt_json_contract();
|
|
124421
|
+
init_prompt_field_visibility();
|
|
124314
124422
|
init_prompt_number_contract();
|
|
124315
124423
|
init_guidance();
|
|
124316
124424
|
init_python_numbers();
|
|
@@ -124385,13 +124493,13 @@ var init_market_regime = __esm({
|
|
|
124385
124493
|
for (const timeframe of Object.keys(activeMap).sort(compareCandleTimeframes)) {
|
|
124386
124494
|
const values = activeMap[timeframe];
|
|
124387
124495
|
const relativeVolume = roundPromptRelativeVolume(values.relative_volume);
|
|
124388
|
-
symbolRegime[timeframe] = {
|
|
124496
|
+
symbolRegime[timeframe] = withoutHiddenFields({
|
|
124389
124497
|
adx: values.adx === null || values.adx === void 0 ? "-" : pythonRound(values.adx, REGIME_ADX_CHOP_DECIMALS),
|
|
124390
124498
|
chop: values.chop === null || values.chop === void 0 ? "-" : pythonRound(values.chop, REGIME_ADX_CHOP_DECIMALS),
|
|
124391
124499
|
atr: values.atr_pct === null || values.atr_pct === void 0 ? "-" : pythonRound(values.atr_pct, PROMPT_METRIC_DECIMALS),
|
|
124392
124500
|
// The candle-row rv column shows the same value with the same rounding.
|
|
124393
124501
|
rv: relativeVolume === null ? "-" : relativeVolume
|
|
124394
|
-
};
|
|
124502
|
+
}, input.hiddenFields ?? /* @__PURE__ */ new Set());
|
|
124395
124503
|
}
|
|
124396
124504
|
guidance[symbol2] = symbolRegime;
|
|
124397
124505
|
}
|
|
@@ -124503,6 +124611,7 @@ var init_performance = __esm({
|
|
|
124503
124611
|
init_define_VTX_PI_MODEL_POLICY();
|
|
124504
124612
|
init_constants();
|
|
124505
124613
|
init_prompt_json_contract();
|
|
124614
|
+
init_prompt_field_visibility();
|
|
124506
124615
|
init_guidance();
|
|
124507
124616
|
init_python_numbers();
|
|
124508
124617
|
init_runtime_error_reason_rules();
|
|
@@ -124760,8 +124869,9 @@ var init_performance = __esm({
|
|
|
124760
124869
|
mlc: pair((metrics) => Math.trunc(metrics.lossCount))
|
|
124761
124870
|
};
|
|
124762
124871
|
const performanceStructured = { global: globalSummary };
|
|
124872
|
+
const shownGlobal = withoutHiddenFields(globalSummary, input.hiddenFields ?? /* @__PURE__ */ new Set());
|
|
124763
124873
|
let performance2 = `<performance>
|
|
124764
|
-
${stringifyPromptJson(
|
|
124874
|
+
${stringifyPromptJson({ global: shownGlobal })}
|
|
124765
124875
|
</performance>`;
|
|
124766
124876
|
const shortLabel = `${pythonFloatRepr(shortWindowHours)}h`;
|
|
124767
124877
|
const longLabel = `${pythonFloatRepr(longWindowHours)}h`;
|
|
@@ -124893,6 +125003,7 @@ var init_render = __esm({
|
|
|
124893
125003
|
init_performance();
|
|
124894
125004
|
init_reference_candles();
|
|
124895
125005
|
init_runtime_error_reason_rules();
|
|
125006
|
+
init_prompt_field_visibility();
|
|
124896
125007
|
CLIENT_RUNTIME_LIVE_MARKET_STATS_UNAVAILABLE_ERROR = "Live market stats unavailable for client runtime contract";
|
|
124897
125008
|
CLIENT_RUNTIME_LIVE_PERFORMANCE_UNAVAILABLE_ERROR = "Live performance context unavailable for client runtime contract";
|
|
124898
125009
|
CLIENT_RUNTIME_LIVE_MARKET_REGIME_UNAVAILABLE_ERROR = "Live market regime context unavailable for client runtime contract";
|
|
@@ -124909,31 +125020,34 @@ var init_render = __esm({
|
|
|
124909
125020
|
this.name = "DerivedPromptContextUnavailableError";
|
|
124910
125021
|
}
|
|
124911
125022
|
};
|
|
124912
|
-
renderPerformanceInputs = (performance2, templates) => buildPerformanceContext({
|
|
125023
|
+
renderPerformanceInputs = (performance2, templates, hiddenFields) => buildPerformanceContext({
|
|
124913
125024
|
fillRecords: performance2.fill_records,
|
|
124914
125025
|
equityHistory: performance2.equity_history,
|
|
124915
125026
|
accountBalance: performance2.account_balance,
|
|
124916
125027
|
nowMs: performance2.now_ms,
|
|
124917
125028
|
config: performance2.config,
|
|
124918
125029
|
breakevenToleranceUsd: performance2.breakeven_tolerance_usd,
|
|
124919
|
-
templates
|
|
125030
|
+
templates,
|
|
125031
|
+
hiddenFields
|
|
124920
125032
|
});
|
|
124921
|
-
renderMarketRegime = (regimeIndicators, scope, thresholds, templates) => buildMarketRegimeContext({
|
|
125033
|
+
renderMarketRegime = (regimeIndicators, scope, thresholds, templates, hiddenFields) => buildMarketRegimeContext({
|
|
124922
125034
|
regimeIndicators,
|
|
124923
125035
|
symbols: scope.symbols,
|
|
124924
125036
|
primarySymbol: scope.primary_symbol,
|
|
124925
125037
|
activeTimeframes: scope.timeframes,
|
|
124926
125038
|
fallbackTimeframes: scope.fallback_timeframes,
|
|
124927
125039
|
thresholds,
|
|
124928
|
-
templates
|
|
125040
|
+
templates,
|
|
125041
|
+
hiddenFields
|
|
124929
125042
|
});
|
|
124930
|
-
renderCalendarInputs = (calendar, templates) => buildCalendarContext({
|
|
125043
|
+
renderCalendarInputs = (calendar, templates, hiddenFields) => buildCalendarContext({
|
|
124931
125044
|
events: calendar.events,
|
|
124932
125045
|
unavailable: calendar.unavailable,
|
|
124933
125046
|
settings: calendar.settings,
|
|
124934
125047
|
defaults: calendar.defaults,
|
|
124935
125048
|
templates: templates.calendar,
|
|
124936
|
-
nowSeconds: calendar.now_seconds
|
|
125049
|
+
nowSeconds: calendar.now_seconds,
|
|
125050
|
+
hiddenFields
|
|
124937
125051
|
});
|
|
124938
125052
|
renderNewsInputs = (news) => Object.fromEntries(
|
|
124939
125053
|
Object.entries(news ?? {}).map(([variable, item]) => [variable, buildNewsContext({
|
|
@@ -124965,7 +125079,11 @@ var init_render = __esm({
|
|
|
124965
125079
|
const uses = (variable) => input.placeholders.includes(variable);
|
|
124966
125080
|
const templates = requireInput(inputs.guidance_templates, "guidance_templates");
|
|
124967
125081
|
const values = {};
|
|
124968
|
-
const
|
|
125082
|
+
const hidden = input.hiddenPromptFields;
|
|
125083
|
+
const market = buildMarketContext({
|
|
125084
|
+
...marketContextInputFromPayload(requireInput(inputs.market, "market"), input.deviceMarket),
|
|
125085
|
+
hiddenStatFields: hiddenFieldsOf(hidden, "market_stats")
|
|
125086
|
+
});
|
|
124969
125087
|
if (uses("market_stats")) {
|
|
124970
125088
|
if (!market.marketStats || !market.marketStatsComplete) {
|
|
124971
125089
|
throw new DerivedPromptContextUnavailableError(CLIENT_RUNTIME_LIVE_MARKET_STATS_UNAVAILABLE_ERROR);
|
|
@@ -124975,8 +125093,14 @@ var init_render = __esm({
|
|
|
124975
125093
|
const performanceInputs = requireInput(inputs.performance, "performance");
|
|
124976
125094
|
let performanceStructured = null;
|
|
124977
125095
|
try {
|
|
124978
|
-
const performance2 = renderPerformanceInputs(performanceInputs, templates);
|
|
124979
|
-
const marketRegime = renderMarketRegime(
|
|
125096
|
+
const performance2 = renderPerformanceInputs(performanceInputs, templates, hiddenFieldsOf(hidden, "performance"));
|
|
125097
|
+
const marketRegime = renderMarketRegime(
|
|
125098
|
+
market.regimeIndicators,
|
|
125099
|
+
performanceInputs,
|
|
125100
|
+
performanceInputs.config.thresholds,
|
|
125101
|
+
templates,
|
|
125102
|
+
hiddenFieldsOf(hidden, "market_regime")
|
|
125103
|
+
);
|
|
124980
125104
|
if (performance2.performance) values.performance = performance2.performance;
|
|
124981
125105
|
if (marketRegime) values.market_regime = marketRegime;
|
|
124982
125106
|
performanceStructured = performance2.performanceStructured;
|
|
@@ -124989,7 +125113,7 @@ var init_render = __esm({
|
|
|
124989
125113
|
if (uses("market_regime") && !String(values.market_regime ?? "").trim()) {
|
|
124990
125114
|
throw new DerivedPromptContextUnavailableError(CLIENT_RUNTIME_LIVE_MARKET_REGIME_UNAVAILABLE_ERROR);
|
|
124991
125115
|
}
|
|
124992
|
-
values.calendar = renderCalendarInputs(requireInput(inputs.calendar, "calendar"), templates);
|
|
125116
|
+
values.calendar = renderCalendarInputs(requireInput(inputs.calendar, "calendar"), templates, hiddenFieldsOf(hidden, "calendar"));
|
|
124993
125117
|
Object.assign(values, renderNewsInputs(inputs.news));
|
|
124994
125118
|
let referenceIndicators;
|
|
124995
125119
|
if (inputs.reference_candles) {
|
|
@@ -128963,6 +129087,7 @@ var init_runtime_prompt_steps = __esm({
|
|
|
128963
129087
|
init_provider_client();
|
|
128964
129088
|
init_native_request_parameters();
|
|
128965
129089
|
init_constants();
|
|
129090
|
+
init_prompt_field_visibility();
|
|
128966
129091
|
init_runtime_error_reason_rules();
|
|
128967
129092
|
init_local_analysis();
|
|
128968
129093
|
buildRuntimePromptParityContext = (input) => {
|
|
@@ -129222,10 +129347,12 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129222
129347
|
return inputs;
|
|
129223
129348
|
};
|
|
129224
129349
|
buildRuntimeBehaviorStateArtifacts = (input) => {
|
|
129350
|
+
const hiddenFields = hiddenFieldsOf(input.hiddenPromptFields, "behavior_state");
|
|
129225
129351
|
if (input.serverOwnsBehaviorState) {
|
|
129226
129352
|
return buildServerBehaviorStateArtifacts(requireServerBehaviorStateInputs(input.derivedContext), {
|
|
129227
129353
|
behaviorInstructions: input.behaviorInstructions,
|
|
129228
|
-
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol
|
|
129354
|
+
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol,
|
|
129355
|
+
hiddenFields
|
|
129229
129356
|
});
|
|
129230
129357
|
}
|
|
129231
129358
|
const behaviorFillCoverage = input.fillEvidence?.source === "live" && input.fillEvidence.exactTerminalFillEvidenceComplete === true ? "complete" : "capped";
|
|
@@ -129240,7 +129367,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129240
129367
|
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol,
|
|
129241
129368
|
decisionMemory: asRecord(input.derivedContext.behavior_decision_memory),
|
|
129242
129369
|
cycleCutoffMs: input.cutoffMs,
|
|
129243
|
-
fillHistoryCoverage: behaviorFillCoverage
|
|
129370
|
+
fillHistoryCoverage: behaviorFillCoverage,
|
|
129371
|
+
hiddenFields
|
|
129244
129372
|
});
|
|
129245
129373
|
};
|
|
129246
129374
|
buildRuntimePromptContextParts = (input) => ({
|
|
@@ -129270,7 +129398,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129270
129398
|
size: input.size,
|
|
129271
129399
|
leverage: input.leverage,
|
|
129272
129400
|
// {interval}, rendered from the contract's loop interval.
|
|
129273
|
-
interval: input.derivedBlocks.intervalContext
|
|
129401
|
+
interval: input.derivedBlocks.intervalContext,
|
|
129402
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
129274
129403
|
});
|
|
129275
129404
|
runtimePromptArtifactInput = (input) => ({
|
|
129276
129405
|
systemTemplate: input.systemTemplate,
|
|
@@ -129281,7 +129410,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129281
129410
|
maxTradesPerPrompt: input.maxTradesPerPrompt,
|
|
129282
129411
|
metricsWindowHours: input.metricsWindowHours,
|
|
129283
129412
|
metricsSecondaryWindowHours: input.metricsSecondaryWindowHours,
|
|
129284
|
-
userTemplate: input.userTemplate
|
|
129413
|
+
userTemplate: input.userTemplate,
|
|
129414
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
129285
129415
|
});
|
|
129286
129416
|
}
|
|
129287
129417
|
});
|
|
@@ -129300,6 +129430,7 @@ var init_prompt_contract = __esm({
|
|
|
129300
129430
|
init_candle_prompt_contract();
|
|
129301
129431
|
init_constants();
|
|
129302
129432
|
init_python_text();
|
|
129433
|
+
init_prompt_field_visibility();
|
|
129303
129434
|
PROMPT_PLACEHOLDER_MAP = {};
|
|
129304
129435
|
DATA_FORMAT_TAG_ALIASES = {};
|
|
129305
129436
|
buildDecisionInstructionVariables = (rawSymbols, maxTrades) => {
|
|
@@ -129438,7 +129569,7 @@ var init_prompt_contract = __esm({
|
|
|
129438
129569
|
};
|
|
129439
129570
|
const metricsWindowLabel = formatWindowHours(options.metricsWindowHours);
|
|
129440
129571
|
const metricsSecondaryWindowLabel = formatWindowHours(options.metricsSecondaryWindowHours);
|
|
129441
|
-
let legend = String(legendTemplate ?? "").replaceAll("{metrics_window_hours}", metricsWindowLabel).replaceAll("{metrics_secondary_window_hours}", metricsSecondaryWindowLabel).replaceAll("{metrics_window}", metricsWindowLabel).replaceAll("{metrics_secondary_window}", metricsSecondaryWindowLabel).trim();
|
|
129572
|
+
let legend = renderPromptFieldLegends(String(legendTemplate ?? ""), options.fieldCatalogs, options.hiddenPromptFields).replaceAll("{metrics_window_hours}", metricsWindowLabel).replaceAll("{metrics_secondary_window_hours}", metricsSecondaryWindowLabel).replaceAll("{metrics_window}", metricsWindowLabel).replaceAll("{metrics_secondary_window}", metricsSecondaryWindowLabel).trim();
|
|
129442
129573
|
if (!legend) return "";
|
|
129443
129574
|
const candleLiveFieldToken = "{candle_live_field}";
|
|
129444
129575
|
const candleLiveGuidanceToken = "{candle_live_guidance}";
|
|
@@ -129742,7 +129873,9 @@ ${jsonInstruction}`.trim();
|
|
|
129742
129873
|
behaviorEntryTradeSchema: instructions.data_format?.behavior_entry_trade,
|
|
129743
129874
|
candleIndicatorSchemas: instructions.data_format?.candle_indicators,
|
|
129744
129875
|
referenceCandlesSummary: options.referenceCandlesSummary,
|
|
129745
|
-
referenceIndicatorFlags: options.referenceIndicatorFlags
|
|
129876
|
+
referenceIndicatorFlags: options.referenceIndicatorFlags,
|
|
129877
|
+
fieldCatalogs: instructions.data_format?.fields,
|
|
129878
|
+
hiddenPromptFields: options.hiddenPromptFields
|
|
129746
129879
|
});
|
|
129747
129880
|
const hasDataFormatInstructions = /^[ \t]*DATA FORMAT(?: INSTRUCTIONS)?:/m.test(template);
|
|
129748
129881
|
if (legend && !hasDataFormatInstructions) {
|
|
@@ -129761,7 +129894,8 @@ ${legend}`.trim();
|
|
|
129761
129894
|
behaviorEntryTradeSchema: instructions.data_format?.behavior_entry_trade,
|
|
129762
129895
|
candleIndicatorSchemas: instructions.data_format?.candle_indicators,
|
|
129763
129896
|
referenceCandlesSummary: options.referenceCandlesSummary,
|
|
129764
|
-
referenceIndicatorFlags: options.referenceIndicatorFlags
|
|
129897
|
+
referenceIndicatorFlags: options.referenceIndicatorFlags,
|
|
129898
|
+
fieldCatalogs: instructions.data_format?.fields
|
|
129765
129899
|
});
|
|
129766
129900
|
template = replaceEmbeddedDataFormatLegend(template, canonicalLegend, legend);
|
|
129767
129901
|
}
|
|
@@ -129772,7 +129906,7 @@ ${legend}`.trim();
|
|
|
129772
129906
|
});
|
|
129773
129907
|
|
|
129774
129908
|
// lib/runtime/behavior-memory-prompt-observability.ts
|
|
129775
|
-
var BODY_FREE_STATUS_FIELDS,
|
|
129909
|
+
var BODY_FREE_STATUS_FIELDS, isRecord8, isBodyFreeScalar, sanitizeBehaviorMemoryStatus, sha256Hex3, renderBehaviorMemoryPromptSeam;
|
|
129776
129910
|
var init_behavior_memory_prompt_observability = __esm({
|
|
129777
129911
|
"lib/runtime/behavior-memory-prompt-observability.ts"() {
|
|
129778
129912
|
"use strict";
|
|
@@ -129801,10 +129935,10 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129801
129935
|
"duration_ms",
|
|
129802
129936
|
"loader_outcome"
|
|
129803
129937
|
];
|
|
129804
|
-
|
|
129938
|
+
isRecord8 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
129805
129939
|
isBodyFreeScalar = (value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
129806
129940
|
sanitizeBehaviorMemoryStatus = (value) => {
|
|
129807
|
-
if (!
|
|
129941
|
+
if (!isRecord8(value)) {
|
|
129808
129942
|
return {};
|
|
129809
129943
|
}
|
|
129810
129944
|
const sanitized = {};
|
|
@@ -129814,16 +129948,16 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129814
129948
|
sanitized[key] = fieldValue;
|
|
129815
129949
|
}
|
|
129816
129950
|
}
|
|
129817
|
-
if (
|
|
129951
|
+
if (isRecord8(value.symbols)) {
|
|
129818
129952
|
const symbols = {};
|
|
129819
129953
|
for (const [symbol2, rawSymbolStatus] of Object.entries(value.symbols)) {
|
|
129820
|
-
if (!
|
|
129954
|
+
if (!isRecord8(rawSymbolStatus)) {
|
|
129821
129955
|
continue;
|
|
129822
129956
|
}
|
|
129823
129957
|
const symbolStatus = {};
|
|
129824
129958
|
for (const itemKey of ["pd", "pc", "et"]) {
|
|
129825
129959
|
const rawItemStatus = rawSymbolStatus[itemKey];
|
|
129826
|
-
if (!
|
|
129960
|
+
if (!isRecord8(rawItemStatus)) {
|
|
129827
129961
|
continue;
|
|
129828
129962
|
}
|
|
129829
129963
|
const itemStatus = {};
|
|
@@ -129915,6 +130049,93 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129915
130049
|
}
|
|
129916
130050
|
});
|
|
129917
130051
|
|
|
130052
|
+
// lib/runtime/prompt-collateral-contract.ts
|
|
130053
|
+
var orderPromptSymbols, buildPromptCollateralPools, poolEquityForSymbol, buildPromptFeeMap;
|
|
130054
|
+
var init_prompt_collateral_contract = __esm({
|
|
130055
|
+
"lib/runtime/prompt-collateral-contract.ts"() {
|
|
130056
|
+
"use strict";
|
|
130057
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
130058
|
+
init_define_VTX_EXO_POLICY();
|
|
130059
|
+
init_define_VTX_GROK_POLICY();
|
|
130060
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
130061
|
+
init_hyperliquid_market_symbol();
|
|
130062
|
+
init_prompt_number_contract();
|
|
130063
|
+
init_constants();
|
|
130064
|
+
orderPromptSymbols = (selected, held = []) => {
|
|
130065
|
+
const ordered = new Set(selected.map(normalizeHyperliquidMarketSymbol).filter(Boolean));
|
|
130066
|
+
const heldOnly = [...new Set(held.map(normalizeHyperliquidMarketSymbol).filter(Boolean))].filter((symbol2) => !ordered.has(symbol2)).sort();
|
|
130067
|
+
return [...ordered, ...heldOnly];
|
|
130068
|
+
};
|
|
130069
|
+
buildPromptCollateralPools = (accounts, symbols) => {
|
|
130070
|
+
const byDex = /* @__PURE__ */ new Map();
|
|
130071
|
+
const duplicateDexes = /* @__PURE__ */ new Set();
|
|
130072
|
+
for (const account of Array.isArray(accounts) ? accounts : []) {
|
|
130073
|
+
if (!account || typeof account !== "object" || typeof account.dex !== "string") continue;
|
|
130074
|
+
const dex = account.dex.trim().toLowerCase();
|
|
130075
|
+
if (byDex.has(dex)) duplicateDexes.add(dex);
|
|
130076
|
+
byDex.set(dex, account);
|
|
130077
|
+
}
|
|
130078
|
+
const symbolsByDex = /* @__PURE__ */ new Map();
|
|
130079
|
+
for (const raw of symbols) {
|
|
130080
|
+
const symbol2 = normalizeHyperliquidMarketSymbol(raw);
|
|
130081
|
+
if (!symbol2) continue;
|
|
130082
|
+
const dex = getHyperliquidMarketDex(symbol2);
|
|
130083
|
+
if (!symbolsByDex.has(dex)) symbolsByDex.set(dex, /* @__PURE__ */ new Set());
|
|
130084
|
+
symbolsByDex.get(dex).add(symbol2);
|
|
130085
|
+
}
|
|
130086
|
+
const number6 = (account, field) => {
|
|
130087
|
+
const raw = account[field];
|
|
130088
|
+
if (typeof raw !== "number" && typeof raw !== "string" || typeof raw === "string" && !raw.trim()) return null;
|
|
130089
|
+
const value = Number(raw);
|
|
130090
|
+
return Number.isFinite(value) ? value : null;
|
|
130091
|
+
};
|
|
130092
|
+
return [...symbolsByDex.keys()].map((dex) => {
|
|
130093
|
+
const account = duplicateDexes.has(dex) ? {} : byDex.get(dex) ?? {};
|
|
130094
|
+
const e = number6(account, "account_value");
|
|
130095
|
+
const u = number6(account, "total_unrealized_pnl");
|
|
130096
|
+
const m = number6(account, "maintenance_margin");
|
|
130097
|
+
const metrics = {
|
|
130098
|
+
e,
|
|
130099
|
+
b: e !== null && u !== null ? e - u : null,
|
|
130100
|
+
u,
|
|
130101
|
+
l: number6(account, "cross_account_leverage"),
|
|
130102
|
+
ut: e !== null && e > 0 && m !== null ? PERCENT_SCALE * m / e : null,
|
|
130103
|
+
a: number6(account, "available_margin"),
|
|
130104
|
+
m,
|
|
130105
|
+
lb: e !== null && m !== null ? e - m : null,
|
|
130106
|
+
mu: number6(account, "total_margin_used")
|
|
130107
|
+
};
|
|
130108
|
+
return {
|
|
130109
|
+
dex,
|
|
130110
|
+
symbols: [...symbolsByDex.get(dex)],
|
|
130111
|
+
...Object.fromEntries(Object.entries(metrics).map(([key, value]) => [
|
|
130112
|
+
key,
|
|
130113
|
+
value === null ? null : roundPromptFixed(value, key === "ut" ? PROMPT_MARGIN_UTILIZATION_DECIMALS : PROMPT_FIXED_DIGITS)
|
|
130114
|
+
]))
|
|
130115
|
+
};
|
|
130116
|
+
});
|
|
130117
|
+
};
|
|
130118
|
+
poolEquityForSymbol = (accounts, symbol2) => {
|
|
130119
|
+
const pool = buildPromptCollateralPools(accounts, [symbol2])[0];
|
|
130120
|
+
const dex = getHyperliquidMarketDex(symbol2);
|
|
130121
|
+
const matches = (Array.isArray(accounts) ? accounts : []).filter((account) => account && typeof account.dex === "string" && account.dex.trim().toLowerCase() === dex);
|
|
130122
|
+
if (!pool || matches.length !== 1 || matches[0].account_value == null) return null;
|
|
130123
|
+
const raw = matches[0].account_value;
|
|
130124
|
+
if (typeof raw !== "number" && typeof raw !== "string" || typeof raw === "string" && !raw.trim()) return null;
|
|
130125
|
+
const value = Number(raw);
|
|
130126
|
+
return Number.isFinite(value) ? value : null;
|
|
130127
|
+
};
|
|
130128
|
+
buildPromptFeeMap = (rates, symbols) => {
|
|
130129
|
+
const source = rates && typeof rates === "object" && !Array.isArray(rates) ? rates : {};
|
|
130130
|
+
return Object.fromEntries(orderPromptSymbols(symbols).map((symbol2) => {
|
|
130131
|
+
const raw = source[symbol2];
|
|
130132
|
+
const value = typeof raw === "number" && Number.isFinite(raw) && raw >= 0 && raw < 1 ? raw : null;
|
|
130133
|
+
return [symbol2, value];
|
|
130134
|
+
}));
|
|
130135
|
+
};
|
|
130136
|
+
}
|
|
130137
|
+
});
|
|
130138
|
+
|
|
129918
130139
|
// lib/runtime/position-prompt-contract.ts
|
|
129919
130140
|
var promptPercent, projectPositionPromptNormalization, projectPositionPromptExcursions;
|
|
129920
130141
|
var init_position_prompt_contract = __esm({
|
|
@@ -129989,89 +130210,151 @@ var init_position_prompt_contract = __esm({
|
|
|
129989
130210
|
}
|
|
129990
130211
|
});
|
|
129991
130212
|
|
|
129992
|
-
// lib/runtime/prompt-
|
|
129993
|
-
var
|
|
129994
|
-
var
|
|
129995
|
-
"lib/runtime/prompt-
|
|
130213
|
+
// lib/runtime/prompt-positions-block.ts
|
|
130214
|
+
var formatPromptPrice, buildPromptAccountStatusValue, buildPromptPositionsValue;
|
|
130215
|
+
var init_prompt_positions_block = __esm({
|
|
130216
|
+
"lib/runtime/prompt-positions-block.ts"() {
|
|
129996
130217
|
"use strict";
|
|
129997
130218
|
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
129998
130219
|
init_define_VTX_EXO_POLICY();
|
|
129999
130220
|
init_define_VTX_GROK_POLICY();
|
|
130000
130221
|
init_define_VTX_PI_MODEL_POLICY();
|
|
130222
|
+
init_constants();
|
|
130223
|
+
init_execution_capacity();
|
|
130001
130224
|
init_hyperliquid_market_symbol();
|
|
130225
|
+
init_position_prompt_contract();
|
|
130226
|
+
init_prompt_collateral_contract();
|
|
130227
|
+
init_prompt_field_visibility();
|
|
130228
|
+
init_prompt_json_contract();
|
|
130002
130229
|
init_prompt_number_contract();
|
|
130003
|
-
|
|
130004
|
-
|
|
130005
|
-
|
|
130006
|
-
const
|
|
130007
|
-
|
|
130008
|
-
|
|
130009
|
-
buildPromptCollateralPools = (accounts, symbols) => {
|
|
130010
|
-
const byDex = /* @__PURE__ */ new Map();
|
|
130011
|
-
const duplicateDexes = /* @__PURE__ */ new Set();
|
|
130012
|
-
for (const account of Array.isArray(accounts) ? accounts : []) {
|
|
130013
|
-
if (!account || typeof account !== "object" || typeof account.dex !== "string") continue;
|
|
130014
|
-
const dex = account.dex.trim().toLowerCase();
|
|
130015
|
-
if (byDex.has(dex)) duplicateDexes.add(dex);
|
|
130016
|
-
byDex.set(dex, account);
|
|
130230
|
+
init_prompt_variable_validation_contract();
|
|
130231
|
+
init_runtime_error_reason_rules();
|
|
130232
|
+
formatPromptPrice = (value) => {
|
|
130233
|
+
const numeric2 = Number(value);
|
|
130234
|
+
if (!Number.isFinite(numeric2) || numeric2 === 0) {
|
|
130235
|
+
return 0;
|
|
130017
130236
|
}
|
|
130018
|
-
|
|
130019
|
-
|
|
130020
|
-
const symbol2 = normalizeHyperliquidMarketSymbol(raw);
|
|
130021
|
-
if (!symbol2) continue;
|
|
130022
|
-
const dex = getHyperliquidMarketDex(symbol2);
|
|
130023
|
-
if (!symbolsByDex.has(dex)) symbolsByDex.set(dex, /* @__PURE__ */ new Set());
|
|
130024
|
-
symbolsByDex.get(dex).add(symbol2);
|
|
130237
|
+
if (Math.abs(numeric2) >= PROMPT_PRICE_INTEGER_THRESHOLD) {
|
|
130238
|
+
return Number(Math.trunc(numeric2));
|
|
130025
130239
|
}
|
|
130026
|
-
|
|
130027
|
-
|
|
130028
|
-
|
|
130029
|
-
|
|
130030
|
-
|
|
130240
|
+
return roundPromptSignificant(numeric2, PROMPT_SIGNIFICANT_DIGITS);
|
|
130241
|
+
};
|
|
130242
|
+
buildPromptAccountStatusValue = (accountSummary, marginNote, effectiveTakerRates, symbols, hiddenFields) => [
|
|
130243
|
+
"<account_status>",
|
|
130244
|
+
stringifyPromptJson(withoutHiddenFields({
|
|
130245
|
+
pools: buildPromptCollateralPools(accountSummary.perp_dex_accounts, symbols).map((pool) => withoutHiddenFields(pool, hiddenFields)),
|
|
130246
|
+
fees: buildPromptFeeMap(effectiveTakerRates, symbols)
|
|
130247
|
+
}, hiddenFields)),
|
|
130248
|
+
"</account_status>",
|
|
130249
|
+
"",
|
|
130250
|
+
marginNote
|
|
130251
|
+
].join("\n");
|
|
130252
|
+
buildPromptPositionsValue = (input) => {
|
|
130253
|
+
const validateInstructionTemplate = (template, allowedKeys) => {
|
|
130254
|
+
formatInstructionTemplate(
|
|
130255
|
+
template,
|
|
130256
|
+
Object.fromEntries(allowedKeys.map((key) => [key, ""])),
|
|
130257
|
+
"positions instruction template"
|
|
130258
|
+
);
|
|
130031
130259
|
};
|
|
130032
|
-
|
|
130033
|
-
|
|
130034
|
-
|
|
130035
|
-
|
|
130036
|
-
|
|
130037
|
-
|
|
130038
|
-
|
|
130039
|
-
|
|
130040
|
-
|
|
130041
|
-
|
|
130042
|
-
|
|
130043
|
-
|
|
130044
|
-
|
|
130045
|
-
|
|
130046
|
-
|
|
130047
|
-
|
|
130260
|
+
validateInstructionTemplate(input.positionsInstructions.close_reduce, []);
|
|
130261
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_flat, []);
|
|
130262
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_full, []);
|
|
130263
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_low, ["remaining"]);
|
|
130264
|
+
const activePositions = input.positions.filter((position) => Number(position.size) !== 0);
|
|
130265
|
+
const orderedSymbols = orderPromptSymbols(input.symbols, activePositions.map((position) => position.symbol));
|
|
130266
|
+
const symbolRanks = new Map(orderedSymbols.map((symbol2, index) => [symbol2, index]));
|
|
130267
|
+
activePositions.sort((left, right) => symbolRanks.get(normalizeHyperliquidMarketSymbol(left.symbol)) - symbolRanks.get(normalizeHyperliquidMarketSymbol(right.symbol)));
|
|
130268
|
+
const assetUsage = /* @__PURE__ */ new Map();
|
|
130269
|
+
const exchangeUsage = /* @__PURE__ */ new Map();
|
|
130270
|
+
let globalUnitsUsed = 0;
|
|
130271
|
+
const promptPositions = activePositions.map((position) => {
|
|
130272
|
+
const entryPrice = Number(position.entry_price);
|
|
130273
|
+
const size = Number(position.size);
|
|
130274
|
+
const unrealizedPnl = Number(position.unrealized_pnl);
|
|
130275
|
+
if (!Number.isFinite(entryPrice) || entryPrice <= 0 || !Number.isFinite(size) || size === 0) {
|
|
130276
|
+
throw new RuntimeReasonError(`Active position identity/economics are invalid for ${position.symbol}`, "internal_data_error");
|
|
130277
|
+
}
|
|
130278
|
+
if (!Number.isFinite(unrealizedPnl)) {
|
|
130279
|
+
throw new RuntimeReasonError(`Active position PnL is unavailable for ${position.symbol}`, "internal_data_error");
|
|
130280
|
+
}
|
|
130281
|
+
const notionalValue = Math.abs(size * entryPrice);
|
|
130282
|
+
const unitsUsed = capacityUnitsUsedForPosition(size, entryPrice, input.unitSize);
|
|
130283
|
+
globalUnitsUsed += unitsUsed;
|
|
130284
|
+
assetUsage.set(position.symbol, unitsUsed);
|
|
130285
|
+
const venue = getHyperliquidMarketDex(position.symbol);
|
|
130286
|
+
exchangeUsage.set(venue, (exchangeUsage.get(venue) ?? 0) + unitsUsed);
|
|
130287
|
+
const currentValue = Math.abs(size > 0 ? notionalValue + unrealizedPnl : notionalValue - unrealizedPnl);
|
|
130288
|
+
const takerRate = buildPromptFeeMap(input.effectiveTakerRates, [position.symbol])[normalizeHyperliquidMarketSymbol(position.symbol)];
|
|
130289
|
+
const totalFees = takerRate == null ? null : (notionalValue + currentValue) * takerRate;
|
|
130290
|
+
const pnlAfterFees = totalFees == null ? null : unrealizedPnl - totalFees;
|
|
130291
|
+
let breakeven = null;
|
|
130292
|
+
if (entryPrice > 0 && takerRate != null) {
|
|
130293
|
+
if (size > 0) {
|
|
130294
|
+
breakeven = entryPrice * (1 + takerRate) / (1 - takerRate);
|
|
130295
|
+
} else if (size < 0) {
|
|
130296
|
+
breakeven = entryPrice * (1 - takerRate) / (1 + takerRate);
|
|
130297
|
+
}
|
|
130298
|
+
}
|
|
130048
130299
|
return {
|
|
130049
|
-
|
|
130050
|
-
|
|
130051
|
-
|
|
130052
|
-
|
|
130053
|
-
|
|
130054
|
-
|
|
130300
|
+
s: position.symbol,
|
|
130301
|
+
sd: size > 0 ? "LONG" : "SHORT",
|
|
130302
|
+
v: roundPromptFixed(notionalValue),
|
|
130303
|
+
cv: roundPromptFixed(currentValue),
|
|
130304
|
+
ep: entryPrice ? formatPromptPrice(entryPrice) : 0,
|
|
130305
|
+
be: breakeven == null ? null : formatPromptPrice(breakeven),
|
|
130306
|
+
liq: position.liquidation_price ? formatPromptPrice(position.liquidation_price) : "-",
|
|
130307
|
+
u: unitsUsed,
|
|
130308
|
+
up: roundPromptFixed(unrealizedPnl),
|
|
130309
|
+
f: totalFees == null ? null : roundPromptFixed(totalFees),
|
|
130310
|
+
n: pnlAfterFees == null ? null : roundPromptFixed(pnlAfterFees),
|
|
130311
|
+
...projectPositionPromptNormalization({
|
|
130312
|
+
entryValue: notionalValue,
|
|
130313
|
+
currentValue,
|
|
130314
|
+
unrealizedPnl,
|
|
130315
|
+
netPnl: pnlAfterFees,
|
|
130316
|
+
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol)
|
|
130317
|
+
}),
|
|
130318
|
+
...projectPositionPromptExcursions({
|
|
130319
|
+
projection: input.positionExcursions[normalizeHyperliquidMarketSymbol(position.symbol)],
|
|
130320
|
+
size,
|
|
130321
|
+
entryPrice,
|
|
130322
|
+
unrealizedPnl,
|
|
130323
|
+
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol),
|
|
130324
|
+
cutoffMs: input.cutoffMs
|
|
130325
|
+
})
|
|
130055
130326
|
};
|
|
130056
130327
|
});
|
|
130057
|
-
|
|
130058
|
-
|
|
130059
|
-
|
|
130060
|
-
|
|
130061
|
-
|
|
130062
|
-
|
|
130063
|
-
|
|
130064
|
-
|
|
130065
|
-
|
|
130066
|
-
|
|
130067
|
-
|
|
130068
|
-
|
|
130069
|
-
|
|
130070
|
-
|
|
130071
|
-
|
|
130072
|
-
|
|
130073
|
-
|
|
130074
|
-
|
|
130328
|
+
const remainingGlobal = Math.max(0, input.maxTradesGlobal - globalUnitsUsed);
|
|
130329
|
+
const parts = [
|
|
130330
|
+
"<positions>",
|
|
130331
|
+
stringifyPromptJson(promptPositions.map((position) => withoutHiddenFields(position, input.hiddenFields))),
|
|
130332
|
+
"</positions>",
|
|
130333
|
+
...activePositions.length === 0 ? ["", input.positionsInstructions.capacity_flat] : [],
|
|
130334
|
+
"",
|
|
130335
|
+
"--- Capacity & Limits --- ",
|
|
130336
|
+
`Global: ${globalUnitsUsed}/${input.maxTradesGlobal} exposure units used. (Additional capacity: ${remainingGlobal}) `
|
|
130337
|
+
];
|
|
130338
|
+
for (const venue of new Set(orderedSymbols.map(getHyperliquidMarketDex))) {
|
|
130339
|
+
const used = exchangeUsage.get(venue) ?? 0;
|
|
130340
|
+
const remaining = Math.max(0, input.maxTradesPerExchange - used);
|
|
130341
|
+
parts.push(`Exchange '${venue || "native"}': ${used}/${input.maxTradesPerExchange} exposure units used. (Additional capacity: ${remaining}) `);
|
|
130342
|
+
}
|
|
130343
|
+
for (const symbol2 of input.symbols) {
|
|
130344
|
+
const used = assetUsage.get(symbol2) ?? 0;
|
|
130345
|
+
const remaining = Math.max(0, input.maxTradesPerAsset - used);
|
|
130346
|
+
parts.push(`Asset '${symbol2}': ${used}/${input.maxTradesPerAsset} exposure units used. (Additional capacity: ${remaining}) `);
|
|
130347
|
+
}
|
|
130348
|
+
parts.push("");
|
|
130349
|
+
parts.push(...input.positionsInstructions.close_reduce.split("\n"));
|
|
130350
|
+
if (remainingGlobal <= 0) {
|
|
130351
|
+
parts.push(`${input.positionsInstructions.capacity_full} `);
|
|
130352
|
+
} else if (input.maxTradesPerPrompt < input.maxTradesGlobal && remainingGlobal < input.maxTradesPerPrompt) {
|
|
130353
|
+
parts.push(`${formatInstructionTemplate(input.positionsInstructions.capacity_low, {
|
|
130354
|
+
remaining: remainingGlobal
|
|
130355
|
+
}, "positions instruction template")} `);
|
|
130356
|
+
}
|
|
130357
|
+
return parts.join("\n");
|
|
130075
130358
|
};
|
|
130076
130359
|
}
|
|
130077
130360
|
});
|
|
@@ -130589,7 +130872,7 @@ __export(local_analysis_exports, {
|
|
|
130589
130872
|
toPositiveFinite: () => toPositiveFinite2,
|
|
130590
130873
|
unwrapRuntimeCycleSettledResult: () => unwrapRuntimeCycleSettledResult
|
|
130591
130874
|
});
|
|
130592
|
-
var cycleCandles, CYCLE_TIMEOUT_FLOOR_MS, DECISION_SETTLEMENT_RESERVE_MAX_BUDGET_DIVISOR, MIN_AGENT_INSTRUCTION_RETRY_AFTER_MS, PROMPT_PARITY_ERROR_DETAIL_MAX_CHARS, EXTERNAL_INFERENCE_RUNTIME_POLL_INTERVAL_MS, EXTERNAL_INFERENCE_RESULT_WAIT_MS, assertPromptModelController, resolveRuntimeReasoningControlsForModel, observeRuntimeCycle, observeAccountState, aiOrderSlippageFraction, buildServerBehaviorStateArtifacts, ClientRuntimeAgentInstructionEmpty, isClientRuntimeAgentInstructionEmpty, ClientRuntimeAiSchedulePaused, ClientRuntimeAiScheduleStillActive, isClientRuntimeAiScheduleStillActive, ServerDispatchAccountStateStale, isServerDispatchAccountStateStale, isClientRuntimeAiSchedulePaused, judgesPositionCaps, NO_POSITION_CAPS, POSITION_CAP_REFUSALS, judgeCyclePlans, capacityTrimOf, tradabilityExecutionBlock, accountSnapshotCapturedAt, buildClaimedAgentRuntimeCycleResult, resolveRuntimeMarginModePreference, resolveRuntimeLeveragePreference, resolveBooleanSetting, CLIENT_RUNTIME_LIVE_CONTEXT_UNAVAILABLE_ERRORS, BEHAVIOR_STATE_UNAVAILABLE_ERROR, CriticalBehaviorStateError, BEHAVIOR_MEMORY_UNAVAILABLE_ERROR, BehaviorMemoryUnavailableError, clampNumber, resolveExternalInferenceRuntimeTimeoutSeconds, toPositiveFinite2, EFFECTIVE_INPUT_MANIFEST_SCHEMA_VERSION, PROMPT_ASSEMBLY_DEFINITION_VERSION, RUNTIME_SOURCE_DEFINITION_VERSION, DECISION_INPUT_DEFINITION_VERSION, CONTEXT_ENVELOPE_DEFINITION_VERSION, CLIENT_RUNTIME_SOURCE_VERSION, CLIENT_MAIN_PROMPT_RENDERER, CLIENT_REVIEW_PROMPT_RENDERER, resolveEffectivePromptRuntimeProvenance, canonicalManifestValue, canonicalManifestJson, sha256ManifestHex, effectiveInputComponent, buildEffectiveInputManifest, MANIFEST_COMPONENT_NAME, derivePromptVisibleSections, decodeDecisionTracePayload, extractDecisionSymbolTrace, formatDecisionSymbolTrace, formatActionableDecisionSymbols, decisionRecordsBySymbol, SERVER_UNREADABLE_REPLY_HOLD_REASONING, buildMissingDecisionHold, buildDecisionPlansFromResponse, buildReviewCandidatePlansFromResponse, forceUnavailableSymbolsToHold, extractTemplatePlaceholders, requireReviewPrimaryUserPromptTemplate, containsCompetingBehaviorStateMarkup, containsCompetingMainBehaviorStateMarkup, requireStrategyReviewTemplates, preflightStrategyReviewPromptContract, extractRuntimeReasoningSelection, isAbortError, isRuntimeTimeoutAbortReason, createAbortError2, settleRuntimeCyclePromise, unwrapRuntimeCycleSettledResult, normalizeDecisionLabel, normalizeRuntimeSymbol, PromptContractFetchError, isLivePromptContextUnavailableError, buildFailClosedHoldResult, buildPromptConstructionFailureResult, buildLivePromptContextUnavailableFailureResult, pickFirstString, normalizeRuntimeStringList, requirePositiveRuntimeLimit, resolveRuntimeTradingScope, normalizeRuntimeProviderAlias, resolveCatalogModelEntry, createClientRuntimeProviderSetupError, createProviderSetupRejectionError, evaluateModelEligibility, extractReviewRuntimeReasoningSelection, isUsableRuntimeSettingsFallback, resolveRuntimeSettings, formatRuntimeDurationMs, normalizeRuntimeTimingNote, appendRuntimeTimingEvent, reportPromptParityTelemetry, resolveLocalRuntimeSecretRequirements, resolveLocalRuntimeSecretProvider, AI_INDICATOR_KEYS_NEWER_THAN_SOME_SERVERS, sortTradingTimeframes, normalizePromptIdentityTimestamp, resolveCompletedCandleBoundary, normalizeAiIndicatorFlags, getPromptLookback, resolvePromptRelativeVolumeContext, promptRelativeVolumeBaseline, CANDLE_CLOSE_TICKER_TIMEFRAME, candleCloseTicker, promptMarketAsOfTimestamp, deviceMarketReads, buildPromptCandlesPayload, formatUtcTimestampWithWeekday, formatUtcNowWithWeekday,
|
|
130875
|
+
var cycleCandles, CYCLE_TIMEOUT_FLOOR_MS, DECISION_SETTLEMENT_RESERVE_MAX_BUDGET_DIVISOR, MIN_AGENT_INSTRUCTION_RETRY_AFTER_MS, PROMPT_PARITY_ERROR_DETAIL_MAX_CHARS, EXTERNAL_INFERENCE_RUNTIME_POLL_INTERVAL_MS, EXTERNAL_INFERENCE_RESULT_WAIT_MS, assertPromptModelController, resolveRuntimeReasoningControlsForModel, observeRuntimeCycle, observeAccountState, aiOrderSlippageFraction, buildServerBehaviorStateArtifacts, ClientRuntimeAgentInstructionEmpty, isClientRuntimeAgentInstructionEmpty, ClientRuntimeAiSchedulePaused, ClientRuntimeAiScheduleStillActive, isClientRuntimeAiScheduleStillActive, ServerDispatchAccountStateStale, isServerDispatchAccountStateStale, isClientRuntimeAiSchedulePaused, judgesPositionCaps, NO_POSITION_CAPS, POSITION_CAP_REFUSALS, judgeCyclePlans, capacityTrimOf, tradabilityExecutionBlock, accountSnapshotCapturedAt, buildClaimedAgentRuntimeCycleResult, resolveRuntimeMarginModePreference, resolveRuntimeLeveragePreference, resolveBooleanSetting, CLIENT_RUNTIME_LIVE_CONTEXT_UNAVAILABLE_ERRORS, BEHAVIOR_STATE_UNAVAILABLE_ERROR, CriticalBehaviorStateError, BEHAVIOR_MEMORY_UNAVAILABLE_ERROR, BehaviorMemoryUnavailableError, clampNumber, resolveExternalInferenceRuntimeTimeoutSeconds, toPositiveFinite2, EFFECTIVE_INPUT_MANIFEST_SCHEMA_VERSION, PROMPT_ASSEMBLY_DEFINITION_VERSION, RUNTIME_SOURCE_DEFINITION_VERSION, DECISION_INPUT_DEFINITION_VERSION, CONTEXT_ENVELOPE_DEFINITION_VERSION, CLIENT_RUNTIME_SOURCE_VERSION, CLIENT_MAIN_PROMPT_RENDERER, CLIENT_REVIEW_PROMPT_RENDERER, resolveEffectivePromptRuntimeProvenance, canonicalManifestValue, canonicalManifestJson, sha256ManifestHex, effectiveInputComponent, buildEffectiveInputManifest, MANIFEST_COMPONENT_NAME, derivePromptVisibleSections, decodeDecisionTracePayload, extractDecisionSymbolTrace, formatDecisionSymbolTrace, formatActionableDecisionSymbols, decisionRecordsBySymbol, SERVER_UNREADABLE_REPLY_HOLD_REASONING, buildMissingDecisionHold, buildDecisionPlansFromResponse, buildReviewCandidatePlansFromResponse, forceUnavailableSymbolsToHold, extractTemplatePlaceholders, requireReviewPrimaryUserPromptTemplate, containsCompetingBehaviorStateMarkup, containsCompetingMainBehaviorStateMarkup, requireStrategyReviewTemplates, preflightStrategyReviewPromptContract, extractRuntimeReasoningSelection, isAbortError, isRuntimeTimeoutAbortReason, createAbortError2, settleRuntimeCyclePromise, unwrapRuntimeCycleSettledResult, normalizeDecisionLabel, normalizeRuntimeSymbol, PromptContractFetchError, isLivePromptContextUnavailableError, buildFailClosedHoldResult, buildPromptConstructionFailureResult, buildLivePromptContextUnavailableFailureResult, pickFirstString, normalizeRuntimeStringList, requirePositiveRuntimeLimit, resolveRuntimeTradingScope, normalizeRuntimeProviderAlias, resolveCatalogModelEntry, createClientRuntimeProviderSetupError, createProviderSetupRejectionError, evaluateModelEligibility, extractReviewRuntimeReasoningSelection, isUsableRuntimeSettingsFallback, resolveRuntimeSettings, formatRuntimeDurationMs, normalizeRuntimeTimingNote, appendRuntimeTimingEvent, reportPromptParityTelemetry, resolveLocalRuntimeSecretRequirements, resolveLocalRuntimeSecretProvider, AI_INDICATOR_KEYS_NEWER_THAN_SOME_SERVERS, sortTradingTimeframes, normalizePromptIdentityTimestamp, resolveCompletedCandleBoundary, normalizeAiIndicatorFlags, getPromptLookback, resolvePromptRelativeVolumeContext, promptRelativeVolumeBaseline, CANDLE_CLOSE_TICKER_TIMEFRAME, candleCloseTicker, promptMarketAsOfTimestamp, deviceMarketReads, buildPromptCandlesPayload, formatUtcTimestampWithWeekday, formatUtcNowWithWeekday, capacityUnitSize, sanitizePromptSymbol, fillTimeMs, fillSize, normalizeFillSide, normalizeFillOrderId, normalizeFillRiskOrderIdentity, fillStartPosition, fillSortValue, sortFillsAscending, sortFillsDescending, inferEntryFromStartPositionChain, inferEntryFromCurrentPositionSize, calculateCurrentPositionState, calculatePositionEntryTimes, countPositionAdds, latestPositionRiskIncreaseTimeMs, latestPositionRiskIncreaseEvidence, compactPromptRiskIncrease, roundPositiveDecimalHalfUp, compactPromptLastTrade, ENTRY_TRADE_FIELDS, PREVIOUS_DECISION_FIELDS, PREVIOUS_CAMPAIGN_FIELDS, hasExactKeys2, isNonnegativeInteger, isFiniteNumber, isExactEnumString, isNonemptyPromptText, isCampaignReasoningText, projectBackendDecisionMemoryItem, requireRenderedStrategyBehaviorState, canonicalFillSideForRiskEvidence, isValidRiskEvidenceFill, isValidCampaignBoundaryFill, normalizeFillHistoryCoverage, resolveFillHistoryCoverageForSymbol, buildPromptBehaviorStateArtifacts, buildReviewSystemPrompt, formatReviewUserPrompt, assemblePromptContextVars, buildPromptBehaviorStateValue, buildLocalRuntimePromptArtifacts2, createRuntimeId2, asRecord, buildRuntimeConstraintRejectionMessage, hasDeviceProviderSecret, requireNonEmptyStringField, requirePositiveIntegerField, compareContractVersion, parsePromptContractTimestamp, assertPromptContractCompatibility, assertPromptContractTemporalBounds, sleepWithAbort, requireAgentPollRetryAfterMs, materializeClaimedClientRuntimeAgentInstruction, attachClientRuntimeErrorProvenance, isExternalRuntimeProviderResult, invokeClientExternalInference, assertPromptContractBindingTupleEqual, assertPromptContractScopeMatch, fetchBoundPromptContracts, carryReturnedModelCalls, requireRuntimePositionsInstructions2, resolveRuntimePromptDerivedBlocks, requireRuntimePromptLane, requireRuntimeAccountMarginNote, runLocalRuntimeCycle;
|
|
130593
130876
|
var init_local_analysis = __esm({
|
|
130594
130877
|
"lib/runtime/local-analysis.ts"() {
|
|
130595
130878
|
"use strict";
|
|
@@ -130636,10 +130919,10 @@ var init_local_analysis = __esm({
|
|
|
130636
130919
|
init_prompt_contract();
|
|
130637
130920
|
init_behavior_memory_prompt_observability();
|
|
130638
130921
|
init_prompt_variable_validation_contract();
|
|
130639
|
-
init_position_prompt_contract();
|
|
130640
130922
|
init_prompt_json_contract();
|
|
130641
130923
|
init_prompt_collateral_contract();
|
|
130642
|
-
|
|
130924
|
+
init_prompt_positions_block();
|
|
130925
|
+
init_prompt_field_visibility();
|
|
130643
130926
|
init_local_ai();
|
|
130644
130927
|
init_reasoning_controls();
|
|
130645
130928
|
init_native_request_parameters();
|
|
@@ -130726,7 +131009,8 @@ var init_local_analysis = __esm({
|
|
|
130726
131009
|
cycleCutoffMs: inputs.now_ms ?? void 0,
|
|
130727
131010
|
nowMs: inputs.now_ms ?? options.nowMs,
|
|
130728
131011
|
fillHistoryCoverage: inputs.fill_history_coverage,
|
|
130729
|
-
positionStates: inputs.position_states
|
|
131012
|
+
positionStates: inputs.position_states,
|
|
131013
|
+
hiddenFields: options.hiddenFields
|
|
130730
131014
|
});
|
|
130731
131015
|
ClientRuntimeAgentInstructionEmpty = class extends Error {
|
|
130732
131016
|
constructor(retryAfterMs) {
|
|
@@ -131222,9 +131506,9 @@ var init_local_analysis = __esm({
|
|
|
131222
131506
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
131223
131507
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
131224
131508
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
131225
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
131226
|
-
"
|
|
131227
|
-
) ? "
|
|
131509
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "68890025dbd4546782da81b71404334ad74799f8".trim() && !["unknown", "unstamped", "development"].includes(
|
|
131510
|
+
"68890025dbd4546782da81b71404334ad74799f8".trim().toLowerCase()
|
|
131511
|
+
) ? "68890025dbd4546782da81b71404334ad74799f8".trim() : null;
|
|
131228
131512
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
131229
131513
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
131230
131514
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|
|
@@ -132293,16 +132577,6 @@ ${reviewOutputContract}`;
|
|
|
132293
132577
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds} UTC (${weekday})`;
|
|
132294
132578
|
};
|
|
132295
132579
|
formatUtcNowWithWeekday = () => formatUtcTimestampWithWeekday(Date.now());
|
|
132296
|
-
formatPromptPrice = (value) => {
|
|
132297
|
-
const numeric2 = Number(value);
|
|
132298
|
-
if (!Number.isFinite(numeric2) || numeric2 === 0) {
|
|
132299
|
-
return 0;
|
|
132300
|
-
}
|
|
132301
|
-
if (Math.abs(numeric2) >= PROMPT_PRICE_INTEGER_THRESHOLD) {
|
|
132302
|
-
return Number(Math.trunc(numeric2));
|
|
132303
|
-
}
|
|
132304
|
-
return roundPromptSignificant(numeric2, PROMPT_SIGNIFICANT_DIGITS);
|
|
132305
|
-
};
|
|
132306
132580
|
capacityUnitSize = (tradeSize, configuredTradeAmount) => {
|
|
132307
132581
|
if (Number.isFinite(tradeSize) && tradeSize > 0) return tradeSize;
|
|
132308
132582
|
const configured2 = Number(configuredTradeAmount);
|
|
@@ -132311,123 +132585,6 @@ ${reviewOutputContract}`;
|
|
|
132311
132585
|
}
|
|
132312
132586
|
return configured2;
|
|
132313
132587
|
};
|
|
132314
|
-
buildPromptAccountStatusValue = (accountSummary, marginNote, effectiveTakerRates, symbols) => [
|
|
132315
|
-
"<account_status>",
|
|
132316
|
-
stringifyPromptJson({
|
|
132317
|
-
pools: buildPromptCollateralPools(accountSummary.perp_dex_accounts, symbols),
|
|
132318
|
-
fees: buildPromptFeeMap(effectiveTakerRates, symbols)
|
|
132319
|
-
}),
|
|
132320
|
-
"</account_status>",
|
|
132321
|
-
"",
|
|
132322
|
-
marginNote
|
|
132323
|
-
].join("\n");
|
|
132324
|
-
buildPromptPositionsValue = (input) => {
|
|
132325
|
-
const validateInstructionTemplate = (template, allowedKeys) => {
|
|
132326
|
-
formatInstructionTemplate(
|
|
132327
|
-
template,
|
|
132328
|
-
Object.fromEntries(allowedKeys.map((key) => [key, ""])),
|
|
132329
|
-
"positions instruction template"
|
|
132330
|
-
);
|
|
132331
|
-
};
|
|
132332
|
-
validateInstructionTemplate(input.positionsInstructions.close_reduce, []);
|
|
132333
|
-
validateInstructionTemplate(input.positionsInstructions.capacity_flat, []);
|
|
132334
|
-
validateInstructionTemplate(input.positionsInstructions.capacity_full, []);
|
|
132335
|
-
validateInstructionTemplate(input.positionsInstructions.capacity_low, ["remaining"]);
|
|
132336
|
-
const activePositions = input.positions.filter((position) => Number(position.size) !== 0);
|
|
132337
|
-
const orderedSymbols = orderPromptSymbols(input.symbols, activePositions.map((position) => position.symbol));
|
|
132338
|
-
const symbolRanks = new Map(orderedSymbols.map((symbol2, index) => [symbol2, index]));
|
|
132339
|
-
activePositions.sort((left, right) => symbolRanks.get(normalizeHyperliquidMarketSymbol(left.symbol)) - symbolRanks.get(normalizeHyperliquidMarketSymbol(right.symbol)));
|
|
132340
|
-
const assetUsage = /* @__PURE__ */ new Map();
|
|
132341
|
-
const exchangeUsage = /* @__PURE__ */ new Map();
|
|
132342
|
-
let globalUnitsUsed = 0;
|
|
132343
|
-
const promptPositions = activePositions.map((position) => {
|
|
132344
|
-
const entryPrice = Number(position.entry_price);
|
|
132345
|
-
const size = Number(position.size);
|
|
132346
|
-
const unrealizedPnl = Number(position.unrealized_pnl);
|
|
132347
|
-
if (!Number.isFinite(entryPrice) || entryPrice <= 0 || !Number.isFinite(size) || size === 0) {
|
|
132348
|
-
throw new Error(`Active position identity/economics are invalid for ${position.symbol}`);
|
|
132349
|
-
}
|
|
132350
|
-
if (!Number.isFinite(unrealizedPnl)) {
|
|
132351
|
-
throw new Error(`Active position PnL is unavailable for ${position.symbol}`);
|
|
132352
|
-
}
|
|
132353
|
-
const notionalValue = Math.abs(size * entryPrice);
|
|
132354
|
-
const unitsUsed = capacityUnitsUsedForPosition(size, entryPrice, input.unitSize);
|
|
132355
|
-
globalUnitsUsed += unitsUsed;
|
|
132356
|
-
assetUsage.set(position.symbol, unitsUsed);
|
|
132357
|
-
const venue = getHyperliquidMarketDex(position.symbol);
|
|
132358
|
-
exchangeUsage.set(venue, (exchangeUsage.get(venue) ?? 0) + unitsUsed);
|
|
132359
|
-
const currentValue = Math.abs(size > 0 ? notionalValue + unrealizedPnl : notionalValue - unrealizedPnl);
|
|
132360
|
-
const takerRate = buildPromptFeeMap(input.effectiveTakerRates, [position.symbol])[normalizeHyperliquidMarketSymbol(position.symbol)];
|
|
132361
|
-
const totalFees = takerRate == null ? null : (notionalValue + currentValue) * takerRate;
|
|
132362
|
-
const pnlAfterFees = totalFees == null ? null : unrealizedPnl - totalFees;
|
|
132363
|
-
let breakeven = null;
|
|
132364
|
-
if (entryPrice > 0 && takerRate != null) {
|
|
132365
|
-
if (size > 0) {
|
|
132366
|
-
breakeven = entryPrice * (1 + takerRate) / (1 - takerRate);
|
|
132367
|
-
} else if (size < 0) {
|
|
132368
|
-
breakeven = entryPrice * (1 - takerRate) / (1 + takerRate);
|
|
132369
|
-
}
|
|
132370
|
-
}
|
|
132371
|
-
return {
|
|
132372
|
-
s: position.symbol,
|
|
132373
|
-
sd: size > 0 ? "LONG" : "SHORT",
|
|
132374
|
-
v: roundPromptFixed(notionalValue),
|
|
132375
|
-
cv: roundPromptFixed(currentValue),
|
|
132376
|
-
ep: entryPrice ? formatPromptPrice(entryPrice) : 0,
|
|
132377
|
-
be: breakeven == null ? null : formatPromptPrice(breakeven),
|
|
132378
|
-
liq: position.liquidation_price ? formatPromptPrice(position.liquidation_price) : "-",
|
|
132379
|
-
u: unitsUsed,
|
|
132380
|
-
up: roundPromptFixed(unrealizedPnl),
|
|
132381
|
-
f: totalFees == null ? null : roundPromptFixed(totalFees),
|
|
132382
|
-
n: pnlAfterFees == null ? null : roundPromptFixed(pnlAfterFees),
|
|
132383
|
-
...projectPositionPromptNormalization({
|
|
132384
|
-
entryValue: notionalValue,
|
|
132385
|
-
currentValue,
|
|
132386
|
-
unrealizedPnl,
|
|
132387
|
-
netPnl: pnlAfterFees,
|
|
132388
|
-
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol)
|
|
132389
|
-
}),
|
|
132390
|
-
...projectPositionPromptExcursions({
|
|
132391
|
-
projection: input.positionExcursions[normalizeHyperliquidMarketSymbol(position.symbol)],
|
|
132392
|
-
size,
|
|
132393
|
-
entryPrice,
|
|
132394
|
-
unrealizedPnl,
|
|
132395
|
-
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol),
|
|
132396
|
-
cutoffMs: input.cutoffMs
|
|
132397
|
-
})
|
|
132398
|
-
};
|
|
132399
|
-
});
|
|
132400
|
-
const remainingGlobal = Math.max(0, input.maxTradesGlobal - globalUnitsUsed);
|
|
132401
|
-
const parts = [
|
|
132402
|
-
"<positions>",
|
|
132403
|
-
stringifyPromptJson(promptPositions),
|
|
132404
|
-
"</positions>",
|
|
132405
|
-
...activePositions.length === 0 ? ["", input.positionsInstructions.capacity_flat] : [],
|
|
132406
|
-
"",
|
|
132407
|
-
"--- Capacity & Limits --- ",
|
|
132408
|
-
`Global: ${globalUnitsUsed}/${input.maxTradesGlobal} exposure units used. (Additional capacity: ${remainingGlobal}) `
|
|
132409
|
-
];
|
|
132410
|
-
for (const venue of new Set(orderedSymbols.map(getHyperliquidMarketDex))) {
|
|
132411
|
-
const used = exchangeUsage.get(venue) ?? 0;
|
|
132412
|
-
const remaining = Math.max(0, input.maxTradesPerExchange - used);
|
|
132413
|
-
parts.push(`Exchange '${venue || "native"}': ${used}/${input.maxTradesPerExchange} exposure units used. (Additional capacity: ${remaining}) `);
|
|
132414
|
-
}
|
|
132415
|
-
for (const symbol2 of input.symbols) {
|
|
132416
|
-
const used = assetUsage.get(symbol2) ?? 0;
|
|
132417
|
-
const remaining = Math.max(0, input.maxTradesPerAsset - used);
|
|
132418
|
-
parts.push(`Asset '${symbol2}': ${used}/${input.maxTradesPerAsset} exposure units used. (Additional capacity: ${remaining}) `);
|
|
132419
|
-
}
|
|
132420
|
-
parts.push("");
|
|
132421
|
-
parts.push(...input.positionsInstructions.close_reduce.split("\n"));
|
|
132422
|
-
if (remainingGlobal <= 0) {
|
|
132423
|
-
parts.push(`${input.positionsInstructions.capacity_full} `);
|
|
132424
|
-
} else if (input.maxTradesPerPrompt < input.maxTradesGlobal && remainingGlobal < input.maxTradesPerPrompt) {
|
|
132425
|
-
parts.push(`${formatInstructionTemplate(input.positionsInstructions.capacity_low, {
|
|
132426
|
-
remaining: remainingGlobal
|
|
132427
|
-
}, "positions instruction template")} `);
|
|
132428
|
-
}
|
|
132429
|
-
return parts.join("\n");
|
|
132430
|
-
};
|
|
132431
132588
|
sanitizePromptSymbol = (value) => String(value ?? "").replace(/<[^>]*>/g, "").slice(0, PROMPT_SYMBOL_MAX_CHARS);
|
|
132432
132589
|
fillTimeMs = (fill) => {
|
|
132433
132590
|
const value = Number(fill.time ?? fill.time_ms ?? 0);
|
|
@@ -133179,7 +133336,9 @@ ${reviewOutputContract}`;
|
|
|
133179
133336
|
return text2.startsWith("- ") ? text2 : `- ${text2}`;
|
|
133180
133337
|
};
|
|
133181
133338
|
const renderBehaviorData = (entries) => {
|
|
133182
|
-
const behaviorJson = stringifyPromptJson(
|
|
133339
|
+
const behaviorJson = stringifyPromptJson(Object.fromEntries(Object.entries(entries).map(
|
|
133340
|
+
([symbol2, entry]) => [symbol2, withoutHiddenFields(entry, input.hiddenFields ?? /* @__PURE__ */ new Set())]
|
|
133341
|
+
))).replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
133183
133342
|
const lines = [
|
|
133184
133343
|
`<behavior_state>
|
|
133185
133344
|
${behaviorJson}
|
|
@@ -133245,11 +133404,12 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
133245
133404
|
orderPromptSymbols(
|
|
133246
133405
|
parts.positions.symbols,
|
|
133247
133406
|
parts.positions.positions.filter((position) => Number(position.size) !== 0).map((position) => position.symbol)
|
|
133248
|
-
)
|
|
133407
|
+
),
|
|
133408
|
+
hiddenFieldsOf(parts.hiddenPromptFields, "account_status")
|
|
133249
133409
|
),
|
|
133250
133410
|
calendar: parts.calendar,
|
|
133251
133411
|
behavior_state: parts.behaviorState,
|
|
133252
|
-
positions: buildPromptPositionsValue(parts.positions),
|
|
133412
|
+
positions: buildPromptPositionsValue({ ...parts.positions, hiddenFields: hiddenFieldsOf(parts.hiddenPromptFields, "positions") }),
|
|
133253
133413
|
performance: String(parts.derivedValues.performance ?? ""),
|
|
133254
133414
|
market_regime: String(parts.derivedValues.market_regime ?? ""),
|
|
133255
133415
|
...Object.fromEntries(
|
|
@@ -133276,7 +133436,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
133276
133436
|
calendarSummary: String(input.contextVars.calendar ?? ""),
|
|
133277
133437
|
behaviorStateSummary: String(input.contextVars.behavior_state ?? ""),
|
|
133278
133438
|
referenceCandlesSummary: String(input.contextVars[REFERENCE_CANDLES_PROMPT_VARIABLE] ?? ""),
|
|
133279
|
-
referenceIndicatorFlags: input.referenceIndicators
|
|
133439
|
+
referenceIndicatorFlags: input.referenceIndicators,
|
|
133440
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
133280
133441
|
});
|
|
133281
133442
|
const templateContextVars = Object.fromEntries(
|
|
133282
133443
|
Object.entries(input.contextVars).filter(([key]) => activePlaceholders.has(key))
|
|
@@ -134283,6 +134444,7 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134283
134444
|
} = resolveRuntimeTradingScope(settings, config2);
|
|
134284
134445
|
const sortedTimeframes = sortTradingTimeframes(timeframes);
|
|
134285
134446
|
const activeIndicators = normalizeAiIndicatorFlags(config2.default_ai_indicators, settings.ai_indicators);
|
|
134447
|
+
const hiddenPromptFields = resolveHiddenPromptFields(config2.default_hidden_prompt_fields, settings.hidden_prompt_fields);
|
|
134286
134448
|
const lookbackSettings = settings.analysis_lookback;
|
|
134287
134449
|
const effectiveDefaultLookbacks = config2.default_analysis_lookback_fallbacks;
|
|
134288
134450
|
const indicatorCandleCount = Number(config2.indicator_candle_count);
|
|
@@ -134662,7 +134824,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134662
134824
|
inputs: requireDerivedPromptInputs(asRecord(promptDerivedContext.derived_context)),
|
|
134663
134825
|
placeholders: extractTemplatePlaceholders(String(promptMetadata.user_template ?? "")),
|
|
134664
134826
|
loopIntervalSeconds: Number(asRecord(promptMetadata.prompt_knobs).loop_interval_seconds),
|
|
134665
|
-
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount })
|
|
134827
|
+
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount }),
|
|
134828
|
+
hiddenPromptFields
|
|
134666
134829
|
});
|
|
134667
134830
|
} catch (error48) {
|
|
134668
134831
|
if (input.mode === "trader" && error48 instanceof DerivedPromptContextUnavailableError) {
|
|
@@ -134964,7 +135127,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134964
135127
|
promptSymbols,
|
|
134965
135128
|
promptTimeframes,
|
|
134966
135129
|
behaviorMemoryEnabled,
|
|
134967
|
-
cutoffMs: behaviorMemoryCutoffMs
|
|
135130
|
+
cutoffMs: behaviorMemoryCutoffMs,
|
|
135131
|
+
hiddenPromptFields
|
|
134968
135132
|
});
|
|
134969
135133
|
} catch (error48) {
|
|
134970
135134
|
throw new BehaviorMemoryUnavailableError(error48);
|
|
@@ -134987,7 +135151,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134987
135151
|
knobs: { maxTradesGlobal, maxTradesPerExchange, maxTradesPerAsset, maxTradesPerPrompt, tradeSize: metadataTradeSize },
|
|
134988
135152
|
positionsInstructions,
|
|
134989
135153
|
size: metadataTradeSize,
|
|
134990
|
-
leverage: metadataLeverage
|
|
135154
|
+
leverage: metadataLeverage,
|
|
135155
|
+
hiddenPromptFields
|
|
134991
135156
|
}));
|
|
134992
135157
|
} catch (error48) {
|
|
134993
135158
|
const detail = error48 instanceof Error ? error48.message : String(error48);
|
|
@@ -135108,7 +135273,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
135108
135273
|
promptSymbols,
|
|
135109
135274
|
maxTradesPerPrompt,
|
|
135110
135275
|
metricsWindowHours,
|
|
135111
|
-
metricsSecondaryWindowHours
|
|
135276
|
+
metricsSecondaryWindowHours,
|
|
135277
|
+
hiddenPromptFields
|
|
135112
135278
|
}),
|
|
135113
135279
|
contextVars: renderContextVars
|
|
135114
135280
|
})
|
|
@@ -136267,7 +136433,7 @@ ${indentText.repeat(depth)}${brackets[1]}`;
|
|
|
136267
136433
|
});
|
|
136268
136434
|
|
|
136269
136435
|
// lib/runtime/copy-review-prompt.ts
|
|
136270
|
-
var COPY_REVIEW_PRIMARY_MODEL, COPY_TRADE_PROPOSAL, COPY_POSITION_REPAIR, metadataOf, copyReviewIsGapRepair,
|
|
136436
|
+
var COPY_REVIEW_DECISIONS, COPY_REVIEW_INTENTS, COPY_REVIEW_PRIMARY_MODEL, COPY_TRADE_PROPOSAL, COPY_POSITION_REPAIR, metadataOf, copyReviewIsGapRepair, isOneOf, copyReviewSentProposal, copyReviewObserved, copyReviewProposedTrade, text, gapRepairTemplates, copyReviewPromptContext, copyReviewPrimaryReasoning, copyReviewPromptSymbols, copyReviewPromptSize, promptJsonValue, renderCopyReviewPrompts;
|
|
136271
136437
|
var init_copy_review_prompt = __esm({
|
|
136272
136438
|
"lib/runtime/copy-review-prompt.ts"() {
|
|
136273
136439
|
"use strict";
|
|
@@ -136284,40 +136450,24 @@ var init_copy_review_prompt = __esm({
|
|
|
136284
136450
|
init_local_analysis();
|
|
136285
136451
|
init_python_json();
|
|
136286
136452
|
init_runtime_error_reason_rules();
|
|
136453
|
+
COPY_REVIEW_DECISIONS = ["BUY", "SELL", "HOLD"];
|
|
136454
|
+
COPY_REVIEW_INTENTS = ["open", "add", "reduce", "close", "flip", "unknown"];
|
|
136287
136455
|
COPY_REVIEW_PRIMARY_MODEL = "Copy Trading";
|
|
136288
136456
|
COPY_TRADE_PROPOSAL = "copy_trade_proposal";
|
|
136289
136457
|
COPY_POSITION_REPAIR = "copy_position_repair";
|
|
136290
136458
|
metadataOf = (event) => event.sanitized_metadata && typeof event.sanitized_metadata === "object" && !Array.isArray(event.sanitized_metadata) ? event.sanitized_metadata : {};
|
|
136291
136459
|
copyReviewIsGapRepair = (event) => metadataOf(event).source_fill_gap_reconciliation === true;
|
|
136292
|
-
|
|
136293
|
-
|
|
136294
|
-
|
|
136295
|
-
|
|
136296
|
-
|
|
136297
|
-
|
|
136298
|
-
|
|
136299
|
-
|
|
136300
|
-
|
|
136301
|
-
|
|
136302
|
-
|
|
136303
|
-
if (Math.abs(next) > Math.abs(previous)) return "add";
|
|
136304
|
-
return "reduce";
|
|
136305
|
-
};
|
|
136306
|
-
pythonFloatOf = (value) => {
|
|
136307
|
-
if (typeof value === "boolean") return value ? 1 : 0;
|
|
136308
|
-
if (typeof value === "number") return value;
|
|
136309
|
-
if (typeof value !== "string" || !value.trim()) return null;
|
|
136310
|
-
const parsed = Number(value.trim());
|
|
136311
|
-
return Number.isNaN(parsed) ? null : parsed;
|
|
136312
|
-
};
|
|
136313
|
-
copyReviewDestinationIntent = (event) => {
|
|
136314
|
-
const reconciliation = metadataOf(event).position_reconciliation;
|
|
136315
|
-
if (!reconciliation || typeof reconciliation !== "object" || Array.isArray(reconciliation)) return "unknown";
|
|
136316
|
-
const previous = pythonFloatOf(reconciliation.destination_position_before);
|
|
136317
|
-
const size = event.destination_size || 0;
|
|
136318
|
-
if (previous === null) return "unknown";
|
|
136319
|
-
const delta = String(event.destination_side || "").trim().toLowerCase() === "buy" ? size : -size;
|
|
136320
|
-
return inferIntentFromPositionDelta(previous, previous + delta);
|
|
136460
|
+
isOneOf = (values, value) => values.includes(value);
|
|
136461
|
+
copyReviewSentProposal = (event) => {
|
|
136462
|
+
const decision = event.proposed_decision;
|
|
136463
|
+
const intent = event.destination_intent;
|
|
136464
|
+
if (!isOneOf(COPY_REVIEW_DECISIONS, decision) || !isOneOf(COPY_REVIEW_INTENTS, intent)) {
|
|
136465
|
+
throw new RuntimeReasonError(
|
|
136466
|
+
"Missing copy review proposal: the server sent this copy without its proposed_decision and destination_intent.",
|
|
136467
|
+
"runtime_config_missing"
|
|
136468
|
+
);
|
|
136469
|
+
}
|
|
136470
|
+
return { decision, intent };
|
|
136321
136471
|
};
|
|
136322
136472
|
copyReviewObserved = (event) => copyReviewIsGapRepair(event) ? {
|
|
136323
136473
|
source_position: {
|
|
@@ -136336,32 +136486,35 @@ var init_copy_review_prompt = __esm({
|
|
|
136336
136486
|
fingerprint: event.source_event_fingerprint
|
|
136337
136487
|
}
|
|
136338
136488
|
};
|
|
136339
|
-
copyReviewProposedTrade = (event, source) =>
|
|
136340
|
-
|
|
136341
|
-
|
|
136342
|
-
type:
|
|
136343
|
-
|
|
136344
|
-
|
|
136345
|
-
|
|
136346
|
-
|
|
136347
|
-
|
|
136348
|
-
|
|
136349
|
-
|
|
136350
|
-
|
|
136351
|
-
|
|
136352
|
-
|
|
136353
|
-
|
|
136354
|
-
|
|
136355
|
-
|
|
136356
|
-
|
|
136357
|
-
|
|
136358
|
-
|
|
136359
|
-
|
|
136360
|
-
|
|
136361
|
-
|
|
136362
|
-
|
|
136363
|
-
|
|
136364
|
-
|
|
136489
|
+
copyReviewProposedTrade = (event, source) => {
|
|
136490
|
+
const proposal = copyReviewSentProposal(event);
|
|
136491
|
+
return {
|
|
136492
|
+
type: copyReviewIsGapRepair(event) ? COPY_POSITION_REPAIR : COPY_TRADE_PROPOSAL,
|
|
136493
|
+
source: {
|
|
136494
|
+
type: source.source_type,
|
|
136495
|
+
identifier: source.source_identifier,
|
|
136496
|
+
display_name: source.source_display_name,
|
|
136497
|
+
wallet_address: source.source_wallet_address
|
|
136498
|
+
},
|
|
136499
|
+
symbol: event.symbol,
|
|
136500
|
+
decision: proposal.decision,
|
|
136501
|
+
...copyReviewObserved(event),
|
|
136502
|
+
destination_order: {
|
|
136503
|
+
side: event.destination_side,
|
|
136504
|
+
size: pythonFloat(event.destination_size),
|
|
136505
|
+
notional: pythonFloat(event.destination_notional),
|
|
136506
|
+
reduce_only: Boolean(event.reduce_only),
|
|
136507
|
+
runtime_mode: event.runtime_mode,
|
|
136508
|
+
idempotency_key: event.idempotency_key
|
|
136509
|
+
},
|
|
136510
|
+
copy_intent: {
|
|
136511
|
+
source_intent: event.inferred_intent,
|
|
136512
|
+
destination_intent: proposal.intent,
|
|
136513
|
+
scaling_mode: event.scaling_mode,
|
|
136514
|
+
scale_factor: pythonFloat(event.scale_factor)
|
|
136515
|
+
}
|
|
136516
|
+
};
|
|
136517
|
+
};
|
|
136365
136518
|
text = (value) => ({ kind: "str", value });
|
|
136366
136519
|
gapRepairTemplates = (templates) => {
|
|
136367
136520
|
if (!templates.gap_repair) {
|
|
@@ -136400,7 +136553,7 @@ var init_copy_review_prompt = __esm({
|
|
|
136400
136553
|
return value;
|
|
136401
136554
|
};
|
|
136402
136555
|
renderCopyReviewPrompts = (input) => {
|
|
136403
|
-
const proposedDecision =
|
|
136556
|
+
const proposedDecision = copyReviewSentProposal(input.event).decision;
|
|
136404
136557
|
const proposedTrade = copyReviewProposedTrade(input.event, input.source);
|
|
136405
136558
|
const { context, ...primary } = input.primary;
|
|
136406
136559
|
const main = buildLocalRuntimePromptArtifacts2({ ...primary, contextVars: assemblePromptContextVars(context) });
|
|
@@ -136445,7 +136598,6 @@ ${copyReviewPromptContext(proposedTrade, input.templates)}`;
|
|
|
136445
136598
|
primaryDecisionJson
|
|
136446
136599
|
});
|
|
136447
136600
|
return {
|
|
136448
|
-
proposedDecision,
|
|
136449
136601
|
primaryDecision,
|
|
136450
136602
|
primarySystemPrompt,
|
|
136451
136603
|
primaryUserPrompt,
|
|
@@ -136470,6 +136622,7 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136470
136622
|
init_client_account_report();
|
|
136471
136623
|
init_copy_review_prompt();
|
|
136472
136624
|
init_render();
|
|
136625
|
+
init_prompt_field_visibility();
|
|
136473
136626
|
init_local_analysis();
|
|
136474
136627
|
init_runtime_error_reason_rules();
|
|
136475
136628
|
init_runtime_prompt_steps();
|
|
@@ -136541,6 +136694,7 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136541
136694
|
const { config: config2, contract: derived, marketData, fills, accountState } = input;
|
|
136542
136695
|
const { settings, symbols, sortedTimeframes, indicatorCandleCount } = input.scope;
|
|
136543
136696
|
const activeIndicators = normalizeAiIndicatorFlags(config2.default_ai_indicators, settings.ai_indicators);
|
|
136697
|
+
const hiddenPromptFields = resolveHiddenPromptFields(config2.default_hidden_prompt_fields, settings.hidden_prompt_fields);
|
|
136544
136698
|
const accountSummary = copyReviewAccountSummary(accountState);
|
|
136545
136699
|
const promptMetadata = requireCopyReviewContractReady(derived);
|
|
136546
136700
|
const tickersBySymbol = Object.fromEntries(marketData.map((entry) => [entry.symbol, entry.ticker]));
|
|
@@ -136550,7 +136704,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136550
136704
|
inputs: requireDerivedPromptInputs(derivedContext),
|
|
136551
136705
|
placeholders: extractTemplatePlaceholders(String(promptMetadata.user_template ?? "")),
|
|
136552
136706
|
loopIntervalSeconds: Number(asRecord(promptMetadata.prompt_knobs).loop_interval_seconds),
|
|
136553
|
-
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount })
|
|
136707
|
+
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount }),
|
|
136708
|
+
hiddenPromptFields
|
|
136554
136709
|
});
|
|
136555
136710
|
const promptKnobs = asRecord(promptMetadata.prompt_knobs);
|
|
136556
136711
|
const promptInstructions = asRecord(promptMetadata.prompt_instructions);
|
|
@@ -136589,7 +136744,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136589
136744
|
promptSymbols: knobs.promptSymbols,
|
|
136590
136745
|
promptTimeframes: knobs.promptTimeframes,
|
|
136591
136746
|
behaviorMemoryEnabled,
|
|
136592
|
-
cutoffMs
|
|
136747
|
+
cutoffMs,
|
|
136748
|
+
hiddenPromptFields
|
|
136593
136749
|
}).rendered;
|
|
136594
136750
|
const context = buildRuntimePromptContextParts({
|
|
136595
136751
|
config: config2,
|
|
@@ -136607,7 +136763,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136607
136763
|
knobs,
|
|
136608
136764
|
positionsInstructions,
|
|
136609
136765
|
size: input.promptSize(copyReviewSizes),
|
|
136610
|
-
leverage: knobs.leverage
|
|
136766
|
+
leverage: knobs.leverage,
|
|
136767
|
+
hiddenPromptFields
|
|
136611
136768
|
});
|
|
136612
136769
|
const reviewInstructions = asRecord(promptMetadata.review_instructions);
|
|
136613
136770
|
return {
|
|
@@ -136621,7 +136778,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136621
136778
|
promptSymbols: knobs.promptSymbols,
|
|
136622
136779
|
maxTradesPerPrompt: knobs.maxTradesPerPrompt,
|
|
136623
136780
|
metricsWindowHours: knobs.metricsWindowHours,
|
|
136624
|
-
metricsSecondaryWindowHours: knobs.metricsSecondaryWindowHours
|
|
136781
|
+
metricsSecondaryWindowHours: knobs.metricsSecondaryWindowHours,
|
|
136782
|
+
hiddenPromptFields
|
|
136625
136783
|
}),
|
|
136626
136784
|
context
|
|
136627
136785
|
},
|
|
@@ -136768,6 +136926,7 @@ var init_copy_review_runtime = __esm({
|
|
|
136768
136926
|
});
|
|
136769
136927
|
};
|
|
136770
136928
|
renderRuntimeCopyReview = async (input) => {
|
|
136929
|
+
copyReviewSentProposal(input.event);
|
|
136771
136930
|
const prepared = await prepareRuntimeCopyReviewPrimary({
|
|
136772
136931
|
profileId: input.profileId,
|
|
136773
136932
|
payload: input.payload,
|
|
@@ -138809,7 +138968,7 @@ var init_client_killswitch = __esm({
|
|
|
138809
138968
|
});
|
|
138810
138969
|
|
|
138811
138970
|
// lib/runtime/portfolio-evidence.ts
|
|
138812
|
-
var PORTFOLIO_RETRY_MS, PORTFOLIO_READ_PRIORITY, PortfolioBodyError, portfolioRequestBody,
|
|
138971
|
+
var PORTFOLIO_RETRY_MS, PORTFOLIO_READ_PRIORITY, PortfolioBodyError, portfolioRequestBody, isRecord9, checkPortfolioBody, runningProfiles2, portfolioBackoffUntil, errorCode2, runClientPortfolioReport;
|
|
138813
138972
|
var init_portfolio_evidence = __esm({
|
|
138814
138973
|
"lib/runtime/portfolio-evidence.ts"() {
|
|
138815
138974
|
"use strict";
|
|
@@ -138831,7 +138990,7 @@ var init_portfolio_evidence = __esm({
|
|
|
138831
138990
|
}
|
|
138832
138991
|
};
|
|
138833
138992
|
portfolioRequestBody = (walletAddress) => ({ type: "portfolio", user: walletAddress });
|
|
138834
|
-
|
|
138993
|
+
isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
138835
138994
|
checkPortfolioBody = (body) => {
|
|
138836
138995
|
if (typeof body !== "string") throw new PortfolioBodyError("The portfolio body must be the raw response text.");
|
|
138837
138996
|
let parsed;
|
|
@@ -138841,7 +139000,7 @@ var init_portfolio_evidence = __esm({
|
|
|
138841
139000
|
throw new PortfolioBodyError("The portfolio response is not JSON.");
|
|
138842
139001
|
}
|
|
138843
139002
|
const periods = Array.isArray(parsed) ? parsed : [];
|
|
138844
|
-
const valid = periods.some((item) => Array.isArray(item) && item.length === RUNTIME_PORTFOLIO_PERIOD_ENTRY_LENGTH && typeof item[0] === "string" &&
|
|
139003
|
+
const valid = periods.some((item) => Array.isArray(item) && item.length === RUNTIME_PORTFOLIO_PERIOD_ENTRY_LENGTH && typeof item[0] === "string" && isRecord9(item[1]) && Array.isArray(item[1].accountValueHistory) && Array.isArray(item[1].pnlHistory));
|
|
138845
139004
|
if (!valid) throw new PortfolioBodyError("The portfolio response has no period histories.");
|
|
138846
139005
|
};
|
|
138847
139006
|
runningProfiles2 = /* @__PURE__ */ new Set();
|