@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
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
32
32
  return [""];
33
33
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
34
34
  }
35
- function isExecutableFile(filePath, platform) {
35
+ function isExecutableFile(filePath2, platform) {
36
36
  try {
37
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
- return fs.statSync(filePath).isFile();
37
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath2).isFile();
39
39
  } catch {
40
40
  return false;
41
41
  }
@@ -1745,8 +1745,8 @@ function cleanEnum(obj) {
1745
1745
  return Number.isNaN(Number.parseInt(k, 10));
1746
1746
  }).map((el) => el[1]);
1747
1747
  }
1748
- function base64ToUint8Array(base643) {
1749
- const binaryString = atob(base643);
1748
+ function base64ToUint8Array(base644) {
1749
+ const binaryString = atob(base644);
1750
1750
  const bytes = new Uint8Array(binaryString.length);
1751
1751
  for (let i = 0; i < binaryString.length; i++) {
1752
1752
  bytes[i] = binaryString.charCodeAt(i);
@@ -1761,9 +1761,9 @@ function uint8ArrayToBase64(bytes) {
1761
1761
  return btoa(binaryString);
1762
1762
  }
1763
1763
  function base64urlToUint8Array(base64url3) {
1764
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1765
- const padding = "=".repeat((4 - base643.length % 4) % 4);
1766
- return base64ToUint8Array(base643 + padding);
1764
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1765
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
1766
+ return base64ToUint8Array(base644 + padding);
1767
1767
  }
1768
1768
  function uint8ArrayToBase64url(bytes) {
1769
1769
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -3129,8 +3129,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
3129
3129
  function isValidBase64URL(data) {
3130
3130
  if (!base64url.test(data))
3131
3131
  return false;
3132
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3133
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
3132
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3133
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
3134
3134
  return isValidBase64(padded);
3135
3135
  }
3136
3136
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -3584,42 +3584,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3584
3584
  }
3585
3585
  doc.write(`const newResult = {};`);
3586
3586
  for (const key of normalized.keys) {
3587
- const id = ids[key];
3587
+ const id2 = ids[key];
3588
3588
  const k = esc(key);
3589
3589
  const schema = shape[key];
3590
3590
  const isOptionalIn = schema?._zod?.optin === "optional";
3591
3591
  const isOptionalOut = schema?._zod?.optout === "optional";
3592
- doc.write(`const ${id} = ${parseStr(key)};`);
3592
+ doc.write(`const ${id2} = ${parseStr(key)};`);
3593
3593
  if (isOptionalIn && isOptionalOut) {
3594
3594
  doc.write(`
3595
- if (${id}.issues.length) {
3595
+ if (${id2}.issues.length) {
3596
3596
  if (${k} in input) {
3597
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3597
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3598
3598
  ...iss,
3599
3599
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3600
3600
  })));
3601
3601
  }
3602
3602
  }
3603
3603
 
3604
- if (${id}.value === undefined) {
3604
+ if (${id2}.value === undefined) {
3605
3605
  if (${k} in input) {
3606
3606
  newResult[${k}] = undefined;
3607
3607
  }
3608
3608
  } else {
3609
- newResult[${k}] = ${id}.value;
3609
+ newResult[${k}] = ${id2}.value;
3610
3610
  }
3611
3611
 
3612
3612
  `);
3613
3613
  } else if (!isOptionalIn) {
3614
3614
  doc.write(`
3615
- const ${id}_present = ${k} in input;
3616
- if (${id}.issues.length) {
3617
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3615
+ const ${id2}_present = ${k} in input;
3616
+ if (${id2}.issues.length) {
3617
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3618
3618
  ...iss,
3619
3619
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3620
3620
  })));
3621
3621
  }
3622
- if (!${id}_present && !${id}.issues.length) {
3622
+ if (!${id2}_present && !${id2}.issues.length) {
3623
3623
  payload.issues.push({
3624
3624
  code: "invalid_type",
3625
3625
  expected: "nonoptional",
@@ -3628,30 +3628,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3628
3628
  });
3629
3629
  }
3630
3630
 
3631
- if (${id}_present) {
3632
- if (${id}.value === undefined) {
3631
+ if (${id2}_present) {
3632
+ if (${id2}.value === undefined) {
3633
3633
  newResult[${k}] = undefined;
3634
3634
  } else {
3635
- newResult[${k}] = ${id}.value;
3635
+ newResult[${k}] = ${id2}.value;
3636
3636
  }
3637
3637
  }
3638
3638
 
3639
3639
  `);
3640
3640
  } else {
3641
3641
  doc.write(`
3642
- if (${id}.issues.length) {
3643
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3642
+ if (${id2}.issues.length) {
3643
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3644
3644
  ...iss,
3645
3645
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3646
3646
  })));
3647
3647
  }
3648
3648
 
3649
- if (${id}.value === undefined) {
3649
+ if (${id2}.value === undefined) {
3650
3650
  if (${k} in input) {
3651
3651
  newResult[${k}] = undefined;
3652
3652
  }
3653
3653
  } else {
3654
- newResult[${k}] = ${id}.value;
3654
+ newResult[${k}] = ${id2}.value;
3655
3655
  }
3656
3656
 
3657
3657
  `);
@@ -11983,26 +11983,26 @@ function extractDefs(ctx, schema) {
11983
11983
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11984
11984
  const idToSchema = /* @__PURE__ */ new Map();
11985
11985
  for (const entry of ctx.seen.entries()) {
11986
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11987
- if (id) {
11988
- const existing = idToSchema.get(id);
11986
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11987
+ if (id2) {
11988
+ const existing = idToSchema.get(id2);
11989
11989
  if (existing && existing !== entry[0]) {
11990
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11990
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11991
11991
  }
11992
- idToSchema.set(id, entry[0]);
11992
+ idToSchema.set(id2, entry[0]);
11993
11993
  }
11994
11994
  }
11995
11995
  const makeURI = (entry) => {
11996
11996
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11997
11997
  if (ctx.external) {
11998
11998
  const externalId = ctx.external.registry.get(entry[0])?.id;
11999
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11999
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
12000
12000
  if (externalId) {
12001
12001
  return { ref: uriGenerator(externalId) };
12002
12002
  }
12003
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
12004
- entry[1].defId = id;
12005
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
12003
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
12004
+ entry[1].defId = id2;
12005
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
12006
12006
  }
12007
12007
  if (entry[1] === root) {
12008
12008
  return { ref: "#" };
@@ -12050,8 +12050,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12050
12050
  continue;
12051
12051
  }
12052
12052
  }
12053
- const id = ctx.metadataRegistry.get(entry[0])?.id;
12054
- if (id) {
12053
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
12054
+ if (id2) {
12055
12055
  extractToDef(entry);
12056
12056
  continue;
12057
12057
  }
@@ -12147,10 +12147,10 @@ function finalize(ctx, schema) {
12147
12147
  } else {
12148
12148
  }
12149
12149
  if (ctx.external?.uri) {
12150
- const id = ctx.external.registry.get(schema)?.id;
12151
- if (!id)
12150
+ const id2 = ctx.external.registry.get(schema)?.id;
12151
+ if (!id2)
12152
12152
  throw new Error("Schema is missing an `id` property");
12153
- result.$id = ctx.external.uri(id);
12153
+ result.$id = ctx.external.uri(id2);
12154
12154
  }
12155
12155
  Object.assign(result, root.def ?? root.schema);
12156
12156
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -12310,9 +12310,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12310
12310
  json2.type = "number";
12311
12311
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
12312
12312
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
12313
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12313
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12314
12314
  if (exMin) {
12315
- if (legacy) {
12315
+ if (legacy2) {
12316
12316
  json2.minimum = exclusiveMinimum;
12317
12317
  json2.exclusiveMinimum = true;
12318
12318
  } else {
@@ -12322,7 +12322,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12322
12322
  json2.minimum = minimum;
12323
12323
  }
12324
12324
  if (exMax) {
12325
- if (legacy) {
12325
+ if (legacy2) {
12326
12326
  json2.maximum = exclusiveMaximum;
12327
12327
  json2.exclusiveMaximum = true;
12328
12328
  } else {
@@ -13184,7 +13184,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
13184
13184
 
13185
13185
  // ../../../node_modules/zod/v4/classic/schemas.js
13186
13186
  var _installedGroups = /* @__PURE__ */ new WeakMap();
13187
- function _installLazyMethods(inst, group, methods2) {
13187
+ function _installLazyMethods(inst, group, methods3) {
13188
13188
  const proto = Object.getPrototypeOf(inst);
13189
13189
  let installed = _installedGroups.get(proto);
13190
13190
  if (!installed) {
@@ -13194,8 +13194,8 @@ function _installLazyMethods(inst, group, methods2) {
13194
13194
  if (installed.has(group))
13195
13195
  return;
13196
13196
  installed.add(group);
13197
- for (const key in methods2) {
13198
- const fn = methods2[key];
13197
+ for (const key in methods3) {
13198
+ const fn = methods3[key];
13199
13199
  Object.defineProperty(proto, key, {
13200
13200
  configurable: true,
13201
13201
  enumerable: false,
@@ -15006,87 +15006,6 @@ function date4(params) {
15006
15006
  // ../../../node_modules/zod/v4/classic/external.js
15007
15007
  config(en_default());
15008
15008
 
15009
- // ../../shared-contracts/dist/ids.js
15010
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15011
- message: "Identifier must not be empty or whitespace"
15012
- });
15013
- var harnessIdSchema = opaqueIdSchema.brand();
15014
- var hostThreadIdSchema = opaqueIdSchema.brand();
15015
- var hostTurnIdSchema = opaqueIdSchema.brand();
15016
- var hostItemIdSchema = opaqueIdSchema.brand();
15017
- var hostInteractionIdSchema = opaqueIdSchema.brand();
15018
-
15019
- // ../../shared-contracts/dist/harness-plugins.js
15020
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15021
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15022
- var HARNESS_PLUGIN_LIMIT = 128;
15023
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15024
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15025
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
15026
- 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");
15027
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15028
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15029
- var harnessInstallationGuideSchema = external_exports.object({
15030
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15031
- before: localizedTextSchema.optional(),
15032
- after: localizedTextSchema.optional(),
15033
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15034
- }).strict();
15035
- var pluginPresentationShape = {
15036
- id: installedHarnessPluginIdSchema,
15037
- name: external_exports.string().trim().min(1).max(128),
15038
- version: external_exports.string().min(1).max(128),
15039
- /** Capability-only plugin; omitted for existing session-capable plugins. */
15040
- kind: external_exports.literal("usage").optional(),
15041
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15042
- iconStyle: external_exports.object({
15043
- vector: external_exports.object({
15044
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15045
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15046
- paths: external_exports.array(external_exports.object({
15047
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15048
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15049
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15050
- }).strict()).min(1).max(32)
15051
- }).strict().optional(),
15052
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15053
- borderRadius: external_exports.number().min(0).max(50).optional(),
15054
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
15055
- }).strict().optional(),
15056
- installation: harnessInstallationGuideSchema.optional(),
15057
- notice: localizedTextSchema.optional(),
15058
- /** The factory accepts a persisted local entrypoint through its construction context. */
15059
- launchCommand: external_exports.literal(true).optional(),
15060
- links: external_exports.object({
15061
- website: documentationUrlSchema.optional(),
15062
- documentation: documentationUrlSchema.optional(),
15063
- installation: documentationUrlSchema.optional()
15064
- }).strict().optional()
15065
- };
15066
- var harnessPluginManifestSchema = external_exports.object({
15067
- manifestVersion: external_exports.literal(1),
15068
- ...pluginPresentationShape,
15069
- adapterApiVersion: external_exports.number().int().positive(),
15070
- entry: pluginRelativeResourceSchema,
15071
- icon: pluginRelativeResourceSchema.optional()
15072
- }).strict();
15073
- 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);
15074
- var harnessPluginDescriptorSchema = external_exports.object({
15075
- ...pluginPresentationShape,
15076
- icon: harnessPluginIconSchema.optional()
15077
- }).strict();
15078
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
15079
- var harnessPluginListResultSchema = external_exports.object({
15080
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15081
- }).strict();
15082
- var harnessPluginConfigurationSchema = external_exports.object({
15083
- version: external_exports.literal(1),
15084
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15085
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15086
- message: "Enabled plugin IDs must be unique",
15087
- path: ["enabled"]
15088
- });
15089
-
15090
15009
  // ../../shared-contracts/dist/json-value.js
15091
15010
  function rejectExplicitUndefined(keys) {
15092
15011
  return (value, context) => {
@@ -15146,403 +15065,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
15146
15065
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
15147
15066
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
15148
15067
 
15149
- // ../../shared-contracts/dist/desktop-extensions.js
15150
- var DESKTOP_EXTENSION_API_VERSION = 1;
15151
- var DESKTOP_EXTENSION_LIMIT = 64;
15152
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15153
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
15154
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15155
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15156
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15157
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15158
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15159
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15160
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15161
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15162
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15163
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15164
- var desktopExtensionIdSchema = installedPluginIdSchema;
15165
- var desktopExtensionSlotSchema = external_exports.enum([
15166
- "sidebar.thread-layout",
15167
- "sidebar.thread-badge",
15168
- "appearance.theme"
15169
- ]);
15170
- var desktopExtensionCategorySchema = external_exports.enum([
15171
- "appearance",
15172
- "interface",
15173
- "workflow",
15174
- "analytics",
15175
- "integrations",
15176
- "tools"
15177
- ]);
15178
- var extensionName = external_exports.string().trim().min(1).max(128);
15179
- function desktopExtensionScreenshotMimeType(resource) {
15180
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15181
- case "png":
15182
- return "image/png";
15183
- case "jpg":
15184
- case "jpeg":
15185
- return "image/jpeg";
15186
- case "webp":
15187
- return "image/webp";
15188
- default:
15189
- return void 0;
15068
+ // ../../shared-contracts/dist/errors.js
15069
+ var codexhostErrorSchema = external_exports.strictObject({
15070
+ code: external_exports.string().min(1),
15071
+ message: external_exports.string().min(1),
15072
+ retryable: external_exports.boolean(),
15073
+ diagnostic: external_exports.string().min(1).optional(),
15074
+ stage: external_exports.string().min(1).optional(),
15075
+ durationMs: external_exports.number().int().nonnegative().optional(),
15076
+ stderrTail: external_exports.string().min(1).optional()
15077
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
15078
+
15079
+ // ../../shared-contracts/dist/harness-presentation.js
15080
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
15081
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
15082
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
15083
+ label: displayText(256).optional(),
15084
+ description: displayText(1024).optional()
15085
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15086
+ 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");
15087
+
15088
+ // ../../shared-contracts/dist/ids.js
15089
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15090
+ message: "Identifier must not be empty or whitespace"
15091
+ });
15092
+ var harnessIdSchema = opaqueIdSchema.brand();
15093
+ var hostThreadIdSchema = opaqueIdSchema.brand();
15094
+ var hostTurnIdSchema = opaqueIdSchema.brand();
15095
+ var hostItemIdSchema = opaqueIdSchema.brand();
15096
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
15097
+
15098
+ // ../../shared-contracts/dist/harness-permission-modes.js
15099
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
15100
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
15101
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
15102
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
15103
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15104
+ message: "Value must not be empty or whitespace"
15105
+ });
15106
+ 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();
15107
+ var harnessPermissionModeSchema = external_exports.object({
15108
+ id: harnessPermissionModeIdSchema,
15109
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15110
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15111
+ dangerous: external_exports.boolean().optional(),
15112
+ localizations: harnessLocalizationsSchema.optional()
15113
+ }).strict();
15114
+ var harnessPermissionModeCatalogSchema = external_exports.object({
15115
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
15116
+ defaultModeId: harnessPermissionModeIdSchema
15117
+ }).strict().superRefine((catalog, context) => {
15118
+ const ids = /* @__PURE__ */ new Set();
15119
+ for (const [index, mode] of catalog.modes.entries()) {
15120
+ if (ids.has(mode.id)) {
15121
+ context.addIssue({
15122
+ code: "custom",
15123
+ message: "Permission Mode IDs must be unique",
15124
+ path: ["modes", index, "id"]
15125
+ });
15126
+ }
15127
+ ids.add(mode.id);
15190
15128
  }
15191
- }
15192
- function desktopExtensionAssetMimeType(resource) {
15193
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15194
- case "gif":
15195
- return "image/gif";
15196
- case "svg":
15197
- return "image/svg+xml";
15198
- case "woff2":
15199
- return "font/woff2";
15200
- case "json":
15201
- return "application/json";
15202
- case "css":
15203
- return "text/css";
15204
- default:
15205
- return desktopExtensionScreenshotMimeType(resource);
15206
- }
15207
- }
15208
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15209
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
15210
- 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");
15211
- 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) => {
15212
- const { username, password } = new URL(value);
15213
- return !username && !password && !/[\\\s]/u.test(value);
15214
- }, "URL must not contain credentials, backslashes, or whitespace");
15215
- function localizedText(text) {
15216
- return external_exports.strictObject({ en: text, "zh-CN": text });
15217
- }
15218
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15219
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15220
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15221
- var settingField = {
15222
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15223
- label: desktopExtensionLocalizedTextSchema,
15224
- description: desktopExtensionLocalizedTextSchema.optional()
15225
- };
15226
- var numericSetting = {
15227
- ...settingField,
15228
- step: external_exports.number().positive().optional(),
15229
- default: external_exports.number().optional()
15230
- };
15231
- var settingOption = external_exports.strictObject({
15232
- value: external_exports.string(),
15233
- label: desktopExtensionLocalizedTextSchema
15234
- });
15235
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15236
- external_exports.strictObject({
15237
- ...settingField,
15238
- type: external_exports.literal("boolean"),
15239
- default: external_exports.boolean().optional()
15240
- }),
15241
- external_exports.strictObject({
15242
- ...settingField,
15243
- type: external_exports.literal("string"),
15244
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
15245
- default: external_exports.string().optional()
15246
- }),
15247
- external_exports.strictObject({
15248
- ...numericSetting,
15249
- type: external_exports.literal("number"),
15250
- min: external_exports.number().optional(),
15251
- max: external_exports.number().optional()
15252
- }),
15253
- external_exports.strictObject({
15254
- ...numericSetting,
15255
- type: external_exports.literal("range"),
15256
- min: external_exports.number(),
15257
- max: external_exports.number()
15258
- }),
15259
- external_exports.strictObject({
15260
- ...settingField,
15261
- type: external_exports.literal("select"),
15262
- options: external_exports.array(settingOption).min(1),
15263
- default: external_exports.string().optional()
15264
- })
15265
- ]).superRefine((field2, ctx) => {
15266
- const issue2 = (path10, message) => ctx.addIssue({ code: "custom", path: [path10], message });
15267
- if (field2.type === "number" || field2.type === "range") {
15268
- const { min = -Infinity, max = Infinity, default: value } = field2;
15269
- if (min > max)
15270
- issue2("max", "Must be at least min");
15271
- if (value !== void 0 && (value < min || value > max))
15272
- issue2("default", "Must be within min and max");
15273
- } else if (field2.type === "select") {
15274
- const values = new Set(field2.options.map(({ value }) => value));
15275
- if (values.size !== field2.options.length)
15276
- issue2("options", "Duplicate option values");
15277
- if (field2.default !== void 0 && !values.has(field2.default))
15278
- issue2("default", "Must match an option value");
15279
- }
15280
- });
15281
- var manifestHeader = external_exports.object({
15282
- manifestVersion: external_exports.int().positive(),
15283
- id: desktopExtensionIdSchema,
15284
- name: external_exports.union([extensionName, localizedText(extensionName)]),
15285
- version: external_exports.string().min(1).max(128),
15286
- desktopApi: external_exports.int().positive()
15287
- }).passthrough();
15288
- var desktopExtensionManifestSchema = manifestHeader.extend({
15289
- manifestVersion: external_exports.literal(1),
15290
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15291
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15292
- author: external_exports.string().trim().min(1).max(128).optional(),
15293
- repository: desktopExtensionHttpUrlSchema.optional(),
15294
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15295
- icon: imagePathSchema.optional(),
15296
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15297
- desktop: external_exports.strictObject({
15298
- script: pluginRelativeResourceSchema,
15299
- style: pluginRelativeResourceSchema.optional()
15300
- }).optional(),
15301
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15302
- slots: slotsSchema.default(() => []),
15303
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15304
- categories: categoriesSchema.optional()
15305
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15306
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
15307
- version: external_exports.literal(1),
15308
- revision: external_exports.int().nonnegative(),
15309
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
15310
- reloadToken: external_exports.uuid().optional()
15311
- });
15312
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15313
- var desktopExtensionStatusSchema = external_exports.strictObject({
15314
- state: external_exports.enum([
15315
- "running",
15316
- "disabled",
15317
- "invalid",
15318
- "incompatible",
15319
- "conflict",
15320
- "failed",
15321
- "waiting"
15322
- ]),
15323
- hash: desktopExtensionHashSchema.optional(),
15324
- error: external_exports.string().optional(),
15325
- conflictWith: desktopExtensionIdSchema.optional()
15326
- });
15327
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15328
- controllerPid: external_exports.int().positive(),
15329
- targetId: external_exports.string().nullable(),
15330
- updatedAt: external_exports.iso.datetime(),
15331
- handledReloadToken: external_exports.uuid().optional(),
15332
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
15333
- });
15334
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15335
- function isGitHubDesktopExtensionZipballUrl(url2) {
15336
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15337
- }
15338
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15339
- const url2 = new URL(input);
15340
- 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);
15341
- }, "Expected a .zip download URL or a GitHub zipball URL");
15342
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15343
- id: desktopExtensionIdSchema,
15344
- version: external_exports.string().trim().min(1).max(128),
15345
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15346
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
15347
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15348
- author: external_exports.string().trim().min(1).max(128),
15349
- repository: desktopExtensionHttpUrlSchema,
15350
- stars: external_exports.number().int().min(0).optional(),
15351
- downloads: external_exports.number().int().min(0).optional(),
15352
- categories: categoriesSchema.optional(),
15353
- trustTier: desktopExtensionTrustTierSchema.default("community"),
15354
- icon: desktopExtensionHttpUrlSchema.optional(),
15355
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15356
- downloadUrl: desktopExtensionZipUrlSchema,
15357
- sha256: desktopExtensionHashSchema,
15358
- slots: slotsSchema.optional(),
15359
- publishedAt: external_exports.string().optional(),
15360
- updatedAt: external_exports.string().optional(),
15361
- minCodexHostVersion: external_exports.string().optional()
15362
- });
15363
- var desktopExtensionCatalogSchema = external_exports.strictObject({
15364
- schemaVersion: external_exports.literal(1),
15365
- generatedAt: external_exports.string(),
15366
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
15367
- });
15368
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
15369
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
15370
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
15371
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
15372
- var extensionIdParams = { id: desktopExtensionIdSchema };
15373
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
15374
- ...extensionIdParams,
15375
- path: desktopExtensionAssetPathSchema
15376
- });
15377
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
15378
- mimeType: external_exports.string(),
15379
- dataUrl: external_exports.string()
15380
- });
15381
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
15382
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
15383
- ...extensionIdParams,
15384
- values: jsonObjectSchema
15385
- });
15386
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
15387
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15388
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
15389
- ...extensionIdParams,
15390
- method: desktopExtensionBackendMethodSchema,
15391
- params: jsonValueSchema.optional()
15392
- });
15393
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
15394
- result: jsonValueSchema
15395
- });
15396
-
15397
- // ../../shared-contracts/dist/desktop-extension-management.js
15398
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
15399
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
15400
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
15401
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
15402
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
15403
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
15404
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
15405
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
15406
- DESKTOP_EXTENSIONS_LIST_METHOD,
15407
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
15408
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
15409
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
15410
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
15411
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
15412
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
15413
- DESKTOP_EXTENSIONS_ASSET_METHOD,
15414
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
15415
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
15416
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
15417
- ];
15418
- var revisionSchema = external_exports.int().nonnegative();
15419
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
15420
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
15421
- id: desktopExtensionIdSchema,
15422
- expectedRevision: revisionSchema
15423
- });
15424
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
15425
- expectedRevision: revisionSchema.optional()
15426
- });
15427
- 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);
15428
- var desktopExtensionListItemSchema = external_exports.strictObject({
15429
- // An invalid discovery can have a directory name that isn't a valid extension ID.
15430
- id: external_exports.string().min(1),
15431
- manifest: desktopExtensionManifestSchema.optional(),
15432
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15433
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15434
- enabled: external_exports.boolean(),
15435
- status: desktopExtensionStatusSchema
15436
- });
15437
- var desktopExtensionsListResultSchema = external_exports.strictObject({
15438
- configuration: desktopExtensionConfigurationSchema,
15439
- desktopConnected: external_exports.boolean(),
15440
- diagnostics: external_exports.array(external_exports.string()),
15441
- extensions: external_exports.array(desktopExtensionListItemSchema)
15442
- });
15443
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
15444
- forceRefresh: external_exports.boolean().optional()
15445
- });
15446
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
15447
- catalogUrl: external_exports.string(),
15448
- source: external_exports.enum(["remote", "fallback"]),
15449
- fetchedAt: external_exports.string(),
15450
- cached: external_exports.boolean(),
15451
- extensions: desktopExtensionCatalogSchema.shape.extensions,
15452
- error: external_exports.string().optional()
15453
- });
15454
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
15455
- source: external_exports.discriminatedUnion("type", [
15456
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
15457
- external_exports.strictObject({
15458
- type: external_exports.literal("url"),
15459
- url: desktopExtensionHttpUrlSchema,
15460
- expectedSha256: desktopExtensionHashSchema.optional()
15461
- }),
15462
- external_exports.strictObject({
15463
- type: external_exports.literal("zip-base64"),
15464
- fileName: external_exports.string().trim().min(1).max(255),
15465
- 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")
15466
- })
15467
- ])
15468
- });
15469
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
15470
- extensionId: desktopExtensionIdSchema,
15471
- version: external_exports.string().min(1),
15472
- replaced: external_exports.boolean(),
15473
- installedPath: external_exports.string(),
15474
- list: desktopExtensionsListResultSchema
15475
- });
15476
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
15477
- id: desktopExtensionIdSchema
15478
- });
15479
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
15480
- removedId: desktopExtensionIdSchema,
15481
- list: desktopExtensionsListResultSchema
15482
- });
15483
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
15484
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
15485
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
15486
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
15487
- ]);
15488
-
15489
- // ../../shared-contracts/dist/errors.js
15490
- var codexhostErrorSchema = external_exports.strictObject({
15491
- code: external_exports.string().min(1),
15492
- message: external_exports.string().min(1),
15493
- retryable: external_exports.boolean(),
15494
- diagnostic: external_exports.string().min(1).optional(),
15495
- stage: external_exports.string().min(1).optional(),
15496
- durationMs: external_exports.number().int().nonnegative().optional(),
15497
- stderrTail: external_exports.string().min(1).optional()
15498
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
15499
-
15500
- // ../../shared-contracts/dist/harness-presentation.js
15501
- var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
15502
- var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
15503
- var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
15504
- label: displayText(256).optional(),
15505
- description: displayText(1024).optional()
15506
- }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15507
- 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");
15508
-
15509
- // ../../shared-contracts/dist/harness-permission-modes.js
15510
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
15511
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
15512
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
15513
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
15514
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15515
- message: "Value must not be empty or whitespace"
15516
- });
15517
- 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();
15518
- var harnessPermissionModeSchema = external_exports.object({
15519
- id: harnessPermissionModeIdSchema,
15520
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15521
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15522
- dangerous: external_exports.boolean().optional(),
15523
- localizations: harnessLocalizationsSchema.optional()
15524
- }).strict();
15525
- var harnessPermissionModeCatalogSchema = external_exports.object({
15526
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
15527
- defaultModeId: harnessPermissionModeIdSchema
15528
- }).strict().superRefine((catalog, context) => {
15529
- const ids = /* @__PURE__ */ new Set();
15530
- for (const [index, mode] of catalog.modes.entries()) {
15531
- if (ids.has(mode.id)) {
15532
- context.addIssue({
15533
- code: "custom",
15534
- message: "Permission Mode IDs must be unique",
15535
- path: ["modes", index, "id"]
15536
- });
15537
- }
15538
- ids.add(mode.id);
15539
- }
15540
- if (!ids.has(catalog.defaultModeId)) {
15541
- context.addIssue({
15542
- code: "custom",
15543
- message: "Default Permission Mode must exist in the catalog",
15544
- path: ["defaultModeId"]
15545
- });
15129
+ if (!ids.has(catalog.defaultModeId)) {
15130
+ context.addIssue({
15131
+ code: "custom",
15132
+ message: "Default Permission Mode must exist in the catalog",
15133
+ path: ["defaultModeId"]
15134
+ });
15546
15135
  }
15547
15136
  });
15548
15137
  var threadPermissionModeSelectParamsSchema = external_exports.object({
@@ -15550,6 +15139,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15550
15139
  permissionModeId: harnessPermissionModeIdSchema
15551
15140
  }).strict();
15552
15141
 
15142
+ // ../../shared-contracts/dist/harness-route-limit.js
15143
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
15144
+
15553
15145
  // ../../shared-contracts/dist/thread-usage.js
15554
15146
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15555
15147
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -15582,7 +15174,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15582
15174
  expiresAtUnix: nonNegativeSafeIntegerSchema,
15583
15175
  label: indicatorTextSchema(256).optional(),
15584
15176
  tooltip: indicatorTextSchema(1024).optional()
15585
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15177
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
15586
15178
  message: "Composer indicator IDs must be unique"
15587
15179
  });
