@codexhost/cli-darwin-x64 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +1565 -1805
  4. package/app/console-web.js +5786 -1600
  5. package/app/desktop-controller.mjs +13104 -2842
  6. package/app/host-runtime.mjs +50518 -51753
  7. package/app/plugins/antigravity/plugin.mjs +1932 -1148
  8. package/app/plugins/claude-code/plugin.mjs +1676 -1218
  9. package/app/plugins/codebuddy/plugin.mjs +1266 -850
  10. package/app/plugins/codex-usage/plugin.mjs +916 -737
  11. package/app/plugins/copilot/plugin.mjs +838 -640
  12. package/app/plugins/cursor-cli/plugin.mjs +1058 -747
  13. package/app/plugins/deepseek-harness/plugin.mjs +1302 -1070
  14. package/app/plugins/devin/plugin.mjs +949 -752
  15. package/app/plugins/grok/plugin.mjs +1132 -964
  16. package/app/plugins/hermes/plugin.mjs +1084 -905
  17. package/app/plugins/kimi-code/plugin.mjs +977 -804
  18. package/app/plugins/kiro-cli/plugin.mjs +951 -758
  19. package/app/plugins/omp/plugin.mjs +1408 -1169
  20. package/app/plugins/opencode/plugin.mjs +1385 -1142
  21. package/app/plugins/pi/plugin.mjs +1515 -1287
  22. package/app/plugins/qoder/plugin.mjs +861 -676
  23. package/app/plugins/qoder-cn/plugin.mjs +861 -676
  24. package/app/plugins/qwen-code/plugin.mjs +1060 -888
  25. package/app/plugins/workbuddy/plugin.mjs +1272 -856
  26. package/app/plugins/zcode/plugin.mjs +1529 -880
  27. package/app/renderer-extension.js +11568 -7827
  28. package/app/web/assets/index-CTCFIQbU.css +1 -0
  29. package/app/web/assets/index-IvFk9KT-.js +203 -0
  30. package/app/web/codexhost-settings.js +4472 -36194
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  34. package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +19 -16
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  49. package/app/web/sw.js +8 -1
  50. package/app/web-modules/server.mjs +2682 -5540
  51. package/bin/codexhost +0 -0
  52. package/libexec/codexhost-shim +0 -0
  53. package/libexec/codexhost-updater +0 -0
  54. package/package.json +1 -1
  55. package/app/web/assets/index-DJW4bmyx.css +0 -1
  56. package/app/web/assets/index-Dyh1KzAB.js +0 -201
@@ -3736,10 +3736,10 @@ function executableExtensions(command, platform, environment) {
3736
3736
  return [""];
3737
3737
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension2) => extension2.trim()).filter(Boolean);
3738
3738
  }
3739
- function isExecutableFile(filePath, platform) {
3739
+ function isExecutableFile(filePath2, platform) {
3740
3740
  try {
3741
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
3742
- return fs.statSync(filePath).isFile();
3741
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
3742
+ return fs.statSync(filePath2).isFile();
3743
3743
  } catch {
3744
3744
  return false;
3745
3745
  }
@@ -5450,8 +5450,8 @@ function cleanEnum(obj) {
5450
5450
  return Number.isNaN(Number.parseInt(k, 10));
5451
5451
  }).map((el) => el[1]);
5452
5452
  }
5453
- function base64ToUint8Array(base643) {
5454
- const binaryString = atob(base643);
5453
+ function base64ToUint8Array(base644) {
5454
+ const binaryString = atob(base644);
5455
5455
  const bytes = new Uint8Array(binaryString.length);
5456
5456
  for (let i = 0; i < binaryString.length; i++) {
5457
5457
  bytes[i] = binaryString.charCodeAt(i);
@@ -5466,9 +5466,9 @@ function uint8ArrayToBase64(bytes) {
5466
5466
  return btoa(binaryString);
5467
5467
  }
5468
5468
  function base64urlToUint8Array(base64url3) {
5469
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
5470
- const padding = "=".repeat((4 - base643.length % 4) % 4);
5471
- return base64ToUint8Array(base643 + padding);
5469
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
5470
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
5471
+ return base64ToUint8Array(base644 + padding);
5472
5472
  }
5473
5473
  function uint8ArrayToBase64url(bytes) {
5474
5474
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -6834,8 +6834,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
6834
6834
  function isValidBase64URL(data) {
6835
6835
  if (!base64url.test(data))
6836
6836
  return false;
6837
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
6838
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
6837
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
6838
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
6839
6839
  return isValidBase64(padded);
6840
6840
  }
6841
6841
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -7289,42 +7289,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7289
7289
  }
7290
7290
  doc.write(`const newResult = {};`);
7291
7291
  for (const key of normalized.keys) {
7292
- const id = ids[key];
7292
+ const id2 = ids[key];
7293
7293
  const k = esc(key);
7294
7294
  const schema = shape[key];
7295
7295
  const isOptionalIn = schema?._zod?.optin === "optional";
7296
7296
  const isOptionalOut = schema?._zod?.optout === "optional";
7297
- doc.write(`const ${id} = ${parseStr(key)};`);
7297
+ doc.write(`const ${id2} = ${parseStr(key)};`);
7298
7298
  if (isOptionalIn && isOptionalOut) {
7299
7299
  doc.write(`
7300
- if (${id}.issues.length) {
7300
+ if (${id2}.issues.length) {
7301
7301
  if (${k} in input) {
7302
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7302
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7303
7303
  ...iss,
7304
7304
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7305
7305
  })));
7306
7306
  }
7307
7307
  }
7308
7308
 
7309
- if (${id}.value === undefined) {
7309
+ if (${id2}.value === undefined) {
7310
7310
  if (${k} in input) {
7311
7311
  newResult[${k}] = undefined;
7312
7312
  }
7313
7313
  } else {
7314
- newResult[${k}] = ${id}.value;
7314
+ newResult[${k}] = ${id2}.value;
7315
7315
  }
7316
7316
 
7317
7317
  `);
7318
7318
  } else if (!isOptionalIn) {
7319
7319
  doc.write(`
7320
- const ${id}_present = ${k} in input;
7321
- if (${id}.issues.length) {
7322
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7320
+ const ${id2}_present = ${k} in input;
7321
+ if (${id2}.issues.length) {
7322
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7323
7323
  ...iss,
7324
7324
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7325
7325
  })));
7326
7326
  }
7327
- if (!${id}_present && !${id}.issues.length) {
7327
+ if (!${id2}_present && !${id2}.issues.length) {
7328
7328
  payload.issues.push({
7329
7329
  code: "invalid_type",
7330
7330
  expected: "nonoptional",
@@ -7333,30 +7333,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
7333
7333
  });
7334
7334
  }
7335
7335
 
7336
- if (${id}_present) {
7337
- if (${id}.value === undefined) {
7336
+ if (${id2}_present) {
7337
+ if (${id2}.value === undefined) {
7338
7338
  newResult[${k}] = undefined;
7339
7339
  } else {
7340
- newResult[${k}] = ${id}.value;
7340
+ newResult[${k}] = ${id2}.value;
7341
7341
  }
7342
7342
  }
7343
7343
 
7344
7344
  `);
7345
7345
  } else {
7346
7346
  doc.write(`
7347
- if (${id}.issues.length) {
7348
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
7347
+ if (${id2}.issues.length) {
7348
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
7349
7349
  ...iss,
7350
7350
  path: iss.path ? [${k}, ...iss.path] : [${k}]
7351
7351
  })));
7352
7352
  }
7353
7353
 
7354
- if (${id}.value === undefined) {
7354
+ if (${id2}.value === undefined) {
7355
7355
  if (${k} in input) {
7356
7356
  newResult[${k}] = undefined;
7357
7357
  }
7358
7358
  } else {
7359
- newResult[${k}] = ${id}.value;
7359
+ newResult[${k}] = ${id2}.value;
7360
7360
  }
7361
7361
 
7362
7362
  `);
@@ -15688,26 +15688,26 @@ function extractDefs(ctx, schema) {
15688
15688
  throw new Error("Unprocessed schema. This is a bug in Zod.");
15689
15689
  const idToSchema = /* @__PURE__ */ new Map();
15690
15690
  for (const entry of ctx.seen.entries()) {
15691
- const id = ctx.metadataRegistry.get(entry[0])?.id;
15692
- if (id) {
15693
- const existing = idToSchema.get(id);
15691
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
15692
+ if (id2) {
15693
+ const existing = idToSchema.get(id2);
15694
15694
  if (existing && existing !== entry[0]) {
15695
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
15695
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
15696
15696
  }
15697
- idToSchema.set(id, entry[0]);
15697
+ idToSchema.set(id2, entry[0]);
15698
15698
  }
15699
15699
  }
15700
15700
  const makeURI = (entry) => {
15701
15701
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
15702
15702
  if (ctx.external) {
15703
15703
  const externalId = ctx.external.registry.get(entry[0])?.id;
15704
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
15704
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
15705
15705
  if (externalId) {
15706
15706
  return { ref: uriGenerator(externalId) };
15707
15707
  }
15708
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
15709
- entry[1].defId = id;
15710
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
15708
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
15709
+ entry[1].defId = id2;
15710
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
15711
15711
  }
15712
15712
  if (entry[1] === root) {
15713
15713
  return { ref: "#" };
@@ -15755,8 +15755,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15755
15755
  continue;
15756
15756
  }
15757
15757
  }
15758
- const id = ctx.metadataRegistry.get(entry[0])?.id;
15759
- if (id) {
15758
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
15759
+ if (id2) {
15760
15760
  extractToDef(entry);
15761
15761
  continue;
15762
15762
  }
@@ -15852,10 +15852,10 @@ function finalize(ctx, schema) {
15852
15852
  } else {
15853
15853
  }
15854
15854
  if (ctx.external?.uri) {
15855
- const id = ctx.external.registry.get(schema)?.id;
15856
- if (!id)
15855
+ const id2 = ctx.external.registry.get(schema)?.id;
15856
+ if (!id2)
15857
15857
  throw new Error("Schema is missing an `id` property");
15858
- result.$id = ctx.external.uri(id);
15858
+ result.$id = ctx.external.uri(id2);
15859
15859
  }
15860
15860
  Object.assign(result, root.def ?? root.schema);
15861
15861
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -16015,9 +16015,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
16015
16015
  json2.type = "number";
16016
16016
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
16017
16017
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
16018
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
16018
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
16019
16019
  if (exMin) {
16020
- if (legacy) {
16020
+ if (legacy2) {
16021
16021
  json2.minimum = exclusiveMinimum;
16022
16022
  json2.exclusiveMinimum = true;
16023
16023
  } else {
@@ -16027,7 +16027,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
16027
16027
  json2.minimum = minimum;
16028
16028
  }
16029
16029
  if (exMax) {
16030
- if (legacy) {
16030
+ if (legacy2) {
16031
16031
  json2.maximum = exclusiveMaximum;
16032
16032
  json2.exclusiveMaximum = true;
16033
16033
  } else {
@@ -16889,7 +16889,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
16889
16889
 
16890
16890
  // ../../../node_modules/zod/v4/classic/schemas.js
16891
16891
  var _installedGroups = /* @__PURE__ */ new WeakMap();
16892
- function _installLazyMethods(inst, group, methods) {
16892
+ function _installLazyMethods(inst, group, methods2) {
16893
16893
  const proto = Object.getPrototypeOf(inst);
16894
16894
  let installed = _installedGroups.get(proto);
16895
16895
  if (!installed) {
@@ -16899,8 +16899,8 @@ function _installLazyMethods(inst, group, methods) {
16899
16899
  if (installed.has(group))
16900
16900
  return;
16901
16901
  installed.add(group);
16902
- for (const key in methods) {
16903
- const fn = methods[key];
16902
+ for (const key in methods2) {
16903
+ const fn = methods2[key];
16904
16904
  Object.defineProperty(proto, key, {
16905
16905
  configurable: true,
16906
16906
  enumerable: false,
@@ -18711,87 +18711,6 @@ function date4(params) {
18711
18711
  // ../../../node_modules/zod/v4/classic/external.js
18712
18712
  config(en_default());
18713
18713
 
18714
- // ../../shared-contracts/dist/ids.js
18715
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18716
- message: "Identifier must not be empty or whitespace"
18717
- });
18718
- var harnessIdSchema = opaqueIdSchema.brand();
18719
- var hostThreadIdSchema = opaqueIdSchema.brand();
18720
- var hostTurnIdSchema = opaqueIdSchema.brand();
18721
- var hostItemIdSchema = opaqueIdSchema.brand();
18722
- var hostInteractionIdSchema = opaqueIdSchema.brand();
18723
-
18724
- // ../../shared-contracts/dist/harness-plugins.js
18725
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
18726
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
18727
- var HARNESS_PLUGIN_LIMIT = 128;
18728
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
18729
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
18730
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
18731
- var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
18732
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
18733
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
18734
- var harnessInstallationGuideSchema = external_exports.object({
18735
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
18736
- before: localizedTextSchema.optional(),
18737
- after: localizedTextSchema.optional(),
18738
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
18739
- }).strict();
18740
- var pluginPresentationShape = {
18741
- id: installedHarnessPluginIdSchema,
18742
- name: external_exports.string().trim().min(1).max(128),
18743
- version: external_exports.string().min(1).max(128),
18744
- /** Capability-only plugin; omitted for existing session-capable plugins. */
18745
- kind: external_exports.literal("usage").optional(),
18746
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
18747
- iconStyle: external_exports.object({
18748
- vector: external_exports.object({
18749
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
18750
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
18751
- paths: external_exports.array(external_exports.object({
18752
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
18753
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
18754
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
18755
- }).strict()).min(1).max(32)
18756
- }).strict().optional(),
18757
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
18758
- borderRadius: external_exports.number().min(0).max(50).optional(),
18759
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
18760
- }).strict().optional(),
18761
- installation: harnessInstallationGuideSchema.optional(),
18762
- notice: localizedTextSchema.optional(),
18763
- /** The factory accepts a persisted local entrypoint through its construction context. */
18764
- launchCommand: external_exports.literal(true).optional(),
18765
- links: external_exports.object({
18766
- website: documentationUrlSchema.optional(),
18767
- documentation: documentationUrlSchema.optional(),
18768
- installation: documentationUrlSchema.optional()
18769
- }).strict().optional()
18770
- };
18771
- var harnessPluginManifestSchema = external_exports.object({
18772
- manifestVersion: external_exports.literal(1),
18773
- ...pluginPresentationShape,
18774
- adapterApiVersion: external_exports.number().int().positive(),
18775
- entry: pluginRelativeResourceSchema,
18776
- icon: pluginRelativeResourceSchema.optional()
18777
- }).strict();
18778
- var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
18779
- var harnessPluginDescriptorSchema = external_exports.object({
18780
- ...pluginPresentationShape,
18781
- icon: harnessPluginIconSchema.optional()
18782
- }).strict();
18783
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
18784
- var harnessPluginListResultSchema = external_exports.object({
18785
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
18786
- }).strict();
18787
- var harnessPluginConfigurationSchema = external_exports.object({
18788
- version: external_exports.literal(1),
18789
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
18790
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
18791
- message: "Enabled plugin IDs must be unique",
18792
- path: ["enabled"]
18793
- });
18794
-
18795
18714
  // ../../shared-contracts/dist/json-value.js
18796
18715
  function rejectExplicitUndefined(keys) {
18797
18716
  return (value, context) => {
@@ -18851,403 +18770,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
18851
18770
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
18852
18771
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
18853
18772
 
18854
- // ../../shared-contracts/dist/desktop-extensions.js
18855
- var DESKTOP_EXTENSION_API_VERSION = 1;
18856
- var DESKTOP_EXTENSION_LIMIT = 64;
18857
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
18858
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
18859
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
18860
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
18861
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
18862
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
18863
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
18864
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
18865
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
18866
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
18867
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
18868
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
18869
- var desktopExtensionIdSchema = installedPluginIdSchema;
18870
- var desktopExtensionSlotSchema = external_exports.enum([
18871
- "sidebar.thread-layout",
18872
- "sidebar.thread-badge",
18873
- "appearance.theme"
18874
- ]);
18875
- var desktopExtensionCategorySchema = external_exports.enum([
18876
- "appearance",
18877
- "interface",
18878
- "workflow",
18879
- "analytics",
18880
- "integrations",
18881
- "tools"
18882
- ]);
18883
- var extensionName = external_exports.string().trim().min(1).max(128);
18884
- function desktopExtensionScreenshotMimeType(resource) {
18885
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
18886
- case "png":
18887
- return "image/png";
18888
- case "jpg":
18889
- case "jpeg":
18890
- return "image/jpeg";
18891
- case "webp":
18892
- return "image/webp";
18893
- default:
18894
- return void 0;
18773
+ // ../../shared-contracts/dist/errors.js
18774
+ var codexhostErrorSchema = external_exports.strictObject({
18775
+ code: external_exports.string().min(1),
18776
+ message: external_exports.string().min(1),
18777
+ retryable: external_exports.boolean(),
18778
+ diagnostic: external_exports.string().min(1).optional(),
18779
+ stage: external_exports.string().min(1).optional(),
18780
+ durationMs: external_exports.number().int().nonnegative().optional(),
18781
+ stderrTail: external_exports.string().min(1).optional()
18782
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
18783
+
18784
+ // ../../shared-contracts/dist/harness-presentation.js
18785
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
18786
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
18787
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
18788
+ label: displayText(256).optional(),
18789
+ description: displayText(1024).optional()
18790
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
18791
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
18792
+
18793
+ // ../../shared-contracts/dist/ids.js
18794
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18795
+ message: "Identifier must not be empty or whitespace"
18796
+ });
18797
+ var harnessIdSchema = opaqueIdSchema.brand();
18798
+ var hostThreadIdSchema = opaqueIdSchema.brand();
18799
+ var hostTurnIdSchema = opaqueIdSchema.brand();
18800
+ var hostItemIdSchema = opaqueIdSchema.brand();
18801
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
18802
+
18803
+ // ../../shared-contracts/dist/harness-permission-modes.js
18804
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
18805
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
18806
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
18807
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
18808
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
18809
+ message: "Value must not be empty or whitespace"
18810
+ });
18811
+ var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
18812
+ var harnessPermissionModeSchema = external_exports.object({
18813
+ id: harnessPermissionModeIdSchema,
18814
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
18815
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
18816
+ dangerous: external_exports.boolean().optional(),
18817
+ localizations: harnessLocalizationsSchema.optional()
18818
+ }).strict();
18819
+ var harnessPermissionModeCatalogSchema = external_exports.object({
18820
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
18821
+ defaultModeId: harnessPermissionModeIdSchema
18822
+ }).strict().superRefine((catalog, context) => {
18823
+ const ids = /* @__PURE__ */ new Set();
18824
+ for (const [index, mode] of catalog.modes.entries()) {
18825
+ if (ids.has(mode.id)) {
18826
+ context.addIssue({
18827
+ code: "custom",
18828
+ message: "Permission Mode IDs must be unique",
18829
+ path: ["modes", index, "id"]
18830
+ });
18831
+ }
18832
+ ids.add(mode.id);
18895
18833
  }
18896
- }
18897
- function desktopExtensionAssetMimeType(resource) {
18898
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
18899
- case "gif":
18900
- return "image/gif";
18901
- case "svg":
18902
- return "image/svg+xml";
18903
- case "woff2":
18904
- return "font/woff2";
18905
- case "json":
18906
- return "application/json";
18907
- case "css":
18908
- return "text/css";
18909
- default:
18910
- return desktopExtensionScreenshotMimeType(resource);
18911
- }
18912
- }
18913
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
18914
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
18915
- var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
18916
- var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
18917
- const { username, password } = new URL(value);
18918
- return !username && !password && !/[\\\s]/u.test(value);
18919
- }, "URL must not contain credentials, backslashes, or whitespace");
18920
- function localizedText(text) {
18921
- return external_exports.strictObject({ en: text, "zh-CN": text });
18922
- }
18923
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
18924
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
18925
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
18926
- var settingField = {
18927
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
18928
- label: desktopExtensionLocalizedTextSchema,
18929
- description: desktopExtensionLocalizedTextSchema.optional()
18930
- };
18931
- var numericSetting = {
18932
- ...settingField,
18933
- step: external_exports.number().positive().optional(),
18934
- default: external_exports.number().optional()
18935
- };
18936
- var settingOption = external_exports.strictObject({
18937
- value: external_exports.string(),
18938
- label: desktopExtensionLocalizedTextSchema
18939
- });
18940
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
18941
- external_exports.strictObject({
18942
- ...settingField,
18943
- type: external_exports.literal("boolean"),
18944
- default: external_exports.boolean().optional()
18945
- }),
18946
- external_exports.strictObject({
18947
- ...settingField,
18948
- type: external_exports.literal("string"),
18949
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
18950
- default: external_exports.string().optional()
18951
- }),
18952
- external_exports.strictObject({
18953
- ...numericSetting,
18954
- type: external_exports.literal("number"),
18955
- min: external_exports.number().optional(),
18956
- max: external_exports.number().optional()
18957
- }),
18958
- external_exports.strictObject({
18959
- ...numericSetting,
18960
- type: external_exports.literal("range"),
18961
- min: external_exports.number(),
18962
- max: external_exports.number()
18963
- }),
18964
- external_exports.strictObject({
18965
- ...settingField,
18966
- type: external_exports.literal("select"),
18967
- options: external_exports.array(settingOption).min(1),
18968
- default: external_exports.string().optional()
18969
- })
18970
- ]).superRefine((field2, ctx) => {
18971
- const issue2 = (path12, message) => ctx.addIssue({ code: "custom", path: [path12], message });
18972
- if (field2.type === "number" || field2.type === "range") {
18973
- const { min = -Infinity, max = Infinity, default: value } = field2;
18974
- if (min > max)
18975
- issue2("max", "Must be at least min");
18976
- if (value !== void 0 && (value < min || value > max))
18977
- issue2("default", "Must be within min and max");
18978
- } else if (field2.type === "select") {
18979
- const values = new Set(field2.options.map(({ value }) => value));
18980
- if (values.size !== field2.options.length)
18981
- issue2("options", "Duplicate option values");
18982
- if (field2.default !== void 0 && !values.has(field2.default))
18983
- issue2("default", "Must match an option value");
18984
- }
18985
- });
18986
- var manifestHeader = external_exports.object({
18987
- manifestVersion: external_exports.int().positive(),
18988
- id: desktopExtensionIdSchema,
18989
- name: external_exports.union([extensionName, localizedText(extensionName)]),
18990
- version: external_exports.string().min(1).max(128),
18991
- desktopApi: external_exports.int().positive()
18992
- }).passthrough();
18993
- var desktopExtensionManifestSchema = manifestHeader.extend({
18994
- manifestVersion: external_exports.literal(1),
18995
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
18996
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
18997
- author: external_exports.string().trim().min(1).max(128).optional(),
18998
- repository: desktopExtensionHttpUrlSchema.optional(),
18999
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
19000
- icon: imagePathSchema.optional(),
19001
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
19002
- desktop: external_exports.strictObject({
19003
- script: pluginRelativeResourceSchema,
19004
- style: pluginRelativeResourceSchema.optional()
19005
- }).optional(),
19006
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
19007
- slots: slotsSchema.default(() => []),
19008
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
19009
- categories: categoriesSchema.optional()
19010
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
19011
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
19012
- version: external_exports.literal(1),
19013
- revision: external_exports.int().nonnegative(),
19014
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
19015
- reloadToken: external_exports.uuid().optional()
19016
- });
19017
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
19018
- var desktopExtensionStatusSchema = external_exports.strictObject({
19019
- state: external_exports.enum([
19020
- "running",
19021
- "disabled",
19022
- "invalid",
19023
- "incompatible",
19024
- "conflict",
19025
- "failed",
19026
- "waiting"
19027
- ]),
19028
- hash: desktopExtensionHashSchema.optional(),
19029
- error: external_exports.string().optional(),
19030
- conflictWith: desktopExtensionIdSchema.optional()
19031
- });
19032
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
19033
- controllerPid: external_exports.int().positive(),
19034
- targetId: external_exports.string().nullable(),
19035
- updatedAt: external_exports.iso.datetime(),
19036
- handledReloadToken: external_exports.uuid().optional(),
19037
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
19038
- });
19039
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
19040
- function isGitHubDesktopExtensionZipballUrl(url2) {
19041
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
19042
- }
19043
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
19044
- const url2 = new URL(input);
19045
- return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
19046
- }, "Expected a .zip download URL or a GitHub zipball URL");
19047
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
19048
- id: desktopExtensionIdSchema,
19049
- version: external_exports.string().trim().min(1).max(128),
19050
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
19051
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
19052
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
19053
- author: external_exports.string().trim().min(1).max(128),
19054
- repository: desktopExtensionHttpUrlSchema,
19055
- stars: external_exports.number().int().min(0).optional(),
19056
- downloads: external_exports.number().int().min(0).optional(),
19057
- categories: categoriesSchema.optional(),
19058
- trustTier: desktopExtensionTrustTierSchema.default("community"),
19059
- icon: desktopExtensionHttpUrlSchema.optional(),
19060
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19061
- downloadUrl: desktopExtensionZipUrlSchema,
19062
- sha256: desktopExtensionHashSchema,
19063
- slots: slotsSchema.optional(),
19064
- publishedAt: external_exports.string().optional(),
19065
- updatedAt: external_exports.string().optional(),
19066
- minCodexHostVersion: external_exports.string().optional()
19067
- });
19068
- var desktopExtensionCatalogSchema = external_exports.strictObject({
19069
- schemaVersion: external_exports.literal(1),
19070
- generatedAt: external_exports.string(),
19071
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
19072
- });
19073
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
19074
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
19075
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
19076
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
19077
- var extensionIdParams = { id: desktopExtensionIdSchema };
19078
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
19079
- ...extensionIdParams,
19080
- path: desktopExtensionAssetPathSchema
19081
- });
19082
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
19083
- mimeType: external_exports.string(),
19084
- dataUrl: external_exports.string()
19085
- });
19086
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
19087
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
19088
- ...extensionIdParams,
19089
- values: jsonObjectSchema
19090
- });
19091
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
19092
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
19093
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
19094
- ...extensionIdParams,
19095
- method: desktopExtensionBackendMethodSchema,
19096
- params: jsonValueSchema.optional()
19097
- });
19098
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
19099
- result: jsonValueSchema
19100
- });
19101
-
19102
- // ../../shared-contracts/dist/desktop-extension-management.js
19103
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
19104
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
19105
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
19106
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
19107
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
19108
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
19109
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
19110
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
19111
- DESKTOP_EXTENSIONS_LIST_METHOD,
19112
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
19113
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
19114
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
19115
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
19116
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
19117
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
19118
- DESKTOP_EXTENSIONS_ASSET_METHOD,
19119
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
19120
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
19121
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
19122
- ];
19123
- var revisionSchema = external_exports.int().nonnegative();
19124
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
19125
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
19126
- id: desktopExtensionIdSchema,
19127
- expectedRevision: revisionSchema
19128
- });
19129
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
19130
- expectedRevision: revisionSchema.optional()
19131
- });
19132
- var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
19133
- var desktopExtensionListItemSchema = external_exports.strictObject({
19134
- // An invalid discovery can have a directory name that isn't a valid extension ID.
19135
- id: external_exports.string().min(1),
19136
- manifest: desktopExtensionManifestSchema.optional(),
19137
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
19138
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19139
- enabled: external_exports.boolean(),
19140
- status: desktopExtensionStatusSchema
19141
- });
19142
- var desktopExtensionsListResultSchema = external_exports.strictObject({
19143
- configuration: desktopExtensionConfigurationSchema,
19144
- desktopConnected: external_exports.boolean(),
19145
- diagnostics: external_exports.array(external_exports.string()),
19146
- extensions: external_exports.array(desktopExtensionListItemSchema)
19147
- });
19148
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
19149
- forceRefresh: external_exports.boolean().optional()
19150
- });
19151
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
19152
- catalogUrl: external_exports.string(),
19153
- source: external_exports.enum(["remote", "fallback"]),
19154
- fetchedAt: external_exports.string(),
19155
- cached: external_exports.boolean(),
19156
- extensions: desktopExtensionCatalogSchema.shape.extensions,
19157
- error: external_exports.string().optional()
19158
- });
19159
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
19160
- source: external_exports.discriminatedUnion("type", [
19161
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
19162
- external_exports.strictObject({
19163
- type: external_exports.literal("url"),
19164
- url: desktopExtensionHttpUrlSchema,
19165
- expectedSha256: desktopExtensionHashSchema.optional()
19166
- }),
19167
- external_exports.strictObject({
19168
- type: external_exports.literal("zip-base64"),
19169
- fileName: external_exports.string().trim().min(1).max(255),
19170
- contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
19171
- })
19172
- ])
19173
- });
19174
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
19175
- extensionId: desktopExtensionIdSchema,
19176
- version: external_exports.string().min(1),
19177
- replaced: external_exports.boolean(),
19178
- installedPath: external_exports.string(),
19179
- list: desktopExtensionsListResultSchema
19180
- });
19181
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
19182
- id: desktopExtensionIdSchema
19183
- });
19184
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
19185
- removedId: desktopExtensionIdSchema,
19186
- list: desktopExtensionsListResultSchema
19187
- });
19188
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
19189
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
19190
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
19191
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
19192
- ]);
19193
-
19194
- // ../../shared-contracts/dist/errors.js
19195
- var codexhostErrorSchema = external_exports.strictObject({
19196
- code: external_exports.string().min(1),
19197
- message: external_exports.string().min(1),
19198
- retryable: external_exports.boolean(),
19199
- diagnostic: external_exports.string().min(1).optional(),
19200
- stage: external_exports.string().min(1).optional(),
19201
- durationMs: external_exports.number().int().nonnegative().optional(),
19202
- stderrTail: external_exports.string().min(1).optional()
19203
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
19204
-
19205
- // ../../shared-contracts/dist/harness-presentation.js
19206
- var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
19207
- var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
19208
- var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
19209
- label: displayText(256).optional(),
19210
- description: displayText(1024).optional()
19211
- }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
19212
- var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
19213
-
19214
- // ../../shared-contracts/dist/harness-permission-modes.js
19215
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
19216
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
19217
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
19218
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
19219
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
19220
- message: "Value must not be empty or whitespace"
19221
- });
19222
- var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
19223
- var harnessPermissionModeSchema = external_exports.object({
19224
- id: harnessPermissionModeIdSchema,
19225
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
19226
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
19227
- dangerous: external_exports.boolean().optional(),
19228
- localizations: harnessLocalizationsSchema.optional()
19229
- }).strict();
19230
- var harnessPermissionModeCatalogSchema = external_exports.object({
19231
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
19232
- defaultModeId: harnessPermissionModeIdSchema
19233
- }).strict().superRefine((catalog, context) => {
19234
- const ids = /* @__PURE__ */ new Set();
19235
- for (const [index, mode] of catalog.modes.entries()) {
19236
- if (ids.has(mode.id)) {
19237
- context.addIssue({
19238
- code: "custom",
19239
- message: "Permission Mode IDs must be unique",
19240
- path: ["modes", index, "id"]
19241
- });
19242
- }
19243
- ids.add(mode.id);
19244
- }
19245
- if (!ids.has(catalog.defaultModeId)) {
19246
- context.addIssue({
19247
- code: "custom",
19248
- message: "Default Permission Mode must exist in the catalog",
19249
- path: ["defaultModeId"]
19250
- });
18834
+ if (!ids.has(catalog.defaultModeId)) {
18835
+ context.addIssue({
18836
+ code: "custom",
18837
+ message: "Default Permission Mode must exist in the catalog",
18838
+ path: ["defaultModeId"]
18839
+ });
19251
18840
  }
19252
18841
  });
19253
18842
  var threadPermissionModeSelectParamsSchema = external_exports.object({
@@ -19255,6 +18844,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
19255
18844
  permissionModeId: harnessPermissionModeIdSchema
19256
18845
  }).strict();
19257
18846
 
18847
+ // ../../shared-contracts/dist/harness-route-limit.js
18848
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
18849
+
19258
18850
  // ../../shared-contracts/dist/thread-usage.js
19259
18851
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
19260
18852
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -19287,7 +18879,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
19287
18879
  expiresAtUnix: nonNegativeSafeIntegerSchema,
19288
18880
  label: indicatorTextSchema(256).optional(),
19289
18881
  tooltip: indicatorTextSchema(1024).optional()
19290
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
18882
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
19291
18883
  message: "Composer indicator IDs must be unique"
19292
18884
  });
