@codexhost/cli-darwin-x64 0.20.0 → 0.22.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 (51) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +27 -6
  4. package/app/console-web.js +35 -7
  5. package/app/desktop-controller.mjs +166 -52
  6. package/app/host-runtime.mjs +35350 -28799
  7. package/app/plugins/antigravity/assets/icon.svg +1 -1
  8. package/app/plugins/antigravity/plugin.mjs +411 -231
  9. package/app/plugins/claude-code/plugin.mjs +538 -109
  10. package/app/plugins/codebuddy/plugin.mjs +36 -6
  11. package/app/plugins/codex-usage/plugin.mjs +36 -6
  12. package/app/plugins/copilot/plugin.mjs +28 -6
  13. package/app/plugins/cursor-cli/plugin.mjs +28 -6
  14. package/app/plugins/deepseek-harness/plugin.mjs +53 -11
  15. package/app/plugins/devin/plugin.mjs +28 -6
  16. package/app/plugins/grok/plugin.mjs +255 -192
  17. package/app/plugins/hermes/plugin.mjs +28 -6
  18. package/app/plugins/kimi-code/plugin.mjs +53 -16
  19. package/app/plugins/kiro-cli/plugin.mjs +28 -6
  20. package/app/plugins/omp/plugin.mjs +143 -28
  21. package/app/plugins/opencode/plugin.mjs +54 -15
  22. package/app/plugins/pi/plugin.mjs +154 -29
  23. package/app/plugins/qoder/plugin.mjs +43 -6
  24. package/app/plugins/qoder-cn/plugin.mjs +43 -6
  25. package/app/plugins/qwen-code/plugin.mjs +28 -6
  26. package/app/plugins/workbuddy/plugin.mjs +36 -6
  27. package/app/plugins/zcode/plugin.mjs +36 -6
  28. package/app/renderer-extension.js +27 -6
  29. package/app/web/assets/index-CN4a4sj0.js +201 -0
  30. package/app/web/assets/{index-D6-hvggd.css → index-DJW4bmyx.css} +1 -1
  31. package/app/web/codexhost-settings.js +35 -7
  32. package/app/web/index.html +2 -2
  33. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  34. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +7 -7
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +9 -9
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +6 -6
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +22 -22
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +2 -2
  46. package/app/web-modules/server.mjs +1123 -722
  47. package/bin/codexhost +0 -0
  48. package/libexec/codexhost-shim +0 -0
  49. package/libexec/codexhost-updater +0 -0
  50. package/package.json +1 -1
  51. package/app/web/assets/index-D85gPBbQ.js +0 -201
package/README.md CHANGED
@@ -7,7 +7,7 @@ Run Pi and Claude Code as first-class external harnesses inside Codex Desktop.
7
7
  ## Install
8
8
 
9
9
  ```bash
10
- npm install -g @codexhost/cli@0.20.0
10
+ npm install -g @codexhost/cli@0.22.0
11
11
  ```
12
12
 
13
13
  Do not install this package directly. npm selects it through the optional dependencies of `@codexhost/cli`.
