@vtxmacro/cli 2026.8.43 → 2026.8.44
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.js +165 -80
- package/package.json +1 -1
package/bin/vtx.js
CHANGED
|
@@ -38,7 +38,7 @@ var init_agent_cli_release = __esm({
|
|
|
38
38
|
"agent-cli-release.json"() {
|
|
39
39
|
agent_cli_release_default = {
|
|
40
40
|
package_name: "@vtxmacro/cli",
|
|
41
|
-
package_version: "2026.8.
|
|
41
|
+
package_version: "2026.8.44",
|
|
42
42
|
codex_package_name: "@openai/codex",
|
|
43
43
|
codex_version: "0.147.0",
|
|
44
44
|
copilot_sdk_package_name: "@github/copilot-sdk",
|
|
@@ -16196,7 +16196,7 @@ import { spawn } from "node:child_process";
|
|
|
16196
16196
|
import { constants } from "node:fs";
|
|
16197
16197
|
import { lstat, mkdir, open, readFile, realpath, rename, rm } from "node:fs/promises";
|
|
16198
16198
|
import { homedir } from "node:os";
|
|
16199
|
-
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
16199
|
+
import { dirname, isAbsolute, join, relative, resolve, win32 as windowsPath } from "node:path";
|
|
16200
16200
|
function inferenceBaseDir(env) {
|
|
16201
16201
|
const configured = String(env.VTX_INFERENCE_HOST_HOME || "").trim();
|
|
16202
16202
|
return configured || join(homedir(), ".vtx", "inference-host");
|
|
@@ -16737,7 +16737,7 @@ async function acquireInferenceHostProcessLock(path, dependencies = {}) {
|
|
|
16737
16737
|
}
|
|
16738
16738
|
};
|
|
16739
16739
|
}
|
|
16740
|
-
var INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, windowsPrivateAclBrokerInvocation, WindowsPrivateAclBroker, defaultWindowsPrivateAclBroker, runWindowsPrivateAcl, windowsAclCache, windowsAclIdentity, aclCacheKey, secureWindowsPrivatePath, invalidateWindowsAclCache, rebindHardenedWindowsAclAfterRename, rebindHardenedWindowsDirectoryAfterOwnedMutation, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, defaultCurrentProcessIdentity, processLockObservationCache, inferenceProcessIdentitiesMatch, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig;
|
|
16740
|
+
var INFERENCE_CREDENTIAL_NAMESPACE, MAX_INFERENCE_PRIVATE_FILE_BYTES, 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, isDefaultWindowsPrivatePath, secureExistingWindowsPath, linuxProcessIdentity, windowsProcessIdentityInvocation, windowsBootIdentityInvocation, windowsProcessIdentity, darwinProcessIdentity, runSmallIdentityCommand, cachedSystemBootIdentity, readInferenceSystemBootIdentity, defaultProcessIdentity, defaultCurrentProcessIdentity, processLockObservationCache, inferenceProcessIdentitiesMatch, DEFAULT_INFERENCE_HOST_INSTANCE, SAFE_INFERENCE_HOST_INSTANCE, requireNamedInstancePath, credentialStoreIdentity, inferenceHostCredentialContextPath, inferenceHostCredentialContextTransitionPath, credentialContextForConfig;
|
|
16741
16741
|
var init_config = __esm({
|
|
16742
16742
|
"lib/inference-host/config.ts"() {
|
|
16743
16743
|
"use strict";
|
|
@@ -16747,6 +16747,7 @@ var init_config = __esm({
|
|
|
16747
16747
|
$ProgressPreference='SilentlyContinue'
|
|
16748
16748
|
while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
16749
16749
|
$requestId=$null
|
|
16750
|
+
$failureStage='request_validation'
|
|
16750
16751
|
try {
|
|
16751
16752
|
if($line.Length -lt 2 -or $line.Length -gt 65536) { throw 'invalid request size' }
|
|
16752
16753
|
$request=$line | ConvertFrom-Json
|
|
@@ -16761,18 +16762,25 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16761
16762
|
if($mode -ne 'harden' -and $mode -ne 'verify' -and $mode -ne 'verify-owner') { throw 'invalid ACL mode' }
|
|
16762
16763
|
$path=[Text.Encoding]::UTF8.GetString([Convert]::FromBase64String([string]$request.path_b64))
|
|
16763
16764
|
if([string]::IsNullOrWhiteSpace($path) -or $path.Length -gt 32767 -or $path.Contains([char]0)) { throw 'invalid path' }
|
|
16765
|
+
$failureStage='path_lookup'
|
|
16764
16766
|
if(-not (Test-Path -LiteralPath $path)) {
|
|
16765
16767
|
[Console]::Out.WriteLine((@{id=$requestId;status='missing'} | ConvertTo-Json -Compress))
|
|
16766
16768
|
continue
|
|
16767
16769
|
}
|
|
16768
|
-
$
|
|
16770
|
+
$failureStage='principal_resolution'
|
|
16771
|
+
$currentIdentity=[Security.Principal.WindowsIdentity]::GetCurrent()
|
|
16772
|
+
$current=$currentIdentity.User
|
|
16769
16773
|
$system=New-Object Security.Principal.SecurityIdentifier('S-1-5-18')
|
|
16770
16774
|
$admins=New-Object Security.Principal.SecurityIdentifier('S-1-5-32-544')
|
|
16775
|
+
$currentIsAdmin=(New-Object Security.Principal.WindowsPrincipal($currentIdentity)).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
|
|
16771
16776
|
$allowed=@($current.Value,$system.Value,$admins.Value)
|
|
16772
16777
|
if($mode -eq 'harden') {
|
|
16778
|
+
$failureStage='acl_read'
|
|
16773
16779
|
$acl=Get-Acl -LiteralPath $path
|
|
16780
|
+
$failureStage='owner_validation'
|
|
16774
16781
|
$existingOwner=(New-Object Security.Principal.NTAccount($acl.Owner)).Translate([Security.Principal.SecurityIdentifier]).Value
|
|
16775
|
-
if($existingOwner -ne $current.Value) { throw 'private ACL owner is invalid' }
|
|
16782
|
+
if($existingOwner -ne $current.Value -and ($existingOwner -ne $admins.Value -or -not $currentIsAdmin)) { throw 'private ACL owner is invalid' }
|
|
16783
|
+
$failureStage='acl_mutation'
|
|
16776
16784
|
$acl.SetAccessRuleProtection($true,$false)
|
|
16777
16785
|
foreach($existingRule in @($acl.Access)) { [void]$acl.RemoveAccessRuleSpecific($existingRule) }
|
|
16778
16786
|
$inherit=if($kind -eq 'directory') {
|
|
@@ -16788,11 +16796,14 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16788
16796
|
)
|
|
16789
16797
|
[void]$acl.AddAccessRule($rule)
|
|
16790
16798
|
}
|
|
16799
|
+
$failureStage='acl_write'
|
|
16791
16800
|
(Get-Item -LiteralPath $path).SetAccessControl($acl)
|
|
16792
16801
|
}
|
|
16802
|
+
$failureStage='acl_readback'
|
|
16793
16803
|
$actual=Get-Acl -LiteralPath $path
|
|
16804
|
+
$failureStage='acl_verification'
|
|
16794
16805
|
$owner=(New-Object Security.Principal.NTAccount($actual.Owner)).Translate([Security.Principal.SecurityIdentifier]).Value
|
|
16795
|
-
if($owner -ne $current.Value) { throw 'private ACL owner is invalid' }
|
|
16806
|
+
if($owner -ne $current.Value -and ($owner -ne $admins.Value -or -not $currentIsAdmin)) { throw 'private ACL owner is invalid' }
|
|
16796
16807
|
if($mode -ne 'verify-owner') {
|
|
16797
16808
|
if(-not $actual.AreAccessRulesProtected) { throw 'private ACL inheritance is invalid' }
|
|
16798
16809
|
$userFull=$false
|
|
@@ -16807,9 +16818,28 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16807
16818
|
}
|
|
16808
16819
|
[Console]::Out.WriteLine((@{id=$requestId;status='ok'} | ConvertTo-Json -Compress))
|
|
16809
16820
|
} catch {
|
|
16810
|
-
[Console]::Out.WriteLine((@{id=$requestId;status='error'} | ConvertTo-Json -Compress))
|
|
16821
|
+
[Console]::Out.WriteLine((@{id=$requestId;status='error';error_code=$failureStage} | ConvertTo-Json -Compress))
|
|
16811
16822
|
}
|
|
16812
16823
|
}`;
|
|
16824
|
+
WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS = 15e3;
|
|
16825
|
+
WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS = 45e3;
|
|
16826
|
+
SMALL_IDENTITY_COMMAND_TIMEOUT_MS = 5e3;
|
|
16827
|
+
windowsPowerShellEnvironment = (extra = {}) => {
|
|
16828
|
+
const sanitizedExtra = { ...extra };
|
|
16829
|
+
delete sanitizedExtra.PSModulePath;
|
|
16830
|
+
const windowsRoot = process.env.SystemRoot ?? process.env.WINDIR;
|
|
16831
|
+
return {
|
|
16832
|
+
...sanitizedExtra,
|
|
16833
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
16834
|
+
SystemRoot: process.env.SystemRoot,
|
|
16835
|
+
WINDIR: process.env.WINDIR,
|
|
16836
|
+
ComSpec: process.env.ComSpec,
|
|
16837
|
+
PATHEXT: process.env.PATHEXT,
|
|
16838
|
+
PSModulePath: windowsRoot ? windowsPath.join(windowsRoot, "System32", "WindowsPowerShell", "v1.0", "Modules") : void 0,
|
|
16839
|
+
TEMP: process.env.TEMP,
|
|
16840
|
+
TMP: process.env.TMP
|
|
16841
|
+
};
|
|
16842
|
+
};
|
|
16813
16843
|
windowsPrivateAclBrokerInvocation = () => ({
|
|
16814
16844
|
args: [
|
|
16815
16845
|
"-NoLogo",
|
|
@@ -16818,16 +16848,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16818
16848
|
"-EncodedCommand",
|
|
16819
16849
|
Buffer.from(WINDOWS_PRIVATE_ACL_BROKER_SCRIPT, "utf16le").toString("base64")
|
|
16820
16850
|
],
|
|
16821
|
-
env:
|
|
16822
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
16823
|
-
SystemRoot: process.env.SystemRoot,
|
|
16824
|
-
WINDIR: process.env.WINDIR,
|
|
16825
|
-
ComSpec: process.env.ComSpec,
|
|
16826
|
-
PATHEXT: process.env.PATHEXT,
|
|
16827
|
-
PSModulePath: process.env.PSModulePath,
|
|
16828
|
-
TEMP: process.env.TEMP,
|
|
16829
|
-
TMP: process.env.TMP
|
|
16830
|
-
}
|
|
16851
|
+
env: windowsPowerShellEnvironment()
|
|
16831
16852
|
});
|
|
16832
16853
|
WindowsPrivateAclBroker = class {
|
|
16833
16854
|
constructor(dependencies = {}) {
|
|
@@ -16846,6 +16867,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16846
16867
|
await operation;
|
|
16847
16868
|
};
|
|
16848
16869
|
this.requestTimeoutMs = dependencies.requestTimeoutMs ?? 15e3;
|
|
16870
|
+
this.startupRequestTimeoutMs = dependencies.startupRequestTimeoutMs ?? WINDOWS_PRIVATE_ACL_BROKER_STARTUP_TIMEOUT_MS;
|
|
16849
16871
|
this.idleShutdownMs = dependencies.idleShutdownMs ?? 3e4;
|
|
16850
16872
|
this.spawnProcess = dependencies.spawnProcess ?? (() => {
|
|
16851
16873
|
const invocation = windowsPrivateAclBrokerInvocation();
|
|
@@ -16896,7 +16918,19 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16896
16918
|
let response;
|
|
16897
16919
|
try {
|
|
16898
16920
|
const parsed = JSON.parse(line);
|
|
16899
|
-
|
|
16921
|
+
const status = String(parsed.status);
|
|
16922
|
+
const expectedKeys = status === "error" ? "error_code\0id\0status" : "id\0status";
|
|
16923
|
+
if (Object.keys(parsed).sort().join("\0") !== expectedKeys || parsed.id !== pending.id || !["ok", "missing", "error"].includes(status) || status === "error" && ![
|
|
16924
|
+
"request_validation",
|
|
16925
|
+
"path_lookup",
|
|
16926
|
+
"principal_resolution",
|
|
16927
|
+
"acl_read",
|
|
16928
|
+
"owner_validation",
|
|
16929
|
+
"acl_mutation",
|
|
16930
|
+
"acl_write",
|
|
16931
|
+
"acl_readback",
|
|
16932
|
+
"acl_verification"
|
|
16933
|
+
].includes(String(parsed.error_code))) throw new Error("invalid response");
|
|
16900
16934
|
response = parsed;
|
|
16901
16935
|
} catch {
|
|
16902
16936
|
this.failChild(child, new Error("Windows private ACL broker returned malformed output."));
|
|
@@ -16911,12 +16945,16 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16911
16945
|
error48.code = "ENOENT";
|
|
16912
16946
|
pending.reject(error48);
|
|
16913
16947
|
} else {
|
|
16914
|
-
pending.reject(new Error(
|
|
16948
|
+
pending.reject(new Error(
|
|
16949
|
+
`Windows private ACL ${pending.mode} failed (${response.error_code}).`
|
|
16950
|
+
));
|
|
16915
16951
|
}
|
|
16916
16952
|
this.scheduleIdleShutdown();
|
|
16917
16953
|
}
|
|
16918
16954
|
ensureChild() {
|
|
16919
|
-
if (this.child && this.child.exitCode === null && !this.child.killed)
|
|
16955
|
+
if (this.child && this.child.exitCode === null && !this.child.killed) {
|
|
16956
|
+
return { child: this.child, startedNow: false };
|
|
16957
|
+
}
|
|
16920
16958
|
const child = this.spawnProcess();
|
|
16921
16959
|
this.child = child;
|
|
16922
16960
|
this.outputBuffer = "";
|
|
@@ -16947,7 +16985,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16947
16985
|
for (const stream of [child.stdin, child.stdout, child.stderr]) {
|
|
16948
16986
|
stream.unref?.();
|
|
16949
16987
|
}
|
|
16950
|
-
return child;
|
|
16988
|
+
return { child, startedNow: true };
|
|
16951
16989
|
}
|
|
16952
16990
|
async dispatch(path, kind, mode) {
|
|
16953
16991
|
if (this.idleTimer) {
|
|
@@ -16965,11 +17003,12 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
16965
17003
|
if (Buffer.byteLength(request, "utf8") > 65536) {
|
|
16966
17004
|
throw new Error("Windows private ACL broker request exceeds its input limit.");
|
|
16967
17005
|
}
|
|
16968
|
-
const child = this.ensureChild();
|
|
17006
|
+
const { child, startedNow } = this.ensureChild();
|
|
17007
|
+
const timeoutMs = startedNow ? this.startupRequestTimeoutMs : this.requestTimeoutMs;
|
|
16969
17008
|
await new Promise((resolvePromise, reject) => {
|
|
16970
17009
|
const timer = setTimeout(() => {
|
|
16971
17010
|
this.failChild(child, new Error("Windows private ACL broker request timed out."));
|
|
16972
|
-
},
|
|
17011
|
+
}, timeoutMs);
|
|
16973
17012
|
this.pending = { id: id2, mode, resolve: resolvePromise, reject, timer };
|
|
16974
17013
|
child.stdin.write(request, "utf8", (error48) => {
|
|
16975
17014
|
if (error48) {
|
|
@@ -17072,26 +17111,40 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
17072
17111
|
return null;
|
|
17073
17112
|
}
|
|
17074
17113
|
};
|
|
17114
|
+
windowsProcessIdentityInvocation = (pid) => {
|
|
17115
|
+
const script = `$ErrorActionPreference='Stop';$p=[Diagnostics.Process]::GetProcessById([int]$env:VTX_PROCESS_PID);[Console]::Out.Write($p.StartTime.ToUniversalTime().ToFileTimeUtc())`;
|
|
17116
|
+
return {
|
|
17117
|
+
args: [
|
|
17118
|
+
"-NoLogo",
|
|
17119
|
+
"-NoProfile",
|
|
17120
|
+
"-NonInteractive",
|
|
17121
|
+
"-EncodedCommand",
|
|
17122
|
+
Buffer.from(script, "utf16le").toString("base64")
|
|
17123
|
+
],
|
|
17124
|
+
env: windowsPowerShellEnvironment({ VTX_PROCESS_PID: String(pid) }),
|
|
17125
|
+
timeoutMs: WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS
|
|
17126
|
+
};
|
|
17127
|
+
};
|
|
17128
|
+
windowsBootIdentityInvocation = () => {
|
|
17129
|
+
const script = `$ErrorActionPreference='Stop';$s=[System.Management.ManagementObjectSearcher]::new('SELECT LastBootUpTime FROM Win32_OperatingSystem');try{$c=$s.Get();$e=$c.GetEnumerator();if(-not $e.MoveNext()){throw 'boot identity unavailable'};$raw=[string]$e.Current['LastBootUpTime'];$v=[System.Management.ManagementDateTimeConverter]::ToDateTime($raw).ToUniversalTime().ToFileTimeUtc();[Console]::Out.Write($v)}finally{if($c){$c.Dispose()};$s.Dispose()}`;
|
|
17130
|
+
return {
|
|
17131
|
+
args: [
|
|
17132
|
+
"-NoLogo",
|
|
17133
|
+
"-NoProfile",
|
|
17134
|
+
"-NonInteractive",
|
|
17135
|
+
"-EncodedCommand",
|
|
17136
|
+
Buffer.from(script, "utf16le").toString("base64")
|
|
17137
|
+
],
|
|
17138
|
+
env: windowsPowerShellEnvironment(),
|
|
17139
|
+
timeoutMs: WINDOWS_IDENTITY_COMMAND_TIMEOUT_MS
|
|
17140
|
+
};
|
|
17141
|
+
};
|
|
17075
17142
|
windowsProcessIdentity = async (pid) => await new Promise((resolvePromise) => {
|
|
17076
|
-
const
|
|
17077
|
-
const child = spawn("powershell.exe", [
|
|
17078
|
-
"-NoLogo",
|
|
17079
|
-
"-NoProfile",
|
|
17080
|
-
"-NonInteractive",
|
|
17081
|
-
"-EncodedCommand",
|
|
17082
|
-
Buffer.from(script, "utf16le").toString("base64")
|
|
17083
|
-
], {
|
|
17143
|
+
const invocation = windowsProcessIdentityInvocation(pid);
|
|
17144
|
+
const child = spawn("powershell.exe", [...invocation.args], {
|
|
17084
17145
|
windowsHide: true,
|
|
17085
17146
|
stdio: ["ignore", "pipe", "ignore"],
|
|
17086
|
-
env:
|
|
17087
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
17088
|
-
SystemRoot: process.env.SystemRoot,
|
|
17089
|
-
WINDIR: process.env.WINDIR,
|
|
17090
|
-
ComSpec: process.env.ComSpec,
|
|
17091
|
-
PATHEXT: process.env.PATHEXT,
|
|
17092
|
-
PSModulePath: process.env.PSModulePath,
|
|
17093
|
-
VTX_PROCESS_PID: String(pid)
|
|
17094
|
-
}
|
|
17147
|
+
env: invocation.env
|
|
17095
17148
|
});
|
|
17096
17149
|
const output3 = [];
|
|
17097
17150
|
let settled = false;
|
|
@@ -17104,7 +17157,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
17104
17157
|
const timer = setTimeout(() => {
|
|
17105
17158
|
child.kill("SIGKILL");
|
|
17106
17159
|
settle(null);
|
|
17107
|
-
},
|
|
17160
|
+
}, invocation.timeoutMs);
|
|
17108
17161
|
child.stdout.on("data", (chunk) => {
|
|
17109
17162
|
if (output3.reduce((total, item) => total + item.byteLength, 0) + Buffer.byteLength(chunk) > 1024) {
|
|
17110
17163
|
child.kill("SIGKILL");
|
|
@@ -17142,7 +17195,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
17142
17195
|
settle(code === 0 && Number.isFinite(started) ? `darwin:${Math.floor(started / 1e3)}` : null);
|
|
17143
17196
|
});
|
|
17144
17197
|
});
|
|
17145
|
-
runSmallIdentityCommand = async (command, args, env) => await new Promise((resolvePromise) => {
|
|
17198
|
+
runSmallIdentityCommand = async (command, args, env, timeoutMs = SMALL_IDENTITY_COMMAND_TIMEOUT_MS) => await new Promise((resolvePromise) => {
|
|
17146
17199
|
const child = spawn(command, [...args], {
|
|
17147
17200
|
windowsHide: true,
|
|
17148
17201
|
stdio: ["ignore", "pipe", "ignore"],
|
|
@@ -17160,7 +17213,7 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
17160
17213
|
const timer = setTimeout(() => {
|
|
17161
17214
|
child.kill("SIGKILL");
|
|
17162
17215
|
settle(null);
|
|
17163
|
-
},
|
|
17216
|
+
}, timeoutMs);
|
|
17164
17217
|
child.stdout.on("data", (chunk) => {
|
|
17165
17218
|
bytes3 += Buffer.byteLength(chunk);
|
|
17166
17219
|
if (bytes3 > 4096) {
|
|
@@ -17189,21 +17242,13 @@ while(($line=[Console]::In.ReadLine()) -ne $null) {
|
|
|
17189
17242
|
identity = null;
|
|
17190
17243
|
}
|
|
17191
17244
|
} else if (platform === "win32") {
|
|
17192
|
-
const
|
|
17193
|
-
identity = await runSmallIdentityCommand(
|
|
17194
|
-
"
|
|
17195
|
-
|
|
17196
|
-
|
|
17197
|
-
|
|
17198
|
-
|
|
17199
|
-
], {
|
|
17200
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
17201
|
-
SystemRoot: process.env.SystemRoot,
|
|
17202
|
-
WINDIR: process.env.WINDIR,
|
|
17203
|
-
ComSpec: process.env.ComSpec,
|
|
17204
|
-
PATHEXT: process.env.PATHEXT,
|
|
17205
|
-
PSModulePath: process.env.PSModulePath
|
|
17206
|
-
});
|
|
17245
|
+
const invocation = windowsBootIdentityInvocation();
|
|
17246
|
+
identity = await runSmallIdentityCommand(
|
|
17247
|
+
"powershell.exe",
|
|
17248
|
+
invocation.args,
|
|
17249
|
+
invocation.env,
|
|
17250
|
+
invocation.timeoutMs
|
|
17251
|
+
);
|
|
17207
17252
|
} else if (platform === "darwin") {
|
|
17208
17253
|
identity = await runSmallIdentityCommand("sysctl", ["-n", "kern.boottime"], void 0);
|
|
17209
17254
|
}
|
|
@@ -29717,7 +29762,7 @@ function createDefaultInferenceHostRunnerDependencies(options) {
|
|
|
29717
29762
|
envelopePublicKey: options.envelopePublicKey
|
|
29718
29763
|
};
|
|
29719
29764
|
}
|
|
29720
|
-
var import_ajv, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, membershipFailureDisposition, safeFailureCode, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner;
|
|
29765
|
+
var import_ajv, RUNTIME_RECEIPT_SCHEMA_VERSION, ATTEMPT_RECEIPT_SCHEMA_VERSION, DEFAULT_ADVERTISEMENT_TTL_MS, DEFAULT_ADVERTISEMENT_REFRESH_LEAD_MS, DEFAULT_HOST_HEARTBEAT_MS, DEFAULT_PROVIDER_RATE_LIMIT_REFRESH_MS, DEFAULT_ATTEMPT_HEARTBEAT_MS, DEFAULT_DRAIN_TIMEOUT_MS, DEFAULT_REMOTE_RETRY_LIMIT, MIN_SLEEP_MS, DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS, MIN_CLAIM_START_WINDOW_MS, MAX_ATTEMPT_START_RETRY_DELAY_MS, UNBOUNDED_AVAILABLE_SLOTS, buildInferenceAdvertisedModels, summarizeInferenceHostRuntimeRecovery, FileInferenceHostRuntimeReceiptStore, InferenceHostRecoveryRequiredError, InferenceHostRunnerError, defaultSleep, abortError, defaultRegisterSignalHandlers, safeInteger, exactObjectKeys, validIso, validateAttemptReceipt, validateRuntimeReceipt, sha256, stableOperationId, buildAttemptStartRequest, isoAt, providerWeeklyQuotaFromRateLimits, finitePositiveOption, validateRunnerOptions, assertLocalCredentialIdentity, retryableRemoteError, remoteRetryAfterMs, controlPlaneFatal, defaultValidateOutput, objectRecord, positiveUtf8ByteLimit, assertCompilableOutputSchema, parseOutputContract, membershipFailureDisposition, safeFailureCode, attemptStartRetryFallbackMs, exactJson2, runnerIdentityMismatch, assertAdvertisementResult, assertHostHeartbeatResult, assertClaimResult, assertStartResult, assertJobHeartbeatResult, assertTerminalResult, classifyFailure, ambiguousHeartbeatTransport, reportedTokenUsage, reportedUsage, InferenceHostRunner;
|
|
29721
29766
|
var init_runner = __esm({
|
|
29722
29767
|
"lib/inference-host/runner.ts"() {
|
|
29723
29768
|
"use strict";
|
|
@@ -29741,6 +29786,7 @@ var init_runner = __esm({
|
|
|
29741
29786
|
MIN_SLEEP_MS = 10;
|
|
29742
29787
|
DEFAULT_CODEX_ACCOUNT_COOLDOWN_MS = 5 * 60 * 1e3;
|
|
29743
29788
|
MIN_CLAIM_START_WINDOW_MS = 5e3;
|
|
29789
|
+
MAX_ATTEMPT_START_RETRY_DELAY_MS = 15e3;
|
|
29744
29790
|
UNBOUNDED_AVAILABLE_SLOTS = Number.MAX_SAFE_INTEGER;
|
|
29745
29791
|
buildInferenceAdvertisedModels = (capabilities, adapterRuntimeVersion, adapter = "codex", structuredOutput = true, sameAttemptRecovery = adapter === "codex") => {
|
|
29746
29792
|
const visible = capabilities.filter((capability) => !capability.hidden);
|
|
@@ -30276,6 +30322,10 @@ var init_runner = __esm({
|
|
|
30276
30322
|
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/gu, "_").slice(0, 96);
|
|
30277
30323
|
return /^[a-z0-9]/u.test(normalized) ? normalized : fallback;
|
|
30278
30324
|
};
|
|
30325
|
+
attemptStartRetryFallbackMs = (retryCount) => Math.min(
|
|
30326
|
+
1e3 * 2 ** Math.min(Math.max(0, retryCount - 1), 4),
|
|
30327
|
+
MAX_ATTEMPT_START_RETRY_DELAY_MS
|
|
30328
|
+
);
|
|
30279
30329
|
exactJson2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
|
|
30280
30330
|
runnerIdentityMismatch = (operation) => {
|
|
30281
30331
|
throw new InferenceHostRunnerError(
|
|
@@ -30736,6 +30786,7 @@ var init_runner = __esm({
|
|
|
30736
30786
|
let pendingClaimPromotions = 0;
|
|
30737
30787
|
let onceClaimed = false;
|
|
30738
30788
|
const recoveryQueue = [];
|
|
30789
|
+
const attemptStartRetryCounts = /* @__PURE__ */ new Map();
|
|
30739
30790
|
const launchClaim = (claim, recovery, claimRequest) => {
|
|
30740
30791
|
if (!recovery) {
|
|
30741
30792
|
claimed += 1;
|
|
@@ -30748,6 +30799,10 @@ var init_runner = __esm({
|
|
|
30748
30799
|
claim.attempt_index,
|
|
30749
30800
|
claim.input_sha256
|
|
30750
30801
|
]);
|
|
30802
|
+
const nextStartRetryCount = Math.min(
|
|
30803
|
+
(attemptStartRetryCounts.get(attemptId) ?? 0) + 1,
|
|
30804
|
+
Number.MAX_SAFE_INTEGER
|
|
30805
|
+
);
|
|
30751
30806
|
const controller = new AbortController();
|
|
30752
30807
|
attemptControllers.set(attemptId, controller);
|
|
30753
30808
|
let claimPromotionSettled = claimRequest === void 0;
|
|
@@ -30812,13 +30867,27 @@ var init_runner = __esm({
|
|
|
30812
30867
|
active_attempts: active.size
|
|
30813
30868
|
});
|
|
30814
30869
|
},
|
|
30870
|
+
startRetryCount: nextStartRetryCount,
|
|
30871
|
+
onAttemptStartRetry: (observation) => {
|
|
30872
|
+
attemptStartRetryCounts.set(attemptId, observation.retry_count);
|
|
30873
|
+
emitDiagnostic("attempt_start_retry_scheduled", {
|
|
30874
|
+
...observation,
|
|
30875
|
+
job_id: claim.job_id,
|
|
30876
|
+
attempt_id: attemptId,
|
|
30877
|
+
active_attempts: active.size
|
|
30878
|
+
});
|
|
30879
|
+
},
|
|
30815
30880
|
resumeReceipt: recovery,
|
|
30816
30881
|
claimRequest,
|
|
30817
30882
|
onClaimPersisted: settleClaimPromotion
|
|
30818
30883
|
}).then((outcome) => {
|
|
30819
|
-
if (outcome === "completed")
|
|
30820
|
-
|
|
30821
|
-
|
|
30884
|
+
if (outcome === "completed") {
|
|
30885
|
+
attemptStartRetryCounts.delete(attemptId);
|
|
30886
|
+
completed += 1;
|
|
30887
|
+
} else if (outcome === "failed") {
|
|
30888
|
+
attemptStartRetryCounts.delete(attemptId);
|
|
30889
|
+
failed += 1;
|
|
30890
|
+
} else {
|
|
30822
30891
|
const recovery2 = receipt.attempts[attemptId];
|
|
30823
30892
|
if (recovery2?.phase !== "claimed") {
|
|
30824
30893
|
throw new InferenceHostRecoveryRequiredError(
|
|
@@ -30828,6 +30897,7 @@ var init_runner = __esm({
|
|
|
30828
30897
|
retryRecovery = recovery2;
|
|
30829
30898
|
}
|
|
30830
30899
|
}).catch((error48) => {
|
|
30900
|
+
attemptStartRetryCounts.delete(attemptId);
|
|
30831
30901
|
failed += 1;
|
|
30832
30902
|
const recovery2 = receipt.attempts[attemptId];
|
|
30833
30903
|
if (recovery2?.phase === "terminal_pending") {
|
|
@@ -30840,22 +30910,19 @@ var init_runner = __esm({
|
|
|
30840
30910
|
attemptControllers.delete(attemptId);
|
|
30841
30911
|
if (retryRecovery) {
|
|
30842
30912
|
recoveryQueue.push(retryRecovery);
|
|
30843
|
-
emitDiagnostic("attempt_start_retry_scheduled", {
|
|
30844
|
-
job_id: claim.job_id,
|
|
30845
|
-
attempt_id: attemptId,
|
|
30846
|
-
active_attempts: active.size
|
|
30847
|
-
});
|
|
30848
30913
|
}
|
|
30849
30914
|
});
|
|
30850
30915
|
active.set(attemptId, promise2);
|
|
30851
|
-
|
|
30852
|
-
|
|
30853
|
-
|
|
30854
|
-
|
|
30855
|
-
|
|
30856
|
-
|
|
30857
|
-
|
|
30858
|
-
|
|
30916
|
+
if (!recovery) {
|
|
30917
|
+
emitDiagnostic("attempt_started", {
|
|
30918
|
+
job_id: claim.job_id,
|
|
30919
|
+
attempt_id: attemptId,
|
|
30920
|
+
attempt_index: claim.attempt_index,
|
|
30921
|
+
requested_model: claim.requested_model,
|
|
30922
|
+
requested_reasoning_effort: claim.requested_reasoning_effort,
|
|
30923
|
+
active_attempts: active.size
|
|
30924
|
+
});
|
|
30925
|
+
}
|
|
30859
30926
|
return attemptId;
|
|
30860
30927
|
};
|
|
30861
30928
|
const removeRecoveredAttempt = async (attemptId) => {
|
|
@@ -31262,10 +31329,28 @@ var init_runner = __esm({
|
|
|
31262
31329
|
MIN_SLEEP_MS,
|
|
31263
31330
|
attemptDeadlineAtMs - now() - MIN_CLAIM_START_WINDOW_MS
|
|
31264
31331
|
);
|
|
31265
|
-
|
|
31266
|
-
Math.
|
|
31267
|
-
|
|
31332
|
+
const retryCount = Math.min(
|
|
31333
|
+
Math.max(1, options.startRetryCount),
|
|
31334
|
+
Number.MAX_SAFE_INTEGER
|
|
31335
|
+
);
|
|
31336
|
+
const retryDelayMs = Math.min(
|
|
31337
|
+
remoteRetryAfterMs(error48, attemptStartRetryFallbackMs(retryCount)),
|
|
31338
|
+
remainingMs
|
|
31268
31339
|
);
|
|
31340
|
+
const rawErrorCode = error48 && typeof error48 === "object" && "code" in error48 ? String(error48.code) : "start_acknowledgement_failed";
|
|
31341
|
+
options.onAttemptStartRetry?.({
|
|
31342
|
+
failure_stage: "job_start_acknowledgement",
|
|
31343
|
+
error_code: safeFailureCode(rawErrorCode, "start_acknowledgement_failed"),
|
|
31344
|
+
http_status_code: error48 instanceof ExternalInferenceMcpError ? error48.httpStatusCode : null,
|
|
31345
|
+
retryable: retryableRemoteError(error48),
|
|
31346
|
+
definitively_not_applied: Boolean(
|
|
31347
|
+
error48 && typeof error48 === "object" && "definitivelyNotApplied" in error48 && error48.definitivelyNotApplied === true
|
|
31348
|
+
),
|
|
31349
|
+
retry_after_ms: error48 instanceof ExternalInferenceMcpError ? error48.retryAfterMs : null,
|
|
31350
|
+
retry_count: retryCount,
|
|
31351
|
+
next_delay_ms: retryDelayMs
|
|
31352
|
+
});
|
|
31353
|
+
await options.sleep(retryDelayMs, signal);
|
|
31269
31354
|
return "retry_claimed";
|
|
31270
31355
|
}
|
|
31271
31356
|
assertStartResult(startRequest, startResult);
|
|
@@ -32983,8 +33068,8 @@ ${result2.stderr}`)) {
|
|
|
32983
33068
|
return !nextWorker || !sameWorker(record2.worker, nextWorker);
|
|
32984
33069
|
});
|
|
32985
33070
|
for (const record2 of retiring) {
|
|
32986
|
-
await updateRecord(record2, "draining");
|
|
32987
33071
|
record2.controller.abort();
|
|
33072
|
+
await updateRecord(record2, "draining");
|
|
32988
33073
|
}
|
|
32989
33074
|
const settled = await Promise.allSettled(retiring.map((record2) => record2.promise));
|
|
32990
33075
|
const failedDrain = settled.find(
|
|
@@ -33018,8 +33103,8 @@ ${result2.stderr}`)) {
|
|
|
33018
33103
|
const drainWorkers = async () => {
|
|
33019
33104
|
const draining = [...workers.values()];
|
|
33020
33105
|
for (const record2 of draining) {
|
|
33021
|
-
await updateRecord(record2, "draining");
|
|
33022
33106
|
record2.controller.abort();
|
|
33107
|
+
await updateRecord(record2, "draining");
|
|
33023
33108
|
}
|
|
33024
33109
|
const settled = await Promise.allSettled(draining.map((record2) => record2.promise));
|
|
33025
33110
|
const failedDrain = settled.find(
|