@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
  }
@@ -1625,8 +1625,8 @@ function cleanEnum(obj2) {
1625
1625
  return Number.isNaN(Number.parseInt(k, 10));
1626
1626
  }).map((el) => el[1]);
1627
1627
  }
1628
- function base64ToUint8Array(base643) {
1629
- const binaryString = atob(base643);
1628
+ function base64ToUint8Array(base644) {
1629
+ const binaryString = atob(base644);
1630
1630
  const bytes = new Uint8Array(binaryString.length);
1631
1631
  for (let i = 0; i < binaryString.length; i++) {
1632
1632
  bytes[i] = binaryString.charCodeAt(i);
@@ -1641,9 +1641,9 @@ function uint8ArrayToBase64(bytes) {
1641
1641
  return btoa(binaryString);
1642
1642
  }
1643
1643
  function base64urlToUint8Array(base64url3) {
1644
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1645
- const padding = "=".repeat((4 - base643.length % 4) % 4);
1646
- return base64ToUint8Array(base643 + padding);
1644
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1645
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
1646
+ return base64ToUint8Array(base644 + padding);
1647
1647
  }
1648
1648
  function uint8ArrayToBase64url(bytes) {
1649
1649
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -3009,8 +3009,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
3009
3009
  function isValidBase64URL(data) {
3010
3010
  if (!base64url.test(data))
3011
3011
  return false;
3012
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3013
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
3012
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3013
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
3014
3014
  return isValidBase64(padded);
3015
3015
  }
3016
3016
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -3464,42 +3464,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3464
3464
  }
3465
3465
  doc.write(`const newResult = {};`);
3466
3466
  for (const key of normalized.keys) {
3467
- const id = ids[key];
3467
+ const id2 = ids[key];
3468
3468
  const k = esc(key);
3469
3469
  const schema = shape[key];
3470
3470
  const isOptionalIn = schema?._zod?.optin === "optional";
3471
3471
  const isOptionalOut = schema?._zod?.optout === "optional";
3472
- doc.write(`const ${id} = ${parseStr(key)};`);
3472
+ doc.write(`const ${id2} = ${parseStr(key)};`);
3473
3473
  if (isOptionalIn && isOptionalOut) {
3474
3474
  doc.write(`
3475
- if (${id}.issues.length) {
3475
+ if (${id2}.issues.length) {
3476
3476
  if (${k} in input) {
3477
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3477
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3478
3478
  ...iss,
3479
3479
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3480
3480
  })));
3481
3481
  }
3482
3482
  }
3483
3483
 
3484
- if (${id}.value === undefined) {
3484
+ if (${id2}.value === undefined) {
3485
3485
  if (${k} in input) {
3486
3486
  newResult[${k}] = undefined;
3487
3487
  }
3488
3488
  } else {
3489
- newResult[${k}] = ${id}.value;
3489
+ newResult[${k}] = ${id2}.value;
3490
3490
  }
3491
3491
 
3492
3492
  `);
3493
3493
  } else if (!isOptionalIn) {
3494
3494
  doc.write(`
3495
- const ${id}_present = ${k} in input;
3496
- if (${id}.issues.length) {
3497
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3495
+ const ${id2}_present = ${k} in input;
3496
+ if (${id2}.issues.length) {
3497
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3498
3498
  ...iss,
3499
3499
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3500
3500
  })));
3501
3501
  }
3502
- if (!${id}_present && !${id}.issues.length) {
3502
+ if (!${id2}_present && !${id2}.issues.length) {
3503
3503
  payload.issues.push({
3504
3504
  code: "invalid_type",
3505
3505
  expected: "nonoptional",
@@ -3508,30 +3508,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3508
3508
  });
3509
3509
  }
3510
3510
 
3511
- if (${id}_present) {
3512
- if (${id}.value === undefined) {
3511
+ if (${id2}_present) {
3512
+ if (${id2}.value === undefined) {
3513
3513
  newResult[${k}] = undefined;
3514
3514
  } else {
3515
- newResult[${k}] = ${id}.value;
3515
+ newResult[${k}] = ${id2}.value;
3516
3516
  }
3517
3517
  }
3518
3518
 
3519
3519
  `);
3520
3520
  } else {
3521
3521
  doc.write(`
3522
- if (${id}.issues.length) {
3523
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3522
+ if (${id2}.issues.length) {
3523
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3524
3524
  ...iss,
3525
3525
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3526
3526
  })));
3527
3527
  }
3528
3528
 
3529
- if (${id}.value === undefined) {
3529
+ if (${id2}.value === undefined) {
3530
3530
  if (${k} in input) {
3531
3531
  newResult[${k}] = undefined;
3532
3532
  }
3533
3533
  } else {
3534
- newResult[${k}] = ${id}.value;
3534
+ newResult[${k}] = ${id2}.value;
3535
3535
  }
3536
3536
 
3537
3537
  `);
@@ -11863,26 +11863,26 @@ function extractDefs(ctx, schema) {
11863
11863
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11864
11864
  const idToSchema = /* @__PURE__ */ new Map();
11865
11865
  for (const entry of ctx.seen.entries()) {
11866
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11867
- if (id) {
11868
- const existing = idToSchema.get(id);
11866
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11867
+ if (id2) {
11868
+ const existing = idToSchema.get(id2);
11869
11869
  if (existing && existing !== entry[0]) {
11870
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11870
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11871
11871
  }
11872
- idToSchema.set(id, entry[0]);
11872
+ idToSchema.set(id2, entry[0]);
11873
11873
  }
11874
11874
  }
11875
11875
  const makeURI = (entry) => {
11876
11876
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11877
11877
  if (ctx.external) {
11878
11878
  const externalId = ctx.external.registry.get(entry[0])?.id;
11879
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11879
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
11880
11880
  if (externalId) {
11881
11881
  return { ref: uriGenerator(externalId) };
11882
11882
  }
11883
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11884
- entry[1].defId = id;
11885
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
11883
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11884
+ entry[1].defId = id2;
11885
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
11886
11886
  }
11887
11887
  if (entry[1] === root) {
11888
11888
  return { ref: "#" };
@@ -11930,8 +11930,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11930
11930
  continue;
11931
11931
  }
11932
11932
  }
11933
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11934
- if (id) {
11933
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11934
+ if (id2) {
11935
11935
  extractToDef(entry);
11936
11936
  continue;
11937
11937
  }
@@ -12027,10 +12027,10 @@ function finalize(ctx, schema) {
12027
12027
  } else {
12028
12028
  }
12029
12029
  if (ctx.external?.uri) {
12030
- const id = ctx.external.registry.get(schema)?.id;
12031
- if (!id)
12030
+ const id2 = ctx.external.registry.get(schema)?.id;
12031
+ if (!id2)
12032
12032
  throw new Error("Schema is missing an `id` property");
12033
- result.$id = ctx.external.uri(id);
12033
+ result.$id = ctx.external.uri(id2);
12034
12034
  }
12035
12035
  Object.assign(result, root.def ?? root.schema);
12036
12036
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -12190,9 +12190,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12190
12190
  json2.type = "number";
12191
12191
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
12192
12192
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
12193
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12193
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12194
12194
  if (exMin) {
12195
- if (legacy) {
12195
+ if (legacy2) {
12196
12196
  json2.minimum = exclusiveMinimum;
12197
12197
  json2.exclusiveMinimum = true;
12198
12198
  } else {
@@ -12202,7 +12202,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12202
12202
  json2.minimum = minimum;
12203
12203
  }
12204
12204
  if (exMax) {
12205
- if (legacy) {
12205
+ if (legacy2) {
12206
12206
  json2.maximum = exclusiveMaximum;
12207
12207
  json2.exclusiveMaximum = true;
12208
12208
  } else {
@@ -13064,7 +13064,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
13064
13064
 
13065
13065
  // ../../../node_modules/zod/v4/classic/schemas.js
13066
13066
  var _installedGroups = /* @__PURE__ */ new WeakMap();
13067
- function _installLazyMethods(inst, group, methods2) {
13067
+ function _installLazyMethods(inst, group, methods3) {
13068
13068
  const proto = Object.getPrototypeOf(inst);
13069
13069
  let installed = _installedGroups.get(proto);
13070
13070
  if (!installed) {
@@ -13074,8 +13074,8 @@ function _installLazyMethods(inst, group, methods2) {
13074
13074
  if (installed.has(group))
13075
13075
  return;
13076
13076
  installed.add(group);
13077
- for (const key in methods2) {
13078
- const fn = methods2[key];
13077
+ for (const key in methods3) {
13078
+ const fn = methods3[key];
13079
13079
  Object.defineProperty(proto, key, {
13080
13080
  configurable: true,
13081
13081
  enumerable: false,
@@ -14886,87 +14886,6 @@ function date4(params) {
14886
14886
  // ../../../node_modules/zod/v4/classic/external.js
14887
14887
  config(en_default());
14888
14888
 
14889
- // ../../shared-contracts/dist/ids.js
14890
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14891
- message: "Identifier must not be empty or whitespace"
14892
- });
14893
- var harnessIdSchema = opaqueIdSchema.brand();
14894
- var hostThreadIdSchema = opaqueIdSchema.brand();
14895
- var hostTurnIdSchema = opaqueIdSchema.brand();
14896
- var hostItemIdSchema = opaqueIdSchema.brand();
14897
- var hostInteractionIdSchema = opaqueIdSchema.brand();
14898
-
14899
- // ../../shared-contracts/dist/harness-plugins.js
14900
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
14901
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
14902
- var HARNESS_PLUGIN_LIMIT = 128;
14903
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
14904
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
14905
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
14906
- 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");
14907
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
14908
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
14909
- var harnessInstallationGuideSchema = external_exports.object({
14910
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
14911
- before: localizedTextSchema.optional(),
14912
- after: localizedTextSchema.optional(),
14913
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
14914
- }).strict();
14915
- var pluginPresentationShape = {
14916
- id: installedHarnessPluginIdSchema,
14917
- name: external_exports.string().trim().min(1).max(128),
14918
- version: external_exports.string().min(1).max(128),
14919
- /** Capability-only plugin; omitted for existing session-capable plugins. */
14920
- kind: external_exports.literal("usage").optional(),
14921
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
14922
- iconStyle: external_exports.object({
14923
- vector: external_exports.object({
14924
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
14925
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
14926
- paths: external_exports.array(external_exports.object({
14927
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
14928
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
14929
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
14930
- }).strict()).min(1).max(32)
14931
- }).strict().optional(),
14932
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
14933
- borderRadius: external_exports.number().min(0).max(50).optional(),
14934
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
14935
- }).strict().optional(),
14936
- installation: harnessInstallationGuideSchema.optional(),
14937
- notice: localizedTextSchema.optional(),
14938
- /** The factory accepts a persisted local entrypoint through its construction context. */
14939
- launchCommand: external_exports.literal(true).optional(),
14940
- links: external_exports.object({
14941
- website: documentationUrlSchema.optional(),
14942
- documentation: documentationUrlSchema.optional(),
14943
- installation: documentationUrlSchema.optional()
14944
- }).strict().optional()
14945
- };
14946
- var harnessPluginManifestSchema = external_exports.object({
14947
- manifestVersion: external_exports.literal(1),
14948
- ...pluginPresentationShape,
14949
- adapterApiVersion: external_exports.number().int().positive(),
14950
- entry: pluginRelativeResourceSchema,
14951
- icon: pluginRelativeResourceSchema.optional()
14952
- }).strict();
14953
- 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);
14954
- var harnessPluginDescriptorSchema = external_exports.object({
14955
- ...pluginPresentationShape,
14956
- icon: harnessPluginIconSchema.optional()
14957
- }).strict();
14958
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
14959
- var harnessPluginListResultSchema = external_exports.object({
14960
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
14961
- }).strict();
14962
- var harnessPluginConfigurationSchema = external_exports.object({
14963
- version: external_exports.literal(1),
14964
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
14965
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
14966
- message: "Enabled plugin IDs must be unique",
14967
- path: ["enabled"]
14968
- });
14969
-
14970
14889
  // ../../shared-contracts/dist/json-value.js
14971
14890
  function rejectExplicitUndefined(keys) {
14972
14891
  return (value, context) => {
@@ -15026,403 +14945,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
15026
14945
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
15027
14946
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
15028
14947
 
15029
- // ../../shared-contracts/dist/desktop-extensions.js
15030
- var DESKTOP_EXTENSION_API_VERSION = 1;
15031
- var DESKTOP_EXTENSION_LIMIT = 64;
15032
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15033
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
15034
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15035
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15036
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15037
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15038
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15039
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15040
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15041
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15042
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15043
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15044
- var desktopExtensionIdSchema = installedPluginIdSchema;
15045
- var desktopExtensionSlotSchema = external_exports.enum([
15046
- "sidebar.thread-layout",
15047
- "sidebar.thread-badge",
15048
- "appearance.theme"
15049
- ]);
15050
- var desktopExtensionCategorySchema = external_exports.enum([
15051
- "appearance",
15052
- "interface",
15053
- "workflow",
15054
- "analytics",
15055
- "integrations",
15056
- "tools"
15057
- ]);
15058
- var extensionName = external_exports.string().trim().min(1).max(128);
15059
- function desktopExtensionScreenshotMimeType(resource) {
15060
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15061
- case "png":
15062
- return "image/png";
15063
- case "jpg":
15064
- case "jpeg":
15065
- return "image/jpeg";
15066
- case "webp":
15067
- return "image/webp";
15068
- default:
15069
- return void 0;
14948
+ // ../../shared-contracts/dist/errors.js
14949
+ var codexhostErrorSchema = external_exports.strictObject({
14950
+ code: external_exports.string().min(1),
14951
+ message: external_exports.string().min(1),
14952
+ retryable: external_exports.boolean(),
14953
+ diagnostic: external_exports.string().min(1).optional(),
14954
+ stage: external_exports.string().min(1).optional(),
14955
+ durationMs: external_exports.number().int().nonnegative().optional(),
14956
+ stderrTail: external_exports.string().min(1).optional()
14957
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
14958
+
14959
+ // ../../shared-contracts/dist/harness-presentation.js
14960
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
14961
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
14962
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
14963
+ label: displayText(256).optional(),
14964
+ description: displayText(1024).optional()
14965
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
14966
+ 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");
14967
+
14968
+ // ../../shared-contracts/dist/ids.js
14969
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14970
+ message: "Identifier must not be empty or whitespace"
14971
+ });
14972
+ var harnessIdSchema = opaqueIdSchema.brand();
14973
+ var hostThreadIdSchema = opaqueIdSchema.brand();
14974
+ var hostTurnIdSchema = opaqueIdSchema.brand();
14975
+ var hostItemIdSchema = opaqueIdSchema.brand();
14976
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
14977
+
14978
+ // ../../shared-contracts/dist/harness-permission-modes.js
14979
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
14980
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
14981
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
14982
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
14983
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
14984
+ message: "Value must not be empty or whitespace"
14985
+ });
14986
+ 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();
14987
+ var harnessPermissionModeSchema = external_exports.object({
14988
+ id: harnessPermissionModeIdSchema,
14989
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
14990
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
14991
+ dangerous: external_exports.boolean().optional(),
14992
+ localizations: harnessLocalizationsSchema.optional()
14993
+ }).strict();
14994
+ var harnessPermissionModeCatalogSchema = external_exports.object({
14995
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
14996
+ defaultModeId: harnessPermissionModeIdSchema
14997
+ }).strict().superRefine((catalog, context) => {
14998
+ const ids = /* @__PURE__ */ new Set();
14999
+ for (const [index, mode] of catalog.modes.entries()) {
15000
+ if (ids.has(mode.id)) {
15001
+ context.addIssue({
15002
+ code: "custom",
15003
+ message: "Permission Mode IDs must be unique",
15004
+ path: ["modes", index, "id"]
15005
+ });
15006
+ }
15007
+ ids.add(mode.id);
15070
15008
  }
15071
- }
15072
- function desktopExtensionAssetMimeType(resource) {
15073
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15074
- case "gif":
15075
- return "image/gif";
15076
- case "svg":
15077
- return "image/svg+xml";
15078
- case "woff2":
15079
- return "font/woff2";
15080
- case "json":
15081
- return "application/json";
15082
- case "css":
15083
- return "text/css";
15084
- default:
15085
- return desktopExtensionScreenshotMimeType(resource);
15086
- }
15087
- }
15088
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15089
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
15090
- 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");
15091
- 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) => {
15092
- const { username, password } = new URL(value);
15093
- return !username && !password && !/[\\\s]/u.test(value);
15094
- }, "URL must not contain credentials, backslashes, or whitespace");
15095
- function localizedText(text) {
15096
- return external_exports.strictObject({ en: text, "zh-CN": text });
15097
- }
15098
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15099
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15100
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15101
- var settingField = {
15102
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15103
- label: desktopExtensionLocalizedTextSchema,
15104
- description: desktopExtensionLocalizedTextSchema.optional()
15105
- };
15106
- var numericSetting = {
15107
- ...settingField,
15108
- step: external_exports.number().positive().optional(),
15109
- default: external_exports.number().optional()
15110
- };
15111
- var settingOption = external_exports.strictObject({
15112
- value: external_exports.string(),
15113
- label: desktopExtensionLocalizedTextSchema
15114
- });
15115
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15116
- external_exports.strictObject({
15117
- ...settingField,
15118
- type: external_exports.literal("boolean"),
15119
- default: external_exports.boolean().optional()
15120
- }),
15121
- external_exports.strictObject({
15122
- ...settingField,
15123
- type: external_exports.literal("string"),
15124
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
15125
- default: external_exports.string().optional()
15126
- }),
15127
- external_exports.strictObject({
15128
- ...numericSetting,
15129
- type: external_exports.literal("number"),
15130
- min: external_exports.number().optional(),
15131
- max: external_exports.number().optional()
15132
- }),
15133
- external_exports.strictObject({
15134
- ...numericSetting,
15135
- type: external_exports.literal("range"),
15136
- min: external_exports.number(),
15137
- max: external_exports.number()
15138
- }),
15139
- external_exports.strictObject({
15140
- ...settingField,
15141
- type: external_exports.literal("select"),
15142
- options: external_exports.array(settingOption).min(1),
15143
- default: external_exports.string().optional()
15144
- })
15145
- ]).superRefine((field2, ctx) => {
15146
- const issue2 = (path11, message) => ctx.addIssue({ code: "custom", path: [path11], message });
15147
- if (field2.type === "number" || field2.type === "range") {
15148
- const { min = -Infinity, max = Infinity, default: value } = field2;
15149
- if (min > max)
15150
- issue2("max", "Must be at least min");
15151
- if (value !== void 0 && (value < min || value > max))
15152
- issue2("default", "Must be within min and max");
15153
- } else if (field2.type === "select") {
15154
- const values = new Set(field2.options.map(({ value }) => value));
15155
- if (values.size !== field2.options.length)
15156
- issue2("options", "Duplicate option values");
15157
- if (field2.default !== void 0 && !values.has(field2.default))
15158
- issue2("default", "Must match an option value");
15159
- }
15160
- });
15161
- var manifestHeader = external_exports.object({
15162
- manifestVersion: external_exports.int().positive(),
15163
- id: desktopExtensionIdSchema,
15164
- name: external_exports.union([extensionName, localizedText(extensionName)]),
15165
- version: external_exports.string().min(1).max(128),
15166
- desktopApi: external_exports.int().positive()
15167
- }).passthrough();
15168
- var desktopExtensionManifestSchema = manifestHeader.extend({
15169
- manifestVersion: external_exports.literal(1),
15170
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15171
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15172
- author: external_exports.string().trim().min(1).max(128).optional(),
15173
- repository: desktopExtensionHttpUrlSchema.optional(),
15174
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15175
- icon: imagePathSchema.optional(),
15176
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15177
- desktop: external_exports.strictObject({
15178
- script: pluginRelativeResourceSchema,
15179
- style: pluginRelativeResourceSchema.optional()
15180
- }).optional(),
15181
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15182
- slots: slotsSchema.default(() => []),
15183
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15184
- categories: categoriesSchema.optional()
15185
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15186
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
15187
- version: external_exports.literal(1),
15188
- revision: external_exports.int().nonnegative(),
15189
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
15190
- reloadToken: external_exports.uuid().optional()
15191
- });
15192
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15193
- var desktopExtensionStatusSchema = external_exports.strictObject({
15194
- state: external_exports.enum([
15195
- "running",
15196
- "disabled",
15197
- "invalid",
15198
- "incompatible",
15199
- "conflict",
15200
- "failed",
15201
- "waiting"
15202
- ]),
15203
- hash: desktopExtensionHashSchema.optional(),
15204
- error: external_exports.string().optional(),
15205
- conflictWith: desktopExtensionIdSchema.optional()
15206
- });
15207
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15208
- controllerPid: external_exports.int().positive(),
15209
- targetId: external_exports.string().nullable(),
15210
- updatedAt: external_exports.iso.datetime(),
15211
- handledReloadToken: external_exports.uuid().optional(),
15212
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
15213
- });
15214
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15215
- function isGitHubDesktopExtensionZipballUrl(url2) {
15216
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15217
- }
15218
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15219
- const url2 = new URL(input);
15220
- 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);
15221
- }, "Expected a .zip download URL or a GitHub zipball URL");
15222
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15223
- id: desktopExtensionIdSchema,
15224
- version: external_exports.string().trim().min(1).max(128),
15225
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15226
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
15227
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15228
- author: external_exports.string().trim().min(1).max(128),
15229
- repository: desktopExtensionHttpUrlSchema,
15230
- stars: external_exports.number().int().min(0).optional(),
15231
- downloads: external_exports.number().int().min(0).optional(),
15232
- categories: categoriesSchema.optional(),
15233
- trustTier: desktopExtensionTrustTierSchema.default("community"),
15234
- icon: desktopExtensionHttpUrlSchema.optional(),
15235
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15236
- downloadUrl: desktopExtensionZipUrlSchema,
15237
- sha256: desktopExtensionHashSchema,
15238
- slots: slotsSchema.optional(),
15239
- publishedAt: external_exports.string().optional(),
15240
- updatedAt: external_exports.string().optional(),
15241
- minCodexHostVersion: external_exports.string().optional()
15242
- });
15243
- var desktopExtensionCatalogSchema = external_exports.strictObject({
15244
- schemaVersion: external_exports.literal(1),
15245
- generatedAt: external_exports.string(),
15246
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
15247
- });
15248
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
15249
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
15250
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
15251
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
15252
- var extensionIdParams = { id: desktopExtensionIdSchema };
15253
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
15254
- ...extensionIdParams,
15255
- path: desktopExtensionAssetPathSchema
15256
- });
15257
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
15258
- mimeType: external_exports.string(),
15259
- dataUrl: external_exports.string()
15260
- });
15261
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
15262
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
15263
- ...extensionIdParams,
15264
- values: jsonObjectSchema
15265
- });
15266
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
15267
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15268
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
15269
- ...extensionIdParams,
15270
- method: desktopExtensionBackendMethodSchema,
15271
- params: jsonValueSchema.optional()
15272
- });
15273
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
15274
- result: jsonValueSchema
15275
- });
15276
-
15277
- // ../../shared-contracts/dist/desktop-extension-management.js
15278
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
15279
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
15280
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
15281
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
15282
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
15283
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
15284
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
15285
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
15286
- DESKTOP_EXTENSIONS_LIST_METHOD,
15287
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
15288
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
15289
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
15290
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
15291
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
15292
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
15293
- DESKTOP_EXTENSIONS_ASSET_METHOD,
15294
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
15295
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
15296
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
15297
- ];
15298
- var revisionSchema = external_exports.int().nonnegative();
15299
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
15300
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
15301
- id: desktopExtensionIdSchema,
15302
- expectedRevision: revisionSchema
15303
- });
15304
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
15305
- expectedRevision: revisionSchema.optional()
15306
- });
15307
- 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);
15308
- var desktopExtensionListItemSchema = external_exports.strictObject({
15309
- // An invalid discovery can have a directory name that isn't a valid extension ID.
15310
- id: external_exports.string().min(1),
15311
- manifest: desktopExtensionManifestSchema.optional(),
15312
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15313
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15314
- enabled: external_exports.boolean(),
15315
- status: desktopExtensionStatusSchema
15316
- });
15317
- var desktopExtensionsListResultSchema = external_exports.strictObject({
15318
- configuration: desktopExtensionConfigurationSchema,
15319
- desktopConnected: external_exports.boolean(),
15320
- diagnostics: external_exports.array(external_exports.string()),
15321
- extensions: external_exports.array(desktopExtensionListItemSchema)
15322
- });
15323
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
15324
- forceRefresh: external_exports.boolean().optional()
15325
- });
15326
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
15327
- catalogUrl: external_exports.string(),
15328
- source: external_exports.enum(["remote", "fallback"]),
15329
- fetchedAt: external_exports.string(),
15330
- cached: external_exports.boolean(),
15331
- extensions: desktopExtensionCatalogSchema.shape.extensions,
15332
- error: external_exports.string().optional()
15333
- });
15334
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
15335
- source: external_exports.discriminatedUnion("type", [
15336
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
15337
- external_exports.strictObject({
15338
- type: external_exports.literal("url"),
15339
- url: desktopExtensionHttpUrlSchema,
15340
- expectedSha256: desktopExtensionHashSchema.optional()
15341
- }),
15342
- external_exports.strictObject({
15343
- type: external_exports.literal("zip-base64"),
15344
- fileName: external_exports.string().trim().min(1).max(255),
15345
- 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")
15346
- })
15347
- ])
15348
- });
15349
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
15350
- extensionId: desktopExtensionIdSchema,
15351
- version: external_exports.string().min(1),
15352
- replaced: external_exports.boolean(),
15353
- installedPath: external_exports.string(),
15354
- list: desktopExtensionsListResultSchema
15355
- });
15356
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
15357
- id: desktopExtensionIdSchema
15358
- });
15359
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
15360
- removedId: desktopExtensionIdSchema,
15361
- list: desktopExtensionsListResultSchema
15362
- });
15363
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
15364
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
15365
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
15366
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
15367
- ]);
15368
-
15369
- // ../../shared-contracts/dist/errors.js
15370
- var codexhostErrorSchema = external_exports.strictObject({
15371
- code: external_exports.string().min(1),
15372
- message: external_exports.string().min(1),
15373
- retryable: external_exports.boolean(),
15374
- diagnostic: external_exports.string().min(1).optional(),
15375
- stage: external_exports.string().min(1).optional(),
15376
- durationMs: external_exports.number().int().nonnegative().optional(),
15377
- stderrTail: external_exports.string().min(1).optional()
15378
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
15379
-
15380
- // ../../shared-contracts/dist/harness-presentation.js
15381
- var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
15382
- var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
15383
- var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
15384
- label: displayText(256).optional(),
15385
- description: displayText(1024).optional()
15386
- }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
15387
- 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");
15388
-
15389
- // ../../shared-contracts/dist/harness-permission-modes.js
15390
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
15391
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
15392
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
15393
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
15394
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
15395
- message: "Value must not be empty or whitespace"
15396
- });
15397
- 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();
15398
- var harnessPermissionModeSchema = external_exports.object({
15399
- id: harnessPermissionModeIdSchema,
15400
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
15401
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
15402
- dangerous: external_exports.boolean().optional(),
15403
- localizations: harnessLocalizationsSchema.optional()
15404
- }).strict();
15405
- var harnessPermissionModeCatalogSchema = external_exports.object({
15406
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
15407
- defaultModeId: harnessPermissionModeIdSchema
15408
- }).strict().superRefine((catalog, context) => {
15409
- const ids = /* @__PURE__ */ new Set();
15410
- for (const [index, mode] of catalog.modes.entries()) {
15411
- if (ids.has(mode.id)) {
15412
- context.addIssue({
15413
- code: "custom",
15414
- message: "Permission Mode IDs must be unique",
15415
- path: ["modes", index, "id"]
15416
- });
15417
- }
15418
- ids.add(mode.id);
15419
- }
15420
- if (!ids.has(catalog.defaultModeId)) {
15421
- context.addIssue({
15422
- code: "custom",
15423
- message: "Default Permission Mode must exist in the catalog",
15424
- path: ["defaultModeId"]
15425
- });
15009
+ if (!ids.has(catalog.defaultModeId)) {
15010
+ context.addIssue({
15011
+ code: "custom",
15012
+ message: "Default Permission Mode must exist in the catalog",
15013
+ path: ["defaultModeId"]
15014
+ });
15426
15015
  }
15427
15016
  });
15428
15017
  var threadPermissionModeSelectParamsSchema = external_exports.object({
@@ -15430,6 +15019,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15430
15019
  permissionModeId: harnessPermissionModeIdSchema
15431
15020
  }).strict();
15432
15021
 
15022
+ // ../../shared-contracts/dist/harness-route-limit.js
15023
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
15024
+
15433
15025
  // ../../shared-contracts/dist/thread-usage.js
15434
15026
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15435
15027
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -15462,7 +15054,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15462
15054
  expiresAtUnix: nonNegativeSafeIntegerSchema,
15463
15055
  label: indicatorTextSchema(256).optional(),
15464
15056
  tooltip: indicatorTextSchema(1024).optional()
15465
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15057
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
15466
15058
  message: "Composer indicator IDs must be unique"
15467
15059
  });
