@karlorz/codexhost-cli-linux-x64 0.20.0-0 → 0.20.0-1

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 CHANGED
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @karlorz/codexhost-cli@0.20.0-0
10
+ npm install -g @karlorz/codexhost-cli@0.20.0-1
11
11
  ```
12
12
 
13
13
  Do not install this package directly. npm selects it through the optional dependencies of `@karlorz/codexhost-cli`.
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.20.0-0","distribution":"npm","target":"linux-x64"}
1
+ {"schemaVersion":1,"version":"0.20.0-1","distribution":"npm","target":"linux-x64"}
@@ -20432,6 +20432,17 @@ function headerValue(value) {
20432
20432
  }
20433
20433
 
20434
20434
  // packages/console-server/src/open.ts
20435
+ var CONSOLE_STOPPING_SERVICE = `${CONSOLE_SERVICE}-stopping`;
20436
+ function isConsoleService(service) {
20437
+ return service === CONSOLE_SERVICE || service === CONSOLE_STOPPING_SERVICE;
20438
+ }
20439
+ function terminateConsole(pid) {
20440
+ try {
20441
+ process.kill(pid, "SIGTERM");
20442
+ } catch (error51) {
20443
+ if (error51.code !== "ESRCH") throw error51;
20444
+ }
20445
+ }
20435
20446
  function refused(error51) {
20436
20447
  let current = error51;
20437
20448
  for (let depth = 0; depth < 4 && current; depth += 1) {
@@ -20446,9 +20457,10 @@ async function probeConsole(port) {
20446
20457
  signal: AbortSignal.timeout(1500)
20447
20458
  });
20448
20459
  const body = await response.json().catch(() => null);
20449
- if (response.ok && body?.service === CONSOLE_SERVICE && typeof body.appDirectory === "string" && typeof body.pid === "number") {
20460
+ if (response.ok && isConsoleService(body?.service) && typeof body.appDirectory === "string" && typeof body.pid === "number") {
20450
20461
  return {
20451
20462
  kind: "console",
20463
+ stopping: body.service === CONSOLE_STOPPING_SERVICE,
20452
20464
  appDirectory: body.appDirectory,
20453
20465
  pid: body.pid,
20454
20466
  buildId: typeof body.buildId === "string" ? body.buildId : null
@@ -20476,12 +20488,28 @@ async function requestShutdown(port) {
20476
20488
  });
20477
20489
  if (!response.ok) throw new Error(`console shutdown failed: HTTP ${response.status}`);
20478
20490
  }
20491
+ async function waitUntilConsoleGone(port, pid) {
20492
+ let probe = await waitFor(port, (next) => next.kind !== "console", 5e3);
20493
+ if (probe.kind !== "console") return probe;
20494
+ terminateConsole(pid);
20495
+ probe = await waitFor(port, (next) => next.kind !== "console", 5e3);
20496
+ if (probe.kind === "console") throw new Error(`codexhost console did not stop on port ${port}`);
20497
+ return probe;
20498
+ }
20479
20499
  async function stopConsole(environment = process.env) {
20480
20500
  const port = consolePort(environment);
20481
- if ((await probeConsole(port)).kind !== "console") return false;
20501
+ const first = await probeConsole(port);
20502
+ if (first.kind !== "console") return false;
20503
+ if (first.stopping) {
20504
+ await requestShutdown(port).catch(() => void 0);
20505
+ await waitUntilConsoleGone(port, first.pid);
20506
+ return true;
20507
+ }
20482
20508
  await requestShutdown(port);
20483
- const probe = await waitFor(port, (next) => next.kind !== "console", 5e3);
20484
- if (probe.kind === "console") throw new Error(`codexhost console did not stop on port ${port}`);
20509
+ const probe = await waitFor(port, (next) => next.kind !== "console" || next.stopping, 5e3);
20510
+ if (probe.kind === "console" && !probe.stopping) {
20511
+ await waitUntilConsoleGone(port, first.pid);
20512
+ }
20485
20513
  return true;
20486
20514
  }
20487
20515
  async function consoleBuildId(entryPath2, environment = process.env) {
@@ -20520,9 +20548,9 @@ async function ensureConsole(options) {
20520
20548
  const port = consolePort(environment);
20521
20549
  let probe = await probeConsole(port);
20522
20550
  const ownBuildId = await consoleBuildId(options.entryPath, environment);
20523
- if (probe.kind === "console" && (probe.appDirectory !== options.appDirectory || probe.buildId !== ownBuildId)) {
20551
+ if (probe.kind === "console" && (probe.stopping || probe.appDirectory !== options.appDirectory || probe.buildId !== ownBuildId)) {
20524
20552
  await requestShutdown(port).catch(() => void 0);
20525
- probe = await waitFor(port, (next) => next.kind !== "console", 5e3);
20553
+ probe = await waitUntilConsoleGone(port, probe.pid);
20526
20554
  }
20527
20555
  if (probe.kind === "foreign") {
20528
20556
  throw new Error(
@@ -20531,8 +20559,8 @@ async function ensureConsole(options) {
20531
20559
  }
20532
20560
  if (probe.kind === "free") {
20533
20561
  startDetachedServer(options.entryPath, environment);
20534
- probe = await waitFor(port, (next) => next.kind === "console", 1e4);
20535
- if (probe.kind !== "console") {
20562
+ probe = await waitFor(port, (next) => next.kind === "console" && !next.stopping, 1e4);
20563
+ if (probe.kind !== "console" || probe.stopping) {
20536
20564
  throw new Error(`codexhost console did not start on port ${port}`);
20537
20565
  }
20538
20566
  }
package/bin/codexhost CHANGED
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@karlorz/codexhost-cli-linux-x64",
3
- "version": "0.20.0-0",
3
+ "version": "0.20.0-1",
4
4
  "description": "Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.",
5
5
  "type": "module",
6
6
  "files": [