@karlorz/codexhost-cli-win32-x64 0.13.3-5 → 0.13.3-6

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.
@@ -6,149 +6,6 @@
6
6
  __defProp(target, name, { get: all[name], enumerable: true });
7
7
  };
8
8
 
9
- // src/renderer-cpa-live-voice-preference.ts
10
- var CPA_LIVE_VOICE_STORAGE_KEY = "codexhost.cpa-live-voice.v1";
11
- function cpaLiveVoicePreferenceAllowsInstall(globalObject) {
12
- const storage = globalObject.localStorage;
13
- if (!storage) return true;
14
- try {
15
- return storage.getItem(CPA_LIVE_VOICE_STORAGE_KEY) !== "0";
16
- } catch {
17
- return true;
18
- }
19
- }
20
-
21
- // src/renderer-cpa-live-voice-hook.ts
22
- var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
23
- var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
24
- var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
25
- var THREAD_REALTIME_EXISTING_CALL_GATE = "206132468";
26
- var originalCheckGate = /* @__PURE__ */ new WeakMap();
27
- var DISCOVERY_TIMEOUT_MS = 6e4;
28
- function isRecord(value) {
29
- return typeof value === "object" && value !== null;
30
- }
31
- function readCpaLiveVoiceHookConfig(globalObject) {
32
- const value = globalObject[CPA_LIVE_VOICE_HOOK_GLOBAL];
33
- if (!isRecord(value) || value.enabled !== true) return null;
34
- if (typeof value.auditedDesktopVersion !== "string" || typeof value.auditedAppInitialAsset !== "string") {
35
- return null;
36
- }
37
- return {
38
- enabled: true,
39
- auditedDesktopVersion: value.auditedDesktopVersion,
40
- auditedAppInitialAsset: value.auditedAppInitialAsset,
41
- ...typeof value.desktopVersion === "string" ? { desktopVersion: value.desktopVersion } : {}
42
- };
43
- }
44
- function auditedAppInitialAssetPresent(resourceNames, asset) {
45
- return resourceNames.some((name) => {
46
- try {
47
- const url2 = new URL(name, "app://-/");
48
- return url2.protocol === "app:" && url2.hostname === "-" && url2.pathname === `/assets/${asset}`;
49
- } catch {
50
- return false;
51
- }
52
- });
53
- }
54
- function resourceNamesFromPerformance(source) {
55
- const target = source ?? (typeof performance === "undefined" ? void 0 : performance);
56
- if (!target || typeof target.getEntriesByType !== "function") return [];
57
- return target.getEntriesByType("resource").map((entry) => entry.name).filter((name) => typeof name === "string");
58
- }
59
- function loadedAssetNames(root, performanceSource) {
60
- const names = resourceNamesFromPerformance(performanceSource);
61
- if (!root || !("querySelectorAll" in root)) return names;
62
- for (const element of root.querySelectorAll("script[src], link[href]")) {
63
- const value = element.getAttribute("src") ?? element.getAttribute("href");
64
- if (value) names.push(value);
65
- }
66
- return names;
67
- }
68
- function statsigClients(globalObject) {
69
- const registry2 = globalObject.__STATSIG__;
70
- if (!isRecord(registry2)) return [];
71
- const clients = new Set(
72
- isRecord(registry2.instances) ? Object.values(registry2.instances) : []
73
- );
74
- if (registry2.firstInstance) clients.add(registry2.firstInstance);
75
- return [...clients].filter(
76
- (client) => isRecord(client) && typeof client.checkGate === "function"
77
- );
78
- }
79
- function wrapCheckGate(client) {
80
- if (originalCheckGate.has(client)) return false;
81
- const original = client.checkGate;
82
- originalCheckGate.set(client, original);
83
- client.checkGate = function(name, ...rest) {
84
- return name === THREAD_REALTIME_EXISTING_CALL_GATE ? false : original.call(this, name, ...rest);
85
- };
86
- return true;
87
- }
88
- function restoreCheckGate(client) {
89
- const original = originalCheckGate.get(client);
90
- if (!original) return;
91
- client.checkGate = original;
92
- originalCheckGate.delete(client);
93
- }
94
- function configAllowsInstall(config2, resourceNames) {
95
- if (config2.desktopVersion !== void 0 && config2.desktopVersion !== config2.auditedDesktopVersion) {
96
- return false;
97
- }
98
- if (config2.auditedDesktopVersion !== AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION) return false;
99
- if (config2.auditedAppInitialAsset !== AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET) return false;
100
- return auditedAppInitialAssetPresent(resourceNames, config2.auditedAppInitialAsset);
101
- }
102
- function installCpaLiveVoiceHook(options = {}) {
103
- const globalObject = options.globalThis ?? globalThis;
104
- const config2 = options.config === void 0 ? readCpaLiveVoiceHookConfig(globalObject) : options.config;
105
- if (!config2?.enabled || !cpaLiveVoicePreferenceAllowsInstall(globalObject)) {
106
- return { status: "disabled", dispose() {
107
- } };
108
- }
109
- const root = options.document ?? globalObject.document;
110
- const wrapped = [];
111
- let disposed = false;
112
- let auditedAssetFound = false;
113
- const handle = {
114
- status: "pending",
115
- dispose() {
116
- disposed = true;
117
- for (const client of wrapped) restoreCheckGate(client);
118
- wrapped.length = 0;
119
- }
120
- };
121
- const attempt = () => {
122
- if (!auditedAssetFound) {
123
- const resourceNames = options.resourceNames ?? loadedAssetNames(root);
124
- auditedAssetFound = configAllowsInstall(config2, resourceNames);
125
- if (!auditedAssetFound) return false;
126
- }
127
- for (const client of statsigClients(globalObject)) {
128
- if (wrapCheckGate(client)) wrapped.push(client);
129
- }
130
- if (wrapped.length === 0) return false;
131
- handle.status = "active";
132
- return true;
133
- };
134
- if (attempt()) return handle;
135
- if (options.resourceNames && !configAllowsInstall(config2, options.resourceNames)) {
136
- handle.status = "unsupported";
137
- return handle;
138
- }
139
- const started = Date.now();
140
- const tick = () => {
141
- if (disposed || attempt()) return;
142
- if (Date.now() - started > DISCOVERY_TIMEOUT_MS) {
143
- handle.status = "unsupported";
144
- return;
145
- }
146
- globalThis.setTimeout(tick, 250);
147
- };
148
- globalThis.setTimeout(tick, 250);
149
- return handle;
150
- }
151
-
152
9
  // ../../node_modules/zod/v4/classic/external.js
