llmz 0.0.2

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.
Files changed (96) hide show
  1. package/README.md +41 -0
  2. package/dist/chunk-3CGLDS5T.cjs +3059 -0
  3. package/dist/chunk-3T465BEW.js +96 -0
  4. package/dist/chunk-6QDFMQHA.js +98 -0
  5. package/dist/chunk-7FIPXMZR.js +33 -0
  6. package/dist/chunk-7S3UY52U.js +3059 -0
  7. package/dist/chunk-A7BDFLAE.cjs +30 -0
  8. package/dist/chunk-BKGPO722.cjs +3079 -0
  9. package/dist/chunk-BOLDQGES.cjs +33 -0
  10. package/dist/chunk-C2TSWGYC.cjs +91 -0
  11. package/dist/chunk-DFZ6GX5C.js +220 -0
  12. package/dist/chunk-DILHJIMP.js +180 -0
  13. package/dist/chunk-E2B5DRIC.cjs +419 -0
  14. package/dist/chunk-E5W3P7EO.cjs +96 -0
  15. package/dist/chunk-ENFB45AI.cjs +220 -0
  16. package/dist/chunk-MSTBEKOQ.js +28 -0
  17. package/dist/chunk-PQN6HW7A.cjs +28 -0
  18. package/dist/chunk-Q4DEJGXD.js +344 -0
  19. package/dist/chunk-QPSUMPLP.js +419 -0
  20. package/dist/chunk-QZGFCB4T.cjs +344 -0
  21. package/dist/chunk-R2N2UUKC.cjs +98 -0
  22. package/dist/chunk-RB2L33ZR.js +3079 -0
  23. package/dist/chunk-RJHDQL4C.js +161 -0
  24. package/dist/chunk-UG2GCPHF.js +91 -0
  25. package/dist/chunk-UVSOAH2H.js +152 -0
  26. package/dist/chunk-VP6WWAE2.cjs +152 -0
  27. package/dist/chunk-YPOOKE3A.cjs +180 -0
  28. package/dist/chunk-YSQDPG26.js +30 -0
  29. package/dist/chunk-YUDUY7XW.cjs +284 -0
  30. package/dist/chunk-ZSRC3TN4.js +284 -0
  31. package/dist/chunk-ZUAFUOUR.cjs +161 -0
  32. package/dist/compiler/compiler.d.ts +28 -0
  33. package/dist/compiler/index.d.ts +2 -0
  34. package/dist/compiler/plugins/async-iterator.d.ts +4 -0
  35. package/dist/compiler/plugins/braces-tsx.d.ts +3 -0
  36. package/dist/compiler/plugins/jsx-preserve-newlines.d.ts +5 -0
  37. package/dist/compiler/plugins/line-tracking.d.ts +5 -0
  38. package/dist/compiler/plugins/replace-comment.d.ts +5 -0
  39. package/dist/compiler/plugins/return-async.d.ts +4 -0
  40. package/dist/compiler/plugins/track-tool-calls.d.ts +16 -0
  41. package/dist/compiler/plugins/variable-extraction.d.ts +5 -0
  42. package/dist/component-DWBRHLEN.cjs +9 -0
  43. package/dist/component-R3ZAVXUC.js +9 -0
  44. package/dist/component.d.ts +51 -0
  45. package/dist/component.default.d.ts +10 -0
  46. package/dist/context.d.ts +167 -0
  47. package/dist/dual-modes-2VDEOJ5D.js +13 -0
  48. package/dist/dual-modes-3MH5N6RY.cjs +13 -0
  49. package/dist/errors.d.ts +64 -0
  50. package/dist/exit-GYMXZZ4I.js +9 -0
  51. package/dist/exit-PQHMJEOG.cjs +9 -0
  52. package/dist/exit.d.ts +20 -0
  53. package/dist/formatting.d.ts +5 -0
  54. package/dist/getter.d.ts +2 -0
  55. package/dist/handlers.d.ts +10 -0
  56. package/dist/hoist.d.ts +2 -0
  57. package/dist/index.cjs +811 -0
  58. package/dist/index.d.ts +18 -0
  59. package/dist/index.js +811 -0
  60. package/dist/inspect.d.ts +6 -0
  61. package/dist/jsx-CJ2RBODH.js +14 -0
  62. package/dist/jsx-PPLE5YTB.cjs +14 -0
  63. package/dist/jsx.d.ts +11 -0
  64. package/dist/llmz-EGTGPSTX.cjs +1049 -0
  65. package/dist/llmz-WY74UVE3.js +1049 -0
  66. package/dist/llmz.d.ts +41 -0
  67. package/dist/objects.d.ts +24 -0
  68. package/dist/openai.d.ts +8 -0
  69. package/dist/prompts/chat-mode/system.md.d.ts +2 -0
  70. package/dist/prompts/chat-mode/user.md.d.ts +2 -0
  71. package/dist/prompts/common.d.ts +6 -0
  72. package/dist/prompts/dual-modes.d.ts +2 -0
  73. package/dist/prompts/prompt.d.ts +50 -0
  74. package/dist/prompts/worker-mode/system.md.d.ts +2 -0
  75. package/dist/prompts/worker-mode/user.md.d.ts +2 -0
  76. package/dist/snapshots.d.ts +61 -0
  77. package/dist/stack-traces.d.ts +1 -0
  78. package/dist/tool-AY47ML65.cjs +12 -0
  79. package/dist/tool-WVIPESKN.js +12 -0
  80. package/dist/tool.d.ts +30 -0
  81. package/dist/transcript.d.ts +9 -0
  82. package/dist/truncator-MTONQESU.js +11 -0
  83. package/dist/truncator-ZKPOW2I3.cjs +11 -0
  84. package/dist/truncator.d.ts +21 -0
  85. package/dist/types.d.ts +131 -0
  86. package/dist/typings-HTYLRNIC.js +11 -0
  87. package/dist/typings-QRJGGNUM.cjs +11 -0
  88. package/dist/typings.d.ts +5 -0
  89. package/dist/utils-TS23YJPE.js +38 -0
  90. package/dist/utils-UR4IMUHC.cjs +38 -0
  91. package/dist/utils.d.ts +21 -0
  92. package/dist/vm-4JFSZAMR.cjs +13 -0
  93. package/dist/vm-SMMA664M.js +13 -0
  94. package/dist/vm.d.ts +3 -0
  95. package/package.json +85 -0
  96. package/patches/source-map-js@1.2.1.patch +16 -0
