@stamn/stamn-plugin 0.1.0-alpha.34 → 0.1.0-alpha.36
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 +255 -36
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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__ */ ((
|
|
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
|
-
}) :
|
|
9
|
+
}) : x3)(function(x3) {
|
|
10
10
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' +
|
|
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(
|
|
42
|
-
if (!y2) return `${CSI}${
|
|
43
|
-
return `${CSI}${y2 + 1};${
|
|
41
|
+
to(x3, y2) {
|
|
42
|
+
if (!y2) return `${CSI}${x3 + 1}G`;
|
|
43
|
+
return `${CSI}${y2 + 1};${x3 + 1}H`;
|
|
44
44
|
},
|
|
45
|
-
move(
|
|
45
|
+
move(x3, y2) {
|
|
46
46
|
let ret = "";
|
|
47
|
-
if (
|
|
48
|
-
else if (
|
|
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
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
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",
|
|
4595
|
+
const u = r ? `${t("cyan", h)} ` : "", l = r ? t("cyan", x2) : "";
|
|
4468
4596
|
return `${s}${u}${a}
|
|
4469
4597
|
${l}
|
|
4470
4598
|
`;
|
|
@@ -4819,7 +4947,7 @@ var StamnClient = class {
|
|
|
4819
4947
|
}
|
|
4820
4948
|
};
|
|
4821
4949
|
|
|
4822
|
-
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.
|
|
4950
|
+
// node_modules/.pnpm/@stamn+cli@0.1.0-alpha.11/node_modules/@stamn/cli/dist/chunk-2OW6NQTB.js
|
|
4823
4951
|
import { execSync } from "child_process";
|
|
4824
4952
|
import { mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs";
|
|
4825
4953
|
import { join } from "path";
|
|
@@ -4878,19 +5006,52 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
4878
5006
|
process.exit(1);
|
|
4879
5007
|
}
|
|
4880
5008
|
let name = opts.name;
|
|
5009
|
+
let bindTo = opts.name;
|
|
4881
5010
|
if (!name) {
|
|
4882
|
-
const
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
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;
|
|
5023
|
+
}
|
|
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;
|
|
4887
5039
|
}
|
|
4888
|
-
});
|
|
4889
|
-
if (typeof input === "symbol") {
|
|
4890
|
-
Nt("Cancelled.");
|
|
4891
|
-
return;
|
|
4892
5040
|
}
|
|
4893
|
-
name
|
|
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;
|
|
5054
|
+
}
|
|
4894
5055
|
}
|
|
4895
5056
|
const client = new StamnClient({ apiKey: config.apiKey });
|
|
4896
5057
|
const s = be();
|
|
@@ -4900,17 +5061,18 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
4900
5061
|
const match = agents.find((a) => a.name === name);
|
|
4901
5062
|
if (match) {
|
|
4902
5063
|
s.stop("Agent found.");
|
|
4903
|
-
writeResult(adapter, name, match.id, match.name, config.apiKey);
|
|
5064
|
+
writeResult(adapter, name, match.id, match.name, config.apiKey, bindTo);
|
|
4904
5065
|
R2.success(`Agent "${match.name}" (${match.id}) already exists. Selected as active.`);
|
|
5066
|
+
if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
|
|
4905
5067
|
Gt("Done!");
|
|
4906
5068
|
process.exit(0);
|
|
4907
5069
|
}
|
|
4908
5070
|
s.start("Registering agent...");
|
|
4909
5071
|
const participant = await client.participants.create({ name });
|
|
4910
5072
|
s.stop("Agent registered.");
|
|
4911
|
-
writeResult(adapter, name, participant.id, participant.name, config.apiKey);
|
|
5073
|
+
writeResult(adapter, name, participant.id, participant.name, config.apiKey, bindTo);
|
|
4912
5074
|
R2.success(`Agent "${participant.name}" (${participant.id})`);
|
|
4913
|
-
R2.info(`Bound to OpenClaw agent "${
|
|
5075
|
+
if (bindTo) R2.info(`Bound to OpenClaw agent "${bindTo}".`);
|
|
4914
5076
|
Gt("Done!");
|
|
4915
5077
|
process.exit(0);
|
|
4916
5078
|
} catch (err) {
|
|
@@ -4919,8 +5081,10 @@ async function handleAgentRegister(opts, adapter) {
|
|
|
4919
5081
|
process.exit(1);
|
|
4920
5082
|
}
|
|
4921
5083
|
}
|
|
4922
|
-
function writeResult(adapter, name, agentId, agentName, apiKey) {
|
|
4923
|
-
|
|
5084
|
+
function writeResult(adapter, name, agentId, agentName, apiKey, bindTo) {
|
|
5085
|
+
if (bindTo) {
|
|
5086
|
+
adapter.writeAgentBinding(bindTo, { agentId, apiKey, agentName });
|
|
5087
|
+
}
|
|
4924
5088
|
adapter.writeConfig({ agentId, agentName });
|
|
4925
5089
|
}
|
|
4926
5090
|
async function handleAgentList(_opts, adapter) {
|
|
@@ -5110,8 +5274,11 @@ import { join as join3 } from "path";
|
|
|
5110
5274
|
import { homedir } from "os";
|
|
5111
5275
|
var DEFAULT_SERVER_URL = "https://api.stamn.com";
|
|
5112
5276
|
var PLUGIN_ID = "stamn-plugin";
|
|
5277
|
+
function getHttpUrl() {
|
|
5278
|
+
return process.env.STAMN_SERVER_URL || DEFAULT_SERVER_URL;
|
|
5279
|
+
}
|
|
5113
5280
|
function getWsUrl() {
|
|
5114
|
-
const base =
|
|
5281
|
+
const base = getHttpUrl();
|
|
5115
5282
|
const wsBase = base.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://");
|
|
5116
5283
|
return `${wsBase}/ws/agent`;
|
|
5117
5284
|
}
|
|
@@ -5146,7 +5313,8 @@ var STAMN_TOOL_NAMES = [
|
|
|
5146
5313
|
"stamn_update_service_listing",
|
|
5147
5314
|
"stamn_list_service_listings",
|
|
5148
5315
|
"stamn_chat_reply",
|
|
5149
|
-
"stamn_spend"
|
|
5316
|
+
"stamn_spend",
|
|
5317
|
+
"stamn_blog_create_post"
|
|
5150
5318
|
];
|
|
5151
5319
|
function ensureToolsAllowed() {
|
|
5152
5320
|
const config = readOpenclawConfig();
|
|
@@ -5198,6 +5366,12 @@ function createOpenclawAdapter() {
|
|
|
5198
5366
|
readStatusFile() {
|
|
5199
5367
|
return readJsonFile(join3(homedir(), ".openclaw", "stamn-status.json"));
|
|
5200
5368
|
},
|
|
5369
|
+
listHostAgents() {
|
|
5370
|
+
const config = readOpenclawConfig();
|
|
5371
|
+
const list = config?.agents?.list;
|
|
5372
|
+
if (!Array.isArray(list)) return [];
|
|
5373
|
+
return list.filter((e) => e && typeof e.id === "string").map((e) => ({ id: e.id, workspace: e.workspace }));
|
|
5374
|
+
},
|
|
5201
5375
|
uninstall() {
|
|
5202
5376
|
const config = readOpenclawConfig();
|
|
5203
5377
|
if (config?.plugins?.entries?.[PLUGIN_ID]) {
|
|
@@ -6770,7 +6944,50 @@ function resolveEscalation(ws) {
|
|
|
6770
6944
|
}
|
|
6771
6945
|
};
|
|
6772
6946
|
}
|
|
6773
|
-
function
|
|
6947
|
+
function createBlogPost(apiKey, baseUrl) {
|
|
6948
|
+
return {
|
|
6949
|
+
name: "stamn_blog_create_post",
|
|
6950
|
+
description: "Publish a blog post to your public profile. Posts appear at /@yourName and in the global feed. You can create 1 post per 24 hours.",
|
|
6951
|
+
parameters: {
|
|
6952
|
+
type: "object",
|
|
6953
|
+
properties: {
|
|
6954
|
+
title: param("string", "Post title (max 200 chars)."),
|
|
6955
|
+
content: param("string", "Post body in Markdown (max 100,000 chars)."),
|
|
6956
|
+
excerpt: param("string", "Short summary for feed cards (max 500 chars)."),
|
|
6957
|
+
publish: param("string", 'Set to "true" to publish immediately. Default: draft.', {
|
|
6958
|
+
enum: ["true", "false"]
|
|
6959
|
+
})
|
|
6960
|
+
},
|
|
6961
|
+
required: ["title", "content"]
|
|
6962
|
+
},
|
|
6963
|
+
execute: async (_id, args) => {
|
|
6964
|
+
const body = {
|
|
6965
|
+
title: assertStr(args.title, "title", 200),
|
|
6966
|
+
content: assertStr(args.content, "content", 1e5),
|
|
6967
|
+
publish: args.publish === "true"
|
|
6968
|
+
};
|
|
6969
|
+
if (args.excerpt) body.excerpt = assertStr(args.excerpt, "excerpt", 500);
|
|
6970
|
+
const res = await fetch(`${baseUrl}/v1/blog/posts`, {
|
|
6971
|
+
method: "POST",
|
|
6972
|
+
headers: {
|
|
6973
|
+
"Content-Type": "application/json",
|
|
6974
|
+
"X-API-Key": apiKey
|
|
6975
|
+
},
|
|
6976
|
+
body: JSON.stringify(body)
|
|
6977
|
+
});
|
|
6978
|
+
const data = await res.json();
|
|
6979
|
+
if (!res.ok) {
|
|
6980
|
+
const msg = data?.message || data?.error || `HTTP ${res.status}`;
|
|
6981
|
+
return text(`Failed to create post: ${msg}`);
|
|
6982
|
+
}
|
|
6983
|
+
const post = data.data;
|
|
6984
|
+
return text(
|
|
6985
|
+
`Post created: "${post.title}" (${post.status}). Slug: ${post.slug}`
|
|
6986
|
+
);
|
|
6987
|
+
}
|
|
6988
|
+
};
|
|
6989
|
+
}
|
|
6990
|
+
function allTools(ws, agentId, maxSpendCents, apiKey, baseUrl) {
|
|
6774
6991
|
return [
|
|
6775
6992
|
worldStatus(ws),
|
|
6776
6993
|
getEvents(ws),
|
|
@@ -6797,7 +7014,8 @@ function allTools(ws, agentId, maxSpendCents) {
|
|
|
6797
7014
|
setHybridMode(ws),
|
|
6798
7015
|
addCredential(ws),
|
|
6799
7016
|
requestEscalation(ws),
|
|
6800
|
-
resolveEscalation(ws)
|
|
7017
|
+
resolveEscalation(ws),
|
|
7018
|
+
createBlogPost(apiKey, baseUrl)
|
|
6801
7019
|
];
|
|
6802
7020
|
}
|
|
6803
7021
|
function withAuthGuard(tool, ws) {
|
|
@@ -6820,12 +7038,13 @@ function withAuthGuard(tool, ws) {
|
|
|
6820
7038
|
function registerTools(api, pool, config) {
|
|
6821
7039
|
const maxSpendCents = config.maxSpendCentsPerCall ?? DEFAULT_MAX_SPEND_CENTS;
|
|
6822
7040
|
api.registerTool(ping());
|
|
7041
|
+
const baseUrl = getHttpUrl();
|
|
6823
7042
|
api.registerTool((ctx) => {
|
|
6824
7043
|
const binding = resolveBinding(config, ctx.agentId);
|
|
6825
7044
|
if (!binding) return null;
|
|
6826
7045
|
const ws = pool.resolve(ctx.agentId);
|
|
6827
7046
|
if (!ws) return null;
|
|
6828
|
-
const tools = allTools(ws, binding.agentId, maxSpendCents);
|
|
7047
|
+
const tools = allTools(ws, binding.agentId, maxSpendCents, binding.apiKey, baseUrl);
|
|
6829
7048
|
return tools.map((tool) => withAuthGuard(tool, ws));
|
|
6830
7049
|
});
|
|
6831
7050
|
}
|