19293
18885
  var threadUsageSnapshotSchema = external_exports.object({
@@ -19313,6 +18905,7 @@ var threadUsageSnapshotSchema = external_exports.object({
19313
18905
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
19314
18906
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
19315
18907
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
18908
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
19316
18909
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
19317
18910
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
19318
18911
  }).strict().superRefine((usage, context) => {
@@ -19440,10 +19033,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
19440
19033
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
19441
19034
  message: "Value must not be empty or whitespace"
19442
19035
  });
19443
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
19036
+ var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
19037
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
19444
19038
  var harnessModelRefSchema = external_exports.object({
19445
- id: harnessModelRefIdSchema
19039
+ id: harnessModelRefIdSchema,
19040
+ serviceTier: harnessModelServiceTierSchema.optional()
19446
19041
  }).strict();
19042
+ function sameHarnessModelRef(left, right) {
19043
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
19044
+ }
19447
19045
  var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
19448
19046
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
19449
19047
  var harnessThinkingOptionSchema = external_exports.object({
@@ -19457,7 +19055,15 @@ var harnessModelSchema = external_exports.object({
19457
19055
  /** Optional opaque selection for this same Model with priority processing enabled. */
19458
19056
  fastModel: harnessModelRefSchema.optional(),
19459
19057
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
19460
- }).strict();
19058
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
19059
+ path: ["fastModel", "id"],
19060
+ message: "A tiered Fast Model must share the base Model ID"
19061
+ });
19062
+ function catalogModelForRef(catalog, ref) {
19063
+ if (!ref)
19064
+ return void 0;
19065
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
19066
+ }
19461
19067
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
19462
19068
  const ids = /* @__PURE__ */ new Set();
19463
19069
  for (const [index, option] of options.entries()) {
@@ -19477,26 +19083,26 @@ var harnessModelCatalogSchema = external_exports.object({
19477
19083
  thinkingOptions: harnessThinkingOptionsSchema,
19478
19084
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
19479
19085
  }).strict().superRefine((catalog, context) => {
19480
- const refs = /* @__PURE__ */ new Set();
19481
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
19086
+ const refs = [];
19087
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
19482
19088
  for (const [index, model2] of catalog.models.entries()) {
19483
- if (refs.has(model2.ref.id)) {
19089
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
19484
19090
  context.addIssue({
19485
19091
  code: "custom",
19486
19092
  message: "Model Catalog refs must be unique",
19487
19093
  path: ["models", index, "ref", "id"]
19488
19094
  });
19489
19095
  }
19490
- refs.add(model2.ref.id);
19096
+ refs.push(model2.ref);
19491
19097
  if (model2.fastModel) {
19492
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
19098
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
19493
19099
  context.addIssue({
19494
19100
  code: "custom",
19495
19101
  message: "Fast Model refs must be distinct and unique",
19496
19102
  path: ["models", index, "fastModel"]
19497
19103
  });
19498
19104
  }
19499
- refs.add(model2.fastModel.id);
19105
+ refs.push(model2.fastModel);
19500
19106
  }
19501
19107
  const supportedThinkingIds = /* @__PURE__ */ new Set();
19502
19108
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -19517,7 +19123,7 @@ var harnessModelCatalogSchema = external_exports.object({
19517
19123
  }
19518
19124
  }
19519
19125
  }
19520
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
19126
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
19521
19127
  context.addIssue({
19522
19128
  code: "custom",
19523
19129
  message: "Default Model must exist in the Model Catalog",
@@ -19557,7 +19163,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
19557
19163
  observe: external_exports.boolean()
19558
19164
  }).strict().optional(),
19559
19165
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
19560
- steer: external_exports.boolean().optional()
19166
+ steer: external_exports.boolean().optional(),
19167
+ /**
19168
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
19169
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
19170
+ */
19171
+ persistentPlan: external_exports.boolean().optional()
19561
19172
  }).strict();
19562
19173
  var harnessConfigurationStateSchema = external_exports.object({
19563
19174
  effectiveModel: harnessModelRefSchema.optional(),
@@ -19566,7 +19177,7 @@ var harnessConfigurationStateSchema = external_exports.object({
19566
19177
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19567
19178
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
19568
19179
  }).strict().superRefine((state, context) => {
19569
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
19180
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
19570
19181
  context.addIssue({
19571
19182
  code: "custom",
19572
19183
  message: "Effective Thinking option must be currently available",
@@ -19574,150 +19185,696 @@ var harnessConfigurationStateSchema = external_exports.object({
19574
19185
  });
19575
19186
  }
19576
19187
  });
19577
- var harnessWebUiCapabilitySchema = external_exports.object({
19578
- open: external_exports.literal(true)
19579
- }).strict();
19580
- var readyHarnessInspectionSchema = external_exports.object({
19581
- status: external_exports.literal("ready"),
19582
- catalog: harnessModelCatalogSchema,
19583
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
19584
- capabilities: harnessSessionCapabilitiesSchema,
19585
- webUi: harnessWebUiCapabilitySchema.optional()
19586
- }).strict().superRefine((inspection, context) => {
19587
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
19588
- if (selectable !== Boolean(inspection.permissionModes)) {
19589
- context.addIssue({
19590
- code: "custom",
19591
- message: "Permission Mode catalog and capability must agree",
19592
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19593
- });
19594
- }
19188
+ var harnessWebUiCapabilitySchema = external_exports.object({
19189
+ open: external_exports.literal(true)
19190
+ }).strict();
19191
+ var readyHarnessInspectionSchema = external_exports.object({
19192
+ status: external_exports.literal("ready"),
19193
+ catalog: harnessModelCatalogSchema,
19194
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
19195
+ capabilities: harnessSessionCapabilitiesSchema,
19196
+ webUi: harnessWebUiCapabilitySchema.optional()
19197
+ }).strict().superRefine((inspection, context) => {
19198
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
19199
+ if (selectable !== Boolean(inspection.permissionModes)) {
19200
+ context.addIssue({
19201
+ code: "custom",
19202
+ message: "Permission Mode catalog and capability must agree",
19203
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
19204
+ });
19205
+ }
19206
+ });
19207
+ var failedHarnessInspectionSchema = external_exports.object({
19208
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19209
+ error: codexhostErrorSchema
19210
+ }).strict();
19211
+ var harnessInspectionSchema = external_exports.union([
19212
+ readyHarnessInspectionSchema,
19213
+ failedHarnessInspectionSchema
19214
+ ]);
19215
+ var harnessInspectParamsSchema = external_exports.object({
19216
+ harnessId: harnessIdSchema,
19217
+ cwd: nonBlankTextSchema2.max(16384).optional(),
19218
+ refresh: external_exports.boolean().optional(),
19219
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
19220
+ purpose: external_exports.literal("availability").optional(),
19221
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
19222
+ }).strict();
19223
+ var harnessWebUiOpenParamsSchema = external_exports.object({
19224
+ harnessId: harnessIdSchema
19225
+ }).strict();
19226
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19227
+ var threadModelSelectParamsSchema = external_exports.object({
19228
+ threadId: hostThreadIdSchema,
19229
+ model: harnessModelRefSchema
19230
+ }).strict();
19231
+ var threadThinkingSelectParamsSchema = external_exports.object({
19232
+ threadId: hostThreadIdSchema,
19233
+ thinkingOptionId: harnessThinkingOptionIdSchema
19234
+ }).strict();
19235
+ var threadInspectionParamsSchema = external_exports.object({
19236
+ threadId: hostThreadIdSchema,
19237
+ includeReferenceCapability: external_exports.boolean().optional()
19238
+ }).strict();
19239
+ var codexThreadInspectionSchema = external_exports.object({
19240
+ owner: external_exports.literal("codex"),
19241
+ locked: external_exports.boolean(),
19242
+ effectiveModel: harnessModelRefSchema.optional(),
19243
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19244
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19245
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19246
+ history: harnessHistoryCapabilitiesSchema.optional(),
19247
+ supportsThreadReferences: external_exports.literal(true).optional()
19248
+ }).strict();
19249
+ var externalThreadInspectionSchema = external_exports.object({
19250
+ owner: external_exports.literal("external"),
19251
+ harnessId: nonBlankTextSchema2.max(256),
19252
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
19253
+ effectiveModel: harnessModelRefSchema.optional(),
19254
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19255
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19256
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19257
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19258
+ history: harnessHistoryCapabilitiesSchema,
19259
+ usage: threadUsageSnapshotSchema.optional(),
19260
+ locked: external_exports.literal(true)
19261
+ }).strict();
19262
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19263
+ codexThreadInspectionSchema,
19264
+ externalThreadInspectionSchema
19265
+ ]);
19266
+ var threadOwnershipListParamsSchema = external_exports.object({
19267
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19268
+ }).strict().superRefine(({ threadIds }, context) => {
19269
+ const seen = /* @__PURE__ */ new Set();
19270
+ for (const [index, threadId] of threadIds.entries()) {
19271
+ if (seen.has(threadId)) {
19272
+ context.addIssue({
19273
+ code: "custom",
19274
+ message: "Thread ownership-list IDs must be unique",
19275
+ path: ["threadIds", index]
19276
+ });
19277
+ }
19278
+ seen.add(threadId);
19279
+ }
19280
+ });
19281
+ var codexThreadOwnershipSchema = external_exports.object({
19282
+ threadId: hostThreadIdSchema,
19283
+ owner: external_exports.literal("codex")
19284
+ }).strict();
19285
+ var externalThreadOwnershipSchema = external_exports.object({
19286
+ threadId: hostThreadIdSchema,
19287
+ owner: external_exports.literal("external"),
19288
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19289
+ }).strict();
19290
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19291
+ codexThreadOwnershipSchema,
19292
+ externalThreadOwnershipSchema
19293
+ ]);
19294
+ var threadOwnershipListResultSchema = external_exports.object({
19295
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19296
+ }).strict().superRefine(({ threads }, context) => {
19297
+ const seen = /* @__PURE__ */ new Set();
19298
+ for (const [index, thread2] of threads.entries()) {
19299
+ if (seen.has(thread2.threadId)) {
19300
+ context.addIssue({
19301
+ code: "custom",
19302
+ message: "Thread ownership-list results must be unique",
19303
+ path: ["threads", index, "threadId"]
19304
+ });
19305
+ }
19306
+ seen.add(thread2.threadId);
19307
+ }
19308
+ });
19309
+ var threadSteeringInspectParamsSchema = external_exports.object({
19310
+ threadId: hostThreadIdSchema,
19311
+ /** The text about to be steered; a Harness command always stops and restarts. */
19312
+ text: external_exports.string().optional()
19313
+ }).strict();
19314
+ var threadSteeringContextSchema = external_exports.object({
19315
+ kind: external_exports.literal("application"),
19316
+ value: external_exports.string().transform((text, context) => {
19317
+ try {
19318
+ return JSON.parse(text);
19319
+ } catch {
19320
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
19321
+ return external_exports.NEVER;
19322
+ }
19323
+ }).pipe(external_exports.object({
19324
+ expectedTurnId: hostTurnIdSchema,
19325
+ clientUserMessageId: external_exports.string().min(1),
19326
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
19327
+ }).strict())
19328
+ }).strict().transform((context) => context.value);
19329
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
19330
+ var threadSteeringInspectResultSchema = external_exports.object({
19331
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
19332
+ }).strict();
19333
+
19334
+ // ../../shared-contracts/dist/harness-plugins.js
19335
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
19336
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
19337
+ var HARNESS_PLUGIN_LIMIT = 128;
19338
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
19339
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
19340
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
19341
+ var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
19342
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
19343
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
19344
+ var harnessInstallationGuideSchema = external_exports.object({
19345
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
19346
+ before: localizedTextSchema.optional(),
19347
+ after: localizedTextSchema.optional(),
19348
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
19349
+ }).strict();
19350
+ var pluginPresentationShape = {
19351
+ id: installedHarnessPluginIdSchema,
19352
+ name: external_exports.string().trim().min(1).max(128),
19353
+ version: external_exports.string().min(1).max(128),
19354
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
19355
+ kind: external_exports.literal("usage").optional(),
19356
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
19357
+ iconStyle: external_exports.object({
19358
+ vector: external_exports.object({
19359
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
19360
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
19361
+ paths: external_exports.array(external_exports.object({
19362
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
19363
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
19364
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
19365
+ }).strict()).min(1).max(32)
19366
+ }).strict().optional(),
19367
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
19368
+ borderRadius: external_exports.number().min(0).max(50).optional(),
19369
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
19370
+ }).strict().optional(),
19371
+ installation: harnessInstallationGuideSchema.optional(),
19372
+ notice: localizedTextSchema.optional(),
19373
+ /** The factory accepts a persisted local entrypoint through its construction context. */
19374
+ launchCommand: external_exports.literal(true).optional(),
19375
+ links: external_exports.object({
19376
+ website: documentationUrlSchema.optional(),
19377
+ documentation: documentationUrlSchema.optional(),
19378
+ installation: documentationUrlSchema.optional()
19379
+ }).strict().optional()
19380
+ };
19381
+ var harnessPluginManifestSchema = external_exports.object({
19382
+ manifestVersion: external_exports.literal(1),
19383
+ ...pluginPresentationShape,
19384
+ adapterApiVersion: external_exports.number().int().positive(),
19385
+ entry: pluginRelativeResourceSchema,
19386
+ icon: pluginRelativeResourceSchema.optional()
19387
+ }).strict();
19388
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
19389
+ var harnessPluginDescriptorSchema = external_exports.object({
19390
+ ...pluginPresentationShape,
19391
+ icon: harnessPluginIconSchema.optional()
19392
+ }).strict();
19393
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
19394
+ var harnessPluginListResultSchema = external_exports.object({
19395
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
19396
+ }).strict();
19397
+ var harnessPluginConfigurationSchema = external_exports.object({
19398
+ version: external_exports.literal(1),
19399
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
19400
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
19401
+ message: "Enabled plugin IDs must be unique",
19402
+ path: ["enabled"]
19403
+ });
19404
+
19405
+ // ../../shared-contracts/dist/desktop-extensions.js
19406
+ var DESKTOP_EXTENSION_API_VERSION = 1;
19407
+ var DESKTOP_EXTENSION_LIMIT = 64;
19408
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
19409
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
19410
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
19411
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
19412
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
19413
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
19414
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
19415
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
19416
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
19417
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
19418
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
19419
+ var desktopExtensionIdSchema = installedPluginIdSchema;
19420
+ var desktopExtensionSlotSchema = external_exports.enum([
19421
+ "sidebar.thread-layout",
19422
+ "sidebar.thread-badge",
19423
+ "appearance.theme"
19424
+ ]);
19425
+ var desktopExtensionCategorySchema = external_exports.enum([
19426
+ "appearance",
19427
+ "interface",
19428
+ "workflow",
19429
+ "analytics",
19430
+ "integrations",
19431
+ "tools"
19432
+ ]);
19433
+ var extensionName = external_exports.string().trim().min(1).max(128);
19434
+ function desktopExtensionScreenshotMimeType(resource) {
19435
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
19436
+ case "png":
19437
+ return "image/png";
19438
+ case "jpg":
19439
+ case "jpeg":
19440
+ return "image/jpeg";
19441
+ case "webp":
19442
+ return "image/webp";
19443
+ default:
19444
+ return void 0;
19445
+ }
19446
+ }
19447
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
19448
+ var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
19449
+ var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
19450
+ const { username, password } = new URL(value);
19451
+ return !username && !password && !/[\\\s]/u.test(value);
19452
+ }, "URL must not contain credentials, backslashes, or whitespace");
19453
+ function localizedText(text) {
19454
+ return external_exports.strictObject({ en: text, "zh-CN": text });
19455
+ }
19456
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
19457
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
19458
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
19459
+ var settingField = {
19460
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
19461
+ label: desktopExtensionLocalizedTextSchema,
19462
+ description: desktopExtensionLocalizedTextSchema.optional()
19463
+ };
19464
+ var numericSetting = {
19465
+ ...settingField,
19466
+ step: external_exports.number().positive().optional(),
19467
+ default: external_exports.number().optional()
19468
+ };
19469
+ var settingOption = external_exports.strictObject({
19470
+ value: external_exports.string(),
19471
+ label: desktopExtensionLocalizedTextSchema
19472
+ });
19473
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
19474
+ external_exports.strictObject({
19475
+ ...settingField,
19476
+ type: external_exports.literal("boolean"),
19477
+ default: external_exports.boolean().optional()
19478
+ }),
19479
+ external_exports.strictObject({
19480
+ ...settingField,
19481
+ type: external_exports.literal("string"),
19482
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
19483
+ default: external_exports.string().optional()
19484
+ }),
19485
+ external_exports.strictObject({
19486
+ ...numericSetting,
19487
+ type: external_exports.literal("number"),
19488
+ min: external_exports.number().optional(),
19489
+ max: external_exports.number().optional()
19490
+ }),
19491
+ external_exports.strictObject({
19492
+ ...numericSetting,
19493
+ type: external_exports.literal("range"),
19494
+ min: external_exports.number(),
19495
+ max: external_exports.number()
19496
+ }),
19497
+ external_exports.strictObject({
19498
+ ...settingField,
19499
+ type: external_exports.literal("select"),
19500
+ options: external_exports.array(settingOption).min(1),
19501
+ default: external_exports.string().optional()
19502
+ })
19503
+ ]).superRefine((field2, ctx) => {
19504
+ const issue2 = (path12, message) => ctx.addIssue({ code: "custom", path: [path12], message });
19505
+ if (field2.type === "number" || field2.type === "range") {
19506
+ const { min = -Infinity, max = Infinity, default: value } = field2;
19507
+ if (min > max)
19508
+ issue2("max", "Must be at least min");
19509
+ if (value !== void 0 && (value < min || value > max))
19510
+ issue2("default", "Must be within min and max");
19511
+ } else if (field2.type === "select") {
19512
+ const values = new Set(field2.options.map(({ value }) => value));
19513
+ if (values.size !== field2.options.length)
19514
+ issue2("options", "Duplicate option values");
19515
+ if (field2.default !== void 0 && !values.has(field2.default))
19516
+ issue2("default", "Must match an option value");
19517
+ }
19518
+ });
19519
+ var manifestHeader = external_exports.object({
19520
+ manifestVersion: external_exports.int().positive(),
19521
+ id: desktopExtensionIdSchema,
19522
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
19523
+ version: external_exports.string().min(1).max(128),
19524
+ desktopApi: external_exports.int().positive()
19525
+ }).passthrough();
19526
+ var desktopExtensionManifestSchema = manifestHeader.extend({
19527
+ manifestVersion: external_exports.literal(1),
19528
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
19529
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
19530
+ author: external_exports.string().trim().min(1).max(128).optional(),
19531
+ repository: desktopExtensionHttpUrlSchema.optional(),
19532
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
19533
+ icon: imagePathSchema.optional(),
19534
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
19535
+ desktop: external_exports.strictObject({
19536
+ script: pluginRelativeResourceSchema,
19537
+ style: pluginRelativeResourceSchema.optional()
19538
+ }).optional(),
19539
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
19540
+ slots: slotsSchema.default(() => []),
19541
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
19542
+ categories: categoriesSchema.optional()
19543
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
19544
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
19545
+ var desktopExtensionStatusSchema = external_exports.strictObject({
19546
+ state: external_exports.enum([
19547
+ "running",
19548
+ "disabled",
19549
+ "invalid",
19550
+ "incompatible",
19551
+ "conflict",
19552
+ "failed",
19553
+ "waiting"
19554
+ ]),
19555
+ hash: desktopExtensionHashSchema.optional(),
19556
+ error: external_exports.string().optional(),
19557
+ conflictWith: desktopExtensionIdSchema.optional()
19558
+ });
19559
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
19560
+ controllerPid: external_exports.int().positive(),
19561
+ targetId: external_exports.string().nullable(),
19562
+ updatedAt: external_exports.iso.datetime(),
19563
+ handledReloadToken: external_exports.uuid().optional(),
19564
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
19565
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
19595
19566
  });
