@karlorz/codexhost-cli-win32-x64 0.18.0-0 → 0.19.0-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +317 -59
  4. package/app/console-web.js +1889 -141
  5. package/app/cpa-live-voice-hook.js +1938 -428
  6. package/app/desktop-controller.mjs +2081 -212
  7. package/app/host-runtime.mjs +14818 -3381
  8. package/app/overlay-voice-bootstrap.js +1616 -0
  9. package/app/plugins/antigravity/plugin.mjs +963 -324
  10. package/app/plugins/claude-code/plugin.mjs +395 -67
  11. package/app/plugins/codebuddy/plugin.mjs +409 -76
  12. package/app/plugins/codex-usage/plugin.mjs +316 -58
  13. package/app/plugins/copilot/plugin.mjs +316 -58
  14. package/app/plugins/cursor-cli/plugin.mjs +391 -68
  15. package/app/plugins/deepseek-harness/manifest.json +2 -2
  16. package/app/plugins/deepseek-harness/plugin.mjs +343 -63
  17. package/app/plugins/devin/plugin.mjs +316 -58
  18. package/app/plugins/grok/plugin.mjs +1350 -1026
  19. package/app/plugins/hermes/plugin.mjs +395 -70
  20. package/app/plugins/kimi-code/plugin.mjs +316 -58
  21. package/app/plugins/kiro-cli/plugin.mjs +544 -74
  22. package/app/plugins/omp/plugin.mjs +1264 -902
  23. package/app/plugins/opencode/plugin.mjs +316 -58
  24. package/app/plugins/pi/plugin.mjs +1189 -862
  25. package/app/plugins/qoder/plugin.mjs +318 -62
  26. package/app/plugins/qoder-cn/plugin.mjs +318 -62
  27. package/app/plugins/qwen-code/plugin.mjs +425 -150
  28. package/app/plugins/workbuddy/plugin.mjs +409 -76
  29. package/app/plugins/zcode/plugin.mjs +389 -61
  30. package/app/renderer-extension.js +11830 -8531
  31. package/app/voice-profile-pins.json +25 -0
  32. package/app/voice-qualification.json +4 -0
  33. package/app/web/assets/index-BCyiiDDL.js +199 -0
  34. package/app/web/assets/index-BNQIOOHE.css +1 -0
  35. package/app/web/codexhost-settings.js +1895 -190
  36. package/app/web/index.html +2 -2
  37. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  38. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  39. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  40. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +65 -63
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  54. package/app/web-modules/server.mjs +3279 -1676
  55. package/bin/codexhost.exe +0 -0
  56. package/libexec/codexhost-node-repl.exe +0 -0
  57. package/libexec/codexhost-shim.exe +0 -0
  58. package/libexec/codexhost-updater.exe +0 -0
  59. package/package.json +1 -1
  60. package/app/web/assets/index-Bs17Kuah.js +0 -199
  61. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -728,9 +728,9 @@
728
728
  return ratio - roundedRatio;
729
729
  }
730
730
  var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
