@codexhost/cli-linux-arm64 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +3117 -274
  4. package/app/console-web.js +15645 -4413
  5. package/app/desktop-controller.mjs +14057 -969
  6. package/app/host-runtime.mjs +11518 -8277
  7. package/app/plugins/antigravity/plugin.mjs +2030 -678
  8. package/app/plugins/claude-code/plugin.mjs +2116 -929
  9. package/app/plugins/codebuddy/plugin.mjs +1247 -353
  10. package/app/plugins/codex-usage/plugin.mjs +786 -163
  11. package/app/plugins/copilot/plugin.mjs +938 -296
  12. package/app/plugins/cursor-cli/plugin.mjs +1021 -232
  13. package/app/plugins/deepseek-harness/plugin.mjs +1552 -664
  14. package/app/plugins/devin/plugin.mjs +826 -185
  15. package/app/plugins/grok/plugin.mjs +1083 -424
  16. package/app/plugins/hermes/plugin.mjs +961 -338
  17. package/app/plugins/kimi-code/plugin.mjs +854 -237
  18. package/app/plugins/kiro-cli/plugin.mjs +821 -184
  19. package/app/plugins/omp/plugin.mjs +1316 -633
  20. package/app/plugins/opencode/plugin.mjs +1293 -606
  21. package/app/plugins/pi/plugin.mjs +1540 -867
  22. package/app/plugins/qoder/plugin.mjs +961 -332
  23. package/app/plugins/qoder-cn/plugin.mjs +961 -332
  24. package/app/plugins/qwen-code/plugin.mjs +937 -321
  25. package/app/plugins/workbuddy/plugin.mjs +1311 -370
  26. package/app/plugins/zcode/plugin.mjs +1516 -423
  27. package/app/renderer-extension.js +21297 -9060
  28. package/app/web/assets/index-CTCFIQbU.css +1 -0
  29. package/app/web/assets/index-IvFk9KT-.js +203 -0
  30. package/app/web/codexhost-settings.js +6753 -31616
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +1 -1
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  34. package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +14 -14
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +94 -91
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-browser/client.js +1 -1
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +79 -79
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +7 -7
  50. package/app/web/sw.js +8 -1
  51. package/app/web-modules/licenses/werift-NOTICES.txt +123 -0
  52. package/app/web-modules/licenses/werift-libwebrtc-NOTICES.txt +58 -0
  53. package/app/web-modules/server.mjs +40416 -11283
  54. package/bin/codexhost +0 -0
  55. package/libexec/codexhost-shim +0 -0
  56. package/libexec/codexhost-updater +0 -0
  57. package/package.json +1 -1
  58. package/app/web/assets/index-CN4a4sj0.js +0 -201
  59. package/app/web/assets/index-DJW4bmyx.css +0 -1
@@ -2235,10 +2235,10 @@ var require_resolve = __commonJS({
2235
2235
  }
2236
2236
  return count3;
2237
2237
  }
2238
- function getFullPath(resolver, id3 = "", normalize) {
2238
+ function getFullPath(resolver, id4 = "", normalize) {
2239
2239
  if (normalize !== false)
2240
- id3 = normalizeId(id3);
2241
- const p = resolver.parse(id3);
2240
+ id4 = normalizeId(id4);
2241
+ const p = resolver.parse(id4);
2242
2242
  return _getFullPath(resolver, p);
2243
2243
  }
2244
2244
  exports.getFullPath = getFullPath;
@@ -2248,13 +2248,13 @@ var require_resolve = __commonJS({
2248
2248
  }
2249
2249
  exports._getFullPath = _getFullPath;
2250
2250
  var TRAILING_SLASH_HASH = /#\/?$/;
2251
- function normalizeId(id3) {
2252
- return id3 ? id3.replace(TRAILING_SLASH_HASH, "") : "";
2251
+ function normalizeId(id4) {
2252
+ return id4 ? id4.replace(TRAILING_SLASH_HASH, "") : "";
2253
2253
  }
2254
2254
  exports.normalizeId = normalizeId;
2255
- function resolveUrl(resolver, baseId, id3) {
2256
- id3 = normalizeId(id3);
2257
- return resolver.resolve(baseId, id3);
2255
+ function resolveUrl(resolver, baseId, id4) {
2256
+ id4 = normalizeId(id4);
2257
+ return resolver.resolve(baseId, id4);
2258
2258
  }
2259
2259
  exports.resolveUrl = resolveUrl;
2260
2260
  var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
@@ -3024,8 +3024,8 @@ var require_compile = __commonJS({
3024
3024
  if (Object.keys(root.schema).length > 0 && refPath === baseId) {
3025
3025
  return getJsonPointer.call(this, p, root);
3026
3026
  }
3027
- const id3 = (0, resolve_1.normalizeId)(refPath);
3028
- const schOrRef = this.refs[id3] || this.schemas[id3];
3027
+ const id4 = (0, resolve_1.normalizeId)(refPath);
3028
+ const schOrRef = this.refs[id4] || this.schemas[id4];
3029
3029
  if (typeof schOrRef == "string") {
3030
3030
  const sch = resolveSchema.call(this, root, schOrRef);
3031
3031
  if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
@@ -3036,7 +3036,7 @@ var require_compile = __commonJS({
3036
3036
  return;
3037
3037
  if (!schOrRef.validate)
3038
3038
  compileSchema.call(this, schOrRef);
3039
- if (id3 === (0, resolve_1.normalizeId)(ref)) {
3039
+ if (id4 === (0, resolve_1.normalizeId)(ref)) {
3040
3040
  const { schema } = schOrRef;
3041
3041
  const { schemaId } = this.opts;
3042
3042
  const schId = schema[schemaId];
@@ -4159,15 +4159,15 @@ var require_core = __commonJS({
4159
4159
  this.addSchema(sch, void 0, _meta, _validateSchema);
4160
4160
  return this;
4161
4161
  }
4162
- let id3;
4162
+ let id4;
4163
4163
  if (typeof schema === "object") {
4164
4164
  const { schemaId } = this.opts;
4165
- id3 = schema[schemaId];
4166
- if (id3 !== void 0 && typeof id3 != "string") {
4165
+ id4 = schema[schemaId];
4166
+ if (id4 !== void 0 && typeof id4 != "string") {
4167
4167
  throw new Error(`schema ${schemaId} must be string`);
4168
4168
  }
4169
4169
  }
4170
- key = (0, resolve_1.normalizeId)(key || id3);
4170
+ key = (0, resolve_1.normalizeId)(key || id4);
4171
4171
  this._checkUnique(key);
4172
4172
  this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
4173
4173
  return this;
@@ -4246,11 +4246,11 @@ var require_core = __commonJS({
4246
4246
  case "object": {
4247
4247
  const cacheKey = schemaKeyRef;
4248
4248
  this._cache.delete(cacheKey);
4249
- let id3 = schemaKeyRef[this.opts.schemaId];
4250
- if (id3) {
4251
- id3 = (0, resolve_1.normalizeId)(id3);
4252
- delete this.schemas[id3];
4253
- delete this.refs[id3];
4249
+ let id4 = schemaKeyRef[this.opts.schemaId];
4250
+ if (id4) {
4251
+ id4 = (0, resolve_1.normalizeId)(id4);
4252
+ delete this.schemas[id4];
4253
+ delete this.refs[id4];
4254
4254
  }
4255
4255
  return this;
4256
4256
  }
@@ -4357,10 +4357,10 @@ var require_core = __commonJS({
4357
4357
  }
4358
4358
  }
4359
4359
  _addSchema(schema, meta3, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4360
- let id3;
4360
+ let id4;
4361
4361
  const { schemaId } = this.opts;
4362
4362
  if (typeof schema == "object") {
4363
- id3 = schema[schemaId];
4363
+ id4 = schema[schemaId];
4364
4364
  } else {
4365
4365
  if (this.opts.jtd)
4366
4366
  throw new Error("schema must be object");
@@ -4370,7 +4370,7 @@ var require_core = __commonJS({
4370
4370
  let sch = this._cache.get(schema);
4371
4371
  if (sch !== void 0)
4372
4372
  return sch;
4373
- baseId = (0, resolve_1.normalizeId)(id3 || baseId);
4373
+ baseId = (0, resolve_1.normalizeId)(id4 || baseId);
4374
4374
  const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
4375
4375
  sch = new compile_1.SchemaEnv({ schema, schemaId, meta: meta3, baseId, localRefs });
4376
4376
  this._cache.set(sch.schema, sch);
@@ -4383,9 +4383,9 @@ var require_core = __commonJS({
4383
4383
  this.validateSchema(schema, true);
4384
4384
  return sch;
4385
4385
  }
4386
- _checkUnique(id3) {
4387
- if (this.schemas[id3] || this.refs[id3]) {
4388
- throw new Error(`schema with key or id "${id3}" already exists`);
4386
+ _checkUnique(id4) {
4387
+ if (this.schemas[id4] || this.refs[id4]) {
4388
+ throw new Error(`schema with key or id "${id4}" already exists`);
4389
4389
  }
4390
4390
  }
4391
4391
  _compileSchemaEnv(sch) {
@@ -8948,10 +8948,10 @@ var require_resolve2 = __commonJS({
8948
8948
  }
8949
8949
  return count3;
8950
8950
  }
8951
- function getFullPath(resolver, id3 = "", normalize) {
8951
+ function getFullPath(resolver, id4 = "", normalize) {
8952
8952
  if (normalize !== false)
8953
- id3 = normalizeId(id3);
8954
- const p = resolver.parse(id3);
8953
+ id4 = normalizeId(id4);
8954
+ const p = resolver.parse(id4);
8955
8955
  return _getFullPath(resolver, p);
8956
8956
  }
8957
8957
  exports.getFullPath = getFullPath;
@@ -8961,13 +8961,13 @@ var require_resolve2 = __commonJS({
8961
8961
  }
8962
8962
  exports._getFullPath = _getFullPath;
8963
8963
  var TRAILING_SLASH_HASH = /#\/?$/;
8964
- function normalizeId(id3) {
8965
- return id3 ? id3.replace(TRAILING_SLASH_HASH, "") : "";
8964
+ function normalizeId(id4) {
8965
+ return id4 ? id4.replace(TRAILING_SLASH_HASH, "") : "";
8966
8966
  }
8967
8967
  exports.normalizeId = normalizeId;
8968
- function resolveUrl(resolver, baseId, id3) {
8969
- id3 = normalizeId(id3);
8970
- return resolver.resolve(baseId, id3);
8968
+ function resolveUrl(resolver, baseId, id4) {
8969
+ id4 = normalizeId(id4);
8970
+ return resolver.resolve(baseId, id4);
8971
8971
  }
8972
8972
  exports.resolveUrl = resolveUrl;
8973
8973
  var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
@@ -9737,8 +9737,8 @@ var require_compile2 = __commonJS({
9737
9737
  if (Object.keys(root.schema).length > 0 && refPath === baseId) {
9738
9738
  return getJsonPointer.call(this, p, root);
9739
9739
  }
9740
- const id3 = (0, resolve_1.normalizeId)(refPath);
9741
- const schOrRef = this.refs[id3] || this.schemas[id3];
9740
+ const id4 = (0, resolve_1.normalizeId)(refPath);
9741
+ const schOrRef = this.refs[id4] || this.schemas[id4];
9742
9742
  if (typeof schOrRef == "string") {
9743
9743
  const sch = resolveSchema.call(this, root, schOrRef);
9744
9744
  if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
@@ -9749,7 +9749,7 @@ var require_compile2 = __commonJS({
9749
9749
  return;
9750
9750
  if (!schOrRef.validate)
9751
9751
  compileSchema.call(this, schOrRef);
9752
- if (id3 === (0, resolve_1.normalizeId)(ref)) {
9752
+ if (id4 === (0, resolve_1.normalizeId)(ref)) {
9753
9753
  const { schema } = schOrRef;
9754
9754
  const { schemaId } = this.opts;
9755
9755
  const schId = schema[schemaId];
@@ -10057,15 +10057,15 @@ var require_core3 = __commonJS({
10057
10057
  this.addSchema(sch, void 0, _meta, _validateSchema);
10058
10058
  return this;
10059
10059
  }
10060
- let id3;
10060
+ let id4;
10061
10061
  if (typeof schema === "object") {
10062
10062
  const { schemaId } = this.opts;
10063
- id3 = schema[schemaId];
10064
- if (id3 !== void 0 && typeof id3 != "string") {
10063
+ id4 = schema[schemaId];
10064
+ if (id4 !== void 0 && typeof id4 != "string") {
10065
10065
  throw new Error(`schema ${schemaId} must be string`);
10066
10066
  }
10067
10067
  }
10068
- key = (0, resolve_1.normalizeId)(key || id3);
10068
+ key = (0, resolve_1.normalizeId)(key || id4);
10069
10069
  this._checkUnique(key);
10070
10070
  this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
10071
10071
  return this;
@@ -10144,11 +10144,11 @@ var require_core3 = __commonJS({
10144
10144
  case "object": {
10145
10145
  const cacheKey = schemaKeyRef;
10146
10146
  this._cache.delete(cacheKey);
10147
- let id3 = schemaKeyRef[this.opts.schemaId];
10148
- if (id3) {
10149
- id3 = (0, resolve_1.normalizeId)(id3);
10150
- delete this.schemas[id3];
10151
- delete this.refs[id3];
10147
+ let id4 = schemaKeyRef[this.opts.schemaId];
10148
+ if (id4) {
10149
+ id4 = (0, resolve_1.normalizeId)(id4);
10150
+ delete this.schemas[id4];
10151
+ delete this.refs[id4];
10152
10152
  }
10153
10153
  return this;
10154
10154
  }
@@ -10255,10 +10255,10 @@ var require_core3 = __commonJS({
10255
10255
  }
10256
10256
  }
10257
10257
  _addSchema(schema, meta3, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
10258
- let id3;
10258
+ let id4;
10259
10259
  const { schemaId } = this.opts;
10260
10260
  if (typeof schema == "object") {
10261
- id3 = schema[schemaId];
10261
+ id4 = schema[schemaId];
10262
10262
  } else {
10263
10263
  if (this.opts.jtd)
10264
10264
  throw new Error("schema must be object");
@@ -10268,7 +10268,7 @@ var require_core3 = __commonJS({
10268
10268
  let sch = this._cache.get(schema);
10269
10269
  if (sch !== void 0)
10270
10270
  return sch;
10271
- baseId = (0, resolve_1.normalizeId)(id3 || baseId);
10271
+ baseId = (0, resolve_1.normalizeId)(id4 || baseId);
10272
10272
  const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
10273
10273
  sch = new compile_1.SchemaEnv({ schema, schemaId, meta: meta3, baseId, localRefs });
10274
10274
  this._cache.set(sch.schema, sch);
@@ -10281,9 +10281,9 @@ var require_core3 = __commonJS({
10281
10281
  this.validateSchema(schema, true);
10282
10282
  return sch;
10283
10283
  }
10284
- _checkUnique(id3) {
10285
- if (this.schemas[id3] || this.refs[id3]) {
10286
- throw new Error(`schema with key or id "${id3}" already exists`);
10284
+ _checkUnique(id4) {
10285
+ if (this.schemas[id4] || this.refs[id4]) {
10286
+ throw new Error(`schema with key or id "${id4}" already exists`);
10287
10287
  }
10288
10288
  }
10289
10289
  _compileSchemaEnv(sch) {
@@ -13847,8 +13847,8 @@ function cleanEnum(obj) {
13847
13847
  return Number.isNaN(Number.parseInt(k3, 10));
13848
13848
  }).map((el3) => el3[1]);
13849
13849
  }
13850
- function base64ToUint8Array(base643) {
13851
- const binaryString = atob(base643);
13850
+ function base64ToUint8Array(base644) {
13851
+ const binaryString = atob(base644);
13852
13852
  const bytes = new Uint8Array(binaryString.length);
13853
13853
  for (let i = 0; i < binaryString.length; i++) {
13854
13854
  bytes[i] = binaryString.charCodeAt(i);
@@ -13863,9 +13863,9 @@ function uint8ArrayToBase64(bytes) {
13863
13863
  return btoa(binaryString);
13864
13864
  }
13865
13865
  function base64urlToUint8Array(base64url3) {
13866
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
13867
- const padding = "=".repeat((4 - base643.length % 4) % 4);
13868
- return base64ToUint8Array(base643 + padding);
13866
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
13867
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
13868
+ return base64ToUint8Array(base644 + padding);
13869
13869
  }
13870
13870
  function uint8ArrayToBase64url(bytes) {
13871
13871
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -15231,8 +15231,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
15231
15231
  function isValidBase64URL(data) {
15232
15232
  if (!base64url.test(data))
15233
15233
  return false;
15234
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
15235
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
15234
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
15235
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
15236
15236
  return isValidBase64(padded);
15237
15237
  }
15238
15238
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -15686,42 +15686,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
15686
15686
  }
15687
15687
  doc.write(`const newResult = {};`);
15688
15688
  for (const key of normalized.keys) {
15689
- const id3 = ids[key];
15689
+ const id4 = ids[key];
15690
15690
  const k3 = esc(key);
15691
15691
  const schema = shape[key];
15692
15692
  const isOptionalIn = schema?._zod?.optin === "optional";
15693
15693
  const isOptionalOut = schema?._zod?.optout === "optional";
15694
- doc.write(`const ${id3} = ${parseStr(key)};`);
15694
+ doc.write(`const ${id4} = ${parseStr(key)};`);
15695
15695
  if (isOptionalIn && isOptionalOut) {
15696
15696
  doc.write(`
15697
- if (${id3}.issues.length) {
15697
+ if (${id4}.issues.length) {
15698
15698
  if (${k3} in input) {
15699
- payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
15699
+ payload.issues = payload.issues.concat(${id4}.issues.map(iss => ({
15700
15700
  ...iss,
15701
15701
  path: iss.path ? [${k3}, ...iss.path] : [${k3}]
15702
15702
  })));
15703
15703
  }
15704
15704
  }
15705
15705
 
15706
- if (${id3}.value === undefined) {
15706
+ if (${id4}.value === undefined) {
15707
15707
  if (${k3} in input) {
15708
15708
  newResult[${k3}] = undefined;
15709
15709
  }
15710
15710
  } else {
15711
- newResult[${k3}] = ${id3}.value;
15711
+ newResult[${k3}] = ${id4}.value;
15712
15712
  }
15713
15713
 
15714
15714
  `);
15715
15715
  } else if (!isOptionalIn) {
15716
15716
  doc.write(`
15717
- const ${id3}_present = ${k3} in input;
15718
- if (${id3}.issues.length) {
15719
- payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
15717
+ const ${id4}_present = ${k3} in input;
15718
+ if (${id4}.issues.length) {
15719
+ payload.issues = payload.issues.concat(${id4}.issues.map(iss => ({
15720
15720
  ...iss,
15721
15721
  path: iss.path ? [${k3}, ...iss.path] : [${k3}]
15722
15722
  })));
15723
15723
  }
15724
- if (!${id3}_present && !${id3}.issues.length) {
15724
+ if (!${id4}_present && !${id4}.issues.length) {
15725
15725
  payload.issues.push({
15726
15726
  code: "invalid_type",
15727
15727
  expected: "nonoptional",
@@ -15730,30 +15730,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
15730
15730
  });
15731
15731
  }
15732
15732
 
15733
- if (${id3}_present) {
15734
- if (${id3}.value === undefined) {
15733
+ if (${id4}_present) {
15734
+ if (${id4}.value === undefined) {
15735
15735
  newResult[${k3}] = undefined;
15736
15736
  } else {
15737
- newResult[${k3}] = ${id3}.value;
15737
+ newResult[${k3}] = ${id4}.value;
15738
15738
  }
15739
15739
  }
15740
15740
 
15741
15741
  `);
15742
15742
  } else {
15743
15743
  doc.write(`
15744
- if (${id3}.issues.length) {
15745
- payload.issues = payload.issues.concat(${id3}.issues.map(iss => ({
15744
+ if (${id4}.issues.length) {
15745
+ payload.issues = payload.issues.concat(${id4}.issues.map(iss => ({
15746
15746
  ...iss,
15747
15747
  path: iss.path ? [${k3}, ...iss.path] : [${k3}]
15748
15748
  })));
15749
15749
  }
15750
15750
 
15751
- if (${id3}.value === undefined) {
15751
+ if (${id4}.value === undefined) {
15752
15752
  if (${k3} in input) {
15753
15753
  newResult[${k3}] = undefined;
15754
15754
  }
15755
15755
  } else {
15756
- newResult[${k3}] = ${id3}.value;
15756
+ newResult[${k3}] = ${id4}.value;
15757
15757
  }
15758
15758
 
15759
15759
  `);
@@ -24085,26 +24085,26 @@ function extractDefs(ctx, schema) {
24085
24085
  throw new Error("Unprocessed schema. This is a bug in Zod.");
24086
24086
  const idToSchema = /* @__PURE__ */ new Map();
24087
24087
  for (const entry of ctx.seen.entries()) {
24088
- const id3 = ctx.metadataRegistry.get(entry[0])?.id;
24089
- if (id3) {
24090
- const existing = idToSchema.get(id3);
24088
+ const id4 = ctx.metadataRegistry.get(entry[0])?.id;
24089
+ if (id4) {
24090
+ const existing = idToSchema.get(id4);
24091
24091
  if (existing && existing !== entry[0]) {
24092
- throw new Error(`Duplicate schema id "${id3}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
24092
+ throw new Error(`Duplicate schema id "${id4}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
24093
24093
  }
24094
- idToSchema.set(id3, entry[0]);
24094
+ idToSchema.set(id4, entry[0]);
24095
24095
  }
24096
24096
  }
24097
24097
  const makeURI = (entry) => {
24098
24098
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
24099
24099
  if (ctx.external) {
24100
24100
  const externalId = ctx.external.registry.get(entry[0])?.id;
24101
- const uriGenerator = ctx.external.uri ?? ((id4) => id4);
24101
+ const uriGenerator = ctx.external.uri ?? ((id5) => id5);
24102
24102
  if (externalId) {
24103
24103
  return { ref: uriGenerator(externalId) };
24104
24104
  }
24105
- const id3 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
24106
- entry[1].defId = id3;
24107
- return { defId: id3, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id3}` };
24105
+ const id4 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
24106
+ entry[1].defId = id4;
24107
+ return { defId: id4, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id4}` };
24108
24108
  }
24109
24109
  if (entry[1] === root) {
24110
24110
  return { ref: "#" };
@@ -24152,8 +24152,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
24152
24152
  continue;
24153
24153
  }
24154
24154
  }
24155
- const id3 = ctx.metadataRegistry.get(entry[0])?.id;
24156
- if (id3) {
24155
+ const id4 = ctx.metadataRegistry.get(entry[0])?.id;
24156
+ if (id4) {
24157
24157
  extractToDef(entry);
24158
24158
  continue;
24159
24159
  }
@@ -24249,10 +24249,10 @@ function finalize(ctx, schema) {
24249
24249
  } else {
24250
24250
  }
24251
24251
  if (ctx.external?.uri) {
24252
- const id3 = ctx.external.registry.get(schema)?.id;
24253
- if (!id3)
24252
+ const id4 = ctx.external.registry.get(schema)?.id;
24253
+ if (!id4)
24254
24254
  throw new Error("Schema is missing an `id` property");
24255
- result.$id = ctx.external.uri(id3);
24255
+ result.$id = ctx.external.uri(id4);
24256
24256
  }
24257
24257
  Object.assign(result, root.def ?? root.schema);
24258
24258
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -24412,9 +24412,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
24412
24412
  json2.type = "number";
24413
24413
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
24414
24414
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
24415
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
24415
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
24416
24416
  if (exMin) {
24417
- if (legacy) {
24417
+ if (legacy2) {
24418
24418
  json2.minimum = exclusiveMinimum;
24419
24419
  json2.exclusiveMinimum = true;
24420
24420
  } else {
@@ -24424,7 +24424,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
24424
24424
  json2.minimum = minimum;
24425
24425
  }
24426
24426
  if (exMax) {
24427
- if (legacy) {
24427
+ if (legacy2) {
24428
24428
  json2.maximum = exclusiveMaximum;
24429
24429
  json2.exclusiveMaximum = true;
24430
24430
  } else {
@@ -25286,7 +25286,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
25286
25286
 
25287
25287
  // ../../../node_modules/zod/v4/classic/schemas.js
25288
25288
  var _installedGroups = /* @__PURE__ */ new WeakMap();
25289
- function _installLazyMethods(inst, group, methods) {
25289
+ function _installLazyMethods(inst, group, methods2) {
25290
25290
  const proto = Object.getPrototypeOf(inst);
25291
25291
  let installed = _installedGroups.get(proto);
25292
25292
  if (!installed) {
@@ -25296,8 +25296,8 @@ function _installLazyMethods(inst, group, methods) {
25296
25296
  if (installed.has(group))
25297
25297
  return;
25298
25298
  installed.add(group);
25299
- for (const key in methods) {
25300
- const fn3 = methods[key];
25299
+ for (const key in methods2) {
25300
+ const fn3 = methods2[key];
25301
25301
  Object.defineProperty(proto, key, {
25302
25302
  configurable: true,
25303
25303
  enumerable: false,
@@ -27241,6 +27241,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
27241
27241
  permissionModeId: harnessPermissionModeIdSchema
27242
27242
  }).strict();
27243
27243
 
27244
+ // ../../shared-contracts/dist/harness-route-limit.js
27245
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
27246
+
27244
27247
  // ../../shared-contracts/dist/thread-usage.js
27245
27248
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
27246
27249
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -27273,7 +27276,7 @@ var composerIndicatorsSchema = external_exports.array(external_exports.object({
27273
27276
  expiresAtUnix: nonNegativeSafeIntegerSchema,
27274
27277
  label: indicatorTextSchema(256).optional(),
27275
27278
  tooltip: indicatorTextSchema(1024).optional()
27276
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id3 }) => id3)).size === entries.length, {
27279
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id4 }) => id4)).size === entries.length, {
27277
27280
  message: "Composer indicator IDs must be unique"
27278
27281
  });
27279
27282
  var threadUsageSnapshotSchema = external_exports.object({
@@ -27299,6 +27302,7 @@ var threadUsageSnapshotSchema = external_exports.object({
27299
27302
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
27300
27303
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
27301
27304
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27305
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
27302
27306
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
27303
27307
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
27304
27308
  }).strict().superRefine((usage, context) => {
@@ -27396,6 +27400,13 @@ var accountCreditsSnapshotSchema = external_exports.object({
27396
27400
  productUsage: external_exports.array(accountCreditsProductUsageSchema).min(1).optional(),
27397
27401
  resetCredits: accountResetCreditsSchema.optional()
27398
27402
  }).strict();
27403
+ var accountBalanceSnapshotSchema = external_exports.object({
27404
+ amount: external_exports.number().finite().nonnegative(),
27405
+ /** ISO 4217 code as reported by the Provider, for example `CNY`. */
27406
+ currency: external_exports.string().trim().min(1).max(8),
27407
+ /** Native label when the Harness exposes several Billing Sources. */
27408
+ label: external_exports.string().trim().min(1).max(128).optional()
27409
+ }).strict();
27399
27410
  var threadUsageInspectionParamsSchema = external_exports.object({
27400
27411
  threadId: hostThreadIdSchema,
27401
27412
  refresh: external_exports.literal("exact").optional()
@@ -27404,7 +27415,10 @@ var threadUsageInspectionSchema = external_exports.object({
27404
27415
  threadId: hostThreadIdSchema,
27405
27416
  usage: threadUsageSnapshotSchema.nullable(),
27406
27417
  accountCredits: accountCreditsSnapshotSchema.optional(),
27407
- /** Whether this source can provide cached account quota independently of usage. */
27418
+ /** Prepaid funds for the Thread's Billing Source; shown only when no percentage quota exists. */
27419
+ accountBalance: accountBalanceSnapshotSchema.optional(),
27420
+ /** Whether this source can provide cached account quota (credits or a prepaid balance)
27421
+ * independently of usage. */
27408
27422
  accountCreditsSupported: external_exports.boolean().optional()
27409
27423
  }).strict();
27410
27424
 
@@ -27416,10 +27430,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
27416
27430
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
27417
27431
  message: "Value must not be empty or whitespace"
27418
27432
  });
27419
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
27433
+ var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id4) => !new RegExp("\\p{Cc}", "u").test(id4), "Model Ref must not contain control characters").brand();
27434
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
27420
27435
  var harnessModelRefSchema = external_exports.object({
27421
- id: harnessModelRefIdSchema
27436
+ id: harnessModelRefIdSchema,
27437
+ serviceTier: harnessModelServiceTierSchema.optional()
27422
27438
  }).strict();
27439
+ function sameHarnessModelRef(left, right) {
27440
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
27441
+ }
27423
27442
  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();
27424
27443
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
27425
27444
  var harnessThinkingOptionSchema = external_exports.object({
@@ -27433,7 +27452,15 @@ var harnessModelSchema = external_exports.object({
27433
27452
  /** Optional opaque selection for this same Model with priority processing enabled. */
27434
27453
  fastModel: harnessModelRefSchema.optional(),
27435
27454
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
27436
- }).strict();
27455
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
27456
+ path: ["fastModel", "id"],
27457
+ message: "A tiered Fast Model must share the base Model ID"
27458
+ });
27459
+ function catalogModelForRef(catalog, ref) {
27460
+ if (!ref)
27461
+ return void 0;
27462
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
27463
+ }
27437
27464
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
27438
27465
  const ids = /* @__PURE__ */ new Set();
27439
27466
  for (const [index, option] of options.entries()) {
@@ -27453,26 +27480,26 @@ var harnessModelCatalogSchema = external_exports.object({
27453
27480
  thinkingOptions: harnessThinkingOptionsSchema,
27454
27481
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
27455
27482
  }).strict().superRefine((catalog, context) => {
27456
- const refs = /* @__PURE__ */ new Set();
27457
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id3 }) => id3));
27483
+ const refs = [];
27484
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id4 }) => id4));
27458
27485
  for (const [index, model2] of catalog.models.entries()) {
27459
- if (refs.has(model2.ref.id)) {
27486
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
27460
27487
  context.addIssue({
27461
27488
  code: "custom",
27462
27489
  message: "Model Catalog refs must be unique",
27463
27490
  path: ["models", index, "ref", "id"]
27464
27491
  });
27465
27492
  }
27466
- refs.add(model2.ref.id);
27493
+ refs.push(model2.ref);
27467
27494
  if (model2.fastModel) {
27468
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
27495
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
27469
27496
  context.addIssue({
27470
27497
  code: "custom",
27471
27498
  message: "Fast Model refs must be distinct and unique",
27472
27499
  path: ["models", index, "fastModel"]
27473
27500
  });
27474
27501
  }
27475
- refs.add(model2.fastModel.id);
27502
+ refs.push(model2.fastModel);
27476
27503
  }
27477
27504
  const supportedThinkingIds = /* @__PURE__ */ new Set();
27478
27505
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -27493,7 +27520,7 @@ var harnessModelCatalogSchema = external_exports.object({
27493
27520
  }
27494
27521
  }
27495
27522
  }
27496
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
27523
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
27497
27524
  context.addIssue({
27498
27525
  code: "custom",
27499
27526
  message: "Default Model must exist in the Model Catalog",
@@ -27533,7 +27560,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
27533
27560
  observe: external_exports.boolean()
27534
27561
  }).strict().optional(),
27535
27562
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
27536
- steer: external_exports.boolean().optional()
27563
+ steer: external_exports.boolean().optional(),
27564
+ /**
27565
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
27566
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
27567
+ */
27568
+ persistentPlan: external_exports.boolean().optional()
27537
27569
  }).strict();
27538
27570
  var harnessConfigurationStateSchema = external_exports.object({
27539
27571
  effectiveModel: harnessModelRefSchema.optional(),
@@ -27542,7 +27574,7 @@ var harnessConfigurationStateSchema = external_exports.object({
27542
27574
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
27543
27575
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
27544
27576
  }).strict().superRefine((state, context) => {
27545
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id3 }) => id3 === state.effectiveThinkingOptionId)) {
27577
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id4 }) => id4 === state.effectiveThinkingOptionId)) {
27546
27578
  context.addIssue({
27547
27579
  code: "custom",
27548
27580
  message: "Effective Thinking option must be currently available",
@@ -27582,7 +27614,8 @@ var harnessInspectParamsSchema = external_exports.object({
27582
27614
  cwd: nonBlankTextSchema2.max(16384).optional(),
27583
27615
  refresh: external_exports.boolean().optional(),
27584
27616
  /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
27585
- purpose: external_exports.literal("availability").optional()
27617
+ purpose: external_exports.literal("availability").optional(),
27618
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
27586
27619
  }).strict();
27587
27620
  var harnessWebUiOpenParamsSchema = external_exports.object({
27588
27621
  harnessId: harnessIdSchema
@@ -27613,7 +27646,7 @@ var codexThreadInspectionSchema = external_exports.object({
27613
27646
  var externalThreadInspectionSchema = external_exports.object({
27614
27647
  owner: external_exports.literal("external"),
27615
27648
  harnessId: nonBlankTextSchema2.max(256),
27616
- transportModelId: nonBlankTextSchema2.max(1024),
27649
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
27617
27650
  effectiveModel: harnessModelRefSchema.optional(),
27618
27651
  resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
27619
27652
  effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -27695,13 +27728,635 @@ var threadSteeringInspectResultSchema = external_exports.object({
27695
27728
  delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
27696
27729
  }).strict();
27697
27730
 
27731
+ // ../../shared-contracts/dist/harness-plugins.js
27732
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
27733
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
27734
+ var HARNESS_PLUGIN_LIMIT = 128;
27735
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
27736
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
27737
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id4) => id4 !== "codex", "The official Codex identity is reserved");
27738
+ 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");
27739
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
27740
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
27741
+ var harnessInstallationGuideSchema = external_exports.object({
27742
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
27743
+ before: localizedTextSchema.optional(),
27744
+ after: localizedTextSchema.optional(),
27745
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
27746
+ }).strict();
27747
+ var pluginPresentationShape = {
27748
+ id: installedHarnessPluginIdSchema,
27749
+ name: external_exports.string().trim().min(1).max(128),
27750
+ version: external_exports.string().min(1).max(128),
27751
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
27752
+ kind: external_exports.literal("usage").optional(),
27753
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
27754
+ iconStyle: external_exports.object({
27755
+ vector: external_exports.object({
27756
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
27757
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
27758
+ paths: external_exports.array(external_exports.object({
27759
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
27760
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
27761
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
27762
+ }).strict()).min(1).max(32)
27763
+ }).strict().optional(),
27764
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
27765
+ borderRadius: external_exports.number().min(0).max(50).optional(),
27766
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
27767
+ }).strict().optional(),
27768
+ installation: harnessInstallationGuideSchema.optional(),
27769
+ notice: localizedTextSchema.optional(),
27770
+ /** The factory accepts a persisted local entrypoint through its construction context. */
27771
+ launchCommand: external_exports.literal(true).optional(),
27772
+ links: external_exports.object({
27773
+ website: documentationUrlSchema.optional(),
27774
+ documentation: documentationUrlSchema.optional(),
27775
+ installation: documentationUrlSchema.optional()
27776
+ }).strict().optional()
27777
+ };
27778
+ var harnessPluginManifestSchema = external_exports.object({
27779
+ manifestVersion: external_exports.literal(1),
27780
+ ...pluginPresentationShape,
27781
+ adapterApiVersion: external_exports.number().int().positive(),
27782
+ entry: pluginRelativeResourceSchema,
27783
+ icon: pluginRelativeResourceSchema.optional()
27784
+ }).strict();
27785
+ 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);
27786
+ var harnessPluginDescriptorSchema = external_exports.object({
27787
+ ...pluginPresentationShape,
27788
+ icon: harnessPluginIconSchema.optional()
27789
+ }).strict();
27790
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
27791
+ var harnessPluginListResultSchema = external_exports.object({
27792
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
27793
+ }).strict();
27794
+ var harnessPluginConfigurationSchema = external_exports.object({
27795
+ version: external_exports.literal(1),
27796
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
27797
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
27798
+ message: "Enabled plugin IDs must be unique",
27799
+ path: ["enabled"]
27800
+ });
27801
+
27802
+ // ../../shared-contracts/dist/desktop-extensions.js
27803
+ var DESKTOP_EXTENSION_API_VERSION = 1;
27804
+ var DESKTOP_EXTENSION_LIMIT = 64;
27805
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
27806
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
27807
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
27808
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
27809
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
27810
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
27811
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
27812
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
27813
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
27814
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
27815
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
27816
+ var desktopExtensionIdSchema = installedPluginIdSchema;
27817
+ var desktopExtensionSlotSchema = external_exports.enum([
27818
+ "sidebar.thread-layout",
27819
+ "sidebar.thread-badge",
27820
+ "appearance.theme"
27821
+ ]);
27822
+ var desktopExtensionCategorySchema = external_exports.enum([
27823
+ "appearance",
27824
+ "interface",
27825
+ "workflow",
27826
+ "analytics",
27827
+ "integrations",
27828
+ "tools"
27829
+ ]);
27830
+ var extensionName = external_exports.string().trim().min(1).max(128);
27831
+ function desktopExtensionScreenshotMimeType(resource) {
27832
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
27833
+ case "png":
27834
+ return "image/png";
27835
+ case "jpg":
27836
+ case "jpeg":
27837
+ return "image/jpeg";
27838
+ case "webp":
27839
+ return "image/webp";
27840
+ default:
27841
+ return void 0;
27842
+ }
27843
+ }
27844
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
27845
+ 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");
27846
+ 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) => {
27847
+ const { username, password } = new URL(value);
27848
+ return !username && !password && !/[\\\s]/u.test(value);
27849
+ }, "URL must not contain credentials, backslashes, or whitespace");
27850
+ function localizedText(text) {
27851
+ return external_exports.strictObject({ en: text, "zh-CN": text });
27852
+ }
27853
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
27854
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
27855
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
27856
+ var settingField = {
27857
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
27858
+ label: desktopExtensionLocalizedTextSchema,
27859
+ description: desktopExtensionLocalizedTextSchema.optional()
27860
+ };
27861
+ var numericSetting = {
27862
+ ...settingField,
27863
+ step: external_exports.number().positive().optional(),
27864
+ default: external_exports.number().optional()
27865
+ };
27866
+ var settingOption = external_exports.strictObject({
27867
+ value: external_exports.string(),
27868
+ label: desktopExtensionLocalizedTextSchema
27869
+ });
27870
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
27871
+ external_exports.strictObject({
27872
+ ...settingField,
27873
+ type: external_exports.literal("boolean"),
27874
+ default: external_exports.boolean().optional()
27875
+ }),
27876
+ external_exports.strictObject({
27877
+ ...settingField,
27878
+ type: external_exports.literal("string"),
27879
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
27880
+ default: external_exports.string().optional()
27881
+ }),
27882
+ external_exports.strictObject({
27883
+ ...numericSetting,
27884
+ type: external_exports.literal("number"),
27885
+ min: external_exports.number().optional(),
27886
+ max: external_exports.number().optional()
27887
+ }),
27888
+ external_exports.strictObject({
27889
+ ...numericSetting,
27890
+ type: external_exports.literal("range"),
27891
+ min: external_exports.number(),
27892
+ max: external_exports.number()
27893
+ }),
27894
+ external_exports.strictObject({
27895
+ ...settingField,
27896
+ type: external_exports.literal("select"),
27897
+ options: external_exports.array(settingOption).min(1),
27898
+ default: external_exports.string().optional()
27899
+ })
27900
+ ]).superRefine((field2, ctx) => {
27901
+ const issue2 = (path10, message) => ctx.addIssue({ code: "custom", path: [path10], message });
27902
+ if (field2.type === "number" || field2.type === "range") {
27903
+ const { min = -Infinity, max = Infinity, default: value } = field2;
27904
+ if (min > max)
27905
+ issue2("max", "Must be at least min");
27906
+ if (value !== void 0 && (value < min || value > max))
27907
+ issue2("default", "Must be within min and max");
27908
+ } else if (field2.type === "select") {
27909
+ const values = new Set(field2.options.map(({ value }) => value));
27910
+ if (values.size !== field2.options.length)
27911
+ issue2("options", "Duplicate option values");
27912
+ if (field2.default !== void 0 && !values.has(field2.default))
27913
+ issue2("default", "Must match an option value");
27914
+ }
27915
+ });
27916
+ var manifestHeader = external_exports.object({
27917
+ manifestVersion: external_exports.int().positive(),
27918
+ id: desktopExtensionIdSchema,
27919
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
27920
+ version: external_exports.string().min(1).max(128),
27921
+ desktopApi: external_exports.int().positive()
27922
+ }).passthrough();
27923
+ var desktopExtensionManifestSchema = manifestHeader.extend({
27924
+ manifestVersion: external_exports.literal(1),
27925
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
27926
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
27927
+ author: external_exports.string().trim().min(1).max(128).optional(),
27928
+ repository: desktopExtensionHttpUrlSchema.optional(),
27929
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
27930
+ icon: imagePathSchema.optional(),
27931
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
27932
+ desktop: external_exports.strictObject({
27933
+ script: pluginRelativeResourceSchema,
27934
+ style: pluginRelativeResourceSchema.optional()
27935
+ }).optional(),
27936
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
27937
+ slots: slotsSchema.default(() => []),
27938
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
27939
+ categories: categoriesSchema.optional()
27940
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
27941
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
27942
+ var desktopExtensionStatusSchema = external_exports.strictObject({
27943
+ state: external_exports.enum([
27944
+ "running",
27945
+ "disabled",
27946
+ "invalid",
27947
+ "incompatible",
27948
+ "conflict",
27949
+ "failed",
27950
+ "waiting"
27951
+ ]),
27952
+ hash: desktopExtensionHashSchema.optional(),
27953
+ error: external_exports.string().optional(),
27954
+ conflictWith: desktopExtensionIdSchema.optional()
27955
+ });
27956
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
27957
+ controllerPid: external_exports.int().positive(),
27958
+ targetId: external_exports.string().nullable(),
27959
+ updatedAt: external_exports.iso.datetime(),
27960
+ handledReloadToken: external_exports.uuid().optional(),
27961
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
27962
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
27963
+ });
27964
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
27965
+ function isGitHubDesktopExtensionZipballUrl(url2) {
27966
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
27967
+ }
27968
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
27969
+ const url2 = new URL(input);
27970
+ 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);
27971
+ }, "Expected a .zip download URL or a GitHub zipball URL");
27972
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
27973
+ id: desktopExtensionIdSchema,
27974
+ version: external_exports.string().trim().min(1).max(128),
27975
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
27976
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
27977
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
27978
+ author: external_exports.string().trim().min(1).max(128),
27979
+ repository: desktopExtensionHttpUrlSchema,
27980
+ stars: external_exports.number().int().min(0).optional(),
27981
+ downloads: external_exports.number().int().min(0).optional(),
27982
+ categories: categoriesSchema.optional(),
27983
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
27984
+ icon: desktopExtensionHttpUrlSchema.optional(),
27985
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
27986
+ downloadUrl: desktopExtensionZipUrlSchema,
27987
+ sha256: desktopExtensionHashSchema,
27988
+ slots: slotsSchema.optional(),
27989
+ publishedAt: external_exports.string().optional(),
27990
+ updatedAt: external_exports.string().optional(),
27991
+ minCodexHostVersion: external_exports.string().optional()
27992
+ });
27993
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
27994
+ schemaVersion: external_exports.literal(1),
27995
+ generatedAt: external_exports.string(),
27996
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id4 }) => id4)).size === entries.length, "Duplicate extension IDs")
27997
+ });
27998
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
27999
+
28000
+ // ../../shared-contracts/dist/host-extensions.js
28001
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
28002
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
28003
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id4) => !reservedName.test(id4), "Reserved extension ID");
28004
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
28005
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
28006
+ var hostExtensionActivationIdSchema = external_exports.uuid();
28007
+ 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");
28008
+ var legacy = desktopExtensionManifestSchema.shape;
28009
+ var localized = (max, min = 0) => external_exports.strictObject({
28010
+ en: external_exports.string().trim().min(min).max(max),
28011
+ "zh-CN": external_exports.string().trim().min(min).max(max)
28012
+ });
28013
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path10) => path10.endsWith(suffix), `Expected a ${suffix} file`);
28014
+ var moduleEntry = resourceWithSuffix(".mjs");
28015
+ var style = resourceWithSuffix(".css").optional();
28016
+ var hostExtensionCanonicalPath = (path10) => path10.normalize("NFC").toLowerCase();
28017
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
28018
+ manifestVersion: external_exports.literal(2),
28019
+ id: hostExtensionIdSchema,
28020
+ name: localized(128, 1),
28021
+ version: external_exports.string().trim().min(1).max(128),
28022
+ description: localized(4096),
28023
+ details: localized(16384).optional(),
28024
+ author: legacy.author,
28025
+ repository: legacy.repository,
28026
+ icon: legacy.icon.refine((path10) => path10 === void 0 || hostExtensionResourcePathSchema.safeParse(path10).success),
28027
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path10) => hostExtensionResourcePathSchema.safeParse(path10).success)),
28028
+ categories: legacy.categories,
28029
+ settingsSchema: legacy.settingsSchema,
28030
+ slots: legacy.slots.removeDefault().optional(),
28031
+ page: external_exports.strictObject({
28032
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
28033
+ entry: moduleEntry,
28034
+ style,
28035
+ title: localized(128, 1).optional()
28036
+ }).optional(),
28037
+ widget: external_exports.strictObject({
28038
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
28039
+ entry: moduleEntry,
28040
+ style
28041
+ }).optional(),
28042
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
28043
+ 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(),
28044
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
28045
+ }).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" });
28046
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
28047
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
28048
+ return ["desktop", "web"];
28049
+ const targets = [];
28050
+ if (hasDesktop)
28051
+ targets.push("desktop");
28052
+ if (hasWeb)
28053
+ targets.push("web");
28054
+ return targets;
28055
+ }
28056
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
28057
+
28058
+ // ../../shared-contracts/dist/host-extension-management.js
28059
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
28060
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
28061
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
28062
+ revision: hostExtensionRevisionSchema,
28063
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
28064
+ });
28065
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
28066
+ var hostExtensionCatalogEntrySchema = external_exports.object({
28067
+ ...catalogMetadata,
28068
+ id: hostExtensionIdSchema,
28069
+ format: external_exports.literal("codexhost"),
28070
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
28071
+ apis: external_exports.strictObject({
28072
+ page: external_exports.int().positive().optional(),
28073
+ widget: external_exports.int().positive().optional(),
28074
+ desktop: external_exports.int().positive().optional(),
28075
+ web: external_exports.int().positive().optional(),
28076
+ backend: external_exports.int().positive().optional()
28077
+ }),
28078
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
28079
+ }).refine(({ targets, apis }) => {
28080
+ const derived = targetsForCapabilities({
28081
+ hasPage: Boolean(apis.page),
28082
+ hasWidget: Boolean(apis.widget),
28083
+ hasDesktop: Boolean(apis.desktop),
28084
+ hasWeb: Boolean(apis.web),
28085
+ hasBackend: Boolean(apis.backend)
28086
+ });
28087
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
28088
+ }, "Catalog targets must match the declared APIs");
28089
+ var hostExtensionCatalogSchema = external_exports.object({
28090
+ schemaVersion: external_exports.literal(2),
28091
+ generatedAt: external_exports.string().min(1),
28092
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id4 }) => id4)).size === entries.length, "Duplicate extension IDs")
28093
+ });
28094
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
28095
+ catalogUrl: desktopExtensionHttpUrlSchema,
28096
+ fetchedAt: external_exports.iso.datetime(),
28097
+ cached: external_exports.boolean()
28098
+ });
28099
+ var id = { id: hostExtensionIdSchema };
28100
+ var active = {
28101
+ ...id,
28102
+ activationId: hostExtensionActivationIdSchema,
28103
+ digest: hostExtensionDigestSchema
28104
+ };
28105
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
28106
+ 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");
28107
+ 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");
28108
+ function base643(maxBytes) {
28109
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
28110
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
28111
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
28112
+ }, "Expected bounded standard padded base64");
28113
+ }
28114
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
28115
+ type: external_exports.literal("github"),
28116
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
28117
+ ref: gitRef.optional(),
28118
+ tag: gitRef.optional(),
28119
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
28120
+ subpath: hostExtensionResourcePathSchema.optional()
28121
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
28122
+ var hostExtensionInstallSourceSchema = external_exports.union([
28123
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
28124
+ hostExtensionGitHubSourceSchema,
28125
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
28126
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
28127
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
28128
+ ]);
28129
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
28130
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
28131
+ hostExtensionGitHubSourceSchema,
28132
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
28133
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
28134
+ ]);
28135
+ var hostExtensionInstallationSchema = external_exports.strictObject({
28136
+ ...active,
28137
+ manifest: hostExtensionManifestV2Schema,
28138
+ installedAt: external_exports.iso.datetime(),
28139
+ source: hostExtensionProvenanceSchema.optional()
28140
+ });
28141
+ 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);
28142
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
28143
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
28144
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
28145
+ hostExtensionInstallationSchema.extend({
28146
+ state: external_exports.literal("valid"),
28147
+ enabled: external_exports.boolean(),
28148
+ ...desktopConflict,
28149
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
28150
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
28151
+ backendState: backendState.optional(),
28152
+ backendError: external_exports.string().optional()
28153
+ }),
28154
+ external_exports.strictObject({
28155
+ state: external_exports.enum(["invalid", "incompatible"]),
28156
+ id: external_exports.string().min(1),
28157
+ enabled: external_exports.boolean(),
28158
+ error: external_exports.string()
28159
+ })
28160
+ ]);
28161
+ var hostExtensionsListResultSchema = external_exports.strictObject({
28162
+ revision: hostExtensionRevisionSchema,
28163
+ configuration: hostExtensionConfigurationSchema,
28164
+ diagnostics: external_exports.array(external_exports.string()),
28165
+ extensions: external_exports.array(hostExtensionListItemSchema)
28166
+ });
28167
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
28168
+ ...desktopConflict,
28169
+ settingsRevision: hostExtensionRevisionSchema
28170
+ });
28171
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
28172
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
28173
+ revision: hostExtensionRevisionSchema,
28174
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
28175
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
28176
+ });
28177
+ var HOST_EXTENSIONS_RPC = {
28178
+ list: "codexhost/extensions/list",
28179
+ snapshot: "codexhost/extensions/snapshot",
28180
+ catalog: "codexhost/extensions/catalog",
28181
+ install: "codexhost/extensions/install",
28182
+ update: "codexhost/extensions/update",
28183
+ enable: "codexhost/extensions/enable",
28184
+ disable: "codexhost/extensions/disable",
28185
+ uninstall: "codexhost/extensions/uninstall",
28186
+ recover: "codexhost/extensions/recover",
28187
+ asset: "codexhost/extensions/asset",
28188
+ settingsGet: "codexhost/extensions/settings/get",
28189
+ settingsSet: "codexhost/extensions/settings/set",
28190
+ backendInvoke: "codexhost/extensions/backend/invoke"
28191
+ };
28192
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
28193
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
28194
+ var noParams = external_exports.strictObject({});
28195
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
28196
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
28197
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
28198
+ var mutationResult = external_exports.discriminatedUnion("state", [
28199
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
28200
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
28201
+ ]);
28202
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
28203
+ ...optionalActivation,
28204
+ digest: active.digest.optional(),
28205
+ path: hostExtensionResourcePathSchema
28206
+ });
28207
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
28208
+ mimeType: external_exports.string().min(1),
28209
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
28210
+ digest: active.digest
28211
+ });
28212
+ var hostExtensionSettingsSchema = external_exports.strictObject({
28213
+ settingsRevision: hostExtensionRevisionSchema,
28214
+ values: jsonObjectSchema
28215
+ });
28216
+ var hostExtensionsRpcSchemas = {
28217
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
28218
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
28219
+ [HOST_EXTENSIONS_RPC.catalog]: {
28220
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
28221
+ result: hostExtensionsCatalogResultSchema
28222
+ },
28223
+ [HOST_EXTENSIONS_RPC.install]: {
28224
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
28225
+ result: installationResult
28226
+ },
28227
+ [HOST_EXTENSIONS_RPC.update]: {
28228
+ params: external_exports.strictObject({
28229
+ ...id,
28230
+ expectedDigest: active.digest,
28231
+ expectedActivationId: active.activationId.optional(),
28232
+ source: hostExtensionInstallSourceSchema.optional()
28233
+ }),
28234
+ result: installationResult
28235
+ },
28236
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
28237
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
28238
+ [HOST_EXTENSIONS_RPC.uninstall]: {
28239
+ params: external_exports.strictObject({
28240
+ ...id,
28241
+ removeData: external_exports.boolean().optional(),
28242
+ expectedDigest: active.digest.optional()
28243
+ }),
28244
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
28245
+ },
28246
+ [HOST_EXTENSIONS_RPC.recover]: {
28247
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
28248
+ result: mutationResult
28249
+ },
28250
+ [HOST_EXTENSIONS_RPC.asset]: {
28251
+ params: hostExtensionsAssetParamsSchema,
28252
+ result: hostExtensionsAssetResultSchema
28253
+ },
28254
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
28255
+ params: external_exports.strictObject(optionalActivation),
28256
+ result: hostExtensionSettingsSchema
28257
+ },
28258
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
28259
+ params: external_exports.strictObject({
28260
+ ...optionalActivation,
28261
+ expectedSettingsRevision: hostExtensionRevisionSchema,
28262
+ values: jsonObjectSchema
28263
+ }),
28264
+ result: hostExtensionSettingsSchema
28265
+ },
28266
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
28267
+ params: external_exports.strictObject({
28268
+ ...optionalActivation,
28269
+ method: hostExtensionBackendMethodSchema,
28270
+ params: jsonValueSchema.optional()
28271
+ }),
28272
+ result: external_exports.strictObject({ result: jsonValueSchema })
28273
+ }
28274
+ };
28275
+
27698
28276
  // ../../shared-contracts/dist/thread-archive-confirm.js
28277
+ var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
27699
28278
  var threadArchiveConfirmParamsSchema = external_exports.object({ threadId: hostThreadIdSchema }).strict();
27700
28279
  var threadArchiveConfirmResultSchema = external_exports.object({ confirmed: external_exports.boolean() }).strict();
27701
28280
 
27702
28281
  // ../../shared-contracts/dist/client-channel.js
27703
28282
  var CLIENT_CHANNEL_VERSION = 1;
27704
28283
  var CLIENT_REQUEST_LIMIT_BYTES = 128 * 1024 * 1024;
28284
+ var CLIENT_CHANNEL_METHODS = [
28285
+ "codexhost/skills/list",
28286
+ "codexhost/voice/status",
28287
+ "codexhost/voice/transcribe",
28288
+ "codexhost/harness/display-settings/get",
28289
+ "codexhost/harness/display-settings/set",
28290
+ "codexhost/harness/display-settings/capabilities",
28291
+ "codexhost/harness/preferences/get",
28292
+ "codexhost/harness/preferences/patch",
28293
+ "thread/list",
28294
+ "codexhost/thread/catalog/read",
28295
+ "thread/read",
28296
+ "thread/resume",
28297
+ "thread/fork",
28298
+ "thread/turns/list",
28299
+ "thread/revert",
28300
+ "thread/items/list",
28301
+ "thread/start",
28302
+ "thread/name/set",
28303
+ "codexhost/thread/title/generate",
28304
+ "thread/archive",
28305
+ THREAD_ARCHIVE_CONFIRM_METHOD,
28306
+ "thread/unarchive",
28307
+ "turn/start",
28308
+ "turn/interrupt",
28309
+ "turn/steer",
28310
+ "thread/queue/list",
28311
+ "thread/queue/add",
28312
+ "thread/queue/update",
28313
+ "thread/queue/delete",
28314
+ "thread/queue/reorder",
28315
+ "thread/queue/start",
28316
+ "codexhost/thread/queue/send-now",
28317
+ "codexhost/workspace/read",
28318
+ "codexhost/thread/tree/read",
28319
+ "codexhost/thread/pins/list",
28320
+ "codexhost/thread/pins/set",
28321
+ "codexhost/harness/plugins/list",
28322
+ "codexhost/harness/inspect",
28323
+ "codexhost/thread/inspect",
28324
+ "codexhost/thread/usage/inspect",
28325
+ "codexhost/thread/ownership/list",
28326
+ "codexhost/thread/model/select",
28327
+ "codexhost/thread/thinking/select",
28328
+ "codexhost/thread/permission-mode/select",
28329
+ "codexhost/thread/commands/inspect",
28330
+ "codexhost/harness/commands/inspect",
28331
+ "codexhost/thread/command/execute",
28332
+ "codexhost/thread/fork",
28333
+ "codexhost/harness/session-import/sources",
28334
+ "codexhost/harness/session-import/list",
28335
+ "codexhost/harness/session-import/import",
28336
+ // Host settings shared across Desktop and Web.
28337
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
28338
+ "codexhost/harness/installation",
28339
+ "codexhost/harness/installation/start",
28340
+ "codexhost/harness/installation/status",
28341
+ "codexhost/harness/launch-settings/get",
28342
+ "codexhost/harness/launch-settings/set",
28343
+ "codexhost/harness/web-ui/open",
28344
+ "codexhost/harness/accounts/sources",
28345
+ "codexhost/harness/accounts/list",
28346
+ "codexhost/harness/accounts/inspect",
28347
+ "codexhost/harness/credential-imports",
28348
+ "codexhost/account/list",
28349
+ "codexhost/account/refresh",
28350
+ "codexhost/account/usage/inspect",
28351
+ "codexhost/usage/model-prices/get",
28352
+ "codexhost/usage/model-prices/set",
28353
+ "codexhost/usage/model-prices/default",
28354
+ "codexhost/usage/statistics/get",
28355
+ "codexhost/update/check",
28356
+ "codexhost/update/start",
28357
+ "codexhost/update/status",
28358
+ "codexhost/sessions/loaded/list"
28359
+ ];
27705
28360
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
27706
28361
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
27707
28362
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -27740,6 +28395,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
27740
28395
  cursor: clientChannelCursorSchema,
27741
28396
  revision: external_exports.number().int().nonnegative()
27742
28397
  }),
28398
+ external_exports.object({
28399
+ type: external_exports.literal("extensions-changed"),
28400
+ cursor: clientChannelCursorSchema,
28401
+ revision: hostExtensionRevisionSchema
28402
+ }),
27743
28403
  external_exports.object({
27744
28404
  type: external_exports.literal("hello"),
27745
28405
  version: external_exports.literal(1),
@@ -27915,6 +28575,29 @@ var threadCatalogReadResultSchema = external_exports.object({
27915
28575
  officialCursor: external_exports.object({ live: external_exports.string().nullable(), archived: external_exports.string().nullable().optional() }).strict().optional()
27916
28576
  }).strict();
27917
28577
 
28578
+ // ../../shared-contracts/dist/thread-tree-watch.js
28579
+ var THREAD_TREE_MAX_NODES = 5e3;
28580
+ var threadTreeStatusSchema = external_exports.enum(["running", "waiting", "idle", "unknown"]);
28581
+ var threadTreeNodeSchema = external_exports.strictObject({
28582
+ harnessId: harnessIdSchema,
28583
+ title: external_exports.string().optional(),
28584
+ status: threadTreeStatusSchema,
28585
+ archived: external_exports.boolean()
28586
+ });
28587
+ var threadTreeSnapshotSchema = external_exports.strictObject({
28588
+ revision: external_exports.int().nonnegative(),
28589
+ parents: external_exports.record(hostThreadIdSchema, hostThreadIdSchema),
28590
+ nodes: external_exports.record(hostThreadIdSchema, threadTreeNodeSchema),
28591
+ truncated: external_exports.boolean()
28592
+ }).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");
28593
+ var subscriptionId = external_exports.string().min(1).max(128);
28594
+ var threadTreeWatchParamsSchema = external_exports.strictObject({});
28595
+ var threadTreeUnwatchParamsSchema = external_exports.strictObject({ subscriptionId });
28596
+ var threadTreeUnwatchResultSchema = external_exports.strictObject({});
28597
+ var threadTreeWatchResultSchema = threadTreeUnwatchParamsSchema.extend({
28598
+ snapshot: threadTreeSnapshotSchema
28599
+ });
28600
+
27918
28601
  // ../../shared-contracts/dist/voice.js
27919
28602
  var VOICE_AUDIO_MAX_BYTES = 10 * 1024 * 1024;
27920
28603
  var voiceAudioMimeTypeSchema = external_exports.string().regex(/^audio\/[a-z0-9.+-]+(?:\s*;[^\r\n]*)?$/i);
@@ -28153,7 +28836,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
28153
28836
 
28154
28837
  // ../../shared-contracts/dist/harness-preferences.js
28155
28838
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
28156
- var preferenceHarnessKey = harnessIdSchema.transform((id3) => String(id3));
28839
+ var preferenceHarnessKey = harnessIdSchema.transform((id4) => String(id4));
28157
28840
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
28158
28841
  model: harnessModelRefSchema.optional(),
28159
28842
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -28163,11 +28846,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
28163
28846
  lastHarness: harnessIdSchema.optional(),
28164
28847
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
28165
28848
  });
28849
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
28850
+ model: harnessModelRefSchema.optional(),
28851
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
28852
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
28853
+ var delegationDefaultsSchema = external_exports.strictObject({
28854
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
28855
+ });
28166
28856
  var modelId = external_exports.string().min(1).max(1024);
28167
28857
  var harnessPreferenceValuesSchema = external_exports.strictObject({
28168
28858
  idleRelease: idleReleaseSettingsSchema.optional(),
28169
28859
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
28170
- newThread: newThreadDefaultsSchema.optional()
28860
+ newThread: newThreadDefaultsSchema.optional(),
28861
+ delegation: delegationDefaultsSchema.optional()
28171
28862
  });
28172
28863
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
28173
28864
  scope: harnessPreferenceScopeSchema,
@@ -28195,6 +28886,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
28195
28886
  lastHarness: harnessIdSchema.optional(),
28196
28887
  harnessId: harnessIdSchema.optional(),
28197
28888
  configuration: harnessDefaultConfigurationSchema.optional()
28889
+ }),
28890
+ external_exports.strictObject({
28891
+ kind: external_exports.literal("delegation"),
28892
+ harnessId: harnessIdSchema,
28893
+ configuration: harnessDelegationDefaultSchema.nullable()
28198
28894
  })
28199
28895
  ]);
28200
28896
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -28545,13 +29241,6 @@ var threadManualCompactionStartedSchema = external_exports.strictObject({
28545
29241
  });
28546
29242
 
28547
29243
  // ../../shared-contracts/dist/harness-accounts.js
28548
- var accountBalanceSnapshotSchema = external_exports.object({
28549
- amount: external_exports.number().finite().nonnegative(),
28550
- /** ISO 4217 code as reported by the Provider, for example `CNY`. */
28551
- currency: external_exports.string().trim().min(1).max(8),
28552
- /** Native label when the Harness exposes several Billing Sources. */
28553
- label: external_exports.string().trim().min(1).max(128).optional()
28554
- }).strict();
28555
29244
  var harnessAccountSnapshotObject = external_exports.object({
28556
29245
  email: external_exports.string().trim().min(1).max(320).optional(),
28557
29246
  label: external_exports.string().trim().min(1).max(256).optional(),
@@ -28585,76 +29274,6 @@ var harnessAccountListResultSchema = external_exports.object({
28585
29274
  accounts: external_exports.array(requireReportedQuota(harnessAccountSnapshotObject.extend(harnessAccountIdentityShape))).max(128)
28586
29275
  }).strict();
28587
29276
 
28588
- // ../../shared-contracts/dist/harness-plugins.js
28589
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
28590
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
28591
- var HARNESS_PLUGIN_LIMIT = 128;
28592
- var installedHarnessPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u).pipe(harnessIdSchema);
28593
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id3) => id3 !== "codex", "The official Codex identity is reserved");
28594
- 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");
28595
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
28596
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
28597
- var harnessInstallationGuideSchema = external_exports.object({
28598
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
28599
- before: localizedTextSchema.optional(),
28600
- after: localizedTextSchema.optional(),
28601
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
28602
- }).strict();
28603
- var pluginPresentationShape = {
28604
- id: installedHarnessPluginIdSchema,
28605
- name: external_exports.string().trim().min(1).max(128),
28606
- version: external_exports.string().min(1).max(128),
28607
- /** Capability-only plugin; omitted for existing session-capable plugins. */
28608
- kind: external_exports.literal("usage").optional(),
28609
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
28610
- iconStyle: external_exports.object({
28611
- vector: external_exports.object({
28612
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
28613
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
28614
- paths: external_exports.array(external_exports.object({
28615
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
28616
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
28617
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
28618
- }).strict()).min(1).max(32)
28619
- }).strict().optional(),
28620
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
28621
- borderRadius: external_exports.number().min(0).max(50).optional(),
28622
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
28623
- }).strict().optional(),
28624
- installation: harnessInstallationGuideSchema.optional(),
28625
- notice: localizedTextSchema.optional(),
28626
- /** The factory accepts a persisted local entrypoint through its construction context. */
28627
- launchCommand: external_exports.literal(true).optional(),
28628
- links: external_exports.object({
28629
- website: documentationUrlSchema.optional(),
28630
- documentation: documentationUrlSchema.optional(),
28631
- installation: documentationUrlSchema.optional()
28632
- }).strict().optional()
28633
- };
28634
- var harnessPluginManifestSchema = external_exports.object({
28635
- manifestVersion: external_exports.literal(1),
28636
- ...pluginPresentationShape,
28637
- adapterApiVersion: external_exports.number().int().positive(),
28638
- entry: relativeResourceSchema,
28639
- icon: relativeResourceSchema.optional()
28640
- }).strict();
28641
- 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);
28642
- var harnessPluginDescriptorSchema = external_exports.object({
28643
- ...pluginPresentationShape,
28644
- icon: harnessPluginIconSchema.optional()
28645
- }).strict();
28646
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
28647
- var harnessPluginListResultSchema = external_exports.object({
28648
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
28649
- }).strict();
28650
- var harnessPluginConfigurationSchema = external_exports.object({
28651
- version: external_exports.literal(1),
28652
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
28653
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
28654
- message: "Enabled plugin IDs must be unique",
28655
- path: ["enabled"]
28656
- });
28657
-
28658
29277
  // ../../shared-contracts/dist/harness-route.js
28659
29278
  var harnessPluginRouteSchema = external_exports.object({
28660
29279
  harnessId: harnessPluginIdSchema,
@@ -29095,9 +29714,12 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
29095
29714
  ...thread,
29096
29715
  epoch: identity,
29097
29716
  modelId: identity.optional(),
29717
+ serviceTier: harnessModelServiceTierSchema.optional(),
29098
29718
  thinkingOptionId: identity.optional(),
29099
29719
  permissionModeId: identity.optional()
29100
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
29720
+ }).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, {
29721
+ message: "A service tier requires a Model ID"
29722
+ }),
29101
29723
  external_exports.strictObject({
29102
29724
  kind: external_exports.literal("prompt"),
29103
29725
  ...thread,
@@ -29147,7 +29769,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
29147
29769
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
29148
29770
  external_exports.strictObject({
29149
29771
  action: external_exports.literal("read-thread"),
29150
- hostId: hostId.refine((id3) => id3 !== "local"),
29772
+ hostId: hostId.refine((id4) => id4 !== "local"),
29151
29773
  input: delegationReadParamsSchema
29152
29774
  }),
29153
29775
  external_exports.strictObject({
@@ -29161,7 +29783,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
29161
29783
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
29162
29784
  external_exports.strictObject({
29163
29785
  action: external_exports.literal("update"),
29164
- hostId: hostId.refine((id3) => id3 !== "local"),
29786
+ hostId: hostId.refine((id4) => id4 !== "local"),
29165
29787
  version: remoteUpdateParamsSchema.shape.version
29166
29788
  })
29167
29789
  ]);
@@ -29250,10 +29872,10 @@ function executableExtensions(command, platform, environment) {
29250
29872
  return [""];
29251
29873
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
29252
29874
  }
29253
- function isExecutableFile(filePath, platform) {
29875
+ function isExecutableFile(filePath2, platform) {
29254
29876
  try {
29255
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
29256
- return fs.statSync(filePath).isFile();
29877
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
29878
+ return fs.statSync(filePath2).isFile();
29257
29879
  } catch {
29258
29880
  return false;
29259
29881
  }
@@ -29909,7 +30531,7 @@ function invalidRequest(message) {
29909
30531
  return { code: "invalidRequest", message, retryable: false };
29910
30532
  }
29911
30533
  function validateHostApprovalResponse(interaction, response) {
29912
- return interaction.actions.some(({ id: id3 }) => id3 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
30534
+ return interaction.actions.some(({ id: id4 }) => id4 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
29913
30535
  }
29914
30536
 
29915
30537
  // ../../harness-adapter/dist/question.js
@@ -29917,7 +30539,7 @@ function invalidRequest2(message) {
29917
30539
  return { code: "invalidRequest", message, retryable: false };
29918
30540
  }
29919
30541
  function validateHostQuestionResponse(interaction, response) {
29920
- const questionIds = new Set(interaction.questions.map(({ id: id3 }) => id3));
30542
+ const questionIds = new Set(interaction.questions.map(({ id: id4 }) => id4));
29921
30543
  if (response.cancelled) {
29922
30544
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
29923
30545
  }
@@ -29948,6 +30570,18 @@ function validateHostQuestionResponse(interaction, response) {
29948
30570
  return null;
29949
30571
  }
29950
30572
 
30573
+ // ../../harness-adapter/dist/legacy-model-ref.js
30574
+ import { Buffer as Buffer2 } from "node:buffer";
30575
+ function normalizeLegacyBase64ModelRef(ref, catalog, prefix) {
30576
+ if (ref.serviceTier || !ref.id.startsWith(prefix))
30577
+ return void 0;
30578
+ const encoded = ref.id.slice(prefix.length);
30579
+ const id4 = Buffer2.from(encoded, "base64url").toString("utf8");
30580
+ if (Buffer2.from(id4).toString("base64url") !== encoded)
30581
+ return void 0;
30582
+ return catalog.models.find(({ ref: ref2 }) => ref2.id === id4 && !ref2.serviceTier)?.ref;
30583
+ }
30584
+
29951
30585
  // ../../harness-adapter/dist/output-channel.js
29952
30586
  var HarnessOutputChannel = class {
29953
30587
  outputs;
@@ -30023,7 +30657,8 @@ var tokenFields = [
30023
30657
  var safeIntegerFields = [
30024
30658
  "planFiveHourResetsAtUnix",
30025
30659
  "planSevenDayResetsAtUnix",
30026
- "timeToFirstOutputMs"
30660
+ "timeToFirstOutputMs",
30661
+ "latestRequestTimeToFirstOutputMs"
30027
30662
  ];
30028
30663
  var percentFields = [
30029
30664
  "cacheHitRatePercent",
@@ -30270,19 +30905,19 @@ function mapQoderSlashCommands(commands) {
30270
30905
  const cleanName = rawName.replace(/^\//, "").trim().toLowerCase();
30271
30906
  if (!cleanName || isExcludedLiveCommand(cleanName))
30272
30907
  continue;
30273
- const id3 = `qoder.${cleanName}`;
30274
- if (seenIds.has(id3))
30908
+ const id4 = `qoder.${cleanName}`;
30909
+ if (seenIds.has(id4))
30275
30910
  continue;
30276
- seenIds.add(id3);
30911
+ seenIds.add(id4);
30277
30912
  const desc = typeof native === "object" && typeof native.description === "string" ? native.description.trim() : void 0;
30278
30913
  const argumentHint = typeof native === "object" && typeof native.argumentHint === "string" ? native.argumentHint : void 0;
30279
30914
  const hasArg = typeof argumentHint === "string" && argumentHint.trim().length > 0;
30280
30915
  rawDescriptors.push({
30281
- id: id3,
30916
+ id: id4,
30282
30917
  invocation: `/${cleanName}`,
30283
30918
  label: humanize(cleanName).trim() || cleanName,
30284
30919
  ...desc && desc.length > 0 ? { description: desc.slice(0, 512) } : {},
30285
- argumentMode: hasArg || isQoderCompactionCommand(id3) ? "text" : "none"
30920
+ argumentMode: hasArg || isQoderCompactionCommand(id4) ? "text" : "none"
30286
30921
  });
30287
30922
  }
30288
30923
  return harnessCommandCatalogSchema.parse({
@@ -30620,10 +31255,10 @@ function mapQoderSnapshot(messages, sessionId, harnessId = qoderHarnessId) {
30620
31255
  }
30621
31256
 
30622
31257
  // ../qoder/dist/qoder-models.js
30623
- import { Buffer as Buffer2 } from "node:buffer";
30624
- var QODER_MODEL_REF_PREFIX = "qoder-model-v1.";
30625
- var QODER_MODEL_VALUE_MAX_LENGTH = 512;
30626
- var QODER_DEFAULT_MODEL_REF = encodeQoderModelRef("auto");
31258
+ function qoderModelRef(id4) {
31259
+ return harnessModelRefSchema.parse({ id: id4 });
31260
+ }
31261
+ var QODER_DEFAULT_MODEL_REF = qoderModelRef("auto");
30627
31262
  var QODER_EFFORT_LABELS = /* @__PURE__ */ new Map([
30628
31263
  ["off", "Off"],
30629
31264
  ["none", "Off"],
@@ -30634,11 +31269,11 @@ var QODER_EFFORT_LABELS = /* @__PURE__ */ new Map([
30634
31269
  ["max", "Max"]
30635
31270
  ]);
30636
31271
  var PREFERRED_EFFORT_ORDER = ["off", "none", "low", "medium", "high", "xhigh", "max"];
30637
- function effortLabel(id3) {
30638
- const standard = QODER_EFFORT_LABELS.get(id3.toLowerCase());
31272
+ function effortLabel(id4) {
31273
+ const standard = QODER_EFFORT_LABELS.get(id4.toLowerCase());
30639
31274
  if (standard)
30640
31275
  return standard;
30641
- return id3.charAt(0).toUpperCase() + id3.slice(1);
31276
+ return id4.charAt(0).toUpperCase() + id4.slice(1);
30642
31277
  }
30643
31278
  function extractModelEfforts(raw) {
30644
31279
  const effortIds = /* @__PURE__ */ new Set();
@@ -30712,7 +31347,7 @@ function extractModelEfforts(raw) {
30712
31347
  if (sorted.includes("medium")) {
30713
31348
  defaultEffortId = "medium";
30714
31349
  } else {
30715
- defaultEffortId = sorted.find((id3) => id3 !== "off" && id3 !== "none") ?? sorted[0];
31350
+ defaultEffortId = sorted.find((id4) => id4 !== "off" && id4 !== "none") ?? sorted[0];
30716
31351
  }
30717
31352
  }
30718
31353
  return {
@@ -30720,25 +31355,11 @@ function extractModelEfforts(raw) {
30720
31355
  ...defaultEffortId ? { defaultEffortId } : {}
30721
31356
  };
30722
31357
  }
30723
- function encodeQoderModelRef(value) {
30724
- const parsed = external_exports.string().trim().min(1).max(QODER_MODEL_VALUE_MAX_LENGTH).parse(value);
30725
- const id3 = `${QODER_MODEL_REF_PREFIX}${Buffer2.from(parsed, "utf8").toString("base64url")}`;
30726
- if (id3.length > HARNESS_MODEL_REF_MAX_LENGTH) {
30727
- throw new Error("Qoder Model value is too long for a Model Ref");
30728
- }
30729
- return harnessModelRefSchema.parse({ id: id3 });
31358
+ function qoderModelValue(ref) {
31359
+ return harnessModelRefSchema.safeParse(ref).data?.id;
30730
31360
  }
30731
- function decodeQoderModelRef(ref) {
30732
- const parsed = harnessModelRefSchema.safeParse(ref);
30733
- if (!parsed.success || !parsed.data.id.startsWith(QODER_MODEL_REF_PREFIX))
30734
- return void 0;
30735
- const encoded = parsed.data.id.slice(QODER_MODEL_REF_PREFIX.length);
30736
- try {
30737
- const value = Buffer2.from(encoded, "base64url").toString("utf8");
30738
- return encodeQoderModelRef(value).id === parsed.data.id ? value : void 0;
30739
- } catch {
30740
- return void 0;
30741
- }
31361
+ function normalizeStoredQoderModelRef(ref, catalog) {
31362
+ return normalizeLegacyBase64ModelRef(ref, catalog, "qoder-model-v1.");
30742
31363
  }
30743
31364
  function parseQoderModelCatalog(rawModels) {
30744
31365
  const models = [];
@@ -30751,7 +31372,7 @@ function parseQoderModelCatalog(rawModels) {
30751
31372
  for (const item of rawModels) {
30752
31373
  if (typeof item === "object" && item !== null) {
30753
31374
  const raw = item;
30754
- const value = typeof raw.value === "string" && raw.value.trim().length > 0 ? raw.value.trim() : typeof raw.modelId === "string" && raw.modelId.trim().length > 0 ? raw.modelId.trim() : typeof raw.id === "string" && raw.id.trim().length > 0 ? raw.id.trim() : void 0;
31375
+ const value = typeof raw.value === "string" && raw.value.length > 0 ? raw.value : typeof raw.modelId === "string" && raw.modelId.length > 0 ? raw.modelId : typeof raw.id === "string" ? raw.id : void 0;
30755
31376
  if (!value)
30756
31377
  continue;
30757
31378
  const labelCandidate = typeof raw.displayName === "string" && raw.displayName.trim().length > 0 ? raw.displayName.trim() : typeof raw.name === "string" && raw.name.trim().length > 0 ? raw.name.trim() : value;
@@ -30760,7 +31381,7 @@ function parseQoderModelCatalog(rawModels) {
30760
31381
  for (const effortId of supportedEffortIds) {
30761
31382
  allThinkingOptions.set(effortId, { id: effortId, label: effortLabel(effortId) });
30762
31383
  }
30763
- const ref = encodeQoderModelRef(value);
31384
+ const ref = qoderModelRef(value);
30764
31385
  if (!seenRefs.has(ref.id)) {
30765
31386
  seenRefs.add(ref.id);
30766
31387
  models.push({
@@ -30808,13 +31429,13 @@ function parseQoderModelCatalog(rawModels) {
30808
31429
  });
30809
31430
  }
30810
31431
  function qoderAvailableThinkingOptions(catalog, model2) {
30811
- if (!catalog || !model2)
31432
+ if (!catalog)
30812
31433
  return void 0;
30813
- const supported = catalog.models.find(({ ref }) => ref.id === model2.id)?.supportedThinkingOptionIds;
31434
+ const supported = catalogModelForRef(catalog, model2)?.supportedThinkingOptionIds;
30814
31435
  if (!supported || supported.length === 0)
30815
31436
  return void 0;
30816
- const options = supported.flatMap((id3) => {
30817
- const option = catalog.thinkingOptions.find((candidate) => candidate.id === id3);
31437
+ const options = supported.flatMap((id4) => {
31438
+ const option = catalog.thinkingOptions.find((candidate) => candidate.id === id4);
30818
31439
  return option ? [option] : [];
30819
31440
  });
30820
31441
  return options.length > 0 ? options : void 0;
@@ -30862,22 +31483,22 @@ var QODER_PERMISSION_MODE_CATALOG = harnessPermissionModeCatalogSchema.parse({
30862
31483
  ],
30863
31484
  defaultModeId: QODER_DEFAULT_PERMISSION_MODE_ID
30864
31485
  });
30865
- function mapToQoderPermissionMode(id3) {
30866
- if (!id3)
31486
+ function mapToQoderPermissionMode(id4) {
31487
+ if (!id4)
30867
31488
  return void 0;
30868
- const str = String(id3);
31489
+ const str = String(id4);
30869
31490
  if (str === "default" || str === "acceptEdits" || str === "bypassPermissions" || str === "yolo" || str === "plan" || str === "dontAsk" || str === "auto") {
30870
31491
  return str;
30871
31492
  }
30872
31493
  return void 0;
30873
31494
  }
30874
- function isQoderPlanModeId(id3) {
30875
- return String(id3 ?? "") === "plan";
31495
+ function isQoderPlanModeId(id4) {
31496
+ return String(id4 ?? "") === "plan";
30876
31497
  }
30877
- function mapToQoderPermissionModeExcludingPlan(id3) {
30878
- if (isQoderPlanModeId(id3))
31498
+ function mapToQoderPermissionModeExcludingPlan(id4) {
31499
+ if (isQoderPlanModeId(id4))
30879
31500
  return void 0;
30880
- return mapToQoderPermissionMode(id3);
31501
+ return mapToQoderPermissionMode(id4);
30881
31502
  }
30882
31503
 
30883
31504
  // ../qoder/dist/qoder-daemon-pool.js
@@ -31955,8 +32576,8 @@ function isValidJWT2(jwt2, alg) {
31955
32576
  const [header] = jwt2.split(".");
31956
32577
  if (!header)
31957
32578
  return false;
31958
- const base643 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
31959
- const decoded = JSON.parse(atob(base643));
32579
+ const base644 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
32580
+ const decoded = JSON.parse(atob(base644));
31960
32581
  if (typeof decoded !== "object" || decoded === null)
31961
32582
  return false;
31962
32583
  if ("typ" in decoded && decoded?.typ !== "JWT")
@@ -39135,7 +39756,7 @@ var ExperimentalServerTasks = class {
39135
39756
  if (hasPreviousToolUse) {
39136
39757
  const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
39137
39758
  const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
39138
- if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id3) => toolResultIds.has(id3))) {
39759
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id4) => toolResultIds.has(id4))) {
39139
39760
  throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
39140
39761
  }
39141
39762
  }
@@ -39560,7 +40181,7 @@ var Server = class extends Protocol {
39560
40181
  if (hasPreviousToolUse) {
39561
40182
  const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
39562
40183
  const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
39563
- if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id3) => toolResultIds.has(id3))) {
40184
+ if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id4) => toolResultIds.has(id4))) {
39564
40185
  throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
39565
40186
  }
39566
40187
  }
@@ -46225,7 +46846,7 @@ var Xn = class {
46225
46846
  };
46226
46847
  var od = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
46227
46848
  var rd = 500;
46228
- var id = 1024 * 1024;
46849
+ var id2 = 1024 * 1024;
46229
46850
  async function ad(t9) {
46230
46851
  let e = td(t9);
46231
46852
  try {
@@ -46291,7 +46912,7 @@ async function Kr(t9, e, n, s) {
46291
46912
  console.warn(`importSessionToStore: skipping non-object line in ${t9}`);
46292
46913
  continue;
46293
46914
  }
46294
- r.push(u), i += Buffer.byteLength(a), (r.length >= s || i >= id) && (await n.append(e, r), r = [], i = 0);
46915
+ r.push(u), i += Buffer.byteLength(a), (r.length >= s || i >= id2) && (await n.append(e, r), r = [], i = 0);
46295
46916
  }
46296
46917
  r.length > 0 && await n.append(e, r);
46297
46918
  }
@@ -52311,7 +52932,7 @@ var Xn2 = class {
52311
52932
  };
52312
52933
  var od2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
52313
52934
  var rd2 = 500;
52314
- var id2 = 1024 * 1024;
52935
+ var id3 = 1024 * 1024;
52315
52936
  async function ad2(t9) {
52316
52937
  let e = td2(t9);
52317
52938
  try {
@@ -52377,7 +52998,7 @@ async function Kr2(t9, e, n, s) {
52377
52998
  console.warn(`importSessionToStore: skipping non-object line in ${t9}`);
52378
52999
  continue;
52379
53000
  }
52380
- r.push(u), i += Buffer.byteLength(a), (r.length >= s || i >= id2) && (await n.append(e, r), r = [], i = 0);
53001
+ r.push(u), i += Buffer.byteLength(a), (r.length >= s || i >= id3) && (await n.append(e, r), r = [], i = 0);
52381
53002
  }
52382
53003
  r.length > 0 && await n.append(e, r);
52383
53004
  }
@@ -52638,15 +53259,16 @@ function isNonNegativeSafeInteger(value) {
52638
53259
  function isNonNegativeFinite(value) {
52639
53260
  return typeof value === "number" && Number.isFinite(value) && value >= 0;
52640
53261
  }
52641
- var QODER_DEFAULT_CONTEXT_WINDOW_TOKENS = 2e5;
52642
- function resolveQoderContextWindow(modelId2, reportedWindow) {
52643
- if (reportedWindow && reportedWindow > 0)
52644
- return reportedWindow;
52645
- if (modelId2 && /gemini/iu.test(modelId2))
52646
- return 1048576;
52647
- if (modelId2 && /gpt-5\.6/iu.test(modelId2))
52648
- return 252e3;
52649
- return QODER_DEFAULT_CONTEXT_WINDOW_TOKENS;
53262
+ function isContextWindow(value) {
53263
+ return isNonNegativeSafeInteger(value) && value > 0;
53264
+ }
53265
+ function modelAlias(modelId2) {
53266
+ const prefix = "qoder/";
53267
+ const namespaced = modelId2.startsWith(prefix);
53268
+ const id4 = namespaced ? modelId2.slice(prefix.length) : modelId2;
53269
+ if (!id4 || id4.includes("/") || /\s/u.test(id4))
53270
+ return void 0;
53271
+ return namespaced ? id4 : `${prefix}${id4}`;
52650
53272
  }
52651
53273
  function parseQoderConfiguredContextWindows(settings) {
52652
53274
  if (!settings || typeof settings !== "object")
@@ -52658,19 +53280,17 @@ function parseQoderConfiguredContextWindows(settings) {
52658
53280
  if (!model2 || typeof model2 !== "object")
52659
53281
  return void 0;
52660
53282
  const { name, preferences } = model2;
52661
- const windows = {};
53283
+ const windows = /* @__PURE__ */ Object.create(null);
52662
53284
  if (preferences && typeof preferences === "object") {
52663
53285
  for (const [modelId2, preference] of Object.entries(preferences)) {
52664
53286
  if (!preference || typeof preference !== "object")
52665
53287
  continue;
52666
53288
  const contextWindow = preference.contextWindow;
52667
- if (isNonNegativeSafeInteger(contextWindow) && contextWindow > 0) {
53289
+ if (isContextWindow(contextWindow)) {
52668
53290
  windows[modelId2] = contextWindow;
52669
53291
  }
52670
53292
  }
52671
53293
  }
52672
- if (Object.keys(windows).length === 0)
52673
- return void 0;
52674
53294
  return {
52675
53295
  ...typeof name === "string" && name.length > 0 ? { defaultModelId: name } : {},
52676
53296
  windows
@@ -52684,7 +53304,7 @@ var QoderUsageTracker = class {
52684
53304
  #totalCredits;
52685
53305
  #totalCostUsd;
52686
53306
  #contextUsagePercent;
52687
- #contextWindowTokens;
53307
+ #reportedWindow;
52688
53308
  #contextUsedTokens;
52689
53309
  #latestInputTokens;
52690
53310
  #cacheHitRatePercent;
@@ -52694,28 +53314,33 @@ var QoderUsageTracker = class {
52694
53314
  #modelId;
52695
53315
  #configuredWindows = /* @__PURE__ */ new Map();
52696
53316
  constructor(options) {
52697
- this.#contextWindowTokens = options?.contextWindowTokens && options.contextWindowTokens > 0 ? options.contextWindowTokens : resolveQoderContextWindow(options?.modelId);
52698
- this.#modelId = options?.modelId;
53317
+ this.setModel(options?.modelId);
52699
53318
  }
52700
- setModel(modelId2, catalogWindow) {
52701
- if (modelId2)
52702
- this.#modelId = modelId2;
52703
- if (catalogWindow && catalogWindow > 0) {
52704
- this.#contextWindowTokens = catalogWindow;
52705
- } else if (modelId2) {
52706
- this.#contextWindowTokens = this.#configuredWindows.get(modelId2) ?? resolveQoderContextWindow(modelId2);
53319
+ setModel(modelId2) {
53320
+ if (!modelId2 || modelId2 === this.#modelId)
53321
+ return;
53322
+ if (this.#modelId === void 0 || modelAlias(modelId2) !== this.#modelId) {
53323
+ this.#reportedWindow = void 0;
53324
+ this.#contextUsedTokens = void 0;
53325
+ this.#contextUsagePercent = void 0;
53326
+ this.#latestInputTokens = void 0;
52707
53327
  }
53328
+ this.#modelId = modelId2;
52708
53329
  }
52709
- /** Applies configured windows from `get_settings`; later `setModel` calls reuse them. */
53330
+ /** A complete settings response replaces the previous settings, not the native reading. */
52710
53331
  setConfiguredContextWindows(configured) {
52711
- for (const [modelId2, window2] of Object.entries(configured.windows)) {
52712
- if (window2 > 0)
52713
- this.#configuredWindows.set(modelId2, window2);
53332
+ this.#configuredWindows.clear();
53333
+ for (const [modelId2, window] of Object.entries(configured.windows)) {
53334
+ if (isContextWindow(window))
53335
+ this.#configuredWindows.set(modelId2, window);
52714
53336
  }
52715
53337
  this.#modelId ??= configured.defaultModelId;
52716
- const window = this.#modelId ? this.#configuredWindows.get(this.#modelId) : void 0;
52717
- if (window)
52718
- this.#contextWindowTokens = window;
53338
+ }
53339
+ #configuredWindow() {
53340
+ if (!this.#modelId)
53341
+ return void 0;
53342
+ const alias = modelAlias(this.#modelId);
53343
+ return this.#configuredWindows.get(this.#modelId) ?? (alias === void 0 ? void 0 : this.#configuredWindows.get(alias));
52719
53344
  }
52720
53345
  observeAssistant(message) {
52721
53346
  const rawUsage = message.message?.usage;
@@ -52804,8 +53429,11 @@ var QoderUsageTracker = class {
52804
53429
  if (!context || typeof context !== "object")
52805
53430
  return;
52806
53431
  const raw = context;
52807
- if (typeof raw.model === "string" && raw.model !== this.#modelId) {
52808
- this.setModel(raw.model);
53432
+ if (typeof raw.model === "string" && raw.model) {
53433
+ if (this.#modelId === void 0)
53434
+ this.#modelId = raw.model;
53435
+ else
53436
+ this.setModel(raw.model);
52809
53437
  }
52810
53438
  const contextWindow = raw.contextWindow ?? {};
52811
53439
  const percent = typeof contextWindow.usedPercentage === "number" ? contextWindow.usedPercentage : typeof raw.usedPercentage === "number" ? raw.usedPercentage : void 0;
@@ -52813,9 +53441,8 @@ var QoderUsageTracker = class {
52813
53441
  this.#contextUsagePercent = percent;
52814
53442
  }
52815
53443
  const maxTokens = typeof contextWindow.maxTokens === "number" ? contextWindow.maxTokens : typeof raw.maxTokens === "number" ? raw.maxTokens : void 0;
52816
- if (isNonNegativeSafeInteger(maxTokens) && maxTokens > 0) {
52817
- this.#contextWindowTokens = maxTokens;
52818
- }
53444
+ if (isContextWindow(maxTokens))
53445
+ this.#reportedWindow = maxTokens;
52819
53446
  const totalTokens = typeof contextWindow.totalTokens === "number" ? contextWindow.totalTokens : typeof raw.totalTokens === "number" ? raw.totalTokens : void 0;
52820
53447
  if (isNonNegativeSafeInteger(totalTokens) && totalTokens >= 0) {
52821
53448
  this.#contextUsedTokens = totalTokens;
@@ -52869,25 +53496,17 @@ var QoderUsageTracker = class {
52869
53496
  candidate.planFiveHourResetsAtUnix = this.#planFiveHourResetsAtUnix;
52870
53497
  }
52871
53498
  }
52872
- const windowTokens = this.#contextWindowTokens;
52873
- let usedTokens = this.#contextUsedTokens;
52874
- if (usedTokens === void 0 && this.#contextUsagePercent !== void 0 && windowTokens > 0) {
52875
- usedTokens = Math.round(windowTokens * this.#contextUsagePercent / 100);
52876
- } else if (usedTokens === void 0) {
52877
- usedTokens = this.#latestInputTokens;
52878
- }
52879
- if (usedTokens !== void 0 && windowTokens > 0) {
52880
- candidate.contextUsedTokens = usedTokens;
52881
- candidate.contextWindowTokens = windowTokens;
52882
- if (this.#contextUsagePercent === void 0) {
52883
- candidate.contextUsagePercent = Math.min(100, Math.max(0, usedTokens / windowTokens * 100));
52884
- } else {
52885
- candidate.contextUsagePercent = this.#contextUsagePercent;
53499
+ const percent = this.#contextUsagePercent;
53500
+ if (percent !== void 0)
53501
+ candidate.contextUsagePercent = percent;
53502
+ const windowTokens = this.#reportedWindow ?? this.#configuredWindow();
53503
+ if (windowTokens !== void 0) {
53504
+ const usedTokens = this.#contextUsedTokens ?? (percent === void 0 ? this.#latestInputTokens : Math.round(windowTokens * (percent / 100)));
53505
+ if (usedTokens !== void 0) {
53506
+ candidate.contextUsedTokens = usedTokens;
53507
+ candidate.contextWindowTokens = windowTokens;
53508
+ candidate.contextUsagePercent = percent ?? Math.min(100, usedTokens / windowTokens * 100);
52886
53509
  }
52887
- } else if (this.#contextUsagePercent !== void 0 && windowTokens > 0) {
52888
- candidate.contextUsedTokens = Math.round(windowTokens * this.#contextUsagePercent / 100);
52889
- candidate.contextWindowTokens = windowTokens;
52890
- candidate.contextUsagePercent = this.#contextUsagePercent;
52891
53510
  }
52892
53511
  if (Object.keys(candidate).length === 0)
52893
53512
  return null;
@@ -52960,8 +53579,9 @@ var QoderSession = class {
52960
53579
  #closed = false;
52961
53580
  #consumerLoopDone;
52962
53581
  #configuredContextWindows;
52963
- /** Set when a usage refresh stopped waiting for `get_settings` and used the fallback window. */
53582
+ /** Set when a usage refresh stopped waiting for `get_settings`. */
52964
53583
  #usageRefreshedWithoutSettings = false;
53584
+ #usageModelRevision = 0;
52965
53585
  constructor(options) {
52966
53586
  const variant = options.variant ?? "global";
52967
53587
  const runtime = QODER_RUNTIMES[variant];
@@ -53016,7 +53636,7 @@ var QoderSession = class {
53016
53636
  ...availableThinkingOptions && availableThinkingOptions.length > 0 ? { availableThinkingOptions } : {}
53017
53637
  };
53018
53638
  this.initialState = { ...this.#state };
53019
- const nativeModel = options.model ? decodeQoderModelRef(options.model) : void 0;
53639
+ const nativeModel = options.model ? qoderModelValue(options.model) : void 0;
53020
53640
  this.#usageTracker = new QoderUsageTracker(nativeModel ? { modelId: nativeModel } : void 0);
53021
53641
  const planMode = isQoderPlanModeId(options.permissionModeId);
53022
53642
  const permissionMode = mapToQoderPermissionModeExcludingPlan(options.permissionModeId);
@@ -53788,8 +54408,7 @@ var QoderSession = class {
53788
54408
  }
53789
54409
  /**
53790
54410
  * `get_context_usage` may report only a percentage, so read the effective per-model
53791
- * `contextWindow` from `get_settings`. Best effort: unsupported or failed requests keep the
53792
- * built-in fallback window.
54411
+ * `contextWindow` from `get_settings`. If no window is known, report only the measured usage.
53793
54412
  */
53794
54413
  #loadConfiguredContextWindows() {
53795
54414
  if (typeof this.#query.request !== "function")
@@ -53830,11 +54449,16 @@ var QoderSession = class {
53830
54449
  }
53831
54450
  }
53832
54451
  async refreshUsage(forTurnId) {
54452
+ const revision = this.#usageModelRevision;
53833
54453
  await this.#awaitConfiguredContextWindows();
54454
+ if (revision !== this.#usageModelRevision || this.#closed)
54455
+ return;
53834
54456
  let changed = false;
53835
54457
  if (this.#query.getContextUsage) {
53836
54458
  try {
53837
54459
  const usage = await this.#query.getContextUsage();
54460
+ if (revision !== this.#usageModelRevision || this.#closed)
54461
+ return;
53838
54462
  if (usage) {
53839
54463
  this.#usageTracker.observeContextUsage(usage);
53840
54464
  changed = true;
@@ -53845,6 +54469,8 @@ var QoderSession = class {
53845
54469
  if (this.#query.getUsageInfo) {
53846
54470
  try {
53847
54471
  const info = await this.#query.getUsageInfo();
54472
+ if (revision !== this.#usageModelRevision || this.#closed)
54473
+ return;
53848
54474
  if (info) {
53849
54475
  this.#usageTracker.observeUsageInfo(info);
53850
54476
  changed = true;
@@ -53852,7 +54478,7 @@ var QoderSession = class {
53852
54478
  } catch {
53853
54479
  }
53854
54480
  }
53855
- if (changed && !this.#closed) {
54481
+ if (changed && !this.#closed && revision === this.#usageModelRevision) {
53856
54482
  const snapshot = this.#usageTracker.snapshot();
53857
54483
  if (snapshot) {
53858
54484
  const targetTurnId = forTurnId ?? this.#activeTurn?.turnId;
@@ -54044,7 +54670,7 @@ var QoderSession = class {
54044
54670
  }
54045
54671
  };
54046
54672
  }
54047
- const nativeModel = decodeQoderModelRef(command.model);
54673
+ const nativeModel = qoderModelValue(command.model);
54048
54674
  if (!nativeModel) {
54049
54675
  return {
54050
54676
  ok: false,
@@ -54102,7 +54728,9 @@ var QoderSession = class {
54102
54728
  delete nextState.availableThinkingOptions;
54103
54729
  }
54104
54730
  this.#state = nextState;
54731
+ this.#usageModelRevision += 1;
54105
54732
  this.#usageTracker.setModel(nativeModel);
54733
+ this.#emitEvent({ type: "session.usage.changed", usage: this.#usageTracker.snapshot() });
54106
54734
  void this.#loadConfiguredContextWindows();
54107
54735
  void this.refreshUsage();
54108
54736
  this.#emitEvent({
@@ -54136,7 +54764,7 @@ var QoderSession = class {
54136
54764
  };
54137
54765
  }
54138
54766
  }
54139
- const nativeModel = this.#state.effectiveModel ? decodeQoderModelRef(this.#state.effectiveModel) : void 0;
54767
+ const nativeModel = this.#state.effectiveModel ? qoderModelValue(this.#state.effectiveModel) : void 0;
54140
54768
  if (this.#state.effectiveModel && !nativeModel) {
54141
54769
  return {
54142
54770
  ok: false,
@@ -54315,7 +54943,7 @@ var QoderSession = class {
54315
54943
  return { ok: true, value: { turnId: command.turnId } };
54316
54944
  }
54317
54945
  #cancelPendingInteractions(turnId, reason) {
54318
- for (const [id3, pending] of this.#pendingInteractions) {
54946
+ for (const [id4, pending] of this.#pendingInteractions) {
54319
54947
  this.#emitEvent({
54320
54948
  type: "interaction.closed",
54321
54949
  interactionId: pending.id,
@@ -54323,7 +54951,7 @@ var QoderSession = class {
54323
54951
  reason: "cancelled"
54324
54952
  });
54325
54953
  pending.resolve({ behavior: "deny", message: reason });
54326
- this.#pendingInteractions.delete(id3);
54954
+ this.#pendingInteractions.delete(id4);
54327
54955
  }
54328
54956
  }
54329
54957
  async close() {
@@ -54416,7 +55044,7 @@ var QoderSession = class {
54416
55044
  outcome
54417
55045
  });
54418
55046
  } else {
54419
- for (const [id3, pending] of this.#pendingInteractions) {
55047
+ for (const [id4, pending] of this.#pendingInteractions) {
54420
55048
  this.#emitEvent({
54421
55049
  type: "interaction.closed",
54422
55050
  interactionId: pending.id,
@@ -54424,7 +55052,7 @@ var QoderSession = class {
54424
55052
  reason: "cancelled"
54425
55053
  });
54426
55054
  pending.resolve({ behavior: "deny", message: "Session closed" });
54427
- this.#pendingInteractions.delete(id3);
55055
+ this.#pendingInteractions.delete(id4);
54428
55056
  }
54429
55057
  }
54430
55058
  if (error51)
@@ -54806,12 +55434,12 @@ async function readQoderModelLabels(configDirectory, signal) {
54806
55434
  const prefix = "modelSelector.item.";
54807
55435
  if (!key.startsWith(prefix))
54808
55436
  continue;
54809
- const id3 = key.slice(prefix.length);
54810
- if (!id3 || id3.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id3))
55437
+ const id4 = key.slice(prefix.length);
55438
+ if (!id4 || id4.length > 512 || /\.(description|markdownDescription)(\.|$)/u.test(id4))
54811
55439
  continue;
54812
55440
  if (typeof value !== "string" || !value.trim() || value.trim().length > 512)
54813
55441
  continue;
54814
- labels.set(id3, value.trim());
55442
+ labels.set(id4, value.trim());
54815
55443
  }
54816
55444
  }
54817
55445
  return Object.fromEntries(labels);
@@ -54866,12 +55494,12 @@ async function readQoderUsage(file2, signal) {
54866
55494
  cwd ??= line.cwd;
54867
55495
  if (isRecord2(line.forkedFrom) || line.isApiErrorMessage === true)
54868
55496
  continue;
54869
- const { id: id3, model: model2, usage } = line.message;
54870
- if (typeof id3 !== "string" || !id3 || model2 === "<synthetic>")
55497
+ const { id: id4, model: model2, usage } = line.message;
55498
+ if (typeof id4 !== "string" || !id4 || model2 === "<synthetic>")
54871
55499
  continue;
54872
- const message = messages.get(id3) ?? { at: null };
55500
+ const message = messages.get(id4) ?? { at: null };
54873
55501
  message.at ??= nativeTimeMs(line.timestamp);
54874
- messages.set(id3, message);
55502
+ messages.set(id4, message);
54875
55503
  if (!isRecord2(usage) || message.at === null)
54876
55504
  continue;
54877
55505
  const input = usage.input_tokens;
@@ -54886,7 +55514,7 @@ async function readQoderUsage(file2, signal) {
54886
55514
  const thinking = details?.thinking_tokens;
54887
55515
  const unreported = input === 0 && output === 0 && cached2 === 0 && written === 0;
54888
55516
  const entry = parseHarnessUsageEntry({
54889
- id: id3,
55517
+ id: id4,
54890
55518
  occurredAtMs: message.at,
54891
55519
  ...typeof model2 === "string" && model2 ? { model: model2 } : {},
54892
55520
  inputTokens: input + cached2 + written,
@@ -54918,6 +55546,7 @@ function createQoderUsageStatistics(environment, variant) {
54918
55546
 
54919
55547
  // ../qoder/dist/qoder-adapter.js
54920
55548
  var QoderAdapter = class {
55549
+ normalizeStoredModelRef = normalizeStoredQoderModelRef;
54921
55550
  harnessId;
54922
55551
  #variant;
54923
55552
  commandCatalog = QODER_FALLBACK_COMMAND_CATALOG;
@@ -55030,8 +55659,8 @@ var QoderAdapter = class {
55030
55659
  };
55031
55660
  }
55032
55661
  if (input?.refresh) {
55033
- this.#inspections.delete(cacheKey);
55034
- this.#inFlightInspections.delete(cacheKey);
55662
+ this.#inspections.clear();
55663
+ this.#inFlightInspections.clear();
55035
55664
  } else {
55036
55665
  const cached2 = this.#inspections.get(cacheKey);
55037
55666
  if (cached2)
@@ -55146,7 +55775,7 @@ var QoderAdapter = class {
55146
55775
  return task;
55147
55776
  }
55148
55777
  async open(input) {
55149
- if ("model" in input && input.model && !decodeQoderModelRef(input.model)) {
55778
+ if ("model" in input && input.model && !qoderModelValue(input.model)) {
55150
55779
  return {
55151
55780
  ok: false,
55152
55781
  error: { code: "invalidRequest", message: "Invalid Qoder Model Ref", retryable: false }
@@ -55191,8 +55820,8 @@ var QoderAdapter = class {
55191
55820
  if (input.kind === "create") {
55192
55821
  sessionId = randomUUID2();
55193
55822
  } else if (input.kind === "resume") {
55194
- const id3 = input.nativeRef?.nativeSessionId;
55195
- if (!id3 || typeof id3 !== "string" || input.nativeRef.harnessId !== this.harnessId) {
55823
+ const id4 = input.nativeRef?.nativeSessionId;
55824
+ if (!id4 || typeof id4 !== "string" || input.nativeRef.harnessId !== this.harnessId) {
55196
55825
  return {
55197
55826
  ok: false,
55198
55827
  error: {
@@ -55202,8 +55831,8 @@ var QoderAdapter = class {
55202
55831
  }
55203
55832
  };
55204
55833
  }
55205
- sessionId = id3;
55206
- openResumeId = id3;
55834
+ sessionId = id4;
55835
+ openResumeId = id4;
55207
55836
  } else if (input.kind === "fork") {
55208
55837
  const sourceRef = nativeSessionRefSchema.safeParse(input.sourceRef);
55209
55838
  const checkpoint = nativeCheckpointRefSchema.safeParse(input.checkpoint);