15468
15060
  var threadUsageSnapshotSchema = external_exports.object({
@@ -15488,6 +15080,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15488
15080
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15489
15081
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15490
15082
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15083
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15491
15084
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15492
15085
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15493
15086
  }).strict().superRefine((usage, context) => {
@@ -15615,10 +15208,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
15615
15208
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15616
15209
  message: "Value must not be empty or whitespace"
15617
15210
  });
15618
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
15211
+ 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();
15212
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
15619
15213
  var harnessModelRefSchema = external_exports.object({
15620
- id: harnessModelRefIdSchema
15214
+ id: harnessModelRefIdSchema,
15215
+ serviceTier: harnessModelServiceTierSchema.optional()
15621
15216
  }).strict();
15217
+ function sameHarnessModelRef(left, right) {
15218
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
15219
+ }
15622
15220
  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();
15623
15221
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15624
15222
  var harnessThinkingOptionSchema = external_exports.object({
@@ -15632,7 +15230,15 @@ var harnessModelSchema = external_exports.object({
15632
15230
  /** Optional opaque selection for this same Model with priority processing enabled. */
15633
15231
  fastModel: harnessModelRefSchema.optional(),
15634
15232
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15635
- }).strict();
15233
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
15234
+ path: ["fastModel", "id"],
15235
+ message: "A tiered Fast Model must share the base Model ID"
15236
+ });
15237
+ function catalogModelForRef(catalog, ref) {
15238
+ if (!ref)
15239
+ return void 0;
15240
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
15241
+ }
15636
15242
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15637
15243
  const ids = /* @__PURE__ */ new Set();