731
- function defineLazy(object3, key, getter) {
731
+ function defineLazy(object5, key, getter) {
732
732
  let value = void 0;
733
- Object.defineProperty(object3, key, {
733
+ Object.defineProperty(object5, key, {
734
734
  get() {
735
735
  if (value === EVALUATING) {
736
736
  return void 0;
@@ -742,7 +742,7 @@
742
742
  return value;
743
743
  },
744
744
  set(v) {
745
- Object.defineProperty(object3, key, {
745
+ Object.defineProperty(object5, key, {
746
746
  value: v
747
747
  // configurable: true,
748
748
  });
@@ -14547,7 +14547,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14547
14547
  origin: goalOriginSchema
14548
14548
  });
14549
14549
 
14550
- // ../shared-contracts/dist/realtime-call.js
14550
+ // ../shared-contracts/dist/realtime-call-core.js
14551
14551
  var REALTIME_CALL_METHOD = "codexhost/realtime/call";
14552
14552
  var REALTIME_CALL_FORWARDED_HEADERS = [
14553
14553
  "openai-alpha",
@@ -14566,7 +14566,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14566
14566
  }
14567
14567
  return result;
14568
14568
  }
14569
- var REALTIME_CALL_ID_PATTERN = /^rtc_[A-Za-z0-9_-]{1,128}$/u;
14569
+ var REALTIME_CALL_ID_PATTERN = /^[A-Za-z0-9_-]{1,128}$/u;
14570
14570
  function isRealtimeCallId(value) {
14571
14571
  return typeof value === "string" && REALTIME_CALL_ID_PATTERN.test(value);
14572
14572
  }
@@ -14576,6 +14576,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14576
14576
  return path;
14577
14577
  return /\/(?:calls|live)\/([A-Za-z0-9_-]{1,128})$/u.exec(path)?.[1];
14578
14578
  }
14579
+
14580
+ // ../shared-contracts/dist/realtime-call.js
14579
14581
  var requestId = external_exports.string().min(1).max(128);
14580
14582
  var realtimeCallParamsSchema = external_exports.discriminatedUnion("operation", [
14581
14583
  external_exports.object({
@@ -14630,12 +14632,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14630
14632
  var RELAY_PUBLIC_RESOURCE = `${RELAY_PUBLIC_ORIGIN}/mcp`;
14631
14633
  var RELAY_WAIT_TIMEOUT_MAX_MS = 25e3;
14632
14634
  var RELAY_MAX_BODY_BYTES = 2 * 1024 * 1024;
14633
- var RELAY_ALLOWED_ROUTES = [
14634
- "/v1/enroll/status",
14635
- "/v1/thread/read",
14636
- "/v1/thread/wait",
14637
- "/v1/thread/send"
14638
- ];
14639
14635
  var relayLinkHelloSchema = external_exports.strictObject({
14640
14636
  v: external_exports.literal(RELAY_LINK_PROTOCOL_VERSION),
14641
14637
  secret: external_exports.string().min(1).max(4096)
@@ -14647,8 +14643,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14647
14643
  var relayLinkRequestSchema = external_exports.strictObject({
14648
14644
  requestId: external_exports.string().min(1).max(128),
14649
14645
  deadlineMs: external_exports.number().int().positive(),
14650
- route: external_exports.enum(RELAY_ALLOWED_ROUTES),
14651
- body: external_exports.record(external_exports.string(), external_exports.unknown())
14646
+ route: external_exports.string().min(1).max(128),
14647
+ body: external_exports.record(external_exports.string(), external_exports.unknown()),
14648
+ operationalClient: external_exports.string().min(1).max(64).optional(),
14649
+ oauthClientId: external_exports.string().min(1).max(128).optional(),
14650
+ dispatchGrant: external_exports.enum(["legacy-four", "full-dispatch"]).optional()
14652
14651
  });
14653
14652
  var relayLinkErrorSchema = external_exports.strictObject({
14654
14653
  code: external_exports.string().min(1).max(64),
@@ -14692,6 +14691,204 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14692
14691
  runtime: external_exports.enum(["reachable", "unreachable"])
14693
14692
  });
14694
14693
 
14694
+ // ../shared-contracts/dist/external-clients.js
14695
+ var EXTERNAL_CLIENT_NAME_PATTERN = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/u;
14696
+ var externalClientNameSchema = external_exports.string().trim().min(1).max(64).regex(EXTERNAL_CLIENT_NAME_PATTERN);
14697
+ var externalClientAccessSchema = external_exports.enum(["all-threads", "selected-workspaces"]);
14698
+ var externalClientConnectionModeSchema = external_exports.enum(["public-relay", "local", "direct"]);
14699
+ var externalClientDispatchGrantSchema = external_exports.enum(["legacy-four", "full-dispatch"]);
14700
+ var workspacePathSchema = external_exports.string().trim().min(1).max(4096);
14701
+ var directUrlSchema = external_exports.string().trim().max(2048);
14702
+ var externalClientPublicViewSchema = external_exports.strictObject({
14703
+ name: externalClientNameSchema,
14704
+ createdAt: external_exports.string().min(1).max(64),
14705
+ access: externalClientAccessSchema,
14706
+ workspaces: external_exports.array(workspacePathSchema).max(64),
14707
+ connectionMode: externalClientConnectionModeSchema,
14708
+ dispatchGrant: externalClientDispatchGrantSchema,
14709
+ oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
14710
+ directUrl: directUrlSchema.optional(),
14711
+ mcpUrl: external_exports.string().min(1).max(2048).optional(),
14712
+ mcpUrlNote: external_exports.string().min(1).max(512).optional()
14713
+ });
14714
+ var externalClientListParamsSchema = external_exports.strictObject({});
14715
+ var externalClientListResultSchema = external_exports.strictObject({
14716
+ clients: external_exports.array(externalClientPublicViewSchema).max(256)
14717
+ });
14718
+ var externalClientWriteFieldsSchema = external_exports.strictObject({
14719
+ access: externalClientAccessSchema.optional(),
14720
+ workspaces: external_exports.array(workspacePathSchema).max(64).optional(),
14721
+ connectionMode: externalClientConnectionModeSchema.optional(),
14722
+ dispatchGrant: externalClientDispatchGrantSchema.optional(),
14723
+ oauthClientId: external_exports.string().trim().min(1).max(128).optional(),
14724
+ directUrl: directUrlSchema.optional()
14725
+ });
14726
+ var externalClientCreateParamsSchema = externalClientWriteFieldsSchema.extend({
14727
+ name: externalClientNameSchema
14728
+ });
14729
+ var externalClientCreateResultSchema = externalClientPublicViewSchema.extend({
14730
+ token: external_exports.string().min(1).max(256).optional()
14731
+ });
14732
+ var externalClientUpdateParamsSchema = externalClientWriteFieldsSchema.extend({
14733
+ name: externalClientNameSchema,
14734
+ clearOauthClientId: external_exports.literal(true).optional()
14735
+ });
14736
+ var externalClientRevokeParamsSchema = external_exports.strictObject({
14737
+ name: externalClientNameSchema
14738
+ });
14739
+ var externalClientRevokeResultSchema = external_exports.strictObject({
14740
+ name: externalClientNameSchema,
14741
+ revoked: external_exports.literal(true)
14742
+ });
14743
+ var stringProp = (description) => ({ type: "string", description });
14744
+ var integerProp = (description) => ({
14745
+ type: "integer",
14746
+ minimum: 0,
14747
+ description
14748
+ });
14749
+ var threadProp = stringProp("Thread id or codex://threads/<id> link");
14750
+ var EXTERNAL_MCP_TOOL_DESCRIPTORS = [
14751
+ {
14752
+ name: "harness_list",
14753
+ description: "List the Harnesses this codexhost can delegate to.",
14754
+ inputSchema: { type: "object", properties: {} }
14755
+ },
14756
+ {
14757
+ name: "harness_inspect",
14758
+ description: "Read a Harness's Models, Thinking options and defaults; use the returned ids when delegating.",
14759
+ inputSchema: {
14760
+ type: "object",
14761
+ properties: {
14762
+ harnessId: stringProp("Harness id from harness_list"),
14763
+ cwd: stringProp("Absolute workspace path"),
14764
+ refresh: { type: "boolean" }
14765
+ },
14766
+ required: ["harnessId"]
14767
+ }
14768
+ },
14769
+ {
14770
+ name: "delegate_start",
14771
+ description: "Start a task in a new Thread and return at once. Without parentThread the work belongs to this client and cwd is required. watch=true records an event for this client when the Thread stops (read it with events_poll or the SSE stream).",
14772
+ inputSchema: {
14773
+ type: "object",
14774
+ properties: {
14775
+ harnessId: stringProp("Harness id from harness_list"),
14776
+ task: stringProp("The full task text"),
14777
+ taskName: stringProp("Short display name"),
14778
+ cwd: stringProp("Absolute workspace path"),
14779
+ model: stringProp("Model id from harness_inspect"),
14780
+ thinking: stringProp("Thinking option id from harness_inspect"),
14781
+ parentThread: stringProp("Optional parent Thread"),
14782
+ requestId: stringProp("Reuse to retry idempotently"),
14783
+ refs: {
14784
+ type: "array",
14785
+ items: { type: "string" },
14786
+ description: "Absolute URIs of where the work came from"
14787
+ },
14788
+ watch: { type: "boolean", description: "Record an event when the Thread stops" },
14789
+ watchTimeoutMs: integerProp("How long to watch; default 29 minutes")
14790
+ },
14791
+ required: ["harnessId", "task"]
14792
+ }
14793
+ },
14794
+ {
14795
+ name: "thread_read",
14796
+ description: "Read a Thread's status and latest result, or page its visible messages (view=messages). Never changes the Thread.",
14797
+ inputSchema: {
14798
+ type: "object",
14799
+ properties: {
14800
+ thread: threadProp,
14801
+ view: { type: "string", enum: ["result", "messages"] },
14802
+ cursor: stringProp("Message cursor"),
14803
+ limit: integerProp("Messages per page, at most 100")
14804
+ },
14805
+ required: ["thread"]
14806
+ }
14807
+ },
14808
+ {
14809
+ name: "thread_wait",
14810
+ description: "Wait up to timeoutMs (at most 60000) for a Thread to stop, then return the same snapshot as thread_read plus timedOut.",
14811
+ inputSchema: {
14812
+ type: "object",
14813
+ properties: {
14814
+ thread: threadProp,
14815
+ timeoutMs: integerProp("At most 60000; default 30000"),
14816
+ view: { type: "string", enum: ["result", "messages"] }
14817
+ },
14818
+ required: ["thread"]
14819
+ }
14820
+ },
14821
+ {
14822
+ name: "thread_list",
14823
+ description: "List Threads: by workspace (cwd), by parent Thread, by the client that started them, or by reference.",
14824
+ inputSchema: {
14825
+ type: "object",
14826
+ properties: {
14827
+ cwd: stringProp("Absolute workspace path"),
14828
+ parent: stringProp("Parent Thread"),
14829
+ client: stringProp("Client name"),
14830
+ ref: stringProp("Reference URI"),
14831
+ limit: integerProp("At most 100; default 25"),
14832
+ cursor: stringProp("Cursor from a previous page"),
14833
+ sort: {
14834
+ type: "string",
14835
+ enum: [
14836
+ "created-asc",
14837
+ "created-desc",
14838
+ "updated-asc",
14839
+ "updated-desc",
14840
+ "recency-asc",
14841
+ "recency-desc"
14842
+ ]
14843
+ }
14844
+ }
14845
+ }
14846
+ },
14847
+ {
14848
+ name: "thread_send",
14849
+ description: "Start a new Turn in an idle Thread. THREAD_BUSY means its current Turn is still running; messages are not queued.",
14850
+ inputSchema: {
14851
+ type: "object",
14852
+ properties: { thread: threadProp, message: stringProp("Message text") },
14853
+ required: ["thread", "message"]
14854
+ }
14855
+ },
14856
+ {
14857
+ name: "thread_cancel",
14858
+ description: "Cancel a Thread's active Turn, keeping the Thread and its history.",
14859
+ inputSchema: { type: "object", properties: { thread: threadProp }, required: ["thread"] }
14860
+ },
14861
+ {
14862
+ name: "thread_watch",
14863
+ description: "Record one event for this client when the Thread stops or the watch expires.",
14864
+ inputSchema: {
14865
+ type: "object",
14866
+ properties: { thread: threadProp, timeoutMs: integerProp("Default 29 minutes") },
14867
+ required: ["thread"]
14868
+ }
14869
+ },
14870
+ {
14871
+ name: "thread_watches",
14872
+ description: "List watches that have not been delivered yet.",
14873
+ inputSchema: { type: "object", properties: {} }
14874
+ },
14875
+ {
14876
+ name: "events_poll",
14877
+ description: "Read this client's events after a cursor (0 for all retained). Waits up to timeoutMs (at most 60000) for the first one. Pass the returned cursor back next time. CURSOR_EXPIRED: reconcile with thread_list client=<this client>.",
14878
+ inputSchema: {
14879
+ type: "object",
14880
+ properties: {
14881
+ after: integerProp("Cursor; 0 for all retained"),
14882
+ timeoutMs: integerProp("At most 60000; default 0"),
14883
+ limit: integerProp("At most 100")
14884
+ }
14885
+ }
14886
+ }
14887
+ ];
14888
+
14889
+ // ../shared-contracts/dist/external-mcp-map.js
14890
+ var DEFAULT_WATCH_MS = 29 * 6e4;
14891
+
14695
14892
  // ../shared-contracts/dist/grok-computer-use.js
14696
14893
  var grokComputerUseGetSchema = external_exports.object({}).strict();
14697
14894
  var grokComputerUseSetSchema = external_exports.object({
@@ -15289,11 +15486,62 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15289
15486
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15290
15487
  }).strict();
15291
15488
 
15489
+ // ../shared-contracts/dist/voice-settings.js
15490
+ var VOICE_GATEWAY_STATUS_METHOD = "codexhost/voice/gateway-status";
15491
+ var voiceRoutesSchema = external_exports.strictObject({
15492
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
15493
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
15494
+ workConnection: external_exports.enum(["desktop", "gateway"])
15495
+ });
15496
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
15497
+ chatExperience: "chatgpt",
15498
+ chatConnection: "desktop",
15499
+ workConnection: "gateway"
15500
+ });
15501
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
15502
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
15503
+ external_exports.strictObject({
15504
+ operation: external_exports.literal("get"),
15505
+ runtime: external_exports.strictObject({
15506
+ id: external_exports.string().uuid(),
15507
+ revision: external_exports.string().max(64),
15508
+ activeCall: external_exports.boolean()
15509
+ }).optional()
15510
+ }),
15511
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
15512
+ external_exports.strictObject({
15513
+ operation: external_exports.literal("set"),
15514
+ settings: voiceSettingsSchema,
15515
+ revision: external_exports.string().max(64)
15516
+ }),
15517
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
15518
+ ]);
15519
+ var voiceSettingsStateSchema = external_exports.strictObject({
15520
+ settings: voiceSettingsSchema,
15521
+ initialized: external_exports.boolean(),
15522
+ revision: external_exports.string(),
15523
+ activeInject: external_exports.boolean().nullable(),
15524
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
15525
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
15526
+ routesActive: external_exports.boolean().nullable(),
15527
+ activeCall: external_exports.boolean().nullable(),
15528
+ gatewayReady: external_exports.boolean().nullable(),
15529
+ restartAvailable: external_exports.boolean(),
15530
+ restart: external_exports.strictObject({
15531
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
15532
+ error: external_exports.string().nullable()
15533
+ })
15534
+ });
15535
+
15292
15536
  // ../shared-contracts/dist/client-channel.js
15293
15537
  var CLIENT_CHANNEL_VERSION = 1;
15294
15538
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15295
15539
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15296
15540
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15541
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
15542
+ var clientThreadTreeSchema = external_exports.object({
15543
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
15544
+ }).strict();
15297
15545
  var clientProjectlessWorkspaceSchema = external_exports.object({
15298
15546
  prompt: external_exports.string().max(16384).optional()
15299
15547
  }).strict();
@@ -15310,6 +15558,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15310
15558
  sequence: external_exports.number().int().nonnegative()
15311
15559
  });
15312
15560
  var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15561
+ external_exports.object({
15562
+ type: external_exports.literal("skills-changed"),
15563
+ cursor: clientChannelCursorSchema,
15564
+ cwd: external_exports.string().optional()
15565
+ }),
15313
15566
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15314
15567
  external_exports.object({
15315
15568
  type: external_exports.literal("preferences-changed"),
@@ -15507,6 +15760,28 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15507
15760
  external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
15508
15761
  ]);
15509
15762
 
15763
+ // ../shared-contracts/dist/skills.js
15764
+ var skillsListParamsSchema = external_exports.object({
15765
+ threadId: hostThreadIdSchema.optional(),
15766
+ cwd: external_exports.string().min(1).optional()
15767
+ }).strict().refine((params) => !(params.threadId && params.cwd), {
15768
+ message: "Specify threadId or cwd, not both"
15769
+ });
15770
+ var librarySkillSchema = external_exports.object({
15771
+ name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
15772
+ description: external_exports.string().optional(),
15773
+ path: external_exports.string().min(1),
15774
+ scope: external_exports.enum(["project", "global"]),
15775
+ source: external_exports.string().min(1)
15776
+ }).strict();
15777
+ var skillsListResultSchema = external_exports.object({
15778
+ revision: external_exports.number().int().nonnegative(),
15779
+ complete: external_exports.boolean(),
15780
+ skills: external_exports.array(librarySkillSchema),
15781
+ warnings: external_exports.array(external_exports.string()).optional()
15782
+ }).strict();
15783
+ var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
15784
+
15510
15785
  // ../shared-contracts/dist/web-access-tokens.js
15511
15786
  var webNetworkAccessUrlSchema = external_exports.object({
15512
15787
  /**
@@ -15613,8 +15888,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15613
15888
  var delegationReadParamsSchema = external_exports.strictObject({
15614
15889
  threadId: external_exports.string().min(1).max(1024),
15615
15890
  view: external_exports.enum(["result", "messages"]),
15616
- cursor: external_exports.string().min(1).max(8192).optional(),
15617
- limit: external_exports.number().int().min(1).max(100).optional()
15891
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
15892
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
15618
15893
  });
15619
15894
 
15620
15895
  // ../shared-contracts/dist/credential-imports.js
@@ -16066,6 +16341,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16066
16341
  "codexhost/voice/gateway-status",
16067
16342
  "codexhost/enrollment/list",
16068
16343
  "codexhost/enrollment/revoke",
16344
+ "codexhost/external-clients/list",
16345
+ "codexhost/external-clients/create",
16346
+ "codexhost/external-clients/update",
16347
+ "codexhost/external-clients/revoke",
16069
16348
  "codexhost/console/remote-connections",
16070
16349
  "codexhost/runtime/status",
16071
16350
  "codexhost/remote/ssh-setup",
@@ -16607,6 +16886,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16607
16886
  status: updateStatusSchema.nullable()
16608
16887
  });
16609
16888
 
16889
+ // ../shared-contracts/dist/thread-watch-notice.js
16890
+ var THREAD_WATCH_NOTICE_OUTCOMES = [
16891
+ "completed",
16892
+ "failed",
16893
+ "interrupted",
16894
+ "timedOut",
16895
+ "unreadable",
16896
+ "notFound"
16897
+ ];
16898
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
16899
+
16610
16900
  // ../shared-contracts/dist/remote-runtime.js
16611
16901
  var remoteUpdatePhaseSchema = external_exports.enum([
16612
16902
  "idle",
@@ -16654,6 +16944,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16654
16944
  archived: external_exports.boolean()
16655
16945
  }),
16656
16946
  external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16947
+ external_exports.strictObject({
16948
+ kind: external_exports.literal("configure"),
16949
+ ...thread,
16950
+ epoch: identity,
16951
+ modelId: identity.optional(),
16952
+ thinkingOptionId: identity.optional(),
16953
+ permissionModeId: identity.optional()
16954
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
16657
16955
  external_exports.strictObject({
16658
16956
  kind: external_exports.literal("prompt"),
16659
16957
  ...thread,
@@ -16726,6 +17024,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16726
17024
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16727
17025
  ]);
16728
17026
 
17027
+ // ../shared-contracts/dist/thread-title.js
17028
+ var threadTitleInputSchema = external_exports.strictObject({
17029
+ prompt: external_exports.string().trim().min(1).max(2e3),
17030
+ cwd: external_exports.string().max(4096).nullable()
17031
+ });
17032
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
17033
+
16729
17034
  // ../shared-contracts/dist/web-ui-extensions.js
16730
17035
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
16731
17036
  var localizedTextSchema2 = external_exports.union([
@@ -16766,53 +17071,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16766
17071
  var webUiExtensionEnabledSchema = external_exports.object({ id: webUiExtensionIdSchema, enabled: external_exports.boolean() }).strict();
16767
17072
  var webUiExtensionRemoveSchema = external_exports.object({ id: webUiExtensionIdSchema }).strict();
16768
17073
 
16769
- // ../shared-contracts/dist/voice-settings.js
16770
- var VOICE_GATEWAY_STATUS_METHOD = "codexhost/voice/gateway-status";
16771
- var voiceRoutesSchema = external_exports.strictObject({
16772
- chatExperience: external_exports.enum(["chatgpt", "codex"]),
16773
- chatConnection: external_exports.enum(["desktop", "gateway"]),
16774
- workConnection: external_exports.enum(["desktop", "gateway"])
16775
- });
16776
- var DEFAULT_VOICE_ROUTES = Object.freeze({
16777
- chatExperience: "chatgpt",
16778
- chatConnection: "desktop",
16779
- workConnection: "gateway"
16780
- });
16781
- var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
16782
- var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
16783
- external_exports.strictObject({
16784
- operation: external_exports.literal("get"),
16785
- runtime: external_exports.strictObject({
16786
- id: external_exports.string().uuid(),
16787
- revision: external_exports.string().max(64),
16788
- activeCall: external_exports.boolean()
16789
- }).optional()
16790
- }),
16791
- external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
16792
- external_exports.strictObject({
16793
- operation: external_exports.literal("set"),
16794
- settings: voiceSettingsSchema,
16795
- revision: external_exports.string().max(64)
16796
- }),
16797
- external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
16798
- ]);
16799
- var voiceSettingsStateSchema = external_exports.strictObject({
16800
- settings: voiceSettingsSchema,
16801
- initialized: external_exports.boolean(),
16802
- revision: external_exports.string(),
16803
- activeInject: external_exports.boolean().nullable(),
16804
- envOverride: external_exports.enum(["0", "1"]).nullable(),
16805
- activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
16806
- routesActive: external_exports.boolean().nullable(),
16807
- activeCall: external_exports.boolean().nullable(),
16808
- gatewayReady: external_exports.boolean().nullable(),
16809
- restartAvailable: external_exports.boolean(),
16810
- restart: external_exports.strictObject({
16811
- phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
16812
- error: external_exports.string().nullable()
16813
- })
16814
- });
16815
-
16816
17074
  // ../shared-contracts/dist/background-activity.js
16817
17075
  var backgroundActivitySchema = external_exports.strictObject({
16818
17076
  id: external_exports.string().min(1),
@@ -16847,30 +17105,42 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16847
17105
  // ../shared-contracts/dist/index.js
16848
17106
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16849
17107
 
16850
- // src/renderer-cpa-live-voice-preference.ts
16851
- var voiceStateOwner = globalThis;
16852
- var { sharedRoutes, gatewayReady } = voiceStateOwner.__codexhostVoicePreferenceStateV1 ??= {
16853
- sharedRoutes: /* @__PURE__ */ new WeakMap(),
16854
- gatewayReady: /* @__PURE__ */ new WeakMap()
16855
- };
17108
+ // src/renderer-voice-routes-cache.ts
16856
17109
  var SHARED_VOICE_CACHE = "codexhost.voice-routes-cache.v1";
16857
- function cachedRoutes(owner) {
17110
+ var CPA_LIVE_VOICE_STORAGE_KEY = "codexhost.cpa-live-voice.v1";
17111
+ var CHAT_LIVE_VOICE_STORAGE_KEY = "codexhost.chat-live-voice.v1";
17112
+ var voiceStateOwner = globalThis;
17113
+ function voicePreferenceState() {
17114
+ return voiceStateOwner.__codexhostVoicePreferenceStateV1 ??= {
17115
+ sharedRoutes: /* @__PURE__ */ new WeakMap(),
17116
+ gatewayReady: /* @__PURE__ */ new WeakMap()
17117
+ };
17118
+ }
17119
+ function parseVoiceRoutes(value) {
17120
+ if (value === null || typeof value !== "object") return;
17121
+ const record5 = value;
17122
+ if (record5.chatExperience !== "chatgpt" && record5.chatExperience !== "codex" || record5.chatConnection !== "desktop" && record5.chatConnection !== "gateway" || record5.workConnection !== "desktop" && record5.workConnection !== "gateway")
17123
+ return;
17124
+ return {
17125
+ chatExperience: record5.chatExperience,
17126
+ chatConnection: record5.chatConnection,
17127
+ workConnection: record5.workConnection
17128
+ };
17129
+ }
17130
+ function cachedVoiceRoutes(owner) {
17131
+ const { sharedRoutes } = voicePreferenceState();
16858
17132
  const memory = sharedRoutes.get(owner);
16859
17133
  if (memory) return memory;
16860
17134
  try {
16861
17135
  const storage = owner.localStorage;
16862
- const parsed = voiceRoutesSchema.safeParse(
16863
- JSON.parse(storage?.getItem(SHARED_VOICE_CACHE) ?? "null")
16864
- ).data;
17136
+ const parsed = parseVoiceRoutes(JSON.parse(storage?.getItem(SHARED_VOICE_CACHE) ?? "null"));
16865
17137
  if (parsed) sharedRoutes.set(owner, parsed);
16866
17138
  return parsed;
16867
17139
  } catch {
16868
17140
  return void 0;
16869
17141
  }
16870
17142
  }
16871
- var CPA_LIVE_VOICE_STORAGE_KEY = "codexhost.cpa-live-voice.v1";
16872
- var CHAT_LIVE_VOICE_STORAGE_KEY = "codexhost.chat-live-voice.v1";
16873
- function readFlag(owner, key, enabledWhenUnset) {
17143
+ function readVoiceStorageFlag(owner, key, enabledWhenUnset) {
16874
17144
  const storage = owner.localStorage;
16875
17145
  if (!storage) return enabledWhenUnset;
16876
17146
  try {
@@ -16880,13 +17150,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16880
17150
  return enabledWhenUnset;
16881
17151
  }
16882
17152
  }
17153
+ function nativeChatVoicePreferenceAllowsStart(owner) {
17154
+ const routes = cachedVoiceRoutes(owner);
17155
+ return routes ? routes.chatExperience === "chatgpt" : !readVoiceStorageFlag(owner, CHAT_LIVE_VOICE_STORAGE_KEY, false);
17156
+ }
17157
+
17158
+ // src/renderer-cpa-live-voice-preference.ts
16883
17159
  function readCpaLiveVoicePreference(owner) {
16884
- const routes = cachedRoutes(owner);
16885
- return routes ? routes.workConnection === "gateway" : readFlag(owner, CPA_LIVE_VOICE_STORAGE_KEY, true);
17160
+ const routes = cachedVoiceRoutes(owner);
17161
+ return routes ? routes.workConnection === "gateway" : readVoiceStorageFlag(owner, CPA_LIVE_VOICE_STORAGE_KEY, true);
16886
17162
  }
16887
17163
  function readChatLiveVoicePreference(owner) {
16888
- const routes = cachedRoutes(owner);
16889
- return routes ? routes.chatExperience === "codex" && routes.chatConnection === "gateway" : readFlag(owner, CHAT_LIVE_VOICE_STORAGE_KEY, false);
17164
+ const routes = cachedVoiceRoutes(owner);
17165
+ return routes ? routes.chatExperience === "codex" && routes.chatConnection === "gateway" : readVoiceStorageFlag(owner, CHAT_LIVE_VOICE_STORAGE_KEY, false);
16890
17166
  }
16891
17167
  function cpaLiveVoicePreferenceAllowsInstall(globalObject) {
16892
17168
  return readCpaLiveVoicePreference(globalObject);
@@ -16895,13 +17171,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16895
17171
  return readChatLiveVoicePreference(globalObject);
16896
17172
  }
16897
17173
 
16898
- // src/renderer-cpa-live-voice-hook.ts
17174
+ // src/renderer-cpa-live-voice-config.ts
16899
17175
  var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
16900
- var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
16901
- var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
16902
- var THREAD_REALTIME_EXISTING_CALL_GATE = "206132468";
16903
- var originalCheckGate = /* @__PURE__ */ new WeakMap();
16904
- var DISCOVERY_TIMEOUT_MS = 6e4;
17176
+ var ISOLATED_VOICE_PATHS = ["chat", "work-codex", "work-grok"];
17177
+ var PRODUCTION_DESKTOP_APP_PATH = "/Applications/ChatGPT.app";
17178
+ var PRODUCTION_WINDOWS_APPX_PATH = /(?:^|[\\/])WindowsApps[\\/]OpenAI\.(?:Codex|ChatGPT)_/i;
17179
+ function isProductionDesktopAppPath(appPath) {
17180
+ if (typeof appPath !== "string" || appPath.length === 0) return false;
17181
+ if (appPath === PRODUCTION_DESKTOP_APP_PATH) return true;
17182
+ return PRODUCTION_WINDOWS_APPX_PATH.test(appPath);
17183
+ }
16905
17184
  function isRecord(value) {
16906
17185
  return typeof value === "object" && value !== null;
16907
17186
  }
@@ -16916,8 +17195,59 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16916
17195
  auditedDesktopVersion: value.auditedDesktopVersion,
16917
17196
  auditedAppInitialAsset: value.auditedAppInitialAsset,
16918
17197
  ...typeof value.desktopPlatform === "string" ? { desktopPlatform: value.desktopPlatform } : {},
16919
- ...typeof value.desktopVersion === "string" ? { desktopVersion: value.desktopVersion } : {}
16920
- };
17198
+ ...typeof value.desktopVersion === "string" ? { desktopVersion: value.desktopVersion } : {},
17199
+ ...typeof value.desktopBuild === "string" ? { desktopBuild: value.desktopBuild } : {},
17200
+ ...typeof value.asarDigest === "string" ? { asarDigest: value.asarDigest } : {},
17201
+ ...typeof value.implementationRevision === "string" ? { implementationRevision: value.implementationRevision } : {},
17202
+ ...typeof value.desktopAppPath === "string" ? { desktopAppPath: value.desktopAppPath } : {},
17203
+ ...Array.isArray(value.voiceEvidence) ? { voiceEvidence: value.voiceEvidence } : {},
17204
+ ...isIsolatedVoiceQualification(value.isolatedQualification) ? { isolatedQualification: value.isolatedQualification } : {}
17205
+ };
17206
+ }
17207
+ function isIsolatedVoicePath(value) {
17208
+ return value === "chat" || value === "work-codex" || value === "work-grok";
17209
+ }
17210
+ function isIsolatedDesktopPlatform(value) {
17211
+ return value === "darwin" || value === "win32" || value === "linux";
17212
+ }
17213
+ function isolatedQualificationExpiresAtMs(expiresAt) {
17214
+ if (typeof expiresAt !== "string" || expiresAt.length === 0) return void 0;
17215
+ const parsed = Date.parse(expiresAt);
17216
+ return Number.isFinite(parsed) ? parsed : void 0;
17217
+ }
17218
+ function isolatedQualificationPathSet(value) {
17219
+ if (!isRecord(value)) return void 0;
17220
+ const pathsPresent = value.paths !== void 0;
17221
+ const pathPresent = value.path !== void 0;
17222
+ let listed;
17223
+ if (pathsPresent) {
17224
+ if (!Array.isArray(value.paths) || value.paths.length === 0) return void 0;
17225
+ if (value.paths.some((path) => !isIsolatedVoicePath(path))) return void 0;
17226
+ if (new Set(value.paths).size !== value.paths.length) return void 0;
17227
+ listed = ISOLATED_VOICE_PATHS.filter((path) => value.paths.includes(path));
17228
+ if (listed.length !== value.paths.length) return void 0;
17229
+ } else if (pathPresent) {
17230
+ if (!isIsolatedVoicePath(value.path)) return void 0;
17231
+ listed = [value.path];
17232
+ } else {
17233
+ return void 0;
17234
+ }
17235
+ if (pathPresent) {
17236
+ if (!isIsolatedVoicePath(value.path) || !listed.includes(value.path)) return void 0;
17237
+ }
17238
+ return listed;
17239
+ }
17240
+ function isolatedQualificationPaths(isolated) {
17241
+ return isolatedQualificationPathSet(isolated) ?? [];
17242
+ }
17243
+ function isIsolatedVoiceQualification(value, now = Date.now()) {
17244
+ if (!isRecord(value)) return false;
17245
+ const paths = isolatedQualificationPathSet(value);
17246
+ if (!paths || paths.length === 0) return false;
17247
+ if (typeof value.appPath === "string" && isProductionDesktopAppPath(value.appPath)) return false;
17248
+ const expiresAtMs = isolatedQualificationExpiresAtMs(value.expiresAt);
17249
+ if (expiresAtMs === void 0 || expiresAtMs <= now) return false;
17250
+ 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";
16921
17251
  }
16922
17252
  function auditedAppInitialAssetPresent(resourceNames, asset) {
16923
17253
  return resourceNames.some((name) => {
@@ -16954,132 +17284,215 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16954
17284
  }
16955
17285
  return names;
16956
17286
  }
16957
- function statsigClients(globalObject) {
16958
- const registry2 = globalObject.__STATSIG__;
16959
- if (!isRecord(registry2)) return [];
16960
- const clients = new Set(
16961
- isRecord(registry2.instances) ? Object.values(registry2.instances) : []
16962
- );
16963
- if (registry2.firstInstance) clients.add(registry2.firstInstance);
16964
- return [...clients].filter(
16965
- (client) => isRecord(client) && typeof client.checkGate === "function"
16966
- );
16967
- }
16968
- function wrapCheckGate(client) {
16969
- if (originalCheckGate.has(client)) return false;
16970
- const original = client.checkGate;
16971
- originalCheckGate.set(client, original);
16972
- client.checkGate = function(name, ...rest) {
16973
- return name === THREAD_REALTIME_EXISTING_CALL_GATE ? false : original.call(this, name, ...rest);
16974
- };
16975
- return true;
16976
- }
16977
- function restoreCheckGate(client) {
16978
- const original = originalCheckGate.get(client);
16979
- if (!original) return;
16980
- client.checkGate = original;
16981
- originalCheckGate.delete(client);
16982
- }
16983
- function configAllowsInstall(config2, resourceNames) {
16984
- if (config2.desktopVersion !== void 0 && config2.desktopVersion !== config2.auditedDesktopVersion) {
16985
- return false;
16986
- }
16987
- if (config2.auditedDesktopVersion !== AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION) return false;
16988
- if (config2.auditedAppInitialAsset !== AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET) return false;
16989
- return auditedAppInitialAssetPresent(resourceNames, config2.auditedAppInitialAsset);
16990
- }
16991
- function installCpaLiveVoiceHook(options = {}) {
16992
- const globalObject = options.globalThis ?? globalThis;
16993
- const config2 = options.config === void 0 ? readCpaLiveVoiceHookConfig(globalObject) : options.config;
16994
- if (!config2?.enabled || !cpaLiveVoicePreferenceAllowsInstall(globalObject)) {
16995
- return { status: "disabled", dispose() {
16996
- } };
16997
- }
16998
- const root = options.document ?? globalObject.document;
16999
- const wrapped = [];
17000
- let disposed = false;
17001
- let auditedAssetFound = false;
17002
- const handle = {
17003
- status: "pending",
17004
- dispose() {
17005
- disposed = true;
17006
- for (const client of wrapped) restoreCheckGate(client);
17007
- wrapped.length = 0;
17008
- }
17009
- };
17010
- const attempt = () => {
17011
- if (!auditedAssetFound) {
17012
- const resourceNames = options.resourceNames ?? loadedAssetNames(root);
17013
- auditedAssetFound = configAllowsInstall(config2, resourceNames);
17014
- if (!auditedAssetFound) return false;
17015
- }
17016
- for (const client of statsigClients(globalObject)) {
17017
- if (wrapCheckGate(client)) wrapped.push(client);
17018
- }
17019
- if (wrapped.length === 0) return false;
17020
- handle.status = "active";
17021
- return true;
17022
- };
17023
- if (attempt()) return handle;
17024
- if (options.resourceNames && !configAllowsInstall(config2, options.resourceNames)) {
17025
- handle.status = "unsupported";
17026
- return handle;
17027
- }
17028
- const started = Date.now();
17029
- const tick = () => {
17030
- if (disposed || attempt()) return;
17031
- if (Date.now() - started > DISCOVERY_TIMEOUT_MS) {
17032
- handle.status = "unsupported";
17033
- return;
17034
- }
17035
- globalThis.setTimeout(tick, 250);
17036
- };
17037
- globalThis.setTimeout(tick, 250);
17038
- return handle;
17039
- }
17040
17287
 
17041
- // src/renderer-voice-assets.ts
17042
- function supportsVoiceVersion(profiles, version2) {
17043
- return version2 === void 0 || profiles.some((profile) => profile.version === version2);
17044
- }
17045
- function selectVoiceAssets(profiles, names, version2, platform) {
17046
- const present = profiles.filter(
17047
- (profile) => [profile.initial, profile.shared].some((asset) => auditedAppInitialAssetPresent(names, asset))
17048
- );
17049
- const matchesMetadata = (profile) => (version2 === void 0 || profile.version === version2) && (platform === void 0 || profile.platform === platform);
17050
- if (present.length > 0) {
17051
- const profile = present.length === 1 ? present[0] : void 0;
17052
- if (!profile || !matchesMetadata(profile)) return void 0;
17053
- const initialPresent = auditedAppInitialAssetPresent(names, profile.initial);
17054
- const sharedPresent = auditedAppInitialAssetPresent(names, profile.shared);
17055
- return sharedPresent && (initialPresent || version2 !== void 0 && platform !== void 0) ? profile : void 0;
17056
- }
17057
- if (version2 === void 0) return void 0;
17058
- const candidates = profiles.filter(matchesMetadata);
17059
- return candidates.length === 1 ? candidates[0] : void 0;
17060
- }
17288
+ // src/renderer-voice-implementation-revision.generated.ts
17289
+ var VOICE_IMPLEMENTATION_REVISION = "0a2ee1b441686523";
17061
17290
 
17062
- // src/renderer-chat-voice-debug.ts
17063
- var CHAT_VOICE_DEBUG_GLOBAL = "__codexhostChatVoiceDebug";
17064
- var CHAT_VOICE_DEBUG_STORAGE_KEY = "codexhost.chat-voice-debug.v1";
17065
- function chatVoiceDebug(event, detail = {}) {
17066
- const entry = { t: Date.now(), event, ...detail };
17067
- const owner = globalThis;
17068
- const log = Array.isArray(owner[CHAT_VOICE_DEBUG_GLOBAL]) ? owner[CHAT_VOICE_DEBUG_GLOBAL] : [];
17069
- log.push(entry);
17070
- while (log.length > 40) log.shift();
17071
- owner[CHAT_VOICE_DEBUG_GLOBAL] = log;
17072
- try {
17073
- owner.localStorage?.setItem(CHAT_VOICE_DEBUG_STORAGE_KEY, JSON.stringify(log));
17074
- } catch {
17291
+ // src/renderer-voice-profiles.ts
17292
+ var NATIVE_CHAT_VOICE_VERSION = "26.1027.61615";
17293
+ var NATIVE_CHAT_INITIAL_ASSET = "app-initial-18b189e867e7.js";
17294
+ var START_ASSET = "start-voice-221a396d38a5.js";
17295
+ var BASELINE_NAMED_CHAT_ROLES = {
17296
+ initializeFrom: "initial",
17297
+ initialize: "oT",
17298
+ startShape: "module",
17299
+ voiceSessionSelector: "SPn",
17300
+ reactFactory: "FBt",
17301
+ reactDomFactory: "PNt",
17302
+ prewarmController: "VoiceInstantConnectCacheController",
17303
+ initial: {
17304
+ MOr: "MOr",
17305
+ CDr: "CDr",
17306
+ B1n: "B1n",
17307
+ SPn: "SPn",
17308
+ oTFrom: "initial",
17309
+ oT: "oT",
17310
+ aTFrom: "initial",
17311
+ aT: "aT",
17312
+ Ycr: "Ycr",
17313
+ Nir: "Nir",
17314
+ n0n: "n0n",
17315
+ Y1n: "Y1n",
17316
+ HJt: "HJt"
17317
+ },
17318
+ shared: { Qst: "Qst", FBt: "FBt", PNt: "PNt", Vot: "Vot" }
17319
+ };
17320
+ var NAMED_CHAT_ROLES_26_1027_61615 = {
17321
+ initializeFrom: "primary",
17322
+ initialize: "Qp",
17323
+ startShape: "module",
17324
+ voiceSessionSelector: "etn",
17325
+ reactFactory: "pWt",
17326
+ reactDomFactory: "GFt",
17327
+ prewarmController: "VoiceInstantConnectCacheController",
17328
+ initial: {
17329
+ MOr: "p5n",
17330
+ CDr: "w6n",
17331
+ B1n: "_On",
17332
+ SPn: "etn",
17333
+ oTFrom: "primary",
17334
+ oT: "Qp",
17335
+ aTFrom: "primary",
17336
+ aT: "Zp",
17337
+ Ycr: "ofr",
17338
+ Nir: "yEn",
17339
+ n0n: "FOn",
17340
+ Y1n: "JOn",
17341
+ HJt: "Z6"
17342
+ },
17343
+ shared: { Qst: "klt", FBt: "pWt", PNt: "GFt", Vot: "_ct" }
17344
+ };
17345
+ var NAMED_CHAT_ROLES_26_1027_30824 = {
17346
+ initializeFrom: "primary",
17347
+ initialize: "Yp",
17348
+ startShape: "module",
17349
+ voiceSessionSelector: "Xen",
17350
+ reactFactory: "pWt",
17351
+ reactDomFactory: "GFt",
17352
+ prewarmController: "VoiceInstantConnectCacheController",
17353
+ initial: {
17354
+ MOr: "l5n",
17355
+ CDr: "b6n",
17356
+ B1n: "pOn",
17357
+ SPn: "Xen",
17358
+ oTFrom: "primary",
17359
+ oT: "Yp",
17360
+ aTFrom: "primary",
17361
+ aT: "Jp",
17362
+ Ycr: "nfr",
17363
+ Nir: "hEn",
17364
+ n0n: "jOn",
17365
+ Y1n: "wOn",
17366
+ HJt: "J6"
17367
+ },
17368
+ shared: { Qst: "klt", FBt: "pWt", PNt: "GFt", Vot: "_ct" }
17369
+ };
17370
+ var NAMED_CHAT_ROLES_26_1023_51421 = {
17371
+ initializeFrom: "primary",
17372
+ initialize: "gm",
17373
+ startShape: "module",
17374
+ voiceSessionSelector: "s$t",
17375
+ reactFactory: "OHt",
17376
+ reactDomFactory: "wPt",
17377
+ prewarmController: "VoiceInstantConnectCacheController",
17378
+ initial: {
17379
+ MOr: "x1n",
17380
+ CDr: "MQn",
17381
+ B1n: "Opn",
17382
+ SPn: "s$t",
17383
+ oTFrom: "primary",
17384
+ oT: "gm",
17385
+ aTFrom: "primary",
17386
+ aT: "hm",
17387
+ Ycr: "Zir",
17388
+ Nir: "ejn",
17389
+ n0n: "Kpn",
17390
+ Y1n: "zpn",
17391
+ HJt: "k3"
17392
+ },
17393
+ shared: { Qst: "uct", FBt: "OHt", PNt: "wPt", Vot: "ast" }
17394
+ };
17395
+ var NAMED_CHAT_ROLES_26_1021_31345 = {
17396
+ initializeFrom: "primary",
17397
+ initialize: "um",
17398
+ startShape: "entityBusiness",
17399
+ startT: "r",
17400
+ startN: "i",
17401
+ voiceSessionSelector: "qXt",
17402
+ reactFactory: "XVt",
17403
+ reactDomFactory: "KNt",
17404
+ prewarmController: "VoiceInstantConnectCacheController",
17405
+ initial: {
17406
+ MOr: "CQn",
17407
+ CDr: "PXn",
17408
+ B1n: "tdn",
17409
+ SPn: "qXt",
17410
+ oTFrom: "primary",
17411
+ oT: "um",
17412
+ aTFrom: "primary",
17413
+ aT: "lm",
17414
+ Ycr: "Xkn",
17415
+ Nir: "yAn",
17416
+ n0n: "ydn",
17417
+ Y1n: "fdn",
17418
+ HJt: "R2"
17419
+ },
17420
+ shared: { Qst: "Bst", FBt: "XVt", PNt: "KNt", Vot: "Fot" }
17421
+ };
17422
+ var NATIVE_CHAT_VOICE_ASSETS = [
17423
+ {
17424
+ platform: "darwin",
17425
+ version: NATIVE_CHAT_VOICE_VERSION,
17426
+ initial: NATIVE_CHAT_INITIAL_ASSET,
17427
+ shared: "app-shared-601019a330d7.js",
17428
+ primary: "app-primary-75d53eef2374.js",
17429
+ start: START_ASSET,
17430
+ prewarm: "voice-prewarm-a7cd5160219e.js",
17431
+ settings: "voice-settings-320cf1212f2c.js",
17432
+ roles: NAMED_CHAT_ROLES_26_1027_61615
17433
+ },
17434
+ {
17435
+ platform: "darwin",
17436
+ version: "26.1027.30824",
17437
+ initial: "app-initial-60f141238751.js",
17438
+ shared: "app-shared-7815d5a1a42a.js",
17439
+ primary: "app-primary-95a0e6d83f1e.js",
17440
+ start: "start-voice-4c77215aa289.js",
17441
+ prewarm: "voice-prewarm-e49220ad61bd.js",
17442
+ roles: NAMED_CHAT_ROLES_26_1027_30824
17443
+ },
17444
+ {
17445
+ platform: "darwin",
17446
+ version: "26.1023.51421",
17447
+ initial: "app-initial-bc8256c3cccb.js",
17448
+ shared: "app-shared-e9f258fd3588.js",
17449
+ primary: "app-primary-b7f335b763ca.js",
17450
+ start: "start-voice-a0564cefdc95.js",
17451
+ prewarm: "voice-prewarm-53aefded152c.js",
17452
+ settings: "voice-settings-1a9f68eb7ae8.js",
17453
+ roles: NAMED_CHAT_ROLES_26_1023_51421
17454
+ },
17455
+ {
17456
+ platform: "darwin",
17457
+ version: "26.1021.31345",
17458
+ initial: "app-initial-feb30b196d11.js",
17459
+ shared: "app-shared-2cae01273bae.js",
17460
+ primary: "app-primary-7d7313419f84.js",
17461
+ start: "entity-business-profile-reference-b68063dfc05d.js",
17462
+ prewarm: "voice-prewarm-d672f1245523.js",
17463
+ settings: "voice-settings-14000f5c9fc2.js",
17464
+ roles: NAMED_CHAT_ROLES_26_1021_31345
17465
+ },
17466
+ {
17467
+ platform: "win32",
17468
+ version: "26.1021.31345",
17469
+ initial: "app-initial-438d1df57f70.js",
17470
+ shared: "app-shared-955d52676f9c.js",
17471
+ primary: "app-primary-844e405f2b90.js",
17472
+ start: "entity-business-profile-reference-241c52d811f4.js",
17473
+ prewarm: "voice-prewarm-8b47c50a17ae.js",
17474
+ settings: "voice-settings-b1c1633136a5.js",
17475
+ roles: NAMED_CHAT_ROLES_26_1021_31345
17476
+ },
17477
+ {
17478
+ platform: "darwin",
17479
+ version: "26.1016.62342",
17480
+ initial: "app-initial-dddef47d6ef6.js",
17481
+ shared: "app-shared-fc3316d48427.js",
17482
+ start: "start-voice-7cbf0a39d53b.js",
17483
+ prewarm: "voice-prewarm-5d107129ac1c.js",
17484
+ roles: BASELINE_NAMED_CHAT_ROLES
17485
+ },
17486
+ {
17487
+ platform: "darwin",
17488
+ version: "26.1016.61520",
17489
+ initial: "app-initial-c95ddb62696e.js",
17490
+ shared: "app-shared-2eda13eb7044.js",
17491
+ start: "start-voice-18b08f0acdd7.js",
17492
+ prewarm: "voice-prewarm-94271e581c1b.js",
17493
+ roles: BASELINE_NAMED_CHAT_ROLES
17075
17494
  }
17076
- owner.console?.info?.("[codexhost-chat-voice]", event, detail);
17077
- }
17078
-
17079
- // src/renderer-new-thread-preference.ts
17080
- var RENDERER_NEW_THREAD_PREFERENCE_KEY = "codexhost.new-thread-preference.v1";
17081
-
17082
- // src/renderer-client-owned-voice.ts
17495
+ ];
17083
17496
  var CLIENT_OWNED_VOICE_VERSION = "26.1027.61615";
17084
17497
  var CLIENT_OWNED_VOICE_INITIAL_ASSET = "app-initial-18b189e867e7.js";
17085
17498
  var CLIENT_OWNED_VOICE_SHARED_ASSET = "app-shared-601019a330d7.js";
@@ -17193,60 +17606,864 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17193
17606
  inferenceGateFamily: "uBr"
17194
17607
  }
17195
17608
  ];
17196
- var SHARED_INIT = "Oit";
17197
- var SHARED_RESPONSE_ERROR = "Mit";
17198
- var HOOK_GLOBAL = "__codexhostClientOwnedVoiceV1";
17199
- function object2(value) {
17609
+ var HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
17610
+ var HISTORICAL_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
17611
+ var HASHED_WEBPACK_VOICE_VERSION = "26.1106.51428";
17612
+ var HASHED_WEBPACK_VOICE_RUNTIME_ASSET = "348410.1a97dde15f.js";
17613
+ var HASHED_NATIVE_CHAT_START_ASSET = "530142.1e51e7f4b2.js";
17614
+ var HASHED_NATIVE_CHAT_PREWARM_ASSET = "586788.c871bb9b7d.js";
17615
+ var NATIVE_CHAT_VOICE_CHUNKS = [
17616
+ 157963,
17617
+ 74692,
17618
+ 198336,
17619
+ 543449,
17620
+ 904485,
17621
+ 459859,
17622
+ 822019,
17623
+ 431137,
17624
+ 108823,
17625
+ 208490,
17626
+ 384218,
17627
+ 843292,
17628
+ 652289,
17629
+ 907652,
17630
+ 796195,
17631
+ 144338,
17632
+ 140959,
17633
+ 587936,
17634
+ 904817,
17635
+ 426774,
17636
+ 452048,
17637
+ 490954,
17638
+ 445991,
17639
+ 612928,
17640
+ 42903,
17641
+ 363341,
17642
+ 997826,
17643
+ 223736,
17644
+ 21878,
17645
+ 89655,
17646
+ 333490,
17647
+ 422391,
17648
+ 792483,
17649
+ 530142
17650
+ ];
17651
+ var HASHED_NATIVE_CHAT_ROLES = {
17652
+ startModuleId: "j9r7",
17653
+ prewarmModuleId: "oWM3",
17654
+ appScopeModuleId: "OWtl",
17655
+ appScopeExport: "u",
17656
+ routeScopeModuleId: "Oj9r",
17657
+ routeScopeExport: "GD",
17658
+ composerScopeModuleId: "Sd8U",
17659
+ composerScopeExport: "PR",
17660
+ storeModuleId: "bgok",
17661
+ storeExport: "MH",
17662
+ runtimeModuleId: "cY1t",
17663
+ runtimeEnableExport: "Iy",
17664
+ runtimeLoaderExport: "Re",
17665
+ reactModuleId: "zd8w",
17666
+ reactDomModuleId: "CE87",
17667
+ startInitializeExport: "initializeVoiceSession",
17668
+ prewarmControllerExport: "VoiceInstantConnectCacheController",
17669
+ /** Conversation store: adopted backend ID, transcript mapping, current node. */
17670
+ conversationModuleId: "MrGp",
17671
+ backendConversationExport: "jS",
17672
+ transcriptMappingExport: "Jv",
17673
+ currentNodeExport: "Od",
17674
+ /** App location atom used as the draft-selection origin. */
17675
+ locationModuleId: "nlNF",
17676
+ locationExport: "x2",
17677
+ /** AppNavigation.navigate(scope, location). */
17678
+ navigationModuleId: "E8Sp",
17679
+ navigationExport: "oo",
17680
+ /** `/c/:conversationId` builder; not a GPT `/g/` path. */
17681
+ conversationPathModuleId: "jAnS",
17682
+ conversationPathExport: "mv"
17683
+ };
17684
+ var HASHED_OVERLAY_VOICE_ROLES = {
17685
+ fetchFactoryId: "GDNt",
17686
+ fetchExport: "_n",
17687
+ bridgeModuleId: "TL6G",
17688
+ bridgeExport: "O1",
17689
+ responseErrorModuleId: "eShZ",
17690
+ responseErrorExport: "s1",
17691
+ capabilityModuleId: "ChYf",
17692
+ capabilityExport: "G",
17693
+ inferenceGateModuleId: "OMIV",
17694
+ inferenceGateExport: "JW",
17695
+ /** Workspace voice access derived atom `P` via `zTeN.un`; Instant Connect ANDs `Y3.status`. */
17696
+ voiceAccessModuleId: "eFn4",
17697
+ voiceAccessExport: "Y3"
17698
+ };
17699
+ function hashedVoiceCandidateOwner(config2) {
17700
+ return config2.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && (config2.desktopPlatform === "darwin" || config2.desktopPlatform === "win32");
17701
+ }
17702
+ function hashedVoiceProfileSupported(config2) {
17703
+ return config2.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config2.desktopPlatform === "darwin";
17704
+ }
17705
+ function reviewedOverlayHookDesktopVersions() {
17706
+ const versions = /* @__PURE__ */ new Set([
17707
+ HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION,
17708
+ HASHED_WEBPACK_VOICE_VERSION
17709
+ ]);
17710
+ for (const profile of NATIVE_CHAT_VOICE_ASSETS) versions.add(profile.version);
17711
+ for (const profile of CLIENT_OWNED_VOICE_ASSETS) versions.add(profile.version);
17712
+ return [...versions].sort();
17713
+ }
17714
+ var VOICE_PROFILE_PINS = {
17715
+ workVersion: CLIENT_OWNED_VOICE_VERSION,
17716
+ workInitial: CLIENT_OWNED_VOICE_INITIAL_ASSET,
17717
+ workShared: CLIENT_OWNED_VOICE_SHARED_ASSET,
17718
+ overlayAsset: CLIENT_OWNED_VOICE_OVERLAY_ASSET,
17719
+ chatVersion: NATIVE_CHAT_VOICE_VERSION,
17720
+ chatInitial: NATIVE_CHAT_INITIAL_ASSET,
17721
+ chatStart: START_ASSET,
17722
+ hashedVersion: HASHED_WEBPACK_VOICE_VERSION,
17723
+ hashedRuntimeAsset: HASHED_WEBPACK_VOICE_RUNTIME_ASSET,
17724
+ hashedStartAsset: HASHED_NATIVE_CHAT_START_ASSET,
17725
+ hashedPrewarmAsset: HASHED_NATIVE_CHAT_PREWARM_ASSET,
17726
+ historicalCpaVersion: HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION,
17727
+ historicalCpaInitial: HISTORICAL_CPA_LIVE_VOICE_APP_INITIAL_ASSET
17728
+ };
17729
+ var voiceProfilePins = {
17730
+ ...VOICE_PROFILE_PINS,
17731
+ overlayHookDesktopVersions: reviewedOverlayHookDesktopVersions()
17732
+ };
17733
+ function nativeChatVoiceKind(config2) {
17734
+ if (!config2.desktopVersion) return void 0;
17735
+ if (hashedVoiceProfileSupported(config2)) return "hashed";
17736
+ if (NATIVE_CHAT_VOICE_ASSETS.some(
17737
+ (profile) => profile.version === config2.desktopVersion && (config2.desktopPlatform === void 0 || profile.platform === config2.desktopPlatform)
17738
+ )) {
17739
+ return "named";
17740
+ }
17741
+ return void 0;
17742
+ }
17743
+ function nativeChatVoiceUnavailableReason(config2) {
17744
+ if (nativeChatVoiceKind(config2)) return void 0;
17745
+ if (!config2.desktopVersion) return "Chat voice is waiting for Desktop identity.";
17746
+ if (config2.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config2.desktopPlatform === "win32") {
17747
+ return "Chat voice is not qualified on this Windows Desktop.";
17748
+ }
17749
+ return "Chat voice is not qualified on this Desktop.";
17750
+ }
17751
+ function workVoiceUnavailableReason(config2) {
17752
+ if (hashedVoiceProfileSupported(config2)) return void 0;
17753
+ if (config2.desktopVersion !== void 0 && CLIENT_OWNED_VOICE_ASSETS.some(
17754
+ (profile) => profile.version === config2.desktopVersion && (config2.desktopPlatform === void 0 || profile.platform === config2.desktopPlatform)
17755
+ )) {
17756
+ return void 0;
17757
+ }
17758
+ if (!config2.desktopVersion) return "Work voice is waiting for Desktop identity.";
17759
+ if (config2.desktopVersion === HASHED_WEBPACK_VOICE_VERSION && config2.desktopPlatform === "win32") {
17760
+ return "Work voice is not qualified on this Windows Desktop.";
17761
+ }
17762
+ return "Work voice is not qualified on this Desktop.";
17763
+ }
17764
+ function profileIdentityKey(product, platform, version2) {
17765
+ return `${product}:${platform ?? "unknown"}:${version2 ?? "unknown"}`;
17766
+ }
17767
+ function fnv1aHex(value) {
17768
+ let hash2 = 0xcbf29ce484222325n;
17769
+ for (let index = 0; index < value.length; index += 1) {
17770
+ hash2 ^= BigInt(value.charCodeAt(index));
17771
+ hash2 = hash2 * 0x100000001b3n & 0xffffffffffffffffn;
17772
+ }
17773
+ return hash2.toString(16).padStart(16, "0");
17774
+ }
17775
+ function digestJson(value) {
17776
+ return fnv1aHex(JSON.stringify(value));
17777
+ }
17778
+ function legacyRetainedVoiceLanes() {
17779
+ return [
17780
+ ...NATIVE_CHAT_VOICE_ASSETS.map((profile) => ({
17781
+ path: "chat",
17782
+ platform: profile.platform,
17783
+ version: profile.version
17784
+ })),
17785
+ ...CLIENT_OWNED_VOICE_ASSETS.map((profile) => ({
17786
+ path: "work-codex",
17787
+ platform: profile.platform,
17788
+ version: profile.version
17789
+ }))
17790
+ ];
17791
+ }
17792
+ function voiceProfileOwner(product, platform, version2) {
17793
+ if (product === "chat") {
17794
+ if (hashedVoiceCandidateOwner({ desktopVersion: version2, desktopPlatform: platform })) {
17795
+ return {
17796
+ kind: "hashed-chat",
17797
+ platform,
17798
+ version: version2,
17799
+ roles: HASHED_NATIVE_CHAT_ROLES,
17800
+ chunks: [...NATIVE_CHAT_VOICE_CHUNKS],
17801
+ webpack: HASHED_WEBPACK_VOICE_RUNTIME_ASSET,
17802
+ start: HASHED_NATIVE_CHAT_START_ASSET,
17803
+ prewarm: HASHED_NATIVE_CHAT_PREWARM_ASSET
17804
+ };
17805
+ }
17806
+ const named = NATIVE_CHAT_VOICE_ASSETS.find(
17807
+ (profile) => profile.platform === platform && profile.version === version2
17808
+ );
17809
+ if (!named) return void 0;
17810
+ return {
17811
+ kind: "named-chat",
17812
+ platform: named.platform,
17813
+ version: named.version,
17814
+ initial: named.initial,
17815
+ shared: named.shared,
17816
+ primary: named.primary ?? null,
17817
+ start: named.start,
17818
+ prewarm: named.prewarm,
17819
+ settings: named.settings ?? null,
17820
+ roles: named.roles
17821
+ };
17822
+ }
17823
+ const namedWork = CLIENT_OWNED_VOICE_ASSETS.find(
17824
+ (profile) => profile.platform === platform && profile.version === version2
17825
+ );
17826
+ if (namedWork) {
17827
+ return {
17828
+ kind: "named-work",
17829
+ platform: namedWork.platform,
17830
+ version: namedWork.version,
17831
+ initial: namedWork.initial,
17832
+ shared: namedWork.shared,
17833
+ overlay: namedWork.overlay,
17834
+ init: namedWork.init ?? null,
17835
+ fetch: namedWork.fetch,
17836
+ fetchFrom: namedWork.fetchFrom ?? null,
17837
+ bridge: namedWork.bridge,
17838
+ services: namedWork.services,
17839
+ responseError: namedWork.responseError ?? null,
17840
+ responseErrorFrom: namedWork.responseErrorFrom ?? null,
17841
+ capabilityInit: namedWork.capabilityInit,
17842
+ capabilityFamily: namedWork.capabilityFamily,
17843
+ inferenceGateFamily: namedWork.inferenceGateFamily
17844
+ };
17845
+ }
17846
+ if (hashedVoiceCandidateOwner({ desktopVersion: version2, desktopPlatform: platform })) {
17847
+ return {
17848
+ kind: "hashed-work",
17849
+ platform,
17850
+ version: version2,
17851
+ overlay: HASHED_OVERLAY_VOICE_ROLES,
17852
+ webpack: HASHED_WEBPACK_VOICE_RUNTIME_ASSET
17853
+ };
17854
+ }
17855
+ return void 0;
17856
+ }
17857
+ function voiceProfileDigest(product, platform, version2) {
17858
+ const owner = voiceProfileOwner(product, platform, version2);
17859
+ return owner ? digestJson(owner) : void 0;
17860
+ }
17861
+ function voiceImplementationRevision() {
17862
+ return VOICE_IMPLEMENTATION_REVISION;
17863
+ }
17864
+
17865
+ // src/renderer-cpa-live-voice-hook.ts
17866
+ var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = HISTORICAL_CPA_LIVE_VOICE_DESKTOP_VERSION;
17867
+ var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = HISTORICAL_CPA_LIVE_VOICE_APP_INITIAL_ASSET;
17868
+ var THREAD_REALTIME_EXISTING_CALL_GATE = "206132468";
17869
+ var originalCheckGate = /* @__PURE__ */ new WeakMap();
17870
+ var DISCOVERY_TIMEOUT_MS = 6e4;
17871
+ function isRecord2(value) {
17872
+ return typeof value === "object" && value !== null;
17873
+ }
17874
+ function statsigClients(globalObject) {
17875
+ const registry2 = globalObject.__STATSIG__;
17876
+ if (!isRecord2(registry2)) return [];
17877
+ const clients = new Set(
17878
+ isRecord2(registry2.instances) ? Object.values(registry2.instances) : []
17879
+ );
17880
+ if (registry2.firstInstance) clients.add(registry2.firstInstance);
17881
+ return [...clients].filter(
17882
+ (client) => isRecord2(client) && typeof client.checkGate === "function"
17883
+ );
17884
+ }
17885
+ function wrapCheckGate(client) {
17886
+ if (originalCheckGate.has(client)) return false;
17887
+ const original = client.checkGate;
17888
+ originalCheckGate.set(client, original);
17889
+ client.checkGate = function(name, ...rest) {
17890
+ return name === THREAD_REALTIME_EXISTING_CALL_GATE ? false : original.call(this, name, ...rest);
17891
+ };
17892
+ return true;
17893
+ }
17894
+ function restoreCheckGate(client) {
17895
+ const original = originalCheckGate.get(client);
17896
+ if (!original) return;
17897
+ client.checkGate = original;
17898
+ originalCheckGate.delete(client);
17899
+ }
17900
+ function configAllowsInstall(config2, resourceNames) {
17901
+ if (config2.desktopVersion !== void 0 && config2.desktopVersion !== config2.auditedDesktopVersion) {
17902
+ return false;
17903
+ }
17904
+ if (config2.auditedDesktopVersion !== AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION) return false;
17905
+ if (config2.auditedAppInitialAsset !== AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET) return false;
17906
+ return auditedAppInitialAssetPresent(resourceNames, config2.auditedAppInitialAsset);
17907
+ }
17908
+ function installCpaLiveVoiceHook(options = {}) {
17909
+ const globalObject = options.globalThis ?? globalThis;
17910
+ const config2 = options.config === void 0 ? readCpaLiveVoiceHookConfig(globalObject) : options.config;
17911
+ if (!config2?.enabled || !cpaLiveVoicePreferenceAllowsInstall(globalObject)) {
17912
+ return { status: "disabled", dispose() {
17913
+ } };
17914
+ }
17915
+ const root = options.document ?? globalObject.document;
17916
+ const wrapped = [];
17917
+ let disposed = false;
17918
+ let auditedAssetFound = false;
17919
+ const handle = {
17920
+ status: "pending",
17921
+ dispose() {
17922
+ disposed = true;
17923
+ for (const client of wrapped) restoreCheckGate(client);
17924
+ wrapped.length = 0;
17925
+ }
17926
+ };
17927
+ const attempt = () => {
17928
+ if (!auditedAssetFound) {
17929
+ const resourceNames = options.resourceNames ?? loadedAssetNames(root);
17930
+ auditedAssetFound = configAllowsInstall(config2, resourceNames);
17931
+ if (!auditedAssetFound) return false;
17932
+ }
17933
+ for (const client of statsigClients(globalObject)) {
17934
+ if (wrapCheckGate(client)) wrapped.push(client);
17935
+ }
17936
+ if (wrapped.length === 0) return false;
17937
+ handle.status = "active";
17938
+ return true;
17939
+ };
17940
+ if (attempt()) return handle;
17941
+ if (options.resourceNames && !configAllowsInstall(config2, options.resourceNames)) {
17942
+ handle.status = "unsupported";
17943
+ return handle;
17944
+ }
17945
+ const started = Date.now();
17946
+ const tick = () => {
17947
+ if (disposed || attempt()) return;
17948
+ if (Date.now() - started > DISCOVERY_TIMEOUT_MS) {
17949
+ handle.status = "unsupported";
17950
+ return;
17951
+ }
17952
+ globalThis.setTimeout(tick, 250);
17953
+ };
17954
+ globalThis.setTimeout(tick, 250);
17955
+ return handle;
17956
+ }
17957
+
17958
+ // src/renderer-voice-assets.ts
17959
+ function supportsVoiceVersion(profiles, version2) {
17960
+ return version2 === void 0 || profiles.some((profile) => profile.version === version2);
17961
+ }
17962
+ function selectVoiceAssets(profiles, names, version2, platform) {
17963
+ const present = profiles.filter(
17964
+ (profile) => [profile.initial, profile.shared].some((asset) => auditedAppInitialAssetPresent(names, asset))
17965
+ );
17966
+ const matchesMetadata = (profile) => (version2 === void 0 || profile.version === version2) && (platform === void 0 || profile.platform === platform);
17967
+ if (present.length > 0) {
17968
+ const profile = present.length === 1 ? present[0] : void 0;
17969
+ if (!profile || !matchesMetadata(profile)) return void 0;
17970
+ const initialPresent = auditedAppInitialAssetPresent(names, profile.initial);
17971
+ const sharedPresent = auditedAppInitialAssetPresent(names, profile.shared);
17972
+ return sharedPresent && (initialPresent || version2 !== void 0 && platform !== void 0) ? profile : void 0;
17973
+ }
17974
+ if (version2 === void 0) return void 0;
17975
+ const candidates = profiles.filter(matchesMetadata);
17976
+ return candidates.length === 1 ? candidates[0] : void 0;
17977
+ }
17978
+
17979
+ // src/renderer-voice-evidence.ts
17980
+ var VOICE_EVIDENCE_STAGES = [
17981
+ "structural",
17982
+ "activation",
17983
+ "connection",
17984
+ "identity",
17985
+ "speech",
17986
+ "cleanup"
17987
+ ];
17988
+ var REQUIRED_STAGES = VOICE_EVIDENCE_STAGES;
17989
+ function recordObject(value) {
17200
17990
  return value !== null && typeof value === "object";
17201
17991
  }
17202
- function requestVoiceHost(bridge, params, method = REALTIME_CALL_METHOD) {
17203
- const id = `codexhost-voice:${crypto.randomUUID()}`;
17204
- return new Promise((resolve, reject) => {
17205
- let unsubscribe = () => {
17992
+ function missingStages(record5) {
17993
+ return REQUIRED_STAGES.filter((stage) => record5.stages[stage] !== true);
17994
+ }
17995
+ function productForPath(path) {
17996
+ return path === "chat" ? "chat" : "work";
17997
+ }
17998
+ function evaluateVoiceEvidence(record5) {
17999
+ const expectedKey = profileIdentityKey(
18000
+ productForPath(record5.path),
18001
+ record5.platform,
18002
+ record5.desktopVersion
18003
+ );
18004
+ if (record5.profileKey !== expectedKey) {
18005
+ return {
18006
+ outcome: "mismatch",
18007
+ qualified: false,
18008
+ missing: missingStages(record5),
18009
+ reason: "evidence-profile-mismatch"
18010
+ };
18011
+ }
18012
+ if (typeof record5.implementationRevision !== "string" || record5.implementationRevision === "") {
18013
+ return {
18014
+ outcome: "mismatch",
18015
+ qualified: false,
18016
+ missing: missingStages(record5),
18017
+ reason: "missing-implementation-revision"
17206
18018
  };
17207
- const timer = setTimeout(() => {
17208
- unsubscribe();
17209
- reject(new Error("Voice gateway did not answer in time"));
17210
- }, 3e4);
17211
- const done = () => {
17212
- clearTimeout(timer);
17213
- unsubscribe();
18019
+ }
18020
+ if (record5.policy !== "legacy-retained" && record5.implementationRevision !== voiceImplementationRevision()) {
18021
+ return {
18022
+ outcome: "mismatch",
18023
+ qualified: false,
18024
+ missing: missingStages(record5),
18025
+ reason: "implementation-revision-mismatch"
18026
+ };
18027
+ }
18028
+ if (record5.policy !== "legacy-retained") {
18029
+ if (typeof record5.desktopBuild !== "string" || record5.desktopBuild === "" || typeof record5.asarDigest !== "string" || record5.asarDigest === "") {
18030
+ return {
18031
+ outcome: "mismatch",
18032
+ qualified: false,
18033
+ missing: missingStages(record5),
18034
+ reason: "missing-native-identity"
18035
+ };
18036
+ }
18037
+ }
18038
+ if (typeof record5.profileDigest !== "string" || record5.profileDigest === "") {
18039
+ return {
18040
+ outcome: "mismatch",
18041
+ qualified: false,
18042
+ missing: missingStages(record5),
18043
+ reason: "missing-profile-digest"
18044
+ };
18045
+ }
18046
+ const expectedDigest = voiceProfileDigest(
18047
+ productForPath(record5.path),
18048
+ record5.platform,
18049
+ record5.desktopVersion
18050
+ );
18051
+ if (!expectedDigest || record5.profileDigest !== expectedDigest) {
18052
+ return {
18053
+ outcome: "mismatch",
18054
+ qualified: false,
18055
+ missing: missingStages(record5),
18056
+ reason: "stale-profile-digest"
18057
+ };
18058
+ }
18059
+ if (record5.startAcknowledged === true && record5.connected !== true) {
18060
+ return {
18061
+ outcome: "incomplete",
18062
+ qualified: false,
18063
+ missing: missingStages(record5).length > 0 ? missingStages(record5) : ["connection"],
18064
+ reason: "start-acknowledged-without-connection"
18065
+ };
18066
+ }
18067
+ if (record5.path !== "chat" && record5.gatewayOwned !== true && record5.stages.connection === true) {
18068
+ return {
18069
+ outcome: "incomplete",
18070
+ qualified: false,
18071
+ missing: missingStages(record5).length > 0 ? missingStages(record5) : ["connection"],
18072
+ reason: "route-only-without-connected-gateway"
18073
+ };
18074
+ }
18075
+ if (record5.speech?.attended === true && (!record5.speech.witness || !record5.speech.run)) {
18076
+ return {
18077
+ outcome: "incomplete",
18078
+ qualified: false,
18079
+ missing: missingStages(record5).includes("speech") ? missingStages(record5) : ["speech"],
18080
+ reason: "attended-speech-missing-provenance"
18081
+ };
18082
+ }
18083
+ if (record5.speech && record5.speech.attended !== true) {
18084
+ return {
18085
+ outcome: "incomplete",
18086
+ qualified: false,
18087
+ missing: missingStages(record5),
18088
+ reason: "synthetic-speech-is-not-qualification"
18089
+ };
18090
+ }
18091
+ const missing = missingStages(record5);
18092
+ if (missing.length > 0) {
18093
+ return {
18094
+ outcome: "incomplete",
18095
+ qualified: false,
18096
+ missing,
18097
+ reason: `missing:${missing.join(",")}`
18098
+ };
18099
+ }
18100
+ if (record5.connected !== true || record5.conversationMatched !== true || (record5.path === "chat" ? record5.harnessMatched !== void 0 && record5.harnessMatched !== true : record5.harnessMatched !== true) || record5.speech?.attended !== true || record5.speech.bothDirections !== true || record5.cleanup?.ended !== true || record5.cleanup.microphoneReleased !== true) {
18101
+ return {
18102
+ outcome: "fail",
18103
+ qualified: false,
18104
+ missing: [],
18105
+ reason: "required-assertions-failed"
18106
+ };
18107
+ }
18108
+ return { outcome: "pass", qualified: true, missing: [], reason: "qualified" };
18109
+ }
18110
+ function evidenceMatchesRuntime(record5, config2) {
18111
+ if (record5.platform !== config2.desktopPlatform) return false;
18112
+ if (record5.desktopVersion !== config2.desktopVersion) return false;
18113
+ if (record5.implementationRevision !== config2.implementationRevision) return false;
18114
+ if (record5.policy === "legacy-retained") return true;
18115
+ if (typeof record5.desktopBuild !== "string" || record5.desktopBuild === "" || typeof record5.asarDigest !== "string" || record5.asarDigest === "" || typeof config2.desktopBuild !== "string" || config2.desktopBuild === "" || typeof config2.asarDigest !== "string" || config2.asarDigest === "" || typeof config2.implementationRevision !== "string" || config2.implementationRevision === "") {
18116
+ return false;
18117
+ }
18118
+ return record5.desktopBuild === config2.desktopBuild && record5.asarDigest === config2.asarDigest;
18119
+ }
18120
+ function isolatedVoicePathEnabled(config2, path) {
18121
+ return isolatedQualificationMatches(path, config2);
18122
+ }
18123
+ function isolatedQualificationMatches(path, config2) {
18124
+ const isolated = config2.isolatedQualification;
18125
+ if (!isIsolatedVoiceQualification(isolated)) return false;
18126
+ if (!isolatedQualificationPaths(isolated).includes(path)) return false;
18127
+ if (isProductionDesktopAppPath(isolated.appPath) || isProductionDesktopAppPath(config2.desktopAppPath))
18128
+ return false;
18129
+ if (isolated.desktopPlatform !== config2.desktopPlatform) return false;
18130
+ return isolated.desktopVersion === config2.desktopVersion && isolated.desktopBuild === config2.desktopBuild && isolated.asarDigest === config2.asarDigest && isolated.appPath === config2.desktopAppPath && isolated.implementationRevision === config2.implementationRevision && typeof config2.desktopBuild === "string" && config2.desktopBuild !== "" && typeof config2.asarDigest === "string" && config2.asarDigest !== "" && typeof config2.desktopAppPath === "string" && config2.desktopAppPath !== "" && typeof config2.implementationRevision === "string" && config2.implementationRevision !== "";
18131
+ }
18132
+ function unsupportedReason(path, config2) {
18133
+ if (path === "chat") {
18134
+ return nativeChatVoiceUnavailableReason(config2) ?? "Chat voice is not qualified on this Desktop.";
18135
+ }
18136
+ return workVoiceUnavailableReason(config2) ?? "Work voice is not qualified on this Desktop.";
18137
+ }
18138
+ function decidePath(path, config2, records) {
18139
+ if (!config2.desktopVersion || !config2.desktopPlatform) {
18140
+ return { enabled: false, policy: "unreviewed", reason: "waiting-for-identity" };
18141
+ }
18142
+ const pathRecords = records.filter((record5) => record5.path === path);
18143
+ if (pathRecords.length > 0) {
18144
+ const matching = pathRecords.filter((record6) => evidenceMatchesRuntime(record6, config2));
18145
+ if (matching.length === 0) {
18146
+ return { enabled: false, policy: "unreviewed", reason: "stale-or-wrong-platform-evidence" };
18147
+ }
18148
+ for (const record6 of matching) {
18149
+ const evaluation = evaluateVoiceEvidence(record6);
18150
+ if (!evaluation.qualified) {
18151
+ return { enabled: false, policy: "unreviewed", reason: evaluation.reason };
18152
+ }
18153
+ }
18154
+ const record5 = matching[0];
18155
+ if (!record5) {
18156
+ return { enabled: false, policy: "unreviewed", reason: "missing-evidence" };
18157
+ }
18158
+ if (hashedVoiceCandidateOwner(config2) && !hashedVoiceProfileSupported(config2)) {
18159
+ } else {
18160
+ return {
18161
+ enabled: true,
18162
+ policy: record5.policy === "legacy-retained" ? "legacy-retained" : "reviewed"
18163
+ };
18164
+ }
18165
+ }
18166
+ const digest = voiceProfileDigest(
18167
+ productForPath(path),
18168
+ config2.desktopPlatform,
18169
+ config2.desktopVersion
18170
+ );
18171
+ if (!digest) {
18172
+ return { enabled: false, policy: "unreviewed", reason: unsupportedReason(path, config2) };
18173
+ }
18174
+ const legacy = legacyRetainedVoiceLanes().find(
18175
+ (lane) => lane.path === path && lane.platform === config2.desktopPlatform && lane.version === config2.desktopVersion
18176
+ );
18177
+ if (legacy) {
18178
+ return {
18179
+ enabled: true,
18180
+ policy: "legacy-retained",
18181
+ reason: "legacy-retained-named-profile"
18182
+ };
18183
+ }
18184
+ if (isolatedQualificationMatches(path, config2)) {
18185
+ return {
18186
+ enabled: true,
18187
+ policy: "unreviewed",
18188
+ reason: "isolated-qualification"
18189
+ };
18190
+ }
18191
+ return { enabled: false, policy: "unreviewed", reason: "missing-evidence" };
18192
+ }
18193
+ function isVoiceEvidenceRecord(value) {
18194
+ if (!recordObject(value)) return false;
18195
+ 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);
18196
+ }
18197
+ function voiceEvidenceRecordsFromConfig(config2) {
18198
+ return (config2.voiceEvidence ?? []).filter(isVoiceEvidenceRecord);
18199
+ }
18200
+ function startupVoiceGate(config2) {
18201
+ const records = [
18202
+ ...voiceEvidenceRecordsFromConfig(config2),
18203
+ ...config2.evidence && isVoiceEvidenceRecord(config2.evidence) ? [config2.evidence] : []
18204
+ ];
18205
+ const chat = decidePath("chat", config2, records);
18206
+ const workCodex = decidePath("work-codex", config2, records);
18207
+ const workGrok = decidePath("work-grok", config2, records);
18208
+ return {
18209
+ chat,
18210
+ "work-codex": workCodex,
18211
+ "work-grok": workGrok,
18212
+ work: workCodex
18213
+ };
18214
+ }
18215
+ function chatVoiceQualified(config2) {
18216
+ return startupVoiceGate(config2).chat.enabled;
18217
+ }
18218
+ function workVoiceLaneEnabled(owner, path) {
18219
+ return workVoicePathDecision(owner, path).enabled;
18220
+ }
18221
+ function workVoicePathDecision(owner, path) {
18222
+ const config2 = readCpaLiveVoiceHookConfig(owner);
18223
+ if (!config2) {
18224
+ return {
18225
+ enabled: false,
18226
+ policy: "unreviewed",
18227
+ reason: workVoiceUnavailableReason({}) ?? "Work voice is not qualified on this Desktop."
18228
+ };
18229
+ }
18230
+ return startupVoiceGate(config2)[path];
18231
+ }
18232
+ function workVoiceUserFacingUnavailable(owner, path) {
18233
+ void path;
18234
+ const config2 = readCpaLiveVoiceHookConfig(owner) ?? {};
18235
+ return workVoiceUnavailableReason(config2) ?? "Work voice is not qualified on this Desktop.";
18236
+ }
18237
+ function chatVoiceUserFacingUnavailable(owner) {
18238
+ const config2 = readCpaLiveVoiceHookConfig(owner) ?? {};
18239
+ return nativeChatVoiceUnavailableReason(config2) ?? "Chat voice is not qualified on this Desktop.";
18240
+ }
18241
+ function chatVoiceQualifiedOnOwner(owner) {
18242
+ const config2 = readCpaLiveVoiceHookConfig(owner);
18243
+ return config2 ? chatVoiceQualified(config2) : false;
18244
+ }
18245
+
18246
+ // src/renderer-chat-voice-debug.ts
18247
+ var CHAT_VOICE_DEBUG_GLOBAL = "__codexhostChatVoiceDebug";
18248
+ var CHAT_VOICE_DEBUG_STORAGE_KEY = "codexhost.chat-voice-debug.v1";
18249
+ function chatVoiceDebug(event, detail = {}) {
18250
+ const entry = { t: Date.now(), event, ...detail };
18251
+ const owner = globalThis;
18252
+ const log = Array.isArray(owner[CHAT_VOICE_DEBUG_GLOBAL]) ? owner[CHAT_VOICE_DEBUG_GLOBAL] : [];
18253
+ log.push(entry);
18254
+ while (log.length > 40) log.shift();
18255
+ owner[CHAT_VOICE_DEBUG_GLOBAL] = log;
18256
+ try {
18257
+ owner.localStorage?.setItem(CHAT_VOICE_DEBUG_STORAGE_KEY, JSON.stringify(log));
18258
+ } catch {
18259
+ }
18260
+ owner.console?.info?.("[codexhost-chat-voice]", event, detail);
18261
+ }
18262
+
18263
+ // src/renderer-voice-gateway-wrap.ts
18264
+ function object2(value) {
18265
+ return value !== null && typeof value === "object";
18266
+ }
18267
+ var HOST_MCP_TIMEOUT_MESSAGE = "Host request timed out";
18268
+ var HOST_MCP_UNAVAILABLE_MESSAGE = "Local Host connection is unavailable";
18269
+ var DIRECT_VOICE_HOST_GLOBAL = "__codexhostVoiceHostV1";
18270
+ function resolveDirectVoiceHost(owner = globalThis) {
18271
+ const value = Reflect.get(owner, DIRECT_VOICE_HOST_GLOBAL);
18272
+ if (!value || typeof value !== "object") return null;
18273
+ const request = Reflect.get(value, "request");
18274
+ return typeof request === "function" ? { request: request.bind(value) } : null;
18275
+ }
18276
+ function hostMcpStage(value) {
18277
+ return value === "config" || value === "request" || value === "transport" || value === "identity" || value === "cancel" ? value : "rpc";
18278
+ }
18279
+ function requestVoiceHost(_bridge, params, method = REALTIME_CALL_METHOD) {
18280
+ const host = resolveDirectVoiceHost();
18281
+ if (!host) {
18282
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "host-unavailable" });
18283
+ return Promise.reject(new Error("Voice gateway Host connection is unavailable"));
18284
+ }
18285
+ return host.request(method, params).then(
18286
+ (result) => result,
18287
+ (error51) => {
18288
+ const message = error51 instanceof Error ? error51.message : "";
18289
+ if (message === HOST_MCP_TIMEOUT_MESSAGE || /timed out/i.test(message)) {
18290
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "timeout" });
18291
+ throw new Error("Voice gateway did not answer in time");
18292
+ }
18293
+ if (message === HOST_MCP_UNAVAILABLE_MESSAGE) {
18294
+ chatVoiceDebug("gateway-create", { stage: "rpc", cause: "host-unavailable" });
18295
+ throw new Error("Voice gateway Host connection is unavailable");
18296
+ }
18297
+ const stage = error51 instanceof Error && "stage" in error51 ? hostMcpStage(error51.stage) : "rpc";
18298
+ chatVoiceDebug("gateway-create", { stage, cause: "failed" });
18299
+ throw new Error("Configured voice gateway request failed");
18300
+ }
18301
+ );
18302
+ }
18303
+ function parseRealtimeCallResponse(value) {
18304
+ if (value === null || typeof value !== "object")
18305
+ throw new Error("Invalid voice gateway response");
18306
+ const record5 = value;
18307
+ if (typeof record5.status !== "number" || !Number.isInteger(record5.status) || record5.status < 200 || record5.status > 599 || typeof record5.body !== "string" || record5.headers === null || typeof record5.headers !== "object" || Array.isArray(record5.headers)) {
18308
+ throw new Error("Invalid voice gateway response");
18309
+ }
18310
+ const headers = {};
18311
+ for (const [name, header] of Object.entries(record5.headers)) {
18312
+ if (typeof header === "string") headers[name] = header;
18313
+ }
18314
+ return { status: record5.status, body: record5.body, headers };
18315
+ }
18316
+ function backendModelName(headers) {
18317
+ const raw = new Headers(headers).get("x-codex-turn-metadata");
18318
+ if (!raw) return "";
18319
+ try {
18320
+ const parsed = JSON.parse(raw);
18321
+ return typeof parsed.backend_model_name === "string" ? parsed.backend_model_name : "";
18322
+ } catch {
18323
+ return "";
18324
+ }
18325
+ }
18326
+ function isWorkBackendModel(name) {
18327
+ const model2 = name.toLowerCase();
18328
+ if (!model2) return false;
18329
+ if (model2.startsWith("codexhost/")) return true;
18330
+ return model2.includes("codex") && !model2.includes("gpt-live");
18331
+ }
18332
+ var lastVoiceProductExperience;
18333
+ var VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY = "codexhost.voice-launch-experience.v1";
18334
+ function launchStorage(owner) {
18335
+ return owner.localStorage;
18336
+ }
18337
+ function storedVoiceProductExperience(owner) {
18338
+ try {
18339
+ const stored = launchStorage(owner)?.getItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY);
18340
+ return stored === "chat" || stored === "work" || stored === "codex" ? stored : void 0;
18341
+ } catch {
18342
+ return void 0;
18343
+ }
18344
+ }
18345
+ function rememberVoiceProductExperience(request, owner = globalThis) {
18346
+ const experience = object2(request) ? request.productExperience : void 0;
18347
+ lastVoiceProductExperience = experience === "chat" || experience === "work" || experience === "codex" ? experience : void 0;
18348
+ try {
18349
+ const storage = launchStorage(owner);
18350
+ if (!storage) return;
18351
+ if (lastVoiceProductExperience)
18352
+ storage.setItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY, lastVoiceProductExperience);
18353
+ else storage.removeItem(VOICE_LAUNCH_EXPERIENCE_STORAGE_KEY);
18354
+ } catch {
18355
+ }
18356
+ }
18357
+ function lastVoiceLaunchProductExperience(owner = globalThis) {
18358
+ return lastVoiceProductExperience ?? storedVoiceProductExperience(owner);
18359
+ }
18360
+ 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) {
18361
+ const original = client.fetch;
18362
+ const wrapped = async function(url2, options) {
18363
+ if (typeof url2 !== "string" || url2.split("?")[0] !== "/wham/realtime/calls" || options?.method !== "POST")
18364
+ return original.call(this, url2, options);
18365
+ const experience = lastVoiceLaunchProductExperience();
18366
+ const model2 = backendModelName(options.headers);
18367
+ const originator = new Headers(options.headers).get("originator");
18368
+ const overlayWork = originator === "codex_work_desktop" && experience !== "chat";
18369
+ const overlayHostCreate = overlayExistingCall() && workOverride() && experience !== "chat";
18370
+ const chat = experience === "chat" && !overlayWork && !overlayHostCreate;
18371
+ const work = overlayWork || overlayHostCreate || !chat && (experience === "work" || experience === "codex" || isWorkBackendModel(model2) || workSurface());
18372
+ const external = !chat && (model2.startsWith("codexhost/") || externalHarness());
18373
+ const intendedGateway = external ? true : work ? workOverride() : chatOverride();
18374
+ const chatQualified = chatLane();
18375
+ const qualified = external ? externalLane() : work ? workLane() : chat ? chatQualified : true;
18376
+ const chatgptNative = chat && chatgptInstantConnect();
18377
+ const nativeChatWham = chatgptNative && !intendedGateway && allowChatNativeWham() && chatQualified;
18378
+ let route;
18379
+ if (chatgptNative && !chatQualified) route = "blocked";
18380
+ else if (chatgptNative && !intendedGateway && !nativeChatWham) route = "blocked";
18381
+ else if (chat && intendedGateway && !chatQualified) route = "blocked";
18382
+ else if (!intendedGateway) route = "desktop";
18383
+ else if (qualified) route = "gateway";
18384
+ else route = "blocked";
18385
+ chatVoiceDebug("wham-create", {
18386
+ work,
18387
+ external,
18388
+ route,
18389
+ productExperience: experience ?? "unset",
18390
+ originator: originator ?? "unset",
18391
+ overlayWork,
18392
+ overlayHostCreate
18393
+ });
18394
+ if (route === "blocked") {
18395
+ if (chat) {
18396
+ throw new Error(
18397
+ chatQualified ? "Native Chat voice is unavailable" : unavailableReason("chat")
18398
+ );
18399
+ }
18400
+ throw new Error(unavailableReason(external ? "external" : "work"));
18401
+ }
18402
+ if (route === "desktop") {
18403
+ if (!external && !work)
18404
+ chatVoiceDebug("chat-native-passthrough", {
18405
+ hasThreadId: new Headers(options.headers).has("Thread-Id")
18406
+ });
18407
+ return original.call(this, url2, options);
18408
+ }
18409
+ if (typeof options.body !== "string") throw new Error("Unsupported native voice call request");
18410
+ options.signal?.throwIfAborted();
18411
+ const requestId2 = crypto.randomUUID();
18412
+ let cancelled = false;
18413
+ const cancel = () => {
18414
+ if (cancelled) return;
18415
+ cancelled = true;
18416
+ void requestVoiceHost(bridge, { operation: "cancel", requestId: requestId2 }).catch(() => void 0);
17214
18417
  };
17215
- unsubscribe = bridge.subscribe("mcp-response", (event) => {
17216
- if (!object2(event) || event.hostId !== "local" || !object2(event.message) || event.message.id !== id)
17217
- return;
17218
- done();
17219
- if (event.message.error) reject(new Error("Configured voice gateway request failed"));
17220
- else resolve(event.message.result);
17221
- });
18418
+ options.signal?.addEventListener("abort", cancel, { once: true });
17222
18419
  try {
17223
- bridge.dispatchMessage("mcp-request", {
17224
- hostId: "local",
17225
- request: { id, method, params }
18420
+ let result;
18421
+ try {
18422
+ result = parseRealtimeCallResponse(
18423
+ await requestVoiceHost(bridge, {
18424
+ operation: "create",
18425
+ requestId: requestId2,
18426
+ body: options.body,
18427
+ headers: filterRealtimeCallHeaders(Object.fromEntries(new Headers(options.headers)))
18428
+ })
18429
+ );
18430
+ } catch (error51) {
18431
+ if (error51 instanceof Error && error51.message === "Invalid voice gateway response")
18432
+ chatVoiceDebug("gateway-create", { stage: "response", cause: "invalid" });
18433
+ throw error51;
18434
+ }
18435
+ chatVoiceDebug("gateway-create", {
18436
+ stage: "status",
18437
+ status: result.status,
18438
+ ok: result.status >= 200 && result.status < 300
17226
18439
  });
17227
- } catch {
17228
- done();
17229
- reject(new Error("Voice gateway Host connection is unavailable"));
18440
+ if (options.signal?.aborted) {
18441
+ const callId = realtimeCallIdFromLocation(result.headers.location ?? "");
18442
+ if (result.status >= 200 && result.status < 300 && isRealtimeCallId(callId))
18443
+ await requestVoiceHost(bridge, { operation: "hangup", callId });
18444
+ options.signal.throwIfAborted();
18445
+ }
18446
+ const response = new Response(result.status === 204 ? null : result.body, {
18447
+ status: result.status,
18448
+ headers: result.headers
18449
+ });
18450
+ if (!response.ok) throw await responseError(response, url2);
18451
+ return response;
18452
+ } catch (error51) {
18453
+ cancel();
18454
+ throw error51;
18455
+ } finally {
18456
+ options.signal?.removeEventListener("abort", cancel);
17230
18457
  }
17231
- });
18458
+ };
18459
+ client.fetch = wrapped;
18460
+ return () => {
18461
+ if (client.fetch === wrapped) client.fetch = original;
18462
+ };
17232
18463
  }
18464
+
18465
+ // src/renderer-work-composer-surface.ts
17233
18466
  var HOME_COMPOSER_MODE_STORAGE_KEY = "home-composer-mode-v1";
17234
- function backendModelName(headers) {
17235
- const raw = new Headers(headers).get("x-codex-turn-metadata");
17236
- if (!raw) return "";
17237
- try {
17238
- const parsed = JSON.parse(raw);
17239
- return typeof parsed.backend_model_name === "string" ? parsed.backend_model_name : "";
17240
- } catch {
17241
- return "";
17242
- }
17243
- }
17244
- function isWorkBackendModel(name) {
17245
- const model2 = name.toLowerCase();
17246
- if (!model2) return false;
17247
- if (model2.startsWith("codexhost/")) return true;
17248
- return model2.includes("codex") && !model2.includes("gpt-live");
17249
- }
17250
18467
  function visibleWorkComposer(owner) {
17251
18468
  const document = owner.document;
17252
18469
  if (!document?.querySelectorAll) return false;
@@ -17292,134 +18509,402 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17292
18509
  }
17293
18510
  return selectedWorkTab(owner) || visibleWorkComposer(owner);
17294
18511
  }
17295
- function selectedComposerModel(owner) {
17296
- const routing = owner.__codexhostHostRoutingV1;
18512
+
18513
+ // src/renderer-hashed-overlay-voice.ts
18514
+ var HOOK_GLOBAL = "__codexhostClientOwnedVoiceV1";
18515
+ var SHARED_VOICE_CACHE2 = "codexhost.voice-routes-cache.v1";
18516
+ var WORK_GATEWAY_FLAG = "codexhost.cpa-live-voice.v1";
18517
+ var CHAT_GATEWAY_FLAG = "codexhost.chat-live-voice.v1";
18518
+ function object3(value) {
18519
+ return value !== null && typeof value === "object";
18520
+ }
18521
+ function overlayCompactVoiceDocument(target2) {
17297
18522
  try {
17298
- const model2 = routing?.forComposer()?.policy.selectedModel();
17299
- return typeof model2 === "string" ? model2 : "";
18523
+ const href = target2.location?.href ?? globalThis.location?.href ?? "";
18524
+ return href.includes("avatar-overlay");
17300
18525
  } catch {
17301
- return "";
18526
+ return false;
17302
18527
  }
17303
18528
  }
17304
- var lastVoiceProductExperience;
17305
- function rememberVoiceProductExperience(request) {
17306
- const experience = object2(request) ? request.productExperience : void 0;
17307
- lastVoiceProductExperience = experience === "chat" || experience === "work" || experience === "codex" ? experience : void 0;
18529
+ function visibleComposerLaunchExperience(target2) {
18530
+ const document = target2.document;
18531
+ if (!document?.querySelectorAll) return;
18532
+ const visible = (element) => {
18533
+ const box = element.getBoundingClientRect?.() ?? { width: 0 };
18534
+ return box.width > 0 && !element.closest?.("[hidden], [inert]");
18535
+ };
18536
+ const chat = [...document.querySelectorAll("[data-chatgpt-composer]")].some(visible);
18537
+ const work = [...document.querySelectorAll("[data-codex-composer-root]")].some(visible);
18538
+ if (chat && !work) return "chat";
18539
+ if (work && !chat) return "work";
18540
+ }
18541
+ function publishComposerLaunchExperience(target2) {
18542
+ if (overlayCompactVoiceDocument(target2)) return;
18543
+ rememberVoiceProductExperience(
18544
+ {
18545
+ productExperience: visibleComposerLaunchExperience(target2) ?? (isWorkComposerSurface(target2) ? "work" : "chat")
18546
+ },
18547
+ target2
18548
+ );
18549
+ }
18550
+ function hashedOverlayVoiceSupported(config2) {
18551
+ if (hashedVoiceProfileSupported(config2)) return true;
18552
+ if (!hashedVoiceCandidateOwner(config2)) return false;
18553
+ return isolatedVoicePathEnabled(config2, "work-codex") || isolatedVoicePathEnabled(config2, "work-grok");
18554
+ }
18555
+ function hashedWebpackVoiceSupported(config2) {
18556
+ return hashedOverlayVoiceSupported(config2);
18557
+ }
18558
+ function cachedConnection(owner, field2) {
18559
+ try {
18560
+ const parsed = JSON.parse(
18561
+ owner.localStorage?.getItem(SHARED_VOICE_CACHE2) ?? "null"
18562
+ );
18563
+ return object3(parsed) ? parsed[field2] : void 0;
18564
+ } catch {
18565
+ return void 0;
18566
+ }
17308
18567
  }
17309
- function lastVoiceLaunchProductExperience() {
17310
- return lastVoiceProductExperience;
18568
+ function cachedChatExperience(owner) {
18569
+ try {
18570
+ const parsed = JSON.parse(
18571
+ owner.localStorage?.getItem(SHARED_VOICE_CACHE2) ?? "null"
18572
+ );
18573
+ return object3(parsed) ? parsed.chatExperience : void 0;
18574
+ } catch {
18575
+ return void 0;
18576
+ }
17311
18577
  }
17312
- function lastAgentIsExternalHarness(owner) {
18578
+ function storageFlag(owner, key, enabledWhenUnset) {
17313
18579
  const storage = owner.localStorage;
17314
- if (!storage) return false;
18580
+ if (!storage) return enabledWhenUnset;
17315
18581
  try {
17316
- const parsed = JSON.parse(storage.getItem(RENDERER_NEW_THREAD_PREFERENCE_KEY) ?? "");
17317
- return typeof parsed.lastAgent === "string" && parsed.lastAgent !== "" && parsed.lastAgent !== "codex";
18582
+ const value = storage.getItem(key);
18583
+ return enabledWhenUnset ? value !== "0" : value === "1";
17318
18584
  } catch {
17319
- return false;
18585
+ return enabledWhenUnset;
17320
18586
  }
17321
18587
  }
17322
- function isExternalHarnessComposer(owner = globalThis) {
17323
- if (lastVoiceProductExperience === "chat") return false;
17324
- if (selectedComposerModel(owner).startsWith("codexhost/")) return true;
17325
- if (lastVoiceProductExperience === "codex") return false;
17326
- if (lastVoiceProductExperience !== "work" && !isWorkComposerSurface(owner)) return false;
17327
- return lastAgentIsExternalHarness(owner);
18588
+ function workGatewayPreference(owner) {
18589
+ const connection = cachedConnection(owner, "workConnection");
18590
+ return connection !== void 0 ? connection === "gateway" : storageFlag(owner, WORK_GATEWAY_FLAG, true);
17328
18591
  }
17329
- function wrapClientOwnedVoiceFetch(client, bridge, workOverride, responseError, chatOverride = () => false, workSurface = () => isWorkComposerSurface(), externalHarness = () => isExternalHarnessComposer()) {
17330
- const original = client.fetch;
17331
- const wrapped = async function(url2, options) {
17332
- if (typeof url2 !== "string" || url2.split("?")[0] !== "/wham/realtime/calls" || options?.method !== "POST")
17333
- return original.call(this, url2, options);
17334
- const experience = lastVoiceLaunchProductExperience();
17335
- const chat = experience === "chat";
17336
- const model2 = backendModelName(options.headers);
17337
- const work = !chat && (experience === "work" || experience === "codex" || isWorkBackendModel(model2) || workSurface());
17338
- const external = !chat && (model2.startsWith("codexhost/") || externalHarness());
17339
- const gateway = external || (work ? workOverride() : chatOverride());
17340
- chatVoiceDebug("wham-create", {
17341
- work,
17342
- external,
17343
- route: gateway ? "gateway" : "desktop",
17344
- productExperience: experience ?? "unset"
17345
- });
17346
- if (!gateway) {
17347
- if (!external && !work)
17348
- chatVoiceDebug("chat-native-passthrough", {
17349
- hasThreadId: new Headers(options.headers).has("Thread-Id")
17350
- });
17351
- return original.call(this, url2, options);
17352
- }
17353
- if (typeof options.body !== "string") throw new Error("Unsupported native voice call request");
17354
- options.signal?.throwIfAborted();
17355
- const requestId2 = crypto.randomUUID();
17356
- let cancelled = false;
17357
- const cancel = () => {
17358
- if (cancelled) return;
17359
- cancelled = true;
17360
- void requestVoiceHost(bridge, { operation: "cancel", requestId: requestId2 }).catch(() => void 0);
17361
- };
17362
- options.signal?.addEventListener("abort", cancel, { once: true });
18592
+ function chatGatewayEnabled(owner) {
18593
+ const experience = cachedChatExperience(owner);
18594
+ const connection = cachedConnection(owner, "chatConnection");
18595
+ if (experience !== void 0 || connection !== void 0)
18596
+ return experience === "codex" && connection === "gateway";
18597
+ return storageFlag(owner, CHAT_GATEWAY_FLAG, false);
18598
+ }
18599
+ function nativeVoiceOwner(value) {
18600
+ return value !== null && (typeof value === "object" || typeof value === "function") ? value : void 0;
18601
+ }
18602
+ function nativeVoiceInstance(value) {
18603
+ const owner = nativeVoiceOwner(value);
18604
+ if (!owner) return value;
18605
+ const getInstance = Reflect.get(owner, "getInstance");
18606
+ return typeof getInstance === "function" ? getInstance.call(owner) : owner;
18607
+ }
18608
+ function nativeVoiceFetch(value) {
18609
+ const instance = nativeVoiceInstance(value);
18610
+ if (!object3(instance) || typeof instance.fetch !== "function") return void 0;
18611
+ return instance;
18612
+ }
18613
+ function nativeVoiceBridge(value) {
18614
+ const instance = nativeVoiceInstance(value);
18615
+ if (!object3(instance) || typeof instance.dispatchMessage !== "function" || typeof instance.subscribe !== "function") {
18616
+ return void 0;
18617
+ }
18618
+ return instance;
18619
+ }
18620
+ function isWebpackRequire(value) {
18621
+ return typeof value === "function";
18622
+ }
18623
+ function peekWebpackExport(req, id) {
18624
+ return req.c?.[id]?.exports;
18625
+ }
18626
+ function unpoisonIncompleteWebpackModule(req, id, usable) {
18627
+ const cache = req.c;
18628
+ const cached2 = cache?.[id];
18629
+ if (!cache || !cached2 || usable(cached2.exports)) return;
18630
+ try {
18631
+ Reflect.deleteProperty(cache, id);
18632
+ } catch {
18633
+ }
18634
+ }
18635
+ function safeWebpackRequire(req, id) {
18636
+ const existing = peekWebpackExport(req, id);
18637
+ if (object3(existing) && Object.keys(existing).length > 0) return existing;
18638
+ try {
18639
+ return req(id);
18640
+ } catch {
18641
+ unpoisonIncompleteWebpackModule(
18642
+ req,
18643
+ id,
18644
+ (value) => object3(value) && Object.keys(value).length > 0
18645
+ );
18646
+ return void 0;
18647
+ }
18648
+ }
18649
+ function readGdntExports(req) {
18650
+ const factoryId = HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId;
18651
+ const fetchExport = HASHED_OVERLAY_VOICE_ROLES.fetchExport;
18652
+ const peeked = peekWebpackExport(req, factoryId);
18653
+ if (nativeVoiceFetch(object3(peeked) ? peeked[fetchExport] : void 0)) return peeked;
18654
+ unpoisonIncompleteWebpackModule(
18655
+ req,
18656
+ factoryId,
18657
+ (value) => Boolean(nativeVoiceFetch(object3(value) ? value[fetchExport] : void 0))
18658
+ );
18659
+ if (typeof req.m?.[factoryId] !== "function") return safeWebpackRequire(req, factoryId);
18660
+ return void 0;
18661
+ }
18662
+ function hookWebpackVoiceFactory(req, onExports) {
18663
+ const modules = req.m;
18664
+ const factoryId = HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId;
18665
+ const original = modules?.[factoryId];
18666
+ if (!modules || typeof original !== "function") return false;
18667
+ if (original.__codexhostVoiceFactory) return true;
18668
+ const wrapped = function(module, exports, webpackRequire) {
17363
18669
  try {
17364
- const result = realtimeCallResponseSchema.parse(
17365
- await requestVoiceHost(bridge, {
17366
- operation: "create",
17367
- requestId: requestId2,
17368
- body: options.body,
17369
- // Drop Desktop OAuth, ChatGPT account identity and cookies at the bridge
17370
- // boundary; the Host allowlist repeats this check before sending.
17371
- headers: filterRealtimeCallHeaders(Object.fromEntries(new Headers(options.headers)))
17372
- })
17373
- );
17374
- if (options.signal?.aborted) {
17375
- const callId = realtimeCallIdFromLocation(result.headers.location ?? "");
17376
- if (result.status >= 200 && result.status < 300 && isRealtimeCallId(callId))
17377
- await requestVoiceHost(bridge, { operation: "hangup", callId });
17378
- options.signal.throwIfAborted();
17379
- }
17380
- const response = new Response(result.status === 204 ? null : result.body, {
17381
- status: result.status,
17382
- headers: result.headers
17383
- });
17384
- if (!response.ok) throw await responseError(response, url2);
17385
- return response;
17386
- } catch (error51) {
17387
- cancel();
17388
- throw error51;
18670
+ return original.apply(this, [module, exports, webpackRequire]);
17389
18671
  } finally {
17390
- options.signal?.removeEventListener("abort", cancel);
18672
+ onExports(exports ?? module?.exports);
17391
18673
  }
17392
18674
  };
17393
- client.fetch = wrapped;
17394
- return () => {
17395
- if (client.fetch === wrapped) client.fetch = original;
18675
+ wrapped.__codexhostVoiceFactory = true;
18676
+ modules[factoryId] = wrapped;
18677
+ return true;
18678
+ }
18679
+ async function resolveHashedWebpackVoice(importModule) {
18680
+ const runtime = await importModule(`app://-/assets/${HASHED_WEBPACK_VOICE_RUNTIME_ASSET}`);
18681
+ const req = runtime?.__webpack_require__;
18682
+ if (!isWebpackRequire(req)) return null;
18683
+ const roles = HASHED_OVERLAY_VOICE_ROLES;
18684
+ const gdnt = readGdntExports(req);
18685
+ const client = nativeVoiceFetch(object3(gdnt) ? gdnt[roles.fetchExport] : void 0);
18686
+ const hostBridge = safeWebpackRequire(req, roles.bridgeModuleId);
18687
+ const bridged = nativeVoiceBridge(
18688
+ object3(hostBridge) ? hostBridge[roles.bridgeExport] : void 0
18689
+ );
18690
+ const errorModule = safeWebpackRequire(req, roles.responseErrorModuleId);
18691
+ const responseError = object3(errorModule) ? errorModule[roles.responseErrorExport] : void 0;
18692
+ if (!bridged || typeof responseError !== "function") return null;
18693
+ if (client)
18694
+ return {
18695
+ client,
18696
+ bridge: bridged,
18697
+ responseError
18698
+ };
18699
+ if (typeof req.m?.[HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId] !== "function") return null;
18700
+ return {
18701
+ bridge: bridged,
18702
+ responseError,
18703
+ require: req
17396
18704
  };
17397
18705
  }
17398
- function installClientOwnedVoiceHook(options = {}) {
18706
+ function installHashedOverlayVoiceHook(options = {}) {
17399
18707
  const target2 = options.target ?? globalThis;
17400
18708
  const existing = target2[HOOK_GLOBAL];
17401
18709
  if (existing) return existing;
17402
18710
  const config2 = readCpaLiveVoiceHookConfig(target2);
17403
18711
  if (!config2) return { status: "disabled", dispose() {
17404
18712
  } };
17405
- if (!supportsVoiceVersion(CLIENT_OWNED_VOICE_ASSETS, config2.desktopVersion))
17406
- return { status: "unsupported", dispose() {
17407
- } };
18713
+ if (!hashedWebpackVoiceSupported(config2)) return { status: "unsupported", dispose() {
18714
+ } };
17408
18715
  const importModule = options.importModule ?? ((url2) => import(url2));
17409
18716
  let disposed = false;
17410
18717
  let timer;
18718
+ let surfaceTimer;
17411
18719
  let restore;
17412
18720
  const started = Date.now();
18721
+ const activation = {
18722
+ assetSeen: false,
18723
+ importStarted: false,
18724
+ importResolved: false,
18725
+ factoryHooked: false,
18726
+ wrapperActive: false
18727
+ };
18728
+ const pointerTarget = target2.document;
18729
+ const onPointerDown = () => publishComposerLaunchExperience(target2);
17413
18730
  const handle = {
17414
18731
  status: "pending",
18732
+ activation,
17415
18733
  dispose() {
17416
18734
  disposed = true;
17417
18735
  if (timer !== void 0) target2.clearTimeout(timer);
18736
+ if (surfaceTimer !== void 0) target2.clearTimeout(surfaceTimer);
18737
+ pointerTarget?.removeEventListener?.("pointerdown", onPointerDown, true);
17418
18738
  restore?.();
17419
18739
  if (target2[HOOK_GLOBAL] === handle) Reflect.deleteProperty(target2, HOOK_GLOBAL);
17420
18740
  }
17421
18741
  };
17422
18742
  target2[HOOK_GLOBAL] = handle;
18743
+ pointerTarget?.addEventListener?.("pointerdown", onPointerDown, true);
18744
+ const publishLoop = () => {
18745
+ if (disposed) return;
18746
+ publishComposerLaunchExperience(target2);
18747
+ surfaceTimer = target2.setTimeout(publishLoop, 250);
18748
+ };
18749
+ publishLoop();
18750
+ const activate = (client, bridge, responseError) => {
18751
+ restore = wrapClientOwnedVoiceFetch(
18752
+ client,
18753
+ bridge,
18754
+ () => workGatewayPreference(target2),
18755
+ responseError,
18756
+ () => chatGatewayEnabled(target2),
18757
+ () => !overlayCompactVoiceDocument(target2) && isWorkComposerSurface(target2),
18758
+ () => false,
18759
+ () => overlayCompactVoiceDocument(target2),
18760
+ () => workVoiceLaneEnabled(target2, "work-grok"),
18761
+ () => workVoiceLaneEnabled(target2, "work-codex"),
18762
+ (kind) => kind === "chat" ? chatVoiceUserFacingUnavailable(target2) : workVoiceUserFacingUnavailable(
18763
+ target2,
18764
+ kind === "external" ? "work-grok" : "work-codex"
18765
+ ),
18766
+ () => chatVoiceQualifiedOnOwner(target2),
18767
+ () => false,
18768
+ () => nativeChatVoicePreferenceAllowsStart(target2)
18769
+ );
18770
+ activation.wrapperActive = true;
18771
+ handle.status = "active";
18772
+ };
18773
+ const attempt = async () => {
18774
+ if (disposed || handle.status === "active") return;
18775
+ publishComposerLaunchExperience(target2);
18776
+ const names = loadedAssetNames(target2.document, target2.performance);
18777
+ const hashedAssetSeen = names.some((name) => name.includes(HASHED_WEBPACK_VOICE_RUNTIME_ASSET));
18778
+ if (hashedAssetSeen) activation.assetSeen = true;
18779
+ if (hashedAssetSeen) {
18780
+ activation.importStarted = true;
18781
+ try {
18782
+ const resolved = await resolveHashedWebpackVoice(importModule);
18783
+ if (disposed || activation.wrapperActive) return;
18784
+ if (resolved?.client) {
18785
+ activation.importResolved = true;
18786
+ delete activation.importFailed;
18787
+ activate(resolved.client, resolved.bridge, resolved.responseError);
18788
+ return;
18789
+ }
18790
+ const webpackRequire = resolved?.require;
18791
+ if (webpackRequire && hookWebpackVoiceFactory(webpackRequire, (exports) => {
18792
+ if (disposed || activation.wrapperActive) return;
18793
+ const client = nativeVoiceFetch(
18794
+ object3(exports) ? exports[HASHED_OVERLAY_VOICE_ROLES.fetchExport] : void 0
18795
+ );
18796
+ if (!client) {
18797
+ unpoisonIncompleteWebpackModule(
18798
+ webpackRequire,
18799
+ HASHED_OVERLAY_VOICE_ROLES.fetchFactoryId,
18800
+ (value) => Boolean(
18801
+ nativeVoiceFetch(
18802
+ object3(value) ? value[HASHED_OVERLAY_VOICE_ROLES.fetchExport] : void 0
18803
+ )
18804
+ )
18805
+ );
18806
+ return;
18807
+ }
18808
+ activate(client, resolved.bridge, resolved.responseError);
18809
+ })) {
18810
+ activation.importResolved = true;
18811
+ activation.factoryHooked = true;
18812
+ delete activation.importFailed;
18813
+ return;
18814
+ }
18815
+ activation.importFailed = "hashed-exports-missing";
18816
+ } catch {
18817
+ activation.importFailed = "hashed-import-failed";
18818
+ }
18819
+ }
18820
+ timer = target2.setTimeout(() => void attempt(), Date.now() - started >= 5e3 ? 1e3 : 250);
18821
+ };
18822
+ void attempt();
18823
+ return handle;
18824
+ }
18825
+
18826
+ // src/renderer-client-owned-voice.ts
18827
+ var SHARED_INIT = "Oit";
18828
+ var SHARED_RESPONSE_ERROR = "Mit";
18829
+ var HOOK_GLOBAL2 = "__codexhostClientOwnedVoiceV1";
18830
+ function selectedComposerModel(owner) {
18831
+ const routing = owner.__codexhostHostRoutingV1;
18832
+ try {
18833
+ const model2 = routing?.forComposer()?.policy.selectedModel();
18834
+ return typeof model2 === "string" ? model2 : "";
18835
+ } catch {
18836
+ return "";
18837
+ }
18838
+ }
18839
+ function isExternalHarnessComposer(owner = globalThis) {
18840
+ const experience = lastVoiceLaunchProductExperience();
18841
+ if (experience === "chat") return false;
18842
+ return selectedComposerModel(owner).startsWith("codexhost/");
18843
+ }
18844
+ function object4(value) {
18845
+ return value !== null && typeof value === "object";
18846
+ }
18847
+ function installClientOwnedVoiceHook(options = {}) {
18848
+ const target2 = options.target ?? globalThis;
18849
+ const existing = target2[HOOK_GLOBAL2];
18850
+ if (existing) return existing;
18851
+ const config2 = readCpaLiveVoiceHookConfig(target2);
18852
+ if (!config2) return { status: "disabled", dispose() {
18853
+ } };
18854
+ if (hashedOverlayVoiceSupported(config2)) {
18855
+ return installHashedOverlayVoiceHook({
18856
+ target: target2,
18857
+ ...options.importModule ? { importModule: options.importModule } : {}
18858
+ });
18859
+ }
18860
+ if (!supportsVoiceVersion(CLIENT_OWNED_VOICE_ASSETS, config2.desktopVersion))
18861
+ return { status: "unsupported", dispose() {
18862
+ } };
18863
+ const importModule = options.importModule ?? ((url2) => import(url2));
18864
+ let disposed = false;
18865
+ let timer;
18866
+ let restore;
18867
+ const started = Date.now();
18868
+ const activation = {
18869
+ assetSeen: false,
18870
+ importStarted: false,
18871
+ importResolved: false,
18872
+ wrapperActive: false
18873
+ };
18874
+ const handle = {
18875
+ status: "pending",
18876
+ activation,
18877
+ dispose() {
18878
+ disposed = true;
18879
+ if (timer !== void 0) target2.clearTimeout(timer);
18880
+ restore?.();
18881
+ if (target2[HOOK_GLOBAL2] === handle) Reflect.deleteProperty(target2, HOOK_GLOBAL2);
18882
+ }
18883
+ };
18884
+ target2[HOOK_GLOBAL2] = handle;
18885
+ const activate = (client, bridge, responseError) => {
18886
+ restore = wrapClientOwnedVoiceFetch(
18887
+ client,
18888
+ bridge,
18889
+ () => cpaLiveVoicePreferenceAllowsInstall(target2),
18890
+ responseError,
18891
+ () => chatLiveVoicePreferenceAllowsOverride(target2),
18892
+ () => isWorkComposerSurface(target2),
18893
+ () => isExternalHarnessComposer(target2),
18894
+ () => false,
18895
+ () => workVoiceLaneEnabled(target2, "work-grok"),
18896
+ () => workVoiceLaneEnabled(target2, "work-codex"),
18897
+ (kind) => kind === "chat" ? chatVoiceUserFacingUnavailable(target2) : workVoiceUserFacingUnavailable(
18898
+ target2,
18899
+ kind === "external" ? "work-grok" : "work-codex"
18900
+ ),
18901
+ () => chatVoiceQualifiedOnOwner(target2),
18902
+ () => !hashedOverlayVoiceSupported(config2),
18903
+ () => nativeChatVoicePreferenceAllowsStart(target2)
18904
+ );
18905
+ activation.wrapperActive = true;
18906
+ handle.status = "active";
18907
+ };
17423
18908
  const attempt = async () => {
17424
18909
  if (disposed) return;
17425
18910
  const names = loadedAssetNames(target2.document, target2.performance);
@@ -17429,7 +18914,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17429
18914
  config2.desktopVersion,
17430
18915
  config2.desktopPlatform
17431
18916
  );
17432
- if (assets) {
18917
+ if (handle.status !== "active" && assets) {
17433
18918
  try {
17434
18919
  const sharedModule = await importModule(`app://-/assets/${assets.shared}`);
17435
18920
  const fetchFrom = "fetchFrom" in assets ? assets.fetchFrom : "shared";
@@ -17446,8 +18931,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17446
18931
  }
17447
18932
  const fetchClass = typeof fetchName === "string" ? fetchModule[fetchName] : void 0;
17448
18933
  const bridgeClass = typeof bridgeName === "string" ? sharedModule[bridgeName] : void 0;
17449
- if (!object2(fetchClass) && typeof fetchClass !== "function") throw new Error();
17450
- if (!object2(bridgeClass) && typeof bridgeClass !== "function") throw new Error();
18934
+ if (!object4(fetchClass) && typeof fetchClass !== "function") throw new Error();
18935
+ if (!object4(bridgeClass) && typeof bridgeClass !== "function") throw new Error();
17451
18936
  const client = Reflect.get(fetchClass, "getInstance").call(fetchClass);
17452
18937
  const bridge = Reflect.get(bridgeClass, "getInstance").call(bridgeClass);
17453
18938
  const errorModule = "responseErrorFrom" in assets && assets.responseErrorFrom === "initial" ? fetchModule : sharedModule;
@@ -17456,16 +18941,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17456
18941
  };
17457
18942
  if (typeof client?.fetch !== "function" || typeof bridge?.dispatchMessage !== "function" || typeof bridge?.subscribe !== "function")
17458
18943
  throw new Error();
17459
- restore = wrapClientOwnedVoiceFetch(
17460
- client,
17461
- bridge,
17462
- () => cpaLiveVoicePreferenceAllowsInstall(target2),
17463
- responseError,
17464
- () => chatLiveVoicePreferenceAllowsOverride(target2),
17465
- () => isWorkComposerSurface(target2),
17466
- () => isExternalHarnessComposer(target2)
17467
- );
17468
- handle.status = "active";
18944
+ activate(client, bridge, responseError);
17469
18945
  } catch {
17470
18946
  }
17471
18947
  }
@@ -17561,7 +19037,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17561
19037
  }
17562
19038
 
17563
19039
  // src/renderer-external-queue.ts
17564
- function isRecord2(value) {
19040
+ function isRecord3(value) {
17565
19041
  return value !== null && typeof value === "object" && !Array.isArray(value);
17566
19042
  }
17567
19043
  function notificationTarget(manager) {
@@ -17569,11 +19045,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17569
19045
  return manager;
17570
19046
  }
17571
19047
  const nested = manager.requestClient;
17572
- return isRecord2(nested) && typeof nested.addNotificationCallback === "function" ? nested : null;
19048
+ return isRecord3(nested) && typeof nested.addNotificationCallback === "function" ? nested : null;
17573
19049
  }
17574
19050
  function notificationParams(notification) {
17575
- if (!isRecord2(notification)) return null;
17576
- return isRecord2(notification.params) ? notification.params : notification;
19051
+ if (!isRecord3(notification)) return null;
19052
+ return isRecord3(notification.params) ? notification.params : notification;
17577
19053
  }
17578
19054
  function notificationThreadId(notification) {
17579
19055
  const params = notificationParams(notification);
@@ -17588,25 +19064,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17588
19064
  if (!params) return null;
17589
19065
  if (typeof params.status === "string") return params.status;
17590
19066
  const turn = params.turn;
17591
- return isRecord2(turn) && typeof turn.status === "string" ? turn.status : null;
19067
+ return isRecord3(turn) && typeof turn.status === "string" ? turn.status : null;
17592
19068
  }
17593
19069
  function isExternalConversation(conversation, threadId) {
17594
- return isRecord2(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
19070
+ return isRecord3(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
17595
19071
  }
17596
19072
  function firstQueuedItemId(items) {
17597
19073
  if (!Array.isArray(items)) return null;
17598
19074
  for (const item of items) {
17599
- if (!isRecord2(item) || item.pausedReason != null) continue;
19075
+ if (!isRecord3(item) || item.pausedReason != null) continue;
17600
19076
  if (typeof item.id === "string" && item.id) return item.id;
17601
19077
  }
17602
19078
  return null;
17603
19079
  }
17604
19080
  function removeQueuedItem(coordinator, threadId, queuedSubmissionId) {
17605
- if (!isRecord2(coordinator) || typeof coordinator.mutate !== "function") return;
19081
+ if (!isRecord3(coordinator) || typeof coordinator.mutate !== "function") return;
17606
19082
  try {
17607
19083
  coordinator.mutate.call(coordinator, threadId, (current) => {
17608
19084
  if (!Array.isArray(current)) return current;
17609
- return current.filter((item) => !isRecord2(item) || item.id !== queuedSubmissionId);
19085
+ return current.filter((item) => !isRecord3(item) || item.id !== queuedSubmissionId);
17610
19086
  });
17611
19087
  } catch (error51) {
17612
19088
  console.error("codexhost could not reconcile the submitted local follow-up", error51);
@@ -17625,24 +19101,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17625
19101
  const isExternalOwner = (threadId) => {
17626
19102
  if (!isExternalConversation(getConversation.call(target2, threadId), threadId)) return false;
17627
19103
  const role = getStreamRole.call(target2, threadId);
17628
- return !(isRecord2(role) && role.role === "follower");
19104
+ return !(isRecord3(role) && role.role === "follower");
17629
19105
  };
17630
19106
  const isIdle = (threadId, coordinator) => {
17631
- const options = isRecord2(coordinator) ? coordinator.options : null;
17632
- const host = isRecord2(options) ? options.submissionHost : null;
17633
- if (isRecord2(host) && typeof host.getActiveTurnId === "function" && typeof host.hasPendingTurnStart === "function") {
19107
+ const options = isRecord3(coordinator) ? coordinator.options : null;
19108
+ const host = isRecord3(options) ? options.submissionHost : null;
19109
+ if (isRecord3(host) && typeof host.getActiveTurnId === "function" && typeof host.hasPendingTurnStart === "function") {
17634
19110
  return host.getActiveTurnId.call(host, threadId) == null && host.hasPendingTurnStart.call(host, threadId) !== true;
17635
19111
  }
17636
19112
  const conversation = getConversation.call(target2, threadId);
17637
- return isRecord2(conversation) && isRecord2(conversation.threadRuntimeStatus) && conversation.threadRuntimeStatus.type === "idle";
19113
+ return isRecord3(conversation) && isRecord3(conversation.threadRuntimeStatus) && conversation.threadRuntimeStatus.type === "idle";
17638
19114
  };
17639
19115
  const queuedSubmissionId = (coordinator, threadId) => {
17640
- if (isRecord2(coordinator) && typeof coordinator.readMessages === "function") {
19116
+ if (isRecord3(coordinator) && typeof coordinator.readMessages === "function") {
17641
19117
  const messages = coordinator.readMessages.call(coordinator, threadId);
17642
19118
  if (Array.isArray(messages)) return firstQueuedItemId(messages);
17643
19119
  }
17644
- const queue = isRecord2(coordinator) ? coordinator.serverQueue : null;
17645
- if (isRecord2(queue) && typeof queue.read === "function") {
19120
+ const queue = isRecord3(coordinator) ? coordinator.serverQueue : null;
19121
+ if (isRecord3(queue) && typeof queue.read === "function") {
17646
19122
  return firstQueuedItemId(queue.read.call(queue, threadId));
17647
19123
  }
17648
19124
  return null;
@@ -17671,7 +19147,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17671
19147
  };
17672
19148
  const onNotification = (notification) => {
17673
19149
  if (disposed) return;
17674
- const method = isRecord2(notification) && typeof notification.method === "string" ? notification.method : null;
19150
+ const method = isRecord3(notification) && typeof notification.method === "string" ? notification.method : null;
17675
19151
  const threadId = notificationThreadId(notification);
17676
19152
  if (!threadId) return;
17677
19153
  if (method === "turn/completed") {
@@ -17692,10 +19168,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17692
19168
  };
17693
19169
  }
17694
19170
  function installRendererExternalQueue(target2) {
17695
- if (!isRecord2(target2) || typeof target2.getTurnCoordinator !== "function") return null;
19171
+ if (!isRecord3(target2) || typeof target2.getTurnCoordinator !== "function") return null;
17696
19172
  const coordinator = target2.getTurnCoordinator();
17697
- const queue = isRecord2(coordinator) ? coordinator.serverQueue : null;
17698
- if (!isRecord2(queue) || typeof queue.isEnabled !== "function") return null;
19173
+ const queue = isRecord3(coordinator) ? coordinator.serverQueue : null;
19174
+ if (!isRecord3(queue) || typeof queue.isEnabled !== "function") return null;
17699
19175
  if (typeof target2.getConversation === "function" && typeof target2.getStreamRole === "function") {
17700
19176
  return installServerQueueDrain(target2);
17701
19177
  }
@@ -17703,13 +19179,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17703
19179
  }
17704
19180
 
17705
19181
  // src/renderer-native-thread.ts
17706
- function isRecord3(value) {
19182
+ function isRecord4(value) {
17707
19183
  return typeof value === "object" && value !== null && !Array.isArray(value);
17708
19184
  }
17709
19185
  async function verifyNativeCodexThread(sendRequest, threadId) {
17710
19186
  const native = await sendRequest("thread/read", { threadId, includeTurns: false });
17711
- const thread2 = isRecord3(native) ? native.thread : null;
17712
- if (!isRecord3(thread2) || thread2.id !== threadId || typeof thread2.modelProvider !== "string" || !thread2.modelProvider || thread2.modelProvider === "codexhost" || typeof thread2.cliVersion !== "string" || !thread2.cliVersion || thread2.cliVersion === "codexhost") {
19187
+ const thread2 = isRecord4(native) ? native.thread : null;
19188
+ if (!isRecord4(thread2) || thread2.id !== threadId || typeof thread2.modelProvider !== "string" || !thread2.modelProvider || thread2.modelProvider === "codexhost" || typeof thread2.cliVersion !== "string" || !thread2.cliVersion || thread2.cliVersion === "codexhost") {
17713
19189
  throw new Error("Native Thread response cannot establish Codex ownership");
17714
19190
  }
17715
19191
  }
@@ -17747,59 +19223,59 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17747
19223
  }
17748
19224
 
17749
19225
  // src/renderer-external-steering.ts
17750
- function isRecord4(value) {
19226
+ function isRecord5(value) {
17751
19227
  return value !== null && typeof value === "object" && !Array.isArray(value);
17752
19228
  }
17753
19229
  function conversationIdFrom(request) {
17754
19230
  if (typeof request === "string" && request) return request;
17755
- if (!isRecord4(request)) return null;
19231
+ if (!isRecord5(request)) return null;
17756
19232
  if (typeof request.conversationId === "string" && request.conversationId)
17757
19233
  return request.conversationId;
17758
19234
  if (typeof request.threadId === "string" && request.threadId) return request.threadId;
17759
19235
  return null;
17760
19236
  }
17761
19237
  function isHostExternalConversation(conversation, threadId) {
17762
- return isRecord4(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
19238
+ return isRecord5(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost";
17763
19239
  }
17764
19240
  function isManager(value) {
17765
- return isRecord4(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator"].every(
19241
+ return isRecord5(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator"].every(
17766
19242
  (key) => typeof value[key] === "function"
17767
19243
  );
17768
19244
  }
17769
19245
  function inputText(input) {
17770
19246
  if (!Array.isArray(input)) return "";
17771
19247
  return input.filter(
17772
- (item) => isRecord4(item) && typeof item.text === "string"
19248
+ (item) => isRecord5(item) && typeof item.text === "string"
17773
19249
  ).map((item) => item.text).join("\n");
17774
19250
  }
17775
19251
  function queuedFollowUpText(message) {
17776
- if (!isRecord4(message)) return "";
19252
+ if (!isRecord5(message)) return "";
17777
19253
  if (typeof message.text === "string" && message.text.trim()) return message.text;
17778
19254
  const context = message.context;
17779
- if (isRecord4(context) && typeof context.prompt === "string" && context.prompt.trim()) {
19255
+ if (isRecord5(context) && typeof context.prompt === "string" && context.prompt.trim()) {
17780
19256
  return context.prompt;
17781
19257
  }
17782
19258
  return "";
17783
19259
  }
17784
19260
  function restoreQueuedTurnStartText(manager, params) {
17785
- if (!isManager(manager) || !isRecord4(params) || typeof params.threadId !== "string")
19261
+ if (!isManager(manager) || !isRecord5(params) || typeof params.threadId !== "string")
17786
19262
  return params;
17787
19263
  if (inputText(params.input).trim()) return params;
17788
19264
  const messageId = params.clientUserMessageId;
17789
19265
  if (typeof messageId !== "string" || !messageId) return params;
17790
19266
  const coordinator = manager.getTurnCoordinator();
17791
- if (!isRecord4(coordinator) || typeof coordinator.readMessages !== "function") return params;
19267
+ if (!isRecord5(coordinator) || typeof coordinator.readMessages !== "function") return params;
17792
19268
  const messages = coordinator.readMessages.call(coordinator, params.threadId);
17793
19269
  if (!Array.isArray(messages)) return params;
17794
- const match = messages.find((message) => isRecord4(message) && message.id === messageId);
19270
+ const match = messages.find((message) => isRecord5(message) && message.id === messageId);
17795
19271
  const text = queuedFollowUpText(match);
17796
19272
  if (!text) return params;
17797
19273
  return { ...params, input: [{ type: "text", text, text_elements: [] }] };
17798
19274
  }
17799
19275
  function installExternalQueueUi(manager) {
17800
19276
  const coordinator = manager.getTurnCoordinator();
17801
- const options = isRecord4(coordinator) ? coordinator.options : null;
17802
- if (!isRecord4(options) || typeof options.getMessageQueueMode !== "function") return null;
19277
+ const options = isRecord5(coordinator) ? coordinator.options : null;
19278
+ if (!isRecord5(options) || typeof options.getMessageQueueMode !== "function") return null;
17803
19279
  const descriptor = Object.getOwnPropertyDescriptor(options, "getMessageQueueMode");
17804
19280
  if (!descriptor?.writable) return null;
17805
19281
  const original = options.getMessageQueueMode;
@@ -17819,9 +19295,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17819
19295
  }
17820
19296
  function submissionHost(manager) {
17821
19297
  const coordinator = manager.getTurnCoordinator();
17822
- const options = isRecord4(coordinator) ? coordinator.options : null;
17823
- const host = isRecord4(options) ? options.submissionHost : null;
17824
- if (!isRecord4(host) || typeof host.getActiveTurnId !== "function" || typeof host.hasPendingTurnStart !== "function") {
19298
+ const options = isRecord5(coordinator) ? coordinator.options : null;
19299
+ const host = isRecord5(options) ? options.submissionHost : null;
19300
+ if (!isRecord5(host) || typeof host.getActiveTurnId !== "function" || typeof host.hasPendingTurnStart !== "function") {
17825
19301
  throw new Error("Desktop turn submission binding is unavailable");
17826
19302
  }
17827
19303
  return {
@@ -17865,20 +19341,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17865
19341
  var INTERRUPTED_QUEUE_REASON = "Interrupted before the steer was accepted.";
17866
19342
  async function preserveQueuedFollowUps(manager, threadId) {
17867
19343
  const coordinator = manager.getTurnCoordinator();
17868
- if (!isRecord4(coordinator) || typeof coordinator.loadMessages !== "function" || typeof coordinator.readMessages !== "function" || typeof coordinator.mutate !== "function") {
19344
+ if (!isRecord5(coordinator) || typeof coordinator.loadMessages !== "function" || typeof coordinator.readMessages !== "function" || typeof coordinator.mutate !== "function") {
17869
19345
  throw new Error("Desktop follow-up queue binding is unavailable");
17870
19346
  }
17871
19347
  await coordinator.loadMessages.call(coordinator, threadId);
17872
19348
  const messages = coordinator.readMessages.call(coordinator, threadId);
17873
19349
  if (!Array.isArray(messages)) throw new Error("Desktop follow-up queue is unavailable");
17874
19350
  const alreadyPaused = new Set(
17875
- messages.filter((message) => isRecord4(message) && message.pausedReason != null).map((message) => message.id)
19351
+ messages.filter((message) => isRecord5(message) && message.pausedReason != null).map((message) => message.id)
17876
19352
  );
17877
19353
  return () => {
17878
19354
  coordinator.mutate.call(coordinator, threadId, (current) => {
17879
19355
  if (!Array.isArray(current)) return current;
17880
19356
  return current.map((message) => {
17881
- if (!isRecord4(message) || alreadyPaused.has(message.id) || message.pausedReason !== INTERRUPTED_QUEUE_REASON)
19357
+ if (!isRecord5(message) || alreadyPaused.has(message.id) || message.pausedReason !== INTERRUPTED_QUEUE_REASON)
17882
19358
  return message;
17883
19359
  const resumed = { ...message };
17884
19360
  delete resumed.pausedReason;
@@ -17904,16 +19380,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17904
19380
  if (method === "turn/start" || method === "turn/steer") {
17905
19381
  params = restoreQueuedTurnStartText(manager, params);
17906
19382
  }
17907
- const messageId = isRecord4(params) ? params.clientUserMessageId : null;
17908
- const route = typeof messageId === "string" && isRecord4(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
17909
- if (method !== "turn/start" || !isRecord4(params) || !route || route.threadId !== params.threadId) {
19383
+ const messageId = isRecord5(params) ? params.clientUserMessageId : null;
19384
+ const route = typeof messageId === "string" && isRecord5(params) ? routes.get(`${params.threadId}\0${messageId}`) : void 0;
19385
+ if (method !== "turn/start" || !isRecord5(params) || !route || route.threadId !== params.threadId) {
17910
19386
  if (method === "turn/start" && sendTurnStart) {
17911
19387
  return sendTurnStart(params, (input) => {
17912
19388
  if (disposed) throw new Error("External submission binding was disposed");
17913
19389
  return originalSend.call(manager, method, input, options);
17914
19390
  });
17915
19391
  }
17916
- if (method === "turn/steer" && isRecord4(params) && typeof params.threadId === "string" && activeTurnSteers.has(params.threadId)) {
19392
+ if (method === "turn/steer" && isRecord5(params) && typeof params.threadId === "string" && activeTurnSteers.has(params.threadId)) {
17917
19393
  params = { ...params, [THREAD_STEER_DELIVERY_PARAM]: "activeTurn" };
17918
19394
  }
17919
19395
  return originalSend.call(manager, method, params, options);
@@ -17936,7 +19412,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17936
19412
  options
17937
19413
  )
17938
19414
  ).then((response) => {
17939
- if (!isRecord4(response) || typeof response.turnId !== "string" || !response.turnId) {
19415
+ if (!isRecord5(response) || typeof response.turnId !== "string" || !response.turnId) {
17940
19416
  throw new Error("External steering returned no replacement Turn identity");
17941
19417
  }
17942
19418
  return {
@@ -17974,7 +19450,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17974
19450
  ] = args;
17975
19451
  if (typeof threadId !== "string") return originalSteer.apply(manager, args);
17976
19452
  const role = manager.getStreamRole?.(threadId);
17977
- if (isRecord4(role) && role.role === "follower") return originalSteer.apply(manager, args);
19453
+ if (isRecord5(role) && role.role === "follower") return originalSteer.apply(manager, args);
17978
19454
  let host = null;
17979
19455
  let expectedTurnId;
17980
19456
  try {
@@ -17998,21 +19474,21 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17998
19474
  }
17999
19475
  if (!host) throw new Error("Desktop turn submission binding is unavailable");
18000
19476
  const currentRole = manager.getStreamRole?.(threadId);
18001
- if (isRecord4(currentRole) && currentRole.role === "follower")
19477
+ if (isRecord5(currentRole) && currentRole.role === "follower")
18002
19478
  return originalSteer.apply(manager, args);
18003
19479
  if (!Array.isArray(input) || input.length === 0 || input.some((item) => {
18004
- if (!isRecord4(item)) return true;
19480
+ if (!isRecord5(item)) return true;
18005
19481
  if (item.type === "text") return typeof item.text !== "string";
18006
19482
  if (item.type === "localImage") return typeof item.path !== "string" || !item.path;
18007
19483
  if (item.type === "image") return typeof item.url !== "string" || !item.url;
18008
19484
  return true;
18009
19485
  }) || !input.some(
18010
- (item) => isRecord4(item) && (item.type !== "text" || typeof item.text === "string" && item.text.trim())
19486
+ (item) => isRecord5(item) && (item.type !== "text" || typeof item.text === "string" && item.text.trim())
18011
19487
  )) {
18012
19488
  throw new Error("External steering requires non-empty text or image input");
18013
19489
  }
18014
19490
  if (toolOutput != null) throw new Error("External steering cannot replace a tool response");
18015
- if (!isRecord4(restoreMessage) || !isRecord4(restoreMessage.context)) {
19491
+ if (!isRecord5(restoreMessage) || !isRecord5(restoreMessage.context)) {
18016
19492
  throw new Error("Desktop steering message context is unavailable");
18017
19493
  }
18018
19494
  const messageId = typeof clientUserMessageId === "string" && clientUserMessageId ? clientUserMessageId : typeof restoreMessage.id === "string" && restoreMessage.id ? restoreMessage.id : crypto.randomUUID();
@@ -18062,7 +19538,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18062
19538
  },
18063
19539
  onMessageAdded
18064
19540
  );
18065
- if (!isRecord4(response) || !isRecord4(response.turn) || typeof response.turn.id !== "string") {
19541
+ if (!isRecord5(response) || !isRecord5(response.turn) || typeof response.turn.id !== "string") {
18066
19542
  throw new Error("Desktop returned no replacement Turn identity");
18067
19543
  }
18068
19544
  try {
@@ -18084,7 +19560,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18084
19560
  const threadId = args[0];
18085
19561
  if (typeof threadId === "string" && typeof manager.getConversation === "function") {
18086
19562
  const conversation = manager.getConversation(threadId);
18087
- if (isRecord4(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost") {
19563
+ if (isRecord5(conversation) && conversation.id === threadId && conversation.modelProvider === "codexhost") {
18088
19564
  return externalOwnerRole;
18089
19565
  }
18090
19566
  }
@@ -18111,7 +19587,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18111
19587
  }
18112
19588
 
18113
19589
  // src/renderer-overlay-thread-isolation.ts
18114
- function isRecord5(value) {
19590
+ function isRecord6(value) {
18115
19591
  return value !== null && typeof value === "object" && !Array.isArray(value);
18116
19592
  }
18117
19593
  var BLOCKED_METHODS = /* @__PURE__ */ new Set(["thread/started"]);
@@ -18135,10 +19611,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18135
19611
  return method.startsWith("turn/") || method.startsWith("item/");
18136
19612
  }
18137
19613
  function notificationThreadId2(params) {
18138
- if (!isRecord5(params)) return void 0;
19614
+ if (!isRecord6(params)) return void 0;
18139
19615
  if (typeof params.threadId === "string" && params.threadId.length > 0) return params.threadId;
18140
19616
  const thread2 = params.thread;
18141
- if (isRecord5(thread2) && typeof thread2.id === "string" && thread2.id.length > 0) {
19617
+ if (isRecord6(thread2) && typeof thread2.id === "string" && thread2.id.length > 0) {
18142
19618
  return thread2.id;
18143
19619
  }
18144
19620
  return void 0;
@@ -18156,7 +19632,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18156
19632
  const voiceThreadIds = /* @__PURE__ */ new Set();
18157
19633
  const listener = (event) => {
18158
19634
  const message = event.data;
18159
- if (!isRecord5(message) || message.type !== "mcp-notification") return;
19635
+ if (!isRecord6(message) || message.type !== "mcp-notification") return;
18160
19636
  if (typeof message.method !== "string") return;
18161
19637
  const threadId = notificationThreadId2(message.params);
18162
19638
  if (message.method === "thread/realtime/started" && threadId) {
@@ -18181,17 +19657,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18181
19657
  var DISCOVERY_MS = 6e4;
18182
19658
  var INTERVAL_MS = 50;
18183
19659
  var HOOK_WALK_LIMIT = 120;
18184
- function isRecord6(value) {
19660
+ function isRecord7(value) {
18185
19661
  return value !== null && typeof value === "object" && !Array.isArray(value);
18186
19662
  }
18187
19663
  function isFollowUpManager(value) {
18188
- return isRecord6(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator", "getConversation"].every(
19664
+ return isRecord7(value) && ["sendRequest", "steerTurn", "startTurn", "getTurnCoordinator", "getConversation"].every(
18189
19665
  (key) => typeof value[key] === "function"
18190
19666
  );
18191
19667
  }
18192
19668
  function managerFromHookState(value) {
18193
19669
  if (isFollowUpManager(value)) return value;
18194
- return isRecord6(value) && isFollowUpManager(value.manager) ? value.manager : null;
19670
+ return isRecord7(value) && isFollowUpManager(value.manager) ? value.manager : null;
18195
19671
  }
18196
19672
  function overlayFollowUpManagers(document) {
18197
19673
  const managers = /* @__PURE__ */ new Set();
@@ -18269,7 +19745,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18269
19745
  var VOICE_REGION_SELECTOR = '[data-avatar-overlay-hit-region="realtime-voice"]';
18270
19746
  var HIDE_SELECTOR = `${MASCOT_SELECTOR}, ${TRANSCRIPT_SELECTOR}, ${QUICK_CHAT_ORB_SELECTOR}`;
18271
19747
  var OVERLAY_VOICE_MIN_EDGE = 40;
18272
- function isRecord7(value) {
19748
+ function isRecord8(value) {
18273
19749
  return value !== null && typeof value === "object" && !Array.isArray(value);
18274
19750
  }
18275
19751
  function overlayOwnsVoiceControls(document) {
@@ -18322,7 +19798,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18322
19798
  };
18323
19799
  const listener = (event) => {
18324
19800
  const message = event.data;
18325
- if (!isRecord7(message) || message.type !== "mcp-notification") return;
19801
+ if (!isRecord8(message) || message.type !== "mcp-notification") return;
18326
19802
  if (typeof message.method !== "string") return;
18327
19803
  const threadId = notificationThreadId2(message.params);
18328
19804
  if (!threadId) return;
@@ -18421,7 +19897,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18421
19897
  }
18422
19898
  return hook == null ? result : [];
18423
19899
  }
18424
- function bindVoiceCapabilitySubscriptions(currentFibers, family, gates, allowed, realtimeOnly = false, names = ["voice.realtime", "voice.thread"]) {
19900
+ function bindVoiceCapabilitySubscriptions(currentFibers, family, gates, allowed, realtimeOnly = false, names = ["voice.realtime", "voice.thread"], project2) {
18425
19901
  const fibers = currentFibers();
18426
19902
  const restores = [];
18427
19903
  const bindings = [];
@@ -18457,12 +19933,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18457
19933
  subscriber.getSnapshot()
18458
19934
  ) || !equal(subscriber.getSnapshot(), instance.getSnapshot()) || subscriber.createRender?.() != null)
18459
19935
  throw new Error("Unsupported voice subscription");
18460
- for (const [object3, key] of [
19936
+ for (const [object5, key] of [
18461
19937
  [store, "sub"],
18462
19938
  [subscriber, "getSnapshot"],
18463
19939
  [instance, "getSnapshot"]
18464
19940
  ])
18465
- if (Object.getOwnPropertyDescriptor(object3, key)?.writable !== true)
19941
+ if (Object.getOwnPropertyDescriptor(object5, key)?.writable !== true)
18466
19942
  throw new Error("Voice subscription is not writable");
18467
19943
  let notify;
18468
19944
  const sub = store.sub;
@@ -18484,7 +19960,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18484
19960
  const snapshot = () => {
18485
19961
  const native = original.call(subscriber);
18486
19962
  if (!allowed()) return native;
18487
- const projected = replayVoiceCapability(store, signal.atom, gate);
19963
+ const projected = project2 ? project2({
19964
+ native,
19965
+ store,
19966
+ atom: signal.atom,
19967
+ gate,
19968
+ node,
19969
+ chain
19970
+ }) : replayVoiceCapability(store, signal.atom, gate);
18488
19971
  if (!projected || !projected.isCapable) return native;
18489
19972
  if (!previous || !equal(previous, projected)) previous = projected;
18490
19973
  return previous;
@@ -18554,13 +20037,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18554
20037
  const mode = request.activeCollaborationMode;
18555
20038
  const settings = record4(mode) ? mode.settings : void 0;
18556
20039
  const model2 = record4(settings) ? settings.model : void 0;
18557
- return workGateway || externalHarness || typeof model2 === "string" && model2.startsWith("codexhost/");
20040
+ if (typeof model2 === "string" && model2.startsWith("codexhost/")) return externalHarness;
20041
+ return workGateway || externalHarness;
18558
20042
  }
18559
20043
  function wrapGatewayVoiceStarter(start, options) {
18560
20044
  let active;
18561
20045
  return {
18562
20046
  async start(...args) {
18563
- if (!options.qualifies(args[0])) return start(...args);
20047
+ const request = args[0];
20048
+ const qualified = options.qualifies(request);
20049
+ const wantsGateway = options.configured?.(request) ?? qualified;
20050
+ if (!wantsGateway) return start(...args);
20051
+ if (!qualified) {
20052
+ throw new Error(
20053
+ options.unavailable?.(request) ?? "Work voice is not qualified on this Desktop."
20054
+ );
20055
+ }
18564
20056
  if (active) throw new Error("Voice gateway start is already pending");
18565
20057
  const attempt = {};
18566
20058
  active = attempt;
@@ -18653,12 +20145,30 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18653
20145
  if (typeof start !== "function" || typeof cancel !== "function")
18654
20146
  throw new Error("Voice starter callback unavailable");
18655
20147
  const wrapper = wrapGatewayVoiceStarter(start, {
20148
+ configured: (request) => {
20149
+ const mode = record4(request) ? request.activeCollaborationMode : void 0;
20150
+ const settings = record4(mode) ? mode.settings : void 0;
20151
+ const model2 = record4(settings) ? settings.model : void 0;
20152
+ return gatewayVoiceStartRequest(
20153
+ request,
20154
+ cpaLiveVoicePreferenceAllowsInstall(target2),
20155
+ chatLiveVoicePreferenceAllowsOverride(target2),
20156
+ typeof model2 === "string" && model2.startsWith("codexhost/")
20157
+ );
20158
+ },
18656
20159
  qualifies: (request) => !disposed && !!readCpaLiveVoiceHookConfig(target2) && gatewayVoiceStartRequest(
18657
20160
  request,
18658
- cpaLiveVoicePreferenceAllowsInstall(target2),
20161
+ cpaLiveVoicePreferenceAllowsInstall(target2) && workVoiceLaneEnabled(target2, "work-codex"),
18659
20162
  chatLiveVoicePreferenceAllowsOverride(target2),
18660
- isExternalHarnessComposer(target2)
20163
+ workVoiceLaneEnabled(target2, "work-grok")
18661
20164
  ),
20165
+ unavailable: (request) => {
20166
+ const mode = record4(request) ? request.activeCollaborationMode : void 0;
20167
+ const settings = record4(mode) ? mode.settings : void 0;
20168
+ const model2 = record4(settings) ? settings.model : void 0;
20169
+ const path = typeof model2 === "string" && model2.startsWith("codexhost/") ? "work-grok" : "work-codex";
20170
+ return workVoiceUserFacingUnavailable(target2, path);
20171
+ },
18662
20172
  ready: async () => {
18663
20173
  const hook = target2.__codexhostClientOwnedVoiceV1;
18664
20174
  if (!record4(hook) || hook.status !== "active") return false;