@vtxmacro/cli 2026.9.64 → 2026.9.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vtx-service-bootstrap.js +5 -1
- package/bin/vtx-service-launcher.js +4 -0
- package/bin/vtx.js +656 -499
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
17
|
var agent_cli_release_default = {
|
|
18
18
|
package_name: "@vtxmacro/cli",
|
|
19
|
-
package_version: "2026.9.
|
|
19
|
+
package_version: "2026.9.65",
|
|
20
20
|
codex_package_name: "@openai/codex",
|
|
21
21
|
codex_version: "0.155.0",
|
|
22
22
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -132,6 +132,10 @@ var runtime_policy_generated_default = {
|
|
|
132
132
|
base_delay_milliseconds: 500,
|
|
133
133
|
min_delay_milliseconds: 250,
|
|
134
134
|
max_delay_milliseconds: 1e4
|
|
135
|
+
},
|
|
136
|
+
deployment_reload_observability: {
|
|
137
|
+
bootstrap_max_error_events_per_page: 4,
|
|
138
|
+
bootstrap_max_profiles: 10
|
|
135
139
|
}
|
|
136
140
|
},
|
|
137
141
|
ai_dashboard: {
|
|
@@ -15,6 +15,10 @@ var runtime_policy_generated_default = {
|
|
|
15
15
|
base_delay_milliseconds: 500,
|
|
16
16
|
min_delay_milliseconds: 250,
|
|
17
17
|
max_delay_milliseconds: 1e4
|
|
18
|
+
},
|
|
19
|
+
deployment_reload_observability: {
|
|
20
|
+
bootstrap_max_error_events_per_page: 4,
|
|
21
|
+
bootstrap_max_profiles: 10
|
|
18
22
|
}
|
|
19
23
|
},
|
|
20
24
|
ai_dashboard: {
|
package/bin/vtx.js
CHANGED
|
@@ -77,7 +77,7 @@ var init_agent_cli_release = __esm({
|
|
|
77
77
|
"agent-cli-release.json"() {
|
|
78
78
|
agent_cli_release_default = {
|
|
79
79
|
package_name: "@vtxmacro/cli",
|
|
80
|
-
package_version: "2026.9.
|
|
80
|
+
package_version: "2026.9.65",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.155.0",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -20515,6 +20515,10 @@ var init_runtime_policy_generated = __esm({
|
|
|
20515
20515
|
base_delay_milliseconds: 500,
|
|
20516
20516
|
min_delay_milliseconds: 250,
|
|
20517
20517
|
max_delay_milliseconds: 1e4
|
|
20518
|
+
},
|
|
20519
|
+
deployment_reload_observability: {
|
|
20520
|
+
bootstrap_max_error_events_per_page: 4,
|
|
20521
|
+
bootstrap_max_profiles: 10
|
|
20518
20522
|
}
|
|
20519
20523
|
},
|
|
20520
20524
|
ai_dashboard: {
|
|
@@ -42604,6 +42608,10 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42604
42608
|
base_delay_milliseconds: 500,
|
|
42605
42609
|
min_delay_milliseconds: 250,
|
|
42606
42610
|
max_delay_milliseconds: 1e4
|
|
42611
|
+
},
|
|
42612
|
+
deployment_reload_observability: {
|
|
42613
|
+
bootstrap_max_error_events_per_page: 4,
|
|
42614
|
+
bootstrap_max_profiles: 10
|
|
42607
42615
|
}
|
|
42608
42616
|
},
|
|
42609
42617
|
ai_dashboard: {
|
|
@@ -48869,6 +48877,520 @@ var init_runtime_redaction = __esm({
|
|
|
48869
48877
|
}
|
|
48870
48878
|
});
|
|
48871
48879
|
|
|
48880
|
+
// lib/runtime/channel-sender.ts
|
|
48881
|
+
var RUNTIME_TAB_ID_STORAGE_KEY, createRuntimeUuid, getOrCreateRuntimeTabSenderId;
|
|
48882
|
+
var init_channel_sender = __esm({
|
|
48883
|
+
"lib/runtime/channel-sender.ts"() {
|
|
48884
|
+
"use strict";
|
|
48885
|
+
init_define_VTX_EXO_POLICY();
|
|
48886
|
+
init_define_VTX_GROK_POLICY();
|
|
48887
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
48888
|
+
RUNTIME_TAB_ID_STORAGE_KEY = "vtx_client_runtime_tab_id";
|
|
48889
|
+
createRuntimeUuid = () => {
|
|
48890
|
+
if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
|
|
48891
|
+
return globalThis.crypto.randomUUID();
|
|
48892
|
+
}
|
|
48893
|
+
return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
48894
|
+
};
|
|
48895
|
+
getOrCreateRuntimeTabSenderId = () => {
|
|
48896
|
+
if (typeof window === "undefined") {
|
|
48897
|
+
return null;
|
|
48898
|
+
}
|
|
48899
|
+
try {
|
|
48900
|
+
const stored = window.sessionStorage.getItem(RUNTIME_TAB_ID_STORAGE_KEY);
|
|
48901
|
+
if (stored && stored.trim()) {
|
|
48902
|
+
return stored;
|
|
48903
|
+
}
|
|
48904
|
+
const created = createRuntimeUuid();
|
|
48905
|
+
window.sessionStorage.setItem(RUNTIME_TAB_ID_STORAGE_KEY, created);
|
|
48906
|
+
return created;
|
|
48907
|
+
} catch {
|
|
48908
|
+
return null;
|
|
48909
|
+
}
|
|
48910
|
+
};
|
|
48911
|
+
}
|
|
48912
|
+
});
|
|
48913
|
+
|
|
48914
|
+
// lib/runtime/network-debug.ts
|
|
48915
|
+
var MAX_RUNTIME_NETWORK_DEBUG_ENTRIES, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES, RUNTIME_NETWORK_DEBUG_STORAGE_KEY, RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY, RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY, runtimeNetworkDebugEntries, runtimeProviderFailureDebugEntries, runtimeMarketDataFailureDebugEntries, runtimeNetworkDebugListeners, isRuntimeMarketDataFailureDebugEntry, persistRuntimeNetworkDebugEntries, persistRuntimeProviderFailureDebugEntries, persistRuntimeMarketDataFailureDebugEntries, emitRuntimeNetworkDebugEntries, emitRuntimeProviderFailureDebugEntries, emitRuntimeMarketDataFailureDebugEntries, buildRuntimeNetworkDebugId, normalizeRuntimeNetworkUrl, readRuntimeNetworkBrowserContext, classifyRuntimeNetworkFailure, isLocalProviderFailureProbeCandidate, buildLocalProviderProbeUrls, patchRuntimeProviderFailureDebugEntry, runLocalProviderFailureHealthProbe, compactRuntimePromptString, shouldCompactRuntimeRequestString, sanitizeRuntimeNetworkDebugPayload, getRuntimeNetworkDebugEntries, startRuntimeNetworkDebugTrace, appendRuntimeDebugEvent;
|
|
48916
|
+
var init_network_debug = __esm({
|
|
48917
|
+
"lib/runtime/network-debug.ts"() {
|
|
48918
|
+
"use strict";
|
|
48919
|
+
init_define_VTX_EXO_POLICY();
|
|
48920
|
+
init_define_VTX_GROK_POLICY();
|
|
48921
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
48922
|
+
init_runtime_redaction();
|
|
48923
|
+
init_channel_sender();
|
|
48924
|
+
MAX_RUNTIME_NETWORK_DEBUG_ENTRIES = 80;
|
|
48925
|
+
MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES = 20;
|
|
48926
|
+
MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES = 20;
|
|
48927
|
+
RUNTIME_NETWORK_DEBUG_STORAGE_KEY = "vtx_client_runtime_network_debug_entries_v1";
|
|
48928
|
+
RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY = "vtx_client_runtime_provider_failure_debug_entries_v1";
|
|
48929
|
+
RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY = "vtx_client_runtime_market_data_failure_debug_entries_v1";
|
|
48930
|
+
runtimeNetworkDebugEntries = [];
|
|
48931
|
+
runtimeProviderFailureDebugEntries = [];
|
|
48932
|
+
runtimeMarketDataFailureDebugEntries = [];
|
|
48933
|
+
runtimeNetworkDebugListeners = /* @__PURE__ */ new Set();
|
|
48934
|
+
isRuntimeMarketDataFailureDebugEntry = (entry) => entry.kind === "runtime" && entry.label.startsWith("market_data_api:") && entry.outcome === "error";
|
|
48935
|
+
persistRuntimeNetworkDebugEntries = () => {
|
|
48936
|
+
if (typeof window === "undefined") {
|
|
48937
|
+
return;
|
|
48938
|
+
}
|
|
48939
|
+
try {
|
|
48940
|
+
window.localStorage.setItem(
|
|
48941
|
+
RUNTIME_NETWORK_DEBUG_STORAGE_KEY,
|
|
48942
|
+
JSON.stringify(runtimeNetworkDebugEntries.slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES))
|
|
48943
|
+
);
|
|
48944
|
+
} catch {
|
|
48945
|
+
}
|
|
48946
|
+
};
|
|
48947
|
+
persistRuntimeProviderFailureDebugEntries = () => {
|
|
48948
|
+
if (typeof window === "undefined") {
|
|
48949
|
+
return;
|
|
48950
|
+
}
|
|
48951
|
+
try {
|
|
48952
|
+
window.localStorage.setItem(
|
|
48953
|
+
RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY,
|
|
48954
|
+
JSON.stringify(runtimeProviderFailureDebugEntries.slice(0, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES))
|
|
48955
|
+
);
|
|
48956
|
+
} catch {
|
|
48957
|
+
}
|
|
48958
|
+
};
|
|
48959
|
+
persistRuntimeMarketDataFailureDebugEntries = () => {
|
|
48960
|
+
if (typeof window === "undefined") {
|
|
48961
|
+
return;
|
|
48962
|
+
}
|
|
48963
|
+
try {
|
|
48964
|
+
window.localStorage.setItem(
|
|
48965
|
+
RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY,
|
|
48966
|
+
JSON.stringify(runtimeMarketDataFailureDebugEntries.slice(0, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES))
|
|
48967
|
+
);
|
|
48968
|
+
} catch {
|
|
48969
|
+
}
|
|
48970
|
+
};
|
|
48971
|
+
emitRuntimeNetworkDebugEntries = (options = {}) => {
|
|
48972
|
+
if (options.persist !== false) {
|
|
48973
|
+
persistRuntimeNetworkDebugEntries();
|
|
48974
|
+
}
|
|
48975
|
+
const snapshot = getRuntimeNetworkDebugEntries();
|
|
48976
|
+
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
48977
|
+
};
|
|
48978
|
+
emitRuntimeProviderFailureDebugEntries = (options = {}) => {
|
|
48979
|
+
if (options.persist !== false) {
|
|
48980
|
+
persistRuntimeProviderFailureDebugEntries();
|
|
48981
|
+
}
|
|
48982
|
+
const snapshot = getRuntimeNetworkDebugEntries();
|
|
48983
|
+
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
48984
|
+
};
|
|
48985
|
+
emitRuntimeMarketDataFailureDebugEntries = (options = {}) => {
|
|
48986
|
+
if (options.persist !== false) {
|
|
48987
|
+
persistRuntimeMarketDataFailureDebugEntries();
|
|
48988
|
+
}
|
|
48989
|
+
const snapshot = getRuntimeNetworkDebugEntries();
|
|
48990
|
+
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
48991
|
+
};
|
|
48992
|
+
buildRuntimeNetworkDebugId = () => {
|
|
48993
|
+
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
48994
|
+
return crypto.randomUUID();
|
|
48995
|
+
}
|
|
48996
|
+
return `runtime-net-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
48997
|
+
};
|
|
48998
|
+
normalizeRuntimeNetworkUrl = (value) => {
|
|
48999
|
+
try {
|
|
49000
|
+
const parsed = new URL(value);
|
|
49001
|
+
return {
|
|
49002
|
+
targetProtocol: parsed.protocol ? parsed.protocol.replace(/:$/, "").toLowerCase() : null,
|
|
49003
|
+
targetHost: parsed.host || "unknown-host",
|
|
49004
|
+
targetPath: sanitizeRuntimeNetworkPath(parsed.pathname || "/")
|
|
49005
|
+
};
|
|
49006
|
+
} catch {
|
|
49007
|
+
return {
|
|
49008
|
+
targetProtocol: null,
|
|
49009
|
+
targetHost: "invalid-url",
|
|
49010
|
+
targetPath: sanitizeRuntimeNetworkPath(value)
|
|
49011
|
+
};
|
|
49012
|
+
}
|
|
49013
|
+
};
|
|
49014
|
+
readRuntimeNetworkBrowserContext = () => {
|
|
49015
|
+
if (typeof window === "undefined") {
|
|
49016
|
+
return {
|
|
49017
|
+
tabId: null,
|
|
49018
|
+
online: null,
|
|
49019
|
+
visibilityState: null,
|
|
49020
|
+
hidden: null,
|
|
49021
|
+
focused: null,
|
|
49022
|
+
pageHost: null,
|
|
49023
|
+
connectionEffectiveType: null,
|
|
49024
|
+
connectionDownlink: null,
|
|
49025
|
+
connectionRtt: null
|
|
49026
|
+
};
|
|
49027
|
+
}
|
|
49028
|
+
const nav = typeof navigator !== "undefined" ? navigator : null;
|
|
49029
|
+
const connection = nav && typeof nav === "object" ? nav.connection : null;
|
|
49030
|
+
let tabId = null;
|
|
49031
|
+
try {
|
|
49032
|
+
tabId = getOrCreateRuntimeTabSenderId() || null;
|
|
49033
|
+
} catch {
|
|
49034
|
+
tabId = null;
|
|
49035
|
+
}
|
|
49036
|
+
return {
|
|
49037
|
+
tabId,
|
|
49038
|
+
online: nav && typeof nav.onLine === "boolean" ? nav.onLine : null,
|
|
49039
|
+
visibilityState: typeof document !== "undefined" && typeof document.visibilityState === "string" ? document.visibilityState : null,
|
|
49040
|
+
hidden: typeof document !== "undefined" && typeof document.hidden === "boolean" ? document.hidden : null,
|
|
49041
|
+
focused: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : null,
|
|
49042
|
+
pageHost: window.location?.host || null,
|
|
49043
|
+
connectionEffectiveType: typeof connection?.effectiveType === "string" ? connection.effectiveType : null,
|
|
49044
|
+
connectionDownlink: Number.isFinite(Number(connection?.downlink)) ? Number(connection?.downlink) : null,
|
|
49045
|
+
connectionRtt: Number.isFinite(Number(connection?.rtt)) ? Number(connection?.rtt) : null
|
|
49046
|
+
};
|
|
49047
|
+
};
|
|
49048
|
+
classifyRuntimeNetworkFailure = (error48, status) => {
|
|
49049
|
+
if (status != null) {
|
|
49050
|
+
return `http_${status}`;
|
|
49051
|
+
}
|
|
49052
|
+
if (!error48) {
|
|
49053
|
+
return null;
|
|
49054
|
+
}
|
|
49055
|
+
const normalized = error48.toLowerCase();
|
|
49056
|
+
if (normalized.includes("abort")) {
|
|
49057
|
+
return "abort";
|
|
49058
|
+
}
|
|
49059
|
+
if (normalized.includes("cors")) {
|
|
49060
|
+
return "cors";
|
|
49061
|
+
}
|
|
49062
|
+
if (normalized.includes("failed to fetch") || normalized.includes("networkerror")) {
|
|
49063
|
+
return "fetch_failed";
|
|
49064
|
+
}
|
|
49065
|
+
if (normalized.includes("load failed") || normalized.includes("network request failed")) {
|
|
49066
|
+
return "network_failed";
|
|
49067
|
+
}
|
|
49068
|
+
return "error";
|
|
49069
|
+
};
|
|
49070
|
+
isLocalProviderFailureProbeCandidate = (entry) => {
|
|
49071
|
+
if (entry.kind !== "provider" || entry.label !== "local" || entry.status != null) {
|
|
49072
|
+
return false;
|
|
49073
|
+
}
|
|
49074
|
+
const host = entry.targetHost.toLowerCase();
|
|
49075
|
+
if (host.startsWith("127.0.0.1:") || host === "127.0.0.1" || host.startsWith("localhost:") || host === "localhost" || host.startsWith("[::1]:") || host === "[::1]") {
|
|
49076
|
+
return true;
|
|
49077
|
+
}
|
|
49078
|
+
return false;
|
|
49079
|
+
};
|
|
49080
|
+
buildLocalProviderProbeUrls = (entry) => {
|
|
49081
|
+
const protocol = entry.targetProtocol === "https" ? "https" : "http";
|
|
49082
|
+
const origin = `${protocol}://${entry.targetHost}`;
|
|
49083
|
+
return [
|
|
49084
|
+
{ path: "/api/v0/models", url: `${origin}/api/v0/models` },
|
|
49085
|
+
{ path: "/v1/models", url: `${origin}/v1/models` }
|
|
49086
|
+
];
|
|
49087
|
+
};
|
|
49088
|
+
patchRuntimeProviderFailureDebugEntry = (id2, patcher) => {
|
|
49089
|
+
runtimeProviderFailureDebugEntries = runtimeProviderFailureDebugEntries.map((entry) => entry.id === id2 ? patcher(entry) : entry);
|
|
49090
|
+
emitRuntimeProviderFailureDebugEntries();
|
|
49091
|
+
};
|
|
49092
|
+
runLocalProviderFailureHealthProbe = (entry) => {
|
|
49093
|
+
if (typeof fetch !== "function" || !isLocalProviderFailureProbeCandidate(entry)) {
|
|
49094
|
+
return;
|
|
49095
|
+
}
|
|
49096
|
+
const probeStartedAt = Date.now();
|
|
49097
|
+
const probe = {
|
|
49098
|
+
reason: "local_provider_network_failure",
|
|
49099
|
+
startedAt: probeStartedAt,
|
|
49100
|
+
completedAt: null,
|
|
49101
|
+
attempts: []
|
|
49102
|
+
};
|
|
49103
|
+
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
49104
|
+
...current,
|
|
49105
|
+
healthProbe: probe
|
|
49106
|
+
}));
|
|
49107
|
+
void (async () => {
|
|
49108
|
+
const attempts = [];
|
|
49109
|
+
for (const candidate of buildLocalProviderProbeUrls(entry)) {
|
|
49110
|
+
const startedAt = Date.now();
|
|
49111
|
+
const attempt = {
|
|
49112
|
+
path: candidate.path,
|
|
49113
|
+
startedAt,
|
|
49114
|
+
completedAt: null,
|
|
49115
|
+
outcome: "pending",
|
|
49116
|
+
status: null,
|
|
49117
|
+
error: null,
|
|
49118
|
+
elapsedMs: null
|
|
49119
|
+
};
|
|
49120
|
+
attempts.push(attempt);
|
|
49121
|
+
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
49122
|
+
...current,
|
|
49123
|
+
healthProbe: {
|
|
49124
|
+
...current.healthProbe ?? probe,
|
|
49125
|
+
attempts: attempts.slice()
|
|
49126
|
+
}
|
|
49127
|
+
}));
|
|
49128
|
+
const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
49129
|
+
const timeoutId = controller ? setTimeout(() => controller.abort(), 2e3) : null;
|
|
49130
|
+
try {
|
|
49131
|
+
const response = await fetch(candidate.url, {
|
|
49132
|
+
method: "GET",
|
|
49133
|
+
signal: controller?.signal
|
|
49134
|
+
});
|
|
49135
|
+
const completedAt2 = Date.now();
|
|
49136
|
+
attempt.completedAt = completedAt2;
|
|
49137
|
+
attempt.outcome = response.ok ? "ok" : "error";
|
|
49138
|
+
attempt.status = response.status;
|
|
49139
|
+
attempt.error = response.ok ? null : `HTTP ${response.status}`;
|
|
49140
|
+
attempt.elapsedMs = Math.max(0, completedAt2 - startedAt);
|
|
49141
|
+
} catch (error48) {
|
|
49142
|
+
const completedAt2 = Date.now();
|
|
49143
|
+
attempt.completedAt = completedAt2;
|
|
49144
|
+
attempt.outcome = "error";
|
|
49145
|
+
attempt.error = getSanitizedRuntimeErrorMessage(error48) || "health probe failed";
|
|
49146
|
+
attempt.elapsedMs = Math.max(0, completedAt2 - startedAt);
|
|
49147
|
+
} finally {
|
|
49148
|
+
if (timeoutId) {
|
|
49149
|
+
clearTimeout(timeoutId);
|
|
49150
|
+
}
|
|
49151
|
+
}
|
|
49152
|
+
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
49153
|
+
...current,
|
|
49154
|
+
healthProbe: {
|
|
49155
|
+
...current.healthProbe ?? probe,
|
|
49156
|
+
attempts: attempts.slice()
|
|
49157
|
+
}
|
|
49158
|
+
}));
|
|
49159
|
+
if (attempt.outcome === "ok") {
|
|
49160
|
+
break;
|
|
49161
|
+
}
|
|
49162
|
+
}
|
|
49163
|
+
const completedAt = Date.now();
|
|
49164
|
+
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
49165
|
+
...current,
|
|
49166
|
+
healthProbe: {
|
|
49167
|
+
...current.healthProbe ?? probe,
|
|
49168
|
+
completedAt,
|
|
49169
|
+
attempts: attempts.slice()
|
|
49170
|
+
}
|
|
49171
|
+
}));
|
|
49172
|
+
})();
|
|
49173
|
+
};
|
|
49174
|
+
compactRuntimePromptString = (value) => {
|
|
49175
|
+
const normalized = sanitizeRuntimeDiagnosticValue(value);
|
|
49176
|
+
const preview = normalized.replace(/\s+/g, " ").trim().slice(0, 220);
|
|
49177
|
+
return `[OMITTED_PROMPT_TEXT chars=${normalized.length}${preview ? ` preview=${JSON.stringify(preview)}` : ""}]`;
|
|
49178
|
+
};
|
|
49179
|
+
shouldCompactRuntimeRequestString = (key, value) => {
|
|
49180
|
+
if (value.length <= 500) {
|
|
49181
|
+
return false;
|
|
49182
|
+
}
|
|
49183
|
+
const normalizedKey = key.trim().toLowerCase();
|
|
49184
|
+
return normalizedKey === "system" || normalizedKey === "instructions" || normalizedKey === "content" || normalizedKey === "text" || normalizedKey === "input" || normalizedKey === "prompt" || normalizedKey.endsWith("_prompt");
|
|
49185
|
+
};
|
|
49186
|
+
sanitizeRuntimeNetworkDebugPayload = (value, options = {}) => {
|
|
49187
|
+
if (value == null) {
|
|
49188
|
+
return value;
|
|
49189
|
+
}
|
|
49190
|
+
if (typeof value === "string") {
|
|
49191
|
+
if (options.compactPromptText && shouldCompactRuntimeRequestString(options.key || "", value)) {
|
|
49192
|
+
return compactRuntimePromptString(value);
|
|
49193
|
+
}
|
|
49194
|
+
return sanitizeRuntimeDiagnosticValue(value);
|
|
49195
|
+
}
|
|
49196
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
49197
|
+
return value;
|
|
49198
|
+
}
|
|
49199
|
+
if (Array.isArray(value)) {
|
|
49200
|
+
return value.map((item) => sanitizeRuntimeNetworkDebugPayload(item, options));
|
|
49201
|
+
}
|
|
49202
|
+
if (typeof value === "object") {
|
|
49203
|
+
const out = {};
|
|
49204
|
+
for (const [key, item] of Object.entries(value)) {
|
|
49205
|
+
const normalizedKey = key.trim().toLowerCase();
|
|
49206
|
+
if (normalizedKey === "authorization" || normalizedKey === "x-api-key" || normalizedKey === "api-key" || normalizedKey === "apikey" || normalizedKey === "signature" || normalizedKey.includes("secret") || normalizedKey.includes("private_key") || normalizedKey.includes("signing_key")) {
|
|
49207
|
+
out[key] = "[REDACTED]";
|
|
49208
|
+
continue;
|
|
49209
|
+
}
|
|
49210
|
+
out[key] = sanitizeRuntimeNetworkDebugPayload(item, {
|
|
49211
|
+
...options,
|
|
49212
|
+
key
|
|
49213
|
+
});
|
|
49214
|
+
}
|
|
49215
|
+
return out;
|
|
49216
|
+
}
|
|
49217
|
+
return sanitizeRuntimeDiagnosticValue(String(value));
|
|
49218
|
+
};
|
|
49219
|
+
getRuntimeNetworkDebugEntries = () => runtimeNetworkDebugEntries.slice();
|
|
49220
|
+
startRuntimeNetworkDebugTrace = (input) => {
|
|
49221
|
+
const { targetProtocol, targetHost, targetPath } = normalizeRuntimeNetworkUrl(input.url);
|
|
49222
|
+
const entry = {
|
|
49223
|
+
id: buildRuntimeNetworkDebugId(),
|
|
49224
|
+
kind: input.kind,
|
|
49225
|
+
label: input.label,
|
|
49226
|
+
transport: "browser",
|
|
49227
|
+
providerTransport: input.kind === "provider" ? input.providerTransport ?? "direct" : null,
|
|
49228
|
+
actualRelayPath: input.kind === "provider" && input.providerTransport === "server_relay" ? "/llm/native-provider-relay" : null,
|
|
49229
|
+
method: (input.method || "POST").toUpperCase(),
|
|
49230
|
+
targetProtocol,
|
|
49231
|
+
targetHost,
|
|
49232
|
+
targetPath,
|
|
49233
|
+
startedAt: Date.now(),
|
|
49234
|
+
completedAt: null,
|
|
49235
|
+
status: null,
|
|
49236
|
+
outcome: "pending",
|
|
49237
|
+
error: null,
|
|
49238
|
+
note: typeof input.note === "string" ? input.note : null,
|
|
49239
|
+
request: null,
|
|
49240
|
+
response: null,
|
|
49241
|
+
browser: {
|
|
49242
|
+
started: readRuntimeNetworkBrowserContext(),
|
|
49243
|
+
completed: null,
|
|
49244
|
+
elapsedMs: null,
|
|
49245
|
+
failureKind: null
|
|
49246
|
+
}
|
|
49247
|
+
};
|
|
49248
|
+
runtimeNetworkDebugEntries = [entry, ...runtimeNetworkDebugEntries].slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES);
|
|
49249
|
+
emitRuntimeNetworkDebugEntries();
|
|
49250
|
+
let completed = false;
|
|
49251
|
+
const finalize2 = (outcome, status, error48) => {
|
|
49252
|
+
if (completed) {
|
|
49253
|
+
return;
|
|
49254
|
+
}
|
|
49255
|
+
completed = true;
|
|
49256
|
+
const completedAt = Date.now();
|
|
49257
|
+
const completedBrowserContext = readRuntimeNetworkBrowserContext();
|
|
49258
|
+
runtimeNetworkDebugEntries = runtimeNetworkDebugEntries.map((candidate) => candidate.id === entry.id ? {
|
|
49259
|
+
...candidate,
|
|
49260
|
+
completedAt,
|
|
49261
|
+
status,
|
|
49262
|
+
outcome,
|
|
49263
|
+
error: error48,
|
|
49264
|
+
browser: candidate.browser ? {
|
|
49265
|
+
...candidate.browser,
|
|
49266
|
+
completed: completedBrowserContext,
|
|
49267
|
+
elapsedMs: Math.max(0, completedAt - candidate.startedAt),
|
|
49268
|
+
failureKind: outcome === "error" ? classifyRuntimeNetworkFailure(error48, status) : null
|
|
49269
|
+
} : null
|
|
49270
|
+
} : candidate);
|
|
49271
|
+
emitRuntimeNetworkDebugEntries();
|
|
49272
|
+
const failedProviderEntry = runtimeNetworkDebugEntries.find((candidate) => candidate.id === entry.id && candidate.kind === "provider" && candidate.outcome === "error");
|
|
49273
|
+
if (failedProviderEntry) {
|
|
49274
|
+
const providerFailureEntry = {
|
|
49275
|
+
...failedProviderEntry,
|
|
49276
|
+
healthProbe: null
|
|
49277
|
+
};
|
|
49278
|
+
runtimeProviderFailureDebugEntries = [
|
|
49279
|
+
providerFailureEntry,
|
|
49280
|
+
...runtimeProviderFailureDebugEntries.filter((candidate) => candidate.id !== providerFailureEntry.id)
|
|
49281
|
+
].slice(0, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES);
|
|
49282
|
+
emitRuntimeProviderFailureDebugEntries();
|
|
49283
|
+
runLocalProviderFailureHealthProbe(providerFailureEntry);
|
|
49284
|
+
}
|
|
49285
|
+
const failedMarketDataEntry = runtimeNetworkDebugEntries.find((candidate) => candidate.id === entry.id && isRuntimeMarketDataFailureDebugEntry(candidate));
|
|
49286
|
+
if (failedMarketDataEntry) {
|
|
49287
|
+
runtimeMarketDataFailureDebugEntries = [
|
|
49288
|
+
failedMarketDataEntry,
|
|
49289
|
+
...runtimeMarketDataFailureDebugEntries.filter((candidate) => candidate.id !== failedMarketDataEntry.id)
|
|
49290
|
+
].slice(0, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES);
|
|
49291
|
+
emitRuntimeMarketDataFailureDebugEntries();
|
|
49292
|
+
}
|
|
49293
|
+
};
|
|
49294
|
+
const attachPayload = (field, payload) => {
|
|
49295
|
+
runtimeNetworkDebugEntries = runtimeNetworkDebugEntries.map((candidate) => candidate.id === entry.id ? {
|
|
49296
|
+
...candidate,
|
|
49297
|
+
[field]: sanitizeRuntimeNetworkDebugPayload(payload, {
|
|
49298
|
+
compactPromptText: field === "request"
|
|
49299
|
+
})
|
|
49300
|
+
} : candidate);
|
|
49301
|
+
emitRuntimeNetworkDebugEntries();
|
|
49302
|
+
};
|
|
49303
|
+
return {
|
|
49304
|
+
id: entry.id,
|
|
49305
|
+
attachRequest: (payload) => attachPayload("request", payload),
|
|
49306
|
+
attachResponse: (payload) => attachPayload("response", payload),
|
|
49307
|
+
completeSuccess: (status) => finalize2("ok", typeof status === "number" ? status : null, null),
|
|
49308
|
+
completeError: (error48, status) => {
|
|
49309
|
+
const message = getSanitizedRuntimeErrorMessage(error48);
|
|
49310
|
+
finalize2("error", typeof status === "number" ? status : null, message);
|
|
49311
|
+
}
|
|
49312
|
+
};
|
|
49313
|
+
};
|
|
49314
|
+
appendRuntimeDebugEvent = (input) => {
|
|
49315
|
+
const outcome = input.outcome === "error" ? "error" : "ok";
|
|
49316
|
+
const entry = {
|
|
49317
|
+
id: buildRuntimeNetworkDebugId(),
|
|
49318
|
+
kind: "runtime",
|
|
49319
|
+
label: String(input.label || "runtime_event").trim() || "runtime_event",
|
|
49320
|
+
transport: "browser",
|
|
49321
|
+
method: "TRACE",
|
|
49322
|
+
targetProtocol: null,
|
|
49323
|
+
targetHost: "client-runtime",
|
|
49324
|
+
targetPath: "/runtime",
|
|
49325
|
+
startedAt: Date.now(),
|
|
49326
|
+
completedAt: Date.now(),
|
|
49327
|
+
status: null,
|
|
49328
|
+
outcome,
|
|
49329
|
+
error: null,
|
|
49330
|
+
note: typeof input.note === "string" && input.note.trim().length > 0 ? input.note.trim() : null,
|
|
49331
|
+
request: null,
|
|
49332
|
+
response: null,
|
|
49333
|
+
browser: {
|
|
49334
|
+
started: readRuntimeNetworkBrowserContext(),
|
|
49335
|
+
completed: readRuntimeNetworkBrowserContext(),
|
|
49336
|
+
elapsedMs: 0,
|
|
49337
|
+
failureKind: null
|
|
49338
|
+
}
|
|
49339
|
+
};
|
|
49340
|
+
runtimeNetworkDebugEntries = [entry, ...runtimeNetworkDebugEntries].slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES);
|
|
49341
|
+
emitRuntimeNetworkDebugEntries({ persist: outcome === "error" });
|
|
49342
|
+
};
|
|
49343
|
+
}
|
|
49344
|
+
});
|
|
49345
|
+
|
|
49346
|
+
// lib/runtime/sl-tp-execution-settings.ts
|
|
49347
|
+
var resolveBooleanSetting, resolvePositiveNumberSetting, resolveRiskModeSetting, resolveStopLossTypeSetting, buildRuntimeSlTpExecutionSettings;
|
|
49348
|
+
var init_sl_tp_execution_settings = __esm({
|
|
49349
|
+
"lib/runtime/sl-tp-execution-settings.ts"() {
|
|
49350
|
+
"use strict";
|
|
49351
|
+
init_define_VTX_EXO_POLICY();
|
|
49352
|
+
init_define_VTX_GROK_POLICY();
|
|
49353
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
49354
|
+
resolveBooleanSetting = (settings, key, fallback) => {
|
|
49355
|
+
if (Object.prototype.hasOwnProperty.call(settings, key)) {
|
|
49356
|
+
return settings[key] === true;
|
|
49357
|
+
}
|
|
49358
|
+
return fallback === true;
|
|
49359
|
+
};
|
|
49360
|
+
resolvePositiveNumberSetting = (settings, key, fallback) => {
|
|
49361
|
+
const raw = Object.prototype.hasOwnProperty.call(settings, key) ? settings[key] : fallback;
|
|
49362
|
+
const parsed = Number(raw);
|
|
49363
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
49364
|
+
};
|
|
49365
|
+
resolveRiskModeSetting = (settings, key, fallback) => {
|
|
49366
|
+
const normalized = String(Object.prototype.hasOwnProperty.call(settings, key) ? settings[key] : fallback).trim().toLowerCase();
|
|
49367
|
+
return normalized === "usdc" ? "usdc" : "percent";
|
|
49368
|
+
};
|
|
49369
|
+
resolveStopLossTypeSetting = (settings, fallback) => {
|
|
49370
|
+
const normalized = String(
|
|
49371
|
+
Object.prototype.hasOwnProperty.call(settings, "stop_loss_type") ? settings.stop_loss_type : fallback
|
|
49372
|
+
).trim().toLowerCase();
|
|
49373
|
+
return normalized === "trailing" ? "trailing" : "fixed";
|
|
49374
|
+
};
|
|
49375
|
+
buildRuntimeSlTpExecutionSettings = (settings, config2) => ({
|
|
49376
|
+
tpSlEnabled: resolveBooleanSetting(
|
|
49377
|
+
settings,
|
|
49378
|
+
"tp_sl_enabled",
|
|
49379
|
+
config2.default_ai_tp_sl_enabled ?? config2.default_tp_sl_enabled
|
|
49380
|
+
),
|
|
49381
|
+
stopLossEnabled: resolveBooleanSetting(settings, "sl_enabled", config2.default_sl_enabled),
|
|
49382
|
+
stopLossType: resolveStopLossTypeSetting(settings, config2.default_stop_loss_type),
|
|
49383
|
+
stopLossMode: resolveRiskModeSetting(settings, "stop_loss_mode", config2.default_stop_loss_mode),
|
|
49384
|
+
stopLossPct: resolvePositiveNumberSetting(settings, "stop_loss_pct", config2.default_stop_loss_pct),
|
|
49385
|
+
stopLossUsdc: resolvePositiveNumberSetting(settings, "stop_loss_usdc", config2.default_stop_loss_usdc),
|
|
49386
|
+
takeProfitEnabled: resolveBooleanSetting(settings, "tp_enabled", config2.default_tp_enabled),
|
|
49387
|
+
takeProfitMode: resolveRiskModeSetting(settings, "take_profit_mode", config2.default_take_profit_mode),
|
|
49388
|
+
takeProfitPct: resolvePositiveNumberSetting(settings, "take_profit_pct", config2.default_take_profit_pct),
|
|
49389
|
+
takeProfitUsdc: resolvePositiveNumberSetting(settings, "take_profit_usdc", config2.default_take_profit_usdc)
|
|
49390
|
+
});
|
|
49391
|
+
}
|
|
49392
|
+
});
|
|
49393
|
+
|
|
48872
49394
|
// lib/runtime/hyperliquid-public-read.ts
|
|
48873
49395
|
var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, priorityRank, createHyperliquidPublicPriorityScope, promoteHyperliquidPublicPriority, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, fallbackDelayMs, admit, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
48874
49396
|
var init_hyperliquid_public_read = __esm({
|
|
@@ -49930,472 +50452,6 @@ var init_hyperliquid_fee_contract = __esm({
|
|
|
49930
50452
|
}
|
|
49931
50453
|
});
|
|
49932
50454
|
|
|
49933
|
-
// lib/runtime/channel-sender.ts
|
|
49934
|
-
var RUNTIME_TAB_ID_STORAGE_KEY, createRuntimeUuid, getOrCreateRuntimeTabSenderId;
|
|
49935
|
-
var init_channel_sender = __esm({
|
|
49936
|
-
"lib/runtime/channel-sender.ts"() {
|
|
49937
|
-
"use strict";
|
|
49938
|
-
init_define_VTX_EXO_POLICY();
|
|
49939
|
-
init_define_VTX_GROK_POLICY();
|
|
49940
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
49941
|
-
RUNTIME_TAB_ID_STORAGE_KEY = "vtx_client_runtime_tab_id";
|
|
49942
|
-
createRuntimeUuid = () => {
|
|
49943
|
-
if (typeof globalThis.crypto !== "undefined" && typeof globalThis.crypto.randomUUID === "function") {
|
|
49944
|
-
return globalThis.crypto.randomUUID();
|
|
49945
|
-
}
|
|
49946
|
-
return `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
49947
|
-
};
|
|
49948
|
-
getOrCreateRuntimeTabSenderId = () => {
|
|
49949
|
-
if (typeof window === "undefined") {
|
|
49950
|
-
return null;
|
|
49951
|
-
}
|
|
49952
|
-
try {
|
|
49953
|
-
const stored = window.sessionStorage.getItem(RUNTIME_TAB_ID_STORAGE_KEY);
|
|
49954
|
-
if (stored && stored.trim()) {
|
|
49955
|
-
return stored;
|
|
49956
|
-
}
|
|
49957
|
-
const created = createRuntimeUuid();
|
|
49958
|
-
window.sessionStorage.setItem(RUNTIME_TAB_ID_STORAGE_KEY, created);
|
|
49959
|
-
return created;
|
|
49960
|
-
} catch {
|
|
49961
|
-
return null;
|
|
49962
|
-
}
|
|
49963
|
-
};
|
|
49964
|
-
}
|
|
49965
|
-
});
|
|
49966
|
-
|
|
49967
|
-
// lib/runtime/network-debug.ts
|
|
49968
|
-
var MAX_RUNTIME_NETWORK_DEBUG_ENTRIES, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES, RUNTIME_NETWORK_DEBUG_STORAGE_KEY, RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY, RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY, runtimeNetworkDebugEntries, runtimeProviderFailureDebugEntries, runtimeMarketDataFailureDebugEntries, runtimeNetworkDebugListeners, isRuntimeMarketDataFailureDebugEntry, persistRuntimeNetworkDebugEntries, persistRuntimeProviderFailureDebugEntries, persistRuntimeMarketDataFailureDebugEntries, emitRuntimeNetworkDebugEntries, emitRuntimeProviderFailureDebugEntries, emitRuntimeMarketDataFailureDebugEntries, buildRuntimeNetworkDebugId, normalizeRuntimeNetworkUrl, readRuntimeNetworkBrowserContext, classifyRuntimeNetworkFailure, isLocalProviderFailureProbeCandidate, buildLocalProviderProbeUrls, patchRuntimeProviderFailureDebugEntry, runLocalProviderFailureHealthProbe, compactRuntimePromptString, shouldCompactRuntimeRequestString, sanitizeRuntimeNetworkDebugPayload, getRuntimeNetworkDebugEntries, startRuntimeNetworkDebugTrace, appendRuntimeDebugEvent;
|
|
49969
|
-
var init_network_debug = __esm({
|
|
49970
|
-
"lib/runtime/network-debug.ts"() {
|
|
49971
|
-
"use strict";
|
|
49972
|
-
init_define_VTX_EXO_POLICY();
|
|
49973
|
-
init_define_VTX_GROK_POLICY();
|
|
49974
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
49975
|
-
init_runtime_redaction();
|
|
49976
|
-
init_channel_sender();
|
|
49977
|
-
MAX_RUNTIME_NETWORK_DEBUG_ENTRIES = 80;
|
|
49978
|
-
MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES = 20;
|
|
49979
|
-
MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES = 20;
|
|
49980
|
-
RUNTIME_NETWORK_DEBUG_STORAGE_KEY = "vtx_client_runtime_network_debug_entries_v1";
|
|
49981
|
-
RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY = "vtx_client_runtime_provider_failure_debug_entries_v1";
|
|
49982
|
-
RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY = "vtx_client_runtime_market_data_failure_debug_entries_v1";
|
|
49983
|
-
runtimeNetworkDebugEntries = [];
|
|
49984
|
-
runtimeProviderFailureDebugEntries = [];
|
|
49985
|
-
runtimeMarketDataFailureDebugEntries = [];
|
|
49986
|
-
runtimeNetworkDebugListeners = /* @__PURE__ */ new Set();
|
|
49987
|
-
isRuntimeMarketDataFailureDebugEntry = (entry) => entry.kind === "runtime" && entry.label.startsWith("market_data_api:") && entry.outcome === "error";
|
|
49988
|
-
persistRuntimeNetworkDebugEntries = () => {
|
|
49989
|
-
if (typeof window === "undefined") {
|
|
49990
|
-
return;
|
|
49991
|
-
}
|
|
49992
|
-
try {
|
|
49993
|
-
window.localStorage.setItem(
|
|
49994
|
-
RUNTIME_NETWORK_DEBUG_STORAGE_KEY,
|
|
49995
|
-
JSON.stringify(runtimeNetworkDebugEntries.slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES))
|
|
49996
|
-
);
|
|
49997
|
-
} catch {
|
|
49998
|
-
}
|
|
49999
|
-
};
|
|
50000
|
-
persistRuntimeProviderFailureDebugEntries = () => {
|
|
50001
|
-
if (typeof window === "undefined") {
|
|
50002
|
-
return;
|
|
50003
|
-
}
|
|
50004
|
-
try {
|
|
50005
|
-
window.localStorage.setItem(
|
|
50006
|
-
RUNTIME_PROVIDER_FAILURE_DEBUG_STORAGE_KEY,
|
|
50007
|
-
JSON.stringify(runtimeProviderFailureDebugEntries.slice(0, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES))
|
|
50008
|
-
);
|
|
50009
|
-
} catch {
|
|
50010
|
-
}
|
|
50011
|
-
};
|
|
50012
|
-
persistRuntimeMarketDataFailureDebugEntries = () => {
|
|
50013
|
-
if (typeof window === "undefined") {
|
|
50014
|
-
return;
|
|
50015
|
-
}
|
|
50016
|
-
try {
|
|
50017
|
-
window.localStorage.setItem(
|
|
50018
|
-
RUNTIME_MARKET_DATA_FAILURE_DEBUG_STORAGE_KEY,
|
|
50019
|
-
JSON.stringify(runtimeMarketDataFailureDebugEntries.slice(0, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES))
|
|
50020
|
-
);
|
|
50021
|
-
} catch {
|
|
50022
|
-
}
|
|
50023
|
-
};
|
|
50024
|
-
emitRuntimeNetworkDebugEntries = (options = {}) => {
|
|
50025
|
-
if (options.persist !== false) {
|
|
50026
|
-
persistRuntimeNetworkDebugEntries();
|
|
50027
|
-
}
|
|
50028
|
-
const snapshot = getRuntimeNetworkDebugEntries();
|
|
50029
|
-
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
50030
|
-
};
|
|
50031
|
-
emitRuntimeProviderFailureDebugEntries = (options = {}) => {
|
|
50032
|
-
if (options.persist !== false) {
|
|
50033
|
-
persistRuntimeProviderFailureDebugEntries();
|
|
50034
|
-
}
|
|
50035
|
-
const snapshot = getRuntimeNetworkDebugEntries();
|
|
50036
|
-
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
50037
|
-
};
|
|
50038
|
-
emitRuntimeMarketDataFailureDebugEntries = (options = {}) => {
|
|
50039
|
-
if (options.persist !== false) {
|
|
50040
|
-
persistRuntimeMarketDataFailureDebugEntries();
|
|
50041
|
-
}
|
|
50042
|
-
const snapshot = getRuntimeNetworkDebugEntries();
|
|
50043
|
-
runtimeNetworkDebugListeners.forEach((listener) => listener(snapshot));
|
|
50044
|
-
};
|
|
50045
|
-
buildRuntimeNetworkDebugId = () => {
|
|
50046
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
50047
|
-
return crypto.randomUUID();
|
|
50048
|
-
}
|
|
50049
|
-
return `runtime-net-${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
50050
|
-
};
|
|
50051
|
-
normalizeRuntimeNetworkUrl = (value) => {
|
|
50052
|
-
try {
|
|
50053
|
-
const parsed = new URL(value);
|
|
50054
|
-
return {
|
|
50055
|
-
targetProtocol: parsed.protocol ? parsed.protocol.replace(/:$/, "").toLowerCase() : null,
|
|
50056
|
-
targetHost: parsed.host || "unknown-host",
|
|
50057
|
-
targetPath: sanitizeRuntimeNetworkPath(parsed.pathname || "/")
|
|
50058
|
-
};
|
|
50059
|
-
} catch {
|
|
50060
|
-
return {
|
|
50061
|
-
targetProtocol: null,
|
|
50062
|
-
targetHost: "invalid-url",
|
|
50063
|
-
targetPath: sanitizeRuntimeNetworkPath(value)
|
|
50064
|
-
};
|
|
50065
|
-
}
|
|
50066
|
-
};
|
|
50067
|
-
readRuntimeNetworkBrowserContext = () => {
|
|
50068
|
-
if (typeof window === "undefined") {
|
|
50069
|
-
return {
|
|
50070
|
-
tabId: null,
|
|
50071
|
-
online: null,
|
|
50072
|
-
visibilityState: null,
|
|
50073
|
-
hidden: null,
|
|
50074
|
-
focused: null,
|
|
50075
|
-
pageHost: null,
|
|
50076
|
-
connectionEffectiveType: null,
|
|
50077
|
-
connectionDownlink: null,
|
|
50078
|
-
connectionRtt: null
|
|
50079
|
-
};
|
|
50080
|
-
}
|
|
50081
|
-
const nav = typeof navigator !== "undefined" ? navigator : null;
|
|
50082
|
-
const connection = nav && typeof nav === "object" ? nav.connection : null;
|
|
50083
|
-
let tabId = null;
|
|
50084
|
-
try {
|
|
50085
|
-
tabId = getOrCreateRuntimeTabSenderId() || null;
|
|
50086
|
-
} catch {
|
|
50087
|
-
tabId = null;
|
|
50088
|
-
}
|
|
50089
|
-
return {
|
|
50090
|
-
tabId,
|
|
50091
|
-
online: nav && typeof nav.onLine === "boolean" ? nav.onLine : null,
|
|
50092
|
-
visibilityState: typeof document !== "undefined" && typeof document.visibilityState === "string" ? document.visibilityState : null,
|
|
50093
|
-
hidden: typeof document !== "undefined" && typeof document.hidden === "boolean" ? document.hidden : null,
|
|
50094
|
-
focused: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : null,
|
|
50095
|
-
pageHost: window.location?.host || null,
|
|
50096
|
-
connectionEffectiveType: typeof connection?.effectiveType === "string" ? connection.effectiveType : null,
|
|
50097
|
-
connectionDownlink: Number.isFinite(Number(connection?.downlink)) ? Number(connection?.downlink) : null,
|
|
50098
|
-
connectionRtt: Number.isFinite(Number(connection?.rtt)) ? Number(connection?.rtt) : null
|
|
50099
|
-
};
|
|
50100
|
-
};
|
|
50101
|
-
classifyRuntimeNetworkFailure = (error48, status) => {
|
|
50102
|
-
if (status != null) {
|
|
50103
|
-
return `http_${status}`;
|
|
50104
|
-
}
|
|
50105
|
-
if (!error48) {
|
|
50106
|
-
return null;
|
|
50107
|
-
}
|
|
50108
|
-
const normalized = error48.toLowerCase();
|
|
50109
|
-
if (normalized.includes("abort")) {
|
|
50110
|
-
return "abort";
|
|
50111
|
-
}
|
|
50112
|
-
if (normalized.includes("cors")) {
|
|
50113
|
-
return "cors";
|
|
50114
|
-
}
|
|
50115
|
-
if (normalized.includes("failed to fetch") || normalized.includes("networkerror")) {
|
|
50116
|
-
return "fetch_failed";
|
|
50117
|
-
}
|
|
50118
|
-
if (normalized.includes("load failed") || normalized.includes("network request failed")) {
|
|
50119
|
-
return "network_failed";
|
|
50120
|
-
}
|
|
50121
|
-
return "error";
|
|
50122
|
-
};
|
|
50123
|
-
isLocalProviderFailureProbeCandidate = (entry) => {
|
|
50124
|
-
if (entry.kind !== "provider" || entry.label !== "local" || entry.status != null) {
|
|
50125
|
-
return false;
|
|
50126
|
-
}
|
|
50127
|
-
const host = entry.targetHost.toLowerCase();
|
|
50128
|
-
if (host.startsWith("127.0.0.1:") || host === "127.0.0.1" || host.startsWith("localhost:") || host === "localhost" || host.startsWith("[::1]:") || host === "[::1]") {
|
|
50129
|
-
return true;
|
|
50130
|
-
}
|
|
50131
|
-
return false;
|
|
50132
|
-
};
|
|
50133
|
-
buildLocalProviderProbeUrls = (entry) => {
|
|
50134
|
-
const protocol = entry.targetProtocol === "https" ? "https" : "http";
|
|
50135
|
-
const origin = `${protocol}://${entry.targetHost}`;
|
|
50136
|
-
return [
|
|
50137
|
-
{ path: "/api/v0/models", url: `${origin}/api/v0/models` },
|
|
50138
|
-
{ path: "/v1/models", url: `${origin}/v1/models` }
|
|
50139
|
-
];
|
|
50140
|
-
};
|
|
50141
|
-
patchRuntimeProviderFailureDebugEntry = (id2, patcher) => {
|
|
50142
|
-
runtimeProviderFailureDebugEntries = runtimeProviderFailureDebugEntries.map((entry) => entry.id === id2 ? patcher(entry) : entry);
|
|
50143
|
-
emitRuntimeProviderFailureDebugEntries();
|
|
50144
|
-
};
|
|
50145
|
-
runLocalProviderFailureHealthProbe = (entry) => {
|
|
50146
|
-
if (typeof fetch !== "function" || !isLocalProviderFailureProbeCandidate(entry)) {
|
|
50147
|
-
return;
|
|
50148
|
-
}
|
|
50149
|
-
const probeStartedAt = Date.now();
|
|
50150
|
-
const probe = {
|
|
50151
|
-
reason: "local_provider_network_failure",
|
|
50152
|
-
startedAt: probeStartedAt,
|
|
50153
|
-
completedAt: null,
|
|
50154
|
-
attempts: []
|
|
50155
|
-
};
|
|
50156
|
-
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
50157
|
-
...current,
|
|
50158
|
-
healthProbe: probe
|
|
50159
|
-
}));
|
|
50160
|
-
void (async () => {
|
|
50161
|
-
const attempts = [];
|
|
50162
|
-
for (const candidate of buildLocalProviderProbeUrls(entry)) {
|
|
50163
|
-
const startedAt = Date.now();
|
|
50164
|
-
const attempt = {
|
|
50165
|
-
path: candidate.path,
|
|
50166
|
-
startedAt,
|
|
50167
|
-
completedAt: null,
|
|
50168
|
-
outcome: "pending",
|
|
50169
|
-
status: null,
|
|
50170
|
-
error: null,
|
|
50171
|
-
elapsedMs: null
|
|
50172
|
-
};
|
|
50173
|
-
attempts.push(attempt);
|
|
50174
|
-
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
50175
|
-
...current,
|
|
50176
|
-
healthProbe: {
|
|
50177
|
-
...current.healthProbe ?? probe,
|
|
50178
|
-
attempts: attempts.slice()
|
|
50179
|
-
}
|
|
50180
|
-
}));
|
|
50181
|
-
const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
50182
|
-
const timeoutId = controller ? setTimeout(() => controller.abort(), 2e3) : null;
|
|
50183
|
-
try {
|
|
50184
|
-
const response = await fetch(candidate.url, {
|
|
50185
|
-
method: "GET",
|
|
50186
|
-
signal: controller?.signal
|
|
50187
|
-
});
|
|
50188
|
-
const completedAt2 = Date.now();
|
|
50189
|
-
attempt.completedAt = completedAt2;
|
|
50190
|
-
attempt.outcome = response.ok ? "ok" : "error";
|
|
50191
|
-
attempt.status = response.status;
|
|
50192
|
-
attempt.error = response.ok ? null : `HTTP ${response.status}`;
|
|
50193
|
-
attempt.elapsedMs = Math.max(0, completedAt2 - startedAt);
|
|
50194
|
-
} catch (error48) {
|
|
50195
|
-
const completedAt2 = Date.now();
|
|
50196
|
-
attempt.completedAt = completedAt2;
|
|
50197
|
-
attempt.outcome = "error";
|
|
50198
|
-
attempt.error = getSanitizedRuntimeErrorMessage(error48) || "health probe failed";
|
|
50199
|
-
attempt.elapsedMs = Math.max(0, completedAt2 - startedAt);
|
|
50200
|
-
} finally {
|
|
50201
|
-
if (timeoutId) {
|
|
50202
|
-
clearTimeout(timeoutId);
|
|
50203
|
-
}
|
|
50204
|
-
}
|
|
50205
|
-
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
50206
|
-
...current,
|
|
50207
|
-
healthProbe: {
|
|
50208
|
-
...current.healthProbe ?? probe,
|
|
50209
|
-
attempts: attempts.slice()
|
|
50210
|
-
}
|
|
50211
|
-
}));
|
|
50212
|
-
if (attempt.outcome === "ok") {
|
|
50213
|
-
break;
|
|
50214
|
-
}
|
|
50215
|
-
}
|
|
50216
|
-
const completedAt = Date.now();
|
|
50217
|
-
patchRuntimeProviderFailureDebugEntry(entry.id, (current) => ({
|
|
50218
|
-
...current,
|
|
50219
|
-
healthProbe: {
|
|
50220
|
-
...current.healthProbe ?? probe,
|
|
50221
|
-
completedAt,
|
|
50222
|
-
attempts: attempts.slice()
|
|
50223
|
-
}
|
|
50224
|
-
}));
|
|
50225
|
-
})();
|
|
50226
|
-
};
|
|
50227
|
-
compactRuntimePromptString = (value) => {
|
|
50228
|
-
const normalized = sanitizeRuntimeDiagnosticValue(value);
|
|
50229
|
-
const preview = normalized.replace(/\s+/g, " ").trim().slice(0, 220);
|
|
50230
|
-
return `[OMITTED_PROMPT_TEXT chars=${normalized.length}${preview ? ` preview=${JSON.stringify(preview)}` : ""}]`;
|
|
50231
|
-
};
|
|
50232
|
-
shouldCompactRuntimeRequestString = (key, value) => {
|
|
50233
|
-
if (value.length <= 500) {
|
|
50234
|
-
return false;
|
|
50235
|
-
}
|
|
50236
|
-
const normalizedKey = key.trim().toLowerCase();
|
|
50237
|
-
return normalizedKey === "system" || normalizedKey === "instructions" || normalizedKey === "content" || normalizedKey === "text" || normalizedKey === "input" || normalizedKey === "prompt" || normalizedKey.endsWith("_prompt");
|
|
50238
|
-
};
|
|
50239
|
-
sanitizeRuntimeNetworkDebugPayload = (value, options = {}) => {
|
|
50240
|
-
if (value == null) {
|
|
50241
|
-
return value;
|
|
50242
|
-
}
|
|
50243
|
-
if (typeof value === "string") {
|
|
50244
|
-
if (options.compactPromptText && shouldCompactRuntimeRequestString(options.key || "", value)) {
|
|
50245
|
-
return compactRuntimePromptString(value);
|
|
50246
|
-
}
|
|
50247
|
-
return sanitizeRuntimeDiagnosticValue(value);
|
|
50248
|
-
}
|
|
50249
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
50250
|
-
return value;
|
|
50251
|
-
}
|
|
50252
|
-
if (Array.isArray(value)) {
|
|
50253
|
-
return value.map((item) => sanitizeRuntimeNetworkDebugPayload(item, options));
|
|
50254
|
-
}
|
|
50255
|
-
if (typeof value === "object") {
|
|
50256
|
-
const out = {};
|
|
50257
|
-
for (const [key, item] of Object.entries(value)) {
|
|
50258
|
-
const normalizedKey = key.trim().toLowerCase();
|
|
50259
|
-
if (normalizedKey === "authorization" || normalizedKey === "x-api-key" || normalizedKey === "api-key" || normalizedKey === "apikey" || normalizedKey === "signature" || normalizedKey.includes("secret") || normalizedKey.includes("private_key") || normalizedKey.includes("signing_key")) {
|
|
50260
|
-
out[key] = "[REDACTED]";
|
|
50261
|
-
continue;
|
|
50262
|
-
}
|
|
50263
|
-
out[key] = sanitizeRuntimeNetworkDebugPayload(item, {
|
|
50264
|
-
...options,
|
|
50265
|
-
key
|
|
50266
|
-
});
|
|
50267
|
-
}
|
|
50268
|
-
return out;
|
|
50269
|
-
}
|
|
50270
|
-
return sanitizeRuntimeDiagnosticValue(String(value));
|
|
50271
|
-
};
|
|
50272
|
-
getRuntimeNetworkDebugEntries = () => runtimeNetworkDebugEntries.slice();
|
|
50273
|
-
startRuntimeNetworkDebugTrace = (input) => {
|
|
50274
|
-
const { targetProtocol, targetHost, targetPath } = normalizeRuntimeNetworkUrl(input.url);
|
|
50275
|
-
const entry = {
|
|
50276
|
-
id: buildRuntimeNetworkDebugId(),
|
|
50277
|
-
kind: input.kind,
|
|
50278
|
-
label: input.label,
|
|
50279
|
-
transport: "browser",
|
|
50280
|
-
providerTransport: input.kind === "provider" ? input.providerTransport ?? "direct" : null,
|
|
50281
|
-
actualRelayPath: input.kind === "provider" && input.providerTransport === "server_relay" ? "/llm/native-provider-relay" : null,
|
|
50282
|
-
method: (input.method || "POST").toUpperCase(),
|
|
50283
|
-
targetProtocol,
|
|
50284
|
-
targetHost,
|
|
50285
|
-
targetPath,
|
|
50286
|
-
startedAt: Date.now(),
|
|
50287
|
-
completedAt: null,
|
|
50288
|
-
status: null,
|
|
50289
|
-
outcome: "pending",
|
|
50290
|
-
error: null,
|
|
50291
|
-
note: typeof input.note === "string" ? input.note : null,
|
|
50292
|
-
request: null,
|
|
50293
|
-
response: null,
|
|
50294
|
-
browser: {
|
|
50295
|
-
started: readRuntimeNetworkBrowserContext(),
|
|
50296
|
-
completed: null,
|
|
50297
|
-
elapsedMs: null,
|
|
50298
|
-
failureKind: null
|
|
50299
|
-
}
|
|
50300
|
-
};
|
|
50301
|
-
runtimeNetworkDebugEntries = [entry, ...runtimeNetworkDebugEntries].slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES);
|
|
50302
|
-
emitRuntimeNetworkDebugEntries();
|
|
50303
|
-
let completed = false;
|
|
50304
|
-
const finalize2 = (outcome, status, error48) => {
|
|
50305
|
-
if (completed) {
|
|
50306
|
-
return;
|
|
50307
|
-
}
|
|
50308
|
-
completed = true;
|
|
50309
|
-
const completedAt = Date.now();
|
|
50310
|
-
const completedBrowserContext = readRuntimeNetworkBrowserContext();
|
|
50311
|
-
runtimeNetworkDebugEntries = runtimeNetworkDebugEntries.map((candidate) => candidate.id === entry.id ? {
|
|
50312
|
-
...candidate,
|
|
50313
|
-
completedAt,
|
|
50314
|
-
status,
|
|
50315
|
-
outcome,
|
|
50316
|
-
error: error48,
|
|
50317
|
-
browser: candidate.browser ? {
|
|
50318
|
-
...candidate.browser,
|
|
50319
|
-
completed: completedBrowserContext,
|
|
50320
|
-
elapsedMs: Math.max(0, completedAt - candidate.startedAt),
|
|
50321
|
-
failureKind: outcome === "error" ? classifyRuntimeNetworkFailure(error48, status) : null
|
|
50322
|
-
} : null
|
|
50323
|
-
} : candidate);
|
|
50324
|
-
emitRuntimeNetworkDebugEntries();
|
|
50325
|
-
const failedProviderEntry = runtimeNetworkDebugEntries.find((candidate) => candidate.id === entry.id && candidate.kind === "provider" && candidate.outcome === "error");
|
|
50326
|
-
if (failedProviderEntry) {
|
|
50327
|
-
const providerFailureEntry = {
|
|
50328
|
-
...failedProviderEntry,
|
|
50329
|
-
healthProbe: null
|
|
50330
|
-
};
|
|
50331
|
-
runtimeProviderFailureDebugEntries = [
|
|
50332
|
-
providerFailureEntry,
|
|
50333
|
-
...runtimeProviderFailureDebugEntries.filter((candidate) => candidate.id !== providerFailureEntry.id)
|
|
50334
|
-
].slice(0, MAX_RUNTIME_PROVIDER_FAILURE_DEBUG_ENTRIES);
|
|
50335
|
-
emitRuntimeProviderFailureDebugEntries();
|
|
50336
|
-
runLocalProviderFailureHealthProbe(providerFailureEntry);
|
|
50337
|
-
}
|
|
50338
|
-
const failedMarketDataEntry = runtimeNetworkDebugEntries.find((candidate) => candidate.id === entry.id && isRuntimeMarketDataFailureDebugEntry(candidate));
|
|
50339
|
-
if (failedMarketDataEntry) {
|
|
50340
|
-
runtimeMarketDataFailureDebugEntries = [
|
|
50341
|
-
failedMarketDataEntry,
|
|
50342
|
-
...runtimeMarketDataFailureDebugEntries.filter((candidate) => candidate.id !== failedMarketDataEntry.id)
|
|
50343
|
-
].slice(0, MAX_RUNTIME_MARKET_DATA_FAILURE_DEBUG_ENTRIES);
|
|
50344
|
-
emitRuntimeMarketDataFailureDebugEntries();
|
|
50345
|
-
}
|
|
50346
|
-
};
|
|
50347
|
-
const attachPayload = (field, payload) => {
|
|
50348
|
-
runtimeNetworkDebugEntries = runtimeNetworkDebugEntries.map((candidate) => candidate.id === entry.id ? {
|
|
50349
|
-
...candidate,
|
|
50350
|
-
[field]: sanitizeRuntimeNetworkDebugPayload(payload, {
|
|
50351
|
-
compactPromptText: field === "request"
|
|
50352
|
-
})
|
|
50353
|
-
} : candidate);
|
|
50354
|
-
emitRuntimeNetworkDebugEntries();
|
|
50355
|
-
};
|
|
50356
|
-
return {
|
|
50357
|
-
id: entry.id,
|
|
50358
|
-
attachRequest: (payload) => attachPayload("request", payload),
|
|
50359
|
-
attachResponse: (payload) => attachPayload("response", payload),
|
|
50360
|
-
completeSuccess: (status) => finalize2("ok", typeof status === "number" ? status : null, null),
|
|
50361
|
-
completeError: (error48, status) => {
|
|
50362
|
-
const message = getSanitizedRuntimeErrorMessage(error48);
|
|
50363
|
-
finalize2("error", typeof status === "number" ? status : null, message);
|
|
50364
|
-
}
|
|
50365
|
-
};
|
|
50366
|
-
};
|
|
50367
|
-
appendRuntimeDebugEvent = (input) => {
|
|
50368
|
-
const outcome = input.outcome === "error" ? "error" : "ok";
|
|
50369
|
-
const entry = {
|
|
50370
|
-
id: buildRuntimeNetworkDebugId(),
|
|
50371
|
-
kind: "runtime",
|
|
50372
|
-
label: String(input.label || "runtime_event").trim() || "runtime_event",
|
|
50373
|
-
transport: "browser",
|
|
50374
|
-
method: "TRACE",
|
|
50375
|
-
targetProtocol: null,
|
|
50376
|
-
targetHost: "client-runtime",
|
|
50377
|
-
targetPath: "/runtime",
|
|
50378
|
-
startedAt: Date.now(),
|
|
50379
|
-
completedAt: Date.now(),
|
|
50380
|
-
status: null,
|
|
50381
|
-
outcome,
|
|
50382
|
-
error: null,
|
|
50383
|
-
note: typeof input.note === "string" && input.note.trim().length > 0 ? input.note.trim() : null,
|
|
50384
|
-
request: null,
|
|
50385
|
-
response: null,
|
|
50386
|
-
browser: {
|
|
50387
|
-
started: readRuntimeNetworkBrowserContext(),
|
|
50388
|
-
completed: readRuntimeNetworkBrowserContext(),
|
|
50389
|
-
elapsedMs: 0,
|
|
50390
|
-
failureKind: null
|
|
50391
|
-
}
|
|
50392
|
-
};
|
|
50393
|
-
runtimeNetworkDebugEntries = [entry, ...runtimeNetworkDebugEntries].slice(0, MAX_RUNTIME_NETWORK_DEBUG_ENTRIES);
|
|
50394
|
-
emitRuntimeNetworkDebugEntries({ persist: outcome === "error" });
|
|
50395
|
-
};
|
|
50396
|
-
}
|
|
50397
|
-
});
|
|
50398
|
-
|
|
50399
50455
|
// lib/runtime/hyperliquid-account-state-adapter.ts
|
|
50400
50456
|
var unsupportedUserActiveAssetCache, MAX_UNSUPPORTED_USER_ACTIVE_ASSET_CACHE_KEYS, UNSUPPORTED_USER_ACTIVE_ASSET_STORAGE_KEY, USER_FILLS_CACHE_STORAGE_PREFIX, ACCOUNT_STATE_CACHE_STORAGE_PREFIX, browserUserFillsCache, browserUserFillsInFlight, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, browserAccountStateCache, browserAccountStateInFlight, UNSUPPORTED_USER_ACTIVE_ASSET_DETAIL_PATTERNS, unsupportedUserActiveAssetCacheHydrated, hydrateUnsupportedUserActiveAssetCache, persistUnsupportedUserActiveAssetCache, toPositiveFinite, toFinite, firstFiniteNumber, parseFundingUsdcFromInfoPosition, buildActiveAssetCacheKey, buildUserFillsCacheKey, buildUserFillsStorageKey, buildAccountStateCacheKey, buildAccountStateStorageKey, hasActiveInfoRateLimitCooldown, requireNonNegativeConfigSeconds, requireAccountStateCacheConfig, requireUserFillsCacheConfig, normalizeFillSymbol, buildSymbolFilter, filterFillsBySymbols, readBrowserUserFillsCache, writeBrowserUserFillsCache, cloneBrowserAccountStateResult, withAccountStateEvidence, readBrowserAccountStateCache, writeBrowserAccountStateCache, isRateLimitError, createAbortError, waitForSharedBrowserRequest, waitForSharedBrowserUserFills, getBrowserActiveAssetTypeCandidates, normalizeHyperliquidErrorDetail, isUnsupportedUserActiveAssetError, rememberUnsupportedUserActiveAssetKey, parseInfoPositions, requireFinitePromptMetric, requirePromptClearinghouseState, requirePromptSpotState, normalizePerpDexName, listConfiguredPerpDexs, listPerpDexsForAccountState, prefixHip3PositionCoins, aggregateClearinghouseResponses, hasCompletePerpDexAccountMetrics, normalizeBrowserFillToTradeHistory, isPerpFill, settleAccountReads, fetchHyperliquidInfoRead, fetchHyperliquidInfoPayload, requireHyperliquidApiUrl, requireWalletAddress, parseInfoPositionSnapshot, fetchBrowserAccountState, fetchBrowserAccountStateUncached, fetchBrowserUserFills, fetchBrowserPositionSnapshot;
|
|
50401
50457
|
var init_hyperliquid_account_state_adapter = __esm({
|
|
@@ -52099,6 +52155,26 @@ var init_local_breadcrumbs = __esm({
|
|
|
52099
52155
|
}
|
|
52100
52156
|
});
|
|
52101
52157
|
|
|
52158
|
+
// lib/api/browser-api-url.ts
|
|
52159
|
+
function resolveBrowserApiUrl(hostname3, protocol, publicApiUrl, development) {
|
|
52160
|
+
if (development) {
|
|
52161
|
+
const local = hostname3 === "localhost" || hostname3 === "127.0.0.1" || hostname3.startsWith("192.168.") || hostname3.startsWith("10.") || hostname3.startsWith("172.") && Number(hostname3.split(".")[1]) >= 16 && Number(hostname3.split(".")[1]) <= 31;
|
|
52162
|
+
if (local) return `http://${hostname3}:8000`;
|
|
52163
|
+
}
|
|
52164
|
+
if (publicApiUrl) return publicApiUrl;
|
|
52165
|
+
const baseHost = hostname3.startsWith("www.") ? hostname3.slice(4) : hostname3;
|
|
52166
|
+
const apiHost = baseHost.startsWith("api.") ? baseHost : `api.${baseHost}`;
|
|
52167
|
+
return `${protocol}//${apiHost}`;
|
|
52168
|
+
}
|
|
52169
|
+
var init_browser_api_url = __esm({
|
|
52170
|
+
"lib/api/browser-api-url.ts"() {
|
|
52171
|
+
"use strict";
|
|
52172
|
+
init_define_VTX_EXO_POLICY();
|
|
52173
|
+
init_define_VTX_GROK_POLICY();
|
|
52174
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
52175
|
+
}
|
|
52176
|
+
});
|
|
52177
|
+
|
|
52102
52178
|
// lib/api/shared.ts
|
|
52103
52179
|
function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
52104
52180
|
const headers = { ...baseHeaders };
|
|
@@ -52113,34 +52189,19 @@ var init_shared = __esm({
|
|
|
52113
52189
|
init_define_VTX_EXO_POLICY();
|
|
52114
52190
|
init_define_VTX_GROK_POLICY();
|
|
52115
52191
|
init_define_VTX_PI_MODEL_POLICY();
|
|
52192
|
+
init_browser_api_url();
|
|
52116
52193
|
init_runtime_policy_generated();
|
|
52117
52194
|
init_abort();
|
|
52118
52195
|
getApiUrl = () => {
|
|
52119
52196
|
if (typeof window === "undefined") {
|
|
52120
52197
|
return process.env.API_URL_SERVER || process.env.NEXT_PUBLIC_API_URL || "http://api:8000";
|
|
52121
52198
|
}
|
|
52122
|
-
|
|
52123
|
-
|
|
52124
|
-
|
|
52125
|
-
|
|
52126
|
-
|
|
52127
|
-
|
|
52128
|
-
if (hostname3 === "localhost" || hostname3 === "127.0.0.1") {
|
|
52129
|
-
return `http://${hostname3}:8000`;
|
|
52130
|
-
}
|
|
52131
|
-
}
|
|
52132
|
-
if (process.env.NEXT_PUBLIC_API_URL) {
|
|
52133
|
-
return process.env.NEXT_PUBLIC_API_URL;
|
|
52134
|
-
}
|
|
52135
|
-
try {
|
|
52136
|
-
const hostname3 = window.location.hostname;
|
|
52137
|
-
const protocol = window.location.protocol;
|
|
52138
|
-
const baseHost = hostname3.startsWith("www.") ? hostname3.slice(4) : hostname3;
|
|
52139
|
-
const apiHost = baseHost.startsWith("api.") ? baseHost : `api.${baseHost}`;
|
|
52140
|
-
return `${protocol}//${apiHost}`;
|
|
52141
|
-
} catch {
|
|
52142
|
-
return "http://localhost:8000";
|
|
52143
|
-
}
|
|
52199
|
+
return resolveBrowserApiUrl(
|
|
52200
|
+
window.location.hostname,
|
|
52201
|
+
window.location.protocol,
|
|
52202
|
+
process.env.NEXT_PUBLIC_API_URL,
|
|
52203
|
+
process.env.NODE_ENV === "development"
|
|
52204
|
+
);
|
|
52144
52205
|
};
|
|
52145
52206
|
API_URL = getApiUrl();
|
|
52146
52207
|
sleep2 = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
@@ -52206,6 +52267,18 @@ var init_shared = __esm({
|
|
|
52206
52267
|
}
|
|
52207
52268
|
});
|
|
52208
52269
|
|
|
52270
|
+
// lib/api/client-runtime-bootstrap.ts
|
|
52271
|
+
var init_client_runtime_bootstrap = __esm({
|
|
52272
|
+
"lib/api/client-runtime-bootstrap.ts"() {
|
|
52273
|
+
"use strict";
|
|
52274
|
+
init_define_VTX_EXO_POLICY();
|
|
52275
|
+
init_define_VTX_GROK_POLICY();
|
|
52276
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
52277
|
+
init_local_breadcrumbs();
|
|
52278
|
+
init_browser_api_url();
|
|
52279
|
+
}
|
|
52280
|
+
});
|
|
52281
|
+
|
|
52209
52282
|
// lib/api/billing.ts
|
|
52210
52283
|
var init_billing = __esm({
|
|
52211
52284
|
"lib/api/billing.ts"() {
|
|
@@ -52977,6 +53050,7 @@ var init_api2 = __esm({
|
|
|
52977
53050
|
init_abort();
|
|
52978
53051
|
init_shared();
|
|
52979
53052
|
init_shared();
|
|
53053
|
+
init_client_runtime_bootstrap();
|
|
52980
53054
|
init_billing();
|
|
52981
53055
|
init_market_data();
|
|
52982
53056
|
init_screener();
|
|
@@ -87844,7 +87918,7 @@ var init_execution_guard_contract = __esm({
|
|
|
87844
87918
|
});
|
|
87845
87919
|
|
|
87846
87920
|
// lib/runtime/runtime-execution.ts
|
|
87847
|
-
var executionReadPriority, fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, executeClientRuntimeDecision;
|
|
87921
|
+
var executionReadPriority, fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, withClientExecutionMutation, executeClientRuntimeDecision, maintainClientRuntimeTrailingStops, executeClientRuntimeDecisionUnlocked;
|
|
87848
87922
|
var init_runtime_execution = __esm({
|
|
87849
87923
|
"lib/runtime/runtime-execution.ts"() {
|
|
87850
87924
|
"use strict";
|
|
@@ -91466,6 +91540,9 @@ var init_runtime_execution = __esm({
|
|
|
91466
91540
|
signal: request.signal,
|
|
91467
91541
|
signingKey: request.signingKey,
|
|
91468
91542
|
onExchangeOrderDispatched: () => {
|
|
91543
|
+
if (request.shouldCancelBeforeExchangeOrderDispatch?.()) {
|
|
91544
|
+
throw new Error(CLIENT_RUNTIME_WINDOW_HANDOFF_BEFORE_PLAN_DISPATCH);
|
|
91545
|
+
}
|
|
91469
91546
|
if (!assertExactProtectiveReplacementDispatchAuthority({
|
|
91470
91547
|
profileId,
|
|
91471
91548
|
symbol: symbol2,
|
|
@@ -91770,7 +91847,52 @@ var init_runtime_execution = __esm({
|
|
|
91770
91847
|
return { blocksEntry: false, reports: [] };
|
|
91771
91848
|
}
|
|
91772
91849
|
};
|
|
91773
|
-
|
|
91850
|
+
clientExecutionMutations = /* @__PURE__ */ new Map();
|
|
91851
|
+
withClientExecutionMutation = async (request, work) => {
|
|
91852
|
+
const key = String(request.profileId).trim();
|
|
91853
|
+
const previous = clientExecutionMutations.get(key);
|
|
91854
|
+
const pending3 = (previous ?? Promise.resolve()).catch(() => void 0).then(() => {
|
|
91855
|
+
throwIfAborted2(request.signal);
|
|
91856
|
+
if (request.shouldCancelBeforeExchangeOrderDispatch?.()) {
|
|
91857
|
+
throw new Error(CLIENT_RUNTIME_WINDOW_HANDOFF_BEFORE_PLAN_DISPATCH);
|
|
91858
|
+
}
|
|
91859
|
+
return work();
|
|
91860
|
+
});
|
|
91861
|
+
clientExecutionMutations.set(key, pending3);
|
|
91862
|
+
try {
|
|
91863
|
+
return await pending3;
|
|
91864
|
+
} finally {
|
|
91865
|
+
if (clientExecutionMutations.get(key) === pending3) clientExecutionMutations.delete(key);
|
|
91866
|
+
}
|
|
91867
|
+
};
|
|
91868
|
+
executeClientRuntimeDecision = (input) => withClientExecutionMutation(input, () => executeClientRuntimeDecisionUnlocked(input));
|
|
91869
|
+
maintainClientRuntimeTrailingStops = (request) => withClientExecutionMutation(request, async () => {
|
|
91870
|
+
const context = request.executionContext;
|
|
91871
|
+
const capturedAt = Date.parse(context.decisionSnapshotCapturedAt ?? "");
|
|
91872
|
+
const maxAge = Number(context.executionFreshnessMaxAgeSeconds) * 1e3;
|
|
91873
|
+
const age = Date.now() - capturedAt;
|
|
91874
|
+
if (!context.tpSlEnabled || context.stopLossEnabled === false || context.stopLossType !== "trailing" || !Number.isFinite(age) || age < 0 || !Number.isFinite(maxAge) || maxAge <= 0 || age > maxAge || !Number.isFinite(context.currentPositionSize) || context.currentPositionSize === 0 || !Number.isFinite(context.lastPrice) || context.lastPrice <= 0) return [];
|
|
91875
|
+
const groups = readFreshClientProtectiveGroups(String(request.profileId).trim(), context.symbol);
|
|
91876
|
+
if (hasClientProtectiveGroupReadFailure(String(request.profileId).trim(), context.symbol) || groups.some((group) => group.walletAddress !== String(context.walletAddress ?? "").trim().toLowerCase() || group.pendingEntry || group.attachmentJournal || group.cleanupRequired || group.legs.some((leg) => leg.replacement))) return [];
|
|
91877
|
+
const isLong = context.currentPositionSize > 0;
|
|
91878
|
+
const improves = groups.some((group) => group.isLong === isLong && group.legs.some((leg) => {
|
|
91879
|
+
if (!leg.isTrailing || typeof leg.orderId !== "number") return false;
|
|
91880
|
+
const size = roundAssetSize(Math.min(leg.size, Math.abs(context.currentPositionSize)), context.sizeDecimals);
|
|
91881
|
+
if (!(size > 0)) return false;
|
|
91882
|
+
const risk = resolveRiskPct(context.stopLossMode, context.stopLossPct, context.stopLossUsdc, context.lastPrice * size);
|
|
91883
|
+
const raw = buildTriggerPrice(context.lastPrice, risk, isLong, false);
|
|
91884
|
+
const candidate = raw > 0 ? Number(formatHyperliquidTriggerPriceWire(raw, context.sizeDecimals)) : 0;
|
|
91885
|
+
return candidate > 0 && (isLong ? candidate > leg.triggerPrice : candidate < leg.triggerPrice);
|
|
91886
|
+
}));
|
|
91887
|
+
if (!improves) return [];
|
|
91888
|
+
await request.beforeTrailingMaintenance?.(request.signal);
|
|
91889
|
+
const guardedRequest = { ...request, onExchangeOrderDispatched: (kind) => {
|
|
91890
|
+
if (Date.now() - capturedAt > maxAge) throw new Error("Trailing observation expired before exchange dispatch.");
|
|
91891
|
+
request.onExchangeOrderDispatched?.(kind);
|
|
91892
|
+
} };
|
|
91893
|
+
return tightenClientTrailingStops({ request: guardedRequest, currentPositionSize: context.currentPositionSize, currentPrice: context.lastPrice });
|
|
91894
|
+
});
|
|
91895
|
+
executeClientRuntimeDecisionUnlocked = async (input) => {
|
|
91774
91896
|
throwIfAborted2(input.signal);
|
|
91775
91897
|
const requestedUnits = Math.max(0, Math.trunc(input.units));
|
|
91776
91898
|
appendRuntimeDebugEvent({
|
|
@@ -91800,7 +91922,7 @@ var init_runtime_execution = __esm({
|
|
|
91800
91922
|
execution_metadata: { reason_code: "protective_lifecycle_storage_invalid" }
|
|
91801
91923
|
}] : hasTrackedProtection ? await reconcileClientProtectiveGroups(input) : [];
|
|
91802
91924
|
if (input.decision === "HOLD" || requestedUnits <= 0) {
|
|
91803
|
-
const shouldTrail = input.executionContext.tpSlEnabled === true && input.executionContext.stopLossEnabled !== false && input.executionContext.stopLossType === "trailing" && decisionSnapshotPositionSize !== 0;
|
|
91925
|
+
const shouldTrail = !input.skipTrailingMaintenance && input.executionContext.tpSlEnabled === true && input.executionContext.stopLossEnabled !== false && input.executionContext.stopLossType === "trailing" && decisionSnapshotPositionSize !== 0;
|
|
91804
91926
|
if (shouldTrail && !reconciliationReports.some((report) => report.status === "failed")) {
|
|
91805
91927
|
const {
|
|
91806
91928
|
currentPositionSize: currentPositionSize2,
|
|
@@ -93998,7 +94120,7 @@ async function fetchLocalHyperliquidSnapshot(input) {
|
|
|
93998
94120
|
symbol: input.symbol,
|
|
93999
94121
|
timeframe: input.timeframe,
|
|
94000
94122
|
decisionSnapshotId: input.decisionSnapshotId,
|
|
94001
|
-
decisionSnapshotCapturedAt: input.decisionSnapshotCapturedAt,
|
|
94123
|
+
decisionSnapshotCapturedAt: new Date(Math.min(Date.parse(input.decisionSnapshotCapturedAt), accountState.evidence?.fetchedAtMs ?? Date.parse(input.decisionSnapshotCapturedAt))).toISOString(),
|
|
94002
94124
|
currentPositionSize: Number.isFinite(currentPositionSize) ? currentPositionSize : 0,
|
|
94003
94125
|
currentPositionEntryPrice: accountState.positions.find((position) => normalizeRuntimeSymbol(position.symbol) === normalizeRuntimeSymbol(input.symbol))?.entry_price ?? null,
|
|
94004
94126
|
walletAddress,
|
|
@@ -94009,7 +94131,8 @@ async function fetchLocalHyperliquidSnapshot(input) {
|
|
|
94009
94131
|
marginMode,
|
|
94010
94132
|
closePositionDelaySeconds: requireFiniteNumber(input.llmConfig.client_runtime_close_position_delay_seconds, "close position delay seconds"),
|
|
94011
94133
|
maxSlippageFraction: requireFiniteNumber(input.llmConfig.default_max_slippage, "max slippage") / 100,
|
|
94012
|
-
executionFreshnessMaxAgeSeconds
|
|
94134
|
+
executionFreshnessMaxAgeSeconds,
|
|
94135
|
+
...buildRuntimeSlTpExecutionSettings(promptKnobs, input.llmConfig)
|
|
94013
94136
|
}
|
|
94014
94137
|
};
|
|
94015
94138
|
}
|
|
@@ -94178,6 +94301,40 @@ function createHeadlessLocalWorker(options) {
|
|
|
94178
94301
|
user_prompt: providerInput.userPrompt
|
|
94179
94302
|
})
|
|
94180
94303
|
]);
|
|
94304
|
+
const symbol2 = requireText(prompt.symbol ?? metadata.symbol, "symbol");
|
|
94305
|
+
const timeframe = requireText(prompt.timeframe ?? metadata.timeframe, "timeframe");
|
|
94306
|
+
const secrets = objectOrNull3(input.secrets) ?? {};
|
|
94307
|
+
const protectiveSettings = buildRuntimeSlTpExecutionSettings(objectOrNull3(metadata.prompt_knobs) ?? {}, llmConfig);
|
|
94308
|
+
let preparedHyperliquidContext = null;
|
|
94309
|
+
try {
|
|
94310
|
+
preparedHyperliquidContext = protectiveSettings.tpSlEnabled && protectiveSettings.stopLossEnabled && protectiveSettings.stopLossType === "trailing" && hasClientRuntimeProtectionState(input.profileId, symbol2) ? await fetchLocalHyperliquidSnapshot({
|
|
94311
|
+
client: options.client,
|
|
94312
|
+
profileId: input.profileId,
|
|
94313
|
+
llmConfig,
|
|
94314
|
+
secrets,
|
|
94315
|
+
metadata,
|
|
94316
|
+
symbol: symbol2,
|
|
94317
|
+
timeframe,
|
|
94318
|
+
decisionSnapshotId,
|
|
94319
|
+
decisionSnapshotCapturedAt,
|
|
94320
|
+
fetchAccountState
|
|
94321
|
+
}) : null;
|
|
94322
|
+
if (preparedHyperliquidContext && preparedHyperliquidContext.accountState.evidence?.source !== "stale_if_429") {
|
|
94323
|
+
await maintainClientRuntimeTrailingStops({
|
|
94324
|
+
profileId: String(input.profileId),
|
|
94325
|
+
sessionId: input.runtimeState.runtimeSessionId,
|
|
94326
|
+
runtimeLeaseToken: input.runtimeState.leaseToken,
|
|
94327
|
+
runtimeDeviceId: input.runtimeState.deviceId,
|
|
94328
|
+
signingKey: preparedHyperliquidContext.signingKey,
|
|
94329
|
+
config: buildHeadlessExchangeConfig(llmConfig),
|
|
94330
|
+
decision: "HOLD",
|
|
94331
|
+
units: 0,
|
|
94332
|
+
executionContext: preparedHyperliquidContext.executionContext
|
|
94333
|
+
});
|
|
94334
|
+
}
|
|
94335
|
+
} catch {
|
|
94336
|
+
appendRuntimeDebugEvent({ label: "client_pre_inference_trailing_maintenance", note: "Headless trailing maintenance unavailable; continuing inference.", outcome: "error" });
|
|
94337
|
+
}
|
|
94181
94338
|
let providerResult;
|
|
94182
94339
|
try {
|
|
94183
94340
|
providerResult = options.invokeProvider ? await options.invokeProvider(providerInput) : await invokeOpenAiCompatibleProvider(providerInput, fetchImpl);
|
|
@@ -94227,10 +94384,7 @@ function createHeadlessLocalWorker(options) {
|
|
|
94227
94384
|
}
|
|
94228
94385
|
throw error48;
|
|
94229
94386
|
}
|
|
94230
|
-
const symbol2 = requireText(prompt.symbol ?? metadata.symbol, "symbol");
|
|
94231
|
-
const timeframe = requireText(prompt.timeframe ?? metadata.timeframe, "timeframe");
|
|
94232
94387
|
const providerDecision = extractDecisionPayload(providerResult.content, symbol2);
|
|
94233
|
-
const secrets = objectOrNull3(input.secrets) ?? {};
|
|
94234
94388
|
const normalizedUsage = normalizeRuntimeUsageDetails(providerResult.usage);
|
|
94235
94389
|
const detailedUsage = {
|
|
94236
94390
|
...normalizedUsage,
|
|
@@ -94305,7 +94459,7 @@ function createHeadlessLocalWorker(options) {
|
|
|
94305
94459
|
"Increase Position Tradability minimum"
|
|
94306
94460
|
);
|
|
94307
94461
|
const holdHasProtectiveWork = hasClientRuntimeProtectionState(input.profileId, symbol2);
|
|
94308
|
-
const candidateHyperliquidContext = (providerDecision.decision === "HOLD" || providerDecision.units <= 0) && !holdHasProtectiveWork ? null : await fetchLocalHyperliquidSnapshot({
|
|
94462
|
+
const candidateHyperliquidContext = (providerDecision.decision === "HOLD" || providerDecision.units <= 0) && !holdHasProtectiveWork ? null : preparedHyperliquidContext ?? await fetchLocalHyperliquidSnapshot({
|
|
94309
94463
|
client: options.client,
|
|
94310
94464
|
profileId: input.profileId,
|
|
94311
94465
|
llmConfig,
|
|
@@ -94451,7 +94605,8 @@ function createHeadlessLocalWorker(options) {
|
|
|
94451
94605
|
config: buildHeadlessExchangeConfig(llmConfig),
|
|
94452
94606
|
decision: accepted.decision,
|
|
94453
94607
|
units: accepted.units,
|
|
94454
|
-
executionContext: localHyperliquidContext.executionContext
|
|
94608
|
+
executionContext: localHyperliquidContext.executionContext,
|
|
94609
|
+
skipTrailingMaintenance: preparedHyperliquidContext !== null
|
|
94455
94610
|
});
|
|
94456
94611
|
return {
|
|
94457
94612
|
...baseTradeSync,
|
|
@@ -94470,6 +94625,8 @@ var init_headless_local_worker = __esm({
|
|
|
94470
94625
|
init_define_VTX_EXO_POLICY();
|
|
94471
94626
|
init_define_VTX_GROK_POLICY();
|
|
94472
94627
|
init_define_VTX_PI_MODEL_POLICY();
|
|
94628
|
+
init_network_debug();
|
|
94629
|
+
init_sl_tp_execution_settings();
|
|
94473
94630
|
init_hyperliquid_account_state_adapter();
|
|
94474
94631
|
init_hyperliquid_market_symbol();
|
|
94475
94632
|
init_runtime_execution();
|