15588
15180
  var threadUsageSnapshotSchema = external_exports.object({
@@ -15608,6 +15200,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15608
15200
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15609
15201
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15610
15202
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15203
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15611
15204
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15612
15205
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15613
15206
  }).strict().superRefine((usage, context) => {
@@ -15735,10 +15328,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
15735
15328
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15736
15329
  message: "Value must not be empty or whitespace"
15737
15330
  });
15738
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
15331
+ 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();
15332
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
15739
15333
  var harnessModelRefSchema = external_exports.object({
15740
- id: harnessModelRefIdSchema
15334
+ id: harnessModelRefIdSchema,
15335
+ serviceTier: harnessModelServiceTierSchema.optional()
15741
15336
  }).strict();
15337
+ function sameHarnessModelRef(left, right) {
15338
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
15339
+ }
15742
15340
  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();
15743
15341
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15744
15342
  var harnessThinkingOptionSchema = external_exports.object({
@@ -15752,7 +15350,15 @@ var harnessModelSchema = external_exports.object({
15752
15350
  /** Optional opaque selection for this same Model with priority processing enabled. */
15753
15351
  fastModel: harnessModelRefSchema.optional(),
15754
15352
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15755
- }).strict();
15353
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
15354
+ path: ["fastModel", "id"],
15355
+ message: "A tiered Fast Model must share the base Model ID"
15356
+ });
15357
+ function catalogModelForRef(catalog, ref) {
15358
+ if (!ref)
15359
+ return void 0;
15360
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
15361
+ }
15756
15362
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15757
15363
  const ids = /* @__PURE__ */ new Set();
