@karlorz/codexhost-cli-win32-x64 0.18.0-0 → 0.18.0-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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +258 -57
  4. package/app/console-web.js +1813 -137
  5. package/app/cpa-live-voice-hook.js +1879 -426
  6. package/app/desktop-controller.mjs +1783 -192
  7. package/app/host-runtime.mjs +2595 -1088
  8. package/app/overlay-voice-bootstrap.js +1616 -0
  9. package/app/plugins/antigravity/plugin.mjs +257 -56
  10. package/app/plugins/claude-code/plugin.mjs +257 -56
  11. package/app/plugins/codebuddy/plugin.mjs +257 -56
  12. package/app/plugins/codex-usage/plugin.mjs +257 -56
  13. package/app/plugins/copilot/plugin.mjs +257 -56
  14. package/app/plugins/cursor-cli/plugin.mjs +257 -56
  15. package/app/plugins/deepseek-harness/plugin.mjs +257 -56
  16. package/app/plugins/devin/plugin.mjs +257 -56
  17. package/app/plugins/grok/plugin.mjs +257 -56
  18. package/app/plugins/hermes/plugin.mjs +257 -56
  19. package/app/plugins/kimi-code/plugin.mjs +257 -56
  20. package/app/plugins/kiro-cli/plugin.mjs +257 -56
  21. package/app/plugins/omp/plugin.mjs +257 -56
  22. package/app/plugins/opencode/plugin.mjs +257 -56
  23. package/app/plugins/pi/plugin.mjs +257 -56
  24. package/app/plugins/qoder/plugin.mjs +257 -56
  25. package/app/plugins/qoder-cn/plugin.mjs +257 -56
  26. package/app/plugins/qwen-code/plugin.mjs +257 -56
  27. package/app/plugins/workbuddy/plugin.mjs +257 -56
  28. package/app/plugins/zcode/plugin.mjs +257 -56
  29. package/app/renderer-extension.js +22195 -19283
  30. package/app/voice-profile-pins.json +25 -0
  31. package/app/voice-qualification.json +4 -0
  32. package/app/web/assets/index-py6Ho-Dy.js +199 -0
  33. package/app/web/codexhost-settings.js +1762 -129
  34. package/app/web/index.html +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  36. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +63 -63
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  39. package/app/web-modules/server.mjs +956 -180
  40. package/bin/codexhost.exe +0 -0
  41. package/libexec/codexhost-node-repl.exe +0 -0
  42. package/libexec/codexhost-shim.exe +0 -0
  43. package/libexec/codexhost-updater.exe +0 -0
  44. package/package.json +1 -1
  45. package/app/web/assets/index-Bs17Kuah.js +0 -199
