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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,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
  }
@@ -15092,6 +15092,7 @@ var consoleOpenResultSchema = external_exports.strictObject({
15092
15092
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15093
15093
  });
15094
15094
  var CONSOLE_HOST_METHODS = Object.freeze([
15095
+ "codexhost/voice/gateway-status",
15095
15096
  "codexhost/console/remote-connections",
15096
15097
  "codexhost/runtime/status",
15097
15098
  "codexhost/remote/ssh-setup",
@@ -16196,6 +16197,52 @@ var remoteConnectionsReplySchema = external_exports.union([
16196
16197
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16197
16198
  ]);
16198
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
+
16199
16246
  // packages/shared-contracts/dist/index.js
16200
16247
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16201
16248
 
@@ -16379,6 +16426,10 @@ async function startControllerAttachmentServer(options) {
16379
16426
  void completion.finally(() => pages.delete(completion));
16380
16427
  return;
16381
16428
  }
16429
+ if (options.stop && line === `STOP ${options.nonce}` && request.slice(newline + 1) === "") {
16430
+ socket.end("stopping\n", () => options.stop?.());
16431
+ return;
16432
+ }
16382
16433
  if (line === `ATTACH ${options.nonce}`) {
16383
16434
  if (attachment) {
16384
16435
  respond(socket, "busy");
@@ -16512,13 +16563,33 @@ function createControllerStatusPublisher(filePath = defaultControllerStatusPath(
16512
16563
  };
16513
16564
  }
16514
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
+
16515
16583
  // packages/desktop-control/src/cpa-live-voice-hook.ts
16516
16584
  var CPA_LIVE_VOICE_ENV = "CODEXHOST_CPA_LIVE_VOICE";
16517
16585
  var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
16518
16586
  var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
16519
16587
  var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
16520
16588
  function cpaLiveVoiceHookEnabled(environment = process.env) {
16521
- 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);
16522
16593
  }
16523
16594
  function cpaLiveVoiceHookBootstrap(environment = process.env) {
16524
16595
  if (!cpaLiveVoiceHookEnabled(environment)) return "";
@@ -16559,13 +16630,13 @@ function committedReactAncestors(value) {
16559
16630
  const current = fiber(rootState.current);
16560
16631
  if (!current) return [];
16561
16632
  const alternate = fiber(first.alternate);
16562
- const path3 = [current];
16633
+ const path4 = [current];
16563
16634
  seen.clear();
16564
16635
  seen.add(current);
16565
16636
  for (let index = previous.length - 2; index >= 0; index -= 1) {
16566
16637
  const expected = previous[index];
16567
16638
  const expectedAlternate = fiber(expected?.alternate);
16568
- let child = fiber(path3.at(-1)?.child);
16639
+ let child = fiber(path4.at(-1)?.child);
16569
16640
  let matched = false;
16570
16641
  while (child && !seen.has(child) && seen.size < MAX_VISITED_FIBERS) {
16571
16642
  seen.add(child);
@@ -16576,10 +16647,10 @@ function committedReactAncestors(value) {
16576
16647
  child = fiber(child.sibling);
16577
16648
  }
16578
16649
  if (!matched || !child) break;
16579
- path3.push(child);
16650
+ path4.push(child);
16580
16651
  }
16581
- if (path3.length === previous.length && (path3.at(-1) === first || path3.at(-1) === alternate)) {
16582
- return path3.reverse();
16652
+ if (path4.length === previous.length && (path4.at(-1) === first || path4.at(-1) === alternate)) {
16653
+ return path4.reverse();
16583
16654
  }
16584
16655
  const stack = [{ node: current, parent: null }];
16585
16656
  seen.clear();
@@ -17921,8 +17992,8 @@ function parseDesktopControllerArguments(arguments_) {
17921
17992
  if (argument === "--renderer") {
17922
17993
  if (rendererPath !== void 0) throw new Error("--renderer may only be provided once");
17923
17994
  if (!value) throw new Error("--renderer requires a value");
17924
- if (!path2.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
17925
- rendererPath = path2.normalize(value);
17995
+ if (!path3.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
17996
+ rendererPath = path3.normalize(value);
17926
17997
  index += 1;
17927
17998
  continue;
17928
17999
  }
@@ -17992,8 +18063,13 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
17992
18063
  let session;
17993
18064
  let nextRecoveryAt = 0;
17994
18065
  let recoveryDelayMs = RECOVERY_RETRY_INITIAL_MS;
18066
+ const bootstrap = cpaLiveVoiceHookBootstrap();
17995
18067
  const status = createRendererStatusReporter(
17996
- (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
+ }),
17997
18073
  now
17998
18074
  );
17999
18075
  const recordRecoveryFailure = (error51) => {
@@ -18010,8 +18086,7 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
18010
18086
  status.installing();
18011
18087
  startupTrace("reading Renderer bundle");
18012
18088
  const rendererRead = dependencies.readRenderer(options.rendererPath);
18013
- const bootstrap = cpaLiveVoiceHookBootstrap();
18014
- 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;
18015
18090
  const [rendererSource, overlayBundle] = overlayPath ? await Promise.all([rendererRead, dependencies.readRenderer(overlayPath)]) : [await rendererRead, void 0];
18016
18091
  if (rendererSource.trim().length === 0) throw new Error("production Renderer Bundle is empty");
18017
18092
  const overlayHookSource = bootstrap && overlayBundle && overlayBundle.trim().length > 0 ? `${RENDERER_CSP_BOOTSTRAP}
@@ -18068,6 +18143,7 @@ ${bootstrap}${rendererSource}`,
18068
18143
  attachmentServer = await dependencies.startAttachmentServer({
18069
18144
  port: options.attachmentPort,
18070
18145
  nonce: options.attachmentNonce,
18146
+ ...options.requestStop ? { stop: options.requestStop } : {},
18071
18147
  remoteConnections: async (request) => {
18072
18148
  const current = await useSession(() => recoverSession());
18073
18149
  return remoteConnectionsReplySchema.parse(
@@ -18126,7 +18202,10 @@ var stop = () => abort.abort();
18126
18202
  process.once("SIGINT", stop);
18127
18203
  process.once("SIGTERM", stop);
18128
18204
  try {
18129
- await runDesktopController(parseDesktopControllerArguments(process.argv.slice(2)), abort.signal);
18205
+ await runDesktopController(
18206
+ { ...parseDesktopControllerArguments(process.argv.slice(2)), requestStop: stop },
18207
+ abort.signal
18208
+ );
18130
18209
  } catch (error51) {
18131
18210
  console.error(
18132
18211
  `codexhost Desktop Controller: ${error51 instanceof Error ? error51.message : String(error51)}`