@promptframe/creation 0.3.12 → 0.3.14

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.
package/dist/cli.mjs CHANGED
@@ -407,11 +407,11 @@ var require_codegen = __commonJS({
407
407
  const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
408
408
  return `${varKind} ${this.name}${rhs};` + _n2;
409
409
  }
410
- optimizeNames(names, constants8) {
410
+ optimizeNames(names, constants10) {
411
411
  if (!names[this.name.str])
412
412
  return;
413
413
  if (this.rhs)
414
- this.rhs = optimizeExpr(this.rhs, names, constants8);
414
+ this.rhs = optimizeExpr(this.rhs, names, constants10);
415
415
  return this;
416
416
  }
417
417
  get names() {
@@ -428,10 +428,10 @@ var require_codegen = __commonJS({
428
428
  render({ _n: _n2 }) {
429
429
  return `${this.lhs} = ${this.rhs};` + _n2;
430
430
  }
431
- optimizeNames(names, constants8) {
431
+ optimizeNames(names, constants10) {
432
432
  if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
433
433
  return;
434
- this.rhs = optimizeExpr(this.rhs, names, constants8);
434
+ this.rhs = optimizeExpr(this.rhs, names, constants10);
435
435
  return this;
436
436
  }
437
437
  get names() {
@@ -470,9 +470,9 @@ var require_codegen = __commonJS({
470
470
  }
471
471
  };
472
472
  var Throw = class extends Node {
473
- constructor(error5) {
473
+ constructor(error6) {
474
474
  super();
475
- this.error = error5;
475
+ this.error = error6;
476
476
  }
477
477
  render({ _n: _n2 }) {
478
478
  return `throw ${this.error};` + _n2;
@@ -492,8 +492,8 @@ var require_codegen = __commonJS({
492
492
  optimizeNodes() {
493
493
  return `${this.code}` ? this : void 0;
494
494
  }
495
- optimizeNames(names, constants8) {
496
- this.code = optimizeExpr(this.code, names, constants8);
495
+ optimizeNames(names, constants10) {
496
+ this.code = optimizeExpr(this.code, names, constants10);
497
497
  return this;
498
498
  }
499
499
  get names() {
@@ -522,12 +522,12 @@ var require_codegen = __commonJS({
522
522
  }
523
523
  return nodes.length > 0 ? this : void 0;
524
524
  }
525
- optimizeNames(names, constants8) {
525
+ optimizeNames(names, constants10) {
526
526
  const { nodes } = this;
527
527
  let i = nodes.length;
528
528
  while (i--) {
529
529
  const n = nodes[i];
530
- if (n.optimizeNames(names, constants8))
530
+ if (n.optimizeNames(names, constants10))
531
531
  continue;
532
532
  subtractNames(names, n.names);
533
533
  nodes.splice(i, 1);
@@ -580,12 +580,12 @@ var require_codegen = __commonJS({
580
580
  return void 0;
581
581
  return this;
582
582
  }
583
- optimizeNames(names, constants8) {
583
+ optimizeNames(names, constants10) {
584
584
  var _a3;
585
- this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants8);
586
- if (!(super.optimizeNames(names, constants8) || this.else))
585
+ this.else = (_a3 = this.else) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants10);
586
+ if (!(super.optimizeNames(names, constants10) || this.else))
587
587
  return;
588
- this.condition = optimizeExpr(this.condition, names, constants8);
588
+ this.condition = optimizeExpr(this.condition, names, constants10);
589
589
  return this;
590
590
  }
591
591
  get names() {
@@ -608,10 +608,10 @@ var require_codegen = __commonJS({
608
608
  render(opts) {
609
609
  return `for(${this.iteration})` + super.render(opts);
610
610
  }
611
- optimizeNames(names, constants8) {
612
- if (!super.optimizeNames(names, constants8))
611
+ optimizeNames(names, constants10) {
612
+ if (!super.optimizeNames(names, constants10))
613
613
  return;
614
- this.iteration = optimizeExpr(this.iteration, names, constants8);
614
+ this.iteration = optimizeExpr(this.iteration, names, constants10);
615
615
  return this;
616
616
  }
617
617
  get names() {
@@ -647,10 +647,10 @@ var require_codegen = __commonJS({
647
647
  render(opts) {
648
648
  return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
649
649
  }
650
- optimizeNames(names, constants8) {
651
- if (!super.optimizeNames(names, constants8))
650
+ optimizeNames(names, constants10) {
651
+ if (!super.optimizeNames(names, constants10))
652
652
  return;
653
- this.iterable = optimizeExpr(this.iterable, names, constants8);
653
+ this.iterable = optimizeExpr(this.iterable, names, constants10);
654
654
  return this;
655
655
  }
656
656
  get names() {
@@ -692,11 +692,11 @@ var require_codegen = __commonJS({
692
692
  (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
693
693
  return this;
694
694
  }
695
- optimizeNames(names, constants8) {
695
+ optimizeNames(names, constants10) {
696
696
  var _a3, _b;
697
- super.optimizeNames(names, constants8);
698
- (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants8);
699
- (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants8);
697
+ super.optimizeNames(names, constants10);
698
+ (_a3 = this.catch) === null || _a3 === void 0 ? void 0 : _a3.optimizeNames(names, constants10);
699
+ (_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants10);
700
700
  return this;
701
701
  }
702
702
  get names() {
@@ -709,9 +709,9 @@ var require_codegen = __commonJS({
709
709
  }
710
710
  };
711
711
  var Catch = class extends BlockNode {
712
- constructor(error5) {
712
+ constructor(error6) {
713
713
  super();
714
- this.error = error5;
714
+ this.error = error6;
715
715
  }
716
716
  render(opts) {
717
717
  return `catch(${this.error})` + super.render(opts);
@@ -902,9 +902,9 @@ var require_codegen = __commonJS({
902
902
  this._blockNode(node2);
903
903
  this.code(tryBody);
904
904
  if (catchCode) {
905
- const error5 = this.name("e");
906
- this._currNode = node2.catch = new Catch(error5);
907
- catchCode(error5);
905
+ const error6 = this.name("e");
906
+ this._currNode = node2.catch = new Catch(error6);
907
+ catchCode(error6);
908
908
  }
909
909
  if (finallyCode) {
910
910
  this._currNode = node2.finally = new Finally();
@@ -913,8 +913,8 @@ var require_codegen = __commonJS({
913
913
  return this._endBlockNode(Catch, Finally);
914
914
  }
915
915
  // `throw` statement
916
- throw(error5) {
917
- return this._leafNode(new Throw(error5));
916
+ throw(error6) {
917
+ return this._leafNode(new Throw(error6));
918
918
  }
919
919
  // start self-balancing block
920
920
  block(body, nodeCount) {
@@ -997,7 +997,7 @@ var require_codegen = __commonJS({
997
997
  function addExprNames(names, from) {
998
998
  return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
999
999
  }
1000
- function optimizeExpr(expr, names, constants8) {
1000
+ function optimizeExpr(expr, names, constants10) {
1001
1001
  if (expr instanceof code_1.Name)
1002
1002
  return replaceName(expr);
1003
1003
  if (!canOptimize(expr))
@@ -1012,14 +1012,14 @@ var require_codegen = __commonJS({
1012
1012
  return items;
1013
1013
  }, []));
1014
1014
  function replaceName(n) {
1015
- const c = constants8[n.str];
1015
+ const c = constants10[n.str];
1016
1016
  if (c === void 0 || names[n.str] !== 1)
1017
1017
  return n;
1018
1018
  delete names[n.str];
1019
1019
  return c;
1020
1020
  }
1021
1021
  function canOptimize(e) {
1022
- return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants8[c.str] !== void 0);
1022
+ return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants10[c.str] !== void 0);
1023
1023
  }
1024
1024
  }
1025
1025
  function subtractNames(names, from) {
@@ -1058,10 +1058,10 @@ var require_util = __commonJS({
1058
1058
  var codegen_1 = require_codegen();
1059
1059
  var code_1 = require_code();
1060
1060
  function toHash(arr) {
1061
- const hash7 = {};
1061
+ const hash8 = {};
1062
1062
  for (const item of arr)
1063
- hash7[item] = true;
1064
- return hash7;
1063
+ hash8[item] = true;
1064
+ return hash8;
1065
1065
  }
1066
1066
  exports.toHash = toHash;
1067
1067
  function alwaysValidSchema(it2, schema) {
@@ -1270,10 +1270,10 @@ var require_errors = __commonJS({
1270
1270
  exports.keyword$DataError = {
1271
1271
  message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)`
1272
1272
  };
1273
- function reportError(cxt, error5 = exports.keywordError, errorPaths, overrideAllErrors) {
1273
+ function reportError(cxt, error6 = exports.keywordError, errorPaths, overrideAllErrors) {
1274
1274
  const { it: it2 } = cxt;
1275
1275
  const { gen, compositeRule, allErrors } = it2;
1276
- const errObj = errorObjectCode(cxt, error5, errorPaths);
1276
+ const errObj = errorObjectCode(cxt, error6, errorPaths);
1277
1277
  if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) {
1278
1278
  addError(gen, errObj);
1279
1279
  } else {
@@ -1281,10 +1281,10 @@ var require_errors = __commonJS({
1281
1281
  }
1282
1282
  }
1283
1283
  exports.reportError = reportError;
1284
- function reportExtraError(cxt, error5 = exports.keywordError, errorPaths) {
1284
+ function reportExtraError(cxt, error6 = exports.keywordError, errorPaths) {
1285
1285
  const { it: it2 } = cxt;
1286
1286
  const { gen, compositeRule, allErrors } = it2;
1287
- const errObj = errorObjectCode(cxt, error5, errorPaths);
1287
+ const errObj = errorObjectCode(cxt, error6, errorPaths);
1288
1288
  addError(gen, errObj);
1289
1289
  if (!(compositeRule || allErrors)) {
1290
1290
  returnErrors(it2, names_1.default.vErrors);
@@ -1335,19 +1335,19 @@ var require_errors = __commonJS({
1335
1335
  schema: new codegen_1.Name("schema"),
1336
1336
  parentSchema: new codegen_1.Name("parentSchema")
1337
1337
  };
1338
- function errorObjectCode(cxt, error5, errorPaths) {
1338
+ function errorObjectCode(cxt, error6, errorPaths) {
1339
1339
  const { createErrors } = cxt.it;
1340
1340
  if (createErrors === false)
1341
1341
  return (0, codegen_1._)`{}`;
1342
- return errorObject(cxt, error5, errorPaths);
1342
+ return errorObject(cxt, error6, errorPaths);
1343
1343
  }
1344
- function errorObject(cxt, error5, errorPaths = {}) {
1344
+ function errorObject(cxt, error6, errorPaths = {}) {
1345
1345
  const { gen, it: it2 } = cxt;
1346
1346
  const keyValues = [
1347
1347
  errorInstancePath(it2, errorPaths),
1348
1348
  errorSchemaPath(cxt, errorPaths)
1349
1349
  ];
1350
- extraErrorProps(cxt, error5, keyValues);
1350
+ extraErrorProps(cxt, error6, keyValues);
1351
1351
  return gen.object(...keyValues);
1352
1352
  }
1353
1353
  function errorInstancePath({ errorPath }, { instancePath }) {
@@ -3259,8 +3259,8 @@ var require_utils = __commonJS({
3259
3259
  }
3260
3260
  return ind;
3261
3261
  }
3262
- function removeDotSegments(path21) {
3263
- let input = path21;
3262
+ function removeDotSegments(path23) {
3263
+ let input = path23;
3264
3264
  const output = [];
3265
3265
  let nextSlash = -1;
3266
3266
  let len = 0;
@@ -3349,9 +3349,9 @@ var require_utils = __commonJS({
3349
3349
  let output = "";
3350
3350
  for (let i = 0; i < input.length; i++) {
3351
3351
  if (input[i] === "%" && i + 2 < input.length) {
3352
- const hex2 = input.slice(i + 1, i + 3);
3353
- if (isHexPair(hex2)) {
3354
- const normalizedHex = hex2.toUpperCase();
3352
+ const hex3 = input.slice(i + 1, i + 3);
3353
+ if (isHexPair(hex3)) {
3354
+ const normalizedHex = hex3.toUpperCase();
3355
3355
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3356
3356
  if (decodeUnreserved && isUnreserved(decoded)) {
3357
3357
  output += decoded;
@@ -3371,9 +3371,9 @@ var require_utils = __commonJS({
3371
3371
  for (let i = 0; i < input.length; i++) {
3372
3372
  const ch = input[i];
3373
3373
  if (ch === "%" && i + 2 < input.length) {
3374
- const hex2 = input.slice(i + 1, i + 3);
3375
- if (isHexPair(hex2)) {
3376
- const normalizedHex = hex2.toUpperCase();
3374
+ const hex3 = input.slice(i + 1, i + 3);
3375
+ if (isHexPair(hex3)) {
3376
+ const normalizedHex = hex3.toUpperCase();
3377
3377
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3378
3378
  if (decoded !== "." && isUnreserved(decoded)) {
3379
3379
  output += decoded;
@@ -3413,9 +3413,9 @@ var require_utils = __commonJS({
3413
3413
  for (let i = 0; i < input.length; i++) {
3414
3414
  const ch = input[i];
3415
3415
  if (ch === "%" && i + 2 < input.length) {
3416
- const hex2 = input.slice(i + 1, i + 3);
3417
- if (isHexPair(hex2)) {
3418
- output += "%" + hex2.toUpperCase();
3416
+ const hex3 = input.slice(i + 1, i + 3);
3417
+ if (isHexPair(hex3)) {
3418
+ output += "%" + hex3.toUpperCase();
3419
3419
  i += 2;
3420
3420
  continue;
3421
3421
  }
@@ -3451,9 +3451,9 @@ var require_utils = __commonJS({
3451
3451
  for (let i = 0; i < input.length; i++) {
3452
3452
  const ch = input[i];
3453
3453
  if (ch === "%" && i + 2 < input.length) {
3454
- const hex2 = input.slice(i + 1, i + 3);
3455
- if (isHexPair(hex2)) {
3456
- output += "%" + hex2.toUpperCase();
3454
+ const hex3 = input.slice(i + 1, i + 3);
3455
+ if (isHexPair(hex3)) {
3456
+ output += "%" + hex3.toUpperCase();
3457
3457
  i += 2;
3458
3458
  continue;
3459
3459
  }
@@ -3498,9 +3498,9 @@ var require_utils = __commonJS({
3498
3498
  for (let i = 0; i < input.length; i++) {
3499
3499
  const ch = input[i];
3500
3500
  if (ch === "%" && i + 2 < input.length) {
3501
- const hex2 = input.slice(i + 1, i + 3);
3502
- if (isHexPair(hex2)) {
3503
- const normalizedHex = hex2.toUpperCase();
3501
+ const hex3 = input.slice(i + 1, i + 3);
3502
+ if (isHexPair(hex3)) {
3503
+ const normalizedHex = hex3.toUpperCase();
3504
3504
  const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3505
3505
  if (isUnreserved(decoded)) {
3506
3506
  output += decoded;
@@ -3538,9 +3538,9 @@ var require_utils = __commonJS({
3538
3538
  let output = "";
3539
3539
  for (let i = 0; i < input.length; i++) {
3540
3540
  if (input[i] === "%" && i + 2 < input.length) {
3541
- const hex2 = input.slice(i + 1, i + 3);
3542
- if (isHexPair(hex2)) {
3543
- output += "%" + hex2.toUpperCase();
3541
+ const hex3 = input.slice(i + 1, i + 3);
3542
+ if (isHexPair(hex3)) {
3543
+ output += "%" + hex3.toUpperCase();
3544
3544
  i += 2;
3545
3545
  continue;
3546
3546
  }
@@ -3669,8 +3669,8 @@ var require_schemes = __commonJS({
3669
3669
  }
3670
3670
  if (wsComponent.resourceName) {
3671
3671
  const queryIndex = wsComponent.resourceName.indexOf("?");
3672
- const path21 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3673
- wsComponent.path = path21 && path21 !== "/" ? path21 : void 0;
3672
+ const path23 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3673
+ wsComponent.path = path23 && path23 !== "/" ? path23 : void 0;
3674
3674
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3675
3675
  wsComponent.resourceName = void 0;
3676
3676
  }
@@ -5012,7 +5012,7 @@ var require_limitNumber = __commonJS({
5012
5012
  exclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
5013
5013
  exclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
5014
5014
  };
5015
- var error5 = {
5015
+ var error6 = {
5016
5016
  message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
5017
5017
  params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
5018
5018
  };
@@ -5021,7 +5021,7 @@ var require_limitNumber = __commonJS({
5021
5021
  type: "number",
5022
5022
  schemaType: "number",
5023
5023
  $data: true,
5024
- error: error5,
5024
+ error: error6,
5025
5025
  code(cxt) {
5026
5026
  const { keyword, data, schemaCode } = cxt;
5027
5027
  cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
@@ -5037,7 +5037,7 @@ var require_multipleOf = __commonJS({
5037
5037
  "use strict";
5038
5038
  Object.defineProperty(exports, "__esModule", { value: true });
5039
5039
  var codegen_1 = require_codegen();
5040
- var error5 = {
5040
+ var error6 = {
5041
5041
  message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
5042
5042
  params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
5043
5043
  };
@@ -5046,7 +5046,7 @@ var require_multipleOf = __commonJS({
5046
5046
  type: "number",
5047
5047
  schemaType: "number",
5048
5048
  $data: true,
5049
- error: error5,
5049
+ error: error6,
5050
5050
  code(cxt) {
5051
5051
  const { gen, data, schemaCode, it: it2 } = cxt;
5052
5052
  const prec = it2.opts.multipleOfPrecision;
@@ -5093,7 +5093,7 @@ var require_limitLength = __commonJS({
5093
5093
  var codegen_1 = require_codegen();
5094
5094
  var util_1 = require_util();
5095
5095
  var ucs2length_1 = require_ucs2length();
5096
- var error5 = {
5096
+ var error6 = {
5097
5097
  message({ keyword, schemaCode }) {
5098
5098
  const comp = keyword === "maxLength" ? "more" : "fewer";
5099
5099
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
@@ -5105,7 +5105,7 @@ var require_limitLength = __commonJS({
5105
5105
  type: "string",
5106
5106
  schemaType: "number",
5107
5107
  $data: true,
5108
- error: error5,
5108
+ error: error6,
5109
5109
  code(cxt) {
5110
5110
  const { keyword, data, schemaCode, it: it2 } = cxt;
5111
5111
  const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -5125,7 +5125,7 @@ var require_pattern = __commonJS({
5125
5125
  var code_1 = require_code2();
5126
5126
  var util_1 = require_util();
5127
5127
  var codegen_1 = require_codegen();
5128
- var error5 = {
5128
+ var error6 = {
5129
5129
  message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
5130
5130
  params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
5131
5131
  };
@@ -5134,7 +5134,7 @@ var require_pattern = __commonJS({
5134
5134
  type: "string",
5135
5135
  schemaType: "string",
5136
5136
  $data: true,
5137
- error: error5,
5137
+ error: error6,
5138
5138
  code(cxt) {
5139
5139
  const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
5140
5140
  const u2 = it2.opts.unicodeRegExp ? "u" : "";
@@ -5160,7 +5160,7 @@ var require_limitProperties = __commonJS({
5160
5160
  "use strict";
5161
5161
  Object.defineProperty(exports, "__esModule", { value: true });
5162
5162
  var codegen_1 = require_codegen();
5163
- var error5 = {
5163
+ var error6 = {
5164
5164
  message({ keyword, schemaCode }) {
5165
5165
  const comp = keyword === "maxProperties" ? "more" : "fewer";
5166
5166
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
@@ -5172,7 +5172,7 @@ var require_limitProperties = __commonJS({
5172
5172
  type: "object",
5173
5173
  schemaType: "number",
5174
5174
  $data: true,
5175
- error: error5,
5175
+ error: error6,
5176
5176
  code(cxt) {
5177
5177
  const { keyword, data, schemaCode } = cxt;
5178
5178
  const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -5191,7 +5191,7 @@ var require_required = __commonJS({
5191
5191
  var code_1 = require_code2();
5192
5192
  var codegen_1 = require_codegen();
5193
5193
  var util_1 = require_util();
5194
- var error5 = {
5194
+ var error6 = {
5195
5195
  message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
5196
5196
  params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
5197
5197
  };
@@ -5200,7 +5200,7 @@ var require_required = __commonJS({
5200
5200
  type: "object",
5201
5201
  schemaType: "array",
5202
5202
  $data: true,
5203
- error: error5,
5203
+ error: error6,
5204
5204
  code(cxt) {
5205
5205
  const { gen, schema, schemaCode, data, $data, it: it2 } = cxt;
5206
5206
  const { opts } = it2;
@@ -5271,7 +5271,7 @@ var require_limitItems = __commonJS({
5271
5271
  "use strict";
5272
5272
  Object.defineProperty(exports, "__esModule", { value: true });
5273
5273
  var codegen_1 = require_codegen();
5274
- var error5 = {
5274
+ var error6 = {
5275
5275
  message({ keyword, schemaCode }) {
5276
5276
  const comp = keyword === "maxItems" ? "more" : "fewer";
5277
5277
  return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
@@ -5283,7 +5283,7 @@ var require_limitItems = __commonJS({
5283
5283
  type: "array",
5284
5284
  schemaType: "number",
5285
5285
  $data: true,
5286
- error: error5,
5286
+ error: error6,
5287
5287
  code(cxt) {
5288
5288
  const { keyword, data, schemaCode } = cxt;
5289
5289
  const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
@@ -5314,7 +5314,7 @@ var require_uniqueItems = __commonJS({
5314
5314
  var codegen_1 = require_codegen();
5315
5315
  var util_1 = require_util();
5316
5316
  var equal_1 = require_equal();
5317
- var error5 = {
5317
+ var error6 = {
5318
5318
  message: ({ params: { i, j: j2 } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j2} and ${i} are identical)`,
5319
5319
  params: ({ params: { i, j: j2 } }) => (0, codegen_1._)`{i: ${i}, j: ${j2}}`
5320
5320
  };
@@ -5323,7 +5323,7 @@ var require_uniqueItems = __commonJS({
5323
5323
  type: "array",
5324
5324
  schemaType: "boolean",
5325
5325
  $data: true,
5326
- error: error5,
5326
+ error: error6,
5327
5327
  code(cxt) {
5328
5328
  const { gen, data, $data, schema, parentSchema, schemaCode, it: it2 } = cxt;
5329
5329
  if (!$data && !schema)
@@ -5380,14 +5380,14 @@ var require_const = __commonJS({
5380
5380
  var codegen_1 = require_codegen();
5381
5381
  var util_1 = require_util();
5382
5382
  var equal_1 = require_equal();
5383
- var error5 = {
5383
+ var error6 = {
5384
5384
  message: "must be equal to constant",
5385
5385
  params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
5386
5386
  };
5387
5387
  var def = {
5388
5388
  keyword: "const",
5389
5389
  $data: true,
5390
- error: error5,
5390
+ error: error6,
5391
5391
  code(cxt) {
5392
5392
  const { gen, data, $data, schemaCode, schema } = cxt;
5393
5393
  if ($data || schema && typeof schema == "object") {
@@ -5409,7 +5409,7 @@ var require_enum = __commonJS({
5409
5409
  var codegen_1 = require_codegen();
5410
5410
  var util_1 = require_util();
5411
5411
  var equal_1 = require_equal();
5412
- var error5 = {
5412
+ var error6 = {
5413
5413
  message: "must be equal to one of the allowed values",
5414
5414
  params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
5415
5415
  };
@@ -5417,7 +5417,7 @@ var require_enum = __commonJS({
5417
5417
  keyword: "enum",
5418
5418
  schemaType: "array",
5419
5419
  $data: true,
5420
- error: error5,
5420
+ error: error6,
5421
5421
  code(cxt) {
5422
5422
  const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
5423
5423
  if (!$data && schema.length === 0)
@@ -5496,7 +5496,7 @@ var require_additionalItems = __commonJS({
5496
5496
  exports.validateAdditionalItems = void 0;
5497
5497
  var codegen_1 = require_codegen();
5498
5498
  var util_1 = require_util();
5499
- var error5 = {
5499
+ var error6 = {
5500
5500
  message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
5501
5501
  params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
5502
5502
  };
@@ -5505,7 +5505,7 @@ var require_additionalItems = __commonJS({
5505
5505
  type: "array",
5506
5506
  schemaType: ["boolean", "object"],
5507
5507
  before: "uniqueItems",
5508
- error: error5,
5508
+ error: error6,
5509
5509
  code(cxt) {
5510
5510
  const { parentSchema, it: it2 } = cxt;
5511
5511
  const { items } = parentSchema;
@@ -5624,7 +5624,7 @@ var require_items2020 = __commonJS({
5624
5624
  var util_1 = require_util();
5625
5625
  var code_1 = require_code2();
5626
5626
  var additionalItems_1 = require_additionalItems();
5627
- var error5 = {
5627
+ var error6 = {
5628
5628
  message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
5629
5629
  params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
5630
5630
  };
@@ -5633,7 +5633,7 @@ var require_items2020 = __commonJS({
5633
5633
  type: "array",
5634
5634
  schemaType: ["object", "boolean"],
5635
5635
  before: "uniqueItems",
5636
- error: error5,
5636
+ error: error6,
5637
5637
  code(cxt) {
5638
5638
  const { schema, parentSchema, it: it2 } = cxt;
5639
5639
  const { prefixItems } = parentSchema;
@@ -5657,7 +5657,7 @@ var require_contains = __commonJS({
5657
5657
  Object.defineProperty(exports, "__esModule", { value: true });
5658
5658
  var codegen_1 = require_codegen();
5659
5659
  var util_1 = require_util();
5660
- var error5 = {
5660
+ var error6 = {
5661
5661
  message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
5662
5662
  params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
5663
5663
  };
@@ -5667,7 +5667,7 @@ var require_contains = __commonJS({
5667
5667
  schemaType: ["object", "boolean"],
5668
5668
  before: "uniqueItems",
5669
5669
  trackErrors: true,
5670
- error: error5,
5670
+ error: error6,
5671
5671
  code(cxt) {
5672
5672
  const { gen, schema, parentSchema, data, it: it2 } = cxt;
5673
5673
  let min;
@@ -5845,7 +5845,7 @@ var require_propertyNames = __commonJS({
5845
5845
  Object.defineProperty(exports, "__esModule", { value: true });
5846
5846
  var codegen_1 = require_codegen();
5847
5847
  var util_1 = require_util();
5848
- var error5 = {
5848
+ var error6 = {
5849
5849
  message: "property name must be valid",
5850
5850
  params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
5851
5851
  };
@@ -5853,7 +5853,7 @@ var require_propertyNames = __commonJS({
5853
5853
  keyword: "propertyNames",
5854
5854
  type: "object",
5855
5855
  schemaType: ["object", "boolean"],
5856
- error: error5,
5856
+ error: error6,
5857
5857
  code(cxt) {
5858
5858
  const { gen, schema, data, it: it2 } = cxt;
5859
5859
  if ((0, util_1.alwaysValidSchema)(it2, schema))
@@ -5890,7 +5890,7 @@ var require_additionalProperties = __commonJS({
5890
5890
  var codegen_1 = require_codegen();
5891
5891
  var names_1 = require_names();
5892
5892
  var util_1 = require_util();
5893
- var error5 = {
5893
+ var error6 = {
5894
5894
  message: "must NOT have additional properties",
5895
5895
  params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
5896
5896
  };
@@ -5900,7 +5900,7 @@ var require_additionalProperties = __commonJS({
5900
5900
  schemaType: ["boolean", "object"],
5901
5901
  allowUndefined: true,
5902
5902
  trackErrors: true,
5903
- error: error5,
5903
+ error: error6,
5904
5904
  code(cxt) {
5905
5905
  const { gen, schema, parentSchema, data, errsCount, it: it2 } = cxt;
5906
5906
  if (!errsCount)
@@ -6174,7 +6174,7 @@ var require_oneOf = __commonJS({
6174
6174
  Object.defineProperty(exports, "__esModule", { value: true });
6175
6175
  var codegen_1 = require_codegen();
6176
6176
  var util_1 = require_util();
6177
- var error5 = {
6177
+ var error6 = {
6178
6178
  message: "must match exactly one schema in oneOf",
6179
6179
  params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
6180
6180
  };
@@ -6182,7 +6182,7 @@ var require_oneOf = __commonJS({
6182
6182
  keyword: "oneOf",
6183
6183
  schemaType: "array",
6184
6184
  trackErrors: true,
6185
- error: error5,
6185
+ error: error6,
6186
6186
  code(cxt) {
6187
6187
  const { gen, schema, parentSchema, it: it2 } = cxt;
6188
6188
  if (!Array.isArray(schema))
@@ -6259,7 +6259,7 @@ var require_if = __commonJS({
6259
6259
  Object.defineProperty(exports, "__esModule", { value: true });
6260
6260
  var codegen_1 = require_codegen();
6261
6261
  var util_1 = require_util();
6262
- var error5 = {
6262
+ var error6 = {
6263
6263
  message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
6264
6264
  params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
6265
6265
  };
@@ -6267,7 +6267,7 @@ var require_if = __commonJS({
6267
6267
  keyword: "if",
6268
6268
  schemaType: ["object", "boolean"],
6269
6269
  trackErrors: true,
6270
- error: error5,
6270
+ error: error6,
6271
6271
  code(cxt) {
6272
6272
  const { gen, parentSchema, it: it2 } = cxt;
6273
6273
  if (parentSchema.then === void 0 && parentSchema.else === void 0) {
@@ -6393,7 +6393,7 @@ var require_format = __commonJS({
6393
6393
  "use strict";
6394
6394
  Object.defineProperty(exports, "__esModule", { value: true });
6395
6395
  var codegen_1 = require_codegen();
6396
- var error5 = {
6396
+ var error6 = {
6397
6397
  message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
6398
6398
  params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
6399
6399
  };
@@ -6402,7 +6402,7 @@ var require_format = __commonJS({
6402
6402
  type: ["number", "string"],
6403
6403
  schemaType: "string",
6404
6404
  $data: true,
6405
- error: error5,
6405
+ error: error6,
6406
6406
  code(cxt, ruleType) {
6407
6407
  const { gen, data, $data, schema, schemaCode, it: it2 } = cxt;
6408
6408
  const { opts, errSchemaPath, schemaEnv, self } = it2;
@@ -6557,7 +6557,7 @@ var require_discriminator = __commonJS({
6557
6557
  var compile_1 = require_compile();
6558
6558
  var ref_error_1 = require_ref_error();
6559
6559
  var util_1 = require_util();
6560
- var error5 = {
6560
+ var error6 = {
6561
6561
  message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
6562
6562
  params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
6563
6563
  };
@@ -6565,7 +6565,7 @@ var require_discriminator = __commonJS({
6565
6565
  keyword: "discriminator",
6566
6566
  type: "object",
6567
6567
  schemaType: "object",
6568
- error: error5,
6568
+ error: error6,
6569
6569
  code(cxt) {
6570
6570
  const { gen, data, schema, parentSchema, it: it2 } = cxt;
6571
6571
  const { oneOf } = parentSchema;
@@ -7097,7 +7097,7 @@ var require_limit = __commonJS({
7097
7097
  formatExclusiveMaximum: { okStr: "<", ok: ops.LT, fail: ops.GTE },
7098
7098
  formatExclusiveMinimum: { okStr: ">", ok: ops.GT, fail: ops.LTE }
7099
7099
  };
7100
- var error5 = {
7100
+ var error6 = {
7101
7101
  message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
7102
7102
  params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
7103
7103
  };
@@ -7106,7 +7106,7 @@ var require_limit = __commonJS({
7106
7106
  type: "string",
7107
7107
  schemaType: "string",
7108
7108
  $data: true,
7109
- error: error5,
7109
+ error: error6,
7110
7110
  code(cxt) {
7111
7111
  const { gen, data, schemaCode, keyword, it: it2 } = cxt;
7112
7112
  const { opts, self } = it2;
@@ -7351,9 +7351,9 @@ var secure = async (file, directory3 = false) => {
7351
7351
  let info5;
7352
7352
  try {
7353
7353
  info5 = await lstat(file);
7354
- } catch (error5) {
7355
- if (error5.code === "ENOENT") return null;
7356
- throw error5;
7354
+ } catch (error6) {
7355
+ if (error6.code === "ENOENT") return null;
7356
+ throw error6;
7357
7357
  }
7358
7358
  if (info5.isSymbolicLink() || !(directory3 ? info5.isDirectory() : info5.isFile()) || info5.uid !== process.getuid?.() || (info5.mode & 63) !== 0)
7359
7359
  throw new CreationClientError("credentials.private_owner_required");
@@ -7386,8 +7386,8 @@ async function writeCredentials(value2, file = credentialsPath()) {
7386
7386
  });
7387
7387
  await rename(temporary, file);
7388
7388
  } finally {
7389
- await unlink(temporary).catch((error5) => {
7390
- if (error5.code !== "ENOENT") throw error5;
7389
+ await unlink(temporary).catch((error6) => {
7390
+ if (error6.code !== "ENOENT") throw error6;
7391
7391
  });
7392
7392
  }
7393
7393
  }
@@ -7420,8 +7420,8 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
7420
7420
  let handle;
7421
7421
  try {
7422
7422
  handle = await open(selected, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
7423
- } catch (error5) {
7424
- throw failure(error5.code === "ELOOP" ? "file_not_regular" : error5.code === "EACCES" || error5.code === "EPERM" ? "file_read_denied" : "file_not_on_bridge_host");
7423
+ } catch (error6) {
7424
+ throw failure(error6.code === "ELOOP" ? "file_not_regular" : error6.code === "EACCES" || error6.code === "EPERM" ? "file_read_denied" : "file_not_on_bridge_host");
7425
7425
  }
7426
7426
  const abort = new AbortController(), streams = /* @__PURE__ */ new Map(), reads = /* @__PURE__ */ new Set();
7427
7427
  let closing = false, closed = false, original, closePromise;
@@ -7446,8 +7446,8 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
7446
7446
  try {
7447
7447
  const [current, named] = await Promise.all([handle.stat({ bigint: true }), lstat2(selected, { bigint: true })]);
7448
7448
  if (!current.isFile() || !named.isFile() || !equal(original, fingerprint(current)) || !equal(original, fingerprint(named))) throw failure("file_changed");
7449
- } catch (error5) {
7450
- if (error5 instanceof CreationClientError) throw error5;
7449
+ } catch (error6) {
7450
+ if (error6 instanceof CreationClientError) throw error6;
7451
7451
  throw failure("file_changed");
7452
7452
  }
7453
7453
  };
@@ -7466,17 +7466,17 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
7466
7466
  if (stat3.size <= 0n || stat3.size > BigInt(maxBytes2)) throw failure("file_size_limit");
7467
7467
  original = fingerprint(stat3);
7468
7468
  await assertUnchanged();
7469
- const hash7 = createHash("sha256"), buffer = Buffer.allocUnsafe(LOCAL_UPLOAD_READ_BYTES);
7469
+ const hash8 = createHash("sha256"), buffer = Buffer.allocUnsafe(LOCAL_UPLOAD_READ_BYTES);
7470
7470
  for (let position = 0; position < original.sizeBytes; ) {
7471
7471
  checkSignal();
7472
7472
  const length = Math.min(buffer.length, original.sizeBytes - position);
7473
7473
  const { bytesRead } = await read2(buffer, 0, length, position);
7474
7474
  if (bytesRead === 0) throw failure("file_changed");
7475
- hash7.update(buffer.subarray(0, bytesRead));
7475
+ hash8.update(buffer.subarray(0, bytesRead));
7476
7476
  position += bytesRead;
7477
7477
  }
7478
7478
  await assertUnchanged();
7479
- const checksum = "sha256:" + hash7.digest("hex");
7479
+ const checksum = "sha256:" + hash8.digest("hex");
7480
7480
  return {
7481
7481
  name,
7482
7482
  sizeBytes: original.sizeBytes,
@@ -7509,9 +7509,9 @@ async function openLocalUploadFile(selectedPath, { maxBytes: maxBytes2 = LOCAL_U
7509
7509
  return stream;
7510
7510
  }
7511
7511
  };
7512
- } catch (error5) {
7512
+ } catch (error6) {
7513
7513
  await close();
7514
- if (error5 instanceof CreationClientError) throw error5;
7514
+ if (error6 instanceof CreationClientError) throw error6;
7515
7515
  throw failure("file_read_failed");
7516
7516
  }
7517
7517
  }
@@ -7547,13 +7547,13 @@ var causes = /* @__PURE__ */ new Set([
7547
7547
  "validation_refused",
7548
7548
  "stream_unconfirmed"
7549
7549
  ]);
7550
- var localCause = (error5) => error5 instanceof CreationClientError ? {
7550
+ var localCause = (error6) => error6 instanceof CreationClientError ? {
7551
7551
  "creation.local_upload.file_read_failed": "local_read_failed",
7552
7552
  "creation.local_upload.file_changed": "local_file_changed",
7553
7553
  "creation.local_upload.file_read_cancelled": "local_read_cancelled"
7554
- }[error5.message] : void 0;
7555
- var networkCause = (error5) => {
7556
- const code = typeof error5?.cause?.code === "string" ? error5.cause.code : error5?.code;
7554
+ }[error6.message] : void 0;
7555
+ var networkCause = (error6) => {
7556
+ const code = typeof error6?.cause?.code === "string" ? error6.cause.code : error6?.code;
7557
7557
  if (["ENOTFOUND", "EAI_AGAIN"].includes(code)) return "dns_failure";
7558
7558
  if (code === "ECONNREFUSED") return "connection_refused";
7559
7559
  if (["ECONNRESET", "EPIPE", "UND_ERR_SOCKET"].includes(code)) return "connection_interrupted";
@@ -7624,9 +7624,9 @@ async function transferGrantedPart(file, authorization, grant, {
7624
7624
  report("checking_file", { bytesRead: 0 });
7625
7625
  try {
7626
7626
  await file.assertUnchanged();
7627
- } catch (error5) {
7628
- report("checking_file", { causeCode: localCause(error5) ?? "local_read_failed" });
7629
- throw error5;
7627
+ } catch (error6) {
7628
+ report("checking_file", { causeCode: localCause(error6) ?? "local_read_failed" });
7629
+ throw error6;
7630
7630
  }
7631
7631
  if (signal?.aborted) fail("transfer_cancelled");
7632
7632
  const controller = new AbortController();
@@ -7665,12 +7665,12 @@ async function transferGrantedPart(file, authorization, grant, {
7665
7665
  yield chunk;
7666
7666
  }
7667
7667
  report("awaiting_response", { bytesRead });
7668
- } catch (error5) {
7668
+ } catch (error6) {
7669
7669
  if (!reason && !closing) {
7670
7670
  streamFailure = true;
7671
- report("streaming", { bytesRead, causeCode: localCause(error5) ?? (["EIO", "EACCES", "EPERM", "ESTALE", "EBADF"].includes(error5?.code) ? "local_read_failed" : "stream_unconfirmed") });
7671
+ report("streaming", { bytesRead, causeCode: localCause(error6) ?? (["EIO", "EACCES", "EPERM", "ESTALE", "EBADF"].includes(error6?.code) ? "local_read_failed" : "stream_unconfirmed") });
7672
7672
  }
7673
- throw error5;
7673
+ throw error6;
7674
7674
  }
7675
7675
  }
7676
7676
  try {
@@ -7698,9 +7698,9 @@ async function transferGrantedPart(file, authorization, grant, {
7698
7698
  report("checking_file", { bytesRead });
7699
7699
  try {
7700
7700
  await file.assertUnchanged();
7701
- } catch (error5) {
7702
- report("checking_file", { bytesRead, causeCode: localCause(error5) ?? "local_read_failed" });
7703
- throw error5;
7701
+ } catch (error6) {
7702
+ report("checking_file", { bytesRead, causeCode: localCause(error6) ?? "local_read_failed" });
7703
+ throw error6;
7704
7704
  }
7705
7705
  report("reading_receipt", { bytesRead });
7706
7706
  const etag = response.headers.get("etag");
@@ -7709,13 +7709,13 @@ async function transferGrantedPart(file, authorization, grant, {
7709
7709
  fail("part_receipt_unconfirmed");
7710
7710
  }
7711
7711
  return { partNumber: grant.partNumber, etag, sizeBytes };
7712
- } catch (error5) {
7712
+ } catch (error6) {
7713
7713
  if (reason) fail(reason);
7714
- if (error5 instanceof CreationClientError) {
7715
- if (localCause(error5)) onTransferState({ causeCode: localCause(error5) });
7716
- throw error5;
7714
+ if (error6 instanceof CreationClientError) {
7715
+ if (localCause(error6)) onTransferState({ causeCode: localCause(error6) });
7716
+ throw error6;
7717
7717
  }
7718
- if (!streamFailure) onTransferState({ causeCode: networkCause(error5) });
7718
+ if (!streamFailure) onTransferState({ causeCode: networkCause(error6) });
7719
7719
  fail("part_transfer_unconfirmed");
7720
7720
  } finally {
7721
7721
  closing = true;
@@ -7733,8 +7733,8 @@ async function transferGrantedPart(file, authorization, grant, {
7733
7733
  }
7734
7734
  var effects = /* @__PURE__ */ new WeakMap();
7735
7735
  var diagnostics = /* @__PURE__ */ new WeakMap();
7736
- var readPartTransferEffect = (error5) => error5 && typeof error5 === "object" ? effects.get(error5) : void 0;
7737
- var readPartTransferDiagnostic = (error5) => error5 && typeof error5 === "object" ? diagnostics.get(error5) : void 0;
7736
+ var readPartTransferEffect = (error6) => error6 && typeof error6 === "object" ? effects.get(error6) : void 0;
7737
+ var readPartTransferDiagnostic = (error6) => error6 && typeof error6 === "object" ? diagnostics.get(error6) : void 0;
7738
7738
  async function uploadGrantedPart(file, authorization, grant, options = {}) {
7739
7739
  let dispatched = false, state = { stage: "validating", bytesRead: 0 };
7740
7740
  const monotonic = options.monotonicNow ?? (() => performance2.now()), started = monotonic();
@@ -7745,15 +7745,15 @@ async function uploadGrantedPart(file, authorization, grant, options = {}) {
7745
7745
  dispatched = true;
7746
7746
  return (options.fetch ?? globalThis.fetch)(...args2);
7747
7747
  } });
7748
- } catch (error5) {
7749
- if (error5 && typeof error5 === "object") effects.set(error5, dispatched ? "unknown" : "not_dispatched");
7750
- if (error5 && typeof error5 === "object") diagnostics.set(error5, safePartTransferDiagnostic({
7748
+ } catch (error6) {
7749
+ if (error6 && typeof error6 === "object") effects.set(error6, dispatched ? "unknown" : "not_dispatched");
7750
+ if (error6 && typeof error6 === "object") diagnostics.set(error6, safePartTransferDiagnostic({
7751
7751
  ...state,
7752
7752
  requestId: options.requestId,
7753
- causeCode: state.causeCode ?? (!dispatched && state.stage === "validating" ? "validation_refused" : networkCause(error5)),
7753
+ causeCode: state.causeCode ?? (!dispatched && state.stage === "validating" ? "validation_refused" : networkCause(error6)),
7754
7754
  elapsedMs: Math.max(0, Math.floor(monotonic() - started))
7755
7755
  }));
7756
- throw error5;
7756
+ throw error6;
7757
7757
  }
7758
7758
  }
7759
7759
 
@@ -7979,7 +7979,7 @@ var digest = (value2) => createHash2("sha256").update(JSON.stringify(value2)).di
7979
7979
  var fail3 = (code) => {
7980
7980
  throw new CreationClientError("creation.local_upload." + code);
7981
7981
  };
7982
- var knownError = (error5) => error5 instanceof CreationClientError && /^creation\.[a-z0-9_.:-]{1,180}$/.test(error5.message) ? error5.message : "creation.local_upload.control_unconfirmed";
7982
+ var knownError = (error6) => error6 instanceof CreationClientError && /^creation\.[a-z0-9_.:-]{1,180}$/.test(error6.message) ? error6.message : "creation.local_upload.control_unconfirmed";
7983
7983
  var createRefusal = (code) => /^creation\.direct_object_upload\.(?:size_limit_exceeded|pending_bytes_quota_exceeded|concurrent_multipart_quota_exceeded|daily_bytes_quota_exceeded|durable_storage_quota_exceeded|capacity_unavailable|admission_facts_unavailable)$/.test(code);
7984
7984
  var typeByExtension = {
7985
7985
  ".png": ["image", "image/png"],
@@ -8214,14 +8214,14 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8214
8214
  job.progress = progress.bytesRead;
8215
8215
  }
8216
8216
  });
8217
- } catch (error5) {
8218
- const diagnostic = readPartTransferDiagnostic(error5);
8217
+ } catch (error6) {
8218
+ const diagnostic = readPartTransferDiagnostic(error6);
8219
8219
  if (diagnostic) state.lastTransferDiagnostic = diagnostic;
8220
- if (readPartTransferEffect(error5) === "not_dispatched") {
8220
+ if (readPartTransferEffect(error6) === "not_dispatched") {
8221
8221
  delete state.pendingPart;
8222
8222
  await save();
8223
8223
  }
8224
- throw error5;
8224
+ throw error6;
8225
8225
  }
8226
8226
  state.parts.push(part);
8227
8227
  state.parts.sort((a, b2) => a.partNumber - b2.partNumber);
@@ -8348,11 +8348,11 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8348
8348
  let created;
8349
8349
  try {
8350
8350
  created = await rpc(send, { action: "create", request: state.request });
8351
- } catch (error5) {
8352
- const code = knownError(error5);
8351
+ } catch (error6) {
8352
+ const code = knownError(error6);
8353
8353
  state.createDisposition = createRefusal(code) ? "rejected" : "unconfirmed";
8354
8354
  if (createRefusal(code)) state.createErrorCode = code;
8355
- throw error5;
8355
+ throw error6;
8356
8356
  }
8357
8357
  authorization = created.authorization;
8358
8358
  const session = authorization?.session;
@@ -8370,9 +8370,9 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8370
8370
  job = { state, file, abort, progress: 0, save: () => persistence.write(key, state) };
8371
8371
  jobs.set(key, job);
8372
8372
  file = void 0;
8373
- job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2, options) => send(transfer2, { signal: abort.signal, ...options }), binding)).catch(async (error5) => {
8373
+ job.done = Promise.resolve().then(() => transfer(job, authorization, (transfer2, options) => send(transfer2, { signal: abort.signal, ...options }), binding)).catch(async (error6) => {
8374
8374
  state.phase = "paused";
8375
- state.errorCode = abort.signal.aborted ? "creation.local_upload.transfer_cancelled" : knownError(error5);
8375
+ state.errorCode = abort.signal.aborted ? "creation.local_upload.transfer_cancelled" : knownError(error6);
8376
8376
  await job.save();
8377
8377
  }).finally(async () => {
8378
8378
  try {
@@ -8388,13 +8388,13 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8388
8388
  job.done.catch(() => {
8389
8389
  });
8390
8390
  return view(state, job);
8391
- } catch (error5) {
8391
+ } catch (error6) {
8392
8392
  if (state) {
8393
8393
  state.phase = state.createDisposition === "rejected" && !state.uploadId ? "create_rejected" : "paused";
8394
- state.errorCode = knownError(error5);
8394
+ state.errorCode = knownError(error6);
8395
8395
  await persistence.write(key, state);
8396
8396
  }
8397
- throw error5;
8397
+ throw error6;
8398
8398
  } finally {
8399
8399
  if (!jobs.has(key)) {
8400
8400
  await file?.close();
@@ -8429,11 +8429,11 @@ function createLocalUploadManager({ stateRoot, fetch: fetch2 = globalThis.fetch,
8429
8429
  }
8430
8430
 
8431
8431
  // lib/version.mjs
8432
- var CLIENT_VERSION = "0.3.12";
8432
+ var CLIENT_VERSION = "0.3.14";
8433
8433
  var CLIENT_PROTOCOL = "creation-client/v1";
8434
8434
 
8435
8435
  // lib/cli.mjs
8436
- import { randomBytes as randomBytes8 } from "node:crypto";
8436
+ import { randomBytes as randomBytes10 } from "node:crypto";
8437
8437
  import { spawn as spawn2 } from "node:child_process";
8438
8438
 
8439
8439
  // node_modules/zod/v4/core/util.js
@@ -8579,9 +8579,9 @@ function floatSafeRemainder(val, step) {
8579
8579
  return ratio - roundedRatio;
8580
8580
  }
8581
8581
  var EVALUATING = /* @__PURE__ */ Symbol("evaluating");
8582
- function defineLazy(object3, key, getter) {
8582
+ function defineLazy(object4, key, getter) {
8583
8583
  let value2 = void 0;
8584
- Object.defineProperty(object3, key, {
8584
+ Object.defineProperty(object4, key, {
8585
8585
  get() {
8586
8586
  if (value2 === EVALUATING) {
8587
8587
  return void 0;
@@ -8593,7 +8593,7 @@ function defineLazy(object3, key, getter) {
8593
8593
  return value2;
8594
8594
  },
8595
8595
  set(v2) {
8596
- Object.defineProperty(object3, key, {
8596
+ Object.defineProperty(object4, key, {
8597
8597
  value: v2
8598
8598
  // configurable: true,
8599
8599
  });
@@ -8673,10 +8673,10 @@ function mergeDefs(...defs) {
8673
8673
  function cloneDef(schema) {
8674
8674
  return mergeDefs(schema._zod.def);
8675
8675
  }
8676
- function getElementAtPath(obj, path21) {
8677
- if (!path21)
8676
+ function getElementAtPath(obj, path23) {
8677
+ if (!path23)
8678
8678
  return obj;
8679
- return path21.reduce((acc, key) => acc?.[key], obj);
8679
+ return path23.reduce((acc, key) => acc?.[key], obj);
8680
8680
  }
8681
8681
  function promiseAllObject(promisesObj) {
8682
8682
  const keys = Object.keys(promisesObj);
@@ -9016,11 +9016,11 @@ function explicitlyAborted(x, startIndex = 0) {
9016
9016
  }
9017
9017
  return false;
9018
9018
  }
9019
- function prefixIssues(path21, issues) {
9019
+ function prefixIssues(path23, issues) {
9020
9020
  return issues.map((iss) => {
9021
9021
  var _a3;
9022
9022
  (_a3 = iss).path ?? (_a3.path = []);
9023
- iss.path.unshift(path21);
9023
+ iss.path.unshift(path23);
9024
9024
  return iss;
9025
9025
  });
9026
9026
  }
@@ -9160,8 +9160,8 @@ function base64urlToUint8Array(base64url2) {
9160
9160
  function uint8ArrayToBase64url(bytes2) {
9161
9161
  return uint8ArrayToBase64(bytes2).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
9162
9162
  }
9163
- function hexToUint8Array(hex2) {
9164
- const cleanHex = hex2.replace(/^0x/, "");
9163
+ function hexToUint8Array(hex3) {
9164
+ const cleanHex = hex3.replace(/^0x/, "");
9165
9165
  if (cleanHex.length % 2 !== 0) {
9166
9166
  throw new Error("Invalid hex string length");
9167
9167
  }
@@ -9467,10 +9467,10 @@ function node(obj, key, make) {
9467
9467
  }
9468
9468
  return obj[key];
9469
9469
  }
9470
- function flattenError(error5, mapper = (issue2) => issue2.message) {
9470
+ function flattenError(error6, mapper = (issue2) => issue2.message) {
9471
9471
  const fieldErrors = {};
9472
9472
  const formErrors = [];
9473
- for (const sub of error5.issues) {
9473
+ for (const sub of error6.issues) {
9474
9474
  if (sub.path.length > 0) {
9475
9475
  node(fieldErrors, sub.path[0], () => []).push(mapper(sub));
9476
9476
  } else {
@@ -9479,18 +9479,18 @@ function flattenError(error5, mapper = (issue2) => issue2.message) {
9479
9479
  }
9480
9480
  return { formErrors, fieldErrors };
9481
9481
  }
9482
- function formatError(error5, mapper = (issue2) => issue2.message) {
9482
+ function formatError(error6, mapper = (issue2) => issue2.message) {
9483
9483
  const fieldErrors = { _errors: [] };
9484
- const processError = (error6, path21 = []) => {
9485
- for (const issue2 of error6.issues) {
9484
+ const processError = (error7, path23 = []) => {
9485
+ for (const issue2 of error7.issues) {
9486
9486
  if (issue2.code === "invalid_union" && issue2.errors.length) {
9487
- issue2.errors.map((issues) => processError({ issues }, [...path21, ...issue2.path]));
9487
+ issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
9488
9488
  } else if (issue2.code === "invalid_key") {
9489
- processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
9489
+ processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
9490
9490
  } else if (issue2.code === "invalid_element") {
9491
- processError({ issues: issue2.issues }, [...path21, ...issue2.path]);
9491
+ processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
9492
9492
  } else {
9493
- const fullpath = [...path21, ...issue2.path];
9493
+ const fullpath = [...path23, ...issue2.path];
9494
9494
  if (fullpath.length === 0) {
9495
9495
  fieldErrors._errors.push(mapper(issue2));
9496
9496
  } else {
@@ -9524,7 +9524,7 @@ function formatError(error5, mapper = (issue2) => issue2.message) {
9524
9524
  }
9525
9525
  }
9526
9526
  };
9527
- processError(error5);
9527
+ processError(error6);
9528
9528
  return fieldErrors;
9529
9529
  }
9530
9530
 
@@ -9573,19 +9573,19 @@ var _safeParse = (_Err) => (schema, value2, _ctx) => {
9573
9573
  };
9574
9574
  var safeParse = /* @__PURE__ */ _safeParse($ZodRealError);
9575
9575
  function failure2(Err, issues, ctx) {
9576
- let error5;
9576
+ let error6;
9577
9577
  return {
9578
9578
  success: false,
9579
9579
  get error() {
9580
- if (!error5) {
9581
- error5 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
9580
+ if (!error6) {
9581
+ error6 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config())));
9582
9582
  issues = void 0;
9583
9583
  ctx = void 0;
9584
9584
  }
9585
- return error5;
9585
+ return error6;
9586
9586
  },
9587
9587
  set error(e) {
9588
- error5 = e;
9588
+ error6 = e;
9589
9589
  issues = void 0;
9590
9590
  ctx = void 0;
9591
9591
  }
@@ -13073,8 +13073,8 @@ function foldObjects(members2) {
13073
13073
  }
13074
13074
  const properties = {};
13075
13075
  const required2 = /* @__PURE__ */ new Set();
13076
- for (const object3 of objects) {
13077
- for (const key in object3.properties) {
13076
+ for (const object4 of objects) {
13077
+ for (const key in object4.properties) {
13078
13078
  if (Object.prototype.hasOwnProperty.call(properties, key))
13079
13079
  continue;
13080
13080
  const parts = [];
@@ -13088,18 +13088,18 @@ function foldObjects(members2) {
13088
13088
  const merged = parts.length === 1 ? parts[0] : foldObjects(parts) ?? { allOf: parts };
13089
13089
  assignProp(properties, key, merged);
13090
13090
  }
13091
- for (const key of object3.required ?? [])
13091
+ for (const key of object4.required ?? [])
13092
13092
  required2.add(key);
13093
13093
  }
13094
13094
  const folded = { type: "object", properties };
13095
13095
  if (required2.size)
13096
13096
  folded.required = [...required2];
13097
- if (objects.every((object3) => object3.additionalProperties === false)) {
13097
+ if (objects.every((object4) => object4.additionalProperties === false)) {
13098
13098
  folded.additionalProperties = false;
13099
13099
  } else {
13100
13100
  const constraints = [];
13101
- for (const object3 of objects) {
13102
- const constraint = undeclaredConstraint(object3);
13101
+ for (const object4 of objects) {
13102
+ const constraint = undeclaredConstraint(object4);
13103
13103
  if (constraint && !constraints.some((seen) => JSON.stringify(seen) === JSON.stringify(constraint)))
13104
13104
  constraints.push(constraint);
13105
13105
  }
@@ -16726,8 +16726,8 @@ var Protocol = class {
16726
16726
  resolver(message);
16727
16727
  } else {
16728
16728
  const errorMessage = message;
16729
- const error5 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
16730
- resolver(error5);
16729
+ const error6 = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
16730
+ resolver(error6);
16731
16731
  }
16732
16732
  } else {
16733
16733
  const messageType = queuedMessage.type === "response" ? "Response" : "Error";
@@ -16771,8 +16771,8 @@ var Protocol = class {
16771
16771
  nextCursor,
16772
16772
  _meta: {}
16773
16773
  };
16774
- } catch (error5) {
16775
- throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error5 instanceof Error ? error5.message : String(error5)}`);
16774
+ } catch (error6) {
16775
+ throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error6 instanceof Error ? error6.message : String(error6)}`);
16776
16776
  }
16777
16777
  });
16778
16778
  this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
@@ -16794,11 +16794,11 @@ var Protocol = class {
16794
16794
  _meta: {},
16795
16795
  ...cancelledTask
16796
16796
  };
16797
- } catch (error5) {
16798
- if (error5 instanceof McpError) {
16799
- throw error5;
16797
+ } catch (error6) {
16798
+ if (error6 instanceof McpError) {
16799
+ throw error6;
16800
16800
  }
16801
- throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error5 instanceof Error ? error5.message : String(error5)}`);
16801
+ throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error6 instanceof Error ? error6.message : String(error6)}`);
16802
16802
  }
16803
16803
  });
16804
16804
  }
@@ -16859,9 +16859,9 @@ var Protocol = class {
16859
16859
  this._onclose();
16860
16860
  };
16861
16861
  const _onerror = this.transport?.onerror;
16862
- this._transport.onerror = (error5) => {
16863
- _onerror?.(error5);
16864
- this._onerror(error5);
16862
+ this._transport.onerror = (error6) => {
16863
+ _onerror?.(error6);
16864
+ this._onerror(error6);
16865
16865
  };
16866
16866
  const _onmessage = this._transport?.onmessage;
16867
16867
  this._transport.onmessage = (message, extra) => {
@@ -16892,35 +16892,35 @@ var Protocol = class {
16892
16892
  controller.abort();
16893
16893
  }
16894
16894
  this._requestHandlerAbortControllers.clear();
16895
- const error5 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
16895
+ const error6 = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
16896
16896
  this._transport = void 0;
16897
16897
  this.onclose?.();
16898
16898
  for (const handler of responseHandlers.values()) {
16899
- handler(error5);
16899
+ handler(error6);
16900
16900
  }
16901
16901
  }
16902
- _onerror(error5) {
16903
- this.onerror?.(error5);
16902
+ _onerror(error6) {
16903
+ this.onerror?.(error6);
16904
16904
  }
16905
16905
  _onnotification(notification) {
16906
16906
  const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
16907
16907
  if (handler === void 0) {
16908
16908
  return;
16909
16909
  }
16910
- Promise.resolve().then(() => handler(notification)).catch((error5) => this._onerror(new Error(`Uncaught error in notification handler: ${error5}`)));
16910
+ Promise.resolve().then(() => handler(notification)).catch((error6) => this._onerror(new Error(`Uncaught error in notification handler: ${error6}`)));
16911
16911
  }
16912
16912
  _onrequest(request, extra) {
16913
16913
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
16914
16914
  const capturedTransport = this._transport;
16915
16915
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
16916
- const sessionId = capturedTransport?.sessionId;
16916
+ const sessionId2 = capturedTransport?.sessionId;
16917
16917
  const store = this._taskStore;
16918
16918
  let relatedTaskFound = true;
16919
16919
  let relatedTaskLookup;
16920
- if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
16920
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId2 !== void 0) {
16921
16921
  relatedTaskFound = false;
16922
16922
  relatedTaskLookup = (async () => {
16923
- if (!await store.getTask(relatedTaskId, sessionId)) {
16923
+ if (!await store.getTask(relatedTaskId, sessionId2)) {
16924
16924
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
16925
16925
  }
16926
16926
  relatedTaskFound = true;
@@ -16937,15 +16937,15 @@ var Protocol = class {
16937
16937
  };
16938
16938
  if (relatedTaskId && relatedTaskLookup) {
16939
16939
  const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
16940
- relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error5) => this._onerror(new Error(`Failed to send an error response: ${error5}`)));
16940
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId2), () => capturedTransport?.send(errorResponse)).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
16941
16941
  } else if (relatedTaskId && this._taskMessageQueue) {
16942
16942
  this._enqueueTaskMessage(relatedTaskId, {
16943
16943
  type: "error",
16944
16944
  message: errorResponse,
16945
16945
  timestamp: Date.now()
16946
- }, capturedTransport?.sessionId).catch((error5) => this._onerror(new Error(`Failed to enqueue error response: ${error5}`)));
16946
+ }, capturedTransport?.sessionId).catch((error6) => this._onerror(new Error(`Failed to enqueue error response: ${error6}`)));
16947
16947
  } else {
16948
- capturedTransport?.send(errorResponse).catch((error5) => this._onerror(new Error(`Failed to send an error response: ${error5}`)));
16948
+ capturedTransport?.send(errorResponse).catch((error6) => this._onerror(new Error(`Failed to send an error response: ${error6}`)));
16949
16949
  }
16950
16950
  return;
16951
16951
  }
@@ -17014,7 +17014,7 @@ var Protocol = class {
17014
17014
  } else {
17015
17015
  await capturedTransport?.send(response);
17016
17016
  }
17017
- }, async (error5) => {
17017
+ }, async (error6) => {
17018
17018
  if (abortController.signal.aborted) {
17019
17019
  return;
17020
17020
  }
@@ -17022,9 +17022,9 @@ var Protocol = class {
17022
17022
  jsonrpc: "2.0",
17023
17023
  id: request.id,
17024
17024
  error: {
17025
- code: Number.isSafeInteger(error5["code"]) ? error5["code"] : ErrorCode.InternalError,
17026
- message: error5.message ?? "Internal error",
17027
- ...error5["data"] !== void 0 && { data: error5["data"] }
17025
+ code: Number.isSafeInteger(error6["code"]) ? error6["code"] : ErrorCode.InternalError,
17026
+ message: error6.message ?? "Internal error",
17027
+ ...error6["data"] !== void 0 && { data: error6["data"] }
17028
17028
  }
17029
17029
  };
17030
17030
  if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
@@ -17036,7 +17036,7 @@ var Protocol = class {
17036
17036
  } else {
17037
17037
  await capturedTransport?.send(errorResponse);
17038
17038
  }
17039
- }).catch((error5) => this._onerror(new Error(`Failed to send response: ${error5}`))).finally(() => {
17039
+ }).catch((error6) => this._onerror(new Error(`Failed to send response: ${error6}`))).finally(() => {
17040
17040
  if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
17041
17041
  this._requestHandlerAbortControllers.delete(request.id);
17042
17042
  }
@@ -17055,11 +17055,11 @@ var Protocol = class {
17055
17055
  if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) {
17056
17056
  try {
17057
17057
  this._resetTimeout(messageId);
17058
- } catch (error5) {
17058
+ } catch (error6) {
17059
17059
  this._responseHandlers.delete(messageId);
17060
17060
  this._progressHandlers.delete(messageId);
17061
17061
  this._cleanupTimeout(messageId);
17062
- responseHandler(error5);
17062
+ responseHandler(error6);
17063
17063
  return;
17064
17064
  }
17065
17065
  }
@@ -17073,8 +17073,8 @@ var Protocol = class {
17073
17073
  if (isJSONRPCResultResponse(response)) {
17074
17074
  resolver(response);
17075
17075
  } else {
17076
- const error5 = new McpError(response.error.code, response.error.message, response.error.data);
17077
- resolver(error5);
17076
+ const error6 = new McpError(response.error.code, response.error.message, response.error.data);
17077
+ resolver(error6);
17078
17078
  }
17079
17079
  return;
17080
17080
  }
@@ -17102,8 +17102,8 @@ var Protocol = class {
17102
17102
  if (isJSONRPCResultResponse(response)) {
17103
17103
  handler(response);
17104
17104
  } else {
17105
- const error5 = McpError.fromError(response.error.code, response.error.message, response.error.data);
17106
- handler(error5);
17105
+ const error6 = McpError.fromError(response.error.code, response.error.message, response.error.data);
17106
+ handler(error6);
17107
17107
  }
17108
17108
  }
17109
17109
  get transport() {
@@ -17148,10 +17148,10 @@ var Protocol = class {
17148
17148
  try {
17149
17149
  const result = await this.request(request, resultSchema, options);
17150
17150
  yield { type: "result", result };
17151
- } catch (error5) {
17151
+ } catch (error6) {
17152
17152
  yield {
17153
17153
  type: "error",
17154
- error: error5 instanceof McpError ? error5 : new McpError(ErrorCode.InternalError, String(error5))
17154
+ error: error6 instanceof McpError ? error6 : new McpError(ErrorCode.InternalError, String(error6))
17155
17155
  };
17156
17156
  }
17157
17157
  return;
@@ -17194,10 +17194,10 @@ var Protocol = class {
17194
17194
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
17195
17195
  options?.signal?.throwIfAborted();
17196
17196
  }
17197
- } catch (error5) {
17197
+ } catch (error6) {
17198
17198
  yield {
17199
17199
  type: "error",
17200
- error: error5 instanceof McpError ? error5 : new McpError(ErrorCode.InternalError, String(error5))
17200
+ error: error6 instanceof McpError ? error6 : new McpError(ErrorCode.InternalError, String(error6))
17201
17201
  };
17202
17202
  }
17203
17203
  }
@@ -17209,8 +17209,8 @@ var Protocol = class {
17209
17209
  request(request, resultSchema, options) {
17210
17210
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
17211
17211
  return new Promise((resolve, reject) => {
17212
- const earlyReject = (error5) => {
17213
- reject(error5);
17212
+ const earlyReject = (error6) => {
17213
+ reject(error6);
17214
17214
  };
17215
17215
  if (!this._transport) {
17216
17216
  earlyReject(new Error("Not connected"));
@@ -17270,9 +17270,9 @@ var Protocol = class {
17270
17270
  requestId: messageId,
17271
17271
  reason: String(reason)
17272
17272
  }
17273
- }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error6) => this._onerror(new Error(`Failed to send cancellation: ${error6}`)));
17274
- const error5 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
17275
- reject(error5);
17273
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error7) => this._onerror(new Error(`Failed to send cancellation: ${error7}`)));
17274
+ const error6 = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
17275
+ reject(error6);
17276
17276
  };
17277
17277
  this._responseHandlers.set(messageId, (response) => {
17278
17278
  if (options?.signal?.aborted) {
@@ -17288,8 +17288,8 @@ var Protocol = class {
17288
17288
  } else {
17289
17289
  resolve(parseResult.data);
17290
17290
  }
17291
- } catch (error5) {
17292
- reject(error5);
17291
+ } catch (error6) {
17292
+ reject(error6);
17293
17293
  }
17294
17294
  });
17295
17295
  options?.signal?.addEventListener("abort", () => {
@@ -17313,14 +17313,14 @@ var Protocol = class {
17313
17313
  type: "request",
17314
17314
  message: jsonrpcRequest,
17315
17315
  timestamp: Date.now()
17316
- }).catch((error5) => {
17316
+ }).catch((error6) => {
17317
17317
  this._cleanupTimeout(messageId);
17318
- reject(error5);
17318
+ reject(error6);
17319
17319
  });
17320
17320
  } else {
17321
- this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error5) => {
17321
+ this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error6) => {
17322
17322
  this._cleanupTimeout(messageId);
17323
- reject(error5);
17323
+ reject(error6);
17324
17324
  });
17325
17325
  }
17326
17326
  });
@@ -17413,7 +17413,7 @@ var Protocol = class {
17413
17413
  }
17414
17414
  };
17415
17415
  }
17416
- this._transport?.send(jsonrpcNotification2, options).catch((error5) => this._onerror(error5));
17416
+ this._transport?.send(jsonrpcNotification2, options).catch((error6) => this._onerror(error6));
17417
17417
  });
17418
17418
  return;
17419
17419
  }
@@ -17502,21 +17502,21 @@ var Protocol = class {
17502
17502
  * the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
17503
17503
  * simply propagates the error.
17504
17504
  */
17505
- async _enqueueTaskMessage(taskId, message, sessionId) {
17505
+ async _enqueueTaskMessage(taskId, message, sessionId2) {
17506
17506
  if (!this._taskStore || !this._taskMessageQueue) {
17507
17507
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
17508
17508
  }
17509
17509
  const maxQueueSize = this._options?.maxTaskQueueSize;
17510
- await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
17510
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId2 ?? this._transport?.sessionId, maxQueueSize);
17511
17511
  }
17512
17512
  /**
17513
17513
  * Clears the message queue for a task and rejects any pending request resolvers.
17514
17514
  * @param taskId The task ID whose queue should be cleared
17515
17515
  * @param sessionId Optional session ID for binding the operation to a specific session
17516
17516
  */
17517
- async _clearTaskQueue(taskId, sessionId) {
17517
+ async _clearTaskQueue(taskId, sessionId2) {
17518
17518
  if (this._taskMessageQueue) {
17519
- const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
17519
+ const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId2);
17520
17520
  for (const message of messages) {
17521
17521
  if (message.type === "request" && isJSONRPCRequest(message.message)) {
17522
17522
  const requestId = message.message.id;
@@ -17539,10 +17539,10 @@ var Protocol = class {
17539
17539
  * @param sessionId Session of the request that waits, passed to the task store
17540
17540
  * @returns Promise that resolves when an update occurs or rejects if aborted
17541
17541
  */
17542
- async _waitForTaskUpdate(taskId, signal, sessionId) {
17542
+ async _waitForTaskUpdate(taskId, signal, sessionId2) {
17543
17543
  let interval = this._options?.defaultTaskPollInterval ?? 1e3;
17544
17544
  try {
17545
- const task = await this._taskStore?.getTask(taskId, sessionId);
17545
+ const task = await this._taskStore?.getTask(taskId, sessionId2);
17546
17546
  if (task?.pollInterval) {
17547
17547
  interval = task.pollInterval;
17548
17548
  }
@@ -17560,7 +17560,7 @@ var Protocol = class {
17560
17560
  }, { once: true });
17561
17561
  });
17562
17562
  }
17563
- requestTaskStore(request, sessionId) {
17563
+ requestTaskStore(request, sessionId2) {
17564
17564
  const taskStore = this._taskStore;
17565
17565
  if (!taskStore) {
17566
17566
  throw new Error("No task store configured");
@@ -17573,18 +17573,18 @@ var Protocol = class {
17573
17573
  return await taskStore.createTask(taskParams, request.id, {
17574
17574
  method: request.method,
17575
17575
  params: request.params
17576
- }, sessionId);
17576
+ }, sessionId2);
17577
17577
  },
17578
17578
  getTask: async (taskId) => {
17579
- const task = await taskStore.getTask(taskId, sessionId);
17579
+ const task = await taskStore.getTask(taskId, sessionId2);
17580
17580
  if (!task) {
17581
17581
  throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
17582
17582
  }
17583
17583
  return task;
17584
17584
  },
17585
17585
  storeTaskResult: async (taskId, status, result) => {
17586
- await taskStore.storeTaskResult(taskId, status, result, sessionId);
17587
- const task = await taskStore.getTask(taskId, sessionId);
17586
+ await taskStore.storeTaskResult(taskId, status, result, sessionId2);
17587
+ const task = await taskStore.getTask(taskId, sessionId2);
17588
17588
  if (task) {
17589
17589
  const notification = TaskStatusNotificationSchema.parse({
17590
17590
  method: "notifications/tasks/status",
@@ -17597,18 +17597,18 @@ var Protocol = class {
17597
17597
  }
17598
17598
  },
17599
17599
  getTaskResult: (taskId) => {
17600
- return taskStore.getTaskResult(taskId, sessionId);
17600
+ return taskStore.getTaskResult(taskId, sessionId2);
17601
17601
  },
17602
17602
  updateTaskStatus: async (taskId, status, statusMessage) => {
17603
- const task = await taskStore.getTask(taskId, sessionId);
17603
+ const task = await taskStore.getTask(taskId, sessionId2);
17604
17604
  if (!task) {
17605
17605
  throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
17606
17606
  }
17607
17607
  if (isTerminal(task.status)) {
17608
17608
  throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
17609
17609
  }
17610
- await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
17611
- const updatedTask = await taskStore.getTask(taskId, sessionId);
17610
+ await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId2);
17611
+ const updatedTask = await taskStore.getTask(taskId, sessionId2);
17612
17612
  if (updatedTask) {
17613
17613
  const notification = TaskStatusNotificationSchema.parse({
17614
17614
  method: "notifications/tasks/status",
@@ -17621,7 +17621,7 @@ var Protocol = class {
17621
17621
  }
17622
17622
  },
17623
17623
  listTasks: (cursor) => {
17624
- return taskStore.listTasks(cursor, sessionId);
17624
+ return taskStore.listTasks(cursor, sessionId2);
17625
17625
  }
17626
17626
  };
17627
17627
  }
@@ -17972,8 +17972,8 @@ var Server = class extends Protocol {
17972
17972
  this._serverInfo = _serverInfo;
17973
17973
  this._loggingLevels = /* @__PURE__ */ new Map();
17974
17974
  this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
17975
- this.isMessageIgnored = (level, sessionId) => {
17976
- const currentLevel = this._loggingLevels.get(sessionId);
17975
+ this.isMessageIgnored = (level, sessionId2) => {
17976
+ const currentLevel = this._loggingLevels.get(sessionId2);
17977
17977
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
17978
17978
  };
17979
17979
  this._capabilities = options?.capabilities ?? {};
@@ -18267,11 +18267,11 @@ var Server = class extends Protocol {
18267
18267
  if (!validationResult.valid) {
18268
18268
  throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
18269
18269
  }
18270
- } catch (error5) {
18271
- if (error5 instanceof McpError) {
18272
- throw error5;
18270
+ } catch (error6) {
18271
+ if (error6 instanceof McpError) {
18272
+ throw error6;
18273
18273
  }
18274
- throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error5 instanceof Error ? error5.message : String(error5)}`);
18274
+ throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error6 instanceof Error ? error6.message : String(error6)}`);
18275
18275
  }
18276
18276
  }
18277
18277
  return result;
@@ -18307,9 +18307,9 @@ var Server = class extends Protocol {
18307
18307
  * @param params
18308
18308
  * @param sessionId optional for stateless and backward compatibility
18309
18309
  */
18310
- async sendLoggingMessage(params, sessionId) {
18310
+ async sendLoggingMessage(params, sessionId2) {
18311
18311
  if (this._capabilities.logging) {
18312
- if (!this.isMessageIgnored(params.level, sessionId)) {
18312
+ if (!this.isMessageIgnored(params.level, sessionId2)) {
18313
18313
  return this.notification({ method: "notifications/message", params });
18314
18314
  }
18315
18315
  }
@@ -18383,14 +18383,14 @@ var StdioServerTransport = class {
18383
18383
  try {
18384
18384
  this._readBuffer.append(chunk);
18385
18385
  this.processReadBuffer();
18386
- } catch (error5) {
18387
- this.onerror?.(error5);
18386
+ } catch (error6) {
18387
+ this.onerror?.(error6);
18388
18388
  this.close().catch(() => {
18389
18389
  });
18390
18390
  }
18391
18391
  };
18392
- this._onerror = (error5) => {
18393
- this.onerror?.(error5);
18392
+ this._onerror = (error6) => {
18393
+ this.onerror?.(error6);
18394
18394
  };
18395
18395
  this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
18396
18396
  }
@@ -18413,8 +18413,8 @@ var StdioServerTransport = class {
18413
18413
  break;
18414
18414
  }
18415
18415
  this.onmessage?.(message);
18416
- } catch (error5) {
18417
- this.onerror?.(error5);
18416
+ } catch (error6) {
18417
+ this.onerror?.(error6);
18418
18418
  }
18419
18419
  }
18420
18420
  }
@@ -18511,14 +18511,14 @@ var ExperimentalClientTasks = class {
18511
18511
  };
18512
18512
  return;
18513
18513
  }
18514
- } catch (error5) {
18515
- if (error5 instanceof McpError) {
18516
- yield { type: "error", error: error5 };
18514
+ } catch (error6) {
18515
+ if (error6 instanceof McpError) {
18516
+ yield { type: "error", error: error6 };
18517
18517
  return;
18518
18518
  }
18519
18519
  yield {
18520
18520
  type: "error",
18521
- error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error5 instanceof Error ? error5.message : String(error5)}`)
18521
+ error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error6 instanceof Error ? error6.message : String(error6)}`)
18522
18522
  };
18523
18523
  return;
18524
18524
  }
@@ -18831,9 +18831,9 @@ var Client = class extends Protocol {
18831
18831
  this._setupListChangedHandlers(this._pendingListChangedConfig);
18832
18832
  this._pendingListChangedConfig = void 0;
18833
18833
  }
18834
- } catch (error5) {
18834
+ } catch (error6) {
18835
18835
  void this.close();
18836
- throw error5;
18836
+ throw error6;
18837
18837
  }
18838
18838
  }
18839
18839
  /**
@@ -19003,11 +19003,11 @@ var Client = class extends Protocol {
19003
19003
  if (!validationResult.valid) {
19004
19004
  throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
19005
19005
  }
19006
- } catch (error5) {
19007
- if (error5 instanceof McpError) {
19008
- throw error5;
19006
+ } catch (error6) {
19007
+ if (error6 instanceof McpError) {
19008
+ throw error6;
19009
19009
  }
19010
- throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error5 instanceof Error ? error5.message : String(error5)}`);
19010
+ throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error6 instanceof Error ? error6.message : String(error6)}`);
19011
19011
  }
19012
19012
  }
19013
19013
  }
@@ -19082,8 +19082,8 @@ var Client = class extends Protocol {
19082
19082
  const items = await fetcher();
19083
19083
  onChanged(null, items);
19084
19084
  } catch (e) {
19085
- const error5 = e instanceof Error ? e : new Error(String(e));
19086
- onChanged(error5, null);
19085
+ const error6 = e instanceof Error ? e : new Error(String(e));
19086
+ onChanged(error6, null);
19087
19087
  }
19088
19088
  };
19089
19089
  const handler = () => {
@@ -19224,8 +19224,8 @@ async function random(size) {
19224
19224
  const evenDistCutoff = Math.pow(2, 8) - Math.pow(2, 8) % mask.length;
19225
19225
  let result = "";
19226
19226
  while (result.length < size) {
19227
- const randomBytes9 = await getRandomValues(size - result.length);
19228
- for (const randomByte of randomBytes9) {
19227
+ const randomBytes11 = await getRandomValues(size - result.length);
19228
+ for (const randomByte of randomBytes11) {
19229
19229
  if (randomByte < evenDistCutoff) {
19230
19230
  result += mask[randomByte % mask.length];
19231
19231
  }
@@ -19590,12 +19590,12 @@ async function parseErrorResponse(input) {
19590
19590
  const body = input instanceof Response ? await input.text() : input;
19591
19591
  try {
19592
19592
  const result = OAuthErrorResponseSchema.parse(JSON.parse(body));
19593
- const { error: error5, error_description, error_uri } = result;
19594
- const errorClass = OAUTH_ERRORS[error5] || ServerError;
19593
+ const { error: error6, error_description, error_uri } = result;
19594
+ const errorClass = OAUTH_ERRORS[error6] || ServerError;
19595
19595
  return new errorClass(error_description || "", error_uri);
19596
- } catch (error5) {
19596
+ } catch (error6) {
19597
19597
  const redirect = input instanceof Response ? unfollowedRedirect(input, input.url) : void 0;
19598
- const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error5}. Raw body: ${body}`}`;
19598
+ const errorMessage = `${statusCode ? `HTTP ${statusCode}: ` : ""}${redirect ?? `Invalid OAuth error response: ${error6}. Raw body: ${body}`}`;
19599
19599
  return new ServerError(errorMessage);
19600
19600
  }
19601
19601
  }
@@ -19622,15 +19622,15 @@ function boundElsewhereError(stored, issuer) {
19622
19622
  async function auth(provider, options) {
19623
19623
  try {
19624
19624
  return await authInternal(provider, options);
19625
- } catch (error5) {
19626
- if (error5 instanceof InvalidClientError || error5 instanceof UnauthorizedClientError) {
19625
+ } catch (error6) {
19626
+ if (error6 instanceof InvalidClientError || error6 instanceof UnauthorizedClientError) {
19627
19627
  await provider.invalidateCredentials?.("all");
19628
19628
  return await authInternal(provider, options);
19629
- } else if (error5 instanceof InvalidGrantError) {
19629
+ } else if (error6 instanceof InvalidGrantError) {
19630
19630
  await provider.invalidateCredentials?.("tokens");
19631
19631
  return await authInternal(provider, options);
19632
19632
  }
19633
- throw error5;
19633
+ throw error6;
19634
19634
  }
19635
19635
  }
19636
19636
  async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
@@ -19746,10 +19746,10 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
19746
19746
  await bindClientInformation();
19747
19747
  await provider.saveTokens({ ...newTokens, issuer });
19748
19748
  return "AUTHORIZED";
19749
- } catch (error5) {
19750
- if (!(error5 instanceof OAuthError) || error5 instanceof ServerError) {
19749
+ } catch (error6) {
19750
+ if (!(error6 instanceof OAuthError) || error6 instanceof ServerError) {
19751
19751
  } else {
19752
- throw error5;
19752
+ throw error6;
19753
19753
  }
19754
19754
  }
19755
19755
  }
@@ -19807,11 +19807,11 @@ function extractWWWAuthenticateParams(res) {
19807
19807
  }
19808
19808
  }
19809
19809
  const scope = extractFieldFromWwwAuth(res, "scope") || void 0;
19810
- const error5 = extractFieldFromWwwAuth(res, "error") || void 0;
19810
+ const error6 = extractFieldFromWwwAuth(res, "error") || void 0;
19811
19811
  return {
19812
19812
  resourceMetadataUrl,
19813
19813
  scope,
19814
- error: error5
19814
+ error: error6
19815
19815
  };
19816
19816
  }
19817
19817
  function extractFieldFromWwwAuth(response, fieldName) {
@@ -19844,15 +19844,15 @@ async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn =
19844
19844
  async function fetchWithCorsRetry(url2, headers, fetchFn = fetch) {
19845
19845
  try {
19846
19846
  return await fetchWithinOrigin(fetchFn)(url2, { headers });
19847
- } catch (error5) {
19848
- if (error5 instanceof TypeError) {
19847
+ } catch (error6) {
19848
+ if (error6 instanceof TypeError) {
19849
19849
  if (headers) {
19850
19850
  return fetchWithCorsRetry(url2, void 0, fetchFn);
19851
19851
  } else {
19852
19852
  return void 0;
19853
19853
  }
19854
19854
  }
19855
- throw error5;
19855
+ throw error6;
19856
19856
  }
19857
19857
  }
19858
19858
  function buildWellKnownPath(wellKnownPrefix, pathname = "", options = {}) {
@@ -20301,8 +20301,8 @@ var EventSourceParserStream = class extends TransformStream {
20301
20301
  onEvent: (event) => {
20302
20302
  controller.enqueue(event);
20303
20303
  },
20304
- onError(error5) {
20305
- typeof onError == "function" && onError(error5), (onError === "terminate" || error5.type === "max-buffer-size-exceeded") && controller.error(error5);
20304
+ onError(error6) {
20305
+ typeof onError == "function" && onError(error6), (onError === "terminate" || error6.type === "max-buffer-size-exceeded") && controller.error(error6);
20306
20306
  },
20307
20307
  onRetry,
20308
20308
  onComment,
@@ -20364,9 +20364,9 @@ var StreamableHTTPClientTransport = class {
20364
20364
  scope: this._scope,
20365
20365
  fetchFn: this._fetchWithInit
20366
20366
  });
20367
- } catch (error5) {
20368
- this.onerror?.(error5);
20369
- throw error5;
20367
+ } catch (error6) {
20368
+ this.onerror?.(error6);
20369
+ throw error6;
20370
20370
  }
20371
20371
  if (result !== "AUTHORIZED") {
20372
20372
  throw new UnauthorizedError();
@@ -20419,9 +20419,9 @@ var StreamableHTTPClientTransport = class {
20419
20419
  throw new StreamableHTTPError(response.status, `Failed to open SSE stream: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
20420
20420
  }
20421
20421
  this._handleSseStream(response.body, options, true);
20422
- } catch (error5) {
20423
- this.onerror?.(error5);
20424
- throw error5;
20422
+ } catch (error6) {
20423
+ this.onerror?.(error6);
20424
+ throw error6;
20425
20425
  }
20426
20426
  }
20427
20427
  /**
@@ -20453,8 +20453,8 @@ var StreamableHTTPClientTransport = class {
20453
20453
  }
20454
20454
  const delay = this._getNextReconnectionDelay(attemptCount);
20455
20455
  this._reconnectionTimeout = setTimeout(() => {
20456
- this._startOrAuthSse(options).catch((error5) => {
20457
- this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error5 instanceof Error ? error5.message : String(error5)}`));
20456
+ this._startOrAuthSse(options).catch((error6) => {
20457
+ this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error6 instanceof Error ? error6.message : String(error6)}`));
20458
20458
  this._scheduleReconnection(options, attemptCount + 1);
20459
20459
  });
20460
20460
  }, delay);
@@ -20497,8 +20497,8 @@ var StreamableHTTPClientTransport = class {
20497
20497
  }
20498
20498
  }
20499
20499
  this.onmessage?.(message);
20500
- } catch (error5) {
20501
- this.onerror?.(error5);
20500
+ } catch (error6) {
20501
+ this.onerror?.(error6);
20502
20502
  }
20503
20503
  }
20504
20504
  }
@@ -20511,8 +20511,8 @@ var StreamableHTTPClientTransport = class {
20511
20511
  replayMessageId
20512
20512
  }, 0);
20513
20513
  }
20514
- } catch (error5) {
20515
- this.onerror?.(new Error(`SSE stream disconnected: ${error5}`));
20514
+ } catch (error6) {
20515
+ this.onerror?.(new Error(`SSE stream disconnected: ${error6}`));
20516
20516
  const canResume = isReconnectable || hasPrimingEvent;
20517
20517
  const needsReconnect = canResume && !receivedResponse;
20518
20518
  if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
@@ -20522,8 +20522,8 @@ var StreamableHTTPClientTransport = class {
20522
20522
  onresumptiontoken,
20523
20523
  replayMessageId
20524
20524
  }, 0);
20525
- } catch (error6) {
20526
- this.onerror?.(new Error(`Failed to reconnect: ${error6 instanceof Error ? error6.message : String(error6)}`));
20525
+ } catch (error7) {
20526
+ this.onerror?.(new Error(`Failed to reconnect: ${error7 instanceof Error ? error7.message : String(error7)}`));
20527
20527
  }
20528
20528
  }
20529
20529
  }
@@ -20580,9 +20580,9 @@ var StreamableHTTPClientTransport = class {
20580
20580
  signal: this._abortController?.signal
20581
20581
  };
20582
20582
  const response = await fetchWithinOrigin(this._fetch ?? fetch)(this._url, init);
20583
- const sessionId = response.headers.get("mcp-session-id");
20584
- if (sessionId) {
20585
- this._sessionId = sessionId;
20583
+ const sessionId2 = response.headers.get("mcp-session-id");
20584
+ if (sessionId2) {
20585
+ this._sessionId = sessionId2;
20586
20586
  }
20587
20587
  if (!response.ok) {
20588
20588
  const text = await response.text().catch(() => null);
@@ -20606,8 +20606,8 @@ var StreamableHTTPClientTransport = class {
20606
20606
  return this.send(message);
20607
20607
  }
20608
20608
  if (response.status === 403 && this._authProvider) {
20609
- const { resourceMetadataUrl, scope, error: error5 } = extractWWWAuthenticateParams(response);
20610
- if (error5 === "insufficient_scope") {
20609
+ const { resourceMetadataUrl, scope, error: error6 } = extractWWWAuthenticateParams(response);
20610
+ if (error6 === "insufficient_scope") {
20611
20611
  const wwwAuthHeader = response.headers.get("WWW-Authenticate");
20612
20612
  if (this._lastUpscopingHeader === wwwAuthHeader) {
20613
20613
  throw new StreamableHTTPError(403, "Server returned 403 after trying upscoping");
@@ -20662,9 +20662,9 @@ var StreamableHTTPClientTransport = class {
20662
20662
  } else {
20663
20663
  await response.body?.cancel();
20664
20664
  }
20665
- } catch (error5) {
20666
- this.onerror?.(error5);
20667
- throw error5;
20665
+ } catch (error6) {
20666
+ this.onerror?.(error6);
20667
+ throw error6;
20668
20668
  }
20669
20669
  }
20670
20670
  get sessionId() {
@@ -20699,9 +20699,9 @@ var StreamableHTTPClientTransport = class {
20699
20699
  throw new StreamableHTTPError(response.status, `Failed to terminate session: ${this._unfollowedRedirect(response, this._url) ?? response.statusText}`);
20700
20700
  }
20701
20701
  this._sessionId = void 0;
20702
- } catch (error5) {
20703
- this.onerror?.(error5);
20704
- throw error5;
20702
+ } catch (error6) {
20703
+ this.onerror?.(error6);
20704
+ throw error6;
20705
20705
  }
20706
20706
  }
20707
20707
  setProtocolVersion(version3) {
@@ -20726,21 +20726,27 @@ var StreamableHTTPClientTransport = class {
20726
20726
  };
20727
20727
 
20728
20728
  // lib/host-identity.mjs
20729
+ var SUPPORTED_HOSTS = Object.freeze(["codex", "claude-code", "antigravity"]);
20730
+ var isHookProofHost = (kind) => kind === "claude-code" || kind === "antigravity";
20731
+ var DEFAULT_CLIENT_NAMES = Object.freeze({
20732
+ codex: "Codex PromptFrame",
20733
+ "claude-code": "Claude Code PromptFrame",
20734
+ antigravity: "Antigravity PromptFrame"
20735
+ });
20729
20736
  function hostClientName(savedName, host) {
20730
- return ["Codex PromptFrame", "Claude Code PromptFrame"].includes(savedName) ? host.kind === "claude-code" ? "Claude Code PromptFrame" : "Codex PromptFrame" : savedName;
20737
+ return Object.values(DEFAULT_CLIENT_NAMES).includes(savedName) ? DEFAULT_CLIENT_NAMES[host.kind] ?? DEFAULT_CLIENT_NAMES.codex : savedName;
20731
20738
  }
20732
20739
  var threadFormat = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
20733
20740
  function resolveHostIdentity({ host, env = process.env } = {}) {
20734
20741
  const kind = host ?? (env.CLAUDECODE === "1" ? "claude-code" : "codex");
20735
- if (!["codex", "claude-code"].includes(kind)) throw new CreationClientError("creation.host_unsupported");
20736
- if (kind === "codex") return Object.freeze({ kind });
20742
+ if (!SUPPORTED_HOSTS.includes(kind)) throw new CreationClientError("creation.host_unsupported");
20737
20743
  return Object.freeze({ kind });
20738
20744
  }
20739
20745
  function hostParameters(params, host, access2) {
20740
20746
  const meta2 = params._meta ?? {};
20741
20747
  if (Object.keys(meta2).some((key) => key.startsWith("promptframe.") || ["controlVersion", "controller", "clientDigest", "token", "catalogVersion", "platformDigest"].includes(key)))
20742
20748
  throw new CreationClientError("creation.transport_authority_managed_by_bridge");
20743
- if (host.kind === "claude-code") {
20749
+ if (isHookProofHost(host.kind)) {
20744
20750
  if (Object.hasOwn(meta2, "threadId")) throw new CreationClientError("creation.transport_authority_managed_by_bridge");
20745
20751
  if (!host.threadId) {
20746
20752
  if (access2 === "independent-read") return params;
@@ -20815,7 +20821,7 @@ var BridgeCompatibilityError = class extends CreationClientError {
20815
20821
  });
20816
20822
  }
20817
20823
  };
20818
- var bridgeErrorDetails = (error5) => error5 instanceof BridgeCompatibilityError ? error5.bridgeFacts : void 0;
20824
+ var bridgeErrorDetails = (error6) => error6 instanceof BridgeCompatibilityError ? error6.bridgeFacts : void 0;
20819
20825
  function declaredHostContentCapabilities(capabilities, { initialized = false, standardContent = false } = {}) {
20820
20826
  const requested = capabilities?.experimental?.["promptframe.contentTypes"];
20821
20827
  if (requested === void 0 && initialized && standardContent)
@@ -20877,9 +20883,9 @@ async function directory2(file, create = false) {
20877
20883
  try {
20878
20884
  privateOwner(await lstat4(file), true);
20879
20885
  return true;
20880
- } catch (error5) {
20881
- if (!create && error5.code === "ENOENT") return false;
20882
- throw error5;
20886
+ } catch (error6) {
20887
+ if (!create && error6.code === "ENOENT") return false;
20888
+ throw error6;
20883
20889
  }
20884
20890
  }
20885
20891
  async function ownedPath(root, segments, create = false) {
@@ -20907,10 +20913,10 @@ async function readJson(file) {
20907
20913
  } catch {
20908
20914
  throw failure3("record_invalid");
20909
20915
  }
20910
- } catch (error5) {
20911
- if (error5.code === "ENOENT") return void 0;
20912
- if (error5.code === "ELOOP") throw failure3("private_storage_required");
20913
- throw error5;
20916
+ } catch (error6) {
20917
+ if (error6.code === "ENOENT") return void 0;
20918
+ if (error6.code === "ELOOP") throw failure3("private_storage_required");
20919
+ throw error6;
20914
20920
  } finally {
20915
20921
  await fd?.close();
20916
20922
  }
@@ -20934,15 +20940,15 @@ async function writeJson(directoryPath, name, value2) {
20934
20940
  if (current.dev !== owner.dev || current.ino !== owner.ino) throw failure3("reference_changed");
20935
20941
  try {
20936
20942
  privateOwner(await lstat4(path5.join(directoryPath, name)));
20937
- } catch (error5) {
20938
- if (error5.code !== "ENOENT") throw error5;
20943
+ } catch (error6) {
20944
+ if (error6.code !== "ENOENT") throw error6;
20939
20945
  }
20940
20946
  await rename3(temporary, path5.join(directoryPath, name));
20941
20947
  await parent.sync();
20942
20948
  } finally {
20943
20949
  await parent.close();
20944
- await unlink3(temporary).catch((error5) => {
20945
- if (error5.code !== "ENOENT") throw error5;
20950
+ await unlink3(temporary).catch((error6) => {
20951
+ if (error6.code !== "ENOENT") throw error6;
20946
20952
  });
20947
20953
  }
20948
20954
  }
@@ -21080,7 +21086,7 @@ async function listAccounts({ root = localAccountsRoot(), now = Date.now() } = {
21080
21086
  return { accounts, complete: true };
21081
21087
  }
21082
21088
  function localAgentDigest(agent) {
21083
- if (!agent || !["codex", "claude-code"].includes(agent.kind) || typeof agent.sessionId !== "string" || !threadFormat.test(agent.sessionId)) throw failure3("agent_required");
21089
+ if (!agent || !["codex", "claude-code", "antigravity"].includes(agent.kind) || typeof agent.sessionId !== "string" || !threadFormat.test(agent.sessionId)) throw failure3("agent_required");
21084
21090
  return hash(JSON.stringify([agent.kind, agent.sessionId.toLowerCase()]));
21085
21091
  }
21086
21092
  async function selectAccount({ root = localAccountsRoot(), agent, identity }) {
@@ -21147,13 +21153,13 @@ async function clientObservationInstance({ root = localAccountsRoot(), identity,
21147
21153
  await directoryHandle.close();
21148
21154
  }
21149
21155
  return value2.instanceId;
21150
- } catch (error5) {
21151
- if (error5.code === "EEXIST") return parse4(await readJson(file));
21152
- throw error5;
21156
+ } catch (error6) {
21157
+ if (error6.code === "EEXIST") return parse4(await readJson(file));
21158
+ throw error6;
21153
21159
  } finally {
21154
21160
  await fd?.close();
21155
- await unlink3(temporary).catch((error5) => {
21156
- if (error5.code !== "ENOENT") throw error5;
21161
+ await unlink3(temporary).catch((error6) => {
21162
+ if (error6.code !== "ENOENT") throw error6;
21157
21163
  });
21158
21164
  }
21159
21165
  }
@@ -21220,7 +21226,7 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
21220
21226
  contractVersion: "promptframe-client-observation/v1",
21221
21227
  instanceId,
21222
21228
  systemFamily,
21223
- application: host.kind === "claude-code" ? "Claude Code" : host.kind === "codex" ? "Codex" : "Creation",
21229
+ application: host.kind === "claude-code" ? "Claude Code" : host.kind === "antigravity" ? "Antigravity" : host.kind === "codex" ? "Codex" : "Creation",
21224
21230
  applicationVersion: CLIENT_VERSION
21225
21231
  };
21226
21232
  } catch {
@@ -21228,10 +21234,10 @@ async function connectPlatform(credentials, { host = resolveHostIdentity(), cont
21228
21234
  if (enforceMinimum) assertBridgeCompatible(client.getServerCapabilities(), CLIENT_VERSION);
21229
21235
  else readPlatformBridgePolicy(client.getServerCapabilities());
21230
21236
  return client;
21231
- } catch (error5) {
21237
+ } catch (error6) {
21232
21238
  await client.close().catch(() => {
21233
21239
  });
21234
- throw error5;
21240
+ throw error6;
21235
21241
  }
21236
21242
  }
21237
21243
 
@@ -21293,8 +21299,8 @@ async function claudeHostProcess({
21293
21299
  if (!entryFile || !command2.some((arg) => arg.includes(entryFile)) || !command2.some((arg) => arg === "claude-host-hook" || arg.includes(" claude-host-hook"))) return null;
21294
21300
  }
21295
21301
  const binding = { pid: host.pid, birth: host.birth, uid, device: host.device, inode: host.inode, exe: host.exe, boot };
21296
- const digest5 = hash2(binding);
21297
- return { binding, digest: digest5, eventOrder: { birth: child.birth, pid: child.pid }, async isCurrent() {
21302
+ const digest6 = hash2(binding);
21303
+ return { binding, digest: digest6, eventOrder: { birth: child.birth, pid: child.pid }, async isCurrent() {
21298
21304
  try {
21299
21305
  const current = await readBirth(binding.pid);
21300
21306
  return current.birth === binding.birth && current.uid === uid && current.device === binding.device && current.inode === binding.inode && current.exe === binding.exe && await readBoot() === boot;
@@ -21441,7 +21447,7 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
21441
21447
  async function hook(input) {
21442
21448
  const event = input?.hook_event_name;
21443
21449
  if (!["SessionStart", "PreToolUse", "SessionEnd"].includes(event)) throw error2("host_identity_invalid");
21444
- const valid = typeof input.session_id === "string" && uuid2.test(input.session_id), sessionId = valid ? input.session_id.toLowerCase() : null;
21450
+ const valid = typeof input.session_id === "string" && uuid2.test(input.session_id), sessionId2 = valid ? input.session_id.toLowerCase() : null;
21445
21451
  const rawArgs = input.tool_input;
21446
21452
  if (event === "PreToolUse" && (!rawArgs || typeof rawArgs !== "object" || Array.isArray(rawArgs) || typeof input.tool_name !== "string" || !/^mcp__[A-Za-z0-9_.:-]+__[A-Za-z0-9_.:-]+$/.test(input.tool_name))) throw error2("host_identity_invalid");
21447
21453
  if (!owner) return event === "PreToolUse" && Object.hasOwn(rawArgs, CLAUDE_HOST_PROOF) ? { hookSpecificOutput: { hookEventName: event, updatedInput: withoutProof(rawArgs) } } : {};
@@ -21449,12 +21455,12 @@ async function createClaudeHostSession({ configFile: configFile2, env = process.
21449
21455
  await transaction((current) => {
21450
21456
  if (current && later(current.order, owner.eventOrder)) return void 0;
21451
21457
  if (event === "SessionEnd") {
21452
- if (current?.sessionId === sessionId && ["prompt_input_exit", "logout", "other", "bypass_permissions_disabled"].includes(input.reason)) return null;
21453
- if (!current || current.sessionId !== sessionId) return void 0;
21458
+ if (current?.sessionId === sessionId2 && ["prompt_input_exit", "logout", "other", "bypass_permissions_disabled"].includes(input.reason)) return null;
21459
+ if (!current || current.sessionId !== sessionId2) return void 0;
21454
21460
  }
21455
21461
  if (event === "SessionStart" && !["startup", "resume", "fork", "clear", "compact"].includes(input.source)) throw error2("host_identity_invalid");
21456
- const inconsistent = event === "PreToolUse" && current?.sessionId !== sessionId || event === "SessionStart" && input.source === "compact" && current?.sessionId !== sessionId || event === "SessionStart" && input.source === "startup" && current?.sessionId && current.sessionId !== sessionId;
21457
- const nextId = event === "SessionEnd" || inconsistent ? null : sessionId;
21462
+ const inconsistent = event === "PreToolUse" && current?.sessionId !== sessionId2 || event === "SessionStart" && input.source === "compact" && current?.sessionId !== sessionId2 || event === "SessionStart" && input.source === "startup" && current?.sessionId && current.sessionId !== sessionId2;
21463
+ const nextId = event === "SessionEnd" || inconsistent ? null : sessionId2;
21458
21464
  const same2 = current && current.sessionId === nextId;
21459
21465
  const next = {
21460
21466
  contractVersion: "claude-host-session/v1",
@@ -21512,32 +21518,32 @@ import { open as open6, stat as stat2 } from "node:fs/promises";
21512
21518
  import { constants as constants5 } from "node:fs";
21513
21519
  import path9 from "node:path";
21514
21520
  async function readDevelopmentPairingFile(filePath, { signal } = {}) {
21515
- const fail8 = () => {
21521
+ const fail9 = () => {
21516
21522
  throw new CreationClientError("creation.development_pairing.private_file_unavailable");
21517
21523
  };
21518
- if (typeof filePath !== "string" || filePath.length > 4096 || !path9.isAbsolute(filePath)) fail8();
21524
+ if (typeof filePath !== "string" || filePath.length > 4096 || !path9.isAbsolute(filePath)) fail9();
21519
21525
  let file;
21520
21526
  try {
21521
21527
  signal?.throwIfAborted();
21522
21528
  file = await open6(filePath, constants5.O_RDONLY | constants5.O_NOFOLLOW | constants5.O_NONBLOCK);
21523
21529
  const before = await file.stat();
21524
- if (!before.isFile() || before.size < 2 || before.size > 8192 || process.platform !== "win32" && ((before.mode & 63) !== 0 || before.uid !== process.getuid())) fail8();
21530
+ if (!before.isFile() || before.size < 2 || before.size > 8192 || process.platform !== "win32" && ((before.mode & 63) !== 0 || before.uid !== process.getuid())) fail9();
21525
21531
  const bytes2 = Buffer.alloc(before.size);
21526
21532
  let offset = 0;
21527
21533
  while (offset < bytes2.length) {
21528
21534
  signal?.throwIfAborted();
21529
21535
  const read2 = await file.read(bytes2, offset, bytes2.length - offset, offset);
21530
- if (!read2.bytesRead) fail8();
21536
+ if (!read2.bytesRead) fail9();
21531
21537
  offset += read2.bytesRead;
21532
21538
  }
21533
21539
  const after = await file.stat(), named = await stat2(filePath);
21534
21540
  signal?.throwIfAborted();
21535
- if ([after, named].some((value3) => value3.dev !== before.dev || value3.ino !== before.ino || value3.size !== before.size || value3.mtimeMs !== before.mtimeMs || value3.ctimeMs !== before.ctimeMs)) fail8();
21541
+ if ([after, named].some((value3) => value3.dev !== before.dev || value3.ino !== before.ino || value3.size !== before.size || value3.mtimeMs !== before.mtimeMs || value3.ctimeMs !== before.ctimeMs)) fail9();
21536
21542
  const value2 = JSON.parse(bytes2.toString("utf8"));
21537
- if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) fail8();
21543
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) fail9();
21538
21544
  return Object.fromEntries(["url", "connectionId", "credential", "studioOrigin", "expiresAt", "contractVersion", "lifecycle"].filter((key) => Object.hasOwn(value2, key)).map((key) => [key, value2[key]]));
21539
21545
  } catch {
21540
- fail8();
21546
+ fail9();
21541
21547
  } finally {
21542
21548
  await file?.close();
21543
21549
  }
@@ -21562,10 +21568,10 @@ var boundedSet = (map, key, value2) => {
21562
21568
  async function resolveHostCallBinding(raw, { host = resolveHostIdentity(), hostSession } = {}) {
21563
21569
  for (const field of ["threadId", "controller", "clientDigest", "token", "controlVersion", "developmentPairing"]) if (Object.hasOwn(raw.arguments ?? {}, field))
21564
21570
  throw new CreationClientError("creation.transport_authority_managed_by_bridge");
21565
- if (host.kind === "claude-code") {
21571
+ if (isHookProofHost(host.kind)) {
21566
21572
  if (hostSession) return hostSession.begin(raw);
21567
21573
  if (raw.arguments?.[CLAUDE_HOST_PROOF] !== void 0) throw new CreationClientError("creation.host_identity_invalid");
21568
- return { host: { kind: "claude-code" }, arguments: raw.arguments, assertCurrent: async () => {
21574
+ return { host: { kind: host.kind }, arguments: raw.arguments, assertCurrent: async () => {
21569
21575
  } };
21570
21576
  }
21571
21577
  if (Object.hasOwn(raw.arguments ?? {}, CLAUDE_HOST_PROOF)) throw new CreationClientError("creation.transport_authority_managed_by_bridge");
@@ -21590,8 +21596,8 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21590
21596
  });
21591
21597
  }
21592
21598
  function keyFor(params) {
21593
- const { projectId, sessionId } = params.arguments ?? {}, thread = params._meta?.threadId;
21594
- return typeof thread === "string" && [projectId, sessionId].every((v2) => typeof v2 === "string" && v2.length > 0 && v2.length <= 160) ? JSON.stringify([thread.toLowerCase(), projectId, sessionId]) : null;
21599
+ const { projectId, sessionId: sessionId2 } = params.arguments ?? {}, thread = params._meta?.threadId;
21600
+ return typeof thread === "string" && [projectId, sessionId2].every((v2) => typeof v2 === "string" && v2.length > 0 && v2.length <= 160) ? JSON.stringify([thread.toLowerCase(), projectId, sessionId2]) : null;
21595
21601
  }
21596
21602
  function metadata(params, result) {
21597
21603
  const v2 = result?._meta?.["promptframe.creation"];
@@ -21641,7 +21647,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21641
21647
  if (!schema || schema.type !== "object") throw new CreationClientError("creation.upgrade_required");
21642
21648
  const p2 = schema.properties;
21643
21649
  const { controlVersion: _managed, developmentPairing: _privatePairing, ...properties } = p2 ?? {};
21644
- return { ...tool, inputSchema: { ...schema, properties: { ...properties, ...host.kind === "claude-code" ? {
21650
+ return { ...tool, inputSchema: { ...schema, properties: { ...properties, ...isHookProofHost(host.kind) ? {
21645
21651
  [CLAUDE_HOST_PROOF]: { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\u7684\u5355\u6B21\u8EAB\u4EFD\u51ED\u8BC1\uFF1B\u8BF7\u4FDD\u7559\uFF0C\u4E0D\u81EA\u884C\u586B\u5199\u3002" }
21646
21652
  } : {} }, ...schema.required ? { required: schema.required.filter((name) => name !== "controlVersion") } : {} } };
21647
21653
  }) };
@@ -21676,7 +21682,7 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21676
21682
  }
21677
21683
  async function knowledgeRead(kind, method, raw = {}) {
21678
21684
  if (!upstream[kind]) throw new CreationClientError("creation.knowledge_unsupported");
21679
- const params = hostParameters(raw, host.kind === "claude-code" ? { kind: host.kind } : host, "independent-read"), order = ++sequence;
21685
+ const params = hostParameters(raw, isHookProofHost(host.kind) ? { kind: host.kind } : host, "independent-read"), order = ++sequence;
21680
21686
  const result = assertMcpResponseBudget(await client[method](params, void 0, { timeout: 6e4 }));
21681
21687
  const version3 = result._meta?.[kind === "resources" && method === "listResources" ? "promptframe.guideDirectoryVersion" : "promptframe.guideVersion"];
21682
21688
  const key = JSON.stringify([kind, method, raw.uri ?? raw.arguments?.projectId ?? null]);
@@ -21724,9 +21730,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21724
21730
  let params = hostParameters(raw, binding.host, "independent-read");
21725
21731
  let effectiveAccess = access2, resolvedControl;
21726
21732
  if (definition._meta["promptframe.resolveAccess"] === "target") {
21727
- const { projectId, sessionId, tool, arguments: input } = params.arguments ?? {};
21733
+ const { projectId, sessionId: sessionId2, tool, arguments: input } = params.arguments ?? {};
21728
21734
  if (typeof tool !== "string" || !input || typeof input !== "object" || Array.isArray(input)) throw new CreationClientError("creation.request_invalid");
21729
- const observed = await send({ name: role("describe-target"), _meta: params._meta, arguments: { projectId, sessionId, tool, arguments: input } }, binding);
21735
+ const observed = await send({ name: role("describe-target"), _meta: params._meta, arguments: { projectId, sessionId: sessionId2, tool, arguments: input } }, binding);
21730
21736
  if (observed.result.isError) return observed.result;
21731
21737
  const resolved = observed.trusted?.resolvedAccess;
21732
21738
  const defaults = resolved?.scopeDefaults ?? {};
@@ -21742,9 +21748,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21742
21748
  const local = definition._meta["promptframe.localFileUpload"];
21743
21749
  if (local?.contractVersion === LOCAL_UPLOAD_PROTOCOL) {
21744
21750
  if (!localUploads) throw new CreationClientError("creation.upgrade_required");
21745
- const { projectId, sessionId } = params.arguments ?? {};
21746
- if (typeof projectId !== "string" || typeof sessionId !== "string") throw new CreationClientError("creation.request_invalid");
21747
- const observed = await send({ name: role("control-read"), _meta: params._meta, arguments: { projectId, sessionId, pageSize: 1 } }, binding);
21751
+ const { projectId, sessionId: sessionId2 } = params.arguments ?? {};
21752
+ if (typeof projectId !== "string" || typeof sessionId2 !== "string") throw new CreationClientError("creation.request_invalid");
21753
+ const observed = await send({ name: role("control-read"), _meta: params._meta, arguments: { projectId, sessionId: sessionId2, pageSize: 1 } }, binding);
21748
21754
  if (observed.result.isError) return observed.result;
21749
21755
  if (!observed.trusted) throw new CreationClientError("creation.access_unverified");
21750
21756
  const value2 = await localUploads.call({
@@ -21758,9 +21764,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21758
21764
  host: binding.host.kind,
21759
21765
  thread: params._meta.threadId.toLowerCase(),
21760
21766
  projectId,
21761
- sessionId
21767
+ sessionId: sessionId2
21762
21768
  },
21763
- send: (transfer, options) => send({ name: params.name, _meta: params._meta, arguments: { projectId, sessionId, transfer } }, binding, { timeout: 3e4, ...options })
21769
+ send: (transfer, options) => send({ name: params.name, _meta: params._meta, arguments: { projectId, sessionId: sessionId2, transfer } }, binding, { timeout: 3e4, ...options })
21764
21770
  });
21765
21771
  return assertMcpResponseBudget({ content: [{ type: "text", text: JSON.stringify(value2) }] });
21766
21772
  }
@@ -21799,9 +21805,9 @@ function createHostCallBridge(client, { credentials, host = resolveHostIdentity(
21799
21805
  let response;
21800
21806
  try {
21801
21807
  response = await send(outgoing, binding);
21802
- } catch (error5) {
21808
+ } catch (error6) {
21803
21809
  invalidate();
21804
- throw error5;
21810
+ throw error6;
21805
21811
  }
21806
21812
  if (response.result.isError) invalidate();
21807
21813
  return response.result;
@@ -21827,7 +21833,7 @@ function localTool(name, host) {
21827
21833
  identityKey: { type: "string", pattern: "^[a-f0-9]{64}-[a-f0-9]{64}$" },
21828
21834
  referenceId: { type: "string", pattern: "^sha256:[a-f0-9]{64}$", description: "\u540C\u4E00\u8D26\u53F7\u6709\u591A\u4EFD\u521B\u4F5C\u6388\u6743\u65F6\u53EF\u660E\u786E\u9009\u62E9\u5217\u8868\u4E2D\u7684\u5F15\u7528\u3002" }
21829
21835
  } : {};
21830
- if (host.kind === "claude-code") properties[CLAUDE_HOST_PROOF] = { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\uFF0C\u4FDD\u7559\u539F\u503C\u3002" };
21836
+ if (isHookProofHost(host.kind)) properties[CLAUDE_HOST_PROOF] = { type: "string", pattern: "^[a-f0-9]{64}$", description: "\u7531\u5F53\u524D\u5BBF\u4E3Bhook\u586B\u5165\uFF0C\u4FDD\u7559\u539F\u503C\u3002" };
21831
21837
  return {
21832
21838
  name,
21833
21839
  description: name === listName ? "\u5217\u51FA\u672C\u673A\u5DF2\u767B\u8BB0\u8D26\u53F7\u7684\u5B89\u5168\u6458\u8981\u548C\u7F3A\u5C11\u7684\u6388\u6743\u7C7B\u578B\uFF0C\u4E0D\u8FD4\u56DE\u51ED\u636E\u6216\u672C\u673A\u8DEF\u5F84\u3002" : "\u53EA\u4E3A\u5F53\u524D\u5BBF\u4E3B\u4F1A\u8BDD\u9009\u62E9\u672C\u673A\u5DF2\u6388\u6743\u8D26\u53F7\uFF1B\u4E0D\u5207\u6362\u5176\u5B83Agent\uFF0C\u4E0D\u7533\u8BF7\u7F16\u8F91\u6743\u6216\u91CD\u653E\u4E1A\u52A1\u3002",
@@ -21863,8 +21869,8 @@ function createAccountAwareBridge(defaultClient, {
21863
21869
  function caller(raw, binding, required2 = false) {
21864
21870
  const params = { ...raw, arguments: binding.arguments };
21865
21871
  hostParameters(params, binding.host, required2 ? "authority" : "independent-read");
21866
- const sessionId = binding.host.kind === "claude-code" ? binding.host.threadId : params._meta?.threadId;
21867
- return sessionId ? { kind: binding.host.kind, sessionId } : void 0;
21872
+ const sessionId2 = isHookProofHost(binding.host.kind) ? binding.host.threadId : params._meta?.threadId;
21873
+ return sessionId2 ? { kind: binding.host.kind, sessionId: sessionId2 } : void 0;
21868
21874
  }
21869
21875
  async function context(identity, agent, referenceId) {
21870
21876
  if (sameIdentity(identity, primaryIdentity) && (!referenceId || referenceId === localReferenceId("creation", path10.resolve(configFile2)))) return primary;
@@ -21969,8 +21975,232 @@ function createAccountAwareBridge(defaultClient, {
21969
21975
  };
21970
21976
  }
21971
21977
 
21978
+ // lib/antigravity-host-session.mjs
21979
+ import { constants as constants6 } from "node:fs";
21980
+ import { open as open7, mkdir as mkdir5, lstat as lstat6, rename as rename5, unlink as unlink5, rmdir as rmdir3 } from "node:fs/promises";
21981
+ import path11 from "node:path";
21982
+ import { homedir as homedir5 } from "node:os";
21983
+ import { createHash as createHash7, randomBytes as randomBytes4 } from "node:crypto";
21984
+ var hex2 = /^[0-9a-f]{64}$/;
21985
+ var TICKET_TTL_MS = 12e4;
21986
+ var SESSION_TTL_MS = 24 * 60 * 60 * 1e3;
21987
+ var MAX_TICKETS = 256;
21988
+ var MAX_SESSIONS = 256;
21989
+ var DEFAULT_SERVER = "promptframe-creation_promptframe-creation";
21990
+ var mcpToolName = /^[A-Za-z0-9_.:-]{1,200}$/;
21991
+ var error4 = (code) => new CreationClientError("creation." + code);
21992
+ var canonical3 = (value2) => {
21993
+ if (value2 === null || typeof value2 === "string" || typeof value2 === "boolean" || typeof value2 === "number" && Number.isFinite(value2)) return JSON.stringify(value2);
21994
+ if (Array.isArray(value2)) return "[" + value2.map(canonical3).join(",") + "]";
21995
+ if (value2 && typeof value2 === "object" && [Object.prototype, null].includes(Object.getPrototypeOf(value2)))
21996
+ return "{" + Object.keys(value2).sort().map((key) => JSON.stringify(key) + ":" + canonical3(value2[key])).join(",") + "}";
21997
+ throw error4("request_invalid");
21998
+ };
21999
+ var digest4 = (value2) => createHash7("sha256").update(canonical3(value2)).digest("hex");
22000
+ var withoutProof2 = (args2) => Object.fromEntries(Object.entries(args2 ?? {}).filter(([key]) => key !== CLAUDE_HOST_PROOF));
22001
+ function objectArgs(value2) {
22002
+ return value2 && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
22003
+ }
22004
+ function promptFrameCall(toolCall, serverName) {
22005
+ if (typeof toolCall?.name !== "string") return null;
22006
+ const args2 = objectArgs(toolCall.args) ?? {};
22007
+ if (toolCall.name === "call_mcp_tool") {
22008
+ if (args2.ServerName !== serverName || typeof args2.ToolName !== "string" || !mcpToolName.test(args2.ToolName)) return null;
22009
+ const inner = args2.Arguments === void 0 ? {} : objectArgs(args2.Arguments);
22010
+ return inner ? { name: args2.ToolName, args: inner, lazy: true } : null;
22011
+ }
22012
+ const namespacedPrefix = `mcp_${serverName}_`, oldPrefix = `mcp_${serverName.split("_")[0]}_`;
22013
+ if (toolCall.name.startsWith(namespacedPrefix)) {
22014
+ const name2 = toolCall.name.slice(namespacedPrefix.length);
22015
+ return mcpToolName.test(name2) ? { name: name2, args: args2, lazy: false } : null;
22016
+ }
22017
+ const name = toolCall.name.startsWith(oldPrefix) ? toolCall.name.slice(oldPrefix.length) : toolCall.name;
22018
+ return /^(?:platform_|promptframe_local_)[a-z0-9_]+$/i.test(name) && mcpToolName.test(name) ? { name, args: args2, lazy: false } : null;
22019
+ }
22020
+ function sessionId(value2) {
22021
+ return typeof value2 === "string" && threadFormat.test(value2) ? value2.toLowerCase() : null;
22022
+ }
22023
+ function transcriptDigest(input) {
22024
+ const file = input?.transcriptPath;
22025
+ return typeof file === "string" && file.length <= 4096 && path11.isAbsolute(file) ? digest4(path11.normalize(file)) : null;
22026
+ }
22027
+ function toolNameMatches(hookToolName, bridgeToolName) {
22028
+ if (typeof hookToolName !== "string" || typeof bridgeToolName !== "string" || !bridgeToolName) return false;
22029
+ if (hookToolName === bridgeToolName) return true;
22030
+ return hookToolName.endsWith("_" + bridgeToolName) || hookToolName.endsWith(":" + bridgeToolName);
22031
+ }
22032
+ async function privateDirectory2(directory3) {
22033
+ try {
22034
+ await mkdir5(directory3, { recursive: true, mode: 448 });
22035
+ } catch (e) {
22036
+ if (e.code !== "EEXIST") throw e;
22037
+ }
22038
+ const info5 = await lstat6(directory3);
22039
+ if (!info5.isDirectory() || info5.isSymbolicLink() || info5.uid !== process.getuid?.() || info5.mode & 63) throw error4("host_identity_unavailable");
22040
+ }
22041
+ async function privateRead2(file) {
22042
+ let handle;
22043
+ try {
22044
+ handle = await open7(file, constants6.O_RDONLY | constants6.O_NOFOLLOW);
22045
+ const info5 = await handle.stat();
22046
+ if (!info5.isFile() || info5.uid !== process.getuid?.() || info5.mode & 63 || info5.size > 262144) throw error4("host_identity_unavailable");
22047
+ return JSON.parse(await handle.readFile("utf8"));
22048
+ } catch (e) {
22049
+ if (e.code === "ENOENT") return null;
22050
+ throw e;
22051
+ } finally {
22052
+ await handle?.close();
22053
+ }
22054
+ }
22055
+ function antigravityConfigRoot(env = process.env) {
22056
+ return path11.resolve(env.ANTIGRAVITY_CONFIG_DIR ?? env.GEMINI_CONFIG_DIR ?? path11.join(homedir5(), ".gemini", "config"));
22057
+ }
22058
+ async function createAntigravityHostSession({ configFile: configFile2, env = process.env, root, serverName = DEFAULT_SERVER, now = () => Date.now() } = {}) {
22059
+ const base = root ?? path11.join(antigravityConfigRoot(env), "promptframe-host-sessions");
22060
+ const namespace = path11.join(base, digest4(path11.resolve(configFile2)));
22061
+ const stateFile = path11.join(namespace, "state.json");
22062
+ async function readState() {
22063
+ const value2 = await privateRead2(stateFile);
22064
+ if (!value2) return { contractVersion: "antigravity-host-session/v1", tickets: {} };
22065
+ if (value2.contractVersion !== "antigravity-host-session/v1" || !value2.tickets || typeof value2.tickets !== "object" || Array.isArray(value2.tickets) || Object.keys(value2.tickets).length > MAX_TICKETS + 32) throw error4("host_identity_unavailable");
22066
+ return value2;
22067
+ }
22068
+ async function transaction(work) {
22069
+ await privateDirectory2(base);
22070
+ await privateDirectory2(namespace);
22071
+ const lock = path11.join(namespace, "write.lock");
22072
+ let acquired = false;
22073
+ for (let count = 0; count < 100; count++) try {
22074
+ await mkdir5(lock, { mode: 448 });
22075
+ acquired = true;
22076
+ break;
22077
+ } catch (e) {
22078
+ if (e.code !== "EEXIST") throw e;
22079
+ await new Promise((resolve) => setTimeout(resolve, 10));
22080
+ }
22081
+ if (!acquired) throw error4("host_identity_unavailable");
22082
+ let temporary;
22083
+ try {
22084
+ const current = await readState();
22085
+ const next = await work(current);
22086
+ if (next === void 0) return;
22087
+ const body = JSON.stringify(next);
22088
+ if (Buffer.byteLength(body) > 262144) throw error4("host_identity_unavailable");
22089
+ temporary = path11.join(namespace, "state-" + randomBytes4(16).toString("hex") + ".partial");
22090
+ const file = await open7(temporary, constants6.O_WRONLY | constants6.O_CREAT | constants6.O_EXCL | constants6.O_NOFOLLOW, 384);
22091
+ try {
22092
+ await file.writeFile(body);
22093
+ await file.sync();
22094
+ } finally {
22095
+ await file.close();
22096
+ }
22097
+ await rename5(temporary, stateFile);
22098
+ temporary = void 0;
22099
+ const directory3 = await open7(namespace, constants6.O_RDONLY | constants6.O_DIRECTORY | constants6.O_NOFOLLOW);
22100
+ try {
22101
+ await directory3.sync();
22102
+ } finally {
22103
+ await directory3.close();
22104
+ }
22105
+ } finally {
22106
+ if (temporary) await unlink5(temporary).catch(() => {
22107
+ });
22108
+ await rmdir3(lock).catch(() => {
22109
+ });
22110
+ }
22111
+ }
22112
+ function pruneTickets(tickets, currentTime) {
22113
+ const kept = {};
22114
+ for (const [k2, v2] of Object.entries(tickets)) {
22115
+ if (v2 && typeof v2 === "object" && typeof v2.expiresAt === "number" && v2.expiresAt > currentTime && typeof v2.conversationId === "string" && threadFormat.test(v2.conversationId)) kept[k2] = v2;
22116
+ }
22117
+ const keys = Object.keys(kept);
22118
+ while (keys.length >= MAX_TICKETS) delete kept[keys.shift()];
22119
+ return kept;
22120
+ }
22121
+ function pruneSessions(sessions, currentTime) {
22122
+ const active = Object.entries(sessions ?? {}).filter(([id, value2]) => sessionId(id) && Number.isSafeInteger(value2?.expiresAt) && value2.expiresAt > currentTime);
22123
+ return Object.fromEntries(active.slice(-MAX_SESSIONS));
22124
+ }
22125
+ function bindSession(sessions, id, transcript, currentTime) {
22126
+ const previous = sessions[id];
22127
+ delete sessions[id];
22128
+ sessions[id] = { transcriptDigest: transcript ?? previous?.transcriptDigest ?? null, expiresAt: currentTime + SESSION_TTL_MS };
22129
+ return pruneSessions(sessions, currentTime);
22130
+ }
22131
+ async function begin(raw) {
22132
+ const proof = raw.arguments?.[CLAUDE_HOST_PROOF], args2 = withoutProof2(raw.arguments);
22133
+ if (proof === void 0) return { host: { kind: "antigravity" }, assertCurrent: async () => {
22134
+ }, arguments: args2 };
22135
+ if (typeof proof !== "string" || !hex2.test(proof)) throw error4("host_identity_invalid");
22136
+ const argsHash = digest4(args2), currentTime = now();
22137
+ let accepted;
22138
+ try {
22139
+ await transaction((current) => {
22140
+ const ticket = current.tickets[proof];
22141
+ if (!ticket || ticket.expiresAt <= currentTime || ticket.argsDigest !== argsHash || !(ticket.exactToolName ? ticket.toolName === raw.name : toolNameMatches(ticket.toolName, raw.name)) || !threadFormat.test(ticket.conversationId ?? ""))
22142
+ throw error4("host_identity_invalid");
22143
+ accepted = { threadId: ticket.conversationId.toLowerCase() };
22144
+ delete current.tickets[proof];
22145
+ current.tickets = pruneTickets(current.tickets, currentTime);
22146
+ return current;
22147
+ });
22148
+ } catch (e) {
22149
+ if (e instanceof CreationClientError) throw e;
22150
+ throw error4("host_identity_unavailable");
22151
+ }
22152
+ return { host: { kind: "antigravity", threadId: accepted.threadId }, arguments: args2, assertCurrent: async () => {
22153
+ } };
22154
+ }
22155
+ async function hook(input, event = input?.hookEventName ?? "PreToolUse") {
22156
+ if (input?.hookEventName !== void 0 && input.hookEventName !== event) return {};
22157
+ const id = sessionId(input?.conversationId), transcript = transcriptDigest(input), currentTime = now();
22158
+ if (event === "SessionStart") {
22159
+ if (id) await transaction((current) => {
22160
+ current.sessions = bindSession(pruneSessions(current.sessions, currentTime), id, transcript, currentTime);
22161
+ return current;
22162
+ });
22163
+ return {};
22164
+ }
22165
+ if (event !== "PreToolUse") return {};
22166
+ const call = promptFrameCall(input?.toolCall, serverName);
22167
+ if (!call) return { decision: "allow" };
22168
+ const args2 = withoutProof2(call.args), argsHash = digest4(args2);
22169
+ let token;
22170
+ await transaction((current) => {
22171
+ const sessions = pruneSessions(current.sessions, currentTime);
22172
+ const matches = !id && input?.conversationId === void 0 && transcript ? Object.keys(sessions).filter((key) => sessions[key].transcriptDigest === transcript) : [];
22173
+ const conversationId = id ?? (matches.length === 1 ? matches[0] : null);
22174
+ if (!conversationId) return;
22175
+ const tickets = pruneTickets(current.tickets, currentTime);
22176
+ token = randomBytes4(32).toString("hex");
22177
+ tickets[token] = { toolName: call.name, exactToolName: true, argsDigest: argsHash, conversationId, expiresAt: currentTime + TICKET_TTL_MS };
22178
+ return { contractVersion: "antigravity-host-session/v1", tickets, sessions: bindSession(sessions, conversationId, transcript, currentTime) };
22179
+ });
22180
+ if (!token) return Object.hasOwn(call.args, CLAUDE_HOST_PROOF) ? { decision: "deny", reason: "Missing valid Antigravity conversationId for PromptFrame proof." } : { decision: "allow" };
22181
+ return { decision: "allow", overwrite: call.lazy ? { Arguments: { ...args2, [CLAUDE_HOST_PROOF]: token } } : { [CLAUDE_HOST_PROOF]: token } };
22182
+ }
22183
+ return { begin, hook };
22184
+ }
22185
+ async function readAntigravityHookInput(input) {
22186
+ const chunks = [];
22187
+ let bytes2 = 0;
22188
+ for await (const value2 of input) {
22189
+ const chunk = Buffer.isBuffer(value2) ? value2 : Buffer.from(value2);
22190
+ bytes2 += chunk.length;
22191
+ if (bytes2 > 2 * 1024 * 1024 + 65536) throw error4("host_identity_invalid");
22192
+ chunks.push(chunk);
22193
+ }
22194
+ return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(chunks, bytes2)));
22195
+ }
22196
+ async function runAntigravityHostHook({ configFile: configFile2, serverName, event, input = process.stdin, output = process.stdout, env = process.env } = {}) {
22197
+ const body = await readAntigravityHookInput(input);
22198
+ const store = await createAntigravityHostSession({ configFile: configFile2, serverName, env });
22199
+ output.write(JSON.stringify(await store.hook(body, event)) + "\n");
22200
+ }
22201
+
21972
22202
  // lib/runtime-bootstrap.mjs
21973
- import { createHash as createHash8, randomBytes as randomBytes4 } from "node:crypto";
22203
+ import { createHash as createHash9, randomBytes as randomBytes5 } from "node:crypto";
21974
22204
  import { gunzipSync } from "node:zlib";
21975
22205
 
21976
22206
  // node_modules/tar/dist/esm/index.min.js
@@ -24943,18 +25173,18 @@ var To = (s3) => {
24943
25173
  };
24944
25174
 
24945
25175
  // lib/runtime-bootstrap.mjs
24946
- import { lstat as lstat7, mkdir as mkdir5, open as open7, readFile as readFile5, readdir as readdir3, rename as rename5, rm, statfs } from "node:fs/promises";
25176
+ import { lstat as lstat8, mkdir as mkdir6, open as open8, readFile as readFile5, readdir as readdir3, rename as rename6, rm, statfs } from "node:fs/promises";
24947
25177
  import { execFile } from "node:child_process";
24948
25178
  import { promisify } from "node:util";
24949
- import path12 from "node:path";
25179
+ import path13 from "node:path";
24950
25180
 
24951
25181
  // lib/runtime-package.mjs
24952
- import { lstat as lstat6, readdir as readdir2, readFile as readFile4 } from "node:fs/promises";
24953
- import { createHash as createHash7 } from "node:crypto";
24954
- import path11 from "node:path";
25182
+ import { lstat as lstat7, readdir as readdir2, readFile as readFile4 } from "node:fs/promises";
25183
+ import { createHash as createHash8 } from "node:crypto";
25184
+ import path12 from "node:path";
24955
25185
  var RUNTIME_PACKAGE_ENTRIES = Object.freeze(["package.json", "README.md", "LICENSE", "bin", "dist", "lib", "skills", "docs", ".codex-plugin", ".mcp.json"]);
24956
25186
  var OPTIONAL_HOST_ENTRIES = Object.freeze([".claude-plugin", ".claude-mcp.json"]);
24957
- var hash3 = (b2) => createHash7("sha256").update(b2).digest("hex");
25187
+ var hash3 = (b2) => createHash8("sha256").update(b2).digest("hex");
24958
25188
  var invalid = (code) => {
24959
25189
  throw new CreationClientError("installation." + code);
24960
25190
  };
@@ -24963,7 +25193,7 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
24963
25193
  entries2 = [...RUNTIME_PACKAGE_ENTRIES];
24964
25194
  for (const name of OPTIONAL_HOST_ENTRIES) {
24965
25195
  try {
24966
- await lstat6(path11.join(root, name));
25196
+ await lstat7(path12.join(root, name));
24967
25197
  entries2.push(name);
24968
25198
  } catch (e) {
24969
25199
  if (e.code !== "ENOENT") throw e;
@@ -24975,19 +25205,19 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
24975
25205
  async function walk(relative) {
24976
25206
  let s3;
24977
25207
  try {
24978
- s3 = await lstat6(path11.join(root, relative));
24979
- } catch (error5) {
24980
- if (error5.code !== "ENOENT") throw error5;
25208
+ s3 = await lstat7(path12.join(root, relative));
25209
+ } catch (error6) {
25210
+ if (error6.code !== "ENOENT") throw error6;
24981
25211
  }
24982
25212
  if (!s3 || s3.isSymbolicLink()) invalid("package_file_invalid");
24983
25213
  if (s3.isDirectory()) {
24984
- for (const name of (await readdir2(path11.join(root, relative))).sort()) {
25214
+ for (const name of (await readdir2(path12.join(root, relative))).sort()) {
24985
25215
  if (name === "node_modules" || name === "credentials.json" || name.startsWith(".env")) invalid("package_file_invalid");
24986
- await walk(path11.join(relative, name));
25216
+ await walk(path12.join(relative, name));
24987
25217
  }
24988
25218
  } else if (s3.isFile()) {
24989
25219
  if (s3.size > 32 * 1024 * 1024) invalid("package_too_large");
24990
- const body = await readFile4(path11.join(root, relative));
25220
+ const body = await readFile4(path12.join(root, relative));
24991
25221
  bytes2 += body.length;
24992
25222
  if (files.length >= 1024 || bytes2 > 32 * 1024 * 1024) invalid("package_too_large");
24993
25223
  files.push({ path: relative, bytes: body.length, sha256: hash3(body), body });
@@ -25000,11 +25230,13 @@ async function inspectRuntimePackage(root, { entries: entries2 } = {}) {
25000
25230
  if (pkg.name !== "@promptframe/creation" || !/^\d+\.\d+\.\d+$/.test(pkg.version) || plugin.version !== pkg.version) invalid("package_identity_invalid");
25001
25231
  const claude = files.find((f2) => f2.path === ".claude-plugin/plugin.json");
25002
25232
  if (claude && JSON.parse(claude.body).version !== pkg.version) invalid("package_identity_invalid");
25233
+ const antigravity = files.some((f2) => f2.path === "lib/antigravity-host-session.mjs");
25234
+ const hosts = ["codex", ...claude ? ["claude-code"] : [], ...antigravity ? ["antigravity"] : []];
25003
25235
  return {
25004
25236
  files,
25005
25237
  version: pkg.version,
25006
- hosts: claude ? ["codex", "claude-code"] : ["codex"],
25007
- payloadDigest: hash3(JSON.stringify(files.map(({ path: path21, bytes: bytes3, sha256 }) => ({ path: path21, bytes: bytes3, sha256 }))))
25238
+ hosts,
25239
+ payloadDigest: hash3(JSON.stringify(files.map(({ path: path23, bytes: bytes3, sha256 }) => ({ path: path23, bytes: bytes3, sha256 }))))
25008
25240
  };
25009
25241
  }
25010
25242
 
@@ -25014,9 +25246,9 @@ var REGISTRY = "https://registry.npmjs.org";
25014
25246
  var MAX_ARCHIVE = 8 * 1024 * 1024;
25015
25247
  var MAX_PAYLOAD = 32 * 1024 * 1024;
25016
25248
  var MAX_TAR = 36 * 1024 * 1024;
25017
- var hash4 = (b2) => createHash8("sha256").update(b2).digest("hex");
25249
+ var hash4 = (b2) => createHash9("sha256").update(b2).digest("hex");
25018
25250
  var execute = promisify(execFile);
25019
- var error4 = (code) => new CreationClientError("creation." + code);
25251
+ var error5 = (code) => new CreationClientError("creation." + code);
25020
25252
  var version2 = (v2) => {
25021
25253
  compareBridgeVersions(v2, v2);
25022
25254
  return v2;
@@ -25034,34 +25266,34 @@ var RuntimeSelectionError = class extends CreationClientError {
25034
25266
  });
25035
25267
  }
25036
25268
  };
25037
- var runtimeErrorDetails = (error5) => error5 instanceof RuntimeSelectionError ? error5.runtimeFacts : void 0;
25269
+ var runtimeErrorDetails = (error6) => error6 instanceof RuntimeSelectionError ? error6.runtimeFacts : void 0;
25038
25270
  var snapshot = (payload) => ({
25039
25271
  version: payload.version,
25040
25272
  hosts: payload.hosts,
25041
25273
  payloadDigest: payload.payloadDigest,
25042
- files: payload.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))
25274
+ files: payload.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))
25043
25275
  });
25044
25276
  async function info(file) {
25045
25277
  try {
25046
- return await lstat7(file);
25278
+ return await lstat8(file);
25047
25279
  } catch (e) {
25048
25280
  if (e.code === "ENOENT") return null;
25049
25281
  throw e;
25050
25282
  }
25051
25283
  }
25052
- async function privateDirectory2(dir) {
25053
- await mkdir5(dir, { recursive: true, mode: 448 });
25054
- const s3 = await lstat7(dir);
25055
- if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) throw error4("runtime_cache_owner_invalid");
25284
+ async function privateDirectory3(dir) {
25285
+ await mkdir6(dir, { recursive: true, mode: 448 });
25286
+ const s3 = await lstat8(dir);
25287
+ if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) throw error5("runtime_cache_owner_invalid");
25056
25288
  }
25057
25289
  async function privateJSON(file) {
25058
25290
  const s3 = await info(file);
25059
25291
  if (!s3) return null;
25060
- if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) throw error4("runtime_cache_invalid");
25292
+ if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) throw error5("runtime_cache_invalid");
25061
25293
  return JSON.parse(await readFile5(file, "utf8"));
25062
25294
  }
25063
25295
  async function syncDirectory2(dir) {
25064
- const fd = await open7(dir, "r");
25296
+ const fd = await open8(dir, "r");
25065
25297
  try {
25066
25298
  await fd.sync();
25067
25299
  } finally {
@@ -25069,7 +25301,7 @@ async function syncDirectory2(dir) {
25069
25301
  }
25070
25302
  }
25071
25303
  async function exclusiveJSON(file, value2) {
25072
- const fd = await open7(file, "wx", 384);
25304
+ const fd = await open8(file, "wx", 384);
25073
25305
  try {
25074
25306
  await fd.writeFile(JSON.stringify(value2) + "\n");
25075
25307
  await fd.sync();
@@ -25081,9 +25313,9 @@ function checkedRuntimeMetadata(value2, expectedVersion) {
25081
25313
  version2(expectedVersion);
25082
25314
  const tarball = REGISTRY + "/@promptframe/creation/-/creation-" + expectedVersion + ".tgz";
25083
25315
  if (value2?.name !== PACKAGE || value2.version !== expectedVersion || value2.dist?.tarball !== tarball || typeof value2.dist.integrity !== "string" || !/^sha512-[A-Za-z0-9+/]{86}==$/.test(value2.dist.integrity))
25084
- throw error4("runtime_registry_identity_invalid");
25316
+ throw error5("runtime_registry_identity_invalid");
25085
25317
  const encoded = value2.dist.integrity.slice(7);
25086
- if (Buffer.from(encoded, "base64").toString("base64") !== encoded) throw error4("runtime_registry_identity_invalid");
25318
+ if (Buffer.from(encoded, "base64").toString("base64") !== encoded) throw error5("runtime_registry_identity_invalid");
25087
25319
  return { version: expectedVersion, integrity: value2.dist.integrity, tarball };
25088
25320
  }
25089
25321
  async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2, timeoutMs }) {
@@ -25093,12 +25325,12 @@ async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2
25093
25325
  let response;
25094
25326
  try {
25095
25327
  response = await fetchImpl(url2, { signal: controller.signal, redirect: "error" });
25096
- if (response.status !== 200 || Number(response.headers.get("content-length") ?? 0) > maxBytes2 || !response.body) throw error4("runtime_fetch_unavailable");
25328
+ if (response.status !== 200 || Number(response.headers.get("content-length") ?? 0) > maxBytes2 || !response.body) throw error5("runtime_fetch_unavailable");
25097
25329
  const chunks = [];
25098
25330
  let count = 0;
25099
25331
  for await (const chunk of response.body) {
25100
25332
  count += chunk.length;
25101
- if (count > maxBytes2) throw error4("runtime_download_capacity");
25333
+ if (count > maxBytes2) throw error5("runtime_download_capacity");
25102
25334
  chunks.push(Buffer.from(chunk));
25103
25335
  }
25104
25336
  return Buffer.concat(chunks, count);
@@ -25106,68 +25338,68 @@ async function boundedGet(url2, { fetchImpl = fetch, signal, maxBytes: maxBytes2
25106
25338
  await response?.body?.cancel().catch(() => {
25107
25339
  });
25108
25340
  if (e instanceof CreationClientError) throw e;
25109
- throw error4("runtime_fetch_unavailable");
25341
+ throw error5("runtime_fetch_unavailable");
25110
25342
  } finally {
25111
25343
  clearTimeout(timer);
25112
25344
  signal?.removeEventListener("abort", abort);
25113
25345
  }
25114
25346
  }
25115
25347
  async function readRuntimeArchive(archive, metadata) {
25116
- if (!Buffer.isBuffer(archive) || archive.length > MAX_ARCHIVE || "sha512-" + createHash8("sha512").update(archive).digest("base64") !== metadata.integrity) throw error4("runtime_integrity_invalid");
25348
+ if (!Buffer.isBuffer(archive) || archive.length > MAX_ARCHIVE || "sha512-" + createHash9("sha512").update(archive).digest("base64") !== metadata.integrity) throw error5("runtime_integrity_invalid");
25117
25349
  let raw;
25118
25350
  try {
25119
25351
  raw = gunzipSync(archive, { maxOutputLength: MAX_TAR });
25120
25352
  } catch {
25121
- throw error4("runtime_archive_invalid");
25353
+ throw error5("runtime_archive_invalid");
25122
25354
  }
25123
25355
  const files = [], names = /* @__PURE__ */ new Set();
25124
25356
  let total = 0, entries2 = 0, failure4;
25125
25357
  const parser = Ct({ strict: true, onReadEntry: (entry) => {
25126
25358
  const name = entry.path;
25127
- if (++entries2 > 2048 || !["File", "Directory"].includes(entry.type) || !Number.isSafeInteger(entry.size) || entry.size < 0 || entry.size > MAX_PAYLOAD || typeof name !== "string" || name.length > 240 || !name.startsWith("package/") || name.includes("\\") || /[\x00-\x1f\x7f]/.test(name)) failure4 = error4("runtime_archive_invalid");
25359
+ if (++entries2 > 2048 || !["File", "Directory"].includes(entry.type) || !Number.isSafeInteger(entry.size) || entry.size < 0 || entry.size > MAX_PAYLOAD || typeof name !== "string" || name.length > 240 || !name.startsWith("package/") || name.includes("\\") || /[\x00-\x1f\x7f]/.test(name)) failure4 = error5("runtime_archive_invalid");
25128
25360
  const relative = name.slice(8).replace(/\/$/, "");
25129
25361
  if (relative && (relative.normalize("NFC") !== relative || /[<>:"|?*]/.test(relative) || relative.split("/").some((p2) => !p2 || p2 === "." || p2 === ".." || /[. ]$/.test(p2) || /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(p2) || p2 === "node_modules" || p2 === "credentials.json" || p2.startsWith(".env")) || !roots.has(relative.split("/")[0])))
25130
- failure4 = error4("runtime_archive_invalid");
25362
+ failure4 = error5("runtime_archive_invalid");
25131
25363
  const portableName = relative.toLowerCase();
25132
- if (names.has(portableName)) failure4 = error4("runtime_archive_invalid");
25364
+ if (names.has(portableName)) failure4 = error5("runtime_archive_invalid");
25133
25365
  names.add(portableName);
25134
25366
  if (entry.type === "Directory") {
25135
- if (entry.size !== 0) failure4 = error4("runtime_archive_invalid");
25367
+ if (entry.size !== 0) failure4 = error5("runtime_archive_invalid");
25136
25368
  return;
25137
25369
  }
25138
25370
  total += entry.size;
25139
- if (total > MAX_PAYLOAD || files.length >= 1024 || !relative) failure4 = error4("runtime_archive_capacity");
25371
+ if (total > MAX_PAYLOAD || files.length >= 1024 || !relative) failure4 = error5("runtime_archive_capacity");
25140
25372
  const chunks = [];
25141
25373
  let bytes2 = 0;
25142
25374
  entry.on("data", (chunk) => {
25143
25375
  bytes2 += chunk.length;
25144
- if (bytes2 > entry.size) failure4 = error4("runtime_archive_invalid");
25376
+ if (bytes2 > entry.size) failure4 = error5("runtime_archive_invalid");
25145
25377
  if (!failure4) chunks.push(Buffer.from(chunk));
25146
25378
  });
25147
25379
  entry.on("end", () => {
25148
- if (bytes2 !== entry.size) failure4 = error4("runtime_archive_invalid");
25380
+ if (bytes2 !== entry.size) failure4 = error5("runtime_archive_invalid");
25149
25381
  if (!failure4) files.push({ path: relative, body: Buffer.concat(chunks, bytes2) });
25150
25382
  });
25151
25383
  } });
25152
25384
  await new Promise((resolve, reject) => {
25153
- parser.once("error", () => reject(error4("runtime_archive_invalid")));
25385
+ parser.once("error", () => reject(error5("runtime_archive_invalid")));
25154
25386
  parser.once("end", resolve);
25155
25387
  parser.end(raw);
25156
25388
  });
25157
25389
  if (failure4) throw failure4;
25158
- if (!files.length || files.length > 1024) throw error4("runtime_archive_invalid");
25390
+ if (!files.length || files.length > 1024) throw error5("runtime_archive_invalid");
25159
25391
  return files;
25160
25392
  }
25161
25393
  async function cacheLock(root, signal) {
25162
- const name = path12.join(root, "prepare.lock"), end = Date.now() + 5e3;
25394
+ const name = path13.join(root, "prepare.lock"), end = Date.now() + 5e3;
25163
25395
  let fd;
25164
25396
  while (!fd) {
25165
25397
  signal?.throwIfAborted();
25166
25398
  try {
25167
- fd = await open7(name, "wx", 384);
25399
+ fd = await open8(name, "wx", 384);
25168
25400
  } catch (e) {
25169
25401
  if (e.code !== "EEXIST") throw e;
25170
- if (Date.now() >= end) throw error4("runtime_cache_busy");
25402
+ if (Date.now() >= end) throw error5("runtime_cache_busy");
25171
25403
  await pause(50);
25172
25404
  }
25173
25405
  }
@@ -25185,51 +25417,51 @@ async function cacheLock(root, signal) {
25185
25417
  return async () => {
25186
25418
  const now = await info(name);
25187
25419
  await fd.close();
25188
- if (!now || now.dev !== owned.dev || now.ino !== owned.ino) throw error4("runtime_lock_changed");
25420
+ if (!now || now.dev !== owned.dev || now.ino !== owned.ino) throw error5("runtime_lock_changed");
25189
25421
  await rm(name);
25190
25422
  };
25191
25423
  }
25192
25424
  async function verifyCached(target, metadata, hostKind) {
25193
25425
  if (!await info(target)) return null;
25194
- await privateDirectory2(target);
25195
- const manifest = await privateJSON(path12.join(target, "runtime.json"));
25426
+ await privateDirectory3(target);
25427
+ const manifest = await privateJSON(path13.join(target, "runtime.json"));
25196
25428
  if (!manifest || manifest.contractVersion !== "creation-verified-runtime/v1" || manifest.version !== metadata.version || manifest.integrity !== metadata.integrity)
25197
- throw error4("runtime_cache_invalid");
25429
+ throw error5("runtime_cache_invalid");
25198
25430
  const names = (await readdir3(target)).filter((name) => name !== "runtime.json").sort();
25199
- if (names.some((name) => !roots.has(name)) || RUNTIME_PACKAGE_ENTRIES.some((name) => !names.includes(name))) throw error4("runtime_cache_invalid");
25431
+ if (names.some((name) => !roots.has(name)) || RUNTIME_PACKAGE_ENTRIES.some((name) => !names.includes(name))) throw error5("runtime_cache_invalid");
25200
25432
  const payload = await inspectRuntimePackage(target, { entries: names });
25201
- if (!payload.hosts.includes(hostKind)) throw error4("runtime_host_unsupported");
25202
- if (JSON.stringify(snapshot(payload)) !== JSON.stringify(manifest.payload)) throw error4("runtime_cache_invalid");
25433
+ if (!payload.hosts.includes(hostKind)) throw error5("runtime_host_unsupported");
25434
+ if (JSON.stringify(snapshot(payload)) !== JSON.stringify(manifest.payload)) throw error5("runtime_cache_invalid");
25203
25435
  return { version: payload.version, root: target, integrity: metadata.integrity, reused: true };
25204
25436
  }
25205
25437
  async function checkedVersionIndex(cacheRoot, metadata) {
25206
- const old = await privateJSON(path12.join(cacheRoot, "version-" + metadata.version + ".json"));
25207
- if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw error4("runtime_registry_identity_conflict");
25438
+ const old = await privateJSON(path13.join(cacheRoot, "version-" + metadata.version + ".json"));
25439
+ if (old && JSON.stringify(old) !== JSON.stringify(metadata)) throw error5("runtime_registry_identity_conflict");
25208
25440
  return old;
25209
25441
  }
25210
25442
  async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
25211
- if (!["codex", "claude-code"].includes(hostKind)) throw error4("runtime_host_unsupported");
25212
- if (!path12.isAbsolute(cacheRoot ?? "")) throw error4("runtime_cache_owner_invalid");
25443
+ if (!SUPPORTED_HOSTS.includes(hostKind)) throw error5("runtime_host_unsupported");
25444
+ if (!path13.isAbsolute(cacheRoot ?? "")) throw error5("runtime_cache_owner_invalid");
25213
25445
  metadata = checkedRuntimeMetadata({ name: PACKAGE, version: metadata.version, dist: metadata }, metadata.version);
25214
- await privateDirectory2(cacheRoot);
25446
+ await privateDirectory3(cacheRoot);
25215
25447
  await checkedVersionIndex(cacheRoot, metadata);
25216
- const target = path12.join(cacheRoot, metadata.version + "-" + hash4(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
25448
+ const target = path13.join(cacheRoot, metadata.version + "-" + hash4(metadata.integrity)), existing = await verifyCached(target, metadata, hostKind);
25217
25449
  if (existing) return existing;
25218
25450
  const archive = await boundedGet(metadata.tarball, { fetchImpl, signal, maxBytes: MAX_ARCHIVE, timeoutMs: 15e3 });
25219
25451
  const files = await readRuntimeArchive(archive, metadata), release = await cacheLock(cacheRoot, signal);
25220
- const temporary = path12.join(cacheRoot, ".partial-" + randomBytes4(12).toString("hex"));
25452
+ const temporary = path13.join(cacheRoot, ".partial-" + randomBytes5(12).toString("hex"));
25221
25453
  try {
25222
25454
  const index = await checkedVersionIndex(cacheRoot, metadata);
25223
25455
  const found = await verifyCached(target, metadata, hostKind);
25224
25456
  if (found) return found;
25225
25457
  const space = await statfs(cacheRoot, { bigint: true }), needed = BigInt(files.reduce((n, f2) => n + f2.body.length, 0) + 4 * 1024 * 1024);
25226
- if (space.bavail * space.bsize < needed) throw error4("runtime_cache_capacity");
25227
- await mkdir5(temporary, { mode: 448 });
25458
+ if (space.bavail * space.bsize < needed) throw error5("runtime_cache_capacity");
25459
+ await mkdir6(temporary, { mode: 448 });
25228
25460
  for (const file of files) {
25229
25461
  signal?.throwIfAborted();
25230
- const dest = path12.join(temporary, ...file.path.split("/"));
25231
- await mkdir5(path12.dirname(dest), { recursive: true, mode: 448 });
25232
- const fd = await open7(dest, "wx", 384);
25462
+ const dest = path13.join(temporary, ...file.path.split("/"));
25463
+ await mkdir6(path13.dirname(dest), { recursive: true, mode: 448 });
25464
+ const fd = await open8(dest, "wx", 384);
25233
25465
  try {
25234
25466
  await fd.writeFile(file.body);
25235
25467
  await fd.sync();
@@ -25238,26 +25470,26 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
25238
25470
  }
25239
25471
  }
25240
25472
  const entries2 = [...new Set(files.map((file) => file.path.split("/")[0]))].sort();
25241
- if (RUNTIME_PACKAGE_ENTRIES.some((name) => !entries2.includes(name))) throw error4("runtime_package_incomplete");
25473
+ if (RUNTIME_PACKAGE_ENTRIES.some((name) => !entries2.includes(name))) throw error5("runtime_package_incomplete");
25242
25474
  const payload = await inspectRuntimePackage(temporary, { entries: entries2 });
25243
- if (!payload.hosts.includes(hostKind)) throw error4("runtime_host_unsupported");
25244
- if (payload.version !== metadata.version) throw error4("runtime_package_version_invalid");
25475
+ if (!payload.hosts.includes(hostKind)) throw error5("runtime_host_unsupported");
25476
+ if (payload.version !== metadata.version) throw error5("runtime_package_version_invalid");
25245
25477
  const pkg = JSON.parse(payload.files.find((f2) => f2.path === "package.json").body);
25246
- if (pkg.repository?.url !== "git+https://github.com/ty-teams/promptframe-creation.git" || pkg.private === true) throw error4("runtime_package_identity_invalid");
25478
+ if (pkg.repository?.url !== "git+https://github.com/ty-teams/promptframe-creation.git" || pkg.private === true) throw error5("runtime_package_identity_invalid");
25247
25479
  if (checkRuntime) await checkRuntime(temporary, metadata.version);
25248
25480
  else {
25249
25481
  const result = await execute(
25250
25482
  process.execPath,
25251
- [path12.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
25483
+ [path13.join(temporary, "bin/promptframe-creation.mjs"), "--version"],
25252
25484
  { timeout: 5e3, maxBuffer: 65536, windowsHide: true, signal, env: {
25253
25485
  ...process.env,
25254
- PROMPTFRAME_CREATION_CONFIG: path12.join(temporary, "no-credentials.json")
25486
+ PROMPTFRAME_CREATION_CONFIG: path13.join(temporary, "no-credentials.json")
25255
25487
  } }
25256
25488
  );
25257
- if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw error4("runtime_package_version_invalid");
25489
+ if (result.stdout.trim() !== metadata.version || result.stderr.trim()) throw error5("runtime_package_version_invalid");
25258
25490
  }
25259
25491
  signal?.throwIfAborted();
25260
- await exclusiveJSON(path12.join(temporary, "runtime.json"), {
25492
+ await exclusiveJSON(path13.join(temporary, "runtime.json"), {
25261
25493
  contractVersion: "creation-verified-runtime/v1",
25262
25494
  version: metadata.version,
25263
25495
  integrity: metadata.integrity,
@@ -25265,10 +25497,10 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
25265
25497
  });
25266
25498
  await syncDirectory2(temporary);
25267
25499
  if (!index) {
25268
- await exclusiveJSON(path12.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
25500
+ await exclusiveJSON(path13.join(cacheRoot, "version-" + metadata.version + ".json"), metadata);
25269
25501
  await syncDirectory2(cacheRoot);
25270
25502
  }
25271
- await rename5(temporary, target);
25503
+ await rename6(temporary, target);
25272
25504
  await syncDirectory2(cacheRoot);
25273
25505
  return { version: metadata.version, root: target, integrity: metadata.integrity, reused: false };
25274
25506
  } finally {
@@ -25282,7 +25514,7 @@ async function prepareVerifiedRuntime(metadata, { cacheRoot, fetchImpl = fetch,
25282
25514
  async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, resolvedVersion, cacheRoot, fetchImpl = fetch, signal, checkRuntime, hostKind = "codex" } = {}) {
25283
25515
  version2(currentVersion);
25284
25516
  if (lockedVersion !== void 0) version2(lockedVersion);
25285
- if (resolvedVersion !== void 0 && resolvedVersion !== currentVersion) throw error4("runtime_selection_identity_invalid");
25517
+ if (resolvedVersion !== void 0 && resolvedVersion !== currentVersion) throw error5("runtime_selection_identity_invalid");
25286
25518
  if (!policy) throw new RuntimeSelectionError(
25287
25519
  "platform_bridge_policy_unavailable",
25288
25520
  currentVersion,
@@ -25301,13 +25533,13 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
25301
25533
  return { version: currentVersion, current: true, locked: lockedVersion !== void 0, status: "current" };
25302
25534
  }
25303
25535
  try {
25304
- await privateDirectory2(cacheRoot);
25536
+ await privateDirectory3(cacheRoot);
25305
25537
  let metadata, metadataSource = "registry";
25306
25538
  try {
25307
25539
  const raw = await boundedGet(REGISTRY + "/@promptframe%2fcreation/" + target, { fetchImpl, signal, maxBytes: 256 * 1024, timeoutMs: 5e3 });
25308
25540
  metadata = checkedRuntimeMetadata(JSON.parse(raw), target);
25309
25541
  } catch (e) {
25310
- const prior = await privateJSON(path12.join(cacheRoot, "version-" + target + ".json"));
25542
+ const prior = await privateJSON(path13.join(cacheRoot, "version-" + target + ".json"));
25311
25543
  if (!prior) throw e;
25312
25544
  metadata = checkedRuntimeMetadata({ name: PACKAGE, version: target, dist: prior }, target);
25313
25545
  metadataSource = "previously-verified-cache";
@@ -25320,29 +25552,29 @@ async function selectBridgeRuntime({ policy, currentVersion, lockedVersion, reso
25320
25552
  metadataSource
25321
25553
  };
25322
25554
  } catch (e) {
25323
- if (signal?.aborted) throw error4("runtime_selection_interrupted");
25555
+ if (signal?.aborted) throw error5("runtime_selection_interrupted");
25324
25556
  if (lockedVersion !== void 0)
25325
25557
  throw new RuntimeSelectionError("bridge_locked_version_unavailable", currentVersion, lockedVersion, policy, "retry_same_fixed_version_in_new_session");
25326
25558
  if (policy && compareBridgeVersions(currentVersion, policy.minBridge) >= 0)
25327
25559
  return { version: currentVersion, current: true, locked: false, status: "update_unavailable_current_compatible" };
25328
25560
  if (policy) assertBridgeCompatible({ experimental: { "promptframe.creation": policy } }, currentVersion);
25329
25561
  if (e instanceof CreationClientError) throw e;
25330
- throw error4("runtime_selection_unavailable");
25562
+ throw error5("runtime_selection_unavailable");
25331
25563
  }
25332
25564
  }
25333
25565
 
25334
25566
  // lib/runtime-launch.mjs
25335
25567
  import { spawn } from "node:child_process";
25336
- import path13 from "node:path";
25568
+ import path14 from "node:path";
25337
25569
  async function launchSelectedBridge(selection, { host, configFile: configFile2, spawnImpl = spawn, env = process.env } = {}) {
25338
- if (!path13.isAbsolute(selection.root ?? "") || !path13.isAbsolute(configFile2 ?? "") || !["codex", "claude-code"].includes(host?.kind))
25570
+ if (!path14.isAbsolute(selection.root ?? "") || !path14.isAbsolute(configFile2 ?? "") || !SUPPORTED_HOSTS.includes(host?.kind))
25339
25571
  throw new CreationClientError("creation.runtime_launch_invalid");
25340
25572
  let child;
25341
25573
  try {
25342
25574
  child = spawnImpl(
25343
25575
  process.execPath,
25344
25576
  [
25345
- path13.join(selection.root, "bin/promptframe-creation.mjs"),
25577
+ path14.join(selection.root, "bin/promptframe-creation.mjs"),
25346
25578
  "bridge",
25347
25579
  "--config",
25348
25580
  configFile2,
@@ -25384,10 +25616,10 @@ async function launchSelectedBridge(selection, { host, configFile: configFile2,
25384
25616
  // lib/user-installation.mjs
25385
25617
  import { execFile as execFile2 } from "node:child_process";
25386
25618
  import { promisify as promisify2 } from "node:util";
25387
- import { createHash as createHash9, randomBytes as randomBytes5 } from "node:crypto";
25388
- import { lstat as lstat8, mkdir as mkdir6, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename6, rm as rm2, open as open8 } from "node:fs/promises";
25389
- import { homedir as homedir5 } from "node:os";
25390
- import path14 from "node:path";
25619
+ import { createHash as createHash10, randomBytes as randomBytes6 } from "node:crypto";
25620
+ import { lstat as lstat9, mkdir as mkdir7, readdir as readdir4, readFile as readFile6, writeFile as writeFile2, rename as rename7, rm as rm2, open as open9 } from "node:fs/promises";
25621
+ import { homedir as homedir6 } from "node:os";
25622
+ import path15 from "node:path";
25391
25623
 
25392
25624
  // node_modules/smol-toml/dist/error.js
25393
25625
  function getLineColFromPtr(string4, ptr) {
@@ -25479,14 +25711,14 @@ function parseString(ctx) {
25479
25711
  let value2 = 0;
25480
25712
  let len = c === 120 ? 2 : c === 117 ? 4 : 8;
25481
25713
  for (let j2 = 0; j2 < len; j2++, ctx.p++) {
25482
- let hex2 = ctx.s.charCodeAt(ctx.p);
25714
+ let hex3 = ctx.s.charCodeAt(ctx.p);
25483
25715
  let digit = (
25484
25716
  /* 0-9 */
25485
- hex2 >= 48 && hex2 <= 57 ? hex2 - 48 : (
25717
+ hex3 >= 48 && hex3 <= 57 ? hex3 - 48 : (
25486
25718
  /* A-F */
25487
- hex2 >= 65 && hex2 <= 70 ? hex2 - 65 + 10 : (
25719
+ hex3 >= 65 && hex3 <= 70 ? hex3 - 65 + 10 : (
25488
25720
  /* a-f */
25489
- hex2 >= 97 && hex2 <= 102 ? hex2 - 97 + 10 : -1
25721
+ hex3 >= 97 && hex3 <= 102 ? hex3 - 97 + 10 : -1
25490
25722
  )
25491
25723
  )
25492
25724
  );
@@ -26149,7 +26381,7 @@ var HAS_WELLFORMED = !!"".isWellFormed;
26149
26381
 
26150
26382
  // lib/user-installation.mjs
26151
26383
  var execute2 = promisify2(execFile2);
26152
- var hash5 = (b2) => createHash9("sha256").update(b2).digest("hex");
26384
+ var hash5 = (b2) => createHash10("sha256").update(b2).digest("hex");
26153
26385
  var InstallationError = class extends CreationClientError {
26154
26386
  constructor(code, details) {
26155
26387
  super("installation." + code);
@@ -26159,7 +26391,7 @@ var InstallationError = class extends CreationClientError {
26159
26391
  var fail4 = (code, details) => {
26160
26392
  throw new InstallationError(code, details);
26161
26393
  };
26162
- var installationErrorDetails = (error5) => error5 instanceof InstallationError ? error5.details : void 0;
26394
+ var installationErrorDetails = (error6) => error6 instanceof InstallationError ? error6.details : void 0;
26163
26395
  function compareVersions(a, b2) {
26164
26396
  const left = a.split(".").map(BigInt), right = b2.split(".").map(BigInt);
26165
26397
  for (let i = 0; i < 3; i++) {
@@ -26188,8 +26420,8 @@ function validProfile(profile) {
26188
26420
  }
26189
26421
  function profileCredentialsPath(profile = "default", env = process.env) {
26190
26422
  validProfile(profile);
26191
- return profile === "default" ? credentialsPath(env) : path14.resolve(
26192
- env.XDG_CONFIG_HOME ?? path14.join(homedir5(), ".config"),
26423
+ return profile === "default" ? credentialsPath(env) : path15.resolve(
26424
+ env.XDG_CONFIG_HOME ?? path15.join(homedir6(), ".config"),
26193
26425
  "promptframe-creation",
26194
26426
  "profiles",
26195
26427
  profile,
@@ -26198,18 +26430,18 @@ function profileCredentialsPath(profile = "default", env = process.env) {
26198
26430
  }
26199
26431
  async function info2(file) {
26200
26432
  try {
26201
- return await lstat8(file);
26433
+ return await lstat9(file);
26202
26434
  } catch (e) {
26203
26435
  if (e.code === "ENOENT") return null;
26204
26436
  throw e;
26205
26437
  }
26206
26438
  }
26207
- async function privateDirectory3(dir) {
26208
- await mkdir6(dir, { recursive: true, mode: 448 });
26209
- const s3 = await lstat8(dir);
26439
+ async function privateDirectory4(dir) {
26440
+ await mkdir7(dir, { recursive: true, mode: 448 });
26441
+ const s3 = await lstat9(dir);
26210
26442
  if (!s3.isDirectory() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63) fail4("private_owner_required");
26211
26443
  }
26212
- async function privateRead2(file) {
26444
+ async function privateRead3(file) {
26213
26445
  const s3 = await info2(file);
26214
26446
  if (!s3) return null;
26215
26447
  if (!s3.isFile() || s3.isSymbolicLink() || s3.uid !== process.getuid?.() || s3.mode & 63 || s3.size > 512 * 1024) fail4("state_invalid");
@@ -26221,20 +26453,20 @@ async function packageJSON(file) {
26221
26453
  return json(file);
26222
26454
  }
26223
26455
  function sameTransport(actual, expected) {
26224
- return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path14.resolve(actual.cwd) === path14.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
26456
+ return actual?.type === "stdio" && actual.command === expected.command && typeof actual.cwd === "string" && path15.resolve(actual.cwd) === path15.resolve(expected.cwd) && JSON.stringify(actual.args) === JSON.stringify(expected.args) && JSON.stringify(actual.env_vars ?? []) === JSON.stringify(expected.env_vars ?? []) && !Object.keys(actual.env ?? {}).length;
26225
26457
  }
26226
26458
  async function managedTransport(installed, versions, serverName, profile, configFile2) {
26227
26459
  if (!installed) return null;
26228
26460
  const root = installed.source?.path;
26229
- if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path14.join(versions, installed.version)) fail4("existing_registration_requires_review");
26230
- const directory3 = await info2(root), definition = await info2(path14.join(root, ".mcp.json"));
26461
+ if (installed.source?.source !== "local" || typeof root !== "string" || !/^\d+\.\d+\.\d+$/.test(installed.version ?? "") || root !== path15.join(versions, installed.version)) fail4("existing_registration_requires_review");
26462
+ const directory3 = await info2(root), definition = await info2(path15.join(root, ".mcp.json"));
26231
26463
  if (!directory3?.isDirectory() || directory3.isSymbolicLink() || !definition?.isFile() || definition.isSymbolicLink()) fail4("installed_files_invalid");
26232
- const ready = await privateRead2(path14.join(root, "installation.json"));
26464
+ const ready = await privateRead3(path15.join(root, "installation.json"));
26233
26465
  if (!ready || ready.profile !== profile || ready.configFile !== configFile2 || ready.version !== installed.version) fail4("existing_registration_requires_review");
26234
- const bytes2 = await readFile6(path14.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
26466
+ const bytes2 = await readFile6(path15.join(root, ".mcp.json")), entry = ready.files?.find((x) => x.path === ".mcp.json");
26235
26467
  if (!entry || entry.bytes !== bytes2.length || entry.sha256 !== hash5(bytes2)) fail4("installed_files_invalid");
26236
26468
  const mcp = JSON.parse(bytes2).mcpServers?.[serverName];
26237
- if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path14.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
26469
+ if (!mcp || typeof mcp.command !== "string" || !mcp.command || mcp.cwd !== root || JSON.stringify(mcp.args) !== JSON.stringify([path15.join(root, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2])) fail4("existing_registration_requires_review");
26238
26470
  return mcp;
26239
26471
  }
26240
26472
  async function officialNpmInstallation(installed, servers, env, profile, configFile2) {
@@ -26242,12 +26474,12 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
26242
26474
  const candidates = installed.filter((p3) => p3.enabled === true && p3.name === "promptframe-creation" && p3.pluginId === "promptframe-creation@" + p3.marketplaceName && /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(p3.marketplaceName ?? "") && /^\d+\.\d+\.\d+$/.test(p3.version ?? "") && p3.source?.source === "npm" && p3.source.package === "@promptframe/creation" && p3.source.version === p3.version && ["https://registry.npmjs.org", "https://registry.npmjs.org/"].includes(p3.source.registry));
26243
26475
  if (candidates.length > 1) fail4("existing_registration_requires_review");
26244
26476
  if (!candidates.length) return null;
26245
- const p2 = candidates[0], root = path14.join(path14.resolve(env.CODEX_HOME ?? path14.join(homedir5(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
26477
+ const p2 = candidates[0], root = path15.join(path15.resolve(env.CODEX_HOME ?? path15.join(homedir6(), ".codex")), "plugins/cache", p2.marketplaceName, p2.name, p2.version);
26246
26478
  const directory3 = await info2(root);
26247
26479
  if (!directory3?.isDirectory() || directory3.isSymbolicLink()) fail4("installed_files_invalid");
26248
- const pkg = await packageJSON(path14.join(root, "package.json")), manifest = await packageJSON(path14.join(root, ".codex-plugin/plugin.json"));
26480
+ const pkg = await packageJSON(path15.join(root, "package.json")), manifest = await packageJSON(path15.join(root, ".codex-plugin/plugin.json"));
26249
26481
  if (pkg.name !== "@promptframe/creation" || pkg.version !== p2.version || manifest.name !== p2.name || manifest.version !== p2.version) fail4("installed_files_invalid");
26250
- const definition = (await packageJSON(path14.join(root, ".mcp.json"))).mcpServers?.promptframe;
26482
+ const definition = (await packageJSON(path15.join(root, ".mcp.json"))).mcpServers?.promptframe;
26251
26483
  if (!definition || definition.command !== "node" || definition.cwd !== "." || JSON.stringify(definition.args) !== JSON.stringify(["bin/promptframe-creation.mjs", "bridge"]) || JSON.stringify(definition.env_vars) !== JSON.stringify(["PROMPTFRAME_CREATION_CONFIG", "XDG_CONFIG_HOME"])) fail4("legacy_mcp_entry_requires_review");
26252
26484
  if (servers.length !== 1 || servers[0].enabled !== true || !sameTransport(servers[0].transport, { ...definition, cwd: root }) || JSON.stringify(servers[0].transport.env_vars) !== JSON.stringify(definition.env_vars)) fail4("legacy_mcp_entry_requires_review");
26253
26485
  return {
@@ -26264,17 +26496,17 @@ async function officialNpmInstallation(installed, servers, env, profile, configF
26264
26496
  };
26265
26497
  }
26266
26498
  async function atomicJSON(file, value2) {
26267
- const temp = file + "." + randomBytes5(12).toString("hex") + ".tmp";
26499
+ const temp = file + "." + randomBytes6(12).toString("hex") + ".tmp";
26268
26500
  try {
26269
- const out = await open8(temp, "wx", 384);
26501
+ const out = await open9(temp, "wx", 384);
26270
26502
  try {
26271
26503
  await out.writeFile(JSON.stringify(value2, null, 2) + "\n");
26272
26504
  await out.sync();
26273
26505
  } finally {
26274
26506
  await out.close();
26275
26507
  }
26276
- await rename6(temp, file);
26277
- const directory3 = await open8(path14.dirname(file), "r");
26508
+ await rename7(temp, file);
26509
+ const directory3 = await open9(path15.dirname(file), "r");
26278
26510
  try {
26279
26511
  await directory3.sync();
26280
26512
  } finally {
@@ -26285,13 +26517,13 @@ async function atomicJSON(file, value2) {
26285
26517
  }
26286
26518
  }
26287
26519
  async function acquire(root, signal) {
26288
- const lock = path14.join(root, "install.lock");
26520
+ const lock = path15.join(root, "install.lock");
26289
26521
  const end = Date.now() + 3e4;
26290
26522
  let owned = false;
26291
26523
  while (!owned) {
26292
26524
  signal?.throwIfAborted();
26293
26525
  try {
26294
- await mkdir6(lock, { mode: 448 });
26526
+ await mkdir7(lock, { mode: 448 });
26295
26527
  owned = true;
26296
26528
  } catch (e) {
26297
26529
  if (e.code !== "EEXIST") throw e;
@@ -26300,7 +26532,7 @@ async function acquire(root, signal) {
26300
26532
  }
26301
26533
  }
26302
26534
  try {
26303
- await writeFile2(path14.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
26535
+ await writeFile2(path15.join(lock, "owner.json"), JSON.stringify({ pid: process.pid, startedAt: (/* @__PURE__ */ new Date()).toISOString() }), { flag: "wx", mode: 384 });
26304
26536
  } catch (e) {
26305
26537
  await rm2(lock, { recursive: true, force: true });
26306
26538
  throw e;
@@ -26341,7 +26573,7 @@ async function codexJSON(runCodex, args2) {
26341
26573
  }
26342
26574
  }
26343
26575
  async function relatedPlugins(runCodex, pluginName, env) {
26344
- const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path14.join(path14.resolve(env.CODEX_HOME ?? path14.join(homedir5(), ".codex")), "config.toml");
26576
+ const related = /* @__PURE__ */ new Set(), registered = /* @__PURE__ */ new Set(), pinnedMarketplaces = /* @__PURE__ */ new Map(), config2 = path15.join(path15.resolve(env.CODEX_HOME ?? path15.join(homedir6(), ".codex")), "config.toml");
26345
26577
  try {
26346
26578
  const s3 = await info2(config2);
26347
26579
  if (s3) {
@@ -26361,10 +26593,10 @@ async function relatedPlugins(runCodex, pluginName, env) {
26361
26593
  const state = await codexJSON(runCodex, ["plugin", "marketplace", "list", "--json"]);
26362
26594
  if (!Array.isArray(state?.marketplaces) || state.marketplaces.length > 128) fail4("local_catalog_unconfirmed");
26363
26595
  for (const market of state.marketplaces) {
26364
- if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path14.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
26596
+ if (typeof market.name !== "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,140}$/.test(market.name) || typeof market.root !== "string" || !path15.isAbsolute(market.root)) fail4("local_catalog_unconfirmed");
26365
26597
  let catalog;
26366
26598
  try {
26367
- catalog = await packageJSON(path14.join(market.root, ".agents/plugins/marketplace.json"));
26599
+ catalog = await packageJSON(path15.join(market.root, ".agents/plugins/marketplace.json"));
26368
26600
  } catch {
26369
26601
  fail4("local_catalog_unconfirmed", { phase: "local_check", commandKind: "marketplace_read", localRegistrationState: "unknown", action: "restore_local_marketplace_catalog" });
26370
26602
  }
@@ -26395,7 +26627,7 @@ async function relatedPlugins(runCodex, pluginName, env) {
26395
26627
  }
26396
26628
  async function runNode(root, version3) {
26397
26629
  try {
26398
- const result = await execute2(process.execPath, [path14.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
26630
+ const result = await execute2(process.execPath, [path15.join(root, "bin/promptframe-creation.mjs"), "--version"], { encoding: "utf8", timeout: 1e4, maxBuffer: 8192 });
26399
26631
  if (result.stdout.trim() !== version3) fail4("runtime_version_mismatch");
26400
26632
  } catch (e) {
26401
26633
  if (e instanceof CreationClientError) throw e;
@@ -26409,7 +26641,7 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
26409
26641
  if (!major || Number(major[1]) < 20) throw Error("unsupported_node");
26410
26642
  const result = await execute2(
26411
26643
  command2,
26412
- [path14.join(root, "bin/promptframe-creation.mjs"), "--version"],
26644
+ [path15.join(root, "bin/promptframe-creation.mjs"), "--version"],
26413
26645
  { env, encoding: "utf8", timeout: 1e4, maxBuffer: 8192 }
26414
26646
  );
26415
26647
  if (result.stdout.trim() !== version3) throw Error("wrong_version");
@@ -26423,8 +26655,8 @@ async function checkInstalledRuntime(root, version3, command2, { env = process.e
26423
26655
  }
26424
26656
  var installationFiles = Object.freeze({
26425
26657
  info: info2,
26426
- privateDirectory: privateDirectory3,
26427
- privateRead: privateRead2,
26658
+ privateDirectory: privateDirectory4,
26659
+ privateRead: privateRead3,
26428
26660
  atomicJSON,
26429
26661
  acquire,
26430
26662
  runNode,
@@ -26446,21 +26678,21 @@ async function installForUser({
26446
26678
  const versionOutput = await runCodex(["--version"]);
26447
26679
  const match = versionOutput.match(/codex-cli (\d+)\.(\d+)\.(\d+)/);
26448
26680
  if (!match || Number(match[1]) === 0 && Number(match[2]) < 160) fail4("codex_0160_required");
26449
- const payload = await inspectRuntimePackage(path14.resolve(sourceRoot));
26450
- const root = path14.resolve(env.XDG_DATA_HOME ?? path14.join(homedir5(), ".local/share"), "promptframe-creation", profile);
26451
- await privateDirectory3(root);
26681
+ const payload = await inspectRuntimePackage(path15.resolve(sourceRoot));
26682
+ const root = path15.resolve(env.XDG_DATA_HOME ?? path15.join(homedir6(), ".local/share"), "promptframe-creation", profile);
26683
+ await privateDirectory4(root);
26452
26684
  const release = await acquire(root, signal);
26453
- const versions = path14.join(root, "versions"), currentFile = path14.join(root, "current.json"), pendingFile = path14.join(root, "registration-pending.json");
26454
- const marketplaceFile = path14.join(root, ".agents/plugins/marketplace.json");
26685
+ const versions = path15.join(root, "versions"), currentFile = path15.join(root, "current.json"), pendingFile = path15.join(root, "registration-pending.json");
26686
+ const marketplaceFile = path15.join(root, ".agents/plugins/marketplace.json");
26455
26687
  const pluginName = "promptframe-creation" + (profile === "default" ? "" : "-" + profile), marketplace = "promptframe-creation-user" + (profile === "default" ? "" : "-" + profile);
26456
26688
  const pluginId = pluginName + "@" + marketplace;
26457
- const versionRoot = path14.join(versions, payload.version), temporary = path14.join(versions, ".partial-" + randomBytes5(12).toString("hex"));
26689
+ const versionRoot = path15.join(versions, payload.version), temporary = path15.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
26458
26690
  let previous, registrationStarted = false, newFiles = 0;
26459
26691
  try {
26460
26692
  signal?.throwIfAborted();
26461
- await privateDirectory3(versions);
26462
- await privateDirectory3(path14.dirname(marketplaceFile));
26463
- previous = await privateRead2(currentFile);
26693
+ await privateDirectory4(versions);
26694
+ await privateDirectory4(path15.dirname(marketplaceFile));
26695
+ previous = await privateRead3(currentFile);
26464
26696
  if (previous && (previous.profile !== profile || previous.pluginId !== pluginId || previous.configFile !== configFile2)) fail4("profile_binding_conflict");
26465
26697
  const state = { installed: await relatedPlugins(runCodex, pluginName, env) };
26466
26698
  const installed = state.installed.find((x) => x.pluginId === pluginId);
@@ -26468,14 +26700,14 @@ async function installForUser({
26468
26700
  if (!Array.isArray(legacy)) fail4("local_registration_unconfirmed");
26469
26701
  const serverName = "promptframe" + (profile === "default" ? "" : "-" + profile);
26470
26702
  const servers = legacy.filter((x) => x.name === serverName);
26471
- const pending = await privateRead2(pendingFile);
26703
+ const pending = await privateRead3(pendingFile);
26472
26704
  if (pending) {
26473
- if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path14.join(versions, pending.version)) fail4("profile_binding_conflict");
26705
+ if (pending.profile !== profile || pending.pluginId !== pluginId || pending.configFile !== configFile2 || pending.versionRoot !== path15.join(versions, pending.version)) fail4("profile_binding_conflict");
26474
26706
  if (installed?.version !== pending.version || installed.enabled !== true || installed.source?.path !== pending.versionRoot)
26475
26707
  fail4("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
26476
26708
  const transport2 = await managedTransport(installed, versions, serverName, profile, configFile2);
26477
26709
  if (servers.length !== 1 || servers[0].enabled === false || !sameTransport(servers[0].transport, transport2)) fail4("registration_unconfirmed_keep_existing");
26478
- const ready = await privateRead2(path14.join(pending.versionRoot, "installation.json"));
26710
+ const ready = await privateRead3(path15.join(pending.versionRoot, "installation.json"));
26479
26711
  if (ready?.payloadDigest !== pending.payloadDigest) fail4("installed_files_invalid");
26480
26712
  previous = pending;
26481
26713
  await atomicJSON(currentFile, pending);
@@ -26530,43 +26762,43 @@ async function installForUser({
26530
26762
  const target = await info2(versionRoot);
26531
26763
  if (target) {
26532
26764
  if (!target.isDirectory() || target.isSymbolicLink()) fail4("version_content_conflict");
26533
- const ready = await privateRead2(path14.join(versionRoot, "installation.json"));
26765
+ const ready = await privateRead3(path15.join(versionRoot, "installation.json"));
26534
26766
  if (!ready || ready.payloadDigest !== payload.payloadDigest || ready.profile !== profile || ready.configFile !== configFile2) fail4("version_content_conflict");
26535
26767
  for (const f2 of ready.files) {
26536
26768
  if (!payload.files.some((p2) => p2.path === f2.path)) fail4("installed_files_invalid");
26537
- const file = path14.join(versionRoot, f2.path), s3 = await info2(file);
26769
+ const file = path15.join(versionRoot, f2.path), s3 = await info2(file);
26538
26770
  if (!s3?.isFile() || s3.isSymbolicLink() || s3.size !== f2.bytes || hash5(await readFile6(file)) !== f2.sha256) fail4("installed_files_invalid");
26539
26771
  }
26540
26772
  if (ready.files.length !== payload.files.length) fail4("installed_files_invalid");
26541
26773
  } else {
26542
- await mkdir6(temporary, { mode: 448 });
26774
+ await mkdir7(temporary, { mode: 448 });
26543
26775
  for (const f2 of payload.files) {
26544
26776
  signal?.throwIfAborted();
26545
- await mkdir6(path14.dirname(path14.join(temporary, f2.path)), { recursive: true, mode: 448 });
26546
- await writeFile2(path14.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
26777
+ await mkdir7(path15.dirname(path15.join(temporary, f2.path)), { recursive: true, mode: 448 });
26778
+ await writeFile2(path15.join(temporary, f2.path), f2.body, { flag: "wx", mode: 384 });
26547
26779
  }
26548
- const manifest = await json(path14.join(temporary, ".codex-plugin/plugin.json"));
26780
+ const manifest = await json(path15.join(temporary, ".codex-plugin/plugin.json"));
26549
26781
  manifest.name = pluginName;
26550
- await writeFile2(path14.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
26782
+ await writeFile2(path15.join(temporary, ".codex-plugin/plugin.json"), JSON.stringify(manifest, null, 2) + "\n");
26551
26783
  const mcp = { mcpServers: { ["promptframe" + (profile === "default" ? "" : "-" + profile)]: {
26552
26784
  command: process.execPath,
26553
- args: [path14.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
26785
+ args: [path15.join(versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", configFile2],
26554
26786
  cwd: versionRoot
26555
26787
  } } };
26556
- await writeFile2(path14.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
26788
+ await writeFile2(path15.join(temporary, ".mcp.json"), JSON.stringify(mcp, null, 2) + "\n");
26557
26789
  await checkRuntime(temporary, payload.version);
26558
26790
  const files = [];
26559
26791
  for (const f2 of payload.files) {
26560
- const body = await readFile6(path14.join(temporary, f2.path));
26792
+ const body = await readFile6(path15.join(temporary, f2.path));
26561
26793
  files.push({ path: f2.path, bytes: body.length, sha256: hash5(body) });
26562
26794
  }
26563
- await atomicJSON(path14.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
26795
+ await atomicJSON(path15.join(temporary, "installation.json"), { version: payload.version, profile, configFile: configFile2, payloadDigest: payload.payloadDigest, files });
26564
26796
  signal?.throwIfAborted();
26565
- await rename6(temporary, versionRoot);
26797
+ await rename7(temporary, versionRoot);
26566
26798
  newFiles = payload.files.length;
26567
26799
  }
26568
26800
  if (newFiles === 0) {
26569
- const launch = (await json(path14.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
26801
+ const launch = (await json(path15.join(versionRoot, ".mcp.json"))).mcpServers?.[serverName];
26570
26802
  await verifyInstalledRuntime(versionRoot, payload.version, launch.command, { env });
26571
26803
  }
26572
26804
  const complete = { version: payload.version, profile, configFile: configFile2, pluginId, versionRoot, payloadDigest: payload.payloadDigest };
@@ -26605,16 +26837,16 @@ async function installForUser({
26605
26837
  reloadRequired: !already,
26606
26838
  recordedRuntimeRetained: Boolean(already && recorded && recorded.command !== process.execPath)
26607
26839
  };
26608
- } catch (error5) {
26840
+ } catch (error6) {
26609
26841
  if (registrationStarted) {
26610
26842
  fail4("registration_unconfirmed_keep_existing", {
26611
- ...installationErrorDetails(error5),
26843
+ ...installationErrorDetails(error6),
26612
26844
  phase: "registration_observation",
26613
26845
  localRegistrationState: "unknown",
26614
26846
  action: "inspect_same_registration_no_second_add"
26615
26847
  });
26616
26848
  }
26617
- if (error5 instanceof CreationClientError) throw error5;
26849
+ if (error6 instanceof CreationClientError) throw error6;
26618
26850
  if (signal?.aborted) fail4("interrupted_keep_existing");
26619
26851
  fail4("failed_keep_existing");
26620
26852
  } finally {
@@ -26624,10 +26856,10 @@ async function installForUser({
26624
26856
  }
26625
26857
 
26626
26858
  // lib/claude-installation.mjs
26627
- import { createHash as createHash12, randomBytes as randomBytes7 } from "node:crypto";
26628
- import { mkdir as mkdir8, open as open11, readFile as readFile9, rename as rename8, rm as rm5 } from "node:fs/promises";
26629
- import { homedir as homedir10 } from "node:os";
26630
- import path19 from "node:path";
26859
+ import { createHash as createHash13, randomBytes as randomBytes8 } from "node:crypto";
26860
+ import { mkdir as mkdir9, open as open12, readFile as readFile9, rename as rename9, rm as rm5 } from "node:fs/promises";
26861
+ import { homedir as homedir11 } from "node:os";
26862
+ import path20 from "node:path";
26631
26863
 
26632
26864
  // lib/claude-hook-definition.mjs
26633
26865
  function claudeHostHooks({ pluginName = "promptframe-creation", serverName, configFile: configFile2, nodeCommand = "node", runtimeRoot = "${CLAUDE_PLUGIN_ROOT}" } = {}) {
@@ -26650,10 +26882,10 @@ function claudeHostHooks({ pluginName = "promptframe-creation", serverName, conf
26650
26882
  // lib/claude-command.mjs
26651
26883
  import { execFile as execFile3 } from "node:child_process";
26652
26884
  import { promisify as promisify3 } from "node:util";
26653
- import { access, lstat as lstat9, readdir as readdir5 } from "node:fs/promises";
26654
- import { constants as constants6 } from "node:fs";
26655
- import { homedir as homedir6 } from "node:os";
26656
- import path15 from "node:path";
26885
+ import { access, lstat as lstat10, readdir as readdir5 } from "node:fs/promises";
26886
+ import { constants as constants7 } from "node:fs";
26887
+ import { homedir as homedir7 } from "node:os";
26888
+ import path16 from "node:path";
26657
26889
  var execute3 = promisify3(execFile3);
26658
26890
  var ClaudeCommandError = class extends CreationClientError {
26659
26891
  constructor(code, details) {
@@ -26661,24 +26893,24 @@ var ClaudeCommandError = class extends CreationClientError {
26661
26893
  this.details = details;
26662
26894
  }
26663
26895
  };
26664
- var claudeErrorDetails = (error5) => error5 instanceof ClaudeCommandError ? error5.details : void 0;
26665
- async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir6(), executable } = {}) {
26896
+ var claudeErrorDetails = (error6) => error6 instanceof ClaudeCommandError ? error6.details : void 0;
26897
+ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir7(), executable } = {}) {
26666
26898
  const selected = executable ?? env.PROMPTFRAME_CLAUDE_BIN;
26667
26899
  if (selected) {
26668
- if (!path15.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
26669
- await access(selected, constants6.X_OK);
26900
+ if (!path16.isAbsolute(selected)) throw new CreationClientError("installation.claude_executable_invalid");
26901
+ await access(selected, constants7.X_OK);
26670
26902
  return selected;
26671
26903
  }
26672
- for (const directory3 of (env.PATH ?? "").split(path15.delimiter).filter(path15.isAbsolute)) {
26673
- const file = path15.join(directory3, process.platform === "win32" ? "claude.exe" : "claude");
26904
+ for (const directory3 of (env.PATH ?? "").split(path16.delimiter).filter(path16.isAbsolute)) {
26905
+ const file = path16.join(directory3, process.platform === "win32" ? "claude.exe" : "claude");
26674
26906
  try {
26675
- await access(file, constants6.X_OK);
26907
+ await access(file, constants7.X_OK);
26676
26908
  return file;
26677
26909
  } catch (e) {
26678
26910
  if (!["ENOENT", "EACCES", "ENOTDIR"].includes(e.code)) throw e;
26679
26911
  }
26680
26912
  }
26681
- const root = path15.join(homeDirectory, ".claude/remote/ccd-cli");
26913
+ const root = path16.join(homeDirectory, ".claude/remote/ccd-cli");
26682
26914
  let entries2;
26683
26915
  try {
26684
26916
  entries2 = await readdir5(root);
@@ -26691,9 +26923,9 @@ async function resolveClaudeCommand({ env = process.env, homeDirectory = homedir
26691
26923
  for (const name of entries2) {
26692
26924
  const match = name.match(/^(\d+)\.(\d+)\.(\d+)-[a-f0-9]{6,40}$/);
26693
26925
  if (!match) continue;
26694
- const file = path15.join(root, name), s3 = await lstat9(file);
26926
+ const file = path16.join(root, name), s3 = await lstat10(file);
26695
26927
  if (s3.isFile() && !s3.isSymbolicLink() && s3.uid === process.getuid?.()) {
26696
- await access(file, constants6.X_OK);
26928
+ await access(file, constants7.X_OK);
26697
26929
  candidates.push({ file, version: match.slice(1).map(Number) });
26698
26930
  }
26699
26931
  }
@@ -26729,17 +26961,17 @@ function createClaudeRunner({ env = process.env, executable, signal, resolve = r
26729
26961
  }
26730
26962
 
26731
26963
  // lib/claude-local-state.mjs
26732
- import { readFile as readFile7, lstat as lstat10 } from "node:fs/promises";
26733
- import { homedir as homedir7 } from "node:os";
26734
- import path16 from "node:path";
26964
+ import { readFile as readFile7, lstat as lstat11 } from "node:fs/promises";
26965
+ import { homedir as homedir8 } from "node:os";
26966
+ import path17 from "node:path";
26735
26967
  function claudeConfigRoot(env = process.env) {
26736
- return path16.resolve(env.CLAUDE_CONFIG_DIR ?? path16.join(homedir7(), ".claude"));
26968
+ return path17.resolve(env.CLAUDE_CONFIG_DIR ?? path17.join(homedir8(), ".claude"));
26737
26969
  }
26738
26970
  async function readClaudeUserServer(serverName, env = process.env) {
26739
- const file = env.CLAUDE_CONFIG_DIR ? path16.join(claudeConfigRoot(env), ".claude.json") : path16.join(homedir7(), ".claude.json");
26971
+ const file = env.CLAUDE_CONFIG_DIR ? path17.join(claudeConfigRoot(env), ".claude.json") : path17.join(homedir8(), ".claude.json");
26740
26972
  let info5;
26741
26973
  try {
26742
- info5 = await lstat10(file);
26974
+ info5 = await lstat11(file);
26743
26975
  } catch (e) {
26744
26976
  if (e.code === "ENOENT") return null;
26745
26977
  throw new CreationClientError("installation.claude_local_registration_unconfirmed");
@@ -26759,26 +26991,26 @@ async function readClaudeUserServer(serverName, env = process.env) {
26759
26991
  }
26760
26992
 
26761
26993
  // lib/claude-mcp-installation.mjs
26762
- import { createHash as createHash11, randomBytes as randomBytes6 } from "node:crypto";
26763
- import { mkdir as mkdir7, open as open10, readFile as readFile8, readdir as readdir6, rename as rename7, rm as rm4, lstat as lstat11 } from "node:fs/promises";
26764
- import { homedir as homedir9 } from "node:os";
26765
- import path18 from "node:path";
26994
+ import { createHash as createHash12, randomBytes as randomBytes7 } from "node:crypto";
26995
+ import { mkdir as mkdir8, open as open11, readFile as readFile8, readdir as readdir6, rename as rename8, rm as rm4, lstat as lstat12 } from "node:fs/promises";
26996
+ import { homedir as homedir10 } from "node:os";
26997
+ import path19 from "node:path";
26766
26998
 
26767
26999
  // lib/claude-hook-registration.mjs
26768
- import { createHash as createHash10 } from "node:crypto";
26769
- import { open as open9, rm as rm3 } from "node:fs/promises";
26770
- import { constants as constants7 } from "node:fs";
26771
- import path17 from "node:path";
26772
- import { homedir as homedir8 } from "node:os";
26773
- var { privateDirectory: privateDirectory4, privateRead: privateRead3, atomicJSON: atomicJSON2, acquire: acquire2 } = installationFiles;
26774
- var digest4 = (value2) => createHash10("sha256").update(JSON.stringify(value2)).digest("hex");
27000
+ import { createHash as createHash11 } from "node:crypto";
27001
+ import { open as open10, rm as rm3 } from "node:fs/promises";
27002
+ import { constants as constants8 } from "node:fs";
27003
+ import path18 from "node:path";
27004
+ import { homedir as homedir9 } from "node:os";
27005
+ var { privateDirectory: privateDirectory5, privateRead: privateRead4, atomicJSON: atomicJSON2, acquire: acquire2 } = installationFiles;
27006
+ var digest5 = (value2) => createHash11("sha256").update(JSON.stringify(value2)).digest("hex");
26775
27007
  var fail5 = () => {
26776
27008
  throw new CreationClientError("installation.claude_hooks_require_review");
26777
27009
  };
26778
27010
  async function settings(file) {
26779
27011
  let handle;
26780
27012
  try {
26781
- handle = await open9(file, constants7.O_RDONLY | constants7.O_NOFOLLOW);
27013
+ handle = await open10(file, constants8.O_RDONLY | constants8.O_NOFOLLOW);
26782
27014
  const info5 = await handle.stat();
26783
27015
  if (!info5.isFile() || info5.uid !== process.getuid?.() || info5.size > 512 * 1024) fail5();
26784
27016
  const value2 = JSON.parse(await handle.readFile("utf8"));
@@ -26791,29 +27023,29 @@ async function settings(file) {
26791
27023
  await handle?.close();
26792
27024
  }
26793
27025
  }
26794
- var contains = (value2, entries2) => Object.entries(entries2).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) => digest4(actual) === digest4(entry)).length === 1));
27026
+ var contains = (value2, entries2) => Object.entries(entries2).every(([event, wanted]) => Array.isArray(value2.hooks?.[event]) && wanted.every((entry) => value2.hooks[event].filter((actual) => digest5(actual) === digest5(entry)).length === 1));
26795
27027
  async function verifyClaudeFallbackHooks(record2, env) {
26796
- if (!record2?.settingsFile || record2.settingsFile !== path17.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
27028
+ if (!record2?.settingsFile || record2.settingsFile !== path18.join(claudeConfigRoot(env), "settings.json") || !record2.entries) fail5();
26797
27029
  if (!contains(await settings(record2.settingsFile), record2.entries)) fail5();
26798
27030
  return true;
26799
27031
  }
26800
27032
  async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCommand, signal }) {
26801
- const directory3 = claudeConfigRoot(env), file = path17.join(directory3, "settings.json");
26802
- const guard = path17.resolve(
26803
- env.XDG_DATA_HOME ?? path17.join(homedir8(), ".local/share"),
27033
+ const directory3 = claudeConfigRoot(env), file = path18.join(directory3, "settings.json");
27034
+ const guard = path18.resolve(
27035
+ env.XDG_DATA_HOME ?? path18.join(homedir9(), ".local/share"),
26804
27036
  "promptframe-creation",
26805
- "claude-hook-writer-" + digest4(directory3)
27037
+ "claude-hook-writer-" + digest5(directory3)
26806
27038
  );
26807
- await privateDirectory4(guard);
27039
+ await privateDirectory5(guard);
26808
27040
  const release = await acquire2(guard, signal);
26809
- const markerFile = path17.join(root, "hooks-current.json"), pendingFile = path17.join(root, "hooks-pending.json");
27041
+ const markerFile = path18.join(root, "hooks-current.json"), pendingFile = path18.join(root, "hooks-pending.json");
26810
27042
  try {
26811
- await privateDirectory4(directory3);
27043
+ await privateDirectory5(directory3);
26812
27044
  const entries2 = claudeHostHooks({ serverName: record2.serverName, configFile: record2.configFile, nodeCommand, runtimeRoot: record2.versionRoot });
26813
27045
  const expected = { contractVersion: "creation-claude-hooks/v1", settingsFile: file, profile: record2.profile, entries: entries2 };
26814
- const pending = await privateRead3(pendingFile), previous = await privateRead3(markerFile), before = await settings(file);
27046
+ const pending = await privateRead4(pendingFile), previous = await privateRead4(markerFile), before = await settings(file);
26815
27047
  if (pending) {
26816
- if (digest4(pending) !== digest4(expected) || !contains(before, entries2)) throw new CreationClientError("installation.registration_unconfirmed_keep_existing");
27048
+ if (digest5(pending) !== digest5(expected) || !contains(before, entries2)) throw new CreationClientError("installation.registration_unconfirmed_keep_existing");
26817
27049
  await atomicJSON2(markerFile, expected);
26818
27050
  await rm3(pendingFile);
26819
27051
  return expected;
@@ -26821,19 +27053,19 @@ async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCom
26821
27053
  if (previous) {
26822
27054
  if (previous.contractVersion !== expected.contractVersion || previous.profile !== record2.profile || previous.settingsFile !== file) fail5();
26823
27055
  await verifyClaudeFallbackHooks(previous, env);
26824
- if (digest4(previous) === digest4(expected)) return previous;
27056
+ if (digest5(previous) === digest5(expected)) return previous;
26825
27057
  }
26826
27058
  const next = { ...before, hooks: { ...before.hooks } };
26827
27059
  for (const [event, wanted] of Object.entries(entries2)) {
26828
27060
  const actual = next.hooks[event] ?? [];
26829
27061
  if (!Array.isArray(actual)) fail5();
26830
- const owned = new Set((previous?.entries[event] ?? []).map(digest4));
26831
- if (wanted.some((entry) => actual.some((value2) => digest4(value2) === digest4(entry)) && !owned.has(digest4(entry)))) fail5();
26832
- next.hooks[event] = [...actual.filter((entry) => !owned.has(digest4(entry))), ...wanted];
27062
+ const owned = new Set((previous?.entries[event] ?? []).map(digest5));
27063
+ if (wanted.some((entry) => actual.some((value2) => digest5(value2) === digest5(entry)) && !owned.has(digest5(entry)))) fail5();
27064
+ next.hooks[event] = [...actual.filter((entry) => !owned.has(digest5(entry))), ...wanted];
26833
27065
  }
26834
27066
  signal?.throwIfAborted();
26835
27067
  await atomicJSON2(pendingFile, expected);
26836
- if (digest4(await settings(file)) !== digest4(before)) fail5();
27068
+ if (digest5(await settings(file)) !== digest5(before)) fail5();
26837
27069
  await atomicJSON2(file, next);
26838
27070
  if (!contains(await settings(file), entries2)) throw new CreationClientError("installation.registration_unconfirmed_keep_existing");
26839
27071
  await atomicJSON2(markerFile, expected);
@@ -26845,24 +27077,24 @@ async function registerClaudeFallbackHooks({ record: record2, root, env, nodeCom
26845
27077
  }
26846
27078
 
26847
27079
  // lib/claude-mcp-installation.mjs
26848
- var { info: info3, privateDirectory: privateDirectory5, privateRead: privateRead4, atomicJSON: atomicJSON3, acquire: acquire3, compareVersions: compareVersions2 } = installationFiles;
26849
- var hash6 = (body) => createHash11("sha256").update(body).digest("hex");
27080
+ var { info: info3, privateDirectory: privateDirectory6, privateRead: privateRead5, atomicJSON: atomicJSON3, acquire: acquire3, compareVersions: compareVersions2 } = installationFiles;
27081
+ var hash6 = (body) => createHash12("sha256").update(body).digest("hex");
26850
27082
  var FallbackError = class extends CreationClientError {
26851
27083
  constructor(code, details) {
26852
27084
  super("installation." + code);
26853
27085
  this.details = details;
26854
27086
  }
26855
27087
  };
26856
- var fallbackErrorDetails = (error5) => error5 instanceof FallbackError ? error5.details : void 0;
27088
+ var fallbackErrorDetails = (error6) => error6 instanceof FallbackError ? error6.details : void 0;
26857
27089
  var fail6 = (code, details) => {
26858
27090
  throw new FallbackError(code, details);
26859
27091
  };
26860
27092
  async function claimSkillDirectory(root) {
26861
27093
  try {
26862
- await mkdir7(root, { mode: 448 });
26863
- } catch (error5) {
26864
- if (error5.code === "EEXIST") fail6("claude_skill_requires_review");
26865
- throw error5;
27094
+ await mkdir8(root, { mode: 448 });
27095
+ } catch (error6) {
27096
+ if (error6.code === "EEXIST") fail6("claude_skill_requires_review");
27097
+ throw error6;
26866
27098
  }
26867
27099
  }
26868
27100
  function same(a, b2, depth = 0) {
@@ -26872,17 +27104,17 @@ function same(a, b2, depth = 0) {
26872
27104
  return left.length <= 256 && left.length === right.length && left.every((key, i) => key === right[i] && same(a[key], b2[key], depth + 1));
26873
27105
  }
26874
27106
  async function atomicText(file, body) {
26875
- const temporary = file + "." + randomBytes6(12).toString("hex") + ".tmp";
27107
+ const temporary = file + "." + randomBytes7(12).toString("hex") + ".tmp";
26876
27108
  try {
26877
- const fd = await open10(temporary, "wx", 384);
27109
+ const fd = await open11(temporary, "wx", 384);
26878
27110
  try {
26879
27111
  await fd.writeFile(body);
26880
27112
  await fd.sync();
26881
27113
  } finally {
26882
27114
  await fd.close();
26883
27115
  }
26884
- await rename7(temporary, file);
26885
- const dir = await open10(path18.dirname(file), "r");
27116
+ await rename8(temporary, file);
27117
+ const dir = await open11(path19.dirname(file), "r");
26886
27118
  try {
26887
27119
  await dir.sync();
26888
27120
  } finally {
@@ -26895,15 +27127,15 @@ async function atomicText(file, body) {
26895
27127
  async function verifyVersion(root, record2) {
26896
27128
  const directory3 = await info3(root);
26897
27129
  if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_installed_files_invalid");
26898
- const marker = await privateRead4(path18.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
26899
- if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path18.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
27130
+ const marker = await privateRead5(path19.join(root, "installation.json")), payload = await inspectRuntimePackage(root);
27131
+ if (!marker || marker.host !== "claude-code" || marker.mode !== "mcp-and-skills" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.version !== record2.version || marker.payloadDigest !== record2.payloadDigest || payload.payloadDigest !== marker.payloadDigest || !path19.isAbsolute(marker.nodeCommand ?? "")) fail6("claude_installed_files_invalid");
26900
27132
  return marker;
26901
27133
  }
26902
27134
  function mcpDefinition(record2, nodeCommand) {
26903
27135
  return {
26904
27136
  type: "stdio",
26905
27137
  command: nodeCommand,
26906
- args: [path18.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
27138
+ args: [path19.join(record2.versionRoot, "bin/promptframe-creation.mjs"), "bridge", "--config", record2.configFile, "--host", "claude-code"]
26907
27139
  };
26908
27140
  }
26909
27141
  function skillBody(payload, sourceName, name) {
@@ -26919,14 +27151,14 @@ async function observedSkill(plan, record2, { allowBefore = false } = {}) {
26919
27151
  if (!directory3.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63) fail6("claude_skill_requires_review");
26920
27152
  const names = await readdir6(plan.root);
26921
27153
  if (names.some((n) => !["SKILL.md", "promptframe-installation.json"].includes(n))) fail6("claude_skill_requires_review");
26922
- const marker = await privateRead4(path18.join(plan.root, "promptframe-installation.json")), file = path18.join(plan.root, "SKILL.md"), s3 = await info3(file);
27154
+ const marker = await privateRead5(path19.join(plan.root, "promptframe-installation.json")), file = path19.join(plan.root, "SKILL.md"), s3 = await info3(file);
26923
27155
  if (!marker || marker.host !== "claude-code" || marker.profile !== record2.profile || marker.configFile !== record2.configFile || marker.name !== plan.name)
26924
27156
  fail6("claude_skill_requires_review");
26925
27157
  if (!s3 && allowBefore && plan.beforeSHA === null && marker.sha256 === null) return false;
26926
27158
  if (!s3?.isFile() || s3.isSymbolicLink() || s3.size > 256 * 1024) fail6("claude_skill_requires_review");
26927
- const digest5 = hash6(await readFile8(file));
26928
- if (digest5 === plan.sha256 && marker.sha256 === plan.sha256) return true;
26929
- if (allowBefore && (digest5 === plan.beforeSHA || digest5 === plan.sha256) && marker.sha256 === plan.beforeSHA) return false;
27159
+ const digest6 = hash6(await readFile8(file));
27160
+ if (digest6 === plan.sha256 && marker.sha256 === plan.sha256) return true;
27161
+ if (allowBefore && (digest6 === plan.beforeSHA || digest6 === plan.sha256) && marker.sha256 === plan.beforeSHA) return false;
26930
27162
  fail6("claude_skill_requires_review");
26931
27163
  }
26932
27164
  async function installClaudeMcpFallback({
@@ -26941,17 +27173,17 @@ async function installClaudeMcpFallback({
26941
27173
  nodeCommand,
26942
27174
  writeSkill = atomicText
26943
27175
  }) {
26944
- const payload = await inspectRuntimePackage(path18.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path18.resolve(env.XDG_DATA_HOME ?? path18.join(homedir9(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
26945
- await privateDirectory5(root);
26946
- const release = await acquire3(root, signal), versions = path18.join(root, "versions"), currentFile = path18.join(root, "current.json"), pendingFile = path18.join(root, "registration-pending.json"), versionRoot = path18.join(versions, payload.version), temporary = path18.join(versions, ".partial-" + randomBytes6(12).toString("hex"));
27176
+ const payload = await inspectRuntimePackage(path19.resolve(sourceRoot)), suffix = profile === "default" ? "" : "-" + profile, serverName = "promptframe" + suffix, root = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code-mcp");
27177
+ await privateDirectory6(root);
27178
+ const release = await acquire3(root, signal), versions = path19.join(root, "versions"), currentFile = path19.join(root, "current.json"), pendingFile = path19.join(root, "registration-pending.json"), versionRoot = path19.join(versions, payload.version), temporary = path19.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
26947
27179
  let writeStarted = false, newFiles = 0;
26948
27180
  const complete = { host: "claude-code", mode: "mcp-and-skills", profile, configFile: configFile2, serverName, version: payload.version, versionRoot, payloadDigest: payload.payloadDigest };
26949
27181
  const checkBinding = (record2) => {
26950
- if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path18.join(versions, record2.version))) fail6("profile_binding_conflict");
27182
+ if (record2 && (record2.host !== "claude-code" || record2.mode !== "mcp-and-skills" || record2.profile !== profile || record2.configFile !== configFile2 || record2.serverName !== serverName || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path19.join(versions, record2.version))) fail6("profile_binding_conflict");
26951
27183
  };
26952
27184
  try {
26953
- await privateDirectory5(versions);
26954
- let previous = await privateRead4(currentFile), pending = await privateRead4(pendingFile);
27185
+ await privateDirectory6(versions);
27186
+ let previous = await privateRead5(currentFile), pending = await privateRead5(pendingFile);
26955
27187
  checkBinding(previous);
26956
27188
  checkBinding(pending);
26957
27189
  let saved = await readClaudeUserServer(serverName, env);
@@ -26964,7 +27196,7 @@ async function installClaudeMcpFallback({
26964
27196
  if (!Array.isArray(record2.skills) || record2.skills.length !== 2) fail6("claude_skill_requires_review");
26965
27197
  for (const [i, skill] of record2.skills.entries()) {
26966
27198
  const name = ["creation-setup", "video-creation"][i] + suffix;
26967
- if (skill.name !== name || skill.root !== path18.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
27199
+ if (skill.name !== name || skill.root !== path19.join(claudeConfigRoot(env), "skills", name) || !/^[a-f0-9]{64}$/.test(skill.sha256 ?? ""))
26968
27200
  fail6("claude_skill_requires_review");
26969
27201
  if (!await observedSkill(skill, record2)) return false;
26970
27202
  }
@@ -27004,12 +27236,12 @@ async function installClaudeMcpFallback({
27004
27236
  } else if (saved && !pending) fail6("legacy_mcp_entry_requires_review");
27005
27237
  if (await info3(versionRoot)) await verifyVersion(versionRoot, complete);
27006
27238
  else {
27007
- await mkdir7(temporary, { mode: 448 });
27239
+ await mkdir8(temporary, { mode: 448 });
27008
27240
  for (const file of payload.files) {
27009
27241
  signal?.throwIfAborted();
27010
- const dest = path18.join(temporary, file.path);
27011
- await mkdir7(path18.dirname(dest), { recursive: true, mode: 448 });
27012
- const fd = await open10(dest, "wx", 384);
27242
+ const dest = path19.join(temporary, file.path);
27243
+ await mkdir8(path19.dirname(dest), { recursive: true, mode: 448 });
27244
+ const fd = await open11(dest, "wx", 384);
27013
27245
  try {
27014
27246
  await fd.writeFile(file.body);
27015
27247
  await fd.sync();
@@ -27018,21 +27250,21 @@ async function installClaudeMcpFallback({
27018
27250
  }
27019
27251
  }
27020
27252
  await checkRuntime(temporary, payload.version);
27021
- await atomicJSON3(path18.join(temporary, "installation.json"), { ...complete, nodeCommand });
27253
+ await atomicJSON3(path19.join(temporary, "installation.json"), { ...complete, nodeCommand });
27022
27254
  signal?.throwIfAborted();
27023
- await rename7(temporary, versionRoot);
27255
+ await rename8(temporary, versionRoot);
27024
27256
  newFiles = payload.files.length;
27025
27257
  }
27026
27258
  const ready = await verifyVersion(versionRoot, complete);
27027
27259
  complete.server = mcpDefinition(complete, ready.nodeCommand);
27028
27260
  if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, ready.nodeCommand, { env });
27029
- const skillRoot = path18.join(claudeConfigRoot(env), "skills");
27030
- await mkdir7(skillRoot, { recursive: true, mode: 448 });
27031
- const parent = await lstat11(skillRoot);
27261
+ const skillRoot = path19.join(claudeConfigRoot(env), "skills");
27262
+ await mkdir8(skillRoot, { recursive: true, mode: 448 });
27263
+ const parent = await lstat12(skillRoot);
27032
27264
  if (!parent.isDirectory() || parent.isSymbolicLink() || parent.uid !== process.getuid?.()) fail6("claude_skill_requires_review");
27033
27265
  const plans = [];
27034
27266
  for (const sourceName of ["creation-setup", "video-creation"]) {
27035
- const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path18.join(skillRoot, name), sha256: hash6(body) };
27267
+ const name = sourceName + suffix, body = skillBody(payload, sourceName, name), skill = { name, root: path19.join(skillRoot, name), sha256: hash6(body) };
27036
27268
  if (pending) {
27037
27269
  const old = pending.skills?.find((s3) => s3.name === name);
27038
27270
  if (!old || old.root !== skill.root || old.sha256 !== skill.sha256) fail6("registration_unconfirmed_keep_existing");
@@ -27041,7 +27273,7 @@ async function installClaudeMcpFallback({
27041
27273
  const existing = await info3(skill.root);
27042
27274
  let beforeSHA = null;
27043
27275
  if (existing) {
27044
- const marker = await privateRead4(path18.join(skill.root, "promptframe-installation.json"));
27276
+ const marker = await privateRead5(path19.join(skill.root, "promptframe-installation.json"));
27045
27277
  if (!marker || marker.profile !== profile || marker.configFile !== configFile2 || marker.name !== name) fail6("claude_skill_requires_review");
27046
27278
  const old = { ...skill, sha256: marker.sha256 };
27047
27279
  if (!await observedSkill(old, complete)) fail6("claude_skill_requires_review");
@@ -27062,10 +27294,10 @@ async function installClaudeMcpFallback({
27062
27294
  } else {
27063
27295
  if (plan.beforeSHA !== null) fail6("claude_skill_requires_review");
27064
27296
  await claimSkillDirectory(plan.root);
27065
- await atomicJSON3(path18.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
27297
+ await atomicJSON3(path19.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: null });
27066
27298
  }
27067
- await writeSkill(path18.join(plan.root, "SKILL.md"), plan.body);
27068
- await atomicJSON3(path18.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
27299
+ await writeSkill(path19.join(plan.root, "SKILL.md"), plan.body);
27300
+ await atomicJSON3(path19.join(plan.root, "promptframe-installation.json"), { host: "claude-code", profile, configFile: configFile2, name: plan.name, sha256: plan.sha256 });
27069
27301
  }
27070
27302
  signal?.throwIfAborted();
27071
27303
  if (compareVersions2(payload.version, "0.3.1") >= 0) complete.hostHooks = await registerClaudeFallbackHooks({ record: complete, root, env, nodeCommand: ready.nodeCommand, signal });
@@ -27090,9 +27322,9 @@ async function installClaudeMcpFallback({
27090
27322
  requestedVersion: payload.version,
27091
27323
  versionStatus: "current"
27092
27324
  };
27093
- } catch (error5) {
27325
+ } catch (error6) {
27094
27326
  if (writeStarted) fail6("registration_unconfirmed_keep_existing", { phase: "registration_observation", localRegistrationState: "unknown", action: "inspect_same_registration_no_second_add" });
27095
- if (error5 instanceof CreationClientError) throw error5;
27327
+ if (error6 instanceof CreationClientError) throw error6;
27096
27328
  fail6(signal?.aborted ? "interrupted_keep_existing" : "failed_keep_existing");
27097
27329
  } finally {
27098
27330
  await rm4(temporary, { recursive: true, force: true });
@@ -27101,7 +27333,7 @@ async function installClaudeMcpFallback({
27101
27333
  }
27102
27334
 
27103
27335
  // lib/claude-installation.mjs
27104
- var { info: info4, privateDirectory: privateDirectory6, privateRead: privateRead5, atomicJSON: atomicJSON4, acquire: acquire4, runNode: runNode2, checkInstalledRuntime: checkInstalledRuntime2, compareVersions: compareVersions3, validProfile: validProfile2 } = installationFiles;
27336
+ var { info: info4, privateDirectory: privateDirectory7, privateRead: privateRead6, atomicJSON: atomicJSON4, acquire: acquire4, runNode: runNode2, checkInstalledRuntime: checkInstalledRuntime2, compareVersions: compareVersions3, validProfile: validProfile2 } = installationFiles;
27105
27337
  var effectiveRoot = (plugin) => plugin.readFromFolder ?? plugin.installPath;
27106
27338
  var effectiveVersion = (plugin) => plugin.readFromFolder !== void 0 ? plugin.folderVersion : plugin.version;
27107
27339
  var ClaudeInstallationError = class extends CreationClientError {
@@ -27110,7 +27342,7 @@ var ClaudeInstallationError = class extends CreationClientError {
27110
27342
  this.details = details;
27111
27343
  }
27112
27344
  };
27113
- var claudeInstallationDetails = (error5) => error5 instanceof ClaudeInstallationError ? error5.details : void 0;
27345
+ var claudeInstallationDetails = (error6) => error6 instanceof ClaudeInstallationError ? error6.details : void 0;
27114
27346
  var fail7 = (code, details) => {
27115
27347
  throw new ClaudeInstallationError(code, details);
27116
27348
  };
@@ -27134,7 +27366,7 @@ async function registrations(run, pluginName, marketplace, root) {
27134
27366
  if (plugins.some((p2) => !p2 || typeof p2.id !== "string" || !p2.id || p2.id.length > 256 || typeof p2.scope !== "string" || typeof p2.version !== "string" || typeof p2.enabled !== "boolean" || typeof p2.installPath !== "string") || markets.some((p2) => !p2 || typeof p2.name !== "string" || !p2.name || typeof p2.source !== "string"))
27135
27367
  fail7("claude_local_registration_unconfirmed");
27136
27368
  const related = plugins.filter((p2) => typeof p2?.id === "string" && p2.id.startsWith(pluginName + "@"));
27137
- if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path19.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path19.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
27369
+ if (related.length > 1 || related.some((p2) => p2.id !== pluginName + "@" + marketplace || p2.scope !== "user" || typeof p2.enabled !== "boolean" || !/^\d+\.\d+\.\d+$/.test(p2.version ?? "") || !path20.isAbsolute(p2.installPath ?? "") || p2.readFromFolder !== void 0 && (!path20.isAbsolute(p2.readFromFolder) || !/^\d+\.\d+\.\d+$/.test(p2.folderVersion ?? ""))))
27138
27370
  fail7("claude_existing_registration_requires_review");
27139
27371
  const found = markets.filter((p2) => p2?.name === marketplace);
27140
27372
  if (found.length > 1 || found.some((p2) => p2.source !== "directory" || p2.path !== root || p2.installLocation !== root))
@@ -27154,19 +27386,19 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
27154
27386
  const directory3 = await info4(root);
27155
27387
  if (!directory3?.isDirectory() || directory3.isSymbolicLink() || directory3.uid !== process.getuid?.() || directory3.mode & 63)
27156
27388
  fail7("claude_installed_files_invalid");
27157
- const ready = await privateRead5(path19.join(root, "installation.json"));
27389
+ const ready = await privateRead6(path20.join(root, "installation.json"));
27158
27390
  if (!ready || ready.host !== "claude-code" || ready.version !== version3 || ready.profile !== profile || ready.configFile !== configFile2 || ready.payloadDigest !== payloadDigest || !Array.isArray(ready.files) || ready.files.length > 1024) fail7("claude_installed_files_invalid");
27159
27391
  const actual = await inspectRuntimePackage(root);
27160
- if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
27392
+ if (actual.version !== version3 || JSON.stringify(actual.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))) !== JSON.stringify(ready.files))
27161
27393
  fail7("claude_installed_files_invalid");
27162
- const manifest = JSON.parse(await readFile9(path19.join(root, ".claude-plugin/plugin.json"), "utf8"));
27394
+ const manifest = JSON.parse(await readFile9(path20.join(root, ".claude-plugin/plugin.json"), "utf8"));
27163
27395
  if (manifest.name !== pluginName || manifest.version !== version3 || manifest.skills !== "./skills/" || manifest.mcpServers !== "./.claude-mcp.json")
27164
27396
  fail7("claude_installed_files_invalid");
27165
27397
  let runtimeCommand;
27166
27398
  for (const file of [".mcp.json", ".claude-mcp.json"]) {
27167
- const mcp = JSON.parse(await readFile9(path19.join(root, file), "utf8"));
27399
+ const mcp = JSON.parse(await readFile9(path20.join(root, file), "utf8"));
27168
27400
  const command2 = mcp.mcpServers?.[serverName]?.command;
27169
- if (!path19.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
27401
+ if (!path20.isAbsolute(command2 ?? "") || runtimeCommand !== void 0 && command2 !== runtimeCommand || JSON.stringify(mcp) !== JSON.stringify(transport(serverName, configFile2, command2))) fail7("claude_installed_files_invalid");
27170
27402
  runtimeCommand = command2;
27171
27403
  }
27172
27404
  if (compareVersions3(version3, "0.3.1") >= 0 && JSON.stringify(manifest.hooks) !== JSON.stringify(claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand: runtimeCommand })))
@@ -27176,8 +27408,8 @@ async function verifyVersion2(root, { version: version3, profile, configFile: co
27176
27408
  async function installForClaudeUser(options = {}) {
27177
27409
  const profile = options.profile ?? "default", env = options.env ?? process.env;
27178
27410
  validProfile2(profile);
27179
- const modeRoot = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
27180
- await privateDirectory6(modeRoot);
27411
+ const modeRoot = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile, "claude-code-mode");
27412
+ await privateDirectory7(modeRoot);
27181
27413
  const release = await acquire4(modeRoot, options.signal);
27182
27414
  try {
27183
27415
  return await installClaudeUserLocked(options);
@@ -27198,37 +27430,37 @@ async function installClaudeUserLocked({
27198
27430
  nodeCommand = process.execPath
27199
27431
  } = {}) {
27200
27432
  validProfile2(profile);
27201
- if (!path19.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
27433
+ if (!path20.isAbsolute(nodeCommand)) fail7("runtime_command_invalid");
27202
27434
  const hostVersion = (await runClaude(["--version"])).trim().match(/^(\d+\.\d+\.\d+) \(Claude Code\)$/);
27203
27435
  if (!hostVersion || compareVersions3(hostVersion[1], "2.1.295") < 0) fail7("claude_21295_required");
27204
27436
  const help = await runClaude(["--help"]);
27205
27437
  if (typeof help !== "string" || Buffer.byteLength(help) > 128 * 1024) fail7("claude_capabilities_unconfirmed");
27206
27438
  const hasPlugin = /^\s+plugin(?:\|plugins)?\s/m.test(help), hasMcp = /^\s+mcp\s/m.test(help);
27207
- const base = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path19.join(base, "claude-code-mcp"), pluginRoot = path19.join(base, "claude-code");
27208
- const pluginPending = await info4(path19.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path19.join(pluginRoot, "current.json")), fallbackState = await info4(path19.join(fallbackRoot, "current.json")) || await info4(path19.join(fallbackRoot, "registration-pending.json"));
27439
+ const base = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile), fallbackRoot = path20.join(base, "claude-code-mcp"), pluginRoot = path20.join(base, "claude-code");
27440
+ const pluginPending = await info4(path20.join(pluginRoot, "registration-pending.json")), pluginCurrent = await info4(path20.join(pluginRoot, "current.json")), fallbackState = await info4(path20.join(fallbackRoot, "current.json")) || await info4(path20.join(fallbackRoot, "registration-pending.json"));
27209
27441
  if ((!hasPlugin || fallbackState) && (pluginPending || pluginCurrent)) fail7("registration_unconfirmed_keep_existing");
27210
27442
  if (!hasPlugin || fallbackState) {
27211
27443
  if (!hasMcp) fail7("claude_capabilities_unconfirmed");
27212
27444
  return installClaudeMcpFallback({ sourceRoot, profile, env, configFile: configFile2, signal, runClaude, checkRuntime, verifyInstalledRuntime, nodeCommand });
27213
27445
  }
27214
- const payload = await inspectRuntimePackage(path19.resolve(sourceRoot));
27446
+ const payload = await inspectRuntimePackage(path20.resolve(sourceRoot));
27215
27447
  if (!payload.files.some((f2) => f2.path === ".claude-plugin/plugin.json") || !payload.files.some((f2) => f2.path === ".claude-mcp.json"))
27216
27448
  fail7("claude_package_incomplete");
27217
- const root = path19.resolve(env.XDG_DATA_HOME ?? path19.join(homedir10(), ".local/share"), "promptframe-creation", profile, "claude-code");
27218
- await privateDirectory6(root);
27449
+ const root = path20.resolve(env.XDG_DATA_HOME ?? path20.join(homedir11(), ".local/share"), "promptframe-creation", profile, "claude-code");
27450
+ await privateDirectory7(root);
27219
27451
  const release = await acquire4(root, signal);
27220
27452
  const suffix = profile === "default" ? "" : "-" + profile, pluginName = "promptframe-creation" + suffix, marketplace = "promptframe-creation-user" + suffix, pluginId = pluginName + "@" + marketplace, serverName = "promptframe" + suffix;
27221
- const versions = path19.join(root, "versions"), currentFile = path19.join(root, "current.json"), pendingFile = path19.join(root, "registration-pending.json"), catalogFile = path19.join(root, ".claude-plugin/marketplace.json"), versionRoot = path19.join(versions, payload.version), temporary = path19.join(versions, ".partial-" + randomBytes7(12).toString("hex"));
27453
+ const versions = path20.join(root, "versions"), currentFile = path20.join(root, "current.json"), pendingFile = path20.join(root, "registration-pending.json"), catalogFile = path20.join(root, ".claude-plugin/marketplace.json"), versionRoot = path20.join(versions, payload.version), temporary = path20.join(versions, ".partial-" + randomBytes8(12).toString("hex"));
27222
27454
  let registrationStarted = false, newFiles = 0;
27223
27455
  try {
27224
27456
  signal?.throwIfAborted();
27225
- await privateDirectory6(versions);
27226
- await privateDirectory6(path19.dirname(catalogFile));
27457
+ await privateDirectory7(versions);
27458
+ await privateDirectory7(path20.dirname(catalogFile));
27227
27459
  await legacyUserMcp(env, serverName);
27228
- let previous = await privateRead5(currentFile), pending = await privateRead5(pendingFile), state = await registrations(runClaude, pluginName, marketplace, root);
27460
+ let previous = await privateRead6(currentFile), pending = await privateRead6(pendingFile), state = await registrations(runClaude, pluginName, marketplace, root);
27229
27461
  const binding = { profile, configFile: configFile2, pluginId, pluginName, serverName, host: "claude-code" };
27230
27462
  const checkBinding = (record2) => {
27231
- if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path19.join(versions, record2.version))) fail7("profile_binding_conflict");
27463
+ if (record2 && (record2.profile !== profile || record2.configFile !== configFile2 || record2.pluginId !== pluginId || record2.host !== "claude-code" || !/^\d+\.\d+\.\d+$/.test(record2.version ?? "") || record2.versionRoot !== path20.join(versions, record2.version))) fail7("profile_binding_conflict");
27232
27464
  };
27233
27465
  checkBinding(previous);
27234
27466
  checkBinding(pending);
@@ -27272,12 +27504,12 @@ async function installClaudeUserLocked({
27272
27504
  const ready = await verifyVersion2(versionRoot, { ...complete, pluginName, serverName });
27273
27505
  runtimeCommands.set(versionRoot, ready.runtimeCommand);
27274
27506
  } else {
27275
- await mkdir8(temporary, { mode: 448 });
27507
+ await mkdir9(temporary, { mode: 448 });
27276
27508
  for (const file of payload.files) {
27277
27509
  signal?.throwIfAborted();
27278
- const dest = path19.join(temporary, file.path);
27279
- await mkdir8(path19.dirname(dest), { recursive: true, mode: 448 });
27280
- const fd = await open11(dest, "wx", 384);
27510
+ const dest = path20.join(temporary, file.path);
27511
+ await mkdir9(path20.dirname(dest), { recursive: true, mode: 448 });
27512
+ const fd = await open12(dest, "wx", 384);
27281
27513
  try {
27282
27514
  await fd.writeFile(file.body);
27283
27515
  await fd.sync();
@@ -27285,21 +27517,21 @@ async function installClaudeUserLocked({
27285
27517
  await fd.close();
27286
27518
  }
27287
27519
  }
27288
- const manifest = JSON.parse(await readFile9(path19.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
27520
+ const manifest = JSON.parse(await readFile9(path20.join(temporary, ".claude-plugin/plugin.json"), "utf8"));
27289
27521
  manifest.name = pluginName;
27290
27522
  if (manifest.hooks) manifest.hooks = claudeHostHooks({ pluginName, configFile: configFile2, nodeCommand });
27291
- await atomicJSON4(path19.join(temporary, ".claude-plugin/plugin.json"), manifest);
27292
- for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path19.join(temporary, file), transport(serverName, configFile2, nodeCommand));
27523
+ await atomicJSON4(path20.join(temporary, ".claude-plugin/plugin.json"), manifest);
27524
+ for (const file of [".mcp.json", ".claude-mcp.json"]) await atomicJSON4(path20.join(temporary, file), transport(serverName, configFile2, nodeCommand));
27293
27525
  await checkRuntime(temporary, payload.version);
27294
27526
  const installed = await inspectRuntimePackage(temporary);
27295
- await atomicJSON4(path19.join(temporary, "installation.json"), {
27527
+ await atomicJSON4(path20.join(temporary, "installation.json"), {
27296
27528
  ...binding,
27297
27529
  version: payload.version,
27298
27530
  payloadDigest: payload.payloadDigest,
27299
- files: installed.files.map(({ path: path21, bytes: bytes2, sha256 }) => ({ path: path21, bytes: bytes2, sha256 }))
27531
+ files: installed.files.map(({ path: path23, bytes: bytes2, sha256 }) => ({ path: path23, bytes: bytes2, sha256 }))
27300
27532
  });
27301
27533
  signal?.throwIfAborted();
27302
- await rename8(temporary, versionRoot);
27534
+ await rename9(temporary, versionRoot);
27303
27535
  newFiles = payload.files.length;
27304
27536
  }
27305
27537
  if (newFiles === 0) await verifyInstalledRuntime(versionRoot, payload.version, runtimeCommands.get(versionRoot), { env });
@@ -27334,14 +27566,14 @@ async function installClaudeUserLocked({
27334
27566
  requestedVersion: payload.version,
27335
27567
  recordedRuntimeRetained: runtimeCommands.has(versionRoot) && runtimeCommands.get(versionRoot) !== nodeCommand
27336
27568
  };
27337
- } catch (error5) {
27569
+ } catch (error6) {
27338
27570
  if (registrationStarted) fail7("registration_unconfirmed_keep_existing", {
27339
- ...claudeErrorDetails(error5),
27571
+ ...claudeErrorDetails(error6),
27340
27572
  phase: "registration_observation",
27341
27573
  localRegistrationState: "unknown",
27342
27574
  action: "inspect_same_registration_no_second_add"
27343
27575
  });
27344
- if (error5 instanceof CreationClientError) throw error5;
27576
+ if (error6 instanceof CreationClientError) throw error6;
27345
27577
  fail7(signal?.aborted ? "interrupted_keep_existing" : "failed_keep_existing");
27346
27578
  } finally {
27347
27579
  await rm5(temporary, { recursive: true, force: true });
@@ -27349,9 +27581,307 @@ async function installClaudeUserLocked({
27349
27581
  }
27350
27582
  }
27351
27583
 
27584
+ // lib/antigravity-installation.mjs
27585
+ import { lstat as lstat13, mkdir as mkdir10, open as open13, readFile as readFile10, rename as rename10, rm as rm6 } from "node:fs/promises";
27586
+ import { constants as constants9 } from "node:fs";
27587
+ import { createHash as createHash14, randomBytes as randomBytes9 } from "node:crypto";
27588
+ import { homedir as homedir12 } from "node:os";
27589
+ import path21 from "node:path";
27590
+ var hash7 = (b2) => createHash14("sha256").update(b2).digest("hex");
27591
+ var AntigravityInstallationError = class extends CreationClientError {
27592
+ constructor(code, details) {
27593
+ super("installation." + code);
27594
+ this.details = details;
27595
+ }
27596
+ };
27597
+ var antigravityInstallationDetails = (error6) => error6 instanceof AntigravityInstallationError ? error6.details : void 0;
27598
+ var fail8 = (code, details) => {
27599
+ throw new AntigravityInstallationError(code, details);
27600
+ };
27601
+ var profileFormat = /^[a-z0-9][a-z0-9-]{0,39}$/;
27602
+ var antigravityServerName = (profile) => "promptframe-creation" + (profile === "default" ? "" : "-" + profile);
27603
+ var object3 = (value2) => value2 !== null && typeof value2 === "object" && !Array.isArray(value2);
27604
+ function usesCreationBridge(server, { profile, configFile: configFile2 }) {
27605
+ if (!object3(server) || typeof server.command !== "string" || !Array.isArray(server.args)) return false;
27606
+ const args2 = server.args;
27607
+ const bridgeIndex = args2.indexOf("bridge");
27608
+ if (bridgeIndex < 0) return false;
27609
+ const isCreationExecutable = (value2) => typeof value2 === "string" && /^promptframe-creation(?:\.mjs|\.cmd|\.exe)?$/.test(path21.win32.basename(value2));
27610
+ const command2 = path21.win32.basename(server.command);
27611
+ const bridgeLauncher = isCreationExecutable(command2) || /^(?:node|nodejs|bun)(?:\.exe)?$/.test(command2) && isCreationExecutable(args2[bridgeIndex - 1]) || /^(?:npx|npm|pnpm|yarn|bunx)(?:\.cmd|\.exe)?$/.test(command2) && typeof args2[bridgeIndex - 1] === "string" && /^@promptframe\/creation(?:@[^\s]+)?$/.test(args2[bridgeIndex - 1]);
27612
+ if (!bridgeLauncher) return false;
27613
+ const configIndex = args2.indexOf("--config", bridgeIndex + 1);
27614
+ const profileIndex = args2.indexOf("--profile", bridgeIndex + 1);
27615
+ const configuredProfile = profileIndex < 0 ? "default" : args2[profileIndex + 1];
27616
+ const configuredFile = configIndex >= 0 ? args2[configIndex + 1] : configuredProfile === "default" ? server.env?.PROMPTFRAME_CREATION_CONFIG : void 0;
27617
+ if (typeof configuredFile === "string" && path21.isAbsolute(configuredFile)) return path21.resolve(configuredFile) === configFile2;
27618
+ return configuredProfile === profile;
27619
+ }
27620
+ async function checkAntigravityMcpConflicts({ profile = "default", configFile: configFile2, env = process.env } = {}) {
27621
+ const mcpConfigFile = path21.join(antigravityConfigRoot(env), "mcp_config.json");
27622
+ const unreadable = () => fail8("antigravity_mcp_config_unreadable", {
27623
+ mcpConfigFile,
27624
+ action: "Check that the Antigravity MCP configuration is readable and contains a valid JSON object, then retry connect."
27625
+ });
27626
+ let file;
27627
+ try {
27628
+ file = await open13(mcpConfigFile, constants9.O_RDONLY | constants9.O_NONBLOCK);
27629
+ } catch (error6) {
27630
+ if (error6.code === "ENOENT") return;
27631
+ unreadable();
27632
+ }
27633
+ let config2;
27634
+ try {
27635
+ const info5 = await file.stat();
27636
+ if (!info5.isFile() || info5.size > 4 * 1024 * 1024) unreadable();
27637
+ config2 = JSON.parse(await file.readFile("utf8"));
27638
+ } catch {
27639
+ unreadable();
27640
+ } finally {
27641
+ await file.close();
27642
+ }
27643
+ if (!object3(config2) || config2.mcpServers !== void 0 && !object3(config2.mcpServers)) unreadable();
27644
+ const serverName = antigravityServerName(profile);
27645
+ const mcpServerNames = Object.entries(config2.mcpServers ?? {}).filter(([name, server]) => name === serverName || name === `${serverName}_${serverName}` || profile === "default" && name === "promptframe" || usesCreationBridge(server, { profile, configFile: configFile2 })).map(([name]) => name);
27646
+ if (mcpServerNames.length) fail8("legacy_mcp_entry_requires_review", {
27647
+ mcpConfigFile,
27648
+ mcpServerNames,
27649
+ action: "In Antigravity MCP settings, review the listed entries and remove the conflicting manual PromptFrame entries, then rerun connect with the existing Token."
27650
+ });
27651
+ }
27652
+ function shellQuote(value2) {
27653
+ return '"' + String(value2).replace(/(["\\$`])/g, "\\$1") + '"';
27654
+ }
27655
+ function antigravityPluginManifest({ version: version3, name = "promptframe-creation", displayName = "PromptFrame Creation" }) {
27656
+ return {
27657
+ name,
27658
+ displayName,
27659
+ description: "PromptFrame video creation Skill and MCP bridge for Antigravity: inspect projects, plan shots, search/author components, preview and render videos.",
27660
+ version: version3,
27661
+ repository: "https://github.com/ty-teams/promptframe-creation",
27662
+ suggestedPrompts: [
27663
+ "\u5217\u51FA\u6211\u5728 PromptFrame \u5F53\u524D\u9879\u76EE\u4E2D\u7684\u4F5C\u54C1\u5E76\u8BFB\u53D6\u6700\u65B0\u72B6\u6001",
27664
+ "\u5E2E\u6211\u5728 PromptFrame \u4E2D\u89C4\u5212\u5E76\u521B\u5EFA\u4E00\u4E2A\u65B0\u7684\u79D1\u666E\u89C6\u9891\u5206\u955C",
27665
+ "\u5728\u7EC4\u4EF6\u5E02\u573A\u641C\u7D22\u9002\u5408\u6570\u636E\u5BF9\u6BD4\u5C55\u793A\u7684\u53EF\u89C6\u5316\u7EC4\u4EF6"
27666
+ ]
27667
+ };
27668
+ }
27669
+ function antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot, configFile: configFile2 }) {
27670
+ return {
27671
+ mcpServers: {
27672
+ [serverName]: {
27673
+ command: nodeCommand,
27674
+ args: [path21.join(runtimeRoot, "bin", "promptframe-creation.mjs"), "bridge", "--config", configFile2, "--host", "antigravity"]
27675
+ }
27676
+ }
27677
+ };
27678
+ }
27679
+ function antigravityHooksConfig({ nodeCommand, runtimeRoot, configFile: configFile2, serverName }) {
27680
+ const cliPath = path21.join(runtimeRoot, "bin", "promptframe-creation.mjs");
27681
+ const command2 = [
27682
+ shellQuote(nodeCommand),
27683
+ shellQuote(cliPath),
27684
+ "antigravity-host-hook",
27685
+ "--config",
27686
+ shellQuote(configFile2),
27687
+ "--mcp-server",
27688
+ shellQuote(`${serverName}_${serverName}`)
27689
+ ].join(" ");
27690
+ return {
27691
+ "promptframe-host-identity": {
27692
+ SessionStart: [{ type: "command", command: command2 + " --hook-event SessionStart", timeout: 5 }],
27693
+ PreToolUse: [
27694
+ {
27695
+ matcher: "(.*promptframe.*|^platform_.*|^call_mcp_tool$)",
27696
+ hooks: [{ type: "command", command: command2 + " --hook-event PreToolUse", timeout: 5 }]
27697
+ }
27698
+ ]
27699
+ }
27700
+ };
27701
+ }
27702
+ async function readJsonOrNull(file) {
27703
+ try {
27704
+ return JSON.parse(await readFile10(file, "utf8"));
27705
+ } catch (e) {
27706
+ if (e.code === "ENOENT") return null;
27707
+ throw e;
27708
+ }
27709
+ }
27710
+ async function writeFileAtomic(file, content, mode = 384) {
27711
+ await mkdir10(path21.dirname(file), { recursive: true, mode: 448 });
27712
+ const tmp = file + "." + randomBytes9(8).toString("hex") + ".partial";
27713
+ const fd = await open13(tmp, "wx", mode);
27714
+ try {
27715
+ await fd.writeFile(content);
27716
+ await fd.sync();
27717
+ } finally {
27718
+ await fd.close();
27719
+ }
27720
+ await rename10(tmp, file);
27721
+ }
27722
+ async function copyPackagePayload(payload, destRoot) {
27723
+ const tmp = destRoot + ".partial-" + randomBytes9(8).toString("hex");
27724
+ await mkdir10(tmp, { recursive: true, mode: 448 });
27725
+ try {
27726
+ for (const file of payload.files) {
27727
+ const dest = path21.join(tmp, ...file.path.split("/"));
27728
+ await mkdir10(path21.dirname(dest), { recursive: true, mode: 448 });
27729
+ const fd = await open13(dest, "wx", 384);
27730
+ try {
27731
+ await fd.writeFile(file.body);
27732
+ await fd.sync();
27733
+ } finally {
27734
+ await fd.close();
27735
+ }
27736
+ }
27737
+ await rename10(tmp, destRoot);
27738
+ } catch (e) {
27739
+ await rm6(tmp, { recursive: true, force: true }).catch(() => {
27740
+ });
27741
+ throw e;
27742
+ }
27743
+ }
27744
+ async function installForAntigravityUser({
27745
+ sourceRoot,
27746
+ profile = "default",
27747
+ configFile: configFile2,
27748
+ env = process.env,
27749
+ nodeCommand = process.execPath,
27750
+ signal
27751
+ } = {}) {
27752
+ if (!profileFormat.test(profile)) fail8("profile_invalid");
27753
+ if (!path21.isAbsolute(configFile2 ?? "")) fail8("config_path_invalid");
27754
+ signal?.throwIfAborted();
27755
+ await checkAntigravityMcpConflicts({ profile, configFile: configFile2, env });
27756
+ const payload = await inspectRuntimePackage(sourceRoot);
27757
+ const serverName = antigravityServerName(profile);
27758
+ const pluginDirName = serverName;
27759
+ const dataRoot = path21.resolve(env.XDG_DATA_HOME ?? path21.join(homedir12(), ".local", "share"), "promptframe-creation", profile, "antigravity");
27760
+ const versionRoot = path21.join(dataRoot, "versions", payload.version);
27761
+ const pluginsRoot = path21.join(antigravityConfigRoot(env), "plugins");
27762
+ const pluginDir = path21.join(pluginsRoot, pluginDirName);
27763
+ const markerFile = path21.join(pluginDir, "promptframe-installation.json");
27764
+ let pluginDirectoryExists = false;
27765
+ try {
27766
+ const status = await lstat13(pluginDir);
27767
+ if (!status.isDirectory() || status.isSymbolicLink()) fail8("managed_installation_invalid");
27768
+ pluginDirectoryExists = true;
27769
+ } catch (error6) {
27770
+ if (error6.code !== "ENOENT") throw error6;
27771
+ }
27772
+ const existing = await readJsonOrNull(markerFile);
27773
+ if (pluginDirectoryExists && !existing) fail8("managed_installation_invalid");
27774
+ if (existing) {
27775
+ if (existing.host !== "antigravity" || existing.profile !== profile || existing.configFile !== configFile2 || typeof existing.version !== "string" || !/^\d+\.\d+\.\d+$/.test(existing.version)) fail8("managed_installation_invalid");
27776
+ const cmp = compareBridgeVersions(existing.version, payload.version);
27777
+ if (cmp > 0) {
27778
+ return {
27779
+ registered: true,
27780
+ pluginInstalled: true,
27781
+ pluginEnabled: true,
27782
+ reused: true,
27783
+ host: "antigravity",
27784
+ installationMode: "antigravity-plugin",
27785
+ profile,
27786
+ version: existing.version,
27787
+ requestedVersion: payload.version,
27788
+ versionStatus: "newer_installed_kept",
27789
+ recordedRuntimeRetained: true,
27790
+ pluginDir,
27791
+ serverName,
27792
+ skillsInstalled: true,
27793
+ skills: [{ name: "creation-setup" }, { name: "video-creation" }]
27794
+ };
27795
+ }
27796
+ if (cmp === 0 && existing.payloadDigest === payload.payloadDigest && existing.versionRoot === versionRoot) {
27797
+ return {
27798
+ registered: true,
27799
+ pluginInstalled: true,
27800
+ pluginEnabled: true,
27801
+ reused: true,
27802
+ host: "antigravity",
27803
+ installationMode: "antigravity-plugin",
27804
+ profile,
27805
+ version: payload.version,
27806
+ requestedVersion: payload.version,
27807
+ versionStatus: "already_current",
27808
+ recordedRuntimeRetained: false,
27809
+ pluginDir,
27810
+ serverName,
27811
+ skillsInstalled: true,
27812
+ skills: [{ name: "creation-setup" }, { name: "video-creation" }]
27813
+ };
27814
+ }
27815
+ }
27816
+ let versionExists = false;
27817
+ try {
27818
+ const s3 = await lstat13(versionRoot);
27819
+ versionExists = s3.isDirectory() && !s3.isSymbolicLink();
27820
+ } catch (e) {
27821
+ if (e.code !== "ENOENT") throw e;
27822
+ }
27823
+ if (!versionExists) {
27824
+ await mkdir10(path21.dirname(versionRoot), { recursive: true, mode: 448 });
27825
+ await copyPackagePayload(payload, versionRoot);
27826
+ }
27827
+ signal?.throwIfAborted();
27828
+ if (!existing) {
27829
+ await mkdir10(pluginsRoot, { recursive: true, mode: 448 });
27830
+ await mkdir10(pluginDir, { mode: 448 });
27831
+ }
27832
+ const pluginJson = JSON.stringify(antigravityPluginManifest({
27833
+ version: payload.version,
27834
+ name: pluginDirName,
27835
+ displayName: profile === "default" ? "PromptFrame Creation" : "PromptFrame Creation (" + profile + ")"
27836
+ }), null, 2) + "\n";
27837
+ const mcpJson = JSON.stringify(antigravityMcpConfig({ serverName, nodeCommand, runtimeRoot: versionRoot, configFile: configFile2 }), null, 2) + "\n";
27838
+ const hooksJson = JSON.stringify(antigravityHooksConfig({ nodeCommand, runtimeRoot: versionRoot, configFile: configFile2, serverName }), null, 2) + "\n";
27839
+ await writeFileAtomic(path21.join(pluginDir, "plugin.json"), pluginJson, 420);
27840
+ await writeFileAtomic(path21.join(pluginDir, "mcp_config.json"), mcpJson, 384);
27841
+ await writeFileAtomic(path21.join(pluginDir, "hooks.json"), hooksJson, 384);
27842
+ const skillEntries = payload.files.filter((f2) => f2.path.startsWith("skills/") && f2.path.endsWith("/SKILL.md"));
27843
+ for (const skill of skillEntries) {
27844
+ const dest = path21.join(pluginDir, ...skill.path.split("/"));
27845
+ await writeFileAtomic(dest, skill.body, 420);
27846
+ }
27847
+ const record2 = {
27848
+ contractVersion: "antigravity-plugin-installation/v1",
27849
+ host: "antigravity",
27850
+ profile,
27851
+ configFile: configFile2,
27852
+ pluginDirName,
27853
+ serverName,
27854
+ version: payload.version,
27855
+ versionRoot,
27856
+ nodeCommand,
27857
+ payloadDigest: payload.payloadDigest,
27858
+ mcpDigest: hash7(mcpJson),
27859
+ hooksDigest: hash7(hooksJson),
27860
+ installedAt: (/* @__PURE__ */ new Date()).toISOString()
27861
+ };
27862
+ await writeFileAtomic(markerFile, JSON.stringify(record2, null, 2) + "\n", 384);
27863
+ return {
27864
+ registered: true,
27865
+ pluginInstalled: true,
27866
+ pluginEnabled: true,
27867
+ reused: false,
27868
+ host: "antigravity",
27869
+ installationMode: "antigravity-plugin",
27870
+ profile,
27871
+ version: payload.version,
27872
+ requestedVersion: payload.version,
27873
+ versionStatus: existing ? "upgraded" : "installed",
27874
+ recordedRuntimeRetained: false,
27875
+ pluginDir,
27876
+ serverName,
27877
+ skillsInstalled: true,
27878
+ skills: skillEntries.map((s3) => ({ name: s3.path.split("/")[1] }))
27879
+ };
27880
+ }
27881
+
27352
27882
  // lib/cli.mjs
27353
27883
  import { fileURLToPath } from "node:url";
27354
- import path20 from "node:path";
27884
+ import path22 from "node:path";
27355
27885
  var args = process.argv.slice(2);
27356
27886
  var command = args.shift();
27357
27887
  var value = (key) => {
@@ -27359,7 +27889,7 @@ var value = (key) => {
27359
27889
  return i < 0 ? void 0 : args[i + 1];
27360
27890
  };
27361
27891
  var log = (value2) => process.stdout.write(JSON.stringify(value2) + "\n");
27362
- var configFile = () => value("--config") ? path20.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
27892
+ var configFile = () => value("--config") ? path22.resolve(value("--config")) : profileCredentialsPath(value("--profile") ?? "default");
27363
27893
  async function probe(credentials) {
27364
27894
  const client = await connectPlatform(credentials, { host: resolveHostIdentity({ host: value("--host") }), clientConfigFile: configFile() });
27365
27895
  try {
@@ -27380,8 +27910,8 @@ async function rememberAuthorization(credentials, file, accountIdentity) {
27380
27910
  profile: value("--profile") ?? "default"
27381
27911
  });
27382
27912
  return { status: "recorded" };
27383
- } catch (error5) {
27384
- return { status: "unavailable", reasonCode: error5 instanceof CreationClientError ? error5.message : "accounts.storage_unavailable" };
27913
+ } catch (error6) {
27914
+ return { status: "unavailable", reasonCode: error6 instanceof CreationClientError ? error6.message : "accounts.storage_unavailable" };
27385
27915
  }
27386
27916
  }
27387
27917
  async function tokenInput() {
@@ -27481,8 +28011,8 @@ async function setup({ silent = false } = {}) {
27481
28011
  version: 1,
27482
28012
  endpoint,
27483
28013
  token,
27484
- clientId: existing?.clientId ?? randomBytes8(24).toString("base64url"),
27485
- clientName: value("--name") ?? existing?.clientName ?? (resolveHostIdentity({ host: value("--host") }).kind === "claude-code" ? "Claude Code PromptFrame" : "Codex PromptFrame"),
28014
+ clientId: existing?.clientId ?? randomBytes10(24).toString("base64url"),
28015
+ clientName: value("--name") ?? existing?.clientName ?? hostClientName("Codex PromptFrame", resolveHostIdentity({ host: value("--host") })),
27486
28016
  createdAt: existing?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString()
27487
28017
  };
27488
28018
  const { tools, accountIdentity } = await probe(credentials);
@@ -27518,14 +28048,14 @@ async function bridge() {
27518
28048
  resolvedVersion: value("--resolved-runtime-version"),
27519
28049
  signal: startup.signal,
27520
28050
  hostKind: identity.kind,
27521
- cacheRoot: path20.join(path20.dirname(configFile()), "runtime-cache")
28051
+ cacheRoot: path22.join(path22.dirname(configFile()), "runtime-cache")
27522
28052
  });
27523
28053
  startup.signal.throwIfAborted();
27524
- } catch (error5) {
28054
+ } catch (error6) {
27525
28055
  await client?.close().catch(() => {
27526
28056
  });
27527
28057
  if (startup.signal.aborted) throw new CreationClientError("creation.runtime_selection_interrupted");
27528
- throw error5;
28058
+ throw error6;
27529
28059
  } finally {
27530
28060
  process.removeListener("SIGINT", abort);
27531
28061
  process.removeListener("SIGTERM", abort);
@@ -27537,7 +28067,7 @@ async function bridge() {
27537
28067
  return;
27538
28068
  }
27539
28069
  await rememberAuthorization(credentials, configFile(), connectionAccountIdentity(client));
27540
- const hostSession = identity.kind === "claude-code" ? await createClaudeHostSession({ configFile: configFile() }) : void 0;
28070
+ const hostSession = identity.kind === "claude-code" ? await createClaudeHostSession({ configFile: configFile() }) : identity.kind === "antigravity" ? await createAntigravityHostSession({ configFile: configFile() }) : void 0;
27541
28071
  const server = new Server(
27542
28072
  { name: "promptframe-creation", version: CLIENT_VERSION },
27543
28073
  { capabilities: {
@@ -27557,9 +28087,9 @@ async function bridge() {
27557
28087
  hostSession,
27558
28088
  connectionOptions: { contentTypes: () => contentTypes, contentSource: () => contentSource },
27559
28089
  createLocalUploads: ({ identity: account, agent, configFile: file }) => createLocalUploadManager({
27560
- stateRoot: path20.join(path20.dirname(file), "local-upload-state", "accounts", localAccountKey(account), localAgentDigest(agent).slice(7))
28090
+ stateRoot: path22.join(path22.dirname(file), "local-upload-state", "accounts", localAccountKey(account), localAgentDigest(agent).slice(7))
27561
28091
  }),
27562
- localUploads: createLocalUploadManager({ stateRoot: path20.join(path20.dirname(configFile()), "local-upload-state") }),
28092
+ localUploads: createLocalUploadManager({ stateRoot: path22.join(path22.dirname(configFile()), "local-upload-state") }),
27563
28093
  onCatalogChange: () => server.sendToolListChanged(),
27564
28094
  onKnowledgeChange: (kind) => kind === "resources" ? server.sendResourceListChanged() : server.sendPromptListChanged()
27565
28095
  });
@@ -27574,11 +28104,11 @@ async function bridge() {
27574
28104
  const knowledgeHandler = (schema, method) => server.setRequestHandler(schema, async (request) => {
27575
28105
  try {
27576
28106
  return await host[method](request.params ?? {});
27577
- } catch (error5) {
27578
- const remote = error5?.data?.errorCode;
27579
- const code = error5 instanceof CreationClientError ? error5.message : typeof remote === "string" && /^(?:creation|creative_skill)\.[a-z0-9_.:-]{1,160}$/.test(remote) ? remote : "creation.connection_unresolved";
27580
- const knownRemote = typeof remote === "string" && code === remote && typeof error5.code === "number" && Object.values(ErrorCode).includes(error5.code);
27581
- throw new McpError(knownRemote ? error5.code : error5 instanceof CreationClientError ? ErrorCode.InvalidParams : ErrorCode.InternalError, code, { errorCode: code });
28107
+ } catch (error6) {
28108
+ const remote = error6?.data?.errorCode;
28109
+ const code = error6 instanceof CreationClientError ? error6.message : typeof remote === "string" && /^(?:creation|creative_skill)\.[a-z0-9_.:-]{1,160}$/.test(remote) ? remote : "creation.connection_unresolved";
28110
+ const knownRemote = typeof remote === "string" && code === remote && typeof error6.code === "number" && Object.values(ErrorCode).includes(error6.code);
28111
+ throw new McpError(knownRemote ? error6.code : error6 instanceof CreationClientError ? ErrorCode.InvalidParams : ErrorCode.InternalError, code, { errorCode: code });
27582
28112
  }
27583
28113
  });
27584
28114
  if (upstream.resources) {
@@ -27600,7 +28130,7 @@ async function bridge() {
27600
28130
  server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
27601
28131
  try {
27602
28132
  return await host.call(request.params, { signal: extra.signal });
27603
- } catch (error5) {
28133
+ } catch (error6) {
27604
28134
  return {
27605
28135
  isError: true,
27606
28136
  content: [
@@ -27608,9 +28138,9 @@ async function bridge() {
27608
28138
  type: "text",
27609
28139
  text: JSON.stringify({
27610
28140
  success: false,
27611
- errorCode: error5 instanceof CreationClientError ? error5.message : "creation.connection_unresolved",
27612
- ...error5 instanceof CreationClientError && error5.message === "creation.host_session_changed" ? { effectStatus: "unknown", automaticReplayAllowed: false } : {},
27613
- action: error5 instanceof CreationClientError ? error5.message === "creation.host_session_changed" ? "read_original_task_without_replaying_business" : error5.message.startsWith("creation.host_") ? "use_supported_host_with_session_identity" : error5.message === "creation.editor_not_current" ? "request_control_and_confirm_in_studio" : "read_current_platform_facts_without_replaying_business" : "read_original_task_or_retry_same_idempotency_key"
28141
+ errorCode: error6 instanceof CreationClientError ? error6.message : "creation.connection_unresolved",
28142
+ ...error6 instanceof CreationClientError && error6.message === "creation.host_session_changed" ? { effectStatus: "unknown", automaticReplayAllowed: false } : {},
28143
+ action: error6 instanceof CreationClientError ? error6.message === "creation.host_session_changed" ? "read_original_task_without_replaying_business" : error6.message.startsWith("creation.host_") ? "use_supported_host_with_session_identity" : error6.message === "creation.editor_not_current" ? "request_control_and_confirm_in_studio" : "read_current_platform_facts_without_replaying_business" : "read_original_task_or_retry_same_idempotency_key"
27614
28144
  })
27615
28145
  }
27616
28146
  ]
@@ -27641,21 +28171,25 @@ async function bridge() {
27641
28171
  try {
27642
28172
  if (command === "setup") await setup();
27643
28173
  else if (command === "connect" || command === "install") {
28174
+ const host = resolveHostIdentity({ host: value("--host") });
28175
+ const profile = value("--profile") ?? "default";
28176
+ if (host.kind === "antigravity") await checkAntigravityMcpConflicts({ profile, configFile: configFile() });
27644
28177
  const connection = await setup({ silent: true });
27645
28178
  const signal = new AbortController();
27646
28179
  const abort = () => signal.abort();
27647
28180
  process.once("SIGINT", abort);
27648
28181
  process.once("SIGTERM", abort);
27649
28182
  try {
27650
- const host = resolveHostIdentity({ host: value("--host") }), installer = host.kind === "claude-code" ? installForClaudeUser : installForUser;
28183
+ const installer = host.kind === "claude-code" ? installForClaudeUser : host.kind === "antigravity" ? installForAntigravityUser : installForUser;
27651
28184
  const installed = await installer({
27652
28185
  sourceRoot: fileURLToPath(new URL("..", import.meta.url)),
27653
28186
  executable: value("--claude-bin"),
27654
- profile: value("--profile") ?? "default",
28187
+ profile,
27655
28188
  configFile: configFile(),
27656
28189
  signal: signal.signal
27657
28190
  });
27658
28191
  const skillNames = installed.skills?.map((skill) => skill.name) ?? ["creation-setup", "video-creation"];
28192
+ const nextStep = host.kind === "claude-code" ? "On this host, start a new Claude Code session." : host.kind === "antigravity" ? "On this host, start a new Antigravity conversation (or check promptframe-creation in Customizations)." : "On this host, open a new Local chat (CLI: start a new session).";
27659
28193
  log({
27660
28194
  ...connection,
27661
28195
  pluginRegistered: (installed.pluginInstalled ?? true) && installed.registered,
@@ -27665,6 +28199,7 @@ try {
27665
28199
  pluginInstalled: installed.pluginInstalled ?? true,
27666
28200
  pluginEnabled: installed.pluginEnabled ?? true,
27667
28201
  ...installed.installationMode ? { installationMode: installed.installationMode, skillsInstalled: installed.skillsInstalled, skills: skillNames } : {},
28202
+ ...installed.pluginDir ? { pluginDir: installed.pluginDir } : {},
27668
28203
  hostMcpConnected: "not_verified",
27669
28204
  sessionLoaded: "not_verified",
27670
28205
  installationReused: installed.reused,
@@ -27672,7 +28207,7 @@ try {
27672
28207
  requestedVersion: installed.requestedVersion,
27673
28208
  versionStatus: installed.versionStatus,
27674
28209
  recordedRuntimeRetained: installed.recordedRuntimeRetained ?? false,
27675
- next: (host.kind === "claude-code" ? "On this host, start a new Claude Code session." : "On this host, open a new Local chat (CLI: start a new session).") + " Check " + skillNames.join(", ") + " and the PromptFrame MCP tools together. Keep the existing Token; no reinstall or product repository is needed." + (installed.recordedRuntimeRetained ? " Keep this version's recorded Node path available." : ""),
28210
+ next: nextStep + " Check " + skillNames.join(", ") + " and the PromptFrame MCP tools together. Keep the existing Token; no reinstall or product repository is needed." + (installed.recordedRuntimeRetained ? " Keep this version's recorded Node path available." : ""),
27676
28211
  hostThreadIdentity: "verified_by_the_platform_on_actual_host_tool_calls"
27677
28212
  });
27678
28213
  } finally {
@@ -27681,6 +28216,11 @@ try {
27681
28216
  }
27682
28217
  } else if (command === "bridge") await bridge();
27683
28218
  else if (command === "claude-host-hook") await runClaudeHostHook({ configFile: configFile() });
28219
+ else if (command === "antigravity-host-hook") await runAntigravityHostHook({
28220
+ configFile: configFile(),
28221
+ serverName: value("--mcp-server"),
28222
+ event: value("--hook-event")
28223
+ });
27684
28224
  else if (command === "--version") process.stdout.write(CLIENT_VERSION + "\n");
27685
28225
  else if (command === "accounts") {
27686
28226
  if (args[0] === "refresh") {
@@ -27704,19 +28244,20 @@ try {
27704
28244
  });
27705
28245
  } else if (command === "help" || command === "--help" || !command) {
27706
28246
  process.stdout.write(
27707
- "promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0 or Claude Code >=2.1.295 with its structured plugin commands. Token input is masked in a terminal or accepted through --token-stdin; never use a Token command argument.\nBridge startup checks the platform minimum/recommended version. --bridge-version locks one exact compatible version for this new session; active bridges are not replaced.\n"
28247
+ "promptframe-creation connect --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--profile <environment-account>] [--claude-bin <absolute-file>] [--no-open]\npromptframe-creation setup --endpoint <platform-api-base> [--host codex|claude-code|antigravity] [--no-open] [--replace] [--name <client-name>]\npromptframe-creation status [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation accounts list\npromptframe-creation accounts refresh [--profile <environment-account>] [--host codex|claude-code|antigravity]\npromptframe-creation bridge [--config <private-file>] [--host codex|claude-code|antigravity] [--bridge-version <X.Y.Z>]\npromptframe-creation --version\nNode.js >=20 is required. Plugin installation supports Codex >=0.160.0, Claude Code >=2.1.295 or Google Antigravity. Token input is masked in a terminal or accepted through --token-stdin; never use a Token command argument.\nBridge startup checks the platform minimum/recommended version. --bridge-version locks one exact compatible version for this new session; active bridges are not replaced.\n"
27708
28248
  );
27709
28249
  } else throw new CreationClientError("command.unknown");
27710
- } catch (error5) {
28250
+ } catch (error6) {
27711
28251
  process.stderr.write(
27712
28252
  JSON.stringify({
27713
- ...installationErrorDetails(error5),
27714
- ...claudeInstallationDetails(error5),
27715
- ...claudeErrorDetails(error5),
27716
- ...fallbackErrorDetails(error5),
27717
- ...bridgeErrorDetails(error5),
27718
- ...runtimeErrorDetails(error5),
27719
- error: error5 instanceof CreationClientError ? error5.message : "creation.connection_failed"
28253
+ ...installationErrorDetails(error6),
28254
+ ...antigravityInstallationDetails(error6),
28255
+ ...claudeInstallationDetails(error6),
28256
+ ...claudeErrorDetails(error6),
28257
+ ...fallbackErrorDetails(error6),
28258
+ ...bridgeErrorDetails(error6),
28259
+ ...runtimeErrorDetails(error6),
28260
+ error: error6 instanceof CreationClientError ? error6.message : "creation.connection_failed"
27720
28261
  }) + "\n"
27721
28262
  );
27722
28263
  process.exitCode = 1;