15638
15244
  for (const [index, option] of options.entries()) {
@@ -15652,26 +15258,26 @@ var harnessModelCatalogSchema = external_exports.object({
15652
15258
  thinkingOptions: harnessThinkingOptionsSchema,
15653
15259
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15654
15260
  }).strict().superRefine((catalog, context) => {
15655
- const refs = /* @__PURE__ */ new Set();
15656
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15261
+ const refs = [];
15262
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
15657
15263
  for (const [index, model2] of catalog.models.entries()) {
15658
- if (refs.has(model2.ref.id)) {
15264
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
15659
15265
  context.addIssue({
15660
15266
  code: "custom",
15661
15267
  message: "Model Catalog refs must be unique",
15662
15268
  path: ["models", index, "ref", "id"]
15663
15269
  });
15664
15270
  }
15665
- refs.add(model2.ref.id);
15271
+ refs.push(model2.ref);
15666
15272
  if (model2.fastModel) {
15667
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15273
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
15668
15274
  context.addIssue({
15669
15275
  code: "custom",
15670
15276
  message: "Fast Model refs must be distinct and unique",
15671
15277
  path: ["models", index, "fastModel"]
15672
15278
  });
15673
15279
  }
15674
- refs.add(model2.fastModel.id);
15280
+ refs.push(model2.fastModel);
15675
15281
  }
15676
15282
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15677
15283
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -15692,7 +15298,7 @@ var harnessModelCatalogSchema = external_exports.object({
15692
15298
  }
15693
15299
  }
15694
15300
  }
15695
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15301
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
15696
15302
  context.addIssue({
15697
15303
  code: "custom",
15698
15304
  message: "Default Model must exist in the Model Catalog",
@@ -15732,7 +15338,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15732
15338
  observe: external_exports.boolean()
15733
15339
  }).strict().optional(),
15734
15340
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15735
- steer: external_exports.boolean().optional()
15341
+ steer: external_exports.boolean().optional(),
15342
+ /**
15343
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
15344
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
15345
+ */
15346
+ persistentPlan: external_exports.boolean().optional()
15736
15347
  }).strict();
