@vtxmacro/cli 2026.9.51 → 2026.9.53
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/README.md +5 -3
- package/bin/vtx-service-bootstrap.js +130 -46
- package/bin/vtx-service-launcher.js +1399 -0
- package/bin/vtx.js +819 -565
- 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.53",
|
|
81
81
|
codex_package_name: "@openai/codex",
|
|
82
82
|
codex_version: "0.153.3",
|
|
83
83
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -17849,7 +17849,7 @@ async function syncInferenceDirectory(path, platform = process.platform) {
|
|
|
17849
17849
|
async function replaceAtomicInferencePrivateFile(temporaryPath, destinationPath, options = {}) {
|
|
17850
17850
|
const platform = options.platform ?? process.platform;
|
|
17851
17851
|
const renameFile = options.renameFile ?? rename;
|
|
17852
|
-
const sleep4 = options.sleep ?? ((milliseconds) => new Promise((
|
|
17852
|
+
const sleep4 = options.sleep ?? ((milliseconds) => new Promise((resolve13) => setTimeout(resolve13, milliseconds)));
|
|
17853
17853
|
const maxAttempts = Math.max(1, options.maxAttempts ?? 40);
|
|
17854
17854
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? 25);
|
|
17855
17855
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
@@ -18966,7 +18966,7 @@ var init_credential_store = __esm({
|
|
|
18966
18966
|
}
|
|
18967
18967
|
return;
|
|
18968
18968
|
}
|
|
18969
|
-
await new Promise((
|
|
18969
|
+
await new Promise((resolve13) => {
|
|
18970
18970
|
const terminator = spawn2(
|
|
18971
18971
|
"taskkill.exe",
|
|
18972
18972
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -18984,21 +18984,21 @@ var init_credential_store = __esm({
|
|
|
18984
18984
|
const timer = setTimeout(() => {
|
|
18985
18985
|
terminator.kill("SIGKILL");
|
|
18986
18986
|
child.kill("SIGKILL");
|
|
18987
|
-
|
|
18987
|
+
resolve13();
|
|
18988
18988
|
}, CREDENTIAL_COMMAND_TERMINATION_TIMEOUT_MS);
|
|
18989
18989
|
terminator.once("error", () => {
|
|
18990
18990
|
clearTimeout(timer);
|
|
18991
18991
|
child.kill("SIGKILL");
|
|
18992
|
-
|
|
18992
|
+
resolve13();
|
|
18993
18993
|
});
|
|
18994
18994
|
terminator.once("close", () => {
|
|
18995
18995
|
clearTimeout(timer);
|
|
18996
18996
|
if (child.exitCode === null) child.kill("SIGKILL");
|
|
18997
|
-
|
|
18997
|
+
resolve13();
|
|
18998
18998
|
});
|
|
18999
18999
|
});
|
|
19000
19000
|
};
|
|
19001
|
-
runCredentialCommand = async (command, options) => await new Promise((
|
|
19001
|
+
runCredentialCommand = async (command, options) => await new Promise((resolve13, reject) => {
|
|
19002
19002
|
const timeoutMs = options.timeoutMs ?? DEFAULT_CREDENTIAL_COMMAND_TIMEOUT_MS;
|
|
19003
19003
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1) {
|
|
19004
19004
|
reject(new Error("OS credential command timeout must be a positive integer."));
|
|
@@ -19057,7 +19057,7 @@ var init_credential_store = __esm({
|
|
|
19057
19057
|
const transformedStdout = normalizedExitCode === 0 ? command.transformStdout?.(stdout) ?? stdout : stdout;
|
|
19058
19058
|
settled = true;
|
|
19059
19059
|
cleanup();
|
|
19060
|
-
|
|
19060
|
+
resolve13({
|
|
19061
19061
|
exitCode: normalizedExitCode,
|
|
19062
19062
|
stdout: transformedStdout
|
|
19063
19063
|
});
|
|
@@ -20214,11 +20214,11 @@ async function revokeInferenceCredential(options) {
|
|
|
20214
20214
|
}
|
|
20215
20215
|
}
|
|
20216
20216
|
async function listenLoopback(server) {
|
|
20217
|
-
await new Promise((
|
|
20217
|
+
await new Promise((resolve13, reject) => {
|
|
20218
20218
|
server.once("error", reject);
|
|
20219
20219
|
server.listen(0, CALLBACK_HOST, () => {
|
|
20220
20220
|
server.off("error", reject);
|
|
20221
|
-
|
|
20221
|
+
resolve13();
|
|
20222
20222
|
});
|
|
20223
20223
|
});
|
|
20224
20224
|
const address = server.address();
|
|
@@ -20229,7 +20229,7 @@ async function listenLoopback(server) {
|
|
|
20229
20229
|
}
|
|
20230
20230
|
async function closeServer(server) {
|
|
20231
20231
|
if (!server.listening) return;
|
|
20232
|
-
await new Promise((
|
|
20232
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
20233
20233
|
}
|
|
20234
20234
|
async function beginInferenceOAuthLogin(options) {
|
|
20235
20235
|
const loginTimeoutMs = options.timeoutMs ?? 6e5;
|
|
@@ -20285,7 +20285,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
20285
20285
|
});
|
|
20286
20286
|
let settled = false;
|
|
20287
20287
|
let rejectCompletion;
|
|
20288
|
-
const completion = new Promise((
|
|
20288
|
+
const completion = new Promise((resolve13, reject) => {
|
|
20289
20289
|
rejectCompletion = reject;
|
|
20290
20290
|
handler = async (requestUrl, method, writeResponse) => {
|
|
20291
20291
|
if (settled) {
|
|
@@ -20360,7 +20360,7 @@ async function beginInferenceOAuthLogin(options) {
|
|
|
20360
20360
|
'<!doctype html><html><head><meta charset="utf-8"><title>VTX authorization complete</title></head><body><main><h1>VTX authorization complete</h1><p>The VTX CLI received your approval. You can close this tab and return to the terminal.</p></main></body></html>'
|
|
20361
20361
|
);
|
|
20362
20362
|
await closeServer(server);
|
|
20363
|
-
|
|
20363
|
+
resolve13({
|
|
20364
20364
|
accessToken: tokens.accessToken,
|
|
20365
20365
|
expiresIn: tokens.expiresIn,
|
|
20366
20366
|
credential,
|
|
@@ -20541,6 +20541,14 @@ var init_runtime_policy_generated = __esm({
|
|
|
20541
20541
|
host_liveness_heartbeat_interval_ms: 3e4,
|
|
20542
20542
|
host_liveness_recovery_nudge_ttl_ms: 1e4
|
|
20543
20543
|
}
|
|
20544
|
+
},
|
|
20545
|
+
server_runtime: {
|
|
20546
|
+
prompt_rescue: {
|
|
20547
|
+
client_long_poll_seconds: 20,
|
|
20548
|
+
client_claim_http_timeout_milliseconds: 25e3,
|
|
20549
|
+
client_presence_heartbeat_interval_milliseconds: 3e4,
|
|
20550
|
+
client_presence_http_timeout_milliseconds: 5e3
|
|
20551
|
+
}
|
|
20544
20552
|
}
|
|
20545
20553
|
}
|
|
20546
20554
|
},
|
|
@@ -20548,6 +20556,8 @@ var init_runtime_policy_generated = __esm({
|
|
|
20548
20556
|
service: {
|
|
20549
20557
|
update_check_interval_ms: 3e5,
|
|
20550
20558
|
update_registry_timeout_ms: 15e3,
|
|
20559
|
+
bootstrap_readiness_timeout_ms: 6e5,
|
|
20560
|
+
bootstrap_stop_timeout_ms: 1e4,
|
|
20551
20561
|
startup_max_attempts: 40,
|
|
20552
20562
|
startup_poll_interval_ms: 250,
|
|
20553
20563
|
restart_stable_uptime_ms: 6e4,
|
|
@@ -20583,7 +20593,7 @@ var init_runtime_policy_generated = __esm({
|
|
|
20583
20593
|
exchange: {
|
|
20584
20594
|
hyperliquid: {
|
|
20585
20595
|
client_public_read_budget: {
|
|
20586
|
-
max_weight:
|
|
20596
|
+
max_weight: 1200,
|
|
20587
20597
|
window_seconds: 60,
|
|
20588
20598
|
cooldown_seconds: 60,
|
|
20589
20599
|
metadata_ttl_seconds: 300,
|
|
@@ -20594,6 +20604,7 @@ var init_runtime_policy_generated = __esm({
|
|
|
20594
20604
|
},
|
|
20595
20605
|
read_budget: {
|
|
20596
20606
|
weights: {
|
|
20607
|
+
exchange: 1,
|
|
20597
20608
|
exchangeStatus: 2,
|
|
20598
20609
|
clearinghouseState: 2,
|
|
20599
20610
|
spotClearinghouseState: 2,
|
|
@@ -20624,7 +20635,8 @@ var init_runtime_policy_generated = __esm({
|
|
|
20624
20635
|
authorizedAgents: 20,
|
|
20625
20636
|
agents: 20,
|
|
20626
20637
|
apiWallets: 20
|
|
20627
|
-
}
|
|
20638
|
+
},
|
|
20639
|
+
exchange_action_batch_size: 40
|
|
20628
20640
|
}
|
|
20629
20641
|
}
|
|
20630
20642
|
}
|
|
@@ -22504,51 +22516,51 @@ var require_uri_all = __commonJS({
|
|
|
22504
22516
|
}
|
|
22505
22517
|
return uriTokens.join("");
|
|
22506
22518
|
}
|
|
22507
|
-
function resolveComponents(base2,
|
|
22519
|
+
function resolveComponents(base2, relative4) {
|
|
22508
22520
|
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
22509
22521
|
var skipNormalization = arguments[3];
|
|
22510
22522
|
var target = {};
|
|
22511
22523
|
if (!skipNormalization) {
|
|
22512
22524
|
base2 = parse5(serialize(base2, options), options);
|
|
22513
|
-
|
|
22525
|
+
relative4 = parse5(serialize(relative4, options), options);
|
|
22514
22526
|
}
|
|
22515
22527
|
options = options || {};
|
|
22516
|
-
if (!options.tolerant &&
|
|
22517
|
-
target.scheme =
|
|
22518
|
-
target.userinfo =
|
|
22519
|
-
target.host =
|
|
22520
|
-
target.port =
|
|
22521
|
-
target.path = removeDotSegments(
|
|
22522
|
-
target.query =
|
|
22528
|
+
if (!options.tolerant && relative4.scheme) {
|
|
22529
|
+
target.scheme = relative4.scheme;
|
|
22530
|
+
target.userinfo = relative4.userinfo;
|
|
22531
|
+
target.host = relative4.host;
|
|
22532
|
+
target.port = relative4.port;
|
|
22533
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22534
|
+
target.query = relative4.query;
|
|
22523
22535
|
} else {
|
|
22524
|
-
if (
|
|
22525
|
-
target.userinfo =
|
|
22526
|
-
target.host =
|
|
22527
|
-
target.port =
|
|
22528
|
-
target.path = removeDotSegments(
|
|
22529
|
-
target.query =
|
|
22536
|
+
if (relative4.userinfo !== void 0 || relative4.host !== void 0 || relative4.port !== void 0) {
|
|
22537
|
+
target.userinfo = relative4.userinfo;
|
|
22538
|
+
target.host = relative4.host;
|
|
22539
|
+
target.port = relative4.port;
|
|
22540
|
+
target.path = removeDotSegments(relative4.path || "");
|
|
22541
|
+
target.query = relative4.query;
|
|
22530
22542
|
} else {
|
|
22531
|
-
if (!
|
|
22543
|
+
if (!relative4.path) {
|
|
22532
22544
|
target.path = base2.path;
|
|
22533
|
-
if (
|
|
22534
|
-
target.query =
|
|
22545
|
+
if (relative4.query !== void 0) {
|
|
22546
|
+
target.query = relative4.query;
|
|
22535
22547
|
} else {
|
|
22536
22548
|
target.query = base2.query;
|
|
22537
22549
|
}
|
|
22538
22550
|
} else {
|
|
22539
|
-
if (
|
|
22540
|
-
target.path = removeDotSegments(
|
|
22551
|
+
if (relative4.path.charAt(0) === "/") {
|
|
22552
|
+
target.path = removeDotSegments(relative4.path);
|
|
22541
22553
|
} else {
|
|
22542
22554
|
if ((base2.userinfo !== void 0 || base2.host !== void 0 || base2.port !== void 0) && !base2.path) {
|
|
22543
|
-
target.path = "/" +
|
|
22555
|
+
target.path = "/" + relative4.path;
|
|
22544
22556
|
} else if (!base2.path) {
|
|
22545
|
-
target.path =
|
|
22557
|
+
target.path = relative4.path;
|
|
22546
22558
|
} else {
|
|
22547
|
-
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) +
|
|
22559
|
+
target.path = base2.path.slice(0, base2.path.lastIndexOf("/") + 1) + relative4.path;
|
|
22548
22560
|
}
|
|
22549
22561
|
target.path = removeDotSegments(target.path);
|
|
22550
22562
|
}
|
|
22551
|
-
target.query =
|
|
22563
|
+
target.query = relative4.query;
|
|
22552
22564
|
}
|
|
22553
22565
|
target.userinfo = base2.userinfo;
|
|
22554
22566
|
target.host = base2.host;
|
|
@@ -22556,10 +22568,10 @@ var require_uri_all = __commonJS({
|
|
|
22556
22568
|
}
|
|
22557
22569
|
target.scheme = base2.scheme;
|
|
22558
22570
|
}
|
|
22559
|
-
target.fragment =
|
|
22571
|
+
target.fragment = relative4.fragment;
|
|
22560
22572
|
return target;
|
|
22561
22573
|
}
|
|
22562
|
-
function
|
|
22574
|
+
function resolve13(baseURI, relativeURI, options) {
|
|
22563
22575
|
var schemelessOptions = assign({ scheme: "null" }, options);
|
|
22564
22576
|
return serialize(resolveComponents(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
22565
22577
|
}
|
|
@@ -22824,7 +22836,7 @@ var require_uri_all = __commonJS({
|
|
|
22824
22836
|
exports2.removeDotSegments = removeDotSegments;
|
|
22825
22837
|
exports2.serialize = serialize;
|
|
22826
22838
|
exports2.resolveComponents = resolveComponents;
|
|
22827
|
-
exports2.resolve =
|
|
22839
|
+
exports2.resolve = resolve13;
|
|
22828
22840
|
exports2.normalize = normalize;
|
|
22829
22841
|
exports2.equal = equal;
|
|
22830
22842
|
exports2.escapeComponent = escapeComponent;
|
|
@@ -23195,18 +23207,18 @@ var require_resolve = __commonJS({
|
|
|
23195
23207
|
var util = require_util();
|
|
23196
23208
|
var SchemaObject = require_schema_obj();
|
|
23197
23209
|
var traverse = require_json_schema_traverse();
|
|
23198
|
-
module.exports =
|
|
23199
|
-
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
|
|
23203
|
-
|
|
23204
|
-
|
|
23205
|
-
function
|
|
23210
|
+
module.exports = resolve13;
|
|
23211
|
+
resolve13.normalizeId = normalizeId;
|
|
23212
|
+
resolve13.fullPath = getFullPath;
|
|
23213
|
+
resolve13.url = resolveUrl;
|
|
23214
|
+
resolve13.ids = resolveIds;
|
|
23215
|
+
resolve13.inlineRef = inlineRef;
|
|
23216
|
+
resolve13.schema = resolveSchema;
|
|
23217
|
+
function resolve13(compile, root, ref) {
|
|
23206
23218
|
var refVal = this._refs[ref];
|
|
23207
23219
|
if (typeof refVal == "string") {
|
|
23208
23220
|
if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
23209
|
-
else return
|
|
23221
|
+
else return resolve13.call(this, compile, root, refVal);
|
|
23210
23222
|
}
|
|
23211
23223
|
refVal = refVal || this._schemas[ref];
|
|
23212
23224
|
if (refVal instanceof SchemaObject) {
|
|
@@ -23414,7 +23426,7 @@ var require_error_classes = __commonJS({
|
|
|
23414
23426
|
init_define_VTX_EXO_POLICY();
|
|
23415
23427
|
init_define_VTX_GROK_POLICY();
|
|
23416
23428
|
init_define_VTX_PI_MODEL_POLICY();
|
|
23417
|
-
var
|
|
23429
|
+
var resolve13 = require_resolve();
|
|
23418
23430
|
module.exports = {
|
|
23419
23431
|
Validation: errorSubclass(ValidationError),
|
|
23420
23432
|
MissingRef: errorSubclass(MissingRefError)
|
|
@@ -23429,8 +23441,8 @@ var require_error_classes = __commonJS({
|
|
|
23429
23441
|
};
|
|
23430
23442
|
function MissingRefError(baseId, ref, message) {
|
|
23431
23443
|
this.message = message || MissingRefError.message(baseId, ref);
|
|
23432
|
-
this.missingRef =
|
|
23433
|
-
this.missingSchema =
|
|
23444
|
+
this.missingRef = resolve13.url(baseId, ref);
|
|
23445
|
+
this.missingSchema = resolve13.normalizeId(resolve13.fullPath(this.missingRef));
|
|
23434
23446
|
}
|
|
23435
23447
|
function errorSubclass(Subclass) {
|
|
23436
23448
|
Subclass.prototype = Object.create(Error.prototype);
|
|
@@ -23967,7 +23979,7 @@ var require_compile = __commonJS({
|
|
|
23967
23979
|
init_define_VTX_EXO_POLICY();
|
|
23968
23980
|
init_define_VTX_GROK_POLICY();
|
|
23969
23981
|
init_define_VTX_PI_MODEL_POLICY();
|
|
23970
|
-
var
|
|
23982
|
+
var resolve13 = require_resolve();
|
|
23971
23983
|
var util = require_util();
|
|
23972
23984
|
var errorClasses = require_error_classes();
|
|
23973
23985
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -24029,7 +24041,7 @@ var require_compile = __commonJS({
|
|
|
24029
24041
|
RULES,
|
|
24030
24042
|
validate: validateGenerator,
|
|
24031
24043
|
util,
|
|
24032
|
-
resolve:
|
|
24044
|
+
resolve: resolve13,
|
|
24033
24045
|
resolveRef: resolveRef2,
|
|
24034
24046
|
usePattern,
|
|
24035
24047
|
useDefault,
|
|
@@ -24091,7 +24103,7 @@ var require_compile = __commonJS({
|
|
|
24091
24103
|
return validate;
|
|
24092
24104
|
}
|
|
24093
24105
|
function resolveRef2(baseId2, ref, isRoot) {
|
|
24094
|
-
ref =
|
|
24106
|
+
ref = resolve13.url(baseId2, ref);
|
|
24095
24107
|
var refIndex = refs[ref];
|
|
24096
24108
|
var _refVal, refCode;
|
|
24097
24109
|
if (refIndex !== void 0) {
|
|
@@ -24108,11 +24120,11 @@ var require_compile = __commonJS({
|
|
|
24108
24120
|
}
|
|
24109
24121
|
}
|
|
24110
24122
|
refCode = addLocalRef(ref);
|
|
24111
|
-
var v2 =
|
|
24123
|
+
var v2 = resolve13.call(self2, localCompile, root, ref);
|
|
24112
24124
|
if (v2 === void 0) {
|
|
24113
24125
|
var localSchema = localRefs && localRefs[ref];
|
|
24114
24126
|
if (localSchema) {
|
|
24115
|
-
v2 =
|
|
24127
|
+
v2 = resolve13.inlineRef(localSchema, opts.inlineRefs) ? localSchema : compile.call(self2, localSchema, root, localRefs, baseId2);
|
|
24116
24128
|
}
|
|
24117
24129
|
}
|
|
24118
24130
|
if (v2 === void 0) {
|
|
@@ -27828,7 +27840,7 @@ var require_ajv = __commonJS({
|
|
|
27828
27840
|
init_define_VTX_GROK_POLICY();
|
|
27829
27841
|
init_define_VTX_PI_MODEL_POLICY();
|
|
27830
27842
|
var compileSchema = require_compile();
|
|
27831
|
-
var
|
|
27843
|
+
var resolve13 = require_resolve();
|
|
27832
27844
|
var Cache = require_cache();
|
|
27833
27845
|
var SchemaObject = require_schema_obj();
|
|
27834
27846
|
var stableStringify = require_fast_json_stable_stringify();
|
|
@@ -27910,7 +27922,7 @@ var require_ajv = __commonJS({
|
|
|
27910
27922
|
var id2 = this._getId(schema);
|
|
27911
27923
|
if (id2 !== void 0 && typeof id2 != "string")
|
|
27912
27924
|
throw new Error("schema id must be string");
|
|
27913
|
-
key =
|
|
27925
|
+
key = resolve13.normalizeId(key || id2);
|
|
27914
27926
|
checkUnique(this, key);
|
|
27915
27927
|
this._schemas[key] = this._addSchema(schema, _skipValidation, _meta, true);
|
|
27916
27928
|
return this;
|
|
@@ -27954,7 +27966,7 @@ var require_ajv = __commonJS({
|
|
|
27954
27966
|
}
|
|
27955
27967
|
}
|
|
27956
27968
|
function _getSchemaFragment(self2, ref) {
|
|
27957
|
-
var res =
|
|
27969
|
+
var res = resolve13.schema.call(self2, { schema: {} }, ref);
|
|
27958
27970
|
if (res) {
|
|
27959
27971
|
var schema = res.schema, root = res.root, baseId = res.baseId;
|
|
27960
27972
|
var v = compileSchema.call(self2, schema, root, void 0, baseId);
|
|
@@ -27970,7 +27982,7 @@ var require_ajv = __commonJS({
|
|
|
27970
27982
|
}
|
|
27971
27983
|
}
|
|
27972
27984
|
function _getSchemaObj(self2, keyRef) {
|
|
27973
|
-
keyRef =
|
|
27985
|
+
keyRef = resolve13.normalizeId(keyRef);
|
|
27974
27986
|
return self2._schemas[keyRef] || self2._refs[keyRef] || self2._fragments[keyRef];
|
|
27975
27987
|
}
|
|
27976
27988
|
function removeSchema(schemaKeyRef) {
|
|
@@ -27997,7 +28009,7 @@ var require_ajv = __commonJS({
|
|
|
27997
28009
|
this._cache.del(cacheKey);
|
|
27998
28010
|
var id2 = this._getId(schemaKeyRef);
|
|
27999
28011
|
if (id2) {
|
|
28000
|
-
id2 =
|
|
28012
|
+
id2 = resolve13.normalizeId(id2);
|
|
28001
28013
|
delete this._schemas[id2];
|
|
28002
28014
|
delete this._refs[id2];
|
|
28003
28015
|
}
|
|
@@ -28021,13 +28033,13 @@ var require_ajv = __commonJS({
|
|
|
28021
28033
|
var cached2 = this._cache.get(cacheKey);
|
|
28022
28034
|
if (cached2) return cached2;
|
|
28023
28035
|
shouldAddSchema = shouldAddSchema || this._opts.addUsedSchema !== false;
|
|
28024
|
-
var id2 =
|
|
28036
|
+
var id2 = resolve13.normalizeId(this._getId(schema));
|
|
28025
28037
|
if (id2 && shouldAddSchema) checkUnique(this, id2);
|
|
28026
28038
|
var willValidate = this._opts.validateSchema !== false && !skipValidation;
|
|
28027
28039
|
var recursiveMeta;
|
|
28028
|
-
if (willValidate && !(recursiveMeta = id2 && id2 ==
|
|
28040
|
+
if (willValidate && !(recursiveMeta = id2 && id2 == resolve13.normalizeId(schema.$schema)))
|
|
28029
28041
|
this.validateSchema(schema, true);
|
|
28030
|
-
var localRefs =
|
|
28042
|
+
var localRefs = resolve13.ids.call(this, schema);
|
|
28031
28043
|
var schemaObj = new SchemaObject({
|
|
28032
28044
|
id: id2,
|
|
28033
28045
|
schema,
|
|
@@ -28611,7 +28623,7 @@ var init_codex_app_server = __esm({
|
|
|
28611
28623
|
};
|
|
28612
28624
|
};
|
|
28613
28625
|
killWindowsProcessTree = async (pid) => {
|
|
28614
|
-
await new Promise((
|
|
28626
|
+
await new Promise((resolve13, reject) => {
|
|
28615
28627
|
const child = spawn3(
|
|
28616
28628
|
"taskkill.exe",
|
|
28617
28629
|
["/PID", String(pid), "/T", "/F"],
|
|
@@ -28636,7 +28648,7 @@ var init_codex_app_server = __esm({
|
|
|
28636
28648
|
});
|
|
28637
28649
|
child.once("close", (code) => {
|
|
28638
28650
|
clearTimeout(timer);
|
|
28639
|
-
if (code === 0 || code === 128)
|
|
28651
|
+
if (code === 0 || code === 128) resolve13();
|
|
28640
28652
|
else reject(new Error("Windows Codex process-tree cleanup failed."));
|
|
28641
28653
|
});
|
|
28642
28654
|
});
|
|
@@ -28836,7 +28848,7 @@ child.once('close', async (code, signal) => {
|
|
|
28836
28848
|
const platform = options.platform ?? process.platform;
|
|
28837
28849
|
const renameFile = options.renameFile ?? rename2;
|
|
28838
28850
|
const removeFile = options.removeFile ?? ((path) => rm2(path, { force: true }));
|
|
28839
|
-
const sleep4 = options.sleep ?? ((milliseconds) => new Promise((
|
|
28851
|
+
const sleep4 = options.sleep ?? ((milliseconds) => new Promise((resolve13) => setTimeout(resolve13, milliseconds)));
|
|
28840
28852
|
const maxAttempts = Math.max(1, options.maxAttempts ?? 40);
|
|
28841
28853
|
const retryDelayMs = Math.max(0, options.retryDelayMs ?? 25);
|
|
28842
28854
|
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
@@ -28928,7 +28940,7 @@ child.once('close', async (code, signal) => {
|
|
|
28928
28940
|
throw new Error("Codex guardian terminated before app-server initialization.");
|
|
28929
28941
|
}
|
|
28930
28942
|
}
|
|
28931
|
-
await new Promise((
|
|
28943
|
+
await new Promise((resolve13) => setTimeout(resolve13, 25));
|
|
28932
28944
|
}
|
|
28933
28945
|
throw new Error(`Codex guardian ${expectedState} state was not confirmed.`);
|
|
28934
28946
|
};
|
|
@@ -29310,8 +29322,8 @@ child.once('close', async (code, signal) => {
|
|
|
29310
29322
|
dispatchOutcome: "not_dispatched"
|
|
29311
29323
|
});
|
|
29312
29324
|
}
|
|
29313
|
-
return await new Promise((
|
|
29314
|
-
const pending3 = { resolve:
|
|
29325
|
+
return await new Promise((resolve13, reject) => {
|
|
29326
|
+
const pending3 = { resolve: resolve13, reject, timer: null, abortCleanup: null };
|
|
29315
29327
|
pending3.timer = setTimeout(() => {
|
|
29316
29328
|
this.pending.delete(id2);
|
|
29317
29329
|
this.retireResponseId(id2, method);
|
|
@@ -29986,8 +29998,8 @@ child.once('close', async (code, signal) => {
|
|
|
29986
29998
|
const agentWebSearches = [];
|
|
29987
29999
|
let terminalResolve;
|
|
29988
30000
|
let terminalReject;
|
|
29989
|
-
const terminalPromise = new Promise((
|
|
29990
|
-
terminalResolve =
|
|
30001
|
+
const terminalPromise = new Promise((resolve13, reject) => {
|
|
30002
|
+
terminalResolve = resolve13;
|
|
29991
30003
|
terminalReject = reject;
|
|
29992
30004
|
});
|
|
29993
30005
|
void terminalPromise.catch(() => void 0);
|
|
@@ -30547,15 +30559,15 @@ child.once('close', async (code, signal) => {
|
|
|
30547
30559
|
).catch(() => void 0);
|
|
30548
30560
|
}
|
|
30549
30561
|
this.process.stdin.end();
|
|
30550
|
-
const exited = await new Promise((
|
|
30562
|
+
const exited = await new Promise((resolve13) => {
|
|
30551
30563
|
if (this.process.exitCode !== null) {
|
|
30552
|
-
|
|
30564
|
+
resolve13(true);
|
|
30553
30565
|
return;
|
|
30554
30566
|
}
|
|
30555
|
-
const timer = setTimeout(() =>
|
|
30567
|
+
const timer = setTimeout(() => resolve13(false), 5e3);
|
|
30556
30568
|
this.process.once("close", () => {
|
|
30557
30569
|
clearTimeout(timer);
|
|
30558
|
-
|
|
30570
|
+
resolve13(true);
|
|
30559
30571
|
});
|
|
30560
30572
|
});
|
|
30561
30573
|
if (exited) return;
|
|
@@ -30566,11 +30578,11 @@ child.once('close', async (code, signal) => {
|
|
|
30566
30578
|
else this.process.kill("SIGTERM");
|
|
30567
30579
|
} catch {
|
|
30568
30580
|
}
|
|
30569
|
-
const terminated = await new Promise((
|
|
30570
|
-
const timer = setTimeout(() =>
|
|
30581
|
+
const terminated = await new Promise((resolve13) => {
|
|
30582
|
+
const timer = setTimeout(() => resolve13(false), 1e3);
|
|
30571
30583
|
this.process.once("close", () => {
|
|
30572
30584
|
clearTimeout(timer);
|
|
30573
|
-
|
|
30585
|
+
resolve13(true);
|
|
30574
30586
|
});
|
|
30575
30587
|
});
|
|
30576
30588
|
if (!terminated) {
|
|
@@ -30580,15 +30592,15 @@ child.once('close', async (code, signal) => {
|
|
|
30580
30592
|
else this.process.kill("SIGKILL");
|
|
30581
30593
|
} catch {
|
|
30582
30594
|
}
|
|
30583
|
-
await new Promise((
|
|
30595
|
+
await new Promise((resolve13) => {
|
|
30584
30596
|
if (this.process.exitCode !== null) {
|
|
30585
|
-
|
|
30597
|
+
resolve13();
|
|
30586
30598
|
return;
|
|
30587
30599
|
}
|
|
30588
|
-
const timer = setTimeout(
|
|
30600
|
+
const timer = setTimeout(resolve13, 1e3);
|
|
30589
30601
|
this.process.once("close", () => {
|
|
30590
30602
|
clearTimeout(timer);
|
|
30591
|
-
|
|
30603
|
+
resolve13();
|
|
30592
30604
|
});
|
|
30593
30605
|
});
|
|
30594
30606
|
if (this.process.exitCode === null) {
|
|
@@ -31206,13 +31218,13 @@ var init_runner = __esm({
|
|
|
31206
31218
|
};
|
|
31207
31219
|
defaultSleep = async (milliseconds, signal) => {
|
|
31208
31220
|
if (signal?.aborted) throw abortError();
|
|
31209
|
-
await new Promise((
|
|
31221
|
+
await new Promise((resolve13, reject) => {
|
|
31210
31222
|
const finish = (callback) => {
|
|
31211
31223
|
signal?.removeEventListener("abort", onAbort);
|
|
31212
31224
|
callback();
|
|
31213
31225
|
};
|
|
31214
31226
|
const timer = setTimeout(
|
|
31215
|
-
() => finish(
|
|
31227
|
+
() => finish(resolve13),
|
|
31216
31228
|
Math.max(MIN_SLEEP_MS, milliseconds)
|
|
31217
31229
|
);
|
|
31218
31230
|
const onAbort = () => {
|
|
@@ -31238,9 +31250,9 @@ var init_runner = __esm({
|
|
|
31238
31250
|
let timer = null;
|
|
31239
31251
|
const settled = await Promise.race([
|
|
31240
31252
|
promise2.then(() => true, () => true),
|
|
31241
|
-
new Promise((
|
|
31253
|
+
new Promise((resolve13) => {
|
|
31242
31254
|
timer = setTimeout(
|
|
31243
|
-
() =>
|
|
31255
|
+
() => resolve13(false),
|
|
31244
31256
|
Math.max(MIN_SLEEP_MS, timeoutMs)
|
|
31245
31257
|
);
|
|
31246
31258
|
})
|
|
@@ -31815,8 +31827,8 @@ var init_runner = __esm({
|
|
|
31815
31827
|
};
|
|
31816
31828
|
let quiesceRequested = Boolean(this.options.quiesceSignal?.aborted);
|
|
31817
31829
|
let wakeQuiesce;
|
|
31818
|
-
const quiesceWake = new Promise((
|
|
31819
|
-
wakeQuiesce =
|
|
31830
|
+
const quiesceWake = new Promise((resolve13) => {
|
|
31831
|
+
wakeQuiesce = resolve13;
|
|
31820
31832
|
});
|
|
31821
31833
|
let drainRequested = false;
|
|
31822
31834
|
let drainReason = "stopped";
|
|
@@ -31839,8 +31851,8 @@ var init_runner = __esm({
|
|
|
31839
31851
|
let modelCatalogRefresh = null;
|
|
31840
31852
|
let providerRateLimitRefresh = null;
|
|
31841
31853
|
let wakeDrain;
|
|
31842
|
-
const drainSignal = new Promise((
|
|
31843
|
-
wakeDrain =
|
|
31854
|
+
const drainSignal = new Promise((resolve13) => {
|
|
31855
|
+
wakeDrain = resolve13;
|
|
31844
31856
|
});
|
|
31845
31857
|
const requestDrain = (reason) => {
|
|
31846
31858
|
const priority = (value) => {
|
|
@@ -31931,7 +31943,7 @@ var init_runner = __esm({
|
|
|
31931
31943
|
const metadata = await this.dependencies.discoverOAuth({
|
|
31932
31944
|
signal: this.options.signal
|
|
31933
31945
|
});
|
|
31934
|
-
let
|
|
31946
|
+
let access6 = null;
|
|
31935
31947
|
let accessExpiresAt = 0;
|
|
31936
31948
|
let refreshPromise = null;
|
|
31937
31949
|
const refreshAccessToken = async (requestOptions = {}) => {
|
|
@@ -31944,7 +31956,7 @@ var init_runner = __esm({
|
|
|
31944
31956
|
);
|
|
31945
31957
|
assertLocalCredentialIdentity(localState, refreshed.credential);
|
|
31946
31958
|
credential = refreshed.credential;
|
|
31947
|
-
|
|
31959
|
+
access6 = refreshed;
|
|
31948
31960
|
accessExpiresAt = now() + refreshed.expiresIn * 1e3;
|
|
31949
31961
|
return refreshed.accessToken;
|
|
31950
31962
|
})();
|
|
@@ -31957,10 +31969,10 @@ var init_runner = __esm({
|
|
|
31957
31969
|
await refreshAccessToken({ signal: this.options.signal });
|
|
31958
31970
|
const tokenSource = {
|
|
31959
31971
|
accessToken: async (requestOptions) => {
|
|
31960
|
-
if (!
|
|
31972
|
+
if (!access6 || accessExpiresAt - now() <= 5e3) {
|
|
31961
31973
|
return refreshAccessToken(requestOptions);
|
|
31962
31974
|
}
|
|
31963
|
-
return
|
|
31975
|
+
return access6.accessToken;
|
|
31964
31976
|
},
|
|
31965
31977
|
refreshAccessToken
|
|
31966
31978
|
};
|
|
@@ -32215,8 +32227,8 @@ var init_runner = __esm({
|
|
|
32215
32227
|
receipt = result2;
|
|
32216
32228
|
const revision = receiptRevision + 1;
|
|
32217
32229
|
receiptRevision = revision;
|
|
32218
|
-
const durable = new Promise((
|
|
32219
|
-
receiptDurabilityWaiters.push({ revision, resolve:
|
|
32230
|
+
const durable = new Promise((resolve13, reject) => {
|
|
32231
|
+
receiptDurabilityWaiters.push({ revision, resolve: resolve13, reject });
|
|
32220
32232
|
});
|
|
32221
32233
|
scheduleReceiptWriter();
|
|
32222
32234
|
await durable;
|
|
@@ -32332,8 +32344,8 @@ var init_runner = __esm({
|
|
|
32332
32344
|
const tool = receipt.registered ? "inference.host.advertise" : "inference.host.register";
|
|
32333
32345
|
let result2;
|
|
32334
32346
|
let releaseAdvertisementHandoff;
|
|
32335
|
-
const currentAdvertisementHandoff = new Promise((
|
|
32336
|
-
releaseAdvertisementHandoff =
|
|
32347
|
+
const currentAdvertisementHandoff = new Promise((resolve13) => {
|
|
32348
|
+
releaseAdvertisementHandoff = resolve13;
|
|
32337
32349
|
});
|
|
32338
32350
|
advertisementHandoff = currentAdvertisementHandoff;
|
|
32339
32351
|
try {
|
|
@@ -33550,8 +33562,8 @@ var init_runner = __esm({
|
|
|
33550
33562
|
let providerDispatchWatchdog = null;
|
|
33551
33563
|
let providerDispatchWatchdogExpired = false;
|
|
33552
33564
|
let resolveProviderDispatchWatchdog;
|
|
33553
|
-
const providerDispatchWatchdogSignal = new Promise((
|
|
33554
|
-
resolveProviderDispatchWatchdog =
|
|
33565
|
+
const providerDispatchWatchdogSignal = new Promise((resolve13) => {
|
|
33566
|
+
resolveProviderDispatchWatchdog = resolve13;
|
|
33555
33567
|
});
|
|
33556
33568
|
const clearProviderDispatchWatchdog = () => {
|
|
33557
33569
|
if (providerDispatchWatchdog !== null) clearTimeout(providerDispatchWatchdog);
|
|
@@ -33988,8 +34000,8 @@ var init_runner = __esm({
|
|
|
33988
34000
|
});
|
|
33989
34001
|
}
|
|
33990
34002
|
let resolveTerminalDispatchOutcome;
|
|
33991
|
-
const terminalDispatchOutcomeSignal = new Promise((
|
|
33992
|
-
resolveTerminalDispatchOutcome =
|
|
34003
|
+
const terminalDispatchOutcomeSignal = new Promise((resolve13) => {
|
|
34004
|
+
resolveTerminalDispatchOutcome = resolve13;
|
|
33993
34005
|
});
|
|
33994
34006
|
let terminalDispatchOutcomeObserved = false;
|
|
33995
34007
|
const adapterAttempt = this.dependencies.codexAdapter.runAttempt({
|
|
@@ -35293,7 +35305,7 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35293
35305
|
throw new Error("Host reauthorization was rejected; the previous host identity was preserved.");
|
|
35294
35306
|
}
|
|
35295
35307
|
let candidate = await store.readRecovery();
|
|
35296
|
-
let
|
|
35308
|
+
let access6 = options.authorizedAccess ?? null;
|
|
35297
35309
|
if (!candidate) {
|
|
35298
35310
|
if (transition) {
|
|
35299
35311
|
if (!transition.remote_committed || options.state.client_id !== transition.client_id) {
|
|
@@ -35319,7 +35331,7 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35319
35331
|
});
|
|
35320
35332
|
options.emitAuthorization(pending3.authorizationUrl);
|
|
35321
35333
|
try {
|
|
35322
|
-
|
|
35334
|
+
access6 = await pending3.completion;
|
|
35323
35335
|
} catch (error48) {
|
|
35324
35336
|
await pending3.cancel().catch(() => void 0);
|
|
35325
35337
|
throw error48;
|
|
@@ -35368,7 +35380,7 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35368
35380
|
return runStopped(() => reauthorizeInferenceHost({
|
|
35369
35381
|
...options,
|
|
35370
35382
|
withStoppedHost: void 0,
|
|
35371
|
-
authorizedAccess:
|
|
35383
|
+
authorizedAccess: access6 ?? void 0
|
|
35372
35384
|
}));
|
|
35373
35385
|
}
|
|
35374
35386
|
if (transition.service_prepare_pending) {
|
|
@@ -35377,8 +35389,8 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35377
35389
|
await save();
|
|
35378
35390
|
}
|
|
35379
35391
|
if (!transition.remote_committed) {
|
|
35380
|
-
if (!
|
|
35381
|
-
|
|
35392
|
+
if (!access6) {
|
|
35393
|
+
access6 = await refreshInferenceCredential({
|
|
35382
35394
|
metadata: await discoverInferenceOAuth(config2.apiUrl),
|
|
35383
35395
|
credential: candidate.credential,
|
|
35384
35396
|
store: stagedStore
|
|
@@ -35396,7 +35408,7 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35396
35408
|
});
|
|
35397
35409
|
let result2;
|
|
35398
35410
|
try {
|
|
35399
|
-
result2 = await register(
|
|
35411
|
+
result2 = await register(access6, transition.advertisement);
|
|
35400
35412
|
} catch (error48) {
|
|
35401
35413
|
if (error48 instanceof ExternalInferenceMcpError && error48.code === "tool_rejected" && !error48.retryable && !error48.definitivelyNotApplied) {
|
|
35402
35414
|
transition.remote_rejected = true;
|
|
@@ -35407,7 +35419,7 @@ async function reauthorizeInferenceHost(options) {
|
|
|
35407
35419
|
if (!(error48 instanceof ExternalInferenceMcpError) || !error48.definitivelyNotApplied) throw error48;
|
|
35408
35420
|
transition.advertisement = freshAdvertisement();
|
|
35409
35421
|
await save();
|
|
35410
|
-
result2 = await register(
|
|
35422
|
+
result2 = await register(access6, transition.advertisement);
|
|
35411
35423
|
}
|
|
35412
35424
|
if (result2.host.host_id !== next.host_id || result2.host.host_generation !== next.host_generation || result2.host.key_generation !== next.key_generation || result2.host.advertisement_generation !== transition.advertisement.advertisement_generation) {
|
|
35413
35425
|
throw new Error("Inference host reauthorization returned a different host identity.");
|
|
@@ -35489,7 +35501,7 @@ async function createInferenceAgentMcpSession(options) {
|
|
|
35489
35501
|
options.fetchImpl,
|
|
35490
35502
|
{ signal: options.signal, timeoutMs: options.requestTimeoutMs }
|
|
35491
35503
|
);
|
|
35492
|
-
let
|
|
35504
|
+
let access6 = null;
|
|
35493
35505
|
let accessExpiresAt = 0;
|
|
35494
35506
|
let refreshPromise = null;
|
|
35495
35507
|
const refreshAccessToken = async (requestOptions = {}) => {
|
|
@@ -35506,7 +35518,7 @@ async function createInferenceAgentMcpSession(options) {
|
|
|
35506
35518
|
});
|
|
35507
35519
|
assertCredentialMatchesState(localState, refreshed.credential);
|
|
35508
35520
|
credential = refreshed.credential;
|
|
35509
|
-
|
|
35521
|
+
access6 = refreshed;
|
|
35510
35522
|
accessExpiresAt = Date.now() + refreshed.expiresIn * 1e3;
|
|
35511
35523
|
return refreshed.accessToken;
|
|
35512
35524
|
})();
|
|
@@ -35519,10 +35531,10 @@ async function createInferenceAgentMcpSession(options) {
|
|
|
35519
35531
|
await refreshAccessToken({ signal: options.signal });
|
|
35520
35532
|
const tokenSource = {
|
|
35521
35533
|
accessToken: async (requestOptions) => {
|
|
35522
|
-
if (!
|
|
35534
|
+
if (!access6 || accessExpiresAt - Date.now() <= 5e3) {
|
|
35523
35535
|
return refreshAccessToken(requestOptions);
|
|
35524
35536
|
}
|
|
35525
|
-
return
|
|
35537
|
+
return access6.accessToken;
|
|
35526
35538
|
},
|
|
35527
35539
|
refreshAccessToken
|
|
35528
35540
|
};
|
|
@@ -35610,7 +35622,7 @@ var init_codex_binary = __esm({
|
|
|
35610
35622
|
spec.binaryName
|
|
35611
35623
|
);
|
|
35612
35624
|
};
|
|
35613
|
-
readCodexVersion = async (binaryPath) => await new Promise((
|
|
35625
|
+
readCodexVersion = async (binaryPath) => await new Promise((resolve13, reject) => {
|
|
35614
35626
|
const child = spawn4(binaryPath, ["--version"], {
|
|
35615
35627
|
stdio: ["ignore", "pipe", "pipe"],
|
|
35616
35628
|
windowsHide: true,
|
|
@@ -35648,7 +35660,7 @@ var init_codex_binary = __esm({
|
|
|
35648
35660
|
reject(new Error("Codex version probe failed."));
|
|
35649
35661
|
return;
|
|
35650
35662
|
}
|
|
35651
|
-
|
|
35663
|
+
resolve13(stdout.trim());
|
|
35652
35664
|
});
|
|
35653
35665
|
});
|
|
35654
35666
|
verifyPinnedCodexBinary = async (candidatePath, dependencies = {}) => {
|
|
@@ -36557,7 +36569,7 @@ var init_codex_adapter = __esm({
|
|
|
36557
36569
|
durableSession.session.requireModelCapability(capabilities, modelName, reasoningEffort);
|
|
36558
36570
|
}
|
|
36559
36571
|
async waitForCapabilities(preflight, deadlineAtMs, signal) {
|
|
36560
|
-
return await new Promise((
|
|
36572
|
+
return await new Promise((resolve13, reject) => {
|
|
36561
36573
|
let settled = false;
|
|
36562
36574
|
const finish = (callback) => {
|
|
36563
36575
|
if (settled) return;
|
|
@@ -36584,7 +36596,7 @@ var init_codex_adapter = __esm({
|
|
|
36584
36596
|
return;
|
|
36585
36597
|
}
|
|
36586
36598
|
void preflight.then(
|
|
36587
|
-
(value) => finish(() =>
|
|
36599
|
+
(value) => finish(() => resolve13(value)),
|
|
36588
36600
|
(error48) => finish(() => reject(error48))
|
|
36589
36601
|
);
|
|
36590
36602
|
});
|
|
@@ -38210,9 +38222,9 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
38210
38222
|
response.end();
|
|
38211
38223
|
}
|
|
38212
38224
|
});
|
|
38213
|
-
await new Promise((
|
|
38225
|
+
await new Promise((resolve13, reject) => {
|
|
38214
38226
|
this.server.once("error", reject);
|
|
38215
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
38227
|
+
this.server.listen(0, "127.0.0.1", () => resolve13());
|
|
38216
38228
|
});
|
|
38217
38229
|
const address = this.server.address();
|
|
38218
38230
|
if (!address || typeof address === "string") throw new Error("deepseek_proxy_bind_failed");
|
|
@@ -38224,7 +38236,7 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
38224
38236
|
this.server = null;
|
|
38225
38237
|
this.urlValue = null;
|
|
38226
38238
|
if (!server) return;
|
|
38227
|
-
await new Promise((
|
|
38239
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
38228
38240
|
}
|
|
38229
38241
|
};
|
|
38230
38242
|
}
|
|
@@ -38762,11 +38774,11 @@ ${JSON.stringify(input.outputSchema)}`,
|
|
|
38762
38774
|
boundary.signal.throwIfAborted();
|
|
38763
38775
|
let checkpointReached = false;
|
|
38764
38776
|
let resolveCheckpoint;
|
|
38765
|
-
const checkpoint = new Promise((
|
|
38766
|
-
resolveCheckpoint =
|
|
38777
|
+
const checkpoint = new Promise((resolve13) => {
|
|
38778
|
+
resolveCheckpoint = resolve13;
|
|
38767
38779
|
});
|
|
38768
|
-
const dispatchGate = new Promise((
|
|
38769
|
-
releaseAgentDispatch =
|
|
38780
|
+
const dispatchGate = new Promise((resolve13) => {
|
|
38781
|
+
releaseAgentDispatch = resolve13;
|
|
38770
38782
|
});
|
|
38771
38783
|
ctx.on("llm/stream", (options, next) => {
|
|
38772
38784
|
if (String(options.sessionId ?? "") !== String(sessionId)) return next();
|
|
@@ -39647,7 +39659,7 @@ var init_grok_binary = __esm({
|
|
|
39647
39659
|
decompress = promisify(brotliDecompress);
|
|
39648
39660
|
pending = /* @__PURE__ */ new Map();
|
|
39649
39661
|
digest = (bytes3) => createHash7("sha256").update(bytes3).digest("hex");
|
|
39650
|
-
verifyVersion = async (path) => new Promise((
|
|
39662
|
+
verifyVersion = async (path) => new Promise((resolve13, reject) => {
|
|
39651
39663
|
const child = spawn6(path, ["--version"], {
|
|
39652
39664
|
stdio: ["ignore", "pipe", "ignore"],
|
|
39653
39665
|
windowsHide: true,
|
|
@@ -39674,7 +39686,7 @@ var init_grok_binary = __esm({
|
|
|
39674
39686
|
clearTimeout(timer);
|
|
39675
39687
|
if (code !== 0 || /^grok\s+(\S+)/u.exec(stdout.trim())?.[1] !== agent_cli_release_default.grok_version) {
|
|
39676
39688
|
reject(new Error("Grok runtime version does not match its release."));
|
|
39677
|
-
} else
|
|
39689
|
+
} else resolve13();
|
|
39678
39690
|
});
|
|
39679
39691
|
});
|
|
39680
39692
|
resolvePinnedGrokBinary = async (stateRoot) => {
|
|
@@ -39894,9 +39906,9 @@ var init_grok_transport_proxy = __esm({
|
|
|
39894
39906
|
this.server = createServer3((request, response) => {
|
|
39895
39907
|
void this.handle(request, response);
|
|
39896
39908
|
});
|
|
39897
|
-
await new Promise((
|
|
39909
|
+
await new Promise((resolve13, reject) => {
|
|
39898
39910
|
this.server.once("error", reject);
|
|
39899
|
-
this.server.listen(0, "127.0.0.1", () =>
|
|
39911
|
+
this.server.listen(0, "127.0.0.1", () => resolve13());
|
|
39900
39912
|
});
|
|
39901
39913
|
const address = this.server.address();
|
|
39902
39914
|
if (!address || typeof address === "string") throw new Error("grok_proxy_bind_failed");
|
|
@@ -40272,7 +40284,7 @@ var init_grok_transport_proxy = __esm({
|
|
|
40272
40284
|
this.urlValue = null;
|
|
40273
40285
|
if (!server) return;
|
|
40274
40286
|
server.closeAllConnections();
|
|
40275
|
-
await new Promise((
|
|
40287
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
40276
40288
|
}
|
|
40277
40289
|
};
|
|
40278
40290
|
createGrokTransportProxy = async (options) => {
|
|
@@ -40453,11 +40465,11 @@ var init_grok_runtime = __esm({
|
|
|
40453
40465
|
this.child.kill();
|
|
40454
40466
|
}
|
|
40455
40467
|
});
|
|
40456
|
-
this.exit = new Promise((
|
|
40468
|
+
this.exit = new Promise((resolve13) => {
|
|
40457
40469
|
this.child.once("error", () => this.fail(new Error("grok_process_start_failed")));
|
|
40458
40470
|
this.child.once("close", () => {
|
|
40459
40471
|
this.fail(new Error("grok_process_closed"));
|
|
40460
|
-
|
|
40472
|
+
resolve13();
|
|
40461
40473
|
});
|
|
40462
40474
|
});
|
|
40463
40475
|
}
|
|
@@ -40477,8 +40489,8 @@ var init_grok_runtime = __esm({
|
|
|
40477
40489
|
let timer;
|
|
40478
40490
|
let abort;
|
|
40479
40491
|
try {
|
|
40480
|
-
return await new Promise((
|
|
40481
|
-
this.pending.set(id2, { resolve:
|
|
40492
|
+
return await new Promise((resolve13, reject) => {
|
|
40493
|
+
this.pending.set(id2, { resolve: resolve13, reject });
|
|
40482
40494
|
timer = setTimeout(() => reject(new Error("grok_deadline_exceeded")), Math.max(1, deadlineAtMs - Date.now()));
|
|
40483
40495
|
abort = () => reject(new Error("grok_cancelled"));
|
|
40484
40496
|
signal?.addEventListener("abort", abort, { once: true });
|
|
@@ -40552,9 +40564,9 @@ var init_grok_runtime = __esm({
|
|
|
40552
40564
|
response.writeHead(400).end();
|
|
40553
40565
|
}
|
|
40554
40566
|
});
|
|
40555
|
-
await new Promise((
|
|
40567
|
+
await new Promise((resolve13, reject) => {
|
|
40556
40568
|
server.once("error", reject);
|
|
40557
|
-
server.listen(0, "127.0.0.1",
|
|
40569
|
+
server.listen(0, "127.0.0.1", resolve13);
|
|
40558
40570
|
});
|
|
40559
40571
|
const address = server.address();
|
|
40560
40572
|
if (!address || typeof address === "string") throw new Error("grok_mcp_listen_failed");
|
|
@@ -40565,7 +40577,7 @@ var init_grok_runtime = __esm({
|
|
|
40565
40577
|
descriptor: { type: "http", name: "vtx", url: `http://127.0.0.1:${address.port}/${token}`, headers: [] },
|
|
40566
40578
|
close: async () => {
|
|
40567
40579
|
server.closeAllConnections();
|
|
40568
|
-
await new Promise((
|
|
40580
|
+
await new Promise((resolve13) => server.close(() => resolve13()));
|
|
40569
40581
|
}
|
|
40570
40582
|
};
|
|
40571
40583
|
};
|
|
@@ -41291,7 +41303,7 @@ var init_grok_auth = __esm({
|
|
|
41291
41303
|
await prepareGrokHome(options.grokHome);
|
|
41292
41304
|
const binary = await resolvePinnedGrokBinary(options.stateRoot);
|
|
41293
41305
|
options.signal?.throwIfAborted();
|
|
41294
|
-
await new Promise((
|
|
41306
|
+
await new Promise((resolve13, reject) => {
|
|
41295
41307
|
const child = spawn8(binary.path, ["--no-auto-update", action, ...action === "login" ? ["--device-auth"] : []], {
|
|
41296
41308
|
cwd: options.grokHome,
|
|
41297
41309
|
env: grokRuntimeEnvironment(options.grokHome),
|
|
@@ -41353,7 +41365,7 @@ var init_grok_auth = __esm({
|
|
|
41353
41365
|
child.once("close", (code) => {
|
|
41354
41366
|
cleanup();
|
|
41355
41367
|
if (code !== 0 || failed || options.signal?.aborted) reject(new Error(`Grok ${action} did not complete. Run grok-${action} again.`));
|
|
41356
|
-
else
|
|
41368
|
+
else resolve13();
|
|
41357
41369
|
});
|
|
41358
41370
|
if (options.signal?.aborted) stop();
|
|
41359
41371
|
});
|
|
@@ -42361,6 +42373,74 @@ var init_durable_adapter = __esm({
|
|
|
42361
42373
|
}
|
|
42362
42374
|
});
|
|
42363
42375
|
|
|
42376
|
+
// lib/inference-host/service-launcher-state.ts
|
|
42377
|
+
import { access as access4, readFile as readFile9, rm as rm10 } from "node:fs/promises";
|
|
42378
|
+
import { dirname as dirname12, isAbsolute as isAbsolute5, join as join13, relative as relative3, resolve as resolve10 } from "node:path";
|
|
42379
|
+
var launcherSibling, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
|
|
42380
|
+
var init_service_launcher_state = __esm({
|
|
42381
|
+
"lib/inference-host/service-launcher-state.ts"() {
|
|
42382
|
+
"use strict";
|
|
42383
|
+
init_define_VTX_EXO_POLICY();
|
|
42384
|
+
init_define_VTX_GROK_POLICY();
|
|
42385
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
42386
|
+
init_config();
|
|
42387
|
+
launcherSibling = (manifest, suffix) => {
|
|
42388
|
+
if (!manifest.endsWith(".service.json")) throw new Error("Invalid service manifest path.");
|
|
42389
|
+
return `${manifest.slice(0, -".service.json".length)}${suffix}`;
|
|
42390
|
+
};
|
|
42391
|
+
within = (parent, child) => {
|
|
42392
|
+
const part = relative3(resolve10(parent), resolve10(child));
|
|
42393
|
+
return Boolean(part) && !part.startsWith("..") && !isAbsolute5(part);
|
|
42394
|
+
};
|
|
42395
|
+
launcherSelection = (manifest, value) => {
|
|
42396
|
+
if (!value || typeof value !== "object") return null;
|
|
42397
|
+
const r = value;
|
|
42398
|
+
if (r.schema_version !== "vtx_inference_service_release_v1" || r.package_name !== "@vtxmacro/cli" || typeof r.package_version !== "string" || !/^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(r.package_version) || typeof r.integrity !== "string" || typeof r.selected_at !== "string" || !Number.isFinite(Date.parse(r.selected_at)) || typeof r.script !== "string" || !isAbsolute5(r.script) || /[\r\n\0]/u.test(r.script) || !within(launcherSibling(manifest, ".service-releases"), r.script)) return null;
|
|
42399
|
+
return r;
|
|
42400
|
+
};
|
|
42401
|
+
readLauncherSelection = async (manifest) => {
|
|
42402
|
+
try {
|
|
42403
|
+
return launcherSelection(manifest, JSON.parse(await readFile9(launcherSibling(manifest, ".service-release.json"), "utf8")));
|
|
42404
|
+
} catch (error48) {
|
|
42405
|
+
if (error48.code === "ENOENT") return null;
|
|
42406
|
+
throw error48;
|
|
42407
|
+
}
|
|
42408
|
+
};
|
|
42409
|
+
readLauncherState = async (manifest) => {
|
|
42410
|
+
let value;
|
|
42411
|
+
try {
|
|
42412
|
+
value = JSON.parse(await readFile9(launcherSibling(manifest, ".service-launcher.json"), "utf8"));
|
|
42413
|
+
} catch (error48) {
|
|
42414
|
+
if (error48.code === "ENOENT") return null;
|
|
42415
|
+
throw error48;
|
|
42416
|
+
}
|
|
42417
|
+
if (!value || typeof value !== "object") throw new Error("Invalid service launcher state.");
|
|
42418
|
+
const r = value;
|
|
42419
|
+
const target = (v) => {
|
|
42420
|
+
if (!v || typeof v !== "object") return false;
|
|
42421
|
+
const t = v;
|
|
42422
|
+
return typeof t.package_version === "string" && /^\d{4}\.\d{1,2}\.\d{1,3}$/u.test(t.package_version) && typeof t.script === "string" && isAbsolute5(t.script) && !/[\r\n\0]/u.test(t.script) && (within(launcherSibling(manifest, ".service-releases"), t.script) || resolve10(t.script) === resolve10(launcherSibling(manifest, ".service-bootstrap.previous.js"))) && (t.selection === null || (() => {
|
|
42423
|
+
const selected = launcherSelection(manifest, t.selection);
|
|
42424
|
+
return Boolean(selected && selected.package_version === t.package_version && (resolve10(t.script) === resolve10(join13(dirname12(selected.script), "vtx-service-bootstrap.js")) || resolve10(t.script) === resolve10(launcherSibling(manifest, ".service-bootstrap.previous.js"))));
|
|
42425
|
+
})());
|
|
42426
|
+
};
|
|
42427
|
+
if (r.schema_version !== "vtx_inference_service_launcher_v1" || !target(r.active) || r.previous !== null && !target(r.previous) || typeof r.pending !== "boolean") {
|
|
42428
|
+
throw new Error("Invalid service launcher recovery targets.");
|
|
42429
|
+
}
|
|
42430
|
+
return r;
|
|
42431
|
+
};
|
|
42432
|
+
writeLauncherState = async (manifest, state) => {
|
|
42433
|
+
await writeAtomicInferencePrivateFile(launcherSibling(manifest, ".service-launcher.json"), `${JSON.stringify(state)}
|
|
42434
|
+
`);
|
|
42435
|
+
};
|
|
42436
|
+
targetForSelection = async (selection) => {
|
|
42437
|
+
const script = join13(dirname12(selection.script), "vtx-service-bootstrap.js");
|
|
42438
|
+
await access4(script);
|
|
42439
|
+
return { package_version: selection.package_version, script, selection };
|
|
42440
|
+
};
|
|
42441
|
+
}
|
|
42442
|
+
});
|
|
42443
|
+
|
|
42364
42444
|
// lib/runtime-policy.generated.json with { type: 'json' }
|
|
42365
42445
|
var runtime_policy_generated_default2;
|
|
42366
42446
|
var init_runtime_policy_generated2 = __esm({
|
|
@@ -42449,6 +42529,14 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42449
42529
|
host_liveness_heartbeat_interval_ms: 3e4,
|
|
42450
42530
|
host_liveness_recovery_nudge_ttl_ms: 1e4
|
|
42451
42531
|
}
|
|
42532
|
+
},
|
|
42533
|
+
server_runtime: {
|
|
42534
|
+
prompt_rescue: {
|
|
42535
|
+
client_long_poll_seconds: 20,
|
|
42536
|
+
client_claim_http_timeout_milliseconds: 25e3,
|
|
42537
|
+
client_presence_heartbeat_interval_milliseconds: 3e4,
|
|
42538
|
+
client_presence_http_timeout_milliseconds: 5e3
|
|
42539
|
+
}
|
|
42452
42540
|
}
|
|
42453
42541
|
}
|
|
42454
42542
|
},
|
|
@@ -42456,6 +42544,8 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42456
42544
|
service: {
|
|
42457
42545
|
update_check_interval_ms: 3e5,
|
|
42458
42546
|
update_registry_timeout_ms: 15e3,
|
|
42547
|
+
bootstrap_readiness_timeout_ms: 6e5,
|
|
42548
|
+
bootstrap_stop_timeout_ms: 1e4,
|
|
42459
42549
|
startup_max_attempts: 40,
|
|
42460
42550
|
startup_poll_interval_ms: 250,
|
|
42461
42551
|
restart_stable_uptime_ms: 6e4,
|
|
@@ -42491,7 +42581,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42491
42581
|
exchange: {
|
|
42492
42582
|
hyperliquid: {
|
|
42493
42583
|
client_public_read_budget: {
|
|
42494
|
-
max_weight:
|
|
42584
|
+
max_weight: 1200,
|
|
42495
42585
|
window_seconds: 60,
|
|
42496
42586
|
cooldown_seconds: 60,
|
|
42497
42587
|
metadata_ttl_seconds: 300,
|
|
@@ -42502,6 +42592,7 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42502
42592
|
},
|
|
42503
42593
|
read_budget: {
|
|
42504
42594
|
weights: {
|
|
42595
|
+
exchange: 1,
|
|
42505
42596
|
exchangeStatus: 2,
|
|
42506
42597
|
clearinghouseState: 2,
|
|
42507
42598
|
spotClearinghouseState: 2,
|
|
@@ -42532,7 +42623,8 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42532
42623
|
authorizedAgents: 20,
|
|
42533
42624
|
agents: 20,
|
|
42534
42625
|
apiWallets: 20
|
|
42535
|
-
}
|
|
42626
|
+
},
|
|
42627
|
+
exchange_action_batch_size: 40
|
|
42536
42628
|
}
|
|
42537
42629
|
}
|
|
42538
42630
|
}
|
|
@@ -42544,16 +42636,17 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
42544
42636
|
import { spawn as spawn10 } from "node:child_process";
|
|
42545
42637
|
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
42546
42638
|
import { createWriteStream, readFileSync as readFileSync2 } from "node:fs";
|
|
42547
|
-
import { access as
|
|
42639
|
+
import { access as access5, chmod as chmod3, mkdir as mkdir3, readFile as readFile10, rm as rm11, writeFile as writeFile4 } from "node:fs/promises";
|
|
42548
42640
|
import { homedir as homedir2 } from "node:os";
|
|
42549
|
-
import { dirname as
|
|
42550
|
-
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_COOPERATIVE_STOP_SECONDS, SERVICE_UPDATE_STARTUP_SECONDS, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
42641
|
+
import { dirname as dirname13, join as join14, resolve as resolve11 } from "node:path";
|
|
42642
|
+
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_COOPERATIVE_STOP_SECONDS, SERVICE_UPDATE_STARTUP_SECONDS, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
42551
42643
|
var init_service = __esm({
|
|
42552
42644
|
"lib/inference-host/service.ts"() {
|
|
42553
42645
|
"use strict";
|
|
42554
42646
|
init_define_VTX_EXO_POLICY();
|
|
42555
42647
|
init_define_VTX_GROK_POLICY();
|
|
42556
42648
|
init_define_VTX_PI_MODEL_POLICY();
|
|
42649
|
+
init_service_launcher_state();
|
|
42557
42650
|
init_agent_cli_release();
|
|
42558
42651
|
init_runtime_policy_generated2();
|
|
42559
42652
|
init_durable_adapter();
|
|
@@ -42619,6 +42712,18 @@ var init_service = __esm({
|
|
|
42619
42712
|
stderr: Buffer.concat(stderr).toString("utf8")
|
|
42620
42713
|
}));
|
|
42621
42714
|
});
|
|
42715
|
+
probeInferenceHostLauncher = async (executable, destination, bytes3, runCommand = defaultRunCommand) => {
|
|
42716
|
+
const probe = `${destination}.${randomUUID9()}.probe.js`;
|
|
42717
|
+
try {
|
|
42718
|
+
await writeAtomicInferencePrivateFile(probe, bytes3);
|
|
42719
|
+
const result2 = await runCommand(executable, [probe]);
|
|
42720
|
+
if (result2.exitCode !== 1 || result2.stdout.trim() || result2.stderr.trim() !== "Internal service manifest and lock paths are required.") {
|
|
42721
|
+
throw new Error("Copied service launcher failed its isolated startup check.");
|
|
42722
|
+
}
|
|
42723
|
+
} finally {
|
|
42724
|
+
await rm11(probe, { force: true });
|
|
42725
|
+
}
|
|
42726
|
+
};
|
|
42622
42727
|
managerName = (platform) => {
|
|
42623
42728
|
if (platform === "win32") return "windows-task-scheduler";
|
|
42624
42729
|
if (platform === "darwin") return "launch-agent";
|
|
@@ -42959,10 +43064,10 @@ WantedBy=default.target
|
|
|
42959
43064
|
this.config = config2;
|
|
42960
43065
|
this.platform = dependencies.platform ?? process.platform;
|
|
42961
43066
|
this.home = dependencies.homedir ?? homedir2();
|
|
42962
|
-
this.executable =
|
|
42963
|
-
this.script =
|
|
42964
|
-
this.bootstrapScript =
|
|
42965
|
-
dependencies.bootstrapScript ??
|
|
43067
|
+
this.executable = resolve11(dependencies.executable ?? process.execPath);
|
|
43068
|
+
this.script = resolve11(dependencies.script ?? process.argv[1] ?? "");
|
|
43069
|
+
this.bootstrapScript = resolve11(
|
|
43070
|
+
dependencies.bootstrapScript ?? join14(dirname13(this.script), "vtx-service-launcher.js")
|
|
42966
43071
|
);
|
|
42967
43072
|
this.username = dependencies.username ?? ([process.env.USERDOMAIN, process.env.USERNAME].filter(Boolean).join("\\") || process.env.USER || "");
|
|
42968
43073
|
this.windowsDirectory = (dependencies.windowsDirectory ?? process.env.SystemRoot ?? process.env.WINDIR ?? "C:\\Windows").replace(/[\\/]+$/u, "");
|
|
@@ -43048,16 +43153,16 @@ WantedBy=default.target
|
|
|
43048
43153
|
}
|
|
43049
43154
|
definitionPath() {
|
|
43050
43155
|
if (this.platform === "win32") return `${this.config.supervisorStatePath}.service-task.xml`;
|
|
43051
|
-
if (this.platform === "darwin") return
|
|
43052
|
-
return
|
|
43156
|
+
if (this.platform === "darwin") return join14(this.home, "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
43157
|
+
return join14(this.home, ".config", "systemd", "user", SYSTEMD_UNIT);
|
|
43053
43158
|
}
|
|
43054
43159
|
windowsLauncherPath() {
|
|
43055
43160
|
return `${this.config.supervisorStatePath}.service-launcher.vbs`;
|
|
43056
43161
|
}
|
|
43057
43162
|
async hasBootstrapDefinition() {
|
|
43058
43163
|
try {
|
|
43059
|
-
await
|
|
43060
|
-
const definition = await
|
|
43164
|
+
await access5(this.serviceBootstrapPath());
|
|
43165
|
+
const definition = await readFile10(
|
|
43061
43166
|
this.platform === "win32" ? this.windowsLauncherPath() : this.definitionPath(),
|
|
43062
43167
|
"utf8"
|
|
43063
43168
|
);
|
|
@@ -43187,24 +43292,36 @@ ${result2.stderr}`)) {
|
|
|
43187
43292
|
);
|
|
43188
43293
|
}
|
|
43189
43294
|
async registerManifestUnlocked(manifest, desiredRunning, targetInstanceName) {
|
|
43190
|
-
await
|
|
43295
|
+
await access5(this.bootstrapScript);
|
|
43191
43296
|
const args = serviceBootstrapArguments(
|
|
43192
43297
|
this.serviceBootstrapPath(),
|
|
43193
43298
|
this.manifestPath(),
|
|
43194
43299
|
this.serviceBootstrapLockPath()
|
|
43195
43300
|
);
|
|
43196
43301
|
const definition = this.platform === "win32" ? windowsTaskXml(this.windowsLauncherPath(), this.windowsDirectory, this.username) : this.platform === "darwin" ? launchAgentPlist(manifest.executable, args, manifest.log_path) : systemdUnit(manifest.executable, args);
|
|
43302
|
+
const existingRecovery = await readLauncherState(this.manifestPath());
|
|
43197
43303
|
let managerInstallAttempted = false;
|
|
43198
43304
|
try {
|
|
43199
43305
|
await writeAtomicInferencePrivateFile(this.manifestPath(), `${JSON.stringify(manifest, null, 2)}
|
|
43200
43306
|
`);
|
|
43201
43307
|
await writeDesired(this.desiredPath(), desiredRunning, this.now());
|
|
43202
|
-
await
|
|
43203
|
-
|
|
43204
|
-
await
|
|
43205
|
-
|
|
43308
|
+
const launcherBytes = await readFile10(this.bootstrapScript, "utf8");
|
|
43309
|
+
if (this.bootstrapScript.endsWith("vtx-service-launcher.js") && !existingRecovery) {
|
|
43310
|
+
await probeInferenceHostLauncher(manifest.executable, this.serviceBootstrapPath(), launcherBytes, this.runCommand);
|
|
43311
|
+
const core = launcherSibling(this.manifestPath(), ".service-bootstrap.previous.js");
|
|
43312
|
+
const coreBytes = await readFile10(join14(dirname13(this.bootstrapScript), "vtx-service-bootstrap.js"), "utf8");
|
|
43313
|
+
await probeInferenceHostLauncher(manifest.executable, core, coreBytes, this.runCommand);
|
|
43314
|
+
await writeAtomicInferencePrivateFile(core, coreBytes);
|
|
43315
|
+
await writeLauncherState(this.manifestPath(), {
|
|
43316
|
+
schema_version: "vtx_inference_service_launcher_v1",
|
|
43317
|
+
active: { package_version: agent_cli_release_default.package_version, script: core, selection: null },
|
|
43318
|
+
previous: null,
|
|
43319
|
+
pending: false
|
|
43320
|
+
});
|
|
43321
|
+
}
|
|
43322
|
+
if (!existingRecovery) await writeAtomicInferencePrivateFile(this.serviceBootstrapPath(), launcherBytes);
|
|
43206
43323
|
await chmod3(this.serviceBootstrapPath(), 448);
|
|
43207
|
-
await mkdir3(
|
|
43324
|
+
await mkdir3(dirname13(this.definitionPath()), { recursive: true, mode: 448 });
|
|
43208
43325
|
if (this.platform === "win32") {
|
|
43209
43326
|
await writeAtomicInferencePrivateFile(
|
|
43210
43327
|
this.windowsLauncherPath(),
|
|
@@ -43257,14 +43374,17 @@ ${cleanup.stderr}`)) {
|
|
|
43257
43374
|
);
|
|
43258
43375
|
}
|
|
43259
43376
|
}
|
|
43260
|
-
await
|
|
43377
|
+
await rm11(this.definitionPath(), { force: true }).catch(() => void 0);
|
|
43261
43378
|
if (this.platform === "win32") {
|
|
43262
|
-
await
|
|
43379
|
+
await rm11(this.windowsLauncherPath(), { force: true }).catch(() => void 0);
|
|
43380
|
+
}
|
|
43381
|
+
await rm11(this.manifestPath(), { force: true }).catch(() => void 0);
|
|
43382
|
+
await rm11(this.desiredPath(), { force: true }).catch(() => void 0);
|
|
43383
|
+
await rm11(this.runtimePath(), { force: true }).catch(() => void 0);
|
|
43384
|
+
if (!existingRecovery) await rm11(this.serviceBootstrapPath(), { force: true }).catch(() => void 0);
|
|
43385
|
+
for (const suffix of [".service-launcher.json", ".service-bootstrap.previous.js"]) {
|
|
43386
|
+
if (!existingRecovery) await rm11(launcherSibling(this.manifestPath(), suffix), { force: true }).catch(() => void 0);
|
|
43263
43387
|
}
|
|
43264
|
-
await rm10(this.manifestPath(), { force: true }).catch(() => void 0);
|
|
43265
|
-
await rm10(this.desiredPath(), { force: true }).catch(() => void 0);
|
|
43266
|
-
await rm10(this.runtimePath(), { force: true }).catch(() => void 0);
|
|
43267
|
-
await rm10(this.serviceBootstrapPath(), { force: true }).catch(() => void 0);
|
|
43268
43388
|
if (this.platform === "linux") {
|
|
43269
43389
|
await this.runCommand("systemctl", ["--user", "daemon-reload"]).catch(() => void 0);
|
|
43270
43390
|
}
|
|
@@ -43324,7 +43444,7 @@ ${cleanup.stderr}`)) {
|
|
|
43324
43444
|
}
|
|
43325
43445
|
if (previous) {
|
|
43326
43446
|
try {
|
|
43327
|
-
await this.uninstallUnlocked();
|
|
43447
|
+
await this.uninstallUnlocked(true);
|
|
43328
43448
|
} catch (error48) {
|
|
43329
43449
|
throw new Error(
|
|
43330
43450
|
"Inference-host service reconfiguration could not stop the previous supervisor; its desired state was restored.",
|
|
@@ -43390,15 +43510,15 @@ ${cleanup.stderr}`)) {
|
|
|
43390
43510
|
}
|
|
43391
43511
|
if (this.config.credentialFilePath && otherWorkers.some((worker) => {
|
|
43392
43512
|
const otherPath = worker.runtime_environment.VTX_INFERENCE_HOST_CREDENTIAL_FILE;
|
|
43393
|
-
return otherPath &&
|
|
43513
|
+
return otherPath && resolve11(otherPath) === resolve11(this.config.credentialFilePath);
|
|
43394
43514
|
})) {
|
|
43395
43515
|
throw new Error(
|
|
43396
43516
|
"Each inference-host instance must use a different private credential file."
|
|
43397
43517
|
);
|
|
43398
43518
|
}
|
|
43399
|
-
await
|
|
43400
|
-
await
|
|
43401
|
-
await
|
|
43519
|
+
await access5(this.executable);
|
|
43520
|
+
await access5(this.script);
|
|
43521
|
+
await access5(this.bootstrapScript);
|
|
43402
43522
|
const maxConcurrency = options.maxConcurrency ?? null;
|
|
43403
43523
|
const workers = [
|
|
43404
43524
|
...existing?.workers.filter((worker) => worker.instance_name !== this.config.instanceName) ?? [],
|
|
@@ -43608,7 +43728,7 @@ ${result2.stderr}`)) {
|
|
|
43608
43728
|
const manifest = await readInferenceHostServiceManifest(this.manifestPath());
|
|
43609
43729
|
const path = manifest?.log_path ?? this.logPath();
|
|
43610
43730
|
try {
|
|
43611
|
-
const contents = await
|
|
43731
|
+
const contents = await readFile10(path, "utf8");
|
|
43612
43732
|
const logLines = contents.trimEnd().split(/\r?\n/u);
|
|
43613
43733
|
const filtered = instanceName ? logLines.filter((line) => {
|
|
43614
43734
|
try {
|
|
@@ -43647,7 +43767,7 @@ ${result2.stderr}`)) {
|
|
|
43647
43767
|
async uninstall() {
|
|
43648
43768
|
return await this.withControlLock(async () => await this.uninstallUnlocked());
|
|
43649
43769
|
}
|
|
43650
|
-
async uninstallUnlocked() {
|
|
43770
|
+
async uninstallUnlocked(preserveRecovery = false) {
|
|
43651
43771
|
const manifest = await readInferenceHostServiceManifest(this.manifestPath());
|
|
43652
43772
|
if (!manifest) throw new Error("Inference-host service is not installed.");
|
|
43653
43773
|
const current = await this.status();
|
|
@@ -43661,16 +43781,21 @@ ${result2.stderr}`)) {
|
|
|
43661
43781
|
${result2.stderr}`)) {
|
|
43662
43782
|
throw new Error(`Background service uninstall failed: ${result2.stderr.trim()}`);
|
|
43663
43783
|
}
|
|
43664
|
-
await
|
|
43665
|
-
if (this.platform === "win32") await
|
|
43784
|
+
await rm11(this.definitionPath(), { force: true });
|
|
43785
|
+
if (this.platform === "win32") await rm11(this.windowsLauncherPath(), { force: true });
|
|
43666
43786
|
if (this.platform === "linux") await this.runCommand("systemctl", ["--user", "daemon-reload"]);
|
|
43667
|
-
await
|
|
43668
|
-
await
|
|
43669
|
-
await
|
|
43670
|
-
|
|
43671
|
-
|
|
43672
|
-
|
|
43673
|
-
|
|
43787
|
+
await rm11(this.manifestPath(), { force: true });
|
|
43788
|
+
await rm11(this.desiredPath(), { force: true });
|
|
43789
|
+
await rm11(this.runtimePath(), { force: true });
|
|
43790
|
+
if (!preserveRecovery) {
|
|
43791
|
+
await rm11(this.serviceBootstrapPath(), { force: true });
|
|
43792
|
+
for (const suffix of [".service-launcher.json", ".service-bootstrap.previous.js"]) {
|
|
43793
|
+
await rm11(launcherSibling(this.manifestPath(), suffix), { force: true });
|
|
43794
|
+
}
|
|
43795
|
+
await rm11(this.serviceReleasePath(), { force: true });
|
|
43796
|
+
await rm11(this.serviceReleaseRejectionPath(), { force: true });
|
|
43797
|
+
await rm11(this.serviceReleasesPath(), { recursive: true, force: true });
|
|
43798
|
+
}
|
|
43674
43799
|
return {
|
|
43675
43800
|
installed: false,
|
|
43676
43801
|
desired_running: false,
|
|
@@ -43684,7 +43809,7 @@ ${result2.stderr}`)) {
|
|
|
43684
43809
|
}
|
|
43685
43810
|
};
|
|
43686
43811
|
appendServiceLog = async (path, event, fields = {}) => {
|
|
43687
|
-
await mkdir3(
|
|
43812
|
+
await mkdir3(dirname13(path), { recursive: true, mode: 448 });
|
|
43688
43813
|
const stream = createWriteStream(path, { flags: "a", mode: 384 });
|
|
43689
43814
|
await new Promise((resolvePromise, reject) => {
|
|
43690
43815
|
stream.once("error", reject);
|
|
@@ -43813,7 +43938,7 @@ ${result2.stderr}`)) {
|
|
|
43813
43938
|
runInferenceHostServiceSupervisor = async (manifestPath, options = {}) => {
|
|
43814
43939
|
const storedInitialManifest = await readInferenceHostServiceManifest(manifestPath);
|
|
43815
43940
|
if (!storedInitialManifest) throw new Error("Inference-host service manifest is missing.");
|
|
43816
|
-
const serviceScript = options.serviceScript ?
|
|
43941
|
+
const serviceScript = options.serviceScript ? resolve11(options.serviceScript) : null;
|
|
43817
43942
|
const withServiceScript = (manifest) => serviceScript ? { ...manifest, script: serviceScript } : manifest;
|
|
43818
43943
|
const initialManifest = withServiceScript(storedInitialManifest);
|
|
43819
43944
|
const desiredPath = manifestPath.replace(/\.service\.json$/u, ".service-desired.json");
|
|
@@ -43823,6 +43948,21 @@ ${result2.stderr}`)) {
|
|
|
43823
43948
|
const quiesceSignal = options.quiesceSignal ? AbortSignal.any([options.quiesceSignal, migrationQuiesce.signal]) : migrationQuiesce.signal;
|
|
43824
43949
|
let bootstrapRestartRequired = false;
|
|
43825
43950
|
let bootstrapMigrationErrorReported = false;
|
|
43951
|
+
const priorSelection = await readLauncherSelection(manifestPath);
|
|
43952
|
+
const parentBootstrapVersion = options.bootstrapVersion ?? process.env.VTX_INFERENCE_HOST_BOOTSTRAP_VERSION;
|
|
43953
|
+
if (serviceScript && options.controlLockPath && parentBootstrapVersion && parentBootstrapVersion !== agent_cli_release_default.package_version && process.env.VTX_INFERENCE_HOST_LAUNCHER_PROTOCOL !== "1" && !await readLauncherState(manifestPath) && priorSelection?.package_version === parentBootstrapVersion) {
|
|
43954
|
+
const previousCore = launcherSibling(manifestPath, ".service-bootstrap.previous.js");
|
|
43955
|
+
await writeAtomicInferencePrivateFile(
|
|
43956
|
+
previousCore,
|
|
43957
|
+
await readFile10(launcherSibling(manifestPath, ".service-bootstrap.js"), "utf8")
|
|
43958
|
+
);
|
|
43959
|
+
await writeLauncherState(manifestPath, {
|
|
43960
|
+
schema_version: "vtx_inference_service_launcher_v1",
|
|
43961
|
+
active: { package_version: parentBootstrapVersion, script: previousCore, selection: priorSelection },
|
|
43962
|
+
previous: null,
|
|
43963
|
+
pending: false
|
|
43964
|
+
});
|
|
43965
|
+
}
|
|
43826
43966
|
const migrateSelectedBootstrap = async () => {
|
|
43827
43967
|
if (!serviceScript || !options.controlLockPath || bootstrapRestartRequired || (options.bootstrapVersion ?? process.env.VTX_INFERENCE_HOST_BOOTSTRAP_VERSION) === agent_cli_release_default.package_version || quiesceSignal.aborted || signal.aborted) return;
|
|
43828
43968
|
let controlLock;
|
|
@@ -43835,16 +43975,25 @@ ${result2.stderr}`)) {
|
|
|
43835
43975
|
try {
|
|
43836
43976
|
const current = await readManifestAcrossAtomicReplacement(manifestPath);
|
|
43837
43977
|
if (!current || current.generation !== appliedManifest.generation || !await readDesiredAcrossAtomicReplacement(desiredPath) || signal.aborted) return;
|
|
43838
|
-
|
|
43839
|
-
|
|
43840
|
-
|
|
43841
|
-
|
|
43842
|
-
|
|
43843
|
-
|
|
43978
|
+
const selected = await readLauncherSelection(manifestPath);
|
|
43979
|
+
if (!selected || selected.package_version !== agent_cli_release_default.package_version || resolve11(selected.script) !== serviceScript) return;
|
|
43980
|
+
if (process.env.VTX_INFERENCE_HOST_LAUNCHER_PROTOCOL !== "1") {
|
|
43981
|
+
const launcherPath = launcherSibling(manifestPath, ".service-bootstrap.js");
|
|
43982
|
+
const bytes3 = await readFile10(join14(dirname13(serviceScript), "vtx-service-launcher.js"), "utf8");
|
|
43983
|
+
await (options.probeLauncher ?? probeInferenceHostLauncher)(current.executable, launcherPath, bytes3);
|
|
43984
|
+
const existing = await readLauncherState(manifestPath);
|
|
43985
|
+
if (!existing) throw new Error("Previous private service release is unavailable; refusing unsafe launcher migration.");
|
|
43986
|
+
const previous = existing.active.package_version === selected.package_version ? existing.previous : existing.active;
|
|
43987
|
+
if (!previous) throw new Error("Previous service launcher recovery target is unavailable.");
|
|
43988
|
+
await writeLauncherState(manifestPath, {
|
|
43989
|
+
schema_version: "vtx_inference_service_launcher_v1",
|
|
43990
|
+
active: await targetForSelection(selected),
|
|
43991
|
+
previous,
|
|
43992
|
+
pending: false
|
|
43993
|
+
});
|
|
43994
|
+
if (!await readDesiredAcrossAtomicReplacement(desiredPath) || signal.aborted) return;
|
|
43995
|
+
await writeAtomicInferencePrivateFile(launcherPath, bytes3);
|
|
43844
43996
|
}
|
|
43845
|
-
if (selected.schema_version !== "vtx_inference_service_release_v1" || selected.package_name !== "@vtxmacro/cli" || selected.package_version !== agent_cli_release_default.package_version || typeof selected.script !== "string" || resolve10(selected.script) !== serviceScript) return;
|
|
43846
|
-
const bytes3 = await readFile9(join13(dirname12(serviceScript), "vtx-service-bootstrap.js"), "utf8");
|
|
43847
|
-
await writeAtomicInferencePrivateFile(manifestPath.replace(/\.service\.json$/u, ".service-bootstrap.js"), bytes3);
|
|
43848
43997
|
bootstrapRestartRequired = true;
|
|
43849
43998
|
migrationQuiesce.abort();
|
|
43850
43999
|
} finally {
|
|
@@ -44110,9 +44259,9 @@ __export(cli_exports, {
|
|
|
44110
44259
|
});
|
|
44111
44260
|
import { createHash as createHash12, randomUUID as randomUUID10 } from "node:crypto";
|
|
44112
44261
|
import { spawn as spawn11 } from "node:child_process";
|
|
44113
|
-
import { lstat as lstat9, realpath as realpath8, rm as
|
|
44262
|
+
import { lstat as lstat9, realpath as realpath8, rm as rm12 } from "node:fs/promises";
|
|
44114
44263
|
import { hostname as osHostname } from "node:os";
|
|
44115
|
-
import { join as
|
|
44264
|
+
import { join as join15, resolve as resolve12 } from "node:path";
|
|
44116
44265
|
async function runInferenceHostCli(argv2, env = process.env, dependencies = {}) {
|
|
44117
44266
|
const warnings = [];
|
|
44118
44267
|
try {
|
|
@@ -44500,7 +44649,7 @@ Durable service:
|
|
|
44500
44649
|
if (!raw?.trim()) throw new Error(`${argument} requires a value.`);
|
|
44501
44650
|
if (argument === "--adapter") adapter = raw.trim();
|
|
44502
44651
|
if (argument === "--provider") providerId = raw.trim();
|
|
44503
|
-
if (argument === "--exo-root") exoRoot =
|
|
44652
|
+
if (argument === "--exo-root") exoRoot = resolve12(raw.trim());
|
|
44504
44653
|
if (argument === "--model") modelId = raw.trim();
|
|
44505
44654
|
if (argument === "--model-label") modelLabel = raw.trim();
|
|
44506
44655
|
if (argument === "--effort") reasoningEffort = raw.trim();
|
|
@@ -44516,7 +44665,7 @@ Durable service:
|
|
|
44516
44665
|
throw new Error("--lines must be an integer from 1 through 10000.");
|
|
44517
44666
|
}
|
|
44518
44667
|
}
|
|
44519
|
-
if (argument === "--service-manifest") serviceManifestPath =
|
|
44668
|
+
if (argument === "--service-manifest") serviceManifestPath = resolve12(raw.trim());
|
|
44520
44669
|
if (argument === "--instance") {
|
|
44521
44670
|
instanceName = raw.trim();
|
|
44522
44671
|
instanceExplicit = true;
|
|
@@ -44609,10 +44758,24 @@ Durable service:
|
|
|
44609
44758
|
quiesce?.();
|
|
44610
44759
|
}
|
|
44611
44760
|
};
|
|
44761
|
+
let parentLost = false;
|
|
44762
|
+
const onParentLost = () => {
|
|
44763
|
+
if (parentLost) return;
|
|
44764
|
+
parentLost = true;
|
|
44765
|
+
if (quiesce) quiesce();
|
|
44766
|
+
else abort();
|
|
44767
|
+
};
|
|
44612
44768
|
input.on("data", onControlInput);
|
|
44769
|
+
input.on("end", onParentLost);
|
|
44770
|
+
input.on("close", onParentLost);
|
|
44771
|
+
input.on("error", onParentLost);
|
|
44613
44772
|
input.resume();
|
|
44773
|
+
if (input.readableEnded || input.destroyed) onParentLost();
|
|
44614
44774
|
return () => {
|
|
44615
44775
|
input.off("data", onControlInput);
|
|
44776
|
+
input.off("end", onParentLost);
|
|
44777
|
+
input.off("close", onParentLost);
|
|
44778
|
+
input.off("error", onParentLost);
|
|
44616
44779
|
input.pause();
|
|
44617
44780
|
};
|
|
44618
44781
|
};
|
|
@@ -44714,11 +44877,11 @@ Durable service:
|
|
|
44714
44877
|
return raw !== null;
|
|
44715
44878
|
};
|
|
44716
44879
|
inspectCodexAuthentication = async (config2) => {
|
|
44717
|
-
const path =
|
|
44880
|
+
const path = join15(config2.codexHomePath, "auth.json");
|
|
44718
44881
|
try {
|
|
44719
44882
|
const before = await lstat9(path);
|
|
44720
44883
|
const canonical = await realpath8(path);
|
|
44721
|
-
const isPrivate = before.isFile() && !before.isSymbolicLink() && canonical ===
|
|
44884
|
+
const isPrivate = before.isFile() && !before.isSymbolicLink() && canonical === resolve12(path) && before.size <= 8 * 1024 * 1024 && (process.platform === "win32" || (before.mode & 63) === 0 && (typeof process.getuid !== "function" || before.uid === process.getuid()));
|
|
44722
44885
|
return { present: true, private: isPrivate };
|
|
44723
44886
|
} catch (error48) {
|
|
44724
44887
|
if (error48.code === "ENOENT") {
|
|
@@ -44735,7 +44898,7 @@ Durable service:
|
|
|
44735
44898
|
runtimeReceiptPath(config2),
|
|
44736
44899
|
"Inference host runtime receipt file"
|
|
44737
44900
|
);
|
|
44738
|
-
await
|
|
44901
|
+
await rm12(codexGuardianReceiptRoot(config2), { recursive: true, force: true });
|
|
44739
44902
|
await clearInferencePrivateFile(
|
|
44740
44903
|
codexRecoveryPath(config2),
|
|
44741
44904
|
"Codex attempt recovery file"
|
|
@@ -45043,20 +45206,20 @@ Waiting for approval...
|
|
|
45043
45206
|
} catch {
|
|
45044
45207
|
}
|
|
45045
45208
|
}
|
|
45046
|
-
let
|
|
45209
|
+
let access6;
|
|
45047
45210
|
try {
|
|
45048
|
-
|
|
45211
|
+
access6 = await pending3.completion;
|
|
45049
45212
|
} catch (error48) {
|
|
45050
45213
|
await pending3.cancel().catch(() => void 0);
|
|
45051
45214
|
throw error48;
|
|
45052
45215
|
}
|
|
45053
45216
|
const state = {
|
|
45054
45217
|
schema_version: 1,
|
|
45055
|
-
issuer:
|
|
45056
|
-
client_id:
|
|
45057
|
-
host_id:
|
|
45218
|
+
issuer: access6.credential.issuer,
|
|
45219
|
+
client_id: access6.credential.client_id,
|
|
45220
|
+
host_id: access6.credential.host_id,
|
|
45058
45221
|
host_generation: 1,
|
|
45059
|
-
key_generation:
|
|
45222
|
+
key_generation: access6.credential.key_generation
|
|
45060
45223
|
};
|
|
45061
45224
|
try {
|
|
45062
45225
|
await writeInferenceHostLocalState(config2.statePath, state);
|
|
@@ -45066,7 +45229,7 @@ Waiting for approval...
|
|
|
45066
45229
|
const metadata = await (dependencies.discoverOAuth ?? discoverInferenceOAuth)(config2.apiUrl);
|
|
45067
45230
|
await (dependencies.revokeCredential ?? revokeInferenceCredential)({
|
|
45068
45231
|
metadata,
|
|
45069
|
-
credential:
|
|
45232
|
+
credential: access6.credential,
|
|
45070
45233
|
store
|
|
45071
45234
|
});
|
|
45072
45235
|
remoteCleanupConfirmed = true;
|
|
@@ -45078,8 +45241,8 @@ Waiting for approval...
|
|
|
45078
45241
|
{ cause: stateError }
|
|
45079
45242
|
);
|
|
45080
45243
|
}
|
|
45081
|
-
await store.writeRecovery(
|
|
45082
|
-
await store.remove(
|
|
45244
|
+
await store.writeRecovery(access6.accountKey, access6.credential);
|
|
45245
|
+
await store.remove(access6.accountKey).catch(() => void 0);
|
|
45083
45246
|
}
|
|
45084
45247
|
if (!remoteCleanupConfirmed) {
|
|
45085
45248
|
throw new Error(
|
|
@@ -45984,7 +46147,7 @@ Waiting for approval...
|
|
|
45984
46147
|
const session = await agentSession(config2, dependencies, warnings);
|
|
45985
46148
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
45986
46149
|
const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
|
|
45987
|
-
await new Promise((
|
|
46150
|
+
await new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
45988
46151
|
});
|
|
45989
46152
|
const stopAt = now().getTime() + parsed.waitSeconds * 1e3;
|
|
45990
46153
|
let state = await readInferenceForegroundAgentControlState(config2.statePath) ?? foregroundAgentControlState(session.localState.host_id, now().toISOString());
|
|
@@ -46521,7 +46684,7 @@ Waiting for approval...
|
|
|
46521
46684
|
}
|
|
46522
46685
|
if (parsed.once && !commandLock) break;
|
|
46523
46686
|
await (dependencies.sleep ?? (async (milliseconds) => {
|
|
46524
|
-
await new Promise((
|
|
46687
|
+
await new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
46525
46688
|
}))(retryDelayMs);
|
|
46526
46689
|
}
|
|
46527
46690
|
return {
|
|
@@ -46550,7 +46713,7 @@ Waiting for approval...
|
|
|
46550
46713
|
const session = await agentSession(config2, dependencies, warnings);
|
|
46551
46714
|
const now = dependencies.now ?? (() => /* @__PURE__ */ new Date());
|
|
46552
46715
|
const sleep4 = dependencies.sleep ?? (async (milliseconds) => {
|
|
46553
|
-
await new Promise((
|
|
46716
|
+
await new Promise((resolve13) => setTimeout(resolve13, milliseconds));
|
|
46554
46717
|
});
|
|
46555
46718
|
const stopAt = now().getTime() + parsed.waitSeconds * 1e3;
|
|
46556
46719
|
while (true) {
|
|
@@ -46867,7 +47030,7 @@ Waiting for approval...
|
|
|
46867
47030
|
) || 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) {
|
|
46868
47031
|
throw new Error("Inference-host service recovery transaction is invalid.");
|
|
46869
47032
|
}
|
|
46870
|
-
if (
|
|
47033
|
+
if (resolve12(record5.recovery_backup_path) !== resolve12(recoveryBackupPath(config2, record5.transaction_id))) {
|
|
46871
47034
|
throw new Error("Inference-host service recovery backup path is invalid.");
|
|
46872
47035
|
}
|
|
46873
47036
|
return record5;
|
|
@@ -47118,7 +47281,7 @@ Waiting for approval...
|
|
|
47118
47281
|
serviceRecoveryTransactionPath(config2),
|
|
47119
47282
|
"Inference-host service recovery transaction"
|
|
47120
47283
|
);
|
|
47121
|
-
await
|
|
47284
|
+
await rm12(backupPath, { force: true });
|
|
47122
47285
|
}
|
|
47123
47286
|
}
|
|
47124
47287
|
} finally {
|
|
@@ -47148,7 +47311,7 @@ Waiting for approval...
|
|
|
47148
47311
|
{
|
|
47149
47312
|
signal: cancellation.signal,
|
|
47150
47313
|
quiesceSignal: cancellation.quiesceSignal,
|
|
47151
|
-
serviceScript:
|
|
47314
|
+
serviceScript: resolve12(process.argv[1] ?? ""),
|
|
47152
47315
|
controlLockPath: `${supervisorConfig.supervisorProcessLockPath}.service-control`
|
|
47153
47316
|
}
|
|
47154
47317
|
);
|
|
@@ -47374,7 +47537,7 @@ Waiting for approval...
|
|
|
47374
47537
|
...selectedEnv,
|
|
47375
47538
|
...retainedEnvironment
|
|
47376
47539
|
});
|
|
47377
|
-
if (
|
|
47540
|
+
if (resolve12(installedConfig.statePath) !== resolve12(baseConfig.statePath)) {
|
|
47378
47541
|
throw new Error(
|
|
47379
47542
|
"Installed inference-host service manifest does not match the requested local state path."
|
|
47380
47543
|
);
|
|
@@ -47393,11 +47556,11 @@ Waiting for approval...
|
|
|
47393
47556
|
});
|
|
47394
47557
|
|
|
47395
47558
|
// lib/agent-core/config.ts
|
|
47396
|
-
import { mkdir as mkdir5, readFile as
|
|
47397
|
-
import { dirname as
|
|
47559
|
+
import { mkdir as mkdir5, readFile as readFile11, rm as rm13, writeFile as writeFile5 } from "node:fs/promises";
|
|
47560
|
+
import { dirname as dirname14, join as join16 } from "node:path";
|
|
47398
47561
|
import { homedir as homedir3 } from "node:os";
|
|
47399
47562
|
function defaultBaseDir() {
|
|
47400
|
-
return
|
|
47563
|
+
return join16(homedir3(), ".vtx");
|
|
47401
47564
|
}
|
|
47402
47565
|
function resolveAgentCliConfig(env = process.env) {
|
|
47403
47566
|
const baseDir = String(env.VTX_HOME || "").trim() || defaultBaseDir();
|
|
@@ -47405,8 +47568,8 @@ function resolveAgentCliConfig(env = process.env) {
|
|
|
47405
47568
|
const parsedProfile = rawProfile ? Number(rawProfile) : NaN;
|
|
47406
47569
|
return {
|
|
47407
47570
|
apiUrl: String(env.VTX_API_URL || "http://localhost:8000").replace(/\/+$/, ""),
|
|
47408
|
-
tokenPath: String(env.VTX_TOKEN_PATH || "").trim() ||
|
|
47409
|
-
statePath: String(env.VTX_RUNTIME_STATE_PATH || "").trim() ||
|
|
47571
|
+
tokenPath: String(env.VTX_TOKEN_PATH || "").trim() || join16(baseDir, "token.json"),
|
|
47572
|
+
statePath: String(env.VTX_RUNTIME_STATE_PATH || "").trim() || join16(baseDir, "runtime-state.json"),
|
|
47410
47573
|
runtimeDeviceId: String(env.VTX_RUNTIME_DEVICE_ID || "").trim() || null,
|
|
47411
47574
|
activeProfileId: Number.isFinite(parsedProfile) && parsedProfile > 0 ? parsedProfile : null,
|
|
47412
47575
|
outputJson: String(env.VTX_OUTPUT || "").trim().toLowerCase() === "json"
|
|
@@ -47414,7 +47577,7 @@ function resolveAgentCliConfig(env = process.env) {
|
|
|
47414
47577
|
}
|
|
47415
47578
|
async function readStoredAgentAuth(path) {
|
|
47416
47579
|
try {
|
|
47417
|
-
const raw = await
|
|
47580
|
+
const raw = await readFile11(path, "utf8");
|
|
47418
47581
|
if (!raw.trim()) {
|
|
47419
47582
|
throw new Error(`VTX token file is empty at ${path}. Run "vtx auth login" or remove the file and retry.`);
|
|
47420
47583
|
}
|
|
@@ -47432,16 +47595,16 @@ async function readStoredAgentAuth(path) {
|
|
|
47432
47595
|
}
|
|
47433
47596
|
}
|
|
47434
47597
|
async function writeStoredAgentAuth(path, auth) {
|
|
47435
|
-
await mkdir5(
|
|
47598
|
+
await mkdir5(dirname14(path), { recursive: true });
|
|
47436
47599
|
await writeFile5(path, `${JSON.stringify(auth, null, 2)}
|
|
47437
47600
|
`, { encoding: "utf8", mode: 384 });
|
|
47438
47601
|
}
|
|
47439
47602
|
async function clearStoredAgentAuth(path) {
|
|
47440
|
-
await
|
|
47603
|
+
await rm13(path, { force: true });
|
|
47441
47604
|
}
|
|
47442
47605
|
async function readRuntimeState(path) {
|
|
47443
47606
|
try {
|
|
47444
|
-
const raw = await
|
|
47607
|
+
const raw = await readFile11(path, "utf8");
|
|
47445
47608
|
const parsed = JSON.parse(raw);
|
|
47446
47609
|
const profileId = Number(parsed.profileId);
|
|
47447
47610
|
const runtimeSessionId = String(parsed.runtimeSessionId || "").trim();
|
|
@@ -47467,12 +47630,12 @@ async function readRuntimeState(path) {
|
|
|
47467
47630
|
}
|
|
47468
47631
|
}
|
|
47469
47632
|
async function writeRuntimeState(path, state) {
|
|
47470
|
-
await mkdir5(
|
|
47633
|
+
await mkdir5(dirname14(path), { recursive: true });
|
|
47471
47634
|
await writeFile5(path, `${JSON.stringify(state, null, 2)}
|
|
47472
47635
|
`, { encoding: "utf8", mode: 384 });
|
|
47473
47636
|
}
|
|
47474
47637
|
async function clearRuntimeState(path) {
|
|
47475
|
-
await
|
|
47638
|
+
await rm13(path, { force: true });
|
|
47476
47639
|
}
|
|
47477
47640
|
var init_config2 = __esm({
|
|
47478
47641
|
"lib/agent-core/config.ts"() {
|
|
@@ -47914,7 +48077,7 @@ import {
|
|
|
47914
48077
|
writeFileSync
|
|
47915
48078
|
} from "node:fs";
|
|
47916
48079
|
import { randomUUID as randomUUID12 } from "node:crypto";
|
|
47917
|
-
import { dirname as
|
|
48080
|
+
import { dirname as dirname15 } from "node:path";
|
|
47918
48081
|
var parseStoredValues, FileBackedProtectionStorage, clientRuntimeProtectionStatePath;
|
|
47919
48082
|
var init_protection_storage = __esm({
|
|
47920
48083
|
"lib/agent-core/protection-storage.ts"() {
|
|
@@ -47970,7 +48133,7 @@ var init_protection_storage = __esm({
|
|
|
47970
48133
|
}
|
|
47971
48134
|
}
|
|
47972
48135
|
writeValues(values) {
|
|
47973
|
-
mkdirSync(
|
|
48136
|
+
mkdirSync(dirname15(this.path), { recursive: true, mode: 448 });
|
|
47974
48137
|
const serialized = `${JSON.stringify(values)}
|
|
47975
48138
|
`;
|
|
47976
48139
|
const temporaryPath = `${this.path}.${process.pid}.${randomUUID12()}.tmp`;
|
|
@@ -48403,7 +48566,7 @@ var init_runtime_redaction = __esm({
|
|
|
48403
48566
|
});
|
|
48404
48567
|
|
|
48405
48568
|
// lib/runtime/hyperliquid-public-read.ts
|
|
48406
|
-
var policy, weights, budgets, unpersistedBudgets, cache, pending2, PREFIX, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, admit, cooldown, reserveHyperliquidPublicReads, readHyperliquidPublicInfo;
|
|
48569
|
+
var policy, weights, budgets, unpersistedBudgets, cache, pending2, PREFIX, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, cooldownError, admit, cooldown, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
48407
48570
|
var init_hyperliquid_public_read = __esm({
|
|
48408
48571
|
"lib/runtime/hyperliquid-public-read.ts"() {
|
|
48409
48572
|
"use strict";
|
|
@@ -48423,7 +48586,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48423
48586
|
checkAbort = (signal) => {
|
|
48424
48587
|
if (signal?.aborted) throw abortError2(signal);
|
|
48425
48588
|
};
|
|
48426
|
-
wait = (ms, signal) => new Promise((
|
|
48589
|
+
wait = (ms, signal) => new Promise((resolve13, reject) => {
|
|
48427
48590
|
checkAbort(signal);
|
|
48428
48591
|
const aborted2 = () => {
|
|
48429
48592
|
clearTimeout(timer);
|
|
@@ -48431,7 +48594,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48431
48594
|
};
|
|
48432
48595
|
const timer = setTimeout(() => {
|
|
48433
48596
|
signal?.removeEventListener("abort", aborted2);
|
|
48434
|
-
|
|
48597
|
+
resolve13();
|
|
48435
48598
|
}, Math.min(ms, 2147483647));
|
|
48436
48599
|
signal?.addEventListener("abort", aborted2, { once: true });
|
|
48437
48600
|
});
|
|
@@ -48475,31 +48638,54 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48475
48638
|
}
|
|
48476
48639
|
return work();
|
|
48477
48640
|
};
|
|
48478
|
-
|
|
48641
|
+
HyperliquidPublicReadError = class extends Error {
|
|
48642
|
+
constructor(code, message, requestType, status, retryAfterMs, requiredWeight, usedWeight, maxWeight) {
|
|
48643
|
+
super(message);
|
|
48644
|
+
this.code = code;
|
|
48645
|
+
this.requestType = requestType;
|
|
48646
|
+
this.status = status;
|
|
48647
|
+
this.retryAfterMs = retryAfterMs;
|
|
48648
|
+
this.requiredWeight = requiredWeight;
|
|
48649
|
+
this.usedWeight = usedWeight;
|
|
48650
|
+
this.maxWeight = maxWeight;
|
|
48651
|
+
this.name = "HyperliquidPublicReadError";
|
|
48652
|
+
}
|
|
48653
|
+
};
|
|
48654
|
+
cooldownError = (requestType, until) => new HyperliquidPublicReadError(
|
|
48655
|
+
"public_cooldown_active",
|
|
48656
|
+
"Hyperliquid public request cooldown is active.",
|
|
48657
|
+
requestType,
|
|
48658
|
+
void 0,
|
|
48659
|
+
Math.max(0, until - Date.now())
|
|
48660
|
+
);
|
|
48661
|
+
admit = async (apiUrl, requestType, signal, bundleWeight, bundleId, deadlineMs) => {
|
|
48479
48662
|
const key = `${PREFIX}${apiUrl}`;
|
|
48480
48663
|
const weight = bundleWeight ?? weights[requestType] ?? policy.default_request_weight;
|
|
48481
|
-
if (!(weight > 0 && weight <= policy.max_weight)) throw new
|
|
48664
|
+
if (!(weight > 0 && weight <= policy.max_weight)) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid public request exceeds the available allowance.", requestType, void 0, void 0, weight, void 0, policy.max_weight);
|
|
48482
48665
|
for (; ; ) {
|
|
48483
48666
|
checkAbort(signal);
|
|
48484
|
-
const delay2 = await withBudgetLock(key, signal, () => {
|
|
48667
|
+
const { delay: delay2, usedWeight } = await withBudgetLock(key, signal, () => {
|
|
48485
48668
|
const now = Date.now();
|
|
48486
48669
|
const budget = loadBudget(key);
|
|
48487
48670
|
budget.reservations = budget.reservations.filter((r) => r.at > now - policy.window_seconds * 1e3);
|
|
48488
|
-
if (budget.cooldownUntil > now) throw
|
|
48671
|
+
if (budget.cooldownUntil > now) throw cooldownError(requestType, budget.cooldownUntil);
|
|
48489
48672
|
let used = budget.reservations.reduce((sum, r) => sum + r.weight, 0);
|
|
48673
|
+
const usedWeight2 = used;
|
|
48490
48674
|
if (used + weight <= policy.max_weight) {
|
|
48491
48675
|
budget.reservations.push({ at: now, weight, ...bundleId ? { id: bundleId } : {} });
|
|
48492
48676
|
saveBudget(key, budget);
|
|
48493
|
-
return 0;
|
|
48677
|
+
return { delay: 0, usedWeight: usedWeight2 };
|
|
48494
48678
|
}
|
|
48495
48679
|
for (const reservation of budget.reservations) {
|
|
48496
48680
|
used -= reservation.weight;
|
|
48497
|
-
if (used + weight <= policy.max_weight) return Math.max(1, reservation.at + policy.window_seconds * 1e3 - now);
|
|
48681
|
+
if (used + weight <= policy.max_weight) return { delay: Math.max(1, reservation.at + policy.window_seconds * 1e3 - now), usedWeight: usedWeight2 };
|
|
48498
48682
|
}
|
|
48499
48683
|
throw new Error("Invalid Hyperliquid public read budget.");
|
|
48500
48684
|
});
|
|
48501
48685
|
if (!delay2) return;
|
|
48502
|
-
if (bundleWeight != null
|
|
48686
|
+
if (bundleWeight != null || deadlineMs != null && Date.now() + delay2 >= deadlineMs) {
|
|
48687
|
+
throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid local public request allowance is exhausted.", requestType, void 0, delay2, weight, usedWeight, policy.max_weight);
|
|
48688
|
+
}
|
|
48503
48689
|
await wait(delay2, signal);
|
|
48504
48690
|
}
|
|
48505
48691
|
};
|
|
@@ -48514,32 +48700,73 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48514
48700
|
saveBudget(key, budget);
|
|
48515
48701
|
});
|
|
48516
48702
|
};
|
|
48517
|
-
|
|
48703
|
+
cacheTtlMs = (body, options) => {
|
|
48704
|
+
const requestType = String(body.type);
|
|
48705
|
+
return (["meta", "spotMeta", "perpDexs"].includes(requestType) ? policy.metadata_ttl_seconds : requestType === "userFees" ? policy.user_fees_ttl_seconds : options.cacheAccountMode && ["userAbstraction", "userDexAbstraction"].includes(requestType) ? policy.account_mode_ttl_seconds : 0) * 1e3;
|
|
48706
|
+
};
|
|
48707
|
+
eligibleCache = (apiUrl, body, options) => {
|
|
48708
|
+
const ttl = cacheTtlMs(body, options);
|
|
48709
|
+
const existing = cache.get(`${apiUrl}:${JSON.stringify(body)}`);
|
|
48710
|
+
const horizon = Math.max(Date.now(), options.cacheValidUntilMs ?? Date.now());
|
|
48711
|
+
return ttl > 0 && existing && Date.now() >= existing.fetchedAtMs && horizon - existing.fetchedAtMs < ttl ? existing : void 0;
|
|
48712
|
+
};
|
|
48713
|
+
reserveHyperliquidPublicReads = async (endpoint, bodies, signal, options = {}) => {
|
|
48518
48714
|
const apiUrl = endpoint.replace(/\/$/, "");
|
|
48519
|
-
const
|
|
48520
|
-
const id2 = crypto.randomUUID();
|
|
48521
|
-
const admittedAtMs = Date.now();
|
|
48522
|
-
await admit(apiUrl, "bundle", signal, weight, id2);
|
|
48715
|
+
const cached2 = /* @__PURE__ */ new Map();
|
|
48523
48716
|
const remaining = /* @__PURE__ */ new Map();
|
|
48717
|
+
let weight = 0;
|
|
48524
48718
|
for (const body of bodies) {
|
|
48525
48719
|
const key = JSON.stringify(body);
|
|
48720
|
+
const hit = eligibleCache(apiUrl, body, options);
|
|
48721
|
+
if (hit) {
|
|
48722
|
+
cached2.set(key, hit);
|
|
48723
|
+
continue;
|
|
48724
|
+
}
|
|
48526
48725
|
remaining.set(key, (remaining.get(key) ?? 0) + 1);
|
|
48726
|
+
weight += weights[String(body.type)] ?? policy.default_request_weight;
|
|
48527
48727
|
}
|
|
48528
|
-
|
|
48728
|
+
const id2 = crypto.randomUUID();
|
|
48729
|
+
const admittedAtMs = Date.now();
|
|
48730
|
+
if (weight) await admit(apiUrl, "bundle", signal, weight, id2, options.cacheValidUntilMs);
|
|
48731
|
+
return { id: id2, closed: false, endpoint: apiUrl, expiresAtMs: admittedAtMs + policy.window_seconds * 1e3, remaining, cached: cached2, cacheValidUntilMs: options.cacheValidUntilMs };
|
|
48732
|
+
};
|
|
48733
|
+
releaseHyperliquidPublicReadReservation = async (reservation) => {
|
|
48734
|
+
reservation.closed = true;
|
|
48735
|
+
const key = `${PREFIX}${reservation.endpoint}`;
|
|
48736
|
+
await withBudgetLock(key, void 0, () => {
|
|
48737
|
+
const budget = loadBudget(key);
|
|
48738
|
+
const row = budget.reservations.find((entry) => entry.id === reservation.id);
|
|
48739
|
+
if (row) {
|
|
48740
|
+
const unused = [...reservation.remaining].reduce((sum, [body, count4]) => sum + (weights[String(JSON.parse(body).type)] ?? policy.default_request_weight) * count4, 0);
|
|
48741
|
+
row.weight = Math.max(0, row.weight - unused);
|
|
48742
|
+
budget.reservations = budget.reservations.filter((entry) => entry.weight > 0);
|
|
48743
|
+
saveBudget(key, budget);
|
|
48744
|
+
}
|
|
48745
|
+
reservation.remaining.clear();
|
|
48746
|
+
});
|
|
48747
|
+
};
|
|
48748
|
+
admitHyperliquidExchangeRequest = async (endpoint, action, signal) => {
|
|
48749
|
+
const batchLength = Math.max(0, ...[action.orders, action.cancels, action.modifies].filter(Array.isArray).map((value) => value.length));
|
|
48750
|
+
const weight = weights.exchange + Math.floor(batchLength / runtime_policy_generated_default.exchange.hyperliquid.read_budget.exchange_action_batch_size);
|
|
48751
|
+
await admit(endpoint.replace(/\/$/, ""), "exchange", signal, weight);
|
|
48752
|
+
};
|
|
48753
|
+
recordHyperliquidExchangeResponse = async (endpoint, response) => {
|
|
48754
|
+
if (response.status === 429) await cooldown(endpoint.replace(/\/$/, ""), response.headers.get("Retry-After"));
|
|
48529
48755
|
};
|
|
48530
48756
|
readHyperliquidPublicInfo = async (endpoint, body, options = {}) => {
|
|
48531
48757
|
const apiUrl = endpoint.replace(/\/$/, "");
|
|
48532
48758
|
const requestType = String(body.type ?? "info");
|
|
48533
|
-
const
|
|
48759
|
+
const cacheOptions = { ...options, cacheValidUntilMs: options.reservation?.cacheValidUntilMs ?? options.cacheValidUntilMs };
|
|
48760
|
+
const ttlMs = cacheTtlMs(body, cacheOptions);
|
|
48534
48761
|
const key = `${apiUrl}:${JSON.stringify(body)}`;
|
|
48535
48762
|
checkAbort(options.signal);
|
|
48536
|
-
if (
|
|
48763
|
+
if (ttlMs) {
|
|
48537
48764
|
for (; ; ) {
|
|
48538
|
-
const existing =
|
|
48539
|
-
if (existing
|
|
48765
|
+
const existing = options.reservation?.cached.get(JSON.stringify(body)) ?? eligibleCache(apiUrl, body, cacheOptions);
|
|
48766
|
+
if (existing) return existing;
|
|
48540
48767
|
const running = pending2.get(key);
|
|
48541
48768
|
if (!running) break;
|
|
48542
|
-
await new Promise((
|
|
48769
|
+
await new Promise((resolve13, reject) => {
|
|
48543
48770
|
const aborted2 = () => {
|
|
48544
48771
|
options.signal?.removeEventListener("abort", aborted2);
|
|
48545
48772
|
reject(abortError2(options.signal));
|
|
@@ -48547,33 +48774,38 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48547
48774
|
options.signal?.addEventListener("abort", aborted2, { once: true });
|
|
48548
48775
|
running.then(() => {
|
|
48549
48776
|
options.signal?.removeEventListener("abort", aborted2);
|
|
48550
|
-
|
|
48777
|
+
resolve13();
|
|
48551
48778
|
});
|
|
48552
48779
|
});
|
|
48553
48780
|
checkAbort(options.signal);
|
|
48554
48781
|
}
|
|
48555
48782
|
}
|
|
48556
48783
|
let settled;
|
|
48557
|
-
if (
|
|
48558
|
-
settled =
|
|
48784
|
+
if (ttlMs) pending2.set(key, new Promise((resolve13) => {
|
|
48785
|
+
settled = resolve13;
|
|
48559
48786
|
}));
|
|
48560
48787
|
try {
|
|
48561
48788
|
const reservedKey = JSON.stringify(body);
|
|
48562
48789
|
const remaining = options.reservation?.remaining.get(reservedKey) ?? 0;
|
|
48563
48790
|
if (options.reservation?.endpoint === apiUrl && remaining > 0) {
|
|
48564
|
-
if (Date.now() >= options.reservation.expiresAtMs) throw
|
|
48791
|
+
if (Date.now() >= options.reservation.expiresAtMs) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid public read reservation expired.", requestType);
|
|
48565
48792
|
await withBudgetLock(`${PREFIX}${apiUrl}`, options.signal, () => {
|
|
48793
|
+
if (options.reservation.closed) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid public read bundle is closed.", requestType);
|
|
48794
|
+
if ((options.reservation.remaining.get(reservedKey) ?? 0) <= 0) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid request is outside its admitted bundle.", requestType);
|
|
48566
48795
|
const budget = loadBudget(`${PREFIX}${apiUrl}`);
|
|
48567
48796
|
const row = budget.reservations.find((entry) => entry.id === options.reservation.id);
|
|
48568
|
-
if (!row || Date.now() >= options.reservation.expiresAtMs) throw
|
|
48797
|
+
if (!row || Date.now() >= options.reservation.expiresAtMs) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid public read reservation expired.", requestType);
|
|
48569
48798
|
row.at = Date.now();
|
|
48570
48799
|
budget.reservations.sort((a, b2) => a.at - b2.at);
|
|
48800
|
+
options.reservation.remaining.set(reservedKey, (options.reservation.remaining.get(reservedKey) ?? 0) - 1);
|
|
48571
48801
|
saveBudget(`${PREFIX}${apiUrl}`, budget);
|
|
48572
48802
|
});
|
|
48573
|
-
|
|
48574
|
-
|
|
48803
|
+
} else if (options.reservation) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid request is outside its admitted bundle.", requestType);
|
|
48804
|
+
else await admit(apiUrl, requestType, options.signal, void 0, void 0, options.deadlineMs);
|
|
48575
48805
|
checkAbort(options.signal);
|
|
48576
|
-
if (
|
|
48806
|
+
if (options.reservation?.closed) throw new HyperliquidPublicReadError("public_budget_exhausted", "Hyperliquid public read bundle is closed.", requestType);
|
|
48807
|
+
const cooldownUntil = loadBudget(`${PREFIX}${apiUrl}`).cooldownUntil;
|
|
48808
|
+
if (cooldownUntil > Date.now()) throw cooldownError(requestType, cooldownUntil);
|
|
48577
48809
|
const response = await fetch(`${apiUrl}/info`, {
|
|
48578
48810
|
method: "POST",
|
|
48579
48811
|
headers: { "Content-Type": "application/json" },
|
|
@@ -48581,22 +48813,31 @@ var init_hyperliquid_public_read = __esm({
|
|
|
48581
48813
|
signal: options.signal
|
|
48582
48814
|
});
|
|
48583
48815
|
if (response.status === 429) await cooldown(apiUrl, response.headers.get("Retry-After"));
|
|
48584
|
-
const payload = await response.json().catch(() =>
|
|
48816
|
+
const payload = await response.json().catch((error48) => {
|
|
48817
|
+
if (error48 instanceof SyntaxError) return {};
|
|
48818
|
+
throw error48;
|
|
48819
|
+
});
|
|
48585
48820
|
if (!response.ok) {
|
|
48586
48821
|
const detail = sanitizeRuntimeDiagnosticValue(typeof payload?.response === "string" ? payload.response : typeof payload?.detail === "string" ? payload.detail : "");
|
|
48822
|
+
if (response.status === 429) throw new HyperliquidPublicReadError("public_rate_limited", "Hyperliquid public API returned HTTP 429.", requestType, 429);
|
|
48587
48823
|
throw Object.assign(new Error(`Hyperliquid info request failed (${response.status}) request_type=${requestType}.${detail ? ` ${detail}` : ""}`), {
|
|
48588
48824
|
status: response.status,
|
|
48589
48825
|
requestType
|
|
48590
48826
|
});
|
|
48591
48827
|
}
|
|
48592
48828
|
const result2 = { payload, fetchedAtMs: Date.now() };
|
|
48593
|
-
if (
|
|
48829
|
+
if (ttlMs) {
|
|
48594
48830
|
cache.set(key, result2);
|
|
48595
48831
|
while (cache.size > policy.cache_max_entries) cache.delete(cache.keys().next().value);
|
|
48596
48832
|
}
|
|
48597
48833
|
return result2;
|
|
48834
|
+
} catch (error48) {
|
|
48835
|
+
if (options.signal?.aborted || error48 instanceof HyperliquidPublicReadError) throw error48;
|
|
48836
|
+
if (error48 instanceof TypeError) throw new HyperliquidPublicReadError("public_network_error", "Hyperliquid public request network failure.", requestType);
|
|
48837
|
+
if (error48 instanceof Error && (error48.name === "TimeoutError" || error48.name === "AbortError")) throw new HyperliquidPublicReadError("public_timeout", "Hyperliquid public request timed out.", requestType);
|
|
48838
|
+
throw error48;
|
|
48598
48839
|
} finally {
|
|
48599
|
-
if (
|
|
48840
|
+
if (ttlMs) {
|
|
48600
48841
|
pending2.delete(key);
|
|
48601
48842
|
settled?.();
|
|
48602
48843
|
}
|
|
@@ -50147,12 +50388,12 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50147
50388
|
if (signal.aborted) {
|
|
50148
50389
|
throw createAbortError(abortMessage);
|
|
50149
50390
|
}
|
|
50150
|
-
return new Promise((
|
|
50391
|
+
return new Promise((resolve13, reject) => {
|
|
50151
50392
|
const onAbort = () => {
|
|
50152
50393
|
reject(createAbortError(abortMessage));
|
|
50153
50394
|
};
|
|
50154
50395
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
50155
|
-
promise2.then(
|
|
50396
|
+
promise2.then(resolve13, reject).finally(() => {
|
|
50156
50397
|
signal.removeEventListener("abort", onAbort);
|
|
50157
50398
|
});
|
|
50158
50399
|
});
|
|
@@ -50593,273 +50834,283 @@ var init_hyperliquid_account_state_adapter = __esm({
|
|
|
50593
50834
|
dexNames,
|
|
50594
50835
|
staleIf429MaxAgeMs
|
|
50595
50836
|
}) => {
|
|
50596
|
-
const
|
|
50597
|
-
...await readHyperliquidPublicInfo(apiUrl, { type: "userFees", user: walletAddress }, { signal: input.signal }).catch((error48) => {
|
|
50598
|
-
if (input.signal?.aborted) throw error48;
|
|
50599
|
-
return { payload: null, fetchedAtMs: Date.now() };
|
|
50600
|
-
}).then((result2) => ({ payload: result2.payload, capturedAt: new Date(result2.fetchedAtMs).toISOString() }))
|
|
50601
|
-
}))() : Promise.resolve(null);
|
|
50602
|
-
const exactAccountModePromise = input.includeExactAccountMode === true ? (async () => {
|
|
50603
|
-
const abstractionRead = await readHyperliquidPublicInfo(apiUrl, { type: "userAbstraction", user: walletAddress }, { signal: input.signal, cacheAccountMode: true });
|
|
50604
|
-
const userAbstraction = abstractionRead.payload;
|
|
50605
|
-
let capturedAtMs = abstractionRead.fetchedAtMs;
|
|
50606
|
-
const preliminaryMode = extractCanonicalHyperliquidAccountMode(userAbstraction);
|
|
50607
|
-
if (!preliminaryMode) {
|
|
50608
|
-
throw new Error("Exact Hyperliquid userAbstraction response is invalid.");
|
|
50609
|
-
}
|
|
50610
|
-
let userDexAbstraction;
|
|
50611
|
-
if (preliminaryMode === "default" || preliminaryMode === "disabled") {
|
|
50612
|
-
const dexRead = await readHyperliquidPublicInfo(apiUrl, { type: "userDexAbstraction", user: walletAddress }, { signal: input.signal, cacheAccountMode: true });
|
|
50613
|
-
userDexAbstraction = dexRead.payload;
|
|
50614
|
-
capturedAtMs = Math.min(capturedAtMs, dexRead.fetchedAtMs);
|
|
50615
|
-
}
|
|
50616
|
-
return {
|
|
50617
|
-
accountMode: resolveExactHyperliquidAccountMode(
|
|
50618
|
-
userAbstraction,
|
|
50619
|
-
userDexAbstraction
|
|
50620
|
-
),
|
|
50621
|
-
capturedAt: new Date(capturedAtMs).toISOString()
|
|
50622
|
-
};
|
|
50623
|
-
})() : Promise.resolve(null);
|
|
50624
|
-
await Promise.all([userFeesPromise, exactAccountModePromise]);
|
|
50625
|
-
const metadataByDex = /* @__PURE__ */ new Map();
|
|
50626
|
-
if (input.includeEffectiveTakerRate === true) {
|
|
50627
|
-
await Promise.all(["", ...dexNames].map(async (dex) => {
|
|
50628
|
-
try {
|
|
50629
|
-
metadataByDex.set(dex, await fetchHyperliquidInfoPayload(apiUrl, { type: "meta", ...dex ? { dex } : {} }, input.signal));
|
|
50630
|
-
} catch (error48) {
|
|
50631
|
-
if (input.signal?.aborted) throw error48;
|
|
50632
|
-
metadataByDex.set(dex, null);
|
|
50633
|
-
}
|
|
50634
|
-
}));
|
|
50635
|
-
}
|
|
50837
|
+
const metadataBodies = input.includeEffectiveTakerRate === true ? ["", ...dexNames].map((dex) => ({ type: "meta", ...dex ? { dex } : {} })) : [];
|
|
50636
50838
|
const reservation = await reserveHyperliquidPublicReads(apiUrl, [
|
|
50637
50839
|
{ type: "clearinghouseState", user: walletAddress },
|
|
50638
50840
|
...dexNames.map((dex) => ({ type: "clearinghouseState", user: walletAddress, dex })),
|
|
50639
50841
|
{ type: "spotClearinghouseState", user: walletAddress },
|
|
50640
|
-
...input.includeActiveAssetData === false ? [] : activeAssetRequestTypes.map((type) => ({ type, user: walletAddress, coin: symbol2 }))
|
|
50641
|
-
|
|
50642
|
-
|
|
50643
|
-
|
|
50644
|
-
|
|
50645
|
-
|
|
50646
|
-
|
|
50647
|
-
|
|
50648
|
-
)
|
|
50842
|
+
...input.includeActiveAssetData === false ? [] : activeAssetRequestTypes.map((type) => ({ type, user: walletAddress, coin: symbol2 })),
|
|
50843
|
+
...input.includeEffectiveTakerRate === true ? [{ type: "userFees", user: walletAddress }, ...metadataBodies] : [],
|
|
50844
|
+
...input.includeExactAccountMode === true ? [
|
|
50845
|
+
{ type: "userAbstraction", user: walletAddress },
|
|
50846
|
+
{ type: "userDexAbstraction", user: walletAddress }
|
|
50847
|
+
] : []
|
|
50848
|
+
], input.signal, { cacheAccountMode: true, cacheValidUntilMs: input.publicReadDeadlineMs });
|
|
50849
|
+
try {
|
|
50850
|
+
const userFeesPromise = input.includeEffectiveTakerRate === true ? (async () => ({
|
|
50851
|
+
...await readHyperliquidPublicInfo(apiUrl, { type: "userFees", user: walletAddress }, { signal: input.signal, reservation }).catch((error48) => {
|
|
50852
|
+
if (input.signal?.aborted || error48 instanceof HyperliquidPublicReadError || isRateLimitError(error48)) throw error48;
|
|
50853
|
+
return { payload: null, fetchedAtMs: Date.now() };
|
|
50854
|
+
}).then((result2) => ({ payload: result2.payload, capturedAt: new Date(result2.fetchedAtMs).toISOString() }))
|
|
50855
|
+
}))() : Promise.resolve(null);
|
|
50856
|
+
const exactAccountModePromise = input.includeExactAccountMode === true ? (async () => {
|
|
50857
|
+
const abstractionRead = await readHyperliquidPublicInfo(apiUrl, { type: "userAbstraction", user: walletAddress }, { signal: input.signal, reservation, cacheAccountMode: true });
|
|
50858
|
+
const userAbstraction = abstractionRead.payload;
|
|
50859
|
+
let capturedAtMs = abstractionRead.fetchedAtMs;
|
|
50860
|
+
const preliminaryMode = extractCanonicalHyperliquidAccountMode(userAbstraction);
|
|
50861
|
+
if (!preliminaryMode) {
|
|
50862
|
+
throw new Error("Exact Hyperliquid userAbstraction response is invalid.");
|
|
50863
|
+
}
|
|
50864
|
+
let userDexAbstraction;
|
|
50865
|
+
if (preliminaryMode === "default" || preliminaryMode === "disabled") {
|
|
50866
|
+
const dexRead = await readHyperliquidPublicInfo(apiUrl, { type: "userDexAbstraction", user: walletAddress }, { signal: input.signal, reservation, cacheAccountMode: true });
|
|
50867
|
+
userDexAbstraction = dexRead.payload;
|
|
50868
|
+
capturedAtMs = Math.min(capturedAtMs, dexRead.fetchedAtMs);
|
|
50869
|
+
}
|
|
50870
|
+
return {
|
|
50871
|
+
accountMode: resolveExactHyperliquidAccountMode(
|
|
50872
|
+
userAbstraction,
|
|
50873
|
+
userDexAbstraction
|
|
50874
|
+
),
|
|
50875
|
+
capturedAt: new Date(capturedAtMs).toISOString()
|
|
50876
|
+
};
|
|
50877
|
+
})() : Promise.resolve(null);
|
|
50878
|
+
await Promise.all([userFeesPromise, exactAccountModePromise]);
|
|
50879
|
+
const metadataByDex = /* @__PURE__ */ new Map();
|
|
50649
50880
|
if (input.includeEffectiveTakerRate === true) {
|
|
50650
|
-
|
|
50651
|
-
|
|
50652
|
-
|
|
50653
|
-
|
|
50654
|
-
|
|
50655
|
-
|
|
50656
|
-
{ type: "clearinghouseState", user: walletAddress, dex: dexName },
|
|
50657
|
-
input.signal,
|
|
50658
|
-
reservation
|
|
50659
|
-
);
|
|
50660
|
-
if (input.includeEffectiveTakerRate === true) {
|
|
50661
|
-
requirePromptClearinghouseState(response, dexName);
|
|
50881
|
+
await Promise.all(["", ...dexNames].map(async (dex) => {
|
|
50882
|
+
try {
|
|
50883
|
+
metadataByDex.set(dex, await fetchHyperliquidInfoPayload(apiUrl, { type: "meta", ...dex ? { dex } : {} }, input.signal, reservation));
|
|
50884
|
+
} catch (error48) {
|
|
50885
|
+
if (input.signal?.aborted || error48 instanceof HyperliquidPublicReadError || isRateLimitError(error48)) throw error48;
|
|
50886
|
+
metadataByDex.set(dex, null);
|
|
50662
50887
|
}
|
|
50663
|
-
|
|
50664
|
-
dex: dexName,
|
|
50665
|
-
payload: prefixHip3PositionCoins(response, dexName),
|
|
50666
|
-
rawPayload: response
|
|
50667
|
-
};
|
|
50668
|
-
})
|
|
50669
|
-
);
|
|
50670
|
-
const selectedPayload = selectedDex ? dexResponses.find((entry) => entry.dex === selectedDex)?.payload : defaultResponse;
|
|
50671
|
-
if (!selectedPayload) {
|
|
50672
|
-
throw new Error(`Missing selected Hyperliquid clearinghouse state for DEX ${selectedDex}.`);
|
|
50888
|
+
}));
|
|
50673
50889
|
}
|
|
50674
|
-
|
|
50675
|
-
|
|
50676
|
-
defaultResponse,
|
|
50677
|
-
...dexResponses.map((entry) => entry.payload)
|
|
50678
|
-
]),
|
|
50679
|
-
selectedPayload,
|
|
50680
|
-
dexPayloads: [
|
|
50681
|
-
{ dex: "", payload: defaultResponse },
|
|
50682
|
-
...dexResponses.map(({ dex, rawPayload }) => ({ dex, payload: rawPayload }))
|
|
50683
|
-
],
|
|
50684
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
50685
|
-
};
|
|
50686
|
-
})();
|
|
50687
|
-
const spotPromise = (async () => {
|
|
50688
|
-
let payload;
|
|
50689
|
-
try {
|
|
50690
|
-
payload = await fetchHyperliquidInfoPayload(
|
|
50890
|
+
const perpsPromise = (async () => {
|
|
50891
|
+
const defaultResponse = await fetchHyperliquidInfoPayload(
|
|
50691
50892
|
apiUrl,
|
|
50692
|
-
{ type: "
|
|
50893
|
+
{ type: "clearinghouseState", user: walletAddress },
|
|
50693
50894
|
input.signal,
|
|
50694
50895
|
reservation
|
|
50695
50896
|
);
|
|
50696
|
-
|
|
50697
|
-
|
|
50698
|
-
|
|
50699
|
-
|
|
50897
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50898
|
+
requirePromptClearinghouseState(defaultResponse, "default");
|
|
50899
|
+
}
|
|
50900
|
+
const dexResponses = await Promise.all(
|
|
50901
|
+
dexNames.map(async (dexName) => {
|
|
50902
|
+
const response = await fetchHyperliquidInfoPayload(
|
|
50903
|
+
apiUrl,
|
|
50904
|
+
{ type: "clearinghouseState", user: walletAddress, dex: dexName },
|
|
50905
|
+
input.signal,
|
|
50906
|
+
reservation
|
|
50907
|
+
);
|
|
50908
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50909
|
+
requirePromptClearinghouseState(response, dexName);
|
|
50910
|
+
}
|
|
50911
|
+
return {
|
|
50912
|
+
dex: dexName,
|
|
50913
|
+
payload: prefixHip3PositionCoins(response, dexName),
|
|
50914
|
+
rawPayload: response
|
|
50915
|
+
};
|
|
50916
|
+
})
|
|
50917
|
+
);
|
|
50918
|
+
const selectedPayload = selectedDex ? dexResponses.find((entry) => entry.dex === selectedDex)?.payload : defaultResponse;
|
|
50919
|
+
if (!selectedPayload) {
|
|
50920
|
+
throw new Error(`Missing selected Hyperliquid clearinghouse state for DEX ${selectedDex}.`);
|
|
50700
50921
|
}
|
|
50701
|
-
|
|
50702
|
-
|
|
50703
|
-
|
|
50704
|
-
|
|
50705
|
-
|
|
50706
|
-
|
|
50707
|
-
|
|
50922
|
+
return {
|
|
50923
|
+
payload: aggregateClearinghouseResponses([
|
|
50924
|
+
defaultResponse,
|
|
50925
|
+
...dexResponses.map((entry) => entry.payload)
|
|
50926
|
+
]),
|
|
50927
|
+
selectedPayload,
|
|
50928
|
+
dexPayloads: [
|
|
50929
|
+
{ dex: "", payload: defaultResponse },
|
|
50930
|
+
...dexResponses.map(({ dex, rawPayload }) => ({ dex, payload: rawPayload }))
|
|
50931
|
+
],
|
|
50932
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
50933
|
+
};
|
|
50934
|
+
})();
|
|
50935
|
+
const spotPromise = (async () => {
|
|
50936
|
+
let payload;
|
|
50708
50937
|
try {
|
|
50709
|
-
|
|
50938
|
+
payload = await fetchHyperliquidInfoPayload(
|
|
50710
50939
|
apiUrl,
|
|
50711
|
-
{ type:
|
|
50940
|
+
{ type: "spotClearinghouseState", user: walletAddress },
|
|
50712
50941
|
input.signal,
|
|
50713
50942
|
reservation
|
|
50714
50943
|
);
|
|
50715
|
-
return { payload, type: typeName };
|
|
50716
50944
|
} catch (error48) {
|
|
50717
|
-
lastError = error48;
|
|
50718
50945
|
recordInfoRateLimitCooldownFromError(apiUrl, error48, staleIf429MaxAgeMs);
|
|
50719
|
-
if (
|
|
50720
|
-
|
|
50721
|
-
rememberUnsupportedUserActiveAssetKey(activeAssetCacheKey);
|
|
50946
|
+
if (input.forceRefresh || input.includeEffectiveTakerRate === true) {
|
|
50947
|
+
throw error48;
|
|
50722
50948
|
}
|
|
50949
|
+
payload = {};
|
|
50723
50950
|
}
|
|
50724
|
-
|
|
50725
|
-
|
|
50726
|
-
|
|
50727
|
-
|
|
50728
|
-
|
|
50729
|
-
|
|
50730
|
-
|
|
50731
|
-
|
|
50732
|
-
|
|
50733
|
-
|
|
50734
|
-
|
|
50735
|
-
|
|
50736
|
-
|
|
50737
|
-
|
|
50738
|
-
|
|
50739
|
-
|
|
50740
|
-
|
|
50741
|
-
|
|
50742
|
-
|
|
50743
|
-
|
|
50744
|
-
|
|
50745
|
-
}
|
|
50746
|
-
let effectiveTakerRates;
|
|
50747
|
-
if (input.includeEffectiveTakerRate === true) {
|
|
50748
|
-
const feeSymbols = [...new Set([
|
|
50749
|
-
...input.feeSymbols ?? [symbol2],
|
|
50750
|
-
...parseInfoPositions(perpsResponse).filter((position) => Number(position.size) !== 0).map((position) => position.symbol)
|
|
50751
|
-
].map(normalizeHyperliquidMarketSymbol).filter(Boolean))].sort();
|
|
50752
|
-
const feeDexes = [...new Set(feeSymbols.map(getHyperliquidMarketDex))];
|
|
50753
|
-
const metadata = await Promise.all(feeDexes.map(async (dex) => {
|
|
50754
|
-
try {
|
|
50755
|
-
const payload = metadataByDex.get(dex) ?? null;
|
|
50756
|
-
return [dex, payload];
|
|
50757
|
-
} catch (error48) {
|
|
50758
|
-
if (input.signal?.aborted) throw error48;
|
|
50759
|
-
return [dex, null];
|
|
50951
|
+
return { payload, capturedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
50952
|
+
})();
|
|
50953
|
+
const activeAssetPromise = input.includeActiveAssetData === false ? Promise.resolve(null) : (async () => {
|
|
50954
|
+
let lastError = null;
|
|
50955
|
+
for (const typeName of activeAssetRequestTypes) {
|
|
50956
|
+
try {
|
|
50957
|
+
const payload = await fetchHyperliquidInfoPayload(
|
|
50958
|
+
apiUrl,
|
|
50959
|
+
{ type: typeName, user: walletAddress, coin: symbol2 },
|
|
50960
|
+
input.signal,
|
|
50961
|
+
reservation
|
|
50962
|
+
);
|
|
50963
|
+
return { payload, type: typeName };
|
|
50964
|
+
} catch (error48) {
|
|
50965
|
+
lastError = error48;
|
|
50966
|
+
recordInfoRateLimitCooldownFromError(apiUrl, error48, staleIf429MaxAgeMs);
|
|
50967
|
+
if (isRateLimitError(error48)) throw error48;
|
|
50968
|
+
if (typeName === "userActiveAssetData" && isUnsupportedUserActiveAssetError(error48)) {
|
|
50969
|
+
rememberUnsupportedUserActiveAssetKey(activeAssetCacheKey);
|
|
50970
|
+
}
|
|
50971
|
+
}
|
|
50760
50972
|
}
|
|
50761
|
-
|
|
50762
|
-
|
|
50763
|
-
|
|
50764
|
-
|
|
50765
|
-
|
|
50766
|
-
|
|
50767
|
-
|
|
50768
|
-
|
|
50769
|
-
|
|
50770
|
-
|
|
50771
|
-
|
|
50772
|
-
|
|
50773
|
-
|
|
50774
|
-
|
|
50775
|
-
|
|
50776
|
-
|
|
50777
|
-
|
|
50778
|
-
|
|
50779
|
-
|
|
50780
|
-
|
|
50781
|
-
|
|
50782
|
-
|
|
50783
|
-
|
|
50973
|
+
throw lastError instanceof Error ? lastError : new Error("Failed to fetch browser active asset data.");
|
|
50974
|
+
})();
|
|
50975
|
+
const [perpsResult, spotResult, activeAssetResult, userFeesResult, exactAccountMode] = await Promise.all([
|
|
50976
|
+
perpsPromise,
|
|
50977
|
+
spotPromise,
|
|
50978
|
+
activeAssetPromise,
|
|
50979
|
+
userFeesPromise,
|
|
50980
|
+
exactAccountModePromise
|
|
50981
|
+
]);
|
|
50982
|
+
const perpsResponse = perpsResult.payload;
|
|
50983
|
+
const accountSummaryPerpsResponse = input.scopeAccountSummaryToSelectedDex === true ? perpsResult.selectedPayload : perpsResponse;
|
|
50984
|
+
const spotResponse = spotResult.payload;
|
|
50985
|
+
const userFeesResponse = userFeesResult?.payload ?? null;
|
|
50986
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50987
|
+
requirePromptSpotState(spotResponse);
|
|
50988
|
+
}
|
|
50989
|
+
let takerRate;
|
|
50990
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50991
|
+
const raw = userFeesResponse?.userCrossRate;
|
|
50992
|
+
if ((typeof raw === "number" || typeof raw === "string" && raw.trim() !== "") && Number.isFinite(Number(raw)) && Number(raw) >= 0 && Number(raw) < 1) takerRate = Number(raw);
|
|
50993
|
+
}
|
|
50994
|
+
let effectiveTakerRates;
|
|
50995
|
+
if (input.includeEffectiveTakerRate === true) {
|
|
50996
|
+
const feeSymbols = [...new Set([
|
|
50997
|
+
...input.feeSymbols ?? [symbol2],
|
|
50998
|
+
...parseInfoPositions(perpsResponse).filter((position) => Number(position.size) !== 0).map((position) => position.symbol)
|
|
50999
|
+
].map(normalizeHyperliquidMarketSymbol).filter(Boolean))].sort();
|
|
51000
|
+
const feeDexes = [...new Set(feeSymbols.map(getHyperliquidMarketDex))];
|
|
51001
|
+
const metadata = await Promise.all(feeDexes.map(async (dex) => {
|
|
51002
|
+
try {
|
|
51003
|
+
const payload = metadataByDex.get(dex) ?? null;
|
|
51004
|
+
return [dex, payload];
|
|
51005
|
+
} catch (error48) {
|
|
51006
|
+
if (input.signal?.aborted) throw error48;
|
|
51007
|
+
return [dex, null];
|
|
51008
|
+
}
|
|
51009
|
+
}));
|
|
51010
|
+
effectiveTakerRates = effectiveHyperliquidTakerRates(feeSymbols, userFeesResponse ?? {}, Object.fromEntries(metadata));
|
|
51011
|
+
}
|
|
51012
|
+
const accountStateConfig = input.config.client_runtime_hyperliquid_account_state;
|
|
51013
|
+
const summaryPerpsResponse = exactAccountMode ? { ...accountSummaryPerpsResponse, accountMode: exactAccountMode.accountMode } : accountSummaryPerpsResponse;
|
|
51014
|
+
const accountSummaryOptions = {
|
|
51015
|
+
spotDominatesMinTotalUsd: accountStateConfig?.spot_dominates_min_total_usd,
|
|
51016
|
+
spotDominatesPerpsMultiplier: accountStateConfig?.spot_dominates_perps_multiplier,
|
|
51017
|
+
mirroredAccountValueAbsoluteToleranceUsd: accountStateConfig?.mirrored_account_value_absolute_tolerance_usd,
|
|
51018
|
+
mirroredAccountValueRelativeTolerance: accountStateConfig?.mirrored_account_value_relative_tolerance
|
|
51019
|
+
};
|
|
51020
|
+
const walletSummary = exactAccountMode && input.scopeAccountSummaryToSelectedDex !== true ? buildServerPromptRescueAccountSummary(
|
|
51021
|
+
perpsResponse,
|
|
51022
|
+
spotResponse,
|
|
51023
|
+
exactAccountMode.accountMode,
|
|
51024
|
+
accountSummaryOptions
|
|
51025
|
+
) : buildAccountSummaryFromInfoResponses(
|
|
51026
|
+
perpsResponse,
|
|
51027
|
+
spotResponse,
|
|
51028
|
+
accountSummaryOptions
|
|
51029
|
+
);
|
|
51030
|
+
const normalizedSummary = input.scopeAccountSummaryToSelectedDex === true ? {
|
|
51031
|
+
...buildAccountSummaryFromInfoResponses(
|
|
51032
|
+
summaryPerpsResponse,
|
|
51033
|
+
{},
|
|
51034
|
+
accountSummaryOptions
|
|
51035
|
+
),
|
|
51036
|
+
balances: walletSummary.balances
|
|
51037
|
+
} : exactAccountMode ? buildServerPromptRescueAccountSummary(
|
|
51038
|
+
accountSummaryPerpsResponse,
|
|
51039
|
+
spotResponse,
|
|
51040
|
+
exactAccountMode.accountMode,
|
|
51041
|
+
accountSummaryOptions
|
|
51042
|
+
) : buildAccountSummaryFromInfoResponses(
|
|
50784
51043
|
summaryPerpsResponse,
|
|
50785
|
-
|
|
51044
|
+
spotResponse,
|
|
50786
51045
|
accountSummaryOptions
|
|
50787
|
-
)
|
|
50788
|
-
|
|
50789
|
-
|
|
50790
|
-
|
|
50791
|
-
|
|
50792
|
-
|
|
50793
|
-
|
|
50794
|
-
|
|
50795
|
-
|
|
50796
|
-
|
|
50797
|
-
|
|
50798
|
-
|
|
50799
|
-
|
|
50800
|
-
|
|
50801
|
-
|
|
50802
|
-
|
|
50803
|
-
|
|
50804
|
-
|
|
50805
|
-
|
|
50806
|
-
|
|
50807
|
-
|
|
50808
|
-
|
|
50809
|
-
|
|
50810
|
-
|
|
50811
|
-
|
|
50812
|
-
|
|
50813
|
-
|
|
50814
|
-
|
|
50815
|
-
|
|
50816
|
-
|
|
50817
|
-
|
|
50818
|
-
|
|
50819
|
-
|
|
50820
|
-
|
|
50821
|
-
|
|
50822
|
-
|
|
50823
|
-
|
|
50824
|
-
|
|
50825
|
-
|
|
50826
|
-
|
|
50827
|
-
|
|
50828
|
-
|
|
50829
|
-
|
|
50830
|
-
|
|
50831
|
-
|
|
50832
|
-
|
|
50833
|
-
|
|
50834
|
-
|
|
50835
|
-
|
|
50836
|
-
|
|
50837
|
-
|
|
50838
|
-
|
|
50839
|
-
|
|
50840
|
-
|
|
50841
|
-
|
|
50842
|
-
|
|
50843
|
-
|
|
50844
|
-
|
|
50845
|
-
|
|
50846
|
-
|
|
50847
|
-
|
|
50848
|
-
|
|
50849
|
-
|
|
50850
|
-
...takerRate == null ? {} : { takerRate },
|
|
50851
|
-
...effectiveTakerRates == null ? {} : { effectiveTakerRates },
|
|
50852
|
-
...exactAccountMode == null || userFeesResult == null ? {} : {
|
|
50853
|
-
promptRescueEvidence: {
|
|
50854
|
-
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
50855
|
-
perpsCapturedAt: perpsResult.capturedAt,
|
|
50856
|
-
spotCapturedAt: spotResult.capturedAt,
|
|
50857
|
-
feesCapturedAt: userFeesResult.capturedAt,
|
|
50858
|
-
accountModeCapturedAt: exactAccountMode.capturedAt,
|
|
50859
|
-
accountModeSource: "canonical"
|
|
51046
|
+
);
|
|
51047
|
+
const accountSummary = {
|
|
51048
|
+
...normalizedSummary,
|
|
51049
|
+
...input.scopeAccountSummaryToSelectedDex === true ? {} : {
|
|
51050
|
+
perp_dex_accounts: perpsResult.dexPayloads.filter(({ payload }) => hasCompletePerpDexAccountMetrics(payload)).map(({ dex, payload }) => {
|
|
51051
|
+
const summary = buildServerPromptRescueAccountSummary({
|
|
51052
|
+
...payload,
|
|
51053
|
+
crossMaintenanceMarginUsed: firstFiniteNumber([
|
|
51054
|
+
payload.crossMaintenanceMarginUsed,
|
|
51055
|
+
payload.marginSummary?.crossMaintenanceMarginUsed,
|
|
51056
|
+
payload.marginSummary?.totalMaintenanceMargin
|
|
51057
|
+
])
|
|
51058
|
+
}, {}, "disabled", accountSummaryOptions);
|
|
51059
|
+
const accountValue = Number(payload.marginSummary.accountValue);
|
|
51060
|
+
const calculatedAvailable = accountValue - summary.total_margin_used;
|
|
51061
|
+
const availableMargin = summary.maintenance_margin > 0 ? Math.max(calculatedAvailable, Math.max(0, accountValue - 4 * summary.maintenance_margin), summary.withdrawable) : Math.max(calculatedAvailable, summary.withdrawable);
|
|
51062
|
+
return {
|
|
51063
|
+
dex,
|
|
51064
|
+
account_value: accountValue,
|
|
51065
|
+
total_margin_used: summary.total_margin_used,
|
|
51066
|
+
available_margin: availableMargin,
|
|
51067
|
+
withdrawable: summary.withdrawable,
|
|
51068
|
+
maintenance_margin: summary.maintenance_margin,
|
|
51069
|
+
cross_account_leverage: summary.cross_account_leverage,
|
|
51070
|
+
total_unrealized_pnl: summary.total_unrealized_pnl ?? 0
|
|
51071
|
+
};
|
|
51072
|
+
})
|
|
51073
|
+
},
|
|
51074
|
+
...exactAccountMode == null ? {} : { account_mode: exactAccountMode.accountMode, mode_source: "canonical" },
|
|
51075
|
+
address: walletAddress,
|
|
51076
|
+
dex: input.scopeAccountSummaryToSelectedDex === true ? selectedDex : "all",
|
|
51077
|
+
market_type: "perp"
|
|
51078
|
+
};
|
|
51079
|
+
const activeAssetPayload = activeAssetResult?.payload ?? null;
|
|
51080
|
+
const activeAssetType = activeAssetResult?.type ?? "promptAccountState";
|
|
51081
|
+
const normalizedActiveAsset = normalizeActiveAssetData(activeAssetPayload, symbol2);
|
|
51082
|
+
const markPrice = toPositiveFinite(normalizedActiveAsset.mark_price, toPositiveFinite(input.tickerPrice));
|
|
51083
|
+
const fallbackLeverage = toPositiveFinite(input.leverage, 1);
|
|
51084
|
+
const availableBase = Math.max(0, toFinite(accountSummary.available_margin, 0));
|
|
51085
|
+
const availableToTrade = {
|
|
51086
|
+
symbol: symbol2,
|
|
51087
|
+
available_to_trade_buy: Math.max(0, toFinite(normalizedActiveAsset.available_to_trade_buy, availableBase)),
|
|
51088
|
+
available_to_trade_sell: Math.max(0, toFinite(normalizedActiveAsset.available_to_trade_sell, availableBase)),
|
|
51089
|
+
max_trade_size_buy: Math.max(0, toFinite(normalizedActiveAsset.max_trade_size_buy, availableBase * fallbackLeverage)),
|
|
51090
|
+
max_trade_size_sell: Math.max(0, toFinite(normalizedActiveAsset.max_trade_size_sell, availableBase * fallbackLeverage)),
|
|
51091
|
+
mark_price: markPrice,
|
|
51092
|
+
source: `browser_exchange:${activeAssetType}`
|
|
51093
|
+
};
|
|
51094
|
+
return {
|
|
51095
|
+
accountSummary,
|
|
51096
|
+
availableToTrade,
|
|
51097
|
+
positions: parseInfoPositions(perpsResponse),
|
|
51098
|
+
...takerRate == null ? {} : { takerRate },
|
|
51099
|
+
...effectiveTakerRates == null ? {} : { effectiveTakerRates },
|
|
51100
|
+
...exactAccountMode == null || userFeesResult == null ? {} : {
|
|
51101
|
+
promptRescueEvidence: {
|
|
51102
|
+
capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
51103
|
+
perpsCapturedAt: perpsResult.capturedAt,
|
|
51104
|
+
spotCapturedAt: spotResult.capturedAt,
|
|
51105
|
+
feesCapturedAt: userFeesResult.capturedAt,
|
|
51106
|
+
accountModeCapturedAt: exactAccountMode.capturedAt,
|
|
51107
|
+
accountModeSource: "canonical"
|
|
51108
|
+
}
|
|
50860
51109
|
}
|
|
50861
|
-
}
|
|
50862
|
-
}
|
|
51110
|
+
};
|
|
51111
|
+
} finally {
|
|
51112
|
+
await releaseHyperliquidPublicReadReservation(reservation);
|
|
51113
|
+
}
|
|
50863
51114
|
};
|
|
50864
51115
|
fetchBrowserUserFills = async (input) => {
|
|
50865
51116
|
configureHyperliquidMarketSymbolCasing(input.config.client_runtime_hyperliquid_case_sensitive_symbols);
|
|
@@ -51485,7 +51736,7 @@ var init_shared = __esm({
|
|
|
51485
51736
|
}
|
|
51486
51737
|
};
|
|
51487
51738
|
API_URL = getApiUrl();
|
|
51488
|
-
sleep2 = (ms) => new Promise((
|
|
51739
|
+
sleep2 = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
51489
51740
|
AUTH_BOOTSTRAP_GET_MAX_ATTEMPTS = runtime_policy_generated_default.ui.auth_bootstrap_retry.max_attempts;
|
|
51490
51741
|
AUTH_BOOTSTRAP_RETRY_JITTER_MS = runtime_policy_generated_default.ui.auth_bootstrap_retry.jitter_milliseconds;
|
|
51491
51742
|
parseRetryAfterMs2 = (value) => {
|
|
@@ -52644,7 +52895,7 @@ var init_api2 = __esm({
|
|
|
52644
52895
|
if (signal.aborted) {
|
|
52645
52896
|
throw signal.reason ?? new DOMException("Runtime lease recovery aborted.", "AbortError");
|
|
52646
52897
|
}
|
|
52647
|
-
return await new Promise((
|
|
52898
|
+
return await new Promise((resolve13, reject) => {
|
|
52648
52899
|
let settled = false;
|
|
52649
52900
|
const finish = (callback) => {
|
|
52650
52901
|
if (settled) {
|
|
@@ -52659,7 +52910,7 @@ var init_api2 = __esm({
|
|
|
52659
52910
|
));
|
|
52660
52911
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
52661
52912
|
recovery.promise.then(
|
|
52662
|
-
(token) => finish(() =>
|
|
52913
|
+
(token) => finish(() => resolve13(token)),
|
|
52663
52914
|
(error48) => finish(() => reject(error48))
|
|
52664
52915
|
);
|
|
52665
52916
|
});
|
|
@@ -52871,8 +53122,8 @@ var init_exchange_mutation_fence = __esm({
|
|
|
52871
53122
|
return operation();
|
|
52872
53123
|
}
|
|
52873
53124
|
let markSettled;
|
|
52874
|
-
const settlement = new Promise((
|
|
52875
|
-
markSettled =
|
|
53125
|
+
const settlement = new Promise((resolve13) => {
|
|
53126
|
+
markSettled = resolve13;
|
|
52876
53127
|
});
|
|
52877
53128
|
const activeSettlements = activeSettlementsByScope.get(normalizedScope) ?? /* @__PURE__ */ new Set();
|
|
52878
53129
|
activeSettlements.add(settlement);
|
|
@@ -53876,7 +54127,7 @@ function createGetUrl(options) {
|
|
|
53876
54127
|
request.write(Buffer.from(body));
|
|
53877
54128
|
}
|
|
53878
54129
|
request.end();
|
|
53879
|
-
return new Promise((
|
|
54130
|
+
return new Promise((resolve13, reject) => {
|
|
53880
54131
|
if (signal) {
|
|
53881
54132
|
signal.addListener(() => {
|
|
53882
54133
|
if (abort) {
|
|
@@ -53922,7 +54173,7 @@ function createGetUrl(options) {
|
|
|
53922
54173
|
if (headers2["content-encoding"] === "gzip" && body2) {
|
|
53923
54174
|
body2 = getBytes(gunzipSync2(body2));
|
|
53924
54175
|
}
|
|
53925
|
-
|
|
54176
|
+
resolve13({ statusCode, statusMessage, headers: headers2, body: body2 });
|
|
53926
54177
|
} catch (error48) {
|
|
53927
54178
|
reject(makeError("bad response data", "SERVER_ERROR", {
|
|
53928
54179
|
request: req,
|
|
@@ -53998,7 +54249,7 @@ function unpercent(value) {
|
|
|
53998
54249
|
}));
|
|
53999
54250
|
}
|
|
54000
54251
|
function wait2(delay2) {
|
|
54001
|
-
return new Promise((
|
|
54252
|
+
return new Promise((resolve13) => setTimeout(resolve13, delay2));
|
|
54002
54253
|
}
|
|
54003
54254
|
var MAX_ATTEMPTS, SLOT_INTERVAL, defaultGetUrlFunc, reData, reIpfs, locked, Gateways, fetchSignals, FetchCancelSignal, FetchRequest, FetchResponse;
|
|
54004
54255
|
var init_fetch = __esm({
|
|
@@ -67790,7 +68041,7 @@ var init_provider = __esm({
|
|
|
67790
68041
|
return null;
|
|
67791
68042
|
}
|
|
67792
68043
|
}
|
|
67793
|
-
const waiter = new Promise((
|
|
68044
|
+
const waiter = new Promise((resolve13, reject) => {
|
|
67794
68045
|
const cancellers = [];
|
|
67795
68046
|
const cancel = () => {
|
|
67796
68047
|
cancellers.forEach((c) => c());
|
|
@@ -67811,7 +68062,7 @@ var init_provider = __esm({
|
|
|
67811
68062
|
if (await receipt2.confirmations() >= confirms) {
|
|
67812
68063
|
cancel();
|
|
67813
68064
|
try {
|
|
67814
|
-
|
|
68065
|
+
resolve13(checkReceipt(receipt2));
|
|
67815
68066
|
} catch (error48) {
|
|
67816
68067
|
reject(error48);
|
|
67817
68068
|
}
|
|
@@ -68736,12 +68987,12 @@ var init_contract = __esm({
|
|
|
68736
68987
|
}
|
|
68737
68988
|
const provider = getProvider(this.runner);
|
|
68738
68989
|
assert2(provider != null, "contract runner does not support .provider", "UNSUPPORTED_OPERATION", { operation: "waitForDeployment" });
|
|
68739
|
-
return new Promise((
|
|
68990
|
+
return new Promise((resolve13, reject) => {
|
|
68740
68991
|
const checkCode = async () => {
|
|
68741
68992
|
try {
|
|
68742
68993
|
const code2 = await this.getDeployedCode();
|
|
68743
68994
|
if (code2 != null) {
|
|
68744
|
-
return
|
|
68995
|
+
return resolve13(this);
|
|
68745
68996
|
}
|
|
68746
68997
|
provider.once("block", checkCode);
|
|
68747
68998
|
} catch (error48) {
|
|
@@ -71093,7 +71344,7 @@ var init_abstract_provider = __esm({
|
|
|
71093
71344
|
return t.toLowerCase();
|
|
71094
71345
|
});
|
|
71095
71346
|
const blockHash = "blockHash" in filter ? filter.blockHash : void 0;
|
|
71096
|
-
const
|
|
71347
|
+
const resolve13 = (_address, fromBlock2, toBlock2) => {
|
|
71097
71348
|
let address2 = void 0;
|
|
71098
71349
|
switch (_address.length) {
|
|
71099
71350
|
case 0:
|
|
@@ -71148,10 +71399,10 @@ var init_abstract_provider = __esm({
|
|
|
71148
71399
|
}
|
|
71149
71400
|
if (address.filter((a) => typeof a !== "string").length || fromBlock != null && typeof fromBlock !== "string" || toBlock != null && typeof toBlock !== "string") {
|
|
71150
71401
|
return Promise.all([Promise.all(address), fromBlock, toBlock]).then((result2) => {
|
|
71151
|
-
return
|
|
71402
|
+
return resolve13(result2[0], result2[1], result2[2]);
|
|
71152
71403
|
});
|
|
71153
71404
|
}
|
|
71154
|
-
return
|
|
71405
|
+
return resolve13(address, fromBlock, toBlock);
|
|
71155
71406
|
}
|
|
71156
71407
|
/**
|
|
71157
71408
|
* Returns or resolves to a transaction for %%request%%, resolving
|
|
@@ -71525,14 +71776,14 @@ var init_abstract_provider = __esm({
|
|
|
71525
71776
|
if (confirms === 0) {
|
|
71526
71777
|
return this.getTransactionReceipt(hash4);
|
|
71527
71778
|
}
|
|
71528
|
-
return new Promise(async (
|
|
71779
|
+
return new Promise(async (resolve13, reject) => {
|
|
71529
71780
|
let timer = null;
|
|
71530
71781
|
const listener = (async (blockNumber) => {
|
|
71531
71782
|
try {
|
|
71532
71783
|
const receipt = await this.getTransactionReceipt(hash4);
|
|
71533
71784
|
if (receipt != null) {
|
|
71534
71785
|
if (blockNumber - receipt.blockNumber + 1 >= confirms) {
|
|
71535
|
-
|
|
71786
|
+
resolve13(receipt);
|
|
71536
71787
|
if (timer) {
|
|
71537
71788
|
clearTimeout(timer);
|
|
71538
71789
|
timer = null;
|
|
@@ -72303,8 +72554,8 @@ function deepCopy(value) {
|
|
|
72303
72554
|
throw new Error(`should not happen: ${value} (${typeof value})`);
|
|
72304
72555
|
}
|
|
72305
72556
|
function stall(duration3) {
|
|
72306
|
-
return new Promise((
|
|
72307
|
-
setTimeout(
|
|
72557
|
+
return new Promise((resolve13) => {
|
|
72558
|
+
setTimeout(resolve13, duration3);
|
|
72308
72559
|
});
|
|
72309
72560
|
}
|
|
72310
72561
|
function getLowerCase(value) {
|
|
@@ -72444,14 +72695,14 @@ var init_provider_jsonrpc = __esm({
|
|
|
72444
72695
|
async sendTransaction(tx) {
|
|
72445
72696
|
const blockNumber = await this.provider.getBlockNumber();
|
|
72446
72697
|
const hash4 = await this.sendUncheckedTransaction(tx);
|
|
72447
|
-
return await new Promise((
|
|
72698
|
+
return await new Promise((resolve13, reject) => {
|
|
72448
72699
|
const timeouts = [1e3, 100];
|
|
72449
72700
|
let invalids = 0;
|
|
72450
72701
|
const checkTx = async () => {
|
|
72451
72702
|
try {
|
|
72452
72703
|
const tx2 = await this.provider.getTransaction(hash4);
|
|
72453
72704
|
if (tx2 != null) {
|
|
72454
|
-
|
|
72705
|
+
resolve13(tx2.replaceableTransaction(blockNumber));
|
|
72455
72706
|
return;
|
|
72456
72707
|
}
|
|
72457
72708
|
} catch (error48) {
|
|
@@ -72568,7 +72819,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
72568
72819
|
try {
|
|
72569
72820
|
const result2 = await this._send(payload);
|
|
72570
72821
|
this.emit("debug", { action: "receiveRpcResult", result: result2 });
|
|
72571
|
-
for (const { resolve:
|
|
72822
|
+
for (const { resolve: resolve13, reject, payload: payload2 } of batch) {
|
|
72572
72823
|
if (this.destroyed) {
|
|
72573
72824
|
reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: payload2.method }));
|
|
72574
72825
|
continue;
|
|
@@ -72587,7 +72838,7 @@ var init_provider_jsonrpc = __esm({
|
|
|
72587
72838
|
reject(this.getRpcError(payload2, resp));
|
|
72588
72839
|
continue;
|
|
72589
72840
|
}
|
|
72590
|
-
|
|
72841
|
+
resolve13(resp.result);
|
|
72591
72842
|
}
|
|
72592
72843
|
} catch (error48) {
|
|
72593
72844
|
this.emit("debug", { action: "receiveRpcError", error: error48 });
|
|
@@ -72608,11 +72859,11 @@ var init_provider_jsonrpc = __esm({
|
|
|
72608
72859
|
this.#network = null;
|
|
72609
72860
|
this.#pendingDetectNetwork = null;
|
|
72610
72861
|
{
|
|
72611
|
-
let
|
|
72862
|
+
let resolve13 = null;
|
|
72612
72863
|
const promise2 = new Promise((_resolve) => {
|
|
72613
|
-
|
|
72864
|
+
resolve13 = _resolve;
|
|
72614
72865
|
});
|
|
72615
|
-
this.#notReady = { promise: promise2, resolve:
|
|
72866
|
+
this.#notReady = { promise: promise2, resolve: resolve13 };
|
|
72616
72867
|
}
|
|
72617
72868
|
const staticNetwork = this._getOption("staticNetwork");
|
|
72618
72869
|
if (typeof staticNetwork === "boolean") {
|
|
@@ -73025,9 +73276,9 @@ var init_provider_jsonrpc = __esm({
|
|
|
73025
73276
|
return Promise.reject(makeError("provider destroyed; cancelled request", "UNSUPPORTED_OPERATION", { operation: method }));
|
|
73026
73277
|
}
|
|
73027
73278
|
const id2 = this.#nextId++;
|
|
73028
|
-
const promise2 = new Promise((
|
|
73279
|
+
const promise2 = new Promise((resolve13, reject) => {
|
|
73029
73280
|
this.#payloads.push({
|
|
73030
|
-
resolve:
|
|
73281
|
+
resolve: resolve13,
|
|
73031
73282
|
reject,
|
|
73032
73283
|
payload: { method, params, id: id2, jsonrpc: "2.0" }
|
|
73033
73284
|
});
|
|
@@ -77985,8 +78236,8 @@ var init_provider_socket = __esm({
|
|
|
77985
78236
|
}
|
|
77986
78237
|
async _send(payload) {
|
|
77987
78238
|
assertArgument(!Array.isArray(payload), "WebSocket does not support batch send", "payload", payload);
|
|
77988
|
-
const promise2 = new Promise((
|
|
77989
|
-
this.#callbacks.set(payload.id, { payload, resolve:
|
|
78239
|
+
const promise2 = new Promise((resolve13, reject) => {
|
|
78240
|
+
this.#callbacks.set(payload.id, { payload, resolve: resolve13, reject });
|
|
77990
78241
|
});
|
|
77991
78242
|
await this._waitUntilReady();
|
|
77992
78243
|
await this._write(JSON.stringify(payload));
|
|
@@ -78392,8 +78643,8 @@ function shuffle(array2) {
|
|
|
78392
78643
|
}
|
|
78393
78644
|
}
|
|
78394
78645
|
function stall2(duration3) {
|
|
78395
|
-
return new Promise((
|
|
78396
|
-
setTimeout(
|
|
78646
|
+
return new Promise((resolve13) => {
|
|
78647
|
+
setTimeout(resolve13, duration3);
|
|
78397
78648
|
});
|
|
78398
78649
|
}
|
|
78399
78650
|
function getTime3() {
|
|
@@ -79275,7 +79526,7 @@ var init_provider_browser = __esm({
|
|
|
79275
79526
|
if (timeout === 0) {
|
|
79276
79527
|
return null;
|
|
79277
79528
|
}
|
|
79278
|
-
return await new Promise((
|
|
79529
|
+
return await new Promise((resolve13, reject) => {
|
|
79279
79530
|
let found = [];
|
|
79280
79531
|
const addProvider = (event) => {
|
|
79281
79532
|
found.push(event.detail);
|
|
@@ -79289,9 +79540,9 @@ var init_provider_browser = __esm({
|
|
|
79289
79540
|
if (options && options.filter) {
|
|
79290
79541
|
const filtered = options.filter(found.map((i) => Object.assign({}, i.info)));
|
|
79291
79542
|
if (filtered == null) {
|
|
79292
|
-
|
|
79543
|
+
resolve13(null);
|
|
79293
79544
|
} else if (filtered instanceof _BrowserProvider) {
|
|
79294
|
-
|
|
79545
|
+
resolve13(filtered);
|
|
79295
79546
|
} else {
|
|
79296
79547
|
let match = null;
|
|
79297
79548
|
if (filtered.uuid) {
|
|
@@ -79300,7 +79551,7 @@ var init_provider_browser = __esm({
|
|
|
79300
79551
|
}
|
|
79301
79552
|
if (match) {
|
|
79302
79553
|
const { provider, info } = match;
|
|
79303
|
-
|
|
79554
|
+
resolve13(new _BrowserProvider(provider, void 0, {
|
|
79304
79555
|
providerInfo: info
|
|
79305
79556
|
}));
|
|
79306
79557
|
} else {
|
|
@@ -79311,12 +79562,12 @@ var init_provider_browser = __esm({
|
|
|
79311
79562
|
}
|
|
79312
79563
|
} else {
|
|
79313
79564
|
const { provider, info } = found[0];
|
|
79314
|
-
|
|
79565
|
+
resolve13(new _BrowserProvider(provider, void 0, {
|
|
79315
79566
|
providerInfo: info
|
|
79316
79567
|
}));
|
|
79317
79568
|
}
|
|
79318
79569
|
} else {
|
|
79319
|
-
|
|
79570
|
+
resolve13(null);
|
|
79320
79571
|
}
|
|
79321
79572
|
context.removeEventListener("eip6963:announceProvider", addProvider);
|
|
79322
79573
|
};
|
|
@@ -80730,9 +80981,9 @@ function decryptKeystoreJsonSync(json2, _password) {
|
|
|
80730
80981
|
return getAccount(data4, key);
|
|
80731
80982
|
}
|
|
80732
80983
|
function stall3(duration3) {
|
|
80733
|
-
return new Promise((
|
|
80984
|
+
return new Promise((resolve13) => {
|
|
80734
80985
|
setTimeout(() => {
|
|
80735
|
-
|
|
80986
|
+
resolve13();
|
|
80736
80987
|
}, duration3);
|
|
80737
80988
|
});
|
|
80738
80989
|
}
|
|
@@ -81361,9 +81612,9 @@ var init_json_crowdsale = __esm({
|
|
|
81361
81612
|
|
|
81362
81613
|
// node_modules/ethers/lib.esm/wallet/wallet.js
|
|
81363
81614
|
function stall4(duration3) {
|
|
81364
|
-
return new Promise((
|
|
81615
|
+
return new Promise((resolve13) => {
|
|
81365
81616
|
setTimeout(() => {
|
|
81366
|
-
|
|
81617
|
+
resolve13();
|
|
81367
81618
|
}, duration3);
|
|
81368
81619
|
});
|
|
81369
81620
|
}
|
|
@@ -85309,14 +85560,14 @@ var init_hyperliquid_client = __esm({
|
|
|
85309
85560
|
if (input.signal?.aborted) {
|
|
85310
85561
|
throw input.signal.reason instanceof Error ? input.signal.reason : settlementError;
|
|
85311
85562
|
}
|
|
85312
|
-
await new Promise((
|
|
85563
|
+
await new Promise((resolve13) => {
|
|
85313
85564
|
let settled = false;
|
|
85314
85565
|
const finish = () => {
|
|
85315
85566
|
if (settled) return;
|
|
85316
85567
|
settled = true;
|
|
85317
85568
|
globalThis.clearTimeout(timeoutId);
|
|
85318
85569
|
input.signal?.removeEventListener("abort", finish);
|
|
85319
|
-
|
|
85570
|
+
resolve13();
|
|
85320
85571
|
};
|
|
85321
85572
|
const timeoutId = globalThis.setTimeout(finish, 1e3);
|
|
85322
85573
|
input.signal?.addEventListener("abort", finish, { once: true });
|
|
@@ -85347,12 +85598,12 @@ var init_hyperliquid_client = __esm({
|
|
|
85347
85598
|
captureController.signal,
|
|
85348
85599
|
...durableMutationAuthorityArgs(durableMutation)
|
|
85349
85600
|
).then(() => void 0).catch(() => void 0);
|
|
85350
|
-
const captureDeadline = new Promise((
|
|
85601
|
+
const captureDeadline = new Promise((resolve13) => {
|
|
85351
85602
|
captureTimeout = globalThis.setTimeout(() => {
|
|
85352
85603
|
captureController.abort(
|
|
85353
85604
|
new DOMException("Execution attempt capture timed out.", "TimeoutError")
|
|
85354
85605
|
);
|
|
85355
|
-
|
|
85606
|
+
resolve13();
|
|
85356
85607
|
}, remainingBudgetMs);
|
|
85357
85608
|
});
|
|
85358
85609
|
await Promise.race([captureRequest, captureDeadline]);
|
|
@@ -85367,9 +85618,11 @@ var init_hyperliquid_client = __esm({
|
|
|
85367
85618
|
}
|
|
85368
85619
|
}
|
|
85369
85620
|
try {
|
|
85621
|
+
await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal);
|
|
85370
85622
|
assertFreshPreparedExecutionContext(input.preparedContext);
|
|
85371
85623
|
} catch (preparedContextError) {
|
|
85372
85624
|
await settleDurableMutation("rejected");
|
|
85625
|
+
if (isAbortLikeError(preparedContextError) || preparedContextError instanceof HyperliquidPublicReadError) throw preparedContextError;
|
|
85373
85626
|
throw new RuntimeExecutionError(
|
|
85374
85627
|
preparedContextError instanceof Error ? preparedContextError.message : "Prepared exchange context expired before dispatch.",
|
|
85375
85628
|
"local_safety_block"
|
|
@@ -85402,6 +85655,7 @@ var init_hyperliquid_client = __esm({
|
|
|
85402
85655
|
body: serializedPayload
|
|
85403
85656
|
});
|
|
85404
85657
|
responseStatus = response.status;
|
|
85658
|
+
await recordHyperliquidExchangeResponse(apiUrl, response);
|
|
85405
85659
|
const payload = await response.json().catch(() => ({}));
|
|
85406
85660
|
if (!response.ok) {
|
|
85407
85661
|
await settleDurableMutation("transport_ambiguous");
|
|
@@ -85856,7 +86110,7 @@ var init_vault = __esm({
|
|
|
85856
86110
|
}
|
|
85857
86111
|
return output3.buffer.slice(output3.byteOffset, output3.byteOffset + output3.byteLength);
|
|
85858
86112
|
};
|
|
85859
|
-
openVaultDb = async () => new Promise((
|
|
86113
|
+
openVaultDb = async () => new Promise((resolve13, reject) => {
|
|
85860
86114
|
const request = indexedDB.open(VAULT_DB_NAME, VAULT_DB_VERSION);
|
|
85861
86115
|
request.onerror = () => reject(request.error ?? new Error("Failed to open client vault database."));
|
|
85862
86116
|
request.onupgradeneeded = () => {
|
|
@@ -85865,7 +86119,7 @@ var init_vault = __esm({
|
|
|
85865
86119
|
database.createObjectStore(VAULT_KEY_STORE);
|
|
85866
86120
|
}
|
|
85867
86121
|
};
|
|
85868
|
-
request.onsuccess = () =>
|
|
86122
|
+
request.onsuccess = () => resolve13(request.result);
|
|
85869
86123
|
});
|
|
85870
86124
|
withVaultStore = async (mode, fn) => {
|
|
85871
86125
|
const database = await openVaultDb();
|
|
@@ -85873,8 +86127,8 @@ var init_vault = __esm({
|
|
|
85873
86127
|
const transaction = database.transaction(VAULT_KEY_STORE, mode);
|
|
85874
86128
|
const store = transaction.objectStore(VAULT_KEY_STORE);
|
|
85875
86129
|
const result2 = await fn(store);
|
|
85876
|
-
await new Promise((
|
|
85877
|
-
transaction.oncomplete = () =>
|
|
86130
|
+
await new Promise((resolve13, reject) => {
|
|
86131
|
+
transaction.oncomplete = () => resolve13();
|
|
85878
86132
|
transaction.onerror = () => reject(transaction.error ?? new Error("Client vault transaction failed."));
|
|
85879
86133
|
transaction.onabort = () => reject(transaction.error ?? new Error("Client vault transaction aborted."));
|
|
85880
86134
|
});
|
|
@@ -85889,9 +86143,9 @@ var init_vault = __esm({
|
|
|
85889
86143
|
}
|
|
85890
86144
|
return withVaultStore("readonly", async (store) => {
|
|
85891
86145
|
const request = store.get(profileId);
|
|
85892
|
-
return await new Promise((
|
|
86146
|
+
return await new Promise((resolve13, reject) => {
|
|
85893
86147
|
request.onerror = () => reject(request.error ?? new Error("Failed to read client vault key."));
|
|
85894
|
-
request.onsuccess = () =>
|
|
86148
|
+
request.onsuccess = () => resolve13(request.result ?? null);
|
|
85895
86149
|
});
|
|
85896
86150
|
});
|
|
85897
86151
|
};
|
|
@@ -85913,9 +86167,9 @@ var init_vault = __esm({
|
|
|
85913
86167
|
);
|
|
85914
86168
|
await withVaultStore("readwrite", async (store) => {
|
|
85915
86169
|
const request = store.put(createdKey, profileId);
|
|
85916
|
-
await new Promise((
|
|
86170
|
+
await new Promise((resolve13, reject) => {
|
|
85917
86171
|
request.onerror = () => reject(request.error ?? new Error("Failed to persist client vault key."));
|
|
85918
|
-
request.onsuccess = () =>
|
|
86172
|
+
request.onsuccess = () => resolve13();
|
|
85919
86173
|
});
|
|
85920
86174
|
});
|
|
85921
86175
|
return createdKey;
|
|
@@ -85926,9 +86180,9 @@ var init_vault = __esm({
|
|
|
85926
86180
|
}
|
|
85927
86181
|
await withVaultStore("readwrite", async (store) => {
|
|
85928
86182
|
const request = store.delete(profileId);
|
|
85929
|
-
await new Promise((
|
|
86183
|
+
await new Promise((resolve13, reject) => {
|
|
85930
86184
|
request.onerror = () => reject(request.error ?? new Error("Failed to remove client vault key."));
|
|
85931
|
-
request.onsuccess = () =>
|
|
86185
|
+
request.onsuccess = () => resolve13();
|
|
85932
86186
|
});
|
|
85933
86187
|
});
|
|
85934
86188
|
};
|
|
@@ -90689,10 +90943,10 @@ var init_runtime_execution = __esm({
|
|
|
90689
90943
|
}
|
|
90690
90944
|
};
|
|
90691
90945
|
sleep3 = async (ms, signal) => {
|
|
90692
|
-
await new Promise((
|
|
90946
|
+
await new Promise((resolve13, reject) => {
|
|
90693
90947
|
const timer = setTimeout(() => {
|
|
90694
90948
|
cleanup();
|
|
90695
|
-
|
|
90949
|
+
resolve13(void 0);
|
|
90696
90950
|
}, ms);
|
|
90697
90951
|
const cleanup = () => {
|
|
90698
90952
|
clearTimeout(timer);
|
|
@@ -94092,7 +94346,7 @@ Global options:
|
|
|
94092
94346
|
"alibaba_cloud_model_studio_api_key",
|
|
94093
94347
|
"lightning_api_key"
|
|
94094
94348
|
]);
|
|
94095
|
-
delay = (ms) => new Promise((
|
|
94349
|
+
delay = (ms) => new Promise((resolve13) => setTimeout(resolve13, ms));
|
|
94096
94350
|
}
|
|
94097
94351
|
});
|
|
94098
94352
|
|