@vtxmacro/cli 2026.10.38 → 2026.10.40
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 +363 -27
- 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.40", 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.40", 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.40", 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
|
|
|
@@ -36034,7 +36034,7 @@ function createDefaultInferenceHostRunnerDependencies(options) {
|
|
|
36034
36034
|
envelopePublicKey: options.envelopePublicKey
|
|
36035
36035
|
};
|
|
36036
36036
|
}
|
|
36037
|
-
var import_ajv, providerHttpStatus, terminalFailureRequiresManualRecovery, canReplayFencedAgentTerminal, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, HOST_RUNTIME_POLICY2, CLAIM_DISPATCH_BATCH_SIZE, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_AUTH_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, usableProviderQuotaSnapshot, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
|
|
36037
|
+
var import_ajv, providerHttpStatus, terminalFailureRequiresManualRecovery, canReplayFencedAgentTerminal, fencedTurnAwaitsAssignmentCheck, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, HOST_RUNTIME_POLICY2, CLAIM_DISPATCH_BATCH_SIZE, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, MIN_HOST_HEARTBEAT_GAP_DIAGNOSTIC_MS, HOST_HEARTBEAT_GAP_DIAGNOSTIC_FACTOR, DEFAULT_QUOTA_COOLDOWN_MS, DEFAULT_AGENT_AUTH_COOLDOWN_MS, DEFAULT_AGENT_RATE_LIMIT_COOLDOWN_MS, DEFAULT_AGENT_TRANSIENT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, settlesWithin, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, usableProviderQuotaSnapshot, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, serverProviderDispatchNotAfterMs, membershipFailureDisposition, safeFailureCode, publicServerFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, isDefinitiveCompletionEvidenceExpiry, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner, createInferenceAgentControlClient, INFERENCE_AGENT_WAKE_SCHEMA, parseInferenceAgentWake, InferenceAgentRuntime;
|
|
36038
36038
|
var init_runner = __esm({
|
|
36039
36039
|
"lib/inference-host/runner.ts"() {
|
|
36040
36040
|
"use strict";
|
|
@@ -36061,6 +36061,7 @@ var init_runner = __esm({
|
|
|
36061
36061
|
};
|
|
36062
36062
|
terminalFailureRequiresManualRecovery = (error48) => (error48.terminalEvidence !== null || error48.grokToolValidation != null || error48.grokResponseIdentity != null) && !error48.retryable && error48.category !== "auth" && !["quota_exceeded", "codex_rate_limited", "provider_rate_limited"].includes(error48.code);
|
|
36063
36063
|
canReplayFencedAgentTerminal = (state2, fence) => state2?.schema_version === "vtx_inference_agent_runtime_v3" && state2.adapter_id === fence.adapter_id && state2.host_id === fence.host_id && state2.assignment.assignment_id === fence.assignment_id && state2.pending_turn?.terminal_receipt?.terminal_status === "failed" && state2.pending_turn.terminal_receipt.failure_code === fence.failure_code && (fence.dispatch_outcome !== "outcome_unknown" || (state2.pending_turn.terminal_receipt.grok_tool_validation?.prior_dispatch === true || state2.pending_turn.terminal_receipt.grok_response_identity != null || state2.pending_turn.terminal_receipt.provider_http_status !== void 0) && state2.pending_turn.terminal_receipt.dispatch_outcome === "outcome_unknown");
|
|
36064
|
+
fencedTurnAwaitsAssignmentCheck = (state2, fence) => fence.failure_code === "agent_turn_outcome_unknown" && state2?.schema_version === "vtx_inference_agent_runtime_v3" && state2.adapter_id === fence.adapter_id && state2.host_id === fence.host_id && state2.assignment.assignment_id === fence.assignment_id && state2.pending_turn != null && !state2.pending_turn.terminal_receipt;
|
|
36064
36065
|
RUNTIME_RECEIPT_SCHEMA_VERSION = "vtx_inference_host_runtime_v1";
|
|
36065
36066
|
ATTEMPT_RECEIPT_SCHEMA_VERSION = "vtx_inference_attempt_receipt_v1";
|
|
36066
36067
|
HOST_RUNTIME_POLICY2 = runtime_policy_generated_default.external_inference.host_runtime;
|
|
@@ -36995,7 +36996,7 @@ var init_runner = __esm({
|
|
|
36995
36996
|
}
|
|
36996
36997
|
if (existingFence.retry_at === null) {
|
|
36997
36998
|
const recoveryState = await readInferenceAgentRuntimeState(agentRuntimeSettings.statePath);
|
|
36998
|
-
if (!canReplayFencedAgentTerminal(recoveryState, existingFence)) {
|
|
36999
|
+
if (!canReplayFencedAgentTerminal(recoveryState, existingFence) && !fencedTurnAwaitsAssignmentCheck(recoveryState, existingFence)) {
|
|
36999
37000
|
emitDiagnostic("agent_runtime_quarantined", {
|
|
37000
37001
|
assignment_id: existingFence.assignment_id,
|
|
37001
37002
|
failure_category: existingFence.failure_category,
|
|
@@ -39701,7 +39702,7 @@ var init_runner = __esm({
|
|
|
39701
39702
|
"Inference Agent failure fence belongs to another host or adapter."
|
|
39702
39703
|
);
|
|
39703
39704
|
}
|
|
39704
|
-
if (!canReplayFencedAgentTerminal(recoveredState, failureFence)) {
|
|
39705
|
+
if (!canReplayFencedAgentTerminal(recoveredState, failureFence) && !fencedTurnAwaitsAssignmentCheck(recoveredState, failureFence)) {
|
|
39705
39706
|
throw new InferenceHostRunnerError(
|
|
39706
39707
|
"agent_terminal_failure_fenced",
|
|
39707
39708
|
"The nonretryable Agent failure requires recovery before another model invocation."
|
|
@@ -39782,6 +39783,17 @@ var init_runner = __esm({
|
|
|
39782
39783
|
state2 = await this.resolvePendingDecision(state2, signal);
|
|
39783
39784
|
if (state2.pending_turn) {
|
|
39784
39785
|
if (!state2.pending_turn.terminal_receipt) {
|
|
39786
|
+
const liveness = await this.options.controlClient.heartbeat({
|
|
39787
|
+
operation_id: randomUUID2(),
|
|
39788
|
+
host_id: this.options.hostId,
|
|
39789
|
+
assignment_id: state2.assignment.assignment_id,
|
|
39790
|
+
assignment_generation: state2.assignment.assignment_generation,
|
|
39791
|
+
requested_at: nowIso()
|
|
39792
|
+
}, { signal });
|
|
39793
|
+
if (liveness.directive === "cancel") {
|
|
39794
|
+
await this.settleCancelledTurn(state2, signal);
|
|
39795
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY2.agent_idle_poll_ms);
|
|
39796
|
+
}
|
|
39785
39797
|
throw new InferenceHostRunnerError(
|
|
39786
39798
|
"agent_turn_outcome_unknown",
|
|
39787
39799
|
"The interrupted Agent turn has no terminal receipt; model redispatch is fenced."
|
|
@@ -39805,6 +39817,10 @@ var init_runner = __esm({
|
|
|
39805
39817
|
if (terminal.terminal_receipt.terminal_status === "failed") {
|
|
39806
39818
|
state2 = { ...state2, pending_turn: null, updated_at: nowIso() };
|
|
39807
39819
|
await writeInferenceAgentRuntimeState(this.options.statePath, state2);
|
|
39820
|
+
if (acknowledged.directive === "cancel" && failureFence === null) {
|
|
39821
|
+
await this.handleCancelledAssignment(state2, signal);
|
|
39822
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY2.agent_idle_poll_ms);
|
|
39823
|
+
}
|
|
39808
39824
|
if (terminal.terminal_receipt.dispatch_outcome === "outcome_unknown" || terminal.terminal_receipt.provider_http_status !== void 0 && failureFence?.retry_at === null) {
|
|
39809
39825
|
throw new InferenceHostRunnerError(
|
|
39810
39826
|
"agent_terminal_failure_fenced",
|
|
@@ -40140,6 +40156,7 @@ var init_runner = __esm({
|
|
|
40140
40156
|
const httpStatus = providerHttpStatus(error48);
|
|
40141
40157
|
const sendHttpStatus = httpStatus !== null && await this.options.controlClient.supportsProviderHttpStatusDiagnostics?.({}) === true;
|
|
40142
40158
|
const hasDiagnostic = diagnostic != null || identityDiagnostic != null;
|
|
40159
|
+
const harnessDiagnostic = error48 instanceof CodexAppServerError && (error48.grokToolValidation != null || error48.grokResponseIdentity != null);
|
|
40143
40160
|
const hasFailureEvidence = hasDiagnostic || sendHttpStatus;
|
|
40144
40161
|
if (error48 instanceof CodexAppServerError && error48.dispatchOutcome === "not_dispatched" && error48.terminalEvidence === null && !hasFailureEvidence) {
|
|
40145
40162
|
state2 = { ...state2, pending_turn: null, updated_at: nowIso() };
|
|
@@ -40181,7 +40198,7 @@ var init_runner = __esm({
|
|
|
40181
40198
|
} : {}
|
|
40182
40199
|
}
|
|
40183
40200
|
}, updated_at: nowIso() };
|
|
40184
|
-
if (terminalFailureRequiresManualRecovery(error48) || sendHttpStatus && (error48.dispatchOutcome === "outcome_unknown" || error48.dispatchOutcome === "confirmed_dispatched" && error48.terminalEvidence === null && !["provider_rate_limited", "codex_rate_limited", "quota_exceeded"].includes(error48.code))) {
|
|
40201
|
+
if (!(cancelled && error48.category === "cancelled" && !harnessDiagnostic) && (terminalFailureRequiresManualRecovery(error48) || sendHttpStatus && (error48.dispatchOutcome === "outcome_unknown" || error48.dispatchOutcome === "confirmed_dispatched" && error48.terminalEvidence === null && !["provider_rate_limited", "codex_rate_limited", "quota_exceeded"].includes(error48.code)))) {
|
|
40185
40202
|
await writeInferenceAgentFailureFence(this.options.statePath, {
|
|
40186
40203
|
schema_version: "vtx_inference_agent_failure_fence_v1",
|
|
40187
40204
|
adapter_id: this.options.adapterId,
|
|
@@ -40212,6 +40229,11 @@ var init_runner = __esm({
|
|
|
40212
40229
|
}
|
|
40213
40230
|
}
|
|
40214
40231
|
if (!cancelled) throw error48;
|
|
40232
|
+
if (state2.pending_turn && !state2.pending_turn.terminal_receipt) {
|
|
40233
|
+
if (harnessDiagnostic) throw error48;
|
|
40234
|
+
await this.settleCancelledTurn(state2);
|
|
40235
|
+
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY2.agent_idle_poll_ms);
|
|
40236
|
+
}
|
|
40215
40237
|
await this.handleCancelledAssignment(state2);
|
|
40216
40238
|
return this.now() + (this.options.idlePollMs ?? HOST_RUNTIME_POLICY2.agent_idle_poll_ms);
|
|
40217
40239
|
} finally {
|
|
@@ -40281,6 +40303,63 @@ var init_runner = __esm({
|
|
|
40281
40303
|
await writeInferenceAgentRuntimeState(this.options.statePath, resolved);
|
|
40282
40304
|
return resolved;
|
|
40283
40305
|
}
|
|
40306
|
+
/**
|
|
40307
|
+
* The server revoked this assignment (the owner stopped the bot), so its
|
|
40308
|
+
* interrupted turn can never run again and late decisions are refused. The
|
|
40309
|
+
* turn is recorded as cancelled and the assignment discarded, instead of
|
|
40310
|
+
* fencing every later assignment on this host.
|
|
40311
|
+
*/
|
|
40312
|
+
async settleCancelledTurn(state2, signal) {
|
|
40313
|
+
const nowIso = () => new Date(this.now()).toISOString();
|
|
40314
|
+
const pending3 = state2.pending_turn;
|
|
40315
|
+
const fence = await readInferenceAgentFailureFence(this.options.statePath);
|
|
40316
|
+
if (fence?.failure_code === "agent_turn_outcome_unknown" && fence.assignment_id === state2.assignment.assignment_id) {
|
|
40317
|
+
await clearInferenceAgentFailureFence(this.options.statePath);
|
|
40318
|
+
}
|
|
40319
|
+
const receipt = {
|
|
40320
|
+
terminal_status: "failed",
|
|
40321
|
+
failure_code: "cancelled",
|
|
40322
|
+
turn_id: pending3.turn_id,
|
|
40323
|
+
agent_run_id: state2.thread?.threadId ?? pending3.turn_id,
|
|
40324
|
+
requested_model: state2.assignment.model_id,
|
|
40325
|
+
effective_model: null,
|
|
40326
|
+
requested_reasoning_effort: state2.assignment.reasoning_effort,
|
|
40327
|
+
effective_reasoning_effort: null,
|
|
40328
|
+
started_at: pending3.started_at,
|
|
40329
|
+
completed_at: nowIso(),
|
|
40330
|
+
adapter_request_id: null,
|
|
40331
|
+
adapter_response_id: null,
|
|
40332
|
+
usage: {
|
|
40333
|
+
schema_version: EXTERNAL_INFERENCE_USAGE_SCHEMA_VERSION,
|
|
40334
|
+
availability: "unavailable",
|
|
40335
|
+
reason_code: "terminal_usage_unavailable"
|
|
40336
|
+
},
|
|
40337
|
+
decision_operation_ids: [...pending3.decision_operation_ids]
|
|
40338
|
+
};
|
|
40339
|
+
let current = {
|
|
40340
|
+
...state2,
|
|
40341
|
+
pending_turn: { ...pending3, terminal_receipt: receipt },
|
|
40342
|
+
updated_at: nowIso()
|
|
40343
|
+
};
|
|
40344
|
+
await writeInferenceAgentRuntimeState(this.options.statePath, current);
|
|
40345
|
+
const acknowledged = await this.options.controlClient.heartbeat({
|
|
40346
|
+
operation_id: pending3.turn_id,
|
|
40347
|
+
host_id: this.options.hostId,
|
|
40348
|
+
assignment_id: state2.assignment.assignment_id,
|
|
40349
|
+
assignment_generation: state2.assignment.assignment_generation,
|
|
40350
|
+
requested_at: nowIso(),
|
|
40351
|
+
turn_receipt: receipt
|
|
40352
|
+
}, { signal });
|
|
40353
|
+
if (!acknowledged.turn_receipt_recorded) {
|
|
40354
|
+
throw new InferenceHostRunnerError(
|
|
40355
|
+
"agent_turn_receipt_unacknowledged",
|
|
40356
|
+
"The cancelled Agent turn receipt could not be acknowledged; recovery state is retained."
|
|
40357
|
+
);
|
|
40358
|
+
}
|
|
40359
|
+
current = { ...current, pending_turn: null, updated_at: nowIso() };
|
|
40360
|
+
await writeInferenceAgentRuntimeState(this.options.statePath, current);
|
|
40361
|
+
await this.handleCancelledAssignment(current, signal);
|
|
40362
|
+
}
|
|
40284
40363
|
async handleCancelledAssignment(state2, signal) {
|
|
40285
40364
|
let current = state2;
|
|
40286
40365
|
if (current.pending_decision) {
|
|
@@ -42699,18 +42778,57 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
42699
42778
|
}
|
|
42700
42779
|
});
|
|
42701
42780
|
|
|
42781
|
+
// lib/inference-host/agent-thread-workspace.ts
|
|
42782
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
42783
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
42784
|
+
import { basename as basename2, dirname as dirname6 } from "node:path";
|
|
42785
|
+
var ownedTempThreadWorkspace, removeRecordedTempThreadWorkspace;
|
|
42786
|
+
var init_agent_thread_workspace = __esm({
|
|
42787
|
+
"lib/inference-host/agent-thread-workspace.ts"() {
|
|
42788
|
+
"use strict";
|
|
42789
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
42790
|
+
init_define_VTX_EXO_POLICY();
|
|
42791
|
+
init_define_VTX_GROK_POLICY();
|
|
42792
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
42793
|
+
init_agent_state();
|
|
42794
|
+
init_owned_directory_removal();
|
|
42795
|
+
ownedTempThreadWorkspace = async (threadPath, prefix) => {
|
|
42796
|
+
const resolved = await realpath5(threadPath);
|
|
42797
|
+
const temporaryRoot = await realpath5(tmpdir3());
|
|
42798
|
+
return dirname6(resolved) === temporaryRoot && basename2(resolved).startsWith(prefix) ? resolved : null;
|
|
42799
|
+
};
|
|
42800
|
+
removeRecordedTempThreadWorkspace = async (statePath, prefix) => {
|
|
42801
|
+
let threadPath;
|
|
42802
|
+
try {
|
|
42803
|
+
threadPath = (await readInferenceAgentRuntimeState(statePath))?.thread?.threadPath;
|
|
42804
|
+
} catch {
|
|
42805
|
+
return;
|
|
42806
|
+
}
|
|
42807
|
+
if (!threadPath) return;
|
|
42808
|
+
let owned;
|
|
42809
|
+
try {
|
|
42810
|
+
owned = await ownedTempThreadWorkspace(threadPath, prefix);
|
|
42811
|
+
} catch (error48) {
|
|
42812
|
+
if (error48.code === "ENOENT") return;
|
|
42813
|
+
throw error48;
|
|
42814
|
+
}
|
|
42815
|
+
if (owned) await removeOwnedDirectory(owned);
|
|
42816
|
+
};
|
|
42817
|
+
}
|
|
42818
|
+
});
|
|
42819
|
+
|
|
42702
42820
|
// lib/inference-host/copilot-adapter.ts
|
|
42703
42821
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
42704
42822
|
import { mkdtemp as mkdtemp2 } from "node:fs/promises";
|
|
42705
42823
|
import { createRequire as createRequire2 } from "node:module";
|
|
42706
|
-
import { tmpdir as
|
|
42824
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
42707
42825
|
import { join as join7 } from "node:path";
|
|
42708
42826
|
import {
|
|
42709
42827
|
CopilotClient,
|
|
42710
42828
|
RuntimeConnection,
|
|
42711
42829
|
defineTool
|
|
42712
42830
|
} from "@github/copilot-sdk";
|
|
42713
|
-
var COPILOT_SDK_VERSION, MAX_RESULT_BYTES, resolveRuntimePackage, copilotRuntimePackageCandidates, resolvePinnedCopilotCliPath, createPrivateWorkspace, cleanCopilotEnvironment, defaultClient, modelCapabilities, requiredUsageInteger, optionalUsageInteger, responseModelLabel, coherentResponseModel, copilotAgentToolDefinitions, CopilotSubscriptionAdapter;
|
|
42831
|
+
var COPILOT_SDK_VERSION, MAX_RESULT_BYTES, resolveRuntimePackage, copilotRuntimePackageCandidates, resolvePinnedCopilotCliPath, WORKSPACE_PREFIX, createPrivateWorkspace, cleanCopilotEnvironment, cleanupCopilotOwnedState, defaultClient, modelCapabilities, requiredUsageInteger, optionalUsageInteger, responseModelLabel, coherentResponseModel, copilotAgentToolDefinitions, CopilotSubscriptionAdapter;
|
|
42714
42832
|
var init_copilot_adapter = __esm({
|
|
42715
42833
|
"lib/inference-host/copilot-adapter.ts"() {
|
|
42716
42834
|
"use strict";
|
|
@@ -42719,6 +42837,7 @@ var init_copilot_adapter = __esm({
|
|
|
42719
42837
|
init_define_VTX_GROK_POLICY();
|
|
42720
42838
|
init_define_VTX_PI_MODEL_POLICY();
|
|
42721
42839
|
init_codex_app_server();
|
|
42840
|
+
init_agent_thread_workspace();
|
|
42722
42841
|
init_owned_directory_removal();
|
|
42723
42842
|
init_constants();
|
|
42724
42843
|
COPILOT_SDK_VERSION = "1.0.0-beta.8";
|
|
@@ -42747,8 +42866,9 @@ var init_copilot_adapter = __esm({
|
|
|
42747
42866
|
}
|
|
42748
42867
|
throw new Error(`copilot_runtime_package_missing:${failures.join(";")}`);
|
|
42749
42868
|
};
|
|
42869
|
+
WORKSPACE_PREFIX = "vtx-copilot-";
|
|
42750
42870
|
createPrivateWorkspace = async (removal = {}) => {
|
|
42751
|
-
const path = await mkdtemp2(join7(
|
|
42871
|
+
const path = await mkdtemp2(join7(tmpdir4(), WORKSPACE_PREFIX));
|
|
42752
42872
|
return {
|
|
42753
42873
|
path,
|
|
42754
42874
|
// client.stop() has already awaited the runtime's exit; retries cover the
|
|
@@ -42774,6 +42894,9 @@ var init_copilot_adapter = __esm({
|
|
|
42774
42894
|
]) delete environment[name];
|
|
42775
42895
|
return environment;
|
|
42776
42896
|
};
|
|
42897
|
+
cleanupCopilotOwnedState = async (statePath) => {
|
|
42898
|
+
await removeRecordedTempThreadWorkspace(statePath, WORKSPACE_PREFIX);
|
|
42899
|
+
};
|
|
42777
42900
|
defaultClient = (workingDirectory) => new CopilotClient({
|
|
42778
42901
|
connection: RuntimeConnection.forStdio({ path: resolvePinnedCopilotCliPath() }),
|
|
42779
42902
|
workingDirectory,
|
|
@@ -43342,7 +43465,15 @@ ${JSON.stringify(input.outputSchema)}`
|
|
|
43342
43465
|
if (cleanup) {
|
|
43343
43466
|
await cleanup();
|
|
43344
43467
|
this.agentWorkspaceCleanups.delete(thread.threadPath);
|
|
43468
|
+
return;
|
|
43345
43469
|
}
|
|
43470
|
+
let owned = null;
|
|
43471
|
+
try {
|
|
43472
|
+
owned = await ownedTempThreadWorkspace(thread.threadPath, WORKSPACE_PREFIX);
|
|
43473
|
+
} catch (error48) {
|
|
43474
|
+
if (error48.code !== "ENOENT") throw error48;
|
|
43475
|
+
}
|
|
43476
|
+
if (owned) await removeOwnedDirectory(owned);
|
|
43346
43477
|
}
|
|
43347
43478
|
async close() {
|
|
43348
43479
|
this.closing = true;
|
|
@@ -43591,9 +43722,9 @@ var init_deepseek_transport_proxy = __esm({
|
|
|
43591
43722
|
|
|
43592
43723
|
// lib/inference-host/deepseek-harness-adapter.ts
|
|
43593
43724
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
43594
|
-
import { mkdtemp as mkdtemp3,
|
|
43595
|
-
import { tmpdir as
|
|
43596
|
-
import {
|
|
43725
|
+
import { mkdtemp as mkdtemp3, rm as rm7 } from "node:fs/promises";
|
|
43726
|
+
import { tmpdir as tmpdir5 } from "node:os";
|
|
43727
|
+
import { join as join8 } from "node:path";
|
|
43597
43728
|
import { Context } from "@deepseek-ai/cordis";
|
|
43598
43729
|
import * as AgentSpine from "@deepseek-ai/dsh-agent-spine-demo";
|
|
43599
43730
|
import {
|
|
@@ -43608,7 +43739,7 @@ import * as LlmDeepSeek from "@deepseek-ai/dsh-llm-deepseek";
|
|
|
43608
43739
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
43609
43740
|
import * as SessionCheckpointPolicy from "@deepseek-ai/dsh-session-checkpoint-policy";
|
|
43610
43741
|
import { JsonlSessionPersistence } from "@deepseek-ai/dsh-session-persistence-jsonl";
|
|
43611
|
-
var DEEPSEEK_HARNESS_VERSION, MAX_RESULT_BYTES2, DEEPSEEK_MODELS, DEEPSEEK_API_BASE_URL, isSupportedNodeVersion, effortForHarness, supportedEfforts, toVtxUsage, sumUsage, textFromBlocks, validateText, createDeadlineBoundary, nonDispatchedError, proxyDispatchOutcome, mapDeepSeekFailure, createPrivateWorkspace2, directAdapter, normalizeJsonValue, DeepSeekHarnessAdapter;
|
|
43742
|
+
var DEEPSEEK_HARNESS_VERSION, MAX_RESULT_BYTES2, DEEPSEEK_MODELS, DEEPSEEK_API_BASE_URL, isSupportedNodeVersion, effortForHarness, supportedEfforts, toVtxUsage, sumUsage, textFromBlocks, validateText, createDeadlineBoundary, nonDispatchedError, proxyDispatchOutcome, mapDeepSeekFailure, WORKSPACE_PREFIX2, createPrivateWorkspace2, cleanupDeepSeekOwnedState, directAdapter, normalizeJsonValue, DeepSeekHarnessAdapter;
|
|
43612
43743
|
var init_deepseek_harness_adapter = __esm({
|
|
43613
43744
|
"lib/inference-host/deepseek-harness-adapter.ts"() {
|
|
43614
43745
|
"use strict";
|
|
@@ -43619,6 +43750,7 @@ var init_deepseek_harness_adapter = __esm({
|
|
|
43619
43750
|
init_codex_app_server();
|
|
43620
43751
|
init_agent_data_tool();
|
|
43621
43752
|
init_owned_directory_removal();
|
|
43753
|
+
init_agent_thread_workspace();
|
|
43622
43754
|
init_deepseek_transport_proxy();
|
|
43623
43755
|
init_constants();
|
|
43624
43756
|
DEEPSEEK_HARNESS_VERSION = "0.1.1-rc.2";
|
|
@@ -43744,12 +43876,16 @@ var init_deepseek_harness_adapter = __esm({
|
|
|
43744
43876
|
cause: options.error
|
|
43745
43877
|
});
|
|
43746
43878
|
};
|
|
43879
|
+
WORKSPACE_PREFIX2 = "vtx-deepseek-harness-";
|
|
43747
43880
|
createPrivateWorkspace2 = async () => {
|
|
43748
|
-
const path = await mkdtemp3(join8(
|
|
43881
|
+
const path = await mkdtemp3(join8(tmpdir5(), WORKSPACE_PREFIX2));
|
|
43749
43882
|
return { path, cleanup: async () => {
|
|
43750
43883
|
await removeOwnedDirectory(path);
|
|
43751
43884
|
} };
|
|
43752
43885
|
};
|
|
43886
|
+
cleanupDeepSeekOwnedState = async (statePath) => {
|
|
43887
|
+
await removeRecordedTempThreadWorkspace(statePath, WORKSPACE_PREFIX2);
|
|
43888
|
+
};
|
|
43753
43889
|
directAdapter = (proxy, model, effort2) => {
|
|
43754
43890
|
const connection = resolveAdapterOptions({
|
|
43755
43891
|
apiKeyEnv: "VTX_DSH_LOOPBACK_TOKEN",
|
|
@@ -44248,9 +44384,8 @@ ${JSON.stringify(input.outputSchema)}`,
|
|
|
44248
44384
|
this.agentWorkspaces.delete(thread.threadPath);
|
|
44249
44385
|
return;
|
|
44250
44386
|
}
|
|
44251
|
-
const resolved = await
|
|
44252
|
-
|
|
44253
|
-
if (dirname6(resolved) !== temporaryRoot || !basename2(resolved).startsWith("vtx-deepseek-harness-")) throw new Error("deepseek_harness_thread_path_not_owned");
|
|
44387
|
+
const resolved = await ownedTempThreadWorkspace(thread.threadPath, WORKSPACE_PREFIX2);
|
|
44388
|
+
if (!resolved) throw new Error("deepseek_harness_thread_path_not_owned");
|
|
44254
44389
|
await rm7(resolved, { recursive: true, force: true });
|
|
44255
44390
|
}
|
|
44256
44391
|
async close() {
|
|
@@ -51342,6 +51477,8 @@ Durable service:
|
|
|
51342
51477
|
await cleanupExoOwnedState(`${config2.statePath}.exo`);
|
|
51343
51478
|
await cleanupGrokOwnedState({ stateRoot: `${config2.statePath}.grok`, grokHome: `${config2.statePath}.grok-home` });
|
|
51344
51479
|
await cleanupClaudeCodeOwnedState(claudeCodeStateOptions(config2.statePath));
|
|
51480
|
+
await cleanupDeepSeekOwnedState(config2.statePath);
|
|
51481
|
+
await cleanupCopilotOwnedState(config2.statePath);
|
|
51345
51482
|
await clearInferencePrivateFile(
|
|
51346
51483
|
runtimeReceiptPath(config2),
|
|
51347
51484
|
"Inference host runtime receipt file"
|
|
@@ -59519,6 +59656,18 @@ var init_mobile_notifications = __esm({
|
|
|
59519
59656
|
}
|
|
59520
59657
|
});
|
|
59521
59658
|
|
|
59659
|
+
// lib/api/admin-signups.ts
|
|
59660
|
+
var init_admin_signups = __esm({
|
|
59661
|
+
"lib/api/admin-signups.ts"() {
|
|
59662
|
+
"use strict";
|
|
59663
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
59664
|
+
init_define_VTX_EXO_POLICY();
|
|
59665
|
+
init_define_VTX_GROK_POLICY();
|
|
59666
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
59667
|
+
init_shared();
|
|
59668
|
+
}
|
|
59669
|
+
});
|
|
59670
|
+
|
|
59522
59671
|
// lib/runtime/hyperliquid-account-mode-contract.ts
|
|
59523
59672
|
function resolveExactHyperliquidAccountMode(userAbstraction, ...dexEvidence) {
|
|
59524
59673
|
const mode = extractCanonicalHyperliquidAccountMode(userAbstraction);
|
|
@@ -60137,7 +60286,7 @@ var init_hyperliquid_public_capacity = __esm({
|
|
|
60137
60286
|
adaptivePublicCapacity = (input) => {
|
|
60138
60287
|
const { nowMs: nowMs2, policy: policy2 } = input;
|
|
60139
60288
|
const current = publicDemandBucketIndex(nowMs2, policy2.bucketMs);
|
|
60140
|
-
const oldest =
|
|
60289
|
+
const oldest = publicDemandBucketIndex(nowMs2 - policy2.horizonMs, policy2.bucketMs);
|
|
60141
60290
|
const inHorizon = input.buckets.map((bucket) => ({ ...bucket, index: Math.min(bucket.index, current) })).filter((bucket) => bucket.index >= oldest);
|
|
60142
60291
|
const peak = (from, of) => inHorizon.filter((bucket) => bucket.index >= from).reduce((most, bucket) => Math.max(most, of(bucket)), 0);
|
|
60143
60292
|
const peakHigher = peak(oldest, (bucket) => bucket.higherPeak);
|
|
@@ -60165,7 +60314,7 @@ var init_hyperliquid_public_capacity = __esm({
|
|
|
60165
60314
|
});
|
|
60166
60315
|
|
|
60167
60316
|
// lib/runtime/hyperliquid-public-read.ts
|
|
60168
|
-
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;
|
|
60169
60318
|
var init_hyperliquid_public_read = __esm({
|
|
60170
60319
|
"lib/runtime/hyperliquid-public-read.ts"() {
|
|
60171
60320
|
"use strict";
|
|
@@ -60328,6 +60477,81 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60328
60477
|
minWeight: policy.capacity_min_weight,
|
|
60329
60478
|
recoveryPerMinute: policy.capacity_recovery_weight_per_minute
|
|
60330
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));
|
|
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 offCadenceAt = Math.max(0, ...schedules.map((schedule) => schedule.offCadenceAt ?? 0));
|
|
60544
|
+
const startups = schedules.map((schedule) => ({
|
|
60545
|
+
from: schedule.startedAt,
|
|
60546
|
+
to: Math.min(schedule.firstCycleEndedAt ?? now, schedule.startedAt + schedule.loopMs + schedule.cycleMs)
|
|
60547
|
+
}));
|
|
60548
|
+
return buckets.filter((bucket) => {
|
|
60549
|
+
const bucketStart = bucket.index * capacityPolicy.bucketMs;
|
|
60550
|
+
const bucketEnd = bucketStart + capacityPolicy.bucketMs;
|
|
60551
|
+
const startup = startups.some(({ from, to }) => from < bucketEnd && to > bucketStart - capacityPolicy.windowMs);
|
|
60552
|
+
return !startup || now < Math.max(bucketEnd, offCadenceAt) + releaseAfterMs;
|
|
60553
|
+
});
|
|
60554
|
+
};
|
|
60331
60555
|
isHeldBack = (rank) => rank >= priorityRank("ui");
|
|
60332
60556
|
reservationRank = (entry) => entry.rank ?? mostUrgentRank;
|
|
60333
60557
|
classBoundaries = Array.from({ length: lastRank - mostUrgentRank + 1 }, (_unused, offset) => mostUrgentRank + 1 + offset);
|
|
@@ -60346,7 +60570,7 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60346
60570
|
foldDemand = (budget, now) => {
|
|
60347
60571
|
const foldUpTo = now - capacityPolicy.windowMs;
|
|
60348
60572
|
const foldedUpTo = Math.min(budget.folded ?? 0, foldUpTo);
|
|
60349
|
-
const oldest = publicDemandBucketIndex(now
|
|
60573
|
+
const oldest = publicDemandBucketIndex(now - capacityPolicy.horizonMs, capacityPolicy.bucketMs);
|
|
60350
60574
|
const demand = (budget.demand ?? []).filter((entry) => entry[0] >= oldest);
|
|
60351
60575
|
for (const reservation of budget.reservations) {
|
|
60352
60576
|
if (reservation.at <= foldedUpTo || reservation.at > foldUpTo) continue;
|
|
@@ -60379,14 +60603,13 @@ var init_hyperliquid_public_read = __esm({
|
|
|
60379
60603
|
const live = budget.reservations.filter((entry) => entry.at > now - capacityPolicy.windowMs);
|
|
60380
60604
|
const total = live.reduce((sum, entry) => sum + entry.weight, 0);
|
|
60381
60605
|
const rankAndBelow = (fromRank) => live.filter((entry) => reservationRank(entry) >= fromRank).reduce((sum, entry) => sum + entry.weight, 0);
|
|
60606
|
+
const readers = readTradingReaders(now);
|
|
60382
60607
|
const above = (fromRank) => {
|
|
60383
|
-
const
|
|
60384
|
-
|
|
60385
|
-
|
|
60386
|
-
|
|
60387
|
-
|
|
60388
|
-
});
|
|
60389
|
-
return { capacity: Math.min(computed.capacity, policy.max_weight), peakHigher: computed.peakHigher };
|
|
60608
|
+
const buckets = demandFor(budget, fromRank, now);
|
|
60609
|
+
const lastFailureMs = budget.lastFailure ?? 0;
|
|
60610
|
+
const computed = adaptivePublicCapacity({ nowMs: now, lastFailureMs, buckets, policy: capacityPolicy });
|
|
60611
|
+
const held = adaptivePublicCapacity({ nowMs: now, lastFailureMs, buckets: heldDemand(buckets, now, readers), policy: capacityPolicy });
|
|
60612
|
+
return { capacity: Math.min(computed.capacity, policy.max_weight), peakHigher: held.peakHigher };
|
|
60390
60613
|
};
|
|
60391
60614
|
const own = above(rank);
|
|
60392
60615
|
const uiRank = priorityRank("ui");
|
|
@@ -96616,6 +96839,7 @@ var init_api2 = __esm({
|
|
|
96616
96839
|
init_profile_emoji();
|
|
96617
96840
|
init_account_summary();
|
|
96618
96841
|
init_mobile_notifications();
|
|
96842
|
+
init_admin_signups();
|
|
96619
96843
|
init_server_runtime_lease();
|
|
96620
96844
|
clientRuntimeSecretHeaders = (profileId) => {
|
|
96621
96845
|
const headers = getProfileHeaders({}, profileId);
|
|
@@ -110037,6 +110261,7 @@ var init_runtime_execution = __esm({
|
|
|
110037
110261
|
}
|
|
110038
110262
|
const ownGroups = groups.filter((group) => group.pendingEntry != null && group.walletAddress === walletAddress.toLowerCase());
|
|
110039
110263
|
if (ownGroups.length === 0) return [];
|
|
110264
|
+
input.beforeRead?.();
|
|
110040
110265
|
const sizeDecimals = await resolveExchangeSizeDecimals(symbol2, input.config, "trading_reconcile");
|
|
110041
110266
|
const request = {
|
|
110042
110267
|
mutationAuthority: "manual_session",
|
|
@@ -112431,6 +112656,7 @@ var init_server_protection_sweep = __esm({
|
|
|
112431
112656
|
init_runtime_policy_generated2();
|
|
112432
112657
|
init_protective_cutover();
|
|
112433
112658
|
init_protective_evidence();
|
|
112659
|
+
init_hyperliquid_public_read();
|
|
112434
112660
|
sweepServerOwnedProtectionOnce = async (input) => {
|
|
112435
112661
|
const authority = input.authority;
|
|
112436
112662
|
const listed = await listClientProtectiveActions(
|
|
@@ -112459,6 +112685,7 @@ var init_server_protection_sweep = __esm({
|
|
|
112459
112685
|
})) {
|
|
112460
112686
|
return evidenceSweepAt(null);
|
|
112461
112687
|
}
|
|
112688
|
+
void noteHyperliquidUnscheduledTradingRead(`server-owned-protection:${input.profileId}`).catch(() => void 0);
|
|
112462
112689
|
const config2 = await getLLMConfig(void 0, Number(input.profileId), input.signal);
|
|
112463
112690
|
const result = await syncServerOwnedProtection({
|
|
112464
112691
|
profileId: input.profileId,
|
|
@@ -128526,7 +128753,7 @@ ${reviewOutputContract}`;
|
|
|
128526
128753
|
});
|
|
128527
128754
|
|
|
128528
128755
|
// lib/runtime/engine.ts
|
|
128529
|
-
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;
|
|
128756
|
+
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;
|
|
128530
128757
|
var init_engine = __esm({
|
|
128531
128758
|
"lib/runtime/engine.ts"() {
|
|
128532
128759
|
"use strict";
|
|
@@ -128535,6 +128762,7 @@ var init_engine = __esm({
|
|
|
128535
128762
|
init_define_VTX_GROK_POLICY();
|
|
128536
128763
|
init_define_VTX_PI_MODEL_POLICY();
|
|
128537
128764
|
init_protective_cutover();
|
|
128765
|
+
init_hyperliquid_public_read();
|
|
128538
128766
|
init_runtime_policy_generated2();
|
|
128539
128767
|
init_constants();
|
|
128540
128768
|
init_periodic_schedule();
|
|
@@ -129158,6 +129386,10 @@ var init_engine = __esm({
|
|
|
129158
129386
|
requireProviderSecret
|
|
129159
129387
|
};
|
|
129160
129388
|
};
|
|
129389
|
+
onCadenceGridPoint = (atMs, pointMs, loopMs, toleranceMs) => {
|
|
129390
|
+
const offsetMs = Math.abs(atMs - pointMs);
|
|
129391
|
+
return offsetMs <= toleranceMs && offsetMs < Math.abs(atMs - pointMs - loopMs) && offsetMs < Math.abs(atMs - pointMs + loopMs);
|
|
129392
|
+
};
|
|
129161
129393
|
ClientExecutionEngine = class {
|
|
129162
129394
|
constructor() {
|
|
129163
129395
|
this._state = "stopped";
|
|
@@ -129200,6 +129432,20 @@ var init_engine = __esm({
|
|
|
129200
129432
|
this._heartbeatOfflineAfterMs = null;
|
|
129201
129433
|
this._analysisDefaultTimeoutSeconds = null;
|
|
129202
129434
|
this._analysisStaleAfterMs = null;
|
|
129435
|
+
// When this runtime last started (attached a grant), when its first cycle since ended, and
|
|
129436
|
+
// whether its cycles follow Agent instructions (which no loop schedules) rather than its loop.
|
|
129437
|
+
this._startedAtMs = null;
|
|
129438
|
+
this._firstCycleEndedAtMs = null;
|
|
129439
|
+
this._agentDrivenCycles = false;
|
|
129440
|
+
// The latest slot this runtime missed, whether it has no next run, and the
|
|
129441
|
+
// grid its on-cadence runs follow (see _armExecutionLoopTimer).
|
|
129442
|
+
this._lastOffCadenceAtMs = null;
|
|
129443
|
+
this._noNextRun = false;
|
|
129444
|
+
this._cadenceGridMs = null;
|
|
129445
|
+
this._cadenceLoopMs = null;
|
|
129446
|
+
this._cadenceRunMs = null;
|
|
129447
|
+
this._cadencePendingMs = null;
|
|
129448
|
+
this._cycleStartedByTimer = false;
|
|
129203
129449
|
this._settlementRequestTimeoutMs = null;
|
|
129204
129450
|
this._lastSuccessfulHeartbeatAtMs = null;
|
|
129205
129451
|
this._analysisRequestId = null;
|
|
@@ -130077,8 +130323,13 @@ var init_engine = __esm({
|
|
|
130077
130323
|
this._initializeNextRunAnchor();
|
|
130078
130324
|
}
|
|
130079
130325
|
if (this._nextRunAtMs == null && !options?.suppressNextRunProjection && options?.delayOverrideMs == null) {
|
|
130326
|
+
this._noNextRun = true;
|
|
130327
|
+
this._cadenceGridMs = null;
|
|
130328
|
+
this._cadencePendingMs = null;
|
|
130329
|
+
this._noteTradingRuntime();
|
|
130080
130330
|
return;
|
|
130081
130331
|
}
|
|
130332
|
+
this._noNextRun = false;
|
|
130082
130333
|
const rawDelayOverrideMs = options?.delayOverrideMs;
|
|
130083
130334
|
const parsedDelayOverrideMs = Number(rawDelayOverrideMs);
|
|
130084
130335
|
const hasDelayOverride = rawDelayOverrideMs !== null && rawDelayOverrideMs !== void 0 && Number.isFinite(parsedDelayOverrideMs) && parsedDelayOverrideMs >= 0;
|
|
@@ -130086,6 +130337,30 @@ var init_engine = __esm({
|
|
|
130086
130337
|
const timerReason = options?.reason || "scheduled";
|
|
130087
130338
|
const armedAtMs = Date.now();
|
|
130088
130339
|
const expectedFireAtMs = armedAtMs + delayMs;
|
|
130340
|
+
if (this._agentDrivenCycles) {
|
|
130341
|
+
this._cadenceGridMs = null;
|
|
130342
|
+
this._cadencePendingMs = null;
|
|
130343
|
+
} else if (!timerReason.endsWith("_retry")) {
|
|
130344
|
+
const loopMs = this._loopIntervalMs;
|
|
130345
|
+
const toleranceMs = hyperliquidDemandWindowMs();
|
|
130346
|
+
const gridPointMs = this._cadenceGridMs == null ? null : this._cadenceRunMs == null ? this._cadenceGridMs : this._cadenceRunMs + loopMs;
|
|
130347
|
+
const continuesCadence = gridPointMs != null && this._cadenceLoopMs === loopMs && onCadenceGridPoint(expectedFireAtMs, gridPointMs, loopMs, toleranceMs);
|
|
130348
|
+
if (timerReason === "ai_schedule_paused" || !continuesCadence) {
|
|
130349
|
+
const leftGridMs = this._cadenceRunMs ?? this._cadenceGridMs;
|
|
130350
|
+
const leftLoopMs = this._cadenceLoopMs;
|
|
130351
|
+
const lastLeftSlotMs = leftGridMs != null && leftLoopMs != null && expectedFireAtMs > leftGridMs ? leftGridMs + (Math.ceil((expectedFireAtMs - leftGridMs) / leftLoopMs) - 1) * leftLoopMs : expectedFireAtMs - loopMs;
|
|
130352
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, expectedFireAtMs - loopMs, lastLeftSlotMs);
|
|
130353
|
+
}
|
|
130354
|
+
if (continuesCadence) {
|
|
130355
|
+
this._cadencePendingMs = gridPointMs;
|
|
130356
|
+
} else {
|
|
130357
|
+
this._cadenceGridMs = expectedFireAtMs;
|
|
130358
|
+
this._cadenceLoopMs = loopMs;
|
|
130359
|
+
this._cadenceRunMs = null;
|
|
130360
|
+
this._cadencePendingMs = expectedFireAtMs;
|
|
130361
|
+
}
|
|
130362
|
+
}
|
|
130363
|
+
this._noteTradingRuntime();
|
|
130089
130364
|
const quietAgentPollTimer = timerReason === "agent_instruction_poll" || timerReason === "ai_schedule_paused";
|
|
130090
130365
|
if (!quietAgentPollTimer) this._emitLoopBoundaryTelemetry("client_timer_armed", `reason=${options?.reason || "scheduled"} delay_ms=${delayMs}`, {
|
|
130091
130366
|
reason: timerReason,
|
|
@@ -130139,6 +130414,10 @@ var init_engine = __esm({
|
|
|
130139
130414
|
});
|
|
130140
130415
|
return;
|
|
130141
130416
|
}
|
|
130417
|
+
if (actualFireAtMs - expectedFireAtMs > hyperliquidDemandWindowMs()) {
|
|
130418
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, actualFireAtMs);
|
|
130419
|
+
this._noteTradingRuntime();
|
|
130420
|
+
}
|
|
130142
130421
|
if (this._periodicSchedule && !hasDelayOverride && !options?.suppressNextRunProjection) {
|
|
130143
130422
|
const slot = this._periodicNextSlot(actualFireAtMs, true);
|
|
130144
130423
|
if (slot == null || slot > actualFireAtMs) {
|
|
@@ -130157,6 +130436,7 @@ var init_engine = __esm({
|
|
|
130157
130436
|
...timerPayload
|
|
130158
130437
|
});
|
|
130159
130438
|
}
|
|
130439
|
+
this._cycleStartedByTimer = true;
|
|
130160
130440
|
void this._runExecutionLoop();
|
|
130161
130441
|
}, delayMs);
|
|
130162
130442
|
}
|
|
@@ -130309,6 +130589,16 @@ var init_engine = __esm({
|
|
|
130309
130589
|
}
|
|
130310
130590
|
const startController = new AbortController();
|
|
130311
130591
|
this._startAbortController = startController;
|
|
130592
|
+
void noteHyperliquidUnscheduledTradingRead(this._tradingRuntimeKey(profileId)).catch(() => void 0);
|
|
130593
|
+
this._startedAtMs = Date.now();
|
|
130594
|
+
this._firstCycleEndedAtMs = null;
|
|
130595
|
+
this._agentDrivenCycles = false;
|
|
130596
|
+
this._lastOffCadenceAtMs = null;
|
|
130597
|
+
this._noNextRun = false;
|
|
130598
|
+
this._cadenceGridMs = null;
|
|
130599
|
+
this._cadenceLoopMs = null;
|
|
130600
|
+
this._cadenceRunMs = null;
|
|
130601
|
+
this._cadencePendingMs = null;
|
|
130312
130602
|
const attachTask = this._attachInternal(profileId, grant, options, startController);
|
|
130313
130603
|
this._startPromise = attachTask;
|
|
130314
130604
|
try {
|
|
@@ -130317,6 +130607,9 @@ var init_engine = __esm({
|
|
|
130317
130607
|
if (!startController.signal.aborted && this._lifecycleGeneration === lifecycleGenerationAtRequest && getSanitizedRuntimeErrorMessage(error48) !== AI_RUNTIME_START_CANCELLED_MESSAGE) {
|
|
130318
130608
|
this.noteStartupFailure(profileId, grantedMode, error48);
|
|
130319
130609
|
}
|
|
130610
|
+
if (this._profileId !== profileId || this._state !== "running") {
|
|
130611
|
+
void noteHyperliquidTradingRuntime(this._tradingRuntimeKey(profileId), null).catch(() => void 0);
|
|
130612
|
+
}
|
|
130320
130613
|
throw error48;
|
|
130321
130614
|
} finally {
|
|
130322
130615
|
if (this._startPromise === attachTask) {
|
|
@@ -131603,6 +131896,21 @@ var init_engine = __esm({
|
|
|
131603
131896
|
this._analysisRequestId = requestId;
|
|
131604
131897
|
this._analysisStartedAtMs = Number.isFinite(runStartedAtMs) ? runStartedAtMs : Date.now();
|
|
131605
131898
|
this._lastAnalysisStartedAtMs = this._analysisStartedAtMs;
|
|
131899
|
+
const startedByTimer = this._cycleStartedByTimer;
|
|
131900
|
+
this._cycleStartedByTimer = false;
|
|
131901
|
+
this._noteTradingRuntime();
|
|
131902
|
+
const pendingMs = this._cadencePendingMs;
|
|
131903
|
+
const cadenceLoopMs = this._cadenceLoopMs;
|
|
131904
|
+
if (startedByTimer && pendingMs != null && cadenceLoopMs != null) {
|
|
131905
|
+
const startedAtMs = this._analysisStartedAtMs;
|
|
131906
|
+
if (onCadenceGridPoint(startedAtMs, pendingMs, cadenceLoopMs, hyperliquidDemandWindowMs())) {
|
|
131907
|
+
this._cadenceRunMs = pendingMs;
|
|
131908
|
+
} else {
|
|
131909
|
+
const missedMs = startedAtMs > pendingMs ? pendingMs + (Math.ceil((startedAtMs - pendingMs) / cadenceLoopMs) - 1) * cadenceLoopMs : startedAtMs;
|
|
131910
|
+
this._lastOffCadenceAtMs = Math.max(this._lastOffCadenceAtMs ?? 0, missedMs);
|
|
131911
|
+
this._noteTradingRuntime();
|
|
131912
|
+
}
|
|
131913
|
+
}
|
|
131606
131914
|
this._analysisAbortReason = null;
|
|
131607
131915
|
const analysisAbortController = new AbortController();
|
|
131608
131916
|
this._analysisAbortController = analysisAbortController;
|
|
@@ -131626,6 +131934,7 @@ var init_engine = __esm({
|
|
|
131626
131934
|
let executedExchangeOrderInCycle = false;
|
|
131627
131935
|
let pendingExternalInferenceBindings = [];
|
|
131628
131936
|
let agentPollDelayMs = null;
|
|
131937
|
+
let cycleAgentDriven = null;
|
|
131629
131938
|
let aiSchedulePauseMs = null;
|
|
131630
131939
|
let aiSchedulePauseHasNext = false;
|
|
131631
131940
|
let providerRetryDelayMs = null;
|
|
@@ -131909,6 +132218,7 @@ var init_engine = __esm({
|
|
|
131909
132218
|
cycleOutcome = "skipped";
|
|
131910
132219
|
cycleReason = "agent_instruction_poll_empty";
|
|
131911
132220
|
agentPollDelayMs = error48.retryAfterMs;
|
|
132221
|
+
cycleAgentDriven = true;
|
|
131912
132222
|
this._lastRunAt = previousLastRunAt;
|
|
131913
132223
|
this._nextRunAtMs = previousNextRunAtMs;
|
|
131914
132224
|
this._lastError = null;
|
|
@@ -131986,6 +132296,7 @@ var init_engine = __esm({
|
|
|
131986
132296
|
modelSource: result.model_source ?? result.provider
|
|
131987
132297
|
};
|
|
131988
132298
|
agentPollDelayMs = result.agentPollRetryAfterMs ?? null;
|
|
132299
|
+
cycleAgentDriven = result.externalAgentInstruction != null;
|
|
131989
132300
|
pendingExternalInferenceBindings = [...result.externalInferenceBindings ?? []];
|
|
131990
132301
|
if (analysisAbortController.signal.aborted || this._isStopping || this._analysisRequestId !== requestId) {
|
|
131991
132302
|
if (!this._isStopping && this._state !== "stopped" && !decisionSubmitted) {
|
|
@@ -132972,6 +133283,8 @@ var init_engine = __esm({
|
|
|
132972
133283
|
const windowEndWake = aiSchedulePauseMs === null && agentPollDelayMs === null && providerRetryWake === null && windowEndsAtMs != null && windowEndsAtMs > Date.now() && (nextWorkAtMs == null || windowEndsAtMs < nextWorkAtMs) ? windowEndsAtMs - Date.now() : null;
|
|
132973
133284
|
this._aiScheduleCheckPending = windowEndWake !== null;
|
|
132974
133285
|
const manualRunWake = this._manualRunRequested ? 0 : null;
|
|
133286
|
+
this._firstCycleEndedAtMs ??= Date.now();
|
|
133287
|
+
if (cycleAgentDriven !== null) this._agentDrivenCycles = cycleAgentDriven;
|
|
132975
133288
|
this._armExecutionLoopTimer({
|
|
132976
133289
|
alignToNextRun: agentPollDelayMs === null,
|
|
132977
133290
|
delayOverrideMs: manualRunWake ?? aiSchedulePauseMs ?? agentPollDelayMs ?? providerRetryWake ?? windowEndWake,
|
|
@@ -134218,9 +134531,32 @@ var init_engine = __esm({
|
|
|
134218
134531
|
return null;
|
|
134219
134532
|
}
|
|
134220
134533
|
}
|
|
134534
|
+
// One entry per engine instance: a tab that hands a profile over never removes the new owner's.
|
|
134535
|
+
_tradingRuntimeKey(profileId) {
|
|
134536
|
+
return `${profileId}:${this._instanceId}`;
|
|
134537
|
+
}
|
|
134538
|
+
/**
|
|
134539
|
+
* What the device's read admission counts on (hyperliquid-public-read.ts
|
|
134540
|
+
* heldDemand): this runtime's schedule once its first cycle shows it follows
|
|
134541
|
+
* its loop; until then, while Agent instructions drive its cycles, and while
|
|
134542
|
+
* it has no next run, an unscheduled reader.
|
|
134543
|
+
*/
|
|
134544
|
+
_noteTradingRuntime() {
|
|
134545
|
+
if (!this._profileId) return;
|
|
134546
|
+
const key = this._tradingRuntimeKey(this._profileId);
|
|
134547
|
+
const noted = this._loopIntervalMs != null && this._startedAtMs != null && this._analysisStaleAfterMs != null && this._firstCycleEndedAtMs != null && !this._agentDrivenCycles && !this._noNextRun ? noteHyperliquidTradingRuntime(key, {
|
|
134548
|
+
loopMs: this._loopIntervalMs,
|
|
134549
|
+
cycleMs: this._analysisStaleAfterMs,
|
|
134550
|
+
startedAt: this._startedAtMs,
|
|
134551
|
+
firstCycleEndedAt: this._firstCycleEndedAtMs,
|
|
134552
|
+
offCadenceAt: this._lastOffCadenceAtMs
|
|
134553
|
+
}) : noteHyperliquidUnscheduledTradingRead(key);
|
|
134554
|
+
void noted.catch(() => void 0);
|
|
134555
|
+
}
|
|
134221
134556
|
_resetRuntimeState(options) {
|
|
134222
134557
|
this._clearExecutionLoopTimer();
|
|
134223
134558
|
this._clearClientKillswitchMonitor();
|
|
134559
|
+
if (this._profileId) void noteHyperliquidTradingRuntime(this._tradingRuntimeKey(this._profileId), null).catch(() => void 0);
|
|
134224
134560
|
this._profileId = null;
|
|
134225
134561
|
this._sessionId = null;
|
|
134226
134562
|
this._deviceSecrets = null;
|