@clef-sh/cli 0.1.6-beta.32 → 0.1.7-beta.45

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/index.mjs CHANGED
@@ -976,8 +976,8 @@ var require_command = __commonJS({
976
976
  "../../node_modules/commander/lib/command.js"(exports) {
977
977
  var EventEmitter = __require("node:events").EventEmitter;
978
978
  var childProcess = __require("node:child_process");
979
- var path43 = __require("node:path");
980
- var fs26 = __require("node:fs");
979
+ var path44 = __require("node:path");
980
+ var fs27 = __require("node:fs");
981
981
  var process2 = __require("node:process");
982
982
  var { Argument: Argument2, humanReadableArgName } = require_argument();
983
983
  var { CommanderError: CommanderError2 } = require_error();
@@ -1909,11 +1909,11 @@ Expecting one of '${allowedValues.join("', '")}'`);
1909
1909
  let launchWithNode = false;
1910
1910
  const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
1911
1911
  function findFile(baseDir, baseName) {
1912
- const localBin = path43.resolve(baseDir, baseName);
1913
- if (fs26.existsSync(localBin)) return localBin;
1914
- if (sourceExt.includes(path43.extname(baseName))) return void 0;
1912
+ const localBin = path44.resolve(baseDir, baseName);
1913
+ if (fs27.existsSync(localBin)) return localBin;
1914
+ if (sourceExt.includes(path44.extname(baseName))) return void 0;
1915
1915
  const foundExt = sourceExt.find(
1916
- (ext) => fs26.existsSync(`${localBin}${ext}`)
1916
+ (ext) => fs27.existsSync(`${localBin}${ext}`)
1917
1917
  );
1918
1918
  if (foundExt) return `${localBin}${foundExt}`;
1919
1919
  return void 0;
@@ -1925,21 +1925,21 @@ Expecting one of '${allowedValues.join("', '")}'`);
1925
1925
  if (this._scriptPath) {
1926
1926
  let resolvedScriptPath;
1927
1927
  try {
1928
- resolvedScriptPath = fs26.realpathSync(this._scriptPath);
1928
+ resolvedScriptPath = fs27.realpathSync(this._scriptPath);
1929
1929
  } catch (err) {
1930
1930
  resolvedScriptPath = this._scriptPath;
1931
1931
  }
1932
- executableDir = path43.resolve(
1933
- path43.dirname(resolvedScriptPath),
1932
+ executableDir = path44.resolve(
1933
+ path44.dirname(resolvedScriptPath),
1934
1934
  executableDir
1935
1935
  );
1936
1936
  }
1937
1937
  if (executableDir) {
1938
1938
  let localFile = findFile(executableDir, executableFile);
1939
1939
  if (!localFile && !subcommand._executableFile && this._scriptPath) {
1940
- const legacyName = path43.basename(
1940
+ const legacyName = path44.basename(
1941
1941
  this._scriptPath,
1942
- path43.extname(this._scriptPath)
1942
+ path44.extname(this._scriptPath)
1943
1943
  );
1944
1944
  if (legacyName !== this._name) {
1945
1945
  localFile = findFile(
@@ -1950,7 +1950,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1950
1950
  }
1951
1951
  executableFile = localFile || executableFile;
1952
1952
  }
1953
- launchWithNode = sourceExt.includes(path43.extname(executableFile));
1953
+ launchWithNode = sourceExt.includes(path44.extname(executableFile));
1954
1954
  let proc;
1955
1955
  if (process2.platform !== "win32") {
1956
1956
  if (launchWithNode) {
@@ -2790,7 +2790,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
2790
2790
  * @return {Command}
2791
2791
  */
2792
2792
  nameFromFilename(filename) {
2793
- this._name = path43.basename(filename, path43.extname(filename));
2793
+ this._name = path44.basename(filename, path44.extname(filename));
2794
2794
  return this;
2795
2795
  }
2796
2796
  /**
@@ -2804,9 +2804,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
2804
2804
  * @param {string} [path]
2805
2805
  * @return {(string|null|Command)}
2806
2806
  */
2807
- executableDir(path44) {
2808
- if (path44 === void 0) return this._executableDir;
2809
- this._executableDir = path44;
2807
+ executableDir(path45) {
2808
+ if (path45 === void 0) return this._executableDir;
2809
+ this._executableDir = path45;
2810
2810
  return this;
2811
2811
  }
2812
2812
  /**
@@ -3113,17 +3113,17 @@ var require_visit = __commonJS({
3113
3113
  visit.BREAK = BREAK;
3114
3114
  visit.SKIP = SKIP;
3115
3115
  visit.REMOVE = REMOVE;
3116
- function visit_(key, node, visitor, path43) {
3117
- const ctrl = callVisitor(key, node, visitor, path43);
3116
+ function visit_(key, node, visitor, path44) {
3117
+ const ctrl = callVisitor(key, node, visitor, path44);
3118
3118
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
3119
- replaceNode(key, path43, ctrl);
3120
- return visit_(key, ctrl, visitor, path43);
3119
+ replaceNode(key, path44, ctrl);
3120
+ return visit_(key, ctrl, visitor, path44);
3121
3121
  }
3122
3122
  if (typeof ctrl !== "symbol") {
3123
3123
  if (identity.isCollection(node)) {
3124
- path43 = Object.freeze(path43.concat(node));
3124
+ path44 = Object.freeze(path44.concat(node));
3125
3125
  for (let i = 0; i < node.items.length; ++i) {
3126
- const ci = visit_(i, node.items[i], visitor, path43);
3126
+ const ci = visit_(i, node.items[i], visitor, path44);
3127
3127
  if (typeof ci === "number")
3128
3128
  i = ci - 1;
3129
3129
  else if (ci === BREAK)
@@ -3134,13 +3134,13 @@ var require_visit = __commonJS({
3134
3134
  }
3135
3135
  }
3136
3136
  } else if (identity.isPair(node)) {
3137
- path43 = Object.freeze(path43.concat(node));
3138
- const ck = visit_("key", node.key, visitor, path43);
3137
+ path44 = Object.freeze(path44.concat(node));
3138
+ const ck = visit_("key", node.key, visitor, path44);
3139
3139
  if (ck === BREAK)
3140
3140
  return BREAK;
3141
3141
  else if (ck === REMOVE)
3142
3142
  node.key = null;
3143
- const cv = visit_("value", node.value, visitor, path43);
3143
+ const cv = visit_("value", node.value, visitor, path44);
3144
3144
  if (cv === BREAK)
3145
3145
  return BREAK;
3146
3146
  else if (cv === REMOVE)
@@ -3161,17 +3161,17 @@ var require_visit = __commonJS({
3161
3161
  visitAsync.BREAK = BREAK;
3162
3162
  visitAsync.SKIP = SKIP;
3163
3163
  visitAsync.REMOVE = REMOVE;
3164
- async function visitAsync_(key, node, visitor, path43) {
3165
- const ctrl = await callVisitor(key, node, visitor, path43);
3164
+ async function visitAsync_(key, node, visitor, path44) {
3165
+ const ctrl = await callVisitor(key, node, visitor, path44);
3166
3166
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
3167
- replaceNode(key, path43, ctrl);
3168
- return visitAsync_(key, ctrl, visitor, path43);
3167
+ replaceNode(key, path44, ctrl);
3168
+ return visitAsync_(key, ctrl, visitor, path44);
3169
3169
  }
3170
3170
  if (typeof ctrl !== "symbol") {
3171
3171
  if (identity.isCollection(node)) {
3172
- path43 = Object.freeze(path43.concat(node));
3172
+ path44 = Object.freeze(path44.concat(node));
3173
3173
  for (let i = 0; i < node.items.length; ++i) {
3174
- const ci = await visitAsync_(i, node.items[i], visitor, path43);
3174
+ const ci = await visitAsync_(i, node.items[i], visitor, path44);
3175
3175
  if (typeof ci === "number")
3176
3176
  i = ci - 1;
3177
3177
  else if (ci === BREAK)
@@ -3182,13 +3182,13 @@ var require_visit = __commonJS({
3182
3182
  }
3183
3183
  }
3184
3184
  } else if (identity.isPair(node)) {
3185
- path43 = Object.freeze(path43.concat(node));
3186
- const ck = await visitAsync_("key", node.key, visitor, path43);
3185
+ path44 = Object.freeze(path44.concat(node));
3186
+ const ck = await visitAsync_("key", node.key, visitor, path44);
3187
3187
  if (ck === BREAK)
3188
3188
  return BREAK;
3189
3189
  else if (ck === REMOVE)
3190
3190
  node.key = null;
3191
- const cv = await visitAsync_("value", node.value, visitor, path43);
3191
+ const cv = await visitAsync_("value", node.value, visitor, path44);
3192
3192
  if (cv === BREAK)
3193
3193
  return BREAK;
3194
3194
  else if (cv === REMOVE)
@@ -3215,23 +3215,23 @@ var require_visit = __commonJS({
3215
3215
  }
3216
3216
  return visitor;
3217
3217
  }
3218
- function callVisitor(key, node, visitor, path43) {
3218
+ function callVisitor(key, node, visitor, path44) {
3219
3219
  if (typeof visitor === "function")
3220
- return visitor(key, node, path43);
3220
+ return visitor(key, node, path44);
3221
3221
  if (identity.isMap(node))
3222
- return visitor.Map?.(key, node, path43);
3222
+ return visitor.Map?.(key, node, path44);
3223
3223
  if (identity.isSeq(node))
3224
- return visitor.Seq?.(key, node, path43);
3224
+ return visitor.Seq?.(key, node, path44);
3225
3225
  if (identity.isPair(node))
3226
- return visitor.Pair?.(key, node, path43);
3226
+ return visitor.Pair?.(key, node, path44);
3227
3227
  if (identity.isScalar(node))
3228
- return visitor.Scalar?.(key, node, path43);
3228
+ return visitor.Scalar?.(key, node, path44);
3229
3229
  if (identity.isAlias(node))
3230
- return visitor.Alias?.(key, node, path43);
3230
+ return visitor.Alias?.(key, node, path44);
3231
3231
  return void 0;
3232
3232
  }
3233
- function replaceNode(key, path43, node) {
3234
- const parent = path43[path43.length - 1];
3233
+ function replaceNode(key, path44, node) {
3234
+ const parent = path44[path44.length - 1];
3235
3235
  if (identity.isCollection(parent)) {
3236
3236
  parent.items[key] = node;
3237
3237
  } else if (identity.isPair(parent)) {
@@ -3839,10 +3839,10 @@ var require_Collection = __commonJS({
3839
3839
  var createNode = require_createNode();
3840
3840
  var identity = require_identity();
3841
3841
  var Node = require_Node();
3842
- function collectionFromPath(schema, path43, value) {
3842
+ function collectionFromPath(schema, path44, value) {
3843
3843
  let v = value;
3844
- for (let i = path43.length - 1; i >= 0; --i) {
3845
- const k = path43[i];
3844
+ for (let i = path44.length - 1; i >= 0; --i) {
3845
+ const k = path44[i];
3846
3846
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
3847
3847
  const a = [];
3848
3848
  a[k] = v;
@@ -3861,7 +3861,7 @@ var require_Collection = __commonJS({
3861
3861
  sourceObjects: /* @__PURE__ */ new Map()
3862
3862
  });
3863
3863
  }
3864
- var isEmptyPath = (path43) => path43 == null || typeof path43 === "object" && !!path43[Symbol.iterator]().next().done;
3864
+ var isEmptyPath = (path44) => path44 == null || typeof path44 === "object" && !!path44[Symbol.iterator]().next().done;
3865
3865
  var Collection = class extends Node.NodeBase {
3866
3866
  constructor(type, schema) {
3867
3867
  super(type);
@@ -3891,11 +3891,11 @@ var require_Collection = __commonJS({
3891
3891
  * be a Pair instance or a `{ key, value }` object, which may not have a key
3892
3892
  * that already exists in the map.
3893
3893
  */
3894
- addIn(path43, value) {
3895
- if (isEmptyPath(path43))
3894
+ addIn(path44, value) {
3895
+ if (isEmptyPath(path44))
3896
3896
  this.add(value);
3897
3897
  else {
3898
- const [key, ...rest] = path43;
3898
+ const [key, ...rest] = path44;
3899
3899
  const node = this.get(key, true);
3900
3900
  if (identity.isCollection(node))
3901
3901
  node.addIn(rest, value);
@@ -3909,8 +3909,8 @@ var require_Collection = __commonJS({
3909
3909
  * Removes a value from the collection.
3910
3910
  * @returns `true` if the item was found and removed.
3911
3911
  */
3912
- deleteIn(path43) {
3913
- const [key, ...rest] = path43;
3912
+ deleteIn(path44) {
3913
+ const [key, ...rest] = path44;
3914
3914
  if (rest.length === 0)
3915
3915
  return this.delete(key);
3916
3916
  const node = this.get(key, true);
@@ -3924,8 +3924,8 @@ var require_Collection = __commonJS({
3924
3924
  * scalar values from their surrounding node; to disable set `keepScalar` to
3925
3925
  * `true` (collections are always returned intact).
3926
3926
  */
3927
- getIn(path43, keepScalar) {
3928
- const [key, ...rest] = path43;
3927
+ getIn(path44, keepScalar) {
3928
+ const [key, ...rest] = path44;
3929
3929
  const node = this.get(key, true);
3930
3930
  if (rest.length === 0)
3931
3931
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -3943,8 +3943,8 @@ var require_Collection = __commonJS({
3943
3943
  /**
3944
3944
  * Checks if the collection includes a value with the key `key`.
3945
3945
  */
3946
- hasIn(path43) {
3947
- const [key, ...rest] = path43;
3946
+ hasIn(path44) {
3947
+ const [key, ...rest] = path44;
3948
3948
  if (rest.length === 0)
3949
3949
  return this.has(key);
3950
3950
  const node = this.get(key, true);
@@ -3954,8 +3954,8 @@ var require_Collection = __commonJS({
3954
3954
  * Sets a value in this collection. For `!!set`, `value` needs to be a
3955
3955
  * boolean to add/remove the item from the set.
3956
3956
  */
3957
- setIn(path43, value) {
3958
- const [key, ...rest] = path43;
3957
+ setIn(path44, value) {
3958
+ const [key, ...rest] = path44;
3959
3959
  if (rest.length === 0) {
3960
3960
  this.set(key, value);
3961
3961
  } else {
@@ -6459,9 +6459,9 @@ var require_Document = __commonJS({
6459
6459
  this.contents.add(value);
6460
6460
  }
6461
6461
  /** Adds a value to the document. */
6462
- addIn(path43, value) {
6462
+ addIn(path44, value) {
6463
6463
  if (assertCollection(this.contents))
6464
- this.contents.addIn(path43, value);
6464
+ this.contents.addIn(path44, value);
6465
6465
  }
6466
6466
  /**
6467
6467
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -6536,14 +6536,14 @@ var require_Document = __commonJS({
6536
6536
  * Removes a value from the document.
6537
6537
  * @returns `true` if the item was found and removed.
6538
6538
  */
6539
- deleteIn(path43) {
6540
- if (Collection.isEmptyPath(path43)) {
6539
+ deleteIn(path44) {
6540
+ if (Collection.isEmptyPath(path44)) {
6541
6541
  if (this.contents == null)
6542
6542
  return false;
6543
6543
  this.contents = null;
6544
6544
  return true;
6545
6545
  }
6546
- return assertCollection(this.contents) ? this.contents.deleteIn(path43) : false;
6546
+ return assertCollection(this.contents) ? this.contents.deleteIn(path44) : false;
6547
6547
  }
6548
6548
  /**
6549
6549
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -6558,10 +6558,10 @@ var require_Document = __commonJS({
6558
6558
  * scalar values from their surrounding node; to disable set `keepScalar` to
6559
6559
  * `true` (collections are always returned intact).
6560
6560
  */
6561
- getIn(path43, keepScalar) {
6562
- if (Collection.isEmptyPath(path43))
6561
+ getIn(path44, keepScalar) {
6562
+ if (Collection.isEmptyPath(path44))
6563
6563
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
6564
- return identity.isCollection(this.contents) ? this.contents.getIn(path43, keepScalar) : void 0;
6564
+ return identity.isCollection(this.contents) ? this.contents.getIn(path44, keepScalar) : void 0;
6565
6565
  }
6566
6566
  /**
6567
6567
  * Checks if the document includes a value with the key `key`.
@@ -6572,10 +6572,10 @@ var require_Document = __commonJS({
6572
6572
  /**
6573
6573
  * Checks if the document includes a value at `path`.
6574
6574
  */
6575
- hasIn(path43) {
6576
- if (Collection.isEmptyPath(path43))
6575
+ hasIn(path44) {
6576
+ if (Collection.isEmptyPath(path44))
6577
6577
  return this.contents !== void 0;
6578
- return identity.isCollection(this.contents) ? this.contents.hasIn(path43) : false;
6578
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path44) : false;
6579
6579
  }
6580
6580
  /**
6581
6581
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -6592,13 +6592,13 @@ var require_Document = __commonJS({
6592
6592
  * Sets a value in this document. For `!!set`, `value` needs to be a
6593
6593
  * boolean to add/remove the item from the set.
6594
6594
  */
6595
- setIn(path43, value) {
6596
- if (Collection.isEmptyPath(path43)) {
6595
+ setIn(path44, value) {
6596
+ if (Collection.isEmptyPath(path44)) {
6597
6597
  this.contents = value;
6598
6598
  } else if (this.contents == null) {
6599
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path43), value);
6599
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path44), value);
6600
6600
  } else if (assertCollection(this.contents)) {
6601
- this.contents.setIn(path43, value);
6601
+ this.contents.setIn(path44, value);
6602
6602
  }
6603
6603
  }
6604
6604
  /**
@@ -8550,9 +8550,9 @@ var require_cst_visit = __commonJS({
8550
8550
  visit.BREAK = BREAK;
8551
8551
  visit.SKIP = SKIP;
8552
8552
  visit.REMOVE = REMOVE;
8553
- visit.itemAtPath = (cst, path43) => {
8553
+ visit.itemAtPath = (cst, path44) => {
8554
8554
  let item = cst;
8555
- for (const [field, index] of path43) {
8555
+ for (const [field, index] of path44) {
8556
8556
  const tok = item?.[field];
8557
8557
  if (tok && "items" in tok) {
8558
8558
  item = tok.items[index];
@@ -8561,23 +8561,23 @@ var require_cst_visit = __commonJS({
8561
8561
  }
8562
8562
  return item;
8563
8563
  };
8564
- visit.parentCollection = (cst, path43) => {
8565
- const parent = visit.itemAtPath(cst, path43.slice(0, -1));
8566
- const field = path43[path43.length - 1][0];
8564
+ visit.parentCollection = (cst, path44) => {
8565
+ const parent = visit.itemAtPath(cst, path44.slice(0, -1));
8566
+ const field = path44[path44.length - 1][0];
8567
8567
  const coll = parent?.[field];
8568
8568
  if (coll && "items" in coll)
8569
8569
  return coll;
8570
8570
  throw new Error("Parent collection not found");
8571
8571
  };
8572
- function _visit(path43, item, visitor) {
8573
- let ctrl = visitor(item, path43);
8572
+ function _visit(path44, item, visitor) {
8573
+ let ctrl = visitor(item, path44);
8574
8574
  if (typeof ctrl === "symbol")
8575
8575
  return ctrl;
8576
8576
  for (const field of ["key", "value"]) {
8577
8577
  const token = item[field];
8578
8578
  if (token && "items" in token) {
8579
8579
  for (let i = 0; i < token.items.length; ++i) {
8580
- const ci = _visit(Object.freeze(path43.concat([[field, i]])), token.items[i], visitor);
8580
+ const ci = _visit(Object.freeze(path44.concat([[field, i]])), token.items[i], visitor);
8581
8581
  if (typeof ci === "number")
8582
8582
  i = ci - 1;
8583
8583
  else if (ci === BREAK)
@@ -8588,10 +8588,10 @@ var require_cst_visit = __commonJS({
8588
8588
  }
8589
8589
  }
8590
8590
  if (typeof ctrl === "function" && field === "key")
8591
- ctrl = ctrl(item, path43);
8591
+ ctrl = ctrl(item, path44);
8592
8592
  }
8593
8593
  }
8594
- return typeof ctrl === "function" ? ctrl(item, path43) : ctrl;
8594
+ return typeof ctrl === "function" ? ctrl(item, path44) : ctrl;
8595
8595
  }
8596
8596
  exports.visit = visit;
8597
8597
  }
@@ -9876,14 +9876,14 @@ var require_parser = __commonJS({
9876
9876
  case "scalar":
9877
9877
  case "single-quoted-scalar":
9878
9878
  case "double-quoted-scalar": {
9879
- const fs26 = this.flowScalar(this.type);
9879
+ const fs27 = this.flowScalar(this.type);
9880
9880
  if (atNextItem || it.value) {
9881
- map.items.push({ start, key: fs26, sep: [] });
9881
+ map.items.push({ start, key: fs27, sep: [] });
9882
9882
  this.onKeyLine = true;
9883
9883
  } else if (it.sep) {
9884
- this.stack.push(fs26);
9884
+ this.stack.push(fs27);
9885
9885
  } else {
9886
- Object.assign(it, { key: fs26, sep: [] });
9886
+ Object.assign(it, { key: fs27, sep: [] });
9887
9887
  this.onKeyLine = true;
9888
9888
  }
9889
9889
  return;
@@ -10011,13 +10011,13 @@ var require_parser = __commonJS({
10011
10011
  case "scalar":
10012
10012
  case "single-quoted-scalar":
10013
10013
  case "double-quoted-scalar": {
10014
- const fs26 = this.flowScalar(this.type);
10014
+ const fs27 = this.flowScalar(this.type);
10015
10015
  if (!it || it.value)
10016
- fc.items.push({ start: [], key: fs26, sep: [] });
10016
+ fc.items.push({ start: [], key: fs27, sep: [] });
10017
10017
  else if (it.sep)
10018
- this.stack.push(fs26);
10018
+ this.stack.push(fs27);
10019
10019
  else
10020
- Object.assign(it, { key: fs26, sep: [] });
10020
+ Object.assign(it, { key: fs27, sep: [] });
10021
10021
  return;
10022
10022
  }
10023
10023
  case "flow-map-end":
@@ -10225,7 +10225,7 @@ var require_public_api = __commonJS({
10225
10225
  }
10226
10226
  return doc;
10227
10227
  }
10228
- function parse15(src, reviver, options) {
10228
+ function parse16(src, reviver, options) {
10229
10229
  let _reviver = void 0;
10230
10230
  if (typeof reviver === "function") {
10231
10231
  _reviver = reviver;
@@ -10266,7 +10266,7 @@ var require_public_api = __commonJS({
10266
10266
  return value.toString(options);
10267
10267
  return new Document.Document(value, _replacer, options).toString(options);
10268
10268
  }
10269
- exports.parse = parse15;
10269
+ exports.parse = parse16;
10270
10270
  exports.parseAllDocuments = parseAllDocuments;
10271
10271
  exports.parseDocument = parseDocument;
10272
10272
  exports.stringify = stringify7;
@@ -11463,10 +11463,11 @@ var init_metadata = __esm({
11463
11463
  // ../core/src/matrix/manager.ts
11464
11464
  import * as fs5 from "fs";
11465
11465
  import * as path4 from "path";
11466
- var MatrixManager;
11466
+ var YAML3, MatrixManager;
11467
11467
  var init_manager = __esm({
11468
11468
  "../core/src/matrix/manager.ts"() {
11469
11469
  "use strict";
11470
+ YAML3 = __toESM(require_dist());
11470
11471
  init_metadata();
11471
11472
  MatrixManager = class {
11472
11473
  /**
@@ -11522,9 +11523,15 @@ var init_manager = __esm({
11522
11523
  * @param repoRoot - Absolute path to the repository root.
11523
11524
  * @param sopsClient - SOPS client used to decrypt each cell.
11524
11525
  */
11525
- async getMatrixStatus(manifest, repoRoot, sopsClient) {
11526
+ async getMatrixStatus(manifest, repoRoot, _sopsClient) {
11526
11527
  const cells = this.resolveMatrix(manifest, repoRoot);
11527
11528
  const statuses = [];
11529
+ const cellKeys = /* @__PURE__ */ new Map();
11530
+ for (const cell of cells) {
11531
+ if (cell.exists) {
11532
+ cellKeys.set(cell.filePath, this.readKeyNames(cell.filePath));
11533
+ }
11534
+ }
11528
11535
  for (const cell of cells) {
11529
11536
  if (!cell.exists) {
11530
11537
  statuses.push({
@@ -11547,48 +11554,56 @@ var init_manager = __esm({
11547
11554
  pendingCount = pending.length;
11548
11555
  } catch {
11549
11556
  }
11550
- try {
11551
- const decrypted = await sopsClient.decrypt(cell.filePath);
11552
- const keyCount = Object.keys(decrypted.values).length;
11553
- const lastModified = decrypted.metadata.lastModified;
11554
- const issues = [];
11555
- const siblingCells = cells.filter(
11556
- (c) => c.namespace === cell.namespace && c.environment !== cell.environment && c.exists
11557
- );
11558
- for (const sibling of siblingCells) {
11559
- try {
11560
- const siblingDecrypted = await sopsClient.decrypt(sibling.filePath);
11561
- const siblingKeys = Object.keys(siblingDecrypted.values);
11562
- const currentKeys = Object.keys(decrypted.values);
11563
- const missingKeys = siblingKeys.filter((k) => !currentKeys.includes(k));
11564
- for (const mk of missingKeys) {
11565
- issues.push({
11566
- type: "missing_keys",
11567
- message: `Key '${mk}' exists in ${sibling.environment} but is missing here.`,
11568
- key: mk
11569
- });
11570
- }
11571
- } catch {
11572
- }
11557
+ const keys = cellKeys.get(cell.filePath) ?? [];
11558
+ const keyCount = keys.length;
11559
+ const lastModified = this.readLastModified(cell.filePath);
11560
+ const issues = [];
11561
+ const siblingCells = cells.filter(
11562
+ (c) => c.namespace === cell.namespace && c.environment !== cell.environment && c.exists
11563
+ );
11564
+ for (const sibling of siblingCells) {
11565
+ const siblingKeys = cellKeys.get(sibling.filePath) ?? [];
11566
+ const missingKeys = siblingKeys.filter((k) => !keys.includes(k));
11567
+ for (const mk of missingKeys) {
11568
+ issues.push({
11569
+ type: "missing_keys",
11570
+ message: `Key '${mk}' exists in ${sibling.environment} but is missing here.`,
11571
+ key: mk
11572
+ });
11573
11573
  }
11574
- statuses.push({ cell, keyCount, pendingCount, lastModified, issues });
11575
- } catch {
11576
- statuses.push({
11577
- cell,
11578
- keyCount: 0,
11579
- pendingCount: 0,
11580
- lastModified: null,
11581
- issues: [
11582
- {
11583
- type: "sops_error",
11584
- message: `Could not decrypt '${cell.filePath}'. Check your key configuration.`
11585
- }
11586
- ]
11587
- });
11588
11574
  }
11575
+ statuses.push({ cell, keyCount, pendingCount, lastModified, issues });
11589
11576
  }
11590
11577
  return statuses;
11591
11578
  }
11579
+ /**
11580
+ * Read top-level key names from a SOPS file without decryption.
11581
+ * SOPS stores key names in plaintext — only values are encrypted.
11582
+ */
11583
+ readKeyNames(filePath) {
11584
+ try {
11585
+ const raw = fs5.readFileSync(filePath, "utf-8");
11586
+ const parsed = YAML3.parse(raw);
11587
+ if (!parsed || typeof parsed !== "object") return [];
11588
+ return Object.keys(parsed).filter((k) => k !== "sops");
11589
+ } catch {
11590
+ return [];
11591
+ }
11592
+ }
11593
+ /**
11594
+ * Read the lastModified timestamp from SOPS metadata without decryption.
11595
+ */
11596
+ readLastModified(filePath) {
11597
+ try {
11598
+ const raw = fs5.readFileSync(filePath, "utf-8");
11599
+ const parsed = YAML3.parse(raw);
11600
+ const sops = parsed?.sops;
11601
+ if (sops?.lastmodified) return new Date(String(sops.lastmodified));
11602
+ return null;
11603
+ } catch {
11604
+ return null;
11605
+ }
11606
+ }
11592
11607
  /**
11593
11608
  * Check whether an environment has the `protected` flag set in the manifest.
11594
11609
  *
@@ -11605,11 +11620,11 @@ var init_manager = __esm({
11605
11620
 
11606
11621
  // ../core/src/schema/validator.ts
11607
11622
  import * as fs6 from "fs";
11608
- var YAML3, SchemaValidator;
11623
+ var YAML4, SchemaValidator;
11609
11624
  var init_validator2 = __esm({
11610
11625
  "../core/src/schema/validator.ts"() {
11611
11626
  "use strict";
11612
- YAML3 = __toESM(require_dist());
11627
+ YAML4 = __toESM(require_dist());
11613
11628
  init_types();
11614
11629
  SchemaValidator = class {
11615
11630
  /**
@@ -11628,7 +11643,7 @@ var init_validator2 = __esm({
11628
11643
  }
11629
11644
  let parsed;
11630
11645
  try {
11631
- parsed = YAML3.parse(raw);
11646
+ parsed = YAML4.parse(raw);
11632
11647
  } catch {
11633
11648
  throw new SchemaLoadError(`Schema file '${filePath}' contains invalid YAML.`, filePath);
11634
11649
  }
@@ -19702,11 +19717,11 @@ function openWindowsInputPipe(content) {
19702
19717
  });
19703
19718
  });
19704
19719
  }
19705
- var YAML4, SopsClient;
19720
+ var YAML5, SopsClient;
19706
19721
  var init_client = __esm({
19707
19722
  "../core/src/sops/client.ts"() {
19708
19723
  "use strict";
19709
- YAML4 = __toESM(require_dist());
19724
+ YAML5 = __toESM(require_dist());
19710
19725
  init_types();
19711
19726
  init_checker();
19712
19727
  init_keygen();
@@ -19771,7 +19786,7 @@ var init_client = __esm({
19771
19786
  }
19772
19787
  let parsed;
19773
19788
  try {
19774
- parsed = YAML4.parse(result.stdout) ?? {};
19789
+ parsed = YAML5.parse(result.stdout) ?? {};
19775
19790
  } catch {
19776
19791
  throw new SopsDecryptionError(
19777
19792
  `Decrypted content of '${filePath}' is not valid YAML.`,
@@ -19798,7 +19813,7 @@ var init_client = __esm({
19798
19813
  async encrypt(filePath, values, manifest, environment) {
19799
19814
  await assertSops(this.runner, this.sopsCommand);
19800
19815
  const fmt = formatFromPath(filePath);
19801
- const content = fmt === "json" ? JSON.stringify(values, null, 2) : YAML4.stringify(values);
19816
+ const content = fmt === "json" ? JSON.stringify(values, null, 2) : YAML5.stringify(values);
19802
19817
  const args = this.buildEncryptArgs(filePath, manifest, environment);
19803
19818
  const env = this.buildSopsEnv();
19804
19819
  let inputArg;
@@ -19998,7 +20013,7 @@ var init_client = __esm({
19998
20013
  }
19999
20014
  let parsed;
20000
20015
  try {
20001
- parsed = YAML4.parse(content);
20016
+ parsed = YAML5.parse(content);
20002
20017
  } catch {
20003
20018
  throw new SopsDecryptionError(
20004
20019
  `File '${filePath}' is not valid YAML. Cannot extract SOPS metadata.`,
@@ -20307,7 +20322,7 @@ var init_runner = __esm({
20307
20322
  /**
20308
20323
  * Lint service identity configurations for drift issues.
20309
20324
  */
20310
- async lintServiceIdentities(identities, manifest, _repoRoot, existingCells) {
20325
+ async lintServiceIdentities(identities, manifest, repoRoot, existingCells) {
20311
20326
  const issues = [];
20312
20327
  const declaredEnvNames = new Set(manifest.environments.map((e) => e.name));
20313
20328
  const declaredNsNames = new Set(manifest.namespaces.map((ns) => ns.name));
@@ -20466,7 +20481,7 @@ function detectFormat(filePath, content) {
20466
20481
  } catch {
20467
20482
  }
20468
20483
  try {
20469
- const parsed = YAML5.parse(content);
20484
+ const parsed = YAML6.parse(content);
20470
20485
  if (parsed !== null && typeof parsed === "object" && !Array.isArray(parsed)) {
20471
20486
  return "yaml";
20472
20487
  }
@@ -20547,7 +20562,7 @@ function parseJson(content) {
20547
20562
  function parseYaml(content) {
20548
20563
  let parsed;
20549
20564
  try {
20550
- parsed = YAML5.parse(content);
20565
+ parsed = YAML6.parse(content);
20551
20566
  } catch (err) {
20552
20567
  throw new Error(`Invalid YAML: ${err.message}`);
20553
20568
  }
@@ -20581,7 +20596,7 @@ function parseYaml(content) {
20581
20596
  }
20582
20597
  return { pairs, format: "yaml", skipped, warnings };
20583
20598
  }
20584
- function parse6(content, format, filePath) {
20599
+ function parse7(content, format, filePath) {
20585
20600
  const resolved = format === "auto" ? detectFormat(filePath ?? "", content) : format;
20586
20601
  switch (resolved) {
20587
20602
  case "dotenv":
@@ -20592,11 +20607,11 @@ function parse6(content, format, filePath) {
20592
20607
  return parseYaml(content);
20593
20608
  }
20594
20609
  }
20595
- var YAML5;
20610
+ var YAML6;
20596
20611
  var init_parsers = __esm({
20597
20612
  "../core/src/import/parsers.ts"() {
20598
20613
  "use strict";
20599
- YAML5 = __toESM(require_dist());
20614
+ YAML6 = __toESM(require_dist());
20600
20615
  }
20601
20616
  });
20602
20617
 
@@ -20627,7 +20642,7 @@ var init_import = __esm({
20627
20642
  repoRoot,
20628
20643
  manifest.file_pattern.replace("{namespace}", ns).replace("{environment}", env)
20629
20644
  );
20630
- const parsed = parse6(content, options.format ?? "auto", sourcePath ?? "");
20645
+ const parsed = parse7(content, options.format ?? "auto", sourcePath ?? "");
20631
20646
  let candidates = Object.entries(parsed.pairs);
20632
20647
  if (options.prefix) {
20633
20648
  const prefix2 = options.prefix;
@@ -20708,11 +20723,11 @@ function toRecipient(entry) {
20708
20723
  function readManifestYaml(repoRoot) {
20709
20724
  const manifestPath = path13.join(repoRoot, CLEF_MANIFEST_FILENAME);
20710
20725
  const raw = fs11.readFileSync(manifestPath, "utf-8");
20711
- return YAML6.parse(raw);
20726
+ return YAML7.parse(raw);
20712
20727
  }
20713
20728
  function writeManifestYaml(repoRoot, doc) {
20714
20729
  const manifestPath = path13.join(repoRoot, CLEF_MANIFEST_FILENAME);
20715
- fs11.writeFileSync(manifestPath, YAML6.stringify(doc), "utf-8");
20730
+ fs11.writeFileSync(manifestPath, YAML7.stringify(doc), "utf-8");
20716
20731
  }
20717
20732
  function getRecipientsArray(doc) {
20718
20733
  const sops = doc.sops;
@@ -20760,11 +20775,11 @@ function ensureEnvironmentRecipientsArray(doc, envName) {
20760
20775
  }
20761
20776
  return env.recipients;
20762
20777
  }
20763
- var YAML6, RecipientManager;
20778
+ var YAML7, RecipientManager;
20764
20779
  var init_recipients2 = __esm({
20765
20780
  "../core/src/recipients/index.ts"() {
20766
20781
  "use strict";
20767
- YAML6 = __toESM(require_dist());
20782
+ YAML7 = __toESM(require_dist());
20768
20783
  init_validator();
20769
20784
  init_parser();
20770
20785
  RecipientManager = class {
@@ -20964,7 +20979,7 @@ function loadRequests(repoRoot) {
20964
20979
  try {
20965
20980
  if (!fs12.existsSync(filePath)) return [];
20966
20981
  const content = fs12.readFileSync(filePath, "utf-8");
20967
- const parsed = YAML7.parse(content);
20982
+ const parsed = YAML8.parse(content);
20968
20983
  if (!parsed || !Array.isArray(parsed.requests)) return [];
20969
20984
  return parsed.requests.map((r) => ({
20970
20985
  key: r.key,
@@ -20996,7 +21011,7 @@ function saveRequests(repoRoot, requests) {
20996
21011
  return raw;
20997
21012
  })
20998
21013
  };
20999
- fs12.writeFileSync(filePath, HEADER_COMMENT2 + YAML7.stringify(data), "utf-8");
21014
+ fs12.writeFileSync(filePath, HEADER_COMMENT2 + YAML8.stringify(data), "utf-8");
21000
21015
  }
21001
21016
  function upsertRequest(repoRoot, key, label2, environment) {
21002
21017
  const requests = loadRequests(repoRoot);
@@ -21030,11 +21045,11 @@ function findInList(requests, identifier) {
21030
21045
  const byKey = requests.find((r) => r.key === identifier);
21031
21046
  return byKey ?? null;
21032
21047
  }
21033
- var YAML7, REQUESTS_FILENAME, HEADER_COMMENT2;
21048
+ var YAML8, REQUESTS_FILENAME, HEADER_COMMENT2;
21034
21049
  var init_requests = __esm({
21035
21050
  "../core/src/recipients/requests.ts"() {
21036
21051
  "use strict";
21037
- YAML7 = __toESM(require_dist());
21052
+ YAML8 = __toESM(require_dist());
21038
21053
  REQUESTS_FILENAME = ".clef-requests.yaml";
21039
21054
  HEADER_COMMENT2 = "# Pending recipient access requests. Approve with: clef recipients approve <label>\n";
21040
21055
  }
@@ -21043,11 +21058,11 @@ var init_requests = __esm({
21043
21058
  // ../core/src/drift/detector.ts
21044
21059
  import * as fs13 from "fs";
21045
21060
  import * as path15 from "path";
21046
- var YAML8, DriftDetector;
21061
+ var YAML9, DriftDetector;
21047
21062
  var init_detector = __esm({
21048
21063
  "../core/src/drift/detector.ts"() {
21049
21064
  "use strict";
21050
- YAML8 = __toESM(require_dist());
21065
+ YAML9 = __toESM(require_dist());
21051
21066
  init_parser();
21052
21067
  init_manager();
21053
21068
  DriftDetector = class {
@@ -21136,7 +21151,7 @@ var init_detector = __esm({
21136
21151
  try {
21137
21152
  if (!fs13.existsSync(filePath)) return null;
21138
21153
  const raw = fs13.readFileSync(filePath, "utf-8");
21139
- const parsed = YAML8.parse(raw);
21154
+ const parsed = YAML9.parse(raw);
21140
21155
  if (parsed === null || parsed === void 0 || typeof parsed !== "object") return null;
21141
21156
  return Object.keys(parsed).filter((k) => k !== "sops");
21142
21157
  } catch {
@@ -21289,11 +21304,11 @@ var init_sanitizer = __esm({
21289
21304
  // ../core/src/report/generator.ts
21290
21305
  import * as fs14 from "fs";
21291
21306
  import * as path16 from "path";
21292
- var YAML9, ReportGenerator;
21307
+ var YAML10, ReportGenerator;
21293
21308
  var init_generator = __esm({
21294
21309
  "../core/src/report/generator.ts"() {
21295
21310
  "use strict";
21296
- YAML9 = __toESM(require_dist());
21311
+ YAML10 = __toESM(require_dist());
21297
21312
  init_types();
21298
21313
  init_parser();
21299
21314
  init_runner();
@@ -21472,7 +21487,7 @@ var init_generator = __esm({
21472
21487
  try {
21473
21488
  if (!fs14.existsSync(filePath)) return 0;
21474
21489
  const raw = fs14.readFileSync(filePath, "utf-8");
21475
- const parsed = YAML9.parse(raw);
21490
+ const parsed = YAML10.parse(raw);
21476
21491
  if (parsed === null || parsed === void 0 || typeof parsed !== "object") return 0;
21477
21492
  return Object.keys(parsed).filter((k) => k !== "sops").length;
21478
21493
  } catch {
@@ -21847,11 +21862,11 @@ var init_driver = __esm({
21847
21862
  import * as fs15 from "fs";
21848
21863
  import * as os from "os";
21849
21864
  import * as path17 from "path";
21850
- var YAML10, PartialRotationError, ServiceIdentityManager;
21865
+ var YAML11, PartialRotationError, ServiceIdentityManager;
21851
21866
  var init_manager2 = __esm({
21852
21867
  "../core/src/service-identity/manager.ts"() {
21853
21868
  "use strict";
21854
- YAML10 = __toESM(require_dist());
21869
+ YAML11 = __toESM(require_dist());
21855
21870
  init_types();
21856
21871
  init_keygen();
21857
21872
  init_parser();
@@ -21907,7 +21922,7 @@ var init_manager2 = __esm({
21907
21922
  await this.registerRecipients(definition, manifest, repoRoot);
21908
21923
  const manifestPath = path17.join(repoRoot, CLEF_MANIFEST_FILENAME);
21909
21924
  const raw = fs15.readFileSync(manifestPath, "utf-8");
21910
- const doc = YAML10.parse(raw);
21925
+ const doc = YAML11.parse(raw);
21911
21926
  if (!Array.isArray(doc.service_identities)) {
21912
21927
  doc.service_identities = [];
21913
21928
  }
@@ -21919,7 +21934,7 @@ var init_manager2 = __esm({
21919
21934
  });
21920
21935
  const tmpCreate = path17.join(os.tmpdir(), `clef-manifest-${process.pid}-${Date.now()}.tmp`);
21921
21936
  try {
21922
- fs15.writeFileSync(tmpCreate, YAML10.stringify(doc), "utf-8");
21937
+ fs15.writeFileSync(tmpCreate, YAML11.stringify(doc), "utf-8");
21923
21938
  fs15.renameSync(tmpCreate, manifestPath);
21924
21939
  } finally {
21925
21940
  try {
@@ -21941,6 +21956,95 @@ var init_manager2 = __esm({
21941
21956
  get(manifest, name) {
21942
21957
  return manifest.service_identities?.find((si) => si.name === name);
21943
21958
  }
21959
+ /**
21960
+ * Delete a service identity: remove its recipients from scoped SOPS files
21961
+ * and remove it from the manifest.
21962
+ */
21963
+ async delete(name, manifest, repoRoot) {
21964
+ const identity = this.get(manifest, name);
21965
+ if (!identity) {
21966
+ throw new Error(`Service identity '${name}' not found.`);
21967
+ }
21968
+ const cells = this.matrixManager.resolveMatrix(manifest, repoRoot).filter((c) => c.exists);
21969
+ for (const cell of cells) {
21970
+ if (!identity.namespaces.includes(cell.namespace)) continue;
21971
+ const envConfig = identity.environments[cell.environment];
21972
+ if (!envConfig?.recipient) continue;
21973
+ if (isKmsEnvelope(envConfig)) continue;
21974
+ try {
21975
+ await this.encryption.removeRecipient(cell.filePath, envConfig.recipient);
21976
+ } catch {
21977
+ }
21978
+ }
21979
+ const manifestPath = path17.join(repoRoot, CLEF_MANIFEST_FILENAME);
21980
+ const raw = fs15.readFileSync(manifestPath, "utf-8");
21981
+ const doc = YAML11.parse(raw);
21982
+ const identities = doc.service_identities;
21983
+ if (Array.isArray(identities)) {
21984
+ doc.service_identities = identities.filter(
21985
+ (si) => si.name !== name
21986
+ );
21987
+ }
21988
+ const tmp = path17.join(os.tmpdir(), `clef-manifest-${process.pid}-${Date.now()}.tmp`);
21989
+ try {
21990
+ fs15.writeFileSync(tmp, YAML11.stringify(doc), "utf-8");
21991
+ fs15.renameSync(tmp, manifestPath);
21992
+ } finally {
21993
+ try {
21994
+ fs15.unlinkSync(tmp);
21995
+ } catch {
21996
+ }
21997
+ }
21998
+ }
21999
+ /**
22000
+ * Update environment backends on an existing service identity.
22001
+ * Switches age → KMS (removes old recipient) or updates KMS config.
22002
+ * Returns new private keys for any environments switched from KMS → age.
22003
+ */
22004
+ async updateEnvironments(name, kmsEnvConfigs, manifest, repoRoot) {
22005
+ const identity = this.get(manifest, name);
22006
+ if (!identity) {
22007
+ throw new Error(`Service identity '${name}' not found.`);
22008
+ }
22009
+ const manifestPath = path17.join(repoRoot, CLEF_MANIFEST_FILENAME);
22010
+ const raw = fs15.readFileSync(manifestPath, "utf-8");
22011
+ const doc = YAML11.parse(raw);
22012
+ const identities = doc.service_identities;
22013
+ const siDoc = identities.find((si) => si.name === name);
22014
+ const envs = siDoc.environments;
22015
+ const cells = this.matrixManager.resolveMatrix(manifest, repoRoot).filter((c) => c.exists);
22016
+ const privateKeys = {};
22017
+ for (const [envName, kmsConfig] of Object.entries(kmsEnvConfigs)) {
22018
+ const oldConfig = identity.environments[envName];
22019
+ if (!oldConfig) {
22020
+ throw new Error(`Environment '${envName}' not found on identity '${name}'.`);
22021
+ }
22022
+ if (oldConfig.recipient) {
22023
+ const scopedCells = cells.filter(
22024
+ (c) => identity.namespaces.includes(c.namespace) && c.environment === envName
22025
+ );
22026
+ for (const cell of scopedCells) {
22027
+ try {
22028
+ await this.encryption.removeRecipient(cell.filePath, oldConfig.recipient);
22029
+ } catch {
22030
+ }
22031
+ }
22032
+ }
22033
+ envs[envName] = { kms: kmsConfig };
22034
+ identity.environments[envName] = { kms: kmsConfig };
22035
+ }
22036
+ const tmp = path17.join(os.tmpdir(), `clef-manifest-${process.pid}-${Date.now()}.tmp`);
22037
+ try {
22038
+ fs15.writeFileSync(tmp, YAML11.stringify(doc), "utf-8");
22039
+ fs15.renameSync(tmp, manifestPath);
22040
+ } finally {
22041
+ try {
22042
+ fs15.unlinkSync(tmp);
22043
+ } catch {
22044
+ }
22045
+ }
22046
+ return { privateKeys };
22047
+ }
21944
22048
  /**
21945
22049
  * Register a service identity's public keys as SOPS recipients on scoped matrix files.
21946
22050
  */
@@ -21973,7 +22077,7 @@ var init_manager2 = __esm({
21973
22077
  }
21974
22078
  const manifestPath = path17.join(repoRoot, CLEF_MANIFEST_FILENAME);
21975
22079
  const raw = fs15.readFileSync(manifestPath, "utf-8");
21976
- const doc = YAML10.parse(raw);
22080
+ const doc = YAML11.parse(raw);
21977
22081
  const identities = doc.service_identities;
21978
22082
  const siDoc = identities.find((si) => si.name === name);
21979
22083
  const envs = siDoc.environments;
@@ -22028,7 +22132,7 @@ var init_manager2 = __esm({
22028
22132
  }
22029
22133
  const tmpRotate = path17.join(os.tmpdir(), `clef-manifest-${process.pid}-${Date.now()}.tmp`);
22030
22134
  try {
22031
- fs15.writeFileSync(tmpRotate, YAML10.stringify(doc), "utf-8");
22135
+ fs15.writeFileSync(tmpRotate, YAML11.stringify(doc), "utf-8");
22032
22136
  fs15.renameSync(tmpRotate, manifestPath);
22033
22137
  } finally {
22034
22138
  try {
@@ -22201,7 +22305,8 @@ var init_packer = __esm({
22201
22305
  try {
22202
22306
  const e = new Encrypter2();
22203
22307
  e.addRecipient(ephemeralPublicKey);
22204
- ciphertext = await e.encrypt(plaintext);
22308
+ const encrypted = await e.encrypt(plaintext);
22309
+ ciphertext = Buffer.from(encrypted).toString("base64");
22205
22310
  } catch {
22206
22311
  throw new Error("Failed to age-encrypt artifact with ephemeral key.");
22207
22312
  }
@@ -22230,7 +22335,8 @@ var init_packer = __esm({
22230
22335
  const { Encrypter: Encrypter2 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
22231
22336
  const e = new Encrypter2();
22232
22337
  e.addRecipient(resolved.recipient);
22233
- ciphertext = await e.encrypt(plaintext);
22338
+ const encrypted = await e.encrypt(plaintext);
22339
+ ciphertext = Buffer.from(encrypted).toString("base64");
22234
22340
  } catch {
22235
22341
  throw new Error("Failed to age-encrypt artifact. Check recipient key.");
22236
22342
  }
@@ -22332,7 +22438,7 @@ __export(src_exports, {
22332
22438
  markResolved: () => markResolved,
22333
22439
  matchPatterns: () => matchPatterns,
22334
22440
  metadataPath: () => metadataPath,
22335
- parse: () => parse6,
22441
+ parse: () => parse7,
22336
22442
  parseDotenv: () => parseDotenv,
22337
22443
  parseIgnoreContent: () => parseIgnoreContent,
22338
22444
  parseJson: () => parseJson,
@@ -22470,7 +22576,7 @@ var require_ms = __commonJS({
22470
22576
  options = options || {};
22471
22577
  var type = typeof val;
22472
22578
  if (type === "string" && val.length > 0) {
22473
- return parse15(val);
22579
+ return parse16(val);
22474
22580
  } else if (type === "number" && isFinite(val)) {
22475
22581
  return options.long ? fmtLong(val) : fmtShort(val);
22476
22582
  }
@@ -22478,7 +22584,7 @@ var require_ms = __commonJS({
22478
22584
  "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
22479
22585
  );
22480
22586
  };
22481
- function parse15(str2) {
22587
+ function parse16(str2) {
22482
22588
  str2 = String(str2);
22483
22589
  if (str2.length > 100) {
22484
22590
  return;
@@ -23917,7 +24023,7 @@ var require_bytes = __commonJS({
23917
24023
  "use strict";
23918
24024
  module.exports = bytes;
23919
24025
  module.exports.format = format;
23920
- module.exports.parse = parse15;
24026
+ module.exports.parse = parse16;
23921
24027
  var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
23922
24028
  var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
23923
24029
  var map = {
@@ -23931,7 +24037,7 @@ var require_bytes = __commonJS({
23931
24037
  var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
23932
24038
  function bytes(value, options) {
23933
24039
  if (typeof value === "string") {
23934
- return parse15(value);
24040
+ return parse16(value);
23935
24041
  }
23936
24042
  if (typeof value === "number") {
23937
24043
  return format(value, options);
@@ -23975,7 +24081,7 @@ var require_bytes = __commonJS({
23975
24081
  }
23976
24082
  return str2 + unitSeparator + unit;
23977
24083
  }
23978
- function parse15(val) {
24084
+ function parse16(val) {
23979
24085
  if (typeof val === "number" && !isNaN(val)) {
23980
24086
  return val;
23981
24087
  }
@@ -28180,7 +28286,7 @@ var require_content_type = __commonJS({
28180
28286
  var QUOTE_REGEXP = /([\\"])/g;
28181
28287
  var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
28182
28288
  exports.format = format;
28183
- exports.parse = parse15;
28289
+ exports.parse = parse16;
28184
28290
  function format(obj) {
28185
28291
  if (!obj || typeof obj !== "object") {
28186
28292
  throw new TypeError("argument obj is required");
@@ -28204,7 +28310,7 @@ var require_content_type = __commonJS({
28204
28310
  }
28205
28311
  return string;
28206
28312
  }
28207
- function parse15(string) {
28313
+ function parse16(string) {
28208
28314
  if (!string) {
28209
28315
  throw new TypeError("argument string is required");
28210
28316
  }
@@ -37729,11 +37835,11 @@ var require_mime_types = __commonJS({
37729
37835
  }
37730
37836
  return exts[0];
37731
37837
  }
37732
- function lookup(path43) {
37733
- if (!path43 || typeof path43 !== "string") {
37838
+ function lookup(path44) {
37839
+ if (!path44 || typeof path44 !== "string") {
37734
37840
  return false;
37735
37841
  }
37736
- var extension2 = extname2("x." + path43).toLowerCase().slice(1);
37842
+ var extension2 = extname2("x." + path44).toLowerCase().slice(1);
37737
37843
  if (!extension2) {
37738
37844
  return false;
37739
37845
  }
@@ -37786,7 +37892,7 @@ var require_media_typer = __commonJS({
37786
37892
  var TYPE_NAME_REGEXP = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/;
37787
37893
  var TYPE_REGEXP = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/;
37788
37894
  exports.format = format;
37789
- exports.parse = parse15;
37895
+ exports.parse = parse16;
37790
37896
  exports.test = test;
37791
37897
  function format(obj) {
37792
37898
  if (!obj || typeof obj !== "object") {
@@ -37819,7 +37925,7 @@ var require_media_typer = __commonJS({
37819
37925
  }
37820
37926
  return TYPE_REGEXP.test(string.toLowerCase());
37821
37927
  }
37822
- function parse15(string) {
37928
+ function parse16(string) {
37823
37929
  if (!string) {
37824
37930
  throw new TypeError("argument string is required");
37825
37931
  }
@@ -38005,7 +38111,7 @@ var require_read = __commonJS({
38005
38111
  var hasBody = require_type_is().hasBody;
38006
38112
  var { getCharset } = require_utils();
38007
38113
  module.exports = read2;
38008
- function read2(req, res, next, parse15, debug, options) {
38114
+ function read2(req, res, next, parse16, debug, options) {
38009
38115
  if (onFinished.isFinished(req)) {
38010
38116
  debug("body already parsed");
38011
38117
  next();
@@ -38093,7 +38199,7 @@ var require_read = __commonJS({
38093
38199
  try {
38094
38200
  debug("parse body");
38095
38201
  str2 = typeof body !== "string" && encoding !== null ? iconv.decode(body, encoding) : body;
38096
- req.body = parse15(str2, encoding);
38202
+ req.body = parse16(str2, encoding);
38097
38203
  } catch (err) {
38098
38204
  next(createError(400, err, {
38099
38205
  body: str2,
@@ -38166,7 +38272,7 @@ var require_json = __commonJS({
38166
38272
  const normalizedOptions = normalizeOptions(options, "application/json");
38167
38273
  var reviver = options?.reviver;
38168
38274
  var strict = options?.strict !== false;
38169
- function parse15(body) {
38275
+ function parse16(body) {
38170
38276
  if (body.length === 0) {
38171
38277
  return {};
38172
38278
  }
@@ -38193,7 +38299,7 @@ var require_json = __commonJS({
38193
38299
  isValidCharset: (charset) => charset.slice(0, 4) === "utf-"
38194
38300
  };
38195
38301
  return function jsonParser(req, res, next) {
38196
- read2(req, res, next, parse15, debug, readOptions);
38302
+ read2(req, res, next, parse16, debug, readOptions);
38197
38303
  };
38198
38304
  }
38199
38305
  function createStrictSyntaxError(str2, char) {
@@ -40771,11 +40877,11 @@ var require_lib2 = __commonJS({
40771
40877
  "../../node_modules/qs/lib/index.js"(exports, module) {
40772
40878
  "use strict";
40773
40879
  var stringify7 = require_stringify2();
40774
- var parse15 = require_parse();
40880
+ var parse16 = require_parse();
40775
40881
  var formats = require_formats();
40776
40882
  module.exports = {
40777
40883
  formats,
40778
- parse: parse15,
40884
+ parse: parse16,
40779
40885
  stringify: stringify7
40780
40886
  };
40781
40887
  }
@@ -40797,7 +40903,7 @@ var require_urlencoded = __commonJS({
40797
40903
  throw new TypeError("option defaultCharset must be either utf-8 or iso-8859-1");
40798
40904
  }
40799
40905
  var queryparse = createQueryParser(options);
40800
- function parse15(body, encoding) {
40906
+ function parse16(body, encoding) {
40801
40907
  return body.length ? queryparse(body, encoding) : {};
40802
40908
  }
40803
40909
  const readOptions = {
@@ -40806,7 +40912,7 @@ var require_urlencoded = __commonJS({
40806
40912
  isValidCharset: (charset) => charset === "utf-8" || charset === "iso-8859-1"
40807
40913
  };
40808
40914
  return function urlencodedParser(req, res, next) {
40809
- read2(req, res, next, parse15, debug, readOptions);
40915
+ read2(req, res, next, parse16, debug, readOptions);
40810
40916
  };
40811
40917
  }
40812
40918
  function createQueryParser(options) {
@@ -40990,7 +41096,7 @@ var require_parseurl = __commonJS({
40990
41096
  "../../node_modules/parseurl/index.js"(exports, module) {
40991
41097
  "use strict";
40992
41098
  var url = __require("url");
40993
- var parse15 = url.parse;
41099
+ var parse16 = url.parse;
40994
41100
  var Url = url.Url;
40995
41101
  module.exports = parseurl;
40996
41102
  module.exports.original = originalurl;
@@ -41022,7 +41128,7 @@ var require_parseurl = __commonJS({
41022
41128
  }
41023
41129
  function fastparse(str2) {
41024
41130
  if (typeof str2 !== "string" || str2.charCodeAt(0) !== 47) {
41025
- return parse15(str2);
41131
+ return parse16(str2);
41026
41132
  }
41027
41133
  var pathname = str2;
41028
41134
  var query = null;
@@ -41050,7 +41156,7 @@ var require_parseurl = __commonJS({
41050
41156
  /* # */
41051
41157
  case 160:
41052
41158
  case 65279:
41053
- return parse15(str2);
41159
+ return parse16(str2);
41054
41160
  }
41055
41161
  }
41056
41162
  var url2 = Url !== void 0 ? new Url() : {};
@@ -41201,13 +41307,13 @@ var require_view = __commonJS({
41201
41307
  "../../node_modules/express/lib/view.js"(exports, module) {
41202
41308
  "use strict";
41203
41309
  var debug = require_src()("express:view");
41204
- var path43 = __require("node:path");
41205
- var fs26 = __require("node:fs");
41206
- var dirname7 = path43.dirname;
41207
- var basename5 = path43.basename;
41208
- var extname2 = path43.extname;
41209
- var join39 = path43.join;
41210
- var resolve6 = path43.resolve;
41310
+ var path44 = __require("node:path");
41311
+ var fs27 = __require("node:fs");
41312
+ var dirname7 = path44.dirname;
41313
+ var basename5 = path44.basename;
41314
+ var extname2 = path44.extname;
41315
+ var join40 = path44.join;
41316
+ var resolve6 = path44.resolve;
41211
41317
  module.exports = View;
41212
41318
  function View(name, options) {
41213
41319
  var opts2 = options || {};
@@ -41236,17 +41342,17 @@ var require_view = __commonJS({
41236
41342
  this.path = this.lookup(fileName);
41237
41343
  }
41238
41344
  View.prototype.lookup = function lookup(name) {
41239
- var path44;
41345
+ var path45;
41240
41346
  var roots = [].concat(this.root);
41241
41347
  debug('lookup "%s"', name);
41242
- for (var i = 0; i < roots.length && !path44; i++) {
41348
+ for (var i = 0; i < roots.length && !path45; i++) {
41243
41349
  var root = roots[i];
41244
41350
  var loc = resolve6(root, name);
41245
41351
  var dir = dirname7(loc);
41246
41352
  var file = basename5(loc);
41247
- path44 = this.resolve(dir, file);
41353
+ path45 = this.resolve(dir, file);
41248
41354
  }
41249
- return path44;
41355
+ return path45;
41250
41356
  };
41251
41357
  View.prototype.render = function render(options, callback) {
41252
41358
  var sync = true;
@@ -41268,21 +41374,21 @@ var require_view = __commonJS({
41268
41374
  };
41269
41375
  View.prototype.resolve = function resolve7(dir, file) {
41270
41376
  var ext = this.ext;
41271
- var path44 = join39(dir, file);
41272
- var stat = tryStat(path44);
41377
+ var path45 = join40(dir, file);
41378
+ var stat = tryStat(path45);
41273
41379
  if (stat && stat.isFile()) {
41274
- return path44;
41380
+ return path45;
41275
41381
  }
41276
- path44 = join39(dir, basename5(file, ext), "index" + ext);
41277
- stat = tryStat(path44);
41382
+ path45 = join40(dir, basename5(file, ext), "index" + ext);
41383
+ stat = tryStat(path45);
41278
41384
  if (stat && stat.isFile()) {
41279
- return path44;
41385
+ return path45;
41280
41386
  }
41281
41387
  };
41282
- function tryStat(path44) {
41283
- debug('stat "%s"', path44);
41388
+ function tryStat(path45) {
41389
+ debug('stat "%s"', path45);
41284
41390
  try {
41285
- return fs26.statSync(path44);
41391
+ return fs27.statSync(path45);
41286
41392
  } catch (e) {
41287
41393
  return void 0;
41288
41394
  }
@@ -50788,11 +50894,11 @@ var require_mime_types2 = __commonJS({
50788
50894
  }
50789
50895
  return exts[0];
50790
50896
  }
50791
- function lookup(path43) {
50792
- if (!path43 || typeof path43 !== "string") {
50897
+ function lookup(path44) {
50898
+ if (!path44 || typeof path44 !== "string") {
50793
50899
  return false;
50794
50900
  }
50795
- var extension2 = extname2("x." + path43).toLowerCase().slice(1);
50901
+ var extension2 = extname2("x." + path44).toLowerCase().slice(1);
50796
50902
  if (!extension2) {
50797
50903
  return false;
50798
50904
  }
@@ -50846,7 +50952,7 @@ var require_forwarded = __commonJS({
50846
50952
  if (!req) {
50847
50953
  throw new TypeError("argument req is required");
50848
50954
  }
50849
- var proxyAddrs = parse15(req.headers["x-forwarded-for"] || "");
50955
+ var proxyAddrs = parse16(req.headers["x-forwarded-for"] || "");
50850
50956
  var socketAddr = getSocketAddr(req);
50851
50957
  var addrs = [socketAddr].concat(proxyAddrs);
50852
50958
  return addrs;
@@ -50854,7 +50960,7 @@ var require_forwarded = __commonJS({
50854
50960
  function getSocketAddr(req) {
50855
50961
  return req.socket ? req.socket.remoteAddress : req.connection.remoteAddress;
50856
50962
  }
50857
- function parse15(header) {
50963
+ function parse16(header) {
50858
50964
  var end = header.length;
50859
50965
  var list = [];
50860
50966
  var start = header.length;
@@ -51883,7 +51989,7 @@ var require_dist2 = __commonJS({
51883
51989
  "use strict";
51884
51990
  Object.defineProperty(exports, "__esModule", { value: true });
51885
51991
  exports.PathError = exports.TokenData = void 0;
51886
- exports.parse = parse15;
51992
+ exports.parse = parse16;
51887
51993
  exports.compile = compile;
51888
51994
  exports.match = match;
51889
51995
  exports.pathToRegexp = pathToRegexp;
@@ -51929,7 +52035,7 @@ var require_dist2 = __commonJS({
51929
52035
  }
51930
52036
  };
51931
52037
  exports.PathError = PathError;
51932
- function parse15(str2, options = {}) {
52038
+ function parse16(str2, options = {}) {
51933
52039
  const { encodePath = NOOP_VALUE } = options;
51934
52040
  const chars = [...str2];
51935
52041
  const tokens = [];
@@ -51985,15 +52091,15 @@ var require_dist2 = __commonJS({
51985
52091
  if (token.type === endType)
51986
52092
  break;
51987
52093
  if (token.type === "char" || token.type === "escape") {
51988
- let path43 = token.value;
52094
+ let path44 = token.value;
51989
52095
  let cur = tokens[pos];
51990
52096
  while (cur.type === "char" || cur.type === "escape") {
51991
- path43 += cur.value;
52097
+ path44 += cur.value;
51992
52098
  cur = tokens[++pos];
51993
52099
  }
51994
52100
  output.push({
51995
52101
  type: "text",
51996
- value: encodePath(path43)
52102
+ value: encodePath(path44)
51997
52103
  });
51998
52104
  continue;
51999
52105
  }
@@ -52017,16 +52123,16 @@ var require_dist2 = __commonJS({
52017
52123
  }
52018
52124
  return new TokenData(consumeUntil("end"), str2);
52019
52125
  }
52020
- function compile(path43, options = {}) {
52126
+ function compile(path44, options = {}) {
52021
52127
  const { encode: encode2 = encodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
52022
- const data = typeof path43 === "object" ? path43 : parse15(path43, options);
52128
+ const data = typeof path44 === "object" ? path44 : parse16(path44, options);
52023
52129
  const fn = tokensToFunction(data.tokens, delimiter, encode2);
52024
- return function path44(params = {}) {
52025
- const [path45, ...missing] = fn(params);
52130
+ return function path45(params = {}) {
52131
+ const [path46, ...missing] = fn(params);
52026
52132
  if (missing.length) {
52027
52133
  throw new TypeError(`Missing parameters: ${missing.join(", ")}`);
52028
52134
  }
52029
- return path45;
52135
+ return path46;
52030
52136
  };
52031
52137
  }
52032
52138
  function tokensToFunction(tokens, delimiter, encode2) {
@@ -52082,9 +52188,9 @@ var require_dist2 = __commonJS({
52082
52188
  return [encodeValue(value)];
52083
52189
  };
52084
52190
  }
52085
- function match(path43, options = {}) {
52191
+ function match(path44, options = {}) {
52086
52192
  const { decode: decode2 = decodeURIComponent, delimiter = DEFAULT_DELIMITER } = options;
52087
- const { regexp, keys } = pathToRegexp(path43, options);
52193
+ const { regexp, keys } = pathToRegexp(path44, options);
52088
52194
  const decoders = keys.map((key) => {
52089
52195
  if (decode2 === false)
52090
52196
  return NOOP_VALUE;
@@ -52096,7 +52202,7 @@ var require_dist2 = __commonJS({
52096
52202
  const m = regexp.exec(input);
52097
52203
  if (!m)
52098
52204
  return false;
52099
- const path44 = m[0];
52205
+ const path45 = m[0];
52100
52206
  const params = /* @__PURE__ */ Object.create(null);
52101
52207
  for (let i = 1; i < m.length; i++) {
52102
52208
  if (m[i] === void 0)
@@ -52105,16 +52211,16 @@ var require_dist2 = __commonJS({
52105
52211
  const decoder = decoders[i - 1];
52106
52212
  params[key.name] = decoder(m[i]);
52107
52213
  }
52108
- return { path: path44, params };
52214
+ return { path: path45, params };
52109
52215
  };
52110
52216
  }
52111
- function pathToRegexp(path43, options = {}) {
52217
+ function pathToRegexp(path44, options = {}) {
52112
52218
  const { delimiter = DEFAULT_DELIMITER, end = true, sensitive = false, trailing = true } = options;
52113
52219
  const keys = [];
52114
52220
  const flags = sensitive ? "" : "i";
52115
52221
  const sources = [];
52116
- for (const input of pathsToArray(path43, [])) {
52117
- const data = typeof input === "object" ? input : parse15(input, options);
52222
+ for (const input of pathsToArray(path44, [])) {
52223
+ const data = typeof input === "object" ? input : parse16(input, options);
52118
52224
  for (const tokens of flatten2(data.tokens, 0, [])) {
52119
52225
  sources.push(toRegExpSource(tokens, delimiter, keys, data.originalPath));
52120
52226
  }
@@ -52243,18 +52349,18 @@ var require_layer = __commonJS({
52243
52349
  var TRAILING_SLASH_REGEXP = /\/+$/;
52244
52350
  var MATCHING_GROUP_REGEXP = /\((?:\?<(.*?)>)?(?!\?)/g;
52245
52351
  module.exports = Layer;
52246
- function Layer(path43, options, fn) {
52352
+ function Layer(path44, options, fn) {
52247
52353
  if (!(this instanceof Layer)) {
52248
- return new Layer(path43, options, fn);
52354
+ return new Layer(path44, options, fn);
52249
52355
  }
52250
- debug("new %o", path43);
52356
+ debug("new %o", path44);
52251
52357
  const opts2 = options || {};
52252
52358
  this.handle = fn;
52253
52359
  this.keys = [];
52254
52360
  this.name = fn.name || "<anonymous>";
52255
52361
  this.params = void 0;
52256
52362
  this.path = void 0;
52257
- this.slash = path43 === "/" && opts2.end === false;
52363
+ this.slash = path44 === "/" && opts2.end === false;
52258
52364
  function matcher(_path) {
52259
52365
  if (_path instanceof RegExp) {
52260
52366
  const keys = [];
@@ -52293,7 +52399,7 @@ var require_layer = __commonJS({
52293
52399
  decode: decodeParam
52294
52400
  });
52295
52401
  }
52296
- this.matchers = Array.isArray(path43) ? path43.map(matcher) : [matcher(path43)];
52402
+ this.matchers = Array.isArray(path44) ? path44.map(matcher) : [matcher(path44)];
52297
52403
  }
52298
52404
  Layer.prototype.handleError = function handleError(error, req, res, next) {
52299
52405
  const fn = this.handle;
@@ -52333,9 +52439,9 @@ var require_layer = __commonJS({
52333
52439
  next(err);
52334
52440
  }
52335
52441
  };
52336
- Layer.prototype.match = function match(path43) {
52442
+ Layer.prototype.match = function match(path44) {
52337
52443
  let match2;
52338
- if (path43 != null) {
52444
+ if (path44 != null) {
52339
52445
  if (this.slash) {
52340
52446
  this.params = {};
52341
52447
  this.path = "";
@@ -52343,7 +52449,7 @@ var require_layer = __commonJS({
52343
52449
  }
52344
52450
  let i = 0;
52345
52451
  while (!match2 && i < this.matchers.length) {
52346
- match2 = this.matchers[i](path43);
52452
+ match2 = this.matchers[i](path44);
52347
52453
  i++;
52348
52454
  }
52349
52455
  }
@@ -52371,13 +52477,13 @@ var require_layer = __commonJS({
52371
52477
  throw err;
52372
52478
  }
52373
52479
  }
52374
- function loosen(path43) {
52375
- if (path43 instanceof RegExp || path43 === "/") {
52376
- return path43;
52480
+ function loosen(path44) {
52481
+ if (path44 instanceof RegExp || path44 === "/") {
52482
+ return path44;
52377
52483
  }
52378
- return Array.isArray(path43) ? path43.map(function(p) {
52484
+ return Array.isArray(path44) ? path44.map(function(p) {
52379
52485
  return loosen(p);
52380
- }) : String(path43).replace(TRAILING_SLASH_REGEXP, "");
52486
+ }) : String(path44).replace(TRAILING_SLASH_REGEXP, "");
52381
52487
  }
52382
52488
  }
52383
52489
  });
@@ -52393,9 +52499,9 @@ var require_route = __commonJS({
52393
52499
  var flatten2 = Array.prototype.flat;
52394
52500
  var methods = METHODS.map((method) => method.toLowerCase());
52395
52501
  module.exports = Route;
52396
- function Route(path43) {
52397
- debug("new %o", path43);
52398
- this.path = path43;
52502
+ function Route(path44) {
52503
+ debug("new %o", path44);
52504
+ this.path = path44;
52399
52505
  this.stack = [];
52400
52506
  this.methods = /* @__PURE__ */ Object.create(null);
52401
52507
  }
@@ -52603,8 +52709,8 @@ var require_router = __commonJS({
52603
52709
  if (++sync > 100) {
52604
52710
  return setImmediate(next, err);
52605
52711
  }
52606
- const path43 = getPathname(req);
52607
- if (path43 == null) {
52712
+ const path44 = getPathname(req);
52713
+ if (path44 == null) {
52608
52714
  return done(layerError);
52609
52715
  }
52610
52716
  let layer;
@@ -52612,7 +52718,7 @@ var require_router = __commonJS({
52612
52718
  let route;
52613
52719
  while (match !== true && idx < stack.length) {
52614
52720
  layer = stack[idx++];
52615
- match = matchLayer(layer, path43);
52721
+ match = matchLayer(layer, path44);
52616
52722
  route = layer.route;
52617
52723
  if (typeof match !== "boolean") {
52618
52724
  layerError = layerError || match;
@@ -52650,18 +52756,18 @@ var require_router = __commonJS({
52650
52756
  } else if (route) {
52651
52757
  layer.handleRequest(req, res, next);
52652
52758
  } else {
52653
- trimPrefix(layer, layerError, layerPath, path43);
52759
+ trimPrefix(layer, layerError, layerPath, path44);
52654
52760
  }
52655
52761
  sync = 0;
52656
52762
  });
52657
52763
  }
52658
- function trimPrefix(layer, layerError, layerPath, path43) {
52764
+ function trimPrefix(layer, layerError, layerPath, path44) {
52659
52765
  if (layerPath.length !== 0) {
52660
- if (layerPath !== path43.substring(0, layerPath.length)) {
52766
+ if (layerPath !== path44.substring(0, layerPath.length)) {
52661
52767
  next(layerError);
52662
52768
  return;
52663
52769
  }
52664
- const c = path43[layerPath.length];
52770
+ const c = path44[layerPath.length];
52665
52771
  if (c && c !== "/") {
52666
52772
  next(layerError);
52667
52773
  return;
@@ -52685,7 +52791,7 @@ var require_router = __commonJS({
52685
52791
  };
52686
52792
  Router.prototype.use = function use(handler) {
52687
52793
  let offset = 0;
52688
- let path43 = "/";
52794
+ let path44 = "/";
52689
52795
  if (typeof handler !== "function") {
52690
52796
  let arg = handler;
52691
52797
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -52693,7 +52799,7 @@ var require_router = __commonJS({
52693
52799
  }
52694
52800
  if (typeof arg !== "function") {
52695
52801
  offset = 1;
52696
- path43 = handler;
52802
+ path44 = handler;
52697
52803
  }
52698
52804
  }
52699
52805
  const callbacks = flatten2.call(slice.call(arguments, offset), Infinity);
@@ -52705,8 +52811,8 @@ var require_router = __commonJS({
52705
52811
  if (typeof fn !== "function") {
52706
52812
  throw new TypeError("argument handler must be a function");
52707
52813
  }
52708
- debug("use %o %s", path43, fn.name || "<anonymous>");
52709
- const layer = new Layer(path43, {
52814
+ debug("use %o %s", path44, fn.name || "<anonymous>");
52815
+ const layer = new Layer(path44, {
52710
52816
  sensitive: this.caseSensitive,
52711
52817
  strict: false,
52712
52818
  end: false
@@ -52716,9 +52822,9 @@ var require_router = __commonJS({
52716
52822
  }
52717
52823
  return this;
52718
52824
  };
52719
- Router.prototype.route = function route(path43) {
52720
- const route2 = new Route(path43);
52721
- const layer = new Layer(path43, {
52825
+ Router.prototype.route = function route(path44) {
52826
+ const route2 = new Route(path44);
52827
+ const layer = new Layer(path44, {
52722
52828
  sensitive: this.caseSensitive,
52723
52829
  strict: this.strict,
52724
52830
  end: true
@@ -52731,8 +52837,8 @@ var require_router = __commonJS({
52731
52837
  return route2;
52732
52838
  };
52733
52839
  methods.concat("all").forEach(function(method) {
52734
- Router.prototype[method] = function(path43) {
52735
- const route = this.route(path43);
52840
+ Router.prototype[method] = function(path44) {
52841
+ const route = this.route(path44);
52736
52842
  route[method].apply(route, slice.call(arguments, 1));
52737
52843
  return this;
52738
52844
  };
@@ -52761,9 +52867,9 @@ var require_router = __commonJS({
52761
52867
  const fqdnIndex = url.substring(0, pathLength).indexOf("://");
52762
52868
  return fqdnIndex !== -1 ? url.substring(0, url.indexOf("/", 3 + fqdnIndex)) : void 0;
52763
52869
  }
52764
- function matchLayer(layer, path43) {
52870
+ function matchLayer(layer, path44) {
52765
52871
  try {
52766
- return layer.match(path43);
52872
+ return layer.match(path44);
52767
52873
  } catch (err) {
52768
52874
  return err;
52769
52875
  }
@@ -52991,7 +53097,7 @@ var require_application = __commonJS({
52991
53097
  };
52992
53098
  app.use = function use(fn) {
52993
53099
  var offset = 0;
52994
- var path43 = "/";
53100
+ var path44 = "/";
52995
53101
  if (typeof fn !== "function") {
52996
53102
  var arg = fn;
52997
53103
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -52999,7 +53105,7 @@ var require_application = __commonJS({
52999
53105
  }
53000
53106
  if (typeof arg !== "function") {
53001
53107
  offset = 1;
53002
- path43 = fn;
53108
+ path44 = fn;
53003
53109
  }
53004
53110
  }
53005
53111
  var fns = flatten2.call(slice.call(arguments, offset), Infinity);
@@ -53009,12 +53115,12 @@ var require_application = __commonJS({
53009
53115
  var router = this.router;
53010
53116
  fns.forEach(function(fn2) {
53011
53117
  if (!fn2 || !fn2.handle || !fn2.set) {
53012
- return router.use(path43, fn2);
53118
+ return router.use(path44, fn2);
53013
53119
  }
53014
- debug(".use app under %s", path43);
53015
- fn2.mountpath = path43;
53120
+ debug(".use app under %s", path44);
53121
+ fn2.mountpath = path44;
53016
53122
  fn2.parent = this;
53017
- router.use(path43, function mounted_app(req, res, next) {
53123
+ router.use(path44, function mounted_app(req, res, next) {
53018
53124
  var orig = req.app;
53019
53125
  fn2.handle(req, res, function(err) {
53020
53126
  Object.setPrototypeOf(req, orig.request);
@@ -53026,8 +53132,8 @@ var require_application = __commonJS({
53026
53132
  }, this);
53027
53133
  return this;
53028
53134
  };
53029
- app.route = function route(path43) {
53030
- return this.router.route(path43);
53135
+ app.route = function route(path44) {
53136
+ return this.router.route(path44);
53031
53137
  };
53032
53138
  app.engine = function engine(ext, fn) {
53033
53139
  if (typeof fn !== "function") {
@@ -53070,7 +53176,7 @@ var require_application = __commonJS({
53070
53176
  }
53071
53177
  return this;
53072
53178
  };
53073
- app.path = function path43() {
53179
+ app.path = function path44() {
53074
53180
  return this.parent ? this.parent.path() + this.mountpath : "";
53075
53181
  };
53076
53182
  app.enabled = function enabled(setting) {
@@ -53086,17 +53192,17 @@ var require_application = __commonJS({
53086
53192
  return this.set(setting, false);
53087
53193
  };
53088
53194
  methods.forEach(function(method) {
53089
- app[method] = function(path43) {
53195
+ app[method] = function(path44) {
53090
53196
  if (method === "get" && arguments.length === 1) {
53091
- return this.set(path43);
53197
+ return this.set(path44);
53092
53198
  }
53093
- var route = this.route(path43);
53199
+ var route = this.route(path44);
53094
53200
  route[method].apply(route, slice.call(arguments, 1));
53095
53201
  return this;
53096
53202
  };
53097
53203
  });
53098
- app.all = function all(path43) {
53099
- var route = this.route(path43);
53204
+ app.all = function all(path44) {
53205
+ var route = this.route(path44);
53100
53206
  var args = slice.call(arguments, 1);
53101
53207
  for (var i = 0; i < methods.length; i++) {
53102
53208
  route[methods[i]].apply(route, args);
@@ -63130,11 +63236,11 @@ var require_mime_types3 = __commonJS({
63130
63236
  }
63131
63237
  return exts[0];
63132
63238
  }
63133
- function lookup(path43) {
63134
- if (!path43 || typeof path43 !== "string") {
63239
+ function lookup(path44) {
63240
+ if (!path44 || typeof path44 !== "string") {
63135
63241
  return false;
63136
63242
  }
63137
- var extension2 = extname2("x." + path43).toLowerCase().slice(1);
63243
+ var extension2 = extname2("x." + path44).toLowerCase().slice(1);
63138
63244
  if (!extension2) {
63139
63245
  return false;
63140
63246
  }
@@ -63423,7 +63529,7 @@ var require_request = __commonJS({
63423
63529
  var http = __require("node:http");
63424
63530
  var fresh = require_fresh();
63425
63531
  var parseRange = require_range_parser();
63426
- var parse15 = require_parseurl();
63532
+ var parse16 = require_parseurl();
63427
63533
  var proxyaddr = require_proxy_addr();
63428
63534
  var req = Object.create(http.IncomingMessage.prototype);
63429
63535
  module.exports = req;
@@ -63468,7 +63574,7 @@ var require_request = __commonJS({
63468
63574
  if (!queryparse) {
63469
63575
  return /* @__PURE__ */ Object.create(null);
63470
63576
  }
63471
- var querystring = parse15(this).query;
63577
+ var querystring = parse16(this).query;
63472
63578
  return queryparse(querystring);
63473
63579
  });
63474
63580
  req.is = function is(types) {
@@ -63511,8 +63617,8 @@ var require_request = __commonJS({
63511
63617
  var subdomains2 = !isIP(hostname) ? hostname.split(".").reverse() : [hostname];
63512
63618
  return subdomains2.slice(offset);
63513
63619
  });
63514
- defineGetter(req, "path", function path43() {
63515
- return parse15(this).pathname;
63620
+ defineGetter(req, "path", function path44() {
63621
+ return parse16(this).pathname;
63516
63622
  });
63517
63623
  defineGetter(req, "host", function host() {
63518
63624
  var trust = this.app.get("trust proxy fn");
@@ -63566,7 +63672,7 @@ var require_content_disposition = __commonJS({
63566
63672
  "../../node_modules/content-disposition/index.js"(exports, module) {
63567
63673
  "use strict";
63568
63674
  module.exports = contentDisposition;
63569
- module.exports.parse = parse15;
63675
+ module.exports.parse = parse16;
63570
63676
  var basename5 = __require("path").basename;
63571
63677
  var ENCODE_URL_ATTR_CHAR_REGEXP = /[\x00-\x20"'()*,/:;<=>?@[\\\]{}\x7f]/g;
63572
63678
  var HEX_ESCAPE_REGEXP = /%[0-9A-Fa-f]{2}/;
@@ -63657,7 +63763,7 @@ var require_content_disposition = __commonJS({
63657
63763
  function getlatin1(val) {
63658
63764
  return String(val).replace(NON_LATIN1_REGEXP, "?");
63659
63765
  }
63660
- function parse15(string) {
63766
+ function parse16(string) {
63661
63767
  if (!string || typeof string !== "string") {
63662
63768
  throw new TypeError("argument string is required");
63663
63769
  }
@@ -63746,7 +63852,7 @@ var require_cookie_signature = __commonJS({
63746
63852
  var require_cookie = __commonJS({
63747
63853
  "../../node_modules/cookie/index.js"(exports) {
63748
63854
  "use strict";
63749
- exports.parse = parse15;
63855
+ exports.parse = parse16;
63750
63856
  exports.serialize = serialize;
63751
63857
  var __toString = Object.prototype.toString;
63752
63858
  var __hasOwnProperty = Object.prototype.hasOwnProperty;
@@ -63754,7 +63860,7 @@ var require_cookie = __commonJS({
63754
63860
  var cookieValueRegExp = /^("?)[\u0021\u0023-\u002B\u002D-\u003A\u003C-\u005B\u005D-\u007E]*\1$/;
63755
63861
  var domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
63756
63862
  var pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
63757
- function parse15(str2, opt) {
63863
+ function parse16(str2, opt) {
63758
63864
  if (typeof str2 !== "string") {
63759
63865
  throw new TypeError("argument str must be a string");
63760
63866
  }
@@ -73364,11 +73470,11 @@ var require_mime_types4 = __commonJS({
73364
73470
  }
73365
73471
  return exts[0];
73366
73472
  }
73367
- function lookup(path43) {
73368
- if (!path43 || typeof path43 !== "string") {
73473
+ function lookup(path44) {
73474
+ if (!path44 || typeof path44 !== "string") {
73369
73475
  return false;
73370
73476
  }
73371
- var extension2 = extname2("x." + path43).toLowerCase().slice(1);
73477
+ var extension2 = extname2("x." + path44).toLowerCase().slice(1);
73372
73478
  if (!extension2) {
73373
73479
  return false;
73374
73480
  }
@@ -73423,32 +73529,32 @@ var require_send = __commonJS({
73423
73529
  var escapeHtml = require_escape_html();
73424
73530
  var etag = require_etag();
73425
73531
  var fresh = require_fresh();
73426
- var fs26 = __require("fs");
73532
+ var fs27 = __require("fs");
73427
73533
  var mime = require_mime_types4();
73428
73534
  var ms = require_ms();
73429
73535
  var onFinished = require_on_finished();
73430
73536
  var parseRange = require_range_parser();
73431
- var path43 = __require("path");
73537
+ var path44 = __require("path");
73432
73538
  var statuses = require_statuses();
73433
73539
  var Stream = __require("stream");
73434
73540
  var util = __require("util");
73435
- var extname2 = path43.extname;
73436
- var join39 = path43.join;
73437
- var normalize = path43.normalize;
73438
- var resolve6 = path43.resolve;
73439
- var sep = path43.sep;
73541
+ var extname2 = path44.extname;
73542
+ var join40 = path44.join;
73543
+ var normalize = path44.normalize;
73544
+ var resolve6 = path44.resolve;
73545
+ var sep = path44.sep;
73440
73546
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
73441
73547
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
73442
73548
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
73443
73549
  module.exports = send;
73444
- function send(req, path44, options) {
73445
- return new SendStream(req, path44, options);
73550
+ function send(req, path45, options) {
73551
+ return new SendStream(req, path45, options);
73446
73552
  }
73447
- function SendStream(req, path44, options) {
73553
+ function SendStream(req, path45, options) {
73448
73554
  Stream.call(this);
73449
73555
  var opts2 = options || {};
73450
73556
  this.options = opts2;
73451
- this.path = path44;
73557
+ this.path = path45;
73452
73558
  this.req = req;
73453
73559
  this._acceptRanges = opts2.acceptRanges !== void 0 ? Boolean(opts2.acceptRanges) : true;
73454
73560
  this._cacheControl = opts2.cacheControl !== void 0 ? Boolean(opts2.cacheControl) : true;
@@ -73562,10 +73668,10 @@ var require_send = __commonJS({
73562
73668
  var lastModified = this.res.getHeader("Last-Modified");
73563
73669
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
73564
73670
  };
73565
- SendStream.prototype.redirect = function redirect(path44) {
73671
+ SendStream.prototype.redirect = function redirect(path45) {
73566
73672
  var res = this.res;
73567
73673
  if (hasListeners(this, "directory")) {
73568
- this.emit("directory", res, path44);
73674
+ this.emit("directory", res, path45);
73569
73675
  return;
73570
73676
  }
73571
73677
  if (this.hasTrailingSlash()) {
@@ -73585,38 +73691,38 @@ var require_send = __commonJS({
73585
73691
  SendStream.prototype.pipe = function pipe(res) {
73586
73692
  var root = this._root;
73587
73693
  this.res = res;
73588
- var path44 = decode2(this.path);
73589
- if (path44 === -1) {
73694
+ var path45 = decode2(this.path);
73695
+ if (path45 === -1) {
73590
73696
  this.error(400);
73591
73697
  return res;
73592
73698
  }
73593
- if (~path44.indexOf("\0")) {
73699
+ if (~path45.indexOf("\0")) {
73594
73700
  this.error(400);
73595
73701
  return res;
73596
73702
  }
73597
73703
  var parts;
73598
73704
  if (root !== null) {
73599
- if (path44) {
73600
- path44 = normalize("." + sep + path44);
73705
+ if (path45) {
73706
+ path45 = normalize("." + sep + path45);
73601
73707
  }
73602
- if (UP_PATH_REGEXP.test(path44)) {
73603
- debug('malicious path "%s"', path44);
73708
+ if (UP_PATH_REGEXP.test(path45)) {
73709
+ debug('malicious path "%s"', path45);
73604
73710
  this.error(403);
73605
73711
  return res;
73606
73712
  }
73607
- parts = path44.split(sep);
73608
- path44 = normalize(join39(root, path44));
73713
+ parts = path45.split(sep);
73714
+ path45 = normalize(join40(root, path45));
73609
73715
  } else {
73610
- if (UP_PATH_REGEXP.test(path44)) {
73611
- debug('malicious path "%s"', path44);
73716
+ if (UP_PATH_REGEXP.test(path45)) {
73717
+ debug('malicious path "%s"', path45);
73612
73718
  this.error(403);
73613
73719
  return res;
73614
73720
  }
73615
- parts = normalize(path44).split(sep);
73616
- path44 = resolve6(path44);
73721
+ parts = normalize(path45).split(sep);
73722
+ path45 = resolve6(path45);
73617
73723
  }
73618
73724
  if (containsDotFile(parts)) {
73619
- debug('%s dotfile "%s"', this._dotfiles, path44);
73725
+ debug('%s dotfile "%s"', this._dotfiles, path45);
73620
73726
  switch (this._dotfiles) {
73621
73727
  case "allow":
73622
73728
  break;
@@ -73630,13 +73736,13 @@ var require_send = __commonJS({
73630
73736
  }
73631
73737
  }
73632
73738
  if (this._index.length && this.hasTrailingSlash()) {
73633
- this.sendIndex(path44);
73739
+ this.sendIndex(path45);
73634
73740
  return res;
73635
73741
  }
73636
- this.sendFile(path44);
73742
+ this.sendFile(path45);
73637
73743
  return res;
73638
73744
  };
73639
- SendStream.prototype.send = function send2(path44, stat) {
73745
+ SendStream.prototype.send = function send2(path45, stat) {
73640
73746
  var len = stat.size;
73641
73747
  var options = this.options;
73642
73748
  var opts2 = {};
@@ -73648,9 +73754,9 @@ var require_send = __commonJS({
73648
73754
  this.headersAlreadySent();
73649
73755
  return;
73650
73756
  }
73651
- debug('pipe "%s"', path44);
73652
- this.setHeader(path44, stat);
73653
- this.type(path44);
73757
+ debug('pipe "%s"', path45);
73758
+ this.setHeader(path45, stat);
73759
+ this.type(path45);
73654
73760
  if (this.isConditionalGET()) {
73655
73761
  if (this.isPreconditionFailure()) {
73656
73762
  this.error(412);
@@ -73699,30 +73805,30 @@ var require_send = __commonJS({
73699
73805
  res.end();
73700
73806
  return;
73701
73807
  }
73702
- this.stream(path44, opts2);
73808
+ this.stream(path45, opts2);
73703
73809
  };
73704
- SendStream.prototype.sendFile = function sendFile(path44) {
73810
+ SendStream.prototype.sendFile = function sendFile(path45) {
73705
73811
  var i = 0;
73706
73812
  var self = this;
73707
- debug('stat "%s"', path44);
73708
- fs26.stat(path44, function onstat(err, stat) {
73709
- var pathEndsWithSep = path44[path44.length - 1] === sep;
73710
- if (err && err.code === "ENOENT" && !extname2(path44) && !pathEndsWithSep) {
73813
+ debug('stat "%s"', path45);
73814
+ fs27.stat(path45, function onstat(err, stat) {
73815
+ var pathEndsWithSep = path45[path45.length - 1] === sep;
73816
+ if (err && err.code === "ENOENT" && !extname2(path45) && !pathEndsWithSep) {
73711
73817
  return next(err);
73712
73818
  }
73713
73819
  if (err) return self.onStatError(err);
73714
- if (stat.isDirectory()) return self.redirect(path44);
73820
+ if (stat.isDirectory()) return self.redirect(path45);
73715
73821
  if (pathEndsWithSep) return self.error(404);
73716
- self.emit("file", path44, stat);
73717
- self.send(path44, stat);
73822
+ self.emit("file", path45, stat);
73823
+ self.send(path45, stat);
73718
73824
  });
73719
73825
  function next(err) {
73720
73826
  if (self._extensions.length <= i) {
73721
73827
  return err ? self.onStatError(err) : self.error(404);
73722
73828
  }
73723
- var p = path44 + "." + self._extensions[i++];
73829
+ var p = path45 + "." + self._extensions[i++];
73724
73830
  debug('stat "%s"', p);
73725
- fs26.stat(p, function(err2, stat) {
73831
+ fs27.stat(p, function(err2, stat) {
73726
73832
  if (err2) return next(err2);
73727
73833
  if (stat.isDirectory()) return next();
73728
73834
  self.emit("file", p, stat);
@@ -73730,7 +73836,7 @@ var require_send = __commonJS({
73730
73836
  });
73731
73837
  }
73732
73838
  };
73733
- SendStream.prototype.sendIndex = function sendIndex(path44) {
73839
+ SendStream.prototype.sendIndex = function sendIndex(path45) {
73734
73840
  var i = -1;
73735
73841
  var self = this;
73736
73842
  function next(err) {
@@ -73738,9 +73844,9 @@ var require_send = __commonJS({
73738
73844
  if (err) return self.onStatError(err);
73739
73845
  return self.error(404);
73740
73846
  }
73741
- var p = join39(path44, self._index[i]);
73847
+ var p = join40(path45, self._index[i]);
73742
73848
  debug('stat "%s"', p);
73743
- fs26.stat(p, function(err2, stat) {
73849
+ fs27.stat(p, function(err2, stat) {
73744
73850
  if (err2) return next(err2);
73745
73851
  if (stat.isDirectory()) return next();
73746
73852
  self.emit("file", p, stat);
@@ -73749,10 +73855,10 @@ var require_send = __commonJS({
73749
73855
  }
73750
73856
  next();
73751
73857
  };
73752
- SendStream.prototype.stream = function stream2(path44, options) {
73858
+ SendStream.prototype.stream = function stream2(path45, options) {
73753
73859
  var self = this;
73754
73860
  var res = this.res;
73755
- var stream3 = fs26.createReadStream(path44, options);
73861
+ var stream3 = fs27.createReadStream(path45, options);
73756
73862
  this.emit("stream", stream3);
73757
73863
  stream3.pipe(res);
73758
73864
  function cleanup() {
@@ -73767,17 +73873,17 @@ var require_send = __commonJS({
73767
73873
  self.emit("end");
73768
73874
  });
73769
73875
  };
73770
- SendStream.prototype.type = function type(path44) {
73876
+ SendStream.prototype.type = function type(path45) {
73771
73877
  var res = this.res;
73772
73878
  if (res.getHeader("Content-Type")) return;
73773
- var ext = extname2(path44);
73879
+ var ext = extname2(path45);
73774
73880
  var type2 = mime.contentType(ext) || "application/octet-stream";
73775
73881
  debug("content-type %s", type2);
73776
73882
  res.setHeader("Content-Type", type2);
73777
73883
  };
73778
- SendStream.prototype.setHeader = function setHeader(path44, stat) {
73884
+ SendStream.prototype.setHeader = function setHeader(path45, stat) {
73779
73885
  var res = this.res;
73780
- this.emit("headers", res, path44, stat);
73886
+ this.emit("headers", res, path45, stat);
73781
73887
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
73782
73888
  debug("accept ranges");
73783
73889
  res.setHeader("Accept-Ranges", "bytes");
@@ -73835,9 +73941,9 @@ var require_send = __commonJS({
73835
73941
  }
73836
73942
  return err instanceof Error ? createError(status, err, { expose: false }) : createError(status, err);
73837
73943
  }
73838
- function decode2(path44) {
73944
+ function decode2(path45) {
73839
73945
  try {
73840
- return decodeURIComponent(path44);
73946
+ return decodeURIComponent(path45);
73841
73947
  } catch (err) {
73842
73948
  return -1;
73843
73949
  }
@@ -73910,7 +74016,7 @@ var require_vary = __commonJS({
73910
74016
  if (!field) {
73911
74017
  throw new TypeError("field argument is required");
73912
74018
  }
73913
- var fields = !Array.isArray(field) ? parse15(String(field)) : field;
74019
+ var fields = !Array.isArray(field) ? parse16(String(field)) : field;
73914
74020
  for (var j = 0; j < fields.length; j++) {
73915
74021
  if (!FIELD_NAME_REGEXP.test(fields[j])) {
73916
74022
  throw new TypeError("field argument contains an invalid header name");
@@ -73920,7 +74026,7 @@ var require_vary = __commonJS({
73920
74026
  return header;
73921
74027
  }
73922
74028
  var val = header;
73923
- var vals = parse15(header.toLowerCase());
74029
+ var vals = parse16(header.toLowerCase());
73924
74030
  if (fields.indexOf("*") !== -1 || vals.indexOf("*") !== -1) {
73925
74031
  return "*";
73926
74032
  }
@@ -73933,7 +74039,7 @@ var require_vary = __commonJS({
73933
74039
  }
73934
74040
  return val;
73935
74041
  }
73936
- function parse15(header) {
74042
+ function parse16(header) {
73937
74043
  var end = 0;
73938
74044
  var list = [];
73939
74045
  var start = 0;
@@ -73981,7 +74087,7 @@ var require_response = __commonJS({
73981
74087
  var http = __require("node:http");
73982
74088
  var onFinished = require_on_finished();
73983
74089
  var mime = require_mime_types2();
73984
- var path43 = __require("node:path");
74090
+ var path44 = __require("node:path");
73985
74091
  var pathIsAbsolute = __require("node:path").isAbsolute;
73986
74092
  var statuses = require_statuses();
73987
74093
  var sign = require_cookie_signature().sign;
@@ -73990,8 +74096,8 @@ var require_response = __commonJS({
73990
74096
  var setCharset = require_utils3().setCharset;
73991
74097
  var cookie = require_cookie();
73992
74098
  var send = require_send();
73993
- var extname2 = path43.extname;
73994
- var resolve6 = path43.resolve;
74099
+ var extname2 = path44.extname;
74100
+ var resolve6 = path44.resolve;
73995
74101
  var vary = require_vary();
73996
74102
  var { Buffer: Buffer2 } = __require("node:buffer");
73997
74103
  var res = Object.create(http.ServerResponse.prototype);
@@ -74137,26 +74243,26 @@ var require_response = __commonJS({
74137
74243
  this.type("txt");
74138
74244
  return this.send(body);
74139
74245
  };
74140
- res.sendFile = function sendFile(path44, options, callback) {
74246
+ res.sendFile = function sendFile(path45, options, callback) {
74141
74247
  var done = callback;
74142
74248
  var req = this.req;
74143
74249
  var res2 = this;
74144
74250
  var next = req.next;
74145
74251
  var opts2 = options || {};
74146
- if (!path44) {
74252
+ if (!path45) {
74147
74253
  throw new TypeError("path argument is required to res.sendFile");
74148
74254
  }
74149
- if (typeof path44 !== "string") {
74255
+ if (typeof path45 !== "string") {
74150
74256
  throw new TypeError("path must be a string to res.sendFile");
74151
74257
  }
74152
74258
  if (typeof options === "function") {
74153
74259
  done = options;
74154
74260
  opts2 = {};
74155
74261
  }
74156
- if (!opts2.root && !pathIsAbsolute(path44)) {
74262
+ if (!opts2.root && !pathIsAbsolute(path45)) {
74157
74263
  throw new TypeError("path must be absolute or specify root to res.sendFile");
74158
74264
  }
74159
- var pathname = encodeURI(path44);
74265
+ var pathname = encodeURI(path45);
74160
74266
  opts2.etag = this.app.enabled("etag");
74161
74267
  var file = send(req, pathname, opts2);
74162
74268
  sendfile(res2, file, opts2, function(err) {
@@ -74167,7 +74273,7 @@ var require_response = __commonJS({
74167
74273
  }
74168
74274
  });
74169
74275
  };
74170
- res.download = function download(path44, filename, options, callback) {
74276
+ res.download = function download(path45, filename, options, callback) {
74171
74277
  var done = callback;
74172
74278
  var name = filename;
74173
74279
  var opts2 = options || null;
@@ -74184,7 +74290,7 @@ var require_response = __commonJS({
74184
74290
  opts2 = filename;
74185
74291
  }
74186
74292
  var headers = {
74187
- "Content-Disposition": contentDisposition(name || path44)
74293
+ "Content-Disposition": contentDisposition(name || path45)
74188
74294
  };
74189
74295
  if (opts2 && opts2.headers) {
74190
74296
  var keys = Object.keys(opts2.headers);
@@ -74197,7 +74303,7 @@ var require_response = __commonJS({
74197
74303
  }
74198
74304
  opts2 = Object.create(opts2);
74199
74305
  opts2.headers = headers;
74200
- var fullPath = !opts2.root ? resolve6(path44) : path44;
74306
+ var fullPath = !opts2.root ? resolve6(path45) : path45;
74201
74307
  return this.sendFile(fullPath, opts2, done);
74202
74308
  };
74203
74309
  res.contentType = res.type = function contentType(type) {
@@ -74480,11 +74586,11 @@ var require_serve_static = __commonJS({
74480
74586
  }
74481
74587
  var forwardError = !fallthrough;
74482
74588
  var originalUrl = parseUrl.original(req);
74483
- var path43 = parseUrl(req).pathname;
74484
- if (path43 === "/" && originalUrl.pathname.substr(-1) !== "/") {
74485
- path43 = "";
74589
+ var path44 = parseUrl(req).pathname;
74590
+ if (path44 === "/" && originalUrl.pathname.substr(-1) !== "/") {
74591
+ path44 = "";
74486
74592
  }
74487
- var stream2 = send(req, path43, opts2);
74593
+ var stream2 = send(req, path44, opts2);
74488
74594
  stream2.on("directory", onDirectory);
74489
74595
  if (setHeaders) {
74490
74596
  stream2.on("headers", setHeaders);
@@ -75437,7 +75543,7 @@ var require_api = __commonJS({
75437
75543
  })();
75438
75544
  Object.defineProperty(exports, "__esModule", { value: true });
75439
75545
  exports.createApiRouter = createApiRouter;
75440
- var path43 = __importStar(__require("path"));
75546
+ var path44 = __importStar(__require("path"));
75441
75547
  var os3 = __importStar(__require("os"));
75442
75548
  var child_process_1 = __require("child_process");
75443
75549
  var express_1 = require_express2();
@@ -75455,11 +75561,11 @@ var require_api = __commonJS({
75455
75561
  return deps2.runner.run(cmd, args, {
75456
75562
  ...opts2,
75457
75563
  cwd: opts2?.cwd ?? deps2.repoRoot,
75458
- env: { SOPS_CONFIG: path43.join(deps2.repoRoot, ".sops.yaml"), ...opts2?.env }
75564
+ env: { SOPS_CONFIG: path44.join(deps2.repoRoot, ".sops.yaml"), ...opts2?.env }
75459
75565
  });
75460
75566
  }
75461
- const fifoDir = (0, child_process_1.execFileSync)("mktemp", ["-d", path43.join(os3.tmpdir(), "clef-fifo-XXXXXX")]).toString().trim();
75462
- const fifoPath = path43.join(fifoDir, "input");
75567
+ const fifoDir = (0, child_process_1.execFileSync)("mktemp", ["-d", path44.join(os3.tmpdir(), "clef-fifo-XXXXXX")]).toString().trim();
75568
+ const fifoPath = path44.join(fifoDir, "input");
75463
75569
  (0, child_process_1.execFileSync)("mkfifo", [fifoPath]);
75464
75570
  const writer = (0, child_process_1.spawn)("dd", [`of=${fifoPath}`, "status=none"], {
75465
75571
  stdio: ["pipe", "ignore", "ignore"]
@@ -75472,7 +75578,7 @@ var require_api = __commonJS({
75472
75578
  return deps2.runner.run(cmd, patchedArgs, {
75473
75579
  ...restOpts,
75474
75580
  cwd: restOpts?.cwd ?? deps2.repoRoot,
75475
- env: { SOPS_CONFIG: path43.join(deps2.repoRoot, ".sops.yaml"), ...restOpts?.env }
75581
+ env: { SOPS_CONFIG: path44.join(deps2.repoRoot, ".sops.yaml"), ...restOpts?.env }
75476
75582
  }).finally(() => {
75477
75583
  try {
75478
75584
  writer.kill();
@@ -75618,7 +75724,7 @@ var require_api = __commonJS({
75618
75724
  const nsDef = manifest.namespaces.find((n) => n.name === ns);
75619
75725
  if (nsDef?.schema) {
75620
75726
  try {
75621
- const schema = schemaValidator.loadSchema(path43.join(deps2.repoRoot, nsDef.schema));
75727
+ const schema = schemaValidator.loadSchema(path44.join(deps2.repoRoot, nsDef.schema));
75622
75728
  const result = schemaValidator.validate({ [key]: String(value) }, schema);
75623
75729
  const violations = [...result.errors, ...result.warnings];
75624
75730
  if (violations.length > 0) {
@@ -75882,8 +75988,8 @@ var require_api = __commonJS({
75882
75988
  res.status(400).json({ error: "Request body must include a 'file' string.", code: "BAD_REQUEST" });
75883
75989
  return;
75884
75990
  }
75885
- const resolved = path43.resolve(deps2.repoRoot, file);
75886
- if (!resolved.startsWith(deps2.repoRoot + path43.sep) && resolved !== deps2.repoRoot) {
75991
+ const resolved = path44.resolve(deps2.repoRoot, file);
75992
+ if (!resolved.startsWith(deps2.repoRoot + path44.sep) && resolved !== deps2.repoRoot) {
75887
75993
  res.status(400).json({
75888
75994
  error: "File path must be within the repository.",
75889
75995
  code: "BAD_REQUEST"
@@ -76033,6 +76139,42 @@ var require_api = __commonJS({
76033
76139
  res.status(500).json({ error: message, code: "RECIPIENTS_REMOVE_ERROR" });
76034
76140
  }
76035
76141
  });
76142
+ router.get("/service-identities", (_req, res) => {
76143
+ try {
76144
+ setNoCacheHeaders(res);
76145
+ const manifest = loadManifest();
76146
+ const identities = manifest.service_identities ?? [];
76147
+ const result = identities.map((si) => {
76148
+ const environments = {};
76149
+ for (const [envName, envConfig] of Object.entries(si.environments)) {
76150
+ const env = manifest.environments.find((e) => e.name === envName);
76151
+ if (envConfig.kms) {
76152
+ environments[envName] = {
76153
+ type: "kms",
76154
+ kms: envConfig.kms,
76155
+ protected: env?.protected ?? false
76156
+ };
76157
+ } else {
76158
+ environments[envName] = {
76159
+ type: "age",
76160
+ publicKey: envConfig.recipient,
76161
+ protected: env?.protected ?? false
76162
+ };
76163
+ }
76164
+ }
76165
+ return {
76166
+ name: si.name,
76167
+ description: si.description,
76168
+ namespaces: si.namespaces,
76169
+ environments
76170
+ };
76171
+ });
76172
+ res.json({ identities: result });
76173
+ } catch (err) {
76174
+ const message = err instanceof Error ? err.message : "Failed to load service identities";
76175
+ res.status(500).json({ error: message, code: "SERVICE_IDENTITY_ERROR" });
76176
+ }
76177
+ });
76036
76178
  function dispose() {
76037
76179
  lastScanResult = null;
76038
76180
  lastScanAt = null;
@@ -76089,7 +76231,7 @@ var require_server = __commonJS({
76089
76231
  };
76090
76232
  Object.defineProperty(exports, "__esModule", { value: true });
76091
76233
  exports.startServer = startServer;
76092
- var path43 = __importStar(__require("path"));
76234
+ var path44 = __importStar(__require("path"));
76093
76235
  var path_1 = __require("path");
76094
76236
  var crypto_1 = __require("crypto");
76095
76237
  var express_1 = __importDefault(require_express2());
@@ -76185,10 +76327,10 @@ var require_server = __commonJS({
76185
76327
  mountSeaStaticRoutes(app, sea, staticLimiter);
76186
76328
  }
76187
76329
  if (!isSeaBinary) {
76188
- const resolvedClientDir = clientDir ?? path43.resolve(__dirname, "../client");
76330
+ const resolvedClientDir = clientDir ?? path44.resolve(__dirname, "../client");
76189
76331
  app.use(staticLimiter, express_1.default.static(resolvedClientDir));
76190
76332
  app.get("/{*splat}", staticLimiter, (_req, res) => {
76191
- res.sendFile(path43.join(resolvedClientDir, "index.html"));
76333
+ res.sendFile(path44.join(resolvedClientDir, "index.html"));
76192
76334
  });
76193
76335
  }
76194
76336
  const url = `http://127.0.0.1:${port}`;
@@ -76330,32 +76472,32 @@ var require_disk_cache = __commonJS({
76330
76472
  })();
76331
76473
  Object.defineProperty(exports, "__esModule", { value: true });
76332
76474
  exports.DiskCache = void 0;
76333
- var fs26 = __importStar(__require("fs"));
76334
- var path43 = __importStar(__require("path"));
76475
+ var fs27 = __importStar(__require("fs"));
76476
+ var path44 = __importStar(__require("path"));
76335
76477
  var DiskCache = class {
76336
76478
  artifactPath;
76337
76479
  metaPath;
76338
76480
  constructor(cachePath, identity, environment) {
76339
- const dir = path43.join(cachePath, identity);
76340
- this.artifactPath = path43.join(dir, `${environment}.age.json`);
76341
- this.metaPath = path43.join(dir, `${environment}.meta`);
76481
+ const dir = path44.join(cachePath, identity);
76482
+ this.artifactPath = path44.join(dir, `${environment}.age.json`);
76483
+ this.metaPath = path44.join(dir, `${environment}.meta`);
76342
76484
  }
76343
76485
  /** Write an artifact and optional metadata to disk (atomic via tmp+rename). */
76344
76486
  write(raw, sha) {
76345
- const dir = path43.dirname(this.artifactPath);
76346
- fs26.mkdirSync(dir, { recursive: true });
76487
+ const dir = path44.dirname(this.artifactPath);
76488
+ fs27.mkdirSync(dir, { recursive: true });
76347
76489
  const tmpArtifact = `${this.artifactPath}.tmp.${process.pid}`;
76348
- fs26.writeFileSync(tmpArtifact, raw, "utf-8");
76349
- fs26.renameSync(tmpArtifact, this.artifactPath);
76490
+ fs27.writeFileSync(tmpArtifact, raw, "utf-8");
76491
+ fs27.renameSync(tmpArtifact, this.artifactPath);
76350
76492
  const meta = { sha, fetchedAt: (/* @__PURE__ */ new Date()).toISOString() };
76351
76493
  const tmpMeta = `${this.metaPath}.tmp.${process.pid}`;
76352
- fs26.writeFileSync(tmpMeta, JSON.stringify(meta), "utf-8");
76353
- fs26.renameSync(tmpMeta, this.metaPath);
76494
+ fs27.writeFileSync(tmpMeta, JSON.stringify(meta), "utf-8");
76495
+ fs27.renameSync(tmpMeta, this.metaPath);
76354
76496
  }
76355
76497
  /** Read the cached artifact. Returns null if no cache file exists. */
76356
76498
  read() {
76357
76499
  try {
76358
- return fs26.readFileSync(this.artifactPath, "utf-8");
76500
+ return fs27.readFileSync(this.artifactPath, "utf-8");
76359
76501
  } catch {
76360
76502
  return null;
76361
76503
  }
@@ -76363,7 +76505,7 @@ var require_disk_cache = __commonJS({
76363
76505
  /** Get the SHA from the cached metadata, if available. */
76364
76506
  getCachedSha() {
76365
76507
  try {
76366
- const raw = fs26.readFileSync(this.metaPath, "utf-8");
76508
+ const raw = fs27.readFileSync(this.metaPath, "utf-8");
76367
76509
  const meta = JSON.parse(raw);
76368
76510
  return meta.sha;
76369
76511
  } catch {
@@ -76373,7 +76515,7 @@ var require_disk_cache = __commonJS({
76373
76515
  /** Get the fetchedAt timestamp from metadata, if available. */
76374
76516
  getFetchedAt() {
76375
76517
  try {
76376
- const raw = fs26.readFileSync(this.metaPath, "utf-8");
76518
+ const raw = fs27.readFileSync(this.metaPath, "utf-8");
76377
76519
  const meta = JSON.parse(raw);
76378
76520
  return meta.fetchedAt;
76379
76521
  } catch {
@@ -76383,11 +76525,11 @@ var require_disk_cache = __commonJS({
76383
76525
  /** Remove cached artifact and metadata files. */
76384
76526
  purge() {
76385
76527
  try {
76386
- fs26.unlinkSync(this.artifactPath);
76528
+ fs27.unlinkSync(this.artifactPath);
76387
76529
  } catch {
76388
76530
  }
76389
76531
  try {
76390
- fs26.unlinkSync(this.metaPath);
76532
+ fs27.unlinkSync(this.metaPath);
76391
76533
  } catch {
76392
76534
  }
76393
76535
  }
@@ -76439,7 +76581,7 @@ var require_decrypt = __commonJS({
76439
76581
  })();
76440
76582
  Object.defineProperty(exports, "__esModule", { value: true });
76441
76583
  exports.AgeDecryptor = void 0;
76442
- var fs26 = __importStar(__require("fs"));
76584
+ var fs27 = __importStar(__require("fs"));
76443
76585
  var AgeDecryptor = class {
76444
76586
  /**
76445
76587
  * Decrypt an age-encrypted PEM-armored ciphertext string.
@@ -76452,7 +76594,7 @@ var require_decrypt = __commonJS({
76452
76594
  const { Decrypter: Decrypter2 } = await Promise.resolve(`${"age-encryption"}`).then((s) => __importStar(__require(s)));
76453
76595
  const d = new Decrypter2();
76454
76596
  d.addIdentity(privateKey);
76455
- return d.decrypt(ciphertext, "text");
76597
+ return d.decrypt(Buffer.from(ciphertext, "base64"), "text");
76456
76598
  }
76457
76599
  /**
76458
76600
  * Resolve the age private key from either an inline value or a file path.
@@ -76465,7 +76607,7 @@ var require_decrypt = __commonJS({
76465
76607
  if (ageKey)
76466
76608
  return ageKey.trim();
76467
76609
  if (ageKeyFile) {
76468
- const content = fs26.readFileSync(ageKeyFile, "utf-8").trim();
76610
+ const content = fs27.readFileSync(ageKeyFile, "utf-8").trim();
76469
76611
  const lines = content.split("\n").filter((l) => l.startsWith("AGE-SECRET-KEY-"));
76470
76612
  if (lines.length === 0) {
76471
76613
  throw new Error(`No age secret key found in file: ${ageKeyFile}`);
@@ -77275,8 +77417,8 @@ var require_github = __commonJS({
77275
77417
  this.ref = config.ref;
77276
77418
  this.apiUrl = config.apiUrl ?? "https://api.github.com";
77277
77419
  }
77278
- async fetchFile(path43) {
77279
- const url = new URL(`/repos/${this.repo}/contents/${path43}`, this.apiUrl);
77420
+ async fetchFile(path44) {
77421
+ const url = new URL(`/repos/${this.repo}/contents/${path44}`, this.apiUrl);
77280
77422
  if (this.ref)
77281
77423
  url.searchParams.set("ref", this.ref);
77282
77424
  const res = await fetch(url.toString(), {
@@ -77286,7 +77428,7 @@ var require_github = __commonJS({
77286
77428
  }
77287
77429
  });
77288
77430
  if (!res.ok) {
77289
- throw new Error(`GitHub API error: ${res.status} fetching ${path43} from ${this.repo}`);
77431
+ throw new Error(`GitHub API error: ${res.status} fetching ${path44} from ${this.repo}`);
77290
77432
  }
77291
77433
  const data = await res.json();
77292
77434
  const content = Buffer.from(data.content, "base64").toString("utf-8");
@@ -77314,9 +77456,9 @@ var require_gitlab = __commonJS({
77314
77456
  this.ref = config.ref;
77315
77457
  this.apiUrl = config.apiUrl ?? "https://gitlab.com";
77316
77458
  }
77317
- async fetchFile(path43) {
77459
+ async fetchFile(path44) {
77318
77460
  const encodedRepo = encodeURIComponent(this.repo);
77319
- const encodedPath = encodeURIComponent(path43);
77461
+ const encodedPath = encodeURIComponent(path44);
77320
77462
  const url = new URL(`/api/v4/projects/${encodedRepo}/repository/files/${encodedPath}`, this.apiUrl);
77321
77463
  if (this.ref)
77322
77464
  url.searchParams.set("ref", this.ref);
@@ -77326,7 +77468,7 @@ var require_gitlab = __commonJS({
77326
77468
  }
77327
77469
  });
77328
77470
  if (!res.ok) {
77329
- throw new Error(`GitLab API error: ${res.status} fetching ${path43} from ${this.repo}`);
77471
+ throw new Error(`GitLab API error: ${res.status} fetching ${path44} from ${this.repo}`);
77330
77472
  }
77331
77473
  const data = await res.json();
77332
77474
  const content = Buffer.from(data.content, "base64").toString("utf-8");
@@ -77354,8 +77496,8 @@ var require_bitbucket = __commonJS({
77354
77496
  this.ref = config.ref ?? "main";
77355
77497
  this.apiUrl = config.apiUrl ?? "https://api.bitbucket.org";
77356
77498
  }
77357
- async fetchFile(path43) {
77358
- const baseUrl = `${this.apiUrl}/2.0/repositories/${this.repo}/src/${this.ref}/${path43}`;
77499
+ async fetchFile(path44) {
77500
+ const baseUrl = `${this.apiUrl}/2.0/repositories/${this.repo}/src/${this.ref}/${path44}`;
77359
77501
  const metaRes = await fetch(baseUrl, {
77360
77502
  headers: {
77361
77503
  Authorization: `Bearer ${this.token}`,
@@ -77363,7 +77505,7 @@ var require_bitbucket = __commonJS({
77363
77505
  }
77364
77506
  });
77365
77507
  if (!metaRes.ok) {
77366
- throw new Error(`Bitbucket API error: ${metaRes.status} fetching ${path43} from ${this.repo}`);
77508
+ throw new Error(`Bitbucket API error: ${metaRes.status} fetching ${path44} from ${this.repo}`);
77367
77509
  }
77368
77510
  const meta = await metaRes.json();
77369
77511
  const rawRes = await fetch(baseUrl, {
@@ -77372,7 +77514,7 @@ var require_bitbucket = __commonJS({
77372
77514
  }
77373
77515
  });
77374
77516
  if (!rawRes.ok) {
77375
- throw new Error(`Bitbucket API error: ${rawRes.status} fetching raw content of ${path43} from ${this.repo}`);
77517
+ throw new Error(`Bitbucket API error: ${rawRes.status} fetching raw content of ${path44} from ${this.repo}`);
77376
77518
  }
77377
77519
  const content = await rawRes.text();
77378
77520
  return { content, sha: meta.commit.hash };
@@ -77490,14 +77632,14 @@ var require_file = __commonJS({
77490
77632
  })();
77491
77633
  Object.defineProperty(exports, "__esModule", { value: true });
77492
77634
  exports.FileArtifactSource = void 0;
77493
- var fs26 = __importStar(__require("fs"));
77635
+ var fs27 = __importStar(__require("fs"));
77494
77636
  var FileArtifactSource = class {
77495
77637
  path;
77496
77638
  constructor(filePath) {
77497
77639
  this.path = filePath;
77498
77640
  }
77499
77641
  async fetch() {
77500
- const raw = fs26.readFileSync(this.path, "utf-8");
77642
+ const raw = fs27.readFileSync(this.path, "utf-8");
77501
77643
  return { raw };
77502
77644
  }
77503
77645
  describe() {
@@ -77764,7 +77906,7 @@ var NodeSubprocessRunner = class {
77764
77906
  };
77765
77907
 
77766
77908
  // src/commands/init.ts
77767
- var YAML11 = __toESM(require_dist());
77909
+ var YAML12 = __toESM(require_dist());
77768
77910
  init_src();
77769
77911
  import * as fs17 from "fs";
77770
77912
  import * as path19 from "path";
@@ -77911,6 +78053,7 @@ ${label2}
77911
78053
  return new Promise((resolve6) => {
77912
78054
  rl.question(color(import_picocolors.default.yellow, `${prompt} [y/N] `), (answer) => {
77913
78055
  rl.close();
78056
+ process.stdin.pause();
77914
78057
  resolve6(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
77915
78058
  });
77916
78059
  });
@@ -77950,6 +78093,7 @@ ${label2}
77950
78093
  process.stdin.setRawMode(false);
77951
78094
  }
77952
78095
  process.stdin.removeListener("data", onData);
78096
+ process.stdin.pause();
77953
78097
  process.stderr.write("\n");
77954
78098
  resolve6(value);
77955
78099
  } else if (char === "") {
@@ -78082,25 +78226,57 @@ async function getDarwin(runner2, account) {
78082
78226
  if (result.exitCode === 0) {
78083
78227
  const key = result.stdout.trim();
78084
78228
  if (key.startsWith("AGE-SECRET-KEY-")) return key;
78229
+ if (key) {
78230
+ formatter.warn(
78231
+ "OS keychain entry exists but contains invalid key data\n (expected AGE-SECRET-KEY-... format). The entry may be corrupted.\n Delete the 'clef' entry in Keychain Access and re-run clef init."
78232
+ );
78233
+ }
78085
78234
  }
78086
78235
  return null;
78087
78236
  } catch {
78088
78237
  return null;
78089
78238
  }
78090
78239
  }
78240
+ async function readDarwinRaw(runner2, account) {
78241
+ try {
78242
+ const result = await runner2.run("security", [
78243
+ "find-generic-password",
78244
+ "-a",
78245
+ account,
78246
+ "-s",
78247
+ SERVICE,
78248
+ "-w"
78249
+ ]);
78250
+ return result.exitCode === 0 ? result.stdout.trim() : "";
78251
+ } catch {
78252
+ return "";
78253
+ }
78254
+ }
78091
78255
  async function setDarwin(runner2, privateKey, account) {
78092
78256
  await runner2.run("security", ["delete-generic-password", "-a", account, "-s", SERVICE]).catch(() => {
78093
78257
  });
78094
- const result = await runner2.run("security", [
78095
- "add-generic-password",
78096
- "-a",
78097
- account,
78098
- "-s",
78099
- SERVICE,
78100
- "-w",
78101
- privateKey
78102
- ]);
78103
- return result.exitCode === 0;
78258
+ try {
78259
+ const result = await runner2.run("security", [
78260
+ "add-generic-password",
78261
+ "-a",
78262
+ account,
78263
+ "-s",
78264
+ SERVICE,
78265
+ "-w",
78266
+ privateKey
78267
+ ]);
78268
+ if (result.exitCode !== 0) return false;
78269
+ const stored = await readDarwinRaw(runner2, account);
78270
+ if (stored === privateKey) return true;
78271
+ formatter.warn(
78272
+ "Keychain write succeeded but read-back verification failed \u2014\n the stored value may be truncated or corrupted.\n Falling back to file-based key storage."
78273
+ );
78274
+ await runner2.run("security", ["delete-generic-password", "-a", account, "-s", SERVICE]).catch(() => {
78275
+ });
78276
+ return false;
78277
+ } catch {
78278
+ return false;
78279
+ }
78104
78280
  }
78105
78281
  async function getLinux(runner2, account) {
78106
78282
  try {
@@ -78114,6 +78290,11 @@ async function getLinux(runner2, account) {
78114
78290
  if (result.exitCode === 0) {
78115
78291
  const key = result.stdout.trim();
78116
78292
  if (key.startsWith("AGE-SECRET-KEY-")) return key;
78293
+ if (key) {
78294
+ formatter.warn(
78295
+ "OS keychain entry exists but contains invalid key data\n (expected AGE-SECRET-KEY-... format). The entry may be corrupted."
78296
+ );
78297
+ }
78117
78298
  }
78118
78299
  return null;
78119
78300
  } catch {
@@ -78157,6 +78338,11 @@ ${CRED_HELPER_CS}
78157
78338
  if (result.exitCode === 0) {
78158
78339
  const key = result.stdout.trim();
78159
78340
  if (key.startsWith("AGE-SECRET-KEY-")) return key;
78341
+ if (key) {
78342
+ formatter.warn(
78343
+ "Windows Credential Manager entry exists but contains invalid key data\n (expected AGE-SECRET-KEY-... format). The entry may be corrupted."
78344
+ );
78345
+ }
78160
78346
  }
78161
78347
  return null;
78162
78348
  } catch {
@@ -78423,6 +78609,9 @@ async function handleSecondDevOnboarding(repoRoot, clefConfigPath, deps2, option
78423
78609
  formatter.success("Stored age key in OS keychain");
78424
78610
  config = { age_key_storage: "keychain", age_keychain_label: label2 };
78425
78611
  } else {
78612
+ formatter.warn(
78613
+ "OS keychain is not available on this system.\n The private key will be written to the filesystem instead.\n See https://docs.clef.sh/guide/key-storage for security implications."
78614
+ );
78426
78615
  let keyPath;
78427
78616
  if (options.nonInteractive || !process.stdin.isTTY) {
78428
78617
  keyPath = process.env.CLEF_AGE_KEY_FILE || defaultAgeKeyPath(label2);
@@ -78449,7 +78638,7 @@ async function handleSecondDevOnboarding(repoRoot, clefConfigPath, deps2, option
78449
78638
  if (!fs17.existsSync(clefDir)) {
78450
78639
  fs17.mkdirSync(clefDir, { recursive: true });
78451
78640
  }
78452
- fs17.writeFileSync(clefConfigPath, YAML11.stringify(config), "utf-8");
78641
+ fs17.writeFileSync(clefConfigPath, YAML12.stringify(config), "utf-8");
78453
78642
  formatter.success("Created .clef/config.yaml");
78454
78643
  const gitignorePath = path19.join(clefDir, ".gitignore");
78455
78644
  if (!fs17.existsSync(gitignorePath)) {
@@ -78506,15 +78695,14 @@ async function handleFullSetup(repoRoot, manifestPath, clefConfigPath, deps2, op
78506
78695
  };
78507
78696
  const initParser = new ManifestParser();
78508
78697
  initParser.validate(manifest);
78509
- fs17.writeFileSync(manifestPath, YAML11.stringify(manifest), "utf-8");
78510
- formatter.success("Created clef.yaml");
78511
78698
  let ageKeyFile;
78512
78699
  let ageKey;
78700
+ let publicKey;
78513
78701
  if (backend === "age") {
78514
78702
  const label2 = generateKeyLabel();
78515
78703
  const identity = await generateAgeIdentity();
78516
78704
  const privateKey = identity.privateKey;
78517
- const publicKey = identity.publicKey;
78705
+ publicKey = identity.publicKey;
78518
78706
  const storedInKeychain = await setKeychainKey(deps2.runner, privateKey, label2);
78519
78707
  if (storedInKeychain) {
78520
78708
  formatter.success("Stored age key in OS keychain");
@@ -78558,7 +78746,7 @@ async function handleFullSetup(repoRoot, manifestPath, clefConfigPath, deps2, op
78558
78746
  fs17.mkdirSync(clefDir, { recursive: true });
78559
78747
  }
78560
78748
  const config = ageKeyFile ? { age_key_file: ageKeyFile, age_key_storage: "file", age_keychain_label: label2 } : { age_key_storage: "keychain", age_keychain_label: label2 };
78561
- fs17.writeFileSync(clefConfigPath, YAML11.stringify(config), "utf-8");
78749
+ fs17.writeFileSync(clefConfigPath, YAML12.stringify(config), "utf-8");
78562
78750
  formatter.success("Created .clef/config.yaml");
78563
78751
  const gitignorePath = path19.join(clefDir, ".gitignore");
78564
78752
  if (!fs17.existsSync(gitignorePath)) {
@@ -78566,14 +78754,18 @@ async function handleFullSetup(repoRoot, manifestPath, clefConfigPath, deps2, op
78566
78754
  formatter.success("Created .clef/.gitignore");
78567
78755
  }
78568
78756
  formatter.success(`Key label: ${label2}`);
78757
+ }
78758
+ const manifestDoc = YAML12.parse(YAML12.stringify(manifest));
78759
+ if (backend === "age" && publicKey) {
78760
+ const sopsDoc = manifestDoc.sops;
78761
+ sopsDoc.age = { recipients: [publicKey] };
78762
+ }
78763
+ fs17.writeFileSync(manifestPath, YAML12.stringify(manifestDoc), "utf-8");
78764
+ formatter.success("Created clef.yaml");
78765
+ {
78569
78766
  const sopsYamlPath = path19.join(repoRoot, ".sops.yaml");
78570
78767
  const sopsConfig = buildSopsYaml(manifest, repoRoot, publicKey);
78571
- fs17.writeFileSync(sopsYamlPath, YAML11.stringify(sopsConfig), "utf-8");
78572
- formatter.success("Created .sops.yaml");
78573
- } else {
78574
- const sopsYamlPath = path19.join(repoRoot, ".sops.yaml");
78575
- const sopsConfig = buildSopsYaml(manifest, repoRoot, void 0);
78576
- fs17.writeFileSync(sopsYamlPath, YAML11.stringify(sopsConfig), "utf-8");
78768
+ fs17.writeFileSync(sopsYamlPath, YAML12.stringify(sopsConfig), "utf-8");
78577
78769
  formatter.success("Created .sops.yaml");
78578
78770
  }
78579
78771
  const sopsClient = new SopsClient(deps2.runner, ageKeyFile, ageKey);
@@ -78663,7 +78855,7 @@ function scaffoldSopsConfig(repoRoot) {
78663
78855
  agePublicKey = resolveAgePublicKeyFromEnvOrFile(repoRoot);
78664
78856
  }
78665
78857
  const sopsConfig = buildSopsYaml(manifest, repoRoot, agePublicKey);
78666
- fs17.writeFileSync(sopsYamlPath, YAML11.stringify(sopsConfig), "utf-8");
78858
+ fs17.writeFileSync(sopsYamlPath, YAML12.stringify(sopsConfig), "utf-8");
78667
78859
  }
78668
78860
  function buildSopsYaml(manifest, _repoRoot, agePublicKey) {
78669
78861
  const creationRules = [];
@@ -78729,7 +78921,7 @@ function resolveAgePublicKeyFromEnvOrFile(repoRoot) {
78729
78921
  const clefConfigPath = path19.join(repoRoot, CLEF_DIR, CLEF_CONFIG_FILENAME);
78730
78922
  if (fs17.existsSync(clefConfigPath)) {
78731
78923
  try {
78732
- const config = YAML11.parse(fs17.readFileSync(clefConfigPath, "utf-8"));
78924
+ const config = YAML12.parse(fs17.readFileSync(clefConfigPath, "utf-8"));
78733
78925
  if (config?.age_key_file) {
78734
78926
  const pubKey = extractAgePublicKey(config.age_key_file);
78735
78927
  if (pubKey) return pubKey;
@@ -78798,6 +78990,7 @@ function promptWithDefault(message, defaultValue) {
78798
78990
  return new Promise((resolve6) => {
78799
78991
  rl.question(prompt, (answer) => {
78800
78992
  rl.close();
78993
+ process.stdin.pause();
78801
78994
  resolve6(answer.trim() || defaultValue);
78802
78995
  });
78803
78996
  });
@@ -78808,7 +79001,7 @@ init_src();
78808
79001
  import * as path21 from "path";
78809
79002
 
78810
79003
  // src/age-credential.ts
78811
- var YAML12 = __toESM(require_dist());
79004
+ var YAML13 = __toESM(require_dist());
78812
79005
  init_src();
78813
79006
  import * as fs18 from "fs";
78814
79007
  import * as path20 from "path";
@@ -78820,6 +79013,11 @@ async function resolveAgeCredential(repoRoot, runner2) {
78820
79013
  if (label2) {
78821
79014
  const keychainKey = await getKeychainKey(runner2, label2);
78822
79015
  if (keychainKey) return { source: "keychain", privateKey: keychainKey };
79016
+ if (config?.age_key_storage !== "file") {
79017
+ formatter.warn(
79018
+ "OS keychain is configured but the age key could not be retrieved.\n Falling back to environment variables / key file.\n Run clef doctor for diagnostics."
79019
+ );
79020
+ }
78823
79021
  }
78824
79022
  if (process.env.CLEF_AGE_KEY) return { source: "env-key" };
78825
79023
  if (process.env.CLEF_AGE_KEY_FILE) return { source: "env-file" };
@@ -78873,7 +79071,10 @@ async function resolveAgePrivateKey(repoRoot, runner2) {
78873
79071
  const content = fs18.readFileSync(filePath, "utf-8");
78874
79072
  const match = content.match(AGE_SECRET_KEY_RE);
78875
79073
  return match ? match[1] : null;
78876
- } catch {
79074
+ } catch (err) {
79075
+ formatter.warn(
79076
+ `Could not read age key file (CLEF_AGE_KEY_FILE=${filePath}): ${err instanceof Error ? err.message : String(err)}`
79077
+ );
78877
79078
  return null;
78878
79079
  }
78879
79080
  }
@@ -78882,7 +79083,10 @@ async function resolveAgePrivateKey(repoRoot, runner2) {
78882
79083
  const content = fs18.readFileSync(credential.path, "utf-8");
78883
79084
  const match = content.match(AGE_SECRET_KEY_RE);
78884
79085
  return match ? match[1] : null;
78885
- } catch {
79086
+ } catch (err) {
79087
+ formatter.warn(
79088
+ `Could not read age key file (${credential.path}): ${err instanceof Error ? err.message : String(err)}`
79089
+ );
78886
79090
  return null;
78887
79091
  }
78888
79092
  }
@@ -78892,17 +79096,53 @@ function readLocalConfig(repoRoot) {
78892
79096
  const clefConfigPath = path20.join(repoRoot, CLEF_DIR2, CLEF_CONFIG_FILENAME2);
78893
79097
  try {
78894
79098
  if (!fs18.existsSync(clefConfigPath)) return null;
78895
- return YAML12.parse(fs18.readFileSync(clefConfigPath, "utf-8"));
78896
- } catch {
79099
+ return YAML13.parse(fs18.readFileSync(clefConfigPath, "utf-8"));
79100
+ } catch (err) {
79101
+ formatter.warn(
79102
+ `Failed to parse ${clefConfigPath}: ${err instanceof Error ? err.message : String(err)}
79103
+ Credential resolution will proceed without local config.`
79104
+ );
78897
79105
  return null;
78898
79106
  }
78899
79107
  }
78900
79108
 
79109
+ // src/clipboard.ts
79110
+ import { execFileSync } from "child_process";
79111
+ function copyToClipboard(text) {
79112
+ try {
79113
+ switch (process.platform) {
79114
+ case "darwin":
79115
+ execFileSync("pbcopy", { input: text, stdio: ["pipe", "ignore", "ignore"] });
79116
+ return true;
79117
+ case "win32":
79118
+ execFileSync("clip", { input: text, stdio: ["pipe", "ignore", "ignore"], shell: true });
79119
+ return true;
79120
+ default: {
79121
+ for (const cmd of ["xclip", "xsel"]) {
79122
+ try {
79123
+ const args = cmd === "xclip" ? ["-selection", "clipboard"] : ["--clipboard", "--input"];
79124
+ execFileSync(cmd, args, { input: text, stdio: ["pipe", "ignore", "ignore"] });
79125
+ return true;
79126
+ } catch {
79127
+ continue;
79128
+ }
79129
+ }
79130
+ return false;
79131
+ }
79132
+ }
79133
+ } catch {
79134
+ return false;
79135
+ }
79136
+ }
79137
+ function maskedPlaceholder() {
79138
+ return "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
79139
+ }
79140
+
78901
79141
  // src/commands/get.ts
78902
79142
  function registerGetCommand(program3, deps2) {
78903
79143
  program3.command("get <target> <key>").description(
78904
- "Get a single decrypted value.\n\n target: namespace/environment (e.g. payments/production)\n key: the key name to retrieve\n\nExit codes:\n 0 Value found and printed\n 1 Key not found or decryption error"
78905
- ).action(async (target, key) => {
79144
+ "Get a single decrypted value.\n\n target: namespace/environment (e.g. payments/production)\n key: the key name to retrieve\n\nBy default, the value is copied to clipboard and obfuscated on screen.\nUse --raw to print the plaintext value to stdout.\n\nExit codes:\n 0 Value found\n 1 Key not found or decryption error"
79145
+ ).option("--raw", "Print the plaintext value to stdout (for piping/scripting)").action(async (target, key, opts2) => {
78906
79146
  try {
78907
79147
  const [namespace, environment] = parseTarget(target);
78908
79148
  const repoRoot = program3.opts().dir || process.cwd();
@@ -78921,7 +79161,17 @@ function registerGetCommand(program3, deps2) {
78921
79161
  process.exit(1);
78922
79162
  return;
78923
79163
  }
78924
- formatter.keyValue(key, decrypted.values[key]);
79164
+ const val = decrypted.values[key];
79165
+ if (opts2.raw) {
79166
+ formatter.raw(val);
79167
+ } else {
79168
+ const copied = copyToClipboard(val);
79169
+ if (copied) {
79170
+ formatter.print(` ${key}: ${maskedPlaceholder()} (copied to clipboard)`);
79171
+ } else {
79172
+ formatter.keyValue(key, val);
79173
+ }
79174
+ }
78925
79175
  } catch (err) {
78926
79176
  if (err instanceof SopsMissingError || err instanceof SopsVersionError) {
78927
79177
  formatter.formatDependencyError(err);
@@ -79633,7 +79883,7 @@ async function fetchCheckpoint(config) {
79633
79883
  }
79634
79884
 
79635
79885
  // package.json
79636
- var version = "0.1.6-beta.32";
79886
+ var version = "0.1.7-beta.45";
79637
79887
  var package_default = {
79638
79888
  name: "@clef-sh/cli",
79639
79889
  version,
@@ -79707,6 +79957,10 @@ function registerLintCommand(program3, deps2) {
79707
79957
  const matrixManager = new MatrixManager();
79708
79958
  const schemaValidator = new SchemaValidator();
79709
79959
  const lintRunner = new LintRunner(matrixManager, schemaValidator, sopsClient);
79960
+ const cellCount = manifest.namespaces.length * manifest.environments.length;
79961
+ formatter.print(
79962
+ `${sym("working")} Linting ${cellCount} file(s) across ${manifest.namespaces.length} namespace(s)...`
79963
+ );
79710
79964
  let result;
79711
79965
  if (options.fix) {
79712
79966
  result = await lintRunner.fix(manifest, repoRoot);
@@ -80154,8 +80408,8 @@ init_src();
80154
80408
  import * as path31 from "path";
80155
80409
  function registerExportCommand(program3, deps2) {
80156
80410
  program3.command("export <target>").description(
80157
- "Print decrypted secrets as shell export statements to stdout.\n\n target: namespace/environment (e.g. payments/production)\n\nUsage:\n eval $(clef export payments/production --format env)\n\nExit codes:\n 0 Values printed successfully\n 1 Decryption error or invalid arguments"
80158
- ).option("--format <format>", "Output format (only 'env' is supported)", "env").option("--no-export", "Omit the 'export' keyword \u2014 output bare KEY=value pairs").action(async (target, options) => {
80411
+ "Export decrypted secrets as shell export statements.\n\n target: namespace/environment (e.g. payments/production)\n\nBy default, exports are copied to clipboard. Use --raw to print to stdout.\n\nUsage:\n clef export payments/production (copies to clipboard)\n eval $(clef export payments/production --raw) (injects into shell)\n\nExit codes:\n 0 Values exported successfully\n 1 Decryption error or invalid arguments"
80412
+ ).option("--format <format>", "Output format (only 'env' is supported)", "env").option("--no-export", "Omit the 'export' keyword \u2014 output bare KEY=value pairs").option("--raw", "Print to stdout instead of clipboard (for eval/piping)").action(async (target, options) => {
80159
80413
  try {
80160
80414
  if (options.format !== "env") {
80161
80415
  if (options.format === "dotenv" || options.format === "json" || options.format === "yaml") {
@@ -80188,12 +80442,28 @@ Usage: clef export payments/production --format env`
80188
80442
  const decrypted = await sopsClient.decrypt(filePath);
80189
80443
  const consumption = new ConsumptionClient();
80190
80444
  const output = consumption.formatExport(decrypted, "env", !options.export);
80191
- if (process.platform === "linux") {
80192
- formatter.warn(
80193
- "Exported values will be visible in /proc/<pid>/environ to processes with ptrace access. Use clef exec when possible."
80194
- );
80445
+ if (options.raw) {
80446
+ if (process.platform === "linux") {
80447
+ formatter.warn(
80448
+ "Exported values will be visible in /proc/<pid>/environ to processes with ptrace access. Use clef exec when possible."
80449
+ );
80450
+ }
80451
+ formatter.raw(output);
80452
+ } else {
80453
+ const keyCount = Object.keys(decrypted.values).length;
80454
+ const copied = copyToClipboard(output);
80455
+ if (copied) {
80456
+ formatter.success(`${keyCount} secret(s) copied to clipboard as env exports.`);
80457
+ formatter.hint("eval $(clef export " + target + " --raw) to inject into shell");
80458
+ } else {
80459
+ if (process.platform === "linux") {
80460
+ formatter.warn(
80461
+ "Exported values will be visible in /proc/<pid>/environ to processes with ptrace access. Use clef exec when possible."
80462
+ );
80463
+ }
80464
+ formatter.raw(output);
80465
+ }
80195
80466
  }
80196
- formatter.raw(output);
80197
80467
  } catch (err) {
80198
80468
  if (err instanceof SopsMissingError || err instanceof SopsVersionError) {
80199
80469
  formatter.formatDependencyError(err);
@@ -80215,7 +80485,7 @@ function parseTarget7(target) {
80215
80485
  }
80216
80486
 
80217
80487
  // src/commands/doctor.ts
80218
- var YAML13 = __toESM(require_dist());
80488
+ var YAML14 = __toESM(require_dist());
80219
80489
  init_src();
80220
80490
  import * as fs20 from "fs";
80221
80491
  import * as path32 from "path";
@@ -80466,7 +80736,7 @@ function countAgeRecipients(sopsYamlPath) {
80466
80736
  try {
80467
80737
  if (!fs20.existsSync(sopsYamlPath)) return 0;
80468
80738
  const content = fs20.readFileSync(sopsYamlPath, "utf-8");
80469
- const config = YAML13.parse(content);
80739
+ const config = YAML14.parse(content);
80470
80740
  if (!config?.creation_rules || !Array.isArray(config.creation_rules)) {
80471
80741
  return 0;
80472
80742
  }
@@ -80853,6 +81123,7 @@ function waitForEnter(message) {
80853
81123
  });
80854
81124
  rl.question(message, () => {
80855
81125
  rl.close();
81126
+ process.stdin.pause();
80856
81127
  resolve6();
80857
81128
  });
80858
81129
  });
@@ -81402,6 +81673,9 @@ function registerServiceCommand(program3, deps2) {
81402
81673
  `Invalid KMS provider '${provider}'. Must be one of: aws, gcp, azure.`
81403
81674
  );
81404
81675
  }
81676
+ if (kmsEnvConfigs[envName]) {
81677
+ throw new Error(`Duplicate --kms-env for environment '${envName}'.`);
81678
+ }
81405
81679
  kmsEnvConfigs[envName] = {
81406
81680
  provider,
81407
81681
  keyId
@@ -81440,13 +81714,24 @@ function registerServiceCommand(program3, deps2) {
81440
81714
  `
81441
81715
  );
81442
81716
  if (Object.keys(result.privateKeys).length > 0) {
81443
- formatter.warn(
81444
- "Private keys are shown ONCE. Store them securely (e.g. AWS Secrets Manager, Vault).\n"
81445
- );
81446
- for (const [envName, privateKey] of Object.entries(result.privateKeys)) {
81447
- formatter.print(` ${envName}:`);
81448
- formatter.print(` ${privateKey}
81717
+ const entries = Object.entries(result.privateKeys);
81718
+ const block = entries.map(([env, key]) => `${env}: ${key}`).join("\n");
81719
+ const copied = copyToClipboard(block);
81720
+ if (copied) {
81721
+ formatter.warn("Private keys copied to clipboard. Store them securely.\n");
81722
+ for (const [envName] of entries) {
81723
+ formatter.print(` ${envName}: ${maskedPlaceholder()}`);
81724
+ }
81725
+ formatter.print("");
81726
+ } else {
81727
+ formatter.warn(
81728
+ "Private keys are shown ONCE. Store them securely (e.g. AWS Secrets Manager, Vault).\n"
81729
+ );
81730
+ for (const [envName, privateKey] of entries) {
81731
+ formatter.print(` ${envName}:`);
81732
+ formatter.print(` ${privateKey}
81449
81733
  `);
81734
+ }
81450
81735
  }
81451
81736
  for (const k of Object.keys(result.privateKeys)) result.privateKeys[k] = "";
81452
81737
  }
@@ -81581,6 +81866,109 @@ Service Identity: ${identity.name}`);
81581
81866
  process.exit(1);
81582
81867
  }
81583
81868
  });
81869
+ serviceCmd.command("update <name>").description("Update an existing service identity's environment backends.").option(
81870
+ "--kms-env <mapping>",
81871
+ "Switch an environment to KMS envelope encryption: env=provider:keyId (repeatable)",
81872
+ (val, acc) => {
81873
+ acc.push(val);
81874
+ return acc;
81875
+ },
81876
+ []
81877
+ ).action(async (name, opts2) => {
81878
+ try {
81879
+ if (opts2.kmsEnv.length === 0) {
81880
+ formatter.error("Nothing to update. Provide --kms-env to change environment backends.");
81881
+ process.exit(1);
81882
+ return;
81883
+ }
81884
+ const repoRoot = program3.opts().dir || process.cwd();
81885
+ const parser = new ManifestParser();
81886
+ const manifest = parser.parse(path38.join(repoRoot, "clef.yaml"));
81887
+ const kmsEnvConfigs = {};
81888
+ for (const mapping of opts2.kmsEnv) {
81889
+ const eqIdx = mapping.indexOf("=");
81890
+ if (eqIdx === -1) {
81891
+ throw new Error(`Invalid --kms-env format: '${mapping}'. Expected: env=provider:keyId`);
81892
+ }
81893
+ const envName = mapping.slice(0, eqIdx);
81894
+ const rest = mapping.slice(eqIdx + 1);
81895
+ const colonIdx = rest.indexOf(":");
81896
+ if (colonIdx === -1) {
81897
+ throw new Error(`Invalid --kms-env format: '${mapping}'. Expected: env=provider:keyId`);
81898
+ }
81899
+ const provider = rest.slice(0, colonIdx);
81900
+ const keyId = rest.slice(colonIdx + 1);
81901
+ if (!["aws", "gcp", "azure"].includes(provider)) {
81902
+ throw new Error(`Invalid KMS provider '${provider}'. Must be one of: aws, gcp, azure.`);
81903
+ }
81904
+ if (kmsEnvConfigs[envName]) {
81905
+ throw new Error(`Duplicate --kms-env for environment '${envName}'.`);
81906
+ }
81907
+ kmsEnvConfigs[envName] = {
81908
+ provider,
81909
+ keyId
81910
+ };
81911
+ }
81912
+ const matrixManager = new MatrixManager();
81913
+ const sopsClient = await createSopsClient(repoRoot, deps2.runner);
81914
+ const manager = new ServiceIdentityManager(sopsClient, matrixManager);
81915
+ formatter.print(`${sym("working")} Updating service identity '${name}'...`);
81916
+ await manager.updateEnvironments(name, kmsEnvConfigs, manifest, repoRoot);
81917
+ formatter.success(`Service identity '${name}' updated.`);
81918
+ for (const [envName, kmsConfig] of Object.entries(kmsEnvConfigs)) {
81919
+ formatter.print(` ${envName}: switched to KMS envelope (${kmsConfig.provider})`);
81920
+ }
81921
+ formatter.hint(
81922
+ `git add clef.yaml && git commit -m "chore: update service identity '${name}'"`
81923
+ );
81924
+ } catch (err) {
81925
+ if (err instanceof SopsMissingError || err instanceof SopsVersionError) {
81926
+ formatter.formatDependencyError(err);
81927
+ process.exit(1);
81928
+ return;
81929
+ }
81930
+ formatter.error(err.message);
81931
+ process.exit(1);
81932
+ }
81933
+ });
81934
+ serviceCmd.command("delete <name>").description("Delete a service identity and remove its recipients from scoped files.").action(async (name) => {
81935
+ try {
81936
+ const repoRoot = program3.opts().dir || process.cwd();
81937
+ const parser = new ManifestParser();
81938
+ const manifest = parser.parse(path38.join(repoRoot, "clef.yaml"));
81939
+ const identity = manifest.service_identities?.find((si) => si.name === name);
81940
+ if (!identity) {
81941
+ formatter.error(`Service identity '${name}' not found.`);
81942
+ process.exit(1);
81943
+ return;
81944
+ }
81945
+ const confirmed = await formatter.confirm(
81946
+ `Delete service identity '${name}'? This will remove its recipients from all scoped files.`
81947
+ );
81948
+ if (!confirmed) {
81949
+ formatter.error("Aborted.");
81950
+ process.exit(1);
81951
+ return;
81952
+ }
81953
+ const matrixManager = new MatrixManager();
81954
+ const sopsClient = await createSopsClient(repoRoot, deps2.runner);
81955
+ const manager = new ServiceIdentityManager(sopsClient, matrixManager);
81956
+ formatter.print(`${sym("working")} Deleting service identity '${name}'...`);
81957
+ await manager.delete(name, manifest, repoRoot);
81958
+ formatter.success(`Service identity '${name}' deleted.`);
81959
+ formatter.hint(
81960
+ `git add clef.yaml && git commit -m "chore: delete service identity '${name}'"`
81961
+ );
81962
+ } catch (err) {
81963
+ if (err instanceof SopsMissingError || err instanceof SopsVersionError) {
81964
+ formatter.formatDependencyError(err);
81965
+ process.exit(1);
81966
+ return;
81967
+ }
81968
+ formatter.error(err.message);
81969
+ process.exit(1);
81970
+ }
81971
+ });
81584
81972
  serviceCmd.command("rotate <name>").description("Rotate the age key for a service identity.").option("-e, --environment <env>", "Rotate only a specific environment").action(async (name, opts2) => {
81585
81973
  try {
81586
81974
  const repoRoot = program3.opts().dir || process.cwd();
@@ -81610,11 +81998,22 @@ Service Identity: ${identity.name}`);
81610
81998
  formatter.print(`${sym("working")} Rotating key for '${name}'...`);
81611
81999
  const newKeys = await manager.rotateKey(name, manifest, repoRoot, opts2.environment);
81612
82000
  formatter.success(`Key rotated for '${name}'.`);
81613
- formatter.warn("New private keys are shown ONCE. Store them securely.\n");
81614
- for (const [envName, privateKey] of Object.entries(newKeys)) {
81615
- formatter.print(` ${envName}:`);
81616
- formatter.print(` ${privateKey}
82001
+ const entries = Object.entries(newKeys);
82002
+ const block = entries.map(([env, key]) => `${env}: ${key}`).join("\n");
82003
+ const copied = copyToClipboard(block);
82004
+ if (copied) {
82005
+ formatter.warn("New private keys copied to clipboard. Store them securely.\n");
82006
+ for (const [envName] of entries) {
82007
+ formatter.print(` ${envName}: ${maskedPlaceholder()}`);
82008
+ }
82009
+ formatter.print("");
82010
+ } else {
82011
+ formatter.warn("New private keys are shown ONCE. Store them securely.\n");
82012
+ for (const [envName, privateKey] of entries) {
82013
+ formatter.print(` ${envName}:`);
82014
+ formatter.print(` ${privateKey}
81617
82015
  `);
82016
+ }
81618
82017
  }
81619
82018
  for (const k of Object.keys(newKeys)) newKeys[k] = "";
81620
82019
  formatter.hint(
@@ -81628,11 +82027,25 @@ Service Identity: ${identity.name}`);
81628
82027
  }
81629
82028
  if (err instanceof PartialRotationError) {
81630
82029
  formatter.error(err.message);
81631
- formatter.warn("Partial rotation succeeded. New private keys below \u2014 store them NOW.\n");
81632
- for (const [envName, privateKey] of Object.entries(err.rotatedKeys)) {
81633
- formatter.print(` ${envName}:`);
81634
- formatter.print(` ${privateKey}
82030
+ const partialEntries = Object.entries(err.rotatedKeys);
82031
+ const partialBlock = partialEntries.map(([env, key]) => `${env}: ${key}`).join("\n");
82032
+ const partialCopied = copyToClipboard(partialBlock);
82033
+ if (partialCopied) {
82034
+ formatter.warn(
82035
+ "Partial rotation succeeded. Rotated keys copied to clipboard \u2014 store them NOW.\n"
82036
+ );
82037
+ for (const [envName] of partialEntries) {
82038
+ formatter.print(` ${envName}: ${maskedPlaceholder()}`);
82039
+ }
82040
+ } else {
82041
+ formatter.warn(
82042
+ "Partial rotation succeeded. New private keys below \u2014 store them NOW.\n"
82043
+ );
82044
+ for (const [envName, privateKey] of partialEntries) {
82045
+ formatter.print(` ${envName}:`);
82046
+ formatter.print(` ${privateKey}
81635
82047
  `);
82048
+ }
81636
82049
  }
81637
82050
  for (const k of Object.keys(err.rotatedKeys)) {
81638
82051
  err.rotatedKeys[k] = "";
@@ -82100,6 +82513,189 @@ function formatReportOutput(report) {
82100
82513
  formatter.hint("Run clef lint or clef drift locally for details.");
82101
82514
  }
82102
82515
 
82516
+ // src/commands/install.ts
82517
+ var import_yaml = __toESM(require_dist());
82518
+ import * as fs26 from "fs";
82519
+ import * as path43 from "path";
82520
+
82521
+ // src/registry/client.ts
82522
+ var DEFAULT_REGISTRY = "https://raw.githubusercontent.com/clef-sh/clef/main/brokers";
82523
+ async function fetchIndex(registryUrl = DEFAULT_REGISTRY) {
82524
+ const url = `${registryUrl}/index.json`;
82525
+ const res = await fetch(url);
82526
+ if (!res.ok) {
82527
+ throw new Error(`Failed to fetch registry index from ${url} (${res.status})`);
82528
+ }
82529
+ return await res.json();
82530
+ }
82531
+ async function fetchBrokerFile(registryUrl, brokerPath, filename) {
82532
+ const url = `${registryUrl}/${brokerPath}/${filename}`;
82533
+ const res = await fetch(url);
82534
+ if (!res.ok) {
82535
+ throw new Error(`Failed to fetch ${filename} from ${url} (${res.status})`);
82536
+ }
82537
+ return res.text();
82538
+ }
82539
+ function findBroker(index, name) {
82540
+ return index.brokers.find((b) => b.name === name);
82541
+ }
82542
+
82543
+ // src/commands/install.ts
82544
+ var TIER_LABELS = {
82545
+ 1: "self-expiring",
82546
+ 2: "stateful",
82547
+ 3: "complex"
82548
+ };
82549
+ function registerInstallCommand(program3, _deps) {
82550
+ program3.command("install <broker>").description(
82551
+ "Install a broker template from the Clef registry.\n\nDownloads broker.yaml, handler.ts, and README.md\ninto brokers/<name>/ in your project.\n\nExit codes:\n 0 Broker installed successfully\n 1 Error (broker not found, network failure, etc.)"
82552
+ ).option("--registry <url>", "Custom registry base URL", DEFAULT_REGISTRY).option("--force", "Overwrite existing broker directory without prompting").action(async (brokerName, options) => {
82553
+ try {
82554
+ const repoRoot = program3.opts().dir || process.cwd();
82555
+ const registryUrl = options.registry;
82556
+ formatter.info(`Fetching ${brokerName} from registry...`);
82557
+ const index = await fetchIndex(registryUrl);
82558
+ const entry = findBroker(index, brokerName);
82559
+ if (!entry) {
82560
+ formatter.error(
82561
+ `Broker "${brokerName}" not found in the registry. Run 'clef search' to list available brokers.`
82562
+ );
82563
+ process.exit(1);
82564
+ return;
82565
+ }
82566
+ const brokerDir = path43.join(repoRoot, "brokers", entry.name);
82567
+ if (fs26.existsSync(brokerDir) && !options.force) {
82568
+ const overwrite = await formatter.confirm(
82569
+ `brokers/${entry.name}/ already exists. Overwrite?`
82570
+ );
82571
+ if (!overwrite) {
82572
+ formatter.info("Installation cancelled.");
82573
+ process.exit(0);
82574
+ return;
82575
+ }
82576
+ }
82577
+ const files = [];
82578
+ for (const filename of ["broker.yaml", "handler.ts", "README.md"]) {
82579
+ try {
82580
+ const content = await fetchBrokerFile(registryUrl, entry.path, filename);
82581
+ files.push({ name: filename, content });
82582
+ } catch {
82583
+ if (filename === "handler.ts") {
82584
+ try {
82585
+ const content = await fetchBrokerFile(registryUrl, entry.path, "handler.js");
82586
+ files.push({ name: "handler.js", content });
82587
+ } catch {
82588
+ formatter.warn(`Could not download handler file for ${brokerName}`);
82589
+ }
82590
+ }
82591
+ }
82592
+ }
82593
+ if (files.length === 0) {
82594
+ formatter.error(`Could not download any files for ${brokerName}`);
82595
+ process.exit(1);
82596
+ return;
82597
+ }
82598
+ if (!fs26.existsSync(brokerDir)) {
82599
+ fs26.mkdirSync(brokerDir, { recursive: true });
82600
+ }
82601
+ for (const file of files) {
82602
+ fs26.writeFileSync(path43.join(brokerDir, file.name), file.content, "utf-8");
82603
+ }
82604
+ const manifestFile = files.find((f) => f.name === "broker.yaml");
82605
+ const manifest = manifestFile ? (0, import_yaml.parse)(manifestFile.content) : {};
82606
+ formatter.print("");
82607
+ formatter.print(` ${sym("success")} ${entry.name}`);
82608
+ formatter.print("");
82609
+ formatter.keyValue(" Name", entry.name);
82610
+ formatter.keyValue(" Provider", entry.provider);
82611
+ formatter.keyValue(" Tier", `${entry.tier} (${TIER_LABELS[entry.tier] ?? "unknown"})`);
82612
+ formatter.keyValue(" Description", entry.description);
82613
+ formatter.print("");
82614
+ formatter.section(" Created");
82615
+ for (const file of files) {
82616
+ formatter.print(` brokers/${entry.name}/${file.name}`);
82617
+ }
82618
+ if (manifest.inputs && manifest.inputs.length > 0) {
82619
+ formatter.section(" Inputs");
82620
+ for (const input of manifest.inputs) {
82621
+ const suffix = input.default !== void 0 ? ` (default: ${input.default})` : " (required)";
82622
+ formatter.print(` ${input.name}${suffix}`);
82623
+ }
82624
+ }
82625
+ if (manifest.output?.keys) {
82626
+ formatter.section(" Output");
82627
+ formatter.keyValue(" Keys", manifest.output.keys.join(", "));
82628
+ if (manifest.output.ttl) {
82629
+ formatter.keyValue(" TTL", `${manifest.output.ttl}s`);
82630
+ }
82631
+ }
82632
+ if (manifest.runtime?.permissions?.length > 0) {
82633
+ formatter.section(" Permissions");
82634
+ for (const perm of manifest.runtime.permissions) {
82635
+ formatter.print(` ${perm}`);
82636
+ }
82637
+ }
82638
+ formatter.print("");
82639
+ formatter.hint(`https://registry.clef.sh/brokers/${entry.name}`);
82640
+ process.exit(0);
82641
+ } catch (err) {
82642
+ formatter.error(err.message);
82643
+ process.exit(1);
82644
+ }
82645
+ });
82646
+ }
82647
+
82648
+ // src/commands/search.ts
82649
+ function registerSearchCommand(program3, _deps) {
82650
+ program3.command("search [query]").description(
82651
+ "Search the Clef broker registry.\n\nWithout arguments, lists all available brokers.\n\nExit codes:\n 0 Results found or listing complete\n 1 Error fetching registry"
82652
+ ).option("--provider <name>", "Filter by cloud provider (aws, gcp, azure, agnostic)").option("--tier <n>", "Filter by tier (1, 2, 3)").option("--registry <url>", "Custom registry base URL", DEFAULT_REGISTRY).action(
82653
+ async (query, options) => {
82654
+ try {
82655
+ const index = await fetchIndex(options.registry);
82656
+ let results = index.brokers;
82657
+ if (query) {
82658
+ const q = query.toLowerCase();
82659
+ results = results.filter(
82660
+ (b) => b.name.toLowerCase().includes(q) || b.description.toLowerCase().includes(q) || b.provider.toLowerCase().includes(q)
82661
+ );
82662
+ }
82663
+ if (options.provider) {
82664
+ results = results.filter((b) => b.provider === options.provider);
82665
+ }
82666
+ if (options.tier) {
82667
+ results = results.filter((b) => b.tier === Number(options.tier));
82668
+ }
82669
+ if (results.length === 0) {
82670
+ formatter.info("No brokers found matching your query.");
82671
+ process.exit(0);
82672
+ return;
82673
+ }
82674
+ const label2 = query || options.provider || options.tier ? `${results.length} broker${results.length === 1 ? "" : "s"} found` : `${results.length} broker${results.length === 1 ? "" : "s"} available`;
82675
+ formatter.print(`
82676
+ ${label2}
82677
+ `);
82678
+ printBrokerTable(results);
82679
+ formatter.print("");
82680
+ process.exit(0);
82681
+ } catch (err) {
82682
+ formatter.error(err.message);
82683
+ process.exit(1);
82684
+ }
82685
+ }
82686
+ );
82687
+ }
82688
+ function printBrokerTable(brokers) {
82689
+ const nameWidth = Math.max(...brokers.map((b) => b.name.length));
82690
+ const providerWidth = Math.max(...brokers.map((b) => b.provider.length));
82691
+ for (const b of brokers) {
82692
+ const name = b.name.padEnd(nameWidth);
82693
+ const provider = b.provider.padEnd(providerWidth);
82694
+ const tier = `Tier ${b.tier}`;
82695
+ formatter.print(` ${name} ${provider} ${tier} ${b.description}`);
82696
+ }
82697
+ }
82698
+
82103
82699
  // src/index.ts
82104
82700
  var VERSION = package_default.version;
82105
82701
  var program2 = new Command();
@@ -82155,6 +82751,8 @@ registerPackCommand(program2, deps);
82155
82751
  registerRevokeCommand(program2, deps);
82156
82752
  registerDriftCommand(program2, deps);
82157
82753
  registerReportCommand(program2, deps);
82754
+ registerInstallCommand(program2, deps);
82755
+ registerSearchCommand(program2, deps);
82158
82756
  program2.parseAsync(process.argv).catch((err) => {
82159
82757
  formatter.error(err.message);
82160
82758
  process.exit(1);