@duanluan/codex-plus-plus-launcher 1.2.18 → 1.2.22
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/codex_plus_plus_launcher/__init__.py +1 -1
- package/npm/launcher.js +146 -14
- package/package.json +1 -1
- package/upstream-bin/darwin-arm64/codex-plus-plus-manager +0 -0
- package/upstream-bin/darwin-x64/codex-plus-plus-manager +0 -0
- package/upstream-bin/upstream-release.json +1 -1
- package/upstream-bin/win32-x64/codex-plus-plus-manager.exe +0 -0
- package/upstream-bin/win32-x64/codex-plus-plus.exe +0 -0
package/npm/launcher.js
CHANGED
|
@@ -402,6 +402,39 @@ function findRunningSidecarProcesses(options = {}) {
|
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
+
function findRunningCodexPlusManagerProcesses(options = {}) {
|
|
406
|
+
const platform = optionValue(options, 'platform', process.platform);
|
|
407
|
+
if (platform !== 'win32') {
|
|
408
|
+
return [];
|
|
409
|
+
}
|
|
410
|
+
if (typeof options.findRunningCodexPlusManagerProcesses === 'function') {
|
|
411
|
+
return options.findRunningCodexPlusManagerProcesses(options) || [];
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
const run = options.processSpawnSync || (options.spawnSync ? null : spawnSync);
|
|
415
|
+
if (!run) {
|
|
416
|
+
return [];
|
|
417
|
+
}
|
|
418
|
+
const script = [
|
|
419
|
+
'$ErrorActionPreference = "SilentlyContinue"',
|
|
420
|
+
'Get-CimInstance Win32_Process | Where-Object {',
|
|
421
|
+
' $_.Name -ieq "codex-plus-plus-manager.exe"',
|
|
422
|
+
'} | Select-Object ProcessId,Name,ExecutablePath,CommandLine | ConvertTo-Json -Compress',
|
|
423
|
+
].join('\n');
|
|
424
|
+
const result = run('powershell.exe', ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', script], {
|
|
425
|
+
encoding: 'utf8',
|
|
426
|
+
windowsHide: true,
|
|
427
|
+
});
|
|
428
|
+
if (!result || result.status !== 0) {
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
try {
|
|
432
|
+
return parsePowerShellJson(result.stdout);
|
|
433
|
+
} catch (_error) {
|
|
434
|
+
return [];
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
405
438
|
function cdpTargetsAvailable(debugPort, options = {}) {
|
|
406
439
|
if (typeof options.cdpTargetsAvailable === 'function') {
|
|
407
440
|
return options.cdpTargetsAvailable(debugPort, options);
|
|
@@ -447,10 +480,12 @@ function exitSoon(code) {
|
|
|
447
480
|
}
|
|
448
481
|
}
|
|
449
482
|
|
|
450
|
-
|
|
483
|
+
const HTTP_HOSTS = ['localhost', '127.0.0.1', '::1'];
|
|
484
|
+
|
|
485
|
+
function readJsonFromHost(host, pathname) {
|
|
451
486
|
return new Promise((resolve, reject) => {
|
|
452
487
|
const request = http.get({
|
|
453
|
-
host
|
|
488
|
+
host,
|
|
454
489
|
port: debugPort,
|
|
455
490
|
path: pathname,
|
|
456
491
|
timeout: 1500,
|
|
@@ -471,13 +506,30 @@ function readJson(pathname) {
|
|
|
471
506
|
});
|
|
472
507
|
}
|
|
473
508
|
|
|
509
|
+
async function readJson(pathname) {
|
|
510
|
+
let lastError = null;
|
|
511
|
+
for (const host of HTTP_HOSTS) {
|
|
512
|
+
try {
|
|
513
|
+
return await readJsonFromHost(host, pathname);
|
|
514
|
+
} catch (error) {
|
|
515
|
+
lastError = error;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
throw lastError || new Error('CDP HTTP unavailable');
|
|
519
|
+
}
|
|
520
|
+
|
|
474
521
|
function parseWebSocketTarget(webSocketDebuggerUrl) {
|
|
475
522
|
const parsed = new URL(webSocketDebuggerUrl);
|
|
476
523
|
if (parsed.protocol !== 'ws:') {
|
|
477
524
|
throw new Error('unsupported websocket protocol');
|
|
478
525
|
}
|
|
526
|
+
const host = parsed.hostname.startsWith('[') && parsed.hostname.endsWith(']')
|
|
527
|
+
? parsed.hostname.slice(1, -1)
|
|
528
|
+
: parsed.hostname;
|
|
529
|
+
const hostHeader = host.includes(':') ? '[' + host + ']' : host;
|
|
479
530
|
return {
|
|
480
|
-
host
|
|
531
|
+
host,
|
|
532
|
+
hostHeader,
|
|
481
533
|
port: Number(parsed.port || 80),
|
|
482
534
|
path: (parsed.pathname || '/') + (parsed.search || ''),
|
|
483
535
|
};
|
|
@@ -617,7 +669,7 @@ function evaluateMenuState(webSocketDebuggerUrl) {
|
|
|
617
669
|
const key = crypto.randomBytes(16).toString('base64');
|
|
618
670
|
socket.write([
|
|
619
671
|
'GET ' + target.path + ' HTTP/1.1',
|
|
620
|
-
'Host: ' + target.
|
|
672
|
+
'Host: ' + target.hostHeader + ':' + target.port,
|
|
621
673
|
'Upgrade: websocket',
|
|
622
674
|
'Connection: Upgrade',
|
|
623
675
|
'Sec-WebSocket-Key: ' + key,
|
|
@@ -758,6 +810,22 @@ function preflightWindowsCodexLaunch(args = [], options = {}) {
|
|
|
758
810
|
const requestedDebugPort = launchDebugPort(args);
|
|
759
811
|
const runningDebugPorts = codexProcessDebugPorts(processes);
|
|
760
812
|
const portsToCheck = runningDebugPorts.length > 0 ? runningDebugPorts : [requestedDebugPort];
|
|
813
|
+
if (runningDebugPorts.length === 0) {
|
|
814
|
+
const terminate = options.terminateProcesses || terminateProcesses;
|
|
815
|
+
terminate(processes, options);
|
|
816
|
+
const sidecars = findRunningSidecarProcesses(options);
|
|
817
|
+
if (sidecars.length > 0) {
|
|
818
|
+
terminate(sidecars, options);
|
|
819
|
+
} else {
|
|
820
|
+
terminateSidecarsByImageName(options);
|
|
821
|
+
}
|
|
822
|
+
return {
|
|
823
|
+
action: 'terminated_codex_for_missing_cdp',
|
|
824
|
+
debugPort: requestedDebugPort,
|
|
825
|
+
processCount: processes.length,
|
|
826
|
+
sidecarCount: sidecars.length,
|
|
827
|
+
};
|
|
828
|
+
}
|
|
761
829
|
if (runningDebugPorts.length > 0) {
|
|
762
830
|
const availableDebugPort = portsToCheck.find((debugPort) => cdpTargetsAvailable(debugPort, options));
|
|
763
831
|
if (availableDebugPort) {
|
|
@@ -1019,9 +1087,8 @@ async function installSidecars(options = {}) {
|
|
|
1019
1087
|
return installed;
|
|
1020
1088
|
}
|
|
1021
1089
|
|
|
1022
|
-
function
|
|
1090
|
+
function readInstalledSidecarStampVersion(options = {}) {
|
|
1023
1091
|
const fsImpl = options.fs || fs;
|
|
1024
|
-
const platform = optionValue(options, 'platform', process.platform);
|
|
1025
1092
|
const installRoot = optionValue(options, 'installRoot', () => detectedInstallRoot(options));
|
|
1026
1093
|
const stampPath = path.join(installRoot, SIDECAR_VERSION_STAMP);
|
|
1027
1094
|
try {
|
|
@@ -1031,21 +1098,25 @@ function readInstalledSidecarVersion(options = {}) {
|
|
|
1031
1098
|
return first;
|
|
1032
1099
|
}
|
|
1033
1100
|
} catch (_error) {
|
|
1034
|
-
// stamp absent or unreadable
|
|
1035
|
-
}
|
|
1036
|
-
if (platform !== 'win32') {
|
|
1037
|
-
return null;
|
|
1101
|
+
// stamp absent or unreadable
|
|
1038
1102
|
}
|
|
1103
|
+
return null;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
function readWindowsSidecarBinaryVersion(options = {}) {
|
|
1107
|
+
const fsImpl = options.fs || fs;
|
|
1108
|
+
const installRoot = optionValue(options, 'installRoot', () => detectedInstallRoot(options));
|
|
1039
1109
|
const silent = installedSidecarPath('silent', { ...options, installRoot });
|
|
1040
1110
|
if (!fsImpl.existsSync(silent)) {
|
|
1041
1111
|
return null;
|
|
1042
1112
|
}
|
|
1043
1113
|
const run = options.spawnSync || spawnSync;
|
|
1044
1114
|
try {
|
|
1115
|
+
const env = { ...(options.env || process.env), CODEXPP_VERSION_PROBE_PATH: silent };
|
|
1045
1116
|
const result = run(
|
|
1046
|
-
'powershell',
|
|
1047
|
-
['-NoProfile', '-NonInteractive', '-Command', '(Get-Item -LiteralPath $
|
|
1048
|
-
{ encoding: 'utf8', windowsHide: true },
|
|
1117
|
+
'powershell.exe',
|
|
1118
|
+
['-NoProfile', '-NonInteractive', '-Command', '(Get-Item -LiteralPath $env:CODEXPP_VERSION_PROBE_PATH).VersionInfo.FileVersion'],
|
|
1119
|
+
{ encoding: 'utf8', env, windowsHide: true },
|
|
1049
1120
|
);
|
|
1050
1121
|
if (result && result.status === 0) {
|
|
1051
1122
|
const out = String(result.stdout || '').trim();
|
|
@@ -1059,6 +1130,14 @@ function readInstalledSidecarVersion(options = {}) {
|
|
|
1059
1130
|
return null;
|
|
1060
1131
|
}
|
|
1061
1132
|
|
|
1133
|
+
function readInstalledSidecarVersion(options = {}) {
|
|
1134
|
+
const platform = optionValue(options, 'platform', process.platform);
|
|
1135
|
+
if (platform !== 'win32') {
|
|
1136
|
+
return readInstalledSidecarStampVersion(options);
|
|
1137
|
+
}
|
|
1138
|
+
return readWindowsSidecarBinaryVersion(options) || readInstalledSidecarStampVersion(options);
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1062
1141
|
function computeSidecarDrift(options = {}) {
|
|
1063
1142
|
const platform = optionValue(options, 'platform', process.platform);
|
|
1064
1143
|
const arch = optionValue(options, 'arch', process.arch);
|
|
@@ -1079,6 +1158,38 @@ function computeSidecarDrift(options = {}) {
|
|
|
1079
1158
|
return installed === bundled ? 'none' : 'mismatch';
|
|
1080
1159
|
}
|
|
1081
1160
|
|
|
1161
|
+
function stopCodexPlusProcesses(options = {}) {
|
|
1162
|
+
const platform = optionValue(options, 'platform', process.platform);
|
|
1163
|
+
if (platform !== 'win32') {
|
|
1164
|
+
return { status: 1, error: new Error('cxpp stop is only supported on Windows in this package') };
|
|
1165
|
+
}
|
|
1166
|
+
const sidecars = findRunningSidecarProcesses(options);
|
|
1167
|
+
const managers = findRunningCodexPlusManagerProcesses(options);
|
|
1168
|
+
const codex = findRunningCodexProcesses(options);
|
|
1169
|
+
const targets = [...sidecars, ...managers, ...codex];
|
|
1170
|
+
const uniqueTargets = [];
|
|
1171
|
+
const seen = new Set();
|
|
1172
|
+
for (const target of targets) {
|
|
1173
|
+
const id = Number(target && target.ProcessId);
|
|
1174
|
+
if (!Number.isInteger(id) || id <= 0 || seen.has(id)) {
|
|
1175
|
+
continue;
|
|
1176
|
+
}
|
|
1177
|
+
seen.add(id);
|
|
1178
|
+
uniqueTargets.push(target);
|
|
1179
|
+
}
|
|
1180
|
+
if (uniqueTargets.length > 0) {
|
|
1181
|
+
const terminate = options.terminateProcesses || terminateProcesses;
|
|
1182
|
+
terminate(uniqueTargets, options);
|
|
1183
|
+
}
|
|
1184
|
+
return {
|
|
1185
|
+
status: 0,
|
|
1186
|
+
stoppedCount: uniqueTargets.length,
|
|
1187
|
+
sidecarCount: sidecars.length,
|
|
1188
|
+
managerCount: managers.length,
|
|
1189
|
+
codexCount: codex.length,
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1082
1193
|
async function ensureSidecarsFresh(options = {}) {
|
|
1083
1194
|
const drift = computeSidecarDrift(options);
|
|
1084
1195
|
if (drift === 'none' || drift === 'unsupported') {
|
|
@@ -1814,17 +1925,23 @@ function doctorReport(options = {}) {
|
|
|
1814
1925
|
const sidecars = installedSidecars(options);
|
|
1815
1926
|
const entrypoints = inspectEntrypoints(options);
|
|
1816
1927
|
const supported = SUPPORTED_PLATFORMS.has(platformKey(platform, arch));
|
|
1928
|
+
const installedVersion = readInstalledSidecarVersion({ ...options, installRoot });
|
|
1929
|
+
const expectedVersion = packageVersion(options);
|
|
1930
|
+
const drift = computeSidecarDrift(options);
|
|
1817
1931
|
const report = {
|
|
1818
1932
|
platform,
|
|
1819
1933
|
arch,
|
|
1820
1934
|
supported: supported ? 'yes' : 'no',
|
|
1821
|
-
package_version:
|
|
1935
|
+
package_version: expectedVersion,
|
|
1822
1936
|
upstream_version: bundledUpstreamVersion(options) || 'missing',
|
|
1823
1937
|
upstream_commit: upstreamMetadata(options).commit || 'missing',
|
|
1824
1938
|
sidecar_dir: upstreamBinDir(options),
|
|
1825
1939
|
install_root: installRoot,
|
|
1826
1940
|
silent_binary: sidecars.silent,
|
|
1827
1941
|
silent_binary_state: sidecars.silent_state,
|
|
1942
|
+
expected_sidecar_version: expectedVersion,
|
|
1943
|
+
installed_sidecar_version: installedVersion || 'missing',
|
|
1944
|
+
sidecar_drift: drift,
|
|
1828
1945
|
manager_binary: sidecars.manager,
|
|
1829
1946
|
manager_binary_state: sidecars.manager_state,
|
|
1830
1947
|
silent_entrypoint_state: entrypoints.silent,
|
|
@@ -1927,6 +2044,7 @@ Usage:
|
|
|
1927
2044
|
cxpp manager Open Codex++ manager
|
|
1928
2045
|
cxpp install-app Install or repair local entrypoints
|
|
1929
2046
|
cxpp repair-app Alias of install-app
|
|
2047
|
+
cxpp stop Stop running Codex++ and Codex processes
|
|
1930
2048
|
cxpp doctor [--json] Inspect local state
|
|
1931
2049
|
cxpp version Print wrapper version
|
|
1932
2050
|
`);
|
|
@@ -1945,6 +2063,17 @@ async function runLauncher(args = [], options = {}) {
|
|
|
1945
2063
|
if (command === 'doctor') {
|
|
1946
2064
|
return { status: printDoctor(args.includes('--json'), options) };
|
|
1947
2065
|
}
|
|
2066
|
+
if (command === 'stop') {
|
|
2067
|
+
const result = stopCodexPlusProcesses(options);
|
|
2068
|
+
if (result.error) {
|
|
2069
|
+
return result;
|
|
2070
|
+
}
|
|
2071
|
+
console.log(`stopped_processes=${result.stoppedCount}`);
|
|
2072
|
+
console.log(`sidecar_processes=${result.sidecarCount}`);
|
|
2073
|
+
console.log(`manager_processes=${result.managerCount}`);
|
|
2074
|
+
console.log(`codex_processes=${result.codexCount}`);
|
|
2075
|
+
return result;
|
|
2076
|
+
}
|
|
1948
2077
|
if (command === 'install-app' || command === 'repair-app' || command === 'setup' || command === 'repair' || command === 'npm-postinstall') {
|
|
1949
2078
|
const supported = SUPPORTED_PLATFORMS.has(platformKey(optionValue(options, 'platform', process.platform), optionValue(options, 'arch', process.arch)));
|
|
1950
2079
|
if (!supported) {
|
|
@@ -2028,9 +2157,12 @@ module.exports = {
|
|
|
2028
2157
|
sidecarArgsWithDebugPort,
|
|
2029
2158
|
promptYesNoWindowsPopup,
|
|
2030
2159
|
readInstalledSidecarVersion,
|
|
2160
|
+
readInstalledSidecarStampVersion,
|
|
2161
|
+
readWindowsSidecarBinaryVersion,
|
|
2031
2162
|
removePath,
|
|
2032
2163
|
runLauncher,
|
|
2033
2164
|
spawnSidecar,
|
|
2165
|
+
stopCodexPlusProcesses,
|
|
2034
2166
|
terminateProcesses,
|
|
2035
2167
|
terminateSidecarsByImageName,
|
|
2036
2168
|
upstreamBinDir,
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|