@stamn/stamn-plugin 0.1.0-alpha.33 → 0.1.0-alpha.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,11 +4,11 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
7
+ var __require = /* @__PURE__ */ ((x3) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x3, {
8
8
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x2)(function(x2) {
9
+ }) : x3)(function(x3) {
10
10
  if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x2 + '" is not supported');
11
+ throw Error('Dynamic require of "' + x3 + '" is not supported');
12
12
  });
13
13
  var __commonJS = (cb, mod) => function __require2() {
14
14
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -38,14 +38,14 @@ var require_src = __commonJS({
38
38
  var CSI = `${ESC}[`;
39
39
  var beep = "\x07";
40
40
  var cursor = {
41
- to(x2, y2) {
42
- if (!y2) return `${CSI}${x2 + 1}G`;
43
- return `${CSI}${y2 + 1};${x2 + 1}H`;
41
+ to(x3, y2) {
42
+ if (!y2) return `${CSI}${x3 + 1}G`;
43
+ return `${CSI}${y2 + 1};${x3 + 1}H`;
44
44
  },
45
- move(x2, y2) {
45
+ move(x3, y2) {
46
46
  let ret = "";
47
- if (x2 < 0) ret += `${CSI}${-x2}D`;
48
- else if (x2 > 0) ret += `${CSI}${x2}C`;
47
+ if (x3 < 0) ret += `${CSI}${-x3}D`;
48
+ else if (x3 > 0) ret += `${CSI}${x3}C`;
49
49
  if (y2 < 0) ret += `${CSI}${-y2}A`;
50
50
  else if (y2 > 0) ret += `${CSI}${y2}B`;
51
51
  return ret;
@@ -3712,6 +3712,11 @@ import { stdout as R, stdin as q } from "process";
3712
3712
  import * as k from "readline";
3713
3713
  import ot from "readline";
3714
3714
  import { ReadStream as J } from "tty";
3715
+ function x(t2, e, s) {
3716
+ if (!s.some((u) => !u.disabled)) return t2;
3717
+ const i = t2 + e, r = Math.max(s.length - 1, 0), n = i < 0 ? r : i > r ? 0 : i;
3718
+ return s[n].disabled ? x(n, e < 0 ? -1 : 1, s) : n;
3719
+ }
3715
3720
  var at = (t2) => t2 === 161 || t2 === 164 || t2 === 167 || t2 === 168 || t2 === 170 || t2 === 173 || t2 === 174 || t2 >= 176 && t2 <= 180 || t2 >= 182 && t2 <= 186 || t2 >= 188 && t2 <= 191 || t2 === 198 || t2 === 208 || t2 === 215 || t2 === 216 || t2 >= 222 && t2 <= 225 || t2 === 230 || t2 >= 232 && t2 <= 234 || t2 === 236 || t2 === 237 || t2 === 240 || t2 === 242 || t2 === 243 || t2 >= 247 && t2 <= 250 || t2 === 252 || t2 === 254 || t2 === 257 || t2 === 273 || t2 === 275 || t2 === 283 || t2 === 294 || t2 === 295 || t2 === 299 || t2 >= 305 && t2 <= 307 || t2 === 312 || t2 >= 319 && t2 <= 322 || t2 === 324 || t2 >= 328 && t2 <= 331 || t2 === 333 || t2 === 338 || t2 === 339 || t2 === 358 || t2 === 359 || t2 === 363 || t2 === 462 || t2 === 464 || t2 === 466 || t2 === 468 || t2 === 470 || t2 === 472 || t2 === 474 || t2 === 476 || t2 === 593 || t2 === 609 || t2 === 708 || t2 === 711 || t2 >= 713 && t2 <= 715 || t2 === 717 || t2 === 720 || t2 >= 728 && t2 <= 731 || t2 === 733 || t2 === 735 || t2 >= 768 && t2 <= 879 || t2 >= 913 && t2 <= 929 || t2 >= 931 && t2 <= 937 || t2 >= 945 && t2 <= 961 || t2 >= 963 && t2 <= 969 || t2 === 1025 || t2 >= 1040 && t2 <= 1103 || t2 === 1105 || t2 === 8208 || t2 >= 8211 && t2 <= 8214 || t2 === 8216 || t2 === 8217 || t2 === 8220 || t2 === 8221 || t2 >= 8224 && t2 <= 8226 || t2 >= 8228 && t2 <= 8231 || t2 === 8240 || t2 === 8242 || t2 === 8243 || t2 === 8245 || t2 === 8251 || t2 === 8254 || t2 === 8308 || t2 === 8319 || t2 >= 8321 && t2 <= 8324 || t2 === 8364 || t2 === 8451 || t2 === 8453 || t2 === 8457 || t2 === 8467 || t2 === 8470 || t2 === 8481 || t2 === 8482 || t2 === 8486 || t2 === 8491 || t2 === 8531 || t2 === 8532 || t2 >= 8539 && t2 <= 8542 || t2 >= 8544 && t2 <= 8555 || t2 >= 8560 && t2 <= 8569 || t2 === 8585 || t2 >= 8592 && t2 <= 8601 || t2 === 8632 || t2 === 8633 || t2 === 8658 || t2 === 8660 || t2 === 8679 || t2 === 8704 || t2 === 8706 || t2 === 8707 || t2 === 8711 || t2 === 8712 || t2 === 8715 || t2 === 8719 || t2 === 8721 || t2 === 8725 || t2 === 8730 || t2 >= 8733 && t2 <= 8736 || t2 === 8739 || t2 === 8741 || t2 >= 8743 && t2 <= 8748 || t2 === 8750 || t2 >= 8756 && t2 <= 8759 || t2 === 8764 || t2 === 8765 || t2 === 8776 || t2 === 8780 || t2 === 8786 || t2 === 8800 || t2 === 8801 || t2 >= 8804 && t2 <= 8807 || t2 === 8810 || t2 === 8811 || t2 === 8814 || t2 === 8815 || t2 === 8834 || t2 === 8835 || t2 === 8838 || t2 === 8839 || t2 === 8853 || t2 === 8857 || t2 === 8869 || t2 === 8895 || t2 === 8978 || t2 >= 9312 && t2 <= 9449 || t2 >= 9451 && t2 <= 9547 || t2 >= 9552 && t2 <= 9587 || t2 >= 9600 && t2 <= 9615 || t2 >= 9618 && t2 <= 9621 || t2 === 9632 || t2 === 9633 || t2 >= 9635 && t2 <= 9641 || t2 === 9650 || t2 === 9651 || t2 === 9654 || t2 === 9655 || t2 === 9660 || t2 === 9661 || t2 === 9664 || t2 === 9665 || t2 >= 9670 && t2 <= 9672 || t2 === 9675 || t2 >= 9678 && t2 <= 9681 || t2 >= 9698 && t2 <= 9701 || t2 === 9711 || t2 === 9733 || t2 === 9734 || t2 === 9737 || t2 === 9742 || t2 === 9743 || t2 === 9756 || t2 === 9758 || t2 === 9792 || t2 === 9794 || t2 === 9824 || t2 === 9825 || t2 >= 9827 && t2 <= 9829 || t2 >= 9831 && t2 <= 9834 || t2 === 9836 || t2 === 9837 || t2 === 9839 || t2 === 9886 || t2 === 9887 || t2 === 9919 || t2 >= 9926 && t2 <= 9933 || t2 >= 9935 && t2 <= 9939 || t2 >= 9941 && t2 <= 9953 || t2 === 9955 || t2 === 9960 || t2 === 9961 || t2 >= 9963 && t2 <= 9969 || t2 === 9972 || t2 >= 9974 && t2 <= 9977 || t2 === 9979 || t2 === 9980 || t2 === 9982 || t2 === 9983 || t2 === 10045 || t2 >= 10102 && t2 <= 10111 || t2 >= 11094 && t2 <= 11097 || t2 >= 12872 && t2 <= 12879 || t2 >= 57344 && t2 <= 63743 || t2 >= 65024 && t2 <= 65039 || t2 === 65533 || t2 >= 127232 && t2 <= 127242 || t2 >= 127248 && t2 <= 127277 || t2 >= 127280 && t2 <= 127337 || t2 >= 127344 && t2 <= 127373 || t2 === 127375 || t2 === 127376 || t2 >= 127387 && t2 <= 127404 || t2 >= 917760 && t2 <= 917999 || t2 >= 983040 && t2 <= 1048573 || t2 >= 1048576 && t2 <= 1114109;
3716
3721
  var lt = (t2) => t2 === 12288 || t2 >= 65281 && t2 <= 65376 || t2 >= 65504 && t2 <= 65510;
3717
3722
  var ht = (t2) => t2 >= 4352 && t2 <= 4447 || t2 === 8986 || t2 === 8987 || t2 === 9001 || t2 === 9002 || t2 >= 9193 && t2 <= 9196 || t2 === 9200 || t2 === 9203 || t2 === 9725 || t2 === 9726 || t2 === 9748 || t2 === 9749 || t2 >= 9800 && t2 <= 9811 || t2 === 9855 || t2 === 9875 || t2 === 9889 || t2 === 9898 || t2 === 9899 || t2 === 9917 || t2 === 9918 || t2 === 9924 || t2 === 9925 || t2 === 9934 || t2 === 9940 || t2 === 9962 || t2 === 9970 || t2 === 9971 || t2 === 9973 || t2 === 9978 || t2 === 9981 || t2 === 9989 || t2 === 9994 || t2 === 9995 || t2 === 10024 || t2 === 10060 || t2 === 10062 || t2 >= 10067 && t2 <= 10069 || t2 === 10071 || t2 >= 10133 && t2 <= 10135 || t2 === 10160 || t2 === 10175 || t2 === 11035 || t2 === 11036 || t2 === 11088 || t2 === 11093 || t2 >= 11904 && t2 <= 11929 || t2 >= 11931 && t2 <= 12019 || t2 >= 12032 && t2 <= 12245 || t2 >= 12272 && t2 <= 12287 || t2 >= 12289 && t2 <= 12350 || t2 >= 12353 && t2 <= 12438 || t2 >= 12441 && t2 <= 12543 || t2 >= 12549 && t2 <= 12591 || t2 >= 12593 && t2 <= 12686 || t2 >= 12688 && t2 <= 12771 || t2 >= 12783 && t2 <= 12830 || t2 >= 12832 && t2 <= 12871 || t2 >= 12880 && t2 <= 19903 || t2 >= 19968 && t2 <= 42124 || t2 >= 42128 && t2 <= 42182 || t2 >= 43360 && t2 <= 43388 || t2 >= 44032 && t2 <= 55203 || t2 >= 63744 && t2 <= 64255 || t2 >= 65040 && t2 <= 65049 || t2 >= 65072 && t2 <= 65106 || t2 >= 65108 && t2 <= 65126 || t2 >= 65128 && t2 <= 65131 || t2 >= 94176 && t2 <= 94180 || t2 === 94192 || t2 === 94193 || t2 >= 94208 && t2 <= 100343 || t2 >= 100352 && t2 <= 101589 || t2 >= 101632 && t2 <= 101640 || t2 >= 110576 && t2 <= 110579 || t2 >= 110581 && t2 <= 110587 || t2 === 110589 || t2 === 110590 || t2 >= 110592 && t2 <= 110882 || t2 === 110898 || t2 >= 110928 && t2 <= 110930 || t2 === 110933 || t2 >= 110948 && t2 <= 110951 || t2 >= 110960 && t2 <= 111355 || t2 === 126980 || t2 === 127183 || t2 === 127374 || t2 >= 127377 && t2 <= 127386 || t2 >= 127488 && t2 <= 127490 || t2 >= 127504 && t2 <= 127547 || t2 >= 127552 && t2 <= 127560 || t2 === 127568 || t2 === 127569 || t2 >= 127584 && t2 <= 127589 || t2 >= 127744 && t2 <= 127776 || t2 >= 127789 && t2 <= 127797 || t2 >= 127799 && t2 <= 127868 || t2 >= 127870 && t2 <= 127891 || t2 >= 127904 && t2 <= 127946 || t2 >= 127951 && t2 <= 127955 || t2 >= 127968 && t2 <= 127984 || t2 === 127988 || t2 >= 127992 && t2 <= 128062 || t2 === 128064 || t2 >= 128066 && t2 <= 128252 || t2 >= 128255 && t2 <= 128317 || t2 >= 128331 && t2 <= 128334 || t2 >= 128336 && t2 <= 128359 || t2 === 128378 || t2 === 128405 || t2 === 128406 || t2 === 128420 || t2 >= 128507 && t2 <= 128591 || t2 >= 128640 && t2 <= 128709 || t2 === 128716 || t2 >= 128720 && t2 <= 128722 || t2 >= 128725 && t2 <= 128727 || t2 >= 128732 && t2 <= 128735 || t2 === 128747 || t2 === 128748 || t2 >= 128756 && t2 <= 128764 || t2 >= 128992 && t2 <= 129003 || t2 === 129008 || t2 >= 129292 && t2 <= 129338 || t2 >= 129340 && t2 <= 129349 || t2 >= 129351 && t2 <= 129535 || t2 >= 129648 && t2 <= 129660 || t2 >= 129664 && t2 <= 129672 || t2 >= 129680 && t2 <= 129725 || t2 >= 129727 && t2 <= 129733 || t2 >= 129742 && t2 <= 129755 || t2 >= 129760 && t2 <= 129768 || t2 >= 129776 && t2 <= 129784 || t2 >= 131072 && t2 <= 196605 || t2 >= 196608 && t2 <= 262141;
@@ -3922,6 +3927,12 @@ function xt({ input: t2 = q, output: e = R, overwrite: s = true, hideCursor: i =
3922
3927
  }
3923
3928
  var rt = (t2) => "columns" in t2 && typeof t2.columns == "number" ? t2.columns : 80;
3924
3929
  var nt = (t2) => "rows" in t2 && typeof t2.rows == "number" ? t2.rows : 20;
3930
+ function Bt(t2, e, s, i = s) {
3931
+ const r = rt(t2 ?? R);
3932
+ return K(e, r - s.length, { hard: true, trim: false }).split(`
3933
+ `).map((n, u) => `${u === 0 ? i : s}${n}`).join(`
3934
+ `);
3935
+ }
3925
3936
  var B = class {
3926
3937
  input;
3927
3938
  output;
@@ -4061,6 +4072,33 @@ var kt = class extends B {
4061
4072
  });
4062
4073
  }
4063
4074
  };
4075
+ var Tt = class extends B {
4076
+ options;
4077
+ cursor = 0;
4078
+ get _selectedValue() {
4079
+ return this.options[this.cursor];
4080
+ }
4081
+ changeValue() {
4082
+ this.value = this._selectedValue.value;
4083
+ }
4084
+ constructor(e) {
4085
+ super(e, false), this.options = e.options;
4086
+ const s = this.options.findIndex(({ value: r }) => r === e.initialValue), i = s === -1 ? 0 : s;
4087
+ this.cursor = this.options[i].disabled ? x(i, 1, this.options) : i, this.changeValue(), this.on("cursor", (r) => {
4088
+ switch (r) {
4089
+ case "left":
4090
+ case "up":
4091
+ this.cursor = x(this.cursor, -1, this.options);
4092
+ break;
4093
+ case "down":
4094
+ case "right":
4095
+ this.cursor = x(this.cursor, 1, this.options);
4096
+ break;
4097
+ }
4098
+ this.changeValue();
4099
+ });
4100
+ }
4101
+ };
4064
4102
  var $t = class extends B {
4065
4103
  get userInputWithCursor() {
4066
4104
  if (this.state === "submit") return this.userInput;
@@ -4099,7 +4137,7 @@ var de = I2("\u25B2", "x");
4099
4137
  var V = I2("\u25C7", "o");
4100
4138
  var he = I2("\u250C", "T");
4101
4139
  var h = I2("\u2502", "|");
4102
- var x = I2("\u2514", "\u2014");
4140
+ var x2 = I2("\u2514", "\u2014");
4103
4141
  var Oe = I2("\u2510", "T");
4104
4142
  var Pe = I2("\u2518", "\u2014");
4105
4143
  var z2 = I2("\u25CF", ">");
@@ -4131,6 +4169,19 @@ var W2 = (e) => {
4131
4169
  return t("green", V);
4132
4170
  }
4133
4171
  };
4172
+ var ve = (e) => {
4173
+ switch (e) {
4174
+ case "initial":
4175
+ case "active":
4176
+ return t("cyan", h);
4177
+ case "cancel":
4178
+ return t("red", h);
4179
+ case "error":
4180
+ return t("yellow", h);
4181
+ case "submit":
4182
+ return t("green", h);
4183
+ }
4184
+ };
4134
4185
  var mt2 = (e) => e === 161 || e === 164 || e === 167 || e === 168 || e === 170 || e === 173 || e === 174 || e >= 176 && e <= 180 || e >= 182 && e <= 186 || e >= 188 && e <= 191 || e === 198 || e === 208 || e === 215 || e === 216 || e >= 222 && e <= 225 || e === 230 || e >= 232 && e <= 234 || e === 236 || e === 237 || e === 240 || e === 242 || e === 243 || e >= 247 && e <= 250 || e === 252 || e === 254 || e === 257 || e === 273 || e === 275 || e === 283 || e === 294 || e === 295 || e === 299 || e >= 305 && e <= 307 || e === 312 || e >= 319 && e <= 322 || e === 324 || e >= 328 && e <= 331 || e === 333 || e === 338 || e === 339 || e === 358 || e === 359 || e === 363 || e === 462 || e === 464 || e === 466 || e === 468 || e === 470 || e === 472 || e === 474 || e === 476 || e === 593 || e === 609 || e === 708 || e === 711 || e >= 713 && e <= 715 || e === 717 || e === 720 || e >= 728 && e <= 731 || e === 733 || e === 735 || e >= 768 && e <= 879 || e >= 913 && e <= 929 || e >= 931 && e <= 937 || e >= 945 && e <= 961 || e >= 963 && e <= 969 || e === 1025 || e >= 1040 && e <= 1103 || e === 1105 || e === 8208 || e >= 8211 && e <= 8214 || e === 8216 || e === 8217 || e === 8220 || e === 8221 || e >= 8224 && e <= 8226 || e >= 8228 && e <= 8231 || e === 8240 || e === 8242 || e === 8243 || e === 8245 || e === 8251 || e === 8254 || e === 8308 || e === 8319 || e >= 8321 && e <= 8324 || e === 8364 || e === 8451 || e === 8453 || e === 8457 || e === 8467 || e === 8470 || e === 8481 || e === 8482 || e === 8486 || e === 8491 || e === 8531 || e === 8532 || e >= 8539 && e <= 8542 || e >= 8544 && e <= 8555 || e >= 8560 && e <= 8569 || e === 8585 || e >= 8592 && e <= 8601 || e === 8632 || e === 8633 || e === 8658 || e === 8660 || e === 8679 || e === 8704 || e === 8706 || e === 8707 || e === 8711 || e === 8712 || e === 8715 || e === 8719 || e === 8721 || e === 8725 || e === 8730 || e >= 8733 && e <= 8736 || e === 8739 || e === 8741 || e >= 8743 && e <= 8748 || e === 8750 || e >= 8756 && e <= 8759 || e === 8764 || e === 8765 || e === 8776 || e === 8780 || e === 8786 || e === 8800 || e === 8801 || e >= 8804 && e <= 8807 || e === 8810 || e === 8811 || e === 8814 || e === 8815 || e === 8834 || e === 8835 || e === 8838 || e === 8839 || e === 8853 || e === 8857 || e === 8869 || e === 8895 || e === 8978 || e >= 9312 && e <= 9449 || e >= 9451 && e <= 9547 || e >= 9552 && e <= 9587 || e >= 9600 && e <= 9615 || e >= 9618 && e <= 9621 || e === 9632 || e === 9633 || e >= 9635 && e <= 9641 || e === 9650 || e === 9651 || e === 9654 || e === 9655 || e === 9660 || e === 9661 || e === 9664 || e === 9665 || e >= 9670 && e <= 9672 || e === 9675 || e >= 9678 && e <= 9681 || e >= 9698 && e <= 9701 || e === 9711 || e === 9733 || e === 9734 || e === 9737 || e === 9742 || e === 9743 || e === 9756 || e === 9758 || e === 9792 || e === 9794 || e === 9824 || e === 9825 || e >= 9827 && e <= 9829 || e >= 9831 && e <= 9834 || e === 9836 || e === 9837 || e === 9839 || e === 9886 || e === 9887 || e === 9919 || e >= 9926 && e <= 9933 || e >= 9935 && e <= 9939 || e >= 9941 && e <= 9953 || e === 9955 || e === 9960 || e === 9961 || e >= 9963 && e <= 9969 || e === 9972 || e >= 9974 && e <= 9977 || e === 9979 || e === 9980 || e === 9982 || e === 9983 || e === 10045 || e >= 10102 && e <= 10111 || e >= 11094 && e <= 11097 || e >= 12872 && e <= 12879 || e >= 57344 && e <= 63743 || e >= 65024 && e <= 65039 || e === 65533 || e >= 127232 && e <= 127242 || e >= 127248 && e <= 127277 || e >= 127280 && e <= 127337 || e >= 127344 && e <= 127373 || e === 127375 || e === 127376 || e >= 127387 && e <= 127404 || e >= 917760 && e <= 917999 || e >= 983040 && e <= 1048573 || e >= 1048576 && e <= 1114109;
4135
4186
  var gt2 = (e) => e === 12288 || e >= 65281 && e <= 65376 || e >= 65504 && e <= 65510;
4136
4187
  var ft2 = (e) => e >= 4352 && e <= 4447 || e === 8986 || e === 8987 || e === 9001 || e === 9002 || e >= 9193 && e <= 9196 || e === 9200 || e === 9203 || e === 9725 || e === 9726 || e === 9748 || e === 9749 || e >= 9800 && e <= 9811 || e === 9855 || e === 9875 || e === 9889 || e === 9898 || e === 9899 || e === 9917 || e === 9918 || e === 9924 || e === 9925 || e === 9934 || e === 9940 || e === 9962 || e === 9970 || e === 9971 || e === 9973 || e === 9978 || e === 9981 || e === 9989 || e === 9994 || e === 9995 || e === 10024 || e === 10060 || e === 10062 || e >= 10067 && e <= 10069 || e === 10071 || e >= 10133 && e <= 10135 || e === 10160 || e === 10175 || e === 11035 || e === 11036 || e === 11088 || e === 11093 || e >= 11904 && e <= 11929 || e >= 11931 && e <= 12019 || e >= 12032 && e <= 12245 || e >= 12272 && e <= 12287 || e >= 12289 && e <= 12350 || e >= 12353 && e <= 12438 || e >= 12441 && e <= 12543 || e >= 12549 && e <= 12591 || e >= 12593 && e <= 12686 || e >= 12688 && e <= 12771 || e >= 12783 && e <= 12830 || e >= 12832 && e <= 12871 || e >= 12880 && e <= 19903 || e >= 19968 && e <= 42124 || e >= 42128 && e <= 42182 || e >= 43360 && e <= 43388 || e >= 44032 && e <= 55203 || e >= 63744 && e <= 64255 || e >= 65040 && e <= 65049 || e >= 65072 && e <= 65106 || e >= 65108 && e <= 65126 || e >= 65128 && e <= 65131 || e >= 94176 && e <= 94180 || e === 94192 || e === 94193 || e >= 94208 && e <= 100343 || e >= 100352 && e <= 101589 || e >= 101632 && e <= 101640 || e >= 110576 && e <= 110579 || e >= 110581 && e <= 110587 || e === 110589 || e === 110590 || e >= 110592 && e <= 110882 || e === 110898 || e >= 110928 && e <= 110930 || e === 110933 || e >= 110948 && e <= 110951 || e >= 110960 && e <= 111355 || e === 126980 || e === 127183 || e === 127374 || e >= 127377 && e <= 127386 || e >= 127488 && e <= 127490 || e >= 127504 && e <= 127547 || e >= 127552 && e <= 127560 || e === 127568 || e === 127569 || e >= 127584 && e <= 127589 || e >= 127744 && e <= 127776 || e >= 127789 && e <= 127797 || e >= 127799 && e <= 127868 || e >= 127870 && e <= 127891 || e >= 127904 && e <= 127946 || e >= 127951 && e <= 127955 || e >= 127968 && e <= 127984 || e === 127988 || e >= 127992 && e <= 128062 || e === 128064 || e >= 128066 && e <= 128252 || e >= 128255 && e <= 128317 || e >= 128331 && e <= 128334 || e >= 128336 && e <= 128359 || e === 128378 || e === 128405 || e === 128406 || e === 128420 || e >= 128507 && e <= 128591 || e >= 128640 && e <= 128709 || e === 128716 || e >= 128720 && e <= 128722 || e >= 128725 && e <= 128727 || e >= 128732 && e <= 128735 || e === 128747 || e === 128748 || e >= 128756 && e <= 128764 || e >= 128992 && e <= 129003 || e === 129008 || e >= 129292 && e <= 129338 || e >= 129340 && e <= 129349 || e >= 129351 && e <= 129535 || e >= 129648 && e <= 129660 || e >= 129664 && e <= 129672 || e >= 129680 && e <= 129725 || e >= 129727 && e <= 129733 || e >= 129742 && e <= 129755 || e >= 129760 && e <= 129768 || e >= 129776 && e <= 129784 || e >= 131072 && e <= 196605 || e >= 196608 && e <= 262141;
@@ -4297,6 +4348,38 @@ function J2(e, r, s) {
4297
4348
  `).map((i) => It2(i, r, s)).join(`
4298
4349
  `);
4299
4350
  }
4351
+ var bt2 = (e, r, s, i, a) => {
4352
+ let o = r, u = 0;
4353
+ for (let l = s; l < i; l++) {
4354
+ const n = e[l];
4355
+ if (o = o - n.length, u++, o <= a) break;
4356
+ }
4357
+ return { lineCount: o, removals: u };
4358
+ };
4359
+ var X2 = ({ cursor: e, options: r, style: s, output: i = process.stdout, maxItems: a = Number.POSITIVE_INFINITY, columnPadding: o = 0, rowPadding: u = 4 }) => {
4360
+ const l = rt(i) - o, n = nt(i), c = t("dim", "..."), p = Math.max(n - u, 0), f = Math.max(Math.min(a, p), 5);
4361
+ let g = 0;
4362
+ e >= f - 3 && (g = Math.max(Math.min(e - f + 3, r.length - f), 0));
4363
+ let E = f < r.length && g > 0, $ = f < r.length && g + f < r.length;
4364
+ const m = Math.min(g + f, r.length), d = [];
4365
+ let F = 0;
4366
+ E && F++, $ && F++;
4367
+ const y2 = g + (E ? 1 : 0), v = m - ($ ? 1 : 0);
4368
+ for (let A = y2; A < v; A++) {
4369
+ const b = J2(s(r[A], A === e), l, { hard: true, trim: false }).split(`
4370
+ `);
4371
+ d.push(b), F += b.length;
4372
+ }
4373
+ if (F > p) {
4374
+ let A = 0, b = 0, w = F;
4375
+ const S2 = e - y2, T2 = (M2, O2) => bt2(d, w, M2, O2, p);
4376
+ E ? ({ lineCount: w, removals: A } = T2(0, S2), w > p && ({ lineCount: w, removals: b } = T2(S2 + 1, d.length))) : ({ lineCount: w, removals: b } = T2(S2 + 1, d.length), w > p && ({ lineCount: w, removals: A } = T2(0, S2))), A > 0 && (E = true, d.splice(0, A)), b > 0 && ($ = true, d.splice(d.length - b, b));
4377
+ }
4378
+ const C = [];
4379
+ E && C.push(c);
4380
+ for (const A of d) for (const b of A) C.push(b);
4381
+ return $ && C.push(c), C;
4382
+ };
4300
4383
  var Rt = (e) => {
4301
4384
  const r = e.active ?? "Yes", s = e.inactive ?? "No";
4302
4385
  return new kt({ active: r, inactive: s, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue ?? true, render() {
@@ -4314,7 +4397,7 @@ var Rt = (e) => {
4314
4397
  ${t("gray", h)}` : ""}`;
4315
4398
  }
4316
4399
  default: {
4317
- const u = i ? `${t("cyan", h)} ` : "", l = i ? t("cyan", x) : "";
4400
+ const u = i ? `${t("cyan", h)} ` : "", l = i ? t("cyan", x2) : "";
4318
4401
  return `${a}${u}${this.value ? `${t("green", z2)} ${r}` : `${t("dim", H2)} ${t("dim", r)}`}${e.vertical ? i ? `
4319
4402
  ${t("cyan", h)} ` : `
4320
4403
  ` : ` ${t("dim", "/")} `}${this.value ? `${t("dim", H2)} ${t("dim", s)}` : `${t("green", z2)} ${s}`}
@@ -4351,7 +4434,7 @@ var R2 = { message: (e = [], { symbol: r = t("gray", h), secondarySymbol: s = t(
4351
4434
  R2.message(e, { ...r, symbol: t("red", Ee) });
4352
4435
  } };
4353
4436
  var Nt = (e = "", r) => {
4354
- const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", x)} ` : "";
4437
+ const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", x2)} ` : "";
4355
4438
  s.write(`${i}${t("red", e)}
4356
4439
 
4357
4440
  `);
@@ -4363,7 +4446,7 @@ var Wt2 = (e = "", r) => {
4363
4446
  };
4364
4447
  var Gt = (e = "", r) => {
4365
4448
  const s = r?.output ?? process.stdout, i = r?.withGuide ?? _.withGuide ? `${t("gray", h)}
4366
- ${t("gray", x)} ` : "";
4449
+ ${t("gray", x2)} ` : "";
4367
4450
  s.write(`${i}${e}
4368
4451
 
4369
4452
  `);
@@ -4441,6 +4524,51 @@ var be = ({ indicator: e = "dots", onCancel: r, output: s = process.stdout, canc
4441
4524
  } };
4442
4525
  };
4443
4526
  var ze = { light: I2("\u2500", "-"), heavy: I2("\u2501", "="), block: I2("\u2588", "#") };
4527
+ var oe = (e, r) => e.includes(`
4528
+ `) ? e.split(`
4529
+ `).map((s) => r(s)).join(`
4530
+ `) : r(e);
4531
+ var Jt = (e) => {
4532
+ const r = (s, i) => {
4533
+ const a = s.label ?? String(s.value);
4534
+ switch (i) {
4535
+ case "disabled":
4536
+ return `${t("gray", H2)} ${oe(a, (o) => t("gray", o))}${s.hint ? ` ${t("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
4537
+ case "selected":
4538
+ return `${oe(a, (o) => t("dim", o))}`;
4539
+ case "active":
4540
+ return `${t("green", z2)} ${a}${s.hint ? ` ${t("dim", `(${s.hint})`)}` : ""}`;
4541
+ case "cancelled":
4542
+ return `${oe(a, (o) => t(["strikethrough", "dim"], o))}`;
4543
+ default:
4544
+ return `${t("dim", H2)} ${oe(a, (o) => t("dim", o))}`;
4545
+ }
4546
+ };
4547
+ return new Tt({ options: e.options, signal: e.signal, input: e.input, output: e.output, initialValue: e.initialValue, render() {
4548
+ const s = e.withGuide ?? _.withGuide, i = `${W2(this.state)} `, a = `${ve(this.state)} `, o = Bt(e.output, e.message, a, i), u = `${s ? `${t("gray", h)}
4549
+ ` : ""}${o}
4550
+ `;
4551
+ switch (this.state) {
4552
+ case "submit": {
4553
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "selected"), l);
4554
+ return `${u}${n}`;
4555
+ }
4556
+ case "cancel": {
4557
+ const l = s ? `${t("gray", h)} ` : "", n = Bt(e.output, r(this.options[this.cursor], "cancelled"), l);
4558
+ return `${u}${n}${s ? `
4559
+ ${t("gray", h)}` : ""}`;
4560
+ }
4561
+ default: {
4562
+ const l = s ? `${t("cyan", h)} ` : "", n = s ? t("cyan", x2) : "", c = u.split(`
4563
+ `).length, p = s ? 2 : 1;
4564
+ return `${u}${l}${X2({ output: e.output, cursor: this.cursor, options: this.options, maxItems: e.maxItems, columnPadding: l.length, rowPadding: c + p, style: (f, g) => r(f, f.disabled ? "disabled" : g ? "active" : "inactive") }).join(`
4565
+ ${l}`)}
4566
+ ${n}
4567
+ `;
4568
+ }
4569
+ }
4570
+ } }).prompt();
4571
+ };
4444
4572
  var Qe = `${t("gray", h)} `;
4445
4573
  var Zt = (e) => new $t({ validate: e.validate, placeholder: e.placeholder, defaultValue: e.defaultValue, initialValue: e.initialValue, output: e.output, signal: e.signal, input: e.input, render() {
4446
4574
  const r = e?.withGuide ?? _.withGuide, s = `${`${r ? `${t("gray", h)}
@@ -4448,7 +4576,7 @@ var Zt = (e) => new $t({ validate: e.validate, placeholder: e.placeholder, defau
4448
4576
  `, i = e.placeholder ? t("inverse", e.placeholder[0]) + t("dim", e.placeholder.slice(1)) : t(["inverse", "hidden"], "_"), a = this.userInput ? this.userInputWithCursor : i, o = this.value ?? "";
4449
4577
  switch (this.state) {
4450
4578
  case "error": {
4451
- const u = this.error ? ` ${t("yellow", this.error)}` : "", l = r ? `${t("yellow", h)} ` : "", n = r ? t("yellow", x) : "";
4579
+ const u = this.error ? ` ${t("yellow", this.error)}` : "", l = r ? `${t("yellow", h)} ` : "", n = r ? t("yellow", x2) : "";
4452
4580
  return `${s.trim()}
4453
4581
  ${l}${a}
4454
4582
  ${n}${u}
@@ -4464,7 +4592,7 @@ ${n}${u}
4464
4592
  ${l}` : ""}`;
4465
4593
  }
4466
4594
  default: {
4467
- const u = r ? `${t("cyan", h)} ` : "", l = r ? t("cyan", x) : "";
4595
+ const u = r ? `${t("cyan", h)} ` : "", l = r ? t("cyan", x2) : "";
4468
4596
  return `${s}${u}${a}
4469
4597
  ${l}
4470
4598
  `;
@@ -4472,7 +4600,7 @@ ${l}
4472
4600
  }
4473
4601
  } }).prompt();
4474
4602
 
4475
- // node_modules/.pnpm/@stamn+sdk@0.1.0-alpha.2/node_modules/@stamn/sdk/dist/index.js
4603
+ // node_modules/.pnpm/@stamn+sdk@0.1.0-alpha.3/node_modules/@stamn/sdk/dist/index.js
4476
4604
  var Resource = class {
4477
4605
  constructor(client) {
4478
4606
  this.client = client;
@@ -4676,6 +4804,42 @@ var ServicesResource = class extends Resource {
4676
4804
  );
4677
4805
  }
4678
4806
  };
4807
+ var RuntimeResource = class extends Resource {
4808
+ async listHosts() {
4809
+ const res = await this.client.request(
4810
+ "GET",
4811
+ "/v1/runtime/hosts"
4812
+ );
4813
+ return res.data;
4814
+ }
4815
+ async listFiles(scope, hostname2) {
4816
+ const params = new URLSearchParams({ scope });
4817
+ if (hostname2) params.set("hostname", hostname2);
4818
+ const res = await this.client.request("GET", `/v1/runtime/files?${params}`);
4819
+ return res.data.files;
4820
+ }
4821
+ async readFile(scope, path, hostname2) {
4822
+ const params = new URLSearchParams({ scope, path });
4823
+ if (hostname2) params.set("hostname", hostname2);
4824
+ const res = await this.client.request("GET", `/v1/runtime/files/read?${params}`);
4825
+ return res.data;
4826
+ }
4827
+ async writeFile(scope, path, content, hostname2) {
4828
+ const res = await this.client.request("PATCH", "/v1/runtime/files/write", { scope, path, content, hostname: hostname2 });
4829
+ return res.data;
4830
+ }
4831
+ async readConfig(hostname2) {
4832
+ const params = new URLSearchParams();
4833
+ if (hostname2) params.set("hostname", hostname2);
4834
+ const qs = params.toString();
4835
+ const res = await this.client.request("GET", `/v1/runtime/config${qs ? `?${qs}` : ""}`);
4836
+ return res.data;
4837
+ }
4838
+ async writeConfig(content, hostname2) {
4839
+ const res = await this.client.request("PATCH", "/v1/runtime/config", { content, hostname: hostname2 });
4840
+ return res.data;
4841
+ }
4842
+ };
4679
4843
  var StamnApiError = class extends Error {
4680
4844
  constructor(message, status) {
4681
4845
  super(message);
@@ -4702,6 +4866,7 @@ var StamnClient = class {
4702
4866
  leaderboard;
4703
4867
  health;
4704
4868
  services;
4869
+ runtime;
4705
4870
  constructor(options = {}) {
4706
4871
  this.apiKey = options.apiKey;
4707
4872
  this.retryOptions = { ...DEFAULT_RETRY, ...options.retry };
@@ -4713,6 +4878,7 @@ var StamnClient = class {
4713
4878
  this.leaderboard = new LeaderboardResource(this);
4714
4879
  this.health = new HealthResource(this);
4715
4880
  this.services = new ServicesResource(this);
4881
+ this.runtime = new RuntimeResource(this);
4716
4882
  }
4717
4883
  setApiKey(apiKey) {
4718
4884
  this.apiKey = apiKey;
@@ -4767,7 +4933,7 @@ var StamnClient = class {
4767
4933
  return Math.random() * capped;
4768
4934
  }
4769
4935
  sleep(ms) {
4770
- return new Promise((resolve2) => setTimeout(resolve2, ms));
4936
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
4771
4937
  }
4772
4938
  async parseErrorResponse(res) {
4773
4939
  const body = await res.text();
@@ -4781,7 +4947,7 @@ var StamnClient = class {
4781
4947
  }
4782
4948
  };
4783
4949
 
4784
- // node_modules/.pnpm/@stamn+cli@0.1.0-alpha.7/node_modules/@stamn/cli/dist/chunk-Z2IAJQOV.js
4950
+ // node_modules/.pnpm/@stamn+cli@0.1.0-alpha.11/node_modules/@stamn/cli/dist/chunk-2OW6NQTB.js
4785
4951
  import { execSync } from "child_process";
4786
4952
  import { mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
4787
4953
  import { join } from "path";
@@ -4840,19 +5006,52 @@ async function handleAgentRegister(opts, adapter) {
4840
5006
  process.exit(1);
4841
5007
  }
4842
5008
  let name = opts.name;
5009
+ let bindTo = opts.name;
4843
5010
  if (!name) {
4844
- const input = await Zt({
4845
- message: "What should we call this agent?",
4846
- placeholder: "my-agent",
4847
- validate: (value) => {
4848
- if (!value?.trim()) return "Name is required.";
5011
+ const hostAgents = adapter.listHostAgents?.() ?? [];
5012
+ if (hostAgents.length > 0) {
5013
+ const chosen = await Jt({
5014
+ message: `Found ${hostAgents.length} agent(s) in your OpenClaw config. Which one should this Stamn agent be bound to?`,
5015
+ options: [
5016
+ ...hostAgents.map((a) => ({ value: a.id, label: a.id })),
5017
+ { value: "__none__", label: "None \u2014 use as default (single-agent)" }
5018
+ ]
5019
+ });
5020
+ if (typeof chosen === "symbol") {
5021
+ Nt("Cancelled.");
5022
+ return;
4849
5023
  }
4850
- });
4851
- if (typeof input === "symbol") {
4852
- Nt("Cancelled.");
4853
- return;
5024
+ if (chosen !== "__none__") {
5025
+ bindTo = chosen;
5026
+ const input = await Zt({
5027
+ message: "What should we call this Stamn agent?",
5028
+ placeholder: chosen,
5029
+ initialValue: chosen,
5030
+ validate: (value) => {
5031
+ if (!value?.trim()) return "Name is required.";
5032
+ }
5033
+ });
5034
+ if (typeof input === "symbol") {
5035
+ Nt("Cancelled.");
5036
+ return;
5037
+ }
5038
+ name = input;
5039
+ }
5040
+ }
5041
+ if (!name) {
5042
+ const input = await Zt({
5043
+ message: "What should we call this agent?",
5044
+ placeholder: "my-agent",
5045
+ validate: (value) => {
5046
+ if (!value?.trim()) return "Name is required.";
5047
+ }
5048
+ });
5049
+ if (typeof input === "symbol") {
5050
+ Nt("Cancelled.");
5051
+ return;
5052
+ }
5053
+ name = input;
4854
5054
  }
4855
- name = input;
4856
5055
  }
4857
5056
  const client = new StamnClient({ apiKey: config.apiKey });
4858
5057
  const s = be();
@@ -4862,16 +5061,18 @@ async function handleAgentRegister(opts, adapter) {
4862
5061
  const match = agents.find((a) => a.name === name);
4863
5062
  if (match) {
4864
5063
  s.stop("Agent found.");
4865
- adapter.writeConfig({ agentId: match.id, agentName: match.name });
5064
+ writeResult(adapter, name, match.id, match.name, config.apiKey, bindTo);
4866
5065
  R2.success(`Agent "${match.name}" (${match.id}) already exists. Selected as active.`);
5066
+ if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
4867
5067
  Gt("Done!");
4868
5068
  process.exit(0);
4869
5069
  }
4870
5070
  s.start("Registering agent...");
4871
5071
  const participant = await client.participants.create({ name });
4872
5072
  s.stop("Agent registered.");
4873
- adapter.writeConfig({ agentId: participant.id, agentName: participant.name });
5073
+ writeResult(adapter, name, participant.id, participant.name, config.apiKey, bindTo);
4874
5074
  R2.success(`Agent "${participant.name}" (${participant.id})`);
5075
+ if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
4875
5076
  Gt("Done!");
4876
5077
  process.exit(0);
4877
5078
  } catch (err) {
@@ -4880,6 +5081,12 @@ async function handleAgentRegister(opts, adapter) {
4880
5081
  process.exit(1);
4881
5082
  }
4882
5083
  }
5084
+ function writeResult(adapter, name, agentId, agentName, apiKey, bindTo) {
5085
+ if (bindTo) {
5086
+ adapter.writeAgentBinding(bindTo, { agentId, apiKey, agentName });
5087
+ }
5088
+ adapter.writeConfig({ agentId, agentName });
5089
+ }
4883
5090
  async function handleAgentList(_opts, adapter) {
4884
5091
  Wt2("Stamn Agents");
4885
5092
  const config = adapter.readConfig();
@@ -4927,8 +5134,13 @@ async function handleAgentSelect(opts, adapter) {
4927
5134
  process.exit(1);
4928
5135
  return;
4929
5136
  }
4930
- adapter.writeConfig({ agentId: match.id, agentName: match.name });
4931
- R2.success(`Active agent set to "${match.name}" (${match.id})`);
5137
+ if (opts.bind) {
5138
+ adapter.writeAgentBinding(opts.bind, { agentId: match.id, apiKey: config.apiKey, agentName: match.name });
5139
+ R2.success(`Agent "${match.name}" (${match.id}) bound to OpenClaw agent "${opts.bind}".`);
5140
+ } else {
5141
+ adapter.writeConfig({ agentId: match.id, agentName: match.name });
5142
+ R2.success(`Active agent set to "${match.name}" (${match.id})`);
5143
+ }
4932
5144
  Gt("Done!");
4933
5145
  process.exit(0);
4934
5146
  } catch (err) {
@@ -5150,6 +5362,12 @@ function createOpenclawAdapter() {
5150
5362
  readStatusFile() {
5151
5363
  return readJsonFile(join3(homedir(), ".openclaw", "stamn-status.json"));
5152
5364
  },
5365
+ listHostAgents() {
5366
+ const config = readOpenclawConfig();
5367
+ const list = config?.agents?.list;
5368
+ if (!Array.isArray(list)) return [];
5369
+ return list.filter((e) => e && typeof e.id === "string").map((e) => ({ id: e.id, workspace: e.workspace }));
5370
+ },
5153
5371
  uninstall() {
5154
5372
  const config = readOpenclawConfig();
5155
5373
  if (config?.plugins?.entries?.[PLUGIN_ID]) {
@@ -5403,6 +5621,114 @@ function writeWorkspaceFile(relativePath, content) {
5403
5621
  return { path: relativePath, written: true };
5404
5622
  }
5405
5623
 
5624
+ // src/global-files.ts
5625
+ import { readdirSync as readdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync5, statSync as statSync3, mkdirSync as mkdirSync4, realpathSync as realpathSync2, existsSync as existsSync3 } from "fs";
5626
+ import { join as join7, resolve as resolve2, relative as relative2, dirname as dirname3 } from "path";
5627
+ import { homedir as homedir4 } from "os";
5628
+ var OPENCLAW_DIR = join7(homedir4(), ".openclaw");
5629
+ var CONFIG_FILE = join7(OPENCLAW_DIR, "openclaw.json");
5630
+ var SCOPE_DIRS = {
5631
+ skills: join7(OPENCLAW_DIR, "skills"),
5632
+ workspace: join7(OPENCLAW_DIR, "workspace"),
5633
+ config: OPENCLAW_DIR
5634
+ };
5635
+ function resolveBaseDir(scope) {
5636
+ const dir = SCOPE_DIRS[scope];
5637
+ if (!dir) throw new Error(`Invalid scope: ${scope}`);
5638
+ return dir;
5639
+ }
5640
+ function realBase(dir) {
5641
+ try {
5642
+ return realpathSync2(dir);
5643
+ } catch {
5644
+ return dir;
5645
+ }
5646
+ }
5647
+ function assertWithinScope(scope, relativePath) {
5648
+ const base = resolveBaseDir(scope);
5649
+ const full = resolve2(base, relativePath);
5650
+ if (!full.startsWith(base + "/") && full !== base) {
5651
+ throw new Error("Path outside scope");
5652
+ }
5653
+ const baseReal = realBase(base);
5654
+ try {
5655
+ const realFull = realpathSync2(full);
5656
+ if (!realFull.startsWith(baseReal + "/") && realFull !== baseReal) {
5657
+ throw new Error("Path outside scope");
5658
+ }
5659
+ } catch (err) {
5660
+ if (err.code === "ENOENT") {
5661
+ try {
5662
+ const parentReal = realpathSync2(dirname3(full));
5663
+ if (!parentReal.startsWith(baseReal + "/") && parentReal !== baseReal) {
5664
+ throw new Error("Path outside scope");
5665
+ }
5666
+ } catch {
5667
+ }
5668
+ } else {
5669
+ throw err;
5670
+ }
5671
+ }
5672
+ return full;
5673
+ }
5674
+ function walkDir2(dir, base) {
5675
+ const results = [];
5676
+ let entries;
5677
+ try {
5678
+ entries = readdirSync2(dir, { withFileTypes: true });
5679
+ } catch {
5680
+ return results;
5681
+ }
5682
+ for (const entry of entries) {
5683
+ const fullPath = join7(dir, entry.name);
5684
+ if (entry.isDirectory()) {
5685
+ results.push(...walkDir2(fullPath, base));
5686
+ } else if (entry.isFile() && entry.name.endsWith(".md")) {
5687
+ const stat = statSync3(fullPath);
5688
+ results.push({
5689
+ path: relative2(base, fullPath),
5690
+ size: stat.size,
5691
+ modifiedAt: stat.mtime.toISOString()
5692
+ });
5693
+ }
5694
+ }
5695
+ return results;
5696
+ }
5697
+ function listGlobalFiles(scope) {
5698
+ const base = resolveBaseDir(scope);
5699
+ return walkDir2(base, base);
5700
+ }
5701
+ function readGlobalFile(scope, relativePath) {
5702
+ const full = assertWithinScope(scope, relativePath);
5703
+ const content = readFileSync4(full, "utf-8");
5704
+ const stat = statSync3(full);
5705
+ return { path: relativePath, content, size: stat.size };
5706
+ }
5707
+ function writeGlobalFile(scope, relativePath, content) {
5708
+ const full = assertWithinScope(scope, relativePath);
5709
+ mkdirSync4(dirname3(full), { recursive: true });
5710
+ writeFileSync5(full, content, "utf-8");
5711
+ return { path: relativePath, written: true };
5712
+ }
5713
+ function readOpenclawConfig2() {
5714
+ if (!existsSync3(CONFIG_FILE)) {
5715
+ return { path: "openclaw.json", content: "{}", size: 2 };
5716
+ }
5717
+ const content = readFileSync4(CONFIG_FILE, "utf-8");
5718
+ const stat = statSync3(CONFIG_FILE);
5719
+ return { path: "openclaw.json", content, size: stat.size };
5720
+ }
5721
+ function writeOpenclawConfig(content) {
5722
+ try {
5723
+ JSON.parse(content);
5724
+ } catch {
5725
+ throw new Error("Invalid JSON: config must be valid JSON");
5726
+ }
5727
+ mkdirSync4(dirname3(CONFIG_FILE), { recursive: true });
5728
+ writeFileSync5(CONFIG_FILE, content, "utf-8");
5729
+ return { path: "openclaw.json", written: true };
5730
+ }
5731
+
5406
5732
  // src/ws-service.ts
5407
5733
  var MAX_EVENT_BUFFER_SIZE = 200;
5408
5734
  var BASE_RECONNECT_DELAY_MS = 1e3;
@@ -5592,6 +5918,26 @@ var StamnWsService = class {
5592
5918
  this.handleWriteFile(payload.params);
5593
5919
  return;
5594
5920
  }
5921
+ if (payload.command === "list_global_files") {
5922
+ this.handleListGlobalFiles(payload.params);
5923
+ return;
5924
+ }
5925
+ if (payload.command === "read_global_file") {
5926
+ this.handleReadGlobalFile(payload.params);
5927
+ return;
5928
+ }
5929
+ if (payload.command === "write_global_file") {
5930
+ this.handleWriteGlobalFile(payload.params);
5931
+ return;
5932
+ }
5933
+ if (payload.command === "read_openclaw_config") {
5934
+ this.handleReadOpenclawConfig(payload.params);
5935
+ return;
5936
+ }
5937
+ if (payload.command === "write_openclaw_config") {
5938
+ this.handleWriteOpenclawConfig(payload.params);
5939
+ return;
5940
+ }
5595
5941
  this.logger.info(`Command received: ${payload.command} (${payload.commandId})`);
5596
5942
  if (payload.command === "update_plugin") {
5597
5943
  this.handleUpdatePlugin();
@@ -5685,6 +6031,87 @@ var StamnWsService = class {
5685
6031
  });
5686
6032
  }
5687
6033
  }
6034
+ handleListGlobalFiles(params) {
6035
+ try {
6036
+ const files = listGlobalFiles(params.scope);
6037
+ this.sendMessage("participant:file_response", {
6038
+ requestId: params.requestId,
6039
+ files
6040
+ });
6041
+ } catch (err) {
6042
+ this.sendMessage("participant:file_response", {
6043
+ requestId: params.requestId,
6044
+ files: [],
6045
+ error: err.message
6046
+ });
6047
+ }
6048
+ }
6049
+ handleReadGlobalFile(params) {
6050
+ try {
6051
+ const result = readGlobalFile(params.scope, params.path);
6052
+ this.sendMessage("participant:file_response", {
6053
+ requestId: params.requestId,
6054
+ ...result
6055
+ });
6056
+ } catch (err) {
6057
+ this.sendMessage("participant:file_response", {
6058
+ requestId: params.requestId,
6059
+ path: params.path,
6060
+ content: "",
6061
+ size: 0,
6062
+ error: err.message
6063
+ });
6064
+ }
6065
+ }
6066
+ handleWriteGlobalFile(params) {
6067
+ try {
6068
+ const result = writeGlobalFile(params.scope, params.path, params.content);
6069
+ this.sendMessage("participant:file_response", {
6070
+ requestId: params.requestId,
6071
+ ...result
6072
+ });
6073
+ } catch (err) {
6074
+ this.sendMessage("participant:file_response", {
6075
+ requestId: params.requestId,
6076
+ path: params.path,
6077
+ written: false,
6078
+ error: err.message
6079
+ });
6080
+ }
6081
+ }
6082
+ handleReadOpenclawConfig(params) {
6083
+ try {
6084
+ const result = readOpenclawConfig2();
6085
+ this.sendMessage("participant:file_response", {
6086
+ requestId: params.requestId,
6087
+ ...result
6088
+ });
6089
+ } catch (err) {
6090
+ this.sendMessage("participant:file_response", {
6091
+ requestId: params.requestId,
6092
+ path: "openclaw.json",
6093
+ content: "",
6094
+ size: 0,
6095
+ error: err.message
6096
+ });
6097
+ }
6098
+ }
6099
+ handleWriteOpenclawConfig(params) {
6100
+ try {
6101
+ const result = writeOpenclawConfig(params.content);
6102
+ this.sendMessage("participant:file_response", {
6103
+ requestId: params.requestId,
6104
+ ...result
6105
+ });
6106
+ } catch (err) {
6107
+ this.sendMessage("participant:file_response", {
6108
+ requestId: params.requestId,
6109
+ path: "openclaw.json",
6110
+ written: false,
6111
+ error: err.message
6112
+ });
6113
+ }
6114
+ }
5688
6115
  onAuthError(payload) {
5689
6116
  this.authFailed = true;
5690
6117
  this.logger.error(`Authentication failed: ${payload.reason}`);