19596
- var failedHarnessInspectionSchema = external_exports.object({
19597
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
19598
- error: codexhostErrorSchema
19599
- }).strict();
19600
- var harnessInspectionSchema = external_exports.union([
19601
- readyHarnessInspectionSchema,
19602
- failedHarnessInspectionSchema
19567
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
19568
+ function isGitHubDesktopExtensionZipballUrl(url2) {
19569
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
19570
+ }
19571
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
19572
+ const url2 = new URL(input);
19573
+ return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
19574
+ }, "Expected a .zip download URL or a GitHub zipball URL");
19575
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
19576
+ id: desktopExtensionIdSchema,
19577
+ version: external_exports.string().trim().min(1).max(128),
19578
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
19579
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
19580
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
19581
+ author: external_exports.string().trim().min(1).max(128),
19582
+ repository: desktopExtensionHttpUrlSchema,
19583
+ stars: external_exports.number().int().min(0).optional(),
19584
+ downloads: external_exports.number().int().min(0).optional(),
19585
+ categories: categoriesSchema.optional(),
19586
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
19587
+ icon: desktopExtensionHttpUrlSchema.optional(),
19588
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19589
+ downloadUrl: desktopExtensionZipUrlSchema,
19590
+ sha256: desktopExtensionHashSchema,
19591
+ slots: slotsSchema.optional(),
19592
+ publishedAt: external_exports.string().optional(),
19593
+ updatedAt: external_exports.string().optional(),
19594
+ minCodexHostVersion: external_exports.string().optional()
19595
+ });
19596
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
19597
+ schemaVersion: external_exports.literal(1),
19598
+ generatedAt: external_exports.string(),
19599
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
19600
+ });
19601
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
19602
+
19603
+ // ../../shared-contracts/dist/host-extensions.js
19604
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
19605
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
19606
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
19607
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
19608
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
19609
+ var hostExtensionActivationIdSchema = external_exports.uuid();
19610
+ var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path12) => path12.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
19611
+ var legacy = desktopExtensionManifestSchema.shape;
19612
+ var localized = (max, min = 0) => external_exports.strictObject({
19613
+ en: external_exports.string().trim().min(min).max(max),
19614
+ "zh-CN": external_exports.string().trim().min(min).max(max)
19615
+ });
19616
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path12) => path12.endsWith(suffix), `Expected a ${suffix} file`);
19617
+ var moduleEntry = resourceWithSuffix(".mjs");
19618
+ var style = resourceWithSuffix(".css").optional();
19619
+ var hostExtensionCanonicalPath = (path12) => path12.normalize("NFC").toLowerCase();
19620
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
19621
+ manifestVersion: external_exports.literal(2),
19622
+ id: hostExtensionIdSchema,
19623
+ name: localized(128, 1),
19624
+ version: external_exports.string().trim().min(1).max(128),
19625
+ description: localized(4096),
19626
+ details: localized(16384).optional(),
19627
+ author: legacy.author,
19628
+ repository: legacy.repository,
19629
+ icon: legacy.icon.refine((path12) => path12 === void 0 || hostExtensionResourcePathSchema.safeParse(path12).success),
19630
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path12) => hostExtensionResourcePathSchema.safeParse(path12).success)),
19631
+ categories: legacy.categories,
19632
+ settingsSchema: legacy.settingsSchema,
19633
+ slots: legacy.slots.removeDefault().optional(),
19634
+ page: external_exports.strictObject({
19635
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
19636
+ entry: moduleEntry,
19637
+ style,
19638
+ title: localized(128, 1).optional()
19639
+ }).optional(),
19640
+ widget: external_exports.strictObject({
19641
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
19642
+ entry: moduleEntry,
19643
+ style
19644
+ }).optional(),
19645
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
19646
+ web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
19647
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
19648
+ }).refine(({ page, widget, desktop, web, backend }) => Boolean(page || widget || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget, web, backend }) => !backend || [page?.entry, widget?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
19649
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
19650
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
19651
+ return ["desktop", "web"];
19652
+ const targets = [];
19653
+ if (hasDesktop)
19654
+ targets.push("desktop");
19655
+ if (hasWeb)
19656
+ targets.push("web");
19657
+ return targets;
19658
+ }
19659
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
19660
+
19661
+ // ../../shared-contracts/dist/host-extension-management.js
19662
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
19663
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
19664
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
19665
+ revision: hostExtensionRevisionSchema,
19666
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
19667
+ });
19668
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
19669
+ var hostExtensionCatalogEntrySchema = external_exports.object({
19670
+ ...catalogMetadata,
19671
+ id: hostExtensionIdSchema,
19672
+ format: external_exports.literal("codexhost"),
19673
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
19674
+ apis: external_exports.strictObject({
19675
+ page: external_exports.int().positive().optional(),
19676
+ widget: external_exports.int().positive().optional(),
19677
+ desktop: external_exports.int().positive().optional(),
19678
+ web: external_exports.int().positive().optional(),
19679
+ backend: external_exports.int().positive().optional()
19680
+ }),
19681
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
19682
+ }).refine(({ targets, apis }) => {
19683
+ const derived = targetsForCapabilities({
19684
+ hasPage: Boolean(apis.page),
19685
+ hasWidget: Boolean(apis.widget),
19686
+ hasDesktop: Boolean(apis.desktop),
19687
+ hasWeb: Boolean(apis.web),
19688
+ hasBackend: Boolean(apis.backend)
19689
+ });
19690
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
19691
+ }, "Catalog targets must match the declared APIs");
19692
+ var hostExtensionCatalogSchema = external_exports.object({
19693
+ schemaVersion: external_exports.literal(2),
19694
+ generatedAt: external_exports.string().min(1),
19695
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
19696
+ });
19697
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
19698
+ catalogUrl: desktopExtensionHttpUrlSchema,
19699
+ fetchedAt: external_exports.iso.datetime(),
19700
+ cached: external_exports.boolean()
19701
+ });
19702
+ var id = { id: hostExtensionIdSchema };
19703
+ var active = {
19704
+ ...id,
19705
+ activationId: hostExtensionActivationIdSchema,
19706
+ digest: hostExtensionDigestSchema
19707
+ };
19708
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
19709
+ var filePath = external_exports.string().min(1).max(4096).refine((path12) => /^(?:\/|[a-z]:[/\\])/iu.test(path12) && !path12.includes("\0") && !path12.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
19710
+ var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
19711
+ function base643(maxBytes) {
19712
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
19713
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
19714
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
19715
+ }, "Expected bounded standard padded base64");
19716
+ }
19717
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
19718
+ type: external_exports.literal("github"),
19719
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
19720
+ ref: gitRef.optional(),
19721
+ tag: gitRef.optional(),
19722
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
19723
+ subpath: hostExtensionResourcePathSchema.optional()
19724
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
19725
+ var hostExtensionInstallSourceSchema = external_exports.union([
19726
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
19727
+ hostExtensionGitHubSourceSchema,
19728
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
19729
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
19730
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
19603
19731
  ]);
19604
- var harnessInspectParamsSchema = external_exports.object({
19605
- harnessId: harnessIdSchema,
19606
- cwd: nonBlankTextSchema2.max(16384).optional(),
19607
- refresh: external_exports.boolean().optional(),
19608
- /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
19609
- purpose: external_exports.literal("availability").optional()
19610
- }).strict();
19611
- var harnessWebUiOpenParamsSchema = external_exports.object({
19612
- harnessId: harnessIdSchema
19613
- }).strict();
19614
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
19615
- var threadModelSelectParamsSchema = external_exports.object({
19616
- threadId: hostThreadIdSchema,
19617
- model: harnessModelRefSchema
19618
- }).strict();
19619
- var threadThinkingSelectParamsSchema = external_exports.object({
19620
- threadId: hostThreadIdSchema,
19621
- thinkingOptionId: harnessThinkingOptionIdSchema
19622
- }).strict();
19623
- var threadInspectionParamsSchema = external_exports.object({
19624
- threadId: hostThreadIdSchema,
19625
- includeReferenceCapability: external_exports.boolean().optional()
19626
- }).strict();
19627
- var codexThreadInspectionSchema = external_exports.object({
19628
- owner: external_exports.literal("codex"),
19629
- locked: external_exports.boolean(),
19630
- effectiveModel: harnessModelRefSchema.optional(),
19631
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19632
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19633
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19634
- history: harnessHistoryCapabilitiesSchema.optional(),
19635
- supportsThreadReferences: external_exports.literal(true).optional()
19636
- }).strict();
19637
- var externalThreadInspectionSchema = external_exports.object({
19638
- owner: external_exports.literal("external"),
19639
- harnessId: nonBlankTextSchema2.max(256),
19640
- transportModelId: nonBlankTextSchema2.max(1024),
19641
- effectiveModel: harnessModelRefSchema.optional(),
19642
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
19643
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
19644
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
19645
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
19646
- history: harnessHistoryCapabilitiesSchema,
19647
- usage: threadUsageSnapshotSchema.optional(),
19648
- locked: external_exports.literal(true)
19649
- }).strict();
19650
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
19651
- codexThreadInspectionSchema,
19652
- externalThreadInspectionSchema
19732
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
19733
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
19734
+ hostExtensionGitHubSourceSchema,
19735
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
19736
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
19653
19737
  ]);
19654
- var threadOwnershipListParamsSchema = external_exports.object({
19655
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19656
- }).strict().superRefine(({ threadIds }, context) => {
19657
- const seen = /* @__PURE__ */ new Set();
19658
- for (const [index, threadId] of threadIds.entries()) {
19659
- if (seen.has(threadId)) {
19660
- context.addIssue({
19661
- code: "custom",
19662
- message: "Thread ownership-list IDs must be unique",
19663
- path: ["threadIds", index]
19664
- });
19665
- }
19666
- seen.add(threadId);
19667
- }
19738
+ var hostExtensionInstallationSchema = external_exports.strictObject({
19739
+ ...active,
19740
+ manifest: hostExtensionManifestV2Schema,
19741
+ installedAt: external_exports.iso.datetime(),
19742
+ source: hostExtensionProvenanceSchema.optional()
19668
19743
  });
19669
- var codexThreadOwnershipSchema = external_exports.object({
19670
- threadId: hostThreadIdSchema,
19671
- owner: external_exports.literal("codex")
19672
- }).strict();
19673
- var externalThreadOwnershipSchema = external_exports.object({
19674
- threadId: hostThreadIdSchema,
19675
- owner: external_exports.literal("external"),
19676
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
19677
- }).strict();
19678
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
19679
- codexThreadOwnershipSchema,
19680
- externalThreadOwnershipSchema
19744
+ var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
19745
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
19746
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
19747
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
19748
+ hostExtensionInstallationSchema.extend({
19749
+ state: external_exports.literal("valid"),
19750
+ enabled: external_exports.boolean(),
19751
+ ...desktopConflict,
19752
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
19753
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
19754
+ backendState: backendState.optional(),
19755
+ backendError: external_exports.string().optional()
19756
+ }),
19757
+ external_exports.strictObject({
19758
+ state: external_exports.enum(["invalid", "incompatible"]),
19759
+ id: external_exports.string().min(1),
19760
+ enabled: external_exports.boolean(),
19761
+ error: external_exports.string()
19762
+ })
19681
19763
  ]);
19682
- var threadOwnershipListResultSchema = external_exports.object({
19683
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
19684
- }).strict().superRefine(({ threads }, context) => {
19685
- const seen = /* @__PURE__ */ new Set();
19686
- for (const [index, thread2] of threads.entries()) {
19687
- if (seen.has(thread2.threadId)) {
19688
- context.addIssue({
19689
- code: "custom",
19690
- message: "Thread ownership-list results must be unique",
19691
- path: ["threads", index, "threadId"]
19692
- });
19693
- }
19694
- seen.add(thread2.threadId);
19695
- }
19764
+ var hostExtensionsListResultSchema = external_exports.strictObject({
19765
+ revision: hostExtensionRevisionSchema,
19766
+ configuration: hostExtensionConfigurationSchema,
19767
+ diagnostics: external_exports.array(external_exports.string()),
19768
+ extensions: external_exports.array(hostExtensionListItemSchema)
19769
+ });
19770
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
19771
+ ...desktopConflict,
19772
+ settingsRevision: hostExtensionRevisionSchema
19773
+ });
19774
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
19775
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
19776
+ revision: hostExtensionRevisionSchema,
19777
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
19778
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
19779
+ });
19780
+ var HOST_EXTENSIONS_RPC = {
19781
+ list: "codexhost/extensions/list",
19782
+ snapshot: "codexhost/extensions/snapshot",
19783
+ catalog: "codexhost/extensions/catalog",
19784
+ install: "codexhost/extensions/install",
19785
+ update: "codexhost/extensions/update",
19786
+ enable: "codexhost/extensions/enable",
19787
+ disable: "codexhost/extensions/disable",
19788
+ uninstall: "codexhost/extensions/uninstall",
19789
+ recover: "codexhost/extensions/recover",
19790
+ asset: "codexhost/extensions/asset",
19791
+ settingsGet: "codexhost/extensions/settings/get",
19792
+ settingsSet: "codexhost/extensions/settings/set",
19793
+ backendInvoke: "codexhost/extensions/backend/invoke"
19794
+ };
19795
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
19796
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
19797
+ var noParams = external_exports.strictObject({});
19798
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
19799
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
19800
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
19801
+ var mutationResult = external_exports.discriminatedUnion("state", [
19802
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
19803
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
19804
+ ]);
19805
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
19806
+ ...optionalActivation,
19807
+ digest: active.digest.optional(),
19808
+ path: hostExtensionResourcePathSchema
19809
+ });
19810
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
19811
+ mimeType: external_exports.string().min(1),
19812
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
19813
+ digest: active.digest
19814
+ });
19815
+ var hostExtensionSettingsSchema = external_exports.strictObject({
19816
+ settingsRevision: hostExtensionRevisionSchema,
19817
+ values: jsonObjectSchema
19696
19818
  });