153
10
  var external_exports = {};
154
11
  __export(external_exports, {
@@ -14980,6 +14837,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14980
14837
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
14981
14838
  });
14982
14839
  var CONSOLE_HOST_METHODS = Object.freeze([
14840
+ "codexhost/voice/gateway-status",
14983
14841
  "codexhost/console/remote-connections",
14984
14842
  "codexhost/runtime/status",
14985
14843
  "codexhost/remote/ssh-setup",
@@ -16084,9 +15942,250 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16084
15942
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16085
15943
  ]);
16086
15944
 
15945
+ // ../shared-contracts/dist/voice-settings.js
15946
+ var voiceRoutesSchema = external_exports.strictObject({
15947
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
15948
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
15949
+ workConnection: external_exports.enum(["desktop", "gateway"])
15950
+ });
15951
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
15952
+ chatExperience: "chatgpt",
15953
+ chatConnection: "desktop",
15954
+ workConnection: "gateway"
15955
+ });
15956
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
15957
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
15958
+ external_exports.strictObject({
15959
+ operation: external_exports.literal("get"),
15960
+ runtime: external_exports.strictObject({
15961
+ id: external_exports.string().uuid(),
15962
+ revision: external_exports.string().max(64),
15963
+ activeCall: external_exports.boolean()
15964
+ }).optional()
15965
+ }),
15966
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
15967
+ external_exports.strictObject({
15968
+ operation: external_exports.literal("set"),
15969
+ settings: voiceSettingsSchema,
15970
+ revision: external_exports.string().max(64)
15971
+ }),
15972
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
15973
+ ]);
15974
+ var voiceSettingsStateSchema = external_exports.strictObject({
15975
+ settings: voiceSettingsSchema,
15976
+ initialized: external_exports.boolean(),
15977
+ revision: external_exports.string(),
15978
+ activeInject: external_exports.boolean().nullable(),
15979
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
15980
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
15981
+ routesActive: external_exports.boolean().nullable(),
15982
+ activeCall: external_exports.boolean().nullable(),
15983
+ gatewayReady: external_exports.boolean().nullable(),
15984
+ restartAvailable: external_exports.boolean(),
15985
+ restart: external_exports.strictObject({
15986
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
15987
+ error: external_exports.string().nullable()
15988
+ })
15989
+ });
15990
+
16087
15991
  // ../shared-contracts/dist/index.js