15737
15348
  var harnessConfigurationStateSchema = external_exports.object({
15738
15349
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15741,7 +15352,7 @@ var harnessConfigurationStateSchema = external_exports.object({
15741
15352
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15742
15353
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15743
15354
  }).strict().superRefine((state, context) => {
15744
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15355
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
15745
15356
  context.addIssue({
15746
15357
  code: "custom",
15747
15358
  message: "Effective Thinking option must be currently available",
@@ -15749,150 +15360,696 @@ var harnessConfigurationStateSchema = external_exports.object({
15749
15360
  });
15750
15361
  }
15751
15362
  });
15752
- var harnessWebUiCapabilitySchema = external_exports.object({
15753
- open: external_exports.literal(true)
15754
- }).strict();
15755
- var readyHarnessInspectionSchema = external_exports.object({
15756
- status: external_exports.literal("ready"),
15757
- catalog: harnessModelCatalogSchema,
15758
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
15759
- capabilities: harnessSessionCapabilitiesSchema,
15760
- webUi: harnessWebUiCapabilitySchema.optional()
15761
- }).strict().superRefine((inspection, context) => {
15762
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
15763
- if (selectable !== Boolean(inspection.permissionModes)) {
15764
- context.addIssue({
15765
- code: "custom",
15766
- message: "Permission Mode catalog and capability must agree",
15767
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15768
- });
15769
- }
15363
+ var harnessWebUiCapabilitySchema = external_exports.object({
15364
+ open: external_exports.literal(true)
15365
+ }).strict();
15366
+ var readyHarnessInspectionSchema = external_exports.object({
15367
+ status: external_exports.literal("ready"),
15368
+ catalog: harnessModelCatalogSchema,
15369
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
15370
+ capabilities: harnessSessionCapabilitiesSchema,
15371
+ webUi: harnessWebUiCapabilitySchema.optional()
15372
+ }).strict().superRefine((inspection, context) => {
15373
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
15374
+ if (selectable !== Boolean(inspection.permissionModes)) {
15375
+ context.addIssue({
15376
+ code: "custom",
15377
+ message: "Permission Mode catalog and capability must agree",
15378
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
15379
+ });
15380
+ }
15381
+ });
15382
+ var failedHarnessInspectionSchema = external_exports.object({
15383
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15384
+ error: codexhostErrorSchema
15385
+ }).strict();
15386
+ var harnessInspectionSchema = external_exports.union([
15387
+ readyHarnessInspectionSchema,
15388
+ failedHarnessInspectionSchema
15389
+ ]);
15390
+ var harnessInspectParamsSchema = external_exports.object({
15391
+ harnessId: harnessIdSchema,
15392
+ cwd: nonBlankTextSchema2.max(16384).optional(),
15393
+ refresh: external_exports.boolean().optional(),
15394
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15395
+ purpose: external_exports.literal("availability").optional(),
15396
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15397
+ }).strict();
15398
+ var harnessWebUiOpenParamsSchema = external_exports.object({
15399
+ harnessId: harnessIdSchema
15400
+ }).strict();
15401
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15402
+ var threadModelSelectParamsSchema = external_exports.object({
15403
+ threadId: hostThreadIdSchema,
15404
+ model: harnessModelRefSchema
15405
+ }).strict();
15406
+ var threadThinkingSelectParamsSchema = external_exports.object({
15407
+ threadId: hostThreadIdSchema,
15408
+ thinkingOptionId: harnessThinkingOptionIdSchema
15409
+ }).strict();
15410
+ var threadInspectionParamsSchema = external_exports.object({
15411
+ threadId: hostThreadIdSchema,
15412
+ includeReferenceCapability: external_exports.boolean().optional()
15413
+ }).strict();
15414
+ var codexThreadInspectionSchema = external_exports.object({
15415
+ owner: external_exports.literal("codex"),
15416
+ locked: external_exports.boolean(),
15417
+ effectiveModel: harnessModelRefSchema.optional(),
15418
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15419
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15420
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15421
+ history: harnessHistoryCapabilitiesSchema.optional(),
15422
+ supportsThreadReferences: external_exports.literal(true).optional()
15423
+ }).strict();
15424
+ var externalThreadInspectionSchema = external_exports.object({
15425
+ owner: external_exports.literal("external"),
15426
+ harnessId: nonBlankTextSchema2.max(256),
15427
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15428
+ effectiveModel: harnessModelRefSchema.optional(),
15429
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15430
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15431
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15432
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15433
+ history: harnessHistoryCapabilitiesSchema,
15434
+ usage: threadUsageSnapshotSchema.optional(),
15435
+ locked: external_exports.literal(true)
15436
+ }).strict();
15437
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15438
+ codexThreadInspectionSchema,
15439
+ externalThreadInspectionSchema
15440
+ ]);
15441
+ var threadOwnershipListParamsSchema = external_exports.object({
15442
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15443
+ }).strict().superRefine(({ threadIds }, context) => {
15444
+ const seen = /* @__PURE__ */ new Set();
15445
+ for (const [index, threadId] of threadIds.entries()) {
15446
+ if (seen.has(threadId)) {
15447
+ context.addIssue({
15448
+ code: "custom",
15449
+ message: "Thread ownership-list IDs must be unique",
15450
+ path: ["threadIds", index]
15451
+ });
15452
+ }
15453
+ seen.add(threadId);
15454
+ }
15455
+ });
15456
+ var codexThreadOwnershipSchema = external_exports.object({
15457
+ threadId: hostThreadIdSchema,
15458
+ owner: external_exports.literal("codex")
15459
+ }).strict();
15460
+ var externalThreadOwnershipSchema = external_exports.object({
15461
+ threadId: hostThreadIdSchema,
15462
+ owner: external_exports.literal("external"),
15463
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15464
+ }).strict();
15465
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15466
+ codexThreadOwnershipSchema,
15467
+ externalThreadOwnershipSchema
15468
+ ]);
15469
+ var threadOwnershipListResultSchema = external_exports.object({
15470
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15471
+ }).strict().superRefine(({ threads }, context) => {
15472
+ const seen = /* @__PURE__ */ new Set();
15473
+ for (const [index, thread2] of threads.entries()) {
15474
+ if (seen.has(thread2.threadId)) {
15475
+ context.addIssue({
15476
+ code: "custom",
15477
+ message: "Thread ownership-list results must be unique",
15478
+ path: ["threads", index, "threadId"]
15479
+ });
15480
+ }
15481
+ seen.add(thread2.threadId);
15482
+ }
15483
+ });
15484
+ var threadSteeringInspectParamsSchema = external_exports.object({
15485
+ threadId: hostThreadIdSchema,
15486
+ /** The text about to be steered; a Harness command always stops and restarts. */
15487
+ text: external_exports.string().optional()
15488
+ }).strict();
15489
+ var threadSteeringContextSchema = external_exports.object({
15490
+ kind: external_exports.literal("application"),
15491
+ value: external_exports.string().transform((text, context) => {
15492
+ try {
15493
+ return JSON.parse(text);
15494
+ } catch {
15495
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15496
+ return external_exports.NEVER;
15497
+ }
15498
+ }).pipe(external_exports.object({
15499
+ expectedTurnId: hostTurnIdSchema,
15500
+ clientUserMessageId: external_exports.string().min(1),
15501
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
15502
+ }).strict())
15503
+ }).strict().transform((context) => context.value);
15504
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15505
+ var threadSteeringInspectResultSchema = external_exports.object({
15506
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15507
+ }).strict();
15508
+
15509
+ // ../../shared-contracts/dist/harness-plugins.js
15510
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15511
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15512
+ var HARNESS_PLUGIN_LIMIT = 128;
15513
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15514
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15515
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
15516
+ 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");
15517
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15518
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15519
+ var harnessInstallationGuideSchema = external_exports.object({
15520
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15521
+ before: localizedTextSchema.optional(),
15522
+ after: localizedTextSchema.optional(),
15523
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15524
+ }).strict();
15525
+ var pluginPresentationShape = {
15526
+ id: installedHarnessPluginIdSchema,
15527
+ name: external_exports.string().trim().min(1).max(128),
15528
+ version: external_exports.string().min(1).max(128),
15529
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15530
+ kind: external_exports.literal("usage").optional(),
15531
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15532
+ iconStyle: external_exports.object({
15533
+ vector: external_exports.object({
15534
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15535
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15536
+ paths: external_exports.array(external_exports.object({
15537
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15538
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15539
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15540
+ }).strict()).min(1).max(32)
15541
+ }).strict().optional(),
15542
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15543
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15544
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15545
+ }).strict().optional(),
15546
+ installation: harnessInstallationGuideSchema.optional(),
15547
+ notice: localizedTextSchema.optional(),
15548
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15549
+ launchCommand: external_exports.literal(true).optional(),
15550
+ links: external_exports.object({
15551
+ website: documentationUrlSchema.optional(),
15552
+ documentation: documentationUrlSchema.optional(),
15553
+ installation: documentationUrlSchema.optional()
15554
+ }).strict().optional()
15555
+ };
15556
+ var harnessPluginManifestSchema = external_exports.object({
15557
+ manifestVersion: external_exports.literal(1),
15558
+ ...pluginPresentationShape,
15559
+ adapterApiVersion: external_exports.number().int().positive(),
15560
+ entry: pluginRelativeResourceSchema,
15561
+ icon: pluginRelativeResourceSchema.optional()
15562
+ }).strict();
15563
+ 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);
15564
+ var harnessPluginDescriptorSchema = external_exports.object({
15565
+ ...pluginPresentationShape,
15566
+ icon: harnessPluginIconSchema.optional()
15567
+ }).strict();
15568
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15569
+ var harnessPluginListResultSchema = external_exports.object({
15570
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15571
+ }).strict();
15572
+ var harnessPluginConfigurationSchema = external_exports.object({
15573
+ version: external_exports.literal(1),
15574
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15575
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15576
+ message: "Enabled plugin IDs must be unique",
15577
+ path: ["enabled"]
15578
+ });
15579
+
15580
+ // ../../shared-contracts/dist/desktop-extensions.js
15581
+ var DESKTOP_EXTENSION_API_VERSION = 1;
15582
+ var DESKTOP_EXTENSION_LIMIT = 64;
15583
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15584
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15585
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15586
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15587
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15588
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15589
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15590
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15591
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15592
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15593
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15594
+ var desktopExtensionIdSchema = installedPluginIdSchema;
15595
+ var desktopExtensionSlotSchema = external_exports.enum([
15596
+ "sidebar.thread-layout",
15597
+ "sidebar.thread-badge",
15598
+ "appearance.theme"
15599
+ ]);
15600
+ var desktopExtensionCategorySchema = external_exports.enum([
15601
+ "appearance",
15602
+ "interface",
15603
+ "workflow",
15604
+ "analytics",
15605
+ "integrations",
15606
+ "tools"
15607
+ ]);
15608
+ var extensionName = external_exports.string().trim().min(1).max(128);
15609
+ function desktopExtensionScreenshotMimeType(resource) {
15610
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15611
+ case "png":
15612
+ return "image/png";
15613
+ case "jpg":
15614
+ case "jpeg":
15615
+ return "image/jpeg";
15616
+ case "webp":
15617
+ return "image/webp";
15618
+ default:
15619
+ return void 0;
15620
+ }
15621
+ }
15622
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15623
+ 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");
15624
+ 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) => {
15625
+ const { username, password } = new URL(value);
15626
+ return !username && !password && !/[\\\s]/u.test(value);
15627
+ }, "URL must not contain credentials, backslashes, or whitespace");
15628
+ function localizedText(text) {
15629
+ return external_exports.strictObject({ en: text, "zh-CN": text });
15630
+ }
15631
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15632
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15633
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15634
+ var settingField = {
15635
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15636
+ label: desktopExtensionLocalizedTextSchema,
15637
+ description: desktopExtensionLocalizedTextSchema.optional()
15638
+ };
15639
+ var numericSetting = {
15640
+ ...settingField,
15641
+ step: external_exports.number().positive().optional(),
15642
+ default: external_exports.number().optional()
15643
+ };
15644
+ var settingOption = external_exports.strictObject({
15645
+ value: external_exports.string(),
15646
+ label: desktopExtensionLocalizedTextSchema
15647
+ });
15648
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15649
+ external_exports.strictObject({
15650
+ ...settingField,
15651
+ type: external_exports.literal("boolean"),
15652
+ default: external_exports.boolean().optional()
15653
+ }),
15654
+ external_exports.strictObject({
15655
+ ...settingField,
15656
+ type: external_exports.literal("string"),
15657
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
15658
+ default: external_exports.string().optional()
15659
+ }),
15660
+ external_exports.strictObject({
15661
+ ...numericSetting,
15662
+ type: external_exports.literal("number"),
15663
+ min: external_exports.number().optional(),
15664
+ max: external_exports.number().optional()
15665
+ }),
15666
+ external_exports.strictObject({
15667
+ ...numericSetting,
15668
+ type: external_exports.literal("range"),
15669
+ min: external_exports.number(),
15670
+ max: external_exports.number()
15671
+ }),
15672
+ external_exports.strictObject({
15673
+ ...settingField,
15674
+ type: external_exports.literal("select"),
15675
+ options: external_exports.array(settingOption).min(1),
15676
+ default: external_exports.string().optional()
15677
+ })
15678
+ ]).superRefine((field2, ctx) => {
15679
+ const issue2 = (path11, message) => ctx.addIssue({ code: "custom", path: [path11], message });
15680
+ if (field2.type === "number" || field2.type === "range") {
15681
+ const { min = -Infinity, max = Infinity, default: value } = field2;
15682
+ if (min > max)
15683
+ issue2("max", "Must be at least min");
15684
+ if (value !== void 0 && (value < min || value > max))
15685
+ issue2("default", "Must be within min and max");
15686
+ } else if (field2.type === "select") {
15687
+ const values = new Set(field2.options.map(({ value }) => value));
15688
+ if (values.size !== field2.options.length)
15689
+ issue2("options", "Duplicate option values");
15690
+ if (field2.default !== void 0 && !values.has(field2.default))
15691
+ issue2("default", "Must match an option value");
15692
+ }
15693
+ });
15694
+ var manifestHeader = external_exports.object({
15695
+ manifestVersion: external_exports.int().positive(),
15696
+ id: desktopExtensionIdSchema,
15697
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
15698
+ version: external_exports.string().min(1).max(128),
15699
+ desktopApi: external_exports.int().positive()
15700
+ }).passthrough();
15701
+ var desktopExtensionManifestSchema = manifestHeader.extend({
15702
+ manifestVersion: external_exports.literal(1),
15703
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15704
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15705
+ author: external_exports.string().trim().min(1).max(128).optional(),
15706
+ repository: desktopExtensionHttpUrlSchema.optional(),
15707
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15708
+ icon: imagePathSchema.optional(),
15709
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15710
+ desktop: external_exports.strictObject({
15711
+ script: pluginRelativeResourceSchema,
15712
+ style: pluginRelativeResourceSchema.optional()
15713
+ }).optional(),
15714
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15715
+ slots: slotsSchema.default(() => []),
15716
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15717
+ categories: categoriesSchema.optional()
15718
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15719
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15720
+ var desktopExtensionStatusSchema = external_exports.strictObject({
15721
+ state: external_exports.enum([
15722
+ "running",
15723
+ "disabled",
15724
+ "invalid",
15725
+ "incompatible",
15726
+ "conflict",
15727
+ "failed",
15728
+ "waiting"
15729
+ ]),
15730
+ hash: desktopExtensionHashSchema.optional(),
15731
+ error: external_exports.string().optional(),
15732
+ conflictWith: desktopExtensionIdSchema.optional()
15733
+ });
15734
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15735
+ controllerPid: external_exports.int().positive(),
15736
+ targetId: external_exports.string().nullable(),
15737
+ updatedAt: external_exports.iso.datetime(),
15738
+ handledReloadToken: external_exports.uuid().optional(),
15739
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
15740
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
15770
15741
  });
