@karlorz/codexhost-cli-darwin-x64 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.
@@ -20273,6 +20273,7 @@ var consoleOpenResultSchema = external_exports.strictObject({
20273
20273
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
20274
20274
  });
20275
20275
  var CONSOLE_HOST_METHODS = Object.freeze([
20276
+ "codexhost/voice/gateway-status",
20276
20277
  "codexhost/console/remote-connections",
20277
20278
  "codexhost/runtime/status",
20278
20279
  "codexhost/remote/ssh-setup",
@@ -21468,6 +21469,54 @@ var remoteConnectionsReplySchema = external_exports.union([
21468
21469
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
21469
21470
  ]);
21470
21471
 
21472
+ // packages/shared-contracts/dist/voice-settings.js
21473
+ var VOICE_SETTINGS_METHOD = "codexhost/voice/settings";
21474
+ var VOICE_GATEWAY_STATUS_METHOD = "codexhost/voice/gateway-status";
21475
+ var voiceRoutesSchema = external_exports.strictObject({
21476
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
21477
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
21478
+ workConnection: external_exports.enum(["desktop", "gateway"])
21479
+ });
21480
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
21481
+ chatExperience: "chatgpt",
21482
+ chatConnection: "desktop",
21483
+ workConnection: "gateway"
21484
+ });
21485
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
21486
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
21487
+ external_exports.strictObject({
21488
+ operation: external_exports.literal("get"),
21489
+ runtime: external_exports.strictObject({
21490
+ id: external_exports.string().uuid(),
21491
+ revision: external_exports.string().max(64),
21492
+ activeCall: external_exports.boolean()
21493
+ }).optional()
21494
+ }),
21495
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
21496
+ external_exports.strictObject({
21497
+ operation: external_exports.literal("set"),
21498
+ settings: voiceSettingsSchema,
21499
+ revision: external_exports.string().max(64)
21500
+ }),
21501
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
21502
+ ]);
21503
+ var voiceSettingsStateSchema = external_exports.strictObject({
21504
+ settings: voiceSettingsSchema,
21505
+ initialized: external_exports.boolean(),
21506
+ revision: external_exports.string(),
21507
+ activeInject: external_exports.boolean().nullable(),
21508
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
21509
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
21510
+ routesActive: external_exports.boolean().nullable(),
21511
+ activeCall: external_exports.boolean().nullable(),
21512
+ gatewayReady: external_exports.boolean().nullable(),
21513
+ restartAvailable: external_exports.boolean(),
21514
+ restart: external_exports.strictObject({
21515
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
21516
+ error: external_exports.string().nullable()
21517
+ })
21518
+ });
21519
+
21471
21520
  // packages/shared-contracts/dist/index.js
21472
21521
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
21473
21522
 
@@ -24559,6 +24608,10 @@ async function startControllerAttachmentServer(options2) {
24559
24608
  void completion.finally(() => pages.delete(completion));
24560
24609
  return;
24561
24610
  }
