replicas-cli 0.2.37 → 0.2.40

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.
@@ -1,18 +1,19 @@
1
- #!/usr/bin/env node
2
- "use strict";
1
+ #!/usr/bin/env bun
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
6
  var __getProtoOf = Object.getPrototypeOf;
8
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined") return require.apply(this, arguments);
12
+ throw Error('Dynamic require of "' + x + '" is not supported');
13
+ });
14
+ var __commonJS = (cb, mod) => function __require2() {
10
15
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
16
  };
12
- var __export = (target, all) => {
13
- for (var name in all)
14
- __defProp(target, name, { get: all[name], enumerable: true });
15
- };
16
17
  var __copyProps = (to, from, except, desc) => {
17
18
  if (from && typeof from === "object" || typeof from === "function") {
18
19
  for (let key of __getOwnPropNames(from))
@@ -29,11 +30,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
29
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
31
  mod
31
32
  ));
32
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
33
 
34
- // ../node_modules/yaml/dist/nodes/identity.js
34
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js
35
35
  var require_identity = __commonJS({
36
- "../node_modules/yaml/dist/nodes/identity.js"(exports2) {
36
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/identity.js"(exports) {
37
37
  "use strict";
38
38
  var ALIAS = /* @__PURE__ */ Symbol.for("yaml.alias");
39
39
  var DOC = /* @__PURE__ */ Symbol.for("yaml.document");
@@ -69,28 +69,28 @@ var require_identity = __commonJS({
69
69
  return false;
70
70
  }
71
71
  var hasAnchor = (node) => (isScalar(node) || isCollection(node)) && !!node.anchor;
72
- exports2.ALIAS = ALIAS;
73
- exports2.DOC = DOC;
74
- exports2.MAP = MAP;
75
- exports2.NODE_TYPE = NODE_TYPE;
76
- exports2.PAIR = PAIR;
77
- exports2.SCALAR = SCALAR;
78
- exports2.SEQ = SEQ;
79
- exports2.hasAnchor = hasAnchor;
80
- exports2.isAlias = isAlias;
81
- exports2.isCollection = isCollection;
82
- exports2.isDocument = isDocument;
83
- exports2.isMap = isMap;
84
- exports2.isNode = isNode;
85
- exports2.isPair = isPair;
86
- exports2.isScalar = isScalar;
87
- exports2.isSeq = isSeq;
72
+ exports.ALIAS = ALIAS;
73
+ exports.DOC = DOC;
74
+ exports.MAP = MAP;
75
+ exports.NODE_TYPE = NODE_TYPE;
76
+ exports.PAIR = PAIR;
77
+ exports.SCALAR = SCALAR;
78
+ exports.SEQ = SEQ;
79
+ exports.hasAnchor = hasAnchor;
80
+ exports.isAlias = isAlias;
81
+ exports.isCollection = isCollection;
82
+ exports.isDocument = isDocument;
83
+ exports.isMap = isMap;
84
+ exports.isNode = isNode;
85
+ exports.isPair = isPair;
86
+ exports.isScalar = isScalar;
87
+ exports.isSeq = isSeq;
88
88
  }
89
89
  });
90
90
 
91
- // ../node_modules/yaml/dist/visit.js
91
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/visit.js
92
92
  var require_visit = __commonJS({
93
- "../node_modules/yaml/dist/visit.js"(exports2) {
93
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/visit.js"(exports) {
94
94
  "use strict";
95
95
  var identity = require_identity();
96
96
  var BREAK = /* @__PURE__ */ Symbol("break visit");
@@ -108,17 +108,17 @@ var require_visit = __commonJS({
108
108
  visit.BREAK = BREAK;
109
109
  visit.SKIP = SKIP;
110
110
  visit.REMOVE = REMOVE;
111
- function visit_(key, node, visitor, path5) {
112
- const ctrl = callVisitor(key, node, visitor, path5);
111
+ function visit_(key, node, visitor, path2) {
112
+ const ctrl = callVisitor(key, node, visitor, path2);
113
113
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
114
- replaceNode(key, path5, ctrl);
115
- return visit_(key, ctrl, visitor, path5);
114
+ replaceNode(key, path2, ctrl);
115
+ return visit_(key, ctrl, visitor, path2);
116
116
  }
117
117
  if (typeof ctrl !== "symbol") {
118
118
  if (identity.isCollection(node)) {
119
- path5 = Object.freeze(path5.concat(node));
119
+ path2 = Object.freeze(path2.concat(node));
120
120
  for (let i = 0; i < node.items.length; ++i) {
121
- const ci = visit_(i, node.items[i], visitor, path5);
121
+ const ci = visit_(i, node.items[i], visitor, path2);
122
122
  if (typeof ci === "number")
123
123
  i = ci - 1;
124
124
  else if (ci === BREAK)
@@ -129,13 +129,13 @@ var require_visit = __commonJS({
129
129
  }
130
130
  }
131
131
  } else if (identity.isPair(node)) {
132
- path5 = Object.freeze(path5.concat(node));
133
- const ck = visit_("key", node.key, visitor, path5);
132
+ path2 = Object.freeze(path2.concat(node));
133
+ const ck = visit_("key", node.key, visitor, path2);
134
134
  if (ck === BREAK)
135
135
  return BREAK;
136
136
  else if (ck === REMOVE)
137
137
  node.key = null;
138
- const cv = visit_("value", node.value, visitor, path5);
138
+ const cv = visit_("value", node.value, visitor, path2);
139
139
  if (cv === BREAK)
140
140
  return BREAK;
141
141
  else if (cv === REMOVE)
@@ -156,17 +156,17 @@ var require_visit = __commonJS({
156
156
  visitAsync.BREAK = BREAK;
157
157
  visitAsync.SKIP = SKIP;
158
158
  visitAsync.REMOVE = REMOVE;
159
- async function visitAsync_(key, node, visitor, path5) {
160
- const ctrl = await callVisitor(key, node, visitor, path5);
159
+ async function visitAsync_(key, node, visitor, path2) {
160
+ const ctrl = await callVisitor(key, node, visitor, path2);
161
161
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
162
- replaceNode(key, path5, ctrl);
163
- return visitAsync_(key, ctrl, visitor, path5);
162
+ replaceNode(key, path2, ctrl);
163
+ return visitAsync_(key, ctrl, visitor, path2);
164
164
  }
165
165
  if (typeof ctrl !== "symbol") {
166
166
  if (identity.isCollection(node)) {
167
- path5 = Object.freeze(path5.concat(node));
167
+ path2 = Object.freeze(path2.concat(node));
168
168
  for (let i = 0; i < node.items.length; ++i) {
169
- const ci = await visitAsync_(i, node.items[i], visitor, path5);
169
+ const ci = await visitAsync_(i, node.items[i], visitor, path2);
170
170
  if (typeof ci === "number")
171
171
  i = ci - 1;
172
172
  else if (ci === BREAK)
@@ -177,13 +177,13 @@ var require_visit = __commonJS({
177
177
  }
178
178
  }
179
179
  } else if (identity.isPair(node)) {
180
- path5 = Object.freeze(path5.concat(node));
181
- const ck = await visitAsync_("key", node.key, visitor, path5);
180
+ path2 = Object.freeze(path2.concat(node));
181
+ const ck = await visitAsync_("key", node.key, visitor, path2);
182
182
  if (ck === BREAK)
183
183
  return BREAK;
184
184
  else if (ck === REMOVE)
185
185
  node.key = null;
186
- const cv = await visitAsync_("value", node.value, visitor, path5);
186
+ const cv = await visitAsync_("value", node.value, visitor, path2);
187
187
  if (cv === BREAK)
188
188
  return BREAK;
189
189
  else if (cv === REMOVE)
@@ -210,23 +210,23 @@ var require_visit = __commonJS({
210
210
  }
211
211
  return visitor;
212
212
  }
213
- function callVisitor(key, node, visitor, path5) {
213
+ function callVisitor(key, node, visitor, path2) {
214
214
  if (typeof visitor === "function")
215
- return visitor(key, node, path5);
215
+ return visitor(key, node, path2);
216
216
  if (identity.isMap(node))
217
- return visitor.Map?.(key, node, path5);
217
+ return visitor.Map?.(key, node, path2);
218
218
  if (identity.isSeq(node))
219
- return visitor.Seq?.(key, node, path5);
219
+ return visitor.Seq?.(key, node, path2);
220
220
  if (identity.isPair(node))
221
- return visitor.Pair?.(key, node, path5);
221
+ return visitor.Pair?.(key, node, path2);
222
222
  if (identity.isScalar(node))
223
- return visitor.Scalar?.(key, node, path5);
223
+ return visitor.Scalar?.(key, node, path2);
224
224
  if (identity.isAlias(node))
225
- return visitor.Alias?.(key, node, path5);
225
+ return visitor.Alias?.(key, node, path2);
226
226
  return void 0;
227
227
  }
228
- function replaceNode(key, path5, node) {
229
- const parent = path5[path5.length - 1];
228
+ function replaceNode(key, path2, node) {
229
+ const parent = path2[path2.length - 1];
230
230
  if (identity.isCollection(parent)) {
231
231
  parent.items[key] = node;
232
232
  } else if (identity.isPair(parent)) {
@@ -241,14 +241,14 @@ var require_visit = __commonJS({
241
241
  throw new Error(`Cannot replace node with ${pt} parent`);
242
242
  }
243
243
  }
244
- exports2.visit = visit;
245
- exports2.visitAsync = visitAsync;
244
+ exports.visit = visit;
245
+ exports.visitAsync = visitAsync;
246
246
  }
247
247
  });
248
248
 
249
- // ../node_modules/yaml/dist/doc/directives.js
249
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/directives.js
250
250
  var require_directives = __commonJS({
251
- "../node_modules/yaml/dist/doc/directives.js"(exports2) {
251
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/directives.js"(exports) {
252
252
  "use strict";
253
253
  var identity = require_identity();
254
254
  var visit = require_visit();
@@ -413,13 +413,13 @@ var require_directives = __commonJS({
413
413
  };
414
414
  Directives.defaultYaml = { explicit: false, version: "1.2" };
415
415
  Directives.defaultTags = { "!!": "tag:yaml.org,2002:" };
416
- exports2.Directives = Directives;
416
+ exports.Directives = Directives;
417
417
  }
418
418
  });
419
419
 
420
- // ../node_modules/yaml/dist/doc/anchors.js
420
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/anchors.js
421
421
  var require_anchors = __commonJS({
422
- "../node_modules/yaml/dist/doc/anchors.js"(exports2) {
422
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/anchors.js"(exports) {
423
423
  "use strict";
424
424
  var identity = require_identity();
425
425
  var visit = require_visit();
@@ -480,16 +480,16 @@ var require_anchors = __commonJS({
480
480
  sourceObjects
481
481
  };
482
482
  }
483
- exports2.anchorIsValid = anchorIsValid;
484
- exports2.anchorNames = anchorNames;
485
- exports2.createNodeAnchors = createNodeAnchors;
486
- exports2.findNewAnchor = findNewAnchor;
483
+ exports.anchorIsValid = anchorIsValid;
484
+ exports.anchorNames = anchorNames;
485
+ exports.createNodeAnchors = createNodeAnchors;
486
+ exports.findNewAnchor = findNewAnchor;
487
487
  }
488
488
  });
489
489
 
490
- // ../node_modules/yaml/dist/doc/applyReviver.js
490
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/applyReviver.js
491
491
  var require_applyReviver = __commonJS({
492
- "../node_modules/yaml/dist/doc/applyReviver.js"(exports2) {
492
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/applyReviver.js"(exports) {
493
493
  "use strict";
494
494
  function applyReviver(reviver, obj, key, val) {
495
495
  if (val && typeof val === "object") {
@@ -533,13 +533,13 @@ var require_applyReviver = __commonJS({
533
533
  }
534
534
  return reviver.call(obj, key, val);
535
535
  }
536
- exports2.applyReviver = applyReviver;
536
+ exports.applyReviver = applyReviver;
537
537
  }
538
538
  });
539
539
 
540
- // ../node_modules/yaml/dist/nodes/toJS.js
540
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/toJS.js
541
541
  var require_toJS = __commonJS({
542
- "../node_modules/yaml/dist/nodes/toJS.js"(exports2) {
542
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/toJS.js"(exports) {
543
543
  "use strict";
544
544
  var identity = require_identity();
545
545
  function toJS(value, arg, ctx) {
@@ -563,13 +563,13 @@ var require_toJS = __commonJS({
563
563
  return Number(value);
564
564
  return value;
565
565
  }
566
- exports2.toJS = toJS;
566
+ exports.toJS = toJS;
567
567
  }
568
568
  });
569
569
 
570
- // ../node_modules/yaml/dist/nodes/Node.js
570
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Node.js
571
571
  var require_Node = __commonJS({
572
- "../node_modules/yaml/dist/nodes/Node.js"(exports2) {
572
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Node.js"(exports) {
573
573
  "use strict";
574
574
  var applyReviver = require_applyReviver();
575
575
  var identity = require_identity();
@@ -604,13 +604,13 @@ var require_Node = __commonJS({
604
604
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
605
605
  }
606
606
  };
607
- exports2.NodeBase = NodeBase;
607
+ exports.NodeBase = NodeBase;
608
608
  }
609
609
  });
610
610
 
611
- // ../node_modules/yaml/dist/nodes/Alias.js
611
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Alias.js
612
612
  var require_Alias = __commonJS({
613
- "../node_modules/yaml/dist/nodes/Alias.js"(exports2) {
613
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Alias.js"(exports) {
614
614
  "use strict";
615
615
  var anchors = require_anchors();
616
616
  var visit = require_visit();
@@ -718,13 +718,13 @@ var require_Alias = __commonJS({
718
718
  }
719
719
  return 1;
720
720
  }
721
- exports2.Alias = Alias;
721
+ exports.Alias = Alias;
722
722
  }
723
723
  });
724
724
 
725
- // ../node_modules/yaml/dist/nodes/Scalar.js
725
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Scalar.js
726
726
  var require_Scalar = __commonJS({
727
- "../node_modules/yaml/dist/nodes/Scalar.js"(exports2) {
727
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Scalar.js"(exports) {
728
728
  "use strict";
729
729
  var identity = require_identity();
730
730
  var Node = require_Node();
@@ -747,14 +747,14 @@ var require_Scalar = __commonJS({
747
747
  Scalar.PLAIN = "PLAIN";
748
748
  Scalar.QUOTE_DOUBLE = "QUOTE_DOUBLE";
749
749
  Scalar.QUOTE_SINGLE = "QUOTE_SINGLE";
750
- exports2.Scalar = Scalar;
751
- exports2.isScalarValue = isScalarValue;
750
+ exports.Scalar = Scalar;
751
+ exports.isScalarValue = isScalarValue;
752
752
  }
753
753
  });
754
754
 
755
- // ../node_modules/yaml/dist/doc/createNode.js
755
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/createNode.js
756
756
  var require_createNode = __commonJS({
757
- "../node_modules/yaml/dist/doc/createNode.js"(exports2) {
757
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/createNode.js"(exports) {
758
758
  "use strict";
759
759
  var Alias = require_Alias();
760
760
  var identity = require_identity();
@@ -823,21 +823,21 @@ var require_createNode = __commonJS({
823
823
  ref.node = node;
824
824
  return node;
825
825
  }
826
- exports2.createNode = createNode;
826
+ exports.createNode = createNode;
827
827
  }
828
828
  });
829
829
 
830
- // ../node_modules/yaml/dist/nodes/Collection.js
830
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Collection.js
831
831
  var require_Collection = __commonJS({
832
- "../node_modules/yaml/dist/nodes/Collection.js"(exports2) {
832
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Collection.js"(exports) {
833
833
  "use strict";
834
834
  var createNode = require_createNode();
835
835
  var identity = require_identity();
836
836
  var Node = require_Node();
837
- function collectionFromPath(schema, path5, value) {
837
+ function collectionFromPath(schema, path2, value) {
838
838
  let v = value;
839
- for (let i = path5.length - 1; i >= 0; --i) {
840
- const k = path5[i];
839
+ for (let i = path2.length - 1; i >= 0; --i) {
840
+ const k = path2[i];
841
841
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
842
842
  const a = [];
843
843
  a[k] = v;
@@ -856,7 +856,7 @@ var require_Collection = __commonJS({
856
856
  sourceObjects: /* @__PURE__ */ new Map()
857
857
  });
858
858
  }
859
- var isEmptyPath = (path5) => path5 == null || typeof path5 === "object" && !!path5[Symbol.iterator]().next().done;
859
+ var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
860
860
  var Collection = class extends Node.NodeBase {
861
861
  constructor(type, schema) {
862
862
  super(type);
@@ -886,11 +886,11 @@ var require_Collection = __commonJS({
886
886
  * be a Pair instance or a `{ key, value }` object, which may not have a key
887
887
  * that already exists in the map.
888
888
  */
889
- addIn(path5, value) {
890
- if (isEmptyPath(path5))
889
+ addIn(path2, value) {
890
+ if (isEmptyPath(path2))
891
891
  this.add(value);
892
892
  else {
893
- const [key, ...rest] = path5;
893
+ const [key, ...rest] = path2;
894
894
  const node = this.get(key, true);
895
895
  if (identity.isCollection(node))
896
896
  node.addIn(rest, value);
@@ -904,8 +904,8 @@ var require_Collection = __commonJS({
904
904
  * Removes a value from the collection.
905
905
  * @returns `true` if the item was found and removed.
906
906
  */
907
- deleteIn(path5) {
908
- const [key, ...rest] = path5;
907
+ deleteIn(path2) {
908
+ const [key, ...rest] = path2;
909
909
  if (rest.length === 0)
910
910
  return this.delete(key);
911
911
  const node = this.get(key, true);
@@ -919,8 +919,8 @@ var require_Collection = __commonJS({
919
919
  * scalar values from their surrounding node; to disable set `keepScalar` to
920
920
  * `true` (collections are always returned intact).
921
921
  */
922
- getIn(path5, keepScalar) {
923
- const [key, ...rest] = path5;
922
+ getIn(path2, keepScalar) {
923
+ const [key, ...rest] = path2;
924
924
  const node = this.get(key, true);
925
925
  if (rest.length === 0)
926
926
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -938,8 +938,8 @@ var require_Collection = __commonJS({
938
938
  /**
939
939
  * Checks if the collection includes a value with the key `key`.
940
940
  */
941
- hasIn(path5) {
942
- const [key, ...rest] = path5;
941
+ hasIn(path2) {
942
+ const [key, ...rest] = path2;
943
943
  if (rest.length === 0)
944
944
  return this.has(key);
945
945
  const node = this.get(key, true);
@@ -949,8 +949,8 @@ var require_Collection = __commonJS({
949
949
  * Sets a value in this collection. For `!!set`, `value` needs to be a
950
950
  * boolean to add/remove the item from the set.
951
951
  */
952
- setIn(path5, value) {
953
- const [key, ...rest] = path5;
952
+ setIn(path2, value) {
953
+ const [key, ...rest] = path2;
954
954
  if (rest.length === 0) {
955
955
  this.set(key, value);
956
956
  } else {
@@ -964,15 +964,15 @@ var require_Collection = __commonJS({
964
964
  }
965
965
  }
966
966
  };
967
- exports2.Collection = Collection;
968
- exports2.collectionFromPath = collectionFromPath;
969
- exports2.isEmptyPath = isEmptyPath;
967
+ exports.Collection = Collection;
968
+ exports.collectionFromPath = collectionFromPath;
969
+ exports.isEmptyPath = isEmptyPath;
970
970
  }
971
971
  });
972
972
 
973
- // ../node_modules/yaml/dist/stringify/stringifyComment.js
973
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyComment.js
974
974
  var require_stringifyComment = __commonJS({
975
- "../node_modules/yaml/dist/stringify/stringifyComment.js"(exports2) {
975
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyComment.js"(exports) {
976
976
  "use strict";
977
977
  var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
978
978
  function indentComment(comment, indent) {
@@ -981,15 +981,15 @@ var require_stringifyComment = __commonJS({
981
981
  return indent ? comment.replace(/^(?! *$)/gm, indent) : comment;
982
982
  }
983
983
  var lineComment = (str, indent, comment) => str.endsWith("\n") ? indentComment(comment, indent) : comment.includes("\n") ? "\n" + indentComment(comment, indent) : (str.endsWith(" ") ? "" : " ") + comment;
984
- exports2.indentComment = indentComment;
985
- exports2.lineComment = lineComment;
986
- exports2.stringifyComment = stringifyComment;
984
+ exports.indentComment = indentComment;
985
+ exports.lineComment = lineComment;
986
+ exports.stringifyComment = stringifyComment;
987
987
  }
988
988
  });
989
989
 
990
- // ../node_modules/yaml/dist/stringify/foldFlowLines.js
990
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/foldFlowLines.js
991
991
  var require_foldFlowLines = __commonJS({
992
- "../node_modules/yaml/dist/stringify/foldFlowLines.js"(exports2) {
992
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/foldFlowLines.js"(exports) {
993
993
  "use strict";
994
994
  var FOLD_FLOW = "flow";
995
995
  var FOLD_BLOCK = "block";
@@ -1116,16 +1116,16 @@ ${indent}${text.slice(fold + 1, end2)}`;
1116
1116
  }
1117
1117
  return end;
1118
1118
  }
1119
- exports2.FOLD_BLOCK = FOLD_BLOCK;
1120
- exports2.FOLD_FLOW = FOLD_FLOW;
1121
- exports2.FOLD_QUOTED = FOLD_QUOTED;
1122
- exports2.foldFlowLines = foldFlowLines;
1119
+ exports.FOLD_BLOCK = FOLD_BLOCK;
1120
+ exports.FOLD_FLOW = FOLD_FLOW;
1121
+ exports.FOLD_QUOTED = FOLD_QUOTED;
1122
+ exports.foldFlowLines = foldFlowLines;
1123
1123
  }
1124
1124
  });
1125
1125
 
1126
- // ../node_modules/yaml/dist/stringify/stringifyString.js
1126
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyString.js
1127
1127
  var require_stringifyString = __commonJS({
1128
- "../node_modules/yaml/dist/stringify/stringifyString.js"(exports2) {
1128
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyString.js"(exports) {
1129
1129
  "use strict";
1130
1130
  var Scalar = require_Scalar();
1131
1131
  var foldFlowLines = require_foldFlowLines();
@@ -1402,13 +1402,13 @@ ${indent}`);
1402
1402
  }
1403
1403
  return res;
1404
1404
  }
1405
- exports2.stringifyString = stringifyString;
1405
+ exports.stringifyString = stringifyString;
1406
1406
  }
1407
1407
  });
1408
1408
 
1409
- // ../node_modules/yaml/dist/stringify/stringify.js
1409
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringify.js
1410
1410
  var require_stringify = __commonJS({
1411
- "../node_modules/yaml/dist/stringify/stringify.js"(exports2) {
1411
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringify.js"(exports) {
1412
1412
  "use strict";
1413
1413
  var anchors = require_anchors();
1414
1414
  var identity = require_identity();
@@ -1431,6 +1431,7 @@ var require_stringify = __commonJS({
1431
1431
  nullStr: "null",
1432
1432
  simpleKeys: false,
1433
1433
  singleQuote: null,
1434
+ trailingComma: false,
1434
1435
  trueStr: "true",
1435
1436
  verifyAliasOrder: true
1436
1437
  }, doc.schema.toStringOptions, options);
@@ -1524,14 +1525,14 @@ var require_stringify = __commonJS({
1524
1525
  return identity.isScalar(node) || str[0] === "{" || str[0] === "[" ? `${props} ${str}` : `${props}
1525
1526
  ${ctx.indent}${str}`;
1526
1527
  }
1527
- exports2.createStringifyContext = createStringifyContext;
1528
- exports2.stringify = stringify;
1528
+ exports.createStringifyContext = createStringifyContext;
1529
+ exports.stringify = stringify;
1529
1530
  }
1530
1531
  });
1531
1532
 
1532
- // ../node_modules/yaml/dist/stringify/stringifyPair.js
1533
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyPair.js
1533
1534
  var require_stringifyPair = __commonJS({
1534
- "../node_modules/yaml/dist/stringify/stringifyPair.js"(exports2) {
1535
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyPair.js"(exports) {
1535
1536
  "use strict";
1536
1537
  var identity = require_identity();
1537
1538
  var Scalar = require_Scalar();
@@ -1658,15 +1659,15 @@ ${ctx.indent}`;
1658
1659
  }
1659
1660
  return str;
1660
1661
  }
1661
- exports2.stringifyPair = stringifyPair;
1662
+ exports.stringifyPair = stringifyPair;
1662
1663
  }
1663
1664
  });
1664
1665
 
1665
- // ../node_modules/yaml/dist/log.js
1666
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/log.js
1666
1667
  var require_log = __commonJS({
1667
- "../node_modules/yaml/dist/log.js"(exports2) {
1668
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/log.js"(exports) {
1668
1669
  "use strict";
1669
- var node_process = require("process");
1670
+ var node_process = __require("process");
1670
1671
  function debug(logLevel, ...messages) {
1671
1672
  if (logLevel === "debug")
1672
1673
  console.log(...messages);
@@ -1679,14 +1680,14 @@ var require_log = __commonJS({
1679
1680
  console.warn(warning);
1680
1681
  }
1681
1682
  }
1682
- exports2.debug = debug;
1683
- exports2.warn = warn;
1683
+ exports.debug = debug;
1684
+ exports.warn = warn;
1684
1685
  }
1685
1686
  });
1686
1687
 
1687
- // ../node_modules/yaml/dist/schema/yaml-1.1/merge.js
1688
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/merge.js
1688
1689
  var require_merge = __commonJS({
1689
- "../node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports2) {
1690
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/merge.js"(exports) {
1690
1691
  "use strict";
1691
1692
  var identity = require_identity();
1692
1693
  var Scalar = require_Scalar();
@@ -1735,15 +1736,15 @@ var require_merge = __commonJS({
1735
1736
  }
1736
1737
  return map;
1737
1738
  }
1738
- exports2.addMergeToJSMap = addMergeToJSMap;
1739
- exports2.isMergeKey = isMergeKey;
1740
- exports2.merge = merge;
1739
+ exports.addMergeToJSMap = addMergeToJSMap;
1740
+ exports.isMergeKey = isMergeKey;
1741
+ exports.merge = merge;
1741
1742
  }
1742
1743
  });
1743
1744
 
1744
- // ../node_modules/yaml/dist/nodes/addPairToJSMap.js
1745
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/addPairToJSMap.js
1745
1746
  var require_addPairToJSMap = __commonJS({
1746
- "../node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports2) {
1747
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/addPairToJSMap.js"(exports) {
1747
1748
  "use strict";
1748
1749
  var log = require_log();
1749
1750
  var merge = require_merge();
@@ -1801,13 +1802,13 @@ var require_addPairToJSMap = __commonJS({
1801
1802
  }
1802
1803
  return JSON.stringify(jsKey);
1803
1804
  }
1804
- exports2.addPairToJSMap = addPairToJSMap;
1805
+ exports.addPairToJSMap = addPairToJSMap;
1805
1806
  }
1806
1807
  });
1807
1808
 
1808
- // ../node_modules/yaml/dist/nodes/Pair.js
1809
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Pair.js
1809
1810
  var require_Pair = __commonJS({
1810
- "../node_modules/yaml/dist/nodes/Pair.js"(exports2) {
1811
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/Pair.js"(exports) {
1811
1812
  "use strict";
1812
1813
  var createNode = require_createNode();
1813
1814
  var stringifyPair = require_stringifyPair();
@@ -1840,14 +1841,14 @@ var require_Pair = __commonJS({
1840
1841
  return ctx?.doc ? stringifyPair.stringifyPair(this, ctx, onComment, onChompKeep) : JSON.stringify(this);
1841
1842
  }
1842
1843
  };
1843
- exports2.Pair = Pair;
1844
- exports2.createPair = createPair;
1844
+ exports.Pair = Pair;
1845
+ exports.createPair = createPair;
1845
1846
  }
1846
1847
  });
1847
1848
 
1848
- // ../node_modules/yaml/dist/stringify/stringifyCollection.js
1849
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyCollection.js
1849
1850
  var require_stringifyCollection = __commonJS({
1850
- "../node_modules/yaml/dist/stringify/stringifyCollection.js"(exports2) {
1851
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyCollection.js"(exports) {
1851
1852
  "use strict";
1852
1853
  var identity = require_identity();
1853
1854
  var stringify = require_stringify();
@@ -1948,12 +1949,19 @@ ${indent}${line}` : "\n";
1948
1949
  if (comment)
1949
1950
  reqNewline = true;
1950
1951
  let str = stringify.stringify(item, itemCtx, () => comment = null);
1951
- if (i < items.length - 1)
1952
+ reqNewline || (reqNewline = lines.length > linesAtValue || str.includes("\n"));
1953
+ if (i < items.length - 1) {
1952
1954
  str += ",";
1955
+ } else if (ctx.options.trailingComma) {
1956
+ if (ctx.options.lineWidth > 0) {
1957
+ reqNewline || (reqNewline = lines.reduce((sum, line) => sum + line.length + 2, 2) + (str.length + 2) > ctx.options.lineWidth);
1958
+ }
1959
+ if (reqNewline) {
1960
+ str += ",";
1961
+ }
1962
+ }
1953
1963
  if (comment)
1954
1964
  str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
1955
- if (!reqNewline && (lines.length > linesAtValue || str.includes("\n")))
1956
- reqNewline = true;
1957
1965
  lines.push(str);
1958
1966
  linesAtValue = lines.length;
1959
1967
  }
@@ -1985,13 +1993,13 @@ ${indent}${end}`;
1985
1993
  lines.push(ic.trimStart());
1986
1994
  }
1987
1995
  }
1988
- exports2.stringifyCollection = stringifyCollection;
1996
+ exports.stringifyCollection = stringifyCollection;
1989
1997
  }
1990
1998
  });
1991
1999
 
1992
- // ../node_modules/yaml/dist/nodes/YAMLMap.js
2000
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLMap.js
1993
2001
  var require_YAMLMap = __commonJS({
1994
- "../node_modules/yaml/dist/nodes/YAMLMap.js"(exports2) {
2002
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLMap.js"(exports) {
1995
2003
  "use strict";
1996
2004
  var stringifyCollection = require_stringifyCollection();
1997
2005
  var addPairToJSMap = require_addPairToJSMap();
@@ -2128,14 +2136,14 @@ var require_YAMLMap = __commonJS({
2128
2136
  });
2129
2137
  }
2130
2138
  };
2131
- exports2.YAMLMap = YAMLMap;
2132
- exports2.findPair = findPair;
2139
+ exports.YAMLMap = YAMLMap;
2140
+ exports.findPair = findPair;
2133
2141
  }
2134
2142
  });
2135
2143
 
2136
- // ../node_modules/yaml/dist/schema/common/map.js
2144
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/map.js
2137
2145
  var require_map = __commonJS({
2138
- "../node_modules/yaml/dist/schema/common/map.js"(exports2) {
2146
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/map.js"(exports) {
2139
2147
  "use strict";
2140
2148
  var identity = require_identity();
2141
2149
  var YAMLMap = require_YAMLMap();
@@ -2151,13 +2159,13 @@ var require_map = __commonJS({
2151
2159
  },
2152
2160
  createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
2153
2161
  };
2154
- exports2.map = map;
2162
+ exports.map = map;
2155
2163
  }
2156
2164
  });
2157
2165
 
2158
- // ../node_modules/yaml/dist/nodes/YAMLSeq.js
2166
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLSeq.js
2159
2167
  var require_YAMLSeq = __commonJS({
2160
- "../node_modules/yaml/dist/nodes/YAMLSeq.js"(exports2) {
2168
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/nodes/YAMLSeq.js"(exports) {
2161
2169
  "use strict";
2162
2170
  var createNode = require_createNode();
2163
2171
  var stringifyCollection = require_stringifyCollection();
@@ -2267,13 +2275,13 @@ var require_YAMLSeq = __commonJS({
2267
2275
  idx = Number(idx);
2268
2276
  return typeof idx === "number" && Number.isInteger(idx) && idx >= 0 ? idx : null;
2269
2277
  }
2270
- exports2.YAMLSeq = YAMLSeq;
2278
+ exports.YAMLSeq = YAMLSeq;
2271
2279
  }
2272
2280
  });
2273
2281
 
2274
- // ../node_modules/yaml/dist/schema/common/seq.js
2282
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/seq.js
2275
2283
  var require_seq = __commonJS({
2276
- "../node_modules/yaml/dist/schema/common/seq.js"(exports2) {
2284
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/seq.js"(exports) {
2277
2285
  "use strict";
2278
2286
  var identity = require_identity();
2279
2287
  var YAMLSeq = require_YAMLSeq();
@@ -2289,13 +2297,13 @@ var require_seq = __commonJS({
2289
2297
  },
2290
2298
  createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
2291
2299
  };
2292
- exports2.seq = seq;
2300
+ exports.seq = seq;
2293
2301
  }
2294
2302
  });
2295
2303
 
2296
- // ../node_modules/yaml/dist/schema/common/string.js
2304
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/string.js
2297
2305
  var require_string = __commonJS({
2298
- "../node_modules/yaml/dist/schema/common/string.js"(exports2) {
2306
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/string.js"(exports) {
2299
2307
  "use strict";
2300
2308
  var stringifyString = require_stringifyString();
2301
2309
  var string = {
@@ -2308,13 +2316,13 @@ var require_string = __commonJS({
2308
2316
  return stringifyString.stringifyString(item, ctx, onComment, onChompKeep);
2309
2317
  }
2310
2318
  };
2311
- exports2.string = string;
2319
+ exports.string = string;
2312
2320
  }
2313
2321
  });
2314
2322
 
2315
- // ../node_modules/yaml/dist/schema/common/null.js
2323
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/null.js
2316
2324
  var require_null = __commonJS({
2317
- "../node_modules/yaml/dist/schema/common/null.js"(exports2) {
2325
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/common/null.js"(exports) {
2318
2326
  "use strict";
2319
2327
  var Scalar = require_Scalar();
2320
2328
  var nullTag = {
@@ -2326,13 +2334,13 @@ var require_null = __commonJS({
2326
2334
  resolve: () => new Scalar.Scalar(null),
2327
2335
  stringify: ({ source }, ctx) => typeof source === "string" && nullTag.test.test(source) ? source : ctx.options.nullStr
2328
2336
  };
2329
- exports2.nullTag = nullTag;
2337
+ exports.nullTag = nullTag;
2330
2338
  }
2331
2339
  });
2332
2340
 
2333
- // ../node_modules/yaml/dist/schema/core/bool.js
2341
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/bool.js
2334
2342
  var require_bool = __commonJS({
2335
- "../node_modules/yaml/dist/schema/core/bool.js"(exports2) {
2343
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/bool.js"(exports) {
2336
2344
  "use strict";
2337
2345
  var Scalar = require_Scalar();
2338
2346
  var boolTag = {
@@ -2350,13 +2358,13 @@ var require_bool = __commonJS({
2350
2358
  return value ? ctx.options.trueStr : ctx.options.falseStr;
2351
2359
  }
2352
2360
  };
2353
- exports2.boolTag = boolTag;
2361
+ exports.boolTag = boolTag;
2354
2362
  }
2355
2363
  });
2356
2364
 
2357
- // ../node_modules/yaml/dist/stringify/stringifyNumber.js
2365
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyNumber.js
2358
2366
  var require_stringifyNumber = __commonJS({
2359
- "../node_modules/yaml/dist/stringify/stringifyNumber.js"(exports2) {
2367
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyNumber.js"(exports) {
2360
2368
  "use strict";
2361
2369
  function stringifyNumber({ format, minFractionDigits, tag, value }) {
2362
2370
  if (typeof value === "bigint")
@@ -2377,13 +2385,13 @@ var require_stringifyNumber = __commonJS({
2377
2385
  }
2378
2386
  return n;
2379
2387
  }
2380
- exports2.stringifyNumber = stringifyNumber;
2388
+ exports.stringifyNumber = stringifyNumber;
2381
2389
  }
2382
2390
  });
2383
2391
 
2384
- // ../node_modules/yaml/dist/schema/core/float.js
2392
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/float.js
2385
2393
  var require_float = __commonJS({
2386
- "../node_modules/yaml/dist/schema/core/float.js"(exports2) {
2394
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/float.js"(exports) {
2387
2395
  "use strict";
2388
2396
  var Scalar = require_Scalar();
2389
2397
  var stringifyNumber = require_stringifyNumber();
@@ -2421,15 +2429,15 @@ var require_float = __commonJS({
2421
2429
  },
2422
2430
  stringify: stringifyNumber.stringifyNumber
2423
2431
  };
2424
- exports2.float = float;
2425
- exports2.floatExp = floatExp;
2426
- exports2.floatNaN = floatNaN;
2432
+ exports.float = float;
2433
+ exports.floatExp = floatExp;
2434
+ exports.floatNaN = floatNaN;
2427
2435
  }
2428
2436
  });
2429
2437
 
2430
- // ../node_modules/yaml/dist/schema/core/int.js
2438
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/int.js
2431
2439
  var require_int = __commonJS({
2432
- "../node_modules/yaml/dist/schema/core/int.js"(exports2) {
2440
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/int.js"(exports) {
2433
2441
  "use strict";
2434
2442
  var stringifyNumber = require_stringifyNumber();
2435
2443
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
@@ -2466,15 +2474,15 @@ var require_int = __commonJS({
2466
2474
  resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
2467
2475
  stringify: (node) => intStringify(node, 16, "0x")
2468
2476
  };
2469
- exports2.int = int;
2470
- exports2.intHex = intHex;
2471
- exports2.intOct = intOct;
2477
+ exports.int = int;
2478
+ exports.intHex = intHex;
2479
+ exports.intOct = intOct;
2472
2480
  }
2473
2481
  });
2474
2482
 
2475
- // ../node_modules/yaml/dist/schema/core/schema.js
2483
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/schema.js
2476
2484
  var require_schema = __commonJS({
2477
- "../node_modules/yaml/dist/schema/core/schema.js"(exports2) {
2485
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/core/schema.js"(exports) {
2478
2486
  "use strict";
2479
2487
  var map = require_map();
2480
2488
  var _null = require_null();
@@ -2496,13 +2504,13 @@ var require_schema = __commonJS({
2496
2504
  float.floatExp,
2497
2505
  float.float
2498
2506
  ];
2499
- exports2.schema = schema;
2507
+ exports.schema = schema;
2500
2508
  }
2501
2509
  });
2502
2510
 
2503
- // ../node_modules/yaml/dist/schema/json/schema.js
2511
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/json/schema.js
2504
2512
  var require_schema2 = __commonJS({
2505
- "../node_modules/yaml/dist/schema/json/schema.js"(exports2) {
2513
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/json/schema.js"(exports) {
2506
2514
  "use strict";
2507
2515
  var Scalar = require_Scalar();
2508
2516
  var map = require_map();
@@ -2563,15 +2571,15 @@ var require_schema2 = __commonJS({
2563
2571
  }
2564
2572
  };
2565
2573
  var schema = [map.map, seq.seq].concat(jsonScalars, jsonError);
2566
- exports2.schema = schema;
2574
+ exports.schema = schema;
2567
2575
  }
2568
2576
  });
2569
2577
 
2570
- // ../node_modules/yaml/dist/schema/yaml-1.1/binary.js
2578
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/binary.js
2571
2579
  var require_binary = __commonJS({
2572
- "../node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports2) {
2580
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/binary.js"(exports) {
2573
2581
  "use strict";
2574
- var node_buffer = require("buffer");
2582
+ var node_buffer = __require("buffer");
2575
2583
  var Scalar = require_Scalar();
2576
2584
  var stringifyString = require_stringifyString();
2577
2585
  var binary = {
@@ -2629,13 +2637,13 @@ var require_binary = __commonJS({
2629
2637
  return stringifyString.stringifyString({ comment, type, value: str }, ctx, onComment, onChompKeep);
2630
2638
  }
2631
2639
  };
2632
- exports2.binary = binary;
2640
+ exports.binary = binary;
2633
2641
  }
2634
2642
  });
2635
2643
 
2636
- // ../node_modules/yaml/dist/schema/yaml-1.1/pairs.js
2644
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/pairs.js
2637
2645
  var require_pairs = __commonJS({
2638
- "../node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports2) {
2646
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/pairs.js"(exports) {
2639
2647
  "use strict";
2640
2648
  var identity = require_identity();
2641
2649
  var Pair = require_Pair();
@@ -2705,15 +2713,15 @@ ${cn.comment}` : item.comment;
2705
2713
  resolve: resolvePairs,
2706
2714
  createNode: createPairs
2707
2715
  };
2708
- exports2.createPairs = createPairs;
2709
- exports2.pairs = pairs;
2710
- exports2.resolvePairs = resolvePairs;
2716
+ exports.createPairs = createPairs;
2717
+ exports.pairs = pairs;
2718
+ exports.resolvePairs = resolvePairs;
2711
2719
  }
2712
2720
  });
2713
2721
 
2714
- // ../node_modules/yaml/dist/schema/yaml-1.1/omap.js
2722
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/omap.js
2715
2723
  var require_omap = __commonJS({
2716
- "../node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports2) {
2724
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/omap.js"(exports) {
2717
2725
  "use strict";
2718
2726
  var identity = require_identity();
2719
2727
  var toJS = require_toJS();
@@ -2784,14 +2792,14 @@ var require_omap = __commonJS({
2784
2792
  },
2785
2793
  createNode: (schema, iterable, ctx) => YAMLOMap.from(schema, iterable, ctx)
2786
2794
  };
2787
- exports2.YAMLOMap = YAMLOMap;
2788
- exports2.omap = omap;
2795
+ exports.YAMLOMap = YAMLOMap;
2796
+ exports.omap = omap;
2789
2797
  }
2790
2798
  });
2791
2799
 
2792
- // ../node_modules/yaml/dist/schema/yaml-1.1/bool.js
2800
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/bool.js
2793
2801
  var require_bool2 = __commonJS({
2794
- "../node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports2) {
2802
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/bool.js"(exports) {
2795
2803
  "use strict";
2796
2804
  var Scalar = require_Scalar();
2797
2805
  function boolStringify({ value, source }, ctx) {
@@ -2816,14 +2824,14 @@ var require_bool2 = __commonJS({
2816
2824
  resolve: () => new Scalar.Scalar(false),
2817
2825
  stringify: boolStringify
2818
2826
  };
2819
- exports2.falseTag = falseTag;
2820
- exports2.trueTag = trueTag;
2827
+ exports.falseTag = falseTag;
2828
+ exports.trueTag = trueTag;
2821
2829
  }
2822
2830
  });
2823
2831
 
2824
- // ../node_modules/yaml/dist/schema/yaml-1.1/float.js
2832
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/float.js
2825
2833
  var require_float2 = __commonJS({
2826
- "../node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports2) {
2834
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/float.js"(exports) {
2827
2835
  "use strict";
2828
2836
  var Scalar = require_Scalar();
2829
2837
  var stringifyNumber = require_stringifyNumber();
@@ -2864,15 +2872,15 @@ var require_float2 = __commonJS({
2864
2872
  },
2865
2873
  stringify: stringifyNumber.stringifyNumber
2866
2874
  };
2867
- exports2.float = float;
2868
- exports2.floatExp = floatExp;
2869
- exports2.floatNaN = floatNaN;
2875
+ exports.float = float;
2876
+ exports.floatExp = floatExp;
2877
+ exports.floatNaN = floatNaN;
2870
2878
  }
2871
2879
  });
2872
2880
 
2873
- // ../node_modules/yaml/dist/schema/yaml-1.1/int.js
2881
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/int.js
2874
2882
  var require_int2 = __commonJS({
2875
- "../node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports2) {
2883
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/int.js"(exports) {
2876
2884
  "use strict";
2877
2885
  var stringifyNumber = require_stringifyNumber();
2878
2886
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
@@ -2942,16 +2950,16 @@ var require_int2 = __commonJS({
2942
2950
  resolve: (str, _onError, opt) => intResolve(str, 2, 16, opt),
2943
2951
  stringify: (node) => intStringify(node, 16, "0x")
2944
2952
  };
2945
- exports2.int = int;
2946
- exports2.intBin = intBin;
2947
- exports2.intHex = intHex;
2948
- exports2.intOct = intOct;
2953
+ exports.int = int;
2954
+ exports.intBin = intBin;
2955
+ exports.intHex = intHex;
2956
+ exports.intOct = intOct;
2949
2957
  }
2950
2958
  });
2951
2959
 
2952
- // ../node_modules/yaml/dist/schema/yaml-1.1/set.js
2960
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/set.js
2953
2961
  var require_set = __commonJS({
2954
- "../node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports2) {
2962
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/set.js"(exports) {
2955
2963
  "use strict";
2956
2964
  var identity = require_identity();
2957
2965
  var Pair = require_Pair();
@@ -3033,14 +3041,14 @@ var require_set = __commonJS({
3033
3041
  return map;
3034
3042
  }
3035
3043
  };
3036
- exports2.YAMLSet = YAMLSet;
3037
- exports2.set = set;
3044
+ exports.YAMLSet = YAMLSet;
3045
+ exports.set = set;
3038
3046
  }
3039
3047
  });
3040
3048
 
3041
- // ../node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
3049
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
3042
3050
  var require_timestamp = __commonJS({
3043
- "../node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports2) {
3051
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/timestamp.js"(exports) {
3044
3052
  "use strict";
3045
3053
  var stringifyNumber = require_stringifyNumber();
3046
3054
  function parseSexagesimal(str, asBigInt) {
@@ -3120,15 +3128,15 @@ var require_timestamp = __commonJS({
3120
3128
  },
3121
3129
  stringify: ({ value }) => value?.toISOString().replace(/(T00:00:00)?\.000Z$/, "") ?? ""
3122
3130
  };
3123
- exports2.floatTime = floatTime;
3124
- exports2.intTime = intTime;
3125
- exports2.timestamp = timestamp;
3131
+ exports.floatTime = floatTime;
3132
+ exports.intTime = intTime;
3133
+ exports.timestamp = timestamp;
3126
3134
  }
3127
3135
  });
3128
3136
 
3129
- // ../node_modules/yaml/dist/schema/yaml-1.1/schema.js
3137
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/schema.js
3130
3138
  var require_schema3 = __commonJS({
3131
- "../node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports2) {
3139
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/yaml-1.1/schema.js"(exports) {
3132
3140
  "use strict";
3133
3141
  var map = require_map();
3134
3142
  var _null = require_null();
@@ -3166,13 +3174,13 @@ var require_schema3 = __commonJS({
3166
3174
  timestamp.floatTime,
3167
3175
  timestamp.timestamp
3168
3176
  ];
3169
- exports2.schema = schema;
3177
+ exports.schema = schema;
3170
3178
  }
3171
3179
  });
3172
3180
 
3173
- // ../node_modules/yaml/dist/schema/tags.js
3181
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/tags.js
3174
3182
  var require_tags = __commonJS({
3175
- "../node_modules/yaml/dist/schema/tags.js"(exports2) {
3183
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/tags.js"(exports) {
3176
3184
  "use strict";
3177
3185
  var map = require_map();
3178
3186
  var _null = require_null();
@@ -3259,14 +3267,14 @@ var require_tags = __commonJS({
3259
3267
  return tags2;
3260
3268
  }, []);
3261
3269
  }
3262
- exports2.coreKnownTags = coreKnownTags;
3263
- exports2.getTags = getTags;
3270
+ exports.coreKnownTags = coreKnownTags;
3271
+ exports.getTags = getTags;
3264
3272
  }
3265
3273
  });
3266
3274
 
3267
- // ../node_modules/yaml/dist/schema/Schema.js
3275
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/Schema.js
3268
3276
  var require_Schema = __commonJS({
3269
- "../node_modules/yaml/dist/schema/Schema.js"(exports2) {
3277
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/schema/Schema.js"(exports) {
3270
3278
  "use strict";
3271
3279
  var identity = require_identity();
3272
3280
  var map = require_map();
@@ -3292,13 +3300,13 @@ var require_Schema = __commonJS({
3292
3300
  return copy;
3293
3301
  }
3294
3302
  };
3295
- exports2.Schema = Schema;
3303
+ exports.Schema = Schema;
3296
3304
  }
3297
3305
  });
3298
3306
 
3299
- // ../node_modules/yaml/dist/stringify/stringifyDocument.js
3307
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyDocument.js
3300
3308
  var require_stringifyDocument = __commonJS({
3301
- "../node_modules/yaml/dist/stringify/stringifyDocument.js"(exports2) {
3309
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/stringify/stringifyDocument.js"(exports) {
3302
3310
  "use strict";
3303
3311
  var identity = require_identity();
3304
3312
  var stringify = require_stringify();
@@ -3372,13 +3380,13 @@ var require_stringifyDocument = __commonJS({
3372
3380
  }
3373
3381
  return lines.join("\n") + "\n";
3374
3382
  }
3375
- exports2.stringifyDocument = stringifyDocument;
3383
+ exports.stringifyDocument = stringifyDocument;
3376
3384
  }
3377
3385
  });
3378
3386
 
3379
- // ../node_modules/yaml/dist/doc/Document.js
3387
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/Document.js
3380
3388
  var require_Document = __commonJS({
3381
- "../node_modules/yaml/dist/doc/Document.js"(exports2) {
3389
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/doc/Document.js"(exports) {
3382
3390
  "use strict";
3383
3391
  var Alias = require_Alias();
3384
3392
  var Collection = require_Collection();
@@ -3454,9 +3462,9 @@ var require_Document = __commonJS({
3454
3462
  this.contents.add(value);
3455
3463
  }
3456
3464
  /** Adds a value to the document. */
3457
- addIn(path5, value) {
3465
+ addIn(path2, value) {
3458
3466
  if (assertCollection(this.contents))
3459
- this.contents.addIn(path5, value);
3467
+ this.contents.addIn(path2, value);
3460
3468
  }
3461
3469
  /**
3462
3470
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3531,14 +3539,14 @@ var require_Document = __commonJS({
3531
3539
  * Removes a value from the document.
3532
3540
  * @returns `true` if the item was found and removed.
3533
3541
  */
3534
- deleteIn(path5) {
3535
- if (Collection.isEmptyPath(path5)) {
3542
+ deleteIn(path2) {
3543
+ if (Collection.isEmptyPath(path2)) {
3536
3544
  if (this.contents == null)
3537
3545
  return false;
3538
3546
  this.contents = null;
3539
3547
  return true;
3540
3548
  }
3541
- return assertCollection(this.contents) ? this.contents.deleteIn(path5) : false;
3549
+ return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
3542
3550
  }
3543
3551
  /**
3544
3552
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3553,10 +3561,10 @@ var require_Document = __commonJS({
3553
3561
  * scalar values from their surrounding node; to disable set `keepScalar` to
3554
3562
  * `true` (collections are always returned intact).
3555
3563
  */
3556
- getIn(path5, keepScalar) {
3557
- if (Collection.isEmptyPath(path5))
3564
+ getIn(path2, keepScalar) {
3565
+ if (Collection.isEmptyPath(path2))
3558
3566
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3559
- return identity.isCollection(this.contents) ? this.contents.getIn(path5, keepScalar) : void 0;
3567
+ return identity.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : void 0;
3560
3568
  }
3561
3569
  /**
3562
3570
  * Checks if the document includes a value with the key `key`.
@@ -3567,10 +3575,10 @@ var require_Document = __commonJS({
3567
3575
  /**
3568
3576
  * Checks if the document includes a value at `path`.
3569
3577
  */
3570
- hasIn(path5) {
3571
- if (Collection.isEmptyPath(path5))
3578
+ hasIn(path2) {
3579
+ if (Collection.isEmptyPath(path2))
3572
3580
  return this.contents !== void 0;
3573
- return identity.isCollection(this.contents) ? this.contents.hasIn(path5) : false;
3581
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
3574
3582
  }
3575
3583
  /**
3576
3584
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3587,13 +3595,13 @@ var require_Document = __commonJS({
3587
3595
  * Sets a value in this document. For `!!set`, `value` needs to be a
3588
3596
  * boolean to add/remove the item from the set.
3589
3597
  */
3590
- setIn(path5, value) {
3591
- if (Collection.isEmptyPath(path5)) {
3598
+ setIn(path2, value) {
3599
+ if (Collection.isEmptyPath(path2)) {
3592
3600
  this.contents = value;
3593
3601
  } else if (this.contents == null) {
3594
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path5), value);
3602
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
3595
3603
  } else if (assertCollection(this.contents)) {
3596
- this.contents.setIn(path5, value);
3604
+ this.contents.setIn(path2, value);
3597
3605
  }
3598
3606
  }
3599
3607
  /**
@@ -3681,13 +3689,13 @@ var require_Document = __commonJS({
3681
3689
  return true;
3682
3690
  throw new Error("Expected a YAML collection as document contents");
3683
3691
  }
3684
- exports2.Document = Document;
3692
+ exports.Document = Document;
3685
3693
  }
3686
3694
  });
3687
3695
 
3688
- // ../node_modules/yaml/dist/errors.js
3696
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/errors.js
3689
3697
  var require_errors = __commonJS({
3690
- "../node_modules/yaml/dist/errors.js"(exports2) {
3698
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/errors.js"(exports) {
3691
3699
  "use strict";
3692
3700
  var YAMLError = class extends Error {
3693
3701
  constructor(name, pos, code, message) {
@@ -3743,16 +3751,16 @@ ${pointer}
3743
3751
  `;
3744
3752
  }
3745
3753
  };
3746
- exports2.YAMLError = YAMLError;
3747
- exports2.YAMLParseError = YAMLParseError;
3748
- exports2.YAMLWarning = YAMLWarning;
3749
- exports2.prettifyError = prettifyError;
3754
+ exports.YAMLError = YAMLError;
3755
+ exports.YAMLParseError = YAMLParseError;
3756
+ exports.YAMLWarning = YAMLWarning;
3757
+ exports.prettifyError = prettifyError;
3750
3758
  }
3751
3759
  });
3752
3760
 
3753
- // ../node_modules/yaml/dist/compose/resolve-props.js
3761
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-props.js
3754
3762
  var require_resolve_props = __commonJS({
3755
- "../node_modules/yaml/dist/compose/resolve-props.js"(exports2) {
3763
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-props.js"(exports) {
3756
3764
  "use strict";
3757
3765
  function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
3758
3766
  let spaceBefore = false;
@@ -3880,13 +3888,13 @@ var require_resolve_props = __commonJS({
3880
3888
  start: start ?? end
3881
3889
  };
3882
3890
  }
3883
- exports2.resolveProps = resolveProps;
3891
+ exports.resolveProps = resolveProps;
3884
3892
  }
3885
3893
  });
3886
3894
 
3887
- // ../node_modules/yaml/dist/compose/util-contains-newline.js
3895
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-contains-newline.js
3888
3896
  var require_util_contains_newline = __commonJS({
3889
- "../node_modules/yaml/dist/compose/util-contains-newline.js"(exports2) {
3897
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-contains-newline.js"(exports) {
3890
3898
  "use strict";
3891
3899
  function containsNewline(key) {
3892
3900
  if (!key)
@@ -3922,13 +3930,13 @@ var require_util_contains_newline = __commonJS({
3922
3930
  return true;
3923
3931
  }
3924
3932
  }
3925
- exports2.containsNewline = containsNewline;
3933
+ exports.containsNewline = containsNewline;
3926
3934
  }
3927
3935
  });
3928
3936
 
3929
- // ../node_modules/yaml/dist/compose/util-flow-indent-check.js
3937
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-flow-indent-check.js
3930
3938
  var require_util_flow_indent_check = __commonJS({
3931
- "../node_modules/yaml/dist/compose/util-flow-indent-check.js"(exports2) {
3939
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-flow-indent-check.js"(exports) {
3932
3940
  "use strict";
3933
3941
  var utilContainsNewline = require_util_contains_newline();
3934
3942
  function flowIndentCheck(indent, fc, onError) {
@@ -3940,13 +3948,13 @@ var require_util_flow_indent_check = __commonJS({
3940
3948
  }
3941
3949
  }
3942
3950
  }
3943
- exports2.flowIndentCheck = flowIndentCheck;
3951
+ exports.flowIndentCheck = flowIndentCheck;
3944
3952
  }
3945
3953
  });
3946
3954
 
3947
- // ../node_modules/yaml/dist/compose/util-map-includes.js
3955
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-map-includes.js
3948
3956
  var require_util_map_includes = __commonJS({
3949
- "../node_modules/yaml/dist/compose/util-map-includes.js"(exports2) {
3957
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-map-includes.js"(exports) {
3950
3958
  "use strict";
3951
3959
  var identity = require_identity();
3952
3960
  function mapIncludes(ctx, items, search) {
@@ -3956,13 +3964,13 @@ var require_util_map_includes = __commonJS({
3956
3964
  const isEqual = typeof uniqueKeys === "function" ? uniqueKeys : (a, b) => a === b || identity.isScalar(a) && identity.isScalar(b) && a.value === b.value;
3957
3965
  return items.some((pair) => isEqual(pair.key, search));
3958
3966
  }
3959
- exports2.mapIncludes = mapIncludes;
3967
+ exports.mapIncludes = mapIncludes;
3960
3968
  }
3961
3969
  });
3962
3970
 
3963
- // ../node_modules/yaml/dist/compose/resolve-block-map.js
3971
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-map.js
3964
3972
  var require_resolve_block_map = __commonJS({
3965
- "../node_modules/yaml/dist/compose/resolve-block-map.js"(exports2) {
3973
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-map.js"(exports) {
3966
3974
  "use strict";
3967
3975
  var Pair = require_Pair();
3968
3976
  var YAMLMap = require_YAMLMap();
@@ -4064,13 +4072,13 @@ var require_resolve_block_map = __commonJS({
4064
4072
  map.range = [bm.offset, offset, commentEnd ?? offset];
4065
4073
  return map;
4066
4074
  }
4067
- exports2.resolveBlockMap = resolveBlockMap;
4075
+ exports.resolveBlockMap = resolveBlockMap;
4068
4076
  }
4069
4077
  });
4070
4078
 
4071
- // ../node_modules/yaml/dist/compose/resolve-block-seq.js
4079
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-seq.js
4072
4080
  var require_resolve_block_seq = __commonJS({
4073
- "../node_modules/yaml/dist/compose/resolve-block-seq.js"(exports2) {
4081
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-seq.js"(exports) {
4074
4082
  "use strict";
4075
4083
  var YAMLSeq = require_YAMLSeq();
4076
4084
  var resolveProps = require_resolve_props();
@@ -4115,13 +4123,13 @@ var require_resolve_block_seq = __commonJS({
4115
4123
  seq.range = [bs.offset, offset, commentEnd ?? offset];
4116
4124
  return seq;
4117
4125
  }
4118
- exports2.resolveBlockSeq = resolveBlockSeq;
4126
+ exports.resolveBlockSeq = resolveBlockSeq;
4119
4127
  }
4120
4128
  });
4121
4129
 
4122
- // ../node_modules/yaml/dist/compose/resolve-end.js
4130
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-end.js
4123
4131
  var require_resolve_end = __commonJS({
4124
- "../node_modules/yaml/dist/compose/resolve-end.js"(exports2) {
4132
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-end.js"(exports) {
4125
4133
  "use strict";
4126
4134
  function resolveEnd(end, offset, reqSpace, onError) {
4127
4135
  let comment = "";
@@ -4158,13 +4166,13 @@ var require_resolve_end = __commonJS({
4158
4166
  }
4159
4167
  return { comment, offset };
4160
4168
  }
4161
- exports2.resolveEnd = resolveEnd;
4169
+ exports.resolveEnd = resolveEnd;
4162
4170
  }
4163
4171
  });
4164
4172
 
4165
- // ../node_modules/yaml/dist/compose/resolve-flow-collection.js
4173
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-collection.js
4166
4174
  var require_resolve_flow_collection = __commonJS({
4167
- "../node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports2) {
4175
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-collection.js"(exports) {
4168
4176
  "use strict";
4169
4177
  var identity = require_identity();
4170
4178
  var Pair = require_Pair();
@@ -4352,13 +4360,13 @@ var require_resolve_flow_collection = __commonJS({
4352
4360
  }
4353
4361
  return coll;
4354
4362
  }
4355
- exports2.resolveFlowCollection = resolveFlowCollection;
4363
+ exports.resolveFlowCollection = resolveFlowCollection;
4356
4364
  }
4357
4365
  });
4358
4366
 
4359
- // ../node_modules/yaml/dist/compose/compose-collection.js
4367
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-collection.js
4360
4368
  var require_compose_collection = __commonJS({
4361
- "../node_modules/yaml/dist/compose/compose-collection.js"(exports2) {
4369
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-collection.js"(exports) {
4362
4370
  "use strict";
4363
4371
  var identity = require_identity();
4364
4372
  var Scalar = require_Scalar();
@@ -4417,13 +4425,13 @@ var require_compose_collection = __commonJS({
4417
4425
  node.format = tag.format;
4418
4426
  return node;
4419
4427
  }
4420
- exports2.composeCollection = composeCollection;
4428
+ exports.composeCollection = composeCollection;
4421
4429
  }
4422
4430
  });
4423
4431
 
4424
- // ../node_modules/yaml/dist/compose/resolve-block-scalar.js
4432
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-scalar.js
4425
4433
  var require_resolve_block_scalar = __commonJS({
4426
- "../node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports2) {
4434
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-block-scalar.js"(exports) {
4427
4435
  "use strict";
4428
4436
  var Scalar = require_Scalar();
4429
4437
  function resolveBlockScalar(ctx, scalar, onError) {
@@ -4600,13 +4608,13 @@ var require_resolve_block_scalar = __commonJS({
4600
4608
  lines.push([split[i], split[i + 1]]);
4601
4609
  return lines;
4602
4610
  }
4603
- exports2.resolveBlockScalar = resolveBlockScalar;
4611
+ exports.resolveBlockScalar = resolveBlockScalar;
4604
4612
  }
4605
4613
  });
4606
4614
 
4607
- // ../node_modules/yaml/dist/compose/resolve-flow-scalar.js
4615
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-scalar.js
4608
4616
  var require_resolve_flow_scalar = __commonJS({
4609
- "../node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports2) {
4617
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/resolve-flow-scalar.js"(exports) {
4610
4618
  "use strict";
4611
4619
  var Scalar = require_Scalar();
4612
4620
  var resolveEnd = require_resolve_end();
@@ -4819,13 +4827,13 @@ var require_resolve_flow_scalar = __commonJS({
4819
4827
  }
4820
4828
  return String.fromCodePoint(code);
4821
4829
  }
4822
- exports2.resolveFlowScalar = resolveFlowScalar;
4830
+ exports.resolveFlowScalar = resolveFlowScalar;
4823
4831
  }
4824
4832
  });
4825
4833
 
4826
- // ../node_modules/yaml/dist/compose/compose-scalar.js
4834
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-scalar.js
4827
4835
  var require_compose_scalar = __commonJS({
4828
- "../node_modules/yaml/dist/compose/compose-scalar.js"(exports2) {
4836
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-scalar.js"(exports) {
4829
4837
  "use strict";
4830
4838
  var identity = require_identity();
4831
4839
  var Scalar = require_Scalar();
@@ -4900,13 +4908,13 @@ var require_compose_scalar = __commonJS({
4900
4908
  }
4901
4909
  return tag;
4902
4910
  }
4903
- exports2.composeScalar = composeScalar;
4911
+ exports.composeScalar = composeScalar;
4904
4912
  }
4905
4913
  });
4906
4914
 
4907
- // ../node_modules/yaml/dist/compose/util-empty-scalar-position.js
4915
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-empty-scalar-position.js
4908
4916
  var require_util_empty_scalar_position = __commonJS({
4909
- "../node_modules/yaml/dist/compose/util-empty-scalar-position.js"(exports2) {
4917
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/util-empty-scalar-position.js"(exports) {
4910
4918
  "use strict";
4911
4919
  function emptyScalarPosition(offset, before, pos) {
4912
4920
  if (before) {
@@ -4930,13 +4938,13 @@ var require_util_empty_scalar_position = __commonJS({
4930
4938
  }
4931
4939
  return offset;
4932
4940
  }
4933
- exports2.emptyScalarPosition = emptyScalarPosition;
4941
+ exports.emptyScalarPosition = emptyScalarPosition;
4934
4942
  }
4935
4943
  });
4936
4944
 
4937
- // ../node_modules/yaml/dist/compose/compose-node.js
4945
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-node.js
4938
4946
  var require_compose_node = __commonJS({
4939
- "../node_modules/yaml/dist/compose/compose-node.js"(exports2) {
4947
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-node.js"(exports) {
4940
4948
  "use strict";
4941
4949
  var Alias = require_Alias();
4942
4950
  var identity = require_identity();
@@ -4967,17 +4975,22 @@ var require_compose_node = __commonJS({
4967
4975
  case "block-map":
4968
4976
  case "block-seq":
4969
4977
  case "flow-collection":
4970
- node = composeCollection.composeCollection(CN, ctx, token, props, onError);
4971
- if (anchor)
4972
- node.anchor = anchor.source.substring(1);
4978
+ try {
4979
+ node = composeCollection.composeCollection(CN, ctx, token, props, onError);
4980
+ if (anchor)
4981
+ node.anchor = anchor.source.substring(1);
4982
+ } catch (error) {
4983
+ const message = error instanceof Error ? error.message : String(error);
4984
+ onError(token, "RESOURCE_EXHAUSTION", message);
4985
+ }
4973
4986
  break;
4974
4987
  default: {
4975
4988
  const message = token.type === "error" ? token.message : `Unsupported token (type: ${token.type})`;
4976
4989
  onError(token, "UNEXPECTED_TOKEN", message);
4977
- node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError);
4978
4990
  isSrcToken = false;
4979
4991
  }
4980
4992
  }
4993
+ node ?? (node = composeEmptyNode(ctx, token.offset, void 0, null, props, onError));
4981
4994
  if (anchor && node.anchor === "")
4982
4995
  onError(anchor, "BAD_ALIAS", "Anchor cannot be an empty string");
4983
4996
  if (atKey && ctx.options.stringKeys && (!identity.isScalar(node) || typeof node.value !== "string" || node.tag && node.tag !== "tag:yaml.org,2002:str")) {
@@ -5030,14 +5043,14 @@ var require_compose_node = __commonJS({
5030
5043
  alias.comment = re.comment;
5031
5044
  return alias;
5032
5045
  }
5033
- exports2.composeEmptyNode = composeEmptyNode;
5034
- exports2.composeNode = composeNode;
5046
+ exports.composeEmptyNode = composeEmptyNode;
5047
+ exports.composeNode = composeNode;
5035
5048
  }
5036
5049
  });
5037
5050
 
5038
- // ../node_modules/yaml/dist/compose/compose-doc.js
5051
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-doc.js
5039
5052
  var require_compose_doc = __commonJS({
5040
- "../node_modules/yaml/dist/compose/compose-doc.js"(exports2) {
5053
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/compose-doc.js"(exports) {
5041
5054
  "use strict";
5042
5055
  var Document = require_Document();
5043
5056
  var composeNode = require_compose_node();
@@ -5074,15 +5087,15 @@ var require_compose_doc = __commonJS({
5074
5087
  doc.range = [offset, contentEnd, re.offset];
5075
5088
  return doc;
5076
5089
  }
5077
- exports2.composeDoc = composeDoc;
5090
+ exports.composeDoc = composeDoc;
5078
5091
  }
5079
5092
  });
5080
5093
 
5081
- // ../node_modules/yaml/dist/compose/composer.js
5094
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/composer.js
5082
5095
  var require_composer = __commonJS({
5083
- "../node_modules/yaml/dist/compose/composer.js"(exports2) {
5096
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/compose/composer.js"(exports) {
5084
5097
  "use strict";
5085
- var node_process = require("process");
5098
+ var node_process = __require("process");
5086
5099
  var directives = require_directives();
5087
5100
  var Document = require_Document();
5088
5101
  var errors = require_errors();
@@ -5280,13 +5293,13 @@ ${end.comment}` : end.comment;
5280
5293
  }
5281
5294
  }
5282
5295
  };
5283
- exports2.Composer = Composer;
5296
+ exports.Composer = Composer;
5284
5297
  }
5285
5298
  });
5286
5299
 
5287
- // ../node_modules/yaml/dist/parse/cst-scalar.js
5300
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-scalar.js
5288
5301
  var require_cst_scalar = __commonJS({
5289
- "../node_modules/yaml/dist/parse/cst-scalar.js"(exports2) {
5302
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-scalar.js"(exports) {
5290
5303
  "use strict";
5291
5304
  var resolveBlockScalar = require_resolve_block_scalar();
5292
5305
  var resolveFlowScalar = require_resolve_flow_scalar();
@@ -5463,15 +5476,15 @@ var require_cst_scalar = __commonJS({
5463
5476
  }
5464
5477
  }
5465
5478
  }
5466
- exports2.createScalarToken = createScalarToken;
5467
- exports2.resolveAsScalar = resolveAsScalar;
5468
- exports2.setScalarValue = setScalarValue;
5479
+ exports.createScalarToken = createScalarToken;
5480
+ exports.resolveAsScalar = resolveAsScalar;
5481
+ exports.setScalarValue = setScalarValue;
5469
5482
  }
5470
5483
  });
5471
5484
 
5472
- // ../node_modules/yaml/dist/parse/cst-stringify.js
5485
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-stringify.js
5473
5486
  var require_cst_stringify = __commonJS({
5474
- "../node_modules/yaml/dist/parse/cst-stringify.js"(exports2) {
5487
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-stringify.js"(exports) {
5475
5488
  "use strict";
5476
5489
  var stringify = (cst) => "type" in cst ? stringifyToken(cst) : stringifyItem(cst);
5477
5490
  function stringifyToken(token) {
@@ -5526,13 +5539,13 @@ var require_cst_stringify = __commonJS({
5526
5539
  res += stringifyToken(value);
5527
5540
  return res;
5528
5541
  }
5529
- exports2.stringify = stringify;
5542
+ exports.stringify = stringify;
5530
5543
  }
5531
5544
  });
5532
5545
 
5533
- // ../node_modules/yaml/dist/parse/cst-visit.js
5546
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-visit.js
5534
5547
  var require_cst_visit = __commonJS({
5535
- "../node_modules/yaml/dist/parse/cst-visit.js"(exports2) {
5548
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst-visit.js"(exports) {
5536
5549
  "use strict";
5537
5550
  var BREAK = /* @__PURE__ */ Symbol("break visit");
5538
5551
  var SKIP = /* @__PURE__ */ Symbol("skip children");
@@ -5545,9 +5558,9 @@ var require_cst_visit = __commonJS({
5545
5558
  visit.BREAK = BREAK;
5546
5559
  visit.SKIP = SKIP;
5547
5560
  visit.REMOVE = REMOVE;
5548
- visit.itemAtPath = (cst, path5) => {
5561
+ visit.itemAtPath = (cst, path2) => {
5549
5562
  let item = cst;
5550
- for (const [field, index] of path5) {
5563
+ for (const [field, index] of path2) {
5551
5564
  const tok = item?.[field];
5552
5565
  if (tok && "items" in tok) {
5553
5566
  item = tok.items[index];
@@ -5556,23 +5569,23 @@ var require_cst_visit = __commonJS({
5556
5569
  }
5557
5570
  return item;
5558
5571
  };
5559
- visit.parentCollection = (cst, path5) => {
5560
- const parent = visit.itemAtPath(cst, path5.slice(0, -1));
5561
- const field = path5[path5.length - 1][0];
5572
+ visit.parentCollection = (cst, path2) => {
5573
+ const parent = visit.itemAtPath(cst, path2.slice(0, -1));
5574
+ const field = path2[path2.length - 1][0];
5562
5575
  const coll = parent?.[field];
5563
5576
  if (coll && "items" in coll)
5564
5577
  return coll;
5565
5578
  throw new Error("Parent collection not found");
5566
5579
  };
5567
- function _visit(path5, item, visitor) {
5568
- let ctrl = visitor(item, path5);
5580
+ function _visit(path2, item, visitor) {
5581
+ let ctrl = visitor(item, path2);
5569
5582
  if (typeof ctrl === "symbol")
5570
5583
  return ctrl;
5571
5584
  for (const field of ["key", "value"]) {
5572
5585
  const token = item[field];
5573
5586
  if (token && "items" in token) {
5574
5587
  for (let i = 0; i < token.items.length; ++i) {
5575
- const ci = _visit(Object.freeze(path5.concat([[field, i]])), token.items[i], visitor);
5588
+ const ci = _visit(Object.freeze(path2.concat([[field, i]])), token.items[i], visitor);
5576
5589
  if (typeof ci === "number")
5577
5590
  i = ci - 1;
5578
5591
  else if (ci === BREAK)
@@ -5583,18 +5596,18 @@ var require_cst_visit = __commonJS({
5583
5596
  }
5584
5597
  }
5585
5598
  if (typeof ctrl === "function" && field === "key")
5586
- ctrl = ctrl(item, path5);
5599
+ ctrl = ctrl(item, path2);
5587
5600
  }
5588
5601
  }
5589
- return typeof ctrl === "function" ? ctrl(item, path5) : ctrl;
5602
+ return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
5590
5603
  }
5591
- exports2.visit = visit;
5604
+ exports.visit = visit;
5592
5605
  }
5593
5606
  });
5594
5607
 
5595
- // ../node_modules/yaml/dist/parse/cst.js
5608
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst.js
5596
5609
  var require_cst = __commonJS({
5597
- "../node_modules/yaml/dist/parse/cst.js"(exports2) {
5610
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/cst.js"(exports) {
5598
5611
  "use strict";
5599
5612
  var cstScalar = require_cst_scalar();
5600
5613
  var cstStringify = require_cst_stringify();
@@ -5678,25 +5691,25 @@ var require_cst = __commonJS({
5678
5691
  }
5679
5692
  return null;
5680
5693
  }
5681
- exports2.createScalarToken = cstScalar.createScalarToken;
5682
- exports2.resolveAsScalar = cstScalar.resolveAsScalar;
5683
- exports2.setScalarValue = cstScalar.setScalarValue;
5684
- exports2.stringify = cstStringify.stringify;
5685
- exports2.visit = cstVisit.visit;
5686
- exports2.BOM = BOM;
5687
- exports2.DOCUMENT = DOCUMENT;
5688
- exports2.FLOW_END = FLOW_END;
5689
- exports2.SCALAR = SCALAR;
5690
- exports2.isCollection = isCollection;
5691
- exports2.isScalar = isScalar;
5692
- exports2.prettyToken = prettyToken;
5693
- exports2.tokenType = tokenType;
5694
+ exports.createScalarToken = cstScalar.createScalarToken;
5695
+ exports.resolveAsScalar = cstScalar.resolveAsScalar;
5696
+ exports.setScalarValue = cstScalar.setScalarValue;
5697
+ exports.stringify = cstStringify.stringify;
5698
+ exports.visit = cstVisit.visit;
5699
+ exports.BOM = BOM;
5700
+ exports.DOCUMENT = DOCUMENT;
5701
+ exports.FLOW_END = FLOW_END;
5702
+ exports.SCALAR = SCALAR;
5703
+ exports.isCollection = isCollection;
5704
+ exports.isScalar = isScalar;
5705
+ exports.prettyToken = prettyToken;
5706
+ exports.tokenType = tokenType;
5694
5707
  }
5695
5708
  });
5696
5709
 
5697
- // ../node_modules/yaml/dist/parse/lexer.js
5710
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/lexer.js
5698
5711
  var require_lexer = __commonJS({
5699
- "../node_modules/yaml/dist/parse/lexer.js"(exports2) {
5712
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/lexer.js"(exports) {
5700
5713
  "use strict";
5701
5714
  var cst = require_cst();
5702
5715
  function isEmpty(ch) {
@@ -6269,13 +6282,13 @@ var require_lexer = __commonJS({
6269
6282
  return yield* this.pushToIndex(i, false);
6270
6283
  }
6271
6284
  };
6272
- exports2.Lexer = Lexer;
6285
+ exports.Lexer = Lexer;
6273
6286
  }
6274
6287
  });
6275
6288
 
6276
- // ../node_modules/yaml/dist/parse/line-counter.js
6289
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/line-counter.js
6277
6290
  var require_line_counter = __commonJS({
6278
- "../node_modules/yaml/dist/parse/line-counter.js"(exports2) {
6291
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/line-counter.js"(exports) {
6279
6292
  "use strict";
6280
6293
  var LineCounter = class {
6281
6294
  constructor() {
@@ -6300,15 +6313,15 @@ var require_line_counter = __commonJS({
6300
6313
  };
6301
6314
  }
6302
6315
  };
6303
- exports2.LineCounter = LineCounter;
6316
+ exports.LineCounter = LineCounter;
6304
6317
  }
6305
6318
  });
6306
6319
 
6307
- // ../node_modules/yaml/dist/parse/parser.js
6320
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/parser.js
6308
6321
  var require_parser = __commonJS({
6309
- "../node_modules/yaml/dist/parse/parser.js"(exports2) {
6322
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/parse/parser.js"(exports) {
6310
6323
  "use strict";
6311
- var node_process = require("process");
6324
+ var node_process = __require("process");
6312
6325
  var cst = require_cst();
6313
6326
  var lexer = require_lexer();
6314
6327
  function includesToken(list, type) {
@@ -6871,14 +6884,14 @@ var require_parser = __commonJS({
6871
6884
  case "scalar":
6872
6885
  case "single-quoted-scalar":
6873
6886
  case "double-quoted-scalar": {
6874
- const fs4 = this.flowScalar(this.type);
6887
+ const fs2 = this.flowScalar(this.type);
6875
6888
  if (atNextItem || it.value) {
6876
- map.items.push({ start, key: fs4, sep: [] });
6889
+ map.items.push({ start, key: fs2, sep: [] });
6877
6890
  this.onKeyLine = true;
6878
6891
  } else if (it.sep) {
6879
- this.stack.push(fs4);
6892
+ this.stack.push(fs2);
6880
6893
  } else {
6881
- Object.assign(it, { key: fs4, sep: [] });
6894
+ Object.assign(it, { key: fs2, sep: [] });
6882
6895
  this.onKeyLine = true;
6883
6896
  }
6884
6897
  return;
@@ -7006,13 +7019,13 @@ var require_parser = __commonJS({
7006
7019
  case "scalar":
7007
7020
  case "single-quoted-scalar":
7008
7021
  case "double-quoted-scalar": {
7009
- const fs4 = this.flowScalar(this.type);
7022
+ const fs2 = this.flowScalar(this.type);
7010
7023
  if (!it || it.value)
7011
- fc.items.push({ start: [], key: fs4, sep: [] });
7024
+ fc.items.push({ start: [], key: fs2, sep: [] });
7012
7025
  else if (it.sep)
7013
- this.stack.push(fs4);
7026
+ this.stack.push(fs2);
7014
7027
  else
7015
- Object.assign(it, { key: fs4, sep: [] });
7028
+ Object.assign(it, { key: fs2, sep: [] });
7016
7029
  return;
7017
7030
  }
7018
7031
  case "flow-map-end":
@@ -7167,13 +7180,13 @@ var require_parser = __commonJS({
7167
7180
  }
7168
7181
  }
7169
7182
  };
7170
- exports2.Parser = Parser;
7183
+ exports.Parser = Parser;
7171
7184
  }
7172
7185
  });
7173
7186
 
7174
- // ../node_modules/yaml/dist/public-api.js
7187
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/public-api.js
7175
7188
  var require_public_api = __commonJS({
7176
- "../node_modules/yaml/dist/public-api.js"(exports2) {
7189
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/public-api.js"(exports) {
7177
7190
  "use strict";
7178
7191
  var composer = require_composer();
7179
7192
  var Document = require_Document();
@@ -7261,16 +7274,16 @@ var require_public_api = __commonJS({
7261
7274
  return value.toString(options);
7262
7275
  return new Document.Document(value, _replacer, options).toString(options);
7263
7276
  }
7264
- exports2.parse = parse;
7265
- exports2.parseAllDocuments = parseAllDocuments;
7266
- exports2.parseDocument = parseDocument;
7267
- exports2.stringify = stringify;
7277
+ exports.parse = parse;
7278
+ exports.parseAllDocuments = parseAllDocuments;
7279
+ exports.parseDocument = parseDocument;
7280
+ exports.stringify = stringify;
7268
7281
  }
7269
7282
  });
7270
7283
 
7271
- // ../node_modules/yaml/dist/index.js
7284
+ // ../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/index.js
7272
7285
  var require_dist = __commonJS({
7273
- "../node_modules/yaml/dist/index.js"(exports2) {
7286
+ "../node_modules/.bun/yaml@2.8.3/node_modules/yaml/dist/index.js"(exports) {
7274
7287
  "use strict";
7275
7288
  var composer = require_composer();
7276
7289
  var Document = require_Document();
@@ -7288,81 +7301,65 @@ var require_dist = __commonJS({
7288
7301
  var parser = require_parser();
7289
7302
  var publicApi = require_public_api();
7290
7303
  var visit = require_visit();
7291
- exports2.Composer = composer.Composer;
7292
- exports2.Document = Document.Document;
7293
- exports2.Schema = Schema.Schema;
7294
- exports2.YAMLError = errors.YAMLError;
7295
- exports2.YAMLParseError = errors.YAMLParseError;
7296
- exports2.YAMLWarning = errors.YAMLWarning;
7297
- exports2.Alias = Alias.Alias;
7298
- exports2.isAlias = identity.isAlias;
7299
- exports2.isCollection = identity.isCollection;
7300
- exports2.isDocument = identity.isDocument;
7301
- exports2.isMap = identity.isMap;
7302
- exports2.isNode = identity.isNode;
7303
- exports2.isPair = identity.isPair;
7304
- exports2.isScalar = identity.isScalar;
7305
- exports2.isSeq = identity.isSeq;
7306
- exports2.Pair = Pair.Pair;
7307
- exports2.Scalar = Scalar.Scalar;
7308
- exports2.YAMLMap = YAMLMap.YAMLMap;
7309
- exports2.YAMLSeq = YAMLSeq.YAMLSeq;
7310
- exports2.CST = cst;
7311
- exports2.Lexer = lexer.Lexer;
7312
- exports2.LineCounter = lineCounter.LineCounter;
7313
- exports2.Parser = parser.Parser;
7314
- exports2.parse = publicApi.parse;
7315
- exports2.parseAllDocuments = publicApi.parseAllDocuments;
7316
- exports2.parseDocument = publicApi.parseDocument;
7317
- exports2.stringify = publicApi.stringify;
7318
- exports2.visit = visit.visit;
7319
- exports2.visitAsync = visit.visitAsync;
7304
+ exports.Composer = composer.Composer;
7305
+ exports.Document = Document.Document;
7306
+ exports.Schema = Schema.Schema;
7307
+ exports.YAMLError = errors.YAMLError;
7308
+ exports.YAMLParseError = errors.YAMLParseError;
7309
+ exports.YAMLWarning = errors.YAMLWarning;
7310
+ exports.Alias = Alias.Alias;
7311
+ exports.isAlias = identity.isAlias;
7312
+ exports.isCollection = identity.isCollection;
7313
+ exports.isDocument = identity.isDocument;
7314
+ exports.isMap = identity.isMap;
7315
+ exports.isNode = identity.isNode;
7316
+ exports.isPair = identity.isPair;
7317
+ exports.isScalar = identity.isScalar;
7318
+ exports.isSeq = identity.isSeq;
7319
+ exports.Pair = Pair.Pair;
7320
+ exports.Scalar = Scalar.Scalar;
7321
+ exports.YAMLMap = YAMLMap.YAMLMap;
7322
+ exports.YAMLSeq = YAMLSeq.YAMLSeq;
7323
+ exports.CST = cst;
7324
+ exports.Lexer = lexer.Lexer;
7325
+ exports.LineCounter = lineCounter.LineCounter;
7326
+ exports.Parser = parser.Parser;
7327
+ exports.parse = publicApi.parse;
7328
+ exports.parseAllDocuments = publicApi.parseAllDocuments;
7329
+ exports.parseDocument = publicApi.parseDocument;
7330
+ exports.stringify = publicApi.stringify;
7331
+ exports.visit = visit.visit;
7332
+ exports.visitAsync = visit.visitAsync;
7320
7333
  }
7321
7334
  });
7322
7335
 
7323
- // src/index.ts
7324
- var index_exports = {};
7325
- __export(index_exports, {
7326
- CLI_VERSION: () => CLI_VERSION
7327
- });
7328
- module.exports = __toCommonJS(index_exports);
7329
- var import_config17 = require("dotenv/config");
7330
- var import_commander = require("commander");
7331
- var import_chalk17 = __toESM(require("chalk"));
7332
-
7333
- // src/commands/login.ts
7334
- var import_http = __toESM(require("http"));
7335
- var import_url = require("url");
7336
- var import_open = __toESM(require("open"));
7337
- var import_chalk = __toESM(require("chalk"));
7338
-
7339
7336
  // src/lib/config.ts
7340
- var import_fs = __toESM(require("fs"));
7341
- var import_path = __toESM(require("path"));
7342
- var import_os = __toESM(require("os"));
7343
- var CONFIG_DIR = import_path.default.join(import_os.default.homedir(), ".replicas");
7344
- var CONFIG_FILE = import_path.default.join(CONFIG_DIR, "config.json");
7337
+ import fs from "fs";
7338
+ import path from "path";
7339
+ import os from "os";
7340
+ var CONFIG_DIR = path.join(os.homedir(), ".replicas");
7341
+ var CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
7345
7342
  function ensureConfigDir() {
7346
- if (!import_fs.default.existsSync(CONFIG_DIR)) {
7347
- import_fs.default.mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
7343
+ if (!fs.existsSync(CONFIG_DIR)) {
7344
+ fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
7348
7345
  }
7349
7346
  }
7350
7347
  function readConfig() {
7351
- if (!import_fs.default.existsSync(CONFIG_FILE)) {
7348
+ if (!fs.existsSync(CONFIG_FILE)) {
7352
7349
  return null;
7353
7350
  }
7354
7351
  try {
7355
- const data = import_fs.default.readFileSync(CONFIG_FILE, "utf-8");
7352
+ const data = fs.readFileSync(CONFIG_FILE, "utf-8");
7356
7353
  return JSON.parse(data);
7357
7354
  } catch (error) {
7358
7355
  console.error("Error reading config file:", error);
7359
7356
  return null;
7360
7357
  }
7361
7358
  }
7362
- function writeConfig(config2) {
7359
+ function writeConfig(config) {
7363
7360
  ensureConfigDir();
7364
7361
  try {
7365
- import_fs.default.writeFileSync(CONFIG_FILE, JSON.stringify(config2, null, 2), {
7362
+ fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), {
7366
7363
  mode: 384
7367
7364
  // Only owner can read/write
7368
7365
  });
@@ -7372,44 +7369,49 @@ function writeConfig(config2) {
7372
7369
  }
7373
7370
  }
7374
7371
  function deleteConfig() {
7375
- if (import_fs.default.existsSync(CONFIG_FILE)) {
7376
- import_fs.default.unlinkSync(CONFIG_FILE);
7372
+ if (fs.existsSync(CONFIG_FILE)) {
7373
+ fs.unlinkSync(CONFIG_FILE);
7377
7374
  }
7378
7375
  }
7379
7376
  function isAuthenticated() {
7380
- const config2 = readConfig();
7381
- return config2 !== null && !!config2.access_token;
7377
+ const config = readConfig();
7378
+ if (!config || !config.access_token) return false;
7379
+ if (config.expires_at) {
7380
+ const now = Math.floor(Date.now() / 1e3);
7381
+ if (config.expires_at - now < 60 && !config.refresh_token) return false;
7382
+ }
7383
+ return true;
7382
7384
  }
7383
7385
  function setOrganizationId(organizationId) {
7384
- const config2 = readConfig();
7385
- if (!config2) {
7386
+ const config = readConfig();
7387
+ if (!config) {
7386
7388
  throw new Error("No config file found. Please login first.");
7387
7389
  }
7388
- config2.organization_id = organizationId;
7389
- writeConfig(config2);
7390
+ config.organization_id = organizationId;
7391
+ writeConfig(config);
7390
7392
  }
7391
7393
  function getOrganizationId() {
7392
- const config2 = readConfig();
7393
- return config2?.organization_id || null;
7394
+ const config = readConfig();
7395
+ return config?.organization_id || null;
7394
7396
  }
7395
7397
  function setIdeCommand(ideCommand) {
7396
- const config2 = readConfig();
7397
- if (!config2) {
7398
+ const config = readConfig();
7399
+ if (!config) {
7398
7400
  throw new Error("No config file found. Please login first.");
7399
7401
  }
7400
- config2.ide_command = ideCommand;
7401
- writeConfig(config2);
7402
+ config.ide_command = ideCommand;
7403
+ writeConfig(config);
7402
7404
  }
7403
7405
  function getIdeCommand() {
7404
- const config2 = readConfig();
7405
- return config2?.ide_command || "code";
7406
+ const config = readConfig();
7407
+ return config?.ide_command || "code";
7406
7408
  }
7407
7409
  function isAgentMode() {
7408
- if (!import_fs.default.existsSync(CONFIG_FILE)) {
7410
+ if (!fs.existsSync(CONFIG_FILE)) {
7409
7411
  return false;
7410
7412
  }
7411
7413
  try {
7412
- const data = import_fs.default.readFileSync(CONFIG_FILE, "utf-8");
7414
+ const data = fs.readFileSync(CONFIG_FILE, "utf-8");
7413
7415
  const parsed = JSON.parse(data);
7414
7416
  return !!parsed.engine_secret && !!parsed.workspace_id;
7415
7417
  } catch {
@@ -7417,11 +7419,11 @@ function isAgentMode() {
7417
7419
  }
7418
7420
  }
7419
7421
  function readAgentConfig() {
7420
- if (!import_fs.default.existsSync(CONFIG_FILE)) {
7422
+ if (!fs.existsSync(CONFIG_FILE)) {
7421
7423
  return null;
7422
7424
  }
7423
7425
  try {
7424
- const data = import_fs.default.readFileSync(CONFIG_FILE, "utf-8");
7426
+ const data = fs.readFileSync(CONFIG_FILE, "utf-8");
7425
7427
  const parsed = JSON.parse(data);
7426
7428
  if (parsed.engine_secret && parsed.workspace_id && parsed.organization_id) {
7427
7429
  return parsed;
@@ -7433,13 +7435,13 @@ function readAgentConfig() {
7433
7435
  }
7434
7436
 
7435
7437
  // src/lib/supabase.ts
7436
- var import_supabase_js = require("@supabase/supabase-js");
7438
+ import { createClient } from "@supabase/supabase-js";
7437
7439
  var supabaseUrl = process.env.REPLICAS_SUPABASE_URL || "https://mxeqiomwgdgaesecwtct.supabase.co";
7438
7440
  var supabaseAnonKey = process.env.REPLICAS_SUPABASE_ANON_KEY || "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im14ZXFpb213Z2RnYWVzZWN3dGN0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTk4OTk2ODAsImV4cCI6MjA3NTQ3NTY4MH0.zLRoK4r9Zep-WaLNkvWcb7DXlJBZFH26QXWO1ljMctM";
7439
- var supabase = (0, import_supabase_js.createClient)(supabaseUrl, supabaseAnonKey, {
7441
+ var supabase = createClient(supabaseUrl, supabaseAnonKey, {
7440
7442
  auth: {
7441
- persistSession: false,
7442
- autoRefreshToken: false
7443
+ persistSession: true,
7444
+ autoRefreshToken: true
7443
7445
  }
7444
7446
  });
7445
7447
 
@@ -7449,18 +7451,18 @@ function isTokenExpired(expiresAt) {
7449
7451
  return expiresAt - now < 60;
7450
7452
  }
7451
7453
  async function refreshToken() {
7452
- const config2 = readConfig();
7453
- if (!config2) {
7454
+ const config = readConfig();
7455
+ if (!config) {
7454
7456
  throw new Error('Not authenticated. Please run "replicas login"');
7455
7457
  }
7456
7458
  try {
7457
7459
  const { data, error } = await supabase.auth.refreshSession({
7458
- refresh_token: config2.refresh_token
7460
+ refresh_token: config.refresh_token
7459
7461
  });
7460
7462
  if (error) throw error;
7461
7463
  if (!data.session) throw new Error("Failed to refresh session");
7462
7464
  writeConfig({
7463
- ...config2,
7465
+ ...config,
7464
7466
  access_token: data.session.access_token,
7465
7467
  refresh_token: data.session.refresh_token,
7466
7468
  expires_at: data.session.expires_at || 0
@@ -7470,11 +7472,11 @@ async function refreshToken() {
7470
7472
  }
7471
7473
  }
7472
7474
  async function getValidToken() {
7473
- const config2 = readConfig();
7474
- if (!config2) {
7475
+ const config = readConfig();
7476
+ if (!config) {
7475
7477
  throw new Error('Not authenticated. Please run "replicas login"');
7476
7478
  }
7477
- if (isTokenExpired(config2.expires_at)) {
7479
+ if (isTokenExpired(config.expires_at)) {
7478
7480
  await refreshToken();
7479
7481
  const newConfig = readConfig();
7480
7482
  if (!newConfig) {
@@ -7482,7 +7484,7 @@ async function getValidToken() {
7482
7484
  }
7483
7485
  return newConfig.access_token;
7484
7486
  }
7485
- return config2.access_token;
7487
+ return config.access_token;
7486
7488
  }
7487
7489
  async function getCurrentUser() {
7488
7490
  const token = await getValidToken();
@@ -7495,476 +7497,6 @@ async function getCurrentUser() {
7495
7497
  };
7496
7498
  }
7497
7499
 
7498
- // src/lib/api.ts
7499
- var MONOLITH_URL = process.env.REPLICAS_MONOLITH_URL || "https://api.replicas.dev";
7500
- async function authenticatedFetch(url, options) {
7501
- const token = await getValidToken();
7502
- if (!token) {
7503
- throw new Error("No access token available");
7504
- }
7505
- const headers = {
7506
- "Authorization": `Bearer ${token}`,
7507
- "Content-Type": "application/json",
7508
- ...options?.headers || {}
7509
- };
7510
- const absoluteUrl = `${MONOLITH_URL}${url}`;
7511
- const requestInit = {
7512
- ...options,
7513
- headers,
7514
- body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
7515
- };
7516
- const response = await fetchWithRedirects(absoluteUrl, requestInit);
7517
- if (!response.ok) {
7518
- const error = await response.json().catch(() => ({ error: "Request failed" }));
7519
- throw new Error(error.error || `Request failed with status ${response.status}`);
7520
- }
7521
- return response.json();
7522
- }
7523
- var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
7524
- var MAX_REDIRECTS = 5;
7525
- async function fetchWithRedirects(url, init, attempt = 0) {
7526
- const response = await fetch(url, { ...init, redirect: "manual" });
7527
- if (REDIRECT_STATUSES.has(response.status)) {
7528
- if (attempt >= MAX_REDIRECTS) {
7529
- throw new Error("Too many redirects while contacting the Replicas API");
7530
- }
7531
- const location = response.headers.get("location");
7532
- if (!location) {
7533
- throw new Error(`Redirect status ${response.status} missing Location header`);
7534
- }
7535
- const nextUrl = new URL(location, url).toString();
7536
- const shouldForceGet = response.status === 303 && init.method !== void 0 && init.method.toUpperCase() !== "GET";
7537
- const nextInit = {
7538
- ...init,
7539
- method: shouldForceGet ? "GET" : init.method,
7540
- body: shouldForceGet ? void 0 : init.body
7541
- };
7542
- return fetchWithRedirects(nextUrl, nextInit, attempt + 1);
7543
- }
7544
- return response;
7545
- }
7546
- async function orgAuthenticatedFetch(url, options) {
7547
- const token = await getValidToken();
7548
- const organizationId = getOrganizationId();
7549
- if (!organizationId) {
7550
- throw new Error(
7551
- 'No organization selected. Please run "replicas org switch" to select an organization.'
7552
- );
7553
- }
7554
- const headers = {
7555
- "Authorization": `Bearer ${token}`,
7556
- "Replicas-Org-Id": organizationId,
7557
- "Content-Type": "application/json",
7558
- ...options?.headers || {}
7559
- };
7560
- const absoluteUrl = `${MONOLITH_URL}${url}`;
7561
- const requestInit = {
7562
- ...options,
7563
- headers,
7564
- body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
7565
- };
7566
- const response = await fetchWithRedirects(absoluteUrl, requestInit);
7567
- if (!response.ok) {
7568
- const error = await response.json().catch(() => ({ error: "Request failed" }));
7569
- throw new Error(error.error || `Request failed with status ${response.status}`);
7570
- }
7571
- return response.json();
7572
- }
7573
-
7574
- // src/lib/organization.ts
7575
- async function fetchOrganizations() {
7576
- const response = await authenticatedFetch(
7577
- "/v1/user/organizations"
7578
- );
7579
- return response.organizations;
7580
- }
7581
- async function setActiveOrganization(organizationId) {
7582
- const organizations = await fetchOrganizations();
7583
- const organization = organizations.find((org2) => org2.id === organizationId);
7584
- if (!organization) {
7585
- throw new Error(`Organization with ID ${organizationId} not found or you don't have access to it.`);
7586
- }
7587
- setOrganizationId(organizationId);
7588
- }
7589
- async function ensureOrganization() {
7590
- const organizations = await fetchOrganizations();
7591
- if (organizations.length === 0) {
7592
- throw new Error("You are not a member of any organization. Please contact support.");
7593
- }
7594
- const defaultOrg = organizations[0];
7595
- setOrganizationId(defaultOrg.id);
7596
- return defaultOrg.id;
7597
- }
7598
-
7599
- // src/commands/login.ts
7600
- var WEB_APP_URL = process.env.REPLICAS_WEB_URL || "https://replicas.dev";
7601
- function generateState() {
7602
- return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
7603
- }
7604
- async function loginCommand() {
7605
- const state = generateState();
7606
- return new Promise((resolve, reject) => {
7607
- let authTimeout;
7608
- let hasHandledCallback = false;
7609
- let lastRedirectUrl = null;
7610
- let lastMessage = null;
7611
- const pendingResponses = /* @__PURE__ */ new Set();
7612
- function respondWithRedirect(res) {
7613
- if (lastRedirectUrl) {
7614
- res.writeHead(302, {
7615
- "Location": lastRedirectUrl,
7616
- "Connection": "close"
7617
- });
7618
- res.end();
7619
- } else {
7620
- res.writeHead(200, {
7621
- "Content-Type": "text/html; charset=utf-8",
7622
- "Connection": "close"
7623
- });
7624
- res.end(`
7625
- <!DOCTYPE html>
7626
- <html lang="en">
7627
- <head>
7628
- <meta charset="utf-8" />
7629
- <title>Replicas CLI Login</title>
7630
- <style>
7631
- body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background:#09090b; color:#f4f4f5; display:flex; align-items:center; justify-content:center; height:100vh; margin:0; }
7632
- .card { border:1px solid #27272a; padding:32px; border-radius:12px; background:#0f0f12; max-width:420px; text-align:center; }
7633
- .title { font-size:20px; margin-bottom:12px; letter-spacing:0.08em; text-transform:uppercase; color:#a855f7; }
7634
- .message { font-family: 'Menlo', 'Source Code Pro', monospace; font-size:14px; line-height:1.6; color:#d4d4d8; white-space:pre-line; }
7635
- </style>
7636
- </head>
7637
- <body>
7638
- <div class="card">
7639
- <div class="title">Replicas CLI</div>
7640
- <div class="message">${lastMessage || "Authentication already processed. You can close this tab."}</div>
7641
- </div>
7642
- </body>
7643
- </html>
7644
- `);
7645
- }
7646
- }
7647
- function flushPendingResponses() {
7648
- for (const response of pendingResponses) {
7649
- respondWithRedirect(response);
7650
- }
7651
- pendingResponses.clear();
7652
- }
7653
- const server = import_http.default.createServer(async (req, res) => {
7654
- const url = new import_url.URL(req.url || "", `http://${req.headers.host}`);
7655
- if (url.pathname === "/callback") {
7656
- if (hasHandledCallback) {
7657
- if (!lastRedirectUrl) {
7658
- pendingResponses.add(res);
7659
- res.on("close", () => pendingResponses.delete(res));
7660
- return;
7661
- }
7662
- respondWithRedirect(res);
7663
- return;
7664
- }
7665
- const returnedState = url.searchParams.get("state");
7666
- const accessToken = url.searchParams.get("access_token");
7667
- const refreshToken2 = url.searchParams.get("refresh_token");
7668
- const expiresAt = url.searchParams.get("expires_at");
7669
- const error = url.searchParams.get("error");
7670
- if (error) {
7671
- const errorUrl = `${WEB_APP_URL}/cli-login/error?message=${encodeURIComponent(error)}`;
7672
- lastRedirectUrl = errorUrl;
7673
- lastMessage = `Authentication failed: ${error}`;
7674
- respondWithRedirect(res);
7675
- flushPendingResponses();
7676
- clearTimeout(authTimeout);
7677
- setImmediate(() => {
7678
- server.closeAllConnections?.();
7679
- server.close();
7680
- reject(new Error(`Authentication failed: ${error}`));
7681
- });
7682
- return;
7683
- }
7684
- if (returnedState !== state) {
7685
- const errorUrl = `${WEB_APP_URL}/cli-login/error?message=${encodeURIComponent("Invalid state parameter. This might be a CSRF attack.")}`;
7686
- lastRedirectUrl = errorUrl;
7687
- lastMessage = "Invalid state parameter. This might be a CSRF attack.";
7688
- respondWithRedirect(res);
7689
- flushPendingResponses();
7690
- clearTimeout(authTimeout);
7691
- setImmediate(() => {
7692
- server.closeAllConnections?.();
7693
- server.close();
7694
- reject(new Error("Invalid state parameter"));
7695
- });
7696
- return;
7697
- }
7698
- if (!accessToken || !refreshToken2 || !expiresAt) {
7699
- const errorUrl = `${WEB_APP_URL}/cli-login/error?message=${encodeURIComponent("Missing required authentication tokens.")}`;
7700
- lastRedirectUrl = errorUrl;
7701
- lastMessage = "Missing required authentication tokens.";
7702
- respondWithRedirect(res);
7703
- flushPendingResponses();
7704
- clearTimeout(authTimeout);
7705
- setImmediate(() => {
7706
- server.closeAllConnections?.();
7707
- server.close();
7708
- reject(new Error("Missing authentication tokens"));
7709
- });
7710
- return;
7711
- }
7712
- hasHandledCallback = true;
7713
- const existingConfig = readConfig();
7714
- const config2 = {
7715
- access_token: accessToken,
7716
- refresh_token: refreshToken2,
7717
- expires_at: parseInt(expiresAt, 10),
7718
- organization_id: existingConfig?.organization_id,
7719
- ide_command: existingConfig?.ide_command
7720
- };
7721
- try {
7722
- writeConfig(config2);
7723
- const user = await getCurrentUser();
7724
- try {
7725
- const orgId = await ensureOrganization();
7726
- console.log(import_chalk.default.gray(` Organization: ${orgId}`));
7727
- } catch (orgError) {
7728
- console.log(import_chalk.default.yellow(" Warning: Could not fetch organizations"));
7729
- console.log(import_chalk.default.gray(" You can set your organization later with: replicas org switch"));
7730
- }
7731
- const successUrl = `${WEB_APP_URL}/cli-login/success?email=${encodeURIComponent(user.email)}`;
7732
- lastRedirectUrl = successUrl;
7733
- lastMessage = `Successfully logged in as ${user.email}. You can close this tab.`;
7734
- respondWithRedirect(res);
7735
- flushPendingResponses();
7736
- console.log(import_chalk.default.green("\n\u2713 Successfully logged in!"));
7737
- console.log(import_chalk.default.gray(` Email: ${user.email}
7738
- `));
7739
- clearTimeout(authTimeout);
7740
- setImmediate(() => {
7741
- server.closeAllConnections?.();
7742
- server.close();
7743
- resolve();
7744
- });
7745
- } catch (error2) {
7746
- const errorUrl = `${WEB_APP_URL}/cli-login/error?message=${encodeURIComponent("Failed to verify authentication.")}`;
7747
- lastRedirectUrl = errorUrl;
7748
- lastMessage = "Failed to verify authentication.";
7749
- respondWithRedirect(res);
7750
- flushPendingResponses();
7751
- clearTimeout(authTimeout);
7752
- setImmediate(() => {
7753
- server.closeAllConnections?.();
7754
- server.close();
7755
- reject(error2);
7756
- });
7757
- }
7758
- } else {
7759
- res.writeHead(404);
7760
- res.end("Not found");
7761
- }
7762
- });
7763
- server.listen(0, "localhost", () => {
7764
- const address = server.address();
7765
- if (!address || typeof address === "string") {
7766
- reject(new Error("Failed to start server"));
7767
- return;
7768
- }
7769
- const port = address.port;
7770
- const loginUrl = `${WEB_APP_URL}/cli-login?port=${port}&state=${state}`;
7771
- console.log(import_chalk.default.blue("\nOpening browser for authentication..."));
7772
- console.log(import_chalk.default.gray(`If the browser doesn't open automatically, visit:
7773
- ${loginUrl}
7774
- `));
7775
- (0, import_open.default)(loginUrl).catch((error) => {
7776
- console.log(import_chalk.default.yellow("Failed to open browser automatically."));
7777
- console.log(import_chalk.default.gray(`Please open this URL manually:
7778
- ${loginUrl}
7779
- `));
7780
- });
7781
- });
7782
- authTimeout = setTimeout(() => {
7783
- server.closeAllConnections?.();
7784
- server.close();
7785
- reject(new Error("Authentication timeout. Please try again."));
7786
- }, 5 * 60 * 1e3);
7787
- });
7788
- }
7789
-
7790
- // src/commands/logout.ts
7791
- var import_chalk2 = __toESM(require("chalk"));
7792
- function logoutCommand() {
7793
- if (!isAuthenticated()) {
7794
- console.log(import_chalk2.default.yellow("You are not logged in."));
7795
- return;
7796
- }
7797
- deleteConfig();
7798
- console.log(import_chalk2.default.green("\u2713 Successfully logged out!"));
7799
- }
7800
-
7801
- // src/commands/whoami.ts
7802
- var import_chalk3 = __toESM(require("chalk"));
7803
- async function whoamiCommand() {
7804
- if (!isAuthenticated()) {
7805
- console.log(import_chalk3.default.yellow("You are not logged in."));
7806
- console.log(import_chalk3.default.gray('Run "replicas login" to authenticate.'));
7807
- return;
7808
- }
7809
- try {
7810
- const user = await getCurrentUser();
7811
- console.log(import_chalk3.default.blue("\nCurrent User:"));
7812
- console.log(import_chalk3.default.gray(` ID: ${user.id}`));
7813
- console.log(import_chalk3.default.gray(` Email: ${user.email}
7814
- `));
7815
- } catch (error) {
7816
- console.error(import_chalk3.default.red("Failed to get user information."));
7817
- if (error instanceof Error) {
7818
- console.error(import_chalk3.default.gray(error.message));
7819
- }
7820
- console.log(import_chalk3.default.gray('\nTry running "replicas login" again.'));
7821
- process.exit(1);
7822
- }
7823
- }
7824
-
7825
- // src/commands/connect.ts
7826
- var import_chalk5 = __toESM(require("chalk"));
7827
-
7828
- // src/lib/ssh.ts
7829
- var import_child_process = require("child_process");
7830
- var SSH_OPTIONS = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"];
7831
- async function connectSSH(token, host) {
7832
- return new Promise((resolve, reject) => {
7833
- const sshArgs = [...SSH_OPTIONS, `${token}@${host}`];
7834
- const ssh = (0, import_child_process.spawn)("ssh", sshArgs, {
7835
- stdio: "inherit"
7836
- });
7837
- ssh.on("close", () => {
7838
- resolve();
7839
- });
7840
- ssh.on("error", reject);
7841
- });
7842
- }
7843
-
7844
- // src/lib/workspace-connection.ts
7845
- var import_chalk4 = __toESM(require("chalk"));
7846
- var import_prompts = __toESM(require("prompts"));
7847
-
7848
- // src/lib/git.ts
7849
- var import_child_process2 = require("child_process");
7850
- var import_path2 = __toESM(require("path"));
7851
- function getGitRoot() {
7852
- try {
7853
- const root = (0, import_child_process2.execSync)("git rev-parse --show-toplevel", {
7854
- encoding: "utf-8",
7855
- stdio: ["pipe", "pipe", "pipe"]
7856
- }).trim();
7857
- return root;
7858
- } catch (error) {
7859
- throw new Error("Not inside a git repository");
7860
- }
7861
- }
7862
- function getGitRepoName() {
7863
- const root = getGitRoot();
7864
- return import_path2.default.basename(root);
7865
- }
7866
- function isInsideGitRepo() {
7867
- try {
7868
- (0, import_child_process2.execSync)("git rev-parse --is-inside-work-tree", {
7869
- encoding: "utf-8",
7870
- stdio: ["pipe", "pipe", "pipe"]
7871
- });
7872
- return true;
7873
- } catch {
7874
- return false;
7875
- }
7876
- }
7877
-
7878
- // src/lib/workspace-connection.ts
7879
- async function prepareWorkspaceConnection(workspaceName) {
7880
- const orgId = getOrganizationId();
7881
- if (!orgId) {
7882
- throw new Error('No organization selected. Please run "replicas org switch" first.');
7883
- }
7884
- console.log(import_chalk4.default.blue(`
7885
- Searching for workspace: ${workspaceName}...`));
7886
- const response = await orgAuthenticatedFetch(
7887
- `/v1/workspaces?name=${encodeURIComponent(workspaceName)}`
7888
- );
7889
- if (response.workspaces.length === 0) {
7890
- throw new Error(`No workspaces found with name matching "${workspaceName}".`);
7891
- }
7892
- let selectedWorkspace;
7893
- if (response.workspaces.length === 1) {
7894
- selectedWorkspace = response.workspaces[0];
7895
- } else {
7896
- console.log(import_chalk4.default.yellow(`
7897
- Found ${response.workspaces.length} workspaces matching "${workspaceName}":`));
7898
- const selectResponse = await (0, import_prompts.default)({
7899
- type: "select",
7900
- name: "workspaceId",
7901
- message: "Select a workspace:",
7902
- choices: response.workspaces.map((ws) => ({
7903
- title: `${ws.name} (${ws.status || "unknown"})`,
7904
- value: ws.id,
7905
- description: `Status: ${ws.status || "unknown"}`
7906
- }))
7907
- });
7908
- if (!selectResponse.workspaceId) {
7909
- throw new Error("Workspace selection cancelled.");
7910
- }
7911
- selectedWorkspace = response.workspaces.find((ws) => ws.id === selectResponse.workspaceId);
7912
- }
7913
- console.log(import_chalk4.default.green(`
7914
- \u2713 Selected workspace: ${selectedWorkspace.name}`));
7915
- console.log(import_chalk4.default.gray(` Status: ${selectedWorkspace.status || "unknown"}`));
7916
- if (selectedWorkspace.status === "sleeping") {
7917
- throw new Error(
7918
- "Workspace is currently sleeping. Please wake it up in the dashboard at https://replicas.dev before connecting."
7919
- );
7920
- }
7921
- console.log(import_chalk4.default.blue("\nRequesting SSH access token..."));
7922
- const tokenResponse = await orgAuthenticatedFetch(
7923
- `/v1/workspaces/${selectedWorkspace.id}/ssh-token`,
7924
- { method: "POST" }
7925
- );
7926
- console.log(import_chalk4.default.green("\u2713 SSH token received"));
7927
- let repoName = null;
7928
- if (isInsideGitRepo()) {
7929
- try {
7930
- repoName = getGitRepoName();
7931
- } catch {
7932
- }
7933
- }
7934
- return {
7935
- workspace: selectedWorkspace,
7936
- sshToken: tokenResponse.token,
7937
- sshHost: tokenResponse.host,
7938
- repoName
7939
- };
7940
- }
7941
-
7942
- // src/commands/connect.ts
7943
- async function connectCommand(workspaceName) {
7944
- if (!isAuthenticated()) {
7945
- console.log(import_chalk5.default.red('Not logged in. Please run "replicas login" first.'));
7946
- process.exit(1);
7947
- }
7948
- try {
7949
- const { workspace, sshToken, sshHost } = await prepareWorkspaceConnection(workspaceName);
7950
- console.log(import_chalk5.default.blue(`
7951
- Connecting to ${workspace.name}...`));
7952
- const sshCommand = `ssh ${sshToken}@${sshHost}`;
7953
- console.log(import_chalk5.default.gray(`SSH command: ${sshCommand}`));
7954
- console.log(import_chalk5.default.gray("\nPress Ctrl+D to disconnect.\n"));
7955
- await connectSSH(sshToken, sshHost);
7956
- console.log(import_chalk5.default.green("\n\u2713 Disconnected from workspace.\n"));
7957
- } catch (error) {
7958
- console.error(import_chalk5.default.red(`
7959
- Error: ${error instanceof Error ? error.message : "Unknown error"}`));
7960
- process.exit(1);
7961
- }
7962
- }
7963
-
7964
- // src/commands/code.ts
7965
- var import_chalk6 = __toESM(require("chalk"));
7966
- var import_child_process3 = require("child_process");
7967
-
7968
7500
  // ../shared/src/sandbox.ts
7969
7501
  var SANDBOX_LIFECYCLE = {
7970
7502
  AUTO_STOP_MINUTES: 60,
@@ -7992,9 +7524,15 @@ var MAX_WARM_HOOK_TIMEOUT_MS = 15 * 60 * 1e3;
7992
7524
  // ../shared/src/replicas-config.ts
7993
7525
  var REPLICAS_CONFIG_FILENAMES = ["replicas.json", "replicas.yaml", "replicas.yml"];
7994
7526
 
7995
- // ../shared/src/routes/workspaces.ts
7996
- var WORKSPACE_FILE_UPLOAD_MAX_SIZE_BYTES = 20 * 1024 * 1024;
7997
- var WORKSPACE_FILE_CONTENT_MAX_SIZE_BYTES = 1 * 1024 * 1024;
7527
+ // ../shared/src/prompts.ts
7528
+ var REPLICAS_INSTRUCTIONS_TAG = "replicas_instructions";
7529
+ function removeTag(text, tag) {
7530
+ const regex = new RegExp(`<${tag}>[\\s\\S]*?</${tag}>`, "g");
7531
+ return text.replace(regex, "").trim();
7532
+ }
7533
+ function removeReplicasInstructions(text) {
7534
+ return removeTag(text, REPLICAS_INSTRUCTIONS_TAG);
7535
+ }
7998
7536
 
7999
7537
  // ../shared/src/display-message/parsers/codex-parser.ts
8000
7538
  function safeJsonParse(str, fallback) {
@@ -8281,7 +7819,7 @@ function parseClaudeEvents(events, parentToolUseId) {
8281
7819
  toolName,
8282
7820
  input: toolInput
8283
7821
  });
8284
- if (toolName === "Task") {
7822
+ if (toolName === "Task" || toolName === "Agent") {
8285
7823
  const inputObj = typeof toolInput === "string" ? safeJsonParse2(toolInput, {}) : toolInput;
8286
7824
  const nestedEvents = events.filter((e) => e.payload.parent_tool_use_id === toolUseId).map((e) => ({
8287
7825
  timestamp: e.timestamp,
@@ -8315,19 +7853,28 @@ function parseClaudeEvents(events, parentToolUseId) {
8315
7853
  const inputObj = typeof toolInput === "string" ? safeJsonParse2(toolInput, {}) : toolInput;
8316
7854
  const filePath = inputObj.file_path || "";
8317
7855
  const action = toolName === "Write" ? "add" : "update";
7856
+ let diff;
7857
+ if (toolName === "Edit" && inputObj.old_string != null && inputObj.new_string != null) {
7858
+ const oldLines = inputObj.old_string.replace(/\n$/, "").split("\n").map((l) => `-${l}`);
7859
+ const newLines = inputObj.new_string.replace(/\n$/, "").split("\n").map((l) => `+${l}`);
7860
+ diff = [...oldLines, ...newLines].join("\n");
7861
+ } else if (toolName === "Write" && inputObj.content != null) {
7862
+ diff = inputObj.content.replace(/\n$/, "").split("\n").map((l) => `+${l}`).join("\n");
7863
+ }
8318
7864
  messages.push({
8319
- id: `file-${event.timestamp}-${messages.length}`,
8320
- type: "file_change",
8321
- changes: [{
7865
+ id: `patch-${event.timestamp}-${messages.length}`,
7866
+ type: "patch",
7867
+ operations: [{
7868
+ action,
8322
7869
  path: filePath,
8323
- kind: action
7870
+ diff
8324
7871
  }],
8325
7872
  status: "in_progress",
8326
7873
  timestamp: event.timestamp
8327
7874
  });
8328
7875
  } else if (toolName === "TodoWrite") {
8329
7876
  const inputObj = typeof toolInput === "string" ? safeJsonParse2(toolInput, {}) : toolInput;
8330
- const todos = inputObj.todos || [];
7877
+ const todos = Array.isArray(inputObj.todos) ? inputObj.todos : [];
8331
7878
  const todoItems = todos.map((todo) => ({
8332
7879
  text: todo.content,
8333
7880
  completed: todo.status === "completed"
@@ -8410,7 +7957,7 @@ function parseClaudeEvents(events, parentToolUseId) {
8410
7957
  } else {
8411
7958
  message.exitCode = isError ? 1 : 0;
8412
7959
  }
8413
- } else if (message.type === "file_change") {
7960
+ } else if (message.type === "patch") {
8414
7961
  message.status = status;
8415
7962
  } else if (message.type === "web_search") {
8416
7963
  message.status = status;
@@ -8430,6 +7977,7 @@ function parseClaudeEvents(events, parentToolUseId) {
8430
7977
  }
8431
7978
 
8432
7979
  // ../shared/src/display-message/parsers/index.ts
7980
+ var INTERRUPTED_MESSAGE_REGEX = /^\[Request interrupted by user.*\]$/;
8433
7981
  function parseAgentEvents(events, agentType) {
8434
7982
  if (agentType === "codex") {
8435
7983
  return parseCodexEvents(events);
@@ -8438,1669 +7986,261 @@ function parseAgentEvents(events, agentType) {
8438
7986
  }
8439
7987
  return [];
8440
7988
  }
8441
-
8442
- // src/lib/ssh-config.ts
8443
- var import_fs2 = __toESM(require("fs"));
8444
- var import_path3 = __toESM(require("path"));
8445
- var import_os2 = __toESM(require("os"));
8446
- var SSH_CONFIG_PATH = import_path3.default.join(import_os2.default.homedir(), ".ssh", "config");
8447
- var REPLICAS_MARKER_START = "# === REPLICAS CLI MANAGED ENTRY START ===";
8448
- var REPLICAS_MARKER_END = "# === REPLICAS CLI MANAGED ENTRY END ===";
8449
- function ensureSSHDir() {
8450
- const sshDir = import_path3.default.join(import_os2.default.homedir(), ".ssh");
8451
- if (!import_fs2.default.existsSync(sshDir)) {
8452
- import_fs2.default.mkdirSync(sshDir, { recursive: true, mode: 448 });
8453
- }
8454
- }
8455
- function readSSHConfig() {
8456
- ensureSSHDir();
8457
- if (!import_fs2.default.existsSync(SSH_CONFIG_PATH)) {
8458
- return "";
8459
- }
8460
- return import_fs2.default.readFileSync(SSH_CONFIG_PATH, "utf-8");
8461
- }
8462
- function writeSSHConfig(content) {
8463
- ensureSSHDir();
8464
- import_fs2.default.writeFileSync(SSH_CONFIG_PATH, content, { mode: 384 });
8465
- }
8466
- function generateConfigBlock(entry) {
8467
- const lines = [
8468
- REPLICAS_MARKER_START,
8469
- `Host ${entry.host}`,
8470
- ` HostName ${entry.hostname}`,
8471
- ` User ${entry.user}`,
8472
- ` StrictHostKeyChecking no`,
8473
- ` UserKnownHostsFile /dev/null`
8474
- ];
8475
- lines.push(REPLICAS_MARKER_END);
8476
- return lines.join("\n");
8477
- }
8478
- function addOrUpdateSSHConfigEntry(entry) {
8479
- let config2 = readSSHConfig();
8480
- const lines = config2.split("\n");
8481
- const result = [];
8482
- let inTargetBlock = false;
8483
- for (const line of lines) {
8484
- if (line.trim() === REPLICAS_MARKER_START) {
8485
- const nextLines = lines.slice(lines.indexOf(line) + 1, lines.indexOf(line) + 3);
8486
- const hostLine = nextLines.find((l) => l.trim().startsWith("Host "));
8487
- if (hostLine && hostLine.includes(entry.host)) {
8488
- inTargetBlock = true;
8489
- continue;
8490
- }
8491
- result.push(line);
8492
- continue;
8493
- }
8494
- if (line.trim() === REPLICAS_MARKER_END) {
8495
- if (inTargetBlock) {
8496
- inTargetBlock = false;
8497
- continue;
8498
- }
8499
- result.push(line);
8500
- continue;
8501
- }
8502
- if (inTargetBlock) {
8503
- continue;
8504
- }
8505
- result.push(line);
8506
- }
8507
- config2 = result.join("\n");
8508
- const newEntry = generateConfigBlock(entry);
8509
- let finalConfig = config2.trim();
8510
- if (finalConfig.length > 0) {
8511
- finalConfig += "\n\n";
8512
- }
8513
- finalConfig += newEntry + "\n";
8514
- writeSSHConfig(finalConfig);
8515
- }
8516
- function getWorkspaceHostAlias(workspaceName) {
8517
- return `replicas-${workspaceName.toLowerCase().replace(/[^a-z0-9-]/g, "-")}`;
8518
- }
8519
-
8520
- // src/commands/code.ts
8521
- async function codeCommand(workspaceName) {
8522
- if (!isAuthenticated()) {
8523
- console.log(import_chalk6.default.red('Not logged in. Please run "replicas login" first.'));
8524
- process.exit(1);
8525
- }
8526
- try {
8527
- const { workspace, sshToken, sshHost, repoName } = await prepareWorkspaceConnection(workspaceName);
8528
- const hostAlias = getWorkspaceHostAlias(workspace.name);
8529
- console.log(import_chalk6.default.blue("\nConfiguring SSH connection..."));
8530
- addOrUpdateSSHConfigEntry({
8531
- host: hostAlias,
8532
- hostname: sshHost,
8533
- user: sshToken
8534
- });
8535
- console.log(import_chalk6.default.green(`\u2713 SSH config entry created: ${hostAlias}`));
8536
- const remotePath = repoName ? `${SANDBOX_PATHS.WORKSPACES_DIR}/${repoName}` : SANDBOX_PATHS.HOME_DIR;
8537
- const ideCommand = getIdeCommand();
8538
- const fullCommand = `${ideCommand} --remote ssh-remote+${hostAlias} ${remotePath}`;
8539
- console.log(import_chalk6.default.blue(`
8540
- Opening ${ideCommand} for workspace ${workspace.name}...`));
8541
- console.log(import_chalk6.default.gray(`Command: ${fullCommand}`));
8542
- console.log(import_chalk6.default.yellow(`
8543
- Note: SSH tokens expire after 3 hours. Run this command again to refresh.`));
8544
- const ide = (0, import_child_process3.spawn)(ideCommand, [
8545
- "--remote",
8546
- `ssh-remote+${hostAlias}`,
8547
- remotePath
8548
- ], {
8549
- stdio: "inherit",
8550
- detached: false
8551
- });
8552
- ide.on("error", (error) => {
8553
- console.error(import_chalk6.default.red(`
8554
- Failed to launch ${ideCommand}: ${error.message}`));
8555
- console.log(import_chalk6.default.yellow(`
8556
- Make sure ${ideCommand} is installed and available in your PATH.`));
8557
- console.log(import_chalk6.default.gray(`You can configure a different IDE with: replicas config set ide <command>`));
8558
- process.exit(1);
8559
- });
8560
- ide.on("close", (code) => {
8561
- if (code === 0) {
8562
- console.log(import_chalk6.default.green(`
8563
- \u2713 ${ideCommand} closed successfully.
8564
- `));
8565
- }
8566
- });
8567
- } catch (error) {
8568
- console.error(import_chalk6.default.red(`
8569
- Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8570
- process.exit(1);
8571
- }
8572
- }
8573
-
8574
- // src/commands/org.ts
8575
- var import_chalk7 = __toESM(require("chalk"));
8576
- var import_prompts3 = __toESM(require("prompts"));
8577
- async function orgCommand() {
8578
- if (!isAuthenticated()) {
8579
- console.log(import_chalk7.default.red('Not logged in. Please run "replicas login" first.'));
8580
- process.exit(1);
8581
- }
8582
- try {
8583
- const currentOrgId = getOrganizationId();
8584
- const organizations = await fetchOrganizations();
8585
- if (!currentOrgId) {
8586
- console.log(import_chalk7.default.yellow("No organization selected."));
8587
- console.log(import_chalk7.default.gray('Run "replicas org switch" to select an organization.\n'));
8588
- return;
8589
- }
8590
- const currentOrg = organizations.find((org2) => org2.id === currentOrgId);
8591
- if (!currentOrg) {
8592
- console.log(import_chalk7.default.yellow(`Current organization ID (${currentOrgId}) not found.`));
8593
- console.log(import_chalk7.default.gray('Run "replicas org switch" to select a new organization.\n'));
8594
- return;
8595
- }
8596
- console.log(import_chalk7.default.green("\nCurrent organization:"));
8597
- console.log(import_chalk7.default.gray(` Name: ${currentOrg.name}`));
8598
- console.log(import_chalk7.default.gray(` ID: ${currentOrg.id}
8599
- `));
8600
- } catch (error) {
8601
- console.error(import_chalk7.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8602
- process.exit(1);
8603
- }
7989
+ function createUserMessage(content) {
7990
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
7991
+ return {
7992
+ message: {
7993
+ id: `user-${Date.now()}`,
7994
+ type: "user",
7995
+ content,
7996
+ timestamp
7997
+ },
7998
+ timestamp
7999
+ };
8604
8000
  }
8605
- async function orgSwitchCommand() {
8606
- if (!isAuthenticated()) {
8607
- console.log(import_chalk7.default.red('Not logged in. Please run "replicas login" first.'));
8608
- process.exit(1);
8609
- }
8610
- try {
8611
- const organizations = await fetchOrganizations();
8612
- if (organizations.length === 0) {
8613
- console.log(import_chalk7.default.yellow("You are not a member of any organization."));
8614
- console.log(import_chalk7.default.gray("Please contact support.\n"));
8615
- return;
8616
- }
8617
- if (organizations.length === 1) {
8618
- await setActiveOrganization(organizations[0].id);
8619
- console.log(import_chalk7.default.green(`
8620
- \u2713 Organization set to: ${organizations[0].name}
8621
- `));
8622
- return;
8623
- }
8624
- const currentOrgId = getOrganizationId();
8625
- const response = await (0, import_prompts3.default)({
8626
- type: "select",
8627
- name: "organizationId",
8628
- message: "Select an organization:",
8629
- choices: organizations.map((org2) => ({
8630
- title: `${org2.name}${org2.id === currentOrgId ? " (current)" : ""}`,
8631
- value: org2.id,
8632
- description: org2.id
8633
- })),
8634
- initial: organizations.findIndex((org2) => org2.id === currentOrgId)
8635
- });
8636
- if (!response.organizationId) {
8637
- console.log(import_chalk7.default.yellow("\nCancelled."));
8638
- return;
8639
- }
8640
- await setActiveOrganization(response.organizationId);
8641
- const selectedOrg = organizations.find((org2) => org2.id === response.organizationId);
8642
- console.log(import_chalk7.default.green(`
8643
- \u2713 Switched to organization: ${selectedOrg?.name}
8644
- `));
8645
- } catch (error) {
8646
- console.error(import_chalk7.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8647
- process.exit(1);
8648
- }
8001
+ function isAgentBackendEvent(value) {
8002
+ if (!value || typeof value !== "object") return false;
8003
+ const candidate = value;
8004
+ return typeof candidate.timestamp === "string" && typeof candidate.type === "string" && typeof candidate.payload === "object" && candidate.payload !== null;
8649
8005
  }
8650
-
8651
- // src/commands/config.ts
8652
- var import_chalk8 = __toESM(require("chalk"));
8653
- async function configGetCommand(key) {
8654
- if (!isAuthenticated()) {
8655
- console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
8656
- process.exit(1);
8657
- }
8658
- try {
8659
- if (key === "ide") {
8660
- const ideCommand = getIdeCommand();
8661
- console.log(import_chalk8.default.green(`
8662
- IDE command: ${ideCommand}
8663
- `));
8664
- } else {
8665
- console.log(import_chalk8.default.red(`Unknown config key: ${key}`));
8666
- console.log(import_chalk8.default.gray("Available keys: ide"));
8667
- process.exit(1);
8006
+ function filterDisplayMessages(messages, provider) {
8007
+ let result = messages;
8008
+ if (provider === "codex") {
8009
+ const userMessages = result.map((msg, index) => ({ msg, index })).filter(({ msg }) => msg.type === "user");
8010
+ if (userMessages.length >= 2) {
8011
+ result = result.slice(userMessages[1].index);
8668
8012
  }
8669
- } catch (error) {
8670
- console.error(import_chalk8.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8671
- process.exit(1);
8672
- }
8673
- }
8674
- async function configSetCommand(key, value) {
8675
- if (!isAuthenticated()) {
8676
- console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
8677
- process.exit(1);
8678
8013
  }
8679
- try {
8680
- if (key === "ide") {
8681
- setIdeCommand(value);
8682
- console.log(import_chalk8.default.green(`
8683
- \u2713 IDE command set to: ${value}
8684
- `));
8685
- } else {
8686
- console.log(import_chalk8.default.red(`Unknown config key: ${key}`));
8687
- console.log(import_chalk8.default.gray("Available keys: ide"));
8688
- process.exit(1);
8014
+ result = result.map((msg) => {
8015
+ if (msg.type !== "user") return msg;
8016
+ const cleaned = removeReplicasInstructions(msg.content).trim();
8017
+ if (INTERRUPTED_MESSAGE_REGEX.test(cleaned)) {
8018
+ return { ...msg, content: "Request interrupted" };
8689
8019
  }
8690
- } catch (error) {
8691
- console.error(import_chalk8.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8692
- process.exit(1);
8693
- }
8694
- }
8695
- async function configListCommand() {
8696
- if (!isAuthenticated()) {
8697
- console.log(import_chalk8.default.red('Not logged in. Please run "replicas login" first.'));
8698
- process.exit(1);
8699
- }
8700
- try {
8701
- const config2 = readConfig();
8702
- if (!config2) {
8703
- console.log(import_chalk8.default.red("No config found. Please login first."));
8704
- process.exit(1);
8705
- }
8706
- console.log(import_chalk8.default.green("\nCurrent configuration:"));
8707
- console.log(import_chalk8.default.gray(` Organization ID: ${config2.organization_id || "(not set)"}`));
8708
- console.log(import_chalk8.default.gray(` IDE command: ${config2.ide_command || "code (default)"}`));
8709
- console.log();
8710
- } catch (error) {
8711
- console.error(import_chalk8.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
8712
- process.exit(1);
8713
- }
8020
+ return cleaned !== msg.content ? { ...msg, content: cleaned } : msg;
8021
+ });
8022
+ return result;
8714
8023
  }
8715
8024
 
8716
- // src/commands/codex-auth.ts
8717
- var import_chalk9 = __toESM(require("chalk"));
8718
-
8719
- // src/lib/codex-oauth.ts
8720
- var import_http2 = __toESM(require("http"));
8721
- var import_url2 = require("url");
8722
- var import_open2 = __toESM(require("open"));
8723
-
8724
- // src/lib/pkce.ts
8725
- var import_crypto = require("crypto");
8726
- function generatePkceCodes() {
8727
- const verifierBytes = (0, import_crypto.randomBytes)(32);
8728
- const codeVerifier = verifierBytes.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
8729
- const hash = (0, import_crypto.createHash)("sha256");
8730
- hash.update(codeVerifier);
8731
- const codeChallenge = hash.digest("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
8732
- return {
8733
- codeVerifier,
8734
- codeChallenge
8735
- };
8025
+ // ../shared/src/placeholder-names.ts
8026
+ var FRUITS = [
8027
+ "apple",
8028
+ "banana",
8029
+ "cherry",
8030
+ "fig",
8031
+ "grape",
8032
+ "kiwi",
8033
+ "lemon",
8034
+ "lime",
8035
+ "mango",
8036
+ "melon",
8037
+ "olive",
8038
+ "orange",
8039
+ "peach",
8040
+ "pear",
8041
+ "plum",
8042
+ "guava",
8043
+ "papaya",
8044
+ "lychee",
8045
+ "coconut",
8046
+ "apricot",
8047
+ "avocado",
8048
+ "berry",
8049
+ "kumquat",
8050
+ "nectarine",
8051
+ "tangerine",
8052
+ "dragonfruit"
8053
+ ];
8054
+ var TTC_STATIONS = [
8055
+ "kipling",
8056
+ "islington",
8057
+ "royal-york",
8058
+ "old-mill",
8059
+ "jane",
8060
+ "runnymede",
8061
+ "high-park",
8062
+ "keele",
8063
+ "dundas-west",
8064
+ "lansdowne",
8065
+ "dufferin",
8066
+ "ossington",
8067
+ "christie",
8068
+ "bathurst",
8069
+ "spadina",
8070
+ "st-george",
8071
+ "bay",
8072
+ "bloor-yonge",
8073
+ "sherbourne",
8074
+ "castle-frank",
8075
+ "broadview",
8076
+ "chester",
8077
+ "pape",
8078
+ "donlands",
8079
+ "greenwood",
8080
+ "woodbine",
8081
+ "warden",
8082
+ "kennedy"
8083
+ ];
8084
+ function randomElement(arr) {
8085
+ return arr[Math.floor(Math.random() * arr.length)];
8736
8086
  }
8737
- function generateState2() {
8738
- return (0, import_crypto.randomBytes)(16).toString("hex");
8087
+ function generatePlaceholderName() {
8088
+ return `${randomElement(FRUITS)}-${randomElement(TTC_STATIONS)}`;
8739
8089
  }
8740
8090
 
8741
- // src/lib/codex-oauth.ts
8742
- var CODEX_OAUTH_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
8743
- var AUTHORIZATION_ENDPOINT = "https://auth.openai.com/oauth/authorize";
8744
- var TOKEN_ENDPOINT = "https://auth.openai.com/oauth/token";
8745
- var CALLBACK_PORT = 1455;
8746
- var CALLBACK_PATH = "/auth/callback";
8747
- var WEB_APP_URL2 = process.env.REPLICAS_WEB_URL || "https://replicas.dev";
8748
- function buildAuthorizationUrl(codeChallenge, state) {
8749
- const redirectUri = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
8750
- const params = new URLSearchParams({
8751
- response_type: "code",
8752
- client_id: CODEX_OAUTH_CLIENT_ID,
8753
- redirect_uri: redirectUri,
8754
- scope: "openid profile email offline_access",
8755
- code_challenge: codeChallenge,
8756
- code_challenge_method: "S256",
8757
- id_token_add_organizations: "true",
8758
- codex_cli_simplified_flow: "true",
8759
- state,
8760
- originator: "codex_cli_rs"
8761
- });
8762
- return `${AUTHORIZATION_ENDPOINT}?${params.toString()}`;
8763
- }
8764
- async function exchangeCodeForTokens(code, codeVerifier) {
8765
- const redirectUri = `http://localhost:${CALLBACK_PORT}${CALLBACK_PATH}`;
8766
- const params = new URLSearchParams({
8767
- grant_type: "authorization_code",
8768
- code,
8769
- redirect_uri: redirectUri,
8770
- client_id: CODEX_OAUTH_CLIENT_ID,
8771
- code_verifier: codeVerifier
8772
- });
8773
- const response = await fetch(TOKEN_ENDPOINT, {
8774
- method: "POST",
8775
- headers: {
8776
- "Content-Type": "application/x-www-form-urlencoded"
8777
- },
8778
- body: params.toString()
8779
- });
8780
- if (!response.ok) {
8781
- const errorText = await response.text();
8782
- throw new Error(`Failed to exchange code for tokens: ${response.status} ${errorText}`);
8783
- }
8784
- const data = await response.json();
8785
- return {
8786
- idToken: data.id_token,
8787
- accessToken: data.access_token,
8788
- refreshToken: data.refresh_token
8789
- };
8790
- }
8791
- function startCallbackServer(expectedState, codeVerifier) {
8792
- return new Promise((resolve, reject) => {
8793
- const server = import_http2.default.createServer(async (req, res) => {
8794
- try {
8795
- if (!req.url) {
8796
- res.writeHead(400);
8797
- res.end("Bad Request");
8798
- return;
8799
- }
8800
- const url = new import_url2.URL(req.url, `http://127.0.0.1:${CALLBACK_PORT}`);
8801
- if (url.pathname === CALLBACK_PATH) {
8802
- const code = url.searchParams.get("code");
8803
- const state = url.searchParams.get("state");
8804
- const error = url.searchParams.get("error");
8805
- const errorDescription = url.searchParams.get("error_description");
8806
- if (error) {
8807
- const errorMessage = encodeURIComponent(`${error}: ${errorDescription || "Unknown error"}`);
8808
- res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
8809
- res.end();
8810
- server.close();
8811
- reject(new Error(`OAuth error: ${error} - ${errorDescription}`));
8812
- return;
8813
- }
8814
- if (state !== expectedState) {
8815
- const errorMessage = encodeURIComponent("State parameter mismatch. Possible CSRF attack.");
8816
- res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
8817
- res.end();
8818
- server.close();
8819
- reject(new Error("State mismatch - possible CSRF attack"));
8820
- return;
8821
- }
8822
- if (!code) {
8823
- const errorMessage = encodeURIComponent("No authorization code received.");
8824
- res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
8825
- res.end();
8826
- server.close();
8827
- reject(new Error("No authorization code received"));
8828
- return;
8829
- }
8830
- try {
8831
- const tokens = await exchangeCodeForTokens(code, codeVerifier);
8832
- res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/success` });
8833
- res.end();
8834
- server.close();
8835
- resolve(tokens);
8836
- } catch (tokenError) {
8837
- const errorMessage = encodeURIComponent(tokenError instanceof Error ? tokenError.message : "Unknown error");
8838
- res.writeHead(302, { "Location": `${WEB_APP_URL2}/codex/oauth/error?message=${errorMessage}` });
8839
- res.end();
8840
- server.close();
8841
- reject(tokenError);
8091
+ // ../shared/src/workspace-groups.ts
8092
+ function buildGroups(workspaces, workspacesData, repositories, repositorySets, mockGroupAssignments) {
8093
+ const groupMap = /* @__PURE__ */ new Map();
8094
+ for (const repo of repositories) {
8095
+ groupMap.set(repo.id, { type: "repo", id: repo.id, name: repo.name, url: repo.url, workspaces: [] });
8096
+ }
8097
+ for (const repoSet of repositorySets) {
8098
+ const setKey = `set:${repoSet.id}`;
8099
+ groupMap.set(setKey, { type: "set", id: setKey, name: repoSet.name, workspaces: [] });
8100
+ }
8101
+ const allWsRepos = workspacesData?.workspace_repositories ?? [];
8102
+ for (const workspace of workspaces) {
8103
+ const repos = allWsRepos.filter((r) => r.workspace_id === workspace.id);
8104
+ if (repos.length > 0) {
8105
+ let placedInSet = false;
8106
+ for (const repoSet of repositorySets) {
8107
+ const setRepoIds = new Set(repoSet.repositories.map((r) => r.id));
8108
+ const wsRepoIds = repos.map((r) => r.id);
8109
+ if (wsRepoIds.length > 1 && wsRepoIds.every((id) => setRepoIds.has(id))) {
8110
+ const setKey = `set:${repoSet.id}`;
8111
+ if (groupMap.has(setKey)) {
8112
+ groupMap.get(setKey).workspaces.push(workspace);
8113
+ placedInSet = true;
8114
+ break;
8842
8115
  }
8843
- } else {
8844
- res.writeHead(404);
8845
- res.end("Not Found");
8846
8116
  }
8847
- } catch (serverError) {
8848
- res.writeHead(500);
8849
- res.end("Internal Server Error");
8850
- server.close();
8851
- reject(serverError);
8852
- }
8853
- });
8854
- server.on("error", (err) => {
8855
- if (err.code === "EADDRINUSE") {
8856
- reject(new Error(`Port ${CALLBACK_PORT} is already in use. Please close any other OAuth flows and try again.`));
8857
- } else {
8858
- reject(err);
8859
8117
  }
8860
- });
8861
- server.listen(CALLBACK_PORT, "127.0.0.1");
8862
- });
8863
- }
8864
- async function runCodexOAuthFlow() {
8865
- const pkce = generatePkceCodes();
8866
- const state = generateState2();
8867
- const authUrl = buildAuthorizationUrl(pkce.codeChallenge, state);
8868
- const tokensPromise = startCallbackServer(state, pkce.codeVerifier);
8869
- await new Promise((resolve) => setTimeout(resolve, 500));
8870
- console.log("If the browser does not open automatically, visit:");
8871
- console.log(authUrl);
8872
- console.log();
8873
- try {
8874
- await (0, import_open2.default)(authUrl);
8875
- } catch (openError) {
8876
- console.warn("Failed to open browser automatically. Please open the URL manually.");
8877
- }
8878
- console.log("Waiting for authentication...");
8879
- const tokens = await tokensPromise;
8880
- console.log("\u2713 Successfully obtained Codex credentials");
8881
- return tokens;
8882
- }
8883
-
8884
- // src/commands/codex-auth.ts
8885
- async function codexAuthCommand(options = {}) {
8886
- const isUserScoped = options.user === true;
8887
- const scopeLabel = isUserScoped ? "personal" : "organization";
8888
- console.log(import_chalk9.default.cyan(`Authenticating with Codex (${scopeLabel})...
8889
- `));
8890
- try {
8891
- const tokens = await runCodexOAuthFlow();
8892
- console.log(import_chalk9.default.gray("\nUploading credentials to Replicas..."));
8893
- const endpoint = isUserScoped ? "/v1/codex/user/credentials" : "/v1/codex/credentials";
8894
- const response = await orgAuthenticatedFetch(
8895
- endpoint,
8896
- {
8897
- method: "POST",
8898
- body: {
8899
- access_token: tokens.accessToken,
8900
- refresh_token: tokens.refreshToken,
8901
- id_token: tokens.idToken
8118
+ if (!placedInSet) {
8119
+ const primaryRepo = repos[0];
8120
+ const group = groupMap.get(primaryRepo.id);
8121
+ if (group) {
8122
+ group.workspaces.push(workspace);
8123
+ } else {
8124
+ groupMap.set(primaryRepo.id, {
8125
+ type: "repo",
8126
+ id: primaryRepo.id,
8127
+ name: primaryRepo.name,
8128
+ url: primaryRepo.url,
8129
+ workspaces: [workspace]
8130
+ });
8902
8131
  }
8903
8132
  }
8904
- );
8905
- if (response.success) {
8906
- console.log(import_chalk9.default.green("\n\u2713 Codex authentication complete!"));
8907
- if (response.email) {
8908
- console.log(import_chalk9.default.gray(` Account: ${response.email}`));
8909
- }
8910
- if (response.planType) {
8911
- console.log(import_chalk9.default.gray(` Plan: ${response.planType}`));
8912
- }
8913
- if (isUserScoped) {
8914
- console.log(import_chalk9.default.gray("\nYour personal Codex credentials have been saved.\n"));
8915
- } else {
8916
- console.log(import_chalk9.default.gray("\nYou can now use Codex in your workspaces.\n"));
8917
- }
8918
8133
  } else {
8919
- throw new Error(response.error || "Failed to upload Codex credentials to Replicas");
8920
- }
8921
- } catch (error) {
8922
- console.log(import_chalk9.default.red("\n\u2717 Error:"), error instanceof Error ? error.message : error);
8923
- process.exit(1);
8924
- }
8925
- }
8926
-
8927
- // src/commands/claude-auth.ts
8928
- var import_chalk11 = __toESM(require("chalk"));
8929
-
8930
- // src/lib/claude-oauth.ts
8931
- var import_open3 = __toESM(require("open"));
8932
- var import_readline = __toESM(require("readline"));
8933
- var import_chalk10 = __toESM(require("chalk"));
8934
- var DEFAULT_CLIENT_ID = "9d1c250a-e61b-44d9-88ed-5944d1962f5e";
8935
- var CLAUDE_CLIENT_ID = process.env.CLAUDE_OAUTH_CLIENT_ID || DEFAULT_CLIENT_ID;
8936
- var AUTHORIZATION_ENDPOINT2 = "https://claude.ai/oauth/authorize";
8937
- var TOKEN_ENDPOINT2 = "https://console.anthropic.com/v1/oauth/token";
8938
- var REDIRECT_URI = "https://console.anthropic.com/oauth/code/callback";
8939
- var SCOPES = "org:create_api_key user:profile user:inference";
8940
- function buildAuthorizationUrl2(codeChallenge, state) {
8941
- const params = new URLSearchParams({
8942
- code: "true",
8943
- client_id: CLAUDE_CLIENT_ID,
8944
- response_type: "code",
8945
- redirect_uri: REDIRECT_URI,
8946
- scope: SCOPES,
8947
- code_challenge: codeChallenge,
8948
- code_challenge_method: "S256",
8949
- state
8950
- });
8951
- return `${AUTHORIZATION_ENDPOINT2}?${params.toString()}`;
8952
- }
8953
- async function promptForAuthorizationCode(instruction) {
8954
- const rl = import_readline.default.createInterface({
8955
- input: process.stdin,
8956
- output: process.stdout
8957
- });
8958
- return new Promise((resolve) => {
8959
- rl.question(instruction, (answer) => {
8960
- rl.close();
8961
- resolve(answer.trim());
8962
- });
8963
- });
8964
- }
8965
- function parseUserInput(input) {
8966
- if (!input.includes("#") && !input.includes("code=")) {
8967
- return { code: input };
8968
- }
8969
- if (input.startsWith("http://") || input.startsWith("https://")) {
8970
- try {
8971
- const url = new URL(input);
8972
- const fragment = url.hash.startsWith("#") ? url.hash.slice(1) : url.hash;
8973
- const params = new URLSearchParams(fragment);
8974
- const code2 = params.get("code") ?? void 0;
8975
- const state2 = params.get("state") ?? void 0;
8976
- if (code2) {
8977
- return { code: code2, state: state2 };
8134
+ const assignedGroup = mockGroupAssignments.get(workspace.id);
8135
+ if (assignedGroup && groupMap.has(assignedGroup)) {
8136
+ groupMap.get(assignedGroup).workspaces.push(workspace);
8137
+ } else {
8138
+ const key = "__ungrouped__";
8139
+ if (!groupMap.has(key)) {
8140
+ groupMap.set(key, { type: "repo", id: key, name: "Other", workspaces: [] });
8141
+ }
8142
+ groupMap.get(key).workspaces.push(workspace);
8978
8143
  }
8979
- } catch {
8980
8144
  }
8981
8145
  }
8982
- const [code, state] = input.split("#");
8983
- return { code, state };
8146
+ return Array.from(groupMap.values()).sort((a, b) => a.name.localeCompare(b.name));
8984
8147
  }
8985
- async function exchangeCodeForTokens2(code, state, expectedState, codeVerifier) {
8986
- if (state && state !== expectedState) {
8987
- throw new Error("State mismatch detected. Please restart the authentication flow.");
8988
- }
8989
- const payload = {
8990
- code,
8991
- state: state ?? expectedState,
8992
- grant_type: "authorization_code",
8993
- client_id: CLAUDE_CLIENT_ID,
8994
- redirect_uri: REDIRECT_URI,
8995
- code_verifier: codeVerifier
8996
- };
8997
- const response = await fetch(TOKEN_ENDPOINT2, {
8998
- method: "POST",
8999
- headers: {
9000
- "Content-Type": "application/json"
9001
- },
9002
- body: JSON.stringify(payload)
9003
- });
9004
- if (!response.ok) {
9005
- const text = await response.text();
9006
- throw new Error(`Failed to exchange authorization code: ${response.status} ${text}`);
9007
- }
9008
- const data = await response.json();
9009
- const now = Date.now();
9010
- const expiresAt = new Date(now + data.expires_in * 1e3).toISOString();
9011
- const refreshTokenExpiresAt = data.refresh_token_expires_in ? new Date(now + data.refresh_token_expires_in * 1e3).toISOString() : void 0;
8148
+ function createMockWorkspaceRecord(organizationId, name) {
8149
+ const id = "mock-" + Array.from(
8150
+ { length: 4 },
8151
+ () => Math.random().toString(36).slice(2, 6)
8152
+ ).join("-");
9012
8153
  return {
9013
- accessToken: data.access_token,
9014
- refreshToken: data.refresh_token,
9015
- tokenType: data.token_type,
9016
- scope: data.scope,
9017
- expiresAt,
9018
- refreshTokenExpiresAt
8154
+ id,
8155
+ user_id: null,
8156
+ organization_id: organizationId,
8157
+ name: name || generatePlaceholderName(),
8158
+ sandbox_id: "",
8159
+ engine_url: null,
8160
+ engine_secret: "",
8161
+ github_installation_id: null,
8162
+ last_activity_at: null,
8163
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
8164
+ status: "preparing",
8165
+ creation_source: "dashboard",
8166
+ creator_email: null,
8167
+ soft_delete: false
9019
8168
  };
9020
8169
  }
9021
- async function runClaudeOAuthFlow() {
9022
- const pkce = generatePkceCodes();
9023
- const state = generateState2();
9024
- const authUrl = buildAuthorizationUrl2(pkce.codeChallenge, state);
9025
- console.log(import_chalk10.default.gray("We will open your browser so you can authenticate with Claude Code."));
9026
- console.log(import_chalk10.default.gray("If the browser does not open automatically, use the URL below:\n"));
9027
- console.log(authUrl);
9028
- console.log();
9029
- try {
9030
- await (0, import_open3.default)(authUrl);
9031
- } catch {
9032
- console.warn(import_chalk10.default.yellow("Failed to open browser automatically. Please copy and open the URL manually."));
9033
- }
9034
- console.log(import_chalk10.default.cyan("After completing authentication, copy the code shown on the success page."));
9035
- console.log(import_chalk10.default.cyan("You can paste either the full URL, or a value formatted as CODE#STATE.\n"));
9036
- const userInput = await promptForAuthorizationCode("Paste the authorization code (or URL) here: ");
9037
- if (!userInput) {
9038
- throw new Error("No authorization code provided.");
9039
- }
9040
- const { code, state: returnedState } = parseUserInput(userInput);
9041
- if (!code) {
9042
- throw new Error("Unable to parse authorization code. Please try again.");
9043
- }
9044
- console.log(import_chalk10.default.gray("\nExchanging authorization code for tokens..."));
9045
- const tokens = await exchangeCodeForTokens2(code, returnedState, state, pkce.codeVerifier);
9046
- console.log(import_chalk10.default.green("\u2713 Successfully obtained Claude credentials"));
9047
- return tokens;
9048
- }
9049
-
9050
- // src/commands/claude-auth.ts
9051
- async function claudeAuthCommand(options = {}) {
9052
- const isUserScoped = options.user === true;
9053
- const scopeLabel = isUserScoped ? "personal" : "organization";
9054
- console.log(import_chalk11.default.cyan(`Authenticating with Claude Code (${scopeLabel})...
9055
- `));
9056
- try {
9057
- const tokens = await runClaudeOAuthFlow();
9058
- console.log(import_chalk11.default.gray("\nUploading credentials to Replicas..."));
9059
- const endpoint = isUserScoped ? "/v1/claude/user/credentials" : "/v1/claude/credentials";
9060
- const response = await orgAuthenticatedFetch(
9061
- endpoint,
9062
- {
9063
- method: "POST",
9064
- body: {
9065
- access_token: tokens.accessToken,
9066
- refresh_token: tokens.refreshToken,
9067
- token_type: tokens.tokenType,
9068
- scope: tokens.scope,
9069
- expires_at: tokens.expiresAt,
9070
- refresh_token_expires_at: tokens.refreshTokenExpiresAt
9071
- }
9072
- }
9073
- );
9074
- if (!response.success) {
9075
- throw new Error(response.error || "Failed to upload Claude credentials to Replicas");
9076
- }
9077
- console.log(import_chalk11.default.green("\n\u2713 Claude authentication complete!"));
9078
- if (response.email) {
9079
- console.log(import_chalk11.default.gray(` Account: ${response.email}`));
9080
- }
9081
- if (response.planType) {
9082
- console.log(import_chalk11.default.gray(` Plan: ${response.planType}`));
9083
- }
9084
- if (isUserScoped) {
9085
- console.log(import_chalk11.default.gray("\nYour personal Claude credentials have been saved.\n"));
9086
- } else {
9087
- console.log(import_chalk11.default.gray("\nYou can now use Claude Code in your workspaces.\n"));
9088
- }
9089
- } catch (error) {
9090
- console.log(import_chalk11.default.red("\n\u2717 Error:"), error instanceof Error ? error.message : error);
9091
- process.exit(1);
9092
- }
9093
- }
9094
-
9095
- // src/commands/init.ts
9096
- var import_chalk12 = __toESM(require("chalk"));
9097
- var import_fs3 = __toESM(require("fs"));
9098
- var import_path4 = __toESM(require("path"));
9099
- function getDefaultConfig() {
9100
- return {
9101
- systemPrompt: "",
9102
- startHook: {
9103
- timeout: 3e5,
9104
- commands: []
9105
- }
9106
- };
9107
- }
9108
- function getDefaultYamlContent() {
9109
- return `# Replicas workspace configuration
9110
- # See: https://docs.replicas.dev/features/workspaces/repository-configuration
9111
-
9112
- systemPrompt: |
9113
- Add custom instructions for coding agents here.
9114
-
9115
- startHook:
9116
- timeout: 300000
9117
- commands: []
9118
- `;
9119
- }
9120
- function initCommand(options) {
9121
- const isYaml = options.yaml ?? false;
9122
- const targetFilename = isYaml ? "replicas.yaml" : "replicas.json";
9123
- const configPath = import_path4.default.join(process.cwd(), targetFilename);
9124
- for (const filename of REPLICAS_CONFIG_FILENAMES) {
9125
- const existingPath = import_path4.default.join(process.cwd(), filename);
9126
- if (import_fs3.default.existsSync(existingPath) && !options.force) {
9127
- console.log(
9128
- import_chalk12.default.yellow(
9129
- `${filename} already exists in this directory.`
9130
- )
9131
- );
9132
- console.log(import_chalk12.default.gray("Use --force to overwrite the existing file."));
9133
- return;
9134
- }
9135
- }
9136
- let configContent;
9137
- if (isYaml) {
9138
- configContent = getDefaultYamlContent();
9139
- } else {
9140
- const defaultConfig = getDefaultConfig();
9141
- configContent = JSON.stringify(defaultConfig, null, 2) + "\n";
9142
- }
9143
- try {
9144
- import_fs3.default.writeFileSync(configPath, configContent, "utf-8");
9145
- console.log(import_chalk12.default.green(`\u2713 Created ${targetFilename}`));
9146
- for (const filename of REPLICAS_CONFIG_FILENAMES) {
9147
- if (filename === targetFilename) break;
9148
- const higherPath = import_path4.default.join(process.cwd(), filename);
9149
- if (import_fs3.default.existsSync(higherPath)) {
9150
- console.log("");
9151
- console.log(
9152
- import_chalk12.default.yellow(
9153
- `Warning: ${filename} already exists and takes priority over ${targetFilename}.`
9154
- )
9155
- );
9156
- console.log(import_chalk12.default.gray(`Remove or rename ${filename} for ${targetFilename} to take effect.`));
9157
- }
9158
- }
9159
- console.log("");
9160
- console.log(import_chalk12.default.gray("Configuration options:"));
9161
- console.log(
9162
- import_chalk12.default.gray(" systemPrompt - Custom instructions for AI coding assistants")
9163
- );
9164
- console.log(
9165
- import_chalk12.default.gray(" startHook - Commands to run on workspace startup")
9166
- );
9167
- if (!isYaml) {
9168
- console.log("");
9169
- console.log(import_chalk12.default.gray("Tip: Use --yaml for YAML format with multiline system prompt support."));
9170
- }
9171
- } catch (error) {
9172
- throw new Error(
9173
- `Failed to create ${targetFilename}: ${error instanceof Error ? error.message : "Unknown error"}`
9174
- );
9175
- }
9176
- }
9177
-
9178
- // src/lib/version-check.ts
9179
- var import_chalk13 = __toESM(require("chalk"));
9180
- var MONOLITH_URL2 = process.env.REPLICAS_MONOLITH_URL || "https://api.replicas.dev";
9181
- var VERSION_CHECK_TIMEOUT = 2e3;
9182
- function compareVersions(v1, v2) {
9183
- const parts1 = v1.split(".").map(Number);
9184
- const parts2 = v2.split(".").map(Number);
9185
- for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
9186
- const num1 = parts1[i] || 0;
9187
- const num2 = parts2[i] || 0;
9188
- if (num1 > num2) return 1;
9189
- if (num1 < num2) return -1;
9190
- }
9191
- return 0;
9192
- }
9193
- async function checkForUpdates(currentVersion) {
9194
- try {
9195
- const controller = new AbortController();
9196
- const timeoutId = setTimeout(() => controller.abort(), VERSION_CHECK_TIMEOUT);
9197
- const response = await fetch(`${MONOLITH_URL2}/v1/cli/version`, {
9198
- signal: controller.signal
9199
- });
9200
- clearTimeout(timeoutId);
9201
- if (!response.ok) return;
9202
- const data = await response.json();
9203
- const latestVersion = data.version;
9204
- if (compareVersions(latestVersion, currentVersion) > 0) {
9205
- console.error(import_chalk13.default.yellow(`
9206
- Update available: ${currentVersion} \u2192 ${latestVersion}`));
9207
- console.error(import_chalk13.default.cyan(`Run: npm i -g replicas-cli@latest
9208
- `));
9209
- }
9210
- } catch {
9211
- }
9212
- }
9213
8170
 
9214
- // src/commands/replica.ts
9215
- var import_chalk14 = __toESM(require("chalk"));
9216
- var import_prompts4 = __toESM(require("prompts"));
9217
- function formatDate(dateString) {
9218
- return new Date(dateString).toLocaleString();
9219
- }
9220
- function formatStatus(status) {
9221
- switch (status) {
9222
- case "active":
9223
- return import_chalk14.default.green(status);
9224
- case "sleeping":
9225
- return import_chalk14.default.gray(status);
9226
- default:
9227
- return status;
9228
- }
9229
- }
9230
- function truncate(text, maxLength) {
9231
- if (text.length <= maxLength) return text;
9232
- return text.substring(0, maxLength) + "...";
9233
- }
9234
- function formatDisplayMessage(message) {
9235
- const time = new Date(message.timestamp).toLocaleTimeString();
9236
- switch (message.type) {
9237
- case "user":
9238
- console.log(import_chalk14.default.blue(`
9239
- [${time}] USER:`));
9240
- console.log(import_chalk14.default.white(` ${truncate(message.content, 500)}`));
9241
- break;
9242
- case "agent":
9243
- console.log(import_chalk14.default.green(`
9244
- [${time}] ASSISTANT:`));
9245
- console.log(import_chalk14.default.white(` ${truncate(message.content, 500)}`));
9246
- break;
9247
- case "reasoning":
9248
- console.log(import_chalk14.default.gray(`
9249
- [${time}] THINKING:`));
9250
- console.log(import_chalk14.default.gray(` ${truncate(message.content, 300)}`));
9251
- break;
9252
- case "command":
9253
- console.log(import_chalk14.default.magenta(`
9254
- [${time}] COMMAND:`));
9255
- console.log(import_chalk14.default.white(` $ ${message.command}`));
9256
- if (message.output) {
9257
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
9258
- }
9259
- if (message.exitCode !== void 0) {
9260
- const exitColor = message.exitCode === 0 ? import_chalk14.default.green : import_chalk14.default.red;
9261
- console.log(exitColor(` Exit code: ${message.exitCode}`));
9262
- }
9263
- break;
9264
- case "file_change":
9265
- console.log(import_chalk14.default.yellow(`
9266
- [${time}] FILE CHANGES:`));
9267
- for (const change of message.changes) {
9268
- const icon = change.kind === "add" ? "+" : change.kind === "delete" ? "-" : "~";
9269
- const color = change.kind === "add" ? import_chalk14.default.green : change.kind === "delete" ? import_chalk14.default.red : import_chalk14.default.yellow;
9270
- console.log(color(` ${icon} ${change.path}`));
9271
- }
9272
- break;
9273
- case "patch":
9274
- console.log(import_chalk14.default.yellow(`
9275
- [${time}] PATCH:`));
9276
- for (const op of message.operations) {
9277
- const icon = op.action === "add" ? "+" : op.action === "delete" ? "-" : "~";
9278
- const color = op.action === "add" ? import_chalk14.default.green : op.action === "delete" ? import_chalk14.default.red : import_chalk14.default.yellow;
9279
- console.log(color(` ${icon} ${op.path}`));
9280
- }
9281
- break;
9282
- case "tool_call":
9283
- console.log(import_chalk14.default.cyan(`
9284
- [${time}] TOOL: ${message.tool}`));
9285
- if (message.output) {
9286
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
9287
- }
9288
- break;
9289
- case "web_search":
9290
- console.log(import_chalk14.default.cyan(`
9291
- [${time}] WEB SEARCH:`));
9292
- console.log(import_chalk14.default.white(` "${message.query}"`));
9293
- break;
9294
- case "todo_list":
9295
- console.log(import_chalk14.default.blue(`
9296
- [${time}] PLAN:`));
9297
- for (const item of message.items) {
9298
- const icon = item.completed ? import_chalk14.default.green("[x]") : import_chalk14.default.gray("[ ]");
9299
- console.log(` ${icon} ${item.text}`);
9300
- }
9301
- break;
9302
- case "subagent":
9303
- console.log(import_chalk14.default.magenta(`
9304
- [${time}] SUBAGENT: ${message.description}`));
9305
- if (message.output) {
9306
- console.log(import_chalk14.default.gray(` ${truncate(message.output, 200)}`));
9307
- }
9308
- break;
9309
- case "error":
9310
- console.log(import_chalk14.default.red(`
9311
- [${time}] ERROR:`));
9312
- console.log(import_chalk14.default.red(` ${message.message}`));
9313
- break;
9314
- }
9315
- }
9316
- async function replicaListCommand(options) {
9317
- if (!isAuthenticated()) {
9318
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9319
- process.exit(1);
9320
- }
9321
- try {
9322
- const params = new URLSearchParams();
9323
- if (options.page) params.set("page", options.page);
9324
- if (options.limit) params.set("limit", options.limit);
9325
- const query = params.toString();
9326
- const response = await orgAuthenticatedFetch(
9327
- `/v1/replica${query ? "?" + query : ""}`
9328
- );
9329
- if (response.replicas.length === 0) {
9330
- console.log(import_chalk14.default.yellow("\nNo replicas found.\n"));
9331
- return;
9332
- }
9333
- console.log(import_chalk14.default.green(`
9334
- Replicas (Page ${response.page} of ${response.totalPages}, Total: ${response.total}):
9335
- `));
9336
- for (const replica of response.replicas) {
9337
- console.log(import_chalk14.default.white(` ${replica.name}`));
9338
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
9339
- if (replica.repositories.length > 0) {
9340
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
9341
- }
9342
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
9343
- console.log(import_chalk14.default.gray(` Created: ${formatDate(replica.created_at)}`));
9344
- if (replica.pull_requests && replica.pull_requests.length > 0) {
9345
- console.log(import_chalk14.default.gray(` Pull Requests:`));
9346
- for (const pr of replica.pull_requests) {
9347
- console.log(import_chalk14.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
9348
- }
9349
- }
9350
- console.log();
9351
- }
9352
- } catch (error) {
9353
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9354
- process.exit(1);
9355
- }
9356
- }
9357
- async function replicaGetCommand(id) {
9358
- if (!isAuthenticated()) {
9359
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9360
- process.exit(1);
9361
- }
9362
- try {
9363
- const response = await orgAuthenticatedFetch(`/v1/replica/${id}`);
9364
- const replica = response.replica;
9365
- console.log(import_chalk14.default.green(`
9366
- Replica: ${replica.name}
9367
- `));
9368
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
9369
- if (replica.repositories.length > 0) {
9370
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
9371
- }
9372
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
9373
- console.log(import_chalk14.default.gray(` Created: ${formatDate(replica.created_at)}`));
9374
- if (replica.waking) {
9375
- console.log(import_chalk14.default.yellow("\n Workspace is waking from sleep. Retry in 30-90 seconds for full details.\n"));
9376
- } else {
9377
- if (replica.coding_agent) {
9378
- console.log(import_chalk14.default.gray(` Coding Agent: ${replica.coding_agent}`));
9379
- }
9380
- if (replica.repository_statuses && replica.repository_statuses.length > 0) {
9381
- console.log(import_chalk14.default.gray(" Repository Statuses:"));
9382
- for (const repositoryStatus of replica.repository_statuses) {
9383
- const changeText = repositoryStatus.git_diff ? ` (${import_chalk14.default.green(`+${repositoryStatus.git_diff.added}`)} / ${import_chalk14.default.red(`-${repositoryStatus.git_diff.removed}`)})` : "";
9384
- console.log(import_chalk14.default.gray(` - ${repositoryStatus.repository}: ${repositoryStatus.branch || "unknown"}${changeText}`));
9385
- }
9386
- }
9387
- }
9388
- if (replica.pull_requests && replica.pull_requests.length > 0) {
9389
- console.log(import_chalk14.default.gray(` Pull Requests:`));
9390
- for (const pr of replica.pull_requests) {
9391
- console.log(import_chalk14.default.cyan(` - ${pr.repository} #${pr.number}: ${pr.url}`));
9392
- }
9393
- }
9394
- console.log();
9395
- } catch (error) {
9396
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9397
- process.exit(1);
8171
+ // ../shared/src/pricing.ts
8172
+ var PLANS = {
8173
+ hobby: {
8174
+ id: "hobby",
8175
+ name: "Hobby",
8176
+ monthlyPrice: 0,
8177
+ seatPriceCents: 0,
8178
+ creditsIncluded: 20,
8179
+ features: ["20 hours of usage"]
8180
+ },
8181
+ developer: {
8182
+ id: "developer",
8183
+ name: "Developer",
8184
+ monthlyPrice: 30,
8185
+ seatPriceCents: 3e3,
8186
+ creditsIncluded: 0,
8187
+ features: ["Unlimited usage", "API access ($1/hr)"]
8188
+ },
8189
+ team: {
8190
+ id: "team",
8191
+ name: "Team",
8192
+ monthlyPrice: 120,
8193
+ seatPriceCents: 12e3,
8194
+ creditsIncluded: 0,
8195
+ features: [
8196
+ "Unlimited usage",
8197
+ "API access",
8198
+ "Higher API rate limits",
8199
+ "Warm hooks and pool access",
8200
+ "Optional add-ons for higher resources, warm pools, rate limits, and SOC 2"
8201
+ ]
8202
+ },
8203
+ enterprise: {
8204
+ id: "enterprise",
8205
+ name: "Enterprise",
8206
+ monthlyPrice: 0,
8207
+ seatPriceCents: 0,
8208
+ creditsIncluded: 0,
8209
+ features: [
8210
+ "Unlimited usage",
8211
+ "Custom API rates",
8212
+ "Custom rate limits",
8213
+ "Custom warm hooks and pools",
8214
+ "SOC 2"
8215
+ ]
9398
8216
  }
9399
- }
9400
- async function replicaCreateCommand(name, options) {
9401
- if (!isAuthenticated()) {
9402
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9403
- process.exit(1);
9404
- }
9405
- try {
9406
- const repoResponse = await orgAuthenticatedFetch("/v1/repositories");
9407
- const repositories = repoResponse.repositories;
9408
- if (repositories.length === 0) {
9409
- console.log(import_chalk14.default.red("No repositories found. Please add a repository first."));
9410
- process.exit(1);
9411
- }
9412
- let replicaName = name;
9413
- let message = options.message;
9414
- let selectedRepositories = options.repositories?.split(",").map((repository) => repository.trim()).filter((repository) => repository.length > 0);
9415
- let codingAgent = options.agent;
9416
- if (replicaName && /\s/.test(replicaName)) {
9417
- console.log(import_chalk14.default.red("Replica name cannot contain spaces."));
9418
- process.exit(1);
9419
- }
9420
- if (!replicaName) {
9421
- const response2 = await (0, import_prompts4.default)({
9422
- type: "text",
9423
- name: "name",
9424
- message: "Enter replica name (without spaces):",
9425
- validate: (value) => {
9426
- if (!value.trim()) return "Name is required";
9427
- if (/\s/.test(value)) return "Name cannot contain spaces";
9428
- return true;
9429
- }
9430
- });
9431
- if (!response2.name) {
9432
- console.log(import_chalk14.default.yellow("\nCancelled."));
9433
- return;
9434
- }
9435
- replicaName = response2.name;
9436
- }
9437
- if (!selectedRepositories || selectedRepositories.length === 0) {
9438
- const response2 = await (0, import_prompts4.default)({
9439
- type: "multiselect",
9440
- name: "repositories",
9441
- message: "Select repositories:",
9442
- choices: repositories.map((repo) => ({
9443
- title: repo.name,
9444
- value: repo.name,
9445
- description: repo.url
9446
- })),
9447
- min: 1
9448
- });
9449
- if (!response2.repositories || response2.repositories.length === 0) {
9450
- console.log(import_chalk14.default.yellow("\nCancelled."));
9451
- return;
9452
- }
9453
- selectedRepositories = response2.repositories;
9454
- }
9455
- if (!message) {
9456
- const response2 = await (0, import_prompts4.default)({
9457
- type: "text",
9458
- name: "message",
9459
- message: "Enter initial message for the replica:",
9460
- validate: (value) => value.trim() ? true : "Message is required"
9461
- });
9462
- if (!response2.message) {
9463
- console.log(import_chalk14.default.yellow("\nCancelled."));
9464
- return;
9465
- }
9466
- message = response2.message;
9467
- }
9468
- if (!codingAgent) {
9469
- const response2 = await (0, import_prompts4.default)({
9470
- type: "select",
9471
- name: "agent",
9472
- message: "Select coding agent:",
9473
- choices: [
9474
- { title: "Claude", value: "claude" },
9475
- { title: "Codex", value: "codex" }
9476
- ],
9477
- initial: 0
9478
- });
9479
- if (!response2.agent) {
9480
- console.log(import_chalk14.default.yellow("\nCancelled."));
9481
- return;
9482
- }
9483
- codingAgent = response2.agent;
9484
- }
9485
- if (!codingAgent || !["claude", "codex"].includes(codingAgent)) {
9486
- console.log(import_chalk14.default.red(`Invalid coding agent: ${codingAgent}. Must be one of: claude, codex`));
9487
- process.exit(1);
9488
- }
9489
- const body = {
9490
- name: replicaName,
9491
- message,
9492
- repositories: selectedRepositories,
9493
- coding_agent: codingAgent
9494
- };
9495
- console.log(import_chalk14.default.gray("\nCreating replica..."));
9496
- const response = await orgAuthenticatedFetch("/v1/replica", {
9497
- method: "POST",
9498
- body
9499
- });
9500
- const replica = response.replica;
9501
- console.log(import_chalk14.default.green(`
9502
- Created replica: ${replica.name}`));
9503
- console.log(import_chalk14.default.gray(` ID: ${replica.id}`));
9504
- console.log(import_chalk14.default.gray(` Status: ${formatStatus(replica.status)}`));
9505
- if (replica.repositories.length > 0) {
9506
- console.log(import_chalk14.default.gray(` Repositories: ${replica.repositories.map((repository) => repository.name).join(", ")}`));
9507
- }
9508
- console.log();
9509
- } catch (error) {
9510
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9511
- process.exit(1);
9512
- }
9513
- }
9514
- async function replicaSendCommand(id, options) {
9515
- if (!isAuthenticated()) {
9516
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9517
- process.exit(1);
9518
- }
9519
- try {
9520
- let message = options.message;
9521
- if (!message) {
9522
- const response2 = await (0, import_prompts4.default)({
9523
- type: "text",
9524
- name: "message",
9525
- message: "Enter message to send:",
9526
- validate: (value) => value.trim() ? true : "Message is required"
9527
- });
9528
- if (!response2.message) {
9529
- console.log(import_chalk14.default.yellow("\nCancelled."));
9530
- return;
9531
- }
9532
- message = response2.message;
9533
- }
9534
- const body = {
9535
- message
9536
- };
9537
- if (options.agent) {
9538
- if (!["claude", "codex"].includes(options.agent)) {
9539
- console.log(import_chalk14.default.red(`Invalid coding agent: ${options.agent}. Must be one of: claude, codex`));
9540
- process.exit(1);
9541
- }
9542
- body.coding_agent = options.agent;
9543
- }
9544
- const response = await orgAuthenticatedFetch(
9545
- `/v1/replica/${id}/send`,
9546
- {
9547
- method: "POST",
9548
- body
9549
- }
9550
- );
9551
- const statusColor = response.status === "sent" ? import_chalk14.default.green : import_chalk14.default.yellow;
9552
- console.log(statusColor(`
9553
- Message ${response.status}`));
9554
- if (response.position !== void 0 && response.position > 0) {
9555
- console.log(import_chalk14.default.gray(` Queue position: ${response.position}`));
9556
- }
9557
- console.log();
9558
- } catch (error) {
9559
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9560
- process.exit(1);
9561
- }
9562
- }
9563
- async function replicaDeleteCommand(id, options) {
9564
- if (!isAuthenticated()) {
9565
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9566
- process.exit(1);
9567
- }
9568
- try {
9569
- if (!options.force) {
9570
- const response = await (0, import_prompts4.default)({
9571
- type: "confirm",
9572
- name: "confirm",
9573
- message: `Are you sure you want to delete replica ${id}?`,
9574
- initial: false
9575
- });
9576
- if (!response.confirm) {
9577
- console.log(import_chalk14.default.yellow("\nCancelled."));
9578
- return;
9579
- }
9580
- }
9581
- await orgAuthenticatedFetch(`/v1/replica/${id}`, {
9582
- method: "DELETE"
9583
- });
9584
- console.log(import_chalk14.default.green(`
9585
- Replica ${id} deleted.
9586
- `));
9587
- } catch (error) {
9588
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9589
- process.exit(1);
9590
- }
9591
- }
9592
- async function replicaReadCommand(id, options) {
9593
- if (!isAuthenticated()) {
9594
- console.log(import_chalk14.default.red('Not logged in. Please run "replicas login" first.'));
9595
- process.exit(1);
9596
- }
9597
- try {
9598
- const params = new URLSearchParams();
9599
- if (options.limit) params.set("limit", options.limit);
9600
- if (options.offset) params.set("offset", options.offset);
9601
- const query = params.toString();
9602
- const response = await orgAuthenticatedFetch(
9603
- `/v1/replica/${id}/read${query ? "?" + query : ""}`
9604
- );
9605
- if (response.waking) {
9606
- console.log(import_chalk14.default.yellow("\nWorkspace is waking from sleep. Retry in 30-90 seconds.\n"));
9607
- return;
9608
- }
9609
- console.log(import_chalk14.default.green(`
9610
- Conversation History
9611
- `));
9612
- if (response.coding_agent) {
9613
- console.log(import_chalk14.default.gray(` Agent: ${response.coding_agent}`));
9614
- }
9615
- if (response.thread_id) {
9616
- console.log(import_chalk14.default.gray(` Thread ID: ${response.thread_id}`));
9617
- }
9618
- console.log(import_chalk14.default.gray(` Total Events: ${response.total}`));
9619
- console.log(import_chalk14.default.gray(` Showing: ${response.events.length} events`));
9620
- if (response.hasMore) {
9621
- console.log(import_chalk14.default.gray(` Has More: yes (use --offset to paginate)`));
9622
- }
9623
- console.log();
9624
- if (response.events.length === 0) {
9625
- console.log(import_chalk14.default.yellow(" No events found.\n"));
9626
- return;
9627
- }
9628
- console.log(import_chalk14.default.gray("-".repeat(60)));
9629
- const agentType = response.coding_agent || "claude";
9630
- const displayMessages = parseAgentEvents(response.events, agentType);
9631
- for (const message of displayMessages) {
9632
- formatDisplayMessage(message);
9633
- }
9634
- console.log(import_chalk14.default.gray("\n" + "-".repeat(60)));
9635
- console.log();
9636
- } catch (error) {
9637
- console.error(import_chalk14.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9638
- process.exit(1);
9639
- }
9640
- }
9641
-
9642
- // src/commands/repositories.ts
9643
- var import_chalk15 = __toESM(require("chalk"));
9644
- function formatDate2(dateString) {
9645
- return new Date(dateString).toLocaleString();
9646
- }
9647
- async function repositoriesListCommand() {
9648
- if (!isAuthenticated()) {
9649
- console.log(import_chalk15.default.red('Not logged in. Please run "replicas login" first.'));
9650
- process.exit(1);
9651
- }
9652
- try {
9653
- const response = await orgAuthenticatedFetch("/v1/repositories");
9654
- if (response.repositories.length === 0) {
9655
- console.log(import_chalk15.default.yellow("\nNo repositories found.\n"));
9656
- return;
9657
- }
9658
- console.log(import_chalk15.default.green(`
9659
- Repositories (${response.repositories.length}):
9660
- `));
9661
- for (const repo of response.repositories) {
9662
- console.log(import_chalk15.default.white(` ${repo.name}`));
9663
- console.log(import_chalk15.default.gray(` URL: ${repo.url}`));
9664
- console.log(import_chalk15.default.gray(` Default Branch: ${repo.default_branch}`));
9665
- console.log(import_chalk15.default.gray(` Created: ${formatDate2(repo.created_at)}`));
9666
- if (repo.github_repository_id) {
9667
- console.log(import_chalk15.default.gray(` GitHub ID: ${repo.github_repository_id}`));
9668
- }
9669
- console.log();
9670
- }
9671
- } catch (error) {
9672
- console.error(import_chalk15.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
9673
- process.exit(1);
9674
- }
9675
- }
9676
-
9677
- // src/commands/preview.ts
9678
- var import_chalk16 = __toESM(require("chalk"));
9679
-
9680
- // src/lib/agent-api.ts
9681
- var MONOLITH_URL3 = process.env.MONOLITH_URL || process.env.REPLICAS_MONOLITH_URL || "https://api.replicas.dev";
9682
- var ENGINE_PORT = process.env.REPLICAS_ENGINE_PORT || "3737";
9683
- async function agentFetch(path5, options) {
9684
- const config2 = readAgentConfig();
9685
- if (!config2) {
9686
- throw new Error("Agent mode config not found");
9687
- }
9688
- const headers = {
9689
- "Authorization": `Bearer ${config2.engine_secret}`,
9690
- "X-Workspace-Id": config2.workspace_id,
9691
- "Content-Type": "application/json",
9692
- ...options?.headers || {}
9693
- };
9694
- const response = await fetch(`${MONOLITH_URL3}${path5}`, {
9695
- ...options,
9696
- headers,
9697
- body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
9698
- });
9699
- if (!response.ok) {
9700
- const error = await response.json().catch(() => ({ error: "Request failed" }));
9701
- throw new Error(error.error || `Request failed with status ${response.status}`);
9702
- }
9703
- return response.json();
9704
- }
9705
- async function engineFetch(path5, options) {
9706
- const config2 = readAgentConfig();
9707
- if (!config2) {
9708
- throw new Error("Agent mode config not found");
9709
- }
9710
- const headers = {
9711
- "X-Replicas-Engine-Secret": config2.engine_secret,
9712
- "Content-Type": "application/json",
9713
- ...options?.headers || {}
9714
- };
9715
- const response = await fetch(`http://localhost:${ENGINE_PORT}${path5}`, {
9716
- ...options,
9717
- headers,
9718
- body: options?.body !== void 0 ? JSON.stringify(options.body) : void 0
9719
- });
9720
- if (!response.ok) {
9721
- const error = await response.json().catch(() => ({ error: "Request failed" }));
9722
- throw new Error(error.error || `Request failed with status ${response.status}`);
9723
- }
9724
- return response.json();
9725
- }
8217
+ };
8218
+ var TEAM_PLAN = PLANS.team;
8219
+ var ENTERPRISE_PLAN = PLANS.enterprise;
9726
8220
 
9727
- // src/commands/preview.ts
9728
- async function previewCreateCommand(port) {
9729
- const portNum = parseInt(port, 10);
9730
- if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
9731
- throw new Error("Port must be a number between 1 and 65535");
9732
- }
9733
- if (isAgentMode()) {
9734
- const result = await agentFetch("/v1/previews", {
9735
- method: "POST",
9736
- body: { port: portNum }
9737
- });
9738
- console.log(result.preview.publicUrl);
9739
- } else {
9740
- throw new Error("In human mode, use: replicas preview add <workspaceId> --port <port>");
9741
- }
9742
- }
9743
- async function previewListCommand(workspaceId) {
9744
- if (isAgentMode()) {
9745
- const result = await engineFetch("/previews");
9746
- if (result.previews.length === 0) {
9747
- console.log("No active previews");
9748
- return;
9749
- }
9750
- for (const preview2 of result.previews) {
9751
- console.log(`${preview2.port} -> ${preview2.publicUrl}`);
9752
- }
9753
- } else {
9754
- if (!workspaceId) {
9755
- throw new Error("Workspace ID is required: replicas preview list <workspaceId>");
9756
- }
9757
- const result = await orgAuthenticatedFetch(
9758
- `/v1/workspaces/${workspaceId}/previews`
9759
- );
9760
- if (result.previews.length === 0) {
9761
- console.log(import_chalk16.default.dim("No active previews"));
9762
- return;
9763
- }
9764
- for (const preview2 of result.previews) {
9765
- console.log(` ${import_chalk16.default.cyan(String(preview2.port))} \u2192 ${import_chalk16.default.underline(preview2.publicUrl)}`);
9766
- }
9767
- }
9768
- }
9769
- async function previewAddCommand(workspaceId, options) {
9770
- const portNum = parseInt(options.port, 10);
9771
- if (isNaN(portNum) || portNum < 1 || portNum > 65535) {
9772
- throw new Error("Port must be a number between 1 and 65535");
9773
- }
9774
- const result = await orgAuthenticatedFetch(
9775
- `/v1/workspaces/${workspaceId}/previews`,
9776
- {
9777
- method: "POST",
9778
- body: { port: portNum }
9779
- }
9780
- );
9781
- console.log(import_chalk16.default.green(`Preview created: ${result.preview.publicUrl}`));
9782
- }
8221
+ // ../shared/src/routes/workspaces.ts
8222
+ var WORKSPACE_FILE_UPLOAD_MAX_SIZE_BYTES = 20 * 1024 * 1024;
8223
+ var WORKSPACE_FILE_CONTENT_MAX_SIZE_BYTES = 1 * 1024 * 1024;
9783
8224
 
9784
- // src/index.ts
9785
- var CLI_VERSION = "0.2.37";
9786
- var program = new import_commander.Command();
9787
- program.name("replicas").description("CLI for managing Replicas workspaces").version(CLI_VERSION);
9788
- program.command("login").description("Authenticate with your Replicas account").action(async () => {
9789
- try {
9790
- await loginCommand();
9791
- } catch (error) {
9792
- if (error instanceof Error) {
9793
- console.error(import_chalk17.default.red(`
9794
- \u2717 ${error.message}
9795
- `));
9796
- }
9797
- process.exit(1);
9798
- }
9799
- });
9800
- program.command("init").description("Create a replicas.json or replicas.yaml configuration file").option("-f, --force", "Overwrite existing config file").option("-y, --yaml", "Create replicas.yaml instead of replicas.json").action((options) => {
9801
- try {
9802
- initCommand(options);
9803
- } catch (error) {
9804
- if (error instanceof Error) {
9805
- console.error(import_chalk17.default.red(`
9806
- \u2717 ${error.message}
9807
- `));
9808
- }
9809
- process.exit(1);
9810
- }
9811
- });
9812
- program.command("logout").description("Clear stored credentials").action(() => {
9813
- try {
9814
- logoutCommand();
9815
- } catch (error) {
9816
- if (error instanceof Error) {
9817
- console.error(import_chalk17.default.red(`
9818
- \u2717 ${error.message}
9819
- `));
9820
- }
9821
- process.exit(1);
9822
- }
9823
- });
9824
- program.command("whoami").description("Display current authenticated user").action(async () => {
9825
- try {
9826
- await whoamiCommand();
9827
- } catch (error) {
9828
- if (error instanceof Error) {
9829
- console.error(import_chalk17.default.red(`
9830
- \u2717 ${error.message}
9831
- `));
9832
- }
9833
- process.exit(1);
9834
- }
9835
- });
9836
- program.command("codex-auth").description("Authenticate Replicas with your Codex credentials").option("-u, --user", "Store credentials for your personal account").action(async (options) => {
9837
- try {
9838
- await codexAuthCommand(options);
9839
- } catch (error) {
9840
- if (error instanceof Error) {
9841
- console.error(import_chalk17.default.red(`
9842
- \u2717 ${error.message}
9843
- `));
9844
- }
9845
- process.exit(1);
9846
- }
9847
- });
9848
- program.command("claude-auth").description("Authenticate Replicas with your Claude Code credentials").option("-u, --user", "Store credentials for your personal account").action(async (options) => {
9849
- try {
9850
- await claudeAuthCommand(options);
9851
- } catch (error) {
9852
- if (error instanceof Error) {
9853
- console.error(import_chalk17.default.red(`
9854
- \u2717 ${error.message}
9855
- `));
9856
- }
9857
- process.exit(1);
9858
- }
9859
- });
9860
- var org = program.command("org").description("Manage organizations");
9861
- org.command("switch").description("Switch to a different organization").action(async () => {
9862
- try {
9863
- await orgSwitchCommand();
9864
- } catch (error) {
9865
- if (error instanceof Error) {
9866
- console.error(import_chalk17.default.red(`
9867
- \u2717 ${error.message}
9868
- `));
9869
- }
9870
- process.exit(1);
9871
- }
9872
- });
9873
- org.action(async () => {
9874
- try {
9875
- await orgCommand();
9876
- } catch (error) {
9877
- if (error instanceof Error) {
9878
- console.error(import_chalk17.default.red(`
9879
- \u2717 ${error.message}
9880
- `));
9881
- }
9882
- process.exit(1);
9883
- }
9884
- });
9885
- program.command("connect <workspace-name>").description("Connect to a workspace via SSH").action(async (workspaceName) => {
9886
- try {
9887
- await connectCommand(workspaceName);
9888
- } catch (error) {
9889
- if (error instanceof Error) {
9890
- console.error(import_chalk17.default.red(`
9891
- \u2717 ${error.message}
9892
- `));
9893
- }
9894
- process.exit(1);
9895
- }
9896
- });
9897
- program.command("code <workspace-name>").description("Open a workspace in VSCode/Cursor via Remote SSH").action(async (workspaceName) => {
9898
- try {
9899
- await codeCommand(workspaceName);
9900
- } catch (error) {
9901
- if (error instanceof Error) {
9902
- console.error(import_chalk17.default.red(`
9903
- \u2717 ${error.message}
9904
- `));
9905
- }
9906
- process.exit(1);
9907
- }
9908
- });
9909
- var config = program.command("config").description("Manage CLI configuration");
9910
- config.command("get <key>").description("Get a configuration value").action(async (key) => {
9911
- try {
9912
- await configGetCommand(key);
9913
- } catch (error) {
9914
- if (error instanceof Error) {
9915
- console.error(import_chalk17.default.red(`
9916
- \u2717 ${error.message}
9917
- `));
9918
- }
9919
- process.exit(1);
9920
- }
9921
- });
9922
- config.command("set <key> <value>").description("Set a configuration value").action(async (key, value) => {
9923
- try {
9924
- await configSetCommand(key, value);
9925
- } catch (error) {
9926
- if (error instanceof Error) {
9927
- console.error(import_chalk17.default.red(`
9928
- \u2717 ${error.message}
9929
- `));
9930
- }
9931
- process.exit(1);
9932
- }
9933
- });
9934
- config.command("list").description("List all configuration values").action(async () => {
9935
- try {
9936
- await configListCommand();
9937
- } catch (error) {
9938
- if (error instanceof Error) {
9939
- console.error(import_chalk17.default.red(`
9940
- \u2717 ${error.message}
9941
- `));
9942
- }
9943
- process.exit(1);
9944
- }
9945
- });
9946
- program.command("list").description("List all replicas").option("-p, --page <page>", "Page number").option("-l, --limit <limit>", "Number of items per page").action(async (options) => {
9947
- try {
9948
- await replicaListCommand(options);
9949
- } catch (error) {
9950
- if (error instanceof Error) {
9951
- console.error(import_chalk17.default.red(`
9952
- \u2717 ${error.message}
9953
- `));
9954
- }
9955
- process.exit(1);
9956
- }
9957
- });
9958
- program.command("get <id>").description("Get replica details by ID").action(async (id) => {
9959
- try {
9960
- await replicaGetCommand(id);
9961
- } catch (error) {
9962
- if (error instanceof Error) {
9963
- console.error(import_chalk17.default.red(`
9964
- \u2717 ${error.message}
9965
- `));
9966
- }
9967
- process.exit(1);
9968
- }
9969
- });
9970
- program.command("create [name]").description("Create a new replica").option("-m, --message <message>", "Initial message for the replica").option("-r, --repositories <repositories>", "Comma-separated repository names").option("-a, --agent <agent>", "Coding agent (claude, codex)").action(async (name, options) => {
9971
- try {
9972
- await replicaCreateCommand(name, options);
9973
- } catch (error) {
9974
- if (error instanceof Error) {
9975
- console.error(import_chalk17.default.red(`
9976
- \u2717 ${error.message}
9977
- `));
9978
- }
9979
- process.exit(1);
9980
- }
9981
- });
9982
- program.command("send <id>").description("Send a message to a replica").option("-m, --message <message>", "Message to send").option("-a, --agent <agent>", "Coding agent (claude, codex)").action(async (id, options) => {
9983
- try {
9984
- await replicaSendCommand(id, options);
9985
- } catch (error) {
9986
- if (error instanceof Error) {
9987
- console.error(import_chalk17.default.red(`
9988
- \u2717 ${error.message}
9989
- `));
9990
- }
9991
- process.exit(1);
9992
- }
9993
- });
9994
- program.command("delete <id>").description("Delete a replica").option("-f, --force", "Skip confirmation prompt").action(async (id, options) => {
9995
- try {
9996
- await replicaDeleteCommand(id, options);
9997
- } catch (error) {
9998
- if (error instanceof Error) {
9999
- console.error(import_chalk17.default.red(`
10000
- \u2717 ${error.message}
10001
- `));
10002
- }
10003
- process.exit(1);
10004
- }
10005
- });
10006
- program.command("read <id>").description("Read conversation history of a replica").option("-l, --limit <limit>", "Maximum number of events to return").option("-o, --offset <offset>", "Number of events to skip from the end").action(async (id, options) => {
10007
- try {
10008
- await replicaReadCommand(id, options);
10009
- } catch (error) {
10010
- if (error instanceof Error) {
10011
- console.error(import_chalk17.default.red(`
10012
- \u2717 ${error.message}
10013
- `));
10014
- }
10015
- process.exit(1);
10016
- }
10017
- });
10018
- var repos = program.command("repos").description("Manage repositories");
10019
- repos.command("list").description("List all repositories").action(async () => {
10020
- try {
10021
- await repositoriesListCommand();
10022
- } catch (error) {
10023
- if (error instanceof Error) {
10024
- console.error(import_chalk17.default.red(`
10025
- \u2717 ${error.message}
10026
- `));
10027
- }
10028
- process.exit(1);
10029
- }
10030
- });
10031
- repos.action(async () => {
10032
- try {
10033
- await repositoriesListCommand();
10034
- } catch (error) {
10035
- if (error instanceof Error) {
10036
- console.error(import_chalk17.default.red(`
10037
- \u2717 ${error.message}
10038
- `));
10039
- }
10040
- process.exit(1);
10041
- }
10042
- });
10043
- var preview = program.command("preview").description("Manage preview URLs");
10044
- if (isAgentMode()) {
10045
- preview.command("create <port>").description("Register a preview port").action(async (port) => {
10046
- try {
10047
- await previewCreateCommand(port);
10048
- } catch (error) {
10049
- if (error instanceof Error) {
10050
- console.error(`Error: ${error.message}`);
10051
- }
10052
- process.exit(1);
10053
- }
10054
- });
10055
- preview.command("list").description("List active preview URLs").action(async () => {
10056
- try {
10057
- await previewListCommand();
10058
- } catch (error) {
10059
- if (error instanceof Error) {
10060
- console.error(`Error: ${error.message}`);
10061
- }
10062
- process.exit(1);
10063
- }
10064
- });
10065
- } else {
10066
- preview.command("add <workspaceId>").description("Register a preview port for a workspace").requiredOption("-p, --port <port>", "Port number to preview").action(async (workspaceId, options) => {
10067
- try {
10068
- await previewAddCommand(workspaceId, options);
10069
- } catch (error) {
10070
- if (error instanceof Error) {
10071
- console.error(import_chalk17.default.red(`
10072
- \u2717 ${error.message}
10073
- `));
10074
- }
10075
- process.exit(1);
10076
- }
10077
- });
10078
- preview.command("list [workspaceId]").description("List active preview URLs for a workspace").action(async (workspaceId) => {
10079
- try {
10080
- await previewListCommand(workspaceId);
10081
- } catch (error) {
10082
- if (error instanceof Error) {
10083
- console.error(import_chalk17.default.red(`
10084
- \u2717 ${error.message}
10085
- `));
10086
- }
10087
- process.exit(1);
10088
- }
10089
- });
10090
- }
10091
- if (isAgentMode()) {
10092
- const previewCmd = program.commands.find((cmd) => cmd.name() === "preview");
10093
- const cmds = program.commands;
10094
- cmds.length = 0;
10095
- if (previewCmd) {
10096
- cmds.push(previewCmd);
10097
- }
10098
- }
10099
- var versionCheckPromise = checkForUpdates(CLI_VERSION);
10100
- program.parse();
10101
- versionCheckPromise.catch(() => {
10102
- });
10103
- // Annotate the CommonJS export names for ESM import in node:
10104
- 0 && (module.exports = {
10105
- CLI_VERSION
10106
- });
8225
+ export {
8226
+ readConfig,
8227
+ writeConfig,
8228
+ deleteConfig,
8229
+ isAuthenticated,
8230
+ setOrganizationId,
8231
+ getOrganizationId,
8232
+ setIdeCommand,
8233
+ getIdeCommand,
8234
+ isAgentMode,
8235
+ readAgentConfig,
8236
+ getValidToken,
8237
+ getCurrentUser,
8238
+ SANDBOX_PATHS,
8239
+ REPLICAS_CONFIG_FILENAMES,
8240
+ parseAgentEvents,
8241
+ createUserMessage,
8242
+ isAgentBackendEvent,
8243
+ filterDisplayMessages,
8244
+ buildGroups,
8245
+ createMockWorkspaceRecord
8246
+ };