@vtxmacro/cli 2026.8.55 → 2026.8.56
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/README.md +10 -5
- package/bin/vtx-service-bootstrap.js +1540 -0
- package/bin/vtx.js +96 -30
- package/package.json +1 -1
package/bin/vtx.js
CHANGED
|
@@ -47,7 +47,7 @@ var init_agent_cli_release = __esm({
|
|
|
47
47
|
"agent-cli-release.json"() {
|
|
48
48
|
agent_cli_release_default = {
|
|
49
49
|
package_name: "@vtxmacro/cli",
|
|
50
|
-
package_version: "2026.8.
|
|
50
|
+
package_version: "2026.8.56",
|
|
51
51
|
codex_package_name: "@openai/codex",
|
|
52
52
|
codex_version: "0.147.0",
|
|
53
53
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -35280,7 +35280,7 @@ import { createWriteStream, readFileSync } from "node:fs";
|
|
|
35280
35280
|
import { access as access3, chmod as chmod3, mkdir as mkdir3, readFile as readFile5, rm as rm6, writeFile as writeFile2 } from "node:fs/promises";
|
|
35281
35281
|
import { homedir as homedir2 } from "node:os";
|
|
35282
35282
|
import { dirname as dirname5, join as join7, resolve as resolve4 } from "node:path";
|
|
35283
|
-
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_COOPERATIVE_STOP_SECONDS, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, managerName, assertRuntimeEnvironment, withoutConcurrencyLimit, assertServicePath, manifestGeneration, assertWorker, assertManifest, assertServiceRuntimeState, assertDesiredState, readInferenceHostServiceManifest, readManifestAcrossAtomicReplacement, readInferenceHostServiceRuntime, readRuntimeAcrossAtomicReplacement, readInferenceHostServiceDesired, readDesiredAcrossAtomicReplacement, writeDesired, runtimeEnvironment,
|
|
35283
|
+
var SERVICE_NAME, SYSTEMD_UNIT, LAUNCHD_LABEL, SERVICE_COOPERATIVE_STOP_SECONDS, SERVICE_UPDATE_STARTUP_SECONDS, INFERENCE_HOST_SERVICE_DRAIN_COMMAND, inferenceHostServiceChildEnvironment, isWindowsSubsystemForLinux, inferenceHostServiceManifestPath, inferenceHostServiceDesiredPath, inferenceHostServiceLogPath, inferenceHostServiceRuntimePath, xmlEscape, plistEscape, systemdQuote, defaultRunCommand, 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, appendServiceLog, spawnInferenceHostServiceChild, runInferenceHostServiceSupervisor;
|
|
35284
35284
|
var init_service = __esm({
|
|
35285
35285
|
"lib/inference-host/service.ts"() {
|
|
35286
35286
|
"use strict";
|
|
@@ -35290,6 +35290,7 @@ var init_service = __esm({
|
|
|
35290
35290
|
SYSTEMD_UNIT = "vtx-inference-host.service";
|
|
35291
35291
|
LAUNCHD_LABEL = "com.vtxmacro.inference-host";
|
|
35292
35292
|
SERVICE_COOPERATIVE_STOP_SECONDS = 75;
|
|
35293
|
+
SERVICE_UPDATE_STARTUP_SECONDS = 600;
|
|
35293
35294
|
INFERENCE_HOST_SERVICE_DRAIN_COMMAND = "vtx-inference-host-service-drain-v1";
|
|
35294
35295
|
inferenceHostServiceChildEnvironment = (runtimeEnvironment2, inheritedEnvironment = process.env) => {
|
|
35295
35296
|
const environment = { ...inheritedEnvironment };
|
|
@@ -35594,13 +35595,12 @@ var init_service = __esm({
|
|
|
35594
35595
|
}
|
|
35595
35596
|
return result2;
|
|
35596
35597
|
};
|
|
35597
|
-
|
|
35598
|
-
|
|
35599
|
-
"inference-host",
|
|
35600
|
-
"service",
|
|
35601
|
-
"run-internal",
|
|
35598
|
+
serviceBootstrapArguments = (bootstrapScript, manifestPath, lockPath) => [
|
|
35599
|
+
bootstrapScript,
|
|
35602
35600
|
"--service-manifest",
|
|
35603
|
-
manifestPath
|
|
35601
|
+
manifestPath,
|
|
35602
|
+
"--service-lock",
|
|
35603
|
+
lockPath
|
|
35604
35604
|
];
|
|
35605
35605
|
windowsOwnedCommandLine = (values) => {
|
|
35606
35606
|
if (values.some((value) => value.includes('"') || value.includes("\0"))) {
|
|
@@ -35679,6 +35679,9 @@ WantedBy=default.target
|
|
|
35679
35679
|
this.home = dependencies.homedir ?? homedir2();
|
|
35680
35680
|
this.executable = resolve4(dependencies.executable ?? process.execPath);
|
|
35681
35681
|
this.script = resolve4(dependencies.script ?? process.argv[1] ?? "");
|
|
35682
|
+
this.bootstrapScript = resolve4(
|
|
35683
|
+
dependencies.bootstrapScript ?? join7(dirname5(this.script), "vtx-service-bootstrap.js")
|
|
35684
|
+
);
|
|
35682
35685
|
this.username = dependencies.username ?? ([process.env.USERDOMAIN, process.env.USERNAME].filter(Boolean).join("\\") || process.env.USER || "");
|
|
35683
35686
|
this.windowsDirectory = (dependencies.windowsDirectory ?? process.env.SystemRoot ?? process.env.WINDIR ?? "C:\\Windows").replace(/[\\/]+$/u, "");
|
|
35684
35687
|
this.runCommand = dependencies.runCommand ?? defaultRunCommand;
|
|
@@ -35710,6 +35713,21 @@ WantedBy=default.target
|
|
|
35710
35713
|
runtimePath() {
|
|
35711
35714
|
return inferenceHostServiceRuntimePath(this.config);
|
|
35712
35715
|
}
|
|
35716
|
+
serviceBootstrapPath() {
|
|
35717
|
+
return `${this.config.supervisorStatePath}.service-bootstrap.js`;
|
|
35718
|
+
}
|
|
35719
|
+
serviceReleasePath() {
|
|
35720
|
+
return `${this.config.supervisorStatePath}.service-release.json`;
|
|
35721
|
+
}
|
|
35722
|
+
serviceReleaseRejectionPath() {
|
|
35723
|
+
return `${this.config.supervisorStatePath}.service-release-rejection.json`;
|
|
35724
|
+
}
|
|
35725
|
+
serviceReleasesPath() {
|
|
35726
|
+
return `${this.config.supervisorStatePath}.service-releases`;
|
|
35727
|
+
}
|
|
35728
|
+
serviceBootstrapLockPath() {
|
|
35729
|
+
return `${this.config.supervisorProcessLockPath}.service-bootstrap`;
|
|
35730
|
+
}
|
|
35713
35731
|
controlLockPath() {
|
|
35714
35732
|
return `${this.config.supervisorProcessLockPath}.service-control`;
|
|
35715
35733
|
}
|
|
@@ -35754,6 +35772,18 @@ WantedBy=default.target
|
|
|
35754
35772
|
windowsLauncherPath() {
|
|
35755
35773
|
return `${this.config.supervisorStatePath}.service-launcher.vbs`;
|
|
35756
35774
|
}
|
|
35775
|
+
async hasBootstrapDefinition() {
|
|
35776
|
+
try {
|
|
35777
|
+
await access3(this.serviceBootstrapPath());
|
|
35778
|
+
const definition = await readFile5(
|
|
35779
|
+
this.platform === "win32" ? this.windowsLauncherPath() : this.definitionPath(),
|
|
35780
|
+
"utf8"
|
|
35781
|
+
);
|
|
35782
|
+
return definition.includes(this.serviceBootstrapPath());
|
|
35783
|
+
} catch {
|
|
35784
|
+
return false;
|
|
35785
|
+
}
|
|
35786
|
+
}
|
|
35757
35787
|
async managerCommand(action) {
|
|
35758
35788
|
const definition = this.definitionPath();
|
|
35759
35789
|
if (this.platform === "win32") {
|
|
@@ -35875,13 +35905,23 @@ ${result2.stderr}`)) {
|
|
|
35875
35905
|
);
|
|
35876
35906
|
}
|
|
35877
35907
|
async registerManifestUnlocked(manifest, desiredRunning, targetInstanceName) {
|
|
35878
|
-
|
|
35908
|
+
await access3(this.bootstrapScript);
|
|
35909
|
+
const args = serviceBootstrapArguments(
|
|
35910
|
+
this.serviceBootstrapPath(),
|
|
35911
|
+
this.manifestPath(),
|
|
35912
|
+
this.serviceBootstrapLockPath()
|
|
35913
|
+
);
|
|
35879
35914
|
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);
|
|
35880
35915
|
let managerInstallAttempted = false;
|
|
35881
35916
|
try {
|
|
35882
35917
|
await writeAtomicInferencePrivateFile(this.manifestPath(), `${JSON.stringify(manifest, null, 2)}
|
|
35883
35918
|
`);
|
|
35884
35919
|
await writeDesired(this.desiredPath(), desiredRunning, this.now());
|
|
35920
|
+
await writeAtomicInferencePrivateFile(
|
|
35921
|
+
this.serviceBootstrapPath(),
|
|
35922
|
+
await readFile5(this.bootstrapScript, "utf8")
|
|
35923
|
+
);
|
|
35924
|
+
await chmod3(this.serviceBootstrapPath(), 448);
|
|
35885
35925
|
await mkdir3(dirname5(this.definitionPath()), { recursive: true, mode: 448 });
|
|
35886
35926
|
if (this.platform === "win32") {
|
|
35887
35927
|
await writeAtomicInferencePrivateFile(
|
|
@@ -35911,7 +35951,11 @@ ${started.stderr}`)) {
|
|
|
35911
35951
|
}
|
|
35912
35952
|
await this.waitForManagerActive();
|
|
35913
35953
|
if (this.confirmInitialReadiness) {
|
|
35914
|
-
await this.waitForManifestApplied(
|
|
35954
|
+
await this.waitForManifestApplied(
|
|
35955
|
+
manifest,
|
|
35956
|
+
targetInstanceName,
|
|
35957
|
+
Math.max(this.reconcileWaitAttempts, SERVICE_UPDATE_STARTUP_SECONDS * 4)
|
|
35958
|
+
);
|
|
35915
35959
|
}
|
|
35916
35960
|
}
|
|
35917
35961
|
return await this.status();
|
|
@@ -35938,6 +35982,7 @@ ${cleanup.stderr}`)) {
|
|
|
35938
35982
|
await rm6(this.manifestPath(), { force: true }).catch(() => void 0);
|
|
35939
35983
|
await rm6(this.desiredPath(), { force: true }).catch(() => void 0);
|
|
35940
35984
|
await rm6(this.runtimePath(), { force: true }).catch(() => void 0);
|
|
35985
|
+
await rm6(this.serviceBootstrapPath(), { force: true }).catch(() => void 0);
|
|
35941
35986
|
if (this.platform === "linux") {
|
|
35942
35987
|
await this.runCommand("systemctl", ["--user", "daemon-reload"]).catch(() => void 0);
|
|
35943
35988
|
}
|
|
@@ -35947,10 +35992,11 @@ ${cleanup.stderr}`)) {
|
|
|
35947
35992
|
async replaceManifestUnlocked(next, desiredRunning, targetInstanceName) {
|
|
35948
35993
|
const previous = await readInferenceHostServiceManifest(this.manifestPath());
|
|
35949
35994
|
const previousDesired = previous ? await readInferenceHostServiceDesired(this.desiredPath()) : false;
|
|
35950
|
-
|
|
35995
|
+
const hasBootstrapDefinition = previous ? await this.hasBootstrapDefinition() : false;
|
|
35996
|
+
if (previous && sameServiceDefinition(previous, next) && sameWorkerSet(previous, next) && previousDesired === desiredRunning && hasBootstrapDefinition) {
|
|
35951
35997
|
return await this.status();
|
|
35952
35998
|
}
|
|
35953
|
-
if (previous && previousDesired && desiredRunning && sameServiceDefinition(previous, next)) {
|
|
35999
|
+
if (previous && previousDesired && desiredRunning && sameServiceDefinition(previous, next) && hasBootstrapDefinition) {
|
|
35954
36000
|
const current = await this.status();
|
|
35955
36001
|
const runtime = await readRuntimeAcrossAtomicReplacement(this.runtimePath()).catch(() => null);
|
|
35956
36002
|
if (current.manager_active && runtime?.manifest_generation === previous.generation) {
|
|
@@ -36070,6 +36116,7 @@ ${cleanup.stderr}`)) {
|
|
|
36070
36116
|
}
|
|
36071
36117
|
await access3(this.executable);
|
|
36072
36118
|
await access3(this.script);
|
|
36119
|
+
await access3(this.bootstrapScript);
|
|
36073
36120
|
const maxConcurrency = options.maxConcurrency ?? null;
|
|
36074
36121
|
const workers = [
|
|
36075
36122
|
...existing?.workers.filter((worker) => worker.instance_name !== this.config.instanceName) ?? [],
|
|
@@ -36195,25 +36242,34 @@ ${result2.stderr}`)) {
|
|
|
36195
36242
|
const restoreOnFailure = await readInferenceHostServiceDesired(this.desiredPath());
|
|
36196
36243
|
await writeDesired(this.desiredPath(), false, this.now());
|
|
36197
36244
|
try {
|
|
36198
|
-
const
|
|
36245
|
+
const serviceLockPaths = [
|
|
36246
|
+
`${this.config.supervisorProcessLockPath}.service`,
|
|
36247
|
+
this.serviceBootstrapLockPath()
|
|
36248
|
+
];
|
|
36199
36249
|
let serviceReleased = false;
|
|
36200
36250
|
for (let attempt = 0; attempt < this.stopWaitAttempts; attempt += 1) {
|
|
36201
|
-
|
|
36202
|
-
|
|
36203
|
-
|
|
36251
|
+
let allReleased = true;
|
|
36252
|
+
for (const serviceLockPath of serviceLockPaths) {
|
|
36253
|
+
try {
|
|
36254
|
+
const probe = await this.acquireProcessLock(serviceLockPath);
|
|
36255
|
+
await probe.release();
|
|
36256
|
+
} catch (error48) {
|
|
36257
|
+
if (error48 instanceof Error && error48.message.includes("Another inference host process already owns")) {
|
|
36258
|
+
allReleased = false;
|
|
36259
|
+
break;
|
|
36260
|
+
}
|
|
36261
|
+
throw error48;
|
|
36262
|
+
}
|
|
36263
|
+
}
|
|
36264
|
+
if (allReleased) {
|
|
36204
36265
|
serviceReleased = true;
|
|
36205
36266
|
break;
|
|
36206
|
-
} catch (error48) {
|
|
36207
|
-
if (error48 instanceof Error && error48.message.includes("Another inference host process already owns")) {
|
|
36208
|
-
await this.sleep(250);
|
|
36209
|
-
continue;
|
|
36210
|
-
}
|
|
36211
|
-
throw error48;
|
|
36212
36267
|
}
|
|
36268
|
+
await this.sleep(250);
|
|
36213
36269
|
}
|
|
36214
36270
|
if (!serviceReleased) {
|
|
36215
36271
|
throw new Error(
|
|
36216
|
-
`Inference-host workers did not stop cooperatively within ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; refusing forced termination while cleanup may be pending.`
|
|
36272
|
+
`Inference-host updater or workers did not stop cooperatively within ${SERVICE_COOPERATIVE_STOP_SECONDS} seconds; refusing forced termination while cleanup may be pending.`
|
|
36217
36273
|
);
|
|
36218
36274
|
}
|
|
36219
36275
|
const result2 = await this.managerCommand("stop");
|
|
@@ -36329,6 +36385,10 @@ ${result2.stderr}`)) {
|
|
|
36329
36385
|
await rm6(this.manifestPath(), { force: true });
|
|
36330
36386
|
await rm6(this.desiredPath(), { force: true });
|
|
36331
36387
|
await rm6(this.runtimePath(), { force: true });
|
|
36388
|
+
await rm6(this.serviceBootstrapPath(), { force: true });
|
|
36389
|
+
await rm6(this.serviceReleasePath(), { force: true });
|
|
36390
|
+
await rm6(this.serviceReleaseRejectionPath(), { force: true });
|
|
36391
|
+
await rm6(this.serviceReleasesPath(), { recursive: true, force: true });
|
|
36332
36392
|
return {
|
|
36333
36393
|
installed: false,
|
|
36334
36394
|
desired_running: false,
|
|
@@ -36461,8 +36521,11 @@ ${result2.stderr}`)) {
|
|
|
36461
36521
|
});
|
|
36462
36522
|
};
|
|
36463
36523
|
runInferenceHostServiceSupervisor = async (manifestPath, options = {}) => {
|
|
36464
|
-
const
|
|
36465
|
-
if (!
|
|
36524
|
+
const storedInitialManifest = await readInferenceHostServiceManifest(manifestPath);
|
|
36525
|
+
if (!storedInitialManifest) throw new Error("Inference-host service manifest is missing.");
|
|
36526
|
+
const serviceScript = options.serviceScript ? resolve4(options.serviceScript) : null;
|
|
36527
|
+
const withServiceScript = (manifest) => serviceScript ? { ...manifest, script: serviceScript } : manifest;
|
|
36528
|
+
const initialManifest = withServiceScript(storedInitialManifest);
|
|
36466
36529
|
const desiredPath = manifestPath.replace(/\.service\.json$/u, ".service-desired.json");
|
|
36467
36530
|
const runtimePath = manifestPath.replace(/\.service\.json$/u, ".service-runtime.json");
|
|
36468
36531
|
const signal = options.signal ?? new AbortController().signal;
|
|
@@ -36659,15 +36722,17 @@ ${result2.stderr}`)) {
|
|
|
36659
36722
|
try {
|
|
36660
36723
|
while (!signal.aborted) {
|
|
36661
36724
|
while (!signal.aborted && await readDesiredAcrossAtomicReplacement(desiredPath)) {
|
|
36662
|
-
const
|
|
36663
|
-
if (!
|
|
36725
|
+
const storedNext = await readManifestAcrossAtomicReplacement(manifestPath);
|
|
36726
|
+
if (!storedNext) throw new Error("Inference-host service manifest is missing.");
|
|
36727
|
+
const next = withServiceScript(storedNext);
|
|
36664
36728
|
if (next.generation !== appliedManifest.generation && next.generation !== rejectedManifestGeneration) await reconcile(next);
|
|
36665
36729
|
await sleep4(250);
|
|
36666
36730
|
}
|
|
36667
36731
|
await drainWorkers();
|
|
36668
36732
|
if (signal.aborted || !await readDesiredAcrossAtomicReplacement(desiredPath)) break;
|
|
36669
|
-
const
|
|
36670
|
-
if (!
|
|
36733
|
+
const storedRestored = await readManifestAcrossAtomicReplacement(manifestPath);
|
|
36734
|
+
if (!storedRestored) throw new Error("Inference-host service manifest is missing.");
|
|
36735
|
+
const restored = withServiceScript(storedRestored);
|
|
36671
36736
|
await reconcile(restored);
|
|
36672
36737
|
await appendServiceLog(restored.log_path, "service_desired_state_restored", {
|
|
36673
36738
|
manifest_generation: restored.generation,
|
|
@@ -39406,7 +39471,8 @@ Waiting for approval...
|
|
|
39406
39471
|
await (dependencies.runServiceSupervisor ?? runInferenceHostServiceSupervisor)(
|
|
39407
39472
|
parsed.serviceManifestPath,
|
|
39408
39473
|
{
|
|
39409
|
-
signal: cancellation.signal
|
|
39474
|
+
signal: cancellation.signal,
|
|
39475
|
+
serviceScript: resolve5(process.argv[1] ?? "")
|
|
39410
39476
|
}
|
|
39411
39477
|
);
|
|
39412
39478
|
return { exitCode: 0, stdout: "", stderr: "" };
|