24611
+ if (options2.stop && line === `STOP ${options2.nonce}` && request.slice(newline2 + 1) === "") {
24612
+ socket.end("stopping\n", () => options2.stop?.());
24613
+ return;
24614
+ }
24562
24615
  if (line === `ATTACH ${options2.nonce}`) {
24563
24616
  if (attachment) {
24564
24617
  respond(socket, "busy");
@@ -26916,11 +26969,20 @@ var storedThreadCoreV1Shape = {
26916
26969
  updatedAt: isoDateSchema
26917
26970
  };
26918
26971
  var storedThreadMetadataFieldsShape = {
26972
+ subagentConfiguration: external_exports.object({
26973
+ model: nonBlankTextSchema6.max(1024).optional(),
26974
+ reasoningEffort: nonBlankTextSchema6.max(1024).optional()
26975
+ }).strict().optional(),
26919
26976
  projectId: nonBlankTextSchema6.max(1024).optional(),
26920
26977
  daybreakEnabled: external_exports.boolean().optional(),
26921
26978
  gitInfo: storedGitInfoV1Schema.optional()
26922
26979
  };
26923
- var THREAD_METADATA_FIELDS = ["projectId", "daybreakEnabled", "gitInfo"];
26980
+ var THREAD_METADATA_FIELDS = [
26981
+ "projectId",
26982
+ "daybreakEnabled",
26983
+ "gitInfo",
26984
+ "subagentConfiguration"
26985
+ ];
26924
26986
  var storedThreadMetadataV1Schema = external_exports.object({
26925
26987
  formatVersion: external_exports.literal(1),
26926
26988
  hostThreadId: storedHostThreadIdSchema,
@@ -27200,8 +27262,8 @@ function threadMetadataOf(record4) {
27200
27262
  return { formatVersion: 1, hostThreadId: record4.hostThreadId, ...fields };
27201
27263
  }
27202
27264
  function withoutThreadMetadata(record4) {
27203
- const { projectId, daybreakEnabled, gitInfo, ...core } = record4;
27204
- void [projectId, daybreakEnabled, gitInfo];
27265
+ const { projectId, daybreakEnabled, gitInfo, subagentConfiguration, ...core } = record4;
27266
+ void [projectId, daybreakEnabled, gitInfo, subagentConfiguration];
27205
27267
  return core;
27206
27268
  }
27207
27269
  function withThreadMetadata(record4, metadata) {
@@ -27214,6 +27276,16 @@ function withThreadMetadata(record4, metadata) {
27214
27276
  }
27215
27277
  function applyThreadMetadataPatch(current, patch) {
27216
27278
  const next = { ...current };
27279
+ if (patch.subagentConfiguration !== void 0) {
27280
+ if (!current.subagent)
27281
+ throw new Error("Child configuration requires a Subagent Thread");
27282
+ next.subagentConfiguration = { ...current.subagentConfiguration };
27283
+ for (const name of ["model", "reasoningEffort"]) {
27284
+ const value2 = patch.subagentConfiguration[name];
27285
+ if (value2 !== void 0)
27286
+ next.subagentConfiguration[name] = value2;
27287
+ }
27288
+ }
27217
27289
  if (patch.projectId !== void 0) {
27218
27290
  if (patch.projectId === null)
27219
27291
  delete next.projectId;
@@ -29630,21 +29702,28 @@ function toolContentItems(item) {
29630
29702
  imageUrl: `data:${content.mimeType};base64,${content.base64Data}`
29631
29703
  });
29632
29704
  }
29633
- function collabAgentStatus(status2) {
29634
- switch (status2) {
29635
- case "pending":
29636
- return "pendingInit";
29637
- case "running":
29638
- return "running";
29639
- case "completed":
29640
- return "completed";
29641
- case "failed":
29642
- return "errored";
29643
- case "interrupted":
29644
- return "interrupted";
29645
- }
29705
+ function projectSubagentActivities(item) {
29706
+ return item.subagents.flatMap((child) => {
29707
+ const activity = {
29708
+ id: `${item.itemId}-subagent-${encodeURIComponent(child.subagentId)}`,
29709
+ type: "subAgentActivity",
29710
+ agentThreadId: child.subagentId,
29711
+ agentPath: child.description || child.role || child.subagentId,
29712
+ kind: item.operation === "spawn" ? "started" : "interacted"
29713
+ };
29714
+ if (child.status === "pending" || child.status === "running")
29715
+ return [activity];
29716
+ return [
29717
+ activity,
29718
+ {
29719
+ ...activity,
29720
+ id: `${activity.id}-status`,
29721
+ kind: child.status === "completed" ? "completed" : "interrupted"
29722
+ }
29723
+ ];
29724
+ });
29646
29725
  }
29647
- function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, senderThreadId) {
29726
+ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true) {
29648
29727
  switch (item.type) {
29649
29728
  case "agentMessage":
29650
29729
  return {
@@ -29728,25 +29807,8 @@ function projectItem(item, outcome, defaultCwd, includeCommandOutput = true, sen
29728
29807
  failure: null,
29729
29808
  transparentBackground: null
29730
29809
  };
29731
- case "subagentDelegation": {
29732
- const primary = item.subagents[0];
29733
- const sameConfiguration = item.subagents.every((subagent) => subagent.model === primary?.model && subagent.reasoningEffort === primary?.reasoningEffort);
29734
- return {
29735
- id: item.itemId,
29736
- type: "collabAgentToolCall",
29737
- tool: item.operation === "spawn" ? "spawnAgent" : "sendInput",
29738
- status: itemStatus(outcome),
29739
- senderThreadId: senderThreadId ?? "",
29740
- receiverThreadIds: item.subagents.map(({ subagentId }) => subagentId),
29741
- prompt: item.prompt ?? null,
29742
- model: sameConfiguration ? primary?.model ?? null : null,
29743
- reasoningEffort: sameConfiguration ? primary?.reasoningEffort ?? null : null,
29744
- agentsStates: Object.fromEntries(item.subagents.map(({ subagentId, status: status2, resultSummary }) => [
29745
- subagentId,
29746
- { status: collabAgentStatus(status2), message: resultSummary ?? null }
29747
- ]))
29748
- };
29749
- }
29810
+ case "subagentDelegation":
29811
+ throw new Error("Subagent delegation requires per-child activity projection");
29750
29812
  }
29751
29813
  }
29752
29814
  function reasoningPreviewItemId(itemId) {
@@ -29812,12 +29874,11 @@ function projectHistoricalTurn(input) {
29812
29874
  if (isFileMutatingTool(item.toolName))
29813
29875
  return [];
29814
29876
  }
29877
+ if (item.type === "subagentDelegation")
29878
+ return projectSubagentActivities(item);
29815
29879
  if (item.type === "reasoning" && !reasoningDisplayText(item.text))
29816
29880
  return [];
29817
- return item.type === "reasoning" ? [
29818
- projectItem(item, outcome, cwd, true, input.threadId ?? ""),
29819
- projectReasoningTranscriptItem(item, outcome, cwd)
29820
- ] : [projectItem(item, outcome, cwd, true, input.threadId ?? "")];
29881
+ return item.type === "reasoning" ? [projectItem(item, outcome, cwd), projectReasoningTranscriptItem(item, outcome, cwd)] : [projectItem(item, outcome, cwd)];
29821
29882
  };
29822
29883
  const entries = snapshot2.items.map((entry) => ({ entry, projected: projectEntry(entry) }));
29823
29884
  const lastVisible = entries.findLast(({ projected }) => projected.length > 0)?.entry;
@@ -29906,7 +29967,7 @@ var CodexTurnProjector = class {
29906
29967
  const projected = this.#items.get(itemId);
29907
29968
  if (!projected || projected.outcome)
29908
29969
  continue;
29909
- items.set(itemId, projectItem(projected.item, null, this.#cwd, true, this.#threadId));
29970
+ items.set(itemId, projectItem(projected.item, null, this.#cwd));
29910
29971
  }
29911
29972
  return items;
29912
29973
  }
@@ -30111,6 +30172,13 @@ var CodexTurnProjector = class {
30111
30172
  }
30112
30173
  if (event.item.type === "fileChange")
30113
30174
  return { messages: this.#fileChangeUpdates(startedAtMs) };
30175
+ if (event.item.type === "subagentDelegation") {
30176
+ projected.wireStarted = true;
30177
+ this.#wireItemOrder.push(event.item.itemId);
30178
+ return {
30179
+ messages: this.#subagentActivityMessages(event.item, "item/started", startedAtMs, startedAtMs)
30180
+ };
30181
+ }
30114
30182
  const startedItem = event.item.type === "reasoning" ? { ...event.item, text: "" } : event.item;
30115
30183
  const messages = [this.#startWireItem(projected, startedItem, startedAtMs)];
30116
30184
  if (event.item.type === "reasoning") {
@@ -30188,16 +30256,9 @@ var CodexTurnProjector = class {
30188
30256
  } else if (event.update.type === "fileChanges.replace") {
30189
30257
  messages.push(...this.#fileChangeUpdates(emittedAtMs));
30190
30258
  } else if (event.update.type === "subagents.replace") {
30191
- messages.push({
30192
- method: "item/started",
30193
- emittedAtMs,
30194
- params: {
30195
- threadId: this.#threadId,
30196
- turnId: this.#turnId,
30197
- startedAtMs: projected.startedAtMs ?? emittedAtMs,
30198
- item: projectItem(next, null, this.#cwd, true, this.#threadId)
30199
- }
30200
- });
30259
+ if (next.type !== "subagentDelegation")
30260
+ throw new Error("Invalid Subagent update");
30261
+ messages.push(...this.#subagentActivityMessages(next, "item/started", emittedAtMs, projected.startedAtMs ?? emittedAtMs));
30201
30262
  }
30202
30263
  return { messages };
30203
30264
  }
@@ -30246,8 +30307,13 @@ var CodexTurnProjector = class {
30246
30307
  }
30247
30308
  return { messages: [] };
30248
30309
  }
30310
+ if (projected.item.type === "subagentDelegation") {
30311
+ return {
30312
+ messages: this.#subagentActivityMessages(projected.item, "item/completed", emittedAtMs, startedAtMs)
30313
+ };
30314
+ }
30249
30315
  const messages = [
30250
- completedItem(projectItem(projected.item, projected.outcome, this.#cwd, !projected.streamedCommandOutput, this.#threadId))
30316
+ completedItem(projectItem(projected.item, projected.outcome, this.#cwd, !projected.streamedCommandOutput))
30251
30317
  ];
30252
30318
  if (projected.item.type === "reasoning") {
30253
30319
  const reasoning = projected.item;
@@ -30384,6 +30450,19 @@ var CodexTurnProjector = class {
30384
30450
  }
30385
30451
  ];
30386
30452
  }
30453
+ #subagentActivityMessages(item, method, emittedAtMs, startedAtMs) {
30454
+ return projectSubagentActivities(item).map((activity) => ({
30455
+ method,
30456
+ emittedAtMs,
30457
+ params: {
30458
+ threadId: this.#threadId,
30459
+ turnId: this.#turnId,
30460
+ startedAtMs,
30461
+ ...method === "item/completed" ? { completedAtMs: emittedAtMs } : {},
30462
+ item: activity
30463
+ }
30464
+ }));
30465
+ }
30387
30466
  #startWireItem(projected, item, startedAtMs) {
30388
30467
  if (projected.wireStarted)
30389
30468
  throw new Error("Codex Item started more than once");
@@ -30397,7 +30476,7 @@ var CodexTurnProjector = class {
30397
30476
  threadId: this.#threadId,
30398
30477
  turnId: this.#turnId,
30399
30478
  startedAtMs,
30400
- item: projectItem(item, null, this.#cwd, true, this.#threadId)
30479
+ item: projectItem(item, null, this.#cwd)
30401
30480
  }
30402
30481
  };
30403
30482
  }
@@ -31874,10 +31953,17 @@ function subagentMaterializer(store, parent, previousParent) {
31874
31953
  const { byRequest } = await legacyRecords();
31875
31954
  existing = byRequest.get(createRequestId) ?? (previousRequest ? byRequest.get(previousRequest) : void 0) ?? null;
31876
31955
  }
31956
+ const configured = (record4) => child.model !== void 0 || child.reasoningEffort !== void 0 ? store.updateMetadata(record4.hostThreadId, {
31957
+ subagentConfiguration: {
31958
+ ...child.model !== void 0 ? { model: child.model } : {},
31959
+ ...child.reasoningEffort !== void 0 ? { reasoningEffort: child.reasoningEffort } : {}
31960
+ }
31961
+ }) : record4;
31877
31962
  if (existing?.state === "ready") {
31878
- if (existing.nativeSessionRef?.nativeSessionId === nativeRef.nativeSessionId) return existing;
31963
+ if (existing.nativeSessionRef?.nativeSessionId === nativeRef.nativeSessionId)
31964
+ return configured(existing);
31879
31965
  if (!previousRef) throw new Error("Subagent belongs to a different Native Session");
31880
- return rebind(existing, parent);
31966
+ return configured(await rebind(existing, parent));
31881
31967
  }
31882
31968
  const provisional = existing ?? await store.createProvisional({
31883
31969
  hostThreadId: hostThreadIdSchema.parse(randomUUID10()),
@@ -31885,7 +31971,7 @@ function subagentMaterializer(store, parent, previousParent) {
31885
31971
  harnessId: parent.harnessId,
31886
31972
  cwd: parent.cwd,
31887
31973
  title: child.description,
31888
- transportModelId: parent.transportModelId,
31974
+ transportModelId: encodeExternalTransportSelection(parent.harnessId, {}),
31889
31975
  ephemeral: parent.ephemeral,
31890
31976
  historyMode: "paginated",
31891
31977
  subagent: {
@@ -31894,10 +31980,12 @@ function subagentMaterializer(store, parent, previousParent) {
31894
31980
  ...child.role ? { role: child.role } : {}
31895
31981
  }
31896
31982
  });
31897
- return provisional.state === "ready" ? provisional : store.commitReady({
31898
- hostThreadId: provisional.hostThreadId,
31899
- nativeSessionRef: nativeRef
31900
- });
31983
+ return configured(
31984
+ provisional.state === "ready" ? provisional : await store.commitReady({
31985
+ hostThreadId: provisional.hostThreadId,
31986
+ nativeSessionRef: nativeRef
31987
+ })
31988
+ );
31901
31989
  };
31902
31990
  }
31903
31991
  async function materializeExternalSubagent(store, parent, child) {
@@ -32249,6 +32337,10 @@ function externalThreadValue(input) {
32249
32337
  }
32250
32338
  } : "vscode",
32251
32339
  threadSource: record4.subagent ? "subAgentThreadSpawn" : null,
32340
+ ...record4.subagent ? {
32341
+ model: record4.subagentConfiguration?.model ?? null,
32342
+ reasoningEffort: record4.subagentConfiguration?.reasoningEffort ?? null
32343
+ } : {},
32252
32344
  modelProvider: "codexhost",
32253
32345
  cliVersion: "codexhost",
32254
32346
  createdAt,
@@ -40289,6 +40381,37 @@ var AppServerHost = class {
40289
40381
  this.#dispatchDesktopReply(request, () => this.#handleUpdateRequest(request));
40290
40382
  return;
40291
40383
  }
40384
+ if (request.method === VOICE_SETTINGS_METHOD || request.method === VOICE_GATEWAY_STATUS_METHOD) {
40385
+ this.#dispatchDesktopReply(request, async () => {
40386
+ const service = this.#options.consoleOpener;
40387
+ if (!service?.voiceSettings) {
40388
+ await this.#writer.json(
40389
+ rpcError(request, -32090, "Voice settings are available on the local Host only")
40390
+ );
40391
+ return;
40392
+ }
40393
+ if (request.method === VOICE_GATEWAY_STATUS_METHOD) {
40394
+ const ready = await readRealtimeGateway(this.#options.environment ?? process.env).then(
40395
+ () => true,
40396
+ () => false
40397
+ );
40398
+ await this.#writer.json(rpcEnvelope(request, { result: ready }));
40399
+ return;
40400
+ }
40401
+ const parsed2 = voiceSettingsRequestSchema.safeParse(request.params);
40402
+ if (!parsed2.success) {
40403
+ await this.#writer.json(rpcError(request, -32602, "Invalid voice settings request"));
40404
+ return;
40405
+ }
40406
+ try {
40407
+ const result = await service.voiceSettings(parsed2.data);
40408
+ await this.#writer.json(rpcEnvelope(request, { result: jsonValueSchema.parse(result) }));
40409
+ } catch (error51) {
40410
+ await this.#writer.json(rpcError(request, -32092, errorMessage4(error51).slice(0, 500)));
40411
+ }
40412
+ });
40413
+ return;
40414
+ }
40292
40415
  if (request.method === CONSOLE_OPEN_METHOD) {
40293
40416
  this.#dispatchDesktopReply(request, () => this.#handleConsoleOpen(request));
40294
40417
  return;
@@ -42805,13 +42928,15 @@ var AppServerHost = class {
42805
42928
  turns: params.excludeTurns === true ? [] : turns
42806
42929
  };
42807
42930
  const result = threadForkResult(responseThread, {
42808
- model: thread.transportModelId,
42931
+ model: thread.record.subagent ? thread.record.subagentConfiguration?.model ?? "" : thread.transportModelId,
42809
42932
  cwd: thread.cwd,
42810
42933
  runtimeWorkspaceRoots: Array.isArray(params.runtimeWorkspaceRoots) ? params.runtimeWorkspaceRoots.filter((value2) => typeof value2 === "string") : [],
42811
42934
  approvalPolicy: typeof params.approvalPolicy === "string" ? params.approvalPolicy : "never",
42812
42935
  sandbox: sandboxResult(),
42813
42936
  ...typeof params.serviceTier === "string" ? { serviceTier: params.serviceTier } : {}
42814
42937
  });
42938
+ if (thread.record.subagent)
42939
+ result.reasoningEffort = thread.record.subagentConfiguration?.reasoningEffort ?? null;
42815
42940
  try {
42816
42941
  if (params.initialTurnsPage !== void 0 && params.initialTurnsPage !== null && !isRecord20(params.initialTurnsPage)) {
42817
42942
  throw new ExternalHistoryRequestError("initialTurnsPage must be an object");
@@ -43475,6 +43600,15 @@ var AppServerHost = class {
43475
43600
  const status2 = subagent.status === "pending" || subagent.status === "running" ? "active" : "idle";
43476
43601
  const record4 = await this.#repository.materializeSubagent(parent.record, subagent);
43477
43602
  if (!record4) return subagent;
43603
+ const loaded = this.#externalRuntime.get(record4.hostThreadId);
43604
+ if (loaded) {
43605
+ loaded.record = record4;
43606
+ loaded.thread = {
43607
+ ...loaded.thread,
43608
+ model: record4.subagentConfiguration?.model ?? null,
43609
+ reasoningEffort: record4.subagentConfiguration?.reasoningEffort ?? null
43610
+ };
43611
+ }
43478
43612
  if (this.#subagentThreadStatuses.has(record4.hostThreadId)) {
43479
43613
  this.#trackRunningSubagent(parent.id, record4.hostThreadId, status2);
43480
43614
  await this.#setSubagentThreadStatus(record4.hostThreadId, status2);
@@ -46666,42 +46800,61 @@ function parseConsoleAddress(output) {
46666
46800
  }
46667
46801
  function createHostConsoleOpener(options2) {
46668
46802
  const spawnProcess = options2.spawnProcess ?? spawn7;
46803
+ const address = (command) => new Promise((resolve, reject) => {
46804
+ const child = spawnProcess(
46805
+ options2.nodePath ?? process.execPath,
46806
+ [options2.entrypoint, command],
46807
+ {
46808
+ env: options2.environment,
46809
+ stdio: ["ignore", "pipe", "pipe"],
46810
+ windowsHide: true
46811
+ }
46812
+ );
46813
+ let stdout = "";
46814
+ let stderr = "";
46815
+ const append = (current, chunk) => (current + chunk.toString("utf8")).slice(-OUTPUT_LIMIT);
46816
+ child.stdout?.on("data", (chunk) => stdout = append(stdout, chunk));
46817
+ child.stderr?.on("data", (chunk) => stderr = append(stderr, chunk));
46818
+ const timer = setTimeout(() => {
46819
+ child.kill();
46820
+ reject(new Error("codexhost console did not open in time"));
46821
+ }, OPEN_TIMEOUT_MS2);
46822
+ child.once("error", (error51) => {
46823
+ clearTimeout(timer);
46824
+ reject(error51);
46825
+ });
46826
+ child.once("exit", (code) => {
46827
+ clearTimeout(timer);
46828
+ const url2 = parseConsoleAddress(stdout);
46829
+ if (code === 0 && url2) {
46830
+ resolve({ url: url2 });
46831
+ return;
46832
+ }
46833
+ const detail = stderr.trim().split(/\r?\n/u).at(-1);
46834
+ reject(new Error(detail || "codexhost console could not be opened"));
46835
+ });
46836
+ });
46837
+ let ready = null;
46669
46838
  return {
46670
- open() {
46671
- return new Promise((resolve, reject) => {
46672
- const child = spawnProcess(
46673
- options2.nodePath ?? process.execPath,
46674
- [options2.entrypoint, "open"],
46675
- {
46676
- env: options2.environment,
46677
- stdio: ["ignore", "pipe", "pipe"],
46678
- windowsHide: true
46679
- }
46680
- );
46681
- let stdout = "";
46682
- let stderr = "";
46683
- const append = (current, chunk) => (current + chunk.toString("utf8")).slice(-OUTPUT_LIMIT);
46684
- child.stdout?.on("data", (chunk) => stdout = append(stdout, chunk));
46685
- child.stderr?.on("data", (chunk) => stderr = append(stderr, chunk));
46686
- const timer = setTimeout(() => {
46687
- child.kill();
46688
- reject(new Error("codexhost console did not open in time"));
46689
- }, OPEN_TIMEOUT_MS2);
46690
- child.once("error", (error51) => {
46691
- clearTimeout(timer);
46692
- reject(error51);
46693
- });
46694
- child.once("exit", (code) => {
46695
- clearTimeout(timer);
46696
- const url2 = parseConsoleAddress(stdout);
46697
- if (code === 0 && url2) {
46698
- resolve({ url: url2 });
46699
- return;
46700
- }
46701
- const detail = stderr.trim().split(/\r?\n/u).at(-1);
46702
- reject(new Error(detail || "codexhost console could not be opened"));
46839
+ open: () => address("open"),
46840
+ async voiceSettings(input) {
46841
+ ready ??= address("ensure");
46842
+ try {
46843
+ const { url: url2 } = await ready;
46844
+ const response = await fetch(new URL("api/voice-settings", url2), {
46845
+ method: "POST",
46846
+ headers: { "content-type": "application/json", "x-codexhost-console": "1" },
46847
+ body: JSON.stringify(input),
46848
+ redirect: "error",
46849
+ signal: AbortSignal.timeout(1e4)
46703
46850
  });
46704
- });
46851
+ const body = await response.json();
46852
+ if (!response.ok) throw new Error(body.error ?? "Voice settings request failed");
46853
+ return body;
46854
+ } catch (error51) {
46855
+ ready = null;
46856
+ throw error51;
46857
+ }
46705
46858
  }
46706
46859
  };
46707
46860
  }
@@ -15229,6 +15229,7 @@ var consoleOpenResultSchema = external_exports.strictObject({
15229
15229
  url: external_exports.string().max(2048).regex(/^http:\/\/(?:127\.0\.0\.1|localhost):\d{1,5}\/(?:\?.*)?$/u)
15230
15230
  });
15231
15231
  var CONSOLE_HOST_METHODS = Object.freeze([
15232
+ "codexhost/voice/gateway-status",
15232
15233
  "codexhost/console/remote-connections",
15233
15234
  "codexhost/runtime/status",
15234
15235
  "codexhost/remote/ssh-setup",
@@ -16338,6 +16339,52 @@ var remoteConnectionsReplySchema = external_exports.union([
16338
16339
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
16339
16340
  ]);
16340
16341
 
16342
+ // ../../shared-contracts/dist/voice-settings.js
16343
+ var voiceRoutesSchema = external_exports.strictObject({
16344
+ chatExperience: external_exports.enum(["chatgpt", "codex"]),
16345
+ chatConnection: external_exports.enum(["desktop", "gateway"]),
16346
+ workConnection: external_exports.enum(["desktop", "gateway"])
16347
+ });
16348
+ var DEFAULT_VOICE_ROUTES = Object.freeze({
16349
+ chatExperience: "chatgpt",
16350
+ chatConnection: "desktop",
16351
+ workConnection: "gateway"
16352
+ });
16353
+ var voiceSettingsSchema = voiceRoutesSchema.extend({ inject: external_exports.boolean() });
16354
+ var voiceSettingsRequestSchema = external_exports.discriminatedUnion("operation", [
16355
+ external_exports.strictObject({
16356
+ operation: external_exports.literal("get"),
16357
+ runtime: external_exports.strictObject({
16358
+ id: external_exports.string().uuid(),
16359
+ revision: external_exports.string().max(64),
16360
+ activeCall: external_exports.boolean()
16361
+ }).optional()
16362
+ }),
16363
+ external_exports.strictObject({ operation: external_exports.literal("migrate"), routes: voiceRoutesSchema }),
16364
+ external_exports.strictObject({
16365
+ operation: external_exports.literal("set"),
16366
+ settings: voiceSettingsSchema,
16367
+ revision: external_exports.string().max(64)
16368
+ }),
16369
+ external_exports.strictObject({ operation: external_exports.literal("restart"), confirm: external_exports.literal(true) })
16370
+ ]);
16371
+ var voiceSettingsStateSchema = external_exports.strictObject({
16372
+ settings: voiceSettingsSchema,
16373
+ initialized: external_exports.boolean(),
16374
+ revision: external_exports.string(),
16375
+ activeInject: external_exports.boolean().nullable(),
16376
+ envOverride: external_exports.enum(["0", "1"]).nullable(),
16377
+ activeEnvOverride: external_exports.enum(["0", "1"]).nullable(),
16378
+ routesActive: external_exports.boolean().nullable(),
16379
+ activeCall: external_exports.boolean().nullable(),
16380
+ gatewayReady: external_exports.boolean().nullable(),
16381
+ restartAvailable: external_exports.boolean(),
16382
+ restart: external_exports.strictObject({
16383
+ phase: external_exports.enum(["idle", "restarting", "succeeded", "failed"]),
16384
+ error: external_exports.string().nullable()
16385
+ })
16386
+ });
16387
+
16341
16388
  // ../../shared-contracts/dist/index.js
16342
16389
  var workspaceContractVersionSchema = external_exports.literal(WORKSPACE_CONTRACT_VERSION);
16343
16390