15771
- var failedHarnessInspectionSchema = external_exports.object({
15772
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
15773
- error: codexhostErrorSchema
15774
- }).strict();
15775
- var harnessInspectionSchema = external_exports.union([
15776
- readyHarnessInspectionSchema,
15777
- failedHarnessInspectionSchema
15742
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15743
+ function isGitHubDesktopExtensionZipballUrl(url2) {
15744
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15745
+ }
15746
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15747
+ const url2 = new URL(input);
15748
+ 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);
15749
+ }, "Expected a .zip download URL or a GitHub zipball URL");
15750
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15751
+ id: desktopExtensionIdSchema,
15752
+ version: external_exports.string().trim().min(1).max(128),
15753
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15754
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
15755
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15756
+ author: external_exports.string().trim().min(1).max(128),
15757
+ repository: desktopExtensionHttpUrlSchema,
15758
+ stars: external_exports.number().int().min(0).optional(),
15759
+ downloads: external_exports.number().int().min(0).optional(),
15760
+ categories: categoriesSchema.optional(),
15761
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
15762
+ icon: desktopExtensionHttpUrlSchema.optional(),
15763
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15764
+ downloadUrl: desktopExtensionZipUrlSchema,
15765
+ sha256: desktopExtensionHashSchema,
15766
+ slots: slotsSchema.optional(),
15767
+ publishedAt: external_exports.string().optional(),
15768
+ updatedAt: external_exports.string().optional(),
15769
+ minCodexHostVersion: external_exports.string().optional()
15770
+ });
15771
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
15772
+ schemaVersion: external_exports.literal(1),
15773
+ generatedAt: external_exports.string(),
15774
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15775
+ });
15776
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15777
+
15778
+ // ../../shared-contracts/dist/host-extensions.js
15779
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
15780
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
15781
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
15782
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
15783
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
15784
+ var hostExtensionActivationIdSchema = external_exports.uuid();
15785
+ 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((path11) => path11.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
15786
+ var legacy = desktopExtensionManifestSchema.shape;
15787
+ var localized = (max, min = 0) => external_exports.strictObject({
15788
+ en: external_exports.string().trim().min(min).max(max),
15789
+ "zh-CN": external_exports.string().trim().min(min).max(max)
15790
+ });
15791
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path11) => path11.endsWith(suffix), `Expected a ${suffix} file`);
15792
+ var moduleEntry = resourceWithSuffix(".mjs");
15793
+ var style = resourceWithSuffix(".css").optional();
15794
+ var hostExtensionCanonicalPath = (path11) => path11.normalize("NFC").toLowerCase();
15795
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
15796
+ manifestVersion: external_exports.literal(2),
15797
+ id: hostExtensionIdSchema,
15798
+ name: localized(128, 1),
15799
+ version: external_exports.string().trim().min(1).max(128),
15800
+ description: localized(4096),
15801
+ details: localized(16384).optional(),
15802
+ author: legacy.author,
15803
+ repository: legacy.repository,
15804
+ icon: legacy.icon.refine((path11) => path11 === void 0 || hostExtensionResourcePathSchema.safeParse(path11).success),
15805
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path11) => hostExtensionResourcePathSchema.safeParse(path11).success)),
15806
+ categories: legacy.categories,
15807
+ settingsSchema: legacy.settingsSchema,
15808
+ slots: legacy.slots.removeDefault().optional(),
15809
+ page: external_exports.strictObject({
15810
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15811
+ entry: moduleEntry,
15812
+ style,
15813
+ title: localized(128, 1).optional()
15814
+ }).optional(),
15815
+ widget: external_exports.strictObject({
15816
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15817
+ entry: moduleEntry,
15818
+ style
15819
+ }).optional(),
15820
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
15821
+ 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(),
15822
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
15823
+ }).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" });
15824
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
15825
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
15826
+ return ["desktop", "web"];
15827
+ const targets = [];
15828
+ if (hasDesktop)
15829
+ targets.push("desktop");
15830
+ if (hasWeb)
15831
+ targets.push("web");
15832
+ return targets;
15833
+ }
15834
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
15835
+
15836
+ // ../../shared-contracts/dist/host-extension-management.js
15837
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
15838
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
15839
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
15840
+ revision: hostExtensionRevisionSchema,
15841
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
15842
+ });
15843
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
15844
+ var hostExtensionCatalogEntrySchema = external_exports.object({
15845
+ ...catalogMetadata,
15846
+ id: hostExtensionIdSchema,
15847
+ format: external_exports.literal("codexhost"),
15848
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
15849
+ apis: external_exports.strictObject({
15850
+ page: external_exports.int().positive().optional(),
15851
+ widget: external_exports.int().positive().optional(),
15852
+ desktop: external_exports.int().positive().optional(),
15853
+ web: external_exports.int().positive().optional(),
15854
+ backend: external_exports.int().positive().optional()
15855
+ }),
15856
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
15857
+ }).refine(({ targets, apis }) => {
15858
+ const derived = targetsForCapabilities({
15859
+ hasPage: Boolean(apis.page),
15860
+ hasWidget: Boolean(apis.widget),
15861
+ hasDesktop: Boolean(apis.desktop),
15862
+ hasWeb: Boolean(apis.web),
15863
+ hasBackend: Boolean(apis.backend)
15864
+ });
15865
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
15866
+ }, "Catalog targets must match the declared APIs");
15867
+ var hostExtensionCatalogSchema = external_exports.object({
15868
+ schemaVersion: external_exports.literal(2),
15869
+ generatedAt: external_exports.string().min(1),
15870
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15871
+ });
15872
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
15873
+ catalogUrl: desktopExtensionHttpUrlSchema,
15874
+ fetchedAt: external_exports.iso.datetime(),
15875
+ cached: external_exports.boolean()
15876
+ });
15877
+ var id = { id: hostExtensionIdSchema };
15878
+ var active = {
15879
+ ...id,
15880
+ activationId: hostExtensionActivationIdSchema,
15881
+ digest: hostExtensionDigestSchema
15882
+ };
15883
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
15884
+ var filePath = external_exports.string().min(1).max(4096).refine((path11) => /^(?:\/|[a-z]:[/\\])/iu.test(path11) && !path11.includes("\0") && !path11.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
15885
+ 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");
15886
+ function base643(maxBytes) {
15887
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
15888
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
15889
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
15890
+ }, "Expected bounded standard padded base64");
15891
+ }
15892
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
15893
+ type: external_exports.literal("github"),
15894
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
15895
+ ref: gitRef.optional(),
15896
+ tag: gitRef.optional(),
15897
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
15898
+ subpath: hostExtensionResourcePathSchema.optional()
15899
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
15900
+ var hostExtensionInstallSourceSchema = external_exports.union([
15901
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15902
+ hostExtensionGitHubSourceSchema,
15903
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
15904
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
15905
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
15778
15906
  ]);
15779
- var harnessInspectParamsSchema = external_exports.object({
15780
- harnessId: harnessIdSchema,
15781
- cwd: nonBlankTextSchema2.max(16384).optional(),
15782
- refresh: external_exports.boolean().optional(),
15783
- /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15784
- purpose: external_exports.literal("availability").optional()
15785
- }).strict();
15786
- var harnessWebUiOpenParamsSchema = external_exports.object({
15787
- harnessId: harnessIdSchema
15788
- }).strict();
15789
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
15790
- var threadModelSelectParamsSchema = external_exports.object({
15791
- threadId: hostThreadIdSchema,
15792
- model: harnessModelRefSchema
15793
- }).strict();
15794
- var threadThinkingSelectParamsSchema = external_exports.object({
15795
- threadId: hostThreadIdSchema,
15796
- thinkingOptionId: harnessThinkingOptionIdSchema
15797
- }).strict();
15798
- var threadInspectionParamsSchema = external_exports.object({
15799
- threadId: hostThreadIdSchema,
15800
- includeReferenceCapability: external_exports.boolean().optional()
15801
- }).strict();
15802
- var codexThreadInspectionSchema = external_exports.object({
15803
- owner: external_exports.literal("codex"),
15804
- locked: external_exports.boolean(),
15805
- effectiveModel: harnessModelRefSchema.optional(),
15806
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15807
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15808
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15809
- history: harnessHistoryCapabilitiesSchema.optional(),
15810
- supportsThreadReferences: external_exports.literal(true).optional()
15811
- }).strict();
15812
- var externalThreadInspectionSchema = external_exports.object({
15813
- owner: external_exports.literal("external"),
15814
- harnessId: nonBlankTextSchema2.max(256),
15815
- transportModelId: nonBlankTextSchema2.max(1024),
15816
- effectiveModel: harnessModelRefSchema.optional(),
15817
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15818
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
15819
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15820
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
15821
- history: harnessHistoryCapabilitiesSchema,
15822
- usage: threadUsageSnapshotSchema.optional(),
15823
- locked: external_exports.literal(true)
15824
- }).strict();
15825
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
15826
- codexThreadInspectionSchema,
15827
- externalThreadInspectionSchema
15907
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
15908
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15909
+ hostExtensionGitHubSourceSchema,
15910
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
15911
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
15828
15912
  ]);
15829
- var threadOwnershipListParamsSchema = external_exports.object({
15830
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15831
- }).strict().superRefine(({ threadIds }, context) => {
15832
- const seen = /* @__PURE__ */ new Set();
15833
- for (const [index, threadId] of threadIds.entries()) {
15834
- if (seen.has(threadId)) {
15835
- context.addIssue({
15836
- code: "custom",
15837
- message: "Thread ownership-list IDs must be unique",
15838
- path: ["threadIds", index]
15839
- });
15840
- }
15841
- seen.add(threadId);
15842
- }
15913
+ var hostExtensionInstallationSchema = external_exports.strictObject({
15914
+ ...active,
15915
+ manifest: hostExtensionManifestV2Schema,
15916
+ installedAt: external_exports.iso.datetime(),
15917
+ source: hostExtensionProvenanceSchema.optional()
15843
15918
  });
15844
- var codexThreadOwnershipSchema = external_exports.object({
15845
- threadId: hostThreadIdSchema,
15846
- owner: external_exports.literal("codex")
15847
- }).strict();
15848
- var externalThreadOwnershipSchema = external_exports.object({
15849
- threadId: hostThreadIdSchema,
15850
- owner: external_exports.literal("external"),
15851
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
15852
- }).strict();
15853
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
15854
- codexThreadOwnershipSchema,
15855
- externalThreadOwnershipSchema
15919
+ 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);
15920
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
15921
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
15922
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
15923
+ hostExtensionInstallationSchema.extend({
15924
+ state: external_exports.literal("valid"),
15925
+ enabled: external_exports.boolean(),
15926
+ ...desktopConflict,
15927
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15928
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15929
+ backendState: backendState.optional(),
15930
+ backendError: external_exports.string().optional()
15931
+ }),
15932
+ external_exports.strictObject({
15933
+ state: external_exports.enum(["invalid", "incompatible"]),
15934
+ id: external_exports.string().min(1),
15935
+ enabled: external_exports.boolean(),
15936
+ error: external_exports.string()
15937
+ })
15856
15938
  ]);
15857
- var threadOwnershipListResultSchema = external_exports.object({
15858
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
15859
- }).strict().superRefine(({ threads }, context) => {
15860
- const seen = /* @__PURE__ */ new Set();
15861
- for (const [index, thread2] of threads.entries()) {
15862
- if (seen.has(thread2.threadId)) {
15863
- context.addIssue({
15864
- code: "custom",
15865
- message: "Thread ownership-list results must be unique",
15866
- path: ["threads", index, "threadId"]
15867
- });
15868
- }
15869
- seen.add(thread2.threadId);
15870
- }
15939
+ var hostExtensionsListResultSchema = external_exports.strictObject({
15940
+ revision: hostExtensionRevisionSchema,
15941
+ configuration: hostExtensionConfigurationSchema,
15942
+ diagnostics: external_exports.array(external_exports.string()),
15943
+ extensions: external_exports.array(hostExtensionListItemSchema)
15944
+ });
15945
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
15946
+ ...desktopConflict,
15947
+ settingsRevision: hostExtensionRevisionSchema
15948
+ });
15949
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
15950
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
15951
+ revision: hostExtensionRevisionSchema,
15952
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
15953
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
15954
+ });
15955
+ var HOST_EXTENSIONS_RPC = {
15956
+ list: "codexhost/extensions/list",
15957
+ snapshot: "codexhost/extensions/snapshot",
15958
+ catalog: "codexhost/extensions/catalog",
15959
+ install: "codexhost/extensions/install",
15960
+ update: "codexhost/extensions/update",
15961
+ enable: "codexhost/extensions/enable",
15962
+ disable: "codexhost/extensions/disable",
15963
+ uninstall: "codexhost/extensions/uninstall",
15964
+ recover: "codexhost/extensions/recover",
15965
+ asset: "codexhost/extensions/asset",
15966
+ settingsGet: "codexhost/extensions/settings/get",
15967
+ settingsSet: "codexhost/extensions/settings/set",
15968
+ backendInvoke: "codexhost/extensions/backend/invoke"
15969
+ };
15970
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
15971
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
15972
+ var noParams = external_exports.strictObject({});
15973
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
15974
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
15975
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
15976
+ var mutationResult = external_exports.discriminatedUnion("state", [
15977
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
15978
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
15979
+ ]);
15980
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
15981
+ ...optionalActivation,
15982
+ digest: active.digest.optional(),
15983
+ path: hostExtensionResourcePathSchema
15984
+ });
15985
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
15986
+ mimeType: external_exports.string().min(1),
15987
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
15988
+ digest: active.digest
15989
+ });
15990
+ var hostExtensionSettingsSchema = external_exports.strictObject({
15991
+ settingsRevision: hostExtensionRevisionSchema,
15992
+ values: jsonObjectSchema
15871
15993
  });