@@ -0,0 +1,344 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
2
+
3
+
4
+ var _chunkENFB45AIcjs = require('./chunk-ENFB45AI.cjs');
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _chunk3CGLDS5Tcjs = require('./chunk-3CGLDS5T.cjs');
17
+
18
+ // src/inspect.ts
19
+ var _bytes = require('bytes'); var _bytes2 = _interopRequireDefault(_bytes);
20
+ var SUBTITLE_LN = "--------------";
21
+ var SECTION_SEP = "\n";
22
+ var NUMBER_LOCALE = new Intl.NumberFormat("en-US");
23
+ var LONG_TEXT_LENGTH = 4096;
24
+ var DEFAULT_OPTIONS = {
25
+ tokens: 1e5
26
+ };
27
+ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
28
+ const indent = 2;
29
+ let currentLength = 0;
30
+ let wasTruncated = false;
31
+ function recurse(currentObj, depth, currentIndent) {
32
+ if (depth > maxDepth || currentLength >= maxLength) {
33
+ wasTruncated = true;
34
+ return "...";
35
+ }
36
+ if (typeof currentObj === "object" && currentObj instanceof Date) {
37
+ currentIndent += 3;
38
+ try {
39
+ return currentObj.toISOString();
40
+ } catch (err) {
41
+ return `<Date: ${_nullishCoalesce((err == null ? void 0 : err.message), () => ( "Invalid Date"))}>`;
42
+ }
43
+ }
44
+ if (typeof currentObj !== "object" || currentObj === null) {
45
+ const value = JSON.stringify(currentObj);
46
+ currentLength += _chunkENFB45AIcjs.getTokenizer.call(void 0, ).count(value);
47
+ return value;
48
+ }
49
+ const indentation = " ".repeat(currentIndent);
50
+ if (Array.isArray(currentObj)) {
51
+ let result = "[\n";
52
+ for (let i = 0; i < currentObj.length && currentLength < maxLength; i++) {
53
+ if (i > 0) {
54
+ result += ",\n";
55
+ }
56
+ result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
57
+ }
58
+ result += "\n" + indentation + "]";
59
+ currentLength += _chunkENFB45AIcjs.getTokenizer.call(void 0, ).count(result);
60
+ return result;
61
+ } else {
62
+ let result = "{\n";
63
+ const keys = Object.keys(currentObj);
64
+ const numKeys = keys.length;
65
+ for (let i = 0; i < Math.min(numKeys, maxKeys) && currentLength < maxLength; i++) {
66
+ const key = keys[i];
67
+ if (i > 0) {
68
+ result += ",\n";
69
+ }
70
+ const value = recurse(currentObj[key], depth + 1, currentIndent + indent);
71
+ result += indentation + " ".repeat(indent) + `"${key}": ${value}`;
72
+ }
73
+ if (numKeys > maxKeys) {
74
+ wasTruncated = true;
75
+ result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
76
+ }
77
+ result += "\n" + indentation + "}";
78
+ currentLength += _chunkENFB45AIcjs.getTokenizer.call(void 0, ).count(result);
79
+ return result;
80
+ }
81
+ }
82
+ const output = _chunkENFB45AIcjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
83
+ return { output, truncated: wasTruncated };
84
+ }
85
+ function extractType(value, generic = true) {
86
+ if (value === null) {
87
+ return "null";
88
+ }
89
+ if (value === void 0 || typeof value === "undefined") {
90
+ return "undefined";
91
+ }
92
+ if (typeof value === "object" && Array.isArray(value)) {
93
+ if (!generic) {
94
+ return "Array";
95
+ }
96
+ if (value.length === 0) {
97
+ return "Array (empty)";
98
+ }
99
+ if (value.length === 1) {
100
+ return `Array<${extractType(value[0])}>`;
101
+ }
102
+ const types = /* @__PURE__ */ new Map();
103
+ for (const element of value) {
104
+ const type = extractType(element, false);
105
+ types.set(type, (types.get(type) || 0) + 1);
106
+ }
107
+ if (types.size <= 3) {
108
+ return `Array<${Array.from(types.keys()).join(" | ")}>`;
109
+ }
110
+ return "Array";
111
+ }
112
+ if (typeof value === "number") {
113
+ return "number";
114
+ }
115
+ if (typeof value === "boolean") {
116
+ return "boolean";
117
+ }
118
+ if (typeof value === "bigint") {
119
+ return "bigint";
120
+ }
121
+ if (typeof value === "function") {
122
+ return "function";
123
+ }
124
+ if (typeof value === "object" && value instanceof Date) {
125
+ return "date";
126
+ }
127
+ if (typeof value === "object" && value instanceof RegExp) {
128
+ return "regexp";
129
+ }
130
+ if (value instanceof Error) {
131
+ return "error";
132
+ }
133
+ if (typeof value === "string" && value.trim().length === 0) {
134
+ return "<empty string>";
135
+ }
136
+ return typeof value;
137
+ }
138
+ function previewValue(value, length = LONG_TEXT_LENGTH) {
139
+ if (value === null) {
140
+ return "<nil>";
141
+ }
142
+ if (value === void 0) {
143
+ return "<undefined>";
144
+ }
145
+ const previewStr = (str) => {
146
+ if (str.length > length) {
147
+ return _chunkENFB45AIcjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
148
+ }
149
+ return _chunkENFB45AIcjs.escapeString.call(void 0, str);
150
+ };
151
+ const previewObj = (obj) => {
152
+ const mapped = _chunk3CGLDS5Tcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
153
+ return JSON.stringify(mapped);
154
+ };
155
+ if (typeof value === "string") {
156
+ return "<string> " + previewStr(value);
157
+ }
158
+ if (typeof value === "object" && Array.isArray(value)) {
159
+ return "<array> " + previewStr(JSON.stringify(value));
160
+ }
161
+ if (typeof value === "object" && value instanceof Date) {
162
+ return "<date> " + value.toISOString();
163
+ }
164
+ if (typeof value === "object" && value instanceof RegExp) {
165
+ return "<regexp> " + value.toString();
166
+ }
167
+ if (typeof value === "object") {
168
+ return "<object> " + previewObj(value);
169
+ }
170
+ if (typeof value === "bigint") {
171
+ return "<bigint> " + value.toString();
172
+ }
173
+ if (typeof value === "function") {
174
+ return "<function> " + value.toString();
175
+ }
176
+ if (typeof value === "boolean") {
177
+ return "<boolean> " + value.toString();
178
+ }
179
+ if (value instanceof Error) {
180
+ return "<error> " + previewError(value);
181
+ }
182
+ if (typeof value === "number") {
183
+ return "<number> " + value.toString();
184
+ }
185
+ if (typeof value === "symbol") {
186
+ return "<symbol> " + value.toString();
187
+ }
188
+ return `${typeof value} ` + (_nullishCoalesce((value == null ? void 0 : value.toString()), () => ( "<unknown>")));
189
+ }
190
+ function previewError(err) {
191
+ const lines = [];
192
+ lines.push("Error: " + err.name);
193
+ lines.push(SUBTITLE_LN);
194
+ lines.push(previewValue(err.message));
195
+ lines.push(SECTION_SEP);
196
+ lines.push("Stack Trace:");
197
+ lines.push(SUBTITLE_LN);
198
+ lines.push(previewValue(_nullishCoalesce(err.stack, () => ( "<no stack trace>"))));
199
+ return lines.join("\n");
200
+ }
201
+ function previewArray(arr) {
202
+ if (!Array.isArray(arr)) {
203
+ throw new Error("Expected an array");
204
+ }
205
+ const lines = [];
206
+ const getItemPreview = (value, index) => `[${index}]`.padEnd(15) + ` ${previewValue(value)}`;
207
+ if (arr.length === 0) {
208
+ lines.push("// Array Is Empty (0 element)");
209
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
210
+ }
211
+ if (arr.length <= 10) {
212
+ lines.push("// Full Array Preview");
213
+ lines.push(SUBTITLE_LN);
214
+ lines.push(...arr.map(getItemPreview));
215
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
216
+ }
217
+ lines.push("// Analysis Summary");
218
+ lines.push(SUBTITLE_LN);
219
+ const typesCount = _chunk3CGLDS5Tcjs.countBy_default.call(void 0, arr, (item) => extractType(item, false));
220
+ const ordered = _chunk3CGLDS5Tcjs.orderBy_default.call(void 0,
221
+ arr.filter((item) => !_chunk3CGLDS5Tcjs.isNil_default.call(void 0, item) && JSON.stringify(item).length < 100),
222
+ (item) => JSON.stringify(item),
223
+ "asc"
224
+ );
225
+ const minValues = ordered.slice(0, 3).map((item) => previewValue(item, 10));
226
+ const maxValues = ordered.slice(-3).map((item) => previewValue(item, 10));
227
+ const uniqueItems = _chunk3CGLDS5Tcjs.uniqWith_default.call(void 0, arr, _chunk3CGLDS5Tcjs.isEqual_default);
228
+ const nullValues = _chunk3CGLDS5Tcjs.filter_default.call(void 0, arr, _chunk3CGLDS5Tcjs.isNil_default).length;
229
+ const memoryUsage = _bytes2.default.call(void 0, JSON.stringify(arr).length);
230
+ lines.push(`Total Items: ${arr.length}`);
231
+ lines.push(`Unique Items: ${uniqueItems.length}`);
232
+ lines.push(`Types: ${JSON.stringify(typesCount)}`);
233
+ lines.push(`Minimum Values: [${minValues.join(", ")}]`);
234
+ lines.push(`Maximum Values: [${maxValues.join(", ")}]`);
235
+ lines.push(`Memory Usage: ${memoryUsage}`);
236
+ lines.push(`Nil Values: ${nullValues}`);
237
+ lines.push("// Array Preview (truncated)");
238
+ lines.push(SUBTITLE_LN);
239
+ lines.push(...arr.map(getItemPreview));
240
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
241
+ }
242
+ function previewObject(obj, options) {
243
+ if (typeof obj !== "object" || Array.isArray(obj) || obj === null) {
244
+ throw new Error("Expected an object");
245
+ }
246
+ const lines = [];
247
+ const { output, truncated } = printLimitedJson(obj, 10, options.tokens, 20);
248
+ if (truncated) {
249
+ lines.push(SECTION_SEP);
250
+ lines.push("// Analysis Summary");
251
+ lines.push(SUBTITLE_LN);
252
+ const entries = Object.entries(obj);
253
+ const typesCount = _chunk3CGLDS5Tcjs.chain_default.call(void 0, entries).countBy(([, value]) => extractType(value, false)).entries().orderBy(1, "desc").filter(([, count]) => count > 1).slice(0, 3).fromPairs().value();
254
+ const keys = Object.keys(obj);
255
+ const uniqueEntries = _chunk3CGLDS5Tcjs.uniq_default.call(void 0, Object.values(obj));
256
+ const nilValues = _chunk3CGLDS5Tcjs.filter_default.call(void 0, entries, ([, value]) => _chunk3CGLDS5Tcjs.isNil_default.call(void 0, value)).length;
257
+ const memoryUsage = _bytes2.default.call(void 0, JSON.stringify(obj).length);
258
+ lines.push(`Total Entries: ${NUMBER_LOCALE.format(entries.length)}`);
259
+ lines.push(`Keys: ${previewValue(keys)}`);
260
+ lines.push(`Popular Types: ${previewValue(typesCount)}`);
261
+ lines.push(`Unique Values: ${NUMBER_LOCALE.format(uniqueEntries.length)}`);
262
+ lines.push(`Nil Values: ${NUMBER_LOCALE.format(nilValues)}`);
263
+ lines.push(`Memory Usage: ${memoryUsage}`);
264
+ }
265
+ if (_chunk3CGLDS5Tcjs.isEmpty_default.call(void 0, obj)) {
266
+ lines.push("// Empty Object {}");
267
+ } else {
268
+ lines.push(truncated ? "// Object Preview (truncated)" : "// Full Object Preview");
269
+ lines.push(SUBTITLE_LN);
270
+ lines.push(output);
271
+ }
272
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
273
+ }
274
+ function previewLongText(text, length = LONG_TEXT_LENGTH) {
275
+ const lines = [];
276
+ const urlPattern = /https?:\/\/[^\s]+/g;
277
+ const emailPattern = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
278
+ lines.push("// The string is too long to fully display, here is a preview:");
279
+ const previewStr = (str) => {
280
+ if (str.length > length) {
281
+ return str.slice(0, length) + " ... <truncated>";
282
+ }
283
+ return str;
284
+ };
285
+ lines.push(previewStr(text));
286
+ lines.push(SUBTITLE_LN);
287
+ lines.push("// Analysis Summary");
288
+ lines.push(SUBTITLE_LN);
289
+ const words = text.split(/\s+/);
290
+ const wordCount = words.length;
291
+ const uniqueWords = _chunk3CGLDS5Tcjs.uniq_default.call(void 0, words).length;
292
+ const wordFrequency = _chunk3CGLDS5Tcjs.countBy_default.call(void 0, words);
293
+ const mostCommonWords = _chunk3CGLDS5Tcjs.chain_default.call(void 0, wordFrequency).toPairs().orderBy(1, "desc").filter(([, count]) => count > 1).take(20).map(([word, count]) => `"${word}" ${count} times`).value().join("\n" + " ".repeat(22));
294
+ const urls = text.match(urlPattern) || [];
295
+ const emails = text.match(emailPattern) || [];
296
+ if (urls.length > 0) {
297
+ lines.push(`Found URLs: ${urls.length}`);
298
+ lines.push(`URLs: ${urls.join(", ")}`);
299
+ }
300
+ if (emails.length > 0) {
301
+ lines.push(`Found Emails: ${emails.length}`);
302
+ lines.push(`Emails: ${emails.join(", ")}`);
303
+ }
304
+ lines.push(`Length: ${NUMBER_LOCALE.format(text.length)} chars`);
305
+ lines.push(`Word Count: ${NUMBER_LOCALE.format(wordCount)} words`);
306
+ lines.push(`Unique Words: ${NUMBER_LOCALE.format(uniqueWords)}`);
307
+ lines.push(`Most Common Words: ${mostCommonWords}`);
308
+ return lines.join("\n").replace(/\n{2,}/g, SECTION_SEP);
309
+ }
310
+ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
311
+ options ??= DEFAULT_OPTIONS;
312
+ options.tokens ??= DEFAULT_OPTIONS.tokens;
313
+ try {
314
+ const genericType = extractType(value, false);
315
+ let header = "";
316
+ if (name) {
317
+ header = `// const ${name}: ${genericType}
318
+ `;
319
+ }
320
+ if (genericType === "Array") {
321
+ return header + previewArray(value);
322
+ } else if (genericType === "error") {
323
+ return header + previewError(value);
324
+ } else if (genericType === "object") {
325
+ return header + previewObject(value, options);
326
+ } else if (genericType === "boolean") {
327
+ return header + previewValue(value);
328
+ } else if (typeof value === "string") {
329
+ if (_chunkENFB45AIcjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
330
+ return header + previewValue(value);
331
+ } else {
332
+ return header + previewLongText(value);
333
+ }
334
+ }
335
+ return header + previewValue(value);
336
+ } catch (err) {
337
+ return `Error: ${_nullishCoalesce((err == null ? void 0 : err.message), () => ( "Unknown Error"))}`;
338
+ }
339
+ };
340
+
341
+
342
+
343
+
344
+ exports.extractType = extractType; exports.inspect = inspect;
@@ -0,0 +1,98 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
+
3
+
4
+ var _chunkENFB45AIcjs = require('./chunk-ENFB45AI.cjs');
5
+
6
+
7
+ var _chunk3CGLDS5Tcjs = require('./chunk-3CGLDS5T.cjs');
8
+
9
+ // src/exit.ts
10
+ var _zui = require('@bpinternal/zui');
11
+ var Exit = (_class = class _Exit {
12
+
13
+ __init() {this.aliases = []}
14
+
15
+
16
+
17
+ get zSchema() {
18
+ return this.schema ? _zui.z.fromJsonSchema(this.schema) : void 0;
19
+ }
20
+ rename(name) {
21
+ const before = this.name;
22
+ if (!_chunkENFB45AIcjs.isValidIdentifier.call(void 0, name)) {
23
+ throw new Error(
24
+ `Invalid name for exit ${name}. An exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
25
+ );
26
+ }
27
+ this.name = name;
28
+ this.aliases = _chunk3CGLDS5Tcjs.uniq_default.call(void 0, [name, ...this.aliases.map((alias) => alias === before ? name : alias)]);
29
+ return this;
30
+ }
31
+ clone() {
32
+ return new _Exit({
33
+ name: this.name,
34
+ aliases: [...this.aliases],
35
+ description: this.description,
36
+ metadata: JSON.parse(JSON.stringify(this.metadata)),
37
+ schema: this.zSchema
38
+ });
39
+ }
40
+ constructor(props) {;_class.prototype.__init.call(this);
41
+ if (!_chunkENFB45AIcjs.isValidIdentifier.call(void 0, props.name)) {
42
+ throw new Error(
43
+ `Invalid name for exit ${props.name}. A exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
44
+ );
45
+ }
46
+ if (typeof props.description !== "string" || props.description.trim().length === 0) {
47
+ throw new Error(
48
+ `Invalid description for exit ${props.name}. Expected a non-empty string, but got type "${typeof props.description}"`
49
+ );
50
+ }
51
+ if (props.metadata !== void 0 && typeof props.metadata !== "object") {
52
+ throw new Error(
53
+ `Invalid metadata for exit ${props.name}. Expected an object, but got type "${typeof props.metadata}"`
54
+ );
55
+ }
56
+ if (props.aliases !== void 0 && !Array.isArray(props.aliases)) {
57
+ throw new Error(
58
+ `Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
59
+ );
60
+ }
61
+ if (props.aliases && props.aliases.some((alias) => !_chunkENFB45AIcjs.isValidIdentifier.call(void 0, alias))) {
62
+ throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
63
+ }
64
+ if (typeof props.schema !== "undefined") {
65
+ if (props.schema && "toJsonSchema" in props.schema && typeof props.schema.toJsonSchema === "function") {
66
+ this.schema = props.schema.toJsonSchema();
67
+ } else if (_chunkENFB45AIcjs.isJsonSchema.call(void 0, props.schema)) {
68
+ this.schema = props.schema;
69
+ } else {
70
+ throw new Error(
71
+ `Invalid input schema for exit ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.schema}"`
72
+ );
73
+ }
74
+ }
75
+ this.name = props.name;
76
+ this.aliases = _chunk3CGLDS5Tcjs.uniq_default.call(void 0, [props.name, ..._nullishCoalesce(props.aliases, () => ( []))]);
77
+ this.description = props.description;
78
+ this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
79
+ }
80
+ static __initStatic() {this.withUniqueNames = (exits) => {
81
+ const names = /* @__PURE__ */ new Set();
82
+ return exits.map((exit) => {
83
+ if (exits.filter((t) => t.name === exit.name).length === 1) {
84
+ return exit;
85
+ }
86
+ let counter = 1;
87
+ let exitName = exit.name + counter;
88
+ while (names.has(exitName)) {
89
+ exitName = `${exit.name}${++counter}`;
90
+ }
91
+ return exit.rename(exitName);
92
+ });
93
+ }}
94
+ }, _class.__initStatic(), _class);
95
+
96
+
97
+
98
+ exports.Exit = Exit;