@toolforge-js/sdk 0.3.0 → 0.4.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/agent-DBDnKm26.js +3093 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +3743 -0
- package/dist/components/index.d.ts +6671 -0
- package/dist/components/index.js +33 -0
- package/dist/config/index.d.ts +26 -0
- package/dist/config/index.js +14 -0
- package/dist/config-schema-CcWOtgOv.js +12 -0
- package/package.json +5 -1
- package/eslint.config.js +0 -1
- package/package.json.bak +0 -48
- package/prettier.config.js +0 -1
- package/scripts/internal-deps.ts +0 -4
- package/scripts/postpublish.ts +0 -18
- package/scripts/prepublish.ts +0 -38
- package/tsconfig.json +0 -3
- package/tsdown.config.ts +0 -51
|
@@ -0,0 +1,3093 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as z$1 from "zod";
|
|
3
|
+
import { P, match } from "ts-pattern";
|
|
4
|
+
import { setTimeout } from "node:timers/promises";
|
|
5
|
+
import { nanoid } from "nanoid";
|
|
6
|
+
|
|
7
|
+
//#region rolldown:runtime
|
|
8
|
+
var __create = Object.create;
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJS = (cb, mod) => function() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys$1 = __getOwnPropNames(from), i = 0, n = keys$1.length, key; i < n; i++) {
|
|
19
|
+
key = keys$1[i];
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
+
get: ((k) => from[k]).bind(null, key),
|
|
22
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return to;
|
|
26
|
+
};
|
|
27
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region ../../node_modules/.bun/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js
|
|
35
|
+
var require_dayjs_min = /* @__PURE__ */ __commonJS({ "../../node_modules/.bun/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js": ((exports, module) => {
|
|
36
|
+
(function(t, e) {
|
|
37
|
+
"object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define(e) : (t = "undefined" != typeof globalThis ? globalThis : t || self).dayjs = e();
|
|
38
|
+
})(exports, (function() {
|
|
39
|
+
var t = 1e3, e = 6e4, n = 36e5, r = "millisecond", i = "second", s = "minute", u = "hour", a = "day", o = "week", c = "month", f = "quarter", h = "year", d = "date", l = "Invalid Date", $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, M = {
|
|
40
|
+
name: "en",
|
|
41
|
+
weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
|
|
42
|
+
months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
|
|
43
|
+
ordinal: function(t$1) {
|
|
44
|
+
var e$1 = [
|
|
45
|
+
"th",
|
|
46
|
+
"st",
|
|
47
|
+
"nd",
|
|
48
|
+
"rd"
|
|
49
|
+
], n$1 = t$1 % 100;
|
|
50
|
+
return "[" + t$1 + (e$1[(n$1 - 20) % 10] || e$1[n$1] || e$1[0]) + "]";
|
|
51
|
+
}
|
|
52
|
+
}, m = function(t$1, e$1, n$1) {
|
|
53
|
+
var r$1 = String(t$1);
|
|
54
|
+
return !r$1 || r$1.length >= e$1 ? t$1 : "" + Array(e$1 + 1 - r$1.length).join(n$1) + t$1;
|
|
55
|
+
}, v = {
|
|
56
|
+
s: m,
|
|
57
|
+
z: function(t$1) {
|
|
58
|
+
var e$1 = -t$1.utcOffset(), n$1 = Math.abs(e$1), r$1 = Math.floor(n$1 / 60), i$1 = n$1 % 60;
|
|
59
|
+
return (e$1 <= 0 ? "+" : "-") + m(r$1, 2, "0") + ":" + m(i$1, 2, "0");
|
|
60
|
+
},
|
|
61
|
+
m: function t$1(e$1, n$1) {
|
|
62
|
+
if (e$1.date() < n$1.date()) return -t$1(n$1, e$1);
|
|
63
|
+
var r$1 = 12 * (n$1.year() - e$1.year()) + (n$1.month() - e$1.month()), i$1 = e$1.clone().add(r$1, c), s$1 = n$1 - i$1 < 0, u$1 = e$1.clone().add(r$1 + (s$1 ? -1 : 1), c);
|
|
64
|
+
return +(-(r$1 + (n$1 - i$1) / (s$1 ? i$1 - u$1 : u$1 - i$1)) || 0);
|
|
65
|
+
},
|
|
66
|
+
a: function(t$1) {
|
|
67
|
+
return t$1 < 0 ? Math.ceil(t$1) || 0 : Math.floor(t$1);
|
|
68
|
+
},
|
|
69
|
+
p: function(t$1) {
|
|
70
|
+
return {
|
|
71
|
+
M: c,
|
|
72
|
+
y: h,
|
|
73
|
+
w: o,
|
|
74
|
+
d: a,
|
|
75
|
+
D: d,
|
|
76
|
+
h: u,
|
|
77
|
+
m: s,
|
|
78
|
+
s: i,
|
|
79
|
+
ms: r,
|
|
80
|
+
Q: f
|
|
81
|
+
}[t$1] || String(t$1 || "").toLowerCase().replace(/s$/, "");
|
|
82
|
+
},
|
|
83
|
+
u: function(t$1) {
|
|
84
|
+
return void 0 === t$1;
|
|
85
|
+
}
|
|
86
|
+
}, g = "en", D = {};
|
|
87
|
+
D[g] = M;
|
|
88
|
+
var p = "$isDayjsObject", S = function(t$1) {
|
|
89
|
+
return t$1 instanceof _ || !(!t$1 || !t$1[p]);
|
|
90
|
+
}, w = function t$1(e$1, n$1, r$1) {
|
|
91
|
+
var i$1;
|
|
92
|
+
if (!e$1) return g;
|
|
93
|
+
if ("string" == typeof e$1) {
|
|
94
|
+
var s$1 = e$1.toLowerCase();
|
|
95
|
+
D[s$1] && (i$1 = s$1), n$1 && (D[s$1] = n$1, i$1 = s$1);
|
|
96
|
+
var u$1 = e$1.split("-");
|
|
97
|
+
if (!i$1 && u$1.length > 1) return t$1(u$1[0]);
|
|
98
|
+
} else {
|
|
99
|
+
var a$1 = e$1.name;
|
|
100
|
+
D[a$1] = e$1, i$1 = a$1;
|
|
101
|
+
}
|
|
102
|
+
return !r$1 && i$1 && (g = i$1), i$1 || !r$1 && g;
|
|
103
|
+
}, O = function(t$1, e$1) {
|
|
104
|
+
if (S(t$1)) return t$1.clone();
|
|
105
|
+
var n$1 = "object" == typeof e$1 ? e$1 : {};
|
|
106
|
+
return n$1.date = t$1, n$1.args = arguments, new _(n$1);
|
|
107
|
+
}, b = v;
|
|
108
|
+
b.l = w, b.i = S, b.w = function(t$1, e$1) {
|
|
109
|
+
return O(t$1, {
|
|
110
|
+
locale: e$1.$L,
|
|
111
|
+
utc: e$1.$u,
|
|
112
|
+
x: e$1.$x,
|
|
113
|
+
$offset: e$1.$offset
|
|
114
|
+
});
|
|
115
|
+
};
|
|
116
|
+
var _ = function() {
|
|
117
|
+
function M$1(t$1) {
|
|
118
|
+
this.$L = w(t$1.locale, null, !0), this.parse(t$1), this.$x = this.$x || t$1.x || {}, this[p] = !0;
|
|
119
|
+
}
|
|
120
|
+
var m$1 = M$1.prototype;
|
|
121
|
+
return m$1.parse = function(t$1) {
|
|
122
|
+
this.$d = function(t$2) {
|
|
123
|
+
var e$1 = t$2.date, n$1 = t$2.utc;
|
|
124
|
+
if (null === e$1) return /* @__PURE__ */ new Date(NaN);
|
|
125
|
+
if (b.u(e$1)) return /* @__PURE__ */ new Date();
|
|
126
|
+
if (e$1 instanceof Date) return new Date(e$1);
|
|
127
|
+
if ("string" == typeof e$1 && !/Z$/i.test(e$1)) {
|
|
128
|
+
var r$1 = e$1.match($);
|
|
129
|
+
if (r$1) {
|
|
130
|
+
var i$1 = r$1[2] - 1 || 0, s$1 = (r$1[7] || "0").substring(0, 3);
|
|
131
|
+
return n$1 ? new Date(Date.UTC(r$1[1], i$1, r$1[3] || 1, r$1[4] || 0, r$1[5] || 0, r$1[6] || 0, s$1)) : new Date(r$1[1], i$1, r$1[3] || 1, r$1[4] || 0, r$1[5] || 0, r$1[6] || 0, s$1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return new Date(e$1);
|
|
135
|
+
}(t$1), this.init();
|
|
136
|
+
}, m$1.init = function() {
|
|
137
|
+
var t$1 = this.$d;
|
|
138
|
+
this.$y = t$1.getFullYear(), this.$M = t$1.getMonth(), this.$D = t$1.getDate(), this.$W = t$1.getDay(), this.$H = t$1.getHours(), this.$m = t$1.getMinutes(), this.$s = t$1.getSeconds(), this.$ms = t$1.getMilliseconds();
|
|
139
|
+
}, m$1.$utils = function() {
|
|
140
|
+
return b;
|
|
141
|
+
}, m$1.isValid = function() {
|
|
142
|
+
return !(this.$d.toString() === l);
|
|
143
|
+
}, m$1.isSame = function(t$1, e$1) {
|
|
144
|
+
var n$1 = O(t$1);
|
|
145
|
+
return this.startOf(e$1) <= n$1 && n$1 <= this.endOf(e$1);
|
|
146
|
+
}, m$1.isAfter = function(t$1, e$1) {
|
|
147
|
+
return O(t$1) < this.startOf(e$1);
|
|
148
|
+
}, m$1.isBefore = function(t$1, e$1) {
|
|
149
|
+
return this.endOf(e$1) < O(t$1);
|
|
150
|
+
}, m$1.$g = function(t$1, e$1, n$1) {
|
|
151
|
+
return b.u(t$1) ? this[e$1] : this.set(n$1, t$1);
|
|
152
|
+
}, m$1.unix = function() {
|
|
153
|
+
return Math.floor(this.valueOf() / 1e3);
|
|
154
|
+
}, m$1.valueOf = function() {
|
|
155
|
+
return this.$d.getTime();
|
|
156
|
+
}, m$1.startOf = function(t$1, e$1) {
|
|
157
|
+
var n$1 = this, r$1 = !!b.u(e$1) || e$1, f$1 = b.p(t$1), l$1 = function(t$2, e$2) {
|
|
158
|
+
var i$1 = b.w(n$1.$u ? Date.UTC(n$1.$y, e$2, t$2) : new Date(n$1.$y, e$2, t$2), n$1);
|
|
159
|
+
return r$1 ? i$1 : i$1.endOf(a);
|
|
160
|
+
}, $$1 = function(t$2, e$2) {
|
|
161
|
+
return b.w(n$1.toDate()[t$2].apply(n$1.toDate("s"), (r$1 ? [
|
|
162
|
+
0,
|
|
163
|
+
0,
|
|
164
|
+
0,
|
|
165
|
+
0
|
|
166
|
+
] : [
|
|
167
|
+
23,
|
|
168
|
+
59,
|
|
169
|
+
59,
|
|
170
|
+
999
|
|
171
|
+
]).slice(e$2)), n$1);
|
|
172
|
+
}, y$1 = this.$W, M$2 = this.$M, m$2 = this.$D, v$1 = "set" + (this.$u ? "UTC" : "");
|
|
173
|
+
switch (f$1) {
|
|
174
|
+
case h: return r$1 ? l$1(1, 0) : l$1(31, 11);
|
|
175
|
+
case c: return r$1 ? l$1(1, M$2) : l$1(0, M$2 + 1);
|
|
176
|
+
case o:
|
|
177
|
+
var g$1 = this.$locale().weekStart || 0, D$1 = (y$1 < g$1 ? y$1 + 7 : y$1) - g$1;
|
|
178
|
+
return l$1(r$1 ? m$2 - D$1 : m$2 + (6 - D$1), M$2);
|
|
179
|
+
case a:
|
|
180
|
+
case d: return $$1(v$1 + "Hours", 0);
|
|
181
|
+
case u: return $$1(v$1 + "Minutes", 1);
|
|
182
|
+
case s: return $$1(v$1 + "Seconds", 2);
|
|
183
|
+
case i: return $$1(v$1 + "Milliseconds", 3);
|
|
184
|
+
default: return this.clone();
|
|
185
|
+
}
|
|
186
|
+
}, m$1.endOf = function(t$1) {
|
|
187
|
+
return this.startOf(t$1, !1);
|
|
188
|
+
}, m$1.$set = function(t$1, e$1) {
|
|
189
|
+
var n$1, o$1 = b.p(t$1), f$1 = "set" + (this.$u ? "UTC" : ""), l$1 = (n$1 = {}, n$1[a] = f$1 + "Date", n$1[d] = f$1 + "Date", n$1[c] = f$1 + "Month", n$1[h] = f$1 + "FullYear", n$1[u] = f$1 + "Hours", n$1[s] = f$1 + "Minutes", n$1[i] = f$1 + "Seconds", n$1[r] = f$1 + "Milliseconds", n$1)[o$1], $$1 = o$1 === a ? this.$D + (e$1 - this.$W) : e$1;
|
|
190
|
+
if (o$1 === c || o$1 === h) {
|
|
191
|
+
var y$1 = this.clone().set(d, 1);
|
|
192
|
+
y$1.$d[l$1]($$1), y$1.init(), this.$d = y$1.set(d, Math.min(this.$D, y$1.daysInMonth())).$d;
|
|
193
|
+
} else l$1 && this.$d[l$1]($$1);
|
|
194
|
+
return this.init(), this;
|
|
195
|
+
}, m$1.set = function(t$1, e$1) {
|
|
196
|
+
return this.clone().$set(t$1, e$1);
|
|
197
|
+
}, m$1.get = function(t$1) {
|
|
198
|
+
return this[b.p(t$1)]();
|
|
199
|
+
}, m$1.add = function(r$1, f$1) {
|
|
200
|
+
var d$1, l$1 = this;
|
|
201
|
+
r$1 = Number(r$1);
|
|
202
|
+
var $$1 = b.p(f$1), y$1 = function(t$1) {
|
|
203
|
+
var e$1 = O(l$1);
|
|
204
|
+
return b.w(e$1.date(e$1.date() + Math.round(t$1 * r$1)), l$1);
|
|
205
|
+
};
|
|
206
|
+
if ($$1 === c) return this.set(c, this.$M + r$1);
|
|
207
|
+
if ($$1 === h) return this.set(h, this.$y + r$1);
|
|
208
|
+
if ($$1 === a) return y$1(1);
|
|
209
|
+
if ($$1 === o) return y$1(7);
|
|
210
|
+
var M$2 = (d$1 = {}, d$1[s] = e, d$1[u] = n, d$1[i] = t, d$1)[$$1] || 1, m$2 = this.$d.getTime() + r$1 * M$2;
|
|
211
|
+
return b.w(m$2, this);
|
|
212
|
+
}, m$1.subtract = function(t$1, e$1) {
|
|
213
|
+
return this.add(-1 * t$1, e$1);
|
|
214
|
+
}, m$1.format = function(t$1) {
|
|
215
|
+
var e$1 = this, n$1 = this.$locale();
|
|
216
|
+
if (!this.isValid()) return n$1.invalidDate || l;
|
|
217
|
+
var r$1 = t$1 || "YYYY-MM-DDTHH:mm:ssZ", i$1 = b.z(this), s$1 = this.$H, u$1 = this.$m, a$1 = this.$M, o$1 = n$1.weekdays, c$1 = n$1.months, f$1 = n$1.meridiem, h$1 = function(t$2, n$2, i$2, s$2) {
|
|
218
|
+
return t$2 && (t$2[n$2] || t$2(e$1, r$1)) || i$2[n$2].slice(0, s$2);
|
|
219
|
+
}, d$1 = function(t$2) {
|
|
220
|
+
return b.s(s$1 % 12 || 12, t$2, "0");
|
|
221
|
+
}, $$1 = f$1 || function(t$2, e$2, n$2) {
|
|
222
|
+
var r$2 = t$2 < 12 ? "AM" : "PM";
|
|
223
|
+
return n$2 ? r$2.toLowerCase() : r$2;
|
|
224
|
+
};
|
|
225
|
+
return r$1.replace(y, (function(t$2, r$2) {
|
|
226
|
+
return r$2 || function(t$3) {
|
|
227
|
+
switch (t$3) {
|
|
228
|
+
case "YY": return String(e$1.$y).slice(-2);
|
|
229
|
+
case "YYYY": return b.s(e$1.$y, 4, "0");
|
|
230
|
+
case "M": return a$1 + 1;
|
|
231
|
+
case "MM": return b.s(a$1 + 1, 2, "0");
|
|
232
|
+
case "MMM": return h$1(n$1.monthsShort, a$1, c$1, 3);
|
|
233
|
+
case "MMMM": return h$1(c$1, a$1);
|
|
234
|
+
case "D": return e$1.$D;
|
|
235
|
+
case "DD": return b.s(e$1.$D, 2, "0");
|
|
236
|
+
case "d": return String(e$1.$W);
|
|
237
|
+
case "dd": return h$1(n$1.weekdaysMin, e$1.$W, o$1, 2);
|
|
238
|
+
case "ddd": return h$1(n$1.weekdaysShort, e$1.$W, o$1, 3);
|
|
239
|
+
case "dddd": return o$1[e$1.$W];
|
|
240
|
+
case "H": return String(s$1);
|
|
241
|
+
case "HH": return b.s(s$1, 2, "0");
|
|
242
|
+
case "h": return d$1(1);
|
|
243
|
+
case "hh": return d$1(2);
|
|
244
|
+
case "a": return $$1(s$1, u$1, !0);
|
|
245
|
+
case "A": return $$1(s$1, u$1, !1);
|
|
246
|
+
case "m": return String(u$1);
|
|
247
|
+
case "mm": return b.s(u$1, 2, "0");
|
|
248
|
+
case "s": return String(e$1.$s);
|
|
249
|
+
case "ss": return b.s(e$1.$s, 2, "0");
|
|
250
|
+
case "SSS": return b.s(e$1.$ms, 3, "0");
|
|
251
|
+
case "Z": return i$1;
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}(t$2) || i$1.replace(":", "");
|
|
255
|
+
}));
|
|
256
|
+
}, m$1.utcOffset = function() {
|
|
257
|
+
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
|
|
258
|
+
}, m$1.diff = function(r$1, d$1, l$1) {
|
|
259
|
+
var $$1, y$1 = this, M$2 = b.p(d$1), m$2 = O(r$1), v$1 = (m$2.utcOffset() - this.utcOffset()) * e, g$1 = this - m$2, D$1 = function() {
|
|
260
|
+
return b.m(y$1, m$2);
|
|
261
|
+
};
|
|
262
|
+
switch (M$2) {
|
|
263
|
+
case h:
|
|
264
|
+
$$1 = D$1() / 12;
|
|
265
|
+
break;
|
|
266
|
+
case c:
|
|
267
|
+
$$1 = D$1();
|
|
268
|
+
break;
|
|
269
|
+
case f:
|
|
270
|
+
$$1 = D$1() / 3;
|
|
271
|
+
break;
|
|
272
|
+
case o:
|
|
273
|
+
$$1 = (g$1 - v$1) / 6048e5;
|
|
274
|
+
break;
|
|
275
|
+
case a:
|
|
276
|
+
$$1 = (g$1 - v$1) / 864e5;
|
|
277
|
+
break;
|
|
278
|
+
case u:
|
|
279
|
+
$$1 = g$1 / n;
|
|
280
|
+
break;
|
|
281
|
+
case s:
|
|
282
|
+
$$1 = g$1 / e;
|
|
283
|
+
break;
|
|
284
|
+
case i:
|
|
285
|
+
$$1 = g$1 / t;
|
|
286
|
+
break;
|
|
287
|
+
default: $$1 = g$1;
|
|
288
|
+
}
|
|
289
|
+
return l$1 ? $$1 : b.a($$1);
|
|
290
|
+
}, m$1.daysInMonth = function() {
|
|
291
|
+
return this.endOf(c).$D;
|
|
292
|
+
}, m$1.$locale = function() {
|
|
293
|
+
return D[this.$L];
|
|
294
|
+
}, m$1.locale = function(t$1, e$1) {
|
|
295
|
+
if (!t$1) return this.$L;
|
|
296
|
+
var n$1 = this.clone(), r$1 = w(t$1, e$1, !0);
|
|
297
|
+
return r$1 && (n$1.$L = r$1), n$1;
|
|
298
|
+
}, m$1.clone = function() {
|
|
299
|
+
return b.w(this.$d, this);
|
|
300
|
+
}, m$1.toDate = function() {
|
|
301
|
+
return new Date(this.valueOf());
|
|
302
|
+
}, m$1.toJSON = function() {
|
|
303
|
+
return this.isValid() ? this.toISOString() : null;
|
|
304
|
+
}, m$1.toISOString = function() {
|
|
305
|
+
return this.$d.toISOString();
|
|
306
|
+
}, m$1.toString = function() {
|
|
307
|
+
return this.$d.toUTCString();
|
|
308
|
+
}, M$1;
|
|
309
|
+
}(), k = _.prototype;
|
|
310
|
+
return O.prototype = k, [
|
|
311
|
+
["$ms", r],
|
|
312
|
+
["$s", i],
|
|
313
|
+
["$m", s],
|
|
314
|
+
["$H", u],
|
|
315
|
+
["$W", a],
|
|
316
|
+
["$M", c],
|
|
317
|
+
["$y", h],
|
|
318
|
+
["$D", d]
|
|
319
|
+
].forEach((function(t$1) {
|
|
320
|
+
k[t$1[1]] = function(e$1) {
|
|
321
|
+
return this.$g(e$1, t$1[0], t$1[1]);
|
|
322
|
+
};
|
|
323
|
+
})), O.extend = function(t$1, e$1) {
|
|
324
|
+
return t$1.$i || (t$1(e$1, _, O), t$1.$i = !0), O;
|
|
325
|
+
}, O.locale = w, O.isDayjs = S, O.unix = function(t$1) {
|
|
326
|
+
return O(1e3 * t$1);
|
|
327
|
+
}, O.en = D[g], O.Ls = D, O.p = {}, O;
|
|
328
|
+
}));
|
|
329
|
+
}) });
|
|
330
|
+
|
|
331
|
+
//#endregion
|
|
332
|
+
//#region ../../node_modules/.bun/fast-equals@5.2.2/node_modules/fast-equals/dist/esm/index.mjs
|
|
333
|
+
var getOwnPropertyNames = Object.getOwnPropertyNames, getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
334
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
335
|
+
/**
|
|
336
|
+
* Combine two comparators into a single comparators.
|
|
337
|
+
*/
|
|
338
|
+
function combineComparators(comparatorA, comparatorB) {
|
|
339
|
+
return function isEqual(a, b, state) {
|
|
340
|
+
return comparatorA(a, b, state) && comparatorB(a, b, state);
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Wrap the provided `areItemsEqual` method to manage the circular state, allowing
|
|
345
|
+
* for circular references to be safely included in the comparison without creating
|
|
346
|
+
* stack overflows.
|
|
347
|
+
*/
|
|
348
|
+
function createIsCircular(areItemsEqual) {
|
|
349
|
+
return function isCircular(a, b, state) {
|
|
350
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return areItemsEqual(a, b, state);
|
|
351
|
+
var cache = state.cache;
|
|
352
|
+
var cachedA = cache.get(a);
|
|
353
|
+
var cachedB = cache.get(b);
|
|
354
|
+
if (cachedA && cachedB) return cachedA === b && cachedB === a;
|
|
355
|
+
cache.set(a, b);
|
|
356
|
+
cache.set(b, a);
|
|
357
|
+
var result = areItemsEqual(a, b, state);
|
|
358
|
+
cache.delete(a);
|
|
359
|
+
cache.delete(b);
|
|
360
|
+
return result;
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Get the properties to strictly examine, which include both own properties that are
|
|
365
|
+
* not enumerable and symbol properties.
|
|
366
|
+
*/
|
|
367
|
+
function getStrictProperties(object) {
|
|
368
|
+
return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Whether the object contains the property passed as an own property.
|
|
372
|
+
*/
|
|
373
|
+
var hasOwn = Object.hasOwn || (function(object, property) {
|
|
374
|
+
return hasOwnProperty.call(object, property);
|
|
375
|
+
});
|
|
376
|
+
/**
|
|
377
|
+
* Whether the values passed are strictly equal or both NaN.
|
|
378
|
+
*/
|
|
379
|
+
function sameValueZeroEqual(a, b) {
|
|
380
|
+
return a === b || !a && !b && a !== a && b !== b;
|
|
381
|
+
}
|
|
382
|
+
var PREACT_VNODE = "__v";
|
|
383
|
+
var PREACT_OWNER = "__o";
|
|
384
|
+
var REACT_OWNER = "_owner";
|
|
385
|
+
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor, keys = Object.keys;
|
|
386
|
+
/**
|
|
387
|
+
* Whether the arrays are equal in value.
|
|
388
|
+
*/
|
|
389
|
+
function areArraysEqual(a, b, state) {
|
|
390
|
+
var index = a.length;
|
|
391
|
+
if (b.length !== index) return false;
|
|
392
|
+
while (index-- > 0) if (!state.equals(a[index], b[index], index, index, a, b, state)) return false;
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Whether the dates passed are equal in value.
|
|
397
|
+
*/
|
|
398
|
+
function areDatesEqual(a, b) {
|
|
399
|
+
return sameValueZeroEqual(a.getTime(), b.getTime());
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Whether the errors passed are equal in value.
|
|
403
|
+
*/
|
|
404
|
+
function areErrorsEqual(a, b) {
|
|
405
|
+
return a.name === b.name && a.message === b.message && a.cause === b.cause && a.stack === b.stack;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Whether the functions passed are equal in value.
|
|
409
|
+
*/
|
|
410
|
+
function areFunctionsEqual(a, b) {
|
|
411
|
+
return a === b;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Whether the `Map`s are equal in value.
|
|
415
|
+
*/
|
|
416
|
+
function areMapsEqual(a, b, state) {
|
|
417
|
+
var size = a.size;
|
|
418
|
+
if (size !== b.size) return false;
|
|
419
|
+
if (!size) return true;
|
|
420
|
+
var matchedIndices = new Array(size);
|
|
421
|
+
var aIterable = a.entries();
|
|
422
|
+
var aResult;
|
|
423
|
+
var bResult;
|
|
424
|
+
var index = 0;
|
|
425
|
+
while (aResult = aIterable.next()) {
|
|
426
|
+
if (aResult.done) break;
|
|
427
|
+
var bIterable = b.entries();
|
|
428
|
+
var hasMatch = false;
|
|
429
|
+
var matchIndex = 0;
|
|
430
|
+
while (bResult = bIterable.next()) {
|
|
431
|
+
if (bResult.done) break;
|
|
432
|
+
if (matchedIndices[matchIndex]) {
|
|
433
|
+
matchIndex++;
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
var aEntry = aResult.value;
|
|
437
|
+
var bEntry = bResult.value;
|
|
438
|
+
if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state) && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {
|
|
439
|
+
hasMatch = matchedIndices[matchIndex] = true;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
matchIndex++;
|
|
443
|
+
}
|
|
444
|
+
if (!hasMatch) return false;
|
|
445
|
+
index++;
|
|
446
|
+
}
|
|
447
|
+
return true;
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Whether the numbers are equal in value.
|
|
451
|
+
*/
|
|
452
|
+
var areNumbersEqual = sameValueZeroEqual;
|
|
453
|
+
/**
|
|
454
|
+
* Whether the objects are equal in value.
|
|
455
|
+
*/
|
|
456
|
+
function areObjectsEqual(a, b, state) {
|
|
457
|
+
var properties = keys(a);
|
|
458
|
+
var index = properties.length;
|
|
459
|
+
if (keys(b).length !== index) return false;
|
|
460
|
+
while (index-- > 0) if (!isPropertyEqual(a, b, state, properties[index])) return false;
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Whether the objects are equal in value with strict property checking.
|
|
465
|
+
*/
|
|
466
|
+
function areObjectsEqualStrict(a, b, state) {
|
|
467
|
+
var properties = getStrictProperties(a);
|
|
468
|
+
var index = properties.length;
|
|
469
|
+
if (getStrictProperties(b).length !== index) return false;
|
|
470
|
+
var property;
|
|
471
|
+
var descriptorA;
|
|
472
|
+
var descriptorB;
|
|
473
|
+
while (index-- > 0) {
|
|
474
|
+
property = properties[index];
|
|
475
|
+
if (!isPropertyEqual(a, b, state, property)) return false;
|
|
476
|
+
descriptorA = getOwnPropertyDescriptor(a, property);
|
|
477
|
+
descriptorB = getOwnPropertyDescriptor(b, property);
|
|
478
|
+
if ((descriptorA || descriptorB) && (!descriptorA || !descriptorB || descriptorA.configurable !== descriptorB.configurable || descriptorA.enumerable !== descriptorB.enumerable || descriptorA.writable !== descriptorB.writable)) return false;
|
|
479
|
+
}
|
|
480
|
+
return true;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Whether the primitive wrappers passed are equal in value.
|
|
484
|
+
*/
|
|
485
|
+
function arePrimitiveWrappersEqual(a, b) {
|
|
486
|
+
return sameValueZeroEqual(a.valueOf(), b.valueOf());
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Whether the regexps passed are equal in value.
|
|
490
|
+
*/
|
|
491
|
+
function areRegExpsEqual(a, b) {
|
|
492
|
+
return a.source === b.source && a.flags === b.flags;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Whether the `Set`s are equal in value.
|
|
496
|
+
*/
|
|
497
|
+
function areSetsEqual(a, b, state) {
|
|
498
|
+
var size = a.size;
|
|
499
|
+
if (size !== b.size) return false;
|
|
500
|
+
if (!size) return true;
|
|
501
|
+
var matchedIndices = new Array(size);
|
|
502
|
+
var aIterable = a.values();
|
|
503
|
+
var aResult;
|
|
504
|
+
var bResult;
|
|
505
|
+
while (aResult = aIterable.next()) {
|
|
506
|
+
if (aResult.done) break;
|
|
507
|
+
var bIterable = b.values();
|
|
508
|
+
var hasMatch = false;
|
|
509
|
+
var matchIndex = 0;
|
|
510
|
+
while (bResult = bIterable.next()) {
|
|
511
|
+
if (bResult.done) break;
|
|
512
|
+
if (!matchedIndices[matchIndex] && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {
|
|
513
|
+
hasMatch = matchedIndices[matchIndex] = true;
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
matchIndex++;
|
|
517
|
+
}
|
|
518
|
+
if (!hasMatch) return false;
|
|
519
|
+
}
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* Whether the TypedArray instances are equal in value.
|
|
524
|
+
*/
|
|
525
|
+
function areTypedArraysEqual(a, b) {
|
|
526
|
+
var index = a.length;
|
|
527
|
+
if (b.length !== index) return false;
|
|
528
|
+
while (index-- > 0) if (a[index] !== b[index]) return false;
|
|
529
|
+
return true;
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Whether the URL instances are equal in value.
|
|
533
|
+
*/
|
|
534
|
+
function areUrlsEqual(a, b) {
|
|
535
|
+
return a.hostname === b.hostname && a.pathname === b.pathname && a.protocol === b.protocol && a.port === b.port && a.hash === b.hash && a.username === b.username && a.password === b.password;
|
|
536
|
+
}
|
|
537
|
+
function isPropertyEqual(a, b, state, property) {
|
|
538
|
+
if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE) && (a.$$typeof || b.$$typeof)) return true;
|
|
539
|
+
return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);
|
|
540
|
+
}
|
|
541
|
+
var ARGUMENTS_TAG = "[object Arguments]";
|
|
542
|
+
var BOOLEAN_TAG = "[object Boolean]";
|
|
543
|
+
var DATE_TAG = "[object Date]";
|
|
544
|
+
var ERROR_TAG = "[object Error]";
|
|
545
|
+
var MAP_TAG = "[object Map]";
|
|
546
|
+
var NUMBER_TAG = "[object Number]";
|
|
547
|
+
var OBJECT_TAG = "[object Object]";
|
|
548
|
+
var REG_EXP_TAG = "[object RegExp]";
|
|
549
|
+
var SET_TAG = "[object Set]";
|
|
550
|
+
var STRING_TAG = "[object String]";
|
|
551
|
+
var URL_TAG = "[object URL]";
|
|
552
|
+
var isArray = Array.isArray;
|
|
553
|
+
var isTypedArray = typeof ArrayBuffer === "function" && ArrayBuffer.isView ? ArrayBuffer.isView : null;
|
|
554
|
+
var assign = Object.assign;
|
|
555
|
+
var getTag = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
556
|
+
/**
|
|
557
|
+
* Create a comparator method based on the type-specific equality comparators passed.
|
|
558
|
+
*/
|
|
559
|
+
function createEqualityComparator(_a) {
|
|
560
|
+
var areArraysEqual$1 = _a.areArraysEqual, areDatesEqual$1 = _a.areDatesEqual, areErrorsEqual$1 = _a.areErrorsEqual, areFunctionsEqual$1 = _a.areFunctionsEqual, areMapsEqual$1 = _a.areMapsEqual, areNumbersEqual$1 = _a.areNumbersEqual, areObjectsEqual$1 = _a.areObjectsEqual, arePrimitiveWrappersEqual$1 = _a.arePrimitiveWrappersEqual, areRegExpsEqual$1 = _a.areRegExpsEqual, areSetsEqual$1 = _a.areSetsEqual, areTypedArraysEqual$1 = _a.areTypedArraysEqual, areUrlsEqual$1 = _a.areUrlsEqual;
|
|
561
|
+
/**
|
|
562
|
+
* compare the value of the two objects and return true if they are equivalent in values
|
|
563
|
+
*/
|
|
564
|
+
return function comparator(a, b, state) {
|
|
565
|
+
if (a === b) return true;
|
|
566
|
+
if (a == null || b == null) return false;
|
|
567
|
+
var type = typeof a;
|
|
568
|
+
if (type !== typeof b) return false;
|
|
569
|
+
if (type !== "object") {
|
|
570
|
+
if (type === "number") return areNumbersEqual$1(a, b, state);
|
|
571
|
+
if (type === "function") return areFunctionsEqual$1(a, b, state);
|
|
572
|
+
return false;
|
|
573
|
+
}
|
|
574
|
+
var constructor = a.constructor;
|
|
575
|
+
if (constructor !== b.constructor) return false;
|
|
576
|
+
if (constructor === Object) return areObjectsEqual$1(a, b, state);
|
|
577
|
+
if (isArray(a)) return areArraysEqual$1(a, b, state);
|
|
578
|
+
if (isTypedArray != null && isTypedArray(a)) return areTypedArraysEqual$1(a, b, state);
|
|
579
|
+
if (constructor === Date) return areDatesEqual$1(a, b, state);
|
|
580
|
+
if (constructor === RegExp) return areRegExpsEqual$1(a, b, state);
|
|
581
|
+
if (constructor === Map) return areMapsEqual$1(a, b, state);
|
|
582
|
+
if (constructor === Set) return areSetsEqual$1(a, b, state);
|
|
583
|
+
var tag = getTag(a);
|
|
584
|
+
if (tag === DATE_TAG) return areDatesEqual$1(a, b, state);
|
|
585
|
+
if (tag === REG_EXP_TAG) return areRegExpsEqual$1(a, b, state);
|
|
586
|
+
if (tag === MAP_TAG) return areMapsEqual$1(a, b, state);
|
|
587
|
+
if (tag === SET_TAG) return areSetsEqual$1(a, b, state);
|
|
588
|
+
if (tag === OBJECT_TAG) return typeof a.then !== "function" && typeof b.then !== "function" && areObjectsEqual$1(a, b, state);
|
|
589
|
+
if (tag === URL_TAG) return areUrlsEqual$1(a, b, state);
|
|
590
|
+
if (tag === ERROR_TAG) return areErrorsEqual$1(a, b, state);
|
|
591
|
+
if (tag === ARGUMENTS_TAG) return areObjectsEqual$1(a, b, state);
|
|
592
|
+
if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) return arePrimitiveWrappersEqual$1(a, b, state);
|
|
593
|
+
return false;
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* Create the configuration object used for building comparators.
|
|
598
|
+
*/
|
|
599
|
+
function createEqualityComparatorConfig(_a) {
|
|
600
|
+
var circular = _a.circular, createCustomConfig = _a.createCustomConfig, strict = _a.strict;
|
|
601
|
+
var config = {
|
|
602
|
+
areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,
|
|
603
|
+
areDatesEqual,
|
|
604
|
+
areErrorsEqual,
|
|
605
|
+
areFunctionsEqual,
|
|
606
|
+
areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,
|
|
607
|
+
areNumbersEqual,
|
|
608
|
+
areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,
|
|
609
|
+
arePrimitiveWrappersEqual,
|
|
610
|
+
areRegExpsEqual,
|
|
611
|
+
areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,
|
|
612
|
+
areTypedArraysEqual: strict ? areObjectsEqualStrict : areTypedArraysEqual,
|
|
613
|
+
areUrlsEqual
|
|
614
|
+
};
|
|
615
|
+
if (createCustomConfig) config = assign({}, config, createCustomConfig(config));
|
|
616
|
+
if (circular) {
|
|
617
|
+
var areArraysEqual$1 = createIsCircular(config.areArraysEqual);
|
|
618
|
+
var areMapsEqual$1 = createIsCircular(config.areMapsEqual);
|
|
619
|
+
var areObjectsEqual$1 = createIsCircular(config.areObjectsEqual);
|
|
620
|
+
var areSetsEqual$1 = createIsCircular(config.areSetsEqual);
|
|
621
|
+
config = assign({}, config, {
|
|
622
|
+
areArraysEqual: areArraysEqual$1,
|
|
623
|
+
areMapsEqual: areMapsEqual$1,
|
|
624
|
+
areObjectsEqual: areObjectsEqual$1,
|
|
625
|
+
areSetsEqual: areSetsEqual$1
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
return config;
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Default equality comparator pass-through, used as the standard `isEqual` creator for
|
|
632
|
+
* use inside the built comparator.
|
|
633
|
+
*/
|
|
634
|
+
function createInternalEqualityComparator(compare) {
|
|
635
|
+
return function(a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {
|
|
636
|
+
return compare(a, b, state);
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* Create the `isEqual` function used by the consuming application.
|
|
641
|
+
*/
|
|
642
|
+
function createIsEqual(_a) {
|
|
643
|
+
var circular = _a.circular, comparator = _a.comparator, createState = _a.createState, equals = _a.equals, strict = _a.strict;
|
|
644
|
+
if (createState) return function isEqual(a, b) {
|
|
645
|
+
var _a$1 = createState(), _b = _a$1.cache, cache = _b === void 0 ? circular ? /* @__PURE__ */ new WeakMap() : void 0 : _b, meta = _a$1.meta;
|
|
646
|
+
return comparator(a, b, {
|
|
647
|
+
cache,
|
|
648
|
+
equals,
|
|
649
|
+
meta,
|
|
650
|
+
strict
|
|
651
|
+
});
|
|
652
|
+
};
|
|
653
|
+
if (circular) return function isEqual(a, b) {
|
|
654
|
+
return comparator(a, b, {
|
|
655
|
+
cache: /* @__PURE__ */ new WeakMap(),
|
|
656
|
+
equals,
|
|
657
|
+
meta: void 0,
|
|
658
|
+
strict
|
|
659
|
+
});
|
|
660
|
+
};
|
|
661
|
+
var state = {
|
|
662
|
+
cache: void 0,
|
|
663
|
+
equals,
|
|
664
|
+
meta: void 0,
|
|
665
|
+
strict
|
|
666
|
+
};
|
|
667
|
+
return function isEqual(a, b) {
|
|
668
|
+
return comparator(a, b, state);
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Whether the items passed are deeply-equal in value.
|
|
673
|
+
*/
|
|
674
|
+
var deepEqual = createCustomEqual();
|
|
675
|
+
/**
|
|
676
|
+
* Whether the items passed are deeply-equal in value based on strict comparison.
|
|
677
|
+
*/
|
|
678
|
+
var strictDeepEqual = createCustomEqual({ strict: true });
|
|
679
|
+
/**
|
|
680
|
+
* Whether the items passed are deeply-equal in value, including circular references.
|
|
681
|
+
*/
|
|
682
|
+
var circularDeepEqual = createCustomEqual({ circular: true });
|
|
683
|
+
/**
|
|
684
|
+
* Whether the items passed are deeply-equal in value, including circular references,
|
|
685
|
+
* based on strict comparison.
|
|
686
|
+
*/
|
|
687
|
+
var strictCircularDeepEqual = createCustomEqual({
|
|
688
|
+
circular: true,
|
|
689
|
+
strict: true
|
|
690
|
+
});
|
|
691
|
+
/**
|
|
692
|
+
* Whether the items passed are shallowly-equal in value.
|
|
693
|
+
*/
|
|
694
|
+
var shallowEqual = createCustomEqual({ createInternalComparator: function() {
|
|
695
|
+
return sameValueZeroEqual;
|
|
696
|
+
} });
|
|
697
|
+
/**
|
|
698
|
+
* Whether the items passed are shallowly-equal in value based on strict comparison
|
|
699
|
+
*/
|
|
700
|
+
var strictShallowEqual = createCustomEqual({
|
|
701
|
+
strict: true,
|
|
702
|
+
createInternalComparator: function() {
|
|
703
|
+
return sameValueZeroEqual;
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
/**
|
|
707
|
+
* Whether the items passed are shallowly-equal in value, including circular references.
|
|
708
|
+
*/
|
|
709
|
+
var circularShallowEqual = createCustomEqual({
|
|
710
|
+
circular: true,
|
|
711
|
+
createInternalComparator: function() {
|
|
712
|
+
return sameValueZeroEqual;
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
/**
|
|
716
|
+
* Whether the items passed are shallowly-equal in value, including circular references,
|
|
717
|
+
* based on strict comparison.
|
|
718
|
+
*/
|
|
719
|
+
var strictCircularShallowEqual = createCustomEqual({
|
|
720
|
+
circular: true,
|
|
721
|
+
createInternalComparator: function() {
|
|
722
|
+
return sameValueZeroEqual;
|
|
723
|
+
},
|
|
724
|
+
strict: true
|
|
725
|
+
});
|
|
726
|
+
/**
|
|
727
|
+
* Create a custom equality comparison method.
|
|
728
|
+
*
|
|
729
|
+
* This can be done to create very targeted comparisons in extreme hot-path scenarios
|
|
730
|
+
* where the standard methods are not performant enough, but can also be used to provide
|
|
731
|
+
* support for legacy environments that do not support expected features like
|
|
732
|
+
* `RegExp.prototype.flags` out of the box.
|
|
733
|
+
*/
|
|
734
|
+
function createCustomEqual(options) {
|
|
735
|
+
if (options === void 0) options = {};
|
|
736
|
+
var _a = options.circular, circular = _a === void 0 ? false : _a, createCustomInternalComparator = options.createInternalComparator, createState = options.createState, _b = options.strict, strict = _b === void 0 ? false : _b;
|
|
737
|
+
var comparator = createEqualityComparator(createEqualityComparatorConfig(options));
|
|
738
|
+
return createIsEqual({
|
|
739
|
+
circular,
|
|
740
|
+
comparator,
|
|
741
|
+
createState,
|
|
742
|
+
equals: createCustomInternalComparator ? createCustomInternalComparator(comparator) : createInternalEqualityComparator(comparator),
|
|
743
|
+
strict
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region ../core/dist/schema/index.js
|
|
749
|
+
var import_dayjs_min = /* @__PURE__ */ __toESM(require_dayjs_min(), 1);
|
|
750
|
+
const workflowEdgeSchema = z$1.discriminatedUnion("type", [z$1.object({
|
|
751
|
+
type: z$1.literal("flow"),
|
|
752
|
+
from: z$1.string(),
|
|
753
|
+
to: z$1.string()
|
|
754
|
+
}), z$1.object({
|
|
755
|
+
type: z$1.literal("branch"),
|
|
756
|
+
from: z$1.string(),
|
|
757
|
+
targetMap: z$1.record(z$1.string(), z$1.string())
|
|
758
|
+
})]);
|
|
759
|
+
const agentWorkflowSchema = z$1.object({
|
|
760
|
+
nodes: z$1.string().array(),
|
|
761
|
+
edges: workflowEdgeSchema.array()
|
|
762
|
+
});
|
|
763
|
+
const primitiveSchema = z$1.union([
|
|
764
|
+
z$1.string(),
|
|
765
|
+
z$1.number(),
|
|
766
|
+
z$1.boolean(),
|
|
767
|
+
z$1.bigint()
|
|
768
|
+
]);
|
|
769
|
+
const dataRecord = z$1.record(z$1.string(), primitiveSchema.nullable().optional());
|
|
770
|
+
const chartDataItemSchema = z$1.record(z$1.string(), z$1.any());
|
|
771
|
+
const chartDataSchema = chartDataItemSchema.array();
|
|
772
|
+
const colorString = z$1.string().refine((value) => {
|
|
773
|
+
const color = value.trim().toLowerCase();
|
|
774
|
+
return /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(color) || /^rgba?\(\s*(\d+(?:\.\d+)?%?)\s*,\s*(\d+(?:\.\d+)?%?)\s*,\s*(\d+(?:\.\d+)?%?)(?:\s*,\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color) || /^hsla?\(\s*(\d+(?:\.\d+)?(?:deg|grad|rad|turn)?)\s*,\s*(\d+(?:\.\d+)?%)\s*,\s*(\d+(?:\.\d+)?%)(?:\s*,\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color) || /^oklch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s*\/\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color) || /^oklab\(\s*(\d+(?:\.\d+)?%?)\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)(?:\s*\/\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color) || /^lab\(\s*(\d+(?:\.\d+)?%?)\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)(?:\s*\/\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color) || /^lch\(\s*(\d+(?:\.\d+)?%?)\s+(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)(?:\s*\/\s*(\d+(?:\.\d+)?%?))?\s*\)$/.test(color);
|
|
775
|
+
});
|
|
776
|
+
const availableColors = z$1.enum([
|
|
777
|
+
"blue",
|
|
778
|
+
"emerald",
|
|
779
|
+
"violet",
|
|
780
|
+
"amber",
|
|
781
|
+
"gray",
|
|
782
|
+
"cyan",
|
|
783
|
+
"pink",
|
|
784
|
+
"lime",
|
|
785
|
+
"fuchsia",
|
|
786
|
+
"red",
|
|
787
|
+
"green",
|
|
788
|
+
"yellow"
|
|
789
|
+
]);
|
|
790
|
+
const chartColor = z$1.union([availableColors, colorString]);
|
|
791
|
+
const baseChartSchema = z$1.object({
|
|
792
|
+
type: z$1.literal("chart"),
|
|
793
|
+
title: z$1.string().optional(),
|
|
794
|
+
description: z$1.string().optional()
|
|
795
|
+
});
|
|
796
|
+
const valueFormatSchema = z$1.object({
|
|
797
|
+
type: z$1.enum([
|
|
798
|
+
"number",
|
|
799
|
+
"currency",
|
|
800
|
+
"percentage"
|
|
801
|
+
]).optional().default("number").describe("Type of value formatting to apply"),
|
|
802
|
+
decimals: z$1.number().min(0).max(10).optional().default(0).describe("Precision control"),
|
|
803
|
+
currency: z$1.string().optional().default("USD"),
|
|
804
|
+
currencyDisplay: z$1.enum([
|
|
805
|
+
"symbol",
|
|
806
|
+
"code",
|
|
807
|
+
"name"
|
|
808
|
+
]).optional().default("symbol"),
|
|
809
|
+
thousandsSeparator: z$1.string().optional().default(","),
|
|
810
|
+
decimalSeparator: z$1.string().optional().default("."),
|
|
811
|
+
prefix: z$1.string().optional(),
|
|
812
|
+
suffix: z$1.string().optional(),
|
|
813
|
+
showPercentageSymbol: z$1.boolean().optional().default(true),
|
|
814
|
+
locale: z$1.string().optional().default("en-US"),
|
|
815
|
+
notation: z$1.enum(["standard", "compact"]).optional().default("standard")
|
|
816
|
+
});
|
|
817
|
+
const areaChartSchema = baseChartSchema.extend({
|
|
818
|
+
chartType: z$1.literal("area-chart"),
|
|
819
|
+
data: chartDataSchema,
|
|
820
|
+
index: z$1.string().describe("key of the data object to map the data to the x axis"),
|
|
821
|
+
categories: z$1.string().array().describe("select the categories from your data"),
|
|
822
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
823
|
+
xAxisLabel: z$1.string().optional(),
|
|
824
|
+
yAxisLabel: z$1.string().optional(),
|
|
825
|
+
fillType: z$1.enum([
|
|
826
|
+
"gradient",
|
|
827
|
+
"solid",
|
|
828
|
+
"none"
|
|
829
|
+
]).optional().default("gradient"),
|
|
830
|
+
stackType: z$1.enum([
|
|
831
|
+
"default",
|
|
832
|
+
"stacked",
|
|
833
|
+
"percent"
|
|
834
|
+
]).optional().default("default"),
|
|
835
|
+
intervalType: z$1.enum(["equidistantPreserveStart", "preserveStartEnd"]).optional().describe("Controls the interval logic of x-axis and how ticks and labels are placed").default("equidistantPreserveStart"),
|
|
836
|
+
startEndOnly: z$1.boolean().optional().default(false),
|
|
837
|
+
showXAxis: z$1.boolean().optional().default(true),
|
|
838
|
+
showYAxis: z$1.boolean().optional().default(true),
|
|
839
|
+
showGridLines: z$1.boolean().optional().default(true),
|
|
840
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
841
|
+
showLegend: z$1.boolean().optional().default(true),
|
|
842
|
+
valueFormat: valueFormatSchema.optional()
|
|
843
|
+
});
|
|
844
|
+
const barChartSchema = baseChartSchema.extend({
|
|
845
|
+
chartType: z$1.literal("bar-chart"),
|
|
846
|
+
data: chartDataSchema,
|
|
847
|
+
index: z$1.string().describe("key of the data object to map the data to the x axis"),
|
|
848
|
+
categories: z$1.string().array().describe("select the categories from your data"),
|
|
849
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
850
|
+
xAxisLabel: z$1.string().optional(),
|
|
851
|
+
yAxisLabel: z$1.string().optional(),
|
|
852
|
+
stackType: z$1.enum([
|
|
853
|
+
"default",
|
|
854
|
+
"stacked",
|
|
855
|
+
"percent"
|
|
856
|
+
]).optional().default("default"),
|
|
857
|
+
startEndOnly: z$1.boolean().optional().default(false),
|
|
858
|
+
intervalType: z$1.enum(["equidistantPreserveStart", "preserveStartEnd"]).optional().describe("Controls the interval logic of x-axis and how ticks and labels are placed").default("equidistantPreserveStart"),
|
|
859
|
+
showXAxis: z$1.boolean().optional().default(true),
|
|
860
|
+
showYAxis: z$1.boolean().optional().default(true),
|
|
861
|
+
showGridLines: z$1.boolean().optional().default(true),
|
|
862
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
863
|
+
showLegend: z$1.boolean().optional().default(true),
|
|
864
|
+
valueFormat: valueFormatSchema.optional(),
|
|
865
|
+
layout: z$1.enum(["horizontal", "vertical"]).optional().default("horizontal")
|
|
866
|
+
});
|
|
867
|
+
const barListSchema = baseChartSchema.extend({
|
|
868
|
+
chartType: z$1.literal("bar-list"),
|
|
869
|
+
data: z$1.object({
|
|
870
|
+
value: z$1.number(),
|
|
871
|
+
name: z$1.string()
|
|
872
|
+
}).array(),
|
|
873
|
+
sortOrder: z$1.enum([
|
|
874
|
+
"ascending",
|
|
875
|
+
"descending",
|
|
876
|
+
"none"
|
|
877
|
+
]).optional().default("descending"),
|
|
878
|
+
color: chartColor.optional().default("blue")
|
|
879
|
+
});
|
|
880
|
+
const categoryBarSchema = baseChartSchema.extend({
|
|
881
|
+
chartType: z$1.literal("category-bar"),
|
|
882
|
+
values: z$1.object({
|
|
883
|
+
value: z$1.number(),
|
|
884
|
+
label: z$1.string()
|
|
885
|
+
}).or(z$1.number()).array(),
|
|
886
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
887
|
+
marker: z$1.object({
|
|
888
|
+
value: z$1.number(),
|
|
889
|
+
name: z$1.string().optional()
|
|
890
|
+
}).optional(),
|
|
891
|
+
showLegend: z$1.boolean().optional().default(false),
|
|
892
|
+
showLabel: z$1.boolean().optional().default(true)
|
|
893
|
+
});
|
|
894
|
+
const donutChartSchema = baseChartSchema.extend({
|
|
895
|
+
chartType: z$1.literal("donut-chart"),
|
|
896
|
+
data: chartDataSchema,
|
|
897
|
+
category: z$1.string().describe("key of the data object to map the data to the categories"),
|
|
898
|
+
value: z$1.string().describe("select the value from your data"),
|
|
899
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
900
|
+
variant: z$1.enum(["donut", "pie"]).optional().default("donut"),
|
|
901
|
+
label: z$1.string().optional(),
|
|
902
|
+
showLabel: z$1.boolean().optional().default(false),
|
|
903
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
904
|
+
valueFormat: valueFormatSchema.optional()
|
|
905
|
+
});
|
|
906
|
+
const lineChartSchema = baseChartSchema.extend({
|
|
907
|
+
chartType: z$1.literal("line-chart"),
|
|
908
|
+
data: chartDataSchema,
|
|
909
|
+
index: z$1.string().describe("key of the data object to map the data to the x axis"),
|
|
910
|
+
categories: z$1.string().array().describe("select the categories from your data"),
|
|
911
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
912
|
+
xAxisLabel: z$1.string().optional(),
|
|
913
|
+
yAxisLabel: z$1.string().optional(),
|
|
914
|
+
intervalType: z$1.enum(["equidistantPreserveStart", "preserveStartEnd"]).optional().describe("Controls the interval logic of x-axis and how ticks and labels are placed").default("equidistantPreserveStart"),
|
|
915
|
+
startEndOnly: z$1.boolean().optional().default(false),
|
|
916
|
+
showXAxis: z$1.boolean().optional().default(true),
|
|
917
|
+
showYAxis: z$1.boolean().optional().default(true),
|
|
918
|
+
showGridLines: z$1.boolean().optional().default(true),
|
|
919
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
920
|
+
showLegend: z$1.boolean().optional().default(true),
|
|
921
|
+
valueFormat: valueFormatSchema.optional()
|
|
922
|
+
});
|
|
923
|
+
const progressBarSchema = baseChartSchema.extend({
|
|
924
|
+
chartType: z$1.literal("progress-bar"),
|
|
925
|
+
value: z$1.number(),
|
|
926
|
+
max: z$1.number(),
|
|
927
|
+
label: z$1.string().or(z$1.number()).optional(),
|
|
928
|
+
variant: z$1.enum([
|
|
929
|
+
"default",
|
|
930
|
+
"neutral",
|
|
931
|
+
"warning",
|
|
932
|
+
"error",
|
|
933
|
+
"success"
|
|
934
|
+
]).optional().default("default")
|
|
935
|
+
});
|
|
936
|
+
const progressCircleSchema = baseChartSchema.extend({
|
|
937
|
+
chartType: z$1.literal("progress-circle"),
|
|
938
|
+
value: z$1.number(),
|
|
939
|
+
max: z$1.number(),
|
|
940
|
+
radius: z$1.number().optional().default(32),
|
|
941
|
+
variant: z$1.enum([
|
|
942
|
+
"default",
|
|
943
|
+
"neutral",
|
|
944
|
+
"warning",
|
|
945
|
+
"error",
|
|
946
|
+
"success"
|
|
947
|
+
]).optional().default("default")
|
|
948
|
+
});
|
|
949
|
+
const sparkChartSchema = baseChartSchema.extend({
|
|
950
|
+
chartType: z$1.literal("spark-chart"),
|
|
951
|
+
data: chartDataSchema,
|
|
952
|
+
index: z$1.string().describe("key of the data object to map the data to the x axis"),
|
|
953
|
+
categories: z$1.string().array().describe("select the categories from your data"),
|
|
954
|
+
colors: chartColor.array().optional().default(["blue"]),
|
|
955
|
+
fillType: z$1.enum([
|
|
956
|
+
"gradient",
|
|
957
|
+
"solid",
|
|
958
|
+
"none"
|
|
959
|
+
]).optional().default("gradient"),
|
|
960
|
+
stackType: z$1.enum([
|
|
961
|
+
"default",
|
|
962
|
+
"stacked",
|
|
963
|
+
"percent"
|
|
964
|
+
]).optional().default("default"),
|
|
965
|
+
sparkChartType: z$1.enum([
|
|
966
|
+
"bar",
|
|
967
|
+
"area",
|
|
968
|
+
"line"
|
|
969
|
+
]).optional().default("area")
|
|
970
|
+
});
|
|
971
|
+
const trackerSchema = baseChartSchema.extend({
|
|
972
|
+
chartType: z$1.literal("tracker"),
|
|
973
|
+
data: z$1.object({
|
|
974
|
+
name: z$1.string(),
|
|
975
|
+
color: chartColor.optional().default("blue")
|
|
976
|
+
}).array(),
|
|
977
|
+
defaultBackgroundColor: chartColor.optional().default("gray")
|
|
978
|
+
});
|
|
979
|
+
const comboChartSchema = baseChartSchema.extend({
|
|
980
|
+
chartType: z$1.literal("combo-chart"),
|
|
981
|
+
data: chartDataSchema,
|
|
982
|
+
index: z$1.string().describe("key of the data object to map the data to the x axis"),
|
|
983
|
+
xAxisLabel: z$1.string().optional(),
|
|
984
|
+
showXAxis: z$1.boolean().optional().default(true),
|
|
985
|
+
showGridLines: z$1.boolean().optional().default(true),
|
|
986
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
987
|
+
showLegend: z$1.boolean().optional().default(true),
|
|
988
|
+
barSeries: barChartSchema.omit({
|
|
989
|
+
type: true,
|
|
990
|
+
chartType: true,
|
|
991
|
+
index: true,
|
|
992
|
+
data: true,
|
|
993
|
+
title: true,
|
|
994
|
+
description: true,
|
|
995
|
+
xAxisLabel: true,
|
|
996
|
+
showXAxis: true,
|
|
997
|
+
intervalType: true,
|
|
998
|
+
startEndOnly: true,
|
|
999
|
+
showGridLines: true
|
|
1000
|
+
}).extend({ stackType: z$1.enum(["default", "stacked"]).optional().default("default") }),
|
|
1001
|
+
lineSeries: lineChartSchema.omit({
|
|
1002
|
+
type: true,
|
|
1003
|
+
chartType: true,
|
|
1004
|
+
index: true,
|
|
1005
|
+
data: true,
|
|
1006
|
+
title: true,
|
|
1007
|
+
description: true,
|
|
1008
|
+
xAxisLabel: true,
|
|
1009
|
+
showXAxis: true,
|
|
1010
|
+
intervalType: true,
|
|
1011
|
+
startEndOnly: true,
|
|
1012
|
+
showGridLines: true
|
|
1013
|
+
}),
|
|
1014
|
+
startEndOnly: z$1.boolean().optional().default(false),
|
|
1015
|
+
intervalType: z$1.enum(["equidistantPreserveStart", "preserveStartEnd"]).optional().describe("Controls the interval logic of x-axis and how ticks and labels are placed").default("equidistantPreserveStart")
|
|
1016
|
+
});
|
|
1017
|
+
const predefinedColorScalesSchema = z$1.enum([
|
|
1018
|
+
"Blues",
|
|
1019
|
+
"BrBG",
|
|
1020
|
+
"BuGn",
|
|
1021
|
+
"BuPu",
|
|
1022
|
+
"Cividis",
|
|
1023
|
+
"Cool",
|
|
1024
|
+
"GnBu",
|
|
1025
|
+
"Greens",
|
|
1026
|
+
"Greys",
|
|
1027
|
+
"Inferno",
|
|
1028
|
+
"Magma",
|
|
1029
|
+
"Oranges",
|
|
1030
|
+
"OrRd",
|
|
1031
|
+
"PiYG",
|
|
1032
|
+
"Plasma",
|
|
1033
|
+
"PRGn",
|
|
1034
|
+
"PuBu",
|
|
1035
|
+
"PuBuGn",
|
|
1036
|
+
"PuOr",
|
|
1037
|
+
"PuRd",
|
|
1038
|
+
"Purples",
|
|
1039
|
+
"Rainbow",
|
|
1040
|
+
"RdBu",
|
|
1041
|
+
"RdGy",
|
|
1042
|
+
"RdPu",
|
|
1043
|
+
"RdYlBu",
|
|
1044
|
+
"RdYlGn",
|
|
1045
|
+
"Reds",
|
|
1046
|
+
"Sinebow",
|
|
1047
|
+
"Spectral",
|
|
1048
|
+
"Turbo",
|
|
1049
|
+
"Viridis",
|
|
1050
|
+
"Warm",
|
|
1051
|
+
"YlGn",
|
|
1052
|
+
"YlGnBu",
|
|
1053
|
+
"YlOrBr",
|
|
1054
|
+
"YlOrRd"
|
|
1055
|
+
]);
|
|
1056
|
+
const interpolateColorScaleSchema = z$1.object({
|
|
1057
|
+
min: chartColor,
|
|
1058
|
+
max: chartColor
|
|
1059
|
+
});
|
|
1060
|
+
const colorScaleSchema = z$1.union([predefinedColorScalesSchema, interpolateColorScaleSchema]).describe("Type of color scale to use for mapping values to colors");
|
|
1061
|
+
const heatmapChartSchema = baseChartSchema.extend({
|
|
1062
|
+
chartType: z$1.literal("heatmap-chart"),
|
|
1063
|
+
data: chartDataSchema,
|
|
1064
|
+
xAxis: z$1.string().describe("key of the data object to map to the x-axis (columns)"),
|
|
1065
|
+
yAxis: z$1.string().array().describe("key(s) of the data object to map to the y-axis (rows) - can be single field or multiple fields"),
|
|
1066
|
+
colorScale: colorScaleSchema.optional().default("Oranges"),
|
|
1067
|
+
xAxisLabel: z$1.string().optional(),
|
|
1068
|
+
yAxisLabel: z$1.string().optional(),
|
|
1069
|
+
showXAxis: z$1.boolean().optional().default(true),
|
|
1070
|
+
showYAxis: z$1.boolean().optional().default(true),
|
|
1071
|
+
showTooltip: z$1.boolean().optional().default(true),
|
|
1072
|
+
showLegend: z$1.boolean().optional().default(true),
|
|
1073
|
+
showValues: z$1.boolean().optional().default(false),
|
|
1074
|
+
valueFormat: valueFormatSchema.optional()
|
|
1075
|
+
});
|
|
1076
|
+
const chartBlock = z$1.discriminatedUnion("chartType", [
|
|
1077
|
+
areaChartSchema,
|
|
1078
|
+
barChartSchema,
|
|
1079
|
+
comboChartSchema,
|
|
1080
|
+
barListSchema,
|
|
1081
|
+
categoryBarSchema,
|
|
1082
|
+
donutChartSchema,
|
|
1083
|
+
lineChartSchema,
|
|
1084
|
+
progressBarSchema,
|
|
1085
|
+
progressCircleSchema,
|
|
1086
|
+
sparkChartSchema,
|
|
1087
|
+
trackerSchema,
|
|
1088
|
+
heatmapChartSchema
|
|
1089
|
+
]);
|
|
1090
|
+
const kpiCardChart = z$1.discriminatedUnion("chartType", [
|
|
1091
|
+
categoryBarSchema.omit({
|
|
1092
|
+
title: true,
|
|
1093
|
+
description: true
|
|
1094
|
+
}),
|
|
1095
|
+
progressBarSchema.omit({
|
|
1096
|
+
title: true,
|
|
1097
|
+
description: true
|
|
1098
|
+
}),
|
|
1099
|
+
progressCircleSchema.omit({
|
|
1100
|
+
title: true,
|
|
1101
|
+
description: true
|
|
1102
|
+
}),
|
|
1103
|
+
sparkChartSchema.omit({
|
|
1104
|
+
title: true,
|
|
1105
|
+
description: true
|
|
1106
|
+
}),
|
|
1107
|
+
trackerSchema.omit({
|
|
1108
|
+
title: true,
|
|
1109
|
+
description: true
|
|
1110
|
+
})
|
|
1111
|
+
]);
|
|
1112
|
+
const kpiCardSchema = z$1.object({
|
|
1113
|
+
type: z$1.literal("kpi-card"),
|
|
1114
|
+
name: z$1.string(),
|
|
1115
|
+
value: z$1.number().or(z$1.string()),
|
|
1116
|
+
valueFormat: valueFormatSchema.optional(),
|
|
1117
|
+
change: z$1.number().or(z$1.string()).optional(),
|
|
1118
|
+
changeType: z$1.enum([
|
|
1119
|
+
"positive",
|
|
1120
|
+
"negative",
|
|
1121
|
+
"neutral"
|
|
1122
|
+
]).optional(),
|
|
1123
|
+
chart: kpiCardChart.optional()
|
|
1124
|
+
});
|
|
1125
|
+
const tableRenderConfigSchema = z$1.discriminatedUnion("type", [
|
|
1126
|
+
z$1.object({ type: z$1.literal("default") }),
|
|
1127
|
+
z$1.object({
|
|
1128
|
+
type: z$1.literal("badge"),
|
|
1129
|
+
variant: z$1.enum([
|
|
1130
|
+
"default",
|
|
1131
|
+
"neutral",
|
|
1132
|
+
"warning",
|
|
1133
|
+
"error",
|
|
1134
|
+
"success"
|
|
1135
|
+
]).optional().default("default")
|
|
1136
|
+
}),
|
|
1137
|
+
z$1.object({
|
|
1138
|
+
type: z$1.literal("image"),
|
|
1139
|
+
width: z$1.number().optional().default(40),
|
|
1140
|
+
height: z$1.number().optional().default(40),
|
|
1141
|
+
fit: z$1.enum([
|
|
1142
|
+
"cover",
|
|
1143
|
+
"contain",
|
|
1144
|
+
"fill"
|
|
1145
|
+
]).optional().default("cover")
|
|
1146
|
+
}),
|
|
1147
|
+
z$1.object({
|
|
1148
|
+
type: z$1.literal("progress"),
|
|
1149
|
+
chartType: z$1.enum(["bar", "circle"]).optional().default("bar"),
|
|
1150
|
+
maxValue: z$1.number(),
|
|
1151
|
+
variant: z$1.enum([
|
|
1152
|
+
"default",
|
|
1153
|
+
"neutral",
|
|
1154
|
+
"warning",
|
|
1155
|
+
"error",
|
|
1156
|
+
"success"
|
|
1157
|
+
]).optional().default("default")
|
|
1158
|
+
}),
|
|
1159
|
+
z$1.object({
|
|
1160
|
+
type: z$1.literal("link"),
|
|
1161
|
+
target: z$1.enum(["_blank", "_self"]).optional().default("_blank")
|
|
1162
|
+
})
|
|
1163
|
+
]);
|
|
1164
|
+
const tableColumnSchema = z$1.object({
|
|
1165
|
+
key: z$1.string(),
|
|
1166
|
+
label: z$1.string().optional().describe("display name for the column header"),
|
|
1167
|
+
dataType: z$1.enum([
|
|
1168
|
+
"string",
|
|
1169
|
+
"number",
|
|
1170
|
+
"boolean",
|
|
1171
|
+
"date"
|
|
1172
|
+
]).optional(),
|
|
1173
|
+
sortable: z$1.boolean().optional().default(true),
|
|
1174
|
+
filterable: z$1.boolean().optional().default(true),
|
|
1175
|
+
align: z$1.enum([
|
|
1176
|
+
"left",
|
|
1177
|
+
"center",
|
|
1178
|
+
"right"
|
|
1179
|
+
]).optional().default("left"),
|
|
1180
|
+
valueFormat: valueFormatSchema.optional(),
|
|
1181
|
+
renderConfig: tableRenderConfigSchema.optional().default({ type: "default" }),
|
|
1182
|
+
size: z$1.number().optional(),
|
|
1183
|
+
maxSize: z$1.number().optional()
|
|
1184
|
+
});
|
|
1185
|
+
const tableBlockSchema = z$1.object({
|
|
1186
|
+
type: z$1.literal("table"),
|
|
1187
|
+
title: z$1.string().optional(),
|
|
1188
|
+
description: z$1.string().optional(),
|
|
1189
|
+
data: z$1.record(z$1.string(), z$1.unknown()).array(),
|
|
1190
|
+
columns: tableColumnSchema.array().optional().describe("column configuration - if not provided, autogenrated from data")
|
|
1191
|
+
});
|
|
1192
|
+
const imageBlockSchema = z$1.object({
|
|
1193
|
+
type: z$1.literal("image"),
|
|
1194
|
+
url: z$1.string().optional(),
|
|
1195
|
+
buffer: z$1.instanceof(Uint8Array).or(z$1.number().array().transform((val) => new Uint8Array(val))).or(z$1.record(z$1.string(), z$1.number()).transform((val) => {
|
|
1196
|
+
const arr = Array.from({
|
|
1197
|
+
...val,
|
|
1198
|
+
length: Object.keys(val).length
|
|
1199
|
+
});
|
|
1200
|
+
return new Uint8Array(arr);
|
|
1201
|
+
})).or(z$1.string().transform((value) => {
|
|
1202
|
+
const binaryString = atob(value);
|
|
1203
|
+
return Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
|
|
1204
|
+
})).optional(),
|
|
1205
|
+
fit: z$1.enum([
|
|
1206
|
+
"cover",
|
|
1207
|
+
"contain",
|
|
1208
|
+
"fill"
|
|
1209
|
+
]).optional().default("cover"),
|
|
1210
|
+
width: z$1.number().or(z$1.literal("auto")).optional().default(400),
|
|
1211
|
+
height: z$1.number().or(z$1.literal("auto")).optional().default("auto"),
|
|
1212
|
+
aspectRatio: z$1.number().optional(),
|
|
1213
|
+
alt: z$1.string().optional()
|
|
1214
|
+
}).refine((value) => value.url || value.buffer, "either url or buffer should be present");
|
|
1215
|
+
const textBlockSchema = z$1.object({
|
|
1216
|
+
type: z$1.literal("text"),
|
|
1217
|
+
content: z$1.string()
|
|
1218
|
+
});
|
|
1219
|
+
const objectBlockSchema = z$1.object({
|
|
1220
|
+
type: z$1.literal("object"),
|
|
1221
|
+
data: dataRecord,
|
|
1222
|
+
title: z$1.string().optional(),
|
|
1223
|
+
description: z$1.string().optional()
|
|
1224
|
+
});
|
|
1225
|
+
const layoutChildren = z$1.object({
|
|
1226
|
+
get element() {
|
|
1227
|
+
return blockSchema;
|
|
1228
|
+
},
|
|
1229
|
+
colSpan: z$1.number().optional().default(4),
|
|
1230
|
+
rowSpan: z$1.number().optional().default(1)
|
|
1231
|
+
});
|
|
1232
|
+
const layoutBlockSchema = z$1.object({
|
|
1233
|
+
type: z$1.literal("layout"),
|
|
1234
|
+
columns: z$1.number().optional().default(12),
|
|
1235
|
+
children: layoutChildren.array()
|
|
1236
|
+
});
|
|
1237
|
+
const blockSchema = z$1.discriminatedUnion("type", [
|
|
1238
|
+
kpiCardSchema,
|
|
1239
|
+
chartBlock,
|
|
1240
|
+
layoutBlockSchema,
|
|
1241
|
+
tableBlockSchema,
|
|
1242
|
+
imageBlockSchema,
|
|
1243
|
+
textBlockSchema,
|
|
1244
|
+
objectBlockSchema
|
|
1245
|
+
]);
|
|
1246
|
+
const forgeItemSchema = z$1.object({
|
|
1247
|
+
type: z$1.enum([
|
|
1248
|
+
"TOOL",
|
|
1249
|
+
"DIRECTORY",
|
|
1250
|
+
"AGENT"
|
|
1251
|
+
]),
|
|
1252
|
+
id: z$1.string(),
|
|
1253
|
+
name: z$1.string(),
|
|
1254
|
+
description: z$1.string().optional(),
|
|
1255
|
+
parent: z$1.string().optional(),
|
|
1256
|
+
depth: z$1.number()
|
|
1257
|
+
});
|
|
1258
|
+
const baseFormField = z$1.object({
|
|
1259
|
+
label: z$1.string(),
|
|
1260
|
+
description: z$1.string().optional(),
|
|
1261
|
+
optional: z$1.boolean().optional()
|
|
1262
|
+
});
|
|
1263
|
+
const textInputField = baseFormField.extend({
|
|
1264
|
+
type: z$1.literal("text"),
|
|
1265
|
+
secure: z$1.boolean().optional(),
|
|
1266
|
+
mode: z$1.enum(["input", "textarea"]).optional(),
|
|
1267
|
+
inputType: z$1.enum(["email", "url"]).optional(),
|
|
1268
|
+
min: z$1.number().optional(),
|
|
1269
|
+
max: z$1.number().optional()
|
|
1270
|
+
});
|
|
1271
|
+
const numberInputField = baseFormField.extend({
|
|
1272
|
+
type: z$1.literal("number"),
|
|
1273
|
+
min: z$1.number().optional(),
|
|
1274
|
+
max: z$1.number().optional()
|
|
1275
|
+
});
|
|
1276
|
+
const dateInputField = baseFormField.extend({
|
|
1277
|
+
type: z$1.literal("date"),
|
|
1278
|
+
min: z$1.iso.datetime().optional(),
|
|
1279
|
+
max: z$1.iso.datetime().optional(),
|
|
1280
|
+
mode: z$1.enum([
|
|
1281
|
+
"single",
|
|
1282
|
+
"multiple",
|
|
1283
|
+
"range"
|
|
1284
|
+
]).optional()
|
|
1285
|
+
});
|
|
1286
|
+
const selectOptionValue = z$1.union([
|
|
1287
|
+
z$1.string(),
|
|
1288
|
+
z$1.number(),
|
|
1289
|
+
z$1.boolean()
|
|
1290
|
+
]);
|
|
1291
|
+
const selectOption = z$1.object({
|
|
1292
|
+
label: z$1.string(),
|
|
1293
|
+
description: z$1.string().optional(),
|
|
1294
|
+
value: selectOptionValue
|
|
1295
|
+
});
|
|
1296
|
+
const selectInputField = baseFormField.extend({
|
|
1297
|
+
type: z$1.literal("select"),
|
|
1298
|
+
options: selectOption.array().min(1, "atleast one option should be present").readonly(),
|
|
1299
|
+
mode: z$1.enum([
|
|
1300
|
+
"select",
|
|
1301
|
+
"multi-select",
|
|
1302
|
+
"checkbox",
|
|
1303
|
+
"multi-checkbox",
|
|
1304
|
+
"radio",
|
|
1305
|
+
"radio-card"
|
|
1306
|
+
]).optional()
|
|
1307
|
+
});
|
|
1308
|
+
const tableInputField = baseFormField.extend({
|
|
1309
|
+
type: z$1.literal("table"),
|
|
1310
|
+
data: dataRecord.array().readonly(),
|
|
1311
|
+
mode: z$1.enum(["multiple", "single"]).optional(),
|
|
1312
|
+
min: z$1.number().optional(),
|
|
1313
|
+
max: z$1.number().optional()
|
|
1314
|
+
});
|
|
1315
|
+
const searchInputField = baseFormField.extend({
|
|
1316
|
+
type: z$1.literal("search"),
|
|
1317
|
+
mode: z$1.enum(["multiple", "single"]).optional(),
|
|
1318
|
+
min: z$1.number().optional(),
|
|
1319
|
+
max: z$1.number().optional()
|
|
1320
|
+
});
|
|
1321
|
+
const uploadInputField = baseFormField.extend({
|
|
1322
|
+
type: z$1.literal("upload"),
|
|
1323
|
+
mode: z$1.enum(["single", "multiple"]).optional(),
|
|
1324
|
+
accept: z$1.record(z$1.string().describe("mimeType supported"), z$1.string().array().describe("array of file extensions")).optional()
|
|
1325
|
+
});
|
|
1326
|
+
const uploadedFileSchema = z$1.object({
|
|
1327
|
+
type: z$1.string().optional(),
|
|
1328
|
+
name: z$1.string().optional(),
|
|
1329
|
+
buffer: z$1.instanceof(Uint8Array).or(z$1.number().array().transform((val) => new Uint8Array(val))).or(z$1.record(z$1.string(), z$1.number()).transform((val) => {
|
|
1330
|
+
const arr = Array.from({
|
|
1331
|
+
...val,
|
|
1332
|
+
length: Object.keys(val).length
|
|
1333
|
+
});
|
|
1334
|
+
return new Uint8Array(arr);
|
|
1335
|
+
})).or(z$1.instanceof(ArrayBuffer)),
|
|
1336
|
+
size: z$1.number()
|
|
1337
|
+
});
|
|
1338
|
+
const formInputField = z$1.discriminatedUnion("type", [
|
|
1339
|
+
textInputField,
|
|
1340
|
+
numberInputField,
|
|
1341
|
+
dateInputField,
|
|
1342
|
+
selectInputField,
|
|
1343
|
+
tableInputField,
|
|
1344
|
+
searchInputField,
|
|
1345
|
+
uploadInputField
|
|
1346
|
+
]);
|
|
1347
|
+
const ioForm = z$1.record(z$1.string(), formInputField);
|
|
1348
|
+
function getValidationSchemaForField(field) {
|
|
1349
|
+
let schema = match(field).returnType().with({ type: "text" }, ({ inputType, min, max }) => {
|
|
1350
|
+
let stringSchema = match(inputType).with("email", () => z$1.email()).with("url", () => z$1.url()).otherwise(() => z$1.string());
|
|
1351
|
+
if (typeof min === "number") stringSchema = stringSchema.min(min, `input should be at least ${min} characters`);
|
|
1352
|
+
if (typeof max === "number") stringSchema = stringSchema.max(max, `input should be at most ${max} characters`);
|
|
1353
|
+
return stringSchema;
|
|
1354
|
+
}).with({ type: "number" }, ({ min, max }) => {
|
|
1355
|
+
let schema$1 = z$1.number();
|
|
1356
|
+
if (typeof min == "number") schema$1 = schema$1.min(min);
|
|
1357
|
+
if (typeof max === "number") schema$1 = schema$1.max(max);
|
|
1358
|
+
return schema$1;
|
|
1359
|
+
}).with({ type: "date" }, ({ min, max, mode }) => {
|
|
1360
|
+
const baseSchema = (() => {
|
|
1361
|
+
let schema$1 = z$1.iso.datetime();
|
|
1362
|
+
if (z$1.iso.datetime().safeParse(min).success) schema$1 = schema$1.refine((value) => (0, import_dayjs_min.default)(value).isAfter((0, import_dayjs_min.default)(min)), `date should be after ${(0, import_dayjs_min.default)(min).format("DD MMM YYYY")}`);
|
|
1363
|
+
if (z$1.iso.datetime().safeParse(max).success) schema$1 = schema$1.refine((value) => (0, import_dayjs_min.default)(value).isBefore((0, import_dayjs_min.default)(max)), `date should be before ${(0, import_dayjs_min.default)(max).format("DD MMM YYYY")}`);
|
|
1364
|
+
return schema$1;
|
|
1365
|
+
})();
|
|
1366
|
+
return match(mode).returnType().with(P.union("single", void 0), () => baseSchema).with("multiple", () => baseSchema.array()).with("range", () => z$1.object({
|
|
1367
|
+
from: baseSchema,
|
|
1368
|
+
to: baseSchema
|
|
1369
|
+
})).exhaustive();
|
|
1370
|
+
}).with({ type: "select" }, ({ options, mode }) => {
|
|
1371
|
+
let schema$1 = z$1.enum(options.map((option) => option.value));
|
|
1372
|
+
if (mode === "multi-checkbox" || mode === "multi-select") schema$1 = schema$1.array();
|
|
1373
|
+
return schema$1;
|
|
1374
|
+
}).with({ type: "table" }, ({ data, mode, min, max }) => {
|
|
1375
|
+
let schema$1 = z$1.unknown().refine((value) => {
|
|
1376
|
+
return !!data.find((item) => deepEqual(item, value));
|
|
1377
|
+
}, "value of should be one of the item in the array");
|
|
1378
|
+
if (mode === "multiple") {
|
|
1379
|
+
schema$1 = schema$1.array();
|
|
1380
|
+
if (typeof min === "number") schema$1 = schema$1.min(min);
|
|
1381
|
+
if (typeof max === "number") schema$1 = schema$1.max(max);
|
|
1382
|
+
}
|
|
1383
|
+
return schema$1;
|
|
1384
|
+
}).with({ type: "search" }, ({ mode, min, max }) => {
|
|
1385
|
+
let schema$1 = z$1.string();
|
|
1386
|
+
if (mode === "multiple") {
|
|
1387
|
+
schema$1 = schema$1.array();
|
|
1388
|
+
if (typeof min === "number") schema$1 = schema$1.min(min);
|
|
1389
|
+
if (typeof max === "number") schema$1 = schema$1.max(max);
|
|
1390
|
+
}
|
|
1391
|
+
return schema$1;
|
|
1392
|
+
}).with({ type: "upload" }, ({ mode }) => {
|
|
1393
|
+
let schema$1 = uploadedFileSchema;
|
|
1394
|
+
if (mode === "multiple") schema$1 = schema$1.array();
|
|
1395
|
+
return schema$1;
|
|
1396
|
+
}).exhaustive();
|
|
1397
|
+
if (field.optional) schema = schema.optional();
|
|
1398
|
+
return schema;
|
|
1399
|
+
}
|
|
1400
|
+
function getValidationSchemaForForm(schema) {
|
|
1401
|
+
let validationSchema = z$1.object({});
|
|
1402
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
1403
|
+
const schema$1 = getValidationSchemaForField(value);
|
|
1404
|
+
validationSchema = validationSchema.extend({ [key]: schema$1 });
|
|
1405
|
+
}
|
|
1406
|
+
return validationSchema;
|
|
1407
|
+
}
|
|
1408
|
+
const confirm = z$1.object({
|
|
1409
|
+
title: z$1.string(),
|
|
1410
|
+
description: z$1.string().optional(),
|
|
1411
|
+
block: blockSchema.optional(),
|
|
1412
|
+
okButtonLabel: z$1.string().optional().default("OK"),
|
|
1413
|
+
cancelButtonLabel: z$1.string().optional().default("Cancel")
|
|
1414
|
+
});
|
|
1415
|
+
const baseMessageSchema = z$1.object({
|
|
1416
|
+
id: z$1.nanoid(),
|
|
1417
|
+
timestamp: z$1.number().min(0, { message: "timestamp must be a positive number" })
|
|
1418
|
+
});
|
|
1419
|
+
const runnerId = z$1.string().regex(/^tf-runner:[A-Za-z0-9_-]{32}$/, { message: "runnerId must start with \"tf-runner:\" followed by a 32-character nanoid" });
|
|
1420
|
+
const clientId = z$1.string().regex(/^tf-client:[A-Za-z0-9_-]{32}$/, { message: "runnerId must start with \"tf-runner:\" followed by a 32-character nanoid" });
|
|
1421
|
+
const sdkServerId = z$1.string().regex(/^tf-ss:[A-Za-z0-9_-]{32}$/, { message: "serverId must start with \"tf-ss:\" followed by a 32-character nanoid" });
|
|
1422
|
+
const appServerId = z$1.string().regex(/^tf-as:[A-Za-z0-9_-]{32}$/, { message: "serverId must start with \"tf-ss:\" followed by a 32-character nanoid" });
|
|
1423
|
+
const serverId = z$1.union([sdkServerId, appServerId]);
|
|
1424
|
+
const ackMessageSchema = baseMessageSchema.extend({
|
|
1425
|
+
type: z$1.literal("ACK"),
|
|
1426
|
+
rootMessageId: z$1.string(),
|
|
1427
|
+
data: z$1.discriminatedUnion("type", [z$1.object({ type: z$1.literal("SUCCESS") }), z$1.object({
|
|
1428
|
+
type: z$1.literal("ERROR"),
|
|
1429
|
+
error: z$1.string()
|
|
1430
|
+
})])
|
|
1431
|
+
});
|
|
1432
|
+
const initCommunicationMessageSchema = baseMessageSchema.extend({
|
|
1433
|
+
type: z$1.literal("INIT_COMMUNICATION"),
|
|
1434
|
+
data: z$1.object({
|
|
1435
|
+
serverId,
|
|
1436
|
+
heartbeatIntervalMs: z$1.number().min(1e3, { message: "heartbeatInterval must be at least 1000ms" }),
|
|
1437
|
+
heartbeatAckTimeoutMs: z$1.number().min(1e3, { message: "heartbeatAckTimeout must be at least 1000ms" }),
|
|
1438
|
+
maxRetries: z$1.number().min(0, { message: "maxRetries must be at least 0" })
|
|
1439
|
+
})
|
|
1440
|
+
});
|
|
1441
|
+
const heartbeatMessageSchema = baseMessageSchema.extend({
|
|
1442
|
+
type: z$1.literal("HEARTBEAT"),
|
|
1443
|
+
data: z$1.discriminatedUnion("clientType", [z$1.object({
|
|
1444
|
+
clientType: z$1.literal("RUNNER"),
|
|
1445
|
+
runnerId,
|
|
1446
|
+
cpuUsage: z$1.number(),
|
|
1447
|
+
memoryUsage: z$1.number(),
|
|
1448
|
+
activeSessionsCount: z$1.number()
|
|
1449
|
+
}), z$1.object({
|
|
1450
|
+
clientType: z$1.literal("CLIENT"),
|
|
1451
|
+
clientId
|
|
1452
|
+
})])
|
|
1453
|
+
});
|
|
1454
|
+
const heartbeatAckMessageSchema = baseMessageSchema.extend({
|
|
1455
|
+
type: z$1.literal("HEARTBEAT_ACK"),
|
|
1456
|
+
data: z$1.discriminatedUnion("clientType", [z$1.object({
|
|
1457
|
+
clientType: z$1.literal("RUNNER"),
|
|
1458
|
+
runnerId,
|
|
1459
|
+
serverId: sdkServerId
|
|
1460
|
+
}), z$1.object({
|
|
1461
|
+
clientType: z$1.literal("CLIENT"),
|
|
1462
|
+
clientId,
|
|
1463
|
+
serverId: appServerId
|
|
1464
|
+
})])
|
|
1465
|
+
});
|
|
1466
|
+
const listForgeMessageSchema = baseMessageSchema.extend({
|
|
1467
|
+
type: z$1.literal("LIST_FORGE"),
|
|
1468
|
+
data: z$1.object({
|
|
1469
|
+
runnerId,
|
|
1470
|
+
forgeItems: forgeItemSchema.array()
|
|
1471
|
+
})
|
|
1472
|
+
});
|
|
1473
|
+
const reloadForgeMessageSchema = baseMessageSchema.extend({
|
|
1474
|
+
type: z$1.literal("RELOAD_FORGE"),
|
|
1475
|
+
data: z$1.object({ environmentId: z$1.uuid() })
|
|
1476
|
+
});
|
|
1477
|
+
const startToolMessageSchema = baseMessageSchema.extend({
|
|
1478
|
+
type: z$1.literal("START_TOOL"),
|
|
1479
|
+
data: z$1.object({
|
|
1480
|
+
toolId: z$1.string(),
|
|
1481
|
+
itemId: z$1.string(),
|
|
1482
|
+
sessionId: z$1.uuid(),
|
|
1483
|
+
environmentId: z$1.uuid()
|
|
1484
|
+
})
|
|
1485
|
+
});
|
|
1486
|
+
const stopToolMessageSchema = baseMessageSchema.extend({
|
|
1487
|
+
type: z$1.literal("STOP_TOOL"),
|
|
1488
|
+
data: z$1.object({ sessionId: z$1.uuid() })
|
|
1489
|
+
});
|
|
1490
|
+
const executionContextSchema = z$1.discriminatedUnion("type", [
|
|
1491
|
+
z$1.object({ type: z$1.literal("TOOL") }),
|
|
1492
|
+
z$1.object({
|
|
1493
|
+
type: z$1.literal("STEP"),
|
|
1494
|
+
id: z$1.nanoid(),
|
|
1495
|
+
step: z$1.object({
|
|
1496
|
+
name: z$1.string(),
|
|
1497
|
+
description: z$1.string().optional()
|
|
1498
|
+
})
|
|
1499
|
+
}),
|
|
1500
|
+
z$1.object({ type: z$1.literal("AGENT") })
|
|
1501
|
+
]);
|
|
1502
|
+
const renderInputsMessageSchema = baseMessageSchema.extend({
|
|
1503
|
+
type: z$1.literal("RENDER_INPUTS"),
|
|
1504
|
+
data: z$1.object({
|
|
1505
|
+
sessionId: z$1.uuid(),
|
|
1506
|
+
form: ioForm,
|
|
1507
|
+
defaultValues: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1508
|
+
title: z$1.string().optional(),
|
|
1509
|
+
description: z$1.string().optional(),
|
|
1510
|
+
executionContext: executionContextSchema
|
|
1511
|
+
})
|
|
1512
|
+
});
|
|
1513
|
+
const inputsResponseMessageSchema = baseMessageSchema.extend({
|
|
1514
|
+
type: z$1.literal("INPUTS_RESPONSE"),
|
|
1515
|
+
rootMessageId: z$1.string(),
|
|
1516
|
+
data: z$1.object({
|
|
1517
|
+
sessionId: z$1.uuid(),
|
|
1518
|
+
inputs: z$1.record(z$1.string(), z$1.unknown()),
|
|
1519
|
+
executionContext: executionContextSchema
|
|
1520
|
+
})
|
|
1521
|
+
});
|
|
1522
|
+
const inputsValidMessageSchema = baseMessageSchema.extend({
|
|
1523
|
+
type: z$1.literal("INPUTS_VALID"),
|
|
1524
|
+
rootMessageId: z$1.string(),
|
|
1525
|
+
data: z$1.object({
|
|
1526
|
+
runnerId,
|
|
1527
|
+
sessionId: z$1.uuid(),
|
|
1528
|
+
executionContext: executionContextSchema
|
|
1529
|
+
})
|
|
1530
|
+
});
|
|
1531
|
+
const inputsErrorMessageSchema = baseMessageSchema.extend({
|
|
1532
|
+
type: z$1.literal("INPUTS_ERROR"),
|
|
1533
|
+
rootMessageId: z$1.string(),
|
|
1534
|
+
data: z$1.object({
|
|
1535
|
+
sessionId: z$1.uuid(),
|
|
1536
|
+
issues: z$1.object({
|
|
1537
|
+
code: z$1.string(),
|
|
1538
|
+
message: z$1.string(),
|
|
1539
|
+
path: z$1.union([
|
|
1540
|
+
z$1.string(),
|
|
1541
|
+
z$1.number(),
|
|
1542
|
+
z$1.symbol()
|
|
1543
|
+
]).array()
|
|
1544
|
+
}).array(),
|
|
1545
|
+
attemptsRemaining: z$1.number(),
|
|
1546
|
+
executionContext: executionContextSchema
|
|
1547
|
+
})
|
|
1548
|
+
});
|
|
1549
|
+
const searchInputMessageSchema = baseMessageSchema.extend({
|
|
1550
|
+
type: z$1.literal("SEARCH_INPUT"),
|
|
1551
|
+
rootMessageId: z$1.string(),
|
|
1552
|
+
data: z$1.object({
|
|
1553
|
+
sessionId: z$1.uuid(),
|
|
1554
|
+
searchInputId: z$1.string(),
|
|
1555
|
+
query: z$1.string().min(1, { message: "query must be at least 1 character" }),
|
|
1556
|
+
executionContext: executionContextSchema
|
|
1557
|
+
})
|
|
1558
|
+
});
|
|
1559
|
+
const searchInputResponseMessageSchema = baseMessageSchema.extend({
|
|
1560
|
+
type: z$1.literal("SEARCH_INPUT_RESPONSE"),
|
|
1561
|
+
rootMessageId: z$1.string(),
|
|
1562
|
+
data: z$1.object({
|
|
1563
|
+
sessionId: z$1.uuid(),
|
|
1564
|
+
searchInputId: z$1.string(),
|
|
1565
|
+
results: selectOption.array(),
|
|
1566
|
+
executionContext: executionContextSchema
|
|
1567
|
+
})
|
|
1568
|
+
});
|
|
1569
|
+
const searchInputErrorMessageSchema = baseMessageSchema.extend({
|
|
1570
|
+
type: z$1.literal("SEARCH_INPUT_ERROR"),
|
|
1571
|
+
rootMessageId: z$1.string(),
|
|
1572
|
+
data: z$1.object({
|
|
1573
|
+
sessionId: z$1.uuid(),
|
|
1574
|
+
searchInputId: z$1.string(),
|
|
1575
|
+
error: z$1.object({
|
|
1576
|
+
message: z$1.string(),
|
|
1577
|
+
code: z$1.string().optional(),
|
|
1578
|
+
details: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1579
|
+
stack: z$1.string().optional()
|
|
1580
|
+
}),
|
|
1581
|
+
executionContext: executionContextSchema
|
|
1582
|
+
})
|
|
1583
|
+
});
|
|
1584
|
+
const toolCompleteMessageSchema = baseMessageSchema.extend({
|
|
1585
|
+
type: z$1.literal("TOOL_COMPLETE"),
|
|
1586
|
+
data: z$1.object({
|
|
1587
|
+
sessionId: z$1.uuid(),
|
|
1588
|
+
output: z$1.unknown(),
|
|
1589
|
+
executionContext: executionContextSchema
|
|
1590
|
+
})
|
|
1591
|
+
});
|
|
1592
|
+
const toolErrorMessageSchema = baseMessageSchema.extend({
|
|
1593
|
+
type: z$1.literal("TOOL_ERROR"),
|
|
1594
|
+
data: z$1.object({
|
|
1595
|
+
sessionId: z$1.uuid(),
|
|
1596
|
+
error: z$1.object({
|
|
1597
|
+
message: z$1.string(),
|
|
1598
|
+
code: z$1.string().optional(),
|
|
1599
|
+
details: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1600
|
+
stack: z$1.string().optional()
|
|
1601
|
+
}),
|
|
1602
|
+
executionContext: executionContextSchema
|
|
1603
|
+
})
|
|
1604
|
+
});
|
|
1605
|
+
const listenForEnvironmentChangesMessageSchema = baseMessageSchema.extend({
|
|
1606
|
+
type: z$1.literal("LISTEN_FOR_ENVIRONMENT_CHANGES"),
|
|
1607
|
+
data: z$1.object({
|
|
1608
|
+
environmentId: z$1.uuid(),
|
|
1609
|
+
clientId
|
|
1610
|
+
})
|
|
1611
|
+
});
|
|
1612
|
+
const listenForForgeSessionMessagesMessageSchema = baseMessageSchema.extend({
|
|
1613
|
+
type: z$1.literal("LISTEN_FOR_FORGE_SESSION_MESSAGES"),
|
|
1614
|
+
data: z$1.object({
|
|
1615
|
+
sessionId: z$1.uuid(),
|
|
1616
|
+
clientId
|
|
1617
|
+
})
|
|
1618
|
+
});
|
|
1619
|
+
const startLoaderMessageSchema = baseMessageSchema.extend({
|
|
1620
|
+
type: z$1.literal("START_LOADER"),
|
|
1621
|
+
data: z$1.object({
|
|
1622
|
+
sessionId: z$1.string(),
|
|
1623
|
+
title: z$1.string(),
|
|
1624
|
+
description: z$1.string().optional(),
|
|
1625
|
+
executionContext: executionContextSchema
|
|
1626
|
+
})
|
|
1627
|
+
});
|
|
1628
|
+
const stopLoaderMessgeSchema = baseMessageSchema.extend({
|
|
1629
|
+
type: z$1.literal("STOP_LOADER"),
|
|
1630
|
+
rootMessageId: z$1.string(),
|
|
1631
|
+
data: z$1.object({
|
|
1632
|
+
sessionId: z$1.string(),
|
|
1633
|
+
executionContext: executionContextSchema
|
|
1634
|
+
})
|
|
1635
|
+
});
|
|
1636
|
+
const startProgressLoaderMessageSchema = baseMessageSchema.extend({
|
|
1637
|
+
type: z$1.literal("START_PROGRESS_LOADER"),
|
|
1638
|
+
data: z$1.object({
|
|
1639
|
+
sessionId: z$1.string(),
|
|
1640
|
+
itemsInQueue: z$1.number(),
|
|
1641
|
+
title: z$1.string(),
|
|
1642
|
+
description: z$1.string().optional(),
|
|
1643
|
+
executionContext: executionContextSchema
|
|
1644
|
+
})
|
|
1645
|
+
});
|
|
1646
|
+
const updateProgressLoaderMessageSchema = baseMessageSchema.extend({
|
|
1647
|
+
type: z$1.literal("UPDATE_PROGRESS_LOADER"),
|
|
1648
|
+
rootMessageId: z$1.string(),
|
|
1649
|
+
data: z$1.object({
|
|
1650
|
+
sessionId: z$1.string(),
|
|
1651
|
+
itemsCompleted: z$1.number(),
|
|
1652
|
+
executionContext: executionContextSchema
|
|
1653
|
+
})
|
|
1654
|
+
});
|
|
1655
|
+
const stopProgressLoaderMessageSchema = baseMessageSchema.extend({
|
|
1656
|
+
type: z$1.literal("STOP_PROGRESS_LOADER"),
|
|
1657
|
+
rootMessageId: z$1.string(),
|
|
1658
|
+
data: z$1.object({
|
|
1659
|
+
sessionId: z$1.string(),
|
|
1660
|
+
executionContext: executionContextSchema
|
|
1661
|
+
})
|
|
1662
|
+
});
|
|
1663
|
+
const confirmMessageSchema = baseMessageSchema.extend({
|
|
1664
|
+
type: z$1.literal("CONFIRM"),
|
|
1665
|
+
data: confirm.extend({
|
|
1666
|
+
runnerId,
|
|
1667
|
+
sessionId: z$1.uuid(),
|
|
1668
|
+
executionContext: executionContextSchema
|
|
1669
|
+
})
|
|
1670
|
+
});
|
|
1671
|
+
const confirmResponseMessageSchema = baseMessageSchema.extend({
|
|
1672
|
+
type: z$1.literal("CONFIRM_RESPONSE"),
|
|
1673
|
+
rootMessageId: z$1.string(),
|
|
1674
|
+
data: z$1.object({
|
|
1675
|
+
sessionId: z$1.uuid(),
|
|
1676
|
+
confirmed: z$1.boolean(),
|
|
1677
|
+
executionContext: executionContextSchema
|
|
1678
|
+
})
|
|
1679
|
+
});
|
|
1680
|
+
const confirmValidMessageSchema = baseMessageSchema.extend({
|
|
1681
|
+
type: z$1.literal("CONFIRM_VALID"),
|
|
1682
|
+
rootMessageId: z$1.string(),
|
|
1683
|
+
data: z$1.object({
|
|
1684
|
+
sessionId: z$1.uuid(),
|
|
1685
|
+
executionContext: executionContextSchema
|
|
1686
|
+
})
|
|
1687
|
+
});
|
|
1688
|
+
const showMessageMessageSchema = baseMessageSchema.extend({
|
|
1689
|
+
type: z$1.literal("SHOW_MESSAGE"),
|
|
1690
|
+
data: z$1.object({
|
|
1691
|
+
title: z$1.string().optional(),
|
|
1692
|
+
description: z$1.string().optional(),
|
|
1693
|
+
message: z$1.union([
|
|
1694
|
+
primitiveSchema,
|
|
1695
|
+
dataRecord,
|
|
1696
|
+
dataRecord.array(),
|
|
1697
|
+
blockSchema
|
|
1698
|
+
]),
|
|
1699
|
+
sessionId: z$1.string(),
|
|
1700
|
+
executionContext: executionContextSchema
|
|
1701
|
+
})
|
|
1702
|
+
});
|
|
1703
|
+
const startAgentMessageSchema = baseMessageSchema.extend({
|
|
1704
|
+
type: z$1.literal("START_AGENT"),
|
|
1705
|
+
data: z$1.object({
|
|
1706
|
+
agentId: z$1.string(),
|
|
1707
|
+
itemId: z$1.string(),
|
|
1708
|
+
sessionId: z$1.uuid(),
|
|
1709
|
+
environmentId: z$1.uuid()
|
|
1710
|
+
})
|
|
1711
|
+
});
|
|
1712
|
+
const stopAgentMessageSchema = baseMessageSchema.extend({
|
|
1713
|
+
type: z$1.literal("STOP_AGENT"),
|
|
1714
|
+
data: z$1.object({ sessionId: z$1.uuid() })
|
|
1715
|
+
});
|
|
1716
|
+
const stepStartMessageSchema = baseMessageSchema.extend({
|
|
1717
|
+
type: z$1.literal("STEP_START"),
|
|
1718
|
+
data: z$1.object({
|
|
1719
|
+
sessionId: z$1.uuid(),
|
|
1720
|
+
executionContext: executionContextSchema
|
|
1721
|
+
})
|
|
1722
|
+
});
|
|
1723
|
+
const stepCompleteMessageSchema = baseMessageSchema.extend({
|
|
1724
|
+
type: z$1.literal("STEP_COMPLETE"),
|
|
1725
|
+
data: z$1.object({
|
|
1726
|
+
sessionId: z$1.uuid(),
|
|
1727
|
+
output: z$1.unknown().optional(),
|
|
1728
|
+
executionContext: executionContextSchema
|
|
1729
|
+
})
|
|
1730
|
+
});
|
|
1731
|
+
const stepErrorMessageSchema = baseMessageSchema.extend({
|
|
1732
|
+
type: z$1.literal("STEP_ERROR"),
|
|
1733
|
+
data: z$1.object({
|
|
1734
|
+
sessionId: z$1.uuid(),
|
|
1735
|
+
error: z$1.object({
|
|
1736
|
+
message: z$1.string(),
|
|
1737
|
+
code: z$1.string().optional(),
|
|
1738
|
+
details: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1739
|
+
stack: z$1.string().optional()
|
|
1740
|
+
}),
|
|
1741
|
+
executionContext: executionContextSchema
|
|
1742
|
+
})
|
|
1743
|
+
});
|
|
1744
|
+
const agentStartMessageSchema = baseMessageSchema.extend({
|
|
1745
|
+
type: z$1.literal("AGENT_START"),
|
|
1746
|
+
data: z$1.object({
|
|
1747
|
+
sessionId: z$1.uuid(),
|
|
1748
|
+
agentWorkflow: agentWorkflowSchema,
|
|
1749
|
+
executionContext: executionContextSchema
|
|
1750
|
+
})
|
|
1751
|
+
});
|
|
1752
|
+
const agentCompleteMessageSchema = baseMessageSchema.extend({
|
|
1753
|
+
type: z$1.literal("AGENT_COMPLETE"),
|
|
1754
|
+
data: z$1.object({
|
|
1755
|
+
sessionId: z$1.uuid(),
|
|
1756
|
+
output: z$1.unknown(),
|
|
1757
|
+
executionContext: executionContextSchema
|
|
1758
|
+
})
|
|
1759
|
+
});
|
|
1760
|
+
const agentErrorMessageSchema = baseMessageSchema.extend({
|
|
1761
|
+
type: z$1.literal("AGENT_ERROR"),
|
|
1762
|
+
data: z$1.object({
|
|
1763
|
+
sessionId: z$1.uuid(),
|
|
1764
|
+
error: z$1.object({
|
|
1765
|
+
message: z$1.string(),
|
|
1766
|
+
code: z$1.string().optional(),
|
|
1767
|
+
details: z$1.record(z$1.string(), z$1.unknown()).optional(),
|
|
1768
|
+
stack: z$1.string().optional()
|
|
1769
|
+
}),
|
|
1770
|
+
executionContext: executionContextSchema
|
|
1771
|
+
})
|
|
1772
|
+
});
|
|
1773
|
+
|
|
1774
|
+
//#endregion
|
|
1775
|
+
//#region src/internal/block.ts
|
|
1776
|
+
var Block = class {
|
|
1777
|
+
#signal;
|
|
1778
|
+
constructor(options) {
|
|
1779
|
+
this.#signal = options.signal;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* Creates an area chart block.
|
|
1783
|
+
*/
|
|
1784
|
+
areaChart(props) {
|
|
1785
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1786
|
+
return areaChartSchema.parse({
|
|
1787
|
+
type: "chart",
|
|
1788
|
+
chartType: "area-chart",
|
|
1789
|
+
...props
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Creates a bar chart block.
|
|
1794
|
+
*/
|
|
1795
|
+
barChart(props) {
|
|
1796
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1797
|
+
return barChartSchema.parse({
|
|
1798
|
+
type: "chart",
|
|
1799
|
+
chartType: "bar-chart",
|
|
1800
|
+
...props
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Creates a bar list block.
|
|
1805
|
+
*
|
|
1806
|
+
* A bar list is a vertical list of horizontal bars, useful for comparing multiple values.
|
|
1807
|
+
*/
|
|
1808
|
+
barList(props) {
|
|
1809
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1810
|
+
return barListSchema.parse({
|
|
1811
|
+
type: "chart",
|
|
1812
|
+
chartType: "bar-list",
|
|
1813
|
+
...props
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Creates a category bar block.
|
|
1818
|
+
*
|
|
1819
|
+
* A category bar is a horizontal bar chart that displays categorical data.
|
|
1820
|
+
*/
|
|
1821
|
+
categoryBar(props) {
|
|
1822
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1823
|
+
return categoryBarSchema.parse({
|
|
1824
|
+
type: "chart",
|
|
1825
|
+
chartType: "category-bar",
|
|
1826
|
+
...props
|
|
1827
|
+
});
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Creates a donut chart block.
|
|
1831
|
+
*/
|
|
1832
|
+
donutChart(props) {
|
|
1833
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1834
|
+
return donutChartSchema.parse({
|
|
1835
|
+
type: "chart",
|
|
1836
|
+
chartType: "donut-chart",
|
|
1837
|
+
...props
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
/**
|
|
1841
|
+
* Creates a line chart block.
|
|
1842
|
+
*/
|
|
1843
|
+
lineChart(props) {
|
|
1844
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1845
|
+
return lineChartSchema.parse({
|
|
1846
|
+
type: "chart",
|
|
1847
|
+
chartType: "line-chart",
|
|
1848
|
+
...props
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Creates a progress bar block.
|
|
1853
|
+
*
|
|
1854
|
+
* A progress bar is a visual representation of progress towards a goal.
|
|
1855
|
+
*/
|
|
1856
|
+
progressBar(props) {
|
|
1857
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1858
|
+
return progressBarSchema.parse({
|
|
1859
|
+
type: "chart",
|
|
1860
|
+
chartType: "progress-bar",
|
|
1861
|
+
...props
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Creates a progress circle block.
|
|
1866
|
+
*
|
|
1867
|
+
* A progress circle is a circular representation of progress towards a goal.
|
|
1868
|
+
*/
|
|
1869
|
+
progressCircle(props) {
|
|
1870
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1871
|
+
return progressCircleSchema.parse({
|
|
1872
|
+
type: "chart",
|
|
1873
|
+
chartType: "progress-circle",
|
|
1874
|
+
...props
|
|
1875
|
+
});
|
|
1876
|
+
}
|
|
1877
|
+
/**
|
|
1878
|
+
* Creates a spark chart block.
|
|
1879
|
+
*
|
|
1880
|
+
* A spark chart is a small, simple chart that provides a visual representation of data trends.
|
|
1881
|
+
*/
|
|
1882
|
+
sparkChart(props) {
|
|
1883
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1884
|
+
return sparkChartSchema.parse({
|
|
1885
|
+
type: "chart",
|
|
1886
|
+
chartType: "spark-chart",
|
|
1887
|
+
...props
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
/**
|
|
1891
|
+
* Creates a tracker block.
|
|
1892
|
+
*
|
|
1893
|
+
* A tracker chart is a visual display that shows the real-time or historical status of multiple systems, services, or metrics in a consolidated view, typically using color-coded indicators (green, yellow, red) to quickly communicate operational health.
|
|
1894
|
+
*/
|
|
1895
|
+
tracker(props) {
|
|
1896
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1897
|
+
return trackerSchema.parse({
|
|
1898
|
+
type: "chart",
|
|
1899
|
+
chartType: "tracker",
|
|
1900
|
+
...props
|
|
1901
|
+
});
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Creates a combo chart block.
|
|
1905
|
+
*
|
|
1906
|
+
* A combo chart combines multiple chart types (e.g., bar and line) into a single visualization to represent different data series.
|
|
1907
|
+
*/
|
|
1908
|
+
comboChart(props) {
|
|
1909
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1910
|
+
return comboChartSchema.parse({
|
|
1911
|
+
type: "chart",
|
|
1912
|
+
chartType: "combo-chart",
|
|
1913
|
+
...props
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Creates a heatmap chart block.
|
|
1918
|
+
*
|
|
1919
|
+
* A heatmap chart is a graphical representation of data where individual values are represented as colors in a matrix, allowing for quick identification of patterns, correlations, and outliers within large datasets.
|
|
1920
|
+
*/
|
|
1921
|
+
heatmapChart(props) {
|
|
1922
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1923
|
+
return heatmapChartSchema.parse({
|
|
1924
|
+
type: "chart",
|
|
1925
|
+
chartType: "heatmap-chart",
|
|
1926
|
+
...props
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
/**
|
|
1930
|
+
* Creates a KPI card block.
|
|
1931
|
+
*
|
|
1932
|
+
* A KPI (Key Performance Indicator) card is a visual representation of a specific metric or performance indicator, typically displayed in a concise format to provide quick insights into business performance.
|
|
1933
|
+
* It often includes elements such as the current value, target value, percentage change, and visual cues (like colors or icons) to indicate performance status.
|
|
1934
|
+
* It can include charts such as sparklines or progress indicators to provide additional context.
|
|
1935
|
+
*/
|
|
1936
|
+
kpiCard(props) {
|
|
1937
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1938
|
+
return kpiCardSchema.parse({
|
|
1939
|
+
type: "kpi-card",
|
|
1940
|
+
...props
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* Creates a table block.
|
|
1945
|
+
*
|
|
1946
|
+
* A table block displays data in a structured tabular format, allowing for easy comparison and analysis of information across rows and columns.
|
|
1947
|
+
* It can include features such as sorting, filtering, and pagination to enhance data exploration.
|
|
1948
|
+
* You can also include charts within table cells for visual representation of data, by providing appropriate render configuration.
|
|
1949
|
+
*/
|
|
1950
|
+
table(props) {
|
|
1951
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1952
|
+
return tableBlockSchema.parse({
|
|
1953
|
+
type: "table",
|
|
1954
|
+
...props
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* Creates an image block.
|
|
1959
|
+
*
|
|
1960
|
+
* An image block displays an image from a given URL with optional alt text and caption.
|
|
1961
|
+
*/
|
|
1962
|
+
image(props) {
|
|
1963
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1964
|
+
return imageBlockSchema.parse({
|
|
1965
|
+
type: "image",
|
|
1966
|
+
...props
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Creates a text block.
|
|
1971
|
+
*
|
|
1972
|
+
* A text block displays formatted text content, supporting markdown syntax for styling.
|
|
1973
|
+
*/
|
|
1974
|
+
text(props) {
|
|
1975
|
+
if (this.#signal.aborted) throw new Error("tool execution aborted");
|
|
1976
|
+
return textBlockSchema.parse({
|
|
1977
|
+
type: "text",
|
|
1978
|
+
...props
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Creates an object block.
|
|
1983
|
+
*
|
|
1984
|
+
* An object block allows for rendering structured data. Data would be rendered as a key-value pairs.
|
|
1985
|
+
*/
|
|
1986
|
+
object(props) {
|
|
1987
|
+
return objectBlockSchema.parse({
|
|
1988
|
+
type: "object",
|
|
1989
|
+
...props
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Creates a layout block.
|
|
1994
|
+
*
|
|
1995
|
+
* A layout block is used to arrange other blocks in a grid layout.
|
|
1996
|
+
*/
|
|
1997
|
+
layout(props) {
|
|
1998
|
+
return layoutBlockSchema.parse({
|
|
1999
|
+
type: "layout",
|
|
2000
|
+
...props
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
//#endregion
|
|
2006
|
+
//#region ../core/dist/utils.js
|
|
2007
|
+
function exponentialBackoff(attempt, initialDelay = 1e3, maxRetryDelay = 3e4, jitterFactor = .5, backoffMultiplier = 2) {
|
|
2008
|
+
let delay = initialDelay * Math.pow(backoffMultiplier, attempt - 1);
|
|
2009
|
+
const jitter = delay * jitterFactor * Math.random();
|
|
2010
|
+
delay += jitter;
|
|
2011
|
+
return Math.min(delay, maxRetryDelay);
|
|
2012
|
+
}
|
|
2013
|
+
function runWithRetries(fn, retries = 3, config = {}) {
|
|
2014
|
+
let attempt = 0;
|
|
2015
|
+
const execute = async () => {
|
|
2016
|
+
try {
|
|
2017
|
+
return await fn();
|
|
2018
|
+
} catch (error) {
|
|
2019
|
+
if (attempt < retries) {
|
|
2020
|
+
attempt++;
|
|
2021
|
+
await setTimeout(exponentialBackoff(attempt, config.initialDelayMs, config.maxDelayMs, config.backoffMultiplier));
|
|
2022
|
+
return execute();
|
|
2023
|
+
}
|
|
2024
|
+
throw error;
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
return execute();
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
//#endregion
|
|
2031
|
+
//#region src/lib/utils.ts
|
|
2032
|
+
function convertToWords(input) {
|
|
2033
|
+
if (input.includes("-") || input.includes("_")) return input.split(/[-_]+/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
|
|
2034
|
+
return input.split(/(?=[A-Z])/).filter((word) => word.length > 0).map((word) => word.toLowerCase());
|
|
2035
|
+
}
|
|
2036
|
+
function invariant(cond, message) {
|
|
2037
|
+
if (!cond) throw new Error(message);
|
|
2038
|
+
}
|
|
2039
|
+
function getErrorMessage(error, defaultMessage = "Something went wrong. Please try again") {
|
|
2040
|
+
let errorMessage = defaultMessage;
|
|
2041
|
+
if (error instanceof z$1.ZodError) errorMessage = error.issues.length ? error.issues.map((e) => e.message).join(", ") : error.message;
|
|
2042
|
+
else if (error instanceof Error) errorMessage = error.message;
|
|
2043
|
+
return errorMessage;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
//#endregion
|
|
2047
|
+
//#region src/internal/loader.ts
|
|
2048
|
+
var Loader = class {
|
|
2049
|
+
#id = nanoid();
|
|
2050
|
+
#sessionId;
|
|
2051
|
+
#executionContext;
|
|
2052
|
+
#title;
|
|
2053
|
+
#description;
|
|
2054
|
+
#webSocketClient;
|
|
2055
|
+
#signal;
|
|
2056
|
+
constructor(options) {
|
|
2057
|
+
this.#sessionId = options.sessionId;
|
|
2058
|
+
this.#executionContext = options.executionContext;
|
|
2059
|
+
this.#title = options.title;
|
|
2060
|
+
this.#description = options.description;
|
|
2061
|
+
this.#webSocketClient = options.webSocketClient;
|
|
2062
|
+
this.#signal = options.signal;
|
|
2063
|
+
}
|
|
2064
|
+
async start() {
|
|
2065
|
+
if (this.#signal.aborted) return this;
|
|
2066
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2067
|
+
id: this.#id,
|
|
2068
|
+
type: "START_LOADER",
|
|
2069
|
+
timestamp: Date.now(),
|
|
2070
|
+
data: {
|
|
2071
|
+
sessionId: this.#sessionId,
|
|
2072
|
+
title: this.#title,
|
|
2073
|
+
description: this.#description,
|
|
2074
|
+
executionContext: this.#executionContext
|
|
2075
|
+
}
|
|
2076
|
+
}));
|
|
2077
|
+
return this;
|
|
2078
|
+
}
|
|
2079
|
+
async stop() {
|
|
2080
|
+
if (this.#signal.aborted) return this;
|
|
2081
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2082
|
+
id: nanoid(),
|
|
2083
|
+
timestamp: Date.now(),
|
|
2084
|
+
type: "STOP_LOADER",
|
|
2085
|
+
rootMessageId: this.#id,
|
|
2086
|
+
data: {
|
|
2087
|
+
sessionId: this.#sessionId,
|
|
2088
|
+
executionContext: this.#executionContext
|
|
2089
|
+
}
|
|
2090
|
+
}));
|
|
2091
|
+
return this;
|
|
2092
|
+
}
|
|
2093
|
+
};
|
|
2094
|
+
|
|
2095
|
+
//#endregion
|
|
2096
|
+
//#region src/internal/progress-loader.ts
|
|
2097
|
+
var ProgressLoader = class {
|
|
2098
|
+
#id = nanoid();
|
|
2099
|
+
#title;
|
|
2100
|
+
#description;
|
|
2101
|
+
#itemsCompleted = 0;
|
|
2102
|
+
#itemsInQueue;
|
|
2103
|
+
#sessionId;
|
|
2104
|
+
#executionContext;
|
|
2105
|
+
#webSocketClient;
|
|
2106
|
+
#signal;
|
|
2107
|
+
constructor(options) {
|
|
2108
|
+
this.#title = options.title;
|
|
2109
|
+
this.#description = options.description;
|
|
2110
|
+
this.#itemsInQueue = options.itemsInQueue;
|
|
2111
|
+
this.#sessionId = options.sessionId;
|
|
2112
|
+
this.#executionContext = options.executionContext;
|
|
2113
|
+
this.#webSocketClient = options.webSocketClient;
|
|
2114
|
+
this.#signal = options.signal;
|
|
2115
|
+
}
|
|
2116
|
+
/** Starts the progress loader. */
|
|
2117
|
+
async start() {
|
|
2118
|
+
if (this.#signal.aborted) return this;
|
|
2119
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2120
|
+
id: this.#id,
|
|
2121
|
+
type: "START_PROGRESS_LOADER",
|
|
2122
|
+
timestamp: Date.now(),
|
|
2123
|
+
data: {
|
|
2124
|
+
sessionId: this.#sessionId,
|
|
2125
|
+
itemsInQueue: this.#itemsInQueue,
|
|
2126
|
+
title: this.#title,
|
|
2127
|
+
description: this.#description,
|
|
2128
|
+
executionContext: this.#executionContext
|
|
2129
|
+
}
|
|
2130
|
+
}));
|
|
2131
|
+
return this;
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Updates the progress loader with the number of items completed.
|
|
2135
|
+
*/
|
|
2136
|
+
async update(itemsCompleted) {
|
|
2137
|
+
if (this.#signal.aborted) return this;
|
|
2138
|
+
this.#itemsCompleted = itemsCompleted;
|
|
2139
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2140
|
+
id: nanoid(),
|
|
2141
|
+
type: "UPDATE_PROGRESS_LOADER",
|
|
2142
|
+
timestamp: Date.now(),
|
|
2143
|
+
rootMessageId: this.#id,
|
|
2144
|
+
data: {
|
|
2145
|
+
sessionId: this.#sessionId,
|
|
2146
|
+
itemsCompleted: this.#itemsCompleted,
|
|
2147
|
+
executionContext: this.#executionContext
|
|
2148
|
+
}
|
|
2149
|
+
}));
|
|
2150
|
+
return this;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Increments the number of items completed by one and updates the progress loader.
|
|
2154
|
+
*/
|
|
2155
|
+
async increment() {
|
|
2156
|
+
if (this.#signal.aborted) return this;
|
|
2157
|
+
this.#itemsCompleted += 1;
|
|
2158
|
+
return this.update(this.#itemsCompleted);
|
|
2159
|
+
}
|
|
2160
|
+
/** Stops the progress loader. */
|
|
2161
|
+
async stop() {
|
|
2162
|
+
if (this.#signal.aborted) return this;
|
|
2163
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2164
|
+
id: nanoid(),
|
|
2165
|
+
timestamp: Date.now(),
|
|
2166
|
+
type: "STOP_PROGRESS_LOADER",
|
|
2167
|
+
rootMessageId: this.#id,
|
|
2168
|
+
data: {
|
|
2169
|
+
sessionId: this.#sessionId,
|
|
2170
|
+
executionContext: this.#executionContext
|
|
2171
|
+
}
|
|
2172
|
+
}));
|
|
2173
|
+
return this;
|
|
2174
|
+
}
|
|
2175
|
+
};
|
|
2176
|
+
|
|
2177
|
+
//#endregion
|
|
2178
|
+
//#region src/internal/io.ts
|
|
2179
|
+
const STOP_SYMBOL = Symbol("IO_STOP_SYMBOL");
|
|
2180
|
+
const toIOMessageSchema = z$1.discriminatedUnion("type", [
|
|
2181
|
+
inputsResponseMessageSchema,
|
|
2182
|
+
searchInputMessageSchema,
|
|
2183
|
+
confirmResponseMessageSchema
|
|
2184
|
+
]);
|
|
2185
|
+
var IO = class {
|
|
2186
|
+
#sessionId;
|
|
2187
|
+
#runnerId;
|
|
2188
|
+
#executionContext;
|
|
2189
|
+
#signal;
|
|
2190
|
+
#webSocketClient;
|
|
2191
|
+
#unsubscribeMessageHandler;
|
|
2192
|
+
#logger;
|
|
2193
|
+
/**
|
|
2194
|
+
* map of pending IOs to their corresponding resolve functions.
|
|
2195
|
+
* it is used to track which IO is waiting for a user input.
|
|
2196
|
+
*/
|
|
2197
|
+
#pendingIOs = /* @__PURE__ */ new Map();
|
|
2198
|
+
constructor(options, logger) {
|
|
2199
|
+
this.#sessionId = options.sessionId;
|
|
2200
|
+
this.#runnerId = options.runnerId;
|
|
2201
|
+
this.#executionContext = options.executionContext;
|
|
2202
|
+
this.#logger = logger.child({
|
|
2203
|
+
sessionId: this.#sessionId,
|
|
2204
|
+
component: "IO"
|
|
2205
|
+
});
|
|
2206
|
+
this.#signal = options.signal;
|
|
2207
|
+
this.#webSocketClient = options.webSocketClient;
|
|
2208
|
+
this.#unsubscribeMessageHandler = this.#webSocketClient.subscribeToMessages(this.#handleWebSocketMessage.bind(this));
|
|
2209
|
+
this.#signal.addEventListener("abort", this.#stop.bind(this));
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Handles messages received from the worker.
|
|
2213
|
+
*/
|
|
2214
|
+
async #handleWebSocketMessage(message) {
|
|
2215
|
+
const ioMessageParsed = toIOMessageSchema.safeParse(message);
|
|
2216
|
+
if (ioMessageParsed.success && ioMessageParsed.data.data.sessionId === this.#sessionId) {
|
|
2217
|
+
const message$1 = ioMessageParsed.data;
|
|
2218
|
+
try {
|
|
2219
|
+
await this.#handleIOResponseMessage(message$1);
|
|
2220
|
+
} catch (error) {
|
|
2221
|
+
this.#logger.error(error, "error handling IO message of type %s from worker", ioMessageParsed.data.type);
|
|
2222
|
+
throw error;
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
#handleIOResponseMessage(message) {
|
|
2227
|
+
this.#logger.debug({ data: message }, "handling inputs response message from worker");
|
|
2228
|
+
const pendingIO = this.#pendingIOs.get(message.rootMessageId);
|
|
2229
|
+
if (!pendingIO) {
|
|
2230
|
+
this.#logger.warn("received inputs response for unknown message id %s", message.rootMessageId);
|
|
2231
|
+
return;
|
|
2232
|
+
}
|
|
2233
|
+
pendingIO(message);
|
|
2234
|
+
}
|
|
2235
|
+
[STOP_SYMBOL]() {
|
|
2236
|
+
this.#stop();
|
|
2237
|
+
}
|
|
2238
|
+
#stop() {
|
|
2239
|
+
this.#logger.debug("stopping IO...");
|
|
2240
|
+
if (this.#unsubscribeMessageHandler) {
|
|
2241
|
+
this.#logger.debug("unsubscribing from message handler");
|
|
2242
|
+
this.#unsubscribeMessageHandler();
|
|
2243
|
+
this.#unsubscribeMessageHandler = void 0;
|
|
2244
|
+
}
|
|
2245
|
+
this.#pendingIOs.clear();
|
|
2246
|
+
this.#logger.debug("IO stopped");
|
|
2247
|
+
}
|
|
2248
|
+
#formInput({ form, title, description, validationSchema, maxRetryAttempts, defaultValues }) {
|
|
2249
|
+
return new Promise(async (resolve, reject) => {
|
|
2250
|
+
if (this.#signal.aborted) {
|
|
2251
|
+
this.#logger.warn("form input aborted before start");
|
|
2252
|
+
return reject(/* @__PURE__ */ new Error("form input aborted"));
|
|
2253
|
+
}
|
|
2254
|
+
const messageId = nanoid();
|
|
2255
|
+
let attempts = 0;
|
|
2256
|
+
const searchHandlers = {};
|
|
2257
|
+
const sanitizedForm = Object.entries(form).reduce((acc, [key, value]) => {
|
|
2258
|
+
if (value.type === "search") {
|
|
2259
|
+
const { handleSearch,...rest } = value;
|
|
2260
|
+
if (handleSearch && typeof handleSearch === "function") searchHandlers[key] = handleSearch;
|
|
2261
|
+
return {
|
|
2262
|
+
...acc,
|
|
2263
|
+
[key]: rest
|
|
2264
|
+
};
|
|
2265
|
+
}
|
|
2266
|
+
return {
|
|
2267
|
+
...acc,
|
|
2268
|
+
[key]: value
|
|
2269
|
+
};
|
|
2270
|
+
}, {});
|
|
2271
|
+
this.#signal.addEventListener("abort", () => {
|
|
2272
|
+
this.#logger.warn("form input aborted");
|
|
2273
|
+
this.#pendingIOs.delete(messageId);
|
|
2274
|
+
reject(/* @__PURE__ */ new Error("form input aborted"));
|
|
2275
|
+
});
|
|
2276
|
+
const resolveIO = async (message) => {
|
|
2277
|
+
if (message.type === "SEARCH_INPUT") {
|
|
2278
|
+
const searchHandler = searchHandlers[message.data.searchInputId];
|
|
2279
|
+
if (typeof searchHandler !== "function") {
|
|
2280
|
+
this.#logger.error("no search handler found for search input id %s", message.data.searchInputId);
|
|
2281
|
+
reject(/* @__PURE__ */ new Error(`no search handler found for search input id ${message.data.searchInputId}`));
|
|
2282
|
+
return;
|
|
2283
|
+
}
|
|
2284
|
+
try {
|
|
2285
|
+
const results = await searchHandler(message.data.query);
|
|
2286
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2287
|
+
id: nanoid(),
|
|
2288
|
+
timestamp: Date.now(),
|
|
2289
|
+
rootMessageId: message.id,
|
|
2290
|
+
type: "SEARCH_INPUT_RESPONSE",
|
|
2291
|
+
data: {
|
|
2292
|
+
sessionId: this.#sessionId,
|
|
2293
|
+
searchInputId: message.data.searchInputId,
|
|
2294
|
+
results,
|
|
2295
|
+
executionContext: this.#executionContext
|
|
2296
|
+
}
|
|
2297
|
+
}));
|
|
2298
|
+
this.#logger.debug({
|
|
2299
|
+
messageId,
|
|
2300
|
+
resultsCount: results.length
|
|
2301
|
+
}, "executed search handler for search input id %s", message.data.searchInputId);
|
|
2302
|
+
} catch (error) {
|
|
2303
|
+
this.#logger.error(error, "error executing search handler for search input id %s", message.data.searchInputId);
|
|
2304
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2305
|
+
id: nanoid(),
|
|
2306
|
+
timestamp: Date.now(),
|
|
2307
|
+
rootMessageId: message.id,
|
|
2308
|
+
type: "SEARCH_INPUT_ERROR",
|
|
2309
|
+
data: {
|
|
2310
|
+
sessionId: this.#sessionId,
|
|
2311
|
+
searchInputId: message.data.searchInputId,
|
|
2312
|
+
error: { message: getErrorMessage(error) },
|
|
2313
|
+
executionContext: this.#executionContext
|
|
2314
|
+
}
|
|
2315
|
+
}));
|
|
2316
|
+
}
|
|
2317
|
+
} else if (message.type === "INPUTS_RESPONSE") {
|
|
2318
|
+
this.#pendingIOs.delete(messageId);
|
|
2319
|
+
const value = message.data.inputs;
|
|
2320
|
+
const parsed = validationSchema.safeParse(value);
|
|
2321
|
+
if (parsed.success) {
|
|
2322
|
+
try {
|
|
2323
|
+
this.#logger.debug({
|
|
2324
|
+
messageId,
|
|
2325
|
+
input: parsed.data
|
|
2326
|
+
}, "received valid input from user");
|
|
2327
|
+
resolve(parsed.data);
|
|
2328
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2329
|
+
id: nanoid(),
|
|
2330
|
+
timestamp: Date.now(),
|
|
2331
|
+
rootMessageId: messageId,
|
|
2332
|
+
type: "INPUTS_VALID",
|
|
2333
|
+
data: {
|
|
2334
|
+
runnerId: this.#runnerId,
|
|
2335
|
+
sessionId: this.#sessionId,
|
|
2336
|
+
executionContext: this.#executionContext
|
|
2337
|
+
}
|
|
2338
|
+
}));
|
|
2339
|
+
} catch (error) {
|
|
2340
|
+
this.#logger.error(error, "error sending INPUTS_VALID message to worker");
|
|
2341
|
+
reject(error);
|
|
2342
|
+
}
|
|
2343
|
+
return;
|
|
2344
|
+
}
|
|
2345
|
+
attempts += 1;
|
|
2346
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2347
|
+
id: nanoid(),
|
|
2348
|
+
timestamp: Date.now(),
|
|
2349
|
+
rootMessageId: messageId,
|
|
2350
|
+
type: "INPUTS_ERROR",
|
|
2351
|
+
data: {
|
|
2352
|
+
sessionId: this.#sessionId,
|
|
2353
|
+
issues: parsed.error.issues,
|
|
2354
|
+
attemptsRemaining: maxRetryAttempts - attempts,
|
|
2355
|
+
executionContext: this.#executionContext
|
|
2356
|
+
}
|
|
2357
|
+
}));
|
|
2358
|
+
if (attempts >= maxRetryAttempts) {
|
|
2359
|
+
this.#logger.error("maximum attempts reached for input %s", messageId);
|
|
2360
|
+
return reject(/* @__PURE__ */ new Error(`maximum attempts reached for input ${messageId}`));
|
|
2361
|
+
}
|
|
2362
|
+
this.#logger.warn("invalid input %s for %s", parsed.error, messageId);
|
|
2363
|
+
this.#pendingIOs.set(messageId, resolveIO);
|
|
2364
|
+
this.#logger.debug({ messageId }, "waiting for user to provide valid input");
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
this.#pendingIOs.set(messageId, resolveIO);
|
|
2368
|
+
this.#logger.debug({ messageId }, "setup pending IO for form input");
|
|
2369
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2370
|
+
id: messageId,
|
|
2371
|
+
timestamp: Date.now(),
|
|
2372
|
+
type: "RENDER_INPUTS",
|
|
2373
|
+
data: {
|
|
2374
|
+
sessionId: this.#sessionId,
|
|
2375
|
+
form: sanitizedForm,
|
|
2376
|
+
title,
|
|
2377
|
+
description,
|
|
2378
|
+
executionContext: this.#executionContext,
|
|
2379
|
+
defaultValues
|
|
2380
|
+
}
|
|
2381
|
+
}));
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Prompts the user for a text input.
|
|
2386
|
+
*/
|
|
2387
|
+
async textInput({ label, description, optional, secure, inputType, mode, maxRetryAttempts = 5, validationSchema, defaultValue }) {
|
|
2388
|
+
const form = { value: {
|
|
2389
|
+
type: "text",
|
|
2390
|
+
label,
|
|
2391
|
+
description,
|
|
2392
|
+
optional,
|
|
2393
|
+
secure,
|
|
2394
|
+
mode,
|
|
2395
|
+
inputType
|
|
2396
|
+
} };
|
|
2397
|
+
const stringValidationSchema = validationSchema ?? getValidationSchemaForField(form.value);
|
|
2398
|
+
const formValidationSchema = z$1.object({ value: stringValidationSchema });
|
|
2399
|
+
return (await this.#formInput({
|
|
2400
|
+
form,
|
|
2401
|
+
validationSchema: formValidationSchema,
|
|
2402
|
+
maxRetryAttempts,
|
|
2403
|
+
defaultValues: { value: defaultValue }
|
|
2404
|
+
})).value;
|
|
2405
|
+
}
|
|
2406
|
+
/**
|
|
2407
|
+
* Prompts the user for a number input.
|
|
2408
|
+
*/
|
|
2409
|
+
async numberInput({ label, description, optional, min, max, maxRetryAttempts = 5, validationSchema, defaultValue }) {
|
|
2410
|
+
const form = { value: {
|
|
2411
|
+
type: "number",
|
|
2412
|
+
min,
|
|
2413
|
+
max,
|
|
2414
|
+
optional,
|
|
2415
|
+
label,
|
|
2416
|
+
description
|
|
2417
|
+
} };
|
|
2418
|
+
const numberValidationSchema = validationSchema ?? getValidationSchemaForField(form.value);
|
|
2419
|
+
const formValidationSchema = z$1.object({ value: numberValidationSchema });
|
|
2420
|
+
return (await this.#formInput({
|
|
2421
|
+
form,
|
|
2422
|
+
validationSchema: formValidationSchema,
|
|
2423
|
+
maxRetryAttempts,
|
|
2424
|
+
defaultValues: { value: defaultValue }
|
|
2425
|
+
})).value;
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Prompts the user for a date input. It can be single date, multiple dates or a date range.
|
|
2429
|
+
*/
|
|
2430
|
+
async dateInput({ label, description, optional, min, max, mode = "single", maxRetryAttempts = 5, validationSchema, defaultValue }) {
|
|
2431
|
+
const form = { value: {
|
|
2432
|
+
type: "date",
|
|
2433
|
+
min,
|
|
2434
|
+
max,
|
|
2435
|
+
mode,
|
|
2436
|
+
optional,
|
|
2437
|
+
label,
|
|
2438
|
+
description
|
|
2439
|
+
} };
|
|
2440
|
+
const dateValidationSchema = validationSchema ?? getValidationSchemaForField(form.value);
|
|
2441
|
+
const formValidationSchema = z$1.object({ value: dateValidationSchema });
|
|
2442
|
+
return (await this.#formInput({
|
|
2443
|
+
form,
|
|
2444
|
+
validationSchema: formValidationSchema,
|
|
2445
|
+
maxRetryAttempts,
|
|
2446
|
+
defaultValues: { value: defaultValue }
|
|
2447
|
+
})).value;
|
|
2448
|
+
}
|
|
2449
|
+
/**
|
|
2450
|
+
* Prompts the user for a select input. It can be single select or multi select
|
|
2451
|
+
*/
|
|
2452
|
+
async selectInput({ label, description, optional, options, mode = "select", maxRetryAttempts = 5, defaultValue }) {
|
|
2453
|
+
const form = { value: {
|
|
2454
|
+
type: "select",
|
|
2455
|
+
label,
|
|
2456
|
+
description,
|
|
2457
|
+
options,
|
|
2458
|
+
mode,
|
|
2459
|
+
optional
|
|
2460
|
+
} };
|
|
2461
|
+
const formValidationSchema = getValidationSchemaForForm(form);
|
|
2462
|
+
return (await this.#formInput({
|
|
2463
|
+
form,
|
|
2464
|
+
validationSchema: formValidationSchema,
|
|
2465
|
+
maxRetryAttempts,
|
|
2466
|
+
defaultValues: { value: defaultValue }
|
|
2467
|
+
})).value;
|
|
2468
|
+
}
|
|
2469
|
+
async tableInput({ label, description, data, max, min, mode = "single", optional, defaultValue }) {
|
|
2470
|
+
const form = { value: {
|
|
2471
|
+
type: "table",
|
|
2472
|
+
label,
|
|
2473
|
+
description,
|
|
2474
|
+
data,
|
|
2475
|
+
max,
|
|
2476
|
+
min,
|
|
2477
|
+
mode,
|
|
2478
|
+
optional
|
|
2479
|
+
} };
|
|
2480
|
+
const formValidationSchema = getValidationSchemaForForm(form);
|
|
2481
|
+
return (await this.#formInput({
|
|
2482
|
+
form,
|
|
2483
|
+
validationSchema: formValidationSchema,
|
|
2484
|
+
maxRetryAttempts: 1,
|
|
2485
|
+
defaultValues: { value: defaultValue }
|
|
2486
|
+
})).value;
|
|
2487
|
+
}
|
|
2488
|
+
/**
|
|
2489
|
+
* Prompts the user for a search input. It can be single search or multi search.
|
|
2490
|
+
*/
|
|
2491
|
+
async searchInput({ label, description, mode = "single", optional, min, max, handleSearch }) {
|
|
2492
|
+
const form = { value: {
|
|
2493
|
+
type: "search",
|
|
2494
|
+
label,
|
|
2495
|
+
description,
|
|
2496
|
+
mode,
|
|
2497
|
+
optional,
|
|
2498
|
+
min,
|
|
2499
|
+
max,
|
|
2500
|
+
handleSearch
|
|
2501
|
+
} };
|
|
2502
|
+
const formValidationSchema = getValidationSchemaForForm(form);
|
|
2503
|
+
return (await this.#formInput({
|
|
2504
|
+
form,
|
|
2505
|
+
validationSchema: formValidationSchema,
|
|
2506
|
+
maxRetryAttempts: 1
|
|
2507
|
+
})).value;
|
|
2508
|
+
}
|
|
2509
|
+
/**
|
|
2510
|
+
* Prompts the user for a form input.
|
|
2511
|
+
*/
|
|
2512
|
+
async formInput({ form, validationSchema, maxRetryAttempts = 5, title, description, defaultValues }) {
|
|
2513
|
+
const schema = validationSchema ?? getValidationSchemaForForm(form);
|
|
2514
|
+
return await this.#formInput({
|
|
2515
|
+
form,
|
|
2516
|
+
validationSchema: schema,
|
|
2517
|
+
maxRetryAttempts,
|
|
2518
|
+
title,
|
|
2519
|
+
description,
|
|
2520
|
+
defaultValues
|
|
2521
|
+
});
|
|
2522
|
+
}
|
|
2523
|
+
/**
|
|
2524
|
+
* Creates a loader instance to show loading state to the user.
|
|
2525
|
+
*/
|
|
2526
|
+
loader({ title, description }) {
|
|
2527
|
+
return new Loader({
|
|
2528
|
+
title,
|
|
2529
|
+
description,
|
|
2530
|
+
sessionId: this.#sessionId,
|
|
2531
|
+
webSocketClient: this.#webSocketClient,
|
|
2532
|
+
signal: this.#signal,
|
|
2533
|
+
executionContext: this.#executionContext
|
|
2534
|
+
});
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Creates a progress loader instance to show progress of a long-running operation to the user.
|
|
2538
|
+
* It can be used to indicate that a process is ongoing and provide feedback on its status.
|
|
2539
|
+
*/
|
|
2540
|
+
progressLoader({ title, description, itemsInQueue }) {
|
|
2541
|
+
return new ProgressLoader({
|
|
2542
|
+
title,
|
|
2543
|
+
description,
|
|
2544
|
+
itemsInQueue,
|
|
2545
|
+
webSocketClient: this.#webSocketClient,
|
|
2546
|
+
sessionId: this.#sessionId,
|
|
2547
|
+
signal: this.#signal,
|
|
2548
|
+
executionContext: this.#executionContext
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
/**
|
|
2552
|
+
* Prompts the user for a confirmation (OK/Cancel).
|
|
2553
|
+
* Returns true if the user clicked OK, false if Cancel.
|
|
2554
|
+
*/
|
|
2555
|
+
async confirm({ title, description, okButtonLabel = "OK", cancelButtonLabel = "Cancel", block }) {
|
|
2556
|
+
const message = {
|
|
2557
|
+
id: nanoid(),
|
|
2558
|
+
timestamp: Date.now(),
|
|
2559
|
+
type: "CONFIRM",
|
|
2560
|
+
data: {
|
|
2561
|
+
runnerId: this.#runnerId,
|
|
2562
|
+
sessionId: this.#sessionId,
|
|
2563
|
+
title,
|
|
2564
|
+
description,
|
|
2565
|
+
okButtonLabel,
|
|
2566
|
+
cancelButtonLabel,
|
|
2567
|
+
block,
|
|
2568
|
+
executionContext: this.#executionContext
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
return new Promise(async (resolve, reject) => {
|
|
2572
|
+
if (this.#signal.aborted) {
|
|
2573
|
+
this.#logger.warn("confirm aborted before start");
|
|
2574
|
+
return reject(/* @__PURE__ */ new Error("confirm aborted"));
|
|
2575
|
+
}
|
|
2576
|
+
this.#signal.addEventListener("abort", () => {
|
|
2577
|
+
this.#logger.warn("confirm aborted");
|
|
2578
|
+
reject(/* @__PURE__ */ new Error("confirm aborted"));
|
|
2579
|
+
});
|
|
2580
|
+
const resolveIO = async (receivedIOMessage) => {
|
|
2581
|
+
this.#logger.debug({ message: receivedIOMessage }, "received confirm response from user");
|
|
2582
|
+
if (receivedIOMessage.type === "CONFIRM_RESPONSE" && receivedIOMessage.rootMessageId === message.id) {
|
|
2583
|
+
this.#pendingIOs.delete(message.id);
|
|
2584
|
+
resolve(receivedIOMessage.data.confirmed);
|
|
2585
|
+
runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2586
|
+
id: nanoid(),
|
|
2587
|
+
timestamp: Date.now(),
|
|
2588
|
+
rootMessageId: message.id,
|
|
2589
|
+
type: "CONFIRM_VALID",
|
|
2590
|
+
data: {
|
|
2591
|
+
sessionId: this.#sessionId,
|
|
2592
|
+
executionContext: this.#executionContext
|
|
2593
|
+
}
|
|
2594
|
+
}));
|
|
2595
|
+
}
|
|
2596
|
+
};
|
|
2597
|
+
try {
|
|
2598
|
+
this.#logger.debug({ message }, "sending confirm message to worker");
|
|
2599
|
+
this.#pendingIOs.set(message.id, resolveIO);
|
|
2600
|
+
this.#logger.debug({ messageId: message.id }, "setup pending IO for confirm");
|
|
2601
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement(message));
|
|
2602
|
+
} catch (error) {
|
|
2603
|
+
this.#logger.error(error, "error during confirm");
|
|
2604
|
+
reject(error);
|
|
2605
|
+
}
|
|
2606
|
+
});
|
|
2607
|
+
}
|
|
2608
|
+
/**
|
|
2609
|
+
* Shows a message to the user.
|
|
2610
|
+
*/
|
|
2611
|
+
async message({ title, description, message }) {
|
|
2612
|
+
await runWithRetries(() => this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2613
|
+
id: nanoid(),
|
|
2614
|
+
timestamp: Date.now(),
|
|
2615
|
+
type: "SHOW_MESSAGE",
|
|
2616
|
+
data: {
|
|
2617
|
+
sessionId: this.#sessionId,
|
|
2618
|
+
message,
|
|
2619
|
+
title,
|
|
2620
|
+
description,
|
|
2621
|
+
executionContext: this.#executionContext
|
|
2622
|
+
}
|
|
2623
|
+
}));
|
|
2624
|
+
}
|
|
2625
|
+
};
|
|
2626
|
+
|
|
2627
|
+
//#endregion
|
|
2628
|
+
//#region src/internal/tool.ts
|
|
2629
|
+
const TOOL_HANDLER_TAG_NAME = Symbol("TOOL_HANDLER");
|
|
2630
|
+
const TOOL_TAG_NAME = Symbol("TOOL");
|
|
2631
|
+
/**
|
|
2632
|
+
* Tool class is responsible for running the tool's logic.
|
|
2633
|
+
* It manages the tool lifecycle, communication with the worker, and handles sending messages back to the ForgeRunner.
|
|
2634
|
+
* It uses the IO component to facilitate input/output operations for the tool.
|
|
2635
|
+
*/
|
|
2636
|
+
var Tool = class {
|
|
2637
|
+
#metadata;
|
|
2638
|
+
#abortController = new AbortController();
|
|
2639
|
+
#handler;
|
|
2640
|
+
#io;
|
|
2641
|
+
#block;
|
|
2642
|
+
#logger;
|
|
2643
|
+
constructor(options, logger) {
|
|
2644
|
+
this.#metadata = options.metadata;
|
|
2645
|
+
this.#handler = options.handler;
|
|
2646
|
+
this.#logger = logger.child({
|
|
2647
|
+
sessionId: this.#metadata.sessionId,
|
|
2648
|
+
component: "TOOL"
|
|
2649
|
+
});
|
|
2650
|
+
this.#io = new IO({
|
|
2651
|
+
sessionId: this.#metadata.sessionId,
|
|
2652
|
+
runnerId: this.#metadata.runnerId,
|
|
2653
|
+
webSocketClient: options.webSocketClient,
|
|
2654
|
+
signal: this.#abortController.signal,
|
|
2655
|
+
executionContext: { type: "TOOL" }
|
|
2656
|
+
}, this.#logger);
|
|
2657
|
+
this.#block = new Block({ signal: this.#abortController.signal });
|
|
2658
|
+
this.#logger.debug("initialized Tool instance");
|
|
2659
|
+
}
|
|
2660
|
+
async run() {
|
|
2661
|
+
return new Promise(async (resolve, reject) => {
|
|
2662
|
+
if (this.#abortController.signal.aborted) {
|
|
2663
|
+
this.#logger.info("tool execution aborted before start");
|
|
2664
|
+
return Promise.reject(/* @__PURE__ */ new Error("tool execution aborted"));
|
|
2665
|
+
}
|
|
2666
|
+
this.#abortController.signal.addEventListener("abort", () => {
|
|
2667
|
+
this.#logger.info("tool execution aborted");
|
|
2668
|
+
reject(/* @__PURE__ */ new Error("Tool execution aborted"));
|
|
2669
|
+
});
|
|
2670
|
+
try {
|
|
2671
|
+
this.#logger.info("running tool handler...");
|
|
2672
|
+
const output = await this.#handler({
|
|
2673
|
+
io: this.#io,
|
|
2674
|
+
signal: this.#abortController.signal,
|
|
2675
|
+
block: this.#block,
|
|
2676
|
+
metadata: this.#metadata
|
|
2677
|
+
});
|
|
2678
|
+
this.#logger.info("tool handler completed successfully");
|
|
2679
|
+
this.#io[STOP_SYMBOL]();
|
|
2680
|
+
resolve(output);
|
|
2681
|
+
} catch (error) {
|
|
2682
|
+
this.#logger.error(error, "error running tool handler");
|
|
2683
|
+
return reject(error);
|
|
2684
|
+
}
|
|
2685
|
+
});
|
|
2686
|
+
}
|
|
2687
|
+
stop() {
|
|
2688
|
+
this.#logger.info("stopping Tool...");
|
|
2689
|
+
this.#abortController.abort();
|
|
2690
|
+
this.#logger.info("Tool stopped");
|
|
2691
|
+
}
|
|
2692
|
+
};
|
|
2693
|
+
|
|
2694
|
+
//#endregion
|
|
2695
|
+
//#region src/internal/workflow-builder.ts
|
|
2696
|
+
var WorkflowBuilder = class {
|
|
2697
|
+
#logger;
|
|
2698
|
+
#nodes = /* @__PURE__ */ new Set();
|
|
2699
|
+
#edges = /* @__PURE__ */ new Map();
|
|
2700
|
+
constructor(logger) {
|
|
2701
|
+
this.#logger = logger.child({ component: "WORKFLOW_BUILDER" });
|
|
2702
|
+
this.#nodes.add("START");
|
|
2703
|
+
this.#nodes.add("END");
|
|
2704
|
+
}
|
|
2705
|
+
flow(from, to) {
|
|
2706
|
+
this.#nodes.add(from);
|
|
2707
|
+
this.#nodes.add(to);
|
|
2708
|
+
if (!this.#edges.has(from)) this.#edges.set(from, []);
|
|
2709
|
+
this.#edges.get(from).push({
|
|
2710
|
+
type: "flow",
|
|
2711
|
+
to,
|
|
2712
|
+
from
|
|
2713
|
+
});
|
|
2714
|
+
return this;
|
|
2715
|
+
}
|
|
2716
|
+
branch(from, condition, targetMap) {
|
|
2717
|
+
if (Object.keys(targetMap).length < 2) throw new Error(`branch from '${from}' must have at least 2 targets`);
|
|
2718
|
+
this.#nodes.add(from);
|
|
2719
|
+
for (const to of Object.values(targetMap)) this.#nodes.add(to);
|
|
2720
|
+
if (!this.#edges.has(from)) this.#edges.set(from, []);
|
|
2721
|
+
this.#edges.get(from).push({
|
|
2722
|
+
type: "branch",
|
|
2723
|
+
condition,
|
|
2724
|
+
targetMap,
|
|
2725
|
+
from
|
|
2726
|
+
});
|
|
2727
|
+
return this;
|
|
2728
|
+
}
|
|
2729
|
+
build() {
|
|
2730
|
+
this.#validateStructure();
|
|
2731
|
+
this.#validateEdges();
|
|
2732
|
+
this.#validateConnectivity();
|
|
2733
|
+
this.#logger.debug("workflow graph validated successfully");
|
|
2734
|
+
return {
|
|
2735
|
+
nodes: this.#nodes,
|
|
2736
|
+
edges: this.#edges
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
/**
|
|
2740
|
+
* Validate basic structure
|
|
2741
|
+
*/
|
|
2742
|
+
#validateStructure() {
|
|
2743
|
+
if (!this.#nodes.has("START")) {
|
|
2744
|
+
this.#logger.error("workflow must have START node");
|
|
2745
|
+
throw new Error("workflow must have a START node");
|
|
2746
|
+
}
|
|
2747
|
+
if (!this.#nodes.has("END")) {
|
|
2748
|
+
this.#logger.error("workflow must have END node");
|
|
2749
|
+
throw new Error("workflow must have an END node");
|
|
2750
|
+
}
|
|
2751
|
+
if ((this.#edges.get("START") || []).length === 0) {
|
|
2752
|
+
this.#logger.error("START node must have at least one outgoing edge");
|
|
2753
|
+
throw new Error("START node must have at least one outgoing edge");
|
|
2754
|
+
}
|
|
2755
|
+
if ((this.#edges.get("END") || []).length > 0) {
|
|
2756
|
+
this.#logger.error("END node cannot have outgoing edges");
|
|
2757
|
+
throw new Error("END node cannot have outgoing edges");
|
|
2758
|
+
}
|
|
2759
|
+
const allEdges = Array.from(this.#edges.values()).flatMap((e) => e);
|
|
2760
|
+
for (const edge of allEdges) {
|
|
2761
|
+
if (edge.type === "flow" && edge.to === "START") {
|
|
2762
|
+
this.#logger.error("START node cannot have incoming edges");
|
|
2763
|
+
throw new Error("START node cannot have incoming edges");
|
|
2764
|
+
}
|
|
2765
|
+
if (edge.type === "branch" && Object.values(edge.targetMap).includes("START")) {
|
|
2766
|
+
this.#logger.error("START node cannot have incoming edges");
|
|
2767
|
+
throw new Error("START node cannot have incoming edges");
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
}
|
|
2771
|
+
/**
|
|
2772
|
+
* Validate edges
|
|
2773
|
+
*/
|
|
2774
|
+
#validateEdges() {
|
|
2775
|
+
for (const [node, edges] of this.#edges.entries()) {
|
|
2776
|
+
const hasFlow = edges.some((e) => e.type === "flow");
|
|
2777
|
+
const hasBranch = edges.some((e) => e.type === "branch");
|
|
2778
|
+
if (hasFlow && hasBranch) {
|
|
2779
|
+
this.#logger.error(`node '${node}' cannot have both flow and branch edges`);
|
|
2780
|
+
throw new Error(`node '${node}' cannot have both flow edges and branch edges. use either multiple flow edges OR one branch edge.`);
|
|
2781
|
+
}
|
|
2782
|
+
if (edges.length > 1 && hasBranch) {
|
|
2783
|
+
this.#logger.error(`node '${node}' has multiple edges including a branch`);
|
|
2784
|
+
throw new Error(`node '${node}' has multiple edges including a branch. a node can have only ONE branch edge.`);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
const allEdges = Array.from(this.#edges.values()).flatMap((e) => e);
|
|
2788
|
+
for (const edge of allEdges) if (edge.type === "branch") {
|
|
2789
|
+
for (const [key, target] of Object.entries(edge.targetMap)) if (!this.#nodes.has(target)) {
|
|
2790
|
+
this.#logger.error(`branch from '${edge.from}' has unknown target '${target}' for key '${key}'`);
|
|
2791
|
+
throw new Error(`branch from '${edge.from}' has unknown target '${target}' for key '${key}'`);
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
/**
|
|
2796
|
+
* Validate connectivity using BFS
|
|
2797
|
+
*/
|
|
2798
|
+
#validateConnectivity() {
|
|
2799
|
+
const reachableFromStart = this.#getReachableNodes("START");
|
|
2800
|
+
const unreachable = Array.from(this.#nodes).filter((node) => node !== "START" && !reachableFromStart.has(node));
|
|
2801
|
+
if (unreachable.length > 0) {
|
|
2802
|
+
this.#logger.error(`nodes unreachable from START: ${unreachable.join(", ")}`);
|
|
2803
|
+
throw new Error(`nodes unreachable from START: ${unreachable.join(", ")}`);
|
|
2804
|
+
}
|
|
2805
|
+
if (!reachableFromStart.has("END")) {
|
|
2806
|
+
this.#logger.error("END node is not reachable from START");
|
|
2807
|
+
throw new Error("END node is not reachable from START");
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
/**
|
|
2811
|
+
* Get all nodes reachable from a starting node (BFS)
|
|
2812
|
+
*/
|
|
2813
|
+
#getReachableNodes(start) {
|
|
2814
|
+
const reachable = /* @__PURE__ */ new Set();
|
|
2815
|
+
const queue = [start];
|
|
2816
|
+
reachable.add(start);
|
|
2817
|
+
while (queue.length > 0) {
|
|
2818
|
+
const current = queue.shift();
|
|
2819
|
+
const edges = this.#edges.get(current) || [];
|
|
2820
|
+
for (const edge of edges) if (edge.type === "flow") {
|
|
2821
|
+
if (!reachable.has(edge.to)) {
|
|
2822
|
+
reachable.add(edge.to);
|
|
2823
|
+
queue.push(edge.to);
|
|
2824
|
+
}
|
|
2825
|
+
} else if (edge.type === "branch") {
|
|
2826
|
+
for (const target of Object.values(edge.targetMap)) if (!reachable.has(target)) {
|
|
2827
|
+
reachable.add(target);
|
|
2828
|
+
queue.push(target);
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
return reachable;
|
|
2833
|
+
}
|
|
2834
|
+
};
|
|
2835
|
+
|
|
2836
|
+
//#endregion
|
|
2837
|
+
//#region src/internal/agent.ts
|
|
2838
|
+
const AGENT_TAG_NAME = Symbol("AGENT");
|
|
2839
|
+
const AGENT_STEP_TAG_NAME = Symbol("AGENT_STEP");
|
|
2840
|
+
var Agent = class {
|
|
2841
|
+
#logger;
|
|
2842
|
+
#webSocketClient;
|
|
2843
|
+
#abortController = new AbortController();
|
|
2844
|
+
#metadata;
|
|
2845
|
+
#stepDefinitions;
|
|
2846
|
+
#bootstrap;
|
|
2847
|
+
#workflowBuilder;
|
|
2848
|
+
#workflowGraph;
|
|
2849
|
+
#activeSteps = /* @__PURE__ */ new Set();
|
|
2850
|
+
#MAX_ITERATIONS = 1e3;
|
|
2851
|
+
#iterationCount = 0;
|
|
2852
|
+
#contextSchema;
|
|
2853
|
+
#context;
|
|
2854
|
+
constructor(definition, options, logger) {
|
|
2855
|
+
this.#metadata = options.metadata;
|
|
2856
|
+
this.#stepDefinitions = definition.steps;
|
|
2857
|
+
this.#bootstrap = definition.bootstrap;
|
|
2858
|
+
this.#contextSchema = definition.contextSchema;
|
|
2859
|
+
this.#webSocketClient = options.webSocketClient;
|
|
2860
|
+
this.#logger = logger.child({
|
|
2861
|
+
sessionId: this.#metadata.sessionId,
|
|
2862
|
+
component: "AGENT"
|
|
2863
|
+
});
|
|
2864
|
+
this.#workflowBuilder = new WorkflowBuilder(this.#logger);
|
|
2865
|
+
this.#workflowBuilder = definition.workflow(this.#workflowBuilder);
|
|
2866
|
+
this.#workflowGraph = this.#workflowBuilder.build();
|
|
2867
|
+
}
|
|
2868
|
+
get #agentWorkflow() {
|
|
2869
|
+
const nodeNames = Object.entries(this.#stepDefinitions).reduce((acc, [key, step]) => {
|
|
2870
|
+
acc[key] = step.name ?? key;
|
|
2871
|
+
return acc;
|
|
2872
|
+
}, {});
|
|
2873
|
+
function getNodeLabel(nodeId) {
|
|
2874
|
+
if (nodeId === "START" || nodeId === "END") return nodeId;
|
|
2875
|
+
return nodeNames[String(nodeId)] ?? nodeId;
|
|
2876
|
+
}
|
|
2877
|
+
return {
|
|
2878
|
+
nodes: Array.from(this.#workflowGraph.nodes).map(getNodeLabel),
|
|
2879
|
+
edges: Array.from(this.#workflowGraph.edges.values()).flat().map((edge) => {
|
|
2880
|
+
if (edge.type === "flow") return {
|
|
2881
|
+
type: "flow",
|
|
2882
|
+
from: getNodeLabel(edge.from),
|
|
2883
|
+
to: getNodeLabel(edge.to)
|
|
2884
|
+
};
|
|
2885
|
+
return {
|
|
2886
|
+
type: "branch",
|
|
2887
|
+
from: getNodeLabel(edge.from),
|
|
2888
|
+
targetMap: Object.entries(edge.targetMap).reduce((acc, [key, target]) => {
|
|
2889
|
+
acc[key] = getNodeLabel(target);
|
|
2890
|
+
return acc;
|
|
2891
|
+
}, {})
|
|
2892
|
+
};
|
|
2893
|
+
})
|
|
2894
|
+
};
|
|
2895
|
+
}
|
|
2896
|
+
async run() {
|
|
2897
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2898
|
+
id: nanoid(),
|
|
2899
|
+
timestamp: Date.now(),
|
|
2900
|
+
type: "AGENT_START",
|
|
2901
|
+
data: {
|
|
2902
|
+
sessionId: this.#metadata.sessionId,
|
|
2903
|
+
agentWorkflow: this.#agentWorkflow,
|
|
2904
|
+
executionContext: { type: "AGENT" }
|
|
2905
|
+
}
|
|
2906
|
+
});
|
|
2907
|
+
await this.#initializeContext();
|
|
2908
|
+
invariant(this.#context, "agent context is not initialized");
|
|
2909
|
+
this.#activeSteps.add("START");
|
|
2910
|
+
while (this.#activeSteps.size > 0 && !this.#activeSteps.has("END") && this.#iterationCount < this.#MAX_ITERATIONS) {
|
|
2911
|
+
this.#logger.debug({ activeSteps: Array.from(this.#activeSteps) }, "current active steps");
|
|
2912
|
+
const stepsToExecute = Array.from(this.#activeSteps);
|
|
2913
|
+
await this.#executeSteps(stepsToExecute);
|
|
2914
|
+
const nextActiveSteps = /* @__PURE__ */ new Set();
|
|
2915
|
+
for (const stepName of stepsToExecute) {
|
|
2916
|
+
const edges = this.#workflowGraph.edges.get(stepName);
|
|
2917
|
+
if (!edges) continue;
|
|
2918
|
+
for (const edge of edges) if (edge.type === "flow") nextActiveSteps.add(edge.to);
|
|
2919
|
+
else if (edge.type === "branch") {
|
|
2920
|
+
const target = edge.condition(this.#context);
|
|
2921
|
+
const nextStep = edge.targetMap[target];
|
|
2922
|
+
if (nextStep) nextActiveSteps.add(nextStep);
|
|
2923
|
+
}
|
|
2924
|
+
}
|
|
2925
|
+
this.#logger.debug({ nextActiveSteps: Array.from(nextActiveSteps) }, "next active steps");
|
|
2926
|
+
this.#activeSteps = nextActiveSteps;
|
|
2927
|
+
this.#iterationCount += 1;
|
|
2928
|
+
this.#logger.debug({ iterationCount: this.#iterationCount }, "completed an iteration of the agent run loop");
|
|
2929
|
+
}
|
|
2930
|
+
return this.#context;
|
|
2931
|
+
}
|
|
2932
|
+
async #executeSteps(stepsToExecute) {
|
|
2933
|
+
const stepDefinitions = stepsToExecute.filter((stepName) => stepName !== "START" && stepName !== "END").map((stepName) => {
|
|
2934
|
+
const stepDef = this.#stepDefinitions[stepName];
|
|
2935
|
+
if (!stepDef) throw new Error(`step definition not found for step: ${String(stepName)}`);
|
|
2936
|
+
return {
|
|
2937
|
+
name: stepName,
|
|
2938
|
+
...stepDef
|
|
2939
|
+
};
|
|
2940
|
+
});
|
|
2941
|
+
return Promise.all(stepDefinitions.map(async (stepDefinition) => {
|
|
2942
|
+
invariant(this.#context, "agent context is not initialized");
|
|
2943
|
+
const executionContext = {
|
|
2944
|
+
id: nanoid(),
|
|
2945
|
+
type: "STEP",
|
|
2946
|
+
step: {
|
|
2947
|
+
name: stepDefinition.name,
|
|
2948
|
+
description: stepDefinition.description
|
|
2949
|
+
}
|
|
2950
|
+
};
|
|
2951
|
+
const io = new IO({
|
|
2952
|
+
webSocketClient: this.#webSocketClient,
|
|
2953
|
+
executionContext,
|
|
2954
|
+
runnerId: this.#metadata.runnerId,
|
|
2955
|
+
sessionId: this.#metadata.sessionId,
|
|
2956
|
+
signal: this.#abortController.signal
|
|
2957
|
+
}, this.#logger);
|
|
2958
|
+
const block = new Block({ signal: this.#abortController.signal });
|
|
2959
|
+
try {
|
|
2960
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2961
|
+
id: nanoid(),
|
|
2962
|
+
timestamp: Date.now(),
|
|
2963
|
+
type: "STEP_START",
|
|
2964
|
+
data: {
|
|
2965
|
+
sessionId: this.#metadata.sessionId,
|
|
2966
|
+
executionContext
|
|
2967
|
+
}
|
|
2968
|
+
});
|
|
2969
|
+
this.#logger.debug({ stepName: stepDefinition.name }, "executing agent step");
|
|
2970
|
+
const output = await stepDefinition.handler({
|
|
2971
|
+
io,
|
|
2972
|
+
block,
|
|
2973
|
+
context: this.#context,
|
|
2974
|
+
updateContext: this.#updateContext.bind(this),
|
|
2975
|
+
metadata: {
|
|
2976
|
+
agentId: this.#metadata.agentId,
|
|
2977
|
+
runnerId: this.#metadata.runnerId,
|
|
2978
|
+
sessionId: this.#metadata.sessionId,
|
|
2979
|
+
stepName: stepDefinition.name,
|
|
2980
|
+
stepDescription: stepDefinition.description
|
|
2981
|
+
},
|
|
2982
|
+
signal: this.#abortController.signal
|
|
2983
|
+
});
|
|
2984
|
+
this.#logger.debug({
|
|
2985
|
+
stepName: stepDefinition.name,
|
|
2986
|
+
output
|
|
2987
|
+
}, "agent step executed successfully");
|
|
2988
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
2989
|
+
id: nanoid(),
|
|
2990
|
+
timestamp: Date.now(),
|
|
2991
|
+
type: "STEP_COMPLETE",
|
|
2992
|
+
data: {
|
|
2993
|
+
output,
|
|
2994
|
+
sessionId: this.#metadata.sessionId,
|
|
2995
|
+
executionContext
|
|
2996
|
+
}
|
|
2997
|
+
});
|
|
2998
|
+
} catch (error) {
|
|
2999
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
3000
|
+
id: nanoid(),
|
|
3001
|
+
timestamp: Date.now(),
|
|
3002
|
+
type: "STEP_ERROR",
|
|
3003
|
+
data: {
|
|
3004
|
+
executionContext,
|
|
3005
|
+
error: {
|
|
3006
|
+
message: getErrorMessage(error),
|
|
3007
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
3008
|
+
code: error instanceof Error && "code" in error ? String(error.code) : void 0
|
|
3009
|
+
},
|
|
3010
|
+
sessionId: this.#metadata.sessionId
|
|
3011
|
+
}
|
|
3012
|
+
});
|
|
3013
|
+
this.#logger.error({ error }, "error executing step");
|
|
3014
|
+
throw error;
|
|
3015
|
+
} finally {
|
|
3016
|
+
io[STOP_SYMBOL]();
|
|
3017
|
+
}
|
|
3018
|
+
}));
|
|
3019
|
+
}
|
|
3020
|
+
async #initializeContext() {
|
|
3021
|
+
if (typeof this.#bootstrap === "function") {
|
|
3022
|
+
const executionContext = {
|
|
3023
|
+
type: "STEP",
|
|
3024
|
+
id: nanoid(),
|
|
3025
|
+
step: { name: "Bootstrap" }
|
|
3026
|
+
};
|
|
3027
|
+
const io = new IO({
|
|
3028
|
+
webSocketClient: this.#webSocketClient,
|
|
3029
|
+
executionContext,
|
|
3030
|
+
runnerId: this.#metadata.runnerId,
|
|
3031
|
+
sessionId: this.#metadata.sessionId,
|
|
3032
|
+
signal: this.#abortController.signal
|
|
3033
|
+
}, this.#logger);
|
|
3034
|
+
const block = new Block({ signal: this.#abortController.signal });
|
|
3035
|
+
try {
|
|
3036
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
3037
|
+
id: nanoid(),
|
|
3038
|
+
timestamp: Date.now(),
|
|
3039
|
+
type: "STEP_START",
|
|
3040
|
+
data: {
|
|
3041
|
+
sessionId: this.#metadata.sessionId,
|
|
3042
|
+
executionContext
|
|
3043
|
+
}
|
|
3044
|
+
});
|
|
3045
|
+
const initContext = await this.#bootstrap({
|
|
3046
|
+
io,
|
|
3047
|
+
block
|
|
3048
|
+
});
|
|
3049
|
+
this.#context = this.#contextSchema.parse(initContext);
|
|
3050
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
3051
|
+
id: nanoid(),
|
|
3052
|
+
timestamp: Date.now(),
|
|
3053
|
+
type: "STEP_COMPLETE",
|
|
3054
|
+
data: {
|
|
3055
|
+
output: "Bootstrap completed successfully",
|
|
3056
|
+
sessionId: this.#metadata.sessionId,
|
|
3057
|
+
executionContext
|
|
3058
|
+
}
|
|
3059
|
+
});
|
|
3060
|
+
} catch (error) {
|
|
3061
|
+
this.#logger.error({ error }, "Failed to bootstrap agent");
|
|
3062
|
+
await this.#webSocketClient.sendToServerWithAcknowledgement({
|
|
3063
|
+
id: nanoid(),
|
|
3064
|
+
timestamp: Date.now(),
|
|
3065
|
+
type: "STEP_ERROR",
|
|
3066
|
+
data: {
|
|
3067
|
+
executionContext,
|
|
3068
|
+
error: {
|
|
3069
|
+
message: getErrorMessage(error),
|
|
3070
|
+
stack: error instanceof Error ? error.stack : void 0,
|
|
3071
|
+
code: error instanceof Error && "code" in error ? String(error.code) : void 0
|
|
3072
|
+
},
|
|
3073
|
+
sessionId: this.#metadata.sessionId
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
3076
|
+
throw error;
|
|
3077
|
+
} finally {
|
|
3078
|
+
io[STOP_SYMBOL]();
|
|
3079
|
+
}
|
|
3080
|
+
} else this.#context = this.#contextSchema.parse({});
|
|
3081
|
+
}
|
|
3082
|
+
#updateContext(updates) {
|
|
3083
|
+
invariant(this.#context, "agent context is not initialized");
|
|
3084
|
+
const newValues = typeof updates === "function" ? updates(this.#context) : updates;
|
|
3085
|
+
this.#context = this.#contextSchema.parse({
|
|
3086
|
+
...this.#context,
|
|
3087
|
+
...newValues
|
|
3088
|
+
});
|
|
3089
|
+
}
|
|
3090
|
+
};
|
|
3091
|
+
|
|
3092
|
+
//#endregion
|
|
3093
|
+
export { __toESM as C, __require as S, startAgentMessageSchema as _, TOOL_TAG_NAME as a, stopToolMessageSchema as b, getErrorMessage as c, runWithRetries as d, ackMessageSchema as f, runnerId as g, initCommunicationMessageSchema as h, TOOL_HANDLER_TAG_NAME as i, invariant as l, heartbeatAckMessageSchema as m, AGENT_TAG_NAME as n, Tool as o, baseMessageSchema as p, Agent as r, convertToWords as s, AGENT_STEP_TAG_NAME as t, exponentialBackoff as u, startToolMessageSchema as v, __commonJS as x, stopAgentMessageSchema as y };
|