@@ -0,0 +1,1616 @@
1
+ "use strict";
2
+ (() => {
3
+ // src/renderer-cpa-live-voice-config.ts
4
+ var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
5
+ var ISOLATED_VOICE_PATHS = ["chat", "work-codex", "work-grok"];
6
+ var PRODUCTION_DESKTOP_APP_PATH = "/Applications/ChatGPT.app";
7
+ var PRODUCTION_WINDOWS_APPX_PATH = /(?:^|[\\/])WindowsApps[\\/]OpenAI\.(?:Codex|ChatGPT)_/i;
8
+ function isProductionDesktopAppPath(appPath) {
9
+ if (typeof appPath !== "string" || appPath.length === 0) return false;
10
+ if (appPath === PRODUCTION_DESKTOP_APP_PATH) return true;
11
+ return PRODUCTION_WINDOWS_APPX_PATH.test(appPath);
12
+ }
13
+ function isRecord(value) {
14
+ return typeof value === "object" && value !== null;
15
+ }
16
+ function readCpaLiveVoiceHookConfig(globalObject) {
17
+ const value = globalObject[CPA_LIVE_VOICE_HOOK_GLOBAL];
18
+ if (!isRecord(value) || value.enabled !== true) return null;
19
+ if (typeof value.auditedDesktopVersion !== "string" || typeof value.auditedAppInitialAsset !== "string") {
20
+ return null;
21
+ }
22
+ return {
23
+ enabled: true,
24
+ auditedDesktopVersion: value.auditedDesktopVersion,
25
+ auditedAppInitialAsset: value.auditedAppInitialAsset,
26
+ ...typeof value.desktopPlatform === "string" ? { desktopPlatform: value.desktopPlatform } : {},
27
+ ...typeof value.desktopVersion === "string" ? { desktopVersion: value.desktopVersion } : {},
28
+ ...typeof value.desktopBuild === "string" ? { desktopBuild: value.desktopBuild } : {},
29
+ ...typeof value.asarDigest === "string" ? { asarDigest: value.asarDigest } : {},
30
+ ...typeof value.implementationRevision === "string" ? { implementationRevision: value.implementationRevision } : {},
31
+ ...typeof value.desktopAppPath === "string" ? { desktopAppPath: value.desktopAppPath } : {},
32
+ ...Array.isArray(value.voiceEvidence) ? { voiceEvidence: value.voiceEvidence } : {},
33
+ ...isIsolatedVoiceQualification(value.isolatedQualification) ? { isolatedQualification: value.isolatedQualification } : {}
34
+ };
35
+ }
36
+ function isIsolatedVoicePath(value) {
37
+ return value === "chat" || value === "work-codex" || value === "work-grok";
38
+ }
39
+ function isIsolatedDesktopPlatform(value) {
40
+ return value === "darwin" || value === "win32" || value === "linux";
41
+ }
42
+ function isolatedQualificationExpiresAtMs(expiresAt) {
43
+ if (typeof expiresAt !== "string" || expiresAt.length === 0) return void 0;
44
+ const parsed = Date.parse(expiresAt);
45
+ return Number.isFinite(parsed) ? parsed : void 0;
46
+ }
47
+ function isolatedQualificationPathSet(value) {
48
+ if (!isRecord(value)) return void 0;
49
+ const pathsPresent = value.paths !== void 0;
50
+ const pathPresent = value.path !== void 0;
51
+ let listed;
52
+ if (pathsPresent) {
53
+ if (!Array.isArray(value.paths) || value.paths.length === 0) return void 0;
54
+ if (value.paths.some((path) => !isIsolatedVoicePath(path))) return void 0;
55
+ if (new Set(value.paths).size !== value.paths.length) return void 0;
56
+ listed = ISOLATED_VOICE_PATHS.filter((path) => value.paths.includes(path));
57
+ if (listed.length !== value.paths.length) return void 0;
58
+ } else if (pathPresent) {
59
+ if (!isIsolatedVoicePath(value.path)) return void 0;
60
+ listed = [value.path];
61
+ } else {
62
+ return void 0;
63
+ }
64
+ if (pathPresent) {
65
+ if (!isIsolatedVoicePath(value.path) || !listed.includes(value.path)) return void 0;
66
+ }
67
+ return listed;
68
+ }
69
+ function isolatedQualificationPaths(isolated) {
70
+ return isolatedQualificationPathSet(isolated) ?? [];
71
+ }
72
+ function isIsolatedVoiceQualification(value, now = Date.now()) {
73
+ if (!isRecord(value)) return false;
74
+ const paths = isolatedQualificationPathSet(value);
75
+ if (!paths || paths.length === 0) return false;
76
+ if (typeof value.appPath === "string" && isProductionDesktopAppPath(value.appPath)) return false;
77
+ const expiresAtMs = isolatedQualificationExpiresAtMs(value.expiresAt);
78
+ if (expiresAtMs === void 0 || expiresAtMs <= now) return false;
79
+ return typeof value.run === "string" && value.run.length > 0 && isIsolatedDesktopPlatform(value.desktopPlatform) && typeof value.desktopVersion === "string" && typeof value.desktopBuild === "string" && typeof value.asarDigest === "string" && typeof value.appPath === "string" && typeof value.implementationRevision === "string" && value.label === "unqualified-isolated";
80
+ }
81
+ function resourceNamesFromPerformance(source) {
82
+ const target = source ?? (typeof performance === "undefined" ? void 0 : performance);
83
+ if (!target) return [];
84
+ const names = [];
85
+ const push = (name) => {
86
+ if (typeof name === "string" && name) names.push(name);
87
+ };
88
+ if (typeof target.getEntries === "function") {
89
+ for (const entry of target.getEntries()) push(entry.name);
90
+ } else if (typeof target.getEntriesByType === "function") {
91
+ for (const entry of target.getEntriesByType("resource")) push(entry.name);
92
+ }
93
+ return names;
94
+ }
95
+ function loadedAssetNames(root, performanceSource) {
96
+ const names = resourceNamesFromPerformance(performanceSource);
97
+ if (!root || !("querySelectorAll" in root)) return names;
98
+ for (const element of root.querySelectorAll(
99
+ 'script[src], link[href], link[rel="modulepreload"], link[rel="preload"]'
100
+ )) {
101
+ const value = element.getAttribute("src") ?? element.getAttribute("href");
102
+ if (value) names.push(value);
103
+ }
104
+ return names;
105
+ }
106
+
107
+ // src/renderer-voice-routes-cache.ts
108
+ var SHARED_VOICE_CACHE = "codexhost.voice-routes-cache.v1";
109
+ var CHAT_LIVE_VOICE_STORAGE_KEY = "codexhost.chat-live-voice.v1";
110
+ var voiceStateOwner = globalThis;
111
+ function voicePreferenceState() {
112
+ return voiceStateOwner.__codexhostVoicePreferenceStateV1 ??= {
113
+ sharedRoutes: /* @__PURE__ */ new WeakMap(),
114
+ gatewayReady: /* @__PURE__ */ new WeakMap()
115
+ };
116
+ }
117
+ function parseVoiceRoutes(value) {
118
+ if (value === null || typeof value !== "object") return;
119
+ const record = value;
120
+ if (record.chatExperience !== "chatgpt" && record.chatExperience !== "codex" || record.chatConnection !== "desktop" && record.chatConnection !== "gateway" || record.workConnection !== "desktop" && record.workConnection !== "gateway")
121
+ return;
122
+ return {
123
+ chatExperience: record.chatExperience,
124
+ chatConnection: record.chatConnection,
125
+ workConnection: record.workConnection
126
+ };
127
+ }
128
+ function cachedVoiceRoutes(owner) {
129
+ const { sharedRoutes } = voicePreferenceState();
130
+ const memory = sharedRoutes.get(owner);
131
+ if (memory) return memory;
132
+ try {
133
+ const storage = owner.localStorage;
134
+ const parsed = parseVoiceRoutes(JSON.parse(storage?.getItem(SHARED_VOICE_CACHE) ?? "null"));
135
+ if (parsed) sharedRoutes.set(owner, parsed);
136
+ return parsed;
137
+ } catch {
138
+ return void 0;
139
+ }
140
+ }
141
+ function readVoiceStorageFlag(owner, key, enabledWhenUnset) {
142
+ const storage = owner.localStorage;
143
+ if (!storage) return enabledWhenUnset;
144
+ try {
145
+ const value = storage.getItem(key);
146
+ return enabledWhenUnset ? value !== "0" : value === "1";
147
+ } catch {
148
+ return enabledWhenUnset;
149
+ }
150
+ }
151
+ function nativeChatVoicePreferenceAllowsStart(owner) {
152
+ const routes = cachedVoiceRoutes(owner);
153
+ return routes ? routes.chatExperience === "chatgpt" : !readVoiceStorageFlag(owner, CHAT_LIVE_VOICE_STORAGE_KEY, false);
154
+ }
155
+
156
+ // ../shared-contracts/dist/realtime-call-core.js
157
+ var REALTIME_CALL_METHOD = "codexhost/realtime/call";
158
+ var REALTIME_CALL_FORWARDED_HEADERS = [
159
+ "openai-alpha",
160
+ "thread-id",
161
+ "session-id",
162
+ "originator",
163
+ "x-codex-turn-metadata"
164
+ ];
165
+ var FORWARDED_HEADERS = new Set(REALTIME_CALL_FORWARDED_HEADERS);
166
+ function filterRealtimeCallHeaders(headers) {
167
+ const result = {};
168
+ for (const [name, value] of Object.entries(headers ?? {})) {
169
+ const key = name.toLowerCase();
170
+ if (FORWARDED_HEADERS.has(key) && value.length > 0 && value.length <= 4096)
171
+ result[key] = value;
172
+ }
173
+ return result;
174
+ }
175
+ var REALTIME_CALL_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/u;
176
+ function isRealtimeCallId(value) {
177
+ return typeof value === "string" && REALTIME_CALL_ID_PATTERN.test(value);
178
+ }
179
+ function realtimeCallIdFromLocation(location) {
180
+ const path = location.split(/[?#]/u)[0] ?? "";
181
+ if (/^[A-Za-z0-9_-]{1,128}$/u.test(path))
182
+ return path;
183
+ return /\/(?:calls|live)\/([A-Za-z0-9_-]{1,128})$/u.exec(path)?.[1];
184
+ }
185
+
186
+ // src/renderer-chat-voice-debug.ts
187
+ var CHAT_VOICE_DEBUG_GLOBAL = "__codexhostChatVoiceDebug";
188
+ var CHAT_VOICE_DEBUG_STORAGE_KEY = "codexhost.chat-voice-debug.v1";
189
+ function chatVoiceDebug(event, detail = {}) {
190
+ const entry = { t: Date.now(), event, ...detail };
191
+ const owner = globalThis;
192
+ const log = Array.isArray(owner[CHAT_VOICE_DEBUG_GLOBAL]) ? owner[CHAT_VOICE_DEBUG_GLOBAL] : [];
193
+ log.push(entry);
194
+ while (log.length > 40) log.shift();
195
+ owner[CHAT_VOICE_DEBUG_GLOBAL] = log;
196
+ try {
197
+ owner.localStorage?.setItem(CHAT_VOICE_DEBUG_STORAGE_KEY, JSON.stringify(log));
198
+ } catch {
199
+ }
200
+ owner.console?.info?.("[codexhost-chat-voice]", event, detail);
201
+ }
202
+
203
+ // src/renderer-voice-gateway-wrap.ts
204
+ function object(value) {
205
+ return value !== null && typeof value === "object";
206
+ }
207
+ var HOST_MCP_TIMEOUT_MESSAGE = "Host request timed out";
208
+ var HOST_MCP_UNAVAILABLE_MESSAGE = "Local Host connection is unavailable";
209
+ var DIRECT_VOICE_HOST_GLOBAL = "__codexhostVoiceHostV1";
210
+ function resolveDirectVoiceHost(owner = globalThis) {
211
+ const value = Reflect.get(owner, DIRECT_VOICE_HOST_GLOBAL);
212
+ if (!value || typeof value !== "object") return null;
213
+ const request = Reflect.get(value, "request");
214
+ return typeof request === "function" ? { request: request.bind(value) } : null;
215
+ }
216
+ function hostMcpStage(value) {
217
+ return value === "config" || value === "request" || value === "transport" || value === "identity" || value === "cancel" ? value : "rpc";
218
+ }
219
+ function requestVoiceHost(_bridge, params, method = REALTIME_CALL_METHOD) {
220
+ const host = resolveDirectVoiceHost();
221
+ if (!host) {
222
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "host-unavailable" });
223
+ return Promise.reject(new Error("Voice gateway Host connection is unavailable"));
224
+ }
225
+ return host.request(method, params).then(
226
+ (result) => result,
227
+ (error) => {
228
+ const message = error instanceof Error ? error.message : "";
229
+ if (message === HOST_MCP_TIMEOUT_MESSAGE || /timed out/i.test(message)) {
230
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "timeout" });
231
+ throw new Error("Voice gateway did not answer in time");
232
+ }
233
+ if (message === HOST_MCP_UNAVAILABLE_MESSAGE) {
234
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "host-unavailable" });
235
+ throw new Error("Voice gateway Host connection is unavailable");
236
+ }
237
+ const stage = error instanceof Error && "stage" in error ? hostMcpStage(error.stage) : "rpc";
238
+ chatVoiceDebug("gateway-create", { stage, cause: "failed" });
239
+ throw new Error("Configured voice gateway request failed");
240
+ }
241
+ );
242
+ }
243
+ function parseRealtimeCallResponse(value) {
244
+ if (value === null || typeof value !== "object")
245
+ throw new Error("Invalid voice gateway response");
246
+ const record = value;
247
+ if (typeof record.status !== "number" || !Number.isInteger(record.status) || record.status < 200 || record.status > 599 || typeof record.body !== "string" || record.headers === null || typeof record.headers !== "object" || Array.isArray(record.headers)) {
248
+ throw new Error("Invalid voice gateway response");
249
+ }
250
+ const headers = {};
251
+ for (const [name, header] of Object.entries(record.headers)) {
252
+ if (typeof header === "string") headers[name] = header;
253
+ }
254
+ return { status: record.status, body: record.body, headers };
255
+ }
256
+ function backendModelName(headers) {
257
+ const raw = new Headers(headers).get("x-codex-turn-metadata");
258
+ if (!raw) return "";
259
+ try {
260
+ const parsed = JSON.parse(raw);
261
+ return typeof parsed.backend_model_name === "string" ? parsed.backend_model_name : "";
262
+ } catch {
263
+ return "";
264
+ }
265
+ }
266
+ function isWorkBackendModel(name) {
267
+ const model = name.toLowerCase();
268
+ if (!model) return false;
269
+ if (model.startsWith("codexhost/")) return true;
270
+ return model.includes("codex") && !model.includes("gpt-live");
271
+ }
272
+ var lastVoiceProductExperience;
273
+ var VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY = "codexhost.voice-launch-experience.v1";
274
+ function launchStorage(owner) {
275
+ return owner.localStorage;
276
+ }
277
+ function storedVoiceProductExperience(owner) {
278
+ try {
279
+ const stored = launchStorage(owner)?.getItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY);
280
+ return stored === "chat" || stored === "work" || stored === "codex" ? stored : void 0;
281
+ } catch {
282
+ return void 0;
283
+ }
284
+ }
285
+ function rememberVoiceProductExperience(request, owner = globalThis) {
286
+ const experience = object(request) ? request.productExperience : void 0;
287
+ lastVoiceProductExperience = experience === "chat" || experience === "work" || experience === "codex" ? experience : void 0;
288
+ try {
289
+ const storage = launchStorage(owner);
290
+ if (!storage) return;
291
+ if (lastVoiceProductExperience)
292
+ storage.setItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY, lastVoiceProductExperience);
293
+ else storage.removeItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY);
294
+ } catch {
295
+ }
296
+ }
297
+ function lastVoiceLaunchProductExperience(owner = globalThis) {
298
+ return lastVoiceProductExperience ?? storedVoiceProductExperience(owner);
299
+ }
300
+ function wrapClientOwnedVoiceFetch(client, bridge, workOverride, responseError, chatOverride = () => false, workSurface = () => false, externalHarness = () => false, overlayExistingCall = () => false, externalLane = () => true, workLane = () => true, unavailableReason = (kind) => kind === "chat" ? "Chat voice is not qualified on this Desktop." : "Work voice is not qualified on this Desktop.", chatLane = () => true, allowChatNativeWham = () => true, chatgptInstantConnect = () => true) {
301
+ const original = client.fetch;
302
+ const wrapped = async function(url, options) {
303
+ if (typeof url !== "string" || url.split("?")[0] !== "/wham/realtime/calls" || options?.method !== "POST")
304
+ return original.call(this, url, options);
305
+ const experience = lastVoiceLaunchProductExperience();
306
+ const model = backendModelName(options.headers);
307
+ const originator = new Headers(options.headers).get("originator");
308
+ const overlayWork = originator === "codex_work_desktop" && experience !== "chat";
309
+ const overlayHostCreate = overlayExistingCall() && workOverride() && experience !== "chat";
310
+ const chat = experience === "chat" && !overlayWork && !overlayHostCreate;
311
+ const work = overlayWork || overlayHostCreate || !chat && (experience === "work" || experience === "codex" || isWorkBackendModel(model) || workSurface());
312
+ const external = !chat && (model.startsWith("codexhost/") || externalHarness());
313
+ const intendedGateway = external ? true : work ? workOverride() : chatOverride();
314
+ const chatQualified = chatLane();
315
+ const qualified = external ? externalLane() : work ? workLane() : chat ? chatQualified : true;
316
+ const chatgptNative = chat && chatgptInstantConnect();
317
+ const nativeChatWham = chatgptNative && !intendedGateway && allowChatNativeWham() && chatQualified;
318
+ let route;
319
+ if (chatgptNative && !chatQualified) route = "blocked";
320
+ else if (chatgptNative && !intendedGateway && !nativeChatWham) route = "blocked";
321
+ else if (chat && intendedGateway && !chatQualified) route = "blocked";
322
+ else if (!intendedGateway) route = "desktop";
323
+ else if (qualified) route = "gateway";
324
+ else route = "blocked";
325
+ chatVoiceDebug("wham-create", {
326
+ work,
327
+ external,
328
+ route,
329
+ productExperience: experience ?? "unset",
330
+ originator: originator ?? "unset",
331
+ overlayWork,
332
+ overlayHostCreate
333
+ });
334
+ if (route === "blocked") {
335
+ if (chat) {
336
+ throw new Error(
337
+ chatQualified ? "Native Chat voice is unavailable" : unavailableReason("chat")
338
+ );
339
+ }
340
+ throw new Error(unavailableReason(external ? "external" : "work"));
341
+ }
342
+ if (route === "desktop") {
343
+ if (!external && !work)
344
+ chatVoiceDebug("chat-native-passthrough", {
345
+ hasThreadId: new Headers(options.headers).has("Thread-Id")
346
+ });
347
+ return original.call(this, url, options);
348
+ }
349
+ if (typeof options.body !== "string") throw new Error("Unsupported native voice call request");
350
+ options.signal?.throwIfAborted();
351
+ const requestId = crypto.randomUUID();
352
+ let cancelled = false;
353
+ const cancel = () => {
354
+ if (cancelled) return;
355
+ cancelled = true;
356
+ void requestVoiceHost(bridge, { operation: "cancel", requestId }).catch(() => void 0);
357
+ };
358
+ options.signal?.addEventListener("abort", cancel, { once: true });
359
+ try {
360
+ let result;
361
+ try {
362
+ result = parseRealtimeCallResponse(
363
+ await requestVoiceHost(bridge, {
364
+ operation: "create",
365
+ requestId,
366
+ body: options.body,
367
+ headers: filterRealtimeCallHeaders(Object.fromEntries(new Headers(options.headers)))
368
+ })
369
+ );
370
+ } catch (error) {
371
+ if (error instanceof Error && error.message === "Invalid voice gateway response")
372
+ chatVoiceDebug("gateway-create", { stage: "response", cause: "invalid" });
373
+ throw error;
374
+ }
375
+ chatVoiceDebug("gateway-create", {
376
+ stage: "status",
377
+ status: result.status,
378
+ ok: result.status >= 200 && result.status < 300
379
+ });
380
+ if (options.signal?.aborted) {
381
+ const callId = realtimeCallIdFromLocation(result.headers.location ?? "");
382
+ if (result.status >= 200 && result.status < 300 && isRealtimeCallId(callId))
383
+ await requestVoiceHost(bridge, { operation: "hangup", callId });
384
+ options.signal.throwIfAborted();
385
+ }
386
+ const response = new Response(result.status === 204 ? null : result.body, {
387
+ status: result.status,
388
+ headers: result.headers
389
+ });
390
+ if (!response.ok) throw await responseError(response, url);
391
+ return response;
392
+ } catch (error) {
393
+ cancel();
394
+ throw error;
395
+ } finally {
396
+ options.signal?.removeEventListener("abort", cancel);
397
+ }
398
+ };
399
+ client.fetch = wrapped;
400
+ return () => {
401
+ if (client.fetch === wrapped) client.fetch = original;
402
+ };
403
+ }
404
+
405
+ // src/renderer-work-composer-surface.ts
406
+ var HOME_COMPOSER_MODE_STORAGE_KEY = "home-composer-mode-v1";
407
+ function visibleWorkComposer(owner) {
408
+ const document = owner.document;
409
+ if (!document?.querySelectorAll) return false;
410
+ const visible = (element) => {
411
+ const box = element.getBoundingClientRect?.() ?? { width: 0 };
412
+ return box.width > 0 && !element.closest?.("[hidden], [inert]");
413
+ };
414
+ return [...document.querySelectorAll("[data-codex-composer-root]")].some(visible) && ![...document.querySelectorAll("[data-chatgpt-composer]")].some(visible);
415
+ }
416
+ function selectedWorkTab(owner) {
417
+ const document = owner.document;
418
+ if (!document?.querySelectorAll) return false;
419
+ const controls = document.querySelectorAll("button, [role='tab'], a");
420
+ let workSelected = false;
421
+ let chatSelected = false;
422
+ for (const element of controls) {
423
+ const name = (element.textContent ?? "").replace(/\s+/gu, " ").trim();
424
+ if (name !== "Chat" && name !== "Work") continue;
425
+ const selected = element.getAttribute("aria-selected") === "true" || element.getAttribute("aria-pressed") === "true" || element.getAttribute("data-state") === "active" || element.getAttribute("data-state") === "on";
426
+ if (!selected) continue;
427
+ if (name === "Work") workSelected = true;
428
+ if (name === "Chat") chatSelected = true;
429
+ }
430
+ return workSelected && !chatSelected;
431
+ }
432
+ function isWorkComposerSurface(owner = globalThis) {
433
+ const storage = owner.localStorage;
434
+ try {
435
+ const raw = storage?.getItem(HOME_COMPOSER_MODE_STORAGE_KEY);
436
+ if (raw != null && raw !== "") {
437
+ let value = raw;
438
+ if (raw.startsWith("{") || raw.startsWith('"') || raw.startsWith("[")) {
439
+ try {
440
+ value = JSON.parse(raw);
441
+ } catch {
442
+ value = raw;
443
+ }
444
+ }
445
+ if (value === "work") return true;
446
+ if (value === "chat") return false;
447
+ }
448
+ } catch {
449
+ }
450
+ return selectedWorkTab(owner) || visibleWorkComposer(owner);
451
+ }
452
+
453
+ // src/renderer-voice-implementation-revision.generated.ts
454
+ var VOICE_IMPLEMENTATION_REVISION = "0a2ee1b441686523";
455
+
456
+ // src/renderer-voice-profiles.ts
457
+ var NATIVE_CHAT_VOICE_VERSION = "26.1027.61615";
458
+ var NATIVE_CHAT_INITIAL_ASSET = "app-initial-18b189e867e7.js";
459
+ var START_ASSET = "start-voice-221a396d38a5.js";
460
+ var BASELINE_NAMED_CHAT_ROLES = {
461
+ initializeFrom: "initial",
462
+ initialize: "oT",
463
+ startShape: "module",
464
+ voiceSessionSelector: "SPn",
465
+ reactFactory: "FBt",
466
+ reactDomFactory: "PNt",
467
+ prewarmController: "VoiceInstantConnectCacheController",
468
+ initial: {
469
+ MOr: "MOr",
470
+ CDr: "CDr",
471
+ B1n: "B1n",
472
+ SPn: "SPn",
473
+ oTFrom: "initial",
474
+ oT: "oT",
475
+ aTFrom: "initial",
476
+ aT: "aT",
477
+ Ycr: "Ycr",
478
+ Nir: "Nir",
479
+ n0n: "n0n",
480
+ Y1n: "Y1n",
481
+ HJt: "HJt"
482
+ },
483
+ shared: { Qst: "Qst", FBt: "FBt", PNt: "PNt", Vot: "Vot" }
484
+ };
485
+ var NAMED_CHAT_ROLES_26_1027_61615 = {
486
+ initializeFrom: "primary",
487
+ initialize: "Qp",
488
+ startShape: "module",
489
+ voiceSessionSelector: "etn",
490
+ reactFactory: "pWt",
491
+ reactDomFactory: "GFt",
492
+ prewarmController: "VoiceInstantConnectCacheController",
493
+ initial: {
494
+ MOr: "p5n",
495
+ CDr: "w6n",
496
+ B1n: "_On",
497
+ SPn: "etn",
498
+ oTFrom: "primary",
499
+ oT: "Qp",
500
+ aTFrom: "primary",
501
+ aT: "Zp",
502
+ Ycr: "ofr",
503
+ Nir: "yEn",
504
+ n0n: "FOn",
505
+ Y1n: "JOn",
506
+ HJt: "Z6"
507
+ },
508
+ shared: { Qst: "klt", FBt: "pWt", PNt: "GFt", Vot: "_ct" }
509
+ };
510
+ var NAMED_CHAT_ROLES_26_1027_30824 = {
511
+ initializeFrom: "primary",
512
+ initialize: "Yp",
513
+ startShape: "module",
514
+ voiceSessionSelector: "Xen",
515
+ reactFactory: "pWt",
516
+ reactDomFactory: "GFt",
517
+ prewarmController: "VoiceInstantConnectCacheController",
518
+ initial: {
519
+ MOr: "l5n",
520
+ CDr: "b6n",
521
+ B1n: "pOn",
522
+ SPn: "Xen",
523
+ oTFrom: "primary",
524
+ oT: "Yp",
525
+ aTFrom: "primary",
526
+ aT: "Jp",
527
+ Ycr: "nfr",
528
+ Nir: "hEn",
529
+ n0n: "jOn",
530
+ Y1n: "wOn",
531
+ HJt: "J6"
532
+ },
533
+ shared: { Qst: "klt", FBt: "pWt", PNt: "GFt", Vot: "_ct" }
534
+ };
535
+ var NAMED_CHAT_ROLES_26_1023_51421 = {
536
+ initializeFrom: "primary",
537
+ initialize: "gm",
538
+ startShape: "module",
539
+ voiceSessionSelector: "s$t",
540
+ reactFactory: "OHt",
541
+ reactDomFactory: "wPt",
542
+ prewarmController: "VoiceInstantConnectCacheController",
543
+ initial: {
544
+ MOr: "x1n",
545
+ CDr: "MQn",
546
+ B1n: "Opn",
547
+ SPn: "s$t",
548
+ oTFrom: "primary",
549
+ oT: "gm",
550
+ aTFrom: "primary",
551
+ aT: "hm",
552
+ Ycr: "Zir",
553
+ Nir: "ejn",
554
+ n0n: "Kpn",
555
+ Y1n: "zpn",
556
+ HJt: "k3"
557
+ },
558
+ shared: { Qst: "uct", FBt: "OHt", PNt: "wPt", Vot: "ast" }
559
+ };
560
+ var NAMED_CHAT_ROLES_26_1021_31345 = {
561
+ initializeFrom: "primary",
562
+ initialize: "um",
563
+ startShape: "entityBusiness",
564
+ startT: "r",
565
+ startN: "i",
566
+ voiceSessionSelector: "qXt",
567
+ reactFactory: "XVt",
568
+ reactDomFactory: "KNt",
569
+ prewarmController: "VoiceInstantConnectCacheController",
570
+ initial: {
571
+ MOr: "CQn",
572
+ CDr: "PXn",
573
+ B1n: "tdn",
574
+ SPn: "qXt",
575
+ oTFrom: "primary",
576
+ oT: "um",
577
+ aTFrom: "primary",
578
+ aT: "lm",
579
+ Ycr: "Xkn",
580
+ Nir: "yAn",
581
+ n0n: "ydn",
582
+ Y1n: "fdn",
583
+ HJt: "R2"
584
+ },
585
+ shared: { Qst: "Bst", FBt: "XVt", PNt: "KNt", Vot: "Fot" }
586
+ };
587
+ var NATIVE_CHAT_VOICE_ASSETS = [
588
+ {
589
+ platform: "darwin",
590
+ version: NATIVE_CHAT_VOICE_VERSION,
591
+ initial: NATIVE_CHAT_INITIAL_ASSET,
592
+ shared: "app-shared-601019a330d7.js",
593
+ primary: "app-primary-75d53eef2374.js",
594
+ start: START_ASSET,
595
+ prewarm: "voice-prewarm-a7cd5160219e.js",
596
+ settings: "voice-settings-320cf1212f2c.js",
597
+ roles: NAMED_CHAT_ROLES_26_1027_61615
598
+ },
599
+ {
600
+ platform: "darwin",
601
+ version: "26.1027.30824",
602
+ initial: "app-initial-60f141238751.js",
603
+ shared: "app-shared-7815d5a1a42a.js",
604
+ primary: "app-primary-95a0e6d83f1e.js",
605
+ start: "start-voice-4c77215aa289.js",
606
+ prewarm: "voice-prewarm-e49220ad61bd.js",
607
+ roles: NAMED_CHAT_ROLES_26_1027_30824
608
+ },
609
+ {
610
+ platform: "darwin",
611
+ version: "26.1023.51421",
612
+ initial: "app-initial-bc8256c3cccb.js",
613
+ shared: "app-shared-e9f258fd3588.js",
614
+ primary: "app-primary-b7f335b763ca.js",
615
+ start: "start-voice-a0564cefdc95.js",
616
+ prewarm: "voice-prewarm-53aefded152c.js",
617
+ settings: "voice-settings-1a9f68eb7ae8.js",
618
+ roles: NAMED_CHAT_ROLES_26_1023_51421
619
+ },
620
+ {
621
+ platform: "darwin",
622
+ version: "26.1021.31345",
623
+ initial: "app-initial-feb30b196d11.js",
624
+ shared: "app-shared-2cae01273bae.js",
625
+ primary: "app-primary-7d7313419f84.js",
626
+ start: "entity-business-profile-reference-b68063dfc05d.js",
627
+ prewarm: "voice-prewarm-d672f1245523.js",
628
+ settings: "voice-settings-14000f5c9fc2.js",
629
+ roles: NAMED_CHAT_ROLES_26_1021_31345
630
+ },
631
+ {
632
+ platform: "win32",
633
+ version: "26.1021.31345",
634
+ initial: "app-initial-438d1df57f70.js",
635
+ shared: "app-shared-955d52676f9c.js",
636
+ primary: "app-primary-844e405f2b90.js",
637
+ start: "entity-business-profile-reference-241c52d811f4.js",
638
+ prewarm: "voice-prewarm-8b47c50a17ae.js",
639
+ settings: "voice-settings-b1c1633136a5.js",
640
+ roles: NAMED_CHAT_ROLES_26_1021_31345
641
+ },
642
+ {
643
+ platform: "darwin",
644
+ version: "26.1016.62342",
645
+ initial: "app-initial-dddef47d6ef6.js",
646
+ shared: "app-shared-fc3316d48427.js",
647
+ start: "start-voice-7cbf0a39d53b.js",
648
+ prewarm: "voice-prewarm-5d107129ac1c.js",
649
+ roles: BASELINE_NAMED_CHAT_ROLES
650
+ },
651
+ {
652
+ platform: "darwin",
653
+ version: "26.1016.61520",
654
+ initial: "app-initial-c95ddb62696e.js",
655
+ shared: "app-shared-2eda13eb7044.js",
656
+ start: "start-voice-18b08f0acdd7.js",
657
+ prewarm: "voice-prewarm-94271e581c1b.js",
658
+ roles: BASELINE_NAMED_CHAT_ROLES
659
+ }
660
+ ];
661
+ var CLIENT_OWNED_VOICE_VERSION = "26.1027.61615";
662
+ var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-18b189e867e7.js";
663
+ var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-601019a330d7.js";
664
+ var CLIENT_OWNED_VOICE_OVERLAY_ASSET = "avatar-overlay-native-page-920d05377bbe.js";
665
+ var CLIENT_OWNED_VOICE_ASSETS = [
666
+ {
667
+ platform: "darwin",
668
+ version: CLIENT_OWNED_VOICE_VERSION,
669
+ initial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
670
+ shared: CLIENT_OWNED_VOICE_SHARED_ASSET,
671
+ overlay: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
672
+ init: "Adr",
673
+ fetch: "Odr",
674
+ fetchFrom: "initial",
675
+ bridge: "LRt",
676
+ services: "Vct",
677
+ responseError: "Pdr",
678
+ responseErrorFrom: "initial",
679
+ capabilityInit: "Ler",
680
+ capabilityFamily: "Ier",
681
+ inferenceGateFamily: "Vfr"
682
+ },
683
+ {
684
+ platform: "darwin",
685
+ version: "26.1027.30824",
686
+ initial: "app-initial-60f141238751.js",
687
+ shared: "app-shared-7815d5a1a42a.js",
688
+ overlay: "avatar-overlay-native-page-d9d400e751cd.js",
689
+ init: "Edr",
690
+ fetch: "wdr",
691
+ fetchFrom: "initial",
692
+ bridge: "LRt",
693
+ services: "Vct",
694
+ responseError: "Adr",
695
+ responseErrorFrom: "initial",
696
+ capabilityInit: "Ner",
697
+ capabilityFamily: "Mer",
698
+ inferenceGateFamily: "Lfr"
699
+ },
700
+ {
701
+ platform: "darwin",
702
+ version: "26.1023.51421",
703
+ initial: "app-initial-bc8256c3cccb.js",
704
+ shared: "app-shared-e9f258fd3588.js",
705
+ overlay: "avatar-overlay-native-page-af6c3662f64f.js",
706
+ init: "xir",
707
+ fetch: "yir",
708
+ fetchFrom: "initial",
709
+ bridge: "QIt",
710
+ services: "Sst",
711
+ capabilityInit: "N4n",
712
+ capabilityFamily: "M4n",
713
+ inferenceGateFamily: "Par"
714
+ },
715
+ {
716
+ platform: "darwin",
717
+ version: "26.1021.31345",
718
+ initial: "app-initial-feb30b196d11.js",
719
+ shared: "app-shared-2cae01273bae.js",
720
+ overlay: "avatar-overlay-native-page-d549db3706f1.js",
721
+ fetch: "Htr",
722
+ fetchFrom: "initial",
723
+ bridge: "bIt",
724
+ services: "Qot",
725
+ capabilityInit: "l0n",
726
+ capabilityFamily: "c0n",
727
+ inferenceGateFamily: "Cnr"
728
+ },
729
+ {
730
+ platform: "win32",
731
+ version: "26.1021.31345",
732
+ initial: "app-initial-438d1df57f70.js",
733
+ shared: "app-shared-955d52676f9c.js",
734
+ overlay: "avatar-overlay-native-page-1549fe5955e1.js",
735
+ fetch: "Htr",
736
+ fetchFrom: "initial",
737
+ bridge: "bIt",
738
+ services: "Qot",
739
+ capabilityInit: "l0n",
740
+ capabilityFamily: "c0n",
741
+ inferenceGateFamily: "Cnr"
742
+ },
743
+ {
744
+ platform: "darwin",
745
+ version: "26.1016.62342",
746
+ initial: "app-initial-dddef47d6ef6.js",
747
+ shared: "app-shared-fc3316d48427.js",
748
+ overlay: "avatar-overlay-native-page-ef8332c6a2fb.js",
749
+ init: "Oit",
750
+ fetch: "Eit",
751
+ bridge: "AFt",
752
+ responseError: "Mit",
753
+ services: "ist",
754
+ capabilityInit: "njr",
755
+ capabilityFamily: "tjr",
756
+ inferenceGateFamily: "uBr"
757
+ },
758
+ {
759
+ platform: "darwin",
760
+ version: "26.1016.61520",
761
+ initial: "app-initial-c95ddb62696e.js",
762
+ shared: "app-shared-2eda13eb7044.js",
763
+ overlay: "avatar-overlay-native-page-fcc17283519a.js",
764
+ init: "Oit",
765
+ fetch: "Eit",
766
+ bridge: "AFt",
767
+ responseError: "Mit",
768
+ services: "ist",
769
+ capabilityInit: "njr",
770
+ capabilityFamily: "tjr",
771
+ inferenceGateFamily: "uBr"
772
+ }
773
+ ];
774
+ var HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
775
+ var HISTORICAL_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
776
+ var HASHED_WEBPACK_VOICE_VERSION = "26.1106.51428";
777
+ var HASHED_WEBPACK_VOICE_RUNTIME_ASSET = "348410.1a97dde15f.js";
778
+ var HASHED_NATIVE_CHAT_START_ASSET = "530142.1e51e7f4b2.js";
779
+ var HASHED_NATIVE_CHAT_PREWARM_ASSET = "586788.c871bb9b7d.js";
780
+ var NATIVE_CHAT_VOICE_CHUNKS = [
781
+ 157963,
782
+ 74692,
783
+ 198336,
784
+ 543449,
785
+ 904485,
786
+ 459859,
787
+ 822019,
788
+ 431137,
789
+ 108823,
790
+ 208490,
791
+ 384218,
792
+ 843292,
793
+ 652289,
794
+ 907652,
795
+ 796195,
796
+ 144338,
797
+ 140959,
798
+ 587936,
799
+ 904817,
800
+ 426774,
801
+ 452048,
802
+ 490954,
803
+ 445991,
804
+ 612928,
805
+ 42903,
806
+ 363341,
807
+ 997826,
808
+ 223736,
809
+ 21878,
810
+ 89655,
811
+ 333490,
812
+ 422391,
813
+ 792483,
814
+ 530142
815
+ ];
816
+ var HASHED_NATIVE_CHAT_ROLES = {
817
+ startModuleId: "j9r7",
818
+ prewarmModuleId: "oWM3",
819
+ appScopeModuleId: "OWtl",
820
+ appScopeExport: "u",
821
+ routeScopeModuleId: "Oj9r",
822
+ routeScopeExport: "GD",
823
+ composerScopeModuleId: "Sd8U",
824
+ composerScopeExport: "PR",
825
+ storeModuleId: "bgok",
826
+ storeExport: "MH",
827
+ runtimeModuleId: "cY1t",
828
+ runtimeEnableExport: "Iy",
829
+ runtimeLoaderExport: "Re",
830
+ reactModuleId: "zd8w",
831
+ reactDomModuleId: "CE87",
832
+ startInitializeExport: "initializeVoiceSession",
833
+ prewarmControllerExport: "VoiceInstantConnectCacheController",
834
+ /** Conversation store: adopted backend ID, transcript mapping, current node. */
835
+ conversationModuleId: "MrGp",
836
+ backendConversationExport: "jS",
837
+ transcriptMappingExport: "Jv",
838
+ currentNodeExport: "Od",
839
+ /** App location atom used as the draft-selection origin. */
840
+ locationModuleId: "nlNF",
841
+ locationExport: "x2",
842
+ /** AppNavigation.navigate(scope, location). */
843
+ navigationModuleId: "E8Sp",
844
+ navigationExport: "oo",
845
+ /** `/c/:conversationId` builder; not a GPT `/g/` path. */
846
+ conversationPathModuleId: "jAnS",
847
+ conversationPathExport: "mv"
848
+ };
849
+ var HASHED_OVERLAY_VOICE_ROLES = {
850
+ fetchFactoryId: "GDNt",
851
+ fetchExport: "_n",
852
+ bridgeModuleId: "TL6G",
853
+ bridgeExport: "O1",
854
+ responseErrorModuleId: "eShZ",
855
+ responseErrorExport: "s1",
856
+ capabilityModuleId: "ChYf",
857
+ capabilityExport: "G",
858
+ inferenceGateModuleId: "OMIV",
859
+ inferenceGateExport: "JW",
860
+ /** Workspace voice access derived atom `P` via `zTeN.un`; Instant Connect ANDs `Y3.status`. */
861
+ voiceAccessModuleId: "eFn4",
862
+ voiceAccessExport: "Y3"
863
+ };
864
+ function hashedVoiceCandidateOwner(config) {
865
+ return config.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && (config.desktopPlatform === "darwin" || config.desktopPlatform === "win32");
866
+ }
867
+ function hashedVoiceProfileSupported(config) {
868
+ return config.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config.desktopPlatform === "darwin";
869
+ }
870
+ function reviewedOverlayHookDesktopVersions() {
871
+ const versions = /* @__PURE__ */ new Set([
872
+ HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION,
873
+ HASHED_WEBPACK_VOICE_VERSION
874
+ ]);
875
+ for (const profile of NATIVE_CHAT_VOICE_ASSETS) versions.add(profile.version);
876
+ for (const profile of CLIENT_OWNED_VOICE_ASSETS) versions.add(profile.version);
877
+ return [...versions].sort();
878
+ }
879
+ var VOICE_PROFILE_PINS = {
880
+ workVersion: CLIENT_OWNED_VOICE_VERSION,
881
+ workInitial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
882
+ workShared: CLIENT_OWNED_VOICE_SHARED_ASSET,
883
+ overlayAsset: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
884
+ chatVersion: NATIVE_CHAT_VOICE_VERSION,
885
+ chatInitial: NATIVE_CHAT_INITIAL_ASSET,
886
+ chatStart: START_ASSET,
887
+ hashedVersion: HASHED_WEBPACK_VOICE_VERSION,
888
+ hashedRuntimeAsset: HASHED_WEBPACK_VOICE_RUNTIME_ASSET,
889
+ hashedStartAsset: HASHED_NATIVE_CHAT_START_ASSET,
890
+ hashedPrewarmAsset: HASHED_NATIVE_CHAT_PREWARM_ASSET,
891
+ historicalCpaVersion: HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION,
892
+ historicalCpaInitial: HISTORICAL_CPA_LIVE_VOICE_APP_INITIAL_ASSET
893
+ };
894
+ var voiceProfilePins = {
895
+ ...VOICE_PROFILE_PINS,
896
+ overlayHookDesktopVersions: reviewedOverlayHookDesktopVersions()
897
+ };
898
+ function nativeChatVoiceKind(config) {
899
+ if (!config.desktopVersion) return void 0;
900
+ if (hashedVoiceProfileSupported(config)) return "hashed";
901
+ if (NATIVE_CHAT_VOICE_ASSETS.some(
902
+ (profile) => profile.version === config.desktopVersion && (config.desktopPlatform === void 0 || profile.platform === config.desktopPlatform)
903
+ )) {
904
+ return "named";
905
+ }
906
+ return void 0;
907
+ }
908
+ function nativeChatVoiceUnavailableReason(config) {
909
+ if (nativeChatVoiceKind(config)) return void 0;
910
+ if (!config.desktopVersion) return "Chat voice is waiting for Desktop identity.";
911
+ if (config.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config.desktopPlatform === "win32") {
912
+ return "Chat voice is not qualified on this Windows Desktop.";
913
+ }
914
+ return "Chat voice is not qualified on this Desktop.";
915
+ }
916
+ function workVoiceUnavailableReason(config) {
917
+ if (hashedVoiceProfileSupported(config)) return void 0;
918
+ if (config.desktopVersion !== void 0 && CLIENT_OWNED_VOICE_ASSETS.some(
919
+ (profile) => profile.version === config.desktopVersion && (config.desktopPlatform === void 0 || profile.platform === config.desktopPlatform)
920
+ )) {
921
+ return void 0;
922
+ }
923
+ if (!config.desktopVersion) return "Work voice is waiting for Desktop identity.";
924
+ if (config.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config.desktopPlatform === "win32") {
925
+ return "Work voice is not qualified on this Windows Desktop.";
926
+ }
927
+ return "Work voice is not qualified on this Desktop.";
928
+ }
929
+ function profileIdentityKey(product, platform, version) {
930
+ return `${product}:${platform ?? "unknown"}:${version ?? "unknown"}`;
931
+ }
932
+ function fnv1aHex(value) {
933
+ let hash = 0xcbf29ce484222325n;
934
+ for (let index = 0; index < value.length; index += 1) {
935
+ hash ^= BigInt(value.charCodeAt(index));
936
+ hash = hash * 0x100000001b3n & 0xffffffffffffffffn;
937
+ }
938
+ return hash.toString(16).padStart(16, "0");
939
+ }
940
+ function digestJson(value) {
941
+ return fnv1aHex(JSON.stringify(value));
942
+ }
943
+ function legacyRetainedVoiceLanes() {
944
+ return [
945
+ ...NATIVE_CHAT_VOICE_ASSETS.map((profile) => ({
946
+ path: "chat",
947
+ platform: profile.platform,
948
+ version: profile.version
949
+ })),
950
+ ...CLIENT_OWNED_VOICE_ASSETS.map((profile) => ({
951
+ path: "work-codex",
952
+ platform: profile.platform,
953
+ version: profile.version
954
+ }))
955
+ ];
956
+ }
957
+ function voiceProfileOwner(product, platform, version) {
958
+ if (product === "chat") {
959
+ if (hashedVoiceCandidateOwner({ desktopVersion: version, desktopPlatform: platform })) {
960
+ return {
961
+ kind: "hashed-chat",
962
+ platform,
963
+ version,
964
+ roles: HASHED_NATIVE_CHAT_ROLES,
965
+ chunks: [...NATIVE_CHAT_VOICE_CHUNKS],
966
+ webpack: HASHED_WEBPACK_VOICE_RUNTIME_ASSET,
967
+ start: HASHED_NATIVE_CHAT_START_ASSET,
968
+ prewarm: HASHED_NATIVE_CHAT_PREWARM_ASSET
969
+ };
970
+ }
971
+ const named = NATIVE_CHAT_VOICE_ASSETS.find(
972
+ (profile) => profile.platform === platform && profile.version === version
973
+ );
974
+ if (!named) return void 0;
975
+ return {
976
+ kind: "named-chat",
977
+ platform: named.platform,
978
+ version: named.version,
979
+ initial: named.initial,
980
+ shared: named.shared,
981
+ primary: named.primary ?? null,
982
+ start: named.start,
983
+ prewarm: named.prewarm,
984
+ settings: named.settings ?? null,
985
+ roles: named.roles
986
+ };
987
+ }
988
+ const namedWork = CLIENT_OWNED_VOICE_ASSETS.find(
989
+ (profile) => profile.platform === platform && profile.version === version
990
+ );
991
+ if (namedWork) {
992
+ return {
993
+ kind: "named-work",
994
+ platform: namedWork.platform,
995
+ version: namedWork.version,
996
+ initial: namedWork.initial,
997
+ shared: namedWork.shared,
998
+ overlay: namedWork.overlay,
999
+ init: namedWork.init ?? null,
1000
+ fetch: namedWork.fetch,
1001
+ fetchFrom: namedWork.fetchFrom ?? null,
1002
+ bridge: namedWork.bridge,
1003
+ services: namedWork.services,
1004
+ responseError: namedWork.responseError ?? null,
1005
+ responseErrorFrom: namedWork.responseErrorFrom ?? null,
1006
+ capabilityInit: namedWork.capabilityInit,
1007
+ capabilityFamily: namedWork.capabilityFamily,
1008
+ inferenceGateFamily: namedWork.inferenceGateFamily
1009
+ };
1010
+ }
1011
+ if (hashedVoiceCandidateOwner({ desktopVersion: version, desktopPlatform: platform })) {
1012
+ return {
1013
+ kind: "hashed-work",
1014
+ platform,
1015
+ version,
1016
+ overlay: HASHED_OVERLAY_VOICE_ROLES,
1017
+ webpack: HASHED_WEBPACK_VOICE_RUNTIME_ASSET
1018
+ };
1019
+ }
1020
+ return void 0;
1021
+ }
1022
+ function voiceProfileDigest(product, platform, version) {
1023
+ const owner = voiceProfileOwner(product, platform, version);
1024
+ return owner ? digestJson(owner) : void 0;
1025
+ }
1026
+ function voiceImplementationRevision() {
1027
+ return VOICE_IMPLEMENTATION_REVISION;
1028
+ }
1029
+
1030
+ // src/renderer-voice-evidence.ts
1031
+ var VOICE_EVIDENCE_STAGES = [
1032
+ "structural",
1033
+ "activation",
1034
+ "connection",
1035
+ "identity",
1036
+ "speech",
1037
+ "cleanup"
1038
+ ];
1039
+ var REQUIRED_STAGES = VOICE_EVIDENCE_STAGES;
1040
+ function recordObject(value) {
1041
+ return value !== null && typeof value === "object";
1042
+ }
1043
+ function missingStages(record) {
1044
+ return REQUIRED_STAGES.filter((stage) => record.stages[stage] !== true);
1045
+ }
1046
+ function productForPath(path) {
1047
+ return path === "chat" ? "chat" : "work";
1048
+ }
1049
+ function evaluateVoiceEvidence(record) {
1050
+ const expectedKey = profileIdentityKey(
1051
+ productForPath(record.path),
1052
+ record.platform,
1053
+ record.desktopVersion
1054
+ );
1055
+ if (record.profileKey !== expectedKey) {
1056
+ return {
1057
+ outcome: "mismatch",
1058
+ qualified: false,
1059
+ missing: missingStages(record),
1060
+ reason: "evidence-profile-mismatch"
1061
+ };
1062
+ }
1063
+ if (typeof record.implementationRevision !== "string" || record.implementationRevision === "") {
1064
+ return {
1065
+ outcome: "mismatch",
1066
+ qualified: false,
1067
+ missing: missingStages(record),
1068
+ reason: "missing-implementation-revision"
1069
+ };
1070
+ }
1071
+ if (record.policy !== "legacy-retained" && record.implementationRevision !== voiceImplementationRevision()) {
1072
+ return {
1073
+ outcome: "mismatch",
1074
+ qualified: false,
1075
+ missing: missingStages(record),
1076
+ reason: "implementation-revision-mismatch"
1077
+ };
1078
+ }
1079
+ if (record.policy !== "legacy-retained") {
1080
+ if (typeof record.desktopBuild !== "string" || record.desktopBuild === "" || typeof record.asarDigest !== "string" || record.asarDigest === "") {
1081
+ return {
1082
+ outcome: "mismatch",
1083
+ qualified: false,
1084
+ missing: missingStages(record),
1085
+ reason: "missing-native-identity"
1086
+ };
1087
+ }
1088
+ }
1089
+ if (typeof record.profileDigest !== "string" || record.profileDigest === "") {
1090
+ return {
1091
+ outcome: "mismatch",
1092
+ qualified: false,
1093
+ missing: missingStages(record),
1094
+ reason: "missing-profile-digest"
1095
+ };
1096
+ }
1097
+ const expectedDigest = voiceProfileDigest(
1098
+ productForPath(record.path),
1099
+ record.platform,
1100
+ record.desktopVersion
1101
+ );
1102
+ if (!expectedDigest || record.profileDigest !== expectedDigest) {
1103
+ return {
1104
+ outcome: "mismatch",
1105
+ qualified: false,
1106
+ missing: missingStages(record),
1107
+ reason: "stale-profile-digest"
1108
+ };
1109
+ }
1110
+ if (record.startAcknowledged === true && record.connected !== true) {
1111
+ return {
1112
+ outcome: "incomplete",
1113
+ qualified: false,
1114
+ missing: missingStages(record).length > 0 ? missingStages(record) : ["connection"],
1115
+ reason: "start-acknowledged-without-connection"
1116
+ };
1117
+ }
1118
+ if (record.path !== "chat" && record.gatewayOwned !== true && record.stages.connection === true) {
1119
+ return {
1120
+ outcome: "incomplete",
1121
+ qualified: false,
1122
+ missing: missingStages(record).length > 0 ? missingStages(record) : ["connection"],
1123
+ reason: "route-only-without-connected-gateway"
1124
+ };
1125
+ }
1126
+ if (record.speech?.attended === true && (!record.speech.witness || !record.speech.run)) {
1127
+ return {
1128
+ outcome: "incomplete",
1129
+ qualified: false,
1130
+ missing: missingStages(record).includes("speech") ? missingStages(record) : ["speech"],
1131
+ reason: "attended-speech-missing-provenance"
1132
+ };
1133
+ }
1134
+ if (record.speech && record.speech.attended !== true) {
1135
+ return {
1136
+ outcome: "incomplete",
1137
+ qualified: false,
1138
+ missing: missingStages(record),
1139
+ reason: "synthetic-speech-is-not-qualification"
1140
+ };
1141
+ }
1142
+ const missing = missingStages(record);
1143
+ if (missing.length > 0) {
1144
+ return {
1145
+ outcome: "incomplete",
1146
+ qualified: false,
1147
+ missing,
1148
+ reason: `missing:${missing.join(",")}`
1149
+ };
1150
+ }
1151
+ if (record.connected !== true || record.conversationMatched !== true || (record.path === "chat" ? record.harnessMatched !== void 0 && record.harnessMatched !== true : record.harnessMatched !== true) || record.speech?.attended !== true || record.speech.bothDirections !== true || record.cleanup?.ended !== true || record.cleanup.microphoneReleased !== true) {
1152
+ return {
1153
+ outcome: "fail",
1154
+ qualified: false,
1155
+ missing: [],
1156
+ reason: "required-assertions-failed"
1157
+ };
1158
+ }
1159
+ return { outcome: "pass", qualified: true, missing: [], reason: "qualified" };
1160
+ }
1161
+ function evidenceMatchesRuntime(record, config) {
1162
+ if (record.platform !== config.desktopPlatform) return false;
1163
+ if (record.desktopVersion !== config.desktopVersion) return false;
1164
+ if (record.implementationRevision !== config.implementationRevision) return false;
1165
+ if (record.policy === "legacy-retained") return true;
1166
+ if (typeof record.desktopBuild !== "string" || record.desktopBuild === "" || typeof record.asarDigest !== "string" || record.asarDigest === "" || typeof config.desktopBuild !== "string" || config.desktopBuild === "" || typeof config.asarDigest !== "string" || config.asarDigest === "" || typeof config.implementationRevision !== "string" || config.implementationRevision === "") {
1167
+ return false;
1168
+ }
1169
+ return record.desktopBuild === config.desktopBuild && record.asarDigest === config.asarDigest;
1170
+ }
1171
+ function isolatedVoicePathEnabled(config, path) {
1172
+ return isolatedQualificationMatches(path, config);
1173
+ }
1174
+ function isolatedQualificationMatches(path, config) {
1175
+ const isolated = config.isolatedQualification;
1176
+ if (!isIsolatedVoiceQualification(isolated)) return false;
1177
+ if (!isolatedQualificationPaths(isolated).includes(path)) return false;
1178
+ if (isProductionDesktopAppPath(isolated.appPath) || isProductionDesktopAppPath(config.desktopAppPath))
1179
+ return false;
1180
+ if (isolated.desktopPlatform !== config.desktopPlatform) return false;
1181
+ return isolated.desktopVersion === config.desktopVersion && isolated.desktopBuild === config.desktopBuild && isolated.asarDigest === config.asarDigest && isolated.appPath === config.desktopAppPath && isolated.implementationRevision === config.implementationRevision && typeof config.desktopBuild === "string" && config.desktopBuild !== "" && typeof config.asarDigest === "string" && config.asarDigest !== "" && typeof config.desktopAppPath === "string" && config.desktopAppPath !== "" && typeof config.implementationRevision === "string" && config.implementationRevision !== "";
1182
+ }
1183
+ function unsupportedReason(path, config) {
1184
+ if (path === "chat") {
1185
+ return nativeChatVoiceUnavailableReason(config) ?? "Chat voice is not qualified on this Desktop.";
1186
+ }
1187
+ return workVoiceUnavailableReason(config) ?? "Work voice is not qualified on this Desktop.";
1188
+ }
1189
+ function decidePath(path, config, records) {
1190
+ if (!config.desktopVersion || !config.desktopPlatform) {
1191
+ return { enabled: false, policy: "unreviewed", reason: "waiting-for-identity" };
1192
+ }
1193
+ const pathRecords = records.filter((record) => record.path === path);
1194
+ if (pathRecords.length > 0) {
1195
+ const matching = pathRecords.filter((record2) => evidenceMatchesRuntime(record2, config));
1196
+ if (matching.length === 0) {
1197
+ return { enabled: false, policy: "unreviewed", reason: "stale-or-wrong-platform-evidence" };
1198
+ }
1199
+ for (const record2 of matching) {
1200
+ const evaluation = evaluateVoiceEvidence(record2);
1201
+ if (!evaluation.qualified) {
1202
+ return { enabled: false, policy: "unreviewed", reason: evaluation.reason };
1203
+ }
1204
+ }
1205
+ const record = matching[0];
1206
+ if (!record) {
1207
+ return { enabled: false, policy: "unreviewed", reason: "missing-evidence" };
1208
+ }
1209
+ if (hashedVoiceCandidateOwner(config) && !hashedVoiceProfileSupported(config)) {
1210
+ } else {
1211
+ return {
1212
+ enabled: true,
1213
+ policy: record.policy === "legacy-retained" ? "legacy-retained" : "reviewed"
1214
+ };
1215
+ }
1216
+ }
1217
+ const digest = voiceProfileDigest(
1218
+ productForPath(path),
1219
+ config.desktopPlatform,
1220
+ config.desktopVersion
1221
+ );
1222
+ if (!digest) {
1223
+ return { enabled: false, policy: "unreviewed", reason: unsupportedReason(path, config) };
1224
+ }
1225
+ const legacy = legacyRetainedVoiceLanes().find(
1226
+ (lane) => lane.path === path && lane.platform === config.desktopPlatform && lane.version === config.desktopVersion
1227
+ );
1228
+ if (legacy) {
1229
+ return {
1230
+ enabled: true,
1231
+ policy: "legacy-retained",
1232
+ reason: "legacy-retained-named-profile"
1233
+ };
1234
+ }
1235
+ if (isolatedQualificationMatches(path, config)) {
1236
+ return {
1237
+ enabled: true,
1238
+ policy: "unreviewed",
1239
+ reason: "isolated-qualification"
1240
+ };
1241
+ }
1242
+ return { enabled: false, policy: "unreviewed", reason: "missing-evidence" };
1243
+ }
1244
+ function isVoiceEvidenceRecord(value) {
1245
+ if (!recordObject(value)) return false;
1246
+ return typeof value.profileKey === "string" && typeof value.platform === "string" && typeof value.desktopVersion === "string" && typeof value.implementationRevision === "string" && typeof value.profileDigest === "string" && (value.path === "chat" || value.path === "work-codex" || value.path === "work-grok") && recordObject(value.stages);
1247
+ }
1248
+ function voiceEvidenceRecordsFromConfig(config) {
1249
+ return (config.voiceEvidence ?? []).filter(isVoiceEvidenceRecord);
1250
+ }
1251
+ function startupVoiceGate(config) {
1252
+ const records = [
1253
+ ...voiceEvidenceRecordsFromConfig(config),
1254
+ ...config.evidence && isVoiceEvidenceRecord(config.evidence) ? [config.evidence] : []
1255
+ ];
1256
+ const chat = decidePath("chat", config, records);
1257
+ const workCodex = decidePath("work-codex", config, records);
1258
+ const workGrok = decidePath("work-grok", config, records);
1259
+ return {
1260
+ chat,
1261
+ "work-codex": workCodex,
1262
+ "work-grok": workGrok,
1263
+ work: workCodex
1264
+ };
1265
+ }
1266
+ function chatVoiceQualified(config) {
1267
+ return startupVoiceGate(config).chat.enabled;
1268
+ }
1269
+ function workVoiceLaneEnabled(owner, path) {
1270
+ return workVoicePathDecision(owner, path).enabled;
1271
+ }
1272
+ function workVoicePathDecision(owner, path) {
1273
+ const config = readCpaLiveVoiceHookConfig(owner);
1274
+ if (!config) {
1275
+ return {
1276
+ enabled: false,
1277
+ policy: "unreviewed",
1278
+ reason: workVoiceUnavailableReason({}) ?? "Work voice is not qualified on this Desktop."
1279
+ };
1280
+ }
1281
+ return startupVoiceGate(config)[path];
1282
+ }
1283
+ function workVoiceUserFacingUnavailable(owner, path) {
1284
+ void path;
1285
+ const config = readCpaLiveVoiceHookConfig(owner) ?? {};
1286
+ return workVoiceUnavailableReason(config) ?? "Work voice is not qualified on this Desktop.";
1287
+ }
1288
+ function chatVoiceUserFacingUnavailable(owner) {
1289
+ const config = readCpaLiveVoiceHookConfig(owner) ?? {};
1290
+ return nativeChatVoiceUnavailableReason(config) ?? "Chat voice is not qualified on this Desktop.";
1291
+ }
1292
+ function chatVoiceQualifiedOnOwner(owner) {
1293
+ const config = readCpaLiveVoiceHookConfig(owner);
1294
+ return config ? chatVoiceQualified(config) : false;
1295
+ }
1296
+
1297
+ // src/renderer-hashed-overlay-voice.ts
1298
+ var HOOK_GLOBAL = "__codexhostClientOwnedVoiceV1";
1299
+ var SHARED_VOICE_CACHE2 = "codexhost.voice-routes-cache.v1";
1300
+ var WORK_GATEWAY_FLAG = "codexhost.cpa-live-voice.v1";
1301
+ var CHAT_GATEWAY_FLAG = "codexhost.chat-live-voice.v1";
1302
+ function object2(value) {
1303
+ return value !== null && typeof value === "object";
1304
+ }
1305
+ function overlayCompactVoiceDocument(target) {
1306
+ try {
1307
+ const href = target.location?.href ?? globalThis.location?.href ?? "";
1308
+ return href.includes("avatar-overlay");
1309
+ } catch {
1310
+ return false;
1311
+ }
1312
+ }
1313
+ function visibleComposerLaunchExperience(target) {
1314
+ const document = target.document;
1315
+ if (!document?.querySelectorAll) return;
1316
+ const visible = (element) => {
1317
+ const box = element.getBoundingClientRect?.() ?? { width: 0 };
1318
+ return box.width > 0 && !element.closest?.("[hidden], [inert]");
1319
+ };
1320
+ const chat = [...document.querySelectorAll("[data-chatgpt-composer]")].some(visible);
1321
+ const work = [...document.querySelectorAll("[data-codex-composer-root]")].some(visible);
1322
+ if (chat && !work) return "chat";
1323
+ if (work && !chat) return "work";
1324
+ }
1325
+ function publishComposerLaunchExperience(target) {
1326
+ if (overlayCompactVoiceDocument(target)) return;
1327
+ rememberVoiceProductExperience(
1328
+ {
1329
+ productExperience: visibleComposerLaunchExperience(target) ?? (isWorkComposerSurface(target) ? "work" : "chat")
1330
+ },
1331
+ target
1332
+ );
1333
+ }
1334
+ function hashedOverlayVoiceSupported(config) {
1335
+ if (hashedVoiceProfileSupported(config)) return true;
1336
+ if (!hashedVoiceCandidateOwner(config)) return false;
1337
+ return isolatedVoicePathEnabled(config, "work-codex") || isolatedVoicePathEnabled(config, "work-grok");
1338
+ }
1339
+ function hashedWebpackVoiceSupported(config) {
1340
+ return hashedOverlayVoiceSupported(config);
1341
+ }
1342
+ function cachedConnection(owner, field) {
1343
+ try {
1344
+ const parsed = JSON.parse(
1345
+ owner.localStorage?.getItem(SHARED_VOICE_CACHE2) ?? "null"
1346
+ );
1347
+ return object2(parsed) ? parsed[field] : void 0;
1348
+ } catch {
1349
+ return void 0;
1350
+ }
1351
+ }
1352
+ function cachedChatExperience(owner) {
1353
+ try {
1354
+ const parsed = JSON.parse(
1355
+ owner.localStorage?.getItem(SHARED_VOICE_CACHE2) ?? "null"
1356
+ );
1357
+ return object2(parsed) ? parsed.chatExperience : void 0;
1358
+ } catch {
1359
+ return void 0;
1360
+ }
1361
+ }
1362
+ function storageFlag(owner, key, enabledWhenUnset) {
1363
+ const storage = owner.localStorage;
1364
+ if (!storage) return enabledWhenUnset;
1365
+ try {
1366
+ const value = storage.getItem(key);
1367
+ return enabledWhenUnset ? value !== "0" : value === "1";
1368
+ } catch {
1369
+ return enabledWhenUnset;
1370
+ }
1371
+ }
1372
+ function workGatewayPreference(owner) {
1373
+ const connection = cachedConnection(owner, "workConnection");
1374
+ return connection !== void 0 ? connection === "gateway" : storageFlag(owner, WORK_GATEWAY_FLAG, true);
1375
+ }
1376
+ function chatGatewayEnabled(owner) {
1377
+ const experience = cachedChatExperience(owner);
1378
+ const connection = cachedConnection(owner, "chatConnection");
1379
+ if (experience !== void 0 || connection !== void 0)
1380
+ return experience === "codex" && connection === "gateway";
1381
+ return storageFlag(owner, CHAT_GATEWAY_FLAG, false);
1382
+ }
1383
+ function nativeVoiceOwner(value) {
1384
+ return value !== null && (typeof value === "object" || typeof value === "function") ? value : void 0;
1385
+ }
1386
+ function nativeVoiceInstance(value) {
1387
+ const owner = nativeVoiceOwner(value);
1388
+ if (!owner) return value;
1389
+ const getInstance = Reflect.get(owner, "getInstance");
1390
+ return typeof getInstance === "function" ? getInstance.call(owner) : owner;
1391
+ }
1392
+ function nativeVoiceFetch(value) {
1393
+ const instance = nativeVoiceInstance(value);
1394
+ if (!object2(instance) || typeof instance.fetch !== "function") return void 0;
1395
+ return instance;
1396
+ }
1397
+ function nativeVoiceBridge(value) {
1398
+ const instance = nativeVoiceInstance(value);
1399
+ if (!object2(instance) || typeof instance.dispatchMessage !== "function" || typeof instance.subscribe !== "function") {
1400
+ return void 0;
1401
+ }
1402
+ return instance;
1403
+ }
1404
+ function isWebpackRequire(value) {
1405
+ return typeof value === "function";
1406
+ }
1407
+ function peekWebpackExport(req, id) {
1408
+ return req.c?.[id]?.exports;
1409
+ }
1410
+ function unpoisonIncompleteWebpackModule(req, id, usable) {
1411
+ const cache = req.c;
1412
+ const cached = cache?.[id];
1413
+ if (!cache || !cached || usable(cached.exports)) return;
1414
+ try {
1415
+ Reflect.deleteProperty(cache, id);
1416
+ } catch {
1417
+ }
1418
+ }
1419
+ function safeWebpackRequire(req, id) {
1420
+ const existing2 = peekWebpackExport(req, id);
1421
+ if (object2(existing2) && Object.keys(existing2).length > 0) return existing2;
1422
+ try {
1423
+ return req(id);
1424
+ } catch {
1425
+ unpoisonIncompleteWebpackModule(
1426
+ req,
1427
+ id,
1428
+ (value) => object2(value) && Object.keys(value).length > 0
1429
+ );
1430
+ return void 0;
1431
+ }
1432
+ }
1433
+ function readGdntExports(req) {
1434
+ const factoryId = HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId;
1435
+ const fetchExport = HASHED_OVERLAY_VOICE_ROLES.fetchExport;
1436
+ const peeked = peekWebpackExport(req, factoryId);
1437
+ if (nativeVoiceFetch(object2(peeked) ? peeked[fetchExport] : void 0)) return peeked;
1438
+ unpoisonIncompleteWebpackModule(
1439
+ req,
1440
+ factoryId,
1441
+ (value) => Boolean(nativeVoiceFetch(object2(value) ? value[fetchExport] : void 0))
1442
+ );
1443
+ if (typeof req.m?.[factoryId] !== "function") return safeWebpackRequire(req, factoryId);
1444
+ return void 0;
1445
+ }
1446
+ function hookWebpackVoiceFactory(req, onExports) {
1447
+ const modules = req.m;
1448
+ const factoryId = HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId;
1449
+ const original = modules?.[factoryId];
1450
+ if (!modules || typeof original !== "function") return false;
1451
+ if (original.__codexhostVoiceFactory) return true;
1452
+ const wrapped = function(module, exports, webpackRequire) {
1453
+ try {
1454
+ return original.apply(this, [module, exports, webpackRequire]);
1455
+ } finally {
1456
+ onExports(exports ?? module?.exports);
1457
+ }
1458
+ };
1459
+ wrapped.__codexhostVoiceFactory = true;
1460
+ modules[factoryId] = wrapped;
1461
+ return true;
1462
+ }
1463
+ async function resolveHashedWebpackVoice(importModule) {
1464
+ const runtime = await importModule(`app://-/assets/${HASHED_WEBPACK_VOICE_RUNTIME_ASSET}`);
1465
+ const req = runtime?.__webpack_require__;
1466
+ if (!isWebpackRequire(req)) return null;
1467
+ const roles = HASHED_OVERLAY_VOICE_ROLES;
1468
+ const gdnt = readGdntExports(req);
1469
+ const client = nativeVoiceFetch(object2(gdnt) ? gdnt[roles.fetchExport] : void 0);
1470
+ const hostBridge = safeWebpackRequire(req, roles.bridgeModuleId);
1471
+ const bridged = nativeVoiceBridge(
1472
+ object2(hostBridge) ? hostBridge[roles.bridgeExport] : void 0
1473
+ );
1474
+ const errorModule = safeWebpackRequire(req, roles.responseErrorModuleId);
1475
+ const responseError = object2(errorModule) ? errorModule[roles.responseErrorExport] : void 0;
1476
+ if (!bridged || typeof responseError !== "function") return null;
1477
+ if (client)
1478
+ return {
1479
+ client,
1480
+ bridge: bridged,
1481
+ responseError
1482
+ };
1483
+ if (typeof req.m?.[HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId] !== "function") return null;
1484
+ return {
1485
+ bridge: bridged,
1486
+ responseError,
1487
+ require: req
1488
+ };
1489
+ }
1490
+ function installHashedOverlayVoiceHook(options = {}) {
1491
+ const target = options.target ?? globalThis;
1492
+ const existing2 = target[HOOK_GLOBAL];
1493
+ if (existing2) return existing2;
1494
+ const config = readCpaLiveVoiceHookConfig(target);
1495
+ if (!config) return { status: "disabled", dispose() {
1496
+ } };
1497
+ if (!hashedWebpackVoiceSupported(config)) return { status: "unsupported", dispose() {
1498
+ } };
1499
+ const importModule = options.importModule ?? ((url) => import(url));
1500
+ let disposed = false;
1501
+ let timer;
1502
+ let surfaceTimer;
1503
+ let restore;
1504
+ const started = Date.now();
1505
+ const activation = {
1506
+ assetSeen: false,
1507
+ importStarted: false,
1508
+ importResolved: false,
1509
+ factoryHooked: false,
1510
+ wrapperActive: false
1511
+ };
1512
+ const pointerTarget = target.document;
1513
+ const onPointerDown = () => publishComposerLaunchExperience(target);
1514
+ const handle = {
1515
+ status: "pending",
1516
+ activation,
1517
+ dispose() {
1518
+ disposed = true;
1519
+ if (timer !== void 0) target.clearTimeout(timer);
1520
+ if (surfaceTimer !== void 0) target.clearTimeout(surfaceTimer);
1521
+ pointerTarget?.removeEventListener?.("pointerdown", onPointerDown, true);
1522
+ restore?.();
1523
+ if (target[HOOK_GLOBAL] === handle) Reflect.deleteProperty(target, HOOK_GLOBAL);
1524
+ }
1525
+ };
1526
+ target[HOOK_GLOBAL] = handle;
1527
+ pointerTarget?.addEventListener?.("pointerdown", onPointerDown, true);
1528
+ const publishLoop = () => {
1529
+ if (disposed) return;
1530
+ publishComposerLaunchExperience(target);
1531
+ surfaceTimer = target.setTimeout(publishLoop, 250);
1532
+ };
1533
+ publishLoop();
1534
+ const activate = (client, bridge, responseError) => {
1535
+ restore = wrapClientOwnedVoiceFetch(
1536
+ client,
1537
+ bridge,
1538
+ () => workGatewayPreference(target),
1539
+ responseError,
1540
+ () => chatGatewayEnabled(target),
1541
+ () => !overlayCompactVoiceDocument(target) && isWorkComposerSurface(target),
1542
+ () => false,
1543
+ () => overlayCompactVoiceDocument(target),
1544
+ () => workVoiceLaneEnabled(target, "work-grok"),
1545
+ () => workVoiceLaneEnabled(target, "work-codex"),
1546
+ (kind) => kind === "chat" ? chatVoiceUserFacingUnavailable(target) : workVoiceUserFacingUnavailable(
1547
+ target,
1548
+ kind === "external" ? "work-grok" : "work-codex"
1549
+ ),
1550
+ () => chatVoiceQualifiedOnOwner(target),
1551
+ () => false,
1552
+ () => nativeChatVoicePreferenceAllowsStart(target)
1553
+ );
1554
+ activation.wrapperActive = true;
1555
+ handle.status = "active";
1556
+ };
1557
+ const attempt = async () => {
1558
+ if (disposed || handle.status === "active") return;
1559
+ publishComposerLaunchExperience(target);
1560
+ const names = loadedAssetNames(target.document, target.performance);
1561
+ const hashedAssetSeen = names.some((name) => name.includes(HASHED_WEBPACK_VOICE_RUNTIME_ASSET));
1562
+ if (hashedAssetSeen) activation.assetSeen = true;
1563
+ if (hashedAssetSeen) {
1564
+ activation.importStarted = true;
1565
+ try {
1566
+ const resolved = await resolveHashedWebpackVoice(importModule);
1567
+ if (disposed || activation.wrapperActive) return;
1568
+ if (resolved?.client) {
1569
+ activation.importResolved = true;
1570
+ delete activation.importFailed;
1571
+ activate(resolved.client, resolved.bridge, resolved.responseError);
1572
+ return;
1573
+ }
1574
+ const webpackRequire = resolved?.require;
1575
+ if (webpackRequire && hookWebpackVoiceFactory(webpackRequire, (exports) => {
1576
+ if (disposed || activation.wrapperActive) return;
1577
+ const client = nativeVoiceFetch(
1578
+ object2(exports) ? exports[HASHED_OVERLAY_VOICE_ROLES.fetchExport] : void 0
1579
+ );
1580
+ if (!client) {
1581
+ unpoisonIncompleteWebpackModule(
1582
+ webpackRequire,
1583
+ HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId,
1584
+ (value) => Boolean(
1585
+ nativeVoiceFetch(
1586
+ object2(value) ? value[HASHED_OVERLAY_VOICE_ROLES.fetchExport] : void 0
1587
+ )
1588
+ )
1589
+ );
1590
+ return;
1591
+ }
1592
+ activate(client, resolved.bridge, resolved.responseError);
1593
+ })) {
1594
+ activation.importResolved = true;
1595
+ activation.factoryHooked = true;
1596
+ delete activation.importFailed;
1597
+ return;
1598
+ }
1599
+ activation.importFailed = "hashed-exports-missing";
1600
+ } catch {
1601
+ activation.importFailed = "hashed-import-failed";
1602
+ }
1603
+ }
1604
+ timer = target.setTimeout(() => void attempt(), Date.now() - started >= 5e3 ? 1e3 : 250);
1605
+ };
1606
+ void attempt();
1607
+ return handle;
1608
+ }
1609
+
1610
+ // src/overlay-voice-bootstrap-entry.ts
1611
+ var existing = Reflect.get(globalThis, "__codexhostClientOwnedVoiceV1");
1612
+ existing?.dispose?.();
1613
+ queueMicrotask(() => {
1614
+ installHashedOverlayVoiceHook();
1615
+ });
1616
+ })();