dsh-codex-subscription 3.1.9 → 3.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -194,7 +194,13 @@ function normalizeDefaultSelection(value) {
194
194
  * @param resolveService - reads the optional DSH `agentDefaultModel` service.
195
195
  * @param listModels - optional account catalog used to reject unknown models.
196
196
  */
197
- function createDefaultModelController({ resolveService, listModels } = {}) {
197
+ function createDefaultModelController({ resolveService, resolveEditor, listModels } = {}) {
198
+ let writes = Promise.resolve();
199
+ const enqueue = (operation) => {
200
+ const result = writes.then(operation);
201
+ writes = result.catch(() => {});
202
+ return result;
203
+ };
198
204
  const service = () => {
199
205
  try {
200
206
  return resolveService?.();
@@ -211,11 +217,25 @@ function createDefaultModelController({ resolveService, listModels } = {}) {
211
217
  return;
212
218
  }
213
219
  };
220
+ const resetTarget = () => {
221
+ try {
222
+ const editor = resolveEditor?.();
223
+ if (typeof editor?.entries !== "function" || typeof editor.edit !== "function" || typeof editor.configuration !== "function") return void 0;
224
+ const entries = editor.entries().filter((entry) => entry.options?.name === "@deepseek-ai/dsh-agent-default-model");
225
+ return entries.length === 1 ? {
226
+ editor,
227
+ entry: entries[0]
228
+ } : void 0;
229
+ } catch {
230
+ return;
231
+ }
232
+ };
214
233
  const status = () => {
215
234
  const selection = read();
216
235
  return {
217
236
  available: selection !== void 0,
218
237
  managed: selection?.provider === "openai-codex" && selection.model !== void 0,
238
+ ...selection !== void 0 && resetTarget() ? { resetAvailable: true } : {},
219
239
  ...selection
220
240
  };
221
241
  };
@@ -224,22 +244,34 @@ function createDefaultModelController({ resolveService, listModels } = {}) {
224
244
  if (!validDefaultModelId(model)) throw new DefaultModelError("invalid-model", "Invalid default model");
225
245
  const catalog = typeof listModels === "function" ? listModels() : void 0;
226
246
  if (Array.isArray(catalog) && catalog.length > 0 && !catalog.includes(model)) throw new DefaultModelError("invalid-model", "Invalid default model");
227
- const current = service();
228
- if (current === void 0 || typeof current.saveSelection !== "function") throw new DefaultModelError("unavailable", "This DSH deployment cannot save a default model");
229
- const previous = read();
230
- const reasoningEffort = previous?.provider === "openai-codex" && previous.model === model ? previous.reasoningEffort : void 0;
231
- await current.saveSelection({
232
- provider: DEFAULT_MODEL_PROVIDER,
233
- model,
234
- ...reasoningEffort === void 0 ? {} : { reasoningEffort }
247
+ return enqueue(async () => {
248
+ const current = service();
249
+ if (current === void 0 || typeof current.saveSelection !== "function") throw new DefaultModelError("unavailable", "This DSH deployment cannot save a default model");
250
+ const previous = read();
251
+ const reasoningEffort = previous?.provider === "openai-codex" && previous.model === model ? previous.reasoningEffort : void 0;
252
+ await current.saveSelection({
253
+ provider: DEFAULT_MODEL_PROVIDER,
254
+ model,
255
+ ...reasoningEffort === void 0 ? {} : { reasoningEffort }
256
+ });
257
+ const applied = read();
258
+ if (applied?.provider !== "openai-codex" || applied.model !== model) throw new DefaultModelError("unavailable", "The default model could not be saved");
259
+ return status();
235
260
  });
236
- const applied = read();
237
- if (applied?.provider !== "openai-codex" || applied.model !== model) throw new DefaultModelError("unavailable", "The default model could not be saved");
238
- return status();
239
261
  };
262
+ const reset = () => enqueue(async () => {
263
+ const target = resetTarget();
264
+ if (!target || read() === void 0) throw new DefaultModelError("unavailable", "This DSH deployment cannot restore its default model");
265
+ await target.editor.edit(target.entry, (_current, inherited) => inherited);
266
+ const active = resetTarget();
267
+ const row = active?.editor.configuration().find((item) => item.entry === active.entry);
268
+ if (!row || Object.keys(row.override).length !== 0 || read() === void 0) throw new DefaultModelError("unavailable", "The DSH default model could not be restored");
269
+ return status();
270
+ });
240
271
  return Object.freeze({
241
272
  status,
242
- select
273
+ select,
274
+ reset
243
275
  });
244
276
  }
245
277
  //#endregion
@@ -707,6 +739,11 @@ const PREFERENCE_FIELDS = Object.freeze({
707
739
  default: DEFAULT_REASONING_EFFORT,
708
740
  error: "Invalid default reasoning effort"
709
741
  },
742
+ composerPredictions: {
743
+ choices: ["off", "on"],
744
+ default: "off",
745
+ error: "Invalid input prediction setting"
746
+ },
710
747
  connectionMode: {
711
748
  choices: ["sse", "websocket"],
712
749
  default: "sse",
@@ -1288,6 +1325,7 @@ function createCodexNetworkTransport(options = {}) {
1288
1325
  routed = true;
1289
1326
  }
1290
1327
  });
1328
+ connection.signal?.throwIfAborted();
1291
1329
  if (value instanceof Response && !value.ok) remember(area, {
1292
1330
  status: "failed",
1293
1331
  stage: "http",
@@ -1303,6 +1341,7 @@ function createCodexNetworkTransport(options = {}) {
1303
1341
  });
1304
1342
  return value;
1305
1343
  } catch (error) {
1344
+ if (connection.signal?.aborted && connection.signal.reason?.name !== "TimeoutError") throw error;
1306
1345
  if (routed) remember(area, {
1307
1346
  status: "failed",
1308
1347
  stage: "transport",
@@ -1316,7 +1355,10 @@ function createCodexNetworkTransport(options = {}) {
1316
1355
  return Object.freeze({
1317
1356
  run,
1318
1357
  history: evidence.snapshot,
1319
- fetch: (area, input, init, connection) => run(area, () => globalThis.fetch(input, init), connection),
1358
+ fetch: (area, input, init, connection) => run(area, () => globalThis.fetch(input, init), {
1359
+ ...connection,
1360
+ signal: init?.signal ?? (input instanceof Request ? input.signal : void 0) ?? connection?.signal
1361
+ }),
1320
1362
  snapshot: () => Object.fromEntries([...attempts].map(([area, value]) => [area, { ...value }]))
1321
1363
  });
1322
1364
  }
@@ -1776,6 +1818,7 @@ function normalizeTransportEvent(event, signal) {
1776
1818
  }
1777
1819
  //#endregion
1778
1820
  //#region src/model-retry-hint.js
1821
+ const CODEX_OVERLOADED = /^\s*(?:Codex error:\s*)?Our servers are currently overloaded\. Please try again later\.\s*$/u;
1779
1822
  /** Keep the provider's wait as a fact; only DSH decides whether and when to retry. */
1780
1823
  function providerRetryAfterMs(headers, at = Date.now()) {
1781
1824
  const read = (key) => typeof headers?.get === "function" ? headers.get(key) : headers?.[key];
@@ -1790,9 +1833,10 @@ function providerRetryAfterMs(headers, at = Date.now()) {
1790
1833
  return Number.isFinite(value) && value > 0 ? Math.min(value, Number.MAX_SAFE_INTEGER) : void 0;
1791
1834
  }
1792
1835
  function createModelRetryHint({ now = Date.now, ErrorClass = dshLlm.LlmError } = {}) {
1793
- let response, outputStarted = false;
1836
+ let response, responseStatus, outputStarted = false;
1794
1837
  return {
1795
1838
  onResponse(info) {
1839
+ responseStatus = info?.status;
1796
1840
  response = [429, 503].includes(info?.status) ? {
1797
1841
  status: info.status,
1798
1842
  delay: providerRetryAfterMs(info.headers, now())
@@ -1806,23 +1850,29 @@ function createModelRetryHint({ now = Date.now, ErrorClass = dshLlm.LlmError } =
1806
1850
  ].includes(event.type)) outputStarted = true;
1807
1851
  },
1808
1852
  failure(original, signal) {
1809
- if (signal?.aborted || outputStarted || !response || !original || typeof original.message !== "string" || [
1853
+ if (signal?.aborted || outputStarted || !original || typeof original.message !== "string" || [
1810
1854
  "ABORTED",
1855
+ "AUTH",
1856
+ "INVALID_REQUEST",
1811
1857
  "QUOTA",
1812
1858
  "ACCOUNT_QUOTA",
1813
1859
  "QUOTA_EXCEEDED"
1814
1860
  ].includes(original.code) || typeof dshLlm.isQuotaExceededError === "function" && dshLlm.isQuotaExceededError(original.message)) return original;
1815
- if (/You have hit your ChatGPT usage limit/iu.test(original.message) || response.status === 429 && original.code !== "RATE_LIMIT") return original;
1861
+ const status = responseStatus ?? original.status;
1862
+ const overloaded = original.code === "PI_AI_ERROR" && CODEX_OVERLOADED.test(original.message) && (status === void 0 || status >= 200 && status < 300);
1863
+ if (!response && !overloaded) return original;
1864
+ if (/You have hit your ChatGPT usage limit/iu.test(original.message) || response?.status === 429 && original.code !== "RATE_LIMIT") return original;
1865
+ const code = response?.status === 429 ? "RATE_LIMIT" : "SERVER";
1816
1866
  let error;
1817
1867
  try {
1818
- error = new ErrorClass(original.message, response.status === 429 ? "RATE_LIMIT" : "SERVER", {
1868
+ error = new ErrorClass(original.message, code, response ? {
1819
1869
  status: response.status,
1820
1870
  ...response.delay === void 0 ? {} : { providerRetryAfterMs: response.delay }
1821
- });
1871
+ } : {});
1822
1872
  } catch {
1823
1873
  return original;
1824
1874
  }
1825
- return error.failure?.status === response.status && (response.delay === void 0 || error.failure.providerRetryAfterMs === response.delay) ? {
1875
+ return error.failure?.code === code && (!response || error.failure.status === response.status && (response.delay === void 0 || error.failure.providerRetryAfterMs === response.delay)) ? {
1826
1876
  ...original,
1827
1877
  ...error.failure
1828
1878
  } : original;
@@ -2607,6 +2657,8 @@ const RPC_ENDPOINTS = Object.freeze([
2607
2657
  "preferences/update",
2608
2658
  "default-model/status",
2609
2659
  "default-model/select",
2660
+ "default-model/reset",
2661
+ "predictions/generate",
2610
2662
  "runtime/status",
2611
2663
  "runtime/install",
2612
2664
  "runtime/remove",
@@ -2850,14 +2902,16 @@ const SUPPORTED_RUNTIME_VERSIONS = Object.freeze([
2850
2902
  "0.2.1-rc.1",
2851
2903
  "0.2.1-rc.2",
2852
2904
  "0.2.1-rc.3",
2853
- "0.2.1-rc.4"
2905
+ "0.2.1-rc.4",
2906
+ "0.2.2-alpha.2"
2854
2907
  ]);
2855
2908
  const require = createRequire(import.meta.url);
2856
2909
  const execute = promisify(execFile);
2857
2910
  /** The DSH release this plugin is loaded into, read from the host's own LLM package. */
2858
2911
  function hostDshVersion(resolve = require.resolve, entry = process.argv[1]) {
2859
- const attempts = [() => resolve("@deepseek-ai/dsh-llm/package.json")];
2860
- if (typeof entry === "string" && entry) attempts.push(() => require.resolve("@deepseek-ai/dsh-llm/package.json", { paths: [dirname(entry)] }));
2912
+ const attempts = [];
2913
+ if (typeof entry === "string" && entry) attempts.push(() => require.resolve("@deepseek-ai/dsh-llm/package.json", { paths: [dirname(realpathSync(entry))] }));
2914
+ attempts.push(() => resolve("@deepseek-ai/dsh-llm/package.json"));
2861
2915
  for (const attempt of attempts) try {
2862
2916
  const { version } = JSON.parse(readFileSync(attempt(), "utf8"));
2863
2917
  if (typeof version === "string" && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/u.test(version)) return version;
@@ -3596,6 +3650,15 @@ const sketchCommandArray = {
3596
3650
  };
3597
3651
  //#endregion
3598
3652
  //#region src/subscription-credentials.js
3653
+ /** Step-time capability checks read the vault only; refreshing belongs to execution. */
3654
+ async function subscriptionCredentialReady(readCredential) {
3655
+ try {
3656
+ const value = await readCredential({});
3657
+ return value?.type === "oauth" && typeof value.access === "string" && value.access.length > 0 && typeof value.accountId === "string" && value.accountId.length > 0;
3658
+ } catch {
3659
+ return false;
3660
+ }
3661
+ }
3599
3662
  async function readSubscriptionCredentials(getAuth, readCredential, signal) {
3600
3663
  for (let attempt = 0; attempt < 2; attempt++) {
3601
3664
  const auth = await getAuth({ signal });
@@ -3642,8 +3705,9 @@ function originalImageRefsEqual(left, right) {
3642
3705
  /** Resolve only an exact original reference copied into a DSH fork prefix. */
3643
3706
  function inheritedOriginalImageRef(session, assetId) {
3644
3707
  const parentSession = session?.header?.parentSession;
3708
+ const forked = typeof parentSession === "string" && parentSession.length > 0 || session?.header?.isSeeded === true;
3645
3709
  const seedLength = session?.inheritedEventCount;
3646
- if (typeof parentSession !== "string" || parentSession.length === 0 || !Number.isSafeInteger(seedLength) || seedLength < 0 || !ORIGINAL_IMAGE_ID_PATTERN.test(assetId)) return void 0;
3710
+ if (!forked || !Number.isSafeInteger(seedLength) || seedLength < 0 || !ORIGINAL_IMAGE_ID_PATTERN.test(assetId)) return void 0;
3647
3711
  if (typeof session?.snapshotEvents !== "function") return void 0;
3648
3712
  let events;
3649
3713
  try {
@@ -3660,7 +3724,7 @@ function inheritedOriginalImageRef(session, assetId) {
3660
3724
  }
3661
3725
  //#endregion
3662
3726
  //#region src/version.js
3663
- const PACKAGE_VERSION = "3.1.9";
3727
+ const PACKAGE_VERSION = "3.2.1";
3664
3728
  const USER_AGENT = `dsh-codex-subscription/${PACKAGE_VERSION}`;
3665
3729
  //#endregion
3666
3730
  //#region src/codex-images.js
@@ -9727,8 +9791,32 @@ function createUltraExecutionPreset({ catalog, resolveAgent = () => void 0, defa
9727
9791
  };
9728
9792
  }
9729
9793
  //#endregion
9794
+ //#region src/host-session-sdk.js
9795
+ const id = "@deepseek-ai/dsh-session";
9796
+ const absent = (error) => error?.code === "MODULE_NOT_FOUND" && error.message?.startsWith(`Cannot find module '${id}'`);
9797
+ const loadSdk = (base) => {
9798
+ let resolved = base;
9799
+ try {
9800
+ resolved = realpathSync(base.startsWith("file:") ? new URL(base) : base);
9801
+ } catch (error) {
9802
+ if (error.code !== "ENOENT") throw error;
9803
+ }
9804
+ return createRequire(resolved)(id);
9805
+ };
9806
+ /** Session writers must come from the host's SDK: even equal-version copies have distinct private brands. */
9807
+ function loadHostSessionSdk({ entry = process.argv[1], local = import.meta.url, load = loadSdk } = {}) {
9808
+ for (const base of [typeof entry === "string" && isAbsolute(entry) ? entry : void 0, local]) {
9809
+ if (!base) continue;
9810
+ try {
9811
+ return load(base);
9812
+ } catch (error) {
9813
+ if (!absent(error)) throw error;
9814
+ }
9815
+ }
9816
+ }
9817
+ //#endregion
9730
9818
  //#region src/remote-image-assets.js
9731
- const BASE$1 = "https://chatgpt.com/backend-api/";
9819
+ const BASE$2 = "https://chatgpt.com/backend-api/";
9732
9820
  const FILE_ID = /^file[-_][A-Za-z0-9_-]{1,200}$/u;
9733
9821
  const HASH = /^[a-f0-9]{64}$/u;
9734
9822
  const hash = (value) => createHash("sha256").update(value).digest("hex");
@@ -9818,7 +9906,7 @@ function createRemoteImageAssets({ credentials, fetch: request = globalThis.fetc
9818
9906
  async function upload(bytes, mediaType, auth, owner, key, signal) {
9819
9907
  const api = async (method, path, body) => {
9820
9908
  signal.throwIfAborted();
9821
- const response = await send(BASE$1 + path, {
9909
+ const response = await send(BASE$2 + path, {
9822
9910
  method,
9823
9911
  redirect: "error",
9824
9912
  signal: AbortSignal.any([signal, AbortSignal.timeout(6e4)]),
@@ -11516,6 +11604,11 @@ function createDshSearchProvider({ resolveDshProvider, report }) {
11516
11604
  return Object.freeze({
11517
11605
  id: DSH_SEARCH_PROVIDER_ID,
11518
11606
  available: () => true,
11607
+ async ready(llmProvider) {
11608
+ const provider = resolveDshProvider?.();
11609
+ if (!provider || provider.id === "codex-subscription-dsh") return true;
11610
+ return await provider?.ready?.(llmProvider) ?? true;
11611
+ },
11519
11612
  async search(request, signal) {
11520
11613
  const provider = resolveDshProvider?.();
11521
11614
  if (!provider || provider.id === "codex-subscription-dsh" || provider.available() !== true) throw new WebError("DSH default search is unavailable", "WEB_PROVIDER_UNAVAILABLE");
@@ -11593,6 +11686,7 @@ function createCodexSearchProvider(options) {
11593
11686
  return Object.freeze({
11594
11687
  id: CODEX_SEARCH_PROVIDER_ID,
11595
11688
  available: () => true,
11689
+ ready: () => readCapabilitySettings(options.resolvePreferences?.()).searchMode === "disabled" ? false : subscriptionCredentialReady(options.readCredential),
11596
11690
  async search(request, signal) {
11597
11691
  signal?.throwIfAborted();
11598
11692
  const preferences = readCapabilitySettings(options.resolvePreferences?.());
@@ -11698,6 +11792,14 @@ function createCodexAutoSearchProvider(options) {
11698
11792
  return Object.freeze({
11699
11793
  id: CODEX_AUTO_SEARCH_PROVIDER_ID,
11700
11794
  available: () => true,
11795
+ async ready(llmProvider) {
11796
+ if (await options.codex.ready?.(llmProvider) ?? true) return true;
11797
+ try {
11798
+ return await dsh().ready?.(llmProvider) ?? true;
11799
+ } catch {
11800
+ return false;
11801
+ }
11802
+ },
11701
11803
  async search(request, signal) {
11702
11804
  const [first, second] = options.resolveModelProvider?.() === "openai-codex" ? [viaCodex, viaDsh] : [viaDsh, viaCodex];
11703
11805
  try {
@@ -11722,8 +11824,8 @@ const OWN_IDS = /* @__PURE__ */ new Set([
11722
11824
  ]);
11723
11825
  /** Guard the provider itself, including direct/cached handles and hosts without the registry proxy. */
11724
11826
  function gateSearchProvider(provider, { allowed, resolveDshProvider }) {
11725
- const selected = () => {
11726
- if (allowed()) return provider;
11827
+ const selected = (llmProvider) => {
11828
+ if (allowed(llmProvider)) return provider;
11727
11829
  const dsh = resolveDshProvider();
11728
11830
  if (!dsh || OWN_IDS.has(dsh.id) || dsh.available() !== true) throw new WebError("DSH default search is unavailable", "WEB_PROVIDER_UNAVAILABLE");
11729
11831
  return dsh;
@@ -11737,6 +11839,13 @@ function gateSearchProvider(provider, { allowed, resolveDshProvider }) {
11737
11839
  return false;
11738
11840
  }
11739
11841
  },
11842
+ async ready(llmProvider) {
11843
+ try {
11844
+ return await selected(llmProvider).ready?.(llmProvider) ?? true;
11845
+ } catch {
11846
+ return false;
11847
+ }
11848
+ },
11740
11849
  async search(request, signal) {
11741
11850
  return selected().search(request, signal);
11742
11851
  }
@@ -11754,6 +11863,10 @@ function gateSearchProvider(provider, { allowed, resolveDshProvider }) {
11754
11863
  */
11755
11864
  function createSearchRouter({ registry, configuredId, mode, providers }) {
11756
11865
  if (!(registry instanceof Map)) return void 0;
11866
+ const selected = () => {
11867
+ const source = mode();
11868
+ return source === "codex" ? providers.codex : source === "auto" ? providers.auto : providers.dsh;
11869
+ };
11757
11870
  const wrappers = /* @__PURE__ */ new Map();
11758
11871
  const routerFor = (id) => {
11759
11872
  let router = wrappers.get(id);
@@ -11761,9 +11874,9 @@ function createSearchRouter({ registry, configuredId, mode, providers }) {
11761
11874
  router = Object.freeze({
11762
11875
  id,
11763
11876
  available: () => true,
11877
+ ready: (llmProvider) => selected().ready?.(llmProvider) ?? true,
11764
11878
  search(request, signal) {
11765
- const selected = mode();
11766
- return (selected === "codex" ? providers.codex : selected === "auto" ? providers.auto : providers.dsh).search(request, signal);
11879
+ return selected().search(request, signal);
11767
11880
  }
11768
11881
  });
11769
11882
  wrappers.set(id, router);
@@ -11783,6 +11896,12 @@ function createSearchRouter({ registry, configuredId, mode, providers }) {
11783
11896
  //#region src/codex-fetch.js
11784
11897
  const CODEX_FETCH_PROVIDER_ID = "codex-subscription-fetch";
11785
11898
  const MAX_CONTENT = 64e3;
11899
+ const RETRYABLE = /* @__PURE__ */ new Set([
11900
+ 500,
11901
+ 502,
11902
+ 503,
11903
+ 504
11904
+ ]);
11786
11905
  const httpUrl = (value) => {
11787
11906
  try {
11788
11907
  const url = new URL(value);
@@ -11797,6 +11916,7 @@ function createCodexFetchProvider(options) {
11797
11916
  return Object.freeze({
11798
11917
  id: CODEX_FETCH_PROVIDER_ID,
11799
11918
  available: () => true,
11919
+ ready: (llmProvider) => options.allowed?.(llmProvider) === false ? false : subscriptionCredentialReady(options.readCredential),
11800
11920
  async fetch(request, signal) {
11801
11921
  signal?.throwIfAborted();
11802
11922
  if (options.allowed?.() === false) throw new WebError("Codex webpage reading is disabled for this model", "WEB_PROVIDER_UNAVAILABLE");
@@ -11814,59 +11934,78 @@ function createCodexFetchProvider(options) {
11814
11934
  const timeout = AbortSignal.timeout(options.timeoutMs ?? 3e4);
11815
11935
  const activeSignal = signal === void 0 ? timeout : AbortSignal.any([signal, timeout]);
11816
11936
  try {
11817
- const response = await fetchPage(CODEX_SEARCH_URL, {
11818
- method: "POST",
11819
- redirect: "error",
11820
- headers: {
11821
- authorization: `Bearer ${access}`,
11822
- "chatgpt-account-id": accountId,
11823
- accept: "application/json",
11824
- "content-type": "application/json",
11825
- originator: "pi",
11826
- "user-agent": USER_AGENT
11827
- },
11828
- body: JSON.stringify({
11829
- id: options.resolveSessionId?.() || randomUUID(),
11830
- model: options.resolveModel?.() || "gpt-5.6-luna",
11831
- input: url,
11832
- commands: {
11833
- open: [{ ref_id: url }],
11834
- response_length: "long"
11937
+ for (let attempt = 1; attempt <= 2; attempt++) {
11938
+ const response = await fetchPage(CODEX_SEARCH_URL, {
11939
+ method: "POST",
11940
+ redirect: "error",
11941
+ headers: {
11942
+ authorization: `Bearer ${access}`,
11943
+ "chatgpt-account-id": accountId,
11944
+ accept: "application/json",
11945
+ "content-type": "application/json",
11946
+ originator: "pi",
11947
+ "user-agent": USER_AGENT
11835
11948
  },
11836
- settings: {
11837
- allowed_callers: ["direct"],
11838
- external_web_access: true
11949
+ body: JSON.stringify({
11950
+ id: options.resolveSessionId?.() || randomUUID(),
11951
+ model: options.resolveModel?.() || "gpt-5.6-luna",
11952
+ input: url,
11953
+ commands: {
11954
+ open: [{ ref_id: url }],
11955
+ response_length: "long"
11956
+ },
11957
+ settings: {
11958
+ allowed_callers: ["direct"],
11959
+ external_web_access: true
11960
+ },
11961
+ max_output_tokens: 4096
11962
+ }),
11963
+ signal: activeSignal
11964
+ });
11965
+ activeSignal.throwIfAborted();
11966
+ diagnosticLog.info("fetch", `Codex webpage HTTP ${response.status}`, `attempt=${attempt}`);
11967
+ if (!response.ok) {
11968
+ if (RETRYABLE.has(response.status) && attempt === 1) {
11969
+ await response.body?.cancel();
11970
+ await setTimeout$1(options.retryDelayMs ?? 250, void 0, { signal: activeSignal });
11971
+ continue;
11972
+ }
11973
+ const authFailure = await authFailureMessage(response);
11974
+ throw new WebError(authFailure ?? `Codex webpage request failed (HTTP ${response.status})`, authFailure === "ChatGPT sign-in needs to be renewed" ? "WEB_PROVIDER_CREDENTIAL_MISSING" : "WEB_PROVIDER_ERROR");
11975
+ }
11976
+ const value = await response.json();
11977
+ activeSignal.throwIfAborted();
11978
+ const source = Array.isArray(value?.results) ? value.results.find((item) => httpUrl(item?.url) !== void 0 && item?.type !== "error" && item?.title !== "Internal Error") : void 0;
11979
+ const output = typeof value?.output === "string" ? value.output : "";
11980
+ const heading = output.split(/\r?\n/u, 1)[0].trim();
11981
+ const headingUrl = heading.endsWith(")") ? httpUrl(heading.slice(heading.lastIndexOf(" (") + 2, -1)) : void 0;
11982
+ const metadata = output.slice(0, 1024);
11983
+ const pageUrl = source ? httpUrl(source.url) : headingUrl && /Content type:/u.test(metadata) && /Source: open\(/u.test(metadata) ? headingUrl : void 0;
11984
+ const internalError = /^Internal Error(?:\s|\(|$)/iu.test(heading);
11985
+ if (!pageUrl || output.trim() === "" || internalError) {
11986
+ if (attempt === 1 && !source && /^Internal Error(?:\s*\(\s*\))?\s*$/iu.test(heading) && !/non-retryable|not accessible|not safe|blocked|robots|forbidden|access denied/iu.test(output)) {
11987
+ diagnosticLog.warn("fetch", "Codex webpage service returned an internal error; retrying once");
11988
+ await setTimeout$1(options.retryDelayMs ?? 250, void 0, { signal: activeSignal });
11989
+ continue;
11990
+ }
11991
+ const upstreamTimeout = internalError && /(?:^|\n)Failed to fetch [^\n]*:\s*\(\d+\)\s*Timeout fetching/iu.test(output);
11992
+ diagnosticLog.warn("fetch", "Codex webpage text unavailable", upstreamTimeout ? "upstream-timeout" : internalError ? "upstream-error" : !pageUrl ? "missing-source" : "empty-output");
11993
+ if (upstreamTimeout) throw new WebError("Codex webpage service timed out fetching this page. Try another page, or change the webpage provider in settings.", "WEB_FETCH_TIMEOUT");
11994
+ throw new WebError("Codex could not read this webpage. Try another page, or change the webpage provider in settings.", "WEB_PROVIDER_ERROR");
11995
+ }
11996
+ const lineCount = Number(metadata.match(/Total lines: (\d+)/u)?.[1]);
11997
+ const shownLines = new Set([...output.matchAll(/^L(\d+):/gmu)].map((match) => Number(match[1]))).size;
11998
+ const partialPage = Number.isSafeInteger(lineCount) && lineCount > 0 && shownLines > 0 && shownLines < lineCount;
11999
+ return {
12000
+ url: pageUrl,
12001
+ statusCode: 200,
12002
+ body: {
12003
+ kind: "text",
12004
+ content: output.slice(0, MAX_CONTENT)
11839
12005
  },
11840
- max_output_tokens: 4096
11841
- }),
11842
- signal: activeSignal
11843
- });
11844
- activeSignal.throwIfAborted();
11845
- if (!response.ok) {
11846
- const authFailure = await authFailureMessage(response);
11847
- throw new WebError(authFailure ?? `Codex webpage request failed (HTTP ${response.status})`, authFailure === "ChatGPT sign-in needs to be renewed" ? "WEB_PROVIDER_CREDENTIAL_MISSING" : "WEB_PROVIDER_ERROR");
12006
+ truncated: output.length > MAX_CONTENT || partialPage
12007
+ };
11848
12008
  }
11849
- const value = await response.json();
11850
- activeSignal.throwIfAborted();
11851
- const source = Array.isArray(value?.results) ? value.results.find((item) => httpUrl(item?.url) !== void 0 && item?.type !== "error" && item?.title !== "Internal Error") : void 0;
11852
- const output = typeof value?.output === "string" ? value.output : "";
11853
- const heading = output.split(/\r?\n/u, 1)[0].trim();
11854
- const headingUrl = heading.endsWith(")") ? httpUrl(heading.slice(heading.lastIndexOf(" (") + 2, -1)) : void 0;
11855
- const metadata = output.slice(0, 1024);
11856
- const pageUrl = source ? httpUrl(source.url) : headingUrl && /Content type:/u.test(metadata) && /Source: open\(/u.test(metadata) ? headingUrl : void 0;
11857
- if (!pageUrl || output.trim() === "" || /^Internal Error(?:\s|\()/iu.test(heading)) throw new WebError("Codex could not read this webpage", "WEB_PROVIDER_ERROR");
11858
- const lineCount = Number(metadata.match(/Total lines: (\d+)/u)?.[1]);
11859
- const shownLines = new Set([...output.matchAll(/^L(\d+):/gmu)].map((match) => Number(match[1]))).size;
11860
- const partialPage = Number.isSafeInteger(lineCount) && lineCount > 0 && shownLines > 0 && shownLines < lineCount;
11861
- return {
11862
- url: pageUrl,
11863
- statusCode: 200,
11864
- body: {
11865
- kind: "text",
11866
- content: output.slice(0, MAX_CONTENT)
11867
- },
11868
- truncated: output.length > MAX_CONTENT || partialPage
11869
- };
11870
12009
  } catch (error) {
11871
12010
  if (signal?.aborted || error?.name === "AbortError") throw new WebError("Codex webpage request aborted", "WEB_ABORTED");
11872
12011
  if (activeSignal.aborted) throw new WebError("Codex webpage request timed out", "WEB_FETCH_TIMEOUT");
@@ -11884,6 +12023,7 @@ function createCodexFetchRouter({ registry, configuredId, mode, codex }) {
11884
12023
  if (!wrappers.has(id)) wrappers.set(id, Object.freeze({
11885
12024
  id,
11886
12025
  available: () => mode() === "codex",
12026
+ ready: (llmProvider) => mode() === "codex" && (codex.ready?.(llmProvider) ?? true),
11887
12027
  fetch(request, signal) {
11888
12028
  if (mode() !== "codex") throw new WebError("Codex webpage reading is no longer selected", "WEB_PROVIDER_UNAVAILABLE");
11889
12029
  return codex.fetch(request, signal);
@@ -12259,6 +12399,7 @@ const actions = Object.freeze({
12259
12399
  "account/remove": "accounts",
12260
12400
  "preferences/update": "settings",
12261
12401
  "account/cleanup": "accounts",
12402
+ "predictions/generate": "predictions",
12262
12403
  usage: "quota",
12263
12404
  "preferences/models": "models",
12264
12405
  "storage/status": "storage",
@@ -12272,7 +12413,8 @@ const actions = Object.freeze({
12272
12413
  const QUIET = /* @__PURE__ */ new Set([
12273
12414
  "usage",
12274
12415
  "storage/status",
12275
- "preferences/models"
12416
+ "preferences/models",
12417
+ "predictions/generate"
12276
12418
  ]);
12277
12419
  function safeOperations(raw) {
12278
12420
  if (!Array.isArray(raw?.events)) return void 0;
@@ -12315,6 +12457,7 @@ function createDiagnosticOperations({ now = Date.now } = {}) {
12315
12457
  });
12316
12458
  if (status === "failed") diagnosticLog.error(actions[action], `${action} failed`);
12317
12459
  else if (status === "completed" && !QUIET.has(action)) diagnosticLog.info(actions[action], `${action} completed`);
12460
+ else if (status === "cancelled" && action === "predictions/generate") diagnosticLog.info("predictions", "predictions/generate cancelled");
12318
12461
  if (events.length > 32) {
12319
12462
  events.shift();
12320
12463
  dropped++;
@@ -12325,6 +12468,14 @@ function createDiagnosticOperations({ now = Date.now } = {}) {
12325
12468
  wrap: (handler) => async (endpoint, payload, signal) => {
12326
12469
  try {
12327
12470
  const result = await handler(endpoint, payload, signal);
12471
+ if (endpoint === "predictions/generate" && result?.ok === true) {
12472
+ const reason = {
12473
+ disabled: "disabled",
12474
+ authentication: "not signed in",
12475
+ unavailable: "not available"
12476
+ }[result.value?.reason];
12477
+ diagnosticLog.info("predictions", result.value?.prediction ? "suggestion ready" : `no suggestion${reason ? `: ${reason}` : ""}`);
12478
+ }
12328
12479
  record(endpoint, result?.ok === true ? "completed" : "failed");
12329
12480
  return result;
12330
12481
  } catch (error) {
@@ -12689,6 +12840,64 @@ function highestUsed(windows) {
12689
12840
  return values.length === 0 ? void 0 : Math.max(...values);
12690
12841
  }
12691
12842
  //#endregion
12843
+ //#region src/shared-request.js
12844
+ /** Share one fetch per key while each caller owns only its own wait. */
12845
+ function createSharedRequests() {
12846
+ const flights = /* @__PURE__ */ new Map();
12847
+ const cancelled = () => new DOMException("Shared request cancelled", "AbortError");
12848
+ return {
12849
+ has: (key) => flights.has(key),
12850
+ clear(reason = cancelled()) {
12851
+ const previous = [...flights.values()];
12852
+ flights.clear();
12853
+ for (const flight of previous) flight.controller.abort(reason);
12854
+ },
12855
+ run(key, work, signal) {
12856
+ signal?.throwIfAborted();
12857
+ let flight = flights.get(key);
12858
+ if (!flight) {
12859
+ const controller = new AbortController();
12860
+ flight = {
12861
+ controller,
12862
+ waiters: 0,
12863
+ settled: false
12864
+ };
12865
+ flight.promise = Promise.resolve().then(() => {
12866
+ controller.signal.throwIfAborted();
12867
+ return work(controller.signal);
12868
+ }).then((value) => {
12869
+ controller.signal.throwIfAborted();
12870
+ return value;
12871
+ }).finally(() => {
12872
+ flight.settled = true;
12873
+ if (flights.get(key) === flight) flights.delete(key);
12874
+ });
12875
+ flights.set(key, flight);
12876
+ }
12877
+ flight.waiters++;
12878
+ return new Promise((resolve, reject) => {
12879
+ let done = false;
12880
+ const finish = (callback, value) => {
12881
+ if (done) return;
12882
+ done = true;
12883
+ signal?.removeEventListener("abort", abort);
12884
+ flight.controller.signal.removeEventListener("abort", abort);
12885
+ if (--flight.waiters === 0 && !flight.settled) {
12886
+ if (flights.get(key) === flight) flights.delete(key);
12887
+ flight.controller.abort(cancelled());
12888
+ }
12889
+ callback(value);
12890
+ };
12891
+ const abort = () => finish(reject, signal?.aborted ? signal.reason : flight.controller.signal.reason);
12892
+ signal?.addEventListener("abort", abort, { once: true });
12893
+ flight.controller.signal.addEventListener("abort", abort, { once: true });
12894
+ flight.promise.then((value) => finish(resolve, value), (error) => finish(reject, error));
12895
+ if (signal?.aborted || flight.controller.signal.aborted) abort();
12896
+ });
12897
+ }
12898
+ };
12899
+ }
12900
+ //#endregion
12692
12901
  //#region src/usage.js
12693
12902
  const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
12694
12903
  const DEFAULT_TIMEOUT_MS$1 = 15e3;
@@ -12880,8 +13089,8 @@ function createCodexUsageReader(options) {
12880
13089
  const maxRetryAfterMs = options.maxRetryAfterMs ?? DEFAULT_MAX_RETRY_AFTER_MS;
12881
13090
  let cached;
12882
13091
  let failed;
12883
- let inFlight;
12884
13092
  let generation = 0;
13093
+ const requests = createSharedRequests();
12885
13094
  const load = async (signal) => {
12886
13095
  const { access, accountId } = await readSubscriptionCredentials(getAuth, readCredential, signal);
12887
13096
  if (typeof access !== "string" || access.length === 0 || typeof accountId !== "string" || accountId.length === 0) throw new Error("ChatGPT subscription is not signed in");
@@ -12915,36 +13124,37 @@ function createCodexUsageReader(options) {
12915
13124
  };
12916
13125
  return Object.freeze({
12917
13126
  read({ force = false, signal } = {}) {
13127
+ if (signal?.aborted) return Promise.reject(signal.reason);
12918
13128
  if (failed !== void 0 && now() < failed.retryAt) return Promise.reject(new Error(failed.message));
12919
13129
  if (!force && cached !== void 0 && now() - cached.fetchedAt < ttlFor(cached)) return Promise.resolve(structuredClone(cached));
12920
- if (inFlight !== void 0) return inFlight.then(structuredClone);
12921
- const currentGeneration = generation;
12922
- const current = load(signal).then((value) => {
12923
- if (generation === currentGeneration) {
12924
- cached = structuredClone(value);
12925
- failed = void 0;
12926
- }
12927
- return structuredClone(value);
12928
- }).catch((error) => {
12929
- if (generation === currentGeneration && error?.name !== "AbortError") {
12930
- const delay = Number.isFinite(error?.retryAfterMs) ? error.retryAfterMs : failureTtlMs;
12931
- failed = {
12932
- message: error instanceof Error ? error.message : "ChatGPT usage request failed",
12933
- retryAt: now() + delay
12934
- };
13130
+ return requests.run("read", async (sharedSignal) => {
13131
+ const currentGeneration = generation;
13132
+ try {
13133
+ const value = await load(sharedSignal);
13134
+ sharedSignal.throwIfAborted();
13135
+ if (generation === currentGeneration) {
13136
+ cached = structuredClone(value);
13137
+ failed = void 0;
13138
+ }
13139
+ return value;
13140
+ } catch (error) {
13141
+ sharedSignal.throwIfAborted();
13142
+ if (generation === currentGeneration && error?.name !== "AbortError") {
13143
+ const delay = Number.isFinite(error?.retryAfterMs) ? error.retryAfterMs : failureTtlMs;
13144
+ failed = {
13145
+ message: error instanceof Error ? error.message : "ChatGPT usage request failed",
13146
+ retryAt: now() + delay
13147
+ };
13148
+ }
13149
+ throw error;
12935
13150
  }
12936
- throw error;
12937
- }).finally(() => {
12938
- if (inFlight === current) inFlight = void 0;
12939
- });
12940
- inFlight = current;
12941
- return current;
13151
+ }, signal).then(structuredClone);
12942
13152
  },
12943
13153
  clear() {
12944
13154
  generation += 1;
12945
13155
  cached = void 0;
12946
13156
  failed = void 0;
12947
- inFlight = void 0;
13157
+ requests.clear();
12948
13158
  }
12949
13159
  });
12950
13160
  }
@@ -13103,7 +13313,8 @@ function parsePlanHistory(value) {
13103
13313
  }
13104
13314
  /** Reads one authenticated report through the same credentials as the quota reader; a 404 means the account has no such report. */
13105
13315
  function createReportReader({ url, parse, label, getAuth, readCredential, fetch: fetchReport = fetch, now = Date.now, ttlMs = TTL_MS }) {
13106
- let cached, failed, inFlight, generation = 0;
13316
+ let cached, failed, generation = 0;
13317
+ const requests = createSharedRequests();
13107
13318
  const load = async (signal) => {
13108
13319
  const { access, accountId } = await readSubscriptionCredentials(getAuth, readCredential, signal);
13109
13320
  if (typeof access !== "string" || access.length === 0 || typeof accountId !== "string" || accountId.length === 0) throw new Error("ChatGPT subscription is not signed in");
@@ -13139,33 +13350,34 @@ function createReportReader({ url, parse, label, getAuth, readCredential, fetch:
13139
13350
  };
13140
13351
  return Object.freeze({
13141
13352
  read({ force = false, signal } = {}) {
13353
+ if (signal?.aborted) return Promise.reject(signal.reason);
13142
13354
  if (failed !== void 0 && now() < failed.retryAt) return Promise.reject(new Error(failed.message));
13143
- if (inFlight !== void 0) return inFlight.then(structuredClone);
13144
- if (!force && cached !== void 0 && now() - cached.fetchedAt < ttlMs) return Promise.resolve(structuredClone(cached));
13145
- const current = generation;
13146
- const run = load(signal).then((value) => {
13147
- if (generation === current) {
13148
- cached = structuredClone(value);
13149
- failed = void 0;
13355
+ if (!requests.has("read") && !force && cached !== void 0 && now() - cached.fetchedAt < ttlMs) return Promise.resolve(structuredClone(cached));
13356
+ return requests.run("read", async (sharedSignal) => {
13357
+ const current = generation;
13358
+ try {
13359
+ const value = await load(sharedSignal);
13360
+ sharedSignal.throwIfAborted();
13361
+ if (generation === current) {
13362
+ cached = structuredClone(value);
13363
+ failed = void 0;
13364
+ }
13365
+ return value;
13366
+ } catch (error) {
13367
+ sharedSignal.throwIfAborted();
13368
+ if (generation === current && error?.name !== "AbortError") failed = {
13369
+ message: error instanceof Error ? error.message : `ChatGPT ${label} request failed`,
13370
+ retryAt: now() + FAILURE_TTL_MS
13371
+ };
13372
+ throw error;
13150
13373
  }
13151
- return structuredClone(value);
13152
- }).catch((error) => {
13153
- if (generation === current && error?.name !== "AbortError") failed = {
13154
- message: error instanceof Error ? error.message : `ChatGPT ${label} request failed`,
13155
- retryAt: now() + FAILURE_TTL_MS
13156
- };
13157
- throw error;
13158
- }).finally(() => {
13159
- if (inFlight === run) inFlight = void 0;
13160
- });
13161
- inFlight = run;
13162
- return run;
13374
+ }, signal).then(structuredClone);
13163
13375
  },
13164
13376
  clear() {
13165
13377
  generation += 1;
13166
13378
  cached = void 0;
13167
13379
  failed = void 0;
13168
- inFlight = void 0;
13380
+ requests.clear();
13169
13381
  }
13170
13382
  });
13171
13383
  }
@@ -14445,8 +14657,18 @@ async function settlesLive(preferences, patch, signal, { attempts = 8, delayMs =
14445
14657
  }
14446
14658
  return live();
14447
14659
  }
14448
- function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageReader, planHistoryReader, usageProfileReader, resetCreditService, preferences, defaultModel, runtimeManagement, remoteControl, desktopVoice, nativeVoice, voicePreview, diagnosticsReader, modelCatalog, originalImages, resolveInheritedOriginal, closeConnections, onAccountChanged, onCleanupFailure }) {
14660
+ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageReader, planHistoryReader, usageProfileReader, resetCreditService, preferences, defaultModel, runtimeManagement, remoteControl, desktopVoice, nativeVoice, voicePreview, composerPredictions, diagnosticsReader, modelCatalog, originalImages, resolveInheritedOriginal, closeConnections, onAccountChanged, onCleanupFailure }) {
14449
14661
  return async (endpoint, payload, signal) => {
14662
+ if (endpoint === "predictions/generate") try {
14663
+ signal?.throwIfAborted();
14664
+ return {
14665
+ ok: true,
14666
+ value: composerPredictions ? await composerPredictions.generate(payload, signal) : { prediction: null }
14667
+ };
14668
+ } catch (error) {
14669
+ if (signal?.aborted) throw error;
14670
+ return publicError(error?.code === "invalid-input" ? "invalid-input" : "operation-error", "Could not generate an input prediction");
14671
+ }
14450
14672
  if (endpoint.startsWith("voice/native/")) try {
14451
14673
  signal.throwIfAborted();
14452
14674
  if (!nativeVoice) return publicError("voice-native-unavailable", "Native voice is unavailable");
@@ -14497,12 +14719,12 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
14497
14719
  if (signal.aborted) throw error;
14498
14720
  return publicError(error?.code === "voice-native-unavailable" ? "voice-native-unavailable" : "operation-error", "Could not use native voice");
14499
14721
  }
14500
- if (endpoint === "default-model/status" || endpoint === "default-model/select") try {
14722
+ if (endpoint === "default-model/status" || endpoint === "default-model/select" || endpoint === "default-model/reset") try {
14501
14723
  signal.throwIfAborted();
14502
14724
  if (!defaultModel) return publicError("unavailable", "The default model is unavailable");
14503
14725
  return {
14504
14726
  ok: true,
14505
- value: endpoint === "default-model/status" ? defaultModel.status() : await defaultModel.select({ model: payload?.model })
14727
+ value: endpoint === "default-model/status" ? defaultModel.status() : endpoint === "default-model/reset" ? await defaultModel.reset() : await defaultModel.select({ model: payload?.model })
14506
14728
  };
14507
14729
  } catch (error) {
14508
14730
  if (signal.aborted) throw error;
@@ -14850,86 +15072,365 @@ function createSubscriptionRpcHandler({ authHandler, usageReader, accountUsageRe
14850
15072
  }
14851
15073
  //#endregion
14852
15074
  //#region src/voice-preview.js
14853
- const BASE = "https://chatgpt.com/backend-api";
15075
+ const BASE$1 = "https://chatgpt.com/backend-api";
14854
15076
  const CATALOG_TTL_MS = 10 * 6e4;
14855
15077
  const MAX_CLIP_BYTES = 2 * 1024 * 1024;
15078
+ const MAX_CACHED_AUDIO_BYTES = 8 * 1024 * 1024;
14856
15079
  const PREVIEW_HOSTS = /^https:\/\/[a-z0-9.-]*oaistatic\.com\//u;
14857
15080
  const failure$1 = (code, message) => Object.assign(new Error(message), { code });
14858
- function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, base = BASE }) {
15081
+ function createVoicePreview({ fetch, credentials, userAgent, now = Date.now, base = BASE$1, maxCachedAudioBytes = MAX_CACHED_AUDIO_BYTES }) {
14859
15082
  const catalogs = /* @__PURE__ */ new Map();
14860
15083
  const clips = /* @__PURE__ */ new Map();
15084
+ const requests = createSharedRequests();
15085
+ const cacheLimit = Number.isSafeInteger(maxCachedAudioBytes) && maxCachedAudioBytes >= 0 ? maxCachedAudioBytes : MAX_CACHED_AUDIO_BYTES;
15086
+ let accountId, generation = 0, audioBytes = 0;
14861
15087
  const languageOf = (value) => {
14862
15088
  const language = normalizeVoiceLanguage(value);
14863
15089
  return language === "auto" ? "en" : language;
14864
15090
  };
14865
- const readCatalog = async (language, signal) => {
15091
+ const cancelled = () => new DOMException("Voice preview scope changed", "AbortError");
15092
+ const clear = () => {
15093
+ generation++;
15094
+ accountId = void 0;
15095
+ catalogs.clear();
15096
+ clips.clear();
15097
+ audioBytes = 0;
15098
+ requests.clear(cancelled());
15099
+ };
15100
+ const scope = async (signal) => {
15101
+ signal?.throwIfAborted();
15102
+ const current = generation, auth = await credentials(signal);
14866
15103
  signal?.throwIfAborted();
15104
+ if (current !== generation) throw cancelled();
15105
+ if (!auth?.access || !auth.accountId) {
15106
+ clear();
15107
+ throw failure$1("voice-auth", "ChatGPT sign-in is required");
15108
+ }
15109
+ if (accountId !== void 0 && accountId !== auth.accountId) clear();
15110
+ accountId = auth.accountId;
15111
+ return {
15112
+ ...auth,
15113
+ generation
15114
+ };
15115
+ };
15116
+ const readCatalog = async (auth, language, signal) => {
15117
+ signal?.throwIfAborted();
15118
+ if (auth.generation !== generation) throw cancelled();
14867
15119
  const catalog = catalogs.get(language);
14868
15120
  if (catalog && now() - catalog.at < CATALOG_TTL_MS) return catalog.voices;
14869
- let value;
14870
- try {
14871
- const { access, accountId } = await credentials(signal);
14872
- if (!access || !accountId) throw failure$1("voice-auth", "ChatGPT sign-in is required");
14873
- const response = await fetch(`${base}/settings/voices?spoken_language=${language}`, {
14874
- headers: {
14875
- authorization: `Bearer ${access}`,
14876
- "chatgpt-account-id": accountId,
14877
- accept: "application/json",
14878
- "user-agent": userAgent
14879
- },
14880
- signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(15e3)]) : AbortSignal.timeout(15e3)
15121
+ return requests.run(`catalog:${language}`, async (sharedSignal) => {
15122
+ let value;
15123
+ try {
15124
+ const response = await fetch(`${base}/settings/voices?spoken_language=${language}`, {
15125
+ headers: {
15126
+ authorization: `Bearer ${auth.access}`,
15127
+ "chatgpt-account-id": auth.accountId,
15128
+ accept: "application/json",
15129
+ "user-agent": userAgent
15130
+ },
15131
+ signal: AbortSignal.any([sharedSignal, AbortSignal.timeout(15e3)])
15132
+ });
15133
+ if (response.status === 401) throw failure$1("voice-auth", "ChatGPT sign-in needs renewal");
15134
+ if (!response.ok) throw failure$1("voice-catalog", `voice catalog HTTP ${response.status}`);
15135
+ value = await response.json();
15136
+ if (!Array.isArray(value?.voices)) throw failure$1("voice-catalog", "Invalid voice catalog");
15137
+ sharedSignal.throwIfAborted();
15138
+ } catch (error) {
15139
+ sharedSignal.throwIfAborted();
15140
+ if (error?.code === "voice-auth" || error?.code === "voice-catalog") throw error;
15141
+ throw failure$1("voice-catalog", "Could not load the voice catalog");
15142
+ }
15143
+ const voices = (Array.isArray(value?.voices) ? value.voices : []).filter((entry) => typeof entry?.name === "string" && typeof entry?.preview_url === "string" && PREVIEW_HOSTS.test(entry.preview_url));
15144
+ if (auth.generation !== generation) throw cancelled();
15145
+ catalogs.set(language, {
15146
+ at: now(),
15147
+ voices
14881
15148
  });
14882
- if (response.status === 401) throw failure$1("voice-auth", "ChatGPT sign-in needs renewal");
14883
- if (!response.ok) throw failure$1("voice-catalog", `voice catalog HTTP ${response.status}`);
14884
- value = await response.json();
14885
- if (!Array.isArray(value?.voices)) throw failure$1("voice-catalog", "Invalid voice catalog");
14886
- signal?.throwIfAborted();
14887
- } catch (error) {
14888
- signal?.throwIfAborted();
14889
- if (error?.code === "voice-auth" || error?.code === "voice-catalog") throw error;
14890
- throw failure$1("voice-catalog", "Could not load the voice catalog");
14891
- }
14892
- const voices = (Array.isArray(value?.voices) ? value.voices : []).filter((entry) => typeof entry?.name === "string" && typeof entry?.preview_url === "string" && PREVIEW_HOSTS.test(entry.preview_url));
14893
- catalogs.set(language, {
14894
- at: now(),
14895
- voices
14896
- });
14897
- return voices;
15149
+ return voices;
15150
+ }, signal);
14898
15151
  };
14899
15152
  return {
15153
+ clear,
14900
15154
  /** Which voices ChatGPT's own catalog offers right now (lower-case names), so the settings can mark the others unavailable. */
14901
15155
  async available(language, signal) {
14902
- return (await readCatalog(languageOf(language), signal)).map((entry) => entry.name.toLowerCase());
15156
+ const auth = await scope(signal);
15157
+ const voices = await readCatalog(auth, languageOf(language), signal);
15158
+ signal?.throwIfAborted();
15159
+ if (auth.generation !== generation) throw cancelled();
15160
+ return voices.map((entry) => entry.name.toLowerCase());
14903
15161
  },
14904
15162
  /** The clip of one voice (by its Codex name, e.g. "spruce") as a data URL, with the catalog's description. */
14905
15163
  async preview(voice, selectedLanguage, signal) {
14906
15164
  signal?.throwIfAborted();
14907
15165
  if (typeof voice !== "string" || !/^[a-z]{2,16}$/u.test(voice)) return void 0;
15166
+ const auth = await scope(signal);
14908
15167
  const language = languageOf(selectedLanguage);
14909
- const key = `${language}:${voice}`;
14910
- if (clips.has(key)) return clips.get(key);
14911
- const entry = (await readCatalog(language, signal)).find((item) => item.name.toLowerCase() === voice || item.voice === voice);
15168
+ const entry = (await readCatalog(auth, language, signal)).find((item) => item.name.toLowerCase() === voice || item.voice === voice);
15169
+ signal?.throwIfAborted();
15170
+ if (auth.generation !== generation) throw cancelled();
14912
15171
  if (!entry) return void 0;
14913
- let bytes;
14914
- try {
14915
- const response = await fetch(entry.preview_url, { signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(15e3)]) : AbortSignal.timeout(15e3) });
14916
- if (!response.ok) throw failure$1("voice-download", `voice sample HTTP ${response.status}`);
14917
- bytes = Buffer.from(await response.arrayBuffer());
14918
- if (bytes.byteLength === 0 || bytes.byteLength > MAX_CLIP_BYTES) throw failure$1("voice-download", "voice sample has an unexpected size");
14919
- signal?.throwIfAborted();
14920
- } catch {
14921
- signal?.throwIfAborted();
14922
- throw failure$1("voice-download", "Could not download the voice sample");
14923
- }
14924
- const type = /\.mp3(?:$|\?)/u.test(entry.preview_url) ? "audio/mpeg" : "audio/mp4";
14925
- const result = {
15172
+ const key = `${language}:${voice}:${entry.preview_url}`;
15173
+ let audio = clips.get(key);
15174
+ if (audio) {
15175
+ clips.delete(key);
15176
+ clips.set(key, audio);
15177
+ } else audio = await requests.run(`clip:${key}`, async (sharedSignal) => {
15178
+ let bytes;
15179
+ try {
15180
+ const response = await fetch(entry.preview_url, { signal: AbortSignal.any([sharedSignal, AbortSignal.timeout(15e3)]) });
15181
+ if (!response.ok) throw failure$1("voice-download", `voice sample HTTP ${response.status}`);
15182
+ bytes = Buffer.from(await response.arrayBuffer());
15183
+ if (bytes.byteLength === 0 || bytes.byteLength > MAX_CLIP_BYTES) throw failure$1("voice-download", "voice sample has an unexpected size");
15184
+ sharedSignal.throwIfAborted();
15185
+ } catch {
15186
+ sharedSignal.throwIfAborted();
15187
+ throw failure$1("voice-download", "Could not download the voice sample");
15188
+ }
15189
+ const value = `data:${/\.mp3(?:$|\?)/u.test(entry.preview_url) ? "audio/mpeg" : "audio/mp4"};base64,${bytes.toString("base64")}`;
15190
+ if (auth.generation !== generation) throw cancelled();
15191
+ if (value.length <= cacheLimit) {
15192
+ while (clips.size >= 40 || audioBytes + value.length > cacheLimit) {
15193
+ const oldest = clips.keys().next().value;
15194
+ if (oldest === void 0) break;
15195
+ audioBytes -= clips.get(oldest).length;
15196
+ clips.delete(oldest);
15197
+ }
15198
+ clips.set(key, value);
15199
+ audioBytes += value.length;
15200
+ }
15201
+ return value;
15202
+ }, signal);
15203
+ signal?.throwIfAborted();
15204
+ if (auth.generation !== generation) throw cancelled();
15205
+ return {
14926
15206
  name: entry.name,
14927
15207
  description: typeof entry.description === "string" ? entry.description.slice(0, 120) : "",
14928
15208
  accent: typeof entry.accent === "string" ? entry.accent.slice(0, 60) : "",
14929
- audio: `data:${type};base64,${bytes.toString("base64")}`
15209
+ audio
14930
15210
  };
14931
- if (clips.size < 40) clips.set(key, result);
14932
- return result;
15211
+ }
15212
+ };
15213
+ }
15214
+ //#endregion
15215
+ //#region src/composer-predictions.js
15216
+ const BASE = "https://chatgpt.com/backend-api";
15217
+ const MODELS = /* @__PURE__ */ new Set([
15218
+ "gpt-6-astra",
15219
+ "gpt-6.1-sol",
15220
+ "gpt-6.1-terra"
15221
+ ]);
15222
+ const invalid = () => Object.assign(/* @__PURE__ */ new Error("Invalid prediction request"), { code: "invalid-input" });
15223
+ const cancelled = () => new DOMException("Prediction scope changed", "AbortError");
15224
+ function predictionInput(value) {
15225
+ if (!value || !MODELS.has(value.model) || typeof value.sessionId !== "string" || !value.sessionId || value.sessionId.length > 512 || typeof value.turnId !== "string" || !value.turnId || value.turnId.length > 512 || !Array.isArray(value.messages) || value.messages.length < 2 || value.messages.length > 12) throw invalid();
15226
+ let length = 0;
15227
+ const messages = value.messages.map((message) => {
15228
+ if (!message || !["user", "assistant"].includes(message.role) || typeof message.text !== "string" || !message.text.trim()) throw invalid();
15229
+ length += message.text.length;
15230
+ return {
15231
+ role: message.role,
15232
+ text: message.text
15233
+ };
15234
+ });
15235
+ if (length > 24e3 || messages.at(-1).role !== "assistant" || !messages.some((message) => message.role === "user")) throw invalid();
15236
+ return {
15237
+ sessionId: value.sessionId,
15238
+ turnId: value.turnId,
15239
+ model: value.model,
15240
+ messages
15241
+ };
15242
+ }
15243
+ async function boundedText(response, limit) {
15244
+ if (!response.body) throw new Error("Empty prediction response");
15245
+ const reader = response.body.getReader(), chunks = [];
15246
+ let size = 0;
15247
+ try {
15248
+ while (true) {
15249
+ const { value, done } = await reader.read();
15250
+ if (done) break;
15251
+ size += value.byteLength;
15252
+ if (size > limit) {
15253
+ await reader.cancel();
15254
+ throw new Error("Prediction response too large");
15255
+ }
15256
+ chunks.push(Buffer.from(value));
15257
+ }
15258
+ return Buffer.concat(chunks).toString("utf8");
15259
+ } finally {
15260
+ reader.releaseLock();
15261
+ }
15262
+ }
15263
+ function predictionText(sse) {
15264
+ let completed;
15265
+ for (const line of sse.split(/\r?\n/u)) {
15266
+ if (!line.startsWith("data: ") || line === "data: [DONE]") continue;
15267
+ const event = JSON.parse(line.slice(6));
15268
+ if (event.type === "error" || event.type === "response.failed" || event.type === "response.incomplete") throw new Error("Prediction generation failed");
15269
+ if (event.type === "response.completed") completed = event.response;
15270
+ }
15271
+ if (completed?.status !== "completed" || !Array.isArray(completed.output) || completed.output.some((item) => !["reasoning", "message"].includes(item.type))) throw new Error("Prediction did not complete as text");
15272
+ const text = completed.output.filter((item) => item.type === "message" && item.role === "assistant").flatMap((item) => item.content ?? []).filter((part) => part.type === "output_text").map((part) => part.text).join("");
15273
+ const result = JSON.parse(text);
15274
+ if (result.suggestion === null || result.suggestion === "") return null;
15275
+ if (typeof result.suggestion !== "string" || result.suggestion.length > 600 || /[\u0000-\u0008\u000b\u000c\u000e-\u001f]/u.test(result.suggestion)) throw new Error("Invalid prediction text");
15276
+ return result.suggestion.trim() || null;
15277
+ }
15278
+ /** Optional, isolated next-message inference. Never runs tools or mutates the source conversation. */
15279
+ function createComposerPredictions({ fetch, credentials, enabled, userAgent, now = Date.now, base = BASE, timeoutMs = 3e4 }) {
15280
+ const requests = createSharedRequests(), results = /* @__PURE__ */ new Map();
15281
+ let generation = 0, accountId, config;
15282
+ const clear = () => {
15283
+ generation++;
15284
+ accountId = void 0;
15285
+ config = void 0;
15286
+ results.clear();
15287
+ requests.clear(cancelled());
15288
+ };
15289
+ const active = (auth, signal) => {
15290
+ signal?.throwIfAborted();
15291
+ if (auth.generation !== generation || !enabled()) throw cancelled();
15292
+ };
15293
+ const headers = (auth) => ({
15294
+ authorization: `Bearer ${auth.access}`,
15295
+ "chatgpt-account-id": auth.accountId,
15296
+ "user-agent": userAgent
15297
+ });
15298
+ const configuration = async (auth, signal) => {
15299
+ active(auth, signal);
15300
+ if (config && now() - config.at < 3e5) return config.value;
15301
+ return requests.run("config", async (sharedSignal) => {
15302
+ const response = await fetch(`${base}/wham/predictions/config`, {
15303
+ redirect: "error",
15304
+ headers: {
15305
+ ...headers(auth),
15306
+ accept: "application/json"
15307
+ },
15308
+ signal: AbortSignal.any([sharedSignal, AbortSignal.timeout(15e3)])
15309
+ });
15310
+ if (!response.ok) {
15311
+ await response.body?.cancel();
15312
+ throw new Error("Prediction capability unavailable");
15313
+ }
15314
+ const value = JSON.parse(await boundedText(response, 32e3));
15315
+ if (typeof value?.is_enabled !== "boolean" || value.is_enabled && (typeof value.prompt !== "string" || !value.prompt || value.prompt.length > 16e3) || value.unsupported_models !== void 0 && (!Array.isArray(value.unsupported_models) || value.unsupported_models.some((model) => typeof model !== "string"))) throw new Error("Invalid prediction capability");
15316
+ active(auth, sharedSignal);
15317
+ config = {
15318
+ at: now(),
15319
+ value
15320
+ };
15321
+ return value;
15322
+ }, signal);
15323
+ };
15324
+ return {
15325
+ clear,
15326
+ async generate(raw, signal) {
15327
+ signal?.throwIfAborted();
15328
+ if (!enabled()) return {
15329
+ prediction: null,
15330
+ reason: "disabled"
15331
+ };
15332
+ const input = predictionInput(raw), initialGeneration = generation;
15333
+ const credential = await credentials(signal);
15334
+ signal?.throwIfAborted();
15335
+ if (initialGeneration !== generation) throw cancelled();
15336
+ if (!credential?.access || !credential.accountId) return {
15337
+ prediction: null,
15338
+ reason: "authentication"
15339
+ };
15340
+ if (accountId !== void 0 && credential.accountId !== accountId) clear();
15341
+ accountId = credential.accountId;
15342
+ const auth = {
15343
+ ...credential,
15344
+ generation
15345
+ };
15346
+ const cap = await configuration(auth, signal);
15347
+ active(auth, signal);
15348
+ if (!cap.is_enabled || cap.unsupported_models?.includes(input.model)) return {
15349
+ prediction: null,
15350
+ reason: "unavailable"
15351
+ };
15352
+ const key = createHash("sha256").update(JSON.stringify(input)).digest("hex");
15353
+ const cached = results.get(key);
15354
+ if (cached && now() - cached.at < 3e5) return { prediction: cached.prediction };
15355
+ return requests.run(`prediction:${key}`, async (sharedSignal) => {
15356
+ active(auth, sharedSignal);
15357
+ const metadata = JSON.stringify({
15358
+ thread_source: "composer_predictions",
15359
+ turn_trigger: "composer_predictions",
15360
+ model: input.model,
15361
+ prediction_source_thread_id: input.sessionId,
15362
+ prediction_source_turn_id: input.turnId,
15363
+ prediction_trigger: "live"
15364
+ });
15365
+ const effort = [
15366
+ "none",
15367
+ "minimal",
15368
+ "low",
15369
+ "medium",
15370
+ "high",
15371
+ "xhigh"
15372
+ ].includes(cap.prediction_reasoning_effort) ? cap.prediction_reasoning_effort : "high";
15373
+ const body = {
15374
+ model: input.model,
15375
+ instructions: "Predict a follow-up message from the user, using the conversation. Return only the requested JSON. Do not call tools or perform tasks.",
15376
+ input: [...input.messages.map((message) => ({
15377
+ role: message.role,
15378
+ content: [{
15379
+ type: message.role === "user" ? "input_text" : "output_text",
15380
+ text: message.text
15381
+ }]
15382
+ })), {
15383
+ role: "user",
15384
+ content: [{
15385
+ type: "input_text",
15386
+ text: cap.prompt
15387
+ }]
15388
+ }],
15389
+ reasoning: { effort },
15390
+ tools: [],
15391
+ tool_choice: "none",
15392
+ parallel_tool_calls: false,
15393
+ store: false,
15394
+ stream: true,
15395
+ include: ["reasoning.encrypted_content"],
15396
+ text: { format: {
15397
+ type: "json_schema",
15398
+ name: "composer_prediction",
15399
+ strict: true,
15400
+ schema: {
15401
+ type: "object",
15402
+ properties: { suggestion: { type: ["string", "null"] } },
15403
+ required: ["suggestion"],
15404
+ additionalProperties: false
15405
+ }
15406
+ } },
15407
+ client_metadata: { "x-codex-turn-metadata": metadata }
15408
+ };
15409
+ const response = await fetch(`${base}/codex/responses`, {
15410
+ method: "POST",
15411
+ redirect: "error",
15412
+ headers: {
15413
+ ...headers(auth),
15414
+ accept: "text/event-stream",
15415
+ "content-type": "application/json",
15416
+ "x-codex-turn-metadata": metadata
15417
+ },
15418
+ body: JSON.stringify(body),
15419
+ signal: AbortSignal.any([sharedSignal, AbortSignal.timeout(timeoutMs)])
15420
+ });
15421
+ if (!response.ok) {
15422
+ await response.body?.cancel();
15423
+ throw new Error(`Prediction request failed (HTTP ${response.status})`);
15424
+ }
15425
+ const prediction = predictionText(await boundedText(response, 1024 * 1024));
15426
+ active(auth, sharedSignal);
15427
+ if (results.size >= 32) results.delete(results.keys().next().value);
15428
+ results.set(key, {
15429
+ at: now(),
15430
+ prediction
15431
+ });
15432
+ return { prediction };
15433
+ }, signal);
14933
15434
  }
14934
15435
  };
14935
15436
  }
@@ -15751,12 +16252,7 @@ function apply(ctx, config = {}) {
15751
16252
  3e5
15752
16253
  ]
15753
16254
  });
15754
- let appendUltraPolicy;
15755
- try {
15756
- appendUltraPolicy = createRequire(import.meta.url)("@deepseek-ai/dsh-session").appendPluginRecord;
15757
- } catch (error) {
15758
- if (!(error?.code === "MODULE_NOT_FOUND" && error.message?.startsWith("Cannot find module '@deepseek-ai/dsh-session'"))) throw error;
15759
- }
16255
+ const appendUltraPolicy = loadHostSessionSdk()?.appendPluginRecord;
15760
16256
  const ultra = createUltraExecutionPreset({
15761
16257
  catalog: modelCatalog,
15762
16258
  resolveAgent: () => ctx.get?.("agents")?.currentInitiator?.(),
@@ -15767,6 +16263,7 @@ function apply(ctx, config = {}) {
15767
16263
  const connection = createSubscriptionConnection({ resolveMode: () => settings.get().connectionMode });
15768
16264
  const defaultModel = createDefaultModelController({
15769
16265
  resolveService: () => ctx.get?.("agentDefaultModel"),
16266
+ resolveEditor: () => ctx.get?.("configEditor"),
15770
16267
  listModels: () => modelCatalog.getModels().map((model) => model.id)
15771
16268
  });
15772
16269
  const accountScope = async () => {
@@ -15825,6 +16322,7 @@ function apply(ctx, config = {}) {
15825
16322
  connectionMode: settings.get().connectionMode ?? "sse",
15826
16323
  reviewModel: settings.get().reviewModel ?? "session",
15827
16324
  remoteControl: settings.get().remoteControl ?? "off",
16325
+ composerPredictions: settings.get().composerPredictions === "on" ? "on" : "off",
15828
16326
  otherModels: settings.get().otherModels === "off" ? "off" : "on",
15829
16327
  subagentBackend: settings.get().subagentBackend ?? "dsh",
15830
16328
  subagentBackendAvailable: subagentBackend !== void 0,
@@ -16074,7 +16572,7 @@ function apply(ctx, config = {}) {
16074
16572
  }, "codex-subscription: official model catalog");
16075
16573
  const currentAgent = () => ctx.get?.("agents")?.currentInitiator?.();
16076
16574
  const codexFetch = createCodexFetchProvider({
16077
- allowed: () => fetchRouted && (settings.get().otherModels !== "off" || currentAgent()?.session.requestContext?.()?.provider === PROVIDER),
16575
+ allowed: (llmProvider) => fetchRouted && (settings.get().otherModels !== "off" || (llmProvider ?? currentAgent()?.session.requestContext?.()?.provider) === PROVIDER),
16078
16576
  getAuth: resolveAuth,
16079
16577
  readCredential: (options) => store.read(PROVIDER, options),
16080
16578
  resolveModel: () => {
@@ -16126,7 +16624,7 @@ function apply(ctx, config = {}) {
16126
16624
  const realSearchProviders = ctx.web.searchProviders;
16127
16625
  const resolveDshSearch = () => realSearchProviders?.get(searchProvider.dshProviderId());
16128
16626
  const gateSearch = (provider) => gateSearchProvider(provider, {
16129
- allowed: () => settings.get().otherModels !== "off" || currentAgent()?.session.requestContext?.()?.provider === PROVIDER,
16627
+ allowed: (llmProvider) => settings.get().otherModels !== "off" || (llmProvider ?? currentAgent()?.session.requestContext?.()?.provider) === PROVIDER,
16130
16628
  resolveDshProvider: resolveDshSearch
16131
16629
  });
16132
16630
  const codexSearch = createCodexSearchProvider({
@@ -16144,6 +16642,7 @@ function apply(ctx, config = {}) {
16144
16642
  const tracedCodexSearch = gateSearch({
16145
16643
  id: codexSearch.id,
16146
16644
  available: () => codexSearch.available(),
16645
+ ready: (llmProvider) => codexSearch.ready(llmProvider),
16147
16646
  async search(request, signal) {
16148
16647
  const result = await codexSearch.search(request, signal);
16149
16648
  searchTrace("answered by Codex subscription");
@@ -16434,6 +16933,28 @@ function apply(ctx, config = {}) {
16434
16933
  close();
16435
16934
  };
16436
16935
  });
16936
+ const voicePreview = createVoicePreview({
16937
+ fetch: (input, init) => network.fetch("voice", input, init, { standardHttps: true }),
16938
+ credentials: (signal) => readSubscriptionCredentials(resolveAuth, (options) => store.read(PROVIDER, {
16939
+ ...options,
16940
+ signal
16941
+ }), signal),
16942
+ userAgent: USER_AGENT
16943
+ });
16944
+ ctx.effect(() => () => voicePreview.clear());
16945
+ const composerPredictions = createComposerPredictions({
16946
+ fetch: (input, init) => network.fetch("predictions", input, init, { standardHttps: true }),
16947
+ credentials: (signal) => readSubscriptionCredentials(resolveAuth, (options) => store.read(PROVIDER, {
16948
+ ...options,
16949
+ signal
16950
+ }), signal),
16951
+ enabled: () => settings.get().composerPredictions === "on",
16952
+ userAgent: USER_AGENT
16953
+ });
16954
+ ctx.effect(() => () => composerPredictions.clear());
16955
+ ctx.effect(() => settings.watch((value) => {
16956
+ if (value.composerPredictions !== "on") composerPredictions.clear();
16957
+ }));
16437
16958
  const subscriptionHandler = createSubscriptionRpcHandler({
16438
16959
  authHandler: createCodexRpcHandler(coordinator, { openExternal: openCodexAuthUrl }),
16439
16960
  usageReader,
@@ -16447,17 +16968,13 @@ function apply(ctx, config = {}) {
16447
16968
  remoteControl,
16448
16969
  desktopVoice,
16449
16970
  nativeVoice,
16450
- voicePreview: createVoicePreview({
16451
- fetch: (input, init) => network.fetch("voice", input, init, { standardHttps: true }),
16452
- credentials: (signal) => readSubscriptionCredentials(resolveAuth, (options) => store.read(PROVIDER, {
16453
- ...options,
16454
- signal
16455
- }), signal),
16456
- userAgent: USER_AGENT
16457
- }),
16971
+ voicePreview,
16972
+ composerPredictions,
16458
16973
  onAccountChanged: () => {
16459
16974
  connectorsClient.clear();
16460
16975
  usageProfileReader.clear();
16976
+ voicePreview.clear();
16977
+ composerPredictions.clear();
16461
16978
  quotaRetryHandler.notifyAccountChanged();
16462
16979
  },
16463
16980
  diagnosticsReader: () => createSubscriptionDiagnostics({