15872
- var threadSteeringInspectParamsSchema = external_exports.object({
15873
- threadId: hostThreadIdSchema,
15874
- /** The text about to be steered; a Harness command always stops and restarts. */
15875
- text: external_exports.string().optional()
15876
- }).strict();
15877
- var threadSteeringContextSchema = external_exports.object({
15878
- kind: external_exports.literal("application"),
15879
- value: external_exports.string().transform((text, context) => {
15880
- try {
15881
- return JSON.parse(text);
15882
- } catch {
15883
- context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
15884
- return external_exports.NEVER;
15885
- }
15886
- }).pipe(external_exports.object({
15887
- expectedTurnId: hostTurnIdSchema,
15888
- clientUserMessageId: external_exports.string().min(1),
15889
- delivery: external_exports.enum(["newTurn", "activeTurn"])
15890
- }).strict())
15891
- }).strict().transform((context) => context.value);
15892
- var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
15893
- var threadSteeringInspectResultSchema = external_exports.object({
15894
- delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15895
- }).strict();
15994
+ var hostExtensionsRpcSchemas = {
15995
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
15996
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
15997
+ [HOST_EXTENSIONS_RPC.catalog]: {
15998
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
15999
+ result: hostExtensionsCatalogResultSchema
16000
+ },
16001
+ [HOST_EXTENSIONS_RPC.install]: {
16002
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
16003
+ result: installationResult
16004
+ },
16005
+ [HOST_EXTENSIONS_RPC.update]: {
16006
+ params: external_exports.strictObject({
16007
+ ...id,
16008
+ expectedDigest: active.digest,
16009
+ expectedActivationId: active.activationId.optional(),
16010
+ source: hostExtensionInstallSourceSchema.optional()
16011
+ }),
16012
+ result: installationResult
16013
+ },
16014
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
16015
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
16016
+ [HOST_EXTENSIONS_RPC.uninstall]: {
16017
+ params: external_exports.strictObject({
16018
+ ...id,
16019
+ removeData: external_exports.boolean().optional(),
16020
+ expectedDigest: active.digest.optional()
16021
+ }),
16022
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
16023
+ },
16024
+ [HOST_EXTENSIONS_RPC.recover]: {
16025
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
16026
+ result: mutationResult
16027
+ },
16028
+ [HOST_EXTENSIONS_RPC.asset]: {
16029
+ params: hostExtensionsAssetParamsSchema,
16030
+ result: hostExtensionsAssetResultSchema
16031
+ },
16032
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
16033
+ params: external_exports.strictObject(optionalActivation),
16034
+ result: hostExtensionSettingsSchema
16035
+ },
16036
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
16037
+ params: external_exports.strictObject({
16038
+ ...optionalActivation,
16039
+ expectedSettingsRevision: hostExtensionRevisionSchema,
16040
+ values: jsonObjectSchema
16041
+ }),
16042
+ result: hostExtensionSettingsSchema
16043
+ },
16044
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
16045
+ params: external_exports.strictObject({
16046
+ ...optionalActivation,
16047
+ method: hostExtensionBackendMethodSchema,
16048
+ params: jsonValueSchema.optional()
16049
+ }),
16050
+ result: external_exports.strictObject({ result: jsonValueSchema })
16051
+ }
16052
+ };
15896
16053
 
15897
16054
  // ../../shared-contracts/dist/thread-archive-confirm.js
15898
16055
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -15955,7 +16112,7 @@ var CLIENT_CHANNEL_METHODS = [
15955
16112
  "codexhost/harness/session-import/list",
15956
16113
  "codexhost/harness/session-import/import",
15957
16114
  // Host settings shared across Desktop and Web.
15958
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
16115
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
15959
16116
  "codexhost/harness/installation",
15960
16117
  "codexhost/harness/installation/start",
15961
16118
  "codexhost/harness/installation/status",
@@ -16016,6 +16173,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
16016
16173
  cursor: clientChannelCursorSchema,
16017
16174
  revision: external_exports.number().int().nonnegative()
16018
16175
  }),
16176
+ external_exports.object({
16177
+ type: external_exports.literal("extensions-changed"),
16178
+ cursor: clientChannelCursorSchema,
16179
+ revision: hostExtensionRevisionSchema
16180
+ }),
16019
16181
  external_exports.object({
16020
16182
  type: external_exports.literal("hello"),
16021
16183
  version: external_exports.literal(1),
@@ -16452,7 +16614,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
16452
16614
 
16453
16615
  // ../../shared-contracts/dist/harness-preferences.js
16454
16616
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
16455
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16617
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
16456
16618
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
16457
16619
  model: harnessModelRefSchema.optional(),
16458
16620
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -16462,11 +16624,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
16462
16624
  lastHarness: harnessIdSchema.optional(),
16463
16625
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
16464
16626
  });
16627
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
16628
+ model: harnessModelRefSchema.optional(),
16629
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
16630
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
16631
+ var delegationDefaultsSchema = external_exports.strictObject({
16632
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
16633
+ });
16465
16634
  var modelId = external_exports.string().min(1).max(1024);
16466
16635
  var harnessPreferenceValuesSchema = external_exports.strictObject({
16467
16636
  idleRelease: idleReleaseSettingsSchema.optional(),
16468
16637
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
16469
- newThread: newThreadDefaultsSchema.optional()
16638
+ newThread: newThreadDefaultsSchema.optional(),
16639
+ delegation: delegationDefaultsSchema.optional()
16470
16640
  });
16471
16641
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
16472
16642
  scope: harnessPreferenceScopeSchema,
@@ -16494,6 +16664,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
16494
16664
  lastHarness: harnessIdSchema.optional(),
16495
16665
  harnessId: harnessIdSchema.optional(),
16496
16666
  configuration: harnessDefaultConfigurationSchema.optional()
16667
+ }),
16668
+ external_exports.strictObject({
16669
+ kind: external_exports.literal("delegation"),
16670
+ harnessId: harnessIdSchema,
16671
+ configuration: harnessDelegationDefaultSchema.nullable()
16497
16672
  })
16498
16673
  ]);
16499
16674
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -17317,9 +17492,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
17317
17492
  ...thread,
17318
17493
  epoch: identity,
17319
17494
  modelId: identity.optional(),
17495
+ serviceTier: harnessModelServiceTierSchema.optional(),
17320
17496
  thinkingOptionId: identity.optional(),
17321
17497
  permissionModeId: identity.optional()
