@vtxmacro/cli 2026.9.58 → 2026.9.60

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.
@@ -16,7 +16,7 @@ import { fileURLToPath } from "node:url";
16
16
  // agent-cli-release.json
17
17
  var agent_cli_release_default = {
18
18
  package_name: "@vtxmacro/cli",
19
- package_version: "2026.9.58",
19
+ package_version: "2026.9.60",
20
20
  codex_package_name: "@openai/codex",
21
21
  codex_version: "0.155.0",
22
22
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -320,6 +320,14 @@ var runtime_policy_generated_default = {
320
320
  request_timeout_seconds: 10,
321
321
  pool_timeout_seconds: 5
322
322
  }
323
+ },
324
+ public_request_priority: {
325
+ trading_reduce: 1,
326
+ trading_reconcile: 2,
327
+ trading_execute: 3,
328
+ trading_analysis: 4,
329
+ ui: 5,
330
+ background: 6
323
331
  }
324
332
  }
325
333
  }
@@ -203,6 +203,14 @@ var runtime_policy_generated_default = {
203
203
  request_timeout_seconds: 10,
204
204
  pool_timeout_seconds: 5
205
205
  }
206
+ },
207
+ public_request_priority: {
208
+ trading_reduce: 1,
209
+ trading_reconcile: 2,
210
+ trading_execute: 3,
211
+ trading_analysis: 4,
212
+ ui: 5,
213
+ background: 6
206
214
  }
207
215
  }
208
216
  }
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.58",
80
+ package_version: "2026.9.60",
81
81
  codex_package_name: "@openai/codex",
82
82
  codex_version: "0.155.0",
83
83
  copilot_sdk_package_name: "@github/copilot-sdk",
@@ -20661,6 +20661,14 @@ var init_runtime_policy_generated = __esm({
20661
20661
  request_timeout_seconds: 10,
20662
20662
  pool_timeout_seconds: 5
20663
20663
  }
20664
+ },
20665
+ public_request_priority: {
20666
+ trading_reduce: 1,
20667
+ trading_reconcile: 2,
20668
+ trading_execute: 3,
20669
+ trading_analysis: 4,
20670
+ ui: 5,
20671
+ background: 6
20664
20672
  }
20665
20673
  }
20666
20674
  }
@@ -42723,6 +42731,14 @@ var init_runtime_policy_generated2 = __esm({
42723
42731
  request_timeout_seconds: 10,
42724
42732
  pool_timeout_seconds: 5
42725
42733
  }
42734
+ },
42735
+ public_request_priority: {
42736
+ trading_reduce: 1,
42737
+ trading_reconcile: 2,
42738
+ trading_execute: 3,
42739
+ trading_analysis: 4,
42740
+ ui: 5,
42741
+ background: 6
42726
42742
  }
42727
42743
  }
42728
42744
  }
@@ -48605,7 +48621,7 @@ var init_abort = __esm({
48605
48621
  });
48606
48622
 
48607
48623
  // lib/runtime/runtime-redaction.ts
