@codexhost/cli-linux-arm64 0.22.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 (59) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +3117 -274
  4. package/app/console-web.js +15645 -4413
  5. package/app/desktop-controller.mjs +14057 -969
  6. package/app/host-runtime.mjs +11518 -8277
  7. package/app/plugins/antigravity/plugin.mjs +2030 -678
  8. package/app/plugins/claude-code/plugin.mjs +2116 -929
  9. package/app/plugins/codebuddy/plugin.mjs +1247 -353
  10. package/app/plugins/codex-usage/plugin.mjs +786 -163
  11. package/app/plugins/copilot/plugin.mjs +938 -296
  12. package/app/plugins/cursor-cli/plugin.mjs +1021 -232
  13. package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
  14. package/app/plugins/devin/plugin.mjs +826 -185
  15. package/app/plugins/grok/plugin.mjs +1083 -424
  16. package/app/plugins/hermes/plugin.mjs +961 -338
  17. package/app/plugins/kimi-code/plugin.mjs +854 -237
  18. package/app/plugins/kiro-cli/plugin.mjs +821 -184
  19. package/app/plugins/omp/plugin.mjs +1316 -633
  20. package/app/plugins/opencode/plugin.mjs +1293 -606
  21. package/app/plugins/pi/plugin.mjs +1540 -867
  22. package/app/plugins/qoder/plugin.mjs +961 -332
  23. package/app/plugins/qoder-cn/plugin.mjs +961 -332
  24. package/app/plugins/qwen-code/plugin.mjs +937 -321
  25. package/app/plugins/workbuddy/plugin.mjs +1311 -370
  26. package/app/plugins/zcode/plugin.mjs +1516 -423
  27. package/app/renderer-extension.js +21297 -9060
  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 +6753 -31616
  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 +14 -14
  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 +94 -91
  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-browser/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  50. package/app/web/sw.js +8 -1
  51. package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
  52. package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
  53. package/app/web-modules/server.mjs +40416 -11283
  54. package/bin/codexhost +0 -0
  55. package/libexec/codexhost-shim +0 -0
  56. package/libexec/codexhost-updater +0 -0
  57. package/package.json +1 -1
  58. package/app/web/assets/index-CN4a4sj0.js +0 -201
  59. package/app/web/assets/index-DJW4bmyx.css +0 -1
@@ -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,
@@ -15019,6 +15019,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15019
15019
  permissionModeId: harnessPermissionModeIdSchema
15020
15020
  }).strict();
15021
15021
 
15022
+ // ../../shared-contracts/dist/harness-route-limit.js
15023
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
15024
+
15022
15025
  // ../../shared-contracts/dist/thread-usage.js
15023
15026
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15024
15027
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -15051,7 +15054,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15051
15054
  expiresAtUnix: nonNegativeSafeIntegerSchema,
15052
15055
  label: indicatorTextSchema(256).optional(),
15053
15056
  tooltip: indicatorTextSchema(1024).optional()
15054
- }).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, {
15055
15058
  message: "Composer indicator IDs must be unique"
15056
15059
  });
15057
15060
  var threadUsageSnapshotSchema = external_exports.object({
@@ -15077,6 +15080,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15077
15080
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15078
15081
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15079
15082
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15083
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15080
15084
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15081
15085
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15082
15086
  }).strict().superRefine((usage, context) => {
@@ -15174,6 +15178,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
15174
15178
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
15175
15179
  resetCredits: accountResetCreditsSchema.optional()
15176
15180
  }).strict();
15181
+ var accountBalanceSnapshotSchema = external_exports.object({
15182
+ amount: external_exports.number().finite().nonnegative(),
15183
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
15184
+ currency: external_exports.string().trim().min(1).max(8),
15185
+ /** Native label when the Harness exposes several Billing Sources. */
15186
+ label: external_exports.string().trim().min(1).max(128).optional()
15187
+ }).strict();
15177
15188
  var threadUsageInspectionParamsSchema = external_exports.object({
15178
15189
  threadId: hostThreadIdSchema,
15179
15190
  refresh: external_exports.literal("exact").optional()
@@ -15182,7 +15193,10 @@ var threadUsageInspectionSchema = external_exports.object({
15182
15193
  threadId: hostThreadIdSchema,
15183
15194
  usage: threadUsageSnapshotSchema.nullable(),
15184
15195
  accountCredits: accountCreditsSnapshotSchema.optional(),
15185
- /** Whether this source can provide cached account quota independently of usage. */
15196
+ /** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
15197
+ accountBalance: accountBalanceSnapshotSchema.optional(),
15198
+ /** Whether this source can provide cached account quota (credits or a prepaid balance)
15199
+ * independently of usage. */
15186
15200
  accountCreditsSupported: external_exports.boolean().optional()
15187
15201
  }).strict();
15188
15202
 
@@ -15194,10 +15208,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
15194
15208
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15195
15209
  message: "Value must not be empty or whitespace"
15196
15210
  });
15197
- 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"]);
15198
15213
  var harnessModelRefSchema = external_exports.object({
15199
- id: harnessModelRefIdSchema
15214
+ id: harnessModelRefIdSchema,
15215
+ serviceTier: harnessModelServiceTierSchema.optional()
15200
15216
  }).strict();
15217
+ function sameHarnessModelRef(left, right) {
15218
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
15219
+ }
15201
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();
15202
15221
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15203
15222
  var harnessThinkingOptionSchema = external_exports.object({
@@ -15211,7 +15230,15 @@ var harnessModelSchema = external_exports.object({
15211
15230
  /** Optional opaque selection for this same Model with priority processing enabled. */
15212
15231
  fastModel: harnessModelRefSchema.optional(),
15213
15232
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15214
- }).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
+ }
15215
15242
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15216
15243
  const ids = /* @__PURE__ */ new Set();
15217
15244
  for (const [index, option] of options.entries()) {
@@ -15231,26 +15258,26 @@ var harnessModelCatalogSchema = external_exports.object({
15231
15258
  thinkingOptions: harnessThinkingOptionsSchema,
15232
15259
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15233
15260
  }).strict().superRefine((catalog, context) => {
15234
- const refs = /* @__PURE__ */ new Set();
15235
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15261
+ const refs = [];
15262
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
15236
15263
  for (const [index, model2] of catalog.models.entries()) {
15237
- if (refs.has(model2.ref.id)) {
15264
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
15238
15265
  context.addIssue({
15239
15266
  code: "custom",
15240
15267
  message: "Model Catalog refs must be unique",
15241
15268
  path: ["models", index, "ref", "id"]
15242
15269
  });
15243
15270
  }
15244
- refs.add(model2.ref.id);
15271
+ refs.push(model2.ref);
15245
15272
  if (model2.fastModel) {
15246
- 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))) {
15247
15274
  context.addIssue({
15248
15275
  code: "custom",
15249
15276
  message: "Fast Model refs must be distinct and unique",
15250
15277
  path: ["models", index, "fastModel"]
15251
15278
  });
15252
15279
  }
15253
- refs.add(model2.fastModel.id);
15280
+ refs.push(model2.fastModel);
15254
15281
  }
15255
15282
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15256
15283
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -15271,7 +15298,7 @@ var harnessModelCatalogSchema = external_exports.object({
15271
15298
  }
15272
15299
  }
15273
15300
  }
15274
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15301
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
15275
15302
  context.addIssue({
15276
15303
  code: "custom",
15277
15304
  message: "Default Model must exist in the Model Catalog",
@@ -15311,7 +15338,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15311
15338
  observe: external_exports.boolean()
15312
15339
  }).strict().optional(),
15313
15340
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15314
- 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()
15315
15347
  }).strict();
