@karlorz/codexhost-cli-win32-x64 0.17.1-0 → 0.17.4-0

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.
@@ -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
  }
@@ -15853,6 +15868,21 @@ var threadSteeringInspectParamsSchema = external_exports.object({
15853
15868
  /** The text about to be steered; a Harness command always stops and restarts. */
15854
15869
  text: external_exports.string().optional()
15855
15870
  }).strict();
15871
+ var threadSteeringContextSchema = external_exports.object({
15872
+ kind: external_exports.literal("application"),
15873
+ value: external_exports.string().transform((text, context) => {
15874
+ try {
15875
+ return JSON.parse(text);
15876
+ } catch {
15877
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15878
+ return external_exports.NEVER;
15879
+ }
15880
+ }).pipe(external_exports.object({
15881
+ expectedTurnId: hostTurnIdSchema,
15882
+ clientUserMessageId: external_exports.string().min(1),
15883
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
15884
+ }).strict())
15885
+ }).strict().transform((context) => context.value);
15856
15886
  var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15857
15887
  var threadSteeringInspectResultSchema = external_exports.object({
15858
15888
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
@@ -16856,6 +16886,79 @@ function cpaLiveVoiceHookBootstrap(environment = process.env, desktopVersion) {
16856
16886
  `;
16857
16887
  }
16858
16888
 
16889
+ // packages/desktop-control/src/browser-annotation-style-compat.ts
16890
+ var BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE = String.raw`(() => {
16891
+ const key = '__codexhostBrowserAnnotationStylesV1';
16892
+ if (globalThis[key]?.refresh() === true) return;
16893
+ if (typeof CSSStyleSheet !== 'function' ||
16894
+ typeof CSSStyleSheet.prototype.replaceSync !== 'function') return;
16895
+ let root = null;
16896
+ let shadow = null;
16897
+ let stylesObserver = null;
16898
+ const copies = new Map();
16899
+ function removeCopies() {
16900
+ if (shadow) {
16901
+ const owned = new Set(Array.from(copies.values(), copy => copy.sheet));
16902
+ shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => !owned.has(sheet));
16903
+ }
16904
+ copies.clear();
16905
+ }
16906
+ function syncStyles() {
16907
+ if (!shadow) return;
16908
+ const present = new Set();
16909
+ for (const style of shadow.querySelectorAll('style')) {
16910
+ const text = style.textContent || '';
16911
+ // Only repair Codex's cursor stylesheet when CSP rejected its style element.
16912
+ if (style.sheet || !text.includes('.annotation-selection-cursor')) continue;
16913
+ present.add(style);
16914
+ const previous = copies.get(style);
16915
+ if (previous?.text === text && shadow.adoptedStyleSheets.includes(previous.sheet)) continue;
16916
+ try {
16917
+ const sheet = previous?.sheet ?? new CSSStyleSheet();
16918
+ sheet.replaceSync(text);
16919
+ if (!shadow.adoptedStyleSheets.includes(sheet)) {
16920
+ shadow.adoptedStyleSheets = [...shadow.adoptedStyleSheets, sheet];
16921
+ }
16922
+ copies.set(style, { sheet, text });
16923
+ } catch { /* Unsupported annotation styles leave native behavior intact. */ }
16924
+ }
16925
+ for (const [style, copy] of copies) {
16926
+ if (present.has(style)) continue;
16927
+ shadow.adoptedStyleSheets = shadow.adoptedStyleSheets.filter(sheet => sheet !== copy.sheet);
16928
+ copies.delete(style);
16929
+ }
16930
+ }
16931
+ function refresh() {
16932
+ const nextRoot = document.documentElement;
16933
+ if (root !== nextRoot) {
16934
+ rootObserver.disconnect();
16935
+ rootObserver.observe(document, { childList: true });
16936
+ root = nextRoot;
16937
+ if (root) rootObserver.observe(root, { childList: true });
16938
+ }
16939
+ const host = document.getElementById('codex-browser-sidebar-comments-root');
16940
+ const nextShadow = host?.parentElement === root ? host?.shadowRoot ?? null : null;
16941
+ if (nextShadow !== shadow) {
16942
+ stylesObserver?.disconnect();
16943
+ removeCopies();
16944
+ shadow = nextShadow;
16945
+ stylesObserver = null;
16946
+ if (shadow && 'adoptedStyleSheets' in shadow) {
16947
+ stylesObserver = new MutationObserver(syncStyles);
16948
+ stylesObserver.observe(shadow, { childList: true, subtree: true, characterData: true });
16949
+ } else {
16950
+ shadow = null;
16951
+ }
16952
+ }
16953
+ syncStyles();
16954
+ return true;
16955
+ }
16956
+ const rootObserver = new MutationObserver(refresh);
16957
+ rootObserver.observe(document, { childList: true });
16958
+ globalThis[key] = { refresh };
16959
+ refresh();
16960
+ })();`;
16961
+
16859
16962
  // packages/desktop-control/src/renderer-react-ownership.ts
16860
16963
  function committedReactAncestors(value) {
16861
16964
  const MAX_VISITED_FIBERS = 2e5;
@@ -17920,7 +18023,9 @@ function findRendererHostRpcFamily(store) {
17920
18023
  if (!record3(definition) || definition.kind !== "signal-family") continue;
17921
18024
  if (!record3(members) || typeof members.get !== "function") continue;
17922
18025
  for (const [hostId2, member] of members) {
17923
- if (typeof hostId2 !== "string" || !record3(member)) continue;
18026
+ if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:]|ssh:)/u.test(hostId2))
18027
+ continue;
18028
+ if (!record3(member)) continue;
17924
18029
  const signal = member.value;
17925
18030
  if (!record3(signal) || typeof signal.get !== "function") continue;
17926
18031
  let value;
@@ -18042,7 +18147,8 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18042
18147
  if (disposed) return null;
18043
18148
  try {
18044
18149
  const store = dependencies.findStore(root);
18045
- discovery = store ? dependencies.findFamily(store) : null;
18150
+ const bound = store && discovery?.store === store ? [...store.familyBindings.values()].includes(discovery.family) : false;
18151
+ if (!bound) discovery = store ? dependencies.findFamily(store) : null;
18046
18152
  } catch {
18047
18153
  discovery = null;
18048
18154
  }
@@ -18050,13 +18156,15 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18050
18156
  };
18051
18157
  if (!read()) return null;
18052
18158
  const queuePolicy = dependencies.installQueuePolicy(root, target);
18053
- const native = () => {
18054
- if (disposed) return null;
18055
- try {
18056
- nativeRouting ??= dependencies.nativeRouting?.() ?? null;
18057
- } catch {
18159
+ const discoverComposer = (composer) => {
18160
+ const owners = dependencies.discoverComposer(composer);
18161
+ if (!nativeRouting && (owners.managers.length || owners.registries.length)) {
18162
+ try {
18163
+ nativeRouting = dependencies.installNativeRouting();
18164
+ } catch {
18165
+ }
18058
18166
  }
18059
- return nativeRouting;
18167
+ return owners;
18060
18168
  };
18061
18169
  const connectionFor = (hostId2) => {
18062
18170
  if (!hostId2.startsWith("remote-control:")) return void 0;
@@ -18242,7 +18350,7 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18242
18350
  const routeFor = (hostId2, nativeRoute) => {
18243
18351
  if (disposed) return null;
18244
18352
  const connection = connectionFor(hostId2);
18245
- const preferred = nativeRoute === void 0 ? native()?.forHost(hostId2) : nativeRoute;
18353
+ const preferred = nativeRoute === void 0 ? nativeRouting?.forHost(hostId2) : nativeRoute;
18246
18354
  if (connection === null || preferred) {
18247
18355
  retire(hostId2);
18248
18356
  return connection === null ? null : preferred ?? null;
@@ -18269,21 +18377,25 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18269
18377
  target.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
18270
18378
  }
18271
18379
  };
18272
- const composerHostId = (composer) => {
18273
- const nativeHostId = native()?.hostIdForComposer(composer);
18380
+ const composerHostId = (owners, composer) => {
18381
+ const nativeHostId = nativeRouting?.hostIdForComposer(composer);
18274
18382
  if (nativeHostId) return nativeHostId;
18275
- const hostIds = new Set(dependencies.composerHostIds(composer).hostIds);
18383
+ const hostIds = new Set((owners ?? discoverComposer(composer)).hostIds);
18276
18384
  const hostId2 = hostIds.size === 1 ? hostIds.values().next().value : null;
18277
18385
  return typeof hostId2 === "string" && hostId2 ? hostId2 : null;
18278
18386
  };
18279
18387
  const routing = {
18280
18388
  knownHostIds() {
18281
18389
  if (disposed) return [];
18390
+ try {
18391
+ if (!nativeRouting) discoverComposer();
18392
+ } catch {
18393
+ }
18282
18394
  const current = read();
18283
18395
  return [
18284
18396
  .../* @__PURE__ */ new Set([
18285
18397
  ...current ? dependencies.hostIds(current) : [],
18286
- ...native()?.knownHostIds?.() ?? []
18398
+ ...nativeRouting?.knownHostIds?.() ?? []
18287
18399
  ])
18288
18400
  ];
18289
18401
  },
@@ -18293,7 +18405,7 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18293
18405
  hostIdForComposer(composer) {
18294
18406
  if (disposed) return null;
18295
18407
  try {
18296
- return composerHostId(composer);
18408
+ return composerHostId(nativeRouting ? null : discoverComposer(composer), composer);
18297
18409
  } catch {
18298
18410
  return null;
18299
18411
  }
@@ -18303,8 +18415,9 @@ function installRendererHostRpcRouting(root, target, dependencies) {
18303
18415
  let hostId2;
18304
18416
  let preferred = null;
18305
18417
  try {
18306
- preferred = native()?.forComposer(composer) ?? null;
18307
- hostId2 = preferred?.hostId ?? composerHostId(composer);
18418
+ const owners = nativeRouting ? null : discoverComposer(composer);
18419
+ preferred = nativeRouting?.forComposer(composer) ?? null;
18420
+ hostId2 = preferred?.hostId ?? composerHostId(owners, composer);
18308
18421
  } catch {
18309
18422
  hostId2 = null;
18310
18423
  }
@@ -18388,7 +18501,7 @@ function directRendererInstaller() {
18388
18501
  findFamily: ${findRendererHostRpcFamily.toString()},
18389
18502
  resolve: ${resolveRendererHostRpc.toString()},
18390
18503
  hostIds: ${rendererHostRpcHostIds.toString()},
18391
- composerHostIds: (composer) => {
18504
+ discoverComposer: (composer) => {
18392
18505
  const source = composer?.matches?.('[data-codex-composer], [contenteditable="true"][role="textbox"]')
18393
18506
  ? { querySelectorAll: () => [composer] }
18394
18507
  : (composer ?? document);
@@ -18400,10 +18513,7 @@ function directRendererInstaller() {
18400
18513
  portPrototype: MessagePort.prototype,
18401
18514
  }),
18402
18515
  portPrototype: MessagePort.prototype,
18403
- nativeRouting: () => {
18404
- const native = discover(document);
18405
- return native.managers.length || native.registries.length ? installNative(false) : null;
18406
- },
18516
+ installNativeRouting: () => installNative(false),
18407
18517
  readConnection: (hostId) => readRendererConnectionGeneration(findRendererAppScopeStore(document), hostId),
18408
18518
  });
18409
18519
  const connected = (routing) => routing.forComposer() !== null ||
@@ -19358,6 +19468,117 @@ async function installNativeRpcRemoteControlDirect(renderer) {
19358
19468
  }
19359
19469
  }
19360
19470
 
19471
+ // packages/desktop-control/src/renderer-rpc-steering.ts
19472
+ var RETRY_BASE_MS = 5e3;
19473
+ var RETRY_MAX_MS = 3e5;
19474
+ var retries = /* @__PURE__ */ new WeakMap();
19475
+ async function installRendererRpcSteeringDirect(client, now = Date.now) {
19476
+ try {
19477
+ const needed = await client.evaluate(`(() => {
19478
+ const steering = window.__codexhostRpcSteeringV1;
19479
+ if (steering && steering.controller.forHost === steering.forHost) return false;
19480
+ steering?.release();
19481
+ const routing=window.__codexhostHostRoutingV1;
19482
+ return ['local', ...(routing?.knownHostIds?.() ?? [])].some(id => routing?.forHost(id)?.manager.kind === 'main-process-rpc');
19483
+ })()`);
19484
+ if (!needed) return false;
19485
+ const retry = retries.get(client);
19486
+ if (retry && now() < retry.nextAt) return false;
19487
+ try {
19488
+ await discoverAndInstall(client);
19489
+ retries.delete(client);
19490
+ return true;
19491
+ } catch (error51) {
19492
+ const attempts = (retry?.attempts ?? 0) + 1;
19493
+ const delay = Math.min(RETRY_BASE_MS * 2 ** (attempts - 1), RETRY_MAX_MS);
19494
+ retries.set(client, { attempts, nextAt: now() + delay });
19495
+ console.error(
19496
+ `codexhost native steering discovery failed (attempt ${attempts}):`,
19497
+ error51 instanceof Error ? error51.message : String(error51)
19498
+ );
19499
+ return false;
19500
+ }
19501
+ } catch {
19502
+ return false;
19503
+ }
19504
+ }
19505
+ async function discoverAndInstall(client) {
19506
+ const group = `codexhost-rpc-steering-${crypto.randomUUID()}`;
19507
+ const command = (method, params) => client.command(method, params);
19508
+ const properties = (objectId) => command("Runtime.getProperties", { objectId, ownProperties: true });
19509
+ const call = (objectId, functionDeclaration, args = []) => command("Runtime.callFunctionOn", {
19510
+ objectId,
19511
+ functionDeclaration,
19512
+ arguments: args,
19513
+ objectGroup: group,
19514
+ returnByValue: true
19515
+ });
19516
+ try {
19517
+ const proto = await command("Runtime.evaluate", {
19518
+ expression: "Object.getPrototypeOf(async function(){})",
19519
+ objectGroup: group
19520
+ });
19521
+ if (!proto.result.objectId) throw new Error("Native RPC steering discovery is unavailable");
19522
+ const objects = await command("Runtime.queryObjects", {
19523
+ prototypeObjectId: proto.result.objectId,
19524
+ objectGroup: group
19525
+ });
19526
+ if (!objects.objects.objectId) throw new Error("Native RPC steering discovery is unavailable");
19527
+ const filtered = await command("Runtime.callFunctionOn", {
19528
+ objectId: objects.objects.objectId,
19529
+ functionDeclaration: 'function(){return this.filter(fn=>fn.name==="collectAppStateSnapshot"&&String(fn).includes("collectSnapshot")).slice(0,9)}',
19530
+ objectGroup: group
19531
+ });
19532
+ if (!filtered.result.objectId) throw new Error("Native RPC Controller is unavailable");
19533
+ const snapshots = (await properties(filtered.result.objectId)).result.flatMap(
19534
+ (entry) => entry.value?.type === "function" && entry.value.objectId ? [entry.value.objectId] : []
19535
+ );
19536
+ if (snapshots.length > 8) throw new Error("Native RPC Controller is ambiguous");
19537
+ const controllers = [];
19538
+ for (const snapshot of snapshots) {
19539
+ const scopes = (await properties(snapshot)).internalProperties?.find(
19540
+ (entry) => entry.name === "[[Scopes]]"
19541
+ )?.value?.objectId;
19542
+ if (!scopes) continue;
19543
+ for (const scope of (await properties(scopes)).result) {
19544
+ if (!scope.value?.objectId || !scope.value.description?.startsWith("Closure")) continue;
19545
+ const bindings = (await properties(scope.value.objectId)).result;
19546
+ const owners = [];
19547
+ let rootScope;
19548
+ for (const binding of bindings) {
19549
+ if (binding.value?.type !== "object" || !binding.value.objectId) continue;
19550
+ const id = binding.value.objectId;
19551
+ const result2 = await call(
19552
+ id,
19553
+ `function(){return (${nativeRpcObjectShape.toString()})(this)}`
19554
+ );
19555
+ const shape = result2.result.value;
19556
+ if (shape?.scope) rootScope = id;
19557
+ if (shape?.controller && (await call(id, "function(fn){return this.collectAppStateSnapshot===fn}", [
19558
+ { objectId: snapshot }
19559
+ ])).result.value === true)
19560
+ owners.push(id);
19561
+ }
19562
+ if (owners.length !== 1 || !rootScope) continue;
19563
+ const root = await call(
19564
+ rootScope,
19565
+ `function(){let node=this.node;const seen=new Set();while(node?.parent&&!seen.has(node.parent)&&seen.size<100){seen.add(node);node=node.parent}return (${findRendererAppScopeStore.toString()})(document)===node}`
19566
+ );
19567
+ if (root.result.value === true) controllers.push(owners[0]);
19568
+ }
19569
+ }
19570
+ if (controllers.length !== 1) throw new Error("Native RPC Controller is missing or ambiguous");
19571
+ const result = await call(
19572
+ controllers[0],
19573
+ "function(){return window.__codexhostInstallRpcSteeringV1?.(this) === true}"
19574
+ );
19575
+ if (result.exceptionDetails || result.result.value !== true)
19576
+ throw new Error("Native RPC steering installation failed");
19577
+ } finally {
19578
+ await client.command("Runtime.releaseObjectGroup", { objectGroup: group }).catch(() => void 0);
19579
+ }
19580
+ }
19581
+
19361
19582
  // packages/desktop-control/src/renderer-cdp-control-session.ts
19362
19583
  function isRecord2(value) {
19363
19584
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -19522,6 +19743,7 @@ async function waitForBinding(renderer, enabledAgents, timeoutMs, pollIntervalMs
19522
19743
  } catch (error51) {
19523
19744
  signal?.throwIfAborted();
19524
19745
  lastError = error51;
19746
+ if (error51 instanceof CdpConnectionClosedError) throw error51;
19525
19747
  if (error51 instanceof RendererAdapterReadinessError && error51.state !== "installing") {
19526
19748
  throw error51;
19527
19749
  }
@@ -19565,6 +19787,45 @@ function isLocalThreadRenderer(target) {
19565
19787
  const route = url2.searchParams.get("initialRoute");
19566
19788
  return [...url2.searchParams.keys()].length === 1 && (route === "/local" || route?.startsWith("/local/") === true);
19567
19789
  }
19790
+ function isBrowserPage(target) {
19791
+ if (target.type !== "page") return false;
19792
+ try {
19793
+ return ["http:", "https:"].includes(new URL(target.url).protocol);
19794
+ } catch {
19795
+ return false;
19796
+ }
19797
+ }
19798
+ async function installBrowserAnnotationStyles(target, browserClients, operations, signal) {
19799
+ const timeoutMessage = "Browser annotation style compatibility installation timed out";
19800
+ const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
19801
+ let renderer = browserClients.get(target.id);
19802
+ const registered = renderer !== void 0;
19803
+ renderer ??= await connectRendererTarget(target, operations, signal, timeoutMessage);
19804
+ const connected = renderer;
19805
+ try {
19806
+ if (!registered) {
19807
+ await run(() => connected.command("Page.enable"));
19808
+ await run(
19809
+ () => connected.command("Page.addScriptToEvaluateOnNewDocument", {
19810
+ source: BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE
19811
+ })
19812
+ );
19813
+ browserClients.set(target.id, connected);
19814
+ }
19815
+ const installed = await run(
19816
+ () => connected.evaluate(
19817
+ "globalThis.__codexhostBrowserAnnotationStylesV1?.refresh() === true"
19818
+ )
19819
+ );
19820
+ if (installed !== true) {
19821
+ await run(() => evaluateSource(connected, BROWSER_ANNOTATION_STYLE_COMPAT_SOURCE));
19822
+ }
19823
+ } catch (error51) {
19824
+ browserClients.delete(target.id);
19825
+ connected.close();
19826
+ throw error51;
19827
+ }
19828
+ }
19568
19829
  async function installLocalThreadRenderer(target, source, enabledAgents, operations, signal) {
19569
19830
  const timeoutMessage = "Local chat Renderer installation timed out";
19570
19831
  const run = (operation) => runWithCdpSignal(signal, timeoutMessage, operation);
@@ -19582,14 +19843,24 @@ async function installLocalThreadRenderer(target, source, enabledAgents, operati
19582
19843
  renderer.close();
19583
19844
  }
19584
19845
  }
19585
- async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, operations, signal) {
19846
+ async function installAuxiliaryRenderers(endpoint, rendererSource, enabledAgents, overlayHookSource, browserStyleClients, operations, signal) {
19586
19847
  try {
19587
19848
  const targets = await awaitWithSignal(
19588
19849
  operations.listTargets(endpoint, signal),
19589
19850
  signal,
19590
19851
  "Auxiliary Renderer CDP target discovery timed out"
19591
19852
  );
19853
+ const liveTargets = new Set(targets.map((target) => target.id));
19854
+ for (const [id, client] of browserStyleClients) {
19855
+ if (!liveTargets.has(id)) {
19856
+ client.close();
19857
+ browserStyleClients.delete(id);
19858
+ }
19859
+ }
19592
19860
  await Promise.allSettled([
19861
+ ...targets.filter(isBrowserPage).map(
19862
+ (target) => installBrowserAnnotationStyles(target, browserStyleClients, operations, signal)
19863
+ ),
19593
19864
  ...overlayHookSource ? selectAvatarOverlayRendererTargets(targets).map(
19594
19865
  (overlay) => installOverlayHook(overlay, overlayHookSource, operations, signal)
19595
19866
  ) : [],
@@ -19618,11 +19889,12 @@ async function installTarget(target, rendererSource, enabledAgents, timeoutMs, p
19618
19889
  }
19619
19890
  }
19620
19891
  var InstalledRendererCdpControlSession = class {
19621
- constructor(renderer, rendererCdpEndpoint2, rendererSource, overlayHookSource, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
19892
+ constructor(renderer, rendererCdpEndpoint2, rendererSource, overlayHookSource, browserStyleClients, enabledAgents, timeoutMs, pollIntervalMs, operations, currentSnapshot, disposeModules) {
19622
19893
  this.renderer = renderer;
19623
19894
  this.rendererCdpEndpoint = rendererCdpEndpoint2;
19624
19895
  this.rendererSource = rendererSource;
19625
19896
  this.overlayHookSource = overlayHookSource;
19897
+ this.browserStyleClients = browserStyleClients;
19626
19898
  this.enabledAgents = enabledAgents;
19627
19899
  this.timeoutMs = timeoutMs;
19628
19900
  this.pollIntervalMs = pollIntervalMs;
@@ -19634,6 +19906,7 @@ var InstalledRendererCdpControlSession = class {
19634
19906
  rendererCdpEndpoint;
19635
19907
  rendererSource;
19636
19908
  overlayHookSource;
19909
+ browserStyleClients;
19637
19910
  enabledAgents;
19638
19911
  timeoutMs;
19639
19912
  pollIntervalMs;
@@ -19700,6 +19973,7 @@ var InstalledRendererCdpControlSession = class {
19700
19973
  this.rendererSource,
19701
19974
  this.enabledAgents,
19702
19975
  this.overlayHookSource,
19976
+ this.browserStyleClients,
19703
19977
  this.operations,
19704
19978
  discoveryTimeoutSignal(this.timeoutMs)
19705
19979
  );
@@ -19719,6 +19993,8 @@ var InstalledRendererCdpControlSession = class {
19719
19993
  this.#closed = true;
19720
19994
  this.disposeModules();
19721
19995
  this.renderer.close();
19996
+ for (const client of this.browserStyleClients.values()) client.close();
19997
+ this.browserStyleClients.clear();
19722
19998
  }
19723
19999
  };
19724
20000
  var defaultOperations = {
@@ -19727,6 +20003,7 @@ var defaultOperations = {
19727
20003
  async installDraftPrewarmPolicy(renderer) {
19728
20004
  const status = await installRendererDraftPrewarmPolicyDirect(renderer);
19729
20005
  await installNativeRpcRemoteControlDirect(renderer);
20006
+ await installRendererRpcSteeringDirect(renderer);
19730
20007
  return status;
19731
20008
  }
19732
20009
  };
@@ -19751,11 +20028,13 @@ async function createRendererCdpControlSession(options) {
19751
20028
  pollIntervalMs,
19752
20029
  operations
19753
20030
  );
20031
+ const browserStyleClients = /* @__PURE__ */ new Map();
19754
20032
  await installAuxiliaryRenderers(
19755
20033
  options.rendererCdpEndpoint,
19756
20034
  options.rendererSource,
19757
20035
  enabledAgents,
19758
20036
  options.overlayHookSource,
20037
+ browserStyleClients,
19759
20038
  operations,
19760
20039
  discoveryTimeoutSignal(timeoutMs, options.signal)
19761
20040
  );
@@ -19764,6 +20043,7 @@ async function createRendererCdpControlSession(options) {
19764
20043
  options.rendererCdpEndpoint,
19765
20044
  options.rendererSource,
19766
20045
  options.overlayHookSource,
20046
+ browserStyleClients,
19767
20047
  enabledAgents,
19768
20048
  timeoutMs,
19769
20049
  pollIntervalMs,
@@ -19885,6 +20165,7 @@ function parseDesktopControllerArguments(arguments_) {
19885
20165
  function isTransientRendererInstallError(error51) {
19886
20166
  let current = error51;
19887
20167
  for (let depth = 0; depth < 4; depth += 1) {
20168
+ if (current instanceof CdpConnectionClosedError) return true;
19888
20169
  const message = current instanceof Error ? current.message : String(current);
19889
20170
  if (message.includes("Execution context was destroyed") || message.includes("Promise was collected")) {
19890
20171
  return true;