@vtxmacro/cli 2026.10.56 → 2026.10.58
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 +15 -10
- package/bin/vtx-service-bootstrap.js +15 -10
- package/bin/vtx-service-launcher.js +46 -18
- package/bin/vtx.js +225 -95
- 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.58", 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
|
|
|
@@ -3804,6 +3804,15 @@ var defaultCurrentProcessIdentity = async () => {
|
|
|
3804
3804
|
throw error;
|
|
3805
3805
|
}
|
|
3806
3806
|
};
|
|
3807
|
+
var processExists = (pid) => {
|
|
3808
|
+
try {
|
|
3809
|
+
process.kill(pid, 0);
|
|
3810
|
+
return true;
|
|
3811
|
+
} catch (error) {
|
|
3812
|
+
if (error.code === "ESRCH") return false;
|
|
3813
|
+
throw error;
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3807
3816
|
var processLockObservationCache = /* @__PURE__ */ new Map();
|
|
3808
3817
|
var inferenceProcessIdentitiesMatch = (stored, observed) => stored === observed;
|
|
3809
3818
|
function inferenceBaseDir(env) {
|
|
@@ -4025,6 +4034,10 @@ var inspectProcessLockFile = async (path, label, probes) => {
|
|
|
4025
4034
|
const cached = processLockObservationCache.get(cacheKey);
|
|
4026
4035
|
const observedIdentity = cached && cached.dev === stat.dev && cached.ino === stat.ino && cached.pid === ownerPid && cached.storedIdentity === storedIdentity && Date.now() - cached.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached.observedIdentity : await probes.observeIdentity(ownerPid);
|
|
4027
4036
|
if (!observedIdentity) {
|
|
4037
|
+
if (!probes.isProcessAlive(ownerPid)) {
|
|
4038
|
+
stale = true;
|
|
4039
|
+
return { state: "stale", handle, stat };
|
|
4040
|
+
}
|
|
4028
4041
|
throw new Error("Inference host could not verify the existing lock owner identity.");
|
|
4029
4042
|
}
|
|
4030
4043
|
processLockObservationCache.set(cacheKey, {
|
|
@@ -4200,15 +4213,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
4200
4213
|
const probes = {
|
|
4201
4214
|
currentBootIdentity: dependencies.currentBootIdentity ?? (() => readInferenceSystemBootIdentity()),
|
|
4202
4215
|
observeIdentity: dependencies.processIdentity ?? defaultProcessIdentity,
|
|
4203
|
-
isProcessAlive: dependencies.processAlive ??
|
|
4204
|
-
try {
|
|
4205
|
-
process.kill(pid, 0);
|
|
4206
|
-
return true;
|
|
4207
|
-
} catch (error) {
|
|
4208
|
-
if (error.code === "ESRCH") return false;
|
|
4209
|
-
throw error;
|
|
4210
|
-
}
|
|
4211
|
-
})
|
|
4216
|
+
isProcessAlive: dependencies.processAlive ?? processExists
|
|
4212
4217
|
};
|
|
4213
4218
|
const [ownerIdentity, bootIdentity] = await Promise.all([
|
|
4214
4219
|
(dependencies.currentProcessIdentity ?? defaultCurrentProcessIdentity)(),
|
|
@@ -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.58", 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 = {
|
|
@@ -2141,6 +2141,15 @@ var defaultCurrentProcessIdentity = async () => {
|
|
|
2141
2141
|
throw error;
|
|
2142
2142
|
}
|
|
2143
2143
|
};
|
|
2144
|
+
var processExists = (pid) => {
|
|
2145
|
+
try {
|
|
2146
|
+
process.kill(pid, 0);
|
|
2147
|
+
return true;
|
|
2148
|
+
} catch (error) {
|
|
2149
|
+
if (error.code === "ESRCH") return false;
|
|
2150
|
+
throw error;
|
|
2151
|
+
}
|
|
2152
|
+
};
|
|
2144
2153
|
var processLockObservationCache = /* @__PURE__ */ new Map();
|
|
2145
2154
|
var inferenceProcessIdentitiesMatch = (stored, observed) => stored === observed;
|
|
2146
2155
|
async function ensureInferencePrivateDirectory(path, dependencies = {}) {
|
|
@@ -2356,6 +2365,10 @@ var inspectProcessLockFile = async (path, label, probes) => {
|
|
|
2356
2365
|
const cached = processLockObservationCache.get(cacheKey);
|
|
2357
2366
|
const observedIdentity = cached && cached.dev === stat.dev && cached.ino === stat.ino && cached.pid === ownerPid && cached.storedIdentity === storedIdentity && Date.now() - cached.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached.observedIdentity : await probes.observeIdentity(ownerPid);
|
|
2358
2367
|
if (!observedIdentity) {
|
|
2368
|
+
if (!probes.isProcessAlive(ownerPid)) {
|
|
2369
|
+
stale = true;
|
|
2370
|
+
return { state: "stale", handle, stat };
|
|
2371
|
+
}
|
|
2359
2372
|
throw new Error("Inference host could not verify the existing lock owner identity.");
|
|
2360
2373
|
}
|
|
2361
2374
|
processLockObservationCache.set(cacheKey, {
|
|
@@ -2531,15 +2544,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
2531
2544
|
const probes = {
|
|
2532
2545
|
currentBootIdentity: dependencies.currentBootIdentity ?? (() => readInferenceSystemBootIdentity()),
|
|
2533
2546
|
observeIdentity: dependencies.processIdentity ?? defaultProcessIdentity,
|
|
2534
|
-
isProcessAlive: dependencies.processAlive ??
|
|
2535
|
-
try {
|
|
2536
|
-
process.kill(pid, 0);
|
|
2537
|
-
return true;
|
|
2538
|
-
} catch (error) {
|
|
2539
|
-
if (error.code === "ESRCH") return false;
|
|
2540
|
-
throw error;
|
|
2541
|
-
}
|
|
2542
|
-
})
|
|
2547
|
+
isProcessAlive: dependencies.processAlive ?? processExists
|
|
2543
2548
|
};
|
|
2544
2549
|
const [ownerIdentity, bootIdentity] = await Promise.all([
|
|
2545
2550
|
(dependencies.currentProcessIdentity ?? defaultCurrentProcessIdentity)(),
|
|
@@ -2076,6 +2076,15 @@ var defaultCurrentProcessIdentity = async () => {
|
|
|
2076
2076
|
throw error;
|
|
2077
2077
|
}
|
|
2078
2078
|
};
|
|
2079
|
+
var processExists = (pid) => {
|
|
2080
|
+
try {
|
|
2081
|
+
process.kill(pid, 0);
|
|
2082
|
+
return true;
|
|
2083
|
+
} catch (error) {
|
|
2084
|
+
if (error.code === "ESRCH") return false;
|
|
2085
|
+
throw error;
|
|
2086
|
+
}
|
|
2087
|
+
};
|
|
2079
2088
|
var processLockObservationCache = /* @__PURE__ */ new Map();
|
|
2080
2089
|
var inferenceProcessIdentitiesMatch = (stored, observed) => stored === observed;
|
|
2081
2090
|
async function ensureInferencePrivateDirectory(path, dependencies = {}) {
|
|
@@ -2291,6 +2300,10 @@ var inspectProcessLockFile = async (path, label, probes) => {
|
|
|
2291
2300
|
const cached = processLockObservationCache.get(cacheKey);
|
|
2292
2301
|
const observedIdentity = cached && cached.dev === stat.dev && cached.ino === stat.ino && cached.pid === ownerPid && cached.storedIdentity === storedIdentity && Date.now() - cached.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached.observedIdentity : await probes.observeIdentity(ownerPid);
|
|
2293
2302
|
if (!observedIdentity) {
|
|
2303
|
+
if (!probes.isProcessAlive(ownerPid)) {
|
|
2304
|
+
stale = true;
|
|
2305
|
+
return { state: "stale", handle, stat };
|
|
2306
|
+
}
|
|
2294
2307
|
throw new Error("Inference host could not verify the existing lock owner identity.");
|
|
2295
2308
|
}
|
|
2296
2309
|
processLockObservationCache.set(cacheKey, {
|
|
@@ -2466,15 +2479,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
2466
2479
|
const probes = {
|
|
2467
2480
|
currentBootIdentity: dependencies.currentBootIdentity ?? (() => readInferenceSystemBootIdentity()),
|
|
2468
2481
|
observeIdentity: dependencies.processIdentity ?? defaultProcessIdentity,
|
|
2469
|
-
isProcessAlive: dependencies.processAlive ??
|
|
2470
|
-
try {
|
|
2471
|
-
process.kill(pid, 0);
|
|
2472
|
-
return true;
|
|
2473
|
-
} catch (error) {
|
|
2474
|
-
if (error.code === "ESRCH") return false;
|
|
2475
|
-
throw error;
|
|
2476
|
-
}
|
|
2477
|
-
})
|
|
2482
|
+
isProcessAlive: dependencies.processAlive ?? processExists
|
|
2478
2483
|
};
|
|
2479
2484
|
const [ownerIdentity, bootIdentity] = await Promise.all([
|
|
2480
2485
|
(dependencies.currentProcessIdentity ?? defaultCurrentProcessIdentity)(),
|
|
@@ -2554,6 +2559,7 @@ var launcherSibling = (manifest, suffix) => {
|
|
|
2554
2559
|
if (!manifest.endsWith(".service.json")) throw new Error("Invalid service manifest path.");
|
|
2555
2560
|
return `${manifest.slice(0, -".service.json".length)}${suffix}`;
|
|
2556
2561
|
};
|
|
2562
|
+
var launcherLockPath = (manifest) => launcherSibling(manifest, ".service-launcher.lock");
|
|
2557
2563
|
var within = (parent, child) => {
|
|
2558
2564
|
const part = relative2(resolve2(parent), resolve2(child));
|
|
2559
2565
|
return Boolean(part) && !part.startsWith("..") && !isAbsolute2(part);
|
|
@@ -2614,7 +2620,7 @@ var targetForSelection = async (selection) => {
|
|
|
2614
2620
|
// lib/inference-host/service-launcher.ts
|
|
2615
2621
|
var runInferenceHostServiceLauncher = async (manifestPathValue, lockPathValue, dependencies = {}) => {
|
|
2616
2622
|
const manifestPath = resolve3(manifestPathValue);
|
|
2617
|
-
const lock = await acquireInferenceHostProcessLock(
|
|
2623
|
+
const lock = await acquireInferenceHostProcessLock(launcherLockPath(manifestPath));
|
|
2618
2624
|
const lifetime = new AbortController();
|
|
2619
2625
|
let child = null;
|
|
2620
2626
|
const stop = () => {
|
|
@@ -2676,8 +2682,8 @@ var runInferenceHostServiceLauncher = async (manifestPathValue, lockPathValue, d
|
|
|
2676
2682
|
manifest = JSON.parse(await readFile3(manifestPath, "utf8"));
|
|
2677
2683
|
let state = await readLauncherState(manifestPath);
|
|
2678
2684
|
if (!state) throw new Error("Service launcher recovery state is missing.");
|
|
2679
|
-
const rollback = async (reason) => {
|
|
2680
|
-
if (!state.previous || !await desired()) return false;
|
|
2685
|
+
const rollback = async (reason, whileStopped = false) => {
|
|
2686
|
+
if (!state.previous || !whileStopped && !await desired()) return false;
|
|
2681
2687
|
const failed = state.active;
|
|
2682
2688
|
await writeLauncherSelection(manifestPath, state.previous.selection);
|
|
2683
2689
|
await writeAtomicInferencePrivateFile(launcherSibling(manifestPath, ".service-release-rejection.json"), `${JSON.stringify({
|
|
@@ -2693,20 +2699,31 @@ var runInferenceHostServiceLauncher = async (manifestPathValue, lockPathValue, d
|
|
|
2693
2699
|
return true;
|
|
2694
2700
|
};
|
|
2695
2701
|
if (state.pending && state.previous && await desired()) await rollback("bootstrap_interrupted_before_readiness");
|
|
2702
|
+
const endAttemptForStop = async () => {
|
|
2703
|
+
if (state.pending) {
|
|
2704
|
+
state.pending = false;
|
|
2705
|
+
await writeLauncherState(manifestPath, state);
|
|
2706
|
+
}
|
|
2707
|
+
return 0;
|
|
2708
|
+
};
|
|
2696
2709
|
while (await desired()) {
|
|
2697
2710
|
state.pending = true;
|
|
2698
2711
|
await writeLauncherState(manifestPath, state);
|
|
2699
|
-
if (!await desired()) return
|
|
2712
|
+
if (!await desired()) return await endAttemptForStop();
|
|
2700
2713
|
const launchedAt = Date.now();
|
|
2701
2714
|
const runtimePath = launcherSibling(manifestPath, ".service-runtime.json");
|
|
2702
2715
|
await rm3(runtimePath, { force: true });
|
|
2703
|
-
if (!await desired()) return
|
|
2716
|
+
if (!await desired()) return await endAttemptForStop();
|
|
2717
|
+
let stopRequested = false;
|
|
2704
2718
|
child = runCore(manifest.executable, state.active, ["--service-manifest", manifestPath, "--service-lock", resolve3(lockPathValue)]);
|
|
2705
2719
|
const readiness = new AbortController();
|
|
2706
2720
|
const watchingStop = new AbortController();
|
|
2707
2721
|
const stopped = (async () => {
|
|
2708
2722
|
while (!watchingStop.signal.aborted) {
|
|
2709
|
-
if (!await desired())
|
|
2723
|
+
if (!await desired()) {
|
|
2724
|
+
stopRequested = true;
|
|
2725
|
+
return { kind: "stop", code: 0 };
|
|
2726
|
+
}
|
|
2710
2727
|
await new Promise((done) => {
|
|
2711
2728
|
if (watchingStop.signal.aborted) {
|
|
2712
2729
|
done();
|
|
@@ -2798,7 +2815,12 @@ var runInferenceHostServiceLauncher = async (manifestPathValue, lockPathValue, d
|
|
|
2798
2815
|
}
|
|
2799
2816
|
}
|
|
2800
2817
|
}
|
|
2801
|
-
|
|
2818
|
+
const failedReadiness = first.kind === "timeout" || first.kind === "exit" && first.code !== 0 && first.code !== EXIT_CODE_TEMPFAIL;
|
|
2819
|
+
const failure = first.kind === "timeout" ? "bootstrap_readiness_timeout" : "bootstrap_exited";
|
|
2820
|
+
if (!await desired()) {
|
|
2821
|
+
if (failedReadiness) await rollback(failure, true);
|
|
2822
|
+
return await endAttemptForStop();
|
|
2823
|
+
}
|
|
2802
2824
|
if (code === EXIT_CODE_TEMPFAIL) {
|
|
2803
2825
|
const selected = await readLauncherSelection(manifestPath);
|
|
2804
2826
|
if (selected && selected.package_version !== state.active.package_version) {
|
|
@@ -2818,13 +2840,19 @@ var runInferenceHostServiceLauncher = async (manifestPathValue, lockPathValue, d
|
|
|
2818
2840
|
await writeLauncherState(manifestPath, state);
|
|
2819
2841
|
continue;
|
|
2820
2842
|
}
|
|
2821
|
-
state = {
|
|
2843
|
+
state = {
|
|
2844
|
+
schema_version: state.schema_version,
|
|
2845
|
+
active: next,
|
|
2846
|
+
previous: failedReadiness ? state.previous : state.active,
|
|
2847
|
+
pending: false
|
|
2848
|
+
};
|
|
2822
2849
|
await writeLauncherState(manifestPath, state);
|
|
2823
2850
|
await log("service_launcher_handoff", next.package_version);
|
|
2824
2851
|
continue;
|
|
2825
2852
|
}
|
|
2826
2853
|
}
|
|
2827
|
-
if (!
|
|
2854
|
+
if (!failedReadiness && (stopRequested || first.kind === "ready" && code === 0)) continue;
|
|
2855
|
+
if (!await rollback(failure)) return code || 1;
|
|
2828
2856
|
}
|
|
2829
2857
|
return 0;
|
|
2830
2858
|
} finally {
|
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.58", 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
|
|
|
@@ -4911,15 +4911,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
4911
4911
|
const probes = {
|
|
4912
4912
|
currentBootIdentity: dependencies.currentBootIdentity ?? (() => readInferenceSystemBootIdentity()),
|
|
4913
4913
|
observeIdentity: dependencies.processIdentity ?? defaultProcessIdentity,
|
|
4914
|
-
isProcessAlive: dependencies.processAlive ??
|
|
4915
|
-
try {
|
|
4916
|
-
process.kill(pid, 0);
|
|
4917
|
-
return true;
|
|
4918
|
-
} catch (error48) {
|
|
4919
|
-
if (error48.code === "ESRCH") return false;
|
|
4920
|
-
throw error48;
|
|
4921
|
-
}
|
|
4922
|
-
})
|
|
4914
|
+
isProcessAlive: dependencies.processAlive ?? processExists
|
|
4923
4915
|
};
|
|
4924
4916
|
const [ownerIdentity, bootIdentity] = await Promise.all([
|
|
4925
4917
|
(dependencies.currentProcessIdentity ?? defaultCurrentProcessIdentity)(),
|
|
@@ -4991,7 +4983,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
4991
4983
|
}
|
|
4992
4984
|
};
|
|
4993
4985
|
}
|
|
4994
|
-
var HOST_CORE_POLICY, loadInferenceReceiptDurabilityTimeoutMs, loadInferenceAgentDataRequestTimeoutMs, loadInferenceAgentCommandLockPolicy, InferenceHostProcessLockBusyError, INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, WINDOWS_PRIVATE_ACL_MODES, WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS, WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS, SMALL_IDENTITY_COMMAND_TIMEOUT_MS, windowsPowerShellEnvironment, windowsPrivateAclBrokerInvocation, WindowsPrivateAclBroker, defaultWindowsPrivateAclBroker, runWindowsPrivateAcl, windowsAclCache, windowsAclIdentity, aclCacheKey, secureWindowsPrivatePath, invalidateWindowsAclCache, rebindHardenedWindowsAclAfterRename, rebindHardenedWindowsDirectoryAfterOwnedMutation, isWindowsPrivateAclVerificationFailure, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentityInvocation, windowsBootIdentityInvocation, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, cachedCurrentProcessIdentity, defaultCurrentProcessIdentity, readInferenceHostProcessLockStatus, processLockObservationCache, inferenceProcessIdentitiesMatch, resolveInferenceHostApiUrl, inferenceHostSupervisorServiceManifestPath, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig, WINDOWS_PRIVATE_FILE_REPLACE_ERROR_CODES, PROCESS_LOCK_PUBLICATION_GRACE_MS, PROCESS_LOCK_MAX_RECORD_BYTES, PROCESS_LOCK_GUARD_ELECTION_LEASE_MS, PROCESS_LOCK_GUARD_ELECTION_STALE_MS, PROCESS_LOCK_GUARD_ELECTION_ATTEMPTS, PROCESS_LOCK_GUARD_ELECTION_BACKOFF_MS, PROCESS_LOCK_LABEL, PROCESS_LOCK_GUARD_LABEL, sameProcessLockFile, openExclusiveProcessLockFile, inspectProcessLockFile, removeVerifiedStaleProcessLockFile, removeStaleProcessLockReclaimGuard, acquireProcessLockReclaimGuard;
|
|
4986
|
+
var HOST_CORE_POLICY, loadInferenceReceiptDurabilityTimeoutMs, loadInferenceAgentDataRequestTimeoutMs, loadInferenceAgentCommandLockPolicy, InferenceHostProcessLockBusyError, INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, WINDOWS_PRIVATE_ACL_MODES, WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS, WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS, SMALL_IDENTITY_COMMAND_TIMEOUT_MS, windowsPowerShellEnvironment, windowsPrivateAclBrokerInvocation, WindowsPrivateAclBroker, defaultWindowsPrivateAclBroker, runWindowsPrivateAcl, windowsAclCache, windowsAclIdentity, aclCacheKey, secureWindowsPrivatePath, invalidateWindowsAclCache, rebindHardenedWindowsAclAfterRename, rebindHardenedWindowsDirectoryAfterOwnedMutation, isWindowsPrivateAclVerificationFailure, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentityInvocation, windowsBootIdentityInvocation, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, cachedCurrentProcessIdentity, defaultCurrentProcessIdentity, processExists, readInferenceHostProcessLockStatus, processLockObservationCache, inferenceProcessIdentitiesMatch, resolveInferenceHostApiUrl, inferenceHostSupervisorServiceManifestPath, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig, WINDOWS_PRIVATE_FILE_REPLACE_ERROR_CODES, PROCESS_LOCK_PUBLICATION_GRACE_MS, PROCESS_LOCK_MAX_RECORD_BYTES, PROCESS_LOCK_GUARD_ELECTION_LEASE_MS, PROCESS_LOCK_GUARD_ELECTION_STALE_MS, PROCESS_LOCK_GUARD_ELECTION_ATTEMPTS, PROCESS_LOCK_GUARD_ELECTION_BACKOFF_MS, PROCESS_LOCK_LABEL, PROCESS_LOCK_GUARD_LABEL, sameProcessLockFile, openExclusiveProcessLockFile, inspectProcessLockFile, removeVerifiedStaleProcessLockFile, removeStaleProcessLockReclaimGuard, acquireProcessLockReclaimGuard;
|
|
4995
4987
|
var init_config2 = __esm({
|
|
4996
4988
|
"lib/inference-host/config.ts"() {
|
|
4997
4989
|
"use strict";
|
|
@@ -5609,6 +5601,15 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
5609
5601
|
throw error48;
|
|
5610
5602
|
}
|
|
5611
5603
|
};
|
|
5604
|
+
processExists = (pid) => {
|
|
5605
|
+
try {
|
|
5606
|
+
process.kill(pid, 0);
|
|
5607
|
+
return true;
|
|
5608
|
+
} catch (error48) {
|
|
5609
|
+
if (error48.code === "ESRCH") return false;
|
|
5610
|
+
throw error48;
|
|
5611
|
+
}
|
|
5612
|
+
};
|
|
5612
5613
|
readInferenceHostProcessLockStatus = async (path) => {
|
|
5613
5614
|
const raw = await readInferencePrivateFile(path, "Inference host process lock");
|
|
5614
5615
|
if (raw === null) return { state: "not_running" };
|
|
@@ -5622,7 +5623,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
5622
5623
|
readInferenceSystemBootIdentity()
|
|
5623
5624
|
]);
|
|
5624
5625
|
if (boot !== owner2.boot_identity) return { state: "stale" };
|
|
5625
|
-
if (identity3 === null) return { state: "unknown" };
|
|
5626
|
+
if (identity3 === null) return { state: processExists(owner2.pid) ? "unknown" : "stale" };
|
|
5626
5627
|
return { state: identity3 === owner2.process_identity ? "running" : "stale" };
|
|
5627
5628
|
} catch {
|
|
5628
5629
|
return { state: "unknown" };
|
|
@@ -5740,6 +5741,10 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
5740
5741
|
const cached2 = processLockObservationCache.get(cacheKey);
|
|
5741
5742
|
const observedIdentity = cached2 && cached2.dev === stat2.dev && cached2.ino === stat2.ino && cached2.pid === ownerPid && cached2.storedIdentity === storedIdentity && Date.now() - cached2.observedAtMs < HOST_CORE_POLICY.process_lock_identity_cache_ms ? cached2.observedIdentity : await probes.observeIdentity(ownerPid);
|
|
5742
5743
|
if (!observedIdentity) {
|
|
5744
|
+
if (!probes.isProcessAlive(ownerPid)) {
|
|
5745
|
+
stale = true;
|
|
5746
|
+
return { state: "stale", handle, stat: stat2 };
|
|
5747
|
+
}
|
|
5743
5748
|
throw new Error("Inference host could not verify the existing lock owner identity.");
|
|
5744
5749
|
}
|
|
5745
5750
|
processLockObservationCache.set(cacheKey, {
|
|
@@ -44363,7 +44368,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44363
44368
|
}
|
|
44364
44369
|
}
|
|
44365
44370
|
if ((options.platform ?? process.platform) !== "win32") {
|
|
44366
|
-
const
|
|
44371
|
+
const processExists2 = options.processExists ?? ((pid) => {
|
|
44367
44372
|
try {
|
|
44368
44373
|
process.kill(pid, 0);
|
|
44369
44374
|
return true;
|
|
@@ -44371,7 +44376,7 @@ $items = @(Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('node.ex
|
|
|
44371
44376
|
return error48.code !== "ESRCH";
|
|
44372
44377
|
}
|
|
44373
44378
|
});
|
|
44374
|
-
if ([...pids].some((pid) =>
|
|
44379
|
+
if ([...pids].some((pid) => processExists2(pid)) || processExists2(-options.guardianPid)) {
|
|
44375
44380
|
throw new Error("Codex guardian process tree is still running; recovery evidence was preserved.");
|
|
44376
44381
|
}
|
|
44377
44382
|
return;
|
|
@@ -50696,7 +50701,7 @@ var init_durable_adapter = __esm({
|
|
|
50696
50701
|
// lib/inference-host/service-launcher-state.ts
|
|
50697
50702
|
import { access as access6, readFile as readFile12, rm as rm15 } from "node:fs/promises";
|
|
50698
50703
|
import { dirname as dirname16, isAbsolute as isAbsolute7, join as join17, relative as relative4, resolve as resolve13 } from "node:path";
|
|
50699
|
-
var launcherSibling, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
|
|
50704
|
+
var launcherSibling, launcherLockPath, within, launcherSelection, readLauncherSelection, readLauncherState, writeLauncherState, targetForSelection;
|
|
50700
50705
|
var init_service_launcher_state = __esm({
|
|
50701
50706
|
"lib/inference-host/service-launcher-state.ts"() {
|
|
50702
50707
|
"use strict";
|
|
@@ -50709,6 +50714,7 @@ var init_service_launcher_state = __esm({
|
|
|
50709
50714
|
if (!manifest.endsWith(".service.json")) throw new Error("Invalid service manifest path.");
|
|
50710
50715
|
return `${manifest.slice(0, -".service.json".length)}${suffix}`;
|
|
50711
50716
|
};
|
|
50717
|
+
launcherLockPath = (manifest) => launcherSibling(manifest, ".service-launcher.lock");
|
|
50712
50718
|
within = (parent, child) => {
|
|
50713
50719
|
const part = relative4(resolve13(parent), resolve13(child));
|
|
50714
50720
|
return Boolean(part) && !part.startsWith("..") && !isAbsolute7(part);
|
|
@@ -50771,7 +50777,7 @@ import { homedir as homedir4 } from "node:os";
|
|
|
50771
50777
|
import { dirname as dirname17, join as join18, resolve as resolve14 } from "node:path";
|
|
50772
50778
|
import { Transform } from "node:stream";
|
|
50773
50779
|
import { pipeline } from "node:stream/promises";
|
|
50774
|
-
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, ATOMIC_REPLACEMENT_READ_ATTEMPTS, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRotatedLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, serviceLogSinks, serviceLogSize, rotateServiceLog, writeServiceLog, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
50780
|
+
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_POLICY, ATOMIC_REPLACEMENT_READ_ATTEMPTS, SERVICE_COOPERATIVE_STOP_SECONDS, pollAttemptsWithin, lockStillHeld, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, INFERENCE_HOST_SERVICE_QUIESCE_COMMAND, InferenceHostBootstrapRestartRequiredError, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRotatedLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, probeInferenceHostLauncher, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment, serviceBootstrapArguments, windowsOwnedCommandLine, vbScriptString, windowsServiceLauncher, windowsTaskXml, systemdUnit, launchAgentPlist, sameWorker, sameServiceDefinition, sameWorkerSet, InferenceHostServiceManager, serviceLogSinks, serviceLogSize, rotateServiceLog, writeServiceLog, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
50775
50781
|
var init_service = __esm({
|
|
50776
50782
|
"lib/inference-host/service.ts"() {
|
|
50777
50783
|
"use strict";
|
|
@@ -50793,6 +50799,7 @@ var init_service = __esm({
|
|
|
50793
50799
|
ATOMIC_REPLACEMENT_READ_ATTEMPTS = runtime_policy_generated_default.external_inference.host_core.atomic_replacement_read_attempts;
|
|
50794
50800
|
SERVICE_COOPERATIVE_STOP_SECONDS = Math.ceil(SERVICE_POLICY.cooperative_stop_timeout_ms / MS_PER_SECOND);
|
|
50795
50801
|
pollAttemptsWithin = (milliseconds) => Math.ceil(milliseconds / SERVICE_POLICY.startup_poll_interval_ms);
|
|
50802
|
+
lockStillHeld = (error48) => error48 instanceof Error && (error48.message.includes("Another inference host process already owns") || error48.message.includes("could not verify the existing lock owner identity"));
|
|
50796
50803
|
INFERENCE_HOST_SERVICE_DRAIN_COMMAND = "vtx-inference-host-service-drain-v1";
|
|
50797
50804
|
INFERENCE_HOST_SERVICE_QUIESCE_COMMAND = "vtx-inference-host-service-quiesce-v1";
|
|
50798
50805
|
InferenceHostBootstrapRestartRequiredError = class extends Error {
|
|
@@ -51358,6 +51365,7 @@ WantedBy=default.target
|
|
|
51358
51365
|
generation: randomUUID12(),
|
|
51359
51366
|
installed_at: this.now().toISOString()
|
|
51360
51367
|
});
|
|
51368
|
+
await this.awaitNoLauncherFinishingStop();
|
|
51361
51369
|
await writeAtomicInferencePrivateFile(
|
|
51362
51370
|
this.manifestPath(),
|
|
51363
51371
|
`${JSON.stringify(restoredManifest, null, JSON_INDENT_SPACES)}
|
|
@@ -51437,6 +51445,7 @@ ${result.stderr}`)) {
|
|
|
51437
51445
|
this.serviceBootstrapLockPath()
|
|
51438
51446
|
);
|
|
51439
51447
|
const definition = this.platform === "win32" ? windowsTaskXml(this.windowsLauncherPath(), this.windowsDirectory, this.username) : this.platform === "darwin" ? launchAgentPlist(manifest.executable, args, manifest.log_path) : systemdUnit(manifest.executable, args);
|
|
51448
|
+
if (desiredRunning) await this.awaitNoLauncherFinishingStop();
|
|
51440
51449
|
const existingRecovery = await readLauncherState(this.manifestPath());
|
|
51441
51450
|
let managerInstallAttempted = false;
|
|
51442
51451
|
try {
|
|
@@ -51582,10 +51591,11 @@ ${cleanup.stderr}`)) {
|
|
|
51582
51591
|
}
|
|
51583
51592
|
if (previous) {
|
|
51584
51593
|
try {
|
|
51585
|
-
await this.uninstallUnlocked(true);
|
|
51594
|
+
await this.uninstallUnlocked({ reconfiguring: true });
|
|
51586
51595
|
} catch (error48) {
|
|
51596
|
+
const restored = await readInferenceHostServiceDesired(this.desiredPath()).catch(() => false);
|
|
51587
51597
|
throw new Error(
|
|
51588
|
-
"Inference-host service reconfiguration could not stop the previous supervisor; its desired state was restored.",
|
|
51598
|
+
restored ? "Inference-host service reconfiguration could not stop the previous supervisor; its desired state was restored." : "Inference-host service reconfiguration could not stop the previous supervisor; it stays stopped.",
|
|
51589
51599
|
{ cause: error48 }
|
|
51590
51600
|
);
|
|
51591
51601
|
}
|
|
@@ -51693,6 +51703,7 @@ ${cleanup.stderr}`)) {
|
|
|
51693
51703
|
if (!await readInferenceHostServiceManifest(this.manifestPath())) {
|
|
51694
51704
|
throw new Error("Inference-host service is not installed.");
|
|
51695
51705
|
}
|
|
51706
|
+
await this.awaitNoLauncherFinishingStop();
|
|
51696
51707
|
await writeDesired(this.desiredPath(), true, this.now());
|
|
51697
51708
|
const result = await this.managerCommand("start");
|
|
51698
51709
|
if (result.exitCode !== 0 && !/already running|in progress/iu.test(`${result.stdout}
|
|
@@ -51708,7 +51719,7 @@ ${result.stderr}`)) {
|
|
|
51708
51719
|
}
|
|
51709
51720
|
}
|
|
51710
51721
|
async stop() {
|
|
51711
|
-
return await this.withControlLock(async () => await this.stopUnlocked());
|
|
51722
|
+
return await this.withControlLock(async () => await this.stopUnlocked({ restoreOnFailure: false }));
|
|
51712
51723
|
}
|
|
51713
51724
|
/**
|
|
51714
51725
|
* Quiesce the complete installed worker boundary while one exact instance's
|
|
@@ -51732,7 +51743,7 @@ ${result.stderr}`)) {
|
|
|
51732
51743
|
await options.prepare?.(context);
|
|
51733
51744
|
const before = await this.status();
|
|
51734
51745
|
if (recordedDesiredRunning || before.manager_active) {
|
|
51735
|
-
await this.stopUnlocked(true);
|
|
51746
|
+
await this.stopUnlocked({ restoreOnFailure: true, preserveManifestGeneration: true });
|
|
51736
51747
|
} else {
|
|
51737
51748
|
await writeDesired(this.desiredPath(), false, this.now());
|
|
51738
51749
|
}
|
|
@@ -51774,44 +51785,98 @@ ${result.stderr}`)) {
|
|
|
51774
51785
|
return { result, status: restoredStatus };
|
|
51775
51786
|
});
|
|
51776
51787
|
}
|
|
51777
|
-
|
|
51788
|
+
/**
|
|
51789
|
+
* True once no process holds any of these locks, false when one still does
|
|
51790
|
+
* after the cooperative-stop window.
|
|
51791
|
+
*/
|
|
51792
|
+
async processLocksReleased(lockPaths) {
|
|
51793
|
+
for (let attempt2 = 0; attempt2 < this.stopWaitAttempts; attempt2 += 1) {
|
|
51794
|
+
let allReleased = true;
|
|
51795
|
+
for (const lockPath of lockPaths) {
|
|
51796
|
+
try {
|
|
51797
|
+
const probe = await this.acquireProcessLock(lockPath);
|
|
51798
|
+
await probe.release();
|
|
51799
|
+
} catch (error48) {
|
|
51800
|
+
if (lockStillHeld(error48)) {
|
|
51801
|
+
allReleased = false;
|
|
51802
|
+
break;
|
|
51803
|
+
}
|
|
51804
|
+
throw error48;
|
|
51805
|
+
}
|
|
51806
|
+
}
|
|
51807
|
+
if (allReleased) return true;
|
|
51808
|
+
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
51809
|
+
}
|
|
51810
|
+
return false;
|
|
51811
|
+
}
|
|
51812
|
+
/**
|
|
51813
|
+
* A stop is no verdict on a release whose readiness attempt it ended. A
|
|
51814
|
+
* stable launcher installed before that rule (it is never replaced) leaves
|
|
51815
|
+
* the attempt pending when it stops, and its next start then rolls the
|
|
51816
|
+
* release back as if it had crashed. Once the stop has outlasted the
|
|
51817
|
+
* launcher, end that attempt here, under the launcher's own lock.
|
|
51818
|
+
*/
|
|
51819
|
+
async endLauncherAttemptForStop() {
|
|
51820
|
+
let lock2 = null;
|
|
51821
|
+
for (let attempt2 = 0; attempt2 < this.stopWaitAttempts && !lock2; attempt2 += 1) {
|
|
51822
|
+
try {
|
|
51823
|
+
lock2 = await this.acquireProcessLock(launcherLockPath(this.manifestPath()));
|
|
51824
|
+
} catch (error48) {
|
|
51825
|
+
if (!lockStillHeld(error48)) throw error48;
|
|
51826
|
+
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
51827
|
+
}
|
|
51828
|
+
}
|
|
51829
|
+
if (!lock2) return;
|
|
51830
|
+
try {
|
|
51831
|
+
const state2 = await readLauncherState(this.manifestPath()).catch(() => null);
|
|
51832
|
+
if (state2?.pending) await writeLauncherState(this.manifestPath(), { ...state2, pending: false });
|
|
51833
|
+
} finally {
|
|
51834
|
+
await lock2.release();
|
|
51835
|
+
}
|
|
51836
|
+
}
|
|
51837
|
+
/**
|
|
51838
|
+
* Desired-running goes back to true only once no launcher is still finishing
|
|
51839
|
+
* a stop. A launcher judges its core's exit by the desired state it reads
|
|
51840
|
+
* afterwards, and the stable launcher an older release installed (it is
|
|
51841
|
+
* never replaced) reads a true there as its ready release failing and rolls
|
|
51842
|
+
* it back.
|
|
51843
|
+
*/
|
|
51844
|
+
async awaitNoLauncherFinishingStop() {
|
|
51845
|
+
if (await readInferenceHostServiceDesired(this.desiredPath())) return;
|
|
51846
|
+
if (!await this.processLocksReleased([launcherLockPath(this.manifestPath())])) {
|
|
51847
|
+
throw new Error(
|
|
51848
|
+
`Inference-host service launcher was still finishing a stop after ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; start the service once it has stopped.`
|
|
51849
|
+
);
|
|
51850
|
+
}
|
|
51851
|
+
}
|
|
51852
|
+
/**
|
|
51853
|
+
* A requested stop (`service stop`, uninstall) fences automatic restart: if
|
|
51854
|
+
* it cannot finish cooperatively it says so and leaves desired-running
|
|
51855
|
+
* false, so the service finishes its in-flight work and stays stopped. Only
|
|
51856
|
+
* the internal quiesces (guarded recovery, a reconfiguration that replaces
|
|
51857
|
+
* the definition) restore the supervisor they paused.
|
|
51858
|
+
*/
|
|
51859
|
+
async stopUnlocked(options) {
|
|
51778
51860
|
const manifest = await readInferenceHostServiceManifest(this.manifestPath());
|
|
51779
51861
|
if (!manifest) {
|
|
51780
51862
|
throw new Error("Inference-host service is not installed.");
|
|
51781
51863
|
}
|
|
51782
|
-
const restoreOnFailure = await readInferenceHostServiceDesired(this.desiredPath());
|
|
51864
|
+
const restoreOnFailure = options.restoreOnFailure && await readInferenceHostServiceDesired(this.desiredPath());
|
|
51865
|
+
const launcherStatus = await readInferenceHostProcessLockStatus(launcherLockPath(this.manifestPath())).catch(() => ({ state: "unknown" }));
|
|
51866
|
+
const launcherWasRunning = launcherStatus.state === "running" || launcherStatus.state === "unknown";
|
|
51783
51867
|
await writeDesired(this.desiredPath(), false, this.now());
|
|
51784
51868
|
try {
|
|
51785
|
-
const
|
|
51869
|
+
const serviceReleased = await this.processLocksReleased([
|
|
51786
51870
|
`${this.config.supervisorProcessLockPath}.service`,
|
|
51787
|
-
this.serviceBootstrapLockPath()
|
|
51788
|
-
|
|
51789
|
-
|
|
51790
|
-
for (let attempt2 = 0; attempt2 < this.stopWaitAttempts; attempt2 += 1) {
|
|
51791
|
-
let allReleased = true;
|
|
51792
|
-
for (const serviceLockPath of serviceLockPaths) {
|
|
51793
|
-
try {
|
|
51794
|
-
const probe = await this.acquireProcessLock(serviceLockPath);
|
|
51795
|
-
await probe.release();
|
|
51796
|
-
} catch (error48) {
|
|
51797
|
-
if (error48 instanceof Error && error48.message.includes("Another inference host process already owns")) {
|
|
51798
|
-
allReleased = false;
|
|
51799
|
-
break;
|
|
51800
|
-
}
|
|
51801
|
-
throw error48;
|
|
51802
|
-
}
|
|
51803
|
-
}
|
|
51804
|
-
if (allReleased) {
|
|
51805
|
-
serviceReleased = true;
|
|
51806
|
-
break;
|
|
51807
|
-
}
|
|
51808
|
-
await this.sleep(SERVICE_POLICY.startup_poll_interval_ms);
|
|
51809
|
-
}
|
|
51871
|
+
this.serviceBootstrapLockPath(),
|
|
51872
|
+
launcherLockPath(this.manifestPath())
|
|
51873
|
+
]);
|
|
51810
51874
|
if (!serviceReleased) {
|
|
51811
51875
|
throw new Error(
|
|
51812
51876
|
`Inference-host updater or workers did not stop cooperatively within ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; refusing forced termination while cleanup may be pending.`
|
|
51813
51877
|
);
|
|
51814
51878
|
}
|
|
51879
|
+
if (launcherWasRunning) await this.endLauncherAttemptForStop();
|
|
51815
51880
|
const result = await this.managerCommand("stop");
|
|
51816
51881
|
if (result.exitCode !== 0 && !/not running|not found|does not exist|not loaded|cannot find|no such process/iu.test(`${result.stdout}
|
|
51817
51882
|
${result.stderr}`)) {
|
|
@@ -51825,7 +51890,7 @@ ${result.stderr}`)) {
|
|
|
51825
51890
|
} catch (error48) {
|
|
51826
51891
|
if (!restoreOnFailure) throw error48;
|
|
51827
51892
|
try {
|
|
51828
|
-
await this.restoreRunningSupervisor(manifest,
|
|
51893
|
+
await this.restoreRunningSupervisor(manifest, options.preserveManifestGeneration ?? false);
|
|
51829
51894
|
} catch (restoreError) {
|
|
51830
51895
|
throw new Error(
|
|
51831
51896
|
"Inference-host stop failed and the previous supervisor could not be restored.",
|
|
@@ -51910,12 +51975,14 @@ ${result.stderr}`)) {
|
|
|
51910
51975
|
async uninstall() {
|
|
51911
51976
|
return await this.withControlLock(async () => await this.uninstallUnlocked());
|
|
51912
51977
|
}
|
|
51913
|
-
|
|
51978
|
+
/** A reconfiguration keeps the recovery files and restores the supervisor it could not stop. */
|
|
51979
|
+
async uninstallUnlocked(options = { reconfiguring: false }) {
|
|
51980
|
+
const preserveRecovery = options.reconfiguring;
|
|
51914
51981
|
const manifest = await readInferenceHostServiceManifest(this.manifestPath());
|
|
51915
51982
|
if (!manifest) throw new Error("Inference-host service is not installed.");
|
|
51916
51983
|
const current = await this.status();
|
|
51917
51984
|
if (current.desired_running || current.manager_active) {
|
|
51918
|
-
await this.stopUnlocked();
|
|
51985
|
+
await this.stopUnlocked({ restoreOnFailure: options.reconfiguring });
|
|
51919
51986
|
} else {
|
|
51920
51987
|
await writeDesired(this.desiredPath(), false, this.now());
|
|
51921
51988
|
}
|
|
@@ -105066,7 +105133,7 @@ var init_execution_capacity = __esm({
|
|
|
105066
105133
|
});
|
|
105067
105134
|
|
|
105068
105135
|
// lib/runtime/owed-protection-warnings.ts
|
|
105069
|
-
var storageKey, isWarning, identity2, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
|
|
105136
|
+
var storageKey, isWarning, identity2, owesProtectionRecord, distinctProtectionWarnings, owedProtectionWarnings, store, oweProtectionWarnings, forgetProtectionWarnings;
|
|
105070
105137
|
var init_owed_protection_warnings = __esm({
|
|
105071
105138
|
"lib/runtime/owed-protection-warnings.ts"() {
|
|
105072
105139
|
"use strict";
|
|
@@ -105081,6 +105148,7 @@ var init_owed_protection_warnings = __esm({
|
|
|
105081
105148
|
return record6 != null && typeof record6 === "object" && typeof record6.symbol === "string" && typeof record6.action === "string" && typeof record6.status === "string" && (record6.order_id === null || typeof record6.order_id === "string") && record6.execution_metadata != null && typeof record6.execution_metadata === "object";
|
|
105082
105149
|
};
|
|
105083
105150
|
identity2 = (warning) => JSON.stringify(warning);
|
|
105151
|
+
owesProtectionRecord = (report) => report.status === "executed" && report.order_id != null && (report.execution_metadata?.entry_order_id != null || report.execution_metadata?.previous_order_id != null);
|
|
105084
105152
|
distinctProtectionWarnings = (warnings) => {
|
|
105085
105153
|
const seen = /* @__PURE__ */ new Set();
|
|
105086
105154
|
return warnings.filter((warning) => {
|
|
@@ -105643,7 +105711,7 @@ var init_protective_leg_evidence = __esm({
|
|
|
105643
105711
|
});
|
|
105644
105712
|
|
|
105645
105713
|
// lib/runtime/protective-entry-cover.ts
|
|
105646
|
-
var protectiveEntryCover, protectiveEntryLegSize;
|
|
105714
|
+
var protectiveLegCoverSize, boundOffThePage, liveStopCoverOnPage, protectiveEntryCoverLegs, protectiveEntryCover, protectiveEntryLegSize;
|
|
105647
105715
|
var init_protective_entry_cover = __esm({
|
|
105648
105716
|
"lib/runtime/protective-entry-cover.ts"() {
|
|
105649
105717
|
"use strict";
|
|
@@ -105651,10 +105719,35 @@ var init_protective_entry_cover = __esm({
|
|
|
105651
105719
|
init_define_VTX_EXO_POLICY();
|
|
105652
105720
|
init_define_VTX_GROK_POLICY();
|
|
105653
105721
|
init_define_VTX_PI_MODEL_POLICY();
|
|
105722
|
+
protectiveLegCoverSize = (leg, restingSize = leg.size) => leg.replacement != null && leg.replacement.size < restingSize ? leg.replacement.size : restingSize;
|
|
105723
|
+
boundOffThePage = (orderId, liveOrderIds) => typeof orderId === "number" && !liveOrderIds.has(String(orderId));
|
|
105724
|
+
liveStopCoverOnPage = (input) => {
|
|
105725
|
+
const closeSides = input.positionSize > 0 ? ["a", "sell"] : ["b", "buy"];
|
|
105726
|
+
const liveOrderIds = new Set(input.orders.map((order) => String(order.oid)));
|
|
105727
|
+
const leaving = new Set(input.groups.filter((group) => group.cleanupRequired === true || group.legs.some((leg) => boundOffThePage(leg.orderId, liveOrderIds))).flatMap((group) => group.legs));
|
|
105728
|
+
const legs = input.groups.flatMap((group) => group.legs);
|
|
105729
|
+
return input.orders.filter((order) => !input.excludedOrderIds.has(String(order.oid)) && String(order.coin).trim().toUpperCase() === input.symbol.trim().toUpperCase() && order.reduce_only && order.is_trigger && order.trigger_kind === "sl" && closeSides.includes(String(order.side).trim().toLowerCase())).reduce((total, order) => {
|
|
105730
|
+
const size = Number(order.sz);
|
|
105731
|
+
const leg = legs.find((candidate) => candidate.orderId === order.oid);
|
|
105732
|
+
if (!(size > 0) || leg != null && leaving.has(leg)) return total;
|
|
105733
|
+
return total + (leg == null ? size : protectiveLegCoverSize(leg, size));
|
|
105734
|
+
}, 0);
|
|
105735
|
+
};
|
|
105736
|
+
protectiveEntryCoverLegs = (groups2, entryIsLong, neverLanded) => groups2.filter((group) => group.isLong === entryIsLong).flatMap((group) => group.legs.map((leg) => ({
|
|
105737
|
+
isLong: group.isLong,
|
|
105738
|
+
kind: leg.kind,
|
|
105739
|
+
size: protectiveLegCoverSize(leg),
|
|
105740
|
+
orderId: typeof leg.orderId === "number" ? leg.orderId : null,
|
|
105741
|
+
canStillExist: !neverLanded(group, leg),
|
|
105742
|
+
beingCancelled: group.cleanupRequired === true,
|
|
105743
|
+
group: group.entryOrderId
|
|
105744
|
+
})));
|
|
105654
105745
|
protectiveEntryCover = (input) => {
|
|
105655
105746
|
const cover = { sl: 0, tp: 0 };
|
|
105747
|
+
const groupsOffThePage = new Set(input.storedLegs.filter((leg) => leg.group != null && boundOffThePage(leg.orderId, input.liveOrderIds)).map((leg) => leg.group));
|
|
105656
105748
|
for (const leg of input.storedLegs) {
|
|
105657
105749
|
if (leg.isLong !== input.entryIsLong || leg.beingCancelled === true) continue;
|
|
105750
|
+
if (leg.group != null && groupsOffThePage.has(leg.group)) continue;
|
|
105658
105751
|
const rests = leg.orderId == null ? leg.canStillExist : input.liveOrderIds.has(String(leg.orderId));
|
|
105659
105752
|
if (rests) cover[leg.kind] += leg.size;
|
|
105660
105753
|
}
|
|
@@ -105688,6 +105781,30 @@ var init_protective_oversized_leg = __esm({
|
|
|
105688
105781
|
}
|
|
105689
105782
|
});
|
|
105690
105783
|
|
|
105784
|
+
// lib/runtime/protective-report-entry.ts
|
|
105785
|
+
var executedProtectiveReport;
|
|
105786
|
+
var init_protective_report_entry = __esm({
|
|
105787
|
+
"lib/runtime/protective-report-entry.ts"() {
|
|
105788
|
+
"use strict";
|
|
105789
|
+
init_define_VTX_CLAUDE_CODE_POLICY();
|
|
105790
|
+
init_define_VTX_EXO_POLICY();
|
|
105791
|
+
init_define_VTX_GROK_POLICY();
|
|
105792
|
+
init_define_VTX_PI_MODEL_POLICY();
|
|
105793
|
+
executedProtectiveReport = (input) => ({
|
|
105794
|
+
order_id: input.orderId,
|
|
105795
|
+
...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
|
|
105796
|
+
symbol: input.symbol,
|
|
105797
|
+
action: input.action,
|
|
105798
|
+
status: "executed",
|
|
105799
|
+
execution_metadata: {
|
|
105800
|
+
...input.metadata,
|
|
105801
|
+
protected_size: input.protectedSize,
|
|
105802
|
+
position_tpsl: input.positionTpsl
|
|
105803
|
+
}
|
|
105804
|
+
});
|
|
105805
|
+
}
|
|
105806
|
+
});
|
|
105807
|
+
|
|
105691
105808
|
// lib/runtime/native-position-protection.ts
|
|
105692
105809
|
var nativeProtectionSettings, memberSetting, KINDS, formatTriggerOrNull, nativePositionTriggerPrice, nativeEntryRequest, HALF_UP_DIGIT, roundDecimalHalfUp, nativeTrailingRetracement, nativeAfterFillActions, classifyNativeOrderEnd, isOpenInDirection, nativePlacementGate, nativeStrayOrderDecision, FIRED_TRIGGER_CONDITION, TRAILING_ORDER_TYPE, closingSide, DECIMAL_PATTERN, decimalUnits2, fractionDigits, nativePlaceCover, positiveOrderId, nativeRearmDecision, nativeLostStopCrossed, readListedProtectiveRow, explainAbsentProtectiveOrder, readServerNativeProtectionState, nativeFillOpenedPosition, nativePositionEndedSince, flatReadEndsPosition;
|
|
105693
105810
|
var init_native_position_protection = __esm({
|
|
@@ -106233,14 +106350,23 @@ var init_native_protection_device = __esm({
|
|
|
106233
106350
|
if (!stopLoss?.trailing || !(Number(size) > 0)) return null;
|
|
106234
106351
|
return nativeTrailingRetracement({ mode: stopLoss.mode, value: stopLoss.value, lotSize: Number(size), sizeDecimals });
|
|
106235
106352
|
};
|
|
106236
|
-
lotReport = (symbol2, lot, status, metadata) =>
|
|
106237
|
-
|
|
106238
|
-
|
|
106239
|
-
|
|
106240
|
-
|
|
106241
|
-
|
|
106242
|
-
|
|
106243
|
-
|
|
106353
|
+
lotReport = (symbol2, lot, status, metadata) => {
|
|
106354
|
+
const entry = status === "executed" ? lotFillOrderId(lot) : null;
|
|
106355
|
+
return {
|
|
106356
|
+
order_id: lot.orderId == null ? null : String(lot.orderId),
|
|
106357
|
+
symbol: symbol2,
|
|
106358
|
+
// The lot is the trailing stop; the whole-position stop stays AUTO_SL (protective_fill_attribution.leg_action).
|
|
106359
|
+
action: "AUTO_TRAILING_SL",
|
|
106360
|
+
status,
|
|
106361
|
+
execution_metadata: {
|
|
106362
|
+
trailing_lot: true,
|
|
106363
|
+
protected_size: lot.size,
|
|
106364
|
+
retracement: lot.retracement,
|
|
106365
|
+
...metadata,
|
|
106366
|
+
...entry != null ? { entry_order_id: entry } : {}
|
|
106367
|
+
}
|
|
106368
|
+
};
|
|
106369
|
+
};
|
|
106244
106370
|
sendTrailingLot = async (args) => {
|
|
106245
106371
|
const { io } = args;
|
|
106246
106372
|
if (!io.placeTrailingLot) return { lot: args.lot, report: null };
|
|
@@ -106539,7 +106665,8 @@ var init_native_protection_device = __esm({
|
|
|
106539
106665
|
trigger_price: trigger,
|
|
106540
106666
|
position_tpsl: true,
|
|
106541
106667
|
protected_size: args.protectedSize,
|
|
106542
|
-
|
|
106668
|
+
// The same stop: VTX records it under its predecessor's decision.
|
|
106669
|
+
...newOrderId != null ? { replaced_order_id: String(orderId), previous_order_id: String(orderId) } : {}
|
|
106543
106670
|
}
|
|
106544
106671
|
}
|
|
106545
106672
|
};
|
|
@@ -107191,6 +107318,9 @@ var init_native_protection_device = __esm({
|
|
|
107191
107318
|
execution_metadata: {
|
|
107192
107319
|
reason_code: retried ? "protective_place_rejected" : refused ? retiredReason : args.reasonCode,
|
|
107193
107320
|
...args.member.orderId != null ? { replaced_order_id: String(args.member.orderId) } : {},
|
|
107321
|
+
// A lost stop placed again as the same stop (not a re-arm on a new
|
|
107322
|
+
// position): VTX records it under its predecessor's decision.
|
|
107323
|
+
...!refused && args.member.orderId != null && args.reasonCode === "protective_stop_replaced" ? { previous_order_id: String(args.member.orderId) } : {},
|
|
107194
107324
|
trigger_price: args.trigger,
|
|
107195
107325
|
position_tpsl: true,
|
|
107196
107326
|
protected_size: Math.abs(position.size),
|
|
@@ -107714,7 +107844,7 @@ var init_native_protection_device = __esm({
|
|
|
107714
107844
|
});
|
|
107715
107845
|
|
|
107716
107846
|
// lib/runtime/runtime-execution.ts
|
|
107717
|
-
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _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, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction,
|
|
107847
|
+
var clientProtectiveMutationAuthority, executionReadPriority, serverEntryLeverageAlreadyHeld, fetchClientRuntimeOpenOrders, createRuntimeId, _extractFilledSize, firstMemberAcknowledgement, _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, replacementJournalEntryOrderId, buildProtectiveReplacementJournalGroup, isProtectiveReplacementJournalGroup, reserveProtectiveLegReplacement, ensureProtectiveReplacementJournalCompanion, buildVetoedProtectiveReplacementCleanup, assertExactProtectiveReplacementDispatchAuthority, transitionProtectiveReplacementAcknowledgement, transitionTerminalProtectiveReplacement, pendingProtectiveReplacementReport, isConfiguredProtectionRequested, protectiveAction, 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, nativeSettingsOf, nativePassEnded, nativeProtectionIo, nativeStorageReport, readNativeRecord, reconcileNativeProtectionForDecision, reconcileClientProtectiveGroups, cancelAllClientProtectiveGroups, modifyClientTrailingLeg, trailingRatchetIo, isDefinitiveEntryRejection, resolveExchangeSizeDecimals, roundAssetSize, resolvePositionSize, readServerOrderMarkPrice, serverOrderMetadataRetry, resolveCurrentPositionSize, buildPositionSnapshot, signedRemainingExposureAfterConfirmedReduction, runtimeProtectionAuthority, runtimeProtectionListings, runtimeProtectionListing, resolveServerNativeEntry, SERVER_NATIVE_LEGACY_REFUSAL, isServerNativeLegacyRefusal, serverUserCancelLookup, serverModeProtectionOwner, runtimeProtectionOwners, resolveRuntimeProtectionOwner, drainServerProtectionForRuntime, drainServerProtectionIfOwned, verifyNoLiveClientProtectiveTriggers, clientExecutionMutations, CLIENT_EXECUTION_QUEUE_TIMEOUT_MESSAGE, withClientExecutionMutation, withClientProtectivePlanSetMutation, allocateServerExecutionCapacity, withClientProtectiveAdoptionMutation, executeClientRuntimeDecisionLocked, unsentDecisionOrderReport, SERVER_AUDIT_RECORDED_ELSEWHERE, serverExecutionAuditOutcome, decisionLegOf, withExecutionAuditId, executeClientRuntimeDecision, waitForFlipCloseFreshness, nextClientTrailingStopDueAtMs, ratchetClientTrailingStopsBetweenCycles, listPendingClientProtectiveSymbols, listStoredClientProtectiveSymbols, hasUnresolvedClientProtectiveIdentity, resolveClientProtectiveIdentitiesForAdoption, exportClientProtectiveGroupsForAdoption, adoptionGroupKey, applyClientProtectiveAdoptionOutcomes, hasStoredClientProtectiveGroupsForWallet, hasPendingClientProtectiveGroups, recoverManualClientProtectiveGroups, listStoredClientProtectionSymbols, clientRuntimeDecisionSizesOrders, COMMITTED_EXECUTION_REPORTS, COMMITTED_DECISION_ORDER, getCommittedExecutionReports, getCommittedDecisionOrder, withCommittedExecutionReports, executeClientRuntimeDecisionUnlocked;
|
|
107718
107848
|
var init_runtime_execution = __esm({
|
|
107719
107849
|
"lib/runtime/runtime-execution.ts"() {
|
|
107720
107850
|
"use strict";
|
|
@@ -107749,6 +107879,7 @@ var init_runtime_execution = __esm({
|
|
|
107749
107879
|
init_protective_stop_replacement();
|
|
107750
107880
|
init_protective_entry_cover();
|
|
107751
107881
|
init_protective_oversized_leg();
|
|
107882
|
+
init_protective_report_entry();
|
|
107752
107883
|
init_error_surface_contract();
|
|
107753
107884
|
init_native_position_protection();
|
|
107754
107885
|
init_native_protection_device();
|
|
@@ -108771,18 +108902,6 @@ var init_runtime_execution = __esm({
|
|
|
108771
108902
|
input.executionContext.takeProfitMode === "usdc" ? input.executionContext.takeProfitUsdc : input.executionContext.takeProfitPct
|
|
108772
108903
|
) > 0);
|
|
108773
108904
|
protectiveAction = (leg) => leg.kind === "sl" ? "AUTO_SL" : "AUTO_TP";
|
|
108774
|
-
executedProtectiveReport = (input) => ({
|
|
108775
|
-
order_id: input.orderId,
|
|
108776
|
-
...input.clientMutationId !== void 0 ? { client_mutation_id: input.clientMutationId } : {},
|
|
108777
|
-
symbol: input.symbol,
|
|
108778
|
-
action: input.action,
|
|
108779
|
-
status: "executed",
|
|
108780
|
-
execution_metadata: {
|
|
108781
|
-
...input.metadata,
|
|
108782
|
-
protected_size: input.protectedSize,
|
|
108783
|
-
position_tpsl: input.positionTpsl
|
|
108784
|
-
}
|
|
108785
|
-
});
|
|
108786
108905
|
isExactClientPositionTpslPair = (legs) => legs.length === CLIENT_PROTECTIVE_TPSL_PAIR_LEGS && legs.every((leg) => leg.positionTpsl === true) && new Set(legs.map((leg) => leg.kind)).size === CLIENT_PROTECTIVE_TPSL_PAIR_LEGS;
|
|
108787
108906
|
deviceOwnsClientProtectiveLegKind = (group, kind) => group.deviceOwnedLegKinds == null || group.deviceOwnedLegKinds.includes(kind);
|
|
108788
108907
|
isAdoptionNarrowedPositionTpslLeg = (group) => group.deviceOwnedLegKinds?.length === 1 && group.legs.length === 1 && group.legs[0].positionTpsl === true && group.legs[0].kind === group.deviceOwnedLegKinds[0];
|
|
@@ -109000,14 +109119,11 @@ var init_runtime_execution = __esm({
|
|
|
109000
109119
|
};
|
|
109001
109120
|
attachmentMemberNeverLanded = (group, leg) => group.attachmentJournal?.members.some((member) => member.clientOrderId === leg.orderId && member.neverLandedAtMs != null) === true;
|
|
109002
109121
|
storedClientProtectiveCover = async (request, entryIsLong, groups2) => {
|
|
109003
|
-
const storedLegs =
|
|
109004
|
-
|
|
109005
|
-
|
|
109006
|
-
|
|
109007
|
-
|
|
109008
|
-
canStillExist: !attachmentMemberNeverLanded(group, leg),
|
|
109009
|
-
beingCancelled: group.cleanupRequired === true
|
|
109010
|
-
})));
|
|
109122
|
+
const storedLegs = protectiveEntryCoverLegs(
|
|
109123
|
+
groups2,
|
|
109124
|
+
entryIsLong,
|
|
109125
|
+
(group, leg) => attachmentMemberNeverLanded(group, leg)
|
|
109126
|
+
);
|
|
109011
109127
|
const liveOrderIds = /* @__PURE__ */ new Set();
|
|
109012
109128
|
if (storedLegs.some((leg) => !leg.beingCancelled)) {
|
|
109013
109129
|
const symbol2 = request.executionContext.symbol.trim().toUpperCase();
|
|
@@ -109558,6 +109674,9 @@ var init_runtime_execution = __esm({
|
|
|
109558
109674
|
positionTpsl,
|
|
109559
109675
|
metadata: {
|
|
109560
109676
|
trigger_price: candidates[index].triggerPrice,
|
|
109677
|
+
entry_order_id: fill.orderId,
|
|
109678
|
+
// Names the entry's row while VTX knows it only by its mutation (its outcome unknown).
|
|
109679
|
+
entry_mutation_id: plan.entryMutationId,
|
|
109561
109680
|
entry_filled_size: fill.filledSize,
|
|
109562
109681
|
entry_average_price: fill.averagePrice
|
|
109563
109682
|
}
|
|
@@ -111780,7 +111899,7 @@ var init_runtime_execution = __esm({
|
|
|
111780
111899
|
};
|
|
111781
111900
|
const retainedGroups = expectedGroupSet.filter((group) => group.pendingEntry != null || isProtectiveReplacementJournalGroup(group));
|
|
111782
111901
|
let stopSizePlacedThisPass = 0;
|
|
111783
|
-
const unresolvedStopSize = inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.leg.kind === "sl" && entry.state === "unresolved" && !liveOrders.some((order) => order.oid === entry.leg.orderId)).reduce((total, entry) => total + entry.leg.size, 0);
|
|
111902
|
+
const unresolvedStopSize = inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.leg.kind === "sl" && entry.state === "unresolved" && !liveOrders.some((order) => order.oid === entry.leg.orderId)).reduce((total, entry) => total + (entry.leg.replacement != null ? 0 : entry.leg.size), 0);
|
|
111784
111903
|
const lostOrderIds = new Set(
|
|
111785
111904
|
inspectedGroups.flatMap((candidate) => candidate.legs).filter((entry) => entry.state === "terminal").map((entry) => String(entry.leg.orderId))
|
|
111786
111905
|
);
|
|
@@ -111835,10 +111954,6 @@ var init_runtime_execution = __esm({
|
|
|
111835
111954
|
}
|
|
111836
111955
|
return { sentMs, freshOrders };
|
|
111837
111956
|
});
|
|
111838
|
-
const lostLegLiveStopSize = (freshOrders, positionSize) => {
|
|
111839
|
-
const freshIsLong = positionSize > 0;
|
|
111840
|
-
return freshOrders.filter((order) => !lostOrderIds.has(String(order.oid)) && String(order.coin).trim().toUpperCase() === symbol2.trim().toUpperCase() && order.reduce_only && order.is_trigger && order.trigger_kind === "sl" && (freshIsLong ? ["a", "sell"].includes(String(order.side).trim().toLowerCase()) : ["b", "buy"].includes(String(order.side).trim().toLowerCase()))).reduce((total, order) => total + (Number(order.sz) > 0 ? Number(order.sz) : 0), 0);
|
|
111841
|
-
};
|
|
111842
111957
|
const lostLegPositionEpisodeEnded = async (group, terminalStatus, positionSize, botCleanupInFlight, cancelledByUser) => {
|
|
111843
111958
|
if (terminalStatus == null || !episodeEndProofReachable({
|
|
111844
111959
|
orderStatus: terminalStatus.orderStatus,
|
|
@@ -111910,7 +112025,13 @@ var init_runtime_execution = __esm({
|
|
|
111910
112025
|
});
|
|
111911
112026
|
evidence = {
|
|
111912
112027
|
positionSize: position.positionSize,
|
|
111913
|
-
liveStopSize: replaceReachable ?
|
|
112028
|
+
liveStopSize: replaceReachable ? liveStopCoverOnPage({
|
|
112029
|
+
orders: (await readLostLegOrders()).freshOrders,
|
|
112030
|
+
symbol: symbol2,
|
|
112031
|
+
positionSize: position.positionSize,
|
|
112032
|
+
excludedOrderIds: lostOrderIds,
|
|
112033
|
+
groups: expectedGroupSet
|
|
112034
|
+
}) : 0,
|
|
111914
112035
|
markPrice: replaceReachable ? position.markPrice : null
|
|
111915
112036
|
};
|
|
111916
112037
|
} catch (error48) {
|
|
@@ -112186,6 +112307,7 @@ var init_runtime_execution = __esm({
|
|
|
112186
112307
|
metadata: {
|
|
112187
112308
|
reason_code: decision.reasonCode,
|
|
112188
112309
|
replaced_order_id: lostOrderId,
|
|
112310
|
+
entry_order_id: group.entryOrderId,
|
|
112189
112311
|
trigger_price: triggerPrice,
|
|
112190
112312
|
live_position_size: livePositionSize2,
|
|
112191
112313
|
...acknowledgement.state === "fulfilled" ? { acknowledgement_state: "fulfilled" } : {}
|
|
@@ -112282,7 +112404,7 @@ var init_runtime_execution = __esm({
|
|
|
112282
112404
|
if (state2 !== "open" || openOrder == null) {
|
|
112283
112405
|
remainingByKind[leg.kind] = Math.max(
|
|
112284
112406
|
0,
|
|
112285
|
-
remainingByKind[leg.kind] - leg
|
|
112407
|
+
remainingByKind[leg.kind] - protectiveLegCoverSize(leg)
|
|
112286
112408
|
);
|
|
112287
112409
|
retainedLegs.push(leg);
|
|
112288
112410
|
continue;
|
|
@@ -112315,7 +112437,10 @@ var init_runtime_execution = __esm({
|
|
|
112315
112437
|
Math.min(liveOrderSize, remainingByKind[leg.kind]),
|
|
112316
112438
|
request.executionContext.sizeDecimals
|
|
112317
112439
|
);
|
|
112318
|
-
remainingByKind[leg.kind] = Math.max(
|
|
112440
|
+
remainingByKind[leg.kind] = Math.max(
|
|
112441
|
+
0,
|
|
112442
|
+
remainingByKind[leg.kind] - Math.min(allowedSize, protectiveLegCoverSize(leg, liveOrderSize))
|
|
112443
|
+
);
|
|
112319
112444
|
if (allowedSize <= 0) {
|
|
112320
112445
|
const split3 = splitOversizedProtectiveLeg(expectedGroupSet, durableGroup, leg, exactClientProtectiveGroupSnapshot);
|
|
112321
112446
|
if (!replaceExactClientProtectiveGroupSet(profileId, symbol2, expectedGroupSet, split3.groups)) {
|
|
@@ -112789,7 +112914,8 @@ var init_runtime_execution = __esm({
|
|
|
112789
112914
|
metadata: {
|
|
112790
112915
|
trigger_price: replacementTriggerPrice,
|
|
112791
112916
|
previous_trigger_price: leg.triggerPrice,
|
|
112792
|
-
previous_order_id: orderId
|
|
112917
|
+
previous_order_id: orderId,
|
|
112918
|
+
entry_order_id: reservation.sourceGroup.entryOrderId
|
|
112793
112919
|
}
|
|
112794
112920
|
}));
|
|
112795
112921
|
return { reports, stop: false };
|
|
@@ -115756,9 +115882,11 @@ var init_protection_warning_delivery = __esm({
|
|
|
115756
115882
|
owesWarning = (report) => report.status === "failed" && (report.action === "AUTO_SL" || report.action === "AUTO_TP") && report.execution_metadata?.manual_intervention === true;
|
|
115757
115883
|
hasPendingClientProtection = (profileId) => hasPendingClientProtectiveGroups(profileId) || owedProtectionWarnings(profileId).length > 0;
|
|
115758
115884
|
deliverProtectionWarnings = async (profileId, results, signal) => {
|
|
115885
|
+
const reports = results.flatMap((result) => result.reports);
|
|
115886
|
+
oweProtectionWarnings(profileId, reports.filter(owesProtectionRecord));
|
|
115759
115887
|
const pending3 = distinctProtectionWarnings([
|
|
115760
115888
|
...owedProtectionWarnings(profileId),
|
|
115761
|
-
...
|
|
115889
|
+
...reports.filter((report) => owesWarning(report) || owesProtectionRecord(report))
|
|
115762
115890
|
]);
|
|
115763
115891
|
for (let start = 0; start < pending3.length; start += REPORTS_PER_REQUEST) {
|
|
115764
115892
|
const chunk = pending3.slice(start, start + REPORTS_PER_REQUEST);
|
|
@@ -116299,7 +116427,7 @@ var init_browser_observability = __esm({
|
|
|
116299
116427
|
init_define_VTX_GROK_POLICY();
|
|
116300
116428
|
init_define_VTX_PI_MODEL_POLICY();
|
|
116301
116429
|
init_runtime_policy_generated2();
|
|
116302
|
-
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
116430
|
+
CLIENT_SOURCE_VERSION = typeof process !== "undefined" && true && "8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim() && "8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim() !== "unstamped" ? "8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim() : null;
|
|
116303
116431
|
listenersInstalled = false;
|
|
116304
116432
|
state = {
|
|
116305
116433
|
loadedAtMs: Date.now(),
|
|
@@ -120005,6 +120133,7 @@ var init_device_trailing_maintenance = __esm({
|
|
|
120005
120133
|
init_api2();
|
|
120006
120134
|
init_constants();
|
|
120007
120135
|
init_network_debug();
|
|
120136
|
+
init_protection_warning_delivery();
|
|
120008
120137
|
init_runtime_redaction();
|
|
120009
120138
|
init_runtime_execution();
|
|
120010
120139
|
init_runtime_handoff();
|
|
@@ -120059,6 +120188,7 @@ var init_device_trailing_maintenance = __esm({
|
|
|
120059
120188
|
outcome: failed2 > 0 ? "error" : "ok"
|
|
120060
120189
|
});
|
|
120061
120190
|
}
|
|
120191
|
+
await deliverProtectionWarnings(input.profileId, results, input.signal);
|
|
120062
120192
|
const nextDueAtMs = nextClientTrailingStopDueAtMs(input.profileId, input.intervalMs);
|
|
120063
120193
|
return { recheckAtMs: nextDueAtMs == null ? null : Math.max(nextDueAtMs, ranAtMs + pollMs) };
|
|
120064
120194
|
};
|
|
@@ -129102,9 +129232,9 @@ var init_local_analysis = __esm({
|
|
|
129102
129232
|
RUNTIME_SOURCE_DEFINITION_VERSION = "runtime-source-v1";
|
|
129103
129233
|
DECISION_INPUT_DEFINITION_VERSION = "decision-input-v1";
|
|
129104
129234
|
CONTEXT_ENVELOPE_DEFINITION_VERSION = "context-envelope-v2.1";
|
|
129105
|
-
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "
|
|
129106
|
-
"
|
|
129107
|
-
) ? "
|
|
129235
|
+
CLIENT_RUNTIME_SOURCE_VERSION = typeof process !== "undefined" && true && "8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim() && !["unknown", "unstamped", "development"].includes(
|
|
129236
|
+
"8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim().toLowerCase()
|
|
129237
|
+
) ? "8bf68d84db2d5f7bef90caab1c5161a2ef91085f".trim() : null;
|
|
129108
129238
|
CLIENT_MAIN_PROMPT_RENDERER = "client_runtime.buildLocalRuntimePromptArtifacts:v1";
|
|
129109
129239
|
CLIENT_REVIEW_PROMPT_RENDERER = "client_runtime.review_prompt_assembly:v1";
|
|
129110
129240
|
resolveEffectivePromptRuntimeProvenance = (input) => ({
|