@karlorz/codexhost-cli-win32-x64 0.18.0-1 → 0.19.0-1

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 (57) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +59 -2
  4. package/app/console-web.js +98 -8
  5. package/app/cpa-live-voice-hook.js +59 -2
  6. package/app/desktop-controller.mjs +290 -12
  7. package/app/host-runtime.mjs +12896 -2966
  8. package/app/plugins/antigravity/plugin.mjs +654 -216
  9. package/app/plugins/claude-code/plugin.mjs +138 -11
  10. package/app/plugins/codebuddy/plugin.mjs +152 -20
  11. package/app/plugins/codex-usage/plugin.mjs +59 -2
  12. package/app/plugins/copilot/plugin.mjs +59 -2
  13. package/app/plugins/cursor-cli/plugin.mjs +134 -12
  14. package/app/plugins/deepseek-harness/manifest.json +2 -2
  15. package/app/plugins/deepseek-harness/plugin.mjs +86 -7
  16. package/app/plugins/devin/plugin.mjs +59 -2
  17. package/app/plugins/grok/plugin.mjs +1093 -970
  18. package/app/plugins/hermes/plugin.mjs +138 -14
  19. package/app/plugins/kimi-code/plugin.mjs +59 -2
  20. package/app/plugins/kiro-cli/plugin.mjs +287 -18
  21. package/app/plugins/omp/plugin.mjs +789 -628
  22. package/app/plugins/opencode/plugin.mjs +59 -2
  23. package/app/plugins/pi/plugin.mjs +786 -660
  24. package/app/plugins/qoder/plugin.mjs +61 -6
  25. package/app/plugins/qoder-cn/plugin.mjs +61 -6
  26. package/app/plugins/qwen-code/plugin.mjs +168 -94
  27. package/app/plugins/workbuddy/plugin.mjs +152 -20
  28. package/app/plugins/zcode/plugin.mjs +132 -5
  29. package/app/renderer-extension.js +434 -39
  30. package/app/web/assets/{index-py6Ho-Dy.js → index-BCyiiDDL.js} +62 -62
  31. package/app/web/assets/index-BNQIOOHE.css +1 -0
  32. package/app/web/codexhost-settings.js +84 -4
  33. package/app/web/index.html +2 -2
  34. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +8 -8
  36. package/app/web/plugins/deepseek-ai__dsh-client-file-upload/client.js +1 -1
  37. package/app/web/plugins/deepseek-ai__dsh-client-locale/client.js +3 -3
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-attachment/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +129 -8
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +8 -6
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +95 -93
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.excel.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +16 -16
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +1 -1
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +11 -11
  51. package/app/web-modules/server.mjs +2345 -1518
  52. package/bin/codexhost.exe +0 -0
  53. package/libexec/codexhost-node-repl.exe +0 -0
  54. package/libexec/codexhost-shim.exe +0 -0
  55. package/libexec/codexhost-updater.exe +0 -0
  56. package/package.json +1 -1
  57. package/app/web/assets/index-C3lniEH1.css +0 -1
