@vtxmacro/cli 2026.10.69 → 2026.10.71
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 +506 -338
- 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.71", 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: {
|
|
@@ -1643,7 +1644,7 @@ var init_runtime_policy_generated = __esm({
|
|
|
1643
1644
|
});
|
|
1644
1645
|
|
|
1645
1646
|
// lib/shared-contracts.generated.ts
|
|
1646
|
-
var CANDLE_TIMEFRAME_SECONDS, AI_SNAPSHOT_WIRE_FORMAT, EXTERNAL_INFERENCE_LIMITS, EXTERNAL_INFERENCE_SCHEMA_BOUNDS, BYOK_PROVIDER_REGISTRY, PROVIDER_NAMES, LEGACY_PROVIDER_LABEL_PREFIXES, CLIENT_RUNTIME_SECRET_RATE_LIMIT, HYPERLIQUID_EXCHANGE_SPECIFICATION, HYPERLIQUID_ROW_WEIGHTED_INFO_CHARGE, HYPERLIQUID_CANDLE_SNAPSHOT_CHARGE, ERROR_REDACTION_RULES, RUNTIME_ERROR_WORDING, PROVIDER_OUT_OF_CREDIT;
|
|
1647
|
+
var CANDLE_TIMEFRAME_SECONDS, AI_SNAPSHOT_WIRE_FORMAT, EXTERNAL_INFERENCE_LIMITS, EXTERNAL_INFERENCE_SCHEMA_BOUNDS, BYOK_PROVIDER_REGISTRY, PROVIDER_NAMES, LEGACY_PROVIDER_LABEL_PREFIXES, CLIENT_RUNTIME_SECRET_RATE_LIMIT, HYPERLIQUID_EXCHANGE_SPECIFICATION, HYPERLIQUID_ROW_WEIGHTED_INFO_CHARGE, HYPERLIQUID_CANDLE_SNAPSHOT_CHARGE, ERROR_REDACTION_RULES, RATE_LIMIT_TEXT_RULES, RUNTIME_ERROR_WORDING, PROVIDER_OUT_OF_CREDIT;
|
|
1647
1648
|
var init_shared_contracts_generated = __esm({
|
|
1648
1649
|
"lib/shared-contracts.generated.ts"() {
|
|
1649
1650
|
"use strict";
|
|
@@ -2253,6 +2254,13 @@ var init_shared_contracts_generated = __esm({
|
|
|
2253
2254
|
}
|
|
2254
2255
|
]
|
|
2255
2256
|
};
|
|
2257
|
+
RATE_LIMIT_TEXT_RULES = {
|
|
2258
|
+
"wordings": [
|
|
2259
|
+
"rate[ \\t\\n\\r\\f\\v]*limit",
|
|
2260
|
+
"cooling[ \\t\\n\\r\\f\\v]*down"
|
|
2261
|
+
],
|
|
2262
|
+
"status_429": "(?:^|[^\\w.]|[^\\d.]\\.)429(?![\\w]|\\.\\d)"
|
|
2263
|
+
};
|
|
2256
2264
|
RUNTIME_ERROR_WORDING = {
|
|
2257
2265
|
"pause_prefix": {
|
|
2258
2266
|
"trader": "\u26A0\uFE0F **AI Trader Paused**",
|
|
@@ -3233,7 +3241,7 @@ var init_shared_contracts_generated = __esm({
|
|
|
3233
3241
|
});
|
|
3234
3242
|
|
|
3235
3243
|
// 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,
|
|
3244
|
+
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
3245
|
var init_constants = __esm({
|
|
3238
3246
|
"lib/constants.ts"() {
|
|
3239
3247
|
"use strict";
|
|
@@ -3282,7 +3290,6 @@ var init_constants = __esm({
|
|
|
3282
3290
|
INT32_MIN = -(2 ** 31);
|
|
3283
3291
|
INT32_MAX = 2 ** 31 - 1;
|
|
3284
3292
|
SET_TIMEOUT_MAX_DELAY_MS = INT32_MAX;
|
|
3285
|
-
FLOAT_EQUALITY_EPSILON = 1e-12;
|
|
3286
3293
|
POSITION_SIZE_EPSILON = 1e-5;
|
|
3287
3294
|
HYPERLIQUID_WEBSOCKET_MAX_USERS_PER_IP = 10;
|
|
3288
3295
|
HTTP_STATUS = {
|
|
@@ -22839,7 +22846,8 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
22839
22846
|
base_delay_milliseconds: 300,
|
|
22840
22847
|
max_delay_milliseconds: 8e3,
|
|
22841
22848
|
min_retry_after_milliseconds: 250,
|
|
22842
|
-
deadline_attempt_spacing_milliseconds: 250
|
|
22849
|
+
deadline_attempt_spacing_milliseconds: 250,
|
|
22850
|
+
market_data_max_attempts: 2
|
|
22843
22851
|
}
|
|
22844
22852
|
},
|
|
22845
22853
|
server_runtime: {
|
|
@@ -60005,6 +60013,29 @@ var init_runtime_error_wording = __esm({
|
|
|
60005
60013
|
}
|
|
60006
60014
|
});
|
|
60007
60015
|
|
|
60016
|
+
// lib/rate-limit-text.ts
|
|
60017
|
+
var RATE_LIMIT_TEXT, COOLDOWN_SECONDS, RETRY_IN_SECONDS, APP_RATE_LIMIT_WORDING, isRateLimitErrorText, rateLimitMessage;
|
|
60018
|
+
var init_rate_limit_text = __esm({
|
|
60019
|
+
"lib/rate-limit-text.ts"() {
|
|
60020
|
+
"use strict";
|
|
60021
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
60022
|
+
init_define_VTX_EXO_POLICY();
|
|
60023
|
+
init_define_VTX_GROK_POLICY();
|
|
60024
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
60025
|
+
init_shared_contracts_generated();
|
|
60026
|
+
RATE_LIMIT_TEXT = new RegExp([...RATE_LIMIT_TEXT_RULES.wordings, RATE_LIMIT_TEXT_RULES.status_429].join("|"), "i");
|
|
60027
|
+
COOLDOWN_SECONDS = /cooling\s*down\s*for\s*([0-9]+(?:\.[0-9]+)?)s/i;
|
|
60028
|
+
RETRY_IN_SECONDS = /retry\s*in\s*~?\s*([0-9]+(?:\.[0-9]+)?)s/i;
|
|
60029
|
+
APP_RATE_LIMIT_WORDING = "Hyperliquid is rate-limited.";
|
|
60030
|
+
isRateLimitErrorText = (text2) => RATE_LIMIT_TEXT.test(String(text2 || ""));
|
|
60031
|
+
rateLimitMessage = (raw) => {
|
|
60032
|
+
const text2 = String(raw || "");
|
|
60033
|
+
const match = text2.match(COOLDOWN_SECONDS) ?? text2.match(RETRY_IN_SECONDS);
|
|
60034
|
+
return match ? `${APP_RATE_LIMIT_WORDING} Please retry in ~${match[1]}s.` : `${APP_RATE_LIMIT_WORDING} Please wait a moment and retry.`;
|
|
60035
|
+
};
|
|
60036
|
+
}
|
|
60037
|
+
});
|
|
60038
|
+
|
|
60008
60039
|
// lib/api/shared.ts
|
|
60009
60040
|
function configureApiTransport(transport) {
|
|
60010
60041
|
if (transport === null) {
|
|
@@ -60032,7 +60063,7 @@ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
|
60032
60063
|
if (profileId) headers["x-profile-id"] = profileId.toString();
|
|
60033
60064
|
return headers;
|
|
60034
60065
|
}
|
|
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;
|
|
60066
|
+
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
60067
|
var init_shared = __esm({
|
|
60037
60068
|
"lib/api/shared.ts"() {
|
|
60038
60069
|
"use strict";
|
|
@@ -60048,6 +60079,7 @@ var init_shared = __esm({
|
|
|
60048
60079
|
init_abort();
|
|
60049
60080
|
init_runtime_redaction();
|
|
60050
60081
|
init_runtime_error_wording();
|
|
60082
|
+
init_rate_limit_text();
|
|
60051
60083
|
configuredApiTransport = null;
|
|
60052
60084
|
getApiUrl = () => {
|
|
60053
60085
|
if (configuredApiTransport) return configuredApiTransport.baseUrl;
|
|
@@ -60201,6 +60233,14 @@ var init_shared = __esm({
|
|
|
60201
60233
|
if (Number.isFinite(retryAtMs)) return Math.max(0, retryAtMs - Date.now());
|
|
60202
60234
|
return null;
|
|
60203
60235
|
};
|
|
60236
|
+
resolveClientRuntimeRetryDelayMs = (attempt2, retryAfterHeader) => {
|
|
60237
|
+
const policy3 = runtime_policy_generated_default2.trading.engine.client_runtime.request_retry;
|
|
60238
|
+
const retryAfterMs = parseRetryAfterMs2(retryAfterHeader);
|
|
60239
|
+
if (retryAfterMs != null) {
|
|
60240
|
+
return Math.min(policy3.max_delay_milliseconds, Math.max(policy3.min_retry_after_milliseconds, retryAfterMs));
|
|
60241
|
+
}
|
|
60242
|
+
return Math.min(policy3.max_delay_milliseconds, policy3.base_delay_milliseconds * BACKOFF_GROWTH_FACTOR ** (attempt2 - 1));
|
|
60243
|
+
};
|
|
60204
60244
|
resolveAuthBootstrapRetryDelayMs = (response, attempt2) => {
|
|
60205
60245
|
const retryAfterMs = parseRetryAfterMs2(response.headers.get("Retry-After"));
|
|
60206
60246
|
const baseDelayMs = retryAfterMs ?? runtime_policy_generated_default2.ui.auth_bootstrap_retry.base_delay_milliseconds * BACKOFF_GROWTH_FACTOR ** (attempt2 - 1);
|
|
@@ -60224,8 +60264,26 @@ var init_shared = __esm({
|
|
|
60224
60264
|
runtimeRequestMaxAttempts: 1,
|
|
60225
60265
|
runtimeRequestStatus: status,
|
|
60226
60266
|
runtimeRequestErrorKind: kind,
|
|
60227
|
-
runtimeRequestTransientNetwork: kind === "network" && isTransientNetworkFetchError(error48)
|
|
60267
|
+
runtimeRequestTransientNetwork: kind === "network" && isTransientNetworkFetchError(error48) || kind === "response_body" && isTransientNetworkFetchError(error48.cause)
|
|
60228
60268
|
});
|
|
60269
|
+
readMarketDataWithRetry = async (signal, read) => {
|
|
60270
|
+
const maxAttempts = runtime_policy_generated_default2.trading.engine.client_runtime.request_retry.market_data_max_attempts;
|
|
60271
|
+
for (let attempt2 = 1; ; attempt2 += 1) {
|
|
60272
|
+
try {
|
|
60273
|
+
return await read();
|
|
60274
|
+
} catch (error48) {
|
|
60275
|
+
const transient = error48?.runtimeRequestTransientNetwork === true;
|
|
60276
|
+
if (transient && attempt2 < maxAttempts) {
|
|
60277
|
+
await abortableSleep(resolveClientRuntimeRetryDelayMs(attempt2, null), signal);
|
|
60278
|
+
continue;
|
|
60279
|
+
}
|
|
60280
|
+
if (error48 instanceof Error && "runtimeRequestPath" in error48) {
|
|
60281
|
+
Object.assign(error48, { runtimeRequestAttempt: attempt2, runtimeRequestMaxAttempts: maxAttempts });
|
|
60282
|
+
}
|
|
60283
|
+
throw error48;
|
|
60284
|
+
}
|
|
60285
|
+
}
|
|
60286
|
+
};
|
|
60229
60287
|
buildMarketDataFetchError = async (response, label2, path) => {
|
|
60230
60288
|
let responseText = "";
|
|
60231
60289
|
try {
|
|
@@ -60280,11 +60338,7 @@ var init_shared = __esm({
|
|
|
60280
60338
|
};
|
|
60281
60339
|
getErrorMessage = (error48, defaultMessage) => {
|
|
60282
60340
|
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
|
-
};
|
|
60341
|
+
const extractRateLimitMessage = (raw) => isRateLimitErrorText(raw) ? rateLimitMessage(raw) : null;
|
|
60288
60342
|
if (isTransientNetworkFetchError(error48 instanceof Error ? error48 : error48?.message)) {
|
|
60289
60343
|
return "Network error. Please check your connection.";
|
|
60290
60344
|
}
|
|
@@ -61879,7 +61933,7 @@ async function getRecentCandlesForProfile(profileId, limit, exchange, symbol2, t
|
|
|
61879
61933
|
}
|
|
61880
61934
|
async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal) {
|
|
61881
61935
|
const requestKey = `live-ticker:${symbol2}:${exchange}`;
|
|
61882
|
-
return shareClientGetRequest(requestKey, async (
|
|
61936
|
+
return shareClientGetRequest(requestKey, (requestSignal) => readMarketDataWithRetry(requestSignal, async () => {
|
|
61883
61937
|
const requestUrl2 = `${getApiUrl()}/ticker/live?symbol=${encodeURIComponent(symbol2)}&exchange=${encodeURIComponent(exchange)}`;
|
|
61884
61938
|
const trace = startRuntimeNetworkDebugTrace({
|
|
61885
61939
|
kind: "runtime",
|
|
@@ -61912,7 +61966,7 @@ async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal)
|
|
|
61912
61966
|
if (isAbortLikeError(error48)) throw error48;
|
|
61913
61967
|
throw buildMarketDataNetworkError(error48, "live ticker", "/ticker/live");
|
|
61914
61968
|
}
|
|
61915
|
-
}, { signal });
|
|
61969
|
+
}), { signal });
|
|
61916
61970
|
}
|
|
61917
61971
|
async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
61918
61972
|
const params = new URLSearchParams();
|
|
@@ -61971,7 +62025,7 @@ var init_market_data = __esm({
|
|
|
61971
62025
|
const params = new URLSearchParams({ limit: limit.toString(), exchange, symbol: symbol2, timeframe });
|
|
61972
62026
|
const requestUrl2 = `${getApiUrl()}/candles/recent?${params.toString()}`;
|
|
61973
62027
|
const forProfile = profileId === null ? {} : { credentials: "include", headers: getProfileHeaders(persistedRuntimeLeaseHeaders(profileId), profileId) };
|
|
61974
|
-
return shareClientGetRequest(`recent-candles:${profileId ?? "none"}:${params.toString()}`, async (
|
|
62028
|
+
return shareClientGetRequest(`recent-candles:${profileId ?? "none"}:${params.toString()}`, (requestSignal) => readMarketDataWithRetry(requestSignal, async () => {
|
|
61975
62029
|
const trace = startRuntimeNetworkDebugTrace({
|
|
61976
62030
|
kind: "runtime",
|
|
61977
62031
|
label: "market_data_api:candles_recent",
|
|
@@ -62013,7 +62067,7 @@ var init_market_data = __esm({
|
|
|
62013
62067
|
if (isAbortLikeError(error48)) throw error48;
|
|
62014
62068
|
throw buildMarketDataNetworkError(error48, "recent candles", "/candles/recent");
|
|
62015
62069
|
}
|
|
62016
|
-
}, { signal, shareAbortScoped: true });
|
|
62070
|
+
}), { signal, shareAbortScoped: true });
|
|
62017
62071
|
};
|
|
62018
62072
|
ExecutionAssetMetadataRequestError = class extends Error {
|
|
62019
62073
|
constructor(message, status, retryAfterMs, code = null) {
|
|
@@ -64126,6 +64180,11 @@ var init_hyperliquid_public_read = __esm({
|
|
|
64126
64180
|
checkAbort(signal);
|
|
64127
64181
|
if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
|
|
64128
64182
|
hostTransport?.onPublicInfoSent?.(body);
|
|
64183
|
+
} else {
|
|
64184
|
+
try {
|
|
64185
|
+
hostTransport?.onPrivateInfoSent?.(body);
|
|
64186
|
+
} catch {
|
|
64187
|
+
}
|
|
64129
64188
|
}
|
|
64130
64189
|
outcome = "failure";
|
|
64131
64190
|
let transportAborted;
|
|
@@ -100051,7 +100110,8 @@ async function fetchClientRuntimePromptMetadata(profileId, payload, options) {
|
|
|
100051
100110
|
return postClientRuntime(
|
|
100052
100111
|
"/runtime/prompt-contract/metadata",
|
|
100053
100112
|
profileId,
|
|
100054
|
-
buildClientRuntimeBody(payload),
|
|
100113
|
+
buildClientRuntimeBody(payload, { renders_prompt_field_legends: true }),
|
|
100114
|
+
// builds each {<block>_legend} line
|
|
100055
100115
|
options
|
|
100056
100116
|
);
|
|
100057
100117
|
}
|
|
@@ -100059,8 +100119,8 @@ async function fetchClientRuntimePromptDerivedContext(profileId, payload, option
|
|
|
100059
100119
|
return postClientRuntime(
|
|
100060
100120
|
"/runtime/prompt-contract/derived-context",
|
|
100061
100121
|
profileId,
|
|
100062
|
-
|
|
100063
|
-
|
|
100122
|
+
// The engine renders the blocks (prompt_inputs) and builds each {<block>_legend} line.
|
|
100123
|
+
buildClientRuntimeBody(payload, { renders_derived_prompts: true, renders_prompt_field_legends: true }),
|
|
100064
100124
|
options
|
|
100065
100125
|
);
|
|
100066
100126
|
}
|
|
@@ -100268,7 +100328,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
|
|
|
100268
100328
|
ttlMs: viewer.requestKey ? 0 : CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS
|
|
100269
100329
|
});
|
|
100270
100330
|
}
|
|
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,
|
|
100331
|
+
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
100332
|
var init_api2 = __esm({
|
|
100273
100333
|
"lib/api.ts"() {
|
|
100274
100334
|
"use strict";
|
|
@@ -100670,14 +100730,6 @@ var init_api2 = __esm({
|
|
|
100670
100730
|
};
|
|
100671
100731
|
isRuntimeIdempotencyInProgressError = (status, message) => status === HTTP_STATUS.CONFLICT && (message.toLowerCase().includes("duplicate request already in progress") || message.toLowerCase().includes("duplicate request in-flight"));
|
|
100672
100732
|
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
100733
|
reconcilePendingClientExchangeMutation = async (profileId, requestOptions) => {
|
|
100682
100734
|
let reconciliation;
|
|
100683
100735
|
try {
|
|
@@ -104389,7 +104441,7 @@ var init_hyperliquid_fee_contract = __esm({
|
|
|
104389
104441
|
if (typeof aligned !== "boolean") return unavailable;
|
|
104390
104442
|
const asset = matches[0];
|
|
104391
104443
|
const scale = dex ? numeric(asset.deployerFeeScale) : 0;
|
|
104392
|
-
const growthMode = dex ? asset.growthMode : "disabled";
|
|
104444
|
+
const growthMode = dex && "growthMode" in asset ? asset.growthMode : "disabled";
|
|
104393
104445
|
if (scale == null || scale < 0 || scale > HYPERLIQUID_MAX_DEPLOYER_FEE_SCALE || !["enabled", "disabled", "blocked"].includes(growthMode)) return unavailable;
|
|
104394
104446
|
if (growthMode === "enabled" && scale > 1) return unavailable;
|
|
104395
104447
|
const multiplier = scale < 1 ? 1 + scale : HYPERLIQUID_DEPLOYER_FEE_SCALE_MULTIPLIER * scale;
|
|
@@ -104523,6 +104575,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
104523
104575
|
init_hyperliquid_perp_dex_config();
|
|
104524
104576
|
init_device_account_state_store();
|
|
104525
104577
|
init_runtime_policy_generated2();
|
|
104578
|
+
init_rate_limit_text();
|
|
104526
104579
|
init_constants();
|
|
104527
104580
|
init_hyperliquid_clearinghouse_state();
|
|
104528
104581
|
browserUserFillsCache = /* @__PURE__ */ new Map();
|
|
@@ -104811,7 +104864,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
104811
104864
|
return true;
|
|
104812
104865
|
}
|
|
104813
104866
|
const detail = normalizeHyperliquidErrorDetail(error48).toLowerCase();
|
|
104814
|
-
return
|
|
104867
|
+
return isRateLimitErrorText(detail) || detail.includes("rate-limited") || detail.includes("cooldown");
|
|
104815
104868
|
};
|
|
104816
104869
|
servesStaleObservation = (error48, priority) => isRateLimitError(error48) || isHyperliquidReadRefusal(error48) && isHeldBackHyperliquidPriority(priority);
|
|
104817
104870
|
createAbortError = (message) => {
|
|
@@ -118660,7 +118713,7 @@ var init_browser_observability = __esm({
|
|
|
118660
118713
|
init_define_VTX_GROK_POLICY();
|
|
118661
118714
|
init_define_VTX_PI_MODEL_POLICY();
|
|
118662
118715
|
init_runtime_policy_generated2();
|
|
118663
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
118716
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim() && "2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim() !== "unstamped" ? "2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim() : null;
|
|
118664
118717
|
listenersInstalled = false;
|
|
118665
118718
|
state = {
|
|
118666
118719
|
loadedAtMs: Date.now(),
|
|
@@ -120703,6 +120756,7 @@ async function fetchCopyReviewPromptContract(profileId, payload, options) {
|
|
|
120703
120756
|
profileId,
|
|
120704
120757
|
buildClientRuntimeBody(payload, {
|
|
120705
120758
|
renders_derived_prompts: true,
|
|
120759
|
+
renders_prompt_field_legends: true,
|
|
120706
120760
|
copy_review_symbol: payload.copyReviewSymbol,
|
|
120707
120761
|
copy_review_symbols: payload.copyReviewSymbols
|
|
120708
120762
|
}),
|
|
@@ -122705,6 +122759,7 @@ var init_client_panel_reads = __esm({
|
|
|
122705
122759
|
init_history_evidence();
|
|
122706
122760
|
init_runtime_error_reason_rules();
|
|
122707
122761
|
init_run_with_concurrency_limit();
|
|
122762
|
+
init_bot_account();
|
|
122708
122763
|
exchangeCache = runtime_policy_generated_default2.exchange.cache;
|
|
122709
122764
|
SHARED_RESULT_MS = {
|
|
122710
122765
|
open_orders: runtime_policy_generated_default2.trading.engine.client_runtime.panel_reads.device_open_orders_reuse_seconds * MS_PER_SECOND,
|
|
@@ -123650,6 +123705,57 @@ var init_prompt_json_contract = __esm({
|
|
|
123650
123705
|
}
|
|
123651
123706
|
});
|
|
123652
123707
|
|
|
123708
|
+
// lib/runtime/prompt-field-visibility.ts
|
|
123709
|
+
var NO_FIELDS, LEGEND_TOKEN, isRecord7, readHidden, resolveHiddenPromptFields, hiddenFieldsOf, withoutHiddenFields, renderBlockLegend, renderPromptFieldLegends;
|
|
123710
|
+
var init_prompt_field_visibility = __esm({
|
|
123711
|
+
"lib/runtime/prompt-field-visibility.ts"() {
|
|
123712
|
+
"use strict";
|
|
123713
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
123714
|
+
init_define_VTX_EXO_POLICY();
|
|
123715
|
+
init_define_VTX_GROK_POLICY();
|
|
123716
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
123717
|
+
init_runtime_error_reason_rules();
|
|
123718
|
+
NO_FIELDS = /* @__PURE__ */ new Set();
|
|
123719
|
+
LEGEND_TOKEN = /\{([a-z_]+)_legend\}/g;
|
|
123720
|
+
isRecord7 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
123721
|
+
readHidden = (value, source) => Object.fromEntries(Object.entries(value).map(([block, fields]) => {
|
|
123722
|
+
if (!Array.isArray(fields) || fields.some((field) => typeof field !== "string")) {
|
|
123723
|
+
throw new RuntimeReasonError(`Invalid ${source}.${block}: must be a list of field names.`, "internal_data_error");
|
|
123724
|
+
}
|
|
123725
|
+
return [block, new Set(fields)];
|
|
123726
|
+
}));
|
|
123727
|
+
resolveHiddenPromptFields = (defaults, setting2) => {
|
|
123728
|
+
if (isRecord7(setting2)) return readHidden(setting2, "hidden_prompt_fields");
|
|
123729
|
+
if (defaults === void 0) return {};
|
|
123730
|
+
if (!isRecord7(defaults)) {
|
|
123731
|
+
throw new RuntimeReasonError("Invalid client runtime config: default_hidden_prompt_fields must be an object.", "runtime_config_missing");
|
|
123732
|
+
}
|
|
123733
|
+
return readHidden(defaults, "default_hidden_prompt_fields");
|
|
123734
|
+
};
|
|
123735
|
+
hiddenFieldsOf = (hidden, block) => hidden?.[block] ?? NO_FIELDS;
|
|
123736
|
+
withoutHiddenFields = (record6, hidden) => hidden.size === 0 ? record6 : Object.fromEntries(Object.entries(record6).filter(([key]) => !hidden.has(key)));
|
|
123737
|
+
renderBlockLegend = (block, catalog, hidden) => {
|
|
123738
|
+
if (!Array.isArray(catalog.keys) || !Array.isArray(catalog.legend)) {
|
|
123739
|
+
throw new RuntimeReasonError(`Missing prompts config key: instructions.data_format.fields.${block}`, "runtime_config_missing");
|
|
123740
|
+
}
|
|
123741
|
+
const keys = catalog.keys.filter((key) => !hidden.has(key)).map((key) => catalog.shapes?.[key] ?? key).join(",");
|
|
123742
|
+
return catalog.legend.map((part) => {
|
|
123743
|
+
const fields = part.fields ?? [];
|
|
123744
|
+
const visible = fields.filter((field) => !hidden.has(field));
|
|
123745
|
+
if (fields.length > 0 && visible.length === 0) return "";
|
|
123746
|
+
return part.text.replaceAll("{keys}", keys).replaceAll("{visible}", visible.join(","));
|
|
123747
|
+
}).join("");
|
|
123748
|
+
};
|
|
123749
|
+
renderPromptFieldLegends = (legend, catalogs, hidden) => legend.replace(LEGEND_TOKEN, (_token, block) => {
|
|
123750
|
+
const catalog = isRecord7(catalogs) ? catalogs[block] : void 0;
|
|
123751
|
+
if (!isRecord7(catalog)) {
|
|
123752
|
+
throw new RuntimeReasonError(`Missing prompts config key: instructions.data_format.fields.${block}`, "runtime_config_missing");
|
|
123753
|
+
}
|
|
123754
|
+
return renderBlockLegend(block, catalog, hiddenFieldsOf(hidden, block));
|
|
123755
|
+
});
|
|
123756
|
+
}
|
|
123757
|
+
});
|
|
123758
|
+
|
|
123653
123759
|
// lib/runtime/derived-context/guidance.ts
|
|
123654
123760
|
var FIELD_NAME, FIXED_SPEC, formatField, formatGuidanceTemplate, requireTemplates, requireTemplate, pythonFloatOrNull, threshold, pythonTruthy, enabled, finiteOrNull3, thresholdState, PERFORMANCE_CHECKS, REGIME_CHECKS, stateMessage, assemble, performanceGuidanceMessage, marketRegimeGuidanceMessage;
|
|
123655
123761
|
var init_guidance = __esm({
|
|
@@ -123918,6 +124024,7 @@ var init_calendar = __esm({
|
|
|
123918
124024
|
init_define_VTX_PI_MODEL_POLICY();
|
|
123919
124025
|
init_constants();
|
|
123920
124026
|
init_prompt_json_contract();
|
|
124027
|
+
init_prompt_field_visibility();
|
|
123921
124028
|
init_guidance();
|
|
123922
124029
|
init_python_text();
|
|
123923
124030
|
init_runtime_error_reason_rules();
|
|
@@ -124024,7 +124131,8 @@ var init_calendar = __esm({
|
|
|
124024
124131
|
if (activeEvents.length === 0) {
|
|
124025
124132
|
return "";
|
|
124026
124133
|
}
|
|
124027
|
-
const
|
|
124134
|
+
const hiddenFields = input.hiddenFields ?? /* @__PURE__ */ new Set();
|
|
124135
|
+
const block = `<calendar>${stringifyPromptJson(activeEvents.map((event) => withoutHiddenFields(event, hiddenFields)))}</calendar>`;
|
|
124028
124136
|
const header = output3.header;
|
|
124029
124137
|
const scope = output3.scope;
|
|
124030
124138
|
if (typeof header !== "string" || !header.trim() || typeof scope !== "string" || !scope.trim()) {
|
|
@@ -124073,7 +124181,7 @@ var init_interval = __esm({
|
|
|
124073
124181
|
});
|
|
124074
124182
|
|
|
124075
124183
|
// lib/runtime/derived-context/market-context.ts
|
|
124076
|
-
var calculateSlopeR2, calculateZScore, countPivots, formatCandleSpan, extractWindowFeatures, calculateRelativeVolumeRatio, buildMarketContext, marketCandleFromRow, marketContextInputFromPayload;
|
|
124184
|
+
var calculateSlopeR2, calculateZScore, countPivots, formatCandleSpan, extractWindowFeatures, calculateRelativeVolumeRatio, shownStats, buildMarketContext, marketCandleFromRow, marketContextInputFromPayload;
|
|
124077
124185
|
var init_market_context = __esm({
|
|
124078
124186
|
"lib/runtime/derived-context/market-context.ts"() {
|
|
124079
124187
|
"use strict";
|
|
@@ -124089,6 +124197,7 @@ var init_market_context = __esm({
|
|
|
124089
124197
|
init_python_numbers();
|
|
124090
124198
|
init_python_text();
|
|
124091
124199
|
init_runtime_error_reason_rules();
|
|
124200
|
+
init_prompt_field_visibility();
|
|
124092
124201
|
calculateSlopeR2 = (values) => {
|
|
124093
124202
|
const count5 = values.length;
|
|
124094
124203
|
if (count5 < REGRESSION_MIN_POINTS) {
|
|
@@ -124205,6 +124314,13 @@ var init_market_context = __esm({
|
|
|
124205
124314
|
}
|
|
124206
124315
|
return recentDollarVolume / baselineDollarVolume;
|
|
124207
124316
|
};
|
|
124317
|
+
shownStats = (stats, hidden) => hidden && hidden.size > 0 ? Object.fromEntries(Object.entries(stats).map(([symbol2, byTimeframe]) => [
|
|
124318
|
+
symbol2,
|
|
124319
|
+
Object.fromEntries(Object.entries(byTimeframe).map(([timeframe, features]) => [
|
|
124320
|
+
timeframe,
|
|
124321
|
+
withoutHiddenFields(features, hidden)
|
|
124322
|
+
]))
|
|
124323
|
+
])) : stats;
|
|
124208
124324
|
buildMarketContext = (input) => {
|
|
124209
124325
|
const timeframes = [...new Set(input.timeframes)].sort(compareCandleTimeframes);
|
|
124210
124326
|
const stats = {};
|
|
@@ -124258,7 +124374,7 @@ var init_market_context = __esm({
|
|
|
124258
124374
|
}
|
|
124259
124375
|
const cleanStats = Object.fromEntries(Object.entries(stats).filter(([, value]) => Object.keys(value).length > 0));
|
|
124260
124376
|
const marketStats = Object.keys(cleanStats).length > 0 ? `<market_stats>
|
|
124261
|
-
${stringifyPromptJson(cleanStats)}
|
|
124377
|
+
${stringifyPromptJson(shownStats(cleanStats, input.hiddenStatFields))}
|
|
124262
124378
|
</market_stats>` : "";
|
|
124263
124379
|
const expected = input.symbols.flatMap((rawSymbol) => {
|
|
124264
124380
|
const symbol2 = String(rawSymbol).trim();
|
|
@@ -124311,6 +124427,7 @@ var init_market_regime = __esm({
|
|
|
124311
124427
|
init_constants();
|
|
124312
124428
|
init_candle_timeframes();
|
|
124313
124429
|
init_prompt_json_contract();
|
|
124430
|
+
init_prompt_field_visibility();
|
|
124314
124431
|
init_prompt_number_contract();
|
|
124315
124432
|
init_guidance();
|
|
124316
124433
|
init_python_numbers();
|
|
@@ -124385,13 +124502,13 @@ var init_market_regime = __esm({
|
|
|
124385
124502
|
for (const timeframe of Object.keys(activeMap).sort(compareCandleTimeframes)) {
|
|
124386
124503
|
const values = activeMap[timeframe];
|
|
124387
124504
|
const relativeVolume = roundPromptRelativeVolume(values.relative_volume);
|
|
124388
|
-
symbolRegime[timeframe] = {
|
|
124505
|
+
symbolRegime[timeframe] = withoutHiddenFields({
|
|
124389
124506
|
adx: values.adx === null || values.adx === void 0 ? "-" : pythonRound(values.adx, REGIME_ADX_CHOP_DECIMALS),
|
|
124390
124507
|
chop: values.chop === null || values.chop === void 0 ? "-" : pythonRound(values.chop, REGIME_ADX_CHOP_DECIMALS),
|
|
124391
124508
|
atr: values.atr_pct === null || values.atr_pct === void 0 ? "-" : pythonRound(values.atr_pct, PROMPT_METRIC_DECIMALS),
|
|
124392
124509
|
// The candle-row rv column shows the same value with the same rounding.
|
|
124393
124510
|
rv: relativeVolume === null ? "-" : relativeVolume
|
|
124394
|
-
};
|
|
124511
|
+
}, input.hiddenFields ?? /* @__PURE__ */ new Set());
|
|
124395
124512
|
}
|
|
124396
124513
|
guidance[symbol2] = symbolRegime;
|
|
124397
124514
|
}
|
|
@@ -124503,6 +124620,7 @@ var init_performance = __esm({
|
|
|
124503
124620
|
init_define_VTX_PI_MODEL_POLICY();
|
|
124504
124621
|
init_constants();
|
|
124505
124622
|
init_prompt_json_contract();
|
|
124623
|
+
init_prompt_field_visibility();
|
|
124506
124624
|
init_guidance();
|
|
124507
124625
|
init_python_numbers();
|
|
124508
124626
|
init_runtime_error_reason_rules();
|
|
@@ -124760,8 +124878,9 @@ var init_performance = __esm({
|
|
|
124760
124878
|
mlc: pair((metrics) => Math.trunc(metrics.lossCount))
|
|
124761
124879
|
};
|
|
124762
124880
|
const performanceStructured = { global: globalSummary };
|
|
124881
|
+
const shownGlobal = withoutHiddenFields(globalSummary, input.hiddenFields ?? /* @__PURE__ */ new Set());
|
|
124763
124882
|
let performance2 = `<performance>
|
|
124764
|
-
${stringifyPromptJson(
|
|
124883
|
+
${stringifyPromptJson({ global: shownGlobal })}
|
|
124765
124884
|
</performance>`;
|
|
124766
124885
|
const shortLabel = `${pythonFloatRepr(shortWindowHours)}h`;
|
|
124767
124886
|
const longLabel = `${pythonFloatRepr(longWindowHours)}h`;
|
|
@@ -124893,6 +125012,7 @@ var init_render = __esm({
|
|
|
124893
125012
|
init_performance();
|
|
124894
125013
|
init_reference_candles();
|
|
124895
125014
|
init_runtime_error_reason_rules();
|
|
125015
|
+
init_prompt_field_visibility();
|
|
124896
125016
|
CLIENT_RUNTIME_LIVE_MARKET_STATS_UNAVAILABLE_ERROR = "Live market stats unavailable for client runtime contract";
|
|
124897
125017
|
CLIENT_RUNTIME_LIVE_PERFORMANCE_UNAVAILABLE_ERROR = "Live performance context unavailable for client runtime contract";
|
|
124898
125018
|
CLIENT_RUNTIME_LIVE_MARKET_REGIME_UNAVAILABLE_ERROR = "Live market regime context unavailable for client runtime contract";
|
|
@@ -124909,31 +125029,34 @@ var init_render = __esm({
|
|
|
124909
125029
|
this.name = "DerivedPromptContextUnavailableError";
|
|
124910
125030
|
}
|
|
124911
125031
|
};
|
|
124912
|
-
renderPerformanceInputs = (performance2, templates) => buildPerformanceContext({
|
|
125032
|
+
renderPerformanceInputs = (performance2, templates, hiddenFields) => buildPerformanceContext({
|
|
124913
125033
|
fillRecords: performance2.fill_records,
|
|
124914
125034
|
equityHistory: performance2.equity_history,
|
|
124915
125035
|
accountBalance: performance2.account_balance,
|
|
124916
125036
|
nowMs: performance2.now_ms,
|
|
124917
125037
|
config: performance2.config,
|
|
124918
125038
|
breakevenToleranceUsd: performance2.breakeven_tolerance_usd,
|
|
124919
|
-
templates
|
|
125039
|
+
templates,
|
|
125040
|
+
hiddenFields
|
|
124920
125041
|
});
|
|
124921
|
-
renderMarketRegime = (regimeIndicators, scope, thresholds, templates) => buildMarketRegimeContext({
|
|
125042
|
+
renderMarketRegime = (regimeIndicators, scope, thresholds, templates, hiddenFields) => buildMarketRegimeContext({
|
|
124922
125043
|
regimeIndicators,
|
|
124923
125044
|
symbols: scope.symbols,
|
|
124924
125045
|
primarySymbol: scope.primary_symbol,
|
|
124925
125046
|
activeTimeframes: scope.timeframes,
|
|
124926
125047
|
fallbackTimeframes: scope.fallback_timeframes,
|
|
124927
125048
|
thresholds,
|
|
124928
|
-
templates
|
|
125049
|
+
templates,
|
|
125050
|
+
hiddenFields
|
|
124929
125051
|
});
|
|
124930
|
-
renderCalendarInputs = (calendar, templates) => buildCalendarContext({
|
|
125052
|
+
renderCalendarInputs = (calendar, templates, hiddenFields) => buildCalendarContext({
|
|
124931
125053
|
events: calendar.events,
|
|
124932
125054
|
unavailable: calendar.unavailable,
|
|
124933
125055
|
settings: calendar.settings,
|
|
124934
125056
|
defaults: calendar.defaults,
|
|
124935
125057
|
templates: templates.calendar,
|
|
124936
|
-
nowSeconds: calendar.now_seconds
|
|
125058
|
+
nowSeconds: calendar.now_seconds,
|
|
125059
|
+
hiddenFields
|
|
124937
125060
|
});
|
|
124938
125061
|
renderNewsInputs = (news) => Object.fromEntries(
|
|
124939
125062
|
Object.entries(news ?? {}).map(([variable, item]) => [variable, buildNewsContext({
|
|
@@ -124965,7 +125088,11 @@ var init_render = __esm({
|
|
|
124965
125088
|
const uses = (variable) => input.placeholders.includes(variable);
|
|
124966
125089
|
const templates = requireInput(inputs.guidance_templates, "guidance_templates");
|
|
124967
125090
|
const values = {};
|
|
124968
|
-
const
|
|
125091
|
+
const hidden = input.hiddenPromptFields;
|
|
125092
|
+
const market = buildMarketContext({
|
|
125093
|
+
...marketContextInputFromPayload(requireInput(inputs.market, "market"), input.deviceMarket),
|
|
125094
|
+
hiddenStatFields: hiddenFieldsOf(hidden, "market_stats")
|
|
125095
|
+
});
|
|
124969
125096
|
if (uses("market_stats")) {
|
|
124970
125097
|
if (!market.marketStats || !market.marketStatsComplete) {
|
|
124971
125098
|
throw new DerivedPromptContextUnavailableError(CLIENT_RUNTIME_LIVE_MARKET_STATS_UNAVAILABLE_ERROR);
|
|
@@ -124975,8 +125102,14 @@ var init_render = __esm({
|
|
|
124975
125102
|
const performanceInputs = requireInput(inputs.performance, "performance");
|
|
124976
125103
|
let performanceStructured = null;
|
|
124977
125104
|
try {
|
|
124978
|
-
const performance2 = renderPerformanceInputs(performanceInputs, templates);
|
|
124979
|
-
const marketRegime = renderMarketRegime(
|
|
125105
|
+
const performance2 = renderPerformanceInputs(performanceInputs, templates, hiddenFieldsOf(hidden, "performance"));
|
|
125106
|
+
const marketRegime = renderMarketRegime(
|
|
125107
|
+
market.regimeIndicators,
|
|
125108
|
+
performanceInputs,
|
|
125109
|
+
performanceInputs.config.thresholds,
|
|
125110
|
+
templates,
|
|
125111
|
+
hiddenFieldsOf(hidden, "market_regime")
|
|
125112
|
+
);
|
|
124980
125113
|
if (performance2.performance) values.performance = performance2.performance;
|
|
124981
125114
|
if (marketRegime) values.market_regime = marketRegime;
|
|
124982
125115
|
performanceStructured = performance2.performanceStructured;
|
|
@@ -124989,7 +125122,7 @@ var init_render = __esm({
|
|
|
124989
125122
|
if (uses("market_regime") && !String(values.market_regime ?? "").trim()) {
|
|
124990
125123
|
throw new DerivedPromptContextUnavailableError(CLIENT_RUNTIME_LIVE_MARKET_REGIME_UNAVAILABLE_ERROR);
|
|
124991
125124
|
}
|
|
124992
|
-
values.calendar = renderCalendarInputs(requireInput(inputs.calendar, "calendar"), templates);
|
|
125125
|
+
values.calendar = renderCalendarInputs(requireInput(inputs.calendar, "calendar"), templates, hiddenFieldsOf(hidden, "calendar"));
|
|
124993
125126
|
Object.assign(values, renderNewsInputs(inputs.news));
|
|
124994
125127
|
let referenceIndicators;
|
|
124995
125128
|
if (inputs.reference_candles) {
|
|
@@ -128963,6 +129096,7 @@ var init_runtime_prompt_steps = __esm({
|
|
|
128963
129096
|
init_provider_client();
|
|
128964
129097
|
init_native_request_parameters();
|
|
128965
129098
|
init_constants();
|
|
129099
|
+
init_prompt_field_visibility();
|
|
128966
129100
|
init_runtime_error_reason_rules();
|
|
128967
129101
|
init_local_analysis();
|
|
128968
129102
|
buildRuntimePromptParityContext = (input) => {
|
|
@@ -129222,10 +129356,12 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129222
129356
|
return inputs;
|
|
129223
129357
|
};
|
|
129224
129358
|
buildRuntimeBehaviorStateArtifacts = (input) => {
|
|
129359
|
+
const hiddenFields = hiddenFieldsOf(input.hiddenPromptFields, "behavior_state");
|
|
129225
129360
|
if (input.serverOwnsBehaviorState) {
|
|
129226
129361
|
return buildServerBehaviorStateArtifacts(requireServerBehaviorStateInputs(input.derivedContext), {
|
|
129227
129362
|
behaviorInstructions: input.behaviorInstructions,
|
|
129228
|
-
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol
|
|
129363
|
+
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol,
|
|
129364
|
+
hiddenFields
|
|
129229
129365
|
});
|
|
129230
129366
|
}
|
|
129231
129367
|
const behaviorFillCoverage = input.fillEvidence?.source === "live" && input.fillEvidence.exactTerminalFillEvidenceComplete === true ? "complete" : "capped";
|
|
@@ -129240,7 +129376,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129240
129376
|
maxFillsPerSymbol: input.config.behavior_memory_max_fills_per_symbol,
|
|
129241
129377
|
decisionMemory: asRecord(input.derivedContext.behavior_decision_memory),
|
|
129242
129378
|
cycleCutoffMs: input.cutoffMs,
|
|
129243
|
-
fillHistoryCoverage: behaviorFillCoverage
|
|
129379
|
+
fillHistoryCoverage: behaviorFillCoverage,
|
|
129380
|
+
hiddenFields
|
|
129244
129381
|
});
|
|
129245
129382
|
};
|
|
129246
129383
|
buildRuntimePromptContextParts = (input) => ({
|
|
@@ -129270,7 +129407,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129270
129407
|
size: input.size,
|
|
129271
129408
|
leverage: input.leverage,
|
|
129272
129409
|
// {interval}, rendered from the contract's loop interval.
|
|
129273
|
-
interval: input.derivedBlocks.intervalContext
|
|
129410
|
+
interval: input.derivedBlocks.intervalContext,
|
|
129411
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
129274
129412
|
});
|
|
129275
129413
|
runtimePromptArtifactInput = (input) => ({
|
|
129276
129414
|
systemTemplate: input.systemTemplate,
|
|
@@ -129281,7 +129419,8 @@ var init_runtime_prompt_steps = __esm({
|
|
|
129281
129419
|
maxTradesPerPrompt: input.maxTradesPerPrompt,
|
|
129282
129420
|
metricsWindowHours: input.metricsWindowHours,
|
|
129283
129421
|
metricsSecondaryWindowHours: input.metricsSecondaryWindowHours,
|
|
129284
|
-
userTemplate: input.userTemplate
|
|
129422
|
+
userTemplate: input.userTemplate,
|
|
129423
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
129285
129424
|
});
|
|
129286
129425
|
}
|
|
129287
129426
|
});
|
|
@@ -129300,6 +129439,7 @@ var init_prompt_contract = __esm({
|
|
|
129300
129439
|
init_candle_prompt_contract();
|
|
129301
129440
|
init_constants();
|
|
129302
129441
|
init_python_text();
|
|
129442
|
+
init_prompt_field_visibility();
|
|
129303
129443
|
PROMPT_PLACEHOLDER_MAP = {};
|
|
129304
129444
|
DATA_FORMAT_TAG_ALIASES = {};
|
|
129305
129445
|
buildDecisionInstructionVariables = (rawSymbols, maxTrades) => {
|
|
@@ -129438,7 +129578,7 @@ var init_prompt_contract = __esm({
|
|
|
129438
129578
|
};
|
|
129439
129579
|
const metricsWindowLabel = formatWindowHours(options.metricsWindowHours);
|
|
129440
129580
|
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();
|
|
129581
|
+
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
129582
|
if (!legend) return "";
|
|
129443
129583
|
const candleLiveFieldToken = "{candle_live_field}";
|
|
129444
129584
|
const candleLiveGuidanceToken = "{candle_live_guidance}";
|
|
@@ -129742,7 +129882,9 @@ ${jsonInstruction}`.trim();
|
|
|
129742
129882
|
behaviorEntryTradeSchema: instructions.data_format?.behavior_entry_trade,
|
|
129743
129883
|
candleIndicatorSchemas: instructions.data_format?.candle_indicators,
|
|
129744
129884
|
referenceCandlesSummary: options.referenceCandlesSummary,
|
|
129745
|
-
referenceIndicatorFlags: options.referenceIndicatorFlags
|
|
129885
|
+
referenceIndicatorFlags: options.referenceIndicatorFlags,
|
|
129886
|
+
fieldCatalogs: instructions.data_format?.fields,
|
|
129887
|
+
hiddenPromptFields: options.hiddenPromptFields
|
|
129746
129888
|
});
|
|
129747
129889
|
const hasDataFormatInstructions = /^[ \t]*DATA FORMAT(?: INSTRUCTIONS)?:/m.test(template);
|
|
129748
129890
|
if (legend && !hasDataFormatInstructions) {
|
|
@@ -129761,7 +129903,8 @@ ${legend}`.trim();
|
|
|
129761
129903
|
behaviorEntryTradeSchema: instructions.data_format?.behavior_entry_trade,
|
|
129762
129904
|
candleIndicatorSchemas: instructions.data_format?.candle_indicators,
|
|
129763
129905
|
referenceCandlesSummary: options.referenceCandlesSummary,
|
|
129764
|
-
referenceIndicatorFlags: options.referenceIndicatorFlags
|
|
129906
|
+
referenceIndicatorFlags: options.referenceIndicatorFlags,
|
|
129907
|
+
fieldCatalogs: instructions.data_format?.fields
|
|
129765
129908
|
});
|
|
129766
129909
|
template = replaceEmbeddedDataFormatLegend(template, canonicalLegend, legend);
|
|
129767
129910
|
}
|
|
@@ -129772,7 +129915,7 @@ ${legend}`.trim();
|
|
|
129772
129915
|
});
|
|
129773
129916
|
|
|
129774
129917
|
// lib/runtime/behavior-memory-prompt-observability.ts
|
|
129775
|
-
var BODY_FREE_STATUS_FIELDS,
|
|
129918
|
+
var BODY_FREE_STATUS_FIELDS, isRecord8, isBodyFreeScalar, sanitizeBehaviorMemoryStatus, sha256Hex3, renderBehaviorMemoryPromptSeam;
|
|
129776
129919
|
var init_behavior_memory_prompt_observability = __esm({
|
|
129777
129920
|
"lib/runtime/behavior-memory-prompt-observability.ts"() {
|
|
129778
129921
|
"use strict";
|
|
@@ -129801,10 +129944,10 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129801
129944
|
"duration_ms",
|
|
129802
129945
|
"loader_outcome"
|
|
129803
129946
|
];
|
|
129804
|
-
|
|
129947
|
+
isRecord8 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
129805
129948
|
isBodyFreeScalar = (value) => value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
129806
129949
|
sanitizeBehaviorMemoryStatus = (value) => {
|
|
129807
|
-
if (!
|
|
129950
|
+
if (!isRecord8(value)) {
|
|
129808
129951
|
return {};
|
|
129809
129952
|
}
|
|
129810
129953
|
const sanitized = {};
|
|
@@ -129814,16 +129957,16 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129814
129957
|
sanitized[key] = fieldValue;
|
|
129815
129958
|
}
|
|
129816
129959
|
}
|
|
129817
|
-
if (
|
|
129960
|
+
if (isRecord8(value.symbols)) {
|
|
129818
129961
|
const symbols = {};
|
|
129819
129962
|
for (const [symbol2, rawSymbolStatus] of Object.entries(value.symbols)) {
|
|
129820
|
-
if (!
|
|
129963
|
+
if (!isRecord8(rawSymbolStatus)) {
|
|
129821
129964
|
continue;
|
|
129822
129965
|
}
|
|
129823
129966
|
const symbolStatus = {};
|
|
129824
129967
|
for (const itemKey of ["pd", "pc", "et"]) {
|
|
129825
129968
|
const rawItemStatus = rawSymbolStatus[itemKey];
|
|
129826
|
-
if (!
|
|
129969
|
+
if (!isRecord8(rawItemStatus)) {
|
|
129827
129970
|
continue;
|
|
129828
129971
|
}
|
|
129829
129972
|
const itemStatus = {};
|
|
@@ -129915,6 +130058,93 @@ var init_behavior_memory_prompt_observability = __esm({
|
|
|
129915
130058
|
}
|
|
129916
130059
|
});
|
|
129917
130060
|
|
|
130061
|
+
// lib/runtime/prompt-collateral-contract.ts
|
|
130062
|
+
var orderPromptSymbols, buildPromptCollateralPools, poolEquityForSymbol, buildPromptFeeMap;
|
|
130063
|
+
var init_prompt_collateral_contract = __esm({
|
|
130064
|
+
"lib/runtime/prompt-collateral-contract.ts"() {
|
|
130065
|
+
"use strict";
|
|
130066
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
130067
|
+
init_define_VTX_EXO_POLICY();
|
|
130068
|
+
init_define_VTX_GROK_POLICY();
|
|
130069
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
130070
|
+
init_hyperliquid_market_symbol();
|
|
130071
|
+
init_prompt_number_contract();
|
|
130072
|
+
init_constants();
|
|
130073
|
+
orderPromptSymbols = (selected, held = []) => {
|
|
130074
|
+
const ordered = new Set(selected.map(normalizeHyperliquidMarketSymbol).filter(Boolean));
|
|
130075
|
+
const heldOnly = [...new Set(held.map(normalizeHyperliquidMarketSymbol).filter(Boolean))].filter((symbol2) => !ordered.has(symbol2)).sort();
|
|
130076
|
+
return [...ordered, ...heldOnly];
|
|
130077
|
+
};
|
|
130078
|
+
buildPromptCollateralPools = (accounts, symbols) => {
|
|
130079
|
+
const byDex = /* @__PURE__ */ new Map();
|
|
130080
|
+
const duplicateDexes = /* @__PURE__ */ new Set();
|
|
130081
|
+
for (const account of Array.isArray(accounts) ? accounts : []) {
|
|
130082
|
+
if (!account || typeof account !== "object" || typeof account.dex !== "string") continue;
|
|
130083
|
+
const dex = account.dex.trim().toLowerCase();
|
|
130084
|
+
if (byDex.has(dex)) duplicateDexes.add(dex);
|
|
130085
|
+
byDex.set(dex, account);
|
|
130086
|
+
}
|
|
130087
|
+
const symbolsByDex = /* @__PURE__ */ new Map();
|
|
130088
|
+
for (const raw of symbols) {
|
|
130089
|
+
const symbol2 = normalizeHyperliquidMarketSymbol(raw);
|
|
130090
|
+
if (!symbol2) continue;
|
|
130091
|
+
const dex = getHyperliquidMarketDex(symbol2);
|
|
130092
|
+
if (!symbolsByDex.has(dex)) symbolsByDex.set(dex, /* @__PURE__ */ new Set());
|
|
130093
|
+
symbolsByDex.get(dex).add(symbol2);
|
|
130094
|
+
}
|
|
130095
|
+
const number6 = (account, field) => {
|
|
130096
|
+
const raw = account[field];
|
|
130097
|
+
if (typeof raw !== "number" && typeof raw !== "string" || typeof raw === "string" && !raw.trim()) return null;
|
|
130098
|
+
const value = Number(raw);
|
|
130099
|
+
return Number.isFinite(value) ? value : null;
|
|
130100
|
+
};
|
|
130101
|
+
return [...symbolsByDex.keys()].map((dex) => {
|
|
130102
|
+
const account = duplicateDexes.has(dex) ? {} : byDex.get(dex) ?? {};
|
|
130103
|
+
const e = number6(account, "account_value");
|
|
130104
|
+
const u = number6(account, "total_unrealized_pnl");
|
|
130105
|
+
const m = number6(account, "maintenance_margin");
|
|
130106
|
+
const metrics = {
|
|
130107
|
+
e,
|
|
130108
|
+
b: e !== null && u !== null ? e - u : null,
|
|
130109
|
+
u,
|
|
130110
|
+
l: number6(account, "cross_account_leverage"),
|
|
130111
|
+
ut: e !== null && e > 0 && m !== null ? PERCENT_SCALE * m / e : null,
|
|
130112
|
+
a: number6(account, "available_margin"),
|
|
130113
|
+
m,
|
|
130114
|
+
lb: e !== null && m !== null ? e - m : null,
|
|
130115
|
+
mu: number6(account, "total_margin_used")
|
|
130116
|
+
};
|
|
130117
|
+
return {
|
|
130118
|
+
dex,
|
|
130119
|
+
symbols: [...symbolsByDex.get(dex)],
|
|
130120
|
+
...Object.fromEntries(Object.entries(metrics).map(([key, value]) => [
|
|
130121
|
+
key,
|
|
130122
|
+
value === null ? null : roundPromptFixed(value, key === "ut" ? PROMPT_MARGIN_UTILIZATION_DECIMALS : PROMPT_FIXED_DIGITS)
|
|
130123
|
+
]))
|
|
130124
|
+
};
|
|
130125
|
+
});
|
|
130126
|
+
};
|
|
130127
|
+
poolEquityForSymbol = (accounts, symbol2) => {
|
|
130128
|
+
const pool = buildPromptCollateralPools(accounts, [symbol2])[0];
|
|
130129
|
+
const dex = getHyperliquidMarketDex(symbol2);
|
|
130130
|
+
const matches = (Array.isArray(accounts) ? accounts : []).filter((account) => account && typeof account.dex === "string" && account.dex.trim().toLowerCase() === dex);
|
|
130131
|
+
if (!pool || matches.length !== 1 || matches[0].account_value == null) return null;
|
|
130132
|
+
const raw = matches[0].account_value;
|
|
130133
|
+
if (typeof raw !== "number" && typeof raw !== "string" || typeof raw === "string" && !raw.trim()) return null;
|
|
130134
|
+
const value = Number(raw);
|
|
130135
|
+
return Number.isFinite(value) ? value : null;
|
|
130136
|
+
};
|
|
130137
|
+
buildPromptFeeMap = (rates, symbols) => {
|
|
130138
|
+
const source = rates && typeof rates === "object" && !Array.isArray(rates) ? rates : {};
|
|
130139
|
+
return Object.fromEntries(orderPromptSymbols(symbols).map((symbol2) => {
|
|
130140
|
+
const raw = source[symbol2];
|
|
130141
|
+
const value = typeof raw === "number" && Number.isFinite(raw) && raw >= 0 && raw < 1 ? raw : null;
|
|
130142
|
+
return [symbol2, value];
|
|
130143
|
+
}));
|
|
130144
|
+
};
|
|
130145
|
+
}
|
|
130146
|
+
});
|
|
130147
|
+
|
|
129918
130148
|
// lib/runtime/position-prompt-contract.ts
|
|
129919
130149
|
var promptPercent, projectPositionPromptNormalization, projectPositionPromptExcursions;
|
|
129920
130150
|
var init_position_prompt_contract = __esm({
|
|
@@ -129989,89 +130219,151 @@ var init_position_prompt_contract = __esm({
|
|
|
129989
130219
|
}
|
|
129990
130220
|
});
|
|
129991
130221
|
|
|
129992
|
-
// lib/runtime/prompt-
|
|
129993
|
-
var
|
|
129994
|
-
var
|
|
129995
|
-
"lib/runtime/prompt-
|
|
130222
|
+
// lib/runtime/prompt-positions-block.ts
|
|
130223
|
+
var formatPromptPrice, buildPromptAccountStatusValue, buildPromptPositionsValue;
|
|
130224
|
+
var init_prompt_positions_block = __esm({
|
|
130225
|
+
"lib/runtime/prompt-positions-block.ts"() {
|
|
129996
130226
|
"use strict";
|
|
129997
130227
|
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
129998
130228
|
init_define_VTX_EXO_POLICY();
|
|
129999
130229
|
init_define_VTX_GROK_POLICY();
|
|
130000
130230
|
init_define_VTX_PI_MODEL_POLICY();
|
|
130231
|
+
init_constants();
|
|
130232
|
+
init_execution_capacity();
|
|
130001
130233
|
init_hyperliquid_market_symbol();
|
|
130234
|
+
init_position_prompt_contract();
|
|
130235
|
+
init_prompt_collateral_contract();
|
|
130236
|
+
init_prompt_field_visibility();
|
|
130237
|
+
init_prompt_json_contract();
|
|
130002
130238
|
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);
|
|
130239
|
+
init_prompt_variable_validation_contract();
|
|
130240
|
+
init_runtime_error_reason_rules();
|
|
130241
|
+
formatPromptPrice = (value) => {
|
|
130242
|
+
const numeric2 = Number(value);
|
|
130243
|
+
if (!Number.isFinite(numeric2) || numeric2 === 0) {
|
|
130244
|
+
return 0;
|
|
130017
130245
|
}
|
|
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);
|
|
130246
|
+
if (Math.abs(numeric2) >= PROMPT_PRICE_INTEGER_THRESHOLD) {
|
|
130247
|
+
return Number(Math.trunc(numeric2));
|
|
130025
130248
|
}
|
|
130026
|
-
|
|
130027
|
-
|
|
130028
|
-
|
|
130029
|
-
|
|
130030
|
-
|
|
130249
|
+
return roundPromptSignificant(numeric2, PROMPT_SIGNIFICANT_DIGITS);
|
|
130250
|
+
};
|
|
130251
|
+
buildPromptAccountStatusValue = (accountSummary, marginNote, effectiveTakerRates, symbols, hiddenFields) => [
|
|
130252
|
+
"<account_status>",
|
|
130253
|
+
stringifyPromptJson(withoutHiddenFields({
|
|
130254
|
+
pools: buildPromptCollateralPools(accountSummary.perp_dex_accounts, symbols).map((pool) => withoutHiddenFields(pool, hiddenFields)),
|
|
130255
|
+
fees: buildPromptFeeMap(effectiveTakerRates, symbols)
|
|
130256
|
+
}, hiddenFields)),
|
|
130257
|
+
"</account_status>",
|
|
130258
|
+
"",
|
|
130259
|
+
marginNote
|
|
130260
|
+
].join("\n");
|
|
130261
|
+
buildPromptPositionsValue = (input) => {
|
|
130262
|
+
const validateInstructionTemplate = (template, allowedKeys) => {
|
|
130263
|
+
formatInstructionTemplate(
|
|
130264
|
+
template,
|
|
130265
|
+
Object.fromEntries(allowedKeys.map((key) => [key, ""])),
|
|
130266
|
+
"positions instruction template"
|
|
130267
|
+
);
|
|
130031
130268
|
};
|
|
130032
|
-
|
|
130033
|
-
|
|
130034
|
-
|
|
130035
|
-
|
|
130036
|
-
|
|
130037
|
-
|
|
130038
|
-
|
|
130039
|
-
|
|
130040
|
-
|
|
130041
|
-
|
|
130042
|
-
|
|
130043
|
-
|
|
130044
|
-
|
|
130045
|
-
|
|
130046
|
-
|
|
130047
|
-
|
|
130269
|
+
validateInstructionTemplate(input.positionsInstructions.close_reduce, []);
|
|
130270
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_flat, []);
|
|
130271
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_full, []);
|
|
130272
|
+
validateInstructionTemplate(input.positionsInstructions.capacity_low, ["remaining"]);
|
|
130273
|
+
const activePositions = input.positions.filter((position) => Number(position.size) !== 0);
|
|
130274
|
+
const orderedSymbols = orderPromptSymbols(input.symbols, activePositions.map((position) => position.symbol));
|
|
130275
|
+
const symbolRanks = new Map(orderedSymbols.map((symbol2, index) => [symbol2, index]));
|
|
130276
|
+
activePositions.sort((left, right) => symbolRanks.get(normalizeHyperliquidMarketSymbol(left.symbol)) - symbolRanks.get(normalizeHyperliquidMarketSymbol(right.symbol)));
|
|
130277
|
+
const assetUsage = /* @__PURE__ */ new Map();
|
|
130278
|
+
const exchangeUsage = /* @__PURE__ */ new Map();
|
|
130279
|
+
let globalUnitsUsed = 0;
|
|
130280
|
+
const promptPositions = activePositions.map((position) => {
|
|
130281
|
+
const entryPrice = Number(position.entry_price);
|
|
130282
|
+
const size = Number(position.size);
|
|
130283
|
+
const unrealizedPnl = Number(position.unrealized_pnl);
|
|
130284
|
+
if (!Number.isFinite(entryPrice) || entryPrice <= 0 || !Number.isFinite(size) || size === 0) {
|
|
130285
|
+
throw new RuntimeReasonError(`Active position identity/economics are invalid for ${position.symbol}`, "internal_data_error");
|
|
130286
|
+
}
|
|
130287
|
+
if (!Number.isFinite(unrealizedPnl)) {
|
|
130288
|
+
throw new RuntimeReasonError(`Active position PnL is unavailable for ${position.symbol}`, "internal_data_error");
|
|
130289
|
+
}
|
|
130290
|
+
const notionalValue = Math.abs(size * entryPrice);
|
|
130291
|
+
const unitsUsed = capacityUnitsUsedForPosition(size, entryPrice, input.unitSize);
|
|
130292
|
+
globalUnitsUsed += unitsUsed;
|
|
130293
|
+
assetUsage.set(position.symbol, unitsUsed);
|
|
130294
|
+
const venue = getHyperliquidMarketDex(position.symbol);
|
|
130295
|
+
exchangeUsage.set(venue, (exchangeUsage.get(venue) ?? 0) + unitsUsed);
|
|
130296
|
+
const currentValue = Math.abs(size > 0 ? notionalValue + unrealizedPnl : notionalValue - unrealizedPnl);
|
|
130297
|
+
const takerRate = buildPromptFeeMap(input.effectiveTakerRates, [position.symbol])[normalizeHyperliquidMarketSymbol(position.symbol)];
|
|
130298
|
+
const totalFees = takerRate == null ? null : (notionalValue + currentValue) * takerRate;
|
|
130299
|
+
const pnlAfterFees = totalFees == null ? null : unrealizedPnl - totalFees;
|
|
130300
|
+
let breakeven = null;
|
|
130301
|
+
if (entryPrice > 0 && takerRate != null) {
|
|
130302
|
+
if (size > 0) {
|
|
130303
|
+
breakeven = entryPrice * (1 + takerRate) / (1 - takerRate);
|
|
130304
|
+
} else if (size < 0) {
|
|
130305
|
+
breakeven = entryPrice * (1 - takerRate) / (1 + takerRate);
|
|
130306
|
+
}
|
|
130307
|
+
}
|
|
130048
130308
|
return {
|
|
130049
|
-
|
|
130050
|
-
|
|
130051
|
-
|
|
130052
|
-
|
|
130053
|
-
|
|
130054
|
-
|
|
130309
|
+
s: position.symbol,
|
|
130310
|
+
sd: size > 0 ? "LONG" : "SHORT",
|
|
130311
|
+
v: roundPromptFixed(notionalValue),
|
|
130312
|
+
cv: roundPromptFixed(currentValue),
|
|
130313
|
+
ep: entryPrice ? formatPromptPrice(entryPrice) : 0,
|
|
130314
|
+
be: breakeven == null ? null : formatPromptPrice(breakeven),
|
|
130315
|
+
liq: position.liquidation_price ? formatPromptPrice(position.liquidation_price) : "-",
|
|
130316
|
+
u: unitsUsed,
|
|
130317
|
+
up: roundPromptFixed(unrealizedPnl),
|
|
130318
|
+
f: totalFees == null ? null : roundPromptFixed(totalFees),
|
|
130319
|
+
n: pnlAfterFees == null ? null : roundPromptFixed(pnlAfterFees),
|
|
130320
|
+
...projectPositionPromptNormalization({
|
|
130321
|
+
entryValue: notionalValue,
|
|
130322
|
+
currentValue,
|
|
130323
|
+
unrealizedPnl,
|
|
130324
|
+
netPnl: pnlAfterFees,
|
|
130325
|
+
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol)
|
|
130326
|
+
}),
|
|
130327
|
+
...projectPositionPromptExcursions({
|
|
130328
|
+
projection: input.positionExcursions[normalizeHyperliquidMarketSymbol(position.symbol)],
|
|
130329
|
+
size,
|
|
130330
|
+
entryPrice,
|
|
130331
|
+
unrealizedPnl,
|
|
130332
|
+
accountEquity: poolEquityForSymbol(input.perpDexAccounts, position.symbol),
|
|
130333
|
+
cutoffMs: input.cutoffMs
|
|
130334
|
+
})
|
|
130055
130335
|
};
|
|
130056
130336
|
});
|
|
130057
|
-
|
|
130058
|
-
|
|
130059
|
-
|
|
130060
|
-
|
|
130061
|
-
|
|
130062
|
-
|
|
130063
|
-
|
|
130064
|
-
|
|
130065
|
-
|
|
130066
|
-
|
|
130067
|
-
|
|
130068
|
-
|
|
130069
|
-
|
|
130070
|
-
|
|
130071
|
-
|
|
130072
|
-
|
|
130073
|
-
|
|
130074
|
-
|
|
130337
|
+
const remainingGlobal = Math.max(0, input.maxTradesGlobal - globalUnitsUsed);
|
|
130338
|
+
const parts = [
|
|
130339
|
+
"<positions>",
|
|
130340
|
+
stringifyPromptJson(promptPositions.map((position) => withoutHiddenFields(position, input.hiddenFields))),
|
|
130341
|
+
"</positions>",
|
|
130342
|
+
...activePositions.length === 0 ? ["", input.positionsInstructions.capacity_flat] : [],
|
|
130343
|
+
"",
|
|
130344
|
+
"--- Capacity & Limits --- ",
|
|
130345
|
+
`Global: ${globalUnitsUsed}/${input.maxTradesGlobal} exposure units used. (Additional capacity: ${remainingGlobal}) `
|
|
130346
|
+
];
|
|
130347
|
+
for (const venue of new Set(orderedSymbols.map(getHyperliquidMarketDex))) {
|
|
130348
|
+
const used = exchangeUsage.get(venue) ?? 0;
|
|
130349
|
+
const remaining = Math.max(0, input.maxTradesPerExchange - used);
|
|
130350
|
+
parts.push(`Exchange '${venue || "native"}': ${used}/${input.maxTradesPerExchange} exposure units used. (Additional capacity: ${remaining}) `);
|
|
130351
|
+
}
|
|
130352
|
+
for (const symbol2 of input.symbols) {
|
|
130353
|
+
const used = assetUsage.get(symbol2) ?? 0;
|
|
130354
|
+
const remaining = Math.max(0, input.maxTradesPerAsset - used);
|
|
130355
|
+
parts.push(`Asset '${symbol2}': ${used}/${input.maxTradesPerAsset} exposure units used. (Additional capacity: ${remaining}) `);
|
|
130356
|
+
}
|
|
130357
|
+
parts.push("");
|
|
130358
|
+
parts.push(...input.positionsInstructions.close_reduce.split("\n"));
|
|
130359
|
+
if (remainingGlobal <= 0) {
|
|
130360
|
+
parts.push(`${input.positionsInstructions.capacity_full} `);
|
|
130361
|
+
} else if (input.maxTradesPerPrompt < input.maxTradesGlobal && remainingGlobal < input.maxTradesPerPrompt) {
|
|
130362
|
+
parts.push(`${formatInstructionTemplate(input.positionsInstructions.capacity_low, {
|
|
130363
|
+
remaining: remainingGlobal
|
|
130364
|
+
}, "positions instruction template")} `);
|
|
130365
|
+
}
|
|
130366
|
+
return parts.join("\n");
|
|
130075
130367
|
};
|
|
130076
130368
|
}
|
|
130077
130369
|
});
|
|
@@ -130589,7 +130881,7 @@ __export(local_analysis_exports, {
|
|
|
130589
130881
|
toPositiveFinite: () => toPositiveFinite2,
|
|
130590
130882
|
unwrapRuntimeCycleSettledResult: () => unwrapRuntimeCycleSettledResult
|
|
130591
130883
|
});
|
|
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,
|
|
130884
|
+
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
130885
|
var init_local_analysis = __esm({
|
|
130594
130886
|
"lib/runtime/local-analysis.ts"() {
|
|
130595
130887
|
"use strict";
|
|
@@ -130636,10 +130928,10 @@ var init_local_analysis = __esm({
|
|
|
130636
130928
|
init_prompt_contract();
|
|
130637
130929
|
init_behavior_memory_prompt_observability();
|
|
130638
130930
|
init_prompt_variable_validation_contract();
|
|
130639
|
-
init_position_prompt_contract();
|
|
130640
130931
|
init_prompt_json_contract();
|
|
130641
130932
|
init_prompt_collateral_contract();
|
|
130642
|
-
|
|
130933
|
+
init_prompt_positions_block();
|
|
130934
|
+
init_prompt_field_visibility();
|
|
130643
130935
|
init_local_ai();
|
|
130644
130936
|
init_reasoning_controls();
|
|
130645
130937
|
init_native_request_parameters();
|
|
@@ -130726,7 +131018,8 @@ var init_local_analysis = __esm({
|
|
|
130726
131018
|
cycleCutoffMs: inputs.now_ms ?? void 0,
|
|
130727
131019
|
nowMs: inputs.now_ms ?? options.nowMs,
|
|
130728
131020
|
fillHistoryCoverage: inputs.fill_history_coverage,
|
|
130729
|
-
positionStates: inputs.position_states
|
|
131021
|
+
positionStates: inputs.position_states,
|
|
131022
|
+
hiddenFields: options.hiddenFields
|
|
130730
131023
|
});
|
|
130731
131024
|
ClientRuntimeAgentInstructionEmpty = class extends Error {
|
|
130732
131025
|
constructor(retryAfterMs) {
|
|
@@ -131222,9 +131515,9 @@ var init_local_analysis = __esm({
|
|
|
131222
131515
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
131223
131516
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
131224
131517
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
131225
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
131226
|
-
"
|
|
131227
|
-
) ? "
|
|
131518
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim() && !["unknown", "unstamped", "development"].includes(
|
|
131519
|
+
"2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim().toLowerCase()
|
|
131520
|
+
) ? "2562b05bba09fe4c13820b20bbc63621f3bb0dc0".trim() : null;
|
|
131228
131521
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
131229
131522
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
131230
131523
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|
|
@@ -132293,16 +132586,6 @@ ${reviewOutputContract}`;
|
|
|
132293
132586
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds} UTC (${weekday})`;
|
|
132294
132587
|
};
|
|
132295
132588
|
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
132589
|
capacityUnitSize = (tradeSize, configuredTradeAmount) => {
|
|
132307
132590
|
if (Number.isFinite(tradeSize) && tradeSize > 0) return tradeSize;
|
|
132308
132591
|
const configured2 = Number(configuredTradeAmount);
|
|
@@ -132311,123 +132594,6 @@ ${reviewOutputContract}`;
|
|
|
132311
132594
|
}
|
|
132312
132595
|
return configured2;
|
|
132313
132596
|
};
|
|
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
132597
|
sanitizePromptSymbol = (value) => String(value ?? "").replace(/<[^>]*>/g, "").slice(0, PROMPT_SYMBOL_MAX_CHARS);
|
|
132432
132598
|
fillTimeMs = (fill) => {
|
|
132433
132599
|
const value = Number(fill.time ?? fill.time_ms ?? 0);
|
|
@@ -133179,7 +133345,9 @@ ${reviewOutputContract}`;
|
|
|
133179
133345
|
return text2.startsWith("- ") ? text2 : `- ${text2}`;
|
|
133180
133346
|
};
|
|
133181
133347
|
const renderBehaviorData = (entries) => {
|
|
133182
|
-
const behaviorJson = stringifyPromptJson(
|
|
133348
|
+
const behaviorJson = stringifyPromptJson(Object.fromEntries(Object.entries(entries).map(
|
|
133349
|
+
([symbol2, entry]) => [symbol2, withoutHiddenFields(entry, input.hiddenFields ?? /* @__PURE__ */ new Set())]
|
|
133350
|
+
))).replace(/&/g, "\\u0026").replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
133183
133351
|
const lines = [
|
|
133184
133352
|
`<behavior_state>
|
|
133185
133353
|
${behaviorJson}
|
|
@@ -133245,11 +133413,12 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
133245
133413
|
orderPromptSymbols(
|
|
133246
133414
|
parts.positions.symbols,
|
|
133247
133415
|
parts.positions.positions.filter((position) => Number(position.size) !== 0).map((position) => position.symbol)
|
|
133248
|
-
)
|
|
133416
|
+
),
|
|
133417
|
+
hiddenFieldsOf(parts.hiddenPromptFields, "account_status")
|
|
133249
133418
|
),
|
|
133250
133419
|
calendar: parts.calendar,
|
|
133251
133420
|
behavior_state: parts.behaviorState,
|
|
133252
|
-
positions: buildPromptPositionsValue(parts.positions),
|
|
133421
|
+
positions: buildPromptPositionsValue({ ...parts.positions, hiddenFields: hiddenFieldsOf(parts.hiddenPromptFields, "positions") }),
|
|
133253
133422
|
performance: String(parts.derivedValues.performance ?? ""),
|
|
133254
133423
|
market_regime: String(parts.derivedValues.market_regime ?? ""),
|
|
133255
133424
|
...Object.fromEntries(
|
|
@@ -133276,7 +133445,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
133276
133445
|
calendarSummary: String(input.contextVars.calendar ?? ""),
|
|
133277
133446
|
behaviorStateSummary: String(input.contextVars.behavior_state ?? ""),
|
|
133278
133447
|
referenceCandlesSummary: String(input.contextVars[REFERENCE_CANDLES_PROMPT_VARIABLE] ?? ""),
|
|
133279
|
-
referenceIndicatorFlags: input.referenceIndicators
|
|
133448
|
+
referenceIndicatorFlags: input.referenceIndicators,
|
|
133449
|
+
hiddenPromptFields: input.hiddenPromptFields
|
|
133280
133450
|
});
|
|
133281
133451
|
const templateContextVars = Object.fromEntries(
|
|
133282
133452
|
Object.entries(input.contextVars).filter(([key]) => activePlaceholders.has(key))
|
|
@@ -134283,6 +134453,7 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134283
134453
|
} = resolveRuntimeTradingScope(settings, config2);
|
|
134284
134454
|
const sortedTimeframes = sortTradingTimeframes(timeframes);
|
|
134285
134455
|
const activeIndicators = normalizeAiIndicatorFlags(config2.default_ai_indicators, settings.ai_indicators);
|
|
134456
|
+
const hiddenPromptFields = resolveHiddenPromptFields(config2.default_hidden_prompt_fields, settings.hidden_prompt_fields);
|
|
134286
134457
|
const lookbackSettings = settings.analysis_lookback;
|
|
134287
134458
|
const effectiveDefaultLookbacks = config2.default_analysis_lookback_fallbacks;
|
|
134288
134459
|
const indicatorCandleCount = Number(config2.indicator_candle_count);
|
|
@@ -134662,7 +134833,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134662
134833
|
inputs: requireDerivedPromptInputs(asRecord(promptDerivedContext.derived_context)),
|
|
134663
134834
|
placeholders: extractTemplatePlaceholders(String(promptMetadata.user_template ?? "")),
|
|
134664
134835
|
loopIntervalSeconds: Number(asRecord(promptMetadata.prompt_knobs).loop_interval_seconds),
|
|
134665
|
-
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount })
|
|
134836
|
+
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount }),
|
|
134837
|
+
hiddenPromptFields
|
|
134666
134838
|
});
|
|
134667
134839
|
} catch (error48) {
|
|
134668
134840
|
if (input.mode === "trader" && error48 instanceof DerivedPromptContextUnavailableError) {
|
|
@@ -134964,7 +135136,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134964
135136
|
promptSymbols,
|
|
134965
135137
|
promptTimeframes,
|
|
134966
135138
|
behaviorMemoryEnabled,
|
|
134967
|
-
cutoffMs: behaviorMemoryCutoffMs
|
|
135139
|
+
cutoffMs: behaviorMemoryCutoffMs,
|
|
135140
|
+
hiddenPromptFields
|
|
134968
135141
|
});
|
|
134969
135142
|
} catch (error48) {
|
|
134970
135143
|
throw new BehaviorMemoryUnavailableError(error48);
|
|
@@ -134987,7 +135160,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
134987
135160
|
knobs: { maxTradesGlobal, maxTradesPerExchange, maxTradesPerAsset, maxTradesPerPrompt, tradeSize: metadataTradeSize },
|
|
134988
135161
|
positionsInstructions,
|
|
134989
135162
|
size: metadataTradeSize,
|
|
134990
|
-
leverage: metadataLeverage
|
|
135163
|
+
leverage: metadataLeverage,
|
|
135164
|
+
hiddenPromptFields
|
|
134991
135165
|
}));
|
|
134992
135166
|
} catch (error48) {
|
|
134993
135167
|
const detail = error48 instanceof Error ? error48.message : String(error48);
|
|
@@ -135108,7 +135282,8 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
135108
135282
|
promptSymbols,
|
|
135109
135283
|
maxTradesPerPrompt,
|
|
135110
135284
|
metricsWindowHours,
|
|
135111
|
-
metricsSecondaryWindowHours
|
|
135285
|
+
metricsSecondaryWindowHours,
|
|
135286
|
+
hiddenPromptFields
|
|
135112
135287
|
}),
|
|
135113
135288
|
contextVars: renderContextVars
|
|
135114
135289
|
})
|
|
@@ -136267,7 +136442,7 @@ ${indentText.repeat(depth)}${brackets[1]}`;
|
|
|
136267
136442
|
});
|
|
136268
136443
|
|
|
136269
136444
|
// lib/runtime/copy-review-prompt.ts
|
|
136270
|
-
var COPY_REVIEW_PRIMARY_MODEL, COPY_TRADE_PROPOSAL, COPY_POSITION_REPAIR, metadataOf, copyReviewIsGapRepair,
|
|
136445
|
+
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
136446
|
var init_copy_review_prompt = __esm({
|
|
136272
136447
|
"lib/runtime/copy-review-prompt.ts"() {
|
|
136273
136448
|
"use strict";
|
|
@@ -136284,40 +136459,24 @@ var init_copy_review_prompt = __esm({
|
|
|
136284
136459
|
init_local_analysis();
|
|
136285
136460
|
init_python_json();
|
|
136286
136461
|
init_runtime_error_reason_rules();
|
|
136462
|
+
COPY_REVIEW_DECISIONS = ["BUY", "SELL", "HOLD"];
|
|
136463
|
+
COPY_REVIEW_INTENTS = ["open", "add", "reduce", "close", "flip", "unknown"];
|
|
136287
136464
|
COPY_REVIEW_PRIMARY_MODEL = "Copy Trading";
|
|
136288
136465
|
COPY_TRADE_PROPOSAL = "copy_trade_proposal";
|
|
136289
136466
|
COPY_POSITION_REPAIR = "copy_position_repair";
|
|
136290
136467
|
metadataOf = (event) => event.sanitized_metadata && typeof event.sanitized_metadata === "object" && !Array.isArray(event.sanitized_metadata) ? event.sanitized_metadata : {};
|
|
136291
136468
|
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);
|
|
136469
|
+
isOneOf = (values, value) => values.includes(value);
|
|
136470
|
+
copyReviewSentProposal = (event) => {
|
|
136471
|
+
const decision = event.proposed_decision;
|
|
136472
|
+
const intent = event.destination_intent;
|
|
136473
|
+
if (!isOneOf(COPY_REVIEW_DECISIONS, decision) || !isOneOf(COPY_REVIEW_INTENTS, intent)) {
|
|
136474
|
+
throw new RuntimeReasonError(
|
|
136475
|
+
"Missing copy review proposal: the server sent this copy without its proposed_decision and destination_intent.",
|
|
136476
|
+
"runtime_config_missing"
|
|
136477
|
+
);
|
|
136478
|
+
}
|
|
136479
|
+
return { decision, intent };
|
|
136321
136480
|
};
|
|
136322
136481
|
copyReviewObserved = (event) => copyReviewIsGapRepair(event) ? {
|
|
136323
136482
|
source_position: {
|
|
@@ -136336,32 +136495,35 @@ var init_copy_review_prompt = __esm({
|
|
|
136336
136495
|
fingerprint: event.source_event_fingerprint
|
|
136337
136496
|
}
|
|
136338
136497
|
};
|
|
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
|
-
|
|
136498
|
+
copyReviewProposedTrade = (event, source) => {
|
|
136499
|
+
const proposal = copyReviewSentProposal(event);
|
|
136500
|
+
return {
|
|
136501
|
+
type: copyReviewIsGapRepair(event) ? COPY_POSITION_REPAIR : COPY_TRADE_PROPOSAL,
|
|
136502
|
+
source: {
|
|
136503
|
+
type: source.source_type,
|
|
136504
|
+
identifier: source.source_identifier,
|
|
136505
|
+
display_name: source.source_display_name,
|
|
136506
|
+
wallet_address: source.source_wallet_address
|
|
136507
|
+
},
|
|
136508
|
+
symbol: event.symbol,
|
|
136509
|
+
decision: proposal.decision,
|
|
136510
|
+
...copyReviewObserved(event),
|
|
136511
|
+
destination_order: {
|
|
136512
|
+
side: event.destination_side,
|
|
136513
|
+
size: pythonFloat(event.destination_size),
|
|
136514
|
+
notional: pythonFloat(event.destination_notional),
|
|
136515
|
+
reduce_only: Boolean(event.reduce_only),
|
|
136516
|
+
runtime_mode: event.runtime_mode,
|
|
136517
|
+
idempotency_key: event.idempotency_key
|
|
136518
|
+
},
|
|
136519
|
+
copy_intent: {
|
|
136520
|
+
source_intent: event.inferred_intent,
|
|
136521
|
+
destination_intent: proposal.intent,
|
|
136522
|
+
scaling_mode: event.scaling_mode,
|
|
136523
|
+
scale_factor: pythonFloat(event.scale_factor)
|
|
136524
|
+
}
|
|
136525
|
+
};
|
|
136526
|
+
};
|
|
136365
136527
|
text = (value) => ({ kind: "str", value });
|
|
136366
136528
|
gapRepairTemplates = (templates) => {
|
|
136367
136529
|
if (!templates.gap_repair) {
|
|
@@ -136400,7 +136562,7 @@ var init_copy_review_prompt = __esm({
|
|
|
136400
136562
|
return value;
|
|
136401
136563
|
};
|
|
136402
136564
|
renderCopyReviewPrompts = (input) => {
|
|
136403
|
-
const proposedDecision =
|
|
136565
|
+
const proposedDecision = copyReviewSentProposal(input.event).decision;
|
|
136404
136566
|
const proposedTrade = copyReviewProposedTrade(input.event, input.source);
|
|
136405
136567
|
const { context, ...primary } = input.primary;
|
|
136406
136568
|
const main = buildLocalRuntimePromptArtifacts2({ ...primary, contextVars: assemblePromptContextVars(context) });
|
|
@@ -136445,7 +136607,6 @@ ${copyReviewPromptContext(proposedTrade, input.templates)}`;
|
|
|
136445
136607
|
primaryDecisionJson
|
|
136446
136608
|
});
|
|
136447
136609
|
return {
|
|
136448
|
-
proposedDecision,
|
|
136449
136610
|
primaryDecision,
|
|
136450
136611
|
primarySystemPrompt,
|
|
136451
136612
|
primaryUserPrompt,
|
|
@@ -136470,6 +136631,7 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136470
136631
|
init_client_account_report();
|
|
136471
136632
|
init_copy_review_prompt();
|
|
136472
136633
|
init_render();
|
|
136634
|
+
init_prompt_field_visibility();
|
|
136473
136635
|
init_local_analysis();
|
|
136474
136636
|
init_runtime_error_reason_rules();
|
|
136475
136637
|
init_runtime_prompt_steps();
|
|
@@ -136541,6 +136703,7 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136541
136703
|
const { config: config2, contract: derived, marketData, fills, accountState } = input;
|
|
136542
136704
|
const { settings, symbols, sortedTimeframes, indicatorCandleCount } = input.scope;
|
|
136543
136705
|
const activeIndicators = normalizeAiIndicatorFlags(config2.default_ai_indicators, settings.ai_indicators);
|
|
136706
|
+
const hiddenPromptFields = resolveHiddenPromptFields(config2.default_hidden_prompt_fields, settings.hidden_prompt_fields);
|
|
136544
136707
|
const accountSummary = copyReviewAccountSummary(accountState);
|
|
136545
136708
|
const promptMetadata = requireCopyReviewContractReady(derived);
|
|
136546
136709
|
const tickersBySymbol = Object.fromEntries(marketData.map((entry) => [entry.symbol, entry.ticker]));
|
|
@@ -136550,7 +136713,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136550
136713
|
inputs: requireDerivedPromptInputs(derivedContext),
|
|
136551
136714
|
placeholders: extractTemplatePlaceholders(String(promptMetadata.user_template ?? "")),
|
|
136552
136715
|
loopIntervalSeconds: Number(asRecord(promptMetadata.prompt_knobs).loop_interval_seconds),
|
|
136553
|
-
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount })
|
|
136716
|
+
deviceMarket: deviceMarketReads({ candlesBySymbol, tickersBySymbol, indicatorCandleCount }),
|
|
136717
|
+
hiddenPromptFields
|
|
136554
136718
|
});
|
|
136555
136719
|
const promptKnobs = asRecord(promptMetadata.prompt_knobs);
|
|
136556
136720
|
const promptInstructions = asRecord(promptMetadata.prompt_instructions);
|
|
@@ -136589,7 +136753,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136589
136753
|
promptSymbols: knobs.promptSymbols,
|
|
136590
136754
|
promptTimeframes: knobs.promptTimeframes,
|
|
136591
136755
|
behaviorMemoryEnabled,
|
|
136592
|
-
cutoffMs
|
|
136756
|
+
cutoffMs,
|
|
136757
|
+
hiddenPromptFields
|
|
136593
136758
|
}).rendered;
|
|
136594
136759
|
const context = buildRuntimePromptContextParts({
|
|
136595
136760
|
config: config2,
|
|
@@ -136607,7 +136772,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136607
136772
|
knobs,
|
|
136608
136773
|
positionsInstructions,
|
|
136609
136774
|
size: input.promptSize(copyReviewSizes),
|
|
136610
|
-
leverage: knobs.leverage
|
|
136775
|
+
leverage: knobs.leverage,
|
|
136776
|
+
hiddenPromptFields
|
|
136611
136777
|
});
|
|
136612
136778
|
const reviewInstructions = asRecord(promptMetadata.review_instructions);
|
|
136613
136779
|
return {
|
|
@@ -136621,7 +136787,8 @@ var init_copy_review_render_inputs = __esm({
|
|
|
136621
136787
|
promptSymbols: knobs.promptSymbols,
|
|
136622
136788
|
maxTradesPerPrompt: knobs.maxTradesPerPrompt,
|
|
136623
136789
|
metricsWindowHours: knobs.metricsWindowHours,
|
|
136624
|
-
metricsSecondaryWindowHours: knobs.metricsSecondaryWindowHours
|
|
136790
|
+
metricsSecondaryWindowHours: knobs.metricsSecondaryWindowHours,
|
|
136791
|
+
hiddenPromptFields
|
|
136625
136792
|
}),
|
|
136626
136793
|
context
|
|
136627
136794
|
},
|
|
@@ -136768,6 +136935,7 @@ var init_copy_review_runtime = __esm({
|
|
|
136768
136935
|
});
|
|
136769
136936
|
};
|
|
136770
136937
|
renderRuntimeCopyReview = async (input) => {
|
|
136938
|
+
copyReviewSentProposal(input.event);
|
|
136771
136939
|
const prepared = await prepareRuntimeCopyReviewPrimary({
|
|
136772
136940
|
profileId: input.profileId,
|
|
136773
136941
|
payload: input.payload,
|
|
@@ -138809,7 +138977,7 @@ var init_client_killswitch = __esm({
|
|
|
138809
138977
|
});
|
|
138810
138978
|
|
|
138811
138979
|
// lib/runtime/portfolio-evidence.ts
|
|
138812
|
-
var PORTFOLIO_RETRY_MS, PORTFOLIO_READ_PRIORITY, PortfolioBodyError, portfolioRequestBody,
|
|
138980
|
+
var PORTFOLIO_RETRY_MS, PORTFOLIO_READ_PRIORITY, PortfolioBodyError, portfolioRequestBody, isRecord9, checkPortfolioBody, runningProfiles2, portfolioBackoffUntil, errorCode2, runClientPortfolioReport;
|
|
138813
138981
|
var init_portfolio_evidence = __esm({
|
|
138814
138982
|
"lib/runtime/portfolio-evidence.ts"() {
|
|
138815
138983
|
"use strict";
|
|
@@ -138831,7 +138999,7 @@ var init_portfolio_evidence = __esm({
|
|
|
138831
138999
|
}
|
|
138832
139000
|
};
|
|
138833
139001
|
portfolioRequestBody = (walletAddress) => ({ type: "portfolio", user: walletAddress });
|
|
138834
|
-
|
|
139002
|
+
isRecord9 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
138835
139003
|
checkPortfolioBody = (body) => {
|
|
138836
139004
|
if (typeof body !== "string") throw new PortfolioBodyError("The portfolio body must be the raw response text.");
|
|
138837
139005
|
let parsed;
|
|
@@ -138841,7 +139009,7 @@ var init_portfolio_evidence = __esm({
|
|
|
138841
139009
|
throw new PortfolioBodyError("The portfolio response is not JSON.");
|
|
138842
139010
|
}
|
|
138843
139011
|
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" &&
|
|
139012
|
+
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
139013
|
if (!valid) throw new PortfolioBodyError("The portfolio response has no period histories.");
|
|
138846
139014
|
};
|
|
138847
139015
|
runningProfiles2 = /* @__PURE__ */ new Set();
|