@karlorz/codexhost-cli-linux-arm64 0.14.0-0 → 0.14.0-2

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.
@@ -15254,15 +15254,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15254
15254
  defaultModeId: harnessPermissionModeIdSchema
15255
15255
  }).strict().superRefine((catalog, context) => {
15256
15256
  const ids = /* @__PURE__ */ new Set();
15257
- for (const [index, mode] of catalog.modes.entries()) {
15258
- if (ids.has(mode.id)) {
15257
+ for (const [index, mode2] of catalog.modes.entries()) {
15258
+ if (ids.has(mode2.id)) {
15259
15259
  context.addIssue({
15260
15260
  code: "custom",
15261
15261
  message: "Permission Mode IDs must be unique",
15262
15262
  path: ["modes", index, "id"]
15263
15263
  });
15264
15264
  }
15265
- ids.add(mode.id);
15265
+ ids.add(mode2.id);
15266
15266
  }
15267
15267
  if (!ids.has(catalog.defaultModeId)) {
15268
15268
  context.addIssue({
@@ -16303,13 +16303,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16303
16303
  }
16304
16304
  function resourceNamesFromPerformance(source) {
16305
16305
  const target = source ?? (typeof performance === "undefined" ? void 0 : performance);
16306
- if (!target || typeof target.getEntriesByType !== "function") return [];
16307
- return target.getEntriesByType("resource").map((entry) => entry.name).filter((name) => typeof name === "string");
16306
+ if (!target) return [];
16307
+ const names = [];
16308
+ const push = (name) => {
16309
+ if (typeof name === "string" && name) names.push(name);
16310
+ };
16311
+ if (typeof target.getEntries === "function") {
16312
+ for (const entry of target.getEntries()) push(entry.name);
16313
+ } else if (typeof target.getEntriesByType === "function") {
16314
+ for (const entry of target.getEntriesByType("resource")) push(entry.name);
16315
+ }
16316
+ return names;
16308
16317
  }
16309
16318
  function loadedAssetNames(root, performanceSource) {
16310
16319
  const names = resourceNamesFromPerformance(performanceSource);
16311
16320
  if (!root || !("querySelectorAll" in root)) return names;
16312
- for (const element of root.querySelectorAll("script[src], link[href]")) {
16321
+ for (const element of root.querySelectorAll(
16322
+ 'script[src], link[href], link[rel="modulepreload"], link[rel="preload"]'
16323
+ )) {
16313
16324
  const value = element.getAttribute("src") ?? element.getAttribute("href");
16314
16325
  if (value) names.push(value);
16315
16326
  }
@@ -16407,8 +16418,80 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16407
16418
  const present = profiles.filter(
16408
16419
  (profile2) => [profile2.initial, profile2.shared].some((asset) => auditedAppInitialAssetPresent(names, asset))
16409
16420
  );
16421
+ if (version2 !== void 0) {
16422
+ const profile2 = profiles.find((entry) => entry.version === version2);
16423
+ if (!profile2) return void 0;
16424
+ if (present.some((entry) => entry.version !== version2)) return void 0;
16425
+ const complete = [profile2.initial, profile2.shared].every(
16426
+ (asset) => auditedAppInitialAssetPresent(names, asset)
16427
+ );
16428
+ return complete || present.length === 0 ? profile2 : void 0;
16429
+ }
16410
16430
  const profile = present.length === 1 ? present[0] : void 0;
16411
- return profile && (version2 === void 0 || profile.version === version2) && [profile.initial, profile.shared].every((asset) => auditedAppInitialAssetPresent(names, asset)) ? profile : void 0;
16431
+ return profile && [profile.initial, profile.shared].every((asset) => auditedAppInitialAssetPresent(names, asset)) ? profile : void 0;
16432
+ }
16433
+
16434
+ // src/renderer-native-chat-voice-assets.ts
16435
+ var NATIVE_CHAT_VOICE_VERSION = "26.1021.31345";
16436
+ var NATIVE_CHAT_INITIAL_ASSET = "app-initial-feb30b196d11.js";
16437
+ var START_ASSET = "entity-business-profile-reference-b68063dfc05d.js";
16438
+ var NATIVE_CHAT_VOICE_ASSETS = [
16439
+ {
16440
+ version: NATIVE_CHAT_VOICE_VERSION,
16441
+ initial: NATIVE_CHAT_INITIAL_ASSET,
16442
+ shared: "app-shared-2cae01273bae.js",
16443
+ primary: "app-primary-7d7313419f84.js",
16444
+ start: START_ASSET,
16445
+ prewarm: "voice-prewarm-d672f1245523.js",
16446
+ settings: "voice-settings-14000f5c9fc2.js"
16447
+ },
16448
+ {
16449
+ version: "26.1016.62342",
16450
+ initial: "app-initial-dddef47d6ef6.js",
16451
+ shared: "app-shared-fc3316d48427.js",
16452
+ start: "start-voice-7cbf0a39d53b.js",
16453
+ prewarm: "voice-prewarm-5d107129ac1c.js"
16454
+ },
16455
+ {
16456
+ version: "26.1016.61520",
16457
+ initial: "app-initial-c95ddb62696e.js",
16458
+ shared: "app-shared-2eda13eb7044.js",
16459
+ start: "start-voice-18b08f0acdd7.js",
16460
+ prewarm: "voice-prewarm-94271e581c1b.js"
16461
+ }
16462
+ ];
16463
+ async function loadNativeChatVoiceModules(assets, importModule) {
16464
+ const [sharedModule, initialModule, startModule, prewarm, primary] = await Promise.all(
16465
+ [assets.shared, assets.initial, assets.start, assets.prewarm, assets.primary].map(
16466
+ (asset) => asset ? importModule(`app://-/assets/${asset}`) : Promise.resolve(void 0)
16467
+ )
16468
+ );
16469
+ if (!sharedModule || !initialModule || !startModule || !prewarm) throw new Error();
16470
+ const current = assets.version === NATIVE_CHAT_VOICE_VERSION;
16471
+ const initialize = current ? primary?.um : initialModule.oT;
16472
+ const start = current ? { t: startModule.r, n: startModule.i } : startModule;
16473
+ if (typeof start.t !== "function" || typeof start.n !== "function" || typeof initialize !== "function" || typeof (current ? initialModule.qXt : initialModule.SPn) !== "function" || typeof (current ? sharedModule.XVt : sharedModule.FBt) !== "function" || typeof (current ? sharedModule.KNt : sharedModule.PNt) !== "function" || typeof prewarm.VoiceInstantConnectCacheController !== "function")
16474
+ throw new Error();
16475
+ initialize();
16476
+ start.t();
16477
+ const initial = current ? {
16478
+ MOr: initialModule.CQn,
16479
+ CDr: initialModule.PXn,
16480
+ B1n: initialModule.tdn,
16481
+ SPn: initialModule.qXt,
16482
+ oT: primary?.um,
16483
+ aT: primary?.lm,
16484
+ Ycr: initialModule.Xkn,
16485
+ Nir: initialModule.yAn,
16486
+ n0n: initialModule.ydn,
16487
+ Y1n: initialModule.fdn,
16488
+ HJt: initialModule.R2
16489
+ } : initialModule;
16490
+ const shared = current ? { Qst: sharedModule.Bst, FBt: sharedModule.XVt, PNt: sharedModule.KNt, Vot: sharedModule.Fot } : sharedModule;
16491
+ const scope = (value, brand) => value !== null && typeof value === "object" && value.__scopeBrand === brand;
16492
+ if (!scope(shared.Qst, "AppScope") || !scope(initial.MOr, "RouteScope") || !scope(initial.CDr, "ComposerScope") || !initial.B1n || !initial.aT)
16493
+ throw new Error();
16494
+ return { initial, shared, start, prewarm };
16412
16495
  }
16413
16496
 
16414
16497
  // ../desktop-control/dist/renderer-react-ownership.js
@@ -16632,27 +16715,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16632
16715
 
16633
16716
  // src/renderer-native-chat-voice.ts
16634
16717
  var HOOK_GLOBAL = "__codexhostNativeChatVoiceV1";
16635
- var NATIVE_CHAT_VOICE_VERSION = "26.1016.62342";
16636
- var NATIVE_CHAT_INITIAL_ASSET = "app-initial-dddef47d6ef6.js";
16637
- var NATIVE_CHAT_SHARED_ASSET = "app-shared-fc3316d48427.js";
16638
- var START_ASSET = "start-voice-7cbf0a39d53b.js";
16639
- var PREWARM_ASSET = "voice-prewarm-5d107129ac1c.js";
16640
- var NATIVE_CHAT_VOICE_ASSETS = [
16641
- {
16642
- version: NATIVE_CHAT_VOICE_VERSION,
16643
- initial: NATIVE_CHAT_INITIAL_ASSET,
16644
- shared: NATIVE_CHAT_SHARED_ASSET,
16645
- start: START_ASSET,
16646
- prewarm: PREWARM_ASSET
16647
- },
16648
- {
16649
- version: "26.1016.61520",
16650
- initial: "app-initial-c95ddb62696e.js",
16651
- shared: "app-shared-2eda13eb7044.js",
16652
- start: "start-voice-18b08f0acdd7.js",
16653
- prewarm: "voice-prewarm-94271e581c1b.js"
16654
- }
16655
- ];
16656
16718
  var BUTTON = "data-codexhost-chat-voice-start";
16657
16719
  var CONVERSATION_UUID = /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i;
16658
16720
  var record2 = (value) => value !== null && typeof value === "object";
@@ -16879,19 +16941,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16879
16941
  }
16880
16942
  return;
16881
16943
  }
16882
- const [shared, initial, start, prewarm] = await Promise.all(
16883
- [assets.shared, assets.initial, assets.start, assets.prewarm].map(
16884
- (asset) => importModule(`app://-/assets/${asset}`)
16885
- )
16886
- );
16944
+ const loaded = await loadNativeChatVoiceModules(assets, importModule);
16887
16945
  if (disposed) return;
16888
- if (!shared || !initial || !start || !prewarm || typeof start.t !== "function" || typeof start.n !== "function" || typeof initial.oT !== "function" || typeof initial.SPn !== "function" || typeof shared.FBt !== "function" || typeof shared.PNt !== "function" || typeof prewarm.VoiceInstantConnectCacheController !== "function")
16889
- throw new Error();
16890
- initial.oT();
16891
- start.t();
16892
- if (!record2(shared.Qst) || !record2(initial.MOr) || !initial.B1n || !initial.aT || !record2(initial.CDr))
16893
- throw new Error();
16894
- modules = { shared, initial, start, prewarm };
16946
+ modules = loaded;
16895
16947
  }
16896
16948
  const current = findBinding();
16897
16949
  selectDraft?.();
@@ -17361,28 +17413,54 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17361
17413
  }
17362
17414
 
17363
17415
  // src/renderer-client-owned-voice.ts
17364
- var CLIENT_OWNED_VOICE_VERSION = "26.1016.62342";
17365
- var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-dddef47d6ef6.js";
17366
- var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-fc3316d48427.js";
17367
- var CLIENT_OWNED_VOICE_SERVICES = "ist";
17368
- var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-ef8332c6a2fb.js";
17416
+ var CLIENT_OWNED_VOICE_VERSION = "26.1021.31345";
17417
+ var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-feb30b196d11.js";
17418
+ var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-2cae01273bae.js";
17419
+ var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-d549db3706f1.js";
17369
17420
  var CLIENT_OWNED_VOICE_ASSETS = [
17370
17421
  {
17371
17422
  version: CLIENT_OWNED_VOICE_VERSION,
17372
17423
  initial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
17373
17424
  shared: CLIENT_OWNED_VOICE_SHARED_ASSET,
17374
- overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET
17425
+ overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
17426
+ fetch: "Htr",
17427
+ fetchFrom: "initial",
17428
+ bridge: "bIt",
17429
+ services: "Qot",
17430
+ capabilityInit: "l0n",
17431
+ capabilityFamily: "c0n",
17432
+ inferenceGateFamily: "Cnr"
17433
+ },
17434
+ {
17435
+ version: "26.1016.62342",
17436
+ initial: "app-initial-dddef47d6ef6.js",
17437
+ shared: "app-shared-fc3316d48427.js",
17438
+ overlay: "avatar-overlay-native-page-ef8332c6a2fb.js",
17439
+ init: "Oit",
17440
+ fetch: "Eit",
17441
+ bridge: "AFt",
17442
+ responseError: "Mit",
17443
+ services: "ist",
17444
+ capabilityInit: "njr",
17445
+ capabilityFamily: "tjr",
17446
+ inferenceGateFamily: "uBr"
17375
17447
  },
17376
17448
  {
17377
17449
  version: "26.1016.61520",
17378
17450
  initial: "app-initial-c95ddb62696e.js",
17379
17451
  shared: "app-shared-2eda13eb7044.js",
17380
- overlay: "avatar-overlay-native-page-fcc17283519a.js"
17452
+ overlay: "avatar-overlay-native-page-fcc17283519a.js",
17453
+ init: "Oit",
17454
+ fetch: "Eit",
17455
+ bridge: "AFt",
17456
+ responseError: "Mit",
17457
+ services: "ist",
17458
+ capabilityInit: "njr",
17459
+ capabilityFamily: "tjr",
17460
+ inferenceGateFamily: "uBr"
17381
17461
  }
17382
17462
  ];
17383
17463
  var SHARED_INIT = "Oit";
17384
- var SHARED_FETCH = "Eit";
17385
- var SHARED_BRIDGE = "AFt";
17386
17464
  var SHARED_RESPONSE_ERROR = "Mit";
17387
17465
  var HOOK_GLOBAL2 = "__codexhostClientOwnedVoiceV1";
17388
17466
  function object2(value) {
@@ -17439,11 +17517,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17439
17517
  function visibleWorkComposer(owner) {
17440
17518
  const document2 = owner.document;
17441
17519
  if (!document2?.querySelectorAll) return false;
17442
- const work = [...document2.querySelectorAll("[data-codex-composer-root]")].some((element) => {
17520
+ const visible = (element) => {
17443
17521
  const box = element.getBoundingClientRect?.() ?? { width: 0 };
17444
17522
  return box.width > 0 && !element.closest?.("[hidden], [inert]");
17445
- });
17446
- return work && document2.querySelectorAll("[data-chatgpt-composer]").length === 0;
17523
+ };
17524
+ return [...document2.querySelectorAll("[data-codex-composer-root]")].some(visible) && ![...document2.querySelectorAll("[data-chatgpt-composer]")].some(visible);
17447
17525
  }
17448
17526
  function selectedWorkTab(owner) {
17449
17527
  const document2 = owner.document;
@@ -17493,7 +17571,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17493
17571
  var lastVoiceProductExperience;
17494
17572
  function rememberVoiceProductExperience(request) {
17495
17573
  const experience = object2(request) ? request.productExperience : void 0;
17496
- lastVoiceProductExperience = experience === "chat" || experience === "work" ? experience : void 0;
17574
+ lastVoiceProductExperience = experience === "chat" || experience === "work" || experience === "codex" ? experience : void 0;
17497
17575
  }
17498
17576
  function lastVoiceLaunchProductExperience() {
17499
17577
  return lastVoiceProductExperience;
@@ -17519,7 +17597,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17519
17597
  const experience = lastVoiceLaunchProductExperience();
17520
17598
  const chat = experience === "chat";
17521
17599
  const model2 = backendModelName(options.headers);
17522
- const work = !chat && (experience === "work" || isWorkBackendModel(model2) || workSurface());
17600
+ const work = !chat && (experience === "work" || experience === "codex" || isWorkBackendModel(model2) || workSurface());
17523
17601
  const external = !chat && (model2.startsWith("codexhost/") || externalHarness());
17524
17602
  const gateway = external || (work ? workOverride() : chatOverride());
17525
17603
  chatVoiceDebug("wham-create", {
@@ -17611,33 +17689,44 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17611
17689
  const assets = selectVoiceAssets(CLIENT_OWNED_VOICE_ASSETS, names, config2.desktopVersion);
17612
17690
  if (assets) {
17613
17691
  try {
17614
- const module = await importModule(`app://-/assets/${assets.shared}`);
17692
+ const sharedModule = await importModule(`app://-/assets/${assets.shared}`);
17693
+ const fetchFrom = "fetchFrom" in assets ? assets.fetchFrom : "shared";
17694
+ const fetchModule = fetchFrom === "initial" ? await importModule(`app://-/assets/${assets.initial}`) : sharedModule;
17615
17695
  if (disposed) return;
17616
- if (typeof module[SHARED_INIT] !== "function") throw new Error();
17617
- module[SHARED_INIT]();
17618
- const fetchClass = module[SHARED_FETCH];
17619
- const bridgeClass = module[SHARED_BRIDGE];
17696
+ const init = "init" in assets ? assets.init : SHARED_INIT;
17697
+ const fetchName = assets.fetch;
17698
+ const bridgeName = assets.bridge;
17699
+ const errorName = "responseError" in assets ? assets.responseError : SHARED_RESPONSE_ERROR;
17700
+ if (typeof init === "string" && typeof fetchModule[init] === "function") {
17701
+ fetchModule[init]();
17702
+ } else if (typeof init === "string" && typeof sharedModule[init] === "function") {
17703
+ sharedModule[init]();
17704
+ }
17705
+ const fetchClass = typeof fetchName === "string" ? fetchModule[fetchName] : void 0;
17706
+ const bridgeClass = typeof bridgeName === "string" ? sharedModule[bridgeName] : void 0;
17620
17707
  if (!object2(fetchClass) && typeof fetchClass !== "function") throw new Error();
17621
17708
  if (!object2(bridgeClass) && typeof bridgeClass !== "function") throw new Error();
17622
17709
  const client = Reflect.get(fetchClass, "getInstance").call(fetchClass);
17623
17710
  const bridge = Reflect.get(bridgeClass, "getInstance").call(bridgeClass);
17624
- if (typeof client?.fetch !== "function" || typeof bridge?.dispatchMessage !== "function" || typeof bridge?.subscribe !== "function" || typeof module[SHARED_RESPONSE_ERROR] !== "function")
17711
+ const responseError = typeof errorName === "string" && typeof sharedModule[errorName] === "function" ? sharedModule[errorName] : async (response) => {
17712
+ throw Object.assign(new Error(await response.text()), { status: response.status });
17713
+ };
17714
+ if (typeof client?.fetch !== "function" || typeof bridge?.dispatchMessage !== "function" || typeof bridge?.subscribe !== "function")
17625
17715
  throw new Error();
17626
17716
  restore = wrapClientOwnedVoiceFetch(
17627
17717
  client,
17628
17718
  bridge,
17629
17719
  () => cpaLiveVoicePreferenceAllowsInstall(target),
17630
- module[SHARED_RESPONSE_ERROR],
17720
+ responseError,
17631
17721
  () => chatLiveVoicePreferenceAllowsOverride(target),
17632
17722
  () => isWorkComposerSurface(target),
17633
17723
  () => isExternalHarnessComposer(target)
17634
17724
  );
17635
17725
  handle.status = "active";
17636
17726
  } catch {
17637
- handle.status = "unsupported";
17638
17727
  }
17639
- return;
17640
17728
  }
17729
+ if (handle.status === "active") return;
17641
17730
  if (Date.now() - started >= 6e4) {
17642
17731
  handle.status = "unsupported";
17643
17732
  return;
@@ -17767,10 +17856,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17767
17856
  if (signal?.aborted) return Promise.reject(new DOMException("Aborted", "AbortError"));
17768
17857
  return new Promise((resolve, reject) => {
17769
17858
  const requestId2 = ownerWindow.crypto.randomUUID();
17770
- let settled = false;
17859
+ let settled2 = false;
17771
17860
  const finish = (error51, value) => {
17772
- if (settled) return;
17773
- settled = true;
17861
+ if (settled2) return;
17862
+ settled2 = true;
17774
17863
  ownerWindow.clearTimeout(timer);
17775
17864
  ownerWindow.removeEventListener("message", receive);
17776
17865
  signal?.removeEventListener("abort", abort);
@@ -17803,7 +17892,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17803
17892
  signal?.addEventListener("abort", abort, { once: true });
17804
17893
  void (async () => {
17805
17894
  const native = await services();
17806
- if (settled) return;
17895
+ if (settled2) return;
17807
17896
  if (native) {
17808
17897
  let result;
17809
17898
  switch (operation) {
@@ -19454,23 +19543,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19454
19543
 
19455
19544
  // src/settings/connections-page.ts
19456
19545
  var CODEXHOST_GITHUB_ISSUES_NEW_URL = "https://github.com/karlorz/codex-host/issues/new";
19457
- function connectionStatusLabel(availability, messages, hasError = false) {
19458
- if (availability === "updating") return messages.connectionStatusUpdating;
19459
- if (hasError && availability !== "notInstalled") return messages.connectionStatusError;
19460
- if (availability === "ready") return messages.connectionStatusReady;
19461
- if (availability === "checking") return messages.connectionStatusChecking;
19462
- if (availability === "notInstalled") return messages.connectionStatusNotInstalled;
19463
- if (availability === "unavailable" || availability === "error") {
19464
- return availability === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
19465
- }
19466
- return availability === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
19467
- }
19468
- function connectionStatusTone(availability, hasError = false) {
19469
- if (availability === "updating") return "checking";
19470
- if (hasError && availability !== "notInstalled") return "failed";
19471
- if (availability === "ready") return "ready";
19472
- if (availability === "checking" || availability === "installing") return "checking";
19473
- if (availability === "notInstalled") return "setup";
19546
+ function connectionStatusLabel(availability2, messages, hasError = false) {
19547
+ if (availability2 === "updating") return messages.connectionStatusUpdating;
19548
+ if (hasError && availability2 !== "notInstalled") return messages.connectionStatusError;
19549
+ if (availability2 === "ready") return messages.connectionStatusReady;
19550
+ if (availability2 === "checking") return messages.connectionStatusChecking;
19551
+ if (availability2 === "notInstalled") return messages.connectionStatusNotInstalled;
19552
+ if (availability2 === "unavailable" || availability2 === "error") {
19553
+ return availability2 === "error" ? messages.connectionStatusError : messages.connectionStatusUnavailable;
19554
+ }
19555
+ return availability2 === "installing" ? messages.connectionStatusInstalling : messages.connectionStatusUnsupported;
19556
+ }
19557
+ function connectionStatusTone(availability2, hasError = false) {
19558
+ if (availability2 === "updating") return "checking";
19559
+ if (hasError && availability2 !== "notInstalled") return "failed";
19560
+ if (availability2 === "ready") return "ready";
19561
+ if (availability2 === "checking" || availability2 === "installing") return "checking";
19562
+ if (availability2 === "notInstalled") return "setup";
19474
19563
  return "failed";
19475
19564
  }
19476
19565
  function diagnosticText(hostId2, item) {
@@ -20145,8 +20234,8 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
20145
20234
  const agent = item.agentSnapshot?.agent;
20146
20235
  if (!agent) return item;
20147
20236
  const state = installs?.get(selectedHost.hostId, agent);
20148
- const availability = state?.status ?? item.availability;
20149
- const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability !== "installing" && availability !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
20237
+ const availability2 = state?.status ?? item.availability;
20238
+ const version2 = item.agentSnapshot?.availability !== "notInstalled" && availability2 !== "installing" && availability2 !== "checking" ? versions.get(selectedHost.hostId, agent) : void 0;
20150
20239
  return {
20151
20240
  ...item,
20152
20241
  ...state ? { availability: state.status } : {},
@@ -21151,18 +21240,18 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21151
21240
  const account = state.agent === "codex" && activeAccount ? ` \xB7 ${activeAccount.email ?? activeAccount.label}` : "";
21152
21241
  return `Agent: ${rendererAgentLabel(state.agent, plugin)}${account}${state.phase === "locked" ? " (locked)" : ""}`;
21153
21242
  }
21154
- function rendererAgentPickerView(state, adapterState, switching, agents, availability = {}, plugin) {
21243
+ function rendererAgentPickerView(state, adapterState, switching, agents, availability2 = {}, plugin) {
21155
21244
  const optionDisabled = Object.fromEntries(
21156
21245
  agents.map((agent) => [
21157
21246
  agent,
21158
- switching || state.phase === "locked" || agent !== "codex" && (adapterState !== "ready" || availability[agent] !== "ready")
21247
+ switching || state.phase === "locked" || agent !== "codex" && (adapterState !== "ready" || availability2[agent] !== "ready")
21159
21248
  ])
21160
21249
  );
21161
21250
  const downloadVisible = Object.fromEntries(
21162
- agents.filter((agent) => agent !== "codex").map((agent) => [agent, availability[agent] === "notInstalled"])
21251
+ agents.filter((agent) => agent !== "codex").map((agent) => [agent, availability2[agent] === "notInstalled"])
21163
21252
  );
21164
21253
  const errorVisible = Object.fromEntries(
21165
- agents.filter((agent) => agent !== "codex").map((agent) => [agent, availability[agent] === "error"])
21254
+ agents.filter((agent) => agent !== "codex").map((agent) => [agent, availability2[agent] === "error"])
21166
21255
  );
21167
21256
  return {
21168
21257
  label: rendererAgentLabel(state.agent, plugin),
@@ -21589,10 +21678,10 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21589
21678
  agents: [...enabledAgents],
21590
21679
  plugins,
21591
21680
  options,
21592
- updateAvailability(availability) {
21681
+ updateAvailability(availability2) {
21593
21682
  const next = new Set(
21594
21683
  enabledAgents.filter(
21595
- (agent) => agent !== "codex" && availability[agent] === "notInstalled"
21684
+ (agent) => agent !== "codex" && availability2[agent] === "notInstalled"
21596
21685
  )
21597
21686
  );
21598
21687
  if (next.size === notInstalled.size && [...next].every((agent) => notInstalled.has(agent))) {
@@ -21616,16 +21705,16 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
21616
21705
  };
21617
21706
  return control;
21618
21707
  }
21619
- function renderRendererAgentPicker(control, state, adapterState, switching, availability = {}, currentCodexAccount = null, ownershipError = false) {
21708
+ function renderRendererAgentPicker(control, state, adapterState, switching, availability2 = {}, currentCodexAccount = null, ownershipError = false) {
21620
21709
  const view = rendererAgentPickerView(
21621
21710
  state,
21622
21711
  adapterState,
21623
21712
  switching,
21624
21713
  control.agents,
21625
- availability,
21714
+ availability2,
21626
21715
  control.plugins.find(({ id }) => id === state.agent)
21627
21716
  );
21628
- control.updateAvailability(availability);
21717
+ control.updateAvailability(availability2);
21629
21718
  if (control.iconSlot.dataset.agent !== state.agent) {
21630
21719
  control.iconSlot.replaceChildren(
21631
21720
  createRendererAgentIcon(
@@ -22569,8 +22658,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
22569
22658
  const presentation = localizeHarnessPresentation(command, locale);
22570
22659
  return { ...presentation, description: presentation.description ?? presentation.label };
22571
22660
  }
22572
- function rendererPermissionModePresentation(mode, locale) {
22573
- return localizeHarnessPresentation(mode, locale);
22661
+ function rendererPermissionModePresentation(mode2, locale) {
22662
+ return localizeHarnessPresentation(mode2, locale);
22574
22663
  }
22575
22664
  function rendererLiveCommandsPendingNotice(locale, harnessLabel) {
22576
22665
  const harness2 = harnessLabel.replace(/\s*[((][^))]*[))]\s*$/u, "").trim() || harnessLabel;
@@ -23716,18 +23805,18 @@ Codex Fast mode prioritizes requests and may increase usage.`
23716
23805
  function rebuildOptions2(control, catalog, locale) {
23717
23806
  control.options.clear();
23718
23807
  control.menu.replaceChildren();
23719
- for (const mode of catalog.modes) {
23720
- const presentation = rendererPermissionModePresentation(mode, locale);
23808
+ for (const mode2 of catalog.modes) {
23809
+ const presentation = rendererPermissionModePresentation(mode2, locale);
23721
23810
  const button2 = document.createElement("button");
23722
23811
  button2.type = "button";
23723
- button2.dataset.permissionModeId = mode.id;
23812
+ button2.dataset.permissionModeId = mode2.id;
23724
23813
  button2.setAttribute("role", "menuitemradio");
23725
23814
  button2.className = OPTION_CLASSES2;
23726
23815
  button2.style.letterSpacing = "0";
23727
- if (mode.dangerous) button2.style.color = "var(--color-text-danger, #c2413b)";
23816
+ if (mode2.dangerous) button2.style.color = "var(--color-text-danger, #c2413b)";
23728
23817
  const modeIcon = document.createElement("span");
23729
23818
  modeIcon.className = "inline-flex h-5 w-5 shrink-0 items-center justify-center";
23730
- modeIcon.append(icon(mode.dangerous ? ShieldAlert : Shield, 17));
23819
+ modeIcon.append(icon(mode2.dangerous ? ShieldAlert : Shield, 17));
23731
23820
  const copy = document.createElement("span");
23732
23821
  copy.className = "min-w-0 flex-1";
23733
23822
  const title = document.createElement("span");
@@ -23748,7 +23837,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
23748
23837
  check2.classList.add("mt-0.5", "shrink-0");
23749
23838
  check2.style.visibility = "hidden";
23750
23839
  button2.append(modeIcon, copy, check2);
23751
- control.options.set(mode.id, { button: button2, check: check2, mode });
23840
+ control.options.set(mode2.id, { button: button2, check: check2, mode: mode2 });
23752
23841
  control.menu.append(button2);
23753
23842
  }
23754
23843
  }
@@ -24870,7 +24959,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
24870
24959
  const props = key ? Object.getOwnPropertyDescriptor(button2, key)?.value : void 0;
24871
24960
  return typeof props === "object" && props !== null && "disabled" in props && typeof props.disabled === "boolean" ? props.disabled : fallback;
24872
24961
  }
24873
- function renderComposerAgentControl(control, state, adapterState, switching, availability = {}, modelView = { status: "idle" }, permissionModeView = { status: "idle" }, usage = null, accountCredits = null, locale = "en", currentCodexAccount = null, ownershipError = false) {
24962
+ function renderComposerAgentControl(control, state, adapterState, switching, availability2 = {}, modelView = { status: "idle" }, permissionModeView = { status: "idle" }, usage = null, accountCredits = null, locale = "en", currentCodexAccount = null, ownershipError = false) {
24874
24963
  if (control.usage === null) {
24875
24964
  control.usage = mountRendererUsageControl(control.composerId, locale);
24876
24965
  }
@@ -24897,7 +24986,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
24897
24986
  state,
24898
24987
  adapterState,
24899
24988
  switching,
24900
- availability,
24989
+ availability2,
24901
24990
  currentCodexAccount,
24902
24991
  ownershipError
24903
24992
  );
@@ -25999,6 +26088,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
25999
26088
  if (!isRecord8(target) || typeof target.getTurnCoordinator !== "function" || typeof target.getConversation !== "function") {
26000
26089
  return null;
26001
26090
  }
26091
+ if (typeof target.getStreamRole === "function") return null;
26002
26092
  const coordinator = target.getTurnCoordinator();
26003
26093
  const queue = isRecord8(coordinator) ? coordinator.serverQueue : null;
26004
26094
  if (!isRecord8(queue) || typeof queue.isEnabled !== "function") return null;
@@ -26035,6 +26125,36 @@ Codex Fast mode prioritizes requests and may increase usage.`
26035
26125
  (key) => typeof value[key] === "function"
26036
26126
  );
26037
26127
  }
26128
+ function inputText(input) {
26129
+ if (!Array.isArray(input)) return "";
26130
+ return input.filter(
26131
+ (item) => isRecord9(item) && typeof item.text === "string"
26132
+ ).map((item) => item.text).join("\n");
26133
+ }
26134
+ function queuedFollowUpText(message2) {
26135
+ if (!isRecord9(message2)) return "";
26136
+ if (typeof message2.text === "string" && message2.text.trim()) return message2.text;
26137
+ const context = message2.context;
26138
+ if (isRecord9(context) && typeof context.prompt === "string" && context.prompt.trim()) {
26139
+ return context.prompt;
26140
+ }
26141
+ return "";
26142
+ }
26143
+ function restoreQueuedTurnStartText(manager, params) {
26144
+ if (!isManager(manager) || !isRecord9(params) || typeof params.threadId !== "string")
26145
+ return params;
26146
+ if (inputText(params.input).trim()) return params;
26147
+ const messageId = params.clientUserMessageId;
26148
+ if (typeof messageId !== "string" || !messageId) return params;
26149
+ const coordinator = manager.getTurnCoordinator();
26150
+ if (!isRecord9(coordinator) || typeof coordinator.readMessages !== "function") return params;
26151
+ const messages = coordinator.readMessages.call(coordinator, params.threadId);
26152
+ if (!Array.isArray(messages)) return params;
26153
+ const match = messages.find((message2) => isRecord9(message2) && message2.id === messageId);
26154
+ const text = queuedFollowUpText(match);
26155
+ if (!text) return params;
26156
+ return { ...params, input: [{ type: "text", text, text_elements: [] }] };
26157
+ }
26038
26158
  function submissionHost(manager) {
26039
26159
  const coordinator = manager.getTurnCoordinator();
26040
26160
  const options = isRecord9(coordinator) ? coordinator.options : null;
@@ -26050,7 +26170,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
26050
26170
  function installSteeringMethods(manager, replacements) {
26051
26171
  const originalPrototype = Object.getPrototypeOf(manager);
26052
26172
  const overrides = Object.create(originalPrototype);
26053
- const names = ["sendRequest", "steerTurn"];
26173
+ const names = Object.keys(replacements).filter(
26174
+ (name) => typeof replacements[name] === "function"
26175
+ );
26054
26176
  const descriptors = new Map(
26055
26177
  names.map((name) => [name, Object.getOwnPropertyDescriptor(manager, name)])
26056
26178
  );
@@ -26116,6 +26238,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
26116
26238
  if ((method === "turn/start" || method === "turn/steer") && prepareTurnInput) {
26117
26239
  params = prepareTurnInput(params);
26118
26240
  }
26241
+ if (method === "turn/start") params = restoreQueuedTurnStartText(manager, params);
26119
26242
  const messageId = isRecord9(params) ? params.clientUserMessageId : null;
26120
26243
  const route = typeof messageId === "string" && isRecord9(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
26121
26244
  if (method !== "turn/start" || !isRecord9(params) || !route || route.threadId !== params.threadId) {
@@ -26215,7 +26338,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
26215
26338
  expectedTurnId = host.getActiveTurnId(threadId);
26216
26339
  } catch {
26217
26340
  }
26218
- const text = Array.isArray(input) ? input.filter((item) => isRecord9(item) && typeof item.text === "string").map((item) => item.text).join("\n") : void 0;
26341
+ const text = Array.isArray(input) ? inputText(input) : void 0;
26219
26342
  const delivery = await inspectDelivery(threadId, text);
26220
26343
  if (disposed) throw new Error("External steering binding was disposed");
26221
26344
  if (delivery === "official") return originalSteer.apply(manager, args);
@@ -26303,10 +26426,26 @@ Codex Fast mode prioritizes requests and may increase usage.`
26303
26426
  pending.set(threadId, { messageId, fingerprint, promise: promise2 });
26304
26427
  return promise2;
26305
26428
  };
26306
- const restoreMethod = installSteeringMethods(manager, { sendRequest: send, steerTurn: steer });
26429
+ const originalRole = manager.getStreamRole;
26430
+ const getStreamRole = typeof originalRole === "function" ? (...args) => {
26431
+ const threadId = args[0];
26432
+ if (typeof threadId === "string" && typeof manager.getConversation === "function") {
26433
+ const conversation = manager.getConversation(threadId);
26434
+ if (isRecord9(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost") {
26435
+ return { role: "owner" };
26436
+ }
26437
+ }
26438
+ return originalRole.apply(manager, args);
26439
+ } : void 0;
26440
+ const restoreMethod = installSteeringMethods(manager, {
26441
+ sendRequest: send,
26442
+ steerTurn: steer,
26443
+ ...getStreamRole ? { getStreamRole } : {}
26444
+ });
26307
26445
  return () => {
26308
26446
  disposed = true;
26309
26447
  restoreMethod("steerTurn");
26448
+ if (getStreamRole) restoreMethod("getStreamRole");
26310
26449
  if (pending.size === 0) {
26311
26450
  restoreMethod("sendRequest");
26312
26451
  } else {
@@ -27178,15 +27317,15 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
27178
27317
  return Promise.resolve();
27179
27318
  }
27180
27319
  return new Promise((resolve, reject) => {
27181
- let settled = false;
27320
+ let settled2 = false;
27182
27321
  const cleanup = () => {
27183
27322
  window.clearTimeout(timeout);
27184
27323
  observer.disconnect();
27185
27324
  options.signal?.removeEventListener("abort", onAbort);
27186
27325
  };
27187
27326
  const finish = (row2) => {
27188
- if (settled) return;
27189
- settled = true;
27327
+ if (settled2) return;
27328
+ settled2 = true;
27190
27329
  cleanup();
27191
27330
  row2.click();
27192
27331
  resolve();
@@ -27196,14 +27335,14 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
27196
27335
  if (row2) finish(row2);
27197
27336
  });
27198
27337
  const timeout = window.setTimeout(() => {
27199
- if (settled) return;
27200
- settled = true;
27338
+ if (settled2) return;
27339
+ settled2 = true;
27201
27340
  cleanup();
27202
27341
  reject(new Error("Thread did not appear in the sidebar"));
27203
27342
  }, options.timeoutMs ?? OPEN_THREAD_TIMEOUT_MS);
27204
27343
  const onAbort = () => {
27205
- if (settled) return;
27206
- settled = true;
27344
+ if (settled2) return;
27345
+ settled2 = true;
27207
27346
  cleanup();
27208
27347
  reject(abortError());
27209
27348
  };
@@ -27985,15 +28124,15 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
27985
28124
  if (signal?.aborted) return Promise.reject(abortError2());
27986
28125
  const requestId2 = ownerWindow.crypto.randomUUID();
27987
28126
  return new Promise((resolve, reject) => {
27988
- let settled = false;
28127
+ let settled2 = false;
27989
28128
  const cleanup = () => {
27990
28129
  ownerWindow.clearTimeout(timer);
27991
28130
  ownerWindow.removeEventListener("message", onMessage);
27992
28131
  signal?.removeEventListener("abort", onAbort);
27993
28132
  };
27994
28133
  const settle = (operation) => {
27995
- if (settled) return;
27996
- settled = true;
28134
+ if (settled2) return;
28135
+ settled2 = true;
27997
28136
  cleanup();
27998
28137
  operation();
27999
28138
  };
@@ -28030,7 +28169,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
28030
28169
  void (async () => {
28031
28170
  if (request.kind === "locale-info") {
28032
28171
  const native = await loadCodexNativeServices(ownerWindow, isNativeLocaleServices);
28033
- if (settled) return;
28172
+ if (settled2) return;
28034
28173
  if (native) {
28035
28174
  const response = await native.appInfo.getLocaleInfo();
28036
28175
  settle(() => resolve(response));
@@ -28106,14 +28245,15 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
28106
28245
  source
28107
28246
  });
28108
28247
  }
28248
+ const documentLocale = canonicalLocale(ownerWindow.document?.documentElement?.lang);
28109
28249
  return Object.freeze({
28110
28250
  status: "fallback",
28111
28251
  mode: "unavailable",
28112
28252
  localeOverride: void 0,
28113
28253
  ideLocale: localeInfo.ideLocale,
28114
28254
  systemLocale: localeInfo.systemLocale,
28115
- preferredLocale: navigatorLocale ?? "en-US",
28116
- source: navigatorLocale ? "navigator" : "default"
28255
+ preferredLocale: documentLocale ?? navigatorLocale ?? "en-US",
28256
+ source: documentLocale ? "document" : navigatorLocale ? "navigator" : "default"
28117
28257
  });
28118
28258
  }
28119
28259
 
@@ -33130,7 +33270,7 @@ ${detail}` : ""}`
33130
33270
  void context.runLatest(
33131
33271
  async (signal) => {
33132
33272
  const missing = new Set(
33133
- getDiagnostics()?.snapshot().hosts.find(({ hostId: hostId2 }) => hostId2 === "local")?.agents.filter(({ availability }) => availability === "notInstalled").map(({ agent }) => agent)
33273
+ getDiagnostics()?.snapshot().hosts.find(({ hostId: hostId2 }) => hostId2 === "local")?.agents.filter(({ availability: availability2 }) => availability2 === "notInstalled").map(({ agent }) => agent)
33134
33274
  );
33135
33275
  const harnesses = (await client.listSessionImportSources()).harnesses.filter(
33136
33276
  ({ harnessId }) => !missing.has(harnessId)
@@ -33688,7 +33828,7 @@ ${detail}` : ""}`
33688
33828
  }
33689
33829
  function defaultImportName(source, existing) {
33690
33830
  const base = source.provider === "openai-codex" ? "codex" : "grok";
33691
- const used = new Set(existing.map((record8) => record8.name));
33831
+ const used = new Set(existing.map((record11) => record11.name));
33692
33832
  const valid = (name) => credentialImportNameSchema.safeParse(name).success;
33693
33833
  if (!used.has(base)) return base;
33694
33834
  const local = source.label.includes("@") ? source.label.split("@")[0] ?? "" : "";
@@ -33711,7 +33851,7 @@ ${detail}` : ""}`
33711
33851
  const shown = (text) => accountDisplayText(text, hideEmails);
33712
33852
  const targetButtons = /* @__PURE__ */ new Map();
33713
33853
  const importedRecords = () => snapshot.targets.find((target) => target.harnessId === TARGET_HARNESS_ID)?.imports ?? [];
33714
- const sourceOf = (record8) => snapshot.sources.find((source) => source.id === record8.source.id);
33854
+ const sourceOf = (record11) => snapshot.sources.find((source) => source.id === record11.source.id);
33715
33855
  const piTarget = () => snapshot.targets.find((candidate) => candidate.harnessId === TARGET_HARNESS_ID);
33716
33856
  const compatibleSources = () => {
33717
33857
  const target = piTarget();
@@ -33749,7 +33889,7 @@ ${detail}` : ""}`
33749
33889
  sectionImport.addEventListener("click", () => {
33750
33890
  const sources = compatibleSources();
33751
33891
  const free = sources.find(
33752
- (source2) => !importedRecords().some((record8) => record8.source.id === source2.id)
33892
+ (source2) => !importedRecords().some((record11) => record11.source.id === source2.id)
33753
33893
  );
33754
33894
  const source = free ?? sources[0];
33755
33895
  if (source) openDialog("add", { source, choose: true }, SECTION_IMPORT_KEY);
@@ -33799,30 +33939,30 @@ ${detail}` : ""}`
33799
33939
  mark.append(createRendererAgentIcon(agent ?? "pi", 26, document2, pluginFor(agent ?? "pi")));
33800
33940
  return mark;
33801
33941
  };
33802
- const renderRow = (record8) => {
33942
+ const renderRow = (record11) => {
33803
33943
  const row = document2.createElement("div");
33804
33944
  row.className = "settings-pi-accounts__row";
33805
33945
  row.tabIndex = -1;
33806
- row.dataset.importName = record8.name;
33807
- row.setAttribute("aria-label", shown(record8.source.label));
33808
- const agent = record8.source.harnessId;
33946
+ row.dataset.importName = record11.name;
33947
+ row.setAttribute("aria-label", shown(record11.source.label));
33948
+ const agent = record11.source.harnessId;
33809
33949
  const mark = createMark(agent);
33810
33950
  const identity = document2.createElement("div");
33811
33951
  identity.className = "settings-pi-accounts__identity";
33812
33952
  const label = document2.createElement("strong");
33813
33953
  label.className = "settings-account-email";
33814
- label.textContent = shown(record8.source.label);
33954
+ label.textContent = shown(record11.source.label);
33815
33955
  label.title = label.textContent;
33816
33956
  label.translate = false;
33817
33957
  const meta3 = document2.createElement("div");
33818
33958
  meta3.className = "settings-account-metadata";
33819
- const source = sourceOf(record8);
33959
+ const source = sourceOf(record11);
33820
33960
  const parts = [
33821
33961
  metaPart(rendererAgentLabel(agent, pluginFor(agent)), "settings-pi-accounts__agent"),
33822
- metaPart(`${record8.name}/\u2026`, void 0, true),
33962
+ metaPart(`${record11.name}/\u2026`, void 0, true),
33823
33963
  metaPart(messages.copied)
33824
33964
  ];
33825
- const time3 = formatImportedAt(record8.importedAt);
33965
+ const time3 = formatImportedAt(record11.importedAt);
33826
33966
  if (time3) parts.push(metaPart(time3));
33827
33967
  parts.forEach((part, index) => {
33828
33968
  if (index > 0) {
@@ -33839,23 +33979,23 @@ ${detail}` : ""}`
33839
33979
  reimport.type = "button";
33840
33980
  reimport.className = "settings-account-action";
33841
33981
  reimport.textContent = messages.rowReimport;
33842
- reimport.setAttribute("aria-label", `${messages.reimport}: ${shown(record8.source.label)}`);
33982
+ reimport.setAttribute("aria-label", `${messages.reimport}: ${shown(record11.source.label)}`);
33843
33983
  reimport.disabled = busy || !source;
33844
33984
  reimport.title = messages.reimport;
33845
33985
  reimport.addEventListener("click", () => {
33846
- if (source) openDialog("reimport", { source, record: record8 }, `row:${record8.name}`);
33986
+ if (source) openDialog("reimport", { source, record: record11 }, `row:${record11.name}`);
33847
33987
  });
33848
33988
  const remove = document2.createElement("button");
33849
33989
  remove.type = "button";
33850
33990
  remove.className = "settings-account-action settings-pi-accounts__remove";
33851
33991
  remove.textContent = messages.rowRemove;
33852
- remove.setAttribute("aria-label", `${messages.remove}: ${shown(record8.source.label)}`);
33992
+ remove.setAttribute("aria-label", `${messages.remove}: ${shown(record11.source.label)}`);
33853
33993
  remove.disabled = busy;
33854
- remove.addEventListener("click", () => openDialog("remove", { record: record8 }, `row:${record8.name}`));
33994
+ remove.addEventListener("click", () => openDialog("remove", { record: record11 }, `row:${record11.name}`));
33855
33995
  if (source) actions.append(reimport);
33856
33996
  actions.append(remove);
33857
33997
  row.append(mark, identity, actions);
33858
- rows.set(record8.name, row);
33998
+ rows.set(record11.name, row);
33859
33999
  return row;
33860
34000
  };
33861
34001
  const loginTypeLabel = (type) => type === "oauth" ? messages.typeOauth : type === "api_key" ? messages.typeApiKey : messages.typeOther;
@@ -33961,7 +34101,7 @@ ${detail}` : ""}`
33961
34101
  controls.className = "settings-credential-dialog__actions";
33962
34102
  modal.append(title, body, error51, controls);
33963
34103
  let state = initial;
33964
- let mode = initialMode;
34104
+ let mode2 = initialMode;
33965
34105
  let nameInput;
33966
34106
  let nameEdited = false;
33967
34107
  let sourceRadios = [];
@@ -34008,7 +34148,7 @@ ${detail}` : ""}`
34008
34148
  const label = document2.createElement("strong");
34009
34149
  label.textContent = shown(choice.label);
34010
34150
  label.translate = false;
34011
- const existing = importedRecords().find((record8) => record8.source.id === choice.id);
34151
+ const existing = importedRecords().find((record11) => record11.source.id === choice.id);
34012
34152
  const agent = choice.harnessId;
34013
34153
  const detail = document2.createElement("span");
34014
34154
  detail.textContent = [
@@ -34049,7 +34189,7 @@ ${detail}` : ""}`
34049
34189
  const name = request.action === "list" ? void 0 : request.name;
34050
34190
  state = {
34051
34191
  source: state.source,
34052
- record: importedRecords().find((record8) => record8.name === name) ?? state.record
34192
+ record: importedRecords().find((record11) => record11.name === name) ?? state.record
34053
34193
  };
34054
34194
  show(next);
34055
34195
  } else {
@@ -34057,19 +34197,19 @@ ${detail}` : ""}`
34057
34197
  }
34058
34198
  };
34059
34199
  const show = (next) => {
34060
- mode = next;
34200
+ mode2 = next;
34061
34201
  error51.textContent = "";
34062
34202
  nameInput = void 0;
34063
34203
  sourceRadios = [];
34064
34204
  body.replaceChildren();
34065
34205
  controls.replaceChildren();
34066
- const { source, record: record8 } = state;
34206
+ const { source, record: record11 } = state;
34067
34207
  const close = () => modal.close();
34068
- if (mode === "add" || mode === "reimport") {
34069
- title.textContent = mode === "add" ? messages.add : messages.reimport;
34208
+ if (mode2 === "add" || mode2 === "reimport") {
34209
+ title.textContent = mode2 === "add" ? messages.add : messages.reimport;
34070
34210
  modal.setAttribute("aria-label", title.textContent);
34071
- const active = source ?? record8?.source;
34072
- const choices = mode === "add" && state.choose ? compatibleSources() : [];
34211
+ const active = source ?? record11?.source;
34212
+ const choices = mode2 === "add" && state.choose ? compatibleSources() : [];
34073
34213
  if (choices.length > 1) body.append(sourcePicker(choices));
34074
34214
  else if (active) body.append(line(messages.source, shown(active.label)));
34075
34215
  const input = document2.createElement("input");
@@ -34077,8 +34217,8 @@ ${detail}` : ""}`
34077
34217
  input.maxLength = 48;
34078
34218
  input.autocomplete = "off";
34079
34219
  input.spellcheck = false;
34080
- input.value = record8?.name ?? (source ? defaultImportName(source, importedRecords()) : "codex");
34081
- input.readOnly = Boolean(record8);
34220
+ input.value = record11?.name ?? (source ? defaultImportName(source, importedRecords()) : "codex");
34221
+ input.readOnly = Boolean(record11);
34082
34222
  input.addEventListener("input", () => {
34083
34223
  nameEdited = true;
34084
34224
  });
@@ -34090,7 +34230,7 @@ ${detail}` : ""}`
34090
34230
  label.append(caption, input);
34091
34231
  const preview = note("");
34092
34232
  const update = () => {
34093
- preview.textContent = (mode === "reimport" ? messages.reimportPreview : messages.preview).replace("{name}", input.value);
34233
+ preview.textContent = (mode2 === "reimport" ? messages.reimportPreview : messages.preview).replace("{name}", input.value);
34094
34234
  };
34095
34235
  input.addEventListener("input", update);
34096
34236
  refreshPreview = update;
@@ -34110,9 +34250,9 @@ ${detail}` : ""}`
34110
34250
  }
34111
34251
  await submit(
34112
34252
  {
34113
- action: mode === "reimport" ? "reimport" : "import",
34253
+ action: mode2 === "reimport" ? "reimport" : "import",
34114
34254
  sourceId: source2.id,
34115
- name: record8?.name ?? input.value,
34255
+ name: record11?.name ?? input.value,
34116
34256
  confirmed: true
34117
34257
  },
34118
34258
  "done"
@@ -34121,17 +34261,17 @@ ${detail}` : ""}`
34121
34261
  "primary"
34122
34262
  )
34123
34263
  );
34124
- (mode === "add" ? input : controls.children[0]).focus();
34125
- } else if (mode === "remove" && record8) {
34264
+ (mode2 === "add" ? input : controls.children[0]).focus();
34265
+ } else if (mode2 === "remove" && record11) {
34126
34266
  title.textContent = messages.remove;
34127
34267
  modal.setAttribute("aria-label", title.textContent);
34128
- body.append(note(messages.removeWarning.replace("{name}", record8.name)));
34268
+ body.append(note(messages.removeWarning.replace("{name}", record11.name)));
34129
34269
  const cancel = command(messages.cancel, close);
34130
34270
  controls.append(
34131
34271
  cancel,
34132
34272
  command(
34133
34273
  messages.remove,
34134
- () => submit({ action: "remove", name: record8.name, confirmed: true }, null),
34274
+ () => submit({ action: "remove", name: record11.name, confirmed: true }, null),
34135
34275
  "danger"
34136
34276
  )
34137
34277
  );
@@ -34139,7 +34279,7 @@ ${detail}` : ""}`
34139
34279
  } else {
34140
34280
  title.textContent = messages.doneTitle;
34141
34281
  modal.setAttribute("aria-label", title.textContent);
34142
- const name = record8?.name;
34282
+ const name = record11?.name;
34143
34283
  if (name) body.append(line(messages.entry, `${name}/\u2026`, true));
34144
34284
  body.append(note(messages.done));
34145
34285
  const done = command(messages.close, close, "primary");
@@ -34186,21 +34326,21 @@ ${detail}` : ""}`
34186
34326
  (candidate) => candidate.harnessId === TARGET_HARNESS_ID && source && candidate.providers.includes(source.provider)
34187
34327
  );
34188
34328
  if (!source || !target) return null;
34189
- const record8 = target.imports.find((candidate) => candidate.source.id === source.id);
34329
+ const record11 = target.imports.find((candidate) => candidate.source.id === source.id);
34190
34330
  const key = `${harnessId}:${accountLabel}:import`;
34191
34331
  const button2 = document2.createElement("button");
34192
34332
  button2.type = "button";
34193
34333
  button2.className = "settings-account-pi-import";
34194
34334
  button2.dataset.accountFocus = key;
34195
34335
  button2.disabled = busy;
34196
- const hint = record8 ? messages.importedHint.replace("{name}", record8.name) : messages.add;
34336
+ const hint = record11 ? messages.importedHint.replace("{name}", record11.name) : messages.add;
34197
34337
  button2.title = hint;
34198
34338
  button2.setAttribute("aria-label", hint);
34199
34339
  button2.append(createRendererAgentIcon("pi", 12, document2, pluginFor("pi")));
34200
- if (record8) {
34340
+ if (record11) {
34201
34341
  button2.dataset.state = "imported";
34202
34342
  const name = document2.createElement("code");
34203
- name.textContent = `${record8.name}/\u2026`;
34343
+ name.textContent = `${record11.name}/\u2026`;
34204
34344
  name.translate = false;
34205
34345
  button2.append(name, createRendererSettingsIcon("check", 12));
34206
34346
  } else {
@@ -34208,7 +34348,7 @@ ${detail}` : ""}`
34208
34348
  button2.append(messages.add);
34209
34349
  }
34210
34350
  button2.addEventListener("click", () => {
34211
- if (!record8) {
34351
+ if (!record11) {
34212
34352
  openDialog("add", { source }, key);
34213
34353
  return;
34214
34354
  }
@@ -34217,7 +34357,7 @@ ${detail}` : ""}`
34217
34357
  renderSection();
34218
34358
  sectionToggle.setAttribute("aria-expanded", "true");
34219
34359
  }
34220
- const row = rows.get(record8.name);
34360
+ const row = rows.get(record11.name);
34221
34361
  row?.scrollIntoView({ block: "nearest", behavior: "smooth" });
34222
34362
  row?.focus();
34223
34363
  });
@@ -35222,10 +35362,10 @@ ${detail}` : ""}`
35222
35362
  };
35223
35363
  function runBoundedRendererUpdateRequest(operation, signal, timeoutMs = RENDERER_UPDATE_REQUEST_TIMEOUT_MS) {
35224
35364
  return new Promise((resolve, reject) => {
35225
- let settled = false;
35365
+ let settled2 = false;
35226
35366
  const settle = (handler) => {
35227
- if (settled) return;
35228
- settled = true;
35367
+ if (settled2) return;
35368
+ settled2 = true;
35229
35369
  clearTimeout(timeout);
35230
35370
  signal.removeEventListener("abort", abort);
35231
35371
  handler();
@@ -40855,7 +40995,7 @@ th[aria-sort] .console-usage-sort__mark {
40855
40995
  place();
40856
40996
  const observer = ownerWindow ? new ownerWindow.MutationObserver((records) => {
40857
40997
  const titlebar = source?.closest("[data-app-shell-titlebar]");
40858
- if (!source?.isConnected || records.some((record8) => titlebar?.contains(record8.target))) {
40998
+ if (!source?.isConnected || records.some((record11) => titlebar?.contains(record11.target))) {
40859
40999
  place();
40860
41000
  }
40861
41001
  }) : null;
@@ -41260,7 +41400,10 @@ ${usage_default}`;
41260
41400
  var UPDATE_RETRY_DELAYS_MS = [1e3, 3e3, 1e4, 3e4];
41261
41401
  function installRendererSettingsLifecycle(ownerWindow = window, options = {}) {
41262
41402
  const lifecycleController = new AbortController();
41263
- let locale = resolveRendererSettingsLocale(ownerWindow.navigator.languages);
41403
+ const documentLanguage = ownerWindow.document?.documentElement?.lang;
41404
+ let locale = resolveRendererSettingsLocale(
41405
+ documentLanguage ? [documentLanguage] : ownerWindow.navigator.languages
41406
+ );
41264
41407
  let shell = null;
41265
41408
  let trigger = null;
41266
41409
  let localeRequest = null;
@@ -42027,17 +42170,17 @@ ${usage_default}`;
42027
42170
 
42028
42171
  // src/renderer-binding-probe.ts
42029
42172
  var EMPTY_PLUGINS = [];
42030
- function isRetryableHarnessAvailability(availability, error51) {
42031
- return availability !== void 0 && availability !== "ready" && availability !== "notInstalled" && error51?.retryable === true;
42173
+ function isRetryableHarnessAvailability(availability2, error51) {
42174
+ return availability2 !== void 0 && availability2 !== "ready" && availability2 !== "notInstalled" && error51?.retryable === true;
42032
42175
  }
42033
- function retryableHarnessAvailabilityAgents(availability, errors) {
42034
- return Object.keys(availability).filter(
42035
- (agent) => isRetryableHarnessAvailability(availability[agent], errors[agent])
42176
+ function retryableHarnessAvailabilityAgents(availability2, errors) {
42177
+ return Object.keys(availability2).filter(
42178
+ (agent) => isRetryableHarnessAvailability(availability2[agent], errors[agent])
42036
42179
  );
42037
42180
  }
42038
- function passiveHarnessAvailabilityAgents(availability, errors) {
42039
- return Object.keys(availability).filter(
42040
- (agent) => availability[agent] === "checking" || isRetryableHarnessAvailability(availability[agent], errors[agent])
42181
+ function passiveHarnessAvailabilityAgents(availability2, errors) {
42182
+ return Object.keys(availability2).filter(
42183
+ (agent) => availability2[agent] === "checking" || isRetryableHarnessAvailability(availability2[agent], errors[agent])
42041
42184
  );
42042
42185
  }
42043
42186
  function shouldRefreshCodexAccountsForAdapterState(state) {
@@ -42902,12 +43045,12 @@ ${usage_default}`;
42902
43045
  if (isDraft) mounted.hostId = requestHostId;
42903
43046
  const hostState = hostHarnessAvailabilityState(requestHostId);
42904
43047
  if (!hostState.plugins) void refreshHarnessAvailabilityForHost(requestHostId);
42905
- const availability = hostState.availability[agent] ?? (hostState.plugins ? "unavailable" : "checking");
42906
- if (availability !== "ready" && availability !== "checking") {
43048
+ const availability2 = hostState.availability[agent] ?? (hostState.plugins ? "unavailable" : "checking");
43049
+ if (availability2 !== "ready" && availability2 !== "checking") {
42907
43050
  mounted.modelView = {
42908
43051
  status: composerAdapterState(mounted) === "ready" ? "error" : "waitingForAdapter",
42909
43052
  thinkingSelectionSupported: false,
42910
- ...availability ? { error: `${agent} runtime is ${availability}` } : {}
43053
+ ...availability2 ? { error: `${agent} runtime is ${availability2}` } : {}
42911
43054
  };
42912
43055
  mounted.permissionModeView = { status: "idle" };
42913
43056
  renderMounted(mounted);
@@ -44317,8 +44460,8 @@ ${usage_default}`;
44317
44460
  readTargets: (editor) => {
44318
44461
  const composer = composerForElement(editor);
44319
44462
  const mounted = composer ? mountedByComposer.get(composer) : void 0;
44320
- const availability = mounted ? composerAvailability(mounted) : {};
44321
- return enabledAgents.filter((agent) => agent === "codex" || availability[agent] === "ready").map((agent) => {
44463
+ const availability2 = mounted ? composerAvailability(mounted) : {};
44464
+ return enabledAgents.filter((agent) => agent === "codex" || availability2[agent] === "ready").map((agent) => {
44322
44465
  const plugin = mounted?.hostId ? pluginForHost(mounted.hostId, agent) : void 0;
44323
44466
  return { agent, label: rendererAgentLabel(agent, plugin), ...plugin ? { plugin } : {} };
44324
44467
  });
@@ -44524,10 +44667,7 @@ ${usage_default}`;
44524
44667
  var HOOK_GLOBAL3 = "__codexhostExternalVoiceLaunchV1";
44525
44668
  var SHARED_ASSET = "app-shared-8bd9d0399038.js";
44526
44669
  var LAUNCH_ASSETS = [
44527
- ...CLIENT_OWNED_VOICE_ASSETS.map((profile) => ({
44528
- ...profile,
44529
- services: CLIENT_OWNED_VOICE_SERVICES
44530
- })),
44670
+ ...CLIENT_OWNED_VOICE_ASSETS,
44531
44671
  {
44532
44672
  version: AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION,
44533
44673
  initial: AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET,
@@ -44549,14 +44689,14 @@ ${usage_default}`;
44549
44689
  if (!route || route.hostId !== hostId2 || routing.forHost(hostId2) !== route) return request;
44550
44690
  const model2 = route.policy.selectedModel();
44551
44691
  if (!model2?.startsWith("codexhost/")) return request;
44552
- const mode = request.activeCollaborationMode;
44553
- if (mode !== void 0 && mode !== null && !isRecord16(mode)) return request;
44554
- const settings = isRecord16(mode) ? mode.settings : void 0;
44692
+ const mode2 = request.activeCollaborationMode;
44693
+ if (mode2 !== void 0 && mode2 !== null && !isRecord16(mode2)) return request;
44694
+ const settings = isRecord16(mode2) ? mode2.settings : void 0;
44555
44695
  if (settings !== void 0 && settings !== null && !isRecord16(settings)) return request;
44556
44696
  return {
44557
44697
  ...request,
44558
44698
  activeCollaborationMode: {
44559
- ...isRecord16(mode) ? mode : { mode: "default" },
44699
+ ...isRecord16(mode2) ? mode2 : { mode: "default" },
44560
44700
  settings: {
44561
44701
  reasoning_effort: null,
44562
44702
  developer_instructions: null,
@@ -44692,6 +44832,19 @@ ${usage_default}`;
44692
44832
  return null;
44693
44833
  }
44694
44834
  }
44835
+ function isFamily(value) {
44836
+ return record7(value) && record7(value.scope) && typeof value.resolve === "function";
44837
+ }
44838
+ function initializeVoiceCapabilityFamilies(module, assets) {
44839
+ const initialize = module[assets.capabilityInit];
44840
+ if (typeof initialize !== "function") throw new Error("Voice capability initializer unavailable");
44841
+ initialize();
44842
+ const family = module[assets.capabilityFamily];
44843
+ const gates = module[assets.inferenceGateFamily];
44844
+ if (!isFamily(family) || !isFamily(gates))
44845
+ throw new Error("Voice capability families unavailable");
44846
+ return { family, gates };
44847
+ }
44695
44848
  function hooks(fiber) {
44696
44849
  const result = [];
44697
44850
  const seen = /* @__PURE__ */ new Set();
@@ -44736,7 +44889,7 @@ ${usage_default}`;
44736
44889
  allowed
44737
44890
  );
44738
44891
  }
44739
- function bindVoiceCapabilitySubscriptions(currentFibers, family, gates, allowed, realtimeOnly = false) {
44892
+ function bindVoiceCapabilitySubscriptions(currentFibers, family, gates, allowed, realtimeOnly = false, names = ["voice.realtime", "voice.thread"]) {
44740
44893
  const fibers = currentFibers();
44741
44894
  const restores = [];
44742
44895
  const bindings = [];
@@ -44754,7 +44907,7 @@ ${usage_default}`;
44754
44907
  const matches = [...members].filter(([, member]) => member.cacheKey === deps[0]);
44755
44908
  if (matches.length !== 1 || typeof matches[0]?.[0] !== "string") continue;
44756
44909
  const parameter = JSON.parse(matches[0][0]);
44757
- if (!record7(parameter) || Object.keys(parameter).some((key) => key !== "name" && key !== "hostId") || parameter.name !== "voice.realtime" && parameter.name !== "voice.thread" || realtimeOnly && parameter.name !== "voice.realtime" || parameter.hostId !== void 0 && parameter.hostId !== "local" || parameter.name === "voice.thread" && parameter.hostId !== "local")
44910
+ if (!record7(parameter) || Object.keys(parameter).some((key) => key !== "name" && key !== "hostId") || !names.some((name) => parameter.name === name) || realtimeOnly && parameter.name !== "voice.realtime" || parameter.hostId !== void 0 && parameter.hostId !== "local" || parameter.name === "voice.thread" && parameter.hostId !== "local")
44758
44911
  continue;
44759
44912
  const subscriptions = list.filter((hook2) => {
44760
44913
  const state = hook2.memoizedState;
@@ -44828,11 +44981,20 @@ ${usage_default}`;
44828
44981
  },
44829
44982
  current() {
44830
44983
  const current = [...currentFibers()].flatMap(hooks);
44831
- return bindings.every(
44832
- ({ subscriber, signal, instance }) => current.some(
44833
- (hook) => Array.isArray(hook.memoizedState) && hook.memoizedState[0] === subscriber && hook.memoizedState[1]?.[0] === signal && hook.next?.queue === instance && (!realtimeOnly || capable(hook.next?.memoizedState) && hook.next.memoizedState.isCapable)
44834
- )
44835
- );
44984
+ return bindings.every(({ subscriber, signal, instance }) => {
44985
+ try {
44986
+ const snapshot = subscriber.getSnapshot();
44987
+ const instanceSnapshot = instance.getSnapshot();
44988
+ if (!capable(snapshot) || !capable(instanceSnapshot) || !equal(snapshot, instanceSnapshot))
44989
+ return false;
44990
+ return current.some((hook) => {
44991
+ const committed = hook.next?.memoizedState;
44992
+ return Array.isArray(hook.memoizedState) && hook.memoizedState[0] === subscriber && hook.memoizedState[1]?.[0] === signal && hook.next?.queue === instance && capable(committed) && equal(committed, snapshot) && (!realtimeOnly || snapshot.isCapable);
44993
+ });
44994
+ } catch {
44995
+ return false;
44996
+ }
44997
+ });
44836
44998
  }
44837
44999
  };
44838
45000
  }
@@ -44894,8 +45056,6 @@ ${usage_default}`;
44894
45056
  `app://-/assets/${assets.initial}`
44895
45057
  );
44896
45058
  if (disposed) return;
44897
- if (typeof module.njr !== "function")
44898
- throw new Error("Voice capability exports unavailable");
44899
45059
  const composers = [
44900
45060
  ...target.document?.querySelectorAll(
44901
45061
  chatGateway() ? "[data-chatgpt-composer]" : "[data-codex-composer-root]"
@@ -44905,14 +45065,14 @@ ${usage_default}`;
44905
45065
  );
44906
45066
  if (composers.length !== 1) throw new Error("Voice composer unavailable");
44907
45067
  if (composers[0] !== composer || !binding?.current()) {
44908
- module.njr();
44909
45068
  binding?.dispose();
44910
45069
  binding = void 0;
44911
45070
  composer = composers[0];
45071
+ const { family, gates } = initializeVoiceCapabilityFamilies(module, assets);
44912
45072
  binding = bindComposerVoiceCapability(
44913
45073
  composer,
44914
- module.tjr,
44915
- module.uBr,
45074
+ family,
45075
+ gates,
44916
45076
  allowed,
44917
45077
  chatGateway()
44918
45078
  );
@@ -44933,12 +45093,515 @@ ${usage_default}`;
44933
45093
  return handle;
44934
45094
  }
44935
45095
 
45096
+ // src/renderer-voice-settings-availability.ts
45097
+ var record8 = (value) => value !== null && typeof value === "object";
45098
+ function voiceSettingsSurface(doc, page, appScope) {
45099
+ const pages = /* @__PURE__ */ new Set();
45100
+ const fibers = /* @__PURE__ */ new Set();
45101
+ const elements = /* @__PURE__ */ new Set();
45102
+ for (const section of doc.querySelectorAll("section")) {
45103
+ elements.add(section);
45104
+ for (const control of section.querySelectorAll?.("button,input") ?? []) elements.add(control);
45105
+ }
45106
+ for (const element of [...elements].slice(0, 512)) {
45107
+ const key = Object.getOwnPropertyNames(element).find((key2) => key2.startsWith("__reactFiber$"));
45108
+ const ancestors = committedReactAncestors(
45109
+ key && Object.getOwnPropertyDescriptor(element, key)?.value
45110
+ );
45111
+ const boundary = ancestors.findIndex((fiber) => fiber.type === page);
45112
+ if (boundary < 0) continue;
45113
+ pages.add(ancestors[boundary]);
45114
+ for (const fiber of ancestors.slice(0, boundary + 1)) fibers.add(fiber);
45115
+ }
45116
+ if (pages.size !== 1) return;
45117
+ const scopes = /* @__PURE__ */ new Map();
45118
+ for (const fiber of fibers)
45119
+ for (const hook of hooks(fiber)) {
45120
+ const scope2 = record8(hook.memoizedState) ? hook.memoizedState.current : void 0;
45121
+ if (record8(scope2) && scope2.scope === appScope && record8(scope2.node) && scope2.chain instanceof Map && scope2.chain.get(appScope.id) === scope2.node && typeof scope2.get === "function")
45122
+ scopes.set(scope2.node, scope2);
45123
+ }
45124
+ const scope = [...scopes.values()][0];
45125
+ return scopes.size === 1 && scope ? { scope, fibers } : void 0;
45126
+ }
45127
+ function availability(store, atom, voice, gate) {
45128
+ const native = store.get(atom);
45129
+ const projected = replayVoiceCapability(store, voice, gate);
45130
+ if (typeof native !== "boolean" || atom.write || projected?.isCapable !== true) return;
45131
+ const evaluate = (override) => {
45132
+ let remaining = 512;
45133
+ let hits = 0;
45134
+ const visiting = /* @__PURE__ */ new Set();
45135
+ const read = (dependency) => {
45136
+ if (--remaining < 0) throw new Error("Settings availability dependency limit");
45137
+ const value = store.get(dependency);
45138
+ if (dependency === voice) {
45139
+ hits += 1;
45140
+ return override ? projected : value;
45141
+ }
45142
+ if (dependency.write || visiting.has(dependency)) return value;
45143
+ visiting.add(dependency);
45144
+ try {
45145
+ return dependency.read(read);
45146
+ } finally {
45147
+ visiting.delete(dependency);
45148
+ }
45149
+ };
45150
+ return { value: read(atom), hits };
45151
+ };
45152
+ try {
45153
+ const before = evaluate(false);
45154
+ const after = evaluate(true);
45155
+ return before.hits > 0 && before.value === native && after.hits > 0 && typeof after.value === "boolean" ? after.value : void 0;
45156
+ } catch {
45157
+ return;
45158
+ }
45159
+ }
45160
+ function bindVoiceSettingsAvailability(currentFibers, store, voice, gate, allowed) {
45161
+ const candidates = [];
45162
+ for (const fiber of currentFibers())
45163
+ for (const hook2 of hooks(fiber)) {
45164
+ const [subscriber2, deps] = Array.isArray(hook2.memoizedState) ? hook2.memoizedState : [];
45165
+ if (!record8(subscriber2) || typeof subscriber2.getSnapshot !== "function" || !Array.isArray(deps) || deps.length !== 2 || deps[0] !== store || !record8(deps[1]) || typeof deps[1].read !== "function")
45166
+ continue;
45167
+ const atom2 = deps[1];
45168
+ if (availability(store, atom2, voice, gate) === true)
45169
+ candidates.push({ hook: hook2, subscriber: subscriber2, atom: atom2 });
45170
+ }
45171
+ const candidate = candidates[0];
45172
+ if (candidates.length !== 1 || !candidate)
45173
+ throw new Error("Unavailable or ambiguous Settings availability reader");
45174
+ const { hook, subscriber, atom } = candidate;
45175
+ const instance = hook.next?.queue;
45176
+ const effect = hook.next?.next?.memoizedState;
45177
+ const native = store.get(atom);
45178
+ if (!instance || typeof instance.getSnapshot !== "function" || !record8(effect) || !Array.isArray(effect.deps) || effect.deps.length !== 1 || effect.deps[0] !== subscriber.subscribe || typeof effect.create !== "function" || subscriber.getSnapshot() !== native || instance.getSnapshot() !== native || subscriber.createRender?.() != null)
45179
+ throw new Error("Unsupported Settings availability subscription");
45180
+ for (const [object3, key] of [
45181
+ [store, "sub"],
45182
+ [subscriber, "getSnapshot"],
45183
+ [instance, "getSnapshot"]
45184
+ ])
45185
+ if (Object.getOwnPropertyDescriptor(object3, key)?.writable !== true)
45186
+ throw new Error("Settings availability reader is not writable");
45187
+ let notify;
45188
+ const sub = store.sub;
45189
+ try {
45190
+ store.sub = (selected, listener) => {
45191
+ if (selected !== atom || notify) throw new Error("Unexpected Settings subscription");
45192
+ notify = listener;
45193
+ return () => {
45194
+ };
45195
+ };
45196
+ effect.create();
45197
+ } finally {
45198
+ store.sub = sub;
45199
+ }
45200
+ if (!notify) throw new Error("Settings availability listener unavailable");
45201
+ const original = subscriber.getSnapshot;
45202
+ const originalInstance = instance.getSnapshot;
45203
+ const snapshot = () => allowed() && availability(store, atom, voice, gate) === true ? true : original.call(subscriber);
45204
+ subscriber.getSnapshot = snapshot;
45205
+ instance.getSnapshot = snapshot;
45206
+ const onChange = notify;
45207
+ let disposed = false;
45208
+ const binding = {
45209
+ current() {
45210
+ try {
45211
+ const expected = subscriber.getSnapshot();
45212
+ return !disposed && expected === true && instance.getSnapshot() === expected && [...currentFibers()].flatMap(hooks).some(
45213
+ (current) => current.memoizedState && Array.isArray(current.memoizedState) && current.memoizedState[0] === subscriber && current.memoizedState[1]?.[0] === store && current.memoizedState[1]?.[1] === atom && current.next?.queue === instance && current.next.memoizedState === expected
45214
+ );
45215
+ } catch {
45216
+ return false;
45217
+ }
45218
+ },
45219
+ dispose() {
45220
+ if (disposed) return;
45221
+ disposed = true;
45222
+ if (subscriber.getSnapshot === snapshot) subscriber.getSnapshot = original;
45223
+ if (instance.getSnapshot === snapshot) instance.getSnapshot = originalInstance;
45224
+ onChange();
45225
+ }
45226
+ };
45227
+ try {
45228
+ onChange();
45229
+ } catch (error51) {
45230
+ binding.dispose();
45231
+ throw error51;
45232
+ }
45233
+ return binding;
45234
+ }
45235
+
45236
+ // src/renderer-dictation-settings.ts
45237
+ var record9 = (value) => value !== null && typeof value === "object";
45238
+ var mode = (value) => value === null || value === "os-global" || value === "app";
45239
+ function replayDictationSettingsMode(store, atom, capabilities, gate) {
45240
+ try {
45241
+ const native = store.get(atom);
45242
+ if (atom.write || !mode(native)) return;
45243
+ const replacements = new Map(
45244
+ capabilities.map((capability) => [
45245
+ capability,
45246
+ replayVoiceCapability(store, capability, gate)
45247
+ ])
45248
+ );
45249
+ const evaluate = (override) => {
45250
+ let remaining = 512;
45251
+ let hits = 0;
45252
+ const visiting = /* @__PURE__ */ new Set();
45253
+ const read = (dependency) => {
45254
+ if (--remaining < 0) throw new Error("Dictation Settings dependency limit");
45255
+ const value = store.get(dependency);
45256
+ if (replacements.has(dependency)) {
45257
+ hits += 1;
45258
+ const projected = replacements.get(dependency);
45259
+ return override && projected?.isCapable ? projected : value;
45260
+ }
45261
+ if (dependency.write || visiting.has(dependency)) return value;
45262
+ visiting.add(dependency);
45263
+ try {
45264
+ return dependency.read(read);
45265
+ } finally {
45266
+ visiting.delete(dependency);
45267
+ }
45268
+ };
45269
+ return { value: read(atom), hits };
45270
+ };
45271
+ const before = evaluate(false), after = evaluate(true);
45272
+ return before.hits > 0 && before.value === native && after.hits > 0 && mode(after.value) ? after.value : void 0;
45273
+ } catch {
45274
+ return;
45275
+ }
45276
+ }
45277
+ function bindDictationSettingsMode(currentFibers, store, atom, capabilities, gate, allowed) {
45278
+ const readers = () => [...currentFibers()].flatMap(hooks).filter((hook) => {
45279
+ const [subscriber, deps] = Array.isArray(hook.memoizedState) ? hook.memoizedState : [];
45280
+ return record9(subscriber) && typeof subscriber.getSnapshot === "function" && Array.isArray(deps) && deps.length === 2 && deps[0] === store && deps[1] === atom;
45281
+ });
45282
+ const subscriptions = readers();
45283
+ if (!subscriptions.length || replayDictationSettingsMode(store, atom, capabilities, gate) === void 0)
45284
+ throw new Error("Native Settings dictation mode unavailable");
45285
+ const restores = [];
45286
+ const bindings = [];
45287
+ try {
45288
+ for (const hook of subscriptions) {
45289
+ const subscriber = hook.memoizedState[0];
45290
+ const instance = hook.next?.queue;
45291
+ const effect = hook.next?.next?.memoizedState;
45292
+ const native = store.get(atom);
45293
+ if (!instance || typeof instance.getSnapshot !== "function" || !record9(effect) || !Array.isArray(effect.deps) || effect.deps.length !== 1 || effect.deps[0] !== subscriber.subscribe || typeof effect.create !== "function" || subscriber.getSnapshot() !== native || instance.getSnapshot() !== native || subscriber.createRender?.() != null)
45294
+ throw new Error("Unsupported Settings dictation mode subscription");
45295
+ for (const [object3, key] of [
45296
+ [store, "sub"],
45297
+ [subscriber, "getSnapshot"],
45298
+ [instance, "getSnapshot"]
45299
+ ])
45300
+ if (Object.getOwnPropertyDescriptor(object3, key)?.writable !== true)
45301
+ throw new Error("Dictation Settings reader is not writable");
45302
+ const sub = store.sub;
45303
+ let notify;
45304
+ try {
45305
+ store.sub = (selected, listener) => {
45306
+ if (selected !== atom || notify)
45307
+ throw new Error("Unexpected dictation Settings subscription");
45308
+ notify = listener;
45309
+ return () => {
45310
+ };
45311
+ };
45312
+ effect.create();
45313
+ } finally {
45314
+ store.sub = sub;
45315
+ }
45316
+ if (!notify) throw new Error("Dictation Settings listener unavailable");
45317
+ const original = subscriber.getSnapshot, originalInstance = instance.getSnapshot;
45318
+ const snapshot = () => {
45319
+ if (allowed()) {
45320
+ const projected = replayDictationSettingsMode(store, atom, capabilities, gate);
45321
+ if (projected !== void 0) return projected;
45322
+ }
45323
+ return original.call(subscriber);
45324
+ };
45325
+ subscriber.getSnapshot = snapshot;
45326
+ instance.getSnapshot = snapshot;
45327
+ const onChange = notify;
45328
+ restores.push(() => {
45329
+ if (subscriber.getSnapshot === snapshot) subscriber.getSnapshot = original;
45330
+ if (instance.getSnapshot === snapshot) instance.getSnapshot = originalInstance;
45331
+ onChange();
45332
+ });
45333
+ bindings.push({ subscriber, instance });
45334
+ onChange();
45335
+ }
45336
+ } catch (error51) {
45337
+ for (const restore of restores.reverse()) restore();
45338
+ throw error51;
45339
+ }
45340
+ return {
45341
+ current() {
45342
+ try {
45343
+ const current = readers();
45344
+ return restores.length > 0 && current.length === bindings.length && bindings.every(({ subscriber, instance }) => {
45345
+ const expected = subscriber.getSnapshot();
45346
+ return mode(expected) && instance.getSnapshot() === expected && current.some(
45347
+ (hook) => hook.memoizedState[0] === subscriber && hook.next?.queue === instance && hook.next.memoizedState === expected
45348
+ );
45349
+ });
45350
+ } catch {
45351
+ return false;
45352
+ }
45353
+ },
45354
+ dispose() {
45355
+ for (const restore of restores.splice(0).reverse()) restore();
45356
+ }
45357
+ };
45358
+ }
45359
+
45360
+ // src/renderer-voice-settings.ts
45361
+ var GLOBAL2 = "__codexhostVoiceSettingsV1";
45362
+ var MESSAGE_ID = "settings.general.realtimeVoice.unavailable.description";
45363
+ var LABEL = "Voice settings unavailable with this provider";
45364
+ var DESCRIPTION = "Your account allows voice chat. These Desktop settings require the default inference provider. Start ChatGPT Chat voice from the Chat composer.";
45365
+ var record10 = (value) => value !== null && typeof value === "object";
45366
+ var settled = (value, isCapable) => record10(value) && value.isLoading === false && value.isError === false && value.isCapable === isCapable;
45367
+ function realtimeAtoms(scope, modules) {
45368
+ const atom = modules.capability.resolve(scope.node, scope.chain, { name: "voice.realtime" }).resolve(scope.node, scope.chain);
45369
+ return {
45370
+ atom,
45371
+ gate: modules.gates.resolve(scope.node, scope.chain, INFERENCE_GATE).atom
45372
+ };
45373
+ }
45374
+ function providerBlocksVoiceSettings(scope, modules) {
45375
+ try {
45376
+ const access = scope.get(modules.access);
45377
+ if (!record10(access) || access.status !== "allowed" || !settled(scope.get(modules.capability, { name: "voice" }), true) || !settled(scope.get(modules.capability, { name: "voice.realtime" }), false))
45378
+ return false;
45379
+ const { atom, gate } = realtimeAtoms(scope, modules);
45380
+ return replayVoiceCapability(scope.node.store, atom, gate)?.isCapable === true;
45381
+ } catch {
45382
+ return false;
45383
+ }
45384
+ }
45385
+ function explainVoiceSettingsRestriction(doc, modules) {
45386
+ const descriptions = [];
45387
+ for (const element of doc.querySelectorAll("section div")) {
45388
+ if (element.childNodes.length !== 1 || element.firstChild?.nodeType !== 3) continue;
45389
+ const key = Object.getOwnPropertyNames(element).find((key2) => key2.startsWith("__reactFiber$"));
45390
+ const ancestors = committedReactAncestors(
45391
+ key && Object.getOwnPropertyDescriptor(element, key)?.value
45392
+ );
45393
+ if (!ancestors.some((fiber) => fiber.type === modules.page)) continue;
45394
+ const owner = ancestors.find(
45395
+ ({ memoizedProps: props2 }) => record10(props2) && record10(props2.description) && record10(props2.description.props) && props2.description.props.id === MESSAGE_ID && props2.control === null
45396
+ );
45397
+ const props = owner?.memoizedProps;
45398
+ if (!record10(props) || !record10(props.description) || !record10(props.description.props) || !record10(props.label) || !record10(props.label.props) || element.textContent !== props.description.props.defaultMessage)
45399
+ continue;
45400
+ const labelText = props.label.props.defaultMessage;
45401
+ if (typeof labelText !== "string") continue;
45402
+ const row = ancestors.find((fiber) => {
45403
+ const host2 = fiber.stateNode;
45404
+ return fiber.tag === 5 && host2 !== element && typeof host2?.contains === "function" && host2.contains(element) && host2.textContent?.includes(labelText);
45405
+ });
45406
+ const host = row?.stateNode;
45407
+ const labels = host ? [...host.querySelectorAll("div")].filter(
45408
+ (node) => node.childNodes.length === 1 && node.firstChild?.nodeType === 3 && node.textContent === labelText
45409
+ ) : [];
45410
+ if (labels.length !== 1) continue;
45411
+ const scopes = /* @__PURE__ */ new Map();
45412
+ for (const fiber of ancestors) {
45413
+ let hook = fiber.memoizedState;
45414
+ const seen = /* @__PURE__ */ new Set();
45415
+ while (record10(hook) && seen.size < 4096 && !seen.has(hook)) {
45416
+ seen.add(hook);
45417
+ const scope2 = record10(hook.memoizedState) ? hook.memoizedState.current : void 0;
45418
+ if (record10(scope2) && scope2.scope === modules.appScope && record10(scope2.node) && scope2.chain instanceof Map && scope2.chain.get(modules.appScope.id) === scope2.node && typeof scope2.get === "function")
45419
+ scopes.set(scope2.node, scope2);
45420
+ hook = hook.next;
45421
+ }
45422
+ }
45423
+ const label = labels[0];
45424
+ const scope = [...scopes.values()][0];
45425
+ if (scopes.size === 1 && label && scope) descriptions.push({ element, label, scope });
45426
+ }
45427
+ const current = descriptions.length === 1 ? descriptions[0] : void 0;
45428
+ if (!current) return;
45429
+ if (!providerBlocksVoiceSettings(current.scope, modules)) return;
45430
+ const changes = [
45431
+ [current.element, DESCRIPTION],
45432
+ [current.label, LABEL]
45433
+ ];
45434
+ const restores = changes.map(([element, replacement]) => {
45435
+ const text = element.firstChild;
45436
+ const previous = text.data;
45437
+ text.data = replacement;
45438
+ return () => {
45439
+ if (text.data === replacement) text.data = previous;
45440
+ };
45441
+ });
45442
+ return {
45443
+ current() {
45444
+ return changes.every(
45445
+ ([element, replacement]) => element.isConnected && element.textContent === replacement
45446
+ ) && providerBlocksVoiceSettings(current.scope, modules);
45447
+ },
45448
+ dispose() {
45449
+ for (const restore of restores) restore();
45450
+ }
45451
+ };
45452
+ }
45453
+ function restoreNativeVoiceSettings(doc, modules, enabled = () => true) {
45454
+ const surface = voiceSettingsSurface(doc, modules.page, modules.appScope);
45455
+ if (!surface || !providerBlocksVoiceSettings(surface.scope, modules)) return;
45456
+ const scope = surface.scope;
45457
+ const currentFibers = () => {
45458
+ const current = voiceSettingsSurface(doc, modules.page, modules.appScope);
45459
+ return current?.scope.node === scope.node ? current.fibers : /* @__PURE__ */ new Set();
45460
+ };
45461
+ const allowed = () => enabled() && providerBlocksVoiceSettings(scope, modules);
45462
+ const { atom, gate } = realtimeAtoms(scope, modules);
45463
+ const capability = bindVoiceCapabilitySubscriptions(
45464
+ () => new Set([...currentFibers()].filter((fiber) => fiber.type === modules.page)),
45465
+ modules.capability,
45466
+ modules.gates,
45467
+ allowed,
45468
+ false,
45469
+ ["voice.realtime", "dictation.composer", "dictation.global"]
45470
+ );
45471
+ let availability2;
45472
+ try {
45473
+ availability2 = bindVoiceSettingsAvailability(
45474
+ currentFibers,
45475
+ scope.node.store,
45476
+ atom,
45477
+ gate,
45478
+ allowed
45479
+ );
45480
+ const dictationMode = modules.dictationMode && bindDictationSettingsMode(
45481
+ currentFibers,
45482
+ scope.node.store,
45483
+ modules.dictationMode.resolve(scope.node, scope.chain),
45484
+ ["dictation.composer", "dictation.global", "dictation.chatgpt"].map(
45485
+ (name) => modules.capability.resolve(scope.node, scope.chain, { name }).resolve(scope.node, scope.chain)
45486
+ ),
45487
+ gate,
45488
+ enabled
45489
+ );
45490
+ const voiceAvailability = availability2;
45491
+ return {
45492
+ current: () => allowed() && capability.current() && voiceAvailability.current() && (dictationMode?.current() ?? true),
45493
+ dispose() {
45494
+ dictationMode?.dispose();
45495
+ voiceAvailability.dispose();
45496
+ capability.dispose();
45497
+ }
45498
+ };
45499
+ } catch (error51) {
45500
+ availability2?.dispose();
45501
+ capability.dispose();
45502
+ throw error51;
45503
+ }
45504
+ }
45505
+ function installVoiceSettingsExplanation(options = {}) {
45506
+ const target = options.target ?? globalThis;
45507
+ const globals = target;
45508
+ if (globals[GLOBAL2]) return globals[GLOBAL2];
45509
+ const config2 = readCpaLiveVoiceHookConfig(target);
45510
+ if (!config2) return { dispose() {
45511
+ } };
45512
+ if (config2.desktopVersion && config2.desktopVersion !== NATIVE_CHAT_VOICE_VERSION)
45513
+ return { dispose() {
45514
+ } };
45515
+ let disposed = false;
45516
+ let timer;
45517
+ let binding;
45518
+ let modules;
45519
+ let restored = false;
45520
+ const handle = {
45521
+ dispose() {
45522
+ disposed = true;
45523
+ if (timer !== void 0) target.clearTimeout(timer);
45524
+ binding?.dispose();
45525
+ if (globals[GLOBAL2] === handle) Reflect.deleteProperty(globals, GLOBAL2);
45526
+ }
45527
+ };
45528
+ globals[GLOBAL2] = handle;
45529
+ const tryControls = () => {
45530
+ if (!modules || !target.document) return;
45531
+ try {
45532
+ return restoreNativeVoiceSettings(
45533
+ target.document,
45534
+ modules,
45535
+ () => !!readCpaLiveVoiceHookConfig(target)
45536
+ );
45537
+ } catch {
45538
+ return void 0;
45539
+ }
45540
+ };
45541
+ const refresh = async () => {
45542
+ if (disposed) return;
45543
+ try {
45544
+ if (binding?.current()) {
45545
+ if (restored) return;
45546
+ const controls = tryControls();
45547
+ if (controls) {
45548
+ binding.dispose();
45549
+ binding = controls;
45550
+ restored = true;
45551
+ }
45552
+ return;
45553
+ }
45554
+ binding?.dispose();
45555
+ binding = void 0;
45556
+ restored = false;
45557
+ if (!modules) {
45558
+ const assets = selectVoiceAssets(
45559
+ NATIVE_CHAT_VOICE_ASSETS,
45560
+ loadedAssetNames(target.document, target.performance),
45561
+ config2.desktopVersion
45562
+ );
45563
+ if (!assets?.settings) return;
45564
+ const load = options.importModule ?? ((url2) => import(url2));
45565
+ const [initial, shared, settings] = await Promise.all(
45566
+ [assets.initial, assets.shared, assets.settings].map(
45567
+ (asset) => load(`app://-/assets/${asset}`)
45568
+ )
45569
+ );
45570
+ if (disposed) return;
45571
+ if (typeof initial.l0n !== "function" || typeof settings.VoiceSettings !== "function")
45572
+ return;
45573
+ initial.l0n();
45574
+ const dictationMode = initial.mW;
45575
+ modules = {
45576
+ appScope: shared.Bst,
45577
+ page: settings.VoiceSettings,
45578
+ access: initial.k5n,
45579
+ capability: initial.c0n,
45580
+ gates: initial.Cnr,
45581
+ ...dictationMode ? { dictationMode } : {}
45582
+ };
45583
+ }
45584
+ if (target.document) {
45585
+ binding = tryControls();
45586
+ restored = !!binding;
45587
+ if (!binding) binding = explainVoiceSettingsRestriction(target.document, modules);
45588
+ }
45589
+ } catch {
45590
+ } finally {
45591
+ if (!disposed) timer = target.setTimeout(() => void refresh(), 1e3);
45592
+ }
45593
+ };
45594
+ void refresh();
45595
+ return handle;
45596
+ }
45597
+
44936
45598
  // src/production-entry.ts
44937
45599
  installCpaLiveVoiceHook();
44938
45600
  installClientOwnedVoiceHook();
44939
45601
  installExternalVoiceLaunchHook();
44940
45602
  installNativeChatVoiceHook();
44941
45603
  installVoiceCapabilityProjection();
45604
+ installVoiceSettingsExplanation();
44942
45605
  var installBinding = () => {
44943
45606
  installRendererBinding();
44944
45607
  };