15316
15348
  var harnessConfigurationStateSchema = external_exports.object({
15317
15349
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15320,7 +15352,7 @@ var harnessConfigurationStateSchema = external_exports.object({
15320
15352
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15321
15353
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15322
15354
  }).strict().superRefine((state, context) => {
15323
- 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)) {
15324
15356
  context.addIssue({
15325
15357
  code: "custom",
15326
15358
  message: "Effective Thinking option must be currently available",
@@ -15360,7 +15392,8 @@ var harnessInspectParamsSchema = external_exports.object({
15360
15392
  cwd: nonBlankTextSchema2.max(16384).optional(),
15361
15393
  refresh: external_exports.boolean().optional(),
15362
15394
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15363
- purpose: external_exports.literal("availability").optional()
15395
+ purpose: external_exports.literal("availability").optional(),
15396
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15364
15397
  }).strict();
15365
15398
  var harnessWebUiOpenParamsSchema = external_exports.object({
15366
15399
  harnessId: harnessIdSchema
@@ -15391,7 +15424,7 @@ var codexThreadInspectionSchema = external_exports.object({
15391
15424
  var externalThreadInspectionSchema = external_exports.object({
15392
15425
  owner: external_exports.literal("external"),
15393
15426
  harnessId: nonBlankTextSchema2.max(256),
15394
- transportModelId: nonBlankTextSchema2.max(1024),
15427
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15395
15428
  effectiveModel: harnessModelRefSchema.optional(),
15396
15429
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15397
15430
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15473,13 +15506,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
15473
15506
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15474
15507
  }).strict();
15475
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()
15741
+ });
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 })
15906
+ ]);
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") })
15912
+ ]);
15913
+ var hostExtensionInstallationSchema = external_exports.strictObject({
15914
+ ...active,
15915
+ manifest: hostExtensionManifestV2Schema,
15916
+ installedAt: external_exports.iso.datetime(),
15917
+ source: hostExtensionProvenanceSchema.optional()
15918
+ });
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
+ })
15938
+ ]);
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
15993
+ });
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
+ };
16053
+
15476
16054
  // ../../shared-contracts/dist/thread-archive-confirm.js
16055
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
15477
16056
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15478
16057
  var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15479
16058
 
15480
16059
  // ../../shared-contracts/dist/client-channel.js
15481
16060
  var CLIENT_CHANNEL_VERSION = 1;
15482
16061
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
16062
+ var CLIENT_CHANNEL_METHODS = [
16063
+ "codexhost/skills/list",
16064
+ "codexhost/voice/status",
16065
+ "codexhost/voice/transcribe",
16066
+ "codexhost/harness/display-settings/get",
16067
+ "codexhost/harness/display-settings/set",
16068
+ "codexhost/harness/display-settings/capabilities",
16069
+ "codexhost/harness/preferences/get",
16070
+ "codexhost/harness/preferences/patch",
16071
+ "thread/list",
16072
+ "codexhost/thread/catalog/read",
16073
+ "thread/read",
16074
+ "thread/resume",
16075
+ "thread/fork",
16076
+ "thread/turns/list",
16077
+ "thread/revert",
16078
+ "thread/items/list",
16079
+ "thread/start",
16080
+ "thread/name/set",
16081
+ "codexhost/thread/title/generate",
16082
+ "thread/archive",
16083
+ THREAD_ARCHIVE_CONFIRM_METHOD,
16084
+ "thread/unarchive",
16085
+ "turn/start",
16086
+ "turn/interrupt",
16087
+ "turn/steer",
16088
+ "thread/queue/list",
16089
+ "thread/queue/add",
16090
+ "thread/queue/update",
16091
+ "thread/queue/delete",
16092
+ "thread/queue/reorder",
16093
+ "thread/queue/start",
16094
+ "codexhost/thread/queue/send-now",
16095
+ "codexhost/workspace/read",
16096
+ "codexhost/thread/tree/read",
16097
+ "codexhost/thread/pins/list",
16098
+ "codexhost/thread/pins/set",
16099
+ "codexhost/harness/plugins/list",
16100
+ "codexhost/harness/inspect",
16101
+ "codexhost/thread/inspect",
16102
+ "codexhost/thread/usage/inspect",
16103
+ "codexhost/thread/ownership/list",
16104
+ "codexhost/thread/model/select",
16105
+ "codexhost/thread/thinking/select",
16106
+ "codexhost/thread/permission-mode/select",
16107
+ "codexhost/thread/commands/inspect",
16108
+ "codexhost/harness/commands/inspect",
16109
+ "codexhost/thread/command/execute",
16110
+ "codexhost/thread/fork",
16111
+ "codexhost/harness/session-import/sources",
16112
+ "codexhost/harness/session-import/list",
16113
+ "codexhost/harness/session-import/import",
16114
+ // Host settings shared across Desktop and Web.
16115
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
16116
+ "codexhost/harness/installation",
16117
+ "codexhost/harness/installation/start",
16118
+ "codexhost/harness/installation/status",
16119
+ "codexhost/harness/launch-settings/get",
16120
+ "codexhost/harness/launch-settings/set",
16121
+ "codexhost/harness/web-ui/open",
16122
+ "codexhost/harness/accounts/sources",
16123
+ "codexhost/harness/accounts/list",
16124
+ "codexhost/harness/accounts/inspect",
16125
+ "codexhost/harness/credential-imports",
16126
+ "codexhost/account/list",
16127
+ "codexhost/account/refresh",
16128
+ "codexhost/account/usage/inspect",
16129
+ "codexhost/usage/model-prices/get",
16130
+ "codexhost/usage/model-prices/set",
16131
+ "codexhost/usage/model-prices/default",
16132
+ "codexhost/usage/statistics/get",
16133
+ "codexhost/update/check",
16134
+ "codexhost/update/start",
16135
+ "codexhost/update/status",
16136
+ "codexhost/sessions/loaded/list"
16137
+ ];
15483
16138
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15484
16139
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15485
16140
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -15518,6 +16173,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15518
16173
  cursor: clientChannelCursorSchema,
