@vtxmacro/cli 2026.9.44 → 2026.9.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vtx-service-bootstrap.js +54 -1
- package/bin/vtx.js +851 -546
- package/package.json +1 -1
package/bin/vtx.js
CHANGED
|
@@ -77,7 +77,7 @@ var init_agent_cli_release = __esm({
|
|
|
77
77
|
"agent-cli-release.json"() {
|
|
78
78
|
agent_cli_release_default = {
|
|
79
79
|
package_name: "@vtxmacro/cli",
|
|
80
|
-
package_version: "2026.9.
|
|
80
|
+
package_version: "2026.9.45",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.153.3",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -18351,17 +18351,17 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
18351
18351
|
clearTimeout(this.idleTimer);
|
|
18352
18352
|
this.idleTimer = null;
|
|
18353
18353
|
}
|
|
18354
|
-
const
|
|
18354
|
+
const pending3 = this.pending;
|
|
18355
18355
|
this.pending = null;
|
|
18356
|
-
if (
|
|
18357
|
-
clearTimeout(
|
|
18358
|
-
|
|
18356
|
+
if (pending3) {
|
|
18357
|
+
clearTimeout(pending3.timer);
|
|
18358
|
+
pending3.reject(error48);
|
|
18359
18359
|
}
|
|
18360
18360
|
child.kill("SIGKILL");
|
|
18361
18361
|
}
|
|
18362
18362
|
acceptLine(child, line) {
|
|
18363
|
-
const
|
|
18364
|
-
if (!
|
|
18363
|
+
const pending3 = this.pending;
|
|
18364
|
+
if (!pending3 || !line || line.length > 4096) {
|
|
18365
18365
|
this.failChild(child, new Error("Windows private ACL broker returned malformed output."));
|
|
18366
18366
|
return;
|
|
18367
18367
|
}
|
|
@@ -18370,7 +18370,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
18370
18370
|
const parsed = JSON.parse(line);
|
|
18371
18371
|
const status = String(parsed.status);
|
|
18372
18372
|
const expectedKeys = status === "error" ? "error_code\0id\0status" : "id\0status";
|
|
18373
|
-
if (Object.keys(parsed).sort().join("\0") !== expectedKeys || parsed.id !==
|
|
18373
|
+
if (Object.keys(parsed).sort().join("\0") !== expectedKeys || parsed.id !== pending3.id || !["ok", "missing", "error"].includes(status) || status === "error" && ![
|
|
18374
18374
|
"request_validation",
|
|
18375
18375
|
"path_lookup",
|
|
18376
18376
|
"principal_resolution",
|
|
@@ -18387,16 +18387,16 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
18387
18387
|
return;
|
|
18388
18388
|
}
|
|
18389
18389
|
this.pending = null;
|
|
18390
|
-
clearTimeout(
|
|
18390
|
+
clearTimeout(pending3.timer);
|
|
18391
18391
|
if (response.status === "ok") {
|
|
18392
|
-
|
|
18392
|
+
pending3.resolve();
|
|
18393
18393
|
} else if (response.status === "missing") {
|
|
18394
18394
|
const error48 = new Error("Windows private path no longer exists.");
|
|
18395
18395
|
error48.code = "ENOENT";
|
|
18396
|
-
|
|
18396
|
+
pending3.reject(error48);
|
|
18397
18397
|
} else {
|
|
18398
|
-
|
|
18399
|
-
`Windows private ACL ${
|
|
18398
|
+
pending3.reject(new Error(
|
|
18399
|
+
`Windows private ACL ${pending3.mode} failed (${response.error_code}).`
|
|
18400
18400
|
));
|
|
18401
18401
|
}
|
|
18402
18402
|
this.scheduleIdleShutdown();
|
|
@@ -18707,10 +18707,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
18707
18707
|
}
|
|
18708
18708
|
return `${platform}:${identity2}`;
|
|
18709
18709
|
};
|
|
18710
|
-
const
|
|
18711
|
-
if (platform === process.platform) cachedSystemBootIdentity =
|
|
18710
|
+
const pending3 = read();
|
|
18711
|
+
if (platform === process.platform) cachedSystemBootIdentity = pending3;
|
|
18712
18712
|
try {
|
|
18713
|
-
return await
|
|
18713
|
+
return await pending3;
|
|
18714
18714
|
} catch (error48) {
|
|
18715
18715
|
if (platform === process.platform) cachedSystemBootIdentity = null;
|
|
18716
18716
|
throw error48;
|
|
@@ -28801,8 +28801,8 @@ child.once('close', async (code, signal) => {
|
|
|
28801
28801
|
}
|
|
28802
28802
|
const id2 = message.id;
|
|
28803
28803
|
if (typeof id2 === "number" && Number.isSafeInteger(id2) && !("method" in message)) {
|
|
28804
|
-
const
|
|
28805
|
-
if (!
|
|
28804
|
+
const pending3 = this.pending.get(id2);
|
|
28805
|
+
if (!pending3) {
|
|
28806
28806
|
const retiredMethod = this.retiredResponseIds.get(id2);
|
|
28807
28807
|
this.retiredResponseIds.delete(id2);
|
|
28808
28808
|
if (retiredMethod && LATE_RESPONSE_SAFE_METHODS.has(retiredMethod)) {
|
|
@@ -28816,11 +28816,11 @@ child.once('close', async (code, signal) => {
|
|
|
28816
28816
|
return;
|
|
28817
28817
|
}
|
|
28818
28818
|
this.pending.delete(id2);
|
|
28819
|
-
if (
|
|
28820
|
-
|
|
28819
|
+
if (pending3.timer) clearTimeout(pending3.timer);
|
|
28820
|
+
pending3.abortCleanup?.();
|
|
28821
28821
|
const error48 = objectOrNull(message.error);
|
|
28822
28822
|
if (error48) {
|
|
28823
|
-
|
|
28823
|
+
pending3.reject(new CodexAppServerError({
|
|
28824
28824
|
message: "Codex app-server rejected a request.",
|
|
28825
28825
|
category: "adapter",
|
|
28826
28826
|
code: "rpc_rejected",
|
|
@@ -28830,7 +28830,7 @@ child.once('close', async (code, signal) => {
|
|
|
28830
28830
|
}
|
|
28831
28831
|
const result2 = objectOrNull(message.result);
|
|
28832
28832
|
if (!result2) {
|
|
28833
|
-
|
|
28833
|
+
pending3.reject(new CodexAppServerError({
|
|
28834
28834
|
message: "Codex app-server returned an invalid result.",
|
|
28835
28835
|
category: "adapter",
|
|
28836
28836
|
code: "invalid_rpc_result",
|
|
@@ -28838,7 +28838,7 @@ child.once('close', async (code, signal) => {
|
|
|
28838
28838
|
}));
|
|
28839
28839
|
return;
|
|
28840
28840
|
}
|
|
28841
|
-
|
|
28841
|
+
pending3.resolve(result2);
|
|
28842
28842
|
return;
|
|
28843
28843
|
}
|
|
28844
28844
|
const method = typeof message.method === "string" ? message.method : "";
|
|
@@ -28923,10 +28923,10 @@ child.once('close', async (code, signal) => {
|
|
|
28923
28923
|
retryable: true,
|
|
28924
28924
|
processExit
|
|
28925
28925
|
});
|
|
28926
|
-
for (const
|
|
28927
|
-
if (
|
|
28928
|
-
|
|
28929
|
-
|
|
28926
|
+
for (const pending3 of this.pending.values()) {
|
|
28927
|
+
if (pending3.timer) clearTimeout(pending3.timer);
|
|
28928
|
+
pending3.abortCleanup?.();
|
|
28929
|
+
pending3.reject(this.fatalError);
|
|
28930
28930
|
}
|
|
28931
28931
|
this.pending.clear();
|
|
28932
28932
|
for (const listener of this.fatalListeners) listener(this.fatalError);
|
|
@@ -28985,11 +28985,11 @@ child.once('close', async (code, signal) => {
|
|
|
28985
28985
|
});
|
|
28986
28986
|
}
|
|
28987
28987
|
return await new Promise((resolve12, reject) => {
|
|
28988
|
-
const
|
|
28989
|
-
|
|
28988
|
+
const pending3 = { resolve: resolve12, reject, timer: null, abortCleanup: null };
|
|
28989
|
+
pending3.timer = setTimeout(() => {
|
|
28990
28990
|
this.pending.delete(id2);
|
|
28991
28991
|
this.retireResponseId(id2, method);
|
|
28992
|
-
|
|
28992
|
+
pending3.abortCleanup?.();
|
|
28993
28993
|
reject(new CodexAppServerError({
|
|
28994
28994
|
message: "Codex app-server request timed out.",
|
|
28995
28995
|
category: "timeout",
|
|
@@ -29001,8 +29001,8 @@ child.once('close', async (code, signal) => {
|
|
|
29001
29001
|
const onAbort = () => {
|
|
29002
29002
|
this.pending.delete(id2);
|
|
29003
29003
|
this.retireResponseId(id2, method);
|
|
29004
|
-
if (
|
|
29005
|
-
|
|
29004
|
+
if (pending3.timer) clearTimeout(pending3.timer);
|
|
29005
|
+
pending3.abortCleanup?.();
|
|
29006
29006
|
reject(new CodexAppServerError({
|
|
29007
29007
|
message: "Codex request was cancelled.",
|
|
29008
29008
|
category: "cancelled",
|
|
@@ -29011,16 +29011,16 @@ child.once('close', async (code, signal) => {
|
|
|
29011
29011
|
}));
|
|
29012
29012
|
};
|
|
29013
29013
|
options.signal.addEventListener("abort", onAbort, { once: true });
|
|
29014
|
-
|
|
29014
|
+
pending3.abortCleanup = () => options.signal?.removeEventListener("abort", onAbort);
|
|
29015
29015
|
}
|
|
29016
|
-
this.pending.set(id2,
|
|
29016
|
+
this.pending.set(id2, pending3);
|
|
29017
29017
|
try {
|
|
29018
29018
|
this.write(params === void 0 ? { id: id2, method } : { id: id2, method, params });
|
|
29019
29019
|
options.onWritten?.(id2);
|
|
29020
29020
|
} catch (error48) {
|
|
29021
29021
|
this.pending.delete(id2);
|
|
29022
|
-
if (
|
|
29023
|
-
|
|
29022
|
+
if (pending3.timer) clearTimeout(pending3.timer);
|
|
29023
|
+
pending3.abortCleanup?.();
|
|
29024
29024
|
reject(error48);
|
|
29025
29025
|
}
|
|
29026
29026
|
});
|
|
@@ -30535,15 +30535,15 @@ var init_agent_state = __esm({
|
|
|
30535
30535
|
}
|
|
30536
30536
|
}
|
|
30537
30537
|
if (state.pending_decision !== null) {
|
|
30538
|
-
const
|
|
30539
|
-
if (!hasExactKeys(
|
|
30538
|
+
const pending3 = assertPlainObject(state.pending_decision, message);
|
|
30539
|
+
if (!hasExactKeys(pending3, [
|
|
30540
30540
|
"operation_id",
|
|
30541
30541
|
"candidate",
|
|
30542
30542
|
"observed_at",
|
|
30543
30543
|
"provenance",
|
|
30544
30544
|
"first_transmit_at",
|
|
30545
30545
|
"last_status_check_at"
|
|
30546
|
-
]) || typeof
|
|
30546
|
+
]) || typeof pending3.operation_id !== "string" || !pending3.operation_id || !pending3.candidate || typeof pending3.candidate !== "object" || Array.isArray(pending3.candidate) || !isIsoTimestamp(pending3.observed_at) || pending3.provenance !== null && (typeof pending3.provenance !== "object" || Array.isArray(pending3.provenance)) || pending3.first_transmit_at !== null && !isIsoTimestamp(pending3.first_transmit_at) || pending3.last_status_check_at !== null && !isIsoTimestamp(pending3.last_status_check_at)) throw new Error(message);
|
|
30547
30547
|
}
|
|
30548
30548
|
return state;
|
|
30549
30549
|
};
|
|
@@ -30594,18 +30594,18 @@ var init_agent_state = __esm({
|
|
|
30594
30594
|
]) || state.schema_version !== "vtx_foreground_agent_control_v1" || typeof state.host_id !== "string" || !state.host_id || state.next_wake_at !== null && !isIsoTimestamp(state.next_wake_at) || !isIsoTimestamp(state.updated_at)) throw new Error(message);
|
|
30595
30595
|
if (state.assignment !== null) assertRuntimeAssignment(state.assignment, message);
|
|
30596
30596
|
if (state.pending_next !== null) {
|
|
30597
|
-
const
|
|
30598
|
-
if (!hasExactKeys(
|
|
30597
|
+
const pending3 = assertPlainObject(state.pending_next, message);
|
|
30598
|
+
if (!hasExactKeys(pending3, ["operation_id", "requested_at"]) || typeof pending3.operation_id !== "string" || !pending3.operation_id || !isIsoTimestamp(pending3.requested_at)) throw new Error(message);
|
|
30599
30599
|
}
|
|
30600
30600
|
if (state.pending_decision !== null) {
|
|
30601
30601
|
if (state.assignment === null) throw new Error(message);
|
|
30602
|
-
const
|
|
30603
|
-
if (!hasExactKeys(
|
|
30602
|
+
const pending3 = assertPlainObject(state.pending_decision, message);
|
|
30603
|
+
if (!hasExactKeys(pending3, [
|
|
30604
30604
|
"request",
|
|
30605
30605
|
"first_transmit_at",
|
|
30606
30606
|
"last_status_check_at"
|
|
30607
30607
|
])) throw new Error(message);
|
|
30608
|
-
const request = assertPlainObject(
|
|
30608
|
+
const request = assertPlainObject(pending3.request, message);
|
|
30609
30609
|
if (!hasExactKeys(request, [
|
|
30610
30610
|
"assignment_id",
|
|
30611
30611
|
"assignment_generation",
|
|
@@ -30613,7 +30613,7 @@ var init_agent_state = __esm({
|
|
|
30613
30613
|
"candidate",
|
|
30614
30614
|
"observed_at",
|
|
30615
30615
|
"provenance"
|
|
30616
|
-
]) || request.assignment_id !== state.assignment.assignment_id || request.assignment_generation !== state.assignment.assignment_generation || typeof request.operation_id !== "string" || !request.operation_id || !request.candidate || typeof request.candidate !== "object" || Array.isArray(request.candidate) || !isIsoTimestamp(request.observed_at) || !request.provenance || typeof request.provenance !== "object" || Array.isArray(request.provenance) ||
|
|
30616
|
+
]) || request.assignment_id !== state.assignment.assignment_id || request.assignment_generation !== state.assignment.assignment_generation || typeof request.operation_id !== "string" || !request.operation_id || !request.candidate || typeof request.candidate !== "object" || Array.isArray(request.candidate) || !isIsoTimestamp(request.observed_at) || !request.provenance || typeof request.provenance !== "object" || Array.isArray(request.provenance) || pending3.first_transmit_at !== null && !isIsoTimestamp(pending3.first_transmit_at) || pending3.last_status_check_at !== null && !isIsoTimestamp(pending3.last_status_check_at)) throw new Error(message);
|
|
30617
30617
|
}
|
|
30618
30618
|
return state;
|
|
30619
30619
|
};
|
|
@@ -30663,12 +30663,12 @@ var init_agent_state = __esm({
|
|
|
30663
30663
|
if (Object.keys(record5).sort().join("\0") !== exactKeys.slice().sort().join("\0") || record5.schema_version !== "vtx_inference_agent_attempt_v1" || typeof record5.host_id !== "string" || !record5.host_id || typeof record5.job_id !== "string" || !record5.job_id || typeof record5.attempt_id !== "string" || !record5.attempt_id || typeof record5.claim_handle !== "string" || !record5.claim_handle || typeof record5.completion_operation_id !== "string" || !record5.completion_operation_id || typeof record5.failure_operation_id !== "string" || !record5.failure_operation_id || typeof record5.requested_model !== "string" || !record5.requested_model || typeof record5.requested_reasoning_effort !== "string" || !record5.requested_reasoning_effort || !["provider_response", "decision_candidate"].includes(String(record5.response_mode)) || typeof record5.deadline_at !== "string" || !Number.isFinite(Date.parse(record5.deadline_at)) || typeof record5.received_at !== "string" || !Number.isFinite(Date.parse(record5.received_at))) {
|
|
30664
30664
|
throw new Error("Agent-driven inference attempt state is invalid.");
|
|
30665
30665
|
}
|
|
30666
|
-
const
|
|
30667
|
-
if (
|
|
30668
|
-
if (!
|
|
30666
|
+
const pending3 = record5.pending_terminal;
|
|
30667
|
+
if (pending3 !== null) {
|
|
30668
|
+
if (!pending3 || typeof pending3 !== "object" || Array.isArray(pending3)) {
|
|
30669
30669
|
throw new Error("Agent-driven inference terminal recovery state is invalid.");
|
|
30670
30670
|
}
|
|
30671
|
-
const terminal =
|
|
30671
|
+
const terminal = pending3;
|
|
30672
30672
|
if (Object.keys(terminal).sort().join("\0") !== ["kind", "request"].sort().join("\0")) {
|
|
30673
30673
|
throw new Error("Agent-driven inference terminal recovery state is invalid.");
|
|
30674
30674
|
}
|
|
@@ -34473,7 +34473,7 @@ var init_runner = __esm({
|
|
|
34473
34473
|
if (state.pending_decision) {
|
|
34474
34474
|
return { success: false, value: { error: "decision_outcome_unresolved" } };
|
|
34475
34475
|
}
|
|
34476
|
-
const
|
|
34476
|
+
const pending3 = {
|
|
34477
34477
|
operation_id: randomUUID(),
|
|
34478
34478
|
candidate,
|
|
34479
34479
|
observed_at: nowIso(),
|
|
@@ -34492,17 +34492,17 @@ var init_runner = __esm({
|
|
|
34492
34492
|
if (state.pending_turn.decision_operation_ids.length >= 128) {
|
|
34493
34493
|
return { success: false, value: { error: "agent_turn_decision_limit" } };
|
|
34494
34494
|
}
|
|
34495
|
-
state = { ...state, pending_decision:
|
|
34495
|
+
state = { ...state, pending_decision: pending3, pending_turn: {
|
|
34496
34496
|
...state.pending_turn,
|
|
34497
34497
|
decision_operation_ids: [
|
|
34498
34498
|
...state.pending_turn.decision_operation_ids,
|
|
34499
|
-
|
|
34499
|
+
pending3.operation_id
|
|
34500
34500
|
]
|
|
34501
34501
|
}, updated_at: nowIso() };
|
|
34502
34502
|
await writeInferenceAgentRuntimeState(this.options.statePath, state);
|
|
34503
34503
|
state = {
|
|
34504
34504
|
...state,
|
|
34505
|
-
pending_decision: { ...
|
|
34505
|
+
pending_decision: { ...pending3, first_transmit_at: nowIso() },
|
|
34506
34506
|
updated_at: nowIso()
|
|
34507
34507
|
};
|
|
34508
34508
|
await writeInferenceAgentRuntimeState(this.options.statePath, state);
|
|
@@ -34511,10 +34511,10 @@ var init_runner = __esm({
|
|
|
34511
34511
|
submitStatus = await this.options.controlClient.submitDecision({
|
|
34512
34512
|
assignment_id: assignment.assignment_id,
|
|
34513
34513
|
assignment_generation: assignment.assignment_generation,
|
|
34514
|
-
operation_id:
|
|
34515
|
-
candidate:
|
|
34516
|
-
observed_at:
|
|
34517
|
-
provenance:
|
|
34514
|
+
operation_id: pending3.operation_id,
|
|
34515
|
+
candidate: pending3.candidate,
|
|
34516
|
+
observed_at: pending3.observed_at,
|
|
34517
|
+
provenance: pending3.provenance
|
|
34518
34518
|
}, { signal: turnAbort.signal });
|
|
34519
34519
|
} catch {
|
|
34520
34520
|
const recovery = {};
|
|
@@ -34716,12 +34716,12 @@ var init_runner = __esm({
|
|
|
34716
34716
|
return null;
|
|
34717
34717
|
}
|
|
34718
34718
|
async resolveLegacyPendingDecision(state, signal) {
|
|
34719
|
-
const
|
|
34720
|
-
if (!
|
|
34719
|
+
const pending3 = state.pending_decision;
|
|
34720
|
+
if (!pending3) return state;
|
|
34721
34721
|
const checkedAt = new Date(this.now()).toISOString();
|
|
34722
34722
|
const checking = {
|
|
34723
34723
|
...state,
|
|
34724
|
-
pending_decision: { ...
|
|
34724
|
+
pending_decision: { ...pending3, last_status_check_at: checkedAt },
|
|
34725
34725
|
updated_at: checkedAt
|
|
34726
34726
|
};
|
|
34727
34727
|
await writeInferenceAgentRuntimeState(this.options.statePath, checking);
|
|
@@ -34729,7 +34729,7 @@ var init_runner = __esm({
|
|
|
34729
34729
|
host_id: this.options.hostId,
|
|
34730
34730
|
assignment_id: state.assignment.assignment_id,
|
|
34731
34731
|
assignment_generation: state.assignment.assignment_generation,
|
|
34732
|
-
operation_id:
|
|
34732
|
+
operation_id: pending3.operation_id
|
|
34733
34733
|
}, { signal });
|
|
34734
34734
|
if (status.status !== "applied" && status.status !== "not_applied") return checking;
|
|
34735
34735
|
const resolved = {
|
|
@@ -34741,12 +34741,12 @@ var init_runner = __esm({
|
|
|
34741
34741
|
return resolved;
|
|
34742
34742
|
}
|
|
34743
34743
|
async resolvePendingDecision(state, signal, onStatus) {
|
|
34744
|
-
const
|
|
34745
|
-
if (!
|
|
34744
|
+
const pending3 = state.pending_decision;
|
|
34745
|
+
if (!pending3) return state;
|
|
34746
34746
|
const checkedAt = new Date(this.now()).toISOString();
|
|
34747
34747
|
const checking = {
|
|
34748
34748
|
...state,
|
|
34749
|
-
pending_decision: { ...
|
|
34749
|
+
pending_decision: { ...pending3, last_status_check_at: checkedAt },
|
|
34750
34750
|
updated_at: checkedAt
|
|
34751
34751
|
};
|
|
34752
34752
|
await writeInferenceAgentRuntimeState(this.options.statePath, checking);
|
|
@@ -34754,7 +34754,7 @@ var init_runner = __esm({
|
|
|
34754
34754
|
host_id: this.options.hostId,
|
|
34755
34755
|
assignment_id: state.assignment.assignment_id,
|
|
34756
34756
|
assignment_generation: state.assignment.assignment_generation,
|
|
34757
|
-
operation_id:
|
|
34757
|
+
operation_id: pending3.operation_id
|
|
34758
34758
|
}, { signal });
|
|
34759
34759
|
onStatus?.(status);
|
|
34760
34760
|
if (status.status !== "applied" && status.status !== "not_applied") return checking;
|
|
@@ -34968,18 +34968,18 @@ async function reauthorizeInferenceHost(options) {
|
|
|
34968
34968
|
return options.state;
|
|
34969
34969
|
}
|
|
34970
34970
|
const pair = generateExternalInferenceEnvelopeKeyPair();
|
|
34971
|
-
const
|
|
34971
|
+
const pending3 = await (options.beginLogin ?? beginInferenceOAuthLogin)({
|
|
34972
34972
|
apiUrl: config2.apiUrl,
|
|
34973
34973
|
hostId: previous.host_id,
|
|
34974
34974
|
keyGeneration: previous.key_generation + 1,
|
|
34975
34975
|
x25519PrivateKey: pair.private_key,
|
|
34976
34976
|
store: stagedStore
|
|
34977
34977
|
});
|
|
34978
|
-
options.emitAuthorization(
|
|
34978
|
+
options.emitAuthorization(pending3.authorizationUrl);
|
|
34979
34979
|
try {
|
|
34980
|
-
access5 = await
|
|
34980
|
+
access5 = await pending3.completion;
|
|
34981
34981
|
} catch (error48) {
|
|
34982
|
-
await
|
|
34982
|
+
await pending3.cancel().catch(() => void 0);
|
|
34983
34983
|
throw error48;
|
|
34984
34984
|
}
|
|
34985
34985
|
candidate = await store.readRecovery();
|
|
@@ -35510,9 +35510,9 @@ var init_codex_adapter = __esm({
|
|
|
35510
35510
|
return document2.attempts;
|
|
35511
35511
|
}
|
|
35512
35512
|
enqueue(operation) {
|
|
35513
|
-
const
|
|
35514
|
-
this.queue =
|
|
35515
|
-
return
|
|
35513
|
+
const pending3 = this.queue.then(operation, operation);
|
|
35514
|
+
this.queue = pending3.then(() => void 0, () => void 0);
|
|
35515
|
+
return pending3;
|
|
35516
35516
|
}
|
|
35517
35517
|
async load(attemptId) {
|
|
35518
35518
|
await this.queue;
|
|
@@ -37810,7 +37810,7 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
37810
37810
|
}
|
|
37811
37811
|
const reader = upstream.body.getReader();
|
|
37812
37812
|
const decoder2 = new TextDecoder();
|
|
37813
|
-
let
|
|
37813
|
+
let pending3 = "";
|
|
37814
37814
|
let observedId = "";
|
|
37815
37815
|
let observedModel = "";
|
|
37816
37816
|
let terminalObserved = false;
|
|
@@ -37845,13 +37845,13 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
37845
37845
|
while (true) {
|
|
37846
37846
|
const part = await reader.read();
|
|
37847
37847
|
if (part.done) break;
|
|
37848
|
-
|
|
37849
|
-
const lines =
|
|
37850
|
-
|
|
37848
|
+
pending3 += decoder2.decode(part.value, { stream: true });
|
|
37849
|
+
const lines = pending3.split(/\r?\n/u);
|
|
37850
|
+
pending3 = lines.pop() ?? "";
|
|
37851
37851
|
for (const line of lines) forwardLine(line);
|
|
37852
37852
|
}
|
|
37853
|
-
|
|
37854
|
-
if (
|
|
37853
|
+
pending3 += decoder2.decode();
|
|
37854
|
+
if (pending3) forwardLine(pending3);
|
|
37855
37855
|
if (!terminalObserved) {
|
|
37856
37856
|
throw new Error("deepseek_provider_receipt_missing_or_mismatched");
|
|
37857
37857
|
}
|
|
@@ -38643,7 +38643,7 @@ var init_pi_transport = __esm({
|
|
|
38643
38643
|
reasoningEffortChanged: false
|
|
38644
38644
|
};
|
|
38645
38645
|
this.receipts.push(receipt);
|
|
38646
|
-
let
|
|
38646
|
+
let pending3 = "";
|
|
38647
38647
|
const decoder2 = new TextDecoder();
|
|
38648
38648
|
const inspect3 = (data4) => {
|
|
38649
38649
|
if (!data4.trim() || data4.trim() === "[DONE]") return;
|
|
@@ -38704,9 +38704,9 @@ var init_pi_transport = __esm({
|
|
|
38704
38704
|
}
|
|
38705
38705
|
};
|
|
38706
38706
|
const consume = (flush = false) => {
|
|
38707
|
-
if (
|
|
38708
|
-
const events =
|
|
38709
|
-
|
|
38707
|
+
if (pending3.length > 2e6) throw new Error("pi_receipt_event_too_large");
|
|
38708
|
+
const events = pending3.split(/\r?\n\r?\n/u);
|
|
38709
|
+
pending3 = flush ? "" : events.pop();
|
|
38710
38710
|
for (const event of events) {
|
|
38711
38711
|
const data4 = event.split(/\r?\n/u).filter((line) => line.startsWith("data:")).map((line) => line.slice(5).trimStart()).join("\n");
|
|
38712
38712
|
if (data4) inspect3(data4);
|
|
@@ -38714,12 +38714,12 @@ var init_pi_transport = __esm({
|
|
|
38714
38714
|
};
|
|
38715
38715
|
const stream = response.body.pipeThrough(new TransformStream({
|
|
38716
38716
|
transform: (chunk, controller) => {
|
|
38717
|
-
|
|
38717
|
+
pending3 += decoder2.decode(chunk, { stream: true });
|
|
38718
38718
|
consume();
|
|
38719
38719
|
controller.enqueue(chunk);
|
|
38720
38720
|
},
|
|
38721
38721
|
flush: () => {
|
|
38722
|
-
|
|
38722
|
+
pending3 += decoder2.decode();
|
|
38723
38723
|
consume(true);
|
|
38724
38724
|
}
|
|
38725
38725
|
}));
|
|
@@ -39401,18 +39401,18 @@ var init_grok_policy = __esm({
|
|
|
39401
39401
|
init_dist();
|
|
39402
39402
|
validateGrokPolicy = (value) => {
|
|
39403
39403
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Grok runtime policy is missing.");
|
|
39404
|
-
const
|
|
39405
|
-
const url2 = new URL(String(
|
|
39404
|
+
const policy2 = value;
|
|
39405
|
+
const url2 = new URL(String(policy2.subscription_proxy_base_url));
|
|
39406
39406
|
if (url2.protocol !== "https:" || url2.hostname !== "cli-chat-proxy.grok.com" || url2.pathname !== "/v1" || url2.port || url2.search || url2.hash || url2.username || url2.password) throw new Error("Grok subscription endpoint is invalid.");
|
|
39407
39407
|
for (const key of ["maximum_transport_request_bytes", "maximum_transport_response_bytes"]) {
|
|
39408
|
-
if (!Number.isSafeInteger(
|
|
39408
|
+
if (!Number.isSafeInteger(policy2[key]) || Number(policy2[key]) < 1 || Number(policy2[key]) > 64 * 1024 * 1024) {
|
|
39409
39409
|
throw new Error("Grok transport bounds are missing or invalid.");
|
|
39410
39410
|
}
|
|
39411
39411
|
}
|
|
39412
39412
|
return Object.freeze({
|
|
39413
39413
|
subscription_proxy_base_url: url2.href,
|
|
39414
|
-
maximum_transport_request_bytes: Number(
|
|
39415
|
-
maximum_transport_response_bytes: Number(
|
|
39414
|
+
maximum_transport_request_bytes: Number(policy2.maximum_transport_request_bytes),
|
|
39415
|
+
maximum_transport_response_bytes: Number(policy2.maximum_transport_response_bytes)
|
|
39416
39416
|
});
|
|
39417
39417
|
};
|
|
39418
39418
|
loadGrokPolicy = async () => {
|
|
@@ -39790,7 +39790,7 @@ var init_grok_transport_proxy = __esm({
|
|
|
39790
39790
|
const reader = upstream.body.getReader();
|
|
39791
39791
|
const decoder2 = new TextDecoder();
|
|
39792
39792
|
let bytes3 = 0;
|
|
39793
|
-
let
|
|
39793
|
+
let pending3 = "";
|
|
39794
39794
|
let eventData = [];
|
|
39795
39795
|
let id2 = "";
|
|
39796
39796
|
let model = "";
|
|
@@ -39902,9 +39902,9 @@ var init_grok_transport_proxy = __esm({
|
|
|
39902
39902
|
bytes3 += part.value.byteLength;
|
|
39903
39903
|
if (bytes3 > this.options.maxResponseBytes) throw new Error("grok_response_too_large");
|
|
39904
39904
|
if (route) {
|
|
39905
|
-
|
|
39906
|
-
const lines =
|
|
39907
|
-
|
|
39905
|
+
pending3 += decoder2.decode(part.value, { stream: true });
|
|
39906
|
+
const lines = pending3.split(/\r?\n/u);
|
|
39907
|
+
pending3 = lines.pop() ?? "";
|
|
39908
39908
|
for (const line of lines) {
|
|
39909
39909
|
if (!line) inspect3();
|
|
39910
39910
|
else if (line.startsWith("data:")) eventData.push(line.slice(5));
|
|
@@ -39913,8 +39913,8 @@ var init_grok_transport_proxy = __esm({
|
|
|
39913
39913
|
if (!response.write(part.value)) await once(response, "drain", { signal });
|
|
39914
39914
|
}
|
|
39915
39915
|
if (route) {
|
|
39916
|
-
|
|
39917
|
-
if (
|
|
39916
|
+
pending3 += decoder2.decode();
|
|
39917
|
+
if (pending3.startsWith("data:")) eventData.push(pending3.slice(5));
|
|
39918
39918
|
inspect3();
|
|
39919
39919
|
if (!terminal || !id2 || !model) throw new Error("grok_provider_terminal_missing");
|
|
39920
39920
|
}
|
|
@@ -40614,11 +40614,11 @@ var init_grok_adapter = __esm({
|
|
|
40614
40614
|
try {
|
|
40615
40615
|
signal.throwIfAborted();
|
|
40616
40616
|
const deadline = Date.now() + 3e4;
|
|
40617
|
-
const
|
|
40617
|
+
const policy2 = this.options.policy ?? await loadGrokPolicy();
|
|
40618
40618
|
proxy = await createGrokTransportProxy({
|
|
40619
|
-
upstreamBaseUrl:
|
|
40620
|
-
maxRequestBytes:
|
|
40621
|
-
maxResponseBytes:
|
|
40619
|
+
upstreamBaseUrl: policy2.subscription_proxy_base_url,
|
|
40620
|
+
maxRequestBytes: policy2.maximum_transport_request_bytes,
|
|
40621
|
+
maxResponseBytes: policy2.maximum_transport_response_bytes,
|
|
40622
40622
|
metadataOnly: true,
|
|
40623
40623
|
requestedModel: "",
|
|
40624
40624
|
requestedReasoningEffort: "none",
|
|
@@ -40693,7 +40693,7 @@ var init_grok_adapter = __esm({
|
|
|
40693
40693
|
input.signal.throwIfAborted();
|
|
40694
40694
|
const startedAt = Date.now();
|
|
40695
40695
|
const binary = await this.binary();
|
|
40696
|
-
const
|
|
40696
|
+
const policy2 = this.options.policy ?? await loadGrokPolicy();
|
|
40697
40697
|
input.signal.throwIfAborted();
|
|
40698
40698
|
const workspace = agent?.durableThread ? await validateGrokOwnedThread(this.stateOptions, agent.durableThread) : await createGrokOwnedWorkspace(this.stateOptions, agent ? "agent" : "attempt");
|
|
40699
40699
|
let mcp = null;
|
|
@@ -40743,9 +40743,9 @@ var init_grok_adapter = __esm({
|
|
|
40743
40743
|
return result3;
|
|
40744
40744
|
} }) : null;
|
|
40745
40745
|
proxy = await createGrokTransportProxy({
|
|
40746
|
-
upstreamBaseUrl:
|
|
40747
|
-
maxRequestBytes:
|
|
40748
|
-
maxResponseBytes:
|
|
40746
|
+
upstreamBaseUrl: policy2.subscription_proxy_base_url,
|
|
40747
|
+
maxRequestBytes: policy2.maximum_transport_request_bytes,
|
|
40748
|
+
maxResponseBytes: policy2.maximum_transport_response_bytes,
|
|
40749
40749
|
expectedSystemPrompt: input.systemPrompt,
|
|
40750
40750
|
requestedModel: input.requestedModel,
|
|
40751
40751
|
requestedReasoningEffort: input.requestedReasoningEffort,
|
|
@@ -40956,7 +40956,7 @@ var init_grok_auth = __esm({
|
|
|
40956
40956
|
stdio: ["ignore", "pipe", "pipe"],
|
|
40957
40957
|
windowsHide: true
|
|
40958
40958
|
});
|
|
40959
|
-
let
|
|
40959
|
+
let pending3 = "";
|
|
40960
40960
|
let bytes3 = 0;
|
|
40961
40961
|
let verificationUrl = "";
|
|
40962
40962
|
let userCode = "";
|
|
@@ -40974,9 +40974,9 @@ var init_grok_auth = __esm({
|
|
|
40974
40974
|
stop();
|
|
40975
40975
|
return;
|
|
40976
40976
|
}
|
|
40977
|
-
|
|
40978
|
-
const lines =
|
|
40979
|
-
|
|
40977
|
+
pending3 += chunk.toString("utf8");
|
|
40978
|
+
const lines = pending3.split(/\r?\n/u);
|
|
40979
|
+
pending3 = lines.pop() ?? "";
|
|
40980
40980
|
for (const line of lines) {
|
|
40981
40981
|
const clean = line.replace(/\x1b\[[0-9;]*[A-Za-z]/gu, "").trim();
|
|
40982
40982
|
if (/^https:\/\//u.test(clean)) {
|
|
@@ -41444,16 +41444,16 @@ var init_exo_policy = __esm({
|
|
|
41444
41444
|
init_define_VTX_PI_MODEL_POLICY();
|
|
41445
41445
|
init_dist();
|
|
41446
41446
|
validateExoPolicy = (value) => {
|
|
41447
|
-
const
|
|
41448
|
-
if (!
|
|
41447
|
+
const policy2 = value;
|
|
41448
|
+
if (!policy2 || typeof policy2 !== "object" || Array.isArray(policy2) || Object.keys(policy2).sort().join(",") !== "endpoints,maximum_tool_rounds,models,upstream_commit" || typeof policy2.upstream_commit !== "string" || !/^[a-f0-9]{40}$/u.test(policy2.upstream_commit) || !Number.isSafeInteger(policy2.maximum_tool_rounds) || policy2.maximum_tool_rounds < 1 || policy2.maximum_tool_rounds > 64 || !Array.isArray(policy2.models) || !policy2.models.length || policy2.models.length > 64) {
|
|
41449
41449
|
throw new Error("Exo runtime policy is missing or invalid.");
|
|
41450
41450
|
}
|
|
41451
|
-
if (!
|
|
41452
|
-
for (const [provider, endpoint] of Object.entries(
|
|
41451
|
+
if (!policy2.endpoints || Object.keys(policy2.endpoints).sort().join(",") !== "openai,venice") throw new Error("Exo provider endpoints are invalid.");
|
|
41452
|
+
for (const [provider, endpoint] of Object.entries(policy2.endpoints)) {
|
|
41453
41453
|
const url2 = new URL(endpoint);
|
|
41454
41454
|
if (url2.protocol !== "https:" || url2.username || url2.password || url2.search || url2.hash || url2.hostname !== (provider === "openai" ? "api.openai.com" : "api.venice.ai") || url2.port || url2.pathname !== (provider === "openai" ? "/v1" : "/api/v1")) throw new Error("Exo provider endpoint is not qualified.");
|
|
41455
41455
|
}
|
|
41456
|
-
const models =
|
|
41456
|
+
const models = policy2.models.map((model) => {
|
|
41457
41457
|
if (!model || typeof model !== "object" || Array.isArray(model) || Object.keys(model).sort().join(",") !== "default_effort,efforts,model,name,reasoning" || typeof model.model !== "string" || !/^(?:openai|venice)\/[A-Za-z0-9][A-Za-z0-9._-]{0,110}$/u.test(model.model) || typeof model.name !== "string" || !model.name.trim() || model.name.length > 128 || typeof model.reasoning !== "boolean" || !Array.isArray(model.efforts) || !model.efforts.length || model.efforts.some((effort2) => typeof effort2 !== "string" || !["none", "minimal", "low", "medium", "high", "xhigh", "max"].includes(effort2)) || new Set(model.efforts).size !== model.efforts.length || !model.efforts.includes(model.default_effort) || !model.reasoning && (model.efforts.length !== 1 || model.efforts[0] !== "none") || model.model.startsWith("venice/") && (model.model !== "venice/google-gemma-4-31b-it" || !model.reasoning || model.efforts.length !== 1 || model.efforts[0] !== "none")) {
|
|
41458
41458
|
throw new Error("Exo model qualification policy is invalid.");
|
|
41459
41459
|
}
|
|
@@ -41462,7 +41462,7 @@ var init_exo_policy = __esm({
|
|
|
41462
41462
|
if (new Set(models.map((model) => model.model)).size !== models.length) {
|
|
41463
41463
|
throw new Error("Exo policy contains duplicate model identities.");
|
|
41464
41464
|
}
|
|
41465
|
-
return Object.freeze({ ...
|
|
41465
|
+
return Object.freeze({ ...policy2, endpoints: Object.freeze({ ...policy2.endpoints }), models: Object.freeze(models) });
|
|
41466
41466
|
};
|
|
41467
41467
|
loadExoPolicy = async () => {
|
|
41468
41468
|
if (typeof define_VTX_EXO_POLICY_default !== "undefined") return validateExoPolicy(define_VTX_EXO_POLICY_default);
|
|
@@ -42028,6 +42028,11 @@ var init_runtime_policy_generated = __esm({
|
|
|
42028
42028
|
performance_defaults: {
|
|
42029
42029
|
default_timeframe: "30d"
|
|
42030
42030
|
},
|
|
42031
|
+
execution_metadata_retry: {
|
|
42032
|
+
max_attempts: 3,
|
|
42033
|
+
base_delay_milliseconds: 2e3,
|
|
42034
|
+
max_delay_milliseconds: 3e4
|
|
42035
|
+
},
|
|
42031
42036
|
auth_bootstrap_retry: {
|
|
42032
42037
|
max_attempts: 3,
|
|
42033
42038
|
jitter_milliseconds: 750,
|
|
@@ -42137,6 +42142,54 @@ var init_runtime_policy_generated = __esm({
|
|
|
42137
42142
|
max_inflight: 16,
|
|
42138
42143
|
max_queue: 64
|
|
42139
42144
|
}
|
|
42145
|
+
},
|
|
42146
|
+
exchange: {
|
|
42147
|
+
hyperliquid: {
|
|
42148
|
+
client_public_read_budget: {
|
|
42149
|
+
max_weight: 900,
|
|
42150
|
+
window_seconds: 60,
|
|
42151
|
+
cooldown_seconds: 60,
|
|
42152
|
+
metadata_ttl_seconds: 300,
|
|
42153
|
+
user_fees_ttl_seconds: 300,
|
|
42154
|
+
account_mode_ttl_seconds: 30,
|
|
42155
|
+
default_request_weight: 20,
|
|
42156
|
+
cache_max_entries: 512
|
|
42157
|
+
},
|
|
42158
|
+
read_budget: {
|
|
42159
|
+
weights: {
|
|
42160
|
+
exchangeStatus: 2,
|
|
42161
|
+
clearinghouseState: 2,
|
|
42162
|
+
spotClearinghouseState: 2,
|
|
42163
|
+
l2Book: 2,
|
|
42164
|
+
allMids: 2,
|
|
42165
|
+
userFills: 120,
|
|
42166
|
+
userFillsByTime: 120,
|
|
42167
|
+
historicalOrders: 120,
|
|
42168
|
+
twapHistory: 120,
|
|
42169
|
+
userTwapSliceFills: 120,
|
|
42170
|
+
userFunding: 45,
|
|
42171
|
+
userNonFundingLedgerUpdates: 45,
|
|
42172
|
+
candleSnapshot: 104,
|
|
42173
|
+
userRole: 60,
|
|
42174
|
+
userAbstraction: 20,
|
|
42175
|
+
userDexAbstraction: 20,
|
|
42176
|
+
userActiveAssetData: 20,
|
|
42177
|
+
activeAssetData: 20,
|
|
42178
|
+
openOrders: 20,
|
|
42179
|
+
orderStatus: 2,
|
|
42180
|
+
portfolio: 20,
|
|
42181
|
+
userFees: 20,
|
|
42182
|
+
metaAndAssetCtxs: 20,
|
|
42183
|
+
meta: 20,
|
|
42184
|
+
perpDexs: 20,
|
|
42185
|
+
spotMeta: 20,
|
|
42186
|
+
approvedAgents: 20,
|
|
42187
|
+
authorizedAgents: 20,
|
|
42188
|
+
agents: 20,
|
|
42189
|
+
apiWallets: 20
|
|
42190
|
+
}
|
|
42191
|
+
}
|
|
42192
|
+
}
|
|
42140
42193
|
}
|
|
42141
42194
|
};
|
|
42142
42195
|
}
|
|
@@ -43308,11 +43361,11 @@ ${result2.stderr}`)) {
|
|
|
43308
43361
|
let stdout = "";
|
|
43309
43362
|
let cooperativeStopTimedOut = false;
|
|
43310
43363
|
let cooperativeStopTimer = null;
|
|
43311
|
-
const
|
|
43364
|
+
const pending3 = { stdout: "", stderr: "" };
|
|
43312
43365
|
const writeTaggedOutput = (stream, text, flush = false) => {
|
|
43313
|
-
const lines = `${
|
|
43366
|
+
const lines = `${pending3[stream]}${text}`.split(/\r?\n/u);
|
|
43314
43367
|
const remainder = lines.pop() ?? "";
|
|
43315
|
-
|
|
43368
|
+
pending3[stream] = flush ? "" : remainder;
|
|
43316
43369
|
if (flush && remainder) lines.push(remainder);
|
|
43317
43370
|
if (flush && lines.at(-1) === "") lines.pop();
|
|
43318
43371
|
for (const line of lines) {
|
|
@@ -44617,7 +44670,7 @@ Waiting for approval...
|
|
|
44617
44670
|
}
|
|
44618
44671
|
}
|
|
44619
44672
|
};
|
|
44620
|
-
const
|
|
44673
|
+
const pending3 = await beginLogin({
|
|
44621
44674
|
apiUrl: config2.apiUrl,
|
|
44622
44675
|
hostId,
|
|
44623
44676
|
x25519PrivateKey: keyPair.private_key,
|
|
@@ -44627,23 +44680,23 @@ Waiting for approval...
|
|
|
44627
44680
|
const emitStdout = dependencies.emitStdout ?? ((text) => {
|
|
44628
44681
|
process.stdout.write(text);
|
|
44629
44682
|
});
|
|
44630
|
-
emitStdout(parsed.json ? `${JSON.stringify({ authorizationUrl:
|
|
44683
|
+
emitStdout(parsed.json ? `${JSON.stringify({ authorizationUrl: pending3.authorizationUrl })}
|
|
44631
44684
|
` : `Open this URL to authorize the VTX inference host:
|
|
44632
|
-
${
|
|
44685
|
+
${pending3.authorizationUrl}
|
|
44633
44686
|
|
|
44634
44687
|
Waiting for approval...
|
|
44635
44688
|
`);
|
|
44636
44689
|
if (!parsed.json && Boolean(process.stdout.isTTY) && Boolean(process.stdin.isTTY)) {
|
|
44637
44690
|
try {
|
|
44638
|
-
(dependencies.openBrowser ?? defaultOpenBrowser)(
|
|
44691
|
+
(dependencies.openBrowser ?? defaultOpenBrowser)(pending3.authorizationUrl);
|
|
44639
44692
|
} catch {
|
|
44640
44693
|
}
|
|
44641
44694
|
}
|
|
44642
44695
|
let access5;
|
|
44643
44696
|
try {
|
|
44644
|
-
access5 = await
|
|
44697
|
+
access5 = await pending3.completion;
|
|
44645
44698
|
} catch (error48) {
|
|
44646
|
-
await
|
|
44699
|
+
await pending3.cancel().catch(() => void 0);
|
|
44647
44700
|
throw error48;
|
|
44648
44701
|
}
|
|
44649
44702
|
const state = {
|
|
@@ -45603,13 +45656,13 @@ Waiting for approval...
|
|
|
45603
45656
|
};
|
|
45604
45657
|
await writeInferenceForegroundAgentControlState(config2.statePath, state);
|
|
45605
45658
|
}
|
|
45606
|
-
const
|
|
45659
|
+
const pending3 = state.pending_next;
|
|
45607
45660
|
let result2;
|
|
45608
45661
|
try {
|
|
45609
45662
|
result2 = await session.client.callTool("inference.agent.assignment.next", {
|
|
45610
|
-
operation_id:
|
|
45663
|
+
operation_id: pending3.operation_id,
|
|
45611
45664
|
host_id: session.localState.host_id,
|
|
45612
|
-
requested_at:
|
|
45665
|
+
requested_at: pending3.requested_at,
|
|
45613
45666
|
contract_version: "agent_assignment_v2",
|
|
45614
45667
|
...state.assignment ? {
|
|
45615
45668
|
assignment_id: state.assignment.assignment_id,
|
|
@@ -46150,23 +46203,23 @@ Waiting for approval...
|
|
|
46150
46203
|
});
|
|
46151
46204
|
const stopAt = now().getTime() + parsed.waitSeconds * 1e3;
|
|
46152
46205
|
while (true) {
|
|
46153
|
-
let
|
|
46154
|
-
if (!
|
|
46155
|
-
|
|
46206
|
+
let pending3 = await readInferenceAgentNextState(config2.statePath);
|
|
46207
|
+
if (!pending3) {
|
|
46208
|
+
pending3 = {
|
|
46156
46209
|
schema_version: "vtx_inference_agent_next_v1",
|
|
46157
46210
|
operation_id: agentOperationId("agent-next"),
|
|
46158
46211
|
requested_at: now().toISOString()
|
|
46159
46212
|
};
|
|
46160
|
-
await writeInferenceAgentNextState(config2.statePath,
|
|
46213
|
+
await writeInferenceAgentNextState(config2.statePath, pending3);
|
|
46161
46214
|
}
|
|
46162
46215
|
let result2;
|
|
46163
46216
|
const callStartedAtMs = now().getTime();
|
|
46164
46217
|
const callStartedMonotonicMs = performance.now();
|
|
46165
46218
|
try {
|
|
46166
46219
|
result2 = await session.client.callTool("inference.agent.next", {
|
|
46167
|
-
operation_id:
|
|
46220
|
+
operation_id: pending3.operation_id,
|
|
46168
46221
|
host_id: session.localState.host_id,
|
|
46169
|
-
requested_at:
|
|
46222
|
+
requested_at: pending3.requested_at,
|
|
46170
46223
|
provider_dispatch_freshness_contract: "foreground_v1"
|
|
46171
46224
|
});
|
|
46172
46225
|
} catch (error48) {
|
|
@@ -46188,7 +46241,7 @@ Waiting for approval...
|
|
|
46188
46241
|
const conservativeDeadline = Math.min(
|
|
46189
46242
|
Date.parse(result2.provider_dispatch_not_after),
|
|
46190
46243
|
receivedAtMs + Number(result2.provider_dispatch_freshness_remaining_ms) - roundTripMs,
|
|
46191
|
-
Date.parse(
|
|
46244
|
+
Date.parse(pending3.requested_at) + Number(result2.provider_dispatch_freshness_remaining_ms),
|
|
46192
46245
|
active?.provider_dispatch_local_not_after ? Date.parse(active.provider_dispatch_local_not_after) : Number.POSITIVE_INFINITY
|
|
46193
46246
|
);
|
|
46194
46247
|
localDispatchDeadline = new Date(conservativeDeadline).toISOString();
|
|
@@ -47890,6 +47943,491 @@ var init_hyperliquid_market_symbol = __esm({
|
|
|
47890
47943
|
}
|
|
47891
47944
|
});
|
|
47892
47945
|
|
|
47946
|
+
// lib/runtime/abort.ts
|
|
47947
|
+
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError;
|
|
47948
|
+
var init_abort = __esm({
|
|
47949
|
+
"lib/runtime/abort.ts"() {
|
|
47950
|
+
"use strict";
|
|
47951
|
+
init_define_VTX_EXO_POLICY();
|
|
47952
|
+
init_define_VTX_GROK_POLICY();
|
|
47953
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
47954
|
+
ABORT_MESSAGE_TOKENS = [
|
|
47955
|
+
"the operation was aborted",
|
|
47956
|
+
"the user aborted a request",
|
|
47957
|
+
"request was aborted",
|
|
47958
|
+
"request aborted",
|
|
47959
|
+
"signal is aborted",
|
|
47960
|
+
"client runtime stop requested"
|
|
47961
|
+
];
|
|
47962
|
+
readAbortLikeMessage = (error48) => {
|
|
47963
|
+
if (error48 instanceof Error) {
|
|
47964
|
+
return error48.message;
|
|
47965
|
+
}
|
|
47966
|
+
if (typeof error48 === "string") {
|
|
47967
|
+
return error48;
|
|
47968
|
+
}
|
|
47969
|
+
if (error48 && typeof error48 === "object" && typeof error48.message === "string") {
|
|
47970
|
+
return String(error48.message);
|
|
47971
|
+
}
|
|
47972
|
+
return "";
|
|
47973
|
+
};
|
|
47974
|
+
isAbortLikeError = (error48) => {
|
|
47975
|
+
if (typeof DOMException !== "undefined" && error48 instanceof DOMException) {
|
|
47976
|
+
return error48.name === "AbortError";
|
|
47977
|
+
}
|
|
47978
|
+
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
47979
|
+
return true;
|
|
47980
|
+
}
|
|
47981
|
+
if (error48 && typeof error48 === "object" && error48.name === "AbortError") {
|
|
47982
|
+
return true;
|
|
47983
|
+
}
|
|
47984
|
+
const normalized = readAbortLikeMessage(error48).trim().toLowerCase();
|
|
47985
|
+
if (!normalized) {
|
|
47986
|
+
return false;
|
|
47987
|
+
}
|
|
47988
|
+
return ABORT_MESSAGE_TOKENS.some((token) => normalized.includes(token));
|
|
47989
|
+
};
|
|
47990
|
+
}
|
|
47991
|
+
});
|
|
47992
|
+
|
|
47993
|
+
// lib/runtime/runtime-redaction.ts
|
|
47994
|
+
var REDACTED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, SECRET_ASSIGNMENT_PATTERN, SECRET_KEYWORD_VALUE_PATTERN, OPENAI_STYLE_KEY_PATTERN, VERTEX_EXPRESS_KEY_PATTERN, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError;
|
|
47995
|
+
var init_runtime_redaction = __esm({
|
|
47996
|
+
"lib/runtime/runtime-redaction.ts"() {
|
|
47997
|
+
"use strict";
|
|
47998
|
+
init_define_VTX_EXO_POLICY();
|
|
47999
|
+
init_define_VTX_GROK_POLICY();
|
|
48000
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
48001
|
+
init_abort();
|
|
48002
|
+
REDACTED_VALUE = "[REDACTED]";
|
|
48003
|
+
SECRET_QUERY_PARAM_PATTERN = /([?&](?:access_token|api(?:_|-)?key|auth|authorization|key|private_key|secret|sig|signature|token)=)[^&#\s]*/gi;
|
|
48004
|
+
BEARER_TOKEN_PATTERN = /\b(Bearer)\s+[A-Za-z0-9._:-]+\b/gi;
|
|
48005
|
+
SECRET_ASSIGNMENT_PATTERN = /((?:authorization\s*[:=]\s*['"]?Bearer\s+|x-api-key\s*[:=]\s*['"]?|api(?:_|-)?key\s*[:=]\s*['"]?|\bkey\s*[:=]\s*['"]?|token\s*[:=]\s*['"]?|secret\s*[:=]\s*['"]?))[^'"\s,}]+/gi;
|
|
48006
|
+
SECRET_KEYWORD_VALUE_PATTERN = /((?:private(?:_|-|\s)?key|signing(?:_|-|\s)?key)\s*[:=]\s*['"]?)(0x[a-fA-F0-9]{64}|[^'"\s,}]+)/gi;
|
|
48007
|
+
OPENAI_STYLE_KEY_PATTERN = /\bsk-[A-Za-z0-9._-]+\b/g;
|
|
48008
|
+
VERTEX_EXPRESS_KEY_PATTERN = /\bAQ\.[A-Za-z0-9._-]+\b/g;
|
|
48009
|
+
sanitizeRuntimeDiagnosticValue = (value) => {
|
|
48010
|
+
const normalized = String(value || "");
|
|
48011
|
+
if (!normalized) {
|
|
48012
|
+
return normalized;
|
|
48013
|
+
}
|
|
48014
|
+
return normalized.replace(SECRET_QUERY_PARAM_PATTERN, `$1${REDACTED_VALUE}`).replace(BEARER_TOKEN_PATTERN, `$1 ${REDACTED_VALUE}`).replace(SECRET_ASSIGNMENT_PATTERN, `$1${REDACTED_VALUE}`).replace(SECRET_KEYWORD_VALUE_PATTERN, `$1${REDACTED_VALUE}`).replace(OPENAI_STYLE_KEY_PATTERN, REDACTED_VALUE).replace(VERTEX_EXPRESS_KEY_PATTERN, REDACTED_VALUE);
|
|
48015
|
+
};
|
|
48016
|
+
sanitizeRuntimeNetworkPath = (value) => {
|
|
48017
|
+
const normalized = String(value || "").trim();
|
|
48018
|
+
if (!normalized) {
|
|
48019
|
+
return "/";
|
|
48020
|
+
}
|
|
48021
|
+
const withoutFragment = normalized.split("#", 1)[0] || normalized;
|
|
48022
|
+
const withoutQuery = withoutFragment.split("?", 1)[0] || withoutFragment;
|
|
48023
|
+
const sanitized = sanitizeRuntimeDiagnosticValue(withoutQuery.trim());
|
|
48024
|
+
return sanitized || "/";
|
|
48025
|
+
};
|
|
48026
|
+
getSanitizedRuntimeErrorMessage = (error48) => {
|
|
48027
|
+
const message = error48 instanceof Error ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
|
|
48028
|
+
if (message == null) {
|
|
48029
|
+
return null;
|
|
48030
|
+
}
|
|
48031
|
+
return sanitizeRuntimeDiagnosticValue(message);
|
|
48032
|
+
};
|
|
48033
|
+
toSanitizedRuntimeError = (error48) => {
|
|
48034
|
+
const message = getSanitizedRuntimeErrorMessage(error48) || "Unknown runtime error.";
|
|
48035
|
+
if (error48 instanceof Error && error48.message === message) {
|
|
48036
|
+
if (isAbortLikeError(error48) && error48.name !== "AbortError") {
|
|
48037
|
+
error48.name = "AbortError";
|
|
48038
|
+
}
|
|
48039
|
+
return error48;
|
|
48040
|
+
}
|
|
48041
|
+
const sanitized = new Error(message);
|
|
48042
|
+
if (isAbortLikeError(error48)) {
|
|
48043
|
+
sanitized.name = "AbortError";
|
|
48044
|
+
} else if (error48 instanceof Error && error48.name) {
|
|
48045
|
+
sanitized.name = error48.name;
|
|
48046
|
+
}
|
|
48047
|
+
return sanitized;
|
|
48048
|
+
};
|
|
48049
|
+
}
|
|
48050
|
+
});
|
|
48051
|
+
|
|
48052
|
+
// lib/runtime-policy.generated.json
|
|
48053
|
+
var runtime_policy_generated_default2;
|
|
48054
|
+
var init_runtime_policy_generated2 = __esm({
|
|
48055
|
+
"lib/runtime-policy.generated.json"() {
|
|
48056
|
+
runtime_policy_generated_default2 = {
|
|
48057
|
+
ui: {
|
|
48058
|
+
performance_defaults: {
|
|
48059
|
+
default_timeframe: "30d"
|
|
48060
|
+
},
|
|
48061
|
+
execution_metadata_retry: {
|
|
48062
|
+
max_attempts: 3,
|
|
48063
|
+
base_delay_milliseconds: 2e3,
|
|
48064
|
+
max_delay_milliseconds: 3e4
|
|
48065
|
+
},
|
|
48066
|
+
auth_bootstrap_retry: {
|
|
48067
|
+
max_attempts: 3,
|
|
48068
|
+
jitter_milliseconds: 750,
|
|
48069
|
+
base_delay_milliseconds: 500,
|
|
48070
|
+
min_delay_milliseconds: 250,
|
|
48071
|
+
max_delay_milliseconds: 1e4
|
|
48072
|
+
}
|
|
48073
|
+
},
|
|
48074
|
+
ai_dashboard: {
|
|
48075
|
+
market_news_bounds: {
|
|
48076
|
+
max_items_min: 1,
|
|
48077
|
+
max_items_max: 100,
|
|
48078
|
+
lookback_hours_min: 1,
|
|
48079
|
+
lookback_hours_max: 168,
|
|
48080
|
+
max_items_steps: [
|
|
48081
|
+
1,
|
|
48082
|
+
2,
|
|
48083
|
+
3,
|
|
48084
|
+
4,
|
|
48085
|
+
5,
|
|
48086
|
+
6,
|
|
48087
|
+
7,
|
|
48088
|
+
8,
|
|
48089
|
+
9,
|
|
48090
|
+
10,
|
|
48091
|
+
15,
|
|
48092
|
+
20,
|
|
48093
|
+
25,
|
|
48094
|
+
30,
|
|
48095
|
+
40,
|
|
48096
|
+
50,
|
|
48097
|
+
60,
|
|
48098
|
+
75,
|
|
48099
|
+
90,
|
|
48100
|
+
100
|
|
48101
|
+
],
|
|
48102
|
+
lookback_hours_steps: [
|
|
48103
|
+
1,
|
|
48104
|
+
2,
|
|
48105
|
+
4,
|
|
48106
|
+
8,
|
|
48107
|
+
12,
|
|
48108
|
+
24,
|
|
48109
|
+
48,
|
|
48110
|
+
72,
|
|
48111
|
+
168
|
|
48112
|
+
]
|
|
48113
|
+
}
|
|
48114
|
+
},
|
|
48115
|
+
trading: {
|
|
48116
|
+
engine: {
|
|
48117
|
+
client_runtime: {
|
|
48118
|
+
recovery: {
|
|
48119
|
+
resume_retry_base_delay_ms: 1e3,
|
|
48120
|
+
resume_retry_max_delay_ms: 3e4,
|
|
48121
|
+
transient_load_min_delay_ms: 3e4,
|
|
48122
|
+
transient_load_max_delay_ms: 12e4,
|
|
48123
|
+
rate_limit_buffer_ms: 1e3,
|
|
48124
|
+
rate_limit_max_delay_ms: 3e5,
|
|
48125
|
+
engine_stop_settle_retry_delay_ms: 250,
|
|
48126
|
+
recoverable_reset_settle_retry_delay_ms: 1500,
|
|
48127
|
+
local_ai_preflight_timeout_ms: 3e3,
|
|
48128
|
+
surge_stagger_max_ms: 6e4,
|
|
48129
|
+
surge_stagger_min_ms: 2e3,
|
|
48130
|
+
surge_stagger_min_candidates: 4,
|
|
48131
|
+
stagger_deadline_ttl_ms: 3e5,
|
|
48132
|
+
server_active_reprobe_delay_ms: 6e4,
|
|
48133
|
+
transient_load_jitter_ms: 1e4,
|
|
48134
|
+
cross_host_completed_ttl_ms: 15e3,
|
|
48135
|
+
telemetry_dedupe_ttl_ms: 5e3,
|
|
48136
|
+
browser_presence_heartbeat_interval_ms: 3e4,
|
|
48137
|
+
host_liveness_heartbeat_interval_ms: 3e4,
|
|
48138
|
+
host_liveness_recovery_nudge_ttl_ms: 1e4
|
|
48139
|
+
}
|
|
48140
|
+
}
|
|
48141
|
+
}
|
|
48142
|
+
},
|
|
48143
|
+
external_inference: {
|
|
48144
|
+
service: {
|
|
48145
|
+
update_check_interval_ms: 3e5,
|
|
48146
|
+
update_registry_timeout_ms: 15e3,
|
|
48147
|
+
startup_max_attempts: 40,
|
|
48148
|
+
startup_poll_interval_ms: 250,
|
|
48149
|
+
restart_stable_uptime_ms: 6e4,
|
|
48150
|
+
restart_backoff_base_ms: 1e3,
|
|
48151
|
+
restart_backoff_max_ms: 3e4,
|
|
48152
|
+
restart_exponent_max: 5
|
|
48153
|
+
}
|
|
48154
|
+
},
|
|
48155
|
+
desktop: {
|
|
48156
|
+
runtime_watchdog: {
|
|
48157
|
+
ping_interval_milliseconds: 15e3,
|
|
48158
|
+
telemetry_interval_milliseconds: 3e5
|
|
48159
|
+
}
|
|
48160
|
+
},
|
|
48161
|
+
screener: {
|
|
48162
|
+
resource_scheduler: {
|
|
48163
|
+
client_lock_ttl_milliseconds: 12e4,
|
|
48164
|
+
client_poll_interval_milliseconds: 250
|
|
48165
|
+
}
|
|
48166
|
+
},
|
|
48167
|
+
deployment: {
|
|
48168
|
+
cutover_buffer: {
|
|
48169
|
+
target_timeout_ms: 3e3,
|
|
48170
|
+
retired_timeout_ms: 45e3,
|
|
48171
|
+
max_body_bytes: 33554432,
|
|
48172
|
+
max_inflight: 16,
|
|
48173
|
+
max_queue: 64
|
|
48174
|
+
}
|
|
48175
|
+
},
|
|
48176
|
+
exchange: {
|
|
48177
|
+
hyperliquid: {
|
|
48178
|
+
client_public_read_budget: {
|
|
48179
|
+
max_weight: 900,
|
|
48180
|
+
window_seconds: 60,
|
|
48181
|
+
cooldown_seconds: 60,
|
|
48182
|
+
metadata_ttl_seconds: 300,
|
|
48183
|
+
user_fees_ttl_seconds: 300,
|
|
48184
|
+
account_mode_ttl_seconds: 30,
|
|
48185
|
+
default_request_weight: 20,
|
|
48186
|
+
cache_max_entries: 512
|
|
48187
|
+
},
|
|
48188
|
+
read_budget: {
|
|
48189
|
+
weights: {
|
|
48190
|
+
exchangeStatus: 2,
|
|
48191
|
+
clearinghouseState: 2,
|
|
48192
|
+
spotClearinghouseState: 2,
|
|
48193
|
+
l2Book: 2,
|
|
48194
|
+
allMids: 2,
|
|
48195
|
+
userFills: 120,
|
|
48196
|
+
userFillsByTime: 120,
|
|
48197
|
+
historicalOrders: 120,
|
|
48198
|
+
twapHistory: 120,
|
|
48199
|
+
userTwapSliceFills: 120,
|
|
48200
|
+
userFunding: 45,
|
|
48201
|
+
userNonFundingLedgerUpdates: 45,
|
|
48202
|
+
candleSnapshot: 104,
|
|
48203
|
+
userRole: 60,
|
|
48204
|
+
userAbstraction: 20,
|
|
48205
|
+
userDexAbstraction: 20,
|
|
48206
|
+
userActiveAssetData: 20,
|
|
48207
|
+
activeAssetData: 20,
|
|
48208
|
+
openOrders: 20,
|
|
48209
|
+
orderStatus: 2,
|
|
48210
|
+
portfolio: 20,
|
|
48211
|
+
userFees: 20,
|
|
48212
|
+
metaAndAssetCtxs: 20,
|
|
48213
|
+
meta: 20,
|
|
48214
|
+
perpDexs: 20,
|
|
48215
|
+
spotMeta: 20,
|
|
48216
|
+
approvedAgents: 20,
|
|
48217
|
+
authorizedAgents: 20,
|
|
48218
|
+
agents: 20,
|
|
48219
|
+
apiWallets: 20
|
|
48220
|
+
}
|
|
48221
|
+
}
|
|
48222
|
+
}
|
|
48223
|
+
}
|
|
48224
|
+
};
|
|
48225
|
+
}
|
|
48226
|
+
});
|
|
48227
|
+
|
|
48228
|
+
// lib/runtime/hyperliquid-public-read.ts
|
|
48229
|
+
var policy, weights, budgets, unpersistedBudgets, cache, pending2, PREFIX, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, admit, cooldown, reserveHyperliquidPublicReads, readHyperliquidPublicInfo;
|
|
48230
|
+
var init_hyperliquid_public_read = __esm({
|
|
48231
|
+
"lib/runtime/hyperliquid-public-read.ts"() {
|
|
48232
|
+
"use strict";
|
|
48233
|
+
init_define_VTX_EXO_POLICY();
|
|
48234
|
+
init_define_VTX_GROK_POLICY();
|
|
48235
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
48236
|
+
init_runtime_redaction();
|
|
48237
|
+
init_runtime_policy_generated2();
|
|
48238
|
+
policy = runtime_policy_generated_default2.exchange.hyperliquid.client_public_read_budget;
|
|
48239
|
+
weights = runtime_policy_generated_default2.exchange.hyperliquid.read_budget.weights;
|
|
48240
|
+
budgets = /* @__PURE__ */ new Map();
|
|
48241
|
+
unpersistedBudgets = /* @__PURE__ */ new Set();
|
|
48242
|
+
cache = /* @__PURE__ */ new Map();
|
|
48243
|
+
pending2 = /* @__PURE__ */ new Map();
|
|
48244
|
+
PREFIX = "vtx:hl-public-read-budget:v1:";
|
|
48245
|
+
abortError2 = (signal) => signal?.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
|
|
48246
|
+
checkAbort = (signal) => {
|
|
48247
|
+
if (signal?.aborted) throw abortError2(signal);
|
|
48248
|
+
};
|
|
48249
|
+
wait = (ms, signal) => new Promise((resolve12, reject) => {
|
|
48250
|
+
checkAbort(signal);
|
|
48251
|
+
const aborted2 = () => {
|
|
48252
|
+
clearTimeout(timer);
|
|
48253
|
+
reject(abortError2(signal));
|
|
48254
|
+
};
|
|
48255
|
+
const timer = setTimeout(() => {
|
|
48256
|
+
signal?.removeEventListener("abort", aborted2);
|
|
48257
|
+
resolve12();
|
|
48258
|
+
}, Math.min(ms, 2147483647));
|
|
48259
|
+
signal?.addEventListener("abort", aborted2, { once: true });
|
|
48260
|
+
});
|
|
48261
|
+
storage = () => {
|
|
48262
|
+
try {
|
|
48263
|
+
return typeof localStorage === "undefined" ? null : localStorage;
|
|
48264
|
+
} catch {
|
|
48265
|
+
return null;
|
|
48266
|
+
}
|
|
48267
|
+
};
|
|
48268
|
+
loadBudget = (key) => {
|
|
48269
|
+
const memory = budgets.get(key) ?? { reservations: [], cooldownUntil: 0 };
|
|
48270
|
+
if (unpersistedBudgets.has(key)) return memory;
|
|
48271
|
+
try {
|
|
48272
|
+
const target = storage();
|
|
48273
|
+
if (target && target.getItem(key) == null) return { reservations: [], cooldownUntil: 0 };
|
|
48274
|
+
const stored = JSON.parse(target?.getItem(key) ?? "null");
|
|
48275
|
+
if (stored && Array.isArray(stored.reservations) && Number.isFinite(stored.cooldownUntil) && stored.reservations.every((r) => Number.isFinite(r.at) && Number.isFinite(r.weight) && r.weight > 0)) return stored;
|
|
48276
|
+
} catch {
|
|
48277
|
+
}
|
|
48278
|
+
return memory;
|
|
48279
|
+
};
|
|
48280
|
+
saveBudget = (key, budget) => {
|
|
48281
|
+
budgets.set(key, budget);
|
|
48282
|
+
try {
|
|
48283
|
+
const target = storage();
|
|
48284
|
+
if (!target) {
|
|
48285
|
+
unpersistedBudgets.add(key);
|
|
48286
|
+
return;
|
|
48287
|
+
}
|
|
48288
|
+
target.setItem(key, JSON.stringify(budget));
|
|
48289
|
+
unpersistedBudgets.delete(key);
|
|
48290
|
+
} catch {
|
|
48291
|
+
unpersistedBudgets.add(key);
|
|
48292
|
+
}
|
|
48293
|
+
};
|
|
48294
|
+
withBudgetLock = async (key, signal, work) => {
|
|
48295
|
+
checkAbort(signal);
|
|
48296
|
+
if (typeof navigator !== "undefined" && navigator.locks?.request) {
|
|
48297
|
+
return navigator.locks.request(key, { ...signal ? { signal } : {} }, work);
|
|
48298
|
+
}
|
|
48299
|
+
return work();
|
|
48300
|
+
};
|
|
48301
|
+
admit = async (apiUrl, requestType, signal, bundleWeight, bundleId) => {
|
|
48302
|
+
const key = `${PREFIX}${apiUrl}`;
|
|
48303
|
+
const weight = bundleWeight ?? weights[requestType] ?? policy.default_request_weight;
|
|
48304
|
+
if (!(weight > 0 && weight <= policy.max_weight)) throw new Error("Invalid Hyperliquid public read weight.");
|
|
48305
|
+
for (; ; ) {
|
|
48306
|
+
checkAbort(signal);
|
|
48307
|
+
const delay2 = await withBudgetLock(key, signal, () => {
|
|
48308
|
+
const now = Date.now();
|
|
48309
|
+
const budget = loadBudget(key);
|
|
48310
|
+
budget.reservations = budget.reservations.filter((r) => r.at > now - policy.window_seconds * 1e3);
|
|
48311
|
+
if (budget.cooldownUntil > now) throw Object.assign(new Error("Hyperliquid public read rate-limit cooldown."), { status: 429, requestType });
|
|
48312
|
+
let used = budget.reservations.reduce((sum, r) => sum + r.weight, 0);
|
|
48313
|
+
if (used + weight <= policy.max_weight) {
|
|
48314
|
+
budget.reservations.push({ at: now, weight, ...bundleId ? { id: bundleId } : {} });
|
|
48315
|
+
saveBudget(key, budget);
|
|
48316
|
+
return 0;
|
|
48317
|
+
}
|
|
48318
|
+
for (const reservation of budget.reservations) {
|
|
48319
|
+
used -= reservation.weight;
|
|
48320
|
+
if (used + weight <= policy.max_weight) return Math.max(1, reservation.at + policy.window_seconds * 1e3 - now);
|
|
48321
|
+
}
|
|
48322
|
+
throw new Error("Invalid Hyperliquid public read budget.");
|
|
48323
|
+
});
|
|
48324
|
+
if (!delay2) return;
|
|
48325
|
+
if (bundleWeight != null) throw Object.assign(new Error("Hyperliquid public read bundle budget exhausted."), { code: "public_budget_exhausted" });
|
|
48326
|
+
await wait(delay2, signal);
|
|
48327
|
+
}
|
|
48328
|
+
};
|
|
48329
|
+
cooldown = async (apiUrl, retryAfter) => {
|
|
48330
|
+
const key = `${PREFIX}${apiUrl}`;
|
|
48331
|
+
await withBudgetLock(key, void 0, () => {
|
|
48332
|
+
const now = Date.now();
|
|
48333
|
+
const seconds = retryAfter == null ? NaN : Number(retryAfter);
|
|
48334
|
+
const providerUntil = Number.isFinite(seconds) ? now + seconds * 1e3 : Date.parse(retryAfter ?? "");
|
|
48335
|
+
const budget = loadBudget(key);
|
|
48336
|
+
budget.cooldownUntil = Math.max(budget.cooldownUntil, now + policy.cooldown_seconds * 1e3, Number.isFinite(providerUntil) ? providerUntil : 0);
|
|
48337
|
+
saveBudget(key, budget);
|
|
48338
|
+
});
|
|
48339
|
+
};
|
|
48340
|
+
reserveHyperliquidPublicReads = async (endpoint, bodies, signal) => {
|
|
48341
|
+
const apiUrl = endpoint.replace(/\/$/, "");
|
|
48342
|
+
const weight = bodies.reduce((sum, body) => sum + (weights[String(body.type)] ?? policy.default_request_weight), 0);
|
|
48343
|
+
const id2 = crypto.randomUUID();
|
|
48344
|
+
const admittedAtMs = Date.now();
|
|
48345
|
+
await admit(apiUrl, "bundle", signal, weight, id2);
|
|
48346
|
+
const remaining = /* @__PURE__ */ new Map();
|
|
48347
|
+
for (const body of bodies) {
|
|
48348
|
+
const key = JSON.stringify(body);
|
|
48349
|
+
remaining.set(key, (remaining.get(key) ?? 0) + 1);
|
|
48350
|
+
}
|
|
48351
|
+
return { id: id2, endpoint: apiUrl, expiresAtMs: admittedAtMs + policy.window_seconds * 1e3, remaining };
|
|
48352
|
+
};
|
|
48353
|
+
readHyperliquidPublicInfo = async (endpoint, body, options = {}) => {
|
|
48354
|
+
const apiUrl = endpoint.replace(/\/$/, "");
|
|
48355
|
+
const requestType = String(body.type ?? "info");
|
|
48356
|
+
const ttlSeconds = ["meta", "spotMeta", "perpDexs"].includes(requestType) ? policy.metadata_ttl_seconds : requestType === "userFees" ? policy.user_fees_ttl_seconds : options.cacheAccountMode && ["userAbstraction", "userDexAbstraction"].includes(requestType) ? policy.account_mode_ttl_seconds : 0;
|
|
48357
|
+
const key = `${apiUrl}:${JSON.stringify(body)}`;
|
|
48358
|
+
checkAbort(options.signal);
|
|
48359
|
+
if (ttlSeconds) {
|
|
48360
|
+
for (; ; ) {
|
|
48361
|
+
const existing = cache.get(key);
|
|
48362
|
+
if (existing && Date.now() - existing.fetchedAtMs >= 0 && Date.now() - existing.fetchedAtMs < ttlSeconds * 500) return existing;
|
|
48363
|
+
const running = pending2.get(key);
|
|
48364
|
+
if (!running) break;
|
|
48365
|
+
await new Promise((resolve12, reject) => {
|
|
48366
|
+
const aborted2 = () => {
|
|
48367
|
+
options.signal?.removeEventListener("abort", aborted2);
|
|
48368
|
+
reject(abortError2(options.signal));
|
|
48369
|
+
};
|
|
48370
|
+
options.signal?.addEventListener("abort", aborted2, { once: true });
|
|
48371
|
+
running.then(() => {
|
|
48372
|
+
options.signal?.removeEventListener("abort", aborted2);
|
|
48373
|
+
resolve12();
|
|
48374
|
+
});
|
|
48375
|
+
});
|
|
48376
|
+
checkAbort(options.signal);
|
|
48377
|
+
}
|
|
48378
|
+
}
|
|
48379
|
+
let settled;
|
|
48380
|
+
if (ttlSeconds) pending2.set(key, new Promise((resolve12) => {
|
|
48381
|
+
settled = resolve12;
|
|
48382
|
+
}));
|
|
48383
|
+
try {
|
|
48384
|
+
const reservedKey = JSON.stringify(body);
|
|
48385
|
+
const remaining = options.reservation?.remaining.get(reservedKey) ?? 0;
|
|
48386
|
+
if (options.reservation?.endpoint === apiUrl && remaining > 0) {
|
|
48387
|
+
if (Date.now() >= options.reservation.expiresAtMs) throw Object.assign(new Error("Hyperliquid public read reservation expired."), { code: "public_budget_exhausted" });
|
|
48388
|
+
await withBudgetLock(`${PREFIX}${apiUrl}`, options.signal, () => {
|
|
48389
|
+
const budget = loadBudget(`${PREFIX}${apiUrl}`);
|
|
48390
|
+
const row = budget.reservations.find((entry) => entry.id === options.reservation.id);
|
|
48391
|
+
if (!row || Date.now() >= options.reservation.expiresAtMs) throw Object.assign(new Error("Hyperliquid public read reservation expired."), { code: "public_budget_exhausted" });
|
|
48392
|
+
row.at = Date.now();
|
|
48393
|
+
budget.reservations.sort((a, b2) => a.at - b2.at);
|
|
48394
|
+
saveBudget(`${PREFIX}${apiUrl}`, budget);
|
|
48395
|
+
});
|
|
48396
|
+
options.reservation.remaining.set(reservedKey, remaining - 1);
|
|
48397
|
+
} else await admit(apiUrl, requestType, options.signal);
|
|
48398
|
+
checkAbort(options.signal);
|
|
48399
|
+
if (loadBudget(`${PREFIX}${apiUrl}`).cooldownUntil > Date.now()) throw Object.assign(new Error("Hyperliquid public read rate-limit cooldown."), { status: 429, requestType });
|
|
48400
|
+
const response = await fetch(`${apiUrl}/info`, {
|
|
48401
|
+
method: "POST",
|
|
48402
|
+
headers: { "Content-Type": "application/json" },
|
|
48403
|
+
body: JSON.stringify(body),
|
|
48404
|
+
signal: options.signal
|
|
48405
|
+
});
|
|
48406
|
+
if (response.status === 429) await cooldown(apiUrl, response.headers.get("Retry-After"));
|
|
48407
|
+
const payload = await response.json().catch(() => ({}));
|
|
48408
|
+
if (!response.ok) {
|
|
48409
|
+
const detail = sanitizeRuntimeDiagnosticValue(typeof payload?.response === "string" ? payload.response : typeof payload?.detail === "string" ? payload.detail : "");
|
|
48410
|
+
throw Object.assign(new Error(`Hyperliquid info request failed (${response.status}) request_type=${requestType}.${detail ? ` ${detail}` : ""}`), {
|
|
48411
|
+
status: response.status,
|
|
48412
|
+
requestType
|
|
48413
|
+
});
|
|
48414
|
+
}
|
|
48415
|
+
const result2 = { payload, fetchedAtMs: Date.now() };
|
|
48416
|
+
if (ttlSeconds) {
|
|
48417
|
+
cache.set(key, result2);
|
|
48418
|
+
while (cache.size > policy.cache_max_entries) cache.delete(cache.keys().next().value);
|
|
48419
|
+
}
|
|
48420
|
+
return result2;
|
|
48421
|
+
} finally {
|
|
48422
|
+
if (ttlSeconds) {
|
|
48423
|
+
pending2.delete(key);
|
|
48424
|
+
settled?.();
|
|
48425
|
+
}
|
|
48426
|
+
}
|
|
48427
|
+
};
|
|
48428
|
+
}
|
|
48429
|
+
});
|
|
48430
|
+
|
|
47893
48431
|
// lib/sort-utils.ts
|
|
47894
48432
|
function compareCaseInsensitive(left, right) {
|
|
47895
48433
|
return String(left ?? "").localeCompare(String(right ?? ""), void 0, { sensitivity: "base" });
|
|
@@ -48514,112 +49052,6 @@ var init_hyperliquid_fee_contract = __esm({
|
|
|
48514
49052
|
}
|
|
48515
49053
|
});
|
|
48516
49054
|
|
|
48517
|
-
// lib/runtime/abort.ts
|
|
48518
|
-
var ABORT_MESSAGE_TOKENS, readAbortLikeMessage, isAbortLikeError;
|
|
48519
|
-
var init_abort = __esm({
|
|
48520
|
-
"lib/runtime/abort.ts"() {
|
|
48521
|
-
"use strict";
|
|
48522
|
-
init_define_VTX_EXO_POLICY();
|
|
48523
|
-
init_define_VTX_GROK_POLICY();
|
|
48524
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
48525
|
-
ABORT_MESSAGE_TOKENS = [
|
|
48526
|
-
"the operation was aborted",
|
|
48527
|
-
"the user aborted a request",
|
|
48528
|
-
"request was aborted",
|
|
48529
|
-
"request aborted",
|
|
48530
|
-
"signal is aborted",
|
|
48531
|
-
"client runtime stop requested"
|
|
48532
|
-
];
|
|
48533
|
-
readAbortLikeMessage = (error48) => {
|
|
48534
|
-
if (error48 instanceof Error) {
|
|
48535
|
-
return error48.message;
|
|
48536
|
-
}
|
|
48537
|
-
if (typeof error48 === "string") {
|
|
48538
|
-
return error48;
|
|
48539
|
-
}
|
|
48540
|
-
if (error48 && typeof error48 === "object" && typeof error48.message === "string") {
|
|
48541
|
-
return String(error48.message);
|
|
48542
|
-
}
|
|
48543
|
-
return "";
|
|
48544
|
-
};
|
|
48545
|
-
isAbortLikeError = (error48) => {
|
|
48546
|
-
if (typeof DOMException !== "undefined" && error48 instanceof DOMException) {
|
|
48547
|
-
return error48.name === "AbortError";
|
|
48548
|
-
}
|
|
48549
|
-
if (error48 instanceof Error && error48.name === "AbortError") {
|
|
48550
|
-
return true;
|
|
48551
|
-
}
|
|
48552
|
-
if (error48 && typeof error48 === "object" && error48.name === "AbortError") {
|
|
48553
|
-
return true;
|
|
48554
|
-
}
|
|
48555
|
-
const normalized = readAbortLikeMessage(error48).trim().toLowerCase();
|
|
48556
|
-
if (!normalized) {
|
|
48557
|
-
return false;
|
|
48558
|
-
}
|
|
48559
|
-
return ABORT_MESSAGE_TOKENS.some((token) => normalized.includes(token));
|
|
48560
|
-
};
|
|
48561
|
-
}
|
|
48562
|
-
});
|
|
48563
|
-
|
|
48564
|
-
// lib/runtime/runtime-redaction.ts
|
|
48565
|
-
var REDACTED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, SECRET_ASSIGNMENT_PATTERN, SECRET_KEYWORD_VALUE_PATTERN, OPENAI_STYLE_KEY_PATTERN, VERTEX_EXPRESS_KEY_PATTERN, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError;
|
|
48566
|
-
var init_runtime_redaction = __esm({
|
|
48567
|
-
"lib/runtime/runtime-redaction.ts"() {
|
|
48568
|
-
"use strict";
|
|
48569
|
-
init_define_VTX_EXO_POLICY();
|
|
48570
|
-
init_define_VTX_GROK_POLICY();
|
|
48571
|
-
init_define_VTX_PI_MODEL_POLICY();
|
|
48572
|
-
init_abort();
|
|
48573
|
-
REDACTED_VALUE = "[REDACTED]";
|
|
48574
|
-
SECRET_QUERY_PARAM_PATTERN = /([?&](?:access_token|api(?:_|-)?key|auth|authorization|key|private_key|secret|sig|signature|token)=)[^&#\s]*/gi;
|
|
48575
|
-
BEARER_TOKEN_PATTERN = /\b(Bearer)\s+[A-Za-z0-9._:-]+\b/gi;
|
|
48576
|
-
SECRET_ASSIGNMENT_PATTERN = /((?:authorization\s*[:=]\s*['"]?Bearer\s+|x-api-key\s*[:=]\s*['"]?|api(?:_|-)?key\s*[:=]\s*['"]?|\bkey\s*[:=]\s*['"]?|token\s*[:=]\s*['"]?|secret\s*[:=]\s*['"]?))[^'"\s,}]+/gi;
|
|
48577
|
-
SECRET_KEYWORD_VALUE_PATTERN = /((?:private(?:_|-|\s)?key|signing(?:_|-|\s)?key)\s*[:=]\s*['"]?)(0x[a-fA-F0-9]{64}|[^'"\s,}]+)/gi;
|
|
48578
|
-
OPENAI_STYLE_KEY_PATTERN = /\bsk-[A-Za-z0-9._-]+\b/g;
|
|
48579
|
-
VERTEX_EXPRESS_KEY_PATTERN = /\bAQ\.[A-Za-z0-9._-]+\b/g;
|
|
48580
|
-
sanitizeRuntimeDiagnosticValue = (value) => {
|
|
48581
|
-
const normalized = String(value || "");
|
|
48582
|
-
if (!normalized) {
|
|
48583
|
-
return normalized;
|
|
48584
|
-
}
|
|
48585
|
-
return normalized.replace(SECRET_QUERY_PARAM_PATTERN, `$1${REDACTED_VALUE}`).replace(BEARER_TOKEN_PATTERN, `$1 ${REDACTED_VALUE}`).replace(SECRET_ASSIGNMENT_PATTERN, `$1${REDACTED_VALUE}`).replace(SECRET_KEYWORD_VALUE_PATTERN, `$1${REDACTED_VALUE}`).replace(OPENAI_STYLE_KEY_PATTERN, REDACTED_VALUE).replace(VERTEX_EXPRESS_KEY_PATTERN, REDACTED_VALUE);
|
|
48586
|
-
};
|
|
48587
|
-
sanitizeRuntimeNetworkPath = (value) => {
|
|
48588
|
-
const normalized = String(value || "").trim();
|
|
48589
|
-
if (!normalized) {
|
|
48590
|
-
return "/";
|
|
48591
|
-
}
|
|
48592
|
-
const withoutFragment = normalized.split("#", 1)[0] || normalized;
|
|
48593
|
-
const withoutQuery = withoutFragment.split("?", 1)[0] || withoutFragment;
|
|
48594
|
-
const sanitized = sanitizeRuntimeDiagnosticValue(withoutQuery.trim());
|
|
48595
|
-
return sanitized || "/";
|
|
48596
|
-
};
|
|
48597
|
-
getSanitizedRuntimeErrorMessage = (error48) => {
|
|
48598
|
-
const message = error48 instanceof Error ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
|
|
48599
|
-
if (message == null) {
|
|
48600
|
-
return null;
|
|
48601
|
-
}
|
|
48602
|
-
return sanitizeRuntimeDiagnosticValue(message);
|
|
48603
|
-
};
|
|
48604
|
-
toSanitizedRuntimeError = (error48) => {
|
|
48605
|
-
const message = getSanitizedRuntimeErrorMessage(error48) || "Unknown runtime error.";
|
|
48606
|
-
if (error48 instanceof Error && error48.message === message) {
|
|
48607
|
-
if (isAbortLikeError(error48) && error48.name !== "AbortError") {
|
|
48608
|
-
error48.name = "AbortError";
|
|
48609
|
-
}
|
|
48610
|
-
return error48;
|
|
48611
|
-
}
|
|
48612
|
-
const sanitized = new Error(message);
|
|
48613
|
-
if (isAbortLikeError(error48)) {
|
|
48614
|
-
sanitized.name = "AbortError";
|
|
48615
|
-
} else if (error48 instanceof Error && error48.name) {
|
|
48616
|
-
sanitized.name = error48.name;
|
|
48617
|
-
}
|
|
48618
|
-
return sanitized;
|
|
48619
|
-
};
|
|
48620
|
-
}
|
|
48621
|
-
});
|
|
48622
|
-
|
|
48623
49055
|
// lib/runtime/channel-sender.ts
|
|
48624
49056
|
var RUNTIME_TAB_ID_STORAGE_KEY, createRuntimeUuid, getOrCreateRuntimeTabSenderId;
|
|
48625
49057
|
var init_channel_sender = __esm({
|
|
@@ -49092,6 +49524,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
49092
49524
|
init_define_VTX_EXO_POLICY();
|
|
49093
49525
|
init_define_VTX_GROK_POLICY();
|
|
49094
49526
|
init_define_VTX_PI_MODEL_POLICY();
|
|
49527
|
+
init_hyperliquid_public_read();
|
|
49095
49528
|
init_sort_utils();
|
|
49096
49529
|
init_hyperliquid_account_contract();
|
|
49097
49530
|
init_hyperliquid_active_asset_contract();
|
|
@@ -49841,40 +50274,14 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
49841
50274
|
}
|
|
49842
50275
|
return true;
|
|
49843
50276
|
};
|
|
49844
|
-
fetchHyperliquidInfoPayload = async (apiUrl, body, signal) => {
|
|
49845
|
-
const
|
|
49846
|
-
const requestType = String(body?.type || "info").trim() || "info";
|
|
49847
|
-
const trace = startRuntimeNetworkDebugTrace({
|
|
49848
|
-
kind: "exchange",
|
|
49849
|
-
label: `hyperliquid_info:${requestType}`,
|
|
49850
|
-
method: "POST",
|
|
49851
|
-
url: requestUrl,
|
|
49852
|
-
note: `type=${requestType}`
|
|
49853
|
-
});
|
|
49854
|
-
let response = null;
|
|
50277
|
+
fetchHyperliquidInfoPayload = async (apiUrl, body, signal, reservation) => {
|
|
50278
|
+
const trace = startRuntimeNetworkDebugTrace({ kind: "exchange", label: `hyperliquid_info:${String(body.type)}`, method: "POST", url: `${apiUrl.replace(/\/$/, "")}/info` });
|
|
49855
50279
|
try {
|
|
49856
|
-
|
|
49857
|
-
|
|
49858
|
-
|
|
49859
|
-
"Content-Type": "application/json"
|
|
49860
|
-
},
|
|
49861
|
-
body: JSON.stringify(body),
|
|
49862
|
-
signal
|
|
49863
|
-
});
|
|
49864
|
-
const payload = await response.json().catch(() => ({}));
|
|
49865
|
-
if (!response.ok) {
|
|
49866
|
-
const responseDetail = typeof payload?.response === "string" ? payload.response : typeof payload?.detail === "string" ? payload.detail : "";
|
|
49867
|
-
const detail = response.status === 429 ? `Hyperliquid info request failed (${response.status}) request_type=${requestType}.${responseDetail ? ` ${responseDetail}` : ""}` : responseDetail || `Hyperliquid info request failed (${response.status}) request_type=${requestType}.`;
|
|
49868
|
-
const requestError = new Error(detail);
|
|
49869
|
-
requestError.status = response.status;
|
|
49870
|
-
requestError.detail = detail;
|
|
49871
|
-
requestError.requestType = requestType;
|
|
49872
|
-
throw requestError;
|
|
49873
|
-
}
|
|
49874
|
-
trace.completeSuccess(response.status);
|
|
49875
|
-
return payload;
|
|
50280
|
+
const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation });
|
|
50281
|
+
trace.completeSuccess(200);
|
|
50282
|
+
return result2.payload;
|
|
49876
50283
|
} catch (error48) {
|
|
49877
|
-
trace.completeError(error48,
|
|
50284
|
+
trace.completeError(error48, error48?.status ?? null);
|
|
49878
50285
|
throw error48;
|
|
49879
50286
|
}
|
|
49880
50287
|
};
|
|
@@ -50009,11 +50416,58 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50009
50416
|
dexNames,
|
|
50010
50417
|
staleIf429MaxAgeMs
|
|
50011
50418
|
}) => {
|
|
50419
|
+
const userFeesPromise = input.includeEffectiveTakerRate === true ? (async () => ({
|
|
50420
|
+
...await readHyperliquidPublicInfo(apiUrl, { type: "userFees", user: walletAddress }, { signal: input.signal }).catch((error48) => {
|
|
50421
|
+
if (input.signal?.aborted) throw error48;
|
|
50422
|
+
return { payload: null, fetchedAtMs: Date.now() };
|
|
50423
|
+
}).then((result2) => ({ payload: result2.payload, capturedAt: new Date(result2.fetchedAtMs).toISOString() }))
|
|
50424
|
+
}))() : Promise.resolve(null);
|
|
50425
|
+
const exactAccountModePromise = input.includeExactAccountMode === true ? (async () => {
|
|
50426
|
+
const abstractionRead = await readHyperliquidPublicInfo(apiUrl, { type: "userAbstraction", user: walletAddress }, { signal: input.signal, cacheAccountMode: true });
|
|
50427
|
+
const userAbstraction = abstractionRead.payload;
|
|
50428
|
+
let capturedAtMs = abstractionRead.fetchedAtMs;
|
|
50429
|
+
const preliminaryMode = extractCanonicalHyperliquidAccountMode(userAbstraction);
|
|
50430
|
+
if (!preliminaryMode) {
|
|
50431
|
+
throw new Error("Exact Hyperliquid userAbstraction response is invalid.");
|
|
50432
|
+
}
|
|
50433
|
+
let userDexAbstraction;
|
|
50434
|
+
if (preliminaryMode === "default" || preliminaryMode === "disabled") {
|
|
50435
|
+
const dexRead = await readHyperliquidPublicInfo(apiUrl, { type: "userDexAbstraction", user: walletAddress }, { signal: input.signal, cacheAccountMode: true });
|
|
50436
|
+
userDexAbstraction = dexRead.payload;
|
|
50437
|
+
capturedAtMs = Math.min(capturedAtMs, dexRead.fetchedAtMs);
|
|
50438
|
+
}
|
|
50439
|
+
return {
|
|
50440
|
+
accountMode: resolveExactHyperliquidAccountMode(
|
|
50441
|
+
userAbstraction,
|
|
50442
|
+
userDexAbstraction
|
|
50443
|
+
),
|
|
50444
|
+
capturedAt: new Date(capturedAtMs).toISOString()
|
|
50445
|
+
};
|
|
50446
|
+
})() : Promise.resolve(null);
|
|
50447
|
+
await Promise.all([userFeesPromise, exactAccountModePromise]);
|
|
50448
|
+
const metadataByDex = /* @__PURE__ */ new Map();
|
|
50449
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50450
|
+
await Promise.all(["", ...dexNames].map(async (dex) => {
|
|
50451
|
+
try {
|
|
50452
|
+
metadataByDex.set(dex, await fetchHyperliquidInfoPayload(apiUrl, { type: "meta", ...dex ? { dex } : {} }, input.signal));
|
|
50453
|
+
} catch (error48) {
|
|
50454
|
+
if (input.signal?.aborted) throw error48;
|
|
50455
|
+
metadataByDex.set(dex, null);
|
|
50456
|
+
}
|
|
50457
|
+
}));
|
|
50458
|
+
}
|
|
50459
|
+
const reservation = await reserveHyperliquidPublicReads(apiUrl, [
|
|
50460
|
+
{ type: "clearinghouseState", user: walletAddress },
|
|
50461
|
+
...dexNames.map((dex) => ({ type: "clearinghouseState", user: walletAddress, dex })),
|
|
50462
|
+
{ type: "spotClearinghouseState", user: walletAddress },
|
|
50463
|
+
...input.includeActiveAssetData === false ? [] : activeAssetRequestTypes.map((type) => ({ type, user: walletAddress, coin: symbol2 }))
|
|
50464
|
+
], input.signal);
|
|
50012
50465
|
const perpsPromise = (async () => {
|
|
50013
50466
|
const defaultResponse = await fetchHyperliquidInfoPayload(
|
|
50014
50467
|
apiUrl,
|
|
50015
50468
|
{ type: "clearinghouseState", user: walletAddress },
|
|
50016
|
-
input.signal
|
|
50469
|
+
input.signal,
|
|
50470
|
+
reservation
|
|
50017
50471
|
);
|
|
50018
50472
|
if (input.includeEffectiveTakerRate === true) {
|
|
50019
50473
|
requirePromptClearinghouseState(defaultResponse, "default");
|
|
@@ -50023,7 +50477,8 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50023
50477
|
const response = await fetchHyperliquidInfoPayload(
|
|
50024
50478
|
apiUrl,
|
|
50025
50479
|
{ type: "clearinghouseState", user: walletAddress, dex: dexName },
|
|
50026
|
-
input.signal
|
|
50480
|
+
input.signal,
|
|
50481
|
+
reservation
|
|
50027
50482
|
);
|
|
50028
50483
|
if (input.includeEffectiveTakerRate === true) {
|
|
50029
50484
|
requirePromptClearinghouseState(response, dexName);
|
|
@@ -50058,7 +50513,8 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50058
50513
|
payload = await fetchHyperliquidInfoPayload(
|
|
50059
50514
|
apiUrl,
|
|
50060
50515
|
{ type: "spotClearinghouseState", user: walletAddress },
|
|
50061
|
-
input.signal
|
|
50516
|
+
input.signal,
|
|
50517
|
+
reservation
|
|
50062
50518
|
);
|
|
50063
50519
|
} catch (error48) {
|
|
50064
50520
|
recordInfoRateLimitCooldownFromError(apiUrl, error48, staleIf429MaxAgeMs);
|
|
@@ -50076,12 +50532,14 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50076
50532
|
const payload = await fetchHyperliquidInfoPayload(
|
|
50077
50533
|
apiUrl,
|
|
50078
50534
|
{ type: typeName, user: walletAddress, coin: symbol2 },
|
|
50079
|
-
input.signal
|
|
50535
|
+
input.signal,
|
|
50536
|
+
reservation
|
|
50080
50537
|
);
|
|
50081
50538
|
return { payload, type: typeName };
|
|
50082
50539
|
} catch (error48) {
|
|
50083
50540
|
lastError = error48;
|
|
50084
50541
|
recordInfoRateLimitCooldownFromError(apiUrl, error48, staleIf429MaxAgeMs);
|
|
50542
|
+
if (isRateLimitError(error48)) throw error48;
|
|
50085
50543
|
if (typeName === "userActiveAssetData" && isUnsupportedUserActiveAssetError(error48)) {
|
|
50086
50544
|
rememberUnsupportedUserActiveAssetKey(activeAssetCacheKey);
|
|
50087
50545
|
}
|
|
@@ -50089,43 +50547,6 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50089
50547
|
}
|
|
50090
50548
|
throw lastError instanceof Error ? lastError : new Error("Failed to fetch browser active asset data.");
|
|
50091
50549
|
})();
|
|
50092
|
-
const userFeesPromise = input.includeEffectiveTakerRate === true ? (async () => ({
|
|
50093
|
-
payload: await fetchHyperliquidInfoPayload(
|
|
50094
|
-
apiUrl,
|
|
50095
|
-
{ type: "userFees", user: walletAddress },
|
|
50096
|
-
input.signal
|
|
50097
|
-
).catch((error48) => {
|
|
50098
|
-
if (input.signal?.aborted) throw error48;
|
|
50099
|
-
return null;
|
|
50100
|
-
}),
|
|
50101
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
50102
|
-
}))() : Promise.resolve(null);
|
|
50103
|
-
const exactAccountModePromise = input.includeExactAccountMode === true ? (async () => {
|
|
50104
|
-
const userAbstraction = await fetchHyperliquidInfoPayload(
|
|
50105
|
-
apiUrl,
|
|
50106
|
-
{ type: "userAbstraction", user: walletAddress },
|
|
50107
|
-
input.signal
|
|
50108
|
-
);
|
|
50109
|
-
const preliminaryMode = extractCanonicalHyperliquidAccountMode(userAbstraction);
|
|
50110
|
-
if (!preliminaryMode) {
|
|
50111
|
-
throw new Error("Exact Hyperliquid userAbstraction response is invalid.");
|
|
50112
|
-
}
|
|
50113
|
-
let userDexAbstraction;
|
|
50114
|
-
if (preliminaryMode === "default" || preliminaryMode === "disabled") {
|
|
50115
|
-
userDexAbstraction = await fetchHyperliquidInfoPayload(
|
|
50116
|
-
apiUrl,
|
|
50117
|
-
{ type: "userDexAbstraction", user: walletAddress },
|
|
50118
|
-
input.signal
|
|
50119
|
-
);
|
|
50120
|
-
}
|
|
50121
|
-
return {
|
|
50122
|
-
accountMode: resolveExactHyperliquidAccountMode(
|
|
50123
|
-
userAbstraction,
|
|
50124
|
-
userDexAbstraction
|
|
50125
|
-
),
|
|
50126
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
50127
|
-
};
|
|
50128
|
-
})() : Promise.resolve(null);
|
|
50129
50550
|
const [perpsResult, spotResult, activeAssetResult, userFeesResult, exactAccountMode] = await Promise.all([
|
|
50130
50551
|
perpsPromise,
|
|
50131
50552
|
spotPromise,
|
|
@@ -50154,11 +50575,7 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50154
50575
|
const feeDexes = [...new Set(feeSymbols.map(getHyperliquidMarketDex))];
|
|
50155
50576
|
const metadata = await Promise.all(feeDexes.map(async (dex) => {
|
|
50156
50577
|
try {
|
|
50157
|
-
const payload =
|
|
50158
|
-
apiUrl,
|
|
50159
|
-
{ type: "meta", ...dex ? { dex } : {} },
|
|
50160
|
-
input.signal
|
|
50161
|
-
);
|
|
50578
|
+
const payload = metadataByDex.get(dex) ?? null;
|
|
50162
50579
|
return [dex, payload];
|
|
50163
50580
|
} catch (error48) {
|
|
50164
50581
|
if (input.signal?.aborted) throw error48;
|
|
@@ -50845,129 +51262,6 @@ var init_local_breadcrumbs = __esm({
|
|
|
50845
51262
|
}
|
|
50846
51263
|
});
|
|
50847
51264
|
|
|
50848
|
-
// lib/runtime-policy.generated.json
|
|
50849
|
-
var runtime_policy_generated_default2;
|
|
50850
|
-
var init_runtime_policy_generated2 = __esm({
|
|
50851
|
-
"lib/runtime-policy.generated.json"() {
|
|
50852
|
-
runtime_policy_generated_default2 = {
|
|
50853
|
-
ui: {
|
|
50854
|
-
performance_defaults: {
|
|
50855
|
-
default_timeframe: "30d"
|
|
50856
|
-
},
|
|
50857
|
-
auth_bootstrap_retry: {
|
|
50858
|
-
max_attempts: 3,
|
|
50859
|
-
jitter_milliseconds: 750,
|
|
50860
|
-
base_delay_milliseconds: 500,
|
|
50861
|
-
min_delay_milliseconds: 250,
|
|
50862
|
-
max_delay_milliseconds: 1e4
|
|
50863
|
-
}
|
|
50864
|
-
},
|
|
50865
|
-
ai_dashboard: {
|
|
50866
|
-
market_news_bounds: {
|
|
50867
|
-
max_items_min: 1,
|
|
50868
|
-
max_items_max: 100,
|
|
50869
|
-
lookback_hours_min: 1,
|
|
50870
|
-
lookback_hours_max: 168,
|
|
50871
|
-
max_items_steps: [
|
|
50872
|
-
1,
|
|
50873
|
-
2,
|
|
50874
|
-
3,
|
|
50875
|
-
4,
|
|
50876
|
-
5,
|
|
50877
|
-
6,
|
|
50878
|
-
7,
|
|
50879
|
-
8,
|
|
50880
|
-
9,
|
|
50881
|
-
10,
|
|
50882
|
-
15,
|
|
50883
|
-
20,
|
|
50884
|
-
25,
|
|
50885
|
-
30,
|
|
50886
|
-
40,
|
|
50887
|
-
50,
|
|
50888
|
-
60,
|
|
50889
|
-
75,
|
|
50890
|
-
90,
|
|
50891
|
-
100
|
|
50892
|
-
],
|
|
50893
|
-
lookback_hours_steps: [
|
|
50894
|
-
1,
|
|
50895
|
-
2,
|
|
50896
|
-
4,
|
|
50897
|
-
8,
|
|
50898
|
-
12,
|
|
50899
|
-
24,
|
|
50900
|
-
48,
|
|
50901
|
-
72,
|
|
50902
|
-
168
|
|
50903
|
-
]
|
|
50904
|
-
}
|
|
50905
|
-
},
|
|
50906
|
-
trading: {
|
|
50907
|
-
engine: {
|
|
50908
|
-
client_runtime: {
|
|
50909
|
-
recovery: {
|
|
50910
|
-
resume_retry_base_delay_ms: 1e3,
|
|
50911
|
-
resume_retry_max_delay_ms: 3e4,
|
|
50912
|
-
transient_load_min_delay_ms: 3e4,
|
|
50913
|
-
transient_load_max_delay_ms: 12e4,
|
|
50914
|
-
rate_limit_buffer_ms: 1e3,
|
|
50915
|
-
rate_limit_max_delay_ms: 3e5,
|
|
50916
|
-
engine_stop_settle_retry_delay_ms: 250,
|
|
50917
|
-
recoverable_reset_settle_retry_delay_ms: 1500,
|
|
50918
|
-
local_ai_preflight_timeout_ms: 3e3,
|
|
50919
|
-
surge_stagger_max_ms: 6e4,
|
|
50920
|
-
surge_stagger_min_ms: 2e3,
|
|
50921
|
-
surge_stagger_min_candidates: 4,
|
|
50922
|
-
stagger_deadline_ttl_ms: 3e5,
|
|
50923
|
-
server_active_reprobe_delay_ms: 6e4,
|
|
50924
|
-
transient_load_jitter_ms: 1e4,
|
|
50925
|
-
cross_host_completed_ttl_ms: 15e3,
|
|
50926
|
-
telemetry_dedupe_ttl_ms: 5e3,
|
|
50927
|
-
browser_presence_heartbeat_interval_ms: 3e4,
|
|
50928
|
-
host_liveness_heartbeat_interval_ms: 3e4,
|
|
50929
|
-
host_liveness_recovery_nudge_ttl_ms: 1e4
|
|
50930
|
-
}
|
|
50931
|
-
}
|
|
50932
|
-
}
|
|
50933
|
-
},
|
|
50934
|
-
external_inference: {
|
|
50935
|
-
service: {
|
|
50936
|
-
update_check_interval_ms: 3e5,
|
|
50937
|
-
update_registry_timeout_ms: 15e3,
|
|
50938
|
-
startup_max_attempts: 40,
|
|
50939
|
-
startup_poll_interval_ms: 250,
|
|
50940
|
-
restart_stable_uptime_ms: 6e4,
|
|
50941
|
-
restart_backoff_base_ms: 1e3,
|
|
50942
|
-
restart_backoff_max_ms: 3e4,
|
|
50943
|
-
restart_exponent_max: 5
|
|
50944
|
-
}
|
|
50945
|
-
},
|
|
50946
|
-
desktop: {
|
|
50947
|
-
runtime_watchdog: {
|
|
50948
|
-
ping_interval_milliseconds: 15e3,
|
|
50949
|
-
telemetry_interval_milliseconds: 3e5
|
|
50950
|
-
}
|
|
50951
|
-
},
|
|
50952
|
-
screener: {
|
|
50953
|
-
resource_scheduler: {
|
|
50954
|
-
client_lock_ttl_milliseconds: 12e4,
|
|
50955
|
-
client_poll_interval_milliseconds: 250
|
|
50956
|
-
}
|
|
50957
|
-
},
|
|
50958
|
-
deployment: {
|
|
50959
|
-
cutover_buffer: {
|
|
50960
|
-
target_timeout_ms: 3e3,
|
|
50961
|
-
retired_timeout_ms: 45e3,
|
|
50962
|
-
max_body_bytes: 33554432,
|
|
50963
|
-
max_inflight: 16,
|
|
50964
|
-
max_queue: 64
|
|
50965
|
-
}
|
|
50966
|
-
}
|
|
50967
|
-
};
|
|
50968
|
-
}
|
|
50969
|
-
});
|
|
50970
|
-
|
|
50971
51265
|
// lib/api/shared.ts
|
|
50972
51266
|
function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
50973
51267
|
const headers = { ...baseHeaders };
|
|
@@ -50975,7 +51269,7 @@ function getProfileHeaders(baseHeaders = {}, explicitProfileId) {
|
|
|
50975
51269
|
if (profileId) headers["x-profile-id"] = profileId.toString();
|
|
50976
51270
|
return headers;
|
|
50977
51271
|
}
|
|
50978
|
-
var getApiUrl, API_URL, sleep2, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, activeProfileId, PROFILE_STORAGE_KEY;
|
|
51272
|
+
var getApiUrl, API_URL, sleep2, AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS, AUTH_BOOTSTRAP_RETRY_JITTER_MS, parseRetryAfterMs2, isTransientNetworkFetchError, createIdempotencyKey, getErrorMessage, getErrorPayloadOrEmpty, getErrorPayloadOrFallbackDetail, getErrorMessageFromResponse, activeProfileId, PROFILE_STORAGE_KEY;
|
|
50979
51273
|
var init_shared = __esm({
|
|
50980
51274
|
"lib/api/shared.ts"() {
|
|
50981
51275
|
"use strict";
|
|
@@ -51015,6 +51309,14 @@ var init_shared = __esm({
|
|
|
51015
51309
|
sleep2 = (ms) => new Promise((resolve12) => setTimeout(resolve12, ms));
|
|
51016
51310
|
AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS = runtime_policy_generated_default2.ui.auth_bootstrap_retry.max_attempts;
|
|
51017
51311
|
AUTH_BOOTSTRAP_RETRY_JITTER_MS = runtime_policy_generated_default2.ui.auth_bootstrap_retry.jitter_milliseconds;
|
|
51312
|
+
parseRetryAfterMs2 = (value) => {
|
|
51313
|
+
if (!value) return null;
|
|
51314
|
+
const seconds = Number(value);
|
|
51315
|
+
if (Number.isFinite(seconds) && seconds >= 0) return Math.round(seconds * 1e3);
|
|
51316
|
+
const retryAtMs = Date.parse(value);
|
|
51317
|
+
if (Number.isFinite(retryAtMs)) return Math.max(0, retryAtMs - Date.now());
|
|
51318
|
+
return null;
|
|
51319
|
+
};
|
|
51018
51320
|
isTransientNetworkFetchError = (error48) => {
|
|
51019
51321
|
const message = error48 instanceof Error ? error48.message : String(error48 || "");
|
|
51020
51322
|
const normalized = message.toLowerCase();
|
|
@@ -51087,13 +51389,21 @@ async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
|
51087
51389
|
const response = await fetch(url2, {
|
|
51088
51390
|
headers: getProfileHeaders({}, options?.profileId),
|
|
51089
51391
|
credentials: "include",
|
|
51090
|
-
cache: "no-store"
|
|
51392
|
+
cache: "no-store",
|
|
51393
|
+
signal: options?.signal
|
|
51091
51394
|
});
|
|
51092
51395
|
if (!response.ok) {
|
|
51093
|
-
|
|
51396
|
+
const summary = `Failed to fetch execution asset metadata: ${response.status} ${response.statusText}`;
|
|
51397
|
+
const detail = await getErrorMessageFromResponse(response, summary);
|
|
51398
|
+
throw new ExecutionAssetMetadataRequestError(
|
|
51399
|
+
detail === summary ? summary : `${summary}: ${detail}`,
|
|
51400
|
+
response.status,
|
|
51401
|
+
parseRetryAfterMs2(response.headers.get("Retry-After"))
|
|
51402
|
+
);
|
|
51094
51403
|
}
|
|
51095
51404
|
return response.json();
|
|
51096
51405
|
}
|
|
51406
|
+
var ExecutionAssetMetadataRequestError;
|
|
51097
51407
|
var init_market_data = __esm({
|
|
51098
51408
|
"lib/api/market-data.ts"() {
|
|
51099
51409
|
"use strict";
|
|
@@ -51103,6 +51413,14 @@ var init_market_data = __esm({
|
|
|
51103
51413
|
init_abort();
|
|
51104
51414
|
init_network_debug();
|
|
51105
51415
|
init_shared();
|
|
51416
|
+
ExecutionAssetMetadataRequestError = class extends Error {
|
|
51417
|
+
constructor(message, status, retryAfterMs) {
|
|
51418
|
+
super(message);
|
|
51419
|
+
this.status = status;
|
|
51420
|
+
this.retryAfterMs = retryAfterMs;
|
|
51421
|
+
this.name = "ExecutionAssetMetadataRequestError";
|
|
51422
|
+
}
|
|
51423
|
+
};
|
|
51106
51424
|
}
|
|
51107
51425
|
});
|
|
51108
51426
|
|
|
@@ -52196,8 +52514,8 @@ var init_api2 = __esm({
|
|
|
52196
52514
|
};
|
|
52197
52515
|
CLIENT_EXCHANGE_AUTHORITY_DEVICE_KEY = "vtx_client_exchange_authority_device_v1";
|
|
52198
52516
|
CLIENT_EXCHANGE_AUTHORITY_SESSION_KEY = "vtx_client_exchange_authority_session_v1";
|
|
52199
|
-
getOrCreateClientExchangeAuthorityIdentity = (
|
|
52200
|
-
const existing = String(
|
|
52517
|
+
getOrCreateClientExchangeAuthorityIdentity = (storage2, key, label) => {
|
|
52518
|
+
const existing = String(storage2.getItem(key) || "").trim().toLowerCase();
|
|
52201
52519
|
if (/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(existing)) {
|
|
52202
52520
|
return existing;
|
|
52203
52521
|
}
|
|
@@ -52205,7 +52523,7 @@ var init_api2 = __esm({
|
|
|
52205
52523
|
if (!generated || !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(generated)) {
|
|
52206
52524
|
throw new Error(`Secure ${label} generation is unavailable.`);
|
|
52207
52525
|
}
|
|
52208
|
-
|
|
52526
|
+
storage2.setItem(key, generated);
|
|
52209
52527
|
return generated;
|
|
52210
52528
|
};
|
|
52211
52529
|
resolveClientExchangeMutationAuthority = (profileId, requiredRuntimeSessionId, explicitRuntimeLeaseToken, explicitRuntimeDeviceId, explicitSchedulerInstanceId) => {
|
|
@@ -53500,7 +53818,7 @@ function unpercent(value) {
|
|
|
53500
53818
|
return String.fromCharCode(parseInt(code, 16));
|
|
53501
53819
|
}));
|
|
53502
53820
|
}
|
|
53503
|
-
function
|
|
53821
|
+
function wait2(delay2) {
|
|
53504
53822
|
return new Promise((resolve12) => setTimeout(resolve12, delay2));
|
|
53505
53823
|
}
|
|
53506
53824
|
var MAX_ATTEMPTS, SLOT_INTERVAL, defaultGetUrlFunc, reData, reIpfs, locked, Gateways, fetchSignals, FetchCancelSignal, FetchRequest, FetchResponse;
|
|
@@ -53863,7 +54181,7 @@ var init_fetch = __esm({
|
|
|
53863
54181
|
request: _request
|
|
53864
54182
|
});
|
|
53865
54183
|
if (delay2 > 0) {
|
|
53866
|
-
await
|
|
54184
|
+
await wait2(delay2);
|
|
53867
54185
|
}
|
|
53868
54186
|
let req = this.clone();
|
|
53869
54187
|
const scheme = (req.url.split(":")[0] || "").toLowerCase();
|
|
@@ -77478,9 +77796,9 @@ var init_provider_socket = __esm({
|
|
|
77478
77796
|
*/
|
|
77479
77797
|
_register(filterId, subscriber) {
|
|
77480
77798
|
this.#subs.set(filterId, subscriber);
|
|
77481
|
-
const
|
|
77482
|
-
if (
|
|
77483
|
-
for (const message of
|
|
77799
|
+
const pending3 = this.#pending.get(filterId);
|
|
77800
|
+
if (pending3) {
|
|
77801
|
+
for (const message of pending3) {
|
|
77484
77802
|
subscriber._handleMessage(message);
|
|
77485
77803
|
}
|
|
77486
77804
|
this.#pending.delete(filterId);
|
|
@@ -77532,12 +77850,12 @@ var init_provider_socket = __esm({
|
|
|
77532
77850
|
if (subscriber) {
|
|
77533
77851
|
subscriber._handleMessage(result2.params.result);
|
|
77534
77852
|
} else {
|
|
77535
|
-
let
|
|
77536
|
-
if (
|
|
77537
|
-
|
|
77538
|
-
this.#pending.set(filterId,
|
|
77853
|
+
let pending3 = this.#pending.get(filterId);
|
|
77854
|
+
if (pending3 == null) {
|
|
77855
|
+
pending3 = [];
|
|
77856
|
+
this.#pending.set(filterId, pending3);
|
|
77539
77857
|
}
|
|
77540
|
-
|
|
77858
|
+
pending3.push(result2.params.result);
|
|
77541
77859
|
}
|
|
77542
77860
|
} else {
|
|
77543
77861
|
this.emit("error", makeError("received unexpected message", "UNKNOWN_ERROR", {
|
|
@@ -83044,6 +83362,7 @@ var init_hyperliquid_client = __esm({
|
|
|
83044
83362
|
init_define_VTX_EXO_POLICY();
|
|
83045
83363
|
init_define_VTX_GROK_POLICY();
|
|
83046
83364
|
init_define_VTX_PI_MODEL_POLICY();
|
|
83365
|
+
init_hyperliquid_public_read();
|
|
83047
83366
|
init_api2();
|
|
83048
83367
|
init_abort();
|
|
83049
83368
|
init_hyperliquid_market_symbol();
|
|
@@ -83128,11 +83447,11 @@ var init_hyperliquid_client = __esm({
|
|
|
83128
83447
|
return 0;
|
|
83129
83448
|
}
|
|
83130
83449
|
try {
|
|
83131
|
-
const
|
|
83132
|
-
if (!
|
|
83450
|
+
const storage2 = window.localStorage;
|
|
83451
|
+
if (!storage2) {
|
|
83133
83452
|
return 0;
|
|
83134
83453
|
}
|
|
83135
|
-
const parsed = Number.parseInt(
|
|
83454
|
+
const parsed = Number.parseInt(storage2.getItem(HYPERLIQUID_NONCE_STORAGE_KEY) || "0", 10);
|
|
83136
83455
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
|
83137
83456
|
} catch {
|
|
83138
83457
|
return 0;
|
|
@@ -83143,11 +83462,11 @@ var init_hyperliquid_client = __esm({
|
|
|
83143
83462
|
return;
|
|
83144
83463
|
}
|
|
83145
83464
|
try {
|
|
83146
|
-
const
|
|
83147
|
-
if (!
|
|
83465
|
+
const storage2 = window.localStorage;
|
|
83466
|
+
if (!storage2) {
|
|
83148
83467
|
return;
|
|
83149
83468
|
}
|
|
83150
|
-
|
|
83469
|
+
storage2.setItem(HYPERLIQUID_NONCE_STORAGE_KEY, String(nonce));
|
|
83151
83470
|
} catch {
|
|
83152
83471
|
}
|
|
83153
83472
|
};
|
|
@@ -83310,27 +83629,13 @@ var init_hyperliquid_client = __esm({
|
|
|
83310
83629
|
method: "POST",
|
|
83311
83630
|
url: requestUrl
|
|
83312
83631
|
});
|
|
83313
|
-
let response = null;
|
|
83314
83632
|
try {
|
|
83315
|
-
|
|
83316
|
-
|
|
83317
|
-
headers: {
|
|
83318
|
-
"Content-Type": "application/json"
|
|
83319
|
-
},
|
|
83320
|
-
body: JSON.stringify(body),
|
|
83321
|
-
signal: input.signal
|
|
83322
|
-
});
|
|
83323
|
-
const payload = await response.json().catch(() => ({}));
|
|
83324
|
-
if (!response.ok) {
|
|
83325
|
-
throw new Error(sanitizeRuntimeDiagnosticValue(
|
|
83326
|
-
typeof payload?.response === "string" ? String(payload.response) : typeof payload?.detail === "string" ? String(payload.detail) : `Hyperliquid ${label} request failed.`
|
|
83327
|
-
));
|
|
83328
|
-
}
|
|
83329
|
-
trace.completeSuccess(response.status);
|
|
83633
|
+
const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal });
|
|
83634
|
+
trace.completeSuccess(200);
|
|
83330
83635
|
return payload;
|
|
83331
83636
|
} catch (error48) {
|
|
83332
83637
|
const sanitizedError = toSanitizedRuntimeError(error48);
|
|
83333
|
-
trace.completeError(sanitizedError,
|
|
83638
|
+
trace.completeError(sanitizedError, error48?.status ?? null);
|
|
83334
83639
|
throw sanitizedError;
|
|
83335
83640
|
}
|
|
83336
83641
|
};
|
|
@@ -83764,11 +84069,11 @@ var init_hyperliquid_client = __esm({
|
|
|
83764
84069
|
ancestors: /* @__PURE__ */ new Set()
|
|
83765
84070
|
}));
|
|
83766
84071
|
while (pendingOrders.length > 0) {
|
|
83767
|
-
const
|
|
83768
|
-
if (
|
|
84072
|
+
const pending3 = pendingOrders.shift();
|
|
84073
|
+
if (pending3 == null) {
|
|
83769
84074
|
break;
|
|
83770
84075
|
}
|
|
83771
|
-
const { raw, inheritedCoin, depth, ancestors } =
|
|
84076
|
+
const { raw, inheritedCoin, depth, ancestors } = pending3;
|
|
83772
84077
|
if (raw == null || typeof raw !== "object" || Array.isArray(raw)) {
|
|
83773
84078
|
throw new Error("Malformed Hyperliquid frontendOpenOrders member.");
|
|
83774
84079
|
}
|
|
@@ -84548,12 +84853,12 @@ var init_hyperliquid_client = __esm({
|
|
|
84548
84853
|
};
|
|
84549
84854
|
};
|
|
84550
84855
|
loadClientExecutionReferenceEvidence = async (input, executionObservabilityDeadlineMs) => {
|
|
84551
|
-
const
|
|
84552
|
-
if (
|
|
84856
|
+
const policy2 = input.config?.client_runtime_execution_observability;
|
|
84857
|
+
if (policy2?.enabled !== true || policy2.fresh_l2_fallback_enabled !== true || !input.durableMutation) {
|
|
84553
84858
|
return null;
|
|
84554
84859
|
}
|
|
84555
|
-
const timeoutMs = Number(
|
|
84556
|
-
const acceptableAgeMs = Number(
|
|
84860
|
+
const timeoutMs = Number(policy2.snapshot_timeout_ms);
|
|
84861
|
+
const acceptableAgeMs = Number(policy2.acceptable_snapshot_age_ms);
|
|
84557
84862
|
if (!Number.isInteger(timeoutMs) || timeoutMs <= 0 || !Number.isInteger(acceptableAgeMs) || acceptableAgeMs < 0) {
|
|
84558
84863
|
return { referenceSourceKind: "policy_unavailable" };
|
|
84559
84864
|
}
|
|
@@ -85243,7 +85548,7 @@ function validateDeviceSecrets(value, options) {
|
|
|
85243
85548
|
return [provider, slots];
|
|
85244
85549
|
}).filter(([, slots]) => slots.some(Boolean))
|
|
85245
85550
|
);
|
|
85246
|
-
const
|
|
85551
|
+
const storage2 = normalizeDeviceSecretStorage(record5.storage);
|
|
85247
85552
|
const hyperliquidSigningKey = typeof record5.hyperliquidSigningKey === "string" ? record5.hyperliquidSigningKey.trim() || void 0 : void 0;
|
|
85248
85553
|
const rawLocalAi = record5.localAi && typeof record5.localAi === "object" ? record5.localAi : {};
|
|
85249
85554
|
const localAi = normalizeLocalAiSecrets({
|
|
@@ -85295,7 +85600,7 @@ function validateDeviceSecrets(value, options) {
|
|
|
85295
85600
|
...Object.keys(providerBaseUrlSlots).length > 0 ? { providerBaseUrlSlots } : {},
|
|
85296
85601
|
...localAi ? { localAi } : {},
|
|
85297
85602
|
...openaiCompatible ? { openaiCompatible } : {},
|
|
85298
|
-
storage
|
|
85603
|
+
storage: storage2
|
|
85299
85604
|
},
|
|
85300
85605
|
activeProvider,
|
|
85301
85606
|
hasHyperliquidSigningKey,
|
|
@@ -85545,8 +85850,8 @@ var init_vault = __esm({
|
|
|
85545
85850
|
mergeHydratedSecrets = (existingLocalSecrets, remoteSecrets, options) => {
|
|
85546
85851
|
const localNormalized = validateDeviceSecrets(existingLocalSecrets, options).normalized;
|
|
85547
85852
|
const remoteNormalized = validateDeviceSecrets(remoteSecrets, options).normalized;
|
|
85548
|
-
const
|
|
85549
|
-
const mergedLocalAi =
|
|
85853
|
+
const storage2 = normalizeDeviceSecretStorage(localNormalized?.storage ?? remoteNormalized?.storage);
|
|
85854
|
+
const mergedLocalAi = storage2.byok === "device" ? normalizeLocalAiSecrets({
|
|
85550
85855
|
baseUrl: localNormalized?.localAi?.baseUrl,
|
|
85551
85856
|
apiKey: localNormalized?.localAi?.apiKey,
|
|
85552
85857
|
serverType: localNormalized?.localAi?.serverType
|
|
@@ -85555,7 +85860,7 @@ var init_vault = __esm({
|
|
|
85555
85860
|
apiKey: remoteNormalized?.localAi?.apiKey ?? localNormalized?.localAi?.apiKey,
|
|
85556
85861
|
serverType: localNormalized?.localAi?.serverType
|
|
85557
85862
|
});
|
|
85558
|
-
const mergedOpenAiCompatible =
|
|
85863
|
+
const mergedOpenAiCompatible = storage2.byok === "device" ? normalizeOpenAiCompatibleSecrets({
|
|
85559
85864
|
baseUrl: localNormalized?.openaiCompatible?.baseUrl,
|
|
85560
85865
|
apiKey: localNormalized?.openaiCompatible?.apiKey
|
|
85561
85866
|
}) : normalizeOpenAiCompatibleSecrets({
|
|
@@ -85563,14 +85868,14 @@ var init_vault = __esm({
|
|
|
85563
85868
|
apiKey: remoteNormalized?.openaiCompatible?.apiKey ?? localNormalized?.openaiCompatible?.apiKey
|
|
85564
85869
|
});
|
|
85565
85870
|
return validateDeviceSecrets({
|
|
85566
|
-
hyperliquidSigningKey:
|
|
85567
|
-
providerKeys:
|
|
85568
|
-
providerKeySlots:
|
|
85569
|
-
providerBaseUrls:
|
|
85570
|
-
providerBaseUrlSlots:
|
|
85871
|
+
hyperliquidSigningKey: storage2.hyperliquid === "device" ? localNormalized?.hyperliquidSigningKey : remoteNormalized?.hyperliquidSigningKey,
|
|
85872
|
+
providerKeys: storage2.byok === "device" ? { ...localNormalized?.providerKeys ?? {} } : { ...remoteNormalized?.providerKeys ?? {} },
|
|
85873
|
+
providerKeySlots: storage2.byok === "device" ? { ...localNormalized?.providerKeySlots ?? {} } : { ...remoteNormalized?.providerKeySlots ?? {} },
|
|
85874
|
+
providerBaseUrls: storage2.byok === "device" ? { ...localNormalized?.providerBaseUrls ?? {} } : { ...remoteNormalized?.providerBaseUrls ?? {} },
|
|
85875
|
+
providerBaseUrlSlots: storage2.byok === "device" ? { ...localNormalized?.providerBaseUrlSlots ?? {} } : { ...remoteNormalized?.providerBaseUrlSlots ?? {} },
|
|
85571
85876
|
...mergedLocalAi ? { localAi: mergedLocalAi } : {},
|
|
85572
85877
|
...mergedOpenAiCompatible ? { openaiCompatible: mergedOpenAiCompatible } : {},
|
|
85573
|
-
storage
|
|
85878
|
+
storage: storage2
|
|
85574
85879
|
}, options).normalized;
|
|
85575
85880
|
};
|
|
85576
85881
|
preserveDeviceOnlySecrets = (value, options) => {
|
|
@@ -85578,18 +85883,18 @@ var init_vault = __esm({
|
|
|
85578
85883
|
if (!normalized) {
|
|
85579
85884
|
return null;
|
|
85580
85885
|
}
|
|
85581
|
-
const
|
|
85582
|
-
const localAi =
|
|
85583
|
-
const openaiCompatible =
|
|
85886
|
+
const storage2 = normalizeDeviceSecretStorage(normalized.storage);
|
|
85887
|
+
const localAi = storage2.byok === "device" ? normalizeLocalAiSecrets(normalized.localAi) : normalizeLocalAiSecrets({ apiKey: normalized.localAi?.apiKey, serverType: normalized.localAi?.serverType });
|
|
85888
|
+
const openaiCompatible = storage2.byok === "device" ? normalizeOpenAiCompatibleSecrets(normalized.openaiCompatible) : normalizeOpenAiCompatibleSecrets({ apiKey: normalized.openaiCompatible?.apiKey });
|
|
85584
85889
|
return validateDeviceSecrets({
|
|
85585
|
-
hyperliquidSigningKey:
|
|
85586
|
-
providerKeys:
|
|
85587
|
-
providerKeySlots:
|
|
85588
|
-
providerBaseUrls:
|
|
85589
|
-
providerBaseUrlSlots:
|
|
85890
|
+
hyperliquidSigningKey: storage2.hyperliquid === "device" ? normalized.hyperliquidSigningKey : void 0,
|
|
85891
|
+
providerKeys: storage2.byok === "device" ? { ...normalized.providerKeys } : {},
|
|
85892
|
+
providerKeySlots: storage2.byok === "device" ? { ...normalized.providerKeySlots ?? {} } : {},
|
|
85893
|
+
providerBaseUrls: storage2.byok === "device" ? { ...normalized.providerBaseUrls ?? {} } : {},
|
|
85894
|
+
providerBaseUrlSlots: storage2.byok === "device" ? { ...normalized.providerBaseUrlSlots ?? {} } : {},
|
|
85590
85895
|
...localAi ? { localAi } : {},
|
|
85591
85896
|
...openaiCompatible ? { openaiCompatible } : {},
|
|
85592
|
-
storage
|
|
85897
|
+
storage: storage2
|
|
85593
85898
|
}, options).normalized;
|
|
85594
85899
|
};
|
|
85595
85900
|
normalizeClientRuntimeSecretProvider = (value) => {
|
|
@@ -86562,9 +86867,9 @@ var init_runtime_execution = __esm({
|
|
|
86562
86867
|
return null;
|
|
86563
86868
|
}
|
|
86564
86869
|
};
|
|
86565
|
-
setClientRuntimeProtectionStorage = (
|
|
86566
|
-
if (clientRuntimeProtectionStorage ===
|
|
86567
|
-
clientRuntimeProtectionStorage =
|
|
86870
|
+
setClientRuntimeProtectionStorage = (storage2) => {
|
|
86871
|
+
if (clientRuntimeProtectionStorage === storage2) return;
|
|
86872
|
+
clientRuntimeProtectionStorage = storage2;
|
|
86568
86873
|
trailingStopMemory.clear();
|
|
86569
86874
|
protectiveGroupMemory.clear();
|
|
86570
86875
|
protectiveGroupReadFailures.clear();
|
|
@@ -86575,10 +86880,10 @@ var init_runtime_execution = __esm({
|
|
|
86575
86880
|
const key = trailingStopStorageKey(profileId, symbol2);
|
|
86576
86881
|
const inMemory = trailingStopMemory.get(key);
|
|
86577
86882
|
let raw = inMemory ?? [];
|
|
86578
|
-
const
|
|
86579
|
-
if (inMemory === void 0 &&
|
|
86883
|
+
const storage2 = resolveClientRuntimeProtectionStorage();
|
|
86884
|
+
if (inMemory === void 0 && storage2) {
|
|
86580
86885
|
try {
|
|
86581
|
-
const persisted =
|
|
86886
|
+
const persisted = storage2.getItem(key);
|
|
86582
86887
|
if (persisted !== null) {
|
|
86583
86888
|
raw = JSON.parse(persisted);
|
|
86584
86889
|
}
|
|
@@ -86612,20 +86917,20 @@ var init_runtime_execution = __esm({
|
|
|
86612
86917
|
const key = trailingStopStorageKey(profileId, symbol2);
|
|
86613
86918
|
if (records.length === 0) {
|
|
86614
86919
|
trailingStopMemory.set(key, []);
|
|
86615
|
-
const
|
|
86616
|
-
if (
|
|
86920
|
+
const storage3 = resolveClientRuntimeProtectionStorage();
|
|
86921
|
+
if (storage3) {
|
|
86617
86922
|
try {
|
|
86618
|
-
|
|
86923
|
+
storage3.removeItem(key);
|
|
86619
86924
|
} catch {
|
|
86620
86925
|
}
|
|
86621
86926
|
}
|
|
86622
86927
|
return;
|
|
86623
86928
|
}
|
|
86624
86929
|
trailingStopMemory.set(key, records);
|
|
86625
|
-
const
|
|
86626
|
-
if (
|
|
86930
|
+
const storage2 = resolveClientRuntimeProtectionStorage();
|
|
86931
|
+
if (storage2) {
|
|
86627
86932
|
try {
|
|
86628
|
-
|
|
86933
|
+
storage2.setItem(key, JSON.stringify(records));
|
|
86629
86934
|
} catch {
|
|
86630
86935
|
}
|
|
86631
86936
|
}
|
|
@@ -86642,10 +86947,10 @@ var init_runtime_execution = __esm({
|
|
|
86642
86947
|
const key = protectiveGroupStorageKey(profileId, symbol2);
|
|
86643
86948
|
const inMemory = protectiveGroupMemory.get(key);
|
|
86644
86949
|
let raw = inMemory ?? [];
|
|
86645
|
-
const
|
|
86646
|
-
if (inMemory === void 0 &&
|
|
86950
|
+
const storage2 = resolveClientRuntimeProtectionStorage();
|
|
86951
|
+
if (inMemory === void 0 && storage2) {
|
|
86647
86952
|
try {
|
|
86648
|
-
const persisted =
|
|
86953
|
+
const persisted = storage2.getItem(key);
|
|
86649
86954
|
if (persisted !== null) {
|
|
86650
86955
|
raw = JSON.parse(persisted);
|
|
86651
86956
|
}
|
|
@@ -86693,12 +86998,12 @@ var init_runtime_execution = __esm({
|
|
|
86693
86998
|
protectiveGroupReadFailures.add(key);
|
|
86694
86999
|
return [];
|
|
86695
87000
|
}
|
|
86696
|
-
const
|
|
86697
|
-
const mutationId = String(
|
|
86698
|
-
const clientOrderId = String(
|
|
86699
|
-
const previousOrderId = Number(
|
|
86700
|
-
const replacementTriggerPrice = Number(
|
|
86701
|
-
const replacementSize = Number(
|
|
87001
|
+
const pending3 = replacementRecord;
|
|
87002
|
+
const mutationId = String(pending3.mutationId ?? "").trim().toLowerCase();
|
|
87003
|
+
const clientOrderId = String(pending3.clientOrderId ?? "").trim().toLowerCase();
|
|
87004
|
+
const previousOrderId = Number(pending3.previousOrderId);
|
|
87005
|
+
const replacementTriggerPrice = Number(pending3.triggerPrice);
|
|
87006
|
+
const replacementSize = Number(pending3.size);
|
|
86702
87007
|
if (!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(mutationId) || clientOrderId !== `0x${mutationId.replaceAll("-", "")}` || !Number.isSafeInteger(previousOrderId) || previousOrderId <= 0 || previousOrderId !== orderId || !Number.isFinite(replacementTriggerPrice) || replacementTriggerPrice <= 0 || !Number.isFinite(replacementSize) || replacementSize <= 0) {
|
|
86703
87008
|
protectiveGroupReadFailures.add(key);
|
|
86704
87009
|
return [];
|
|
@@ -86728,10 +87033,10 @@ var init_runtime_execution = __esm({
|
|
|
86728
87033
|
protectiveGroupReadFailures.add(key);
|
|
86729
87034
|
return [];
|
|
86730
87035
|
}
|
|
86731
|
-
const
|
|
86732
|
-
const stopLoss =
|
|
86733
|
-
const takeProfit =
|
|
86734
|
-
if (typeof
|
|
87036
|
+
const pending3 = pendingRecord;
|
|
87037
|
+
const stopLoss = pending3.stopLoss;
|
|
87038
|
+
const takeProfit = pending3.takeProfit;
|
|
87039
|
+
if (typeof pending3.entryMutationId !== "string" || !/^[0-9a-f-]{36}$/.test(pending3.entryMutationId) || typeof pending3.entryClientOrderId !== "string" || !/^0x[0-9a-f]{32}$/.test(pending3.entryClientOrderId) || pending3.entrySide !== "buy" && pending3.entrySide !== "sell" || !Number.isFinite(Number(pending3.requestedSize)) || Number(pending3.requestedSize) <= 0 || stopLoss == null || typeof stopLoss !== "object" || Array.isArray(stopLoss) || takeProfit == null || typeof takeProfit !== "object" || Array.isArray(takeProfit)) {
|
|
86735
87040
|
protectiveGroupReadFailures.add(key);
|
|
86736
87041
|
return [];
|
|
86737
87042
|
}
|
|
@@ -86742,10 +87047,10 @@ var init_runtime_execution = __esm({
|
|
|
86742
87047
|
return [];
|
|
86743
87048
|
}
|
|
86744
87049
|
pendingEntry = {
|
|
86745
|
-
entryMutationId:
|
|
86746
|
-
entryClientOrderId:
|
|
86747
|
-
entrySide:
|
|
86748
|
-
requestedSize: Number(
|
|
87050
|
+
entryMutationId: pending3.entryMutationId,
|
|
87051
|
+
entryClientOrderId: pending3.entryClientOrderId,
|
|
87052
|
+
entrySide: pending3.entrySide,
|
|
87053
|
+
requestedSize: Number(pending3.requestedSize),
|
|
86749
87054
|
stopLoss: {
|
|
86750
87055
|
enabled: sl.enabled,
|
|
86751
87056
|
mode: sl.mode,
|
|
@@ -86832,16 +87137,16 @@ var init_runtime_execution = __esm({
|
|
|
86832
87137
|
};
|
|
86833
87138
|
writeClientProtectiveGroups = (profileId, symbol2, groups) => {
|
|
86834
87139
|
const key = protectiveGroupStorageKey(profileId, symbol2);
|
|
86835
|
-
const
|
|
86836
|
-
if (!
|
|
87140
|
+
const storage2 = resolveClientRuntimeProtectionStorage();
|
|
87141
|
+
if (!storage2) {
|
|
86837
87142
|
protectiveGroupMemory.delete(key);
|
|
86838
87143
|
protectiveGroupReadFailures.add(key);
|
|
86839
87144
|
return false;
|
|
86840
87145
|
}
|
|
86841
87146
|
try {
|
|
86842
87147
|
if (groups.length === 0) {
|
|
86843
|
-
|
|
86844
|
-
const removed =
|
|
87148
|
+
storage2.removeItem(key);
|
|
87149
|
+
const removed = storage2.getItem(key) === null;
|
|
86845
87150
|
if (removed) {
|
|
86846
87151
|
protectiveGroupMemory.set(key, []);
|
|
86847
87152
|
protectiveGroupReadFailures.delete(key);
|
|
@@ -86849,8 +87154,8 @@ var init_runtime_execution = __esm({
|
|
|
86849
87154
|
return removed;
|
|
86850
87155
|
} else {
|
|
86851
87156
|
const serialized = JSON.stringify(groups);
|
|
86852
|
-
|
|
86853
|
-
const persisted =
|
|
87157
|
+
storage2.setItem(key, serialized);
|
|
87158
|
+
const persisted = storage2.getItem(key) === serialized;
|
|
86854
87159
|
if (persisted) {
|
|
86855
87160
|
protectiveGroupMemory.set(key, groups);
|
|
86856
87161
|
protectiveGroupReadFailures.delete(key);
|
|
@@ -87078,18 +87383,18 @@ var init_runtime_execution = __esm({
|
|
|
87078
87383
|
throw createClientRuntimeWindowHandoffBeforePlanDispatchError(cleanup);
|
|
87079
87384
|
};
|
|
87080
87385
|
canPersistClientProtectiveGroups = (profileId, symbol2) => {
|
|
87081
|
-
const
|
|
87082
|
-
if (!
|
|
87386
|
+
const storage2 = resolveClientRuntimeProtectionStorage();
|
|
87387
|
+
if (!storage2) return false;
|
|
87083
87388
|
const probeKey = `${protectiveGroupStorageKey(profileId, symbol2)}:probe`;
|
|
87084
87389
|
const probeValue = `${Date.now()}:${Math.random()}`;
|
|
87085
87390
|
try {
|
|
87086
|
-
|
|
87087
|
-
const durable =
|
|
87088
|
-
|
|
87391
|
+
storage2.setItem(probeKey, probeValue);
|
|
87392
|
+
const durable = storage2.getItem(probeKey) === probeValue;
|
|
87393
|
+
storage2.removeItem(probeKey);
|
|
87089
87394
|
return durable;
|
|
87090
87395
|
} catch {
|
|
87091
87396
|
try {
|
|
87092
|
-
|
|
87397
|
+
storage2.removeItem(probeKey);
|
|
87093
87398
|
} catch {
|
|
87094
87399
|
}
|
|
87095
87400
|
return false;
|