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

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",
@@ -15102,6 +15103,8 @@ var CONSOLE_HOST_METHODS = Object.freeze([
15102
15103
  "codexhost/harness/installation",
15103
15104
  "codexhost/harness/launch-settings/get",
15104
15105
  "codexhost/harness/launch-settings/set",
15106
+ "codexhost/harness/grok-computer-use/get",
15107
+ "codexhost/harness/grok-computer-use/set",
15105
15108
  "codexhost/harness/web-ui/open",
15106
15109
  "codexhost/harness/accounts/sources",
15107
15110
  "codexhost/harness/accounts/list",
@@ -15630,7 +15633,9 @@ var harnessInspectionSchema = external_exports.union([
15630
15633
  var harnessInspectParamsSchema = external_exports.object({
15631
15634
  harnessId: harnessIdSchema,
15632
15635
  cwd: nonBlankTextSchema2.max(16384).optional(),
15633
- refresh: external_exports.boolean().optional()
15636
+ refresh: external_exports.boolean().optional(),
15637
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15638
+ purpose: external_exports.literal("availability").optional()
15634
15639
  }).strict();
15635
15640
  var harnessWebUiOpenParamsSchema = external_exports.object({
15636
15641
  harnessId: harnessIdSchema
@@ -15804,6 +15809,26 @@ var harnessLaunchSettingsSchema = external_exports.object({
15804
15809
  restartRequired: external_exports.boolean()
15805
15810
  }).strict();
15806
15811
 
15812
+ // packages/shared-contracts/dist/grok-computer-use.js
15813
+ var grokComputerUseGetSchema = external_exports.object({}).strict();
15814
+ var grokComputerUseSetSchema = external_exports.object({
15815
+ enabled: external_exports.boolean().optional(),
15816
+ browser: external_exports.boolean().optional()
15817
+ }).strict().refine((value) => value.enabled !== void 0 || value.browser !== void 0, {
15818
+ message: "Expected enabled or browser"
15819
+ });
15820
+ var grokComputerUseSettingsSchema = external_exports.object({
15821
+ enabled: external_exports.boolean(),
15822
+ available: external_exports.boolean(),
15823
+ unavailableReason: external_exports.string().min(1).max(500).optional(),
15824
+ browser: external_exports.boolean().optional(),
15825
+ browserFilesPresent: external_exports.boolean().optional(),
15826
+ browserAvailable: external_exports.boolean().optional(),
15827
+ browserUnavailableReason: external_exports.string().min(1).max(500).optional(),
15828
+ applyFailed: external_exports.boolean().optional(),
15829
+ applyError: external_exports.string().min(1).max(500).optional()
15830
+ }).strict();
15831
+
15807
15832
  // packages/shared-contracts/dist/harness-installation.js
15808
15833
  var harnessInstallationParamsSchema = external_exports.object({
15809
15834
  harnessId: harnessIdSchema,
@@ -16196,6 +16221,52 @@ var remoteConnectionsReplySchema = external_exports.union([
16196
16221
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16197
16222
  ]);
16198
16223
 
16224
+ // packages/shared-contracts/dist/voice-settings.js
16225
+ var voiceRoutesSchema = external_exports.strictObject({
16226
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
16227
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
16228
+ workConnection: external_exports.enum(["desktop", "gateway"])
16229
+ });
16230
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
16231
+ chatExperience: "chatgpt",
16232
+ chatConnection: "desktop",
16233
+ workConnection: "gateway"
16234
+ });
16235
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
16236
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
16237
+ external_exports.strictObject({
16238
+ operation: external_exports.literal("get"),
16239
+ runtime: external_exports.strictObject({
16240
+ id: external_exports.string().uuid(),
16241
+ revision: external_exports.string().max(64),
16242
+ activeCall: external_exports.boolean()
16243
+ }).optional()
16244
+ }),
16245
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
16246
+ external_exports.strictObject({
16247
+ operation: external_exports.literal("set"),
16248
+ settings: voiceSettingsSchema,
16249
+ revision: external_exports.string().max(64)
16250
+ }),
16251
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
16252
+ ]);
16253
+ var voiceSettingsStateSchema = external_exports.strictObject({
16254
+ settings: voiceSettingsSchema,
16255
+ initialized: external_exports.boolean(),
16256
+ revision: external_exports.string(),
16257
+ activeInject: external_exports.boolean().nullable(),
16258
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
16259
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
16260
+ routesActive: external_exports.boolean().nullable(),
16261
+ activeCall: external_exports.boolean().nullable(),
16262
+ gatewayReady: external_exports.boolean().nullable(),
16263
+ restartAvailable: external_exports.boolean(),
16264
+ restart: external_exports.strictObject({
16265
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
16266
+ error: external_exports.string().nullable()
16267
+ })
16268
+ });
16269
+
16199
16270
  // packages/shared-contracts/dist/index.js
16200
16271
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16201
16272
 
@@ -16379,6 +16450,10 @@ async function startControllerAttachmentServer(options) {
16379
16450
  void completion.finally(() => pages.delete(completion));
16380
16451
  return;
16381
16452
  }
16453
+ if (options.stop && line === `STOP ${options.nonce}` && request.slice(newline + 1) === "") {
16454
+ socket.end("stopping\n", () => options.stop?.());
16455
+ return;
16456
+ }
16382
16457
  if (line === `ATTACH ${options.nonce}`) {
16383
16458
  if (attachment) {
16384
16459
  respond(socket, "busy");
@@ -16512,13 +16587,33 @@ function createControllerStatusPublisher(filePath = defaultControllerStatusPath(
16512
16587
  };
16513
16588
  }
16514
16589
 
16590
+ // packages/desktop-control/src/live-voice-inject.ts
16591
+ import { readFileSync } from "node:fs";
16592
+ import os2 from "node:os";
16593
+ import path2 from "node:path";
16594
+ var LIVE_VOICE_INJECT_FILE = "live-voice-inject-v1.json";
16595
+ function readLiveVoiceInjectFile(environment = process.env) {
16596
+ const directory = environment.CODEXHOST_DATA_DIR ? path2.resolve(environment.CODEXHOST_DATA_DIR) : path2.join(os2.homedir(), ".codexhost");
16597
+ try {
16598
+ const parsed = JSON.parse(
16599
+ readFileSync(path2.join(directory, LIVE_VOICE_INJECT_FILE), "utf8")
16600
+ );
16601
+ return parsed.version !== 1 || parsed.inject !== false;
16602
+ } catch {
16603
+ return true;
16604
+ }
16605
+ }
16606
+
16515
16607
  // packages/desktop-control/src/cpa-live-voice-hook.ts
16516
16608
  var CPA_LIVE_VOICE_ENV = "CODEXHOST_CPA_LIVE_VOICE";
16517
16609
  var CPA_LIVE_VOICE_HOOK_GLOBAL = "__codexhostCpaLiveVoiceHookV1";
16518
16610
  var AUDITED_CPA_LIVE_VOICE_DESKTOP_VERSION = "26.1007.30912";
16519
16611
  var AUDITED_CPA_LIVE_VOICE_APP_INITIAL_ASSET = "app-initial-6350d04672d0.js";
16520
16612
  function cpaLiveVoiceHookEnabled(environment = process.env) {
16521
- return environment[CPA_LIVE_VOICE_ENV] !== "0";
16613
+ const value = environment[CPA_LIVE_VOICE_ENV];
16614
+ if (value === "0") return false;
16615
+ if (value === "1") return true;
16616
+ return readLiveVoiceInjectFile(environment);
16522
16617
  }
16523
16618
  function cpaLiveVoiceHookBootstrap(environment = process.env) {
16524
16619
  if (!cpaLiveVoiceHookEnabled(environment)) return "";
@@ -16559,13 +16654,13 @@ function committedReactAncestors(value) {
16559
16654
  const current = fiber(rootState.current);
16560
16655
  if (!current) return [];
16561
16656
  const alternate = fiber(first.alternate);
16562
- const path3 = [current];
16657
+ const path4 = [current];
16563
16658
  seen.clear();
16564
16659
  seen.add(current);
16565
16660
  for (let index = previous.length - 2; index >= 0; index -= 1) {
16566
16661
  const expected = previous[index];
16567
16662
  const expectedAlternate = fiber(expected?.alternate);
16568
- let child = fiber(path3.at(-1)?.child);
16663
+ let child = fiber(path4.at(-1)?.child);
16569
16664
  let matched = false;
16570
16665
  while (child && !seen.has(child) && seen.size < MAX_VISITED_FIBERS) {
16571
16666
  seen.add(child);
@@ -16576,10 +16671,10 @@ function committedReactAncestors(value) {
16576
16671
  child = fiber(child.sibling);
16577
16672
  }
16578
16673
  if (!matched || !child) break;
16579
- path3.push(child);
16674
+ path4.push(child);
16580
16675
  }
16581
- if (path3.length === previous.length && (path3.at(-1) === first || path3.at(-1) === alternate)) {
16582
- return path3.reverse();
16676
+ if (path4.length === previous.length && (path4.at(-1) === first || path4.at(-1) === alternate)) {
16677
+ return path4.reverse();
16583
16678
  }
16584
16679
  const stack = [{ node: current, parent: null }];
16585
16680
  seen.clear();
@@ -17921,8 +18016,8 @@ function parseDesktopControllerArguments(arguments_) {
17921
18016
  if (argument === "--renderer") {
17922
18017
  if (rendererPath !== void 0) throw new Error("--renderer may only be provided once");
17923
18018
  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);
18019
+ if (!path3.isAbsolute(value)) throw new Error("--renderer must be an absolute path");
18020
+ rendererPath = path3.normalize(value);
17926
18021
  index += 1;
17927
18022
  continue;
17928
18023
  }
@@ -17992,8 +18087,13 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
17992
18087
  let session;
17993
18088
  let nextRecoveryAt = 0;
17994
18089
  let recoveryDelayMs = RECOVERY_RETRY_INITIAL_MS;
18090
+ const bootstrap = cpaLiveVoiceHookBootstrap();
17995
18091
  const status = createRendererStatusReporter(
17996
- (document) => dependencies.publishStatus?.(document),
18092
+ (document) => dependencies.publishStatus?.({
18093
+ ...document,
18094
+ voiceInjection: Boolean(bootstrap),
18095
+ voiceEnvOverride: process.env.CODEXHOST_CPA_LIVE_VOICE === "0" || process.env.CODEXHOST_CPA_LIVE_VOICE === "1" ? process.env.CODEXHOST_CPA_LIVE_VOICE : null
18096
+ }),
17997
18097
  now
17998
18098
  );
17999
18099
  const recordRecoveryFailure = (error51) => {
@@ -18010,8 +18110,7 @@ async function runDesktopController(options, signal, dependencies = defaultDepen
18010
18110
  status.installing();
18011
18111
  startupTrace("reading Renderer bundle");
18012
18112
  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;
18113
+ const overlayPath = bootstrap ? path3.join(path3.dirname(options.rendererPath), "cpa-live-voice-hook.js") : void 0;
18015
18114
  const [rendererSource, overlayBundle] = overlayPath ? await Promise.all([rendererRead, dependencies.readRenderer(overlayPath)]) : [await rendererRead, void 0];
18016
18115
  if (rendererSource.trim().length === 0) throw new Error("production Renderer Bundle is empty");
18017
18116
  const overlayHookSource = bootstrap && overlayBundle && overlayBundle.trim().length > 0 ? `${RENDERER_CSP_BOOTSTRAP}
@@ -18068,6 +18167,7 @@ ${bootstrap}${rendererSource}`,
18068
18167
  attachmentServer = await dependencies.startAttachmentServer({
18069
18168
  port: options.attachmentPort,
18070
18169
  nonce: options.attachmentNonce,
18170
+ ...options.requestStop ? { stop: options.requestStop } : {},
18071
18171
  remoteConnections: async (request) => {
18072
18172
  const current = await useSession(() => recoverSession());
18073
18173
  return remoteConnectionsReplySchema.parse(
@@ -18126,7 +18226,10 @@ var stop = () => abort.abort();
18126
18226
  process.once("SIGINT", stop);
18127
18227
  process.once("SIGTERM", stop);
18128
18228
  try {
18129
- await runDesktopController(parseDesktopControllerArguments(process.argv.slice(2)), abort.signal);
18229
+ await runDesktopController(
18230
+ { ...parseDesktopControllerArguments(process.argv.slice(2)), requestStop: stop },
18231
+ abort.signal
18232
+ );
18130
18233
  } catch (error51) {
18131
18234
  console.error(
18132
18235
  `codexhost Desktop Controller: ${error51 instanceof Error ? error51.message : String(error51)}`