15519
16174
  revision: external_exports.number().int().nonnegative()
15520
16175
  }),
16176
+ external_exports.object({
16177
+ type: external_exports.literal("extensions-changed"),
16178
+ cursor: clientChannelCursorSchema,
16179
+ revision: hostExtensionRevisionSchema
16180
+ }),
15521
16181
  external_exports.object({
15522
16182
  type: external_exports.literal("hello"),
15523
16183
  version: external_exports.literal(1),
@@ -15693,6 +16353,29 @@ var threadCatalogReadResultSchema = external_exports.object({
15693
16353
  officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
15694
16354
  }).strict();
15695
16355
 
16356
+ // ../../shared-contracts/dist/thread-tree-watch.js
16357
+ var THREAD_TREE_MAX_NODES = 5e3;
16358
+ var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
16359
+ var threadTreeNodeSchema = external_exports.strictObject({
16360
+ harnessId: harnessIdSchema,
16361
+ title: external_exports.string().optional(),
16362
+ status: threadTreeStatusSchema,
16363
+ archived: external_exports.boolean()
16364
+ });
16365
+ var threadTreeSnapshotSchema = external_exports.strictObject({
16366
+ revision: external_exports.int().nonnegative(),
16367
+ parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
16368
+ nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
16369
+ truncated: external_exports.boolean()
16370
+ }).refine((snapshot) => Object.keys(snapshot.nodes).length <= THREAD_TREE_MAX_NODES, "Too many Thread tree nodes").refine(({ parents, nodes }) => Object.entries(parents).every(([child, parent]) => Object.hasOwn(nodes, child) && Object.hasOwn(nodes, parent)), "Missing Thread tree node");
16371
+ var subscriptionId = external_exports.string().min(1).max(128);
16372
+ var threadTreeWatchParamsSchema = external_exports.strictObject({});
16373
+ var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
16374
+ var threadTreeUnwatchResultSchema = external_exports.strictObject({});
16375
+ var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
16376
+ snapshot: threadTreeSnapshotSchema
16377
+ });
16378
+
15696
16379
  // ../../shared-contracts/dist/voice.js
15697
16380
  var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
15698
16381
  var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
@@ -15931,7 +16614,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
15931
16614
 
15932
16615
  // ../../shared-contracts/dist/harness-preferences.js
15933
16616
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
15934
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16617
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
15935
16618
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
15936
16619
  model: harnessModelRefSchema.optional(),
15937
16620
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15941,11 +16624,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
15941
16624
  lastHarness: harnessIdSchema.optional(),
15942
16625
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
15943
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
+ });
15944
16634
  var modelId = external_exports.string().min(1).max(1024);
15945
16635
  var harnessPreferenceValuesSchema = external_exports.strictObject({
15946
16636
  idleRelease: idleReleaseSettingsSchema.optional(),
15947
16637
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
15948
- newThread: newThreadDefaultsSchema.optional()
16638
+ newThread: newThreadDefaultsSchema.optional(),
16639
+ delegation: delegationDefaultsSchema.optional()
15949
16640
  });
15950
16641
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
15951
16642
  scope: harnessPreferenceScopeSchema,
@@ -15973,6 +16664,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
15973
16664
  lastHarness: harnessIdSchema.optional(),
15974
16665
  harnessId: harnessIdSchema.optional(),
15975
16666
  configuration: harnessDefaultConfigurationSchema.optional()
16667
+ }),
16668
+ external_exports.strictObject({
16669
+ kind: external_exports.literal("delegation"),
16670
+ harnessId: harnessIdSchema,
16671
+ configuration: harnessDelegationDefaultSchema.nullable()
15976
16672
  })
15977
16673
  ]);
15978
16674
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -16323,13 +17019,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
16323
17019
  });
16324
17020
 
16325
17021
  // ../../shared-contracts/dist/harness-accounts.js
