@codexhost/cli-darwin-x64 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
@@ -1264,8 +1264,8 @@ function cleanEnum(obj) {
1264
1264
  return Number.isNaN(Number.parseInt(k, 10));
1265
1265
  }).map((el) => el[1]);
1266
1266
  }
1267
- function base64ToUint8Array(base643) {
1268
- const binaryString = atob(base643);
1267
+ function base64ToUint8Array(base644) {
1268
+ const binaryString = atob(base644);
1269
1269
  const bytes = new Uint8Array(binaryString.length);
1270
1270
  for (let i = 0; i < binaryString.length; i++) {
1271
1271
  bytes[i] = binaryString.charCodeAt(i);
@@ -1280,9 +1280,9 @@ function uint8ArrayToBase64(bytes) {
1280
1280
  return btoa(binaryString);
1281
1281
  }
1282
1282
  function base64urlToUint8Array(base64url3) {
1283
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1284
- const padding = "=".repeat((4 - base643.length % 4) % 4);
1285
- return base64ToUint8Array(base643 + padding);
1283
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1284
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
1285
+ return base64ToUint8Array(base644 + padding);
1286
1286
  }
1287
1287
  function uint8ArrayToBase64url(bytes) {
1288
1288
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -2648,8 +2648,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
2648
2648
  function isValidBase64URL(data) {
2649
2649
  if (!base64url.test(data))
2650
2650
  return false;
2651
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
2652
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
2651
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
2652
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
2653
2653
  return isValidBase64(padded);
2654
2654
  }
2655
2655
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -3103,42 +3103,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3103
3103
  }
3104
3104
  doc.write(`const newResult = {};`);
3105
3105
  for (const key of normalized.keys) {
3106
- const id = ids[key];
3106
+ const id2 = ids[key];
3107
3107
  const k = esc(key);
3108
3108
  const schema = shape[key];
3109
3109
  const isOptionalIn = schema?._zod?.optin === "optional";
3110
3110
  const isOptionalOut = schema?._zod?.optout === "optional";
3111
- doc.write(`const ${id} = ${parseStr(key)};`);
3111
+ doc.write(`const ${id2} = ${parseStr(key)};`);
3112
3112
  if (isOptionalIn && isOptionalOut) {
3113
3113
  doc.write(`
3114
- if (${id}.issues.length) {
3114
+ if (${id2}.issues.length) {
3115
3115
  if (${k} in input) {
3116
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3116
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3117
3117
  ...iss,
3118
3118
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3119
3119
  })));
3120
3120
  }
3121
3121
  }
3122
3122
 
3123
- if (${id}.value === undefined) {
3123
+ if (${id2}.value === undefined) {
3124
3124
  if (${k} in input) {
3125
3125
  newResult[${k}] = undefined;
3126
3126
  }
3127
3127
  } else {
3128
- newResult[${k}] = ${id}.value;
3128
+ newResult[${k}] = ${id2}.value;
3129
3129
  }
3130
3130
 
3131
3131
  `);
3132
3132
  } else if (!isOptionalIn) {
3133
3133
  doc.write(`
3134
- const ${id}_present = ${k} in input;
3135
- if (${id}.issues.length) {
3136
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3134
+ const ${id2}_present = ${k} in input;
3135
+ if (${id2}.issues.length) {
3136
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3137
3137
  ...iss,
3138
3138
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3139
3139
  })));
3140
3140
  }
3141
- if (!${id}_present && !${id}.issues.length) {
3141
+ if (!${id2}_present && !${id2}.issues.length) {
3142
3142
  payload.issues.push({
3143
3143
  code: "invalid_type",
3144
3144
  expected: "nonoptional",
@@ -3147,30 +3147,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3147
3147
  });
3148
3148
  }
3149
3149
 
3150
- if (${id}_present) {
3151
- if (${id}.value === undefined) {
3150
+ if (${id2}_present) {
3151
+ if (${id2}.value === undefined) {
3152
3152
  newResult[${k}] = undefined;
3153
3153
  } else {
3154
- newResult[${k}] = ${id}.value;
3154
+ newResult[${k}] = ${id2}.value;
3155
3155
  }
3156
3156
  }
3157
3157
 
3158
3158
  `);
3159
3159
  } else {
3160
3160
  doc.write(`
3161
- if (${id}.issues.length) {
3162
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3161
+ if (${id2}.issues.length) {
3162
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3163
3163
  ...iss,
3164
3164
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3165
3165
  })));
3166
3166
  }
3167
3167
 
3168
- if (${id}.value === undefined) {
3168
+ if (${id2}.value === undefined) {
3169
3169
  if (${k} in input) {
3170
3170
  newResult[${k}] = undefined;
3171
3171
  }
3172
3172
  } else {
3173
- newResult[${k}] = ${id}.value;
3173
+ newResult[${k}] = ${id2}.value;
3174
3174
  }
3175
3175
 
3176
3176
  `);
@@ -11502,26 +11502,26 @@ function extractDefs(ctx, schema) {
11502
11502
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11503
11503
  const idToSchema = /* @__PURE__ */ new Map();
11504
11504
  for (const entry of ctx.seen.entries()) {
11505
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11506
- if (id) {
11507
- const existing = idToSchema.get(id);
11505
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11506
+ if (id2) {
11507
+ const existing = idToSchema.get(id2);
11508
11508
  if (existing && existing !== entry[0]) {
11509
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11509
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11510
11510
  }
11511
- idToSchema.set(id, entry[0]);
11511
+ idToSchema.set(id2, entry[0]);
11512
11512
  }
11513
11513
  }
11514
11514
  const makeURI = (entry) => {
11515
11515
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11516
11516
  if (ctx.external) {
11517
11517
  const externalId = ctx.external.registry.get(entry[0])?.id;
11518
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11518
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
11519
11519
  if (externalId) {
11520
11520
  return { ref: uriGenerator(externalId) };
11521
11521
  }
11522
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11523
- entry[1].defId = id;
11524
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
11522
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
11523
+ entry[1].defId = id2;
11524
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
11525
11525
  }
11526
11526
  if (entry[1] === root) {
11527
11527
  return { ref: "#" };
@@ -11569,8 +11569,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
11569
11569
  continue;
11570
11570
  }
11571
11571
  }
11572
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11573
- if (id) {
11572
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11573
+ if (id2) {
11574
11574
  extractToDef(entry);
11575
11575
  continue;
11576
11576
  }
@@ -11666,10 +11666,10 @@ function finalize(ctx, schema) {
11666
11666
  } else {
11667
11667
  }
11668
11668
  if (ctx.external?.uri) {
11669
- const id = ctx.external.registry.get(schema)?.id;
11670
- if (!id)
11669
+ const id2 = ctx.external.registry.get(schema)?.id;
11670
+ if (!id2)
11671
11671
  throw new Error("Schema is missing an `id` property");
11672
- result.$id = ctx.external.uri(id);
11672
+ result.$id = ctx.external.uri(id2);
11673
11673
  }
11674
11674
  Object.assign(result, root.def ?? root.schema);
11675
11675
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -11829,9 +11829,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
11829
11829
  json2.type = "number";
11830
11830
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
11831
11831
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
11832
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
11832
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
11833
11833
  if (exMin) {
11834
- if (legacy) {
11834
+ if (legacy2) {
11835
11835
  json2.minimum = exclusiveMinimum;
11836
11836
  json2.exclusiveMinimum = true;
11837
11837
  } else {
@@ -11841,7 +11841,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
11841
11841
  json2.minimum = minimum;
11842
11842
  }
11843
11843
  if (exMax) {
11844
- if (legacy) {
11844
+ if (legacy2) {
11845
11845
  json2.maximum = exclusiveMaximum;
11846
11846
  json2.exclusiveMaximum = true;
11847
11847
  } else {
@@ -12703,7 +12703,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
12703
12703
 
12704
12704
  // ../../../node_modules/zod/v4/classic/schemas.js
12705
12705
  var _installedGroups = /* @__PURE__ */ new WeakMap();
12706
- function _installLazyMethods(inst, group, methods2) {
12706
+ function _installLazyMethods(inst, group, methods3) {
12707
12707
  const proto = Object.getPrototypeOf(inst);
12708
12708
  let installed = _installedGroups.get(proto);
12709
12709
  if (!installed) {
@@ -12713,8 +12713,8 @@ function _installLazyMethods(inst, group, methods2) {
12713
12713
  if (installed.has(group))
12714
12714
  return;
12715
12715
  installed.add(group);
12716
- for (const key in methods2) {
12717
- const fn = methods2[key];
12716
+ for (const key in methods3) {
12717
+ const fn = methods3[key];
12718
12718
  Object.defineProperty(proto, key, {
12719
12719
  configurable: true,
12720
12720
  enumerable: false,
@@ -14658,6 +14658,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
14658
14658
  permissionModeId: harnessPermissionModeIdSchema
14659
14659
  }).strict();
14660
14660
 
14661
+ // ../../shared-contracts/dist/harness-route-limit.js
14662
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
14663
+
14661
14664
  // ../../shared-contracts/dist/thread-usage.js
14662
14665
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
14663
14666
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -14690,7 +14693,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
14690
14693
  expiresAtUnix: nonNegativeSafeIntegerSchema,
14691
14694
  label: indicatorTextSchema(256).optional(),
14692
14695
  tooltip: indicatorTextSchema(1024).optional()
14693
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
14696
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
14694
14697
  message: "Composer indicator IDs must be unique"
14695
14698
  });
14696
14699
  var threadUsageSnapshotSchema = external_exports.object({
@@ -14716,6 +14719,7 @@ var threadUsageSnapshotSchema = external_exports.object({
14716
14719
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
14717
14720
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
14718
14721
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
14722
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
14719
14723
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
14720
14724
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
14721
14725
  }).strict().superRefine((usage, context) => {
@@ -14813,6 +14817,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
14813
14817
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
14814
14818
  resetCredits: accountResetCreditsSchema.optional()
14815
14819
  }).strict();
14820
+ var accountBalanceSnapshotSchema = external_exports.object({
14821
+ amount: external_exports.number().finite().nonnegative(),
14822
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
14823
+ currency: external_exports.string().trim().min(1).max(8),
14824
+ /** Native label when the Harness exposes several Billing Sources. */
14825
+ label: external_exports.string().trim().min(1).max(128).optional()
14826
+ }).strict();
14816
14827
  var threadUsageInspectionParamsSchema = external_exports.object({
14817
14828
  threadId: hostThreadIdSchema,
14818
14829
  refresh: external_exports.literal("exact").optional()
@@ -14821,7 +14832,10 @@ var threadUsageInspectionSchema = external_exports.object({
14821
14832
  threadId: hostThreadIdSchema,
14822
14833
  usage: threadUsageSnapshotSchema.nullable(),
14823
14834
  accountCredits: accountCreditsSnapshotSchema.optional(),
14824
- /** Whether this source can provide cached account quota independently of usage. */
14835
+ /** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
14836
+ accountBalance: accountBalanceSnapshotSchema.optional(),
14837
+ /** Whether this source can provide cached account quota (credits or a prepaid balance)
14838
+ * independently of usage. */
14825
14839
  accountCreditsSupported: external_exports.boolean().optional()
14826
14840
  }).strict();
14827
14841
 
@@ -14833,10 +14847,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
14833
14847
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
14834
14848
  message: "Value must not be empty or whitespace"
14835
14849
  });
14836
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
14850
+ 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();
14851
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
14837
14852
  var harnessModelRefSchema = external_exports.object({
14838
- id: harnessModelRefIdSchema
14853
+ id: harnessModelRefIdSchema,
14854
+ serviceTier: harnessModelServiceTierSchema.optional()
14839
14855
  }).strict();
14856
+ function sameHarnessModelRef(left, right) {
14857
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
14858
+ }
14840
14859
  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();
14841
14860
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
14842
14861
  var harnessThinkingOptionSchema = external_exports.object({
@@ -14850,7 +14869,15 @@ var harnessModelSchema = external_exports.object({
14850
14869
  /** Optional opaque selection for this same Model with priority processing enabled. */
14851
14870
  fastModel: harnessModelRefSchema.optional(),
14852
14871
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
14853
- }).strict();
14872
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
14873
+ path: ["fastModel", "id"],
14874
+ message: "A tiered Fast Model must share the base Model ID"
14875
+ });
14876
+ function catalogModelForRef(catalog, ref) {
14877
+ if (!ref)
14878
+ return void 0;
14879
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
14880
+ }
14854
14881
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
14855
14882
  const ids = /* @__PURE__ */ new Set();
14856
14883
  for (const [index, option] of options.entries()) {
@@ -14870,26 +14897,26 @@ var harnessModelCatalogSchema = external_exports.object({
14870
14897
  thinkingOptions: harnessThinkingOptionsSchema,
14871
14898
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
14872
14899
  }).strict().superRefine((catalog, context) => {
14873
- const refs = /* @__PURE__ */ new Set();
14874
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
14900
+ const refs = [];
14901
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
14875
14902
  for (const [index, model2] of catalog.models.entries()) {
14876
- if (refs.has(model2.ref.id)) {
14903
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
14877
14904
  context.addIssue({
14878
14905
  code: "custom",
14879
14906
  message: "Model Catalog refs must be unique",
14880
14907
  path: ["models", index, "ref", "id"]
14881
14908
  });
14882
14909
  }
14883
- refs.add(model2.ref.id);
14910
+ refs.push(model2.ref);
14884
14911
  if (model2.fastModel) {
14885
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
14912
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
14886
14913
  context.addIssue({
14887
14914
  code: "custom",
14888
14915
  message: "Fast Model refs must be distinct and unique",
14889
14916
  path: ["models", index, "fastModel"]
14890
14917
  });
14891
14918
  }
14892
- refs.add(model2.fastModel.id);
14919
+ refs.push(model2.fastModel);
14893
14920
  }
14894
14921
  const supportedThinkingIds = /* @__PURE__ */ new Set();
14895
14922
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -14910,7 +14937,7 @@ var harnessModelCatalogSchema = external_exports.object({
14910
14937
  }
14911
14938
  }
14912
14939
  }
14913
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
14940
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
14914
14941
  context.addIssue({
14915
14942
  code: "custom",
14916
14943
  message: "Default Model must exist in the Model Catalog",
@@ -14950,7 +14977,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
14950
14977
  observe: external_exports.boolean()
14951
14978
  }).strict().optional(),
14952
14979
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
14953
- steer: external_exports.boolean().optional()
14980
+ steer: external_exports.boolean().optional(),
14981
+ /**
14982
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
14983
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
14984
+ */
14985
+ persistentPlan: external_exports.boolean().optional()
14954
14986
  }).strict();
14955
14987
  var harnessConfigurationStateSchema = external_exports.object({
14956
14988
  effectiveModel: harnessModelRefSchema.optional(),
@@ -14959,7 +14991,7 @@ var harnessConfigurationStateSchema = external_exports.object({
14959
14991
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
14960
14992
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
14961
14993
  }).strict().superRefine((state, context) => {
14962
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
14994
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
14963
14995
  context.addIssue({
14964
14996
  code: "custom",
14965
14997
  message: "Effective Thinking option must be currently available",
@@ -14999,7 +15031,8 @@ var harnessInspectParamsSchema = external_exports.object({
14999
15031
  cwd: nonBlankTextSchema2.max(16384).optional(),
15000
15032
  refresh: external_exports.boolean().optional(),
15001
15033
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15002
- purpose: external_exports.literal("availability").optional()
15034
+ purpose: external_exports.literal("availability").optional(),
15035
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15003
15036
  }).strict();
15004
15037
  var harnessWebUiOpenParamsSchema = external_exports.object({
15005
15038
  harnessId: harnessIdSchema
@@ -15030,7 +15063,7 @@ var codexThreadInspectionSchema = external_exports.object({
15030
15063
  var externalThreadInspectionSchema = external_exports.object({
15031
15064
  owner: external_exports.literal("external"),
15032
15065
  harnessId: nonBlankTextSchema2.max(256),
15033
- transportModelId: nonBlankTextSchema2.max(1024),
15066
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15034
15067
  effectiveModel: harnessModelRefSchema.optional(),
15035
15068
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15036
15069
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15112,13 +15145,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
15112
15145
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15113
15146
  }).strict();
15114
15147
 
15148
+ // ../../shared-contracts/dist/harness-plugins.js
15149
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15150
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15151
+ var HARNESS_PLUGIN_LIMIT = 128;
15152
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15153
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15154
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
15155
+ 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");
15156
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15157
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15158
+ var harnessInstallationGuideSchema = external_exports.object({
15159
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15160
+ before: localizedTextSchema.optional(),
15161
+ after: localizedTextSchema.optional(),
15162
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15163
+ }).strict();
15164
+ var pluginPresentationShape = {
15165
+ id: installedHarnessPluginIdSchema,
15166
+ name: external_exports.string().trim().min(1).max(128),
15167
+ version: external_exports.string().min(1).max(128),
15168
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15169
+ kind: external_exports.literal("usage").optional(),
15170
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15171
+ iconStyle: external_exports.object({
15172
+ vector: external_exports.object({
15173
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15174
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15175
+ paths: external_exports.array(external_exports.object({
15176
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15177
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15178
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15179
+ }).strict()).min(1).max(32)
15180
+ }).strict().optional(),
15181
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15182
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15183
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15184
+ }).strict().optional(),
15185
+ installation: harnessInstallationGuideSchema.optional(),
15186
+ notice: localizedTextSchema.optional(),
15187
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15188
+ launchCommand: external_exports.literal(true).optional(),
15189
+ links: external_exports.object({
15190
+ website: documentationUrlSchema.optional(),
15191
+ documentation: documentationUrlSchema.optional(),
15192
+ installation: documentationUrlSchema.optional()
15193
+ }).strict().optional()
15194
+ };
15195
+ var harnessPluginManifestSchema = external_exports.object({
15196
+ manifestVersion: external_exports.literal(1),
15197
+ ...pluginPresentationShape,
15198
+ adapterApiVersion: external_exports.number().int().positive(),
15199
+ entry: pluginRelativeResourceSchema,
15200
+ icon: pluginRelativeResourceSchema.optional()
15201
+ }).strict();
15202
+ 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);
15203
+ var harnessPluginDescriptorSchema = external_exports.object({
15204
+ ...pluginPresentationShape,
15205
+ icon: harnessPluginIconSchema.optional()
15206
+ }).strict();
15207
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15208
+ var harnessPluginListResultSchema = external_exports.object({
15209
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15210
+ }).strict();
15211
+ var harnessPluginConfigurationSchema = external_exports.object({
15212
+ version: external_exports.literal(1),
15213
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15214
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15215
+ message: "Enabled plugin IDs must be unique",
15216
+ path: ["enabled"]
15217
+ });
15218
+
15219
+ // ../../shared-contracts/dist/desktop-extensions.js
15220
+ var DESKTOP_EXTENSION_API_VERSION = 1;
15221
+ var DESKTOP_EXTENSION_LIMIT = 64;
15222
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15223
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15224
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15225
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15226
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15227
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15228
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15229
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15230
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15231
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15232
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15233
+ var desktopExtensionIdSchema = installedPluginIdSchema;
15234
+ var desktopExtensionSlotSchema = external_exports.enum([
15235
+ "sidebar.thread-layout",
15236
+ "sidebar.thread-badge",
15237
+ "appearance.theme"
15238
+ ]);
15239
+ var desktopExtensionCategorySchema = external_exports.enum([
15240
+ "appearance",
15241
+ "interface",
15242
+ "workflow",
15243
+ "analytics",
15244
+ "integrations",
15245
+ "tools"
15246
+ ]);
15247
+ var extensionName = external_exports.string().trim().min(1).max(128);
15248
+ function desktopExtensionScreenshotMimeType(resource) {
15249
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15250
+ case "png":
15251
+ return "image/png";
15252
+ case "jpg":
15253
+ case "jpeg":
15254
+ return "image/jpeg";
15255
+ case "webp":
15256
+ return "image/webp";
15257
+ default:
15258
+ return void 0;
15259
+ }
15260
+ }
15261
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15262
+ 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");
15263
+ 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) => {
15264
+ const { username, password } = new URL(value);
15265
+ return !username && !password && !/[\\\s]/u.test(value);
15266
+ }, "URL must not contain credentials, backslashes, or whitespace");
15267
+ function localizedText(text2) {
15268
+ return external_exports.strictObject({ en: text2, "zh-CN": text2 });
15269
+ }
15270
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15271
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15272
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15273
+ var settingField = {
15274
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15275
+ label: desktopExtensionLocalizedTextSchema,
15276
+ description: desktopExtensionLocalizedTextSchema.optional()
15277
+ };
15278
+ var numericSetting = {
15279
+ ...settingField,
15280
+ step: external_exports.number().positive().optional(),
15281
+ default: external_exports.number().optional()
15282
+ };
15283
+ var settingOption = external_exports.strictObject({
15284
+ value: external_exports.string(),
15285
+ label: desktopExtensionLocalizedTextSchema
15286
+ });
15287
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15288
+ external_exports.strictObject({
15289
+ ...settingField,
15290
+ type: external_exports.literal("boolean"),
15291
+ default: external_exports.boolean().optional()
15292
+ }),
15293
+ external_exports.strictObject({
15294
+ ...settingField,
15295
+ type: external_exports.literal("string"),
15296
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
15297
+ default: external_exports.string().optional()
15298
+ }),
15299
+ external_exports.strictObject({
15300
+ ...numericSetting,
15301
+ type: external_exports.literal("number"),
15302
+ min: external_exports.number().optional(),
15303
+ max: external_exports.number().optional()
15304
+ }),
15305
+ external_exports.strictObject({
15306
+ ...numericSetting,
15307
+ type: external_exports.literal("range"),
15308
+ min: external_exports.number(),
15309
+ max: external_exports.number()
15310
+ }),
15311
+ external_exports.strictObject({
15312
+ ...settingField,
15313
+ type: external_exports.literal("select"),
15314
+ options: external_exports.array(settingOption).min(1),
15315
+ default: external_exports.string().optional()
15316
+ })
15317
+ ]).superRefine((field2, ctx) => {
15318
+ const issue2 = (path12, message) => ctx.addIssue({ code: "custom", path: [path12], message });
15319
+ if (field2.type === "number" || field2.type === "range") {
15320
+ const { min = -Infinity, max = Infinity, default: value } = field2;
15321
+ if (min > max)
15322
+ issue2("max", "Must be at least min");
15323
+ if (value !== void 0 && (value < min || value > max))
15324
+ issue2("default", "Must be within min and max");
15325
+ } else if (field2.type === "select") {
15326
+ const values = new Set(field2.options.map(({ value }) => value));
15327
+ if (values.size !== field2.options.length)
15328
+ issue2("options", "Duplicate option values");
15329
+ if (field2.default !== void 0 && !values.has(field2.default))
15330
+ issue2("default", "Must match an option value");
15331
+ }
15332
+ });
15333
+ var manifestHeader = external_exports.object({
15334
+ manifestVersion: external_exports.int().positive(),
15335
+ id: desktopExtensionIdSchema,
15336
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
15337
+ version: external_exports.string().min(1).max(128),
15338
+ desktopApi: external_exports.int().positive()
15339
+ }).passthrough();
15340
+ var desktopExtensionManifestSchema = manifestHeader.extend({
15341
+ manifestVersion: external_exports.literal(1),
15342
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15343
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15344
+ author: external_exports.string().trim().min(1).max(128).optional(),
15345
+ repository: desktopExtensionHttpUrlSchema.optional(),
15346
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15347
+ icon: imagePathSchema.optional(),
15348
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15349
+ desktop: external_exports.strictObject({
15350
+ script: pluginRelativeResourceSchema,
15351
+ style: pluginRelativeResourceSchema.optional()
15352
+ }).optional(),
15353
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15354
+ slots: slotsSchema.default(() => []),
15355
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15356
+ categories: categoriesSchema.optional()
15357
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15358
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15359
+ var desktopExtensionStatusSchema = external_exports.strictObject({
15360
+ state: external_exports.enum([
15361
+ "running",
15362
+ "disabled",
15363
+ "invalid",
15364
+ "incompatible",
15365
+ "conflict",
15366
+ "failed",
15367
+ "waiting"
15368
+ ]),
15369
+ hash: desktopExtensionHashSchema.optional(),
15370
+ error: external_exports.string().optional(),
15371
+ conflictWith: desktopExtensionIdSchema.optional()
15372
+ });
15373
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15374
+ controllerPid: external_exports.int().positive(),
15375
+ targetId: external_exports.string().nullable(),
15376
+ updatedAt: external_exports.iso.datetime(),
15377
+ handledReloadToken: external_exports.uuid().optional(),
15378
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
15379
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
15380
+ });
15381
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15382
+ function isGitHubDesktopExtensionZipballUrl(url2) {
15383
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15384
+ }
15385
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15386
+ const url2 = new URL(input);
15387
+ 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);
15388
+ }, "Expected a .zip download URL or a GitHub zipball URL");
15389
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15390
+ id: desktopExtensionIdSchema,
15391
+ version: external_exports.string().trim().min(1).max(128),
15392
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15393
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
15394
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15395
+ author: external_exports.string().trim().min(1).max(128),
15396
+ repository: desktopExtensionHttpUrlSchema,
15397
+ stars: external_exports.number().int().min(0).optional(),
15398
+ downloads: external_exports.number().int().min(0).optional(),
15399
+ categories: categoriesSchema.optional(),
15400
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
15401
+ icon: desktopExtensionHttpUrlSchema.optional(),
15402
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15403
+ downloadUrl: desktopExtensionZipUrlSchema,
15404
+ sha256: desktopExtensionHashSchema,
15405
+ slots: slotsSchema.optional(),
15406
+ publishedAt: external_exports.string().optional(),
15407
+ updatedAt: external_exports.string().optional(),
15408
+ minCodexHostVersion: external_exports.string().optional()
15409
+ });
15410
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
15411
+ schemaVersion: external_exports.literal(1),
15412
+ generatedAt: external_exports.string(),
15413
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15414
+ });
15415
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15416
+
15417
+ // ../../shared-contracts/dist/host-extensions.js
15418
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
15419
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
15420
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
15421
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
15422
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
15423
+ var hostExtensionActivationIdSchema = external_exports.uuid();
15424
+ var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path12) => path12.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
15425
+ var legacy = desktopExtensionManifestSchema.shape;
15426
+ var localized = (max, min = 0) => external_exports.strictObject({
15427
+ en: external_exports.string().trim().min(min).max(max),
15428
+ "zh-CN": external_exports.string().trim().min(min).max(max)
15429
+ });
15430
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path12) => path12.endsWith(suffix), `Expected a ${suffix} file`);
15431
+ var moduleEntry = resourceWithSuffix(".mjs");
15432
+ var style = resourceWithSuffix(".css").optional();
15433
+ var hostExtensionCanonicalPath = (path12) => path12.normalize("NFC").toLowerCase();
15434
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
15435
+ manifestVersion: external_exports.literal(2),
15436
+ id: hostExtensionIdSchema,
15437
+ name: localized(128, 1),
15438
+ version: external_exports.string().trim().min(1).max(128),
15439
+ description: localized(4096),
15440
+ details: localized(16384).optional(),
15441
+ author: legacy.author,
15442
+ repository: legacy.repository,
15443
+ icon: legacy.icon.refine((path12) => path12 === void 0 || hostExtensionResourcePathSchema.safeParse(path12).success),
15444
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path12) => hostExtensionResourcePathSchema.safeParse(path12).success)),
15445
+ categories: legacy.categories,
15446
+ settingsSchema: legacy.settingsSchema,
15447
+ slots: legacy.slots.removeDefault().optional(),
15448
+ page: external_exports.strictObject({
15449
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15450
+ entry: moduleEntry,
15451
+ style,
15452
+ title: localized(128, 1).optional()
15453
+ }).optional(),
15454
+ widget: external_exports.strictObject({
15455
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15456
+ entry: moduleEntry,
15457
+ style
15458
+ }).optional(),
15459
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
15460
+ 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(),
15461
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
15462
+ }).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" });
15463
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
15464
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
15465
+ return ["desktop", "web"];
15466
+ const targets = [];
15467
+ if (hasDesktop)
15468
+ targets.push("desktop");
15469
+ if (hasWeb)
15470
+ targets.push("web");
15471
+ return targets;
15472
+ }
15473
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
15474
+
15475
+ // ../../shared-contracts/dist/host-extension-management.js
15476
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
15477
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
15478
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
15479
+ revision: hostExtensionRevisionSchema,
15480
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
15481
+ });
15482
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
15483
+ var hostExtensionCatalogEntrySchema = external_exports.object({
15484
+ ...catalogMetadata,
15485
+ id: hostExtensionIdSchema,
15486
+ format: external_exports.literal("codexhost"),
15487
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
15488
+ apis: external_exports.strictObject({
15489
+ page: external_exports.int().positive().optional(),
15490
+ widget: external_exports.int().positive().optional(),
15491
+ desktop: external_exports.int().positive().optional(),
15492
+ web: external_exports.int().positive().optional(),
15493
+ backend: external_exports.int().positive().optional()
15494
+ }),
15495
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
15496
+ }).refine(({ targets, apis }) => {
15497
+ const derived = targetsForCapabilities({
15498
+ hasPage: Boolean(apis.page),
15499
+ hasWidget: Boolean(apis.widget),
15500
+ hasDesktop: Boolean(apis.desktop),
15501
+ hasWeb: Boolean(apis.web),
15502
+ hasBackend: Boolean(apis.backend)
15503
+ });
15504
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
15505
+ }, "Catalog targets must match the declared APIs");
15506
+ var hostExtensionCatalogSchema = external_exports.object({
15507
+ schemaVersion: external_exports.literal(2),
15508
+ generatedAt: external_exports.string().min(1),
15509
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15510
+ });
15511
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
15512
+ catalogUrl: desktopExtensionHttpUrlSchema,
15513
+ fetchedAt: external_exports.iso.datetime(),
15514
+ cached: external_exports.boolean()
15515
+ });
15516
+ var id = { id: hostExtensionIdSchema };
15517
+ var active = {
15518
+ ...id,
15519
+ activationId: hostExtensionActivationIdSchema,
15520
+ digest: hostExtensionDigestSchema
15521
+ };
15522
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
15523
+ var filePath = external_exports.string().min(1).max(4096).refine((path12) => /^(?:\/|[a-z]:[/\\])/iu.test(path12) && !path12.includes("\0") && !path12.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
15524
+ 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");
15525
+ function base643(maxBytes) {
15526
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
15527
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
15528
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
15529
+ }, "Expected bounded standard padded base64");
15530
+ }
15531
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
15532
+ type: external_exports.literal("github"),
15533
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
15534
+ ref: gitRef.optional(),
15535
+ tag: gitRef.optional(),
15536
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
15537
+ subpath: hostExtensionResourcePathSchema.optional()
15538
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
15539
+ var hostExtensionInstallSourceSchema = external_exports.union([
15540
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15541
+ hostExtensionGitHubSourceSchema,
15542
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
15543
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
15544
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
15545
+ ]);
15546
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
15547
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
15548
+ hostExtensionGitHubSourceSchema,
15549
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
15550
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
15551
+ ]);
15552
+ var hostExtensionInstallationSchema = external_exports.strictObject({
15553
+ ...active,
15554
+ manifest: hostExtensionManifestV2Schema,
15555
+ installedAt: external_exports.iso.datetime(),
15556
+ source: hostExtensionProvenanceSchema.optional()
15557
+ });
15558
+ 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);
15559
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
15560
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
15561
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
15562
+ hostExtensionInstallationSchema.extend({
15563
+ state: external_exports.literal("valid"),
15564
+ enabled: external_exports.boolean(),
15565
+ ...desktopConflict,
15566
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
15567
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15568
+ backendState: backendState.optional(),
15569
+ backendError: external_exports.string().optional()
15570
+ }),
15571
+ external_exports.strictObject({
15572
+ state: external_exports.enum(["invalid", "incompatible"]),
15573
+ id: external_exports.string().min(1),
15574
+ enabled: external_exports.boolean(),
15575
+ error: external_exports.string()
15576
+ })
15577
+ ]);
15578
+ var hostExtensionsListResultSchema = external_exports.strictObject({
15579
+ revision: hostExtensionRevisionSchema,
15580
+ configuration: hostExtensionConfigurationSchema,
15581
+ diagnostics: external_exports.array(external_exports.string()),
15582
+ extensions: external_exports.array(hostExtensionListItemSchema)
15583
+ });
15584
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
15585
+ ...desktopConflict,
15586
+ settingsRevision: hostExtensionRevisionSchema
15587
+ });
15588
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
15589
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
15590
+ revision: hostExtensionRevisionSchema,
15591
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
15592
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
15593
+ });
15594
+ var HOST_EXTENSIONS_RPC = {
15595
+ list: "codexhost/extensions/list",
15596
+ snapshot: "codexhost/extensions/snapshot",
15597
+ catalog: "codexhost/extensions/catalog",
15598
+ install: "codexhost/extensions/install",
15599
+ update: "codexhost/extensions/update",
15600
+ enable: "codexhost/extensions/enable",
15601
+ disable: "codexhost/extensions/disable",
15602
+ uninstall: "codexhost/extensions/uninstall",
15603
+ recover: "codexhost/extensions/recover",
15604
+ asset: "codexhost/extensions/asset",
15605
+ settingsGet: "codexhost/extensions/settings/get",
15606
+ settingsSet: "codexhost/extensions/settings/set",
15607
+ backendInvoke: "codexhost/extensions/backend/invoke"
15608
+ };
15609
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
15610
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
15611
+ var noParams = external_exports.strictObject({});
15612
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
15613
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
15614
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
15615
+ var mutationResult = external_exports.discriminatedUnion("state", [
15616
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
15617
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
15618
+ ]);
15619
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
15620
+ ...optionalActivation,
15621
+ digest: active.digest.optional(),
15622
+ path: hostExtensionResourcePathSchema
15623
+ });
15624
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
15625
+ mimeType: external_exports.string().min(1),
15626
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
15627
+ digest: active.digest
15628
+ });
15629
+ var hostExtensionSettingsSchema = external_exports.strictObject({
15630
+ settingsRevision: hostExtensionRevisionSchema,
15631
+ values: jsonObjectSchema
15632
+ });
15633
+ var hostExtensionsRpcSchemas = {
15634
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
15635
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
15636
+ [HOST_EXTENSIONS_RPC.catalog]: {
15637
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
15638
+ result: hostExtensionsCatalogResultSchema
15639
+ },
15640
+ [HOST_EXTENSIONS_RPC.install]: {
15641
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
15642
+ result: installationResult
15643
+ },
15644
+ [HOST_EXTENSIONS_RPC.update]: {
15645
+ params: external_exports.strictObject({
15646
+ ...id,
15647
+ expectedDigest: active.digest,
15648
+ expectedActivationId: active.activationId.optional(),
15649
+ source: hostExtensionInstallSourceSchema.optional()
15650
+ }),
15651
+ result: installationResult
15652
+ },
15653
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
15654
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
15655
+ [HOST_EXTENSIONS_RPC.uninstall]: {
15656
+ params: external_exports.strictObject({
15657
+ ...id,
15658
+ removeData: external_exports.boolean().optional(),
15659
+ expectedDigest: active.digest.optional()
15660
+ }),
15661
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
15662
+ },
15663
+ [HOST_EXTENSIONS_RPC.recover]: {
15664
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
15665
+ result: mutationResult
15666
+ },
15667
+ [HOST_EXTENSIONS_RPC.asset]: {
15668
+ params: hostExtensionsAssetParamsSchema,
15669
+ result: hostExtensionsAssetResultSchema
15670
+ },
15671
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
15672
+ params: external_exports.strictObject(optionalActivation),
15673
+ result: hostExtensionSettingsSchema
15674
+ },
15675
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
15676
+ params: external_exports.strictObject({
15677
+ ...optionalActivation,
15678
+ expectedSettingsRevision: hostExtensionRevisionSchema,
15679
+ values: jsonObjectSchema
15680
+ }),
15681
+ result: hostExtensionSettingsSchema
15682
+ },
15683
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
15684
+ params: external_exports.strictObject({
15685
+ ...optionalActivation,
15686
+ method: hostExtensionBackendMethodSchema,
15687
+ params: jsonValueSchema.optional()
15688
+ }),
15689
+ result: external_exports.strictObject({ result: jsonValueSchema })
15690
+ }
15691
+ };
15692
+
15115
15693
  // ../../shared-contracts/dist/thread-archive-confirm.js