17322
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17498
+ }).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, {
17499
+ message: "A service tier requires a Model ID"
17500
+ }),
17323
17501
  external_exports.strictObject({
17324
17502
  kind: external_exports.literal("prompt"),
17325
17503
  ...thread,
@@ -17369,7 +17547,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17369
17547
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
17370
17548
  external_exports.strictObject({
17371
17549
  action: external_exports.literal("read-thread"),
17372
- hostId: hostId.refine((id) => id !== "local"),
17550
+ hostId: hostId.refine((id2) => id2 !== "local"),
17373
17551
  input: delegationReadParamsSchema
17374
17552
  }),
17375
17553
  external_exports.strictObject({
@@ -17383,7 +17561,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17383
17561
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
17384
17562
  external_exports.strictObject({
17385
17563
  action: external_exports.literal("update"),
17386
- hostId: hostId.refine((id) => id !== "local"),
17564
+ hostId: hostId.refine((id2) => id2 !== "local"),
17387
17565
  version: remoteUpdateParamsSchema.shape.version
17388
17566
  })
17389
17567
  ]);
@@ -17447,7 +17625,7 @@ function invalidRequest(message) {
17447
17625
  return { code: "invalidRequest", message, retryable: false };
17448
17626
  }
17449
17627
  function validateHostApprovalResponse(interaction, response) {
17450
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17628
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17451
17629
  }
17452
17630
 
17453
17631
  // ../../harness-adapter/dist/question.js
@@ -17455,7 +17633,7 @@ function invalidRequest2(message) {
17455
17633
  return { code: "invalidRequest", message, retryable: false };
17456
17634
  }
17457
17635
  function validateHostQuestionResponse(interaction, response) {
17458
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17636
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
17459
17637
  if (response.cancelled) {
17460
17638
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
17461
17639
  }
@@ -17587,7 +17765,8 @@ var tokenFields = [
17587
17765
  var safeIntegerFields = [
17588
17766
  "planFiveHourResetsAtUnix",
17589
17767
  "planSevenDayResetsAtUnix",
17590
- "timeToFirstOutputMs"
17768
+ "timeToFirstOutputMs",
17769
+ "latestRequestTimeToFirstOutputMs"
17591
17770
  ];
17592
17771
  var percentFields = [
17593
17772
  "cacheHitRatePercent",
@@ -17873,7 +18052,7 @@ var CURSOR_COMMAND_CATALOG = cursorCommands([
17873
18052
  { name: "copy-request-id", description: "Copy the current request ID", input: null }
17874
18053
  ]);
17875
18054
  function cursorCommandPrompt(command, catalog) {
17876
- const descriptor = catalog.commands.find(({ id }) => id === command.commandId);
18055
+ const descriptor = catalog.commands.find(({ id: id2 }) => id2 === command.commandId);
17877
18056
  if (!descriptor)
17878
18057
  return {
17879
18058
  ok: false,
@@ -18251,10 +18430,10 @@ function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = fal
18251
18430
  const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
18252
18431
  if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
18253
18432
  throw new Error("Cursor native session identity mismatch");
18254
- const get = (id) => {
18255
- if (!/^[0-9a-f]{64}$/u.test(id))
18433
+ const get = (id2) => {
18434
+ if (!/^[0-9a-f]{64}$/u.test(id2))
18256
18435
  throw new Error("Invalid Cursor native blob reference");
18257
- const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id)?.data;
18436
+ const blob = db.prepare("SELECT data FROM blobs WHERE id = ?").get(id2)?.data;
18258
18437
  if (!(blob instanceof Uint8Array))
18259
18438
  throw new Error("Cursor native history blob is missing");
18260
18439
  return protobufBytes(blob);
@@ -18268,13 +18447,13 @@ function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = fal
18268
18447
  for (const record4 of container.get(1) ?? []) {
18269
18448
  const turn = protobufBytes(record4);
18270
18449
  const user = get(one(turn, 1).toString("hex"));
18271
- const id = one(user, 2).toString("utf8");
18272
- if (!/^[0-9a-f-]{36}$/iu.test(id) || result.some((existing) => existing.id === id))
18450
+ const id2 = one(user, 2).toString("utf8");
18451
+ if (!/^[0-9a-f-]{36}$/iu.test(id2) || result.some((existing) => existing.id === id2))
18273
18452
  throw new Error("Cursor native turn ID is invalid or duplicated");
18274
18453
  const anchor = user.get(10)?.[0];
18275
18454
  const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
18276
18455
  result.push({
18277
- id,
18456
+ id: id2,
18278
18457
  text: one(user, 1).toString("utf8"),
18279
18458
  ...rewindRoot ? { rewindRoot } : {},
18280
18459
  ...user.get(15)?.length ? { notification: true } : {}
@@ -18385,12 +18564,12 @@ var CursorSessionImport = class {
18385
18564
  } : null;
18386
18565
  });
18387
18566
  }
18388
- async #candidate(id, signal) {
18567
+ async #candidate(id2, signal) {
18389
18568
  signal.throwIfAborted();
18390
18569
  const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
18391
18570
  if (!(await optionalStat(root))?.isDirectory())
18392
18571
  return null;
18393
- const directory = cursorSessionDirectory(id, this.#environment);
18572
+ const directory = cursorSessionDirectory(id2, this.#environment);
18394
18573
  const files = [
18395
18574
  directory,
18396
18575
  path7.join(directory, "meta.json"),
@@ -18411,7 +18590,7 @@ var CursorSessionImport = class {
18411
18590
  if (!(await stat(cwd)).isDirectory())
18412
18591
  return null;
18413
18592
  signal.throwIfAborted();
18414
- const turns = readCursorNativeTurns(id, cwd, this.#environment);
18593
+ const turns = readCursorNativeTurns(id2, cwd, this.#environment);
18415
18594
  if (!turns.length)
18416
18595
  return null;
18417
18596
  title = sessionImportTitle(turns[0]?.text);
@@ -18426,7 +18605,7 @@ var CursorSessionImport = class {
18426
18605
  if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
18427
18606
  throw new SessionImportChangedError("Cursor Session changed during discovery");
18428
18607
  return sessionImportCandidate({
18429
- nativeSessionId: id,
18608
+ nativeSessionId: id2,
18430
18609
  cwd,
18431
18610
  title,
18432
18611
  updatedAt: Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)
@@ -18464,16 +18643,16 @@ function cursorThinking(options) {
18464
18643
  return [];
18465
18644
  return combinations.flatMap(({ values, labels }) => {
18466
18645
  const encoded = Buffer.from(JSON.stringify(values)).toString("base64url");
18467
- const id = harnessThinkingOptionIdSchema.safeParse(`cursor.${encoded}`);
18468
- return id.success ? [{ id: id.data, label: labels.join(" / "), values }] : [];
18646
+ const id2 = harnessThinkingOptionIdSchema.safeParse(`cursor.${encoded}`);
18647
+ return id2.success ? [{ id: id2.data, label: labels.join(" / "), values }] : [];
18469
18648
  });
18470
18649
  }
18471
18650
  function cursorThinkingState(info) {
18472
18651
  const options = cursorThinking(info.configOptions);
18473
- const current = options.find((entry) => entry.values.every(([id, value]) => info.configOptions?.some((option) => option.id === id && option.currentValue === value)));
18652
+ const current = options.find((entry) => entry.values.every(([id2, value]) => info.configOptions?.some((option) => option.id === id2 && option.currentValue === value)));
18474
18653
  return {
18475
- availableThinkingOptions: options.map(({ id, label }) => ({
18476
- id,
18654
+ availableThinkingOptions: options.map(({ id: id2, label }) => ({
18655
+ id: id2,
18477
18656
  label
18478
18657
  })),
18479
18658
  ...current ? { effectiveThinkingOptionId: current.id } : {}
@@ -18554,8 +18733,8 @@ function cursorCatalog(info) {
18554
18733
  const live = model2.value === native.current;
18555
18734
  const config2 = live ? info.configOptions : info.nativeModels?.find((entry) => entry.value === model2.value)?.configOptions;
18556
18735
  const options = cursorThinking(config2);
18557
- for (const { id, label } of options)
18558
- thinking.set(id, { id, label });
18736
+ for (const { id: id2, label } of options)
18737
+ thinking.set(id2, { id: id2, label });
18559
18738
  return {
18560
18739
  // Only the live model's parameters reflect the user's Cursor settings. The parameterized
18561
18740
  // catalog reports Cursor's built-in defaults for every other model (for example
@@ -18563,7 +18742,7 @@ function cursorCatalog(info) {
18563
18742
  // A bare Ref selects only the model and lets Cursor apply those parameters itself.
18564
18743
  ref: live ? cursorConfiguredModelRef(model2.value, config2) : cursorModelRef(model2.value),
18565
18744
  label: model2.name,
18566
- supportedThinkingOptionIds: options.map(({ id }) => id)
18745
+ supportedThinkingOptionIds: options.map(({ id: id2 }) => id2)
18567
18746
  };
18568
18747
  });
18569
18748
  if (!models.length)
@@ -18621,13 +18800,13 @@ function cursorModelSelection(info, ref) {
18621
18800
  const parameters = [];
18622
18801
  for (const parameter of match[2] ? match[2].split(",") : []) {
18623
18802
  const pair = parameter.split("=");
18624
- const [id, value] = pair;
18625
- if (pair.length !== 2 || !id || value === void 0 || parameters.some(([key]) => key === id))
18803
+ const [id2, value] = pair;
18804
+ if (pair.length !== 2 || !id2 || value === void 0 || parameters.some(([key]) => key === id2))
18626
18805
  throw new Error("Invalid Cursor model parameters");
18627
- const option = model2.configOptions.find((option2) => option2.id === id);
18806
+ const option = model2.configOptions.find((option2) => option2.id === id2);
18628
18807
  if (!option || option.type !== "select" || !option.options.flatMap((entry) => "value" in entry ? [entry] : entry.options).some((entry) => entry.value === value))
18629
18808
  throw new Error("Legacy Cursor model parameter is not selectable in the native catalog");
18630
- parameters.push([id, value]);
18809
+ parameters.push([id2, value]);
18631
18810
  }
18632
18811
  return [["model", model2.value], ...parameters];
18633
18812
  }
@@ -20501,8 +20680,8 @@ var RequestResponder = class {
20501
20680
  signal;
20502
20681
  finishRequest;
20503
20682
  didRespond = false;
20504
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
20505
- this.id = id;
20683
+ constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
20684
+ this.id = id2;
20506
20685
  this.sendResult = sendResult;
20507
20686
  this.signal = signal;
20508
20687
  this.finishRequest = finishRequest;
@@ -20793,7 +20972,7 @@ var Connection = class {
20793
20972
  return this.sendWireMessage({ jsonrpc: "2.0", method, params });
20794
20973
  }
20795
20974
  prepareRequest(method, params, mapResponse, options = {}) {
20796
- const id = this.nextRequestId++;
20975
+ const id2 = this.nextRequestId++;
20797
20976
  let cancel = () => {
20798
20977
  };
20799
20978
  const response = new Promise((resolve, reject) => {
@@ -20813,7 +20992,7 @@ var Connection = class {
20813
20992
  }
20814
20993
  pendingResponse.cancellationSent = true;
20815
20994
  pendingResponse.cleanup?.();
20816
- void this.sendCancelRequest(id).catch(() => {
20995
+ void this.sendCancelRequest(id2).catch(() => {
20817
20996
  });
20818
20997
  };
20819
20998
  options.cancellationSignal?.addEventListener("abort", cancel, {
@@ -20822,12 +21001,12 @@ var Connection = class {
20822
21001
  pendingResponse.cleanup = () => {
20823
21002
  options.cancellationSignal?.removeEventListener("abort", cancel);
20824
21003
  };
20825
- this.pendingResponses.set(id, pendingResponse);
21004
+ this.pendingResponses.set(id2, pendingResponse);
20826
21005
  });
20827
21006
  response.catch(() => {
20828
21007
  });
20829
21008
  return {
20830
- message: { jsonrpc: "2.0", id, method, params },
21009
+ message: { jsonrpc: "2.0", id: id2, method, params },
20831
21010
  response,
20832
21011
  cancel: () => cancel()
20833
21012
  };
@@ -21464,7 +21643,7 @@ function memoryStreamPair() {
21464
21643
  }
21465
21644
  ];
21466
21645
  }
21467
- var methods = {
21646
+ var methods2 = {
21468
21647
  agent: {
21469
21648
  initialize: AGENT_METHODS.initialize,
21470
21649
  authenticate: AGENT_METHODS.authenticate,
@@ -24343,7 +24522,7 @@ async function forkCursorSession(source, checkpoint, options, signal, forkOption
24343
24522
  }, source.nativeSessionId, signal, rewindTurn ? {
24344
24523
  steps: sourceTurns.slice(retained).filter((turn) => turn.rewindRoot).length,
24345
24524
  complete: () => {
24346
- const targets = readdirSync2(chats).filter((id) => id !== source.nativeSessionId);
24525
+ const targets = readdirSync2(chats).filter((id2) => id2 !== source.nativeSessionId);
24347
24526
  const targetId = targets[0];
24348
24527
  return targets.length === 1 && !!targetId && storeIdentity(path8.join(chats, targetId), false).root === rewindTurn.rewindRoot;
24349
24528
  }
@@ -24418,9 +24597,9 @@ var CursorAdapter = class {
24418
24597
  const session = [...this.#sessions].find((s) => s.transport.sessionId === parent.nativeSessionId);
24419
24598
  if (session && path9.resolve(session.transport.options.cwd) !== path9.resolve(cwd))
24420
24599
  return rejected("invalidRequest", "Cursor parent workspace does not match");
24421
- const active = session?.subagentSnapshot(nativeSubagentId);
24422
- if (active)
24423
- return { ok: true, value: active };
24600
+ const active2 = session?.subagentSnapshot(nativeSubagentId);
24601
+ if (active2)
24602
+ return { ok: true, value: active2 };
24424
24603
  const options = session?.transport.options ?? this.transportOptions(cwd);
24425
24604
  const before = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
24426
24605
  replay = new CursorTransport({
@@ -24447,6 +24626,7 @@ var CursorAdapter = class {
24447
24626
  #sessions = /* @__PURE__ */ new Set();
24448
24627
  #forks = /* @__PURE__ */ new Map();
24449
24628
  #inspections = /* @__PURE__ */ new Map();
24629
+ #inspectionTasks = /* @__PURE__ */ new Set();
24450
24630
  #closed = false;
24451
24631
  sessionImport;
24452
24632
  constructor(options = {}) {
@@ -24474,8 +24654,14 @@ var CursorAdapter = class {
24474
24654
  };
24475
24655
  const cwd = path9.resolve(input.cwd ?? process.cwd());
24476
24656
  const cached2 = this.#inspections.get(cwd);
24477
- if (cached2 && (cached2.pending || !input.refresh))
24478
- return cached2.result;
24657
+ if (input.refresh) {
24658
+ this.#inspections.clear();
24659
+ if (cached2 && this.#inspectionTasks.has(cached2))
24660
+ this.#inspections.set(cwd, cached2);
24661
+ }
24662
+ const current = this.#inspections.get(cwd);
24663
+ if (current)
24664
+ return current;
24479
24665
  const result = (async () => {
24480
24666
  const transport = new CursorTransport(this.transportOptions(cwd));
24481
24667
  try {
@@ -24496,11 +24682,9 @@ var CursorAdapter = class {
24496
24682
  await transport.close();
24497
24683
  }
24498
24684
  })();
24499
- const entry = { pending: true, result };
24500
- this.#inspections.set(cwd, entry);
24501
- void result.finally(() => {
24502
- entry.pending = false;
24503
- });
24685
+ this.#inspections.set(cwd, result);
24686
+ this.#inspectionTasks.add(result);
24687
+ void result.finally(() => this.#inspectionTasks.delete(result));
24504
24688
  return result;
24505
24689
  }
24506
24690
  async open(input) {
@@ -24680,7 +24864,7 @@ var CursorAdapter = class {
24680
24864
  controller.abort();
24681
24865
  await Promise.allSettled([importing, ...this.#forks.values()]);
24682
24866
  await Promise.allSettled([...this.#sessions].map((session) => session.close()));
24683
- await Promise.allSettled([...this.#inspections.values()].map((inspection) => inspection.result));
24867
+ await Promise.allSettled(this.#inspectionTasks);
24684
24868
  }
24685
24869
  };
24686
24870
  var CursorSession = class {
@@ -24826,8 +25010,8 @@ var CursorSession = class {
24826
25010
  if (command.type === "turn.cancel") {
24827
25011
  if (!this.#active || this.#active.command.turnId !== command.turnId)
24828
25012
  return rejected("invalidState", "Cursor turn is not active");
24829
- const active = this.#active;
24830
- active.cancelled = true;
25013
+ const active2 = this.#active;
25014
+ active2.cancelled = true;
24831
25015
  this.#interactions.cancel();
24832
25016
  try {
24833
25017
  await this.transport.cancel();
@@ -24835,10 +25019,10 @@ var CursorSession = class {
24835
25019
  await this.transport.close();
24836
25020
  }
24837
25021
  const timer = setTimeout(() => {
24838
- if (this.#active === active)
25022
+ if (this.#active === active2)
24839
25023
  void this.transport.close();
24840
25024
  }, 5e3);
24841
- void active.task.finally(() => clearTimeout(timer));
25025
+ void active2.task.finally(() => clearTimeout(timer));
24842
25026
  return { ok: true, value: { cancellationRequested: true } };
24843
25027
  }
24844
25028
  if (this.#configuring || this.#active && command.type !== "model.select" && command.type !== "thinking.select")
@@ -24856,16 +25040,16 @@ var CursorSession = class {
24856
25040
  }
24857
25041
  this.#submitted.add(command.turnId);
24858
25042
  this.#snapshot = void 0;
24859
- const active = { command, cancelled: false, task: Promise.resolve() };
24860
- this.#active = active;
24861
- active.task = this.#run(command, before);
25043
+ const active2 = { command, cancelled: false, task: Promise.resolve() };
25044
+ this.#active = active2;
25045
+ active2.task = this.#run(command, before);
24862
25046
  return { ok: true, value: { turnId: command.turnId } };
24863
25047
  }
24864
25048
  this.#configuring = true;
24865
25049
  try {
24866
25050
  let selections;
24867
25051
  if (command.type === "thinking.select") {
24868
- const option = cursorThinking(this.info.configOptions).find(({ id }) => id === command.thinkingOptionId);
25052
+ const option = cursorThinking(this.info.configOptions).find(({ id: id2 }) => id2 === command.thinkingOptionId);
24869
25053
  if (!option)
24870
25054
  return rejected("unsupported", "Thinking option is not available for this Cursor model");
24871
25055
  selections = option.values;
@@ -25005,13 +25189,13 @@ var CursorSession = class {
25005
25189
  if (this.#closed)
25006
25190
  return;
25007
25191
  this.#closed = true;
25008
- const active = this.#active;
25009
- if (active)
25010
- active.cancelled = true;
25192
+ const active2 = this.#active;
25193
+ if (active2)
25194
+ active2.cancelled = true;
25011
25195
  this.#interactions.cancel();
25012
25196
  try {
25013
25197
  await this.transport.close();
25014
- await active?.task;
25198
+ await active2?.task;
25015
25199
  } finally {
25016
25200
  this.#channel.end();
25017
25201
  this.onClose();
@@ -25036,6 +25220,7 @@ var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
25036
25220
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
25037
25221
  var harnessBrokerMethodSchema = external_exports.enum([
25038
25222
  "adapter.inspect",
25223
+ "adapter.normalizeStoredModelRef",
25039
25224
  "adapter.inspectAccount",
25040
25225
  "adapter.credits",
25041
25226
  "adapter.open",
@@ -25223,6 +25408,10 @@ var brokerInspectInputSchema = external_exports.object({
25223
25408
  refresh: external_exports.boolean().optional(),
25224
25409
  purpose: external_exports.literal("availability").optional()
25225
25410
  }).strict();
25411
+ var brokerNormalizeStoredModelRefSchema = external_exports.strictObject({
25412
+ ref: harnessModelRefSchema,
25413
+ catalog: harnessModelCatalogSchema
25414
+ });
25226
25415
  var brokerSessionImportListParamsSchema = external_exports.object({
25227
25416
  offset: external_exports.number().int().nonnegative().safe(),
25228
25417
  limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
@@ -25351,11 +25540,13 @@ var eventKeys = /* @__PURE__ */ new Map([
25351
25540
  ["session.state.changed", /* @__PURE__ */ new Set(["type", "state"])],
25352
25541
  ["session.usage.changed", /* @__PURE__ */ new Set(["type", "usage", "observedForTurnId"])],
25353
25542
  ["usage.request", /* @__PURE__ */ new Set(["type", "request"])],
25543
+ ["usage.request.timing", /* @__PURE__ */ new Set(["type", "turnId", "timing"])],
25354
25544
  ["usage.history", /* @__PURE__ */ new Set(["type", "complete"])],
25355
25545
  ["subagent.state.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId", "status", "resultSummary"])],
25356
25546
  ["subagent.transcript.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId"])],
25357
25547
  ["turn.started", /* @__PURE__ */ new Set(["type", "turnId"])],
25358
25548
  ["turn.autonomous.started", /* @__PURE__ */ new Set(["type", "turnId", "input"])],
25549
+ ["turn.autonomous.completed", /* @__PURE__ */ new Set(["type", "snapshot"])],
25359
25550
  ["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
25360
25551
  ["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
25361
25552
  ["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
@@ -25387,6 +25578,118 @@ var interactionKeys = /* @__PURE__ */ new Map([
25387
25578
  function strictKeys(value, allowed) {
25388
25579
  return Boolean(allowed && value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).every((key) => allowed.has(key)));
25389
25580
  }
25581
+ var nonNegativeSafeIntegerSchema2 = external_exports.int().nonnegative();
25582
+ var toolOutputSchema = external_exports.strictObject({
25583
+ content: external_exports.array(external_exports.discriminatedUnion("type", [
25584
+ textInputSchema,
25585
+ external_exports.strictObject({ type: external_exports.literal("image"), mimeType: external_exports.string(), base64Data: external_exports.string() })
25586
+ ])),
25587
+ truncated: external_exports.boolean().optional()
25588
+ });
25589
+ var fileChangeSchema = external_exports.strictObject({
25590
+ path: external_exports.string(),
25591
+ kind: external_exports.enum(["add", "update", "delete"]),
25592
+ unifiedDiff: external_exports.string(),
25593
+ diffScope: external_exports.literal("fragment").optional()
25594
+ });
25595
+ var subagentStateSchema = external_exports.strictObject({
25596
+ subagentId: external_exports.string().min(1),
25597
+ nativeSubagentId: external_exports.string().min(1).optional(),
25598
+ description: external_exports.string(),
25599
+ role: external_exports.string().optional(),
25600
+ model: external_exports.string().optional(),
25601
+ reasoningEffort: external_exports.string().optional(),
25602
+ background: external_exports.boolean(),
25603
+ status: external_exports.enum(["pending", "running", "completed", "failed", "interrupted"]),
25604
+ resultSummary: external_exports.string().optional()
25605
+ });
25606
+ var itemBase = { itemId: hostItemIdSchema };
25607
+ var toolFields = {
25608
+ ...itemBase,
25609
+ toolName: external_exports.string(),
25610
+ arguments: jsonValueSchema,
25611
+ output: toolOutputSchema.optional(),
25612
+ durationMs: external_exports.number().nonnegative().optional()
25613
+ };
25614
+ var snapshotItemSchema = external_exports.discriminatedUnion("type", [
25615
+ external_exports.strictObject({
25616
+ ...itemBase,
25617
+ type: external_exports.literal("agentMessage"),
25618
+ text: external_exports.string(),
25619
+ phase: external_exports.enum(["commentary", "final_answer"]).optional()
25620
+ }),
25621
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("userMessage"), input: external_exports.array(textInputSchema) }),
25622
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("reasoning"), text: external_exports.string() }),
25623
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("contextCompaction") }),
25624
+ external_exports.strictObject({
25625
+ ...itemBase,
25626
+ type: external_exports.literal("commandExecution"),
25627
+ command: external_exports.string(),
25628
+ cwd: cwdSchema.optional(),
25629
+ output: external_exports.string().optional(),
25630
+ outputTruncated: external_exports.boolean().optional(),
25631
+ exitCode: external_exports.int().nullable().optional(),
25632
+ durationMs: external_exports.number().nonnegative().optional()
25633
+ }),
25634
+ external_exports.strictObject({
25635
+ ...toolFields,
25636
+ type: external_exports.literal("toolExecution"),
25637
+ namespace: external_exports.string().optional()
25638
+ }),
25639
+ external_exports.strictObject({ ...toolFields, type: external_exports.literal("mcpToolCall"), server: external_exports.string() }),
25640
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("webSearch"), query: external_exports.string() }),
25641
+ external_exports.strictObject({
25642
+ ...itemBase,
25643
+ type: external_exports.literal("fileChange"),
25644
+ changes: external_exports.array(fileChangeSchema),
25645
+ sourceItemIds: external_exports.array(hostItemIdSchema).optional()
25646
+ }),
25647
+ external_exports.strictObject({
25648
+ ...itemBase,
25649
+ type: external_exports.literal("subagentDelegation"),
25650
+ operation: external_exports.enum(["spawn", "send"]),
25651
+ prompt: external_exports.string().optional(),
25652
+ subagents: external_exports.array(subagentStateSchema)
25653
+ })
25654
+ ]);
25655
+ var terminalOutcomes = [
25656
+ external_exports.strictObject({ status: external_exports.literal("succeeded") }),
25657
+ external_exports.strictObject({ status: external_exports.literal("failed"), error: harnessErrorSchema }),
25658
+ external_exports.strictObject({ status: external_exports.literal("cancelled"), reason: external_exports.string().optional() })
25659
+ ];
25660
+ var autonomousSnapshotSchema = external_exports.strictObject({
25661
+ nativeTurnRef: nativeTurnRefSchema,
25662
+ checkpoint: nativeCheckpointRefSchema.optional(),
25663
+ input: external_exports.array(textInputSchema),
25664
+ items: external_exports.array(external_exports.strictObject({
25665
+ item: snapshotItemSchema,
25666
+ outcome: external_exports.discriminatedUnion("status", terminalOutcomes)
25667
+ })),
25668
+ outcome: external_exports.discriminatedUnion("status", [
25669
+ ...terminalOutcomes,
25670
+ external_exports.strictObject({ status: external_exports.literal("unknown"), reason: external_exports.string() })
25671
+ ]),
25672
+ model: harnessModelRefSchema.optional(),
25673
+ startedAtMs: nonNegativeSafeIntegerSchema2.optional(),
25674
+ completedAtMs: nonNegativeSafeIntegerSchema2.optional()
25675
+ }).refine(({ checkpoint, nativeTurnRef }) => !checkpoint || checkpoint.harnessId === nativeTurnRef.harnessId && checkpoint.nativeSessionId === nativeTurnRef.nativeSessionId, { path: ["checkpoint"], message: "Checkpoint must belong to the native Turn's Session" }).refine(({ startedAtMs, completedAtMs }) => startedAtMs === void 0 || completedAtMs === void 0 || completedAtMs >= startedAtMs, { path: ["completedAtMs"], message: "Turn cannot complete before it starts" }).refine(({ items }) => new Set(items.map(({ item }) => item.itemId)).size === items.length, {
25676
+ path: ["items"],
25677
+ message: "Item IDs must be unique within the Turn"
25678
+ });
25679
+ var usageOutputIntervalSchema = external_exports.strictObject({
25680
+ startedAtMs: nonNegativeSafeIntegerSchema2,
25681
+ completedAtMs: nonNegativeSafeIntegerSchema2,
25682
+ outputTokens: nonNegativeSafeIntegerSchema2
25683
+ }).refine(({ startedAtMs, completedAtMs }) => completedAtMs > startedAtMs);
25684
+ var usageRequestTimingSchema = external_exports.union([
25685
+ external_exports.strictObject({
25686
+ requestId: external_exports.string().min(1),
25687
+ requestStartedAtMs: nonNegativeSafeIntegerSchema2,
25688
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema2,
25689
+ output: usageOutputIntervalSchema.optional()
25690
+ }),
25691
+ external_exports.strictObject({ requestId: external_exports.string().min(1), output: usageOutputIntervalSchema })
25692
+ ]);
25390
25693
  var harnessOutputSchema = external_exports.custom((value) => {
25391
25694
  if (!value || typeof value !== "object" || Array.isArray(value))
25392
25695
  return false;
@@ -25405,10 +25708,14 @@ var harnessOutputSchema = external_exports.custom((value) => {
25405
25708
  itemId: hostItemIdSchema,
25406
25709
  text: external_exports.string()
25407
25710
  }).strict().safeParse(event.item).success;
25711
+ if (event.type === "turn.autonomous.completed")
25712
+ return autonomousSnapshotSchema.safeParse(event.snapshot).success;
25408
25713
  if (event.type === "session.faulted")
25409
25714
  return harnessErrorSchema.safeParse(event.error).success;
25410
25715
  if (event.type === "usage.history")
25411
25716
  return typeof event.complete === "boolean";
25717
+ if (event.type === "usage.request.timing")
25718
+ return hostTurnIdSchema.safeParse(event.turnId).success && usageRequestTimingSchema.safeParse(event.timing).success;
25412
25719
  return true;
25413
25720
  }
25414
25721
  if (output.kind === "interaction") {
@@ -25727,12 +26034,12 @@ var BrokerConnection = class _BrokerConnection {
25727
26034
  }
25728
26035
  #waitForHello() {
25729
26036
  return new Promise((resolve, reject) => {
25730
- const id = "__hello__";
26037
+ const id2 = "__hello__";
25731
26038
  const timeout = setTimeout(() => {
25732
- this.#pending.delete(id);
26039
+ this.#pending.delete(id2);
25733
26040
  reject(new Error("Aqua Harness broker authentication timed out"));
25734
26041
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
25735
- this.#pending.set(id, { resolve: () => resolve(), reject, timeout });
26042
+ this.#pending.set(id2, { resolve: () => resolve(), reject, timeout });
25736
26043
  });
25737
26044
  }
25738
26045
  register(session) {
@@ -25757,13 +26064,13 @@ var BrokerConnection = class _BrokerConnection {
25757
26064
  throw new Error("Aqua Harness broker request limit exceeded");
25758
26065
  }
25759
26066
  this.#inputSequence += 1;
25760
- const id = randomUUID2();
26067
+ const id2 = randomUUID2();
25761
26068
  const response = new Promise((resolve, reject) => {
25762
26069
  const timeout = setTimeout(() => {
25763
- this.#pending.delete(id);
26070
+ this.#pending.delete(id2);
25764
26071
  reject(new Error(`Aqua Harness broker ${method} timed out`));
25765
26072
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
25766
- this.#pending.set(id, { resolve, reject, timeout });
26073
+ this.#pending.set(id2, { resolve, reject, timeout });
25767
26074
  });
25768
26075
  try {
25769
26076
  await writeBrokerFrame(this.#socket, {
@@ -25771,15 +26078,15 @@ var BrokerConnection = class _BrokerConnection {
25771
26078
  generation: this.#descriptor.generation,
25772
26079
  sequence: this.#inputSequence,
25773
26080
  kind: "request",
25774
- id,
26081
+ id: id2,
25775
26082
  method,
25776
26083
  params
25777
26084
  });
25778
26085
  } catch (error51) {
25779
- const pending = this.#pending.get(id);
26086
+ const pending = this.#pending.get(id2);
25780
26087
  if (pending)
25781
26088
  clearTimeout(pending.timeout);
25782
- this.#pending.delete(id);
26089
+ this.#pending.delete(id2);
25783
26090
  response.catch(() => void 0);
25784
26091
  throw new BrokerRequestNotDeliveredError(error51 instanceof Error ? error51.message : String(error51));
25785
26092
  }
@@ -26146,6 +26453,10 @@ var BrokeredHarnessAdapter = class {
26146
26453
  return failedInspection(describeBrokerFailure(error51, this.harnessId));
26147
26454
  }
26148
26455
  }
26456
+ async normalizeStoredModelRef(ref, catalog) {
26457
+ const result = await this.#request("adapter.normalizeStoredModelRef", { ref, catalog }, true);
26458
+ return harnessModelRefSchema.nullable().parse(result) ?? void 0;
26459
+ }
26149
26460
  async open(input) {
26150
26461
  if (this.#closed)
26151
26462
  return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };