@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
@@ -32,10 +32,10 @@ function executableExtensions(command, platform, environment) {
32
32
  return [""];
33
33
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
34
34
  }
35
- function isExecutableFile(filePath, platform) {
35
+ function isExecutableFile(filePath2, platform) {
36
36
  try {
37
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
- return fs.statSync(filePath).isFile();
37
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
38
+ return fs.statSync(filePath2).isFile();
39
39
  } catch {
40
40
  return false;
41
41
  }
@@ -1745,8 +1745,8 @@ function cleanEnum(obj) {
1745
1745
  return Number.isNaN(Number.parseInt(k, 10));
1746
1746
  }).map((el) => el[1]);
1747
1747
  }
1748
- function base64ToUint8Array(base643) {
1749
- const binaryString = atob(base643);
1748
+ function base64ToUint8Array(base644) {
1749
+ const binaryString = atob(base644);
1750
1750
  const bytes = new Uint8Array(binaryString.length);
1751
1751
  for (let i = 0; i < binaryString.length; i++) {
1752
1752
  bytes[i] = binaryString.charCodeAt(i);
@@ -1761,9 +1761,9 @@ function uint8ArrayToBase64(bytes) {
1761
1761
  return btoa(binaryString);
1762
1762
  }
1763
1763
  function base64urlToUint8Array(base64url3) {
1764
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1765
- const padding = "=".repeat((4 - base643.length % 4) % 4);
1766
- return base64ToUint8Array(base643 + padding);
1764
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
1765
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
1766
+ return base64ToUint8Array(base644 + padding);
1767
1767
  }
1768
1768
  function uint8ArrayToBase64url(bytes) {
1769
1769
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -3129,8 +3129,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
3129
3129
  function isValidBase64URL(data) {
3130
3130
  if (!base64url.test(data))
3131
3131
  return false;
3132
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3133
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
3132
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
3133
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
3134
3134
  return isValidBase64(padded);
3135
3135
  }
3136
3136
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -3584,42 +3584,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3584
3584
  }
3585
3585
  doc.write(`const newResult = {};`);
3586
3586
  for (const key of normalized.keys) {
3587
- const id = ids[key];
3587
+ const id2 = ids[key];
3588
3588
  const k = esc(key);
3589
3589
  const schema = shape[key];
3590
3590
  const isOptionalIn = schema?._zod?.optin === "optional";
3591
3591
  const isOptionalOut = schema?._zod?.optout === "optional";
3592
- doc.write(`const ${id} = ${parseStr(key)};`);
3592
+ doc.write(`const ${id2} = ${parseStr(key)};`);
3593
3593
  if (isOptionalIn && isOptionalOut) {
3594
3594
  doc.write(`
3595
- if (${id}.issues.length) {
3595
+ if (${id2}.issues.length) {
3596
3596
  if (${k} in input) {
3597
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3597
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3598
3598
  ...iss,
3599
3599
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3600
3600
  })));
3601
3601
  }
3602
3602
  }
3603
3603
 
3604
- if (${id}.value === undefined) {
3604
+ if (${id2}.value === undefined) {
3605
3605
  if (${k} in input) {
3606
3606
  newResult[${k}] = undefined;
3607
3607
  }
3608
3608
  } else {
3609
- newResult[${k}] = ${id}.value;
3609
+ newResult[${k}] = ${id2}.value;
3610
3610
  }
3611
3611
 
3612
3612
  `);
3613
3613
  } else if (!isOptionalIn) {
3614
3614
  doc.write(`
3615
- const ${id}_present = ${k} in input;
3616
- if (${id}.issues.length) {
3617
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3615
+ const ${id2}_present = ${k} in input;
3616
+ if (${id2}.issues.length) {
3617
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3618
3618
  ...iss,
3619
3619
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3620
3620
  })));
3621
3621
  }
3622
- if (!${id}_present && !${id}.issues.length) {
3622
+ if (!${id2}_present && !${id2}.issues.length) {
3623
3623
  payload.issues.push({
3624
3624
  code: "invalid_type",
3625
3625
  expected: "nonoptional",
@@ -3628,30 +3628,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
3628
3628
  });
3629
3629
  }
3630
3630
 
3631
- if (${id}_present) {
3632
- if (${id}.value === undefined) {
3631
+ if (${id2}_present) {
3632
+ if (${id2}.value === undefined) {
3633
3633
  newResult[${k}] = undefined;
3634
3634
  } else {
3635
- newResult[${k}] = ${id}.value;
3635
+ newResult[${k}] = ${id2}.value;
3636
3636
  }
3637
3637
  }
3638
3638
 
3639
3639
  `);
3640
3640
  } else {
3641
3641
  doc.write(`
3642
- if (${id}.issues.length) {
3643
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
3642
+ if (${id2}.issues.length) {
3643
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
3644
3644
  ...iss,
3645
3645
  path: iss.path ? [${k}, ...iss.path] : [${k}]
3646
3646
  })));
3647
3647
  }
3648
3648
 
3649
- if (${id}.value === undefined) {
3649
+ if (${id2}.value === undefined) {
3650
3650
  if (${k} in input) {
3651
3651
  newResult[${k}] = undefined;
3652
3652
  }
3653
3653
  } else {
3654
- newResult[${k}] = ${id}.value;
3654
+ newResult[${k}] = ${id2}.value;
3655
3655
  }
3656
3656
 
3657
3657
  `);
@@ -11983,26 +11983,26 @@ function extractDefs(ctx, schema) {
11983
11983
  throw new Error("Unprocessed schema. This is a bug in Zod.");
11984
11984
  const idToSchema = /* @__PURE__ */ new Map();
11985
11985
  for (const entry of ctx.seen.entries()) {
11986
- const id = ctx.metadataRegistry.get(entry[0])?.id;
11987
- if (id) {
11988
- const existing = idToSchema.get(id);
11986
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
11987
+ if (id2) {
11988
+ const existing = idToSchema.get(id2);
11989
11989
  if (existing && existing !== entry[0]) {
11990
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11990
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
11991
11991
  }
11992
- idToSchema.set(id, entry[0]);
11992
+ idToSchema.set(id2, entry[0]);
11993
11993
  }
11994
11994
  }
11995
11995
  const makeURI = (entry) => {
11996
11996
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
11997
11997
  if (ctx.external) {
11998
11998
  const externalId = ctx.external.registry.get(entry[0])?.id;
11999
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
11999
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
12000
12000
  if (externalId) {
12001
12001
  return { ref: uriGenerator(externalId) };
12002
12002
  }
12003
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
12004
- entry[1].defId = id;
12005
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
12003
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
12004
+ entry[1].defId = id2;
12005
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
12006
12006
  }
12007
12007
  if (entry[1] === root) {
12008
12008
  return { ref: "#" };
@@ -12050,8 +12050,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
12050
12050
  continue;
12051
12051
  }
12052
12052
  }
12053
- const id = ctx.metadataRegistry.get(entry[0])?.id;
12054
- if (id) {
12053
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
12054
+ if (id2) {
12055
12055
  extractToDef(entry);
12056
12056
  continue;
12057
12057
  }
@@ -12147,10 +12147,10 @@ function finalize(ctx, schema) {
12147
12147
  } else {
12148
12148
  }
12149
12149
  if (ctx.external?.uri) {
12150
- const id = ctx.external.registry.get(schema)?.id;
12151
- if (!id)
12150
+ const id2 = ctx.external.registry.get(schema)?.id;
12151
+ if (!id2)
12152
12152
  throw new Error("Schema is missing an `id` property");
12153
- result.$id = ctx.external.uri(id);
12153
+ result.$id = ctx.external.uri(id2);
12154
12154
  }
12155
12155
  Object.assign(result, root.def ?? root.schema);
12156
12156
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -12310,9 +12310,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12310
12310
  json2.type = "number";
12311
12311
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
12312
12312
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
12313
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12313
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
12314
12314
  if (exMin) {
12315
- if (legacy) {
12315
+ if (legacy2) {
12316
12316
  json2.minimum = exclusiveMinimum;
12317
12317
  json2.exclusiveMinimum = true;
12318
12318
  } else {
@@ -12322,7 +12322,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
12322
12322
  json2.minimum = minimum;
12323
12323
  }
12324
12324
  if (exMax) {
12325
- if (legacy) {
12325
+ if (legacy2) {
12326
12326
  json2.maximum = exclusiveMaximum;
12327
12327
  json2.exclusiveMaximum = true;
12328
12328
  } else {
@@ -13184,7 +13184,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
13184
13184
 
13185
13185
  // ../../../node_modules/zod/v4/classic/schemas.js
13186
13186
  var _installedGroups = /* @__PURE__ */ new WeakMap();
13187
- function _installLazyMethods(inst, group, methods2) {
13187
+ function _installLazyMethods(inst, group, methods3) {
13188
13188
  const proto = Object.getPrototypeOf(inst);
13189
13189
  let installed = _installedGroups.get(proto);
13190
13190
  if (!installed) {
@@ -13194,8 +13194,8 @@ function _installLazyMethods(inst, group, methods2) {
13194
13194
  if (installed.has(group))
13195
13195
  return;
13196
13196
  installed.add(group);
13197
- for (const key in methods2) {
13198
- const fn = methods2[key];
13197
+ for (const key in methods3) {
13198
+ const fn = methods3[key];
13199
13199
  Object.defineProperty(proto, key, {
13200
13200
  configurable: true,
13201
13201
  enumerable: false,
@@ -15139,6 +15139,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
15139
15139
  permissionModeId: harnessPermissionModeIdSchema
15140
15140
  }).strict();
15141
15141
 
15142
+ // ../../shared-contracts/dist/harness-route-limit.js
15143
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
15144
+
15142
15145
  // ../../shared-contracts/dist/thread-usage.js
15143
15146
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
15144
15147
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -15171,7 +15174,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
15171
15174
  expiresAtUnix: nonNegativeSafeIntegerSchema,
15172
15175
  label: indicatorTextSchema(256).optional(),
15173
15176
  tooltip: indicatorTextSchema(1024).optional()
15174
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
15177
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
15175
15178
  message: "Composer indicator IDs must be unique"
15176
15179
  });
15177
15180
  var threadUsageSnapshotSchema = external_exports.object({
@@ -15197,6 +15200,7 @@ var threadUsageSnapshotSchema = external_exports.object({
15197
15200
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
15198
15201
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
15199
15202
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15203
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
15200
15204
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
15201
15205
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
15202
15206
  }).strict().superRefine((usage, context) => {
@@ -15294,6 +15298,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
15294
15298
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
15295
15299
  resetCredits: accountResetCreditsSchema.optional()
15296
15300
  }).strict();
15301
+ var accountBalanceSnapshotSchema = external_exports.object({
15302
+ amount: external_exports.number().finite().nonnegative(),
15303
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
15304
+ currency: external_exports.string().trim().min(1).max(8),
15305
+ /** Native label when the Harness exposes several Billing Sources. */
15306
+ label: external_exports.string().trim().min(1).max(128).optional()
15307
+ }).strict();
15297
15308
  var threadUsageInspectionParamsSchema = external_exports.object({
15298
15309
  threadId: hostThreadIdSchema,
15299
15310
  refresh: external_exports.literal("exact").optional()
@@ -15302,7 +15313,10 @@ var threadUsageInspectionSchema = external_exports.object({
15302
15313
  threadId: hostThreadIdSchema,
15303
15314
  usage: threadUsageSnapshotSchema.nullable(),
15304
15315
  accountCredits: accountCreditsSnapshotSchema.optional(),
15305
- /** Whether this source can provide cached account quota independently of usage. */
15316
+ /** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
15317
+ accountBalance: accountBalanceSnapshotSchema.optional(),
15318
+ /** Whether this source can provide cached account quota (credits or a prepaid balance)
15319
+ * independently of usage. */
15306
15320
  accountCreditsSupported: external_exports.boolean().optional()
15307
15321
  }).strict();
15308
15322
 
@@ -15314,10 +15328,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
15314
15328
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
15315
15329
  message: "Value must not be empty or whitespace"
15316
15330
  });
15317
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
15331
+ var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
15332
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
15318
15333
  var harnessModelRefSchema = external_exports.object({
15319
- id: harnessModelRefIdSchema
15334
+ id: harnessModelRefIdSchema,
15335
+ serviceTier: harnessModelServiceTierSchema.optional()
15320
15336
  }).strict();
15337
+ function sameHarnessModelRef(left, right) {
15338
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
15339
+ }
15321
15340
  var harnessThinkingOptionIdSchema = nonBlankTextSchema2.max(HARNESS_THINKING_OPTION_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Thinking option ID must use transport-safe characters").brand();
15322
15341
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
15323
15342
  var harnessThinkingOptionSchema = external_exports.object({
@@ -15331,7 +15350,15 @@ var harnessModelSchema = external_exports.object({
15331
15350
  /** Optional opaque selection for this same Model with priority processing enabled. */
15332
15351
  fastModel: harnessModelRefSchema.optional(),
15333
15352
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
15334
- }).strict();
15353
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
15354
+ path: ["fastModel", "id"],
15355
+ message: "A tiered Fast Model must share the base Model ID"
15356
+ });
15357
+ function catalogModelForRef(catalog, ref) {
15358
+ if (!ref)
15359
+ return void 0;
15360
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
15361
+ }
15335
15362
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
15336
15363
  const ids = /* @__PURE__ */ new Set();
15337
15364
  for (const [index, option] of options.entries()) {
@@ -15351,26 +15378,26 @@ var harnessModelCatalogSchema = external_exports.object({
15351
15378
  thinkingOptions: harnessThinkingOptionsSchema,
15352
15379
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
15353
15380
  }).strict().superRefine((catalog, context) => {
15354
- const refs = /* @__PURE__ */ new Set();
15355
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
15381
+ const refs = [];
15382
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
15356
15383
  for (const [index, model2] of catalog.models.entries()) {
15357
- if (refs.has(model2.ref.id)) {
15384
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
15358
15385
  context.addIssue({
15359
15386
  code: "custom",
15360
15387
  message: "Model Catalog refs must be unique",
15361
15388
  path: ["models", index, "ref", "id"]
15362
15389
  });
15363
15390
  }
15364
- refs.add(model2.ref.id);
15391
+ refs.push(model2.ref);
15365
15392
  if (model2.fastModel) {
15366
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
15393
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
15367
15394
  context.addIssue({
15368
15395
  code: "custom",
15369
15396
  message: "Fast Model refs must be distinct and unique",
15370
15397
  path: ["models", index, "fastModel"]
15371
15398
  });
15372
15399
  }
15373
- refs.add(model2.fastModel.id);
15400
+ refs.push(model2.fastModel);
15374
15401
  }
15375
15402
  const supportedThinkingIds = /* @__PURE__ */ new Set();
15376
15403
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -15391,7 +15418,7 @@ var harnessModelCatalogSchema = external_exports.object({
15391
15418
  }
15392
15419
  }
15393
15420
  }
15394
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
15421
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
15395
15422
  context.addIssue({
15396
15423
  code: "custom",
15397
15424
  message: "Default Model must exist in the Model Catalog",
@@ -15431,7 +15458,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
15431
15458
  observe: external_exports.boolean()
15432
15459
  }).strict().optional(),
15433
15460
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
15434
- steer: external_exports.boolean().optional()
15461
+ steer: external_exports.boolean().optional(),
15462
+ /**
15463
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
15464
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
15465
+ */
15466
+ persistentPlan: external_exports.boolean().optional()
15435
15467
  }).strict();
15436
15468
  var harnessConfigurationStateSchema = external_exports.object({
15437
15469
  effectiveModel: harnessModelRefSchema.optional(),
@@ -15440,7 +15472,7 @@ var harnessConfigurationStateSchema = external_exports.object({
15440
15472
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
15441
15473
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
15442
15474
  }).strict().superRefine((state, context) => {
15443
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
15475
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
15444
15476
  context.addIssue({
15445
15477
  code: "custom",
15446
15478
  message: "Effective Thinking option must be currently available",
@@ -15480,7 +15512,8 @@ var harnessInspectParamsSchema = external_exports.object({
15480
15512
  cwd: nonBlankTextSchema2.max(16384).optional(),
15481
15513
  refresh: external_exports.boolean().optional(),
15482
15514
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
15483
- purpose: external_exports.literal("availability").optional()
15515
+ purpose: external_exports.literal("availability").optional(),
15516
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
15484
15517
  }).strict();
15485
15518
  var harnessWebUiOpenParamsSchema = external_exports.object({
15486
15519
  harnessId: harnessIdSchema
@@ -15511,7 +15544,7 @@ var codexThreadInspectionSchema = external_exports.object({
15511
15544
  var externalThreadInspectionSchema = external_exports.object({
15512
15545
  owner: external_exports.literal("external"),
15513
15546
  harnessId: nonBlankTextSchema2.max(256),
15514
- transportModelId: nonBlankTextSchema2.max(1024),
15547
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
15515
15548
  effectiveModel: harnessModelRefSchema.optional(),
15516
15549
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
15517
15550
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -15593,13 +15626,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
15593
15626
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
15594
15627
  }).strict();
15595
15628
 
15629
+ // ../../shared-contracts/dist/harness-plugins.js
15630
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
15631
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
15632
+ var HARNESS_PLUGIN_LIMIT = 128;
15633
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
15634
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
15635
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
15636
+ var pluginRelativeResourceSchema = external_exports.string().min(1).max(512).refine((value) => !/[\\\u0000:#?]/u.test(value) && !value.startsWith("/") && !value.split("/").some((part) => part === ".." || part === ""), "Plugin resources must be relative paths inside the plugin");
15637
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
15638
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
15639
+ var harnessInstallationGuideSchema = external_exports.object({
15640
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
15641
+ before: localizedTextSchema.optional(),
15642
+ after: localizedTextSchema.optional(),
15643
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
15644
+ }).strict();
15645
+ var pluginPresentationShape = {
15646
+ id: installedHarnessPluginIdSchema,
15647
+ name: external_exports.string().trim().min(1).max(128),
15648
+ version: external_exports.string().min(1).max(128),
15649
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
15650
+ kind: external_exports.literal("usage").optional(),
15651
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
15652
+ iconStyle: external_exports.object({
15653
+ vector: external_exports.object({
15654
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
15655
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
15656
+ paths: external_exports.array(external_exports.object({
15657
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
15658
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
15659
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
15660
+ }).strict()).min(1).max(32)
15661
+ }).strict().optional(),
15662
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
15663
+ borderRadius: external_exports.number().min(0).max(50).optional(),
15664
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
15665
+ }).strict().optional(),
15666
+ installation: harnessInstallationGuideSchema.optional(),
15667
+ notice: localizedTextSchema.optional(),
15668
+ /** The factory accepts a persisted local entrypoint through its construction context. */
15669
+ launchCommand: external_exports.literal(true).optional(),
15670
+ links: external_exports.object({
15671
+ website: documentationUrlSchema.optional(),
15672
+ documentation: documentationUrlSchema.optional(),
15673
+ installation: documentationUrlSchema.optional()
15674
+ }).strict().optional()
15675
+ };
15676
+ var harnessPluginManifestSchema = external_exports.object({
15677
+ manifestVersion: external_exports.literal(1),
15678
+ ...pluginPresentationShape,
15679
+ adapterApiVersion: external_exports.number().int().positive(),
15680
+ entry: pluginRelativeResourceSchema,
15681
+ icon: pluginRelativeResourceSchema.optional()
15682
+ }).strict();
15683
+ var harnessPluginIconSchema = external_exports.string().max(Math.ceil(HARNESS_PLUGIN_ICON_MAX_BYTES / 3) * 4 + 64).regex(/^data:image\/(?:png|jpeg|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/u);
15684
+ var harnessPluginDescriptorSchema = external_exports.object({
15685
+ ...pluginPresentationShape,
15686
+ icon: harnessPluginIconSchema.optional()
15687
+ }).strict();
15688
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
15689
+ var harnessPluginListResultSchema = external_exports.object({
15690
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
15691
+ }).strict();
15692
+ var harnessPluginConfigurationSchema = external_exports.object({
15693
+ version: external_exports.literal(1),
15694
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
15695
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
15696
+ message: "Enabled plugin IDs must be unique",
15697
+ path: ["enabled"]
15698
+ });
15699
+
15700
+ // ../../shared-contracts/dist/desktop-extensions.js
15701
+ var DESKTOP_EXTENSION_API_VERSION = 1;
15702
+ var DESKTOP_EXTENSION_LIMIT = 64;
15703
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
15704
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
15705
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
15706
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
15707
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
15708
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
15709
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
15710
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
15711
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
15712
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
15713
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
15714
+ var desktopExtensionIdSchema = installedPluginIdSchema;
15715
+ var desktopExtensionSlotSchema = external_exports.enum([
15716
+ "sidebar.thread-layout",
15717
+ "sidebar.thread-badge",
15718
+ "appearance.theme"
15719
+ ]);
15720
+ var desktopExtensionCategorySchema = external_exports.enum([
15721
+ "appearance",
15722
+ "interface",
15723
+ "workflow",
15724
+ "analytics",
15725
+ "integrations",
15726
+ "tools"
15727
+ ]);
15728
+ var extensionName = external_exports.string().trim().min(1).max(128);
15729
+ function desktopExtensionScreenshotMimeType(resource) {
15730
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
15731
+ case "png":
15732
+ return "image/png";
15733
+ case "jpg":
15734
+ case "jpeg":
15735
+ return "image/jpeg";
15736
+ case "webp":
15737
+ return "image/webp";
15738
+ default:
15739
+ return void 0;
15740
+ }
15741
+ }
15742
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
15743
+ var imagePathSchema = pluginRelativeResourceSchema.refine((resource) => desktopExtensionScreenshotMimeType(resource) !== void 0 && hasPortableSegments(resource), "Images must be relative .png, .jpg, .jpeg, or .webp paths with no segments ending in a dot or space");
15744
+ var desktopExtensionHttpUrlSchema = external_exports.string().trim().max(2048).regex(/^https?:\/\/[^/?#\\\s]+/iu, "Expected an HTTP(S) URL").pipe(external_exports.url({ protocol: /^https?$/u })).refine((value) => {
15745
+ const { username, password } = new URL(value);
15746
+ return !username && !password && !/[\\\s]/u.test(value);
15747
+ }, "URL must not contain credentials, backslashes, or whitespace");
15748
+ function localizedText(text) {
15749
+ return external_exports.strictObject({ en: text, "zh-CN": text });
15750
+ }
15751
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
15752
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
15753
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
15754
+ var settingField = {
15755
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
15756
+ label: desktopExtensionLocalizedTextSchema,
15757
+ description: desktopExtensionLocalizedTextSchema.optional()
15758
+ };
15759
+ var numericSetting = {
15760
+ ...settingField,
15761
+ step: external_exports.number().positive().optional(),
15762
+ default: external_exports.number().optional()
15763
+ };
15764
+ var settingOption = external_exports.strictObject({
15765
+ value: external_exports.string(),
15766
+ label: desktopExtensionLocalizedTextSchema
15767
+ });
15768
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
15769
+ external_exports.strictObject({
15770
+ ...settingField,
15771
+ type: external_exports.literal("boolean"),
15772
+ default: external_exports.boolean().optional()
15773
+ }),
15774
+ external_exports.strictObject({
15775
+ ...settingField,
15776
+ type: external_exports.literal("string"),
15777
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
15778
+ default: external_exports.string().optional()
15779
+ }),
15780
+ external_exports.strictObject({
15781
+ ...numericSetting,
15782
+ type: external_exports.literal("number"),
15783
+ min: external_exports.number().optional(),
15784
+ max: external_exports.number().optional()
15785
+ }),
15786
+ external_exports.strictObject({
15787
+ ...numericSetting,
15788
+ type: external_exports.literal("range"),
15789
+ min: external_exports.number(),
15790
+ max: external_exports.number()
15791
+ }),
15792
+ external_exports.strictObject({
15793
+ ...settingField,
15794
+ type: external_exports.literal("select"),
15795
+ options: external_exports.array(settingOption).min(1),
15796
+ default: external_exports.string().optional()
15797
+ })
15798
+ ]).superRefine((field2, ctx) => {
15799
+ const issue2 = (path10, message) => ctx.addIssue({ code: "custom", path: [path10], message });
15800
+ if (field2.type === "number" || field2.type === "range") {
15801
+ const { min = -Infinity, max = Infinity, default: value } = field2;
15802
+ if (min > max)
15803
+ issue2("max", "Must be at least min");
15804
+ if (value !== void 0 && (value < min || value > max))
15805
+ issue2("default", "Must be within min and max");
15806
+ } else if (field2.type === "select") {
15807
+ const values = new Set(field2.options.map(({ value }) => value));
15808
+ if (values.size !== field2.options.length)
15809
+ issue2("options", "Duplicate option values");
15810
+ if (field2.default !== void 0 && !values.has(field2.default))
15811
+ issue2("default", "Must match an option value");
15812
+ }
15813
+ });
15814
+ var manifestHeader = external_exports.object({
15815
+ manifestVersion: external_exports.int().positive(),
15816
+ id: desktopExtensionIdSchema,
15817
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
15818
+ version: external_exports.string().min(1).max(128),
15819
+ desktopApi: external_exports.int().positive()
15820
+ }).passthrough();
15821
+ var desktopExtensionManifestSchema = manifestHeader.extend({
15822
+ manifestVersion: external_exports.literal(1),
15823
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
15824
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
15825
+ author: external_exports.string().trim().min(1).max(128).optional(),
15826
+ repository: desktopExtensionHttpUrlSchema.optional(),
15827
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
15828
+ icon: imagePathSchema.optional(),
15829
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
15830
+ desktop: external_exports.strictObject({
15831
+ script: pluginRelativeResourceSchema,
15832
+ style: pluginRelativeResourceSchema.optional()
15833
+ }).optional(),
15834
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
15835
+ slots: slotsSchema.default(() => []),
15836
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
15837
+ categories: categoriesSchema.optional()
15838
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
15839
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
15840
+ var desktopExtensionStatusSchema = external_exports.strictObject({
15841
+ state: external_exports.enum([
15842
+ "running",
15843
+ "disabled",
15844
+ "invalid",
15845
+ "incompatible",
15846
+ "conflict",
15847
+ "failed",
15848
+ "waiting"
15849
+ ]),
15850
+ hash: desktopExtensionHashSchema.optional(),
15851
+ error: external_exports.string().optional(),
15852
+ conflictWith: desktopExtensionIdSchema.optional()
15853
+ });
15854
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
15855
+ controllerPid: external_exports.int().positive(),
15856
+ targetId: external_exports.string().nullable(),
15857
+ updatedAt: external_exports.iso.datetime(),
15858
+ handledReloadToken: external_exports.uuid().optional(),
15859
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
15860
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
15861
+ });
15862
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
15863
+ function isGitHubDesktopExtensionZipballUrl(url2) {
15864
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
15865
+ }
15866
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
15867
+ const url2 = new URL(input);
15868
+ return /\.zip$/iu.test(url2.pathname) || isGitHubDesktopExtensionZipballUrl(url2) || url2.origin === "https://github.com" && /^\/[\w-]+\/[\w.-]+\/zipball(?:\/.+)?\/?$/u.test(url2.pathname) || url2.origin === "https://codeload.github.com" && /^\/[\w-]+\/[\w.-]+\/(?:zip|zipball|legacy\.zip)\/.+$/u.test(url2.pathname);
15869
+ }, "Expected a .zip download URL or a GitHub zipball URL");
15870
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
15871
+ id: desktopExtensionIdSchema,
15872
+ version: external_exports.string().trim().min(1).max(128),
15873
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
15874
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
15875
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
15876
+ author: external_exports.string().trim().min(1).max(128),
15877
+ repository: desktopExtensionHttpUrlSchema,
15878
+ stars: external_exports.number().int().min(0).optional(),
15879
+ downloads: external_exports.number().int().min(0).optional(),
15880
+ categories: categoriesSchema.optional(),
15881
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
15882
+ icon: desktopExtensionHttpUrlSchema.optional(),
15883
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
15884
+ downloadUrl: desktopExtensionZipUrlSchema,
15885
+ sha256: desktopExtensionHashSchema,
15886
+ slots: slotsSchema.optional(),
15887
+ publishedAt: external_exports.string().optional(),
15888
+ updatedAt: external_exports.string().optional(),
15889
+ minCodexHostVersion: external_exports.string().optional()
15890
+ });
15891
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
15892
+ schemaVersion: external_exports.literal(1),
15893
+ generatedAt: external_exports.string(),
15894
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15895
+ });
15896
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
15897
+
15898
+ // ../../shared-contracts/dist/host-extensions.js
15899
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
15900
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
15901
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
15902
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
15903
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
15904
+ var hostExtensionActivationIdSchema = external_exports.uuid();
15905
+ var hostExtensionResourcePathSchema = pluginRelativeResourceSchema.refine((resource) => !/[\x00-\x1f\x7f<>"|*]/u.test(resource) && resource.split("/").every((part) => !/[. ]$/u.test(part) && !reservedName.test(part)), "Expected a portable relative resource path").refine((path10) => path10.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
15906
+ var legacy = desktopExtensionManifestSchema.shape;
15907
+ var localized = (max, min = 0) => external_exports.strictObject({
15908
+ en: external_exports.string().trim().min(min).max(max),
15909
+ "zh-CN": external_exports.string().trim().min(min).max(max)
15910
+ });
15911
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path10) => path10.endsWith(suffix), `Expected a ${suffix} file`);
15912
+ var moduleEntry = resourceWithSuffix(".mjs");
15913
+ var style = resourceWithSuffix(".css").optional();
15914
+ var hostExtensionCanonicalPath = (path10) => path10.normalize("NFC").toLowerCase();
15915
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
15916
+ manifestVersion: external_exports.literal(2),
15917
+ id: hostExtensionIdSchema,
15918
+ name: localized(128, 1),
15919
+ version: external_exports.string().trim().min(1).max(128),
15920
+ description: localized(4096),
15921
+ details: localized(16384).optional(),
15922
+ author: legacy.author,
15923
+ repository: legacy.repository,
15924
+ icon: legacy.icon.refine((path10) => path10 === void 0 || hostExtensionResourcePathSchema.safeParse(path10).success),
15925
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path10) => hostExtensionResourcePathSchema.safeParse(path10).success)),
15926
+ categories: legacy.categories,
15927
+ settingsSchema: legacy.settingsSchema,
15928
+ slots: legacy.slots.removeDefault().optional(),
15929
+ page: external_exports.strictObject({
15930
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15931
+ entry: moduleEntry,
15932
+ style,
15933
+ title: localized(128, 1).optional()
15934
+ }).optional(),
15935
+ widget: external_exports.strictObject({
15936
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
15937
+ entry: moduleEntry,
15938
+ style
15939
+ }).optional(),
15940
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
15941
+ web: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry.optional(), style }).refine(({ entry, style: style2 }) => entry !== void 0 || style2 !== void 0, "Expected a Web entry or style").optional(),
15942
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
15943
+ }).refine(({ page, widget, desktop, web, backend }) => Boolean(page || widget || desktop || web || backend), "Expected at least one page, widget, desktop, web, or backend entry").refine(({ page, widget, web, backend }) => !backend || [page?.entry, widget?.entry, web?.entry].every((entry) => entry === void 0 || hostExtensionCanonicalPath(entry) !== hostExtensionCanonicalPath(backend.entry)), { path: ["backend", "entry"], message: "A backend entry cannot also be a frontend entry" });
15944
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
15945
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
15946
+ return ["desktop", "web"];
15947
+ const targets = [];
15948
+ if (hasDesktop)
15949
+ targets.push("desktop");
15950
+ if (hasWeb)
15951
+ targets.push("web");
15952
+ return targets;
15953
+ }
15954
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
15955
+
15956
+ // ../../shared-contracts/dist/host-extension-management.js
15957
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
15958
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
15959
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
15960
+ revision: hostExtensionRevisionSchema,
15961
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
15962
+ });
15963
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
15964
+ var hostExtensionCatalogEntrySchema = external_exports.object({
15965
+ ...catalogMetadata,
15966
+ id: hostExtensionIdSchema,
15967
+ format: external_exports.literal("codexhost"),
15968
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
15969
+ apis: external_exports.strictObject({
15970
+ page: external_exports.int().positive().optional(),
15971
+ widget: external_exports.int().positive().optional(),
15972
+ desktop: external_exports.int().positive().optional(),
15973
+ web: external_exports.int().positive().optional(),
15974
+ backend: external_exports.int().positive().optional()
15975
+ }),
15976
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
15977
+ }).refine(({ targets, apis }) => {
15978
+ const derived = targetsForCapabilities({
15979
+ hasPage: Boolean(apis.page),
15980
+ hasWidget: Boolean(apis.widget),
15981
+ hasDesktop: Boolean(apis.desktop),
15982
+ hasWeb: Boolean(apis.web),
15983
+ hasBackend: Boolean(apis.backend)
15984
+ });
15985
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
15986
+ }, "Catalog targets must match the declared APIs");
15987
+ var hostExtensionCatalogSchema = external_exports.object({
15988
+ schemaVersion: external_exports.literal(2),
15989
+ generatedAt: external_exports.string().min(1),
15990
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
15991
+ });
15992
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
15993
+ catalogUrl: desktopExtensionHttpUrlSchema,
15994
+ fetchedAt: external_exports.iso.datetime(),
15995
+ cached: external_exports.boolean()
15996
+ });
15997
+ var id = { id: hostExtensionIdSchema };
15998
+ var active = {
15999
+ ...id,
16000
+ activationId: hostExtensionActivationIdSchema,
16001
+ digest: hostExtensionDigestSchema
16002
+ };
16003
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
16004
+ var filePath = external_exports.string().min(1).max(4096).refine((path10) => /^(?:\/|[a-z]:[/\\])/iu.test(path10) && !path10.includes("\0") && !path10.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
16005
+ var gitRef = external_exports.string().min(1).max(256).refine((ref) => ref.split("/").every((part) => part && /^[a-z0-9_.-]+$/iu.test(part) && part !== "." && part !== ".."), "Invalid GitHub ref");
16006
+ function base643(maxBytes) {
16007
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
16008
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
16009
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
16010
+ }, "Expected bounded standard padded base64");
16011
+ }
16012
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
16013
+ type: external_exports.literal("github"),
16014
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
16015
+ ref: gitRef.optional(),
16016
+ tag: gitRef.optional(),
16017
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
16018
+ subpath: hostExtensionResourcePathSchema.optional()
16019
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
16020
+ var hostExtensionInstallSourceSchema = external_exports.union([
16021
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
16022
+ hostExtensionGitHubSourceSchema,
16023
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
16024
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
16025
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
16026
+ ]);
16027
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
16028
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
16029
+ hostExtensionGitHubSourceSchema,
16030
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
16031
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
16032
+ ]);
16033
+ var hostExtensionInstallationSchema = external_exports.strictObject({
16034
+ ...active,
16035
+ manifest: hostExtensionManifestV2Schema,
16036
+ installedAt: external_exports.iso.datetime(),
16037
+ source: hostExtensionProvenanceSchema.optional()
16038
+ });
16039
+ var rasterDataUrlSchema = (maxBytes) => external_exports.string().max("data:image/jpeg;base64,".length + 4 * Math.ceil(maxBytes / 3)).regex(/^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/u);
16040
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
16041
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
16042
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
16043
+ hostExtensionInstallationSchema.extend({
16044
+ state: external_exports.literal("valid"),
16045
+ enabled: external_exports.boolean(),
16046
+ ...desktopConflict,
16047
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
16048
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
16049
+ backendState: backendState.optional(),
16050
+ backendError: external_exports.string().optional()
16051
+ }),
16052
+ external_exports.strictObject({
16053
+ state: external_exports.enum(["invalid", "incompatible"]),
16054
+ id: external_exports.string().min(1),
16055
+ enabled: external_exports.boolean(),
16056
+ error: external_exports.string()
16057
+ })
16058
+ ]);
16059
+ var hostExtensionsListResultSchema = external_exports.strictObject({
16060
+ revision: hostExtensionRevisionSchema,
16061
+ configuration: hostExtensionConfigurationSchema,
16062
+ diagnostics: external_exports.array(external_exports.string()),
16063
+ extensions: external_exports.array(hostExtensionListItemSchema)
16064
+ });
16065
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
16066
+ ...desktopConflict,
16067
+ settingsRevision: hostExtensionRevisionSchema
16068
+ });
16069
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
16070
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
16071
+ revision: hostExtensionRevisionSchema,
16072
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
16073
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
16074
+ });
16075
+ var HOST_EXTENSIONS_RPC = {
16076
+ list: "codexhost/extensions/list",
16077
+ snapshot: "codexhost/extensions/snapshot",
16078
+ catalog: "codexhost/extensions/catalog",
16079
+ install: "codexhost/extensions/install",
16080
+ update: "codexhost/extensions/update",
16081
+ enable: "codexhost/extensions/enable",
16082
+ disable: "codexhost/extensions/disable",
16083
+ uninstall: "codexhost/extensions/uninstall",
16084
+ recover: "codexhost/extensions/recover",
16085
+ asset: "codexhost/extensions/asset",
16086
+ settingsGet: "codexhost/extensions/settings/get",
16087
+ settingsSet: "codexhost/extensions/settings/set",
16088
+ backendInvoke: "codexhost/extensions/backend/invoke"
16089
+ };
16090
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
16091
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
16092
+ var noParams = external_exports.strictObject({});
16093
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
16094
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
16095
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
16096
+ var mutationResult = external_exports.discriminatedUnion("state", [
16097
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
16098
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
16099
+ ]);
16100
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
16101
+ ...optionalActivation,
16102
+ digest: active.digest.optional(),
16103
+ path: hostExtensionResourcePathSchema
16104
+ });
16105
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
16106
+ mimeType: external_exports.string().min(1),
16107
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
16108
+ digest: active.digest
16109
+ });
16110
+ var hostExtensionSettingsSchema = external_exports.strictObject({
16111
+ settingsRevision: hostExtensionRevisionSchema,
16112
+ values: jsonObjectSchema
16113
+ });
16114
+ var hostExtensionsRpcSchemas = {
16115
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
16116
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
16117
+ [HOST_EXTENSIONS_RPC.catalog]: {
16118
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
16119
+ result: hostExtensionsCatalogResultSchema
16120
+ },
16121
+ [HOST_EXTENSIONS_RPC.install]: {
16122
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
16123
+ result: installationResult
16124
+ },
16125
+ [HOST_EXTENSIONS_RPC.update]: {
16126
+ params: external_exports.strictObject({
16127
+ ...id,
16128
+ expectedDigest: active.digest,
16129
+ expectedActivationId: active.activationId.optional(),
16130
+ source: hostExtensionInstallSourceSchema.optional()
16131
+ }),
16132
+ result: installationResult
16133
+ },
16134
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
16135
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
16136
+ [HOST_EXTENSIONS_RPC.uninstall]: {
16137
+ params: external_exports.strictObject({
16138
+ ...id,
16139
+ removeData: external_exports.boolean().optional(),
16140
+ expectedDigest: active.digest.optional()
16141
+ }),
16142
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
16143
+ },
16144
+ [HOST_EXTENSIONS_RPC.recover]: {
16145
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
16146
+ result: mutationResult
16147
+ },
16148
+ [HOST_EXTENSIONS_RPC.asset]: {
16149
+ params: hostExtensionsAssetParamsSchema,
16150
+ result: hostExtensionsAssetResultSchema
16151
+ },
16152
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
16153
+ params: external_exports.strictObject(optionalActivation),
16154
+ result: hostExtensionSettingsSchema
16155
+ },
16156
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
16157
+ params: external_exports.strictObject({
16158
+ ...optionalActivation,
16159
+ expectedSettingsRevision: hostExtensionRevisionSchema,
16160
+ values: jsonObjectSchema
16161
+ }),
16162
+ result: hostExtensionSettingsSchema
16163
+ },
16164
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
16165
+ params: external_exports.strictObject({
16166
+ ...optionalActivation,
16167
+ method: hostExtensionBackendMethodSchema,
16168
+ params: jsonValueSchema.optional()
16169
+ }),
16170
+ result: external_exports.strictObject({ result: jsonValueSchema })
16171
+ }
16172
+ };
16173
+
15596
16174
  // ../../shared-contracts/dist/thread-archive-confirm.js
16175
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
15597
16176
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
15598
16177
  var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
15599
16178
 
15600
16179
  // ../../shared-contracts/dist/client-channel.js
15601
16180
  var CLIENT_CHANNEL_VERSION = 1;
15602
16181
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
16182
+ var CLIENT_CHANNEL_METHODS = [
16183
+ "codexhost/skills/list",
16184
+ "codexhost/voice/status",
16185
+ "codexhost/voice/transcribe",
16186
+ "codexhost/harness/display-settings/get",
16187
+ "codexhost/harness/display-settings/set",
16188
+ "codexhost/harness/display-settings/capabilities",
16189
+ "codexhost/harness/preferences/get",
16190
+ "codexhost/harness/preferences/patch",
16191
+ "thread/list",
16192
+ "codexhost/thread/catalog/read",
16193
+ "thread/read",
16194
+ "thread/resume",
16195
+ "thread/fork",
16196
+ "thread/turns/list",
16197
+ "thread/revert",
16198
+ "thread/items/list",
16199
+ "thread/start",
16200
+ "thread/name/set",
16201
+ "codexhost/thread/title/generate",
16202
+ "thread/archive",
16203
+ THREAD_ARCHIVE_CONFIRM_METHOD,
16204
+ "thread/unarchive",
16205
+ "turn/start",
16206
+ "turn/interrupt",
16207
+ "turn/steer",
16208
+ "thread/queue/list",
16209
+ "thread/queue/add",
16210
+ "thread/queue/update",
16211
+ "thread/queue/delete",
16212
+ "thread/queue/reorder",
16213
+ "thread/queue/start",
16214
+ "codexhost/thread/queue/send-now",
16215
+ "codexhost/workspace/read",
16216
+ "codexhost/thread/tree/read",
16217
+ "codexhost/thread/pins/list",
16218
+ "codexhost/thread/pins/set",
16219
+ "codexhost/harness/plugins/list",
16220
+ "codexhost/harness/inspect",
16221
+ "codexhost/thread/inspect",
16222
+ "codexhost/thread/usage/inspect",
16223
+ "codexhost/thread/ownership/list",
16224
+ "codexhost/thread/model/select",
16225
+ "codexhost/thread/thinking/select",
16226
+ "codexhost/thread/permission-mode/select",
16227
+ "codexhost/thread/commands/inspect",
16228
+ "codexhost/harness/commands/inspect",
16229
+ "codexhost/thread/command/execute",
16230
+ "codexhost/thread/fork",
16231
+ "codexhost/harness/session-import/sources",
16232
+ "codexhost/harness/session-import/list",
16233
+ "codexhost/harness/session-import/import",
16234
+ // Host settings shared across Desktop and Web.
16235
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
16236
+ "codexhost/harness/installation",
16237
+ "codexhost/harness/installation/start",
16238
+ "codexhost/harness/installation/status",
16239
+ "codexhost/harness/launch-settings/get",
16240
+ "codexhost/harness/launch-settings/set",
16241
+ "codexhost/harness/web-ui/open",
16242
+ "codexhost/harness/accounts/sources",
16243
+ "codexhost/harness/accounts/list",
16244
+ "codexhost/harness/accounts/inspect",
16245
+ "codexhost/harness/credential-imports",
16246
+ "codexhost/account/list",
16247
+ "codexhost/account/refresh",
16248
+ "codexhost/account/usage/inspect",
16249
+ "codexhost/usage/model-prices/get",
16250
+ "codexhost/usage/model-prices/set",
16251
+ "codexhost/usage/model-prices/default",
16252
+ "codexhost/usage/statistics/get",
16253
+ "codexhost/update/check",
16254
+ "codexhost/update/start",
16255
+ "codexhost/update/status",
16256
+ "codexhost/sessions/loaded/list"
16257
+ ];
15603
16258
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
15604
16259
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
15605
16260
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -15638,6 +16293,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
15638
16293
  cursor: clientChannelCursorSchema,
15639
16294
  revision: external_exports.number().int().nonnegative()
15640
16295
  }),
16296
+ external_exports.object({
16297
+ type: external_exports.literal("extensions-changed"),
16298
+ cursor: clientChannelCursorSchema,
16299
+ revision: hostExtensionRevisionSchema
16300
+ }),
15641
16301
  external_exports.object({
15642
16302
  type: external_exports.literal("hello"),
15643
16303
  version: external_exports.literal(1),
@@ -15813,6 +16473,29 @@ var threadCatalogReadResultSchema = external_exports.object({
15813
16473
  officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
15814
16474
  }).strict();
15815
16475
 
16476
+ // ../../shared-contracts/dist/thread-tree-watch.js
16477
+ var THREAD_TREE_MAX_NODES = 5e3;
16478
+ var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
16479
+ var threadTreeNodeSchema = external_exports.strictObject({
16480
+ harnessId: harnessIdSchema,
16481
+ title: external_exports.string().optional(),
16482
+ status: threadTreeStatusSchema,
16483
+ archived: external_exports.boolean()
16484
+ });
16485
+ var threadTreeSnapshotSchema = external_exports.strictObject({
16486
+ revision: external_exports.int().nonnegative(),
16487
+ parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
16488
+ nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
16489
+ truncated: external_exports.boolean()
16490
+ }).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");
16491
+ var subscriptionId = external_exports.string().min(1).max(128);
16492
+ var threadTreeWatchParamsSchema = external_exports.strictObject({});
16493
+ var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
16494
+ var threadTreeUnwatchResultSchema = external_exports.strictObject({});
16495
+ var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
16496
+ snapshot: threadTreeSnapshotSchema
16497
+ });
16498
+
15816
16499
  // ../../shared-contracts/dist/voice.js
15817
16500
  var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
15818
16501
  var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
@@ -16051,7 +16734,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
16051
16734
 
16052
16735
  // ../../shared-contracts/dist/harness-preferences.js
16053
16736
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
16054
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
16737
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
16055
16738
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
16056
16739
  model: harnessModelRefSchema.optional(),
16057
16740
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -16061,11 +16744,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
16061
16744
  lastHarness: harnessIdSchema.optional(),
16062
16745
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
16063
16746
  });
16747
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
16748
+ model: harnessModelRefSchema.optional(),
16749
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
16750
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
16751
+ var delegationDefaultsSchema = external_exports.strictObject({
16752
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
16753
+ });
16064
16754
  var modelId = external_exports.string().min(1).max(1024);
16065
16755
  var harnessPreferenceValuesSchema = external_exports.strictObject({
16066
16756
  idleRelease: idleReleaseSettingsSchema.optional(),
16067
16757
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
16068
- newThread: newThreadDefaultsSchema.optional()
16758
+ newThread: newThreadDefaultsSchema.optional(),
16759
+ delegation: delegationDefaultsSchema.optional()
16069
16760
  });
16070
16761
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
16071
16762
  scope: harnessPreferenceScopeSchema,
@@ -16093,6 +16784,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
16093
16784
  lastHarness: harnessIdSchema.optional(),
16094
16785
  harnessId: harnessIdSchema.optional(),
16095
16786
  configuration: harnessDefaultConfigurationSchema.optional()
16787
+ }),
16788
+ external_exports.strictObject({
16789
+ kind: external_exports.literal("delegation"),
16790
+ harnessId: harnessIdSchema,
16791
+ configuration: harnessDelegationDefaultSchema.nullable()
16096
16792
  })
16097
16793
  ]);
16098
16794
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -16443,13 +17139,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
16443
17139
  });
16444
17140
 
16445
17141
  // ../../shared-contracts/dist/harness-accounts.js
16446
- var accountBalanceSnapshotSchema = external_exports.object({
16447
- amount: external_exports.number().finite().nonnegative(),
16448
- /** ISO 4217 code as reported by the Provider, for example `CNY`. */
16449
- currency: external_exports.string().trim().min(1).max(8),
16450
- /** Native label when the Harness exposes several Billing Sources. */
16451
- label: external_exports.string().trim().min(1).max(128).optional()
16452
- }).strict();
16453
17142
  var harnessAccountSnapshotObject = external_exports.object({
16454
17143
  email: external_exports.string().trim().min(1).max(320).optional(),
16455
17144
  label: external_exports.string().trim().min(1).max(256).optional(),
@@ -16483,76 +17172,6 @@ var harnessAccountListResultSchema = external_exports.object({
16483
17172
  accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
16484
17173
  }).strict();
16485
17174
 
16486
- // ../../shared-contracts/dist/harness-plugins.js
16487
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
16488
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
16489
- var HARNESS_PLUGIN_LIMIT = 128;
16490
- var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
16491
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
16492
- 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");
16493
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
16494
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
16495
- var harnessInstallationGuideSchema = external_exports.object({
16496
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
16497
- before: localizedTextSchema.optional(),
16498
- after: localizedTextSchema.optional(),
16499
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
16500
- }).strict();
16501
- var pluginPresentationShape = {
16502
- id: installedHarnessPluginIdSchema,
16503
- name: external_exports.string().trim().min(1).max(128),
16504
- version: external_exports.string().min(1).max(128),
16505
- /** Capability-only plugin; omitted for existing session-capable plugins. */
16506
- kind: external_exports.literal("usage").optional(),
16507
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
16508
- iconStyle: external_exports.object({
16509
- vector: external_exports.object({
16510
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
16511
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
16512
- paths: external_exports.array(external_exports.object({
16513
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
16514
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
16515
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
16516
- }).strict()).min(1).max(32)
16517
- }).strict().optional(),
16518
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
16519
- borderRadius: external_exports.number().min(0).max(50).optional(),
16520
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
16521
- }).strict().optional(),
16522
- installation: harnessInstallationGuideSchema.optional(),
16523
- notice: localizedTextSchema.optional(),
16524
- /** The factory accepts a persisted local entrypoint through its construction context. */
16525
- launchCommand: external_exports.literal(true).optional(),
16526
- links: external_exports.object({
16527
- website: documentationUrlSchema.optional(),
16528
- documentation: documentationUrlSchema.optional(),
16529
- installation: documentationUrlSchema.optional()
16530
- }).strict().optional()
16531
- };
16532
- var harnessPluginManifestSchema = external_exports.object({
16533
- manifestVersion: external_exports.literal(1),
16534
- ...pluginPresentationShape,
16535
- adapterApiVersion: external_exports.number().int().positive(),
16536
- entry: relativeResourceSchema,
16537
- icon: relativeResourceSchema.optional()
16538
- }).strict();
16539
- 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);
16540
- var harnessPluginDescriptorSchema = external_exports.object({
16541
- ...pluginPresentationShape,
16542
- icon: harnessPluginIconSchema.optional()
16543
- }).strict();
16544
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
16545
- var harnessPluginListResultSchema = external_exports.object({
16546
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
16547
- }).strict();
16548
- var harnessPluginConfigurationSchema = external_exports.object({
16549
- version: external_exports.literal(1),
16550
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
16551
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
16552
- message: "Enabled plugin IDs must be unique",
16553
- path: ["enabled"]
16554
- });
16555
-
16556
17175
  // ../../shared-contracts/dist/harness-route.js
16557
17176
  var harnessPluginRouteSchema = external_exports.object({
16558
17177
  harnessId: harnessPluginIdSchema,
@@ -16993,9 +17612,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
16993
17612
  ...thread,
16994
17613
  epoch: identity,
16995
17614
  modelId: identity.optional(),
17615
+ serviceTier: harnessModelServiceTierSchema.optional(),
16996
17616
  thinkingOptionId: identity.optional(),
16997
17617
  permissionModeId: identity.optional()
16998
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
17618
+ }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting").refine((value) => value.serviceTier === void 0 || value.modelId !== void 0, {
17619
+ message: "A service tier requires a Model ID"
17620
+ }),
16999
17621
  external_exports.strictObject({
17000
17622
  kind: external_exports.literal("prompt"),
17001
17623
  ...thread,
@@ -17045,7 +17667,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17045
17667
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
17046
17668
  external_exports.strictObject({
17047
17669
  action: external_exports.literal("read-thread"),
17048
- hostId: hostId.refine((id) => id !== "local"),
17670
+ hostId: hostId.refine((id2) => id2 !== "local"),
17049
17671
  input: delegationReadParamsSchema
17050
17672
  }),
17051
17673
  external_exports.strictObject({
@@ -17059,7 +17681,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
17059
17681
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
17060
17682
  external_exports.strictObject({
17061
17683
  action: external_exports.literal("update"),
17062
- hostId: hostId.refine((id) => id !== "local"),
17684
+ hostId: hostId.refine((id2) => id2 !== "local"),
17063
17685
  version: remoteUpdateParamsSchema.shape.version
17064
17686
  })
17065
17687
  ]);
@@ -17127,7 +17749,7 @@ function invalidRequest(message) {
17127
17749
  return { code: "invalidRequest", message, retryable: false };
17128
17750
  }
17129
17751
  function validateHostApprovalResponse(interaction, response) {
17130
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17752
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
17131
17753
  }
17132
17754
 
17133
17755
  // ../../harness-adapter/dist/question.js
@@ -17135,7 +17757,7 @@ function invalidRequest2(message) {
17135
17757
  return { code: "invalidRequest", message, retryable: false };
17136
17758
  }
17137
17759
  function validateHostQuestionResponse(interaction, response) {
17138
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
17760
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
17139
17761
  if (response.cancelled) {
17140
17762
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
17141
17763
  }
@@ -17166,6 +17788,18 @@ function validateHostQuestionResponse(interaction, response) {
17166
17788
  return null;
17167
17789
  }
17168
17790
 
17791
+ // ../../harness-adapter/dist/legacy-model-ref.js
17792
+ import { Buffer as Buffer2 } from "node:buffer";
17793
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
17794
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
17795
+ return void 0;
17796
+ const encoded = ref.id.slice(prefix.length);
17797
+ const id2 = Buffer2.from(encoded, "base64url").toString("utf8");
17798
+ if (Buffer2.from(id2).toString("base64url") !== encoded)
17799
+ return void 0;
17800
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id2 && !ref2.serviceTier)?.ref;
17801
+ }
17802
+
17169
17803
  // ../../harness-adapter/dist/output-channel.js
17170
17804
  var HarnessOutputChannel = class {
17171
17805
  outputs;
@@ -17250,7 +17884,8 @@ var tokenFields = [
17250
17884
  var safeIntegerFields = [
17251
17885
  "planFiveHourResetsAtUnix",
17252
17886
  "planSevenDayResetsAtUnix",
17253
- "timeToFirstOutputMs"
17887
+ "timeToFirstOutputMs",
17888
+ "latestRequestTimeToFirstOutputMs"
17254
17889
  ];
17255
17890
  var percentFields = [
17256
17891
  "cacheHitRatePercent",
@@ -19234,8 +19869,8 @@ var RequestResponder = class {
19234
19869
  signal;
19235
19870
  finishRequest;
19236
19871
  didRespond = false;
19237
- constructor(id, sendResult, signal = new AbortController().signal, finishRequest) {
19238
- this.id = id;
19872
+ constructor(id2, sendResult, signal = new AbortController().signal, finishRequest) {
19873
+ this.id = id2;
19239
19874
  this.sendResult = sendResult;
19240
19875
  this.signal = signal;
19241
19876
  this.finishRequest = finishRequest;
@@ -19526,7 +20161,7 @@ var Connection = class {
19526
20161
  return this.sendWireMessage({ jsonrpc: "2.0", method, params });
19527
20162
  }
19528
20163
  prepareRequest(method, params, mapResponse, options = {}) {
19529
- const id = this.nextRequestId++;
20164
+ const id2 = this.nextRequestId++;
19530
20165
  let cancel = () => {
19531
20166
  };
19532
20167
  const response = new Promise((resolve, reject) => {
@@ -19546,7 +20181,7 @@ var Connection = class {
19546
20181
  }
19547
20182
  pendingResponse.cancellationSent = true;
19548
20183
  pendingResponse.cleanup?.();
19549
- void this.sendCancelRequest(id).catch(() => {
20184
+ void this.sendCancelRequest(id2).catch(() => {
19550
20185
  });
19551
20186
  };
19552
20187
  options.cancellationSignal?.addEventListener("abort", cancel, {
@@ -19555,12 +20190,12 @@ var Connection = class {
19555
20190
  pendingResponse.cleanup = () => {
19556
20191
  options.cancellationSignal?.removeEventListener("abort", cancel);
19557
20192
  };
19558
- this.pendingResponses.set(id, pendingResponse);
20193
+ this.pendingResponses.set(id2, pendingResponse);
19559
20194
  });
19560
20195
  response.catch(() => {
19561
20196
  });
19562
20197
  return {
19563
- message: { jsonrpc: "2.0", id, method, params },
20198
+ message: { jsonrpc: "2.0", id: id2, method, params },
19564
20199
  response,
19565
20200
  cancel: () => cancel()
19566
20201
  };
@@ -20197,7 +20832,7 @@ function memoryStreamPair() {
20197
20832
  }
20198
20833
  ];
20199
20834
  }
20200
- var methods = {
20835
+ var methods2 = {
20201
20836
  agent: {
20202
20837
  initialize: AGENT_METHODS.initialize,
20203
20838
  authenticate: AGENT_METHODS.authenticate,
@@ -22133,9 +22768,9 @@ function projectKimiUsages(payload) {
22133
22768
  });
22134
22769
  return parsed.success ? parsed.data : null;
22135
22770
  }
22136
- async function readNativeCredentials(filePath, readAuthFile) {
22771
+ async function readNativeCredentials(filePath2, readAuthFile) {
22137
22772
  try {
22138
- const raw = JSON.parse(await readAuthFile(filePath));
22773
+ const raw = JSON.parse(await readAuthFile(filePath2));
22139
22774
  if (!isRecord3(raw))
22140
22775
  return void 0;
22141
22776
  const parsed = credentialSchema.safeParse(raw);
@@ -22144,16 +22779,16 @@ async function readNativeCredentials(filePath, readAuthFile) {
22144
22779
  return void 0;
22145
22780
  }
22146
22781
  }
22147
- async function defaultWriteAuthFile(filePath, contents) {
22148
- const temporary = `${filePath}.${randomUUID()}.tmp`;
22782
+ async function defaultWriteAuthFile(filePath2, contents) {
22783
+ const temporary = `${filePath2}.${randomUUID()}.tmp`;
22149
22784
  try {
22150
22785
  await writeFile2(temporary, contents, { encoding: "utf8", mode: 384, flag: "wx" });
22151
- await rename(temporary, filePath);
22786
+ await rename(temporary, filePath2);
22152
22787
  } finally {
22153
22788
  await unlink(temporary).catch(() => void 0);
22154
22789
  }
22155
22790
  }
22156
- async function refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, signal, now) {
22791
+ async function refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, signal, now) {
22157
22792
  const refreshToken = stored.credentials.refresh_token;
22158
22793
  if (!refreshToken)
22159
22794
  return void 0;
@@ -22182,7 +22817,7 @@ async function refreshNativeCredentials(environment, stored, filePath, fetchImpl
22182
22817
  ...parsed.data.scope ? { scope: parsed.data.scope } : {},
22183
22818
  ...parsed.data.token_type ? { token_type: parsed.data.token_type } : {}
22184
22819
  };
22185
- await writeAuthFile(filePath, `${JSON.stringify(next, void 0, 2)}
22820
+ await writeAuthFile(filePath2, `${JSON.stringify(next, void 0, 2)}
22186
22821
  `).catch(() => void 0);
22187
22822
  stored.raw = next;
22188
22823
  stored.credentials = {
@@ -22198,18 +22833,18 @@ async function fetchKimiAccount(input = {}) {
22198
22833
  try {
22199
22834
  const environment = input.environment ?? process.env;
22200
22835
  const fromEnv = environment.KIMI_CODE_API_KEY?.trim() || environment.KIMI_API_KEY?.trim();
22201
- const readAuthFile = input.readAuthFile ?? ((filePath2) => readFile2(filePath2, "utf8"));
22836
+ const readAuthFile = input.readAuthFile ?? ((filePath3) => readFile2(filePath3, "utf8"));
22202
22837
  const writeAuthFile = input.writeAuthFile ?? defaultWriteAuthFile;
22203
22838
  const fetchImpl = input.fetch ?? fetch;
22204
22839
  const requestSignal = () => input.signal ? AbortSignal.any([input.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]) : AbortSignal.timeout(REQUEST_TIMEOUT_MS);
22205
22840
  const now = input.now ?? Date.now();
22206
- const filePath = credentialPath(environment);
22207
- const stored = fromEnv ? void 0 : await readNativeCredentials(filePath, readAuthFile);
22841
+ const filePath2 = credentialPath(environment);
22842
+ const stored = fromEnv ? void 0 : await readNativeCredentials(filePath2, readAuthFile);
22208
22843
  let token = fromEnv ?? stored?.credentials.access_token;
22209
22844
  if (!token)
22210
22845
  return null;
22211
22846
  if (stored && !accessTokenFresh(stored.credentials, now)) {
22212
- token = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now) ?? token;
22847
+ token = await refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, requestSignal(), now) ?? token;
22213
22848
  }
22214
22849
  const requestUsages = (accessToken) => fetchImpl(KIMI_USAGES_ENDPOINT, {
22215
22850
  method: "GET",
@@ -22218,7 +22853,7 @@ async function fetchKimiAccount(input = {}) {
22218
22853
  });
22219
22854
  let response = await requestUsages(token);
22220
22855
  if (response.status === 401 && stored?.credentials.refresh_token) {
22221
- const refreshed = await refreshNativeCredentials(environment, stored, filePath, fetchImpl, writeAuthFile, requestSignal(), now);
22856
+ const refreshed = await refreshNativeCredentials(environment, stored, filePath2, fetchImpl, writeAuthFile, requestSignal(), now);
22222
22857
  if (!refreshed)
22223
22858
  return null;
22224
22859
  token = refreshed;
@@ -23545,19 +24180,11 @@ function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
23545
24180
  */
23546
24181
 
23547
24182
  // dist/models.js
23548
- var KIMI_MODEL_PREFIX = "kimi.";
23549
- function encodeKimiModelRef(alias) {
23550
- const encoded = Buffer.from(alias, "utf8").toString("base64url");
23551
- return harnessModelRefSchema.parse({
23552
- id: harnessModelRefIdSchema.parse(`${KIMI_MODEL_PREFIX}${encoded}`)
23553
- });
24183
+ function kimiModelRef(id2) {
24184
+ return harnessModelRefSchema.parse({ id: id2 });
23554
24185
  }
23555
- function decodeKimiModelRefId(id) {
23556
- if (!id.startsWith(KIMI_MODEL_PREFIX)) {
23557
- throw new Error(`Invalid Kimi model ref ID: ${id}`);
23558
- }
23559
- const payload = id.slice(KIMI_MODEL_PREFIX.length);
23560
- return Buffer.from(payload, "base64url").toString("utf8");
24186
+ function normalizeStoredKimiModelRef(ref, catalog) {
24187
+ return normalizeLegacyBase64ModelRef(ref, catalog, "kimi.");
23561
24188
  }
23562
24189
  var KIMI_MODES = ["default", "plan", "auto", "yolo"];
23563
24190
  function isKimiModeId(value) {
@@ -23612,7 +24239,7 @@ function parseKimiConfigToml(content) {
23612
24239
  } catch (error51) {
23613
24240
  throw new Error(`Failed to parse Kimi config.toml: ${error51 instanceof Error ? error51.message : String(error51)}`);
23614
24241
  }
23615
- const defaultModel = typeof parsed.default_model === "string" ? parsed.default_model.trim() : void 0;
24242
+ const defaultModel = typeof parsed.default_model === "string" ? parsed.default_model : void 0;
23616
24243
  const models = [];
23617
24244
  if (typeof parsed.models === "object" && parsed.models !== null) {
23618
24245
  for (const [alias, details] of Object.entries(parsed.models)) {
@@ -23679,17 +24306,17 @@ function buildModelCatalogFromConfig(config2, thinkingOptionsList) {
23679
24306
  thinkingOptions.set(option.id, option);
23680
24307
  const label = m.model ? `${m.alias} (${m.model})` : m.alias;
23681
24308
  return harnessModelSchema.parse({
23682
- ref: encodeKimiModelRef(m.alias),
24309
+ ref: kimiModelRef(m.alias),
23683
24310
  label: label.slice(0, 256),
23684
24311
  ...m.model ? { resolvedModelLabel: m.model.slice(0, 256) } : {},
23685
- supportedThinkingOptionIds: options.map(({ id }) => id)
24312
+ supportedThinkingOptionIds: options.map(({ id: id2 }) => id2)
23686
24313
  });
23687
24314
  });
23688
- const defaultModel = config2.defaultModel && models.some((m) => decodeKimiModelRefId(m.ref.id) === config2.defaultModel) ? encodeKimiModelRef(config2.defaultModel) : models[0]?.ref;
23689
- const selectedModel = models.find((model2) => model2.ref.id === defaultModel?.id);
23690
- const configuredDefault = config2.models.find((model2) => encodeKimiModelRef(model2.alias).id === defaultModel?.id)?.defaultEffort;
24315
+ const selectedModel = models.find((model2) => model2.ref.id === config2.defaultModel) ?? models[0];
24316
+ const defaultModel = selectedModel?.ref;
24317
+ const configuredDefault = config2.models.find((model2) => model2.alias === defaultModel?.id)?.defaultEffort;
23691
24318
  const requestedDefault = config2.thinking?.enabled === false ? "off" : config2.thinking?.effort ?? configuredDefault;
23692
- const defaultThinkingOptionId = selectedModel?.supportedThinkingOptionIds?.find((id) => id === requestedDefault);
24319
+ const defaultThinkingOptionId = selectedModel?.supportedThinkingOptionIds?.find((id2) => id2 === requestedDefault);
23693
24320
  return harnessModelCatalogSchema.parse({
23694
24321
  models,
23695
24322
  ...defaultModel ? { defaultModel } : {},
@@ -24029,9 +24656,9 @@ function activeKimiWireRecords(content) {
24029
24656
  }
24030
24657
  }
24031
24658
  const branches = /* @__PURE__ */ new Map();
24032
- let active = "main";
24659
+ let active2 = "main";
24033
24660
  let segment = { start: 0, end: records.length };
24034
- branches.set(active, segment);
24661
+ branches.set(active2, segment);
24035
24662
  for (const [index, record3] of records.entries()) {
24036
24663
  if (record3?.type !== "agent.switched")
24037
24664
  continue;
@@ -24047,19 +24674,19 @@ function activeKimiWireRecords(content) {
24047
24674
  end: records.length,
24048
24675
  base: { branch: base.branch, line: base.line }
24049
24676
  };
24050
- active = record3.branch;
24051
- branches.set(active, segment);
24677
+ active2 = record3.branch;
24678
+ branches.set(active2, segment);
24052
24679
  }
24053
24680
  const ranges = [];
24054
24681
  let end = records.length;
24055
24682
  for (; ; ) {
24056
- const branch = branches.get(active);
24683
+ const branch = branches.get(active2);
24057
24684
  if (!branch)
24058
- throw new Error(`Unknown Kimi branch: ${active}`);
24685
+ throw new Error(`Unknown Kimi branch: ${active2}`);
24059
24686
  ranges.push({ start: branch.start, end });
24060
24687
  if (!branch.base)
24061
24688
  break;
24062
- active = branch.base.branch;
24689
+ active2 = branch.base.branch;
24063
24690
  end = branch.base.line;
24064
24691
  }
24065
24692
  return ranges.reverse().flatMap(({ start, end: end2 }) => records.slice(start, end2)).filter((record3) => record3 !== void 0 && record3.type !== "agent.switched");
@@ -24254,10 +24881,10 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24254
24881
  } else if (type === "file_history.tracked") {
24255
24882
  const turnId = typeof record3.turnId === "number" ? record3.turnId : 0;
24256
24883
  const turn = getOrCreateTurn(turnId);
24257
- const filePath = typeof record3.path === "string" ? record3.path : void 0;
24884
+ const filePath2 = typeof record3.path === "string" ? record3.path : void 0;
24258
24885
  const entry = record3.entry;
24259
- if (filePath && entry) {
24260
- turn.fileHistoryTracked.set(filePath, {
24886
+ if (filePath2 && entry) {
24887
+ turn.fileHistoryTracked.set(filePath2, {
24261
24888
  key: typeof entry.key === "string" ? entry.key : null,
24262
24889
  version: typeof entry.version === "number" ? entry.version : 1
24263
24890
  });
@@ -24267,9 +24894,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24267
24894
  const turn = getOrCreateTurn(turnId);
24268
24895
  const entries = record3.entries;
24269
24896
  if (entries) {
24270
- for (const [filePath, entry] of Object.entries(entries)) {
24897
+ for (const [filePath2, entry] of Object.entries(entries)) {
24271
24898
  if (typeof entry?.key === "string") {
24272
- turn.fileHistoryCheckpoint.set(filePath, {
24899
+ turn.fileHistoryCheckpoint.set(filePath2, {
24273
24900
  key: entry.key,
24274
24901
  version: typeof entry.version === "number" ? entry.version : 1,
24275
24902
  ...typeof entry.size === "number" ? { size: entry.size } : {}
@@ -24422,9 +25049,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24422
25049
  ...turn.fileHistoryTracked.keys(),
24423
25050
  ...turn.fileHistoryCheckpoint.keys()
24424
25051
  ]);
24425
- for (const filePath of allPaths) {
24426
- const tracked = turn.fileHistoryTracked.get(filePath);
24427
- const checkpoint = turn.fileHistoryCheckpoint.get(filePath);
25052
+ for (const filePath2 of allPaths) {
25053
+ const tracked = turn.fileHistoryTracked.get(filePath2);
25054
+ const checkpoint = turn.fileHistoryCheckpoint.get(filePath2);
24428
25055
  let oldContent = "";
24429
25056
  let newContent = "";
24430
25057
  if (tracked?.key) {
@@ -24443,9 +25070,9 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24443
25070
  }
24444
25071
  if (oldContent !== newContent) {
24445
25072
  const kind = !tracked || tracked.key === null ? "add" : !checkpoint ? "delete" : "update";
24446
- const patch = createTwoFilesPatch(filePath, filePath, oldContent, newContent, "", "");
25073
+ const patch = createTwoFilesPatch(filePath2, filePath2, oldContent, newContent, "", "");
24447
25074
  changes.push({
24448
- path: filePath.replaceAll("\\", "/"),
25075
+ path: filePath2.replaceAll("\\", "/"),
24449
25076
  kind,
24450
25077
  unifiedDiff: patch
24451
25078
  });
@@ -24497,7 +25124,7 @@ async function parseKimiWireLog(wireContent, sessionId, mainHomeDir) {
24497
25124
  input: turn.input.length > 0 ? turn.input : [{ type: "text", text: "" }],
24498
25125
  items,
24499
25126
  outcome,
24500
- ...turn.model ? { model: encodeKimiModelRef(turn.model) } : {},
25127
+ ...turn.model ? { model: kimiModelRef(turn.model) } : {},
24501
25128
  ...turn.startedAtMs !== void 0 ? { startedAtMs: turn.startedAtMs } : {},
24502
25129
  ...turn.completedAtMs !== void 0 ? { completedAtMs: turn.completedAtMs } : {}
24503
25130
  });
@@ -25286,7 +25913,7 @@ var KimiSession = class {
25286
25913
  delete state.effectiveThinkingOptionId;
25287
25914
  delete state.effectivePermissionModeId;
25288
25915
  if (effective.modelAlias)
25289
- state.effectiveModel = encodeKimiModelRef(effective.modelAlias);
25916
+ state.effectiveModel = kimiModelRef(effective.modelAlias);
25290
25917
  if (effective.thinkingOptionId)
25291
25918
  state.effectiveThinkingOptionId = effective.thinkingOptionId;
25292
25919
  if (effective.permissionModeId)
@@ -25875,32 +26502,32 @@ var KimiSession = class {
25875
26502
  return ok({ cancellationRequested: true });
25876
26503
  }
25877
26504
  async #handleInteractionRespond(command) {
25878
- const active = this.#activeInteractions.get(command.interactionId);
25879
- if (!active) {
26505
+ const active2 = this.#activeInteractions.get(command.interactionId);
26506
+ if (!active2) {
25880
26507
  return err("invalidRequest", `No active interaction matches ID ${command.interactionId}`);
25881
26508
  }
25882
- const turnId = active.interaction.turnId;
25883
- if (active.type === "approval") {
26509
+ const turnId = active2.interaction.turnId;
26510
+ if (active2.type === "approval") {
25884
26511
  if (command.response.type !== "approval") {
25885
26512
  return err("invalidRequest", `Expected approval response for interaction ${command.interactionId}`);
25886
26513
  }
25887
- const validation = validateHostApprovalResponse(active.interaction, command.response);
26514
+ const validation = validateHostApprovalResponse(active2.interaction, command.response);
25888
26515
  if (validation) {
25889
26516
  return err(validation.code, validation.message);
25890
26517
  }
25891
26518
  this.#activeInteractions.delete(command.interactionId);
25892
- const optionIdMap = active.metadata;
26519
+ const optionIdMap = active2.metadata;
25893
26520
  const selectedOptionId = optionIdMap?.get(command.response.actionId) || command.response.actionId;
25894
26521
  this.#channel.emit({
25895
26522
  kind: "event",
25896
26523
  event: {
25897
26524
  type: "interaction.closed",
25898
- interactionId: active.id,
26525
+ interactionId: active2.id,
25899
26526
  turnId,
25900
26527
  reason: "responded"
25901
26528
  }
25902
26529
  });
25903
- active.resolve({
26530
+ active2.resolve({
25904
26531
  outcome: {
25905
26532
  outcome: "selected",
25906
26533
  optionId: selectedOptionId
@@ -25908,38 +26535,33 @@ var KimiSession = class {
25908
26535
  });
25909
26536
  return ok({ accepted: true });
25910
26537
  }
25911
- if (active.type === "question") {
26538
+ if (active2.type === "question") {
25912
26539
  if (command.response.type !== "question") {
25913
26540
  return err("invalidRequest", `Expected question response for interaction ${command.interactionId}`);
25914
26541
  }
25915
- const validation = validateHostQuestionResponse(active.interaction, command.response);
26542
+ const validation = validateHostQuestionResponse(active2.interaction, command.response);
25916
26543
  if (validation) {
25917
26544
  return err(validation.code, validation.message);
25918
26545
  }
25919
26546
  this.#activeInteractions.delete(command.interactionId);
25920
- const schemaProps = active.metadata;
26547
+ const schemaProps = active2.metadata;
25921
26548
  const elicitationResponse = formatElicitationResponse(command.response, schemaProps);
25922
26549
  this.#channel.emit({
25923
26550
  kind: "event",
25924
26551
  event: {
25925
26552
  type: "interaction.closed",
25926
- interactionId: active.id,
26553
+ interactionId: active2.id,
25927
26554
  turnId,
25928
26555
  reason: command.response.cancelled ? "cancelled" : "responded"
25929
26556
  }
25930
26557
  });
25931
- active.resolve(elicitationResponse);
26558
+ active2.resolve(elicitationResponse);
25932
26559
  return ok({ accepted: true });
25933
26560
  }
25934
26561
  return err("invalidRequest", `Interaction type mismatch for ${command.interactionId}`);
25935
26562
  }
25936
26563
  async #handleModelSelect(command) {
25937
- let alias;
25938
- try {
25939
- alias = decodeKimiModelRefId(command.model.id);
25940
- } catch {
25941
- return err("invalidRequest", `Invalid model reference: ${command.model.id}`);
25942
- }
26564
+ const alias = command.model.id;
25943
26565
  try {
25944
26566
  const confirmed = await this.#transport.setConfigOption("model", alias);
25945
26567
  this.#applyConfigOptions(confirmed);
@@ -25952,7 +26574,7 @@ var KimiSession = class {
25952
26574
  }
25953
26575
  }
25954
26576
  async #handleThinkingSelect(command) {
25955
- if (!this.#state.availableThinkingOptions?.some(({ id }) => id === command.thinkingOptionId)) {
26577
+ if (!this.#state.availableThinkingOptions?.some(({ id: id2 }) => id2 === command.thinkingOptionId)) {
25956
26578
  return err("invalidRequest", new KimiThinkingSelectionError(command.thinkingOptionId).message);
25957
26579
  }
25958
26580
  try {
@@ -26078,7 +26700,7 @@ function err2(code, message, retryable = false) {
26078
26700
  async function applyRequestedConfig(transport, configOptions, requested) {
26079
26701
  let confirmed = configOptions ?? [];
26080
26702
  for (const option of requested) {
26081
- if (option.id === "thinking" && !readKimiThinkingOptions(confirmed).some(({ id }) => id === option.value)) {
26703
+ if (option.id === "thinking" && !readKimiThinkingOptions(confirmed).some(({ id: id2 }) => id2 === option.value)) {
26082
26704
  throw new KimiThinkingSelectionError(option.value);
26083
26705
  }
26084
26706
  confirmed = await transport.setConfigOption(option.id, option.value);
@@ -26095,7 +26717,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
26095
26717
  return {
26096
26718
  nativeRef: createKimiNativeSessionRef(sessionId, cwd),
26097
26719
  availableThinkingOptions: readKimiThinkingOptions(configOptions),
26098
- ...effective.modelAlias ? { effectiveModel: encodeKimiModelRef(effective.modelAlias) } : {},
26720
+ ...effective.modelAlias ? { effectiveModel: kimiModelRef(effective.modelAlias) } : {},
26099
26721
  ...effective.thinkingOptionId ? { effectiveThinkingOptionId: effective.thinkingOptionId } : {},
26100
26722
  ...effective.permissionModeId ? {
26101
26723
  effectivePermissionModeId: harnessPermissionModeIdSchema.parse(effective.permissionModeId)
@@ -26103,6 +26725,7 @@ function stateFromConfig(sessionId, cwd, configOptions) {
26103
26725
  };
26104
26726
  }
26105
26727
  var KimiAdapter = class {
26728
+ normalizeStoredModelRef = normalizeStoredKimiModelRef;
26106
26729
  harnessId = kimiHarnessId3;
26107
26730
  sessionImport;
26108
26731
  #options;
@@ -26238,13 +26861,7 @@ var KimiAdapter = class {
26238
26861
  if ("permissionModeId" in input && input.permissionModeId && !isKimiModeId(input.permissionModeId)) {
26239
26862
  return err2("invalidRequest", `Unsupported permission mode: ${input.permissionModeId}`);
26240
26863
  }
26241
- let requestedModelAlias;
26242
- try {
26243
- if ("model" in input && input.model)
26244
- requestedModelAlias = decodeKimiModelRefId(input.model.id);
26245
- } catch (error51) {
26246
- return err2("invalidRequest", error51 instanceof Error ? error51.message : String(error51));
26247
- }
26864
+ const requestedModelAlias = "model" in input ? input.model?.id : void 0;
26248
26865
  const environment = { ...process.env, ...this.#options.environment, ...input.environment };
26249
26866
  const cwd = input.cwd ?? process.cwd();
26250
26867
  const kimiCodeHome = getKimiCodeHome(this.#options.homeDirectory, environment);
@@ -26292,7 +26909,7 @@ var KimiAdapter = class {
26292
26909
  }
26293
26910
  const permissionModeId = input.permissionModeId ?? (unattended ? "yolo" : void 0);
26294
26911
  const requested = [
26295
- ...input.model ? [{ id: "model", value: decodeKimiModelRefId(input.model.id) }] : [],
26912
+ ...input.model ? [{ id: "model", value: input.model.id }] : [],
26296
26913
  ...input.thinkingOptionId ? [{ id: "thinking", value: input.thinkingOptionId }] : [],
26297
26914
  ...permissionModeId ? [{ id: "mode", value: permissionModeId }] : []
26298
26915
  ];
@@ -26414,7 +27031,7 @@ var KimiAdapter = class {
26414
27031
  throw new Error(`Unsupported permission mode: ${input.permissionModeId}`);
26415
27032
  }
26416
27033
  const requested = [
26417
- ...input.model ? [{ id: "model", value: decodeKimiModelRefId(input.model.id) }] : [],
27034
+ ...input.model ? [{ id: "model", value: input.model.id }] : [],
26418
27035
  ...input.thinkingOptionId ? [{ id: "thinking", value: input.thinkingOptionId }] : [],
26419
27036
  ...input.permissionModeId ? [{ id: "mode", value: input.permissionModeId }] : []
26420
27037
  ];
@@ -26500,7 +27117,7 @@ var KimiAdapter = class {
26500
27117
  nativeRef: createKimiNativeSessionRef(derivedId, input.cwd),
26501
27118
  cwd: input.cwd,
26502
27119
  environment,
26503
- model: input.model ?? encodeKimiModelRef(rolledBack.model),
27120
+ model: input.model ?? kimiModelRef(rolledBack.model),
26504
27121
  thinkingOptionId: input.thinkingOptionId ?? harnessThinkingOptionIdSchema.parse(rolledBack.thinking),
26505
27122
  permissionModeId: input.permissionModeId ?? harnessPermissionModeIdSchema.parse(rolledBack.mode)
26506
27123
  });