@karlorz/codexhost-cli-win32-x64 0.16.1-3 → 0.17.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.16.1-3
10
+ npm install -g @karlorz/codexhost-cli@0.17.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`.
@@ -36,7 +36,7 @@ The `codexhost` command launches the packaged Rust launcher with:
36
36
 
37
37
  ## Requirements
38
38
 
39
- - Node.js 22 or 24 (Node 20 and older are not supported)
39
+ - Node.js 22.19.0 or later, except 23.x (other releases lack parts of the built-in `node:sqlite` module)
40
40
  - Official ChatGPT/Codex Desktop for macOS, Windows, or Linux
41
41
  - Pi on `PATH` when using the Pi agent
42
42
  - Claude Code installed when using the Claude Code adapter
@@ -32,14 +32,18 @@ License text: licenses/OpenCode-v2-Client-LICENSE.txt
32
32
  License: MIT
33
33
  License text: licenses/OpenCode-SDK-LICENSE.txt
34
34
 
35
- @qoder-ai/qoder-agent-sdk 1.0.39
35
+ @qoder-ai/qoder-agent-sdk 1.0.58
36
36
  License: SEE LICENSE IN LICENSE
37
37
  License text: licenses/Qoder-Agent-SDK-LICENSE.txt
38
38
 
39
- @qodercn-ai/qodercn-agent-sdk 1.0.39
39
+ @qodercn-ai/qodercn-agent-sdk 1.0.58
40
40
  License: SEE LICENSE IN LICENSE
41
41
  License text: licenses/QoderCN-Agent-SDK-LICENSE.txt
42
42
 
43
+ @qwen-code/sdk 0.1.26
44
+ License: Apache-2.0
45
+ License text: licenses/Qwen-Code-SDK-LICENSE.txt
46
+
43
47
  diff 8.0.2
44
48
  License: BSD-3-Clause
45
49
  License text: licenses/diff-LICENSE.txt
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.16.1-3","distribution":"npm","target":"windows-x64"}
1
+ {"schemaVersion":1,"version":"0.17.0-1","distribution":"npm","target":"windows-x64"}
@@ -17203,33 +17203,58 @@ var HarnessLaunchSettingsStore = class {
17203
17203
  return path8.join(this.#directory, `${harnessPluginIdSchema.parse(id)}.json`);
17204
17204
  }
17205
17205
  async #read(id) {
17206
+ const file2 = this.#file(id);
17207
+ let text;
17206
17208
  try {
17207
- const value = harnessLaunchPathSchema.parse(JSON.parse(await readFile4(this.#file(id), "utf8")));
17208
- if (!path8.isAbsolute(value))
17209
- throw new Error("Expected an absolute entrypoint path");
17210
- return value;
17209
+ text = await readFile4(file2, "utf8");
17211
17210
  } catch (error51) {
17212
17211
  if (error51 && typeof error51 === "object" && "code" in error51 && error51.code === "ENOENT")
17213
17212
  return null;
17214
- throw new Error("Could not read Harness launch settings");
17213
+ throw new Error(`Could not read Harness launch settings at ${file2}`, { cause: error51 });
17214
+ }
17215
+ let parsed;
17216
+ try {
17217
+ parsed = harnessLaunchPathSchema.parse(JSON.parse(text));
17218
+ } catch {
17219
+ }
17220
+ if (parsed === void 0 || !path8.isAbsolute(parsed)) {
17221
+ throw new Error(`Could not read Harness launch settings at ${file2}: expected an absolute installation path; save a new path or reset it`);
17215
17222
  }
17223
+ return parsed;
17216
17224
  }
17217
- /** Capture the value used to construct this Host's Adapter; changes require a restart. */
17218
- async initialCommand(id) {
17225
+ #snapshot(id) {
17219
17226
  let initial = this.#initial.get(id);
17220
17227
  if (!initial) {
17221
- initial = this.#read(id);
17228
+ initial = this.#read(id).then((value) => ({ path: value }), (error51) => ({ error: error51 instanceof Error ? error51 : new Error(String(error51)) }));
17222
17229
  this.#initial.set(id, initial);
17223
17230
  }
17224
- return await initial ?? void 0;
17231
+ return initial;
17232
+ }
17233
+ /**
17234
+ * Capture the value used to construct this Host's Adapter; changes require a restart. A failed
17235
+ * read is remembered for restart reporting but not reused: the next call reads the file again.
17236
+ */
17237
+ async initialCommand(id) {
17238
+ const cached2 = this.#initial.get(id);
17239
+ if (cached2 && "error" in await cached2)
17240
+ this.#initial.delete(id);
17241
+ const snapshot = await this.#snapshot(id);
17242
+ if ("error" in snapshot)
17243
+ throw snapshot.error;
17244
+ return snapshot.path ?? void 0;
17245
+ }
17246
+ /** The Adapter was built without a readable setting, so any saved value needs a restart. */
17247
+ #restartRequired(snapshot, value) {
17248
+ return "error" in snapshot || value !== snapshot.path;
17225
17249
  }
17226
17250
  async get(id) {
17227
- const initial = await this.initialCommand(id) ?? null;
17251
+ const snapshot = await this.#snapshot(id);
17228
17252
  const value = await this.#read(id);
17229
- return { path: value, restartRequired: value !== initial };
17253
+ return { path: value, restartRequired: this.#restartRequired(snapshot, value) };
17230
17254
  }
17255
+ /** Replaces the file without reading it, so an unreadable file can always be repaired. */
17231
17256
  async set(id, value) {
17232
- const initial = await this.initialCommand(id) ?? null;
17257
+ const snapshot = await this.#snapshot(id);
17233
17258
  const file2 = this.#file(id);
17234
17259
  if (value === null) {
17235
17260
  await rm3(file2, { force: true });
@@ -17250,7 +17275,7 @@ var HarnessLaunchSettingsStore = class {
17250
17275
  await rm3(temporary, { force: true });
17251
17276
  }
17252
17277
  }
17253
- return { path: value, restartRequired: value !== initial };
17278
+ return { path: value, restartRequired: this.#restartRequired(snapshot, value) };
17254
17279
  }
17255
17280
  };
17256
17281
 
@@ -17653,10 +17678,15 @@ function createConsoleHarnesses(roots, environment = process.env) {
17653
17678
  if (seen.has(manifest.id)) continue;
17654
17679
  seen.add(manifest.id);
17655
17680
  const icon = manifest.icon ? await readPluginIcon(plugin.root, manifest.icon).catch(() => null) : null;
17656
- const launchPath = manifest.launchCommand ? await store.get(manifest.id).then(
17657
- (settings) => settings.path,
17658
- () => null
17659
- ) : null;
17681
+ let launchPath = null;
17682
+ let launchPathError = null;
17683
+ if (manifest.launchCommand) {
17684
+ try {
17685
+ launchPath = (await store.get(manifest.id)).path;
17686
+ } catch (error51) {
17687
+ launchPathError = error51 instanceof Error ? error51.message : String(error51);
17688
+ }
17689
+ }
17660
17690
  harnesses.push({
17661
17691
  id: manifest.id,
17662
17692
  name: manifest.name,
@@ -17666,7 +17696,8 @@ function createConsoleHarnesses(roots, environment = process.env) {
17666
17696
  links: manifest.links ?? null,
17667
17697
  icon,
17668
17698
  launchPath,
17669
- ...manifest.id === "grok" ? { computerUse: await getGrokComputerUseSettings(environment) } : {}
17699
+ ...manifest.id === "grok" ? { computerUse: await getGrokComputerUseSettings(environment) } : {},
17700
+ launchPathError
17670
17701
  });
17671
17702
  }
17672
17703
  return harnesses.sort(
@@ -17683,7 +17714,7 @@ function createConsoleHarnesses(roots, environment = process.env) {
17683
17714
  }
17684
17715
  try {
17685
17716
  const settings = await store.set(id, value);
17686
- return { ...harness2, launchPath: settings.path };
17717
+ return { ...harness2, launchPath: settings.path, launchPathError: null };
17687
17718
  } catch (error51) {
17688
17719
  throw new ConsoleHarnessError(400, error51 instanceof Error ? error51.message : String(error51));
17689
17720
  }
@@ -18843,7 +18874,11 @@ function startConsoleServer(options) {
18843
18874
  return;
18844
18875
  }
18845
18876
  scheduleIdleExit();
18846
- const url2 = new URL(request.url ?? "/", `http://127.0.0.1:${port}`);
18877
+ const url2 = URL.parse(request.url ?? "/", `http://127.0.0.1:${port}`);
18878
+ if (!url2) {
18879
+ sendJson(response, 400, { error: "Bad Request" });
18880
+ return;
18881
+ }
18847
18882
  const method = request.method ?? "GET";
