@vtxmacro/cli 2026.9.41 → 2026.9.42
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 +4 -1
- package/bin/vtx.js +469 -363
- 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.42",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.153.3",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -4196,8 +4196,8 @@ var init_az = __esm({
|
|
|
4196
4196
|
});
|
|
4197
4197
|
|
|
4198
4198
|
// node_modules/zod/v4/locales/be.js
|
|
4199
|
-
function getBelarusianPlural(
|
|
4200
|
-
const absCount = Math.abs(
|
|
4199
|
+
function getBelarusianPlural(count4, one, few, many) {
|
|
4200
|
+
const absCount = Math.abs(count4);
|
|
4201
4201
|
const lastDigit = absCount % 10;
|
|
4202
4202
|
const lastTwoDigits = absCount % 100;
|
|
4203
4203
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -6156,8 +6156,8 @@ var init_hu = __esm({
|
|
|
6156
6156
|
});
|
|
6157
6157
|
|
|
6158
6158
|
// node_modules/zod/v4/locales/hy.js
|
|
6159
|
-
function getArmenianPlural(
|
|
6160
|
-
return Math.abs(
|
|
6159
|
+
function getArmenianPlural(count4, one, many) {
|
|
6160
|
+
return Math.abs(count4) === 1 ? one : many;
|
|
6161
6161
|
}
|
|
6162
6162
|
function withDefiniteArticle(word) {
|
|
6163
6163
|
if (!word)
|
|
@@ -8326,8 +8326,8 @@ var init_pt = __esm({
|
|
|
8326
8326
|
});
|
|
8327
8327
|
|
|
8328
8328
|
// node_modules/zod/v4/locales/ru.js
|
|
8329
|
-
function getRussianPlural(
|
|
8330
|
-
const absCount = Math.abs(
|
|
8329
|
+
function getRussianPlural(count4, one, few, many) {
|
|
8330
|
+
const absCount = Math.abs(count4);
|
|
8331
8331
|
const lastDigit = absCount % 10;
|
|
8332
8332
|
const lastTwoDigits = absCount % 100;
|
|
8333
8333
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
|
|
@@ -17682,17 +17682,17 @@ async function readInferenceHostCredentialContextTransition(config2) {
|
|
|
17682
17682
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17683
17683
|
throw new Error("Inference host credential context transition is invalid.");
|
|
17684
17684
|
}
|
|
17685
|
-
const
|
|
17685
|
+
const record5 = value;
|
|
17686
17686
|
const expectedKeys = ["schema_version", "operation", "phase", "previous", "candidate"];
|
|
17687
|
-
if (Object.keys(
|
|
17687
|
+
if (Object.keys(record5).sort().join("\0") !== expectedKeys.sort().join("\0") || record5.schema_version !== "vtx_inference_credential_context_transition_v1" || record5.operation !== "selection" && record5.operation !== "cleanup" || record5.phase !== "prepared" && record5.phase !== "committed") {
|
|
17688
17688
|
throw new Error("Inference host credential context transition is invalid.");
|
|
17689
17689
|
}
|
|
17690
17690
|
return {
|
|
17691
17691
|
schema_version: "vtx_inference_credential_context_transition_v1",
|
|
17692
|
-
operation:
|
|
17693
|
-
phase:
|
|
17694
|
-
previous:
|
|
17695
|
-
candidate:
|
|
17692
|
+
operation: record5.operation,
|
|
17693
|
+
phase: record5.phase,
|
|
17694
|
+
previous: record5.previous === null ? null : assertInferenceHostCredentialContext(record5.previous, config2),
|
|
17695
|
+
candidate: record5.candidate === null ? null : assertInferenceHostCredentialContext(record5.candidate, config2)
|
|
17696
17696
|
};
|
|
17697
17697
|
}
|
|
17698
17698
|
async function clearInferenceHostCredentialContextTransition(config2) {
|
|
@@ -17725,26 +17725,26 @@ function assertInferenceHostCredentialContext(value, config2) {
|
|
|
17725
17725
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17726
17726
|
throw new Error("Inference host credential context is invalid.");
|
|
17727
17727
|
}
|
|
17728
|
-
const
|
|
17728
|
+
const record5 = value;
|
|
17729
17729
|
const expectedKeys = [
|
|
17730
17730
|
"schema_version",
|
|
17731
17731
|
"instance_name",
|
|
17732
17732
|
"credential_store_mode",
|
|
17733
17733
|
"credential_file_path"
|
|
17734
17734
|
];
|
|
17735
|
-
if (Object.keys(
|
|
17735
|
+
if (Object.keys(record5).sort().join("\0") !== expectedKeys.sort().join("\0") || record5.schema_version !== "vtx_inference_credential_context_v1" || record5.instance_name !== config2.instanceName || record5.credential_store_mode !== "os" && record5.credential_store_mode !== "file" || (record5.credential_store_mode === "os" ? record5.credential_file_path !== null : typeof record5.credential_file_path !== "string" || !record5.credential_file_path)) {
|
|
17736
17736
|
throw new Error("Inference host credential context is invalid.");
|
|
17737
17737
|
}
|
|
17738
|
-
const credentialFilePath =
|
|
17738
|
+
const credentialFilePath = record5.credential_store_mode === "file" ? requireNamedInstancePath(
|
|
17739
17739
|
config2.instanceName,
|
|
17740
17740
|
config2.instanceName === DEFAULT_INFERENCE_HOST_INSTANCE ? config2.baseDir : join(config2.baseDir, "instances", config2.instanceName),
|
|
17741
|
-
|
|
17741
|
+
record5.credential_file_path,
|
|
17742
17742
|
"Stored inference credential path"
|
|
17743
17743
|
) : null;
|
|
17744
17744
|
return {
|
|
17745
17745
|
schema_version: "vtx_inference_credential_context_v1",
|
|
17746
17746
|
instance_name: config2.instanceName,
|
|
17747
|
-
credential_store_mode:
|
|
17747
|
+
credential_store_mode: record5.credential_store_mode,
|
|
17748
17748
|
credential_file_path: credentialFilePath
|
|
17749
17749
|
};
|
|
17750
17750
|
}
|
|
@@ -17752,7 +17752,7 @@ function assertLocalState(value) {
|
|
|
17752
17752
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
17753
17753
|
throw new Error("Inference host local state is invalid.");
|
|
17754
17754
|
}
|
|
17755
|
-
const
|
|
17755
|
+
const record5 = value;
|
|
17756
17756
|
const exactKeys = [
|
|
17757
17757
|
"schema_version",
|
|
17758
17758
|
"issuer",
|
|
@@ -17761,10 +17761,10 @@ function assertLocalState(value) {
|
|
|
17761
17761
|
"host_generation",
|
|
17762
17762
|
"key_generation"
|
|
17763
17763
|
];
|
|
17764
|
-
if (Object.keys(
|
|
17764
|
+
if (Object.keys(record5).sort().join("\0") !== exactKeys.slice().sort().join("\0") || record5.schema_version !== 1 || typeof record5.issuer !== "string" || !record5.issuer || typeof record5.client_id !== "string" || !record5.client_id || typeof record5.host_id !== "string" || !record5.host_id || !Number.isSafeInteger(record5.host_generation) || Number(record5.host_generation) < 1 || !Number.isSafeInteger(record5.key_generation) || Number(record5.key_generation) < 1) {
|
|
17765
17765
|
throw new Error("Inference host local state is invalid.");
|
|
17766
17766
|
}
|
|
17767
|
-
return
|
|
17767
|
+
return record5;
|
|
17768
17768
|
}
|
|
17769
17769
|
async function ensureInferencePrivateDirectory(path, dependencies = {}) {
|
|
17770
17770
|
const platform = dependencies.platform ?? process.platform;
|
|
@@ -18796,7 +18796,7 @@ function validateInferenceHostCredential(value) {
|
|
|
18796
18796
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
18797
18797
|
throw new Error("Inference host credential is invalid.");
|
|
18798
18798
|
}
|
|
18799
|
-
const
|
|
18799
|
+
const record5 = value;
|
|
18800
18800
|
const exactKeys = [
|
|
18801
18801
|
"schema_version",
|
|
18802
18802
|
"issuer",
|
|
@@ -18809,21 +18809,21 @@ function validateInferenceHostCredential(value) {
|
|
|
18809
18809
|
"created_at",
|
|
18810
18810
|
"updated_at"
|
|
18811
18811
|
];
|
|
18812
|
-
if (Object.keys(
|
|
18812
|
+
if (Object.keys(record5).sort().join("\0") !== exactKeys.sort().join("\0")) {
|
|
18813
18813
|
throw new Error("Inference host credential fields are invalid.");
|
|
18814
18814
|
}
|
|
18815
|
-
if (
|
|
18815
|
+
if (record5.schema_version !== 1) {
|
|
18816
18816
|
throw new Error("Inference host credential version is invalid.");
|
|
18817
18817
|
}
|
|
18818
|
-
const issuer = canonicalUrl(String(
|
|
18818
|
+
const issuer = canonicalUrl(String(record5.issuer || ""), "Inference OAuth issuer");
|
|
18819
18819
|
const resource = canonicalUrl(
|
|
18820
|
-
String(
|
|
18820
|
+
String(record5.resource || ""),
|
|
18821
18821
|
"Inference OAuth resource"
|
|
18822
18822
|
);
|
|
18823
|
-
const clientId = String(
|
|
18824
|
-
const hostId = String(
|
|
18825
|
-
const refreshToken = String(
|
|
18826
|
-
const privateKey = String(
|
|
18823
|
+
const clientId = String(record5.client_id || "");
|
|
18824
|
+
const hostId = String(record5.host_id || "");
|
|
18825
|
+
const refreshToken = String(record5.refresh_token || "");
|
|
18826
|
+
const privateKey = String(record5.x25519_private_key || "");
|
|
18827
18827
|
if (!clientId || clientId.length > 512) {
|
|
18828
18828
|
throw new Error("Inference OAuth client ID is invalid.");
|
|
18829
18829
|
}
|
|
@@ -18836,11 +18836,11 @@ function validateInferenceHostCredential(value) {
|
|
|
18836
18836
|
if (!BASE64URL_32_BYTES.test(privateKey)) {
|
|
18837
18837
|
throw new Error("Inference host private key is invalid.");
|
|
18838
18838
|
}
|
|
18839
|
-
if (!Number.isSafeInteger(
|
|
18839
|
+
if (!Number.isSafeInteger(record5.key_generation) || Number(record5.key_generation) < 1) {
|
|
18840
18840
|
throw new Error("Inference host key generation is invalid.");
|
|
18841
18841
|
}
|
|
18842
|
-
const createdAt = isoTimestamp(
|
|
18843
|
-
const updatedAt = isoTimestamp(
|
|
18842
|
+
const createdAt = isoTimestamp(record5.created_at, "Credential creation timestamp");
|
|
18843
|
+
const updatedAt = isoTimestamp(record5.updated_at, "Credential update timestamp");
|
|
18844
18844
|
return {
|
|
18845
18845
|
schema_version: 1,
|
|
18846
18846
|
issuer,
|
|
@@ -18849,7 +18849,7 @@ function validateInferenceHostCredential(value) {
|
|
|
18849
18849
|
host_id: hostId,
|
|
18850
18850
|
refresh_token: refreshToken,
|
|
18851
18851
|
x25519_private_key: privateKey,
|
|
18852
|
-
key_generation: Number(
|
|
18852
|
+
key_generation: Number(record5.key_generation),
|
|
18853
18853
|
created_at: createdAt,
|
|
18854
18854
|
updated_at: updatedAt
|
|
18855
18855
|
};
|
|
@@ -19109,17 +19109,17 @@ var init_credential_store = __esm({
|
|
|
19109
19109
|
if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) {
|
|
19110
19110
|
throw new Error("Inference credential fallback file is invalid.");
|
|
19111
19111
|
}
|
|
19112
|
-
const
|
|
19113
|
-
if (
|
|
19112
|
+
const record5 = envelope;
|
|
19113
|
+
if (record5.schema_version !== 1 || record5.namespace !== INFERENCE_CREDENTIAL_NAMESPACE || typeof record5.account_key !== "string") {
|
|
19114
19114
|
throw new Error("Inference credential fallback identity is invalid.");
|
|
19115
19115
|
}
|
|
19116
|
-
const credential = validateInferenceHostCredential(
|
|
19116
|
+
const credential = validateInferenceHostCredential(record5.credential);
|
|
19117
19117
|
const exactAccountKey = inferenceCredentialAccountKey({
|
|
19118
19118
|
issuer: credential.issuer,
|
|
19119
19119
|
clientId: credential.client_id,
|
|
19120
19120
|
hostId: credential.host_id
|
|
19121
19121
|
});
|
|
19122
|
-
if (
|
|
19122
|
+
if (record5.account_key !== exactAccountKey || accountKey2 && record5.account_key !== accountKey2) {
|
|
19123
19123
|
throw new Error("Inference credential fallback identity is invalid.");
|
|
19124
19124
|
}
|
|
19125
19125
|
return credential;
|
|
@@ -19169,22 +19169,22 @@ var init_credential_store = __esm({
|
|
|
19169
19169
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19170
19170
|
throw new Error("Inference credential recovery file is invalid.");
|
|
19171
19171
|
}
|
|
19172
|
-
const
|
|
19173
|
-
if (Object.keys(
|
|
19172
|
+
const record5 = parsed;
|
|
19173
|
+
if (Object.keys(record5).sort().join("\0") !== [
|
|
19174
19174
|
"account_key",
|
|
19175
19175
|
"credential",
|
|
19176
19176
|
"namespace",
|
|
19177
19177
|
"schema_version"
|
|
19178
|
-
].join("\0") ||
|
|
19178
|
+
].join("\0") || record5.schema_version !== 1 || record5.namespace !== INFERENCE_CREDENTIAL_NAMESPACE || typeof record5.account_key !== "string") {
|
|
19179
19179
|
throw new Error("Inference credential recovery identity is invalid.");
|
|
19180
19180
|
}
|
|
19181
|
-
const credential = validateInferenceHostCredential(
|
|
19181
|
+
const credential = validateInferenceHostCredential(record5.credential);
|
|
19182
19182
|
const accountKey2 = inferenceCredentialAccountKey({
|
|
19183
19183
|
issuer: credential.issuer,
|
|
19184
19184
|
clientId: credential.client_id,
|
|
19185
19185
|
hostId: credential.host_id
|
|
19186
19186
|
});
|
|
19187
|
-
if (
|
|
19187
|
+
if (record5.account_key !== accountKey2) {
|
|
19188
19188
|
throw new Error("Inference credential recovery identity is invalid.");
|
|
19189
19189
|
}
|
|
19190
19190
|
return { accountKey: accountKey2, credential };
|
|
@@ -22981,26 +22981,26 @@ var require_resolve = __commonJS({
|
|
|
22981
22981
|
return true;
|
|
22982
22982
|
}
|
|
22983
22983
|
function countKeys(schema) {
|
|
22984
|
-
var
|
|
22984
|
+
var count4 = 0, item;
|
|
22985
22985
|
if (Array.isArray(schema)) {
|
|
22986
22986
|
for (var i = 0; i < schema.length; i++) {
|
|
22987
22987
|
item = schema[i];
|
|
22988
|
-
if (typeof item == "object")
|
|
22989
|
-
if (
|
|
22988
|
+
if (typeof item == "object") count4 += countKeys(item);
|
|
22989
|
+
if (count4 == Infinity) return Infinity;
|
|
22990
22990
|
}
|
|
22991
22991
|
} else {
|
|
22992
22992
|
for (var key in schema) {
|
|
22993
22993
|
if (key == "$ref") return Infinity;
|
|
22994
22994
|
if (SIMPLE_INLINED[key]) {
|
|
22995
|
-
|
|
22995
|
+
count4++;
|
|
22996
22996
|
} else {
|
|
22997
22997
|
item = schema[key];
|
|
22998
|
-
if (typeof item == "object")
|
|
22999
|
-
if (
|
|
22998
|
+
if (typeof item == "object") count4 += countKeys(item) + 1;
|
|
22999
|
+
if (count4 == Infinity) return Infinity;
|
|
23000
23000
|
}
|
|
23001
23001
|
}
|
|
23002
23002
|
}
|
|
23003
|
-
return
|
|
23003
|
+
return count4;
|
|
23004
23004
|
}
|
|
23005
23005
|
function getFullPath(id2, normalize) {
|
|
23006
23006
|
if (normalize !== false) id2 = normalizeId(id2);
|
|
@@ -30413,7 +30413,7 @@ var init_agent_state = __esm({
|
|
|
30413
30413
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(message);
|
|
30414
30414
|
return value;
|
|
30415
30415
|
};
|
|
30416
|
-
hasExactKeys = (
|
|
30416
|
+
hasExactKeys = (record5, keys) => Object.keys(record5).sort().join("\0") === [...keys].sort().join("\0");
|
|
30417
30417
|
assertInferenceAgentFailureFence = (value) => {
|
|
30418
30418
|
const message = "Inference Agent failure fence is invalid.";
|
|
30419
30419
|
const fence = assertPlainObject(value, message);
|
|
@@ -30596,17 +30596,17 @@ var init_agent_state = __esm({
|
|
|
30596
30596
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
30597
30597
|
throw new Error("Agent-driven inference next recovery state is invalid.");
|
|
30598
30598
|
}
|
|
30599
|
-
const
|
|
30600
|
-
if (Object.keys(
|
|
30599
|
+
const record5 = value;
|
|
30600
|
+
if (Object.keys(record5).sort().join("\0") !== ["schema_version", "operation_id", "requested_at"].sort().join("\0") || record5.schema_version !== "vtx_inference_agent_next_v1" || typeof record5.operation_id !== "string" || !record5.operation_id || typeof record5.requested_at !== "string" || !Number.isFinite(Date.parse(record5.requested_at))) {
|
|
30601
30601
|
throw new Error("Agent-driven inference next recovery state is invalid.");
|
|
30602
30602
|
}
|
|
30603
|
-
return
|
|
30603
|
+
return record5;
|
|
30604
30604
|
};
|
|
30605
30605
|
assertAttemptState = (value) => {
|
|
30606
30606
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
30607
30607
|
throw new Error("Agent-driven inference attempt state is invalid.");
|
|
30608
30608
|
}
|
|
30609
|
-
const
|
|
30609
|
+
const record5 = value;
|
|
30610
30610
|
const exactKeys = [
|
|
30611
30611
|
"schema_version",
|
|
30612
30612
|
"host_id",
|
|
@@ -30623,22 +30623,22 @@ var init_agent_state = __esm({
|
|
|
30623
30623
|
"pending_terminal"
|
|
30624
30624
|
];
|
|
30625
30625
|
const freshnessKeys = ["provider_dispatch_not_after", "provider_dispatch_local_not_after"];
|
|
30626
|
-
if ("execution_mode" in
|
|
30627
|
-
if (!["server", "client"].includes(String(
|
|
30626
|
+
if ("execution_mode" in record5) {
|
|
30627
|
+
if (!["server", "client"].includes(String(record5.execution_mode))) {
|
|
30628
30628
|
throw new Error("Agent-driven inference execution mode is invalid.");
|
|
30629
30629
|
}
|
|
30630
30630
|
exactKeys.push("execution_mode");
|
|
30631
30631
|
}
|
|
30632
|
-
if (freshnessKeys.some((key) => key in
|
|
30633
|
-
if (freshnessKeys.some((key) => typeof
|
|
30632
|
+
if (freshnessKeys.some((key) => key in record5)) {
|
|
30633
|
+
if (freshnessKeys.some((key) => typeof record5[key] !== "string" || !Number.isFinite(Date.parse(record5[key])))) {
|
|
30634
30634
|
throw new Error("Agent-driven inference freshness recovery state is invalid.");
|
|
30635
30635
|
}
|
|
30636
30636
|
exactKeys.push(...freshnessKeys);
|
|
30637
30637
|
}
|
|
30638
|
-
if (Object.keys(
|
|
30638
|
+
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))) {
|
|
30639
30639
|
throw new Error("Agent-driven inference attempt state is invalid.");
|
|
30640
30640
|
}
|
|
30641
|
-
const pending2 =
|
|
30641
|
+
const pending2 = record5.pending_terminal;
|
|
30642
30642
|
if (pending2 !== null) {
|
|
30643
30643
|
if (!pending2 || typeof pending2 !== "object" || Array.isArray(pending2)) {
|
|
30644
30644
|
throw new Error("Agent-driven inference terminal recovery state is invalid.");
|
|
@@ -30655,7 +30655,7 @@ var init_agent_state = __esm({
|
|
|
30655
30655
|
throw new Error("Agent-driven inference terminal recovery state is invalid.");
|
|
30656
30656
|
}
|
|
30657
30657
|
}
|
|
30658
|
-
return
|
|
30658
|
+
return record5;
|
|
30659
30659
|
};
|
|
30660
30660
|
}
|
|
30661
30661
|
});
|
|
@@ -30902,14 +30902,14 @@ var init_runner = __esm({
|
|
|
30902
30902
|
};
|
|
30903
30903
|
};
|
|
30904
30904
|
safeInteger = (value, minimum) => typeof value === "number" && Number.isSafeInteger(value) && value >= minimum;
|
|
30905
|
-
exactObjectKeys = (
|
|
30905
|
+
exactObjectKeys = (record5, keys) => Object.keys(record5).sort().join("\0") === [...keys].sort().join("\0");
|
|
30906
30906
|
validIso = (value) => typeof value === "string" && value.length > 0 && Number.isFinite(Date.parse(value));
|
|
30907
30907
|
validateAttemptReceipt = (value) => {
|
|
30908
30908
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
30909
30909
|
throw new Error("Inference host attempt receipt is invalid.");
|
|
30910
30910
|
}
|
|
30911
|
-
const
|
|
30912
|
-
if (!exactObjectKeys(
|
|
30911
|
+
const record5 = value;
|
|
30912
|
+
if (!exactObjectKeys(record5, [
|
|
30913
30913
|
"schema_version",
|
|
30914
30914
|
"attempt_id",
|
|
30915
30915
|
"job_id",
|
|
@@ -30925,30 +30925,30 @@ var init_runner = __esm({
|
|
|
30925
30925
|
"start_request",
|
|
30926
30926
|
"terminal_request",
|
|
30927
30927
|
"updated_at"
|
|
30928
|
-
]) ||
|
|
30928
|
+
]) || record5.schema_version !== ATTEMPT_RECEIPT_SCHEMA_VERSION || typeof record5.attempt_id !== "string" || !record5.attempt_id || typeof record5.job_id !== "string" || !record5.job_id || !safeInteger(record5.profile_id, 1) || typeof record5.input_sha256 !== "string" || !/^[0-9a-f]{64}$/u.test(record5.input_sha256) || !safeInteger(record5.claim_generation, 1) || !safeInteger(record5.attempt_index, 0) || !["claimed", "started", "dispatched", "terminal_pending"].includes(String(record5.phase)) || !["not_dispatched", "confirmed_dispatched", "outcome_unknown"].includes(String(record5.dispatch_outcome)) || record5.terminal_operation_id !== null && typeof record5.terminal_operation_id !== "string" || !safeInteger(record5.job_heartbeat_sequence, 0) || !validIso(record5.updated_at)) {
|
|
30929
30929
|
throw new Error("Inference host attempt receipt is invalid.");
|
|
30930
30930
|
}
|
|
30931
|
-
const claim =
|
|
30932
|
-
if (!claim || typeof claim !== "object" || Array.isArray(claim) || claim.claim_state !== "claimed" || claim.job_id !==
|
|
30931
|
+
const claim = record5.claim;
|
|
30932
|
+
if (!claim || typeof claim !== "object" || Array.isArray(claim) || claim.claim_state !== "claimed" || claim.job_id !== record5.job_id || claim.claim_generation !== record5.claim_generation || claim.attempt_index !== record5.attempt_index || claim.input_sha256 !== record5.input_sha256) {
|
|
30933
30933
|
throw new Error("Inference host persisted claim is invalid.");
|
|
30934
30934
|
}
|
|
30935
|
-
const startRequest = attemptStartRequestSchema.parse(
|
|
30936
|
-
if (startRequest.attempt_id !==
|
|
30935
|
+
const startRequest = attemptStartRequestSchema.parse(record5.start_request);
|
|
30936
|
+
if (startRequest.attempt_id !== record5.attempt_id || startRequest.job_id !== record5.job_id || startRequest.claim_generation !== record5.claim_generation || startRequest.attempt_index !== record5.attempt_index || startRequest.input_sha256 !== record5.input_sha256) {
|
|
30937
30937
|
throw new Error("Inference host persisted start request is invalid.");
|
|
30938
30938
|
}
|
|
30939
30939
|
let terminalRequest = null;
|
|
30940
|
-
if (
|
|
30941
|
-
const schemaVersion =
|
|
30942
|
-
terminalRequest = schemaVersion === "external_inference_job_complete_v1" ? jobCompleteRequestSchema.parse(
|
|
30943
|
-
if (terminalRequest.attempt_id !==
|
|
30940
|
+
if (record5.terminal_request !== null) {
|
|
30941
|
+
const schemaVersion = record5.terminal_request.schema_version;
|
|
30942
|
+
terminalRequest = schemaVersion === "external_inference_job_complete_v1" ? jobCompleteRequestSchema.parse(record5.terminal_request) : jobFailRequestSchema.parse(record5.terminal_request);
|
|
30943
|
+
if (terminalRequest.attempt_id !== record5.attempt_id || terminalRequest.job_id !== record5.job_id || terminalRequest.claim_generation !== record5.claim_generation) {
|
|
30944
30944
|
throw new Error("Inference host persisted terminal request is invalid.");
|
|
30945
30945
|
}
|
|
30946
30946
|
}
|
|
30947
|
-
if (
|
|
30947
|
+
if (record5.phase === "terminal_pending" !== (terminalRequest !== null)) {
|
|
30948
30948
|
throw new Error("Inference host terminal receipt phase is invalid.");
|
|
30949
30949
|
}
|
|
30950
30950
|
return {
|
|
30951
|
-
...
|
|
30951
|
+
...record5,
|
|
30952
30952
|
claim,
|
|
30953
30953
|
start_request: startRequest,
|
|
30954
30954
|
terminal_request: terminalRequest
|
|
@@ -30958,7 +30958,7 @@ var init_runner = __esm({
|
|
|
30958
30958
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
30959
30959
|
throw new Error("Inference host runtime receipt is invalid.");
|
|
30960
30960
|
}
|
|
30961
|
-
const
|
|
30961
|
+
const record5 = value;
|
|
30962
30962
|
const legacyKeys = [
|
|
30963
30963
|
"schema_version",
|
|
30964
30964
|
"host_id",
|
|
@@ -30974,17 +30974,17 @@ var init_runner = __esm({
|
|
|
30974
30974
|
"updated_at"
|
|
30975
30975
|
];
|
|
30976
30976
|
const currentKeys = [...legacyKeys, "pending_claim_request"];
|
|
30977
|
-
if (!(exactObjectKeys(
|
|
30977
|
+
if (!(exactObjectKeys(record5, legacyKeys) || exactObjectKeys(record5, currentKeys) || exactObjectKeys(record5, [...legacyKeys, "last_advertisement"]) || exactObjectKeys(record5, [...currentKeys, "last_advertisement"])) || record5.schema_version !== RUNTIME_RECEIPT_SCHEMA_VERSION || typeof record5.host_id !== "string" || !record5.host_id || !safeInteger(record5.host_generation, 1) || !safeInteger(record5.key_generation, 1) || !safeInteger(record5.advertisement_generation, 1) || record5.advertisement_expires_at !== null && !validIso(record5.advertisement_expires_at) || typeof record5.registered !== "boolean" || !safeInteger(record5.host_heartbeat_sequence, 0) || !safeInteger(record5.claim_sequence, 0) || !record5.attempts || typeof record5.attempts !== "object" || Array.isArray(record5.attempts) || !validIso(record5.updated_at)) {
|
|
30978
30978
|
throw new Error("Inference host runtime receipt is invalid.");
|
|
30979
30979
|
}
|
|
30980
|
-
const lastAdvertisement =
|
|
30981
|
-
const pendingAdvertisement =
|
|
30982
|
-
const pendingClaimRequest =
|
|
30983
|
-
if (pendingClaimRequest && (pendingClaimRequest.host_id !==
|
|
30980
|
+
const lastAdvertisement = record5.last_advertisement == null ? null : hostAdvertisementSchema.parse(record5.last_advertisement);
|
|
30981
|
+
const pendingAdvertisement = record5.pending_advertisement === null ? null : hostAdvertisementSchema.parse(record5.pending_advertisement);
|
|
30982
|
+
const pendingClaimRequest = record5.pending_claim_request == null ? null : jobClaimRequestSchema.parse(record5.pending_claim_request);
|
|
30983
|
+
if (pendingClaimRequest && (pendingClaimRequest.host_id !== record5.host_id || pendingClaimRequest.host_generation !== record5.host_generation || pendingClaimRequest.key_generation !== record5.key_generation || pendingClaimRequest.advertisement_generation > Number(record5.advertisement_generation))) {
|
|
30984
30984
|
throw new Error("Inference host pending claim receipt is invalid.");
|
|
30985
30985
|
}
|
|
30986
30986
|
const attempts = Object.fromEntries(
|
|
30987
|
-
Object.entries(
|
|
30987
|
+
Object.entries(record5.attempts).map(([key, attempt]) => {
|
|
30988
30988
|
const validated = validateAttemptReceipt(attempt);
|
|
30989
30989
|
if (key !== validated.attempt_id) {
|
|
30990
30990
|
throw new Error("Inference host attempt receipt key is invalid.");
|
|
@@ -30993,9 +30993,9 @@ var init_runner = __esm({
|
|
|
30993
30993
|
})
|
|
30994
30994
|
);
|
|
30995
30995
|
return {
|
|
30996
|
-
...
|
|
30996
|
+
...record5,
|
|
30997
30997
|
pending_advertisement: pendingAdvertisement,
|
|
30998
|
-
..."last_advertisement" in
|
|
30998
|
+
..."last_advertisement" in record5 ? { last_advertisement: lastAdvertisement } : {},
|
|
30999
30999
|
pending_claim_request: pendingClaimRequest,
|
|
31000
31000
|
attempts
|
|
31001
31001
|
};
|
|
@@ -35785,9 +35785,9 @@ var init_codex_adapter = __esm({
|
|
|
35785
35785
|
continue;
|
|
35786
35786
|
}
|
|
35787
35787
|
if (!event || typeof event !== "object" || Array.isArray(event)) continue;
|
|
35788
|
-
const
|
|
35789
|
-
const payload =
|
|
35790
|
-
if (
|
|
35788
|
+
const record5 = event;
|
|
35789
|
+
const payload = record5.payload;
|
|
35790
|
+
if (record5.type === "session_meta" && payload && typeof payload === "object" && !Array.isArray(payload) && resolve3(String(payload.cwd || "")) === resolve3(checkpoint.workspacePath)) {
|
|
35791
35791
|
threadPaths.add(path);
|
|
35792
35792
|
break;
|
|
35793
35793
|
}
|
|
@@ -36954,16 +36954,16 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
36954
36954
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
36955
36955
|
throw new Error("Windows process ownership inventory was invalid.");
|
|
36956
36956
|
}
|
|
36957
|
-
const
|
|
36958
|
-
if (!Number.isSafeInteger(
|
|
36957
|
+
const record5 = entry;
|
|
36958
|
+
if (!Number.isSafeInteger(record5.process_id) || Number(record5.process_id) < 1 || typeof record5.name !== "string" || record5.executable_path !== null && typeof record5.executable_path !== "string" || record5.command_line !== null && typeof record5.command_line !== "string" || record5.creation_date !== null && typeof record5.creation_date !== "string") {
|
|
36959
36959
|
throw new Error("Windows process ownership inventory was invalid.");
|
|
36960
36960
|
}
|
|
36961
36961
|
return {
|
|
36962
|
-
process_id: Number(
|
|
36963
|
-
name:
|
|
36964
|
-
executable_path:
|
|
36965
|
-
command_line:
|
|
36966
|
-
creation_date:
|
|
36962
|
+
process_id: Number(record5.process_id),
|
|
36963
|
+
name: record5.name,
|
|
36964
|
+
executable_path: record5.executable_path,
|
|
36965
|
+
command_line: record5.command_line,
|
|
36966
|
+
creation_date: record5.creation_date
|
|
36967
36967
|
};
|
|
36968
36968
|
});
|
|
36969
36969
|
};
|
|
@@ -41457,14 +41457,14 @@ var init_exo_credential_store = __esm({
|
|
|
41457
41457
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
41458
41458
|
throw new Error("Stored Exo credential is invalid.");
|
|
41459
41459
|
}
|
|
41460
|
-
const
|
|
41461
|
-
if (typeof
|
|
41460
|
+
const record5 = value;
|
|
41461
|
+
if (typeof record5.provider !== "string" || typeof record5.api_key !== "string") {
|
|
41462
41462
|
throw new Error("Stored Exo credential is invalid.");
|
|
41463
41463
|
}
|
|
41464
|
-
const provider = validateProvider(
|
|
41465
|
-
const apiKey = validateApiKey(
|
|
41464
|
+
const provider = validateProvider(record5.provider);
|
|
41465
|
+
const apiKey = validateApiKey(record5.api_key);
|
|
41466
41466
|
const identity2 = credentialIdentity(provider, apiKey);
|
|
41467
|
-
if (
|
|
41467
|
+
if (record5.schema_version !== 1 || record5.adapter !== "exo" || record5.identity !== identity2 || Object.keys(record5).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
|
|
41468
41468
|
throw new Error("Stored Exo credential failed validation.");
|
|
41469
41469
|
}
|
|
41470
41470
|
return { provider, apiKey, identity: identity2 };
|
|
@@ -41658,11 +41658,11 @@ var init_pi_credential_store = __esm({
|
|
|
41658
41658
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
41659
41659
|
throw new Error("Stored Pi credential is invalid.");
|
|
41660
41660
|
}
|
|
41661
|
-
const
|
|
41662
|
-
const provider = validateProvider2(String(
|
|
41663
|
-
const apiKey = validateApiKey2(String(
|
|
41661
|
+
const record5 = value;
|
|
41662
|
+
const provider = validateProvider2(String(record5.provider ?? ""));
|
|
41663
|
+
const apiKey = validateApiKey2(String(record5.api_key ?? ""));
|
|
41664
41664
|
const identity2 = credentialIdentity2(provider, apiKey);
|
|
41665
|
-
if (
|
|
41665
|
+
if (record5.schema_version !== 1 || record5.adapter !== "pi" || record5.identity !== identity2 || Object.keys(record5).sort().join(",") !== "adapter,api_key,identity,provider,schema_version") {
|
|
41666
41666
|
throw new Error("Stored Pi credential failed validation.");
|
|
41667
41667
|
}
|
|
41668
41668
|
return { provider, apiKey, identity: identity2 };
|
|
@@ -41815,10 +41815,10 @@ var init_deepseek_credential_store = __esm({
|
|
|
41815
41815
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
41816
41816
|
throw new Error("Stored DeepSeek Harness credential is invalid.");
|
|
41817
41817
|
}
|
|
41818
|
-
const
|
|
41819
|
-
const apiKey = validateApiKey3(String(
|
|
41818
|
+
const record5 = value;
|
|
41819
|
+
const apiKey = validateApiKey3(String(record5.api_key ?? ""));
|
|
41820
41820
|
const identity2 = credentialIdentity3(apiKey);
|
|
41821
|
-
if (
|
|
41821
|
+
if (record5.schema_version !== 1 || record5.adapter !== "deepseek-harness" || record5.identity !== identity2 || Object.keys(record5).sort().join(",") !== "adapter,api_key,identity,schema_version") {
|
|
41822
41822
|
throw new Error("Stored DeepSeek Harness credential failed validation.");
|
|
41823
41823
|
}
|
|
41824
41824
|
return { apiKey, identity: identity2 };
|
|
@@ -41971,6 +41971,9 @@ var init_runtime_policy_generated = __esm({
|
|
|
41971
41971
|
"lib/runtime-policy.generated.json with { type: 'json' }"() {
|
|
41972
41972
|
runtime_policy_generated_default = {
|
|
41973
41973
|
ui: {
|
|
41974
|
+
performance_defaults: {
|
|
41975
|
+
default_timeframe: "30d"
|
|
41976
|
+
},
|
|
41974
41977
|
auth_bootstrap_retry: {
|
|
41975
41978
|
max_attempts: 3,
|
|
41976
41979
|
jitter_milliseconds: 750,
|
|
@@ -42196,28 +42199,28 @@ var init_service = __esm({
|
|
|
42196
42199
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
42197
42200
|
throw new Error("Inference-host service worker is invalid.");
|
|
42198
42201
|
}
|
|
42199
|
-
const
|
|
42200
|
-
if (typeof
|
|
42202
|
+
const record5 = value;
|
|
42203
|
+
if (typeof record5.instance_name !== "string" || !/^[a-z0-9](?:[a-z0-9-]{0,46}[a-z0-9])?$/u.test(record5.instance_name) || typeof record5.adapter !== "string" || !isDurableInferenceAdapterId(record5.adapter) || typeof record5.display_name !== "string" || !record5.display_name || record5.max_concurrency !== null && (!Number.isSafeInteger(record5.max_concurrency) || Number(record5.max_concurrency) < 1) || record5.authenticated_account_email !== null && typeof record5.authenticated_account_email !== "string" || record5.authenticated_account_identity !== void 0 && record5.authenticated_account_identity !== null && typeof record5.authenticated_account_identity !== "string" || record5.authenticated_account_plan !== null && typeof record5.authenticated_account_plan !== "string") {
|
|
42201
42204
|
throw new Error("Inference-host service worker is invalid.");
|
|
42202
42205
|
}
|
|
42203
42206
|
return {
|
|
42204
|
-
instance_name:
|
|
42205
|
-
adapter:
|
|
42206
|
-
display_name:
|
|
42207
|
-
max_concurrency:
|
|
42208
|
-
authenticated_account_identity:
|
|
42209
|
-
authenticated_account_email:
|
|
42210
|
-
authenticated_account_plan:
|
|
42211
|
-
runtime_environment: assertRuntimeEnvironment(
|
|
42207
|
+
instance_name: record5.instance_name,
|
|
42208
|
+
adapter: record5.adapter,
|
|
42209
|
+
display_name: record5.display_name,
|
|
42210
|
+
max_concurrency: record5.max_concurrency === null ? null : Number(record5.max_concurrency),
|
|
42211
|
+
authenticated_account_identity: record5.authenticated_account_identity,
|
|
42212
|
+
authenticated_account_email: record5.authenticated_account_email,
|
|
42213
|
+
authenticated_account_plan: record5.authenticated_account_plan,
|
|
42214
|
+
runtime_environment: assertRuntimeEnvironment(record5.runtime_environment)
|
|
42212
42215
|
};
|
|
42213
42216
|
};
|
|
42214
42217
|
assertManifest = (value) => {
|
|
42215
42218
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
42216
42219
|
throw new Error("Inference-host service manifest is invalid.");
|
|
42217
42220
|
}
|
|
42218
|
-
const
|
|
42219
|
-
if (
|
|
42220
|
-
const legacy =
|
|
42221
|
+
const record5 = value;
|
|
42222
|
+
if (record5.schema_version === "vtx_inference_service_v1") {
|
|
42223
|
+
const legacy = record5;
|
|
42221
42224
|
if (legacy.adapter !== "codex" || typeof legacy.installed_at !== "string" || !Number.isFinite(Date.parse(legacy.installed_at)) || typeof legacy.executable !== "string" || !legacy.executable || typeof legacy.script !== "string" || !legacy.script || typeof legacy.display_name !== "string" || !legacy.display_name || typeof legacy.log_path !== "string" || !legacy.log_path) throw new Error("Inference-host service manifest is invalid.");
|
|
42222
42225
|
const runtime_environment = withoutConcurrencyLimit(
|
|
42223
42226
|
assertRuntimeEnvironment(legacy.runtime_environment)
|
|
@@ -42241,8 +42244,8 @@ var init_service = __esm({
|
|
|
42241
42244
|
workers: [worker]
|
|
42242
42245
|
};
|
|
42243
42246
|
}
|
|
42244
|
-
if (
|
|
42245
|
-
const legacy =
|
|
42247
|
+
if (record5.schema_version === "vtx_inference_service_v2") {
|
|
42248
|
+
const legacy = record5;
|
|
42246
42249
|
if (typeof legacy.installed_at !== "string" || !Number.isFinite(Date.parse(legacy.installed_at)) || typeof legacy.executable !== "string" || !legacy.executable || typeof legacy.script !== "string" || !legacy.script || typeof legacy.log_path !== "string" || !legacy.log_path || !Array.isArray(legacy.workers) || legacy.workers.length < 1) {
|
|
42247
42250
|
throw new Error("Inference-host service manifest is invalid.");
|
|
42248
42251
|
}
|
|
@@ -42275,19 +42278,19 @@ var init_service = __esm({
|
|
|
42275
42278
|
workers: workers2
|
|
42276
42279
|
};
|
|
42277
42280
|
}
|
|
42278
|
-
if (
|
|
42281
|
+
if (record5.schema_version !== "vtx_inference_service_v3" || typeof record5.installed_at !== "string" || !Number.isFinite(Date.parse(record5.installed_at)) || typeof record5.executable !== "string" || !record5.executable || typeof record5.script !== "string" || !record5.script || typeof record5.log_path !== "string" || !record5.log_path || !Array.isArray(record5.workers) || record5.workers.length < 1) {
|
|
42279
42282
|
throw new Error("Inference-host service manifest is invalid.");
|
|
42280
42283
|
}
|
|
42281
|
-
assertServicePath(
|
|
42282
|
-
assertServicePath(
|
|
42283
|
-
assertServicePath(
|
|
42284
|
-
const workers =
|
|
42284
|
+
assertServicePath(record5.executable);
|
|
42285
|
+
assertServicePath(record5.script);
|
|
42286
|
+
assertServicePath(record5.log_path);
|
|
42287
|
+
const workers = record5.workers.map(assertWorker);
|
|
42285
42288
|
if (new Set(workers.map((worker) => worker.instance_name)).size !== workers.length) {
|
|
42286
42289
|
throw new Error("Inference-host service worker names must be unique.");
|
|
42287
42290
|
}
|
|
42288
42291
|
return {
|
|
42289
|
-
...
|
|
42290
|
-
generation: manifestGeneration(
|
|
42292
|
+
...record5,
|
|
42293
|
+
generation: manifestGeneration(record5.generation, String(record5.installed_at)),
|
|
42291
42294
|
workers
|
|
42292
42295
|
};
|
|
42293
42296
|
};
|
|
@@ -42295,11 +42298,11 @@ var init_service = __esm({
|
|
|
42295
42298
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
42296
42299
|
throw new Error("Inference-host service runtime state is invalid.");
|
|
42297
42300
|
}
|
|
42298
|
-
const
|
|
42299
|
-
if (
|
|
42301
|
+
const record5 = value;
|
|
42302
|
+
if (record5.schema_version !== "vtx_inference_service_runtime_v1" || typeof record5.manifest_generation !== "string" || record5.rejected_manifest_generation !== void 0 && record5.rejected_manifest_generation !== null && typeof record5.rejected_manifest_generation !== "string" || typeof record5.updated_at !== "string" || !Number.isFinite(Date.parse(record5.updated_at)) || !Array.isArray(record5.workers)) {
|
|
42300
42303
|
throw new Error("Inference-host service runtime state is invalid.");
|
|
42301
42304
|
}
|
|
42302
|
-
const workers =
|
|
42305
|
+
const workers = record5.workers.map((worker) => {
|
|
42303
42306
|
if (!worker || typeof worker !== "object" || Array.isArray(worker)) {
|
|
42304
42307
|
throw new Error("Inference-host service worker runtime state is invalid.");
|
|
42305
42308
|
}
|
|
@@ -42313,17 +42316,17 @@ var init_service = __esm({
|
|
|
42313
42316
|
error: item.error
|
|
42314
42317
|
};
|
|
42315
42318
|
});
|
|
42316
|
-
return { ...
|
|
42319
|
+
return { ...record5, workers };
|
|
42317
42320
|
};
|
|
42318
42321
|
assertDesiredState = (value) => {
|
|
42319
42322
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
42320
42323
|
throw new Error("Inference-host service desired state is invalid.");
|
|
42321
42324
|
}
|
|
42322
|
-
const
|
|
42323
|
-
if (
|
|
42325
|
+
const record5 = value;
|
|
42326
|
+
if (record5.schema_version !== "vtx_inference_service_desired_v1" || typeof record5.desired_running !== "boolean" || typeof record5.updated_at !== "string" || !Number.isFinite(Date.parse(record5.updated_at))) {
|
|
42324
42327
|
throw new Error("Inference-host service desired state is invalid.");
|
|
42325
42328
|
}
|
|
42326
|
-
return
|
|
42329
|
+
return record5;
|
|
42327
42330
|
};
|
|
42328
42331
|
readInferenceHostServiceManifest = async (path) => {
|
|
42329
42332
|
const raw = await readInferencePrivateFile(path, "Inference-host service manifest");
|
|
@@ -43410,10 +43413,10 @@ ${result2.stderr}`)) {
|
|
|
43410
43413
|
manifest_generation: appliedManifest.generation,
|
|
43411
43414
|
rejected_manifest_generation: rejectedManifestGeneration,
|
|
43412
43415
|
updated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
43413
|
-
workers: [...workers.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([instanceName,
|
|
43416
|
+
workers: [...workers.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([instanceName, record5]) => ({
|
|
43414
43417
|
instance_name: instanceName,
|
|
43415
|
-
state:
|
|
43416
|
-
error:
|
|
43418
|
+
state: record5.state,
|
|
43419
|
+
error: record5.error
|
|
43417
43420
|
}))
|
|
43418
43421
|
};
|
|
43419
43422
|
runtimeWriteChain = runtimeWriteChain.then(async () => {
|
|
@@ -43422,10 +43425,10 @@ ${result2.stderr}`)) {
|
|
|
43422
43425
|
});
|
|
43423
43426
|
await runtimeWriteChain;
|
|
43424
43427
|
};
|
|
43425
|
-
const updateRecord = async (
|
|
43426
|
-
if (workers.get(
|
|
43427
|
-
|
|
43428
|
-
|
|
43428
|
+
const updateRecord = async (record5, state, error48 = null) => {
|
|
43429
|
+
if (workers.get(record5.worker.instance_name) !== record5) return;
|
|
43430
|
+
record5.state = state;
|
|
43431
|
+
record5.error = error48;
|
|
43429
43432
|
await persistRuntime();
|
|
43430
43433
|
};
|
|
43431
43434
|
const waitRetry = async (milliseconds, controller) => {
|
|
@@ -43443,15 +43446,15 @@ ${result2.stderr}`)) {
|
|
|
43443
43446
|
signal.removeEventListener("abort", finishAbort);
|
|
43444
43447
|
}
|
|
43445
43448
|
};
|
|
43446
|
-
const superviseWorker = async (serviceManifest,
|
|
43449
|
+
const superviseWorker = async (serviceManifest, record5) => {
|
|
43447
43450
|
let failures = 0;
|
|
43448
|
-
while (!signal.aborted && !quiesceSignal.aborted && !
|
|
43451
|
+
while (!signal.aborted && !quiesceSignal.aborted && !record5.controller.signal.aborted && await readDesiredAcrossAtomicReplacement(desiredPath)) {
|
|
43449
43452
|
try {
|
|
43450
|
-
await updateRecord(
|
|
43453
|
+
await updateRecord(record5, "starting");
|
|
43451
43454
|
const attemptController = new AbortController();
|
|
43452
43455
|
const forwardAbort = () => attemptController.abort();
|
|
43453
43456
|
signal.addEventListener("abort", forwardAbort, { once: true });
|
|
43454
|
-
|
|
43457
|
+
record5.controller.signal.addEventListener("abort", forwardAbort, { once: true });
|
|
43455
43458
|
let result2;
|
|
43456
43459
|
let launchSettled = false;
|
|
43457
43460
|
let readinessTask = Promise.resolve();
|
|
@@ -43459,15 +43462,15 @@ ${result2.stderr}`)) {
|
|
|
43459
43462
|
try {
|
|
43460
43463
|
result2 = await launch(
|
|
43461
43464
|
serviceManifest,
|
|
43462
|
-
|
|
43465
|
+
record5.worker,
|
|
43463
43466
|
attemptController.signal,
|
|
43464
43467
|
() => {
|
|
43465
43468
|
if (readinessSignalled) return;
|
|
43466
43469
|
readinessSignalled = true;
|
|
43467
43470
|
readinessTask = (async () => {
|
|
43468
43471
|
await sleep4(500);
|
|
43469
|
-
if (!launchSettled && !attemptController.signal.aborted && !
|
|
43470
|
-
await updateRecord(
|
|
43472
|
+
if (!launchSettled && !attemptController.signal.aborted && !record5.controller.signal.aborted && !signal.aborted) {
|
|
43473
|
+
await updateRecord(record5, "running");
|
|
43471
43474
|
}
|
|
43472
43475
|
})();
|
|
43473
43476
|
},
|
|
@@ -43477,70 +43480,70 @@ ${result2.stderr}`)) {
|
|
|
43477
43480
|
launchSettled = true;
|
|
43478
43481
|
attemptController.abort();
|
|
43479
43482
|
signal.removeEventListener("abort", forwardAbort);
|
|
43480
|
-
|
|
43483
|
+
record5.controller.signal.removeEventListener("abort", forwardAbort);
|
|
43481
43484
|
await readinessTask;
|
|
43482
43485
|
}
|
|
43483
43486
|
if (result2.cooperativeStopTimedOut) {
|
|
43484
|
-
await updateRecord(
|
|
43487
|
+
await updateRecord(record5, "failed", "worker_cooperative_stop_timeout");
|
|
43485
43488
|
await appendServiceLog(serviceManifest.log_path, "worker_cooperative_stop_timeout", {
|
|
43486
|
-
instance_name:
|
|
43489
|
+
instance_name: record5.worker.instance_name
|
|
43487
43490
|
});
|
|
43488
43491
|
throw new Error("worker_cooperative_stop_timeout");
|
|
43489
43492
|
}
|
|
43490
|
-
if (signal.aborted || quiesceSignal.aborted ||
|
|
43493
|
+
if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted || !await readDesiredAcrossAtomicReplacement(desiredPath)) break;
|
|
43491
43494
|
failures = result2.uptimeMs >= runtime_policy_generated_default.external_inference.service.restart_stable_uptime_ms ? 0 : failures + 1;
|
|
43492
43495
|
const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
|
|
43493
|
-
await updateRecord(
|
|
43496
|
+
await updateRecord(record5, "failed", "worker_exited");
|
|
43494
43497
|
await appendServiceLog(serviceManifest.log_path, "worker_exited", {
|
|
43495
|
-
instance_name:
|
|
43498
|
+
instance_name: record5.worker.instance_name,
|
|
43496
43499
|
exit_code: result2.exitCode,
|
|
43497
43500
|
uptime_ms: result2.uptimeMs,
|
|
43498
43501
|
drain_reason: result2.drainReason ?? null,
|
|
43499
43502
|
retry_after_ms: retryAfterMs
|
|
43500
43503
|
});
|
|
43501
|
-
await waitRetry(retryAfterMs,
|
|
43504
|
+
await waitRetry(retryAfterMs, record5.controller);
|
|
43502
43505
|
} catch (error48) {
|
|
43503
43506
|
if (error48 instanceof Error && error48.message === "worker_cooperative_stop_timeout") throw error48;
|
|
43504
|
-
if (signal.aborted || quiesceSignal.aborted ||
|
|
43507
|
+
if (signal.aborted || quiesceSignal.aborted || record5.controller.signal.aborted) break;
|
|
43505
43508
|
failures += 1;
|
|
43506
43509
|
const retryAfterMs = Math.min(runtime_policy_generated_default.external_inference.service.restart_backoff_base_ms * 2 ** Math.min(failures, runtime_policy_generated_default.external_inference.service.restart_exponent_max), runtime_policy_generated_default.external_inference.service.restart_backoff_max_ms);
|
|
43507
|
-
await updateRecord(
|
|
43510
|
+
await updateRecord(record5, "failed", "worker_launch_failed");
|
|
43508
43511
|
await appendServiceLog(serviceManifest.log_path, "worker_launch_failed", {
|
|
43509
|
-
instance_name:
|
|
43512
|
+
instance_name: record5.worker.instance_name,
|
|
43510
43513
|
error: error48 instanceof Error ? error48.message : "unknown",
|
|
43511
43514
|
retry_after_ms: retryAfterMs
|
|
43512
43515
|
});
|
|
43513
|
-
await waitRetry(retryAfterMs,
|
|
43516
|
+
await waitRetry(retryAfterMs, record5.controller);
|
|
43514
43517
|
}
|
|
43515
43518
|
}
|
|
43516
43519
|
};
|
|
43517
43520
|
const startWorker = (serviceManifest, worker) => {
|
|
43518
|
-
const
|
|
43521
|
+
const record5 = {
|
|
43519
43522
|
worker,
|
|
43520
43523
|
controller: new AbortController(),
|
|
43521
43524
|
promise: Promise.resolve(),
|
|
43522
43525
|
state: "starting",
|
|
43523
43526
|
error: null
|
|
43524
43527
|
};
|
|
43525
|
-
workers.set(worker.instance_name,
|
|
43526
|
-
|
|
43528
|
+
workers.set(worker.instance_name, record5);
|
|
43529
|
+
record5.promise = superviseWorker(serviceManifest, record5);
|
|
43527
43530
|
};
|
|
43528
43531
|
const reconcile = async (next) => {
|
|
43529
43532
|
const nextByName = new Map(next.workers.map((worker) => [worker.instance_name, worker]));
|
|
43530
|
-
const retiring = [...workers.values()].filter((
|
|
43531
|
-
const nextWorker = nextByName.get(
|
|
43532
|
-
return !nextWorker || !sameWorker(
|
|
43533
|
+
const retiring = [...workers.values()].filter((record5) => {
|
|
43534
|
+
const nextWorker = nextByName.get(record5.worker.instance_name);
|
|
43535
|
+
return !nextWorker || !sameWorker(record5.worker, nextWorker);
|
|
43533
43536
|
});
|
|
43534
|
-
for (const
|
|
43535
|
-
|
|
43536
|
-
await updateRecord(
|
|
43537
|
+
for (const record5 of retiring) {
|
|
43538
|
+
record5.controller.abort();
|
|
43539
|
+
await updateRecord(record5, "draining");
|
|
43537
43540
|
}
|
|
43538
|
-
const settled = await Promise.allSettled(retiring.map((
|
|
43541
|
+
const settled = await Promise.allSettled(retiring.map((record5) => record5.promise));
|
|
43539
43542
|
const failedDrain = settled.find(
|
|
43540
43543
|
(result2) => result2.status === "rejected"
|
|
43541
43544
|
);
|
|
43542
43545
|
if (failedDrain) {
|
|
43543
|
-
for (const
|
|
43546
|
+
for (const record5 of retiring) workers.delete(record5.worker.instance_name);
|
|
43544
43547
|
for (const worker of appliedManifest.workers) {
|
|
43545
43548
|
if (!workers.has(worker.instance_name)) startWorker(appliedManifest, worker);
|
|
43546
43549
|
}
|
|
@@ -43552,7 +43555,7 @@ ${result2.stderr}`)) {
|
|
|
43552
43555
|
});
|
|
43553
43556
|
return;
|
|
43554
43557
|
}
|
|
43555
|
-
for (const
|
|
43558
|
+
for (const record5 of retiring) workers.delete(record5.worker.instance_name);
|
|
43556
43559
|
for (const worker of next.workers) {
|
|
43557
43560
|
if (!workers.has(worker.instance_name)) startWorker(next, worker);
|
|
43558
43561
|
}
|
|
@@ -43566,18 +43569,18 @@ ${result2.stderr}`)) {
|
|
|
43566
43569
|
};
|
|
43567
43570
|
const drainWorkers = async () => {
|
|
43568
43571
|
const draining = [...workers.values()];
|
|
43569
|
-
for (const
|
|
43570
|
-
|
|
43571
|
-
await updateRecord(
|
|
43572
|
+
for (const record5 of draining) {
|
|
43573
|
+
record5.controller.abort();
|
|
43574
|
+
await updateRecord(record5, "draining");
|
|
43572
43575
|
}
|
|
43573
|
-
const settled = await Promise.allSettled(draining.map((
|
|
43576
|
+
const settled = await Promise.allSettled(draining.map((record5) => record5.promise));
|
|
43574
43577
|
const failedDrain = settled.find(
|
|
43575
43578
|
(result2) => result2.status === "rejected"
|
|
43576
43579
|
);
|
|
43577
43580
|
if (failedDrain) throw failedDrain.reason;
|
|
43578
|
-
for (const
|
|
43579
|
-
if (workers.get(
|
|
43580
|
-
workers.delete(
|
|
43581
|
+
for (const record5 of draining) {
|
|
43582
|
+
if (workers.get(record5.worker.instance_name) === record5) {
|
|
43583
|
+
workers.delete(record5.worker.instance_name);
|
|
43581
43584
|
}
|
|
43582
43585
|
}
|
|
43583
43586
|
await persistRuntime();
|
|
@@ -43603,7 +43606,7 @@ ${result2.stderr}`)) {
|
|
|
43603
43606
|
}
|
|
43604
43607
|
if (quiesceSignal.aborted && !signal.aborted) {
|
|
43605
43608
|
let finished = false;
|
|
43606
|
-
const completion = Promise.allSettled([...workers.values()].map((
|
|
43609
|
+
const completion = Promise.allSettled([...workers.values()].map((record5) => record5.promise)).then((results) => {
|
|
43607
43610
|
finished = true;
|
|
43608
43611
|
return results;
|
|
43609
43612
|
});
|
|
@@ -43866,7 +43869,7 @@ var init_cli = __esm({
|
|
|
43866
43869
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
43867
43870
|
throw new Error("Inference host revocation checkpoint is invalid.");
|
|
43868
43871
|
}
|
|
43869
|
-
const
|
|
43872
|
+
const record5 = value;
|
|
43870
43873
|
const exactKeys = [
|
|
43871
43874
|
"schema_version",
|
|
43872
43875
|
"account_key",
|
|
@@ -43877,11 +43880,11 @@ var init_cli = __esm({
|
|
|
43877
43880
|
"remove_credential_recovery",
|
|
43878
43881
|
"remote_revoked_at"
|
|
43879
43882
|
];
|
|
43880
|
-
const revokedAt = String(
|
|
43881
|
-
if (Object.keys(
|
|
43883
|
+
const revokedAt = String(record5.remote_revoked_at || "");
|
|
43884
|
+
if (Object.keys(record5).sort().join("\0") !== exactKeys.slice().sort().join("\0") || record5.schema_version !== "vtx_inference_revocation_v1" || typeof record5.account_key !== "string" || !record5.account_key || record5.account_key.length > 512 || typeof record5.credential_store_identity !== "string" || !record5.credential_store_identity || record5.credential_store_identity.length > 4096 || typeof record5.issuer !== "string" || !record5.issuer || record5.issuer.length > 2048 || typeof record5.client_id !== "string" || !record5.client_id || record5.client_id.length > 512 || typeof record5.host_id !== "string" || !record5.host_id || record5.host_id.length > 512 || typeof record5.remove_credential_recovery !== "boolean" || typeof record5.remote_revoked_at !== "string" || !Number.isFinite(Date.parse(revokedAt)) || new Date(revokedAt).toISOString() !== revokedAt) {
|
|
43882
43885
|
throw new Error("Inference host revocation checkpoint is invalid.");
|
|
43883
43886
|
}
|
|
43884
|
-
return
|
|
43887
|
+
return record5;
|
|
43885
43888
|
};
|
|
43886
43889
|
readRevocationCheckpoint = async (config2) => {
|
|
43887
43890
|
const raw = await readInferencePrivateFile(
|
|
@@ -45403,12 +45406,12 @@ Waiting for approval...
|
|
|
45403
45406
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
45404
45407
|
throw new Error("Agent-driven inference stdin must be one JSON object.");
|
|
45405
45408
|
}
|
|
45406
|
-
const
|
|
45407
|
-
const unexpected = Object.keys(
|
|
45409
|
+
const record5 = value;
|
|
45410
|
+
const unexpected = Object.keys(record5).filter((key) => !allowedKeys.includes(key));
|
|
45408
45411
|
if (unexpected.length > 0) {
|
|
45409
45412
|
throw new Error(`Unsupported agent-driven inference fields: ${unexpected.join(", ")}.`);
|
|
45410
45413
|
}
|
|
45411
|
-
return
|
|
45414
|
+
return record5;
|
|
45412
45415
|
};
|
|
45413
45416
|
parseOptionalAgentStdin = async (dependencies, allowedKeys) => {
|
|
45414
45417
|
if (!dependencies.readStdin && process.stdin.isTTY) return {};
|
|
@@ -45423,12 +45426,12 @@ Waiting for approval...
|
|
|
45423
45426
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
45424
45427
|
throw new Error("Agent-driven inference stdin must be one JSON object.");
|
|
45425
45428
|
}
|
|
45426
|
-
const
|
|
45427
|
-
const unexpected = Object.keys(
|
|
45429
|
+
const record5 = value;
|
|
45430
|
+
const unexpected = Object.keys(record5).filter((key) => !allowedKeys.includes(key));
|
|
45428
45431
|
if (unexpected.length > 0) {
|
|
45429
45432
|
throw new Error(`Unsupported agent-driven inference fields: ${unexpected.join(", ")}.`);
|
|
45430
45433
|
}
|
|
45431
|
-
return
|
|
45434
|
+
return record5;
|
|
45432
45435
|
};
|
|
45433
45436
|
agentOperationId = (kind) => `${kind}-${randomUUID10()}`;
|
|
45434
45437
|
agentSession = async (config2, dependencies, warnings, signal) => {
|
|
@@ -46388,7 +46391,7 @@ Waiting for approval...
|
|
|
46388
46391
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
46389
46392
|
throw new Error("Inference-host service recovery transaction is invalid.");
|
|
46390
46393
|
}
|
|
46391
|
-
const
|
|
46394
|
+
const record5 = value;
|
|
46392
46395
|
const exactKeys = [
|
|
46393
46396
|
"schema_version",
|
|
46394
46397
|
"phase",
|
|
@@ -46401,15 +46404,15 @@ Waiting for approval...
|
|
|
46401
46404
|
"cleanup_confirmed_attempt_ids",
|
|
46402
46405
|
"started_at"
|
|
46403
46406
|
];
|
|
46404
|
-
if (Object.keys(
|
|
46407
|
+
if (Object.keys(record5).sort().join("\0") !== exactKeys.sort().join("\0") || record5.schema_version !== "vtx_inference_service_recovery_v1" || record5.phase !== "prepared" && record5.phase !== "reconciled" || typeof record5.transaction_id !== "string" || !/^[0-9a-f-]{36}$/u.test(record5.transaction_id) || typeof record5.instance_name !== "string" || typeof record5.manifest_generation !== "string" || typeof record5.restore_desired_running !== "boolean" || typeof record5.recovery_backup_path !== "string" || typeof record5.recovery_backup_sha256 !== "string" || !/^[0-9a-f]{64}$/u.test(record5.recovery_backup_sha256) || !Array.isArray(record5.cleanup_confirmed_attempt_ids) || record5.cleanup_confirmed_attempt_ids.some(
|
|
46405
46408
|
(attemptId) => typeof attemptId !== "string" || attemptId.length < 1 || attemptId.length > 256
|
|
46406
|
-
) || new Set(
|
|
46409
|
+
) || new Set(record5.cleanup_confirmed_attempt_ids).size !== record5.cleanup_confirmed_attempt_ids.length || [...record5.cleanup_confirmed_attempt_ids].sort().join("\0") !== record5.cleanup_confirmed_attempt_ids.join("\0") || typeof record5.started_at !== "string" || !Number.isFinite(Date.parse(record5.started_at)) || new Date(record5.started_at).toISOString() !== record5.started_at) {
|
|
46407
46410
|
throw new Error("Inference-host service recovery transaction is invalid.");
|
|
46408
46411
|
}
|
|
46409
|
-
if (resolve11(
|
|
46412
|
+
if (resolve11(record5.recovery_backup_path) !== resolve11(recoveryBackupPath(config2, record5.transaction_id))) {
|
|
46410
46413
|
throw new Error("Inference-host service recovery backup path is invalid.");
|
|
46411
46414
|
}
|
|
46412
|
-
return
|
|
46415
|
+
return record5;
|
|
46413
46416
|
};
|
|
46414
46417
|
assertResumableCodexRecoveryEvidence = (backupAttempts, currentAttempts, cleanupConfirmedAttemptIds, phase) => {
|
|
46415
46418
|
const backupIds = Object.keys(backupAttempts).sort();
|
|
@@ -48968,7 +48971,7 @@ var init_network_debug = __esm({
|
|
|
48968
48971
|
});
|
|
48969
48972
|
|
|
48970
48973
|
// lib/runtime/hyperliquid-account-state-adapter.ts
|
|
48971
|
-
var unsupportedUserActiveAssetCache, MAX_UNSUPPORTED_USER_ACTIVE_ASSET_CACHE_KEYS, UNSUPPORTED_USER_ACTIVE_ASSET_STORAGE_KEY, USER_FILLS_CACHE_STORAGE_PREFIX, ACCOUNT_STATE_CACHE_STORAGE_PREFIX, INFO_RATE_LIMIT_COOLDOWN_STORAGE_PREFIX, INFO_RATE_LIMIT_COOLDOWN_MIN_MS, INFO_RATE_LIMIT_COOLDOWN_MAX_MS, browserUserFillsCache, browserUserFillsInFlight, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, browserAccountStateCache, browserAccountStateInFlight, browserInfoRateLimitCooldowns, UNSUPPORTED_USER_ACTIVE_ASSET_DETAIL_PATTERNS, unsupportedUserActiveAssetCacheHydrated, hydrateUnsupportedUserActiveAssetCache, persistUnsupportedUserActiveAssetCache, toPositiveFinite, toFinite, firstFiniteNumber, parseFundingUsdcFromInfoPosition, buildActiveAssetCacheKey, buildUserFillsCacheKey, buildUserFillsStorageKey, buildAccountStateCacheKey, buildAccountStateStorageKey, normalizeInfoRateLimitApiUrl, normalizeInfoRequestType, buildInfoRateLimitCooldownKey, buildInfoRateLimitCooldownStorageKey, readInfoRateLimitCooldownUntilMs, hasActiveInfoRateLimitCooldown, writeInfoRateLimitCooldown, extractInfoRequestTypeFromRateLimitError, recordInfoRateLimitCooldownFromError, requireNonNegativeConfigSeconds, requireAccountStateCacheConfig, requireUserFillsCacheConfig, normalizeFillSymbol, buildSymbolFilter, filterFillsBySymbols, readBrowserUserFillsCache, writeBrowserUserFillsCache, cloneBrowserAccountStateResult, withAccountStateEvidence, readBrowserAccountStateCache, writeBrowserAccountStateCache, isRateLimitError, createAbortError, waitForSharedBrowserRequest, waitForSharedBrowserUserFills, getBrowserActiveAssetTypeCandidates, normalizeHyperliquidErrorDetail, isUnsupportedUserActiveAssetError, rememberUnsupportedUserActiveAssetKey, parseInfoPositions, requireFinitePromptMetric, requirePromptClearinghouseState, requirePromptSpotState, normalizePerpDexName, listConfiguredPerpDexs, listPerpDexsForAccountState, prefixHip3PositionCoins, aggregateClearinghouseResponses, normalizeBrowserFillToTradeHistory, isPerpFill, fetchHyperliquidInfoPayload, requireHyperliquidApiUrl, requireWalletAddress, parseInfoPositionSnapshot, fetchBrowserAccountState, fetchBrowserAccountStateUncached, fetchBrowserUserFills, fetchBrowserPositionSnapshot;
|
|
48974
|
+
var unsupportedUserActiveAssetCache, MAX_UNSUPPORTED_USER_ACTIVE_ASSET_CACHE_KEYS, UNSUPPORTED_USER_ACTIVE_ASSET_STORAGE_KEY, USER_FILLS_CACHE_STORAGE_PREFIX, ACCOUNT_STATE_CACHE_STORAGE_PREFIX, INFO_RATE_LIMIT_COOLDOWN_STORAGE_PREFIX, INFO_RATE_LIMIT_COOLDOWN_MIN_MS, INFO_RATE_LIMIT_COOLDOWN_MAX_MS, browserUserFillsCache, browserUserFillsInFlight, HYPERLIQUID_USER_FILLS_PROVIDER_PAGE_CAP, browserAccountStateCache, browserAccountStateInFlight, browserInfoRateLimitCooldowns, UNSUPPORTED_USER_ACTIVE_ASSET_DETAIL_PATTERNS, unsupportedUserActiveAssetCacheHydrated, hydrateUnsupportedUserActiveAssetCache, persistUnsupportedUserActiveAssetCache, toPositiveFinite, toFinite, firstFiniteNumber, parseFundingUsdcFromInfoPosition, buildActiveAssetCacheKey, buildUserFillsCacheKey, buildUserFillsStorageKey, buildAccountStateCacheKey, buildAccountStateStorageKey, normalizeInfoRateLimitApiUrl, normalizeInfoRequestType, buildInfoRateLimitCooldownKey, buildInfoRateLimitCooldownStorageKey, readInfoRateLimitCooldownUntilMs, hasActiveInfoRateLimitCooldown, writeInfoRateLimitCooldown, extractInfoRequestTypeFromRateLimitError, recordInfoRateLimitCooldownFromError, requireNonNegativeConfigSeconds, requireAccountStateCacheConfig, requireUserFillsCacheConfig, normalizeFillSymbol, buildSymbolFilter, filterFillsBySymbols, readBrowserUserFillsCache, writeBrowserUserFillsCache, cloneBrowserAccountStateResult, withAccountStateEvidence, readBrowserAccountStateCache, writeBrowserAccountStateCache, isRateLimitError, createAbortError, waitForSharedBrowserRequest, waitForSharedBrowserUserFills, getBrowserActiveAssetTypeCandidates, normalizeHyperliquidErrorDetail, isUnsupportedUserActiveAssetError, rememberUnsupportedUserActiveAssetKey, parseInfoPositions, requireFinitePromptMetric, requirePromptClearinghouseState, requirePromptSpotState, normalizePerpDexName, listConfiguredPerpDexs, listPerpDexsForAccountState, prefixHip3PositionCoins, aggregateClearinghouseResponses, hasCompletePerpDexAccountMetrics, normalizeBrowserFillToTradeHistory, isPerpFill, fetchHyperliquidInfoPayload, requireHyperliquidApiUrl, requireWalletAddress, parseInfoPositionSnapshot, fetchBrowserAccountState, fetchBrowserAccountStateUncached, fetchBrowserUserFills, fetchBrowserPositionSnapshot;
|
|
48972
48975
|
var init_hyperliquid_account_state_adapter = __esm({
|
|
48973
48976
|
"lib/runtime/hyperliquid-account-state-adapter.ts"() {
|
|
48974
48977
|
"use strict";
|
|
@@ -49656,6 +49659,20 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
49656
49659
|
assetPositions
|
|
49657
49660
|
};
|
|
49658
49661
|
};
|
|
49662
|
+
hasCompletePerpDexAccountMetrics = (response) => {
|
|
49663
|
+
const isFiniteMetric = (value) => (typeof value === "number" || typeof value === "string" && value.trim() !== "") && Number.isFinite(Number(value));
|
|
49664
|
+
if (!response || typeof response !== "object" || Array.isArray(response)) return false;
|
|
49665
|
+
const margin = response.marginSummary;
|
|
49666
|
+
if (!margin || typeof margin !== "object" || Array.isArray(margin)) return false;
|
|
49667
|
+
if (![margin.accountValue, margin.totalMarginUsed, response.withdrawable].every(isFiniteMetric)) return false;
|
|
49668
|
+
const maintenanceValues = [response.crossMaintenanceMarginUsed, margin.crossMaintenanceMarginUsed, margin.totalMaintenanceMargin].filter((value) => value != null);
|
|
49669
|
+
if (maintenanceValues.length === 0 || !maintenanceValues.every(isFiniteMetric)) return false;
|
|
49670
|
+
if (!Array.isArray(response.assetPositions)) return false;
|
|
49671
|
+
return response.assetPositions.every((entry) => {
|
|
49672
|
+
const position = entry?.position;
|
|
49673
|
+
return position && typeof position === "object" && !Array.isArray(position) && [position.szi, position.entryPx, position.unrealizedPnl].every(isFiniteMetric);
|
|
49674
|
+
});
|
|
49675
|
+
};
|
|
49659
49676
|
normalizeBrowserFillToTradeHistory = (fill) => {
|
|
49660
49677
|
if (!fill || typeof fill !== "object") {
|
|
49661
49678
|
return null;
|
|
@@ -49893,7 +49910,8 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
49893
49910
|
}
|
|
49894
49911
|
return {
|
|
49895
49912
|
dex: dexName,
|
|
49896
|
-
payload: prefixHip3PositionCoins(response, dexName)
|
|
49913
|
+
payload: prefixHip3PositionCoins(response, dexName),
|
|
49914
|
+
rawPayload: response
|
|
49897
49915
|
};
|
|
49898
49916
|
})
|
|
49899
49917
|
);
|
|
@@ -49907,6 +49925,10 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
49907
49925
|
...dexResponses.map((entry) => entry.payload)
|
|
49908
49926
|
]),
|
|
49909
49927
|
selectedPayload,
|
|
49928
|
+
dexPayloads: [
|
|
49929
|
+
{ dex: "", payload: defaultResponse },
|
|
49930
|
+
...dexResponses.map(({ dex, rawPayload }) => ({ dex, payload: rawPayload }))
|
|
49931
|
+
],
|
|
49910
49932
|
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
49911
49933
|
};
|
|
49912
49934
|
})();
|
|
@@ -50047,6 +50069,31 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50047
50069
|
);
|
|
50048
50070
|
const accountSummary = {
|
|
50049
50071
|
...normalizedSummary,
|
|
50072
|
+
...input.scopeAccountSummaryToSelectedDex === true ? {} : {
|
|
50073
|
+
perp_dex_accounts: perpsResult.dexPayloads.filter(({ payload }) => hasCompletePerpDexAccountMetrics(payload)).map(({ dex, payload }) => {
|
|
50074
|
+
const summary = buildServerPromptRescueAccountSummary({
|
|
50075
|
+
...payload,
|
|
50076
|
+
crossMaintenanceMarginUsed: firstFiniteNumber([
|
|
50077
|
+
payload.crossMaintenanceMarginUsed,
|
|
50078
|
+
payload.marginSummary?.crossMaintenanceMarginUsed,
|
|
50079
|
+
payload.marginSummary?.totalMaintenanceMargin
|
|
50080
|
+
])
|
|
50081
|
+
}, {}, "disabled", accountSummaryOptions);
|
|
50082
|
+
const accountValue = Number(payload.marginSummary.accountValue);
|
|
50083
|
+
const calculatedAvailable = accountValue - summary.total_margin_used;
|
|
50084
|
+
const availableMargin = summary.maintenance_margin > 0 ? Math.max(calculatedAvailable, Math.max(0, accountValue - 4 * summary.maintenance_margin), summary.withdrawable) : Math.max(calculatedAvailable, summary.withdrawable);
|
|
50085
|
+
return {
|
|
50086
|
+
dex,
|
|
50087
|
+
account_value: accountValue,
|
|
50088
|
+
total_margin_used: summary.total_margin_used,
|
|
50089
|
+
available_margin: availableMargin,
|
|
50090
|
+
withdrawable: summary.withdrawable,
|
|
50091
|
+
maintenance_margin: summary.maintenance_margin,
|
|
50092
|
+
cross_account_leverage: summary.cross_account_leverage,
|
|
50093
|
+
total_unrealized_pnl: summary.total_unrealized_pnl ?? 0
|
|
50094
|
+
};
|
|
50095
|
+
})
|
|
50096
|
+
},
|
|
50050
50097
|
...exactAccountMode == null ? {} : { account_mode: exactAccountMode.accountMode, mode_source: "canonical" },
|
|
50051
50098
|
address: walletAddress,
|
|
50052
50099
|
dex: input.scopeAccountSummaryToSelectedDex === true ? selectedDex : "all",
|
|
@@ -50564,11 +50611,11 @@ var init_local_breadcrumbs = __esm({
|
|
|
50564
50611
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
50565
50612
|
return null;
|
|
50566
50613
|
}
|
|
50567
|
-
const
|
|
50568
|
-
const id2 = sanitizeOptionalString(
|
|
50569
|
-
const createdAt = sanitizeOptionalString(
|
|
50570
|
-
const scope =
|
|
50571
|
-
const kind = sanitizeOptionalString(
|
|
50614
|
+
const record5 = value;
|
|
50615
|
+
const id2 = sanitizeOptionalString(record5.id);
|
|
50616
|
+
const createdAt = sanitizeOptionalString(record5.createdAt);
|
|
50617
|
+
const scope = record5.scope === "engine" || record5.scope === "host" || record5.scope === "api" ? record5.scope : null;
|
|
50618
|
+
const kind = sanitizeOptionalString(record5.kind);
|
|
50572
50619
|
if (!id2 || !createdAt || !scope || !kind) {
|
|
50573
50620
|
return null;
|
|
50574
50621
|
}
|
|
@@ -50577,16 +50624,16 @@ var init_local_breadcrumbs = __esm({
|
|
|
50577
50624
|
createdAt,
|
|
50578
50625
|
scope,
|
|
50579
50626
|
kind,
|
|
50580
|
-
detail: sanitizeOptionalString(
|
|
50581
|
-
profileId: sanitizeOptionalString(
|
|
50582
|
-
sessionId: sanitizeOptionalString(
|
|
50583
|
-
deviceId: sanitizeOptionalString(
|
|
50584
|
-
mode:
|
|
50585
|
-
runtimeState:
|
|
50586
|
-
lastRunAt: sanitizeOptionalString(
|
|
50587
|
-
visibilityState: sanitizeOptionalString(
|
|
50588
|
-
online: typeof
|
|
50589
|
-
payload: clonePayload(
|
|
50627
|
+
detail: sanitizeOptionalString(record5.detail),
|
|
50628
|
+
profileId: sanitizeOptionalString(record5.profileId),
|
|
50629
|
+
sessionId: sanitizeOptionalString(record5.sessionId),
|
|
50630
|
+
deviceId: sanitizeOptionalString(record5.deviceId),
|
|
50631
|
+
mode: record5.mode === "assistant" ? "assistant" : record5.mode === "trader" ? "trader" : null,
|
|
50632
|
+
runtimeState: record5.runtimeState === "stopped" || record5.runtimeState === "running" || record5.runtimeState === "stale" || record5.runtimeState === "offline" || record5.runtimeState === "error" ? record5.runtimeState : null,
|
|
50633
|
+
lastRunAt: sanitizeOptionalString(record5.lastRunAt),
|
|
50634
|
+
visibilityState: sanitizeOptionalString(record5.visibilityState),
|
|
50635
|
+
online: typeof record5.online === "boolean" ? record5.online : null,
|
|
50636
|
+
payload: clonePayload(record5.payload ?? null)
|
|
50590
50637
|
};
|
|
50591
50638
|
};
|
|
50592
50639
|
readLocalRuntimeBreadcrumbs = () => {
|
|
@@ -50668,6 +50715,9 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
50668
50715
|
"lib/runtime-policy.generated.json"() {
|
|
50669
50716
|
runtime_policy_generated_default2 = {
|
|
50670
50717
|
ui: {
|
|
50718
|
+
performance_defaults: {
|
|
50719
|
+
default_timeframe: "30d"
|
|
50720
|
+
},
|
|
50671
50721
|
auth_bootstrap_retry: {
|
|
50672
50722
|
max_attempts: 3,
|
|
50673
50723
|
jitter_milliseconds: 750,
|
|
@@ -50952,59 +51002,59 @@ var init_server_runtime_lease = __esm({
|
|
|
50952
51002
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
50953
51003
|
return null;
|
|
50954
51004
|
}
|
|
50955
|
-
const
|
|
50956
|
-
if (String(
|
|
51005
|
+
const record5 = value;
|
|
51006
|
+
if (String(record5.profileId ?? "").trim() !== profileId) {
|
|
50957
51007
|
return null;
|
|
50958
51008
|
}
|
|
50959
|
-
if (!String(
|
|
51009
|
+
if (!String(record5.runtimeLeaseToken ?? "").trim()) {
|
|
50960
51010
|
return null;
|
|
50961
51011
|
}
|
|
50962
|
-
if (!String(
|
|
51012
|
+
if (!String(record5.leaseId ?? "").trim()) {
|
|
50963
51013
|
return null;
|
|
50964
51014
|
}
|
|
50965
|
-
if (!String(
|
|
51015
|
+
if (!String(record5.runtimeSessionId ?? "").trim()) {
|
|
50966
51016
|
return null;
|
|
50967
51017
|
}
|
|
50968
|
-
if (!String(
|
|
51018
|
+
if (!String(record5.deviceId ?? "").trim()) {
|
|
50969
51019
|
return null;
|
|
50970
51020
|
}
|
|
50971
|
-
if (
|
|
51021
|
+
if (record5.mode !== "assistant" && record5.mode !== "trader") {
|
|
50972
51022
|
return null;
|
|
50973
51023
|
}
|
|
50974
|
-
if (
|
|
51024
|
+
if (record5.scope !== "trade-runtime") {
|
|
50975
51025
|
return null;
|
|
50976
51026
|
}
|
|
50977
|
-
if (!String(
|
|
51027
|
+
if (!String(record5.issuedAt ?? "").trim()) {
|
|
50978
51028
|
return null;
|
|
50979
51029
|
}
|
|
50980
|
-
if (!String(
|
|
51030
|
+
if (!String(record5.expiresAt ?? "").trim()) {
|
|
50981
51031
|
return null;
|
|
50982
51032
|
}
|
|
50983
|
-
if (!String(
|
|
51033
|
+
if (!String(record5.renewableUntil ?? "").trim()) {
|
|
50984
51034
|
return null;
|
|
50985
51035
|
}
|
|
50986
|
-
if (!Number.isFinite(Number(
|
|
51036
|
+
if (!Number.isFinite(Number(record5.savedAt))) {
|
|
50987
51037
|
return null;
|
|
50988
51038
|
}
|
|
50989
51039
|
return {
|
|
50990
51040
|
profileId,
|
|
50991
|
-
runtimeLeaseToken: String(
|
|
50992
|
-
leaseId: String(
|
|
50993
|
-
runtimeSessionId: String(
|
|
50994
|
-
deviceId: String(
|
|
50995
|
-
schedulerInstanceId: String(
|
|
50996
|
-
mode:
|
|
51041
|
+
runtimeLeaseToken: String(record5.runtimeLeaseToken),
|
|
51042
|
+
leaseId: String(record5.leaseId),
|
|
51043
|
+
runtimeSessionId: String(record5.runtimeSessionId),
|
|
51044
|
+
deviceId: String(record5.deviceId),
|
|
51045
|
+
schedulerInstanceId: String(record5.schedulerInstanceId ?? "").trim() || null,
|
|
51046
|
+
mode: record5.mode,
|
|
50997
51047
|
scope: "trade-runtime",
|
|
50998
|
-
leaseGeneration: normalizeLeaseGeneration(
|
|
50999
|
-
issuedAt: String(
|
|
51000
|
-
expiresAt: String(
|
|
51001
|
-
renewableUntil: String(
|
|
51002
|
-
lastSeenAt:
|
|
51003
|
-
renewedAt:
|
|
51004
|
-
revokedAt:
|
|
51005
|
-
transport: typeof
|
|
51006
|
-
runtimeContractIdentity:
|
|
51007
|
-
savedAt: Number(
|
|
51048
|
+
leaseGeneration: normalizeLeaseGeneration(record5.leaseGeneration),
|
|
51049
|
+
issuedAt: String(record5.issuedAt),
|
|
51050
|
+
expiresAt: String(record5.expiresAt),
|
|
51051
|
+
renewableUntil: String(record5.renewableUntil),
|
|
51052
|
+
lastSeenAt: record5.lastSeenAt ?? null,
|
|
51053
|
+
renewedAt: record5.renewedAt ?? null,
|
|
51054
|
+
revokedAt: record5.revokedAt ?? null,
|
|
51055
|
+
transport: typeof record5.transport === "object" && record5.transport != null ? record5.transport : {},
|
|
51056
|
+
runtimeContractIdentity: record5.runtimeContractIdentity ?? null,
|
|
51057
|
+
savedAt: Number(record5.savedAt)
|
|
51008
51058
|
};
|
|
51009
51059
|
};
|
|
51010
51060
|
readPersistedLeaseMap = () => {
|
|
@@ -51092,7 +51142,7 @@ var init_server_runtime_lease = __esm({
|
|
|
51092
51142
|
if (!profileId || !runtimeLeaseToken) {
|
|
51093
51143
|
return null;
|
|
51094
51144
|
}
|
|
51095
|
-
const
|
|
51145
|
+
const record5 = {
|
|
51096
51146
|
profileId,
|
|
51097
51147
|
runtimeLeaseToken,
|
|
51098
51148
|
leaseId: String(lease.lease_id),
|
|
@@ -51114,23 +51164,23 @@ var init_server_runtime_lease = __esm({
|
|
|
51114
51164
|
};
|
|
51115
51165
|
const leaseMap = readPersistedLeaseMap();
|
|
51116
51166
|
const existingLease = leaseMap[profileId] ?? null;
|
|
51117
|
-
if (existingLease &&
|
|
51118
|
-
const incomingGeneration =
|
|
51167
|
+
if (existingLease && record5.leaseId !== existingLease.leaseId) {
|
|
51168
|
+
const incomingGeneration = record5.leaseGeneration ?? null;
|
|
51119
51169
|
const existingGeneration = existingLease.leaseGeneration ?? null;
|
|
51120
51170
|
if (existingGeneration !== null && incomingGeneration === null || existingGeneration !== null && incomingGeneration !== null && incomingGeneration <= existingGeneration) {
|
|
51121
51171
|
return existingLease;
|
|
51122
51172
|
}
|
|
51123
51173
|
if (existingGeneration === null && incomingGeneration === null) {
|
|
51124
|
-
const incomingIssuedAtMs = Date.parse(
|
|
51174
|
+
const incomingIssuedAtMs = Date.parse(record5.issuedAt);
|
|
51125
51175
|
const existingIssuedAtMs = Date.parse(existingLease.issuedAt);
|
|
51126
51176
|
if (Number.isFinite(incomingIssuedAtMs) && Number.isFinite(existingIssuedAtMs) && incomingIssuedAtMs < existingIssuedAtMs) {
|
|
51127
51177
|
return existingLease;
|
|
51128
51178
|
}
|
|
51129
51179
|
}
|
|
51130
51180
|
}
|
|
51131
|
-
leaseMap[profileId] =
|
|
51181
|
+
leaseMap[profileId] = record5;
|
|
51132
51182
|
writePersistedLeaseMap(leaseMap);
|
|
51133
|
-
return
|
|
51183
|
+
return record5;
|
|
51134
51184
|
};
|
|
51135
51185
|
clearPersistedClientRuntimeServerLease = (profileId) => {
|
|
51136
51186
|
const normalizedProfileId = normalizeProfileId(profileId);
|
|
@@ -52531,19 +52581,19 @@ function assert2(check2, message, code, info) {
|
|
|
52531
52581
|
function assertArgument(check2, message, name, value) {
|
|
52532
52582
|
assert2(check2, message, "INVALID_ARGUMENT", { argument: name, value });
|
|
52533
52583
|
}
|
|
52534
|
-
function assertArgumentCount(
|
|
52584
|
+
function assertArgumentCount(count4, expectedCount, message) {
|
|
52535
52585
|
if (message == null) {
|
|
52536
52586
|
message = "";
|
|
52537
52587
|
}
|
|
52538
52588
|
if (message) {
|
|
52539
52589
|
message = ": " + message;
|
|
52540
52590
|
}
|
|
52541
|
-
assert2(
|
|
52542
|
-
count:
|
|
52591
|
+
assert2(count4 >= expectedCount, "missing argument" + message, "MISSING_ARGUMENT", {
|
|
52592
|
+
count: count4,
|
|
52543
52593
|
expectedCount
|
|
52544
52594
|
});
|
|
52545
|
-
assert2(
|
|
52546
|
-
count:
|
|
52595
|
+
assert2(count4 <= expectedCount, "too many arguments" + message, "UNEXPECTED_ARGUMENT", {
|
|
52596
|
+
count: count4,
|
|
52547
52597
|
expectedCount
|
|
52548
52598
|
});
|
|
52549
52599
|
}
|
|
@@ -55186,15 +55236,15 @@ var init_abstract_coder = __esm({
|
|
|
55186
55236
|
get bytes() {
|
|
55187
55237
|
return new Uint8Array(this.#data);
|
|
55188
55238
|
}
|
|
55189
|
-
#incrementBytesRead(
|
|
55239
|
+
#incrementBytesRead(count4) {
|
|
55190
55240
|
if (this.#parent) {
|
|
55191
|
-
return this.#parent.#incrementBytesRead(
|
|
55241
|
+
return this.#parent.#incrementBytesRead(count4);
|
|
55192
55242
|
}
|
|
55193
|
-
this.#bytesRead +=
|
|
55243
|
+
this.#bytesRead += count4;
|
|
55194
55244
|
assert2(this.#maxInflation < 1 || this.#bytesRead <= this.#maxInflation * this.dataLength, `compressed ABI data exceeds inflation ratio of ${this.#maxInflation} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`, "BUFFER_OVERRUN", {
|
|
55195
55245
|
buffer: getBytesCopy(this.#data),
|
|
55196
55246
|
offset: this.#offset,
|
|
55197
|
-
length:
|
|
55247
|
+
length: count4,
|
|
55198
55248
|
info: {
|
|
55199
55249
|
bytesRead: this.#bytesRead,
|
|
55200
55250
|
dataLength: this.dataLength
|
|
@@ -60305,12 +60355,12 @@ var init_array = __esm({
|
|
|
60305
60355
|
if (!Array.isArray(value)) {
|
|
60306
60356
|
this._throwError("expected array value", value);
|
|
60307
60357
|
}
|
|
60308
|
-
let
|
|
60309
|
-
if (
|
|
60310
|
-
|
|
60358
|
+
let count4 = this.length;
|
|
60359
|
+
if (count4 === -1) {
|
|
60360
|
+
count4 = value.length;
|
|
60311
60361
|
writer.writeValue(value.length);
|
|
60312
60362
|
}
|
|
60313
|
-
assertArgumentCount(value.length,
|
|
60363
|
+
assertArgumentCount(value.length, count4, "coder array" + (this.localName ? " " + this.localName : ""));
|
|
60314
60364
|
let coders = [];
|
|
60315
60365
|
for (let i = 0; i < value.length; i++) {
|
|
60316
60366
|
coders.push(this.coder);
|
|
@@ -60318,13 +60368,13 @@ var init_array = __esm({
|
|
|
60318
60368
|
return pack(writer, coders, value);
|
|
60319
60369
|
}
|
|
60320
60370
|
decode(reader) {
|
|
60321
|
-
let
|
|
60322
|
-
if (
|
|
60323
|
-
|
|
60324
|
-
assert2(
|
|
60371
|
+
let count4 = this.length;
|
|
60372
|
+
if (count4 === -1) {
|
|
60373
|
+
count4 = reader.readIndex();
|
|
60374
|
+
assert2(count4 * WordSize <= reader.dataLength, "insufficient data length", "BUFFER_OVERRUN", { buffer: reader.bytes, offset: count4 * WordSize, length: reader.dataLength });
|
|
60325
60375
|
}
|
|
60326
60376
|
let coders = [];
|
|
60327
|
-
for (let i = 0; i <
|
|
60377
|
+
for (let i = 0; i < count4; i++) {
|
|
60328
60378
|
coders.push(new AnonymousCoder(this.coder));
|
|
60329
60379
|
}
|
|
60330
60380
|
return unpack(reader, coders);
|
|
@@ -62891,8 +62941,8 @@ function _pack(type, value, isArray) {
|
|
|
62891
62941
|
match = type.match(regexArray);
|
|
62892
62942
|
if (match && Array.isArray(value)) {
|
|
62893
62943
|
const baseType = match[1];
|
|
62894
|
-
const
|
|
62895
|
-
assertArgument(
|
|
62944
|
+
const count4 = parseInt(match[2] || String(value.length));
|
|
62945
|
+
assertArgument(count4 === value.length, `invalid array length for ${type}`, "value", value);
|
|
62896
62946
|
const result2 = [];
|
|
62897
62947
|
value.forEach(function(value2) {
|
|
62898
62948
|
result2.push(_pack(baseType, value2, true));
|
|
@@ -67794,7 +67844,7 @@ async function _emit(contract, event, args, payloadFunc) {
|
|
|
67794
67844
|
if (!sub) {
|
|
67795
67845
|
return false;
|
|
67796
67846
|
}
|
|
67797
|
-
const
|
|
67847
|
+
const count4 = sub.listeners.length;
|
|
67798
67848
|
sub.listeners = sub.listeners.filter(({ listener, once: once2 }) => {
|
|
67799
67849
|
const passArgs = Array.from(args);
|
|
67800
67850
|
if (payloadFunc) {
|
|
@@ -67810,7 +67860,7 @@ async function _emit(contract, event, args, payloadFunc) {
|
|
|
67810
67860
|
sub.stop();
|
|
67811
67861
|
getInternal(contract).subs.delete(sub.tag);
|
|
67812
67862
|
}
|
|
67813
|
-
return
|
|
67863
|
+
return count4 > 0;
|
|
67814
67864
|
}
|
|
67815
67865
|
async function emit(contract, event, args, payloadFunc) {
|
|
67816
67866
|
try {
|
|
@@ -71029,7 +71079,7 @@ var init_abstract_provider = __esm({
|
|
|
71029
71079
|
return false;
|
|
71030
71080
|
}
|
|
71031
71081
|
;
|
|
71032
|
-
const
|
|
71082
|
+
const count4 = sub.listeners.length;
|
|
71033
71083
|
sub.listeners = sub.listeners.filter(({ listener, once: once2 }) => {
|
|
71034
71084
|
const payload = new EventPayload(this, once2 ? null : listener, event);
|
|
71035
71085
|
try {
|
|
@@ -71044,7 +71094,7 @@ var init_abstract_provider = __esm({
|
|
|
71044
71094
|
}
|
|
71045
71095
|
this.#subs.delete(sub.tag);
|
|
71046
71096
|
}
|
|
71047
|
-
return
|
|
71097
|
+
return count4 > 0;
|
|
71048
71098
|
}
|
|
71049
71099
|
async listenerCount(event) {
|
|
71050
71100
|
if (event) {
|
|
@@ -80024,10 +80074,10 @@ function getDecryptKdfParams(data4) {
|
|
|
80024
80074
|
const prf = spelunk(data4, "crypto.kdfparams.prf:string!");
|
|
80025
80075
|
const algorithm = prf.split("-").pop();
|
|
80026
80076
|
assertArgument(algorithm === "sha256" || algorithm === "sha512", "invalid kdf.pdf", "kdf.pdf", prf);
|
|
80027
|
-
const
|
|
80077
|
+
const count4 = spelunk(data4, "crypto.kdfparams.c:int!");
|
|
80028
80078
|
const dkLen = spelunk(data4, "crypto.kdfparams.dklen:int!");
|
|
80029
80079
|
assertArgument(dkLen === 32, "invalid kdf.dklen", "kdf.dklen", dkLen);
|
|
80030
|
-
return { name: "pbkdf2", salt, count:
|
|
80080
|
+
return { name: "pbkdf2", salt, count: count4, dkLen, algorithm };
|
|
80031
80081
|
}
|
|
80032
80082
|
}
|
|
80033
80083
|
assertArgument(false, "unsupported key-derivation function", "kdf", kdf);
|
|
@@ -80037,8 +80087,8 @@ function decryptKeystoreJsonSync(json2, _password) {
|
|
|
80037
80087
|
const password = getPassword(_password);
|
|
80038
80088
|
const params = getDecryptKdfParams(data4);
|
|
80039
80089
|
if (params.name === "pbkdf2") {
|
|
80040
|
-
const { salt: salt2, count:
|
|
80041
|
-
const key2 = pbkdf2(password, salt2,
|
|
80090
|
+
const { salt: salt2, count: count4, dkLen: dkLen2, algorithm } = params;
|
|
80091
|
+
const key2 = pbkdf2(password, salt2, count4, dkLen2, algorithm);
|
|
80042
80092
|
return getAccount(data4, key2);
|
|
80043
80093
|
}
|
|
80044
80094
|
assert2(params.name === "scrypt", "cannot be reached", "UNKNOWN_ERROR", { params });
|
|
@@ -80062,8 +80112,8 @@ async function decryptKeystoreJson(json2, _password, progress) {
|
|
|
80062
80112
|
progress(0);
|
|
80063
80113
|
await stall3(0);
|
|
80064
80114
|
}
|
|
80065
|
-
const { salt: salt2, count:
|
|
80066
|
-
const key2 = pbkdf2(password, salt2,
|
|
80115
|
+
const { salt: salt2, count: count4, dkLen: dkLen2, algorithm } = params;
|
|
80116
|
+
const key2 = pbkdf2(password, salt2, count4, dkLen2, algorithm);
|
|
80067
80117
|
if (progress) {
|
|
80068
80118
|
progress(1);
|
|
80069
80119
|
await stall3(0);
|
|
@@ -84394,8 +84444,8 @@ var init_hyperliquid_client = __esm({
|
|
|
84394
84444
|
if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
|
|
84395
84445
|
return { referenceSourceKind: "l2_unavailable" };
|
|
84396
84446
|
}
|
|
84397
|
-
const
|
|
84398
|
-
const observedMs = Number(
|
|
84447
|
+
const record5 = payload;
|
|
84448
|
+
const observedMs = Number(record5.time);
|
|
84399
84449
|
const nowMs = Date.now();
|
|
84400
84450
|
const referenceAgeMs = Number.isFinite(observedMs) ? Math.max(0, nowMs - observedMs) : null;
|
|
84401
84451
|
const referenceObservedAt = Number.isFinite(observedMs) ? new Date(observedMs).toISOString() : null;
|
|
@@ -84406,7 +84456,7 @@ var init_hyperliquid_client = __esm({
|
|
|
84406
84456
|
referenceAgeMs
|
|
84407
84457
|
};
|
|
84408
84458
|
}
|
|
84409
|
-
const levels = Array.isArray(
|
|
84459
|
+
const levels = Array.isArray(record5.levels) ? record5.levels : [];
|
|
84410
84460
|
const bids = Array.isArray(levels[0]) ? levels[0] : [];
|
|
84411
84461
|
const asks = Array.isArray(levels[1]) ? levels[1] : [];
|
|
84412
84462
|
const levelPrice = (value) => {
|
|
@@ -85028,12 +85078,12 @@ function validateDeviceSecrets(value, options) {
|
|
|
85028
85078
|
missing: missing3
|
|
85029
85079
|
};
|
|
85030
85080
|
}
|
|
85031
|
-
const
|
|
85032
|
-
const rawProviderKeys =
|
|
85081
|
+
const record5 = value;
|
|
85082
|
+
const rawProviderKeys = record5.providerKeys && typeof record5.providerKeys === "object" ? record5.providerKeys : {};
|
|
85033
85083
|
const providerKeys = Object.fromEntries(
|
|
85034
85084
|
Object.entries(rawProviderKeys).map(([provider, key]) => [provider, typeof key === "string" ? key.trim() : ""]).filter(([, key]) => Boolean(key))
|
|
85035
85085
|
);
|
|
85036
|
-
const rawProviderKeySlots =
|
|
85086
|
+
const rawProviderKeySlots = record5.providerKeySlots && typeof record5.providerKeySlots === "object" ? record5.providerKeySlots : {};
|
|
85037
85087
|
const providerKeySlots = Object.fromEntries(
|
|
85038
85088
|
Object.entries(rawProviderKeySlots).map(([provider, value2]) => {
|
|
85039
85089
|
const slots = Array.isArray(value2) ? value2.map((key) => typeof key === "string" ? key.trim() : "").filter(Boolean) : [];
|
|
@@ -85046,27 +85096,27 @@ function validateDeviceSecrets(value, options) {
|
|
|
85046
85096
|
Object.entries(providerKeySlots).map(([provider, slots]) => [provider, slots[0]]).filter(([, key]) => Boolean(key))
|
|
85047
85097
|
)
|
|
85048
85098
|
};
|
|
85049
|
-
const rawProviderBaseUrls =
|
|
85099
|
+
const rawProviderBaseUrls = record5.providerBaseUrls && typeof record5.providerBaseUrls === "object" ? record5.providerBaseUrls : {};
|
|
85050
85100
|
const providerBaseUrls = Object.fromEntries(
|
|
85051
85101
|
Object.entries(rawProviderBaseUrls).map(([provider, baseUrl]) => [provider, typeof baseUrl === "string" ? baseUrl.trim() : ""]).filter(([, baseUrl]) => Boolean(baseUrl))
|
|
85052
85102
|
);
|
|
85053
|
-
const rawProviderBaseUrlSlots =
|
|
85103
|
+
const rawProviderBaseUrlSlots = record5.providerBaseUrlSlots && typeof record5.providerBaseUrlSlots === "object" ? record5.providerBaseUrlSlots : {};
|
|
85054
85104
|
const providerBaseUrlSlots = Object.fromEntries(
|
|
85055
85105
|
Object.entries(rawProviderBaseUrlSlots).map(([provider, value2]) => {
|
|
85056
85106
|
const slots = Array.isArray(value2) ? value2.map((baseUrl) => typeof baseUrl === "string" ? baseUrl.trim() : "") : [];
|
|
85057
85107
|
return [provider, slots];
|
|
85058
85108
|
}).filter(([, slots]) => slots.some(Boolean))
|
|
85059
85109
|
);
|
|
85060
|
-
const storage = normalizeDeviceSecretStorage(
|
|
85061
|
-
const hyperliquidSigningKey = typeof
|
|
85062
|
-
const rawLocalAi =
|
|
85110
|
+
const storage = normalizeDeviceSecretStorage(record5.storage);
|
|
85111
|
+
const hyperliquidSigningKey = typeof record5.hyperliquidSigningKey === "string" ? record5.hyperliquidSigningKey.trim() || void 0 : void 0;
|
|
85112
|
+
const rawLocalAi = record5.localAi && typeof record5.localAi === "object" ? record5.localAi : {};
|
|
85063
85113
|
const localAi = normalizeLocalAiSecrets({
|
|
85064
85114
|
baseUrl: typeof rawLocalAi.baseUrl === "string" ? rawLocalAi.baseUrl : "",
|
|
85065
85115
|
modelName: typeof rawLocalAi.modelName === "string" ? rawLocalAi.modelName : "",
|
|
85066
85116
|
apiKey: typeof rawLocalAi.apiKey === "string" ? rawLocalAi.apiKey : "",
|
|
85067
85117
|
serverType: rawLocalAi.serverType === "ollama-native" ? "ollama-native" : rawLocalAi.serverType === "openai-compatible" ? "openai-compatible" : void 0
|
|
85068
85118
|
});
|
|
85069
|
-
const rawOpenAiCompatible =
|
|
85119
|
+
const rawOpenAiCompatible = record5.openaiCompatible && typeof record5.openaiCompatible === "object" ? record5.openaiCompatible : {};
|
|
85070
85120
|
const openaiCompatible = normalizeOpenAiCompatibleSecrets({
|
|
85071
85121
|
baseUrl: typeof rawOpenAiCompatible.baseUrl === "string" ? rawOpenAiCompatible.baseUrl : "",
|
|
85072
85122
|
modelName: typeof rawOpenAiCompatible.modelName === "string" ? rawOpenAiCompatible.modelName : "",
|
|
@@ -85316,10 +85366,10 @@ var init_vault = __esm({
|
|
|
85316
85366
|
};
|
|
85317
85367
|
};
|
|
85318
85368
|
normalizeDeviceSecretStorage = (value) => {
|
|
85319
|
-
const
|
|
85369
|
+
const record5 = value && typeof value === "object" ? value : {};
|
|
85320
85370
|
return {
|
|
85321
|
-
byok:
|
|
85322
|
-
hyperliquid:
|
|
85371
|
+
byok: record5.byok === "device" ? "device" : "server",
|
|
85372
|
+
hyperliquid: record5.hyperliquid === "device" ? "device" : "server"
|
|
85323
85373
|
};
|
|
85324
85374
|
};
|
|
85325
85375
|
normalizeLocalAiSecrets = (value) => {
|
|
@@ -86322,15 +86372,15 @@ var init_runtime_execution = __esm({
|
|
|
86322
86372
|
}
|
|
86323
86373
|
return null;
|
|
86324
86374
|
}
|
|
86325
|
-
const
|
|
86326
|
-
const direct =
|
|
86375
|
+
const record5 = node;
|
|
86376
|
+
const direct = record5.oid ?? record5.orderId ?? record5.order_id;
|
|
86327
86377
|
if (direct != null) {
|
|
86328
86378
|
const parsed = String(direct).trim();
|
|
86329
86379
|
if (parsed.length > 0) {
|
|
86330
86380
|
return parsed;
|
|
86331
86381
|
}
|
|
86332
86382
|
}
|
|
86333
|
-
for (const child of Object.values(
|
|
86383
|
+
for (const child of Object.values(record5)) {
|
|
86334
86384
|
const found = walk(child);
|
|
86335
86385
|
if (found) {
|
|
86336
86386
|
return found;
|
|
@@ -86406,19 +86456,19 @@ var init_runtime_execution = __esm({
|
|
|
86406
86456
|
if (!entry || typeof entry !== "object" || Array.isArray(entry)) {
|
|
86407
86457
|
return [];
|
|
86408
86458
|
}
|
|
86409
|
-
const
|
|
86410
|
-
const orderId = Math.trunc(Number(
|
|
86411
|
-
const triggerPrice = Number(
|
|
86412
|
-
const size = Number(
|
|
86413
|
-
if (!Number.isSafeInteger(orderId) || orderId <= 0 || !Number.isFinite(triggerPrice) || triggerPrice <= 0 || !Number.isFinite(size) || size <= 0 || typeof
|
|
86459
|
+
const record5 = entry;
|
|
86460
|
+
const orderId = Math.trunc(Number(record5.orderId));
|
|
86461
|
+
const triggerPrice = Number(record5.triggerPrice);
|
|
86462
|
+
const size = Number(record5.size);
|
|
86463
|
+
if (!Number.isSafeInteger(orderId) || orderId <= 0 || !Number.isFinite(triggerPrice) || triggerPrice <= 0 || !Number.isFinite(size) || size <= 0 || typeof record5.isLong !== "boolean") {
|
|
86414
86464
|
return [];
|
|
86415
86465
|
}
|
|
86416
86466
|
return [{
|
|
86417
86467
|
orderId,
|
|
86418
86468
|
triggerPrice,
|
|
86419
86469
|
size,
|
|
86420
|
-
isLong:
|
|
86421
|
-
positionTpsl:
|
|
86470
|
+
isLong: record5.isLong,
|
|
86471
|
+
positionTpsl: record5.positionTpsl === true
|
|
86422
86472
|
}];
|
|
86423
86473
|
});
|
|
86424
86474
|
};
|
|
@@ -86444,11 +86494,11 @@ var init_runtime_execution = __esm({
|
|
|
86444
86494
|
}
|
|
86445
86495
|
}
|
|
86446
86496
|
};
|
|
86447
|
-
rememberTrailingStop = (profileId, symbol2,
|
|
86497
|
+
rememberTrailingStop = (profileId, symbol2, record5) => {
|
|
86448
86498
|
const records = readTrackedTrailingStops(profileId, symbol2);
|
|
86449
86499
|
writeTrackedTrailingStops(profileId, symbol2, [
|
|
86450
|
-
...records.filter((candidate) => candidate.orderId !==
|
|
86451
|
-
|
|
86500
|
+
...records.filter((candidate) => candidate.orderId !== record5.orderId),
|
|
86501
|
+
record5
|
|
86452
86502
|
]);
|
|
86453
86503
|
};
|
|
86454
86504
|
protectiveGroupStorageKey = (profileId, symbol2) => `vtx:auto-protective-group:${profileId}:${symbol2}`;
|
|
@@ -86476,16 +86526,16 @@ var init_runtime_execution = __esm({
|
|
|
86476
86526
|
protectiveGroupReadFailures.add(key);
|
|
86477
86527
|
return [];
|
|
86478
86528
|
}
|
|
86479
|
-
const
|
|
86480
|
-
const entryOrderId = String(
|
|
86481
|
-
const storedProfileId = String(
|
|
86482
|
-
const storedSymbol = String(
|
|
86483
|
-
const walletAddress = String(
|
|
86484
|
-
if (
|
|
86529
|
+
const record5 = entry;
|
|
86530
|
+
const entryOrderId = String(record5.entryOrderId ?? "").trim();
|
|
86531
|
+
const storedProfileId = String(record5.profileId ?? "").trim();
|
|
86532
|
+
const storedSymbol = String(record5.symbol ?? "").trim().toUpperCase();
|
|
86533
|
+
const walletAddress = String(record5.walletAddress ?? "").trim().toLowerCase();
|
|
86534
|
+
if (record5.version !== 1 && record5.version !== 2 || storedProfileId !== profileId || storedSymbol !== symbol2.trim().toUpperCase() || !walletAddress || !entryOrderId || typeof record5.isLong !== "boolean" || !Array.isArray(record5.legs)) {
|
|
86485
86535
|
protectiveGroupReadFailures.add(key);
|
|
86486
86536
|
return [];
|
|
86487
86537
|
}
|
|
86488
|
-
const legs =
|
|
86538
|
+
const legs = record5.legs.flatMap((leg) => {
|
|
86489
86539
|
if (leg == null || typeof leg !== "object" || Array.isArray(leg)) {
|
|
86490
86540
|
protectiveGroupReadFailures.add(key);
|
|
86491
86541
|
return [];
|
|
@@ -86535,7 +86585,7 @@ var init_runtime_execution = __esm({
|
|
|
86535
86585
|
...replacement ? { replacement } : {}
|
|
86536
86586
|
}];
|
|
86537
86587
|
});
|
|
86538
|
-
const pendingRecord =
|
|
86588
|
+
const pendingRecord = record5.pendingEntry;
|
|
86539
86589
|
let pendingEntry;
|
|
86540
86590
|
if (pendingRecord != null) {
|
|
86541
86591
|
if (pendingRecord == null || typeof pendingRecord !== "object" || Array.isArray(pendingRecord)) {
|
|
@@ -86573,7 +86623,7 @@ var init_runtime_execution = __esm({
|
|
|
86573
86623
|
}
|
|
86574
86624
|
};
|
|
86575
86625
|
}
|
|
86576
|
-
const attachmentRecord =
|
|
86626
|
+
const attachmentRecord = record5.attachmentJournal;
|
|
86577
86627
|
let attachmentJournal;
|
|
86578
86628
|
if (attachmentRecord != null) {
|
|
86579
86629
|
if (attachmentRecord == null || typeof attachmentRecord !== "object" || Array.isArray(attachmentRecord)) {
|
|
@@ -86632,8 +86682,8 @@ var init_runtime_execution = __esm({
|
|
|
86632
86682
|
symbol: storedSymbol,
|
|
86633
86683
|
walletAddress,
|
|
86634
86684
|
entryOrderId,
|
|
86635
|
-
isLong:
|
|
86636
|
-
cleanupRequired:
|
|
86685
|
+
isLong: record5.isLong,
|
|
86686
|
+
cleanupRequired: record5.cleanupRequired === true,
|
|
86637
86687
|
legs,
|
|
86638
86688
|
...pendingEntry ? { pendingEntry } : {},
|
|
86639
86689
|
...attachmentJournal ? { attachmentJournal } : {}
|
|
@@ -86913,11 +86963,11 @@ var init_runtime_execution = __esm({
|
|
|
86913
86963
|
writeTrackedTrailingStops(
|
|
86914
86964
|
profileId,
|
|
86915
86965
|
symbol2,
|
|
86916
|
-
readTrackedTrailingStops(profileId, symbol2).filter((
|
|
86966
|
+
readTrackedTrailingStops(profileId, symbol2).filter((record5) => record5.orderId !== orderId)
|
|
86917
86967
|
);
|
|
86918
86968
|
};
|
|
86919
86969
|
replaceTrackedTrailingStop = (profileId, symbol2, previousOrderId, replacement) => {
|
|
86920
|
-
const retained = readTrackedTrailingStops(profileId, symbol2).filter((
|
|
86970
|
+
const retained = readTrackedTrailingStops(profileId, symbol2).filter((record5) => record5.orderId !== previousOrderId);
|
|
86921
86971
|
writeTrackedTrailingStops(
|
|
86922
86972
|
profileId,
|
|
86923
86973
|
symbol2,
|
|
@@ -89702,49 +89752,49 @@ var init_runtime_execution = __esm({
|
|
|
89702
89752
|
}
|
|
89703
89753
|
liveOrders = fetchedOrders;
|
|
89704
89754
|
} catch (error48) {
|
|
89705
|
-
return tracked.map((
|
|
89706
|
-
order_id: String(
|
|
89755
|
+
return tracked.map((record5) => ({
|
|
89756
|
+
order_id: String(record5.orderId),
|
|
89707
89757
|
symbol: symbol2,
|
|
89708
89758
|
action: "AUTO_TRAILING_SL",
|
|
89709
89759
|
status: "failed",
|
|
89710
89760
|
execution_metadata: {
|
|
89711
|
-
trigger_price:
|
|
89761
|
+
trigger_price: record5.triggerPrice,
|
|
89712
89762
|
error: `Unable to verify the tracked exchange stop: ${error48 instanceof Error ? error48.message : String(error48)}`
|
|
89713
89763
|
}
|
|
89714
89764
|
}));
|
|
89715
89765
|
}
|
|
89716
89766
|
const eligible = [];
|
|
89717
89767
|
const retained = [];
|
|
89718
|
-
for (const
|
|
89719
|
-
if (
|
|
89768
|
+
for (const record5 of tracked) {
|
|
89769
|
+
if (record5.isLong !== isLong) {
|
|
89720
89770
|
continue;
|
|
89721
89771
|
}
|
|
89722
|
-
const liveOrder = liveOrders.find((order) => order.oid ===
|
|
89772
|
+
const liveOrder = liveOrders.find((order) => order.oid === record5.orderId);
|
|
89723
89773
|
if (!liveOrder) {
|
|
89724
|
-
retained.push(
|
|
89774
|
+
retained.push(record5);
|
|
89725
89775
|
continue;
|
|
89726
89776
|
}
|
|
89727
89777
|
const triggerPrice = Number(liveOrder.trigger_px);
|
|
89728
89778
|
const size = Number(liveOrder.sz);
|
|
89729
89779
|
const liveSide = String(liveOrder.side).trim().toLowerCase();
|
|
89730
|
-
const isTrustedProtectiveOrder = String(liveOrder.coin).trim().toUpperCase() === symbol2.trim().toUpperCase() && (isLong ? liveSide === "a" || liveSide === "sell" : liveSide === "b" || liveSide === "buy") && liveOrder.reduce_only && liveOrder.is_trigger && liveOrder.trigger_kind === "sl" && liveOrder.is_position_tpsl ===
|
|
89731
|
-
if (isTrustedProtectiveOrder && triggerPrice ===
|
|
89732
|
-
eligible.push(
|
|
89780
|
+
const isTrustedProtectiveOrder = String(liveOrder.coin).trim().toUpperCase() === symbol2.trim().toUpperCase() && (isLong ? liveSide === "a" || liveSide === "sell" : liveSide === "b" || liveSide === "buy") && liveOrder.reduce_only && liveOrder.is_trigger && liveOrder.trigger_kind === "sl" && liveOrder.is_position_tpsl === record5.positionTpsl && Number.isFinite(size) && size > 0 && Number.isFinite(triggerPrice) && triggerPrice > 0;
|
|
89781
|
+
if (isTrustedProtectiveOrder && triggerPrice === record5.triggerPrice && size === record5.size) {
|
|
89782
|
+
eligible.push(record5);
|
|
89733
89783
|
} else {
|
|
89734
|
-
retained.push(
|
|
89784
|
+
retained.push(record5);
|
|
89735
89785
|
}
|
|
89736
89786
|
}
|
|
89737
89787
|
const reports = [];
|
|
89738
89788
|
const updated = [...retained];
|
|
89739
89789
|
let remainingExposure = Math.abs(currentPositionSize);
|
|
89740
|
-
for (const
|
|
89790
|
+
for (const record5 of eligible) {
|
|
89741
89791
|
const effectiveSize = roundAssetSize(
|
|
89742
|
-
Math.min(
|
|
89792
|
+
Math.min(record5.size, remainingExposure),
|
|
89743
89793
|
request.executionContext.sizeDecimals
|
|
89744
89794
|
);
|
|
89745
89795
|
remainingExposure = Math.max(0, remainingExposure - effectiveSize);
|
|
89746
89796
|
if (!Number.isFinite(effectiveSize) || effectiveSize <= 0) {
|
|
89747
|
-
const trackedLeg = readClientProtectiveGroups(profileId, symbol2).flatMap((group) => group.legs).find((leg) => leg.orderId ===
|
|
89797
|
+
const trackedLeg = readClientProtectiveGroups(profileId, symbol2).flatMap((group) => group.legs).find((leg) => leg.orderId === record5.orderId);
|
|
89748
89798
|
if (trackedLeg) {
|
|
89749
89799
|
const report = await cancelClientProtectiveLeg(
|
|
89750
89800
|
request,
|
|
@@ -89754,19 +89804,19 @@ var init_runtime_execution = __esm({
|
|
|
89754
89804
|
);
|
|
89755
89805
|
reports.push(report);
|
|
89756
89806
|
if (report.status === "executed") {
|
|
89757
|
-
replaceProtectiveLeg(profileId, symbol2,
|
|
89807
|
+
replaceProtectiveLeg(profileId, symbol2, record5.orderId, null);
|
|
89758
89808
|
} else {
|
|
89759
|
-
updated.push(
|
|
89809
|
+
updated.push(record5);
|
|
89760
89810
|
}
|
|
89761
89811
|
} else {
|
|
89762
|
-
updated.push(
|
|
89812
|
+
updated.push(record5);
|
|
89763
89813
|
reports.push({
|
|
89764
|
-
order_id: String(
|
|
89814
|
+
order_id: String(record5.orderId),
|
|
89765
89815
|
symbol: symbol2,
|
|
89766
89816
|
action: "AUTO_TRAILING_SL",
|
|
89767
89817
|
status: "failed",
|
|
89768
89818
|
execution_metadata: {
|
|
89769
|
-
trigger_price:
|
|
89819
|
+
trigger_price: record5.triggerPrice,
|
|
89770
89820
|
reason_code: "protective_order_shape_unresolved"
|
|
89771
89821
|
}
|
|
89772
89822
|
});
|
|
@@ -89784,42 +89834,42 @@ var init_runtime_execution = __esm({
|
|
|
89784
89834
|
rawCandidatePrice,
|
|
89785
89835
|
request.executionContext.sizeDecimals
|
|
89786
89836
|
)) : 0;
|
|
89787
|
-
const tightens = candidatePrice > 0 && (isLong ? candidatePrice >
|
|
89837
|
+
const tightens = candidatePrice > 0 && (isLong ? candidatePrice > record5.triggerPrice : candidatePrice < record5.triggerPrice);
|
|
89788
89838
|
const canonicalRecordSize = roundAssetSize(
|
|
89789
|
-
|
|
89839
|
+
record5.size,
|
|
89790
89840
|
request.executionContext.sizeDecimals
|
|
89791
89841
|
);
|
|
89792
89842
|
const resizes = effectiveSize !== canonicalRecordSize;
|
|
89793
89843
|
if (!tightens && !resizes) {
|
|
89794
|
-
updated.push(
|
|
89844
|
+
updated.push(record5);
|
|
89795
89845
|
continue;
|
|
89796
89846
|
}
|
|
89797
|
-
const replacementTriggerPrice = tightens ? candidatePrice :
|
|
89847
|
+
const replacementTriggerPrice = tightens ? candidatePrice : record5.triggerPrice;
|
|
89798
89848
|
if (!canPersistClientProtectiveGroups(profileId, symbol2)) {
|
|
89799
|
-
updated.push(
|
|
89849
|
+
updated.push(record5);
|
|
89800
89850
|
reports.push({
|
|
89801
|
-
order_id: String(
|
|
89851
|
+
order_id: String(record5.orderId),
|
|
89802
89852
|
symbol: symbol2,
|
|
89803
89853
|
action: "AUTO_TRAILING_SL",
|
|
89804
89854
|
status: "failed",
|
|
89805
89855
|
execution_metadata: {
|
|
89806
89856
|
trigger_price: replacementTriggerPrice,
|
|
89807
|
-
previous_trigger_price:
|
|
89857
|
+
previous_trigger_price: record5.triggerPrice,
|
|
89808
89858
|
reason_code: "protective_lifecycle_storage_unavailable"
|
|
89809
89859
|
}
|
|
89810
89860
|
});
|
|
89811
89861
|
continue;
|
|
89812
89862
|
}
|
|
89813
89863
|
const currentGroups = readFreshClientProtectiveGroups(profileId, symbol2);
|
|
89814
|
-
const sourceGroups = currentGroups.filter((group) => group.legs.some((leg) => leg.orderId ===
|
|
89864
|
+
const sourceGroups = currentGroups.filter((group) => group.legs.some((leg) => leg.orderId === record5.orderId));
|
|
89815
89865
|
const sourceGroup = sourceGroups.length === 1 ? sourceGroups[0] : null;
|
|
89816
|
-
const previousLeg = sourceGroup?.legs.filter((leg) => leg.orderId ===
|
|
89866
|
+
const previousLeg = sourceGroup?.legs.filter((leg) => leg.orderId === record5.orderId);
|
|
89817
89867
|
const replacementMutationId = createRuntimeId().toLowerCase();
|
|
89818
89868
|
const replacementClientOrderId = `0x${replacementMutationId.replaceAll("-", "")}`;
|
|
89819
89869
|
const replacementIntent = {
|
|
89820
89870
|
mutationId: replacementMutationId,
|
|
89821
89871
|
clientOrderId: replacementClientOrderId,
|
|
89822
|
-
previousOrderId:
|
|
89872
|
+
previousOrderId: record5.orderId,
|
|
89823
89873
|
triggerPrice: replacementTriggerPrice,
|
|
89824
89874
|
size: effectiveSize
|
|
89825
89875
|
};
|
|
@@ -89832,15 +89882,15 @@ var init_runtime_execution = __esm({
|
|
|
89832
89882
|
replacement: replacementIntent
|
|
89833
89883
|
});
|
|
89834
89884
|
if (reservation == null) {
|
|
89835
|
-
updated.push(
|
|
89885
|
+
updated.push(record5);
|
|
89836
89886
|
reports.push({
|
|
89837
|
-
order_id: String(
|
|
89887
|
+
order_id: String(record5.orderId),
|
|
89838
89888
|
symbol: symbol2,
|
|
89839
89889
|
action: "AUTO_TRAILING_SL",
|
|
89840
89890
|
status: "failed",
|
|
89841
89891
|
execution_metadata: {
|
|
89842
89892
|
trigger_price: replacementTriggerPrice,
|
|
89843
|
-
previous_trigger_price:
|
|
89893
|
+
previous_trigger_price: record5.triggerPrice,
|
|
89844
89894
|
reason_code: "protective_replacement_reservation_failed"
|
|
89845
89895
|
}
|
|
89846
89896
|
});
|
|
@@ -89873,7 +89923,7 @@ var init_runtime_execution = __esm({
|
|
|
89873
89923
|
replacementDispatchBoundaryCompleted = true;
|
|
89874
89924
|
},
|
|
89875
89925
|
symbol: symbol2,
|
|
89876
|
-
orderId:
|
|
89926
|
+
orderId: record5.orderId,
|
|
89877
89927
|
side: isLong ? "sell" : "buy",
|
|
89878
89928
|
size: effectiveSize,
|
|
89879
89929
|
limitPrice: replacementTriggerPrice,
|
|
@@ -89888,7 +89938,7 @@ var init_runtime_execution = __esm({
|
|
|
89888
89938
|
const modificationAcknowledgement = extractCanonicalHyperliquidOrderStateAcknowledgement(modifyResponse);
|
|
89889
89939
|
const replacementOrderId = Number(modificationAcknowledgement?.orderId);
|
|
89890
89940
|
if (!Number.isSafeInteger(replacementOrderId) || replacementOrderId <= 0) {
|
|
89891
|
-
updated.push(
|
|
89941
|
+
updated.push(record5);
|
|
89892
89942
|
reports.push({
|
|
89893
89943
|
order_id: null,
|
|
89894
89944
|
symbol: symbol2,
|
|
@@ -89896,7 +89946,7 @@ var init_runtime_execution = __esm({
|
|
|
89896
89946
|
status: "failed",
|
|
89897
89947
|
execution_metadata: {
|
|
89898
89948
|
trigger_price: replacementTriggerPrice,
|
|
89899
|
-
previous_trigger_price:
|
|
89949
|
+
previous_trigger_price: record5.triggerPrice,
|
|
89900
89950
|
error: "Trailing stop replacement did not return a trackable order id."
|
|
89901
89951
|
}
|
|
89902
89952
|
});
|
|
@@ -89946,11 +89996,11 @@ var init_runtime_execution = __esm({
|
|
|
89946
89996
|
triggerPrice: replacementTriggerPrice,
|
|
89947
89997
|
size: effectiveSize,
|
|
89948
89998
|
isLong,
|
|
89949
|
-
positionTpsl:
|
|
89999
|
+
positionTpsl: record5.positionTpsl
|
|
89950
90000
|
};
|
|
89951
90001
|
updated.push(replacementTrailingStop);
|
|
89952
90002
|
} else {
|
|
89953
|
-
removeTrackedTrailingStop(profileId, symbol2,
|
|
90003
|
+
removeTrackedTrailingStop(profileId, symbol2, record5.orderId);
|
|
89954
90004
|
reports.push({
|
|
89955
90005
|
order_id: String(replacementOrderId),
|
|
89956
90006
|
symbol: symbol2,
|
|
@@ -89970,8 +90020,8 @@ var init_runtime_execution = __esm({
|
|
|
89970
90020
|
status: "executed",
|
|
89971
90021
|
execution_metadata: {
|
|
89972
90022
|
trigger_price: replacementTriggerPrice,
|
|
89973
|
-
previous_trigger_price:
|
|
89974
|
-
previous_order_id:
|
|
90023
|
+
previous_trigger_price: record5.triggerPrice,
|
|
90024
|
+
previous_order_id: record5.orderId
|
|
89975
90025
|
}
|
|
89976
90026
|
});
|
|
89977
90027
|
} catch (error48) {
|
|
@@ -89987,16 +90037,16 @@ var init_runtime_execution = __esm({
|
|
|
89987
90037
|
throw error48;
|
|
89988
90038
|
}
|
|
89989
90039
|
if (!canonicalCleanupRetained) {
|
|
89990
|
-
updated.push(
|
|
90040
|
+
updated.push(record5);
|
|
89991
90041
|
}
|
|
89992
90042
|
reports.push({
|
|
89993
|
-
order_id: String(
|
|
90043
|
+
order_id: String(record5.orderId),
|
|
89994
90044
|
symbol: symbol2,
|
|
89995
90045
|
action: "AUTO_TRAILING_SL",
|
|
89996
90046
|
status: "failed",
|
|
89997
90047
|
execution_metadata: {
|
|
89998
90048
|
trigger_price: candidatePrice,
|
|
89999
|
-
previous_trigger_price:
|
|
90049
|
+
previous_trigger_price: record5.triggerPrice,
|
|
90000
90050
|
error: error48 instanceof Error ? error48.message : String(error48)
|
|
90001
90051
|
}
|
|
90002
90052
|
});
|
|
@@ -91336,6 +91386,54 @@ var init_runtime_execution = __esm({
|
|
|
91336
91386
|
}
|
|
91337
91387
|
});
|
|
91338
91388
|
|
|
91389
|
+
// lib/runtime/provider-observability.ts
|
|
91390
|
+
var record4, identifier, count3, normalizeProviderDiagnostics;
|
|
91391
|
+
var init_provider_observability = __esm({
|
|
91392
|
+
"lib/runtime/provider-observability.ts"() {
|
|
91393
|
+
"use strict";
|
|
91394
|
+
init_define_VTX_EXO_POLICY();
|
|
91395
|
+
init_define_VTX_GROK_POLICY();
|
|
91396
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
91397
|
+
record4 = (v) => v !== null && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
91398
|
+
identifier = (v) => typeof v === "string" && /^[A-Za-z0-9][A-Za-z0-9_.:/-]{0,255}$/.test(v) ? v : void 0;
|
|
91399
|
+
count3 = (v) => {
|
|
91400
|
+
if (typeof v !== "number" && (typeof v !== "string" || !v.trim())) return void 0;
|
|
91401
|
+
const n2 = Number(v);
|
|
91402
|
+
return Number.isFinite(n2) && n2 >= 0 && n2 <= Number.MAX_SAFE_INTEGER ? n2 : void 0;
|
|
91403
|
+
};
|
|
91404
|
+
normalizeProviderDiagnostics = (value) => {
|
|
91405
|
+
const raw = record4(value);
|
|
91406
|
+
const result2 = {};
|
|
91407
|
+
for (const key of ["retry_after_seconds", "retry_delay_seconds"]) {
|
|
91408
|
+
const n2 = count3(raw[key]);
|
|
91409
|
+
if (n2 !== void 0) result2[key] = n2;
|
|
91410
|
+
}
|
|
91411
|
+
if (typeof raw.credential_ref === "string" && /^[a-f0-9]{64}$/.test(raw.credential_ref)) result2.credential_ref = raw.credential_ref;
|
|
91412
|
+
if (raw.execution_mode === "client" || raw.execution_mode === "server") result2.execution_mode = raw.execution_mode;
|
|
91413
|
+
if (typeof raw.quota_project_ref === "string" && /^[a-f0-9]{64}$/.test(raw.quota_project_ref) && raw.quota_project_source === "provider_quota_subject") {
|
|
91414
|
+
result2.quota_project_ref = raw.quota_project_ref;
|
|
91415
|
+
result2.quota_project_source = "provider_quota_subject";
|
|
91416
|
+
}
|
|
91417
|
+
if (Array.isArray(raw.quota_violations)) {
|
|
91418
|
+
const violations = raw.quota_violations.slice(0, 16).map((item) => {
|
|
91419
|
+
const v = record4(item);
|
|
91420
|
+
const out = {};
|
|
91421
|
+
const metric = identifier(v.metric), id2 = identifier(v.id), value2 = count3(v.value);
|
|
91422
|
+
if (metric) out.metric = metric;
|
|
91423
|
+
if (id2) out.id = id2;
|
|
91424
|
+
if (value2 !== void 0) out.value = value2;
|
|
91425
|
+
const dims = record4(v.dimensions);
|
|
91426
|
+
const model = identifier(dims.model), location = identifier(dims.location);
|
|
91427
|
+
if (model || location) out.dimensions = { ...model ? { model } : {}, ...location ? { location } : {} };
|
|
91428
|
+
return out;
|
|
91429
|
+
}).filter((v) => Object.keys(v).length > 0);
|
|
91430
|
+
if (violations.length) result2.quota_violations = violations;
|
|
91431
|
+
}
|
|
91432
|
+
return result2;
|
|
91433
|
+
};
|
|
91434
|
+
}
|
|
91435
|
+
});
|
|
91436
|
+
|
|
91339
91437
|
// lib/runtime/usage-contract.ts
|
|
91340
91438
|
var PROMPT_TOKEN_KEYS, COMPLETION_TOKEN_KEYS, TOTAL_TOKEN_KEYS, REASONING_TOKEN_KEYS, CACHED_INPUT_TOKEN_KEYS, CACHE_CREATION_INPUT_TOKEN_KEYS, TOOL_USE_TOKEN_KEYS, AUDIO_INPUT_TOKEN_KEYS, AUDIO_OUTPUT_TOKEN_KEYS, BILLABLE_INPUT_TOKEN_KEYS, BILLABLE_OUTPUT_TOKEN_KEYS, BILLABLE_CACHED_INPUT_TOKEN_KEYS, BILLABLE_CACHE_CREATION_INPUT_TOKEN_KEYS, BILLABLE_TOOL_USE_TOKEN_KEYS, MAX_RUNTIME_USAGE_COUNT, PROVIDER_USAGE_DETAIL_KEYS, PROVIDER_USAGE_DETAIL_COUNT_KEY_PATTERN, PROVIDER_USAGE_DETAIL_TEXT_KEYS, MAX_PROVIDER_USAGE_DETAIL_ITEMS, isRecord, coerceOptionalRuntimeUsageCount, readOptionalRuntimeUsageCount, readNestedUsageDetailCount, sanitizeProviderUsageDetail, normalizeUsageProvenance, normalizeRuntimeUsageDetails;
|
|
91341
91439
|
var init_usage_contract = __esm({
|
|
@@ -91441,8 +91539,8 @@ var init_usage_contract = __esm({
|
|
|
91441
91539
|
continue;
|
|
91442
91540
|
}
|
|
91443
91541
|
if (PROVIDER_USAGE_DETAIL_COUNT_KEY_PATTERN.test(key)) {
|
|
91444
|
-
const
|
|
91445
|
-
if (
|
|
91542
|
+
const count4 = coerceOptionalRuntimeUsageCount(rawValue);
|
|
91543
|
+
if (count4 !== null) result2[key] = count4;
|
|
91446
91544
|
}
|
|
91447
91545
|
}
|
|
91448
91546
|
return result2;
|
|
@@ -91654,6 +91752,7 @@ var init_inference_observability = __esm({
|
|
|
91654
91752
|
init_define_VTX_EXO_POLICY();
|
|
91655
91753
|
init_define_VTX_GROK_POLICY();
|
|
91656
91754
|
init_define_VTX_PI_MODEL_POLICY();
|
|
91755
|
+
init_provider_observability();
|
|
91657
91756
|
init_usage_contract();
|
|
91658
91757
|
init_reasoning_observability();
|
|
91659
91758
|
AI_INVOCATION_CONTRACT_VERSION = 2;
|
|
@@ -91795,6 +91894,9 @@ var init_inference_observability = __esm({
|
|
|
91795
91894
|
const useCase = enumValue(source.use_case, USE_CASES, "trader");
|
|
91796
91895
|
const role = enumValue(source.role, ROLES_BY_USE_CASE[useCase], DEFAULT_ROLE[useCase]);
|
|
91797
91896
|
const reasoningContent = safeText(source.reasoning_content);
|
|
91897
|
+
const providerStatus = safeNonNegativeInt(source.provider_status_code);
|
|
91898
|
+
const requestTokensSource = source.request_input_tokens_source === "estimated_chars_v1" || source.request_input_tokens_source === "provider_count" ? source.request_input_tokens_source : null;
|
|
91899
|
+
const requestTokens = requestTokensSource ? safeNonNegativeInt(source.request_input_tokens) : null;
|
|
91798
91900
|
const traceStatus = enumValue(
|
|
91799
91901
|
source.reasoning_trace_status,
|
|
91800
91902
|
TRACE_STATUSES,
|
|
@@ -91856,7 +91958,10 @@ var init_inference_observability = __esm({
|
|
|
91856
91958
|
used_for_final_decision: source.used_for_final_decision === true,
|
|
91857
91959
|
failure_category: safeCode3(source.failure_category),
|
|
91858
91960
|
failure_code: safeCode3(source.failure_code),
|
|
91859
|
-
provider_status_code:
|
|
91961
|
+
provider_status_code: providerStatus !== null && providerStatus >= 100 && providerStatus <= 599 ? providerStatus : null,
|
|
91962
|
+
request_input_tokens: requestTokens,
|
|
91963
|
+
request_input_tokens_source: requestTokens !== null ? requestTokensSource : null,
|
|
91964
|
+
provider_diagnostics: normalizeProviderDiagnostics(source.provider_diagnostics),
|
|
91860
91965
|
retryable: typeof source.retryable === "boolean" ? source.retryable : null,
|
|
91861
91966
|
fallback_from_provider: safeIdentifier(source.fallback_from_provider),
|
|
91862
91967
|
fallback_from_model: safeIdentifier(source.fallback_from_model),
|
|
@@ -91995,6 +92100,7 @@ function buildClientExchangeSnapshot(input) {
|
|
|
91995
92100
|
mark_price: input.accountState.availableToTrade.mark_price ?? null,
|
|
91996
92101
|
account_summary: {
|
|
91997
92102
|
account_value: accountSummary.account_value ?? null,
|
|
92103
|
+
...accountSummary.perp_dex_accounts == null ? {} : { perp_dex_accounts: accountSummary.perp_dex_accounts },
|
|
91998
92104
|
total_margin_used: accountSummary.total_margin_used ?? null,
|
|
91999
92105
|
available_margin: accountSummary.available_margin ?? null,
|
|
92000
92106
|
withdrawable: accountSummary.withdrawable ?? null,
|