16088
15992
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16089
15993
 
15994
+ // src/renderer-cpa-live-voice-preference.ts
15995
+ var sharedRoutes = /* @__PURE__ */ new WeakMap();
15996
+ var SHARED_VOICE_CACHE = "codexhost.voice-routes-cache.v1";
15997
+ function cachedRoutes(owner) {
15998
+ const memory = sharedRoutes.get(owner);
15999
+ if (memory) return memory;
16000
+ try {
16001
+ const storage = owner.localStorage;
16002
+ const parsed = voiceRoutesSchema.safeParse(
16003
+ JSON.parse(storage?.getItem(SHARED_VOICE_CACHE) ?? "null")
16004
+ ).data;
16005
+ if (parsed) sharedRoutes.set(owner, parsed);
16006
+ return parsed;
16007
+ } catch {
16008
+ return void 0;
16009
+ }
16010
+ }
16011
+ var CPA_LIVE_VOICE_STORAGE_KEY = "codexhost.cpa-live-voice.v1";
16012
+ var CHAT_LIVE_VOICE_STORAGE_KEY = "codexhost.chat-live-voice.v1";
16013
+ function readFlag(owner, key, enabledWhenUnset) {
16014
+ const storage = owner.localStorage;
16015
+ if (!storage) return enabledWhenUnset;
16016
+ try {
16017
+ const value = storage.getItem(key);
16018
+ return enabledWhenUnset ? value !== "0" : value === "1";
16019
+ } catch {
16020
+ return enabledWhenUnset;
16021
+ }
16022
+ }
16023
+ function readCpaLiveVoicePreference(owner) {
16024
+ const routes = cachedRoutes(owner);
16025
+ return routes ? routes.workConnection === "gateway" : readFlag(owner, CPA_LIVE_VOICE_STORAGE_KEY, true);
16026
+ }
16027
+ function readChatLiveVoicePreference(owner) {
16028
+ const routes = cachedRoutes(owner);
16029
+ return routes ? routes.chatExperience === "codex" && routes.chatConnection === "gateway" : readFlag(owner, CHAT_LIVE_VOICE_STORAGE_KEY, false);
16030
+ }
16031
+ function cpaLiveVoicePreferenceAllowsInstall(globalObject) {
16032
+ return readCpaLiveVoicePreference(globalObject);
16033
+ }
16034
+ function chatLiveVoicePreferenceAllowsOverride(globalObject) {
16035
+ return readChatLiveVoicePreference(globalObject);
16036
+ }
16037
+
16038
+ // src/renderer-cpa-live-voice-hook.ts
16039
+ var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
16040
+ var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
16041
+ var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
16042
+ var THREAD_REALTIME_EXISTING_CALL_GATE = "206132468";
16043
+ var originalCheckGate = /* @__PURE__ */ new WeakMap();
16044
+ var DISCOVERY_TIMEOUT_MS = 6e4;
16045
+ function isRecord(value) {
16046
+ return typeof value === "object" && value !== null;
16047
+ }
16048
+ function readCpaLiveVoiceHookConfig(globalObject) {
16049
+ const value = globalObject[CPA_LIVE_VOICE_HOOK_GLOBAL];
16050
+ if (!isRecord(value) || value.enabled !== true) return null;
16051
+ if (typeof value.auditedDesktopVersion !== "string" || typeof value.auditedAppInitialAsset !== "string") {
16052
+ return null;
16053
+ }
16054
+ return {
16055
+ enabled: true,
16056
+ auditedDesktopVersion: value.auditedDesktopVersion,
16057
+ auditedAppInitialAsset: value.auditedAppInitialAsset,
16058
+ ...typeof value.desktopVersion === "string" ? { desktopVersion: value.desktopVersion } : {}
16059
+ };
16060
+ }
16061
+ function auditedAppInitialAssetPresent(resourceNames, asset) {
16062
+ return resourceNames.some((name) => {
16063
+ try {
16064
+ const url2 = new URL(name, "app://-/");
16065
+ return url2.protocol === "app:" && url2.hostname === "-" && url2.pathname === `/assets/${asset}`;
16066
+ } catch {
16067
+ return false;
16068
+ }
16069
+ });
16070
+ }
16071
+ function resourceNamesFromPerformance(source) {
16072
+ const target = source ?? (typeof performance === "undefined" ? void 0 : performance);
16073
+ if (!target || typeof target.getEntriesByType !== "function") return [];
16074
+ return target.getEntriesByType("resource").map((entry) => entry.name).filter((name) => typeof name === "string");
16075
+ }
16076
+ function loadedAssetNames(root, performanceSource) {
16077
+ const names = resourceNamesFromPerformance(performanceSource);
16078
+ if (!root || !("querySelectorAll" in root)) return names;
16079
+ for (const element of root.querySelectorAll("script[src], link[href]")) {
16080
+ const value = element.getAttribute("src") ?? element.getAttribute("href");
16081
+ if (value) names.push(value);
16082
+ }
16083
+ return names;
16084
+ }
16085
+ function statsigClients(globalObject) {
16086
+ const registry2 = globalObject.__STATSIG__;
16087
+ if (!isRecord(registry2)) return [];
16088
+ const clients = new Set(
16089
+ isRecord(registry2.instances) ? Object.values(registry2.instances) : []
16090
+ );
16091
+ if (registry2.firstInstance) clients.add(registry2.firstInstance);
16092
+ return [...clients].filter(
16093
+ (client) => isRecord(client) && typeof client.checkGate === "function"
16094
+ );
16095
+ }
16096
+ function wrapCheckGate(client) {
16097
+ if (originalCheckGate.has(client)) return false;
16098
+ const original = client.checkGate;
16099
+ originalCheckGate.set(client, original);
16100
+ client.checkGate = function(name, ...rest) {
16101
+ return name === THREAD_REALTIME_EXISTING_CALL_GATE ? false : original.call(this, name, ...rest);
16102
+ };
16103
+ return true;
16104
+ }
16105
+ function restoreCheckGate(client) {
16106
+ const original = originalCheckGate.get(client);
16107
+ if (!original) return;
16108
+ client.checkGate = original;
16109
+ originalCheckGate.delete(client);
16110
+ }
16111
+ function configAllowsInstall(config2, resourceNames) {
16112
+ if (config2.desktopVersion !== void 0 && config2.desktopVersion !== config2.auditedDesktopVersion) {
16113
+ return false;
16114
+ }
16115
+ if (config2.auditedDesktopVersion !== AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION) return false;
16116
+ if (config2.auditedAppInitialAsset !== AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET) return false;
16117
+ return auditedAppInitialAssetPresent(resourceNames, config2.auditedAppInitialAsset);
16118
+ }
16119
+ function installCpaLiveVoiceHook(options = {}) {
16120
+ const globalObject = options.globalThis ?? globalThis;
16121
+ const config2 = options.config === void 0 ? readCpaLiveVoiceHookConfig(globalObject) : options.config;
16122
+ if (!config2?.enabled || !cpaLiveVoicePreferenceAllowsInstall(globalObject)) {
16123
+ return { status: "disabled", dispose() {
16124
+ } };
16125
+ }
16126
+ const root = options.document ?? globalObject.document;
16127
+ const wrapped = [];
16128
+ let disposed = false;
16129
+ let auditedAssetFound = false;
16130
+ const handle = {
16131
+ status: "pending",
16132
+ dispose() {
16133
+ disposed = true;
16134
+ for (const client of wrapped) restoreCheckGate(client);
16135
+ wrapped.length = 0;
16136
+ }
16137
+ };
16138
+ const attempt = () => {
16139
+ if (!auditedAssetFound) {
16140
+ const resourceNames = options.resourceNames ?? loadedAssetNames(root);
16141
+ auditedAssetFound = configAllowsInstall(config2, resourceNames);
16142
+ if (!auditedAssetFound) return false;
16143
+ }
16144
+ for (const client of statsigClients(globalObject)) {
16145
+ if (wrapCheckGate(client)) wrapped.push(client);
16146
+ }
16147
+ if (wrapped.length === 0) return false;
16148
+ handle.status = "active";
16149
+ return true;
16150
+ };
16151
+ if (attempt()) return handle;
16152
+ if (options.resourceNames && !configAllowsInstall(config2, options.resourceNames)) {
16153
+ handle.status = "unsupported";
16154
+ return handle;
16155
+ }
16156
+ const started = Date.now();
16157
+ const tick = () => {
16158
+ if (disposed || attempt()) return;
16159
+ if (Date.now() - started > DISCOVERY_TIMEOUT_MS) {
16160
+ handle.status = "unsupported";
16161
+ return;
16162
+ }
16163
+ globalThis.setTimeout(tick, 250);
16164
+ };
16165
+ globalThis.setTimeout(tick, 250);
16166
+ return handle;
16167
+ }
16168
+
16169
+ // src/renderer-chat-voice-debug.ts
16170
+ var CHAT_VOICE_DEBUG_GLOBAL = "__codexhostChatVoiceDebug";
16171
+ var CHAT_VOICE_DEBUG_STORAGE_KEY = "codexhost.chat-voice-debug.v1";
16172
+ function chatVoiceDebug(event, detail = {}) {
16173
+ const entry = { t: Date.now(), event, ...detail };
16174
+ const owner = globalThis;
16175
+ const log = Array.isArray(owner[CHAT_VOICE_DEBUG_GLOBAL]) ? owner[CHAT_VOICE_DEBUG_GLOBAL] : [];
16176
+ log.push(entry);
16177
+ while (log.length > 40) log.shift();
16178
+ owner[CHAT_VOICE_DEBUG_GLOBAL] = log;
16179
+ try {
16180
+ owner.localStorage?.setItem(CHAT_VOICE_DEBUG_STORAGE_KEY, JSON.stringify(log));
16181
+ } catch {
16182
+ }
16183
+ owner.console?.info?.("[codexhost-chat-voice]", event, detail);
16184
+ }
16185
+
16186
+ // src/renderer-new-thread-preference.ts
16187
+ var RENDERER_NEW_THREAD_PREFERENCE_KEY = "codexhost.new-thread-preference.v1";
16188
+
16090
16189
  // src/renderer-client-owned-voice.ts
