@codexhost/cli-linux-arm64 0.23.0 → 0.25.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 (60) hide show
  1. package/README.md +1 -1
  2. package/app/codexhost-distribution.json +1 -1
  3. package/app/console-server.mjs +3968 -4082
  4. package/app/console-web.js +6822 -2065
  5. package/app/desktop-controller.mjs +13620 -2977
  6. package/app/host-runtime.mjs +12025 -12636
  7. package/app/plugins/antigravity/plugin.mjs +2382 -1452
  8. package/app/plugins/claude-code/plugin.mjs +2248 -1645
  9. package/app/plugins/codebuddy/plugin.mjs +1753 -1215
  10. package/app/plugins/codex-usage/plugin.mjs +1214 -915
  11. package/app/plugins/copilot/plugin.mjs +1239 -919
  12. package/app/plugins/cursor-cli/plugin.mjs +1549 -1099
  13. package/app/plugins/deepseek-harness/plugin.mjs +1955 -1484
  14. package/app/plugins/devin/plugin.mjs +1295 -978
  15. package/app/plugins/grok/plugin.mjs +1772 -1482
  16. package/app/plugins/hermes/plugin.mjs +1485 -1184
  17. package/app/plugins/kimi-code/plugin.mjs +1388 -1093
  18. package/app/plugins/kiro-cli/plugin.mjs +1349 -1036
  19. package/app/plugins/omp/plugin.mjs +2027 -1420
  20. package/app/plugins/opencode/plugin.mjs +2219 -1844
  21. package/app/plugins/pi/plugin.mjs +1956 -1606
  22. package/app/plugins/qoder/plugin.mjs +1536 -1229
  23. package/app/plugins/qoder-cn/plugin.mjs +1536 -1229
  24. package/app/plugins/qwen-code/plugin.mjs +1490 -1198
  25. package/app/plugins/workbuddy/plugin.mjs +1757 -1221
  26. package/app/plugins/zcode/plugin.mjs +1841 -1072
  27. package/app/renderer-extension.js +12894 -8392
  28. package/app/web/assets/index-CTCFIQbU.css +1 -0
  29. package/app/web/assets/index-DUOvhHbV.js +203 -0
  30. package/app/web/codexhost-settings.js +4811 -36168
  31. package/app/web/index.html +2 -2
  32. package/app/web/plugins/deepseek-ai__dsh-api-remotes/client.js +64 -64
  33. package/app/web/plugins/deepseek-ai__dsh-api-session-controller/client.js +69 -69
  34. package/app/web/plugins/deepseek-ai__dsh-api-workspace-controller/client.js +1 -1
  35. package/app/web/plugins/deepseek-ai__dsh-client-shortcuts/client.js +1 -1
  36. package/app/web/plugins/deepseek-ai__dsh-client-ui-approval/client.js +1 -1
  37. package/app/web/plugins/deepseek-ai__dsh-client-ui-brand-official/client.js +1 -1
  38. package/app/web/plugins/deepseek-ai__dsh-client-ui-chat/client.js +74 -74
  39. package/app/web/plugins/deepseek-ai__dsh-client-ui-codexhost/client.js +75 -64
  40. package/app/web/plugins/deepseek-ai__dsh-client-ui-conversation/client.js +98 -95
  41. package/app/web/plugins/deepseek-ai__dsh-client-ui-input-trigger/client.js +1 -1
  42. package/app/web/plugins/deepseek-ai__dsh-client-ui-layout/client.js +2 -2
  43. package/app/web/plugins/deepseek-ai__dsh-client-ui-model-selection/client.js +2 -2
  44. package/app/web/plugins/deepseek-ai__dsh-client-ui-settings-general/client.js +1 -1
  45. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar/client.js +2 -2
  46. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-documentpreview/client.js +9 -9
  47. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-files/client.js +1 -1
  48. package/app/web/plugins/deepseek-ai__dsh-client-ui-sidebar-right/client.js +1 -1
  49. package/app/web/plugins/deepseek-ai__dsh-client-ui-theme/client.js +1 -1
  50. package/app/web/plugins/deepseek-ai__dsh-client-ui-tool/client.js +18 -18
  51. package/app/web/plugins/deepseek-ai__dsh-client-ui-user-questions/client.js +3 -3
  52. package/app/web/plugins/deepseek-ai__dsh-client-ui-workspace/client.js +9 -9
  53. package/app/web/sw.js +8 -1
  54. package/app/web-modules/server.mjs +4752 -6790
  55. package/bin/codexhost +0 -0
  56. package/libexec/codexhost-shim +0 -0
  57. package/libexec/codexhost-updater +0 -0
  58. package/package.json +1 -1
  59. package/app/web/assets/index-DJW4bmyx.css +0 -1
  60. package/app/web/assets/index-Dyh1KzAB.js +0 -201
@@ -2438,10 +2438,10 @@ var require_resolve = __commonJS({
2438
2438
  }
2439
2439
  return count2;
2440
2440
  }