15758
15364
  for (const [index, option] of options.entries()) {
@@ -15772,26 +15378,26 @@ var harnessModelCatalogSchema = external_exports.object({
15772
15378
  thinkingOptions: harnessThinkingOptionsSchema,
15773
15379
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15774
15380
  }).strict().superRefine((catalog, context) => {
15775
- const refs = /* @__PURE__ */ new Set();
15776
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15381
+ const refs = [];
15382
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
15777
15383
  for (const [index, model2] of catalog.models.entries()) {
15778
- if (refs.has(model2.ref.id)) {
15384
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
15779
15385
  context.addIssue({
15780
15386
  code: "custom",
15781
15387
  message: "Model Catalog refs must be unique",
15782
15388
  path: ["models", index, "ref", "id"]
15783
15389
  });
15784
15390
  }
15785
- refs.add(model2.ref.id);
15391
+ refs.push(model2.ref);
15786
15392
  if (model2.fastModel) {
15787
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15393
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
15788
15394
  context.addIssue({
15789
15395
  code: "custom",
15790
15396
  message: "Fast Model refs must be distinct and unique",
15791
15397
  path: ["models", index, "fastModel"]
15792
15398
  });
15793
15399
  }
15794
- refs.add(model2.fastModel.id);
15400
+ refs.push(model2.fastModel);
15795
15401
  }
15796
15402
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15797
15403
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -15812,7 +15418,7 @@ var harnessModelCatalogSchema = external_exports.object({
15812
15418
  }
15813
15419
  }
15814
15420
  }
15815
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15421
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
15816
15422
  context.addIssue({
15817
15423
  code: "custom",
15818
15424
  message: "Default Model must exist in the Model Catalog",
@@ -15835,184 +15441,735 @@ var harnessHistoryCapabilitiesSchema = external_exports.object({
15835
15441
  path: ["forkAcrossCwd"],
15836
15442
  message: "Cross-cwd Fork requires exact history Fork support"
15837
15443
  });
15838
- var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
15839
- var harnessSessionCapabilitiesSchema = external_exports.object({
15840
- configuration: external_exports.object({
15841
- selectModel: external_exports.boolean(),
15842
- selectThinkingOption: external_exports.boolean(),
15843
- selectPermissionMode: external_exports.boolean(),
15844
- permissionModeScope: harnessPermissionModeScopeSchema.default("live")
15845
- }).strict(),
15846
- history: harnessHistoryCapabilitiesSchema,
15847
- subagents: external_exports.object({
15848
- observe: external_exports.boolean(),
15849
- readTranscript: external_exports.boolean()
15850
- }).strict().optional(),
15851
- autonomousTurns: external_exports.object({
15852
- observe: external_exports.boolean()
15853
- }).strict().optional(),
15854
- /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15855
- steer: external_exports.boolean().optional()
15856
- }).strict();
15857
- var harnessConfigurationStateSchema = external_exports.object({
15858
- effectiveModel: harnessModelRefSchema.optional(),
15859
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15860
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15861
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15862
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15863
- }).strict().superRefine((state, context) => {
15864
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15865
- context.addIssue({
15866
- code: "custom",
15867
- message: "Effective Thinking option must be currently available",
15868
- path: ["effectiveThinkingOptionId"]
15869
- });
15870
- }
15444
+ var harnessPermissionModeScopeSchema = external_exports.enum(["live", "atCreate"]);
15445
+ var harnessSessionCapabilitiesSchema = external_exports.object({
15446
+ configuration: external_exports.object({
15447
+ selectModel: external_exports.boolean(),
15448
+ selectThinkingOption: external_exports.boolean(),
15449
+ selectPermissionMode: external_exports.boolean(),
15450
+ permissionModeScope: harnessPermissionModeScopeSchema.default("live")
15451
+ }).strict(),
15452
+ history: harnessHistoryCapabilitiesSchema,
15453
+ subagents: external_exports.object({
15454
+ observe: external_exports.boolean(),
15455
+ readTranscript: external_exports.boolean()
15456
+ }).strict().optional(),
15457
+ autonomousTurns: external_exports.object({
15458
+ observe: external_exports.boolean()
15459
+ }).strict().optional(),
15460
+ /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15461
+ steer: external_exports.boolean().optional(),
15462
+ /**
15463
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
15464
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
15465
+ */
15466
+ persistentPlan: external_exports.boolean().optional()
15467
+ }).strict();
15468
+ var harnessConfigurationStateSchema = external_exports.object({
15469
+ effectiveModel: harnessModelRefSchema.optional(),
15470
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15471
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15472
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15473
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15474
+ }).strict().superRefine((state, context) => {
15475
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
15476
+ context.addIssue({
15477
+ code: "custom",
15478
+ message: "Effective Thinking option must be currently available",
15479
+ path: ["effectiveThinkingOptionId"]
15480
+ });
15481
+ }
15482
+ });
15483
+ var harnessWebUiCapabilitySchema = external_exports.object({
15484
+ open: external_exports.literal(true)
15485
+ }).strict();
15486
+ var readyHarnessInspectionSchema = external_exports.object({
15487
+ status: external_exports.literal("ready"),
15488
+ catalog: harnessModelCatalogSchema,
15489
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
15490
+ capabilities: harnessSessionCapabilitiesSchema,
15491
+ webUi: harnessWebUiCapabilitySchema.optional()
15492
+ }).strict().superRefine((inspection, context) => {
15493
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
15494
+ if (selectable !== Boolean(inspection.permissionModes)) {
15495
+ context.addIssue({
15496
+ code: "custom",
15497
+ message: "Permission Mode catalog and capability must agree",
15498
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15499
+ });
15500
+ }
15501
+ });
15502
+ var failedHarnessInspectionSchema = external_exports.object({
15503
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15504
+ error: codexhostErrorSchema
15505
+ }).strict();
15506
+ var harnessInspectionSchema = external_exports.union([
15507
+ readyHarnessInspectionSchema,
15508
+ failedHarnessInspectionSchema
15509
+ ]);
15510
+ var harnessInspectParamsSchema = external_exports.object({
15511
+ harnessId: harnessIdSchema,
15512
+ cwd: nonBlankTextSchema2.max(16384).optional(),
15513
+ refresh: external_exports.boolean().optional(),
15514
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15515
+ purpose: external_exports.literal("availability").optional(),
15516
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15517
+ }).strict();
15518
+ var harnessWebUiOpenParamsSchema = external_exports.object({
15519
+ harnessId: harnessIdSchema
15520
+ }).strict();
15521
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15522
+ var threadModelSelectParamsSchema = external_exports.object({
15523
+ threadId: hostThreadIdSchema,
15524
+ model: harnessModelRefSchema
15525
+ }).strict();
15526
+ var threadThinkingSelectParamsSchema = external_exports.object({
15527
+ threadId: hostThreadIdSchema,
15528
+ thinkingOptionId: harnessThinkingOptionIdSchema
15529
+ }).strict();
15530
+ var threadInspectionParamsSchema = external_exports.object({
15531
+ threadId: hostThreadIdSchema,
15532
+ includeReferenceCapability: external_exports.boolean().optional()
15533
+ }).strict();
15534
+ var codexThreadInspectionSchema = external_exports.object({
15535
+ owner: external_exports.literal("codex"),
15536
+ locked: external_exports.boolean(),
15537
+ effectiveModel: harnessModelRefSchema.optional(),
15538
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15539
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15540
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15541
+ history: harnessHistoryCapabilitiesSchema.optional(),
15542
+ supportsThreadReferences: external_exports.literal(true).optional()
15543
+ }).strict();
15544
+ var externalThreadInspectionSchema = external_exports.object({
15545
+ owner: external_exports.literal("external"),
15546
+ harnessId: nonBlankTextSchema2.max(256),
15547
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15548
+ effectiveModel: harnessModelRefSchema.optional(),
15549
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15550
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15551
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15552
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15553
+ history: harnessHistoryCapabilitiesSchema,
15554
+ usage: threadUsageSnapshotSchema.optional(),
15555
+ locked: external_exports.literal(true)
15556
+ }).strict();
15557
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15558
+ codexThreadInspectionSchema,
15559
+ externalThreadInspectionSchema
15560
+ ]);
15561
+ var threadOwnershipListParamsSchema = external_exports.object({
15562
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15563
+ }).strict().superRefine(({ threadIds }, context) => {
15564
+ const seen = /* @__PURE__ */ new Set();
15565
+ for (const [index, threadId] of threadIds.entries()) {
15566
+ if (seen.has(threadId)) {
15567
+ context.addIssue({
15568
+ code: "custom",
15569
+ message: "Thread ownership-list IDs must be unique",
15570
+ path: ["threadIds", index]
15571
+ });
15572
+ }
15573
+ seen.add(threadId);
15574
+ }
15575
+ });
15576
+ var codexThreadOwnershipSchema = external_exports.object({
15577
+ threadId: hostThreadIdSchema,
15578
+ owner: external_exports.literal("codex")
15579
+ }).strict();
15580
+ var externalThreadOwnershipSchema = external_exports.object({
15581
+ threadId: hostThreadIdSchema,
15582
+ owner: external_exports.literal("external"),
15583
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15584
+ }).strict();
15585
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15586
+ codexThreadOwnershipSchema,
15587
+ externalThreadOwnershipSchema
15588
+ ]);
15589
+ var threadOwnershipListResultSchema = external_exports.object({
15590
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15591
+ }).strict().superRefine(({ threads }, context) => {
15592
+ const seen = /* @__PURE__ */ new Set();
15593
+ for (const [index, thread2] of threads.entries()) {
15594
+ if (seen.has(thread2.threadId)) {
15595
+ context.addIssue({
15596
+ code: "custom",
15597
+ message: "Thread ownership-list results must be unique",
15598
+ path: ["threads", index, "threadId"]
15599
+ });
15600
+ }
15601
+ seen.add(thread2.threadId);
15602
+ }
15603
+ });
15604
+ var threadSteeringInspectParamsSchema = external_exports.object({
15605
+ threadId: hostThreadIdSchema,
15606
+ /** The text about to be steered; a Harness command always stops and restarts. */
15607
+ text: external_exports.string().optional()
15608
+ }).strict();
15609
+ var threadSteeringContextSchema = external_exports.object({
15610
+ kind: external_exports.literal("application"),
15611
+ value: external_exports.string().transform((text, context) => {
15612
+ try {
15613
+ return JSON.parse(text);
15614
+ } catch {
15615
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15616
+ return external_exports.NEVER;
15617
+ }
15618
+ }).pipe(external_exports.object({
15619
+ expectedTurnId: hostTurnIdSchema,
15620
+ clientUserMessageId: external_exports.string().min(1),
15621
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
15622
+ }).strict())
15623
+ }).strict().transform((context) => context.value);
15624
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15625
+ var threadSteeringInspectResultSchema = external_exports.object({
15626
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15627
+ }).strict();
15628
+
15629
+ // ../../shared-contracts/dist/harness-plugins.js
15630
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15631
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15632
+ var HARNESS_PLUGIN_LIMIT = 128;
15633
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15634
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15635
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
15636
+ 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");
15637
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15638
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15639
+ var harnessInstallationGuideSchema = external_exports.object({
15640
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15641
+ before: localizedTextSchema.optional(),
15642
+ after: localizedTextSchema.optional(),
15643
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15644
+ }).strict();
15645
+ var pluginPresentationShape = {
15646
+ id: installedHarnessPluginIdSchema,
15647
+ name: external_exports.string().trim().min(1).max(128),
15648
+ version: external_exports.string().min(1).max(128),
15649
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15650
+ kind: external_exports.literal("usage").optional(),
15651
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15652
+ iconStyle: external_exports.object({
15653
+ vector: external_exports.object({
15654
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15655
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15656
+ paths: external_exports.array(external_exports.object({
15657
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15658
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15659
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15660
+ }).strict()).min(1).max(32)
15661
+ }).strict().optional(),
15662
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15663
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15664
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15665
+ }).strict().optional(),
15666
+ installation: harnessInstallationGuideSchema.optional(),
15667
+ notice: localizedTextSchema.optional(),
15668
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15669
+ launchCommand: external_exports.literal(true).optional(),
15670
+ links: external_exports.object({
15671
+ website: documentationUrlSchema.optional(),
15672
+ documentation: documentationUrlSchema.optional(),
15673
+ installation: documentationUrlSchema.optional()
15674
+ }).strict().optional()
15675
+ };
15676
+ var harnessPluginManifestSchema = external_exports.object({
15677
+ manifestVersion: external_exports.literal(1),
15678
+ ...pluginPresentationShape,
15679
+ adapterApiVersion: external_exports.number().int().positive(),
15680
+ entry: pluginRelativeResourceSchema,
15681
+ icon: pluginRelativeResourceSchema.optional()
15682
+ }).strict();
15683
+ 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);
15684
+ var harnessPluginDescriptorSchema = external_exports.object({
15685
+ ...pluginPresentationShape,
15686
+ icon: harnessPluginIconSchema.optional()
15687
+ }).strict();
15688
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15689
+ var harnessPluginListResultSchema = external_exports.object({
15690
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15691
+ }).strict();
15692
+ var harnessPluginConfigurationSchema = external_exports.object({
15693
+ version: external_exports.literal(1),
15694
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15695
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15696
+ message: "Enabled plugin IDs must be unique",
15697
+ path: ["enabled"]
15698
+ });
15699
+
15700
+ // ../../shared-contracts/dist/desktop-extensions.js
15701
+ var DESKTOP_EXTENSION_API_VERSION = 1;
15702
+ var DESKTOP_EXTENSION_LIMIT = 64;
15703
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15704
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15705
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15706
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15707
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15708
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15709
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15710
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15711
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15712
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15713
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15714
+ var desktopExtensionIdSchema = installedPluginIdSchema;
15715
+ var desktopExtensionSlotSchema = external_exports.enum([
15716
+ "sidebar.thread-layout",
15717
+ "sidebar.thread-badge",
15718
+ "appearance.theme"
15719
+ ]);
15720
+ var desktopExtensionCategorySchema = external_exports.enum([
15721
+ "appearance",
15722
+ "interface",
15723
+ "workflow",
15724
+ "analytics",
15725
+ "integrations",
15726
+ "tools"
15727
+ ]);
15728
+ var extensionName = external_exports.string().trim().min(1).max(128);
15729
+ function desktopExtensionScreenshotMimeType(resource) {
15730
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15731
+ case "png":
15732
+ return "image/png";
15733
+ case "jpg":
15734
+ case "jpeg":
15735
+ return "image/jpeg";
15736
+ case "webp":
15737
+ return "image/webp";
15738
+ default:
15739
+ return void 0;
15740
+ }
15741
+ }
15742
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15743
+ 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");
15744
+ 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) => {
15745
+ const { username, password } = new URL(value);
15746
+ return !username && !password && !/[\\\s]/u.test(value);
15747
+ }, "URL must not contain credentials, backslashes, or whitespace");
15748
+ function localizedText(text) {
15749
+ return external_exports.strictObject({ en: text, "zh-CN": text });
15750
+ }
15751
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15752
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15753
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15754
+ var settingField = {
15755
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15756
+ label: desktopExtensionLocalizedTextSchema,
15757
+ description: desktopExtensionLocalizedTextSchema.optional()
15758
+ };
15759
+ var numericSetting = {
15760
+ ...settingField,
15761
+ step: external_exports.number().positive().optional(),
15762
+ default: external_exports.number().optional()
15763
+ };
15764
+ var settingOption = external_exports.strictObject({
15765
+ value: external_exports.string(),
15766
+ label: desktopExtensionLocalizedTextSchema
15767
+ });
15768
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15769
+ external_exports.strictObject({
15770
+ ...settingField,
15771
+ type: external_exports.literal("boolean"),
15772
+ default: external_exports.boolean().optional()
15773
+ }),
15774
+ external_exports.strictObject({
15775
+ ...settingField,
15776
+ type: external_exports.literal("string"),
15777
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
15778
+ default: external_exports.string().optional()
15779
+ }),
15780
+ external_exports.strictObject({
15781
+ ...numericSetting,
15782
+ type: external_exports.literal("number"),
15783
+ min: external_exports.number().optional(),
15784
+ max: external_exports.number().optional()
15785
+ }),
15786
+ external_exports.strictObject({
15787
+ ...numericSetting,
15788
+ type: external_exports.literal("range"),
15789
+ min: external_exports.number(),
15790
+ max: external_exports.number()
15791
+ }),
15792
+ external_exports.strictObject({
15793
+ ...settingField,
15794
+ type: external_exports.literal("select"),
15795
+ options: external_exports.array(settingOption).min(1),
15796
+ default: external_exports.string().optional()
15797
+ })
15798
+ ]).superRefine((field2, ctx) => {
15799
+ const issue2 = (path10, message) => ctx.addIssue({ code: "custom", path: [path10], message });
15800
+ if (field2.type === "number" || field2.type === "range") {
15801
+ const { min = -Infinity, max = Infinity, default: value } = field2;
15802
+ if (min > max)
15803
+ issue2("max", "Must be at least min");
15804
+ if (value !== void 0 && (value < min || value > max))
15805
+ issue2("default", "Must be within min and max");
15806
+ } else if (field2.type === "select") {
15807
+ const values = new Set(field2.options.map(({ value }) => value));
15808
+ if (values.size !== field2.options.length)
15809
+ issue2("options", "Duplicate option values");
15810
+ if (field2.default !== void 0 && !values.has(field2.default))
15811
+ issue2("default", "Must match an option value");
15812
+ }
15813
+ });
15814
+ var manifestHeader = external_exports.object({
15815
+ manifestVersion: external_exports.int().positive(),
15816
+ id: desktopExtensionIdSchema,
15817
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
15818
+ version: external_exports.string().min(1).max(128),
15819
+ desktopApi: external_exports.int().positive()
15820
+ }).passthrough();
15821
+ var desktopExtensionManifestSchema = manifestHeader.extend({
15822
+ manifestVersion: external_exports.literal(1),
15823
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15824
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15825
+ author: external_exports.string().trim().min(1).max(128).optional(),
15826
+ repository: desktopExtensionHttpUrlSchema.optional(),
15827
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15828
+ icon: imagePathSchema.optional(),
15829
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15830
+ desktop: external_exports.strictObject({
15831
+ script: pluginRelativeResourceSchema,
15832
+ style: pluginRelativeResourceSchema.optional()
15833
+ }).optional(),
15834
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15835
+ slots: slotsSchema.default(() => []),
15836
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15837
+ categories: categoriesSchema.optional()
15838
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15839
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15840
+ var desktopExtensionStatusSchema = external_exports.strictObject({
15841
+ state: external_exports.enum([
15842
+ "running",
15843
+ "disabled",
15844
+ "invalid",
15845
+ "incompatible",
15846
+ "conflict",
15847
+ "failed",
15848
+ "waiting"
15849
+ ]),
15850
+ hash: desktopExtensionHashSchema.optional(),
15851
+ error: external_exports.string().optional(),
15852
+ conflictWith: desktopExtensionIdSchema.optional()
15853
+ });
15854
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15855
+ controllerPid: external_exports.int().positive(),
15856
+ targetId: external_exports.string().nullable(),
15857
+ updatedAt: external_exports.iso.datetime(),
15858
+ handledReloadToken: external_exports.uuid().optional(),
15859
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
15860
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
15861
+ });
15862
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15863
+ function isGitHubDesktopExtensionZipballUrl(url2) {
15864
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15865
+ }
15866
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15867
+ const url2 = new URL(input);
15868
+ 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);
15869
+ }, "Expected a .zip download URL or a GitHub zipball URL");
15870
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15871
+ id: desktopExtensionIdSchema,
15872
+ version: external_exports.string().trim().min(1).max(128),
15873
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15874
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
15875
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15876
+ author: external_exports.string().trim().min(1).max(128),
15877
+ repository: desktopExtensionHttpUrlSchema,
15878
+ stars: external_exports.number().int().min(0).optional(),
15879
+ downloads: external_exports.number().int().min(0).optional(),
15880
+ categories: categoriesSchema.optional(),
15881
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
15882
+ icon: desktopExtensionHttpUrlSchema.optional(),
15883
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15884
+ downloadUrl: desktopExtensionZipUrlSchema,
15885
+ sha256: desktopExtensionHashSchema,
15886
+ slots: slotsSchema.optional(),
15887
+ publishedAt: external_exports.string().optional(),
15888
+ updatedAt: external_exports.string().optional(),
15889
+ minCodexHostVersion: external_exports.string().optional()
15871
15890
  });
