@vtxmacro/cli 2026.10.39 → 2026.10.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/vtx-mcp.js +1 -1
- package/bin/vtx-service-bootstrap.js +1 -1
- package/bin/vtx.js +211 -12
- package/package.json +1 -1
package/bin/vtx-mcp.js
CHANGED
|
@@ -43,7 +43,7 @@ var init_define_VTX_PI_MODEL_POLICY = __esm({
|
|
|
43
43
|
var agent_cli_release_default;
|
|
44
44
|
var init_agent_cli_release = __esm({
|
|
45
45
|
"agent-cli-release.json"() {
|
|
46
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
46
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.41", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
49
|
|
|
@@ -14,7 +14,7 @@ import { dirname as dirname4, relative as relative4, resolve as resolve4 } from
|
|
|
14
14
|
import { fileURLToPath } from "node:url";
|
|
15
15
|
|
|
16
16
|
// agent-cli-release.json
|
|
17
|
-
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
17
|
+
var agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.41", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
18
18
|
|
|
19
19
|
// lib/runtime-policy.generated.json
|
|
20
20
|
var runtime_policy_generated_default = {
|
package/bin/vtx.js
CHANGED
|
@@ -122,7 +122,7 @@ var init_routing = __esm({
|
|
|
122
122
|
var agent_cli_release_default;
|
|
123
123
|
var init_agent_cli_release = __esm({
|
|
124
124
|
"agent-cli-release.json"() {
|
|
125
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
125
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.41", codex_package_name: "@openai/codex", codex_version: "0.155.0", copilot_sdk_package_name: "@github/copilot-sdk", copilot_sdk_version: "1.0.0-beta.8", copilot_cli_package_name: "@github/copilot", copilot_cli_version: "1.0.80", deepseek_harness_version: "0.1.1-rc.2", deepseek_harness_packages: ["@deepseek-ai/dsh-agent", "@deepseek-ai/dsh-agent-instructions", "@deepseek-ai/dsh-agent-loop", "@deepseek-ai/dsh-agent-spine-demo", "@deepseek-ai/dsh-anonymous-user-id", "@deepseek-ai/dsh-atomic-write", "@deepseek-ai/dsh-attachment", "@deepseek-ai/dsh-brand", "@deepseek-ai/dsh-code-runtime", "@deepseek-ai/dsh-credentials", "@deepseek-ai/dsh-fs", "@deepseek-ai/dsh-goal", "@deepseek-ai/dsh-goal-round-driver", "@deepseek-ai/dsh-home-paths", "@deepseek-ai/dsh-invariants", "@deepseek-ai/dsh-jobs", "@deepseek-ai/dsh-jobs-local", "@deepseek-ai/dsh-launch-environment", "@deepseek-ai/dsh-llm", "@deepseek-ai/dsh-llm-deepseek", "@deepseek-ai/dsh-llm-retry", "@deepseek-ai/dsh-output-retention", "@deepseek-ai/dsh-sandbox", "@deepseek-ai/dsh-sandbox-policy", "@deepseek-ai/dsh-scope", "@deepseek-ai/dsh-session", "@deepseek-ai/dsh-session-checkpoint-policy", "@deepseek-ai/dsh-session-persistence", "@deepseek-ai/dsh-session-persistence-jsonl", "@deepseek-ai/dsh-session-projection", "@deepseek-ai/dsh-session-title", "@deepseek-ai/dsh-settings", "@deepseek-ai/dsh-shell", "@deepseek-ai/dsh-shell-env", "@deepseek-ai/dsh-skill", "@deepseek-ai/dsh-skill-filesystem", "@deepseek-ai/dsh-subprocess", "@deepseek-ai/dsh-system-prompt", "@deepseek-ai/dsh-timeout", "@deepseek-ai/dsh-tool-bash", "@deepseek-ai/dsh-tool-goal", "@deepseek-ai/dsh-tool-jobs", "@deepseek-ai/dsh-tool-skill", "@deepseek-ai/dsh-tools", "@deepseek-ai/dsh-typert-protocol", "@deepseek-ai/dsh-user-approval"], deepseek_cordis_package_name: "@deepseek-ai/cordis", deepseek_cordis_version: "4.0.1", deepseek_support_packages: { "@deepseek-ai/cordis-plugin-timer": "1.1.3" }, platforms: { "linux-x64": { package_name: "@openai/codex-linux-x64", target: "x86_64-unknown-linux-musl", binary_name: "codex", sha256: "660e159a49e823ac8e5986cb238f73158ce4b957d40d9292f8de90862644b501" }, "win32-x64": { package_name: "@openai/codex-win32-x64", target: "x86_64-pc-windows-msvc", binary_name: "codex.exe", sha256: "e4c11374bd9de8ad5c3b7617fd4654bb7839901edb0863f9930666863c7a021b" } }, pi_coding_agent_package_name: "@earendil-works/pi-coding-agent", pi_ai_package_name: "@earendil-works/pi-ai", pi_version: "0.85.1", pi_support_packages: ["@earendil-works/pi-agent-core", "@earendil-works/pi-telemetry", "@earendil-works/pi-tui", "@earendil-works/chord"], grok_version: "1.0.30", grok_platforms: { "linux-x64": { package_name: "@xai-official/grok-linux-x64", binary_name: "grok", sha256: "504dd6546ab991b75d36698242875ce461489cd1f8cd84285873cb55bd5c7d54" }, "win32-x64": { package_name: "@xai-official/grok-win32-x64", binary_name: "grok.exe", sha256: "48736d1a4342a801ea26d0ecde4c516b653f791399065adaa55973f83abd8867" } } };
|
|
126
126
|
}
|
|
127
127
|
});
|
|
128
128
|
|
|
@@ -60286,7 +60286,7 @@ var init_hyperliquid_public_capacity = __esm({
|
|
|
60286
60286
|
adaptivePublicCapacity = (input) => {
|
|
60287
60287
|
const { nowMs: nowMs2, policy: policy2 } = input;
|
|
60288
60288
|
const current = publicDemandBucketIndex(nowMs2, policy2.bucketMs);
|
|
60289
|
-
const oldest =
|
|
60289
|
+
const oldest = publicDemandBucketIndex(nowMs2 - policy2.horizonMs, policy2.bucketMs);
|
|
60290
60290
|
const inHorizon = input.buckets.map((bucket) => ({ ...bucket, index: Math.min(bucket.index, current) })).filter((bucket) => bucket.index >= oldest);
|
|
60291
60291
|
const peak = (from, of) => inHorizon.filter((bucket) => bucket.index >= from).reduce((most, bucket) => Math.max(most, of(bucket)), 0);
|
|
60292
60292
|
const peakHigher = peak(oldest, (bucket) => bucket.higherPeak);
|
|
@@ -60314,7 +60314,7 @@ var init_hyperliquid_public_capacity = __esm({
|
|
|
60314
60314
|
});
|
|
60315
60315
|
|
|
60316
60316
|
// lib/runtime/hyperliquid-public-read.ts
|
|
60317
|
-
var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, priorityRank, createHyperliquidPublicPriorityScope, promoteHyperliquidPublicPriority, hostTransport, hyperliquidPrivateInfoHeldOff, abortError2, checkAbort, wait, waitUnlessPromoted, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, ranks, mostUrgentRank, lastRank, capacityPolicy, isHeldBack, reservationRank, classBoundaries, everyone, slotOf, windowWeights, foldDemand, demandFor, heldBackDecision, fallbackDelayMs, admit, rowWeightedCharge, settleRowWeightedReservation, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, validateHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
60317
|
+
var policy, weights, recoveryPolicy, budgets, unpersistedBudgets, cache, pending2, PREFIX, priorityRank, createHyperliquidPublicPriorityScope, promoteHyperliquidPublicPriority, hostTransport, hyperliquidPrivateInfoHeldOff, abortError2, checkAbort, wait, waitUnlessPromoted, storage, loadBudget, saveBudget, withBudgetLock, HyperliquidPublicReadError, getHyperliquidPublicReadBudget, cooldownError, recoveryWaitError, ranks, mostUrgentRank, lastRank, capacityPolicy, READERS_KEY, memoryReaders, unwrittenReaders, validSchedule, readTradingReaders, noteTradingReader, noteHyperliquidTradingRuntime, noteHyperliquidUnscheduledTradingRead, hyperliquidDemandWindowMs, greatestCommonDivisor, heldDemand, isHeldBack, reservationRank, classBoundaries, everyone, slotOf, windowWeights, foldDemand, demandFor, heldBackDecision, fallbackDelayMs, admit, rowWeightedCharge, settleRowWeightedReservation, cooldown, finishHyperliquidRecoveryRequest, assertHyperliquidRecoveryDispatch, validateHyperliquidRecoveryDispatch, cacheTtlMs, eligibleCache, reserveHyperliquidPublicReads, releaseHyperliquidPublicReadReservation, admitHyperliquidExchangeRequest, recordHyperliquidExchangeResponse, readHyperliquidPublicInfo;
|
|
60318
60318
|
var init_hyperliquid_public_read = __esm({
|
|
60319
60319
|
"lib/runtime/hyperliquid-public-read.ts"() {
|
|
60320
60320
|
"use strict";
|
|
@@ -60477,6 +60477,86 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60477
60477
|
minWeight: policy.capacity_min_weight,
|
|
60478
60478
|
recoveryPerMinute: policy.capacity_recovery_weight_per_minute
|
|
60479
60479
|
};
|
|
60480
|
+
READERS_KEY = "vtx:hl-trading-readers:v1";
|
|
60481
|
+
memoryReaders = [];
|
|
60482
|
+
unwrittenReaders = /* @__PURE__ */ new Map();
|
|
60483
|
+
validSchedule = (schedule) => Number.isFinite(schedule.loopMs) && schedule.loopMs > 0 && Number.isFinite(schedule.cycleMs) && schedule.cycleMs >= 0 && Number.isFinite(schedule.startedAt) && (schedule.firstCycleEndedAt == null || Number.isFinite(schedule.firstCycleEndedAt)) && (schedule.offCadenceAt == null || Number.isFinite(schedule.offCadenceAt)) && (schedule.loopChangedAt == null || Number.isFinite(schedule.loopChangedAt));
|
|
60484
|
+
readTradingReaders = (now) => {
|
|
60485
|
+
let readers = memoryReaders;
|
|
60486
|
+
try {
|
|
60487
|
+
const stored = JSON.parse(storage()?.getItem(READERS_KEY) ?? "null");
|
|
60488
|
+
if (Array.isArray(stored) && stored.every((reader) => typeof reader?.id === "string" && Number.isFinite(reader.until) && Number.isFinite(reader.notedAt) && (reader.schedule === void 0 || typeof reader.schedule === "object" && reader.schedule !== null && validSchedule(reader.schedule)))) {
|
|
60489
|
+
readers = stored.filter((reader) => {
|
|
60490
|
+
const own = unwrittenReaders.get(reader.id);
|
|
60491
|
+
return own === void 0 || own !== null && reader.notedAt > own.notedAt;
|
|
60492
|
+
});
|
|
60493
|
+
for (const [id2, own] of unwrittenReaders) {
|
|
60494
|
+
if (own && !readers.some((reader) => reader.id === id2)) readers.push(own);
|
|
60495
|
+
}
|
|
60496
|
+
}
|
|
60497
|
+
} catch {
|
|
60498
|
+
}
|
|
60499
|
+
return readers.filter((reader) => reader.until > now);
|
|
60500
|
+
};
|
|
60501
|
+
noteTradingReader = async (id2, entry) => {
|
|
60502
|
+
if (hostTransport) return;
|
|
60503
|
+
await withBudgetLock(READERS_KEY, void 0, () => {
|
|
60504
|
+
const now = Date.now();
|
|
60505
|
+
const added = entry ? entry(now) : null;
|
|
60506
|
+
const readers = readTradingReaders(now).filter((reader) => reader.id !== id2);
|
|
60507
|
+
if (added) readers.push(added);
|
|
60508
|
+
memoryReaders = readers;
|
|
60509
|
+
try {
|
|
60510
|
+
const target = storage();
|
|
60511
|
+
if (!target) return;
|
|
60512
|
+
target.setItem(READERS_KEY, JSON.stringify(readers));
|
|
60513
|
+
unwrittenReaders.clear();
|
|
60514
|
+
} catch {
|
|
60515
|
+
unwrittenReaders.set(id2, added);
|
|
60516
|
+
}
|
|
60517
|
+
});
|
|
60518
|
+
};
|
|
60519
|
+
noteHyperliquidTradingRuntime = (id2, schedule) => noteTradingReader(
|
|
60520
|
+
id2,
|
|
60521
|
+
schedule && ((now) => ({ id: id2, schedule, notedAt: now, until: now + schedule.loopMs + schedule.cycleMs + capacityPolicy.horizonMs }))
|
|
60522
|
+
);
|
|
60523
|
+
noteHyperliquidUnscheduledTradingRead = (id2) => noteTradingReader(
|
|
60524
|
+
id2,
|
|
60525
|
+
(now) => ({ id: id2, notedAt: now, until: now + capacityPolicy.horizonMs })
|
|
60526
|
+
);
|
|
60527
|
+
hyperliquidDemandWindowMs = () => capacityPolicy.windowMs;
|
|
60528
|
+
greatestCommonDivisor = (left, right) => {
|
|
60529
|
+
let [a, b3] = [left, right];
|
|
60530
|
+
while (b3 !== 0) [a, b3] = [b3, a % b3];
|
|
60531
|
+
return a;
|
|
60532
|
+
};
|
|
60533
|
+
heldDemand = (buckets, now, readers) => {
|
|
60534
|
+
const schedules = readers.flatMap((reader) => reader.schedule ? [reader.schedule] : []);
|
|
60535
|
+
if (schedules.length === 0 || schedules.length < readers.length) return buckets;
|
|
60536
|
+
let linedUpMs = schedules[0].loopMs;
|
|
60537
|
+
for (const { loopMs } of schedules) {
|
|
60538
|
+
linedUpMs = linedUpMs / greatestCommonDivisor(linedUpMs, loopMs) * loopMs;
|
|
60539
|
+
if (linedUpMs >= capacityPolicy.horizonMs) return buckets;
|
|
60540
|
+
}
|
|
60541
|
+
const releaseAfterMs = linedUpMs + Math.max(...schedules.map((schedule) => schedule.loopMs)) + Math.max(...schedules.map((schedule) => schedule.cycleMs)) + capacityPolicy.windowMs;
|
|
60542
|
+
if (releaseAfterMs >= capacityPolicy.horizonMs) return buckets;
|
|
60543
|
+
const phased = schedules.filter((schedule) => capacityPolicy.windowMs % schedule.loopMs !== 0);
|
|
60544
|
+
const offCadenceAt = Math.max(
|
|
60545
|
+
0,
|
|
60546
|
+
...phased.length > 1 ? phased.map((schedule) => schedule.offCadenceAt ?? 0) : [],
|
|
60547
|
+
...schedules.map((schedule) => (schedule.loopChangedAt === void 0 ? schedule.offCadenceAt : schedule.loopChangedAt) ?? 0)
|
|
60548
|
+
);
|
|
60549
|
+
const startups = schedules.map((schedule) => ({
|
|
60550
|
+
from: schedule.startedAt,
|
|
60551
|
+
to: Math.min(schedule.firstCycleEndedAt ?? now, schedule.startedAt + schedule.loopMs + schedule.cycleMs)
|
|
60552
|
+
}));
|
|
60553
|
+
return buckets.filter((bucket) => {
|
|
60554
|
+
const bucketStart = bucket.index * capacityPolicy.bucketMs;
|
|
60555
|
+
const bucketEnd = bucketStart + capacityPolicy.bucketMs;
|
|
60556
|
+
const startup = startups.some(({ from, to }) => from < bucketEnd && to > bucketStart - capacityPolicy.windowMs);
|
|
60557
|
+
return !startup || now < Math.max(bucketEnd, offCadenceAt) + releaseAfterMs;
|
|
60558
|
+
});
|
|
60559
|
+
};
|
|
60480
60560
|
isHeldBack = (rank) => rank >= priorityRank("ui");
|
|
60481
60561
|
reservationRank = (entry) => entry.rank ?? mostUrgentRank;
|
|
60482
60562
|
classBoundaries = Array.from({ length: lastRank - mostUrgentRank + 1 }, (_unused, offset) => mostUrgentRank + 1 + offset);
|
|
@@ -60495,7 +60575,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60495
60575
|
foldDemand = (budget, now) => {
|
|
60496
60576
|
const foldUpTo = now - capacityPolicy.windowMs;
|
|
60497
60577
|
const foldedUpTo = Math.min(budget.folded ?? 0, foldUpTo);
|
|
60498
|
-
const oldest = publicDemandBucketIndex(now
|
|
60578
|
+
const oldest = publicDemandBucketIndex(now - capacityPolicy.horizonMs, capacityPolicy.bucketMs);
|
|
60499
60579
|
const demand = (budget.demand ?? []).filter((entry) => entry[0] >= oldest);
|
|
60500
60580
|
for (const reservation of budget.reservations) {
|
|
60501
60581
|
if (reservation.at <= foldedUpTo || reservation.at > foldUpTo) continue;
|
|
@@ -60528,14 +60608,13 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60528
60608
|
const live = budget.reservations.filter((entry) => entry.at > now - capacityPolicy.windowMs);
|
|
60529
60609
|
const total = live.reduce((sum, entry) => sum + entry.weight, 0);
|
|
60530
60610
|
const rankAndBelow = (fromRank) => live.filter((entry) => reservationRank(entry) >= fromRank).reduce((sum, entry) => sum + entry.weight, 0);
|
|
60611
|
+
const readers = readTradingReaders(now);
|
|
60531
60612
|
const above = (fromRank) => {
|
|
60532
|
-
const
|
|
60533
|
-
|
|
60534
|
-
|
|
60535
|
-
|
|
60536
|
-
|
|
60537
|
-
});
|
|
60538
|
-
return { capacity: Math.min(computed.capacity, policy.max_weight), peakHigher: computed.peakHigher };
|
|
60613
|
+
const buckets = demandFor(budget, fromRank, now);
|
|
60614
|
+
const lastFailureMs = budget.lastFailure ?? 0;
|
|
60615
|
+
const computed = adaptivePublicCapacity({ nowMs: now, lastFailureMs, buckets, policy: capacityPolicy });
|
|
60616
|
+
const held = adaptivePublicCapacity({ nowMs: now, lastFailureMs, buckets: heldDemand(buckets, now, readers), policy: capacityPolicy });
|
|
60617
|
+
return { capacity: Math.min(computed.capacity, policy.max_weight), peakHigher: held.peakHigher };
|
|
60539
60618
|
};
|
|
60540
60619
|
const own = above(rank);
|
|
60541
60620
|
const uiRank = priorityRank("ui");
|
|
@@ -110187,6 +110266,7 @@ var init_runtime_execution = __esm({
|
|
|
110187
110266
|
}
|
|
110188
110267
|
const ownGroups = groups.filter((group) => group.pendingEntry != null && group.walletAddress === walletAddress.toLowerCase());
|
|
110189
110268
|
if (ownGroups.length === 0) return [];
|
|
110269
|
+
input.beforeRead?.();
|
|
110190
110270
|
const sizeDecimals = await resolveExchangeSizeDecimals(symbol2, input.config, "trading_reconcile");
|
|
110191
110271
|
const request = {
|
|
110192
110272
|
mutationAuthority: "manual_session",
|
|
@@ -112581,6 +112661,7 @@ var init_server_protection_sweep = __esm({
|
|
|
112581
112661
|
init_runtime_policy_generated2();
|
|
112582
112662
|
init_protective_cutover();
|
|
112583
112663
|
init_protective_evidence();
|
|
112664
|
+
init_hyperliquid_public_read();
|
|
112584
112665
|
sweepServerOwnedProtectionOnce = async (input) => {
|
|
112585
112666
|
const authority = input.authority;
|
|
112586
112667
|
const listed = await listClientProtectiveActions(
|
|
@@ -112609,6 +112690,7 @@ var init_server_protection_sweep = __esm({
|
|
|
112609
112690
|
})) {
|
|
112610
112691
|
return evidenceSweepAt(null);
|
|
112611
112692
|
}
|
|
112693
|
+
void noteHyperliquidUnscheduledTradingRead(`server-owned-protection:${input.profileId}`).catch(() => void 0);
|
|
112612
112694
|
const config2 = await getLLMConfig(void 0, Number(input.profileId), input.signal);
|
|
112613
112695
|
const result = await syncServerOwnedProtection({
|
|
112614
112696
|
profileId: input.profileId,
|
|
@@ -128676,7 +128758,7 @@ ${reviewOutputContract}`;
|
|
|
128676
128758
|
});
|
|
128677
128759
|
|
|
128678
128760
|
// lib/runtime/engine.ts
|
|
128679
|
-
var DEVICE_DIAGNOSTICS3, FALLBACK_ERROR_MAX_CHARS, localAnalysis, getExchangeFailureDiagnostics, getRuntimeFallbackAttempts, sentInvocationAttemptCount, boundRuntimeFallbackAttempts, isProviderFailureDiagnosticsCandidate, getEventBoundProviderLabel, getEventBoundProviderTraceId, CLIENT_RUNTIME_POLICY, getRecentProviderFailureDiagnostics, getClientRuntimeErrorProvenance, getRuntimeProviderSetupDiagnostics, buildProviderSetupErrorDiagnosticFields, buildClientRuntimeErrorProvenanceDiagnosticFields, buildRuntimeRequestErrorDiagnosticFields, getCycleErrorModelCalls, isReturnedModelCall, hasEventBoundProviderFailureEvidence, endsWithNeverSentAttempt, classifyRuntimeErrorStage, buildHyperliquidPublicReadDiagnosticFields, buildRuntimeErrorDiagnostics, positiveNumber, resolveRuntimeEngineOptions, withServerPositionEvents, CLIENT_KILLSWITCH_BLOCK_STORAGE_PREFIX, getClientKillswitchBlockStorageKey, isClientRuntimeKillswitchBlocked, persistClientRuntimeKillswitchBlock, clearClientRuntimeKillswitchBlock, hashRuntimeDebugText2, createRuntimeUuid2, getRuntimeContractIdentityToken, getRuntimeStatusContractIdentityToken, getRuntimeContractBindingTokenFromCycleResult, getRuntimeContractBindingTupleToken, getRuntimeStatusContractBindingTupleToken, isTransientRuntimeConflictError, createRuntimeStartCancelledError, isRuntimeContractMismatchError, isClientExecutionModeMismatchError, isClientRuntimeSessionStoppedError, isClientRuntimeLeaseAuthError, isClientRuntimeReleasedError, deriveFailedStartCleanupOwnershipLossReason, isRuntimeAbortError, isExplicitClientExecutionMode, createStopAbortError, isRuntimeContractIdentityAdvancedAbort, CLIENT_RUNTIME_NO_DECISION_RECOVERY_REASON, sanitizeSettingsSnapshotForFallback, preflightClientRuntime, ClientExecutionEngine, createStoppedRuntimeSnapshot, ClientRuntimeRegistry, botEngine;
|
|
128761
|
+
var DEVICE_DIAGNOSTICS3, FALLBACK_ERROR_MAX_CHARS, localAnalysis, getExchangeFailureDiagnostics, getRuntimeFallbackAttempts, sentInvocationAttemptCount, boundRuntimeFallbackAttempts, isProviderFailureDiagnosticsCandidate, getEventBoundProviderLabel, getEventBoundProviderTraceId, CLIENT_RUNTIME_POLICY, getRecentProviderFailureDiagnostics, getClientRuntimeErrorProvenance, getRuntimeProviderSetupDiagnostics, buildProviderSetupErrorDiagnosticFields, buildClientRuntimeErrorProvenanceDiagnosticFields, buildRuntimeRequestErrorDiagnosticFields, getCycleErrorModelCalls, isReturnedModelCall, hasEventBoundProviderFailureEvidence, endsWithNeverSentAttempt, classifyRuntimeErrorStage, buildHyperliquidPublicReadDiagnosticFields, buildRuntimeErrorDiagnostics, positiveNumber, resolveRuntimeEngineOptions, withServerPositionEvents, CLIENT_KILLSWITCH_BLOCK_STORAGE_PREFIX, getClientKillswitchBlockStorageKey, isClientRuntimeKillswitchBlocked, persistClientRuntimeKillswitchBlock, clearClientRuntimeKillswitchBlock, hashRuntimeDebugText2, createRuntimeUuid2, getRuntimeContractIdentityToken, getRuntimeStatusContractIdentityToken, getRuntimeContractBindingTokenFromCycleResult, getRuntimeContractBindingTupleToken, getRuntimeStatusContractBindingTupleToken, isTransientRuntimeConflictError, createRuntimeStartCancelledError, isRuntimeContractMismatchError, isClientExecutionModeMismatchError, isClientRuntimeSessionStoppedError, isClientRuntimeLeaseAuthError, isClientRuntimeReleasedError, deriveFailedStartCleanupOwnershipLossReason, isRuntimeAbortError, isExplicitClientExecutionMode, createStopAbortError, isRuntimeContractIdentityAdvancedAbort, CLIENT_RUNTIME_NO_DECISION_RECOVERY_REASON, sanitizeSettingsSnapshotForFallback, preflightClientRuntime, onCadenceGridPoint, ClientExecutionEngine, createStoppedRuntimeSnapshot, ClientRuntimeRegistry, botEngine;
|
|
128680
128762
|
var init_engine = __esm({
|
|
128681
128763
|
"lib/runtime/engine.ts"() {
|
|
128682
128764
|
"use strict";
|
|
@@ -128685,6 +128767,7 @@ var init_engine = __esm({
|
|
|
128685
128767
|
init_define_VTX_GROK_POLICY();
|
|
128686
128768
|
init_define_VTX_PI_MODEL_POLICY();
|
|
128687
128769
|
init_protective_cutover();
|
|
128770
|
+
init_hyperliquid_public_read();
|
|
128688
128771
|
init_runtime_policy_generated2();
|
|
128689
128772
|
init_constants();
|
|
128690
128773
|
init_periodic_schedule();
|
|
@@ -129308,6 +129391,10 @@ var init_engine = __esm({
|
|
|
129308
129391
|
requireProviderSecret
|
|
129309
129392
|
};
|
|
129310
129393
|
};
|
|
129394
|
+
onCadenceGridPoint = (atMs, pointMs, loopMs, toleranceMs) => {
|
|
129395
|
+
const offsetMs = Math.abs(atMs - pointMs);
|
|
129396
|
+
return offsetMs <= toleranceMs && offsetMs < Math.abs(atMs - pointMs - loopMs) && offsetMs < Math.abs(atMs - pointMs + loopMs);
|
|
129397
|
+
};
|
|
129311
129398
|
ClientExecutionEngine = class {
|
|
129312
129399
|
constructor() {
|
|
129313
129400
|
this._state = "stopped";
|
|
@@ -129350,6 +129437,22 @@ var init_engine = __esm({
|
|
|
129350
129437
|
this._heartbeatOfflineAfterMs = null;
|
|
129351
129438
|
this._analysisDefaultTimeoutSeconds = null;
|
|
129352
129439
|
this._analysisStaleAfterMs = null;
|
|
129440
|
+
// When this runtime last started (attached a grant), when its first cycle since ended, and
|
|
129441
|
+
// whether its cycles follow Agent instructions (which no loop schedules) rather than its loop.
|
|
129442
|
+
this._startedAtMs = null;
|
|
129443
|
+
this._firstCycleEndedAtMs = null;
|
|
129444
|
+
this._agentDrivenCycles = false;
|
|
129445
|
+
// The latest slot this runtime missed (and the latest it missed when its
|
|
129446
|
+
// loop changed), whether it has no next run, and the grid its on-cadence
|
|
129447
|
+
// runs follow (see _armExecutionLoopTimer).
|
|
129448
|
+
this._lastOffCadenceAtMs = null;
|
|
129449
|
+
this._lastLoopChangedAtMs = null;
|
|
129450
|
+
this._noNextRun = false;
|
|
129451
|
+
this._cadenceGridMs = null;
|
|
129452
|
+
this._cadenceLoopMs = null;
|
|
129453
|
+
this._cadenceRunMs = null;
|
|
129454
|
+
this._cadencePendingMs = null;
|
|
129455
|
+
this._cycleStartedByTimer = false;
|
|
129353
129456
|
this._settlementRequestTimeoutMs = null;
|
|
129354
129457
|
this._lastSuccessfulHeartbeatAtMs = null;
|
|
129355
129458
|
this._analysisRequestId = null;
|
|
@@ -130227,8 +130330,13 @@ var init_engine = __esm({
|
|
|
130227
130330
|
this._initializeNextRunAnchor();
|
|
130228
130331
|
}
|
|
130229
130332
|
if (this._nextRunAtMs == null && !options?.suppressNextRunProjection && options?.delayOverrideMs == null) {
|
|
130333
|
+
this._noNextRun = true;
|
|
130334
|
+
this._cadenceGridMs = null;
|
|
130335
|
+
this._cadencePendingMs = null;
|
|
130336
|
+
this._noteTradingRuntime();
|
|
130230
130337
|
return;
|
|
130231
130338
|
}
|
|
130339
|
+
this._noNextRun = false;
|
|
130232
130340
|
const rawDelayOverrideMs = options?.delayOverrideMs;
|
|
130233
130341
|
const parsedDelayOverrideMs = Number(rawDelayOverrideMs);
|
|
130234
130342
|
const hasDelayOverride = rawDelayOverrideMs !== null && rawDelayOverrideMs !== void 0 && Number.isFinite(parsedDelayOverrideMs) && parsedDelayOverrideMs >= 0;
|
|
@@ -130236,6 +130344,34 @@ var init_engine = __esm({
|
|
|
130236
130344
|
const timerReason = options?.reason || "scheduled";
|
|
130237
130345
|
const armedAtMs = Date.now();
|
|
130238
130346
|
const expectedFireAtMs = armedAtMs + delayMs;
|
|
130347
|
+
if (this._agentDrivenCycles) {
|
|
130348
|
+
this._cadenceGridMs = null;
|
|
130349
|
+
this._cadencePendingMs = null;
|
|
130350
|
+
} else if (!timerReason.endsWith("_retry")) {
|
|
130351
|
+
const loopMs = this._loopIntervalMs;
|
|
130352
|
+
const toleranceMs = hyperliquidDemandWindowMs();
|
|
130353
|
+
const gridPointMs = this._cadenceGridMs == null ? null : this._cadenceRunMs == null ? this._cadenceGridMs : this._cadenceRunMs + loopMs;
|
|
130354
|
+
const continuesCadence = gridPointMs != null && this._cadenceLoopMs === loopMs && onCadenceGridPoint(expectedFireAtMs, gridPointMs, loopMs, toleranceMs);
|
|
130355
|
+
if (timerReason === "ai_schedule_paused" || !continuesCadence) {
|
|
130356
|
+
const leftGridMs = this._cadenceRunMs ?? this._cadenceGridMs;
|
|
130357
|
+
const leftLoopMs = this._cadenceLoopMs;
|
|
130358
|
+
const lastLeftSlotMs = leftGridMs != null && leftLoopMs != null && expectedFireAtMs > leftGridMs ? leftGridMs + (Math.ceil((expectedFireAtMs - leftGridMs) / leftLoopMs) - 1) * leftLoopMs : expectedFireAtMs - loopMs;
|
|
130359
|
+
const missedMs = Math.max(expectedFireAtMs - loopMs, lastLeftSlotMs);
|
|
130360
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, missedMs);
|
|
130361
|
+
if (leftLoopMs != null && leftLoopMs !== loopMs) {
|
|
130362
|
+
this._lastLoopChangedAtMs = Math.max(this._lastLoopChangedAtMs ?? 0, missedMs);
|
|
130363
|
+
}
|
|
130364
|
+
}
|
|
130365
|
+
if (continuesCadence) {
|
|
130366
|
+
this._cadencePendingMs = gridPointMs;
|
|
130367
|
+
} else {
|
|
130368
|
+
this._cadenceGridMs = expectedFireAtMs;
|
|
130369
|
+
this._cadenceLoopMs = loopMs;
|
|
130370
|
+
this._cadenceRunMs = null;
|
|
130371
|
+
this._cadencePendingMs = expectedFireAtMs;
|
|
130372
|
+
}
|
|
130373
|
+
}
|
|
130374
|
+
this._noteTradingRuntime();
|
|
130239
130375
|
const quietAgentPollTimer = timerReason === "agent_instruction_poll" || timerReason === "ai_schedule_paused";
|
|
130240
130376
|
if (!quietAgentPollTimer) this._emitLoopBoundaryTelemetry("client_timer_armed", `reason=${options?.reason || "scheduled"} delay_ms=${delayMs}`, {
|
|
130241
130377
|
reason: timerReason,
|
|
@@ -130289,6 +130425,10 @@ var init_engine = __esm({
|
|
|
130289
130425
|
});
|
|
130290
130426
|
return;
|
|
130291
130427
|
}
|
|
130428
|
+
if (actualFireAtMs - expectedFireAtMs > hyperliquidDemandWindowMs()) {
|
|
130429
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, actualFireAtMs);
|
|
130430
|
+
this._noteTradingRuntime();
|
|
130431
|
+
}
|
|
130292
130432
|
if (this._periodicSchedule && !hasDelayOverride && !options?.suppressNextRunProjection) {
|
|
130293
130433
|
const slot = this._periodicNextSlot(actualFireAtMs, true);
|
|
130294
130434
|
if (slot == null || slot > actualFireAtMs) {
|
|
@@ -130307,6 +130447,7 @@ var init_engine = __esm({
|
|
|
130307
130447
|
...timerPayload
|
|
130308
130448
|
});
|
|
130309
130449
|
}
|
|
130450
|
+
this._cycleStartedByTimer = true;
|
|
130310
130451
|
void this._runExecutionLoop();
|
|
130311
130452
|
}, delayMs);
|
|
130312
130453
|
}
|
|
@@ -130459,6 +130600,17 @@ var init_engine = __esm({
|
|
|
130459
130600
|
}
|
|
130460
130601
|
const startController = new AbortController();
|
|
130461
130602
|
this._startAbortController = startController;
|
|
130603
|
+
void noteHyperliquidUnscheduledTradingRead(this._tradingRuntimeKey(profileId)).catch(() => void 0);
|
|
130604
|
+
this._startedAtMs = Date.now();
|
|
130605
|
+
this._firstCycleEndedAtMs = null;
|
|
130606
|
+
this._agentDrivenCycles = false;
|
|
130607
|
+
this._lastOffCadenceAtMs = null;
|
|
130608
|
+
this._lastLoopChangedAtMs = null;
|
|
130609
|
+
this._noNextRun = false;
|
|
130610
|
+
this._cadenceGridMs = null;
|
|
130611
|
+
this._cadenceLoopMs = null;
|
|
130612
|
+
this._cadenceRunMs = null;
|
|
130613
|
+
this._cadencePendingMs = null;
|
|
130462
130614
|
const attachTask = this._attachInternal(profileId, grant, options, startController);
|
|
130463
130615
|
this._startPromise = attachTask;
|
|
130464
130616
|
try {
|
|
@@ -130467,6 +130619,9 @@ var init_engine = __esm({
|
|
|
130467
130619
|
if (!startController.signal.aborted && this._lifecycleGeneration === lifecycleGenerationAtRequest && getSanitizedRuntimeErrorMessage(error48) !== AI_RUNTIME_START_CANCELLED_MESSAGE) {
|
|
130468
130620
|
this.noteStartupFailure(profileId, grantedMode, error48);
|
|
130469
130621
|
}
|
|
130622
|
+
if (this._profileId !== profileId || this._state !== "running") {
|
|
130623
|
+
void noteHyperliquidTradingRuntime(this._tradingRuntimeKey(profileId), null).catch(() => void 0);
|
|
130624
|
+
}
|
|
130470
130625
|
throw error48;
|
|
130471
130626
|
} finally {
|
|
130472
130627
|
if (this._startPromise === attachTask) {
|
|
@@ -131753,6 +131908,21 @@ var init_engine = __esm({
|
|
|
131753
131908
|
this._analysisRequestId = requestId;
|
|
131754
131909
|
this._analysisStartedAtMs = Number.isFinite(runStartedAtMs) ? runStartedAtMs : Date.now();
|
|
131755
131910
|
this._lastAnalysisStartedAtMs = this._analysisStartedAtMs;
|
|
131911
|
+
const startedByTimer = this._cycleStartedByTimer;
|
|
131912
|
+
this._cycleStartedByTimer = false;
|
|
131913
|
+
this._noteTradingRuntime();
|
|
131914
|
+
const pendingMs = this._cadencePendingMs;
|
|
131915
|
+
const cadenceLoopMs = this._cadenceLoopMs;
|
|
131916
|
+
if (startedByTimer && pendingMs != null && cadenceLoopMs != null) {
|
|
131917
|
+
const startedAtMs = this._analysisStartedAtMs;
|
|
131918
|
+
if (onCadenceGridPoint(startedAtMs, pendingMs, cadenceLoopMs, hyperliquidDemandWindowMs())) {
|
|
131919
|
+
this._cadenceRunMs = pendingMs;
|
|
131920
|
+
} else {
|
|
131921
|
+
const missedMs = startedAtMs > pendingMs ? pendingMs + (Math.ceil((startedAtMs - pendingMs) / cadenceLoopMs) - 1) * cadenceLoopMs : startedAtMs;
|
|
131922
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, missedMs);
|
|
131923
|
+
this._noteTradingRuntime();
|
|
131924
|
+
}
|
|
131925
|
+
}
|
|
131756
131926
|
this._analysisAbortReason = null;
|
|
131757
131927
|
const analysisAbortController = new AbortController();
|
|
131758
131928
|
this._analysisAbortController = analysisAbortController;
|
|
@@ -131776,6 +131946,7 @@ var init_engine = __esm({
|
|
|
131776
131946
|
let executedExchangeOrderInCycle = false;
|
|
131777
131947
|
let pendingExternalInferenceBindings = [];
|
|
131778
131948
|
let agentPollDelayMs = null;
|
|
131949
|
+
let cycleAgentDriven = null;
|
|
131779
131950
|
let aiSchedulePauseMs = null;
|
|
131780
131951
|
let aiSchedulePauseHasNext = false;
|
|
131781
131952
|
let providerRetryDelayMs = null;
|
|
@@ -132059,6 +132230,7 @@ var init_engine = __esm({
|
|
|
132059
132230
|
cycleOutcome = "skipped";
|
|
132060
132231
|
cycleReason = "agent_instruction_poll_empty";
|
|
132061
132232
|
agentPollDelayMs = error48.retryAfterMs;
|
|
132233
|
+
cycleAgentDriven = true;
|
|
132062
132234
|
this._lastRunAt = previousLastRunAt;
|
|
132063
132235
|
this._nextRunAtMs = previousNextRunAtMs;
|
|
132064
132236
|
this._lastError = null;
|
|
@@ -132136,6 +132308,7 @@ var init_engine = __esm({
|
|
|
132136
132308
|
modelSource: result.model_source ?? result.provider
|
|
132137
132309
|
};
|
|
132138
132310
|
agentPollDelayMs = result.agentPollRetryAfterMs ?? null;
|
|
132311
|
+
cycleAgentDriven = result.externalAgentInstruction != null;
|
|
132139
132312
|
pendingExternalInferenceBindings = [...result.externalInferenceBindings ?? []];
|
|
132140
132313
|
if (analysisAbortController.signal.aborted || this._isStopping || this._analysisRequestId !== requestId) {
|
|
132141
132314
|
if (!this._isStopping && this._state !== "stopped" && !decisionSubmitted) {
|
|
@@ -133122,6 +133295,8 @@ var init_engine = __esm({
|
|
|
133122
133295
|
const windowEndWake = aiSchedulePauseMs === null && agentPollDelayMs === null && providerRetryWake === null && windowEndsAtMs != null && windowEndsAtMs > Date.now() && (nextWorkAtMs == null || windowEndsAtMs < nextWorkAtMs) ? windowEndsAtMs - Date.now() : null;
|
|
133123
133296
|
this._aiScheduleCheckPending = windowEndWake !== null;
|
|
133124
133297
|
const manualRunWake = this._manualRunRequested ? 0 : null;
|
|
133298
|
+
this._firstCycleEndedAtMs ??= Date.now();
|
|
133299
|
+
if (cycleAgentDriven !== null) this._agentDrivenCycles = cycleAgentDriven;
|
|
133125
133300
|
this._armExecutionLoopTimer({
|
|
133126
133301
|
alignToNextRun: agentPollDelayMs === null,
|
|
133127
133302
|
delayOverrideMs: manualRunWake ?? aiSchedulePauseMs ?? agentPollDelayMs ?? providerRetryWake ?? windowEndWake,
|
|
@@ -134368,9 +134543,33 @@ var init_engine = __esm({
|
|
|
134368
134543
|
return null;
|
|
134369
134544
|
}
|
|
134370
134545
|
}
|
|
134546
|
+
// One entry per engine instance: a tab that hands a profile over never removes the new owner's.
|
|
134547
|
+
_tradingRuntimeKey(profileId) {
|
|
134548
|
+
return `${profileId}:${this._instanceId}`;
|
|
134549
|
+
}
|
|
134550
|
+
/**
|
|
134551
|
+
* What the device's read admission counts on (hyperliquid-public-read.ts
|
|
134552
|
+
* heldDemand): this runtime's schedule once its first cycle shows it follows
|
|
134553
|
+
* its loop; until then, while Agent instructions drive its cycles, and while
|
|
134554
|
+
* it has no next run, an unscheduled reader.
|
|
134555
|
+
*/
|
|
134556
|
+
_noteTradingRuntime() {
|
|
134557
|
+
if (!this._profileId) return;
|
|
134558
|
+
const key = this._tradingRuntimeKey(this._profileId);
|
|
134559
|
+
const noted = this._loopIntervalMs != null && this._startedAtMs != null && this._analysisStaleAfterMs != null && this._firstCycleEndedAtMs != null && !this._agentDrivenCycles && !this._noNextRun ? noteHyperliquidTradingRuntime(key, {
|
|
134560
|
+
loopMs: this._loopIntervalMs,
|
|
134561
|
+
cycleMs: this._analysisStaleAfterMs,
|
|
134562
|
+
startedAt: this._startedAtMs,
|
|
134563
|
+
firstCycleEndedAt: this._firstCycleEndedAtMs,
|
|
134564
|
+
offCadenceAt: this._lastOffCadenceAtMs,
|
|
134565
|
+
loopChangedAt: this._lastLoopChangedAtMs
|
|
134566
|
+
}) : noteHyperliquidUnscheduledTradingRead(key);
|
|
134567
|
+
void noted.catch(() => void 0);
|
|
134568
|
+
}
|
|
134371
134569
|
_resetRuntimeState(options) {
|
|
134372
134570
|
this._clearExecutionLoopTimer();
|
|
134373
134571
|
this._clearClientKillswitchMonitor();
|
|
134572
|
+
if (this._profileId) void noteHyperliquidTradingRuntime(this._tradingRuntimeKey(this._profileId), null).catch(() => void 0);
|
|
134374
134573
|
this._profileId = null;
|
|
134375
134574
|
this._sessionId = null;
|
|
134376
134575
|
this._deviceSecrets = null;
|