15694
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
15116
15695
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15117
15696
  var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15118
15697
 
15119
15698
  // ../../shared-contracts/dist/client-channel.js
15120
15699
  var CLIENT_CHANNEL_VERSION = 1;
15121
15700
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
15701
+ var CLIENT_CHANNEL_METHODS = [
15702
+ "codexhost/skills/list",
15703
+ "codexhost/voice/status",
15704
+ "codexhost/voice/transcribe",
15705
+ "codexhost/harness/display-settings/get",
15706
+ "codexhost/harness/display-settings/set",
15707
+ "codexhost/harness/display-settings/capabilities",
15708
+ "codexhost/harness/preferences/get",
15709
+ "codexhost/harness/preferences/patch",
15710
+ "thread/list",
15711
+ "codexhost/thread/catalog/read",
15712
+ "thread/read",
15713
+ "thread/resume",
15714
+ "thread/fork",
15715
+ "thread/turns/list",
15716
+ "thread/revert",
15717
+ "thread/items/list",
15718
+ "thread/start",
15719
+ "thread/name/set",
15720
+ "codexhost/thread/title/generate",
15721
+ "thread/archive",
15722
+ THREAD_ARCHIVE_CONFIRM_METHOD,
15723
+ "thread/unarchive",
15724
+ "turn/start",
15725
+ "turn/interrupt",
15726
+ "turn/steer",
15727
+ "thread/queue/list",
15728
+ "thread/queue/add",
15729
+ "thread/queue/update",
15730
+ "thread/queue/delete",
15731
+ "thread/queue/reorder",
15732
+ "thread/queue/start",
15733
+ "codexhost/thread/queue/send-now",
15734
+ "codexhost/workspace/read",
15735
+ "codexhost/thread/tree/read",
15736
+ "codexhost/thread/pins/list",
15737
+ "codexhost/thread/pins/set",
15738
+ "codexhost/harness/plugins/list",
15739
+ "codexhost/harness/inspect",
15740
+ "codexhost/thread/inspect",
15741
+ "codexhost/thread/usage/inspect",
15742
+ "codexhost/thread/ownership/list",
15743
+ "codexhost/thread/model/select",
15744
+ "codexhost/thread/thinking/select",
15745
+ "codexhost/thread/permission-mode/select",
15746
+ "codexhost/thread/commands/inspect",
15747
+ "codexhost/harness/commands/inspect",
15748
+ "codexhost/thread/command/execute",
15749
+ "codexhost/thread/fork",
15750
+ "codexhost/harness/session-import/sources",
15751
+ "codexhost/harness/session-import/list",
15752
+ "codexhost/harness/session-import/import",
15753
+ // Host settings shared across Desktop and Web.
15754
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
15755
+ "codexhost/harness/installation",
15756
+ "codexhost/harness/installation/start",
15757
+ "codexhost/harness/installation/status",
15758
+ "codexhost/harness/launch-settings/get",
15759
+ "codexhost/harness/launch-settings/set",
15760
+ "codexhost/harness/web-ui/open",
15761
+ "codexhost/harness/accounts/sources",
15762
+ "codexhost/harness/accounts/list",
15763
+ "codexhost/harness/accounts/inspect",
15764
+ "codexhost/harness/credential-imports",
15765
+ "codexhost/account/list",
15766
+ "codexhost/account/refresh",
15767
+ "codexhost/account/usage/inspect",
15768
+ "codexhost/usage/model-prices/get",
15769
+ "codexhost/usage/model-prices/set",
15770
+ "codexhost/usage/model-prices/default",
15771
+ "codexhost/usage/statistics/get",
15772
+ "codexhost/update/check",
15773
+ "codexhost/update/start",
15774
+ "codexhost/update/status",
15775
+ "codexhost/sessions/loaded/list"
15776
+ ];
15122
15777
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15123
15778
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15124
15779
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -15157,6 +15812,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15157
15812
  cursor: clientChannelCursorSchema,