18848
18883
  let route = `${method} ${url2.pathname}`;
18849
18884
  if (route === "GET /api/health") {
@@ -19000,13 +19000,12 @@ th[aria-sort] .console-usage-sort__mark {
19000
19000
  { className: "console-harness__path" },
19001
19001
  input,
19002
19002
  button(document2, messages.save, () => submit(input.value.trim() || null)),
19003
- harness2.launchPath ? button(document2, messages.useAutomatic, () => submit(null)) : null
19003
+ harness2.launchPath || harness2.launchPathError ? button(document2, messages.useAutomatic, () => submit(null)) : null
19004
19004
  )
19005
19005
  );
19006
- if (status.has(harness2.id)) {
19007
- row.append(
19008
- h(document2, "div", { className: "console-muted" }, status.get(harness2.id) ?? "")
19009
- );
19006
+ const message2 = status.get(harness2.id) ?? harness2.launchPathError;
19007
+ if (message2) {
19008
+ row.append(h(document2, "div", { className: "console-muted" }, message2));
19010
19009
  }
19011
19010
  }
19012
19011
  if (harness2.computerUse) {
@@ -21892,7 +21891,7 @@ th[aria-sort] .console-usage-sort__mark {
21892
21891
  launchPathAutomatic: "No saved override. Uses environment configuration, then automatic discovery.",
21893
21892
  launchPathSaving: "Saving\u2026",
21894
21893
  launchPathLoading: "Loading launch settings\u2026",
21895
- launchPathLoadError: "Could not load launch settings. Reopen this detail panel to retry.",
21894
+ launchPathLoadError: "Could not load launch settings. Save an installation directory or reset to automatic discovery to replace them.",
21896
21895
  launchPathSaveError: "Could not save. Enter an existing absolute installation folder on this Host and check configuration permissions.",
21897
21896
  grokComputerUseLabel: "Grok Computer Use",
21898
21897
  grokComputerUseTitle: "Computer Use",
@@ -22200,7 +22199,7 @@ th[aria-sort] .console-usage-sort__mark {
22200
22199
  launchPathAutomatic: "\u672A\u8BBE\u7F6E\u81EA\u5B9A\u4E49\u8DEF\u5F84\uFF0C\u4F7F\u7528\u73AF\u5883\u53D8\u91CF\u914D\u7F6E\u6216\u81EA\u52A8\u53D1\u73B0\u3002",
22201
22200
  launchPathSaving: "\u6B63\u5728\u4FDD\u5B58\u2026",
22202
22201
  launchPathLoading: "\u6B63\u5728\u8BFB\u53D6\u542F\u52A8\u8BBE\u7F6E\u2026",
22203
- launchPathLoadError: "\u65E0\u6CD5\u8BFB\u53D6\u542F\u52A8\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u6B64\u8BE6\u60C5\u9762\u677F\u91CD\u8BD5\u3002",
22202
+ launchPathLoadError: "\u65E0\u6CD5\u8BFB\u53D6\u542F\u52A8\u8BBE\u7F6E\u3002\u4FDD\u5B58\u5B89\u88C5\u76EE\u5F55\u6216\u6062\u590D\u81EA\u52A8\u53D1\u73B0\u5373\u53EF\u66FF\u6362\u3002",
22204
22203
  launchPathSaveError: "\u4FDD\u5B58\u5931\u8D25\u3002\u8BF7\u586B\u5199\u6B64 Host \u4E0A\u5B9E\u9645\u5B58\u5728\u7684\u5B89\u88C5\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u5E76\u786E\u8BA4\u914D\u7F6E\u76EE\u5F55\u53EF\u5199\u3002",
22205
22204
  grokComputerUseLabel: "Grok Computer Use",
22206
22205
  grokComputerUseTitle: "Computer Use",
@@ -24864,7 +24863,7 @@ ${detail}` : ""}`
24864
24863
  "codexhost was not detected over SSH. Install it on the remote computer or add it to the login shell PATH, then retry": "\u901A\u8FC7 SSH \u672A\u68C0\u6D4B\u5230 codexhost\u3002\u8BF7\u5728\u8FDC\u7A0B\u7535\u8111\u4E0A\u5B89\u88C5\uFF0C\u6216\u5C06\u5DF2\u5B89\u88C5\u7684 codexhost \u52A0\u5165\u767B\u5F55 shell \u7684 PATH \u540E\u91CD\u8BD5",
24865
24864
  "The active codexhost does not match the global npm installation. Uninstall only the remote service, or remove the package manually on the remote computer": "\u5F53\u524D codexhost \u4E0E npm \u5168\u5C40\u5B89\u88C5\u4F4D\u7F6E\u4E0D\u5339\u914D\u3002\u8BF7\u9009\u62E9\u4EC5\u5378\u8F7D\u8FDC\u7A0B\u670D\u52A1\uFF0C\u6216\u5728\u8FDC\u7A0B\u7535\u8111\u4E0A\u624B\u52A8\u5378\u8F7D\u8F6F\u4EF6\u5305",
24866
24865
  "The remote service was uninstalled, but removing the codexhost package failed. Check npm permissions on the remote computer and retry": "\u8FDC\u7A0B\u670D\u52A1\u5DF2\u5378\u8F7D\uFF0C\u4F46 codexhost \u8F6F\u4EF6\u5305\u5378\u8F7D\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u8FDC\u7A0B\u7535\u8111\u4E0A\u7684 npm \u6743\u9650\u540E\u91CD\u8BD5",
24867
- "Remote Node.js is unsupported. Select Node.js 22.19 or later in the 22.x series, or Node.js 24.x": "\u8FDC\u7A0B Node.js \u7248\u672C\u4E0D\u53D7\u652F\u6301\uFF0C\u8BF7\u9009\u62E9 Node.js 22.19 \u53CA\u4EE5\u4E0A\u7684 22.x \u7248\u672C\uFF0C\u6216 Node.js 24.x",
24866
+ "Remote Node.js is unsupported. Select Node.js 22.19 or later, except 23.x": "\u8FDC\u7A0B Node.js \u7248\u672C\u4E0D\u53D7\u652F\u6301\uFF0C\u8BF7\u9009\u62E9 Node.js 22.19 \u53CA\u4EE5\u4E0A\u7248\u672C\uFF0C\u4F46\u4E0D\u5305\u62EC 23.x",
24868
24867
  "npm installation failed. Check network access and global installation permissions": "npm \u5B89\u88C5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u548C\u5168\u5C40\u5B89\u88C5\u6743\u9650",
24869
24868
  "Remote service configuration failed. Check Codex CLI and the remote desktop login": "\u8FDC\u7A0B\u670D\u52A1\u914D\u7F6E\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5 Codex CLI \u4EE5\u53CA\u8FDC\u7A0B\u7535\u8111\u7684\u684C\u9762\u767B\u5F55\u72B6\u6001",
24870
24869
  "Remote service could not stop. Check the remote service before retrying": "\u8FDC\u7A0B\u670D\u52A1\u65E0\u6CD5\u505C\u6B62\uFF0C\u8BF7\u68C0\u67E5\u8FDC\u7A0B\u670D\u52A1\u540E\u91CD\u8BD5",
@@ -26039,6 +26038,7 @@ ${detail}` : ""}`
26039
26038
  loaded = true;
26040
26039
  show(value);
26041
26040
  }).catch(() => {
26041
+ loaded = true;
26042
26042
  status.textContent = messages.launchPathLoadError;
26043
26043
  }).finally(() => {
26044
26044
  busy = false;
@@ -27674,6 +27674,30 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27674
27674
  };
27675
27675
  }
27676
27676
 
27677
+ // src/settings/session-import-sources.ts
27678
+ async function loadSessionImportSources(client, diagnostics, signal, refresh) {
27679
+ const { harnesses } = await client.listSessionImportSources();
27680
+ signal.throwIfAborted();
27681
+ if (!diagnostics || harnesses.length === 0) return harnesses;
27682
+ const hostId2 = client.hostId ?? "local";
27683
+ const readHost = () => diagnostics.snapshot().hosts.find((host2) => host2.hostId === hostId2);
27684
+ let host = readHost();
27685
+ const incomplete = () => !host || Boolean(host.directoryError) || harnesses.some(({ harnessId }) => {
27686
+ const status = host?.agents.find(({ agent }) => agent === harnessId)?.availability;
27687
+ return status === void 0 || status === "checking";
27688
+ });
27689
+ if (refresh || incomplete()) {
27690
+ await diagnostics.refresh(hostId2);
27691
+ signal.throwIfAborted();
27692
+ host = readHost();
27693
+ }
27694
+ if (incomplete()) throw new Error("Harness installation diagnostics are incomplete");
27695
+ const missing = new Set(
27696
+ host?.agents.filter(({ availability }) => availability === "notInstalled").map(({ agent }) => agent)
27697
+ );
27698
+ return harnesses.filter(({ harnessId }) => !missing.has(harnessId));
27699
+ }
27700
+
27677
27701
  // src/settings/session-import-page.ts
27678
27702
  function shortSessionId(value) {
27679
27703
  return value.length <= 18 ? value : `${value.slice(0, 10)}\u2026${value.slice(-6)}`;
@@ -27743,7 +27767,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
27743
27767
  ...getDiagnostics()?.snapshot().hosts.map(({ hostId: hostId2 }) => hostId2) ?? [],
27744
27768
  ...current ? [current] : []
27745
27769
  ])