19697
- var threadSteeringInspectParamsSchema = external_exports.object({
19698
- threadId: hostThreadIdSchema,
19699
- /** The text about to be steered; a Harness command always stops and restarts. */
19700
- text: external_exports.string().optional()
19701
- }).strict();
19702
- var threadSteeringContextSchema = external_exports.object({
19703
- kind: external_exports.literal("application"),
19704
- value: external_exports.string().transform((text, context) => {
19705
- try {
19706
- return JSON.parse(text);
19707
- } catch {
19708
- context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
19709
- return external_exports.NEVER;
19710
- }
19711
- }).pipe(external_exports.object({
19712
- expectedTurnId: hostTurnIdSchema,
19713
- clientUserMessageId: external_exports.string().min(1),
19714
- delivery: external_exports.enum(["newTurn", "activeTurn"])
19715
- }).strict())
19716
- }).strict().transform((context) => context.value);
19717
- var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
19718
- var threadSteeringInspectResultSchema = external_exports.object({
19719
- delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
19720
- }).strict();
19819
+ var hostExtensionsRpcSchemas = {
19820
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
19821
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
19822
+ [HOST_EXTENSIONS_RPC.catalog]: {
19823
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
19824
+ result: hostExtensionsCatalogResultSchema
19825
+ },
19826
+ [HOST_EXTENSIONS_RPC.install]: {
19827
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
19828
+ result: installationResult
19829
+ },
19830
+ [HOST_EXTENSIONS_RPC.update]: {
19831
+ params: external_exports.strictObject({
19832
+ ...id,
19833
+ expectedDigest: active.digest,
19834
+ expectedActivationId: active.activationId.optional(),
19835
+ source: hostExtensionInstallSourceSchema.optional()
19836
+ }),
19837
+ result: installationResult
19838
+ },
19839
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
19840
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
19841
+ [HOST_EXTENSIONS_RPC.uninstall]: {
19842
+ params: external_exports.strictObject({
19843
+ ...id,
19844
+ removeData: external_exports.boolean().optional(),
19845
+ expectedDigest: active.digest.optional()
19846
+ }),
19847
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
19848
+ },
19849
+ [HOST_EXTENSIONS_RPC.recover]: {
19850
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
19851
+ result: mutationResult
19852
+ },
19853
+ [HOST_EXTENSIONS_RPC.asset]: {
19854
+ params: hostExtensionsAssetParamsSchema,
19855
+ result: hostExtensionsAssetResultSchema
19856
+ },
19857
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
19858
+ params: external_exports.strictObject(optionalActivation),
19859
+ result: hostExtensionSettingsSchema
19860
+ },
19861
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
19862
+ params: external_exports.strictObject({
19863
+ ...optionalActivation,
19864
+ expectedSettingsRevision: hostExtensionRevisionSchema,
19865
+ values: jsonObjectSchema
19866
+ }),
19867
+ result: hostExtensionSettingsSchema
19868
+ },
19869
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
19870
+ params: external_exports.strictObject({
19871
+ ...optionalActivation,
19872
+ method: hostExtensionBackendMethodSchema,
19873
+ params: jsonValueSchema.optional()
19874
+ }),
19875
+ result: external_exports.strictObject({ result: jsonValueSchema })
19876
+ }
19877
+ };
19721
19878
 
19722
19879
  // ../../shared-contracts/dist/thread-archive-confirm.js
19723
19880
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -19780,7 +19937,7 @@ var CLIENT_CHANNEL_METHODS = [
19780
19937
  "codexhost/harness/session-import/list",
19781
19938
  "codexhost/harness/session-import/import",
19782
19939
  // Host settings shared across Desktop and Web.
19783
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
19940
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
19784
19941
  "codexhost/harness/installation",
19785
19942
  "codexhost/harness/installation/start",
19786
19943
  "codexhost/harness/installation/status",
@@ -19841,6 +19998,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
19841
19998
  cursor: clientChannelCursorSchema,
19842
19999
  revision: external_exports.number().int().nonnegative()
19843
20000
  }),
20001
+ external_exports.object({
20002
+ type: external_exports.literal("extensions-changed"),
20003
+ cursor: clientChannelCursorSchema,
20004
+ revision: hostExtensionRevisionSchema
20005
+ }),
19844
20006
  external_exports.object({
19845
20007
  type: external_exports.literal("hello"),
19846
20008
  version: external_exports.literal(1),
@@ -20277,7 +20439,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
20277
20439
 
20278
20440
  // ../../shared-contracts/dist/harness-preferences.js
20279
20441
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
20280
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
20442
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
20281
20443
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
20282
20444
  model: harnessModelRefSchema.optional(),
20283
20445
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -20287,11 +20449,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
20287
20449
  lastHarness: harnessIdSchema.optional(),
20288
20450
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
20289
20451
  });
20452
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
20453
+ model: harnessModelRefSchema.optional(),
20454
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
20455
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
20456
+ var delegationDefaultsSchema = external_exports.strictObject({
20457
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
20458
+ });
20290
20459
  var modelId = external_exports.string().min(1).max(1024);
20291
20460
  var harnessPreferenceValuesSchema = external_exports.strictObject({
20292
20461
  idleRelease: idleReleaseSettingsSchema.optional(),
20293
20462
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
20294
- newThread: newThreadDefaultsSchema.optional()
20463
+ newThread: newThreadDefaultsSchema.optional(),
20464
+ delegation: delegationDefaultsSchema.optional()
20295
20465
  });
20296
20466
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
20297
20467
  scope: harnessPreferenceScopeSchema,
@@ -20319,6 +20489,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
20319
20489
  lastHarness: harnessIdSchema.optional(),
20320
20490
  harnessId: harnessIdSchema.optional(),
20321
20491
  configuration: harnessDefaultConfigurationSchema.optional()
20492
+ }),
20493
+ external_exports.strictObject({
20494
+ kind: external_exports.literal("delegation"),
20495
+ harnessId: harnessIdSchema,
20496
+ configuration: harnessDelegationDefaultSchema.nullable()
20322
20497
  })
20323
20498
  ]);
20324
20499
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -21146,9 +21321,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
21146
21321
  ...thread,
21147
21322
  epoch: identity,
21148
21323
  modelId: identity.optional(),
21324
+ serviceTier: harnessModelServiceTierSchema.optional(),
21149
21325
  thinkingOptionId: identity.optional(),
21150
21326
  permissionModeId: identity.optional()