48608
- var REDACTED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, SECRET_ASSIGNMENT_PATTERN, SECRET_KEYWORD_VALUE_PATTERN, OPENAI_STYLE_KEY_PATTERN, VERTEX_EXPRESS_KEY_PATTERN, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError;
48624
+ var REDACTED_VALUE, SECRET_QUERY_PARAM_PATTERN, BEARER_TOKEN_PATTERN, SECRET_ASSIGNMENT_PATTERN, SECRET_KEYWORD_VALUE_PATTERN, OPENAI_STYLE_KEY_PATTERN, VERTEX_EXPRESS_KEY_PATTERN, isRuntimeErrorObject, sanitizeRuntimeDiagnosticValue, sanitizeRuntimeNetworkPath, getSanitizedRuntimeErrorMessage, toSanitizedRuntimeError, getSanitizedRuntimeAbortReason;
48609
48625
  var init_runtime_redaction = __esm({
48610
48626
  "lib/runtime/runtime-redaction.ts"() {
48611
48627
  "use strict";
@@ -48620,6 +48636,7 @@ var init_runtime_redaction = __esm({
48620
48636
  SECRET_KEYWORD_VALUE_PATTERN = /((?:private(?:_|-|\s)?key|signing(?:_|-|\s)?key)\s*[:=]\s*['"]?)(0x[a-fA-F0-9]{64}|[^'"\s,}]+)/gi;
48621
48637
  OPENAI_STYLE_KEY_PATTERN = /\bsk-[A-Za-z0-9._-]+\b/g;
48622
48638
  VERTEX_EXPRESS_KEY_PATTERN = /\bAQ\.[A-Za-z0-9._-]+\b/g;
48639
+ isRuntimeErrorObject = (error48) => error48 instanceof Error || error48 != null && typeof error48 === "object" && Object.prototype.toString.call(error48) === "[object DOMException]" && typeof error48.message === "string" && typeof error48.name === "string";
48623
48640
  sanitizeRuntimeDiagnosticValue = (value) => {
48624
48641
  const normalized = String(value || "");
48625
48642
  if (!normalized) {
@@ -48638,7 +48655,7 @@ var init_runtime_redaction = __esm({
48638
48655
  return sanitized || "/";
48639
48656
  };
48640
48657
  getSanitizedRuntimeErrorMessage = (error48) => {
48641
- const message = error48 instanceof Error ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
48658
+ const message = isRuntimeErrorObject(error48) ? error48.message : typeof error48 === "string" ? error48 : error48 == null ? null : String(error48);
48642
48659
  if (message == null) {
48643
48660
  return null;
48644
48661
  }
@@ -48646,25 +48663,27 @@ var init_runtime_redaction = __esm({
48646
48663
  };
48647
48664
  toSanitizedRuntimeError = (error48) => {
48648
48665
  const message = getSanitizedRuntimeErrorMessage(error48) || "Unknown runtime error.";
48649
- if (error48 instanceof Error && error48.message === message) {
48666
+ if (isRuntimeErrorObject(error48) && error48.message === message) {
48650
48667
  if (isAbortLikeError(error48) && error48.name !== "AbortError") {
48651
- error48.name = "AbortError";
48668
+ if (error48 instanceof Error) error48.name = "AbortError";
48669
+ else return Object.assign(new Error(message), { name: "AbortError" });
48652
48670
  }
48653
48671
  return error48;
48654
48672
  }
48655
48673
  const sanitized = new Error(message);
48656
48674
  if (isAbortLikeError(error48)) {
48657
48675
  sanitized.name = "AbortError";
48658
- } else if (error48 instanceof Error && error48.name) {
48676
+ } else if (isRuntimeErrorObject(error48) && error48.name) {
48659
48677
  sanitized.name = error48.name;
48660
48678
  }
48661
48679
  return sanitized;
48662
48680
  };
48681
+ getSanitizedRuntimeAbortReason = (signal, fallbackMessage = "The operation was aborted.") => isRuntimeErrorObject(signal?.reason) ? toSanitizedRuntimeError(signal.reason) : new DOMException(fallbackMessage, "AbortError");
48663
48682
  }
48664
48683
  });
48665
48684
 
48666
48685
  // lib/runtime/hyperliquid-public-read.ts
48667
- var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, fallbackDelayMs, admit, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
48686
+ var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, priorityRank, createHyperliquidPublicPriorityScope, promoteHyperliquidPublicPriority, abortError2, checkAbort, wait, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, fallbackDelayMs, admit, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
48668
48687
  var init_hyperliquid_public_read = __esm({
48669
48688
  "lib/runtime/hyperliquid-public-read.ts"() {
48670
48689
  "use strict";
@@ -48681,7 +48700,14 @@ var init_hyperliquid_public_read = __esm({
48681
48700
  cache = /* @__PURE__ */ new Map();
48682
48701
  pending2 = /* @__PURE__ */ new Map();
48683
48702
  PREFIX = "vtx:hl-public-read-budget:v1:";
48684
- abortError2 = (signal) => signal?.reason instanceof Error ? signal.reason : new DOMException("Aborted", "AbortError");
48703
+ priorityRank = (priority) => runtime_policy_generated_default.exchange.hyperliquid.public_request_priority[priority];
48704
+ createHyperliquidPublicPriorityScope = (priority = "background") => ({ value: priority });
48705
+ promoteHyperliquidPublicPriority = (scope, priority) => {
48706
+ if (priorityRank(priority) >= priorityRank(scope.value)) return;
48707
+ scope.value = priority;
48708
+ scope.followers?.forEach((promote) => promote(priority));
48709
+ };
48710
+ abortError2 = (signal) => getSanitizedRuntimeAbortReason(signal, "Aborted");
48685
48711
  checkAbort = (signal) => {
48686
48712
  if (signal?.aborted) throw abortError2(signal);
48687
48713
  };
@@ -48783,7 +48809,7 @@ var init_hyperliquid_public_read = __esm({
48783
48809
  recoveryPolicy.fallback_max_seconds * 1e3,
48784
48810
  recoveryPolicy.fallback_initial_seconds * 1e3 * 2 ** Math.min(30, Math.max(0, failures - 1)) * (0.5 + Math.random())
48785
48811
  );
48786
- admit = async (apiUrl, requestType, signal, weightOverride, deadlineMs) => {
48812
+ admit = async (apiUrl, requestType, signal, weightOverride, deadlineMs, priority = createHyperliquidPublicPriorityScope()) => {
48787
48813
  const key = `${PREFIX}${apiUrl}`;
48788
48814
  const weight = weightOverride ?? weights[requestType] ?? policy.default_request_weight;
48789
48815
  const ticket = crypto.randomUUID();
@@ -48803,12 +48829,15 @@ var init_hyperliquid_public_read = __esm({
48803
48829
  recovery.active = recovery.active.filter((entry) => entry.expiresAt > now);
48804
48830
  recovery.queue = recovery.queue.filter((entry) => entry.expiresAt > now);
48805
48831
  if (now >= deadline) throw recoveryWaitError(requestType);
48806
- if (!recovery.queue.some((entry) => entry.id === ticket)) recovery.queue.push({ id: ticket, expiresAt: deadline });
48807
- if (recovery.queue[0]?.id !== ticket || recovery.active.length >= recovery.concurrency || recovery.nextAt > now) {
48832
+ const queued = recovery.queue.find((entry) => entry.id === ticket);
48833
+ if (queued) queued.priority = priorityRank(priority.value);
48834
+ else recovery.queue.push({ id: ticket, expiresAt: deadline, priority: priorityRank(priority.value) });
48835
+ const first = recovery.queue.reduce((best, item) => (item.priority ?? priorityRank("background")) < (best.priority ?? priorityRank("background")) ? item : best);
48836
+ if (first.id !== ticket || recovery.active.length >= recovery.concurrency || recovery.nextAt > now) {
48808
48837
  saveBudget(key, budget);
48809
48838
  return { ready: false, permit: null };
48810
48839
  }
48811
- recovery.queue.shift();
48840
+ recovery.queue = recovery.queue.filter((entry) => entry.id !== ticket);
48812
48841
  const expiresAt = now + recoveryPolicy.permit_lease_seconds * 1e3;
48813
48842
  recovery.active.push({ id: ticket, expiresAt });
48814
48843
  recovery.nextAt = now + recoveryPolicy.recovery_min_spacing_ms;
@@ -48920,10 +48949,10 @@ var init_hyperliquid_public_read = __esm({
48920
48949
  releaseHyperliquidPublicReadReservation = async (reservation) => {
48921
48950
  reservation.closed = true;
48922
48951
  };
48923
- admitHyperliquidExchangeRequest = async (endpoint, action, signal) => {
48952
+ admitHyperliquidExchangeRequest = async (endpoint, action, signal, priority = "trading_execute") => {
48924
48953
  const batchLength = Math.max(0, ...[action.orders, action.cancels, action.modifies].filter(Array.isArray).map((value) => value.length));
48925
48954
  const weight = weights.exchange + Math.floor(batchLength / runtime_policy_generated_default.exchange.hyperliquid.read_budget.exchange_action_batch_size);
48926
- return admit(endpoint.replace(/\/$/, ""), "exchange", signal, weight);
48955
+ return admit(endpoint.replace(/\/$/, ""), "exchange", signal, weight, void 0, createHyperliquidPublicPriorityScope(priority));
48927
48956
  };
48928
48957
  recordHyperliquidExchangeResponse = async (endpoint, response, permit) => {
48929
48958
  if (response.status === 429) await cooldown(endpoint.replace(/\/$/, ""), response.headers.get("Retry-After"));
@@ -48934,6 +48963,7 @@ var init_hyperliquid_public_read = __esm({
48934
48963
  const requestType = String(body.type ?? "info");
48935
48964
  const cacheOptions = { ...options, cacheValidUntilMs: options.reservation?.cacheValidUntilMs ?? options.cacheValidUntilMs };
48936
48965
  const ttlMs = cacheTtlMs(body, cacheOptions);
48966
+ const priority = options.priorityScope ?? options.reservation?.priorityScope ?? createHyperliquidPublicPriorityScope(options.publicRequestPriority);
48937
48967
  const key = `${apiUrl}:${JSON.stringify(body)}`;
48938
48968
  checkAbort(options.signal);
48939
48969
  const transportPolicy = runtime_policy_generated_default.exchange.hyperliquid.http.public_critical;
@@ -48977,28 +49007,35 @@ var init_hyperliquid_public_read = __esm({
48977
49007
  if (existing) return existing;
48978
49008
  const running = pending2.get(key);
48979
49009
  if (!running) break;
49010
+ promoteHyperliquidPublicPriority(running.priority, priority.value);
48980
49011
  setPendingPhase("cache");
48981
49012
  await new Promise((resolve13, reject) => {
48982
- const aborted2 = () => {
49013
+ const promoteOwner = (next) => promoteHyperliquidPublicPriority(running.priority, next);
49014
+ const cleanup = () => {
48983
49015
  signal.removeEventListener("abort", aborted2);
49016
+ priority.followers?.delete(promoteOwner);
49017
+ };
49018
+ const aborted2 = () => {
49019
+ cleanup();
48984
49020
  reject(abortError2(signal));
48985
49021
  };
49022
+ if (running.priority !== priority) (priority.followers ??= /* @__PURE__ */ new Set()).add(promoteOwner);
48986
49023
  signal.addEventListener("abort", aborted2, { once: true });
48987
- running.then(() => {
48988
- signal.removeEventListener("abort", aborted2);
49024
+ running.promise.then(() => {
49025
+ cleanup();
48989
49026
  resolve13();
48990
49027
  });
48991
49028
  });
48992
49029
  checkAbort(signal);
48993
49030
  }
48994
- pending2.set(key, new Promise((resolve13) => {
49031
+ pending2.set(key, { promise: new Promise((resolve13) => {
48995
49032
  settled = resolve13;
48996
- }));
49033
+ }), priority });
48997
49034
  }
48998
49035
  if (options.reservation?.closed) throw new DOMException("Hyperliquid account read was cancelled.", "AbortError");
48999
49036
  acquiring = true;
49000
49037
  setPendingPhase("admission");
49001
- permit = await admit(apiUrl, requestType, signal, void 0, deadline);
49038
+ permit = await admit(apiUrl, requestType, signal, void 0, deadline, priority);
49002
49039
  acquiring = false;
49003
49040
  armDeadline(Math.min(deadline, permit?.expiresAt ?? Infinity));
49004
49041
  checkAbort(signal);
@@ -50853,10 +50890,10 @@ var init_hyperliquid_account_state_adapter = __esm({
50853
50890
  throw error48;
50854
50891
  }
50855
50892
  };
50856
- fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation) => {
50893
+ fetchHyperliquidInfoRead = async (apiUrl, body, signal, reservation, priorityScope) => {
50857
50894
  const trace = startRuntimeNetworkDebugTrace({ kind: "exchange", label: `hyperliquid_info:${String(body.type)}`, method: "POST", url: `${apiUrl.replace(/\/$/, "")}/info` });
50858
50895
  try {
50859
- const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation });
50896
+ const result2 = await readHyperliquidPublicInfo(apiUrl, body, { signal, reservation, priorityScope });
50860
50897
  trace.completeSuccess(200);
50861
50898
  return result2;
50862
50899
  } catch (error48) {
@@ -50864,7 +50901,7 @@ var init_hyperliquid_account_state_adapter = __esm({
50864
50901
  throw error48;
50865
50902
  }
50866
50903
  };
50867
- fetchHyperliquidInfoPayload = async (apiUrl, body, signal, reservation) => (await fetchHyperliquidInfoRead(apiUrl, body, signal, reservation)).payload;
50904
+ fetchHyperliquidInfoPayload = async (apiUrl, body, signal, reservation, priorityScope) => (await fetchHyperliquidInfoRead(apiUrl, body, signal, reservation, priorityScope)).payload;
50868
50905
  requireHyperliquidApiUrl = (config2) => {
50869
50906
  const apiUrl = String(config2.client_runtime_exchange_endpoints?.hyperliquid_api_url || "").trim();
50870
50907
  if (!apiUrl) {
@@ -50944,7 +50981,11 @@ var init_hyperliquid_account_state_adapter = __esm({
50944
50981
  ], now)) {
50945
50982
  return withAccountStateEvidence(cached2.result, "stale_if_429", cached2.fetchedAtMs, staleIf429MaxAgeMs);
50946
50983
  }
50947
- let inFlight = input.forceRefresh ? void 0 : browserAccountStateInFlight.get(cacheKey);
50984
+ const existingFlight = input.forceRefresh ? void 0 : browserAccountStateInFlight.get(cacheKey);
50985
+ const priority = existingFlight?.priority ?? createHyperliquidPublicPriorityScope(input.publicRequestPriority ?? "ui");
50986
+ promoteHyperliquidPublicPriority(priority, input.publicRequestPriority ?? "ui");
50987
+ input = { ...input, priorityScope: priority };
50988
+ let inFlight = existingFlight?.promise;
50948
50989
  if (!inFlight) {
50949
50990
  const uncachedInput = input.forceRefresh ? input : (({ signal: _callerSignal, ...sharedInput }) => sharedInput)(input);
50950
50991
  inFlight = fetchBrowserAccountStateUncached({
@@ -50967,7 +51008,7 @@ var init_hyperliquid_account_state_adapter = __esm({
50967
51008
  }
50968
51009
  });
50969
51010
  if (!input.forceRefresh) {
50970
- browserAccountStateInFlight.set(cacheKey, inFlight);
51011
+ browserAccountStateInFlight.set(cacheKey, { promise: inFlight, priority });
50971
51012
  }
50972
51013
  }
50973
51014
  try {
@@ -51007,6 +51048,7 @@ var init_hyperliquid_account_state_adapter = __esm({
51007
51048
  { type: "userDexAbstraction", user: walletAddress }
51008
51049
  ] : []
51009
51050
  ], input.signal, { cacheAccountMode: true, cacheValidUntilMs: input.publicReadDeadlineMs });
51051
+ reservation.priorityScope = input.priorityScope;
51010
51052
  if (input.onPublicReadPendingChange) {
51011
51053
  const pending3 = { cache: 0, admission: 0, transport: 0 };
51012
51054
  const reportPending = input.onPublicReadPendingChange;
@@ -51324,21 +51366,28 @@ var init_hyperliquid_account_state_adapter = __esm({
51324
51366
  let evidenceSource = "live";
51325
51367
  let fetchedAtMs = now;
51326
51368
  const olderInFlight = browserUserFillsInFlight.get(cacheKey);
51369
+ if (olderInFlight) promoteHyperliquidPublicPriority(olderInFlight.priority, input.publicRequestPriority ?? "ui");
51327
51370
  if (input.forceRefresh && olderInFlight) {
51328
51371
  try {
51329
- await waitForSharedBrowserUserFills(olderInFlight, input.signal);
51372
+ await waitForSharedBrowserUserFills(olderInFlight.promise, input.signal);
51330
51373
  } catch (error48) {
51331
51374
  if (input.signal?.aborted) {
51332
51375
  throw error48;
51333
51376
  }
51334
51377
  }
51335
51378
  }
51336
- let inFlight = browserUserFillsInFlight.get(cacheKey);
51379
+ const existingFlight = browserUserFillsInFlight.get(cacheKey);
51380
+ const priority = existingFlight?.priority ?? createHyperliquidPublicPriorityScope(input.publicRequestPriority ?? "ui");
51381
+ promoteHyperliquidPublicPriority(priority, input.publicRequestPriority ?? "ui");
51382
+ let inFlight = existingFlight?.promise;
51337
51383
  if (!inFlight) {
51338
51384
  let freshRequest;
51339
51385
  freshRequest = fetchHyperliquidInfoPayload(
51340
51386
  apiUrl,
51341
- { type: "userFills", user: walletAddress }
51387
+ { type: "userFills", user: walletAddress },
51388
+ void 0,
51389
+ void 0,
51390
+ priority
51342
51391
  ).then((payload) => {
51343
51392
  const providerRowCount2 = Array.isArray(payload) ? payload.length : 0;
51344
51393
  const rawFills2 = Array.isArray(payload) ? payload.filter(isPerpFill).map((fill) => ({ ...fill })) : [];
@@ -51349,12 +51398,12 @@ var init_hyperliquid_account_state_adapter = __esm({
51349
51398
  });
51350
51399
  return { fetchedAtMs: Date.now(), rawFills: rawFills2, providerRowCount: providerRowCount2 };
51351
51400
  }).finally(() => {
51352
- if (browserUserFillsInFlight.get(cacheKey) === freshRequest) {
51401
+ if (browserUserFillsInFlight.get(cacheKey)?.promise === freshRequest) {
51353
51402
  browserUserFillsInFlight.delete(cacheKey);
51354
51403
  }
51355
51404
  });
51356
51405
  inFlight = freshRequest;
51357
- browserUserFillsInFlight.set(cacheKey, inFlight);
51406
+ browserUserFillsInFlight.set(cacheKey, { promise: inFlight, priority });
51358
51407
  }
51359
51408
  try {
51360
51409
  const liveResult = await waitForSharedBrowserUserFills(inFlight, input.signal);
@@ -51386,7 +51435,7 @@ var init_hyperliquid_account_state_adapter = __esm({
51386
51435
  }
51387
51436
  };
51388
51437
  };
51389
- fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal) => {
51438
+ fetchBrowserPositionSnapshot = async (config2, walletAddress, symbol2, signal, publicRequestPriority = "ui") => {
51390
51439
  configureHyperliquidMarketSymbolCasing(config2.client_runtime_hyperliquid_case_sensitive_symbols);
51391
51440
  const apiUrl = requireHyperliquidApiUrl(config2);
51392
51441
  const normalizedWallet = requireWalletAddress(walletAddress);
@@ -51399,7 +51448,9 @@ var init_hyperliquid_account_state_adapter = __esm({
51399
51448
  const payload = await fetchHyperliquidInfoPayload(
51400
51449
  apiUrl,
51401
51450
  payloadBody,
51402
- signal
51451
+ signal,
51452
+ void 0,
51453
+ createHyperliquidPublicPriorityScope(publicRequestPriority)
51403
51454
  );
51404
51455
  return parseInfoPositionSnapshot(
51405
51456
  dex ? prefixHip3PositionCoins(payload, dex) : payload,
@@ -51982,6 +52033,7 @@ var init_billing = __esm({
51982
52033
  async function getExecutionAssetMetadata(exchange, symbol2, options) {
51983
52034
  const params = new URLSearchParams();
51984
52035
  if (options?.includePrivateContext) params.set("include_private_context", "true");
52036
+ if (options?.publicRequestPriority) params.set("public_request_priority", options.publicRequestPriority);
51985
52037
  const query = params.size > 0 ? `?${params.toString()}` : "";
51986
52038
  const url2 = `${API_URL}/trading/execution-metadata/${encodeURIComponent(exchange)}/${encodeURIComponent(symbol2)}${query}`;
51987
52039
  const response = await fetch(url2, {
@@ -52272,7 +52324,15 @@ async function getClientRuntimeSecrets(profileId, options) {
52272
52324
  operationHint: "get",
52273
52325
  retryAfterHeader: response.headers.get("Retry-After")
52274
52326
  });
52275
- throw new Error(normalizedRateLimitMessage ?? message);
52327
+ throw annotateRuntimeRequestError(new Error(normalizedRateLimitMessage ?? message), {
52328
+ path: "/auth/me/client-runtime-secrets",
52329
+ method: "GET",
52330
+ attempt: 1,
52331
+ maxAttempts: 1,
52332
+ status: response.status,
52333
+ keepalive: false,
52334
+ hadRuntimeLeaseToken: false
52335
+ });
52276
52336
  }
52277
52337
  const payload = await response.json();
52278
52338
  const fetchedPayload = buildClientRuntimeSecretFetchedEventPayload(
@@ -52641,6 +52701,7 @@ async function settleClientRuntimeExchangeMutation(profileId, mutationId, payloa
52641
52701
  JSON.stringify({
52642
52702
  ...clientExchangeMutationAuthorityBody(authority),
52643
52703
  outcome: payload.outcome,
52704
+ dispatch_diagnostics: payload.dispatchDiagnostics ?? void 0,
52644
52705
  exchange_order_id: payload.exchangeOrderId ?? null,
52645
52706
  order_member_results: payload.orderMemberResults?.map((result3) => ({
52646
52707
  client_order_id: result3.clientOrderId,
@@ -52841,6 +52902,7 @@ var init_api2 = __esm({
52841
52902
  const error48 = new Error(message);
52842
52903
  error48.status = response.status;
52843
52904
  error48.detail = payload.detail;
52905
+ Object.assign(error48, { modelFallbackSafe: nestedDetail?.model_fallback_safe === true });
52844
52906
  const code = typeof payload.code === "string" ? payload.code.trim() : typeof nestedDetail?.code === "string" ? nestedDetail.code.trim() : "";
52845
52907
  if (code) {
52846
52908
  error48.code = code;
@@ -83953,7 +84015,7 @@ var init_hyperliquid_signer = __esm({
83953
84015
  });
83954
84016
 
83955
84017
  // lib/runtime/hyperliquid-client.ts
83956
- var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, HYPERLIQUID_TERMINAL_ORDER_STATUSES, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, generateHyperliquidNonce, roundToSigFigs, normalizeDecimalString, toPlainDecimalString, roundDirectionalDecimalString, formatHyperliquidPerpPriceWire, formatHyperliquidTriggerPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfo, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber2, parseFundingUsdcFromInfoPosition2, isExchangeIsolatedOnly, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress2, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState2, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, submitHyperliquidExchangePayload;
84018
+ var HyperliquidExchangeRejectionError, durableMutationAuthorityArgs, assertFreshPreparedExecutionContext, HYPERLIQUID_TERMINAL_ORDER_STATUSES, normalizeSymbol, HYPERLIQUID_NONCE_STORAGE_KEY, HYPERLIQUID_NONCE_LOCK_NAME, lastGeneratedNonce, readBrowserStoredHyperliquidNonce, writeBrowserStoredHyperliquidNonce, browserNonceCoordinator, allocateHyperliquidNonce, generateHyperliquidNonce, roundToSigFigs, normalizeDecimalString, toPlainDecimalString, roundDirectionalDecimalString, formatHyperliquidPerpPriceWire, formatHyperliquidTriggerPriceWire, countSignificantDigits, countDecimalPlaces, validateHyperliquidPerpPriceWire, validateHyperliquidSizeWire, formatSizeWire, inferApiUrl, inferIsTestnet, postHyperliquidInfo, toFiniteNumber, OPEN_ORDER_NUMERIC_STRING, OPEN_ORDER_ID_STRING, parseCanonicalOpenOrderId, parseOpenOrderFiniteNumber, parseOpenOrderPositiveNumber, parseOpenOrderPresentationNumber, readOpenOrderField, firstFiniteNumber2, parseFundingUsdcFromInfoPosition2, isExchangeIsolatedOnly, computeHip3AssetId, getPerpDexIndexMap, buildAssetInfosFromMetaResponse, requireWalletAddress2, assertPositiveInteger, assertPositiveNumber, normalizeOrderSide, normalizeHyperliquidClientOrderId, resolveAssets, findResolvedAsset, normalizeExecutionAssetMetadata, resolveHyperliquidAsset, resolveHyperliquidAssetIndex, fetchBrowserAvailableAssets, fetchBrowserAllMids, fetchBrowserSymbolMidPrice, fetchBrowserOpenOrders, parseCanonicalHyperliquidOrderStatusEvidence, fetchBrowserOrderStatusEvidence, fetchBrowserUserRole, fetchBrowserAccountState2, fetchBrowserPosition, buildHyperliquidOrderWire, buildHyperliquidTriggerOrderWire, signHyperliquidPayload, buildHyperliquidCancelPayload, buildHyperliquidUpdateLeveragePayload, buildHyperliquidMarketOrderPayload, buildHyperliquidTriggerOrderPayload, buildHyperliquidOrderBatchPayload, buildHyperliquidModifyOrderPayload, extractHyperliquidExchangeError, isDefinitiveHyperliquidExchangeResponse, extractDefinitiveHyperliquidOrderId, CANONICAL_POSITIVE_DECIMAL_PATTERN, extractCanonicalHyperliquidOrderStateAcknowledgement, extractCanonicalHyperliquidOrderStateAcknowledgements, extractCanonicalHyperliquidFilledOrderAcknowledgement, extractDefinitiveHyperliquidOrderMemberResults, buildHyperliquidOrderDiagnostics, loadClientExecutionReferenceEvidence, sha256Hex, extractSignedPayloadClientOrderId, extractSignedPayloadMutationCorrelation, assertDurableMutationMatchesSignedAction, exchangeRejectionReason, exchangeActionPriority, submitHyperliquidExchangePayload;
83957
84019
  var init_hyperliquid_client = __esm({
83958
84020
  "lib/runtime/hyperliquid-client.ts"() {
83959
84021
  "use strict";
@@ -84229,7 +84291,7 @@ var init_hyperliquid_client = __esm({
84229
84291
  url: requestUrl
84230
84292
  });
84231
84293
  try {
84232
- const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal });
84294
+ const { payload } = await readHyperliquidPublicInfo(apiUrl, body, { signal: input.signal, publicRequestPriority: input.publicRequestPriority ?? "ui" });
84233
84295
  trace.completeSuccess(200);
84234
84296
  return payload;
84235
84297
  } catch (error48) {
@@ -84487,7 +84549,7 @@ var init_hyperliquid_client = __esm({
84487
84549
  }
84488
84550
  }
84489
84551
  try {
84490
- const metadata = await getExecutionAssetMetadata("hyperliquid", symbol2);
84552
+ const metadata = input.publicRequestPriority === "trading_reduce" ? await getExecutionAssetMetadata("hyperliquid", symbol2, { publicRequestPriority: "trading_reduce" }) : await getExecutionAssetMetadata("hyperliquid", symbol2);
84491
84553
  return normalizeExecutionAssetMetadata(symbol2, metadata);
84492
84554
  } catch (executionMetadataError) {
84493
84555
  const assets = await resolveAssets(input);
@@ -85000,6 +85062,7 @@ var init_hyperliquid_client = __esm({
85000
85062
  };
85001
85063
  };
85002
85064
  buildHyperliquidCancelPayload = async (input) => {
85065
+ input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
85003
85066
  const numericOrderId = typeof input.orderId === "number" ? input.orderId : Number.NaN;
85004
85067
  const clientOrderId = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : void 0;
85005
85068
  if (clientOrderId == null) {
@@ -85034,6 +85097,7 @@ var init_hyperliquid_client = __esm({
85034
85097
  };
85035
85098
  };
85036
85099
  buildHyperliquidUpdateLeveragePayload = async (input) => {
85100
+ input = { ...input, publicRequestPriority: "trading_execute" };
85037
85101
  const apiUrl = inferApiUrl(input);
85038
85102
  const asset = await resolveHyperliquidAsset(input);
85039
85103
  const { signHyperliquidAction: signHyperliquidAction2 } = await Promise.resolve().then(() => (init_hyperliquid_signer(), hyperliquid_signer_exports));
@@ -85064,6 +85128,7 @@ var init_hyperliquid_client = __esm({
85064
85128
  };
85065
85129
  };
85066
85130
  buildHyperliquidMarketOrderPayload = async (input) => {
85131
+ input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
85067
85132
  assertPositiveNumber(input.size, "Hyperliquid order size");
85068
85133
  assertPositiveNumber(input.estimatedPrice, "Hyperliquid estimated price");
85069
85134
  const slippage = input.slippage == null ? 0.05 : Number(input.slippage);
@@ -85080,6 +85145,7 @@ var init_hyperliquid_client = __esm({
85080
85145
  });
85081
85146
  };
85082
85147
  buildHyperliquidTriggerOrderPayload = async (input) => {
85148
+ input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
85083
85149
  const order = await buildHyperliquidTriggerOrderWire({
85084
85150
  ...input,
85085
85151
  limitPrice: input.limitPrice ?? input.triggerPrice
@@ -85091,6 +85157,7 @@ var init_hyperliquid_client = __esm({
85091
85157
  });
85092
85158
  };
85093
85159
  buildHyperliquidOrderBatchPayload = async (input) => {
85160
+ input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
85094
85161
  if (input.members.length < 2 || input.members.length > 16) {
85095
85162
  throw new Error("Hyperliquid TP/SL batch must contain between 2 and 16 orders.");
85096
85163
  }
@@ -85132,6 +85199,7 @@ var init_hyperliquid_client = __esm({
85132
85199
  });
85133
85200
  };
85134
85201
  buildHyperliquidModifyOrderPayload = async (input) => {
85202
+ input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
85135
85203
  const modifyTarget = typeof input.orderId === "string" ? normalizeHyperliquidClientOrderId(input.orderId) : input.orderId;
85136
85204
  if (typeof modifyTarget === "number") {
85137
85205
  assertPositiveInteger(modifyTarget, "Hyperliquid order id");
@@ -85613,9 +85681,25 @@ var init_hyperliquid_client = __esm({
85613
85681
  }
85614
85682
  return signedAssetId;
85615
85683
  };
85684
+ exchangeRejectionReason = (message) => {
85685
+ if (/insufficient.*margin|margin.*insufficient/i.test(message)) return "insufficient_margin";
85686
+ if (/reduce.?only/i.test(message)) return "reduce_only";
85687
+ if (/minimum.*(?:value|notional)|(?:value|notional).*minimum|at least.*\$10/i.test(message)) return "minimum_notional";
85688
+ if (/tick|invalid.*price|price.*invalid/i.test(message)) return "invalid_price";
85689
+ if (/invalid.*size|size.*invalid/i.test(message)) return "invalid_size";
85690
+ if (/rate.?limit|too many requests/i.test(message)) return "rate_limited";
85691
+ if (/invalid.*order|order.*invalid/i.test(message)) return "invalid_order";
85692
+ return "other";
85693
+ };
85694
+ exchangeActionPriority = (action, requested) => {
85695
+ if (action.type === "cancel" || action.type === "cancelByCloid") return requested === "trading_reduce" ? "trading_reduce" : "trading_execute";
85696
+ const orders = action.type === "order" && Array.isArray(action.orders) ? action.orders : action.type === "modify" ? [action.order] : [];
85697
+ return orders.length > 0 && orders.every((order) => order && typeof order === "object" && order.r === true) ? "trading_reduce" : "trading_execute";
85698
+ };
85616
85699
  submitHyperliquidExchangePayload = async (input) => {
85700
+ input = { ...input, publicRequestPriority: exchangeActionPriority(input.payload.action, input.publicRequestPriority) };
85617
85701
  if (input.signal?.aborted) {
85618
- throw input.signal.reason instanceof Error ? input.signal.reason : new DOMException("The operation was aborted.", "AbortError");
85702
+ throw getSanitizedRuntimeAbortReason(input.signal);
85619
85703
  }
85620
85704
  const apiUrl = inferApiUrl(input);
85621
85705
  const requestUrl = `${apiUrl.replace(/\/$/, "")}/exchange`;
@@ -85686,7 +85770,7 @@ var init_hyperliquid_client = __esm({
85686
85770
  );
85687
85771
  }
85688
85772
  }
85689
- const settleDurableMutation = async (outcome, exchangeOrderId = null, orderMemberResults = null) => {
85773
+ const settleDurableMutation = async (outcome, exchangeOrderId = null, orderMemberResults = null, dispatchDiagnostics) => {
85690
85774
  if (!durableMutation) {
85691
85775
  return null;
85692
85776
  }
@@ -85697,6 +85781,7 @@ var init_hyperliquid_client = __esm({
85697
85781
  durableMutation.mutationId,
85698
85782
  {
85699
85783
  outcome,
85784
+ ...dispatchDiagnostics ? { dispatchDiagnostics } : {},
85700
85785
  ...outcome === "success" ? { requireExactSuccessSettlement: true } : {},
85701
85786
  ...exchangeOrderId ? { exchangeOrderId } : {},
85702
85787
  ...orderMemberResults ? { orderMemberResults } : {},
@@ -85788,7 +85873,7 @@ var init_hyperliquid_client = __esm({
85788
85873
  }
85789
85874
  }
85790
85875
  try {
85791
- recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal);
85876
+ recoveryPermit = await admitHyperliquidExchangeRequest(apiUrl, input.payload.action, input.signal, input.publicRequestPriority);
85792
85877
  assertFreshPreparedExecutionContext(input.preparedContext);
85793
85878
  assertHyperliquidRecoveryDispatch(apiUrl, recoveryPermit, "exchange");
85794
85879
  } catch (preparedContextError) {
@@ -85801,7 +85886,7 @@ var init_hyperliquid_client = __esm({
85801
85886
  }
85802
85887
  if (input.signal?.aborted) {
85803
85888
  await settleDurableMutation("rejected");
85804
- throw input.signal.reason instanceof Error ? input.signal.reason : new DOMException("The operation was aborted.", "AbortError");
85889
+ throw getSanitizedRuntimeAbortReason(input.signal);
85805
85890
  }
85806
85891
  if (durableMutation?.onExchangeOrderDispatched) {
85807
85892
  try {
@@ -85857,7 +85942,11 @@ var init_hyperliquid_client = __esm({
85857
85942
  await finishHyperliquidRecoveryRequest(recoveryPermit, response.status < 400 ? "success" : "failure").catch(() => void 0);
85858
85943
  recoveryPermit = null;
85859
85944
  if (!response.ok) {
85860
- await settleDurableMutation("transport_ambiguous");
85945
+ await settleDurableMutation("transport_ambiguous", null, null, {
85946
+ stage: "exchange_http",
85947
+ failure_kind: "http_error",
85948
+ http_status: response.status
85949
+ });
85861
85950
  throw new RuntimeExecutionError(
85862
85951
  "Exchange submission may have completed; durable reconciliation is pending.",
85863
85952
  "outcome_unknown"
@@ -85866,7 +85955,15 @@ var init_hyperliquid_client = __esm({
85866
85955
  const exchangeError = extractHyperliquidExchangeError(payload);
85867
85956
  if (exchangeError) {
85868
85957
  await settleDurableMutation(
85869
- exchangeError.partial ? "transport_ambiguous" : "rejected"
85958
+ exchangeError.partial ? "transport_ambiguous" : "rejected",
85959
+ null,
85960
+ null,
85961
+ {
85962
+ stage: "exchange_response",
85963
+ http_status: response.status,
85964
+ failure_kind: exchangeError.partial ? "partial_response" : "exchange_rejected",
85965
+ rejection_reason: exchangeRejectionReason(exchangeError.message)
85966
+ }
85870
85967
  );
85871
85968
  if (exchangeError.partial) {
85872
85969
  throw new RuntimeExecutionError(
@@ -85884,7 +85981,11 @@ var init_hyperliquid_client = __esm({
85884
85981
  payload,
85885
85982
  input.payload.action
85886
85983
  )) {
85887
- await settleDurableMutation("transport_ambiguous");
85984
+ await settleDurableMutation("transport_ambiguous", null, null, {
85985
+ stage: "exchange_response",
85986
+ failure_kind: "incomplete_response",
85987
+ http_status: response.status
85988
+ });
85888
85989
  throw new RuntimeExecutionError(
85889
85990
  "Hyperliquid returned an incomplete exchange response; durable reconciliation is pending.",
85890
85991
  "outcome_unknown"
@@ -85907,7 +86008,11 @@ var init_hyperliquid_client = __esm({
85907
86008
  } catch (error48) {
85908
86009
  if (durableMutation && exchangeDispatched && !settlementAttempted) {
85909
86010
  try {
85910
- await settleDurableMutation("transport_ambiguous");
86011
+ await settleDurableMutation("transport_ambiguous", null, null, {
86012
+ stage: "exchange_transport",
86013
+ failure_kind: error48?.name === "TimeoutError" ? "timeout" : isAbortLikeError(error48) ? "aborted" : error48 instanceof TypeError ? "network_error" : "transport_error",
86014
+ ...responseStatus != null ? { http_status: responseStatus } : {}
86015
+ });
85911
86016
  } catch {
85912
86017
  throw new RuntimeExecutionError(
85913
86018
  "Exchange submission may have completed; durable reconciliation is pending.",
@@ -85992,6 +86097,7 @@ var init_hyperliquid_signer_binding = __esm({
85992
86097
  try {
85993
86098
  roleResponse = await fetchBrowserUserRole({
85994
86099
  config: input.config ?? null,
86100
+ publicRequestPriority: input.publicRequestPriority ?? "ui",
85995
86101
  walletAddress: signerAddress,
85996
86102
  signal: input.signal
85997
86103
  });
@@ -86892,6 +86998,7 @@ var init_browser_trading = __esm({
86892
86998
  signingKey,
86893
86999
  walletAddress,
86894
87000
  config: input.config ?? null,
87001
+ publicRequestPriority: input.publicRequestPriority,
86895
87002
  signal: input.signal
86896
87003
  });
86897
87004
  return signingKey;
@@ -86903,12 +87010,13 @@ var init_browser_trading = __esm({
86903
87010
  }
86904
87011
  return walletAddress;
86905
87012
  };
86906
- resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal) => {
87013
+ resolveEstimatedPrice = async (config2, symbol2, explicitPrice, signal, publicRequestPriority = "trading_execute") => {
86907
87014
  if (typeof explicitPrice === "number" && Number.isFinite(explicitPrice) && explicitPrice > 0) {
86908
87015
  return explicitPrice;
86909
87016
  }
86910
87017
  const price = await fetchBrowserSymbolMidPrice({
86911
87018
  config: config2 ?? null,
87019
+ publicRequestPriority,
86912
87020
  symbol: symbol2,
86913
87021
  signal
86914
87022
  });
@@ -86916,12 +87024,14 @@ var init_browser_trading = __esm({
86916
87024
  return price;
86917
87025
  };
86918
87026
  executeClientLeverageUpdate = async (input) => {
87027
+ input = { ...input, publicRequestPriority: "trading_execute" };
86919
87028
  throwIfAborted(input.signal);
86920
87029
  const signingKey = await resolveSigningKey(input);
86921
87030
  throwIfAborted(input.signal);
86922
87031
  const mutation = createExchangeMutationIdentity(false);
86923
87032
  const payload = await buildHyperliquidUpdateLeveragePayload({
86924
87033
  config: input.config ?? null,
87034
+ publicRequestPriority: input.publicRequestPriority,
86925
87035
  signingKey,
86926
87036
  symbol: input.symbol,
86927
87037
  leverage: input.leverage,
@@ -86930,6 +87040,7 @@ var init_browser_trading = __esm({
86930
87040
  });
86931
87041
  return submitHyperliquidExchangePayload({
86932
87042
  config: input.config ?? null,
87043
+ publicRequestPriority: input.publicRequestPriority,
86933
87044
  payload,
86934
87045
  signal: input.signal,
86935
87046
  mutationScope: resolveProfileId(input.profileId),
@@ -86946,15 +87057,17 @@ var init_browser_trading = __esm({
86946
87057
  });
86947
87058
  };
86948
87059
  executeClientMarketOrder = async (input) => {
87060
+ input = { ...input, publicRequestPriority: input.reduceOnly === true ? "trading_reduce" : "trading_execute" };
86949
87061
  throwIfAborted(input.signal);
86950
87062
  const signingKey = await resolveSigningKey(input);
86951
87063
  throwIfAborted(input.signal);
86952
- const estimatedPrice = await resolveEstimatedPrice(input.config, input.symbol, input.estimatedPrice, input.signal);
87064
+ const estimatedPrice = await resolveEstimatedPrice(input.config, input.symbol, input.estimatedPrice, input.signal, input.publicRequestPriority);
86953
87065
  throwIfAborted(input.signal);
86954
87066
  assertFreshPreparedContext(input.preparedContext);
86955
87067
  const mutation = createExchangeMutationIdentity(true, input);
86956
87068
  const payload = await buildHyperliquidMarketOrderPayload({
86957
87069
  config: input.config ?? null,
87070
+ publicRequestPriority: input.publicRequestPriority,
86958
87071
  signingKey,
86959
87072
  symbol: input.symbol,
86960
87073
  side: input.side,
@@ -86968,6 +87081,7 @@ var init_browser_trading = __esm({
86968
87081
  });
86969
87082
  return submitHyperliquidExchangePayload({
86970
87083
  config: input.config ?? null,
87084
+ publicRequestPriority: input.publicRequestPriority,
86971
87085
  payload,
86972
87086
  signal: input.signal,
86973
87087
  mutationScope: resolveProfileId(input.profileId),
@@ -86986,12 +87100,14 @@ var init_browser_trading = __esm({
86986
87100
  });
86987
87101
  };
86988
87102
  executeClientTriggerOrder = async (input) => {
87103
+ input = { ...input, publicRequestPriority: input.reduceOnly !== false ? "trading_reduce" : "trading_execute" };
86989
87104
  throwIfAborted(input.signal);
86990
87105
  const signingKey = await resolveSigningKey(input);
86991
87106
  throwIfAborted(input.signal);
86992
87107
  const mutation = createExchangeMutationIdentity(true, input);
86993
87108
  const payload = await buildHyperliquidTriggerOrderPayload({
86994
87109
  config: input.config ?? null,
87110
+ publicRequestPriority: input.publicRequestPriority,
86995
87111
  signingKey,
86996
87112
  symbol: input.symbol,
86997
87113
  side: input.side,
@@ -87006,6 +87122,7 @@ var init_browser_trading = __esm({
87006
87122
  });
87007
87123
  return submitHyperliquidExchangePayload({
87008
87124
  config: input.config ?? null,
87125
+ publicRequestPriority: input.publicRequestPriority,
87009
87126
  payload,
87010
87127
  signal: input.signal,
87011
87128
  mutationScope: resolveProfileId(input.profileId),
@@ -87023,12 +87140,14 @@ var init_browser_trading = __esm({
87023
87140
  });
87024
87141
  };
87025
87142
  executeClientOrderBatch = async (input) => {
87143
+ input = { ...input, publicRequestPriority: input.members.some((m) => m.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
87026
87144
  throwIfAborted(input.signal);
87027
87145
  const signingKey = await resolveSigningKey(input);
87028
87146
  throwIfAborted(input.signal);
87029
87147
  const mutation = createExchangeMutationIdentity(true, input);
87030
87148
  const payload = await buildHyperliquidOrderBatchPayload({
87031
87149
  config: input.config ?? null,
87150
+ publicRequestPriority: input.publicRequestPriority,
87032
87151
  signingKey,
87033
87152
  symbol: input.symbol,
87034
87153
  members: input.members,
@@ -87037,6 +87156,7 @@ var init_browser_trading = __esm({
87037
87156
  });
87038
87157
  return submitHyperliquidExchangePayload({
87039
87158
  config: input.config ?? null,
87159
+ publicRequestPriority: input.publicRequestPriority,
87040
87160
  payload,
87041
87161
  signal: input.signal,
87042
87162
  mutationScope: resolveProfileId(input.profileId),
@@ -87055,12 +87175,14 @@ var init_browser_trading = __esm({
87055
87175
  });
87056
87176
  };
87057
87177
  executeClientModifyOrder = async (input) => {
87178
+ input = { ...input, publicRequestPriority: (input.orderKind === "trigger" ? input.reduceOnly !== false : input.reduceOnly === true) ? "trading_reduce" : "trading_execute" };
87058
87179
  throwIfAborted(input.signal);
87059
87180
  const signingKey = await resolveSigningKey(input);
87060
87181
  throwIfAborted(input.signal);
87061
87182
  const mutation = createExchangeMutationIdentity(true, input);
87062
87183
  const payload = await buildHyperliquidModifyOrderPayload({
87063
87184
  config: input.config ?? null,
87185
+ publicRequestPriority: input.publicRequestPriority,
87064
87186
  signingKey,
87065
87187
  symbol: input.symbol,
87066
87188
  orderId: input.orderId,
@@ -87078,6 +87200,7 @@ var init_browser_trading = __esm({
87078
87200
  });
87079
87201
  return submitHyperliquidExchangePayload({
87080
87202
  config: input.config ?? null,
87203
+ publicRequestPriority: input.publicRequestPriority,
87081
87204
  payload,
87082
87205
  signal: input.signal,
87083
87206
  mutationScope: resolveProfileId(input.profileId),
@@ -87095,12 +87218,14 @@ var init_browser_trading = __esm({
87095
87218
  });
87096
87219
  };
87097
87220
  executeClientCancelOrder = async (input) => {
87221
+ input = { ...input, publicRequestPriority: input.publicRequestPriority ?? "trading_execute" };
87098
87222
  throwIfAborted(input.signal);
87099
87223
  const signingKey = await resolveSigningKey(input);
87100
87224
  throwIfAborted(input.signal);
87101
87225
  const mutation = createExchangeMutationIdentity(false, input);
87102
87226
  const payload = await buildHyperliquidCancelPayload({
87103
87227
  config: input.config ?? null,
87228
+ publicRequestPriority: input.publicRequestPriority,
87104
87229
  signingKey,
87105
87230
  symbol: input.symbol,
87106
87231
  orderId: input.orderId,
@@ -87108,6 +87233,7 @@ var init_browser_trading = __esm({
87108
87233
  });
87109
87234
  return submitHyperliquidExchangePayload({
87110
87235
  config: input.config ?? null,
87236
+ publicRequestPriority: input.publicRequestPriority,
87111
87237
  payload,
87112
87238
  signal: input.signal,
87113
87239
  mutationScope: resolveProfileId(input.profileId),
@@ -87125,10 +87251,12 @@ var init_browser_trading = __esm({
87125
87251
  });
87126
87252
  };
87127
87253
  executeClientClosePosition = async (input) => {
87254
+ input = { ...input, publicRequestPriority: "trading_reduce" };
87128
87255
  throwIfAborted(input.signal);
87129
87256
  const profileId = resolveProfileId(input.profileId);
87130
87257
  const currentPosition = input.position ?? await fetchBrowserPosition({
87131
87258
  config: input.config ?? null,
87259
+ publicRequestPriority: input.publicRequestPriority,
87132
87260
  walletAddress: requireWalletAddress3(input.walletAddress),
87133
87261
  symbol: input.symbol,
87134
87262
  signal: input.signal
@@ -87149,6 +87277,7 @@ var init_browser_trading = __esm({
87149
87277
  schedulerInstanceId: input.schedulerInstanceId,
87150
87278
  walletAddress: input.walletAddress,
87151
87279
  config: input.config ?? null,
87280
+ publicRequestPriority: input.publicRequestPriority,
87152
87281
  signal: input.signal,
87153
87282
  signingKey: input.signingKey,
87154
87283
  symbol: input.symbol,
@@ -87394,7 +87523,7 @@ var init_execution_guard_contract = __esm({
87394
87523
  });
87395
87524
 
87396
87525
  // lib/runtime/runtime-execution.ts
87397
- var fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, executeClientRuntimeDecision;
87526
+ var executionReadPriority, fetchClientRuntimeOpenOrders, createRuntimeId, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, toPositiveNumber, resolveRiskPct, buildTriggerPrice, isConfiguredProtectionRequested, protectiveAction, isExactClientPositionTpslPair, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, recoverJournaledClientProtectiveAttachments, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep3, roundAssetSize, resolvePositionSize, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, verifyNoLiveClientProtectiveTriggers, executeClientRuntimeDecision;
87398
87527
  var init_runtime_execution = __esm({
87399
87528
  "lib/runtime/runtime-execution.ts"() {
87400
87529
  "use strict";
@@ -87410,7 +87539,16 @@ var init_runtime_execution = __esm({
87410
87539
  init_runtime_redaction();
87411
87540
  init_error_surface_contract();
87412
87541
  init_runtime_handoff();
87413
- fetchClientRuntimeOpenOrders = async (request) => {
87542
+ executionReadPriority = (input) => {
87543
+ const context = input.executionContext;
87544
+ const classified = classifyExecutionIntent(
87545
+ input.decision,
87546
+ input.units,
87547
+ signedUnitsFromPosition(context.currentPositionSize, context.lastPrice, context.unitSizeUsdc)
87548
+ );
87549
+ return classified.reduceOnly ? "trading_reduce" : "trading_execute";
87550
+ };
87551
+ fetchClientRuntimeOpenOrders = async (request, publicRequestPriority = "trading_reconcile") => {
87414
87552
  const normalizedSymbol = normalizeHyperliquidMarketSymbol(
87415
87553
  request.executionContext.symbol
87416
87554
  );
@@ -87419,6 +87557,7 @@ var init_runtime_execution = __esm({
87419
87557
  }
87420
87558
  const dex = getHyperliquidMarketDex(normalizedSymbol);
87421
87559
  return fetchBrowserOpenOrders({
87560
+ publicRequestPriority,
87422
87561
  config: request.config ?? null,
87423
87562
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
87424
87563
  signal: request.signal,
@@ -88352,10 +88491,11 @@ var init_runtime_execution = __esm({
88352
88491
  throw new Error("Protective cleanup intent could not be persisted durably.");
88353
88492
  }
88354
88493
  }
88355
- const liveOrders = await fetchClientRuntimeOpenOrders(request);
88494
+ const liveOrders = await fetchClientRuntimeOpenOrders(request, "trading_reduce");
88356
88495
  const liveOrder = liveOrders.find((order) => String(order.oid) === String(leg.orderId));
88357
88496
  if (!liveOrder) {
88358
88497
  const evidence = await fetchBrowserOrderStatusEvidence({
88498
+ publicRequestPriority: "trading_reduce",
88359
88499
  config: request.config ?? null,
88360
88500
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
88361
88501
  signal: request.signal,
@@ -88410,6 +88550,7 @@ var init_runtime_execution = __esm({
88410
88550
  throw new Error("Tracked protective order no longer has its exact authorized shape.");
88411
88551
  }
88412
88552
  await executeClientCancelOrder({
88553
+ publicRequestPriority: "trading_reduce",
88413
88554
  profileId: request.profileId,
88414
88555
  runtimeSessionId: request.sessionId || "__missing_runtime_session__",
88415
88556
  runtimeLeaseToken: request.runtimeLeaseToken,
@@ -88524,7 +88665,8 @@ var init_runtime_execution = __esm({
88524
88665
  request.config ?? {},
88525
88666
  String(request.executionContext.walletAddress || "").trim(),
88526
88667
  symbol2,
88527
- request.signal
88668
+ request.signal,
88669
+ "trading_reduce"
88528
88670
  );
88529
88671
  const livePositionSize = Number(snapshot.size);
88530
88672
  const directionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
@@ -89016,13 +89158,15 @@ var init_runtime_execution = __esm({
89016
89158
  request.config ?? {},
89017
89159
  walletAddress,
89018
89160
  symbol2,
89019
- request.signal
89161
+ request.signal,
89162
+ "trading_reconcile"
89020
89163
  );
89021
89164
  const livePositionSize = Number(livePosition.size);
89022
89165
  if (!Number.isFinite(livePositionSize)) {
89023
89166
  throw new Error("Journaled protective live exposure is unresolved.");
89024
89167
  }
89025
89168
  const { rawFills, evidence } = await fetchBrowserUserFills({
89169
+ publicRequestPriority: "trading_reconcile",
89026
89170
  config: request.config ?? {},
89027
89171
  walletAddress,
89028
89172
  symbols: [symbol2],
@@ -89163,6 +89307,7 @@ var init_runtime_execution = __esm({
89163
89307
  if (openOrder == null) {
89164
89308
  try {
89165
89309
  const evidence = await fetchBrowserOrderStatusEvidence({
89310
+ publicRequestPriority: "trading_reconcile",
89166
89311
  config: request.config ?? null,
89167
89312
  walletAddress,
89168
89313
  signal: request.signal,
@@ -89539,6 +89684,7 @@ var init_runtime_execution = __esm({
89539
89684
  continue;
89540
89685
  }
89541
89686
  const evidence = await fetchBrowserOrderStatusEvidence({
89687
+ publicRequestPriority: "trading_reconcile",
89542
89688
  config: request.config ?? null,
89543
89689
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
89544
89690
  signal: request.signal,
@@ -89551,6 +89697,7 @@ var init_runtime_execution = __esm({
89551
89697
  throw new Error("Pending entry status or shape is unresolved.");
89552
89698
  }
89553
89699
  const { rawFills, evidence: fillEvidence } = await fetchBrowserUserFills({
89700
+ publicRequestPriority: "trading_reconcile",
89554
89701
  config: request.config ?? {},
89555
89702
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
89556
89703
  symbols: [symbol2],
@@ -89660,6 +89807,7 @@ var init_runtime_execution = __esm({
89660
89807
  }
89661
89808
  replacementCleanup = buildVetoedProtectiveReplacementCleanup(replacementReservation);
89662
89809
  const evidence = await fetchBrowserOrderStatusEvidence({
89810
+ publicRequestPriority: "trading_reconcile",
89663
89811
  config: request.config ?? null,
89664
89812
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
89665
89813
  signal: request.signal,
@@ -90003,6 +90151,7 @@ var init_runtime_execution = __esm({
90003
90151
  const [journalLeg] = journalGroup.legs;
90004
90152
  try {
90005
90153
  const evidence = await fetchBrowserOrderStatusEvidence({
90154
+ publicRequestPriority: "trading_reconcile",
90006
90155
  config: request.config ?? null,
90007
90156
  walletAddress: String(request.executionContext.walletAddress || "").trim(),
90008
90157
  signal: request.signal,
@@ -90157,7 +90306,8 @@ var init_runtime_execution = __esm({
90157
90306
  request.config ?? {},
90158
90307
  walletAddress,
90159
90308
  symbol2,
90160
- request.signal
90309
+ request.signal,
90310
+ "trading_reconcile"
90161
90311
  );
90162
90312
  livePositionSize = Number(snapshot.size);
90163
90313
  } catch (error48) {
@@ -90280,6 +90430,7 @@ var init_runtime_execution = __esm({
90280
90430
  }
90281
90431
  try {
90282
90432
  const evidence = await fetchBrowserOrderStatusEvidence({
90433
+ publicRequestPriority: "trading_reconcile",
90283
90434
  config: request.config ?? null,
90284
90435
  walletAddress,
90285
90436
  signal: request.signal,
@@ -91189,6 +91340,7 @@ var init_runtime_execution = __esm({
91189
91340
  if (shouldRefreshExecutionSnapshot) {
91190
91341
  try {
91191
91342
  const refreshed = await fetchBrowserAccountState({
91343
+ publicRequestPriority: executionReadPriority(input),
91192
91344
  config: input.config ?? {},
91193
91345
  walletAddress,
91194
91346
  symbol: input.executionContext.symbol,
@@ -91221,7 +91373,8 @@ var init_runtime_execution = __esm({
91221
91373
  input.config ?? {},
91222
91374
  walletAddress,
91223
91375
  input.executionContext.symbol,
91224
- input.signal
91376
+ input.signal,
91377
+ executionReadPriority(input)
91225
91378
  );
91226
91379
  const parsedLiveSize = resolvePositionSize({
91227
91380
  symbol: input.executionContext.symbol,
@@ -92121,7 +92274,8 @@ var init_runtime_execution = __esm({
92121
92274
  input.config ?? {},
92122
92275
  String(input.executionContext.walletAddress || "").trim(),
92123
92276
  input.executionContext.symbol,
92124
- input.signal
92277
+ input.signal,
92278
+ "trading_reduce"
92125
92279
  );
92126
92280
  const livePositionSize = Number(liveSnapshot.size);
92127
92281
  const liveDirectionMatches = Number.isFinite(livePositionSize) && (isLong ? livePositionSize > 0 : livePositionSize < 0);
@@ -93453,6 +93607,7 @@ async function fetchLocalHyperliquidSnapshot(input) {
93453
93607
  const promptKnobs = objectOrNull3(input.metadata.prompt_knobs) ?? {};
93454
93608
  const leverage = requirePositiveNumber2(promptKnobs.leverage ?? input.llmConfig.default_leverage, "leverage");
93455
93609
  const accountState = await input.fetchAccountState({
93610
+ publicRequestPriority: "trading_analysis",
93456
93611
  config: executionConfig,
93457
93612
  walletAddress,
93458
93613
  symbol: input.symbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtxmacro/cli",
3
- "version": "2026.9.58",
3
+ "version": "2026.9.60",
4
4
  "description": "VTX Macro CLI, MCP server, and durable external inference host.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",