15872
- var harnessWebUiCapabilitySchema = external_exports.object({
15873
- open: external_exports.literal(true)
15874
- }).strict();
15875
- var readyHarnessInspectionSchema = external_exports.object({
15876
- status: external_exports.literal("ready"),
15877
- catalog: harnessModelCatalogSchema,
15878
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
15879
- capabilities: harnessSessionCapabilitiesSchema,
15880
- webUi: harnessWebUiCapabilitySchema.optional()
15881
- }).strict().superRefine((inspection, context) => {
15882
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
15883
- if (selectable !== Boolean(inspection.permissionModes)) {
15884
- context.addIssue({
15885
- code: "custom",
15886
- message: "Permission Mode catalog and capability must agree",
15887
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15888
- });
15889
- }
15891
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
15892
+ schemaVersion: external_exports.literal(1),
15893
+ generatedAt: external_exports.string(),
15894
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15890
15895
  });
15891
- var failedHarnessInspectionSchema = external_exports.object({
15892
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15893
- error: codexhostErrorSchema
15894
- }).strict();
15895
- var harnessInspectionSchema = external_exports.union([
15896
- readyHarnessInspectionSchema,
15897
- failedHarnessInspectionSchema
15896
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15897
+
15898
+ // ../../shared-contracts/dist/host-extensions.js
15899
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
15900
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
15901
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
15902
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
15903
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
15904
+ var hostExtensionActivationIdSchema = external_exports.uuid();
15905
+ 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((path10) => path10.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
15906
+ var legacy = desktopExtensionManifestSchema.shape;
15907
+ var localized = (max, min = 0) => external_exports.strictObject({
15908
+ en: external_exports.string().trim().min(min).max(max),
15909
+ "zh-CN": external_exports.string().trim().min(min).max(max)
15910
+ });
15911
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path10) => path10.endsWith(suffix), `Expected a ${suffix} file`);
15912
+ var moduleEntry = resourceWithSuffix(".mjs");
15913
+ var style = resourceWithSuffix(".css").optional();
15914
+ var hostExtensionCanonicalPath = (path10) => path10.normalize("NFC").toLowerCase();
15915
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
15916
+ manifestVersion: external_exports.literal(2),
15917
+ id: hostExtensionIdSchema,
15918
+ name: localized(128, 1),
15919
+ version: external_exports.string().trim().min(1).max(128),
15920
+ description: localized(4096),
15921
+ details: localized(16384).optional(),
15922
+ author: legacy.author,
15923
+ repository: legacy.repository,
15924
+ icon: legacy.icon.refine((path10) => path10 === void 0 || hostExtensionResourcePathSchema.safeParse(path10).success),
15925
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path10) => hostExtensionResourcePathSchema.safeParse(path10).success)),
15926
+ categories: legacy.categories,
15927
+ settingsSchema: legacy.settingsSchema,
15928
+ slots: legacy.slots.removeDefault().optional(),
15929
+ page: external_exports.strictObject({
15930
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15931
+ entry: moduleEntry,
15932
+ style,
15933
+ title: localized(128, 1).optional()
15934
+ }).optional(),
15935
+ widget: external_exports.strictObject({
15936
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15937
+ entry: moduleEntry,
15938
+ style
15939
+ }).optional(),
15940
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
15941
+ 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(),
15942
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
15943
+ }).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" });
15944
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
15945
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
15946
+ return ["desktop", "web"];
15947
+ const targets = [];
15948
+ if (hasDesktop)
15949
+ targets.push("desktop");
15950
+ if (hasWeb)
15951
+ targets.push("web");
15952
+ return targets;
15953
+ }
15954
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
15955
+
15956
+ // ../../shared-contracts/dist/host-extension-management.js
15957
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
15958
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
15959
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
15960
+ revision: hostExtensionRevisionSchema,
15961
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
15962
+ });
15963
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
15964
+ var hostExtensionCatalogEntrySchema = external_exports.object({
15965
+ ...catalogMetadata,
15966
+ id: hostExtensionIdSchema,
15967
+ format: external_exports.literal("codexhost"),
15968
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
15969
+ apis: external_exports.strictObject({
15970
+ page: external_exports.int().positive().optional(),
15971
+ widget: external_exports.int().positive().optional(),
15972
+ desktop: external_exports.int().positive().optional(),
15973
+ web: external_exports.int().positive().optional(),
15974
+ backend: external_exports.int().positive().optional()
15975
+ }),
15976
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
15977
+ }).refine(({ targets, apis }) => {
15978
+ const derived = targetsForCapabilities({
15979
+ hasPage: Boolean(apis.page),
15980
+ hasWidget: Boolean(apis.widget),
15981
+ hasDesktop: Boolean(apis.desktop),
15982
+ hasWeb: Boolean(apis.web),
15983
+ hasBackend: Boolean(apis.backend)
15984
+ });
15985
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
15986
+ }, "Catalog targets must match the declared APIs");
15987
+ var hostExtensionCatalogSchema = external_exports.object({
15988
+ schemaVersion: external_exports.literal(2),
15989
+ generatedAt: external_exports.string().min(1),
15990
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15991
+ });
15992
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
15993
+ catalogUrl: desktopExtensionHttpUrlSchema,
15994
+ fetchedAt: external_exports.iso.datetime(),
15995
+ cached: external_exports.boolean()
15996
+ });
15997
+ var id = { id: hostExtensionIdSchema };
15998
+ var active = {
15999
+ ...id,
16000
+ activationId: hostExtensionActivationIdSchema,
16001
+ digest: hostExtensionDigestSchema
16002
+ };
16003
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
16004
+ var filePath = external_exports.string().min(1).max(4096).refine((path10) => /^(?:\/|[a-z]:[/\\])/iu.test(path10) && !path10.includes("\0") && !path10.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
16005
+ 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");
16006
+ function base643(maxBytes) {
16007
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
16008
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
16009
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
16010
+ }, "Expected bounded standard padded base64");
16011
+ }
16012
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
16013
+ type: external_exports.literal("github"),
16014
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
16015
+ ref: gitRef.optional(),
16016
+ tag: gitRef.optional(),
16017
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
16018
+ subpath: hostExtensionResourcePathSchema.optional()
16019
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
16020
+ var hostExtensionInstallSourceSchema = external_exports.union([
16021
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
16022
+ hostExtensionGitHubSourceSchema,
16023
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
16024
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
16025
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
15898
16026
  ]);