15158
15813
  revision: external_exports.number().int().nonnegative()
15159
15814
  }),
15815
+ external_exports.object({
15816
+ type: external_exports.literal("extensions-changed"),
15817
+ cursor: clientChannelCursorSchema,
15818
+ revision: hostExtensionRevisionSchema
15819
+ }),
15160
15820
  external_exports.object({
15161
15821
  type: external_exports.literal("hello"),
15162
15822
  version: external_exports.literal(1),
@@ -15332,6 +15992,29 @@ var threadCatalogReadResultSchema = external_exports.object({
15332
15992
  officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
15333
15993
  }).strict();
15334
15994
 
15995
+ // ../../shared-contracts/dist/thread-tree-watch.js
15996
+ var THREAD_TREE_MAX_NODES = 5e3;
15997
+ var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
15998
+ var threadTreeNodeSchema = external_exports.strictObject({
15999
+ harnessId: harnessIdSchema,
16000
+ title: external_exports.string().optional(),
16001
+ status: threadTreeStatusSchema,
16002
+ archived: external_exports.boolean()
16003
+ });
16004
+ var threadTreeSnapshotSchema = external_exports.strictObject({
16005
+ revision: external_exports.int().nonnegative(),
16006
+ parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
16007
+ nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
16008
+ truncated: external_exports.boolean()
16009
+ }).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");
16010
+ var subscriptionId = external_exports.string().min(1).max(128);
16011
+ var threadTreeWatchParamsSchema = external_exports.strictObject({});
16012
+ var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
16013
+ var threadTreeUnwatchResultSchema = external_exports.strictObject({});
16014
+ var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
16015
+ snapshot: threadTreeSnapshotSchema
16016
+ });
16017
+
15335
16018
  // ../../shared-contracts/dist/voice.js
15336
16019
  var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
15337
16020
  var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
@@ -15570,7 +16253,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
15570
16253
 
15571
16254
  // ../../shared-contracts/dist/harness-preferences.js
15572
16255
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
15573
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16256
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
15574
16257
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
15575
16258
  model: harnessModelRefSchema.optional(),
15576
16259
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15580,11 +16263,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
15580
16263
  lastHarness: harnessIdSchema.optional(),
15581
16264
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
15582
16265
  });
16266
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
16267
+ model: harnessModelRefSchema.optional(),
16268
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
16269
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
16270
+ var delegationDefaultsSchema = external_exports.strictObject({
16271
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
16272
+ });
15583
16273
  var modelId = external_exports.string().min(1).max(1024);
15584
16274
  var harnessPreferenceValuesSchema = external_exports.strictObject({
15585
16275
  idleRelease: idleReleaseSettingsSchema.optional(),
15586
16276
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
15587
- newThread: newThreadDefaultsSchema.optional()
16277
+ newThread: newThreadDefaultsSchema.optional(),
16278
+ delegation: delegationDefaultsSchema.optional()
15588
16279
  });
15589
16280
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
15590
16281
  scope: harnessPreferenceScopeSchema,
@@ -15612,6 +16303,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
15612
16303
  lastHarness: harnessIdSchema.optional(),
15613
16304
  harnessId: harnessIdSchema.optional(),
15614
16305
  configuration: harnessDefaultConfigurationSchema.optional()
16306
+ }),
16307
+ external_exports.strictObject({
16308
+ kind: external_exports.literal("delegation"),
16309
+ harnessId: harnessIdSchema,
16310
+ configuration: harnessDelegationDefaultSchema.nullable()
15615
16311
  })
15616
16312
  ]);
15617
16313
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -15962,13 +16658,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
15962
16658
  });
15963
16659
 
15964
16660
  // ../../shared-contracts/dist/harness-accounts.js