@@ -1 +1 @@
1
- {"schemaVersion":1,"version":"0.20.0","distribution":"npm","target":"macos-x64"}
1
+ {"schemaVersion":1,"version":"0.22.0","distribution":"npm","target":"macos-x64"}
@@ -15621,7 +15621,7 @@ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonneg
15621
15621
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15622
15622
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15623
15623
  var usageOutputTimingSchema = external_exports.object({
15624
- version: external_exports.literal(3).optional(),
15624
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
15625
15625
  requestId: external_exports.string().min(1),
15626
15626
  turnId: external_exports.string().min(1).max(1024),
15627
15627
  outputTokens: nonNegativeSafeIntegerSchema,
@@ -15629,16 +15629,16 @@ var usageOutputTimingSchema = external_exports.object({
15629
15629
  completedAtMs: nonNegativeSafeIntegerSchema
15630
15630
  }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
15631
15631
  var usageMeasurementSchema = external_exports.object({
15632
- version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
15632
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
15633
15633
  value: finiteNonNegativeNumberSchema,
15634
15634
  turnId: external_exports.string().min(1).max(1024),
15635
15635
  at: nonNegativeSafeIntegerSchema
15636
15636
  }).strict();
15637
15637
  var usageMeasurementsSchema = external_exports.object({
15638
- // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
15639
- outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
15638
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
15639
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
15640
15640
  // Retain independent TTFT facts when dropping incompatible speed measurements.
15641
- outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
15641
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
15642
15642
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15643
15643
  }).strict();
15644
15644
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -16104,6 +16104,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
16104
16104
  cursor: clientChannelCursorSchema,
16105
16105
  cwd: external_exports.string().optional()
16106
16106
  }),
16107
+ external_exports.object({
16108
+ type: external_exports.literal("harness-inspection-changed"),
16109
+ cursor: clientChannelCursorSchema,
16110
+ harnessId: external_exports.string().min(1)
16111
+ }),
16107
16112
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
16108
16113
  external_exports.object({
16109
16114
  type: external_exports.literal("preferences-changed"),
@@ -16175,6 +16180,8 @@ var clientItemTruncationSchema = external_exports.object({
16175
16180
  var clientTurnSchema = external_exports.object({
16176
16181
  id: external_exports.string().min(1),
16177
16182
  status: external_exports.string().min(1),
16183
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
16184
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
16178
16185
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
16179
16186
  /** Original file operations, independent of the cumulative Desktop fileChange card.
16180
16187
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -17399,6 +17406,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
17399
17406
  "completed",
17400
17407
  "failed",
17401
17408
  "interrupted",
17409
+ "needsInput",
17402
17410
  "timedOut",
17403
17411
  "unreadable",
17404
17412
  "notFound"
@@ -17445,13 +17453,26 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
17445
17453
  var thread = { ...target, threadId: identity };
17446
17454
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17447
17455
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
17456
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
17448
17457
  external_exports.strictObject({
17449
17458
  kind: external_exports.literal("list"),
17450
17459
  ...target,
17451
17460
  cursor: external_exports.string().nullable(),
17452
17461
  archived: external_exports.boolean()
17453
17462
  }),
17454
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
17463
+ external_exports.strictObject({
17464
+ kind: external_exports.literal("read"),
17465
+ ...thread,
17466
+ page: external_exports.strictObject({
17467
+ cursor: external_exports.string().min(1).max(8192).nullable(),
17468
+ epoch: identity.optional(),
17469
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
17470
+ limit: external_exports.number().int().min(1).max(20).optional()
17471
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
17472
+ message: "A history continuation requires its connection epoch"
17473
+ }).optional()
17474
+ }),
17475
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17455
17476
  external_exports.strictObject({
17456
17477
  kind: external_exports.literal("configure"),
17457
17478
  ...thread,
@@ -14766,7 +14766,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14766
14766
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
14767
14767
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
14768
14768
  var usageOutputTimingSchema = external_exports.object({
14769
- version: external_exports.literal(3).optional(),
14769
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
14770
14770
  requestId: external_exports.string().min(1),
14771
14771
  turnId: external_exports.string().min(1).max(1024),
14772
14772
  outputTokens: nonNegativeSafeIntegerSchema,
@@ -14774,16 +14774,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14774
14774
  completedAtMs: nonNegativeSafeIntegerSchema
14775
14775
  }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
14776
14776
  var usageMeasurementSchema = external_exports.object({
14777
- version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
14777
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
14778
14778
  value: finiteNonNegativeNumberSchema,
14779
14779
  turnId: external_exports.string().min(1).max(1024),
14780
14780
  at: nonNegativeSafeIntegerSchema
14781
14781
  }).strict();
14782
14782
  var usageMeasurementsSchema = external_exports.object({
14783
- // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
14784
- outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
14783
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
14784
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
14785
14785
  // Retain independent TTFT facts when dropping incompatible speed measurements.
14786
- outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
14786
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
14787
14787
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
14788
14788
  }).strict();
14789
14789
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -15250,6 +15250,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15250
15250
  cursor: clientChannelCursorSchema,
15251
15251
  cwd: external_exports.string().optional()
15252
15252
  }),
15253
+ external_exports.object({
15254
+ type: external_exports.literal("harness-inspection-changed"),
15255
+ cursor: clientChannelCursorSchema,
15256
+ harnessId: external_exports.string().min(1)
15257
+ }),
15253
15258
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15254
15259
  external_exports.object({
15255
15260
  type: external_exports.literal("preferences-changed"),
@@ -15321,6 +15326,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15321
15326
  var clientTurnSchema = external_exports.object({
15322
15327
  id: external_exports.string().min(1),
15323
15328
  status: external_exports.string().min(1),
15329
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15330
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15324
15331
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15325
15332
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15326
15333
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -16587,6 +16594,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16587
16594
  "completed",
16588
16595
  "failed",
16589
16596
  "interrupted",
16597
+ "needsInput",
16590
16598
  "timedOut",
16591
16599
  "unreadable",
16592
16600
  "notFound"
@@ -16636,13 +16644,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16636
16644
  var thread = { ...target, threadId: identity };
16637
16645
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16638
16646
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
16647
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
16639
16648
  external_exports.strictObject({
16640
16649
  kind: external_exports.literal("list"),
16641
16650
  ...target,
16642
16651
  cursor: external_exports.string().nullable(),
16643
16652
  archived: external_exports.boolean()
16644
16653
  }),
16645
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
16654
+ external_exports.strictObject({
16655
+ kind: external_exports.literal("read"),
16656
+ ...thread,
16657
+ page: external_exports.strictObject({
16658
+ cursor: external_exports.string().min(1).max(8192).nullable(),
16659
+ epoch: identity.optional(),
16660
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
16661
+ limit: external_exports.number().int().min(1).max(20).optional()
16662
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
16663
+ message: "A history continuation requires its connection epoch"
16664
+ }).optional()
16665
+ }),
16666
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
16646
16667
  external_exports.strictObject({
16647
16668
  kind: external_exports.literal("configure"),
16648
16669
  ...thread,
@@ -17712,11 +17733,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17712
17733
  const webUi = /* @__PURE__ */ new Map();
17713
17734
  const listeners = /* @__PURE__ */ new Set();
17714
17735
  let pending = null;
17736
+ let queuedRefresh = null;
17715
17737
  const publish = () => {
17716
17738
  for (const listener of [...listeners]) listener();
17717
17739
  };
17718
17740
  const inspectAll = (refresh) => {
17719
- if (pending) return pending;
17741
+ if (pending) {
17742
+ if (!refresh) return pending;
17743
+ queuedRefresh ??= pending.then(() => inspectAll(true)).finally(() => {
17744
+ queuedRefresh = null;
17745
+ });
17746
+ return queuedRefresh;
17747
+ }
17720
17748
  pending = Promise.resolve().then(async () => {
17721
17749
  try {
17722
17750
  if (!client.listHarnessPlugins)
@@ -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,131 @@ 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 === "usage")
435
+ return read(() => manager.sendRequest("codexhost/thread/usage/inspect", { threadId }));
436
+ if (operation.kind === "status") {
437
+ const result = await read(
438
+ () => manager.sendRequest("thread/read", {
439
+ threadId,
440
+ includeTurns: false
441
+ })
442
+ );
443
+ if (result.thread?.id !== threadId || typeof result.thread.status?.type !== "string")
444
+ throw new Error("Invalid remote Thread status");
445
+ let turnId = null;
446
+ if (result.thread.status.type === "active") {
447
+ const page = await read(
448
+ () => manager.sendRequest("thread/turns/list", {
449
+ threadId,
450
+ cursor: null,
451
+ limit: 1,
452
+ sortDirection: "desc",
453
+ itemsView: "notLoaded"
454
+ })
455
+ );
456
+ if (!Array.isArray(page.data)) throw new Error("Invalid remote Turn status");
457
+ const latest = page.data[0];
458
+ if (latest?.status === "inProgress" && typeof latest.id === "string") turnId = latest.id;
459
+ }
460
+ return { threadId, status: result.thread.status.type, turnId, epoch: generation.epoch };
461
+ }
412
462
  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");
463
+ const conversation = await read(() => manager.getConversation?.(threadId));
416
464
  return Array.isArray(conversation?.requests) ? conversation.requests : [];
417
465
  };
418
466
  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");
467
+ if (operation.page?.epoch !== void 0 && operation.page.epoch !== generation.epoch)
468
+ throw connectionError(
469
+ "Remote connection changed during history pagination; refresh and retry",
470
+ true
471
+ );
472
+ let result = await read(
473
+ () => manager.sendRequest("thread/read", { threadId, includeTurns: false })
474
+ );
422
475
  const header = result;
423
- if (header.thread?.historyMode === "paginated") {
476
+ let nextCursor = null;
477
+ const requestedPage = operation.page;
478
+ if (header.thread?.historyMode === "paginated" && requestedPage) {
479
+ let limit = requestedPage.limit ?? 20;
480
+ for (; ; ) {
481
+ const response = await read(
482
+ () => manager.sendRequest("thread/turns/list", {
483
+ threadId,
484
+ cursor: requestedPage.cursor,
485
+ limit,
486
+ sortDirection: requestedPage.sortDirection ?? "asc",
487
+ itemsView: "full"
488
+ })
489
+ );
490
+ if (!Array.isArray(response.data) || response.nextCursor !== null && (typeof response.nextCursor !== "string" || response.nextCursor.length === 0))
491
+ throw new Error("Invalid remote history page");
492
+ if (new TextEncoder().encode(JSON.stringify(response.data)).byteLength > 14 * 1024 * 1024) {
493
+ if (response.data.length <= 1 || limit === 1)
494
+ throw Object.assign(
495
+ new Error(
496
+ "A remote Turn exceeds the history page limit; open this chat in Codex Desktop."
497
+ ),
498
+ { code: -32094 }
499
+ );
500
+ limit = Math.max(1, Math.floor(Math.min(limit, response.data.length) / 2));
501
+ continue;
502
+ }
503
+ result = { ...result, thread: { ...header.thread, turns: response.data } };
504
+ nextCursor = response.nextCursor;
505
+ break;
506
+ }
507
+ } else if (header.thread?.historyMode === "paginated") {
424
508
  const turns = [], cursors = /* @__PURE__ */ new Set();
425
509
  let cursor = null, bytes = 0, complete = false;
426
510
  for (let page = 0; page < 100; page++) {
427
511
  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
- });
512
+ throw connectionError("Remote connection changed during read", true);
513
+ const response = await read(
514
+ () => manager.sendRequest("thread/turns/list", {
515
+ threadId,
516
+ cursor,
517
+ limit: 50,
518
+ sortDirection: "asc",
519
+ itemsView: "full"
520
+ })
521
+ );
436
522
  if (!Array.isArray(response.data) || response.nextCursor !== null && typeof response.nextCursor !== "string")
437
523
  throw new Error("Invalid remote history page");
438
524
  bytes += new TextEncoder().encode(JSON.stringify(response.data)).byteLength;
@@ -448,9 +534,12 @@ async function rendererRemoteSession(target2, operation) {
448
534
  }
449
535
  if (!complete) throw new Error("Remote history exceeds the page limit");
450
536
  result = { ...result, thread: { ...header.thread, turns } };
451
- } else result = await manager.sendRequest("thread/read", { threadId, includeTurns: true });
537
+ } else
538
+ result = await read(
539
+ () => manager.sendRequest("thread/read", { threadId, includeTurns: true })
540
+ );
452
541
  if (routing.forHost(operation.hostId) !== route)
453
- throw new Error("Remote connection changed during read");
542
+ throw connectionError("Remote connection changed during read", true);
454
543
  let metadata = {};
455
544
  if (header.thread) {
456
545
  const cwd = header.thread.cwd;
@@ -459,7 +548,7 @@ async function rendererRemoteSession(target2, operation) {
459
548
  threadId
460
549
  });
461
550
  if (routing.forHost(operation.hostId) !== route)
462
- throw new Error("Remote connection changed during read");
551
+ throw connectionError("Remote connection changed during read", true);
463
552
  metadata = {
464
553
  configuration,
465
554
  ...configuration.owner === "codex" ? {
@@ -473,7 +562,7 @@ async function rendererRemoteSession(target2, operation) {
473
562
  if (configuration.owner === "codex" && manager.getConversation) {
474
563
  const conversation = await Promise.resolve().then(() => manager.getConversation?.(threadId)).catch(() => void 0);
475
564
  if (routing.forHost(operation.hostId) !== route)
476
- throw new Error("Remote connection changed during read");
565
+ throw connectionError("Remote connection changed during read", true);
477
566
  const settings = conversation?.latestThreadSettings;
478
567
  if (settings?.model === header.thread.model && typeof settings?.model === "string")
479
568
  metadata.nativeSettings = {
@@ -490,7 +579,7 @@ async function rendererRemoteSession(target2, operation) {
490
579
  const loading = Promise.all([
491
580
  Promise.resolve().then(() => {
492
581
  if (routing.forHost(operation.hostId) !== route)
493
- throw new Error("Remote connection changed during read");
582
+ throw connectionError("Remote connection changed during read", true);
494
583
  return manager.sendRequest("codexhost/harness/inspect", {
495
584
  harnessId,
496
585
  ...cwd ? { cwd } : {}
@@ -498,7 +587,7 @@ async function rendererRemoteSession(target2, operation) {
498
587
  }),
499
588
  Promise.resolve().then(() => {
500
589
  if (routing.forHost(operation.hostId) !== route)
501
- throw new Error("Remote connection changed during read");
590
+ throw connectionError("Remote connection changed during read", true);
502
591
  return manager.sendRequest("codexhost/harness/plugins/list", {});
503
592
  }).catch(() => null)
504
593
  ]).then(([inspection, catalog]) => {
@@ -533,12 +622,13 @@ async function rendererRemoteSession(target2, operation) {
533
622
  }
534
623
  }
535
624
  if (routing.forHost(operation.hostId) !== route)
536
- throw new Error("Remote connection changed during read");
625
+ throw connectionError("Remote connection changed during read", true);
537
626
  const requests = await pendingRequests();
538
627
  return {
539
628
  result,
540
629
  ...metadata,
541
630
  epoch: generation.epoch,
631
+ ...operation.page ? { nextCursor } : {},
542
632
  interactionsAvailable: !!manager.getConversation && !!manager.replyWithCommandExecutionApprovalDecision && !!manager.replyWithFileChangeApprovalDecision,
543
633
  requests: requests.filter(
544
634
  (request) => (request.params.threadId ?? request.params.conversationId) === threadId && !generation.answered.has(JSON.stringify([threadId, request.id]))
@@ -591,7 +681,7 @@ async function rendererRemoteSession(target2, operation) {
591
681
  }
592
682
  }
593
683
  case "prompt":
594
- await manager.sendRequest("thread/resume", { threadId });
684
+ await manager.sendRequest("thread/resume", { threadId, excludeTurns: true });
595
685
  if (routing.forHost(operation.hostId) !== route)
596
686
  throw new Error("Remote connection changed during resume");
597
687
  return manager.sendRequest("turn/start", {
@@ -15262,7 +15352,7 @@ var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonneg
15262
15352
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
15263
15353
  var cacheHitRatePercentSchema = external_exports.number().finite().min(0).max(100);
15264
15354
  var usageOutputTimingSchema = external_exports.object({
15265
- version: external_exports.literal(3).optional(),
15355
+ version: external_exports.union([external_exports.literal(3), external_exports.literal(4)]).optional(),
15266
15356
  requestId: external_exports.string().min(1),
15267
15357
  turnId: external_exports.string().min(1).max(1024),
15268
15358
  outputTokens: nonNegativeSafeIntegerSchema,
@@ -15270,16 +15360,16 @@ var usageOutputTimingSchema = external_exports.object({
15270
15360
  completedAtMs: nonNegativeSafeIntegerSchema
15271
15361
  }).strict().refine((value) => value.completedAtMs > value.startedAtMs);
15272
15362
  var usageMeasurementSchema = external_exports.object({
15273
- version: external_exports.union([external_exports.literal(2), external_exports.literal(3)]).optional(),
15363
+ version: external_exports.union([external_exports.literal(2), external_exports.literal(3), external_exports.literal(4)]).optional(),
15274
15364
  value: finiteNonNegativeNumberSchema,
15275
15365
  turnId: external_exports.string().min(1).max(1024),
15276
15366
  at: nonNegativeSafeIntegerSchema
15277
15367
  }).strict();
15278
15368
  var usageMeasurementsSchema = external_exports.object({
15279
- // Unversioned intervals can omit hidden thinking time; do not restore them into averages.
15280
- outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 3)).optional(),
15369
+ // Older intervals can omit hidden thinking time; do not restore them into averages.
15370
+ outputTimings: external_exports.array(usageOutputTimingSchema).transform((values) => values.filter((value) => value.version === 4)).optional(),
15281
15371
  // Retain independent TTFT facts when dropping incompatible speed measurements.
15282
- outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 3).optional().catch(void 0),
15372
+ outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
15283
15373
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
15284
15374
  }).strict();
15285
15375
  var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
@@ -15745,6 +15835,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15745
15835
  cursor: clientChannelCursorSchema,
15746
15836
  cwd: external_exports.string().optional()
15747
15837
  }),
15838
+ external_exports.object({
15839
+ type: external_exports.literal("harness-inspection-changed"),
15840
+ cursor: clientChannelCursorSchema,
15841
+ harnessId: external_exports.string().min(1)
15842
+ }),
15748
15843
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15749
15844
  external_exports.object({
15750
15845
  type: external_exports.literal("preferences-changed"),
@@ -15816,6 +15911,8 @@ var clientItemTruncationSchema = external_exports.object({
15816
15911
  var clientTurnSchema = external_exports.object({
15817
15912
  id: external_exports.string().min(1),
15818
15913
  status: external_exports.string().min(1),
15914
+ /** Native history has no terminal evidence; Desktop's status vocabulary cannot express this. */
15915
+ codexhostTurnOutcome: external_exports.object({ status: external_exports.literal("unknown"), reason: external_exports.string() }).optional(),
15819
15916
  items: external_exports.array(external_exports.object({ id: external_exports.string().min(1), type: external_exports.string().min(1) }).passthrough()),
15820
15917
  /** Original file operations, independent of the cumulative Desktop fileChange card.
15821
15918
  * Insert before the named non-file Item; null appends at the end of the Turn.
@@ -17028,6 +17125,7 @@ var THREAD_WATCH_NOTICE_OUTCOMES = [
17028
17125
  "completed",
17029
17126
  "failed",
17030
17127
  "interrupted",
17128
+ "needsInput",
17031
17129
  "timedOut",
17032
17130
  "unreadable",
17033
17131
  "notFound"
@@ -17074,13 +17172,26 @@ var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
17074
17172
  var thread = { ...target, threadId: identity };
17075
17173
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17076
17174
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
17175
+ external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
17077
17176
  external_exports.strictObject({
17078
17177
  kind: external_exports.literal("list"),
17079
17178
  ...target,
17080
17179
  cursor: external_exports.string().nullable(),
17081
17180
  archived: external_exports.boolean()
17082
17181
  }),
17083
- external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
17182
+ external_exports.strictObject({
17183
+ kind: external_exports.literal("read"),
17184
+ ...thread,
17185
+ page: external_exports.strictObject({
17186
+ cursor: external_exports.string().min(1).max(8192).nullable(),
17187
+ epoch: identity.optional(),
17188
+ sortDirection: external_exports.enum(["asc", "desc"]).optional(),
17189
+ limit: external_exports.number().int().min(1).max(20).optional()
17190
+ }).refine((page) => page.cursor === null || page.epoch !== void 0, {
17191
+ message: "A history continuation requires its connection epoch"
17192
+ }).optional()
17193
+ }),
17194
+ external_exports.strictObject({ kind: external_exports.literal("usage"), ...thread, epoch: identity }),
17084
17195
  external_exports.strictObject({
17085
17196
  kind: external_exports.literal("configure"),
17086
17197
  ...thread,
@@ -17216,7 +17327,7 @@ var MAX_REPLY_BYTES = 1024 * 1024;
17216
17327
  function remoteConnectionsExpression(input) {
17217
17328
  const request = remoteConnectionsRequestSchema.parse(input);
17218
17329
  if (request.action === "session")
17219
- return `(async () => { try { return {result:await (${rendererRemoteSession.toString()})(window,${JSON.stringify(request.operation)})}; } catch(error) {return {error:{code:-32090,message:String(error?.message ?? error)}};} })()`;
17330
+ 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)}};} })()`;
17220
17331
  return `(async () => {
17221
17332
  try {
17222
17333
  const api = window.__codexhostRendererBindingProbeV1;
@@ -17360,7 +17471,7 @@ async function startControllerAttachmentServer(options) {
17360
17471
  JSON.stringify({
17361
17472
  error: {
17362
17473
  code: -32094,
17363
- 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."
17474
+ 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."
17364
17475
  }
17365
17476
  }) + "\n"
17366
17477
  );
@@ -19203,7 +19314,7 @@ async function installRendererLoadedModules(renderer) {
19203
19314
  };
19204
19315
  try {
19205
19316
  await renderer.command("Runtime.enable");
19206
- await renderer.command("Debugger.enable");
19317
+ await renderer.command("Debugger.enable", { maxScriptsCacheSize: 0 });
19207
19318
  ready = true;
19208
19319
  await flush();
19209
19320
  return dispose;
@@ -20343,9 +20454,9 @@ var InstalledRendererCdpControlSession = class {
20343
20454
  await this.renderer.command("Page.bringToFront");
20344
20455
  return 1;
20345
20456
  }
20346
- executeRenderer(expression) {
20457
+ executeRenderer(expression, timeoutMs) {
20347
20458
  if (this.#closed) return Promise.reject(new Error("Renderer CDP Control Session is closed"));
20348
- return this.renderer.evaluate(expression);
20459
+ return this.renderer.evaluate(expression, timeoutMs);
20349
20460
  }
20350
20461
  close() {
20351
20462
  if (this.#closed) return;
@@ -20641,7 +20752,10 @@ ${rendererSource}`,
20641
20752
  remoteConnections: async (request) => {
20642
20753
  const current = await useSession(() => recoverSession());
20643
20754
  return remoteConnectionsReplySchema.parse(
20644
- await current.executeRenderer(remoteConnectionsExpression(request))
20755
+ await current.executeRenderer(
20756
+ remoteConnectionsExpression(request),
20757
+ request.action === "read-thread" || request.action === "session" ? REMOTE_THREAD_CONTROL_TIMEOUT_MS : 3e4
20758
+ )
20645
20759
  );
20646
20760
  },
20647
20761
  openLocalPage: (url2) => openRendererLocalPage(