2441
- function getFullPath(resolver, id = "", normalize2) {
2441
+ function getFullPath(resolver, id2 = "", normalize2) {
2442
2442
  if (normalize2 !== false)
2443
- id = normalizeId(id);
2444
- const p2 = resolver.parse(id);
2443
+ id2 = normalizeId(id2);
2444
+ const p2 = resolver.parse(id2);
2445
2445
  return _getFullPath(resolver, p2);
2446
2446
  }
2447
2447
  exports.getFullPath = getFullPath;
@@ -2451,13 +2451,13 @@ var require_resolve = __commonJS({
2451
2451
  }
2452
2452
  exports._getFullPath = _getFullPath;
2453
2453
  var TRAILING_SLASH_HASH = /#\/?$/;
2454
- function normalizeId(id) {
2455
- return id ? id.replace(TRAILING_SLASH_HASH, "") : "";
2454
+ function normalizeId(id2) {
2455
+ return id2 ? id2.replace(TRAILING_SLASH_HASH, "") : "";
2456
2456
  }
2457
2457
  exports.normalizeId = normalizeId;
2458
- function resolveUrl(resolver, baseId, id) {
2459
- id = normalizeId(id);
2460
- return resolver.resolve(baseId, id);
2458
+ function resolveUrl(resolver, baseId, id2) {
2459
+ id2 = normalizeId(id2);
2460
+ return resolver.resolve(baseId, id2);
2461
2461
  }
2462
2462
  exports.resolveUrl = resolveUrl;
2463
2463
  var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
@@ -3227,8 +3227,8 @@ var require_compile = __commonJS({
3227
3227
  if (Object.keys(root.schema).length > 0 && refPath === baseId) {
3228
3228
  return getJsonPointer.call(this, p2, root);
3229
3229
  }
3230
- const id = (0, resolve_1.normalizeId)(refPath);
3231
- const schOrRef = this.refs[id] || this.schemas[id];
3230
+ const id2 = (0, resolve_1.normalizeId)(refPath);
3231
+ const schOrRef = this.refs[id2] || this.schemas[id2];
3232
3232
  if (typeof schOrRef == "string") {
3233
3233
  const sch = resolveSchema.call(this, root, schOrRef);
3234
3234
  if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object")
@@ -3239,7 +3239,7 @@ var require_compile = __commonJS({
3239
3239
  return;
3240
3240
  if (!schOrRef.validate)
3241
3241
  compileSchema.call(this, schOrRef);
3242
- if (id === (0, resolve_1.normalizeId)(ref)) {
3242
+ if (id2 === (0, resolve_1.normalizeId)(ref)) {
3243
3243
  const { schema } = schOrRef;
3244
3244
  const { schemaId } = this.opts;
3245
3245
  const schId = schema[schemaId];
@@ -3315,27 +3315,27 @@ var require_utils = __commonJS({
3315
3315
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3316
3316
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3317
3317
  var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3318
- function stringArrayToHexStripped(input) {
3318
+ function stringArrayToHexStripped(input2) {
3319
3319
  let acc = "";
3320
3320
  let code = 0;
3321
3321
  let i = 0;
3322
- for (i = 0; i < input.length; i++) {
3323
- code = input[i].charCodeAt(0);
3322
+ for (i = 0; i < input2.length; i++) {
3323
+ code = input2[i].charCodeAt(0);
3324
3324
  if (code === 48) {
3325
3325
  continue;
3326
3326
  }
3327
3327
  if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
3328
3328
  return "";
3329
3329
  }
3330
- acc += input[i];
3330
+ acc += input2[i];
3331
3331
  break;
3332
3332
  }
3333
- for (i += 1; i < input.length; i++) {
3334
- code = input[i].charCodeAt(0);
3333
+ for (i += 1; i < input2.length; i++) {
3334
+ code = input2[i].charCodeAt(0);
3335
3335
  if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) {
3336
3336
  return "";
3337
3337
  }
3338
- acc += input[i];
3338
+ acc += input2[i];
3339
3339
  }
3340
3340
  return acc;
3341
3341
  }
@@ -3357,7 +3357,7 @@ var require_utils = __commonJS({
3357
3357
  }
3358
3358
  return true;
3359
3359
  }
3360
- function getIPV6(input) {
3360
+ function getIPV6(input2) {
3361
3361
  let tokenCount = 0;
3362
3362
  const output = { error: false, address: "", zone: "" };
3363
3363
  const address = [];
@@ -3365,8 +3365,8 @@ var require_utils = __commonJS({
3365
3365
  let endipv6Encountered = false;
3366
3366
  let endIpv6 = false;
3367
3367
  let consume = consumeHextets;
3368
- for (let i = 0; i < input.length; i++) {
3369
- const cursor = input[i];
3368
+ for (let i = 0; i < input2.length; i++) {
3369
+ const cursor = input2[i];
3370
3370
  if (cursor === "[" || cursor === "]") {
3371
3371
  continue;
3372
3372
  }
@@ -3381,7 +3381,7 @@ var require_utils = __commonJS({
3381
3381
  output.error = true;
3382
3382
  break;
3383
3383
  }
3384
- if (i > 0 && input[i - 1] === ":") {
3384
+ if (i > 0 && input2[i - 1] === ":") {
3385
3385
  endipv6Encountered = true;
3386
3386
  }
3387
3387
  address.push(":");
@@ -3433,37 +3433,37 @@ var require_utils = __commonJS({
3433
3433
  return ind;
3434
3434
  }
3435
3435
  function removeDotSegments(path6) {
3436
- let input = path6;
3436
+ let input2 = path6;
3437
3437
  const output = [];
3438
3438
  let nextSlash = -1;
3439
3439
  let len = 0;
3440
- while (len = input.length) {
3440
+ while (len = input2.length) {
3441
3441
  if (len === 1) {
3442
- if (input === ".") {
3442
+ if (input2 === ".") {
3443
3443
  break;
3444
- } else if (input === "/") {
3444
+ } else if (input2 === "/") {
3445
3445
  output.push("/");
3446
3446
  break;
3447
3447
  } else {
3448
- output.push(input);
3448
+ output.push(input2);
3449
3449
  break;
3450
3450
  }
3451
3451
  } else if (len === 2) {
3452
- if (input[0] === ".") {
3453
- if (input[1] === ".") {
3452
+ if (input2[0] === ".") {
3453
+ if (input2[1] === ".") {
3454
3454
  break;
3455
- } else if (input[1] === "/") {
3456
- input = input.slice(2);
3455
+ } else if (input2[1] === "/") {
3456
+ input2 = input2.slice(2);
3457
3457
  continue;
3458
3458
  }
3459
- } else if (input[0] === "/") {
3460
- if (input[1] === "." || input[1] === "/") {
3459
+ } else if (input2[0] === "/") {
3460
+ if (input2[1] === "." || input2[1] === "/") {
3461
3461
  output.push("/");
3462
3462
  break;
3463
3463
  }
3464
3464
  }
3465
3465
  } else if (len === 3) {
3466
- if (input === "/..") {
3466
+ if (input2 === "/..") {
3467
3467
  if (output.length !== 0) {
3468
3468
  output.pop();
3469
3469
  }
@@ -3471,24 +3471,24 @@ var require_utils = __commonJS({
3471
3471
  break;
3472
3472
  }
3473
3473
  }
3474
- if (input[0] === ".") {
3475
- if (input[1] === ".") {
3476
- if (input[2] === "/") {
3477
- input = input.slice(3);
3474
+ if (input2[0] === ".") {
3475
+ if (input2[1] === ".") {
3476
+ if (input2[2] === "/") {
3477
+ input2 = input2.slice(3);
3478
3478
  continue;
3479
3479
  }
3480
- } else if (input[1] === "/") {
3481
- input = input.slice(2);
3480
+ } else if (input2[1] === "/") {
3481
+ input2 = input2.slice(2);
3482
3482
  continue;
3483
3483
  }
3484
- } else if (input[0] === "/") {
3485
- if (input[1] === ".") {
3486
- if (input[2] === "/") {
3487
- input = input.slice(2);
3484
+ } else if (input2[0] === "/") {
3485
+ if (input2[1] === ".") {
3486
+ if (input2[2] === "/") {
3487
+ input2 = input2.slice(2);
3488
3488
  continue;
3489
- } else if (input[2] === ".") {
3490
- if (input[3] === "/") {
3491
- input = input.slice(3);
3489
+ } else if (input2[2] === ".") {
3490
+ if (input2[3] === "/") {
3491
+ input2 = input2.slice(3);
3492
3492
  if (output.length !== 0) {
3493
3493
  output.pop();
3494
3494
  }
@@ -3497,12 +3497,12 @@ var require_utils = __commonJS({
3497
3497
  }
3498
3498
  }
3499
3499
  }
3500
- if ((nextSlash = input.indexOf("/", 1)) === -1) {
3501
- output.push(input);
3500
+ if ((nextSlash = input2.indexOf("/", 1)) === -1) {
3501
+ output.push(input2);
3502
3502
  break;
3503
3503
  } else {
3504
- output.push(input.slice(0, nextSlash));
3505
- input = input.slice(nextSlash);
3504
+ output.push(input2.slice(0, nextSlash));
3505
+ input2 = input2.slice(nextSlash);
3506
3506
  }
3507
3507
  }
3508
3508
  return output.join("");
@@ -3515,14 +3515,14 @@ var require_utils = __commonJS({
3515
3515
  re2.lastIndex = 0;
3516
3516
  return host.replace(re2, (ch) => HOST_DELIMS[ch]);
3517
3517
  }
3518
- function normalizePercentEncoding(input, decodeUnreserved = false) {
3519
- if (input.indexOf("%") === -1) {
3520
- return input;
3518
+ function normalizePercentEncoding(input2, decodeUnreserved = false) {
3519
+ if (input2.indexOf("%") === -1) {
3520
+ return input2;
3521
3521
  }
3522
3522
  let output = "";
3523
- for (let i = 0; i < input.length; i++) {
3524
- if (input[i] === "%" && i + 2 < input.length) {
3525
- const hex3 = input.slice(i + 1, i + 3);
3523
+ for (let i = 0; i < input2.length; i++) {
3524
+ if (input2[i] === "%" && i + 2 < input2.length) {
3525
+ const hex3 = input2.slice(i + 1, i + 3);
3526
3526
  if (isHexPair(hex3)) {
3527
3527
  const normalizedHex = hex3.toUpperCase();
3528
3528
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
@@ -3535,15 +3535,15 @@ var require_utils = __commonJS({
3535
3535
  continue;
3536
3536
  }
3537
3537
  }
3538
- output += input[i];
3538
+ output += input2[i];
3539
3539
  }
3540
3540
  return output;
3541
3541
  }
3542
- function normalizePathEncoding(input) {
3542
+ function normalizePathEncoding(input2) {
3543
3543
  let output = "";
3544
- for (let i = 0; i < input.length; i++) {
3545
- if (input[i] === "%" && i + 2 < input.length) {
3546
- const hex3 = input.slice(i + 1, i + 3);
3544
+ for (let i = 0; i < input2.length; i++) {
3545
+ if (input2[i] === "%" && i + 2 < input2.length) {
3546
+ const hex3 = input2.slice(i + 1, i + 3);
3547
3547
  if (isHexPair(hex3)) {
3548
3548
  const normalizedHex = hex3.toUpperCase();
3549
3549
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
@@ -3556,26 +3556,26 @@ var require_utils = __commonJS({
3556
3556
  continue;
3557
3557
  }
3558
3558
  }
3559
- if (isPathCharacter(input[i])) {
3560
- output += input[i];
3559
+ if (isPathCharacter(input2[i])) {
3560
+ output += input2[i];
3561
3561
  } else {
3562
- output += escape(input[i]);
3562
+ output += escape(input2[i]);
3563
3563
  }
3564
3564
  }
3565
3565
  return output;
3566
3566
  }
3567
- function escapePreservingEscapes(input) {
3567
+ function escapePreservingEscapes(input2) {
3568
3568
  let output = "";
3569
- for (let i = 0; i < input.length; i++) {
3570
- if (input[i] === "%" && i + 2 < input.length) {
3571
- const hex3 = input.slice(i + 1, i + 3);
3569
+ for (let i = 0; i < input2.length; i++) {
3570
+ if (input2[i] === "%" && i + 2 < input2.length) {
3571
+ const hex3 = input2.slice(i + 1, i + 3);
3572
3572
  if (isHexPair(hex3)) {
3573
3573
  output += "%" + hex3.toUpperCase();
3574
3574
  i += 2;
3575
3575
  continue;
3576
3576
  }
3577
3577
  }
3578
- output += escape(input[i]);
3578
+ output += escape(input2[i]);
3579
3579
  }
3580
3580
  return output;
3581
3581
  }
@@ -4362,15 +4362,15 @@ var require_core = __commonJS({
4362
4362
  this.addSchema(sch, void 0, _meta, _validateSchema);
4363
4363
  return this;
4364
4364
  }
4365
- let id;
4365
+ let id2;
4366
4366
  if (typeof schema === "object") {
4367
4367
  const { schemaId } = this.opts;
4368
- id = schema[schemaId];
4369
- if (id !== void 0 && typeof id != "string") {
4368
+ id2 = schema[schemaId];
4369
+ if (id2 !== void 0 && typeof id2 != "string") {
4370
4370
  throw new Error(`schema ${schemaId} must be string`);
4371
4371
  }
4372
4372
  }
4373
- key = (0, resolve_1.normalizeId)(key || id);
4373
+ key = (0, resolve_1.normalizeId)(key || id2);
4374
4374
  this._checkUnique(key);
4375
4375
  this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
4376
4376
  return this;
@@ -4449,11 +4449,11 @@ var require_core = __commonJS({
4449
4449
  case "object": {
4450
4450
  const cacheKey = schemaKeyRef;
4451
4451
  this._cache.delete(cacheKey);
4452
- let id = schemaKeyRef[this.opts.schemaId];
4453
- if (id) {
4454
- id = (0, resolve_1.normalizeId)(id);
4455
- delete this.schemas[id];
4456
- delete this.refs[id];
4452
+ let id2 = schemaKeyRef[this.opts.schemaId];
4453
+ if (id2) {
4454
+ id2 = (0, resolve_1.normalizeId)(id2);
4455
+ delete this.schemas[id2];
4456
+ delete this.refs[id2];
4457
4457
  }
4458
4458
  return this;
4459
4459
  }
@@ -4524,7 +4524,7 @@ var require_core = __commonJS({
4524
4524
  errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
4525
4525
  if (!errors || errors.length === 0)
4526
4526
  return "No errors";
4527
- return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
4527
+ return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text2, msg) => text2 + separator + msg);
4528
4528
  }
4529
4529
  $dataMetaSchema(metaSchema, keywordsJsonPointers) {
4530
4530
  const rules = this.RULES.all;
@@ -4560,10 +4560,10 @@ var require_core = __commonJS({
4560
4560
  }
4561
4561
  }
4562
4562
  _addSchema(schema, meta3, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
4563
- let id;
4563
+ let id2;
4564
4564
  const { schemaId } = this.opts;
4565
4565
  if (typeof schema == "object") {
4566
- id = schema[schemaId];
4566
+ id2 = schema[schemaId];
4567
4567
  } else {
4568
4568
  if (this.opts.jtd)
4569
4569
  throw new Error("schema must be object");
@@ -4573,7 +4573,7 @@ var require_core = __commonJS({
4573
4573
  let sch = this._cache.get(schema);
4574
4574
  if (sch !== void 0)
4575
4575
  return sch;
4576
- baseId = (0, resolve_1.normalizeId)(id || baseId);
4576
+ baseId = (0, resolve_1.normalizeId)(id2 || baseId);
4577
4577
  const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
4578
4578
  sch = new compile_1.SchemaEnv({ schema, schemaId, meta: meta3, baseId, localRefs });
4579
4579
  this._cache.set(sch.schema, sch);
@@ -4586,9 +4586,9 @@ var require_core = __commonJS({
4586
4586
  this.validateSchema(schema, true);
4587
4587
  return sch;
4588
4588
  }
4589
- _checkUnique(id) {
4590
- if (this.schemas[id] || this.refs[id]) {
4591
- throw new Error(`schema with key or id "${id}" already exists`);
4589
+ _checkUnique(id2) {
4590
+ if (this.schemas[id2] || this.refs[id2]) {
4591
+ throw new Error(`schema with key or id "${id2}" already exists`);
4592
4592
  }
4593
4593
  }
4594
4594
  _compileSchemaEnv(sch) {
@@ -7604,8 +7604,8 @@ function cached(getter) {
7604
7604
  }
7605
7605
  };
7606
7606
  }
7607
- function nullish(input) {
7608
- return input === null || input === void 0;
7607
+ function nullish(input2) {
7608
+ return input2 === null || input2 === void 0;
7609
7609
  }
7610
7610
  function cleanRegex(source) {
7611
7611
  const start = source.startsWith("^") ? 1 : 0;
@@ -7692,8 +7692,8 @@ function randomString(length = 10) {
7692
7692
  function esc(str) {
7693
7693
  return JSON.stringify(str);
7694
7694
  }
7695
- function slugify(input) {
7696
- return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
7695
+ function slugify(input2) {
7696
+ return input2.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
7697
7697
  }
7698
7698
  var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
7699
7699
  };
@@ -8098,19 +8098,19 @@ function finalizeIssue(iss, ctx, config2) {
8098
8098
  }
8099
8099
  return rest;
8100
8100
  }
8101
- function getSizableOrigin(input) {
8102
- if (input instanceof Set)
8101
+ function getSizableOrigin(input2) {
8102
+ if (input2 instanceof Set)
8103
8103
  return "set";
8104
- if (input instanceof Map)
8104
+ if (input2 instanceof Map)
8105
8105
  return "map";
8106
- if (input instanceof File)
8106
+ if (input2 instanceof File)
8107
8107
  return "file";
8108
8108
  return "unknown";
8109
8109
  }
8110
- function getLengthableOrigin(input) {
8111
- if (Array.isArray(input))
8110
+ function getLengthableOrigin(input2) {
8111
+ if (Array.isArray(input2))
8112
8112
  return "array";
8113
- if (typeof input === "string")
8113
+ if (typeof input2 === "string")
8114
8114
  return "string";
8115
8115
  return "unknown";
8116
8116
  }
@@ -8136,12 +8136,12 @@ function parsedType(data) {
8136
8136
  return t;
8137
8137
  }
8138
8138
  function issue(...args) {
8139
- const [iss, input, inst] = args;
8139
+ const [iss, input2, inst] = args;
8140
8140
  if (typeof iss === "string") {
8141
8141
  return {
8142
8142
  message: iss,
8143
8143
  code: "custom",
8144
- input,
8144
+ input: input2,
8145
8145
  inst
8146
8146
  };
8147
8147
  }
@@ -8152,8 +8152,8 @@ function cleanEnum(obj) {
8152
8152
  return Number.isNaN(Number.parseInt(k, 10));
8153
8153
  }).map((el) => el[1]);
8154
8154
  }
8155
- function base64ToUint8Array(base643) {
8156
- const binaryString = atob(base643);
8155
+ function base64ToUint8Array(base644) {
8156
+ const binaryString = atob(base644);
8157
8157
  const bytes = new Uint8Array(binaryString.length);
8158
8158
  for (let i = 0; i < binaryString.length; i++) {
8159
8159
  bytes[i] = binaryString.charCodeAt(i);
@@ -8168,9 +8168,9 @@ function uint8ArrayToBase64(bytes) {
8168
8168
  return btoa(binaryString);
8169
8169
  }
8170
8170
  function base64urlToUint8Array(base64url3) {
8171
- const base643 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
8172
- const padding = "=".repeat((4 - base643.length % 4) % 4);
8173
- return base64ToUint8Array(base643 + padding);
8171
+ const base644 = base64url3.replace(/-/g, "+").replace(/_/g, "/");
8172
+ const padding = "=".repeat((4 - base644.length % 4) % 4);
8173
+ return base64ToUint8Array(base644 + padding);
8174
8174
  }
8175
8175
  function uint8ArrayToBase64url(bytes) {
8176
8176
  return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
@@ -8685,23 +8685,23 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8685
8685
  bag.pattern = integer;
8686
8686
  });
8687
8687
  inst._zod.check = (payload) => {
8688
- const input = payload.value;
8688
+ const input2 = payload.value;
8689
8689
  if (isInt) {
8690
- if (!Number.isInteger(input)) {
8690
+ if (!Number.isInteger(input2)) {
8691
8691
  payload.issues.push({
8692
8692
  expected: origin,
8693
8693
  format: def.format,
8694
8694
  code: "invalid_type",
8695
8695
  continue: false,
8696
- input,
8696
+ input: input2,
8697
8697
  inst
8698
8698
  });
8699
8699
  return;
8700
8700
  }
8701
- if (!Number.isSafeInteger(input)) {
8702
- if (input > 0) {
8701
+ if (!Number.isSafeInteger(input2)) {
8702
+ if (input2 > 0) {
8703
8703
  payload.issues.push({
8704
- input,
8704
+ input: input2,
8705
8705
  code: "too_big",
8706
8706
  maximum: Number.MAX_SAFE_INTEGER,
8707
8707
  note: "Integers must be within the safe integer range.",
@@ -8712,7 +8712,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8712
8712
  });
8713
8713
  } else {
8714
8714
  payload.issues.push({
8715
- input,
8715
+ input: input2,
8716
8716
  code: "too_small",
8717
8717
  minimum: Number.MIN_SAFE_INTEGER,
8718
8718
  note: "Integers must be within the safe integer range.",
@@ -8725,10 +8725,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8725
8725
  return;
8726
8726
  }
8727
8727
  }
8728
- if (input < minimum) {
8728
+ if (input2 < minimum) {
8729
8729
  payload.issues.push({
8730
8730
  origin: "number",
8731
- input,
8731
+ input: input2,
8732
8732
  code: "too_small",
8733
8733
  minimum,
8734
8734
  inclusive: true,
@@ -8736,10 +8736,10 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
8736
8736
  continue: !def.abort
8737
8737
  });
8738
8738
  }
8739
- if (input > maximum) {
8739
+ if (input2 > maximum) {
8740
8740
  payload.issues.push({
8741
8741
  origin: "number",
8742
- input,
8742
+ input: input2,
8743
8743
  code: "too_big",
8744
8744
  maximum,
8745
8745
  inclusive: true,
@@ -8759,11 +8759,11 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
8759
8759
  bag.maximum = maximum;
8760
8760
  });
8761
8761
  inst._zod.check = (payload) => {
8762
- const input = payload.value;
8763
- if (input < minimum) {
8762
+ const input2 = payload.value;
8763
+ if (input2 < minimum) {
8764
8764
  payload.issues.push({
8765
8765
  origin: "bigint",
8766
- input,
8766
+ input: input2,
8767
8767
  code: "too_small",
8768
8768
  minimum,
8769
8769
  inclusive: true,
@@ -8771,10 +8771,10 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
8771
8771
  continue: !def.abort
8772
8772
  });
8773
8773
  }
8774
- if (input > maximum) {
8774
+ if (input2 > maximum) {
8775
8775
  payload.issues.push({
8776
8776
  origin: "bigint",
8777
- input,
8777
+ input: input2,
8778
8778
  code: "too_big",
8779
8779
  maximum,
8780
8780
  inclusive: true,
@@ -8797,16 +8797,16 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
8797
8797
  inst2._zod.bag.maximum = def.maximum;
8798
8798
  });
8799
8799
  inst._zod.check = (payload) => {
8800
- const input = payload.value;
8801
- const size = input.size;
8800
+ const input2 = payload.value;
8801
+ const size = input2.size;
8802
8802
  if (size <= def.maximum)
8803
8803
  return;
8804
8804
  payload.issues.push({
8805
- origin: getSizableOrigin(input),
8805
+ origin: getSizableOrigin(input2),
8806
8806
  code: "too_big",
8807
8807
  maximum: def.maximum,
8808
8808
  inclusive: true,
8809
- input,
8809
+ input: input2,
8810
8810
  inst,
8811
8811
  continue: !def.abort
8812
8812
  });
@@ -8825,16 +8825,16 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
8825
8825
  inst2._zod.bag.minimum = def.minimum;
8826
8826
  });
8827
8827
  inst._zod.check = (payload) => {
8828
- const input = payload.value;
8829
- const size = input.size;
8828
+ const input2 = payload.value;
8829
+ const size = input2.size;
8830
8830
  if (size >= def.minimum)
8831
8831
  return;
8832
8832
  payload.issues.push({
8833
- origin: getSizableOrigin(input),
8833
+ origin: getSizableOrigin(input2),
8834
8834
  code: "too_small",
8835
8835
  minimum: def.minimum,
8836
8836
  inclusive: true,
8837
- input,
8837
+ input: input2,
8838
8838
  inst,
8839
8839
  continue: !def.abort
8840
8840
  });
@@ -8854,13 +8854,13 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
8854
8854
  bag.size = def.size;
8855
8855
  });
8856
8856
  inst._zod.check = (payload) => {
8857
- const input = payload.value;
8858
- const size = input.size;
8857
+ const input2 = payload.value;
8858
+ const size = input2.size;
8859
8859
  if (size === def.size)
8860
8860
  return;
8861
8861
  const tooBig = size > def.size;
8862
8862
  payload.issues.push({
8863
- origin: getSizableOrigin(input),
8863
+ origin: getSizableOrigin(input2),
8864
8864
  ...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
8865
8865
  inclusive: true,
8866
8866
  exact: true,
@@ -8883,17 +8883,17 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
8883
8883
  inst2._zod.bag.maximum = def.maximum;
8884
8884
  });
8885
8885
  inst._zod.check = (payload) => {
8886
- const input = payload.value;
8887
- const length = input.length;
8886
+ const input2 = payload.value;
8887
+ const length = input2.length;
8888
8888
  if (length <= def.maximum)
8889
8889
  return;
8890
- const origin = getLengthableOrigin(input);
8890
+ const origin = getLengthableOrigin(input2);
8891
8891
  payload.issues.push({
8892
8892
  origin,
8893
8893
  code: "too_big",
8894
8894
  maximum: def.maximum,
8895
8895
  inclusive: true,
8896
- input,
8896
+ input: input2,
8897
8897
  inst,
8898
8898
  continue: !def.abort
8899
8899
  });
@@ -8912,17 +8912,17 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
8912
8912
  inst2._zod.bag.minimum = def.minimum;
8913
8913
  });
8914
8914
  inst._zod.check = (payload) => {
8915
- const input = payload.value;
8916
- const length = input.length;
8915
+ const input2 = payload.value;
8916
+ const length = input2.length;
8917
8917
  if (length >= def.minimum)
8918
8918
  return;
8919
- const origin = getLengthableOrigin(input);
8919
+ const origin = getLengthableOrigin(input2);
8920
8920
  payload.issues.push({
8921
8921
  origin,
8922
8922
  code: "too_small",
8923
8923
  minimum: def.minimum,
8924
8924
  inclusive: true,
8925
- input,
8925
+ input: input2,
8926
8926
  inst,
8927
8927
  continue: !def.abort
8928
8928
  });
@@ -8942,11 +8942,11 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
8942
8942
  bag.length = def.length;
8943
8943
  });
8944
8944
  inst._zod.check = (payload) => {
8945
- const input = payload.value;
8946
- const length = input.length;
8945
+ const input2 = payload.value;
8946
+ const length = input2.length;
8947
8947
  if (length === def.length)
8948
8948
  return;
8949
- const origin = getLengthableOrigin(input);
8949
+ const origin = getLengthableOrigin(input2);
8950
8950
  const tooBig = length > def.length;
8951
8951
  payload.issues.push({
8952
8952
  origin,
@@ -9536,8 +9536,8 @@ var $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
9536
9536
  function isValidBase64URL(data) {
9537
9537
  if (!base64url.test(data))
9538
9538
  return false;
9539
- const base643 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
9540
- const padded = base643.padEnd(Math.ceil(base643.length / 4) * 4, "=");
9539
+ const base644 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
9540
+ const padded = base644.padEnd(Math.ceil(base644.length / 4) * 4, "=");
9541
9541
  return isValidBase64(padded);
9542
9542
  }
9543
9543
  var $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
@@ -9617,15 +9617,15 @@ var $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
9617
9617
  payload.value = Number(payload.value);
9618
9618
  } catch (_) {
9619
9619
  }
9620
- const input = payload.value;
9621
- if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) {
9620
+ const input2 = payload.value;
9621
+ if (typeof input2 === "number" && !Number.isNaN(input2) && Number.isFinite(input2)) {
9622
9622
  return payload;
9623
9623
  }
9624
- const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
9624
+ const received = typeof input2 === "number" ? Number.isNaN(input2) ? "NaN" : !Number.isFinite(input2) ? "Infinity" : void 0 : void 0;
9625
9625
  payload.issues.push({
9626
9626
  expected: "number",
9627
9627
  code: "invalid_type",
9628
- input,
9628
+ input: input2,
9629
9629
  inst,
9630
9630
  ...received ? { received } : {}
9631
9631
  });
@@ -9645,13 +9645,13 @@ var $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
9645
9645
  payload.value = Boolean(payload.value);
9646
9646
  } catch (_) {
9647
9647
  }
9648
- const input = payload.value;
9649
- if (typeof input === "boolean")
9648
+ const input2 = payload.value;
9649
+ if (typeof input2 === "boolean")
9650
9650
  return payload;
9651
9651
  payload.issues.push({
9652
9652
  expected: "boolean",
9653
9653
  code: "invalid_type",
9654
- input,
9654
+ input: input2,
9655
9655
  inst
9656
9656
  });
9657
9657
  return payload;
@@ -9684,13 +9684,13 @@ var $ZodBigIntFormat = /* @__PURE__ */ $constructor("$ZodBigIntFormat", (inst, d
9684
9684
  var $ZodSymbol = /* @__PURE__ */ $constructor("$ZodSymbol", (inst, def) => {
9685
9685
  $ZodType.init(inst, def);
9686
9686
  inst._zod.parse = (payload, _ctx) => {
9687
- const input = payload.value;
9688
- if (typeof input === "symbol")
9687
+ const input2 = payload.value;
9688
+ if (typeof input2 === "symbol")
9689
9689
  return payload;
9690
9690
  payload.issues.push({
9691
9691
  expected: "symbol",
9692
9692
  code: "invalid_type",
9693
- input,
9693
+ input: input2,
9694
9694
  inst
9695
9695
  });
9696
9696
  return payload;
@@ -9701,13 +9701,13 @@ var $ZodUndefined = /* @__PURE__ */ $constructor("$ZodUndefined", (inst, def) =>
9701
9701
  inst._zod.pattern = _undefined;
9702
9702
  inst._zod.values = /* @__PURE__ */ new Set([void 0]);
9703
9703
  inst._zod.parse = (payload, _ctx) => {
9704
- const input = payload.value;
9705
- if (typeof input === "undefined")
9704
+ const input2 = payload.value;
9705
+ if (typeof input2 === "undefined")
9706
9706
  return payload;
9707
9707
  payload.issues.push({
9708
9708
  expected: "undefined",
9709
9709
  code: "invalid_type",
9710
- input,
9710
+ input: input2,
9711
9711
  inst
9712
9712
  });
9713
9713
  return payload;
@@ -9718,13 +9718,13 @@ var $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
9718
9718
  inst._zod.pattern = _null;
9719
9719
  inst._zod.values = /* @__PURE__ */ new Set([null]);
9720
9720
  inst._zod.parse = (payload, _ctx) => {
9721
- const input = payload.value;
9722
- if (input === null)
9721
+ const input2 = payload.value;
9722
+ if (input2 === null)
9723
9723
  return payload;
9724
9724
  payload.issues.push({
9725
9725
  expected: "null",
9726
9726
  code: "invalid_type",
9727
- input,
9727
+ input: input2,
9728
9728
  inst
9729
9729
  });
9730
9730
  return payload;
@@ -9753,13 +9753,13 @@ var $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
9753
9753
  var $ZodVoid = /* @__PURE__ */ $constructor("$ZodVoid", (inst, def) => {
9754
9754
  $ZodType.init(inst, def);
9755
9755
  inst._zod.parse = (payload, _ctx) => {
9756
- const input = payload.value;
9757
- if (typeof input === "undefined")
9756
+ const input2 = payload.value;
9757
+ if (typeof input2 === "undefined")
9758
9758
  return payload;
9759
9759
  payload.issues.push({
9760
9760
  expected: "void",
9761
9761
  code: "invalid_type",
9762
- input,
9762
+ input: input2,
9763
9763
  inst
9764
9764
  });
9765
9765
  return payload;
@@ -9774,15 +9774,15 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
9774
9774
  } catch (_err) {
9775
9775
  }
9776
9776
  }
9777
- const input = payload.value;
9778
- const isDate = input instanceof Date;
9779
- const isValidDate = isDate && !Number.isNaN(input.getTime());
9777
+ const input2 = payload.value;
9778
+ const isDate = input2 instanceof Date;
9779
+ const isValidDate = isDate && !Number.isNaN(input2.getTime());
9780
9780
  if (isValidDate)
9781
9781
  return payload;
9782
9782
  payload.issues.push({
9783
9783
  expected: "date",
9784
9784
  code: "invalid_type",
9785
- input,
9785
+ input: input2,
9786
9786
  ...isDate ? { received: "Invalid Date" } : {},
9787
9787
  inst
9788
9788
  });
@@ -9798,20 +9798,20 @@ function handleArrayResult(result, final, index) {
9798
9798
  var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
9799
9799
  $ZodType.init(inst, def);
9800
9800
  inst._zod.parse = (payload, ctx) => {
9801
- const input = payload.value;
9802
- if (!Array.isArray(input)) {
9801
+ const input2 = payload.value;
9802
+ if (!Array.isArray(input2)) {
9803
9803
  payload.issues.push({
9804
9804
  expected: "array",
9805
9805
  code: "invalid_type",
9806
- input,
9806
+ input: input2,
9807
9807
  inst
9808
9808
  });
9809
9809
  return payload;
9810
9810
  }
9811
- payload.value = Array(input.length);
9811
+ payload.value = Array(input2.length);
9812
9812
  const proms = [];
9813
- for (let i = 0; i < input.length; i++) {
9814
- const item = input[i];
9813
+ for (let i = 0; i < input2.length; i++) {
9814
+ const item = input2[i];
9815
9815
  const result = def.element._zod.run({
9816
9816
  value: item,
9817
9817
  issues: []
@@ -9828,8 +9828,8 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
9828
9828
  return payload;
9829
9829
  };
9830
9830
  });
9831
- function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
9832
- const isPresent = key in input;
9831
+ function handlePropertyResult(result, final, key, input2, isOptionalIn, isOptionalOut) {
9832
+ const isPresent = key in input2;
9833
9833
  if (result.issues.length) {
9834
9834
  if (isOptionalIn && isOptionalOut && !isPresent) {
9835
9835
  return;
@@ -9871,14 +9871,14 @@ function normalizeDef(def) {
9871
9871
  optionalKeys: new Set(okeys)
9872
9872
  };
9873
9873
  }
9874
- function handleCatchall(proms, input, payload, ctx, def, inst) {
9874
+ function handleCatchall(proms, input2, payload, ctx, def, inst) {
9875
9875
  const unrecognized = [];
9876
9876
  const keySet = def.keySet;
9877
9877
  const _catchall = def.catchall._zod;
9878
9878
  const t = _catchall.def.type;
9879
9879
  const isOptionalIn = _catchall.optin === "optional";
9880
9880
  const isOptionalOut = _catchall.optout === "optional";
9881
- for (const key in input) {
9881
+ for (const key in input2) {
9882
9882
  if (key === "__proto__")
9883
9883
  continue;
9884
9884
  if (keySet.has(key))
@@ -9887,18 +9887,18 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
9887
9887
  unrecognized.push(key);
9888
9888
  continue;
9889
9889
  }
9890
- const r = _catchall.run({ value: input[key], issues: [] }, ctx);
9890
+ const r = _catchall.run({ value: input2[key], issues: [] }, ctx);
9891
9891
  if (r instanceof Promise) {
9892
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
9892
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
9893
9893
  } else {
9894
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
9894
+ handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
9895
9895
  }
9896
9896
  }
9897
9897
  if (unrecognized.length) {
9898
9898
  payload.issues.push({
9899
9899
  code: "unrecognized_keys",
9900
9900
  keys: unrecognized,
9901
- input,
9901
+ input: input2,
9902
9902
  inst
9903
9903
  });
9904
9904
  }
@@ -9942,12 +9942,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9942
9942
  let value;
9943
9943
  inst._zod.parse = (payload, ctx) => {
9944
9944
  value ?? (value = _normalized.value);
9945
- const input = payload.value;
9946
- if (!isObject2(input)) {
9945
+ const input2 = payload.value;
9946
+ if (!isObject2(input2)) {
9947
9947
  payload.issues.push({
9948
9948
  expected: "object",
9949
9949
  code: "invalid_type",
9950
- input,
9950
+ input: input2,
9951
9951
  inst
9952
9952
  });
9953
9953
  return payload;
@@ -9959,17 +9959,17 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
9959
9959
  const el = shape[key];
9960
9960
  const isOptionalIn = el._zod.optin === "optional";
9961
9961
  const isOptionalOut = el._zod.optout === "optional";
9962
- const r = el._zod.run({ value: input[key], issues: [] }, ctx);
9962
+ const r = el._zod.run({ value: input2[key], issues: [] }, ctx);
9963
9963
  if (r instanceof Promise) {
9964
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalIn, isOptionalOut)));
9964
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input2, isOptionalIn, isOptionalOut)));
9965
9965
  } else {
9966
- handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
9966
+ handlePropertyResult(r, payload, key, input2, isOptionalIn, isOptionalOut);
9967
9967
  }
9968
9968
  }
9969
9969
  if (!catchall) {
9970
9970
  return proms.length ? Promise.all(proms).then(() => payload) : payload;
9971
9971
  }
9972
- return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
9972
+ return handleCatchall(proms, input2, payload, ctx, _normalized.value, inst);
9973
9973
  };
9974
9974
  });
9975
9975
  var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
@@ -9991,42 +9991,42 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
9991
9991
  }
9992
9992
  doc.write(`const newResult = {};`);
9993
9993
  for (const key of normalized.keys) {
9994
- const id = ids[key];
9994
+ const id2 = ids[key];
9995
9995
  const k = esc(key);
9996
9996
  const schema = shape[key];
9997
9997
  const isOptionalIn = schema?._zod?.optin === "optional";
9998
9998
  const isOptionalOut = schema?._zod?.optout === "optional";
9999
- doc.write(`const ${id} = ${parseStr(key)};`);
9999
+ doc.write(`const ${id2} = ${parseStr(key)};`);
10000
10000
  if (isOptionalIn && isOptionalOut) {
10001
10001
  doc.write(`
10002
- if (${id}.issues.length) {
10002
+ if (${id2}.issues.length) {
10003
10003
  if (${k} in input) {
10004
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
10004
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
10005
10005
  ...iss,
10006
10006
  path: iss.path ? [${k}, ...iss.path] : [${k}]
10007
10007
  })));
10008
10008
  }
10009
10009
  }
10010
10010
 
10011
- if (${id}.value === undefined) {
10011
+ if (${id2}.value === undefined) {
10012
10012
  if (${k} in input) {
10013
10013
  newResult[${k}] = undefined;
10014
10014
  }
10015
10015
  } else {
10016
- newResult[${k}] = ${id}.value;
10016
+ newResult[${k}] = ${id2}.value;
10017
10017
  }
10018
10018
 
10019
10019
  `);
10020
10020
  } else if (!isOptionalIn) {
10021
10021
  doc.write(`
10022
- const ${id}_present = ${k} in input;
10023
- if (${id}.issues.length) {
10024
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
10022
+ const ${id2}_present = ${k} in input;
10023
+ if (${id2}.issues.length) {
10024
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
10025
10025
  ...iss,
10026
10026
  path: iss.path ? [${k}, ...iss.path] : [${k}]
10027
10027
  })));
10028
10028
  }
10029
- if (!${id}_present && !${id}.issues.length) {
10029
+ if (!${id2}_present && !${id2}.issues.length) {
10030
10030
  payload.issues.push({
10031
10031
  code: "invalid_type",
10032
10032
  expected: "nonoptional",
@@ -10035,30 +10035,30 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10035
10035
  });
10036
10036
  }
10037
10037
 
10038
- if (${id}_present) {
10039
- if (${id}.value === undefined) {
10038
+ if (${id2}_present) {
10039
+ if (${id2}.value === undefined) {
10040
10040
  newResult[${k}] = undefined;
10041
10041
  } else {
10042
- newResult[${k}] = ${id}.value;
10042
+ newResult[${k}] = ${id2}.value;
10043
10043
  }
10044
10044
  }
10045
10045
 
10046
10046
  `);
10047
10047
  } else {
10048
10048
  doc.write(`
10049
- if (${id}.issues.length) {
10050
- payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
10049
+ if (${id2}.issues.length) {
10050
+ payload.issues = payload.issues.concat(${id2}.issues.map(iss => ({
10051
10051
  ...iss,
10052
10052
  path: iss.path ? [${k}, ...iss.path] : [${k}]
10053
10053
  })));
10054
10054
  }
10055
10055
 
10056
- if (${id}.value === undefined) {
10056
+ if (${id2}.value === undefined) {
10057
10057
  if (${k} in input) {
10058
10058
  newResult[${k}] = undefined;
10059
10059
  }
10060
10060
  } else {
10061
- newResult[${k}] = ${id}.value;
10061
+ newResult[${k}] = ${id2}.value;
10062
10062
  }
10063
10063
 
10064
10064
  `);
@@ -10078,12 +10078,12 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10078
10078
  let value;
10079
10079
  inst._zod.parse = (payload, ctx) => {
10080
10080
  value ?? (value = _normalized.value);
10081
- const input = payload.value;
10082
- if (!isObject2(input)) {
10081
+ const input2 = payload.value;
10082
+ if (!isObject2(input2)) {
10083
10083
  payload.issues.push({
10084
10084
  expected: "object",
10085
10085
  code: "invalid_type",
10086
- input,
10086
+ input: input2,
10087
10087
  inst
10088
10088
  });
10089
10089
  return payload;
@@ -10094,7 +10094,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
10094
10094
  payload = fastpass(payload, ctx);
10095
10095
  if (!catchall)
10096
10096
  return payload;
10097
- return handleCatchall([], input, payload, ctx, value, inst);
10097
+ return handleCatchall([], input2, payload, ctx, value, inst);
10098
10098
  }
10099
10099
  return superParse(payload, ctx);
10100
10100
  };
@@ -10254,17 +10254,17 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10254
10254
  return map2;
10255
10255
  });
10256
10256
  inst._zod.parse = (payload, ctx) => {
10257
- const input = payload.value;
10258
- if (!isObject(input)) {
10257
+ const input2 = payload.value;
10258
+ if (!isObject(input2)) {
10259
10259
  payload.issues.push({
10260
10260
  code: "invalid_type",
10261
10261
  expected: "object",
10262
- input,
10262
+ input: input2,
10263
10263
  inst
10264
10264
  });
10265
10265
  return payload;
10266
10266
  }
10267
- const opt = disc.value.get(input?.[def.discriminator]);
10267
+ const opt = disc.value.get(input2?.[def.discriminator]);
10268
10268
  if (opt) {
10269
10269
  return opt._zod.run(payload, ctx);
10270
10270
  }
@@ -10277,7 +10277,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10277
10277
  note: "No matching discriminator",
10278
10278
  discriminator: def.discriminator,
10279
10279
  options: Array.from(disc.value.keys()),
10280
- input,
10280
+ input: input2,
10281
10281
  path: [def.discriminator],
10282
10282
  inst
10283
10283
  });
@@ -10287,9 +10287,9 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
10287
10287
  var $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
10288
10288
  $ZodType.init(inst, def);
10289
10289
  inst._zod.parse = (payload, ctx) => {
10290
- const input = payload.value;
10291
- const left = def.left._zod.run({ value: input, issues: [] }, ctx);
10292
- const right = def.right._zod.run({ value: input, issues: [] }, ctx);
10290
+ const input2 = payload.value;
10291
+ const left = def.left._zod.run({ value: input2, issues: [] }, ctx);
10292
+ const right = def.right._zod.run({ value: input2, issues: [] }, ctx);
10293
10293
  const async = left instanceof Promise || right instanceof Promise;
10294
10294
  if (async) {
10295
10295
  return Promise.all([left, right]).then(([left2, right2]) => {
@@ -10386,10 +10386,10 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10386
10386
  $ZodType.init(inst, def);
10387
10387
  const items = def.items;
10388
10388
  inst._zod.parse = (payload, ctx) => {
10389
- const input = payload.value;
10390
- if (!Array.isArray(input)) {
10389
+ const input2 = payload.value;
10390
+ if (!Array.isArray(input2)) {
10391
10391
  payload.issues.push({
10392
- input,
10392
+ input: input2,
10393
10393
  inst,
10394
10394
  expected: "tuple",
10395
10395
  code: "invalid_type"
@@ -10401,23 +10401,23 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10401
10401
  const optinStart = getTupleOptStart(items, "optin");
10402
10402
  const optoutStart = getTupleOptStart(items, "optout");
10403
10403
  if (!def.rest) {
10404
- if (input.length < optinStart) {
10404
+ if (input2.length < optinStart) {
10405
10405
  payload.issues.push({
10406
10406
  code: "too_small",
10407
10407
  minimum: optinStart,
10408
10408
  inclusive: true,
10409
- input,
10409
+ input: input2,
10410
10410
  inst,
10411
10411
  origin: "array"
10412
10412
  });
10413
10413
  return payload;
10414
10414
  }
10415
- if (input.length > items.length) {
10415
+ if (input2.length > items.length) {
10416
10416
  payload.issues.push({
10417
10417
  code: "too_big",
10418
10418
  maximum: items.length,
10419
10419
  inclusive: true,
10420
- input,
10420
+ input: input2,
10421
10421
  inst,
10422
10422
  origin: "array"
10423
10423
  });
@@ -10425,7 +10425,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10425
10425
  }
10426
10426
  const itemResults = new Array(items.length);
10427
10427
  for (let i = 0; i < items.length; i++) {
10428
- const r = items[i]._zod.run({ value: input[i], issues: [] }, ctx);
10428
+ const r = items[i]._zod.run({ value: input2[i], issues: [] }, ctx);
10429
10429
  if (r instanceof Promise) {
10430
10430
  proms.push(r.then((rr2) => {
10431
10431
  itemResults[i] = rr2;
@@ -10436,7 +10436,7 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10436
10436
  }
10437
10437
  if (def.rest) {
10438
10438
  let i = items.length - 1;
10439
- const rest = input.slice(items.length);
10439
+ const rest = input2.slice(items.length);
10440
10440
  for (const el of rest) {
10441
10441
  i++;
10442
10442
  const result = def.rest._zod.run({ value: el, issues: [] }, ctx);
@@ -10448,9 +10448,9 @@ var $ZodTuple = /* @__PURE__ */ $constructor("$ZodTuple", (inst, def) => {
10448
10448
  }
10449
10449
  }
10450
10450
  if (proms.length) {
10451
- return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input, optoutStart));
10451
+ return Promise.all(proms).then(() => handleTupleResults(itemResults, payload, items, input2, optoutStart));
10452
10452
  }
10453
- return handleTupleResults(itemResults, payload, items, input, optoutStart);
10453
+ return handleTupleResults(itemResults, payload, items, input2, optoutStart);
10454
10454
  };
10455
10455
  });
10456
10456
  function getTupleOptStart(items, key) {
@@ -10466,10 +10466,10 @@ function handleTupleResult(result, final, index) {
10466
10466
  }
10467
10467
  final.value[index] = result.value;
10468
10468
  }
10469
- function handleTupleResults(itemResults, final, items, input, optoutStart) {
10469
+ function handleTupleResults(itemResults, final, items, input2, optoutStart) {
10470
10470
  for (let i = 0; i < items.length; i++) {
10471
10471
  const r = itemResults[i];
10472
- const isPresent = i < input.length;
10472
+ const isPresent = i < input2.length;
10473
10473
  if (r.issues.length) {
10474
10474
  if (!isPresent && i >= optoutStart) {
10475
10475
  final.value.length = i;
@@ -10479,7 +10479,7 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
10479
10479
  }
10480
10480
  final.value[i] = r.value;
10481
10481
  }
10482
- for (let i = final.value.length - 1; i >= input.length; i--) {
10482
+ for (let i = final.value.length - 1; i >= input2.length; i--) {
10483
10483
  if (items[i]._zod.optout === "optional" && final.value[i] === void 0) {
10484
10484
  final.value.length = i;
10485
10485
  } else {
@@ -10491,12 +10491,12 @@ function handleTupleResults(itemResults, final, items, input, optoutStart) {
10491
10491
  var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10492
10492
  $ZodType.init(inst, def);
10493
10493
  inst._zod.parse = (payload, ctx) => {
10494
- const input = payload.value;
10495
- if (!isPlainObject(input)) {
10494
+ const input2 = payload.value;
10495
+ if (!isPlainObject(input2)) {
10496
10496
  payload.issues.push({
10497
10497
  expected: "record",
10498
10498
  code: "invalid_type",
10499
- input,
10499
+ input: input2,
10500
10500
  inst
10501
10501
  });
10502
10502
  return payload;
@@ -10525,7 +10525,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10525
10525
  continue;
10526
10526
  }
10527
10527
  const outKey = keyResult.value;
10528
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
10528
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
10529
10529
  if (result instanceof Promise) {
10530
10530
  proms.push(result.then((result2) => {
10531
10531
  if (result2.issues.length) {
@@ -10542,7 +10542,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10542
10542
  }
10543
10543
  }
10544
10544
  let unrecognized;
10545
- for (const key in input) {
10545
+ for (const key in input2) {
10546
10546
  if (!recordKeys.has(key)) {
10547
10547
  unrecognized = unrecognized ?? [];
10548
10548
  unrecognized.push(key);
@@ -10551,17 +10551,17 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10551
10551
  if (unrecognized && unrecognized.length > 0) {
10552
10552
  payload.issues.push({
10553
10553
  code: "unrecognized_keys",
10554
- input,
10554
+ input: input2,
10555
10555
  inst,
10556
10556
  keys: unrecognized
10557
10557
  });
10558
10558
  }
10559
10559
  } else {
10560
10560
  payload.value = {};
10561
- for (const key of Reflect.ownKeys(input)) {
10561
+ for (const key of Reflect.ownKeys(input2)) {
10562
10562
  if (key === "__proto__")
10563
10563
  continue;
10564
- if (!Object.prototype.propertyIsEnumerable.call(input, key))
10564
+ if (!Object.prototype.propertyIsEnumerable.call(input2, key))
10565
10565
  continue;
10566
10566
  let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
10567
10567
  if (keyResult instanceof Promise) {
@@ -10579,7 +10579,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10579
10579
  }
10580
10580
  if (keyResult.issues.length) {
10581
10581
  if (def.mode === "loose") {
10582
- payload.value[key] = input[key];
10582
+ payload.value[key] = input2[key];
10583
10583
  } else {
10584
10584
  payload.issues.push({
10585
10585
  code: "invalid_key",
@@ -10592,7 +10592,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10592
10592
  }
10593
10593
  continue;
10594
10594
  }
10595
- const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
10595
+ const result = def.valueType._zod.run({ value: input2[key], issues: [] }, ctx);
10596
10596
  if (result instanceof Promise) {
10597
10597
  proms.push(result.then((result2) => {
10598
10598
  if (result2.issues.length) {
@@ -10617,27 +10617,27 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
10617
10617
  var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
10618
10618
  $ZodType.init(inst, def);
10619
10619
  inst._zod.parse = (payload, ctx) => {
10620
- const input = payload.value;
10621
- if (!(input instanceof Map)) {
10620
+ const input2 = payload.value;
10621
+ if (!(input2 instanceof Map)) {
10622
10622
  payload.issues.push({
10623
10623
  expected: "map",
10624
10624
  code: "invalid_type",
10625
- input,
10625
+ input: input2,
10626
10626
  inst
10627
10627
  });
10628
10628
  return payload;
10629
10629
  }
10630
10630
  const proms = [];
10631
10631
  payload.value = /* @__PURE__ */ new Map();
10632
- for (const [key, value] of input) {
10632
+ for (const [key, value] of input2) {
10633
10633
  const keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
10634
10634
  const valueResult = def.valueType._zod.run({ value, issues: [] }, ctx);
10635
10635
  if (keyResult instanceof Promise || valueResult instanceof Promise) {
10636
10636
  proms.push(Promise.all([keyResult, valueResult]).then(([keyResult2, valueResult2]) => {
10637
- handleMapResult(keyResult2, valueResult2, payload, key, input, inst, ctx);
10637
+ handleMapResult(keyResult2, valueResult2, payload, key, input2, inst, ctx);
10638
10638
  }));
10639
10639
  } else {
10640
- handleMapResult(keyResult, valueResult, payload, key, input, inst, ctx);
10640
+ handleMapResult(keyResult, valueResult, payload, key, input2, inst, ctx);
10641
10641
  }
10642
10642
  }
10643
10643
  if (proms.length)
@@ -10645,7 +10645,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
10645
10645
  return payload;
10646
10646
  };
10647
10647
  });
10648
- function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
10648
+ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx) {
10649
10649
  if (keyResult.issues.length) {
10650
10650
  if (propertyKeyTypes.has(typeof key)) {
10651
10651
  final.issues.push(...prefixIssues(key, keyResult.issues));
@@ -10653,7 +10653,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
10653
10653
  final.issues.push({
10654
10654
  code: "invalid_key",
10655
10655
  origin: "map",
10656
- input,
10656
+ input: input2,
10657
10657
  inst,
10658
10658
  issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
10659
10659
  });
@@ -10666,7 +10666,7 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
10666
10666
  final.issues.push({
10667
10667
  origin: "map",
10668
10668
  code: "invalid_element",
10669
- input,
10669
+ input: input2,
10670
10670
  inst,
10671
10671
  key,
10672
10672
  issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config()))
@@ -10678,10 +10678,10 @@ function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
10678
10678
  var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
10679
10679
  $ZodType.init(inst, def);
10680
10680
  inst._zod.parse = (payload, ctx) => {
10681
- const input = payload.value;
10682
- if (!(input instanceof Set)) {
10681
+ const input2 = payload.value;
10682
+ if (!(input2 instanceof Set)) {
10683
10683
  payload.issues.push({
10684
- input,
10684
+ input: input2,
10685
10685
  inst,
10686
10686
  expected: "set",
10687
10687
  code: "invalid_type"
@@ -10690,7 +10690,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
10690
10690
  }
10691
10691
  const proms = [];
10692
10692
  payload.value = /* @__PURE__ */ new Set();
10693
- for (const item of input) {
10693
+ for (const item of input2) {
10694
10694
  const result = def.valueType._zod.run({ value: item, issues: [] }, ctx);
10695
10695
  if (result instanceof Promise) {
10696
10696
  proms.push(result.then((result2) => handleSetResult(result2, payload)));
@@ -10715,14 +10715,14 @@ var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
10715
10715
  inst._zod.values = valuesSet;
10716
10716
  inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
10717
10717
  inst._zod.parse = (payload, _ctx) => {
10718
- const input = payload.value;
10719
- if (valuesSet.has(input)) {
10718
+ const input2 = payload.value;
10719
+ if (valuesSet.has(input2)) {
10720
10720
  return payload;
10721
10721
  }
10722
10722
  payload.issues.push({
10723
10723
  code: "invalid_value",
10724
10724
  values,
10725
- input,
10725
+ input: input2,
10726
10726
  inst
10727
10727
  });
10728
10728
  return payload;
@@ -10737,14 +10737,14 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
10737
10737
  inst._zod.values = values;
10738
10738
  inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
10739
10739
  inst._zod.parse = (payload, _ctx) => {
10740
- const input = payload.value;
10741
- if (values.has(input)) {
10740
+ const input2 = payload.value;
10741
+ if (values.has(input2)) {
10742
10742
  return payload;
10743
10743
  }
10744
10744
  payload.issues.push({
10745
10745
  code: "invalid_value",
10746
10746
  values: def.values,
10747
- input,
10747
+ input: input2,
10748
10748
  inst
10749
10749
  });
10750
10750
  return payload;
@@ -10753,13 +10753,13 @@ var $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
10753
10753
  var $ZodFile = /* @__PURE__ */ $constructor("$ZodFile", (inst, def) => {
10754
10754
  $ZodType.init(inst, def);
10755
10755
  inst._zod.parse = (payload, _ctx) => {
10756
- const input = payload.value;
10757
- if (input instanceof File)
10756
+ const input2 = payload.value;
10757
+ if (input2 instanceof File)
10758
10758
  return payload;
10759
10759
  payload.issues.push({
10760
10760
  expected: "file",
10761
10761
  code: "invalid_type",
10762
- input,
10762
+ input: input2,
10763
10763
  inst
10764
10764
  });
10765
10765
  return payload;
@@ -10789,8 +10789,8 @@ var $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) =>
10789
10789
  return payload;
10790
10790
  };
10791
10791
  });
10792
- function handleOptionalResult(result, input) {
10793
- if (input === void 0 && (result.issues.length || result.fallback)) {
10792
+ function handleOptionalResult(result, input2) {
10793
+ if (input2 === void 0 && (result.issues.length || result.fallback)) {
10794
10794
  return { issues: [], value: void 0 };
10795
10795
  }
10796
10796
  return result;
@@ -10808,11 +10808,11 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
10808
10808
  });
10809
10809
  inst._zod.parse = (payload, ctx) => {
10810
10810
  if (def.innerType._zod.optin === "optional") {
10811
- const input = payload.value;
10811
+ const input2 = payload.value;
10812
10812
  const result = def.innerType._zod.run(payload, ctx);
10813
10813
  if (result instanceof Promise)
10814
- return result.then((r) => handleOptionalResult(r, input));
10815
- return handleOptionalResult(result, input);
10814
+ return result.then((r) => handleOptionalResult(r, input2));
10815
+ return handleOptionalResult(result, input2);
10816
10816
  }
10817
10817
  if (payload.value === void 0) {
10818
10818
  return payload;
@@ -11237,20 +11237,20 @@ var $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
11237
11237
  return payload;
11238
11238
  };
11239
11239
  inst._zod.check = (payload) => {
11240
- const input = payload.value;
11241
- const r = def.fn(input);
11240
+ const input2 = payload.value;
11241
+ const r = def.fn(input2);
11242
11242
  if (r instanceof Promise) {
11243
- return r.then((r2) => handleRefineResult(r2, payload, input, inst));
11243
+ return r.then((r2) => handleRefineResult(r2, payload, input2, inst));
11244
11244
  }
11245
- handleRefineResult(r, payload, input, inst);
11245
+ handleRefineResult(r, payload, input2, inst);
11246
11246
  return;
11247
11247
  };
11248
11248
  });
11249
- function handleRefineResult(result, payload, input, inst) {
11249
+ function handleRefineResult(result, payload, input2, inst) {
11250
11250
  if (!result) {
11251
11251
  const _iss = {
11252
11252
  code: "custom",
11253
- input,
11253
+ input: input2,
11254
11254
  inst,
11255
11255
  // incorporates params.error into issue reporting
11256
11256
  path: [...inst._zod.def.path ?? []],
@@ -14537,8 +14537,8 @@ function ko_default() {
14537
14537
  }
14538
14538
 
14539
14539
  // ../../../node_modules/zod/v4/locales/lt.js
14540
- var capitalizeFirstCharacter = (text) => {
14541
- return text.charAt(0).toUpperCase() + text.slice(1);
14540
+ var capitalizeFirstCharacter = (text2) => {
14541
+ return text2.charAt(0).toUpperCase() + text2.slice(1);
14542
14542
  };
14543
14543
  function getUnitTypeFromNumber(number4) {
14544
14544
  const abs = Math.abs(number4);
@@ -17938,23 +17938,23 @@ function _overwrite(tx) {
17938
17938
  }
17939
17939
  // @__NO_SIDE_EFFECTS__
17940
17940
  function _normalize(form) {
17941
- return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
17941
+ return /* @__PURE__ */ _overwrite((input2) => input2.normalize(form));
17942
17942
  }
17943
17943
  // @__NO_SIDE_EFFECTS__
17944
17944
  function _trim() {
17945
- return /* @__PURE__ */ _overwrite((input) => input.trim());
17945
+ return /* @__PURE__ */ _overwrite((input2) => input2.trim());
17946
17946
  }
17947
17947
  // @__NO_SIDE_EFFECTS__
17948
17948
  function _toLowerCase() {
17949
- return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
17949
+ return /* @__PURE__ */ _overwrite((input2) => input2.toLowerCase());
17950
17950
  }
17951
17951
  // @__NO_SIDE_EFFECTS__
17952
17952
  function _toUpperCase() {
17953
- return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
17953
+ return /* @__PURE__ */ _overwrite((input2) => input2.toUpperCase());
17954
17954
  }
17955
17955
  // @__NO_SIDE_EFFECTS__
17956
17956
  function _slugify() {
17957
- return /* @__PURE__ */ _overwrite((input) => slugify(input));
17957
+ return /* @__PURE__ */ _overwrite((input2) => slugify(input2));
17958
17958
  }
17959
17959
  // @__NO_SIDE_EFFECTS__
17960
17960
  function _array(Class2, element, params) {
@@ -18259,8 +18259,8 @@ function _stringbool(Classes, _params) {
18259
18259
  type: "pipe",
18260
18260
  in: stringSchema,
18261
18261
  out: booleanSchema,
18262
- transform: ((input, payload) => {
18263
- let data = input;
18262
+ transform: ((input2, payload) => {
18263
+ let data = input2;
18264
18264
  if (params.case !== "sensitive")
18265
18265
  data = data.toLowerCase();
18266
18266
  if (truthySet.has(data)) {
@@ -18279,8 +18279,8 @@ function _stringbool(Classes, _params) {
18279
18279
  return {};
18280
18280
  }
18281
18281
  }),
18282
- reverseTransform: ((input, _payload) => {
18283
- if (input === true) {
18282
+ reverseTransform: ((input2, _payload) => {
18283
+ if (input2 === true) {
18284
18284
  return truthyArray[0] || "true";
18285
18285
  } else {
18286
18286
  return falsyArray[0] || "false";
@@ -18390,26 +18390,26 @@ function extractDefs(ctx, schema) {
18390
18390
  throw new Error("Unprocessed schema. This is a bug in Zod.");
18391
18391
  const idToSchema = /* @__PURE__ */ new Map();
18392
18392
  for (const entry of ctx.seen.entries()) {
18393
- const id = ctx.metadataRegistry.get(entry[0])?.id;
18394
- if (id) {
18395
- const existing = idToSchema.get(id);
18393
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
18394
+ if (id2) {
18395
+ const existing = idToSchema.get(id2);
18396
18396
  if (existing && existing !== entry[0]) {
18397
- throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
18397
+ throw new Error(`Duplicate schema id "${id2}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
18398
18398
  }
18399
- idToSchema.set(id, entry[0]);
18399
+ idToSchema.set(id2, entry[0]);
18400
18400
  }
18401
18401
  }
18402
18402
  const makeURI = (entry) => {
18403
18403
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
18404
18404
  if (ctx.external) {
18405
18405
  const externalId = ctx.external.registry.get(entry[0])?.id;
18406
- const uriGenerator = ctx.external.uri ?? ((id2) => id2);
18406
+ const uriGenerator = ctx.external.uri ?? ((id3) => id3);
18407
18407
  if (externalId) {
18408
18408
  return { ref: uriGenerator(externalId) };
18409
18409
  }
18410
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
18411
- entry[1].defId = id;
18412
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
18410
+ const id2 = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
18411
+ entry[1].defId = id2;
18412
+ return { defId: id2, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id2}` };
18413
18413
  }
18414
18414
  if (entry[1] === root) {
18415
18415
  return { ref: "#" };
@@ -18457,8 +18457,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18457
18457
  continue;
18458
18458
  }
18459
18459
  }
18460
- const id = ctx.metadataRegistry.get(entry[0])?.id;
18461
- if (id) {
18460
+ const id2 = ctx.metadataRegistry.get(entry[0])?.id;
18461
+ if (id2) {
18462
18462
  extractToDef(entry);
18463
18463
  continue;
18464
18464
  }
@@ -18554,10 +18554,10 @@ function finalize(ctx, schema) {
18554
18554
  } else {
18555
18555
  }
18556
18556
  if (ctx.external?.uri) {
18557
- const id = ctx.external.registry.get(schema)?.id;
18558
- if (!id)
18557
+ const id2 = ctx.external.registry.get(schema)?.id;
18558
+ if (!id2)
18559
18559
  throw new Error("Schema is missing an `id` property");
18560
- result.$id = ctx.external.uri(id);
18560
+ result.$id = ctx.external.uri(id2);
18561
18561
  }
18562
18562
  Object.assign(result, root.def ?? root.schema);
18563
18563
  const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
@@ -18717,9 +18717,9 @@ var numberProcessor = (schema, ctx, _json, _params) => {
18717
18717
  json2.type = "number";
18718
18718
  const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
18719
18719
  const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
18720
- const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
18720
+ const legacy2 = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
18721
18721
  if (exMin) {
18722
- if (legacy) {
18722
+ if (legacy2) {
18723
18723
  json2.minimum = exclusiveMinimum;
18724
18724
  json2.exclusiveMinimum = true;
18725
18725
  } else {
@@ -18729,7 +18729,7 @@ var numberProcessor = (schema, ctx, _json, _params) => {
18729
18729
  json2.minimum = minimum;
18730
18730
  }
18731
18731
  if (exMax) {
18732
- if (legacy) {
18732
+ if (legacy2) {
18733
18733
  json2.maximum = exclusiveMaximum;
18734
18734
  json2.exclusiveMaximum = true;
18735
18735
  } else {
@@ -19176,9 +19176,9 @@ var allProcessors = {
19176
19176
  optional: optionalProcessor,
19177
19177
  lazy: lazyProcessor
19178
19178
  };
19179
- function toJSONSchema(input, params) {
19180
- if ("_idmap" in input) {
19181
- const registry2 = input;
19179
+ function toJSONSchema(input2, params) {
19180
+ if ("_idmap" in input2) {
19181
+ const registry2 = input2;
19182
19182
  const ctx2 = initializeContext({ ...params, processors: allProcessors });
19183
19183
  const defs = {};
19184
19184
  for (const entry of registry2._idmap.entries()) {
@@ -19206,9 +19206,9 @@ function toJSONSchema(input, params) {
19206
19206
  return { schemas };
19207
19207
  }
19208
19208
  const ctx = initializeContext({ ...params, processors: allProcessors });
19209
- process2(input, ctx);
19210
- extractDefs(ctx, input);
19211
- return finalize(ctx, input);
19209
+ process2(input2, ctx);
19210
+ extractDefs(ctx, input2);
19211
+ return finalize(ctx, input2);
19212
19212
  }
19213
19213
 
19214
19214
  // ../../../node_modules/zod/v4/core/json-schema-generator.js
@@ -19591,7 +19591,7 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
19591
19591
 
19592
19592
  // ../../../node_modules/zod/v4/classic/schemas.js
19593
19593
  var _installedGroups = /* @__PURE__ */ new WeakMap();
19594
- function _installLazyMethods(inst, group, methods) {
19594
+ function _installLazyMethods(inst, group, methods2) {
19595
19595
  const proto = Object.getPrototypeOf(inst);
19596
19596
  let installed = _installedGroups.get(proto);
19597
19597
  if (!installed) {
@@ -19601,8 +19601,8 @@ function _installLazyMethods(inst, group, methods) {
19601
19601
  if (installed.has(group))
19602
19602
  return;
19603
19603
  installed.add(group);
19604
- for (const key in methods) {
19605
- const fn = methods[key];
19604
+ for (const key in methods2) {
19605
+ const fn = methods2[key];
19606
19606
  Object.defineProperty(proto, key, {
19607
19607
  configurable: true,
19608
19608
  enumerable: false,
@@ -21413,87 +21413,6 @@ function date4(params) {
21413
21413
  // ../../../node_modules/zod/v4/classic/external.js
21414
21414
  config(en_default());
21415
21415
 
21416
- // ../../shared-contracts/dist/ids.js
21417
- var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
21418
- message: "Identifier must not be empty or whitespace"
21419
- });
21420
- var harnessIdSchema = opaqueIdSchema.brand();
21421
- var hostThreadIdSchema = opaqueIdSchema.brand();
21422
- var hostTurnIdSchema = opaqueIdSchema.brand();
21423
- var hostItemIdSchema = opaqueIdSchema.brand();
21424
- var hostInteractionIdSchema = opaqueIdSchema.brand();
21425
-
21426
- // ../../shared-contracts/dist/harness-plugins.js
21427
- var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
21428
- var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
21429
- var HARNESS_PLUGIN_LIMIT = 128;
21430
- var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
21431
- var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
21432
- var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id) => id !== "codex", "The official Codex identity is reserved");
21433
- 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");
21434
- var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
21435
- var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
21436
- var harnessInstallationGuideSchema = external_exports.object({
21437
- commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
21438
- before: localizedTextSchema.optional(),
21439
- after: localizedTextSchema.optional(),
21440
- downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
21441
- }).strict();
21442
- var pluginPresentationShape = {
21443
- id: installedHarnessPluginIdSchema,
21444
- name: external_exports.string().trim().min(1).max(128),
21445
- version: external_exports.string().min(1).max(128),
21446
- /** Capability-only plugin; omitted for existing session-capable plugins. */
21447
- kind: external_exports.literal("usage").optional(),
21448
- /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
21449
- iconStyle: external_exports.object({
21450
- vector: external_exports.object({
21451
- viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
21452
- color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
21453
- paths: external_exports.array(external_exports.object({
21454
- d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
21455
- fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
21456
- fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
21457
- }).strict()).min(1).max(32)
21458
- }).strict().optional(),
21459
- background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
21460
- borderRadius: external_exports.number().min(0).max(50).optional(),
21461
- paddingRatio: external_exports.number().min(0).max(0.25).optional()
21462
- }).strict().optional(),
21463
- installation: harnessInstallationGuideSchema.optional(),
21464
- notice: localizedTextSchema.optional(),
21465
- /** The factory accepts a persisted local entrypoint through its construction context. */
21466
- launchCommand: external_exports.literal(true).optional(),
21467
- links: external_exports.object({
21468
- website: documentationUrlSchema.optional(),
21469
- documentation: documentationUrlSchema.optional(),
21470
- installation: documentationUrlSchema.optional()
21471
- }).strict().optional()
21472
- };
21473
- var harnessPluginManifestSchema = external_exports.object({
21474
- manifestVersion: external_exports.literal(1),
21475
- ...pluginPresentationShape,
21476
- adapterApiVersion: external_exports.number().int().positive(),
21477
- entry: pluginRelativeResourceSchema,
21478
- icon: pluginRelativeResourceSchema.optional()
21479
- }).strict();
21480
- 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);
21481
- var harnessPluginDescriptorSchema = external_exports.object({
21482
- ...pluginPresentationShape,
21483
- icon: harnessPluginIconSchema.optional()
21484
- }).strict();
21485
- var harnessPluginListParamsSchema = external_exports.object({}).strict();
21486
- var harnessPluginListResultSchema = external_exports.object({
21487
- plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
21488
- }).strict();
21489
- var harnessPluginConfigurationSchema = external_exports.object({
21490
- version: external_exports.literal(1),
21491
- enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
21492
- }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
21493
- message: "Enabled plugin IDs must be unique",
21494
- path: ["enabled"]
21495
- });
21496
-
21497
21416
  // ../../shared-contracts/dist/json-value.js
21498
21417
  function rejectExplicitUndefined(keys) {
21499
21418
  return (value, context) => {
@@ -21553,403 +21472,73 @@ var jsonValueSchema = nonCircularSchema.pipe(recursiveJsonValueSchema);
21553
21472
  var jsonArraySchema = nonCircularSchema.pipe(external_exports.array(recursiveJsonValueSchema));
21554
21473
  var jsonObjectSchema = nonCircularSchema.pipe(external_exports.record(external_exports.string(), recursiveJsonValueSchema));
21555
21474
 
21556
- // ../../shared-contracts/dist/desktop-extensions.js
21557
- var DESKTOP_EXTENSION_API_VERSION = 1;
21558
- var DESKTOP_EXTENSION_LIMIT = 64;
21559
- var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
21560
- var DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH = 4 * Math.ceil(DESKTOP_EXTENSION_ZIP_MAX_BYTES / 3);
21561
- var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
21562
- var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
21563
- var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
21564
- var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
21565
- var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
21566
- var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
21567
- var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
21568
- var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
21569
- var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
21570
- var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
21571
- var desktopExtensionIdSchema = installedPluginIdSchema;
21572
- var desktopExtensionSlotSchema = external_exports.enum([
21573
- "sidebar.thread-layout",
21574
- "sidebar.thread-badge",
21575
- "appearance.theme"
21576
- ]);
21577
- var desktopExtensionCategorySchema = external_exports.enum([
21578
- "appearance",
21579
- "interface",
21580
- "workflow",
21581
- "analytics",
21582
- "integrations",
21583
- "tools"
21584
- ]);
21585
- var extensionName = external_exports.string().trim().min(1).max(128);
21586
- function desktopExtensionScreenshotMimeType(resource) {
21587
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
21588
- case "png":
21589
- return "image/png";
21590
- case "jpg":
21591
- case "jpeg":
21592
- return "image/jpeg";
21593
- case "webp":
21594
- return "image/webp";
21595
- default:
21596
- return void 0;
21475
+ // ../../shared-contracts/dist/errors.js
21476
+ var codexhostErrorSchema = external_exports.strictObject({
21477
+ code: external_exports.string().min(1),
21478
+ message: external_exports.string().min(1),
21479
+ retryable: external_exports.boolean(),
21480
+ diagnostic: external_exports.string().min(1).optional(),
21481
+ stage: external_exports.string().min(1).optional(),
21482
+ durationMs: external_exports.number().int().nonnegative().optional(),
21483
+ stderrTail: external_exports.string().min(1).optional()
21484
+ }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
21485
+
21486
+ // ../../shared-contracts/dist/harness-presentation.js
21487
+ var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
21488
+ var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text2) => text2.trim().length > 0);
21489
+ var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
21490
+ label: displayText(256).optional(),
21491
+ description: displayText(1024).optional()
21492
+ }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
21493
+ var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
21494
+
21495
+ // ../../shared-contracts/dist/ids.js
21496
+ var opaqueIdSchema = external_exports.string().refine((value) => value.trim().length > 0, {
21497
+ message: "Identifier must not be empty or whitespace"
21498
+ });
21499
+ var harnessIdSchema = opaqueIdSchema.brand();
21500
+ var hostThreadIdSchema = opaqueIdSchema.brand();
21501
+ var hostTurnIdSchema = opaqueIdSchema.brand();
21502
+ var hostItemIdSchema = opaqueIdSchema.brand();
21503
+ var hostInteractionIdSchema = opaqueIdSchema.brand();
21504
+
21505
+ // ../../shared-contracts/dist/harness-permission-modes.js
21506
+ var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
21507
+ var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
21508
+ var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
21509
+ var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
21510
+ var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
21511
+ message: "Value must not be empty or whitespace"
21512
+ });
21513
+ var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
21514
+ var harnessPermissionModeSchema = external_exports.object({
21515
+ id: harnessPermissionModeIdSchema,
21516
+ label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
21517
+ description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
21518
+ dangerous: external_exports.boolean().optional(),
21519
+ localizations: harnessLocalizationsSchema.optional()
21520
+ }).strict();
21521
+ var harnessPermissionModeCatalogSchema = external_exports.object({
21522
+ modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
21523
+ defaultModeId: harnessPermissionModeIdSchema
21524
+ }).strict().superRefine((catalog, context) => {
21525
+ const ids = /* @__PURE__ */ new Set();
21526
+ for (const [index, mode] of catalog.modes.entries()) {
21527
+ if (ids.has(mode.id)) {
21528
+ context.addIssue({
21529
+ code: "custom",
21530
+ message: "Permission Mode IDs must be unique",
21531
+ path: ["modes", index, "id"]
21532
+ });
21533
+ }
21534
+ ids.add(mode.id);
21597
21535
  }
21598
- }
21599
- function desktopExtensionAssetMimeType(resource) {
21600
- switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
21601
- case "gif":
21602
- return "image/gif";
21603
- case "svg":
21604
- return "image/svg+xml";
21605
- case "woff2":
21606
- return "font/woff2";
21607
- case "json":
21608
- return "application/json";
21609
- case "css":
21610
- return "text/css";
21611
- default:
21612
- return desktopExtensionScreenshotMimeType(resource);
21613
- }
21614
- }
21615
- var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
21616
- var desktopExtensionAssetPathSchema = pluginRelativeResourceSchema.refine((resource) => hasPortableSegments(resource) && desktopExtensionAssetMimeType(resource) !== void 0, "Expected a relative Desktop extension asset path with a supported suffix");
21617
- 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");
21618
- 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) => {
21619
- const { username, password } = new URL(value);
21620
- return !username && !password && !/[\\\s]/u.test(value);
21621
- }, "URL must not contain credentials, backslashes, or whitespace");
21622
- function localizedText(text) {
21623
- return external_exports.strictObject({ en: text, "zh-CN": text });
21624
- }
21625
- var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
21626
- var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
21627
- var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
21628
- var settingField = {
21629
- key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
21630
- label: desktopExtensionLocalizedTextSchema,
21631
- description: desktopExtensionLocalizedTextSchema.optional()
21632
- };
21633
- var numericSetting = {
21634
- ...settingField,
21635
- step: external_exports.number().positive().optional(),
21636
- default: external_exports.number().optional()
21637
- };
21638
- var settingOption = external_exports.strictObject({
21639
- value: external_exports.string(),
21640
- label: desktopExtensionLocalizedTextSchema
21641
- });
21642
- var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
21643
- external_exports.strictObject({
21644
- ...settingField,
21645
- type: external_exports.literal("boolean"),
21646
- default: external_exports.boolean().optional()
21647
- }),
21648
- external_exports.strictObject({
21649
- ...settingField,
21650
- type: external_exports.literal("string"),
21651
- placeholder: desktopExtensionLocalizedTextSchema.optional(),
21652
- default: external_exports.string().optional()
21653
- }),
21654
- external_exports.strictObject({
21655
- ...numericSetting,
21656
- type: external_exports.literal("number"),
21657
- min: external_exports.number().optional(),
21658
- max: external_exports.number().optional()
21659
- }),
21660
- external_exports.strictObject({
21661
- ...numericSetting,
21662
- type: external_exports.literal("range"),
21663
- min: external_exports.number(),
21664
- max: external_exports.number()
21665
- }),
21666
- external_exports.strictObject({
21667
- ...settingField,
21668
- type: external_exports.literal("select"),
21669
- options: external_exports.array(settingOption).min(1),
21670
- default: external_exports.string().optional()
21671
- })
21672
- ]).superRefine((field2, ctx) => {
21673
- const issue2 = (path6, message) => ctx.addIssue({ code: "custom", path: [path6], message });
21674
- if (field2.type === "number" || field2.type === "range") {
21675
- const { min = -Infinity, max = Infinity, default: value } = field2;
21676
- if (min > max)
21677
- issue2("max", "Must be at least min");
21678
- if (value !== void 0 && (value < min || value > max))
21679
- issue2("default", "Must be within min and max");
21680
- } else if (field2.type === "select") {
21681
- const values = new Set(field2.options.map(({ value }) => value));
21682
- if (values.size !== field2.options.length)
21683
- issue2("options", "Duplicate option values");
21684
- if (field2.default !== void 0 && !values.has(field2.default))
21685
- issue2("default", "Must match an option value");
21686
- }
21687
- });
21688
- var manifestHeader = external_exports.object({
21689
- manifestVersion: external_exports.int().positive(),
21690
- id: desktopExtensionIdSchema,
21691
- name: external_exports.union([extensionName, localizedText(extensionName)]),
21692
- version: external_exports.string().min(1).max(128),
21693
- desktopApi: external_exports.int().positive()
21694
- }).passthrough();
21695
- var desktopExtensionManifestSchema = manifestHeader.extend({
21696
- manifestVersion: external_exports.literal(1),
21697
- desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
21698
- description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
21699
- author: external_exports.string().trim().min(1).max(128).optional(),
21700
- repository: desktopExtensionHttpUrlSchema.optional(),
21701
- details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
21702
- icon: imagePathSchema.optional(),
21703
- screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
21704
- desktop: external_exports.strictObject({
21705
- script: pluginRelativeResourceSchema,
21706
- style: pluginRelativeResourceSchema.optional()
21707
- }).optional(),
21708
- backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
21709
- slots: slotsSchema.default(() => []),
21710
- settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
21711
- categories: categoriesSchema.optional()
21712
- }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
21713
- var desktopExtensionConfigurationSchema = external_exports.strictObject({
21714
- version: external_exports.literal(1),
21715
- revision: external_exports.int().nonnegative(),
21716
- enabled: external_exports.array(desktopExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs"),
21717
- reloadToken: external_exports.uuid().optional()
21718
- });
21719
- var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
21720
- var desktopExtensionStatusSchema = external_exports.strictObject({
21721
- state: external_exports.enum([
21722
- "running",
21723
- "disabled",
21724
- "invalid",
21725
- "incompatible",
21726
- "conflict",
21727
- "failed",
21728
- "waiting"
21729
- ]),
21730
- hash: desktopExtensionHashSchema.optional(),
21731
- error: external_exports.string().optional(),
21732
- conflictWith: desktopExtensionIdSchema.optional()
21733
- });
21734
- var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
21735
- controllerPid: external_exports.int().positive(),
21736
- targetId: external_exports.string().nullable(),
21737
- updatedAt: external_exports.iso.datetime(),
21738
- handledReloadToken: external_exports.uuid().optional(),
21739
- extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema)
21740
- });
21741
- var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
21742
- function isGitHubDesktopExtensionZipballUrl(url2) {
21743
- return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
21744
- }
21745
- var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input) => {
21746
- const url2 = new URL(input);
21747
- 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);
21748
- }, "Expected a .zip download URL or a GitHub zipball URL");
21749
- var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
21750
- id: desktopExtensionIdSchema,
21751
- version: external_exports.string().trim().min(1).max(128),
21752
- name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
21753
- description: localizedText(external_exports.string().trim().min(1).max(4096)),
21754
- details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
21755
- author: external_exports.string().trim().min(1).max(128),
21756
- repository: desktopExtensionHttpUrlSchema,
21757
- stars: external_exports.number().int().min(0).optional(),
21758
- downloads: external_exports.number().int().min(0).optional(),
21759
- categories: categoriesSchema.optional(),
21760
- trustTier: desktopExtensionTrustTierSchema.default("community"),
21761
- icon: desktopExtensionHttpUrlSchema.optional(),
21762
- screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
21763
- downloadUrl: desktopExtensionZipUrlSchema,
21764
- sha256: desktopExtensionHashSchema,
21765
- slots: slotsSchema.optional(),
21766
- publishedAt: external_exports.string().optional(),
21767
- updatedAt: external_exports.string().optional(),
21768
- minCodexHostVersion: external_exports.string().optional()
21769
- });
21770
- var desktopExtensionCatalogSchema = external_exports.strictObject({
21771
- schemaVersion: external_exports.literal(1),
21772
- generatedAt: external_exports.string(),
21773
- extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, "Duplicate extension IDs")
21774
- });
21775
- var DESKTOP_EXTENSIONS_ASSET_METHOD = "codexhost/desktop/extensions/asset";
21776
- var DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD = "codexhost/desktop/extensions/settings/get";
21777
- var DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD = "codexhost/desktop/extensions/settings/set";
21778
- var DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD = "codexhost/desktop/extensions/backend/invoke";
21779
- var extensionIdParams = { id: desktopExtensionIdSchema };
21780
- var desktopExtensionsAssetParamsSchema = external_exports.strictObject({
21781
- ...extensionIdParams,
21782
- path: desktopExtensionAssetPathSchema
21783
- });
21784
- var desktopExtensionsAssetResultSchema = external_exports.strictObject({
21785
- mimeType: external_exports.string(),
21786
- dataUrl: external_exports.string()
21787
- });
21788
- var desktopExtensionsSettingsGetParamsSchema = external_exports.strictObject(extensionIdParams);
21789
- var desktopExtensionsSettingsSetParamsSchema = external_exports.strictObject({
21790
- ...extensionIdParams,
21791
- values: jsonObjectSchema
21792
- });
21793
- var desktopExtensionsSettingsResultSchema = external_exports.strictObject({ values: jsonObjectSchema });
21794
- var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
21795
- var desktopExtensionsBackendInvokeParamsSchema = external_exports.strictObject({
21796
- ...extensionIdParams,
21797
- method: desktopExtensionBackendMethodSchema,
21798
- params: jsonValueSchema.optional()
21799
- });
21800
- var desktopExtensionsBackendInvokeResultSchema = external_exports.strictObject({
21801
- result: jsonValueSchema
21802
- });
21803
-
21804
- // ../../shared-contracts/dist/desktop-extension-management.js
21805
- var DESKTOP_EXTENSIONS_LIST_METHOD = "codexhost/desktop/extensions/list";
21806
- var DESKTOP_EXTENSIONS_ENABLE_METHOD = "codexhost/desktop/extensions/enable";
21807
- var DESKTOP_EXTENSIONS_DISABLE_METHOD = "codexhost/desktop/extensions/disable";
21808
- var DESKTOP_EXTENSIONS_CATALOG_METHOD = "codexhost/desktop/extensions/catalog";
21809
- var DESKTOP_EXTENSIONS_INSTALL_METHOD = "codexhost/desktop/extensions/install";
21810
- var DESKTOP_EXTENSIONS_UNINSTALL_METHOD = "codexhost/desktop/extensions/uninstall";
21811
- var DESKTOP_EXTENSIONS_RECOVER_METHOD = "codexhost/desktop/extensions/disable-all-and-reload";
21812
- var DESKTOP_EXTENSION_MANAGEMENT_METHODS = [
21813
- DESKTOP_EXTENSIONS_LIST_METHOD,
21814
- DESKTOP_EXTENSIONS_ENABLE_METHOD,
21815
- DESKTOP_EXTENSIONS_DISABLE_METHOD,
21816
- DESKTOP_EXTENSIONS_RECOVER_METHOD,
21817
- DESKTOP_EXTENSIONS_CATALOG_METHOD,
21818
- DESKTOP_EXTENSIONS_INSTALL_METHOD,
21819
- DESKTOP_EXTENSIONS_UNINSTALL_METHOD,
21820
- DESKTOP_EXTENSIONS_ASSET_METHOD,
21821
- DESKTOP_EXTENSIONS_SETTINGS_GET_METHOD,
21822
- DESKTOP_EXTENSIONS_SETTINGS_SET_METHOD,
21823
- DESKTOP_EXTENSIONS_BACKEND_INVOKE_METHOD
21824
- ];
21825
- var revisionSchema = external_exports.int().nonnegative();
21826
- var desktopExtensionsListParamsSchema = external_exports.strictObject({});
21827
- var desktopExtensionSelectionParamsSchema = external_exports.strictObject({
21828
- id: desktopExtensionIdSchema,
21829
- expectedRevision: revisionSchema
21830
- });
21831
- var desktopExtensionsRecoveryParamsSchema = external_exports.strictObject({
21832
- expectedRevision: revisionSchema.optional()
21833
- });
21834
- 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);
21835
- var desktopExtensionListItemSchema = external_exports.strictObject({
21836
- // An invalid discovery can have a directory name that isn't a valid extension ID.
21837
- id: external_exports.string().min(1),
21838
- manifest: desktopExtensionManifestSchema.optional(),
21839
- iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
21840
- screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
21841
- enabled: external_exports.boolean(),
21842
- status: desktopExtensionStatusSchema
21843
- });
21844
- var desktopExtensionsListResultSchema = external_exports.strictObject({
21845
- configuration: desktopExtensionConfigurationSchema,
21846
- desktopConnected: external_exports.boolean(),
21847
- diagnostics: external_exports.array(external_exports.string()),
21848
- extensions: external_exports.array(desktopExtensionListItemSchema)
21849
- });
21850
- var desktopExtensionsCatalogParamsSchema = external_exports.strictObject({
21851
- forceRefresh: external_exports.boolean().optional()
21852
- });
21853
- var desktopExtensionsCatalogResultSchema = external_exports.strictObject({
21854
- catalogUrl: external_exports.string(),
21855
- source: external_exports.enum(["remote", "fallback"]),
21856
- fetchedAt: external_exports.string(),
21857
- cached: external_exports.boolean(),
21858
- extensions: desktopExtensionCatalogSchema.shape.extensions,
21859
- error: external_exports.string().optional()
21860
- });
21861
- var desktopExtensionsInstallParamsSchema = external_exports.strictObject({
21862
- source: external_exports.discriminatedUnion("type", [
21863
- external_exports.strictObject({ type: external_exports.literal("catalog"), id: desktopExtensionIdSchema }),
21864
- external_exports.strictObject({
21865
- type: external_exports.literal("url"),
21866
- url: desktopExtensionHttpUrlSchema,
21867
- expectedSha256: desktopExtensionHashSchema.optional()
21868
- }),
21869
- external_exports.strictObject({
21870
- type: external_exports.literal("zip-base64"),
21871
- fileName: external_exports.string().trim().min(1).max(255),
21872
- contentBase64: external_exports.string().min(4).max(DESKTOP_EXTENSION_ZIP_MAX_BASE64_LENGTH).refine((value) => value.length % 4 === 0 && /^[A-Za-z0-9+/]+={0,2}$/u.test(value), "Expected standard padded base64")
21873
- })
21874
- ])
21875
- });
21876
- var desktopExtensionsInstallResultSchema = external_exports.strictObject({
21877
- extensionId: desktopExtensionIdSchema,
21878
- version: external_exports.string().min(1),
21879
- replaced: external_exports.boolean(),
21880
- installedPath: external_exports.string(),
21881
- list: desktopExtensionsListResultSchema
21882
- });
21883
- var desktopExtensionsUninstallParamsSchema = external_exports.strictObject({
21884
- id: desktopExtensionIdSchema
21885
- });
21886
- var desktopExtensionsUninstallResultSchema = external_exports.strictObject({
21887
- removedId: desktopExtensionIdSchema,
21888
- list: desktopExtensionsListResultSchema
21889
- });
21890
- var desktopExtensionMutationResultSchema = external_exports.discriminatedUnion("state", [
21891
- external_exports.strictObject({ state: external_exports.literal("saved"), configuration: desktopExtensionConfigurationSchema }),
21892
- external_exports.strictObject({ state: external_exports.literal("slot-conflict"), conflictWith: desktopExtensionIdSchema }),
21893
- external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: revisionSchema })
21894
- ]);
21895
-
21896
- // ../../shared-contracts/dist/errors.js
21897
- var codexhostErrorSchema = external_exports.strictObject({
21898
- code: external_exports.string().min(1),
21899
- message: external_exports.string().min(1),
21900
- retryable: external_exports.boolean(),
21901
- diagnostic: external_exports.string().min(1).optional(),
21902
- stage: external_exports.string().min(1).optional(),
21903
- durationMs: external_exports.number().int().nonnegative().optional(),
21904
- stderrTail: external_exports.string().min(1).optional()
21905
- }).superRefine(rejectExplicitUndefined(["diagnostic", "stage", "durationMs", "stderrTail"]));
21906
-
21907
- // ../../shared-contracts/dist/harness-presentation.js
21908
- var localeSchema = external_exports.string().max(64).regex(/^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/u);
21909
- var displayText = (maximum) => external_exports.string().min(1).max(maximum).refine((text) => text.trim().length > 0);
21910
- var harnessLocalizationsSchema = external_exports.record(localeSchema, external_exports.object({
21911
- label: displayText(256).optional(),
21912
- description: displayText(1024).optional()
21913
- }).strict()).refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
21914
- var harnessLocalizedTextSchema = external_exports.record(localeSchema, displayText(4096)).refine((entries) => typeof entries.en === "string", "English fallback is required").refine((entries) => Object.keys(entries).length <= 16, "Too many locales");
21915
-
21916
- // ../../shared-contracts/dist/harness-permission-modes.js
21917
- var HARNESS_PERMISSION_MODE_ID_MAX_LENGTH = 128;
21918
- var HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH = 256;
21919
- var HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH = 1024;
21920
- var HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH = 32;
21921
- var nonBlankTextSchema = external_exports.string().refine((value) => value.trim().length > 0, {
21922
- message: "Value must not be empty or whitespace"
21923
- });
21924
- var harnessPermissionModeIdSchema = nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_ID_MAX_LENGTH).regex(/^[A-Za-z0-9._~:-]+$/u, "Permission Mode ID must use transport-safe characters").brand();
21925
- var harnessPermissionModeSchema = external_exports.object({
21926
- id: harnessPermissionModeIdSchema,
21927
- label: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_LABEL_MAX_LENGTH),
21928
- description: nonBlankTextSchema.max(HARNESS_PERMISSION_MODE_DESCRIPTION_MAX_LENGTH).optional(),
21929
- dangerous: external_exports.boolean().optional(),
21930
- localizations: harnessLocalizationsSchema.optional()
21931
- }).strict();
21932
- var harnessPermissionModeCatalogSchema = external_exports.object({
21933
- modes: external_exports.array(harnessPermissionModeSchema).min(1).max(HARNESS_PERMISSION_MODE_CATALOG_MAX_LENGTH),
21934
- defaultModeId: harnessPermissionModeIdSchema
21935
- }).strict().superRefine((catalog, context) => {
21936
- const ids = /* @__PURE__ */ new Set();
21937
- for (const [index, mode] of catalog.modes.entries()) {
21938
- if (ids.has(mode.id)) {
21939
- context.addIssue({
21940
- code: "custom",
21941
- message: "Permission Mode IDs must be unique",
21942
- path: ["modes", index, "id"]
21943
- });
21944
- }
21945
- ids.add(mode.id);
21946
- }
21947
- if (!ids.has(catalog.defaultModeId)) {
21948
- context.addIssue({
21949
- code: "custom",
21950
- message: "Default Permission Mode must exist in the catalog",
21951
- path: ["defaultModeId"]
21952
- });
21536
+ if (!ids.has(catalog.defaultModeId)) {
21537
+ context.addIssue({
21538
+ code: "custom",
21539
+ message: "Default Permission Mode must exist in the catalog",
21540
+ path: ["defaultModeId"]
21541
+ });
21953
21542
  }
21954
21543
  });
21955
21544
  var threadPermissionModeSelectParamsSchema = external_exports.object({
@@ -21957,6 +21546,9 @@ var threadPermissionModeSelectParamsSchema = external_exports.object({
21957
21546
  permissionModeId: harnessPermissionModeIdSchema
21958
21547
  }).strict();
21959
21548
 
21549
+ // ../../shared-contracts/dist/harness-route-limit.js
21550
+ var HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH = 8192;
21551
+
21960
21552
  // ../../shared-contracts/dist/thread-usage.js
21961
21553
  var nonNegativeSafeIntegerSchema = external_exports.number().int().safe().nonnegative();
21962
21554
  var finiteNonNegativeNumberSchema = external_exports.number().finite().nonnegative();
@@ -21982,14 +21574,14 @@ var usageMeasurementsSchema = external_exports.object({
21982
21574
  outputTokensPerSecond: usageMeasurementSchema.refine((value) => value.version === 4).optional().catch(void 0),
21983
21575
  timeToFirstOutputMs: usageMeasurementSchema.extend({ value: nonNegativeSafeIntegerSchema }).optional()
21984
21576
  }).strict();
21985
- var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text) => text.length <= maximum));
21577
+ var indicatorTextSchema = (maximum) => harnessLocalizedTextSchema.refine((entries) => Object.values(entries).every((text2) => text2.length <= maximum));
21986
21578
  var composerIndicatorsSchema = external_exports.array(external_exports.object({
21987
21579
  kind: external_exports.literal("countdown"),
21988
21580
  id: external_exports.string().min(1).max(64),
21989
21581
  expiresAtUnix: nonNegativeSafeIntegerSchema,
21990
21582
  label: indicatorTextSchema(256).optional(),
21991
21583
  tooltip: indicatorTextSchema(1024).optional()
21992
- }).strict()).max(2).refine((entries) => new Set(entries.map(({ id }) => id)).size === entries.length, {
21584
+ }).strict()).max(2).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, {
21993
21585
  message: "Composer indicator IDs must be unique"
21994
21586
  });
21995
21587
  var threadUsageSnapshotSchema = external_exports.object({
@@ -22015,6 +21607,7 @@ var threadUsageSnapshotSchema = external_exports.object({
22015
21607
  planSevenDayResetsAtUnix: nonNegativeSafeIntegerSchema.optional(),
22016
21608
  sessionCacheHitRatePercent: cacheHitRatePercentSchema.optional(),
22017
21609
  timeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
21610
+ latestRequestTimeToFirstOutputMs: nonNegativeSafeIntegerSchema.optional(),
22018
21611
  costSource: external_exports.enum(["publicPrice", "native"]).optional(),
22019
21612
  unpricedModels: external_exports.array(external_exports.string().min(1)).min(1).optional()
22020
21613
  }).strict().superRefine((usage, context) => {
@@ -22142,10 +21735,15 @@ var THREAD_OWNERSHIP_LIST_MAX_LENGTH = 100;
22142
21735
  var nonBlankTextSchema2 = external_exports.string().refine((value) => value.trim().length > 0, {
22143
21736
  message: "Value must not be empty or whitespace"
22144
21737
  });
22145
- var harnessModelRefIdSchema = nonBlankTextSchema2.max(HARNESS_MODEL_REF_MAX_LENGTH).regex(/^[A-Za-z0-9._~-]+$/u, "Model Ref must use transport-safe opaque characters").brand();
21738
+ var harnessModelRefIdSchema = external_exports.string().min(1).max(HARNESS_MODEL_REF_MAX_LENGTH).refine((id2) => !new RegExp("\\p{Cc}", "u").test(id2), "Model Ref must not contain control characters").brand();
21739
+ var harnessModelServiceTierSchema = external_exports.enum(["priority", "ultrafast"]);
22146
21740
  var harnessModelRefSchema = external_exports.object({
22147
- id: harnessModelRefIdSchema
21741
+ id: harnessModelRefIdSchema,
21742
+ serviceTier: harnessModelServiceTierSchema.optional()
22148
21743
  }).strict();
21744
+ function sameHarnessModelRef(left, right) {
21745
+ return left?.id === right?.id && left?.serviceTier === right?.serviceTier;
21746
+ }
22149
21747
  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();
22150
21748
  var harnessResolvedModelLabelSchema = nonBlankTextSchema2.max(HARNESS_MODEL_LABEL_MAX_LENGTH);
22151
21749
  var harnessThinkingOptionSchema = external_exports.object({
@@ -22159,7 +21757,15 @@ var harnessModelSchema = external_exports.object({
22159
21757
  /** Optional opaque selection for this same Model with priority processing enabled. */
22160
21758
  fastModel: harnessModelRefSchema.optional(),
22161
21759
  supportedThinkingOptionIds: external_exports.array(harnessThinkingOptionIdSchema).optional()
22162
- }).strict();
21760
+ }).strict().refine((model2) => model2.fastModel?.serviceTier === void 0 || model2.fastModel.id === model2.ref.id, {
21761
+ path: ["fastModel", "id"],
21762
+ message: "A tiered Fast Model must share the base Model ID"
21763
+ });
21764
+ function catalogModelForRef(catalog, ref) {
21765
+ if (!ref)
21766
+ return void 0;
21767
+ return catalog?.models.find((model2) => sameHarnessModelRef(model2.ref, ref) || sameHarnessModelRef(model2.fastModel, ref));
21768
+ }
22163
21769
  var harnessThinkingOptionsSchema = external_exports.array(harnessThinkingOptionSchema).superRefine((options, context) => {
22164
21770
  const ids = /* @__PURE__ */ new Set();
22165
21771
  for (const [index, option] of options.entries()) {
@@ -22179,26 +21785,26 @@ var harnessModelCatalogSchema = external_exports.object({
22179
21785
  thinkingOptions: harnessThinkingOptionsSchema,
22180
21786
  defaultThinkingOptionId: harnessThinkingOptionIdSchema.optional()
22181
21787
  }).strict().superRefine((catalog, context) => {
22182
- const refs = /* @__PURE__ */ new Set();
22183
- const thinkingIds = new Set(catalog.thinkingOptions.map(({ id }) => id));
21788
+ const refs = [];
21789
+ const thinkingIds = new Set(catalog.thinkingOptions.map(({ id: id2 }) => id2));
22184
21790
  for (const [index, model2] of catalog.models.entries()) {
22185
- if (refs.has(model2.ref.id)) {
21791
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.ref))) {
22186
21792
  context.addIssue({
22187
21793
  code: "custom",
22188
21794
  message: "Model Catalog refs must be unique",
22189
21795
  path: ["models", index, "ref", "id"]
22190
21796
  });
22191
21797
  }
22192
- refs.add(model2.ref.id);
21798
+ refs.push(model2.ref);
22193
21799
  if (model2.fastModel) {
22194
- if (refs.has(model2.fastModel.id) || catalog.models.some((entry) => entry.ref.id === model2.fastModel?.id)) {
21800
+ if (refs.some((ref) => sameHarnessModelRef(ref, model2.fastModel))) {
22195
21801
  context.addIssue({
22196
21802
  code: "custom",
22197
21803
  message: "Fast Model refs must be distinct and unique",
22198
21804
  path: ["models", index, "fastModel"]
22199
21805
  });
22200
21806
  }
22201
- refs.add(model2.fastModel.id);
21807
+ refs.push(model2.fastModel);
22202
21808
  }
22203
21809
  const supportedThinkingIds = /* @__PURE__ */ new Set();
22204
21810
  for (const [optionIndex, optionId] of (model2.supportedThinkingOptionIds ?? []).entries()) {
@@ -22219,7 +21825,7 @@ var harnessModelCatalogSchema = external_exports.object({
22219
21825
  }
22220
21826
  }
22221
21827
  }
22222
- if (catalog.defaultModel && !refs.has(catalog.defaultModel.id)) {
21828
+ if (catalog.defaultModel && !catalogModelForRef(catalog, catalog.defaultModel)) {
22223
21829
  context.addIssue({
22224
21830
  code: "custom",
22225
21831
  message: "Default Model must exist in the Model Catalog",
@@ -22259,7 +21865,12 @@ var harnessSessionCapabilitiesSchema = external_exports.object({
22259
21865
  observe: external_exports.boolean()
22260
21866
  }).strict().optional(),
22261
21867
  /** True only when `turn.steer` delivers input into the active Turn through a native primitive. */
22262
- steer: external_exports.boolean().optional()
21868
+ steer: external_exports.boolean().optional(),
21869
+ /**
21870
+ * True when the native plan (task list) outlives the Turn that changed it, so a reopened
21871
+ * Thread gets its latest plan again. Otherwise a plan stays with the Turn that made it.
21872
+ */
21873
+ persistentPlan: external_exports.boolean().optional()
22263
21874
  }).strict();
22264
21875
  var harnessConfigurationStateSchema = external_exports.object({
22265
21876
  effectiveModel: harnessModelRefSchema.optional(),
@@ -22268,7 +21879,7 @@ var harnessConfigurationStateSchema = external_exports.object({
22268
21879
  availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
22269
21880
  effectivePermissionModeId: harnessPermissionModeIdSchema.optional()
22270
21881
  }).strict().superRefine((state, context) => {
22271
- if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id }) => id === state.effectiveThinkingOptionId)) {
21882
+ if (state.effectiveThinkingOptionId && state.availableThinkingOptions && !state.availableThinkingOptions.some(({ id: id2 }) => id2 === state.effectiveThinkingOptionId)) {
22272
21883
  context.addIssue({
22273
21884
  code: "custom",
22274
21885
  message: "Effective Thinking option must be currently available",
@@ -22276,150 +21887,698 @@ var harnessConfigurationStateSchema = external_exports.object({
22276
21887
  });
22277
21888
  }
22278
21889
  });
22279
- var harnessWebUiCapabilitySchema = external_exports.object({
22280
- open: external_exports.literal(true)
22281
- }).strict();
22282
- var readyHarnessInspectionSchema = external_exports.object({
22283
- status: external_exports.literal("ready"),
22284
- catalog: harnessModelCatalogSchema,
22285
- permissionModes: harnessPermissionModeCatalogSchema.optional(),
22286
- capabilities: harnessSessionCapabilitiesSchema,
22287
- webUi: harnessWebUiCapabilitySchema.optional()
22288
- }).strict().superRefine((inspection, context) => {
22289
- const selectable = inspection.capabilities.configuration.selectPermissionMode;
22290
- if (selectable !== Boolean(inspection.permissionModes)) {
22291
- context.addIssue({
22292
- code: "custom",
22293
- message: "Permission Mode catalog and capability must agree",
22294
- path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
22295
- });
22296
- }
21890
+ var harnessWebUiCapabilitySchema = external_exports.object({
21891
+ open: external_exports.literal(true)
21892
+ }).strict();
21893
+ var readyHarnessInspectionSchema = external_exports.object({
21894
+ status: external_exports.literal("ready"),
21895
+ catalog: harnessModelCatalogSchema,
21896
+ permissionModes: harnessPermissionModeCatalogSchema.optional(),
21897
+ capabilities: harnessSessionCapabilitiesSchema,
21898
+ webUi: harnessWebUiCapabilitySchema.optional()
21899
+ }).strict().superRefine((inspection, context) => {
21900
+ const selectable = inspection.capabilities.configuration.selectPermissionMode;
21901
+ if (selectable !== Boolean(inspection.permissionModes)) {
21902
+ context.addIssue({
21903
+ code: "custom",
21904
+ message: "Permission Mode catalog and capability must agree",
21905
+ path: selectable ? ["permissionModes"] : ["capabilities", "configuration", "selectPermissionMode"]
21906
+ });
21907
+ }
21908
+ });
21909
+ var failedHarnessInspectionSchema = external_exports.object({
21910
+ status: external_exports.enum(["notInstalled", "unavailable", "error"]),
21911
+ error: codexhostErrorSchema
21912
+ }).strict();
21913
+ var harnessInspectionSchema = external_exports.union([
21914
+ readyHarnessInspectionSchema,
21915
+ failedHarnessInspectionSchema
21916
+ ]);
21917
+ var harnessInspectParamsSchema = external_exports.object({
21918
+ harnessId: harnessIdSchema,
21919
+ cwd: nonBlankTextSchema2.max(16384).optional(),
21920
+ refresh: external_exports.boolean().optional(),
21921
+ /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
21922
+ purpose: external_exports.literal("availability").optional(),
21923
+ credentialAccess: external_exports.enum(["allow", "retry"]).optional()
21924
+ }).strict();
21925
+ var harnessWebUiOpenParamsSchema = external_exports.object({
21926
+ harnessId: harnessIdSchema
21927
+ }).strict();
21928
+ var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
21929
+ var threadModelSelectParamsSchema = external_exports.object({
21930
+ threadId: hostThreadIdSchema,
21931
+ model: harnessModelRefSchema
21932
+ }).strict();
21933
+ var threadThinkingSelectParamsSchema = external_exports.object({
21934
+ threadId: hostThreadIdSchema,
21935
+ thinkingOptionId: harnessThinkingOptionIdSchema
21936
+ }).strict();
21937
+ var threadInspectionParamsSchema = external_exports.object({
21938
+ threadId: hostThreadIdSchema,
21939
+ includeReferenceCapability: external_exports.boolean().optional()
21940
+ }).strict();
21941
+ var codexThreadInspectionSchema = external_exports.object({
21942
+ owner: external_exports.literal("codex"),
21943
+ locked: external_exports.boolean(),
21944
+ effectiveModel: harnessModelRefSchema.optional(),
21945
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
21946
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
21947
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
21948
+ history: harnessHistoryCapabilitiesSchema.optional(),
21949
+ supportsThreadReferences: external_exports.literal(true).optional()
21950
+ }).strict();
21951
+ var externalThreadInspectionSchema = external_exports.object({
21952
+ owner: external_exports.literal("external"),
21953
+ harnessId: nonBlankTextSchema2.max(256),
21954
+ transportModelId: nonBlankTextSchema2.max(HARNESS_TRANSPORT_MODEL_ID_MAX_LENGTH),
21955
+ effectiveModel: harnessModelRefSchema.optional(),
21956
+ resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
21957
+ effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
21958
+ availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
21959
+ effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
21960
+ /** Live Session catalog when it, not the Adapter inspection, contains `effectiveModel`. */
21961
+ catalog: harnessModelCatalogSchema.optional(),
21962
+ history: harnessHistoryCapabilitiesSchema,
21963
+ usage: threadUsageSnapshotSchema.optional(),
21964
+ locked: external_exports.literal(true)
21965
+ }).strict();
21966
+ var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
21967
+ codexThreadInspectionSchema,
21968
+ externalThreadInspectionSchema
21969
+ ]);
21970
+ var threadOwnershipListParamsSchema = external_exports.object({
21971
+ threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
21972
+ }).strict().superRefine(({ threadIds }, context) => {
21973
+ const seen = /* @__PURE__ */ new Set();
21974
+ for (const [index, threadId] of threadIds.entries()) {
21975
+ if (seen.has(threadId)) {
21976
+ context.addIssue({
21977
+ code: "custom",
21978
+ message: "Thread ownership-list IDs must be unique",
21979
+ path: ["threadIds", index]
21980
+ });
21981
+ }
21982
+ seen.add(threadId);
21983
+ }
21984
+ });
21985
+ var codexThreadOwnershipSchema = external_exports.object({
21986
+ threadId: hostThreadIdSchema,
21987
+ owner: external_exports.literal("codex")
21988
+ }).strict();
21989
+ var externalThreadOwnershipSchema = external_exports.object({
21990
+ threadId: hostThreadIdSchema,
21991
+ owner: external_exports.literal("external"),
21992
+ harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
21993
+ }).strict();
21994
+ var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
21995
+ codexThreadOwnershipSchema,
21996
+ externalThreadOwnershipSchema
21997
+ ]);
21998
+ var threadOwnershipListResultSchema = external_exports.object({
21999
+ threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
22000
+ }).strict().superRefine(({ threads }, context) => {
22001
+ const seen = /* @__PURE__ */ new Set();
22002
+ for (const [index, thread2] of threads.entries()) {
22003
+ if (seen.has(thread2.threadId)) {
22004
+ context.addIssue({
22005
+ code: "custom",
22006
+ message: "Thread ownership-list results must be unique",
22007
+ path: ["threads", index, "threadId"]
22008
+ });
22009
+ }
22010
+ seen.add(thread2.threadId);
22011
+ }
22012
+ });
22013
+ var threadSteeringInspectParamsSchema = external_exports.object({
22014
+ threadId: hostThreadIdSchema,
22015
+ /** The text about to be steered; a Harness command always stops and restarts. */
22016
+ text: external_exports.string().optional()
22017
+ }).strict();
22018
+ var threadSteeringContextSchema = external_exports.object({
22019
+ kind: external_exports.literal("application"),
22020
+ value: external_exports.string().transform((text2, context) => {
22021
+ try {
22022
+ return JSON.parse(text2);
22023
+ } catch {
22024
+ context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
22025
+ return external_exports.NEVER;
22026
+ }
22027
+ }).pipe(external_exports.object({
22028
+ expectedTurnId: hostTurnIdSchema,
22029
+ clientUserMessageId: external_exports.string().min(1),
22030
+ delivery: external_exports.enum(["newTurn", "activeTurn"])
22031
+ }).strict())
22032
+ }).strict().transform((context) => context.value);
22033
+ var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
22034
+ var threadSteeringInspectResultSchema = external_exports.object({
22035
+ delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
22036
+ }).strict();
22037
+
22038
+ // ../../shared-contracts/dist/harness-plugins.js
22039
+ var HARNESS_PLUGIN_MANIFEST_MAX_BYTES = 32 * 1024;
22040
+ var HARNESS_PLUGIN_ICON_MAX_BYTES = 128 * 1024;
22041
+ var HARNESS_PLUGIN_LIMIT = 128;
22042
+ var installedPluginIdSchema = external_exports.string().min(1).max(128).regex(/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u);
22043
+ var installedHarnessPluginIdSchema = installedPluginIdSchema.pipe(harnessIdSchema);
22044
+ var harnessPluginIdSchema = installedHarnessPluginIdSchema.refine((id2) => id2 !== "codex", "The official Codex identity is reserved");
22045
+ 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");
22046
+ var documentationUrlSchema = external_exports.url().refine((value) => /^https:\/\/[^/?#@]+(?:[/?#]|$)/iu.test(value), "Plugin documentation links must be credential-free HTTPS URLs");
22047
+ var localizedTextSchema = external_exports.object({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).strict();
22048
+ var harnessInstallationGuideSchema = external_exports.object({
22049
+ commands: external_exports.array(external_exports.object({ terminal: external_exports.string().max(256), command: external_exports.string().max(4096) }).strict()).max(8),
22050
+ before: localizedTextSchema.optional(),
22051
+ after: localizedTextSchema.optional(),
22052
+ downloads: external_exports.array(external_exports.object({ label: external_exports.string().max(128), url: documentationUrlSchema }).strict()).max(8).optional()
22053
+ }).strict();
22054
+ var pluginPresentationShape = {
22055
+ id: installedHarnessPluginIdSchema,
22056
+ name: external_exports.string().trim().min(1).max(128),
22057
+ version: external_exports.string().min(1).max(128),
22058
+ /** Capability-only plugin; omitted for existing session-capable plugins. */
22059
+ kind: external_exports.literal("usage").optional(),
22060
+ /** Original image styling or bounded vector paths; never arbitrary CSS/SVG markup. */
22061
+ iconStyle: external_exports.object({
22062
+ vector: external_exports.object({
22063
+ viewBox: external_exports.string().max(128).regex(/^-?\d+(?:\.\d+)?(?: +-?\d+(?:\.\d+)?){3}$/u),
22064
+ color: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu),
22065
+ paths: external_exports.array(external_exports.object({
22066
+ d: external_exports.string().min(1).max(32768).regex(/^[MmLlHhVvCcSsQqTtAaZz\d.,+eE\s-]+$/u),
22067
+ fillRule: external_exports.enum(["evenodd", "nonzero"]).optional(),
22068
+ fill: external_exports.string().regex(/^(?:currentColor|#[a-f0-9]{6})$/iu).optional()
22069
+ }).strict()).min(1).max(32)
22070
+ }).strict().optional(),
22071
+ background: external_exports.string().regex(/^#[a-f0-9]{6}$/iu).optional(),
22072
+ borderRadius: external_exports.number().min(0).max(50).optional(),
22073
+ paddingRatio: external_exports.number().min(0).max(0.25).optional()
22074
+ }).strict().optional(),
22075
+ installation: harnessInstallationGuideSchema.optional(),
22076
+ notice: localizedTextSchema.optional(),
22077
+ /** The factory accepts a persisted local entrypoint through its construction context. */
22078
+ launchCommand: external_exports.literal(true).optional(),
22079
+ links: external_exports.object({
22080
+ website: documentationUrlSchema.optional(),
22081
+ documentation: documentationUrlSchema.optional(),
22082
+ installation: documentationUrlSchema.optional()
22083
+ }).strict().optional()
22084
+ };
22085
+ var harnessPluginManifestSchema = external_exports.object({
22086
+ manifestVersion: external_exports.literal(1),
22087
+ ...pluginPresentationShape,
22088
+ adapterApiVersion: external_exports.number().int().positive(),
22089
+ entry: pluginRelativeResourceSchema,
22090
+ icon: pluginRelativeResourceSchema.optional()
22091
+ }).strict();
22092
+ 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);
22093
+ var harnessPluginDescriptorSchema = external_exports.object({
22094
+ ...pluginPresentationShape,
22095
+ icon: harnessPluginIconSchema.optional()
22096
+ }).strict();
22097
+ var harnessPluginListParamsSchema = external_exports.object({}).strict();
22098
+ var harnessPluginListResultSchema = external_exports.object({
22099
+ plugins: external_exports.array(harnessPluginDescriptorSchema.extend({ id: harnessPluginIdSchema })).max(HARNESS_PLUGIN_LIMIT)
22100
+ }).strict();
22101
+ var harnessPluginConfigurationSchema = external_exports.object({
22102
+ version: external_exports.literal(1),
22103
+ enabled: external_exports.array(installedHarnessPluginIdSchema).max(HARNESS_PLUGIN_LIMIT)
22104
+ }).strict().refine((value) => new Set(value.enabled).size === value.enabled.length, {
22105
+ message: "Enabled plugin IDs must be unique",
22106
+ path: ["enabled"]
22107
+ });
22108
+
22109
+ // ../../shared-contracts/dist/desktop-extensions.js
22110
+ var DESKTOP_EXTENSION_API_VERSION = 1;
22111
+ var DESKTOP_EXTENSION_LIMIT = 64;
22112
+ var DESKTOP_EXTENSION_ZIP_MAX_BYTES = 64 * 1024 * 1024;
22113
+ var DESKTOP_EXTENSION_MANIFEST_MAX_BYTES = 128 * 1024;
22114
+ var DESKTOP_EXTENSION_SCRIPT_MAX_BYTES = 2 * 1024 * 1024;
22115
+ var DESKTOP_EXTENSION_STYLE_MAX_BYTES = 256 * 1024;
22116
+ var DESKTOP_EXTENSION_ICON_MAX_BYTES = 128 * 1024;
22117
+ var DESKTOP_EXTENSION_SCREENSHOT_LIMIT = 4;
22118
+ var DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES = 512 * 1024;
22119
+ var DESKTOP_EXTENSION_LIST_SCREENSHOTS_MAX_BYTES = 8 * 1024 * 1024;
22120
+ var DESKTOP_EXTENSION_SNAPSHOT_MAX_BYTES = 8 * 1024 * 1024;
22121
+ var DESKTOP_EXTENSION_ASSET_MAX_BYTES = 16 * 1024 * 1024;
22122
+ var DESKTOP_EXTENSION_SETTINGS_MAX_BYTES = 1024 * 1024;
22123
+ var desktopExtensionIdSchema = installedPluginIdSchema;
22124
+ var desktopExtensionSlotSchema = external_exports.enum([
22125
+ "sidebar.thread-layout",
22126
+ "sidebar.thread-badge",
22127
+ "appearance.theme"
22128
+ ]);
22129
+ var desktopExtensionCategorySchema = external_exports.enum([
22130
+ "appearance",
22131
+ "interface",
22132
+ "workflow",
22133
+ "analytics",
22134
+ "integrations",
22135
+ "tools"
22136
+ ]);
22137
+ var extensionName = external_exports.string().trim().min(1).max(128);
22138
+ function desktopExtensionScreenshotMimeType(resource) {
22139
+ switch (resource.match(/\.([^./]+)$/u)?.[1]?.toLowerCase()) {
22140
+ case "png":
22141
+ return "image/png";
22142
+ case "jpg":
22143
+ case "jpeg":
22144
+ return "image/jpeg";
22145
+ case "webp":
22146
+ return "image/webp";
22147
+ default:
22148
+ return void 0;
22149
+ }
22150
+ }
22151
+ var hasPortableSegments = (resource) => resource.split("/").every((segment) => !/[. ]$/u.test(segment));
22152
+ 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");
22153
+ 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) => {
22154
+ const { username, password } = new URL(value);
22155
+ return !username && !password && !/[\\\s]/u.test(value);
22156
+ }, "URL must not contain credentials, backslashes, or whitespace");
22157
+ function localizedText(text2) {
22158
+ return external_exports.strictObject({ en: text2, "zh-CN": text2 });
22159
+ }
22160
+ var desktopExtensionLocalizedTextSchema = localizedText(external_exports.string().trim().min(1));
22161
+ var categoriesSchema = external_exports.array(desktopExtensionCategorySchema).max(desktopExtensionCategorySchema.options.length).refine((categories) => new Set(categories).size === categories.length, "Duplicate categories");
22162
+ var slotsSchema = external_exports.array(desktopExtensionSlotSchema).max(desktopExtensionSlotSchema.options.length).refine((slots) => new Set(slots).size === slots.length, "Duplicate slots");
22163
+ var settingField = {
22164
+ key: external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/u),
22165
+ label: desktopExtensionLocalizedTextSchema,
22166
+ description: desktopExtensionLocalizedTextSchema.optional()
22167
+ };
22168
+ var numericSetting = {
22169
+ ...settingField,
22170
+ step: external_exports.number().positive().optional(),
22171
+ default: external_exports.number().optional()
22172
+ };
22173
+ var settingOption = external_exports.strictObject({
22174
+ value: external_exports.string(),
22175
+ label: desktopExtensionLocalizedTextSchema
22176
+ });
22177
+ var desktopExtensionSettingFieldSchema = external_exports.discriminatedUnion("type", [
22178
+ external_exports.strictObject({
22179
+ ...settingField,
22180
+ type: external_exports.literal("boolean"),
22181
+ default: external_exports.boolean().optional()
22182
+ }),
22183
+ external_exports.strictObject({
22184
+ ...settingField,
22185
+ type: external_exports.literal("string"),
22186
+ placeholder: desktopExtensionLocalizedTextSchema.optional(),
22187
+ default: external_exports.string().optional()
22188
+ }),
22189
+ external_exports.strictObject({
22190
+ ...numericSetting,
22191
+ type: external_exports.literal("number"),
22192
+ min: external_exports.number().optional(),
22193
+ max: external_exports.number().optional()
22194
+ }),
22195
+ external_exports.strictObject({
22196
+ ...numericSetting,
22197
+ type: external_exports.literal("range"),
22198
+ min: external_exports.number(),
22199
+ max: external_exports.number()
22200
+ }),
22201
+ external_exports.strictObject({
22202
+ ...settingField,
22203
+ type: external_exports.literal("select"),
22204
+ options: external_exports.array(settingOption).min(1),
22205
+ default: external_exports.string().optional()
22206
+ })
22207
+ ]).superRefine((field2, ctx) => {
22208
+ const issue2 = (path6, message) => ctx.addIssue({ code: "custom", path: [path6], message });
22209
+ if (field2.type === "number" || field2.type === "range") {
22210
+ const { min = -Infinity, max = Infinity, default: value } = field2;
22211
+ if (min > max)
22212
+ issue2("max", "Must be at least min");
22213
+ if (value !== void 0 && (value < min || value > max))
22214
+ issue2("default", "Must be within min and max");
22215
+ } else if (field2.type === "select") {
22216
+ const values = new Set(field2.options.map(({ value }) => value));
22217
+ if (values.size !== field2.options.length)
22218
+ issue2("options", "Duplicate option values");
22219
+ if (field2.default !== void 0 && !values.has(field2.default))
22220
+ issue2("default", "Must match an option value");
22221
+ }
22222
+ });
22223
+ var manifestHeader = external_exports.object({
22224
+ manifestVersion: external_exports.int().positive(),
22225
+ id: desktopExtensionIdSchema,
22226
+ name: external_exports.union([extensionName, localizedText(extensionName)]),
22227
+ version: external_exports.string().min(1).max(128),
22228
+ desktopApi: external_exports.int().positive()
22229
+ }).passthrough();
22230
+ var desktopExtensionManifestSchema = manifestHeader.extend({
22231
+ manifestVersion: external_exports.literal(1),
22232
+ desktopApi: external_exports.literal(DESKTOP_EXTENSION_API_VERSION),
22233
+ description: external_exports.strictObject({ en: external_exports.string().max(4096), "zh-CN": external_exports.string().max(4096).optional() }).optional(),
22234
+ author: external_exports.string().trim().min(1).max(128).optional(),
22235
+ repository: desktopExtensionHttpUrlSchema.optional(),
22236
+ details: external_exports.strictObject({ en: external_exports.string().max(16384), "zh-CN": external_exports.string().max(16384).optional() }).optional(),
22237
+ icon: imagePathSchema.optional(),
22238
+ screenshots: external_exports.array(imagePathSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).refine((screenshots) => new Set(screenshots).size === screenshots.length, "Duplicate screenshots").optional(),
22239
+ desktop: external_exports.strictObject({
22240
+ script: pluginRelativeResourceSchema,
22241
+ style: pluginRelativeResourceSchema.optional()
22242
+ }).optional(),
22243
+ backend: external_exports.strictObject({ script: pluginRelativeResourceSchema.refine(hasPortableSegments) }).optional(),
22244
+ slots: slotsSchema.default(() => []),
22245
+ settingsSchema: external_exports.array(desktopExtensionSettingFieldSchema).max(32).refine((fields) => new Set(fields.map(({ key }) => key)).size === fields.length, "Duplicate setting keys").optional(),
22246
+ categories: categoriesSchema.optional()
22247
+ }).strict().refine((manifest) => manifest.desktop !== void 0 || manifest.backend !== void 0, "Expected at least one desktop or backend entry");
22248
+ var desktopExtensionHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/u);
22249
+ var desktopExtensionStatusSchema = external_exports.strictObject({
22250
+ state: external_exports.enum([
22251
+ "running",
22252
+ "disabled",
22253
+ "invalid",
22254
+ "incompatible",
22255
+ "conflict",
22256
+ "failed",
22257
+ "waiting"
22258
+ ]),
22259
+ hash: desktopExtensionHashSchema.optional(),
22260
+ error: external_exports.string().optional(),
22261
+ conflictWith: desktopExtensionIdSchema.optional()
22262
+ });
22263
+ var desktopExtensionsDiagnosticSchema = external_exports.strictObject({
22264
+ controllerPid: external_exports.int().positive(),
22265
+ targetId: external_exports.string().nullable(),
22266
+ updatedAt: external_exports.iso.datetime(),
22267
+ handledReloadToken: external_exports.uuid().optional(),
22268
+ extensions: external_exports.record(external_exports.string(), desktopExtensionStatusSchema),
22269
+ surfaces: external_exports.record(external_exports.string(), desktopExtensionStatusSchema).optional()
22297
22270
  });
22298
- var failedHarnessInspectionSchema = external_exports.object({
22299
- status: external_exports.enum(["notInstalled", "unavailable", "error"]),
22300
- error: codexhostErrorSchema
22301
- }).strict();
22302
- var harnessInspectionSchema = external_exports.union([
22303
- readyHarnessInspectionSchema,
22304
- failedHarnessInspectionSchema
22271
+ var desktopExtensionTrustTierSchema = external_exports.enum(["official", "community"]);
22272
+ function isGitHubDesktopExtensionZipballUrl(url2) {
22273
+ return url2.origin === "https://api.github.com" && /^\/repos\/[\w-]+\/[\w.-]+\/zipball(?:\/[^/]+)?\/?$/u.test(url2.pathname);
22274
+ }
22275
+ var desktopExtensionZipUrlSchema = desktopExtensionHttpUrlSchema.refine((input2) => {
22276
+ const url2 = new URL(input2);
22277
+ 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);
22278
+ }, "Expected a .zip download URL or a GitHub zipball URL");
22279
+ var desktopExtensionCatalogEntrySchema = external_exports.strictObject({
22280
+ id: desktopExtensionIdSchema,
22281
+ version: external_exports.string().trim().min(1).max(128),
22282
+ name: desktopExtensionLocalizedTextSchema.extend({ en: extensionName, "zh-CN": extensionName }),
22283
+ description: localizedText(external_exports.string().trim().min(1).max(4096)),
22284
+ details: localizedText(external_exports.string().trim().min(1).max(16384)).optional(),
22285
+ author: external_exports.string().trim().min(1).max(128),
22286
+ repository: desktopExtensionHttpUrlSchema,
22287
+ stars: external_exports.number().int().min(0).optional(),
22288
+ downloads: external_exports.number().int().min(0).optional(),
22289
+ categories: categoriesSchema.optional(),
22290
+ trustTier: desktopExtensionTrustTierSchema.default("community"),
22291
+ icon: desktopExtensionHttpUrlSchema.optional(),
22292
+ screenshots: external_exports.array(desktopExtensionHttpUrlSchema).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
22293
+ downloadUrl: desktopExtensionZipUrlSchema,
22294
+ sha256: desktopExtensionHashSchema,
22295
+ slots: slotsSchema.optional(),
22296
+ publishedAt: external_exports.string().optional(),
22297
+ updatedAt: external_exports.string().optional(),
22298
+ minCodexHostVersion: external_exports.string().optional()
22299
+ });
22300
+ var desktopExtensionCatalogSchema = external_exports.strictObject({
22301
+ schemaVersion: external_exports.literal(1),
22302
+ generatedAt: external_exports.string(),
22303
+ extensions: external_exports.array(desktopExtensionCatalogEntrySchema).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
22304
+ });
22305
+ var desktopExtensionBackendMethodSchema = external_exports.string().trim().min(1).max(128);
22306
+
22307
+ // ../../shared-contracts/dist/host-extensions.js
22308
+ var reservedName = /^(?:con|prn|aux|nul|com[1-9¹²³]|lpt[1-9¹²³]) *(?:\.|$)/iu;
22309
+ var HOST_EXTENSION_PAGE_API_VERSION = 1;
22310
+ var hostExtensionIdSchema = desktopExtensionIdSchema.refine((id2) => !reservedName.test(id2), "Reserved extension ID");
22311
+ var hostExtensionTargetSchema = external_exports.enum(["desktop", "web"]);
22312
+ var hostExtensionDigestSchema = desktopExtensionHashSchema;
22313
+ var hostExtensionActivationIdSchema = external_exports.uuid();
22314
+ 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((path6) => path6.split("/").length <= 32, "Extension resources may be at most 32 segments deep");
22315
+ var legacy = desktopExtensionManifestSchema.shape;
22316
+ var localized = (max, min = 0) => external_exports.strictObject({
22317
+ en: external_exports.string().trim().min(min).max(max),
22318
+ "zh-CN": external_exports.string().trim().min(min).max(max)
22319
+ });
22320
+ var resourceWithSuffix = (suffix) => hostExtensionResourcePathSchema.refine((path6) => path6.endsWith(suffix), `Expected a ${suffix} file`);
22321
+ var moduleEntry = resourceWithSuffix(".mjs");
22322
+ var style = resourceWithSuffix(".css").optional();
22323
+ var hostExtensionCanonicalPath = (path6) => path6.normalize("NFC").toLowerCase();
22324
+ var hostExtensionManifestV2Schema = external_exports.strictObject({
22325
+ manifestVersion: external_exports.literal(2),
22326
+ id: hostExtensionIdSchema,
22327
+ name: localized(128, 1),
22328
+ version: external_exports.string().trim().min(1).max(128),
22329
+ description: localized(4096),
22330
+ details: localized(16384).optional(),
22331
+ author: legacy.author,
22332
+ repository: legacy.repository,
22333
+ icon: legacy.icon.refine((path6) => path6 === void 0 || hostExtensionResourcePathSchema.safeParse(path6).success),
22334
+ screenshots: legacy.screenshots.refine((paths) => paths === void 0 || paths.every((path6) => hostExtensionResourcePathSchema.safeParse(path6).success)),
22335
+ categories: legacy.categories,
22336
+ settingsSchema: legacy.settingsSchema,
22337
+ slots: legacy.slots.removeDefault().optional(),
22338
+ page: external_exports.strictObject({
22339
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
22340
+ entry: moduleEntry,
22341
+ style,
22342
+ title: localized(128, 1).optional()
22343
+ }).optional(),
22344
+ widget: external_exports.strictObject({
22345
+ apiVersion: external_exports.literal(HOST_EXTENSION_PAGE_API_VERSION),
22346
+ entry: moduleEntry,
22347
+ style
22348
+ }).optional(),
22349
+ desktop: external_exports.strictObject({ apiVersion: external_exports.literal(1), script: resourceWithSuffix(".js"), style }).optional(),
22350
+ 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(),
22351
+ backend: external_exports.strictObject({ apiVersion: external_exports.literal(1), entry: moduleEntry }).optional()
22352
+ }).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" });
22353
+ function targetsForCapabilities({ hasPage, hasWidget, hasDesktop, hasWeb, hasBackend }) {
22354
+ if (hasPage || hasWidget || hasBackend && !hasDesktop && !hasWeb)
22355
+ return ["desktop", "web"];
22356
+ const targets = [];
22357
+ if (hasDesktop)
22358
+ targets.push("desktop");
22359
+ if (hasWeb)
22360
+ targets.push("web");
22361
+ return targets;
22362
+ }
22363
+ var hostExtensionBackendMethodSchema = desktopExtensionBackendMethodSchema;
22364
+
22365
+ // ../../shared-contracts/dist/host-extension-management.js
22366
+ var HOST_EXTENSION_ZIP_MAX_BYTES = DESKTOP_EXTENSION_ZIP_MAX_BYTES;
22367
+ var hostExtensionRevisionSchema = external_exports.int().nonnegative();
22368
+ var hostExtensionConfigurationSchema = external_exports.strictObject({
22369
+ revision: hostExtensionRevisionSchema,
22370
+ enabled: external_exports.array(hostExtensionIdSchema).max(DESKTOP_EXTENSION_LIMIT).refine((ids) => new Set(ids).size === ids.length, "Duplicate extension IDs")
22371
+ });
22372
+ var { downloadUrl, ...catalogMetadata } = desktopExtensionCatalogEntrySchema.shape;
22373
+ var hostExtensionCatalogEntrySchema = external_exports.object({
22374
+ ...catalogMetadata,
22375
+ id: hostExtensionIdSchema,
22376
+ format: external_exports.literal("codexhost"),
22377
+ targets: external_exports.array(hostExtensionTargetSchema).min(1).max(2).refine((targets) => new Set(targets).size === targets.length, "Duplicate targets"),
22378
+ apis: external_exports.strictObject({
22379
+ page: external_exports.int().positive().optional(),
22380
+ widget: external_exports.int().positive().optional(),
22381
+ desktop: external_exports.int().positive().optional(),
22382
+ web: external_exports.int().positive().optional(),
22383
+ backend: external_exports.int().positive().optional()
22384
+ }),
22385
+ downloadUrl: downloadUrl.refine((url2) => url2.startsWith("https://"), "Expected HTTPS")
22386
+ }).refine(({ targets, apis }) => {
22387
+ const derived = targetsForCapabilities({
22388
+ hasPage: Boolean(apis.page),
22389
+ hasWidget: Boolean(apis.widget),
22390
+ hasDesktop: Boolean(apis.desktop),
22391
+ hasWeb: Boolean(apis.web),
22392
+ hasBackend: Boolean(apis.backend)
22393
+ });
22394
+ return targets.length === derived.length && derived.every((target2) => targets.includes(target2));
22395
+ }, "Catalog targets must match the declared APIs");
22396
+ var hostExtensionCatalogSchema = external_exports.object({
22397
+ schemaVersion: external_exports.literal(2),
22398
+ generatedAt: external_exports.string().min(1),
22399
+ extensions: external_exports.array(hostExtensionCatalogEntrySchema).max(1e4).refine((entries) => new Set(entries.map(({ id: id2 }) => id2)).size === entries.length, "Duplicate extension IDs")
22400
+ });
22401
+ var hostExtensionsCatalogResultSchema = hostExtensionCatalogSchema.extend({
22402
+ catalogUrl: desktopExtensionHttpUrlSchema,
22403
+ fetchedAt: external_exports.iso.datetime(),
22404
+ cached: external_exports.boolean()
22405
+ });
22406
+ var id = { id: hostExtensionIdSchema };
22407
+ var active = {
22408
+ ...id,
22409
+ activationId: hostExtensionActivationIdSchema,
22410
+ digest: hostExtensionDigestSchema
22411
+ };
22412
+ var optionalActivation = { ...id, activationId: active.activationId.optional() };
22413
+ var filePath = external_exports.string().min(1).max(4096).refine((path6) => /^(?:\/|[a-z]:[/\\])/iu.test(path6) && !path6.includes("\0") && !path6.split(/[/\\]/u).some((part) => part === "." || part === ".."), "Expected an absolute local path without dot segments");
22414
+ 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");
22415
+ function base643(maxBytes) {
22416
+ return external_exports.string().max(4 * Math.ceil(maxBytes / 3)).refine((value) => {
22417
+ const padding = value.endsWith("==") ? 2 : value.endsWith("=") ? 1 : 0;
22418
+ return value.length % 4 === 0 && value.length * 3 / 4 - padding <= maxBytes && /^[A-Za-z0-9+/]*={0,2}$/u.test(value);
22419
+ }, "Expected bounded standard padded base64");
22420
+ }
22421
+ var hostExtensionGitHubSourceSchema = external_exports.strictObject({
22422
+ type: external_exports.literal("github"),
22423
+ repository: external_exports.string().max(150).regex(/^[a-z0-9-]+\/[a-z0-9_-][a-z0-9_.-]*$/iu),
22424
+ ref: gitRef.optional(),
22425
+ tag: gitRef.optional(),
22426
+ asset: external_exports.string().max(255).regex(/^[a-z0-9_.-]+\.zip$/iu).optional(),
22427
+ subpath: hostExtensionResourcePathSchema.optional()
22428
+ }).refine(({ ref, tag, asset }) => !ref || !tag && !asset, "Use either a zipball ref or a release tag/asset");
22429
+ var hostExtensionInstallSourceSchema = external_exports.union([
22430
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
22431
+ hostExtensionGitHubSourceSchema,
22432
+ external_exports.strictObject({ type: external_exports.literal("zip"), base64: base643(HOST_EXTENSION_ZIP_MAX_BYTES).min(4) }),
22433
+ external_exports.strictObject({ type: external_exports.literal("zip"), localZipPath: filePath }),
22434
+ external_exports.strictObject({ type: external_exports.literal("localDir"), localDir: filePath })
22305
22435
  ]);
22306
- var harnessInspectParamsSchema = external_exports.object({
22307
- harnessId: harnessIdSchema,
22308
- cwd: nonBlankTextSchema2.max(16384).optional(),
22309
- refresh: external_exports.boolean().optional(),
22310
- /** `availability` asks only whether the Harness can run; see `InspectHarnessInput.purpose`. */
22311
- purpose: external_exports.literal("availability").optional()
22312
- }).strict();
22313
- var harnessWebUiOpenParamsSchema = external_exports.object({
22314
- harnessId: harnessIdSchema
22315
- }).strict();
22316
- var harnessWebUiOpenResultSchema = external_exports.object({}).strict();
22317
- var threadModelSelectParamsSchema = external_exports.object({
22318
- threadId: hostThreadIdSchema,
22319
- model: harnessModelRefSchema
22320
- }).strict();
22321
- var threadThinkingSelectParamsSchema = external_exports.object({
22322
- threadId: hostThreadIdSchema,
22323
- thinkingOptionId: harnessThinkingOptionIdSchema
22324
- }).strict();
22325
- var threadInspectionParamsSchema = external_exports.object({
22326
- threadId: hostThreadIdSchema,
22327
- includeReferenceCapability: external_exports.boolean().optional()
22328
- }).strict();
22329
- var codexThreadInspectionSchema = external_exports.object({
22330
- owner: external_exports.literal("codex"),
22331
- locked: external_exports.boolean(),
22332
- effectiveModel: harnessModelRefSchema.optional(),
22333
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
22334
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
22335
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
22336
- history: harnessHistoryCapabilitiesSchema.optional(),
22337
- supportsThreadReferences: external_exports.literal(true).optional()
22338
- }).strict();
22339
- var externalThreadInspectionSchema = external_exports.object({
22340
- owner: external_exports.literal("external"),
22341
- harnessId: nonBlankTextSchema2.max(256),
22342
- transportModelId: nonBlankTextSchema2.max(1024),
22343
- effectiveModel: harnessModelRefSchema.optional(),
22344
- resolvedModelLabel: harnessResolvedModelLabelSchema.optional(),
22345
- effectiveThinkingOptionId: harnessThinkingOptionIdSchema.optional(),
22346
- availableThinkingOptions: harnessThinkingOptionsSchema.optional(),
22347
- effectivePermissionModeId: harnessPermissionModeIdSchema.optional(),
22348
- history: harnessHistoryCapabilitiesSchema,
22349
- usage: threadUsageSnapshotSchema.optional(),
22350
- locked: external_exports.literal(true)
22351
- }).strict();
22352
- var threadInspectionSchema = external_exports.discriminatedUnion("owner", [
22353
- codexThreadInspectionSchema,
22354
- externalThreadInspectionSchema
22436
+ var hostExtensionProvenanceSchema = external_exports.discriminatedUnion("type", [
22437
+ external_exports.strictObject({ type: external_exports.literal("catalog"), ...id }),
22438
+ hostExtensionGitHubSourceSchema,
22439
+ external_exports.strictObject({ type: external_exports.literal("zip") }),
22440
+ external_exports.strictObject({ type: external_exports.literal("localDir") })
22355
22441
  ]);
22356
- var threadOwnershipListParamsSchema = external_exports.object({
22357
- threadIds: external_exports.array(hostThreadIdSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
22358
- }).strict().superRefine(({ threadIds }, context) => {
22359
- const seen = /* @__PURE__ */ new Set();
22360
- for (const [index, threadId] of threadIds.entries()) {
22361
- if (seen.has(threadId)) {
22362
- context.addIssue({
22363
- code: "custom",
22364
- message: "Thread ownership-list IDs must be unique",
22365
- path: ["threadIds", index]
22366
- });
22367
- }
22368
- seen.add(threadId);
22369
- }
22442
+ var hostExtensionInstallationSchema = external_exports.strictObject({
22443
+ ...active,
22444
+ manifest: hostExtensionManifestV2Schema,
22445
+ installedAt: external_exports.iso.datetime(),
22446
+ source: hostExtensionProvenanceSchema.optional()
22370
22447
  });
22371
- var codexThreadOwnershipSchema = external_exports.object({
22372
- threadId: hostThreadIdSchema,
22373
- owner: external_exports.literal("codex")
22374
- }).strict();
22375
- var externalThreadOwnershipSchema = external_exports.object({
22376
- threadId: hostThreadIdSchema,
22377
- owner: external_exports.literal("external"),
22378
- harnessId: external_exports.string().max(256).pipe(harnessIdSchema)
22379
- }).strict();
22380
- var threadOwnershipSchema = external_exports.discriminatedUnion("owner", [
22381
- codexThreadOwnershipSchema,
22382
- externalThreadOwnershipSchema
22448
+ 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);
22449
+ var desktopConflict = { desktopConflictWith: hostExtensionIdSchema.optional() };
22450
+ var backendState = external_exports.enum(["none", "inactive", "starting", "running", "failed"]);
22451
+ var hostExtensionListItemSchema = external_exports.discriminatedUnion("state", [
22452
+ hostExtensionInstallationSchema.extend({
22453
+ state: external_exports.literal("valid"),
22454
+ enabled: external_exports.boolean(),
22455
+ ...desktopConflict,
22456
+ iconDataUrl: rasterDataUrlSchema(DESKTOP_EXTENSION_ICON_MAX_BYTES).optional(),
22457
+ screenshotDataUrls: external_exports.array(rasterDataUrlSchema(DESKTOP_EXTENSION_SCREENSHOT_MAX_BYTES)).max(DESKTOP_EXTENSION_SCREENSHOT_LIMIT).optional(),
22458
+ backendState: backendState.optional(),
22459
+ backendError: external_exports.string().optional()
22460
+ }),
22461
+ external_exports.strictObject({
22462
+ state: external_exports.enum(["invalid", "incompatible"]),
22463
+ id: external_exports.string().min(1),
22464
+ enabled: external_exports.boolean(),
22465
+ error: external_exports.string()
22466
+ })
22383
22467
  ]);
22384
- var threadOwnershipListResultSchema = external_exports.object({
22385
- threads: external_exports.array(threadOwnershipSchema).min(1).max(THREAD_OWNERSHIP_LIST_MAX_LENGTH)
22386
- }).strict().superRefine(({ threads }, context) => {
22387
- const seen = /* @__PURE__ */ new Set();
22388
- for (const [index, thread2] of threads.entries()) {
22389
- if (seen.has(thread2.threadId)) {
22390
- context.addIssue({
22391
- code: "custom",
22392
- message: "Thread ownership-list results must be unique",
22393
- path: ["threads", index, "threadId"]
22394
- });
22395
- }
22396
- seen.add(thread2.threadId);
22397
- }
22468
+ var hostExtensionsListResultSchema = external_exports.strictObject({
22469
+ revision: hostExtensionRevisionSchema,
22470
+ configuration: hostExtensionConfigurationSchema,
22471
+ diagnostics: external_exports.array(external_exports.string()),
22472
+ extensions: external_exports.array(hostExtensionListItemSchema)
22473
+ });
22474
+ var hostExtensionRuntimeEntrySchema = hostExtensionInstallationSchema.extend({
22475
+ ...desktopConflict,
22476
+ settingsRevision: hostExtensionRevisionSchema
22477
+ });
22478
+ var hostExtensionsSnapshotResultSchema = external_exports.strictObject({
22479
+ /** The Host publishes this revision in extensions-changed, independent of enabled.json's revision. */
22480
+ revision: hostExtensionRevisionSchema,
22481
+ // Enabled, valid activations only. A Desktop conflict does not hide other capabilities.
22482
+ extensions: external_exports.array(hostExtensionRuntimeEntrySchema).max(DESKTOP_EXTENSION_LIMIT)
22483
+ });
22484
+ var HOST_EXTENSIONS_RPC = {
22485
+ list: "codexhost/extensions/list",
22486
+ snapshot: "codexhost/extensions/snapshot",
22487
+ catalog: "codexhost/extensions/catalog",
22488
+ install: "codexhost/extensions/install",
22489
+ update: "codexhost/extensions/update",
22490
+ enable: "codexhost/extensions/enable",
22491
+ disable: "codexhost/extensions/disable",
22492
+ uninstall: "codexhost/extensions/uninstall",
22493
+ recover: "codexhost/extensions/recover",
22494
+ asset: "codexhost/extensions/asset",
22495
+ settingsGet: "codexhost/extensions/settings/get",
22496
+ settingsSet: "codexhost/extensions/settings/set",
22497
+ backendInvoke: "codexhost/extensions/backend/invoke"
22498
+ };
22499
+ var HOST_EXTENSION_MANAGEMENT_METHODS = Object.freeze(Object.values(HOST_EXTENSIONS_RPC));
22500
+ var methods = new Set(HOST_EXTENSION_MANAGEMENT_METHODS);
22501
+ var noParams = external_exports.strictObject({});
22502
+ var expectedRevision = { expectedRevision: hostExtensionRevisionSchema };
22503
+ var selection = external_exports.strictObject({ ...id, ...expectedRevision });
22504
+ var installationResult = hostExtensionInstallationSchema.extend({ replaced: external_exports.boolean() });
22505
+ var mutationResult = external_exports.discriminatedUnion("state", [
22506
+ external_exports.strictObject({ state: external_exports.literal("saved"), configuration: hostExtensionConfigurationSchema }),
22507
+ external_exports.strictObject({ state: external_exports.literal("revision-conflict"), revision: hostExtensionRevisionSchema })
22508
+ ]);
22509
+ var hostExtensionsAssetParamsSchema = external_exports.strictObject({
22510
+ ...optionalActivation,
22511
+ digest: active.digest.optional(),
22512
+ path: hostExtensionResourcePathSchema
22513
+ });
22514
+ var hostExtensionsAssetResultSchema = external_exports.strictObject({
22515
+ mimeType: external_exports.string().min(1),
22516
+ base64: base643(DESKTOP_EXTENSION_ASSET_MAX_BYTES),
22517
+ digest: active.digest
22518
+ });
22519
+ var hostExtensionSettingsSchema = external_exports.strictObject({
22520
+ settingsRevision: hostExtensionRevisionSchema,
22521
+ values: jsonObjectSchema
22398
22522
  });
22399
- var threadSteeringInspectParamsSchema = external_exports.object({
22400
- threadId: hostThreadIdSchema,
22401
- /** The text about to be steered; a Harness command always stops and restarts. */
22402
- text: external_exports.string().optional()
22403
- }).strict();
22404
- var threadSteeringContextSchema = external_exports.object({
22405
- kind: external_exports.literal("application"),
22406
- value: external_exports.string().transform((text, context) => {
22407
- try {
22408
- return JSON.parse(text);
22409
- } catch {
22410
- context.addIssue({ code: "custom", message: "Invalid steering context JSON" });
22411
- return external_exports.NEVER;
22412
- }
22413
- }).pipe(external_exports.object({
22414
- expectedTurnId: hostTurnIdSchema,
22415
- clientUserMessageId: external_exports.string().min(1),
22416
- delivery: external_exports.enum(["newTurn", "activeTurn"])
22417
- }).strict())
22418
- }).strict().transform((context) => context.value);
22419
- var threadSteerDeliverySchema = external_exports.enum(["activeTurn", "newTurn"]);
22420
- var threadSteeringInspectResultSchema = external_exports.object({
22421
- delivery: external_exports.enum(["official", "activeTurn", "newTurn"])
22422
- }).strict();
22523
+ var hostExtensionsRpcSchemas = {
22524
+ [HOST_EXTENSIONS_RPC.list]: { params: noParams, result: hostExtensionsListResultSchema },
22525
+ [HOST_EXTENSIONS_RPC.snapshot]: { params: noParams, result: hostExtensionsSnapshotResultSchema },
22526
+ [HOST_EXTENSIONS_RPC.catalog]: {
22527
+ params: external_exports.strictObject({ forceRefresh: external_exports.boolean().optional() }),
22528
+ result: hostExtensionsCatalogResultSchema
22529
+ },
22530
+ [HOST_EXTENSIONS_RPC.install]: {
22531
+ params: external_exports.strictObject({ source: hostExtensionInstallSourceSchema }),
22532
+ result: installationResult
22533
+ },
22534
+ [HOST_EXTENSIONS_RPC.update]: {
22535
+ params: external_exports.strictObject({
22536
+ ...id,
22537
+ expectedDigest: active.digest,
22538
+ expectedActivationId: active.activationId.optional(),
22539
+ source: hostExtensionInstallSourceSchema.optional()
22540
+ }),
22541
+ result: installationResult
22542
+ },
22543
+ [HOST_EXTENSIONS_RPC.enable]: { params: selection, result: mutationResult },
22544
+ [HOST_EXTENSIONS_RPC.disable]: { params: selection, result: mutationResult },
22545
+ [HOST_EXTENSIONS_RPC.uninstall]: {
22546
+ params: external_exports.strictObject({
22547
+ ...id,
22548
+ removeData: external_exports.boolean().optional(),
22549
+ expectedDigest: active.digest.optional()
22550
+ }),
22551
+ result: external_exports.strictObject({ ...id, removed: external_exports.boolean() })
22552
+ },
22553
+ [HOST_EXTENSIONS_RPC.recover]: {
22554
+ params: external_exports.strictObject({ expectedRevision: expectedRevision.expectedRevision.optional() }),
22555
+ result: mutationResult
22556
+ },
22557
+ [HOST_EXTENSIONS_RPC.asset]: {
22558
+ params: hostExtensionsAssetParamsSchema,
22559
+ result: hostExtensionsAssetResultSchema
22560
+ },
22561
+ [HOST_EXTENSIONS_RPC.settingsGet]: {
22562
+ params: external_exports.strictObject(optionalActivation),
22563
+ result: hostExtensionSettingsSchema
22564
+ },
22565
+ [HOST_EXTENSIONS_RPC.settingsSet]: {
22566
+ params: external_exports.strictObject({
22567
+ ...optionalActivation,
22568
+ expectedSettingsRevision: hostExtensionRevisionSchema,
22569
+ values: jsonObjectSchema
22570
+ }),
22571
+ result: hostExtensionSettingsSchema
22572
+ },
22573
+ [HOST_EXTENSIONS_RPC.backendInvoke]: {
22574
+ params: external_exports.strictObject({
22575
+ ...optionalActivation,
22576
+ method: hostExtensionBackendMethodSchema,
22577
+ params: jsonValueSchema.optional()
22578
+ }),
22579
+ result: external_exports.strictObject({ result: jsonValueSchema })
22580
+ }
22581
+ };
22423
22582
 
22424
22583
  // ../../shared-contracts/dist/thread-archive-confirm.js
22425
22584
  var THREAD_ARCHIVE_CONFIRM_METHOD = "codexhost/thread/archive/confirm";
@@ -22465,6 +22624,8 @@ var CLIENT_CHANNEL_METHODS = [
22465
22624
  "codexhost/workspace/read",
22466
22625
  "codexhost/thread/tree/read",
22467
22626
  "codexhost/thread/pins/list",
22627
+ "codexhost/thread/sections/list",
22628
+ "codexhost/thread/sections/move",
22468
22629
  "codexhost/thread/pins/set",
22469
22630
  "codexhost/harness/plugins/list",
22470
22631
  "codexhost/harness/inspect",
@@ -22482,7 +22643,7 @@ var CLIENT_CHANNEL_METHODS = [
22482
22643
  "codexhost/harness/session-import/list",
22483
22644
  "codexhost/harness/session-import/import",
22484
22645
  // Host settings shared across Desktop and Web.
22485
- ...DESKTOP_EXTENSION_MANAGEMENT_METHODS,
22646
+ ...HOST_EXTENSION_MANAGEMENT_METHODS,
22486
22647
  "codexhost/harness/installation",
22487
22648
  "codexhost/harness/installation/start",
22488
22649
  "codexhost/harness/installation/status",
@@ -22503,8 +22664,21 @@ var CLIENT_CHANNEL_METHODS = [
22503
22664
  "codexhost/update/check",
22504
22665
  "codexhost/update/start",
22505
22666
  "codexhost/update/status",
22667
+ "codexhost/announcement/get",
22668
+ "codexhost/announcement/acknowledge",
22506
22669
  "codexhost/sessions/loaded/list"
22507
22670
  ];
22671
+ var clientThreadSectionsSchema = external_exports.object({
22672
+ sections: external_exports.array(external_exports.object({
22673
+ id: external_exports.string().min(1),
22674
+ name: external_exports.string().min(1),
22675
+ threads: external_exports.array(jsonObjectSchema)
22676
+ }).strict())
22677
+ }).strict();
22678
+ var clientThreadSectionMoveSchema = external_exports.object({
22679
+ threadId: external_exports.string().min(1).max(1024),
22680
+ sectionId: external_exports.string().min(1).max(1024).nullable()
22681
+ }).strict();
22508
22682
  var clientThreadPinsSchema = external_exports.object({ threadIds: external_exports.array(external_exports.string().min(1)) }).strict();
22509
22683
  var clientThreadPinParamsSchema = external_exports.object({ threadId: external_exports.string().min(1).max(1024), pinned: external_exports.boolean() }).strict();
22510
22684
  var clientThreadTreeReadParamsSchema = external_exports.object({}).strict();
@@ -22543,6 +22717,11 @@ var clientChannelEventSchema = external_exports.discriminatedUnion("type", [
22543
22717
  cursor: clientChannelCursorSchema,
22544
22718
  revision: external_exports.number().int().nonnegative()
22545
22719
  }),
22720
+ external_exports.object({
22721
+ type: external_exports.literal("extensions-changed"),
22722
+ cursor: clientChannelCursorSchema,
22723
+ revision: hostExtensionRevisionSchema
22724
+ }),
22546
22725
  external_exports.object({
22547
22726
  type: external_exports.literal("hello"),
22548
22727
  version: external_exports.literal(1),
@@ -22979,7 +23158,7 @@ var DEFAULT_IDLE_RELEASE_SETTINGS = Object.freeze({
22979
23158
 
22980
23159
  // ../../shared-contracts/dist/harness-preferences.js
22981
23160
  var harnessPreferenceScopeSchema = external_exports.string().regex(/^external$/u);
22982
- var preferenceHarnessKey = harnessIdSchema.transform((id) => String(id));
23161
+ var preferenceHarnessKey = harnessIdSchema.transform((id2) => String(id2));
22983
23162
  var harnessDefaultConfigurationSchema = external_exports.strictObject({
22984
23163
  model: harnessModelRefSchema.optional(),
22985
23164
  thinkingOptionId: harnessThinkingOptionIdSchema.optional(),
@@ -22989,11 +23168,19 @@ var newThreadDefaultsSchema = external_exports.strictObject({
22989
23168
  lastHarness: harnessIdSchema.optional(),
22990
23169
  byHarness: external_exports.record(preferenceHarnessKey, harnessDefaultConfigurationSchema)
22991
23170
  });
23171
+ var harnessDelegationDefaultSchema = external_exports.strictObject({
23172
+ model: harnessModelRefSchema.optional(),
23173
+ thinkingOptionId: harnessThinkingOptionIdSchema.optional()
23174
+ }).refine((value) => Boolean(value.model || value.thinkingOptionId), "A delegation default must contain a Model or Thinking option");
23175
+ var delegationDefaultsSchema = external_exports.strictObject({
23176
+ byHarness: external_exports.record(preferenceHarnessKey, harnessDelegationDefaultSchema)
23177
+ });
22992
23178
  var modelId = external_exports.string().min(1).max(1024);
22993
23179
  var harnessPreferenceValuesSchema = external_exports.strictObject({
22994
23180
  idleRelease: idleReleaseSettingsSchema.optional(),
22995
23181
  favorites: external_exports.record(preferenceHarnessKey, external_exports.array(modelId).max(2048)).default({}),
22996
- newThread: newThreadDefaultsSchema.optional()
23182
+ newThread: newThreadDefaultsSchema.optional(),
23183
+ delegation: delegationDefaultsSchema.optional()
22997
23184
  });
22998
23185
  var harnessPreferenceSnapshotSchema = external_exports.strictObject({
22999
23186
  scope: harnessPreferenceScopeSchema,
@@ -23021,6 +23208,11 @@ var harnessPreferenceOperationSchema = external_exports.discriminatedUnion("kind
23021
23208
  lastHarness: harnessIdSchema.optional(),
23022
23209
  harnessId: harnessIdSchema.optional(),
23023
23210
  configuration: harnessDefaultConfigurationSchema.optional()
23211
+ }),
23212
+ external_exports.strictObject({
23213
+ kind: external_exports.literal("delegation"),
23214
+ harnessId: harnessIdSchema,
23215
+ configuration: harnessDelegationDefaultSchema.nullable()
23024
23216
  })
23025
23217
  ]);
23026
23218
  var harnessPreferencePatchSchema = external_exports.strictObject({
@@ -23028,8 +23220,8 @@ var harnessPreferencePatchSchema = external_exports.strictObject({
23028
23220
  operations: external_exports.array(harnessPreferenceOperationSchema).min(1).max(256),
23029
23221
  initializeOnly: external_exports.boolean().optional(),
23030
23222
  expectedRevision: external_exports.number().int().nonnegative().optional()
23031
- }).superRefine((input, ctx) => {
23032
- for (const operation of input.operations) {
23223
+ }).superRefine((input2, ctx) => {
23224
+ for (const operation of input2.operations) {
23033
23225
  if (operation.kind === "newThread" && (!operation.lastHarness && !operation.configuration || Boolean(operation.harnessId) !== Boolean(operation.configuration)))
23034
23226
  ctx.addIssue({
23035
23227
  code: "custom",
@@ -23431,13 +23623,18 @@ var harnessLaunchSettingsSchema = external_exports.object({
23431
23623
  // ../../shared-contracts/dist/harness-installation.js
23432
23624
  var harnessInstallationParamsSchema = external_exports.object({
23433
23625
  harnessId: harnessIdSchema,
23434
- action: external_exports.enum(["check", "update", "install"])
23435
- }).strict();
23626
+ action: external_exports.enum(["check", "update", "install"]),
23627
+ confirmedVersion: external_exports.string().min(1).max(128).optional()
23628
+ }).strict().refine(({ action, confirmedVersion }) => action === "update" || confirmedVersion === void 0);
23436
23629
  var harnessInstallationStateSchema = external_exports.object({
23437
23630
  currentVersion: external_exports.string().min(1).max(128),
23438
23631
  latestVersion: external_exports.string().min(1).max(128),
23439
23632
  updateAvailable: external_exports.boolean(),
23440
23633
  canUpdate: external_exports.boolean(),
23634
+ /** Present when the Adapter has a verified list and the available target is outside it. */
23635
+ latestVerifiedVersion: external_exports.string().min(1).max(128).optional(),
23636
+ /** Update preflight stopped before running the installer; latestVersion needs confirmation. */
23637
+ confirmationRequired: external_exports.literal(true).optional(),
23441
23638
  /** Defaults to CLI; some Harnesses ship only inside a desktop application. */
23442
23639
  versionKind: external_exports.enum(["cli", "application"]).optional(),
23443
23640
  /** Official download opened by the user; does not imply an automatic installation. */
@@ -23765,6 +23962,38 @@ var updateStatusResultSchema = external_exports.strictObject({
23765
23962
  status: updateStatusSchema.nullable()
23766
23963
  });
23767
23964
 
23965
+ // ../../shared-contracts/dist/release-announcement.js
23966
+ var RELEASE_ANNOUNCEMENT_MAX_THEMES = 12;
23967
+ var releaseAnnouncementThemeSchema = external_exports.strictObject({
23968
+ icon: external_exports.string().min(1).max(16).optional(),
23969
+ title: external_exports.string().min(1).max(120),
23970
+ body: external_exports.string().min(1).max(1200),
23971
+ contributors: external_exports.array(external_exports.string().min(1).max(39)).max(30)
23972
+ });
23973
+ var releaseAnnouncementContentSchema = external_exports.strictObject({
23974
+ summary: external_exports.string().min(1).max(600).optional(),
23975
+ themes: external_exports.array(releaseAnnouncementThemeSchema).min(1).max(RELEASE_ANNOUNCEMENT_MAX_THEMES)
23976
+ });
23977
+ var releaseAnnouncementSchema = external_exports.strictObject({
23978
+ version: updateSemanticVersionSchema,
23979
+ publishedAt: external_exports.iso.datetime(),
23980
+ url: external_exports.string().max(300).regex(/^https:\/\/github\.com\/BytePioneer-AI\/codex-host\/releases\/tag\/v[0-9A-Za-z.+-]+$/u),
23981
+ zh: releaseAnnouncementContentSchema.nullable(),
23982
+ en: releaseAnnouncementContentSchema.nullable()
23983
+ }).refine((value) => value.zh !== null || value.en !== null, {
23984
+ message: "an announcement needs at least one language"
23985
+ });
23986
+ var releaseAnnouncementGetParamsSchema = external_exports.strictObject({
23987
+ manual: external_exports.boolean().optional()
23988
+ });
23989
+ var releaseAnnouncementGetResultSchema = external_exports.strictObject({
23990
+ announcement: releaseAnnouncementSchema.nullable(),
23991
+ unread: external_exports.boolean()
23992
+ });
23993
+ var releaseAnnouncementAcknowledgeParamsSchema = external_exports.strictObject({
23994
+ version: updateSemanticVersionSchema
23995
+ });
23996
+
23768
23997
  // ../../shared-contracts/dist/thread-watch-notice.js
23769
23998
  var THREAD_WATCH_NOTICE_OUTCOMES = [
23770
23999
  "completed",
@@ -23812,17 +24041,67 @@ var remoteSshSetupResultSchema = external_exports.object({ state: external_expor
23812
24041
 
23813
24042
  // ../../shared-contracts/dist/remote-sessions.js
23814
24043
  var REMOTE_CONTROLLER_REQUEST_MAX_BYTES = 16 * 1024;
23815
- var identity = external_exports.string().min(1).max(1024);
24044
+ var REMOTE_IDENTITY_MAX_LENGTH = 1024;
24045
+ var identity = external_exports.string().min(1).max(REMOTE_IDENTITY_MAX_LENGTH);
23816
24046
  var target = { hostId: identity.regex(/^remote-(?:ssh(?:-|:)|control:)/u) };
23817
24047
  var thread = { ...target, threadId: identity };
24048
+ var text = external_exports.string().min(1).max(8e3);
24049
+ var input = { text, requestId: identity };
24050
+ var remoteDeliveryReplySchema = external_exports.discriminatedUnion("accepted", [
24051
+ external_exports.object({ accepted: external_exports.literal(true), startQueuedItemId: identity.optional() }),
24052
+ external_exports.object({
24053
+ accepted: external_exports.literal(false),
24054
+ code: external_exports.enum([
24055
+ "remote/queue-unavailable",
24056
+ "remote/steer-unavailable",
24057
+ "remote/turn-changed",
24058
+ "remote/send-rejected",
24059
+ "session/queue-item-not-found",
24060
+ "session/queue-item-starting"
24061
+ ]),
24062
+ message: external_exports.string()
24063
+ })
24064
+ ]);
24065
+ var remoteQueueSnapshotSchema = external_exports.discriminatedUnion("available", [
24066
+ external_exports.object({ available: external_exports.literal(false) }),
24067
+ external_exports.object({
24068
+ available: external_exports.literal(true),
24069
+ items: external_exports.array(external_exports.object({ id: identity, clientUserMessageId: identity, preview: external_exports.string().max(801) })).max(100)
24070
+ })
24071
+ ]);
23818
24072
  var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
23819
24073
  external_exports.strictObject({ kind: external_exports.literal("hosts") }),
24074
+ external_exports.strictObject({
24075
+ kind: external_exports.literal("create"),
24076
+ ...target,
24077
+ cwd: external_exports.string().min(1).max(8192),
24078
+ epoch: identity
24079
+ }),
24080
+ external_exports.strictObject({ kind: external_exports.literal("projectHarnesses"), ...target, epoch: identity }),
24081
+ external_exports.strictObject({
24082
+ kind: external_exports.literal("inspectHarness"),
24083
+ ...target,
24084
+ epoch: identity,
24085
+ cwd: external_exports.string().min(1).max(8192),
24086
+ harnessId: identity
24087
+ }),
24088
+ external_exports.strictObject({
24089
+ kind: external_exports.literal("startSelected"),
24090
+ ...target,
24091
+ epoch: identity,
24092
+ cwd: external_exports.string().min(1).max(8192),
24093
+ harnessId: identity,
24094
+ model: external_exports.string().min(1).max(4096),
24095
+ serviceTier: external_exports.enum(["priority", "ultrafast"]).optional(),
24096
+ reasoningEffort: identity.optional()
24097
+ }),
23820
24098
  external_exports.strictObject({ kind: external_exports.literal("status"), ...thread }),
23821
24099
  external_exports.strictObject({
23822
24100
  kind: external_exports.literal("list"),
23823
24101
  ...target,
23824
24102
  cursor: external_exports.string().nullable(),
23825
- archived: external_exports.boolean()
24103
+ archived: external_exports.boolean(),
24104
+ includeLoaded: external_exports.literal(true).optional()
23826
24105
  }),
23827
24106
  external_exports.strictObject({
23828
24107
  kind: external_exports.literal("read"),
@@ -23842,16 +24121,35 @@ var remoteSessionOperationSchema = external_exports.discriminatedUnion("kind", [
23842
24121
  ...thread,
23843
24122
  epoch: identity,
23844
24123
  modelId: identity.optional(),
24124
+ serviceTier: harnessModelServiceTierSchema.optional(),
23845
24125
  thinkingOptionId: identity.optional(),
23846
24126
  permissionModeId: identity.optional()
23847
- }).refine((value) => [value.modelId, value.thinkingOptionId, value.permissionModeId].filter((v) => v !== void 0).length === 1, "Select exactly one remote setting"),
24127
+ }).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, {
24128
+ message: "A service tier requires a Model ID"
24129
+ }),
23848
24130
  external_exports.strictObject({
23849
24131
  kind: external_exports.literal("prompt"),
23850
24132
  ...thread,
23851
24133
  epoch: identity,
23852
- text: external_exports.string().min(1).max(8e3),
24134
+ text,
23853
24135
  requestId: identity.optional()
23854
24136
  }),
24137
+ external_exports.strictObject({ kind: external_exports.literal("queue"), ...thread, epoch: identity }),
24138
+ external_exports.strictObject({
24139
+ kind: external_exports.literal("delivery"),
24140
+ ...thread,
24141
+ epoch: identity,
24142
+ action: external_exports.discriminatedUnion("kind", [
24143
+ external_exports.strictObject({ kind: external_exports.literal("enqueue"), ...input }),
24144
+ external_exports.strictObject({ kind: external_exports.literal("steer"), ...input, turnId: identity }),
24145
+ external_exports.strictObject({ kind: external_exports.literal("remove"), itemId: identity }),
24146
+ external_exports.strictObject({
24147
+ kind: external_exports.literal("start"),
24148
+ itemId: identity,
24149
+ onlyIfHead: external_exports.literal(true).optional()
24150
+ })
24151
+ ])
24152
+ }),
23855
24153
  external_exports.strictObject({ kind: external_exports.literal("interrupt"), ...thread, epoch: identity, turnId: identity }),
23856
24154
  external_exports.strictObject({
23857
24155
  kind: external_exports.literal("rename"),
@@ -23894,7 +24192,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
23894
24192
  external_exports.strictObject({ action: external_exports.literal("catalog") }),
23895
24193
  external_exports.strictObject({
23896
24194
  action: external_exports.literal("read-thread"),
23897
- hostId: hostId.refine((id) => id !== "local"),
24195
+ hostId: hostId.refine((id2) => id2 !== "local"),
23898
24196
  input: delegationReadParamsSchema
23899
24197
  }),
23900
24198
  external_exports.strictObject({
@@ -23908,7 +24206,7 @@ var remoteConnectionsRequestSchema = external_exports.discriminatedUnion("action
23908
24206
  external_exports.strictObject({ action: external_exports.literal("runtime"), hostId }),
23909
24207
  external_exports.strictObject({
23910
24208
  action: external_exports.literal("update"),
23911
- hostId: hostId.refine((id) => id !== "local"),
24209
+ hostId: hostId.refine((id2) => id2 !== "local"),
23912
24210
  version: remoteUpdateParamsSchema.shape.version
23913
24211
  })
23914
24212
  ]);
@@ -23972,7 +24270,7 @@ function invalidRequest(message) {
23972
24270
  return { code: "invalidRequest", message, retryable: false };
23973
24271
  }
23974
24272
  function validateHostApprovalResponse(interaction, response) {
23975
- return interaction.actions.some(({ id }) => id === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
24273
+ return interaction.actions.some(({ id: id2 }) => id2 === response.actionId) ? null : invalidRequest("Approval Response contains an undeclared action ID");
23976
24274
  }
23977
24275
 
23978
24276
  // ../../harness-adapter/dist/question.js
@@ -23980,7 +24278,7 @@ function invalidRequest2(message) {
23980
24278
  return { code: "invalidRequest", message, retryable: false };
23981
24279
  }
23982
24280
  function validateHostQuestionResponse(interaction, response) {
23983
- const questionIds = new Set(interaction.questions.map(({ id }) => id));
24281
+ const questionIds = new Set(interaction.questions.map(({ id: id2 }) => id2));
23984
24282
  if (response.cancelled) {
23985
24283
  return Object.keys(response.answers).length === 0 ? null : invalidRequest2("Cancelled Question Response must not contain answers");
23986
24284
  }
@@ -24086,7 +24384,8 @@ var tokenFields = [
24086
24384
  var safeIntegerFields = [
24087
24385
  "planFiveHourResetsAtUnix",
24088
24386
  "planSevenDayResetsAtUnix",
24089
- "timeToFirstOutputMs"
24387
+ "timeToFirstOutputMs",
24388
+ "latestRequestTimeToFirstOutputMs"
24090
24389
  ];
24091
24390
  var percentFields = [
24092
24391
  "cacheHitRatePercent",
@@ -28302,10 +28601,10 @@ function executableExtensions(command, platform, environment) {
28302
28601
  return [""];
28303
28602
  return (environmentValue(environment, "PATHEXT") ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean);
28304
28603
  }
28305
- function isExecutableFile(filePath, platform) {
28604
+ function isExecutableFile(filePath2, platform) {
28306
28605
  try {
28307
- fs.accessSync(filePath, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
28308
- return fs.statSync(filePath).isFile();
28606
+ fs.accessSync(filePath2, platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK);
28607
+ return fs.statSync(filePath2).isFile();
28309
28608
  } catch {
28310
28609
  return false;
28311
28610
  }
@@ -28401,8 +28700,8 @@ var VERSION_MANAGER_ROOTS = "<version-managers>";
28401
28700
  function installRootExtensions(platform) {
28402
28701
  return platform === "win32" ? [".exe", ".cmd"] : [""];
28403
28702
  }
28404
- function resolveHomeDirectory(input) {
28405
- return input.homeDirectory ?? environmentValue(input.environment, "HOME") ?? environmentValue(input.environment, "USERPROFILE") ?? os.homedir();
28703
+ function resolveHomeDirectory(input2) {
28704
+ return input2.homeDirectory ?? environmentValue(input2.environment, "HOME") ?? environmentValue(input2.environment, "USERPROFILE") ?? os.homedir();
28406
28705
  }
28407
28706
  function templateVariables(environment, platform, home) {
28408
28707
  const pathFlavor = targetPath(platform);
@@ -28435,36 +28734,36 @@ function expandInstallRoot(template, environment, platform, home) {
28435
28734
  });
28436
28735
  return unresolved ? void 0 : joinTemplate(platform, substituted);
28437
28736
  }
28438
- function installRootDirectories(spec, input, dependencies, platform, home) {
28737
+ function installRootDirectories(spec, input2, dependencies, platform, home) {
28439
28738
  const templates = (platform === "win32" ? spec.installRoots?.windows : spec.installRoots?.posix) ?? [];
28440
28739
  const directories = [];
28441
28740
  for (const template of templates) {
28442
28741
  if (template === VERSION_MANAGER_ROOTS) {
28443
28742
  directories.push(...versionManagerBinaryDirectories({
28444
28743
  platform,
28445
- environment: input.environment,
28744
+ environment: input2.environment,
28446
28745
  home,
28447
28746
  ...dependencies.subdirectories ? { subdirectories: dependencies.subdirectories } : {}
28448
28747
  }));
28449
28748
  continue;
28450
28749
  }
28451
- const directory = expandInstallRoot(template, input.environment, platform, home);
28750
+ const directory = expandInstallRoot(template, input2.environment, platform, home);
28452
28751
  if (directory !== void 0)
28453
28752
  directories.push(directory);
28454
28753
  }
28455
28754
  return directories;
28456
28755
  }
28457
- function harnessCandidates(spec, input, dependencies = {}) {
28458
- const platform = input.platform ?? process.platform;
28756
+ function harnessCandidates(spec, input2, dependencies = {}) {
28757
+ const platform = input2.platform ?? process.platform;
28459
28758
  const pathFlavor = targetPath(platform);
28460
- const configured = input.command ?? (spec.commandEnvironmentVariable ? environmentValue(input.environment, spec.commandEnvironmentVariable) : void 0);
28759
+ const configured = input2.command ?? (spec.commandEnvironmentVariable ? environmentValue(input2.environment, spec.commandEnvironmentVariable) : void 0);
28461
28760
  const command = configured ?? spec.command;
28462
28761
  if (pathFlavor.isAbsolute(command) || command.includes("/") || command.includes("\\")) {
28463
28762
  return [{ candidate: command, source: "configured" }];
28464
28763
  }
28465
28764
  const candidates = [];
28466
- const extensions = executableExtensions(command, platform, input.environment);
28467
- for (const directory of pathDirectories(input.environment, platform)) {
28765
+ const extensions = executableExtensions(command, platform, input2.environment);
28766
+ for (const directory of pathDirectories(input2.environment, platform)) {
28468
28767
  for (const extension of extensions) {
28469
28768
  candidates.push({
28470
28769
  candidate: pathFlavor.join(directory, command + extension),
@@ -28474,8 +28773,8 @@ function harnessCandidates(spec, input, dependencies = {}) {
28474
28773
  }
28475
28774
  if (configured !== void 0)
28476
28775
  return candidates;
28477
- const home = resolveHomeDirectory(input);
28478
- for (const directory of installRootDirectories(spec, input, dependencies, platform, home)) {
28776
+ const home = resolveHomeDirectory(input2);
28777
+ for (const directory of installRootDirectories(spec, input2, dependencies, platform, home)) {
28479
28778
  for (const extension of installRootExtensions(platform)) {
28480
28779
  candidates.push({
28481
28780
  candidate: pathFlavor.join(directory, spec.command + extension),
@@ -28485,12 +28784,12 @@ function harnessCandidates(spec, input, dependencies = {}) {
28485
28784
  }
28486
28785
  return candidates;
28487
28786
  }
28488
- function resolveHarnessExecutable(spec, input, dependencies = {}) {
28489
- const platform = input.platform ?? process.platform;
28787
+ function resolveHarnessExecutable(spec, input2, dependencies = {}) {
28788
+ const platform = input2.platform ?? process.platform;
28490
28789
  const isExecutable = dependencies.isExecutable ?? ((candidate) => isExecutableFile(candidate, platform));
28491
28790
  const runnable = spec.runnableCandidate ?? ((candidate) => candidate);
28492
28791
  const context = { platform, isExecutable };
28493
- for (const { candidate, source } of harnessCandidates(spec, input, dependencies)) {
28792
+ for (const { candidate, source } of harnessCandidates(spec, input2, dependencies)) {
28494
28793
  const executable = runnable(candidate, context);
28495
28794
  if (executable !== void 0 && isExecutable(executable))
28496
28795
  return { executable, source };
@@ -28569,12 +28868,12 @@ var qwenCodeDiscoverySpec = {
28569
28868
  return isExecutable(entrypoint) ? entrypoint : void 0;
28570
28869
  }
28571
28870
  };
28572
- function resolveQwenCodeExecutable(input = {}, dependencies = {}) {
28573
- const platform = input.platform ?? process.platform;
28871
+ function resolveQwenCodeExecutable(input2 = {}, dependencies = {}) {
28872
+ const platform = input2.platform ?? process.platform;
28574
28873
  const resolution = resolveHarnessExecutable(qwenCodeDiscoverySpec, {
28575
- ...input.command ? { command: input.command } : {},
28576
- environment: input.environment ?? process.env,
28577
- ...input.homeDirectory ? { homeDirectory: input.homeDirectory } : {},
28874
+ ...input2.command ? { command: input2.command } : {},
28875
+ environment: input2.environment ?? process.env,
28876
+ ...input2.homeDirectory ? { homeDirectory: input2.homeDirectory } : {},
28578
28877
  platform
28579
28878
  }, dependencies);
28580
28879
  if (!resolution)
@@ -28620,22 +28919,22 @@ function qwenCodeCommand(kind, rawInput) {
28620
28919
  return void 0;
28621
28920
  return stringField(rawInput, "command");
28622
28921
  }
28623
- function startQwenCodeToolItem(input) {
28624
- const command = qwenCodeCommand(input.kind ?? void 0, input.rawInput);
28922
+ function startQwenCodeToolItem(input2) {
28923
+ const command = qwenCodeCommand(input2.kind ?? void 0, input2.rawInput);
28625
28924
  if (command) {
28626
- const rawCwd = stringField(input.rawInput, "cwd");
28925
+ const rawCwd = stringField(input2.rawInput, "cwd");
28627
28926
  return {
28628
28927
  type: "commandExecution",
28629
- itemId: input.itemId,
28928
+ itemId: input2.itemId,
28630
28929
  command,
28631
- cwd: rawCwd ?? input.cwd
28930
+ cwd: rawCwd ?? input2.cwd
28632
28931
  };
28633
28932
  }
28634
28933
  return {
28635
28934
  type: "toolExecution",
28636
- itemId: input.itemId,
28637
- toolName: qwenCodeToolName(input.name, input.title),
28638
- arguments: qwenCodeToolArguments(input.rawInput)
28935
+ itemId: input2.itemId,
28936
+ toolName: qwenCodeToolName(input2.name, input2.title),
28937
+ arguments: qwenCodeToolArguments(input2.rawInput)
28639
28938
  };
28640
28939
  }
28641
28940
  function acpContentText(content) {
@@ -28679,9 +28978,9 @@ function rawOutputProjection(rawOutput) {
28679
28978
  const exitCode = numberField(rawOutput, "exit_code") ?? numberField(rawOutput, "exitCode");
28680
28979
  const output = rawOutput.output;
28681
28980
  const outputText = typeof output === "string" ? output : void 0;
28682
- const text = outputText ?? stringField(rawOutput, "content") ?? stringField(rawOutput, "text") ?? stringField(rawOutput, "tool_result") ?? stringField(rawOutput, "raw_output");
28683
- if (text || exitCode !== void 0) {
28684
- return { ...text ? { text } : {}, ...exitCode !== void 0 ? { exitCode } : {} };
28981
+ const text2 = outputText ?? stringField(rawOutput, "content") ?? stringField(rawOutput, "text") ?? stringField(rawOutput, "tool_result") ?? stringField(rawOutput, "raw_output");
28982
+ if (text2 || exitCode !== void 0) {
28983
+ return { ...text2 ? { text: text2 } : {}, ...exitCode !== void 0 ? { exitCode } : {} };
28685
28984
  }
28686
28985
  return {};
28687
28986
  }
@@ -28689,33 +28988,33 @@ function projectQwenCodeToolOutput(content, rawOutput, limit = DEFAULT_QWEN_CODE
28689
28988
  if (!Number.isSafeInteger(limit) || limit <= 0)
28690
28989
  return {};
28691
28990
  const fromRaw = rawOutputProjection(rawOutput);
28692
- const text = acpContentText(content) || fromRaw.text || "";
28991
+ const text2 = acpContentText(content) || fromRaw.text || "";
28693
28992
  const parts = [];
28694
- if (text.length > 0) {
28695
- const truncated = text.length > limit;
28696
- parts.push({ type: "text", text: truncated ? text.slice(0, limit) : text });
28993
+ if (text2.length > 0) {
28994
+ const truncated = text2.length > limit;
28995
+ parts.push({ type: "text", text: truncated ? text2.slice(0, limit) : text2 });
28697
28996
  }
28698
- parts.push(...acpContentImages(content, Math.max(0, limit - text.length)));
28997
+ parts.push(...acpContentImages(content, Math.max(0, limit - text2.length)));
28699
28998
  return {
28700
28999
  ...parts.length > 0 ? {
28701
29000
  output: {
28702
29001
  content: parts,
28703
- ...text.length > limit ? { truncated: true } : {}
29002
+ ...text2.length > limit ? { truncated: true } : {}
28704
29003
  }
28705
29004
  } : {},
28706
29005
  ...fromRaw.exitCode !== void 0 ? { exitCode: fromRaw.exitCode } : {}
28707
29006
  };
28708
29007
  }
28709
29008
  function qwenCodeToolOutputText(output) {
28710
- return output?.content.filter((entry) => entry.type === "text").map(({ text }) => text).join("") ?? "";
29009
+ return output?.content.filter((entry) => entry.type === "text").map(({ text: text2 }) => text2).join("") ?? "";
28711
29010
  }
28712
29011
  function applyQwenCodeToolProjection(item, projection) {
28713
29012
  if (item.type === "commandExecution") {
28714
- const text = qwenCodeToolOutputText(projection.output);
29013
+ const text2 = qwenCodeToolOutputText(projection.output);
28715
29014
  return {
28716
29015
  ...item,
28717
29016
  ...projection.output ? {
28718
- output: text,
29017
+ output: text2,
28719
29018
  outputTruncated: projection.output.truncated === true
28720
29019
  } : {},
28721
29020
  ...projection.exitCode !== void 0 ? { exitCode: projection.exitCode } : {}
@@ -28788,19 +29087,19 @@ function errorText(error51) {
28788
29087
  function classifyError(error51, stage = "startup") {
28789
29088
  if (error51 instanceof QwenCodeTransportError)
28790
29089
  return error51;
28791
- const text = errorText(error51);
28792
- const lower = text.toLowerCase();
29090
+ const text2 = errorText(error51);
29091
+ const lower = text2.toLowerCase();
28793
29092
  const code = error51?.code;
28794
29093
  if (stage === "startup" && (code === "ENOENT" || lower.includes("executable file not found"))) {
28795
29094
  return new QwenCodeTransportError("notInstalled", "Qwen Code CLI is not installed", {
28796
29095
  cause: error51,
28797
- diagnostic: text
29096
+ diagnostic: text2
28798
29097
  });
28799
29098
  }
28800
29099
  if (lower.includes("auth_required") || lower.includes("auth type") || lower.includes("authentication") || lower.includes("not logged in") || lower.includes("sign in")) {
28801
- return new QwenCodeTransportError("authenticationRequired", "Qwen Code CLI authentication is required", { cause: error51, diagnostic: text });
29100
+ return new QwenCodeTransportError("authenticationRequired", "Qwen Code CLI authentication is required", { cause: error51, diagnostic: text2 });
28802
29101
  }
28803
- return new QwenCodeTransportError("unavailable", text, {
29102
+ return new QwenCodeTransportError("unavailable", text2, {
28804
29103
  cause: error51
28805
29104
  });
28806
29105
  }
@@ -28809,8 +29108,8 @@ function rawToolOutput(content) {
28809
29108
  return content;
28810
29109
  if (!Array.isArray(content))
28811
29110
  return void 0;
28812
- const text = content.flatMap((block) => isRecord3(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
28813
- return text.length > 0 ? text : void 0;
29111
+ const text2 = content.flatMap((block) => isRecord3(block) && block.type === "text" && typeof block.text === "string" ? [block.text] : []).join("\n");
29112
+ return text2.length > 0 ? text2 : void 0;
28814
29113
  }
28815
29114
  var QwenCodeSdkTransport = class {
28816
29115
  #options;
@@ -28838,15 +29137,15 @@ var QwenCodeSdkTransport = class {
28838
29137
  await this.close();
28839
29138
  }
28840
29139
  }
28841
- async open(input) {
28842
- await this.#start(input);
29140
+ async open(input2) {
29141
+ await this.#start(input2);
28843
29142
  return {
28844
29143
  sessionId: this.sessionId,
28845
29144
  models: await this.#models(),
28846
- resumed: input.kind === "resume"
29145
+ resumed: input2.kind === "resume"
28847
29146
  };
28848
29147
  }
28849
- async runTurn(text, onEvent, onPermission) {
29148
+ async runTurn(text2, onEvent, onPermission) {
28850
29149
  if (this.#failure)
28851
29150
  throw this.#failure;
28852
29151
  if (!this.#input || !this.#sessionId || this.#closed) {
@@ -28860,7 +29159,7 @@ var QwenCodeSdkTransport = class {
28860
29159
  this.#input?.push({
28861
29160
  type: "user",
28862
29161
  session_id: this.#sessionId,
28863
- message: { role: "user", content: text },
29162
+ message: { role: "user", content: text2 },
28864
29163
  parent_tool_use_id: null
28865
29164
  });
28866
29165
  } catch (error51) {
@@ -28902,27 +29201,27 @@ var QwenCodeSdkTransport = class {
28902
29201
  this.#query = null;
28903
29202
  const abortController = this.#abortController;
28904
29203
  this.#abortController = null;
28905
- const input = this.#input;
29204
+ const input2 = this.#input;
28906
29205
  this.#input = null;
28907
- const active = this.#active;
29206
+ const active2 = this.#active;
28908
29207
  this.#active = null;
28909
- active?.resolve({ status: "cancelled" });
29208
+ active2?.resolve({ status: "cancelled" });
28910
29209
  await query?.close().catch(() => void 0);
28911
29210
  abortController?.abort();
28912
- input?.fail(new Error("Qwen Code SDK input closed"));
29211
+ input2?.fail(new Error("Qwen Code SDK input closed"));
28913
29212
  }
28914
- async #start(input) {
29213
+ async #start(input2) {
28915
29214
  if (this.#query || this.#closed)
28916
29215
  throw new Error("Qwen Code SDK Transport cannot be opened twice");
28917
- const resumeSessionId = input.kind === "resume" ? input.sessionId : void 0;
28918
- if (input.kind === "resume" && !resumeSessionId) {
29216
+ const resumeSessionId = input2.kind === "resume" ? input2.sessionId : void 0;
29217
+ if (input2.kind === "resume" && !resumeSessionId) {
28919
29218
  throw new QwenCodeTransportError("protocolError", "Qwen Code resume requires a Session identity");
28920
29219
  }
28921
29220
  const inputStream = new PushableInput();
28922
29221
  const abortController = new AbortController();
28923
29222
  const queryFactory = this.#options.queryFactory ?? ma;
28924
29223
  const sessionId = resumeSessionId ?? randomUUID();
28925
- const permissionMode = decodeQwenCodePermissionModeId(input.permissionMode);
29224
+ const permissionMode = decodeQwenCodePermissionModeId(input2.permissionMode);
28926
29225
  const environment = this.#environment();
28927
29226
  try {
28928
29227
  const executable = resolveQwenCodeExecutable({
@@ -28933,7 +29232,7 @@ var QwenCodeSdkTransport = class {
28933
29232
  prompt: inputStream,
28934
29233
  options: {
28935
29234
  cwd: this.#options.cwd,
28936
- ...input.model ? { model: input.model } : {},
29235
+ ...input2.model ? { model: input2.model } : {},
28937
29236
  ...this.#options.commandTimeoutMs ? { timeout: { controlRequest: this.#options.commandTimeoutMs } } : {},
28938
29237
  env: environment,
28939
29238
  abortController,
@@ -28971,15 +29270,15 @@ var QwenCodeSdkTransport = class {
28971
29270
  const environment = withNodeRuntimeOnPath({ ...process.env, ...this.#options.environment });
28972
29271
  return Object.fromEntries(Object.entries(environment).filter((entry) => typeof entry[1] === "string"));
28973
29272
  }
28974
- #canUseTool = async (toolName, input) => {
28975
- const active = this.#active;
28976
- if (!active)
29273
+ #canUseTool = async (toolName, input2) => {
29274
+ const active2 = this.#active;
29275
+ if (!active2)
28977
29276
  return { behavior: "deny", message: "No active codexhost Turn" };
28978
- const response = await active.onPermission({ toolName, input });
29277
+ const response = await active2.onPermission({ toolName, input: input2 });
28979
29278
  if (response.behavior === "allow") {
28980
29279
  return {
28981
29280
  behavior: "allow",
28982
- updatedInput: response.updatedInput ?? input
29281
+ updatedInput: response.updatedInput ?? input2
28983
29282
  };
28984
29283
  }
28985
29284
  return { behavior: "deny", message: "Denied by user" };
@@ -29037,32 +29336,32 @@ var QwenCodeSdkTransport = class {
29037
29336
  return;
29038
29337
  }
29039
29338
  if (nn(message)) {
29040
- const active2 = this.#active;
29339
+ const active3 = this.#active;
29041
29340
  const errorMessage = typeof message.error === "string" ? message.error : typeof message.error === "object" && message.error !== null && "message" in message.error && typeof message.error.message === "string" ? message.error.message : `Qwen Code SDK returned ${message.subtype}`;
29042
29341
  const error51 = message.is_error ? classifyError(errorMessage, "turn") : void 0;
29043
- if (!active2) {
29342
+ if (!active3) {
29044
29343
  if (error51)
29045
29344
  this.#fault(error51);
29046
29345
  return;
29047
29346
  }
29048
- active2.onEvent({ type: "usage", metadata: { usage: message.usage } });
29347
+ active3.onEvent({ type: "usage", metadata: { usage: message.usage } });
29049
29348
  this.#active = null;
29050
- active2.resolve({
29349
+ active3.resolve({
29051
29350
  status: message.is_error ? "failed" : "succeeded",
29052
29351
  ...error51 ? { error: error51 } : {}
29053
29352
  });
29054
29353
  return;
29055
29354
  }
29056
- const active = this.#active;
29057
- if (!active)
29355
+ const active2 = this.#active;
29356
+ if (!active2)
29058
29357
  return;
29059
29358
  if (on(message)) {
29060
29359
  if (message.event.type !== "content_block_delta")
29061
29360
  return;
29062
29361
  if (message.event.delta.type === "text_delta" && message.event.delta.text.length > 0) {
29063
- active.onEvent({ type: "agent.text", text: message.event.delta.text });
29362
+ active2.onEvent({ type: "agent.text", text: message.event.delta.text });
29064
29363
  } else if (message.event.delta.type === "thinking_delta" && message.event.delta.thinking.length > 0) {
29065
- active.onEvent({ type: "agent.thought", text: message.event.delta.thinking });
29364
+ active2.onEvent({ type: "agent.thought", text: message.event.delta.thinking });
29066
29365
  }
29067
29366
  return;
29068
29367
  }
@@ -29071,7 +29370,7 @@ var QwenCodeSdkTransport = class {
29071
29370
  if (block.type !== "tool_use")
29072
29371
  continue;
29073
29372
  const kind = qwenCodeToolKind(block.name);
29074
- active.onEvent({
29373
+ active2.onEvent({
29075
29374
  type: "tool.call",
29076
29375
  callId: block.id,
29077
29376
  title: block.name,
@@ -29086,7 +29385,7 @@ var QwenCodeSdkTransport = class {
29086
29385
  for (const block of typeof message.message.content === "string" ? [] : message.message.content) {
29087
29386
  if (block.type !== "tool_result")
29088
29387
  continue;
29089
- active.onEvent({
29388
+ active2.onEvent({
29090
29389
  type: "tool.update",
29091
29390
  callId: block.tool_use_id,
29092
29391
  status: block.is_error ? "failed" : "completed",
@@ -29100,9 +29399,9 @@ var QwenCodeSdkTransport = class {
29100
29399
  if (this.#closed || this.#failure)
29101
29400
  return;
29102
29401
  this.#failure = error51;
29103
- const active = this.#active;
29402
+ const active2 = this.#active;
29104
29403
  this.#active = null;
29105
- active?.reject(error51);
29404
+ active2?.reject(error51);
29106
29405
  this.#options.onFault?.(error51);
29107
29406
  }
29108
29407
  };
@@ -29114,40 +29413,33 @@ function isRecord4(value) {
29114
29413
  function nonBlank(value) {
29115
29414
  return typeof value === "string" && value.trim().length > 0;
29116
29415
  }
29117
- function sanitizeQwenCodeModelRefId(nativeModelId, taken) {
29118
- const sanitized = nativeModelId.replace(/[^A-Za-z0-9._~-]/gu, "-").replace(/^-+/u, "").replace(/-+$/u, "");
29119
- const base = sanitized.length > 0 ? sanitized : "qwen-model";
29120
- let candidate = base;
29121
- let suffix = 2;
29122
- while (taken.has(candidate))
29123
- candidate = `${base}-${suffix++}`;
29124
- return candidate;
29416
+ function legacyAliasBase(id2) {
29417
+ return id2.replace(/[^A-Za-z0-9._~-]/gu, "-").replace(/^-+|-+$/gu, "") || "qwen-model";
29418
+ }
29419
+ function normalizeStoredQwenCodeModelRef(ref, catalog) {
29420
+ if (ref.serviceTier)
29421
+ return void 0;
29422
+ const matches = catalog.models.filter(({ ref: candidate }) => !candidate.serviceTier && legacyAliasBase(candidate.id) === ref.id);
29423
+ return matches.length === 1 ? matches[0]?.ref : void 0;
29125
29424
  }
29126
29425
  function parseQwenCodeModelState(value) {
29127
- if (!isRecord4(value) || !nonBlank(value.currentModelId) || !Array.isArray(value.availableModels)) {
29426
+ if (!isRecord4(value) || typeof value.currentModelId !== "string" || !Array.isArray(value.availableModels)) {
29128
29427
  return null;
29129
29428
  }
29130
- const nativeModelIdByRef = /* @__PURE__ */ new Map();
29131
29429
  const contextWindowTokensByModel = /* @__PURE__ */ new Map();
29132
29430
  const models = [];
29133
- const takenRefs = /* @__PURE__ */ new Set();
29134
29431
  const seenNativeModelIds = /* @__PURE__ */ new Set();
29135
29432
  let currentModel = null;
29136
29433
  for (const candidate of value.availableModels) {
29137
- if (!isRecord4(candidate) || !nonBlank(candidate.modelId) || !nonBlank(candidate.name))
29138
- continue;
29139
- if (seenNativeModelIds.has(candidate.modelId))
29434
+ if (!isRecord4(candidate) || !nonBlank(candidate.name))
29140
29435
  continue;
29141
- const refId = sanitizeQwenCodeModelRefId(candidate.modelId, takenRefs);
29142
- const ref = harnessModelRefSchema.safeParse({ id: refId });
29143
- if (!ref.success)
29436
+ const ref = harnessModelRefSchema.safeParse({ id: candidate.modelId });
29437
+ if (!ref.success || seenNativeModelIds.has(ref.data.id))
29144
29438
  continue;
29145
- takenRefs.add(refId);
29146
- seenNativeModelIds.add(candidate.modelId);
29147
- nativeModelIdByRef.set(refId, candidate.modelId);
29439
+ seenNativeModelIds.add(ref.data.id);
29148
29440
  const metadata = isRecord4(candidate._meta) ? candidate._meta : {};
29149
29441
  if (typeof metadata.contextLimit === "number" && Number.isSafeInteger(metadata.contextLimit) && metadata.contextLimit > 0) {
29150
- contextWindowTokensByModel.set(refId, metadata.contextLimit);
29442
+ contextWindowTokensByModel.set(ref.data.id, metadata.contextLimit);
29151
29443
  }
29152
29444
  const model2 = { ref: ref.data, label: candidate.name };
29153
29445
  models.push(model2);
@@ -29159,7 +29451,6 @@ function parseQwenCodeModelState(value) {
29159
29451
  return null;
29160
29452
  return {
29161
29453
  currentModel,
29162
- nativeModelIdByRef,
29163
29454
  contextWindowTokensByModel,
29164
29455
  catalog: {
29165
29456
  models,
@@ -29168,9 +29459,6 @@ function parseQwenCodeModelState(value) {
29168
29459
  }
29169
29460
  };
29170
29461
  }
29171
- function nativeModelIdForRef(modelState, model2) {
29172
- return modelState.nativeModelIdByRef.get(model2.id);
29173
- }
29174
29462
  function stateForQwenCodeModel(modelState, nativeState, model2 = modelState.currentModel, permissionModeId) {
29175
29463
  return {
29176
29464
  ...nativeState,
@@ -29231,11 +29519,11 @@ function toolCall(part) {
29231
29519
  const call = isRecord5(part.functionCall) ? part.functionCall : part.tool_use;
29232
29520
  if (!isRecord5(call))
29233
29521
  return null;
29234
- const id = typeof call.id === "string" ? call.id : typeof call.callId === "string" ? call.callId : null;
29522
+ const id2 = typeof call.id === "string" ? call.id : typeof call.callId === "string" ? call.callId : null;
29235
29523
  const name = typeof call.name === "string" ? call.name : null;
29236
- if (!id || !name)
29524
+ if (!id2 || !name)
29237
29525
  return null;
29238
- return { id, name, input: call.args ?? call.input ?? {} };
29526
+ return { id: id2, name, input: call.args ?? call.input ?? {} };
29239
29527
  }
29240
29528
  function toolResult(record3) {
29241
29529
  const result = isRecord5(record3.toolCallResult) ? record3.toolCallResult : null;
@@ -29244,14 +29532,14 @@ function toolResult(record3) {
29244
29532
  const source = result ?? (isRecord5(response) ? response : null);
29245
29533
  if (!source)
29246
29534
  return null;
29247
- const id = typeof source.callId === "string" ? source.callId : typeof source.id === "string" ? source.id : typeof source.tool_use_id === "string" ? source.tool_use_id : null;
29248
- if (!id)
29535
+ const id2 = typeof source.callId === "string" ? source.callId : typeof source.id === "string" ? source.id : typeof source.tool_use_id === "string" ? source.tool_use_id : null;
29536
+ if (!id2)
29249
29537
  return null;
29250
29538
  const statuses = [source.status, source.executionStatus].filter((value) => typeof value === "string").map((value) => value.toLowerCase());
29251
29539
  const cancelled = statuses.some((value) => value === "cancelled" || value === "canceled");
29252
29540
  const failed = source.error === true || source.is_error === true || source.error !== void 0 && source.error !== null && source.error !== false || statuses.some((value) => value === "error" || value === "failed" || value === "failure");
29253
29541
  return {
29254
- id,
29542
+ id: id2,
29255
29543
  output: source.resultDisplay ?? source.response ?? source.result ?? source.content ?? "",
29256
29544
  status: cancelled ? "cancelled" : failed ? "failed" : "succeeded"
29257
29545
  };
@@ -29283,7 +29571,7 @@ function stableItemId(kind, turn, index) {
29283
29571
  }
29284
29572
  function projectHistory(records, harnessId, sessionId, cwd, knownTurnRefs, toolOutputLimit) {
29285
29573
  const turns = [];
29286
- let input = "";
29574
+ let input2 = "";
29287
29575
  let items = [];
29288
29576
  let agent = null;
29289
29577
  let reasoning = null;
@@ -29303,7 +29591,7 @@ function projectHistory(records, harnessId, sessionId, cwd, knownTurnRefs, toolO
29303
29591
  reasoning = null;
29304
29592
  };
29305
29593
  const finishTurn = () => {
29306
- if (input.length === 0)
29594
+ if (input2.length === 0)
29307
29595
  return;
29308
29596
  finishReasoning();
29309
29597
  finishAgent();
@@ -29318,11 +29606,11 @@ function projectHistory(records, harnessId, sessionId, cwd, knownTurnRefs, toolO
29318
29606
  nativeTurnKey: qwenCodeTurnKey(ordinal),
29319
29607
  formatVersion: 1
29320
29608
  }),
29321
- input: [{ type: "text", text: input }],
29609
+ input: [{ type: "text", text: input2 }],
29322
29610
  items,
29323
29611
  outcome
29324
29612
  });
29325
- input = "";
29613
+ input2 = "";
29326
29614
  items = [];
29327
29615
  agent = null;
29328
29616
  reasoning = null;
@@ -29347,7 +29635,7 @@ function projectHistory(records, harnessId, sessionId, cwd, knownTurnRefs, toolO
29347
29635
  if (subtype === "notification" || subtype === "cron" || subtype === "mid_turn_user_message")
29348
29636
  continue;
29349
29637
  finishTurn();
29350
- input = messageText(record3);
29638
+ input2 = messageText(record3);
29351
29639
  continue;
29352
29640
  }
29353
29641
  if (record3.type === "tool_result") {
@@ -29360,7 +29648,7 @@ function projectHistory(records, harnessId, sessionId, cwd, knownTurnRefs, toolO
29360
29648
  }
29361
29649
  continue;
29362
29650
  }
29363
- if (record3.type !== "assistant" || input.length === 0)
29651
+ if (record3.type !== "assistant" || input2.length === 0)
29364
29652
  continue;
29365
29653
  for (const candidate of messageParts(record3)) {
29366
29654
  if (!isRecord5(candidate))
@@ -29444,10 +29732,10 @@ async function readQwenCodeHistory(cwd, harnessId, sessionId, knownTurnRefs = []
29444
29732
  path4.join(projectDir, "archive", `${sessionId}.jsonl`)
29445
29733
  ];
29446
29734
  let lastReadError;
29447
- for (const filePath of paths) {
29735
+ for (const filePath2 of paths) {
29448
29736
  let content;
29449
29737
  try {
29450
- content = await readFile(filePath, "utf8");
29738
+ content = await readFile(filePath2, "utf8");
29451
29739
  } catch (error51) {
29452
29740
  lastReadError = error51;
29453
29741
  continue;
@@ -29530,8 +29818,8 @@ function normalizeError(error51, fallback) {
29530
29818
  retryable: fallback === "unavailable" || fallback === "nativeFailure"
29531
29819
  };
29532
29820
  }
29533
- function qwenQuestions(input) {
29534
- const questions = input.questions;
29821
+ function qwenQuestions(input2) {
29822
+ const questions = input2.questions;
29535
29823
  if (!Array.isArray(questions))
29536
29824
  return null;
29537
29825
  const parsed = questions.flatMap((candidate) => {
@@ -29684,8 +29972,8 @@ var QwenCodeHarnessSession = class {
29684
29972
  }
29685
29973
  };
29686
29974
  }
29687
- const text = command.input.map(({ text: text2 }) => text2).join("\n");
29688
- if (text.length === 0) {
29975
+ const text2 = command.input.map(({ text: text3 }) => text3).join("\n");
29976
+ if (text2.length === 0) {
29689
29977
  return {
29690
29978
  ok: false,
29691
29979
  error: {
@@ -29699,7 +29987,7 @@ var QwenCodeHarnessSession = class {
29699
29987
  const completion = new Promise((resolve2) => {
29700
29988
  resolveCompletion = resolve2;
29701
29989
  });
29702
- const active = {
29990
+ const active2 = {
29703
29991
  command,
29704
29992
  agent: null,
29705
29993
  reasoning: null,
@@ -29710,14 +29998,13 @@ var QwenCodeHarnessSession = class {
29710
29998
  completion,
29711
29999
  resolveCompletion
29712
30000
  };
29713
- this.#active = active;
30001
+ this.#active = active2;
29714
30002
  this.#event({ type: "turn.started", turnId: command.turnId });
29715
- void this.#transport.runTurn(text, (event) => this.#handleEvent(active, event), (request) => this.#requestPermission(active, request)).then((response) => this.#finish(active, terminalOutcome(response, active.cancellationRequested)), (error51) => this.#finish(active, { status: "failed", error: normalizeError(error51, "nativeFailure") }));
30003
+ void this.#transport.runTurn(text2, (event) => this.#handleEvent(active2, event), (request) => this.#requestPermission(active2, request)).then((response) => this.#finish(active2, terminalOutcome(response, active2.cancellationRequested)), (error51) => this.#finish(active2, { status: "failed", error: normalizeError(error51, "nativeFailure") }));
29716
30004
  return { ok: true, value: { turnId: command.turnId } };
29717
30005
  }
29718
30006
  async #selectModel(command) {
29719
- const nativeModelId = nativeModelIdForRef(this.#modelState, command.model);
29720
- if (!nativeModelId) {
30007
+ if (!catalogModelForRef(this.#modelState.catalog, command.model)) {
29721
30008
  return {
29722
30009
  ok: false,
29723
30010
  error: {
@@ -29739,7 +30026,7 @@ var QwenCodeHarnessSession = class {
29739
30026
  }
29740
30027
  this.#configuring = true;
29741
30028
  try {
29742
- await this.#transport.setModel(nativeModelId);
30029
+ await this.#transport.setModel(command.model.id);
29743
30030
  this.#modelState = { ...this.#modelState, currentModel: command.model };
29744
30031
  this.#state = stateForQwenCodeModel(this.#modelState, { nativeRef: nativeRef(this.#transport.sessionId) }, command.model, this.#state.effectivePermissionModeId);
29745
30032
  this.#event({ type: "session.state.changed", state: this.#state });
@@ -29789,17 +30076,17 @@ var QwenCodeHarnessSession = class {
29789
30076
  }
29790
30077
  }
29791
30078
  async #cancel(command) {
29792
- const active = this.#active;
29793
- if (!active || active.command.turnId !== command.turnId) {
30079
+ const active2 = this.#active;
30080
+ if (!active2 || active2.command.turnId !== command.turnId) {
29794
30081
  return {
29795
30082
  ok: false,
29796
30083
  error: invalidState("Qwen Code Turn Cancel must reference the active Turn")
29797
30084
  };
29798
30085
  }
29799
- if (active.cancellationRequested)
30086
+ if (active2.cancellationRequested)
29800
30087
  return { ok: true, value: { cancellationRequested: true } };
29801
- active.cancellationRequested = true;
29802
- for (const approval of active.approvals.values()) {
30088
+ active2.cancellationRequested = true;
30089
+ for (const approval of active2.approvals.values()) {
29803
30090
  approval.resolve({ behavior: "deny" });
29804
30091
  }
29805
30092
  try {
@@ -29810,9 +30097,9 @@ var QwenCodeHarnessSession = class {
29810
30097
  }
29811
30098
  }
29812
30099
  async #respond(command) {
29813
- const active = this.#active;
29814
- const pending = active?.approvals.get(command.interactionId);
29815
- if (!active || !pending)
30100
+ const active2 = this.#active;
30101
+ const pending = active2?.approvals.get(command.interactionId);
30102
+ if (!active2 || !pending)
29816
30103
  return { ok: false, error: invalidState("Qwen Code interaction is not pending") };
29817
30104
  if (pending.interaction.type === "question") {
29818
30105
  if (command.response.type !== "question")
@@ -29823,7 +30110,7 @@ var QwenCodeHarnessSession = class {
29823
30110
  const validation = validateHostQuestionResponse(pending.interaction, command.response);
29824
30111
  if (validation)
29825
30112
  return { ok: false, error: validation };
29826
- active.approvals.delete(command.interactionId);
30113
+ active2.approvals.delete(command.interactionId);
29827
30114
  if (command.response.cancelled)
29828
30115
  pending.resolve({ behavior: "deny" });
29829
30116
  else {
@@ -29843,7 +30130,7 @@ var QwenCodeHarnessSession = class {
29843
30130
  return { ok: false, error: validation };
29844
30131
  if (command.response.actionId !== "allow" && command.response.actionId !== "deny")
29845
30132
  return { ok: false, error: invalidState("Qwen Code Approval action is unavailable") };
29846
- active.approvals.delete(command.interactionId);
30133
+ active2.approvals.delete(command.interactionId);
29847
30134
  const behavior = command.response.actionId;
29848
30135
  pending.resolve({
29849
30136
  behavior,
@@ -29853,20 +30140,20 @@ var QwenCodeHarnessSession = class {
29853
30140
  this.#event({
29854
30141
  type: "interaction.closed",
29855
30142
  interactionId: command.interactionId,
29856
- turnId: active.command.turnId,
30143
+ turnId: active2.command.turnId,
29857
30144
  reason: "responded"
29858
30145
  });
29859
30146
  return { ok: true, value: { accepted: true } };
29860
30147
  }
29861
- #requestPermission(active, request) {
29862
- if (this.#active !== active || active.cancellationRequested)
30148
+ #requestPermission(active2, request) {
30149
+ if (this.#active !== active2 || active2.cancellationRequested)
29863
30150
  return Promise.resolve({ behavior: "deny" });
29864
30151
  const interactionId = hostInteractionIdSchema.parse(this.#randomUUID());
29865
30152
  const questions = request.toolName === "ask_user_question" ? qwenQuestions(request.input) : null;
29866
30153
  const interaction = questions ? {
29867
30154
  type: "question",
29868
30155
  interactionId,
29869
- turnId: active.command.turnId,
30156
+ turnId: active2.command.turnId,
29870
30157
  ...questions.length === 1 && questions[0]?.header ? { title: questions[0].header } : { title: "Qwen Code" },
29871
30158
  questions: questions.map((question, index) => ({
29872
30159
  id: `question-${index}`,
@@ -29884,7 +30171,7 @@ var QwenCodeHarnessSession = class {
29884
30171
  } : {
29885
30172
  type: "approval",
29886
30173
  interactionId,
29887
- turnId: active.command.turnId,
30174
+ turnId: active2.command.turnId,
29888
30175
  title: request.toolName,
29889
30176
  subject: { type: "nativeAction" },
29890
30177
  actions: [
@@ -29893,66 +30180,66 @@ var QwenCodeHarnessSession = class {
29893
30180
  ]
29894
30181
  };
29895
30182
  return new Promise((resolve2) => {
29896
- active.approvals.set(interactionId, { interaction, request, resolve: resolve2 });
30183
+ active2.approvals.set(interactionId, { interaction, request, resolve: resolve2 });
29897
30184
  this.#channel.emit({ kind: "interaction", interaction });
29898
30185
  });
29899
30186
  }
29900
- #handleEvent(active, event) {
29901
- if (this.#active !== active || this.#phase !== "open")
30187
+ #handleEvent(active2, event) {
30188
+ if (this.#active !== active2 || this.#phase !== "open")
29902
30189
  return;
29903
30190
  if (event.type === "usage") {
29904
30191
  const usage = usageFromMetadata(event.metadata);
29905
30192
  if (usage)
29906
- this.#publishUsage(usage, active.command.turnId);
30193
+ this.#publishUsage(usage, active2.command.turnId);
29907
30194
  return;
29908
30195
  }
29909
30196
  if (event.type === "agent.text")
29910
- this.#appendAgent(active, event.text);
30197
+ this.#appendAgent(active2, event.text);
29911
30198
  else if (event.type === "agent.thought")
29912
- this.#appendReasoning(active, event.text);
30199
+ this.#appendReasoning(active2, event.text);
29913
30200
  else if (event.type === "tool.call")
29914
- this.#startTool(active, event);
30201
+ this.#startTool(active2, event);
29915
30202
  else if (event.type === "tool.update")
29916
- this.#updateTool(active, event);
30203
+ this.#updateTool(active2, event);
29917
30204
  }
29918
- #appendAgent(active, text) {
29919
- if (!active.agent) {
29920
- this.#completeReasoning(active, { status: "succeeded" });
29921
- active.agent = {
30205
+ #appendAgent(active2, text2) {
30206
+ if (!active2.agent) {
30207
+ this.#completeReasoning(active2, { status: "succeeded" });
30208
+ active2.agent = {
29922
30209
  type: "agentMessage",
29923
30210
  itemId: hostItemIdSchema.parse(this.#randomUUID()),
29924
30211
  text: ""
29925
30212
  };
29926
- this.#event({ type: "item.started", turnId: active.command.turnId, item: active.agent });
30213
+ this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.agent });
29927
30214
  }
29928
- active.agent = { ...active.agent, text: active.agent.text + text };
30215
+ active2.agent = { ...active2.agent, text: active2.agent.text + text2 };
29929
30216
  this.#event({
29930
30217
  type: "item.updated",
29931
- turnId: active.command.turnId,
29932
- itemId: active.agent.itemId,
29933
- update: { type: "text.append", text }
30218
+ turnId: active2.command.turnId,
30219
+ itemId: active2.agent.itemId,
30220
+ update: { type: "text.append", text: text2 }
29934
30221
  });
29935
30222
  }
29936
- #appendReasoning(active, text) {
29937
- if (!active.reasoning) {
29938
- active.reasoning = {
30223
+ #appendReasoning(active2, text2) {
30224
+ if (!active2.reasoning) {
30225
+ active2.reasoning = {
29939
30226
  type: "reasoning",
29940
30227
  itemId: hostItemIdSchema.parse(this.#randomUUID()),
29941
30228
  text: ""
29942
30229
  };
29943
- this.#event({ type: "item.started", turnId: active.command.turnId, item: active.reasoning });
30230
+ this.#event({ type: "item.started", turnId: active2.command.turnId, item: active2.reasoning });
29944
30231
  }
29945
- active.reasoning = { ...active.reasoning, text: active.reasoning.text + text };
30232
+ active2.reasoning = { ...active2.reasoning, text: active2.reasoning.text + text2 };
29946
30233
  this.#event({
29947
30234
  type: "item.updated",
29948
- turnId: active.command.turnId,
29949
- itemId: active.reasoning.itemId,
29950
- update: { type: "text.append", text }
30235
+ turnId: active2.command.turnId,
30236
+ itemId: active2.reasoning.itemId,
30237
+ update: { type: "text.append", text: text2 }
29951
30238
  });
29952
30239
  }
29953
- #startTool(active, event) {
29954
- this.#completeReasoning(active, { status: "succeeded" });
29955
- this.#completeAgent(active, { status: "succeeded" });
30240
+ #startTool(active2, event) {
30241
+ this.#completeReasoning(active2, { status: "succeeded" });
30242
+ this.#completeAgent(active2, { status: "succeeded" });
29956
30243
  let item = startQwenCodeToolItem({
29957
30244
  itemId: hostItemIdSchema.parse(this.#randomUUID()),
29958
30245
  name: event.name,
@@ -29964,18 +30251,18 @@ var QwenCodeHarnessSession = class {
29964
30251
  const projection = projectQwenCodeToolOutput(event.content, event.rawOutput, this.#toolOutputLimit);
29965
30252
  if (hasQwenCodeToolProjection(projection))
29966
30253
  item = applyQwenCodeToolProjection(item, projection);
29967
- active.tools.set(event.callId, {
30254
+ active2.tools.set(event.callId, {
29968
30255
  item,
29969
30256
  rawInput: event.rawInput,
29970
30257
  ...event.status ? { status: event.status } : {}
29971
30258
  });
29972
- this.#event({ type: "item.started", turnId: active.command.turnId, item });
30259
+ this.#event({ type: "item.started", turnId: active2.command.turnId, item });
29973
30260
  if (event.status === "completed" || event.status === "failed") {
29974
- this.#completeTool(active, event.callId, event.status, event.content, event.rawOutput);
30261
+ this.#completeTool(active2, event.callId, event.status, event.content, event.rawOutput);
29975
30262
  }
29976
30263
  }
29977
- #updateTool(active, event) {
29978
- const tool = active.tools.get(event.callId);
30264
+ #updateTool(active2, event) {
30265
+ const tool = active2.tools.get(event.callId);
29979
30266
  if (!tool)
29980
30267
  return;
29981
30268
  if (event.rawInput !== void 0)
@@ -29991,7 +30278,7 @@ var QwenCodeHarnessSession = class {
29991
30278
  if (delta.length > 0) {
29992
30279
  this.#event({
29993
30280
  type: "item.updated",
29994
- turnId: active.command.turnId,
30281
+ turnId: active2.command.turnId,
29995
30282
  itemId: tool.item.itemId,
29996
30283
  update: { type: "output.append", text: delta }
29997
30284
  });
@@ -30000,7 +30287,7 @@ var QwenCodeHarnessSession = class {
30000
30287
  } else if (tool.item.type === "toolExecution" && projection.output) {
30001
30288
  this.#event({
30002
30289
  type: "item.updated",
30003
- turnId: active.command.turnId,
30290
+ turnId: active2.command.turnId,
30004
30291
  itemId: tool.item.itemId,
30005
30292
  update: { type: "output.replace", output: projection.output }
30006
30293
  });
@@ -30009,14 +30296,14 @@ var QwenCodeHarnessSession = class {
30009
30296
  if (event.status)
30010
30297
  tool.status = event.status;
30011
30298
  if (event.status === "completed" || event.status === "failed") {
30012
- this.#completeTool(active, event.callId, event.status, event.content, event.rawOutput);
30299
+ this.#completeTool(active2, event.callId, event.status, event.content, event.rawOutput);
30013
30300
  }
30014
30301
  }
30015
- #completeTool(active, callId, status, content, rawOutput) {
30016
- const tool = active.tools.get(callId);
30302
+ #completeTool(active2, callId, status, content, rawOutput) {
30303
+ const tool = active2.tools.get(callId);
30017
30304
  if (!tool)
30018
30305
  return;
30019
- active.tools.delete(callId);
30306
+ active2.tools.delete(callId);
30020
30307
  const projection = projectQwenCodeToolOutput(content, rawOutput, this.#toolOutputLimit);
30021
30308
  if (hasQwenCodeToolProjection(projection)) {
30022
30309
  tool.item = applyQwenCodeToolProjection(tool.item, projection);
@@ -30029,45 +30316,45 @@ var QwenCodeHarnessSession = class {
30029
30316
  retryable: false
30030
30317
  }
30031
30318
  } : { status: "succeeded" };
30032
- this.#completeItem(active, tool.item, outcome);
30319
+ this.#completeItem(active2, tool.item, outcome);
30033
30320
  }
30034
- #completeAgent(active, outcome) {
30035
- const item = active.agent;
30036
- active.agent = null;
30321
+ #completeAgent(active2, outcome) {
30322
+ const item = active2.agent;
30323
+ active2.agent = null;
30037
30324
  if (item)
30038
- this.#completeItem(active, item, outcome);
30325
+ this.#completeItem(active2, item, outcome);
30039
30326
  }
30040
- #completeReasoning(active, outcome) {
30041
- const item = active.reasoning;
30042
- active.reasoning = null;
30327
+ #completeReasoning(active2, outcome) {
30328
+ const item = active2.reasoning;
30329
+ active2.reasoning = null;
30043
30330
  if (item)
30044
- this.#completeItem(active, item, outcome);
30331
+ this.#completeItem(active2, item, outcome);
30045
30332
  }
30046
- #completeItem(active, item, outcome) {
30333
+ #completeItem(active2, item, outcome) {
30047
30334
  const snapshot = { item, outcome };
30048
- active.completedItems.push(snapshot);
30335
+ active2.completedItems.push(snapshot);
30049
30336
  this.#event({
30050
30337
  type: "item.completed",
30051
- turnId: active.command.turnId,
30338
+ turnId: active2.command.turnId,
30052
30339
  snapshot
30053
30340
  });
30054
30341
  }
30055
- #finish(active, outcome) {
30056
- if (this.#active !== active)
30342
+ #finish(active2, outcome) {
30343
+ if (this.#active !== active2)
30057
30344
  return;
30058
30345
  const itemOutcome = outcome;
30059
- this.#completeReasoning(active, itemOutcome);
30060
- this.#completeAgent(active, itemOutcome);
30061
- for (const tool of active.tools.values())
30062
- this.#completeItem(active, tool.item, itemOutcome);
30063
- active.tools.clear();
30064
- for (const [interactionId, pending] of active.approvals) {
30065
- active.approvals.delete(interactionId);
30346
+ this.#completeReasoning(active2, itemOutcome);
30347
+ this.#completeAgent(active2, itemOutcome);
30348
+ for (const tool of active2.tools.values())
30349
+ this.#completeItem(active2, tool.item, itemOutcome);
30350
+ active2.tools.clear();
30351
+ for (const [interactionId, pending] of active2.approvals) {
30352
+ active2.approvals.delete(interactionId);
30066
30353
  pending.resolve({ behavior: "deny" });
30067
30354
  this.#event({
30068
30355
  type: "interaction.closed",
30069
30356
  interactionId,
30070
- turnId: active.command.turnId,
30357
+ turnId: active2.command.turnId,
30071
30358
  reason: "cancelled"
30072
30359
  });
30073
30360
  }
@@ -30081,18 +30368,18 @@ var QwenCodeHarnessSession = class {
30081
30368
  this.#nextTurnOrdinal += 1;
30082
30369
  const turn = {
30083
30370
  nativeTurnRef,
30084
- input: active.command.input,
30085
- items: active.completedItems,
30371
+ input: active2.command.input,
30372
+ items: active2.completedItems,
30086
30373
  outcome
30087
30374
  };
30088
30375
  this.#snapshot.turns = [...this.#snapshot.turns, turn];
30089
30376
  this.#event({
30090
30377
  type: "turn.completed",
30091
- turnId: active.command.turnId,
30378
+ turnId: active2.command.turnId,
30092
30379
  nativeTurnRef,
30093
30380
  outcome
30094
30381
  });
30095
- active.resolveCompletion();
30382
+ active2.resolveCompletion();
30096
30383
  }
30097
30384
  #publishUsage(usage, observedForTurnId) {
30098
30385
  const merged = combineUsage(this.#usage, usage);
@@ -30117,10 +30404,10 @@ var QwenCodeHarnessSession = class {
30117
30404
  if (this.#phase === "closed")
30118
30405
  return;
30119
30406
  this.#phase = "closing";
30120
- const active = this.#active;
30121
- if (active) {
30122
- active.cancellationRequested = true;
30123
- for (const approval of active.approvals.values())
30407
+ const active2 = this.#active;
30408
+ if (active2) {
30409
+ active2.cancellationRequested = true;
30410
+ for (const approval of active2.approvals.values())
30124
30411
  approval.resolve({ behavior: "deny" });
30125
30412
  const { promise: deadline, resolve: resolve2 } = Promise.withResolvers();
30126
30413
  const timeout = setTimeout(() => resolve2(void 0), this.#closeTimeoutMs);
@@ -30128,7 +30415,7 @@ var QwenCodeHarnessSession = class {
30128
30415
  await Promise.race([
30129
30416
  (async () => {
30130
30417
  await this.#transport.cancel().catch(() => void 0);
30131
- await active.completion;
30418
+ await active2.completion;
30132
30419
  })(),
30133
30420
  deadline
30134
30421
  ]);
@@ -30163,11 +30450,13 @@ var QwenCodeHarnessSession = class {
30163
30450
  }
30164
30451
  };
30165
30452
  var QwenCodeAdapter = class {
30453
+ normalizeStoredModelRef = normalizeStoredQwenCodeModelRef;
30166
30454
  harnessId = qwenCodeHarnessId;
30167
30455
  #closeTimeoutMs;
30168
30456
  #dependencies;
30169
30457
  #environment;
30170
30458
  #inspectionCache = /* @__PURE__ */ new Map();
30459
+ #inspectionGeneration = 0;
30171
30460
  #sessions = /* @__PURE__ */ new Set();
30172
30461
  #toolOutputLimit;
30173
30462
  #closePromise = null;
@@ -30180,16 +30469,19 @@ var QwenCodeAdapter = class {
30180
30469
  createTransport: (transportOptions) => new QwenCodeSdkTransport({ ...options, ...transportOptions })
30181
30470
  };
30182
30471
  }
30183
- async inspect(input = {}) {
30472
+ async inspect(input2 = {}) {
30184
30473
  if (this.#closePromise) {
30185
30474
  return { status: "unavailable", error: invalidState("Qwen Code Adapter is closed") };
30186
30475
  }
30187
- const cwd = path5.resolve(input.cwd ?? process.cwd());
30188
- if (!input.refresh) {
30189
- const cached2 = this.#inspectionCache.get(cwd);
30190
- if (cached2)
30191
- return cached2;
30476
+ const cwd = path5.resolve(input2.cwd ?? process.cwd());
30477
+ if (input2.refresh) {
30478
+ this.#inspectionCache.clear();
30479
+ this.#inspectionGeneration++;
30192
30480
  }
30481
+ const cached2 = this.#inspectionCache.get(cwd);
30482
+ if (cached2)
30483
+ return cached2;
30484
+ const generation = this.#inspectionGeneration;
30193
30485
  let transport = null;
30194
30486
  const startedAt = Date.now();
30195
30487
  let stage = "spawn";
@@ -30212,7 +30504,8 @@ var QwenCodeAdapter = class {
30212
30504
  permissionModes: QWEN_CODE_PERMISSION_MODE_CATALOG,
30213
30505
  capabilities: capabilitiesForModels(modelState)
30214
30506
  };
30215
- this.#inspectionCache.set(cwd, ready);
30507
+ if (!this.#closePromise && generation === this.#inspectionGeneration)
30508
+ this.#inspectionCache.set(cwd, ready);
30216
30509
  return ready;
30217
30510
  } catch (error51) {
30218
30511
  await transport?.close().catch(() => void 0);
@@ -30227,11 +30520,11 @@ var QwenCodeAdapter = class {
30227
30520
  };
30228
30521
  }
30229
30522
  }
30230
- async open(input) {
30523
+ async open(input2) {
30231
30524
  if (this.#closePromise) {
30232
30525
  return { ok: false, error: invalidState("Qwen Code Adapter is closed") };
30233
30526
  }
30234
- if (input.cwd.length === 0) {
30527
+ if (input2.cwd.length === 0) {
30235
30528
  return {
30236
30529
  ok: false,
30237
30530
  error: {
@@ -30241,7 +30534,7 @@ var QwenCodeAdapter = class {
30241
30534
  }
30242
30535
  };
30243
30536
  }
30244
- if (input.kind === "fork" || input.kind === "rollbackLastTurn") {
30537
+ if (input2.kind === "fork" || input2.kind === "rollbackLastTurn") {
30245
30538
  return {
30246
30539
  ok: false,
30247
30540
  error: {
@@ -30251,14 +30544,14 @@ var QwenCodeAdapter = class {
30251
30544
  }
30252
30545
  };
30253
30546
  }
30254
- const cwd = path5.resolve(input.cwd);
30255
- const sessionEnvironment = mergeEnvironment(this.#environment, input.environment);
30547
+ const cwd = path5.resolve(input2.cwd);
30548
+ const sessionEnvironment = mergeEnvironment(this.#environment, input2.environment);
30256
30549
  let initialPermissionModeId = QWEN_CODE_DEFAULT_PERMISSION_MODE_ID;
30257
- if (input.kind === "create") {
30258
- const requested = input.permissionModeId ?? (input.executionPolicy === "unattended-full-access" ? qwenCodeUnattendedPermissionModeId : QWEN_CODE_DEFAULT_PERMISSION_MODE_ID);
30550
+ if (input2.kind === "create") {
30551
+ const requested = input2.permissionModeId ?? (input2.executionPolicy === "unattended-full-access" ? qwenCodeUnattendedPermissionModeId : QWEN_CODE_DEFAULT_PERMISSION_MODE_ID);
30259
30552
  try {
30260
30553
  const permissionMode = decodeQwenCodePermissionModeId(requested);
30261
- if (input.executionPolicy === "unattended-full-access" && permissionMode !== "yolo") {
30554
+ if (input2.executionPolicy === "unattended-full-access" && permissionMode !== "yolo") {
30262
30555
  return {
30263
30556
  ok: false,
30264
30557
  error: {
@@ -30279,9 +30572,9 @@ var QwenCodeAdapter = class {
30279
30572
  };
30280
30573
  }
30281
30574
  initialPermissionModeId = requested;
30282
- } else if (input.permissionModeId) {
30575
+ } else if (input2.permissionModeId) {
30283
30576
  try {
30284
- decodeQwenCodePermissionModeId(input.permissionModeId);
30577
+ decodeQwenCodePermissionModeId(input2.permissionModeId);
30285
30578
  } catch {
30286
30579
  return {
30287
30580
  ok: false,
@@ -30292,11 +30585,11 @@ var QwenCodeAdapter = class {
30292
30585
  }
30293
30586
  };
30294
30587
  }
30295
- initialPermissionModeId = input.permissionModeId;
30588
+ initialPermissionModeId = input2.permissionModeId;
30296
30589
  }
30297
30590
  let parsedRef = null;
30298
- if (input.kind === "resume") {
30299
- parsedRef = nativeSessionRefSchema.safeParse(input.nativeRef);
30591
+ if (input2.kind === "resume") {
30592
+ parsedRef = nativeSessionRefSchema.safeParse(input2.nativeRef);
30300
30593
  if (!parsedRef.success || parsedRef.data.harnessId !== this.harnessId) {
30301
30594
  return {
30302
30595
  ok: false,
@@ -30322,7 +30615,7 @@ var QwenCodeAdapter = class {
30322
30615
  });
30323
30616
  try {
30324
30617
  let opened;
30325
- if (input.kind === "create") {
30618
+ if (input2.kind === "create") {
30326
30619
  opened = await transport.open({ kind: "create", permissionMode: initialPermissionModeId });
30327
30620
  } else {
30328
30621
  const resumeRef = parsedRef;
@@ -30339,21 +30632,20 @@ var QwenCodeAdapter = class {
30339
30632
  if (!modelState) {
30340
30633
  throw new QwenCodeTransportError("protocolError", "Qwen Code returned an invalid Model catalog");
30341
30634
  }
30342
- const selectedModel = input.kind === "create" ? input.model ?? modelState.currentModel : modelState.currentModel;
30343
- const nativeModelId = nativeModelIdForRef(modelState, selectedModel);
30344
- if (!nativeModelId) {
30635
+ const selectedModel = input2.kind === "create" ? input2.model ?? modelState.currentModel : modelState.currentModel;
30636
+ if (!catalogModelForRef(modelState.catalog, selectedModel)) {
30345
30637
  throw new QwenCodeTransportError("protocolError", "Requested Qwen Code Model is unavailable");
30346
30638
  }
30347
- await transport.setModel(nativeModelId);
30639
+ await transport.setModel(selectedModel.id);
30348
30640
  modelState.currentModel = selectedModel;
30349
- const history = input.kind === "resume" ? (await readQwenCodeHistory(cwd, this.harnessId, opened.sessionId, input.knownTurnRefs, this.#toolOutputLimit, sessionEnvironment)).turns : [];
30641
+ const history = input2.kind === "resume" ? (await readQwenCodeHistory(cwd, this.harnessId, opened.sessionId, input2.knownTurnRefs, this.#toolOutputLimit, sessionEnvironment)).turns : [];
30350
30642
  const initialUsage = null;
30351
30643
  if (pendingTransportFault)
30352
30644
  throw pendingTransportFault;
30353
30645
  const openedSession = new QwenCodeHarnessSession(cwd, transport, opened, modelState, () => this.#sessions.delete(openedSession), {
30354
30646
  closeTimeoutMs: this.#closeTimeoutMs,
30355
30647
  history,
30356
- turnCount: input.kind === "resume" ? Math.max(nextQwenCodeTurnOrdinal(input.knownTurnRefs ?? []), history.length) : 0,
30648
+ turnCount: input2.kind === "resume" ? Math.max(nextQwenCodeTurnOrdinal(input2.knownTurnRefs ?? []), history.length) : 0,
30357
30649
  initialUsage,
30358
30650
  initialPermissionModeId,
30359
30651
  randomUUID: this.#dependencies.randomUUID,