15965
- var accountBalanceSnapshotSchema = external_exports.object({
15966
- amount: external_exports.number().finite().nonnegative(),
15967
- /** ISO 4217 code as reported by the Provider, for example `CNY`. */
15968
- currency: external_exports.string().trim().min(1).max(8),
15969
- /** Native label when the Harness exposes several Billing Sources. */
15970
- label: external_exports.string().trim().min(1).max(128).optional()
15971
- }).strict();
15972
16661
  var harnessAccountSnapshotObject = external_exports.object({
15973
16662
  email: external_exports.string().trim().min(1).max(320).optional(),
15974
16663
  label: external_exports.string().trim().min(1).max(256).optional(),
@@ -16002,76 +16691,6 @@ var harnessAccountListResultSchema = external_exports.object({
16002
16691
  accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
16003
16692
  }).strict();
16004
16693
 
16005
- // ../../shared-contracts/dist/harness-plugins.js
16006
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
16007
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
16008
- var HARNESS_PLUGIN_LIMIT = 128;
16009
- var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
16010
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
16011
- 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");
16012
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
16013
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
16014
- var harnessInstallationGuideSchema = external_exports.object({
16015
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
16016
- before: localizedTextSchema.optional(),
16017
- after: localizedTextSchema.optional(),
16018
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
16019
- }).strict();
16020
- var pluginPresentationShape = {
16021
- id: installedHarnessPluginIdSchema,
16022
- name: external_exports.string().trim().min(1).max(128),
16023
- version: external_exports.string().min(1).max(128),
16024
- /** Capability-only plugin; omitted for existing session-capable plugins. */
16025
- kind: external_exports.literal("usage").optional(),
16026
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
16027
- iconStyle: external_exports.object({
16028
- vector: external_exports.object({
16029
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
16030
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
16031
- paths: external_exports.array(external_exports.object({
16032
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
16033
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
16034
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
16035
- }).strict()).min(1).max(32)
16036
- }).strict().optional(),
16037
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
16038
- borderRadius: external_exports.number().min(0).max(50).optional(),
16039
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
16040
- }).strict().optional(),
16041
- installation: harnessInstallationGuideSchema.optional(),
16042
- notice: localizedTextSchema.optional(),
16043
- /** The factory accepts a persisted local entrypoint through its construction context. */
16044
- launchCommand: external_exports.literal(true).optional(),
16045
- links: external_exports.object({
16046
- website: documentationUrlSchema.optional(),
16047
- documentation: documentationUrlSchema.optional(),
16048
- installation: documentationUrlSchema.optional()
16049
- }).strict().optional()
16050
- };
16051
- var harnessPluginManifestSchema = external_exports.object({
16052
- manifestVersion: external_exports.literal(1),
16053
- ...pluginPresentationShape,
16054
- adapterApiVersion: external_exports.number().int().positive(),
16055
- entry: relativeResourceSchema,
16056
- icon: relativeResourceSchema.optional()
16057
- }).strict();
16058
- 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);
16059
- var harnessPluginDescriptorSchema = external_exports.object({
16060
- ...pluginPresentationShape,
16061
- icon: harnessPluginIconSchema.optional()
16062
- }).strict();
16063
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
16064
- var harnessPluginListResultSchema = external_exports.object({
16065
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
16066
- }).strict();
16067
- var harnessPluginConfigurationSchema = external_exports.object({
16068
- version: external_exports.literal(1),
16069
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
16070
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
16071
- message: "Enabled plugin IDs must be unique",
16072
- path: ["enabled"]
16073
- });
16074
-
16075
16694
  // ../../shared-contracts/dist/harness-route.js
16076
16695
  var harnessPluginRouteSchema = external_exports.object({
16077
16696
  harnessId: harnessPluginIdSchema,
@@ -16512,9 +17131,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16512
17131
  ...thread,
16513
17132
  epoch: identity,
16514
17133
  modelId: identity.optional(),
17134
+ serviceTier: harnessModelServiceTierSchema.optional(),
16515
17135
  thinkingOptionId: identity.optional(),
16516
17136
  permissionModeId: identity.optional()
16517
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17137
+ }).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, {
17138
+ message: "A service tier requires a Model ID"
17139
+ }),
16518
17140
  external_exports.strictObject({
16519
17141
  kind: external_exports.literal("prompt"),
16520
17142
  ...thread,
@@ -16564,7 +17186,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
16564
17186
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
16565
17187
  external_exports.strictObject({
16566
17188
  action: external_exports.literal("read-thread"),
16567
- hostId: hostId.refine((id) => id !== "local"),
17189
+ hostId: hostId.refine((id2) => id2 !== "local"),
16568
17190
  input: delegationReadParamsSchema
16569
17191
  }),
16570
17192
  external_exports.strictObject({
@@ -16578,7 +17200,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
16578
17200
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
16579
17201
  external_exports.strictObject({
16580
17202
  action: external_exports.literal("update"),
16581
- hostId: hostId.refine((id) => id !== "local"),
17203
+ hostId: hostId.refine((id2) => id2 !== "local"),
16582
17204
  version: remoteUpdateParamsSchema.shape.version
16583
17205
  })
16584
17206
  ]);
@@ -16642,7 +17264,7 @@ function invalidRequest(message) {
16642
17264
  return { code: "invalidRequest", message, retryable: false };
16643
17265
  }
16644
17266
  function validateHostApprovalResponse(interaction, response) {
16645
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17267
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
16646
17268
  }
16647
17269
 
16648
17270
  // ../../harness-adapter/dist/question.js
@@ -16650,7 +17272,7 @@ function invalidRequest2(message) {
16650
17272
  return { code: "invalidRequest", message, retryable: false };
16651
17273
  }
16652
17274
  function validateHostQuestionResponse(interaction, response) {
16653
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17275
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
16654
17276
  if (response.cancelled) {
16655
17277
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
16656
17278
  }
@@ -16698,6 +17320,18 @@ function validateHostInteractionResponse(interaction, response) {
16698
17320
  return response.type === "approval" ? validateHostApprovalResponse(interaction, response) : invalidRequest3("Interaction Response type does not match the pending Interaction");
16699
17321
  }
16700
17322
 
17323
+ // ../../harness-adapter/dist/legacy-model-ref.js
17324
+ import { Buffer as Buffer2 } from "node:buffer";
17325
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
17326
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
17327
+ return void 0;
17328
+ const encoded = ref.id.slice(prefix.length);
17329
+ const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
17330
+ if (Buffer2.from(id2).toString("base64url") !== encoded)
17331
+ return void 0;
17332
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
17333
+ }
17334
+
16701
17335
  // ../../harness-adapter/dist/output-channel.js
16702
17336
  var HarnessOutputChannel = class {
16703
17337
  outputs;
@@ -16782,7 +17416,8 @@ var tokenFields = [
16782
17416
  var safeIntegerFields = [
16783
17417
  "planFiveHourResetsAtUnix",
16784
17418
  "planSevenDayResetsAtUnix",
16785
- "timeToFirstOutputMs"
17419
+ "timeToFirstOutputMs",
17420
+ "latestRequestTimeToFirstOutputMs"
16786
17421
  ];
16787
17422
  var percentFields = [
16788
17423
  "cacheHitRatePercent",
@@ -17100,6 +17735,7 @@ function configureSubagentSnapshot(snapshot, parent) {
17100
17735
  // ../../harness-broker/dist/protocol.js
17101
17736
  var HARNESS_BROKER_PROTOCOL_VERSION = 1;
17102
17737
  var HARNESS_BROKER_MAX_FRAME_BYTES = 8 * 1024 * 1024;
17738
+ var HARNESS_BROKER_MAX_RESPONSE_BYTES = 32 * 1024 * 1024;
17103
17739
  var HARNESS_BROKER_MAX_PENDING_REQUESTS = 32;
17104
17740
  var HARNESS_BROKER_REQUEST_TIMEOUT_MS = 15e3;
17105
17741
  var HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE = 100;
@@ -17107,6 +17743,7 @@ var HARNESS_BROKER_IDLE_TIMEOUT_MS = 60 * 60 * 1e3;
17107
17743
  var HARNESS_BROKER_RETIRING_ERROR_CODE = "brokerRetiring";
17108
17744
  var harnessBrokerMethodSchema = external_exports.enum([
17109
17745
  "adapter.inspect",
17746
+ "adapter.normalizeStoredModelRef",
17110
17747
  "adapter.inspectAccount",
17111
17748
  "adapter.credits",
17112
17749
  "adapter.open",
@@ -17127,7 +17764,9 @@ var harnessBrokerHelloSchema = external_exports.object({
17127
17764
  generation: external_exports.string().uuid(),
17128
17765
  sequence: external_exports.literal(1),
17129
17766
  kind: external_exports.literal("hello"),
17130
- token: external_exports.string().regex(/^[a-f0-9]{64}$/u)
17767
+ token: external_exports.string().regex(/^[a-f0-9]{64}$/u),
17768
+ // A declared limit must leave room for the hello and frame-size error responses.
17769
+ maxResponseBytes: external_exports.number().int().min(512).max(Number.MAX_SAFE_INTEGER).optional()
17131
17770
  }).strict();
17132
17771
  var harnessBrokerRequestSchema = external_exports.object({
17133
17772
  version: external_exports.literal(HARNESS_BROKER_PROTOCOL_VERSION),
@@ -17176,40 +17815,63 @@ var harnessBrokerDescriptorSchema = external_exports.object({
17176
17815
  }).strict();
17177
17816
 
17178
17817
  // ../../harness-broker/dist/framing.js
17179
- function writeBrokerFrame(socket, value) {
17818
+ function writeBrokerFrame(socket, value, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
17180
17819
  const frame = `${JSON.stringify(value)}
17181
17820
  `;
17182
- if (Buffer.byteLength(frame) > HARNESS_BROKER_MAX_FRAME_BYTES) {
17183
- return Promise.reject(new Error("Harness broker frame exceeds the maximum size"));
17821
+ if (Buffer.byteLength(frame) > maxBytes) {
17822
+ throw new Error("Harness broker frame exceeds the maximum size");
17184
17823
  }
17185
17824
  return new Promise((resolve, reject) => {
17186
17825
  socket.write(frame, (error51) => error51 ? reject(error51) : resolve());
17187
17826
  });
17188
17827
  }
17189
- function consumeBrokerFrames(socket, onFrame, onError) {
17828
+ function consumeBrokerFrames(socket, onFrame, onError, maxBytes = HARNESS_BROKER_MAX_FRAME_BYTES) {
17190
17829
  let buffered = Buffer.alloc(0);
17830
+ let bufferedBytes = 0;
17831
+ let stopped = false;
17832
+ const fail = (error51) => {
17833
+ stopped = true;
17834
+ buffered = Buffer.alloc(0);
17835
+ bufferedBytes = 0;
17836
+ onError(error51);
17837
+ socket.destroy();
17838
+ };
17191
17839
  socket.on("data", (chunk) => {
17192
- buffered = Buffer.concat([buffered, chunk]);
17193
- if (buffered.length > HARNESS_BROKER_MAX_FRAME_BYTES) {
17194
- onError(new Error("Harness broker frame exceeds the maximum size"));
17195
- socket.destroy();
17840
+ if (stopped)
17196
17841
  return;
17197
- }
17198
- let newline2 = buffered.indexOf(10);
17199
- while (newline2 >= 0) {
17200
- const frame = buffered.subarray(0, newline2);
17201
- buffered = buffered.subarray(newline2 + 1);
17202
- if (frame.length > 0) {
17842
+ let start = 0;
17843
+ while (start < chunk.length) {
17844
+ const newline2 = chunk.indexOf(10, start);
17845
+ const part = chunk.subarray(start, newline2 < 0 ? chunk.length : newline2);
17846
+ const required2 = bufferedBytes + part.length;
17847
+ if (required2 + (newline2 < 0 ? 0 : 1) > maxBytes) {
17848
+ fail(new Error("Harness broker frame exceeds the maximum size"));
17849
+ return;
17850
+ }
17851
+ if (required2 > buffered.length) {
17852
+ const capacity = Math.min(maxBytes, Math.max(required2, 4096, buffered.length * 2));
17853
+ const next = Buffer.allocUnsafe(capacity);
17854
+ buffered.copy(next, 0, 0, bufferedBytes);
17855
+ buffered = next;
17856
+ }
17857
+ part.copy(buffered, bufferedBytes);
17858
+ bufferedBytes = required2;
17859
+ if (newline2 < 0)
17860
+ return;
17861
+ const text2 = buffered.toString("utf8", 0, bufferedBytes);
17862
+ bufferedBytes = 0;
17863
+ if (buffered.length > 64 * 1024)
17864
+ buffered = Buffer.alloc(0);
17865
+ if (text2.length > 0) {
17203
17866
  try {
17204
- const value = JSON.parse(frame.toString("utf8"));
17867
+ const value = JSON.parse(text2);
17205
17868
  onFrame(value);
17206
17869
  } catch (error51) {
17207
- onError(error51 instanceof SyntaxError ? new Error("Harness broker received invalid JSON") : error51 instanceof Error ? error51 : new Error(String(error51)));
17208
- socket.destroy();
17870
+ fail(error51 instanceof SyntaxError ? new Error("Harness broker received invalid JSON") : error51 instanceof Error ? error51 : new Error(String(error51)));
17209
17871
  return;
17210
17872
  }
17211
17873
  }
17212
- newline2 = buffered.indexOf(10);
17874
+ start = newline2 + 1;
17213
17875
  }
17214
17876
  });
17215
17877
  }
@@ -17269,6 +17931,10 @@ var brokerInspectInputSchema = external_exports.object({
17269
17931
  refresh: external_exports.boolean().optional(),
17270
17932
  purpose: external_exports.literal("availability").optional()
17271
17933
  }).strict();
17934
+ var brokerNormalizeStoredModelRefSchema = external_exports.strictObject({
17935
+ ref: harnessModelRefSchema,
17936
+ catalog: harnessModelCatalogSchema
17937
+ });
17272
17938
  var brokerSessionImportListParamsSchema = external_exports.object({
17273
17939
  offset: external_exports.number().int().nonnegative().safe(),
17274
17940
  limit: external_exports.number().int().min(1).max(HARNESS_BROKER_SESSION_IMPORT_PAGE_SIZE)
@@ -17397,15 +18063,18 @@ var eventKeys = /* @__PURE__ */ new Map([
17397
18063
  ["session.state.changed", /* @__PURE__ */ new Set(["type", "state"])],
17398
18064
  ["session.usage.changed", /* @__PURE__ */ new Set(["type", "usage", "observedForTurnId"])],
17399
18065
  ["usage.request", /* @__PURE__ */ new Set(["type", "request"])],
18066
+ ["usage.request.timing", /* @__PURE__ */ new Set(["type", "turnId", "timing"])],
17400
18067
  ["usage.history", /* @__PURE__ */ new Set(["type", "complete"])],
17401
18068
  ["subagent.state.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId", "status", "resultSummary"])],
17402
18069
  ["subagent.transcript.changed", /* @__PURE__ */ new Set(["type", "nativeSubagentId"])],
17403
18070
  ["turn.started", /* @__PURE__ */ new Set(["type", "turnId"])],
17404
18071
  ["turn.autonomous.started", /* @__PURE__ */ new Set(["type", "turnId", "input"])],
18072
+ ["turn.autonomous.completed", /* @__PURE__ */ new Set(["type", "snapshot"])],
17405
18073
  ["item.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
17406
18074
  ["item.updated", /* @__PURE__ */ new Set(["type", "turnId", "itemId", "update"])],
17407
18075
  ["item.completed", /* @__PURE__ */ new Set(["type", "turnId", "snapshot"])],
17408
18076
  ["item.detached", /* @__PURE__ */ new Set(["type", "turnId", "itemId"])],
18077
+ ["item.background.started", /* @__PURE__ */ new Set(["type", "turnId", "item"])],
17409
18078
  ["interaction.closed", /* @__PURE__ */ new Set(["type", "interactionId", "turnId", "reason"])],
17410
18079
  ["turn.completed", /* @__PURE__ */ new Set(["type", "turnId", "nativeTurnRef", "outcome"])],
17411
18080
  ["session.faulted", /* @__PURE__ */ new Set(["type", "error"])]
@@ -17432,6 +18101,118 @@ var interactionKeys = /* @__PURE__ */ new Map([
17432
18101
  function strictKeys(value, allowed) {
17433
18102
  return Boolean(allowed && value && typeof value === "object" && !Array.isArray(value) && Object.keys(value).every((key) => allowed.has(key)));
17434
18103
  }
18104
+ var nonNegativeSafeIntegerSchema2 = external_exports.int().nonnegative();
18105
+ var toolOutputSchema = external_exports.strictObject({
18106
+ content: external_exports.array(external_exports.discriminatedUnion("type", [
18107
+ textInputSchema,
18108
+ external_exports.strictObject({ type: external_exports.literal("image"), mimeType: external_exports.string(), base64Data: external_exports.string() })
18109
+ ])),
18110
+ truncated: external_exports.boolean().optional()
18111
+ });
18112
+ var fileChangeSchema = external_exports.strictObject({
18113
+ path: external_exports.string(),
18114
+ kind: external_exports.enum(["add", "update", "delete"]),
18115
+ unifiedDiff: external_exports.string(),
18116
+ diffScope: external_exports.literal("fragment").optional()
18117
+ });
18118
+ var subagentStateSchema = external_exports.strictObject({
18119
+ subagentId: external_exports.string().min(1),
18120
+ nativeSubagentId: external_exports.string().min(1).optional(),
18121
+ description: external_exports.string(),
18122
+ role: external_exports.string().optional(),
18123
+ model: external_exports.string().optional(),
18124
+ reasoningEffort: external_exports.string().optional(),
18125
+ background: external_exports.boolean(),
18126
+ status: external_exports.enum(["pending", "running", "completed", "failed", "interrupted"]),
18127
+ resultSummary: external_exports.string().optional()
18128
+ });
18129
+ var itemBase = { itemId: hostItemIdSchema };
18130
+ var toolFields = {
18131
+ ...itemBase,
18132
+ toolName: external_exports.string(),
18133
+ arguments: jsonValueSchema,
18134
+ output: toolOutputSchema.optional(),
18135
+ durationMs: external_exports.number().nonnegative().optional()
18136
+ };
18137
+ var snapshotItemSchema = external_exports.discriminatedUnion("type", [
18138
+ external_exports.strictObject({
18139
+ ...itemBase,
18140
+ type: external_exports.literal("agentMessage"),
18141
+ text: external_exports.string(),
18142
+ phase: external_exports.enum(["commentary", "final_answer"]).optional()
18143
+ }),
18144
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("userMessage"), input: external_exports.array(textInputSchema) }),
18145
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("reasoning"), text: external_exports.string() }),
18146
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("contextCompaction") }),
18147
+ external_exports.strictObject({
18148
+ ...itemBase,
18149
+ type: external_exports.literal("commandExecution"),
18150
+ command: external_exports.string(),
18151
+ cwd: cwdSchema.optional(),
18152
+ output: external_exports.string().optional(),
18153
+ outputTruncated: external_exports.boolean().optional(),
18154
+ exitCode: external_exports.int().nullable().optional(),
18155
+ durationMs: external_exports.number().nonnegative().optional()
18156
+ }),
18157
+ external_exports.strictObject({
18158
+ ...toolFields,
18159
+ type: external_exports.literal("toolExecution"),
18160
+ namespace: external_exports.string().optional()
18161
+ }),
18162
+ external_exports.strictObject({ ...toolFields, type: external_exports.literal("mcpToolCall"), server: external_exports.string() }),
18163
+ external_exports.strictObject({ ...itemBase, type: external_exports.literal("webSearch"), query: external_exports.string() }),
18164
+ external_exports.strictObject({
18165
+ ...itemBase,
18166
+ type: external_exports.literal("fileChange"),
18167
+ changes: external_exports.array(fileChangeSchema),
18168
+ sourceItemIds: external_exports.array(hostItemIdSchema).optional()
18169
+ }),
18170
+ external_exports.strictObject({
18171
+ ...itemBase,
18172
+ type: external_exports.literal("subagentDelegation"),
18173
+ operation: external_exports.enum(["spawn", "send"]),
18174
+ prompt: external_exports.string().optional(),
18175
+ subagents: external_exports.array(subagentStateSchema)
18176
+ })
18177
+ ]);
18178
+ var terminalOutcomes = [
18179
+ external_exports.strictObject({ status: external_exports.literal("succeeded") }),
18180
+ external_exports.strictObject({ status: external_exports.literal("failed"), error: harnessErrorSchema }),
18181
+ external_exports.strictObject({ status: external_exports.literal("cancelled"), reason: external_exports.string().optional() })
18182
+ ];
18183
+ var autonomousSnapshotSchema = external_exports.strictObject({
18184
+ nativeTurnRef: nativeTurnRefSchema,
18185
+ checkpoint: nativeCheckpointRefSchema.optional(),
18186
+ input: external_exports.array(textInputSchema),
18187
+ items: external_exports.array(external_exports.strictObject({
18188
+ item: snapshotItemSchema,
18189
+ outcome: external_exports.discriminatedUnion("status", terminalOutcomes)
18190
+ })),
18191
+ outcome: external_exports.discriminatedUnion("status", [
18192
+ ...terminalOutcomes,
18193
+ external_exports.strictObject({ status: external_exports.literal("unknown"), reason: external_exports.string() })
18194
+ ]),
18195
+ model: harnessModelRefSchema.optional(),
18196
+ startedAtMs: nonNegativeSafeIntegerSchema2.optional(),
18197
+ completedAtMs: nonNegativeSafeIntegerSchema2.optional()
18198
+ }).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, {
18199
+ path: ["items"],
18200
+ message: "Item IDs must be unique within the Turn"
18201
+ });
18202
+ var usageOutputIntervalSchema = external_exports.strictObject({
18203
+ startedAtMs: nonNegativeSafeIntegerSchema2,
18204
+ completedAtMs: nonNegativeSafeIntegerSchema2,
18205
+ outputTokens: nonNegativeSafeIntegerSchema2
18206
+ }).refine(({ startedAtMs, completedAtMs }) => completedAtMs > startedAtMs);
18207
+ var usageRequestTimingSchema = external_exports.union([
18208
+ external_exports.strictObject({
18209
+ requestId: external_exports.string().min(1),
18210
+ requestStartedAtMs: nonNegativeSafeIntegerSchema2,
18211
+ timeToFirstOutputMs: nonNegativeSafeIntegerSchema2,
18212
+ output: usageOutputIntervalSchema.optional()
18213
+ }),
18214
+ external_exports.strictObject({ requestId: external_exports.string().min(1), output: usageOutputIntervalSchema })
18215
+ ]);
17435
18216
  var harnessOutputSchema = external_exports.custom((value) => {
17436
18217
  if (!value || typeof value !== "object" || Array.isArray(value))
17437
18218
  return false;
@@ -17444,10 +18225,20 @@ var harnessOutputSchema = external_exports.custom((value) => {
17444
18225
  return false;
17445
18226
  if (event.type === "session.state.changed")
17446
18227
  return harnessSessionStateSchema.safeParse(event.state).success;
18228
+ if (event.type === "item.background.started")
18229
+ return hostTurnIdSchema.safeParse(event.turnId).success && external_exports.object({
18230
+ type: external_exports.enum(["agentMessage", "reasoning"]),
18231
+ itemId: hostItemIdSchema,
18232
+ text: external_exports.string()
18233
+ }).strict().safeParse(event.item).success;
18234
+ if (event.type === "turn.autonomous.completed")
18235
+ return autonomousSnapshotSchema.safeParse(event.snapshot).success;
17447
18236
  if (event.type === "session.faulted")
17448
18237
  return harnessErrorSchema.safeParse(event.error).success;
17449
18238
  if (event.type === "usage.history")
17450
18239
  return typeof event.complete === "boolean";
18240
+ if (event.type === "usage.request.timing")
18241
+ return hostTurnIdSchema.safeParse(event.turnId).success && usageRequestTimingSchema.safeParse(event.timing).success;
17451
18242
  return true;
17452
18243
  }
17453
18244
  if (output.kind === "interaction") {
@@ -17721,7 +18512,7 @@ var BrokerConnection = class _BrokerConnection {
17721
18512
  constructor(descriptor, socket) {
17722
18513
  this.#descriptor = descriptor;
17723
18514
  this.#socket = socket;
17724
- consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error51) => this.#fail(error51));
18515
+ consumeBrokerFrames(socket, (raw) => this.#frame(raw), (error51) => this.#fail(error51), HARNESS_BROKER_MAX_RESPONSE_BYTES);
17725
18516
  socket.once("close", () => this.#fail(new Error("Aqua Harness broker connection closed")));
17726
18517
  socket.once("error", (error51) => this.#fail(error51));
17727
18518
  }
@@ -17758,19 +18549,20 @@ var BrokerConnection = class _BrokerConnection {
17758
18549
  generation: descriptor.generation,
17759
18550
  sequence: 1,
17760
18551
  kind: "hello",
17761
- token: descriptor.token
18552
+ token: descriptor.token,
18553
+ maxResponseBytes: HARNESS_BROKER_MAX_RESPONSE_BYTES
17762
18554
  });
17763
18555
  await hello;
17764
18556
  return connection;
17765
18557
  }
17766
18558
  #waitForHello() {
17767
18559
  return new Promise((resolve, reject) => {
17768
- const id = "__hello__";
18560
+ const id2 = "__hello__";
17769
18561
  const timeout = setTimeout(() => {
17770
- this.#pending.delete(id);
18562
+ this.#pending.delete(id2);
17771
18563
  reject(new Error("Aqua Harness broker authentication timed out"));
17772
18564
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
17773
- this.#pending.set(id, { resolve: () => resolve(), reject, timeout });
18565
+ this.#pending.set(id2, { resolve: () => resolve(), reject, timeout });
17774
18566
  });
17775
18567
  }
17776
18568
  register(session) {
@@ -17795,13 +18587,13 @@ var BrokerConnection = class _BrokerConnection {
17795
18587
  throw new Error("Aqua Harness broker request limit exceeded");
17796
18588
  }
17797
18589
  this.#inputSequence += 1;
17798
- const id = randomUUID();
18590
+ const id2 = randomUUID();
17799
18591
  const response = new Promise((resolve, reject) => {
17800
18592
  const timeout = setTimeout(() => {
17801
- this.#pending.delete(id);
18593
+ this.#pending.delete(id2);
17802
18594
  reject(new Error(`Aqua Harness broker ${method} timed out`));
17803
18595
  }, HARNESS_BROKER_REQUEST_TIMEOUT_MS);
17804
- this.#pending.set(id, { resolve, reject, timeout });
18596
+ this.#pending.set(id2, { resolve, reject, timeout });
17805
18597
  });
17806
18598
  try {
17807
18599
  await writeBrokerFrame(this.#socket, {
@@ -17809,15 +18601,15 @@ var BrokerConnection = class _BrokerConnection {
17809
18601
  generation: this.#descriptor.generation,
17810
18602
  sequence: this.#inputSequence,
17811
18603
  kind: "request",
17812
- id,
18604
+ id: id2,
17813
18605
  method,
17814
18606
  params
17815
18607
  });
17816
18608
  } catch (error51) {
17817
- const pending = this.#pending.get(id);
18609
+ const pending = this.#pending.get(id2);
17818
18610
  if (pending)
17819
18611
  clearTimeout(pending.timeout);
17820
- this.#pending.delete(id);
18612
+ this.#pending.delete(id2);
17821
18613
  response.catch(() => void 0);
17822
18614
  throw new BrokerRequestNotDeliveredError(error51 instanceof Error ? error51.message : String(error51));
17823
18615
  }
@@ -18184,6 +18976,10 @@ var BrokeredHarnessAdapter = class {
18184
18976
  return failedInspection(describeBrokerFailure(error51, this.harnessId));
18185
18977
  }
18186
18978
  }
18979
+ async normalizeStoredModelRef(ref, catalog) {
18980
+ const result = await this.#request("adapter.normalizeStoredModelRef", { ref, catalog }, true);
18981
+ return harnessModelRefSchema.nullable().parse(result) ?? void 0;
18982
+ }
18187
18983
  async open(input) {
18188
18984
  if (this.#closed)
18189
18985
  return { ok: false, error: unavailable("Aqua Harness broker adapter is closed", false) };
@@ -18557,17 +19353,14 @@ function capabilitiesForProfile(profile = CODEBUDDY_RUNTIME_PROFILE) {
18557
19353
  };
18558
19354
  }
18559
19355
  function modelRef(modelId2) {
18560
- return harnessModelRefSchema.parse({ id: `cb.${Buffer.from(modelId2).toString("base64url")}` });
19356
+ return harnessModelRefSchema.parse({ id: modelId2 });
18561
19357
  }
18562
- function nativeModel(ref) {
18563
- const value = Buffer.from(ref.id.slice(3), "base64url").toString("utf8");
18564
- if (!value || !ref.id.startsWith("cb.") || modelRef(value).id !== ref.id)
18565
- throw new CodeBuddyError("invalidRequest", "Invalid native Model Ref");
18566
- return value;
19358
+ function normalizeStoredCodeBuddyModelRef(ref, catalog) {
19359
+ return normalizeLegacyBase64ModelRef(ref, catalog, "cb.");
18567
19360
  }
18568
19361
  function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE) {
18569
19362
  const options = rows(value);
18570
- const get = (id) => options.find((option) => option.id === id) ?? {};
19363
+ const get = (id2) => options.find((option) => option.id === id2) ?? {};
18571
19364
  const model2 = get("model"), mode = get("mode"), thought = get("thought_level");
18572
19365
  const thinkingOptions = rows(thought.options).map((option) => harnessThinkingOptionSchema.parse({ id: option.value, label: option.name }));
18573
19366
  const currentThinking = thinkingOptions.find((option) => option.id === thought.currentValue);
@@ -18611,10 +19404,34 @@ function configuration(value, profile = CODEBUDDY_RUNTIME_PROFILE) {
18611
19404
  };
18612
19405
  return { catalog, permissionModes, state, options };
18613
19406
  }
18614
- function confirmedConfiguration(response, id, value, profile = CODEBUDDY_RUNTIME_PROFILE) {
19407
+ async function selectConfiguration(config2, id2, value, profile, request) {
19408
+ const option = config2?.options.find((option2) => option2.id === id2);
19409
+ const listed = rows(option?.options).some((option2) => option2.value === value);
19410
+ if (!listed && !(id2 === "model" && profile.allowUnlistedModelSelection))
19411
+ throw new CodeBuddyError("invalidRequest", `Unavailable ${profile.displayName} ${id2} selection`);
19412
+ return confirmedConfiguration(await request(id2, value), id2, value, profile);
19413
+ }
19414
+ async function restoreConfiguration(config2, saved, profile, request) {
19415
+ const selections = [
19416
+ ["model", saved.effectiveModel?.id],
19417
+ ["thought_level", saved.effectiveThinkingOptionId],
19418
+ ["mode", saved.effectivePermissionModeId]
19419
+ ];
19420
+ const matches = (id2, value) => config2.options.some((option) => option.id === id2 && option.currentValue === value);
19421
+ for (const [id2, value] of selections) {
19422
+ if (value && !matches(id2, value))
19423
+ config2 = await selectConfiguration(config2, id2, value, profile, request);
19424
+ }
19425
+ for (const [id2, value] of selections) {
19426
+ if (value && !matches(id2, value))
19427
+ throw new CodeBuddyError("protocolError", `ACP did not restore ${id2}`);
19428
+ }
19429
+ return config2;
19430
+ }
19431
+ function confirmedConfiguration(response, id2, value, profile = CODEBUDDY_RUNTIME_PROFILE) {
18615
19432
  const result = configuration(record3(response).configOptions, profile);
18616
- if (result.options.find((option) => option.id === id)?.currentValue !== value) {
18617
- throw new CodeBuddyError("protocolError", `ACP did not confirm ${id}`);
19433
+ if (result.options.find((option) => option.id === id2)?.currentValue !== value) {
19434
+ throw new CodeBuddyError("protocolError", `ACP did not confirm ${id2}`);
18618
19435
  }
18619
19436
  return result;
18620
19437
  }
@@ -19250,8 +20067,8 @@ var CodeBuddyTurnOutput = class {
19250
20067
  this.#textItems.set(type, item2);
19251
20068
  this.#start(item2);
19252
20069
  }
19253
- const id2 = item2.itemId;
19254
- if (this.#finished.has(id2))
20070
+ const id3 = item2.itemId;
20071
+ if (this.#finished.has(id3))
19255
20072
  throw new CodeBuddyError("protocolError", "Text arrived after Item completion");
19256
20073
  if (item2.text.length + delta.length > 2e6)
19257
20074
  throw new CodeBuddyError("protocolError", "Agent output exceeded the supported Item size");
@@ -19259,7 +20076,7 @@ var CodeBuddyTurnOutput = class {
19259
20076
  this.emit({
19260
20077
  type: "item.updated",
19261
20078
  turnId: this.turnId,
19262
- itemId: id2,
20079
+ itemId: id3,
19263
20080
  update: { type: "text.append", text: delta }
19264
20081
  });
19265
20082
  return;
@@ -19280,8 +20097,8 @@ var CodeBuddyTurnOutput = class {
19280
20097
  if (!terminal && !record3(merged._meta)["codebuddy.ai/toolArgumentsComplete"])
19281
20098
  return;
19282
20099
  const name = text(record3(merged._meta)["codebuddy.ai/toolName"]) || text(merged.title) || `${this.profile.displayName} tool`;
19283
- const id = `tool-${callId}`;
19284
- let item = this.#items.get(id)?.item;
20100
+ const id2 = `tool-${callId}`;
20101
+ let item = this.#items.get(id2)?.item;
19285
20102
  if (!item) {
19286
20103
  this.completeMessage();
19287
20104
  item = toolItem(callId, name, merged.rawInput, this.cwd);
@@ -19355,13 +20172,13 @@ var CodeBuddyTurnOutput = class {
19355
20172
  };
19356
20173
 
19357
20174
  // ../codebuddy/dist/subagent-tool.js
19358
- var validCodeBuddyChildId = (id) => /^agent-[a-zA-Z0-9_-]{1,100}$/u.test(id);
20175
+ var validCodeBuddyChildId = (id2) => /^agent-[a-zA-Z0-9_-]{1,100}$/u.test(id2);
19359
20176
  function codeBuddyChildId(value) {
19360
20177
  const row = record3(value);
19361
20178
  const structured = text(record3(record3(record3(row.providerData).toolResult).subAgent).sessionId);
19362
20179
  const body = contentText(row.rawOutput ?? row.output);
19363
- const id = structured || /\[Agent ID: (agent-[a-zA-Z0-9_-]+)\]\s*$/u.exec(body)?.[1];
19364
- return id && validCodeBuddyChildId(id) ? id : void 0;
20180
+ const id2 = structured || /\[Agent ID: (agent-[a-zA-Z0-9_-]+)\]\s*$/u.exec(body)?.[1];
20181
+ return id2 && validCodeBuddyChildId(id2) ? id2 : void 0;
19365
20182
  }
19366
20183
  function codeBuddyDelegation(callId, input, status, childId, displayName = "CodeBuddy") {
19367
20184
  const args = record3(input);
@@ -19539,10 +20356,10 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
19539
20356
  const checkedDirectories = /* @__PURE__ */ new Set();
19540
20357
  const inheritedRows = /* @__PURE__ */ new Map();
19541
20358
  for (const row of transaction?.inheritedContents ? parseRows(transaction.inheritedContents) : []) {
19542
- const id = text(row.id);
19543
- const candidates2 = inheritedRows.get(id) ?? [];
20359
+ const id2 = text(row.id);
20360
+ const candidates2 = inheritedRows.get(id2) ?? [];
19544
20361
  candidates2.push(row);
19545
- inheritedRows.set(id, candidates2);
20362
+ inheritedRows.set(id2, candidates2);
19546
20363
  }
19547
20364
  const inherited = (row) => inheritedRows.get(text(row.id))?.some((candidate) => isDeepStrictEqual(candidate, row)) === true;
19548
20365
  if (transaction) {
@@ -19564,15 +20381,15 @@ async function codeBuddyHistory(cwd, ref, environment, tolerateIncompleteTail, p
19564
20381
  } else if (provenance) {
19565
20382
  if (!await sameCwd(provenance.boundCwd, cwd) || provenance.targetProjectSlug !== slug || path3.resolve(file2) !== path3.resolve(primary))
19566
20383
  throw new CodeBuddyError("invalidRequest", "Derived Native Session target binding changed");
19567
- const active = nativeHistoryRows(parsed.contents);
19568
- if (provenance.inheritedPrefixRows > active.length || nativeRowsDigest(active.slice(0, provenance.inheritedPrefixRows)) !== provenance.inheritedPrefixSha256)
20384
+ const active2 = nativeHistoryRows(parsed.contents);
20385
+ if (provenance.inheritedPrefixRows > active2.length || nativeRowsDigest(active2.slice(0, provenance.inheritedPrefixRows)) !== provenance.inheritedPrefixSha256)
19569
20386
  throw new CodeBuddyError("protocolError", "Derived Native Session prefix verification failed");
19570
20387
  const marker = parsed.rows.find((row) => text(row.id) === provenance.bindingMarkerId);
19571
20388
  if (!marker || marker.sessionId !== ref.nativeSessionId || typeof marker.cwd !== "string" || !await sameCwd(marker.cwd, cwd))
19572
20389
  throw new CodeBuddyError("protocolError", "Derived Native Session target marker is missing");
19573
20390
  checkedDirectories.add(cwd);
19574
20391
  const verifiedSuffixCwds = /* @__PURE__ */ new Set();
19575
- for (const row of active.slice(provenance.inheritedPrefixRows)) {
20392
+ for (const row of active2.slice(provenance.inheritedPrefixRows)) {
19576
20393
  if (row.sessionId && row.sessionId !== ref.nativeSessionId)
19577
20394
  throw new CodeBuddyError("protocolError", "Derived Native Session appended foreign history");
19578
20395
  if (typeof row.cwd === "string" && !verifiedSuffixCwds.has(row.cwd)) {
@@ -19989,14 +20806,14 @@ async function readCodeBuddyUsage(file2, signal) {
19989
20806
  sessionId ??= row.sessionId;
19990
20807
  cwd ??= row.cwd;
19991
20808
  const data = record4(row.providerData);
19992
- const id = typeof data.messageId === "string" ? data.messageId : "";
19993
- if (!id || Object.keys(record4(data.rawUsage)).length === 0)
20809
+ const id2 = typeof data.messageId === "string" ? data.messageId : "";
20810
+ if (!id2 || Object.keys(record4(data.rawUsage)).length === 0)
19994
20811
  continue;
19995
- messages.set(id, { data, at: messages.get(id)?.at ?? nativeTimeMs(row.timestamp) });
20812
+ messages.set(id2, { data, at: messages.get(id2)?.at ?? nativeTimeMs(row.timestamp) });
19996
20813
  }
19997
20814
  const entries = [];
19998
- for (const [id, { data, at }] of messages) {
19999
- const request = providerUsageRequest(id, data, false);
20815
+ for (const [id2, { data, at }] of messages) {
20816
+ const request = providerUsageRequest(id2, data, false);
20000
20817
  const entry = request && at !== null && usageEntryFromRequest(request, at);
20001
20818
  if (entry) {
20002
20819
  const credits = record4(data.rawUsage).credit;
@@ -20016,7 +20833,7 @@ function createCodeBuddyUsageStatistics(environment, profile) {
20016
20833
  return Object.freeze({
20017
20834
  // projects/<project>/<session>.jsonl and <session>/subagents/*.jsonl
20018
20835
  listSources: (signal) => jsonlUsageSources(path4.join(codeBuddyConfigRoot(environment, profile), "projects"), 3, signal),
20019
- readSource: (id, signal) => readCodeBuddyUsage(id, signal)
20836
+ readSource: (id2, signal) => readCodeBuddyUsage(id2, signal)
20020
20837
  });
20021
20838
  }
20022
20839
 
@@ -21879,8 +22696,8 @@ var RequestResponder = class {
21879
22696
  signal;
21880
22697
  finishRequest;
21881
22698
  didRespond = false;
21882
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
21883
- this.id = id;
22699
+ constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
22700
+ this.id = id2;
21884
22701
  this.sendResult = sendResult;
21885
22702
  this.signal = signal;
21886
22703
  this.finishRequest = finishRequest;
@@ -22171,7 +22988,7 @@ var Connection = class {
22171
22988
  return this.sendWireMessage({ jsonrpc: "2.0", method, params });
22172
22989
  }
22173
22990
  prepareRequest(method, params, mapResponse, options = {}) {
22174
- const id = this.nextRequestId++;
22991
+ const id2 = this.nextRequestId++;
22175
22992
  let cancel = () => {
22176
22993
  };
22177
22994
  const response = new Promise((resolve, reject) => {
@@ -22191,7 +23008,7 @@ var Connection = class {
22191
23008
  }
22192
23009
  pendingResponse.cancellationSent = true;
22193
23010
  pendingResponse.cleanup?.();
22194
- void this.sendCancelRequest(id).catch(() => {
23011
+ void this.sendCancelRequest(id2).catch(() => {
22195
23012
  });
22196
23013
  };
22197
23014
  options.cancellationSignal?.addEventListener("abort", cancel, {
@@ -22200,12 +23017,12 @@ var Connection = class {
22200
23017
  pendingResponse.cleanup = () => {
22201
23018
  options.cancellationSignal?.removeEventListener("abort", cancel);
22202
23019
  };
22203
- this.pendingResponses.set(id, pendingResponse);
23020
+ this.pendingResponses.set(id2, pendingResponse);
22204
23021
  });
22205
23022
  response.catch(() => {
22206
23023
  });
22207
23024
  return {
22208
- message: { jsonrpc: "2.0", id, method, params },
23025
+ message: { jsonrpc: "2.0", id: id2, method, params },
22209
23026
  response,
22210
23027
  cancel: () => cancel()
22211
23028
  };
@@ -22842,7 +23659,7 @@ function memoryStreamPair() {
22842
23659
  }
22843
23660
  ];
22844
23661
  }
22845
- var methods = {
23662
+ var methods2 = {
22846
23663
  agent: {
22847
23664
  initialize: AGENT_METHODS.initialize,
22848
23665
  authenticate: AGENT_METHODS.authenticate,
@@ -24285,10 +25102,10 @@ function executableExtensions(command, platform, environment) {
24285
25102
  return [""];
24286
25103
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
24287
25104
  }
24288
- function isExecutableFile(filePath, platform) {
25105
+ function isExecutableFile(filePath2, platform) {
24289
25106
  try {
24290
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
24291
- return fs.statSync(filePath).isFile();
25107
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
25108
+ return fs.statSync(filePath2).isFile();
24292
25109
  } catch {
24293
25110
  return false;
24294
25111
  }
@@ -25250,12 +26067,12 @@ function referencedChildren(rows2) {
25250
26067
  function assertChildRanges(rows2, child) {
25251
26068
  const positions = /* @__PURE__ */ new Map();
25252
26069
  for (const [index, row] of rows2.entries()) {
25253
- const id = text(row.id);
25254
- if (!id)
26070
+ const id2 = text(row.id);
26071
+ if (!id2)
25255
26072
  continue;
25256
- const matches = positions.get(id) ?? [];
26073
+ const matches = positions.get(id2) ?? [];
25257
26074
  matches.push(index);
25258
- positions.set(id, matches);
26075
+ positions.set(id2, matches);
25259
26076
  }
25260
26077
  let previous = -1;
25261
26078
  for (const range of child.ranges) {
@@ -25793,13 +26610,13 @@ var CodeBuddySessionImport = class {
25793
26610
  }
25794
26611
  listCandidates() {
25795
26612
  return this.#scope.read(async (signal) => {
25796
- const active = await this.#activeSessions(signal);
26613
+ const active2 = await this.#activeSessions(signal);
25797
26614
  const candidates = [];
25798
26615
  for (const [nativeSessionId, files] of await this.#sessionFiles(signal)) {
25799
26616
  if (files.length !== 1 || !files[0])
25800
26617
  continue;
25801
26618
  try {
25802
- const source = await this.#source(nativeSessionId, files[0], active, signal);
26619
+ const source = await this.#source(nativeSessionId, files[0], active2, signal);
25803
26620
  if (source)
25804
26621
  candidates.push(source.candidate);
25805
26622
  } catch (error51) {
@@ -25826,7 +26643,7 @@ var CodeBuddySessionImport = class {
25826
26643
  }
25827
26644
  /** IDs a live native process registered in `<config>/sessions/<pid>.json`. */
25828
26645
  async #activeSessions(signal) {
25829
- const active = /* @__PURE__ */ new Set();
26646
+ const active2 = /* @__PURE__ */ new Set();
25830
26647
  const directory = path9.join(this.#root(), "sessions");
25831
26648
  const markers = await opendir2(directory).catch((error51) => {
25832
26649
  if (isMissingFileError(error51) || record3(error51).code === "ENOTDIR")
@@ -25834,7 +26651,7 @@ var CodeBuddySessionImport = class {
25834
26651
  throw error51;
25835
26652
  });
25836
26653
  if (!markers)
25837
- return active;
26654
+ return active2;
25838
26655
  for await (const marker of markers) {
25839
26656
  signal.throwIfAborted();
25840
26657
  if (!marker.isFile() || !marker.name.endsWith(".json"))
@@ -25845,14 +26662,14 @@ var CodeBuddySessionImport = class {
25845
26662
  continue;
25846
26663
  const entry = record3(JSON.parse(await readFile4(file2, { encoding: "utf8", signal })));
25847
26664
  if (typeof entry.sessionId === "string" && processAlive(entry.pid))
25848
- active.add(entry.sessionId);
26665
+ active2.add(entry.sessionId);
25849
26666
  } catch (error51) {
25850
26667
  signal.throwIfAborted();
25851
26668
  if (isStorageAccessError(error51))
25852
26669
  throw error51;
25853
26670
  }
25854
26671
  }
25855
- return active;
26672
+ return active2;
25856
26673
  }
25857
26674
  /** Session ID to every project file claiming it. Enumerated links are not followed. */
25858
26675
  async #sessionFiles(signal) {
@@ -25887,7 +26704,7 @@ var CodeBuddySessionImport = class {
25887
26704
  }
25888
26705
  return found;
25889
26706
  }
25890
- async #source(nativeSessionId, file2, active, signal) {
26707
+ async #source(nativeSessionId, file2, active2, signal) {
25891
26708
  signal.throwIfAborted();
25892
26709
  return readStableFiles([file2], async ([info]) => {
25893
26710
  if (!info?.isFile() || info.size === 0 || info.size > MAX_HISTORY_BYTES)
@@ -25914,7 +26731,7 @@ var CodeBuddySessionImport = class {
25914
26731
  title: facts.title,
25915
26732
  updatedAt: facts.updatedAt ?? info.mtimeMs,
25916
26733
  // A registered live process holds the Session. Absence is not proof of idleness.
25917
- running: active.has(nativeSessionId) ? true : null
26734
+ running: active2.has(nativeSessionId) ? true : null
25918
26735
  });
25919
26736
  return candidate ? { candidate, nativeRef } : null;
25920
26737
  } catch (error51) {
@@ -26184,10 +27001,10 @@ var CodeBuddyChildObserver = class {
26184
27001
  throw new CodeBuddyError("unsupported", "Too many native Subagent transcripts");
26185
27002
  const matches = [];
26186
27003
  for (const file2 of files) {
26187
- const id = file2.name.slice(0, -6), data = await this.#child(directory, id);
27004
+ const id2 = file2.name.slice(0, -6), data = await this.#child(directory, id2);
26188
27005
  const first = data.entries.find((row) => row.type === "message" && row.role === "user");
26189
27006
  if (record3(first?.providerData).conversationRequestId === requestId)
26190
- matches.push(id);
27007
+ matches.push(id2);
26191
27008
  }
26192
27009
  if (matches.length > 1)
26193
27010
  throw new CodeBuddyError("protocolError", "Ambiguous native Subagent correlation");
@@ -26258,8 +27075,8 @@ var CodeBuddySubagents = class {
26258
27075
  hasItem(itemId) {
26259
27076
  return [...this.#calls.values()].some((call) => call.turnId === this.#turnId && call.item.itemId === itemId);
26260
27077
  }
26261
- state(id) {
26262
- return [...this.#calls.values()].map((call) => call.item.subagents[0]).findLast((child) => child?.nativeSubagentId === id);
27078
+ state(id2) {
27079
+ return [...this.#calls.values()].map((call) => call.item.subagents[0]).findLast((child) => child?.nativeSubagentId === id2);
26263
27080
  }
26264
27081
  project(snapshot) {
26265
27082
  for (const turn of snapshot.turns)
@@ -26333,9 +27150,9 @@ var CodeBuddySubagents = class {
26333
27150
  }
26334
27151
  });
26335
27152
  }
26336
- const id = call.item.subagents[0]?.nativeSubagentId;
26337
- if (id)
26338
- this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId: id });
27153
+ const id2 = call.item.subagents[0]?.nativeSubagentId;
27154
+ if (id2)
27155
+ this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId: id2 });
26339
27156
  }
26340
27157
  return true;
26341
27158
  }
@@ -26384,25 +27201,25 @@ var CodeBuddySubagents = class {
26384
27201
  if (call.observationDone)
26385
27202
  continue;
26386
27203
  try {
26387
- const id = call.item.subagents[0]?.nativeSubagentId ?? (call.requestId ? await (this.options.locate ? this.options.locate(parent, this.options.cwd, this.options.environment, call.requestId, this.profile) : this.#observer.locate(call.requestId)) : void 0);
26388
- if (!id || this.#closed || call.observationDone)
27204
+ const id2 = call.item.subagents[0]?.nativeSubagentId ?? (call.requestId ? await (this.options.locate ? this.options.locate(parent, this.options.cwd, this.options.environment, call.requestId, this.profile) : this.#observer.locate(call.requestId)) : void 0);
27205
+ if (!id2 || this.#closed || call.observationDone)
26389
27206
  continue;
26390
27207
  if (!call.item.subagents[0]?.nativeSubagentId)
26391
- this.#update(call, { nativeSubagentId: id, subagentId: id });
26392
- const snapshot = await (this.options.read ? this.options.read(parent, id, this.options.cwd, this.options.environment, "running", this.profile) : this.#observer.read(id, "running"));
27208
+ this.#update(call, { nativeSubagentId: id2, subagentId: id2 });
27209
+ const snapshot = await (this.options.read ? this.options.read(parent, id2, this.options.cwd, this.options.environment, "running", this.profile) : this.#observer.read(id2, "running"));
26393
27210
  if (this.#closed || call.observationDone)
26394
27211
  continue;
26395
27212
  const observedModel = snapshot.turns.at(-1)?.model ?? snapshot.state?.effectiveModel;
26396
27213
  const reasoningEffort = snapshot.state?.effectiveThinkingOptionId;
26397
27214
  if (observedModel || reasoningEffort)
26398
27215
  this.#update(call, {
26399
- ...observedModel ? { model: nativeModel(observedModel) } : {},
27216
+ ...observedModel ? { model: observedModel.id } : {},
26400
27217
  ...reasoningEffort ? { reasoningEffort } : {}
26401
27218
  });
26402
27219
  const signature = JSON.stringify(snapshot);
26403
27220
  if (signature !== call.signature) {
26404
27221
  call.signature = signature;
26405
- this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId: id });
27222
+ this.options.emit({ type: "subagent.transcript.changed", nativeSubagentId: id2 });
26406
27223
  }
26407
27224
  } catch {
26408
27225
  }
@@ -26462,7 +27279,8 @@ var CodeBuddySession = class {
26462
27279
  subagents;
26463
27280
  #client;
26464
27281
  #generation = 0;
26465
- #replaying = false;
27282
+ #needsResume = false;
27283
+ #replay;
26466
27284
  #interactions;
26467
27285
  #config;
26468
27286
  #ref;
@@ -26514,22 +27332,31 @@ var CodeBuddySession = class {
26514
27332
  ephemeral: false,
26515
27333
  handlers: {
26516
27334
  fault: (error51) => {
26517
- if (generation === this.#generation)
27335
+ if (generation !== this.#generation || this.#closed)
27336
+ return;
27337
+ if (this.#replay)
27338
+ this.#replay.fault ??= { error: error51 };
27339
+ else
26518
27340
  this.#onFault(error51);
26519
27341
  },
26520
27342
  update: (notification) => {
26521
- if (generation !== this.#generation || this.#closed)
27343
+ if (generation !== this.#generation || this.#closed || this.#fault)
26522
27344
  return;
26523
27345
  if (this.#ref && notification.sessionId !== this.#ref.nativeSessionId)
26524
27346
  return;
26525
27347
  try {
26526
27348
  const update = record3(notification.update);
26527
27349
  if (nativeCommandsEnabled(this.profile) && update.sessionUpdate === "available_commands_update") {
26528
- if (!this.profile.staticCommandCatalog)
26529
- this.#commands = commandCatalog(update.availableCommands, this.profile);
27350
+ if (!this.profile.staticCommandCatalog) {
27351
+ const commands = commandCatalog(update.availableCommands, this.profile);
27352
+ if (this.#replay)
27353
+ this.#replay.commands = commands;
27354
+ else
27355
+ this.#commands = commands;
27356
+ }
26530
27357
  return;
26531
27358
  }
26532
- if (this.#replaying)
27359
+ if (this.#replay)
26533
27360
  return;
26534
27361
  if ((text(record3(update._meta)["codebuddy.ai/parentToolCallId"]) || !this.#active?.output.hasItem(`tool-${text(update.toolCallId)}`)) && this.subagents.update(update))
26535
27362
  return;
@@ -26546,19 +27373,31 @@ var CodeBuddySession = class {
26546
27373
  }
26547
27374
  this.#active?.output.update(update);
26548
27375
  } catch (error51) {
26549
- this.#onFault(error51);
27376
+ if (this.#replay)
27377
+ this.#replay.fault ??= { error: error51 };
27378
+ else
27379
+ this.#onFault(error51);
26550
27380
  }
26551
27381
  },
26552
- permission: (request) => generation === this.#generation && !this.#replaying && this.#active && request.sessionId === this.#ref?.nativeSessionId ? this.#interactions.permission(this.#active.command.turnId, request) : Promise.resolve({ outcome: { outcome: "cancelled" } }),
26553
- question: (params) => generation === this.#generation && !this.#replaying && this.#active && params.sessionId === this.#ref?.nativeSessionId ? this.#interactions.question(this.#active.command.turnId, params) : Promise.resolve({ outcome: "cancelled" })
27382
+ permission: (request) => generation === this.#generation && !this.#closed && !this.#fault && !this.#replay && this.#active && !this.#active.cancelled && request.sessionId === this.#ref?.nativeSessionId ? this.#interactions.permission(this.#active.command.turnId, request) : Promise.resolve({ outcome: { outcome: "cancelled" } }),
27383
+ question: (params) => generation === this.#generation && !this.#closed && !this.#fault && !this.#replay && this.#active && !this.#active.cancelled && params.sessionId === this.#ref?.nativeSessionId ? this.#interactions.question(this.#active.command.turnId, params) : Promise.resolve({ outcome: "cancelled" })
26554
27384
  }
26555
27385
  });
26556
27386
  }
27387
+ #assertClient(generation) {
27388
+ if (this.#closed || this.#fault || generation !== this.#generation)
27389
+ throw new CodeBuddyError("invalidState", "ACP client is no longer current");
27390
+ if (this.#replay?.fault)
27391
+ throw this.#replay.fault.error;
27392
+ }
26557
27393
  /** Every fresh process must restore an unanchored rewind before it can accept prompts. */
26558
27394
  async #openClient() {
27395
+ const client2 = this.#client;
27396
+ const generation = this.#generation;
26559
27397
  let rewind;
26560
27398
  if (this.#ref) {
26561
- const history = await this.readHistory(this.input.cwd, this.#ref, this.environment, this.profile);
27399
+ const history = await this.#history(this.#ref);
27400
+ this.#assertClient(generation);
26562
27401
  this.#hasTurn = snapshotFromHistory(history, this.#ref, this.input.cwd, this.profile).turns.length > 0;
26563
27402
  this.#usage = historyUsage(history);
26564
27403
  this.#meterHistory(history, true);
@@ -26566,15 +27405,19 @@ var CodeBuddySession = class {
26566
27405
  } else {
26567
27406
  this.#emit({ type: "usage.history", complete: true });
26568
27407
  }
26569
- await this.#client.initialize();
26570
- const opened = await this.#client.open(this.input.cwd, this.#ref?.nativeSessionId);
27408
+ this.#assertClient(generation);
27409
+ await client2.initialize();
27410
+ this.#assertClient(generation);
27411
+ const opened = await client2.open(this.input.cwd, this.#ref?.nativeSessionId);
27412
+ this.#assertClient(generation);
26571
27413
  const sessionId = this.#ref?.nativeSessionId ?? text(opened.sessionId);
26572
27414
  if (!sessionId || opened.sessionId && opened.sessionId !== sessionId)
26573
27415
  throw new CodeBuddyError("protocolError", "ACP returned a different Native Session identity");
26574
27416
  if (rewind) {
26575
- if (!this.#client.rollback)
27417
+ if (!client2.rollback)
26576
27418
  throw new CodeBuddyError("unsupported", "Native history rewind is unavailable");
26577
- const result = await this.#client.rollback(sessionId, rewind.forkPointId);
27419
+ const result = await client2.rollback(sessionId, rewind.forkPointId);
27420
+ this.#assertClient(generation);
26578
27421
  if (result.applied !== true || (result.actualForkPointId ?? null) !== rewind.forkPointId)
26579
27422
  throw new CodeBuddyError("nativeFailure", "Native history rewind was not confirmed");
26580
27423
  }
@@ -26602,7 +27445,7 @@ var CodeBuddySession = class {
26602
27445
  } else if (this.input.permissionModeId || text(saved.mode))
26603
27446
  await this.#configure("mode", this.input.permissionModeId ?? text(saved.mode));
26604
27447
  if (this.input.model || text(saved.model))
26605
- await this.#configure("model", this.input.model ? nativeModel(this.input.model) : text(saved.model));
27448
+ await this.#configure("model", this.input.model?.id ?? text(saved.model));
26606
27449
  if (this.input.thinkingOptionId || text(saved.thinking))
26607
27450
  await this.#configure("thought_level", this.input.thinkingOptionId ?? text(saved.thinking));
26608
27451
  if (this.#fault || this.#closed)
@@ -26645,7 +27488,7 @@ var CodeBuddySession = class {
26645
27488
  locator: {
26646
27489
  ...record3(this.#ref.locator),
26647
27490
  configuration: {
26648
- model: config2.state.effectiveModel ? nativeModel(config2.state.effectiveModel) : "",
27491
+ model: config2.state.effectiveModel?.id ?? "",
26649
27492
  mode: config2.state.effectivePermissionModeId ?? "",
26650
27493
  thinking: config2.state.effectiveThinkingOptionId ?? ""
26651
27494
  }
@@ -26655,45 +27498,57 @@ var CodeBuddySession = class {
26655
27498
  if (emit)
26656
27499
  this.#emit({ type: "session.state.changed", state: this.#state });
26657
27500
  }
26658
- async #configure(id, value) {
26659
- const option = this.#config?.options.find((option2) => option2.id === id);
26660
- const listed = Array.isArray(option?.options) && option.options.some((option2) => record3(option2).value === value);
26661
- const allowedProductModel = id === "model" && this.profile.allowUnlistedModelSelection;
26662
- if (!listed && !allowedProductModel)
26663
- throw new CodeBuddyError("invalidRequest", `Unavailable ${this.profile.displayName} ${id} selection`);
26664
- if (!this.#ref)
27501
+ #configurationRequest() {
27502
+ const generation = this.#generation;
27503
+ const client2 = this.#client;
27504
+ const sessionId = this.#ref?.nativeSessionId;
27505
+ if (!sessionId)
26665
27506
  throw new CodeBuddyError("invalidState", "Session is not open");
26666
- const result = await this.#client.configure(this.#ref.nativeSessionId, id, value);
26667
- if (this.#closed || this.#fault)
26668
- throw new CodeBuddyError("invalidState", "Session closed during configuration");
26669
- this.#apply(confirmedConfiguration(result, id, value, this.profile));
27507
+ return async (id2, value) => {
27508
+ this.#assertClient(generation);
27509
+ const result = await client2.configure(sessionId, id2, value);
27510
+ this.#assertClient(generation);
27511
+ return result;
27512
+ };
26670
27513
  }
26671
- async #snapshot() {
26672
- if (!this.#ref)
26673
- throw new CodeBuddyError("invalidState", "Session is not open");
27514
+ async #configure(id2, value) {
27515
+ const generation = this.#generation;
27516
+ const confirmed = await selectConfiguration(this.#config, id2, value, this.profile, this.#configurationRequest());
27517
+ this.#assertClient(generation);
27518
+ this.#apply(confirmed);
27519
+ }
27520
+ async #history(ref) {
26674
27521
  try {
26675
- const history = await this.readHistory(this.input.cwd, this.#ref, this.environment, this.profile);
26676
- this.#usage = historyUsage(history);
26677
- this.#meterHistory(history, false);
26678
- return {
26679
- ...this.subagents.project(snapshotFromHistory(history, this.#ref, this.input.cwd, this.profile)),
26680
- state: this.#state
26681
- };
27522
+ return await this.readHistory(this.input.cwd, ref, this.environment, this.profile);
26682
27523
  } catch (error51) {
26683
27524
  if (!this.#hasTurn && this.input.kind === "create" && error51 instanceof CodeBuddyError && error51.code === "sessionNotFound")
26684
- return { turns: [], state: this.#state };
27525
+ return "";
26685
27526
  throw error51;
26686
27527
  }
26687
27528
  }
27529
+ async #snapshot(historyTimeout) {
27530
+ if (!this.#ref)
27531
+ throw new CodeBuddyError("invalidState", "Session is not open");
27532
+ const read = this.#history(this.#ref);
27533
+ const history = historyTimeout ? await bounded(read, historyTimeout, "Native Turn history read") : await read;
27534
+ if (this.#closed || this.#fault)
27535
+ throw new CodeBuddyError("invalidState", "Session closed during history read");
27536
+ const snapshot = snapshotFromHistory(history, this.#ref, this.input.cwd, this.profile);
27537
+ if (snapshot.turns.length)
27538
+ this.#hasTurn = true;
27539
+ this.#usage = historyUsage(history);
27540
+ this.#meterHistory(history, false);
27541
+ return { ...this.subagents.project(snapshot), state: this.#state };
27542
+ }
26688
27543
  /** Read persisted request usage without waiting for the ACP prompt (including tool waits). */
26689
27544
  async refreshUsage() {
26690
- if (this.#refreshingUsage || this.#closed || this.#fault || this.#replaying || !this.#ref)
27545
+ if (this.#refreshingUsage || this.#closed || this.#fault || this.#replay || !this.#ref)
26691
27546
  return;
26692
27547
  this.#refreshingUsage = true;
26693
- const active = this.#active, generation = this.#generation;
27548
+ const active2 = this.#active, generation = this.#generation;
26694
27549
  try {
26695
27550
  const history = await this.readHistory(this.input.cwd, this.#ref, this.environment, this.profile);
26696
- if (this.#closed || this.#fault || this.#active !== active || this.#generation !== generation)
27551
+ if (this.#closed || this.#fault || this.#active !== active2 || this.#generation !== generation)
26697
27552
  return;
26698
27553
  this.#usage = historyUsage(history);
26699
27554
  this.#meterHistory(history, false);
@@ -26705,7 +27560,7 @@ var CodeBuddySession = class {
26705
27560
  }
26706
27561
  #subagentConfiguration() {
26707
27562
  const state = this.#state;
26708
- const model2 = state.effectiveModel ? nativeModel(state.effectiveModel) : void 0;
27563
+ const model2 = state.effectiveModel?.id;
26709
27564
  return {
26710
27565
  ...model2 ? { model: model2 } : {},
26711
27566
  ...state.effectiveThinkingOptionId ? { reasoningEffort: state.effectiveThinkingOptionId } : {}
@@ -26730,19 +27585,16 @@ var CodeBuddySession = class {
26730
27585
  }
26731
27586
  }
26732
27587
  async #executeCommand(command) {
26733
- const parsed = commandPrompt(command, this.#commands, this.profile);
26734
- if (!parsed.ok)
26735
- return parsed;
26736
- const result = await this.#execute({ type: "turn.start", turnId: command.turnId, input: [{ type: "text", text: parsed.value }] }, true);
27588
+ const result = await this.#execute({ ...command, type: "command.execute" });
26737
27589
  return result.ok ? { ok: true, value: { turnId: command.turnId } } : result;
26738
27590
  }
26739
27591
  async execute(command) {
26740
27592
  const invocation = command.type === "turn.start" ? command.input.map((item) => item.text).join("\n").trim().split(/\s/u)[0] : void 0;
26741
27593
  if (nativeCommandsEnabled(this.profile) && isExcludedInvocation(invocation))
26742
27594
  return failure("unsupported", "Command is not available in this Session", this.profile);
26743
- return this.#execute(command, nativeCommandsEnabled(this.profile) && this.#commands.commands.some((entry) => entry.invocation === invocation));
27595
+ return this.#execute(command, invocation);
26744
27596
  }
26745
- async #execute(command, nativeCommand = false) {
27597
+ async #execute(command, invocation) {
26746
27598
  if (this.#closed || this.#fault)
26747
27599
  return failure("invalidState", "Session is closed or faulted", this.profile);
26748
27600
  if (command.type === "turn.steer")
@@ -26750,35 +27602,58 @@ var CodeBuddySession = class {
26750
27602
  if (command.type === "interaction.respond")
26751
27603
  return this.#interactions.respond(command);
26752
27604
  if (command.type === "turn.cancel") {
26753
- const active = this.#active;
26754
- if (!active || active.command.turnId !== command.turnId || !this.#ref)
27605
+ const active2 = this.#active;
27606
+ if (!active2 || active2.command.turnId !== command.turnId || !this.#ref)
26755
27607
  return failure("invalidRequest", "Turn is not active", this.profile);
26756
- if (!active.cancelled) {
26757
- active.cancelled = true;
27608
+ if (!active2.cancelled) {
27609
+ active2.cancelled = true;
27610
+ const generation = this.#generation;
26758
27611
  try {
26759
- await this.#client.cancel(this.#ref.nativeSessionId);
27612
+ const requested = this.#client.cancel(this.#ref.nativeSessionId);
27613
+ this.#interactions.close();
27614
+ await requested;
26760
27615
  } catch (error51) {
26761
- this.#onFault(error51);
26762
- return { ok: false, error: nativeError(error51, this.profile) };
27616
+ if (generation === this.#generation) {
27617
+ if (this.#active === active2)
27618
+ this.#onFault(error51);
27619
+ return { ok: false, error: nativeError(error51, this.profile) };
27620
+ }
27621
+ }
27622
+ if (this.#active === active2 && !this.#closed) {
27623
+ void bounded(active2.completion, 3e4, "ACP cancel acknowledgement").catch((error51) => {
27624
+ if (this.#active === active2 && !this.#needsResume)
27625
+ this.#onFault(error51);
27626
+ });
26763
27627
  }
26764
- this.#interactions.close();
26765
- void bounded(active.completion, 3e4, "ACP cancel acknowledgement").catch((error51) => this.#onFault(error51));
26766
27628
  }
26767
27629
  return { ok: true, value: { cancellationRequested: true } };
26768
27630
  }
26769
- if (this.#busy || this.#active && command.type !== "model.select" && command.type !== "thinking.select")
27631
+ if (this.#busy || this.#active && (this.#active.cancelled || command.type !== "model.select" && command.type !== "thinking.select"))
26770
27632
  return failure("sessionBusy", "Session is executing an operation", this.profile);
26771
27633
  this.#busy = true;
26772
27634
  try {
26773
- if (command.type === "turn.start") {
26774
- if (!command.turnId.trim() || !command.input.length || command.input.some((item) => item.type !== "text") || !command.input.map((item) => item.text).join("").trim())
27635
+ if (command.type === "turn.start" || command.type === "command.execute") {
27636
+ if (!command.turnId.trim() || command.type === "turn.start" && (!command.input.length || command.input.some((item) => item.type !== "text") || !command.input.map((item) => item.text).join("").trim()))
26775
27637
  return failure("invalidRequest", "A nonempty text prompt is required", this.profile);
27638
+ if (this.#needsResume)
27639
+ await this.#resumeClient();
27640
+ const nativeCommand = command.type === "command.execute" || nativeCommandsEnabled(this.profile) && this.#commands.commands.some((entry) => entry.invocation === invocation);
27641
+ if (command.type === "command.execute") {
27642
+ const parsed = commandPrompt(command, this.#commands, this.profile);
27643
+ if (!parsed.ok)
27644
+ return parsed;
27645
+ command = {
27646
+ type: "turn.start",
27647
+ turnId: command.turnId,
27648
+ input: [{ type: "text", text: parsed.value }]
27649
+ };
27650
+ }
26776
27651
  const snapshot = await this.#snapshot();
26777
27652
  const before = new Set(snapshot.turns.map((turn) => turn.nativeTurnRef.nativeTurnKey));
26778
27653
  const beforeItems = new Set(snapshot.turns.flatMap((turn) => turn.items.map((snapshot2) => snapshot2.item.itemId)));
26779
27654
  if (this.#closed || this.#fault)
26780
27655
  return failure("invalidState", "Session closed before Turn start", this.profile);
26781
- const active = {
27656
+ const active2 = {
26782
27657
  command,
26783
27658
  before,
26784
27659
  beforeItems,
@@ -26788,15 +27663,15 @@ var CodeBuddySession = class {
26788
27663
  done: false,
26789
27664
  completion: Promise.resolve()
26790
27665
  };
26791
- this.#active = active;
27666
+ this.#active = active2;
26792
27667
  this.subagents.begin(command.turnId);
26793
- if (!nativeCommand)
26794
- this.#hasTurn = true;
26795
27668
  this.#emit({ type: "turn.started", turnId: command.turnId });
26796
- active.completion = this.#run(active);
27669
+ active2.completion = this.#run(active2);
26797
27670
  return { ok: true, value: { turnId: command.turnId } };
26798
27671
  }
26799
- await this.#configure(command.type === "model.select" ? "model" : command.type === "thinking.select" ? "thought_level" : "mode", command.type === "model.select" ? nativeModel(command.model) : command.type === "thinking.select" ? command.thinkingOptionId : command.permissionModeId);
27672
+ if (this.#needsResume)
27673
+ await this.#resumeClient();
27674
+ await this.#configure(command.type === "model.select" ? "model" : command.type === "thinking.select" ? "thought_level" : "mode", command.type === "model.select" ? command.model.id : command.type === "thinking.select" ? command.thinkingOptionId : command.permissionModeId);
26800
27675
  return { ok: true, value: { completed: true } };
26801
27676
  } catch (error51) {
26802
27677
  return { ok: false, error: nativeError(error51, this.profile) };
@@ -26804,12 +27679,13 @@ var CodeBuddySession = class {
26804
27679
  this.#busy = false;
26805
27680
  }
26806
27681
  }
26807
- async #run(active) {
27682
+ async #run(active2) {
27683
+ let cancellationConfirmed = false;
26808
27684
  try {
26809
27685
  if (!this.#ref)
26810
27686
  throw new CodeBuddyError("invalidState", "Session is not open");
26811
- const response = await this.#client.prompt(this.#ref.nativeSessionId, active.command.input.map((item) => item.text).join("\n"));
26812
- if (active.done)
27687
+ const response = await this.#client.prompt(this.#ref.nativeSessionId, active2.command.input.map((item) => item.text).join("\n"));
27688
+ if (active2.done || this.#closed)
26813
27689
  return;
26814
27690
  const stop = response.stopReason, meta3 = record3(response._meta);
26815
27691
  const outcome = stop === "cancelled" || meta3["codebuddy.ai/outcome"] === "CANCELLED" ? { status: "cancelled" } : stop === "end_turn" && // Native PARTIAL_SUCCESS means a final answer with recorded model/tool errors.
@@ -26818,77 +27694,90 @@ var CodeBuddySession = class {
26818
27694
  status: "failed",
26819
27695
  error: nativeTurnError(stop, meta3, this.profile)
26820
27696
  };
26821
- const snapshot = await this.#snapshot();
26822
- const added = snapshot.turns.filter((turn) => !active.before.has(turn.nativeTurnRef.nativeTurnKey));
26823
- if (added.length > 1 || !active.nativeCommand && outcome.status === "succeeded" && added.length !== 1)
27697
+ if (outcome.status === "cancelled") {
27698
+ active2.cancelled = true;
27699
+ ++this.#generation;
27700
+ this.#interactions.close();
27701
+ try {
27702
+ await this.#client.close();
27703
+ } catch (error51) {
27704
+ this.#onFault(error51);
27705
+ return;
27706
+ }
27707
+ if (active2.done || this.#closed)
27708
+ return;
27709
+ this.#needsResume = true;
27710
+ cancellationConfirmed = true;
27711
+ }
27712
+ const snapshot = await this.#snapshot(cancellationConfirmed ? 1e3 : void 0);
27713
+ if (active2.done || this.#closed)
27714
+ return;
27715
+ const added = snapshot.turns.filter((turn) => !active2.before.has(turn.nativeTurnRef.nativeTurnKey));
27716
+ if (added.length > 1 || !active2.nativeCommand && outcome.status === "succeeded" && added.length !== 1)
26824
27717
  throw new CodeBuddyError("protocolError", "Could not identify exactly one persisted Native Turn");
26825
- active.output.confirmCompaction(snapshot.turns.flatMap((turn) => turn.items).filter((snapshot2) => !active.beforeItems.has(snapshot2.item.itemId)));
26826
- if (active.nativeCommand)
26827
- active.output.replayCommandResult((added[0]?.items ?? []).filter(({ item }) => !this.subagents.hasItem(item.itemId)));
26828
27718
  const nativeTurnRef = added[0]?.nativeTurnRef;
26829
- if (nativeTurnRef)
26830
- this.#hasTurn = true;
26831
27719
  if (response.userMessageId && nativeTurnRef?.nativeTurnKey !== response.userMessageId)
26832
27720
  throw new CodeBuddyError("protocolError", "ACP terminal and native history disagree on Turn identity");
26833
- if (outcome.status === "cancelled")
26834
- await this.#resumeAfterCancel();
26835
- const compactCommand = active.nativeCommand && /^\/compact(?:\s|$)/u.test(active.command.input.map((item) => item.text).join("\n").trim());
27721
+ active2.output.confirmCompaction(snapshot.turns.flatMap((turn) => turn.items).filter((snapshot2) => !active2.beforeItems.has(snapshot2.item.itemId)));
27722
+ if (active2.nativeCommand)
27723
+ active2.output.replayCommandResult((added[0]?.items ?? []).filter(({ item }) => !this.subagents.hasItem(item.itemId)));
27724
+ const compactCommand = outcome.status !== "cancelled" && active2.nativeCommand && /^\/compact(?:\s|$)/u.test(active2.command.input.map((item) => item.text).join("\n").trim());
26836
27725
  const persisted = compactCommand ? added[0]?.outcome : void 0;
26837
27726
  if (compactCommand && (!persisted || persisted.status === "unknown"))
26838
27727
  throw new CodeBuddyError("protocolError", "Native compaction terminal outcome was not persisted");
26839
27728
  const terminalOutcome = persisted && persisted.status !== "unknown" ? persisted : outcome;
26840
- this.#finish(active, {
27729
+ this.#finish(active2, {
26841
27730
  ...terminalOutcome,
26842
27731
  ...added[0]?.checkpoint ? { checkpoint: added[0].checkpoint } : {}
26843
27732
  }, nativeTurnRef);
26844
27733
  if (this.#usage)
26845
27734
  this.#emitUsage();
26846
27735
  } catch (error51) {
26847
- if (!active.done)
26848
- this.#finish(active, { status: "failed", error: nativeError(error51, this.profile) });
27736
+ if (!active2.done && !this.#closed)
27737
+ this.#finish(active2, cancellationConfirmed ? { status: "cancelled" } : { status: "failed", error: nativeError(error51, this.profile) });
26849
27738
  }
26850
27739
  }
26851
- async #resumeAfterCancel() {
26852
- if (!this.#ref)
26853
- throw new CodeBuddyError("invalidState", "Missing Native Session after cancellation");
26854
- const saved = this.#state;
26855
- this.#interactions.close();
26856
- this.#replaying = true;
26857
- ++this.#generation;
27740
+ /** Runs only under the native operation gate, after the old process has exited. */
27741
+ async #resumeClient() {
27742
+ const replay = {};
27743
+ this.#replay = replay;
27744
+ let candidate;
26858
27745
  try {
26859
- await this.#client.close();
26860
- if (this.#closed)
26861
- return;
26862
- this.#client = this.#createClient();
27746
+ this.#client = candidate = this.#createClient();
27747
+ const generation = this.#generation;
26863
27748
  const loaded = await this.#openClient();
26864
- this.#apply(configuration(loaded.configOptions, this.profile));
26865
- if (saved.effectiveModel)
26866
- await this.#configure("model", nativeModel(saved.effectiveModel));
26867
- if (saved.effectiveThinkingOptionId)
26868
- await this.#configure("thought_level", saved.effectiveThinkingOptionId);
26869
- if (saved.effectivePermissionModeId)
26870
- await this.#configure("mode", saved.effectivePermissionModeId);
27749
+ const restored = await restoreConfiguration(configuration(loaded.configOptions, this.profile), this.#state, this.profile, this.#configurationRequest());
27750
+ this.#assertClient(generation);
27751
+ this.#apply(restored);
27752
+ if (!this.profile.staticCommandCatalog)
27753
+ this.#commands = replay.commands ?? { commands: [] };
27754
+ this.#needsResume = false;
26871
27755
  } catch (error51) {
26872
- this.#onFault(error51);
27756
+ ++this.#generation;
27757
+ try {
27758
+ await candidate?.close();
27759
+ } catch (closeError) {
27760
+ this.#onFault(closeError);
27761
+ }
26873
27762
  throw error51;
26874
27763
  } finally {
26875
- this.#replaying = false;
27764
+ this.#replay = void 0;
26876
27765
  }
26877
27766
  }
26878
- #finish(active, outcome, nativeTurnRef) {
26879
- if (active.done)
27767
+ #finish(active2, outcome, nativeTurnRef) {
27768
+ if (active2.done)
26880
27769
  return;
26881
- active.done = true;
27770
+ active2.done = true;
26882
27771
  this.subagents.finish(outcome);
26883
27772
  this.#interactions.close();
26884
- active.output.finish(outcome.status, outcome.status === "failed" ? outcome.error : void 0);
27773
+ active2.output.finish(outcome.status, outcome.status === "failed" ? outcome.error : void 0);
26885
27774
  this.#emit({
26886
27775
  type: "turn.completed",
26887
- turnId: active.command.turnId,
27776
+ turnId: active2.command.turnId,
26888
27777
  outcome,
26889
27778
  ...nativeTurnRef ? { nativeTurnRef } : {}
26890
27779
  });
26891
- if (this.#active === active)
27780
+ if (this.#active === active2)
26892
27781
  this.#active = void 0;
26893
27782
  }
26894
27783
  #onFault(error51) {
@@ -26909,13 +27798,17 @@ var CodeBuddySession = class {
26909
27798
  }
26910
27799
  async #close() {
26911
27800
  this.#closed = true;
26912
- this.subagents.close();
26913
- if (this.#active)
26914
- this.#finish(this.#active, { status: "cancelled", reason: "Session closed" });
26915
27801
  this.#interactions.close();
26916
27802
  try {
26917
27803
  await this.#client.close();
27804
+ if (this.#active)
27805
+ this.#finish(this.#active, { status: "cancelled", reason: "Session closed" });
27806
+ } catch (error51) {
27807
+ if (this.#active)
27808
+ this.#finish(this.#active, { status: "failed", error: nativeError(error51, this.profile) });
27809
+ throw error51;
26918
27810
  } finally {
27811
+ this.subagents.close();
26919
27812
  this.#channel.end();
26920
27813
  this.onClose();
26921
27814
  }
@@ -26925,6 +27818,7 @@ var CodeBuddySession = class {
26925
27818
  // ../codebuddy/dist/codebuddy-adapter.js
26926
27819
  var CodeBuddyAdapter = class {
26927
27820
  options;
27821
+ normalizeStoredModelRef = normalizeStoredCodeBuddyModelRef;
26928
27822
  harnessId;
26929
27823
  commandCatalog;
26930
27824
  liveCommandCatalog = true;
@@ -26971,7 +27865,7 @@ var CodeBuddyAdapter = class {
26971
27865
  inspect(input = {}) {
26972
27866
  const cwd = input.cwd ?? process.cwd();
26973
27867
  if (input.refresh)
26974
- this.#cache.delete(cwd);
27868
+ this.#cache.clear();
26975
27869
  let inspection = this.#cache.get(cwd);
26976
27870
  if (!inspection) {
26977
27871
  inspection = this.#inspect(cwd);
@@ -27141,8 +28035,9 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
27141
28035
  return;
27142
28036
  }
27143
28037
  const policy = env.WORKBUDDY_AT_REST_ENCRYPTION?.trim();
27144
- // Other explicit policies remain owned by the native CLI.
27145
- if (policy && policy !== "fields") return;
28038
+ // "disabled" stays owned by the native CLI; "required" is the legacy name
28039
+ // for the same field-encryption bootstrap.
28040
+ if (policy && policy !== "fields" && policy !== "required") return;
27146
28041
 
27147
28042
  let provider;
27148
28043
  try {
@@ -27168,6 +28063,33 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
27168
28063
  const key = crypto.createHash("sha256").update(secret, "utf8").digest();
27169
28064
  secret = undefined;
27170
28065
  payload = undefined;
28066
+ // The bundled CLI changed its credential-bootstrap wire format: before 2.156
28067
+ // it reads bootstrap.mode and answers with a space-terminated {ok,mode}; from
28068
+ // 2.156 it reads bootstrap.policy and answers with a newline-terminated
28069
+ // {ok,policy}. The receiver accepts one connection only, so choose the format
28070
+ // before connecting instead of retrying.
28071
+ let legacyBootstrap = false;
28072
+ const cliEntry = process.argv[1];
28073
+ if (cliEntry) {
28074
+ try {
28075
+ const metadata = JSON.parse(
28076
+ fs.readFileSync(path.resolve(path.dirname(cliEntry), "..", "package.json"), "utf8"),
28077
+ );
28078
+ const version = String(
28079
+ metadata.publishConfig?.customPackage?.version || metadata.version || "",
28080
+ );
28081
+ const [major, minor] = version.split("-")[0].split(".").map(Number);
28082
+ // 0.x is the placeholder version in development packages; keep the
28083
+ // format this adapter shipped with.
28084
+ if (Number.isInteger(major) && Number.isInteger(minor) && major > 0) {
28085
+ legacyBootstrap = major < 2 || (major === 2 && minor < 156);
28086
+ }
28087
+ } catch {
28088
+ // Unreadable package metadata keeps the newer format.
28089
+ }
28090
+ }
28091
+ const protectionMode = legacyBootstrap ? "required" : "fields";
28092
+ const bootstrapField = legacyBootstrap ? "mode" : "policy";
27171
28093
  const token = crypto.randomBytes(24).toString("hex");
27172
28094
  const sessionId = crypto.randomUUID();
27173
28095
  let directory;
@@ -27235,17 +28157,21 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
27235
28157
  }
27236
28158
  process.once("exit", cleanup);
27237
28159
  Object.assign(env, {
27238
- WORKBUDDY_AT_REST_ENCRYPTION: "fields",
28160
+ WORKBUDDY_AT_REST_ENCRYPTION: protectionMode,
27239
28161
  CODEBUDDY_SIDECAR_CREDENTIAL_BOOTSTRAP_SOCKET: socketPath,
27240
28162
  CODEBUDDY_SIDECAR_READY_SOCKET: socketPath + "-ready",
27241
28163
  CODEBUDDY_SIDECAR_READY_TOKEN: token,
27242
28164
  CODEBUDDY_SIDECAR_READY_SESSION_ID: sessionId,
27243
28165
  });
27244
- let message = JSON.stringify({version:1,sessionId,token,pid:process.pid,bootstrap:{
27245
- version:1,policy:"fields",
28166
+ const bootstrapPayload = {
28167
+ version:1,
27246
28168
  symmetricKey:{keyId:crypto.createHash("sha256").update(key).digest("hex").slice(0,16),keyBase64:key.toString("base64")},
27247
28169
  asymmetricUnavailable:"missing-key",
27248
- }}) + "\n";
28170
+ };
28171
+ // Legacy receivers reject the newer key name and vice versa; exactly one may
28172
+ // be present.
28173
+ bootstrapPayload[bootstrapField] = protectionMode;
28174
+ let message = JSON.stringify({version:1,sessionId,token,pid:process.pid,bootstrap:bootstrapPayload}) + "\n";
27249
28175
  key.fill(0);
27250
28176
  let done = false;
27251
28177
  let socket;
@@ -27268,16 +28194,31 @@ var WORKBUDDY_CREDENTIAL_PRELOAD = String.raw`
27268
28194
  socket = net.createConnection(socketPath);
27269
28195
  let reply = "";
27270
28196
  socket.once("connect", () => socket.end(message, () => { message = ""; }));
28197
+ // Newer CLIs answer with a newline-terminated {ok,policy} frame; legacy
28198
+ // ones answer with a space-terminated {ok,mode} and close immediately.
28199
+ const acceptReply = raw => {
28200
+ const text = String(raw || "").trim();
28201
+ if (!text) return false;
28202
+ try {
28203
+ const result = JSON.parse(text);
28204
+ // The legacy receiver was only validated to acknowledge with ok:true;
28205
+ // the newer one echoes the policy it applied.
28206
+ if (result && result.ok === true && (legacyBootstrap || result.policy === protectionMode)) {
28207
+ finish(true);
28208
+ return true;
28209
+ }
28210
+ } catch {}
28211
+ return false;
28212
+ };
27271
28213
  socket.on("data", chunk => {
27272
28214
  reply += chunk;
27273
28215
  if (reply.length > 1024) return finish(false);
27274
28216
  if (!reply.includes("\n")) return;
27275
- try {
27276
- const result = JSON.parse(reply.slice(0, reply.indexOf("\n")));
27277
- finish(result.ok === true && result.policy === "fields");
27278
- } catch { finish(false); }
28217
+ if (!acceptReply(reply.slice(0, reply.indexOf("\n")))) finish(false);
28218
+ });
28219
+ socket.once("end", () => {
28220
+ if (!done && (!legacyBootstrap || !acceptReply(reply))) finish(false);
27279
28221
  });
27280
- socket.once("end", () => { if (!done) finish(false); });
27281
28222
  socket.once("error", error => {
27282
28223
  socket.destroy();
27283
28224
  if (error.code === "ENOENT" || error.code === "ECONNREFUSED") setTimeout(connect, 20);
@@ -27531,26 +28472,26 @@ function parseWorkBuddyProductModels(value) {
27531
28472
  const cli = agents.map(record5).find((agent) => nonBlank(agent.name) === "cli");
27532
28473
  if (!Array.isArray(cli?.models))
27533
28474
  return [];
27534
- const configuredIds = new Set(cli.models.map(nonBlank).filter((id) => !!id));
28475
+ const configuredIds = new Set(cli.models);
27535
28476
  const parsed = [];
27536
28477
  const ids = /* @__PURE__ */ new Set();
27537
28478
  for (const value2 of models) {
27538
28479
  const source = record5(value2);
27539
- const id = nonBlank(source.id);
28480
+ const id2 = source.id;
27540
28481
  const name = nonBlank(source.name);
27541
- if (!id || !name || !configuredIds.has(id) || ids.has(id))
28482
+ if (typeof id2 !== "string" || !name || !configuredIds.has(id2) || ids.has(id2))
27542
28483
  continue;
27543
28484
  try {
27544
- modelRef(id);
28485
+ modelRef(id2);
27545
28486
  } catch {
27546
28487
  continue;
27547
28488
  }
27548
- ids.add(id);
28489
+ ids.add(id2);
27549
28490
  if (name.length > HARNESS_MODEL_LABEL_MAX_LENGTH)
27550
28491
  continue;
27551
28492
  const credits = nonBlank(source.credits);
27552
28493
  parsed.push({
27553
- id,
28494
+ id: id2,
27554
28495
  name,
27555
28496
  ...credits && credits.length <= 64 ? { credits } : {}
27556
28497
  });