16091
16190
  var CLIENT_OWNED_VOICE_VERSION = "26.1013.40934";
16092
16191
  var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-90eb42395b7d.js";
@@ -16126,11 +16225,91 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16126
16225
  }
16127
16226
  });
16128
16227
  }
16129
- function wrapClientOwnedVoiceFetch(client, bridge, enabled, responseError) {
16228
+ var HOME_COMPOSER_MODE_STORAGE_KEY = "home-composer-mode-v1";
16229
+ function backendModelName(headers) {
16230
+ const raw = new Headers(headers).get("x-codex-turn-metadata");
16231
+ if (!raw) return "";
16232
+ try {
16233
+ const parsed = JSON.parse(raw);
16234
+ return typeof parsed.backend_model_name === "string" ? parsed.backend_model_name : "";
16235
+ } catch {
16236
+ return "";
16237
+ }
16238
+ }
16239
+ function isWorkBackendModel(name) {
16240
+ const model2 = name.toLowerCase();
16241
+ if (!model2) return false;
16242
+ if (model2.startsWith("codexhost/")) return true;
16243
+ return model2.includes("codex") && !model2.includes("gpt-live");
16244
+ }
16245
+ function isWorkComposerSurface(owner = globalThis) {
16246
+ const storage = owner.localStorage;
16247
+ if (!storage) return false;
16248
+ try {
16249
+ const raw = storage.getItem(HOME_COMPOSER_MODE_STORAGE_KEY);
16250
+ if (raw == null || raw === "") return false;
16251
+ let value = raw;
16252
+ if (raw.startsWith("{") || raw.startsWith('"') || raw.startsWith("[")) {
16253
+ try {
16254
+ value = JSON.parse(raw);
16255
+ } catch {
16256
+ value = raw;
16257
+ }
16258
+ }
16259
+ return value === "work";
16260
+ } catch {
16261
+ return false;
16262
+ }
16263
+ }
16264
+ function selectedComposerModel(owner) {
16265
+ const routing = owner.__codexhostHostRoutingV1;
16266
+ try {
16267
+ const model2 = routing?.forComposer()?.policy.selectedModel();
16268
+ return typeof model2 === "string" ? model2 : "";
16269
+ } catch {
16270
+ return "";
16271
+ }
16272
+ }
16273
+ var lastVoiceProductExperience;
16274
+ function lastVoiceLaunchProductExperience() {
16275
+ return lastVoiceProductExperience;
16276
+ }
16277
+ function isExternalHarnessComposer(owner = globalThis) {
16278
+ if (lastVoiceProductExperience === "chat") return false;
16279
+ if (selectedComposerModel(owner).startsWith("codexhost/")) return true;
16280
+ if (lastVoiceProductExperience !== "work") return false;
16281
+ const storage = owner.localStorage;
16282
+ if (!storage) return false;
16283
+ try {
16284
+ const parsed = JSON.parse(storage.getItem(RENDERER_NEW_THREAD_PREFERENCE_KEY) ?? "");
16285
+ return typeof parsed.lastAgent === "string" && parsed.lastAgent !== "" && parsed.lastAgent !== "codex";
16286
+ } catch {
16287
+ return false;
16288
+ }
16289
+ }
16290
+ function wrapClientOwnedVoiceFetch(client, bridge, workOverride, responseError, chatOverride = () => false, workSurface = () => isWorkComposerSurface(), externalHarness = () => isExternalHarnessComposer()) {
16130
16291
  const original = client.fetch;
16131
16292
  const wrapped = async function(url2, options) {
16132
- if (typeof url2 !== "string" || url2.split("?")[0] !== "/wham/realtime/calls" || options?.method !== "POST" || !enabled())
16293
+ if (typeof url2 !== "string" || url2.split("?")[0] !== "/wham/realtime/calls" || options?.method !== "POST")
16294
+ return original.call(this, url2, options);
16295
+ const chat = lastVoiceLaunchProductExperience() === "chat";
16296
+ const model2 = backendModelName(options.headers);
16297
+ const work = !chat && (isWorkBackendModel(model2) || workSurface());
16298
+ const external = !chat && (model2.startsWith("codexhost/") || externalHarness());
16299
+ const gateway = external || (work ? workOverride() : chatOverride());
16300
+ chatVoiceDebug("wham-create", {
16301
+ work,
16302
+ external,
16303
+ route: gateway ? "gateway" : "desktop",
16304
+ productExperience: lastVoiceLaunchProductExperience() ?? "unset"
16305
+ });
16306
+ if (!gateway) {
16307
+ if (!external && !work)
16308
+ chatVoiceDebug("chat-native-passthrough", {
16309
+ hasThreadId: new Headers(options.headers).has("Thread-Id")
16310
+ });
16133
16311
  return original.call(this, url2, options);
16312
+ }
16134
16313
  if (typeof options.body !== "string") throw new Error("Unsupported native voice call request");
16135
16314
  options.signal?.throwIfAborted();
16136
16315
  const requestId2 = crypto.randomUUID();
@@ -16181,9 +16360,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16181
16360
  const existing = target[HOOK_GLOBAL];
16182
16361
  if (existing) return existing;
16183
16362
  const config2 = readCpaLiveVoiceHookConfig(target);
16184
- if (!config2 || !cpaLiveVoicePreferenceAllowsInstall(target))
16185
- return { status: "disabled", dispose() {
16186
- } };
16363
+ if (!config2) return { status: "disabled", dispose() {
16364
+ } };
16187
16365
  if (config2.desktopVersion !== void 0 && config2.desktopVersion !== CLIENT_OWNED_VOICE_VERSION)
16188
16366
  return { status: "unsupported", dispose() {
16189
16367
  } };
@@ -16209,6 +16387,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16209
16387
  try {
16210
16388
  const module = await importModule(`app://-/assets/${CLIENT_OWNED_VOICE_SHARED_ASSET}`);
16211
16389
  if (disposed) return;
16390
+ if (typeof module.frt !== "function") throw new Error();
16391
+ module.frt();
16212
16392
  const fetchClass = module.urt;
16213
16393
  const bridgeClass = module.mPt;
16214
16394
  if (!object2(fetchClass) && typeof fetchClass !== "function") throw new Error();
@@ -16221,7 +16401,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16221
16401
  client,
16222
16402
  bridge,
16223
16403
  () => cpaLiveVoicePreferenceAllowsInstall(target),
16224
- module.grt
16404
+ module.grt,
16405
+ () => chatLiveVoicePreferenceAllowsOverride(target),
16406
+ () => isWorkComposerSurface(target),
16407
+ () => isExternalHarnessComposer(target)
16225
16408
  );
16226
16409
  handle.status = "active";
16227
16410
  } catch {