@karlorz/codexhost-cli-linux-x64 0.14.0-0 → 0.14.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.
@@ -23314,7 +23314,7 @@ function retainRendererHostResponses(client, hostId2, target) {
23314
23314
  if (typeof client.addRequestLifecycleListener !== "function" || typeof target.addEventListener !== "function" || typeof target.removeEventListener !== "function")
23315
23315
  return () => {
23316
23316
  };
23317
- const isRecord21 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
23317
+ const isRecord22 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
23318
23318
  const pending = /* @__PURE__ */ new Set();
23319
23319
  let retired = false;
23320
23320
  let unsubscribe = () => {
@@ -23330,15 +23330,15 @@ function retainRendererHostResponses(client, hostId2, target) {
23330
23330
  const ownOrigin = target.location?.origin;
23331
23331
  if (source === target && ownOrigin && ownOrigin !== "null" && origin !== ownOrigin)
23332
23332
  return;
23333
- if (!isRecord21(data) || data.type !== "mcp-response" || data.hostId !== hostId2)
23333
+ if (!isRecord22(data) || data.type !== "mcp-response" || data.hostId !== hostId2)
23334
23334
  return;
23335
23335
  const message2 = data.message;
23336
- if (!isRecord21(message2))
23336
+ if (!isRecord22(message2))
23337
23337
  return;
23338
23338
  const id2 = message2.id;
23339
23339
  if (typeof id2 !== "string" && typeof id2 !== "number" || !pending.has(id2))
23340
23340
  return;
23341
- const hasError = isRecord21(message2.error);
23341
+ const hasError = isRecord22(message2.error);
23342
23342
  if (!hasError && !Object.prototype.hasOwnProperty.call(message2, "result"))
23343
23343
  return;
23344
23344
  queueMicrotask(() => {
@@ -23352,7 +23352,7 @@ function retainRendererHostResponses(client, hostId2, target) {
23352
23352
  };
23353
23353
  target.addEventListener("message", receive);
23354
23354
  unsubscribe = client.addRequestLifecycleListener((event) => {
23355
- if (!isRecord21(event) || event.hostId !== hostId2)
23355
+ if (!isRecord22(event) || event.hostId !== hostId2)
23356
23356
  return;
23357
23357
  const id2 = event.id;
23358
23358
  if (typeof id2 !== "string" && typeof id2 !== "number")
@@ -23382,13 +23382,13 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23382
23382
  let selectedModel = null;
23383
23383
  let prewarmGeneration = 0;
23384
23384
  const externalPrewarms = /* @__PURE__ */ new Set();
23385
- const isRecord21 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
23385
+ const isRecord22 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
23386
23386
  const isUnsupportedPosixBridgeSpawn = (value2) => {
23387
23387
  const marker = "AbsolutePathBuf deserialized without a base path";
23388
23388
  if (typeof value2 === "string") {
23389
23389
  return value2.startsWith("Invalid request:") && value2.includes(marker);
23390
23390
  }
23391
- if (!isRecord21(value2))
23391
+ if (!isRecord22(value2))
23392
23392
  return false;
23393
23393
  if (typeof value2.message === "string" && value2.message.includes(marker)) {
23394
23394
  if (value2.code === -32600 || value2.message.startsWith("Invalid request:"))
@@ -23481,7 +23481,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23481
23481
  bridgeState = "idle";
23482
23482
  };
23483
23483
  const rememberExternalThread = (value2) => {
23484
- if (!isRecord21(value2) || typeof value2.id !== "string")
23484
+ if (!isRecord22(value2) || typeof value2.id !== "string")
23485
23485
  return;
23486
23486
  if (value2.modelProvider === "codexhost" || value2.cliVersion === "codexhost") {
23487
23487
  knownExternalThreadIds.add(value2.id);
@@ -23489,7 +23489,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23489
23489
  }
23490
23490
  };
23491
23491
  const observeBridgeResult = (request, result) => {
23492
- if (!request || !isRecord21(result))
23492
+ if (!request || !isRecord22(result))
23493
23493
  return;
23494
23494
  if (request.method === "thread/list" && Array.isArray(result.data)) {
23495
23495
  for (const thread of result.data)
@@ -23500,7 +23500,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23500
23500
  rememberExternalThread(result.thread);
23501
23501
  return;
23502
23502
  }
23503
- if (request.method === "codexhost/thread/inspect" && isRecord21(request.parameters) && typeof request.parameters.threadId === "string") {
23503
+ if (request.method === "codexhost/thread/inspect" && isRecord22(request.parameters) && typeof request.parameters.threadId === "string") {
23504
23504
  if (result.owner === "external") {
23505
23505
  knownExternalThreadIds.add(request.parameters.threadId);
23506
23506
  knownOfficialThreadIds.delete(request.parameters.threadId);
@@ -23510,18 +23510,18 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23510
23510
  }
23511
23511
  return;
23512
23512
  }
23513
- if (request.method === "thread/delete" && isRecord21(request.parameters) && typeof request.parameters.threadId === "string") {
23513
+ if (request.method === "thread/delete" && isRecord22(request.parameters) && typeof request.parameters.threadId === "string") {
23514
23514
  knownExternalThreadIds.delete(request.parameters.threadId);
23515
23515
  knownOfficialThreadIds.delete(request.parameters.threadId);
23516
23516
  }
23517
23517
  };
23518
23518
  const handleBridgeFrame = (value2) => {
23519
- if (!isRecord21(value2)) {
23519
+ if (!isRecord22(value2)) {
23520
23520
  failBridge("received a non-object app-server frame");
23521
23521
  return;
23522
23522
  }
23523
23523
  if (value2.method === bridgeReadyMethod && value2.id === void 0) {
23524
- if (isRecord21(value2.params) && value2.params.protocolVersion === 1) {
23524
+ if (isRecord22(value2.params) && value2.params.protocolVersion === 1) {
23525
23525
  bridgeState = "ready";
23526
23526
  if (bridgeReadyTimeout !== null)
23527
23527
  globalThis.clearTimeout(bridgeReadyTimeout);
@@ -23535,7 +23535,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23535
23535
  return;
23536
23536
  }
23537
23537
  if (typeof value2.method === "string" && value2.id === void 0) {
23538
- if (value2.method === "thread/started" && isRecord21(value2.params)) {
23538
+ if (value2.method === "thread/started" && isRecord22(value2.params)) {
23539
23539
  rememberExternalThread(value2.params.thread);
23540
23540
  }
23541
23541
  originalOnNotification.call(manager, value2.method, value2.params);
@@ -23586,13 +23586,13 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23586
23586
  }
23587
23587
  };
23588
23588
  const handleOuterNotification = (method, parameters) => {
23589
- if (method === "process/exited" && isRecord21(parameters) && parameters.processHandle === bridgeProcessHandle) {
23589
+ if (method === "process/exited" && isRecord22(parameters) && parameters.processHandle === bridgeProcessHandle) {
23590
23590
  const exitCode = typeof parameters.exitCode === "number" ? parameters.exitCode : "unknown";
23591
23591
  const stderr = typeof parameters.stderr === "string" ? parameters.stderr.trim() : "";
23592
23592
  failBridge(`process exited unexpectedly with code ${exitCode}${stderr ? `: ${stderr}` : ""}`, false);
23593
23593
  return true;
23594
23594
  }
23595
- if (method !== "process/outputDelta" || !isRecord21(parameters) || parameters.processHandle !== bridgeProcessHandle || parameters.stream !== "stdout" && parameters.stream !== "stderr" || typeof parameters.deltaBase64 !== "string") {
23595
+ if (method !== "process/outputDelta" || !isRecord22(parameters) || parameters.processHandle !== bridgeProcessHandle || parameters.stream !== "stdout" && parameters.stream !== "stderr" || typeof parameters.deltaBase64 !== "string") {
23596
23596
  return false;
23597
23597
  }
23598
23598
  if (parameters.capReached === true) {
@@ -23696,7 +23696,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23696
23696
  return bridgeInitialization;
23697
23697
  };
23698
23698
  const threadIdFromParameters = (parameters) => {
23699
- if (!isRecord21(parameters))
23699
+ if (!isRecord22(parameters))
23700
23700
  return null;
23701
23701
  const value2 = parameters.threadId ?? parameters.conversationId;
23702
23702
  return typeof value2 === "string" ? value2 : null;
@@ -23713,9 +23713,9 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23713
23713
  const resolution = initializeBridge().then(() => enqueueBridgeRequest("codexhost/thread/ownership/list", {
23714
23714
  threadIds: [threadId2]
23715
23715
  })).then((value2) => {
23716
- const ownerships = isRecord21(value2) && Array.isArray(value2.threads) ? value2.threads : null;
23716
+ const ownerships = isRecord22(value2) && Array.isArray(value2.threads) ? value2.threads : null;
23717
23717
  const ownership = ownerships?.[0];
23718
- if (!ownerships || !isRecord21(ownership) || ownerships.length !== 1 || ownership.threadId !== threadId2 || ownership.owner !== "external" && ownership.owner !== "codex") {
23718
+ if (!ownerships || !isRecord22(ownership) || ownerships.length !== 1 || ownership.threadId !== threadId2 || ownership.owner !== "external" && ownership.owner !== "codex") {
23719
23719
  throw transportError("Thread ownership lookup returned an invalid result");
23720
23720
  }
23721
23721
  if (ownership.owner === "external") {
@@ -23754,7 +23754,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23754
23754
  if (method === "thread/list")
23755
23755
  return true;
23756
23756
  if (method === "thread/start") {
23757
- return isRecord21(parameters) && typeof parameters.model === "string" && parameters.model.startsWith("codexhost/");
23757
+ return isRecord22(parameters) && typeof parameters.model === "string" && parameters.model.startsWith("codexhost/");
23758
23758
  }
23759
23759
  const threadId2 = threadIdFromParameters(parameters);
23760
23760
  if (threadId2 && knownExternalThreadIds.has(threadId2))
@@ -23764,7 +23764,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23764
23764
  return selectedModel !== null && (method.startsWith("thread/") || method.startsWith("turn/") || method.startsWith("review/"));
23765
23765
  };
23766
23766
  const routeThreadStart = (parameters) => {
23767
- if (!isRecord21(parameters) || parameters.ephemeral === true) {
23767
+ if (!isRecord22(parameters) || parameters.ephemeral === true) {
23768
23768
  return parameters;
23769
23769
  }
23770
23770
  return {
@@ -23797,12 +23797,12 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23797
23797
  return shouldUseBridge(method, routedParameters) ? sendBridged() : sendDirect();
23798
23798
  };
23799
23799
  const publishDraftWorkspace = (parameters) => {
23800
- if (!isRecord21(parameters) || parameters.ephemeral === true)
23800
+ if (!isRecord22(parameters) || parameters.ephemeral === true)
23801
23801
  return;
23802
23802
  const cwd = parameters.cwd;
23803
23803
  if (typeof cwd !== "string" || cwd.length === 0)
23804
23804
  return;
23805
- const drafts = isRecord21(target.__codexhostDraftWorkspacesV1) ? target.__codexhostDraftWorkspacesV1 : {};
23805
+ const drafts = isRecord22(target.__codexhostDraftWorkspacesV1) ? target.__codexhostDraftWorkspacesV1 : {};
23806
23806
  drafts[hostId2] = cwd;
23807
23807
  Object.defineProperty(target, "__codexhostDraftWorkspacesV1", {
23808
23808
  configurable: true,
@@ -23825,16 +23825,16 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23825
23825
  };
23826
23826
  const routedPrewarm = (parameters, options2) => {
23827
23827
  const routed = routeThreadStart(parameters);
23828
- const external = isRecord21(routed) && routed.ephemeral !== true && typeof routed.model === "string" && routed.model.startsWith("codexhost/");
23828
+ const external = isRecord22(routed) && routed.ephemeral !== true && typeof routed.model === "string" && routed.model.startsWith("codexhost/");
23829
23829
  const routedParameters = external ? { ...routed, codexhostPrewarm: true } : routed;
23830
23830
  const generation = prewarmGeneration;
23831
23831
  publishDraftWorkspace(routedParameters);
23832
23832
  const pending = shouldUseBridge("thread/start", routedParameters) ? routedSend("thread/start", routedParameters, options2) : options2 === void 0 ? originalPrewarm.call(bridge, routedParameters) : originalPrewarm.call(bridge, routedParameters, options2);
23833
- if (isRecord21(parameters) && parameters.ephemeral === true || typeof pending !== "object" && typeof pending !== "function" || pending === null || typeof Reflect.get(pending, "then") !== "function") {
23833
+ if (isRecord22(parameters) && parameters.ephemeral === true || typeof pending !== "object" && typeof pending !== "function" || pending === null || typeof Reflect.get(pending, "then") !== "function") {
23834
23834
  return pending;
23835
23835
  }
23836
23836
  return Promise.resolve(pending).then((result) => {
23837
- const threadId2 = external && isRecord21(result) && isRecord21(result.thread) && typeof result.thread.id === "string" ? result.thread.id : null;
23837
+ const threadId2 = external && isRecord22(result) && isRecord22(result.thread) && typeof result.thread.id === "string" ? result.thread.id : null;
23838
23838
  if (disposed || generation !== prewarmGeneration) {
23839
23839
  if (threadId2)
23840
23840
  discardExternalPrewarm(threadId2);
@@ -23850,7 +23850,7 @@ function createDraftPrewarmPolicyBridge(manager, bridge, hostId2, target, prewar
23850
23850
  bridge.prewarmThreadStart = routedPrewarm;
23851
23851
  const routedWindowMessage = (event) => {
23852
23852
  const message2 = event.data;
23853
- if (!isRecord21(message2) || message2.type !== "mcp-notification" || message2.hostId !== hostId2 || typeof message2.method !== "string") {
23853
+ if (!isRecord22(message2) || message2.type !== "mcp-notification" || message2.hostId !== hostId2 || typeof message2.method !== "string") {
23854
23854
  return;
23855
23855
  }
23856
23856
  handleOuterNotification(message2.method, message2.params);
@@ -32428,7 +32428,7 @@ var HarnessAccountInspectionCache = class {
32428
32428
  };
32429
32429
 
32430
32430
  // packages/host-runtime/src/app-server-host.ts
32431
- import { createHash as createHash9, randomUUID as randomUUID18 } from "node:crypto";
32431
+ import { createHash as createHash9, randomUUID as randomUUID19 } from "node:crypto";
32432
32432
  import os9 from "node:os";
32433
32433
  import path28 from "node:path";
32434
32434
 
@@ -40063,13 +40063,106 @@ async function moveThreadSection(input) {
40063
40063
  // packages/host-runtime/src/external-thread-official-defaults.ts
40064
40064
  var EMPTY_RESULTS = /* @__PURE__ */ new Map([
40065
40065
  ["thread/attachment/list", () => ({ data: [], nextCursor: null })],
40066
- ["thread/queue/list", () => ({ data: [], nextCursor: null })],
40067
40066
  ["thread/settings/update", () => ({})]
40068
40067
  ]);
40069
40068
  function externalThreadEmptyOfficialResult(method) {
40070
40069
  return EMPTY_RESULTS.get(method)?.();
40071
40070
  }
40072
40071
 
40072
+ // packages/host-runtime/src/external-thread-follow-up-queue.ts
40073
+ import { randomUUID as randomUUID18 } from "node:crypto";
40074
+ function isRecord20(value2) {
40075
+ return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
40076
+ }
40077
+ function queuedSubmissionText(input) {
40078
+ return input.filter(isRecord20).map((item) => item.text).filter((value2) => typeof value2 === "string" && value2.length > 0).join("\n");
40079
+ }
40080
+ function queuedSubmissionInput(input) {
40081
+ return input.map((entry) => {
40082
+ if (!isRecord20(entry) || typeof entry.text !== "string" || entry.text.length === 0) {
40083
+ return entry;
40084
+ }
40085
+ if (entry.type === "input_text") {
40086
+ return {
40087
+ type: "text",
40088
+ text: entry.text,
40089
+ text_elements: Array.isArray(entry.text_elements) ? entry.text_elements : []
40090
+ };
40091
+ }
40092
+ if (entry.type !== "text" || Array.isArray(entry.text_elements)) return entry;
40093
+ return { ...entry, text_elements: [] };
40094
+ });
40095
+ }
40096
+ var ExternalThreadFollowUpQueue = class {
40097
+ #threads = /* @__PURE__ */ new Map();
40098
+ list(threadId2) {
40099
+ return { data: [...this.#threads.get(threadId2) ?? []], nextCursor: null };
40100
+ }
40101
+ add(threadId2, input, clientUserMessageId) {
40102
+ const item = {
40103
+ id: randomUUID18(),
40104
+ clientUserMessageId: clientUserMessageId?.trim() || randomUUID18(),
40105
+ input: queuedSubmissionInput(input)
40106
+ };
40107
+ const items = this.#threads.get(threadId2) ?? [];
40108
+ items.push(item);
40109
+ this.#threads.set(threadId2, items);
40110
+ return item;
40111
+ }
40112
+ update(threadId2, id2, input) {
40113
+ const item = this.#threads.get(threadId2)?.find((entry) => entry.id === id2);
40114
+ if (!item) return void 0;
40115
+ item.input = queuedSubmissionInput(input);
40116
+ return item;
40117
+ }
40118
+ delete(threadId2, id2) {
40119
+ const items = this.#threads.get(threadId2);
40120
+ if (!items) return false;
40121
+ const next = items.filter((entry) => entry.id !== id2);
40122
+ if (next.length === items.length) return false;
40123
+ if (next.length === 0) this.#threads.delete(threadId2);
40124
+ else this.#threads.set(threadId2, next);
40125
+ return true;
40126
+ }
40127
+ reorder(threadId2, ids) {
40128
+ const items = this.#threads.get(threadId2);
40129
+ if (!items) return false;
40130
+ const remaining = new Map(items.map((entry) => [entry.id, entry]));
40131
+ const next = [];
40132
+ for (const id2 of ids) {
40133
+ const item = remaining.get(id2);
40134
+ if (!item) return false;
40135
+ next.push(item);
40136
+ remaining.delete(id2);
40137
+ }
40138
+ next.push(...remaining.values());
40139
+ this.#threads.set(threadId2, next);
40140
+ return true;
40141
+ }
40142
+ peek(threadId2, id2) {
40143
+ const items = this.#threads.get(threadId2);
40144
+ if (!items?.length) return void 0;
40145
+ return id2 ? items.find((entry) => this.#matches(entry, id2)) : items[0];
40146
+ }
40147
+ take(threadId2, id2) {
40148
+ const items = this.#threads.get(threadId2);
40149
+ if (!items?.length) return void 0;
40150
+ const index = id2 ? items.findIndex((entry) => this.#matches(entry, id2)) : 0;
40151
+ if (index < 0) return void 0;
40152
+ const [item] = items.splice(index, 1);
40153
+ if (items.length === 0) this.#threads.delete(threadId2);
40154
+ return item;
40155
+ }
40156
+ restore(threadId2, item) {
40157
+ const items = this.#threads.get(threadId2) ?? [];
40158
+ items.unshift(item);
40159
+ this.#threads.set(threadId2, items);
40160
+ }
40161
+ #matches(entry, id2) {
40162
+ return entry.id === id2 || entry.clientUserMessageId === id2;
40163
+ }
40164
+ };
40165
+
40073
40166
  // packages/host-runtime/src/observed-session-usage.ts
40074
40167
  var ObservedSessionUsage = class {
40075
40168
  constructor(providers, prices, diagnose) {
@@ -40229,14 +40322,14 @@ var THREAD_USAGE_UPDATED_METHOD = "codexhost/thread/usage/updated";
40229
40322
  function delay5(milliseconds) {
40230
40323
  return new Promise((resolve) => setTimeout(resolve, milliseconds));
40231
40324
  }
40232
- function isRecord20(value2) {
40325
+ function isRecord21(value2) {
40233
40326
  return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
40234
40327
  }
40235
40328
  function officialThreadBusy(thread) {
40236
- if (thread && isRecord20(thread.status) && thread.status.type === "active") return true;
40329
+ if (thread && isRecord21(thread.status) && thread.status.type === "active") return true;
40237
40330
  const turns = thread && Array.isArray(thread.turns) ? thread.turns : [];
40238
40331
  const latestTurn = turns.at(-1);
40239
- return isRecord20(latestTurn) && (latestTurn.status === "inProgress" || latestTurn.status === "running");
40332
+ return isRecord21(latestTurn) && (latestTurn.status === "inProgress" || latestTurn.status === "running");
40240
40333
  }
40241
40334
  function errorMessage4(error51) {
40242
40335
  return error51 instanceof Error ? error51.message : String(error51);
@@ -40343,15 +40436,15 @@ function classifyCreateRequestRoute(request) {
40343
40436
  };
40344
40437
  }
40345
40438
  function routingParams(request) {
40346
- return isRecord20(request.params) ? request.params : {};
40439
+ return isRecord21(request.params) ? request.params : {};
40347
40440
  }
40348
40441
  function requestObject(request) {
40349
- if (!isRecord20(request.params)) throw new Error(`${request.method} params must be an object`);
40442
+ if (!isRecord21(request.params)) throw new Error(`${request.method} params must be an object`);
40350
40443
  return request.params;
40351
40444
  }
40352
40445
  function requestText(params) {
40353
40446
  if (!Array.isArray(params.input)) throw new Error("turn/start input must be an array");
40354
- const text = params.input.filter((item) => isRecord20(item) && item.type === "text").map((item) => item.text).filter((value2) => typeof value2 === "string").join("\n");
40447
+ const text = queuedSubmissionText(params.input);
40355
40448
  if (!text) throw new Error("turn/start must contain text input");
40356
40449
  return text;
40357
40450
  }
@@ -40404,6 +40497,7 @@ var AppServerHost = class {
40404
40497
  #executionHosts = /* @__PURE__ */ new WeakMap();
40405
40498
  #externalPrewarms = new ExternalThreadPrewarms();
40406
40499
  #externalSteering = new ExternalTurnSteering();
40500
+ #followUps = new ExternalThreadFollowUpQueue();
40407
40501
  #nativeVoiceGateway;
40408
40502
  #externalVoice;
40409
40503
  #externalVoiceResults = new ExternalVoiceResults(
@@ -40435,7 +40529,7 @@ var AppServerHost = class {
40435
40529
  #sectionMoves = Promise.resolve();
40436
40530
  #writer;
40437
40531
  /** Console requests share Desktop handling; their replies return to the console. */
40438
- #consoleRequestPrefix = `codexhost-console:${randomUUID18()}:`;
40532
+ #consoleRequestPrefix = `codexhost-console:${randomUUID19()}:`;
40439
40533
  #consoleReplies = /* @__PURE__ */ new Map();
40440
40534
  #nextConsoleRequest = 0;
40441
40535
  #subagentThreadStatuses = /* @__PURE__ */ new Map();
@@ -40793,19 +40887,19 @@ var AppServerHost = class {
40793
40887
  for (const resolve of waiters) resolve();
40794
40888
  }
40795
40889
  #observeOfficialTurnStartResponse(value2) {
40796
- if (!isRecord20(value2) || !("id" in value2)) return;
40890
+ if (!isRecord21(value2) || !("id" in value2)) return;
40797
40891
  const threadId2 = this.#pendingOfficialTurnStarts.get(value2.id);
40798
40892
  if (!threadId2) return;
40799
40893
  this.#pendingOfficialTurnStarts.delete(value2.id);
40800
- const result = isRecord20(value2.result) ? value2.result : null;
40801
- const turn = result && isRecord20(result.turn) ? result.turn : null;
40894
+ const result = isRecord21(value2.result) ? value2.result : null;
40895
+ const turn = result && isRecord21(result.turn) ? result.turn : null;
40802
40896
  if (turn && typeof turn.id === "string") {
40803
40897
  this.#activeOfficialTurns.set(threadId2, turn.id);
40804
40898
  }
40805
40899
  this.#signalActiveWorkChanged();
40806
40900
  }
40807
40901
  #takeConsoleReply(value2) {
40808
- if (!isRecord20(value2) || typeof value2.id !== "string") return false;
40902
+ if (!isRecord21(value2) || typeof value2.id !== "string") return false;
40809
40903
  const reply2 = this.#consoleReplies.get(value2.id);
40810
40904
  if (!reply2) return false;
40811
40905
  this.#consoleReplies.delete(value2.id);
@@ -40851,10 +40945,10 @@ var AppServerHost = class {
40851
40945
  );
40852
40946
  try {
40853
40947
  const message2 = await reply2;
40854
- if (isRecord20(message2) && "result" in message2) {
40948
+ if (isRecord21(message2) && "result" in message2) {
40855
40949
  return { result: message2.result ?? null };
40856
40950
  }
40857
- const error51 = isRecord20(message2) && isRecord20(message2.error) ? message2.error : void 0;
40951
+ const error51 = isRecord21(message2) && isRecord21(message2.error) ? message2.error : void 0;
40858
40952
  return {
40859
40953
  error: {
40860
40954
  code: typeof error51?.code === "number" ? error51.code : -32603,
@@ -40880,7 +40974,7 @@ var AppServerHost = class {
40880
40974
  this.#diagnose(error51);
40881
40975
  continue;
40882
40976
  }
40883
- if (isRecord20(parsed2) && parsed2.method === "initialized" && !("id" in parsed2)) {
40977
+ if (isRecord21(parsed2) && parsed2.method === "initialized" && !("id" in parsed2)) {
40884
40978
  continue;
40885
40979
  }
40886
40980
  if (await this.#handleDesktopApprovalResponse(parsed2)) continue;
@@ -40902,7 +40996,7 @@ var AppServerHost = class {
40902
40996
  const options2 = this.#observedSessionUsage.requestOptions("initialize", params);
40903
40997
  const nativeParams = options2 ? { ...params, ...options2 } : params;
40904
40998
  const response = await this.#officialRuntime.initializeProtocol(nativeParams);
40905
- if (!isRecord20(response.error)) this.#observedSessionUsage.initialized(nativeParams);
40999
+ if (!isRecord21(response.error)) this.#observedSessionUsage.initialized(nativeParams);
40906
41000
  await this.#writer.json({ ...response, id: request.id });
40907
41001
  this.#nativeAccountObserver?.initialized(nativeGeneration);
40908
41002
  } catch (error51) {
@@ -40910,7 +41004,7 @@ var AppServerHost = class {
40910
41004
  }
40911
41005
  continue;
40912
41006
  }
40913
- const threadId2 = isRecord20(request.params) && typeof request.params.threadId === "string" ? request.params.threadId : void 0;
41007
+ const threadId2 = isRecord21(request.params) && typeof request.params.threadId === "string" ? request.params.threadId : void 0;
40914
41008
  this.#dispatchDesktopRequest(
40915
41009
  () => this.#desktopRequests.run(
40916
41010
  threadId2,
@@ -40958,7 +41052,7 @@ var AppServerHost = class {
40958
41052
  for (const guard of this.#replyGuards.get(id2) ?? []) guard.answered = true;
40959
41053
  }
40960
41054
  #noteDesktopReply(value2) {
40961
- if (isRecord20(value2) && "id" in value2 && !("method" in value2)) {
41055
+ if (isRecord21(value2) && "id" in value2 && !("method" in value2)) {
40962
41056
  this.#markDesktopRequestAnswered(value2.id);
40963
41057
  }
40964
41058
  }
@@ -41537,7 +41631,7 @@ var AppServerHost = class {
41537
41631
  return;
41538
41632
  }
41539
41633
  if (request.method === "thread/fork") {
41540
- const params = isRecord20(request.params) ? request.params : {};
41634
+ const params = isRecord21(request.params) ? request.params : {};
41541
41635
  const resolution = typeof params.threadId === "string" ? await this.#resolveExternalThread(params.threadId) : { kind: "official" };
41542
41636
  if (resolution.kind === "error") {
41543
41637
  await this.#writer.json(rpcError(request, resolution.error.code, resolution.error.message));
@@ -41558,7 +41652,7 @@ var AppServerHost = class {
41558
41652
  }
41559
41653
  }
41560
41654
  if (request.method === "thread/revert") {
41561
- const params = isRecord20(request.params) ? request.params : {};
41655
+ const params = isRecord21(request.params) ? request.params : {};
41562
41656
  const resolution = typeof params.threadId === "string" ? await this.#resolveExternalThread(params.threadId) : { kind: "official" };
41563
41657
  if (resolution.kind === "error") {
41564
41658
  await this.#writer.json(rpcError(request, resolution.error.code, resolution.error.message));
@@ -41579,7 +41673,7 @@ var AppServerHost = class {
41579
41673
  }
41580
41674
  }
41581
41675
  if (request.method === "thread/rollback") {
41582
- const params = isRecord20(request.params) ? request.params : {};
41676
+ const params = isRecord21(request.params) ? request.params : {};
41583
41677
  const resolution = typeof params.threadId === "string" ? await this.#resolveExternalThread(params.threadId) : { kind: "official" };
41584
41678
  if (resolution.kind === "error") {
41585
41679
  await this.#writer.json(rpcError(request, resolution.error.code, resolution.error.message));
@@ -41638,6 +41732,24 @@ var AppServerHost = class {
41638
41732
  this.#pendingOfficialTurnStarts.set(request.id, threadId2);
41639
41733
  }
41640
41734
  }
41735
+ if (request.method.startsWith("thread/queue/")) {
41736
+ const params = routingParams(request);
41737
+ const threadId2 = params.threadId;
41738
+ const resolution = typeof threadId2 === "string" ? await this.#resolveExternalThread(threadId2) : { kind: "official" };
41739
+ if (await this.#writeResolutionError(request, resolution)) return;
41740
+ if (resolution.kind === "external") {
41741
+ if (request.method === "thread/queue/start") {
41742
+ this.#dispatchDesktopReply(
41743
+ request,
41744
+ () => this.#startExternalQueuedTurn(request, resolution.thread),
41745
+ resolution.thread.id
41746
+ );
41747
+ return;
41748
+ }
41749
+ await this.#handleExternalQueueMutation(request, resolution.thread);
41750
+ return;
41751
+ }
41752
+ }
41641
41753
  if (request.method === "turn/steer") {
41642
41754
  const params = routingParams(request);
41643
41755
  const resolution = typeof params.threadId === "string" ? await this.#resolveExternalThread(params.threadId) : { kind: "official" };
@@ -41737,7 +41849,7 @@ var AppServerHost = class {
41737
41849
  return;
41738
41850
  }
41739
41851
  }
41740
- if (request.method === "thread/backgroundTerminals/clean" && isRecord20(request.params) && typeof request.params.threadId === "string") {
41852
+ if (request.method === "thread/backgroundTerminals/clean" && isRecord21(request.params) && typeof request.params.threadId === "string") {
41741
41853
  const location = await this.#locateExternalThread(request.params.threadId);
41742
41854
  if (await this.#writeResolutionError(request, location)) return;
41743
41855
  if (location.kind === "external") {
@@ -41745,7 +41857,7 @@ var AppServerHost = class {
41745
41857
  return;
41746
41858
  }
41747
41859
  }
41748
- if (request.method.startsWith("thread/realtime/") && isRecord20(request.params) && typeof request.params.threadId === "string") {
41860
+ if (request.method.startsWith("thread/realtime/") && isRecord21(request.params) && typeof request.params.threadId === "string") {
41749
41861
  const resolution = await this.#resolveExternalThread(request.params.threadId);
41750
41862
  if (await this.#writeResolutionError(request, resolution)) return;
41751
41863
  if (resolution.kind === "external") {
@@ -41757,7 +41869,7 @@ var AppServerHost = class {
41757
41869
  return;
41758
41870
  }
41759
41871
  }
41760
- if (request.method.startsWith("thread/") && !EXPLICIT_EXTERNAL_THREAD_METHODS.has(request.method) && isRecord20(request.params) && typeof request.params.threadId === "string") {
41872
+ if (request.method.startsWith("thread/") && !EXPLICIT_EXTERNAL_THREAD_METHODS.has(request.method) && isRecord21(request.params) && typeof request.params.threadId === "string") {
41761
41873
  const location = await this.#locateExternalThread(request.params.threadId);
41762
41874
  if (await this.#writeResolutionError(request, location)) return;
41763
41875
  if (location.kind === "external") {
@@ -41776,10 +41888,10 @@ var AppServerHost = class {
41776
41888
  /** Native Codex Turns: turn `#` delegation chips into an explicit Skill-backed request. */
41777
41889
  async #rewriteOfficialDelegationMentions(request, frame) {
41778
41890
  if (request.method !== "turn/start" && request.method !== "turn/steer") return frame;
41779
- if (!isRecord20(request.params) || !Array.isArray(request.params.input)) return frame;
41891
+ if (!isRecord21(request.params) || !Array.isArray(request.params.input)) return frame;
41780
41892
  const input = request.params.input;
41781
41893
  if (!input.some(
41782
- (item) => isRecord20(item) && typeof item.text === "string" && item.text.includes(DELEGATION_MENTION_PATH_PREFIX)
41894
+ (item) => isRecord21(item) && typeof item.text === "string" && item.text.includes(DELEGATION_MENTION_PATH_PREFIX)
41783
41895
  )) {
41784
41896
  return frame;
41785
41897
  }
@@ -41792,7 +41904,7 @@ var AppServerHost = class {
41792
41904
  }
41793
41905
  async #forwardOfficialNonRequest(value2, frame) {
41794
41906
  if (this.#options.externalOnly) return;
41795
- const response = isRecord20(value2) ? value2 : null;
41907
+ const response = isRecord21(value2) ? value2 : null;
41796
41908
  const request = response && (typeof response.id === "string" || typeof response.id === "number") ? this.#officialServerRequests.get(response.id) : null;
41797
41909
  if (request !== void 0 && response) {
41798
41910
  this.#officialServerRequests.delete(response.id);
@@ -41812,13 +41924,13 @@ var AppServerHost = class {
41812
41924
  return;
41813
41925
  }
41814
41926
  try {
41815
- const options2 = isRecord20(request.params) ? this.#observedSessionUsage.requestOptions(request.method, request.params) : null;
41927
+ const options2 = isRecord21(request.params) ? this.#observedSessionUsage.requestOptions(request.method, request.params) : null;
41816
41928
  if (options2) {
41817
41929
  const original = parseJsonFrame(frame);
41818
- if (isRecord20(original))
41930
+ if (isRecord21(original))
41819
41931
  frame = encodeJsonFrame({
41820
41932
  ...original,
41821
- params: { ...isRecord20(original.params) ? original.params : {}, ...options2 }
41933
+ params: { ...isRecord21(original.params) ? original.params : {}, ...options2 }
41822
41934
  });
41823
41935
  }
41824
41936
  await this.#officialRuntime.sendFrame(frame);
@@ -41842,7 +41954,7 @@ var AppServerHost = class {
41842
41954
  const observedAtMs = Date.now();
41843
41955
  this.#observeOfficialTurnStartResponse(parsed2);
41844
41956
  let forwarded = parsed2;
41845
- if (isRecord20(parsed2) && typeof parsed2.method === "string" && "id" in parsed2) {
41957
+ if (isRecord21(parsed2) && typeof parsed2.method === "string" && "id" in parsed2) {
41846
41958
  const originalId = parsed2.id;
41847
41959
  if (typeof originalId === "string" || typeof originalId === "number") {
41848
41960
  const forwardedId = `codexhost:official:${++this.#nextOfficialServerRequestId}`;
@@ -41850,7 +41962,7 @@ var AppServerHost = class {
41850
41962
  forwarded = { ...parsed2, id: forwardedId };
41851
41963
  }
41852
41964
  }
41853
- const accountScopedNotification = isRecord20(parsed2) && typeof parsed2.method === "string" && (parsed2.method === "account/updated" || parsed2.method.startsWith("account/rateLimits/"));
41965
+ const accountScopedNotification = isRecord21(parsed2) && typeof parsed2.method === "string" && (parsed2.method === "account/updated" || parsed2.method.startsWith("account/rateLimits/"));
41854
41966
  if (accountScopedNotification) {
41855
41967
  if (parsed2.method === "account/updated") this.#officialRateLimits.reset(input.accountId);
41856
41968
  }
@@ -41862,7 +41974,7 @@ var AppServerHost = class {
41862
41974
  this.#diagnose(error51);
41863
41975
  }
41864
41976
  this.#routeObservationTracker.bindOfficialResponse(parsed2);
41865
- const privateTelemetry = isRecord20(parsed2) && typeof parsed2.method === "string" && !("id" in parsed2) && !this.#observedSessionUsage.shouldForwardNotification(parsed2);
41977
+ const privateTelemetry = isRecord21(parsed2) && typeof parsed2.method === "string" && !("id" in parsed2) && !this.#observedSessionUsage.shouldForwardNotification(parsed2);
41866
41978
  if (!privateTelemetry) {
41867
41979
  if (forwarded === parsed2) await this.#writer.frame(input.frame);
41868
41980
  else await this.#writer.json(forwarded);
@@ -41928,10 +42040,10 @@ var AppServerHost = class {
41928
42040
  }
41929
42041
  }
41930
42042
  async #observeOfficialTurnLifecycle(value2) {
41931
- if (!isRecord20(value2) || !isRecord20(value2.params)) return;
42043
+ if (!isRecord21(value2) || !isRecord21(value2.params)) return;
41932
42044
  const params = value2.params;
41933
42045
  if (value2.method === "turn/started" && typeof params.threadId === "string") {
41934
- const turn = isRecord20(params.turn) ? params.turn : null;
42046
+ const turn = isRecord21(params.turn) ? params.turn : null;
41935
42047
  if (turn && typeof turn.id === "string") {
41936
42048
  this.#forgetPendingOfficialTurnStarts(params.threadId);
41937
42049
  this.#activeOfficialTurns.set(params.threadId, turn.id);
@@ -41944,7 +42056,7 @@ var AppServerHost = class {
41944
42056
  const delegation = await this.#repository.getDelegationByChild(
41945
42057
  hostThreadIdSchema.parse(params.threadId)
41946
42058
  );
41947
- const turn = isRecord20(params.turn) ? params.turn : null;
42059
+ const turn = isRecord21(params.turn) ? params.turn : null;
41948
42060
  const status2 = turn?.status === "failed" ? "failed" : turn?.status === "interrupted" || turn?.status === "cancelled" ? "interrupted" : "completed";
41949
42061
  if (this.#pendingOfficialDelegationThreads.has(params.threadId)) {
41950
42062
  this.#pendingOfficialTerminalStatuses.set(params.threadId, status2);
@@ -41977,9 +42089,9 @@ var AppServerHost = class {
41977
42089
  }
41978
42090
  async #readOfficialThreadMetadata(threadId2) {
41979
42091
  const response = await this.#requestOfficial("thread/read", { threadId: threadId2, includeTurns: false });
41980
- if (isRecord20(response.error)) return {};
41981
- const result = isRecord20(response.result) ? response.result : null;
41982
- const thread = result && isRecord20(result.thread) ? result.thread : null;
42092
+ if (isRecord21(response.error)) return {};
42093
+ const result = isRecord21(response.result) ? response.result : null;
42094
+ const thread = result && isRecord21(result.thread) ? result.thread : null;
41983
42095
  if (!thread) return {};
41984
42096
  const title = typeof thread.name === "string" && thread.name.trim() ? thread.name : thread.preview;
41985
42097
  return {
@@ -41989,21 +42101,21 @@ var AppServerHost = class {
41989
42101
  }
41990
42102
  async #inspectOfficialDelegationTarget(input) {
41991
42103
  const response = await this.#requestOfficial("model/list", {});
41992
- if (isRecord20(response.error)) {
42104
+ if (isRecord21(response.error)) {
41993
42105
  throw new DelegationControlError(
41994
42106
  "DELEGATION_FAILED",
41995
42107
  typeof response.error.message === "string" ? response.error.message : "Official Model catalog could not be read"
41996
42108
  );
41997
42109
  }
41998
- const result = isRecord20(response.result) ? response.result : null;
42110
+ const result = isRecord21(response.result) ? response.result : null;
41999
42111
  const data = result && Array.isArray(result.data) ? result.data : [];
42000
42112
  const thinkingById = /* @__PURE__ */ new Map();
42001
42113
  const models = data.flatMap((candidate) => {
42002
- if (!isRecord20(candidate) || typeof candidate.model !== "string" || !candidate.model.trim()) {
42114
+ if (!isRecord21(candidate) || typeof candidate.model !== "string" || !candidate.model.trim()) {
42003
42115
  return [];
42004
42116
  }
42005
42117
  const supportedThinkingOptionIds = Array.isArray(candidate.supportedReasoningEfforts) ? candidate.supportedReasoningEfforts.flatMap((option) => {
42006
- if (!isRecord20(option) || typeof option.reasoningEffort !== "string" || !option.reasoningEffort.trim()) {
42118
+ if (!isRecord21(option) || typeof option.reasoningEffort !== "string" || !option.reasoningEffort.trim()) {
42007
42119
  return [];
42008
42120
  }
42009
42121
  const id2 = harnessThinkingOptionIdSchema.safeParse(option.reasoningEffort);
@@ -42023,9 +42135,9 @@ var AppServerHost = class {
42023
42135
  ];
42024
42136
  });
42025
42137
  const defaultEntry = data.find(
42026
- (candidate) => isRecord20(candidate) && candidate.isDefault === true
42138
+ (candidate) => isRecord21(candidate) && candidate.isDefault === true
42027
42139
  );
42028
- const defaultModel = isRecord20(defaultEntry) && typeof defaultEntry.model === "string" ? encodeOfficialCodexModelRef(defaultEntry.model) : void 0;
42140
+ const defaultModel = isRecord21(defaultEntry) && typeof defaultEntry.model === "string" ? encodeOfficialCodexModelRef(defaultEntry.model) : void 0;
42029
42141
  return {
42030
42142
  harnessId: input.harnessId,
42031
42143
  inspection: {
@@ -42131,8 +42243,8 @@ var AppServerHost = class {
42131
42243
  ephemeral: false,
42132
42244
  historyMode: "paginated"
42133
42245
  });
42134
- const startedResult = isRecord20(started.result) ? started.result : null;
42135
- const thread = startedResult && isRecord20(startedResult.thread) ? startedResult.thread : null;
42246
+ const startedResult = isRecord21(started.result) ? started.result : null;
42247
+ const thread = startedResult && isRecord21(startedResult.thread) ? startedResult.thread : null;
42136
42248
  const threadId2 = thread && typeof thread.id === "string" ? thread.id : null;
42137
42249
  if (!threadId2) throw new Error("Official thread/start returned no Thread identity");
42138
42250
  this.#pendingOfficialDelegationThreads.add(threadId2);
@@ -42147,8 +42259,8 @@ var AppServerHost = class {
42147
42259
  ...nativeModelId ? { model: nativeModelId } : {},
42148
42260
  ...input.thinkingOptionId ? { effort: input.thinkingOptionId } : {}
42149
42261
  });
42150
- const turnResult = isRecord20(turn.result) ? turn.result : null;
42151
- const turnValue = turnResult && isRecord20(turnResult.turn) ? turnResult.turn : null;
42262
+ const turnResult = isRecord21(turn.result) ? turn.result : null;
42263
+ const turnValue = turnResult && isRecord21(turnResult.turn) ? turnResult.turn : null;
42152
42264
  const parsedTurnId = turnValue && typeof turnValue.id === "string" ? turnValue.id : null;
42153
42265
  if (!parsedTurnId) throw new Error("Official turn/start returned no Turn identity");
42154
42266
  turnId = parsedTurnId;
@@ -42159,7 +42271,7 @@ var AppServerHost = class {
42159
42271
  throw error51;
42160
42272
  }
42161
42273
  this.#activeOfficialTurns.set(threadId2, turnId);
42162
- const delegationId = hostThreadIdSchema.parse(randomUUID18());
42274
+ const delegationId = hostThreadIdSchema.parse(randomUUID19());
42163
42275
  try {
42164
42276
  const source = await this.#repository.find(input.parentThreadId);
42165
42277
  const pendingTerminal = this.#pendingOfficialTerminalStatuses.get(threadId2);
@@ -42218,11 +42330,11 @@ var AppServerHost = class {
42218
42330
  threadId: input.threadId,
42219
42331
  includeTurns: true
42220
42332
  });
42221
- if (isRecord20(current.error)) throw officialThreadReadError(current.error);
42222
- if (!isRecord20(current.result)) {
42333
+ if (isRecord21(current.error)) throw officialThreadReadError(current.error);
42334
+ if (!isRecord21(current.result)) {
42223
42335
  throw new DelegationControlError("INTERNAL_ERROR", "Official Thread read returned no result");
42224
42336
  }
42225
- const currentThread = isRecord20(current.result.thread) ? current.result.thread : null;
42337
+ const currentThread = isRecord21(current.result.thread) ? current.result.thread : null;
42226
42338
  if (officialThreadBusy(currentThread)) {
42227
42339
  throw new DelegationControlError("THREAD_BUSY", "Thread already has an active Turn");
42228
42340
  }
@@ -42230,14 +42342,14 @@ var AppServerHost = class {
42230
42342
  threadId: input.threadId,
42231
42343
  excludeTurns: true
42232
42344
  });
42233
- if (isRecord20(resumed.error) || !isRecord20(resumed.result)) {
42345
+ if (isRecord21(resumed.error) || !isRecord21(resumed.result)) {
42234
42346
  throw new DelegationControlError(
42235
42347
  "DELEGATION_FAILED",
42236
- isRecord20(resumed.error) && typeof resumed.error.message === "string" ? resumed.error.message : "Official Thread resume failed",
42348
+ isRecord21(resumed.error) && typeof resumed.error.message === "string" ? resumed.error.message : "Official Thread resume failed",
42237
42349
  { notStarted: true }
42238
42350
  );
42239
42351
  }
42240
- const resumedThread = isRecord20(resumed.result.thread) ? resumed.result.thread : null;
42352
+ const resumedThread = isRecord21(resumed.result.thread) ? resumed.result.thread : null;
42241
42353
  if (!resumedThread || resumedThread.id !== input.threadId) {
42242
42354
  throw new DelegationControlError(
42243
42355
  "DELEGATION_FAILED",
@@ -42248,7 +42360,7 @@ var AppServerHost = class {
42248
42360
  if (officialThreadBusy(resumedThread)) {
42249
42361
  throw new DelegationControlError("THREAD_BUSY", "Thread already has an active Turn");
42250
42362
  }
42251
- if (!isRecord20(resumedThread.status) || resumedThread.status.type !== "idle") {
42363
+ if (!isRecord21(resumedThread.status) || resumedThread.status.type !== "idle") {
42252
42364
  throw new DelegationControlError(
42253
42365
  "DELEGATION_FAILED",
42254
42366
  "Official Thread is not idle after resume",
@@ -42259,15 +42371,15 @@ var AppServerHost = class {
42259
42371
  threadId: input.threadId,
42260
42372
  input: [{ type: "text", text: input.message }]
42261
42373
  });
42262
- if (isRecord20(response.error)) {
42374
+ if (isRecord21(response.error)) {
42263
42375
  throw new DelegationControlError(
42264
42376
  "DELEGATION_FAILED",
42265
42377
  typeof response.error.message === "string" ? response.error.message : "Turn start failed",
42266
42378
  { notStarted: true }
42267
42379
  );
42268
42380
  }
42269
- const result = isRecord20(response.result) ? response.result : null;
42270
- const turn = result && isRecord20(result.turn) ? result.turn : null;
42381
+ const result = isRecord21(response.result) ? response.result : null;
42382
+ const turn = result && isRecord21(result.turn) ? result.turn : null;
42271
42383
  const turnId = turn && typeof turn.id === "string" ? turn.id : null;
42272
42384
  if (!turnId) throw new Error("Official turn/start returned no Turn identity");
42273
42385
  this.#activeOfficialTurns.set(input.threadId, turnId);
@@ -42289,13 +42401,13 @@ var AppServerHost = class {
42289
42401
  threadId: input.threadId,
42290
42402
  includeTurns: true
42291
42403
  });
42292
- if (isRecord20(current.error) || !isRecord20(current.result)) {
42404
+ if (isRecord21(current.error) || !isRecord21(current.result)) {
42293
42405
  throw new DelegationControlError("THREAD_NOT_FOUND", "Official Thread was not found");
42294
42406
  }
42295
- const currentThread = isRecord20(current.result.thread) ? current.result.thread : null;
42407
+ const currentThread = isRecord21(current.result.thread) ? current.result.thread : null;
42296
42408
  const currentTurns = currentThread && Array.isArray(currentThread.turns) ? currentThread.turns : [];
42297
42409
  const latestTurn = currentTurns.at(-1);
42298
- if (isRecord20(latestTurn) && typeof latestTurn.id === "string" && (latestTurn.status === "inProgress" || latestTurn.status === "running")) {
42410
+ if (isRecord21(latestTurn) && typeof latestTurn.id === "string" && (latestTurn.status === "inProgress" || latestTurn.status === "running")) {
42299
42411
  turnId = latestTurn.id;
42300
42412
  this.#activeOfficialTurns.set(input.threadId, turnId);
42301
42413
  } else {
@@ -42306,7 +42418,7 @@ var AppServerHost = class {
42306
42418
  threadId: input.threadId,
42307
42419
  turnId
42308
42420
  });
42309
- if (isRecord20(response.error)) {
42421
+ if (isRecord21(response.error)) {
42310
42422
  throw new DelegationControlError(
42311
42423
  "DELEGATION_FAILED",
42312
42424
  typeof response.error.message === "string" ? response.error.message : "Turn cancel failed"
@@ -42319,13 +42431,13 @@ var AppServerHost = class {
42319
42431
  threadId: input.threadId,
42320
42432
  includeTurns: true
42321
42433
  });
42322
- if (isRecord20(response.error)) throw officialThreadReadError(response.error);
42323
- const result = isRecord20(response.result) ? response.result : null;
42324
- const thread = result && isRecord20(result.thread) ? result.thread : null;
42434
+ if (isRecord21(response.error)) throw officialThreadReadError(response.error);
42435
+ const result = isRecord21(response.result) ? response.result : null;
42436
+ const thread = result && isRecord21(result.thread) ? result.thread : null;
42325
42437
  if (!thread)
42326
42438
  throw new DelegationControlError("INTERNAL_ERROR", "Official Thread read returned no Thread");
42327
- const turns = Array.isArray(thread.turns) ? thread.turns.filter((turn) => isRecord20(turn)) : [];
42328
- const running = this.#activeOfficialTurns.has(input.threadId) || isRecord20(thread.status) && thread.status.type === "active";
42439
+ const turns = Array.isArray(thread.turns) ? thread.turns.filter((turn) => isRecord21(turn)) : [];
42440
+ const running = this.#activeOfficialTurns.has(input.threadId) || isRecord21(thread.status) && thread.status.type === "active";
42329
42441
  const snapshot2 = projectDelegationThreadSnapshot({
42330
42442
  threadId: input.threadId,
42331
42443
  harnessId: "codex",
@@ -42347,7 +42459,7 @@ var AppServerHost = class {
42347
42459
  async #listDelegationThreads(input) {
42348
42460
  const [sortKey, sortDirection2] = input.sort.split("-");
42349
42461
  const request = {
42350
- id: `codexhost:delegation-list:${randomUUID18()}`,
42462
+ id: `codexhost:delegation-list:${randomUUID19()}`,
42351
42463
  method: "thread/list",
42352
42464
  params: {
42353
42465
  cwd: input.cwd ? [input.cwd] : null,
@@ -42373,7 +42485,7 @@ var AppServerHost = class {
42373
42485
  threads: result.data.flatMap((entry) => {
42374
42486
  if (typeof entry.id !== "string") return [];
42375
42487
  const record4 = records.find((candidate) => candidate.hostThreadId === entry.id);
42376
- const status2 = isRecord20(entry.status) && entry.status.type === "active" ? "running" : "completed";
42488
+ const status2 = isRecord21(entry.status) && entry.status.type === "active" ? "running" : "completed";
42377
42489
  return [
42378
42490
  {
42379
42491
  threadId: entry.id,
@@ -42540,7 +42652,7 @@ var AppServerHost = class {
42540
42652
  const exists2 = await this.#requestOfficial("project/read", {
42541
42653
  projectId: update.projectId
42542
42654
  }).then(
42543
- (response) => !isRecord20(response.error) && isRecord20(response.result) && isRecord20(response.result.project) && response.result.project.id === update.projectId,
42655
+ (response) => !isRecord21(response.error) && isRecord21(response.result) && isRecord21(response.result.project) && response.result.project.id === update.projectId,
42544
42656
  () => false
42545
42657
  );
42546
42658
  if (!exists2) {
@@ -43075,7 +43187,7 @@ var AppServerHost = class {
43075
43187
  if (thread.running || thread.activeTurnId) {
43076
43188
  throw new ExternalCommandError(-32072, "External Thread already has an active operation");
43077
43189
  }
43078
- const turnId = requestedTurnId ?? hostTurnIdSchema.parse(randomUUID18());
43190
+ const turnId = requestedTurnId ?? hostTurnIdSchema.parse(randomUUID19());
43079
43191
  const projection = {
43080
43192
  projector: new CodexTurnProjector({
43081
43193
  threadId: thread.id,
@@ -43791,10 +43903,10 @@ var AppServerHost = class {
43791
43903
  if (thread.record.subagent)
43792
43904
  result.reasoningEffort = thread.record.subagentConfiguration?.reasoningEffort ?? null;
43793
43905
  try {
43794
- if (params.initialTurnsPage !== void 0 && params.initialTurnsPage !== null && !isRecord20(params.initialTurnsPage)) {
43906
+ if (params.initialTurnsPage !== void 0 && params.initialTurnsPage !== null && !isRecord21(params.initialTurnsPage)) {
43795
43907
  throw new ExternalHistoryRequestError("initialTurnsPage must be an object");
43796
43908
  }
43797
- const initialPageParams = isRecord20(params.initialTurnsPage) ? params.initialTurnsPage : null;
43909
+ const initialPageParams = isRecord21(params.initialTurnsPage) ? params.initialTurnsPage : null;
43798
43910
  const initialTurnsPage = initialPageParams ? listExternalTurns(turns, initialPageParams) : null;
43799
43911
  const paginated = thread.record.historyMode === "paginated";
43800
43912
  const turnsBackwardsCursor = paginated ? listExternalTurns(turns, { limit: 1, itemsView: "notLoaded" }).backwardsCursor : null;
@@ -43935,6 +44047,117 @@ var AppServerHost = class {
43935
44047
  (signal) => this.#externalVoiceResults.watch(threadId2, turnId, signal)
43936
44048
  );
43937
44049
  }
44050
+ async #notifyFollowUpQueueChanged(threadId2) {
44051
+ await this.#writer.json({
44052
+ method: "thread/queue/changed",
44053
+ params: { threadId: threadId2 }
44054
+ });
44055
+ }
44056
+ async #handleExternalQueueMutation(request, thread) {
44057
+ const params = requestObject(request);
44058
+ try {
44059
+ if (request.method === "thread/queue/list") {
44060
+ await this.#writer.json(rpcEnvelope(request, { result: this.#followUps.list(thread.id) }));
44061
+ return;
44062
+ }
44063
+ if (request.method === "thread/queue/add") {
44064
+ if (!Array.isArray(params.input))
44065
+ throw new Error("thread/queue/add input must be an array");
44066
+ const text = queuedSubmissionText(params.input);
44067
+ if (!text) throw new Error("thread/queue/add must contain text input");
44068
+ const queuedSubmission = this.#followUps.add(
44069
+ thread.id,
44070
+ params.input,
44071
+ typeof params.clientUserMessageId === "string" ? params.clientUserMessageId : void 0
44072
+ );
44073
+ await this.#writer.json(rpcEnvelope(request, { result: { queuedSubmission } }));
44074
+ await this.#notifyFollowUpQueueChanged(thread.id);
44075
+ return;
44076
+ }
44077
+ if (request.method === "thread/queue/update") {
44078
+ if (typeof params.queuedSubmissionId !== "string" || !Array.isArray(params.input)) {
44079
+ throw new Error("thread/queue/update requires queuedSubmissionId and input");
44080
+ }
44081
+ const queuedSubmission = this.#followUps.update(
44082
+ thread.id,
44083
+ params.queuedSubmissionId,
44084
+ params.input
44085
+ );
44086
+ if (!queuedSubmission) throw new Error("Queued follow-up was not found");
44087
+ await this.#writer.json(rpcEnvelope(request, { result: { queuedSubmission } }));
44088
+ await this.#notifyFollowUpQueueChanged(thread.id);
44089
+ return;
44090
+ }
44091
+ if (request.method === "thread/queue/delete") {
44092
+ if (typeof params.queuedSubmissionId !== "string") {
44093
+ throw new Error("thread/queue/delete requires queuedSubmissionId");
44094
+ }
44095
+ const deleted = this.#followUps.delete(thread.id, params.queuedSubmissionId);
44096
+ await this.#writer.json(rpcEnvelope(request, { result: { deleted } }));
44097
+ if (deleted) await this.#notifyFollowUpQueueChanged(thread.id);
44098
+ return;
44099
+ }
44100
+ if (request.method === "thread/queue/reorder") {
44101
+ if (!Array.isArray(params.queuedSubmissionIds) || params.queuedSubmissionIds.some((id2) => typeof id2 !== "string")) {
44102
+ throw new Error("thread/queue/reorder requires queuedSubmissionIds");
44103
+ }
44104
+ if (!this.#followUps.reorder(thread.id, params.queuedSubmissionIds)) {
44105
+ throw new Error("Queued follow-up order could not be applied");
44106
+ }
44107
+ await this.#writer.json(rpcEnvelope(request, { result: {} }));
44108
+ await this.#notifyFollowUpQueueChanged(thread.id);
44109
+ return;
44110
+ }
44111
+ await this.#writer.json(
44112
+ rpcError(request, -32076, `External Thread does not support ${request.method}`)
44113
+ );
44114
+ } catch (error51) {
44115
+ await this.#writer.json(rpcError(request, -32602, errorMessage4(error51)));
44116
+ }
44117
+ }
44118
+ async #startExternalFromFollowUp(request, thread, queued, sourceHostId) {
44119
+ const text = queuedSubmissionText(queued.input);
44120
+ if (!text) {
44121
+ this.#followUps.restore(thread.id, queued);
44122
+ await this.#writer.json(rpcError(request, -32602, "Queued follow-up was not found"));
44123
+ return;
44124
+ }
44125
+ await this.#notifyFollowUpQueueChanged(thread.id);
44126
+ try {
44127
+ const started = await this.#beginExternalInputTurn(
44128
+ thread,
44129
+ text,
44130
+ void 0,
44131
+ queued.clientUserMessageId,
44132
+ sourceHostId
44133
+ );
44134
+ try {
44135
+ await this.#writer.json(rpcEnvelope(request, { result: { turn: started.turn } }));
44136
+ } finally {
44137
+ started.gate.resolve();
44138
+ }
44139
+ } catch (error51) {
44140
+ this.#followUps.restore(thread.id, queued);
44141
+ await this.#notifyFollowUpQueueChanged(thread.id);
44142
+ await this.#writer.json(
44143
+ rpcError(
44144
+ request,
44145
+ error51 instanceof ExternalSteerError || error51 instanceof ExternalCommandError ? error51.code : -32073,
44146
+ errorMessage4(error51)
44147
+ )
44148
+ );
44149
+ }
44150
+ }
44151
+ async #startExternalQueuedTurn(request, thread) {
44152
+ const params = requestObject(request);
44153
+ const queuedSubmissionId = typeof params.queuedSubmissionId === "string" ? params.queuedSubmissionId : void 0;
44154
+ const queued = this.#followUps.take(thread.id, queuedSubmissionId);
44155
+ if (!queued) {
44156
+ await this.#writer.json(rpcError(request, -32602, "Queued follow-up was not found"));
44157
+ return;
44158
+ }
44159
+ await this.#startExternalFromFollowUp(request, thread, queued);
44160
+ }
43938
44161
  async #startExternalTurn(request, thread) {
43939
44162
  if (this.#externalThreadBusy(thread) || this.#pendingExternalCommandRequests.has(thread.id)) {
43940
44163
  await this.#writer.json(
@@ -43959,10 +44182,21 @@ var AppServerHost = class {
43959
44182
  }
43960
44183
  }
43961
44184
  let text;
44185
+ const clientUserMessageId = typeof params.clientUserMessageId === "string" ? params.clientUserMessageId : void 0;
43962
44186
  try {
43963
44187
  text = requestText(params);
43964
44188
  } catch (error51) {
43965
- await this.#writer.json(rpcError(request, -32602, errorMessage4(error51)));
44189
+ const queued = this.#followUps.take(thread.id, clientUserMessageId) ?? this.#followUps.take(thread.id);
44190
+ if (!queued) {
44191
+ await this.#writer.json(rpcError(request, -32602, errorMessage4(error51)));
44192
+ return;
44193
+ }
44194
+ await this.#startExternalFromFollowUp(
44195
+ request,
44196
+ thread,
44197
+ queued,
44198
+ params[THREAD_REFERENCE_SOURCE_HOST_PARAM]
44199
+ );
43966
44200
  return;
43967
44201
  }
43968
44202
  try {
@@ -43970,7 +44204,7 @@ var AppServerHost = class {
43970
44204
  thread,
43971
44205
  text,
43972
44206
  void 0,
43973
- typeof params.clientUserMessageId === "string" ? params.clientUserMessageId : void 0,
44207
+ clientUserMessageId,
43974
44208
  params[THREAD_REFERENCE_SOURCE_HOST_PARAM]
43975
44209
  );
43976
44210
  try {
@@ -44108,7 +44342,7 @@ var AppServerHost = class {
44108
44342
  if (thread.running || thread.activeTurnId || this.#pendingExternalCommandRequests.has(thread.id)) {
44109
44343
  throw new ExternalSteerError(-32072, "External Thread already has an active Turn");
44110
44344
  }
44111
- const turnId = hostTurnIdSchema.parse(randomUUID18());
44345
+ const turnId = hostTurnIdSchema.parse(randomUUID19());
44112
44346
  const startedAtMs = Date.now();
44113
44347
  const projection = {
44114
44348
  projector: new CodexTurnProjector({
@@ -44541,7 +44775,7 @@ var AppServerHost = class {
44541
44775
  const previousItems = new Map(
44542
44776
  child.turns.flatMap(
44543
44777
  (turn) => Array.isArray(turn.items) ? turn.items.flatMap(
44544
- (item) => isRecord20(item) && typeof item.id === "string" ? [[item.id, JSON.stringify(item)]] : []
44778
+ (item) => isRecord21(item) && typeof item.id === "string" ? [[item.id, JSON.stringify(item)]] : []
44545
44779
  ) : []
44546
44780
  )
44547
44781
  );
@@ -44554,7 +44788,7 @@ var AppServerHost = class {
44554
44788
  for (const turn of child.turns) {
44555
44789
  if (typeof turn.id !== "string" || !Array.isArray(turn.items)) continue;
44556
44790
  const changedItems = turn.items.filter(
44557
- (item) => isRecord20(item) && typeof item.id === "string" && previousItems.get(item.id) !== JSON.stringify(item)
44791
+ (item) => isRecord21(item) && typeof item.id === "string" && previousItems.get(item.id) !== JSON.stringify(item)
44558
44792
  );
44559
44793
  if (changedItems.length > 0) {
44560
44794
  await this.#writer.json({
@@ -44686,7 +44920,7 @@ var AppServerHost = class {
44686
44920
  }
44687
44921
  }
44688
44922
  async #handleDesktopApprovalResponse(value2) {
44689
- if (!isRecord20(value2) || !isHostApprovalRequestId(value2.id)) return false;
44923
+ if (!isRecord21(value2) || !isHostApprovalRequestId(value2.id)) return false;
44690
44924
  const requestId2 = value2.id;
44691
44925
  const pending = this.#pendingDesktopApprovals.get(requestId2);
44692
44926
  if (!pending) return true;
@@ -44770,7 +45004,7 @@ var AppServerHost = class {
44770
45004
  try {
44771
45005
  result = projection.projector.projectQuestion(
44772
45006
  interaction,
44773
- hostItemIdSchema.parse(randomUUID18())
45007
+ hostItemIdSchema.parse(randomUUID19())
44774
45008
  );
44775
45009
  } catch (error51) {
44776
45010
  this.#diagnose(error51);
@@ -44815,7 +45049,7 @@ var AppServerHost = class {
44815
45049
  }
44816
45050
  }
44817
45051
  async #handleDesktopQuestionResponse(value2) {
44818
- if (!isRecord20(value2) || !isHostQuestionRequestId(value2.id)) return false;
45052
+ if (!isRecord21(value2) || !isHostQuestionRequestId(value2.id)) return false;
44819
45053
  const requestId2 = value2.id;
44820
45054
  const pending = this.#pendingDesktopQuestions.get(requestId2);
44821
45055
  if (!pending) return true;
@@ -44998,7 +45232,7 @@ import path30 from "node:path";
44998
45232
  import { PassThrough } from "node:stream";
44999
45233
 
45000
45234
  // packages/host-runtime/src/remote-socket-lock.ts
45001
- import { randomUUID as randomUUID19 } from "node:crypto";
45235
+ import { randomUUID as randomUUID20 } from "node:crypto";
45002
45236
  import { chmod as chmod3, lstat as lstat5, mkdir as mkdir14, open as open9, readFile as readFile18, readdir as readdir5, rename as rename12, rm as rm13 } from "node:fs/promises";
45003
45237
  import { uptime } from "node:os";
45004
45238
  import path29 from "node:path";
@@ -45124,7 +45358,7 @@ async function preparePrivateLockDirectory(lockDirectory) {
45124
45358
  await chmod3(lockDirectory, 448);
45125
45359
  }
45126
45360
  async function writeLockRecordAtomic(lockDirectory, entryPath, record4) {
45127
- const temporary = path29.join(lockDirectory, `.tmp-${record4.ownerToken}-${randomUUID19()}`);
45361
+ const temporary = path29.join(lockDirectory, `.tmp-${record4.ownerToken}-${randomUUID20()}`);
45128
45362
  const handle = await open9(temporary, "wx", 384);
45129
45363
  try {
45130
45364
  await handle.writeFile(`${JSON.stringify(record4)}
@@ -45199,7 +45433,7 @@ async function withRemoteAppServerSocketInitializationLock(socketPath, action) {
45199
45433
  const legacyPath = `${socketPath}.initializing`;
45200
45434
  const lockDirectory = `${socketPath}.initializers`;
45201
45435
  await preparePrivateLockDirectory(lockDirectory);
45202
- const ownerToken = randomUUID19();
45436
+ const ownerToken = randomUUID20();
45203
45437
  const entryPath = path29.join(lockDirectory, lockEntryName(ownerToken));
45204
45438
  const baseRecord = {
45205
45439
  version: 2,
@@ -45710,12 +45944,12 @@ function createRemoteAppServerWebSocketListener(input) {
45710
45944
 
45711
45945
  // packages/host-runtime/src/remote-official-app-server.ts
45712
45946
  import { spawn as spawn5 } from "node:child_process";
45713
- import { randomUUID as randomUUID20 } from "node:crypto";
45947
+ import { randomUUID as randomUUID21 } from "node:crypto";
45714
45948
  import { lstat as lstat7, rm as rm15, stat as stat7 } from "node:fs/promises";
45715
45949
  import path31 from "node:path";
45716
45950
  var DEFAULT_CLOSE_TIMEOUT_MS = 2e3;
45717
45951
  var DEFAULT_LISTEN_TIMEOUT_MS = 1e4;
45718
- function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID20()) {
45952
+ function remoteOfficialAppServerSocketPath(desktopControlSocketPath, token = randomUUID21()) {
45719
45953
  if (!path31.posix.isAbsolute(desktopControlSocketPath)) {
45720
45954
  throw new Error("Desktop control socket path must be absolute");
45721
45955
  }
@@ -47001,11 +47235,11 @@ async function readRemoteDelegationThread(environment, input) {
47001
47235
  }
47002
47236
 
47003
47237
  // packages/host-runtime/src/shared-thread-owner.ts
47004
- import { randomUUID as randomUUID22 } from "node:crypto";
47238
+ import { randomUUID as randomUUID23 } from "node:crypto";
47005
47239
  import { PassThrough as PassThrough3 } from "node:stream";
47006
47240
 
47007
47241
  // packages/host-runtime/src/shared-thread-peer.ts
47008
- import { randomUUID as randomUUID21 } from "node:crypto";
47242
+ import { randomUUID as randomUUID22 } from "node:crypto";
47009
47243
  function object9(value2) {
47010
47244
  return value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
47011
47245
  }
@@ -47019,7 +47253,7 @@ var StreamThreadPeer = class {
47019
47253
  input;
47020
47254
  output;
47021
47255
  stop;
47022
- #prefix = `shared:${randomUUID21()}:`;
47256
+ #prefix = `shared:${randomUUID22()}:`;
47023
47257
  #pending = /* @__PURE__ */ new Map();
47024
47258
  #listeners = /* @__PURE__ */ new Set();
47025
47259
  #ended = Promise.withResolvers();
@@ -47097,7 +47331,7 @@ var SharedThreadOwner = class {
47097
47331
  input = new PassThrough3();
47098
47332
  output = new PassThrough3();
47099
47333
  #peer = new StreamThreadPeer(this.output, this.input, () => this.input.end());
47100
- #prefix = `shared-interaction:${randomUUID22()}:`;
47334
+ #prefix = `shared-interaction:${randomUUID23()}:`;
47101
47335
  #interactions = /* @__PURE__ */ new Map();
47102
47336
  #listeners = /* @__PURE__ */ new Set();
47103
47337
  #receipts = /* @__PURE__ */ new Map();
@@ -47407,7 +47641,7 @@ var SharedThreadBridge = class {
47407
47641
  };
47408
47642
 
47409
47643
  // packages/host-runtime/src/remote-control-app-server.ts
47410
- import { randomUUID as randomUUID23 } from "node:crypto";
47644
+ import { randomUUID as randomUUID24 } from "node:crypto";
47411
47645
  import { mkdir as mkdir17, open as open10, rename as rename13, rm as rm17 } from "node:fs/promises";
47412
47646
  import path37 from "node:path";
47413
47647
  var REMOTE_CONTROL_BRIDGE_PIPE_ENV = "CODEXHOST_REMOTE_CONTROL_BRIDGE_PIPE";
@@ -47428,7 +47662,7 @@ function nodeCompatibleWindowsPath(value2) {
47428
47662
  if (value2.startsWith("\\\\?\\")) return value2.slice(4);
47429
47663
  return value2;
47430
47664
  }
47431
- function remoteControlBridgePipePath(processId = process.pid, instanceId = randomUUID23()) {
47665
+ function remoteControlBridgePipePath(processId = process.pid, instanceId = randomUUID24()) {
47432
47666
  const safeInstance = instanceId.replaceAll(/[^a-zA-Z0-9-]/gu, "");
47433
47667
  if (!safeInstance) throw new Error("Remote Control bridge instance ID is invalid");
47434
47668
  return `\\\\.\\pipe\\codexhost-remote-control-${processId}-${safeInstance}`;
@@ -47443,7 +47677,7 @@ async function publishRemoteControlAppServerDescriptor(plan) {
47443
47677
  await mkdir17(directory, { recursive: true, mode: 448 });
47444
47678
  const temporaryPath = path37.join(
47445
47679
  directory,
47446
- `.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID23()}.tmp`
47680
+ `.${REMOTE_CONTROL_BRIDGE_DESCRIPTOR_FILE}.${plan.descriptor.ownerPid}.${randomUUID24()}.tmp`
47447
47681
  );
47448
47682
  const handle = await open10(temporaryPath, "wx", 384);
47449
47683
  try {
@@ -47984,7 +48218,7 @@ function createHostUpdateCoordinator(options2) {
47984
48218
  }
47985
48219
 
47986
48220
  // packages/host-runtime/src/usage-statistics.ts
47987
- import { randomUUID as randomUUID24 } from "node:crypto";
48221
+ import { randomUUID as randomUUID25 } from "node:crypto";
47988
48222
  import { mkdir as mkdir19, readFile as readFile20, readdir as readdir6, rename as rename15, rm as rm19, writeFile as writeFile11 } from "node:fs/promises";
47989
48223
  import path40 from "node:path";
47990
48224
  import { setImmediate as yieldToEventLoop } from "node:timers/promises";
@@ -48519,7 +48753,7 @@ var UsageStatistics = class {
48519
48753
  async #persist(harness2, cache) {
48520
48754
  if (!cache.dirty || this.#now() - cache.persistedAtMs < PERSIST_INTERVAL_MS) return;
48521
48755
  const file2 = this.#file(harness2);
48522
- const temporary = `${file2}.${randomUUID24()}.tmp`;
48756
+ const temporary = `${file2}.${randomUUID25()}.tmp`;
48523
48757
  try {
48524
48758
  await mkdir19(this.#directory, { recursive: true });
48525
48759
  const sources = [...cache.sources].map(([id2, source]) => [
@@ -49135,7 +49369,7 @@ async function runHostRuntime(input) {
49135
49369
  }
49136
49370
 
49137
49371
  // packages/host-runtime/src/remote-host-install.ts
49138
- import { createHash as createHash12, randomUUID as randomUUID25 } from "node:crypto";
49372
+ import { createHash as createHash12, randomUUID as randomUUID26 } from "node:crypto";
49139
49373
  import { constants as fsConstants } from "node:fs";
49140
49374
  import {
49141
49375
  access as access4,
@@ -49234,7 +49468,7 @@ async function writeAtomic(filePath, contents, mode) {
49234
49468
  await mkdir20(path42.dirname(filePath), { recursive: true, mode: 448 });
49235
49469
  const temporary = path42.join(
49236
49470
  path42.dirname(filePath),
49237
- `.${path42.basename(filePath)}.${process.pid}.${randomUUID25()}.tmp`
49471
+ `.${path42.basename(filePath)}.${process.pid}.${randomUUID26()}.tmp`
49238
49472
  );
49239
49473
  try {
49240
49474
  if (typeof contents === "string") {
@@ -49258,7 +49492,7 @@ async function writeAtomicExecutable(filePath, sourcePath) {
49258
49492
  await mkdir20(path42.dirname(filePath), { recursive: true, mode: 448 });
49259
49493
  const temporary = path42.join(
49260
49494
  path42.dirname(filePath),
49261
- `.${path42.basename(filePath)}.${process.pid}.${randomUUID25()}.tmp`
49495
+ `.${path42.basename(filePath)}.${process.pid}.${randomUUID26()}.tmp`
49262
49496
  );
49263
49497
  try {
49264
49498
  await copyFile4(sourcePath, temporary);
@@ -50347,7 +50581,7 @@ var harnessOutputSchema = external_exports.custom((value2) => {
50347
50581
  });
50348
50582
 
50349
50583
  // packages/harness-broker/dist/server.js
50350
- import { randomBytes as randomBytes5, randomUUID as randomUUID26 } from "node:crypto";
50584
+ import { randomBytes as randomBytes5, randomUUID as randomUUID27 } from "node:crypto";
50351
50585
  import { chmod as chmod6, lstat as lstat10, mkdir as mkdir21, open as open11, readFile as readFile22, rename as rename17, rm as rm21 } from "node:fs/promises";
50352
50586
  import net4, {} from "node:net";
50353
50587
  import path45 from "node:path";
@@ -50406,7 +50640,7 @@ async function assertNoLiveDescriptor(descriptorPath) {
50406
50640
  }
50407
50641
  }
50408
50642
  async function publishDescriptor(descriptorPath, descriptor) {
50409
- const temporary = `${descriptorPath}.${process.pid}.${randomUUID26()}.tmp`;
50643
+ const temporary = `${descriptorPath}.${process.pid}.${randomUUID27()}.tmp`;
50410
50644
  const handle = await open11(temporary, "wx", 384);
50411
50645
  try {
50412
50646
  await handle.writeFile(`${JSON.stringify(descriptor)}
@@ -50484,7 +50718,7 @@ async function startHarnessBrokerServer(input) {
50484
50718
  await assertNoLiveDescriptor(input.descriptorPath);
50485
50719
  if (process.platform !== "win32")
50486
50720
  await prepareUnixSocketPath(input.socketPath);
50487
- const generation = input.generation ?? randomUUID26();
50721
+ const generation = input.generation ?? randomUUID27();
50488
50722
  const token = input.token ?? randomBytes5(32).toString("hex");
50489
50723
  const descriptor = {
50490
50724
  schemaVersion: 1,
@@ -50525,7 +50759,7 @@ async function startHarnessBrokerServer(input) {
50525
50759
  };
50526
50760
  const server = net4.createServer((socket) => {
50527
50761
  const state = {
50528
- id: randomUUID26(),
50762
+ id: randomUUID27(),
50529
50763
  socket,
50530
50764
  authenticated: false,
50531
50765
  inputSequence: 0,
@@ -50763,7 +50997,7 @@ async function startHarnessBrokerServer(input) {
50763
50997
  }
50764
50998
  };
50765
50999
  }
50766
- const openReservation = randomUUID26();
51000
+ const openReservation = randomUUID27();
50767
51001
  if (sourceKey)
50768
51002
  nativeWriters.set(sourceKey, openReservation);
50769
51003
  const provisionalReservation = openInput.kind === "create" ? openReservation : void 0;
@@ -51070,7 +51304,7 @@ async function startHarnessBrokerServer(input) {
51070
51304
  }
51071
51305
  state.authenticated = true;
51072
51306
  state.inputSequence = 1;
51073
- await send({ kind: "response", id: randomUUID26(), ok: true, value: { ready: true } });
51307
+ await send({ kind: "response", id: randomUUID27(), ok: true, value: { ready: true } });
51074
51308
  return;
51075
51309
  }
51076
51310
  const parsed2 = harnessBrokerRequestSchema.safeParse(raw);