@codexhost/cli-linux-arm64 0.19.0 → 0.21.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 (63) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +45 -4
  4. package/app/console-web.js +1124 -684
  5. package/app/desktop-controller.mjs +197 -50
  6. package/app/host-runtime.mjs +36192 -29254
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +8863 -4094
  9. package/app/plugins/claude-code/plugin.mjs +173 -26
  10. package/app/plugins/codebuddy/plugin.mjs +71 -6
  11. package/app/plugins/codex-usage/plugin.mjs +56 -4
  12. package/app/plugins/copilot/plugin.mjs +48 -4
  13. package/app/plugins/cursor-cli/plugin.mjs +48 -4
  14. package/app/plugins/deepseek-harness/plugin.mjs +73 -9
  15. package/app/plugins/devin/plugin.mjs +47 -4
  16. package/app/plugins/grok/plugin.mjs +84 -13
  17. package/app/plugins/hermes/plugin.mjs +47 -4
  18. package/app/plugins/kimi-code/plugin.mjs +73 -14
  19. package/app/plugins/kiro-cli/plugin.mjs +48 -4
  20. package/app/plugins/omp/plugin.mjs +74 -7
  21. package/app/plugins/opencode/plugin.mjs +74 -13
  22. package/app/plugins/pi/plugin.mjs +75 -7
  23. package/app/plugins/qoder/plugin.mjs +85 -5
  24. package/app/plugins/qoder-cn/plugin.mjs +85 -5
  25. package/app/plugins/qwen-code/plugin.mjs +48 -4
  26. package/app/plugins/workbuddy/plugin.mjs +75 -9
  27. package/app/plugins/zcode/plugin.mjs +56 -4
  28. package/app/renderer-extension.js +1431 -737
  29. package/app/web/assets/index-BdmZfTRW.js +201 -0
  30. package/app/web/assets/index-DJW4bmyx.css +1 -0
  31. package/app/web/assets/langs/{graphql-B8vkg11W.js → graphql-ChAeyPkT.js} +1 -1
  32. package/app/web/assets/langs/{http-DmoDEjMt.js → http-BvreBIbD.js} +1 -1
  33. package/app/web/assets/langs/{php-DJ5ovfAM.js → php-D8omCIuJ.js} +1 -1
  34. package/app/web/assets/langs/{rst-U5-R5x3p.js → rst-Do7RLLCS.js} +1 -1
  35. package/app/web/assets/langs/{ruby-VKVsnS0H.js → ruby-rH_O_vse.js} +1 -1
  36. package/app/web/assets/langs/{svelte-C20lOv9V.js → svelte-xZy73wAj.js} +1 -1
  37. package/app/web/assets/langs/{vue-z6Y-lzP-.js → vue-C4DW8agZ.js} +1 -1
  38. package/app/web/assets/{vendor-dSL872WO.js → vendor-C9g2bw8s.js} +3 -3
  39. package/app/web/codexhost-settings.js +1130 -686
  40. package/app/web/index.html +4 -3
  41. package/app/web/plugins/deepseek-ai__dsh-api-gateway/client.js +2 -2
  42. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  44. package/app/web/plugins/deepseek-ai__dsh-client-connection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -69
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +7 -7
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +27 -27
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-session/client.js +1 -1
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  53. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  54. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  55. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  56. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  57. package/app/web-modules/server.mjs +1144 -731
  58. package/bin/codexhost +0 -0
  59. package/libexec/codexhost-shim +0 -0
  60. package/libexec/codexhost-updater +0 -0
  61. package/package.json +1 -1
  62. package/app/web/assets/index-BNQIOOHE.css +0 -1
  63. package/app/web/assets/index-Feo4BkqN.js +0 -199
@@ -212,14 +212,14 @@ var CdpClient = class _CdpClient {
212
212
  if (listeners.size === 0) this.#listeners.delete(method);
213
213
  };
214
214
  }