16326
- var accountBalanceSnapshotSchema = external_exports.object({
16327
- amount: external_exports.number().finite().nonnegative(),
16328
- /** ISO 4217 code as reported by the Provider, for example `CNY`. */
16329
- currency: external_exports.string().trim().min(1).max(8),
16330
- /** Native label when the Harness exposes several Billing Sources. */
16331
- label: external_exports.string().trim().min(1).max(128).optional()
16332
- }).strict();
16333
17022
  var harnessAccountSnapshotObject = external_exports.object({
16334
17023
  email: external_exports.string().trim().min(1).max(320).optional(),
16335
17024
  label: external_exports.string().trim().min(1).max(256).optional(),
@@ -16363,76 +17052,6 @@ var harnessAccountListResultSchema = external_exports.object({
16363
17052
  accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
16364
17053
  }).strict();
16365
17054
 
16366
- // ../../shared-contracts/dist/harness-plugins.js
16367
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
16368
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
16369
- var HARNESS_PLUGIN_LIMIT = 128;
16370
- var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
16371
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
16372
- var relativeResourceSchema = 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");
16373
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
16374
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
16375
- var harnessInstallationGuideSchema = external_exports.object({
16376
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
16377
- before: localizedTextSchema.optional(),
16378
- after: localizedTextSchema.optional(),
16379
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
16380
- }).strict();
16381
- var pluginPresentationShape = {
16382
- id: installedHarnessPluginIdSchema,
16383
- name: external_exports.string().trim().min(1).max(128),
16384
- version: external_exports.string().min(1).max(128),
16385
- /** Capability-only plugin; omitted for existing session-capable plugins. */
16386
- kind: external_exports.literal("usage").optional(),
16387
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
16388
- iconStyle: external_exports.object({
16389
- vector: external_exports.object({
16390
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
16391
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
16392
- paths: external_exports.array(external_exports.object({
16393
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
16394
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
16395
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
16396
- }).strict()).min(1).max(32)
16397
- }).strict().optional(),
16398
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
16399
- borderRadius: external_exports.number().min(0).max(50).optional(),
16400
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
16401
- }).strict().optional(),
16402
- installation: harnessInstallationGuideSchema.optional(),
16403
- notice: localizedTextSchema.optional(),
16404
- /** The factory accepts a persisted local entrypoint through its construction context. */
16405
- launchCommand: external_exports.literal(true).optional(),
16406
- links: external_exports.object({
16407
- website: documentationUrlSchema.optional(),
16408
- documentation: documentationUrlSchema.optional(),
16409
- installation: documentationUrlSchema.optional()
16410
- }).strict().optional()
16411
- };
16412
- var harnessPluginManifestSchema = external_exports.object({
16413
- manifestVersion: external_exports.literal(1),
16414
- ...pluginPresentationShape,
16415
- adapterApiVersion: external_exports.number().int().positive(),
16416
- entry: relativeResourceSchema,
16417
- icon: relativeResourceSchema.optional()
16418
- }).strict();
16419
- 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);
16420
- var harnessPluginDescriptorSchema = external_exports.object({
16421
- ...pluginPresentationShape,
16422
- icon: harnessPluginIconSchema.optional()
16423
- }).strict();
16424
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
16425
- var harnessPluginListResultSchema = external_exports.object({
16426
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
16427
- }).strict();
16428
- var harnessPluginConfigurationSchema = external_exports.object({
16429
- version: external_exports.literal(1),
16430
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
16431
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
16432
- message: "Enabled plugin IDs must be unique",
16433
- path: ["enabled"]
16434
- });
16435
-
16436
17055
  // ../../shared-contracts/dist/harness-route.js
16437
17056
  var harnessPluginRouteSchema = external_exports.object({
16438
17057
  harnessId: harnessPluginIdSchema,
@@ -16873,9 +17492,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16873
17492
  ...thread,
16874
17493
  epoch: identity,
16875
17494
  modelId: identity.optional(),
17495
+ serviceTier: harnessModelServiceTierSchema.optional(),
16876
17496
  thinkingOptionId: identity.optional(),
16877
17497
  permissionModeId: identity.optional()
16878
- }).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
+ }),
16879
17501
  external_exports.strictObject({
16880
17502
  kind: external_exports.literal("prompt"),
16881
17503
  ...thread,
@@ -16925,7 +17547,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
16925
17547
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
16926
17548
  external_exports.strictObject({
16927
17549
  action: external_exports.literal("read-thread"),
16928
- hostId: hostId.refine((id) => id !== "local"),
17550
+ hostId: hostId.refine((id2) => id2 !== "local"),
16929
17551
  input: delegationReadParamsSchema
16930
17552
  }),
16931
17553
  external_exports.strictObject({
@@ -16939,7 +17561,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
16939
17561
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16940
17562
  external_exports.strictObject({
16941
17563
  action: external_exports.literal("update"),
16942
- hostId: hostId.refine((id) => id !== "local"),
17564
+ hostId: hostId.refine((id2) => id2 !== "local"),
16943
17565
  version: remoteUpdateParamsSchema.shape.version
16944
17566
  })
16945
17567
  ]);
@@ -17003,7 +17625,7 @@ function invalidRequest(message) {
17003
17625
  return { code: "invalidRequest", message, retryable: false };
17004
17626
  }
17005
17627
  function validateHostApprovalResponse(interaction, response) {
17006
- 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");
17007
17629
  }
17008
17630
 
17009
17631
  // ../../harness-adapter/dist/question.js
@@ -17011,7 +17633,7 @@ function invalidRequest2(message) {
17011
17633
  return { code: "invalidRequest", message, retryable: false };
17012
17634
  }
17013
17635
  function validateHostQuestionResponse(interaction, response) {
17014
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17636
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
17015
17637
  if (response.cancelled) {
17016
17638
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
17017
17639
  }
@@ -17143,7 +17765,8 @@ var tokenFields = [
17143
17765
  var safeIntegerFields = [
17144
17766
  "planFiveHourResetsAtUnix",
17145
17767
  "planSevenDayResetsAtUnix",
17146
- "timeToFirstOutputMs"
17768
+ "timeToFirstOutputMs",
17769
+ "latestRequestTimeToFirstOutputMs"
17147
17770
  ];
17148
17771
  var percentFields = [
17149
17772
  "cacheHitRatePercent",
@@ -17429,7 +18052,7 @@ var CURSOR_COMMAND_CATALOG = cursorCommands([
17429
18052
  { name: "copy-request-id", description: "Copy the current request ID", input: null }
17430
18053
  ]);
17431
18054
  function cursorCommandPrompt(command, catalog) {
17432
- const descriptor = catalog.commands.find(({ id }) => id === command.commandId);
18055
+ const descriptor = catalog.commands.find(({ id: id2 }) => id2 === command.commandId);
17433
18056
  if (!descriptor)
17434
18057
  return {
17435
18058
  ok: false,
@@ -17807,10 +18430,10 @@ function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = fal
17807
18430
  const metadata = JSON.parse(Buffer.from(row.value, "hex").toString("utf8"));
17808
18431
  if (metadata.agentId !== sessionId || typeof metadata.latestRootBlobId !== "string")
17809
18432
  throw new Error("Cursor native session identity mismatch");
17810
- const get = (id) => {
17811
- if (!/^[0-9a-f]{64}$/u.test(id))
18433
+ const get = (id2) => {
18434
+ if (!/^[0-9a-f]{64}$/u.test(id2))
17812
18435
  throw new Error("Invalid Cursor native blob reference");
17813
- 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;
17814
18437
  if (!(blob instanceof Uint8Array))
17815
18438
  throw new Error("Cursor native history blob is missing");
17816
18439
  return protobufBytes(blob);
@@ -17824,13 +18447,13 @@ function readCursorNativeHistory(sessionId, cwd, environment, allowMissing = fal
17824
18447
  for (const record4 of container.get(1) ?? []) {
17825
18448
  const turn = protobufBytes(record4);
17826
18449
  const user = get(one(turn, 1).toString("hex"));
17827
- const id = one(user, 2).toString("utf8");
17828
- 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))
17829
18452
  throw new Error("Cursor native turn ID is invalid or duplicated");
17830
18453
  const anchor = user.get(10)?.[0];
17831
18454
  const rewindRoot = anchor?.length === 32 && db.prepare("SELECT 1 FROM blobs WHERE id = ?").get(anchor.toString("hex")) ? anchor.toString("hex") : void 0;
17832
18455
  result.push({
17833
- id,
18456
+ id: id2,
17834
18457
  text: one(user, 1).toString("utf8"),
17835
18458
  ...rewindRoot ? { rewindRoot } : {},
17836
18459
  ...user.get(15)?.length ? { notification: true } : {}
@@ -17941,12 +18564,12 @@ var CursorSessionImport = class {
17941
18564
  } : null;
17942
18565
  });
17943
18566
  }
17944
- async #candidate(id, signal) {
18567
+ async #candidate(id2, signal) {
17945
18568
  signal.throwIfAborted();
17946
18569
  const root = path7.join(cursorConfigDirectory(this.#environment), "acp-sessions");
17947
18570
  if (!(await optionalStat(root))?.isDirectory())
17948
18571
  return null;
17949
- const directory = cursorSessionDirectory(id, this.#environment);
18572
+ const directory = cursorSessionDirectory(id2, this.#environment);
17950
18573
  const files = [
17951
18574
  directory,
17952
18575
  path7.join(directory, "meta.json"),
@@ -17967,7 +18590,7 @@ var CursorSessionImport = class {
17967
18590
  if (!(await stat(cwd)).isDirectory())
17968
18591
  return null;
17969
18592
  signal.throwIfAborted();
17970
- const turns = readCursorNativeTurns(id, cwd, this.#environment);
18593
+ const turns = readCursorNativeTurns(id2, cwd, this.#environment);
17971
18594
  if (!turns.length)
17972
18595
  return null;
17973
18596
  title = sessionImportTitle(turns[0]?.text);
@@ -17982,7 +18605,7 @@ var CursorSessionImport = class {
17982
18605
  if (before.some((info, index) => !sameFileFingerprint(info, after[index] ?? null)))
17983
18606
  throw new SessionImportChangedError("Cursor Session changed during discovery");
17984
18607
  return sessionImportCandidate({
17985
- nativeSessionId: id,
18608
+ nativeSessionId: id2,
17986
18609
  cwd,
17987
18610
  title,
17988
18611
  updatedAt: Math.max(database.mtimeMs, wal?.mtimeMs ?? 0)
@@ -18020,16 +18643,16 @@ function cursorThinking(options) {
18020
18643
  return [];
18021
18644
  return combinations.flatMap(({ values, labels }) => {
18022
18645
  const encoded = Buffer.from(JSON.stringify(values)).toString("base64url");
18023
- const id = harnessThinkingOptionIdSchema.safeParse(`cursor.${encoded}`);
18024
- 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 }] : [];
18025
18648
  });
18026
18649
  }
18027
18650
  function cursorThinkingState(info) {
18028
18651
  const options = cursorThinking(info.configOptions);
18029
- 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)));
18030
18653
  return {
18031
- availableThinkingOptions: options.map(({ id, label }) => ({
18032
- id,
18654
+ availableThinkingOptions: options.map(({ id: id2, label }) => ({
18655
+ id: id2,
18033
18656
  label
18034
18657
  })),
18035
18658
  ...current ? { effectiveThinkingOptionId: current.id } : {}
@@ -18110,8 +18733,8 @@ function cursorCatalog(info) {
18110
18733
  const live = model2.value === native.current;
18111
18734
  const config2 = live ? info.configOptions : info.nativeModels?.find((entry) => entry.value === model2.value)?.configOptions;
18112
18735
  const options = cursorThinking(config2);
18113
- for (const { id, label } of options)
18114
- thinking.set(id, { id, label });
18736
+ for (const { id: id2, label } of options)
18737
+ thinking.set(id2, { id: id2, label });
18115
18738
  return {
18116
18739
  // Only the live model's parameters reflect the user's Cursor settings. The parameterized
18117
18740
  // catalog reports Cursor's built-in defaults for every other model (for example
@@ -18119,7 +18742,7 @@ function cursorCatalog(info) {
18119
18742
  // A bare Ref selects only the model and lets Cursor apply those parameters itself.
18120
18743
  ref: live ? cursorConfiguredModelRef(model2.value, config2) : cursorModelRef(model2.value),
18121
18744
  label: model2.name,
18122
- supportedThinkingOptionIds: options.map(({ id }) => id)
18745
+ supportedThinkingOptionIds: options.map(({ id: id2 }) => id2)
18123
18746
  };
18124
18747
  });
18125
18748
  if (!models.length)
@@ -18177,13 +18800,13 @@ function cursorModelSelection(info, ref) {
18177
18800
  const parameters = [];
18178
18801
  for (const parameter of match[2] ? match[2].split(",") : []) {
18179
18802
  const pair = parameter.split("=");
18180
- const [id, value] = pair;
18181
- 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))
18182
18805
  throw new Error("Invalid Cursor model parameters");
18183
- const option = model2.configOptions.find((option2) => option2.id === id);
18806
+ const option = model2.configOptions.find((option2) => option2.id === id2);
18184
18807
  if (!option || option.type !== "select" || !option.options.flatMap((entry) => "value" in entry ? [entry] : entry.options).some((entry) => entry.value === value))
18185
18808
  throw new Error("Legacy Cursor model parameter is not selectable in the native catalog");
18186
- parameters.push([id, value]);
18809
+ parameters.push([id2, value]);
18187
18810
  }
18188
18811
  return [["model", model2.value], ...parameters];
18189
18812
  }
@@ -20057,8 +20680,8 @@ var RequestResponder = class {
20057
20680
  signal;
20058
20681
  finishRequest;
20059
20682
  didRespond = false;
20060
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
20061
- this.id = id;
20683
+ constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
20684
+ this.id = id2;
20062
20685
  this.sendResult = sendResult;
20063
20686
  this.signal = signal;
20064
20687
  this.finishRequest = finishRequest;
@@ -20349,7 +20972,7 @@ var Connection = class {
20349
20972
  return this.sendWireMessage({ jsonrpc: "2.0", method, params });
20350
20973
  }
20351
20974
  prepareRequest(method, params, mapResponse, options = {}) {
20352
- const id = this.nextRequestId++;
20975
+ const id2 = this.nextRequestId++;
20353
20976
  let cancel = () => {
20354
20977
  };
20355
20978
  const response = new Promise((resolve, reject) => {
@@ -20369,7 +20992,7 @@ var Connection = class {
20369
20992
  }
20370
20993
  pendingResponse.cancellationSent = true;
20371
20994
  pendingResponse.cleanup?.();
20372
- void this.sendCancelRequest(id).catch(() => {
20995
+ void this.sendCancelRequest(id2).catch(() => {
20373
20996
  });
20374
20997
  };
20375
20998
  options.cancellationSignal?.addEventListener("abort", cancel, {
@@ -20378,12 +21001,12 @@ var Connection = class {
20378
21001
  pendingResponse.cleanup = () => {
20379
21002
  options.cancellationSignal?.removeEventListener("abort", cancel);
20380
21003
  };
20381
- this.pendingResponses.set(id, pendingResponse);
21004
+ this.pendingResponses.set(id2, pendingResponse);
20382
21005
  });
20383
21006
  response.catch(() => {
20384
21007
  });
20385
21008
  return {
20386
- message: { jsonrpc: "2.0", id, method, params },
21009
+ message: { jsonrpc: "2.0", id: id2, method, params },
20387
21010
  response,
20388
21011
  cancel: () => cancel()
20389
21012
  };
@@ -21020,7 +21643,7 @@ function memoryStreamPair() {
21020
21643
  }
21021
21644
  ];
21022
21645
  }
21023
- var methods = {
21646
+ var methods2 = {
21024
21647
  agent: {
21025
21648
  initialize: AGENT_METHODS.initialize,
21026
21649
  authenticate: AGENT_METHODS.authenticate,
@@ -23899,7 +24522,7 @@ async function forkCursorSession(source, checkpoint, options, signal, forkOption
23899
24522
  }, source.nativeSessionId, signal, rewindTurn ? {
23900
24523
  steps: sourceTurns.slice(retained).filter((turn) => turn.rewindRoot).length,
23901
24524
  complete: () => {
23902
- const targets = readdirSync2(chats).filter((id) => id !== source.nativeSessionId);
24525
+ const targets = readdirSync2(chats).filter((id2) => id2 !== source.nativeSessionId);
23903
24526
  const targetId = targets[0];
23904
24527
  return targets.length === 1 && !!targetId && storeIdentity(path8.join(chats, targetId), false).root === rewindTurn.rewindRoot;
23905
24528
  }
@@ -23974,9 +24597,9 @@ var CursorAdapter = class {
23974
24597
  const session = [...this.#sessions].find((s) => s.transport.sessionId === parent.nativeSessionId);
23975
24598
  if (session && path9.resolve(session.transport.options.cwd) !== path9.resolve(cwd))
23976
24599
  return rejected("invalidRequest", "Cursor parent workspace does not match");
23977
- const active = session?.subagentSnapshot(nativeSubagentId);
23978
- if (active)
23979
- return { ok: true, value: active };
24600
+ const active2 = session?.subagentSnapshot(nativeSubagentId);
24601
+ if (active2)
24602
+ return { ok: true, value: active2 };
23980
24603
  const options = session?.transport.options ?? this.transportOptions(cwd);
23981
24604
  const before = readCursorNativeTurns(parent.nativeSessionId, cwd, options.environment);
23982
24605
  replay = new CursorTransport({
@@ -24003,6 +24626,7 @@ var CursorAdapter = class {
24003
24626
  #sessions = /* @__PURE__ */ new Set();
24004
24627
  #forks = /* @__PURE__ */ new Map();
24005
24628
  #inspections = /* @__PURE__ */ new Map();
24629
+ #inspectionTasks = /* @__PURE__ */ new Set();
24006
24630
  #closed = false;
24007
24631
  sessionImport;
24008
24632
  constructor(options = {}) {
@@ -24030,8 +24654,14 @@ var CursorAdapter = class {
24030
24654
  };
24031
24655
  const cwd = path9.resolve(input.cwd ?? process.cwd());
24032
24656
  const cached2 = this.#inspections.get(cwd);
24033
- if (cached2 && (cached2.pending || !input.refresh))
24034
- 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;
24035
24665
  const result = (async () => {
24036
24666
  const transport = new CursorTransport(this.transportOptions(cwd));
24037
24667
  try {
@@ -24052,11 +24682,9 @@ var CursorAdapter = class {
24052
24682
  await transport.close();
24053
24683
  }
24054
24684
  })();
24055
- const entry = { pending: true, result };
24056
- this.#inspections.set(cwd, entry);
24057
- void result.finally(() => {
24058
- entry.pending = false;
24059
- });
24685
+ this.#inspections.set(cwd, result);
24686
+ this.#inspectionTasks.add(result);
24687
+ void result.finally(() => this.#inspectionTasks.delete(result));
24060
24688
  return result;
24061
24689
  }
24062
24690
  async open(input) {
@@ -24236,7 +24864,7 @@ var CursorAdapter = class {
24236
24864
  controller.abort();
24237
24865
  await Promise.allSettled([importing, ...this.#forks.values()]);
24238
24866
  await Promise.allSettled([...this.#sessions].map((session) => session.close()));
24239
- await Promise.allSettled([...this.#inspections.values()].map((inspection) => inspection.result));
24867
+ await Promise.allSettled(this.#inspectionTasks);
24240
24868
  }
24241
24869
  };
24242
24870
  var CursorSession = class {
@@ -24382,8 +25010,8 @@ var CursorSession = class {
24382
25010
  if (command.type === "turn.cancel") {
24383
25011
  if (!this.#active || this.#active.command.turnId !== command.turnId)
24384
25012
  return rejected("invalidState", "Cursor turn is not active");
24385
- const active = this.#active;
24386
- active.cancelled = true;
25013
+ const active2 = this.#active;
25014
+ active2.cancelled = true;
24387
25015
  this.#interactions.cancel();
24388
25016
  try {
24389
25017
  await this.transport.cancel();
@@ -24391,10 +25019,10 @@ var CursorSession = class {
24391
25019
  await this.transport.close();
24392
25020
  }
24393
25021
  const timer = setTimeout(() => {
24394
- if (this.#active === active)
25022
+ if (this.#active === active2)
24395
25023
  void this.transport.close();
24396
25024
  }, 5e3);
24397
- void active.task.finally(() => clearTimeout(timer));
25025
+ void active2.task.finally(() => clearTimeout(timer));
24398
25026
  return { ok: true, value: { cancellationRequested: true } };
24399
25027
  }
24400
25028
  if (this.#configuring || this.#active && command.type !== "model.select" && command.type !== "thinking.select")
@@ -24412,16 +25040,16 @@ var CursorSession = class {
24412
25040
  }
24413
25041
  this.#submitted.add(command.turnId);
24414
25042
  this.#snapshot = void 0;
24415
- const active = { command, cancelled: false, task: Promise.resolve() };
24416
- this.#active = active;
24417
- 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);
24418
25046
  return { ok: true, value: { turnId: command.turnId } };
24419
25047
  }
24420
25048
  this.#configuring = true;
24421
25049
  try {
24422
25050
  let selections;
24423
25051
  if (command.type === "thinking.select") {
24424
- const option = cursorThinking(this.info.configOptions).find(({ id }) => id === command.thinkingOptionId);
25052
+ const option = cursorThinking(this.info.configOptions).find(({ id: id2 }) => id2 === command.thinkingOptionId);
24425
25053
  if (!option)
24426
25054
  return rejected("unsupported", "Thinking option is not available for this Cursor model");
24427
25055
  selections = option.values;
@@ -24561,13 +25189,13 @@ var CursorSession = class {
24561
25189
  if (this.#closed)
24562
25190
  return;
24563
25191
  this.#closed = true;
24564
- const active = this.#active;
24565
- if (active)
24566
- active.cancelled = true;
25192
+ const active2 = this.#active;
25193
+ if (active2)
25194
+ active2.cancelled = true;
24567
25195
  this.#interactions.cancel();
24568
25196
  try {
24569
25197
  await this.transport.close();
24570
- await active?.task;
25198
+ await active2?.task;
24571
25199
  } finally {
24572
25200
  this.#channel.end();
24573
25201
  this.onClose();
@@ -24584,6 +25212,7 @@ import net, {} from "node:net";
24584
25212
  // ../../harness-broker/dist/protocol.js
24585
25213
  var HARNESS_BROKER_PROTOCOL_VERSION = 1;
24586
25214
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
25215
+ var HARNESS_BROKER_MAX_RESPONSE_BYTES = 32 * 1024 * 1024;
24587
25216
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
24588
25217
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
24589
25218
  var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
@@ -24591,6 +25220,7 @@ var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
24591
25220
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
24592
25221
  var harnessBrokerMethodSchema = external_exports.enum([
24593
25222
  "adapter.inspect",
25223
+ "adapter.normalizeStoredModelRef",
24594
25224
  "adapter.inspectAccount",
24595
25225
  "adapter.credits",
24596
25226
  "adapter.open",
@@ -24611,7 +25241,9 @@ var harnessBrokerHelloSchema = external_exports.object({
24611
25241
  generation: external_exports.string().uuid(),
24612
25242
  sequence: external_exports.literal(1),
24613
25243
  kind: external_exports.literal("hello"),
24614
- token: external_exports.string().regex(/^[a-f0-9]{64}$/u)
25244
+ token: external_exports.string().regex(/^[a-f0-9]{64}$/u),
25245
+ // A declared limit must leave room for the hello and frame-size error responses.
25246
+ maxResponseBytes: external_exports.number().int().min(512).max(Number.MAX_SAFE_INTEGER).optional()
24615
25247
  }).strict();
24616
25248
  var harnessBrokerRequestSchema = external_exports.object({
24617
25249
  version: external_exports.literal(HARNESS_BROKER_PROTOCOL_VERSION),
@@ -24660,40 +25292,63 @@ var harnessBrokerDescriptorSchema = external_exports.object({
24660
25292
  }).strict();
24661
25293
 
24662
25294
  // ../../harness-broker/dist/framing.js
24663
- function writeBrokerFrame(socket, value) {
25295
+ function writeBrokerFrame(socket, value, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
24664
25296
  const frame = `${JSON.stringify(value)}
24665
25297
  `;
24666
- if (Buffer.byteLength(frame) > HARNESS_BROKER_MAX_FRAME_BYTES) {
24667
- return Promise.reject(new Error("Harness broker frame exceeds the maximum size"));
25298
+ if (Buffer.byteLength(frame) > maxBytes) {
25299
+ throw new Error("Harness broker frame exceeds the maximum size");
24668
25300
  }
24669
25301
  return new Promise((resolve, reject) => {
24670
25302
  socket.write(frame, (error51) => error51 ? reject(error51) : resolve());
24671
25303
  });
24672
25304
  }
24673
- function consumeBrokerFrames(socket, onFrame, onError) {
25305
+ function consumeBrokerFrames(socket, onFrame, onError, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
24674
25306
  let buffered = Buffer.alloc(0);
25307
+ let bufferedBytes = 0;
25308
+ let stopped = false;
25309
+ const fail = (error51) => {
25310
+ stopped = true;
25311
+ buffered = Buffer.alloc(0);
25312
+ bufferedBytes = 0;
25313
+ onError(error51);
25314
+ socket.destroy();
25315
+ };
24675
25316
  socket.on("data", (chunk) => {
24676
- buffered = Buffer.concat([buffered, chunk]);
24677
- if (buffered.length > HARNESS_BROKER_MAX_FRAME_BYTES) {
24678
- onError(new Error("Harness broker frame exceeds the maximum size"));
24679
- socket.destroy();
25317
+ if (stopped)
24680
25318
  return;
24681
- }
24682
- let newline2 = buffered.indexOf(10);
24683
- while (newline2 >= 0) {
24684
- const frame = buffered.subarray(0, newline2);
24685
- buffered = buffered.subarray(newline2 + 1);
24686
- if (frame.length > 0) {
25319
+ let start = 0;
25320
+ while (start < chunk.length) {
25321
+ const newline2 = chunk.indexOf(10, start);
25322
+ const part = chunk.subarray(start, newline2 < 0 ? chunk.length : newline2);
25323
+ const required2 = bufferedBytes + part.length;
25324
+ if (required2 + (newline2 < 0 ? 0 : 1) > maxBytes) {
25325
+ fail(new Error("Harness broker frame exceeds the maximum size"));
25326
+ return;
25327
+ }
25328
+ if (required2 > buffered.length) {
25329
+ const capacity = Math.min(maxBytes, Math.max(required2, 4096, buffered.length * 2));
25330
+ const next = Buffer.allocUnsafe(capacity);
25331
+ buffered.copy(next, 0, 0, bufferedBytes);
25332
+ buffered = next;
25333
+ }
25334
+ part.copy(buffered, bufferedBytes);
25335
+ bufferedBytes = required2;
25336
+ if (newline2 < 0)
25337
+ return;
25338
+ const text = buffered.toString("utf8", 0, bufferedBytes);
25339
+ bufferedBytes = 0;
25340
+ if (buffered.length > 64 * 1024)
25341
+ buffered = Buffer.alloc(0);
25342
+ if (text.length > 0) {
24687
25343
  try {
24688
- const value = JSON.parse(frame.toString("utf8"));
25344
+ const value = JSON.parse(text);
24689
25345
  onFrame(value);
24690
25346
  } catch (error51) {
24691
- onError(error51 instanceof SyntaxError ? new Error("Harness broker received invalid JSON") : error51 instanceof Error ? error51 : new Error(String(error51)));
24692
- socket.destroy();
25347
+ fail(error51 instanceof SyntaxError ? new Error("Harness broker received invalid JSON") : error51 instanceof Error ? error51 : new Error(String(error51)));
24693
25348
  return;
24694
25349
  }
24695
25350
  }
24696
- newline2 = buffered.indexOf(10);
25351
+ start = newline2 + 1;
24697
25352
  }
24698
25353
  });
24699
25354
  }
@@ -24753,6 +25408,10 @@ var brokerInspectInputSchema = external_exports.object({
24753
25408
  refresh: external_exports.boolean().optional(),
24754
25409
  purpose: external_exports.literal("availability").optional()
24755
25410
  }).strict();
25411
+ var brokerNormalizeStoredModelRefSchema = external_exports.strictObject({
25412
+ ref: harnessModelRefSchema,
25413
+ catalog: harnessModelCatalogSchema
25414
+ });
24756
25415
  var brokerSessionImportListParamsSchema = external_exports.object({
24757
25416
  offset: external_exports.number().int().nonnegative().safe(),
24758
25417
  limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
@@ -24881,15 +25540,18 @@ var eventKeys = /* @__PURE__ */ new Map([
24881
25540
  ["session.state.changed", /* @__PURE__ */ new Set(["type", "state"])],
24882
25541
  ["session.usage.changed", /* @__PURE__ */ new Set(["type", "usage", "observedForTurnId"])],
24883
25542
  ["usage.request", /* @__PURE__ */ new Set(["type", "request"])],
25543
+ ["usage.request.timing", /* @__PURE__ */ new Set(["type", "turnId", "timing"])],
24884
25544
  ["usage.history", /* @__PURE__ */ new Set(["type", "complete"])],
24885
25545
  ["subagent.state.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId", "status", "resultSummary"])],
24886
25546
  ["subagent.transcript.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId"])],
24887
25547
  ["turn.started", /* @__PURE__ */ new Set(["type", "turnId"])],
24888
25548
  ["turn.autonomous.started", /* @__PURE__ */ new Set(["type", "turnId", "input"])],
25549
+ ["turn.autonomous.completed", /* @__PURE__ */ new Set(["type", "snapshot"])],
24889
25550
  ["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
24890
25551
  ["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
24891
25552
  ["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
24892
25553
  ["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
25554
+ ["item.background.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
24893
25555
  ["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
24894
25556
  ["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome"])],
24895
25557
  ["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
@@ -24916,6 +25578,118 @@ var interactionKeys = /* @__PURE__ */ new Map([
24916
25578
  function strictKeys(value, allowed) {
24917
25579
  return Boolean(allowed && value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).every((key) => allowed.has(key)));
24918
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
+ ]);
24919
25693
  var harnessOutputSchema = external_exports.custom((value) => {
24920
25694
  if (!value || typeof value !== "object" || Array.isArray(value))
24921
25695
  return false;
@@ -24928,10 +25702,20 @@ var harnessOutputSchema = external_exports.custom((value) => {
24928
25702
  return false;
24929
25703
  if (event.type === "session.state.changed")
24930
25704
  return harnessSessionStateSchema.safeParse(event.state).success;
25705
+ if (event.type === "item.background.started")
25706
+ return hostTurnIdSchema.safeParse(event.turnId).success && external_exports.object({
25707
+ type: external_exports.enum(["agentMessage", "reasoning"]),
25708
+ itemId: hostItemIdSchema,
25709
+ text: external_exports.string()
25710
+ }).strict().safeParse(event.item).success;
25711
+ if (event.type === "turn.autonomous.completed")
25712
+ return autonomousSnapshotSchema.safeParse(event.snapshot).success;
24931
25713
  if (event.type === "session.faulted")
24932
25714
  return harnessErrorSchema.safeParse(event.error).success;
24933
25715
  if (event.type === "usage.history")
24934
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;
24935
25719
  return true;
24936
25720
  }
24937
25721
  if (output.kind === "interaction") {
@@ -25205,7 +25989,7 @@ var BrokerConnection = class _BrokerConnection {
25205
25989
  constructor(descriptor, socket) {
25206
25990
  this.#descriptor = descriptor;
25207
25991
  this.#socket = socket;
25208
- consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error51) => this.#fail(error51));
25992
+ consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error51) => this.#fail(error51), HARNESS_BROKER_MAX_RESPONSE_BYTES);
25209
25993
  socket.once("close", () => this.#fail(new Error("Aqua Harness broker connection closed")));
25210
25994
  socket.once("error", (error51) => this.#fail(error51));
25211
25995
  }
@@ -25242,19 +26026,20 @@ var BrokerConnection = class _BrokerConnection {
25242
26026
  generation: descriptor.generation,
25243
26027
  sequence: 1,
25244
26028
  kind: "hello",
25245
- token: descriptor.token
26029
+ token: descriptor.token,
26030
+ maxResponseBytes: HARNESS_BROKER_MAX_RESPONSE_BYTES
25246
26031
  });
25247
26032
  await hello;
25248
26033
  return connection;
25249
26034
  }
25250
26035
  #waitForHello() {
25251
26036
  return new Promise((resolve, reject) => {
25252
- const id = "__hello__";
26037
+ const id2 = "__hello__";
25253
26038
  const timeout = setTimeout(() => {
25254
- this.#pending.delete(id);
26039
+ this.#pending.delete(id2);
25255
26040
  reject(new Error("Aqua Harness broker authentication timed out"));
25256
26041
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
25257
- this.#pending.set(id, { resolve: () => resolve(), reject, timeout });
26042
+ this.#pending.set(id2, { resolve: () => resolve(), reject, timeout });
25258
26043
  });
25259
26044
  }
25260
26045
  register(session) {
@@ -25279,13 +26064,13 @@ var BrokerConnection = class _BrokerConnection {
25279
26064
  throw new Error("Aqua Harness broker request limit exceeded");
25280
26065
  }
25281
26066
  this.#inputSequence += 1;
25282
- const id = randomUUID2();
26067
+ const id2 = randomUUID2();
25283
26068
  const response = new Promise((resolve, reject) => {
25284
26069
  const timeout = setTimeout(() => {
25285
- this.#pending.delete(id);
26070
+ this.#pending.delete(id2);
25286
26071
  reject(new Error(`Aqua Harness broker ${method} timed out`));
25287
26072
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
25288
- this.#pending.set(id, { resolve, reject, timeout });
26073
+ this.#pending.set(id2, { resolve, reject, timeout });
25289
26074
  });
25290
26075
  try {
25291
26076
  await writeBrokerFrame(this.#socket, {
@@ -25293,15 +26078,15 @@ var BrokerConnection = class _BrokerConnection {
25293
26078
  generation: this.#descriptor.generation,
25294
26079
  sequence: this.#inputSequence,
25295
26080
  kind: "request",
25296
- id,
26081
+ id: id2,
25297
26082
  method,
25298
26083
  params
25299
26084
  });
25300
26085
  } catch (error51) {
25301
- const pending = this.#pending.get(id);
26086
+ const pending = this.#pending.get(id2);
25302
26087
  if (pending)
25303
26088
  clearTimeout(pending.timeout);
25304
- this.#pending.delete(id);
26089
+ this.#pending.delete(id2);
25305
26090
  response.catch(() => void 0);
25306
26091
  throw new BrokerRequestNotDeliveredError(error51 instanceof Error ? error51.message : String(error51));
25307
26092
  }
@@ -25668,6 +26453,10 @@ var BrokeredHarnessAdapter = class {
25668
26453
  return failedInspection(describeBrokerFailure(error51, this.harnessId));
25669
26454
  }
25670
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
+ }
25671
26460
  async open(input) {
25672
26461
  if (this.#closed)
25673
26462
  return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };