@vtxmacro/cli 2026.10.19 → 2026.10.20
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/exo-harness.ts +3 -0
- package/bin/vtx-mcp.js +4 -1
- package/bin/vtx-service-bootstrap.js +4 -1
- package/bin/vtx-service-launcher.js +3 -0
- package/bin/vtx.js +208 -108
- package/package.json +1 -1
package/bin/exo-harness.ts
CHANGED
package/bin/vtx-mcp.js
CHANGED
|
@@ -37,7 +37,7 @@ var init_define_VTX_PI_MODEL_POLICY = __esm({
|
|
|
37
37
|
var agent_cli_release_default;
|
|
38
38
|
var init_agent_cli_release = __esm({
|
|
39
39
|
"agent-cli-release.json"() {
|
|
40
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
40
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.20", 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" } } };
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
|
|
@@ -2485,6 +2485,9 @@ var runtime_policy_generated_default = {
|
|
|
2485
2485
|
websocket: {
|
|
2486
2486
|
ping_interval_seconds: 20,
|
|
2487
2487
|
account_open_timeout_seconds: 10
|
|
2488
|
+
},
|
|
2489
|
+
perp_dexs: {
|
|
2490
|
+
default_dex_label: "Hyperliquid"
|
|
2488
2491
|
}
|
|
2489
2492
|
},
|
|
2490
2493
|
cache: {
|
|
@@ -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.20", 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 = {
|
|
@@ -1193,6 +1193,9 @@ var runtime_policy_generated_default = {
|
|
|
1193
1193
|
websocket: {
|
|
1194
1194
|
ping_interval_seconds: 20,
|
|
1195
1195
|
account_open_timeout_seconds: 10
|
|
1196
|
+
},
|
|
1197
|
+
perp_dexs: {
|
|
1198
|
+
default_dex_label: "Hyperliquid"
|
|
1196
1199
|
}
|
|
1197
1200
|
},
|
|
1198
1201
|
cache: {
|
package/bin/vtx.js
CHANGED
|
@@ -113,7 +113,7 @@ var init_routing = __esm({
|
|
|
113
113
|
var agent_cli_release_default;
|
|
114
114
|
var init_agent_cli_release = __esm({
|
|
115
115
|
"agent-cli-release.json"() {
|
|
116
|
-
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.
|
|
116
|
+
agent_cli_release_default = { package_name: "@vtxmacro/cli", package_version: "2026.10.20", 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" } } };
|
|
117
117
|
}
|
|
118
118
|
});
|
|
119
119
|
|
|
@@ -1297,6 +1297,9 @@ var init_runtime_policy_generated = __esm({
|
|
|
1297
1297
|
websocket: {
|
|
1298
1298
|
ping_interval_seconds: 20,
|
|
1299
1299
|
account_open_timeout_seconds: 10
|
|
1300
|
+
},
|
|
1301
|
+
perp_dexs: {
|
|
1302
|
+
default_dex_label: "Hyperliquid"
|
|
1300
1303
|
}
|
|
1301
1304
|
},
|
|
1302
1305
|
cache: {
|
|
@@ -21108,6 +21111,9 @@ var init_runtime_policy_generated2 = __esm({
|
|
|
21108
21111
|
websocket: {
|
|
21109
21112
|
ping_interval_seconds: 20,
|
|
21110
21113
|
account_open_timeout_seconds: 10
|
|
21114
|
+
},
|
|
21115
|
+
perp_dexs: {
|
|
21116
|
+
default_dex_label: "Hyperliquid"
|
|
21111
21117
|
}
|
|
21112
21118
|
},
|
|
21113
21119
|
cache: {
|
|
@@ -54793,7 +54799,6 @@ async function getLiveTicker(symbol2 = "PI_XBTUSD", exchange = "kraken", signal)
|
|
|
54793
54799
|
}
|
|
54794
54800
|
async function getExecutionAssetMetadata(exchange, symbol2, options) {
|
|
54795
54801
|
const params = new URLSearchParams();
|
|
54796
|
-
if (options?.includePrivateContext) params.set("include_private_context", "true");
|
|
54797
54802
|
if (options?.forceCatalogRefresh) params.set("force_catalog_refresh", "true");
|
|
54798
54803
|
if (options?.publicRequestPriority) params.set("public_request_priority", options.publicRequestPriority);
|
|
54799
54804
|
const query = params.size > 0 ? `?${params.toString()}` : "";
|
|
@@ -88377,20 +88382,14 @@ var init_hyperliquid_client = __esm({
|
|
|
88377
88382
|
if (!symbol2) {
|
|
88378
88383
|
throw new Error("Missing Hyperliquid symbol.");
|
|
88379
88384
|
}
|
|
88380
|
-
const
|
|
88381
|
-
input.includePrivateContext && String(input.walletAddress ?? "").trim()
|
|
88382
|
-
);
|
|
88383
|
-
const devicePrivateContext = deviceReadsPrivateContext ? readDevicePrivateExecutionContext({
|
|
88385
|
+
const devicePrivateContext = input.includePrivateContext ? readDevicePrivateExecutionContext({
|
|
88384
88386
|
...input,
|
|
88385
|
-
|
|
88387
|
+
// Refused before any request when the wallet is missing.
|
|
88388
|
+
walletAddress: requireWalletAddress(String(input.walletAddress ?? "")),
|
|
88386
88389
|
symbol: symbol2
|
|
88387
88390
|
}) : null;
|
|
88388
88391
|
devicePrivateContext?.catch(() => void 0);
|
|
88389
|
-
const metadata = input.
|
|
88390
|
-
includePrivateContext: true,
|
|
88391
|
-
...input.publicRequestPriority === "trading_reduce" ? { publicRequestPriority: "trading_reduce" } : {},
|
|
88392
|
-
profileId: Number.isFinite(Number(input.profileId)) ? Number(input.profileId) : void 0
|
|
88393
|
-
}) : input.publicRequestPriority === "trading_reduce" ? await getExecutionAssetMetadata("hyperliquid", symbol2, { publicRequestPriority: "trading_reduce" }) : await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
88392
|
+
const metadata = input.publicRequestPriority === "trading_reduce" ? await getExecutionAssetMetadata("hyperliquid", symbol2, { publicRequestPriority: "trading_reduce" }) : await getExecutionAssetMetadata("hyperliquid", symbol2);
|
|
88394
88393
|
const deviceContext = devicePrivateContext ? await devicePrivateContext : null;
|
|
88395
88394
|
const executionContextReceivedAtMonotonicMs = globalThis.performance.now();
|
|
88396
88395
|
const resolved = normalizeExecutionAssetMetadata(symbol2, metadata);
|
|
@@ -88430,11 +88429,6 @@ var init_hyperliquid_client = __esm({
|
|
|
88430
88429
|
executionPositionSize: deviceContext.executionPositionSize,
|
|
88431
88430
|
executionContextAtMs: deviceContext.executionContextAtMs,
|
|
88432
88431
|
executionContextReceivedAtMonotonicMs
|
|
88433
|
-
} : input.includePrivateContext ? {
|
|
88434
|
-
executionMarkPrice: Number.isFinite(Number(metadata.execution_mark_price)) && Number(metadata.execution_mark_price) > 0 ? Number(metadata.execution_mark_price) : null,
|
|
88435
|
-
executionPositionSize: Number.isFinite(Number(metadata.execution_position_size)) ? Number(metadata.execution_position_size) : null,
|
|
88436
|
-
executionContextAtMs: Number.isFinite(Number(metadata.execution_context_at_ms)) && Number(metadata.execution_context_at_ms) > 0 ? Number(metadata.execution_context_at_ms) : null,
|
|
88437
|
-
executionContextReceivedAtMonotonicMs
|
|
88438
88432
|
} : {}
|
|
88439
88433
|
};
|
|
88440
88434
|
};
|
|
@@ -96901,7 +96895,7 @@ function copiedTargetNow(reconciliation, recordedTarget, actualPosition) {
|
|
|
96901
96895
|
);
|
|
96902
96896
|
return { copiedNow, targetNow, kept: copiedTargetBesideOwnPosition(targetNow, copiedNow, actualPosition) };
|
|
96903
96897
|
}
|
|
96904
|
-
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, withCapacityTrim, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, getCommittedExecutionReports, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
|
|
96898
|
+
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, _extractOrderResponseStates, createRuntimeId, _extractFilledSize, _extractOrderId, _toExecutionMetadata, _extractClientMutationId, _stableMutationIdentity, trailingStopMemory, protectiveGroupMemory, protectiveGroupReadFailures, windowHandoffCleanupAttempts, clientRuntimeProtectionStorage, resolveClientRuntimeProtectionStorage, setClientRuntimeProtectionStorage, trailingStopStorageKey, readTrackedTrailingStops, writeTrackedTrailingStops, rememberTrailingStop, protectiveGroupStorageKey, LOST_LEG_EVIDENCE_MAX_AGE_MS, EPISODE_END_FILL_LOOKBACK_MS, withClientProtectivePlanSetLock, readClientProtectiveGroups, writeClientProtectiveGroups, hasClientProtectiveGroupReadFailure, readFreshClientProtectiveGroups, stableProtectionSnapshot, exactClientProtectiveGroupSnapshot, exactClientProtectiveGroupSetSnapshot, storableClientProtectiveGroup, replaceExactClientProtectiveGroup, replaceExactClientProtectiveGroupSet, isClientRuntimeLeaseOwnershipError, hasClientRuntimeProtectionState, clearClientRuntimeVetoedProtectiveIntent, rethrowWindowHandoffAfterProtectiveReplacementVeto, canPersistClientProtectiveGroups, removeTrackedTrailingStop, replaceTrackedTrailingStop, replaceProtectiveLeg, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, executedProtectiveReport, isExactClientPositionTpslPair, deviceOwnsClientProtectiveLegKind, isAdoptionNarrowedPositionTpslLeg, hasAmbiguousClientPositionTpslAuthority, protectiveStableShapeMatches, observedProtectiveGroupingMatches, protectiveLiveShapeMatches, protectiveTerminalShapeMatches, cancelClientProtectiveLeg, buildPendingProtectivePlan, persistPendingClientProtectiveGroup, attachmentMemberNeverLanded, storedClientProtectiveCover, attachClientProtectivePlan, resolveJournaledAttachmentContinuity, protectiveMemberRested, ledgerOrderIdsByClientOrderId, journaledAttachmentNeverLanded, recoverJournaledClientProtectiveAttachments, readClientOrderMutation, readPendingEntryMutation, clientOrderNeverLandsAfterMs, requireClientRuntimeConfigSeconds, replacePendingEntryRecovery, recoverPendingClientProtectiveGroups, recoverPendingProtectiveReplacements, liveProtectiveOrderShape, observedStandaloneProtectiveGroup, migrateTrackedTrailingStopsToStandalone, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, tightenClientTrailingStops, throwIfAborted2, sleep2, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, withCapacityTrim, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, maintainClientRuntimeTrailingStops, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked, executeClientCopyTradingIntent, _copyCancelOrderId, executeClientCopyTradingOrderAction;
|
|
96905
96899
|
var init_runtime_execution = __esm({
|
|
96906
96900
|
"lib/runtime/runtime-execution.ts"() {
|
|
96907
96901
|
"use strict";
|
|
@@ -102376,7 +102370,7 @@ var init_runtime_execution = __esm({
|
|
|
102376
102370
|
try {
|
|
102377
102371
|
return await executeClientRuntimeDecisionUnlocked(input, progress);
|
|
102378
102372
|
} catch (error48) {
|
|
102379
|
-
throw withCommittedExecutionReports(error48, progress.committedReports);
|
|
102373
|
+
throw withCommittedExecutionReports(error48, progress.committedReports, progress.committedOrder ?? null);
|
|
102380
102374
|
}
|
|
102381
102375
|
});
|
|
102382
102376
|
unsentDecisionOrderReport = (input, reasonCode, metadata = {}) => ({
|
|
@@ -102433,6 +102427,7 @@ var init_runtime_execution = __esm({
|
|
|
102433
102427
|
if (input.executionMode !== "server") return executeClientRuntimeDecisionLocked(input);
|
|
102434
102428
|
const audit = input.serverExecutionAudit ?? { auditId: null };
|
|
102435
102429
|
let entryDispatched = false;
|
|
102430
|
+
let exitDispatched = false;
|
|
102436
102431
|
const recordAudit = async (auditId2, fields, signal = input.signal) => {
|
|
102437
102432
|
try {
|
|
102438
102433
|
const recorded = await recordServerHostExecutionAudit(
|
|
@@ -102469,13 +102464,15 @@ var init_runtime_execution = __esm({
|
|
|
102469
102464
|
onExchangeOrderDispatched: (kind) => {
|
|
102470
102465
|
input.onExchangeOrderDispatched?.(kind);
|
|
102471
102466
|
if (kind === "entry") entryDispatched = true;
|
|
102467
|
+
if (kind === "exit") exitDispatched = true;
|
|
102472
102468
|
}
|
|
102473
102469
|
});
|
|
102474
102470
|
} catch (error48) {
|
|
102475
102471
|
const committedClose = getCommittedExecutionReports(error48).find((report) => report.status === "executed" && decisionLegOf(report) === "flip_close");
|
|
102476
102472
|
if (audit.auditId !== null && (!input.signal?.aborted || committedClose) && (input.decision === "BUY" || input.decision === "SELL")) {
|
|
102477
102473
|
const reason = String(error48?.reasonCode ?? "");
|
|
102478
|
-
const
|
|
102474
|
+
const orderMayHaveGoneOut = entryDispatched || exitDispatched && !committedClose;
|
|
102475
|
+
const [status2, reasonCode2] = reason === "outcome_unknown" || !reason && orderMayHaveGoneOut ? ["outcome_unknown", "outcome_unknown"] : ["error", reason === "exchange_rejected" ? "exchange_rejected" : "execution_error"];
|
|
102479
102476
|
const side = input.decision === "BUY" ? "buy" : "sell";
|
|
102480
102477
|
if (committedClose) {
|
|
102481
102478
|
await recordAudit(audit.auditId, {
|
|
@@ -102952,12 +102949,18 @@ var init_runtime_execution = __esm({
|
|
|
102952
102949
|
return !input.skipTrailingMaintenance && context.tpSlEnabled === true && context.stopLossEnabled !== false && context.stopLossType === "trailing" && positionSize !== 0;
|
|
102953
102950
|
};
|
|
102954
102951
|
COMMITTED_EXECUTION_REPORTS = /* @__PURE__ */ Symbol("committedExecutionReports");
|
|
102952
|
+
COMMITTED_DECISION_ORDER = /* @__PURE__ */ Symbol("committedDecisionOrder");
|
|
102955
102953
|
getCommittedExecutionReports = (error48) => {
|
|
102956
102954
|
if (!error48 || typeof error48 !== "object") return [];
|
|
102957
102955
|
const reports = error48[COMMITTED_EXECUTION_REPORTS];
|
|
102958
102956
|
return Array.isArray(reports) ? reports : [];
|
|
102959
102957
|
};
|
|
102960
|
-
|
|
102958
|
+
getCommittedDecisionOrder = (error48) => {
|
|
102959
|
+
if (!error48 || typeof error48 !== "object") return null;
|
|
102960
|
+
const order = error48[COMMITTED_DECISION_ORDER];
|
|
102961
|
+
return order && typeof order === "object" ? order : null;
|
|
102962
|
+
};
|
|
102963
|
+
withCommittedExecutionReports = (error48, reports, order = null) => {
|
|
102961
102964
|
if (!reports || !reports.some((report) => report.status === "executed")) return error48;
|
|
102962
102965
|
const carrier = error48 && typeof error48 === "object" ? error48 : new Error(String(error48 ?? "Unknown runtime execution error."), { cause: error48 });
|
|
102963
102966
|
Object.defineProperty(carrier, COMMITTED_EXECUTION_REPORTS, {
|
|
@@ -102965,6 +102968,11 @@ var init_runtime_execution = __esm({
|
|
|
102965
102968
|
enumerable: false,
|
|
102966
102969
|
configurable: true
|
|
102967
102970
|
});
|
|
102971
|
+
Object.defineProperty(carrier, COMMITTED_DECISION_ORDER, {
|
|
102972
|
+
value: order,
|
|
102973
|
+
enumerable: false,
|
|
102974
|
+
configurable: true
|
|
102975
|
+
});
|
|
102968
102976
|
return carrier;
|
|
102969
102977
|
};
|
|
102970
102978
|
executeClientRuntimeDecisionUnlocked = async (unsizedInput, progress = { committedReports: null }) => {
|
|
@@ -103361,7 +103369,7 @@ var init_runtime_execution = __esm({
|
|
|
103361
103369
|
config: input.config ?? null,
|
|
103362
103370
|
signal: input.signal,
|
|
103363
103371
|
signingKey: input.signingKey,
|
|
103364
|
-
onExchangeOrderDispatched: () => input.onExchangeOrderDispatched?.("
|
|
103372
|
+
onExchangeOrderDispatched: () => input.onExchangeOrderDispatched?.("exit"),
|
|
103365
103373
|
symbol: input.executionContext.symbol,
|
|
103366
103374
|
position: currentPosition,
|
|
103367
103375
|
estimatedPrice,
|
|
@@ -103373,8 +103381,30 @@ var init_runtime_execution = __esm({
|
|
|
103373
103381
|
const expectedCloseSize = Math.abs(currentPositionSize);
|
|
103374
103382
|
const closeTolerance = Math.max(expectedCloseSize, 1) * Number.EPSILON * CLIENT_CLOSE_FILL_EPSILON_ULPS;
|
|
103375
103383
|
const closeFillConfirmed = confirmedClose != null && Math.abs(confirmedClose.filledSize - expectedCloseSize) <= closeTolerance;
|
|
103384
|
+
const closeReport = {
|
|
103385
|
+
order_id: _extractOrderId(closeResponse),
|
|
103386
|
+
client_mutation_id: _extractClientMutationId(closeResponse),
|
|
103387
|
+
symbol: input.executionContext.symbol,
|
|
103388
|
+
action: classified.side.toUpperCase(),
|
|
103389
|
+
status: "executed",
|
|
103390
|
+
execution_metadata: _toExecutionMetadata(closeResponse)
|
|
103391
|
+
};
|
|
103392
|
+
const committedCloseReports = [...reconciliationReports, closeReport];
|
|
103393
|
+
progress.committedReports = committedCloseReports;
|
|
103394
|
+
const recordPostCloseReports = (reports) => {
|
|
103395
|
+
reconciliationReports.push(...reports);
|
|
103396
|
+
committedCloseReports.push(...reports);
|
|
103397
|
+
};
|
|
103398
|
+
progress.committedOrder = {
|
|
103399
|
+
intent: classified.intent,
|
|
103400
|
+
side: classified.side,
|
|
103401
|
+
reduceOnly: classified.reduceOnly,
|
|
103402
|
+
requestedUnits: classified.requestedUnits,
|
|
103403
|
+
targetSignedUnits: classified.targetSignedUnits,
|
|
103404
|
+
executedSizeAsset: confirmedClose?.filledSize ?? 0
|
|
103405
|
+
};
|
|
103376
103406
|
if (closeFillConfirmed) {
|
|
103377
|
-
|
|
103407
|
+
recordPostCloseReports(await cancelAllClientProtectiveGroups(
|
|
103378
103408
|
input,
|
|
103379
103409
|
"position_closed"
|
|
103380
103410
|
));
|
|
@@ -103385,7 +103415,7 @@ var init_runtime_execution = __esm({
|
|
|
103385
103415
|
[]
|
|
103386
103416
|
);
|
|
103387
103417
|
} else if (hasTrackedProtection) {
|
|
103388
|
-
|
|
103418
|
+
recordPostCloseReports(await reconcileClientProtectiveGroups(
|
|
103389
103419
|
input,
|
|
103390
103420
|
confirmedClose == null ? void 0 : signedRemainingExposureAfterConfirmedReduction(
|
|
103391
103421
|
currentPositionSize,
|
|
@@ -103401,17 +103431,7 @@ var init_runtime_execution = __esm({
|
|
|
103401
103431
|
requestedUnits: classified.requestedUnits,
|
|
103402
103432
|
targetSignedUnits: classified.targetSignedUnits,
|
|
103403
103433
|
executedSizeAsset: confirmedClose?.filledSize ?? 0,
|
|
103404
|
-
executionReports: [
|
|
103405
|
-
...reconciliationReports,
|
|
103406
|
-
{
|
|
103407
|
-
order_id: _extractOrderId(closeResponse),
|
|
103408
|
-
client_mutation_id: _extractClientMutationId(closeResponse),
|
|
103409
|
-
symbol: input.executionContext.symbol,
|
|
103410
|
-
action: classified.side.toUpperCase(),
|
|
103411
|
-
status: "executed",
|
|
103412
|
-
execution_metadata: _toExecutionMetadata(closeResponse)
|
|
103413
|
-
}
|
|
103414
|
-
],
|
|
103434
|
+
executionReports: [...reconciliationReports, closeReport],
|
|
103415
103435
|
message: closeFillConfirmed ? "Closed position" : "The close order did not confirm the full position size; retained trailing protection for any remaining exposure.",
|
|
103416
103436
|
...closeFillConfirmed ? {} : { reasonCode: "close_fill_unresolved" },
|
|
103417
103437
|
executionSnapshotId,
|
|
@@ -103437,7 +103457,7 @@ var init_runtime_execution = __esm({
|
|
|
103437
103457
|
config: input.config ?? null,
|
|
103438
103458
|
signal: input.signal,
|
|
103439
103459
|
signingKey: input.signingKey,
|
|
103440
|
-
onExchangeOrderDispatched: () => input.onExchangeOrderDispatched?.("
|
|
103460
|
+
onExchangeOrderDispatched: () => input.onExchangeOrderDispatched?.("exit"),
|
|
103441
103461
|
symbol: input.executionContext.symbol,
|
|
103442
103462
|
position: currentPosition,
|
|
103443
103463
|
estimatedPrice,
|
|
@@ -103765,7 +103785,7 @@ var init_runtime_execution = __esm({
|
|
|
103765
103785
|
);
|
|
103766
103786
|
}
|
|
103767
103787
|
input.onExchangeOrderDispatched?.(
|
|
103768
|
-
classified.intent === "open" || classified.intent === "add" || classified.intent === "flip" ? "entry" : "
|
|
103788
|
+
classified.intent === "open" || classified.intent === "add" || classified.intent === "flip" ? "entry" : "exit"
|
|
103769
103789
|
);
|
|
103770
103790
|
entryDispatchBoundaryPassed = true;
|
|
103771
103791
|
},
|
|
@@ -103862,6 +103882,15 @@ var init_runtime_execution = __esm({
|
|
|
103862
103882
|
status: "executed",
|
|
103863
103883
|
execution_metadata: classified.intent === "flip" ? { ..._toExecutionMetadata(marketOrderResponse), decision_leg: "entry" } : { ..._toExecutionMetadata(marketOrderResponse), entry_began_flat: livePositionDirection === 0 }
|
|
103864
103884
|
});
|
|
103885
|
+
progress.committedReports = executionReports;
|
|
103886
|
+
progress.committedOrder = {
|
|
103887
|
+
intent: classified.intent,
|
|
103888
|
+
side: classified.side,
|
|
103889
|
+
reduceOnly: classified.reduceOnly,
|
|
103890
|
+
requestedUnits: classified.requestedUnits,
|
|
103891
|
+
targetSignedUnits: classified.targetSignedUnits,
|
|
103892
|
+
executedSizeAsset: confirmedMarketFill == null ? 0 : confirmedMarketFill.filledSize
|
|
103893
|
+
};
|
|
103865
103894
|
const appendPostEntryProtectionFailure = (error48) => {
|
|
103866
103895
|
const projection = projectExecutionErrorContract({
|
|
103867
103896
|
error: error48,
|
|
@@ -104426,7 +104455,6 @@ var init_runtime_execution = __esm({
|
|
|
104426
104455
|
size: destinationSize,
|
|
104427
104456
|
roundingMode: "nearest",
|
|
104428
104457
|
includePrivateContext: desiredPosition != null && Number.isFinite(desiredPosition),
|
|
104429
|
-
profileId: input.profileId,
|
|
104430
104458
|
// The device reads its own position and mark; the server never reads
|
|
104431
104459
|
// a Client wallet.
|
|
104432
104460
|
walletAddress: input.walletAddress,
|
|
@@ -108712,6 +108740,7 @@ var init_ai_settings_helpers = __esm({
|
|
|
108712
108740
|
init_define_VTX_EXO_POLICY();
|
|
108713
108741
|
init_define_VTX_GROK_POLICY();
|
|
108714
108742
|
init_define_VTX_PI_MODEL_POLICY();
|
|
108743
|
+
init_perp_dex_scope();
|
|
108715
108744
|
sortAiSettings = (settings) => {
|
|
108716
108745
|
if (!settings || typeof settings !== "object") return settings;
|
|
108717
108746
|
const normalized = { ...settings };
|
|
@@ -121466,6 +121495,9 @@ var init_engine = __esm({
|
|
|
121466
121495
|
this._lastErrorReportCalls = null;
|
|
121467
121496
|
// The retry wait the API returned for this runtime's latest error report.
|
|
121468
121497
|
this._reportedProviderRetryAfterSeconds = null;
|
|
121498
|
+
// Whether the server answered the last error report with the failure shown
|
|
121499
|
+
// on its decision's card.
|
|
121500
|
+
this._reportedOrderFailureOnDecisionCard = false;
|
|
121469
121501
|
this._activeRuntimeContractIdentity = null;
|
|
121470
121502
|
this._contractRebindInFlight = false;
|
|
121471
121503
|
this._contractRebindExhausted = false;
|
|
@@ -123853,6 +123885,7 @@ var init_engine = __esm({
|
|
|
123853
123885
|
let cycleObservation = { stage: "setup" };
|
|
123854
123886
|
let cycleOutcome = "unknown";
|
|
123855
123887
|
let cycleReason = null;
|
|
123888
|
+
let cycleOrderFailure = null;
|
|
123856
123889
|
let cycleFailureStage = null;
|
|
123857
123890
|
let decisionSnapshotId = null;
|
|
123858
123891
|
let observationClosed = false;
|
|
@@ -124463,6 +124496,7 @@ var init_engine = __esm({
|
|
|
124463
124496
|
}
|
|
124464
124497
|
const runPlan = async (plan, planIndex) => {
|
|
124465
124498
|
let planEntryOrderDispatched = false;
|
|
124499
|
+
let planExitOrderDispatched = false;
|
|
124466
124500
|
const decisionWallet = String(
|
|
124467
124501
|
plan.executionContext.walletAddress || ""
|
|
124468
124502
|
).trim().toLowerCase();
|
|
@@ -124555,98 +124589,150 @@ var init_engine = __esm({
|
|
|
124555
124589
|
if (dispatchKind === "entry") {
|
|
124556
124590
|
planEntryOrderDispatched = true;
|
|
124557
124591
|
}
|
|
124592
|
+
if (dispatchKind === "exit") {
|
|
124593
|
+
planExitOrderDispatched = true;
|
|
124594
|
+
}
|
|
124558
124595
|
this._executionFinalizationRequired = true;
|
|
124559
124596
|
},
|
|
124560
124597
|
shouldCancelBeforeExchangeOrderDispatch: () => this._windowHandoffRequested
|
|
124561
124598
|
});
|
|
124562
124599
|
} catch (executionError) {
|
|
124600
|
+
const committedReports = getCommittedExecutionReports(executionError);
|
|
124601
|
+
const committedOrder = getCommittedDecisionOrder(executionError);
|
|
124602
|
+
const plannedUnits = Number.isFinite(Number(plan.units)) ? Math.max(0, Math.trunc(Number(plan.units))) : 0;
|
|
124563
124603
|
if (isClientRuntimeWindowHandoffBeforePlanDispatch(executionError)) {
|
|
124564
124604
|
const handoffCleanup = getClientRuntimeWindowHandoffCleanup(executionError);
|
|
124565
|
-
if (handoffCleanup) {
|
|
124605
|
+
if (handoffCleanup || committedReports.length > 0) {
|
|
124566
124606
|
this._executionFinalizationRequired = true;
|
|
124567
124607
|
return { control: "break", result: {
|
|
124568
|
-
status: "skipped",
|
|
124608
|
+
status: committedReports.length > 0 ? "executed" : "skipped",
|
|
124569
124609
|
intent: "hold",
|
|
124570
124610
|
side: null,
|
|
124571
124611
|
reduceOnly: false,
|
|
124572
|
-
requestedUnits:
|
|
124612
|
+
requestedUnits: plannedUnits,
|
|
124573
124613
|
targetSignedUnits: 0,
|
|
124574
124614
|
executedSizeAsset: 0,
|
|
124575
|
-
|
|
124576
|
-
|
|
124577
|
-
handoffCleanup,
|
|
124615
|
+
...committedOrder ?? {},
|
|
124616
|
+
executionReports: committedReports,
|
|
124617
|
+
message: handoffCleanup ? "Stopped before protective replacement dispatch; cleanup remains blocked." : "Stopped after the order for ownership handoff.",
|
|
124618
|
+
...handoffCleanup ? { handoffCleanup } : {},
|
|
124578
124619
|
executionSnapshotId: `handoff-cleanup-${planIndex + 1}-${Date.now()}`,
|
|
124579
124620
|
executionSnapshotCapturedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
124580
124621
|
} };
|
|
124581
124622
|
}
|
|
124582
124623
|
return { control: "break" };
|
|
124583
124624
|
}
|
|
124584
|
-
const committedReports = getCommittedExecutionReports(executionError);
|
|
124585
124625
|
const abortedAfterCommittedOrder = committedReports.length > 0 && (analysisAbortController.signal.aborted || isRuntimeAbortError(executionError));
|
|
124586
124626
|
if (!abortedAfterCommittedOrder && (analysisAbortController.signal.aborted || isRuntimeAbortError(executionError)) || isRuntimeContractMismatchError(executionError) || isClientExecutionModeMismatchError(executionError) || isClientRuntimeSessionStoppedError(executionError) || isClientRuntimeLeaseAuthError(executionError) || isTransientRuntimeConflictError(executionError) && committedReports.length === 0) {
|
|
124587
124627
|
throw executionError;
|
|
124588
124628
|
}
|
|
124589
124629
|
const sanitizedReason = getSanitizedRuntimeErrorMessage(executionError) || "Unknown runtime execution error.";
|
|
124590
|
-
|
|
124591
|
-
|
|
124592
|
-
|
|
124593
|
-
|
|
124594
|
-
reasonCode: typeof typedExecutionError?.reasonCode === "string" ? typedExecutionError.reasonCode : planEntryOrderDispatched ? "outcome_unknown" : "local_safety_block"
|
|
124595
|
-
});
|
|
124596
|
-
const failureDiagnostics = getExchangeFailureDiagnostics(executionError);
|
|
124597
|
-
if (!abortedAfterCommittedOrder) {
|
|
124598
|
-
executionFailures.push({
|
|
124599
|
-
symbol: plan.executionContext.symbol,
|
|
124600
|
-
projection: projectedFailure
|
|
124630
|
+
if (committedOrder !== null) {
|
|
124631
|
+
const stepFailure = projectExecutionErrorContract({
|
|
124632
|
+
error: executionError,
|
|
124633
|
+
symbol: plan.executionContext.symbol
|
|
124601
124634
|
});
|
|
124602
|
-
|
|
124603
|
-
|
|
124604
|
-
|
|
124605
|
-
|
|
124606
|
-
|
|
124607
|
-
|
|
124608
|
-
|
|
124609
|
-
|
|
124610
|
-
|
|
124611
|
-
|
|
124612
|
-
|
|
124613
|
-
|
|
124614
|
-
|
|
124615
|
-
|
|
124616
|
-
|
|
124617
|
-
|
|
124618
|
-
|
|
124619
|
-
|
|
124620
|
-
|
|
124621
|
-
|
|
124622
|
-
|
|
124623
|
-
|
|
124624
|
-
|
|
124625
|
-
|
|
124626
|
-
|
|
124627
|
-
|
|
124628
|
-
|
|
124629
|
-
|
|
124630
|
-
|
|
124631
|
-
|
|
124635
|
+
appendRuntimeDebugEvent({
|
|
124636
|
+
label: "execution_plan_failed_after_order",
|
|
124637
|
+
note: [
|
|
124638
|
+
`cycle_id=${result.cycleId}`,
|
|
124639
|
+
`decision_snapshot_id=${result.decisionSnapshotId}`,
|
|
124640
|
+
`index=${planIndex + 1}/${executionPlans.length}`,
|
|
124641
|
+
`symbol=${plan.executionContext.symbol}`,
|
|
124642
|
+
`decision=${plan.decision}`,
|
|
124643
|
+
`error=${sanitizedReason}`
|
|
124644
|
+
].join(" "),
|
|
124645
|
+
outcome: "error"
|
|
124646
|
+
});
|
|
124647
|
+
executionResult = {
|
|
124648
|
+
status: "executed",
|
|
124649
|
+
...committedOrder,
|
|
124650
|
+
message: stepFailure.message,
|
|
124651
|
+
executionSnapshotId: `execution-error-${planIndex + 1}-${Date.now()}`,
|
|
124652
|
+
executionSnapshotCapturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
124653
|
+
executionReports: abortedAfterCommittedOrder ? committedReports : [...committedReports, {
|
|
124654
|
+
order_id: null,
|
|
124655
|
+
symbol: plan.executionContext.symbol,
|
|
124656
|
+
action: "PROTECTIVE_RECONCILIATION",
|
|
124657
|
+
status: "failed",
|
|
124658
|
+
execution_metadata: {
|
|
124659
|
+
reason_code: stepFailure.reason_code,
|
|
124660
|
+
execution_stage: stepFailure.execution_stage,
|
|
124661
|
+
dispatch_outcome: stepFailure.dispatch_outcome,
|
|
124662
|
+
operation_stage: committedOrder.intent === "close" ? "post_close_protection" : "post_entry_protection",
|
|
124663
|
+
error: stepFailure.message,
|
|
124664
|
+
cycle_id: result.cycleId,
|
|
124665
|
+
decision_snapshot_id: result.decisionSnapshotId
|
|
124666
|
+
}
|
|
124667
|
+
}]
|
|
124668
|
+
};
|
|
124669
|
+
if (abortedAfterCommittedOrder) {
|
|
124670
|
+
this._executionFinalizationRequired = true;
|
|
124671
|
+
return { control: "break", result: executionResult };
|
|
124672
|
+
}
|
|
124673
|
+
} else {
|
|
124674
|
+
const typedExecutionError = executionError;
|
|
124675
|
+
const planOrderMayHaveGoneOut = planEntryOrderDispatched || planExitOrderDispatched && committedReports.length === 0;
|
|
124676
|
+
const projectedFailure = projectExecutionErrorContract({
|
|
124677
|
+
error: executionError,
|
|
124632
124678
|
symbol: plan.executionContext.symbol,
|
|
124633
|
-
|
|
124634
|
-
|
|
124635
|
-
|
|
124636
|
-
|
|
124637
|
-
|
|
124638
|
-
|
|
124639
|
-
|
|
124640
|
-
|
|
124641
|
-
|
|
124642
|
-
|
|
124643
|
-
|
|
124644
|
-
|
|
124645
|
-
|
|
124646
|
-
|
|
124647
|
-
|
|
124648
|
-
|
|
124649
|
-
|
|
124679
|
+
reasonCode: typeof typedExecutionError?.reasonCode === "string" ? typedExecutionError.reasonCode : planOrderMayHaveGoneOut ? "outcome_unknown" : "local_safety_block"
|
|
124680
|
+
});
|
|
124681
|
+
const failureDiagnostics = getExchangeFailureDiagnostics(executionError);
|
|
124682
|
+
if (!abortedAfterCommittedOrder) {
|
|
124683
|
+
executionFailures.push({
|
|
124684
|
+
symbol: plan.executionContext.symbol,
|
|
124685
|
+
projection: projectedFailure
|
|
124686
|
+
});
|
|
124687
|
+
executionFailureCauses.push(executionError);
|
|
124688
|
+
}
|
|
124689
|
+
appendRuntimeDebugEvent({
|
|
124690
|
+
label: "execution_plan_failed",
|
|
124691
|
+
note: [
|
|
124692
|
+
`cycle_id=${result.cycleId}`,
|
|
124693
|
+
`decision_snapshot_id=${result.decisionSnapshotId}`,
|
|
124694
|
+
`index=${planIndex + 1}/${executionPlans.length}`,
|
|
124695
|
+
`symbol=${plan.executionContext.symbol}`,
|
|
124696
|
+
`decision=${plan.decision}`,
|
|
124697
|
+
`units=${plan.units}`,
|
|
124698
|
+
`error=${sanitizedReason}`
|
|
124699
|
+
].join(" "),
|
|
124700
|
+
outcome: "error"
|
|
124701
|
+
});
|
|
124702
|
+
const flipCloseCommitted = committedReports.some((report) => report.status === "executed" && report.execution_metadata?.decision_leg === "flip_close");
|
|
124703
|
+
const planSide = String(plan.decision || "").toUpperCase() === "BUY" ? "buy" : String(plan.decision || "").toUpperCase() === "SELL" ? "sell" : null;
|
|
124704
|
+
executionResult = {
|
|
124705
|
+
status: committedReports.length > 0 ? "executed" : "skipped",
|
|
124706
|
+
intent: flipCloseCommitted ? "flip" : "hold",
|
|
124707
|
+
side: flipCloseCommitted ? planSide : null,
|
|
124708
|
+
reduceOnly: false,
|
|
124709
|
+
requestedUnits: plannedUnits,
|
|
124710
|
+
targetSignedUnits: 0,
|
|
124711
|
+
executedSizeAsset: 0,
|
|
124712
|
+
message: projectedFailure.message,
|
|
124713
|
+
executionSnapshotId: `execution-error-${planIndex + 1}-${Date.now()}`,
|
|
124714
|
+
executionSnapshotCapturedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
124715
|
+
executionReports: [...committedReports, {
|
|
124716
|
+
order_id: null,
|
|
124717
|
+
symbol: plan.executionContext.symbol,
|
|
124718
|
+
action: String(plan.decision || "UNKNOWN").toUpperCase(),
|
|
124719
|
+
status: "failed",
|
|
124720
|
+
execution_metadata: {
|
|
124721
|
+
error: projectedFailure.message,
|
|
124722
|
+
reason_code: projectedFailure.reason_code,
|
|
124723
|
+
execution_stage: projectedFailure.execution_stage,
|
|
124724
|
+
dispatch_outcome: projectedFailure.dispatch_outcome,
|
|
124725
|
+
cycle_id: result.cycleId,
|
|
124726
|
+
decision_snapshot_id: result.decisionSnapshotId,
|
|
124727
|
+
...flipCloseCommitted ? { decision_leg: "entry" } : {},
|
|
124728
|
+
...failureDiagnostics ?? {}
|
|
124729
|
+
}
|
|
124730
|
+
}]
|
|
124731
|
+
};
|
|
124732
|
+
if (abortedAfterCommittedOrder) {
|
|
124733
|
+
this._executionFinalizationRequired = true;
|
|
124734
|
+
return { control: "break", result: executionResult };
|
|
124735
|
+
}
|
|
124650
124736
|
}
|
|
124651
124737
|
}
|
|
124652
124738
|
}
|
|
@@ -124871,6 +124957,7 @@ var init_engine = __esm({
|
|
|
124871
124957
|
cycleFailureStage = "execution";
|
|
124872
124958
|
const primaryFailure = selectPrimaryExecutionFailure(executionFailures);
|
|
124873
124959
|
const reportedFailures = this._expectedExecutionMode === "server" ? executionFailures.filter((_, index) => executionFailureCauses.indexOf(executionFailureCauses[index]) === index) : primaryFailure ? [primaryFailure] : [];
|
|
124960
|
+
this._lastError = null;
|
|
124874
124961
|
for (const failure2 of reportedFailures) {
|
|
124875
124962
|
await this.reportError(failure2.projection.message, {
|
|
124876
124963
|
fatal: false,
|
|
@@ -124879,8 +124966,12 @@ var init_engine = __esm({
|
|
|
124879
124966
|
executionSymbol: failure2.symbol,
|
|
124880
124967
|
executionReasonCode: failure2.projection.reason_code,
|
|
124881
124968
|
executionStage: failure2.projection.execution_stage,
|
|
124882
|
-
dispatchOutcome: failure2.projection.dispatch_outcome
|
|
124969
|
+
dispatchOutcome: failure2.projection.dispatch_outcome,
|
|
124970
|
+
recordedOrderFailure: true
|
|
124883
124971
|
});
|
|
124972
|
+
if (this._reportedOrderFailureOnDecisionCard) {
|
|
124973
|
+
cycleOrderFailure = failure2.projection.message;
|
|
124974
|
+
}
|
|
124884
124975
|
}
|
|
124885
124976
|
return;
|
|
124886
124977
|
}
|
|
@@ -125148,7 +125239,7 @@ var init_engine = __esm({
|
|
|
125148
125239
|
requestId,
|
|
125149
125240
|
outcome: cycleOutcome,
|
|
125150
125241
|
reason: cycleReason,
|
|
125151
|
-
error: cycleOutcome === "failed" ? this._lastError : null,
|
|
125242
|
+
error: cycleOutcome === "failed" ? this._lastError ?? cycleOrderFailure : null,
|
|
125152
125243
|
decisionSubmitted,
|
|
125153
125244
|
executionOccurred: executedExchangeOrderInCycle
|
|
125154
125245
|
};
|
|
@@ -125341,6 +125432,7 @@ var init_engine = __esm({
|
|
|
125341
125432
|
}
|
|
125342
125433
|
async reportError(reason, options) {
|
|
125343
125434
|
this._reportedProviderRetryAfterSeconds = null;
|
|
125435
|
+
this._reportedOrderFailureOnDecisionCard = false;
|
|
125344
125436
|
if (this._isStopping) {
|
|
125345
125437
|
this._lastError = null;
|
|
125346
125438
|
return null;
|
|
@@ -125375,10 +125467,13 @@ var init_engine = __esm({
|
|
|
125375
125467
|
});
|
|
125376
125468
|
const projectedErrorWithoutWarning = String(projected.error_message || "").replace(/^\s*⚠️?\s*/u, "").trim();
|
|
125377
125469
|
const persistedError = executionProjection?.message ?? (projectedErrorWithoutWarning === sanitizedReason ? sanitizedReason : projected.error_message);
|
|
125378
|
-
|
|
125470
|
+
const awaitsDecisionCardAnswer = options?.recordedOrderFailure === true && !isFatal;
|
|
125471
|
+
if (!awaitsDecisionCardAnswer) {
|
|
125472
|
+
this._lastError = persistedError;
|
|
125473
|
+
}
|
|
125379
125474
|
if (isFatal) {
|
|
125380
125475
|
this._setState("error");
|
|
125381
|
-
} else {
|
|
125476
|
+
} else if (!awaitsDecisionCardAnswer) {
|
|
125382
125477
|
this._notifyListeners();
|
|
125383
125478
|
}
|
|
125384
125479
|
this.recordLocalBreadcrumb("runtime_error_detected", projected.error_message, {
|
|
@@ -125418,13 +125513,18 @@ var init_engine = __esm({
|
|
|
125418
125513
|
requestTimeoutMs: this._settlementRequestTimeoutMs ?? void 0
|
|
125419
125514
|
}
|
|
125420
125515
|
);
|
|
125516
|
+
const shownOnDecisionCard = awaitsDecisionCardAnswer && response.shown_on_decision_card === true;
|
|
125517
|
+
this._reportedOrderFailureOnDecisionCard = shownOnDecisionCard;
|
|
125518
|
+
if (!shownOnDecisionCard) {
|
|
125519
|
+
this._lastError = persistedError;
|
|
125520
|
+
}
|
|
125421
125521
|
const accepted = this._setRuntimeStatus(response.runtime, "error_report");
|
|
125422
125522
|
const retryAfterSeconds = Number(response.provider_retry_after_seconds);
|
|
125423
125523
|
this._reportedProviderRetryAfterSeconds = accepted && response.provider_retry_after_seconds != null && Number.isFinite(retryAfterSeconds) && retryAfterSeconds >= 0 ? retryAfterSeconds : null;
|
|
125424
|
-
this._lastError = persistedError;
|
|
125425
125524
|
this._notifyListeners();
|
|
125426
125525
|
return accepted ? response.runtime ?? null : null;
|
|
125427
125526
|
} catch (error48) {
|
|
125527
|
+
this._lastError = persistedError;
|
|
125428
125528
|
if (isClientRuntimeReleasedError(error48)) {
|
|
125429
125529
|
await this._handleRuntimeReleased("error_report", { deferUntilExecutionLoopSettles: true });
|
|
125430
125530
|
return null;
|