215
- #send(method, params, sessionId) {
215
+ #send(method, params, sessionId, timeoutMs = this.#commandTimeoutMs) {
216
216
  if (this.#closed) return Promise.reject(new CdpConnectionClosedError("CDP client is closed"));
217
217
  const id = this.#nextId++;
218
218
  return new Promise((resolve, reject) => {
219
219
  const timeout = setTimeout(() => {
220
220
  this.#pending.delete(id);
221
221
  reject(new Error(`CDP command '${method}' timed out`));
222
- }, this.#commandTimeoutMs);
222
+ }, timeoutMs);
223
223
  this.#pending.set(id, { resolve, reject, timeout });
224
224
  try {
225
225
  this.#socket.send(
@@ -232,12 +232,13 @@ var CdpClient = class _CdpClient {
232
232
  }
233
233
  });
234
234
  }
235
- async evaluate(expression) {
236
- const response = await this.command("Runtime.evaluate", {
237
- expression,
238
- awaitPromise: true,
239
- returnByValue: true
240
- });
235
+ async evaluate(expression, timeoutMs) {
236
+ const response = await this.#send(
237
+ "Runtime.evaluate",
238
+ { expression, awaitPromise: true, returnByValue: true },
239
+ void 0,
240
+ timeoutMs
241
+ );
241
242
  if (!isRecord(response)) throw new Error("Runtime.evaluate returned an invalid result");
242
243
  try {
243
244
  if (isRecord(response.exceptionDetails)) {
@@ -316,7 +317,10 @@ var CdpClient = class _CdpClient {
316
317
  // packages/desktop-control/src/renderer-remote-sessions.ts
317
318
  async function rendererRemoteSession(target2, operation) {
318
319
  const routing = target2.__codexhostHostRoutingV1;
319
- if (!routing) throw new Error("Desktop remote session routing is unavailable");
320
+ if (!routing)
321
+ throw Object.assign(new Error("Desktop remote session routing is unavailable"), {
322
+ code: -32090
323
+ });
320
324
  const ids = [...new Set(routing.knownHostIds?.() ?? [])].filter(
321
325
  (id) => /^remote-(?:ssh(?:-|:)|control:)/u.test(id)
322
326
  );
@@ -390,49 +394,129 @@ async function rendererRemoteSession(target2, operation) {
390
394
  })
391
395
  );
392
396
  }
397
+ const connectionError = (message, changed = false) => Object.assign(new Error(message), {
398
+ code: changed && routing.forHost(operation.hostId) ? -32095 : -32090
399
+ });
393
400
  if (!ids.includes(operation.hostId))
394
- throw new Error("Remote Host is offline or no longer known to Desktop");
401
+ throw connectionError("Remote Host is offline or no longer known to Desktop");
395
402
  const route = routing.forHost(operation.hostId);
396
403
  const manager = route?.manager;
397
- if (!route || !manager) throw new Error("Remote Host is offline");
404
+ if (!route || !manager) throw connectionError("Remote Host is offline");
405
+ const read = async (request) => {
406
+ let result;
407
+ try {
408
+ result = await request();
409
+ } catch (error51) {
410
+ if (routing.forHost(operation.hostId) !== route)
411
+ throw connectionError("Remote connection changed during read", true);
412
+ throw error51;
413
+ }
414
+ if (routing.forHost(operation.hostId) !== route)
415
+ throw connectionError("Remote connection changed during read", true);
416
+ return result;
417
+ };
398
418
  let generation = state.managers.get(route);
399
419
  if (!generation) {
400
420
  generation = { epoch: crypto.randomUUID(), answered: /* @__PURE__ */ new Set() };
401
421
  state.managers.set(route, generation);
402
422
  }
403
423
  if ("epoch" in operation && operation.epoch !== generation.epoch)
404
- throw new Error("Remote connection changed; refresh before operating");
424
+ throw connectionError("Remote connection changed; refresh before operating", true);
405
425
  if (operation.kind === "list")
406
- return manager.sendRequest("thread/list", {
407
- cursor: operation.cursor,
408
- archived: operation.archived,
409
- limit: 100
410
- });
426
+ return read(
427
+ () => manager.sendRequest("thread/list", {
428
+ cursor: operation.cursor,
429
+ archived: operation.archived,
430
+ limit: 100
431
+ })
432
+ );
411
433
  const threadId = operation.threadId;
434
+ if (operation.kind === "status") {
435
+ const result = await read(
436
+ () => manager.sendRequest("thread/read", {
437
+ threadId,
438
+ includeTurns: false
439
+ })
440
+ );
441
+ if (result.thread?.id !== threadId || typeof result.thread.status?.type !== "string")
442
+ throw new Error("Invalid remote Thread status");
443
+ let turnId = null;
444
+ if (result.thread.status.type === "active") {
445
+ const page = await read(
446
+ () => manager.sendRequest("thread/turns/list", {
447
+ threadId,
448
+ cursor: null,
449
+ limit: 1,
450
+ sortDirection: "desc",
451
+ itemsView: "notLoaded"
452
+ })
453
+ );
454
+ if (!Array.isArray(page.data)) throw new Error("Invalid remote Turn status");
455
+ const latest = page.data[0];
456
+ if (latest?.status === "inProgress" && typeof latest.id === "string") turnId = latest.id;
457
+ }
458
+ return { threadId, status: result.thread.status.type, turnId, epoch: generation.epoch };
459
+ }
412
460
  const pendingRequests = async () => {
413
- const conversation = await manager.getConversation?.(threadId);
414
- if (routing.forHost(operation.hostId) !== route)
415
- throw new Error("Remote connection changed during interaction read");
461
+ const conversation = await read(() => manager.getConversation?.(threadId));
416
462
  return Array.isArray(conversation?.requests) ? conversation.requests : [];
417
463
  };
418
464
  if (operation.kind === "read") {
419
- let result = await manager.sendRequest("thread/read", { threadId, includeTurns: false });
420
- if (routing.forHost(operation.hostId) !== route)
421
- throw new Error("Remote connection changed during read");
465
+ if (operation.page?.epoch !== void 0 && operation.page.epoch !== generation.epoch)
466
+ throw connectionError(
467
+ "Remote connection changed during history pagination; refresh and retry",
468
+ true
469
+ );
470
+ let result = await read(
471
+ () => manager.sendRequest("thread/read", { threadId, includeTurns: false })
472
+ );
422
473
  const header = result;
423
- if (header.thread?.historyMode === "paginated") {
474
+ let nextCursor = null;
475
+ const requestedPage = operation.page;
476
+ if (header.thread?.historyMode === "paginated" && requestedPage) {
477
+ let limit = requestedPage.limit ?? 20;
478
+ for (; ; ) {
479
+ const response = await read(
480
+ () => manager.sendRequest("thread/turns/list", {
481
+ threadId,
482
+ cursor: requestedPage.cursor,
483
+ limit,
484
+ sortDirection: requestedPage.sortDirection ?? "asc",
485
+ itemsView: "full"
486
+ })
487
+ );
488
+ if (!Array.isArray(response.data) || response.nextCursor !== null && (typeof response.nextCursor !== "string" || response.nextCursor.length === 0))
489
+ throw new Error("Invalid remote history page");
490
+ if (new TextEncoder().encode(JSON.stringify(response.data)).byteLength > 14 * 1024 * 1024) {
491
+ if (response.data.length <= 1 || limit === 1)
492
+ throw Object.assign(
493
+ new Error(
494
+ "A remote Turn exceeds the history page limit; open this chat in Codex Desktop."
495
+ ),
496
+ { code: -32094 }
497
+ );
498
+ limit = Math.max(1, Math.floor(Math.min(limit, response.data.length) / 2));
499
+ continue;
500
+ }
501
+ result = { ...result, thread: { ...header.thread, turns: response.data } };
502
+ nextCursor = response.nextCursor;
503
+ break;
504
+ }
505
+ } else if (header.thread?.historyMode === "paginated") {
424
506
  const turns = [], cursors = /* @__PURE__ */ new Set();
425
507
  let cursor = null, bytes = 0, complete = false;
426
508
  for (let page = 0; page < 100; page++) {
427
509
  if (routing.forHost(operation.hostId) !== route)
428
- throw new Error("Remote connection changed during read");
429
- const response = await manager.sendRequest("thread/turns/list", {
430
- threadId,
431
- cursor,
432
- limit: 50,
433
- sortDirection: "asc",
434
- itemsView: "full"
435
- });
510
+ throw connectionError("Remote connection changed during read", true);
511
+ const response = await read(
512
+ () => manager.sendRequest("thread/turns/list", {
513
+ threadId,
514
+ cursor,
515
+ limit: 50,
516
+ sortDirection: "asc",
517
+ itemsView: "full"
518
+ })
519
+ );
436
520
  if (!Array.isArray(response.data) || response.nextCursor !== null && typeof response.nextCursor !== "string")
437
521
  throw new Error("Invalid remote history page");
438
522
  bytes += new TextEncoder().encode(JSON.stringify(response.data)).byteLength;
@@ -448,9 +532,12 @@ async function rendererRemoteSession(target2, operation) {
448
532
  }
449
533
  if (!complete) throw new Error("Remote history exceeds the page limit");
450
534
  result = { ...result, thread: { ...header.thread, turns } };
451
- } else result = await manager.sendRequest("thread/read", { threadId, includeTurns: true });
535
+ } else
536
+ result = await read(
537
+ () => manager.sendRequest("thread/read", { threadId, includeTurns: true })
538
+ );
452
539
  if (routing.forHost(operation.hostId) !== route)
453
- throw new Error("Remote connection changed during read");
540
+ throw connectionError("Remote connection changed during read", true);
454
541
  let metadata = {};
455
542
  if (header.thread) {
456
543
  const cwd = header.thread.cwd;
@@ -459,7 +546,7 @@ async function rendererRemoteSession(target2, operation) {
459
546
  threadId
460
547
  });
461
548
  if (routing.forHost(operation.hostId) !== route)
462
- throw new Error("Remote connection changed during read");
549
+ throw connectionError("Remote connection changed during read", true);
463
550
  metadata = {
464
551
  configuration,
465
552
  ...configuration.owner === "codex" ? {
@@ -473,7 +560,7 @@ async function rendererRemoteSession(target2, operation) {
473
560
  if (configuration.owner === "codex" && manager.getConversation) {
474
561
  const conversation = await Promise.resolve().then(() => manager.getConversation?.(threadId)).catch(() => void 0);
475
562
  if (routing.forHost(operation.hostId) !== route)
476
- throw new Error("Remote connection changed during read");
563
+ throw connectionError("Remote connection changed during read", true);
477
564
  const settings = conversation?.latestThreadSettings;
478
565
  if (settings?.model === header.thread.model && typeof settings?.model === "string")
479
566
  metadata.nativeSettings = {
@@ -490,7 +577,7 @@ async function rendererRemoteSession(target2, operation) {
490
577
  const loading = Promise.all([
491
578
  Promise.resolve().then(() => {
492
579
  if (routing.forHost(operation.hostId) !== route)
493
- throw new Error("Remote connection changed during read");
580
+ throw connectionError("Remote connection changed during read", true);
494
581
  return manager.sendRequest("codexhost/harness/inspect", {
495
582
  harnessId,
496
583
  ...cwd ? { cwd } : {}
@@ -498,7 +585,7 @@ async function rendererRemoteSession(target2, operation) {
498
585
  }),
499
586
  Promise.resolve().then(() => {
500
587
  if (routing.forHost(operation.hostId) !== route)
501
- throw new Error("Remote connection changed during read");
588
+ throw connectionError("Remote connection changed during read", true);
502
589
  return manager.sendRequest("codexhost/harness/plugins/list", {});
503
590
  }).catch(() => null)
504
591
  ]).then(([inspection, catalog]) => {
@@ -533,12 +620,13 @@ async function rendererRemoteSession(target2, operation) {
533
620
  }
534
621
  }
535
622
  if (routing.forHost(operation.hostId) !== route)
536
- throw new Error("Remote connection changed during read");
623
+ throw connectionError("Remote connection changed during read", true);
537
624
  const requests = await pendingRequests();
538
625
  return {
539
626
  result,
540
627
  ...metadata,
541
628
  epoch: generation.epoch,
629
+ ...operation.page ? { nextCursor } : {},
542
630
  interactionsAvailable: !!manager.getConversation && !!manager.replyWithCommandExecutionApprovalDecision && !!manager.replyWithFileChangeApprovalDecision,
543
631
  requests: requests.filter(
544
632
  (request) => (request.params.threadId ?? request.params.conversationId) === threadId && !generation.answered.has(JSON.stringify([threadId, request.id]))
@@ -591,7 +679,7 @@ async function rendererRemoteSession(target2, operation) {
591
679
  }
592
680
  }
593
681
  case "prompt":
594
- await manager.sendRequest("thread/resume", { threadId });
682
+ await manager.sendRequest("thread/resume", { threadId, excludeTurns: true });
595
683
  if (routing.forHost(operation.hostId) !== route)
596
684
  throw new Error("Remote connection changed during resume");
597
685
  return manager.sendRequest("turn/start", {
@@ -15261,13 +15349,25 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15261
15349
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15262
15350
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15263
15351
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15352
+ var usageOutputTimingSchema = external_exports.object({
15353
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
15354
+ requestId: external_exports.string().min(1),
15355
+ turnId: external_exports.string().min(1).max(1024),
15356
+ outputTokens: nonNegativeSafeIntegerSchema,
15357
+ startedAtMs: nonNegativeSafeIntegerSchema,
15358
+ completedAtMs: nonNegativeSafeIntegerSchema
15359
+ }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
15264
15360
  var usageMeasurementSchema = external_exports.object({
15361
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
15265
15362
  value: finiteNonNegativeNumberSchema,
15266
15363
  turnId: external_exports.string().min(1).max(1024),
15267
15364
  at: nonNegativeSafeIntegerSchema
15268
15365
  }).strict();
15269
15366
  var usageMeasurementsSchema = external_exports.object({
15270
- outputTokensPerSecond: usageMeasurementSchema.optional(),
15367
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
15368
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
15369
+ // Retain independent TTFT facts when dropping incompatible speed measurements.
15370
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
15271
15371
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15272
15372
  }).strict();
15273
15373
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -15287,6 +15387,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15287
15387
  cacheWriteInputTokens: nonNegativeSafeIntegerSchema.optional(),
15288
15388
  outputTokens: nonNegativeSafeIntegerSchema.optional(),
15289
15389
  outputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15390
+ sessionOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15290
15391
  apiOutputTokensPerSecond: finiteNonNegativeNumberSchema.optional(),
15291
15392
  reasoningOutputTokens: nonNegativeSafeIntegerSchema.optional(),
15292
15393
  totalTokens: nonNegativeSafeIntegerSchema.optional(),
@@ -15698,6 +15799,10 @@ var threadSteeringInspectResultSchema = external_exports.object({
15698
15799
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15699
15800
  }).strict();
15700
15801
 
15802
+ // packages/shared-contracts/dist/thread-archive-confirm.js
15803
+ var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15804
+ var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15805
+
15701
15806
  // packages/shared-contracts/dist/client-channel.js
15702
15807
  var CLIENT_CHANNEL_VERSION = 1;
15703
15808
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
@@ -15728,6 +15833,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15728
15833
  cursor: clientChannelCursorSchema,
15729
15834
  cwd: external_exports.string().optional()
15730
15835
  }),
15836
+ external_exports.object({
15837
+ type: external_exports.literal("harness-inspection-changed"),
15838
+ cursor: clientChannelCursorSchema,
15839
+ harnessId: external_exports.string().min(1)
15840
+ }),
15731
15841
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15732
15842
  external_exports.object({
15733
15843
  type: external_exports.literal("preferences-changed"),
@@ -15799,6 +15909,8 @@ var clientItemTruncationSchema = external_exports.object({
15799
15909
  var clientTurnSchema = external_exports.object({
15800
15910
  id: external_exports.string().min(1),
15801
15911
  status: external_exports.string().min(1),
15912
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15913
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15802
15914
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15803
15915
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15804
15916
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -15837,7 +15949,12 @@ var clientThreadSnapshotSchema = external_exports.object({
15837
15949
  /** Current interruptible Host Turn, including command Turns omitted from client history. */
15838
15950
  activeTurnId: external_exports.string().min(1).nullable().optional(),
15839
15951
  /** Most recent explicit command in this Host process; not native conversation history. */
15840
- command: external_exports.object({ name: external_exports.string().min(1), turn: clientTurnSchema }).optional(),
15952
+ command: external_exports.object({
15953
+ name: external_exports.string().min(1),
15954
+ turn: clientTurnSchema,
15955
+ /** First ordinary Turn started after this command; its retained result is not a new event. */
15956
+ subsequentTurnId: external_exports.string().min(1).optional()
15957
+ }).optional(),
15841
15958
  thread: external_exports.object({
15842
15959
  id: external_exports.string().min(1),
15843
15960
  cwd: external_exports.string(),
@@ -16045,7 +16162,6 @@ var webAccessStateSchema = external_exports.object({
16045
16162
  quotaUntil: external_exports.string().optional()
16046
16163
  }).strict().optional()
16047
16164
  }).strict();
16048
- var webLocalAccessRequiredDetailsSchema = external_exports.object({ url: external_exports.string() }).strict();
16049
16165
 
16050
16166
  // packages/shared-contracts/dist/delegation-read.js
16051
16167
  var REMOTE_THREAD_REPLY_MAX_BYTES = 16 * 1024 * 1024;
@@ -17007,6 +17123,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
17007
17123
  "completed",
17008
17124
  "failed",
17009
17125
  "interrupted",
17126
+ "needsInput",
17010
17127
  "timedOut",
17011
17128
  "unreadable",
17012
17129
  "notFound"
@@ -17053,13 +17170,25 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
17053
17170
  var thread = { ...target, threadId: identity };
17054
17171
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17055
17172
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
17173
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
17056
17174
  external_exports.strictObject({
17057
17175
  kind: external_exports.literal("list"),
17058
17176
  ...target,
17059
17177
  cursor: external_exports.string().nullable(),
17060
17178
  archived: external_exports.boolean()
17061
17179
  }),
17062
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
17180
+ external_exports.strictObject({
17181
+ kind: external_exports.literal("read"),
17182
+ ...thread,
17183
+ page: external_exports.strictObject({
17184
+ cursor: external_exports.string().min(1).max(8192).nullable(),
17185
+ epoch: identity.optional(),
17186
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
17187
+ limit: external_exports.number().int().min(1).max(20).optional()
17188
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
17189
+ message: "A history continuation requires its connection epoch"
17190
+ }).optional()
17191
+ }),
17063
17192
  external_exports.strictObject({
17064
17193
  kind: external_exports.literal("configure"),
17065
17194
  ...thread,
@@ -17195,7 +17324,7 @@ var MAX_REPLY_BYTES = 1024 * 1024;
17195
17324
  function remoteConnectionsExpression(input) {
17196
17325
  const request = remoteConnectionsRequestSchema.parse(input);
17197
17326
  if (request.action === "session")
17198
- return `(async () => { try { return {result:await (${rendererRemoteSession.toString()})(window,${JSON.stringify(request.operation)})}; } catch(error) {return {error:{code:-32090,message:String(error?.message ?? error)}};} })()`;
17327
+ return `(async () => { try { return {result:await (${rendererRemoteSession.toString()})(window,${JSON.stringify(request.operation)})}; } catch(error) {return {error:{code:typeof error?.code === "number" ? error.code : -32603,message:String(error?.message ?? error)}};} })()`;
17199
17328
  return `(async () => {
17200
17329
  try {
17201
17330
  const api = window.__codexhostRendererBindingProbeV1;
@@ -17339,7 +17468,7 @@ async function startControllerAttachmentServer(options) {
17339
17468
  JSON.stringify({
17340
17469
  error: {
17341
17470
  code: -32094,
17342
- message: input.action === "session" ? "Remote Thread snapshot exceeds the 16 MiB response limit; open this Thread in Codex Desktop. Paged remote snapshots are not supported." : "Thread snapshot exceeds the 16 MiB response limit; reduce the message page size. Oversized individual results are not supported."
17471
+ message: input.action === "session" ? "Remote history reply exceeds the 16 MiB limit; update codexhost on this computer to use paged history, or open this chat in Codex Desktop." : "Thread snapshot exceeds the 16 MiB response limit; reduce the message page size. Oversized individual results are not supported."
17343
17472
  }
17344
17473
  }) + "\n"
17345
17474
  );
@@ -20322,9 +20451,9 @@ var InstalledRendererCdpControlSession = class {
20322
20451
  await this.renderer.command("Page.bringToFront");
20323
20452
  return 1;
20324
20453
  }
20325
- executeRenderer(expression) {
20454
+ executeRenderer(expression, timeoutMs) {
20326
20455
  if (this.#closed) return Promise.reject(new Error("Renderer CDP Control Session is closed"));
20327
- return this.renderer.evaluate(expression);
20456
+ return this.renderer.evaluate(expression, timeoutMs);
20328
20457
  }
20329
20458
  close() {
20330
20459
  if (this.#closed) return;
@@ -20389,6 +20518,20 @@ var TRANSIENT_INSTALL_RETRY_MS = 250;
20389
20518
  var RECOVERY_RETRY_INITIAL_MS = 3e4;
20390
20519
  var RECOVERY_RETRY_MAX_MS = 3e5;
20391
20520
  var REMOTE_CONNECTION_RECOVERY_INTERVAL_MS = 5e3;
20521
+ var SHUTDOWN_OPERATION_WAIT_MS = 3e3;
20522
+ async function settleWithin(promise2, milliseconds) {
20523
+ let timer;
20524
+ try {
20525
+ await Promise.race([
20526
+ promise2,
20527
+ new Promise((resolve) => {
20528
+ timer = setTimeout(resolve, milliseconds);
20529
+ })
20530
+ ]);
20531
+ } finally {
20532
+ clearTimeout(timer);
20533
+ }
20534
+ }
20392
20535
  var startupTraceStartedAt = Date.now();
20393
20536
  function startupTrace(stage, detail) {
20394
20537
  if (process.env.CODEXHOST_STARTUP_TRACE !== "1") return;
@@ -20606,7 +20749,10 @@ ${rendererSource}`,
20606
20749
  remoteConnections: async (request) => {
20607
20750
  const current = await useSession(() => recoverSession());
20608
20751
  return remoteConnectionsReplySchema.parse(
20609
- await current.executeRenderer(remoteConnectionsExpression(request))
20752
+ await current.executeRenderer(
20753
+ remoteConnectionsExpression(request),
20754
+ request.action === "read-thread" || request.action === "session" ? REMOTE_THREAD_CONTROL_TIMEOUT_MS : 3e4
20755
+ )
20610
20756
  );
20611
20757
  },
20612
20758
  openLocalPage: (url2) => openRendererLocalPage(
@@ -20651,8 +20797,9 @@ ${rendererSource}`,
20651
20797
  }
20652
20798
  } finally {
20653
20799
  await attachmentServer?.close();
20654
- await operation;
20800
+ await settleWithin(operation, SHUTDOWN_OPERATION_WAIT_MS);
20655
20801
  resetSession();
20802
+ void operation.then(resetSession);
20656
20803
  }
20657
20804
  }
20658
20805