27746
- ];
27770
+ ].filter((hostId2) => hostId2 !== "durable");
27747
27771
  displayedHostId = current;
27748
27772
  const scrollLeft = hostOptions.scrollLeft;
27749
27773
  hostOptions.replaceChildren();
@@ -28087,10 +28111,14 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28087
28111
  content.append(list);
28088
28112
  updateImportActions();
28089
28113
  };
28090
- const load = () => {
28114
+ const load = (refreshDiagnostics = false) => {
28091
28115
  if (importingId !== null || context.signal.aborted) return;
28092
28116
  loadedClient = null;
28093
- const client = getClient(selectedHostId);
28117
+ let client = getClient(selectedHostId);
28118
+ if (client?.hostId === "durable") {
28119
+ selectedHostId = "local";
28120
+ client = getClient(selectedHostId);
28121
+ }
28094
28122
  renderHosts(client);
28095
28123
  listControls.setBusy(client !== null);
28096
28124
  refresh.disabled = client !== null;
@@ -28103,11 +28131,11 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28103
28131
  void context.runLatest(
28104
28132
  async (signal) => {
28105
28133
  if (!client) throw new RendererSessionImportUnavailableError();
28106
- const missing = new Set(
28107
- getDiagnostics()?.snapshot().hosts.find(({ hostId: hostId2 }) => hostId2 === (client.hostId ?? "local"))?.agents.filter(({ availability }) => availability === "notInstalled").map(({ agent }) => agent)
28108
- );
28109
- const harnesses = (await client.listSessionImportSources()).harnesses.filter(
28110
- ({ harnessId }) => !missing.has(harnessId)
28134
+ const harnesses = await loadSessionImportSources(
28135
+ client,
28136
+ getDiagnostics(),
28137
+ signal,
28138
+ refreshDiagnostics
28111
28139
  );
28112
28140
  const selected = harnesses.find(({ harnessId }) => harnessId === requestedHarness)?.harnessId ?? harnesses[0]?.harnessId ?? null;
28113
28141
  if (signal.aborted) throw new Error("Session import selection changed");
@@ -28158,7 +28186,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
28158
28186
  load();
28159
28187
  hostButtons.find((button2) => button2.dataset.sessionImportHost === hostId2)?.focus();
28160
28188
  };
28161
- refresh.addEventListener("click", load);
28189
+ refresh.addEventListener("click", () => load(true));
28162
28190
  load();
28163
28191
  return void 0;
28164
28192
  }
@@ -16423,10 +16423,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16423
16423
  var RENDERER_NEW_THREAD_PREFERENCE_KEY = "codexhost.new-thread-preference.v1";
16424
16424
 
16425
16425
  // src/renderer-client-owned-voice.ts
16426
- var CLIENT_OWNED_VOICE_VERSION = "26.1027.30824";
16427
- var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-60f141238751.js";
16428
- var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-7815d5a1a42a.js";
16429
- var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-d9d400e751cd.js";
16426
+ var CLIENT_OWNED_VOICE_VERSION = "26.1027.61615";
16427
+ var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-18b189e867e7.js";
16428
+ var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-601019a330d7.js";
16429
+ var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-920d05377bbe.js";
16430
16430
  var CLIENT_OWNED_VOICE_ASSETS = [
16431
16431
  {
16432
16432
  platform: "darwin",
@@ -16434,6 +16434,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16434
16434
  initial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
16435
16435
  shared: CLIENT_OWNED_VOICE_SHARED_ASSET,
16436
16436
  overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
16437
+ init: "Adr",
16438
+ fetch: "Odr",
16439
+ fetchFrom: "initial",
16440
+ bridge: "LRt",
16441
+ services: "Vct",
16442
+ responseError: "Pdr",
16443
+ responseErrorFrom: "initial",
16444
+ capabilityInit: "Ler",
16445
+ capabilityFamily: "Ier",
16446
+ inferenceGateFamily: "Vfr"
16447
+ },
16448
+ {
16449
+ platform: "darwin",
16450
+ version: "26.1027.30824",
16451
+ initial: "app-initial-60f141238751.js",
16452
+ shared: "app-shared-7815d5a1a42a.js",
16453
+ overlay: "avatar-overlay-native-page-d9d400e751cd.js",
16437
16454
  init: "Edr",
16438
16455
  fetch: "wdr",
16439
16456
  fetchFrom: "initial",
@@ -17339,10 +17356,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17339
17356
  const currentRole = manager.getStreamRole?.(threadId);
17340
17357
  if (isRecord4(currentRole) && currentRole.role === "follower")
17341
17358
  return originalSteer.apply(manager, args);
17342
- if (!Array.isArray(input) || input.length === 0 || input.some(
17343
- (item) => !isRecord4(item) || item.type !== "text" || typeof item.text !== "string"
17344
- ) || !input.some((item) => isRecord4(item) && typeof item.text === "string" && item.text.trim())) {
17345
- throw new Error("External steering requires non-empty text input");
17359
+ if (!Array.isArray(input) || input.length === 0 || input.some((item) => {
17360
+ if (!isRecord4(item)) return true;
17361
+ if (item.type === "text") return typeof item.text !== "string";
17362
+ if (item.type === "localImage") return typeof item.path !== "string" || !item.path;
17363
+ if (item.type === "image") return typeof item.url !== "string" || !item.url;
17364
+ return true;
17365
+ }) || !input.some(
17366
+ (item) => isRecord4(item) && (item.type !== "text" || typeof item.text === "string" && item.text.trim())
17367
+ )) {
17368
+ throw new Error("External steering requires non-empty text or image input");
17346
17369
  }
17347
17370
  if (toolOutput != null) throw new Error("External steering cannot replace a tool response");
17348
17371
  if (!isRecord4(restoreMessage) || !isRecord4(restoreMessage.context)) {
@@ -227,13 +227,32 @@ var CdpClient = class _CdpClient {
227
227
  returnByValue: true
228
228
  });
229
229
  if (!isRecord(response)) throw new Error("Runtime.evaluate returned an invalid result");
230
- if (isRecord(response.exceptionDetails)) {
231
- throw new Error(cdpExceptionMessage(response.exceptionDetails, "Renderer evaluation failed"));
232
- }
233
- if (!isRecord(response.result) || !("value" in response.result)) {
234
- throw new Error("Runtime.evaluate did not return a value");
230
+ try {
231
+ if (isRecord(response.exceptionDetails)) {
232
+ throw new Error(
233
+ cdpExceptionMessage(response.exceptionDetails, "Renderer evaluation failed")
234
+ );
235
+ }
236
+ if (!isRecord(response.result) || !("value" in response.result)) {
237
+ throw new Error("Runtime.evaluate did not return a value");
238
+ }
239
+ return response.result.value;
240
+ } finally {
241
+ const objects = [
242
+ response.result,
243
+ isRecord(response.exceptionDetails) ? response.exceptionDetails.exception : void 0
244
+ ];
245
+ const ids = new Set(
246
+ objects.flatMap(
247
+ (object2) => isRecord(object2) && typeof object2.objectId === "string" ? [object2.objectId] : []
248
+ )
249
+ );
250
+ await Promise.all(
251
+ [...ids].map(
252
+ (objectId) => this.command("Runtime.releaseObject", { objectId }).catch(() => void 0)
253
+ )
254
+ );
235
255
  }
236
- return response.result.value;
237
256
  }
238
257
  close() {
239
258
  if (this.#closed) return;
@@ -18053,16 +18072,20 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18053
18072
  if (!isRecord3(input) || !isRecord3(input.collaborationMode)) return message;
18054
18073
  const settings = input.collaborationMode.settings;
18055
18074
  if (!isRecord3(settings)) return message;
18075
+ const nativeModel = typeof settings.model === "string" ? settings.model : null;
18056
18076
  let model2 = null;
18057
18077
  if (path5[0] === "startConversation") {
18058
18078
  const draftId = isRecord3(options) ? options.clientThreadId : null;
18059
18079
  model2 = typeof draftId === "string" ? externalDrafts.get(draftId)?.model ?? null : null;
18060
18080
  } else if (path5[0] === "prewarmConversation") {
18061
18081
  if (input.ephemeral !== true) publishDraftWorkspace("local", input.cwd);
18062
- const selected = selectedModels.get("local");
18063
- model2 = selected ? prewarmCarrier(selected) : null;
18082
+ const selected = selectedModels.get("local") ?? null;
18083
+ const carrier = nativeModel?.startsWith("codexhost/") ? nativeModel : selected;
18084
+ model2 = carrier ? prewarmCarrier(carrier) : null;
18064
18085
  }
18065
18086
  if (!model2) return message;
18087
+ if (path5[0] === "startConversation" && nativeModel?.startsWith("codexhost/") && nativeModel !== model2)
18088
+ return message;
18066
18089
  return [
18067
18090
  "push",
18068
18091
  [
@@ -18284,9 +18307,11 @@ function directRendererInstaller() {
18284
18307
  }),
18285
18308
  portPrototype: MessagePort.prototype,
18286
18309
  });
18287
- // Desktop 26.1027 moved AppServerManagers to the main process. Older builds
18288
- // expose native managers in Renderer hook state; the main-process mode only
18289
- // applies when none is visible and its per-Host RPC store is identified.
18310
+ const connected = (routing) => routing.forComposer() !== null ||
18311
+ ['local', ...(routing.knownHostIds?.() ?? [])].some((hostId) => routing.forHost(hostId) !== null);
18312
+ let nativeReady = false;
18313
+ // A legacy registry can remain mounted without a usable native manager.
18314
+ // Prefer a ready native route, then try the identified main-process RPC store.
18290
18315
  const routing = (() => {
18291
18316
  if (window.__codexhostHostRoutingV1) {
18292
18317
  const existing = window.__codexhostHostRoutingV1;
@@ -18296,17 +18321,21 @@ function directRendererInstaller() {
18296
18321
  return existing;
18297
18322
  }
18298
18323
  const native = discover(document);
18299
- if (native.managers.length || native.registries.length) return installNative();
18324
+ if (native.managers.length || native.registries.length) {
18325
+ const routing = installNative();
18326
+ if (connected(routing)) {
18327
+ nativeReady = true;
18328
+ return routing;
18329
+ }
18330
+ routing.dispose();
18331
+ }
18300
18332
  const rpc = installRpc();
18301
18333
  if (rpc) return rpc;
18302
18334
  throw new Error('Renderer Host request manager is unavailable');
18303
18335
  })();
18304
18336
  // Publish a default draft policy only when its Host is unambiguous. Host
18305
18337
  // connections can be ready even when multiple Composers coexist.
18306
- const composerRoute = routing.forComposer();
18307
- const connected = composerRoute !== null ||
18308
- ['local', ...(routing.knownHostIds?.() ?? [])].some((hostId) => routing.forHost(hostId) !== null);
18309
- if (!connected) throw new Error('Renderer Host request manager is unavailable');
18338
+ if (!nativeReady && !connected(routing)) throw new Error('Renderer Host request manager is unavailable');
18310
18339
  return { state: 'ready', reason: 'owned-request-bridge' };
18311
18340
  })()`;
18312
18341
  }
@@ -18340,6 +18369,10 @@ function installRendererDraftPrewarmPolicyDirect(renderer) {
18340
18369
  // packages/desktop-control/src/renderer-loaded-modules.ts
18341
18370
  var record2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
18342
18371
  var MAX_MODULES = 4096;
18372
+ var STALE_CONTEXT_ERROR = /uniqueContextId not found|Cannot find context with specified id|Execution context was destroyed|Cannot find default execution context/i;
18373
+ function isStaleContextError(error51) {
18374
+ return error51 instanceof Error && STALE_CONTEXT_ERROR.test(error51.message);
18375
+ }
18343
18376
  function nativeModuleCatalogExpression(urls, complete, owner) {
18344
18377
  return `Object.defineProperty(globalThis, '__codexhostLoadedModulesV1', {
18345
18378
  configurable: true,
@@ -18361,16 +18394,27 @@ async function installRendererLoadedModules(renderer) {
18361
18394
  const pending = [...dirty];
18362
18395
  dirty.clear();
18363
18396
  publishing = publishing.catch(() => void 0).then(async () => {
18397
+ let failure;
18364
18398
  for (const uniqueId of pending) {
18365
18399
  const context = contexts.get(uniqueId);
18366
18400
  if (!context || disposed) continue;
18367
- const response = await renderer.command("Runtime.evaluate", {
18368
- expression: nativeModuleCatalogExpression([...context.urls], context.complete, owner),
18369
- uniqueContextId: uniqueId
18370
- });
18371
- if (record2(response) && record2(response.exceptionDetails))
18372
- throw new Error("Loaded Renderer module catalog publication failed");
18401
+ try {
18402
+ const response = await renderer.command("Runtime.evaluate", {
18403
+ expression: nativeModuleCatalogExpression([...context.urls], context.complete, owner),
18404
+ uniqueContextId: uniqueId
18405
+ });
18406
+ if (record2(response) && record2(response.exceptionDetails))
18407
+ throw new Error("Loaded Renderer module catalog publication failed");
18408
+ } catch (error51) {
18409
+ if (contexts.get(uniqueId) !== context) continue;
18410
+ if (isStaleContextError(error51)) {
18411
+ forget(uniqueId);
18412
+ continue;
18413
+ }
18414
+ failure ??= error51;
18415
+ }
18373
18416
  }
18417
+ if (failure !== void 0) throw failure;
18374
18418
  });
18375
18419
  return publishing;
18376
18420
  };
@@ -18383,13 +18427,15 @@ async function installRendererLoadedModules(renderer) {
18383
18427
  });
18384
18428
  }, 10);
18385
18429
  };
18386
- const remove = (id) => {
18387
- const uniqueId = contextIds.get(id);
18388
- contextIds.delete(id);
18389
- if (uniqueId) {
18390
- contexts.delete(uniqueId);
18391
- dirty.delete(uniqueId);
18392
- }
18430
+ const forget = (uniqueId) => {
18431
+ contexts.delete(uniqueId);
18432
+ dirty.delete(uniqueId);
18433
+ for (const [id, value] of contextIds) if (value === uniqueId) contextIds.delete(id);
18434
+ };
18435
+ const remove = (params) => {
18436
+ const byId = typeof params.executionContextId === "number" ? contextIds.get(params.executionContextId) : void 0;
18437
+ const uniqueId = typeof params.executionContextUniqueId === "string" ? params.executionContextUniqueId : byId;
18438
+ if (uniqueId) forget(uniqueId);
18393
18439
  };
18394
18440
  const listeners = [
18395
18441
  renderer.on("Runtime.executionContextCreated", (params) => {
@@ -18401,8 +18447,7 @@ async function installRendererLoadedModules(renderer) {
18401
18447
  schedule(context.uniqueId);
18402
18448
  }),
18403
18449
  renderer.on("Runtime.executionContextDestroyed", (params) => {
18404
- if (record2(params) && typeof params.executionContextId === "number")
18405
- remove(params.executionContextId);
18450
+ if (record2(params)) remove(params);
18406
18451
  }),
18407
18452
  renderer.on("Runtime.executionContextsCleared", () => {
18408
18453
  contextIds.clear();