@vtxmacro/cli 2026.10.53 → 2026.10.54
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-mcp.js +1 -1
- package/bin/vtx-service-bootstrap.js +1 -1
- package/bin/vtx.js +636 -291
- 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.54", 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
|
|
|
@@ -4728,7 +4728,7 @@ async function syncInferenceDirectory(path, platform = process.platform) {
|
|
|
4728
4728
|
async function replaceAtomicInferencePrivateFile(temporaryPath, destinationPath, options = {}) {
|
|
4729
4729
|
const platform = options.platform ?? process.platform;
|
|
4730
4730
|
const renameFile = options.renameFile ?? rename;
|
|
4731
|
-
const
|
|
4731
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve16) => setTimeout(resolve16, milliseconds)));
|
|
4732
4732
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_CORE_POLICY.private_file_replace_attempts);
|
|
4733
4733
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_CORE_POLICY.private_file_replace_retry_delay_ms);
|
|
4734
4734
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -4740,7 +4740,7 @@ async function replaceAtomicInferencePrivateFile(temporaryPath, destinationPath,
|
|
|
4740
4740
|
if (platform !== "win32" || !WINDOWS_PRIVATE_FILE_REPLACE_ERROR_CODES.has(code) || attempt2 === maxAttempts - 1) {
|
|
4741
4741
|
throw error48;
|
|
4742
4742
|
}
|
|
4743
|
-
await
|
|
4743
|
+
await sleep3(retryDelayMs);
|
|
4744
4744
|
}
|
|
4745
4745
|
}
|
|
4746
4746
|
}
|
|
@@ -5893,7 +5893,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
5893
5893
|
});
|
|
5894
5894
|
|
|
5895
5895
|
// lib/runtime/abort.ts
|
|
5896
|
-
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError, toAbortError;
|
|
5896
|
+
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError, toAbortError, throwIfAborted, abortableSleep;
|
|
5897
5897
|
var init_abort = __esm({
|
|
5898
5898
|
"lib/runtime/abort.ts"() {
|
|
5899
5899
|
"use strict";
|
|
@@ -5947,6 +5947,32 @@ var init_abort = __esm({
|
|
|
5947
5947
|
return fallback;
|
|
5948
5948
|
}
|
|
5949
5949
|
};
|
|
5950
|
+
throwIfAborted = (signal) => {
|
|
5951
|
+
if (signal?.aborted) {
|
|
5952
|
+
throw new DOMException("The operation was aborted.", "AbortError");
|
|
5953
|
+
}
|
|
5954
|
+
};
|
|
5955
|
+
abortableSleep = async (ms, signal) => {
|
|
5956
|
+
await new Promise((resolve16, reject) => {
|
|
5957
|
+
const timer = setTimeout(() => {
|
|
5958
|
+
cleanup();
|
|
5959
|
+
resolve16(void 0);
|
|
5960
|
+
}, ms);
|
|
5961
|
+
const cleanup = () => {
|
|
5962
|
+
clearTimeout(timer);
|
|
5963
|
+
signal?.removeEventListener("abort", onAbort);
|
|
5964
|
+
};
|
|
5965
|
+
const onAbort = () => {
|
|
5966
|
+
cleanup();
|
|
5967
|
+
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
5968
|
+
};
|
|
5969
|
+
if (signal?.aborted) {
|
|
5970
|
+
onAbort();
|
|
5971
|
+
return;
|
|
5972
|
+
}
|
|
5973
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
5974
|
+
});
|
|
5975
|
+
};
|
|
5950
5976
|
}
|
|
5951
5977
|
});
|
|
5952
5978
|
|
|
@@ -35221,7 +35247,7 @@ child.once('close', async (code, signal) => {
|
|
|
35221
35247
|
const platform = options.platform ?? process.platform;
|
|
35222
35248
|
const renameFile = options.renameFile ?? rename3;
|
|
35223
35249
|
const removeFile = options.removeFile ?? ((path) => rm4(path, { force: true }));
|
|
35224
|
-
const
|
|
35250
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve16) => setTimeout(resolve16, milliseconds)));
|
|
35225
35251
|
const maxAttempts = Math.max(1, options.maxAttempts ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_attempts);
|
|
35226
35252
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? HOST_RUNTIME_POLICY.codex_guardian_receipt_replace_retry_ms);
|
|
35227
35253
|
for (let attempt2 = 0; attempt2 < maxAttempts; attempt2 += 1) {
|
|
@@ -35241,7 +35267,7 @@ child.once('close', async (code, signal) => {
|
|
|
35241
35267
|
throw removeError;
|
|
35242
35268
|
}
|
|
35243
35269
|
}
|
|
35244
|
-
await
|
|
35270
|
+
await sleep3(retryDelayMs);
|
|
35245
35271
|
}
|
|
35246
35272
|
}
|
|
35247
35273
|
};
|
|
@@ -38343,7 +38369,7 @@ var init_runner = __esm({
|
|
|
38343
38369
|
receiptDurabilityTimeoutMs: this.options.receiptDurabilityTimeoutMs ?? await loadInferenceReceiptDurabilityTimeoutMs()
|
|
38344
38370
|
});
|
|
38345
38371
|
const now = this.dependencies.now ?? Date.now;
|
|
38346
|
-
const
|
|
38372
|
+
const sleep3 = this.dependencies.sleep ?? defaultSleep;
|
|
38347
38373
|
const lock2 = await this.dependencies.acquireProcessLock();
|
|
38348
38374
|
let unregisterSignals = () => {
|
|
38349
38375
|
};
|
|
@@ -38559,7 +38585,7 @@ var init_runner = __esm({
|
|
|
38559
38585
|
});
|
|
38560
38586
|
if (this.options.once) return;
|
|
38561
38587
|
try {
|
|
38562
|
-
await
|
|
38588
|
+
await sleep3(Math.max(MIN_SLEEP_MS, retryAtMs - now()), agentIdleSignal);
|
|
38563
38589
|
} catch {
|
|
38564
38590
|
return;
|
|
38565
38591
|
}
|
|
@@ -38647,11 +38673,11 @@ var init_runner = __esm({
|
|
|
38647
38673
|
const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
|
|
38648
38674
|
const fence = await readInferenceAgentFailureFence(agentRuntimeSettings.statePath);
|
|
38649
38675
|
if (!fence || !canReplayFencedAgentTerminal(retained, fence)) return;
|
|
38650
|
-
await
|
|
38676
|
+
await sleep3(HOST_RUNTIME_POLICY2.agent_idle_retry_ms, agentIdleSignal).catch(() => void 0);
|
|
38651
38677
|
continue;
|
|
38652
38678
|
}
|
|
38653
38679
|
try {
|
|
38654
|
-
await
|
|
38680
|
+
await sleep3(Math.max(MIN_SLEEP_MS, retryAtMs - now()), agentIdleSignal);
|
|
38655
38681
|
} catch {
|
|
38656
38682
|
return;
|
|
38657
38683
|
}
|
|
@@ -38667,7 +38693,7 @@ var init_runner = __esm({
|
|
|
38667
38693
|
const retained = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
|
|
38668
38694
|
if (!retained || retained.schema_version !== "vtx_inference_agent_runtime_v3" || !retained.pending_turn?.terminal_receipt) return;
|
|
38669
38695
|
if (this.options.once) return;
|
|
38670
|
-
await
|
|
38696
|
+
await sleep3(HOST_RUNTIME_POLICY2.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
|
|
38671
38697
|
if (!quiesceRequested) throw error49;
|
|
38672
38698
|
});
|
|
38673
38699
|
continue;
|
|
@@ -38681,7 +38707,7 @@ var init_runner = __esm({
|
|
|
38681
38707
|
});
|
|
38682
38708
|
if (this.options.once) return;
|
|
38683
38709
|
try {
|
|
38684
|
-
await
|
|
38710
|
+
await sleep3(HOST_RUNTIME_POLICY2.agent_idle_retry_ms, agentIdleSignal).catch((error49) => {
|
|
38685
38711
|
if (!quiesceRequested) throw error49;
|
|
38686
38712
|
});
|
|
38687
38713
|
} catch {
|
|
@@ -38812,7 +38838,7 @@ var init_runner = __esm({
|
|
|
38812
38838
|
{ cause: error48 }
|
|
38813
38839
|
);
|
|
38814
38840
|
}
|
|
38815
|
-
await
|
|
38841
|
+
await sleep3(requestedRetryDelay, boundary.signal);
|
|
38816
38842
|
}
|
|
38817
38843
|
}
|
|
38818
38844
|
throw lastError;
|
|
@@ -39039,7 +39065,7 @@ var init_runner = __esm({
|
|
|
39039
39065
|
result = status === "draining" || !retryRemote ? await heartbeatOperation() : await retryExact(heartbeatOperation, requestOptions);
|
|
39040
39066
|
} catch (error48) {
|
|
39041
39067
|
if (status !== "draining" && retryRemote && error48 instanceof ExternalInferenceMcpError && error48.definitivelyNotApplied && error48.retryable && definitiveReseedAttempt < settings.remoteRetryLimit - 1) {
|
|
39042
|
-
await
|
|
39068
|
+
await sleep3(remoteRetryAfterMs(error48, MIN_SLEEP_MS), requestOptions.signal);
|
|
39043
39069
|
return await hostHeartbeat(
|
|
39044
39070
|
status,
|
|
39045
39071
|
requestOptions,
|
|
@@ -39237,7 +39263,7 @@ var init_runner = __esm({
|
|
|
39237
39263
|
hostHeartbeatLoop = (async () => {
|
|
39238
39264
|
while (!drainRequested && !hostHeartbeatAbort.signal.aborted) {
|
|
39239
39265
|
try {
|
|
39240
|
-
await
|
|
39266
|
+
await sleep3(
|
|
39241
39267
|
Math.max(MIN_SLEEP_MS, nextHostHeartbeatAt - now()),
|
|
39242
39268
|
hostHeartbeatAbort.signal
|
|
39243
39269
|
);
|
|
@@ -39253,7 +39279,7 @@ var init_runner = __esm({
|
|
|
39253
39279
|
try {
|
|
39254
39280
|
await Promise.race([
|
|
39255
39281
|
pendingAdvertisementHandoff,
|
|
39256
|
-
|
|
39282
|
+
sleep3(settings.hostHeartbeatMs, hostHeartbeatAbort.signal)
|
|
39257
39283
|
]);
|
|
39258
39284
|
} catch (error48) {
|
|
39259
39285
|
if (hostHeartbeatAbort.signal.aborted || drainRequested) return;
|
|
@@ -39395,7 +39421,7 @@ var init_runner = __esm({
|
|
|
39395
39421
|
signal: controller.signal,
|
|
39396
39422
|
attemptHeartbeatMs: settings.attemptHeartbeatMs,
|
|
39397
39423
|
receiptDurabilityTimeoutMs: settings.receiptDurabilityTimeoutMs,
|
|
39398
|
-
sleep:
|
|
39424
|
+
sleep: sleep3,
|
|
39399
39425
|
now,
|
|
39400
39426
|
onProviderCooldown: ({ retryAtMs, reason, rateLimits }) => {
|
|
39401
39427
|
if (!Number.isSafeInteger(retryAtMs) || retryAtMs <= now()) return;
|
|
@@ -40077,7 +40103,7 @@ var init_runner = __esm({
|
|
|
40077
40103
|
);
|
|
40078
40104
|
if (yieldRenewalToClaim) continue;
|
|
40079
40105
|
await Promise.race([
|
|
40080
|
-
|
|
40106
|
+
sleep3(Math.max(MIN_SLEEP_MS, wakeAt - now())),
|
|
40081
40107
|
drainSignal,
|
|
40082
40108
|
quiesceWake,
|
|
40083
40109
|
...active.values()
|
|
@@ -40104,7 +40130,7 @@ var init_runner = __esm({
|
|
|
40104
40130
|
let timedOut = false;
|
|
40105
40131
|
await Promise.race([
|
|
40106
40132
|
Promise.allSettled([...active.values()]),
|
|
40107
|
-
|
|
40133
|
+
sleep3(settings.drainTimeoutMs).then(() => {
|
|
40108
40134
|
timedOut = true;
|
|
40109
40135
|
})
|
|
40110
40136
|
]);
|
|
@@ -40113,7 +40139,7 @@ var init_runner = __esm({
|
|
|
40113
40139
|
for (const controller of attemptControllers.values()) controller.abort();
|
|
40114
40140
|
await Promise.race([
|
|
40115
40141
|
Promise.allSettled([...active.values()]),
|
|
40116
|
-
|
|
40142
|
+
sleep3(settings.drainTimeoutMs)
|
|
40117
40143
|
]);
|
|
40118
40144
|
requestDrain("drain_timeout");
|
|
40119
40145
|
}
|
|
@@ -42379,7 +42405,7 @@ var init_owned_directory_removal = __esm({
|
|
|
42379
42405
|
TRANSIENT_REMOVAL_ERROR_CODES = /* @__PURE__ */ new Set(["EBUSY", "EMFILE", "ENFILE", "ENOTEMPTY", "EPERM"]);
|
|
42380
42406
|
removeOwnedDirectory = async (path, options = {}) => {
|
|
42381
42407
|
const removeDirectory = options.removeDirectory ?? rm5;
|
|
42382
|
-
const
|
|
42408
|
+
const sleep3 = options.sleep ?? ((milliseconds) => new Promise((resolve16) => {
|
|
42383
42409
|
setTimeout(resolve16, milliseconds);
|
|
42384
42410
|
}));
|
|
42385
42411
|
const maxAttempts = Math.max(1, options.maxAttempts ?? runtime_policy_generated_default.external_inference.host_core.owned_directory_removal_attempts);
|
|
@@ -42391,7 +42417,7 @@ var init_owned_directory_removal = __esm({
|
|
|
42391
42417
|
} catch (error48) {
|
|
42392
42418
|
const code = String(error48?.code ?? "");
|
|
42393
42419
|
if (attempt2 >= maxAttempts || !TRANSIENT_REMOVAL_ERROR_CODES.has(code)) throw error48;
|
|
42394
|
-
await
|
|
42420
|
+
await sleep3(retryDelayMs * attempt2);
|
|
42395
42421
|
}
|
|
42396
42422
|
}
|
|
42397
42423
|
};
|
|
@@ -44269,7 +44295,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44269
44295
|
throw new Error("Same-boot service recovery is currently supported only on Windows.");
|
|
44270
44296
|
}
|
|
44271
44297
|
const queryProcesses = options.queryProcesses ?? queryWindowsProcesses;
|
|
44272
|
-
const
|
|
44298
|
+
const sleep3 = options.sleep ?? (async (milliseconds) => {
|
|
44273
44299
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
44274
44300
|
});
|
|
44275
44301
|
for (let observation = 0; observation < HOST_RUNTIME_POLICY5.codex_recovery_process_observations; observation += 1) {
|
|
@@ -44288,7 +44314,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44288
44314
|
);
|
|
44289
44315
|
}
|
|
44290
44316
|
if (observation + 1 < HOST_RUNTIME_POLICY5.codex_recovery_process_observations) {
|
|
44291
|
-
await
|
|
44317
|
+
await sleep3(HOST_RUNTIME_POLICY5.codex_recovery_process_observation_interval_ms);
|
|
44292
44318
|
}
|
|
44293
44319
|
}
|
|
44294
44320
|
};
|
|
@@ -44314,7 +44340,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44314
44340
|
return;
|
|
44315
44341
|
}
|
|
44316
44342
|
const queryProcesses = options.queryProcesses ?? queryWindowsProcesses;
|
|
44317
|
-
const
|
|
44343
|
+
const sleep3 = options.sleep ?? (async (milliseconds) => {
|
|
44318
44344
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
44319
44345
|
});
|
|
44320
44346
|
for (let observation = 0; observation < HOST_RUNTIME_POLICY5.codex_recovery_process_observations; observation += 1) {
|
|
@@ -44323,7 +44349,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44323
44349
|
throw new Error("Codex guardian process tree is still running; recovery evidence was preserved.");
|
|
44324
44350
|
}
|
|
44325
44351
|
if (observation + 1 < HOST_RUNTIME_POLICY5.codex_recovery_process_observations) {
|
|
44326
|
-
await
|
|
44352
|
+
await sleep3(HOST_RUNTIME_POLICY5.codex_recovery_process_observation_interval_ms);
|
|
44327
44353
|
}
|
|
44328
44354
|
}
|
|
44329
44355
|
};
|
|
@@ -52141,7 +52167,7 @@ ${result.stderr}`)) {
|
|
|
52141
52167
|
await controlLock.release();
|
|
52142
52168
|
}
|
|
52143
52169
|
};
|
|
52144
|
-
const
|
|
52170
|
+
const sleep3 = options.sleep ?? (async (milliseconds) => {
|
|
52145
52171
|
await new Promise((resolvePromise) => setTimeout(resolvePromise, milliseconds));
|
|
52146
52172
|
});
|
|
52147
52173
|
const launch = options.runWorker ?? options.spawnChild ?? spawnInferenceHostServiceChild;
|
|
@@ -52186,7 +52212,7 @@ ${result.stderr}`)) {
|
|
|
52186
52212
|
controller.signal.addEventListener("abort", finishAbort, { once: true });
|
|
52187
52213
|
signal.addEventListener("abort", finishAbort, { once: true });
|
|
52188
52214
|
try {
|
|
52189
|
-
await Promise.race([
|
|
52215
|
+
await Promise.race([sleep3(milliseconds), aborted2]);
|
|
52190
52216
|
} finally {
|
|
52191
52217
|
controller.signal.removeEventListener("abort", finishAbort);
|
|
52192
52218
|
signal.removeEventListener("abort", finishAbort);
|
|
@@ -52214,7 +52240,7 @@ ${result.stderr}`)) {
|
|
|
52214
52240
|
if (readinessSignalled) return;
|
|
52215
52241
|
readinessSignalled = true;
|
|
52216
52242
|
readinessTask = (async () => {
|
|
52217
|
-
await
|
|
52243
|
+
await sleep3(SERVICE_POLICY.worker_readiness_settle_ms);
|
|
52218
52244
|
if (!launchSettled && !attemptController.signal.aborted && !record6.controller.signal.aborted && !signal.aborted) {
|
|
52219
52245
|
await updateRecord(record6, "running");
|
|
52220
52246
|
}
|
|
@@ -52348,7 +52374,7 @@ ${result.stderr}`)) {
|
|
|
52348
52374
|
if (!storedNext) throw new Error("Inference-host service manifest is missing.");
|
|
52349
52375
|
const next = withServiceScript(storedNext);
|
|
52350
52376
|
if (next.generation !== appliedManifest.generation && next.generation !== rejectedManifestGeneration) await reconcile(next);
|
|
52351
|
-
await
|
|
52377
|
+
await sleep3(SERVICE_POLICY.supervisor_manifest_poll_interval_ms);
|
|
52352
52378
|
}
|
|
52353
52379
|
if (quiesceSignal.aborted && !signal.aborted) {
|
|
52354
52380
|
let finished = false;
|
|
@@ -52357,7 +52383,7 @@ ${result.stderr}`)) {
|
|
|
52357
52383
|
return results;
|
|
52358
52384
|
});
|
|
52359
52385
|
while (!finished && !signal.aborted && await readDesiredAcrossAtomicReplacement(desiredPath)) {
|
|
52360
|
-
await Promise.race([completion,
|
|
52386
|
+
await Promise.race([completion, sleep3(SERVICE_POLICY.supervisor_manifest_poll_interval_ms)]);
|
|
52361
52387
|
}
|
|
52362
52388
|
if (!finished) {
|
|
52363
52389
|
await drainWorkers();
|
|
@@ -54422,7 +54448,7 @@ Waiting for approval...
|
|
|
54422
54448
|
}
|
|
54423
54449
|
const session = await agentSession(config2, dependencies, warnings);
|
|
54424
54450
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
54425
|
-
const
|
|
54451
|
+
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
54426
54452
|
await new Promise((resolve16) => setTimeout(resolve16, milliseconds));
|
|
54427
54453
|
});
|
|
54428
54454
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
@@ -54520,7 +54546,7 @@ Waiting for approval...
|
|
|
54520
54546
|
` : ""
|
|
54521
54547
|
};
|
|
54522
54548
|
}
|
|
54523
|
-
await
|
|
54549
|
+
await sleep3(Math.min(remaining, Math.max(HOST_RUNTIME_POLICY16.agent_next_poll_min_ms, result.retry_after_ms)));
|
|
54524
54550
|
}
|
|
54525
54551
|
};
|
|
54526
54552
|
foregroundAssignmentHeartbeat = async (config2, parsed, dependencies, warnings) => {
|
|
@@ -55054,7 +55080,7 @@ Waiting for approval...
|
|
|
55054
55080
|
}
|
|
55055
55081
|
const session = await agentSession(config2, dependencies, warnings);
|
|
55056
55082
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
55057
|
-
const
|
|
55083
|
+
const sleep3 = dependencies.sleep ?? (async (milliseconds) => {
|
|
55058
55084
|
await new Promise((resolve16) => setTimeout(resolve16, milliseconds));
|
|
55059
55085
|
});
|
|
55060
55086
|
const stopAt = now().getTime() + parsed.waitSeconds * MS_PER_SECOND;
|
|
@@ -55172,7 +55198,7 @@ Waiting for approval...
|
|
|
55172
55198
|
` : ""
|
|
55173
55199
|
};
|
|
55174
55200
|
}
|
|
55175
|
-
await
|
|
55201
|
+
await sleep3(Math.max(
|
|
55176
55202
|
HOST_RUNTIME_POLICY16.agent_assignment_poll_min_ms,
|
|
55177
55203
|
Math.min(
|
|
55178
55204
|
result.retry_after_ms || HOST_RUNTIME_POLICY16.agent_assignment_poll_fallback_ms,
|
|
@@ -60494,45 +60520,10 @@ var init_billing = __esm({
|
|
|
60494
60520
|
|
|
60495
60521
|
// lib/api/market-data.ts
|
|
60496
60522
|
async function getRecentCandles(limit, exchange = "kraken", symbol2 = "PI_XBTUSD", timeframe = "1m", signal) {
|
|
60497
|
-
|
|
60498
|
-
|
|
60499
|
-
|
|
60500
|
-
|
|
60501
|
-
kind: "runtime",
|
|
60502
|
-
label: "market_data_api:candles_recent",
|
|
60503
|
-
method: "GET",
|
|
60504
|
-
url: requestUrl2,
|
|
60505
|
-
note: `symbol=${symbol2} exchange=${exchange} timeframe=${timeframe} limit=${limit}`
|
|
60506
|
-
});
|
|
60507
|
-
let response = null;
|
|
60508
|
-
try {
|
|
60509
|
-
response = await apiFetch(requestUrl2, {
|
|
60510
|
-
cache: "no-store",
|
|
60511
|
-
signal: requestSignal
|
|
60512
|
-
});
|
|
60513
|
-
if (!response.ok) {
|
|
60514
|
-
const error48 = await buildMarketDataFetchError(response, "recent candles", "/candles/recent");
|
|
60515
|
-
trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
|
|
60516
|
-
trace.completeError(error48, response.status);
|
|
60517
|
-
console.error(`[API] ${error48.message} URL: ${response.url}`);
|
|
60518
|
-
throw error48;
|
|
60519
|
-
}
|
|
60520
|
-
trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
|
|
60521
|
-
const payload = await response.json();
|
|
60522
|
-
trace.completeSuccess(response.status);
|
|
60523
|
-
return payload;
|
|
60524
|
-
} catch (error48) {
|
|
60525
|
-
if (response && !response.ok) throw error48;
|
|
60526
|
-
if (response && !isAbortLikeError(error48)) {
|
|
60527
|
-
const failure2 = buildMarketDataResponseBodyError(error48, "recent candles", response, "/candles/recent");
|
|
60528
|
-
trace.completeError(failure2, response.status);
|
|
60529
|
-
throw failure2;
|
|
60530
|
-
}
|
|
60531
|
-
trace.completeError(error48, response?.status ?? null);
|
|
60532
|
-
if (isAbortLikeError(error48)) throw error48;
|
|
60533
|
-
throw buildMarketDataNetworkError(error48, "recent candles", "/candles/recent");
|
|
60534
|
-
}
|
|
60535
|
-
}, { signal, shareAbortScoped: true });
|
|
60523
|
+
return (await readRecentCandles(limit, exchange, symbol2, timeframe, signal, null)).candles;
|
|
60524
|
+
}
|
|
60525
|
+
async function getRecentCandlesForProfile(profileId, limit, exchange, symbol2, timeframe, signal) {
|
|
60526
|
+
return readRecentCandles(limit, exchange, symbol2, timeframe, signal, profileId);
|
|
60536
60527
|
}
|
|
60537
60528
|
async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal) {
|
|
60538
60529
|
const requestKey = `live-ticker:${symbol2}:${exchange}`;
|
|
@@ -60596,7 +60587,7 @@ async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
|
60596
60587
|
}
|
|
60597
60588
|
return response.json();
|
|
60598
60589
|
}
|
|
60599
|
-
var ExecutionAssetMetadataRequestError, CLIENT_EXECUTION_METADATA_DEVICE_READ, executionMetadataNeedsDeviceRead;
|
|
60590
|
+
var CANDLES_MISSING_HEADER, CandlesMissingRangeError, parseCandlesMissing, readRecentCandles, ExecutionAssetMetadataRequestError, CLIENT_EXECUTION_METADATA_DEVICE_READ, executionMetadataNeedsDeviceRead;
|
|
60600
60591
|
var init_market_data = __esm({
|
|
60601
60592
|
"lib/api/market-data.ts"() {
|
|
60602
60593
|
"use strict";
|
|
@@ -60609,6 +60600,67 @@ var init_market_data = __esm({
|
|
|
60609
60600
|
init_network_debug();
|
|
60610
60601
|
init_shared();
|
|
60611
60602
|
init_constants();
|
|
60603
|
+
CANDLES_MISSING_HEADER = "X-VTX-Candles-Missing";
|
|
60604
|
+
CandlesMissingRangeError = class extends Error {
|
|
60605
|
+
};
|
|
60606
|
+
parseCandlesMissing = (value) => {
|
|
60607
|
+
if (value === null || value.trim() === "") return null;
|
|
60608
|
+
const [startText, endText, ...extra] = value.split(",");
|
|
60609
|
+
const startMs = Number(startText?.trim());
|
|
60610
|
+
const endMs = Number(endText?.trim());
|
|
60611
|
+
if (extra.length > 0 || !Number.isSafeInteger(startMs) || !Number.isSafeInteger(endMs) || startMs > endMs) {
|
|
60612
|
+
throw new CandlesMissingRangeError(`The candle answer named an unreadable missing range: ${sanitizeRuntimeDiagnosticValue(value)}`);
|
|
60613
|
+
}
|
|
60614
|
+
return { startMs, endMs };
|
|
60615
|
+
};
|
|
60616
|
+
readRecentCandles = async (limit, exchange, symbol2, timeframe, signal, profileId) => {
|
|
60617
|
+
const params = new URLSearchParams({ limit: limit.toString(), exchange, symbol: symbol2, timeframe });
|
|
60618
|
+
const requestUrl2 = `${getApiUrl()}/candles/recent?${params.toString()}`;
|
|
60619
|
+
const forProfile = profileId === null ? {} : { credentials: "include", headers: getProfileHeaders({}, profileId) };
|
|
60620
|
+
return shareClientGetRequest(`recent-candles:${profileId ?? "none"}:${params.toString()}`, async (requestSignal) => {
|
|
60621
|
+
const trace = startRuntimeNetworkDebugTrace({
|
|
60622
|
+
kind: "runtime",
|
|
60623
|
+
label: "market_data_api:candles_recent",
|
|
60624
|
+
method: "GET",
|
|
60625
|
+
url: requestUrl2,
|
|
60626
|
+
note: `symbol=${symbol2} exchange=${exchange} timeframe=${timeframe} limit=${limit}`
|
|
60627
|
+
});
|
|
60628
|
+
let response = null;
|
|
60629
|
+
try {
|
|
60630
|
+
response = await apiFetch(requestUrl2, {
|
|
60631
|
+
...forProfile,
|
|
60632
|
+
cache: "no-store",
|
|
60633
|
+
signal: requestSignal
|
|
60634
|
+
});
|
|
60635
|
+
if (!response.ok) {
|
|
60636
|
+
const error48 = await buildMarketDataFetchError(response, "recent candles", "/candles/recent");
|
|
60637
|
+
trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
|
|
60638
|
+
trace.completeError(error48, response.status);
|
|
60639
|
+
console.error(`[API] ${error48.message} URL: ${response.url}`);
|
|
60640
|
+
throw error48;
|
|
60641
|
+
}
|
|
60642
|
+
trace.attachResponse({ status: response.status, statusText: response.statusText, url: response.url });
|
|
60643
|
+
const missing2 = parseCandlesMissing(response.headers.get(CANDLES_MISSING_HEADER));
|
|
60644
|
+
const payload = await response.json();
|
|
60645
|
+
trace.completeSuccess(response.status);
|
|
60646
|
+
return { candles: payload, missing: missing2 };
|
|
60647
|
+
} catch (error48) {
|
|
60648
|
+
if (response && !response.ok) throw error48;
|
|
60649
|
+
if (response && error48 instanceof CandlesMissingRangeError) {
|
|
60650
|
+
trace.completeError(error48, response.status);
|
|
60651
|
+
throw error48;
|
|
60652
|
+
}
|
|
60653
|
+
if (response && !isAbortLikeError(error48)) {
|
|
60654
|
+
const failure2 = buildMarketDataResponseBodyError(error48, "recent candles", response, "/candles/recent");
|
|
60655
|
+
trace.completeError(failure2, response.status);
|
|
60656
|
+
throw failure2;
|
|
60657
|
+
}
|
|
60658
|
+
trace.completeError(error48, response?.status ?? null);
|
|
60659
|
+
if (isAbortLikeError(error48)) throw error48;
|
|
60660
|
+
throw buildMarketDataNetworkError(error48, "recent candles", "/candles/recent");
|
|
60661
|
+
}
|
|
60662
|
+
}, { signal, shareAbortScoped: true });
|
|
60663
|
+
};
|
|
60612
60664
|
ExecutionAssetMetadataRequestError = class extends Error {
|
|
60613
60665
|
constructor(message, status, retryAfterMs, code = null) {
|
|
60614
60666
|
super(message);
|
|
@@ -61626,7 +61678,7 @@ var init_server_loop_account_value = __esm({
|
|
|
61626
61678
|
});
|
|
61627
61679
|
|
|
61628
61680
|
// lib/runtime/hyperliquid-account-contract.ts
|
|
61629
|
-
var toNumber2, firstNumber, roundTo, canonicalAvailableMargin, spotBalanceValueUsd, normalizeSpotBalancesFromInfoResponse, sumBalanceHoldUsd2, sumPositionUnrealizedPnl, resolveTotalUnrealizedPnl, approximatelyEqualAccountValues, accountValueThresholds, serverLoopValuation, serverLoopValuationCountsSpot, buildAccountSummaryFromInfoResponses;
|
|
61681
|
+
var toNumber2, firstNumber, roundTo, canonicalAvailableMargin, crossMarginRatio, spotBalanceValueUsd, normalizeSpotBalancesFromInfoResponse, sumBalanceHoldUsd2, sumPositionUnrealizedPnl, resolveTotalUnrealizedPnl, approximatelyEqualAccountValues, accountValueThresholds, serverLoopValuation, serverLoopValuationCountsSpot, buildAccountSummaryFromInfoResponses;
|
|
61630
61682
|
var init_hyperliquid_account_contract = __esm({
|
|
61631
61683
|
"lib/runtime/hyperliquid-account-contract.ts"() {
|
|
61632
61684
|
"use strict";
|
|
@@ -61655,6 +61707,7 @@ var init_hyperliquid_account_contract = __esm({
|
|
|
61655
61707
|
};
|
|
61656
61708
|
roundTo = (value, digits = HYPERLIQUID_ACCOUNT_ROUNDING_DECIMALS) => Number(value.toFixed(digits));
|
|
61657
61709
|
canonicalAvailableMargin = (accountValue, totalMarginUsed) => Math.max(0, accountValue - totalMarginUsed);
|
|
61710
|
+
crossMarginRatio = (maintenanceMargin, accountValue) => accountValue > 0 ? maintenanceMargin / accountValue : 0;
|
|
61658
61711
|
spotBalanceValueUsd = (balance, coin, total) => {
|
|
61659
61712
|
const explicit = firstNumber([balance?.value_usd, balance?.usdValue, balance?.usdcValue], Number.NaN);
|
|
61660
61713
|
if (Number.isFinite(explicit)) {
|
|
@@ -61781,7 +61834,7 @@ var init_hyperliquid_account_contract = __esm({
|
|
|
61781
61834
|
total_margin_used,
|
|
61782
61835
|
available_margin: roundTo(canonicalAvailableMargin(account_value, total_margin_used)),
|
|
61783
61836
|
withdrawable,
|
|
61784
|
-
cross_margin_ratio:
|
|
61837
|
+
cross_margin_ratio: crossMarginRatio(maintenance_margin, account_value),
|
|
61785
61838
|
maintenance_margin,
|
|
61786
61839
|
cross_account_leverage: account_value > 0 ? totalNtlPos / account_value : 0,
|
|
61787
61840
|
total_unrealized_pnl: resolveTotalUnrealizedPnl(perpsResponse),
|
|
@@ -94982,7 +95035,7 @@ var init_hyperliquid_signer = __esm({
|
|
|
94982
95035
|
});
|
|
94983
95036
|
|
|
94984
95037
|
// lib/runtime/hyperliquid-client.ts
|
|
94985
|
-
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, normalizeSymbol, normalizeBotMarket, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, hostNonceAllocator, allocateActionNonce, generateHyperliquidNonce, normalizeDecimalString, HYPERLIQUID_PRICE_SIGNIFICANT_FIGURES, HYPERLIQUID_INTEGER_PRICE_MINIMUM, shortestDecimalParts, formatHyperliquidPerpPriceGrid, formatHyperliquidTriggerPriceWire, hyperliquidOrderPriceRounding, formatHyperliquidOrderPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfoRead, postHyperliquidInfo, fetchBrowserHyperliquidInfoPayload, fetchBrowserHyperliquidInfoRead, fetchBrowserHyperliquidInfoText, coerceMarketMaxLeverage, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderNonNegativeNumber, NATIVE_FIRED_TRIGGER_CONDITION, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber, parseFundingUsdcFromInfoPosition, isExchangeIsolatedOnly, resolveLeverageTarget, computeHip3AssetId,
|
|
95038
|
+
var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, normalizeSymbol, normalizeBotMarket, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, hostNonceAllocator, allocateActionNonce, generateHyperliquidNonce, normalizeDecimalString, HYPERLIQUID_PRICE_SIGNIFICANT_FIGURES, HYPERLIQUID_INTEGER_PRICE_MINIMUM, shortestDecimalParts, formatHyperliquidPerpPriceGrid, formatHyperliquidTriggerPriceWire, hyperliquidOrderPriceRounding, formatHyperliquidOrderPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfoRead, postHyperliquidInfo, fetchBrowserHyperliquidInfoPayload, fetchBrowserHyperliquidInfoRead, fetchBrowserHyperliquidInfoText, coerceMarketMaxLeverage, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderNonNegativeNumber, NATIVE_FIRED_TRIGGER_CONDITION, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber, parseFundingUsdcFromInfoPosition, isExchangeIsolatedOnly, resolveLeverageTarget, computeHip3AssetId, buildAssetInfosFromMetaResponse, requireWalletAddress, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, readDeviceExecutionAssetMetadata, requireBotProfileId, executionAssetMetadataFor, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, decimalUnits, quantizeHyperliquidOrderSizeValue, hyperliquidSignedSizeMatchesRequestedSize, finitePositive, readDevicePrivateExecutionContext, quantizeHyperliquidOrderSize, listBrowserMarketListDexes, browserMarketListMaxMarkets, cutBrowserMarketList, readBrowserPerpDexIndexes, readBrowserMarketListDex, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, signHyperliquidPreparedAction, buildHyperliquidCancelAction, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeverageAction, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderAction, buildHyperliquidMarketOrderPayload, buildHyperliquidLimitOrderAction, buildHyperliquidLimitOrderPayload, buildHyperliquidTriggerOrderAction, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchAction, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderAction, buildHyperliquidModifyOrderPayload, TRAILING_PCT_PATTERN, buildHyperliquidTrailingStopAction, buildHyperliquidTrailingStopPayload, extractHyperliquidExchangeError, acknowledgementLookupPacing, lookupUntilListed, resolveHyperliquidTriggerAcknowledgements, readHyperliquidTrailingStopAcknowledgement, resolveHyperliquidModifyAcknowledgement, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, exchangeRejectionReason, exchangeActionPriority, submitHyperliquidExchangePayload;
|
|
94986
95039
|
var init_hyperliquid_client = __esm({
|
|
94987
95040
|
"lib/runtime/hyperliquid-client.ts"() {
|
|
94988
95041
|
"use strict";
|
|
@@ -95381,18 +95434,6 @@ var init_hyperliquid_client = __esm({
|
|
|
95381
95434
|
isCross: isExchangeIsolatedOnly(asset) ? false : isCross !== false
|
|
95382
95435
|
});
|
|
95383
95436
|
computeHip3AssetId = (perpDexIndex, indexInMeta) => HYPERLIQUID_EXCHANGE_SPECIFICATION.hip3_asset_id_base + Math.trunc(perpDexIndex) * HYPERLIQUID_EXCHANGE_SPECIFICATION.hip3_asset_id_dex_stride + Math.trunc(indexInMeta);
|
|
95384
|
-
getPerpDexIndexMap = (payload) => {
|
|
95385
|
-
if (!Array.isArray(payload)) {
|
|
95386
|
-
throw new Error("Malformed Hyperliquid perp DEX response.");
|
|
95387
|
-
}
|
|
95388
|
-
const indexes = /* @__PURE__ */ new Map();
|
|
95389
|
-
payload.forEach((raw, index) => {
|
|
95390
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return;
|
|
95391
|
-
const name = String(raw.name || "").trim().toLowerCase();
|
|
95392
|
-
if (name) indexes.set(name, index);
|
|
95393
|
-
});
|
|
95394
|
-
return indexes;
|
|
95395
|
-
};
|
|
95396
95437
|
buildAssetInfosFromMetaResponse = (payload, options) => {
|
|
95397
95438
|
if (!Array.isArray(payload) || payload.length < HYPERLIQUID_META_AND_ASSET_CTXS_PARTS) {
|
|
95398
95439
|
throw new Error("Malformed Hyperliquid asset metadata response.");
|
|
@@ -95442,7 +95483,9 @@ var init_hyperliquid_client = __esm({
|
|
|
95442
95483
|
change_24h: prevDayPx > 0 ? (markPx - prevDayPx) / prevDayPx : 0,
|
|
95443
95484
|
funding_8h: toFiniteNumber(ctx.funding, 0),
|
|
95444
95485
|
volume_24h: volume,
|
|
95445
|
-
open_interest: toFiniteNumber(ctx.openInterest, 0)
|
|
95486
|
+
open_interest: toFiniteNumber(ctx.openInterest, 0),
|
|
95487
|
+
// As the server's catalog marks it: a delisted market is never a candidate.
|
|
95488
|
+
is_delisted: asset.isDelisted === true
|
|
95446
95489
|
});
|
|
95447
95490
|
if (options.maxMarkets !== null && assets.length >= options.maxMarkets) {
|
|
95448
95491
|
break;
|
|
@@ -95767,7 +95810,7 @@ var init_hyperliquid_client = __esm({
|
|
|
95767
95810
|
return Number.isInteger(maxMarketsTotal) && Number(maxMarketsTotal) > 0 ? Number(maxMarketsTotal) : null;
|
|
95768
95811
|
};
|
|
95769
95812
|
cutBrowserMarketList = (assets, config2) => [...assets].sort((a, b3) => toFiniteNumber(b3.volume_24h, 0) - toFiniteNumber(a.volume_24h, 0)).slice(0, browserMarketListMaxMarkets(config2) ?? assets.length);
|
|
95770
|
-
readBrowserPerpDexIndexes = async (input) =>
|
|
95813
|
+
readBrowserPerpDexIndexes = async (input) => perpDexIndexes(await postHyperliquidInfo(input, { type: "perpDexs" }, "hyperliquid.perpDexs"));
|
|
95771
95814
|
readBrowserMarketListDex = async (input, dex, perpDexIndex) => {
|
|
95772
95815
|
let payload;
|
|
95773
95816
|
try {
|
|
@@ -96173,7 +96216,7 @@ var init_hyperliquid_client = __esm({
|
|
|
96173
96216
|
total_margin_used: totalMarginUsed,
|
|
96174
96217
|
available_margin: canonicalAvailableMargin(accountValue, totalMarginUsed),
|
|
96175
96218
|
withdrawable,
|
|
96176
|
-
cross_margin_ratio:
|
|
96219
|
+
cross_margin_ratio: crossMarginRatio(maintenanceMargin, accountValue),
|
|
96177
96220
|
maintenance_margin: maintenanceMargin,
|
|
96178
96221
|
cross_account_leverage: accountValue > 0 ? totalNtlPos / accountValue : 0,
|
|
96179
96222
|
total_unrealized_pnl: positions.reduce((total, position) => total + toFiniteNumber(position.unrealized_pnl, 0), 0),
|
|
@@ -99094,7 +99137,7 @@ async function getClientRuntimeStatuses(profileIds, signal, options) {
|
|
|
99094
99137
|
ttlMs: viewer.requestKey ? 0 : CLIENT_RUNTIME_STATUSES_DEDUPE_TTL_MS
|
|
99095
99138
|
});
|
|
99096
99139
|
}
|
|
99097
|
-
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, createRuntimeRequestError, parseClientRuntimeRequestContext, recordRuntimeAuthFailureBreadcrumb, classifyRuntimeRequestError, annotateRuntimeRequestError, CLIENT_RUNTIME_RETRYABLE_STATUSES, isRetryableClientRuntimeStatus, shouldRetryClientRuntimeHttpStatus, isRuntimeIdempotencyInProgressError, isRetryableRuntimeConflictError, resolveClientRuntimeRetryDelayMs, 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, protectiveBoundClientExchangeMutations, rememberProtectiveBoundClientExchangeMutation, isProtectiveBoundClientExchangeMutation, postClientExchangeMutationReconciliation, scheduleClientExchangeMutationReconciliation, postClientDeviceReport, reportClientTradeMarketRead;
|
|
99140
|
+
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, resolveClientRuntimeRetryDelayMs, 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, protectiveBoundClientExchangeMutations, rememberProtectiveBoundClientExchangeMutation, isProtectiveBoundClientExchangeMutation, postClientExchangeMutationReconciliation, scheduleClientExchangeMutationReconciliation, postClientDeviceReport, reportClientTradeMarketRead;
|
|
99098
99141
|
var init_api2 = __esm({
|
|
99099
99142
|
"lib/api.ts"() {
|
|
99100
99143
|
"use strict";
|
|
@@ -99327,6 +99370,17 @@ var init_api2 = __esm({
|
|
|
99327
99370
|
}
|
|
99328
99371
|
return clientRuntimeLeaseEndedFromCode(error48, statusCode) === true;
|
|
99329
99372
|
};
|
|
99373
|
+
readRetryableRuntimeRefusalDelayMs = (error48) => {
|
|
99374
|
+
const typed = error48;
|
|
99375
|
+
if (!typed || typed.retryable !== true || typed.status !== HTTP_STATUS.CONFLICT) return null;
|
|
99376
|
+
if (typeof typed.retryAfterMs === "number" && Number.isFinite(typed.retryAfterMs)) {
|
|
99377
|
+
return Math.max(0, typed.retryAfterMs);
|
|
99378
|
+
}
|
|
99379
|
+
if (typeof typed.retryAfterSeconds === "number" && Number.isFinite(typed.retryAfterSeconds)) {
|
|
99380
|
+
return Math.max(0, typed.retryAfterSeconds * MS_PER_SECOND);
|
|
99381
|
+
}
|
|
99382
|
+
return null;
|
|
99383
|
+
};
|
|
99330
99384
|
createRuntimeRequestError = async (response, defaultMessage) => {
|
|
99331
99385
|
const payload = await getErrorPayloadOrEmpty(response);
|
|
99332
99386
|
const nestedDetail = payload.detail && typeof payload.detail === "object" && !Array.isArray(payload.detail) ? payload.detail : null;
|
|
@@ -100751,7 +100805,7 @@ var init_vault = __esm({
|
|
|
100751
100805
|
});
|
|
100752
100806
|
|
|
100753
100807
|
// lib/runtime/browser-trading.ts
|
|
100754
|
-
var protectiveWriteRecorder, ProtectiveWriteRecordedError, recordInsteadOfSending, resolveProfileId, requirePositiveNumber, assertFreshPreparedContext,
|
|
100808
|
+
var protectiveWriteRecorder, ProtectiveWriteRecordedError, recordInsteadOfSending, resolveProfileId, requirePositiveNumber, assertFreshPreparedContext, throwIfAborted2, UUID_PATTERN2, createExchangeMutationIdentity, requireClientExchangeExpiresAfterSeconds, loadSigningKey, priorityOf, resolveSigningKey, requireWalletAddress2, resolveEstimatedPrice, executeClientLeverageUpdate, executeClientMarketOrder, resolveClientProtectiveSigningKey, executeClientPreparedProtectiveAction, executeClientLimitOrder, executeClientTriggerOrder, executeClientOrderBatch, executeClientModifyOrder, executeClientCancelOrder, executeClientTrailingStop, executeClientClosePosition;
|
|
100755
100809
|
var init_browser_trading = __esm({
|
|
100756
100810
|
"lib/runtime/browser-trading.ts"() {
|
|
100757
100811
|
"use strict";
|
|
@@ -100799,7 +100853,7 @@ var init_browser_trading = __esm({
|
|
|
100799
100853
|
throw new Error("Copy Trading private execution context expired before signing.");
|
|
100800
100854
|
}
|
|
100801
100855
|
};
|
|
100802
|
-
|
|
100856
|
+
throwIfAborted2 = (signal) => {
|
|
100803
100857
|
if (signal?.aborted) {
|
|
100804
100858
|
throw new DOMException("The operation was aborted.", "AbortError");
|
|
100805
100859
|
}
|
|
@@ -100913,9 +100967,9 @@ var init_browser_trading = __esm({
|
|
|
100913
100967
|
};
|
|
100914
100968
|
executeClientLeverageUpdate = async (input) => {
|
|
100915
100969
|
input = { ...input, publicRequestPriority: "trading_execute" };
|
|
100916
|
-
|
|
100970
|
+
throwIfAborted2(input.signal);
|
|
100917
100971
|
const signingKey = await resolveSigningKey(input);
|
|
100918
|
-
|
|
100972
|
+
throwIfAborted2(input.signal);
|
|
100919
100973
|
const mutation = createExchangeMutationIdentity(false, input);
|
|
100920
100974
|
const payload = await buildHyperliquidUpdateLeveragePayload({
|
|
100921
100975
|
config: input.config ?? null,
|
|
@@ -100950,11 +101004,11 @@ var init_browser_trading = __esm({
|
|
|
100950
101004
|
if ((input.positionChildren?.length ?? 0) > 0 && input.protection && !input.protection.native) {
|
|
100951
101005
|
throw new Error("An entry carries either native position children or server-owned protection, not both.");
|
|
100952
101006
|
}
|
|
100953
|
-
|
|
101007
|
+
throwIfAborted2(input.signal);
|
|
100954
101008
|
const signingKey = await resolveSigningKey(input);
|
|
100955
|
-
|
|
101009
|
+
throwIfAborted2(input.signal);
|
|
100956
101010
|
const estimatedPrice = await resolveEstimatedPrice(input.config, input.symbol, input.estimatedPrice, input.signal, input.publicRequestPriority);
|
|
100957
|
-
|
|
101011
|
+
throwIfAborted2(input.signal);
|
|
100958
101012
|
assertFreshPreparedContext(input.preparedContext);
|
|
100959
101013
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
100960
101014
|
const payload = await buildHyperliquidMarketOrderPayload({
|
|
@@ -101002,9 +101056,9 @@ var init_browser_trading = __esm({
|
|
|
101002
101056
|
resolveClientProtectiveSigningKey = (input) => resolveSigningKey({ ...input, publicRequestPriority: "trading_reduce" });
|
|
101003
101057
|
executeClientPreparedProtectiveAction = async (input) => {
|
|
101004
101058
|
input = { ...input, publicRequestPriority: "trading_reduce" };
|
|
101005
|
-
|
|
101059
|
+
throwIfAborted2(input.signal);
|
|
101006
101060
|
const signingKey = await resolveSigningKey(input);
|
|
101007
|
-
|
|
101061
|
+
throwIfAborted2(input.signal);
|
|
101008
101062
|
const payload = await signHyperliquidPreparedAction({
|
|
101009
101063
|
config: input.config ?? null,
|
|
101010
101064
|
publicRequestPriority: priorityOf(input),
|
|
@@ -101036,9 +101090,9 @@ var init_browser_trading = __esm({
|
|
|
101036
101090
|
};
|
|
101037
101091
|
executeClientLimitOrder = async (input) => {
|
|
101038
101092
|
input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
|
|
101039
|
-
|
|
101093
|
+
throwIfAborted2(input.signal);
|
|
101040
101094
|
const signingKey = await resolveSigningKey(input);
|
|
101041
|
-
|
|
101095
|
+
throwIfAborted2(input.signal);
|
|
101042
101096
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
101043
101097
|
const payload = await buildHyperliquidLimitOrderPayload({
|
|
101044
101098
|
config: input.config ?? null,
|
|
@@ -101083,9 +101137,9 @@ var init_browser_trading = __esm({
|
|
|
101083
101137
|
triggerPrice: input.triggerPrice,
|
|
101084
101138
|
isTakeProfit: input.isTakeProfit
|
|
101085
101139
|
});
|
|
101086
|
-
|
|
101140
|
+
throwIfAborted2(input.signal);
|
|
101087
101141
|
const signingKey = await resolveSigningKey(input);
|
|
101088
|
-
|
|
101142
|
+
throwIfAborted2(input.signal);
|
|
101089
101143
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
101090
101144
|
const payload = await buildHyperliquidTriggerOrderPayload({
|
|
101091
101145
|
config: input.config ?? null,
|
|
@@ -101136,9 +101190,9 @@ var init_browser_trading = __esm({
|
|
|
101136
101190
|
positionOrder: member.positionOrder === true
|
|
101137
101191
|
}))
|
|
101138
101192
|
});
|
|
101139
|
-
|
|
101193
|
+
throwIfAborted2(input.signal);
|
|
101140
101194
|
const signingKey = await resolveSigningKey(input);
|
|
101141
|
-
|
|
101195
|
+
throwIfAborted2(input.signal);
|
|
101142
101196
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
101143
101197
|
const payload = await buildHyperliquidOrderBatchPayload({
|
|
101144
101198
|
config: input.config ?? null,
|
|
@@ -101181,9 +101235,9 @@ var init_browser_trading = __esm({
|
|
|
101181
101235
|
size: input.size,
|
|
101182
101236
|
triggerPrice: input.triggerPrice
|
|
101183
101237
|
});
|
|
101184
|
-
|
|
101238
|
+
throwIfAborted2(input.signal);
|
|
101185
101239
|
const signingKey = await resolveSigningKey(input);
|
|
101186
|
-
|
|
101240
|
+
throwIfAborted2(input.signal);
|
|
101187
101241
|
const mutation = createExchangeMutationIdentity(true, input);
|
|
101188
101242
|
const payload = await buildHyperliquidModifyOrderPayload({
|
|
101189
101243
|
config: input.config ?? null,
|
|
@@ -101230,9 +101284,9 @@ var init_browser_trading = __esm({
|
|
|
101230
101284
|
executeClientCancelOrder = async (input) => {
|
|
101231
101285
|
input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
|
|
101232
101286
|
recordInsteadOfSending({ kind: "cancel", symbol: input.symbol, orderId: input.orderId });
|
|
101233
|
-
|
|
101287
|
+
throwIfAborted2(input.signal);
|
|
101234
101288
|
const signingKey = await resolveSigningKey(input);
|
|
101235
|
-
|
|
101289
|
+
throwIfAborted2(input.signal);
|
|
101236
101290
|
const mutation = createExchangeMutationIdentity(false, input);
|
|
101237
101291
|
const payload = await buildHyperliquidCancelPayload({
|
|
101238
101292
|
config: input.config ?? null,
|
|
@@ -101271,9 +101325,9 @@ var init_browser_trading = __esm({
|
|
|
101271
101325
|
size: input.size,
|
|
101272
101326
|
retracement: input.retracement
|
|
101273
101327
|
});
|
|
101274
|
-
|
|
101328
|
+
throwIfAborted2(input.signal);
|
|
101275
101329
|
const signingKey = await resolveSigningKey(input);
|
|
101276
|
-
|
|
101330
|
+
throwIfAborted2(input.signal);
|
|
101277
101331
|
const mutation = createExchangeMutationIdentity(false, input);
|
|
101278
101332
|
const payload = await buildHyperliquidTrailingStopPayload({
|
|
101279
101333
|
config: input.config ?? null,
|
|
@@ -101307,7 +101361,7 @@ var init_browser_trading = __esm({
|
|
|
101307
101361
|
};
|
|
101308
101362
|
executeClientClosePosition = async (input) => {
|
|
101309
101363
|
input = { ...input, publicRequestPriority: "trading_reduce" };
|
|
101310
|
-
|
|
101364
|
+
throwIfAborted2(input.signal);
|
|
101311
101365
|
const profileId = resolveProfileId(input.profileId);
|
|
101312
101366
|
const currentPosition = input.position ?? await fetchBrowserPosition({
|
|
101313
101367
|
config: input.config ?? null,
|
|
@@ -101507,7 +101561,7 @@ var init_server_prompt_rescue_account_contract = __esm({
|
|
|
101507
101561
|
total_margin_used: totalMarginUsed,
|
|
101508
101562
|
available_margin: availableMargin,
|
|
101509
101563
|
withdrawable,
|
|
101510
|
-
cross_margin_ratio:
|
|
101564
|
+
cross_margin_ratio: crossMarginRatio(maintenanceMargin, accountValue),
|
|
101511
101565
|
maintenance_margin: maintenanceMargin,
|
|
101512
101566
|
cross_account_leverage: accountValue > 0 ? totalNotional / accountValue : 0,
|
|
101513
101567
|
total_unrealized_pnl: totalUnrealizedPnl,
|
|
@@ -102144,7 +102198,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
102144
102198
|
}
|
|
102145
102199
|
const position = entry.position && typeof entry.position === "object" ? { ...entry.position } : entry.position;
|
|
102146
102200
|
const rawCoin = String(entry.coin || position?.coin || "").trim();
|
|
102147
|
-
const normalizedCoin = rawCoin.includes(":") ?
|
|
102201
|
+
const normalizedCoin = normalizeHyperliquidMarketSymbol(rawCoin.includes(":") ? rawCoin : `${dex}:${rawCoin}`);
|
|
102148
102202
|
return {
|
|
102149
102203
|
...entry,
|
|
102150
102204
|
coin: normalizedCoin,
|
|
@@ -107112,7 +107166,7 @@ var init_native_protection_device = __esm({
|
|
|
107112
107166
|
});
|
|
107113
107167
|
|
|
107114
107168
|
// lib/runtime/runtime-execution.ts
|
|
107115
|
-
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, nativeSettingsOf, nativePassEnded, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops,
|
|
107169
|
+
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, nativeSettingsOf, nativePassEnded, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionListings, runtimeProtectionListing, resolveServerNativeEntry, SERVER_NATIVE_LEGACY_REFUSAL, isServerNativeLegacyRefusal, serverUserCancelLookup, serverModeProtectionOwner, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked;
|
|
107116
107170
|
var init_runtime_execution = __esm({
|
|
107117
107171
|
"lib/runtime/runtime-execution.ts"() {
|
|
107118
107172
|
"use strict";
|
|
@@ -107123,6 +107177,7 @@ var init_runtime_execution = __esm({
|
|
|
107123
107177
|
init_order_identity();
|
|
107124
107178
|
init_runtime_policy_generated2();
|
|
107125
107179
|
init_constants();
|
|
107180
|
+
init_abort();
|
|
107126
107181
|
init_bounded_lock();
|
|
107127
107182
|
init_client_runtime_ownership_errors();
|
|
107128
107183
|
init_api2();
|
|
@@ -107185,7 +107240,7 @@ var init_runtime_execution = __esm({
|
|
|
107185
107240
|
"hyperliquid.activeAssetData"
|
|
107186
107241
|
);
|
|
107187
107242
|
} catch {
|
|
107188
|
-
|
|
107243
|
+
throwIfAborted(input.signal);
|
|
107189
107244
|
return false;
|
|
107190
107245
|
}
|
|
107191
107246
|
const leverage = active?.leverage;
|
|
@@ -112278,7 +112333,7 @@ var init_runtime_execution = __esm({
|
|
|
112278
112333
|
let canonicalCleanupRetained = false;
|
|
112279
112334
|
let replacementDispatchBoundaryCompleted = false;
|
|
112280
112335
|
try {
|
|
112281
|
-
|
|
112336
|
+
throwIfAborted(request.signal);
|
|
112282
112337
|
const modifyResponse = await executeClientModifyOrder({
|
|
112283
112338
|
profileId: request.profileId,
|
|
112284
112339
|
...clientProtectiveMutationAuthority(request),
|
|
@@ -112435,32 +112490,6 @@ var init_runtime_execution = __esm({
|
|
|
112435
112490
|
writeTrackedTrailingStops(profileId, symbol2, updated);
|
|
112436
112491
|
return reports;
|
|
112437
112492
|
};
|
|
112438
|
-
throwIfAborted2 = (signal) => {
|
|
112439
|
-
if (signal?.aborted) {
|
|
112440
|
-
throw new DOMException("The operation was aborted.", "AbortError");
|
|
112441
|
-
}
|
|
112442
|
-
};
|
|
112443
|
-
sleep2 = async (ms, signal) => {
|
|
112444
|
-
await new Promise((resolve16, reject) => {
|
|
112445
|
-
const timer = setTimeout(() => {
|
|
112446
|
-
cleanup();
|
|
112447
|
-
resolve16(void 0);
|
|
112448
|
-
}, ms);
|
|
112449
|
-
const cleanup = () => {
|
|
112450
|
-
clearTimeout(timer);
|
|
112451
|
-
signal?.removeEventListener("abort", onAbort);
|
|
112452
|
-
};
|
|
112453
|
-
const onAbort = () => {
|
|
112454
|
-
cleanup();
|
|
112455
|
-
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
112456
|
-
};
|
|
112457
|
-
if (signal?.aborted) {
|
|
112458
|
-
onAbort();
|
|
112459
|
-
return;
|
|
112460
|
-
}
|
|
112461
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
112462
|
-
});
|
|
112463
|
-
};
|
|
112464
112493
|
isDefinitiveEntryRejection = (error48, entryMutationId) => error48 instanceof HyperliquidExchangeRejectionError && Boolean(entryMutationId) && String(error48.clientMutationId ?? "").trim().toLowerCase() === String(entryMutationId).trim().toLowerCase();
|
|
112465
112494
|
resolveExchangeSizeDecimals = async (symbol2, config2, publicRequestPriority, profileId) => {
|
|
112466
112495
|
const { sz_decimals: sizeDecimals } = await resolveHyperliquidAsset({
|
|
@@ -112502,7 +112531,7 @@ var init_runtime_execution = __esm({
|
|
|
112502
112531
|
if (input.executionMode !== "server" || !decisionSnapshotId || !isDefinitiveEntryRejection(rejection, rejectedMutationId)) return null;
|
|
112503
112532
|
const reason = orderMetadataRetryReason(rejection.message);
|
|
112504
112533
|
if (reason === null) return null;
|
|
112505
|
-
|
|
112534
|
+
throwIfAborted(input.signal);
|
|
112506
112535
|
try {
|
|
112507
112536
|
const asset = await resolveHyperliquidAsset({
|
|
112508
112537
|
symbol: input.executionContext.symbol,
|
|
@@ -112538,12 +112567,12 @@ var init_runtime_execution = __esm({
|
|
|
112538
112567
|
markPrice
|
|
112539
112568
|
};
|
|
112540
112569
|
} catch {
|
|
112541
|
-
|
|
112570
|
+
throwIfAborted(input.signal);
|
|
112542
112571
|
return null;
|
|
112543
112572
|
}
|
|
112544
112573
|
};
|
|
112545
112574
|
resolveCurrentPositionSize = async (input, orderPrice = "decision") => {
|
|
112546
|
-
|
|
112575
|
+
throwIfAborted(input.signal);
|
|
112547
112576
|
const snapshotPositionSize = Number.isFinite(input.executionContext.currentPositionSize) ? Number(input.executionContext.currentPositionSize) : 0;
|
|
112548
112577
|
const decisionPrice = Number.isFinite(input.executionContext.lastPrice) ? Number(input.executionContext.lastPrice) : 0;
|
|
112549
112578
|
const walletAddress = String(input.executionContext.walletAddress || "").trim();
|
|
@@ -112774,7 +112803,7 @@ var init_runtime_execution = __esm({
|
|
|
112774
112803
|
const pending3 = previous.catch(() => void 0).then(async () => {
|
|
112775
112804
|
if (abandoned) return void 0;
|
|
112776
112805
|
startTurn();
|
|
112777
|
-
|
|
112806
|
+
throwIfAborted(request.signal);
|
|
112778
112807
|
if (request.shouldCancelBeforeExchangeOrderDispatch?.()) {
|
|
112779
112808
|
throw new Error(CLIENT_RUNTIME_WINDOW_HANDOFF_BEFORE_PLAN_DISPATCH);
|
|
112780
112809
|
}
|
|
@@ -112845,7 +112874,7 @@ var init_runtime_execution = __esm({
|
|
|
112845
112874
|
}
|
|
112846
112875
|
return judged;
|
|
112847
112876
|
} catch (error48) {
|
|
112848
|
-
|
|
112877
|
+
throwIfAborted(authority.signal);
|
|
112849
112878
|
return plans.map(() => ({ unavailable: error48 }));
|
|
112850
112879
|
}
|
|
112851
112880
|
};
|
|
@@ -112945,7 +112974,8 @@ var init_runtime_execution = __esm({
|
|
|
112945
112974
|
});
|
|
112946
112975
|
} catch (error48) {
|
|
112947
112976
|
const committedClose = getCommittedExecutionReports(error48).find((report) => report.status === "executed" && decisionLegOf(report) === "flip_close");
|
|
112948
|
-
|
|
112977
|
+
const aborted2 = input.signal?.aborted || isAbortLikeError(error48);
|
|
112978
|
+
if (audit.auditId !== null && (!aborted2 || committedClose) && (input.decision === "BUY" || input.decision === "SELL")) {
|
|
112949
112979
|
const reason = String(error48?.reasonCode ?? "");
|
|
112950
112980
|
const orderMayHaveGoneOut = entryDispatched || exitDispatched && !committedClose;
|
|
112951
112981
|
const [status2, reasonCode2] = reason === "outcome_unknown" || !reason && orderMayHaveGoneOut ? ["outcome_unknown", "outcome_unknown"] : ["error", reason === "exchange_rejected" ? "exchange_rejected" : "execution_error"];
|
|
@@ -112964,7 +112994,7 @@ var init_runtime_execution = __esm({
|
|
|
112964
112994
|
...committedClose.execution_metadata,
|
|
112965
112995
|
execution_audit_id: audit.auditId
|
|
112966
112996
|
};
|
|
112967
|
-
await recordAudit(null, {
|
|
112997
|
+
if (!aborted2 || entryDispatched) await recordAudit(null, {
|
|
112968
112998
|
intent: "flip",
|
|
112969
112999
|
side,
|
|
112970
113000
|
requestedUnits: input.units,
|
|
@@ -113045,12 +113075,12 @@ var init_runtime_execution = __esm({
|
|
|
113045
113075
|
const pollMs = Number(input.executionContext.closePositionFreshnessPollMs);
|
|
113046
113076
|
const walletAddress = String(input.executionContext.walletAddress || "").trim();
|
|
113047
113077
|
if (input.executionMode !== "server" || !(pollMs > 0) || !walletAddress) {
|
|
113048
|
-
await
|
|
113078
|
+
await abortableSleep(delayMs, input.signal);
|
|
113049
113079
|
return;
|
|
113050
113080
|
}
|
|
113051
113081
|
const deadline = Date.now() + delayMs;
|
|
113052
113082
|
for (; ; ) {
|
|
113053
|
-
|
|
113083
|
+
throwIfAborted(input.signal);
|
|
113054
113084
|
try {
|
|
113055
113085
|
const snapshot = await fetchBrowserPositionSnapshot(
|
|
113056
113086
|
input.config ?? {},
|
|
@@ -113061,11 +113091,11 @@ var init_runtime_execution = __esm({
|
|
|
113061
113091
|
);
|
|
113062
113092
|
if (Number(snapshot.size) === 0) return;
|
|
113063
113093
|
} catch {
|
|
113064
|
-
|
|
113094
|
+
throwIfAborted(input.signal);
|
|
113065
113095
|
}
|
|
113066
113096
|
const remaining = deadline - Date.now();
|
|
113067
113097
|
if (remaining <= 0) return;
|
|
113068
|
-
await
|
|
113098
|
+
await abortableSleep(Math.min(pollMs, remaining), input.signal);
|
|
113069
113099
|
}
|
|
113070
113100
|
};
|
|
113071
113101
|
maintainClientRuntimeTrailingStops = (request) => withClientProtectivePlanSetMutation(request, request.executionContext.symbol, async () => {
|
|
@@ -113373,7 +113403,7 @@ var init_runtime_execution = __esm({
|
|
|
113373
113403
|
if (!profileId || !walletAddress) return [];
|
|
113374
113404
|
const results = [];
|
|
113375
113405
|
for (const symbol2 of listPendingClientProtectiveSymbols(profileId)) {
|
|
113376
|
-
|
|
113406
|
+
throwIfAborted(input.signal);
|
|
113377
113407
|
const retired = [];
|
|
113378
113408
|
const reports = await withClientProtectivePlanSetMutation({ profileId, signal: input.signal }, symbol2, async () => {
|
|
113379
113409
|
const groups2 = readFreshClientProtectiveGroups(profileId, symbol2);
|
|
@@ -113453,7 +113483,7 @@ var init_runtime_execution = __esm({
|
|
|
113453
113483
|
return carrier;
|
|
113454
113484
|
};
|
|
113455
113485
|
executeClientRuntimeDecisionUnlocked = async (unsizedInput, progress = { committedReports: null }) => {
|
|
113456
|
-
|
|
113486
|
+
throwIfAborted(unsizedInput.signal);
|
|
113457
113487
|
const requestedUnits = Math.max(0, Math.trunc(unsizedInput.units));
|
|
113458
113488
|
appendRuntimeDebugEvent({
|
|
113459
113489
|
label: "execution_start",
|
|
@@ -113502,7 +113532,7 @@ var init_runtime_execution = __esm({
|
|
|
113502
113532
|
{ symbol: unsizedInput.executionContext.symbol, decision: unsizedInput.decision, units: requestedUnits }
|
|
113503
113533
|
], unsizedInput.executionContext.decisionSnapshotCapturedAt))[0];
|
|
113504
113534
|
if ("unavailable" in capacity) {
|
|
113505
|
-
|
|
113535
|
+
throwIfAborted(unsizedInput.signal);
|
|
113506
113536
|
throw capacity.unavailable instanceof Error ? capacity.unavailable : new Error("Positions could not be read before the limit check.");
|
|
113507
113537
|
}
|
|
113508
113538
|
if (!capacity.accepted || !(capacity.units > 0)) {
|
|
@@ -113537,7 +113567,7 @@ var init_runtime_execution = __esm({
|
|
|
113537
113567
|
)
|
|
113538
113568
|
}
|
|
113539
113569
|
};
|
|
113540
|
-
|
|
113570
|
+
throwIfAborted(input.signal);
|
|
113541
113571
|
const decisionSnapshotPositionSize = Number.isFinite(input.executionContext.currentPositionSize) ? Number(input.executionContext.currentPositionSize) : 0;
|
|
113542
113572
|
const decisionSnapshotSignedUnits = signedUnitsFromEntryPosition(
|
|
113543
113573
|
decisionSnapshotPositionSize,
|
|
@@ -113626,7 +113656,7 @@ var init_runtime_execution = __esm({
|
|
|
113626
113656
|
executionSnapshotCapturedAt
|
|
113627
113657
|
} = await resolveCurrentPositionSize(input, serverOrder ? "fresh_mark" : "decision");
|
|
113628
113658
|
let executionPrice = resolvedExecutionPrice;
|
|
113629
|
-
|
|
113659
|
+
throwIfAborted(input.signal);
|
|
113630
113660
|
const currentPosition = buildPositionSnapshot(input.executionContext.symbol, currentPositionSize);
|
|
113631
113661
|
const decisionSnapshotId = String(input.executionContext.decisionSnapshotId ?? "").trim();
|
|
113632
113662
|
const decisionLegMutationId = (leg) => decisionSnapshotId ? clientDecisionMutationId({
|
|
@@ -113768,7 +113798,7 @@ var init_runtime_execution = __esm({
|
|
|
113768
113798
|
};
|
|
113769
113799
|
}
|
|
113770
113800
|
if (input.executionMode === "server") {
|
|
113771
|
-
|
|
113801
|
+
throwIfAborted(input.signal);
|
|
113772
113802
|
const claim = await claimServerHostExecution(
|
|
113773
113803
|
input.profileId,
|
|
113774
113804
|
{
|
|
@@ -113816,7 +113846,7 @@ var init_runtime_execution = __esm({
|
|
|
113816
113846
|
}
|
|
113817
113847
|
}
|
|
113818
113848
|
if (!targetResolution.closeOpposingPosition && classified.reduceOnly !== true && !await serverEntryLeverageAlreadyHeld(input)) {
|
|
113819
|
-
|
|
113849
|
+
throwIfAborted(input.signal);
|
|
113820
113850
|
await executeClientLeverageUpdate({
|
|
113821
113851
|
profileId: input.profileId,
|
|
113822
113852
|
runtimeSessionId: input.sessionId || "__missing_runtime_session__",
|
|
@@ -113831,10 +113861,10 @@ var init_runtime_execution = __esm({
|
|
|
113831
113861
|
leverage: input.executionContext.leverage,
|
|
113832
113862
|
isCross: input.executionContext.marginMode !== "isolated"
|
|
113833
113863
|
});
|
|
113834
|
-
|
|
113864
|
+
throwIfAborted(input.signal);
|
|
113835
113865
|
}
|
|
113836
113866
|
if (classified.intent === "close") {
|
|
113837
|
-
|
|
113867
|
+
throwIfAborted(input.signal);
|
|
113838
113868
|
const closeMutationId = await decisionLegMutationId("close");
|
|
113839
113869
|
const closeResponse = await closeWithServerMetadataRetry("close", closeMutationId, (mutationId, estimatedPrice, assets) => executeClientClosePosition({
|
|
113840
113870
|
mutationId,
|
|
@@ -113922,7 +113952,7 @@ var init_runtime_execution = __esm({
|
|
|
113922
113952
|
];
|
|
113923
113953
|
let flipCloseFillConfirmed = true;
|
|
113924
113954
|
if (targetResolution.closeOpposingPosition) {
|
|
113925
|
-
|
|
113955
|
+
throwIfAborted(input.signal);
|
|
113926
113956
|
const flipCloseMutationId = await decisionLegMutationId("flip_close");
|
|
113927
113957
|
const closeResponse = await closeWithServerMetadataRetry("flip_close", flipCloseMutationId, (mutationId, estimatedPrice, assets) => executeClientClosePosition({
|
|
113928
113958
|
mutationId,
|
|
@@ -114044,7 +114074,7 @@ var init_runtime_execution = __esm({
|
|
|
114044
114074
|
[]
|
|
114045
114075
|
);
|
|
114046
114076
|
await waitForFlipCloseFreshness(input);
|
|
114047
|
-
|
|
114077
|
+
throwIfAborted(input.signal);
|
|
114048
114078
|
await executeClientLeverageUpdate({
|
|
114049
114079
|
profileId: input.profileId,
|
|
114050
114080
|
runtimeSessionId: input.sessionId || "__missing_runtime_session__",
|
|
@@ -114059,7 +114089,7 @@ var init_runtime_execution = __esm({
|
|
|
114059
114089
|
leverage: input.executionContext.leverage,
|
|
114060
114090
|
isCross: input.executionContext.marginMode !== "isolated"
|
|
114061
114091
|
});
|
|
114062
|
-
|
|
114092
|
+
throwIfAborted(input.signal);
|
|
114063
114093
|
if (serverOrder) executionPrice = await readServerOrderMarkPrice(input);
|
|
114064
114094
|
}
|
|
114065
114095
|
const actualUnits = targetResolution.orderUnits;
|
|
@@ -114693,7 +114723,7 @@ var init_runtime_execution = __esm({
|
|
|
114693
114723
|
continue;
|
|
114694
114724
|
}
|
|
114695
114725
|
try {
|
|
114696
|
-
|
|
114726
|
+
throwIfAborted(input.signal);
|
|
114697
114727
|
const liveSnapshot = await fetchBrowserPositionSnapshot(
|
|
114698
114728
|
input.config ?? {},
|
|
114699
114729
|
String(input.executionContext.walletAddress || "").trim(),
|
|
@@ -115357,6 +115387,93 @@ var init_server_protection_sweep = __esm({
|
|
|
115357
115387
|
}
|
|
115358
115388
|
});
|
|
115359
115389
|
|
|
115390
|
+
// lib/runtime/runtime-error-diagnostic-fields.ts
|
|
115391
|
+
var DEVICE_DIAGNOSTICS3, buildRuntimeRequestErrorDiagnosticFields, buildHyperliquidPublicReadDiagnosticFields;
|
|
115392
|
+
var init_runtime_error_diagnostic_fields = __esm({
|
|
115393
|
+
"lib/runtime/runtime-error-diagnostic-fields.ts"() {
|
|
115394
|
+
"use strict";
|
|
115395
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
115396
|
+
init_define_VTX_EXO_POLICY();
|
|
115397
|
+
init_define_VTX_GROK_POLICY();
|
|
115398
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
115399
|
+
init_runtime_policy_generated2();
|
|
115400
|
+
init_constants();
|
|
115401
|
+
init_runtime_redaction();
|
|
115402
|
+
DEVICE_DIAGNOSTICS3 = runtime_policy_generated_default2.trading.engine.client_runtime.device_diagnostics;
|
|
115403
|
+
buildRuntimeRequestErrorDiagnosticFields = (reason) => {
|
|
115404
|
+
if (!reason || typeof reason !== "object" && typeof reason !== "function") {
|
|
115405
|
+
return {};
|
|
115406
|
+
}
|
|
115407
|
+
const record6 = reason;
|
|
115408
|
+
const path = sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestPath || "")).trim();
|
|
115409
|
+
if (!path) {
|
|
115410
|
+
return {};
|
|
115411
|
+
}
|
|
115412
|
+
const numberOrNull = (value) => {
|
|
115413
|
+
if (value === null || value === void 0 || value === "") {
|
|
115414
|
+
return null;
|
|
115415
|
+
}
|
|
115416
|
+
const parsed = Number(value);
|
|
115417
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
115418
|
+
};
|
|
115419
|
+
return {
|
|
115420
|
+
runtime_request_path: path.slice(0, DEVICE_DIAGNOSTICS3.request_path_chars),
|
|
115421
|
+
runtime_request_method: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestMethod || "")).slice(0, DEVICE_DIAGNOSTICS3.request_method_chars) || null,
|
|
115422
|
+
runtime_request_attempt: numberOrNull(record6.runtimeRequestAttempt),
|
|
115423
|
+
runtime_request_max_attempts: numberOrNull(record6.runtimeRequestMaxAttempts),
|
|
115424
|
+
runtime_request_status: numberOrNull(record6.runtimeRequestStatus),
|
|
115425
|
+
runtime_request_error_kind: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestErrorKind || "")).slice(0, DEVICE_DIAGNOSTICS3.error_kind_chars) || null,
|
|
115426
|
+
runtime_request_transient_network: record6.runtimeRequestTransientNetwork === true,
|
|
115427
|
+
runtime_request_deadline_at_ms: numberOrNull(record6.runtimeRequestDeadlineAtMs),
|
|
115428
|
+
runtime_request_deadline_exceeded: record6.runtimeRequestDeadlineExceeded === true,
|
|
115429
|
+
...record6.code === "snapshot_stale" && record6.runtimeRequestStatus === HTTP_STATUS.CONFLICT ? {
|
|
115430
|
+
runtime_rejection_reason_code: "snapshot_stale",
|
|
115431
|
+
snapshot_age_seconds: numberOrNull(record6.runtimeSnapshotAgeSeconds),
|
|
115432
|
+
snapshot_max_age_seconds: numberOrNull(record6.runtimeSnapshotMaxAgeSeconds)
|
|
115433
|
+
} : {},
|
|
115434
|
+
...record6.runtimeRequestId ? {
|
|
115435
|
+
runtime_request_id: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestId)).slice(0, DEVICE_DIAGNOSTICS3.request_id_chars)
|
|
115436
|
+
} : {},
|
|
115437
|
+
...record6.runtimeReconciliationAttempted === true ? {
|
|
115438
|
+
runtime_reconciliation_attempted: true,
|
|
115439
|
+
runtime_reconciliation_elapsed_ms: numberOrNull(record6.runtimeReconciliationElapsedMs),
|
|
115440
|
+
runtime_reconciliation_status: numberOrNull(record6.runtimeReconciliationStatus),
|
|
115441
|
+
runtime_reconciliation_error_kind: sanitizeRuntimeDiagnosticValue(String(record6.runtimeReconciliationErrorKind || "")).slice(0, DEVICE_DIAGNOSTICS3.error_kind_chars) || null,
|
|
115442
|
+
runtime_reconciliation_deadline_exceeded: record6.runtimeReconciliationDeadlineExceeded === true,
|
|
115443
|
+
runtime_reconciliation_request_id: sanitizeRuntimeDiagnosticValue(String(record6.runtimeReconciliationRequestId || "")).slice(0, DEVICE_DIAGNOSTICS3.request_id_chars) || null
|
|
115444
|
+
} : {}
|
|
115445
|
+
};
|
|
115446
|
+
};
|
|
115447
|
+
buildHyperliquidPublicReadDiagnosticFields = (reason) => {
|
|
115448
|
+
let current = reason;
|
|
115449
|
+
const seen = /* @__PURE__ */ new Set();
|
|
115450
|
+
for (let depth = 0; depth < DEVICE_DIAGNOSTICS3.error_cause_max_depth; depth += 1) {
|
|
115451
|
+
if (!current || typeof current !== "object" || seen.has(current)) return {};
|
|
115452
|
+
seen.add(current);
|
|
115453
|
+
const record6 = current;
|
|
115454
|
+
if (record6.name === "HyperliquidPublicReadError" && [
|
|
115455
|
+
"public_budget_exhausted",
|
|
115456
|
+
"public_recovery_wait",
|
|
115457
|
+
"public_cooldown_active",
|
|
115458
|
+
"public_rate_limited",
|
|
115459
|
+
"public_network_error",
|
|
115460
|
+
"public_timeout"
|
|
115461
|
+
].includes(String(record6.code))) {
|
|
115462
|
+
const finiteNonnegative = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= Number.MAX_SAFE_INTEGER ? value : null;
|
|
115463
|
+
return {
|
|
115464
|
+
hl_public_read_code: record6.code,
|
|
115465
|
+
hl_public_read_request_type: typeof record6.requestType === "string" ? sanitizeRuntimeDiagnosticValue(record6.requestType).slice(0, CLIENT_RUNTIME_HL_REQUEST_TYPE_MAX_CHARS) : null,
|
|
115466
|
+
hl_public_read_status: finiteNonnegative(record6.status),
|
|
115467
|
+
hl_public_read_retry_after_ms: finiteNonnegative(record6.retryAfterMs)
|
|
115468
|
+
};
|
|
115469
|
+
}
|
|
115470
|
+
current = record6.cause;
|
|
115471
|
+
}
|
|
115472
|
+
return {};
|
|
115473
|
+
};
|
|
115474
|
+
}
|
|
115475
|
+
});
|
|
115476
|
+
|
|
115360
115477
|
// lib/runtime/periodic-schedule.ts
|
|
115361
115478
|
function periodicSlotAtOrAfter(schedule, nowMs2, options = {}) {
|
|
115362
115479
|
if (schedule.phaseMs === null || schedule.intervalMs === null) return null;
|
|
@@ -115730,7 +115847,7 @@ var init_browser_observability = __esm({
|
|
|
115730
115847
|
init_define_VTX_GROK_POLICY();
|
|
115731
115848
|
init_define_VTX_PI_MODEL_POLICY();
|
|
115732
115849
|
init_runtime_policy_generated2();
|
|
115733
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
115850
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "513abd7057f4f450bc3739a147e240268030e1f6".trim() && "513abd7057f4f450bc3739a147e240268030e1f6".trim() !== "unstamped" ? "513abd7057f4f450bc3739a147e240268030e1f6".trim() : null;
|
|
115734
115851
|
listenersInstalled = false;
|
|
115735
115852
|
state = {
|
|
115736
115853
|
loadedAtMs: Date.now(),
|
|
@@ -118084,6 +118201,7 @@ var init_copy_trading_execution = __esm({
|
|
|
118084
118201
|
init_hyperliquid_client();
|
|
118085
118202
|
init_runtime_error_reason_rules();
|
|
118086
118203
|
init_runtime_execution();
|
|
118204
|
+
init_abort();
|
|
118087
118205
|
init_runtime_handoff();
|
|
118088
118206
|
_extractOrderResponseStates = (value) => {
|
|
118089
118207
|
if (value == null || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -118127,7 +118245,7 @@ var init_copy_trading_execution = __esm({
|
|
|
118127
118245
|
};
|
|
118128
118246
|
executeClientCopyTradingIntent = (input) => executeCopyTradingIntent(input, CLIENT_COPY_TRADING_EXECUTION);
|
|
118129
118247
|
executeCopyTradingIntent = async (input, execution) => {
|
|
118130
|
-
|
|
118248
|
+
throwIfAborted(input.signal);
|
|
118131
118249
|
const intent = input.intent;
|
|
118132
118250
|
if (intent.status !== execution.pendingStatus) {
|
|
118133
118251
|
return {
|
|
@@ -118450,7 +118568,7 @@ var init_copy_trading_execution = __esm({
|
|
|
118450
118568
|
};
|
|
118451
118569
|
executeClientCopyTradingOrderAction = (input) => executeCopyTradingOrderAction(input, CLIENT_COPY_TRADING_EXECUTION);
|
|
118452
118570
|
executeCopyTradingOrderAction = async (input, execution) => {
|
|
118453
|
-
|
|
118571
|
+
throwIfAborted(input.signal);
|
|
118454
118572
|
const action = input.action;
|
|
118455
118573
|
if (action.status !== execution.pendingStatus) {
|
|
118456
118574
|
return {
|
|
@@ -119863,6 +119981,201 @@ var init_ai_settings_helpers = __esm({
|
|
|
119863
119981
|
}
|
|
119864
119982
|
});
|
|
119865
119983
|
|
|
119984
|
+
// lib/executionMode.ts
|
|
119985
|
+
var init_executionMode = __esm({
|
|
119986
|
+
"lib/executionMode.ts"() {
|
|
119987
|
+
"use strict";
|
|
119988
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
119989
|
+
init_define_VTX_EXO_POLICY();
|
|
119990
|
+
init_define_VTX_GROK_POLICY();
|
|
119991
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
119992
|
+
}
|
|
119993
|
+
});
|
|
119994
|
+
|
|
119995
|
+
// lib/run-with-concurrency-limit.ts
|
|
119996
|
+
var init_run_with_concurrency_limit = __esm({
|
|
119997
|
+
"lib/run-with-concurrency-limit.ts"() {
|
|
119998
|
+
"use strict";
|
|
119999
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
120000
|
+
init_define_VTX_EXO_POLICY();
|
|
120001
|
+
init_define_VTX_GROK_POLICY();
|
|
120002
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
120003
|
+
}
|
|
120004
|
+
});
|
|
120005
|
+
|
|
120006
|
+
// lib/runtime/client-panel-reads.ts
|
|
120007
|
+
var exchangeCache, SHARED_RESULT_MS, capacityWaitMs, waitForCapacity, infoRead, readInfoRowsWaitingForCapacity, waitingForCapacity, PANEL_PROFILE_CONCURRENCY;
|
|
120008
|
+
var init_client_panel_reads = __esm({
|
|
120009
|
+
"lib/runtime/client-panel-reads.ts"() {
|
|
120010
|
+
"use strict";
|
|
120011
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
120012
|
+
init_define_VTX_EXO_POLICY();
|
|
120013
|
+
init_define_VTX_GROK_POLICY();
|
|
120014
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
120015
|
+
init_api2();
|
|
120016
|
+
init_constants();
|
|
120017
|
+
init_executionMode();
|
|
120018
|
+
init_runtime_policy_generated2();
|
|
120019
|
+
init_hyperliquid_account_state_adapter();
|
|
120020
|
+
init_hyperliquid_client();
|
|
120021
|
+
init_hyperliquid_market_symbol();
|
|
120022
|
+
init_hyperliquid_public_read();
|
|
120023
|
+
init_history_evidence();
|
|
120024
|
+
init_runtime_error_reason_rules();
|
|
120025
|
+
init_run_with_concurrency_limit();
|
|
120026
|
+
exchangeCache = runtime_policy_generated_default2.exchange.cache;
|
|
120027
|
+
SHARED_RESULT_MS = {
|
|
120028
|
+
open_orders: runtime_policy_generated_default2.trading.engine.client_runtime.panel_reads.device_open_orders_reuse_seconds * MS_PER_SECOND,
|
|
120029
|
+
order_history: exchangeCache.order_history_ttl_seconds * MS_PER_SECOND,
|
|
120030
|
+
twap_orders: exchangeCache.twap_history_ttl_seconds * MS_PER_SECOND,
|
|
120031
|
+
twap_fills: exchangeCache.twap_fills_ttl_seconds * MS_PER_SECOND,
|
|
120032
|
+
funding: exchangeCache.funding_history_ttl_seconds * MS_PER_SECOND
|
|
120033
|
+
};
|
|
120034
|
+
capacityWaitMs = (error48) => {
|
|
120035
|
+
if (!isHyperliquidReadRefusal(error48)) return null;
|
|
120036
|
+
const retryAfter = Number(error48.retryAfterMs);
|
|
120037
|
+
return Number.isFinite(retryAfter) && retryAfter > 0 ? retryAfter : runtime_policy_generated_default2.exchange.hyperliquid.public_recovery.queue_poll_ms;
|
|
120038
|
+
};
|
|
120039
|
+
waitForCapacity = (ms, signal) => new Promise((resolve16, reject) => {
|
|
120040
|
+
if (signal?.aborted) {
|
|
120041
|
+
reject(signal.reason);
|
|
120042
|
+
return;
|
|
120043
|
+
}
|
|
120044
|
+
const done = () => {
|
|
120045
|
+
signal?.removeEventListener("abort", aborted2);
|
|
120046
|
+
resolve16();
|
|
120047
|
+
};
|
|
120048
|
+
const timer = setTimeout(done, Math.max(1, ms));
|
|
120049
|
+
const aborted2 = () => {
|
|
120050
|
+
clearTimeout(timer);
|
|
120051
|
+
reject(signal?.reason);
|
|
120052
|
+
};
|
|
120053
|
+
signal?.addEventListener("abort", aborted2, { once: true });
|
|
120054
|
+
});
|
|
120055
|
+
infoRead = async (config2, body, options) => {
|
|
120056
|
+
const payload = await fetchBrowserHyperliquidInfoPayload(
|
|
120057
|
+
{
|
|
120058
|
+
config: config2 ?? void 0,
|
|
120059
|
+
signal: options.signal,
|
|
120060
|
+
publicRequestPriority: options.priority
|
|
120061
|
+
},
|
|
120062
|
+
body,
|
|
120063
|
+
`hyperliquid.${String(body.type)}`
|
|
120064
|
+
);
|
|
120065
|
+
if (!Array.isArray(payload)) throw new Error(`Malformed Hyperliquid ${String(body.type)} response.`);
|
|
120066
|
+
return payload;
|
|
120067
|
+
};
|
|
120068
|
+
readInfoRowsWaitingForCapacity = (config2, body, options) => waitingForCapacity(() => infoRead(config2, body, options), options.signal);
|
|
120069
|
+
waitingForCapacity = async (read, signal) => {
|
|
120070
|
+
const deadlineMs = Date.now() + runtime_policy_generated_default2.trading.history_reads.device_read_deadline_seconds * MS_PER_SECOND;
|
|
120071
|
+
for (; ; ) {
|
|
120072
|
+
try {
|
|
120073
|
+
return await read();
|
|
120074
|
+
} catch (error48) {
|
|
120075
|
+
const waitMs = capacityWaitMs(error48);
|
|
120076
|
+
const remaining = deadlineMs - Date.now();
|
|
120077
|
+
if (waitMs === null || remaining <= 0) throw error48;
|
|
120078
|
+
await waitForCapacity(Math.min(waitMs, remaining), signal);
|
|
120079
|
+
}
|
|
120080
|
+
}
|
|
120081
|
+
};
|
|
120082
|
+
PANEL_PROFILE_CONCURRENCY = runtime_policy_generated_default2.trading.engine.client_runtime.panel_reads.all_view_profile_concurrency;
|
|
120083
|
+
}
|
|
120084
|
+
});
|
|
120085
|
+
|
|
120086
|
+
// lib/runtime/hyperliquid-candle-reads.ts
|
|
120087
|
+
var decimalText, readHyperliquidCandles;
|
|
120088
|
+
var init_hyperliquid_candle_reads = __esm({
|
|
120089
|
+
"lib/runtime/hyperliquid-candle-reads.ts"() {
|
|
120090
|
+
"use strict";
|
|
120091
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
120092
|
+
init_define_VTX_EXO_POLICY();
|
|
120093
|
+
init_define_VTX_GROK_POLICY();
|
|
120094
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
120095
|
+
init_constants();
|
|
120096
|
+
init_client_panel_reads();
|
|
120097
|
+
init_runtime_error_reason_rules();
|
|
120098
|
+
decimalText = (value) => {
|
|
120099
|
+
if (typeof value === "number") return Number.isFinite(value) ? String(value) : null;
|
|
120100
|
+
return typeof value === "string" && value.trim() !== "" && Number.isFinite(Number(value)) ? value.trim() : null;
|
|
120101
|
+
};
|
|
120102
|
+
readHyperliquidCandles = async (config2, request, options) => {
|
|
120103
|
+
const seconds = CANDLE_TIMEFRAME_SECONDS[request.timeframe];
|
|
120104
|
+
if (!seconds || !request.symbol.trim()) {
|
|
120105
|
+
throw new RuntimeReasonError("A candle read needs a market symbol and a supported timeframe.", "internal_data_error");
|
|
120106
|
+
}
|
|
120107
|
+
const intervalMs = seconds * MS_PER_SECOND;
|
|
120108
|
+
const byOpen = /* @__PURE__ */ new Map();
|
|
120109
|
+
for (const range of request.ranges) {
|
|
120110
|
+
for (let pieceStart = range.startMs; pieceStart <= range.endMs; ) {
|
|
120111
|
+
const pieceEnd = Math.min(range.endMs, pieceStart + (HYPERLIQUID_CANDLE_SNAPSHOT_MAX_ROWS - 1) * intervalMs);
|
|
120112
|
+
options.signal?.throwIfAborted();
|
|
120113
|
+
const rows = await readInfoRowsWaitingForCapacity(config2, {
|
|
120114
|
+
type: "candleSnapshot",
|
|
120115
|
+
req: { coin: request.symbol, interval: request.timeframe, startTime: pieceStart, endTime: pieceEnd }
|
|
120116
|
+
}, options);
|
|
120117
|
+
for (const row of rows) {
|
|
120118
|
+
const candle = row && typeof row === "object" ? row : null;
|
|
120119
|
+
const opened = Number(candle?.t);
|
|
120120
|
+
const ohlcv = ["o", "h", "l", "c", "v"].map((key) => decimalText(candle?.[key]));
|
|
120121
|
+
if (!candle || !Number.isSafeInteger(opened) || ohlcv.some((value) => value === null)) {
|
|
120122
|
+
throw new RuntimeReasonError("Hyperliquid returned a malformed candle.", "hyperliquid_data_unavailable");
|
|
120123
|
+
}
|
|
120124
|
+
if (opened < pieceStart || opened > pieceEnd || opened % intervalMs !== 0) continue;
|
|
120125
|
+
const [o, h, l, c, v] = ohlcv;
|
|
120126
|
+
byOpen.set(opened, { t: opened, o, h, l, c, v });
|
|
120127
|
+
}
|
|
120128
|
+
pieceStart = pieceEnd + intervalMs;
|
|
120129
|
+
}
|
|
120130
|
+
}
|
|
120131
|
+
return [...byOpen.values()].sort((left, right) => left.t - right.t);
|
|
120132
|
+
};
|
|
120133
|
+
}
|
|
120134
|
+
});
|
|
120135
|
+
|
|
120136
|
+
// lib/runtime/client-recent-candles.ts
|
|
120137
|
+
var routeTimestamp, routeCandle, mergeDeviceCandles, readRuntimeRecentCandles;
|
|
120138
|
+
var init_client_recent_candles = __esm({
|
|
120139
|
+
"lib/runtime/client-recent-candles.ts"() {
|
|
120140
|
+
"use strict";
|
|
120141
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
120142
|
+
init_define_VTX_EXO_POLICY();
|
|
120143
|
+
init_define_VTX_GROK_POLICY();
|
|
120144
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
120145
|
+
init_api2();
|
|
120146
|
+
init_constants();
|
|
120147
|
+
init_hyperliquid_candle_reads();
|
|
120148
|
+
routeTimestamp = (openMs2) => new Date(Math.floor(openMs2 / MS_PER_SECOND) * MS_PER_SECOND).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
120149
|
+
routeCandle = (row, series) => ({
|
|
120150
|
+
...series,
|
|
120151
|
+
timestamp: routeTimestamp(row.t),
|
|
120152
|
+
open: row.o,
|
|
120153
|
+
high: row.h,
|
|
120154
|
+
low: row.l,
|
|
120155
|
+
close: row.c,
|
|
120156
|
+
volume: row.v
|
|
120157
|
+
});
|
|
120158
|
+
mergeDeviceCandles = (stored, rows, series) => {
|
|
120159
|
+
const { limit, ...market } = series;
|
|
120160
|
+
const byOpen = /* @__PURE__ */ new Map();
|
|
120161
|
+
for (const candle of stored) byOpen.set(Date.parse(candle.timestamp), candle);
|
|
120162
|
+
for (const row of rows) byOpen.set(row.t, routeCandle(row, market));
|
|
120163
|
+
return [...byOpen.entries()].filter(([openMs2]) => Number.isFinite(openMs2)).sort(([left], [right]) => right - left).slice(0, limit).map(([, candle]) => candle);
|
|
120164
|
+
};
|
|
120165
|
+
readRuntimeRecentCandles = async (limit, exchange, symbol2, timeframe, signal, context) => {
|
|
120166
|
+
if (!context) return getRecentCandles(limit, exchange, symbol2, timeframe, signal);
|
|
120167
|
+
const { candles, missing: missing2 } = await getRecentCandlesForProfile(context.profileId, limit, exchange, symbol2, timeframe, signal);
|
|
120168
|
+
if (missing2 === null) return candles;
|
|
120169
|
+
const rows = await readHyperliquidCandles(await context.deviceConfig(), {
|
|
120170
|
+
symbol: symbol2,
|
|
120171
|
+
timeframe,
|
|
120172
|
+
ranges: [missing2]
|
|
120173
|
+
}, { priority: context.priority, signal });
|
|
120174
|
+
return mergeDeviceCandles(candles, rows, { exchange, symbol: symbol2, timeframe, limit });
|
|
120175
|
+
};
|
|
120176
|
+
}
|
|
120177
|
+
});
|
|
120178
|
+
|
|
119866
120179
|
// lib/runtime/candle-prompt-contract.ts
|
|
119867
120180
|
var AI_INDICATOR_ROW_COLUMNS, AI_INDICATOR_KEYS, EMA_INDICATOR_KEYS, CANDLE_BASE_ROW_COLUMNS, candlesRowColumns, projectCandlePromptComponent, readCandleNumber, closedCandleCount, calculateRelativeVolumeSeries;
|
|
119868
120181
|
var init_candle_prompt_contract = __esm({
|
|
@@ -122102,6 +122415,29 @@ var init_server_host_prompt_rescue = __esm({
|
|
|
122102
122415
|
}
|
|
122103
122416
|
});
|
|
122104
122417
|
|
|
122418
|
+
// lib/api/inference-pacing.ts
|
|
122419
|
+
async function reserveClientRuntimeInferencePacing(profileId, payload, options) {
|
|
122420
|
+
return postClientRuntime(
|
|
122421
|
+
"/runtime/inference-pacing",
|
|
122422
|
+
profileId,
|
|
122423
|
+
buildClientRuntimeBody(payload, {
|
|
122424
|
+
analysis_run_id: payload.analysisRunId,
|
|
122425
|
+
cycle_id: payload.cycleId
|
|
122426
|
+
}, { includeForceTakeover: false }),
|
|
122427
|
+
options
|
|
122428
|
+
);
|
|
122429
|
+
}
|
|
122430
|
+
var init_inference_pacing = __esm({
|
|
122431
|
+
"lib/api/inference-pacing.ts"() {
|
|
122432
|
+
"use strict";
|
|
122433
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
122434
|
+
init_define_VTX_EXO_POLICY();
|
|
122435
|
+
init_define_VTX_GROK_POLICY();
|
|
122436
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
122437
|
+
init_api2();
|
|
122438
|
+
}
|
|
122439
|
+
});
|
|
122440
|
+
|
|
122105
122441
|
// lib/runtime/server-prompt-rescue-snapshot.ts
|
|
122106
122442
|
var accountStateFromServerPromptRescueSnapshot;
|
|
122107
122443
|
var init_server_prompt_rescue_snapshot = __esm({
|
|
@@ -122588,7 +122924,7 @@ var init_provider_client = __esm({
|
|
|
122588
122924
|
emptyProviderContentError = (message, reply) => Object.assign(new Error(message), {
|
|
122589
122925
|
runtimeEmptyProviderContent: true,
|
|
122590
122926
|
// Kept for the in-place retry's own row only (Venice): a model's final
|
|
122591
|
-
// empty reply is recorded with no result and never priced
|
|
122927
|
+
// empty reply is recorded with no result and never priced.
|
|
122592
122928
|
...reply ? { runtimeEmptyProviderReply: reply.result, runtimeEmptyProviderMessage: reply.emptyMessage } : {}
|
|
122593
122929
|
});
|
|
122594
122930
|
isEmptyProviderContentFailure = (error48) => error48?.runtimeEmptyProviderContent === true;
|
|
@@ -123997,7 +124333,7 @@ var init_provider_client = __esm({
|
|
|
123997
124333
|
providerDiagnostics: marker2.providerDiagnostics,
|
|
123998
124334
|
providerRequestId: providerRequestId(response),
|
|
123999
124335
|
errorDetail: getSanitizedRuntimeErrorMessage(error48) || "Provider compatibility dispatch failed.",
|
|
124000
|
-
// An empty reply is an unknown outcome with no status
|
|
124336
|
+
// An empty reply is an unknown outcome with no status.
|
|
124001
124337
|
statusCode: isEmptyProviderContentFailure(error48) ? null : response?.status ?? null,
|
|
124002
124338
|
retryable: isEmptyProviderContentFailure(error48),
|
|
124003
124339
|
response: emptyReplyForInternalAttempt(error48)
|
|
@@ -126937,8 +127273,8 @@ var init_ai_schedule = __esm({
|
|
|
126937
127273
|
function createRecentCandleSeries(read, now = Date.now) {
|
|
126938
127274
|
const held = /* @__PURE__ */ new Map();
|
|
126939
127275
|
const copy4 = (candles) => candles.map((candle) => ({ ...candle }));
|
|
126940
|
-
const readWhole = async (key, limit, exchange, symbol2, timeframe, stepMs, signal) => {
|
|
126941
|
-
const candles = await read(limit, exchange, symbol2, timeframe, signal);
|
|
127276
|
+
const readWhole = async (key, limit, exchange, symbol2, timeframe, stepMs, signal, context) => {
|
|
127277
|
+
const candles = await read(limit, exchange, symbol2, timeframe, signal, context);
|
|
126942
127278
|
if (stepMs != null && candles.length > 0 && contiguous(candles, stepMs)) {
|
|
126943
127279
|
held.set(key, { candles: copy4(candles), fullReadAtMs: now() });
|
|
126944
127280
|
} else {
|
|
@@ -126946,7 +127282,7 @@ function createRecentCandleSeries(read, now = Date.now) {
|
|
|
126946
127282
|
}
|
|
126947
127283
|
return candles;
|
|
126948
127284
|
};
|
|
126949
|
-
const recentCandles = async (limit, exchange, symbol2, timeframe, signal) => {
|
|
127285
|
+
const recentCandles = async (limit, exchange, symbol2, timeframe, signal, context) => {
|
|
126950
127286
|
for (const [heldKey, entry] of held) {
|
|
126951
127287
|
if (now() - entry.fullReadAtMs >= FULL_REFRESH_MS) held.delete(heldKey);
|
|
126952
127288
|
}
|
|
@@ -126955,18 +127291,18 @@ function createRecentCandleSeries(read, now = Date.now) {
|
|
|
126955
127291
|
const stepMs = seconds == null ? null : seconds * MS_PER_SECOND;
|
|
126956
127292
|
const kept = held.get(key);
|
|
126957
127293
|
if (stepMs == null || !kept || now() - kept.fullReadAtMs >= FULL_REFRESH_MS) {
|
|
126958
|
-
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal);
|
|
127294
|
+
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal, context);
|
|
126959
127295
|
}
|
|
126960
127296
|
const newestHeldMs = openMs(kept.candles[0]);
|
|
126961
127297
|
const newCount = Math.max(0, Math.floor((now() - newestHeldMs) / stepMs));
|
|
126962
127298
|
const deltaLimit = newCount + OVERLAP_CANDLES;
|
|
126963
127299
|
if (newCount > DELTA_MAX_CANDLES || deltaLimit >= limit) {
|
|
126964
|
-
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal);
|
|
127300
|
+
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal, context);
|
|
126965
127301
|
}
|
|
126966
|
-
const newest = await read(deltaLimit, exchange, symbol2, timeframe, signal);
|
|
127302
|
+
const newest = await read(deltaLimit, exchange, symbol2, timeframe, signal, context);
|
|
126967
127303
|
const oldestNewMs = newest.length > 0 ? openMs(newest[newest.length - 1]) : Number.NaN;
|
|
126968
127304
|
if (newest.length === 0 || !contiguous(newest, stepMs) || !Number.isFinite(oldestNewMs) || oldestNewMs > newestHeldMs) {
|
|
126969
|
-
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal);
|
|
127305
|
+
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal, context);
|
|
126970
127306
|
}
|
|
126971
127307
|
const heldByOpen = new Map(kept.candles.slice(1).map((candle) => [candle.timestamp, candle]));
|
|
126972
127308
|
const overlapChanged = newest.some((candle) => {
|
|
@@ -126974,11 +127310,11 @@ function createRecentCandleSeries(read, now = Date.now) {
|
|
|
126974
127310
|
return before != null && (before.open !== candle.open || before.high !== candle.high || before.low !== candle.low || before.close !== candle.close || before.volume !== candle.volume);
|
|
126975
127311
|
});
|
|
126976
127312
|
if (overlapChanged) {
|
|
126977
|
-
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal);
|
|
127313
|
+
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal, context);
|
|
126978
127314
|
}
|
|
126979
127315
|
const merged = [...copy4(newest), ...kept.candles.filter((candle) => openMs(candle) < oldestNewMs)].slice(0, limit);
|
|
126980
127316
|
if (!contiguous(merged, stepMs)) {
|
|
126981
|
-
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal);
|
|
127317
|
+
return readWhole(key, limit, exchange, symbol2, timeframe, stepMs, signal, context);
|
|
126982
127318
|
}
|
|
126983
127319
|
held.set(key, { candles: merged, fullReadAtMs: kept.fullReadAtMs });
|
|
126984
127320
|
return copy4(merged);
|
|
@@ -127029,6 +127365,7 @@ __export(local_analysis_exports, {
|
|
|
127029
127365
|
buildServerBehaviorStateArtifacts: () => buildServerBehaviorStateArtifacts,
|
|
127030
127366
|
capacityUnitSize: () => capacityUnitSize,
|
|
127031
127367
|
currentModelOutputJsonText: () => currentModelOutputJsonText,
|
|
127368
|
+
currentModelOutputMatchesContract: () => currentModelOutputMatchesContract,
|
|
127032
127369
|
derivePromptVisibleSections: () => derivePromptVisibleSections,
|
|
127033
127370
|
formatReviewUserPrompt: () => formatReviewUserPrompt,
|
|
127034
127371
|
isClientRuntimeAgentInstructionEmpty: () => isClientRuntimeAgentInstructionEmpty,
|
|
@@ -127064,6 +127401,7 @@ var init_local_analysis = __esm({
|
|
|
127064
127401
|
init_profile_model_fallbacks();
|
|
127065
127402
|
init_api2();
|
|
127066
127403
|
init_ai_settings_helpers();
|
|
127404
|
+
init_client_recent_candles();
|
|
127067
127405
|
init_candle_timeframes();
|
|
127068
127406
|
init_candle_prompt_contract();
|
|
127069
127407
|
init_prompt_candles();
|
|
@@ -127076,6 +127414,7 @@ var init_local_analysis = __esm({
|
|
|
127076
127414
|
init_client_account_report();
|
|
127077
127415
|
init_hyperliquid_public_read();
|
|
127078
127416
|
init_server_host_prompt_rescue();
|
|
127417
|
+
init_inference_pacing();
|
|
127079
127418
|
init_server_prompt_rescue_snapshot();
|
|
127080
127419
|
init_network_debug();
|
|
127081
127420
|
init_abort();
|
|
@@ -127103,7 +127442,7 @@ var init_local_analysis = __esm({
|
|
|
127103
127442
|
init_recent_candle_series();
|
|
127104
127443
|
init_runtime_policy_generated2();
|
|
127105
127444
|
init_constants();
|
|
127106
|
-
cycleCandles = createRecentCandleSeries(
|
|
127445
|
+
cycleCandles = createRecentCandleSeries(readRuntimeRecentCandles);
|
|
127107
127446
|
CYCLE_TIMEOUT_FLOOR_MS = runtime_policy_generated_default2.trading.engine.client_runtime.cycle_timeout_floor_milliseconds;
|
|
127108
127447
|
DECISION_SETTLEMENT_RESERVE_MAX_BUDGET_DIVISOR = runtime_policy_generated_default2.trading.engine.client_runtime.decision_settlement_reserve_max_budget_divisor;
|
|
127109
127448
|
MIN_AGENT_INSTRUCTION_RETRY_AFTER_MS = runtime_policy_generated_default2.trading.engine.client_runtime.request_bounds.min_agent_instruction_retry_after_ms;
|
|
@@ -127710,9 +128049,9 @@ var init_local_analysis = __esm({
|
|
|
127710
128049
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
127711
128050
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
127712
128051
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
127713
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
127714
|
-
"
|
|
127715
|
-
) ? "
|
|
128052
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "513abd7057f4f450bc3739a147e240268030e1f6".trim() && !["unknown", "unstamped", "development"].includes(
|
|
128053
|
+
"513abd7057f4f450bc3739a147e240268030e1f6".trim().toLowerCase()
|
|
128054
|
+
) ? "513abd7057f4f450bc3739a147e240268030e1f6".trim() : null;
|
|
127716
128055
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
127717
128056
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
127718
128057
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|
|
@@ -130984,6 +131323,20 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
130984
131323
|
if (input.mode === "trader" && initialPromptMetadata?.main_model_enabled === false) {
|
|
130985
131324
|
return buildMainModelDisabledResult(initialPromptMetadata);
|
|
130986
131325
|
}
|
|
131326
|
+
const pacedMainController = liveModelControllerSchema.safeParse(settings.main_model_controller);
|
|
131327
|
+
if (pacedMainController.success && pacedMainController.data.kind === "external_agent") {
|
|
131328
|
+
await reserveClientRuntimeInferencePacing(profileId, {
|
|
131329
|
+
sessionId,
|
|
131330
|
+
deviceId,
|
|
131331
|
+
schedulerInstanceId: String(input.schedulerInstanceId || "").trim(),
|
|
131332
|
+
mode: input.mode,
|
|
131333
|
+
analysisRunId: input.analysisRunId ?? cycleId,
|
|
131334
|
+
cycleId
|
|
131335
|
+
}, {
|
|
131336
|
+
schedulerInstanceId: String(input.schedulerInstanceId || "").trim(),
|
|
131337
|
+
signal: timeoutController.signal
|
|
131338
|
+
});
|
|
131339
|
+
}
|
|
130987
131340
|
appendRuntimeDebugEvent({
|
|
130988
131341
|
label: "analysis_input",
|
|
130989
131342
|
note: `symbol=${localFallbackSymbol} timeframe=${localFallbackTimeframe} wallet=${walletAddress ? "present" : "missing"}`
|
|
@@ -131188,7 +131541,10 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
131188
131541
|
"hyperliquid",
|
|
131189
131542
|
marketSymbol,
|
|
131190
131543
|
marketTimeframe,
|
|
131191
|
-
timeoutController.signal
|
|
131544
|
+
timeoutController.signal,
|
|
131545
|
+
// VTX's servers read Hyperliquid only for a Server Mode bot: a
|
|
131546
|
+
// Client Mode bot's candles are stored ones, completed here.
|
|
131547
|
+
input.executionMode === "server" ? void 0 : { profileId, deviceConfig: () => config2, priority: "trading_analysis" }
|
|
131192
131548
|
)
|
|
131193
131549
|
])
|
|
131194
131550
|
)
|
|
@@ -132976,7 +133332,7 @@ ${stringifyPromptJson(parts.candlesPayload)}
|
|
|
132976
133332
|
});
|
|
132977
133333
|
|
|
132978
133334
|
// lib/runtime/engine.ts
|
|
132979
|
-
var
|
|
133335
|
+
var DEVICE_DIAGNOSTICS4, FALLBACK_ERROR_MAX_CHARS, localAnalysis, getExchangeFailureDiagnostics, getRuntimeFallbackAttempts, sentInvocationAttemptCount, boundRuntimeFallbackAttempts, isProviderFailureDiagnosticsCandidate, getEventBoundProviderLabel, getEventBoundProviderTraceId, CLIENT_RUNTIME_POLICY, getRecentProviderFailureDiagnostics, getClientRuntimeErrorProvenance, getRuntimeProviderSetupDiagnostics, buildProviderSetupErrorDiagnosticFields, buildClientRuntimeErrorProvenanceDiagnosticFields, getCycleErrorModelCalls, isReturnedModelCall, hasEventBoundProviderFailureEvidence, endsWithNeverSentAttempt, classifyRuntimeErrorStage, buildRuntimeErrorDiagnostics, positiveNumber, resolveRuntimeEngineOptions, withServerPositionEvents, CLIENT_KILLSWITCH_BLOCK_STORAGE_PREFIX, getClientKillswitchBlockStorageKey, isClientRuntimeKillswitchBlocked, persistClientRuntimeKillswitchBlock, clearClientRuntimeKillswitchBlock, hashRuntimeDebugText2, createRuntimeUuid2, getRuntimeContractIdentityToken, getRuntimeStatusContractIdentityToken, getRuntimeContractBindingTokenFromCycleResult, getRuntimeContractBindingTupleToken, getRuntimeStatusContractBindingTupleToken, isTransientRuntimeConflictError, createRuntimeStartCancelledError, isRuntimeContractMismatchError, isClientExecutionModeMismatchError, isClientRuntimeSessionStoppedError, isClientRuntimeLeaseAuthError, isClientRuntimeReleasedError, deriveFailedStartCleanupOwnershipLossReason, isRuntimeAbortError, isExplicitClientExecutionMode, createStopAbortError, isRuntimeContractIdentityAdvancedAbort, CLIENT_RUNTIME_NO_DECISION_RECOVERY_REASON, CLIENT_RUNTIME_NO_DECISION_MESSAGE, sanitizeSettingsSnapshotForFallback, preflightClientRuntime, onCadenceGridPoint, ClientExecutionEngine, createStoppedRuntimeSnapshot, ClientRuntimeRegistry, botEngine;
|
|
132980
133336
|
var init_engine = __esm({
|
|
132981
133337
|
"lib/runtime/engine.ts"() {
|
|
132982
133338
|
"use strict";
|
|
@@ -132988,6 +133344,7 @@ var init_engine = __esm({
|
|
|
132988
133344
|
init_hyperliquid_public_read();
|
|
132989
133345
|
init_runtime_policy_generated2();
|
|
132990
133346
|
init_constants();
|
|
133347
|
+
init_runtime_error_diagnostic_fields();
|
|
132991
133348
|
init_periodic_schedule();
|
|
132992
133349
|
init_host_storage();
|
|
132993
133350
|
init_vault();
|
|
@@ -133029,7 +133386,7 @@ var init_engine = __esm({
|
|
|
133029
133386
|
init_runtime_error_reason_rules();
|
|
133030
133387
|
init_host_wake_schedule();
|
|
133031
133388
|
init_copy_trading_evidence();
|
|
133032
|
-
|
|
133389
|
+
DEVICE_DIAGNOSTICS4 = runtime_policy_generated_default2.trading.engine.client_runtime.device_diagnostics;
|
|
133033
133390
|
FALLBACK_ERROR_MAX_CHARS = runtime_policy_generated_default2.trading.engine.client_runtime.request_bounds.max_fallback_error_length;
|
|
133034
133391
|
getExchangeFailureDiagnostics = (error48) => {
|
|
133035
133392
|
if (error48 instanceof HyperliquidExchangeRejectionError) {
|
|
@@ -133043,7 +133400,7 @@ var init_engine = __esm({
|
|
|
133043
133400
|
let attempts = null;
|
|
133044
133401
|
let current = error48;
|
|
133045
133402
|
const seen = /* @__PURE__ */ new Set();
|
|
133046
|
-
for (let depth = 0; depth <
|
|
133403
|
+
for (let depth = 0; depth < DEVICE_DIAGNOSTICS4.error_cause_max_depth && current && typeof current === "object" && !seen.has(current); depth += 1) {
|
|
133047
133404
|
seen.add(current);
|
|
133048
133405
|
const candidate = current.runtimeFallbackAttempts;
|
|
133049
133406
|
if (Array.isArray(candidate)) {
|
|
@@ -133128,7 +133485,7 @@ var init_engine = __esm({
|
|
|
133128
133485
|
getEventBoundProviderTraceId = (reason) => {
|
|
133129
133486
|
let current = reason;
|
|
133130
133487
|
const seen = /* @__PURE__ */ new Set();
|
|
133131
|
-
for (let depth = 0; depth <
|
|
133488
|
+
for (let depth = 0; depth < DEVICE_DIAGNOSTICS4.error_cause_max_depth; depth += 1) {
|
|
133132
133489
|
if (!current || typeof current !== "object" && typeof current !== "function" || seen.has(current)) {
|
|
133133
133490
|
return null;
|
|
133134
133491
|
}
|
|
@@ -133165,7 +133522,7 @@ var init_engine = __esm({
|
|
|
133165
133522
|
getClientRuntimeErrorProvenance = (reason) => {
|
|
133166
133523
|
let current = reason;
|
|
133167
133524
|
const seen = /* @__PURE__ */ new Set();
|
|
133168
|
-
for (let depth = 0; depth <
|
|
133525
|
+
for (let depth = 0; depth < DEVICE_DIAGNOSTICS4.error_cause_max_depth; depth += 1) {
|
|
133169
133526
|
if (!current || typeof current !== "object" && typeof current !== "function" || seen.has(current)) {
|
|
133170
133527
|
return null;
|
|
133171
133528
|
}
|
|
@@ -133232,50 +133589,6 @@ var init_engine = __esm({
|
|
|
133232
133589
|
error_provenance_model_source: provenance.modelSource
|
|
133233
133590
|
};
|
|
133234
133591
|
};
|
|
133235
|
-
buildRuntimeRequestErrorDiagnosticFields = (reason) => {
|
|
133236
|
-
if (!reason || typeof reason !== "object" && typeof reason !== "function") {
|
|
133237
|
-
return {};
|
|
133238
|
-
}
|
|
133239
|
-
const record6 = reason;
|
|
133240
|
-
const path = sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestPath || "")).trim();
|
|
133241
|
-
if (!path) {
|
|
133242
|
-
return {};
|
|
133243
|
-
}
|
|
133244
|
-
const numberOrNull = (value) => {
|
|
133245
|
-
if (value === null || value === void 0 || value === "") {
|
|
133246
|
-
return null;
|
|
133247
|
-
}
|
|
133248
|
-
const parsed = Number(value);
|
|
133249
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
133250
|
-
};
|
|
133251
|
-
return {
|
|
133252
|
-
runtime_request_path: path.slice(0, DEVICE_DIAGNOSTICS3.request_path_chars),
|
|
133253
|
-
runtime_request_method: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestMethod || "")).slice(0, DEVICE_DIAGNOSTICS3.request_method_chars) || null,
|
|
133254
|
-
runtime_request_attempt: numberOrNull(record6.runtimeRequestAttempt),
|
|
133255
|
-
runtime_request_max_attempts: numberOrNull(record6.runtimeRequestMaxAttempts),
|
|
133256
|
-
runtime_request_status: numberOrNull(record6.runtimeRequestStatus),
|
|
133257
|
-
runtime_request_error_kind: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestErrorKind || "")).slice(0, DEVICE_DIAGNOSTICS3.error_kind_chars) || null,
|
|
133258
|
-
runtime_request_transient_network: record6.runtimeRequestTransientNetwork === true,
|
|
133259
|
-
runtime_request_deadline_at_ms: numberOrNull(record6.runtimeRequestDeadlineAtMs),
|
|
133260
|
-
runtime_request_deadline_exceeded: record6.runtimeRequestDeadlineExceeded === true,
|
|
133261
|
-
...record6.code === "snapshot_stale" && record6.runtimeRequestStatus === HTTP_STATUS.CONFLICT ? {
|
|
133262
|
-
runtime_rejection_reason_code: "snapshot_stale",
|
|
133263
|
-
snapshot_age_seconds: numberOrNull(record6.runtimeSnapshotAgeSeconds),
|
|
133264
|
-
snapshot_max_age_seconds: numberOrNull(record6.runtimeSnapshotMaxAgeSeconds)
|
|
133265
|
-
} : {},
|
|
133266
|
-
...record6.runtimeRequestId ? {
|
|
133267
|
-
runtime_request_id: sanitizeRuntimeDiagnosticValue(String(record6.runtimeRequestId)).slice(0, DEVICE_DIAGNOSTICS3.request_id_chars)
|
|
133268
|
-
} : {},
|
|
133269
|
-
...record6.runtimeReconciliationAttempted === true ? {
|
|
133270
|
-
runtime_reconciliation_attempted: true,
|
|
133271
|
-
runtime_reconciliation_elapsed_ms: numberOrNull(record6.runtimeReconciliationElapsedMs),
|
|
133272
|
-
runtime_reconciliation_status: numberOrNull(record6.runtimeReconciliationStatus),
|
|
133273
|
-
runtime_reconciliation_error_kind: sanitizeRuntimeDiagnosticValue(String(record6.runtimeReconciliationErrorKind || "")).slice(0, DEVICE_DIAGNOSTICS3.error_kind_chars) || null,
|
|
133274
|
-
runtime_reconciliation_deadline_exceeded: record6.runtimeReconciliationDeadlineExceeded === true,
|
|
133275
|
-
runtime_reconciliation_request_id: sanitizeRuntimeDiagnosticValue(String(record6.runtimeReconciliationRequestId || "")).slice(0, DEVICE_DIAGNOSTICS3.request_id_chars) || null
|
|
133276
|
-
} : {}
|
|
133277
|
-
};
|
|
133278
|
-
};
|
|
133279
133592
|
getCycleErrorModelCalls = (reason) => {
|
|
133280
133593
|
if (!reason || typeof reason !== "object" && typeof reason !== "function") return [];
|
|
133281
133594
|
const record6 = reason;
|
|
@@ -133337,33 +133650,6 @@ var init_engine = __esm({
|
|
|
133337
133650
|
}
|
|
133338
133651
|
return "runtime";
|
|
133339
133652
|
};
|
|
133340
|
-
buildHyperliquidPublicReadDiagnosticFields = (reason) => {
|
|
133341
|
-
let current = reason;
|
|
133342
|
-
const seen = /* @__PURE__ */ new Set();
|
|
133343
|
-
for (let depth = 0; depth < DEVICE_DIAGNOSTICS3.error_cause_max_depth; depth += 1) {
|
|
133344
|
-
if (!current || typeof current !== "object" || seen.has(current)) return {};
|
|
133345
|
-
seen.add(current);
|
|
133346
|
-
const record6 = current;
|
|
133347
|
-
if (record6.name === "HyperliquidPublicReadError" && [
|
|
133348
|
-
"public_budget_exhausted",
|
|
133349
|
-
"public_recovery_wait",
|
|
133350
|
-
"public_cooldown_active",
|
|
133351
|
-
"public_rate_limited",
|
|
133352
|
-
"public_network_error",
|
|
133353
|
-
"public_timeout"
|
|
133354
|
-
].includes(String(record6.code))) {
|
|
133355
|
-
const finiteNonnegative = (value) => typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= Number.MAX_SAFE_INTEGER ? value : null;
|
|
133356
|
-
return {
|
|
133357
|
-
hl_public_read_code: record6.code,
|
|
133358
|
-
hl_public_read_request_type: typeof record6.requestType === "string" ? sanitizeRuntimeDiagnosticValue(record6.requestType).slice(0, CLIENT_RUNTIME_HL_REQUEST_TYPE_MAX_CHARS) : null,
|
|
133359
|
-
hl_public_read_status: finiteNonnegative(record6.status),
|
|
133360
|
-
hl_public_read_retry_after_ms: finiteNonnegative(record6.retryAfterMs)
|
|
133361
|
-
};
|
|
133362
|
-
}
|
|
133363
|
-
current = record6.cause;
|
|
133364
|
-
}
|
|
133365
|
-
return {};
|
|
133366
|
-
};
|
|
133367
133653
|
buildRuntimeErrorDiagnostics = (reason) => {
|
|
133368
133654
|
const existing = getRecentProviderFailureDiagnostics(reason);
|
|
133369
133655
|
if (existing) {
|
|
@@ -133512,7 +133798,7 @@ var init_engine = __esm({
|
|
|
133512
133798
|
};
|
|
133513
133799
|
isTransientRuntimeConflictError = (error48) => {
|
|
133514
133800
|
const structured = error48;
|
|
133515
|
-
return Number(structured?.status) === HTTP_STATUS.CONFLICT && structured?.retryable === true && (structured?.code === "profile_runtime_contract_busy" || structured?.code === "runtime_decision_finalizing" || structured?.code === "runtime_trade_sync_finalizing");
|
|
133801
|
+
return Number(structured?.status) === HTTP_STATUS.CONFLICT && structured?.retryable === true && (structured?.code === "profile_runtime_contract_busy" || structured?.code === "runtime_decision_finalizing" || structured?.code === "runtime_trade_sync_finalizing" || structured?.code === "provider_paced");
|
|
133516
133802
|
};
|
|
133517
133803
|
createRuntimeStartCancelledError = (reason, detail) => Object.assign(new Error(AI_RUNTIME_START_CANCELLED_MESSAGE), {
|
|
133518
133804
|
runtimeStartCancelReason: reason,
|
|
@@ -134124,7 +134410,7 @@ var init_engine = __esm({
|
|
|
134124
134410
|
}
|
|
134125
134411
|
appendRuntimeDebugEvent({
|
|
134126
134412
|
label: "runtime_contract_invalidated",
|
|
134127
|
-
note: `source=${source} previous=${previousToken.slice(0,
|
|
134413
|
+
note: `source=${source} previous=${previousToken.slice(0, DEVICE_DIAGNOSTICS4.contract_token_prefix_chars)} next=${nextToken.slice(0, DEVICE_DIAGNOSTICS4.contract_token_prefix_chars)}`
|
|
134128
134414
|
});
|
|
134129
134415
|
this._lastError = "Runtime contract updated. Rebinding to latest server identity...";
|
|
134130
134416
|
if (!this._executionFinalizationRequired && this._analysisAbortController && !this._analysisAbortController.signal.aborted) {
|
|
@@ -136217,6 +136503,7 @@ var init_engine = __esm({
|
|
|
136217
136503
|
let aiSchedulePauseMs = null;
|
|
136218
136504
|
let aiSchedulePauseHasNext = false;
|
|
136219
136505
|
let providerRetryDelayMs = null;
|
|
136506
|
+
let pacedTurnDelayMs = null;
|
|
136220
136507
|
const ignoreAiSchedule = this._manualRunRequested;
|
|
136221
136508
|
this._manualRunRequested = false;
|
|
136222
136509
|
const pausedBeforeSlot = this._aiSchedulePaused && this._nextRunAtMs != null && Date.now() < this._nextRunAtMs;
|
|
@@ -136616,7 +136903,7 @@ var init_engine = __esm({
|
|
|
136616
136903
|
this._lastError = "Local analysis is stale against latest runtime contract. Rebinding.";
|
|
136617
136904
|
appendRuntimeDebugEvent({
|
|
136618
136905
|
label: "runtime_contract_checkpoint_block",
|
|
136619
|
-
note: `checkpoint=${checkpoint} reason=binding_mismatch latest=${latestBindingTupleToken.slice(0,
|
|
136906
|
+
note: `checkpoint=${checkpoint} reason=binding_mismatch latest=${latestBindingTupleToken.slice(0, DEVICE_DIAGNOSTICS4.contract_token_prefix_chars)} cycle=${cycleContractBindingToken.slice(0, DEVICE_DIAGNOSTICS4.contract_token_prefix_chars)}`
|
|
136620
136907
|
});
|
|
136621
136908
|
this._notifyListeners();
|
|
136622
136909
|
return true;
|
|
@@ -136884,6 +137171,20 @@ var init_engine = __esm({
|
|
|
136884
137171
|
})), capacityPlans[0]?.plan.executionContext.decisionSnapshotCapturedAt);
|
|
136885
137172
|
capacityPlans.forEach(({ planIndex }, index) => serverCapacityByPlan.set(planIndex, allocations[index]));
|
|
136886
137173
|
}
|
|
137174
|
+
const endPlansAfterEarlierOrder = (planIndex, symbol2, reason) => {
|
|
137175
|
+
cycleOutcome = "interrupted";
|
|
137176
|
+
cycleReason = reason;
|
|
137177
|
+
appendRuntimeDebugEvent({
|
|
137178
|
+
label: "execution_plans_ended_after_earlier_order",
|
|
137179
|
+
note: [
|
|
137180
|
+
`cycle_id=${result.cycleId}`,
|
|
137181
|
+
`index=${planIndex + 1}/${executionPlans.length}`,
|
|
137182
|
+
`symbol=${symbol2}`,
|
|
137183
|
+
`reason=${reason}`
|
|
137184
|
+
].join(" "),
|
|
137185
|
+
outcome: "error"
|
|
137186
|
+
});
|
|
137187
|
+
};
|
|
136887
137188
|
const runPlan = async (plan, planIndex) => {
|
|
136888
137189
|
const withPlanCapacityTrim = (planResult) => {
|
|
136889
137190
|
if (plan.capacityTrim) {
|
|
@@ -136903,6 +137204,7 @@ var init_engine = __esm({
|
|
|
136903
137204
|
};
|
|
136904
137205
|
let planEntryOrderDispatched = false;
|
|
136905
137206
|
let planExitOrderDispatched = false;
|
|
137207
|
+
const finalizationOwedBeforePlan = this._executionFinalizationRequired;
|
|
136906
137208
|
const decisionWallet = String(
|
|
136907
137209
|
plan.executionContext.walletAddress || ""
|
|
136908
137210
|
).trim().toLowerCase();
|
|
@@ -136916,13 +137218,23 @@ var init_engine = __esm({
|
|
|
136916
137218
|
plan.executionContext.symbol
|
|
136917
137219
|
);
|
|
136918
137220
|
if (actionablePlan || trailingHoldCanMutate || protectiveHoldCanMutate) {
|
|
136919
|
-
|
|
136920
|
-
|
|
136921
|
-
|
|
136922
|
-
|
|
136923
|
-
|
|
136924
|
-
|
|
137221
|
+
try {
|
|
137222
|
+
await this._assertFreshClientWalletAssignment(
|
|
137223
|
+
profileId,
|
|
137224
|
+
decisionWallet,
|
|
137225
|
+
analysisAbortController.signal,
|
|
137226
|
+
actionablePlan ? "decision execution" : trailingHoldCanMutate ? "trailing stop maintenance" : "protective order reconciliation"
|
|
137227
|
+
);
|
|
137228
|
+
} catch (walletCheckError) {
|
|
137229
|
+
if (!finalizationOwedBeforePlan) throw walletCheckError;
|
|
137230
|
+
endPlansAfterEarlierOrder(planIndex, plan.executionContext.symbol, isTransientRuntimeConflictError(walletCheckError) ? "runtime_conflict" : isRuntimeContractMismatchError(walletCheckError) ? "runtime_contract_changed" : "runtime_interrupted");
|
|
137231
|
+
return { control: "break" };
|
|
137232
|
+
}
|
|
136925
137233
|
if (shouldAbortForContractInvalidation("post_execution_preferences_refresh")) {
|
|
137234
|
+
if (finalizationOwedBeforePlan) {
|
|
137235
|
+
endPlansAfterEarlierOrder(planIndex, plan.executionContext.symbol, "runtime_contract_changed");
|
|
137236
|
+
return { control: "break" };
|
|
137237
|
+
}
|
|
136926
137238
|
return { control: "return" };
|
|
136927
137239
|
}
|
|
136928
137240
|
}
|
|
@@ -136992,6 +137304,9 @@ var init_engine = __esm({
|
|
|
136992
137304
|
if (this._windowHandoffRequested && (dispatchKind !== "protection" || !planEntryOrderDispatched)) {
|
|
136993
137305
|
throw new Error(CLIENT_RUNTIME_WINDOW_HANDOFF_BEFORE_PLAN_DISPATCH);
|
|
136994
137306
|
}
|
|
137307
|
+
if (this._isStopping && this._executionFinalizationRequired && (dispatchKind === "entry" || dispatchKind === "exit")) {
|
|
137308
|
+
throw createStopAbortError("stopping_after_order");
|
|
137309
|
+
}
|
|
136995
137310
|
if (dispatchKind === "entry") {
|
|
136996
137311
|
planEntryOrderDispatched = true;
|
|
136997
137312
|
}
|
|
@@ -137030,6 +137345,15 @@ var init_engine = __esm({
|
|
|
137030
137345
|
return { control: "break" };
|
|
137031
137346
|
}
|
|
137032
137347
|
const abortedAfterCommittedOrder = committedReports.length > 0 && (analysisAbortController.signal.aborted || isRuntimeAbortError(executionError));
|
|
137348
|
+
const stoppedAfterEarlierPlanOrder = finalizationOwedBeforePlan && committedReports.length === 0 && !planEntryOrderDispatched && !planExitOrderDispatched;
|
|
137349
|
+
if (stoppedAfterEarlierPlanOrder) {
|
|
137350
|
+
const conflict = isTransientRuntimeConflictError(executionError);
|
|
137351
|
+
const contractChanged = isRuntimeContractMismatchError(executionError);
|
|
137352
|
+
if (conflict || contractChanged || analysisAbortController.signal.aborted || isRuntimeAbortError(executionError)) {
|
|
137353
|
+
endPlansAfterEarlierOrder(planIndex, plan.executionContext.symbol, conflict ? executionError.code === "provider_paced" ? "provider_paced" : "runtime_conflict" : contractChanged ? "runtime_contract_changed" : "runtime_interrupted");
|
|
137354
|
+
return { control: "break" };
|
|
137355
|
+
}
|
|
137356
|
+
}
|
|
137033
137357
|
if (!abortedAfterCommittedOrder && (analysisAbortController.signal.aborted || isRuntimeAbortError(executionError)) || isRuntimeContractMismatchError(executionError) || isClientExecutionModeMismatchError(executionError) || isClientRuntimeSessionStoppedError(executionError) || isClientRuntimeLeaseAuthError(executionError) || isTransientRuntimeConflictError(executionError) && committedReports.length === 0) {
|
|
137034
137358
|
throw executionError;
|
|
137035
137359
|
}
|
|
@@ -137196,6 +137520,10 @@ var init_engine = __esm({
|
|
|
137196
137520
|
if (dispatched > 0 && this._windowHandoffRequested) {
|
|
137197
137521
|
break;
|
|
137198
137522
|
}
|
|
137523
|
+
if (this._executionFinalizationRequired && this._isStopping) {
|
|
137524
|
+
endPlansAfterEarlierOrder(planIndex, executionPlans[planIndex].executionContext.symbol, "runtime_interrupted");
|
|
137525
|
+
break;
|
|
137526
|
+
}
|
|
137199
137527
|
const outcome = await runPlan(executionPlans[planIndex], planIndex);
|
|
137200
137528
|
if (outcome.control === "return") {
|
|
137201
137529
|
await settleUnsentAgentDecision("plan_ended_cycle");
|
|
@@ -137359,7 +137687,7 @@ var init_engine = __esm({
|
|
|
137359
137687
|
if (this._windowHandoffRequested) {
|
|
137360
137688
|
return;
|
|
137361
137689
|
}
|
|
137362
|
-
await checkInCopyTrading(config2);
|
|
137690
|
+
if (!this._isStopping) await checkInCopyTrading(config2);
|
|
137363
137691
|
this._executionModeMismatchConsecutiveCount = 0;
|
|
137364
137692
|
if (executionFailures.length > 0) {
|
|
137365
137693
|
cycleOutcome = "failed";
|
|
@@ -137424,7 +137752,7 @@ var init_engine = __esm({
|
|
|
137424
137752
|
cycleReason = "execution_mode_changed";
|
|
137425
137753
|
} else if (isTransientRuntimeConflictError(error48)) {
|
|
137426
137754
|
cycleOutcome = "interrupted";
|
|
137427
|
-
cycleReason = "runtime_conflict";
|
|
137755
|
+
cycleReason = error48.code === "provider_paced" ? "provider_paced" : "runtime_conflict";
|
|
137428
137756
|
}
|
|
137429
137757
|
if (this._state === "stopped" || this._analysisRequestId !== requestId) {
|
|
137430
137758
|
this._lastError = null;
|
|
@@ -137482,6 +137810,9 @@ var init_engine = __esm({
|
|
|
137482
137810
|
}
|
|
137483
137811
|
if (isTransientRuntimeConflictError(error48)) {
|
|
137484
137812
|
this._lastError = null;
|
|
137813
|
+
if (error48.code === "provider_paced") {
|
|
137814
|
+
pacedTurnDelayMs = readRetryableRuntimeRefusalDelayMs(error48);
|
|
137815
|
+
}
|
|
137485
137816
|
this._notifyListeners();
|
|
137486
137817
|
return;
|
|
137487
137818
|
}
|
|
@@ -137596,6 +137927,17 @@ var init_engine = __esm({
|
|
|
137596
137927
|
if (this._state === "running" && this._sessionId === sessionId) {
|
|
137597
137928
|
this._agentInstructionPollActive = agentPollDelayMs !== null;
|
|
137598
137929
|
}
|
|
137930
|
+
if (
|
|
137931
|
+
// Stale and offline runtimes run too (active); recovery re-arms none owing a settlement.
|
|
137932
|
+
(this._state === "running" || this._state === "stale" || this._state === "offline") && !this._killswitchLatched && !this._isStopping && !this._scheduledSuspendPromise && !this._windowHandoffRequested && this._executionFinalizationRequired
|
|
137933
|
+
) {
|
|
137934
|
+
appendRuntimeDebugEvent({
|
|
137935
|
+
label: "engine_execution_finalization_unsettled",
|
|
137936
|
+
note: `request_id=${requestId} outcome=${cycleOutcome} reason=${cycleReason ?? "none"}`,
|
|
137937
|
+
outcome: "error"
|
|
137938
|
+
});
|
|
137939
|
+
this._scheduleRecoverableSuspendAfterExecutionLoop({ reason: "execution_finalization_unsettled" });
|
|
137940
|
+
}
|
|
137599
137941
|
if (this._state === "running" && !this._killswitchLatched && !this._isStopping && !this._scheduledSuspendPromise && !this._executionFinalizationRequired) {
|
|
137600
137942
|
if (executedExchangeOrderInCycle) {
|
|
137601
137943
|
const previousNextRunAtMs2 = this._nextRunAtMs;
|
|
@@ -137622,16 +137964,19 @@ var init_engine = __esm({
|
|
|
137622
137964
|
const providerRetryWake = providerRetryDelayMs !== null && aiSchedulePauseMs === null && agentPollDelayMs === null ? providerRetryDelayMs : null;
|
|
137623
137965
|
if (providerRetryWake !== null) this._nextRunAtMs = Date.now() + providerRetryWake;
|
|
137624
137966
|
const windowEndsAtMs = this._aiScheduleWindowEndsAtMs;
|
|
137967
|
+
const pacedTurnAtMs = pacedTurnDelayMs === null ? null : Date.now() + pacedTurnDelayMs;
|
|
137968
|
+
const pacedTurnWake = pacedTurnAtMs !== null && aiSchedulePauseMs === null && agentPollDelayMs === null && providerRetryWake === null && this._nextRunAtMs != null && pacedTurnAtMs < this._nextRunAtMs && (windowEndsAtMs == null || pacedTurnAtMs < windowEndsAtMs) ? pacedTurnDelayMs : null;
|
|
137969
|
+
if (pacedTurnWake !== null && this._periodicSchedule) this._nextRunAtMs = Date.now() + pacedTurnWake;
|
|
137625
137970
|
const nextWorkAtMs = this._primaryAnalysisDisabled && this._loopIntervalMs != null ? Date.now() + this._loopIntervalMs : this._nextRunAtMs;
|
|
137626
|
-
const windowEndWake = aiSchedulePauseMs === null && agentPollDelayMs === null && providerRetryWake === null && windowEndsAtMs != null && windowEndsAtMs > Date.now() && (nextWorkAtMs == null || windowEndsAtMs < nextWorkAtMs) ? windowEndsAtMs - Date.now() : null;
|
|
137971
|
+
const windowEndWake = aiSchedulePauseMs === null && agentPollDelayMs === null && providerRetryWake === null && pacedTurnWake === null && windowEndsAtMs != null && windowEndsAtMs > Date.now() && (nextWorkAtMs == null || windowEndsAtMs < nextWorkAtMs) ? windowEndsAtMs - Date.now() : null;
|
|
137627
137972
|
this._aiScheduleCheckPending = windowEndWake !== null;
|
|
137628
137973
|
const manualRunWake = this._manualRunRequested ? 0 : null;
|
|
137629
137974
|
this._firstCycleEndedAtMs ??= Date.now();
|
|
137630
137975
|
if (cycleAgentDriven !== null) this._agentDrivenCycles = cycleAgentDriven;
|
|
137631
137976
|
this._armExecutionLoopTimer({
|
|
137632
137977
|
alignToNextRun: agentPollDelayMs === null,
|
|
137633
|
-
delayOverrideMs: manualRunWake ?? aiSchedulePauseMs ?? agentPollDelayMs ?? providerRetryWake ?? windowEndWake,
|
|
137634
|
-
reason: manualRunWake !== null ? "manual_run_requested" : aiSchedulePauseMs !== null ? "ai_schedule_paused" : agentPollDelayMs !== null ? "agent_instruction_poll" : providerRetryWake !== null ? "provider_failure_retry" : windowEndWake !== null ? "ai_schedule_window_end" : this._primaryAnalysisDisabled ? "main_model_disabled_copy_poll" : "cycle_finally",
|
|
137978
|
+
delayOverrideMs: manualRunWake ?? aiSchedulePauseMs ?? agentPollDelayMs ?? providerRetryWake ?? pacedTurnWake ?? windowEndWake,
|
|
137979
|
+
reason: manualRunWake !== null ? "manual_run_requested" : aiSchedulePauseMs !== null ? "ai_schedule_paused" : agentPollDelayMs !== null ? "agent_instruction_poll" : providerRetryWake !== null ? "provider_failure_retry" : pacedTurnWake !== null ? "provider_paced_retry" : windowEndWake !== null ? "ai_schedule_window_end" : this._primaryAnalysisDisabled ? "main_model_disabled_copy_poll" : "cycle_finally",
|
|
137635
137980
|
suppressNextRunProjection: aiSchedulePauseMs !== null && !aiSchedulePauseHasNext || agentPollDelayMs === null && aiSchedulePauseMs === null && this._primaryAnalysisDisabled
|
|
137636
137981
|
});
|
|
137637
137982
|
}
|
|
@@ -137855,7 +138200,7 @@ var init_engine = __esm({
|
|
|
137855
138200
|
origin: provenance?.origin ?? null,
|
|
137856
138201
|
providerNotConfigured: getRuntimeProviderSetupDiagnostics(reason)?.reason === "provider_not_configured",
|
|
137857
138202
|
attempts: getCycleErrorModelCalls(reason),
|
|
137858
|
-
causeMaxDepth:
|
|
138203
|
+
causeMaxDepth: DEVICE_DIAGNOSTICS4.error_cause_max_depth
|
|
137859
138204
|
});
|
|
137860
138205
|
if (failure2?.overloaded && provenance?.lane === "main") this._serverOverloadStreak += 1;
|
|
137861
138206
|
return failure2;
|
|
@@ -138862,7 +139207,7 @@ var init_engine = __esm({
|
|
|
138862
139207
|
* account_evidence_status, which is logged here.
|
|
138863
139208
|
*/
|
|
138864
139209
|
async _sendClientCopyTradingAccountEvidence(input) {
|
|
138865
|
-
const requestId = String(input.request.request_id ?? "").trim().slice(0,
|
|
139210
|
+
const requestId = String(input.request.request_id ?? "").trim().slice(0, DEVICE_DIAGNOSTICS4.copy_trading_request_id_chars) || "none";
|
|
138866
139211
|
const evidence = await readClientCopyTradingAccountEvidence({
|
|
138867
139212
|
request: input.request,
|
|
138868
139213
|
trustedWalletAddress: input.trustedWalletAddress,
|
|
@@ -138886,7 +139231,7 @@ var init_engine = __esm({
|
|
|
138886
139231
|
if (status !== "applied") {
|
|
138887
139232
|
appendRuntimeDebugEvent({
|
|
138888
139233
|
label: "copy_trading_account_evidence_rejected",
|
|
138889
|
-
note: `profile_id=${input.profileId} request_id=${requestId} reason=${String(status ?? "missing").slice(0,
|
|
139234
|
+
note: `profile_id=${input.profileId} request_id=${requestId} reason=${String(status ?? "missing").slice(0, DEVICE_DIAGNOSTICS4.copy_trading_status_chars)}`,
|
|
138890
139235
|
outcome: "error"
|
|
138891
139236
|
});
|
|
138892
139237
|
}
|
|
@@ -138894,7 +139239,7 @@ var init_engine = __esm({
|
|
|
138894
139239
|
if (evidence.read.source && sourceStatus !== "accepted") {
|
|
138895
139240
|
appendRuntimeDebugEvent({
|
|
138896
139241
|
label: "copy_trading_source_evidence_rejected",
|
|
138897
|
-
note: `profile_id=${input.profileId} request_id=${requestId} reason=${String(sourceStatus ?? "missing").slice(0,
|
|
139242
|
+
note: `profile_id=${input.profileId} request_id=${requestId} reason=${String(sourceStatus ?? "missing").slice(0, DEVICE_DIAGNOSTICS4.copy_trading_status_chars)}`,
|
|
138898
139243
|
outcome: "error"
|
|
138899
139244
|
});
|
|
138900
139245
|
}
|
|
@@ -139448,7 +139793,7 @@ var init_local_ai_preflight = __esm({
|
|
|
139448
139793
|
|
|
139449
139794
|
// lib/agent-core/headless-runtime.ts
|
|
139450
139795
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
139451
|
-
import { setTimeout as
|
|
139796
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
139452
139797
|
function objectOrNull2(value) {
|
|
139453
139798
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
139454
139799
|
}
|
|
@@ -139497,7 +139842,7 @@ async function claimRuntime(options, engine, identity2, kind, signal) {
|
|
|
139497
139842
|
}
|
|
139498
139843
|
if (claim.outcome === "wait" && waits < maxWaits) {
|
|
139499
139844
|
waits += 1;
|
|
139500
|
-
await
|
|
139845
|
+
await sleep2(Math.max(1, Number(claim.retry_after_seconds) || 1) * MS_PER_SECOND, void 0, { signal });
|
|
139501
139846
|
continue;
|
|
139502
139847
|
}
|
|
139503
139848
|
if (kind === "auto" && claim.outcome === "blocked") return null;
|
|
@@ -139789,7 +140134,7 @@ async function runHeadlessRuntime(options) {
|
|
|
139789
140134
|
status = read === "retry" ? null : read.status;
|
|
139790
140135
|
if (status || attempt2 >= BACKUP_FIRST_READ_RETRY_MS.length || stopController.signal.aborted) break;
|
|
139791
140136
|
try {
|
|
139792
|
-
await
|
|
140137
|
+
await sleep2(BACKUP_FIRST_READ_RETRY_MS[attempt2], void 0, { signal: stopController.signal });
|
|
139793
140138
|
} catch {
|
|
139794
140139
|
break;
|
|
139795
140140
|
}
|
|
@@ -139831,7 +140176,7 @@ async function runHeadlessRuntime(options) {
|
|
|
139831
140176
|
return "yielded_for_update";
|
|
139832
140177
|
}
|
|
139833
140178
|
try {
|
|
139834
|
-
await
|
|
140179
|
+
await sleep2(options.serverBackupWaitMs ?? BACKUP_WAIT_TICK_MS, void 0, { signal: stopController.signal });
|
|
139835
140180
|
} catch {
|
|
139836
140181
|
await withdraw();
|
|
139837
140182
|
return "stopped";
|
|
@@ -139984,7 +140329,7 @@ async function runHeadlessRuntime(options) {
|
|
|
139984
140329
|
try {
|
|
139985
140330
|
const backoff = options.resumeBackoffMs?.length ? options.resumeBackoffMs : RESUME_BACKOFF_MS;
|
|
139986
140331
|
if (event.kind !== "resume" || !event.immediate) {
|
|
139987
|
-
await
|
|
140332
|
+
await sleep2(backoff[Math.min(resumesWithoutCycle, backoff.length - 1)], void 0, {
|
|
139988
140333
|
signal: stopController.signal
|
|
139989
140334
|
});
|
|
139990
140335
|
}
|
|
@@ -140185,7 +140530,7 @@ function parsePositiveNumber(value, flag) {
|
|
|
140185
140530
|
}
|
|
140186
140531
|
return parsed;
|
|
140187
140532
|
}
|
|
140188
|
-
function
|
|
140533
|
+
function parseExecutionMode2(value) {
|
|
140189
140534
|
const normalized = value.trim().toLowerCase();
|
|
140190
140535
|
if (normalized !== "client" && normalized !== "server") {
|
|
140191
140536
|
throw new Error("--mode must be client or server");
|
|
@@ -140539,7 +140884,7 @@ async function runVtxCli(argv2, env = process.env) {
|
|
|
140539
140884
|
}
|
|
140540
140885
|
if (group === "profiles" && command === "set-mode") {
|
|
140541
140886
|
const profileId = requireProfileId(parsed.profileId, config2.activeProfileId);
|
|
140542
|
-
const mode =
|
|
140887
|
+
const mode = parseExecutionMode2(requireValue(args, "--mode"));
|
|
140543
140888
|
return { exitCode: 0, stdout: render3(await client.setProfileExecutionMode(profileId, mode), json2), stderr: "" };
|
|
140544
140889
|
}
|
|
140545
140890
|
if (group === "bots" && command === "start") {
|