@karlorz/codexhost-cli-win32-arm64 0.13.3-4 → 0.13.3-6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // packages/desktop-control/src/production-controller.ts
8
8
  import { readFile } from "node:fs/promises";
9
- import path2 from "node:path";
9
+ import path3 from "node:path";
10
10
 
11
11
  // packages/desktop-control/src/renderer-local-page.ts
12
12
  import { randomUUID } from "node:crypto";
@@ -1045,10 +1045,10 @@ function mergeDefs(...defs) {
1045
1045
  function cloneDef(schema) {
1046
1046
  return mergeDefs(schema._zod.def);
1047
1047
  }
1048
- function getElementAtPath(obj, path3) {
1049
- if (!path3)
1048
+ function getElementAtPath(obj, path4) {
1049
+ if (!path4)
1050
1050
  return obj;
1051
- return path3.reduce((acc, key) => acc?.[key], obj);
1051
+ return path4.reduce((acc, key) => acc?.[key], obj);
1052
1052
  }
1053
1053
  function promiseAllObject(promisesObj) {
1054
1054
  const keys = Object.keys(promisesObj);
@@ -1457,11 +1457,11 @@ function explicitlyAborted(x, startIndex = 0) {
1457
1457
  }
1458
1458
  return false;
1459
1459
  }
1460
- function prefixIssues(path3, issues) {
1460
+ function prefixIssues(path4, issues) {
1461
1461
  return issues.map((iss) => {
1462
1462
  var _a3;
1463
1463
  (_a3 = iss).path ?? (_a3.path = []);
1464
- iss.path.unshift(path3);
1464
+ iss.path.unshift(path4);
1465
1465
  return iss;
1466
1466
  });
1467
1467
  }
@@ -1608,16 +1608,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
1608
1608
  }
1609
1609
  function formatError(error51, mapper = (issue2) => issue2.message) {
1610
1610
  const fieldErrors = { _errors: [] };
1611
- const processError = (error52, path3 = []) => {
1611
+ const processError = (error52, path4 = []) => {
1612
1612
  for (const issue2 of error52.issues) {
1613
1613
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1614
- issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
1614
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
1615
1615
  } else if (issue2.code === "invalid_key") {
1616
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
1616
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
1617
1617
  } else if (issue2.code === "invalid_element") {
1618
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
1618
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
1619
1619
  } else {
1620
- const fullpath = [...path3, ...issue2.path];
1620
+ const fullpath = [...path4, ...issue2.path];
1621
1621
  if (fullpath.length === 0) {
1622
1622
  fieldErrors._errors.push(mapper(issue2));
1623
1623
  } else {
@@ -1644,17 +1644,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
1644
1644
  }
1645
1645
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
1646
1646
  const result = { errors: [] };
1647
- const processError = (error52, path3 = []) => {
1647
+ const processError = (error52, path4 = []) => {
1648
1648
  var _a3, _b;
1649
1649
  for (const issue2 of error52.issues) {
1650
1650
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1651
- issue2.errors.map((issues) => processError({ issues }, [...path3, ...issue2.path]));
1651
+ issue2.errors.map((issues) => processError({ issues }, [...path4, ...issue2.path]));
1652
1652
  } else if (issue2.code === "invalid_key") {
1653
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
1653
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
1654
1654
  } else if (issue2.code === "invalid_element") {
1655
- processError({ issues: issue2.issues }, [...path3, ...issue2.path]);
1655
+ processError({ issues: issue2.issues }, [...path4, ...issue2.path]);
1656
1656
  } else {
1657
- const fullpath = [...path3, ...issue2.path];
1657
+ const fullpath = [...path4, ...issue2.path];
1658
1658
  if (fullpath.length === 0) {
1659
1659
  result.errors.push(mapper(issue2));
1660
1660
  continue;
@@ -1686,8 +1686,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
1686
1686
  }
1687
1687
  function toDotPath(_path) {
1688
1688
  const segs = [];
1689
- const path3 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1690
- for (const seg of path3) {
1689
+ const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
1690
+ for (const seg of path4) {
1691
1691
  if (typeof seg === "number")
1692
1692
  segs.push(`[${seg}]`);
1693
1693
  else if (typeof seg === "symbol")
@@ -14379,13 +14379,13 @@ function resolveRef(ref, ctx) {
14379
14379
  if (!ref.startsWith("#")) {
14380
14380
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14381
14381
  }
14382
- const path3 = ref.slice(1).split("/").filter(Boolean);
14383
- if (path3.length === 0) {
14382
+ const path4 = ref.slice(1).split("/").filter(Boolean);
14383
+ if (path4.length === 0) {
14384
14384
  return ctx.rootSchema;
14385
14385
  }
14386
14386
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14387
- if (path3[0] === defsKey) {
14388
- const key = path3[1];
14387
+ if (path4[0] === defsKey) {
14388
+ const key = path4[1];
14389
14389
  if (!key || !ctx.defs[key]) {
14390
14390
  throw new Error(`Reference not found: ${ref}`);
14391
14391
  }
@@ -15050,6 +15050,36 @@ var hostInteractionIdSchema = opaqueIdSchema.brand();
15050
15050
  var threadPrewarmDiscardParamsSchema = external_exports.object({ threadId: hostThreadIdSchema });
15051
15051
  var threadPrewarmDiscardResultSchema = external_exports.object({ discarded: external_exports.boolean() });
15052
15052
 
15053
+ // packages/shared-contracts/dist/realtime-call.js
15054
+ var REALTIME_CALL_FORWARDED_HEADERS = [
15055
+ "openai-alpha",
15056
+ "thread-id",
15057
+ "session-id",
15058
+ "originator",
15059
+ "x-codex-turn-metadata"
15060
+ ];
15061
+ var FORWARDED_HEADERS = new Set(REALTIME_CALL_FORWARDED_HEADERS);
15062
+ var REALTIME_CALL_ID_PATTERN = /^rtc_[A-Za-z0-9_-]{1,128}$/u;
15063
+ var requestId = external_exports.string().min(1).max(128);
15064
+ var realtimeCallParamsSchema = external_exports.discriminatedUnion("operation", [
15065
+ external_exports.object({
15066
+ operation: external_exports.literal("create"),
15067
+ requestId,
15068
+ body: external_exports.string().min(1).max(16 << 20),
15069
+ headers: external_exports.record(external_exports.string(), external_exports.string()).default({})
15070
+ }),
15071
+ external_exports.object({ operation: external_exports.literal("cancel"), requestId }),
15072
+ external_exports.object({
15073
+ operation: external_exports.literal("hangup"),
15074
+ callId: external_exports.string().regex(REALTIME_CALL_ID_PATTERN)
15075
+ })
15076
+ ]);
15077
+ var realtimeCallResponseSchema = external_exports.object({
15078
+ status: external_exports.number().int().min(200).max(599),
15079
+ body: external_exports.string(),
15080
+ headers: external_exports.record(external_exports.string(), external_exports.string())
15081
+ });
15082
+
15053
15083
  // packages/shared-contracts/dist/console.js
15054
15084
  var consoleAnnouncementSchema = external_exports.strictObject({
15055
15085
  title: external_exports.string().trim().min(1).max(200),
@@ -15062,6 +15092,7 @@ var consoleOpenResultSchema = external_exports.strictObject({
15062
15092
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15063
15093
  });
15064
15094
  var CONSOLE_HOST_METHODS = Object.freeze([
15095
+ "codexhost/voice/gateway-status",
15065
15096
  "codexhost/console/remote-connections",
15066
15097
  "codexhost/runtime/status",
15067
15098
  "codexhost/remote/ssh-setup",
@@ -16166,6 +16197,52 @@ var remoteConnectionsReplySchema = external_exports.union([
16166
16197
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16167
16198
  ]);
16168
16199
 
16200
+ // packages/shared-contracts/dist/voice-settings.js
16201
+ var voiceRoutesSchema = external_exports.strictObject({
16202
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
16203
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
16204
+ workConnection: external_exports.enum(["desktop", "gateway"])
16205
+ });
16206
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
16207
+ chatExperience: "chatgpt",
16208
+ chatConnection: "desktop",
16209
+ workConnection: "gateway"
16210
+ });
16211
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
16212
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
16213
+ external_exports.strictObject({
16214
+ operation: external_exports.literal("get"),
16215
+ runtime: external_exports.strictObject({
16216
+ id: external_exports.string().uuid(),
16217
+ revision: external_exports.string().max(64),
16218
+ activeCall: external_exports.boolean()
16219
+ }).optional()
16220
+ }),
16221
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
16222
+ external_exports.strictObject({
16223
+ operation: external_exports.literal("set"),
16224
+ settings: voiceSettingsSchema,
16225
+ revision: external_exports.string().max(64)
16226
+ }),
16227
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
16228
+ ]);
16229
+ var voiceSettingsStateSchema = external_exports.strictObject({
16230
+ settings: voiceSettingsSchema,
16231
+ initialized: external_exports.boolean(),
16232
+ revision: external_exports.string(),
16233
+ activeInject: external_exports.boolean().nullable(),
16234
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
16235
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
16236
+ routesActive: external_exports.boolean().nullable(),
16237
+ activeCall: external_exports.boolean().nullable(),
16238
+ gatewayReady: external_exports.boolean().nullable(),
16239
+ restartAvailable: external_exports.boolean(),
16240
+ restart: external_exports.strictObject({
16241
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
16242
+ error: external_exports.string().nullable()
16243
+ })
16244
+ });
16245
+
16169
16246
  // packages/shared-contracts/dist/index.js
16170
16247
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16171
16248
 
@@ -16349,6 +16426,10 @@ async function startControllerAttachmentServer(options) {
16349
16426
  void completion.finally(() => pages.delete(completion));
16350
16427
  return;
16351
16428
  }
16429
+ if (options.stop && line === `STOP ${options.nonce}` && request.slice(newline + 1) === "") {
16430
+ socket.end("stopping\n", () => options.stop?.());
16431
+ return;
16432
+ }
16352
16433
  if (line === `ATTACH ${options.nonce}`) {
16353
16434
  if (attachment) {
16354
16435
  respond(socket, "busy");
@@ -16482,13 +16563,33 @@ function createControllerStatusPublisher(filePath = defaultControllerStatusPath(
16482
16563
  };
16483
16564
  }
16484
16565
 
16566
+ // packages/desktop-control/src/live-voice-inject.ts
16567
+ import { readFileSync } from "node:fs";
16568
+ import os2 from "node:os";
16569
+ import path2 from "node:path";
16570
+ var LIVE_VOICE_INJECT_FILE = "live-voice-inject-v1.json";
16571
+ function readLiveVoiceInjectFile(environment = process.env) {
16572
+ const directory = environment.CODEXHOST_DATA_DIR ? path2.resolve(environment.CODEXHOST_DATA_DIR) : path2.join(os2.homedir(), ".codexhost");
16573
+ try {
16574
+ const parsed = JSON.parse(
16575
+ readFileSync(path2.join(directory, LIVE_VOICE_INJECT_FILE), "utf8")
16576
+ );
16577
+ return parsed.version !== 1 || parsed.inject !== false;
16578
+ } catch {
16579
+ return true;
16580
+ }
16581
+ }
16582
+
16485
16583
  // packages/desktop-control/src/cpa-live-voice-hook.ts
16486
16584
  var CPA_LIVE_VOICE_ENV = "CODEXHOST_CPA_LIVE_VOICE";
16487
16585
  var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
16488
16586
  var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
16489
16587
  var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
16490
16588
  function cpaLiveVoiceHookEnabled(environment = process.env) {
16491
- return environment[CPA_LIVE_VOICE_ENV] !== "0";
16589
+ const value = environment[CPA_LIVE_VOICE_ENV];
16590
+ if (value === "0") return false;
16591
+ if (value === "1") return true;
16592
+ return readLiveVoiceInjectFile(environment);
16492
16593
  }
16493
16594
  function cpaLiveVoiceHookBootstrap(environment = process.env) {
16494
16595
  if (!cpaLiveVoiceHookEnabled(environment)) return "";
@@ -16529,13 +16630,13 @@ function committedReactAncestors(value) {
16529
16630
  const current = fiber(rootState.current);
16530
16631
  if (!current) return [];
16531
16632
  const alternate = fiber(first.alternate);
16532
- const path3 = [current];
16633
+ const path4 = [current];
16533
16634
  seen.clear();
16534
16635
  seen.add(current);
16535
16636
  for (let index = previous.length - 2; index >= 0; index -= 1) {
16536
16637
  const expected = previous[index];
16537
16638
  const expectedAlternate = fiber(expected?.alternate);
16538
- let child = fiber(path3.at(-1)?.child);
16639
+ let child = fiber(path4.at(-1)?.child);
16539
16640
  let matched = false;
16540
16641
  while (child && !seen.has(child) && seen.size < MAX_VISITED_FIBERS) {
16541
16642
  seen.add(child);
@@ -16546,10 +16647,10 @@ function committedReactAncestors(value) {
16546
16647
  child = fiber(child.sibling);
16547
16648
  }
16548
16649
  if (!matched || !child) break;
16549
- path3.push(child);
16650
+ path4.push(child);
16550
16651
  }
16551
- if (path3.length === previous.length && (path3.at(-1) === first || path3.at(-1) === alternate)) {
16552
- return path3.reverse();
16652
+ if (path4.length === previous.length && (path4.at(-1) === first || path4.at(-1) === alternate)) {
16653
+ return path4.reverse();
16553
16654
  }
16554
16655
  const stack = [{ node: current, parent: null }];
16555
16656
  seen.clear();
@@ -16705,7 +16806,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
16705
16806
  bridgeReadyReject?.(error51);
16706
16807
  bridgeReadyReject = null;
16707
16808
  bridgeReadyResolve = null;
16708
- for (const requestId of bridgeRequests.keys()) bridge.onError(requestId, error51);
16809
+ for (const requestId2 of bridgeRequests.keys()) bridge.onError(requestId2, error51);
16709
16810
  bridgeRequests.clear();
16710
16811
  if (isRemoteControlHost && terminate) {
16711
16812
  void Promise.resolve(
@@ -17186,7 +17287,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
17186
17287
  bridgeState = "disposed";
17187
17288
  const disposedError = transportError("was disposed");
17188
17289
  bridgeReadyReject?.(disposedError);
17189
- for (const requestId of bridgeRequests.keys()) bridge.onError(requestId, disposedError);
17290
+ for (const requestId2 of bridgeRequests.keys()) bridge.onError(requestId2, disposedError);
17190
17291
  bridgeRequests.clear();
17191
17292
  bridgeServerRequests.clear();
17192
17293
  knownExternalThreadIds.clear();
@@ -17891,8 +17992,8 @@ function parseDesktopControllerArguments(arguments_) {
17891
17992
  if (argument === "--renderer") {
17892
17993
  if (rendererPath !== void 0) throw new Error("--renderer may only be provided once");
17893
17994
  if (!value) throw new Error("--renderer requires a value");
17894
- if (!path2.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
17895
- rendererPath = path2.normalize(value);
17995
+ if (!path3.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
17996
+ rendererPath = path3.normalize(value);
17896
17997
  index += 1;
17897
17998
  continue;
17898
17999
  }
@@ -17962,8 +18063,13 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
17962
18063
  let session;
17963
18064
  let nextRecoveryAt = 0;
17964
18065
  let recoveryDelayMs = RECOVERY_RETRY_INITIAL_MS;
18066
+ const bootstrap = cpaLiveVoiceHookBootstrap();
17965
18067
  const status = createRendererStatusReporter(
17966
- (document) => dependencies.publishStatus?.(document),
18068
+ (document) => dependencies.publishStatus?.({
18069
+ ...document,
18070
+ voiceInjection: Boolean(bootstrap),
18071
+ voiceEnvOverride: process.env.CODEXHOST_CPA_LIVE_VOICE === "0" || process.env.CODEXHOST_CPA_LIVE_VOICE === "1" ? process.env.CODEXHOST_CPA_LIVE_VOICE : null
18072
+ }),
17967
18073
  now
17968
18074
  );
17969
18075
  const recordRecoveryFailure = (error51) => {
@@ -17980,11 +18086,11 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
17980
18086
  status.installing();
17981
18087
  startupTrace("reading Renderer bundle");
17982
18088
  const rendererRead = dependencies.readRenderer(options.rendererPath);
17983
- const bootstrap = cpaLiveVoiceHookBootstrap();
17984
- const overlayPath = bootstrap ? path2.join(path2.dirname(options.rendererPath), "cpa-live-voice-hook.js") : void 0;
18089
+ const overlayPath = bootstrap ? path3.join(path3.dirname(options.rendererPath), "cpa-live-voice-hook.js") : void 0;
17985
18090
  const [rendererSource, overlayBundle] = overlayPath ? await Promise.all([rendererRead, dependencies.readRenderer(overlayPath)]) : [await rendererRead, void 0];
17986
18091
  if (rendererSource.trim().length === 0) throw new Error("production Renderer Bundle is empty");
17987
- const overlayHookSource = bootstrap && overlayBundle && overlayBundle.trim().length > 0 ? `${bootstrap}${overlayBundle}` : void 0;
18092
+ const overlayHookSource = bootstrap && overlayBundle && overlayBundle.trim().length > 0 ? `${RENDERER_CSP_BOOTSTRAP}
18093
+ ${bootstrap}${overlayBundle}` : void 0;
17988
18094
  startupTrace("installing Renderer Session");
17989
18095
  const installed = await installProductionSession(
17990
18096
  {
@@ -18037,6 +18143,7 @@ ${bootstrap}${rendererSource}`,
18037
18143
  attachmentServer = await dependencies.startAttachmentServer({
18038
18144
  port: options.attachmentPort,
18039
18145
  nonce: options.attachmentNonce,
18146
+ ...options.requestStop ? { stop: options.requestStop } : {},
18040
18147
  remoteConnections: async (request) => {
18041
18148
  const current = await useSession(() => recoverSession());
18042
18149
  return remoteConnectionsReplySchema.parse(
@@ -18095,7 +18202,10 @@ var stop = () => abort.abort();
18095
18202
  process.once("SIGINT", stop);
18096
18203
  process.once("SIGTERM", stop);
18097
18204
  try {
18098
- await runDesktopController(parseDesktopControllerArguments(process.argv.slice(2)), abort.signal);
18205
+ await runDesktopController(
18206
+ { ...parseDesktopControllerArguments(process.argv.slice(2)), requestStop: stop },
18207
+ abort.signal
18208
+ );
18099
18209
  } catch (error51) {
18100
18210
  console.error(
18101
18211
  `codexhost Desktop Controller: ${error51 instanceof Error ? error51.message : String(error51)}`