@karlorz/codexhost-cli-win32-x64 0.17.3-0 → 0.17.4-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.17.3-0
10
+ npm install -g @karlorz/codexhost-cli@0.17.4-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.17.3-0","distribution":"npm","target":"windows-x64"}
1
+ {"schemaVersion":1,"version":"0.17.4-1","distribution":"npm","target":"windows-x64"}
@@ -16667,10 +16667,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16667
16667
  function lastVoiceLaunchProductExperience() {
16668
16668
  return lastVoiceProductExperience;
16669
16669
  }
16670
- function isExternalHarnessComposer(owner = globalThis) {
16671
- if (lastVoiceProductExperience === "chat") return false;
16672
- if (selectedComposerModel(owner).startsWith("codexhost/")) return true;
16673
- if (lastVoiceProductExperience !== "work") return false;
16670
+ function lastAgentIsExternalHarness(owner) {
16674
16671
  const storage = owner.localStorage;
16675
16672
  if (!storage) return false;
16676
16673
  try {
@@ -16680,6 +16677,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16680
16677
  return false;
16681
16678
  }
16682
16679
  }
16680
+ function isExternalHarnessComposer(owner = globalThis) {
16681
+ if (lastVoiceProductExperience === "chat") return false;
16682
+ if (selectedComposerModel(owner).startsWith("codexhost/")) return true;
16683
+ if (lastVoiceProductExperience === "codex") return false;
16684
+ if (lastVoiceProductExperience !== "work" && !isWorkComposerSurface(owner)) return false;
16685
+ return lastAgentIsExternalHarness(owner);
16686
+ }
16683
16687
  function wrapClientOwnedVoiceFetch(client, bridge, workOverride, responseError, chatOverride = () => false, workSurface = () => isWorkComposerSurface(), externalHarness = () => isExternalHarnessComposer()) {
16684
16688
  const original = client.fetch;
16685
16689
  const wrapped = async function(url2, options) {
@@ -17819,7 +17823,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17819
17823
  // src/renderer-voice-start-capability.ts
17820
17824
  var GLOBAL = "__codexhostVoiceStartCapabilityV1";
17821
17825
  var record3 = (v) => v !== null && typeof v === "object";
17822
- function gatewayVoiceStartRequest(request, workGateway, chatGateway = false) {
17826
+ function gatewayVoiceStartRequest(request, workGateway, chatGateway = false, externalHarness = false) {
17823
17827
  if (!record3(request) || request.productExperience !== "work" && request.productExperience !== "codex" && request.productExperience !== "chat")
17824
17828
  return false;
17825
17829
  if (request.source === "composer_button_existing_thread") {
@@ -17830,7 +17834,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17830
17834
  const mode = request.activeCollaborationMode;
17831
17835
  const settings = record3(mode) ? mode.settings : void 0;
17832
17836
  const model2 = record3(settings) ? settings.model : void 0;
17833
- return workGateway || typeof model2 === "string" && model2.startsWith("codexhost/");
17837
+ return workGateway || externalHarness || typeof model2 === "string" && model2.startsWith("codexhost/");
17834
17838
  }
17835
17839
  function wrapGatewayVoiceStarter(start, options) {
17836
17840
  let active;
@@ -17932,7 +17936,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17932
17936
  qualifies: (request) => !disposed && !!readCpaLiveVoiceHookConfig(target) && gatewayVoiceStartRequest(
17933
17937
  request,
17934
17938
  cpaLiveVoicePreferenceAllowsInstall(target),
17935
- chatLiveVoicePreferenceAllowsOverride(target)
17939
+ chatLiveVoicePreferenceAllowsOverride(target),
17940
+ isExternalHarnessComposer(target)
17936
17941
  ),
17937
17942
  ready: async () => {
17938
17943
  const hook = target.__codexhostClientOwnedVoiceV1;
@@ -65,6 +65,12 @@ async function openRendererLocalPage(execute, url2, targets) {
65
65
  }
66
66
 
67
67
  // packages/desktop-control/src/cdp-client.ts
68
+ var CdpConnectionClosedError = class extends Error {
69
+ constructor(message) {
70
+ super(message);
71
+ this.name = "CdpConnectionClosedError";
72
+ }
73
+ };
68
74
  function cdpExceptionMessage(details, fallback) {
69
75
  const exception = details.exception;
70
76
  if (isRecord(exception) && typeof exception.description === "string" && exception.description) {
@@ -152,8 +158,14 @@ var CdpClient = class _CdpClient {
152
158
  this.#socket = socket;
153
159
  this.#commandTimeoutMs = commandTimeoutMs;
154
160
  socket.addEventListener("message", (event) => this.#onMessage(event));
155
- socket.addEventListener("error", () => this.#fail(new Error("CDP WebSocket failed")));
156
- socket.addEventListener("close", () => this.#fail(new Error("CDP WebSocket closed")));
161
+ socket.addEventListener(
162
+ "error",
163
+ () => this.#disconnect(new CdpConnectionClosedError("CDP WebSocket failed"))
164
+ );
165
+ socket.addEventListener(
166
+ "close",
167
+ () => this.#disconnect(new CdpConnectionClosedError("CDP WebSocket closed"))
168
+ );
157
169
  }
158
170
  static async connect(url2, options = {}) {
159
171
  loopbackUrl(url2, ["ws:", "wss:"]);
@@ -201,7 +213,7 @@ var CdpClient = class _CdpClient {
201
213
  };
202
214
  }
203
215
  #send(method, params, sessionId) {
204
- if (this.#closed) return Promise.reject(new Error("CDP client is closed"));
216
+ if (this.#closed) return Promise.reject(new CdpConnectionClosedError("CDP client is closed"));
205
217
  const id = this.#nextId++;
206
218
  return new Promise((resolve, reject) => {
207
219
  const timeout = setTimeout(() => {
@@ -255,9 +267,12 @@ var CdpClient = class _CdpClient {
255
267
  }
256
268
  }
257
269
  close() {
270
+ this.#disconnect(new CdpConnectionClosedError("CDP client closed"));
271
+ }
272
+ #disconnect(error51) {
258
273
  if (this.#closed) return;
259
274
  this.#closed = true;
260
- this.#fail(new Error("CDP client closed"));
275
+ this.#fail(error51);
261
276
  this.#listeners.clear();
262
277
  this.#socket.close();
263
278
  }
@@ -19728,6 +19743,7 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
19728
19743
  } catch (error51) {
19729
19744
  signal?.throwIfAborted();
19730
19745
  lastError = error51;
19746
+ if (error51 instanceof CdpConnectionClosedError) throw error51;
19731
19747
  if (error51 instanceof RendererAdapterReadinessError && error51.state !== "installing") {
19732
19748
  throw error51;
19733
19749
  }
@@ -20149,6 +20165,7 @@ function parseDesktopControllerArguments(arguments_) {
20149
20165
  function isTransientRendererInstallError(error51) {
20150
20166
  let current = error51;
20151
20167
  for (let depth = 0; depth < 4; depth += 1) {
20168
+ if (current instanceof CdpConnectionClosedError) return true;
20152
20169
  const message = current instanceof Error ? current.message : String(current);
20153
20170
  if (message.includes("Execution context was destroyed") || message.includes("Promise was collected")) {
20154
20171
  return true;