15899
- var harnessInspectParamsSchema = external_exports.object({
15900
- harnessId: harnessIdSchema,
15901
- cwd: nonBlankTextSchema2.max(16384).optional(),
15902
- refresh: external_exports.boolean().optional(),
15903
- /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15904
- purpose: external_exports.literal("availability").optional()
15905
- }).strict();
15906
- var harnessWebUiOpenParamsSchema = external_exports.object({
15907
- harnessId: harnessIdSchema
15908
- }).strict();
15909
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15910
- var threadModelSelectParamsSchema = external_exports.object({
15911
- threadId: hostThreadIdSchema,
15912
- model: harnessModelRefSchema
15913
- }).strict();
15914
- var threadThinkingSelectParamsSchema = external_exports.object({
15915
- threadId: hostThreadIdSchema,
15916
- thinkingOptionId: harnessThinkingOptionIdSchema
15917
- }).strict();
15918
- var threadInspectionParamsSchema = external_exports.object({
15919
- threadId: hostThreadIdSchema,
15920
- includeReferenceCapability: external_exports.boolean().optional()
15921
- }).strict();
15922
- var codexThreadInspectionSchema = external_exports.object({
15923
- owner: external_exports.literal("codex"),
15924
- locked: external_exports.boolean(),
15925
- effectiveModel: harnessModelRefSchema.optional(),
15926
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15927
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15928
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15929
- history: harnessHistoryCapabilitiesSchema.optional(),
15930
- supportsThreadReferences: external_exports.literal(true).optional()
15931
- }).strict();
15932
- var externalThreadInspectionSchema = external_exports.object({
15933
- owner: external_exports.literal("external"),
15934
- harnessId: nonBlankTextSchema2.max(256),
15935
- transportModelId: nonBlankTextSchema2.max(1024),
15936
- effectiveModel: harnessModelRefSchema.optional(),
15937
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15938
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15939
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15940
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15941
- history: harnessHistoryCapabilitiesSchema,
15942
- usage: threadUsageSnapshotSchema.optional(),
15943
- locked: external_exports.literal(true)
15944
- }).strict();
15945
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15946
- codexThreadInspectionSchema,
15947
- externalThreadInspectionSchema
16027
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
16028
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
16029
+ hostExtensionGitHubSourceSchema,
16030
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
16031
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
15948
16032
  ]);
15949
- var threadOwnershipListParamsSchema = external_exports.object({
15950
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15951
- }).strict().superRefine(({ threadIds }, context) => {
15952
- const seen = /* @__PURE__ */ new Set();
15953
- for (const [index, threadId] of threadIds.entries()) {
15954
- if (seen.has(threadId)) {
15955
- context.addIssue({
15956
- code: "custom",
15957
- message: "Thread ownership-list IDs must be unique",
15958
- path: ["threadIds", index]
15959
- });
15960
- }
15961
- seen.add(threadId);
15962
- }
16033
+ var hostExtensionInstallationSchema = external_exports.strictObject({
16034
+ ...active,
16035
+ manifest: hostExtensionManifestV2Schema,
16036
+ installedAt: external_exports.iso.datetime(),
16037
+ source: hostExtensionProvenanceSchema.optional()
15963
16038
  });
15964
- var codexThreadOwnershipSchema = external_exports.object({
15965
- threadId: hostThreadIdSchema,
15966
- owner: external_exports.literal("codex")
15967
- }).strict();
15968
- var externalThreadOwnershipSchema = external_exports.object({
15969
- threadId: hostThreadIdSchema,
15970
- owner: external_exports.literal("external"),
15971
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15972
- }).strict();
15973
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15974
- codexThreadOwnershipSchema,
15975
- externalThreadOwnershipSchema
16039
+ 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);
16040
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
16041
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
16042
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
16043
+ hostExtensionInstallationSchema.extend({
16044
+ state: external_exports.literal("valid"),
16045
+ enabled: external_exports.boolean(),
16046
+ ...desktopConflict,
16047
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
16048
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
16049
+ backendState: backendState.optional(),
16050
+ backendError: external_exports.string().optional()
16051
+ }),
16052
+ external_exports.strictObject({
16053
+ state: external_exports.enum(["invalid", "incompatible"]),
16054
+ id: external_exports.string().min(1),
16055
+ enabled: external_exports.boolean(),
16056
+ error: external_exports.string()
16057
+ })
15976
16058
  ]);
