agentroam 0.2.0-preview.63 → 0.2.0-preview.64
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/dist/codex-desktop-command.js +7 -1
- package/dist/codex-desktop-force-stop.js +46 -0
- package/dist/codex-desktop-setup.js +34 -3
- package/dist/codex-desktop-windows.js +122 -0
- package/dist/codex-sharing.js +3 -3
- package/dist/codex-windows-backend-host.js +59 -0
- package/dist/codex-windows-backend.js +120 -0
- package/dist/runtime-manager.js +10 -0
- package/dist/service/service-command.js +1 -1
- package/install/install-agentroam.ps1 +1 -1
- package/install/install-manifest.json +2 -2
- package/install/start-codex-desktop-shared.sh +11 -8
- package/package.json +5 -5
|
@@ -5,12 +5,17 @@ import { resolveCodexRuntime } from "./codex-runtime-manager.js";
|
|
|
5
5
|
import { readServiceConfig, resolveServicePaths } from "./service/service-files.js";
|
|
6
6
|
import { detectPlatform } from "./platform.js";
|
|
7
7
|
import { configureCodexSharing, inspectCodexSharing } from "./codex-sharing.js";
|
|
8
|
+
import { runWindowsCodexDesktop } from "./codex-desktop-windows.js";
|
|
8
9
|
const execFileAsync = promisify(execFile);
|
|
9
10
|
const scriptPath = fileURLToPath(new URL("../install/start-codex-desktop-shared.sh", import.meta.url));
|
|
10
11
|
export async function runCodexDesktopCommand(options, context = {}) {
|
|
11
12
|
const platform = context.platform ?? process.platform;
|
|
13
|
+
if (platform === "win32") {
|
|
14
|
+
await runWindowsCodexDesktop(options, context);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
12
17
|
if (platform !== "darwin")
|
|
13
|
-
throw new Error("
|
|
18
|
+
throw new Error("当前系统不支持官方 Codex 桌面共享后端入口");
|
|
14
19
|
const log = context.log ?? console.log;
|
|
15
20
|
const environment = { ...(context.environment ?? process.env) };
|
|
16
21
|
const service = await (context.readConfig ?? (() => readServiceConfig(resolveServicePaths())))();
|
|
@@ -43,6 +48,7 @@ export async function runCodexDesktopCommand(options, context = {}) {
|
|
|
43
48
|
if (!options.desktopDryRun) {
|
|
44
49
|
environment.AGENTROAM_CODEX_DESKTOP_PREFLIGHT_NODE = process.execPath;
|
|
45
50
|
environment.AGENTROAM_CODEX_DESKTOP_PREFLIGHT = fileURLToPath(new URL("./codex-desktop-preflight.js", import.meta.url));
|
|
51
|
+
environment.AGENTROAM_CODEX_DESKTOP_FORCE_STOP = fileURLToPath(new URL("./codex-desktop-force-stop.js", import.meta.url));
|
|
46
52
|
}
|
|
47
53
|
if (options.desktopRestart)
|
|
48
54
|
args.push("--restart");
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
function snapshot() {
|
|
4
|
+
return execFileSync("/bin/ps", ["-axo", "pid=,ppid=,lstart=,args="], { encoding: "utf8" }).split("\n").flatMap(line => {
|
|
5
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(\S+\s+\S+\s+\d+\s+\S+\s+\d+)\s+(.+)$/.exec(line);
|
|
6
|
+
return match ? [{ pid: Number(match[1]), parent: Number(match[2]), started: match[3], command: match[4] }] : [];
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
export function forceStopCodexDesktop(pid, binary, context = {}) {
|
|
10
|
+
const read = context.snapshot ?? snapshot;
|
|
11
|
+
const initial = read();
|
|
12
|
+
const desktop = initial.find(row => row.pid === pid && (row.command === binary || row.command.startsWith(`${binary} `)));
|
|
13
|
+
if (!desktop)
|
|
14
|
+
throw new Error("Desktop process changed; no forced restart attempted.");
|
|
15
|
+
const appRoot = binary.slice(0, binary.lastIndexOf("/Contents/MacOS/"));
|
|
16
|
+
const backends = initial.filter(row => row.parent === pid && row.command.startsWith(`${appRoot}/Contents/`)
|
|
17
|
+
&& /\/codex\s.*\bapp-server(?:\s|$)/.test(row.command) && !/\bapp-server\s+(?:proxy|daemon)\b/.test(row.command));
|
|
18
|
+
for (const target of [...backends, desktop]) {
|
|
19
|
+
const current = read().find(row => row.pid === target.pid);
|
|
20
|
+
if (!current)
|
|
21
|
+
continue;
|
|
22
|
+
if (current.started !== target.started || current.command !== target.command || current.parent !== target.parent) {
|
|
23
|
+
throw new Error("Desktop process identity changed; forced restart stopped.");
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
(context.kill ?? (targetPid => process.kill(targetPid, "SIGKILL")))(target.pid);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code !== "ESRCH")
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
35
|
+
try {
|
|
36
|
+
const pid = Number(process.argv[2]);
|
|
37
|
+
const binary = process.argv[3];
|
|
38
|
+
if (!Number.isSafeInteger(pid) || pid <= 1 || !binary?.includes("/Contents/MacOS/"))
|
|
39
|
+
throw new Error("Invalid Desktop process identity");
|
|
40
|
+
forceStopCodexDesktop(pid, binary);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
console.error(error instanceof Error ? error.message : error);
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -4,9 +4,27 @@ import { ReadStream, WriteStream } from "node:tty";
|
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { runCodexDesktopCommand } from "./codex-desktop-command.js";
|
|
6
6
|
import { inspectCodexDesktop } from "./codex-desktop-status.js";
|
|
7
|
-
import { configureCodexSharing } from "./codex-sharing.js";
|
|
7
|
+
import { configureCodexSharing, inspectCodexSharing } from "./codex-sharing.js";
|
|
8
8
|
import { withoutCliProgress } from "../bin/cli-progress.mjs";
|
|
9
|
+
import { runWindowsCodexDesktop } from "./codex-desktop-windows.js";
|
|
9
10
|
export async function setupCodexDesktop(options, context = {}) {
|
|
11
|
+
if ((context.platform ?? process.platform) === "win32") {
|
|
12
|
+
const inherited = context.environment ?? process.env;
|
|
13
|
+
const environment = { ...inherited, AGENTROAM_CODEX_DESKTOP_NONINTERACTIVE: "1" };
|
|
14
|
+
if (context.service?.dataDir === options.dataDir) {
|
|
15
|
+
if (!environment.CODEX_HOME && context.service.codexHome)
|
|
16
|
+
environment.CODEX_HOME = context.service.codexHome;
|
|
17
|
+
if (!environment.AGENT_CODEX_BIN && context.service.codexPath)
|
|
18
|
+
environment.AGENT_CODEX_BIN = context.service.codexPath;
|
|
19
|
+
}
|
|
20
|
+
const result = await runWindowsCodexDesktop(options, { environment, log: context.log });
|
|
21
|
+
if (result.state === "independent" && inherited.AGENTROAM_CODEX_DESKTOP_NONINTERACTIVE !== "1") {
|
|
22
|
+
const answer = await withoutCliProgress(() => (context.confirm ?? confirmDesktopRestart)("Force restart Codex Desktop? Running tasks and unsent input may be lost [y/N]: "));
|
|
23
|
+
if (/^(y|yes)$/i.test(answer?.trim() ?? ""))
|
|
24
|
+
await runWindowsCodexDesktop({ ...options, desktopSetup: false, desktopRestart: true }, { environment, log: context.log });
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
10
28
|
if ((context.platform ?? process.platform) !== "darwin")
|
|
11
29
|
return;
|
|
12
30
|
const log = context.log ?? console.log;
|
|
@@ -21,12 +39,20 @@ export async function setupCodexDesktop(options, context = {}) {
|
|
|
21
39
|
const deferred = () => log("Current Codex Desktop preserved. Scan to connect to AgentRoam; existing desktop sessions are not shared yet. Run agentroam codex-desktop --setup later.");
|
|
22
40
|
try {
|
|
23
41
|
await (context.configureSharing ?? configureCodexSharing)(options, { environment });
|
|
24
|
-
log("Saved
|
|
42
|
+
log("Saved shared backend and background recovery settings. Use the avatar menu to switch if Desktop starts independently.");
|
|
43
|
+
if ((await (context.inspectSharing ?? inspectCodexSharing)({ environment })).state === "shared") {
|
|
44
|
+
log("Codex Desktop already uses the shared backend; no restart needed.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
25
47
|
let snapshot = await inspect(environment);
|
|
26
48
|
if (snapshot.status === "not-installed") {
|
|
27
49
|
log("Codex Desktop is not installed. Continuing with phone pairing.");
|
|
28
50
|
return;
|
|
29
51
|
}
|
|
52
|
+
if (snapshot.status === "stopped") {
|
|
53
|
+
log("Shared backend configured. Codex Desktop remains closed; open it normally when needed.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
30
56
|
const original = snapshot;
|
|
31
57
|
let restartConfirmed = false;
|
|
32
58
|
if (snapshot.status === "running" && snapshot.activity.state === "idle") {
|
|
@@ -43,7 +69,12 @@ export async function setupCodexDesktop(options, context = {}) {
|
|
|
43
69
|
? `Codex Desktop has ${snapshot.activity.activeCount} active sessions.`
|
|
44
70
|
: "Cannot reliably confirm that all Codex Desktop tasks have finished.";
|
|
45
71
|
log(reason);
|
|
46
|
-
|
|
72
|
+
if (environment.AGENTROAM_CODEX_DESKTOP_NONINTERACTIVE === "1") {
|
|
73
|
+
log(JSON.stringify({ codexSharingAction: "confirmation-required" }));
|
|
74
|
+
deferred();
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const answer = await withoutCliProgress(() => (context.confirm ?? confirmDesktopRestart)("Force restart Desktop now to share sessions? This will interrupt all running desktop tasks and may lose unsent input. No Codex quit dialog will appear. Continue [y/N]: "));
|
|
47
78
|
if (!answer || !/^(?:y|yes)$/i.test(answer.trim())) {
|
|
48
79
|
deferred();
|
|
49
80
|
return;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { withDesktopRpc } from "./codex-desktop-probe.js";
|
|
4
|
+
import { ensureWindowsBackend, readWindowsBackend, WINDOWS_CODEX_TASK } from "./codex-windows-backend.js";
|
|
5
|
+
const executeFile = promisify(execFile);
|
|
6
|
+
export function windowsSharingEndpoint(environment) {
|
|
7
|
+
const endpoint = environment.AGENT_CODEX_DESKTOP_WS_URL || environment.CODEX_APP_SERVER_WS_URL;
|
|
8
|
+
if (!endpoint)
|
|
9
|
+
return null;
|
|
10
|
+
const url = new URL(endpoint);
|
|
11
|
+
if (url.protocol !== "ws:" || !["127.0.0.1", "localhost", "[::1]"].includes(url.hostname)
|
|
12
|
+
|| url.username || url.password || url.search || url.hash)
|
|
13
|
+
throw new Error("Windows 共享后端必须使用无凭据的本机 WebSocket 地址。");
|
|
14
|
+
return url.href;
|
|
15
|
+
}
|
|
16
|
+
export function powershellLiteral(value) { return `'${value.replaceAll("'", "''")}'`; }
|
|
17
|
+
export async function runWindowsCodexDesktop(options, context = {}) {
|
|
18
|
+
const environment = { ...(context.environment ?? process.env) };
|
|
19
|
+
const log = context.log ?? console.log;
|
|
20
|
+
const execute = context.execute ?? executeFile;
|
|
21
|
+
const run = (script) => execute("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `$ErrorActionPreference='Stop'; ${script}`], { env: environment, encoding: "utf8", timeout: 15_000, maxBuffer: 1024 * 1024, windowsHide: true });
|
|
22
|
+
const report = { state: "unsupported", configured: false, autoStart: false, daemonReachable: false,
|
|
23
|
+
message: "Windows 共享后台尚未就绪;已保留 Codex,不会强制重启。" };
|
|
24
|
+
let endpoint = windowsSharingEndpoint(environment);
|
|
25
|
+
if (!endpoint) {
|
|
26
|
+
const config = options.desktopSharingStatus || options.desktopDryRun
|
|
27
|
+
? await (context.readBackend ?? readWindowsBackend)()
|
|
28
|
+
: await (context.backend ?? ensureWindowsBackend)(options.dataDir, { environment, execute });
|
|
29
|
+
if (config) {
|
|
30
|
+
endpoint = config.endpoint;
|
|
31
|
+
environment.CODEX_HOME = config.codexHome;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!endpoint) {
|
|
35
|
+
report.state = "failed";
|
|
36
|
+
report.message = "Windows 共享后台尚未配置,请运行安装或点击检查并修复。";
|
|
37
|
+
log(JSON.stringify(report));
|
|
38
|
+
return report;
|
|
39
|
+
}
|
|
40
|
+
environment.AGENT_CODEX_DESKTOP_WS_URL = endpoint;
|
|
41
|
+
let binary = environment.CODEX_DESKTOP_APP;
|
|
42
|
+
if (!binary) {
|
|
43
|
+
const { stdout } = await run(`$candidates=@(); $sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; Get-CimInstance Win32_Process | Where-Object { $_.Name -in @('Codex.exe','ChatGPT.exe') -and $_.CommandLine -notmatch '--type=' } | ForEach-Object { if ((Invoke-CimMethod -InputObject $_ -MethodName GetOwnerSid).Sid -eq $sid) { $candidates += $_.ExecutablePath } }; Get-AppxPackage | Where-Object { $_.Name -match 'OpenAI.*(Codex|ChatGPT)' } | ForEach-Object { $root=$_.InstallLocation; $manifest=Get-AppxPackageManifest $_; $manifest.Package.Applications.Application | ForEach-Object { if ($_.Executable) { $candidates += Join-Path $root $_.Executable } } }; $candidates += @((Join-Path $env:LOCALAPPDATA 'Programs\\Codex\\Codex.exe'),(Join-Path $env:LOCALAPPDATA 'Programs\\ChatGPT\\ChatGPT.exe')); foreach($candidate in ($candidates | Select-Object -Unique)) { if ($candidate -and (Test-Path -LiteralPath $candidate -PathType Leaf) -and [IO.Path]::GetFileName($candidate) -in @('Codex.exe','ChatGPT.exe')) { $signature=Get-AuthenticodeSignature -LiteralPath $candidate; if ($signature.Status -eq 'Valid' -and $signature.SignerCertificate.Subject -match 'OpenAI') { Write-Output $candidate; break } } }`);
|
|
44
|
+
binary = stdout.trim() || undefined;
|
|
45
|
+
}
|
|
46
|
+
if (!binary || !/^[A-Za-z]:\\.*\.exe$/i.test(binary)) {
|
|
47
|
+
report.state = "not-installed";
|
|
48
|
+
report.message = "未找到当前用户安装的官方 Codex 桌面端;不会结束其他程序。";
|
|
49
|
+
log(JSON.stringify(report));
|
|
50
|
+
return report;
|
|
51
|
+
}
|
|
52
|
+
const encodedBinary = powershellLiteral(binary);
|
|
53
|
+
const { stdout: supported } = await run(`$signature=Get-AuthenticodeSignature -LiteralPath ${encodedBinary}; if ($signature.Status -ne 'Valid' -or $signature.SignerCertificate.Subject -notmatch 'OpenAI') { throw 'Not an official signed Desktop executable' }; $archive=Join-Path (Split-Path ${encodedBinary}) 'resources\\app.asar'; if (Test-Path -LiteralPath $archive) { $text=[Text.Encoding]::UTF8.GetString([IO.File]::ReadAllBytes($archive)); if ($text.Contains('CODEX_APP_SERVER_WS_URL')) { 'supported' } }`);
|
|
54
|
+
if (supported.trim() !== "supported") {
|
|
55
|
+
report.message = "当前 Windows 官方桌面版本未提供可确认的共享连接能力,已保留进程。";
|
|
56
|
+
log(JSON.stringify(report));
|
|
57
|
+
return report;
|
|
58
|
+
}
|
|
59
|
+
const processes = async () => {
|
|
60
|
+
const { stdout } = await run(`$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; @((Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -eq ${encodedBinary} -and $_.CommandLine -notmatch '--type=' -and (Invoke-CimMethod -InputObject $_ -MethodName GetOwnerSid).Sid -eq $sid }) | Select-Object ProcessId,@{Name='CreationDate';Expression={$_.CreationDate.ToString('o')}},ExecutablePath) | ConvertTo-Json -Compress`);
|
|
61
|
+
const rows = JSON.parse(stdout.trim() || "[]");
|
|
62
|
+
return (Array.isArray(rows) ? rows : [rows]);
|
|
63
|
+
};
|
|
64
|
+
const initial = await processes();
|
|
65
|
+
if (initial.length > 1)
|
|
66
|
+
throw new Error("检测到多个 Codex 桌面实例,无法安全确定重启目标。");
|
|
67
|
+
report.backendEndpoint = endpoint;
|
|
68
|
+
const { stdout: task } = await run(`$task=Get-ScheduledTask -TaskName '${WINDOWS_CODEX_TASK}' -ErrorAction SilentlyContinue; if ($task -and $task.State -eq 'Running') { 'running' }`);
|
|
69
|
+
report.autoStart = task.trim() === "running";
|
|
70
|
+
report.state = initial.length ? "independent" : "stopped";
|
|
71
|
+
if (!options.desktopDryRun) {
|
|
72
|
+
await (context.probe ?? (async (url) => { await withDesktopRpc(url, async (request) => { await request("config/read", { includeLayers: false }); }); }))(endpoint);
|
|
73
|
+
report.daemonReachable = true;
|
|
74
|
+
}
|
|
75
|
+
const { stdout: defaults } = await run(`[Environment]::GetEnvironmentVariable('CODEX_APP_SERVER_WS_URL','User')`);
|
|
76
|
+
report.configured = defaults.trim() === endpoint;
|
|
77
|
+
if (initial.length && report.daemonReachable) {
|
|
78
|
+
const port = new URL(endpoint).port || "80";
|
|
79
|
+
const { stdout } = await run(`$listeners=@(Get-NetTCPConnection -State Listen -LocalPort ${port} -ErrorAction SilentlyContinue); if ($listeners.Count -eq 0 -or @($listeners | Where-Object { $_.LocalAddress -notin @('127.0.0.1','::1') -or $_.OwningProcess -eq ${initial[0].ProcessId} }).Count -gt 0) { throw 'Shared endpoint ownership unavailable' }; $ids=@(${initial[0].ProcessId}); $family=@(Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -eq ${encodedBinary} }); do { $added=@($family | Where-Object { $_.ParentProcessId -in $ids -and $_.ProcessId -notin $ids } | ForEach-Object { $_.ProcessId }); $ids += $added } while ($added.Count -gt 0); @(Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue | Where-Object { $_.OwningProcess -in $ids -and $_.RemotePort -eq ${port} -and $_.RemoteAddress -in @('127.0.0.1','::1') }).Count`);
|
|
80
|
+
if (Number(stdout.trim()) > 0)
|
|
81
|
+
report.state = "shared";
|
|
82
|
+
}
|
|
83
|
+
report.message = report.state === "shared" ? "Codex 已连接配置的共享后台。" : report.state === "stopped" ? "共享后端可用;Codex 桌面保持关闭。" : "Codex 未连接共享后台;Windows 暂无法可靠判断桌面任务,切换前需要确认强制重启。";
|
|
84
|
+
if (options.desktopDryRun) {
|
|
85
|
+
log(JSON.stringify({ ...report, message: "Dry run: 未写配置、未启动或结束任何进程。" }));
|
|
86
|
+
return report;
|
|
87
|
+
}
|
|
88
|
+
if (options.desktopSharingStatus) {
|
|
89
|
+
log(JSON.stringify(report));
|
|
90
|
+
return report;
|
|
91
|
+
}
|
|
92
|
+
await run(`[Environment]::SetEnvironmentVariable('CODEX_APP_SERVER_WS_URL',${powershellLiteral(endpoint)},'User'); [Environment]::SetEnvironmentVariable('CODEX_APP_SERVER_FORCE_CLI','0','User')`);
|
|
93
|
+
await run(`Add-Type -Namespace AgentRoam -Name EnvironmentBroadcast -MemberDefinition '[DllImport("user32.dll", CharSet=CharSet.Unicode, SetLastError=true)] public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, UIntPtr wParam, string lParam, uint flags, uint timeout, out UIntPtr result);'; $result=[UIntPtr]::Zero; [AgentRoam.EnvironmentBroadcast]::SendMessageTimeout([IntPtr]0xffff,0x1a,[UIntPtr]::Zero,'Environment',2,3000,[ref]$result) | Out-Null`);
|
|
94
|
+
report.configured = true;
|
|
95
|
+
if (options.desktopRepair || report.state === "shared") {
|
|
96
|
+
log(JSON.stringify(report));
|
|
97
|
+
return report;
|
|
98
|
+
}
|
|
99
|
+
if (options.desktopSetup && report.state === "stopped") {
|
|
100
|
+
log(JSON.stringify(report));
|
|
101
|
+
return report;
|
|
102
|
+
}
|
|
103
|
+
if (initial.length && !options.desktopRestart) {
|
|
104
|
+
if (options.desktopSetup && environment.AGENTROAM_CODEX_DESKTOP_NONINTERACTIVE === "1") {
|
|
105
|
+
log(JSON.stringify({ codexSharingAction: "confirmation-required" }));
|
|
106
|
+
log(JSON.stringify(report));
|
|
107
|
+
return report;
|
|
108
|
+
}
|
|
109
|
+
throw new Error("Windows 桌面任务状态无法确认。请确认中断风险后使用 --restart;不会自动结束进程。");
|
|
110
|
+
}
|
|
111
|
+
if (initial.length) {
|
|
112
|
+
const target = initial[0];
|
|
113
|
+
if (!Number.isSafeInteger(target.ProcessId) || target.ProcessId <= 1)
|
|
114
|
+
throw new Error("无效的桌面 PID");
|
|
115
|
+
await run(`$target=Get-CimInstance Win32_Process -Filter 'ProcessId=${target.ProcessId}'; if (!$target -or $target.ExecutablePath -ne ${encodedBinary} -or $target.CreationDate.ToString('o') -ne ${powershellLiteral(String(target.CreationDate))}) { throw 'Desktop process identity changed' }; $sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; if ((Invoke-CimMethod -InputObject $target -MethodName GetOwnerSid).Sid -ne $sid) { throw 'Desktop user changed' }; $root=(Split-Path ${encodedBinary}) + '\\'; $private=@(Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq ${target.ProcessId} -and $_.ExecutablePath -and $_.ExecutablePath.StartsWith($root,[StringComparison]::OrdinalIgnoreCase) -and $_.Name -eq 'codex.exe' -and $_.CommandLine -match '\\sapp-server(?:\\s|$)' -and $_.CommandLine -notmatch '\\s(proxy|daemon)(?:\\s|$)|--managed-daemon' }); foreach($child in $private) { $live=Get-CimInstance Win32_Process -Filter "ProcessId=$($child.ProcessId)"; if (!$live -or $live.CreationDate -ne $child.CreationDate -or $live.ParentProcessId -ne ${target.ProcessId} -or $live.ExecutablePath -ne $child.ExecutablePath) { throw 'Private backend identity changed' }; Stop-Process -Id $child.ProcessId -Force }; Stop-Process -Id ${target.ProcessId} -Force; Wait-Process -Id ${target.ProcessId} -Timeout 10 -ErrorAction SilentlyContinue; if (Get-Process -Id ${target.ProcessId} -ErrorAction SilentlyContinue) { throw 'Desktop did not exit' }`);
|
|
116
|
+
}
|
|
117
|
+
await run(`$env:CODEX_APP_SERVER_WS_URL=${powershellLiteral(endpoint)}; ${environment.CODEX_HOME ? `$env:CODEX_HOME=${powershellLiteral(environment.CODEX_HOME)}; ` : ''}$env:CODEX_APP_SERVER_FORCE_CLI='0'; Start-Process -FilePath ${encodedBinary}`);
|
|
118
|
+
report.state = "failed";
|
|
119
|
+
report.message = "已请求共享启动;请刷新并验证实际连接,尚不能确认共享成功。";
|
|
120
|
+
log(JSON.stringify(report));
|
|
121
|
+
return report;
|
|
122
|
+
}
|
package/dist/codex-sharing.js
CHANGED
|
@@ -123,14 +123,14 @@ export async function inspectCodexSharing(context = {}) {
|
|
|
123
123
|
const desktop = await (context.inspect ?? inspectCodexDesktop)(paths.environment);
|
|
124
124
|
if (desktop.status !== "running")
|
|
125
125
|
return { ...result, state: desktop.status, message: desktop.status === "stopped"
|
|
126
|
-
? result.configured && result.autoStart && result.daemonReachable ? "Codex
|
|
126
|
+
? result.configured && result.autoStart && result.daemonReachable ? "Codex 尚未启动;请使用 头像菜单或 agentroam codex-desktop 启动。普通图标或系统恢复不保证继承共享配置。" : "Codex 尚未启动;请先修复共享配置。" : "尚未安装官方 Codex 桌面端。" };
|
|
127
127
|
const { stdout } = await execute("/bin/ps", ["-axo", "pid=,ppid=,args="], commandOptions);
|
|
128
128
|
const processes = String(stdout).split("\n").flatMap(line => {
|
|
129
129
|
const match = /^\s*(\d+)\s+(\d+)\s+(.+)$/.exec(line);
|
|
130
130
|
return match ? [{ pid: Number(match[1]), parent: Number(match[2]), command: match[3] }] : [];
|
|
131
131
|
});
|
|
132
132
|
if (processes.some(p => p.parent === desktop.pid && /\bapp-server\b/.test(p.command) && !/\b(?:proxy|daemon)\b/.test(p.command))) {
|
|
133
|
-
return { ...result, state: "independent", message: "Codex
|
|
133
|
+
return { ...result, state: "independent", message: "Codex 正在使用独立后台。请在任务结束时退出,再用 头像菜单或 agentroam codex-desktop 启动;不会自动中断现有会话。" };
|
|
134
134
|
}
|
|
135
135
|
if (!result.daemonReachable)
|
|
136
136
|
return result;
|
|
@@ -145,7 +145,7 @@ export async function inspectCodexSharing(context = {}) {
|
|
|
145
145
|
if (rows.some(row => row.pid === desktop.pid && row.name.startsWith("->") && devices.has(row.name.slice(2)))) {
|
|
146
146
|
return { ...result, state: "shared", message: "Codex 已连接共享后台。" };
|
|
147
147
|
}
|
|
148
|
-
return { ...result, message: "共享后台可用,但尚未确认 Codex
|
|
148
|
+
return { ...result, message: "共享后台可用,但尚未确认 Codex 连接。请在任务结束时退出,再用 头像菜单或 agentroam codex-desktop 启动。" };
|
|
149
149
|
}
|
|
150
150
|
catch {
|
|
151
151
|
return result;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { createInterface } from "node:readline";
|
|
7
|
+
import { WebSocketServer, WebSocket } from "ws";
|
|
8
|
+
import { validateWindowsBackend } from "./codex-windows-backend.js";
|
|
9
|
+
export async function startWindowsBackendHost(config, dependencies = {}) {
|
|
10
|
+
validateWindowsBackend(config);
|
|
11
|
+
const environment = { ...process.env, CODEX_HOME: config.codexHome };
|
|
12
|
+
await (dependencies.startDaemon ?? (async (executable, env) => {
|
|
13
|
+
await promisify(execFile)(executable, ["app-server", "daemon", "start"], { env, cwd: homedir(), windowsHide: true, timeout: 30_000 });
|
|
14
|
+
}))(config.executable, environment);
|
|
15
|
+
const endpoint = new URL(config.endpoint);
|
|
16
|
+
const server = new WebSocketServer({ host: "127.0.0.1", port: Number(endpoint.port), path: endpoint.pathname, maxPayload: 32 * 1024 * 1024, perMessageDeflate: false });
|
|
17
|
+
server.on("connection", socket => {
|
|
18
|
+
const child = (dependencies.spawnProxy ?? spawn)(config.executable, ["app-server", "proxy"], { env: environment, cwd: homedir(), windowsHide: true, stdio: ["pipe", "pipe", "ignore"] });
|
|
19
|
+
const lines = createInterface({ input: child.stdout });
|
|
20
|
+
lines.on("line", line => { if (socket.readyState === WebSocket.OPEN) {
|
|
21
|
+
if (socket.bufferedAmount > 32 * 1024 * 1024)
|
|
22
|
+
socket.close(1013);
|
|
23
|
+
else
|
|
24
|
+
socket.send(line);
|
|
25
|
+
} });
|
|
26
|
+
socket.on("message", (data, binary) => {
|
|
27
|
+
if (binary || (Array.isArray(data) ? data.reduce((size, chunk) => size + chunk.length, 0) : data.byteLength) > 32 * 1024 * 1024) {
|
|
28
|
+
socket.close(1003);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const message = JSON.parse(String(data));
|
|
33
|
+
if (!message || typeof message !== "object" || Array.isArray(message) || child.stdin.writableLength > 32 * 1024 * 1024) {
|
|
34
|
+
socket.close(1008);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
socket.close(1007);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
socket.on("error", () => { });
|
|
44
|
+
const close = () => { lines.close(); child.stdin.end(); if (child.exitCode === null)
|
|
45
|
+
child.kill(); };
|
|
46
|
+
socket.once("close", close);
|
|
47
|
+
child.once("error", () => socket.close(1011));
|
|
48
|
+
child.once("exit", () => socket.close(1011));
|
|
49
|
+
});
|
|
50
|
+
await new Promise((resolve, reject) => { server.once("listening", resolve); server.once("error", reject); });
|
|
51
|
+
return server;
|
|
52
|
+
}
|
|
53
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
54
|
+
const path = process.argv[2];
|
|
55
|
+
if (!path)
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
else
|
|
58
|
+
readFile(path, "utf8").then(text => startWindowsBackendHost(validateWindowsBackend(JSON.parse(text)))).catch(() => { console.error("Windows shared backend failed to start"); process.exitCode = 1; });
|
|
59
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { readFile, mkdir, writeFile, rename, rm, open, stat } from "node:fs/promises";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { createServer } from "node:net";
|
|
9
|
+
import { resolveCodexRuntime } from "./codex-runtime-manager.js";
|
|
10
|
+
import { withDesktopRpc } from "./codex-desktop-probe.js";
|
|
11
|
+
const executeFile = promisify(execFile);
|
|
12
|
+
export const WINDOWS_CODEX_TASK = "AgentRoam-Codex-Shared";
|
|
13
|
+
export function windowsBackendPath(home = homedir()) { return join(home, ".agentroam", "codex-desktop", "windows-backend.json"); }
|
|
14
|
+
export function psLiteral(value) { return `'${value.replaceAll("'", "''")}'`; }
|
|
15
|
+
export function quoteWindowsArgument(value) { return `"${value.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/g, "$1$1")}"`; }
|
|
16
|
+
export function validateWindowsBackend(value) {
|
|
17
|
+
const config = value;
|
|
18
|
+
const url = new URL(config.endpoint);
|
|
19
|
+
if (config.version !== 1 || url.protocol !== "ws:" || url.hostname !== "127.0.0.1" || !url.port
|
|
20
|
+
|| !/^\/[a-f0-9]{48}$/.test(url.pathname) || url.search || url.hash || url.username || url.password
|
|
21
|
+
|| !/^[A-Za-z]:\\.*\.exe$/i.test(config.executable) || !/^[A-Za-z]:\\/.test(config.codexHome))
|
|
22
|
+
throw new Error("Invalid Windows shared backend configuration");
|
|
23
|
+
return config;
|
|
24
|
+
}
|
|
25
|
+
export async function readWindowsBackend(home = homedir()) {
|
|
26
|
+
try {
|
|
27
|
+
return validateWindowsBackend(JSON.parse(await readFile(windowsBackendPath(home), "utf8")));
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error.code === "ENOENT")
|
|
31
|
+
return null;
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export async function ensureWindowsBackend(dataDir, context = {}) {
|
|
36
|
+
const home = context.homeDir ?? homedir();
|
|
37
|
+
const environment = context.environment ?? process.env;
|
|
38
|
+
const path = windowsBackendPath(home), root = join(home, ".agentroam", "codex-desktop");
|
|
39
|
+
const execute = context.execute ?? executeFile;
|
|
40
|
+
const run = (script) => execute("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", `$ErrorActionPreference='Stop'; ${script}`], { env: environment, encoding: "utf8", timeout: 30_000, maxBuffer: 1024 * 1024, windowsHide: true });
|
|
41
|
+
await mkdir(root, { recursive: true });
|
|
42
|
+
await run(`$sid=[System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value; & icacls.exe ${psLiteral(root)} /inheritance:r /grant:r "\${sid}:(OI)(CI)F" '*S-1-5-18:(OI)(CI)F' | Out-Null; if ($LASTEXITCODE -ne 0) { throw 'Cannot protect shared backend directory' }`);
|
|
43
|
+
const lockPath = `${path}.lock`;
|
|
44
|
+
let lock;
|
|
45
|
+
for (let attempt = 0; attempt < 120; attempt++) {
|
|
46
|
+
try {
|
|
47
|
+
lock = await open(lockPath, "wx");
|
|
48
|
+
await lock.writeFile(String(process.pid));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error.code !== "EEXIST")
|
|
53
|
+
throw error;
|
|
54
|
+
try {
|
|
55
|
+
const owner = Number(await readFile(lockPath, "utf8"));
|
|
56
|
+
const age = Date.now() - (await stat(lockPath)).mtimeMs;
|
|
57
|
+
if (Number.isSafeInteger(owner) && owner > 1) {
|
|
58
|
+
try {
|
|
59
|
+
process.kill(owner, 0);
|
|
60
|
+
}
|
|
61
|
+
catch (probeError) {
|
|
62
|
+
if (probeError.code === "ESRCH")
|
|
63
|
+
await rm(lockPath, { force: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else if (age > 30_000)
|
|
67
|
+
await rm(lockPath, { force: true });
|
|
68
|
+
}
|
|
69
|
+
catch (readError) {
|
|
70
|
+
if (readError.code !== "ENOENT")
|
|
71
|
+
throw readError;
|
|
72
|
+
}
|
|
73
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!lock)
|
|
77
|
+
throw new Error("Windows shared backend setup is busy; retry shortly");
|
|
78
|
+
try {
|
|
79
|
+
let config = await readWindowsBackend(home);
|
|
80
|
+
const executable = await (context.resolveExecutable ?? (async () => environment.AGENT_CODEX_BIN || (await resolveCodexRuntime({ dataDir, target: "windows-amd64", platform: "win32", environment })).executable))();
|
|
81
|
+
if (!config) {
|
|
82
|
+
const port = await (context.allocatePort ?? (() => new Promise((resolve, reject) => {
|
|
83
|
+
const server = createServer();
|
|
84
|
+
server.once("error", reject);
|
|
85
|
+
server.listen(0, "127.0.0.1", () => { const address = server.address(); if (!address || typeof address === "string") {
|
|
86
|
+
server.close();
|
|
87
|
+
reject(new Error("No loopback port"));
|
|
88
|
+
return;
|
|
89
|
+
} server.close(error => error ? reject(error) : resolve(address.port)); });
|
|
90
|
+
})))();
|
|
91
|
+
config = { version: 1, endpoint: `ws://127.0.0.1:${port}/${randomBytes(24).toString("hex")}`, executable, codexHome: environment.CODEX_HOME || join(home, ".codex") };
|
|
92
|
+
}
|
|
93
|
+
else
|
|
94
|
+
config = { ...config, executable };
|
|
95
|
+
validateWindowsBackend(config);
|
|
96
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
97
|
+
await writeFile(temporary, JSON.stringify(config), { mode: 0o600 });
|
|
98
|
+
await rename(temporary, path);
|
|
99
|
+
const host = fileURLToPath(new URL("./codex-windows-backend-host.js", import.meta.url));
|
|
100
|
+
const argumentsValue = `${quoteWindowsArgument(host)} ${quoteWindowsArgument(path)}`;
|
|
101
|
+
await run(`$action=New-ScheduledTaskAction -Execute ${psLiteral(process.execPath)} -Argument ${psLiteral(argumentsValue)} -WorkingDirectory ${psLiteral(home)}; $user=[System.Security.Principal.WindowsIdentity]::GetCurrent().Name; $trigger=New-ScheduledTaskTrigger -AtLogOn -User $user; $principal=New-ScheduledTaskPrincipal -UserId $user -LogonType Interactive -RunLevel Limited; $settings=New-ScheduledTaskSettingsSet -MultipleInstances IgnoreNew -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 1) -ExecutionTimeLimit ([TimeSpan]::Zero) -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries; Register-ScheduledTask -TaskName ${psLiteral(WINDOWS_CODEX_TASK)} -Action $action -Trigger $trigger -Principal $principal -Settings $settings -Force | Out-Null; Start-ScheduledTask -TaskName ${psLiteral(WINDOWS_CODEX_TASK)}`);
|
|
102
|
+
const probe = context.probe ?? (async (endpoint) => { await withDesktopRpc(endpoint, async (request) => { await request("config/read", { includeLayers: false }); }, 2_000); });
|
|
103
|
+
for (let attempt = 0; attempt < 8; attempt++) {
|
|
104
|
+
try {
|
|
105
|
+
await probe(config.endpoint);
|
|
106
|
+
return config;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
if (attempt === 7)
|
|
110
|
+
throw new Error("Windows 共享后台未就绪,已保留 Codex 桌面。", { cause: error });
|
|
111
|
+
await (context.wait ?? (() => new Promise(resolve => setTimeout(resolve, 500))))();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
throw new Error("Shared backend unavailable");
|
|
115
|
+
}
|
|
116
|
+
finally {
|
|
117
|
+
await lock.close();
|
|
118
|
+
await rm(`${path}.lock`, { force: true });
|
|
119
|
+
}
|
|
120
|
+
}
|
package/dist/runtime-manager.js
CHANGED
|
@@ -7,6 +7,7 @@ import { resolveOpenCodeRuntime, } from "./opencode-runtime-manager.js";
|
|
|
7
7
|
import { resolvePlatformRuntime } from "./platform-packages.js";
|
|
8
8
|
import { findAvailablePort } from "./port.js";
|
|
9
9
|
import { ProcessSupervisor } from "./process-supervisor.js";
|
|
10
|
+
import { ensureWindowsBackend } from "./codex-windows-backend.js";
|
|
10
11
|
import { configureCodexSharing } from "./codex-sharing.js";
|
|
11
12
|
import { withCliProgress } from "../bin/cli-progress.mjs";
|
|
12
13
|
import { withAbortSignal, withTimeout } from "./abort.js";
|
|
@@ -37,6 +38,15 @@ export class RuntimeManager {
|
|
|
37
38
|
this.report(`Codex 共享启动配置未完成,可在电脑菜单中修复:${error instanceof Error ? error.message : error}`);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
41
|
+
if (process.platform === "win32" && childEnvironment.AGENT_CODEX_BIN) {
|
|
42
|
+
try {
|
|
43
|
+
const backend = await ensureWindowsBackend(dataDir, { environment: childEnvironment });
|
|
44
|
+
childEnvironment.AGENT_CODEX_DESKTOP_WS_URL = backend.endpoint;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.report(`Codex 共享后台未就绪,可在头像菜单重试:${error instanceof Error ? error.message : error}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
40
50
|
const { runtimeRoot } = resolvePlatformRuntime(target);
|
|
41
51
|
await repairNativeRuntimePermissions(runtimeRoot);
|
|
42
52
|
const gateway = resolve(runtimeRoot, "ws-server.mjs");
|
|
@@ -101,7 +101,7 @@ export async function runServiceCommand(options, context) {
|
|
|
101
101
|
log("Codex Desktop sharing: agentroam codex-desktop --setup; preview: agentroam codex-desktop --dry-run.");
|
|
102
102
|
if (state.version === config.version)
|
|
103
103
|
await cleanupOldLaunchers(config, log);
|
|
104
|
-
if (options.desktopSetup &&
|
|
104
|
+
if (options.desktopSetup && ["darwin", "win32"].includes(platform)) {
|
|
105
105
|
await withCliProgress("Configuring Codex Desktop sharing", () => (context.desktopSetup ?? setupCodexDesktop)(options, { platform, environment, service: config, log }));
|
|
106
106
|
}
|
|
107
107
|
await (context.pairingPrinter ?? printPairingCode)(options.dataDir, log, { accessUrl: state.accessUrl, qr: options.qr, interactive: stdoutIsTTY });
|
|
@@ -333,7 +333,7 @@ if ($LASTEXITCODE -ne 0) { Write-Warning "Some component checks failed; continui
|
|
|
333
333
|
if ($env:AGENTROAM_INSTALL_SKIP_SERVICE -eq "1") {
|
|
334
334
|
Write-Host "AgentRoam service registration skipped for isolated verification."
|
|
335
335
|
} else {
|
|
336
|
-
& $NodeBin $Entry service install --root $ServiceRoot --data-dir $DataDir
|
|
336
|
+
& $NodeBin $Entry service install --root $ServiceRoot --data-dir $DataDir --setup-codex-desktop
|
|
337
337
|
if ($LASTEXITCODE -ne 0) { throw "CLI installed, but the background service failed (exit $LASTEXITCODE). Run agentroam service logs, fix the error, then run agentroam service start and agentroam pair." }
|
|
338
338
|
}
|
|
339
339
|
Write-Host "`nAgentRoam $AgentRoamVersion installed: $WrapperPath"
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
},
|
|
9
9
|
"windows-amd64": {
|
|
10
10
|
"fileName": "install-agentroam.ps1",
|
|
11
|
-
"sha256": "
|
|
12
|
-
"size":
|
|
11
|
+
"sha256": "a2cd04ae1dd7c46e7617c15e77d753055e9e5b07841a3529181b8e026180f00e",
|
|
12
|
+
"size": 19089
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -84,7 +84,7 @@ if [[ "$codex_desktop_dry_run" == true ]]; then
|
|
|
84
84
|
echo "CLI: $codex_shared_cli"
|
|
85
85
|
if [[ -n "$codex_desktop_running_pid" ]]; then
|
|
86
86
|
if [[ "$codex_desktop_restart" == true ]]; then
|
|
87
|
-
echo "Desktop PID $codex_desktop_running_pid would be
|
|
87
|
+
echo "Desktop PID $codex_desktop_running_pid would be force stopped and relaunched; all its running sessions would be interrupted."
|
|
88
88
|
else
|
|
89
89
|
echo "Desktop PID $codex_desktop_running_pid is running; launch will refuse until Desktop has exited."
|
|
90
90
|
fi
|
|
@@ -126,17 +126,19 @@ if [[ -n "$codex_desktop_running_pid" ]]; then
|
|
|
126
126
|
"${AGENTROAM_CODEX_DESKTOP_GUARD_NODE:?}" "$AGENTROAM_CODEX_DESKTOP_IDLE_GUARD"
|
|
127
127
|
check_desktop_pid
|
|
128
128
|
fi
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
codex_desktop_force_stop="${AGENTROAM_CODEX_DESKTOP_FORCE_STOP:-$(dirname "$0")/../dist/codex-desktop-force-stop.js}"
|
|
130
|
+
if [[ ! -f "$codex_desktop_force_stop" ]]; then
|
|
131
|
+
echo "Desktop force-stop helper unavailable; Desktop was preserved." >&2
|
|
132
|
+
exit 1
|
|
133
|
+
fi
|
|
134
|
+
echo "Force restarting official Desktop; all its running sessions will be interrupted."
|
|
135
|
+
"$codex_desktop_preflight_node" "$codex_desktop_force_stop" "$codex_desktop_running_pid" "$codex_desktop_binary"
|
|
134
136
|
for ((codex_desktop_wait=0; codex_desktop_wait<40; codex_desktop_wait++)); do
|
|
135
137
|
if ! /bin/kill -0 "$codex_desktop_running_pid" 2>/dev/null; then break; fi
|
|
136
138
|
sleep 0.25
|
|
137
139
|
done
|
|
138
140
|
if /bin/kill -0 "$codex_desktop_running_pid" 2>/dev/null; then
|
|
139
|
-
echo "Desktop did not exit
|
|
141
|
+
echo "Desktop did not exit after force stop; no second launch was attempted." >&2
|
|
140
142
|
exit 1
|
|
141
143
|
fi
|
|
142
144
|
fi
|
|
@@ -145,5 +147,6 @@ fi
|
|
|
145
147
|
# environment changes and preserving all Desktop settings and saved windows.
|
|
146
148
|
/usr/bin/open -a "$codex_desktop_app" \
|
|
147
149
|
--env "CODEX_APP_SERVER_WS_URL=$codex_shared_url" \
|
|
148
|
-
--env "CODEX_APP_SERVER_FORCE_CLI=0"
|
|
150
|
+
--env "CODEX_APP_SERVER_FORCE_CLI=0" \
|
|
151
|
+
--env "CODEX_HOME=$codex_shared_root"
|
|
149
152
|
echo "Desktop launch requested against $codex_shared_url."
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentroam",
|
|
3
|
-
"version": "0.2.0-preview.
|
|
3
|
+
"version": "0.2.0-preview.64",
|
|
4
4
|
"description": "Zero-install mobile remote terminal and file console",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
"ws": "^8.21.3"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"agentroam-runtime-darwin-arm64": "0.2.0-preview.
|
|
31
|
-
"agentroam-runtime-win32-x64": "0.2.0-preview.
|
|
30
|
+
"agentroam-runtime-darwin-arm64": "0.2.0-preview.64",
|
|
31
|
+
"agentroam-runtime-win32-x64": "0.2.0-preview.64",
|
|
32
32
|
"agentroam-cloudflared-darwin-arm64": "0.2.0-preview.58",
|
|
33
33
|
"agentroam-cloudflared-win32-x64": "0.2.0-preview.58",
|
|
34
|
-
"agentroam-tui-darwin-arm64": "0.2.0-preview.
|
|
35
|
-
"@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.
|
|
34
|
+
"agentroam-tui-darwin-arm64": "0.2.0-preview.64",
|
|
35
|
+
"@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.64"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^22.0.0",
|