boomkin 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,21 +1,25 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
+ var __defProp = Object.defineProperty;
3
4
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
4
- var __esm = (fn, res, err) => () => {
5
- if (fn)
6
- try {
7
- res = fn(fn = 0);
8
- } catch (e) {
9
- err = [e];
10
- }
11
- if (err)
12
- throw err[0];
13
- return res;
5
+ var __returnValue = (v) => v;
6
+ function __exportSetter(name, newValue) {
7
+ this[name] = __returnValue.bind(null, newValue);
8
+ }
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true,
14
+ configurable: true,
15
+ set: __exportSetter.bind(all, name)
16
+ });
14
17
  };
18
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
15
19
  var __require = import.meta.require;
16
20
 
17
21
  // node_modules/yaml/dist/nodes/identity.js
18
- var require_identity = __commonJS(function(exports) {
22
+ var require_identity = __commonJS((exports) => {
19
23
  var ALIAS = Symbol.for("yaml.alias");
20
24
  var DOC = Symbol.for("yaml.document");
21
25
  var MAP = Symbol.for("yaml.map");
@@ -69,7 +73,7 @@ var require_identity = __commonJS(function(exports) {
69
73
  });
70
74
 
71
75
  // node_modules/yaml/dist/visit.js
72
- var require_visit = __commonJS(function(exports) {
76
+ var require_visit = __commonJS((exports) => {
73
77
  var identity = require_identity();
74
78
  var BREAK = Symbol("break visit");
75
79
  var SKIP = Symbol("skip children");
@@ -224,7 +228,7 @@ var require_visit = __commonJS(function(exports) {
224
228
  });
225
229
 
226
230
  // node_modules/yaml/dist/doc/directives.js
227
- var require_directives = __commonJS(function(exports) {
231
+ var require_directives = __commonJS((exports) => {
228
232
  var identity = require_identity();
229
233
  var visit = require_visit();
230
234
  var escapeChars = {
@@ -376,7 +380,7 @@ var require_directives = __commonJS(function(exports) {
376
380
  });
377
381
 
378
382
  // node_modules/yaml/dist/doc/anchors.js
379
- var require_anchors = __commonJS(function(exports) {
383
+ var require_anchors = __commonJS((exports) => {
380
384
  var identity = require_identity();
381
385
  var visit = require_visit();
382
386
  function anchorIsValid(anchor) {
@@ -438,7 +442,7 @@ var require_anchors = __commonJS(function(exports) {
438
442
  });
439
443
 
440
444
  // node_modules/yaml/dist/doc/applyReviver.js
441
- var require_applyReviver = __commonJS(function(exports) {
445
+ var require_applyReviver = __commonJS((exports) => {
442
446
  function applyReviver(reviver, obj, key, val) {
443
447
  if (val && typeof val === "object") {
444
448
  if (Array.isArray(val)) {
@@ -485,7 +489,7 @@ var require_applyReviver = __commonJS(function(exports) {
485
489
  });
486
490
 
487
491
  // node_modules/yaml/dist/nodes/toJS.js
488
- var require_toJS = __commonJS(function(exports) {
492
+ var require_toJS = __commonJS((exports) => {
489
493
  var identity = require_identity();
490
494
  function toJS(value, arg, ctx) {
491
495
  if (Array.isArray(value))
@@ -495,8 +499,8 @@ var require_toJS = __commonJS(function(exports) {
495
499
  return value.toJSON(arg, ctx);
496
500
  const data = { aliasCount: 0, count: 1, res: undefined };
497
501
  ctx.anchors.set(value, data);
498
- ctx.onCreate = (res) => {
499
- data.res = res;
502
+ ctx.onCreate = (res2) => {
503
+ data.res = res2;
500
504
  delete ctx.onCreate;
501
505
  };
502
506
  const res = value.toJSON(arg, ctx);
@@ -512,7 +516,7 @@ var require_toJS = __commonJS(function(exports) {
512
516
  });
513
517
 
514
518
  // node_modules/yaml/dist/nodes/Node.js
515
- var require_Node = __commonJS(function(exports) {
519
+ var require_Node = __commonJS((exports) => {
516
520
  var applyReviver = require_applyReviver();
517
521
  var identity = require_identity();
518
522
  var toJS = require_toJS();
@@ -540,8 +544,8 @@ var require_Node = __commonJS(function(exports) {
540
544
  };
541
545
  const res = toJS.toJS(this, "", ctx);
542
546
  if (typeof onAnchor === "function")
543
- for (const { count, res } of ctx.anchors.values())
544
- onAnchor(res, count);
547
+ for (const { count, res: res2 } of ctx.anchors.values())
548
+ onAnchor(res2, count);
545
549
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
546
550
  }
547
551
  }
@@ -549,7 +553,7 @@ var require_Node = __commonJS(function(exports) {
549
553
  });
550
554
 
551
555
  // node_modules/yaml/dist/nodes/Alias.js
552
- var require_Alias = __commonJS(function(exports) {
556
+ var require_Alias = __commonJS((exports) => {
553
557
  var anchors = require_anchors();
554
558
  var visit = require_visit();
555
559
  var identity = require_identity();
@@ -591,11 +595,11 @@ var require_Alias = __commonJS(function(exports) {
591
595
  found = node;
592
596
  }
593
597
  if (found && ctx) {
594
- const { anchors, doc, maxAliasCount } = ctx;
595
- let data = anchors.get(found);
598
+ const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
599
+ let data = anchors2.get(found);
596
600
  if (!data) {
597
601
  toJS.toJS(found, null, ctx);
598
- data = anchors.get(found);
602
+ data = anchors2.get(found);
599
603
  }
600
604
  if (data?.res === undefined) {
601
605
  const msg = "This should not happen: Alias anchor was not resolved?";
@@ -604,7 +608,7 @@ var require_Alias = __commonJS(function(exports) {
604
608
  if (maxAliasCount >= 0) {
605
609
  data.count += 1;
606
610
  if (data.aliasCount === 0)
607
- data.aliasCount = getAliasCount(doc, found, anchors);
611
+ data.aliasCount = getAliasCount(doc2, found, anchors2);
608
612
  if (data.count * data.aliasCount > maxAliasCount) {
609
613
  const msg = "Excessive alias count indicates a resource exhaustion attack";
610
614
  throw new ReferenceError(msg);
@@ -637,22 +641,22 @@ var require_Alias = __commonJS(function(exports) {
637
641
  return src;
638
642
  }
639
643
  }
640
- function getAliasCount(doc, node, anchors) {
644
+ function getAliasCount(doc, node, anchors2) {
641
645
  if (identity.isAlias(node)) {
642
646
  const source = node.resolve(doc);
643
- const anchor = anchors && source && anchors.get(source);
647
+ const anchor = anchors2 && source && anchors2.get(source);
644
648
  return anchor ? anchor.count * anchor.aliasCount : 0;
645
649
  } else if (identity.isCollection(node)) {
646
650
  let count = 0;
647
651
  for (const item of node.items) {
648
- const c = getAliasCount(doc, item, anchors);
652
+ const c = getAliasCount(doc, item, anchors2);
649
653
  if (c > count)
650
654
  count = c;
651
655
  }
652
656
  return count;
653
657
  } else if (identity.isPair(node)) {
654
- const kc = getAliasCount(doc, node.key, anchors);
655
- const vc = getAliasCount(doc, node.value, anchors);
658
+ const kc = getAliasCount(doc, node.key, anchors2);
659
+ const vc = getAliasCount(doc, node.value, anchors2);
656
660
  return Math.max(kc, vc);
657
661
  }
658
662
  return 1;
@@ -661,7 +665,7 @@ var require_Alias = __commonJS(function(exports) {
661
665
  });
662
666
 
663
667
  // node_modules/yaml/dist/nodes/Scalar.js
664
- var require_Scalar = __commonJS(function(exports) {
668
+ var require_Scalar = __commonJS((exports) => {
665
669
  var identity = require_identity();
666
670
  var Node = require_Node();
667
671
  var toJS = require_toJS();
@@ -689,7 +693,7 @@ var require_Scalar = __commonJS(function(exports) {
689
693
  });
690
694
 
691
695
  // node_modules/yaml/dist/doc/createNode.js
692
- var require_createNode = __commonJS(function(exports) {
696
+ var require_createNode = __commonJS((exports) => {
693
697
  var Alias = require_Alias();
694
698
  var identity = require_identity();
695
699
  var Scalar = require_Scalar();
@@ -737,10 +741,10 @@ var require_createNode = __commonJS(function(exports) {
737
741
  value = value.toJSON();
738
742
  }
739
743
  if (!value || typeof value !== "object") {
740
- const node = new Scalar.Scalar(value);
744
+ const node2 = new Scalar.Scalar(value);
741
745
  if (ref)
742
- ref.node = node;
743
- return node;
746
+ ref.node = node2;
747
+ return node2;
744
748
  }
745
749
  tagObj = value instanceof Map ? schema[identity.MAP] : (Symbol.iterator in Object(value)) ? schema[identity.SEQ] : schema[identity.MAP];
746
750
  }
@@ -761,7 +765,7 @@ var require_createNode = __commonJS(function(exports) {
761
765
  });
762
766
 
763
767
  // node_modules/yaml/dist/nodes/Collection.js
764
- var require_Collection = __commonJS(function(exports) {
768
+ var require_Collection = __commonJS((exports) => {
765
769
  var createNode = require_createNode();
766
770
  var identity = require_identity();
767
771
  var Node = require_Node();
@@ -876,7 +880,7 @@ var require_Collection = __commonJS(function(exports) {
876
880
  });
877
881
 
878
882
  // node_modules/yaml/dist/stringify/stringifyComment.js
879
- var require_stringifyComment = __commonJS(function(exports) {
883
+ var require_stringifyComment = __commonJS((exports) => {
880
884
  var stringifyComment = (str) => str.replace(/^(?!$)(?: $)?/gm, "#");
881
885
  function indentComment(comment, indent) {
882
886
  if (/^\n+$/.test(comment))
@@ -893,7 +897,7 @@ var require_stringifyComment = __commonJS(function(exports) {
893
897
  });
894
898
 
895
899
  // node_modules/yaml/dist/stringify/foldFlowLines.js
896
- var require_foldFlowLines = __commonJS(function(exports) {
900
+ var require_foldFlowLines = __commonJS((exports) => {
897
901
  var FOLD_FLOW = "flow";
898
902
  var FOLD_BLOCK = "block";
899
903
  var FOLD_QUOTED = "quoted";
@@ -989,17 +993,17 @@ var require_foldFlowLines = __commonJS(function(exports) {
989
993
  if (onFold)
990
994
  onFold();
991
995
  let res = text.slice(0, folds[0]);
992
- for (let i = 0;i < folds.length; ++i) {
993
- const fold = folds[i];
994
- const end = folds[i + 1] || text.length;
996
+ for (let i2 = 0;i2 < folds.length; ++i2) {
997
+ const fold = folds[i2];
998
+ const end2 = folds[i2 + 1] || text.length;
995
999
  if (fold === 0)
996
1000
  res = `
997
- ${indent}${text.slice(0, end)}`;
1001
+ ${indent}${text.slice(0, end2)}`;
998
1002
  else {
999
1003
  if (mode === FOLD_QUOTED && escapedFolds[fold])
1000
1004
  res += `${text[fold]}\\`;
1001
1005
  res += `
1002
- ${indent}${text.slice(fold + 1, end)}`;
1006
+ ${indent}${text.slice(fold + 1, end2)}`;
1003
1007
  }
1004
1008
  }
1005
1009
  return res;
@@ -1030,7 +1034,7 @@ ${indent}${text.slice(fold + 1, end)}`;
1030
1034
  });
1031
1035
 
1032
1036
  // node_modules/yaml/dist/stringify/stringifyString.js
1033
- var require_stringifyString = __commonJS(function(exports) {
1037
+ var require_stringifyString = __commonJS((exports) => {
1034
1038
  var Scalar = require_Scalar();
1035
1039
  var foldFlowLines = require_foldFlowLines();
1036
1040
  var getFoldOptions = (ctx, isBlock) => ({
@@ -1328,7 +1332,7 @@ ${indent}`);
1328
1332
  });
1329
1333
 
1330
1334
  // node_modules/yaml/dist/stringify/stringify.js
1331
- var require_stringify = __commonJS(function(exports) {
1335
+ var require_stringify = __commonJS((exports) => {
1332
1336
  var anchors = require_anchors();
1333
1337
  var identity = require_identity();
1334
1338
  var stringifyComment = require_stringifyComment();
@@ -1449,7 +1453,7 @@ ${ctx.indent}${str}`;
1449
1453
  });
1450
1454
 
1451
1455
  // node_modules/yaml/dist/stringify/stringifyPair.js
1452
- var require_stringifyPair = __commonJS(function(exports) {
1456
+ var require_stringifyPair = __commonJS((exports) => {
1453
1457
  var identity = require_identity();
1454
1458
  var Scalar = require_Scalar();
1455
1459
  var stringify = require_stringify();
@@ -1585,7 +1589,7 @@ ${ctx.indent}`;
1585
1589
  });
1586
1590
 
1587
1591
  // node_modules/yaml/dist/log.js
1588
- var require_log = __commonJS(function(exports) {
1592
+ var require_log = __commonJS((exports) => {
1589
1593
  var node_process = __require("process");
1590
1594
  function debug(logLevel, ...messages) {
1591
1595
  if (logLevel === "debug")
@@ -1604,7 +1608,7 @@ var require_log = __commonJS(function(exports) {
1604
1608
  });
1605
1609
 
1606
1610
  // node_modules/yaml/dist/schema/yaml-1.1/merge.js
1607
- var require_merge = __commonJS(function(exports) {
1611
+ var require_merge = __commonJS((exports) => {
1608
1612
  var identity = require_identity();
1609
1613
  var Scalar = require_Scalar();
1610
1614
  var MERGE_KEY = "<<";
@@ -1635,15 +1639,15 @@ var require_merge = __commonJS(function(exports) {
1635
1639
  if (!identity.isMap(source))
1636
1640
  throw new Error("Merge sources must be maps or map aliases");
1637
1641
  const srcMap = source.toJSON(null, ctx, Map);
1638
- for (const [key, value] of srcMap) {
1642
+ for (const [key, value2] of srcMap) {
1639
1643
  if (map instanceof Map) {
1640
1644
  if (!map.has(key))
1641
- map.set(key, value);
1645
+ map.set(key, value2);
1642
1646
  } else if (map instanceof Set) {
1643
1647
  map.add(key);
1644
1648
  } else if (!Object.prototype.hasOwnProperty.call(map, key)) {
1645
1649
  Object.defineProperty(map, key, {
1646
- value,
1650
+ value: value2,
1647
1651
  writable: true,
1648
1652
  enumerable: true,
1649
1653
  configurable: true
@@ -1661,7 +1665,7 @@ var require_merge = __commonJS(function(exports) {
1661
1665
  });
1662
1666
 
1663
1667
  // node_modules/yaml/dist/nodes/addPairToJSMap.js
1664
- var require_addPairToJSMap = __commonJS(function(exports) {
1668
+ var require_addPairToJSMap = __commonJS((exports) => {
1665
1669
  var log = require_log();
1666
1670
  var merge = require_merge();
1667
1671
  var stringify = require_stringify();
@@ -1722,7 +1726,7 @@ var require_addPairToJSMap = __commonJS(function(exports) {
1722
1726
  });
1723
1727
 
1724
1728
  // node_modules/yaml/dist/nodes/Pair.js
1725
- var require_Pair = __commonJS(function(exports) {
1729
+ var require_Pair = __commonJS((exports) => {
1726
1730
  var createNode = require_createNode();
1727
1731
  var stringifyPair = require_stringifyPair();
1728
1732
  var addPairToJSMap = require_addPairToJSMap();
@@ -1760,14 +1764,14 @@ var require_Pair = __commonJS(function(exports) {
1760
1764
  });
1761
1765
 
1762
1766
  // node_modules/yaml/dist/stringify/stringifyCollection.js
1763
- var require_stringifyCollection = __commonJS(function(exports) {
1767
+ var require_stringifyCollection = __commonJS((exports) => {
1764
1768
  var identity = require_identity();
1765
1769
  var stringify = require_stringify();
1766
1770
  var stringifyComment = require_stringifyComment();
1767
1771
  function stringifyCollection(collection, ctx, options) {
1768
1772
  const flow = ctx.inFlow ?? collection.flow;
1769
- const stringify = flow ? stringifyFlowCollection : stringifyBlockCollection;
1770
- return stringify(collection, ctx, options);
1773
+ const stringify2 = flow ? stringifyFlowCollection : stringifyBlockCollection;
1774
+ return stringify2(collection, ctx, options);
1771
1775
  }
1772
1776
  function stringifyBlockCollection({ comment, items }, ctx, { blockItemPrefix, flowChars, itemIndent, onChompKeep, onComment }) {
1773
1777
  const { indent, options: { commentString } } = ctx;
@@ -1776,13 +1780,13 @@ var require_stringifyCollection = __commonJS(function(exports) {
1776
1780
  const lines = [];
1777
1781
  for (let i = 0;i < items.length; ++i) {
1778
1782
  const item = items[i];
1779
- let comment = null;
1783
+ let comment2 = null;
1780
1784
  if (identity.isNode(item)) {
1781
1785
  if (!chompKeep && item.spaceBefore)
1782
1786
  lines.push("");
1783
1787
  addCommentBefore(ctx, lines, item.commentBefore, chompKeep);
1784
1788
  if (item.comment)
1785
- comment = item.comment;
1789
+ comment2 = item.comment;
1786
1790
  } else if (identity.isPair(item)) {
1787
1791
  const ik = identity.isNode(item.key) ? item.key : null;
1788
1792
  if (ik) {
@@ -1792,12 +1796,12 @@ var require_stringifyCollection = __commonJS(function(exports) {
1792
1796
  }
1793
1797
  }
1794
1798
  chompKeep = false;
1795
- let str = stringify.stringify(item, itemCtx, () => comment = null, () => chompKeep = true);
1796
- if (comment)
1797
- str += stringifyComment.lineComment(str, itemIndent, commentString(comment));
1798
- if (chompKeep && comment)
1799
+ let str2 = stringify.stringify(item, itemCtx, () => comment2 = null, () => chompKeep = true);
1800
+ if (comment2)
1801
+ str2 += stringifyComment.lineComment(str2, itemIndent, commentString(comment2));
1802
+ if (chompKeep && comment2)
1799
1803
  chompKeep = false;
1800
- lines.push(blockItemPrefix + str);
1804
+ lines.push(blockItemPrefix + str2);
1801
1805
  }
1802
1806
  let str;
1803
1807
  if (lines.length === 0) {
@@ -1912,7 +1916,7 @@ ${indent}${end}`;
1912
1916
  });
1913
1917
 
1914
1918
  // node_modules/yaml/dist/nodes/YAMLMap.js
1915
- var require_YAMLMap = __commonJS(function(exports) {
1919
+ var require_YAMLMap = __commonJS((exports) => {
1916
1920
  var stringifyCollection = require_stringifyCollection();
1917
1921
  var addPairToJSMap = require_addPairToJSMap();
1918
1922
  var Collection = require_Collection();
@@ -2039,7 +2043,7 @@ var require_YAMLMap = __commonJS(function(exports) {
2039
2043
  });
2040
2044
 
2041
2045
  // node_modules/yaml/dist/schema/common/map.js
2042
- var require_map = __commonJS(function(exports) {
2046
+ var require_map = __commonJS((exports) => {
2043
2047
  var identity = require_identity();
2044
2048
  var YAMLMap = require_YAMLMap();
2045
2049
  var map = {
@@ -2047,10 +2051,10 @@ var require_map = __commonJS(function(exports) {
2047
2051
  default: true,
2048
2052
  nodeClass: YAMLMap.YAMLMap,
2049
2053
  tag: "tag:yaml.org,2002:map",
2050
- resolve(map, onError) {
2051
- if (!identity.isMap(map))
2054
+ resolve(map2, onError) {
2055
+ if (!identity.isMap(map2))
2052
2056
  onError("Expected a mapping for this tag");
2053
- return map;
2057
+ return map2;
2054
2058
  },
2055
2059
  createNode: (schema, obj, ctx) => YAMLMap.YAMLMap.from(schema, obj, ctx)
2056
2060
  };
@@ -2058,7 +2062,7 @@ var require_map = __commonJS(function(exports) {
2058
2062
  });
2059
2063
 
2060
2064
  // node_modules/yaml/dist/nodes/YAMLSeq.js
2061
- var require_YAMLSeq = __commonJS(function(exports) {
2065
+ var require_YAMLSeq = __commonJS((exports) => {
2062
2066
  var createNode = require_createNode();
2063
2067
  var stringifyCollection = require_stringifyCollection();
2064
2068
  var Collection = require_Collection();
@@ -2151,7 +2155,7 @@ var require_YAMLSeq = __commonJS(function(exports) {
2151
2155
  });
2152
2156
 
2153
2157
  // node_modules/yaml/dist/schema/common/seq.js
2154
- var require_seq = __commonJS(function(exports) {
2158
+ var require_seq = __commonJS((exports) => {
2155
2159
  var identity = require_identity();
2156
2160
  var YAMLSeq = require_YAMLSeq();
2157
2161
  var seq = {
@@ -2159,10 +2163,10 @@ var require_seq = __commonJS(function(exports) {
2159
2163
  default: true,
2160
2164
  nodeClass: YAMLSeq.YAMLSeq,
2161
2165
  tag: "tag:yaml.org,2002:seq",
2162
- resolve(seq, onError) {
2163
- if (!identity.isSeq(seq))
2166
+ resolve(seq2, onError) {
2167
+ if (!identity.isSeq(seq2))
2164
2168
  onError("Expected a sequence for this tag");
2165
- return seq;
2169
+ return seq2;
2166
2170
  },
2167
2171
  createNode: (schema, obj, ctx) => YAMLSeq.YAMLSeq.from(schema, obj, ctx)
2168
2172
  };
@@ -2170,7 +2174,7 @@ var require_seq = __commonJS(function(exports) {
2170
2174
  });
2171
2175
 
2172
2176
  // node_modules/yaml/dist/schema/common/string.js
2173
- var require_string = __commonJS(function(exports) {
2177
+ var require_string = __commonJS((exports) => {
2174
2178
  var stringifyString = require_stringifyString();
2175
2179
  var string = {
2176
2180
  identify: (value) => typeof value === "string",
@@ -2186,7 +2190,7 @@ var require_string = __commonJS(function(exports) {
2186
2190
  });
2187
2191
 
2188
2192
  // node_modules/yaml/dist/schema/common/null.js
2189
- var require_null = __commonJS(function(exports) {
2193
+ var require_null = __commonJS((exports) => {
2190
2194
  var Scalar = require_Scalar();
2191
2195
  var nullTag = {
2192
2196
  identify: (value) => value == null,
@@ -2201,7 +2205,7 @@ var require_null = __commonJS(function(exports) {
2201
2205
  });
2202
2206
 
2203
2207
  // node_modules/yaml/dist/schema/core/bool.js
2204
- var require_bool = __commonJS(function(exports) {
2208
+ var require_bool = __commonJS((exports) => {
2205
2209
  var Scalar = require_Scalar();
2206
2210
  var boolTag = {
2207
2211
  identify: (value) => typeof value === "boolean",
@@ -2222,7 +2226,7 @@ var require_bool = __commonJS(function(exports) {
2222
2226
  });
2223
2227
 
2224
2228
  // node_modules/yaml/dist/stringify/stringifyNumber.js
2225
- var require_stringifyNumber = __commonJS(function(exports) {
2229
+ var require_stringifyNumber = __commonJS((exports) => {
2226
2230
  function stringifyNumber({ format, minFractionDigits, tag, value }) {
2227
2231
  if (typeof value === "bigint")
2228
2232
  return String(value);
@@ -2246,7 +2250,7 @@ var require_stringifyNumber = __commonJS(function(exports) {
2246
2250
  });
2247
2251
 
2248
2252
  // node_modules/yaml/dist/schema/core/float.js
2249
- var require_float = __commonJS(function(exports) {
2253
+ var require_float = __commonJS((exports) => {
2250
2254
  var Scalar = require_Scalar();
2251
2255
  var stringifyNumber = require_stringifyNumber();
2252
2256
  var floatNaN = {
@@ -2289,7 +2293,7 @@ var require_float = __commonJS(function(exports) {
2289
2293
  });
2290
2294
 
2291
2295
  // node_modules/yaml/dist/schema/core/int.js
2292
- var require_int = __commonJS(function(exports) {
2296
+ var require_int = __commonJS((exports) => {
2293
2297
  var stringifyNumber = require_stringifyNumber();
2294
2298
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
2295
2299
  var intResolve = (str, offset, radix, { intAsBigInt }) => intAsBigInt ? BigInt(str) : parseInt(str.substring(offset), radix);
@@ -2331,7 +2335,7 @@ var require_int = __commonJS(function(exports) {
2331
2335
  });
2332
2336
 
2333
2337
  // node_modules/yaml/dist/schema/core/schema.js
2334
- var require_schema = __commonJS(function(exports) {
2338
+ var require_schema = __commonJS((exports) => {
2335
2339
  var map = require_map();
2336
2340
  var _null = require_null();
2337
2341
  var seq = require_seq();
@@ -2356,7 +2360,7 @@ var require_schema = __commonJS(function(exports) {
2356
2360
  });
2357
2361
 
2358
2362
  // node_modules/yaml/dist/schema/json/schema.js
2359
- var require_schema2 = __commonJS(function(exports) {
2363
+ var require_schema2 = __commonJS((exports) => {
2360
2364
  var Scalar = require_Scalar();
2361
2365
  var map = require_map();
2362
2366
  var seq = require_seq();
@@ -2420,7 +2424,7 @@ var require_schema2 = __commonJS(function(exports) {
2420
2424
  });
2421
2425
 
2422
2426
  // node_modules/yaml/dist/schema/yaml-1.1/binary.js
2423
- var require_binary = __commonJS(function(exports) {
2427
+ var require_binary = __commonJS((exports) => {
2424
2428
  var node_buffer = __require("buffer");
2425
2429
  var Scalar = require_Scalar();
2426
2430
  var stringifyString = require_stringifyString();
@@ -2475,7 +2479,7 @@ var require_binary = __commonJS(function(exports) {
2475
2479
  });
2476
2480
 
2477
2481
  // node_modules/yaml/dist/schema/yaml-1.1/pairs.js
2478
- var require_pairs = __commonJS(function(exports) {
2482
+ var require_pairs = __commonJS((exports) => {
2479
2483
  var identity = require_identity();
2480
2484
  var Pair = require_Pair();
2481
2485
  var Scalar = require_Scalar();
@@ -2508,8 +2512,8 @@ ${cn.comment}` : item.comment;
2508
2512
  }
2509
2513
  function createPairs(schema, iterable, ctx) {
2510
2514
  const { replacer } = ctx;
2511
- const pairs = new YAMLSeq.YAMLSeq(schema);
2512
- pairs.tag = "tag:yaml.org,2002:pairs";
2515
+ const pairs2 = new YAMLSeq.YAMLSeq(schema);
2516
+ pairs2.tag = "tag:yaml.org,2002:pairs";
2513
2517
  let i = 0;
2514
2518
  if (iterable && Symbol.iterator in Object(iterable))
2515
2519
  for (let it of iterable) {
@@ -2533,9 +2537,9 @@ ${cn.comment}` : item.comment;
2533
2537
  } else {
2534
2538
  key = it;
2535
2539
  }
2536
- pairs.items.push(Pair.createPair(key, value, ctx));
2540
+ pairs2.items.push(Pair.createPair(key, value, ctx));
2537
2541
  }
2538
- return pairs;
2542
+ return pairs2;
2539
2543
  }
2540
2544
  var pairs = {
2541
2545
  collection: "seq",
@@ -2550,7 +2554,7 @@ ${cn.comment}` : item.comment;
2550
2554
  });
2551
2555
 
2552
2556
  // node_modules/yaml/dist/schema/yaml-1.1/omap.js
2553
- var require_omap = __commonJS(function(exports) {
2557
+ var require_omap = __commonJS((exports) => {
2554
2558
  var identity = require_identity();
2555
2559
  var toJS = require_toJS();
2556
2560
  var YAMLMap = require_YAMLMap();
@@ -2589,9 +2593,9 @@ var require_omap = __commonJS(function(exports) {
2589
2593
  }
2590
2594
  static from(schema, iterable, ctx) {
2591
2595
  const pairs$1 = pairs.createPairs(schema, iterable, ctx);
2592
- const omap = new this;
2593
- omap.items = pairs$1.items;
2594
- return omap;
2596
+ const omap2 = new this;
2597
+ omap2.items = pairs$1.items;
2598
+ return omap2;
2595
2599
  }
2596
2600
  }
2597
2601
  YAMLOMap.tag = "tag:yaml.org,2002:omap";
@@ -2622,7 +2626,7 @@ var require_omap = __commonJS(function(exports) {
2622
2626
  });
2623
2627
 
2624
2628
  // node_modules/yaml/dist/schema/yaml-1.1/bool.js
2625
- var require_bool2 = __commonJS(function(exports) {
2629
+ var require_bool2 = __commonJS((exports) => {
2626
2630
  var Scalar = require_Scalar();
2627
2631
  function boolStringify({ value, source }, ctx) {
2628
2632
  const boolObj = value ? trueTag : falseTag;
@@ -2651,7 +2655,7 @@ var require_bool2 = __commonJS(function(exports) {
2651
2655
  });
2652
2656
 
2653
2657
  // node_modules/yaml/dist/schema/yaml-1.1/float.js
2654
- var require_float2 = __commonJS(function(exports) {
2658
+ var require_float2 = __commonJS((exports) => {
2655
2659
  var Scalar = require_Scalar();
2656
2660
  var stringifyNumber = require_stringifyNumber();
2657
2661
  var floatNaN = {
@@ -2697,7 +2701,7 @@ var require_float2 = __commonJS(function(exports) {
2697
2701
  });
2698
2702
 
2699
2703
  // node_modules/yaml/dist/schema/yaml-1.1/int.js
2700
- var require_int2 = __commonJS(function(exports) {
2704
+ var require_int2 = __commonJS((exports) => {
2701
2705
  var stringifyNumber = require_stringifyNumber();
2702
2706
  var intIdentify = (value) => typeof value === "bigint" || Number.isInteger(value);
2703
2707
  function intResolve(str, offset, radix, { intAsBigInt }) {
@@ -2717,8 +2721,8 @@ var require_int2 = __commonJS(function(exports) {
2717
2721
  str = `0x${str}`;
2718
2722
  break;
2719
2723
  }
2720
- const n = BigInt(str);
2721
- return sign === "-" ? BigInt(-1) * n : n;
2724
+ const n2 = BigInt(str);
2725
+ return sign === "-" ? BigInt(-1) * n2 : n2;
2722
2726
  }
2723
2727
  const n = parseInt(str, radix);
2724
2728
  return sign === "-" ? -1 * n : n;
@@ -2773,7 +2777,7 @@ var require_int2 = __commonJS(function(exports) {
2773
2777
  });
2774
2778
 
2775
2779
  // node_modules/yaml/dist/schema/yaml-1.1/set.js
2776
- var require_set = __commonJS(function(exports) {
2780
+ var require_set = __commonJS((exports) => {
2777
2781
  var identity = require_identity();
2778
2782
  var Pair = require_Pair();
2779
2783
  var YAMLMap = require_YAMLMap();
@@ -2822,14 +2826,14 @@ var require_set = __commonJS(function(exports) {
2822
2826
  }
2823
2827
  static from(schema, iterable, ctx) {
2824
2828
  const { replacer } = ctx;
2825
- const set = new this(schema);
2829
+ const set2 = new this(schema);
2826
2830
  if (iterable && Symbol.iterator in Object(iterable))
2827
2831
  for (let value of iterable) {
2828
2832
  if (typeof replacer === "function")
2829
2833
  value = replacer.call(iterable, value, value);
2830
- set.items.push(Pair.createPair(value, null, ctx));
2834
+ set2.items.push(Pair.createPair(value, null, ctx));
2831
2835
  }
2832
- return set;
2836
+ return set2;
2833
2837
  }
2834
2838
  }
2835
2839
  YAMLSet.tag = "tag:yaml.org,2002:set";
@@ -2856,13 +2860,13 @@ var require_set = __commonJS(function(exports) {
2856
2860
  });
2857
2861
 
2858
2862
  // node_modules/yaml/dist/schema/yaml-1.1/timestamp.js
2859
- var require_timestamp = __commonJS(function(exports) {
2863
+ var require_timestamp = __commonJS((exports) => {
2860
2864
  var stringifyNumber = require_stringifyNumber();
2861
2865
  function parseSexagesimal(str, asBigInt) {
2862
2866
  const sign = str[0];
2863
2867
  const parts = sign === "-" || sign === "+" ? str.substring(1) : str;
2864
2868
  const num = (n) => asBigInt ? BigInt(n) : Number(n);
2865
- const res = parts.replace(/_/g, "").split(":").reduce((res, p) => res * num(60) + num(p), num(0));
2869
+ const res = parts.replace(/_/g, "").split(":").reduce((res2, p) => res2 * num(60) + num(p), num(0));
2866
2870
  return sign === "-" ? num(-1) * res : res;
2867
2871
  }
2868
2872
  function stringifySexagesimal(node) {
@@ -2938,7 +2942,7 @@ var require_timestamp = __commonJS(function(exports) {
2938
2942
  });
2939
2943
 
2940
2944
  // node_modules/yaml/dist/schema/yaml-1.1/schema.js
2941
- var require_schema3 = __commonJS(function(exports) {
2945
+ var require_schema3 = __commonJS((exports) => {
2942
2946
  var map = require_map();
2943
2947
  var _null = require_null();
2944
2948
  var seq = require_seq();
@@ -2979,7 +2983,7 @@ var require_schema3 = __commonJS(function(exports) {
2979
2983
  });
2980
2984
 
2981
2985
  // node_modules/yaml/dist/schema/tags.js
2982
- var require_tags = __commonJS(function(exports) {
2986
+ var require_tags = __commonJS((exports) => {
2983
2987
  var map = require_map();
2984
2988
  var _null = require_null();
2985
2989
  var seq = require_seq();
@@ -3053,16 +3057,16 @@ var require_tags = __commonJS(function(exports) {
3053
3057
  }
3054
3058
  if (addMergeTag)
3055
3059
  tags = tags.concat(merge.merge);
3056
- return tags.reduce((tags, tag) => {
3060
+ return tags.reduce((tags2, tag) => {
3057
3061
  const tagObj = typeof tag === "string" ? tagsByName[tag] : tag;
3058
3062
  if (!tagObj) {
3059
3063
  const tagName = JSON.stringify(tag);
3060
3064
  const keys = Object.keys(tagsByName).map((key) => JSON.stringify(key)).join(", ");
3061
3065
  throw new Error(`Unknown custom tag ${tagName}; use one of ${keys}`);
3062
3066
  }
3063
- if (!tags.includes(tagObj))
3064
- tags.push(tagObj);
3065
- return tags;
3067
+ if (!tags2.includes(tagObj))
3068
+ tags2.push(tagObj);
3069
+ return tags2;
3066
3070
  }, []);
3067
3071
  }
3068
3072
  exports.coreKnownTags = coreKnownTags;
@@ -3070,7 +3074,7 @@ var require_tags = __commonJS(function(exports) {
3070
3074
  });
3071
3075
 
3072
3076
  // node_modules/yaml/dist/schema/Schema.js
3073
- var require_Schema = __commonJS(function(exports) {
3077
+ var require_Schema = __commonJS((exports) => {
3074
3078
  var identity = require_identity();
3075
3079
  var map = require_map();
3076
3080
  var seq = require_seq();
@@ -3100,7 +3104,7 @@ var require_Schema = __commonJS(function(exports) {
3100
3104
  });
3101
3105
 
3102
3106
  // node_modules/yaml/dist/stringify/stringifyDocument.js
3103
- var require_stringifyDocument = __commonJS(function(exports) {
3107
+ var require_stringifyDocument = __commonJS((exports) => {
3104
3108
  var identity = require_identity();
3105
3109
  var stringify = require_stringify();
3106
3110
  var stringifyComment = require_stringifyComment();
@@ -3180,7 +3184,7 @@ var require_stringifyDocument = __commonJS(function(exports) {
3180
3184
  });
3181
3185
 
3182
3186
  // node_modules/yaml/dist/doc/Document.js
3183
- var require_Document = __commonJS(function(exports) {
3187
+ var require_Document = __commonJS((exports) => {
3184
3188
  var Alias = require_Alias();
3185
3189
  var Collection = require_Collection();
3186
3190
  var identity = require_identity();
@@ -3389,8 +3393,8 @@ var require_Document = __commonJS(function(exports) {
3389
3393
  };
3390
3394
  const res = toJS.toJS(this.contents, jsonArg ?? "", ctx);
3391
3395
  if (typeof onAnchor === "function")
3392
- for (const { count, res } of ctx.anchors.values())
3393
- onAnchor(res, count);
3396
+ for (const { count, res: res2 } of ctx.anchors.values())
3397
+ onAnchor(res2, count);
3394
3398
  return typeof reviver === "function" ? applyReviver.applyReviver(reviver, { "": res }, "", res) : res;
3395
3399
  }
3396
3400
  toJSON(jsonArg, onAnchor) {
@@ -3415,7 +3419,7 @@ var require_Document = __commonJS(function(exports) {
3415
3419
  });
3416
3420
 
3417
3421
  // node_modules/yaml/dist/errors.js
3418
- var require_errors = __commonJS(function(exports) {
3422
+ var require_errors = __commonJS((exports) => {
3419
3423
  class YAMLError extends Error {
3420
3424
  constructor(name, pos, code, message) {
3421
3425
  super();
@@ -3480,7 +3484,7 @@ ${pointer}
3480
3484
  });
3481
3485
 
3482
3486
  // node_modules/yaml/dist/compose/resolve-props.js
3483
- var require_resolve_props = __commonJS(function(exports) {
3487
+ var require_resolve_props = __commonJS((exports) => {
3484
3488
  function resolveProps(tokens, { flow, indicator, next, offset, onError, parentIndent, startOnNewline }) {
3485
3489
  let spaceBefore = false;
3486
3490
  let atNewline = startOnNewline;
@@ -3610,7 +3614,7 @@ var require_resolve_props = __commonJS(function(exports) {
3610
3614
  });
3611
3615
 
3612
3616
  // node_modules/yaml/dist/compose/util-contains-newline.js
3613
- var require_util_contains_newline = __commonJS(function(exports) {
3617
+ var require_util_contains_newline = __commonJS((exports) => {
3614
3618
  function containsNewline(key) {
3615
3619
  if (!key)
3616
3620
  return null;
@@ -3650,7 +3654,7 @@ var require_util_contains_newline = __commonJS(function(exports) {
3650
3654
  });
3651
3655
 
3652
3656
  // node_modules/yaml/dist/compose/util-flow-indent-check.js
3653
- var require_util_flow_indent_check = __commonJS(function(exports) {
3657
+ var require_util_flow_indent_check = __commonJS((exports) => {
3654
3658
  var utilContainsNewline = require_util_contains_newline();
3655
3659
  function flowIndentCheck(indent, fc, onError) {
3656
3660
  if (fc?.type === "flow-collection") {
@@ -3665,7 +3669,7 @@ var require_util_flow_indent_check = __commonJS(function(exports) {
3665
3669
  });
3666
3670
 
3667
3671
  // node_modules/yaml/dist/compose/util-map-includes.js
3668
- var require_util_map_includes = __commonJS(function(exports) {
3672
+ var require_util_map_includes = __commonJS((exports) => {
3669
3673
  var identity = require_identity();
3670
3674
  function mapIncludes(ctx, items, search) {
3671
3675
  const { uniqueKeys } = ctx.options;
@@ -3678,7 +3682,7 @@ var require_util_map_includes = __commonJS(function(exports) {
3678
3682
  });
3679
3683
 
3680
3684
  // node_modules/yaml/dist/compose/resolve-block-map.js
3681
- var require_resolve_block_map = __commonJS(function(exports) {
3685
+ var require_resolve_block_map = __commonJS((exports) => {
3682
3686
  var Pair = require_Pair();
3683
3687
  var YAMLMap = require_YAMLMap();
3684
3688
  var resolveProps = require_resolve_props();
@@ -3785,7 +3789,7 @@ var require_resolve_block_map = __commonJS(function(exports) {
3785
3789
  });
3786
3790
 
3787
3791
  // node_modules/yaml/dist/compose/resolve-block-seq.js
3788
- var require_resolve_block_seq = __commonJS(function(exports) {
3792
+ var require_resolve_block_seq = __commonJS((exports) => {
3789
3793
  var YAMLSeq = require_YAMLSeq();
3790
3794
  var resolveProps = require_resolve_props();
3791
3795
  var utilFlowIndentCheck = require_util_flow_indent_check();
@@ -3833,7 +3837,7 @@ var require_resolve_block_seq = __commonJS(function(exports) {
3833
3837
  });
3834
3838
 
3835
3839
  // node_modules/yaml/dist/compose/resolve-end.js
3836
- var require_resolve_end = __commonJS(function(exports) {
3840
+ var require_resolve_end = __commonJS((exports) => {
3837
3841
  function resolveEnd(end, offset, reqSpace, onError) {
3838
3842
  let comment = "";
3839
3843
  if (end) {
@@ -3873,7 +3877,7 @@ var require_resolve_end = __commonJS(function(exports) {
3873
3877
  });
3874
3878
 
3875
3879
  // node_modules/yaml/dist/compose/resolve-flow-collection.js
3876
- var require_resolve_flow_collection = __commonJS(function(exports) {
3880
+ var require_resolve_flow_collection = __commonJS((exports) => {
3877
3881
  var identity = require_identity();
3878
3882
  var Pair = require_Pair();
3879
3883
  var YAMLMap = require_YAMLMap();
@@ -4064,7 +4068,7 @@ var require_resolve_flow_collection = __commonJS(function(exports) {
4064
4068
  });
4065
4069
 
4066
4070
  // node_modules/yaml/dist/compose/compose-collection.js
4067
- var require_compose_collection = __commonJS(function(exports) {
4071
+ var require_compose_collection = __commonJS((exports) => {
4068
4072
  var identity = require_identity();
4069
4073
  var Scalar = require_Scalar();
4070
4074
  var YAMLMap = require_YAMLMap();
@@ -4126,7 +4130,7 @@ var require_compose_collection = __commonJS(function(exports) {
4126
4130
  });
4127
4131
 
4128
4132
  // node_modules/yaml/dist/compose/resolve-block-scalar.js
4129
- var require_resolve_block_scalar = __commonJS(function(exports) {
4133
+ var require_resolve_block_scalar = __commonJS((exports) => {
4130
4134
  var Scalar = require_Scalar();
4131
4135
  function resolveBlockScalar(ctx, scalar, onError) {
4132
4136
  const start = scalar.offset;
@@ -4144,12 +4148,12 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
4144
4148
  break;
4145
4149
  }
4146
4150
  if (chompStart === 0) {
4147
- const value = header.chomp === "+" && lines.length > 0 ? `
4151
+ const value2 = header.chomp === "+" && lines.length > 0 ? `
4148
4152
  `.repeat(Math.max(1, lines.length - 1)) : "";
4149
- let end = start + header.length;
4153
+ let end2 = start + header.length;
4150
4154
  if (scalar.source)
4151
- end += scalar.source.length;
4152
- return { value, type, comment: header.comment, range: [start, end, end] };
4155
+ end2 += scalar.source.length;
4156
+ return { value: value2, type, comment: header.comment, range: [start, end2, end2] };
4153
4157
  }
4154
4158
  let trimIndent = scalar.indent + header.indent;
4155
4159
  let offset = scalar.offset + header.length;
@@ -4319,7 +4323,7 @@ var require_resolve_block_scalar = __commonJS(function(exports) {
4319
4323
  });
4320
4324
 
4321
4325
  // node_modules/yaml/dist/compose/resolve-flow-scalar.js
4322
- var require_resolve_flow_scalar = __commonJS(function(exports) {
4326
+ var require_resolve_flow_scalar = __commonJS((exports) => {
4323
4327
  var Scalar = require_Scalar();
4324
4328
  var resolveEnd = require_resolve_end();
4325
4329
  function resolveFlowScalar(scalar, strict, onError) {
@@ -4535,7 +4539,7 @@ var require_resolve_flow_scalar = __commonJS(function(exports) {
4535
4539
  });
4536
4540
 
4537
4541
  // node_modules/yaml/dist/compose/compose-scalar.js
4538
- var require_compose_scalar = __commonJS(function(exports) {
4542
+ var require_compose_scalar = __commonJS((exports) => {
4539
4543
  var identity = require_identity();
4540
4544
  var Scalar = require_Scalar();
4541
4545
  var resolveBlockScalar = require_resolve_block_scalar();
@@ -4597,9 +4601,9 @@ var require_compose_scalar = __commonJS(function(exports) {
4597
4601
  return schema[identity.SCALAR];
4598
4602
  }
4599
4603
  function findScalarTagByTest({ atKey, directives, schema }, value, token, onError) {
4600
- const tag = schema.tags.find((tag) => (tag.default === true || atKey && tag.default === "key") && tag.test?.test(value)) || schema[identity.SCALAR];
4604
+ const tag = schema.tags.find((tag2) => (tag2.default === true || atKey && tag2.default === "key") && tag2.test?.test(value)) || schema[identity.SCALAR];
4601
4605
  if (schema.compat) {
4602
- const compat = schema.compat.find((tag) => tag.default && tag.test?.test(value)) ?? schema[identity.SCALAR];
4606
+ const compat = schema.compat.find((tag2) => tag2.default && tag2.test?.test(value)) ?? schema[identity.SCALAR];
4603
4607
  if (tag.tag !== compat.tag) {
4604
4608
  const ts = directives.tagString(tag.tag);
4605
4609
  const cs = directives.tagString(compat.tag);
@@ -4613,7 +4617,7 @@ var require_compose_scalar = __commonJS(function(exports) {
4613
4617
  });
4614
4618
 
4615
4619
  // node_modules/yaml/dist/compose/util-empty-scalar-position.js
4616
- var require_util_empty_scalar_position = __commonJS(function(exports) {
4620
+ var require_util_empty_scalar_position = __commonJS((exports) => {
4617
4621
  function emptyScalarPosition(offset, before, pos) {
4618
4622
  if (before) {
4619
4623
  pos ?? (pos = before.length);
@@ -4640,7 +4644,7 @@ var require_util_empty_scalar_position = __commonJS(function(exports) {
4640
4644
  });
4641
4645
 
4642
4646
  // node_modules/yaml/dist/compose/compose-node.js
4643
- var require_compose_node = __commonJS(function(exports) {
4647
+ var require_compose_node = __commonJS((exports) => {
4644
4648
  var Alias = require_Alias();
4645
4649
  var identity = require_identity();
4646
4650
  var composeCollection = require_compose_collection();
@@ -4743,7 +4747,7 @@ var require_compose_node = __commonJS(function(exports) {
4743
4747
  });
4744
4748
 
4745
4749
  // node_modules/yaml/dist/compose/compose-doc.js
4746
- var require_compose_doc = __commonJS(function(exports) {
4750
+ var require_compose_doc = __commonJS((exports) => {
4747
4751
  var Document = require_Document();
4748
4752
  var composeNode = require_compose_node();
4749
4753
  var resolveEnd = require_resolve_end();
@@ -4783,7 +4787,7 @@ var require_compose_doc = __commonJS(function(exports) {
4783
4787
  });
4784
4788
 
4785
4789
  // node_modules/yaml/dist/compose/composer.js
4786
- var require_composer = __commonJS(function(exports) {
4790
+ var require_composer = __commonJS((exports) => {
4787
4791
  var node_process = __require("process");
4788
4792
  var directives = require_directives();
4789
4793
  var Document = require_Document();
@@ -4974,7 +4978,7 @@ ${end.comment}` : end.comment;
4974
4978
  });
4975
4979
 
4976
4980
  // node_modules/yaml/dist/parse/cst-scalar.js
4977
- var require_cst_scalar = __commonJS(function(exports) {
4981
+ var require_cst_scalar = __commonJS((exports) => {
4978
4982
  var resolveBlockScalar = require_resolve_block_scalar();
4979
4983
  var resolveFlowScalar = require_resolve_flow_scalar();
4980
4984
  var errors = require_errors();
@@ -5164,7 +5168,7 @@ var require_cst_scalar = __commonJS(function(exports) {
5164
5168
  });
5165
5169
 
5166
5170
  // node_modules/yaml/dist/parse/cst-stringify.js
5167
- var require_cst_stringify = __commonJS(function(exports) {
5171
+ var require_cst_stringify = __commonJS((exports) => {
5168
5172
  var stringify = (cst) => ("type" in cst) ? stringifyToken(cst) : stringifyItem(cst);
5169
5173
  function stringifyToken(token) {
5170
5174
  switch (token.type) {
@@ -5222,7 +5226,7 @@ var require_cst_stringify = __commonJS(function(exports) {
5222
5226
  });
5223
5227
 
5224
5228
  // node_modules/yaml/dist/parse/cst-visit.js
5225
- var require_cst_visit = __commonJS(function(exports) {
5229
+ var require_cst_visit = __commonJS((exports) => {
5226
5230
  var BREAK = Symbol("break visit");
5227
5231
  var SKIP = Symbol("skip children");
5228
5232
  var REMOVE = Symbol("remove item");
@@ -5281,7 +5285,7 @@ var require_cst_visit = __commonJS(function(exports) {
5281
5285
  });
5282
5286
 
5283
5287
  // node_modules/yaml/dist/parse/cst.js
5284
- var require_cst = __commonJS(function(exports) {
5288
+ var require_cst = __commonJS((exports) => {
5285
5289
  var cstScalar = require_cst_scalar();
5286
5290
  var cstStringify = require_cst_stringify();
5287
5291
  var cstVisit = require_cst_visit();
@@ -5382,7 +5386,7 @@ var require_cst = __commonJS(function(exports) {
5382
5386
  });
5383
5387
 
5384
5388
  // node_modules/yaml/dist/parse/lexer.js
5385
- var require_lexer = __commonJS(function(exports) {
5389
+ var require_lexer = __commonJS((exports) => {
5386
5390
  var cst = require_cst();
5387
5391
  function isEmpty(ch) {
5388
5392
  switch (ch) {
@@ -5755,18 +5759,18 @@ var require_lexer = __commonJS(function(exports) {
5755
5759
  let indent = 0;
5756
5760
  let ch;
5757
5761
  loop:
5758
- for (let i = this.pos;ch = this.buffer[i]; ++i) {
5762
+ for (let i2 = this.pos;ch = this.buffer[i2]; ++i2) {
5759
5763
  switch (ch) {
5760
5764
  case " ":
5761
5765
  indent += 1;
5762
5766
  break;
5763
5767
  case `
5764
5768
  `:
5765
- nl = i;
5769
+ nl = i2;
5766
5770
  indent = 0;
5767
5771
  break;
5768
5772
  case "\r": {
5769
- const next = this.buffer[i + 1];
5773
+ const next = this.buffer[i2 + 1];
5770
5774
  if (!next && !this.atEnd)
5771
5775
  return this.setNext("block-scalar");
5772
5776
  if (next === `
@@ -5809,16 +5813,16 @@ var require_lexer = __commonJS(function(exports) {
5809
5813
  nl = i - 1;
5810
5814
  } else if (!this.blockScalarKeep) {
5811
5815
  do {
5812
- let i = nl - 1;
5813
- let ch = this.buffer[i];
5814
- if (ch === "\r")
5815
- ch = this.buffer[--i];
5816
- const lastChar = i;
5817
- while (ch === " ")
5818
- ch = this.buffer[--i];
5819
- if (ch === `
5820
- ` && i >= this.pos && i + 1 + indent > lastChar)
5821
- nl = i;
5816
+ let i2 = nl - 1;
5817
+ let ch2 = this.buffer[i2];
5818
+ if (ch2 === "\r")
5819
+ ch2 = this.buffer[--i2];
5820
+ const lastChar = i2;
5821
+ while (ch2 === " ")
5822
+ ch2 = this.buffer[--i2];
5823
+ if (ch2 === `
5824
+ ` && i2 >= this.pos && i2 + 1 + indent > lastChar)
5825
+ nl = i2;
5822
5826
  else
5823
5827
  break;
5824
5828
  } while (true);
@@ -5979,7 +5983,7 @@ var require_lexer = __commonJS(function(exports) {
5979
5983
  });
5980
5984
 
5981
5985
  // node_modules/yaml/dist/parse/line-counter.js
5982
- var require_line_counter = __commonJS(function(exports) {
5986
+ var require_line_counter = __commonJS((exports) => {
5983
5987
  class LineCounter {
5984
5988
  constructor() {
5985
5989
  this.lineStarts = [];
@@ -6007,7 +6011,7 @@ var require_line_counter = __commonJS(function(exports) {
6007
6011
  });
6008
6012
 
6009
6013
  // node_modules/yaml/dist/parse/parser.js
6010
- var require_parser = __commonJS(function(exports) {
6014
+ var require_parser = __commonJS((exports) => {
6011
6015
  var node_process = __require("process");
6012
6016
  var cst = require_cst();
6013
6017
  var lexer = require_lexer();
@@ -6505,12 +6509,12 @@ var require_parser = __commonJS(function(exports) {
6505
6509
  if (includesToken(it.start, "newline")) {
6506
6510
  Object.assign(it, { key: null, sep: [this.sourceToken] });
6507
6511
  } else {
6508
- const start = getFirstKeyStartProps(it.start);
6512
+ const start2 = getFirstKeyStartProps(it.start);
6509
6513
  this.stack.push({
6510
6514
  type: "block-map",
6511
6515
  offset: this.offset,
6512
6516
  indent: this.indent,
6513
- items: [{ start, key: null, sep: [this.sourceToken] }]
6517
+ items: [{ start: start2, key: null, sep: [this.sourceToken] }]
6514
6518
  });
6515
6519
  }
6516
6520
  } else if (it.value) {
@@ -6523,7 +6527,7 @@ var require_parser = __commonJS(function(exports) {
6523
6527
  items: [{ start, key: null, sep: [this.sourceToken] }]
6524
6528
  });
6525
6529
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
6526
- const start = getFirstKeyStartProps(it.start);
6530
+ const start2 = getFirstKeyStartProps(it.start);
6527
6531
  const key = it.key;
6528
6532
  const sep = it.sep;
6529
6533
  sep.push(this.sourceToken);
@@ -6533,7 +6537,7 @@ var require_parser = __commonJS(function(exports) {
6533
6537
  type: "block-map",
6534
6538
  offset: this.offset,
6535
6539
  indent: this.indent,
6536
- items: [{ start, key, sep }]
6540
+ items: [{ start: start2, key, sep }]
6537
6541
  });
6538
6542
  } else if (start.length > 0) {
6539
6543
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -6863,7 +6867,7 @@ var require_parser = __commonJS(function(exports) {
6863
6867
  });
6864
6868
 
6865
6869
  // node_modules/yaml/dist/public-api.js
6866
- var require_public_api = __commonJS(function(exports) {
6870
+ var require_public_api = __commonJS((exports) => {
6867
6871
  var composer = require_composer();
6868
6872
  var Document = require_Document();
6869
6873
  var errors = require_errors();
@@ -6877,22 +6881,22 @@ var require_public_api = __commonJS(function(exports) {
6877
6881
  return { lineCounter: lineCounter$1, prettyErrors };
6878
6882
  }
6879
6883
  function parseAllDocuments(source, options = {}) {
6880
- const { lineCounter, prettyErrors } = parseOptions(options);
6881
- const parser$1 = new parser.Parser(lineCounter?.addNewLine);
6884
+ const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
6885
+ const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
6882
6886
  const composer$1 = new composer.Composer(options);
6883
6887
  const docs = Array.from(composer$1.compose(parser$1.parse(source)));
6884
- if (prettyErrors && lineCounter)
6888
+ if (prettyErrors && lineCounter2)
6885
6889
  for (const doc of docs) {
6886
- doc.errors.forEach(errors.prettifyError(source, lineCounter));
6887
- doc.warnings.forEach(errors.prettifyError(source, lineCounter));
6890
+ doc.errors.forEach(errors.prettifyError(source, lineCounter2));
6891
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
6888
6892
  }
6889
6893
  if (docs.length > 0)
6890
6894
  return docs;
6891
6895
  return Object.assign([], { empty: true }, composer$1.streamInfo());
6892
6896
  }
6893
6897
  function parseDocument(source, options = {}) {
6894
- const { lineCounter, prettyErrors } = parseOptions(options);
6895
- const parser$1 = new parser.Parser(lineCounter?.addNewLine);
6898
+ const { lineCounter: lineCounter2, prettyErrors } = parseOptions(options);
6899
+ const parser$1 = new parser.Parser(lineCounter2?.addNewLine);
6896
6900
  const composer$1 = new composer.Composer(options);
6897
6901
  let doc = null;
6898
6902
  for (const _doc of composer$1.compose(parser$1.parse(source), true, source.length)) {
@@ -6903,9 +6907,9 @@ var require_public_api = __commonJS(function(exports) {
6903
6907
  break;
6904
6908
  }
6905
6909
  }
6906
- if (prettyErrors && lineCounter) {
6907
- doc.errors.forEach(errors.prettifyError(source, lineCounter));
6908
- doc.warnings.forEach(errors.prettifyError(source, lineCounter));
6910
+ if (prettyErrors && lineCounter2) {
6911
+ doc.errors.forEach(errors.prettifyError(source, lineCounter2));
6912
+ doc.warnings.forEach(errors.prettifyError(source, lineCounter2));
6909
6913
  }
6910
6914
  return doc;
6911
6915
  }
@@ -7423,6 +7427,20 @@ var init_workflows = __esm(() => {
7423
7427
  });
7424
7428
 
7425
7429
  // src/core.ts
7430
+ var exports_core = {};
7431
+ __export(exports_core, {
7432
+ selectPacks: () => selectPacks,
7433
+ parseHarness: () => parseHarness,
7434
+ parseConfig: () => parseConfig,
7435
+ parseCatalog: () => parseCatalog,
7436
+ installedVersion: () => installedVersion,
7437
+ installArgs: () => installArgs,
7438
+ identity: () => identity2,
7439
+ harnesses: () => harnesses,
7440
+ fetchCatalog: () => fetchCatalog,
7441
+ compatibilitySetupMessage: () => compatibilitySetupMessage,
7442
+ catalogChanges: () => catalogChanges
7443
+ });
7426
7444
  import { resolve } from "path";
7427
7445
  function compatibilitySetupMessage(harness) {
7428
7446
  return harness === "hermes" ? undefined : harnesses[harness].setup;
@@ -7569,9 +7587,9 @@ var init_core = __esm(() => {
7569
7587
  });
7570
7588
 
7571
7589
  // src/cli.ts
7572
- import { mkdir as mkdir3, readFile as readFile5, writeFile as writeFile3, rename as rename3, rm as rm3, realpath, mkdtemp } from "fs/promises";
7573
- import { resolve as resolve5, join as join5, dirname as dirname2, basename } from "path";
7574
- import { fileURLToPath } from "url";
7590
+ import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile4, rename as rename4, rm as rm4, realpath, mkdtemp } from "fs/promises";
7591
+ import { resolve as resolve8, join as join8, dirname as dirname2, basename } from "path";
7592
+ import { fileURLToPath as fileURLToPath2 } from "url";
7575
7593
  import { parseArgs } from "util";
7576
7594
  // catalog/skills.json
7577
7595
  var skills_default = {
@@ -7676,8 +7694,8 @@ var skills_default = {
7676
7694
  id: "defi-yield-skills",
7677
7695
  source: "galleonlabs/crypto-defi-skills",
7678
7696
  description: "Evaluate vaults and yield tokens, including liquidity and maturity.",
7679
- version: "0.2.1",
7680
- revision: "9fe67c24efc0fd5796066605b29576f3b8f2de94",
7697
+ version: "0.3.0",
7698
+ revision: "27960db6bc3dfd4e3264b73232a0196dd845c37c",
7681
7699
  skills: [
7682
7700
  "galleon-defi-yield",
7683
7701
  "galleon-pendle-maturity",
@@ -7818,7 +7836,7 @@ var skills_default = {
7818
7836
  // package.json
7819
7837
  var package_default = {
7820
7838
  name: "boomkin",
7821
- version: "0.10.0",
7839
+ version: "0.12.0",
7822
7840
  description: "Your open-source DeFi desk: native Hermes research projects, verifiable evidence and independent financial skills.",
7823
7841
  type: "module",
7824
7842
  license: "MIT",
@@ -7828,7 +7846,7 @@ var package_default = {
7828
7846
  test: "bun test test",
7829
7847
  typecheck: "tsc --noEmit",
7830
7848
  check: "bun run typecheck && bun run test",
7831
- build: "bun build src/cli.ts --target=bun --outdir=dist",
7849
+ build: "bun scripts/build.ts",
7832
7850
  smoke: "bun scripts/smoke.ts",
7833
7851
  "build:site": "bun scripts/build-site.ts",
7834
7852
  "serve:site": "bun scripts/serve-site.ts",
@@ -7840,8 +7858,8 @@ var package_default = {
7840
7858
  },
7841
7859
  devDependencies: {
7842
7860
  "@types/bun": "1.4.2",
7843
- marked: "16.4.0",
7844
- typescript: "5.9.3"
7861
+ marked: "18.1.0",
7862
+ typescript: "7.0.2"
7845
7863
  },
7846
7864
  bin: {
7847
7865
  boomkin: "dist/cli.js"
@@ -7924,10 +7942,10 @@ async function packageDirectory(pack, checkout) {
7924
7942
  const manifest = JSON.parse(await readFile(join(path, "package.json"), "utf8"));
7925
7943
  if (manifest.name !== pack.package || manifest.version !== pack.version)
7926
7944
  throw new Error(`Package release metadata mismatch: ${pack.id}`);
7927
- await Promise.resolve().then(() => init_core());
7945
+ const { installedVersion: installedVersion2 } = await Promise.resolve().then(() => (init_core(), exports_core));
7928
7946
  for (const skill of pack.skills) {
7929
7947
  const text = await readFile(join(path, "skills", skill, "SKILL.md"), "utf8");
7930
- if (installedVersion(text) !== pack.version)
7948
+ if (installedVersion2(text) !== pack.version)
7931
7949
  throw new Error(`Source skill version mismatch: ${skill}`);
7932
7950
  }
7933
7951
  return path;
@@ -7946,6 +7964,43 @@ import { access, chmod, lstat, mkdir, readFile, rename, rm, writeFile } from "fs
7946
7964
  import { constants } from "fs";
7947
7965
  import { resolve as resolve2, join } from "path";
7948
7966
  import { createHash, randomUUID } from "crypto";
7967
+
7968
+ // src/processes.ts
7969
+ async function terminateOwnedProcess(child, group, graceMs = 2000) {
7970
+ const signal = (value) => {
7971
+ try {
7972
+ if (group)
7973
+ process.kill(-child.pid, value);
7974
+ else if (child.exitCode === null)
7975
+ child.kill(value);
7976
+ } catch {}
7977
+ };
7978
+ const groupExists = () => {
7979
+ try {
7980
+ process.kill(-child.pid, 0);
7981
+ return true;
7982
+ } catch (error) {
7983
+ return error.code !== "ESRCH";
7984
+ }
7985
+ };
7986
+ signal("SIGTERM");
7987
+ let timer;
7988
+ const escalation = new Promise((done) => {
7989
+ timer = setTimeout(() => {
7990
+ signal("SIGKILL");
7991
+ done();
7992
+ }, graceMs);
7993
+ });
7994
+ try {
7995
+ await child.exited;
7996
+ if (group && groupExists())
7997
+ await escalation;
7998
+ } finally {
7999
+ clearTimeout(timer);
8000
+ }
8001
+ }
8002
+
8003
+ // src/hermes.ts
7949
8004
  var HERMES_VERSION = "0.21.5";
7950
8005
  var HERMES_COMMIT = "f97608f178d1ffeca59860195ab7da295f7c8e5f";
7951
8006
  var HERMES_INSTALLER_SHA256 = "2017ddf0cc7bc6cfb70d40dc9fba1d916f47dbcccf5fe73bdee2cf93a11262af";
@@ -7994,6 +8049,22 @@ async function readHermesConfig(directory) {
7994
8049
  const root = await profilePath(directory);
7995
8050
  return document(await textOrEmpty(join(root, "config.yaml"))).toJS({ maxAliasCount: 0 });
7996
8051
  }
8052
+ function hermesModelConfigured(config) {
8053
+ const object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
8054
+ const model = config.model;
8055
+ if (typeof model === "string")
8056
+ return !!model.trim();
8057
+ if (!object(model))
8058
+ return false;
8059
+ const flatten = (value) => {
8060
+ if (!object(value))
8061
+ return value;
8062
+ const id2 = value.model || value.default;
8063
+ return typeof id2 === "string" ? id2.trim() : id2;
8064
+ };
8065
+ const id = flatten(model.default) || flatten(model.model) || flatten(model.name);
8066
+ return typeof id === "string" && !!id.trim();
8067
+ }
7997
8068
  async function executableAt(path) {
7998
8069
  try {
7999
8070
  await access(path, constants.X_OK);
@@ -8022,11 +8093,29 @@ async function runHermes(directory, args, options = {}) {
8022
8093
  throw new Error("Hermes runtime is missing. Run onboarding with runtime installation enabled.");
8023
8094
  if (args.some((arg) => ["-p", "--profile"].includes(arg) || arg.startsWith("--profile=")))
8024
8095
  throw new Error("Select the Boomkin directory instead of overriding its Hermes profile");
8025
- const child = Bun.spawn([executable, "--profile", "default", ...args], { cwd: root, env: nativeEnvironment(root), stdin: "inherit", stdout: "inherit", stderr: "inherit" });
8026
- if (await child.exited !== 0)
8027
- throw new Error("Hermes command failed; review its native output above.");
8096
+ options.signal?.throwIfAborted();
8097
+ const ownGroup = !!options.signal && process.platform !== "win32";
8098
+ const child = Bun.spawn([executable, "--profile", "default", ...args], { cwd: root, env: nativeEnvironment(root), stdin: "inherit", stdout: "inherit", stderr: "inherit", detached: ownGroup });
8099
+ let termination;
8100
+ const abort = () => {
8101
+ termination ??= terminateOwnedProcess(child, ownGroup);
8102
+ };
8103
+ options.signal?.addEventListener("abort", abort, { once: true });
8104
+ try {
8105
+ if (options.signal?.aborted)
8106
+ abort();
8107
+ const code = await child.exited;
8108
+ options.signal?.throwIfAborted();
8109
+ if (code !== 0)
8110
+ throw new Error("Hermes command failed; review its native output above.");
8111
+ } finally {
8112
+ options.signal?.removeEventListener("abort", abort);
8113
+ if (termination)
8114
+ await termination;
8115
+ }
8028
8116
  }
8029
8117
  async function ensureRuntime(directory, options) {
8118
+ options.signal?.throwIfAborted();
8030
8119
  const root = await profilePath(directory);
8031
8120
  const existing = await findRuntime(root);
8032
8121
  if (existing) {
@@ -8035,7 +8124,7 @@ async function ensureRuntime(directory, options) {
8035
8124
  return existing;
8036
8125
  }
8037
8126
  await mkdir(root, { recursive: true, mode: 448 });
8038
- const status = await localProfileStatus(root);
8127
+ const status = await localProfileStatus(root, { signal: options.signal });
8039
8128
  if (!status.runtime.available)
8040
8129
  throw new Error("The existing Hermes executable did not report a valid version; repair it before onboarding");
8041
8130
  const [major, minor] = status.runtime.version.split(".").map(Number);
@@ -8054,7 +8143,7 @@ async function ensureRuntime(directory, options) {
8054
8143
  if (process.platform === "win32")
8055
8144
  throw new Error("Install Hermes with the official Windows installer first, then rerun Boomkin onboarding.");
8056
8145
  await mkdir(join(root, ".boomkin"), { recursive: true, mode: 448 });
8057
- const response = await fetch(HERMES_INSTALLER_URL, { signal: AbortSignal.timeout(30000) });
8146
+ const response = await fetch(HERMES_INSTALLER_URL, { signal: AbortSignal.any([AbortSignal.timeout(30000), ...options.signal ? [options.signal] : []]) });
8058
8147
  if (!response.ok)
8059
8148
  throw new Error(`Official Hermes installer download failed (${response.status})`);
8060
8149
  const installer = await response.text();
@@ -8063,16 +8152,33 @@ async function ensureRuntime(directory, options) {
8063
8152
  const path = join(root, ".boomkin", `hermes-installer-${randomUUID()}.sh`);
8064
8153
  await writeFile(path, installer, { flag: "wx", mode: 384 });
8065
8154
  try {
8155
+ options.signal?.throwIfAborted();
8066
8156
  console.log("Installing the official Hermes runtime. Its installer also manages the user-level hermes command and runtime dependencies.");
8067
- const child = Bun.spawn(["bash", path, "--commit", HERMES_COMMIT, "--dir", runtime, "--hermes-home", root, "--skip-setup", "--skip-browser", "--skip-computer-use", "--non-interactive"], { cwd: root, env: nativeEnvironment(root), stdin: "inherit", stdout: "inherit", stderr: "inherit" });
8068
- if (await child.exited !== 0)
8069
- throw new Error("The official Hermes installer failed. Resolve its reported issue and retry onboarding.");
8157
+ const group = !!options.signal;
8158
+ const child = Bun.spawn(["bash", path, "--commit", HERMES_COMMIT, "--dir", runtime, "--hermes-home", root, "--skip-setup", "--skip-browser", "--skip-computer-use", "--non-interactive"], { cwd: root, env: nativeEnvironment(root), stdin: "inherit", stdout: "inherit", stderr: "inherit", detached: group });
8159
+ let termination;
8160
+ const abort = () => {
8161
+ termination ??= terminateOwnedProcess(child, group);
8162
+ };
8163
+ options.signal?.addEventListener("abort", abort, { once: true });
8164
+ try {
8165
+ if (options.signal?.aborted)
8166
+ abort();
8167
+ const code = await child.exited;
8168
+ options.signal?.throwIfAborted();
8169
+ if (code !== 0)
8170
+ throw new Error("The official Hermes installer failed. Resolve its reported issue and retry onboarding.");
8171
+ } finally {
8172
+ options.signal?.removeEventListener("abort", abort);
8173
+ if (termination)
8174
+ await termination;
8175
+ }
8070
8176
  const installed = await findRuntime(root);
8071
8177
  if (!installed || !installed.startsWith(runtime + "/"))
8072
8178
  throw new Error("The installer completed without a usable profile-managed Hermes executable");
8073
- const git = Bun.spawn(["git", "-C", runtime, "rev-parse", "HEAD"], { stdout: "pipe", stderr: "ignore" });
8074
- const revision = (await new Response(git.stdout).text()).trim();
8075
- if (await git.exited !== 0 || revision !== HERMES_COMMIT)
8179
+ const git2 = Bun.spawn(["git", "-C", runtime, "rev-parse", "HEAD"], { stdout: "pipe", stderr: "ignore" });
8180
+ const revision = (await new Response(git2.stdout).text()).trim();
8181
+ if (await git2.exited !== 0 || revision !== HERMES_COMMIT)
8076
8182
  throw new Error("Hermes installed revision differs from the reviewed pin. Existing runtime was preserved; review it before continuing.");
8077
8183
  if (!(await localProfileStatus(root)).runtime.available)
8078
8184
  throw new Error("Installed Hermes cannot report its version; runtime readiness is incomplete");
@@ -8081,12 +8187,12 @@ async function ensureRuntime(directory, options) {
8081
8187
  await rm(path, { force: true });
8082
8188
  }
8083
8189
  }
8084
- async function initializeProfile(directory, identity) {
8190
+ async function initializeProfile(directory, identity3) {
8085
8191
  const root = await profilePath(directory);
8086
8192
  await mkdir(root, { recursive: true, mode: 448 });
8087
8193
  await safePath(join(root, "SOUL.md"));
8088
8194
  try {
8089
- await writeFile(join(root, "SOUL.md"), identity, { flag: "wx", mode: 384 });
8195
+ await writeFile(join(root, "SOUL.md"), identity3, { flag: "wx", mode: 384 });
8090
8196
  return { createdSoul: true };
8091
8197
  } catch (error) {
8092
8198
  if (error.code === "EEXIST")
@@ -8115,7 +8221,7 @@ async function configureMcpServers(directory, servers) {
8115
8221
  for (const [name, server] of Object.entries(servers)) {
8116
8222
  if (!/^[a-z][a-z0-9_-]*$/.test(name))
8117
8223
  throw new Error("Invalid MCP server name");
8118
- if (server.trust !== "untrusted" || !Array.isArray(server.tools?.include) || server.tools.include.some((name) => !name || /[*?\[\]]/.test(name)) || server.tools.resources !== false || server.tools.prompts !== false)
8224
+ if (server.trust !== "untrusted" || !Array.isArray(server.tools?.include) || server.tools.include.some((name2) => !name2 || /[*?\[\]]/.test(name2)) || server.tools.resources !== false || server.tools.prompts !== false)
8119
8225
  throw new Error("Boomkin MCP setup requires untrusted servers, explicit tool names, and disabled resource/prompt utilities");
8120
8226
  if (Boolean(server.url) === Boolean(server.command))
8121
8227
  throw new Error("Choose one MCP transport");
@@ -8186,7 +8292,7 @@ function envValues(text) {
8186
8292
  }
8187
8293
  return result;
8188
8294
  }
8189
- async function localProfileStatus(directory) {
8295
+ async function localProfileStatus(directory, options = {}) {
8190
8296
  const root = await profilePath(directory);
8191
8297
  const executable = await findRuntime(root);
8192
8298
  let version;
@@ -8198,15 +8304,32 @@ async function localProfileStatus(directory) {
8198
8304
  throw error;
8199
8305
  }
8200
8306
  if (executable && rootExists) {
8201
- const child = Bun.spawn([executable, "--profile", "default", "--version"], { cwd: root, env: nativeEnvironment(root), stdout: "pipe", stderr: "ignore", timeout: 15000 });
8202
- const output = await new Response(child.stdout).text();
8203
- if (await child.exited === 0)
8204
- version = output.match(/\bHermes(?: Agent)?\s+v?(\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?)/i)?.[1];
8307
+ options.signal?.throwIfAborted();
8308
+ const group = process.platform !== "win32";
8309
+ const child = Bun.spawn([executable, "--profile", "default", "--version"], { cwd: root, env: nativeEnvironment(root), stdout: "pipe", stderr: "ignore", detached: group });
8310
+ let termination;
8311
+ const abort = () => {
8312
+ termination ??= terminateOwnedProcess(child, group);
8313
+ };
8314
+ const timeout = setTimeout(abort, 15000);
8315
+ options.signal?.addEventListener("abort", abort, { once: true });
8316
+ try {
8317
+ if (options.signal?.aborted)
8318
+ abort();
8319
+ const output = await new Response(child.stdout).text();
8320
+ if (await child.exited === 0)
8321
+ version = output.match(/\bHermes(?: Agent)?\s+v?(\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?)/i)?.[1];
8322
+ options.signal?.throwIfAborted();
8323
+ } finally {
8324
+ clearTimeout(timeout);
8325
+ options.signal?.removeEventListener("abort", abort);
8326
+ if (termination)
8327
+ await termination;
8328
+ }
8205
8329
  }
8206
8330
  const config = await readHermesConfig(root);
8207
8331
  const env = { ...process.env, ...envValues(await textOrEmpty(join(root, ".env"))) };
8208
- const model = config.model && typeof config.model === "object" ? config.model : {};
8209
- const modelConfigured = typeof model.default === "string" && !!model.default.trim();
8332
+ const modelConfigured = hermesModelConfigured(config);
8210
8333
  const knownModelKeys = ["OPENROUTER_API_KEY", "OPENAI_API_KEY", "ANTHROPIC_API_KEY", "NOUS_API_KEY", "GEMINI_API_KEY", "GROQ_API_KEY", "DEEPSEEK_API_KEY", "XAI_API_KEY"];
8211
8334
  const credentialConfigured = knownModelKeys.some((key) => !!env[key]?.trim() && !env[key]?.includes("${"));
8212
8335
  const servers = config.mcp_servers && typeof config.mcp_servers === "object" && !Array.isArray(config.mcp_servers) ? config.mcp_servers : {};
@@ -8479,16 +8602,18 @@ function coinbaseSettings(directory) {
8479
8602
  };
8480
8603
  }
8481
8604
  async function prepareHermes(directory, options) {
8605
+ options.signal?.throwIfAborted();
8482
8606
  if (!options.dryRun)
8483
8607
  await initializeProfile(directory, identity2);
8484
8608
  const executable = await ensureRuntime(directory, options);
8485
8609
  if (options.dryRun)
8486
8610
  return;
8611
+ options.signal?.throwIfAborted();
8487
8612
  await configureMcpServers(directory, { coingecko: coinGeckoConfig });
8488
8613
  if (!options.skipModelSetup) {
8489
8614
  if (!process.stdin.isTTY)
8490
8615
  throw new Error("Hermes model setup needs a terminal. Rerun onboard interactively, or use --skip-model-setup to prepare the profile and configure it later.");
8491
- await runHermes(directory, ["setup", "model"], { executable });
8616
+ await runHermes(directory, ["setup", "model"], { executable, signal: options.signal });
8492
8617
  }
8493
8618
  }
8494
8619
  async function connectProvider(directory, provider, dryRun = false, keyFile) {
@@ -11285,6 +11410,7 @@ async function checkProjectRun(directory, project, selectedRun, now = Date.now()
11285
11410
  return { run, path, issues, observations: ids.size };
11286
11411
  }
11287
11412
  async function runProject(directory, projectName, options = {}) {
11413
+ options.signal?.throwIfAborted();
11288
11414
  const project = await readProject(directory, projectName);
11289
11415
  const id = new Date().toISOString().replaceAll(":", "-").replace(".", "-") + "-" + randomUUID2().slice(0, 8);
11290
11416
  const parts = [".boomkin", "projects", projectName, "runs", id];
@@ -11295,6 +11421,7 @@ async function runProject(directory, projectName, options = {}) {
11295
11421
  if (options.dryRun)
11296
11422
  return { path: output, prompt };
11297
11423
  const executable = options.executable ?? await findRuntime(directory);
11424
+ await options.onProgress?.("Checking the native Hermes profile and installed research tools");
11298
11425
  if (!executable)
11299
11426
  throw new Error("Hermes runtime is missing; onboard this profile before running a project");
11300
11427
  const selected = parseCatalog(JSON.parse(await readLimited(await safePath2(directory, [".boomkin", "last-sync.json"]), 1048576)).catalog);
@@ -11307,11 +11434,32 @@ async function runProject(directory, projectName, options = {}) {
11307
11434
  const integrityIssues = await verifyIntegrity(join4(directory, "skills"), { schemaVersion: 3, packs: [pack] }, await readIntegrity(directory));
11308
11435
  if (integrityIssues.length)
11309
11436
  throw new Error(integrityIssues.join("; "));
11310
- const probe = Bun.spawn([executable, "--profile", "default", "chat", "--help"], { cwd: resolve4(directory), env: { ...process.env, HERMES_HOME: resolve4(directory), HERMES_CONFIG: join4(resolve4(directory), "config.yaml"), HERMES_ENV: join4(resolve4(directory), ".env") }, stdout: "pipe", stderr: "ignore", timeout: 15000 });
11311
- const help = await new Response(probe.stdout).text();
11312
- if (await probe.exited !== 0 || ["--query-file", "--skills", "--max-turns", "--oneshot", "--cli"].some((flag) => !help.includes(flag)))
11437
+ options.signal?.throwIfAborted();
11438
+ const group = process.platform !== "win32";
11439
+ const probe = Bun.spawn([executable, "--profile", "default", "chat", "--help"], { cwd: resolve4(directory), env: { ...process.env, HERMES_HOME: resolve4(directory), HERMES_CONFIG: join4(resolve4(directory), "config.yaml"), HERMES_ENV: join4(resolve4(directory), ".env") }, stdout: "pipe", stderr: "ignore", detached: group });
11440
+ let probeTermination;
11441
+ const abortProbe = () => {
11442
+ probeTermination ??= terminateOwnedProcess(probe, group);
11443
+ };
11444
+ const probeTimeout = setTimeout(abortProbe, 15000);
11445
+ options.signal?.addEventListener("abort", abortProbe, { once: true });
11446
+ let help, probeCode;
11447
+ try {
11448
+ if (options.signal?.aborted)
11449
+ abortProbe();
11450
+ help = await new Response(probe.stdout).text();
11451
+ probeCode = await probe.exited;
11452
+ options.signal?.throwIfAborted();
11453
+ } finally {
11454
+ clearTimeout(probeTimeout);
11455
+ options.signal?.removeEventListener("abort", abortProbe);
11456
+ if (probeTermination)
11457
+ await probeTermination;
11458
+ }
11459
+ if (probeCode !== 0 || ["--query-file", "--skills", "--max-turns", "--oneshot", "--cli"].some((flag) => !help.includes(flag)))
11313
11460
  throw new Error("Existing Hermes lacks the reviewed project launch contract; preserve it and review its native update");
11314
11461
  const lockParts = [".boomkin", "projects", projectName, "run.lock"];
11462
+ options.signal?.throwIfAborted();
11315
11463
  const lock = await safePath2(directory, lockParts);
11316
11464
  try {
11317
11465
  await mkdir2(lock, { mode: 448 });
@@ -11331,14 +11479,18 @@ async function runProject(directory, projectName, options = {}) {
11331
11479
  await writeFile2(join4(output, "prompt.md"), prompt, { flag: "wx", mode: 384 });
11332
11480
  await atomicWrite(directory, [...parts, "run.json"], json(run));
11333
11481
  recorded = true;
11482
+ await options.onPrepared?.(run, output);
11483
+ options.signal?.throwIfAborted();
11334
11484
  run.state = "running";
11335
11485
  await atomicWrite(directory, [...parts, "run.json"], json(run));
11336
11486
  console.log(`Research run: ${output}. Native Hermes uses your configured model; provider usage may incur costs.`);
11337
- await runHermes(directory, args, { executable });
11487
+ await options.onProgress?.("Native Hermes is researching your question");
11488
+ await runHermes(directory, args, { executable, signal: options.signal });
11338
11489
  run.state = "needs-review";
11339
11490
  run.finishedAt = new Date().toISOString();
11340
11491
  await atomicWrite(directory, [...parts, "run.json"], json(run));
11341
11492
  const checked = await checkProjectRun(directory, projectName, id);
11493
+ await options.onProgress?.("Checking the captured research files");
11342
11494
  run.issues = checked.issues;
11343
11495
  if (!checked.issues.length)
11344
11496
  run.state = "ready-for-review";
@@ -11348,7 +11500,7 @@ async function runProject(directory, projectName, options = {}) {
11348
11500
  if (recorded) {
11349
11501
  run.state = "failed";
11350
11502
  run.finishedAt = new Date().toISOString();
11351
- run.issues = ["Hermes or artifact validation failed; review the native output and preserved run files before retrying"];
11503
+ run.issues = [options.signal?.aborted ? "Research was canceled; preserved files may be incomplete" : "Hermes or artifact validation failed; review the native output and preserved run files before retrying"];
11352
11504
  await atomicWrite(directory, [...parts, "run.json"], json(run));
11353
11505
  }
11354
11506
  throw error;
@@ -11431,9 +11583,1285 @@ function renderTemplate(template) {
11431
11583
  Creation and preview make no model or data call. Live runs use your configured model and tools.`;
11432
11584
  }
11433
11585
 
11586
+ // src/desk.ts
11587
+ import { createHash as createHash5, randomBytes, randomUUID as randomUUID3, timingSafeEqual } from "crypto";
11588
+ import { lstat as lstat4, mkdir as mkdir3, readFile as readFile5, rename as rename3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
11589
+ import { join as join5, resolve as resolve5 } from "path";
11590
+ import { pathToFileURL } from "url";
11591
+ init_core();
11592
+
11593
+ // src/desk-comparison.ts
11594
+ var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
11595
+ var at = (value, ...path) => path.reduce((next, key) => record(next)[key], value);
11596
+ var list2 = (value) => Array.isArray(value) ? value : [];
11597
+ var strings = (value) => list2(value).filter((item) => typeof item === "string");
11598
+ var time = (value) => typeof value === "string" && Number.isFinite(Date.parse(value)) ? Date.parse(value) : NaN;
11599
+ var hash = (value) => typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
11600
+ var number = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
11601
+ var display = (value) => value === null || !Number.isFinite(value) ? null : String(Object.is(value, -0) ? 0 : value);
11602
+ function stable(value) {
11603
+ if (Array.isArray(value))
11604
+ return `[${value.map(stable).join(",")}]`;
11605
+ if (value !== null && typeof value === "object")
11606
+ return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${stable(record(value)[key])}`).join(",")}}`;
11607
+ return JSON.stringify(value);
11608
+ }
11609
+ function sourceKey(value) {
11610
+ const item = record(value);
11611
+ if (typeof item.id !== "string" || !/^[a-z0-9][a-z0-9-]{0,62}$/.test(item.id) || typeof item.source !== "string")
11612
+ return null;
11613
+ try {
11614
+ const url = new URL(item.source);
11615
+ if (!item.id || !["https:", "http:"].includes(url.protocol) || url.username || url.password)
11616
+ return null;
11617
+ url.hash = "";
11618
+ url.searchParams.sort();
11619
+ return `${item.id} \xB7 ${url.href}`;
11620
+ } catch {
11621
+ return null;
11622
+ }
11623
+ }
11624
+ function decimal(value) {
11625
+ if (typeof value !== "string" || !/^-?\d{1,60}(?:\.\d{1,36})?$/.test(value))
11626
+ return null;
11627
+ const [whole, fraction = ""] = value.split(".");
11628
+ const units = BigInt(whole + fraction), scale = fraction.length;
11629
+ return { units, scale, text: decimalText(units, scale) };
11630
+ }
11631
+ function decimalText(units, scale) {
11632
+ const digits = (units < 0n ? -units : units).toString().padStart(scale + 1, "0");
11633
+ const value = scale ? `${digits.slice(0, -scale)}.${digits.slice(-scale)}`.replace(/\.?0+$/, "") : digits;
11634
+ return `${units < 0n ? "-" : ""}${value}`;
11635
+ }
11636
+ function walletRow(id, label, before, after, note) {
11637
+ const a = decimal(before), b = decimal(after), scale = Math.max(a?.scale ?? 0, b?.scale ?? 0);
11638
+ return {
11639
+ id,
11640
+ label,
11641
+ unit: "USDC",
11642
+ before: a?.text ?? null,
11643
+ after: b?.text ?? null,
11644
+ delta: a && b ? decimalText(b.units * 10n ** BigInt(scale - b.scale) - a.units * 10n ** BigInt(scale - a.scale), scale) : null,
11645
+ changePct: null,
11646
+ note: a && b ? note : `${note} Missing or invalid amounts remain unavailable.`
11647
+ };
11648
+ }
11649
+ function numericRow(id, label, unit, before, after, comparable, note, relative2 = false) {
11650
+ const a = number(before), b = number(after), delta = comparable && a !== null && b !== null ? b - a : null;
11651
+ return {
11652
+ id,
11653
+ label,
11654
+ unit,
11655
+ before: display(a),
11656
+ after: display(b),
11657
+ delta: display(delta),
11658
+ changePct: relative2 && delta !== null && a !== null && a > 0 ? display(delta / a * 100) : null,
11659
+ note: a === null || b === null ? `${note} Missing or invalid values remain unavailable.` : note
11660
+ };
11661
+ }
11662
+ function compareDeskRuns(kind, before, after) {
11663
+ const select = ({ id, createdAt, state }) => ({ id, createdAt, state });
11664
+ const output = { schemaVersion: 1, kind, status: "unavailable", summary: "These runs cannot be compared.", baseline: select(before.run), current: select(after.run), sections: [], notes: [], issues: [], sourceChanges: { added: [], removed: [], changed: [] } };
11665
+ if (before.run.id === after.run.id || !(time(before.run.createdAt) < time(after.run.createdAt)))
11666
+ output.issues.push("Choose a different baseline run captured before the current run.");
11667
+ if (before.run.project !== after.run.project || before.run.kind !== kind || after.run.kind !== kind)
11668
+ output.issues.push("Runs must belong to the same project and research kind.");
11669
+ if (stable(before.inputs) !== stable(after.inputs))
11670
+ output.issues.push("Saved research inputs differ; comparisons require the same question and scope.");
11671
+ if (!before.packRevision || before.packRevision !== after.packRevision)
11672
+ output.issues.push("Installed helper revisions differ or are missing; recapture both runs with the same helper revision.");
11673
+ for (const [label, snapshot] of [["Baseline", before], ["Current", after]]) {
11674
+ if (snapshot.run.execution || !["complete", "partial"].includes(snapshot.run.state))
11675
+ output.issues.push(`${label}: only completed deterministic captures can be compared; native or unfinished runs are unavailable.`);
11676
+ if (snapshot.resultVerified !== true)
11677
+ output.issues.push(`${label}: this saved result has no verified result digest. Recapture the research to create a comparable run; legacy results remain readable.`);
11678
+ if (!Array.isArray(snapshot.integrityIssues) || snapshot.integrityIssues.some((issue) => typeof issue !== "string"))
11679
+ output.issues.push(`${label}: integrity validation is unavailable.`);
11680
+ output.issues.push(...strings(snapshot.integrityIssues).map((issue) => `${label}: ${issue}`));
11681
+ }
11682
+ if (output.issues.length)
11683
+ return finish(output);
11684
+ const indexes = [];
11685
+ for (const [label, snapshot] of [["Baseline", before], ["Current", after]]) {
11686
+ const index = new Map;
11687
+ if (!Array.isArray(snapshot.evidence) || !snapshot.evidence.length)
11688
+ output.issues.push(`${label}: captured source evidence is missing or malformed.`);
11689
+ for (const value of list2(snapshot.evidence)) {
11690
+ const item = record(value);
11691
+ const key = sourceKey(item);
11692
+ if (!key || !hash(item.sha256) || index.has(key) || !Array.isArray(item.limitations) || item.limitations.some((note) => typeof note !== "string"))
11693
+ output.issues.push(`${label}: captured source identity, digest or limitations are missing, malformed or duplicated.`);
11694
+ else
11695
+ index.set(key, item.sha256);
11696
+ output.notes.push(...strings(item.limitations).map((note) => `${label} source: ${note}`));
11697
+ }
11698
+ indexes.push(index);
11699
+ output.notes.push(...strings(at(snapshot.result, "limitations")).map((note) => `${label}: ${note}`));
11700
+ output.notes.push(`${label} captured ${snapshot.run.createdAt}${snapshot.run.finishedAt ? `; finished ${snapshot.run.finishedAt}` : ""}.`);
11701
+ }
11702
+ if (output.issues.length)
11703
+ return finish(output);
11704
+ const [oldSources, newSources] = indexes;
11705
+ output.sourceChanges = {
11706
+ added: [...newSources.keys()].filter((key) => !oldSources.has(key)).sort(),
11707
+ removed: [...oldSources.keys()].filter((key) => !newSources.has(key)).sort(),
11708
+ changed: [...newSources.keys()].filter((key) => oldSources.has(key) && oldSources.get(key) !== newSources.get(key)).sort()
11709
+ };
11710
+ output.notes.push("Source changes compare captured bytes by artifact identity and source URL; a new retrieval time alone is not market movement. Hashes verify saved bytes, not provider truth.");
11711
+ if (output.issues.length)
11712
+ return finish(output);
11713
+ if (kind === "market")
11714
+ market(output, before, after);
11715
+ if (kind === "wallet")
11716
+ wallet(output, before, after);
11717
+ if (kind === "strategy")
11718
+ strategy(output, before, after);
11719
+ const rows = output.sections.flatMap((section) => section.rows), valid = rows.some((row) => row.before !== null || row.after !== null);
11720
+ output.status = !valid ? "unavailable" : output.issues.length || rows.some((row) => row.delta === null) || before.run.state === "partial" || after.run.state === "partial" ? "limited" : "compared";
11721
+ output.summary = output.status === "compared" ? "Saved observations compared within the same research scope." : output.status === "limited" ? rows.some((row) => row.delta !== null) ? "Some saved observations are comparable; read the gaps and limitations below." : "Saved values are shown, but their changes cannot be compared." : "No comparable observations are available in these saved runs.";
11722
+ return finish(output);
11723
+ }
11724
+ function finish(output) {
11725
+ output.notes = [...new Set(output.notes)];
11726
+ output.issues = [...new Set(output.issues)];
11727
+ return output;
11728
+ }
11729
+ function market(output, before, after) {
11730
+ function observations(snapshot) {
11731
+ const rows2 = new Map;
11732
+ const age = number(at(snapshot.result, "parameters", "maxAgeSeconds")) ?? 300;
11733
+ for (const read of list2(at(snapshot.result, "reads")))
11734
+ for (const row of list2(at(read, "observations"))) {
11735
+ const provider = at(read, "provider"), identity3 = at(row, "identity");
11736
+ if (typeof provider !== "string" || !["coingecko", "defillama"].includes(provider) || at(row, "provider") !== provider || at(identity3, "namespace") !== "coingecko" || at(identity3, "id") !== snapshot.inputs.asset) {
11737
+ output.issues.push("A market observation has an unsupported provider or mismatched CoinGecko identity.");
11738
+ continue;
11739
+ }
11740
+ const key = String(provider), observed = time(at(row, "observedAt")), retrieved = time(at(row, "retrievedAt"));
11741
+ const price = number(at(row, "priceUsd")), delay = (retrieved - observed) / 1000;
11742
+ const valid = at(row, "ok") === true && at(row, "unit") === "USD" && price !== null && price >= 0.000000000001 && price <= 1000000000000 && delay >= -60 && delay <= age && age >= 1 && age <= 86400;
11743
+ const note = valid ? `Observed ${at(row, "observedAt")}; retrieved ${at(row, "retrievedAt")}.` : `Unavailable: ${typeof at(row, "error") === "string" ? at(row, "error") : "missing, stale or invalid observation"}.`;
11744
+ if (rows2.has(key)) {
11745
+ output.issues.push(`Duplicate ${key} observations cannot be matched reliably.`);
11746
+ rows2.set(key, { value: null, observed: NaN, note: "Duplicate source observations." });
11747
+ } else
11748
+ rows2.set(key, { value: valid ? price : null, observed, note });
11749
+ }
11750
+ return rows2;
11751
+ }
11752
+ const a = observations(before), b = observations(after);
11753
+ const rows = [...new Set([...a.keys(), ...b.keys()])].sort().map((provider) => {
11754
+ const old = a.get(provider), current = b.get(provider), newer = !!old && !!current && old.observed < current.observed;
11755
+ const chronology = !old || !current ? "Source missing in one run." : !newer ? "Provider timestamp is cached, reversed or unavailable; no price movement is inferred." : "Change is between provider observations, not a portfolio return.";
11756
+ return numericRow(provider, provider === "coingecko" ? "CoinGecko USD mark" : "DefiLlama USD mark", "USD", old?.value, current?.value, newer, `Baseline: ${old?.note ?? "unavailable"} Current: ${current?.note ?? "unavailable"} ${chronology}`, true);
11757
+ });
11758
+ output.sections.push({ title: "Market observations", description: "Same provider and exact CoinGecko asset identity. Missing and stale marks remain unavailable.", rows });
11759
+ output.notes.push("Aggregate marks are not executable quotes. Providers may share upstream data; agreement does not establish independent corroboration.");
11760
+ }
11761
+ function wallet(output, before, after) {
11762
+ const a = before.result, b = after.result;
11763
+ for (const snapshot of [before, after]) {
11764
+ const scope = at(snapshot.result, "scope"), input = snapshot.inputs;
11765
+ const address = at(scope, "address");
11766
+ if (typeof input.account !== "string" || typeof address !== "string" || address.toLowerCase() !== input.account.toLowerCase() || at(scope, "network") !== input.network || at(scope, "startTime") !== time(input.startTime) || at(scope, "endTime") !== time(input.endTime)) {
11767
+ output.issues.push("Wallet result scope does not match the saved account, network and time window.");
11768
+ return;
11769
+ }
11770
+ }
11771
+ function historyAvailable(result, type) {
11772
+ const network = at(result, "scope", "network");
11773
+ const endpoint = network === "testnet" ? "https://api.hyperliquid-testnet.xyz/info" : network === "mainnet" ? "https://api.hyperliquid.xyz/info" : null;
11774
+ return endpoint !== null && list2(at(result, "evidence", "entries")).some((entry) => at(entry, "type") === type && at(entry, "endpoint") === endpoint && at(entry, "httpStatus") === 200 && at(entry, "error") === null);
11775
+ }
11776
+ function amount(result, field) {
11777
+ const fills = historyAvailable(result, "userFillsByTime"), funding = historyAvailable(result, "userFunding");
11778
+ if (field === "fundingUsdc" ? !funding : field === "observedNetUsdc" ? !fills || !funding : !fills)
11779
+ return null;
11780
+ if (field !== "signedFeesByToken")
11781
+ return at(result, "outcome", field);
11782
+ const fees = at(result, "outcome", field);
11783
+ if (at(result, "outcome", "fillCount") === 0 && fees !== null && typeof fees === "object" && !Array.isArray(fees) && Object.keys(fees).length === 0)
11784
+ return "0";
11785
+ return at(fees, "USDC");
11786
+ }
11787
+ for (const [label, result] of [["Baseline", a], ["Current", b]]) {
11788
+ for (const type of ["userFillsByTime", "userFunding"])
11789
+ if (!historyAvailable(result, type))
11790
+ output.issues.push(`${label}: no successful ${type} history read was captured; dependent amounts are unavailable, not zero.`);
11791
+ output.notes.push(...strings(at(result, "coverage", "gaps")).map((note) => `${label} coverage: ${note}`));
11792
+ if (at(result, "coverage", "completeWindow") !== true)
11793
+ output.issues.push(`${label}: full-window history is unverified; results describe only observed activity.`);
11794
+ const observed = at(result, "exposure", "accountSnapshotTime");
11795
+ output.notes.push(`${label} exposure snapshot: ${typeof observed === "number" && Number.isFinite(observed) && !Number.isNaN(new Date(observed).getTime()) ? new Date(observed).toISOString() : "timestamp unavailable"}.`);
11796
+ }
11797
+ const accounting = "Change is revised evidence for the same historical window, not newly earned profit or a portfolio return.";
11798
+ output.sections.push({ title: "Observed wallet activity", description: accounting, rows: [
11799
+ walletRow("observed-net", "Observed net outcome", amount(a, "observedNetUsdc"), amount(b, "observedNetUsdc"), "Closed PnL minus signed fees plus signed funding; excludes unrealized PnL and unseen cashflows."),
11800
+ walletRow("closed-pnl", "Observed closed PnL", amount(a, "closedPnlUsdc"), amount(b, "closedPnlUsdc"), accounting),
11801
+ walletRow("signed-fees", "Signed USDC fees", amount(a, "signedFeesByToken"), amount(b, "signedFeesByToken"), "Positive fees are costs; negative fees are rebates. Builder fees are already included. Missing fee currencies are not assumed zero."),
11802
+ walletRow("signed-funding", "Signed funding", amount(a, "fundingUsdc"), amount(b, "fundingUsdc"), "Positive funding is received; negative funding is paid. Signed cashflow changes have no percentage-return interpretation.")
11803
+ ] });
11804
+ output.sections.push({ title: "Current exposure", description: "Sequential capture-time observations, not historical window-end balances.", rows: [walletRow("gross-exposure", "Gross default-perp exposure", at(a, "exposure", "grossNotionalUsdc"), at(b, "exposure", "grossNotionalUsdc"), "Gross notional is exposure, not account equity or profit. Stop protection is not assessed.")] });
11805
+ output.notes.push(accounting, "Default-perpetual scope only. Provider retention, page budgets and unknown opening inventory limit coverage; spot, HIP-3, transfers and unenumerated accounts prevent a complete portfolio-return claim.");
11806
+ }
11807
+ function strategy(output, before, after) {
11808
+ const a = before.result, b = after.result;
11809
+ if ([a, b].some((result) => at(result, "model") !== "daily-frozen-rule-validation-v1" || at(result, "identity", "namespace") !== "coingecko" || at(result, "identity", "id") !== before.inputs.asset)) {
11810
+ output.issues.push("Strategy result model or asset identity is unsupported or inconsistent.");
11811
+ return;
11812
+ }
11813
+ const sameHashes = ["datasetSha256", "specificationSha256", "engineSha256"].every((key) => hash(at(a, "inputHashes", key)) && at(a, "inputHashes", key) === at(b, "inputHashes", key));
11814
+ if (!sameHashes)
11815
+ output.issues.push("Dataset, specification or engine hashes changed or are missing. Values are shown for inspection; deltas are unavailable across incompatible experiments.");
11816
+ for (const period of ["reference", "heldOut"]) {
11817
+ const pa = at(a, "periods", period, "period"), pb = at(b, "periods", period, "period");
11818
+ const validPeriod = (value) => time(at(value, "firstObservation")) < time(at(value, "lastObservation")) && Number.isSafeInteger(at(value, "observations")) && Number(at(value, "observations")) >= 2;
11819
+ const samePeriod = validPeriod(pa) && validPeriod(pb) && stable(pa) === stable(pb);
11820
+ if (!samePeriod)
11821
+ output.issues.push(`${period === "heldOut" ? "Held-out" : "Reference"} period boundaries changed or are unavailable; period deltas are suppressed.`);
11822
+ const periodLabel = (value) => validPeriod(value) ? `${at(value, "firstObservation")} to ${at(value, "lastObservation")} (${at(value, "observations")} observations)` : "unavailable";
11823
+ for (const scenario of ["baseline", "higherCosts"]) {
11824
+ const metricsA = at(a, "periods", period, scenario, "metrics"), metricsB = at(b, "periods", period, scenario, "metrics");
11825
+ const comparable = sameHashes && samePeriod && stable(at(a, "costScenarios", scenario)) === stable(at(b, "costScenarios", scenario));
11826
+ const note = comparable ? "Same data, frozen specification, engine and period. Percentage metrics change in percentage points." : "Different or unverifiable experiments; values are shown without a performance delta.";
11827
+ const metrics = [["timeWeightedReturnPct", "Time-weighted return", "percent"], ["endingEquityUsd", "Ending equity", "USD"], ["maxDrawdownPct", "Maximum drawdown", "percent"], ["tradeCount", "Modeled trades", "count"]];
11828
+ const validMetric = (value, key) => key === "tradeCount" ? Number.isSafeInteger(value) && Number(value) >= 0 ? value : null : key === "maxDrawdownPct" ? number(value) !== null && Number(value) >= 0 && Number(value) <= 100 ? value : null : value;
11829
+ output.sections.push({ title: `${period === "heldOut" ? "Held-out" : "Reference"} \xB7 ${scenario === "higherCosts" ? "Higher costs" : "Baseline costs"}`, description: `Baseline: ${periodLabel(pa)}. Current: ${periodLabel(pb)}.`, rows: metrics.map(([key, label, unit]) => numericRow(`${period}-${scenario}-${key}`, label, unit, validMetric(at(metricsA, key), key), validMetric(at(metricsB, key), key), comparable, note)) });
11830
+ }
11831
+ }
11832
+ output.notes.push("Historical simulations restart each period independently. Comparing captures is not a continuous equity curve, an out-of-sample guarantee or a reason to tune a rule on held-out results.");
11833
+ }
11834
+
11835
+ // src/desk.ts
11836
+ var sha = (value) => createHash5("sha256").update(value).digest("hex");
11837
+ var json2 = (value) => JSON.stringify(value, null, 2) + `
11838
+ `;
11839
+ var object = (value) => !!value && typeof value === "object" && !Array.isArray(value);
11840
+ var slug = /^[a-z0-9][a-z0-9-]{0,62}$/;
11841
+ var runPattern = /^\d{4}-\d{2}-\d{2}T[0-9-]+Z-[0-9a-f]{8}$/;
11842
+ var kinds = {
11843
+ wallet: { workflow: "hyperliquid-wallet-audit", pack: "hyperliquid-skills", skill: "hyperliquid-wallet-audit", module: "audit-engine.mjs" },
11844
+ market: { workflow: "market-snapshot", pack: "defi-data-skills", skill: "galleon-defi-market-snapshot", module: "market-data.mjs" },
11845
+ strategy: { workflow: "strategy-backtest", pack: "defi-strategy-skills", skill: "galleon-defi-strategy-backtest", module: "engine.mjs" }
11846
+ };
11847
+
11848
+ class DeskError extends Error {
11849
+ status;
11850
+ constructor(message, status = 400) {
11851
+ super(message);
11852
+ this.status = status;
11853
+ }
11854
+ }
11855
+ function validName(value) {
11856
+ if (!slug.test(value))
11857
+ throw new DeskError("Invalid project name");
11858
+ return value;
11859
+ }
11860
+ function validRun(value) {
11861
+ if (!runPattern.test(value))
11862
+ throw new DeskError("Invalid run ID");
11863
+ return value;
11864
+ }
11865
+ async function safe(root, parts = []) {
11866
+ let path = resolve5(root);
11867
+ for (const part of ["", ...parts]) {
11868
+ if (part) {
11869
+ if (!/^[a-zA-Z0-9.][a-zA-Z0-9._-]*$/.test(part) || part === "." || part === "..")
11870
+ throw new DeskError("Invalid managed path");
11871
+ path = join5(path, part);
11872
+ }
11873
+ try {
11874
+ if ((await lstat4(path)).isSymbolicLink())
11875
+ throw new DeskError("Refusing a symbolic link in a managed desk path", 409);
11876
+ } catch (error) {
11877
+ if (error.code !== "ENOENT")
11878
+ throw error;
11879
+ }
11880
+ }
11881
+ return path;
11882
+ }
11883
+ async function limitedBytes(path, maxBytes = 1048576) {
11884
+ const info = await lstat4(path);
11885
+ if (!info.isFile() || info.size > maxBytes)
11886
+ throw new DeskError("Expected a bounded regular file", 409);
11887
+ return readFile5(path);
11888
+ }
11889
+ async function limited(path, maxBytes = 1048576) {
11890
+ return (await limitedBytes(path, maxBytes)).toString("utf8");
11891
+ }
11892
+ async function atomic(root, parts, value) {
11893
+ const path = await safe(root, parts), temporary = path + "." + randomUUID3() + ".tmp";
11894
+ try {
11895
+ await writeFile3(temporary, value, { flag: "wx", mode: 384 });
11896
+ await safe(root, parts);
11897
+ await rename3(temporary, path);
11898
+ } finally {
11899
+ await rm3(temporary, { force: true });
11900
+ }
11901
+ }
11902
+ var projectParts = (name2) => [".boomkin", "projects", validName(name2)];
11903
+ var runParts = (name2, id) => [...projectParts(name2), "runs", validRun(id)];
11904
+ function parseRun(value, name2, id) {
11905
+ if (!object(value) || value.schemaVersion !== 1 || value.project !== name2 || value.id !== id || !Object.hasOwn(kinds, value.kind) || !["queued", "running", "complete", "partial", "failed", "cancelled", "interrupted"].includes(value.state) || typeof value.createdAt !== "string" || !Number.isFinite(Date.parse(value.createdAt)) || typeof value.progress !== "string")
11906
+ throw new DeskError("Saved desk run is malformed; files were preserved", 409);
11907
+ return value;
11908
+ }
11909
+ function parseMetadata(value) {
11910
+ if (!object(value) || value.schemaVersion !== 1 || !Object.hasOwn(kinds, value.kind) || typeof value.title !== "string" || !value.title.trim() || value.title.length > 160)
11911
+ throw new DeskError("Saved desk project is malformed; files were preserved", 409);
11912
+ if (value.parent !== undefined && (!object(value.parent) || typeof value.parent.project !== "string" || !slug.test(value.parent.project) || typeof value.parent.runId !== "string" || !runPattern.test(value.parent.runId)))
11913
+ throw new DeskError("Saved parent capture is malformed; files were preserved", 409);
11914
+ return value;
11915
+ }
11916
+ function normalizeInput(kind, input) {
11917
+ if (!object(input))
11918
+ throw new DeskError("Inputs must be an object");
11919
+ const allowed = kind === "wallet" ? ["account", "startTime", "endTime", "network", "maxPages"] : kind === "market" ? ["asset"] : ["asset", "days", "template", "initialCashUsd", "feeBps", "slippageBps", "amountUsd", "datasetSource", "dataset"];
11920
+ if (Object.keys(input).some((key) => !allowed.includes(key)))
11921
+ throw new DeskError("Unknown task input");
11922
+ if (kind === "wallet") {
11923
+ const network = input.network ?? "mainnet", maxPages = input.maxPages ?? 10;
11924
+ if (typeof input.account !== "string" || !/^0x[\da-f]{40}$/i.test(input.account) || /^0x0{40}$/i.test(input.account))
11925
+ throw new DeskError("Enter a nonzero public Hyperliquid address");
11926
+ for (const key of ["startTime", "endTime"])
11927
+ if (typeof input[key] !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{3})?Z$/.test(input[key]) || !Number.isFinite(Date.parse(input[key])))
11928
+ throw new DeskError("Choose UTC start and end times");
11929
+ if (Date.parse(input.startTime) >= Date.parse(input.endTime) || Date.parse(input.endTime) > Date.now() + 300000)
11930
+ throw new DeskError("Choose an ordered window ending no later than now");
11931
+ if (!["mainnet", "testnet"].includes(network) || !Number.isInteger(maxPages) || maxPages < 1 || maxPages > 50)
11932
+ throw new DeskError("Choose mainnet/testnet and 1\u201350 history pages");
11933
+ return { account: input.account.toLowerCase(), startTime: new Date(input.startTime).toISOString(), endTime: new Date(input.endTime).toISOString(), network, maxPages };
11934
+ }
11935
+ const asset = input.asset ?? "bitcoin";
11936
+ if (typeof asset !== "string" || !/^[a-z0-9][a-z0-9-]{0,99}$/.test(asset))
11937
+ throw new DeskError("Use the exact CoinGecko asset ID, for example ethereum");
11938
+ if (kind === "market")
11939
+ return { asset };
11940
+ const result = { asset, days: input.days ?? 180, template: input.template ?? "sma-10", initialCashUsd: input.initialCashUsd ?? 1e4, feeBps: input.feeBps ?? 10, slippageBps: input.slippageBps ?? 5, ...input.amountUsd !== undefined ? { amountUsd: input.amountUsd } : {}, datasetSource: input.datasetSource ?? "live", ...input.dataset !== undefined ? { dataset: input.dataset } : {} };
11941
+ if (!Number.isInteger(result.days) || result.days < 91 || result.days > 365 || !["buy-and-hold", "weekly-dca", "sma-10", "sma-30"].includes(result.template))
11942
+ throw new DeskError("Choose a documented rule and 91\u2013365 days");
11943
+ for (const key of ["initialCashUsd", "feeBps", "slippageBps", "amountUsd"])
11944
+ if (result[key] !== undefined && (typeof result[key] !== "number" || !Number.isFinite(result[key]) || result[key] < (key === "initialCashUsd" || key === "amountUsd" ? 0.01 : 0) || result[key] > (key === "feeBps" || key === "slippageBps" ? 1000 : 1e9)))
11945
+ throw new DeskError("Invalid cash or cost assumptions");
11946
+ if (result.template === "weekly-dca" && result.amountUsd === undefined)
11947
+ throw new DeskError("Weekly DCA requires an explicit purchase budget");
11948
+ if (!["live", "bundled", "upload"].includes(result.datasetSource) || result.datasetSource === "upload" && !object(result.dataset) || result.datasetSource !== "upload" && result.dataset !== undefined)
11949
+ throw new DeskError("Choose live, bundled or an uploaded daily dataset");
11950
+ if (result.dataset !== undefined && Buffer.byteLength(json2(result.dataset)) > 262144)
11951
+ throw new DeskError("Uploaded dataset exceeds 256 KiB", 413);
11952
+ if (result.datasetSource === "bundled" && result.asset !== "bitcoin")
11953
+ throw new DeskError("The bundled historical dataset is Bitcoin; choose its exact asset ID");
11954
+ return result;
11955
+ }
11956
+ async function startDesk(options) {
11957
+ const root = resolve5(options.directory), assets = resolve5(options.assetsDirectory ?? join5(import.meta.dir, "../desk"));
11958
+ const catalog = parseCatalog(options.catalog ?? skills_default), token = randomBytes(32).toString("hex");
11959
+ const active = new Map;
11960
+ const preparing = new Map;
11961
+ let stopped = false;
11962
+ let stopping;
11963
+ let profileCache = { runtimeAvailable: false, modelConfigured: false, credentialConfigured: false, authenticated: "unverified" };
11964
+ let profileCheckedAt = 0, profileGeneration = 0, profilePromise, profileController;
11965
+ let setup;
11966
+ let setupPromise;
11967
+ let setupController;
11968
+ await safe(root);
11969
+ await mkdir3(root, { recursive: true, mode: 448 });
11970
+ await mkdir3(await safe(root, [".boomkin"]), { recursive: true, mode: 448 });
11971
+ const lock = await safe(root, [".boomkin", "desk.lock"]);
11972
+ try {
11973
+ await mkdir3(lock, { mode: 448 });
11974
+ } catch (error) {
11975
+ if (error.code !== "EEXIST")
11976
+ throw error;
11977
+ const recovery = await safe(root, [".boomkin", "desk-recovery.lock"]);
11978
+ try {
11979
+ await mkdir3(recovery, { mode: 448 });
11980
+ } catch (error2) {
11981
+ if (error2.code === "EEXIST")
11982
+ throw new DeskError("Desk lock recovery is already in progress. Retry after it finishes; inspect a retained recovery lock before removing it", 409);
11983
+ throw error2;
11984
+ }
11985
+ try {
11986
+ await writeFile3(join5(recovery, "owner.json"), json2({ pid: process.pid, startedAt: new Date().toISOString() }), { flag: "wx", mode: 384 });
11987
+ let owner;
11988
+ try {
11989
+ owner = JSON.parse(await limited(await safe(root, [".boomkin", "desk.lock", "owner.json"])));
11990
+ } catch {
11991
+ throw new DeskError("Desk lock has no verifiable owner; preserve it and inspect the profile", 409);
11992
+ }
11993
+ if (!object(owner) || !Number.isSafeInteger(owner.pid) || owner.pid <= 0)
11994
+ throw new DeskError("Desk lock owner is malformed", 409);
11995
+ let alive = true;
11996
+ try {
11997
+ process.kill(owner.pid, 0);
11998
+ } catch (error2) {
11999
+ if (error2.code === "ESRCH")
12000
+ alive = false;
12001
+ }
12002
+ if (alive)
12003
+ throw new DeskError("A desk already owns this profile. Use its existing window", 409);
12004
+ await rm3(lock, { recursive: true });
12005
+ await mkdir3(lock, { mode: 448 });
12006
+ } finally {
12007
+ await rm3(recovery, { recursive: true, force: true });
12008
+ }
12009
+ }
12010
+ await writeFile3(join5(lock, "owner.json"), json2({ pid: process.pid, startedAt: new Date().toISOString() }), { flag: "wx", mode: 384 });
12011
+ async function readMetadata(name2) {
12012
+ return parseMetadata(JSON.parse(await limited(await safe(root, [...projectParts(name2), "desk.json"]))));
12013
+ }
12014
+ async function readDeskRun(name2, id) {
12015
+ return parseRun(JSON.parse(await limited(await safe(root, [...runParts(name2, id), "desk.json"]))), name2, id);
12016
+ }
12017
+ async function saveRun(run) {
12018
+ await atomic(root, [...runParts(run.project, run.id), "desk.json"], json2(run));
12019
+ }
12020
+ async function projectDto(project) {
12021
+ const meta = await readMetadata(project.name), runs = [];
12022
+ for (const run of await projectRuns(root, project.name)) {
12023
+ try {
12024
+ runs.push(await readDeskRun(project.name, run.id));
12025
+ } catch (error) {
12026
+ if (error.code !== "ENOENT")
12027
+ throw error;
12028
+ }
12029
+ }
12030
+ return { name: project.name, title: meta.title, kind: meta.kind, ...meta.execution ? { execution: meta.execution } : {}, ...meta.parent ? { parent: meta.parent } : {}, createdAt: project.createdAt, inputs: project.inputs, runs: runs.reverse() };
12031
+ }
12032
+ async function projects() {
12033
+ const result = [];
12034
+ for (const project of await listProjects(root)) {
12035
+ try {
12036
+ result.push(await projectDto(project));
12037
+ } catch (error) {
12038
+ if (error.code !== "ENOENT")
12039
+ throw error;
12040
+ }
12041
+ }
12042
+ return result.sort((a, b) => b.createdAt.localeCompare(a.createdAt));
12043
+ }
12044
+ try {
12045
+ for (const project of await projects())
12046
+ for (const run of project.runs)
12047
+ if (["queued", "running"].includes(run.state)) {
12048
+ run.state = "interrupted";
12049
+ run.finishedAt = new Date().toISOString();
12050
+ run.progress = "The previous desk stopped before this run finished. Refresh to capture new evidence.";
12051
+ await saveRun(run);
12052
+ const previous = (await projectRuns(root, project.name)).find((item) => item.id === run.id);
12053
+ await atomic(root, [...runParts(project.name, run.id), "run.json"], json2({ ...previous, state: "failed", finishedAt: run.finishedAt, issues: [run.progress] }));
12054
+ if (run.execution !== "native-hermes")
12055
+ await rm3(await safe(root, [...projectParts(project.name), "run.lock"]), { recursive: true, force: true });
12056
+ }
12057
+ } catch (error) {
12058
+ await rm3(lock, { recursive: true, force: true });
12059
+ throw error;
12060
+ }
12061
+ async function installed(kind) {
12062
+ const contract = kinds[kind], recorded = JSON.parse(await limited(await safe(root, [".boomkin", "last-sync.json"])));
12063
+ const selected = parseCatalog(recorded.catalog), pack = selected.packs.find((item) => item.id === contract.pack && item.skills.includes(contract.skill));
12064
+ const reviewed = catalog.packs.find((item) => item.id === contract.pack);
12065
+ if (!pack || !reviewed)
12066
+ throw new DeskError(`Install ${contract.pack} in this profile`, 409);
12067
+ if (pack.version !== reviewed.version || pack.revision !== reviewed.revision || json2(pack) !== json2(reviewed))
12068
+ throw new DeskError("Installed release differs from the reviewed catalog; review update before running", 409);
12069
+ const skills = await safe(root, ["skills"]), skillPath = await safe(root, ["skills", contract.skill]);
12070
+ if (installedVersion(await limited(await safe(root, ["skills", contract.skill, "SKILL.md"]))) !== pack.version)
12071
+ throw new DeskError("Installed skill version differs from its recorded release", 409);
12072
+ const issues = await verifyIntegrity(skills, { schemaVersion: 3, packs: [pack] }, recorded.integrity);
12073
+ if (issues.length)
12074
+ throw new DeskError(issues.join("; "), 409);
12075
+ const path = await safe(root, ["skills", contract.skill, "scripts", contract.module]);
12076
+ await limited(path);
12077
+ return { pack, path };
12078
+ }
12079
+ async function reserve(key, operation) {
12080
+ if (stopped)
12081
+ throw new DeskError("This desk is shutting down", 503);
12082
+ if (setup?.state === "running")
12083
+ throw new DeskError("Finish setup before starting research", 409);
12084
+ if (preparing.has(key) || active.has(key))
12085
+ throw new DeskError("This project already has an active run", 409);
12086
+ const controller = new AbortController;
12087
+ let release;
12088
+ const done = new Promise((resolve6) => {
12089
+ release = resolve6;
12090
+ });
12091
+ preparing.set(key, { controller, done });
12092
+ try {
12093
+ return await operation(controller);
12094
+ } finally {
12095
+ preparing.delete(key);
12096
+ release();
12097
+ }
12098
+ }
12099
+ function checkProfile() {
12100
+ if (profilePromise || Date.now() - profileCheckedAt < 60000 || stopped)
12101
+ return;
12102
+ const generation = profileGeneration;
12103
+ profileController = new AbortController;
12104
+ profilePromise = localProfileStatus(root, { signal: profileController.signal }).then((value) => {
12105
+ if (generation === profileGeneration)
12106
+ profileCache = { runtimeAvailable: value.runtime.available, modelConfigured: value.modelConfigured, credentialConfigured: value.credentialConfigured, authenticated: value.authenticated };
12107
+ }, () => {
12108
+ if (generation === profileGeneration)
12109
+ profileCache.runtimeAvailable = false;
12110
+ }).finally(() => {
12111
+ profileCheckedAt = generation === profileGeneration ? Date.now() : 0;
12112
+ profilePromise = undefined;
12113
+ profileController = undefined;
12114
+ });
12115
+ }
12116
+ async function status() {
12117
+ checkProfile();
12118
+ let modelConfigured = false;
12119
+ try {
12120
+ modelConfigured = hermesModelConfigured(await readHermesConfig(root));
12121
+ } catch {}
12122
+ const profile = { ...profileCache, modelConfigured, runtimeChecking: !!profilePromise };
12123
+ const capabilities = await Promise.all(Object.keys(kinds).map(async (kind) => {
12124
+ try {
12125
+ await installed(kind);
12126
+ return { kind, ready: true, issues: [] };
12127
+ } catch (error) {
12128
+ return { kind, ready: false, issues: [error.code === "ENOENT" ? `Install ${kinds[kind].pack} in this profile` : error.message] };
12129
+ }
12130
+ }));
12131
+ return { schemaVersion: 1, version: package_default.version, ready: capabilities.every((item) => item.ready), profile, capabilities, activeRuns: active.size + preparing.size, ...setup ? { setup } : {}, setupAvailable: !!options.onSetup, modelSetupAvailable: !!options.onModelSetup };
12132
+ }
12133
+ async function create(body) {
12134
+ return reserve(`create-${randomUUID3()}`, async (controller) => {
12135
+ if (!object(body) || !Object.hasOwn(kinds, body.kind) || Object.keys(body).some((key) => !["kind", "title", "inputs"].includes(key)))
12136
+ throw new DeskError("Choose wallet, market or strategy");
12137
+ const kind = body.kind, input = normalizeInput(kind, body.inputs);
12138
+ const title = body.title ?? (kind === "wallet" ? "Hyperliquid wallet review" : kind === "market" ? `${input.asset} market research` : `${input.asset} strategy test`);
12139
+ if (typeof title !== "string" || !title.trim() || title.length > 160)
12140
+ throw new DeskError("Title must contain 1\u2013160 characters");
12141
+ const name2 = `${kind}-${randomUUID3().slice(0, 8)}`;
12142
+ controller.signal.throwIfAborted();
12143
+ const { dataset, ...savedInput } = input;
12144
+ if (dataset)
12145
+ savedInput.uploadedDatasetSha256 = sha(json2(dataset));
12146
+ const project = await createProject(root, { name: name2, workflow: kinds[kind].workflow, inputs: savedInput, objective: title }, catalog);
12147
+ if (dataset)
12148
+ await writeFile3(await safe(root, [...projectParts(name2), "input.json"]), json2(dataset), { flag: "wx", mode: 384 });
12149
+ await writeFile3(await safe(root, [...projectParts(name2), "desk.json"]), json2({ schemaVersion: 1, kind, title }), { flag: "wx", mode: 384 });
12150
+ return projectDto(project);
12151
+ });
12152
+ }
12153
+ async function runDetails(name2, id) {
12154
+ const run = await readDeskRun(name2, id), parts = runParts(name2, id);
12155
+ const integrity = { issues: [], resultVerified: false };
12156
+ function parseSaved(value, file) {
12157
+ try {
12158
+ return JSON.parse(value);
12159
+ } catch {
12160
+ integrity.issues.push(`${file} contains invalid JSON`);
12161
+ return null;
12162
+ }
12163
+ }
12164
+ async function optional(file, parse = false) {
12165
+ try {
12166
+ const value = await limited(await safe(root, [...parts, file]), 20971520);
12167
+ return parse ? parseSaved(value, file) : value;
12168
+ } catch (error) {
12169
+ if (error.code === "ENOENT")
12170
+ return null;
12171
+ throw error;
12172
+ }
12173
+ }
12174
+ const resultText = await optional("result.json");
12175
+ if (["complete", "partial"].includes(run.state)) {
12176
+ integrity.issues = (await checkProjectRun(root, name2, id)).issues;
12177
+ if (run.resultSha256 !== undefined) {
12178
+ integrity.resultVerified = typeof run.resultSha256 === "string" && /^[a-f0-9]{64}$/.test(run.resultSha256) && resultText !== null && sha(resultText) === run.resultSha256;
12179
+ if (!integrity.resultVerified)
12180
+ integrity.issues.push("Structured result changed or is missing since this capture finished");
12181
+ }
12182
+ }
12183
+ return { run, report: await optional("report.md"), evidence: await optional("evidence.json", true), result: resultText === null ? null : parseSaved(resultText, "result.json"), integrity };
12184
+ }
12185
+ async function comparisonSnapshot(name2, id) {
12186
+ const detail = await runDetails(name2, id), record2 = (await projectRuns(root, name2)).find((run) => run.id === id);
12187
+ const brief = detail.integrity.issues.length ? { inputs: {} } : JSON.parse(await limited(await safe(root, [...runParts(name2, id), "brief.json"])));
12188
+ return { run: detail.run, inputs: brief.inputs, packRevision: record2.pack.revision, result: detail.result, evidence: detail.evidence?.observations ?? [], integrityIssues: detail.integrity.issues, resultVerified: detail.integrity.resultVerified };
12189
+ }
12190
+ async function startRun(name2) {
12191
+ return reserve(name2, async (controller) => {
12192
+ const project = await readProject(root, name2), meta = await readMetadata(name2), tools = await installed(meta.kind);
12193
+ controller.signal.throwIfAborted();
12194
+ if (meta.execution === "native-hermes")
12195
+ return startNative(project, meta, controller);
12196
+ const id = new Date().toISOString().replaceAll(":", "-").replace(".", "-") + "-" + randomUUID3().slice(0, 8), parts = runParts(name2, id);
12197
+ const output = await safe(root, parts), createdAt = new Date().toISOString();
12198
+ const brief = json2(project), prompt = renderProjectPrompt(project, output, (await projectRuns(root, name2)).at(-1));
12199
+ controller.signal.throwIfAborted();
12200
+ const projectLock = await safe(root, [...projectParts(name2), "run.lock"]);
12201
+ try {
12202
+ await mkdir3(projectLock, { mode: 448 });
12203
+ } catch (error) {
12204
+ if (error.code === "EEXIST")
12205
+ throw new DeskError("This project already has an active run or an unresolved run lock", 409);
12206
+ throw error;
12207
+ }
12208
+ const run = { schemaVersion: 1, id, project: name2, kind: meta.kind, createdAt, state: "queued", progress: "Preparing verified research tools" };
12209
+ const record2 = { schemaVersion: 1, id, project: name2, createdAt, state: "prepared", briefSha256: sha(brief), promptSha256: sha(prompt), pack: tools.pack, maxTurns: 1 };
12210
+ try {
12211
+ await writeFile3(join5(projectLock, "owner.json"), json2({ pid: process.pid, runId: id, owner: "desk" }), { flag: "wx", mode: 384 });
12212
+ await mkdir3(output, { mode: 448 });
12213
+ await mkdir3(join5(output, "sources"), { mode: 448 });
12214
+ for (const [file, value] of [["brief.json", brief], ["prompt.md", prompt], ["run.json", json2(record2)], ["desk.json", json2(run)]])
12215
+ await writeFile3(join5(output, file), value, { flag: "wx", mode: 384 });
12216
+ } catch (error) {
12217
+ await rm3(projectLock, { recursive: true, force: true });
12218
+ throw error;
12219
+ }
12220
+ const entry = { controller, done: Promise.resolve() };
12221
+ active.set(name2, entry);
12222
+ entry.done = execute(project, tools, run, record2, controller.signal).finally(async () => {
12223
+ active.delete(name2);
12224
+ await rm3(projectLock, { recursive: true, force: true });
12225
+ });
12226
+ return run;
12227
+ });
12228
+ }
12229
+ async function followup(name2, body) {
12230
+ return reserve(`followup-${name2}`, async (controller) => {
12231
+ if (!object(body) || Object.keys(body).some((key) => !["question", "maxTurns", "runId"].includes(key)) || typeof body.question !== "string" || !body.question.trim() || body.question.length > 4000)
12232
+ throw new DeskError("Enter a follow-up question under 4000 characters");
12233
+ if (body.runId !== undefined && (typeof body.runId !== "string" || !runPattern.test(body.runId)))
12234
+ throw new DeskError("Choose a valid saved run for the follow-up");
12235
+ const maxTurns = body.maxTurns ?? 10;
12236
+ if (!Number.isInteger(maxTurns) || maxTurns < 1 || maxTurns > 30)
12237
+ throw new DeskError("Follow-up requires 1\u201330 native model turns");
12238
+ const previous = await readProject(root, name2), meta = await readMetadata(name2);
12239
+ await installed(meta.kind);
12240
+ const runs = await projectRuns(root, name2);
12241
+ const priorRun = body.runId ? runs.find((item) => item.id === body.runId) : runs.filter((item) => item.state === "ready-for-review").at(-1);
12242
+ if (!priorRun || priorRun.state !== "ready-for-review")
12243
+ throw new DeskError("Follow up on a completed result with verified evidence", 409);
12244
+ const priorDetail = await runDetails(name2, priorRun.id);
12245
+ if (!["complete", "partial"].includes(priorDetail.run.state) || priorDetail.integrity.issues.length)
12246
+ throw new DeskError("Follow up on a completed result with verified evidence", 409);
12247
+ checkProfile();
12248
+ await profilePromise;
12249
+ controller.signal.throwIfAborted();
12250
+ const config = await readHermesConfig(root);
12251
+ if (!profileCache.runtimeAvailable || !hermesModelConfigured(config))
12252
+ throw new DeskError("Configure the native Hermes runtime and model first", 409);
12253
+ const derivedName = `followup-${randomUUID3().slice(0, 8)}`;
12254
+ const question = body.question.trim(), title = `Follow-up: ${question}`.slice(0, 160);
12255
+ const priorBrief = JSON.parse(await limited(await safe(root, [...runParts(name2, priorRun.id), "brief.json"])));
12256
+ const project = await createProject(root, { name: derivedName, workflow: previous.workflow.id, objective: `Answer the user's follow-up using fresh public reads and the previous saved research as historical context. Question: ${question}`, inputs: { ...priorBrief.inputs, followupQuestion: question, previousProject: name2, previousRunId: priorRun.id, previousReport: await safe(root, [...runParts(name2, priorRun.id), "report.md"]), previousEvidence: await safe(root, [...runParts(name2, priorRun.id), "evidence.json"]) } }, catalog);
12257
+ const derived = { schemaVersion: 1, kind: meta.kind, title, execution: "native-hermes", maxTurns, parent: { project: name2, runId: priorRun.id } };
12258
+ await writeFile3(await safe(root, [...projectParts(derivedName), "desk.json"]), json2(derived), { flag: "wx", mode: 384 });
12259
+ const run = await startNative(project, derived, controller);
12260
+ return { project: await projectDto(project), run };
12261
+ });
12262
+ }
12263
+ async function startNative(project, meta, controller = new AbortController) {
12264
+ if (active.has(project.name))
12265
+ throw new DeskError("This project already has an active run", 409);
12266
+ let persisted, preparedResolve, preparedReject;
12267
+ const prepared = new Promise((resolve6, reject) => {
12268
+ preparedResolve = resolve6;
12269
+ preparedReject = reject;
12270
+ });
12271
+ const entry = { controller, done: Promise.resolve() };
12272
+ active.set(project.name, entry);
12273
+ entry.done = (async () => {
12274
+ try {
12275
+ const launched = await runProject(root, project.name, {
12276
+ signal: controller.signal,
12277
+ executable: options.nativeExecutable,
12278
+ maxTurns: meta.maxTurns ?? 10,
12279
+ onPrepared: async (record2) => {
12280
+ persisted = { schemaVersion: 1, project: project.name, id: record2.id, kind: meta.kind, execution: "native-hermes", createdAt: record2.createdAt, state: "queued", progress: "Starting native Hermes with the configured model; provider usage may incur costs" };
12281
+ await saveRun(persisted);
12282
+ preparedResolve(persisted);
12283
+ },
12284
+ onProgress: async (message) => {
12285
+ if (persisted) {
12286
+ persisted.state = "running";
12287
+ persisted.progress = message;
12288
+ await saveRun(persisted);
12289
+ }
12290
+ }
12291
+ });
12292
+ if (!persisted || !launched.run)
12293
+ throw new Error("Native research did not produce its saved run record");
12294
+ persisted.state = launched.run.state === "ready-for-review" ? "complete" : "partial";
12295
+ persisted.finishedAt = launched.run.finishedAt;
12296
+ persisted.progress = launched.run.state === "ready-for-review" ? "Native research saved with validated evidence" : "Native research finished with evidence gaps that need review";
12297
+ await saveRun(persisted);
12298
+ } catch (error) {
12299
+ if (!persisted) {
12300
+ preparedReject(error);
12301
+ return;
12302
+ }
12303
+ persisted.state = controller.signal.aborted ? "cancelled" : "failed";
12304
+ persisted.finishedAt = new Date().toISOString();
12305
+ persisted.error = controller.signal.aborted ? "Native research cancelled; recorded evidence was preserved" : "Native research failed. Inspect the saved result and launching terminal before retrying.";
12306
+ persisted.progress = persisted.error;
12307
+ await saveRun(persisted);
12308
+ } finally {
12309
+ active.delete(project.name);
12310
+ }
12311
+ })();
12312
+ return prepared;
12313
+ }
12314
+ async function execute(project, tools, run, record2, signal) {
12315
+ const parts = runParts(project.name, run.id), evidence = [];
12316
+ async function progress(message) {
12317
+ signal.throwIfAborted();
12318
+ run.progress = message;
12319
+ await saveRun(run);
12320
+ }
12321
+ async function artifact(filename, value, source, summary, limitations = [], observedAt = new Date().toISOString()) {
12322
+ signal.throwIfAborted();
12323
+ const id = filename.replace(/\.[^.]+$/, "").toLowerCase().replace(/[^a-z0-9-]/g, "-").slice(0, 63);
12324
+ await writeFile3(await safe(root, [...parts, "sources", filename]), value, { flag: "wx", mode: 384 });
12325
+ evidence.push({ id, source, observedAt, summary, artifact: `sources/${filename}`, sha256: sha(value), limitations });
12326
+ }
12327
+ let readSequence = 0;
12328
+ const fetcher = async (resource, init) => {
12329
+ signal.throwIfAborted();
12330
+ const url = String(resource), parsed = new URL(url);
12331
+ if (!["api.hyperliquid.xyz", "api.hyperliquid-testnet.xyz", "api.coingecko.com", "coins.llama.fi"].includes(parsed.hostname) || parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.port)
12332
+ throw new DeskError("Helper requested an unreviewed endpoint", 409);
12333
+ let label = parsed.hostname.includes("hyperliquid") ? "Fetching account history" : "Fetching public market data";
12334
+ if (typeof init?.body === "string") {
12335
+ const type = JSON.parse(init.body).type;
12336
+ label = { userRole: "Checking public account identity", userAbstraction: "Checking account balance mode", clearinghouseState: "Fetching current perpetual exposure", spotClearinghouseState: "Fetching spot balances", frontendOpenOrders: "Fetching visible open orders", userFillsByTime: "Fetching fill history", userFunding: "Fetching funding cashflows" }[type] ?? label;
12337
+ }
12338
+ await progress(label);
12339
+ const sequence = ++readSequence;
12340
+ const response2 = await (options.fetcher ?? fetch)(resource, { ...init, credentials: "omit", redirect: "error", signal: init?.signal ? AbortSignal.any([signal, init.signal]) : signal });
12341
+ {
12342
+ const limit = run.kind === "wallet" ? 8388608 : 2097152, reader = response2.body?.getReader();
12343
+ if (!reader || Number(response2.headers.get("content-length")) > limit)
12344
+ throw new DeskError("Public response exceeds the capture bound", 502);
12345
+ const chunks = [];
12346
+ let length = 0;
12347
+ try {
12348
+ for (;; ) {
12349
+ const { done, value } = await reader.read();
12350
+ signal.throwIfAborted();
12351
+ if (done)
12352
+ break;
12353
+ length += value.length;
12354
+ if (length > limit)
12355
+ throw new DeskError("Public response exceeds the capture bound", 502);
12356
+ chunks.push(value);
12357
+ }
12358
+ } finally {
12359
+ await reader.cancel().catch(() => {});
12360
+ }
12361
+ const bytes2 = Buffer.concat(chunks);
12362
+ new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
12363
+ await artifact(`read-${String(sequence).padStart(3, "0")}.${run.kind === "wallet" ? "txt" : "json"}`, bytes2, url, `Raw public response: HTTP ${response2.status}; historical timestamps are contained in the response`, [run.kind === "wallet" ? "Sequential exchange snapshot; full-window completeness is unverified." : "Aggregate observations are not executable quotes."]);
12364
+ return new Response(bytes2, { status: response2.status, headers: response2.headers });
12365
+ }
12366
+ };
12367
+ try {
12368
+ run.state = "running";
12369
+ record2.state = "running";
12370
+ await saveRun(run);
12371
+ await atomic(root, [...parts, "run.json"], json2(record2));
12372
+ const module = await import(pathToFileURL(tools.path).href + `?release=${tools.pack.revision}`);
12373
+ let result, report, partial = false;
12374
+ if (run.kind === "wallet") {
12375
+ const capture = await module.captureWallet({ address: project.inputs.account, network: project.inputs.network, startTime: Date.parse(String(project.inputs.startTime)), endTime: Date.parse(String(project.inputs.endTime)) }, { maxPages: project.inputs.maxPages, timeoutMs: 15000, fetchImpl: fetcher });
12376
+ signal.throwIfAborted();
12377
+ await progress("Calculating signed fees, funding and current exposure");
12378
+ const serialized = json2(capture), endpoint = project.inputs.network === "testnet" ? "https://api.hyperliquid-testnet.xyz/info" : "https://api.hyperliquid.xyz/info";
12379
+ if (Buffer.byteLength(serialized) <= 20971520)
12380
+ await artifact("capture.json", serialized, endpoint, "Captured public request/response manifest with hashes", ["Window completeness remains unverified."], capture.finishedAt);
12381
+ else {
12382
+ await writeFile3(await safe(root, [...parts, "sources", "capture.json"]), serialized, { flag: "wx", mode: 384 });
12383
+ const manifest = { ...capture, evidence: capture.evidence.map(({ responseText, ...entry }) => ({ ...entry, responseArtifact: responseText !== null ? `sources/read-${String(entry.sequence).padStart(3, "0")}.txt` : null })) };
12384
+ await artifact("capture-manifest.json", json2(manifest), endpoint, "Large capture manifest; raw responses are separate bounded evidence artifacts", ["Aggregate capture exceeds the individual evidence download bound; reconstruct from each response and this manifest."], capture.finishedAt);
12385
+ }
12386
+ result = module.analyzeCapture(capture);
12387
+ report = module.renderReport(result);
12388
+ partial = result.coverage.status === "partial";
12389
+ } else if (run.kind === "market") {
12390
+ result = await module.marketSnapshot({ ids: [project.inputs.asset], provider: "both" }, { fetch: fetcher, timeoutMs: 15000 });
12391
+ signal.throwIfAborted();
12392
+ if (result.status === "unavailable" || result.error) {
12393
+ await atomic(root, [...parts, "result.json"], json2(result));
12394
+ throw new DeskError("Market data is unavailable. Inspect provider errors and retry later.", 502);
12395
+ }
12396
+ const rows = result.reads.flatMap((read) => read.observations);
12397
+ report = `# ${project.inputs.asset} market snapshot
12398
+
12399
+ Exact identity: CoinGecko ID ${project.inputs.asset}. Public USD aggregate observations.
12400
+
12401
+ ` + rows.map((row) => row.ok ? `${row.provider}: ${row.priceUsd} USD, observed ${row.observedAt}, retrieved ${row.retrievedAt}.` : `${row.provider}: unavailable (${row.error}).`).join(`
12402
+
12403
+ `) + `
12404
+
12405
+ ${result.limitations.join(`
12406
+
12407
+ `)}
12408
+
12409
+ A price snapshot alone cannot establish valuation, investment quality or a complete asset thesis.
12410
+ `;
12411
+ partial = result.status !== "complete";
12412
+ } else {
12413
+ const input = project.inputs;
12414
+ const source = `https://raw.githubusercontent.com/galleonlabs/crypto-defi-skills/${tools.pack.revision}/packages/strategy/skills/galleon-defi-strategy-backtest/scripts/engine.mjs`;
12415
+ let dataset;
12416
+ if (input.datasetSource === "upload") {
12417
+ const uploaded = await limited(await safe(root, [...projectParts(project.name), "input.json"]), 262144);
12418
+ if (sha(uploaded) !== input.uploadedDatasetSha256)
12419
+ throw new DeskError("Saved uploaded dataset changed; create a new project", 409);
12420
+ dataset = JSON.parse(uploaded);
12421
+ await progress("Validating uploaded daily observations");
12422
+ } else if (input.datasetSource === "bundled") {
12423
+ dataset = JSON.parse(await limited(await safe(assets, ["data", "bitcoin-180d.json"]), 262144));
12424
+ await progress("Validating the explicitly selected historical Bitcoin series");
12425
+ } else {
12426
+ const dataTools = await installed("market"), dataModule = await import(pathToFileURL(dataTools.path).href + `?release=${dataTools.pack.revision}`);
12427
+ const collected = await dataModule.collectHistory({ id: input.asset, days: input.days }, { fetch: fetcher, timeoutMs: 15000 });
12428
+ signal.throwIfAborted();
12429
+ if (!collected.ok)
12430
+ throw new DeskError(`Daily history unavailable (${collected.error}); no substitute data was used`, 502);
12431
+ dataset = collected.dataset;
12432
+ }
12433
+ const valid = module.validateDataset(dataset);
12434
+ if (valid.identity.namespace !== "coingecko" || valid.identity.id !== input.asset)
12435
+ throw new DeskError("Dataset identity differs from the selected CoinGecko asset", 409);
12436
+ const spec = module.createStrategySpec(input.template, { initialCashUsd: input.initialCashUsd, feeBps: input.feeBps, slippageBps: input.slippageBps, ...input.amountUsd !== undefined ? { amountUsd: input.amountUsd } : {} });
12437
+ await artifact("dataset.json", json2(valid), valid.provenance.synthetic ? source : valid.provenance.source, `${valid.identity.id} daily USD observations, retrieved ${valid.provenance.retrievedAt}`, [valid.provenance.synthetic ? "Synthetic dataset: source URL documents the model, not market history. Dataset provenance remains in the captured JSON." : "Historical aggregate series; source timestamps and price type are retained."]);
12438
+ await artifact("specification.json", json2(spec), source, "Frozen rule and explicit cash, fee and slippage assumptions", ["No parameter optimization or future-return claim."]);
12439
+ await progress("Comparing reference and held-out periods with higher trading costs");
12440
+ result = module.runStrategyValidation(valid, spec);
12441
+ result.inputHashes = { datasetSha256: sha(json2(valid)), specificationSha256: sha(json2(spec)), engineSha256: sha(await readFile5(tools.path)) };
12442
+ report = `# ${input.asset} frozen-rule strategy validation
12443
+
12444
+ Evidence: ${valid.provenance.synthetic ? "synthetic example" : "historical simulation"}. Source: ${valid.provenance.source}. Dataset retrieved ${valid.provenance.retrievedAt}.
12445
+
12446
+ Rule: ${input.template}. Each period restarts independently with ${input.initialCashUsd} USD.
12447
+
12448
+ ` + ["reference", "heldOut"].map((period) => {
12449
+ const row = result.periods[period];
12450
+ return `${period === "heldOut" ? "Held-out" : "Reference"}: ${row.period.firstObservation} to ${row.period.lastObservation}. Baseline ending equity ${row.baseline.metrics.endingEquityUsd} USD; maximum drawdown ${row.baseline.metrics.maxDrawdownPct}%. Higher-cost ending equity ${row.higherCosts.metrics.endingEquityUsd} USD. Same-cost buy-and-hold benchmark ${row.baseline.benchmark.metrics.endingEquityUsd} USD.`;
12451
+ }).join(`
12452
+
12453
+ `) + `
12454
+
12455
+ ${result.limitations.join(`
12456
+
12457
+ `)}
12458
+ `;
12459
+ }
12460
+ signal.throwIfAborted();
12461
+ report += `
12462
+
12463
+ Captured evidence:
12464
+ ` + evidence.map((item) => `
12465
+ - [${item.id}] ${item.summary}`).join("") + `
12466
+ `;
12467
+ const resultText = json2(result);
12468
+ await atomic(root, [...parts, "result.json"], resultText);
12469
+ run.resultSha256 = sha(resultText);
12470
+ await atomic(root, [...parts, "report.md"], report);
12471
+ await atomic(root, [...parts, "evidence.json"], json2({ schemaVersion: 1, observations: evidence }));
12472
+ await atomic(root, [...parts, "plan.json"], json2({ schemaVersion: 1, status: "no-action", authorization: "not-granted", summary: "Read-only research; no financial action or authority", steps: [] }));
12473
+ record2.state = "needs-review";
12474
+ record2.finishedAt = new Date().toISOString();
12475
+ await atomic(root, [...parts, "run.json"], json2(record2));
12476
+ const checked = await checkProjectRun(root, project.name, run.id);
12477
+ if (checked.issues.length)
12478
+ throw new DeskError("Saved result failed evidence validation: " + checked.issues.join("; "), 409);
12479
+ record2.state = "ready-for-review";
12480
+ await atomic(root, [...parts, "run.json"], json2(record2));
12481
+ run.state = partial ? "partial" : "complete";
12482
+ run.finishedAt = record2.finishedAt;
12483
+ run.progress = partial ? "Saved with explicit missing or partial observations" : "Research saved; sources and methodology are available";
12484
+ await saveRun(run);
12485
+ } catch (error) {
12486
+ const message = signal.aborted ? "Capture cancelled. Refresh starts a new run; previous evidence was preserved." : error.message;
12487
+ run.state = signal.aborted ? "cancelled" : "failed";
12488
+ run.finishedAt = new Date().toISOString();
12489
+ run.error = message;
12490
+ run.progress = message;
12491
+ record2.state = "failed";
12492
+ record2.finishedAt = run.finishedAt;
12493
+ record2.issues = [message];
12494
+ await atomic(root, [...parts, "evidence.json"], json2({ schemaVersion: 1, observations: evidence }));
12495
+ await atomic(root, [...parts, "report.md"], `# Research incomplete
12496
+
12497
+ ${message}
12498
+
12499
+ ${evidence.map((item) => `[${item.id}] ${item.summary}`).join(`
12500
+
12501
+ `)}
12502
+ `);
12503
+ await atomic(root, [...parts, "plan.json"], json2({ schemaVersion: 1, status: "no-action", authorization: "not-granted", summary: message, steps: [] }));
12504
+ await atomic(root, [...parts, "run.json"], json2(record2));
12505
+ await saveRun(run);
12506
+ }
12507
+ }
12508
+ let origin = "";
12509
+ const headers = { "cache-control": "no-store", "x-content-type-options": "nosniff", "referrer-policy": "no-referrer", "content-security-policy": "default-src 'self'; connect-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'; form-action 'self'" };
12510
+ function response(value, status2 = 200) {
12511
+ return Response.json(value, { status: status2, headers });
12512
+ }
12513
+ async function requestJson(request) {
12514
+ if (request.headers.get("content-type")?.split(";")[0].trim() !== "application/json")
12515
+ throw new DeskError("Use application/json", 415);
12516
+ if (Number(request.headers.get("content-length")) > 327680)
12517
+ throw new DeskError("Request exceeds 320 KiB", 413);
12518
+ const reader = request.body?.getReader();
12519
+ if (!reader)
12520
+ throw new DeskError("JSON body is required");
12521
+ let length = 0;
12522
+ const chunks = [];
12523
+ try {
12524
+ for (;; ) {
12525
+ const { value, done } = await reader.read();
12526
+ if (done)
12527
+ break;
12528
+ length += value.length;
12529
+ if (length > 327680)
12530
+ throw new DeskError("Request exceeds 320 KiB", 413);
12531
+ chunks.push(value);
12532
+ }
12533
+ } finally {
12534
+ await reader.cancel().catch(() => {});
12535
+ }
12536
+ try {
12537
+ return JSON.parse(Buffer.concat(chunks).toString("utf8"));
12538
+ } catch {
12539
+ throw new DeskError("Invalid JSON request");
12540
+ }
12541
+ }
12542
+ const server = await (async () => {
12543
+ try {
12544
+ return Bun.serve({
12545
+ hostname: "127.0.0.1",
12546
+ port: options.port ?? 0,
12547
+ maxRequestBodySize: 327680,
12548
+ async fetch(request) {
12549
+ try {
12550
+ if (stopped)
12551
+ throw new DeskError("This desk is shutting down", 503);
12552
+ const url = new URL(request.url);
12553
+ if (request.headers.get("host") !== new URL(origin).host || url.origin !== origin)
12554
+ throw new DeskError("Unexpected desk host", 403);
12555
+ const requestOrigin = request.headers.get("origin");
12556
+ if (requestOrigin && requestOrigin !== origin || request.headers.get("sec-fetch-site") === "cross-site")
12557
+ throw new DeskError("Only the local desk origin is allowed", 403);
12558
+ const path = url.pathname;
12559
+ if (path.startsWith("/api/")) {
12560
+ const supplied = request.headers.get("authorization")?.replace(/^Bearer /, "") ?? "";
12561
+ if (!/^[0-9a-f]{64}$/.test(supplied) || !timingSafeEqual(Buffer.from(supplied), Buffer.from(token)))
12562
+ throw new DeskError("This desk session requires its launch token", 401);
12563
+ if (!["GET", "POST"].includes(request.method))
12564
+ throw new DeskError("Method not allowed", 405);
12565
+ if (request.method === "GET" && path === "/api/status")
12566
+ return response(await status());
12567
+ if (request.method === "GET" && path === "/api/projects")
12568
+ return response({ projects: await projects() });
12569
+ if (request.method === "POST" && ["/api/setup", "/api/model-setup"].includes(path)) {
12570
+ if (active.size || preparing.size || setup?.state === "running")
12571
+ throw new DeskError("A capture or setup is already running", 409);
12572
+ const callback = path === "/api/setup" ? options.onSetup : options.onModelSetup;
12573
+ if (!callback)
12574
+ throw new DeskError("This launcher does not provide this setup action", 409);
12575
+ setup = { state: "running", action: path === "/api/setup" ? "public-tools" : "model", message: path === "/api/setup" ? "Installing reviewed public research tools" : "Preparing Hermes's browser setup; the first build can take several minutes" };
12576
+ setupController = new AbortController;
12577
+ setupPromise = Promise.resolve().then(() => callback(setupController.signal)).then((value) => {
12578
+ profileCheckedAt = 0;
12579
+ profileGeneration++;
12580
+ profileController?.abort();
12581
+ let result;
12582
+ if (object(value) && typeof value.url === "string") {
12583
+ const destination = new URL(value.url);
12584
+ if (destination.protocol === "http:" && destination.hostname === "127.0.0.1" && !destination.username && !destination.password)
12585
+ result = { url: value.url };
12586
+ }
12587
+ setup = { ...setup, state: "complete", message: result ? "Native model setup is available in its local window" : "Setup completed; readiness is checked against the selected profile", ...result ? { result } : {} };
12588
+ }).catch((error) => {
12589
+ setup = { ...setup, state: "failed", message: error.message };
12590
+ });
12591
+ return response({ setup }, 202);
12592
+ }
12593
+ if (request.method === "POST" && path === "/api/projects")
12594
+ return response({ project: await create(await requestJson(request)) }, 201);
12595
+ const match = path.match(/^\/api\/projects\/([a-z0-9-]+)(?:\/runs\/([^/]+)(?:\/(export|cancel|evidence|compare)(?:\/([^/]+))?)?|\/(run|refresh|followup))?$/);
12596
+ if (!match)
12597
+ throw new DeskError("Unknown desk route", 404);
12598
+ const [, name2, id, action, observationId, operation] = match;
12599
+ if (!id && !operation && request.method === "GET")
12600
+ return response({ project: await projectDto(await readProject(root, name2)) });
12601
+ if (operation === "followup" && request.method === "POST")
12602
+ return response(await followup(name2, await requestJson(request)), 202);
12603
+ if (operation && request.method === "POST")
12604
+ return response({ run: await startRun(name2) }, 202);
12605
+ if (id) {
12606
+ if (action === "compare" && request.method === "GET") {
12607
+ const params = new URL(request.url).searchParams, baseline = params.get("baseline");
12608
+ if (!baseline || params.getAll("baseline").length !== 1 || [...params.keys()].some((key) => key !== "baseline") || observationId)
12609
+ throw new DeskError("Choose one baseline run from this project");
12610
+ validRun(baseline);
12611
+ validRun(id);
12612
+ const before = await comparisonSnapshot(name2, baseline), after = await comparisonSnapshot(name2, id);
12613
+ return response(compareDeskRuns(after.run.kind, before, after));
12614
+ }
12615
+ if (action === "cancel" && request.method === "POST") {
12616
+ const run = await readDeskRun(name2, id), pending = active.get(name2);
12617
+ if (!pending || !["queued", "running"].includes(run.state))
12618
+ throw new DeskError("This run is no longer active", 409);
12619
+ const current = (await projectRuns(root, name2)).at(-1);
12620
+ if (current?.id !== id)
12621
+ throw new DeskError("Only the active run can be cancelled", 409);
12622
+ pending.controller.abort();
12623
+ await pending.done;
12624
+ return response({ run: await readDeskRun(name2, id) });
12625
+ }
12626
+ if (request.method === "GET" && action === "evidence") {
12627
+ if (!observationId || !slug.test(observationId))
12628
+ throw new DeskError("Invalid observation ID");
12629
+ const detail = await runDetails(name2, id), evidence = detail.evidence?.observations?.find((item) => item.id === observationId);
12630
+ if (!evidence || !/^sources\/(?:[a-zA-Z0-9][a-zA-Z0-9._-]*\/)*[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(evidence.artifact))
12631
+ throw new DeskError("Unknown captured observation", 404);
12632
+ const bytes2 = await limitedBytes(await safe(root, [...runParts(name2, id), ...evidence.artifact.split("/")]), 20971520);
12633
+ if (sha(bytes2) !== evidence.sha256)
12634
+ throw new DeskError("Captured artifact hash differs from its evidence record", 409);
12635
+ return new Response(bytes2, { headers: { ...headers, "content-type": "text/plain; charset=utf-8" } });
12636
+ }
12637
+ if (request.method === "GET" && (!action || action === "export")) {
12638
+ const detail = await runDetails(name2, id);
12639
+ if (action === "export")
12640
+ return new Response(json2(detail), { headers: { ...headers, "content-type": "application/json", "content-disposition": `attachment; filename="${name2}-${id}.json"` } });
12641
+ return response(detail);
12642
+ }
12643
+ }
12644
+ throw new DeskError("Unknown desk operation", 404);
12645
+ }
12646
+ if (request.method !== "GET" && request.method !== "HEAD")
12647
+ throw new DeskError("Method not allowed", 405);
12648
+ const files = {
12649
+ "/": { parts: ["index.html"], type: "text/html; charset=utf-8" },
12650
+ "/index.html": { parts: ["index.html"], type: "text/html; charset=utf-8" },
12651
+ "/app.js": { parts: ["app.js"], type: "text/javascript; charset=utf-8" },
12652
+ "/style.css": { parts: ["style.css"], type: "text/css; charset=utf-8" },
12653
+ "/assets/app.js": { parts: ["app.js"], type: "text/javascript; charset=utf-8" },
12654
+ "/assets/ui.js": { parts: ["ui.js"], type: "text/javascript; charset=utf-8" },
12655
+ "/assets/desk.css": { parts: ["desk.css"], type: "text/css; charset=utf-8" },
12656
+ "/assets/favicon.svg": { parts: ["assets", "favicon.svg"], type: "image/svg+xml" },
12657
+ "/assets/manrope.ttf": { parts: ["assets", "manrope.ttf"], type: "font/ttf" },
12658
+ "/assets/strategy-engine.mjs": { parts: ["vendor", "strategy-engine.mjs"], type: "text/javascript; charset=utf-8" },
12659
+ "/assets/bitcoin-180d.json": { parts: ["data", "bitcoin-180d.json"], type: "application/json" },
12660
+ "/assets/synthetic-daily.json": { parts: ["data", "synthetic-daily.json"], type: "application/json" }
12661
+ };
12662
+ if (!Object.hasOwn(files, path))
12663
+ throw new DeskError("Unknown desk asset", 404);
12664
+ const file = files[path], filePath = await safe(assets, file.parts);
12665
+ const stat = await lstat4(filePath);
12666
+ if (!stat.isFile() || stat.size > 1048576)
12667
+ throw new DeskError("Expected a bounded regular asset", 409);
12668
+ const contents = await readFile5(filePath);
12669
+ return new Response(request.method === "HEAD" ? null : contents, { headers: { ...headers, "content-type": file.type } });
12670
+ } catch (error) {
12671
+ const status2 = error instanceof DeskError ? error.status : error.code === "ENOENT" ? 404 : 500;
12672
+ return response({ error: { message: status2 === 500 ? "Desk operation failed; saved files were preserved" : error.message } }, status2);
12673
+ }
12674
+ }
12675
+ });
12676
+ } catch (error) {
12677
+ await rm3(lock, { recursive: true, force: true });
12678
+ throw error;
12679
+ }
12680
+ })();
12681
+ origin = `http://127.0.0.1:${server.port}`;
12682
+ return { url: `${origin}/#token=${token}`, server, async stop() {
12683
+ if (stopping)
12684
+ return stopping;
12685
+ stopped = true;
12686
+ stopping = (async () => {
12687
+ profileController?.abort();
12688
+ setupController?.abort();
12689
+ for (const entry of preparing.values())
12690
+ entry.controller.abort();
12691
+ for (const entry of active.values())
12692
+ entry.controller.abort();
12693
+ await Promise.allSettled([...preparing.values()].map((entry) => entry.done));
12694
+ for (const entry of active.values())
12695
+ entry.controller.abort();
12696
+ await Promise.allSettled([...active.values()].map((entry) => entry.done));
12697
+ await Promise.allSettled([profilePromise, setupPromise]);
12698
+ server.stop(true);
12699
+ await rm3(lock, { recursive: true, force: true });
12700
+ })();
12701
+ return stopping;
12702
+ } };
12703
+ }
12704
+
12705
+ // src/desk-launch.ts
12706
+ init_core();
12707
+ import { lstat as lstat5, readFile as readFile6 } from "fs/promises";
12708
+ import { join as join6, resolve as resolve6 } from "path";
12709
+ import { fileURLToPath } from "url";
12710
+ var publicDeskPacks = ["defi-data-skills", "hyperliquid-skills", "defi-strategy-skills"];
12711
+ async function deskSetupPacks(directory, catalog) {
12712
+ const root = resolve6(directory);
12713
+ const file = join6(root, ".boomkin/config.json");
12714
+ let previous = [];
12715
+ try {
12716
+ for (const path of [root, join6(root, ".boomkin"), file])
12717
+ if ((await lstat5(path)).isSymbolicLink())
12718
+ throw new Error("Refusing a symlink in the selected profile");
12719
+ const config = parseConfig(JSON.parse(await readFile6(file, "utf8")), root);
12720
+ if (config.harness !== "hermes")
12721
+ throw new Error("The local desk requires a Hermes profile; choose another directory");
12722
+ previous = config.packs ?? catalog.packs.map((pack) => pack.id);
12723
+ } catch (error) {
12724
+ if (error.code !== "ENOENT")
12725
+ throw error;
12726
+ }
12727
+ return [...new Set([...previous, ...publicDeskPacks])];
12728
+ }
12729
+ function deskAssetsDirectory(moduleUrl) {
12730
+ const file = fileURLToPath(moduleUrl);
12731
+ return file.endsWith("/dist/cli.js") ? join6(file, "../desk") : join6(file, "../../dist/desk");
12732
+ }
12733
+ function deskPort(value) {
12734
+ if (value === undefined)
12735
+ return 0;
12736
+ if (!/^(?:0|[1-9]\d{0,4})$/.test(value) || Number(value) > 65535)
12737
+ throw new Error("--port must be an integer from 0 to 65535");
12738
+ return Number(value);
12739
+ }
12740
+
12741
+ // src/desk-model.ts
12742
+ import { join as join7, resolve as resolve7 } from "path";
12743
+ function dashboardEnvironment(directory, inherited = process.env) {
12744
+ const root = resolve7(directory);
12745
+ const env = { ...inherited, HERMES_HOME: root, HERMES_CONFIG: join7(root, "config.yaml"), HERMES_ENV: join7(root, ".env") };
12746
+ for (const key of ["HERMES_DESKTOP", "HERMES_SERVE_HEADLESS", "HERMES_WEB_DIST", "HERMES_DASHBOARD_SESSION_TOKEN", "HERMES_SESSION_KEY"])
12747
+ delete env[key];
12748
+ return env;
12749
+ }
12750
+ function createNativeDashboard(directory, options = {}) {
12751
+ let child;
12752
+ let probe;
12753
+ let opening;
12754
+ let readyUrl;
12755
+ let stopped = false;
12756
+ const terminate = async (target) => {
12757
+ if (!target)
12758
+ return;
12759
+ await terminateOwnedProcess(target, process.platform !== "win32");
12760
+ if (child === target) {
12761
+ child = undefined;
12762
+ readyUrl = undefined;
12763
+ }
12764
+ if (probe === target)
12765
+ probe = undefined;
12766
+ };
12767
+ const stop = async () => {
12768
+ stopped = true;
12769
+ await Promise.all([terminate(child), terminate(probe)]);
12770
+ readyUrl = undefined;
12771
+ };
12772
+ const open = async () => {
12773
+ if (stopped)
12774
+ throw new Error("The desk has stopped");
12775
+ if (readyUrl && child?.exitCode === null)
12776
+ return { url: readyUrl };
12777
+ if (opening)
12778
+ return opening;
12779
+ opening = (async () => {
12780
+ const executable = options.executable ?? await findRuntime(directory);
12781
+ if (!executable)
12782
+ throw new Error("Prepare native Hermes before connecting a model");
12783
+ const env = dashboardEnvironment(directory, options.environment);
12784
+ const helpProbe = probe = Bun.spawn([executable, "--profile", "default", "dashboard", "--help"], { cwd: resolve7(directory), env, stdin: "ignore", stdout: "pipe", stderr: "pipe", detached: process.platform !== "win32" });
12785
+ new Response(helpProbe.stderr).arrayBuffer();
12786
+ const probeTimeout = setTimeout(() => {
12787
+ terminate(helpProbe);
12788
+ }, 15000);
12789
+ let help, probeCode;
12790
+ try {
12791
+ help = await new Response(helpProbe.stdout).text();
12792
+ probeCode = await helpProbe.exited;
12793
+ } finally {
12794
+ clearTimeout(probeTimeout);
12795
+ }
12796
+ if (probe === helpProbe)
12797
+ probe = undefined;
12798
+ if (probeCode !== 0 || ["--no-open", "--isolated", "--host", "--port"].some((flag) => !help.includes(flag)))
12799
+ throw new Error("This Hermes installation lacks the reviewed browser setup contract. Use its native update or boomkin model in your terminal.");
12800
+ if (stopped)
12801
+ throw new Error("The desk has stopped");
12802
+ const started = child = Bun.spawn([executable, "--profile", "default", "dashboard", "--no-open", "--isolated", "--host", "127.0.0.1", "--port", "0"], { cwd: resolve7(directory), env, stdin: "ignore", stdout: "pipe", stderr: "pipe", detached: process.platform !== "win32" });
12803
+ let resolvePort;
12804
+ const portReady = new Promise((done) => {
12805
+ resolvePort = done;
12806
+ });
12807
+ const consume = async (stream) => {
12808
+ const decoder = new TextDecoder;
12809
+ let tail = "";
12810
+ for await (const bytes2 of stream) {
12811
+ const lines = (tail + decoder.decode(bytes2, { stream: true })).split(`
12812
+ `);
12813
+ tail = lines.pop().slice(-4096);
12814
+ for (const line of lines) {
12815
+ const match = line.match(/^HERMES_DASHBOARD_READY port=(\d{1,5})\r?$/);
12816
+ if (match && Number(match[1]) >= 1 && Number(match[1]) <= 65535)
12817
+ resolvePort(Number(match[1]));
12818
+ }
12819
+ }
12820
+ };
12821
+ consume(started.stdout).catch(() => {});
12822
+ consume(started.stderr).catch(() => {});
12823
+ let timeout;
12824
+ try {
12825
+ const port = await Promise.race([
12826
+ portReady,
12827
+ started.exited.then(() => {
12828
+ throw new Error("Native browser setup exited before it was ready. Check Hermes's dashboard prerequisites, including its supported Node.js version, or use boomkin model in your terminal.");
12829
+ }),
12830
+ new Promise((_, reject) => {
12831
+ timeout = setTimeout(() => reject(new Error("Native browser setup timed out while preparing its dashboard. Check Hermes's prerequisites or use boomkin model in your terminal.")), options.startupTimeoutMs ?? 900000);
12832
+ })
12833
+ ]);
12834
+ if (stopped || started.exitCode !== null)
12835
+ throw new Error("Native browser setup has stopped");
12836
+ const origin = `http://127.0.0.1:${port}`;
12837
+ const response = await fetch(`${origin}/api/health`, { redirect: "error", signal: AbortSignal.timeout(5000) });
12838
+ const health = await response.json();
12839
+ if (!response.ok || health.ok !== true || typeof health.version !== "string" || started.exitCode !== null)
12840
+ throw new Error("Native browser setup did not confirm its health");
12841
+ readyUrl = `${origin}/env`;
12842
+ return { url: readyUrl };
12843
+ } catch (error) {
12844
+ await terminate(started);
12845
+ throw error;
12846
+ } finally {
12847
+ if (timeout)
12848
+ clearTimeout(timeout);
12849
+ }
12850
+ })();
12851
+ try {
12852
+ return await opening;
12853
+ } finally {
12854
+ opening = undefined;
12855
+ }
12856
+ };
12857
+ return { open, stop };
12858
+ }
12859
+
11434
12860
  // src/cli.ts
11435
12861
  var help = `Boomkin \u2014 your Hermes DeFi agent.
11436
12862
 
12863
+ boomkin desk
12864
+ boomkin desk --directory ~/.boomkin/hermes --no-open
11437
12865
  boomkin onboard
11438
12866
  boomkin doctor --live
11439
12867
  boomkin start
@@ -11461,6 +12889,10 @@ boomkin chatgpt --action status
11461
12889
  boomkin check --directory ~/.boomkin/hermes
11462
12890
  boomkin update --directory ~/.boomkin/hermes
11463
12891
 
12892
+ desk opens your local browser desk for public market data, wallet reviews and strategy tests.
12893
+ Prepare public tools in the desk; these jobs need no model or funded wallet.
12894
+ Optional research uses native Hermes and your selected model. --port chooses a loopback port.
12895
+ --no-open prints the local address without opening a browser. Stop with Ctrl-C.
11464
12896
  onboard installs the official Hermes runtime if needed, prepares an isolated profile,
11465
12897
  installs the selected Galleon skill packs and public CoinGecko MCP, then runs native model setup.
11466
12898
  --directory chooses the Hermes home (default ~/.boomkin/hermes for the commands above).
@@ -11493,7 +12925,7 @@ async function canonicalPath(path) {
11493
12925
  } catch (error) {
11494
12926
  if (error.code !== "ENOENT")
11495
12927
  throw error;
11496
- return join5(await canonicalPath(dirname2(path)), basename(path));
12928
+ return join8(await canonicalPath(dirname2(path)), basename(path));
11497
12929
  }
11498
12930
  }
11499
12931
  async function main() {
@@ -11509,6 +12941,8 @@ async function main() {
11509
12941
  workflow: { type: "string" },
11510
12942
  protocol: { type: "string" },
11511
12943
  json: { type: "boolean" },
12944
+ port: { type: "string" },
12945
+ "no-open": { type: "boolean" },
11512
12946
  search: { type: "string" },
11513
12947
  capability: { type: "string" },
11514
12948
  access: { type: "string" },
@@ -11530,6 +12964,8 @@ async function main() {
11530
12964
  return console.log(`Boomkin ${package_default.version}`);
11531
12965
  if (values.help || command === "help")
11532
12966
  return console.log(help);
12967
+ if ((values.port !== undefined || values["no-open"]) && command !== "desk")
12968
+ throw new Error("--port and --no-open are only available for desk");
11533
12969
  if (values.action && command !== "chatgpt")
11534
12970
  throw new Error("--action is only available for chatgpt");
11535
12971
  if (positionals.length > (command === "project" ? 2 : 1))
@@ -11556,8 +12992,70 @@ async function main() {
11556
12992
  throw new Error("--live is only available for doctor");
11557
12993
  if ((values["all-packs"] || values["skip-model-setup"] || values["no-install"]) && command !== "onboard")
11558
12994
  throw new Error("Onboarding options are only available for onboard");
11559
- if (values["dry-run"] && !["onboard", "setup", "update", "connect", "start", "model", "chatgpt", "project"].includes(command))
12995
+ if (values["dry-run"] && !["desk", "onboard", "setup", "update", "connect", "start", "model", "chatgpt", "project"].includes(command))
11560
12996
  throw new Error("--dry-run is unavailable for this read-only command");
12997
+ if (command === "desk") {
12998
+ if (values.pack || values.harness || values["offline-catalog"])
12999
+ throw new Error("desk uses its selected Hermes profile; pack options belong to setup or onboard");
13000
+ const directory2 = await canonicalPath(resolve8(values.directory ?? defaultProfile()));
13001
+ const port = deskPort(values.port);
13002
+ if (values["dry-run"])
13003
+ return console.log(`Would serve the local desk on 127.0.0.1:${port || "an available port"} using ${directory2}; no model, data read or setup starts in this preview.`);
13004
+ const catalog2 = parseCatalog(skills_default);
13005
+ const nativeDashboard = createNativeDashboard(directory2);
13006
+ const desk = await startDesk({
13007
+ directory: directory2,
13008
+ catalog: catalog2,
13009
+ port,
13010
+ assetsDirectory: deskAssetsDirectory(import.meta.url),
13011
+ onSetup: async (signal) => {
13012
+ const selected = await deskSetupPacks(directory2, catalog2);
13013
+ signal.throwIfAborted();
13014
+ const group = process.platform !== "win32";
13015
+ const child = Bun.spawn([process.execPath, fileURLToPath2(import.meta.url), "setup", "--harness", "hermes", "--directory", directory2, ...selected.flatMap((id) => ["--pack", id])], { stdin: "inherit", stdout: "inherit", stderr: "inherit", detached: group });
13016
+ let termination;
13017
+ const abort = () => {
13018
+ termination ??= terminateOwnedProcess(child, group);
13019
+ };
13020
+ signal.addEventListener("abort", abort, { once: true });
13021
+ try {
13022
+ if (signal.aborted)
13023
+ abort();
13024
+ const code = await child.exited;
13025
+ signal.throwIfAborted();
13026
+ if (code !== 0)
13027
+ throw new Error("Public tool preparation failed. Review the launching terminal and retry; completed packs remain installed.");
13028
+ } finally {
13029
+ signal.removeEventListener("abort", abort);
13030
+ if (termination)
13031
+ await termination;
13032
+ }
13033
+ },
13034
+ onModelSetup: async (signal) => {
13035
+ await prepareHermes(directory2, { install: true, skipModelSetup: true, signal });
13036
+ signal.throwIfAborted();
13037
+ return nativeDashboard.open();
13038
+ }
13039
+ });
13040
+ console.log(`Boomkin desk: ${desk.url}
13041
+ Profile: ${directory2}
13042
+ Public jobs use bounded keyless reads. Native model research is optional. Stop with Ctrl-C.`);
13043
+ if (!values["no-open"]) {
13044
+ const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? undefined : Bun.which("xdg-open");
13045
+ if (opener)
13046
+ Bun.spawn([opener, desk.url], { stdout: "ignore", stderr: "ignore" });
13047
+ }
13048
+ const stop = async () => {
13049
+ await nativeDashboard.stop();
13050
+ await desk.stop();
13051
+ process.exit(0);
13052
+ };
13053
+ process.once("SIGINT", stop);
13054
+ process.once("SIGTERM", stop);
13055
+ if (process.platform !== "win32")
13056
+ process.once("SIGHUP", stop);
13057
+ return;
13058
+ }
11561
13059
  if (command === "project") {
11562
13060
  const action = positionals[1];
11563
13061
  if (!action || !["create", "list", "show", "run", "check"].includes(action))
@@ -11574,11 +13072,11 @@ async function main() {
11574
13072
  throw new Error("--dry-run is available for project create and run");
11575
13073
  if (action === "run" && values.json && !values["dry-run"])
11576
13074
  throw new Error("Live project run streams native Hermes output. Use --dry-run --json to preview, or project show/project check for saved JSON results");
11577
- const directory = await canonicalPath(resolve5(values.directory ?? defaultProfile()));
13075
+ const directory2 = await canonicalPath(resolve8(values.directory ?? defaultProfile()));
11578
13076
  if (action === "list") {
11579
13077
  if (values.name !== undefined)
11580
13078
  throw new Error("project list does not accept --name");
11581
- const projects = await listProjects(directory);
13079
+ const projects = await listProjects(directory2);
11582
13080
  return console.log(values.json ? JSON.stringify({ schemaVersion: 1, projects }, null, 2) : projects.length ? projects.map((project) => `${project.name}: ${project.workflow.title}`).join(`
11583
13081
  `) : "No saved projects. Use project create with a workflow and input file.");
11584
13082
  }
@@ -11587,23 +13085,23 @@ async function main() {
11587
13085
  if (action === "create") {
11588
13086
  if (!(values.workflow || values.template) || !values["input-file"])
11589
13087
  throw new Error("project create requires --workflow or --template, and --input-file (a JSON object)");
11590
- const file = Bun.file(resolve5(values["input-file"]));
13088
+ const file = Bun.file(resolve8(values["input-file"]));
11591
13089
  if (file.size > 65536)
11592
13090
  throw new Error("Project input file exceeds 64 KiB");
11593
13091
  const supplied = await file.json();
11594
- const project = await createProject(directory, { name: values.name, workflow: values.template ? selectTemplate(values.template).workflow : values.workflow, inputs: values.template ? templateInputs(values.template, supplied) : supplied, objective: values.objective, dryRun: values["dry-run"] }, parseCatalog(skills_default));
11595
- return console.log(values.json ? JSON.stringify(project, null, 2) : `${values["dry-run"] ? "Would create" : "Saved"} ${project.name} in ${directory}. Preview with project run --name ${project.name} --dry-run.`);
13092
+ const project = await createProject(directory2, { name: values.name, workflow: values.template ? selectTemplate(values.template).workflow : values.workflow, inputs: values.template ? templateInputs(values.template, supplied) : supplied, objective: values.objective, dryRun: values["dry-run"] }, parseCatalog(skills_default));
13093
+ return console.log(values.json ? JSON.stringify(project, null, 2) : `${values["dry-run"] ? "Would create" : "Saved"} ${project.name} in ${directory2}. Preview with project run --name ${project.name} --dry-run.`);
11596
13094
  }
11597
13095
  if (action === "show")
11598
- return console.log(JSON.stringify({ project: await readProject(directory, values.name), runs: await projectRuns(directory, values.name) }, null, 2));
13096
+ return console.log(JSON.stringify({ project: await readProject(directory2, values.name), runs: await projectRuns(directory2, values.name) }, null, 2));
11599
13097
  if (action === "run") {
11600
- const result = await runProject(directory, values.name, { dryRun: values["dry-run"], maxTurns: values["max-turns"] === undefined ? undefined : Number(values["max-turns"]) });
11601
- return console.log(values.json ? JSON.stringify(result, null, 2) : values["dry-run"] ? result.prompt : `${result.run.state}: ${result.path}${result.run.issues?.length ? `
11602
- ${result.run.issues.join(`
13098
+ const result2 = await runProject(directory2, values.name, { dryRun: values["dry-run"], maxTurns: values["max-turns"] === undefined ? undefined : Number(values["max-turns"]) });
13099
+ return console.log(values.json ? JSON.stringify(result2, null, 2) : values["dry-run"] ? result2.prompt : `${result2.run.state}: ${result2.path}${result2.run.issues?.length ? `
13100
+ ${result2.run.issues.join(`
11603
13101
  `)}` : `
11604
13102
  Captured files passed structural and hash checks. Review the findings and unsigned plan.`}`);
11605
13103
  }
11606
- const result = await checkProjectRun(directory, values.name, values["run-id"]);
13104
+ const result = await checkProjectRun(directory2, values.name, values["run-id"]);
11607
13105
  console.log(JSON.stringify(result, null, 2));
11608
13106
  if (result.issues.length)
11609
13107
  process.exitCode = 1;
@@ -11639,48 +13137,48 @@ Captured files passed structural and hash checks. Review the findings and unsign
11639
13137
  if (["onboard", "doctor", "start", "connect", "model", "chatgpt"].includes(command)) {
11640
13138
  if (values.harness && values.harness !== "hermes")
11641
13139
  throw new Error("Boomkin onboarding uses Hermes. Use setup for skill-only compatibility with another harness.");
11642
- const directory = await canonicalPath(resolve5(values.directory ?? defaultProfile()));
13140
+ const directory2 = await canonicalPath(resolve8(values.directory ?? defaultProfile()));
11643
13141
  if (command === "onboard") {
11644
13142
  if (values.pack && values["all-packs"])
11645
13143
  throw new Error("Choose --pack or --all-packs, not both");
11646
13144
  const selected = values.workflow !== undefined ? workflowPacks(values.workflow, parseCatalog(skills_default)) : values["all-packs"] ? parseCatalog(skills_default).packs.map((pack) => pack.id) : values.pack;
11647
13145
  const args = [
11648
13146
  process.execPath,
11649
- fileURLToPath(import.meta.url),
13147
+ fileURLToPath2(import.meta.url),
11650
13148
  "setup",
11651
13149
  "--harness",
11652
13150
  "hermes",
11653
13151
  "--directory",
11654
- directory,
13152
+ directory2,
11655
13153
  ...selected?.flatMap((id) => ["--pack", id]) ?? [],
11656
13154
  ...values["dry-run"] ? ["--dry-run"] : []
11657
13155
  ];
11658
13156
  const child = Bun.spawn(args, { stdin: "inherit", stdout: "inherit", stderr: "inherit" });
11659
13157
  if (await child.exited !== 0)
11660
13158
  throw new Error("Skill setup did not finish. Resolve its reported issue and rerun onboard.");
11661
- console.log(`Hermes home: ${directory}. Native model setup and keyless CoinGecko data; other providers are opt-in.`);
11662
- await prepareHermes(directory, { install: !values["no-install"], dryRun: values["dry-run"], skipModelSetup: values["skip-model-setup"] });
13159
+ console.log(`Hermes home: ${directory2}. Native model setup and keyless CoinGecko data; other providers are opt-in.`);
13160
+ await prepareHermes(directory2, { install: !values["no-install"], dryRun: values["dry-run"], skipModelSetup: values["skip-model-setup"] });
11663
13161
  if (values["dry-run"])
11664
13162
  return;
11665
- console.log(JSON.stringify(await doctor(directory, parseCatalog(skills_default)), null, 2));
13163
+ console.log(JSON.stringify(await doctor(directory2, parseCatalog(skills_default)), null, 2));
11666
13164
  console.log("Onboarding saved. Use doctor --live to check public data, then start to launch Hermes. Complete any listed setup gaps first.");
11667
13165
  return;
11668
13166
  }
11669
13167
  if (values.pack || values["all-packs"] || values["skip-model-setup"] || values["no-install"])
11670
13168
  throw new Error("Pack and installer options are only available for onboard here");
11671
13169
  if (command === "chatgpt")
11672
- return runChatGpt(directory, values.action ?? "status", values["dry-run"]);
13170
+ return runChatGpt(directory2, values.action ?? "status", values["dry-run"]);
11673
13171
  if (command === "doctor")
11674
- return console.log(JSON.stringify(await doctor(directory, parseCatalog(skills_default), values.live), null, 2));
13172
+ return console.log(JSON.stringify(await doctor(directory2, parseCatalog(skills_default), values.live), null, 2));
11675
13173
  if (command === "connect")
11676
- return connectProvider(directory, values.provider ?? "", values["dry-run"], values["key-file"] ? resolve5(values["key-file"]) : undefined);
13174
+ return connectProvider(directory2, values.provider ?? "", values["dry-run"], values["key-file"] ? resolve8(values["key-file"]) : undefined);
11677
13175
  if (values["dry-run"])
11678
- return console.log(`Hermes ${command === "model" ? "setup model" : "chat"} in ${directory}`);
11679
- return runHermes(directory, command === "model" ? ["setup", "model"] : ["chat"]);
13176
+ return console.log(`Hermes ${command === "model" ? "setup model" : "chat"} in ${directory2}`);
13177
+ return runHermes(directory2, command === "model" ? ["setup", "model"] : ["chat"]);
11680
13178
  }
11681
13179
  if (command === "harnesses") {
11682
- for (const [name, h] of Object.entries(harnesses))
11683
- console.log(`${name}
13180
+ for (const [name2, h] of Object.entries(harnesses))
13181
+ console.log(`${name2}
11684
13182
  ${h.setup}
11685
13183
  ${h.docs}
11686
13184
  `);
@@ -11692,14 +13190,14 @@ Captured files passed structural and hash checks. Review the findings and unsign
11692
13190
  throw new Error(`Unknown command: ${command}`);
11693
13191
  if (!values.directory)
11694
13192
  throw new Error("Pass --directory with your harness workspace (Hermes: its HERMES_HOME).");
11695
- const directory = await canonicalPath(resolve5(values.directory));
11696
- const stateDir = join5(directory, ".boomkin");
11697
- const configPath = join5(stateDir, "config.json");
13193
+ const directory = await canonicalPath(resolve8(values.directory));
13194
+ const stateDir = join8(directory, ".boomkin");
13195
+ const configPath = join8(stateDir, "config.json");
11698
13196
  let config;
11699
13197
  if (command === "setup") {
11700
13198
  config = { schemaVersion: 1, harness: parseHarness(values.harness), directory };
11701
13199
  try {
11702
- const existing = parseConfig(JSON.parse(await readFile5(configPath, "utf8")), directory);
13200
+ const existing = parseConfig(JSON.parse(await readFile7(configPath, "utf8")), directory);
11703
13201
  if (existing.harness !== config.harness)
11704
13202
  throw new Error("This directory belongs to another harness. Use a separate workspace.");
11705
13203
  config = existing;
@@ -11708,24 +13206,24 @@ Captured files passed structural and hash checks. Review the findings and unsign
11708
13206
  throw error;
11709
13207
  }
11710
13208
  } else
11711
- config = parseConfig(JSON.parse(await readFile5(configPath, "utf8")), directory);
13209
+ config = parseConfig(JSON.parse(await readFile7(configPath, "utf8")), directory);
11712
13210
  if (values.pack && !["setup", "update"].includes(command))
11713
13211
  throw new Error("--pack is available for setup and update");
11714
13212
  if (values.pack)
11715
13213
  config.packs = values.pack;
11716
13214
  const adapter = harnesses[config.harness];
11717
- const env = { ...process.env, DISABLE_TELEMETRY: "1", XDG_STATE_HOME: join5(stateDir, "state"), ...config.harness === "hermes" ? { HERMES_HOME: directory } : {} };
11718
- const skillsBin = fileURLToPath(import.meta.resolve("skills/bin/cli.mjs"));
13215
+ const env = { ...process.env, DISABLE_TELEMETRY: "1", XDG_STATE_HOME: join8(stateDir, "state"), ...config.harness === "hermes" ? { HERMES_HOME: directory } : {} };
13216
+ const skillsBin = fileURLToPath2(import.meta.resolve("skills/bin/cli.mjs"));
11719
13217
  async function run(args) {
11720
13218
  const child = Bun.spawn([process.execPath, skillsBin, ...args], { cwd: directory, env, stdin: "inherit", stdout: "inherit", stderr: "inherit" });
11721
13219
  if (await child.exited !== 0)
11722
13220
  throw new Error("Upstream skills command failed. Completed packs remain installed; rerun after resolving the error.");
11723
13221
  }
11724
- async function verifyInstalled(catalog) {
11725
- for (const pack of catalog.packs) {
13222
+ async function verifyInstalled(catalog2) {
13223
+ for (const pack of catalog2.packs) {
11726
13224
  for (const skill of pack.skills) {
11727
- const text = await readFile5(join5(directory, adapter.skillsPath, skill, "SKILL.md"), "utf8");
11728
- const version = installedVersion(text);
13225
+ const text2 = await readFile7(join8(directory, adapter.skillsPath, skill, "SKILL.md"), "utf8");
13226
+ const version = installedVersion(text2);
11729
13227
  if (version !== pack.version)
11730
13228
  throw new Error(`Installed ${skill} has version ${version ?? "unknown"}; expected ${pack.version}. Sync not marked complete.`);
11731
13229
  }
@@ -11733,15 +13231,15 @@ Captured files passed structural and hash checks. Review the findings and unsign
11733
13231
  }
11734
13232
  if (command === "status") {
11735
13233
  console.log(JSON.stringify(config, null, 2));
11736
- console.log(`Skills: ${join5(directory, adapter.skillsPath)}
13234
+ console.log(`Skills: ${join8(directory, adapter.skillsPath)}
11737
13235
  ${adapter.setup}`);
11738
13236
  return run(["list", "--agent", adapter.agent, ...adapter.global ? ["--global"] : []]);
11739
13237
  }
11740
13238
  let previous;
11741
13239
  try {
11742
- const record = JSON.parse(await readFile5(join5(stateDir, "last-sync.json"), "utf8"));
11743
- if (record.catalog?.schemaVersion === 3)
11744
- previous = parseCatalog(record.catalog);
13240
+ const record2 = JSON.parse(await readFile7(join8(stateDir, "last-sync.json"), "utf8"));
13241
+ if (record2.catalog?.schemaVersion === 3)
13242
+ previous = parseCatalog(record2.catalog);
11745
13243
  } catch (error) {
11746
13244
  if (error.code !== "ENOENT" && command === "check")
11747
13245
  throw new Error("Sync record is incomplete; run update to rebuild it.");
@@ -11751,7 +13249,7 @@ ${adapter.setup}`);
11751
13249
  if (command === "check") {
11752
13250
  const current = selectPacks(values["offline-catalog"] ? parseCatalog(skills_default) : await fetchCatalog(), config.packs);
11753
13251
  const changes = catalogChanges(current, previous);
11754
- const issues = previous ? await verifyIntegrity(join5(directory, adapter.skillsPath), previous, await readIntegrity(directory)) : [];
13252
+ const issues = previous ? await verifyIntegrity(join8(directory, adapter.skillsPath), previous, await readIntegrity(directory)) : [];
11755
13253
  if (!changes.length && previous)
11756
13254
  await verifyInstalled(current);
11757
13255
  if (changes.length)
@@ -11776,27 +13274,27 @@ ${adapter.setup}`);
11776
13274
  console.log(`Install ${pack.source}/${pack.path}@${pack.version} from verified commit ${pack.revision}`);
11777
13275
  if (values["dry-run"])
11778
13276
  return;
11779
- await mkdir3(directory, { recursive: true });
11780
- await mkdir3(stateDir, { recursive: true });
11781
- const lock = join5(stateDir, "operation.lock");
13277
+ await mkdir4(directory, { recursive: true });
13278
+ await mkdir4(stateDir, { recursive: true });
13279
+ const lock = join8(stateDir, "operation.lock");
11782
13280
  try {
11783
- await mkdir3(lock);
13281
+ await mkdir4(lock);
11784
13282
  } catch {
11785
13283
  throw new Error(`Another operation is active. If it crashed, remove ${lock} after checking no installer is running.`);
11786
13284
  }
11787
13285
  try {
11788
13286
  try {
11789
- const existing = parseConfig(JSON.parse(await readFile5(configPath, "utf8")), directory);
13287
+ const existing = parseConfig(JSON.parse(await readFile7(configPath, "utf8")), directory);
11790
13288
  if (existing.harness !== config.harness)
11791
13289
  throw new Error("This directory belongs to another harness. Use a separate workspace.");
11792
13290
  } catch (error) {
11793
13291
  if (error.code !== "ENOENT")
11794
13292
  throw error;
11795
13293
  }
11796
- await writeFile3(`${configPath}.tmp`, JSON.stringify(config, null, 2) + `
13294
+ await writeFile4(`${configPath}.tmp`, JSON.stringify(config, null, 2) + `
11797
13295
  `);
11798
- await rename3(`${configPath}.tmp`, configPath);
11799
- const staging = await mkdtemp(join5(tmpdir(), "boomkin-sources-"));
13296
+ await rename4(`${configPath}.tmp`, configPath);
13297
+ const staging = await mkdtemp(join8(tmpdir(), "boomkin-sources-"));
11800
13298
  const integrity = {};
11801
13299
  try {
11802
13300
  const sources = new Map;
@@ -11805,7 +13303,7 @@ ${adapter.setup}`);
11805
13303
  const key = `${pack.source}@${pack.revision}`;
11806
13304
  let checkout = sources.get(key);
11807
13305
  if (!checkout) {
11808
- checkout = join5(staging, `source-${sources.size}`);
13306
+ checkout = join8(staging, `source-${sources.size}`);
11809
13307
  await checkoutPack(pack, checkout);
11810
13308
  sources.set(key, checkout);
11811
13309
  }
@@ -11814,32 +13312,32 @@ ${adapter.setup}`);
11814
13312
  for (const pack of catalog.packs) {
11815
13313
  await run(installArgs(packages.get(pack.id), config.harness, pack.skills));
11816
13314
  for (const skill of pack.skills)
11817
- integrity[skill] = await verifyCopiedSkill(join5(packages.get(pack.id), "skills", skill), join5(directory, adapter.skillsPath, skill));
13315
+ integrity[skill] = await verifyCopiedSkill(join8(packages.get(pack.id), "skills", skill), join8(directory, adapter.skillsPath, skill));
11818
13316
  }
11819
13317
  } finally {
11820
- await rm3(staging, { recursive: true, force: true });
13318
+ await rm4(staging, { recursive: true, force: true });
11821
13319
  }
11822
13320
  await verifyInstalled(catalog);
11823
13321
  for (const retired of ["lp-research", "lp-operate", "hyperliquid-research", "hyperliquid-operate"]) {
11824
- if (await Bun.file(join5(directory, adapter.skillsPath, retired, "SKILL.md")).exists())
13322
+ if (await Bun.file(join8(directory, adapter.skillsPath, retired, "SKILL.md")).exists())
11825
13323
  console.log(`Legacy skill ${retired} remains. Review local edits and follow docs/UPDATES.md before removing it.`);
11826
13324
  }
11827
- const identityPath = join5(directory, config.harness === "eve" ? "agent/instructions.md" : "AGENTS.md");
11828
- await mkdir3(dirname2(identityPath), { recursive: true });
13325
+ const identityPath = join8(directory, config.harness === "eve" ? "agent/instructions.md" : "AGENTS.md");
13326
+ await mkdir4(dirname2(identityPath), { recursive: true });
11829
13327
  try {
11830
- await writeFile3(identityPath, identity2, { flag: "wx" });
13328
+ await writeFile4(identityPath, identity2, { flag: "wx" });
11831
13329
  } catch (error) {
11832
13330
  if (error.code !== "EEXIST")
11833
13331
  throw error;
11834
13332
  console.log(`Preserved ${identityPath}. Add the Boomkin identity from docs/IDENTITY.md if wanted.`);
11835
13333
  }
11836
- await writeFile3(join5(stateDir, "last-sync.json.tmp"), JSON.stringify({ syncedAt: new Date().toISOString(), catalog, integrity }, null, 2) + `
13334
+ await writeFile4(join8(stateDir, "last-sync.json.tmp"), JSON.stringify({ syncedAt: new Date().toISOString(), catalog, integrity }, null, 2) + `
11837
13335
  `);
11838
- await rename3(join5(stateDir, "last-sync.json.tmp"), join5(stateDir, "last-sync.json"));
11839
- console.log(`Skills ready in ${join5(directory, adapter.skillsPath)}. Use the installed skill matching your task; infrastructure and data skills establish tool readiness and evidence first. Restart the harness to reload.${setupHint ? `
13336
+ await rename4(join8(stateDir, "last-sync.json.tmp"), join8(stateDir, "last-sync.json"));
13337
+ console.log(`Skills ready in ${join8(directory, adapter.skillsPath)}. Use the installed skill matching your task; infrastructure and data skills establish tool readiness and evidence first. Restart the harness to reload.${setupHint ? `
11840
13338
  ${setupHint}` : ""}`);
11841
13339
  } finally {
11842
- await rm3(lock, { recursive: true });
13340
+ await rm4(lock, { recursive: true });
11843
13341
  }
11844
13342
  }
11845
13343
  main().catch((error) => {