15977
- var threadOwnershipListResultSchema = external_exports.object({
15978
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15979
- }).strict().superRefine(({ threads }, context) => {
15980
- const seen = /* @__PURE__ */ new Set();
15981
- for (const [index, thread2] of threads.entries()) {
15982
- if (seen.has(thread2.threadId)) {
15983
- context.addIssue({
15984
- code: "custom",
15985
- message: "Thread ownership-list results must be unique",
15986
- path: ["threads", index, "threadId"]
15987
- });
15988
- }
15989
- seen.add(thread2.threadId);
15990
- }
16059
+ var hostExtensionsListResultSchema = external_exports.strictObject({
16060
+ revision: hostExtensionRevisionSchema,
16061
+ configuration: hostExtensionConfigurationSchema,
16062
+ diagnostics: external_exports.array(external_exports.string()),
16063
+ extensions: external_exports.array(hostExtensionListItemSchema)
16064
+ });
16065
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
16066
+ ...desktopConflict,
16067
+ settingsRevision: hostExtensionRevisionSchema
16068
+ });
16069
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
16070
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
16071
+ revision: hostExtensionRevisionSchema,
16072
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
16073
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
16074
+ });
16075
+ var HOST_EXTENSIONS_RPC = {
16076
+ list: "codexhost/extensions/list",
16077
+ snapshot: "codexhost/extensions/snapshot",
16078
+ catalog: "codexhost/extensions/catalog",
16079
+ install: "codexhost/extensions/install",
16080
+ update: "codexhost/extensions/update",
16081
+ enable: "codexhost/extensions/enable",
16082
+ disable: "codexhost/extensions/disable",
16083
+ uninstall: "codexhost/extensions/uninstall",
16084
+ recover: "codexhost/extensions/recover",
16085
+ asset: "codexhost/extensions/asset",
16086
+ settingsGet: "codexhost/extensions/settings/get",
16087
+ settingsSet: "codexhost/extensions/settings/set",
16088
+ backendInvoke: "codexhost/extensions/backend/invoke"
16089
+ };
16090
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
16091
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
16092
+ var noParams = external_exports.strictObject({});
16093
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
16094
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
16095
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
16096
+ var mutationResult = external_exports.discriminatedUnion("state", [
16097
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
16098
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
16099
+ ]);
16100
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
16101
+ ...optionalActivation,
16102
+ digest: active.digest.optional(),
16103
+ path: hostExtensionResourcePathSchema
16104
+ });
16105
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
16106
+ mimeType: external_exports.string().min(1),
16107
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
16108
+ digest: active.digest
16109
+ });
16110
+ var hostExtensionSettingsSchema = external_exports.strictObject({
16111
+ settingsRevision: hostExtensionRevisionSchema,
16112
+ values: jsonObjectSchema
15991
16113
  });
15992
- var threadSteeringInspectParamsSchema = external_exports.object({
15993
- threadId: hostThreadIdSchema,
15994
- /** The text about to be steered; a Harness command always stops and restarts. */
15995
- text: external_exports.string().optional()
15996
- }).strict();
15997
- var threadSteeringContextSchema = external_exports.object({
15998
- kind: external_exports.literal("application"),
15999
- value: external_exports.string().transform((text, context) => {
16000
- try {
16001
- return JSON.parse(text);
16002
- } catch {
16003
- context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
16004
- return external_exports.NEVER;
16005
- }
16006
- }).pipe(external_exports.object({
16007
- expectedTurnId: hostTurnIdSchema,
16008
- clientUserMessageId: external_exports.string().min(1),
16009
- delivery: external_exports.enum(["newTurn", "activeTurn"])
16010
- }).strict())
16011
- }).strict().transform((context) => context.value);
16012
- var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
16013
- var threadSteeringInspectResultSchema = external_exports.object({
16014
- delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
16015
- }).strict();
16114
+ var hostExtensionsRpcSchemas = {
16115
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
16116
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
16117
+ [HOST_EXTENSIONS_RPC.catalog]: {
16118
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
16119
+ result: hostExtensionsCatalogResultSchema
16120
+ },
16121
+ [HOST_EXTENSIONS_RPC.install]: {
16122
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
16123
+ result: installationResult
16124
+ },
16125
+ [HOST_EXTENSIONS_RPC.update]: {
16126
+ params: external_exports.strictObject({
16127
+ ...id,
16128
+ expectedDigest: active.digest,
16129
+ expectedActivationId: active.activationId.optional(),
16130
+ source: hostExtensionInstallSourceSchema.optional()
16131
+ }),
16132
+ result: installationResult
16133
+ },
16134
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
16135
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
16136
+ [HOST_EXTENSIONS_RPC.uninstall]: {
16137
+ params: external_exports.strictObject({
16138
+ ...id,
16139
+ removeData: external_exports.boolean().optional(),
16140
+ expectedDigest: active.digest.optional()
16141
+ }),
16142
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
16143
+ },
16144
+ [HOST_EXTENSIONS_RPC.recover]: {
16145
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
16146
+ result: mutationResult
16147
+ },
16148
+ [HOST_EXTENSIONS_RPC.asset]: {
16149
+ params: hostExtensionsAssetParamsSchema,
16150
+ result: hostExtensionsAssetResultSchema
16151
+ },
16152
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
16153
+ params: external_exports.strictObject(optionalActivation),
16154
+ result: hostExtensionSettingsSchema
16155
+ },
16156
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
16157
+ params: external_exports.strictObject({
16158
+ ...optionalActivation,
16159
+ expectedSettingsRevision: hostExtensionRevisionSchema,
16160
+ values: jsonObjectSchema
16161
+ }),
16162
+ result: hostExtensionSettingsSchema
16163
+ },
16164
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
16165
+ params: external_exports.strictObject({
16166
+ ...optionalActivation,
16167
+ method: hostExtensionBackendMethodSchema,
16168
+ params: jsonValueSchema.optional()
16169
+ }),
16170
+ result: external_exports.strictObject({ result: jsonValueSchema })
16171
+ }
16172
+ };
16016
16173
 
16017
16174
  // ../../shared-contracts/dist/thread-archive-confirm.js
16018
16175
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -16075,7 +16232,7 @@ var CLIENT_CHANNEL_METHODS = [
16075
16232
  "codexhost/harness/session-import/list",
16076
16233
  "codexhost/harness/session-import/import",
16077
16234
  // Host settings shared across Desktop and Web.
16078
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
16235
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
16079
16236
  "codexhost/harness/installation",
16080
16237
  "codexhost/harness/installation/start",
16081
16238
  "codexhost/harness/installation/status",
@@ -16136,6 +16293,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
16136
16293
  cursor: clientChannelCursorSchema,
16137
16294
  revision: external_exports.number().int().nonnegative()
16138
16295
  }),
16296
+ external_exports.object({
16297
+ type: external_exports.literal("extensions-changed"),
16298
+ cursor: clientChannelCursorSchema,
16299
+ revision: hostExtensionRevisionSchema
16300
+ }),
16139
16301
  external_exports.object({
16140
16302
  type: external_exports.literal("hello"),
16141
16303
  version: external_exports.literal(1),
@@ -16572,7 +16734,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
16572
16734
 
16573
16735
  // ../../shared-contracts/dist/harness-preferences.js
16574
16736
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
16575
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16737
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
16576
16738
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
16577
16739
  model: harnessModelRefSchema.optional(),
16578
16740
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -16582,11 +16744,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
16582
16744
  lastHarness: harnessIdSchema.optional(),
16583
16745
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
16584
16746
  });
16747
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
16748
+ model: harnessModelRefSchema.optional(),
16749
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
16750
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
16751
+ var delegationDefaultsSchema = external_exports.strictObject({
16752
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
16753
+ });
16585
16754
  var modelId = external_exports.string().min(1).max(1024);
16586
16755
  var harnessPreferenceValuesSchema = external_exports.strictObject({
16587
16756
  idleRelease: idleReleaseSettingsSchema.optional(),
16588
16757
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
16589
- newThread: newThreadDefaultsSchema.optional()
16758
+ newThread: newThreadDefaultsSchema.optional(),
16759
+ delegation: delegationDefaultsSchema.optional()
16590
16760
  });
16591
16761
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
16592
16762
  scope: harnessPreferenceScopeSchema,
@@ -16614,6 +16784,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
16614
16784
  lastHarness: harnessIdSchema.optional(),
16615
16785
  harnessId: harnessIdSchema.optional(),
16616
16786
  configuration: harnessDefaultConfigurationSchema.optional()
16787
+ }),
16788
+ external_exports.strictObject({
16789
+ kind: external_exports.literal("delegation"),
16790
+ harnessId: harnessIdSchema,
16791
+ configuration: harnessDelegationDefaultSchema.nullable()
16617
16792
  })
16618
16793
  ]);
16619
16794
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -17437,9 +17612,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17437
17612
  ...thread,
17438
17613
  epoch: identity,
17439
17614
  modelId: identity.optional(),
17615
+ serviceTier: harnessModelServiceTierSchema.optional(),
17440
17616
  thinkingOptionId: identity.optional(),
17441
17617
  permissionModeId: identity.optional()