21151
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
21327
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
21328
+ message: "A service tier requires a Model ID"
21329
+ }),
21152
21330
  external_exports.strictObject({
21153
21331
  kind: external_exports.literal("prompt"),
21154
21332
  ...thread,
@@ -21198,7 +21376,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
21198
21376
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
21199
21377
  external_exports.strictObject({
21200
21378
  action: external_exports.literal("read-thread"),
21201
- hostId: hostId.refine((id) => id !== "local"),
21379
+ hostId: hostId.refine((id2) => id2 !== "local"),
21202
21380
  input: delegationReadParamsSchema
21203
21381
  }),
21204
21382
  external_exports.strictObject({
@@ -21212,7 +21390,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
21212
21390
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
21213
21391
  external_exports.strictObject({
21214
21392
  action: external_exports.literal("update"),
21215
- hostId: hostId.refine((id) => id !== "local"),
21393
+ hostId: hostId.refine((id2) => id2 !== "local"),
21216
21394
  version: remoteUpdateParamsSchema.shape.version
21217
21395
  })
21218
21396
  ]);
@@ -21518,7 +21696,7 @@ function invalidRequest(message) {
21518
21696
  return { code: "invalidRequest", message, retryable: false };
21519
21697
  }
21520
21698
  function validateHostApprovalResponse(interaction, response) {
21521
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
21699
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
21522
21700
  }
21523
21701
 
21524
21702
  // ../../harness-adapter/dist/question.js
@@ -21526,7 +21704,7 @@ function invalidRequest2(message) {
21526
21704
  return { code: "invalidRequest", message, retryable: false };
21527
21705
  }
21528
21706
  function validateHostQuestionResponse(interaction, response) {
21529
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
21707
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
21530
21708
  if (response.cancelled) {
21531
21709
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
21532
21710
  }
@@ -21574,6 +21752,21 @@ function validateHostInteractionResponse(interaction, response) {
21574
21752
  return response.type === "approval" ? validateHostApprovalResponse(interaction, response) : invalidRequest3("Interaction Response type does not match the pending Interaction");
21575
21753
  }
21576
21754
 
21755
+ // ../../harness-adapter/dist/composite-model-ref.js
21756
+ function compositeModelRefIds(entries, fallbackId) {
21757
+ const counts = /* @__PURE__ */ new Map();
21758
+ for (const entry of entries) {
21759
+ const id2 = `${entry.provider}/${entry.model}`;
21760
+ counts.set(id2, (counts.get(id2) ?? 0) + 1);
21761
+ }
21762
+ const ids = /* @__PURE__ */ new Map();
21763
+ for (const entry of entries) {
21764
+ const id2 = `${entry.provider}/${entry.model}`;
21765
+ ids.set(counts.get(id2) === 1 ? id2 : fallbackId(entry), entry);
21766
+ }
21767
+ return ids;
21768
+ }
21769
+
21577
21770
  // ../../harness-adapter/dist/output-channel.js
21578
21771
  var HarnessOutputChannel = class {
21579
21772
  outputs;
@@ -21663,7 +21856,8 @@ var tokenFields = [
21663
21856
  var safeIntegerFields = [
21664
21857
  "planFiveHourResetsAtUnix",
21665
21858
  "planSevenDayResetsAtUnix",
21666
- "timeToFirstOutputMs"
21859
+ "timeToFirstOutputMs",
21860
+ "latestRequestTimeToFirstOutputMs"
21667
21861
  ];
21668
21862
  var percentFields = [
21669
21863
  "cacheHitRatePercent",
@@ -22970,7 +23164,7 @@ function expandAssistantStream(value) {
22970
23164
  if (gaps.length !== members.length - 1)
22971
23165
  throw invalid("assistant stream dt length");
22972
23166
  const index = nonNegativeInteger2(candidate.index, "assistant stream block index");
22973
- const id = tool ? identifier(candidate.id, "assistant stream tool id") : void 0;
23167
+ const id2 = tool ? identifier(candidate.id, "assistant stream tool id") : void 0;
22974
23168
  const name = withName ? identifier(candidate.name, "assistant stream tool name") : void 0;
22975
23169
  let time3 = safeInteger(candidate.time0, "assistant stream first time");
22976
23170
  for (const [memberIndex, member] of members.entries()) {
@@ -22979,7 +23173,7 @@ function expandAssistantStream(value) {
22979
23173
  const chunk = tool ? {
22980
23174
  type: "tool-call-delta",
22981
23175
  index,
22982
- id,
23176
+ id: id2,
22983
23177
  ...withName ? { name } : {},
22984
23178
  argumentsDelta: member
22985
23179
  } : {
@@ -23636,7 +23830,7 @@ function createDshUsageStatistics(environment) {
23636
23830
  }
23637
23831
  return sources;
23638
23832
  },
23639
- readSource: (id) => readDshUsage(id)
23833
+ readSource: (id2) => readDshUsage(id2)
23640
23834
  });
23641
23835
  }
23642
23836
 
@@ -23677,7 +23871,7 @@ function deepSeekHarnessCommandCatalog() {
23677
23871
  });
23678
23872
  }
23679
23873
  function parseDeepSeekHarnessCommand(command) {
23680
- const definition = commandDefinitions.find(({ id }) => id === command.commandId);
23874
+ const definition = commandDefinitions.find(({ id: id2 }) => id2 === command.commandId);
23681
23875
  if (!definition) {
23682
23876
  return {
23683
23877
  ok: false,
@@ -24182,45 +24376,59 @@ async function probeDeepSeekExecutableGeneration(options = {}, dependencies = {
24182
24376
  // dist/modern/deepseek-harness-adapter.js
24183
24377
  import { randomUUID as randomUUID2 } from "node:crypto";
24184
24378
  import path11 from "node:path";
24185
-
24186
- // dist/modern/catalog.js
24187
- import { Buffer as Buffer3 } from "node:buffer";
24379
+ import { isDeepStrictEqual as isDeepStrictEqual7 } from "node:util";
24188
24380
 
24189
24381
  // dist/model-catalog.js
24190
24382
  import { Buffer as Buffer2 } from "node:buffer";
24191
24383
  var MODEL_REF_PREFIX = "deepseek-harness-model-v2.";
24192
- function encodeDeepSeekHarnessModelRef(model2) {
24193
- const provider = model2.provider.trim();
24194
- const modelId2 = model2.model.trim();
24195
- if (!provider || !modelId2)
24384
+ function readableId({ provider, model: model2 }) {
24385
+ return `${provider}/${model2}`;
24386
+ }
24387
+ function legacyId({ provider, model: model2 }) {
24388
+ return MODEL_REF_PREFIX + Buffer2.from(JSON.stringify([provider, model2])).toString("base64url");
24389
+ }
24390
+ function sameModel(a, b) {
24391
+ return a.provider === b.provider && a.model === b.model;
24392
+ }
24393
+ function modelIndex(models) {
24394
+ const ids = compositeModelRefIds([...new Map(models.map((model2) => [legacyId(model2), model2])).values()], legacyId);
24395
+ const readable = new Set(models.map(readableId));
24396
+ const byIdentity = /* @__PURE__ */ new Map();
24397
+ const byLegacy = /* @__PURE__ */ new Map();
24398
+ for (const [id2, model2] of ids) {
24399
+ const ref = harnessModelRefSchema.parse({ id: id2 });
24400
+ byIdentity.set(legacyId(model2), ref);
24401
+ const oldId = legacyId({ provider: model2.provider.trim(), model: model2.model.trim() });
24402
+ const other = byLegacy.get(oldId);
24403
+ byLegacy.set(oldId, other === void 0 ? ref : null);
24404
+ }
24405
+ const encode3 = (model2) => {
24406
+ if (!model2.provider.trim() || !model2.model.trim()) {
24407
+ throw new Error("DeepSeek Harness Model identity must not be empty");
24408
+ }
24409
+ const id2 = readableId(model2);
24410
+ return byIdentity.get(legacyId(model2)) ?? harnessModelRefSchema.parse({
24411
+ id: readable.has(id2) ? legacyId(model2) : id2
24412
+ });
24413
+ };
24414
+ return { encode: encode3, ids, byLegacy };
24415
+ }
24416
+ function encodeDeepSeekHarnessModelRef(model2, index) {
24417
+ if (index)
24418
+ return index.encode(model2);
24419
+ if (!model2.provider.trim() || !model2.model.trim()) {
24196
24420
  throw new Error("DeepSeek Harness Model identity must not be empty");
24197
- const encoded = Buffer2.from(JSON.stringify([provider, modelId2]), "utf8").toString("base64url");
24198
- const id = `${MODEL_REF_PREFIX}${encoded}`;
24199
- if (id.length > HARNESS_MODEL_REF_MAX_LENGTH) {
24200
- throw new Error("DeepSeek Harness Model is too long for a Model Ref");
24201
24421
  }
24202
- return harnessModelRefSchema.parse({ id });
24422
+ return harnessModelRefSchema.parse({ id: readableId(model2) });
24203
24423
  }
24204
- function decodeDeepSeekHarnessModelRef(ref) {
24205
- const parsed = harnessModelRefSchema.parse(ref);
24206
- if (!parsed.id.startsWith(MODEL_REF_PREFIX)) {
24207
- throw new Error("DeepSeek Harness Model Ref belongs to another Adapter");
24208
- }
24209
- const encoded = parsed.id.slice(MODEL_REF_PREFIX.length);
24210
- let decoded;
24211
- try {
24212
- decoded = JSON.parse(Buffer2.from(encoded, "base64url").toString("utf8"));
24213
- } catch {
24214
- throw new Error("DeepSeek Harness Model Ref is invalid");
24215
- }
24216
- if (!Array.isArray(decoded) || decoded.length !== 2 || typeof decoded[0] !== "string" || typeof decoded[1] !== "string") {
24217
- throw new Error("DeepSeek Harness Model Ref is invalid");
24218
- }
24219
- const native = { provider: decoded[0], model: decoded[1] };
24220
- if (encodeDeepSeekHarnessModelRef(native).id !== parsed.id) {
24221
- throw new Error("DeepSeek Harness Model Ref is not canonical");
24222
- }
24223
- return native;
24424
+ function decodeDeepSeekHarnessModelRef(ref, index) {
24425
+ const model2 = !ref.serviceTier && index.ids.get(ref.id);
24426
+ if (!model2)
24427
+ throw new Error("DeepSeek Harness Model is unavailable");
24428
+ return model2;
24429
+ }
24430
+ function normalizeStoredDeepSeekModelRef(ref, index) {
24431
+ return ref.serviceTier ? void 0 : index.byLegacy.get(ref.id) ?? void 0;
24224
24432
  }
24225
24433
  function parseDeepSeekThinkingOptionId(value) {
24226
24434
  if (value === void 0)
@@ -24236,7 +24444,7 @@ function normalizeDeepSeekThinkingOptions(models) {
24236
24444
  return parsedId.success ? [{ id: parsedId.data, label: effort.name }] : [];
24237
24445
  });
24238
24446
  }
24239
- function normalizeDeepSeekModelCatalog(groups2, selection2) {
24447
+ function normalizeDeepSeekModelCatalog(groups2, selection3) {
24240
24448
  const thinkingOptions = [];
24241
24449
  const knownEffortIds = /* @__PURE__ */ new Set();
24242
24450
  for (const group of groups2) {
@@ -24252,25 +24460,34 @@ function normalizeDeepSeekModelCatalog(groups2, selection2) {
24252
24460
  }
24253
24461
  }
24254
24462
  }
24463
+ const identities = groups2.flatMap((group) => group.models.map((model2) => ({ provider: group.id, model: model2.id })));
24464
+ if (selection3 && !identities.some((model2) => sameModel(model2, selection3))) {
24465
+ identities.push({ provider: selection3.provider, model: selection3.model });
24466
+ }
24467
+ const index = modelIndex(identities);
24255
24468
  const models = groups2.flatMap((group) => group.models.map((model2) => ({
24256
- ref: encodeDeepSeekHarnessModelRef({ provider: group.id, model: model2.id }),
24469
+ ref: index.encode({ provider: group.id, model: model2.id }),
24257
24470
  label: `${group.name} / ${model2.name}`,
24258
24471
  ...model2.reasoning && model2.reasoning.efforts.length > 0 ? { supportedThinkingOptionIds: model2.reasoning.efforts.map((effort) => effort.id) } : {}
24259
24472
  })));
24260
- const defaultModel = selection2 ? encodeDeepSeekHarnessModelRef(selection2) : void 0;
24261
- if (selection2 && defaultModel && !models.some((model2) => model2.ref.id === defaultModel.id)) {
24262
- models.unshift({ ref: defaultModel, label: `${selection2.provider} / ${selection2.model}` });
24473
+ const defaultModel = selection3 ? index.encode(selection3) : void 0;
24474
+ if (selection3 && defaultModel && !models.some((model2) => model2.ref.id === defaultModel.id)) {
24475
+ models.unshift({ ref: defaultModel, label: `${selection3.provider} / ${selection3.model}` });
24263
24476
  }
24264
- const defaultReasoning = selection2 ? groups2.find((group) => group.id === selection2.provider)?.models.find((model2) => model2.id === selection2.model)?.reasoning : void 0;
24265
- const defaultThinkingOptionId = parseDeepSeekThinkingOptionId(selection2?.reasoningEffort ?? defaultReasoning?.defaultEffort);
24266
- return harnessModelCatalogSchema.parse({
24477
+ const defaultReasoning = selection3 ? groups2.find((group) => group.id === selection3.provider)?.models.find((model2) => model2.id === selection3.model)?.reasoning : void 0;
24478
+ const defaultThinkingOptionId = parseDeepSeekThinkingOptionId(selection3?.reasoningEffort ?? defaultReasoning?.defaultEffort);
24479
+ const catalog = harnessModelCatalogSchema.parse({
24267
24480
  models,
24268
24481
  ...defaultModel ? { defaultModel } : {},
24269
24482
  thinkingOptions,
24270
24483
  ...defaultThinkingOptionId && defaultReasoning?.efforts.some((effort) => effort.id === defaultThinkingOptionId) ? { defaultThinkingOptionId } : {}
24271
24484
  });
24485
+ return { catalog, index };
24272
24486
  }
24273
24487
 
24488
+ // dist/modern/catalog.js
24489
+ import { Buffer as Buffer3 } from "node:buffer";
24490
+
24274
24491
  // dist/modern/remote-connection.js
24275
24492
  import { spawn as spawn2 } from "node:child_process";
24276
24493
  import { randomUUID } from "node:crypto";
@@ -25393,7 +25610,7 @@ function array2(value, maximum, area) {
25393
25610
  }
25394
25611
  return value;
25395
25612
  }
25396
- function selection(value) {
25613
+ function selection2(value) {
25397
25614
  if (!isPlainRecord(value) || !exactKeys2(value, ["provider", "model"], ["reasoningEffort"])) {
25398
25615
  throw catalogError("protocolError", "DeepSeek Harness returned an invalid default Model");
25399
25616
  }
@@ -25413,19 +25630,19 @@ function reasoning(value) {
25413
25630
  if (!isPlainRecord(candidate) || !exactKeys2(candidate, ["id", "name"], ["description"])) {
25414
25631
  throw catalogError("protocolError", "DeepSeek Harness returned an invalid reasoning effort");
25415
25632
  }
25416
- const id = boundedString(candidate.id, MAX_ID_LENGTH, "reasoning effort id");
25417
- if (!harnessThinkingOptionIdSchema.safeParse(id).success) {
25633
+ const id2 = boundedString(candidate.id, MAX_ID_LENGTH, "reasoning effort id");
25634
+ if (!harnessThinkingOptionIdSchema.safeParse(id2).success) {
25418
25635
  throw catalogError("protocolError", "DeepSeek Harness returned an unusable reasoning effort id");
25419
25636
  }
25420
25637
  return {
25421
- id,
25638
+ id: id2,
25422
25639
  name: boundedString(candidate.name, MAX_NAME_LENGTH, "reasoning effort name"),
25423
25640
  ...candidate.description === void 0 ? {} : {
25424
25641
  description: boundedString(candidate.description, MAX_DESCRIPTION_LENGTH, "reasoning effort description", true)
25425
25642
  }
25426
25643
  };
25427
25644
  });
25428
- const ids = efforts.map(({ id }) => id);
25645
+ const ids = efforts.map(({ id: id2 }) => id2);
25429
25646
  if (new Set(ids).size !== ids.length) {
25430
25647
  throw catalogError("protocolError", "DeepSeek Harness returned duplicate reasoning efforts");
25431
25648
  }
@@ -25453,8 +25670,8 @@ function groups(value, routable) {
25453
25670
  if (!isPlainRecord(candidate) || !exactKeys2(candidate, ["id", "name", "models"])) {
25454
25671
  throw catalogError("protocolError", "DeepSeek Harness returned an invalid Model provider group");
25455
25672
  }
25456
- const id = boundedString(candidate.id, MAX_ID_LENGTH, "Model provider id");
25457
- if (!routable.has(id)) {
25673
+ const id2 = boundedString(candidate.id, MAX_ID_LENGTH, "Model provider id");
25674
+ if (!routable.has(id2)) {
25458
25675
  throw catalogError("protocolError", "DeepSeek Harness returned a non-routable Model group");
25459
25676
  }
25460
25677
  const name = boundedString(candidate.name, MAX_NAME_LENGTH, "Model provider name");
@@ -25489,9 +25706,9 @@ function groups(value, routable) {
25489
25706
  if (new Set(modelIds).size !== modelIds.length) {
25490
25707
  throw catalogError("protocolError", "DeepSeek Harness returned duplicate Model ids");
25491
25708
  }
25492
- return { id, name, models };
25709
+ return { id: id2, name, models };
25493
25710
  });
25494
- const ids = parsed.map(({ id }) => id);
25711
+ const ids = parsed.map(({ id: id2 }) => id2);
25495
25712
  if (new Set(ids).size !== ids.length) {
25496
25713
  throw catalogError("protocolError", "DeepSeek Harness returned duplicate Model provider groups");
25497
25714
  }
@@ -25503,13 +25720,13 @@ function validateFailures(value, routable, successful) {
25503
25720
  if (!isPlainRecord(candidate) || !exactKeys2(candidate, ["id", "name", "message"])) {
25504
25721
  throw catalogError("protocolError", "DeepSeek Harness returned an invalid provider failure");
25505
25722
  }
25506
- const id = boundedString(candidate.id, MAX_ID_LENGTH, "failed provider id");
25723
+ const id2 = boundedString(candidate.id, MAX_ID_LENGTH, "failed provider id");
25507
25724
  boundedString(candidate.name, MAX_NAME_LENGTH, "failed provider name");
25508
25725
  boundedString(candidate.message, MAX_DESCRIPTION_LENGTH, "provider failure message", true);
25509
- if (!routable.has(id) || successful.has(id)) {
25726
+ if (!routable.has(id2) || successful.has(id2)) {
25510
25727
  throw catalogError("protocolError", "DeepSeek Harness returned an inconsistent provider failure");
25511
25728
  }
25512
- ids.push(id);
25729
+ ids.push(id2);
25513
25730
  }
25514
25731
  if (new Set(ids).size !== ids.length) {
25515
25732
  throw catalogError("protocolError", "DeepSeek Harness returned duplicate provider failures");
@@ -25520,26 +25737,24 @@ function parseModernModelCatalog(value) {
25520
25737
  if (!isPlainRecord(value) || !exactKeys2(value, ["default", "routableProviders", "groups", "failures"])) {
25521
25738
  throw catalogError("protocolError", "DeepSeek Harness returned an invalid model catalog");
25522
25739
  }
25523
- const defaultSelection = selection(value.default);
25740
+ const defaultSelection = selection2(value.default);
25524
25741
  const routableProviders = array2(value.routableProviders, MAX_PROVIDERS, "routable provider list").map((candidate) => boundedString(candidate, MAX_ID_LENGTH, "routable provider id"));
25525
25742
  if (new Set(routableProviders).size !== routableProviders.length) {
25526
25743
  throw catalogError("protocolError", "DeepSeek Harness returned duplicate routable providers");
25527
25744
  }
25528
25745
  const routable = new Set(routableProviders);
25529
25746
  const parsedGroups = groups(value.groups, routable);
25530
- validateFailures(value.failures, routable, new Set(parsedGroups.map(({ id }) => id)));
25531
- let catalog;
25747
+ validateFailures(value.failures, routable, new Set(parsedGroups.map(({ id: id2 }) => id2)));
25532
25748
  try {
25533
- catalog = normalizeDeepSeekModelCatalog(parsedGroups, routable.has(defaultSelection.provider) ? defaultSelection : void 0);
25749
+ return {
25750
+ ...normalizeDeepSeekModelCatalog(parsedGroups, routable.has(defaultSelection.provider) ? defaultSelection : void 0),
25751
+ defaultSelection,
25752
+ routableProviders,
25753
+ groups: parsedGroups
25754
+ };
25534
25755
  } catch {
25535
25756
  throw catalogError("protocolError", "DeepSeek Harness returned an unusable model catalog");
25536
25757
  }
25537
- return {
25538
- catalog,
25539
- defaultSelection,
25540
- routableProviders,
25541
- groups: parsedGroups
25542
- };
25543
25758
  }
25544
25759
  async function loadModernModelCatalog(remote, signal) {
25545
25760
  try {
@@ -26513,11 +26728,11 @@ function presetOptions(value, area) {
26513
26728
  if (!isPlainRecord4(candidate) || !exactKeys3(candidate, ["value", "name"], ["description"])) {
26514
26729
  throw permissionError("protocolError", "DeepSeek Harness returned an invalid permission option");
26515
26730
  }
26516
- const id = harnessPermissionModeIdSchema.safeParse(candidate.value);
26517
- if (!id.success) {
26731
+ const id2 = harnessPermissionModeIdSchema.safeParse(candidate.value);
26732
+ if (!id2.success) {
26518
26733
  throw permissionError("protocolError", "DeepSeek Harness returned an invalid permission option id");
26519
26734
  }
26520
- if (id.data === CUSTOM_PERMISSION_MODE_ID) {
26735
+ if (id2.data === CUSTOM_PERMISSION_MODE_ID) {
26521
26736
  throw permissionError("protocolError", "DeepSeek Harness advertised the reserved custom permission");
26522
26737
  }
26523
26738
  const label = nonBlankString2(candidate.name, HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH, "permission label");
@@ -26527,13 +26742,13 @@ function presetOptions(value, area) {
26527
26742
  }
26528
26743
  const presentation = presetLabels.get(label);
26529
26744
  return {
26530
- id: id.data,
26745
+ id: id2.data,
26531
26746
  label,
26532
26747
  ...presentation ? { localizations: { en: { label: presentation.en }, "zh-CN": { label: presentation.zh } } } : {},
26533
26748
  ...description?.trim() ? { description } : {}
26534
26749
  };
26535
26750
  });
26536
- if (new Set(modes.map(({ id }) => id)).size !== modes.length) {
26751
+ if (new Set(modes.map(({ id: id2 }) => id2)).size !== modes.length) {
26537
26752
  throw permissionError("protocolError", "DeepSeek Harness returned duplicate permission choices");
26538
26753
  }
26539
26754
  return modes;
@@ -26545,11 +26760,11 @@ function parseModernPermissionPresetCatalog(value) {
26545
26760
  }
26546
26761
  const modes = presetOptions(value.options, "options");
26547
26762
  const defaults = presetOptions(value.defaultOptions, "default options");
26548
- if (defaults.some((preset) => !modes.some(({ id, label, description }) => id === preset.id && label === preset.label && description === preset.description))) {
26763
+ if (defaults.some((preset) => !modes.some(({ id: id2, label, description }) => id2 === preset.id && label === preset.label && description === preset.description))) {
26549
26764
  throw permissionError("protocolError", "DeepSeek Harness permission defaults disagree with its selectable presets");
26550
26765
  }
26551
26766
  const defaultModeId = harnessPermissionModeIdSchema.safeParse(value.defaultPreset);
26552
- if (!defaultModeId.success || !defaults.some(({ id }) => id === defaultModeId.data)) {
26767
+ if (!defaultModeId.success || !defaults.some(({ id: id2 }) => id2 === defaultModeId.data)) {
26553
26768
  throw permissionError("protocolError", "DeepSeek Harness returned an invalid permission default");
26554
26769
  }
26555
26770
  try {
@@ -26586,7 +26801,7 @@ function parseCurrentPermission(value, catalog) {
26586
26801
  if (!current.success) {
26587
26802
  throw permissionError("protocolError", "DeepSeek Harness returned an invalid current permission");
26588
26803
  }
26589
- if (current.data !== CUSTOM_PERMISSION_MODE_ID && current.data !== AUTO_PERMISSION_MODE_ID && !catalog.modes.some(({ id }) => id === current.data)) {
26804
+ if (current.data !== CUSTOM_PERMISSION_MODE_ID && current.data !== AUTO_PERMISSION_MODE_ID && !catalog.modes.some(({ id: id2 }) => id2 === current.data)) {
26590
26805
  throw permissionError("protocolError", "DeepSeek Harness returned an unknown current permission");
26591
26806
  }
26592
26807
  return current.data;
@@ -26611,7 +26826,7 @@ function readModernPermissionModeState(row, catalog) {
26611
26826
  }
26612
26827
  function isModernPermissionModeProjectionMatch(value, catalog, expectedPermissionModeId) {
26613
26828
  const expected = harnessPermissionModeIdSchema.safeParse(expectedPermissionModeId);
26614
- if (!expected.success || !catalog.modes.some(({ id }) => id === expected.data)) {
26829
+ if (!expected.success || !catalog.modes.some(({ id: id2 }) => id2 === expected.data)) {
26615
26830
  throw new TypeError("expectedPermissionModeId is not in the permission catalog");
26616
26831
  }
26617
26832
  return parseCurrentPermission(value, catalog) === expected.data;
@@ -26690,28 +26905,28 @@ function readModernModelSelectionState(row, catalog) {
26690
26905
  throw configurationError("protocolError", "DeepSeek Harness modelSelection projection has an invalid sequence");
26691
26906
  }
26692
26907
  const projected = parseProjectionSelection(row.value);
26693
- const selection2 = projected ?? parseSelection(catalog.defaultSelection, "default Model selection");
26908
+ const selection3 = projected ?? parseSelection(catalog.defaultSelection, "default Model selection");
26694
26909
  try {
26695
- encodeDeepSeekHarnessModelRef(selection2);
26910
+ encodeDeepSeekHarnessModelRef(selection3, catalog.index);
26696
26911
  } catch {
26697
26912
  throw configurationError("protocolError", "DeepSeek Harness modelSelection projection cannot be represented by codexhost");
26698
26913
  }
26699
- return { selection: selection2, projectionSeq: row.seq, explicit: projected !== null };
26914
+ return { selection: selection3, projectionSeq: row.seq, explicit: projected !== null };
26700
26915
  }
26701
- function stateForSelection(nativeRef, selection2, catalog, permissionModeId) {
26702
- const effectiveModel = encodeDeepSeekHarnessModelRef(selection2);
26703
- if (!catalog.routableProviders.includes(selection2.provider)) {
26916
+ function stateForSelection(nativeRef, selection3, catalog, permissionModeId) {
26917
+ const effectiveModel = encodeDeepSeekHarnessModelRef(selection3, catalog.index);
26918
+ if (!catalog.routableProviders.includes(selection3.provider)) {
26704
26919
  throw configurationError("protocolError", "DeepSeek Harness modelSelection names a non-routable provider");
26705
26920
  }
26706
- const nativeModel = catalog.groups.find(({ id }) => id === selection2.provider)?.models.find(({ id }) => id === selection2.model);
26921
+ const nativeModel = catalog.groups.find(({ id: id2 }) => id2 === selection3.provider)?.models.find(({ id: id2 }) => id2 === selection3.model);
26707
26922
  const catalogModel = nativeModel ? catalog.catalog.models.find(({ ref }) => ref.id === effectiveModel.id) : void 0;
26708
26923
  const availableThinkingOptions = normalizeDeepSeekThinkingOptions({
26709
- current: selection2,
26924
+ current: selection3,
26710
26925
  groups: catalog.groups
26711
26926
  });
26712
- const effectiveEffort = selection2.reasoningEffort ?? nativeModel?.reasoning?.defaultEffort;
26927
+ const effectiveEffort = selection3.reasoningEffort ?? nativeModel?.reasoning?.defaultEffort;
26713
26928
  const effectiveThinkingOptionId = effectiveEffort === void 0 ? void 0 : harnessThinkingOptionIdSchema.parse(effectiveEffort);
26714
- const canPublishThinkingOptions = availableThinkingOptions.length > 0 && (!effectiveThinkingOptionId || availableThinkingOptions.some(({ id }) => id === effectiveThinkingOptionId));
26929
+ const canPublishThinkingOptions = availableThinkingOptions.length > 0 && (!effectiveThinkingOptionId || availableThinkingOptions.some(({ id: id2 }) => id2 === effectiveThinkingOptionId));
26715
26930
  return {
26716
26931
  nativeRef,
26717
26932
  effectiveModel,
@@ -26737,7 +26952,7 @@ function readModernConfigurationSnapshot(input) {
26737
26952
  function modernSelectionForModel(catalog, model2, thinkingOptionId) {
26738
26953
  let native;
26739
26954
  try {
26740
- native = decodeDeepSeekHarnessModelRef(model2);
26955
+ native = decodeDeepSeekHarnessModelRef(model2, catalog.index);
26741
26956
  } catch (error51) {
26742
26957
  throw configurationError("invalidRequest", error51 instanceof Error ? error51.message : "DeepSeek Harness Model is invalid");
26743
26958
  }
@@ -26745,7 +26960,7 @@ function modernSelectionForModel(catalog, model2, thinkingOptionId) {
26745
26960
  if (!catalogModel) {
26746
26961
  throw configurationError("invalidRequest", "DeepSeek Harness Model is unavailable");
26747
26962
  }
26748
- const nativeModel = catalog.groups.find(({ id }) => id === native.provider)?.models.find(({ id }) => id === native.model);
26963
+ const nativeModel = catalog.groups.find(({ id: id2 }) => id2 === native.provider)?.models.find(({ id: id2 }) => id2 === native.model);
26749
26964
  const effort = thinkingOptionId ?? nativeModel?.reasoning?.defaultEffort;
26750
26965
  if (effort !== void 0) {
26751
26966
  const parsed = harnessThinkingOptionIdSchema.safeParse(effort);
@@ -26797,7 +27012,7 @@ async function selectModernModel(remote, control, sessionId, catalog, requested,
26797
27012
  }
26798
27013
  async function selectModernPermissionMode(remote, control, sessionId, catalog, permissionModeId, signal) {
26799
27014
  const requested = harnessPermissionModeIdSchema.safeParse(permissionModeId);
26800
- if (!requested.success || !catalog?.modes.some(({ id }) => id === requested.data)) {
27015
+ if (!requested.success || !catalog?.modes.some(({ id: id2 }) => id2 === requested.data)) {
26801
27016
  throw configurationError(catalog ? "invalidRequest" : "unsupported", "DeepSeek Harness Permission Mode is unavailable");
26802
27017
  }
26803
27018
  const current = await requireModernPermissionModeState(control, sessionId, catalog, signal);
@@ -27668,7 +27883,7 @@ function parseQuestionRequest(value) {
27668
27883
  if (value.questions.length === 0)
27669
27884
  throw invalidFrame();
27670
27885
  const questions = value.questions.map(parseQuestionItem);
27671
- if (new Set(questions.map(({ id }) => id)).size !== questions.length)
27886
+ if (new Set(questions.map(({ id: id2 }) => id2)).size !== questions.length)
27672
27887
  throw invalidFrame();
27673
27888
  const wait = Object.hasOwn(value, "wait") ? parseQuestionWait(value.wait) : void 0;
27674
27889
  if (questions.some(({ intent }) => intent?.kind === "approval") && (questions.length !== 1 || wait !== void 0)) {
@@ -28048,9 +28263,9 @@ async function openModernJournal(remote, request, options = {}) {
28048
28263
  }
28049
28264
  const parsed = parseLiveItem(item.value, limits, profile);
28050
28265
  if ("frame" in parsed.item) {
28051
- const expectedRevision = assistantRevision + 1;
28266
+ const expectedRevision2 = assistantRevision + 1;
28052
28267
  const restartsLifecycle = parsed.item.frame.type === "start" && parsed.item.frame.revision === 1;
28053
- if (!restartsLifecycle && parsed.item.frame.revision !== expectedRevision) {
28268
+ if (!restartsLifecycle && parsed.item.frame.revision !== expectedRevision2) {
28054
28269
  throw new ModernJournalDesyncError("journal assistant stream is not revision-contiguous");
28055
28270
  }
28056
28271
  assistantRevision = parsed.item.frame.revision;
@@ -29453,7 +29668,7 @@ function projectModernHistory(input) {
29453
29668
  const toolOutputLimit = boundedInteger(input.toolOutputLimit ?? MODERN_TOOL_OUTPUT_LIMIT, "toolOutputLimit", 0);
29454
29669
  const validator = new ModernEventValidator(input.maxEvents, profile);
29455
29670
  const turns = [];
29456
- let active = null;
29671
+ let active2 = null;
29457
29672
  let effectiveModel = input.fallbackModel;
29458
29673
  let effectiveThinkingOptionId = input.fallbackThinkingOptionId;
29459
29674
  let contextWindowTokens;
@@ -29484,7 +29699,7 @@ function projectModernHistory(input) {
29484
29699
  workingDirectory = modernWorkingDirectory(workingDirectory, event);
29485
29700
  switch (event.type) {
29486
29701
  case "turn/start":
29487
- active = {
29702
+ active2 = {
29488
29703
  turn: data.turn,
29489
29704
  startIndex: index,
29490
29705
  input: [],
@@ -29496,19 +29711,19 @@ function projectModernHistory(input) {
29496
29711
  };
29497
29712
  break;
29498
29713
  case "model/selection": {
29499
- const selection2 = selectionFrom(data);
29500
- effectiveModel = selection2.model;
29501
- effectiveThinkingOptionId = selection2.thinking;
29502
- if (active)
29503
- active.model = selection2.model;
29714
+ const selection3 = selectionFrom(data, input.modelIndex);
29715
+ effectiveModel = selection3.model;
29716
+ effectiveThinkingOptionId = selection3.thinking;
29717
+ if (active2)
29718
+ active2.model = selection3.model;
29504
29719
  break;
29505
29720
  }
29506
29721
  case "request/header": {
29507
- const selection2 = selectionFromHeader(data);
29508
- effectiveModel = selection2.model;
29509
- effectiveThinkingOptionId = selection2.thinking;
29510
- if (active)
29511
- active.model = selection2.model;
29722
+ const selection3 = selectionFromHeader(data, input.modelIndex);
29723
+ effectiveModel = selection3.model;
29724
+ effectiveThinkingOptionId = selection3.thinking;
29725
+ if (active2)
29726
+ active2.model = selection3.model;
29512
29727
  break;
29513
29728
  }
29514
29729
  case "request/context":
@@ -29516,8 +29731,8 @@ function projectModernHistory(input) {
29516
29731
  rebuildUsage();
29517
29732
  break;
29518
29733
  case "user/message":
29519
- if (active && event.surfaceOp === "append" && isRecord4(data.source) && data.source.kind === "user") {
29520
- active.input.push(...textInputs(data.content));
29734
+ if (active2 && event.surfaceOp === "append" && isRecord4(data.source) && data.source.kind === "user") {
29735
+ active2.input.push(...textInputs(data.content));
29521
29736
  }
29522
29737
  break;
29523
29738
  case "assistant/attempt":
@@ -29526,18 +29741,18 @@ function projectModernHistory(input) {
29526
29741
  case "assistant/message":
29527
29742
  if (event.surfaceOp === "append") {
29528
29743
  recordSettlementUsage(data, event.seq);
29529
- if (active) {
29530
- projectAssistantMessage(active, input.sessionId, data, media ? modernMediaRoots(workingDirectory, input.cwd) : void 0);
29744
+ if (active2) {
29745
+ projectAssistantMessage(active2, input.sessionId, data, media ? modernMediaRoots(workingDirectory, input.cwd) : void 0);
29531
29746
  }
29532
29747
  }
29533
29748
  break;
29534
29749
  case "compaction/start":
29535
- if (active && data.turn === active.turn && data.sourceCommandId === void 0) {
29536
- if (active.compaction)
29750
+ if (active2 && data.turn === active2.turn && data.sourceCommandId === void 0) {
29751
+ if (active2.compaction)
29537
29752
  fail("Modern compactions overlap");
29538
29753
  const nativeId = data.compactionId;
29539
- active.compaction = { nativeId, itemIndex: active.items.length };
29540
- active.items.push({
29754
+ active2.compaction = { nativeId, itemIndex: active2.items.length };
29755
+ active2.items.push({
29541
29756
  item: {
29542
29757
  type: "contextCompaction",
29543
29758
  itemId: modernItemId(input.sessionId, `compaction:${nativeId}`)
@@ -29547,45 +29762,45 @@ function projectModernHistory(input) {
29547
29762
  }
29548
29763
  break;
29549
29764
  case "compaction/end":
29550
- if (active && data.turn === active.turn && data.sourceCommandId === void 0) {
29551
- if (!active.compaction || active.compaction.nativeId !== data.compactionId)
29765
+ if (active2 && data.turn === active2.turn && data.sourceCommandId === void 0) {
29766
+ if (!active2.compaction || active2.compaction.nativeId !== data.compactionId)
29552
29767
  fail("Modern compaction ended without its start");
29553
- const index2 = active.compaction.itemIndex;
29554
- const snapshot = active.items[index2];
29768
+ const index2 = active2.compaction.itemIndex;
29769
+ const snapshot = active2.items[index2];
29555
29770
  if (!snapshot)
29556
29771
  fail("Modern compaction Item is missing");
29557
- active.items[index2] = { ...snapshot, outcome: modernCompactionOutcome(data) };
29558
- delete active.compaction;
29772
+ active2.items[index2] = { ...snapshot, outcome: modernCompactionOutcome(data) };
29773
+ delete active2.compaction;
29559
29774
  }
29560
29775
  break;
29561
29776
  case "tool/call":
29562
- if (active)
29563
- projectToolCall(active, input.sessionId, data, event.seq);
29777
+ if (active2)
29778
+ projectToolCall(active2, input.sessionId, data, event.seq);
29564
29779
  break;
29565
29780
  case "tool/result":
29566
- if (active && event.surfaceOp === "append") {
29567
- projectToolResultEvent(active, input.sessionId, event, toolOutputLimit);
29781
+ if (active2 && event.surfaceOp === "append") {
29782
+ projectToolResultEvent(active2, input.sessionId, event, toolOutputLimit);
29568
29783
  }
29569
29784
  break;
29570
29785
  case "tool/ptc-dispatch-start":
29571
- if (active)
29572
- projectPtcDispatchStart(active, input.sessionId, data, event.seq);
29786
+ if (active2)
29787
+ projectPtcDispatchStart(active2, input.sessionId, data, event.seq);
29573
29788
  break;
29574
29789
  case "tool/ptc-dispatch":
29575
- if (active) {
29576
- projectPtcDispatchSettle(active, input.sessionId, data, event.seq, toolOutputLimit);
29790
+ if (active2) {
29791
+ projectPtcDispatchSettle(active2, input.sessionId, data, event.seq, toolOutputLimit);
29577
29792
  }
29578
29793
  break;
29579
29794
  case "turn/end":
29580
- if (active) {
29795
+ if (active2) {
29581
29796
  const terminal = safeTurnReason(data.reason);
29582
- finishIncompleteTools(active, itemOutcome(terminal.outcome));
29583
- if (active.compaction) {
29584
- const index2 = active.compaction.itemIndex;
29585
- const snapshot = active.items[index2];
29797
+ finishIncompleteTools(active2, itemOutcome(terminal.outcome));
29798
+ if (active2.compaction) {
29799
+ const index2 = active2.compaction.itemIndex;
29800
+ const snapshot = active2.items[index2];
29586
29801
  if (!snapshot)
29587
29802
  fail("Modern compaction Item is missing");
29588
- active.items[index2] = {
29803
+ active2.items[index2] = {
29589
29804
  ...snapshot,
29590
29805
  outcome: terminal.outcome.status === "succeeded" ? modernCompactionOutcome({
29591
29806
  error: "DeepSeek Harness compaction ended without a terminal event"
@@ -29593,14 +29808,14 @@ function projectModernHistory(input) {
29593
29808
  };
29594
29809
  }
29595
29810
  turns.push({
29596
- nativeTurnRef: modernNativeTurnRef(harnessId, input.sessionId, active.turn),
29811
+ nativeTurnRef: modernNativeTurnRef(harnessId, input.sessionId, active2.turn),
29597
29812
  checkpoint: modernCheckpointRef(harnessId, input.sessionId, event.seq, profile),
29598
- input: active.input,
29599
- items: active.items,
29813
+ input: active2.input,
29814
+ items: active2.items,
29600
29815
  outcome: terminal.history,
29601
- ...active.model ? { model: active.model } : {}
29816
+ ...active2.model ? { model: active2.model } : {}
29602
29817
  });
29603
- active = null;
29818
+ active2 = null;
29604
29819
  }
29605
29820
  break;
29606
29821
  default:
@@ -29626,7 +29841,7 @@ function projectModernHistory(input) {
29626
29841
  effectiveThinkingOptionId,
29627
29842
  contextWindowTokens,
29628
29843
  usage,
29629
- incompleteTurn: active ? { turn: active.turn, events: input.events.slice(active.startIndex) } : void 0
29844
+ incompleteTurn: active2 ? { turn: active2.turn, events: input.events.slice(active2.startIndex) } : void 0
29630
29845
  };
29631
29846
  }
29632
29847
  function modernNativeTurnRef(harnessId, sessionId, turn) {
@@ -29801,18 +30016,18 @@ function incompleteToolOutcome(toolName) {
29801
30016
  })
29802
30017
  };
29803
30018
  }
29804
- function selectionFrom(data) {
30019
+ function selectionFrom(data, index) {
29805
30020
  return {
29806
30021
  model: encodeDeepSeekHarnessModelRef({
29807
30022
  provider: data.provider,
29808
30023
  model: data.model
29809
- }),
30024
+ }, index),
29810
30025
  thinking: parseDeepSeekThinkingOptionId(data.reasoningEffort)
29811
30026
  };
29812
30027
  }
29813
- function selectionFromHeader(data) {
30028
+ function selectionFromHeader(data, index) {
29814
30029
  const header = data.header;
29815
- return selectionFrom(header.config);
30030
+ return selectionFrom(header.config, index);
29816
30031
  }
29817
30032
  function textInputs(value) {
29818
30033
  return Array.isArray(value) ? value.flatMap((block) => isRecord4(block) && block.type === "text" && typeof block.text === "string" ? [{ type: "text", text: block.text }] : []) : [];
@@ -30580,6 +30795,7 @@ var ModernHarnessSession = class {
30580
30795
  this.#workingDirectory = modernWorkingDirectory(this.#workingDirectory, event);
30581
30796
  }
30582
30797
  const projection = projectModernHistory({
30798
+ modelIndex: this.#modelCatalog.index,
30583
30799
  harnessId: this.harnessId,
30584
30800
  sessionId: this.#sessionId,
30585
30801
  events: this.#events,
@@ -30727,9 +30943,9 @@ var ModernHarnessSession = class {
30727
30943
  this.#queuedDeliveries.set(delivery.eventId, delivery);
30728
30944
  return;
30729
30945
  }
30730
- const active = this.#active;
30731
- if (active && !active.terminal) {
30732
- this.#publishInteraction(delivery, active);
30946
+ const active2 = this.#active;
30947
+ if (active2 && !active2.terminal) {
30948
+ this.#publishInteraction(delivery, active2);
30733
30949
  return;
30734
30950
  }
30735
30951
  this.#queuedDeliveries.set(delivery.eventId, delivery);
@@ -30748,12 +30964,12 @@ var ModernHarnessSession = class {
30748
30964
  this.#closeInteraction(interactionId, "cancelled");
30749
30965
  }
30750
30966
  async cancelNative() {
30751
- const active = this.#active;
30752
- if (active?.cancelAcknowledged)
30967
+ const active2 = this.#active;
30968
+ if (active2?.cancelAcknowledged)
30753
30969
  return;
30754
- const operation = active?.cancelPromise ?? this.#requestNativeCancel(active);
30755
- if (active && !active.cancelPromise)
30756
- active.cancelPromise = operation;
30970
+ const operation = active2?.cancelPromise ?? this.#requestNativeCancel(active2);
30971
+ if (active2 && !active2.cancelPromise)
30972
+ active2.cancelPromise = operation;
30757
30973
  await operation;
30758
30974
  }
30759
30975
  onFault(error51) {
@@ -30933,8 +31149,8 @@ var ModernHarnessSession = class {
30933
31149
  }
30934
31150
  }
30935
31151
  #outlivesReleasedWait(pending) {
30936
- const active = this.#active;
30937
- return !this.#closed && !this.#closing && pending.delivery.type === "question" && pending.delivery.request.wait?.timed === true && active !== void 0 && !active.terminal && active.interactions.has(pending.interaction.interactionId);
31152
+ const active2 = this.#active;
31153
+ return !this.#closed && !this.#closing && pending.delivery.type === "question" && pending.delivery.request.wait?.timed === true && active2 !== void 0 && !active2.terminal && active2.interactions.has(pending.interaction.interactionId);
30938
31154
  }
30939
31155
  /** Keep a timed answer pending until its call's native result arrives or the interaction closes. */
30940
31156
  #holdAnswer(pending, callId, answer) {
@@ -30944,9 +31160,9 @@ var ModernHarnessSession = class {
30944
31160
  return { callId, answer, outcome };
30945
31161
  }
30946
31162
  /** Apply the native result of a timed question's call to its Host interaction. */
30947
- #observeTimedQuestion(active, callId, readOutcome) {
31163
+ #observeTimedQuestion(active2, callId, readOutcome) {
30948
31164
  let interactionId;
30949
- for (const candidate of active.interactions) {
31165
+ for (const candidate of active2.interactions) {
30950
31166
  const delivery = this.#interactions.get(candidate)?.delivery;
30951
31167
  if (delivery?.type === "question" && delivery.request.wait?.timed === true && delivery.request.wait.callId === callId) {
30952
31168
  interactionId = candidate;
@@ -30969,7 +31185,7 @@ var ModernHarnessSession = class {
30969
31185
  this.#closeInteraction(interactionId, outcome === "answered" ? "superseded" : "cancelled");
30970
31186
  }
30971
31187
  }
30972
- #publishInteraction(delivery, active) {
31188
+ #publishInteraction(delivery, active2) {
30973
31189
  const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
30974
31190
  if (this.#usedInteractionIds.has(interactionId)) {
30975
31191
  throw new ModernEventGatewayError("protocolError", "DeepSeek Harness Host interaction identity was duplicated");
@@ -30979,7 +31195,7 @@ var ModernHarnessSession = class {
30979
31195
  interaction = {
30980
31196
  type: "approval",
30981
31197
  interactionId,
30982
- turnId: active.turnId,
31198
+ turnId: active2.turnId,
30983
31199
  title: delivery.request.displayReason?.en ?? delivery.request.reason ?? `Allow ${delivery.request.toolName}?`,
30984
31200
  description: delivery.request.callId ? `${delivery.request.toolName} (${delivery.request.callId})` : delivery.request.toolName,
30985
31201
  subject: { type: "nativeAction" },
@@ -30996,7 +31212,7 @@ var ModernHarnessSession = class {
30996
31212
  interaction = {
30997
31213
  type: "question",
30998
31214
  interactionId,
30999
- turnId: active.turnId,
31215
+ turnId: active2.turnId,
31000
31216
  title: first.header ?? "DeepSeek Harness question",
31001
31217
  questions: delivery.request.questions.map((question) => {
31002
31218
  const prompt = question.detail ? `${question.question}
@@ -31029,12 +31245,12 @@ ${question.detail}` : question.question;
31029
31245
  this.#usedInteractionIds.add(interactionId);
31030
31246
  this.#interactions.set(interactionId, { delivery, interaction, responding: false });
31031
31247
  this.#interactionByEventId.set(delivery.eventId, interactionId);
31032
- active.interactions.add(interactionId);
31248
+ active2.interactions.add(interactionId);
31033
31249
  this.#channel.emit({ kind: "interaction", interaction });
31034
31250
  }
31035
- #publishQueuedInteractions(active) {
31251
+ #publishQueuedInteractions(active2) {
31036
31252
  for (const delivery of [...this.#queuedDeliveries.values()]) {
31037
- this.#publishInteraction(delivery, active);
31253
+ this.#publishInteraction(delivery, active2);
31038
31254
  }
31039
31255
  }
31040
31256
  #closeInteraction(interactionId, reason) {
@@ -31054,8 +31270,8 @@ ${question.detail}` : question.question;
31054
31270
  reason
31055
31271
  });
31056
31272
  }
31057
- #closeActiveInteractions(active) {
31058
- for (const interactionId of [...active.interactions]) {
31273
+ #closeActiveInteractions(active2) {
31274
+ for (const interactionId of [...active2.interactions]) {
31059
31275
  const pending = this.#interactions.get(interactionId);
31060
31276
  if (pending?.continuation) {
31061
31277
  this.#closeInteraction(interactionId, "expired");
@@ -31385,7 +31601,7 @@ ${question.detail}` : question.question;
31385
31601
  if (admission.cancellationRequested) {
31386
31602
  return { ok: false, error: invalidState2("DeepSeek Harness command was cancelled") };
31387
31603
  }
31388
- if (!catalog.value.commands.some(({ id }) => id === parsed.value.commandId)) {
31604
+ if (!catalog.value.commands.some(({ id: id2 }) => id2 === parsed.value.commandId)) {
31389
31605
  return {
31390
31606
  ok: false,
31391
31607
  error: {
@@ -31400,19 +31616,19 @@ ${question.detail}` : question.question;
31400
31616
  }
31401
31617
  const itemId = modernItemId(this.#sessionId, `host-command:${command.turnId}`);
31402
31618
  const item = parsed.value.commandId === "dsh.compact" ? { type: "contextCompaction", itemId } : { type: "commandExecution", itemId, command: parsed.value.line };
31403
- const active = {
31619
+ const active2 = {
31404
31620
  command,
31405
31621
  line: parsed.value.line,
31406
31622
  abort: new AbortController(),
31407
31623
  item,
31408
31624
  cancellationRequested: false
31409
31625
  };
31410
- this.#activeCommand = active;
31626
+ this.#activeCommand = active2;
31411
31627
  this.#acceptedTurnIds.add(command.turnId);
31412
- this.#operationControllers.add(active.abort);
31628
+ this.#operationControllers.add(active2.abort);
31413
31629
  this.#emit({ type: "turn.started", turnId: command.turnId });
31414
31630
  this.#emit({ type: "item.started", turnId: command.turnId, item });
31415
- void this.#runHarnessCommand(active);
31631
+ void this.#runHarnessCommand(active2);
31416
31632
  return { ok: true, value: { turnId: command.turnId } };
31417
31633
  } finally {
31418
31634
  this.#operationControllers.delete(admission.abort);
@@ -31424,66 +31640,66 @@ ${question.detail}` : question.question;
31424
31640
  #hasCommandConflict(ignoreOwnOperation = false) {
31425
31641
  return Boolean(this.#active || this.#buffer || this.#pendingByRequestId.size > 0 || this.#activeCommand || !ignoreOwnOperation && this.#commandAdmission || this.#queuedDeliveries.size > 0 || this.#configuring || this.#reading);
31426
31642
  }
31427
- async #runHarnessCommand(active) {
31643
+ async #runHarnessCommand(active2) {
31428
31644
  try {
31429
- const execution = await executeModernCommand(this.#remote, this.#sessionId, active.line, active.abort.signal);
31430
- if (this.#activeCommand !== active)
31645
+ const execution = await executeModernCommand(this.#remote, this.#sessionId, active2.line, active2.abort.signal);
31646
+ if (this.#activeCommand !== active2)
31431
31647
  return;
31432
31648
  if (!execution) {
31433
- this.#finishCommand(active, {
31649
+ this.#finishCommand(active2, {
31434
31650
  status: "failed",
31435
31651
  error: {
31436
31652
  code: "nativeFailure",
31437
- message: `DeepSeek Harness did not resolve registered command '${active.command.commandId}'`,
31653
+ message: `DeepSeek Harness did not resolve registered command '${active2.command.commandId}'`,
31438
31654
  retryable: false
31439
31655
  }
31440
31656
  });
31441
31657
  return;
31442
31658
  }
31443
31659
  if (execution.result.kind === "success") {
31444
- this.#finishCommand(active, { status: "succeeded" }, execution.result.text);
31445
- } else if (active.cancellationRequested || active.command.commandId === "dsh.compact" && execution.result.text === DSH_COMPACT_CANCELLED) {
31446
- this.#finishCommand(active, { status: "cancelled", reason: execution.result.text }, execution.result.text);
31660
+ this.#finishCommand(active2, { status: "succeeded" }, execution.result.text);
31661
+ } else if (active2.cancellationRequested || active2.command.commandId === "dsh.compact" && execution.result.text === DSH_COMPACT_CANCELLED) {
31662
+ this.#finishCommand(active2, { status: "cancelled", reason: execution.result.text }, execution.result.text);
31447
31663
  } else {
31448
- this.#finishCommand(active, {
31664
+ this.#finishCommand(active2, {
31449
31665
  status: "failed",
31450
31666
  error: {
31451
- code: active.command.commandId === "dsh.compact" && execution.result.text === DSH_COMPACT_BUSY ? "sessionBusy" : "nativeFailure",
31667
+ code: active2.command.commandId === "dsh.compact" && execution.result.text === DSH_COMPACT_BUSY ? "sessionBusy" : "nativeFailure",
31452
31668
  message: execution.result.text,
31453
31669
  retryable: true
31454
31670
  }
31455
31671
  }, execution.result.text);
31456
31672
  }
31457
31673
  } catch (error51) {
31458
- if (this.#activeCommand !== active)
31674
+ if (this.#activeCommand !== active2)
31459
31675
  return;
31460
- if (active.cancellationRequested || active.abort.signal.aborted) {
31461
- this.#finishCommand(active, {
31676
+ if (active2.cancellationRequested || active2.abort.signal.aborted) {
31677
+ this.#finishCommand(active2, {
31462
31678
  status: "cancelled",
31463
- reason: active.command.commandId === "dsh.compact" ? "DeepSeek Harness context compaction was cancelled" : "DeepSeek Harness command was cancelled"
31679
+ reason: active2.command.commandId === "dsh.compact" ? "DeepSeek Harness context compaction was cancelled" : "DeepSeek Harness command was cancelled"
31464
31680
  });
31465
31681
  } else {
31466
31682
  const failure = commandHarnessError(error51);
31467
31683
  if (commandFailureRequiresSessionFault(error51))
31468
31684
  this.#fault(failure);
31469
31685
  else
31470
- this.#finishCommand(active, { status: "failed", error: failure });
31686
+ this.#finishCommand(active2, { status: "failed", error: failure });
31471
31687
  }
31472
31688
  } finally {
31473
- this.#operationControllers.delete(active.abort);
31689
+ this.#operationControllers.delete(active2.abort);
31474
31690
  }
31475
31691
  }
31476
- #finishCommand(active, outcome, output) {
31477
- if (this.#activeCommand !== active)
31692
+ #finishCommand(active2, outcome, output) {
31693
+ if (this.#activeCommand !== active2)
31478
31694
  return;
31479
31695
  this.#activeCommand = void 0;
31480
- const item = active.item.type === "commandExecution" && output !== void 0 ? { ...active.item, output } : active.item;
31696
+ const item = active2.item.type === "commandExecution" && output !== void 0 ? { ...active2.item, output } : active2.item;
31481
31697
  this.#emit({
31482
31698
  type: "item.completed",
31483
- turnId: active.command.turnId,
31699
+ turnId: active2.command.turnId,
31484
31700
  snapshot: { item, outcome }
31485
31701
  });
31486
- this.#emit({ type: "turn.completed", turnId: active.command.turnId, outcome });
31702
+ this.#emit({ type: "turn.completed", turnId: active2.command.turnId, outcome });
31487
31703
  this.#activateBufferedAutonomous();
31488
31704
  }
31489
31705
  #cancel(command) {
@@ -31503,23 +31719,23 @@ ${question.detail}` : question.question;
31503
31719
  }
31504
31720
  return Promise.resolve({ ok: true, value: { cancellationRequested: true } });
31505
31721
  }
31506
- const active = this.#active;
31507
- if (!active || active.terminal || active.turnId !== command.turnId) {
31722
+ const active2 = this.#active;
31723
+ if (!active2 || active2.terminal || active2.turnId !== command.turnId) {
31508
31724
  return Promise.resolve({
31509
31725
  ok: false,
31510
31726
  error: invalidState2("DeepSeek Harness cancel requires the active Turn")
31511
31727
  });
31512
31728
  }
31513
- if (active.cancelAcknowledged) {
31729
+ if (active2.cancelAcknowledged) {
31514
31730
  return Promise.resolve({ ok: true, value: { cancellationRequested: true } });
31515
31731
  }
31516
- if (active.cancelPromise)
31517
- return active.cancelPromise;
31518
- const operation = this.#requestNativeCancel(active);
31519
- active.cancelPromise = operation;
31732
+ if (active2.cancelPromise)
31733
+ return active2.cancelPromise;
31734
+ const operation = this.#requestNativeCancel(active2);
31735
+ active2.cancelPromise = operation;
31520
31736
  return operation;
31521
31737
  }
31522
- #requestNativeCancel(active) {
31738
+ #requestNativeCancel(active2) {
31523
31739
  const abort = new AbortController();
31524
31740
  this.#operationControllers.add(abort);
31525
31741
  const operation = (async () => {
@@ -31537,8 +31753,8 @@ ${question.detail}` : question.question;
31537
31753
  this.#fault(error51);
31538
31754
  return { ok: false, error: error51 };
31539
31755
  }
31540
- if (active)
31541
- active.cancelAcknowledged = true;
31756
+ if (active2)
31757
+ active2.cancelAcknowledged = true;
31542
31758
  return { ok: true, value: { cancellationRequested: true } };
31543
31759
  } catch (error51) {
31544
31760
  return {
@@ -31547,8 +31763,8 @@ ${question.detail}` : question.question;
31547
31763
  };
31548
31764
  } finally {
31549
31765
  this.#operationControllers.delete(abort);
31550
- if (active && !active.cancelAcknowledged)
31551
- delete active.cancelPromise;
31766
+ if (active2 && !active2.cancelAcknowledged)
31767
+ delete active2.cancelPromise;
31552
31768
  }
31553
31769
  })();
31554
31770
  return operation;
@@ -31713,46 +31929,46 @@ ${question.detail}` : question.question;
31713
31929
  }
31714
31930
  #discardAssistantAttempt() {
31715
31931
  const attempt = this.#assistantAttempt;
31716
- const active = this.#active;
31717
- if (attempt && !attempt.projected && active?.nativeTurn === attempt.turn && active.agent) {
31718
- this.#cancelAgentItem(active);
31932
+ const active2 = this.#active;
31933
+ if (attempt && !attempt.projected && active2?.nativeTurn === attempt.turn && active2.agent) {
31934
+ this.#cancelAgentItem(active2);
31719
31935
  }
31720
- if (attempt && active?.reasoning?.attemptId === attempt.attemptId) {
31721
- this.#cancelReasoningItem(active);
31936
+ if (attempt && active2?.reasoning?.attemptId === attempt.attemptId) {
31937
+ this.#cancelReasoningItem(active2);
31722
31938
  }
31723
31939
  this.#assistantAttempt = void 0;
31724
31940
  }
31725
- #cancelAgentItem(active) {
31726
- const agent = active.agent;
31941
+ #cancelAgentItem(active2) {
31942
+ const agent = active2.agent;
31727
31943
  if (!agent)
31728
31944
  return;
31729
- this.#flushAgent(active, agent);
31945
+ this.#flushAgent(active2, agent);
31730
31946
  agent.item = { ...agent.item, text: agent.item.text + CANCELLED_ASSISTANT_ATTEMPT_SUFFIX };
31731
31947
  this.#emit({
31732
31948
  type: "item.updated",
31733
- turnId: active.turnId,
31949
+ turnId: active2.turnId,
31734
31950
  itemId: agent.item.itemId,
31735
31951
  update: { type: "text.append", text: CANCELLED_ASSISTANT_ATTEMPT_SUFFIX }
31736
31952
  });
31737
- delete active.agent;
31738
- this.#completeItem(active, agent.item, { status: "cancelled" });
31953
+ delete active2.agent;
31954
+ this.#completeItem(active2, agent.item, { status: "cancelled" });
31739
31955
  }
31740
- #cancelReasoningItem(active) {
31741
- const reasoning2 = active.reasoning;
31956
+ #cancelReasoningItem(active2) {
31957
+ const reasoning2 = active2.reasoning;
31742
31958
  if (!reasoning2)
31743
31959
  return;
31744
- delete active.reasoning;
31745
- this.#completeItem(active, reasoning2.item, { status: "cancelled" });
31960
+ delete active2.reasoning;
31961
+ this.#completeItem(active2, reasoning2.item, { status: "cancelled" });
31746
31962
  }
31747
31963
  #projectAssistantLiveChunks() {
31748
31964
  const attempt = this.#assistantAttempt;
31749
- const active = this.#active;
31750
- if (!attempt || attempt.projected || !active || active.terminal || active.nativeTurn !== attempt.turn)
31965
+ const active2 = this.#active;
31966
+ if (!attempt || attempt.projected || !active2 || active2.terminal || active2.nativeTurn !== attempt.turn)
31751
31967
  return;
31752
31968
  while (attempt.projectedChunks < attempt.chunks.length) {
31753
31969
  const frame = attempt.chunks[attempt.projectedChunks++];
31754
31970
  if (frame)
31755
- this.#projectAssistantChunk(active, frame.chunk, attempt.step, false, attempt.attemptId);
31971
+ this.#projectAssistantChunk(active2, frame.chunk, attempt.step, false, attempt.attemptId);
31756
31972
  }
31757
31973
  }
31758
31974
  #matchesDurableAssistantSettlement(attempt, outcome) {
@@ -31769,7 +31985,7 @@ ${question.detail}` : question.question;
31769
31985
  }
31770
31986
  attempt.settlement = { eventType: event.type, seq: event.seq };
31771
31987
  }
31772
- #projectAssistantSettlement(active, event, initialReplay) {
31988
+ #projectAssistantSettlement(active2, event, initialReplay) {
31773
31989
  const attempt = this.#assistantAttempt;
31774
31990
  if (!attempt || attempt.settlement?.seq !== event.seq || attempt.projected)
31775
31991
  return;
@@ -31777,8 +31993,8 @@ ${question.detail}` : question.question;
31777
31993
  if (!initialReplay)
31778
31994
  this.#projectAssistantLiveChunks();
31779
31995
  } else {
31780
- this.#cancelAgentItem(active);
31781
- this.#cancelReasoningItem(active);
31996
+ this.#cancelAgentItem(active2);
31997
+ this.#cancelReasoningItem(active2);
31782
31998
  }
31783
31999
  attempt.projected = true;
31784
32000
  if (attempt.ended)
@@ -32008,7 +32224,7 @@ ${question.detail}` : question.question;
32008
32224
  if (buffer.active || this.#active) {
32009
32225
  throw new ModernHistoryError("protocolError", "Modern Host Turns overlap");
32010
32226
  }
32011
- const active = {
32227
+ const active2 = {
32012
32228
  turnId,
32013
32229
  nativeTurn: buffer.nativeTurn,
32014
32230
  input: [...input],
@@ -32021,8 +32237,8 @@ ${question.detail}` : question.question;
32021
32237
  terminal: false,
32022
32238
  cancelAcknowledged: false
32023
32239
  };
32024
- buffer.active = active;
32025
- this.#active = active;
32240
+ buffer.active = active2;
32241
+ this.#active = active2;
32026
32242
  this.#flush(buffer, initialReplay);
32027
32243
  }
32028
32244
  #flush(buffer, initialReplay) {
@@ -32035,152 +32251,152 @@ ${question.detail}` : question.question;
32035
32251
  this.#projectAssistantLiveChunks();
32036
32252
  }
32037
32253
  #projectLiveEvent(buffer, event, initialReplay) {
32038
- const active = buffer.active;
32039
- if (!active || !isRecord4(event.data))
32254
+ const active2 = buffer.active;
32255
+ if (!active2 || !isRecord4(event.data))
32040
32256
  return;
32041
32257
  const data = event.data;
32042
32258
  switch (event.type) {
32043
32259
  case "turn/start":
32044
- this.#emit({ type: "turn.started", turnId: active.turnId });
32045
- this.#publishQueuedInteractions(active);
32260
+ this.#emit({ type: "turn.started", turnId: active2.turnId });
32261
+ this.#publishQueuedInteractions(active2);
32046
32262
  return;
32047
32263
  case "request/header":
32048
32264
  case "request/context":
32049
32265
  case "model/selection":
32050
32266
  return;
32051
32267
  case "compaction/start": {
32052
- if (data.turn !== active.nativeTurn || data.sourceCommandId !== void 0)
32268
+ if (data.turn !== active2.nativeTurn || data.sourceCommandId !== void 0)
32053
32269
  return;
32054
- if (active.compaction)
32270
+ if (active2.compaction)
32055
32271
  throw new ModernHistoryError("protocolError", "Modern compactions overlap");
32056
32272
  const nativeId = data.compactionId;
32057
32273
  const item = {
32058
32274
  type: "contextCompaction",
32059
32275
  itemId: modernItemId(this.#sessionId, `compaction:${nativeId}`)
32060
32276
  };
32061
- active.compaction = { nativeId, item };
32062
- this.#emit({ type: "item.started", turnId: active.turnId, item });
32277
+ active2.compaction = { nativeId, item };
32278
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
32063
32279
  return;
32064
32280
  }
32065
32281
  case "compaction/end": {
32066
- if (data.turn !== active.nativeTurn || data.sourceCommandId !== void 0)
32282
+ if (data.turn !== active2.nativeTurn || data.sourceCommandId !== void 0)
32067
32283
  return;
32068
- if (!active.compaction || active.compaction.nativeId !== data.compactionId) {
32284
+ if (!active2.compaction || active2.compaction.nativeId !== data.compactionId) {
32069
32285
  throw new ModernHistoryError("protocolError", "Modern compaction ended without its start");
32070
32286
  }
32071
- const { item } = active.compaction;
32072
- delete active.compaction;
32073
- this.#completeItem(active, item, modernCompactionOutcome(data));
32287
+ const { item } = active2.compaction;
32288
+ delete active2.compaction;
32289
+ this.#completeItem(active2, item, modernCompactionOutcome(data));
32074
32290
  if (!initialReplay)
32075
- this.#publishUsageChanges(active.turnId);
32291
+ this.#publishUsageChanges(active2.turnId);
32076
32292
  return;
32077
32293
  }
32078
32294
  case "assistant/message":
32079
- this.#projectAssistantSettlement(active, event, initialReplay);
32295
+ this.#projectAssistantSettlement(active2, event, initialReplay);
32080
32296
  if (event.surfaceOp === "append")
32081
- this.#completeAssistant(active, data);
32297
+ this.#completeAssistant(active2, data);
32082
32298
  if (event.surfaceOp === "append" && data.usage !== void 0 && !initialReplay) {
32083
- this.#publishUsageChanges(active.turnId);
32299
+ this.#publishUsageChanges(active2.turnId);
32084
32300
  }
32085
32301
  return;
32086
32302
  case "assistant/attempt":
32087
- this.#projectAssistantSettlement(active, event, initialReplay);
32303
+ this.#projectAssistantSettlement(active2, event, initialReplay);
32088
32304
  if (!initialReplay)
32089
- this.#publishUsageChanges(active.turnId);
32305
+ this.#publishUsageChanges(active2.turnId);
32090
32306
  return;
32091
32307
  case "tool/call":
32092
- this.#startTool(active, data, event.seq);
32308
+ this.#startTool(active2, data, event.seq);
32093
32309
  return;
32094
32310
  case "tool/result":
32095
32311
  if (event.surfaceOp === "append") {
32096
- const callId = this.#completeTool(active, event);
32097
- this.#observeTimedQuestion(active, callId, () => toolResultQuestionOutcome(data));
32312
+ const callId = this.#completeTool(active2, event);
32313
+ this.#observeTimedQuestion(active2, callId, () => toolResultQuestionOutcome(data));
32098
32314
  }
32099
32315
  return;
32100
32316
  case "tool/ptc-dispatch-start":
32101
- this.#startPtcDispatch(active, data, event.seq, event.time);
32317
+ this.#startPtcDispatch(active2, data, event.seq, event.time);
32102
32318
  return;
32103
32319
  case "tool/ptc-dispatch":
32104
- this.#settlePtcDispatch(active, data, event.seq, event.time);
32320
+ this.#settlePtcDispatch(active2, data, event.seq, event.time);
32105
32321
  if (typeof data.subCallId === "string") {
32106
- this.#observeTimedQuestion(active, data.subCallId, () => ptcDispatchQuestionOutcome(data));
32322
+ this.#observeTimedQuestion(active2, data.subCallId, () => ptcDispatchQuestionOutcome(data));
32107
32323
  }
32108
32324
  return;
32109
32325
  case "step/end":
32110
- this.#cancelReasoningItem(active);
32326
+ this.#cancelReasoningItem(active2);
32111
32327
  return;
32112
32328
  case "turn/end":
32113
- this.#finishTurn(buffer, active, data.reason, event.seq);
32329
+ this.#finishTurn(buffer, active2, data.reason, event.seq);
32114
32330
  return;
32115
32331
  default:
32116
32332
  return;
32117
32333
  }
32118
32334
  }
32119
- #projectAssistantChunk(active, chunk, step, initialReplay, attemptId) {
32335
+ #projectAssistantChunk(active2, chunk, step, initialReplay, attemptId) {
32120
32336
  if (chunk.type === "text-delta") {
32121
- this.#appendAgent(active, chunk.text, step, attemptId);
32337
+ this.#appendAgent(active2, chunk.text, step, attemptId);
32122
32338
  } else if (chunk.type === "reasoning-delta") {
32123
- this.#appendReasoning(active, chunk.text, step, true, attemptId);
32339
+ this.#appendReasoning(active2, chunk.text, step, true, attemptId);
32124
32340
  } else if (chunk.type === "usage" && !initialReplay) {
32125
- this.#publishUsageChanges(active.turnId);
32341
+ this.#publishUsageChanges(active2.turnId);
32126
32342
  }
32127
32343
  }
32128
- #appendAgent(active, text, step, attemptId) {
32344
+ #appendAgent(active2, text, step, attemptId) {
32129
32345
  if (!text)
32130
32346
  return;
32131
- if (!active.agent) {
32347
+ if (!active2.agent) {
32132
32348
  const item = {
32133
32349
  type: "agentMessage",
32134
- itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${attemptId ? `attempt:${attemptId}:` : ""}assistant`),
32350
+ itemId: modernItemId(this.#sessionId, `turn:${active2.nativeTurn}:step:${step}:${attemptId ? `attempt:${attemptId}:` : ""}assistant`),
32135
32351
  text: ""
32136
32352
  };
32137
32353
  const buffer = this.#buffer;
32138
- const workingDirectory = buffer?.active === active ? buffer.workingDirectory : this.#workingDirectory;
32354
+ const workingDirectory = buffer?.active === active2 ? buffer.workingDirectory : this.#workingDirectory;
32139
32355
  const roots = modernMediaRoots(workingDirectory, this.#sessionDirectory);
32140
- active.agent = { item, text: "", media: new LocalMediaMarkdownStream(roots) };
32141
- this.#emit({ type: "item.started", turnId: active.turnId, item });
32356
+ active2.agent = { item, text: "", media: new LocalMediaMarkdownStream(roots) };
32357
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
32142
32358
  }
32143
- active.agent.text += text;
32144
- this.#publishAgent(active, active.agent, active.agent.media.append(text));
32359
+ active2.agent.text += text;
32360
+ this.#publishAgent(active2, active2.agent, active2.agent.media.append(text));
32145
32361
  }
32146
32362
  /** Publish text the media projection held for a trailing construct before the Item ends. */
32147
- #flushAgent(active, agent) {
32148
- this.#publishAgent(active, agent, agent.media.flush());
32363
+ #flushAgent(active2, agent) {
32364
+ this.#publishAgent(active2, agent, agent.media.flush());
32149
32365
  }
32150
- #publishAgent(active, agent, delta) {
32366
+ #publishAgent(active2, agent, delta) {
32151
32367
  if (!delta)
32152
32368
  return;
32153
32369
  agent.item = { ...agent.item, text: agent.media.text };
32154
32370
  this.#emit({
32155
32371
  type: "item.updated",
32156
- turnId: active.turnId,
32372
+ turnId: active2.turnId,
32157
32373
  itemId: agent.item.itemId,
32158
32374
  update: { type: "text.append", text: delta }
32159
32375
  });
32160
32376
  }
32161
- #startReasoning(active, step, provisional, attemptId) {
32162
- if (!active.reasoning) {
32163
- const key = provisional ? `reasoning:provisional:${++active.reasoningOrdinal}` : "reasoning";
32377
+ #startReasoning(active2, step, provisional, attemptId) {
32378
+ if (!active2.reasoning) {
32379
+ const key = provisional ? `reasoning:provisional:${++active2.reasoningOrdinal}` : "reasoning";
32164
32380
  const item = {
32165
32381
  type: "reasoning",
32166
- itemId: modernItemId(this.#sessionId, `turn:${active.nativeTurn}:step:${step}:${key}`),
32382
+ itemId: modernItemId(this.#sessionId, `turn:${active2.nativeTurn}:step:${step}:${key}`),
32167
32383
  text: ""
32168
32384
  };
32169
- active.reasoning = {
32385
+ active2.reasoning = {
32170
32386
  item,
32171
32387
  text: "",
32172
32388
  provisional,
32173
32389
  pendingLineBreaks: "",
32174
32390
  ...attemptId ? { attemptId } : {}
32175
32391
  };
32176
- this.#emit({ type: "item.started", turnId: active.turnId, item });
32392
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
32177
32393
  }
32178
- return active.reasoning;
32394
+ return active2.reasoning;
32179
32395
  }
32180
- #appendReasoning(active, text, step, provisional = false, attemptId, final = false) {
32396
+ #appendReasoning(active2, text, step, provisional = false, attemptId, final = false) {
32181
32397
  if (!text)
32182
32398
  return;
32183
- const reasoning2 = this.#startReasoning(active, step, provisional, attemptId);
32399
+ const reasoning2 = this.#startReasoning(active2, step, provisional, attemptId);
32184
32400
  const candidate = final ? text : reasoning2.pendingLineBreaks + text;
32185
32401
  const appended = final ? candidate : candidate.replace(/[\r\n]+$/u, "");
32186
32402
  reasoning2.pendingLineBreaks = final ? "" : candidate.slice(appended.length);
@@ -32190,18 +32406,18 @@ ${question.detail}` : question.question;
32190
32406
  reasoning2.item = { ...reasoning2.item, text: reasoning2.text };
32191
32407
  this.#emit({
32192
32408
  type: "item.updated",
32193
- turnId: active.turnId,
32409
+ turnId: active2.turnId,
32194
32410
  itemId: reasoning2.item.itemId,
32195
32411
  update: { type: "text.append", text: appended }
32196
32412
  });
32197
32413
  }
32198
- #completeAssistant(active, data) {
32414
+ #completeAssistant(active2, data) {
32199
32415
  const message = data.message;
32200
32416
  const step = data.step;
32201
32417
  if (Array.isArray(message.content)) {
32202
32418
  for (const block of message.content) {
32203
32419
  if (isRecord4(block) && block.type === "tool-call" && typeof block.id === "string" && typeof block.name === "string" && typeof block.arguments === "string") {
32204
- active.advertisedTools.set(block.id, {
32420
+ active2.advertisedTools.set(block.id, {
32205
32421
  toolName: block.name,
32206
32422
  arguments: block.arguments
32207
32423
  });
@@ -32210,56 +32426,56 @@ ${question.detail}` : question.question;
32210
32426
  }
32211
32427
  const reasoning2 = contentText2(message.content, "reasoning");
32212
32428
  const text = contentText2(message.content, "text");
32213
- if (active.agent && !text.startsWith(active.agent.text))
32214
- this.#cancelAgentItem(active);
32215
- this.#completeReasoning(active, reasoning2, step);
32216
- this.#completeAgentPrefix(active, text, step);
32429
+ if (active2.agent && !text.startsWith(active2.agent.text))
32430
+ this.#cancelAgentItem(active2);
32431
+ this.#completeReasoning(active2, reasoning2, step);
32432
+ this.#completeAgentPrefix(active2, text, step);
32217
32433
  }
32218
- #completeReasoning(active, finalText, step) {
32219
- if (active.reasoning && !finalText.startsWith(active.reasoning.text)) {
32220
- this.#cancelReasoningItem(active);
32434
+ #completeReasoning(active2, finalText, step) {
32435
+ if (active2.reasoning && !finalText.startsWith(active2.reasoning.text)) {
32436
+ this.#cancelReasoningItem(active2);
32221
32437
  }
32222
- const suffix = finalText.slice(active.reasoning?.text.length ?? 0);
32438
+ const suffix = finalText.slice(active2.reasoning?.text.length ?? 0);
32223
32439
  if (suffix)
32224
- this.#appendReasoning(active, suffix, step, false, void 0, true);
32225
- const current = active.reasoning;
32440
+ this.#appendReasoning(active2, suffix, step, false, void 0, true);
32441
+ const current = active2.reasoning;
32226
32442
  if (!current)
32227
32443
  return;
32228
- delete active.reasoning;
32229
- this.#completeItem(active, current.item, { status: "succeeded" });
32444
+ delete active2.reasoning;
32445
+ this.#completeItem(active2, current.item, { status: "succeeded" });
32230
32446
  }
32231
- #completeAgentPrefix(active, finalText, step) {
32232
- let current = active.agent;
32447
+ #completeAgentPrefix(active2, finalText, step) {
32448
+ let current = active2.agent;
32233
32449
  if (!current && finalText) {
32234
- this.#appendAgent(active, finalText, step);
32235
- current = active.agent;
32450
+ this.#appendAgent(active2, finalText, step);
32451
+ current = active2.agent;
32236
32452
  } else if (current && finalText !== current.text) {
32237
32453
  if (!finalText.startsWith(current.text)) {
32238
32454
  throw new ModernHistoryError("protocolError", "Modern assistant message does not match its streamed prefix");
32239
32455
  }
32240
32456
  const suffix = finalText.slice(current.text.length);
32241
- this.#appendAgent(active, suffix, step);
32242
- current = active.agent;
32457
+ this.#appendAgent(active2, suffix, step);
32458
+ current = active2.agent;
32243
32459
  }
32244
32460
  if (!current)
32245
32461
  return;
32246
- this.#flushAgent(active, current);
32247
- delete active.agent;
32248
- this.#completeItem(active, current.item, { status: "succeeded" });
32462
+ this.#flushAgent(active2, current);
32463
+ delete active2.agent;
32464
+ this.#completeItem(active2, current.item, { status: "succeeded" });
32249
32465
  }
32250
- #startTool(active, data, seq) {
32466
+ #startTool(active2, data, seq) {
32251
32467
  const callId = data.callId;
32252
- if (active.tools.has(callId) || active.programCalls.has(callId)) {
32468
+ if (active2.tools.has(callId) || active2.programCalls.has(callId)) {
32253
32469
  throw new ModernHistoryError("protocolError", "Modern tool/call is duplicated");
32254
32470
  }
32255
- active.advertisedTools.delete(callId);
32471
+ active2.advertisedTools.delete(callId);
32256
32472
  if (isPtcProgramTool(data.name)) {
32257
- active.programCalls.add(callId);
32473
+ active2.programCalls.add(callId);
32258
32474
  return;
32259
32475
  }
32260
- this.#openTool(active, callId, seq, data.name, data.arguments);
32476
+ this.#openTool(active2, callId, seq, data.name, data.arguments);
32261
32477
  }
32262
- #openTool(active, callId, seq, toolName, rawArguments) {
32478
+ #openTool(active2, callId, seq, toolName, rawArguments) {
32263
32479
  const item = {
32264
32480
  type: "toolExecution",
32265
32481
  itemId: modernItemId(this.#sessionId, `event:${seq}:tool`),
@@ -32267,37 +32483,37 @@ ${question.detail}` : question.question;
32267
32483
  arguments: parseArguments(rawArguments)
32268
32484
  };
32269
32485
  const tool = { item, toolName, startedAtMs: this.#now() };
32270
- active.tools.set(callId, tool);
32271
- this.#emit({ type: "item.started", turnId: active.turnId, item });
32486
+ active2.tools.set(callId, tool);
32487
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
32272
32488
  return tool;
32273
32489
  }
32274
32490
  /** Complete the Tool Item of one appended native result and return its call. */
32275
- #completeTool(active, event) {
32491
+ #completeTool(active2, event) {
32276
32492
  const data = event.data;
32277
32493
  const seq = event.seq;
32278
32494
  const result = projectToolResult(data.message, this.#toolOutputLimit);
32279
32495
  if (!result)
32280
32496
  throw new ModernHistoryError("protocolError", "Modern tool/result is malformed");
32281
- const advertised = active.advertisedTools.get(result.callId);
32282
- active.advertisedTools.delete(result.callId);
32283
- if (active.programCalls.delete(result.callId))
32497
+ const advertised = active2.advertisedTools.get(result.callId);
32498
+ active2.advertisedTools.delete(result.callId);
32499
+ if (active2.programCalls.delete(result.callId))
32284
32500
  return result.callId;
32285
- let tool = active.tools.get(result.callId);
32501
+ let tool = active2.tools.get(result.callId);
32286
32502
  if (!tool && advertised && isNotStartedToolResult(data, event.sourceEventSeqs, seq)) {
32287
32503
  if (isPtcProgramTool(advertised.toolName))
32288
32504
  return result.callId;
32289
- tool = this.#openTool(active, result.callId, seq, advertised.toolName, advertised.arguments);
32505
+ tool = this.#openTool(active2, result.callId, seq, advertised.toolName, advertised.arguments);
32290
32506
  }
32291
32507
  if (!tool)
32292
32508
  throw new ModernHistoryError("protocolError", "Modern tool/result is unmatched");
32293
- active.tools.delete(result.callId);
32509
+ active2.tools.delete(result.callId);
32294
32510
  const item = {
32295
32511
  ...tool.item,
32296
32512
  ...result.output ? { output: result.output } : {},
32297
32513
  durationMs: Math.max(0, this.#now() - tool.startedAtMs)
32298
32514
  };
32299
32515
  const failed = result.failed || data.error !== void 0;
32300
- this.#completeItem(active, item, failed ? {
32516
+ this.#completeItem(active2, item, failed ? {
32301
32517
  status: "failed",
32302
32518
  error: {
32303
32519
  code: "nativeFailure",
@@ -32314,62 +32530,62 @@ ${question.detail}` : question.question;
32314
32530
  sourceItemIds: [item.itemId],
32315
32531
  changes
32316
32532
  };
32317
- this.#emit({ type: "item.started", turnId: active.turnId, item: fileItem });
32318
- this.#completeItem(active, fileItem, { status: "succeeded" });
32533
+ this.#emit({ type: "item.started", turnId: active2.turnId, item: fileItem });
32534
+ this.#completeItem(active2, fileItem, { status: "succeeded" });
32319
32535
  }
32320
32536
  }
32321
32537
  return result.callId;
32322
32538
  }
32323
- #startPtcDispatch(active, data, seq, time3) {
32539
+ #startPtcDispatch(active2, data, seq, time3) {
32324
32540
  const key = ptcDispatchKey(data);
32325
- if (active.tools.has(key)) {
32541
+ if (active2.tools.has(key)) {
32326
32542
  throw new ModernHistoryError("protocolError", "Modern PTC dispatch is duplicated");
32327
32543
  }
32328
32544
  const item = ptcDispatchItem(modernItemId(this.#sessionId, `event:${seq}:tool`), data);
32329
32545
  const tool = { item, toolName: item.toolName, startedAtMs: time3 };
32330
- active.tools.set(key, tool);
32331
- this.#emit({ type: "item.started", turnId: active.turnId, item });
32546
+ active2.tools.set(key, tool);
32547
+ this.#emit({ type: "item.started", turnId: active2.turnId, item });
32332
32548
  return tool;
32333
32549
  }
32334
- #settlePtcDispatch(active, data, seq, time3) {
32335
- const tool = active.tools.get(ptcDispatchKey(data)) ?? this.#startPtcDispatch(active, data, seq, time3);
32336
- active.tools.delete(ptcDispatchKey(data));
32550
+ #settlePtcDispatch(active2, data, seq, time3) {
32551
+ const tool = active2.tools.get(ptcDispatchKey(data)) ?? this.#startPtcDispatch(active2, data, seq, time3);
32552
+ active2.tools.delete(ptcDispatchKey(data));
32337
32553
  const output = ptcDispatchOutput(data, this.#toolOutputLimit);
32338
32554
  const item = {
32339
32555
  ...tool.item,
32340
32556
  ...output ? { output } : {},
32341
32557
  durationMs: Math.max(0, time3 - tool.startedAtMs)
32342
32558
  };
32343
- this.#completeItem(active, item, ptcDispatchOutcome(data, tool.toolName));
32559
+ this.#completeItem(active2, item, ptcDispatchOutcome(data, tool.toolName));
32344
32560
  }
32345
- #finishTurn(buffer, active, reason, seq) {
32346
- if (active.terminal)
32561
+ #finishTurn(buffer, active2, reason, seq) {
32562
+ if (active2.terminal)
32347
32563
  return;
32348
32564
  const projected = turnOutcome(reason);
32349
32565
  const itemOutcome2 = toItemOutcome(projected);
32350
32566
  this.#discardAssistantAttempt();
32351
- this.#cancelReasoningItem(active);
32352
- this.#closeActiveInteractions(active);
32353
- this.#completeOpenItems(active, itemOutcome2);
32354
- active.terminal = true;
32567
+ this.#cancelReasoningItem(active2);
32568
+ this.#closeActiveInteractions(active2);
32569
+ this.#completeOpenItems(active2, itemOutcome2);
32570
+ active2.terminal = true;
32355
32571
  if (buffer.pending)
32356
32572
  buffer.pending.terminal = true;
32357
32573
  this.#nativeCloseTerminal?.();
32358
32574
  const checkpoint = modernCheckpointRef(this.harnessId, this.#sessionId, seq, this.#profile);
32359
32575
  this.#emit({
32360
32576
  type: "turn.completed",
32361
- turnId: active.turnId,
32362
- nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active.nativeTurn),
32577
+ turnId: active2.turnId,
32578
+ nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active2.nativeTurn),
32363
32579
  outcome: { ...projected, checkpoint }
32364
32580
  });
32365
- if (this.#active === active)
32581
+ if (this.#active === active2)
32366
32582
  this.#active = void 0;
32367
32583
  if (this.#buffer === buffer)
32368
32584
  this.#buffer = void 0;
32369
32585
  }
32370
- #completeOpenItems(active, outcome) {
32371
- if (active.compaction) {
32372
- this.#completeItem(active, active.compaction.item, outcome.status === "succeeded" ? {
32586
+ #completeOpenItems(active2, outcome) {
32587
+ if (active2.compaction) {
32588
+ this.#completeItem(active2, active2.compaction.item, outcome.status === "succeeded" ? {
32373
32589
  status: "failed",
32374
32590
  error: {
32375
32591
  code: "nativeFailure",
@@ -32377,27 +32593,27 @@ ${question.detail}` : question.question;
32377
32593
  retryable: true
32378
32594
  }
32379
32595
  } : outcome);
32380
- delete active.compaction;
32596
+ delete active2.compaction;
32381
32597
  }
32382
- if (active.reasoning) {
32383
- const item = active.reasoning.item;
32384
- delete active.reasoning;
32385
- this.#completeItem(active, item, outcome);
32598
+ if (active2.reasoning) {
32599
+ const item = active2.reasoning.item;
32600
+ delete active2.reasoning;
32601
+ this.#completeItem(active2, item, outcome);
32386
32602
  }
32387
- if (active.agent) {
32388
- const agent = active.agent;
32389
- this.#flushAgent(active, agent);
32390
- delete active.agent;
32391
- this.#completeItem(active, agent.item, outcome);
32603
+ if (active2.agent) {
32604
+ const agent = active2.agent;
32605
+ this.#flushAgent(active2, agent);
32606
+ delete active2.agent;
32607
+ this.#completeItem(active2, agent.item, outcome);
32392
32608
  }
32393
- for (const tool of active.tools.values())
32394
- this.#completeItem(active, tool.item, outcome);
32395
- active.tools.clear();
32609
+ for (const tool of active2.tools.values())
32610
+ this.#completeItem(active2, tool.item, outcome);
32611
+ active2.tools.clear();
32396
32612
  }
32397
- #completeItem(active, item, outcome) {
32613
+ #completeItem(active2, item, outcome) {
32398
32614
  this.#emit({
32399
32615
  type: "item.completed",
32400
- turnId: active.turnId,
32616
+ turnId: active2.turnId,
32401
32617
  snapshot: { item, outcome }
32402
32618
  });
32403
32619
  }
@@ -32418,6 +32634,7 @@ ${question.detail}` : question.question;
32418
32634
  /** `media` also resolves local media paths, which only displayed history needs. */
32419
32635
  #project(media = false) {
32420
32636
  return projectModernHistory({
32637
+ modelIndex: this.#modelCatalog.index,
32421
32638
  harnessId: this.harnessId,
32422
32639
  sessionId: this.#sessionId,
32423
32640
  events: this.#events,
@@ -32461,9 +32678,9 @@ ${question.detail}` : question.question;
32461
32678
  async #performFault(failure, acceptedPending) {
32462
32679
  await this.#detachEvents().catch(() => void 0);
32463
32680
  this.#closeAllInteractions();
32464
- let active = this.#active;
32681
+ let active2 = this.#active;
32465
32682
  const buffer = this.#buffer;
32466
- if (!active && buffer) {
32683
+ if (!active2 && buffer) {
32467
32684
  const pending = buffer.pending;
32468
32685
  const hostBound = pending !== void 0 && (pending.admissionObserved || pending.observed || pending.admitted);
32469
32686
  const turnId = hostBound ? pending.command.turnId : hostTurnIdSchema.parse(this.#randomUUID());
@@ -32474,7 +32691,7 @@ ${question.detail}` : question.question;
32474
32691
  input: [...buffer.input]
32475
32692
  });
32476
32693
  }
32477
- active = {
32694
+ active2 = {
32478
32695
  turnId,
32479
32696
  nativeTurn: buffer.nativeTurn,
32480
32697
  input: hostBound ? [...pending.command.input] : [...buffer.input],
@@ -32487,19 +32704,19 @@ ${question.detail}` : question.question;
32487
32704
  terminal: false,
32488
32705
  cancelAcknowledged: false
32489
32706
  };
32490
- buffer.active = active;
32491
- this.#active = active;
32707
+ buffer.active = active2;
32708
+ this.#active = active2;
32492
32709
  this.#emit({ type: "turn.started", turnId });
32493
32710
  }
32494
- if (active && !active.terminal) {
32495
- this.#completeOpenItems(active, { status: "failed", error: failure });
32496
- active.terminal = true;
32497
- if (buffer?.pending?.command.turnId === active.turnId)
32711
+ if (active2 && !active2.terminal) {
32712
+ this.#completeOpenItems(active2, { status: "failed", error: failure });
32713
+ active2.terminal = true;
32714
+ if (buffer?.pending?.command.turnId === active2.turnId)
32498
32715
  buffer.pending.terminal = true;
32499
32716
  this.#emit({
32500
32717
  type: "turn.completed",
32501
- turnId: active.turnId,
32502
- nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active.nativeTurn),
32718
+ turnId: active2.turnId,
32719
+ nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active2.nativeTurn),
32503
32720
  outcome: { status: "failed", error: failure }
32504
32721
  });
32505
32722
  }
@@ -32581,21 +32798,21 @@ ${question.detail}` : question.question;
32581
32798
  this.#abortOperations();
32582
32799
  await this.#detachEvents().catch(() => void 0);
32583
32800
  this.#closeAllInteractions();
32584
- const active = this.#active;
32585
- if (active && !active.terminal) {
32801
+ const active2 = this.#active;
32802
+ if (active2 && !active2.terminal) {
32586
32803
  const outcome = {
32587
32804
  status: "cancelled",
32588
32805
  reason: "DeepSeek Harness Session closed"
32589
32806
  };
32590
- this.#completeOpenItems(active, outcome);
32591
- active.terminal = true;
32592
- if (this.#buffer?.pending?.command.turnId === active.turnId) {
32807
+ this.#completeOpenItems(active2, outcome);
32808
+ active2.terminal = true;
32809
+ if (this.#buffer?.pending?.command.turnId === active2.turnId) {
32593
32810
  this.#buffer.pending.terminal = true;
32594
32811
  }
32595
32812
  this.#emit({
32596
32813
  type: "turn.completed",
32597
- turnId: active.turnId,
32598
- nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active.nativeTurn),
32814
+ turnId: active2.turnId,
32815
+ nativeTurnRef: modernNativeTurnRef(this.harnessId, this.#sessionId, active2.nativeTurn),
32599
32816
  outcome
32600
32817
  });
32601
32818
  }
@@ -33187,6 +33404,12 @@ var DEFAULT_DEPENDENCIES2 = {
33187
33404
  createConnection: (options) => new ModernRemoteConnection(options)
33188
33405
  };
33189
33406
  var ModernDeepSeekHarnessAdapter = class {
33407
+ normalizeStoredModelRef = (ref, catalog) => {
33408
+ const snapshot = this.#catalog;
33409
+ if (snapshot && isDeepStrictEqual7(snapshot.catalog, catalog)) {
33410
+ return normalizeStoredDeepSeekModelRef(ref, snapshot.index);
33411
+ }
33412
+ };
33190
33413
  commandCatalog = deepSeekHarnessCommandCatalog();
33191
33414
  harnessId = DEEPSEEK_HARNESS_ID3;
33192
33415
  sessionImport = Object.freeze({
@@ -33355,7 +33578,7 @@ var ModernDeepSeekHarnessAdapter = class {
33355
33578
  }
33356
33579
  this.#assertAccepting();
33357
33580
  if (rollbackSourceSessionId) {
33358
- rollbackPlan = await this.#resolveLastTurnRollback(rollbackSourceSessionId, cwd);
33581
+ rollbackPlan = await this.#resolveLastTurnRollback(rollbackSourceSessionId, cwd, catalog);
33359
33582
  if (rollbackPlan.kind === "fork") {
33360
33583
  forkInput = rollbackPlan.input;
33361
33584
  } else {
@@ -33374,7 +33597,7 @@ var ModernDeepSeekHarnessAdapter = class {
33374
33597
  this.#assertAccepting();
33375
33598
  }
33376
33599
  if (forkInput) {
33377
- forkExpectation = await this.#forkSession(forkInput, cwd);
33600
+ forkExpectation = await this.#forkSession(forkInput, cwd, catalog);
33378
33601
  sessionId = forkExpectation.childSessionId;
33379
33602
  if (this.#sessionIds.has(sessionId)) {
33380
33603
  throw forkProtocolError();
@@ -33403,11 +33626,11 @@ var ModernDeepSeekHarnessAdapter = class {
33403
33626
  journal = await openModernJournal(this.#connection, { sessionId, cwd }, this.#journalOptions());
33404
33627
  this.#assertAccepting();
33405
33628
  if (forkExpectation) {
33406
- await this.#verifyForkJournal(forkExpectation, journal, cwd);
33629
+ await this.#verifyForkJournal(forkExpectation, journal, cwd, catalog);
33407
33630
  if (await clearInheritedForkInbox(this.#connection, journal, this.#lifetime.signal)) {
33408
33631
  await journal.close();
33409
33632
  journal = await openModernJournal(this.#connection, { sessionId, cwd }, this.#journalOptions());
33410
- await this.#verifyForkJournal(forkExpectation, journal, cwd);
33633
+ await this.#verifyForkJournal(forkExpectation, journal, cwd, catalog);
33411
33634
  if (pendingForkInboxIds(journal).length !== 0)
33412
33635
  throw forkProtocolError();
33413
33636
  await this.#connection.flushSession(sessionId, this.#lifetime.signal);
@@ -33419,6 +33642,7 @@ var ModernDeepSeekHarnessAdapter = class {
33419
33642
  }
33420
33643
  if (rollbackPlan.kind === "create") {
33421
33644
  const replacement = projectModernHistory({
33645
+ modelIndex: catalog.index,
33422
33646
  harnessId: this.harnessId,
33423
33647
  sessionId,
33424
33648
  events: journal.events,
@@ -33541,10 +33765,11 @@ var ModernDeepSeekHarnessAdapter = class {
33541
33765
  });
33542
33766
  }
33543
33767
  }
33544
- async #resolveLastTurnRollback(sourceSessionId, cwd) {
33768
+ async #resolveLastTurnRollback(sourceSessionId, cwd, catalog) {
33545
33769
  const source = await openModernJournal(this.#connection, { sessionId: sourceSessionId, cwd }, this.#journalOptions());
33546
33770
  try {
33547
33771
  const projected = projectModernHistory({
33772
+ modelIndex: catalog.index,
33548
33773
  harnessId: this.harnessId,
33549
33774
  sessionId: sourceSessionId,
33550
33775
  events: source.events,
@@ -33586,7 +33811,7 @@ var ModernDeepSeekHarnessAdapter = class {
33586
33811
  await source.close();
33587
33812
  }
33588
33813
  }
33589
- async #forkSession(input, cwd) {
33814
+ async #forkSession(input, cwd, catalog) {
33590
33815
  const source = await openModernJournal(this.#connection, {
33591
33816
  sessionId: input.sourceSessionId,
33592
33817
  cwd
@@ -33598,6 +33823,7 @@ var ModernDeepSeekHarnessAdapter = class {
33598
33823
  if (!boundary)
33599
33824
  throw forkCheckpointError();
33600
33825
  const projected = projectModernHistory({
33826
+ modelIndex: catalog.index,
33601
33827
  harnessId: this.harnessId,
33602
33828
  sessionId: input.sourceSessionId,
33603
33829
  events: boundary.events,
@@ -33627,7 +33853,7 @@ var ModernDeepSeekHarnessAdapter = class {
33627
33853
  seedLength
33628
33854
  };
33629
33855
  }
33630
- async #verifyForkJournal(expected, child, cwd) {
33856
+ async #verifyForkJournal(expected, child, cwd, catalog) {
33631
33857
  const seedLength = child.inheritedEventCount;
33632
33858
  if (
33633
33859
  // DSH 0.2.2 writes ordinary Fork children without their source; the
@@ -33649,6 +33875,7 @@ var ModernDeepSeekHarnessAdapter = class {
33649
33875
  throw forkProtocolError();
33650
33876
  }
33651
33877
  const expectedProjection = projectModernHistory({
33878
+ modelIndex: catalog.index,
33652
33879
  harnessId: this.harnessId,
33653
33880
  sessionId: expected.sourceSessionId,
33654
33881
  events: inherited,
@@ -33657,6 +33884,7 @@ var ModernDeepSeekHarnessAdapter = class {
33657
33884
  ...this.#options.maxEvents === void 0 ? {} : { maxEvents: this.#options.maxEvents }
33658
33885
  });
33659
33886
  const childProjection = projectModernHistory({
33887
+ modelIndex: catalog.index,
33660
33888
  harnessId: this.harnessId,
33661
33889
  sessionId: expected.childSessionId,
33662
33890
  events: child.events,
@@ -33749,7 +33977,10 @@ var ModernDeepSeekHarnessAdapter = class {
33749
33977
  this.#lifetime.abort(new Error("DeepSeek Harness Adapter faulted"));
33750
33978
  for (const session of this.#sessions)
33751
33979
  session.fault(failure);
33752
- this.#closePromise ??= this.#performClose(failure);
33980
+ if (this.#closePromise)
33981
+ return;
33982
+ this.#closePromise = this.#performClose(failure);
33983
+ this.#closePromise.catch(() => void 0);
33753
33984
  }
33754
33985
  #sealEventFailure(error51) {
33755
33986
  if (this.#fault || this.#normalClose || this.#declaredEventFailure)
@@ -33869,7 +34100,7 @@ function resolveCreateConfiguration(input, modelCatalog, permissionModes) {
33869
34100
  }
33870
34101
  const unattended = input.executionPolicy === "unattended-full-access";
33871
34102
  const permissionModeId = input.permissionModeId ?? (unattended ? harnessPermissionModeIdSchema.parse(DELEGATION_PERMISSION_PRESET) : void 0);
33872
- if (permissionModeId && !permissionModes?.modes.some(({ id }) => id === permissionModeId)) {
34103
+ if (permissionModeId && !permissionModes?.modes.some(({ id: id2 }) => id2 === permissionModeId)) {
33873
34104
  throw new AdapterOperationError({
33874
34105
  code: permissionModes ? "invalidRequest" : "unsupported",
33875
34106
  message: unattended ? "DeepSeek Harness does not expose the required danger-full-access Permission Mode" : "DeepSeek Harness Permission Mode is unavailable",
@@ -34112,6 +34343,7 @@ var DelegateSelectionError = class extends Error {
34112
34343
  };
34113
34344
  var DeepSeekHarnessAdapter = class {
34114
34345
  commandCatalog = deepSeekHarnessCommandCatalog();
34346
+ normalizeStoredModelRef = (ref, catalog) => this.#delegate?.adapter.normalizeStoredModelRef?.(ref, catalog);
34115
34347
  harnessId = DEEPSEEK_HARNESS_ID4;
34116
34348
  usageStatistics;
34117
34349
  sessionImport = Object.freeze({
@@ -34254,7 +34486,7 @@ var DeepSeekHarnessAdapter = class {
34254
34486
  }
34255
34487
  this.#failure = void 0;
34256
34488
  const abort = new AbortController();
34257
- const selection2 = {};
34489
+ const selection3 = {};
34258
34490
  const promise2 = this.#performSelection(abort.signal).then(async (selected) => {
34259
34491
  if (this.#closed || abort.signal.aborted) {
34260
34492
  await this.#closeFailedCandidate(selected);
@@ -34269,11 +34501,11 @@ var DeepSeekHarnessAdapter = class {
34269
34501
  this.#failure = failure;
34270
34502
  throw new DelegateSelectionError(failure);
34271
34503
  }).finally(() => {
34272
- if (this.#selection === selection2)
34504
+ if (this.#selection === selection3)
34273
34505
  this.#selection = void 0;
34274
34506
  });
34275
- Object.assign(selection2, { abort, promise: promise2 });
34276
- this.#selection = selection2;
34507
+ Object.assign(selection3, { abort, promise: promise2 });
34508
+ this.#selection = selection3;
34277
34509
  return promise2;
34278
34510
  }
34279
34511
  async #performSelection(signal) {
@@ -34372,15 +34604,15 @@ var DeepSeekHarnessAdapter = class {
34372
34604
  this.#accountInspection.abort(new Error("DeepSeek Harness account inspection closed"));
34373
34605
  this.#balance.close();
34374
34606
  let cleanupFailed = false;
34375
- const selection2 = this.#selection;
34376
- selection2?.abort.abort(new Error("DeepSeek Harness generation selection closed"));
34607
+ const selection3 = this.#selection;
34608
+ selection3?.abort.abort(new Error("DeepSeek Harness generation selection closed"));
34377
34609
  const candidate = this.#candidate;
34378
34610
  if (candidate) {
34379
34611
  await this.#closeOwner(candidate).catch(() => {
34380
34612
  cleanupFailed = true;
34381
34613
  });
34382
34614
  }
34383
- await selection2?.promise.catch(() => void 0);
34615
+ await selection3?.promise.catch(() => void 0);
34384
34616
  const lateCandidate = this.#candidate;
34385
34617
  if (lateCandidate && lateCandidate !== candidate) {
34386
34618
  await this.#closeOwner(lateCandidate).catch(() => {