@@ -326,15 +326,58 @@ async function rendererRemoteSession(target2, operation) {
326
326
  return ids.map((hostId2) => ({ hostId: hostId2, online: !!routing.forHost(hostId2) }));
327
327
  const configured = await api.remoteConnections({ action: "catalog" });
328
328
  const connections = Array.isArray(configured) ? configured : [];
329
- const attempts = state.reconnectAttempts ??= /* @__PURE__ */ new Set();
329
+ const previous = state.reconnectAttempts;
330
+ const attempts = state.reconnectAttempts = previous && !("get" in previous) ? new Map([...previous].map((id) => [id, { failures: 0, retryAt: Infinity }])) : previous ?? /* @__PURE__ */ new Map();
330
331
  return Promise.all(
331
332
  [.../* @__PURE__ */ new Set([...ids, ...connections.map((c) => c.hostId)])].map(async (hostId2) => {
332
333
  const connection = connections.find((c) => c.hostId === hostId2);
333
334
  let status = await api.remoteConnections({ action: "state", hostId: hostId2 }).catch(() => ({ state: "error" }));
334
- if (connection?.autoConnect === false) attempts.delete(hostId2);
335
- if (connection?.autoConnect && status.state === "disconnected" && !attempts.has(hostId2)) {
336
- attempts.add(hostId2);
337
- await api.remoteConnections({ action: "connect", hostId: hostId2, enabled: true }).catch(() => void 0);
335
+ if (connection?.autoConnect === false || status.state === "connected")
336
+ attempts.delete(hostId2);
337
+ if (connection?.autoConnect && status.state === "disconnected") {
338
+ let attempt = attempts.get(hostId2);
339
+ if (!attempt || !attempt.loading && Date.now() >= attempt.retryAt) {
340
+ attempt ??= { failures: 0, retryAt: Infinity };
341
+ const current = attempt;
342
+ current.retryAt = Infinity;
343
+ attempts.set(hostId2, current);
344
+ current.loading = Promise.resolve().then(async () => {
345
+ try {
346
+ const latestStatus = await api.remoteConnections({ action: "state", hostId: hostId2 });
347
+ const latest = await api.remoteConnections({ action: "catalog" });
348
+ if (attempts.get(hostId2) !== current || !Array.isArray(latest) || !latest.some((c) => c.hostId === hostId2 && c.autoConnect === true) || latestStatus.state !== "disconnected") {
349
+ if (attempts.get(hostId2) === current) attempts.delete(hostId2);
350
+ return;
351
+ }
352
+ let acknowledged = false;
353
+ let failureCode;
354
+ try {
355
+ await api.remoteConnections({ action: "connect", hostId: hostId2, enabled: true });
356
+ acknowledged = true;
357
+ } catch (error51) {
358
+ failureCode = error51?.code;
359
+ }
360
+ const result = await api.remoteConnections({ action: "state", hostId: hostId2 });
361
+ const failed = acknowledged || [
362
+ "ECONNREFUSED",
363
+ "ECONNRESET",
364
+ "ENETUNREACH",
365
+ "EHOSTUNREACH",
366
+ "ENOTFOUND",
367
+ "EAI_AGAIN"
368
+ ].includes(String(failureCode));
369
+ if (failed && result.state === "disconnected" && result.error) {
370
+ current.failures = Math.min(current.failures + 1, 4);
371
+ current.retryAt = Date.now() + Math.min(3e4, 5e3 * 2 ** (current.failures - 1));
372
+ }
373
+ } catch {
374
+ } finally {
375
+ delete current.loading;
376
+ }
377
+ });
378
+ attempt = current;
379
+ }
380
+ await attempt.loading;
338
381
  status = await api.remoteConnections({ action: "state", hostId: hostId2 }).catch(() => ({ state: "error" }));
339
382
  }
340
383
  return {
@@ -372,12 +415,128 @@ async function rendererRemoteSession(target2, operation) {
372
415
  return Array.isArray(conversation?.requests) ? conversation.requests : [];
373
416
  };
374
417
  if (operation.kind === "read") {
375
- const result = await manager.sendRequest("thread/read", { threadId, includeTurns: true });
418
+ let result = await manager.sendRequest("thread/read", { threadId, includeTurns: false });
419
+ if (routing.forHost(operation.hostId) !== route)
420
+ throw new Error("Remote connection changed during read");
421
+ const header = result;
422
+ if (header.thread?.historyMode === "paginated") {
423
+ const turns = [], cursors = /* @__PURE__ */ new Set();
424
+ let cursor = null, bytes = 0, complete = false;
425
+ for (let page = 0; page < 100; page++) {
426
+ if (routing.forHost(operation.hostId) !== route)
427
+ throw new Error("Remote connection changed during read");
428
+ const response = await manager.sendRequest("thread/turns/list", {
429
+ threadId,
430
+ cursor,
431
+ limit: 50,
432
+ sortDirection: "asc",
433
+ itemsView: "full"
434
+ });
435
+ if (!Array.isArray(response.data) || response.nextCursor !== null && typeof response.nextCursor !== "string")
436
+ throw new Error("Invalid remote history page");
437
+ bytes += new TextEncoder().encode(JSON.stringify(response.data)).byteLength;
438
+ if (bytes > 14 * 1024 * 1024) throw new Error("Remote history exceeds the snapshot limit");
439
+ turns.push(...response.data);
440
+ cursor = response.nextCursor;
441
+ if (cursor === null) {
442
+ complete = true;
443
+ break;
444
+ }
445
+ if (cursors.has(cursor)) throw new Error("Remote history cursor repeated");
446
+ cursors.add(cursor);
447
+ }
448
+ if (!complete) throw new Error("Remote history exceeds the page limit");
449
+ result = { ...result, thread: { ...header.thread, turns } };
450
+ } else result = await manager.sendRequest("thread/read", { threadId, includeTurns: true });
451
+ if (routing.forHost(operation.hostId) !== route)
452
+ throw new Error("Remote connection changed during read");
453
+ let metadata = {};
454
+ if (header.thread) {
455
+ const cwd = header.thread.cwd;
456
+ try {
457
+ const configuration = await manager.sendRequest("codexhost/thread/inspect", {
458
+ threadId
459
+ });
460
+ if (routing.forHost(operation.hostId) !== route)
461
+ throw new Error("Remote connection changed during read");
462
+ metadata = {
463
+ configuration,
464
+ ...configuration.owner === "codex" ? {
465
+ nativeSettings: {
466
+ model: header.thread.model,
467
+ reasoningEffort: header.thread.reasoningEffort,
468
+ serviceTier: header.thread.serviceTier
469
+ }
470
+ } : {}
471
+ };
472
+ if (configuration.owner === "codex" && manager.getConversation) {
473
+ const conversation = await Promise.resolve().then(() => manager.getConversation?.(threadId)).catch(() => void 0);
474
+ if (routing.forHost(operation.hostId) !== route)
475
+ throw new Error("Remote connection changed during read");
476
+ const settings = conversation?.latestThreadSettings;
477
+ if (settings?.model === header.thread.model && typeof settings?.model === "string")
478
+ metadata.nativeSettings = {
479
+ model: settings.model,
480
+ reasoningEffort: header.thread.reasoningEffort === void 0 ? settings.effort : header.thread.reasoningEffort,
481
+ serviceTier: header.thread.serviceTier === void 0 ? settings.serviceTier : header.thread.serviceTier
482
+ };
483
+ }
484
+ if (configuration.owner === "codex" || configuration.owner === "external" && configuration.harnessId) {
485
+ const harnessId = configuration.owner === "codex" ? "codex" : configuration.harnessId ?? "codex", key = JSON.stringify([harnessId, cwd]);
486
+ const cache = generation.metadata ??= /* @__PURE__ */ new Map();
487
+ let discovery = cache.get(key);
488
+ if (!discovery || Date.now() >= discovery.retryAt) {
489
+ const loading = Promise.all([
490
+ Promise.resolve().then(() => {
491
+ if (routing.forHost(operation.hostId) !== route)
492
+ throw new Error("Remote connection changed during read");
493
+ return manager.sendRequest("codexhost/harness/inspect", {
494
+ harnessId,
495
+ ...cwd ? { cwd } : {}
496
+ });
497
+ }),
498
+ Promise.resolve().then(() => {
499
+ if (routing.forHost(operation.hostId) !== route)
500
+ throw new Error("Remote connection changed during read");
501
+ return manager.sendRequest("codexhost/harness/plugins/list", {});
502
+ }).catch(() => null)
503
+ ]).then(([inspection, catalog]) => {
504
+ if (inspection?.status !== "ready")
505
+ throw new Error("Remote Harness discovery is unavailable");
506
+ return {
507
+ inspection,
508
+ harness: catalog?.plugins?.find(
509
+ (p) => p.id === harnessId
510
+ )
511
+ };
512
+ });
513
+ const attempt = {
514
+ loading,
515
+ failures: discovery?.failures ?? 0,
516
+ retryAt: Infinity
517
+ };
518
+ void loading.catch(() => {
519
+ attempt.failures = Math.min(attempt.failures + 1, 4);
520
+ attempt.retryAt = Date.now() + Math.min(3e4, 5e3 * 2 ** (attempt.failures - 1));
521
+ });
522
+ discovery = attempt;
523
+ if (cache.size >= 64 && !cache.has(key)) {
524
+ const oldest = cache.keys().next().value;
525
+ if (oldest !== void 0) cache.delete(oldest);
526
+ }
527
+ cache.set(key, discovery);
528
+ }
529
+ metadata = { ...metadata, ...await discovery.loading };
530
+ }
531
+ } catch {
532
+ }
533
+ }
376
534
  if (routing.forHost(operation.hostId) !== route)
377
535
  throw new Error("Remote connection changed during read");
378
536
  const requests = await pendingRequests();
379
537
  return {
380
538
  result,
539
+ ...metadata,
381
540
  epoch: generation.epoch,
382
541
  interactionsAvailable: !!manager.getConversation && !!manager.replyWithCommandExecutionApprovalDecision && !!manager.replyWithFileChangeApprovalDecision,
383
542
  requests: requests.filter(
@@ -402,6 +561,34 @@ async function rendererRemoteSession(target2, operation) {
402
561
  return { accepted: true };
403
562
  }
404
563
  switch (operation.kind) {
564
+ case "configure": {
565
+ const configuration = await manager.sendRequest("codexhost/thread/inspect", {
566
+ threadId
567
+ });
568
+ if (routing.forHost(operation.hostId) !== route)
569
+ throw new Error("Remote connection changed during configuration");
570
+ if (configuration.owner !== "external" && configuration.owner !== "codex")
571
+ throw new Error("Remote Thread configuration is unavailable");
572
+ let method, params;
573
+ if (operation.modelId !== void 0) {
574
+ method = "codexhost/thread/model/select";
575
+ params = { threadId, model: { id: operation.modelId } };
576
+ } else if (operation.thinkingOptionId !== void 0) {
577
+ method = "codexhost/thread/thinking/select";
578
+ params = { threadId, thinkingOptionId: operation.thinkingOptionId };
579
+ } else {
580
+ method = "codexhost/thread/permission-mode/select";
581
+ params = { threadId, permissionModeId: operation.permissionModeId };
582
+ }
583
+ try {
584
+ const result = await manager.sendRequest(method, params);
585
+ if (routing.forHost(operation.hostId) !== route)
586
+ throw new Error("Remote connection changed during configuration");
587
+ return result;
588
+ } finally {
589
+ generation.metadata?.clear();
590
+ }
591
+ }
405
592
  case "prompt":
406
593
  await manager.sendRequest("thread/resume", { threadId });
407
594
  if (routing.forHost(operation.hostId) !== route)
@@ -15945,6 +16132,10 @@ var CLIENT_CHANNEL_VERSION = 1;
15945
16132
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15946
16133
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15947
16134
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
16135
+ var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
16136
+ var clientThreadTreeSchema = external_exports.object({
16137
+ parents: external_exports.record(external_exports.string().min(1), external_exports.string().min(1))
16138
+ }).strict();
15948
16139
  var clientProjectlessWorkspaceSchema = external_exports.object({
15949
16140
  prompt: external_exports.string().max(16384).optional()
15950
16141
  }).strict();
@@ -15961,6 +16152,11 @@ var clientChannelCursorSchema = external_exports.object({
15961
16152
  sequence: external_exports.number().int().nonnegative()
15962
16153
  });
15963
16154
  var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
16155
+ external_exports.object({
16156
+ type: external_exports.literal("skills-changed"),
16157
+ cursor: clientChannelCursorSchema,
16158
+ cwd: external_exports.string().optional()
16159
+ }),
15964
16160
  external_exports.object({ type: external_exports.literal("display-settings-changed"), cursor: clientChannelCursorSchema }),
15965
16161
  external_exports.object({
15966
16162
  type: external_exports.literal("preferences-changed"),
@@ -16158,6 +16354,28 @@ var voiceTranscribeResultSchema = external_exports.discriminatedUnion("ok", [
16158
16354
  external_exports.object({ ok: external_exports.literal(false), error: external_exports.object({ code: voiceErrorCodeSchema }).strict() }).strict()
16159
16355
  ]);
16160
16356
 
16357
+ // packages/shared-contracts/dist/skills.js
16358
+ var skillsListParamsSchema = external_exports.object({
16359
+ threadId: hostThreadIdSchema.optional(),
16360
+ cwd: external_exports.string().min(1).optional()
16361
+ }).strict().refine((params) => !(params.threadId && params.cwd), {
16362
+ message: "Specify threadId or cwd, not both"
16363
+ });
16364
+ var librarySkillSchema = external_exports.object({
16365
+ name: external_exports.string().min(1).regex(/^[^\s[\]]+$/u),
16366
+ description: external_exports.string().optional(),
16367
+ path: external_exports.string().min(1),
16368
+ scope: external_exports.enum(["project", "global"]),
16369
+ source: external_exports.string().min(1)
16370
+ }).strict();
16371
+ var skillsListResultSchema = external_exports.object({
16372
+ revision: external_exports.number().int().nonnegative(),
16373
+ complete: external_exports.boolean(),
16374
+ skills: external_exports.array(librarySkillSchema),
16375
+ warnings: external_exports.array(external_exports.string()).optional()
16376
+ }).strict();
16377
+ var skillsChangedParamsSchema = external_exports.object({ cwd: external_exports.string().min(1).optional() }).strict();
16378
+
16161
16379
  // packages/shared-contracts/dist/web-access-tokens.js
16162
16380
  var webNetworkAccessUrlSchema = external_exports.object({
16163
16381
  /**
@@ -16264,8 +16482,8 @@ var REMOTE_THREAD_CONTROL_TIMEOUT_MS = 4e4;
16264
16482
  var delegationReadParamsSchema = external_exports.strictObject({
16265
16483
  threadId: external_exports.string().min(1).max(1024),
16266
16484
  view: external_exports.enum(["result", "messages"]),
16267
- cursor: external_exports.string().min(1).max(8192).optional(),
16268
- limit: external_exports.number().int().min(1).max(100).optional()
16485
+ from: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional(),
16486
+ to: external_exports.number().int().min(1).max(Number.MAX_SAFE_INTEGER).optional()
16269
16487
  });
16270
16488
 
16271
16489
  // packages/shared-contracts/dist/credential-imports.js
@@ -17272,6 +17490,17 @@ var updateStatusResultSchema = external_exports.strictObject({
17272
17490
  status: updateStatusSchema.nullable()
17273
17491
  });
17274
17492
 
17493
+ // packages/shared-contracts/dist/thread-watch-notice.js
17494
+ var THREAD_WATCH_NOTICE_OUTCOMES = [
17495
+ "completed",
17496
+ "failed",
17497
+ "interrupted",
17498
+ "timedOut",
17499
+ "unreadable",
17500
+ "notFound"
17501
+ ];
17502
+ var ENTRY_PATTERN = new RegExp(String.raw`^- \[([^\]\n]+)\]\(thread://([^\s()<>"?#/]+)\): ` + `(${THREAD_WATCH_NOTICE_OUTCOMES.join("|")})(?:. (.+))?$`, "u");
17503
+
17275
17504
  // packages/shared-contracts/dist/remote-runtime.js
17276
17505
  var remoteUpdatePhaseSchema = external_exports.enum([
17277
17506
  "idle",
@@ -17319,6 +17548,14 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17319
17548
  archived: external_exports.boolean()
17320
17549
  }),
17321
17550
  external_exports.strictObject({ kind: external_exports.literal("read"), ...thread }),
17551
+ external_exports.strictObject({
17552
+ kind: external_exports.literal("configure"),
17553
+ ...thread,
17554
+ epoch: identity,
17555
+ modelId: identity.optional(),
17556
+ thinkingOptionId: identity.optional(),
17557
+ permissionModeId: identity.optional()
17558
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17322
17559
  external_exports.strictObject({
17323
17560
  kind: external_exports.literal("prompt"),
17324
17561
  ...thread,
@@ -17391,6 +17628,13 @@ var remoteConnectionsReplySchema = external_exports.union([
17391
17628
  external_exports.strictObject({ error: external_exports.strictObject({ code: external_exports.number().int(), message: external_exports.string() }) })
17392
17629
  ]);
17393
17630
 
17631
+ // packages/shared-contracts/dist/thread-title.js
17632
+ var threadTitleInputSchema = external_exports.strictObject({
17633
+ prompt: external_exports.string().trim().min(1).max(2e3),
17634
+ cwd: external_exports.string().max(4096).nullable()
17635
+ });
17636
+ var threadTitleResultSchema = external_exports.string().trim().min(1).max(60).nullable();
17637
+
17394
17638
  // packages/shared-contracts/dist/web-ui-extensions.js
17395
17639
  var webUiExtensionIdSchema = external_exports.string().max(214).regex(/^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/u);
17396
17640
  var localizedTextSchema2 = external_exports.union([
@@ -19414,8 +19658,9 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
19414
19658
  model2 = carrier ? prewarmCarrier(carrier) : null;
19415
19659
  }
19416
19660
  if (!model2) return message;
19417
- if (path7[0] === "startConversation" && nativeModel?.startsWith("codexhost/") && nativeModel !== model2)
19418
- return message;
19661
+ if (path7[0] === "startConversation" && nativeModel?.startsWith("codexhost/"))
19662
+ model2 = nativeModel;
19663
+ const config2 = input.config == null ? { model: model2 } : isRecord4(input.config) ? { model: model2, ...input.config } : input.config;
19419
19664
  return [
19420
19665
  "push",
19421
19666
  [
@@ -19425,6 +19670,7 @@ function installRendererHostRpcRouting(root, target2, dependencies) {
19425
19670
  [
19426
19671
  {
19427
19672
  ...input,
19673
+ ...path7[0] === "startConversation" ? { config: config2 } : {},
19428
19674
  collaborationMode: { ...input.collaborationMode, settings: { ...settings, model: model2 } }
19429
19675
  },
19430
19676
  ...args.slice(1)
@@ -22396,6 +22642,21 @@ var TRANSIENT_INSTALL_ATTEMPTS = 3;
22396
22642
  var TRANSIENT_INSTALL_RETRY_MS = 250;
22397
22643
  var RECOVERY_RETRY_INITIAL_MS = 3e4;
22398
22644
  var RECOVERY_RETRY_MAX_MS = 3e5;
22645
+ var REMOTE_CONNECTION_RECOVERY_INTERVAL_MS = 5e3;
22646
+ var SHUTDOWN_OPERATION_WAIT_MS = 3e3;
22647
+ async function settleWithin(promise2, milliseconds) {
22648
+ let timer;
22649
+ try {
22650
+ await Promise.race([
22651
+ promise2,
22652
+ new Promise((resolve) => {
22653
+ timer = setTimeout(resolve, milliseconds);
22654
+ })
22655
+ ]);
22656
+ } finally {
22657
+ clearTimeout(timer);
22658
+ }
22659
+ }
22399
22660
  var startupTraceStartedAt = Date.now();
22400
22661
  function startupTrace(stage, detail) {
22401
22662
  if (process.env.CODEXHOST_STARTUP_TRACE !== "1") return;
@@ -22624,6 +22885,21 @@ ${bootstrap}${rendererSource}`,
22624
22885
  );
22625
22886
  return next;
22626
22887
  };
22888
+ let remoteRecovery;
22889
+ let nextRemoteRecoveryAt = 0;
22890
+ const restoreRemoteConnections = (current) => {
22891
+ if (signal.aborted || remoteRecovery || now() < nextRemoteRecoveryAt) return;
22892
+ nextRemoteRecoveryAt = now() + REMOTE_CONNECTION_RECOVERY_INTERVAL_MS;
22893
+ remoteRecovery = Promise.resolve().then(() => {
22894
+ if (!signal.aborted && session === current)
22895
+ return current.executeRenderer(
22896
+ remoteConnectionsExpression({ action: "session", operation: { kind: "hosts" } })
22897
+ );
22898
+ return void 0;
22899
+ }).catch(() => void 0).finally(() => {
22900
+ remoteRecovery = void 0;
22901
+ });
22902
+ };
22627
22903
  const resetSession = () => {
22628
22904
  session?.close();
22629
22905
  session = void 0;
@@ -22685,6 +22961,7 @@ ${bootstrap}${rendererSource}`,
22685
22961
  try {
22686
22962
  session = await createSession();
22687
22963
  recordRecoverySuccess();
22964
+ restoreRemoteConnections(session);
22688
22965
  } catch (error51) {
22689
22966
  startupTrace("initial Renderer Session unavailable", error51);
22690
22967
  session = void 0;
@@ -22697,16 +22974,17 @@ ${bootstrap}${rendererSource}`,
22697
22974
  await useSession(async () => {
22698
22975
  if (!session && now() < nextRecoveryAt) return;
22699
22976
  try {
22700
- await recoverSession();
22977
+ restoreRemoteConnections(await recoverSession());
22701
22978
  } catch {
22702
22979
  }
22703
22980
  });
22704
22981
  }
22705
22982
  } finally {
22706
22983
  await attachmentServer?.close();
22707
- await operation;
22984
+ await settleWithin(operation, SHUTDOWN_OPERATION_WAIT_MS);
22708
22985
  resetSession();
22709
22986
  voiceHost?.close();
22987
+ void operation.then(resetSession);
22710
22988
  }
22711
22989
  }
22712
22990