17442
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17618
+ }).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, {
17619
+ message: "A service tier requires a Model ID"
17620
+ }),
17443
17621
  external_exports.strictObject({
17444
17622
  kind: external_exports.literal("prompt"),
17445
17623
  ...thread,
@@ -17489,7 +17667,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17489
17667
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
17490
17668
  external_exports.strictObject({
17491
17669
  action: external_exports.literal("read-thread"),
17492
- hostId: hostId.refine((id) => id !== "local"),
17670
+ hostId: hostId.refine((id2) => id2 !== "local"),
17493
17671
  input: delegationReadParamsSchema
17494
17672
  }),
17495
17673
  external_exports.strictObject({
@@ -17503,7 +17681,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17503
17681
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
17504
17682
  external_exports.strictObject({
17505
17683
  action: external_exports.literal("update"),
17506
- hostId: hostId.refine((id) => id !== "local"),
17684
+ hostId: hostId.refine((id2) => id2 !== "local"),
17507
17685
  version: remoteUpdateParamsSchema.shape.version
17508
17686
  })
17509
17687
  ]);
@@ -17571,7 +17749,7 @@ function invalidRequest(message) {
17571
17749
  return { code: "invalidRequest", message, retryable: false };
17572
17750
  }
17573
17751
  function validateHostApprovalResponse(interaction, response) {
17574
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17752
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17575
17753
  }
17576
17754
 
17577
17755
  // ../../harness-adapter/dist/question.js
@@ -17579,7 +17757,7 @@ function invalidRequest2(message) {
17579
17757
  return { code: "invalidRequest", message, retryable: false };
17580
17758
  }
17581
17759
  function validateHostQuestionResponse(interaction, response) {
17582
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17760
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
17583
17761
  if (response.cancelled) {
17584
17762
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
17585
17763
  }
@@ -17610,6 +17788,18 @@ function validateHostQuestionResponse(interaction, response) {
17610
17788
  return null;
17611
17789
  }
17612
17790
 
17791
+ // ../../harness-adapter/dist/legacy-model-ref.js
17792
+ import { Buffer as Buffer2 } from "node:buffer";
17793
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
17794
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
17795
+ return void 0;
17796
+ const encoded = ref.id.slice(prefix.length);
17797
+ const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
17798
+ if (Buffer2.from(id2).toString("base64url") !== encoded)
17799
+ return void 0;
17800
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
17801
+ }
17802
+
17613
17803
  // ../../harness-adapter/dist/output-channel.js
17614
17804
  var HarnessOutputChannel = class {
17615
17805
  outputs;
@@ -17694,7 +17884,8 @@ var tokenFields = [
17694
17884
  var safeIntegerFields = [
17695
17885
  "planFiveHourResetsAtUnix",
17696
17886
  "planSevenDayResetsAtUnix",
17697
- "timeToFirstOutputMs"
17887
+ "timeToFirstOutputMs",
17888
+ "latestRequestTimeToFirstOutputMs"
17698
17889
  ];
17699
17890
  var percentFields = [
17700
17891
  "cacheHitRatePercent",
@@ -19678,8 +19869,8 @@ var RequestResponder = class {
19678
19869
  signal;
19679
19870
  finishRequest;
19680
19871
  didRespond = false;
19681
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
19682
- this.id = id;
19872
+ constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
19873
+ this.id = id2;
19683
19874
  this.sendResult = sendResult;
19684
19875
  this.signal = signal;
19685
19876
  this.finishRequest = finishRequest;
@@ -19970,7 +20161,7 @@ var Connection = class {
19970
20161
  return this.sendWireMessage({ jsonrpc: "2.0", method, params });
19971
20162
  }
19972
20163
  prepareRequest(method, params, mapResponse, options = {}) {
19973
- const id = this.nextRequestId++;
20164
+ const id2 = this.nextRequestId++;
19974
20165
  let cancel = () => {
19975
20166
  };
19976
20167
  const response = new Promise((resolve, reject) => {
@@ -19990,7 +20181,7 @@ var Connection = class {
19990
20181
  }
19991
20182
  pendingResponse.cancellationSent = true;
19992
20183
  pendingResponse.cleanup?.();
19993
- void this.sendCancelRequest(id).catch(() => {
20184
+ void this.sendCancelRequest(id2).catch(() => {
19994
20185
  });
19995
20186
  };
19996
20187
  options.cancellationSignal?.addEventListener("abort", cancel, {
@@ -19999,12 +20190,12 @@ var Connection = class {
19999
20190
  pendingResponse.cleanup = () => {
20000
20191
  options.cancellationSignal?.removeEventListener("abort", cancel);
20001
20192
  };
20002
- this.pendingResponses.set(id, pendingResponse);
20193
+ this.pendingResponses.set(id2, pendingResponse);
20003
20194
  });
20004
20195
  response.catch(() => {
20005
20196
  });
20006
20197
  return {
20007
- message: { jsonrpc: "2.0", id, method, params },
20198
+ message: { jsonrpc: "2.0", id: id2, method, params },
20008
20199
  response,
20009
20200
  cancel: () => cancel()
20010
20201
  };
@@ -20641,7 +20832,7 @@ function memoryStreamPair() {
20641
20832
  }
20642
20833
  ];
20643
20834
  }
20644
- var methods = {
20835
+ var methods2 = {
20645
20836
  agent: {
20646
20837
  initialize: AGENT_METHODS.initialize,
20647
20838
  authenticate: AGENT_METHODS.authenticate,
@@ -22577,9 +22768,9 @@ function projectKimiUsages(payload) {
22577
22768
  });
22578
22769
  return parsed.success ? parsed.data : null;
22579
22770
  }
22580
- async function readNativeCredentials(filePath, readAuthFile) {
22771
+ async function readNativeCredentials(filePath2, readAuthFile) {
22581
22772
  try {
22582
- const raw = JSON.parse(await readAuthFile(filePath));
22773
+ const raw = JSON.parse(await readAuthFile(filePath2));
22583
22774
  if (!isRecord3(raw))
22584
22775
  return void 0;
22585
22776
  const parsed = credentialSchema.safeParse(raw);
@@ -22588,16 +22779,16 @@ async function readNativeCredentials(filePath, readAuthFile) {
22588
22779
  return void 0;
22589
22780
  }
22590
22781
  }
22591
- async function defaultWriteAuthFile(filePath, contents) {
22592
- const temporary = `${filePath}.${randomUUID()}.tmp`;
22782
+ async function defaultWriteAuthFile(filePath2, contents) {
22783
+ const temporary = `${filePath2}.${randomUUID()}.tmp`;
22593
22784
  try {
22594
22785
  await writeFile2(temporary, contents, { encoding: "utf8", mode: 384, flag: "wx" });
22595
- await rename(temporary, filePath);
22786
+ await rename(temporary, filePath2);
22596
22787
  } finally {
22597
22788
  await unlink(temporary).catch(() => void 0);
22598
22789
  }
22599
22790
  }
22600
- async function refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, signal, now) {
22791
+ async function refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, signal, now) {
22601
22792
  const refreshToken = stored.credentials.refresh_token;
22602
22793
  if (!refreshToken)
22603
22794
  return void 0;
@@ -22626,7 +22817,7 @@ async function refreshNativeCredentials(environment, stored, filePath, fetchImpl
22626
22817
  ...parsed.data.scope ? { scope: parsed.data.scope } : {},
22627
22818
  ...parsed.data.token_type ? { token_type: parsed.data.token_type } : {}
22628
22819
  };
22629
- await writeAuthFile(filePath, `${JSON.stringify(next, void 0, 2)}
22820
+ await writeAuthFile(filePath2, `${JSON.stringify(next, void 0, 2)}
22630
22821
  `).catch(() => void 0);
22631
22822
  stored.raw = next;
22632
22823
  stored.credentials = {
@@ -22642,18 +22833,18 @@ async function fetchKimiAccount(input = {}) {
22642
22833
  try {
22643
22834
  const environment = input.environment ?? process.env;
22644
22835
  const fromEnv = environment.KIMI_CODE_API_KEY?.trim() || environment.KIMI_API_KEY?.trim();
22645
- const readAuthFile = input.readAuthFile ?? ((filePath2) => readFile2(filePath2, "utf8"));
22836
+ const readAuthFile = input.readAuthFile ?? ((filePath3) => readFile2(filePath3, "utf8"));
22646
22837
  const writeAuthFile = input.writeAuthFile ?? defaultWriteAuthFile;
22647
22838
  const fetchImpl = input.fetch ?? fetch;
22648
22839
  const requestSignal = () => input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]) : AbortSignal.timeout(REQUEST_TIMEOUT_MS);
22649
22840
  const now = input.now ?? Date.now();
22650
- const filePath = credentialPath(environment);
22651
- const stored = fromEnv ? void 0 : await readNativeCredentials(filePath, readAuthFile);
22841
+ const filePath2 = credentialPath(environment);
22842
+ const stored = fromEnv ? void 0 : await readNativeCredentials(filePath2, readAuthFile);
22652
22843
  let token = fromEnv ?? stored?.credentials.access_token;
22653
22844
  if (!token)
22654
22845
  return null;
22655
22846
  if (stored && !accessTokenFresh(stored.credentials, now)) {
22656
- token = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now) ?? token;
22847
+ token = await refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, requestSignal(), now) ?? token;
22657
22848
  }
22658
22849
  const requestUsages = (accessToken) => fetchImpl(KIMI_USAGES_ENDPOINT, {
22659
22850
  method: "GET",
@@ -22662,7 +22853,7 @@ async function fetchKimiAccount(input = {}) {
22662
22853
  });
22663
22854
  let response = await requestUsages(token);
22664
22855
  if (response.status === 401 && stored?.credentials.refresh_token) {
22665
- const refreshed = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now);
22856
+ const refreshed = await refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, requestSignal(), now);
22666
22857
  if (!refreshed)
22667
22858
  return null;
22668
22859
  token = refreshed;
@@ -23989,19 +24180,11 @@ function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
23989
24180
  */
23990
24181
 
23991
24182
  // dist/models.js
23992
- var KIMI_MODEL_PREFIX = "kimi.";
23993
- function encodeKimiModelRef(alias) {
23994
- const encoded = Buffer.from(alias, "utf8").toString("base64url");
23995
- return harnessModelRefSchema.parse({
23996
- id: harnessModelRefIdSchema.parse(`${KIMI_MODEL_PREFIX}${encoded}`)
23997
- });
24183
+ function kimiModelRef(id2) {
24184
+ return harnessModelRefSchema.parse({ id: id2 });
23998
24185
  }
23999
- function decodeKimiModelRefId(id) {
24000
- if (!id.startsWith(KIMI_MODEL_PREFIX)) {
24001
- throw new Error(`Invalid Kimi model ref ID: ${id}`);
24002
- }
24003
- const payload = id.slice(KIMI_MODEL_PREFIX.length);
24004
- return Buffer.from(payload, "base64url").toString("utf8");
24186
+ function normalizeStoredKimiModelRef(ref, catalog) {
24187
+ return normalizeLegacyBase64ModelRef(ref, catalog, "kimi.");
24005
24188
  }
24006
24189
  var KIMI_MODES = ["default", "plan", "auto", "yolo"];
24007
24190
  function isKimiModeId(value) {
@@ -24056,7 +24239,7 @@ function parseKimiConfigToml(content) {
24056
24239
  } catch (error51) {
24057
24240
  throw new Error(`Failed to parse Kimi config.toml: ${error51 instanceof Error ? error51.message : String(error51)}`);
24058
24241
  }
24059
- const defaultModel = typeof parsed.default_model === "string" ? parsed.default_model.trim() : void 0;
24242
+ const defaultModel = typeof parsed.default_model === "string" ? parsed.default_model : void 0;
24060
24243
  const models = [];
24061
24244
  if (typeof parsed.models === "object" && parsed.models !== null) {
24062
24245
  for (const [alias, details] of Object.entries(parsed.models)) {
@@ -24123,17 +24306,17 @@ function buildModelCatalogFromConfig(config2, thinkingOptionsList) {
24123
24306
  thinkingOptions.set(option.id, option);
24124
24307
  const label = m.model ? `${m.alias} (${m.model})` : m.alias;
24125
24308
  return harnessModelSchema.parse({
24126
- ref: encodeKimiModelRef(m.alias),
24309
+ ref: kimiModelRef(m.alias),
24127
24310
  label: label.slice(0, 256),
24128
24311
  ...m.model ? { resolvedModelLabel: m.model.slice(0, 256) } : {},
24129
- supportedThinkingOptionIds: options.map(({ id }) => id)
24312
+ supportedThinkingOptionIds: options.map(({ id: id2 }) => id2)
24130
24313
  });
24131
24314
  });
24132
- const defaultModel = config2.defaultModel && models.some((m) => decodeKimiModelRefId(m.ref.id) === config2.defaultModel) ? encodeKimiModelRef(config2.defaultModel) : models[0]?.ref;
24133
- const selectedModel = models.find((model2) => model2.ref.id === defaultModel?.id);
24134
- const configuredDefault = config2.models.find((model2) => encodeKimiModelRef(model2.alias).id === defaultModel?.id)?.defaultEffort;
24315
+ const selectedModel = models.find((model2) => model2.ref.id === config2.defaultModel) ?? models[0];
24316
+ const defaultModel = selectedModel?.ref;
24317
+ const configuredDefault = config2.models.find((model2) => model2.alias === defaultModel?.id)?.defaultEffort;
24135
24318
  const requestedDefault = config2.thinking?.enabled === false ? "off" : config2.thinking?.effort ?? configuredDefault;
24136
- const defaultThinkingOptionId = selectedModel?.supportedThinkingOptionIds?.find((id) => id === requestedDefault);
24319
+ const defaultThinkingOptionId = selectedModel?.supportedThinkingOptionIds?.find((id2) => id2 === requestedDefault);
24137
24320
  return harnessModelCatalogSchema.parse({
24138
24321
  models,
24139
24322
  ...defaultModel ? { defaultModel } : {},
@@ -24473,9 +24656,9 @@ function activeKimiWireRecords(content) {
24473
24656
  }
24474
24657
  }
24475
24658
  const branches = /* @__PURE__ */ new Map();
24476
- let active = "main";
24659
+ let active2 = "main";
24477
24660
  let segment = { start: 0, end: records.length };
24478
- branches.set(active, segment);
24661
+ branches.set(active2, segment);
24479
24662
  for (const [index, record3] of records.entries()) {
24480
24663
  if (record3?.type !== "agent.switched")
24481
24664
  continue;
@@ -24491,19 +24674,19 @@ function activeKimiWireRecords(content) {
24491
24674
  end: records.length,
24492
24675
  base: { branch: base.branch, line: base.line }
24493
24676
  };
24494
- active = record3.branch;
24495
- branches.set(active, segment);
24677
+ active2 = record3.branch;
24678
+ branches.set(active2, segment);
24496
24679
  }
24497
24680
  const ranges = [];
24498
24681
  let end = records.length;
24499
24682
  for (; ; ) {
24500
- const branch = branches.get(active);
24683
+ const branch = branches.get(active2);
24501
24684
  if (!branch)
24502
- throw new Error(`Unknown Kimi branch: ${active}`);
24685
+ throw new Error(`Unknown Kimi branch: ${active2}`);
24503
24686
  ranges.push({ start: branch.start, end });
24504
24687
  if (!branch.base)
24505
24688
  break;
24506
- active = branch.base.branch;
24689
+ active2 = branch.base.branch;
24507
24690
  end = branch.base.line;
24508
24691
  }
24509
24692
  return ranges.reverse().flatMap(({ start, end: end2 }) => records.slice(start, end2)).filter((record3) => record3 !== void 0 && record3.type !== "agent.switched");
@@ -24698,10 +24881,10 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24698
24881
  } else if (type === "file_history.tracked") {
24699
24882
  const turnId = typeof record3.turnId === "number" ? record3.turnId : 0;
24700
24883
  const turn = getOrCreateTurn(turnId);
24701
- const filePath = typeof record3.path === "string" ? record3.path : void 0;
24884
+ const filePath2 = typeof record3.path === "string" ? record3.path : void 0;
24702
24885
  const entry = record3.entry;
24703
- if (filePath && entry) {
24704
- turn.fileHistoryTracked.set(filePath, {
24886
+ if (filePath2 && entry) {
24887
+ turn.fileHistoryTracked.set(filePath2, {
24705
24888
  key: typeof entry.key === "string" ? entry.key : null,
24706
24889
  version: typeof entry.version === "number" ? entry.version : 1
24707
24890
  });
@@ -24711,9 +24894,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24711
24894
  const turn = getOrCreateTurn(turnId);
24712
24895
  const entries = record3.entries;
24713
24896
  if (entries) {
24714
- for (const [filePath, entry] of Object.entries(entries)) {
24897
+ for (const [filePath2, entry] of Object.entries(entries)) {
24715
24898
  if (typeof entry?.key === "string") {
24716
- turn.fileHistoryCheckpoint.set(filePath, {
24899
+ turn.fileHistoryCheckpoint.set(filePath2, {
24717
24900
  key: entry.key,
24718
24901
  version: typeof entry.version === "number" ? entry.version : 1,
24719
24902
  ...typeof entry.size === "number" ? { size: entry.size } : {}
@@ -24866,9 +25049,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24866
25049
  ...turn.fileHistoryTracked.keys(),
24867
25050
  ...turn.fileHistoryCheckpoint.keys()
24868
25051
  ]);
24869
- for (const filePath of allPaths) {
24870
- const tracked = turn.fileHistoryTracked.get(filePath);
24871
- const checkpoint = turn.fileHistoryCheckpoint.get(filePath);
25052
+ for (const filePath2 of allPaths) {
25053
+ const tracked = turn.fileHistoryTracked.get(filePath2);
25054
+ const checkpoint = turn.fileHistoryCheckpoint.get(filePath2);
24872
25055
  let oldContent = "";
24873
25056
  let newContent = "";
24874
25057
  if (tracked?.key) {
@@ -24887,9 +25070,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24887
25070
  }
24888
25071
  if (oldContent !== newContent) {
24889
25072
  const kind = !tracked || tracked.key === null ? "add" : !checkpoint ? "delete" : "update";
24890
- const patch = createTwoFilesPatch(filePath, filePath, oldContent, newContent, "", "");
25073
+ const patch = createTwoFilesPatch(filePath2, filePath2, oldContent, newContent, "", "");
24891
25074
  changes.push({
24892
- path: filePath.replaceAll("\\", "/"),
25075
+ path: filePath2.replaceAll("\\", "/"),
24893
25076
  kind,
24894
25077
  unifiedDiff: patch
24895
25078
  });
@@ -24941,7 +25124,7 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24941
25124
  input: turn.input.length > 0 ? turn.input : [{ type: "text", text: "" }],
24942
25125
  items,
24943
25126
  outcome,
24944
- ...turn.model ? { model: encodeKimiModelRef(turn.model) } : {},
25127
+ ...turn.model ? { model: kimiModelRef(turn.model) } : {},
24945
25128
  ...turn.startedAtMs !== void 0 ? { startedAtMs: turn.startedAtMs } : {},
24946
25129
  ...turn.completedAtMs !== void 0 ? { completedAtMs: turn.completedAtMs } : {}
24947
25130
  });
@@ -25730,7 +25913,7 @@ var KimiSession = class {
25730
25913
  delete state.effectiveThinkingOptionId;
25731
25914
  delete state.effectivePermissionModeId;
25732
25915
  if (effective.modelAlias)
25733
- state.effectiveModel = encodeKimiModelRef(effective.modelAlias);
25916
+ state.effectiveModel = kimiModelRef(effective.modelAlias);
25734
25917
  if (effective.thinkingOptionId)
25735
25918
  state.effectiveThinkingOptionId = effective.thinkingOptionId;
25736
25919
  if (effective.permissionModeId)
@@ -26319,32 +26502,32 @@ var KimiSession = class {
26319
26502
  return ok({ cancellationRequested: true });
26320
26503
  }
26321
26504
  async #handleInteractionRespond(command) {
26322
- const active = this.#activeInteractions.get(command.interactionId);
26323
- if (!active) {
26505
+ const active2 = this.#activeInteractions.get(command.interactionId);
26506
+ if (!active2) {
26324
26507
  return err("invalidRequest", `No active interaction matches ID ${command.interactionId}`);
26325
26508
  }
26326
- const turnId = active.interaction.turnId;
26327
- if (active.type === "approval") {
26509
+ const turnId = active2.interaction.turnId;
26510
+ if (active2.type === "approval") {
26328
26511
  if (command.response.type !== "approval") {
26329
26512
  return err("invalidRequest", `Expected approval response for interaction ${command.interactionId}`);
26330
26513
  }
26331
- const validation = validateHostApprovalResponse(active.interaction, command.response);
26514
+ const validation = validateHostApprovalResponse(active2.interaction, command.response);
26332
26515
  if (validation) {
26333
26516
  return err(validation.code, validation.message);
26334
26517
  }
26335
26518
  this.#activeInteractions.delete(command.interactionId);
26336
- const optionIdMap = active.metadata;
26519
+ const optionIdMap = active2.metadata;
26337
26520
  const selectedOptionId = optionIdMap?.get(command.response.actionId) || command.response.actionId;
26338
26521
  this.#channel.emit({
26339
26522
  kind: "event",
26340
26523
  event: {
26341
26524
  type: "interaction.closed",
26342
- interactionId: active.id,
26525
+ interactionId: active2.id,
26343
26526
  turnId,
26344
26527
  reason: "responded"
26345
26528
  }
26346
26529
  });
26347
- active.resolve({
26530
+ active2.resolve({
26348
26531
  outcome: {
26349
26532
  outcome: "selected",
26350
26533
  optionId: selectedOptionId
@@ -26352,38 +26535,33 @@ var KimiSession = class {
26352
26535
  });
26353
26536
  return ok({ accepted: true });
26354
26537
  }
26355
- if (active.type === "question") {
26538
+ if (active2.type === "question") {
26356
26539
  if (command.response.type !== "question") {
26357
26540
  return err("invalidRequest", `Expected question response for interaction ${command.interactionId}`);
26358
26541
  }
26359
- const validation = validateHostQuestionResponse(active.interaction, command.response);
26542
+ const validation = validateHostQuestionResponse(active2.interaction, command.response);
26360
26543
  if (validation) {
26361
26544
  return err(validation.code, validation.message);
26362
26545
  }
26363
26546
  this.#activeInteractions.delete(command.interactionId);
26364
- const schemaProps = active.metadata;
26547
+ const schemaProps = active2.metadata;
26365
26548
  const elicitationResponse = formatElicitationResponse(command.response, schemaProps);
26366
26549
  this.#channel.emit({
26367
26550
  kind: "event",
26368
26551
  event: {
26369
26552
  type: "interaction.closed",
26370
- interactionId: active.id,
26553
+ interactionId: active2.id,
26371
26554
  turnId,
26372
26555
  reason: command.response.cancelled ? "cancelled" : "responded"
26373
26556
  }
26374
26557
  });
26375
- active.resolve(elicitationResponse);
26558
+ active2.resolve(elicitationResponse);
26376
26559
  return ok({ accepted: true });
26377
26560
  }
26378
26561
  return err("invalidRequest", `Interaction type mismatch for ${command.interactionId}`);
26379
26562
  }
26380
26563
  async #handleModelSelect(command) {
26381
- let alias;
26382
- try {
26383
- alias = decodeKimiModelRefId(command.model.id);
26384
- } catch {
26385
- return err("invalidRequest", `Invalid model reference: ${command.model.id}`);
26386
- }
26564
+ const alias = command.model.id;
26387
26565
  try {
26388
26566
  const confirmed = await this.#transport.setConfigOption("model", alias);
26389
26567
  this.#applyConfigOptions(confirmed);
@@ -26396,7 +26574,7 @@ var KimiSession = class {
26396
26574
  }
26397
26575
  }
26398
26576
  async #handleThinkingSelect(command) {
26399
- if (!this.#state.availableThinkingOptions?.some(({ id }) => id === command.thinkingOptionId)) {
26577
+ if (!this.#state.availableThinkingOptions?.some(({ id: id2 }) => id2 === command.thinkingOptionId)) {
26400
26578
  return err("invalidRequest", new KimiThinkingSelectionError(command.thinkingOptionId).message);
26401
26579
  }
26402
26580
  try {
@@ -26522,7 +26700,7 @@ function err2(code, message, retryable = false) {
26522
26700
  async function applyRequestedConfig(transport, configOptions, requested) {
26523
26701
  let confirmed = configOptions ?? [];
26524
26702
  for (const option of requested) {
26525
- if (option.id === "thinking" && !readKimiThinkingOptions(confirmed).some(({ id }) => id === option.value)) {
26703
+ if (option.id === "thinking" && !readKimiThinkingOptions(confirmed).some(({ id: id2 }) => id2 === option.value)) {
26526
26704
  throw new KimiThinkingSelectionError(option.value);
26527
26705
  }
26528
26706
  confirmed = await transport.setConfigOption(option.id, option.value);
@@ -26539,7 +26717,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
26539
26717
  return {
26540
26718
  nativeRef: createKimiNativeSessionRef(sessionId, cwd),
26541
26719
  availableThinkingOptions: readKimiThinkingOptions(configOptions),
26542
- ...effective.modelAlias ? { effectiveModel: encodeKimiModelRef(effective.modelAlias) } : {},
26720
+ ...effective.modelAlias ? { effectiveModel: kimiModelRef(effective.modelAlias) } : {},
26543
26721
  ...effective.thinkingOptionId ? { effectiveThinkingOptionId: effective.thinkingOptionId } : {},
26544
26722
  ...effective.permissionModeId ? {
26545
26723
  effectivePermissionModeId: harnessPermissionModeIdSchema.parse(effective.permissionModeId)
@@ -26547,6 +26725,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
26547
26725
  };
26548
26726
  }
26549
26727
  var KimiAdapter = class {
26728
+ normalizeStoredModelRef = normalizeStoredKimiModelRef;
26550
26729
  harnessId = kimiHarnessId3;
26551
26730
  sessionImport;
26552
26731
  #options;
@@ -26682,13 +26861,7 @@ var KimiAdapter = class {
26682
26861
  if ("permissionModeId" in input && input.permissionModeId && !isKimiModeId(input.permissionModeId)) {
26683
26862
  return err2("invalidRequest", `Unsupported permission mode: ${input.permissionModeId}`);
26684
26863
  }
26685
- let requestedModelAlias;
26686
- try {
26687
- if ("model" in input && input.model)
26688
- requestedModelAlias = decodeKimiModelRefId(input.model.id);
26689
- } catch (error51) {
26690
- return err2("invalidRequest", error51 instanceof Error ? error51.message : String(error51));
26691
- }
26864
+ const requestedModelAlias = "model" in input ? input.model?.id : void 0;
26692
26865
  const environment = { ...process.env, ...this.#options.environment, ...input.environment };
26693
26866
  const cwd = input.cwd ?? process.cwd();
26694
26867
  const kimiCodeHome = getKimiCodeHome(this.#options.homeDirectory, environment);
@@ -26736,7 +26909,7 @@ var KimiAdapter = class {
26736
26909
  }
26737
26910
  const permissionModeId = input.permissionModeId ?? (unattended ? "yolo" : void 0);
26738
26911
  const requested = [
26739
- ...input.model ? [{ id: "model", value: decodeKimiModelRefId(input.model.id) }] : [],
26912
+ ...input.model ? [{ id: "model", value: input.model.id }] : [],
26740
26913
  ...input.thinkingOptionId ? [{ id: "thinking", value: input.thinkingOptionId }] : [],
26741
26914
  ...permissionModeId ? [{ id: "mode", value: permissionModeId }] : []
26742
26915
  ];
@@ -26858,7 +27031,7 @@ var KimiAdapter = class {
26858
27031
  throw new Error(`Unsupported permission mode: ${input.permissionModeId}`);
26859
27032
  }
26860
27033
  const requested = [
26861
- ...input.model ? [{ id: "model", value: decodeKimiModelRefId(input.model.id) }] : [],
27034
+ ...input.model ? [{ id: "model", value: input.model.id }] : [],
26862
27035
  ...input.thinkingOptionId ? [{ id: "thinking", value: input.thinkingOptionId }] : [],
26863
27036
  ...input.permissionModeId ? [{ id: "mode", value: input.permissionModeId }] : []
26864
27037
  ];
@@ -26944,7 +27117,7 @@ var KimiAdapter = class {
26944
27117
  nativeRef: createKimiNativeSessionRef(derivedId, input.cwd),
26945
27118
  cwd: input.cwd,
26946
27119
  environment,
26947
- model: input.model ?? encodeKimiModelRef(rolledBack.model),
27120
+ model: input.model ?? kimiModelRef(rolledBack.model),
26948
27121
  thinkingOptionId: input.thinkingOptionId ?? harnessThinkingOptionIdSchema.parse(rolledBack.thinking),
26949
27122
  permissionModeId: input.permissionModeId ?? harnessPermissionModeIdSchema.parse(rolledBack.mode)
26950
27123
  });