@karlorz/codexhost-cli-win32-x64 0.17.1-0 → 0.17.3-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15103,49 +15103,49 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15103
15103
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15104
15104
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15105
15105
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15106
- }).strict().superRefine((usage, context) => {
15106
+ }).strict().superRefine((usage, context2) => {
15107
15107
  if (Object.keys(usage).length === 0) {
15108
- context.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
15108
+ context2.addIssue({ code: "custom", message: "Thread Usage must contain a reliable field" });
15109
15109
  }
15110
15110
  const hasContextUsed = usage.contextUsedTokens !== void 0;
15111
15111
  const hasContextWindow = usage.contextWindowTokens !== void 0;
15112
15112
  if (hasContextUsed !== hasContextWindow) {
15113
- context.addIssue({
15113
+ context2.addIssue({
15114
15114
  code: "custom",
15115
15115
  message: "Thread Usage context fields must be provided together",
15116
15116
  path: [hasContextUsed ? "contextWindowTokens" : "contextUsedTokens"]
15117
15117
  });
15118
15118
  }
15119
15119
  if (usage.contextWindowTokens === 0) {
15120
- context.addIssue({
15120
+ context2.addIssue({
15121
15121
  code: "custom",
15122
15122
  message: "Thread Usage contextWindowTokens must be greater than zero",
15123
15123
  path: ["contextWindowTokens"]
15124
15124
  });
15125
15125
  }
15126
15126
  if (usage.costSource !== void 0 && usage.totalCostUsd === void 0) {
15127
- context.addIssue({
15127
+ context2.addIssue({
15128
15128
  code: "custom",
15129
15129
  message: "Thread Usage costSource must be provided with totalCostUsd",
15130
15130
  path: ["costSource"]
15131
15131
  });
15132
15132
  }
15133
15133
  if (usage.unpricedModels !== void 0 && usage.costSource !== "publicPrice") {
15134
- context.addIssue({
15134
+ context2.addIssue({
15135
15135
  code: "custom",
15136
15136
  message: "Thread Usage unpricedModels must be provided with a publicPrice cost",
15137
15137
  path: ["unpricedModels"]
15138
15138
  });
15139
15139
  }
15140
15140
  if (usage.planFiveHourResetsAtUnix !== void 0 && usage.planFiveHourUsedPercent === void 0) {
15141
- context.addIssue({
15141
+ context2.addIssue({
15142
15142
  code: "custom",
15143
15143
  message: "Thread Usage planFiveHourResetsAtUnix must be provided with planFiveHourUsedPercent",
15144
15144
  path: ["planFiveHourResetsAtUnix"]
15145
15145
  });
15146
15146
  }
15147
15147
  if (usage.planSevenDayResetsAtUnix !== void 0 && usage.planSevenDayUsedPercent === void 0) {
15148
- context.addIssue({
15148
+ context2.addIssue({
15149
15149
  code: "custom",
15150
15150
  message: "Thread Usage planSevenDayResetsAtUnix must be provided with planSevenDayUsedPercent",
15151
15151
  path: ["planSevenDayResetsAtUnix"]
@@ -15253,10 +15253,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15253
15253
 
15254
15254
  // ../shared-contracts/dist/json-value.js
15255
15255
  function rejectExplicitUndefined(keys) {
15256
- return (value, context) => {
15256
+ return (value, context2) => {
15257
15257
  for (const key of keys) {
15258
15258
  if (Object.hasOwn(value, key) && value[key] === void 0) {
15259
- context.addIssue({
15259
+ context2.addIssue({
15260
15260
  code: "custom",
15261
15261
  path: [key],
15262
15262
  message: "Explicit undefined is not valid JSON"
@@ -15340,11 +15340,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15340
15340
  var harnessPermissionModeCatalogSchema = external_exports.object({
15341
15341
  modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
15342
15342
  defaultModeId: harnessPermissionModeIdSchema
15343
- }).strict().superRefine((catalog, context) => {
15343
+ }).strict().superRefine((catalog, context2) => {
15344
15344
  const ids = /* @__PURE__ */ new Set();
15345
15345
  for (const [index, mode2] of catalog.modes.entries()) {
15346
15346
  if (ids.has(mode2.id)) {
15347
- context.addIssue({
15347
+ context2.addIssue({
15348
15348
  code: "custom",
15349
15349
  message: "Permission Mode IDs must be unique",
15350
15350
  path: ["modes", index, "id"]
@@ -15353,7 +15353,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15353
15353
  ids.add(mode2.id);
15354
15354
  }
15355
15355
  if (!ids.has(catalog.defaultModeId)) {
15356
- context.addIssue({
15356
+ context2.addIssue({
15357
15357
  code: "custom",
15358
15358
  message: "Default Permission Mode must exist in the catalog",
15359
15359
  path: ["defaultModeId"]
@@ -15396,11 +15396,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15396
15396
  return void 0;
15397
15397
  return catalog?.models.find((model2) => model2.ref.id === ref.id || model2.fastModel?.id === ref.id);
15398
15398
  }
15399
- var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15399
+ var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context2) => {
15400
15400
  const ids = /* @__PURE__ */ new Set();
15401
15401
  for (const [index, option] of options.entries()) {
15402
15402
  if (ids.has(option.id)) {
15403
- context.addIssue({
15403
+ context2.addIssue({
15404
15404
  code: "custom",
15405
15405
  message: "Thinking option IDs must be unique",
15406
15406
  path: [index, "id"]
@@ -15414,12 +15414,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15414
15414
  defaultModel: harnessModelRefSchema.optional(),
15415
15415
  thinkingOptions: harnessThinkingOptionsSchema,
15416
15416
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15417
- }).strict().superRefine((catalog, context) => {
15417
+ }).strict().superRefine((catalog, context2) => {
15418
15418
  const refs = /* @__PURE__ */ new Set();
15419
15419
  const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15420
15420
  for (const [index, model2] of catalog.models.entries()) {
15421
15421
  if (refs.has(model2.ref.id)) {
15422
- context.addIssue({
15422
+ context2.addIssue({
15423
15423
  code: "custom",
15424
15424
  message: "Model Catalog refs must be unique",
15425
15425
  path: ["models", index, "ref", "id"]
@@ -15428,7 +15428,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15428
15428
  refs.add(model2.ref.id);
15429
15429
  if (model2.fastModel) {
15430
15430
  if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15431
- context.addIssue({
15431
+ context2.addIssue({
15432
15432
  code: "custom",
15433
15433
  message: "Fast Model refs must be distinct and unique",
15434
15434
  path: ["models", index, "fastModel"]
@@ -15439,7 +15439,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15439
15439
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15440
15440
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
15441
15441
  if (supportedThinkingIds.has(optionId)) {
15442
- context.addIssue({
15442
+ context2.addIssue({
15443
15443
  code: "custom",
15444
15444
  message: "Supported Thinking option IDs must be unique per Model",
15445
15445
  path: ["models", index, "supportedThinkingOptionIds", optionIndex]
@@ -15447,7 +15447,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15447
15447
  }
15448
15448
  supportedThinkingIds.add(optionId);
15449
15449
  if (!thinkingIds.has(optionId)) {
15450
- context.addIssue({
15450
+ context2.addIssue({
15451
15451
  code: "custom",
15452
15452
  message: "Supported Thinking option must exist in the catalog",
15453
15453
  path: ["models", index, "supportedThinkingOptionIds", optionIndex]
@@ -15456,14 +15456,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15456
15456
  }
15457
15457
  }
15458
15458
  if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15459
- context.addIssue({
15459
+ context2.addIssue({
15460
15460
  code: "custom",
15461
15461
  message: "Default Model must exist in the Model Catalog",
15462
15462
  path: ["defaultModel", "id"]
15463
15463
  });
15464
15464
  }
15465
15465
  if (catalog.defaultThinkingOptionId && !thinkingIds.has(catalog.defaultThinkingOptionId)) {
15466
- context.addIssue({
15466
+ context2.addIssue({
15467
15467
  code: "custom",
15468
15468
  message: "Default Thinking option must exist in the catalog",
15469
15469
  path: ["defaultThinkingOptionId"]
@@ -15508,9 +15508,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15508
15508
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15509
15509
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15510
15510
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15511
- }).strict().superRefine((state, context) => {
15511
+ }).strict().superRefine((state, context2) => {
15512
15512
  if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15513
- context.addIssue({
15513
+ context2.addIssue({
15514
15514
  code: "custom",
15515
15515
  message: "Effective Thinking option must be currently available",
15516
15516
  path: ["effectiveThinkingOptionId"]
@@ -15527,10 +15527,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15527
15527
  permissionModes: harnessPermissionModeCatalogSchema.optional(),
15528
15528
  capabilities: harnessSessionCapabilitiesSchema,
15529
15529
  webUi: harnessWebUiCapabilitySchema.optional()
15530
- }).strict().superRefine((inspection, context) => {
15530
+ }).strict().superRefine((inspection, context2) => {
15531
15531
  const selectable = inspection.capabilities.configuration.selectPermissionMode;
15532
15532
  if (selectable !== Boolean(inspection.permissionModes)) {
15533
- context.addIssue({
15533
+ context2.addIssue({
15534
15534
  code: "custom",
15535
15535
  message: "Permission Mode catalog and capability must agree",
15536
15536
  path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
@@ -15592,11 +15592,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15592
15592
  ]);
15593
15593
  var threadOwnershipListParamsSchema = external_exports.object({
15594
15594
  threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15595
- }).strict().superRefine(({ threadIds }, context) => {
15595
+ }).strict().superRefine(({ threadIds }, context2) => {
15596
15596
  const seen = /* @__PURE__ */ new Set();
15597
15597
  for (const [index, threadId] of threadIds.entries()) {
15598
15598
  if (seen.has(threadId)) {
15599
- context.addIssue({
15599
+ context2.addIssue({
15600
15600
  code: "custom",
15601
15601
  message: "Thread ownership-list IDs must be unique",
15602
15602
  path: ["threadIds", index]
@@ -15620,11 +15620,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15620
15620
  ]);
15621
15621
  var threadOwnershipListResultSchema = external_exports.object({
15622
15622
  threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15623
- }).strict().superRefine(({ threads }, context) => {
15623
+ }).strict().superRefine(({ threads }, context2) => {
15624
15624
  const seen = /* @__PURE__ */ new Set();
15625
15625
  for (const [index, thread] of threads.entries()) {
15626
15626
  if (seen.has(thread.threadId)) {
15627
- context.addIssue({
15627
+ context2.addIssue({
15628
15628
  code: "custom",
15629
15629
  message: "Thread ownership-list results must be unique",
15630
15630
  path: ["threads", index, "threadId"]
@@ -15639,6 +15639,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15639
15639
  text: external_exports.string().optional()
15640
15640
  }).strict();
15641
15641
  var THREAD_STEER_DELIVERY_PARAM = "codexhostSteerDelivery";
15642
+ var THREAD_STEERING_CONTEXT_PARAM = "codexhost_external_steering";
15643
+ var threadSteeringContextSchema = external_exports.object({
15644
+ kind: external_exports.literal("application"),
15645
+ value: external_exports.string().transform((text, context2) => {
15646
+ try {
15647
+ return JSON.parse(text);
15648
+ } catch {
15649
+ context2.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15650
+ return external_exports.NEVER;
15651
+ }
15652
+ }).pipe(external_exports.object({
15653
+ expectedTurnId: hostTurnIdSchema,
15654
+ clientUserMessageId: external_exports.string().min(1),
15655
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
15656
+ }).strict())
15657
+ }).strict().transform((context2) => context2.value);
15642
15658
  var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15643
15659
  var threadSteeringInspectResultSchema = external_exports.object({
15644
15660
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
@@ -15967,11 +15983,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15967
15983
  * Omitted by Adapters; set by the Host on inspection results.
15968
15984
  */
15969
15985
  source: external_exports.enum(["live", "static"]).optional()
15970
- }).strict().superRefine((catalog, context) => {
15986
+ }).strict().superRefine((catalog, context2) => {
15971
15987
  const ids = /* @__PURE__ */ new Set();
15972
15988
  for (const [index, command] of catalog.commands.entries()) {
15973
15989
  if (ids.has(command.id)) {
15974
- context.addIssue({
15990
+ context2.addIssue({
15975
15991
  code: "custom",
15976
15992
  message: "Harness command IDs must be unique",
15977
15993
  path: ["commands", index, "id"]
@@ -16094,9 +16110,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16094
16110
  downloadedBytes: external_exports.number().int().nonnegative().optional(),
16095
16111
  totalBytes: external_exports.number().int().positive().optional(),
16096
16112
  error: external_exports.string().min(1).max(UPDATE_ERROR_MAX_LENGTH).nullable()
16097
- }).superRefine((status, context) => {
16113
+ }).superRefine((status, context2) => {
16098
16114
  if (status.downloadedBytes !== void 0 && status.totalBytes !== void 0 && status.downloadedBytes > status.totalBytes) {
16099
- context.addIssue({
16115
+ context2.addIssue({
16100
16116
  code: "custom",
16101
16117
  path: ["downloadedBytes"],
16102
16118
  message: "downloadedBytes must not exceed totalBytes"
@@ -16154,10 +16170,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16154
16170
  var CONTROL_CHARACTER_PATTERN = /[\u0000-\u001f\u007f]/u;
16155
16171
  function desktopImageAttachmentPaths(text) {
16156
16172
  const end = text.search(REQUEST_HEADING);
16157
- const context = end < 0 ? text : text.slice(0, end);
16158
- if (!ATTACHED_FILES_HEADING.test(context))
16173
+ const context2 = end < 0 ? text : text.slice(0, end);
16174
+ if (!ATTACHED_FILES_HEADING.test(context2))
16159
16175
  return [];
16160
- return [...context.matchAll(IMAGE_ATTACHMENT_PATTERN)].map((match) => match[1] ?? "").filter((path) => path.length > 0 && !CONTROL_CHARACTER_PATTERN.test(path));
16176
+ return [...context2.matchAll(IMAGE_ATTACHMENT_PATTERN)].map((match) => match[1] ?? "").filter((path) => path.length > 0 && !CONTROL_CHARACTER_PATTERN.test(path));
16161
16177
  }
16162
16178
 
16163
16179
  // ../shared-contracts/dist/remote-runtime.js
@@ -16810,15 +16826,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16810
16826
  // ../desktop-control/dist/renderer-host-rpc-discovery.js
16811
16827
  function findRendererAppScopeStore(root) {
16812
16828
  const MAX_VISITED_FIBERS = 5e4;
16813
- const record19 = (value) => typeof value === "object" && value !== null;
16829
+ const record21 = (value) => typeof value === "object" && value !== null;
16814
16830
  const container = root.getElementById?.("root");
16815
- if (!record19(container))
16831
+ if (!record21(container))
16816
16832
  return null;
16817
16833
  const key = Object.getOwnPropertyNames(container).find((name) => name.startsWith("__reactContainer$"));
16818
16834
  const first = key ? container[key] : null;
16819
- if (!record19(first))
16835
+ if (!record21(first))
16820
16836
  return null;
16821
- const isScopeHandle = (value) => record19(value) && record19(value.node) && "chain" in value && "scope" in value && typeof value.get === "function" && typeof value.set === "function" && typeof value.watch === "function";
16837
+ const isScopeHandle = (value) => record21(value) && record21(value.node) && "chain" in value && "scope" in value && typeof value.get === "function" && typeof value.set === "function" && typeof value.watch === "function";
16822
16838
  const stack = [first];
16823
16839
  const seen = /* @__PURE__ */ new Set();
16824
16840
  while (stack.length && seen.size < MAX_VISITED_FIBERS) {
@@ -16827,41 +16843,43 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16827
16843
  continue;
16828
16844
  seen.add(fiber);
16829
16845
  let hook = fiber.memoizedState;
16830
- for (let index = 0; record19(hook) && "next" in hook && index < 150; index += 1) {
16846
+ for (let index = 0; record21(hook) && "next" in hook && index < 150; index += 1) {
16831
16847
  const state = hook.memoizedState;
16832
- const handle = record19(state) ? state.current : null;
16848
+ const handle = record21(state) ? state.current : null;
16833
16849
  if (isScopeHandle(handle)) {
16834
16850
  let node = handle.node;
16835
16851
  const nodes = /* @__PURE__ */ new Set();
16836
- while (record19(node.parent) && !nodes.has(node.parent)) {
16852
+ while (record21(node.parent) && !nodes.has(node.parent)) {
16837
16853
  nodes.add(node);
16838
16854
  node = node.parent;
16839
16855
  }
16840
16856
  const bindings = node.familyBindings;
16841
- return record19(bindings) && typeof bindings.get === "function" && typeof bindings.entries === "function" ? node : null;
16857
+ return record21(bindings) && typeof bindings.get === "function" && typeof bindings.entries === "function" ? node : null;
16842
16858
  }
16843
16859
  hook = hook.next;
16844
16860
  }
16845
- if (record19(fiber.sibling))
16861
+ if (record21(fiber.sibling))
16846
16862
  stack.push(fiber.sibling);
16847
- if (record19(fiber.child))
16863
+ if (record21(fiber.child))
16848
16864
  stack.push(fiber.child);
16849
16865
  }
16850
16866
  return null;
16851
16867
  }
16852
16868
  function findRendererHostRpcFamily(store) {
16853
- const record19 = (value) => typeof value === "object" && value !== null;
16869
+ const record21 = (value) => typeof value === "object" && value !== null;
16854
16870
  const families = /* @__PURE__ */ new Set();
16855
16871
  for (const [definition, members] of store.familyBindings) {
16856
- if (!record19(definition) || definition.kind !== "signal-family")
16872
+ if (!record21(definition) || definition.kind !== "signal-family")
16857
16873
  continue;
16858
- if (!record19(members) || typeof members.get !== "function")
16874
+ if (!record21(members) || typeof members.get !== "function")
16859
16875
  continue;
16860
16876
  for (const [hostId2, member] of members) {
16861
- if (typeof hostId2 !== "string" || !record19(member))
16877
+ if (typeof hostId2 !== "string" || !/^(?:local$|durable$|remote[-:]|ssh:)/u.test(hostId2))
16878
+ continue;
16879
+ if (!record21(member))
16862
16880
  continue;
16863
16881
  const signal = member.value;
16864
- if (!record19(signal) || typeof signal.get !== "function")
16882
+ if (!record21(signal) || typeof signal.get !== "function")
16865
16883
  continue;
16866
16884
  let value;
16867
16885
  try {
@@ -16869,7 +16887,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16869
16887
  } catch {
16870
16888
  continue;
16871
16889
  }
16872
- if (record19(value) && Object.keys(value).length === 2 && typeof value.status === "string" && record19(value.client) && value.client.hostId === hostId2 && "rpc" in value.client) {
16890
+ if (record21(value) && Object.keys(value).length === 2 && typeof value.status === "string" && record21(value.client) && value.client.hostId === hostId2 && "rpc" in value.client) {
16873
16891
  families.add(members);
16874
16892
  break;
16875
16893
  }
@@ -16880,9 +16898,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16880
16898
  return { store, family: families.values().next().value };
16881
16899
  }
16882
16900
  function resolveRendererHostRpc(discovery, hostId2) {
16883
- const record19 = (value2) => typeof value2 === "object" && value2 !== null;
16901
+ const record21 = (value2) => typeof value2 === "object" && value2 !== null;
16884
16902
  const signal = discovery.family.get(hostId2)?.value;
16885
- if (!record19(signal) || typeof signal.get !== "function")
16903
+ if (!record21(signal) || typeof signal.get !== "function")
16886
16904
  return null;
16887
16905
  let value;
16888
16906
  try {
@@ -16890,10 +16908,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16890
16908
  } catch {
16891
16909
  return null;
16892
16910
  }
16893
- if (!record19(value) || value.status !== "ready" || !record19(value.client) || value.client.hostId !== hostId2)
16911
+ if (!record21(value) || value.status !== "ready" || !record21(value.client) || value.client.hostId !== hostId2)
16894
16912
  return null;
16895
16913
  const rpc = value.client.rpc;
16896
- return typeof rpc === "function" || record19(rpc) ? rpc : null;
16914
+ return typeof rpc === "function" || record21(rpc) ? rpc : null;
16897
16915
  }
16898
16916
  function rendererHostRpcUsesExternalQueue(store, conversationId) {
16899
16917
  const providers = /* @__PURE__ */ new Map();
@@ -17181,11 +17199,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17181
17199
  for (const row of rows) {
17182
17200
  if (row.length !== 24 || row[7] !== null || row[10] !== true || !updates.has(row[13]))
17183
17201
  continue;
17184
- const context = row[12];
17202
+ const context2 = row[12];
17185
17203
  const result = row[23];
17186
- if (context && context === row[21] && typeof context.usesAccountPreferences === "boolean" && result?.usesAccountPreferences === context.usesAccountPreferences && typeof row[14] === "function" && row[14] === row[20] && result.setModelAndReasoningEffort === row[14]) {
17204
+ if (context2 && context2 === row[21] && typeof context2.usesAccountPreferences === "boolean" && result?.usesAccountPreferences === context2.usesAccountPreferences && typeof row[14] === "function" && row[14] === row[20] && result.setModelAndReasoningEffort === row[14]) {
17187
17205
  update ??= row[13];
17188
- modes.add(context.usesAccountPreferences);
17206
+ modes.add(context2.usesAccountPreferences);
17189
17207
  const settings = result.modelSettings;
17190
17208
  const candidate = previousRows.get(row);
17191
17209
  const mode2 = candidate?.[44];
@@ -17330,14 +17348,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17330
17348
 
17331
17349
  // ../desktop-control/dist/renderer-host-discovery.js
17332
17350
  function requestManagerFromHookState(value, hostId2) {
17333
- const record19 = (candidate) => typeof candidate === "object" && candidate !== null;
17351
+ const record21 = (candidate) => typeof candidate === "object" && candidate !== null;
17334
17352
  const manager = (candidate) => {
17335
- if (!record19(candidate) || !record19(candidate.requestClient) || !record19(candidate.prewarmedThreadManager))
17353
+ if (!record21(candidate) || !record21(candidate.requestClient) || !record21(candidate.prewarmedThreadManager))
17336
17354
  return null;
17337
17355
  const bridge = candidate.requestClient;
17338
17356
  return typeof candidate.sendRequest === "function" && typeof bridge.sendRequest === "function" && typeof bridge.prewarmThreadStart === "function" && typeof bridge.enqueueRequest === "function" && typeof candidate.prewarmedThreadManager.discardAllPrewarmedThreads === "function" ? candidate : null;
17339
17357
  };
17340
- if (!record19(value))
17358
+ if (!record21(value))
17341
17359
  return null;
17342
17360
  const direct = manager(value) ?? manager(value.manager);
17343
17361
  if (direct)
@@ -17856,10 +17874,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17856
17874
  const seenDependencies = /* @__PURE__ */ new Set();
17857
17875
  while (record6(dependency) && seenDependencies.size < 4096 && !seenDependencies.has(dependency)) {
17858
17876
  seenDependencies.add(dependency);
17859
- const context = dependency.context;
17877
+ const context2 = dependency.context;
17860
17878
  const chain = dependency.memoizedValue;
17861
- if (record6(context) && context.displayName === native.scopeDefinition.__scopeBrand && chain instanceof Map && chain.get(native.scopeDefinition.id) === appNode)
17862
- contexts.add(context);
17879
+ if (record6(context2) && context2.displayName === native.scopeDefinition.__scopeBrand && chain instanceof Map && chain.get(native.scopeDefinition.id) === appNode)
17880
+ contexts.add(context2);
17863
17881
  dependency = dependency.next;
17864
17882
  }
17865
17883
  }
@@ -19101,7 +19119,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19101
19119
  "[data-codexhost-background-activity] .activity-error{font-size:12px;padding:0 20px;color:var(--color-text-danger,light-dark(#a32020,#ffaaa0))}"
19102
19120
  ].join("\n");
19103
19121
  function installRendererBackgroundActivity(window2, readContext) {
19104
- let context = null;
19122
+ let context2 = null;
19105
19123
  let revision = 0;
19106
19124
  let disposed = false;
19107
19125
  let inFlight = null;
@@ -19119,7 +19137,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19119
19137
  let renderedOutput;
19120
19138
  let navigation = null;
19121
19139
  const unsupported = /* @__PURE__ */ new WeakSet();
19122
- const valid = (owner, token) => !disposed && token === revision && same(owner, context) && same(owner, readContext());
19140
+ const valid = (owner, token) => !disposed && token === revision && same(owner, context2) && same(owner, readContext());
19123
19141
  const message2 = (error51) => error51 instanceof Error ? error51.message : "Native activity is unavailable";
19124
19142
  const setError = (text) => {
19125
19143
  if (errorNode && errorNode.textContent !== text) errorNode.textContent = text;
@@ -19200,7 +19218,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19200
19218
  openRendererActivityChild(owner, child);
19201
19219
  };
19202
19220
  const showDetail = async (id) => {
19203
- const owner = context;
19221
+ const owner = context2;
19204
19222
  if (!owner) return;
19205
19223
  const token = revision;
19206
19224
  selected = selected === id ? null : id;
@@ -19223,7 +19241,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19223
19241
  }
19224
19242
  };
19225
19243
  const render = () => {
19226
- if (!body || !context) return;
19244
+ if (!body || !context2) return;
19227
19245
  const key = JSON.stringify([
19228
19246
  activities,
19229
19247
  selected,
@@ -19261,7 +19279,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19261
19279
  note.textContent = "Native output is truncated.";
19262
19280
  content.append(note);
19263
19281
  }
19264
- const owner = context;
19282
+ const owner = context2;
19265
19283
  const token = revision;
19266
19284
  if (activity.relatedActivityId) {
19267
19285
  const id = activity.relatedActivityId;
@@ -19381,13 +19399,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19381
19399
  const refresh = async () => {
19382
19400
  if (disposed) return;
19383
19401
  const next = readContext();
19384
- if (!same(context, next)) {
19402
+ if (!same(context2, next)) {
19385
19403
  revision++;
19386
19404
  inFlight = null;
19387
19405
  clear();
19388
- context = next;
19406
+ context2 = next;
19389
19407
  }
19390
- const owner = context;
19408
+ const owner = context2;
19391
19409
  if (!owner) return;
19392
19410
  if (inFlight || unsupported.has(owner.route)) return;
19393
19411
  const token = revision;
@@ -19444,7 +19462,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19444
19462
  void refresh();
19445
19463
  return {
19446
19464
  refreshContext() {
19447
- if (!same(context, readContext()) || root && !root.isConnected) void refresh();
19465
+ if (!same(context2, readContext()) || root && !root.isConnected) void refresh();
19448
19466
  },
19449
19467
  dispose() {
19450
19468
  disposed = true;
@@ -19511,6 +19529,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19511
19529
  }
19512
19530
 
19513
19531
  // src/codex-native-services.ts
19532
+ var MAX_RUNTIME_MODULES = 32768;
19533
+ var MAX_RUNTIME_EXPORTS = 131072;
19534
+ var RUNTIME_SCAN_SLICE = 2048;
19535
+ var COMPILED_EXPORT_GETTER = /^(?:\(\)=>|function\(\)\{return )[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[(?:[A-Za-z_$][\w$]*|"[^"\\]*"|'[^'\\]*')\])*\}?$/;
19536
+ var objectLike = (value) => (typeof value === "object" || typeof value === "function") && value !== null;
19537
+ function instantiatedModules(namespace) {
19538
+ const runtime = namespace.__webpack_require__;
19539
+ if (typeof runtime !== "function") return null;
19540
+ const cache = Object.getOwnPropertyDescriptor(runtime, "c")?.value;
19541
+ return objectLike(cache) ? cache : null;
19542
+ }
19543
+ function compiledExportValues(module) {
19544
+ if (!objectLike(module) || Object.hasOwn(module, "error")) return [];
19545
+ const exports = Object.getOwnPropertyDescriptor(module, "exports")?.value;
19546
+ if (typeof exports !== "object" || exports === null) return [];
19547
+ const prototype = Object.getPrototypeOf(exports);
19548
+ if (prototype !== Object.prototype && prototype !== null) return [];
19549
+ const values = [];
19550
+ for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(exports))) {
19551
+ if (!descriptor.enumerable || descriptor.configurable) continue;
19552
+ if ("value" in descriptor) {
19553
+ values.push(descriptor.value);
19554
+ continue;
19555
+ }
19556
+ if (!descriptor.get) continue;
19557
+ try {
19558
+ if (COMPILED_EXPORT_GETTER.test(Function.prototype.toString.call(descriptor.get)))
19559
+ values.push(descriptor.get.call(exports));
19560
+ } catch {
19561
+ }
19562
+ }
19563
+ return values;
19564
+ }
19514
19565
  async function loadCodexNativeServices(ownerWindow, matchesServices, importModule = (url2) => import(url2)) {
19515
19566
  if (!ownerWindow.document || !ownerWindow.location) return null;
19516
19567
  const page = new URL(ownerWindow.location.href);
@@ -19540,6 +19591,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19540
19591
  (a, b) => Number(b.includes("/app-shared-")) - Number(a.includes("/app-shared-"))
19541
19592
  );
19542
19593
  const matches = /* @__PURE__ */ new Set();
19594
+ const addMatch = (value) => {
19595
+ if (matchesServices(value)) matches.add(value);
19596
+ if (matches.size > 1) throw new Error("Codex native services are unavailable in this window");
19597
+ };
19598
+ const runtimes = /* @__PURE__ */ new Set();
19543
19599
  for (const url2 of candidates) {
19544
19600
  let module;
19545
19601
  try {
@@ -19547,8 +19603,24 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19547
19603
  } catch {
19548
19604
  continue;
19549
19605
  }
19550
- for (const value of Object.values(module).filter(matchesServices)) matches.add(value);
19551
- if (matches.size > 1) throw new Error("Codex native services are unavailable in this window");
19606
+ Object.values(module).forEach(addMatch);
19607
+ const runtime = instantiatedModules(module);
19608
+ if (runtime) runtimes.add(runtime);
19609
+ }
19610
+ let scannedExports = 0;
19611
+ for (const runtime of runtimes) {
19612
+ const modules = Object.values(runtime);
19613
+ if (modules.length > MAX_RUNTIME_MODULES)
19614
+ throw new Error("Codex native services are unavailable in this window");
19615
+ for (const [index, module] of modules.entries()) {
19616
+ if (index > 0 && index % RUNTIME_SCAN_SLICE === 0)
19617
+ await new Promise((resolve) => setTimeout(resolve));
19618
+ const values = compiledExportValues(module);
19619
+ scannedExports += values.length;
19620
+ if (scannedExports > MAX_RUNTIME_EXPORTS)
19621
+ throw new Error("Codex native services are unavailable in this window");
19622
+ values.forEach(addMatch);
19623
+ }
19552
19624
  }
19553
19625
  if (catalog !== void 0 && Reflect.get(ownerWindow, "__codexhostLoadedModulesV1") !== catalog)
19554
19626
  throw new Error("Codex loaded module catalog changed during discovery. Try again once ready.");
@@ -20314,7 +20386,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20314
20386
  let disposed = false;
20315
20387
  let inFlight = false;
20316
20388
  let revision = 0;
20317
- let context = null;
20389
+ let context2 = null;
20318
20390
  let card = null;
20319
20391
  let cardKey = null;
20320
20392
  let stopActivity;
@@ -20335,12 +20407,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20335
20407
  const refresh = async () => {
20336
20408
  if (disposed) return;
20337
20409
  const next = readContext();
20338
- if (!same2(context, next)) {
20410
+ if (!same2(context2, next)) {
20339
20411
  clear();
20340
- context = next;
20412
+ context2 = next;
20341
20413
  revision++;
20342
20414
  }
20343
- const current = context;
20415
+ const current = context2;
20344
20416
  if (!current || inFlight || unsupported.has(current.route)) return;
20345
20417
  const startedRevision = revision;
20346
20418
  inFlight = true;
@@ -20390,7 +20462,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20390
20462
  );
20391
20463
  threadQuestionRespondResultSchema.parse(raw2);
20392
20464
  drafts.delete(key);
20393
- if (same2(current, context)) {
20465
+ if (same2(current, context2)) {
20394
20466
  revision++;
20395
20467
  if (cardKey === key) clear(false);
20396
20468
  }
@@ -20420,7 +20492,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20420
20492
  );
20421
20493
  } catch (error51) {
20422
20494
  if (isUnsupportedMethod(error51, THREAD_QUESTIONS_LIST_METHOD)) unsupported.add(current.route);
20423
- if (revision === startedRevision && same2(current, context)) clear();
20495
+ if (revision === startedRevision && same2(current, context2)) clear();
20424
20496
  } finally {
20425
20497
  inFlight = false;
20426
20498
  }
@@ -20432,7 +20504,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
20432
20504
  return {
20433
20505
  refresh,
20434
20506
  refreshContext() {
20435
- if (!same2(context, readContext()) || card && !card.root.isConnected) void refresh();
20507
+ if (!same2(context2, readContext()) || card && !card.root.isConnected) void refresh();
20436
20508
  },
20437
20509
  dispose() {
20438
20510
  disposed = true;
@@ -20597,9 +20669,9 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
20597
20669
  }
20598
20670
  return Object.create(Object.getPrototypeOf(value), descriptors);
20599
20671
  }
20600
- async function prepareRendererRpcAttachments(value, context) {
20672
+ async function prepareRendererRpcAttachments(value, context2) {
20601
20673
  if (!record10(value) || !record10(value.steer) || !Array.isArray(value.steer.input)) return value;
20602
- const { manager, threadId, isCurrent } = context;
20674
+ const { manager, threadId, isCurrent } = context2;
20603
20675
  const created = /* @__PURE__ */ new Set();
20604
20676
  const uploads = /* @__PURE__ */ new Map();
20605
20677
  const storage = {
@@ -20622,7 +20694,7 @@ ${text.includes("## My request:") ? "" : "\n## My request:\n"}`,
20622
20694
  return manager.removePastedTextAttachment(path);
20623
20695
  }
20624
20696
  };
20625
- const send = createRemoteAttachmentSender(storage, context.hostId, isCurrent);
20697
+ const send = createRemoteAttachmentSender(storage, context2.hostId, isCurrent);
20626
20698
  const input = async (request) => {
20627
20699
  const prepared = await send({ ...request, threadId }, (params) => params);
20628
20700
  if (!record10(prepared)) throw new Error("Image attachment preparation returned invalid input");
@@ -22625,8 +22697,8 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
22625
22697
  id: "connections",
22626
22698
  label: messages.pageLabels.connections,
22627
22699
  icon: "connections",
22628
- mount(context) {
22629
- const document2 = context.content.ownerDocument;
22700
+ mount(context2) {
22701
+ const document2 = context2.content.ownerDocument;
22630
22702
  const header = document2.createElement("div");
22631
22703
  header.className = "settings-connection-page-header";
22632
22704
  const headingCopy = document2.createElement("div");
@@ -22648,7 +22720,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
22648
22720
  const syncMessage = document2.createElement("p");
22649
22721
  syncMessage.className = "settings-page-description";
22650
22722
  syncMessage.setAttribute("role", "status");
22651
- context.content.append(header, syncMessage, content);
22723
+ context2.content.append(header, syncMessage, content);
22652
22724
  let pending = false;
22653
22725
  let selectedHostId = null;
22654
22726
  let selectedItemKey = null;
@@ -22660,12 +22732,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
22660
22732
  let renderQueued = false;
22661
22733
  let renderFrame = null;
22662
22734
  const scheduleRender = () => {
22663
- if (disposed || context.signal.aborted || renderQueued) return;
22735
+ if (disposed || context2.signal.aborted || renderQueued) return;
22664
22736
  renderQueued = true;
22665
22737
  const flush = () => {
22666
22738
  renderFrame = null;
22667
22739
  renderQueued = false;
22668
- if (!disposed && !context.signal.aborted) {
22740
+ if (!disposed && !context2.signal.aborted) {
22669
22741
  render(diagnostics?.snapshot() ?? latestSnapshot);
22670
22742
  }
22671
22743
  };
@@ -22684,12 +22756,12 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
22684
22756
  const versions = createConnectionVersions(
22685
22757
  document2,
22686
22758
  messages,
22687
- context.signal,
22759
+ context2.signal,
22688
22760
  diagnostics,
22689
22761
  scheduleRender
22690
22762
  );
22691
22763
  const installs = diagnostics ? harnessInstallStore(diagnostics) : null;
22692
- const updates = createConnectionUpdates(document2, messages, context.signal, scheduleRender);
22764
+ const updates = createConnectionUpdates(document2, messages, context2.signal, scheduleRender);
22693
22765
  const runRefresh = () => {
22694
22766
  if (pending || !diagnostics) return;
22695
22767
  pending = true;
@@ -22698,7 +22770,7 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
22698
22770
  createRendererSettingsIcon("diagnose", 16),
22699
22771
  messages.connectionRefreshing
22700
22772
  );
22701
- void context.runLatest(() => diagnostics.refresh(), {
22773
+ void context2.runLatest(() => diagnostics.refresh(), {
22702
22774
  success() {
22703
22775
  installs?.clearErrors();
22704
22776
  pending = false;
@@ -23054,9 +23126,9 @@ ${messages.harnessVersionLatest}: ${harnessVersionLabel(version2.state, messages
23054
23126
  }
23055
23127
  };
23056
23128
  render(diagnostics?.snapshot() ?? null);
23057
- void getRemoteConnections()?.ssh.list(context.signal).then(
23129
+ void getRemoteConnections()?.ssh.list(context2.signal).then(
23058
23130
  (connections) => {
23059
- if (context.signal.aborted) return;
23131
+ if (context2.signal.aborted) return;
23060
23132
  for (const connection of connections) {
23061
23133
  hostNames.set(connection.hostId, connection.displayName.trim());
23062
23134
  }
@@ -27327,7 +27399,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
27327
27399
  let fiber = fiberName ? Object.getOwnPropertyDescriptor(element, fiberName)?.value : null;
27328
27400
  for (let depth = 0; fiber && depth < 60; depth += 1) {
27329
27401
  const props = fiber.memoizedProps;
27330
- if (isRecord4(props) && typeof props.onSelectModel === "function" && typeof props.onSelectReasoningEffort === "function" && "reasoningEffort" in props && isRecord4(props.fallbackPowerSelection)) {
27402
+ if (isRecord4(props) && typeof props.onSelectModel === "function" && "reasoningEffort" in props && (typeof props.onSelectReasoningEffort === "function" && isRecord4(props.fallbackPowerSelection) || element.getAttribute("data-composer-navigation-target") === "reasoning" && typeof props.onCommitPower === "function" && Array.isArray(props.powerSelections))) {
27331
27403
  return true;
27332
27404
  }
27333
27405
  const parent = fiber.return;
@@ -27438,8 +27510,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
27438
27510
  }
27439
27511
  }
27440
27512
  function usagePlacementAnchor(control) {
27441
- const context = control.nativeContextUsageControl?.element;
27442
- const contextWrapper = context?.parentElement;
27513
+ const context2 = control.nativeContextUsageControl?.element;
27514
+ const contextWrapper = context2?.parentElement;
27443
27515
  if (contextWrapper?.parentElement) return contextWrapper;
27444
27516
  const modelRoot = control.modelPicker?.root;
27445
27517
  return modelRoot?.parentElement ? modelRoot : null;
@@ -27665,7 +27737,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
27665
27737
  const modelReady = selectedModel !== void 0 && selectedCatalogModel !== void 0;
27666
27738
  const modelBlocked = state.agent !== "codex" && (modelView.status === "selecting" || !modelReady || !thinkingReady);
27667
27739
  const permissionModeBlocked = state.agent !== "codex" && !isPermissionModeControlReady(permissionModeView);
27668
- const submissionBlocked = switching || ownershipError || modelBlocked || permissionModeBlocked;
27740
+ const submissionBlocked = switching || ownershipError || state.agent !== "codex" && adapterState !== "ready" || modelBlocked || permissionModeBlocked;
27669
27741
  if (submissionBlocked && control.sendDisabledBeforeSwitch === null) {
27670
27742
  control.sendDisabledBeforeSwitch = control.sendButton.disabled;
27671
27743
  control.sendButton.disabled = true;
@@ -28906,9 +28978,31 @@ Codex Fast mode prioritizes requests and may increase usage.`
28906
28978
  return installLocalQueueGate(target);
28907
28979
  }
28908
28980
 
28981
+ // src/renderer-steering-delivery.ts
28982
+ async function inspectRendererSteeringDelivery(send, threadId, text) {
28983
+ const inspect = "codexhost/thread/steering/inspect";
28984
+ try {
28985
+ const response2 = await send(inspect, { threadId, ...text !== void 0 ? { text } : {} });
28986
+ return threadSteeringInspectResultSchema.parse(response2).delivery;
28987
+ } catch (error51) {
28988
+ if (!isUnsupportedMethod(error51, inspect)) throw error51;
28989
+ }
28990
+ const ownership = "codexhost/thread/ownership/list";
28991
+ let response;
28992
+ try {
28993
+ response = await send(ownership, { threadIds: [threadId] });
28994
+ } catch (error51) {
28995
+ if (!isUnsupportedMethod(error51, ownership)) throw error51;
28996
+ await verifyNativeCodexThread(send, threadId);
28997
+ return "official";
28998
+ }
28999
+ const result = threadOwnershipListResultSchema.parse(response);
29000
+ const owner = result.threads.find((thread) => thread.threadId === threadId)?.owner;
29001
+ if (!owner) throw new Error("Thread ownership could not be resolved for steering");
29002
+ return owner === "codex" ? "official" : "newTurn";
29003
+ }
29004
+
28909
29005
  // src/renderer-external-steering.ts
28910
- var THREAD_STEERING_INSPECT_METHOD = "codexhost/thread/steering/inspect";
28911
- var THREAD_OWNERSHIP_LIST_METHOD2 = "codexhost/thread/ownership/list";
28912
29006
  function isRecord10(value) {
28913
29007
  return value !== null && typeof value === "object" && !Array.isArray(value);
28914
29008
  }
@@ -28937,9 +29031,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
28937
29031
  function queuedFollowUpText(message2) {
28938
29032
  if (!isRecord10(message2)) return "";
28939
29033
  if (typeof message2.text === "string" && message2.text.trim()) return message2.text;
28940
- const context = message2.context;
28941
- if (isRecord10(context) && typeof context.prompt === "string" && context.prompt.trim()) {
28942
- return context.prompt;
29034
+ const context2 = message2.context;
29035
+ if (isRecord10(context2) && typeof context2.prompt === "string" && context2.prompt.trim()) {
29036
+ return context2.prompt;
28943
29037
  }
28944
29038
  return "";
28945
29039
  }
@@ -29115,34 +29209,11 @@ Codex Fast mode prioritizes requests and may increase usage.`
29115
29209
  };
29116
29210
  });
29117
29211
  };
29118
- const inspectDelivery = async (threadId, text) => {
29119
- try {
29120
- const response = await originalSend.call(manager, THREAD_STEERING_INSPECT_METHOD, {
29121
- threadId,
29122
- ...text !== void 0 ? { text } : {}
29123
- });
29124
- return threadSteeringInspectResultSchema.parse(response).delivery;
29125
- } catch (error51) {
29126
- if (!isUnsupportedMethod(error51, THREAD_STEERING_INSPECT_METHOD)) throw error51;
29127
- }
29128
- let ownershipResponse;
29129
- try {
29130
- ownershipResponse = await originalSend.call(manager, THREAD_OWNERSHIP_LIST_METHOD2, {
29131
- threadIds: [threadId]
29132
- });
29133
- } catch (error51) {
29134
- if (!isUnsupportedMethod(error51, THREAD_OWNERSHIP_LIST_METHOD2)) throw error51;
29135
- await verifyNativeCodexThread(
29136
- (method, params) => originalSend.call(manager, method, params),
29137
- threadId
29138
- );
29139
- return "official";
29140
- }
29141
- const ownership = threadOwnershipListResultSchema.parse(ownershipResponse);
29142
- const owner = ownership.threads.find((thread) => thread.threadId === threadId)?.owner;
29143
- if (!owner) throw new Error("Thread ownership could not be resolved for steering");
29144
- return owner === "codex" ? "official" : "newTurn";
29145
- };
29212
+ const inspectDelivery = (threadId, text) => inspectRendererSteeringDelivery(
29213
+ (method, params) => originalSend.call(manager, method, params),
29214
+ threadId,
29215
+ text
29216
+ );
29146
29217
  const steer = async function(...args) {
29147
29218
  const [
29148
29219
  threadId,
@@ -29153,7 +29224,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
29153
29224
  clientUserMessageId,
29154
29225
  additionalContext,
29155
29226
  toolOutput,
29156
- onMessageAdded
29227
+ onMessageAdded,
29228
+ beforeSendRequest,
29229
+ assertRequestCurrent
29157
29230
  ] = args;
29158
29231
  if (typeof threadId !== "string") return originalSteer.apply(manager, args);
29159
29232
  const role = manager.getStreamRole?.(threadId);
@@ -29212,7 +29285,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
29212
29285
  if (expectedTurnId == null && host.hasPendingTurnStart(threadId)) {
29213
29286
  throw new Error("Previous Turn submission has not been confirmed yet");
29214
29287
  }
29215
- const context = restoreMessage.context;
29288
+ const context2 = restoreMessage.context;
29216
29289
  const routeKey = `${threadId}\0${messageId}`;
29217
29290
  if (typeof expectedTurnId === "string") routes.set(routeKey, { threadId, expectedTurnId });
29218
29291
  const promise2 = Promise.resolve().then(async () => {
@@ -29232,13 +29305,15 @@ Codex Fast mode prioritizes requests and may increase usage.`
29232
29305
  serviceTier,
29233
29306
  model: null,
29234
29307
  effort: null,
29235
- collaborationMode: context.collaborationMode ?? null
29308
+ collaborationMode: context2.collaborationMode ?? null
29236
29309
  },
29237
29310
  context: {
29238
29311
  attachments: attachments ?? [],
29239
- commentAttachments: context.commentAttachments ?? [],
29240
- mcpAppModelContextAttachments: context.mcpAppModelContextAttachments,
29241
- useAppServerPermissionDefault: true
29312
+ commentAttachments: context2.commentAttachments ?? [],
29313
+ mcpAppModelContextAttachments: context2.mcpAppModelContextAttachments,
29314
+ useAppServerPermissionDefault: true,
29315
+ beforeSendRequest,
29316
+ assertRequestCurrent
29242
29317
  }
29243
29318
  },
29244
29319
  onMessageAdded
@@ -30587,9 +30662,12 @@ Codex Fast mode prioritizes requests and may increase usage.`
30587
30662
  const connected = !disposed && (client !== null || localClient !== null || (window.__codexhostHostRoutingV1?.knownHostIds?.() ?? []).some(
30588
30663
  (hostId2) => window.__codexhostHostRoutingV1?.forHost(hostId2) != null
30589
30664
  ));
30665
+ const manager = route?.manager;
30666
+ const needsRpcSteering = manager != null && "kind" in manager && manager.kind === "main-process-rpc";
30667
+ const steeringReady = !needsRpcSteering || window.__codexhostRpcSteeringV1 !== void 0;
30590
30668
  updateStatus(
30591
30669
  connected ? "ready" : "installing",
30592
- connected ? "ready" : fiberWalkLimited ? "react-fiber-walk-limit-exceeded" : "draft-routing-policy-unavailable",
30670
+ connected && !steeringReady ? "native-steering-policy-unavailable" : connected ? "ready" : fiberWalkLimited ? "react-fiber-walk-limit-exceeded" : "draft-routing-policy-unavailable",
30593
30671
  connected ? "request-bridge" : null
30594
30672
  );
30595
30673
  return route;
@@ -30906,7 +30984,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
30906
30984
  systemLocale: optionalLocale(value.systemLocale, "system locale")
30907
30985
  };
30908
30986
  }
30909
- function requestNativeLocale(ownerWindow, signal, timeoutMs, matchesServices, invoke) {
30987
+ function requestNativeLocale(ownerWindow, signal, timeoutMs, matchesServices, invoke2) {
30910
30988
  if (signal?.aborted) return Promise.reject(abortError2());
30911
30989
  return new Promise((resolve, reject) => {
30912
30990
  let settled2 = false;
@@ -30933,7 +31011,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
30933
31011
  const native = await loadCodexNativeServices(ownerWindow, matchesServices);
30934
31012
  if (settled2) return;
30935
31013
  if (!native) throw new Error("Codex native locale services are unavailable");
30936
- nativeRequest = invoke(native);
31014
+ nativeRequest = invoke2(native);
30937
31015
  const response = await nativeRequest;
30938
31016
  settle(() => resolve(response));
30939
31017
  })().catch((error51) => settle(() => reject(error51)));
@@ -31158,8 +31236,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
31158
31236
  id: options.id ?? "voice",
31159
31237
  label: m.title,
31160
31238
  icon: "settings",
31161
- mount(context) {
31162
- const doc = context.content.ownerDocument;
31239
+ mount(context2) {
31240
+ const doc = context2.content.ownerDocument;
31163
31241
  let state = null;
31164
31242
  let base = null;
31165
31243
  let draft = null;
@@ -31249,9 +31327,9 @@ Codex Fast mode prioritizes requests and may increase usage.`
31249
31327
  };
31250
31328
  const render = () => {
31251
31329
  if (disposed) return;
31252
- const tree = context.content.getRootNode();
31330
+ const tree = context2.content.getRootNode();
31253
31331
  const focused = tree.activeElement;
31254
- const focusedId = focused && context.content.contains(focused) ? focused.id : "";
31332
+ const focusedId = focused && context2.content.contains(focused) ? focused.id : "";
31255
31333
  const root = h(doc, "div", { className: "settings-voice" });
31256
31334
  root.append(
31257
31335
  h(doc, "div", { className: "settings-section-label" }, m.title),
@@ -31260,7 +31338,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
31260
31338
  if (!draft || !state) {
31261
31339
  root.append(h(doc, "p", { role: "status" }, offline ? m.unavailable : m.loading));
31262
31340
  if (offline) root.append(button(doc, m.retry, () => void load(true)));
31263
- context.content.replaceChildren(root);
31341
+ context2.content.replaceChildren(root);
31264
31342
  return;
31265
31343
  }
31266
31344
  const unavailable = busy || offline || state.restart.phase === "restarting";
@@ -31456,7 +31534,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
31456
31534
  root.append(h(doc, "p", { className: "settings-voice__hint" }, m.integrationOff));
31457
31535
  if (offline || base?.revision !== state.revision)
31458
31536
  root.append(button(doc, m.retry, () => void load(true)));
31459
- context.content.replaceChildren(root);
31537
+ context2.content.replaceChildren(root);
31460
31538
  if (focusedId)
31461
31539
  root.querySelector(`#${focusedId}`)?.focus({ preventScroll: true });
31462
31540
  };
@@ -32862,8 +32940,8 @@ Codex Fast mode prioritizes requests and may increase usage.`
32862
32940
  id: "usage-statistics",
32863
32941
  label: messages.label,
32864
32942
  icon: "dashboard",
32865
- mount(context) {
32866
- const document2 = context.content.ownerDocument;
32943
+ mount(context2) {
32944
+ const document2 = context2.content.ownerDocument;
32867
32945
  const locale = pageLocale ?? (document2.documentElement.lang || "en");
32868
32946
  const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
32869
32947
  const count4 = (value) => count3(value, locale);
@@ -32921,7 +32999,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
32921
32999
  document2,
32922
33000
  consoleMessages2,
32923
33001
  (method, params2) => request(method, params2, view.hostId),
32924
- context.signal,
33002
+ context2.signal,
32925
33003
  load
32926
33004
  );
32927
33005
  let offeredHosts = usageHosts ? [] : void 0;
@@ -32929,7 +33007,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
32929
33007
  label: messages.host,
32930
33008
  searchLabel: messages.search,
32931
33009
  emptyLabel: messages.noMatches,
32932
- signal: context.signal,
33010
+ signal: context2.signal,
32933
33011
  searchable: false,
32934
33012
  display: (option) => `${messages.host} \xB7 ${option.label}`,
32935
33013
  onChange: (key) => {
@@ -32959,7 +33037,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
32959
33037
  const offerHosts = () => {
32960
33038
  if (!usageHosts) return;
32961
33039
  void usageHosts().then((hosts) => {
32962
- if (context.signal.aborted) return;
33040
+ if (context2.signal.aborted) return;
32963
33041
  offeredHosts = hosts;
32964
33042
  hostOptions();
32965
33043
  }).catch(() => void 0);
@@ -32985,7 +33063,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
32985
33063
  label: messages.autoRefresh,
32986
33064
  searchLabel: messages.search,
32987
33065
  emptyLabel: messages.noMatches,
32988
- signal: context.signal,
33066
+ signal: context2.signal,
32989
33067
  searchable: false,
32990
33068
  display: (option) => `${messages.autoRefresh} \xB7 ${option.label}`,
32991
33069
  onChange: (key) => {
@@ -33030,7 +33108,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
33030
33108
  label: messages.filterModel,
33031
33109
  searchLabel: messages.search,
33032
33110
  emptyLabel: messages.noMatches,
33033
- signal: context.signal,
33111
+ signal: context2.signal,
33034
33112
  onChange: (key) => {
33035
33113
  view.model = key;
33036
33114
  changed();
@@ -33040,7 +33118,7 @@ Codex Fast mode prioritizes requests and may increase usage.`
33040
33118
  label: messages.filterProject,
33041
33119
  searchLabel: messages.search,
33042
33120
  emptyLabel: messages.noMatches,
33043
- signal: context.signal,
33121
+ signal: context2.signal,
33044
33122
  onChange: (key) => {
33045
33123
  view.project = key;
33046
33124
  changed();
@@ -33828,7 +33906,7 @@ ${detail}` : ""}`
33828
33906
  }
33829
33907
  function schedule() {
33830
33908
  window.clearTimeout(poll);
33831
- if (context.signal.aborted) return;
33909
+ if (context2.signal.aborted) return;
33832
33910
  if (result && !result.reading.complete) poll = window.setTimeout(load, POLL_MS);
33833
33911
  else if (view.autoRefreshMs > 0) poll = window.setTimeout(load, view.autoRefreshMs);
33834
33912
  }
@@ -33846,12 +33924,12 @@ ${detail}` : ""}`
33846
33924
  } catch {
33847
33925
  if (!isCurrent()) return;
33848
33926
  }
33849
- if (!context.signal.aborted) render();
33927
+ if (!context2.signal.aborted) render();
33850
33928
  }
33851
33929
  function load() {
33852
33930
  window.clearTimeout(poll);
33853
33931
  const requested = params();
33854
- void context.runLatest(() => request(USAGE_STATISTICS_METHOD, requested, view.hostId), {
33932
+ void context2.runLatest(() => request(USAGE_STATISTICS_METHOD, requested, view.hostId), {
33855
33933
  success(value) {
33856
33934
  const parsed = usageStatisticsResultSchema.safeParse(value);
33857
33935
  if (parsed.success) {
@@ -33874,7 +33952,7 @@ ${detail}` : ""}`
33874
33952
  }
33875
33953
  });
33876
33954
  }
33877
- context.content.replaceChildren(header, prices.element, filters, notices, body);
33955
+ context2.content.replaceChildren(header, prices.element, filters, notices, body);
33878
33956
  render();
33879
33957
  offerHosts();
33880
33958
  void refreshHarnessNames();
@@ -35691,8 +35769,8 @@ ${detail}` : ""}`
35691
35769
  id: "session-import",
35692
35770
  label: messages.pageLabels["session-import"],
35693
35771
  icon: "session-import",
35694
- mount(context) {
35695
- const document2 = context.content.ownerDocument;
35772
+ mount(context2) {
35773
+ const document2 = context2.content.ownerDocument;
35696
35774
  const header = document2.createElement("div");
35697
35775
  header.className = "settings-session-import-header";
35698
35776
  const heading = document2.createElement("h2");
@@ -35812,7 +35890,7 @@ ${detail}` : ""}`
35812
35890
  const content = document2.createElement("section");
35813
35891
  content.className = "settings-session-import-content";
35814
35892
  const listControls = createSessionImportListControls(document2, messages, () => load());
35815
- context.content.append(
35893
+ context2.content.append(
35816
35894
  header,
35817
35895
  hostLabel,
35818
35896
  harness2,
@@ -35945,7 +36023,7 @@ ${detail}` : ""}`
35945
36023
  retry.addEventListener("click", () => {
35946
36024
  if (retry.disabled) return;
35947
36025
  setRetrying(true);
35948
- void context.runLatest((signal) => openImportedThread(threadId, signal, hostId2), {
36026
+ void context2.runLatest((signal) => openImportedThread(threadId, signal, hostId2), {
35949
36027
  success() {
35950
36028
  setRetrying(false);
35951
36029
  },
@@ -36006,16 +36084,16 @@ ${detail}` : ""}`
36006
36084
  const actionArea = document2.createElement("div");
36007
36085
  actionArea.className = "settings-session-import-row__action";
36008
36086
  if (candidate.running === true) {
36009
- const running = document2.createElement("span");
36010
- running.className = "settings-session-import-running";
36011
- running.textContent = messages.sessionImportRunning;
36012
- running.title = messages.sessionImportRunningHint;
36013
- running.setAttribute("aria-hidden", "true");
36087
+ const running2 = document2.createElement("span");
36088
+ running2.className = "settings-session-import-running";
36089
+ running2.textContent = messages.sessionImportRunning;
36090
+ running2.title = messages.sessionImportRunningHint;
36091
+ running2.setAttribute("aria-hidden", "true");
36014
36092
  actionArea.append(
36015
- running,
36093
+ running2,
36016
36094
  createAccessibleText(
36017
36095
  document2,
36018
- `${running.textContent}: ${messages.sessionImportRunningHint}`
36096
+ `${running2.textContent}: ${messages.sessionImportRunningHint}`
36019
36097
  )
36020
36098
  );
36021
36099
  }
@@ -36036,7 +36114,7 @@ ${detail}` : ""}`
36036
36114
  refresh.disabled = true;
36037
36115
  updateImportActions();
36038
36116
  let committedThreadId = null;
36039
- void context.runLatest(
36117
+ void context2.runLatest(
36040
36118
  async (signal) => {
36041
36119
  importStatus.replaceChildren();
36042
36120
  const result = await client.importHarnessSession({
@@ -36080,7 +36158,7 @@ ${detail}` : ""}`
36080
36158
  updateImportActions();
36081
36159
  };
36082
36160
  const load = (refreshDiagnostics = false) => {
36083
- if (importingId !== null || context.signal.aborted) return;
36161
+ if (importingId !== null || context2.signal.aborted) return;
36084
36162
  loadedClient = null;
36085
36163
  let client = getClient(selectedHostId);
36086
36164
  if (client?.hostId === "durable") {
@@ -36096,7 +36174,7 @@ ${detail}` : ""}`
36096
36174
  else renderUnavailable();
36097
36175
  const requestedHarness = selectedHarness;
36098
36176
  const pageParams = listControls.params();
36099
- void context.runLatest(
36177
+ void context2.runLatest(
36100
36178
  async (signal) => {
36101
36179
  if (!client) throw new RendererSessionImportUnavailableError();
36102
36180
  const harnesses = await loadSessionImportSources(
@@ -36162,8 +36240,8 @@ ${detail}` : ""}`
36162
36240
  }
36163
36241
 
36164
36242
  // src/settings/loaded-sessions-table.ts
36165
- function mountLoadedSessionsTable(context, messages, getClient) {
36166
- const document2 = context.content.ownerDocument;
36243
+ function mountLoadedSessionsTable(context2, messages, getClient) {
36244
+ const document2 = context2.content.ownerDocument;
36167
36245
  const owner = document2.defaultView;
36168
36246
  if (!owner) return () => void 0;
36169
36247
  const text = messages.loadedSessions;
@@ -36199,7 +36277,7 @@ ${detail}` : ""}`
36199
36277
  scroll.hidden = true;
36200
36278
  header.append(title, description);
36201
36279
  container.append(header, status, scroll);
36202
- context.content.append(container);
36280
+ context2.content.append(container);
36203
36281
  let disposed = false;
36204
36282
  let timer;
36205
36283
  let requestTimer;
@@ -36221,7 +36299,7 @@ ${detail}` : ""}`
36221
36299
  );
36222
36300
  })
36223
36301
  ]);
36224
- if (disposed || context.signal.aborted) return;
36302
+ if (disposed || context2.signal.aborted) return;
36225
36303
  body.replaceChildren();
36226
36304
  for (const row of rows.toSorted(
36227
36305
  (a, b) => b.inactiveMs - a.inactiveMs || a.harnessId.localeCompare(b.harnessId) || a.threadId.localeCompare(b.threadId)
@@ -36245,13 +36323,13 @@ ${detail}` : ""}`
36245
36323
  status.hidden = rows.length > 0;
36246
36324
  scroll.hidden = rows.length === 0;
36247
36325
  } catch (error51) {
36248
- if (disposed || context.signal.aborted) return;
36326
+ if (disposed || context2.signal.aborted) return;
36249
36327
  status.textContent = error51 instanceof RendererMethodUnavailableError ? text.unavailable : text.failed;
36250
36328
  status.hidden = false;
36251
36329
  scroll.hidden = true;
36252
36330
  } finally {
36253
36331
  owner.clearTimeout(requestTimer);
36254
- if (!disposed && !context.signal.aborted)
36332
+ if (!disposed && !context2.signal.aborted)
36255
36333
  timer = owner.setTimeout(() => void refresh(), 1e4);
36256
36334
  }
36257
36335
  };
@@ -36264,8 +36342,8 @@ ${detail}` : ""}`
36264
36342
  }
36265
36343
 
36266
36344
  // src/settings/idle-release-controls.ts
36267
- function mountIdleReleaseControls(context, messages, getLoadedSessionsClient) {
36268
- const { content } = context;
36345
+ function mountIdleReleaseControls(context2, messages, getLoadedSessionsClient) {
36346
+ const { content } = context2;
36269
36347
  const document2 = content.ownerDocument;
36270
36348
  const owner = document2.defaultView;
36271
36349
  if (!owner) return () => void 0;
@@ -36307,7 +36385,7 @@ ${detail}` : ""}`
36307
36385
  card.append(toggle.item, timeout.item);
36308
36386
  content.append(group);
36309
36387
  const disposeTable = mountLoadedSessionsTable(
36310
- { ...context, content: card },
36388
+ { ...context2, content: card },
36311
36389
  messages,
36312
36390
  getLoadedSessionsClient
36313
36391
  );
@@ -36380,8 +36458,8 @@ ${detail}` : ""}`
36380
36458
  id: "appearance",
36381
36459
  label: messages.pageLabels.appearance,
36382
36460
  icon: "settings",
36383
- mount(context) {
36384
- const document2 = context.content.ownerDocument;
36461
+ mount(context2) {
36462
+ const document2 = context2.content.ownerDocument;
36385
36463
  const ownerWindow = document2.defaultView;
36386
36464
  if (!ownerWindow) return;
36387
36465
  const heading = document2.createElement("div");
@@ -36433,9 +36511,9 @@ ${detail}` : ""}`
36433
36511
  ownerWindow.addEventListener(REASONING_SOFT_WRAP_CHANGE_EVENT, sync);
36434
36512
  row.item.append(toggle);
36435
36513
  card.append(row.item);
36436
- context.content.append(heading, description, group);
36514
+ context2.content.append(heading, description, group);
36437
36515
  const disposeIdleRelease = mountIdleReleaseControls(
36438
- context,
36516
+ context2,
36439
36517
  messages,
36440
36518
  getLoadedSessionsClient
36441
36519
  );
@@ -36673,7 +36751,7 @@ ${detail}` : ""}`
36673
36751
  }
36674
36752
  function defaultImportName(source, existing) {
36675
36753
  const base = source.provider === "openai-codex" ? "codex" : "grok";
36676
- const used = new Set(existing.map((record19) => record19.name));
36754
+ const used = new Set(existing.map((record21) => record21.name));
36677
36755
  const valid = (name) => credentialImportNameSchema.safeParse(name).success;
36678
36756
  if (!used.has(base)) return base;
36679
36757
  const local = source.label.includes("@") ? source.label.split("@")[0] ?? "" : "";
@@ -36696,7 +36774,7 @@ ${detail}` : ""}`
36696
36774
  const shown = (text) => accountDisplayText(text, hideEmails);
36697
36775
  const targetButtons = /* @__PURE__ */ new Map();
36698
36776
  const importedRecords = () => snapshot.targets.find((target) => target.harnessId === TARGET_HARNESS_ID)?.imports ?? [];
36699
- const sourceOf = (record19) => snapshot.sources.find((source) => source.id === record19.source.id);
36777
+ const sourceOf = (record21) => snapshot.sources.find((source) => source.id === record21.source.id);
36700
36778
  const piTarget = () => snapshot.targets.find((candidate) => candidate.harnessId === TARGET_HARNESS_ID);
36701
36779
  const compatibleSources = () => {
36702
36780
  const target = piTarget();
@@ -36734,7 +36812,7 @@ ${detail}` : ""}`
36734
36812
  sectionImport.addEventListener("click", () => {
36735
36813
  const sources = compatibleSources();
36736
36814
  const free = sources.find(
36737
- (source2) => !importedRecords().some((record19) => record19.source.id === source2.id)
36815
+ (source2) => !importedRecords().some((record21) => record21.source.id === source2.id)
36738
36816
  );
36739
36817
  const source = free ?? sources[0];
36740
36818
  if (source) openDialog("add", { source, choose: true }, SECTION_IMPORT_KEY);
@@ -36784,30 +36862,30 @@ ${detail}` : ""}`
36784
36862
  mark.append(createRendererAgentIcon(agent ?? "pi", 26, document2, pluginFor(agent ?? "pi")));
36785
36863
  return mark;
36786
36864
  };
36787
- const renderRow = (record19) => {
36865
+ const renderRow = (record21) => {
36788
36866
  const row = document2.createElement("div");
36789
36867
  row.className = "settings-pi-accounts__row";
36790
36868
  row.tabIndex = -1;
36791
- row.dataset.importName = record19.name;
36792
- row.setAttribute("aria-label", shown(record19.source.label));
36793
- const agent = record19.source.harnessId;
36869
+ row.dataset.importName = record21.name;
36870
+ row.setAttribute("aria-label", shown(record21.source.label));
36871
+ const agent = record21.source.harnessId;
36794
36872
  const mark = createMark(agent);
36795
36873
  const identity = document2.createElement("div");
36796
36874
  identity.className = "settings-pi-accounts__identity";
36797
36875
  const label = document2.createElement("strong");
36798
36876
  label.className = "settings-account-email";
36799
- label.textContent = shown(record19.source.label);
36877
+ label.textContent = shown(record21.source.label);
36800
36878
  label.title = label.textContent;
36801
36879
  label.translate = false;
36802
36880
  const meta3 = document2.createElement("div");
36803
36881
  meta3.className = "settings-account-metadata";
36804
- const source = sourceOf(record19);
36882
+ const source = sourceOf(record21);
36805
36883
  const parts = [
36806
36884
  metaPart(rendererAgentLabel(agent, pluginFor(agent)), "settings-pi-accounts__agent"),
36807
- metaPart(`${record19.name}/\u2026`, void 0, true),
36885
+ metaPart(`${record21.name}/\u2026`, void 0, true),
36808
36886
  metaPart(messages.copied)
36809
36887
  ];
36810
- const time3 = formatImportedAt(record19.importedAt);
36888
+ const time3 = formatImportedAt(record21.importedAt);
36811
36889
  if (time3) parts.push(metaPart(time3));
36812
36890
  parts.forEach((part, index) => {
36813
36891
  if (index > 0) {
@@ -36824,23 +36902,23 @@ ${detail}` : ""}`
36824
36902
  reimport.type = "button";
36825
36903
  reimport.className = "settings-account-action";
36826
36904
  reimport.textContent = messages.rowReimport;
36827
- reimport.setAttribute("aria-label", `${messages.reimport}: ${shown(record19.source.label)}`);
36905
+ reimport.setAttribute("aria-label", `${messages.reimport}: ${shown(record21.source.label)}`);
36828
36906
  reimport.disabled = busy || !source;
36829
36907
  reimport.title = messages.reimport;
36830
36908
  reimport.addEventListener("click", () => {
36831
- if (source) openDialog("reimport", { source, record: record19 }, `row:${record19.name}`);
36909
+ if (source) openDialog("reimport", { source, record: record21 }, `row:${record21.name}`);
36832
36910
  });
36833
36911
  const remove = document2.createElement("button");
36834
36912
  remove.type = "button";
36835
36913
  remove.className = "settings-account-action settings-pi-accounts__remove";
36836
36914
  remove.textContent = messages.rowRemove;
36837
- remove.setAttribute("aria-label", `${messages.remove}: ${shown(record19.source.label)}`);
36915
+ remove.setAttribute("aria-label", `${messages.remove}: ${shown(record21.source.label)}`);
36838
36916
  remove.disabled = busy;
36839
- remove.addEventListener("click", () => openDialog("remove", { record: record19 }, `row:${record19.name}`));
36917
+ remove.addEventListener("click", () => openDialog("remove", { record: record21 }, `row:${record21.name}`));
36840
36918
  if (source) actions.append(reimport);
36841
36919
  actions.append(remove);
36842
36920
  row.append(mark, identity, actions);
36843
- rows.set(record19.name, row);
36921
+ rows.set(record21.name, row);
36844
36922
  return row;
36845
36923
  };
36846
36924
  const loginTypeLabel = (type) => type === "oauth" ? messages.typeOauth : type === "api_key" ? messages.typeApiKey : messages.typeOther;
@@ -36993,7 +37071,7 @@ ${detail}` : ""}`
36993
37071
  const label = document2.createElement("strong");
36994
37072
  label.textContent = shown(choice.label);
36995
37073
  label.translate = false;
36996
- const existing = importedRecords().find((record19) => record19.source.id === choice.id);
37074
+ const existing = importedRecords().find((record21) => record21.source.id === choice.id);
36997
37075
  const agent = choice.harnessId;
36998
37076
  const detail = document2.createElement("span");
36999
37077
  detail.textContent = [
@@ -37034,7 +37112,7 @@ ${detail}` : ""}`
37034
37112
  const name = request.action === "list" ? void 0 : request.name;
37035
37113
  state = {
37036
37114
  source: state.source,
37037
- record: importedRecords().find((record19) => record19.name === name) ?? state.record
37115
+ record: importedRecords().find((record21) => record21.name === name) ?? state.record
37038
37116
  };
37039
37117
  show(next);
37040
37118
  } else {
@@ -37048,12 +37126,12 @@ ${detail}` : ""}`
37048
37126
  sourceRadios = [];
37049
37127
  body.replaceChildren();
37050
37128
  controls.replaceChildren();
37051
- const { source, record: record19 } = state;
37129
+ const { source, record: record21 } = state;
37052
37130
  const close = () => modal.close();
37053
37131
  if (mode2 === "add" || mode2 === "reimport") {
37054
37132
  title.textContent = mode2 === "add" ? messages.add : messages.reimport;
37055
37133
  modal.setAttribute("aria-label", title.textContent);
37056
- const active = source ?? record19?.source;
37134
+ const active = source ?? record21?.source;
37057
37135
  const choices = mode2 === "add" && state.choose ? compatibleSources() : [];
37058
37136
  if (choices.length > 1) body.append(sourcePicker(choices));
37059
37137
  else if (active) body.append(line(messages.source, shown(active.label)));
@@ -37062,8 +37140,8 @@ ${detail}` : ""}`
37062
37140
  input.maxLength = 48;
37063
37141
  input.autocomplete = "off";
37064
37142
  input.spellcheck = false;
37065
- input.value = record19?.name ?? (source ? defaultImportName(source, importedRecords()) : "codex");
37066
- input.readOnly = Boolean(record19);
37143
+ input.value = record21?.name ?? (source ? defaultImportName(source, importedRecords()) : "codex");
37144
+ input.readOnly = Boolean(record21);
37067
37145
  input.addEventListener("input", () => {
37068
37146
  nameEdited = true;
37069
37147
  });
@@ -37097,7 +37175,7 @@ ${detail}` : ""}`
37097
37175
  {
37098
37176
  action: mode2 === "reimport" ? "reimport" : "import",
37099
37177
  sourceId: source2.id,
37100
- name: record19?.name ?? input.value,
37178
+ name: record21?.name ?? input.value,
37101
37179
  confirmed: true
37102
37180
  },
37103
37181
  "done"
@@ -37107,16 +37185,16 @@ ${detail}` : ""}`
37107
37185
  )
37108
37186
  );
37109
37187
  (mode2 === "add" ? input : controls.children[0]).focus();
37110
- } else if (mode2 === "remove" && record19) {
37188
+ } else if (mode2 === "remove" && record21) {
37111
37189
  title.textContent = messages.remove;
37112
37190
  modal.setAttribute("aria-label", title.textContent);
37113
- body.append(note(messages.removeWarning.replace("{name}", record19.name)));
37191
+ body.append(note(messages.removeWarning.replace("{name}", record21.name)));
37114
37192
  const cancel = command(messages.cancel, close);
37115
37193
  controls.append(
37116
37194
  cancel,
37117
37195
  command(
37118
37196
  messages.remove,
37119
- () => submit({ action: "remove", name: record19.name, confirmed: true }, null),
37197
+ () => submit({ action: "remove", name: record21.name, confirmed: true }, null),
37120
37198
  "danger"
37121
37199
  )
37122
37200
  );
@@ -37124,7 +37202,7 @@ ${detail}` : ""}`
37124
37202
  } else {
37125
37203
  title.textContent = messages.doneTitle;
37126
37204
  modal.setAttribute("aria-label", title.textContent);
37127
- const name = record19?.name;
37205
+ const name = record21?.name;
37128
37206
  if (name) body.append(line(messages.entry, `${name}/\u2026`, true));
37129
37207
  body.append(note(messages.done));
37130
37208
  const done = command(messages.close, close, "primary");
@@ -37171,21 +37249,21 @@ ${detail}` : ""}`
37171
37249
  (candidate) => candidate.harnessId === TARGET_HARNESS_ID && source && candidate.providers.includes(source.provider)
37172
37250
  );
37173
37251
  if (!source || !target) return null;
37174
- const record19 = target.imports.find((candidate) => candidate.source.id === source.id);
37252
+ const record21 = target.imports.find((candidate) => candidate.source.id === source.id);
37175
37253
  const key = `${harnessId}:${accountLabel}:import`;
37176
37254
  const button2 = document2.createElement("button");
37177
37255
  button2.type = "button";
37178
37256
  button2.className = "settings-account-pi-import";
37179
37257
  button2.dataset.accountFocus = key;
37180
37258
  button2.disabled = busy;
37181
- const hint = record19 ? messages.importedHint.replace("{name}", record19.name) : messages.add;
37259
+ const hint = record21 ? messages.importedHint.replace("{name}", record21.name) : messages.add;
37182
37260
  button2.title = hint;
37183
37261
  button2.setAttribute("aria-label", hint);
37184
37262
  button2.append(createRendererAgentIcon("pi", 12, document2, pluginFor("pi")));
37185
- if (record19) {
37263
+ if (record21) {
37186
37264
  button2.dataset.state = "imported";
37187
37265
  const name = document2.createElement("code");
37188
- name.textContent = `${record19.name}/\u2026`;
37266
+ name.textContent = `${record21.name}/\u2026`;
37189
37267
  name.translate = false;
37190
37268
  button2.append(name, createRendererSettingsIcon("check", 12));
37191
37269
  } else {
@@ -37193,7 +37271,7 @@ ${detail}` : ""}`
37193
37271
  button2.append(messages.add);
37194
37272
  }
37195
37273
  button2.addEventListener("click", () => {
37196
- if (!record19) {
37274
+ if (!record21) {
37197
37275
  openDialog("add", { source }, key);
37198
37276
  return;
37199
37277
  }
@@ -37202,7 +37280,7 @@ ${detail}` : ""}`
37202
37280
  renderSection();
37203
37281
  sectionToggle.setAttribute("aria-expanded", "true");
37204
37282
  }
37205
- const row = rows.get(record19.name);
37283
+ const row = rows.get(record21.name);
37206
37284
  row?.scrollIntoView({ block: "nearest", behavior: "smooth" });
37207
37285
  row?.focus();
37208
37286
  });
@@ -37905,8 +37983,8 @@ ${detail}` : ""}`
37905
37983
  id: "accounts",
37906
37984
  label: messages.pageLabels.accounts,
37907
37985
  icon: "accounts",
37908
- mount(context) {
37909
- const document2 = context.content.ownerDocument;
37986
+ mount(context2) {
37987
+ const document2 = context2.content.ownerDocument;
37910
37988
  const header = document2.createElement("div");
37911
37989
  header.className = "settings-account-header";
37912
37990
  const copy = document2.createElement("div");
@@ -37991,15 +38069,15 @@ ${detail}` : ""}`
37991
38069
  let plugins = [];
37992
38070
  const pluginFor = (id) => plugins.find((plugin) => plugin.id === id);
37993
38071
  const credentialImports = mountCredentialImports(
37994
- context.content,
37995
- context.signal,
38072
+ context2.content,
38073
+ context2.signal,
37996
38074
  getClient,
37997
38075
  messages.credentialImports,
37998
38076
  () => render(),
37999
38077
  pluginFor
38000
38078
  );
38001
- context.content.append(header, status, toolbar, list, credentialImports.section);
38002
- const stopCountdowns = mountAccountResetCountdowns(list, messages, context.signal);
38079
+ context2.content.append(header, status, toolbar, list, credentialImports.section);
38080
+ const stopCountdowns = mountAccountResetCountdowns(list, messages, context2.signal);
38003
38081
  let accounts = [];
38004
38082
  let currentAccountId = null;
38005
38083
  let accountPhase = "unavailable";
@@ -38105,7 +38183,7 @@ ${detail}` : ""}`
38105
38183
  requests.map(async ({ account, loading }) => {
38106
38184
  try {
38107
38185
  const result = await inspect({ accountId: account.accountId });
38108
- if (context.signal.aborted || usageByAccountId.get(account.accountId) !== loading)
38186
+ if (context2.signal.aborted || usageByAccountId.get(account.accountId) !== loading)
38109
38187
  return;
38110
38188
  usageByAccountId.set(
38111
38189
  account.accountId,
@@ -38117,7 +38195,7 @@ ${detail}` : ""}`
38117
38195
  } : { status: "empty" }
38118
38196
  );
38119
38197
  } catch {
38120
- if (context.signal.aborted || usageByAccountId.get(account.accountId) !== loading)
38198
+ if (context2.signal.aborted || usageByAccountId.get(account.accountId) !== loading)
38121
38199
  return;
38122
38200
  usageByAccountId.set(account.accountId, { status: "error" });
38123
38201
  }
@@ -38146,7 +38224,7 @@ ${detail}` : ""}`
38146
38224
  };
38147
38225
  const refreshInBackground = () => {
38148
38226
  if (!client().refreshCodexAccounts) return;
38149
- void context.runLatest(
38227
+ void context2.runLatest(
38150
38228
  () => client().refreshCodexAccounts?.() ?? client().listCodexAccounts(),
38151
38229
  {
38152
38230
  success(result) {
@@ -38158,7 +38236,7 @@ ${detail}` : ""}`
38158
38236
  );
38159
38237
  };
38160
38238
  const load = () => {
38161
- void context.runLatest(() => client().listCodexAccounts(), {
38239
+ void context2.runLatest(() => client().listCodexAccounts(), {
38162
38240
  success(result) {
38163
38241
  loadMessage = null;
38164
38242
  setAccounts(result);
@@ -38178,10 +38256,10 @@ ${detail}` : ""}`
38178
38256
  });
38179
38257
  } catch {
38180
38258
  }
38181
- const harnessAccounts = createHarnessAccounts(context.signal, getClient, render);
38259
+ const harnessAccounts = createHarnessAccounts(context2.signal, getClient, render);
38182
38260
  const directoryClient = getClient();
38183
38261
  void directoryClient?.listHarnessPlugins?.().then(({ plugins: next }) => {
38184
- if (context.signal.aborted || getClient() !== directoryClient) return;
38262
+ if (context2.signal.aborted || getClient() !== directoryClient) return;
38185
38263
  plugins = next;
38186
38264
  render();
38187
38265
  void credentialImports.refresh();
@@ -38204,14 +38282,14 @@ ${detail}` : ""}`
38204
38282
  id: "harness-schedules",
38205
38283
  label: t("\u5B9A\u65F6\u4EFB\u52A1", "Schedules"),
38206
38284
  icon: "schedules",
38207
- mount(context) {
38285
+ mount(context2) {
38208
38286
  const navigate = () => {
38209
- context.content.replaceChildren();
38210
- void context.runLatest((signal) => options.openSchedules(signal), {
38287
+ context2.content.replaceChildren();
38288
+ void context2.runLatest((signal) => options.openSchedules(signal), {
38211
38289
  success() {
38212
38290
  },
38213
38291
  failure() {
38214
- const document2 = context.content.ownerDocument;
38292
+ const document2 = context2.content.ownerDocument;
38215
38293
  const status = document2.createElement("p");
38216
38294
  status.setAttribute("role", "status");
38217
38295
  status.className = "text-sm text-settings-muted";
@@ -38224,7 +38302,7 @@ ${detail}` : ""}`
38224
38302
  retry.className = "rounded-lg px-3 py-2 text-sm text-settings-text hover:bg-settings-hover focus-visible:outline-2 focus-visible:outline-settings-focus";
38225
38303
  retry.textContent = t("\u91CD\u8BD5", "Retry");
38226
38304
  retry.addEventListener("click", navigate);
38227
- context.content.replaceChildren(status, retry);
38305
+ context2.content.replaceChildren(status, retry);
38228
38306
  }
38229
38307
  });
38230
38308
  };
@@ -38387,8 +38465,8 @@ ${detail}` : ""}`
38387
38465
  id: "about",
38388
38466
  label: messages.pageLabels.about,
38389
38467
  icon: "about",
38390
- mount(context) {
38391
- const document2 = context.content.ownerDocument;
38468
+ mount(context2) {
38469
+ const document2 = context2.content.ownerDocument;
38392
38470
  const heading = document2.createElement("div");
38393
38471
  heading.className = "settings-section-label";
38394
38472
  heading.textContent = messages.pageLabels.about;
@@ -38430,7 +38508,7 @@ ${detail}` : ""}`
38430
38508
  panel.append(product, tagline, introduction, starCallout, repositorySection);
38431
38509
  const consoleEntry = consoleSection(document2, messages, getClient());
38432
38510
  if (consoleEntry) panel.append(consoleEntry);
38433
- context.content.append(heading, panel);
38511
+ context2.content.append(heading, panel);
38434
38512
  return void 0;
38435
38513
  }
38436
38514
  });
@@ -38457,8 +38535,8 @@ ${detail}` : ""}`
38457
38535
  id: "updates",
38458
38536
  label: messages.pageLabels.updates,
38459
38537
  icon: "updates",
38460
- mount(context) {
38461
- const document2 = context.content.ownerDocument;
38538
+ mount(context2) {
38539
+ const document2 = context2.content.ownerDocument;
38462
38540
  const windows = isWindowsRenderer(document2.defaultView);
38463
38541
  const heading = document2.createElement("div");
38464
38542
  heading.className = "settings-section-label";
@@ -38559,7 +38637,7 @@ ${detail}` : ""}`
38559
38637
  const notes = document2.createElement("div");
38560
38638
  notes.className = "settings-update-notes-section";
38561
38639
  const starBanner = updateStarBanner(document2, messages);
38562
- context.content.append(heading, metadata, panel, controls, starBanner, notes);
38640
+ context2.content.append(heading, metadata, panel, controls, starBanner, notes);
38563
38641
  const setManualFallback = (fallback) => {
38564
38642
  controls.className = fallback ? "settings-update-controls" : "settings-update-controls is-quiet";
38565
38643
  manualNpmDescription.textContent = fallback ? messages.updateManualFallbackDescription : messages.updateManualNpmDescription;
@@ -38612,7 +38690,7 @@ ${detail}` : ""}`
38612
38690
  }
38613
38691
  pollAttempts += 1;
38614
38692
  pollTimer = document2.defaultView?.setTimeout(() => {
38615
- void context.runLatest(
38693
+ void context2.runLatest(
38616
38694
  (signal) => runBoundedRendererUpdateRequest(() => client.readUpdateStatus(), signal),
38617
38695
  {
38618
38696
  success(result) {
@@ -38659,7 +38737,7 @@ ${detail}` : ""}`
38659
38737
  if (pending) return;
38660
38738
  pending = true;
38661
38739
  renderPendingStatus(null, messages.updatePreparing);
38662
- void context.runLatest(
38740
+ void context2.runLatest(
38663
38741
  (signal) => runBoundedRendererUpdateRequest(() => client.startUpdate(), signal),
38664
38742
  {
38665
38743
  success(result) {
@@ -38765,7 +38843,7 @@ ${detail}` : ""}`
38765
38843
  }
38766
38844
  pending = true;
38767
38845
  renderPendingStatus(null, messages.updateChecking);
38768
- return context.runLatest(
38846
+ return context2.runLatest(
38769
38847
  (signal) => runBoundedRendererUpdateRequest(() => client.checkUpdate(), signal),
38770
38848
  {
38771
38849
  success(result) {
@@ -43914,7 +43992,7 @@ th[aria-sort] .console-usage-sort__mark {
43914
43992
  place();
43915
43993
  const observer = ownerWindow ? new ownerWindow.MutationObserver((records) => {
43916
43994
  const titlebar = source?.closest("[data-app-shell-titlebar]");
43917
- if (!source?.isConnected || records.some((record19) => titlebar?.contains(record19.target))) {
43995
+ if (!source?.isConnected || records.some((record21) => titlebar?.contains(record21.target))) {
43918
43996
  place();
43919
43997
  }
43920
43998
  }) : null;
@@ -46433,7 +46511,11 @@ ${usage_default}`;
46433
46511
  const agent = controller.get(mounted.composer).agent;
46434
46512
  return state.plugins && agent !== "codex" && !state.plugins.some(({ id }) => id === agent) ? { ...state.availability, [agent]: "unavailable" } : state.availability;
46435
46513
  };
46436
- const composerAdapterState = (mounted) => composerClient(mounted) ? "ready" : "installing";
46514
+ const composerAdapterState = (mounted) => {
46515
+ const manager = mounted.hostId ? window.__codexhostHostRoutingV1?.forHost(mounted.hostId)?.manager : null;
46516
+ const needsRpcSteering = manager != null && "kind" in manager && manager.kind === "main-process-rpc";
46517
+ return composerClient(mounted) && (!needsRpcSteering || window.__codexhostRpcSteeringV1) ? "ready" : "installing";
46518
+ };
46437
46519
  const renderMounted = (mounted) => {
46438
46520
  if (!isMountedComposer(mounted.composer)) return;
46439
46521
  const hostId2 = mounted.hostId;
@@ -46654,7 +46736,7 @@ ${usage_default}`;
46654
46736
  const isExternalConfigurationReady = (mounted) => {
46655
46737
  const current = controller.get(mounted.composer);
46656
46738
  if (current.agent === "codex") return true;
46657
- return isExternalConfigurationReadyView(mounted.modelView, mounted.permissionModeView);
46739
+ return composerAdapterState(mounted) === "ready" && isExternalConfigurationReadyView(mounted.modelView, mounted.permissionModeView);
46658
46740
  };
46659
46741
  const clearDraftPrewarm = async (composer) => {
46660
46742
  const policy = await waitForRendererDraftPrewarmPolicy(window, composer);
@@ -49476,7 +49558,268 @@ ${usage_default}`;
49476
49558
  return handle;
49477
49559
  }
49478
49560
 
49561
+ // src/renderer-rpc-steering-queue.ts
49562
+ var INTERRUPTED = "Interrupted before the steer was accepted.";
49563
+ var record19 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
49564
+ async function prepareRpcSteeringQueue(hostId2, threadId, manager, coordinator, messageId) {
49565
+ const snapshot = Promise.withResolvers();
49566
+ let lease;
49567
+ let released = false;
49568
+ const dispose = (value) => {
49569
+ if (value != null) value[Symbol.dispose]?.();
49570
+ };
49571
+ const pending = manager("subscribe", {
49572
+ type: "thread",
49573
+ key: { hostId: hostId2, threadId },
49574
+ field: "queuedMessages",
49575
+ listener(value) {
49576
+ if (Array.isArray(value)) snapshot.resolve(value);
49577
+ }
49578
+ });
49579
+ let timeout;
49580
+ let messages;
49581
+ try {
49582
+ timeout = setTimeout(
49583
+ () => snapshot.reject(new Error("Native follow-up queue did not become ready")),
49584
+ 5e3
49585
+ );
49586
+ const ready = Promise.resolve(pending).then((value) => {
49587
+ if (released) dispose(value);
49588
+ else lease = value;
49589
+ });
49590
+ [messages] = await Promise.all([snapshot.promise, ready]);
49591
+ } finally {
49592
+ released = true;
49593
+ clearTimeout(timeout);
49594
+ for (const value of /* @__PURE__ */ new Set([pending, lease])) dispose(value);
49595
+ }
49596
+ if (messages.some(
49597
+ (message2) => record19(message2) && message2.id !== messageId && message2.pausedReason === INTERRUPTED
49598
+ ))
49599
+ throw new Error(
49600
+ "Resume or remove the other previously paused messages before changing direction"
49601
+ );
49602
+ return async (turnId) => {
49603
+ await coordinator("removeQueuedMessage", threadId, messageId);
49604
+ const state = await manager("getThreadExecutionState", threadId);
49605
+ const stillRunning = record19(state) && state.inProgress === true && state.activeTurnId === turnId;
49606
+ const turn = stillRunning ? null : await manager("getTurnById", threadId, turnId);
49607
+ if (stillRunning || record19(turn) && turn.status === "completed")
49608
+ await coordinator("resumeInterruptedQueuedMessages", threadId);
49609
+ };
49610
+ }
49611
+
49612
+ // src/renderer-rpc-steering.ts
49613
+ var record20 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
49614
+ var invoke = (target, name, ...args) => Reflect.apply(Reflect.get(target, name), target, args);
49615
+ var running = (state) => record20(state) && (state.inProgress === true || !!state.activeTurnId);
49616
+ var context = (previous, marker) => ({
49617
+ ...record20(previous) ? previous : {},
49618
+ [THREAD_STEERING_CONTEXT_PARAM]: { kind: "application", value: JSON.stringify(marker) }
49619
+ });
49620
+ function installRendererRpcSteering(value) {
49621
+ if (!record20(value) || typeof value.forHost !== "function") return null;
49622
+ const descriptor = Object.getOwnPropertyDescriptor(value, "forHost");
49623
+ if (!descriptor?.writable) return null;
49624
+ const controller = value;
49625
+ const original = controller.forHost;
49626
+ const cached2 = /* @__PURE__ */ new WeakMap();
49627
+ let disposed = false;
49628
+ const wrap = (rpc, hostId2, owner = rpc) => {
49629
+ const existing = cached2.get(rpc);
49630
+ if (existing) return existing;
49631
+ const current = () => {
49632
+ if (disposed || original.call(controller, hostId2) !== owner)
49633
+ throw new Error("Steering connection was retired");
49634
+ };
49635
+ const inspect = async (threadId, input) => {
49636
+ const text = Array.isArray(input) ? input.filter(record20).map((item) => typeof item.text === "string" ? item.text : "").join("\n") : "";
49637
+ current();
49638
+ const delivery = await inspectRendererSteeringDelivery(
49639
+ (method, params) => {
49640
+ current();
49641
+ return invoke(rpc, "sendRequest", method, params);
49642
+ },
49643
+ threadId,
49644
+ text
49645
+ );
49646
+ current();
49647
+ return delivery;
49648
+ };
49649
+ const target = async (threadId, messageId, delivery) => {
49650
+ const state = await invoke(rpc, "getThreadExecutionState", threadId);
49651
+ current();
49652
+ if (!record20(state) || typeof state.activeTurnId !== "string" || !state.activeTurnId || typeof messageId !== "string" || !messageId)
49653
+ throw new Error("Native steering target or message identity is unavailable");
49654
+ return { expectedTurnId: state.activeTurnId, clientUserMessageId: messageId, delivery };
49655
+ };
49656
+ const withoutQueueRow = async (request) => {
49657
+ if (!record20(request) || request.acceptLocally !== true || typeof request.conversationId !== "string")
49658
+ return request;
49659
+ try {
49660
+ const state = await invoke(rpc, "getThreadExecutionState", request.conversationId);
49661
+ current();
49662
+ if (!running(state)) return request;
49663
+ const message2 = request.message;
49664
+ const text = record20(message2) && typeof message2.text === "string" ? message2.text : "";
49665
+ const delivery = await inspect(request.conversationId, [{ text }]);
49666
+ return delivery === "newTurn" ? { ...request, acceptLocally: false } : request;
49667
+ } catch {
49668
+ return request;
49669
+ }
49670
+ };
49671
+ const coordinator = (remote) => new Proxy(remote, {
49672
+ get(handle, key) {
49673
+ if (key === "then") {
49674
+ const then = Reflect.get(handle, key);
49675
+ return typeof then === "function" ? (resolve, reject) => Reflect.apply(then, handle, [(value2) => resolve(coordinator(value2)), reject]) : then;
49676
+ }
49677
+ if (key === "dup") return () => coordinator(invoke(handle, "dup"));
49678
+ if (key !== "sendMessage" && key !== "sendQueuedMessageNow")
49679
+ return Reflect.get(handle, key);
49680
+ return async (...args) => {
49681
+ current();
49682
+ const index = key === "sendMessage" ? 1 : 3;
49683
+ const callback = args[index];
49684
+ if (typeof callback !== "function")
49685
+ throw new Error("Native submission preparation is unavailable");
49686
+ let marker = null;
49687
+ let threadId;
49688
+ let messageId;
49689
+ let finish;
49690
+ const apply = (prepared) => {
49691
+ if (!marker || !record20(prepared.steer)) return prepared;
49692
+ const result2 = {
49693
+ ...prepared,
49694
+ steer: {
49695
+ ...prepared.steer,
49696
+ additionalContext: context(prepared.steer.additionalContext, marker)
49697
+ }
49698
+ };
49699
+ if (marker.delivery !== "newTurn") return result2;
49700
+ if (!record20(prepared.start) || !record20(prepared.start.request))
49701
+ throw new Error("Native start preparation is unavailable for steering");
49702
+ return {
49703
+ ...result2,
49704
+ afterInactiveTurnId: marker.expectedTurnId,
49705
+ start: {
49706
+ ...prepared.start,
49707
+ request: {
49708
+ ...prepared.start.request,
49709
+ additionalContext: context(prepared.start.request.additionalContext, marker)
49710
+ }
49711
+ }
49712
+ };
49713
+ };
49714
+ const prepare = async (...input) => {
49715
+ current();
49716
+ const prepared = await callback(...input);
49717
+ current();
49718
+ if (!record20(prepared)) throw new Error("Native submission preparation is malformed");
49719
+ if (marker) return apply(prepared);
49720
+ if (input[1] !== "steer" || !record20(prepared.steer) || typeof prepared.conversationId !== "string")
49721
+ return prepared;
49722
+ threadId = prepared.conversationId;
49723
+ const execution = await invoke(rpc, "getThreadExecutionState", threadId);
49724
+ current();
49725
+ if (!running(execution)) return prepared;
49726
+ const delivery = await inspect(threadId, prepared.steer.input);
49727
+ if (delivery === "official") return prepared;
49728
+ const restore = prepared.steer.restoreMessage;
49729
+ messageId = record20(restore) && typeof restore.id === "string" ? restore.id : void 0;
49730
+ const clientId = prepared.steer.clientUserMessageId ?? messageId;
49731
+ marker = await target(threadId, clientId, delivery);
49732
+ if (delivery === "activeTurn") return apply(prepared);
49733
+ if (!messageId) throw new Error("Native queued message identity is unavailable");
49734
+ finish = await prepareRpcSteeringQueue(
49735
+ hostId2,
49736
+ threadId,
49737
+ (name, ...values) => invoke(rpc, name, ...values),
49738
+ (name, ...values) => invoke(remote, name, ...values),
49739
+ messageId
49740
+ );
49741
+ const start = await callback(input[0], "start");
49742
+ current();
49743
+ if (!record20(start)) throw new Error("Native start preparation is malformed");
49744
+ return apply(start);
49745
+ };
49746
+ const forwarded = [...args];
49747
+ forwarded[index] = prepare;
49748
+ if (key === "sendMessage") forwarded[0] = await withoutQueueRow(args[0]);
49749
+ const result = await invoke(handle, key, ...forwarded);
49750
+ if (finish && record20(result) && result.status === "sent" && typeof result.turnId === "string") {
49751
+ await finish(result.turnId).catch(
49752
+ () => console.error("codexhost could not reconcile native steering queue")
49753
+ );
49754
+ }
49755
+ return result;
49756
+ };
49757
+ }
49758
+ });
49759
+ const wrapped = new Proxy(rpc, {
49760
+ get(handle, key) {
49761
+ if (key === "then") {
49762
+ const then = Reflect.get(handle, key);
49763
+ return typeof then === "function" ? (resolve, reject) => Reflect.apply(then, handle, [
49764
+ (value2) => resolve(wrap(value2, hostId2, owner)),
49765
+ reject
49766
+ ]) : then;
49767
+ }
49768
+ if (key === "dup") return () => wrap(invoke(handle, "dup"), hostId2, owner);
49769
+ if (key === "getTurnCoordinator")
49770
+ return () => {
49771
+ current();
49772
+ return coordinator(invoke(handle, "getTurnCoordinator"));
49773
+ };
49774
+ return Reflect.get(handle, key);
49775
+ }
49776
+ });
49777
+ cached2.set(rpc, wrapped);
49778
+ return wrapped;
49779
+ };
49780
+ const forHost = (hostId2) => wrap(original.call(controller, hostId2), hostId2);
49781
+ controller.forHost = forHost;
49782
+ return () => {
49783
+ disposed = true;
49784
+ if (controller.forHost === forHost) Object.defineProperty(controller, "forHost", descriptor);
49785
+ };
49786
+ }
49787
+
49479
49788
  // src/production-entry.ts
49789
+ Object.defineProperty(window, "__codexhostInstallRpcSteeringV1", {
49790
+ configurable: true,
49791
+ value(controller) {
49792
+ const state = window;
49793
+ if (state.__codexhostRpcSteeringV1)
49794
+ return window.__codexhostRpcSteeringV1?.controller === controller;
49795
+ const routing = window.__codexhostHostRoutingV1;
49796
+ if (!routing) return false;
49797
+ const cleanup = installRendererRpcSteering(controller);
49798
+ if (!cleanup) return false;
49799
+ const originalDispose = routing.dispose;
49800
+ const dispose = () => {
49801
+ cleanup();
49802
+ delete state.__codexhostRpcSteeringV1;
49803
+ window.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
49804
+ if (routing.dispose === dispose) routing.dispose = originalDispose;
49805
+ originalDispose.call(routing);
49806
+ };
49807
+ routing.dispose = dispose;
49808
+ state.__codexhostRpcSteeringV1 = {
49809
+ controller,
49810
+ // A later native Remote Control install replaces this method; the Controller
49811
+ // compares it on every tick and releases a displaced wrapper to reinstall.
49812
+ forHost: controller.forHost,
49813
+ release() {
49814
+ cleanup();
49815
+ delete state.__codexhostRpcSteeringV1;
49816
+ window.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
49817
+ }
49818
+ };
49819
+ window.dispatchEvent(new CustomEvent("codexhost:draft-prewarm-policy-changed"));
49820
+ return true;
49821
+ }
49822
+ });
49480
49823
  installCpaLiveVoiceHook();
49481
49824
  installClientOwnedVoiceHook();
49482
49825
  installExternalVoiceLaunchHook();