llmz 0.6.0 → 0.6.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 (110) hide show
  1. package/DOCS.md +1 -3
  2. package/dist/_baseForOwn-CFhWe_W6.js +48 -0
  3. package/dist/_baseForOwn-buOZDFbK.cjs +103 -0
  4. package/dist/_baseIteratee-CF4qP2a8.cjs +2377 -0
  5. package/dist/_baseIteratee-P_firB7b.js +2138 -0
  6. package/dist/_getPrototype-CG7Dxrrz.js +6 -0
  7. package/dist/_getPrototype-DQDlNVVM.cjs +10 -0
  8. package/dist/_overArg-C5Hy7oCi.cjs +196 -0
  9. package/dist/_overArg-CRYbj1NH.js +155 -0
  10. package/dist/citations.d.ts +11 -11
  11. package/dist/component-BwixNVH8.cjs +73 -0
  12. package/dist/component-DGG7d_Mz.js +44 -0
  13. package/dist/context.d.ts +8 -8
  14. package/dist/custom-client-BPmEoWKu.cjs +2618 -0
  15. package/dist/custom-client-NUoxrFQh.js +2547 -0
  16. package/dist/dual-modes-D_p-jedw.js +2750 -0
  17. package/dist/dual-modes-wAOAlaBS.cjs +2840 -0
  18. package/dist/errors-C962uJdS.cjs +220 -0
  19. package/dist/errors-Cg1G0Awu.js +161 -0
  20. package/dist/execute-BEaq3jkV.cjs +1003 -0
  21. package/dist/execute-DYvFRs54.js +1001 -0
  22. package/dist/exit-BGi0Kk0y.cjs +428 -0
  23. package/dist/exit-CDdxDBRT.js +417 -0
  24. package/dist/index.cjs +1786 -1489
  25. package/dist/index.d.ts +10 -9
  26. package/dist/index.js +1721 -1479
  27. package/dist/index.workerd.js +17534 -16875
  28. package/dist/isEmpty-BhJRCqIF.js +52 -0
  29. package/dist/isEmpty-LY533Wmh.cjs +57 -0
  30. package/dist/isPlainObject-CSxXVKCk.cjs +56 -0
  31. package/dist/isPlainObject-D39AzPO2.js +51 -0
  32. package/dist/jsx-BWvT6ukg.cjs +75 -0
  33. package/dist/jsx-CIgdGGVs.js +52 -0
  34. package/dist/jsx.d.ts +2 -2
  35. package/dist/prompts/chat-mode/system.md.d.ts +1 -1
  36. package/dist/prompts/chat-mode/user.md.d.ts +1 -1
  37. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  38. package/dist/prompts/worker-mode/user.md.d.ts +1 -1
  39. package/dist/quickjs-variant-BYhMBpwU.js +45 -0
  40. package/dist/quickjs-variant-CsIwTVFC.cjs +56 -0
  41. package/dist/quickjs-variant.workerd.d.ts +1 -1
  42. package/dist/result.d.ts +12 -12
  43. package/dist/rolldown-runtime-EAsCxrDo.js +14 -0
  44. package/dist/runtime/interpret-result.d.ts +1 -1
  45. package/dist/snapshots.d.ts +5 -5
  46. package/dist/stack-traces-BIE_5Xwf.js +21 -0
  47. package/dist/stack-traces-ntw_qhoy.cjs +26 -0
  48. package/dist/tool-CAo-BQHs.js +643 -0
  49. package/dist/tool-DdPZb0JW.cjs +654 -0
  50. package/dist/tool.d.ts +3 -3
  51. package/dist/truncator-B6aaJaN1.cjs +276 -0
  52. package/dist/truncator-DZqEqnpD.js +253 -0
  53. package/dist/typings-BwAz_TM9.cjs +784 -0
  54. package/dist/typings-CrBa7Tyy.js +743 -0
  55. package/dist/uniq-BYQ7GWwb.js +183 -0
  56. package/dist/uniq-G872RWmE.cjs +200 -0
  57. package/dist/utils-UBeAFeEI.js +950 -0
  58. package/dist/utils-ZpJm00ed.cjs +1075 -0
  59. package/dist/vm/errors.d.ts +2 -2
  60. package/dist/vm-BjkJqSQH.cjs +3438 -0
  61. package/dist/vm-C5vf1LH3.js +3436 -0
  62. package/package.json +7 -7
  63. package/dist/chunk-34GJUS6U.js +0 -3266
  64. package/dist/chunk-3UZKLXAD.cjs +0 -3249
  65. package/dist/chunk-4POZJQXN.js +0 -1530
  66. package/dist/chunk-5WBNTV42.cjs +0 -1530
  67. package/dist/chunk-5ZF6NTYI.cjs +0 -33
  68. package/dist/chunk-72ZWBNZV.js +0 -173
  69. package/dist/chunk-DDSJTR6Q.cjs +0 -257
  70. package/dist/chunk-GDJTKI7J.js +0 -792
  71. package/dist/chunk-GLXADNTR.js +0 -199
  72. package/dist/chunk-GOWPACSK.cjs +0 -199
  73. package/dist/chunk-HB2G32AK.js +0 -257
  74. package/dist/chunk-HC2QZTVT.cjs +0 -3266
  75. package/dist/chunk-HEAQAEFZ.cjs +0 -173
  76. package/dist/chunk-HMMM32RG.cjs +0 -792
  77. package/dist/chunk-I56MPOVG.cjs +0 -62
  78. package/dist/chunk-KIN7Y247.cjs +0 -32
  79. package/dist/chunk-KTDBAJBB.cjs +0 -1685
  80. package/dist/chunk-KWQTYXAT.js +0 -62
  81. package/dist/chunk-LOX7GOR6.js +0 -1685
  82. package/dist/chunk-PK72FAKD.cjs +0 -175
  83. package/dist/chunk-PZE6PIPG.cjs +0 -621
  84. package/dist/chunk-RGUG3UMF.cjs +0 -26
  85. package/dist/chunk-TDALRNGL.js +0 -621
  86. package/dist/chunk-UGHFNCPD.js +0 -26
  87. package/dist/chunk-WSVDMGMR.js +0 -175
  88. package/dist/chunk-XTEHT2TK.js +0 -33
  89. package/dist/chunk-YEAWWJSJ.js +0 -32
  90. package/dist/chunk-YRS7KRKP.js +0 -3249
  91. package/dist/component-2NYFY6CW.cjs +0 -14
  92. package/dist/component-ASNZHQUR.js +0 -14
  93. package/dist/dual-modes-S5TJ5JVJ.js +0 -10
  94. package/dist/dual-modes-TCMWBZIH.cjs +0 -10
  95. package/dist/execute-FF7D46TY.js +0 -1109
  96. package/dist/execute-IK6O4SU2.cjs +0 -1109
  97. package/dist/exit-MX56VN2C.cjs +0 -8
  98. package/dist/exit-UQ3EUX5D.js +0 -8
  99. package/dist/jsx-DDZ63UUF.js +0 -13
  100. package/dist/jsx-ULPWX5TW.cjs +0 -13
  101. package/dist/tool-KD7FL45V.js +0 -11
  102. package/dist/tool-VE2YHIY2.cjs +0 -11
  103. package/dist/truncator-73RCL52Y.js +0 -12
  104. package/dist/truncator-FZNLYSDL.cjs +0 -12
  105. package/dist/typings-E2RROCLT.js +0 -10
  106. package/dist/typings-LQOBZXSO.cjs +0 -10
  107. package/dist/utils-IATCUNKF.js +0 -43
  108. package/dist/utils-ITB4NEL7.cjs +0 -43
  109. package/dist/vm-6D3IIIU7.cjs +0 -12
  110. package/dist/vm-QO5FSGPN.js +0 -12
@@ -1,33 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
- var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
5
-
6
- // src/jsx.ts
7
- var _zui = require('@bpinternal/zui');
8
- function isAnyJsxComponent(component) {
9
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string";
10
- }
11
- function isJsxComponent(type, component) {
12
- return typeof component === "object" && component !== null && "__jsx" in component && component.__jsx === true && typeof component.type === "string" && typeof type === "string" && component.type.toUpperCase().trim() === type.toUpperCase().trim();
13
- }
14
- var createJsxComponent = (props) => ({
15
- __jsx: true,
16
- type: _chunkHC2QZTVTcjs.isString_default.call(void 0, props.type) ? props.type.toUpperCase() : "__unknown__",
17
- children: Array.isArray(props.children) ? props.children : props.children ? [props.children] : [],
18
- props: _chunkHC2QZTVTcjs.isPlainObject_default.call(void 0, props.props) ? props.props : {}
19
- });
20
- var Jsx = _zui.z.custom(
21
- (value) => isAnyJsxComponent(value),
22
- (value) => ({
23
- params: { value },
24
- message: `Invalid JSX component: ${value}`
25
- })
26
- );
27
-
28
-
29
-
30
-
31
-
32
-
33
- exports.isAnyJsxComponent = isAnyJsxComponent; exports.isJsxComponent = isJsxComponent; exports.createJsxComponent = createJsxComponent; exports.Jsx = Jsx;
@@ -1,173 +0,0 @@
1
- import {
2
- getTokenizer
3
- } from "./chunk-GLXADNTR.js";
4
-
5
- // src/truncator.ts
6
- var DEFAULT_REMOVE_CHUNK = 250;
7
- var WRAP_OPEN_TAG_1 = "\u3010TRUNCATE";
8
- var WRAP_OPEN_TAG_2 = "\u3011";
9
- var WRAP_CLOSE_TAG = "\u3010/TRUNCATE\u3011";
10
- var REGEXP = `(${WRAP_OPEN_TAG_1}(?:\\s+[\\w:]+)*\\s*${WRAP_OPEN_TAG_2})([\\s\\S]*?)(${WRAP_CLOSE_TAG})`;
11
- var DEFAULT_TRUNCATE_OPTIONS = {
12
- preserve: "top",
13
- flex: 1,
14
- minTokens: 0
15
- };
16
- function wrapContent(content, options) {
17
- const preserve = (options == null ? void 0 : options.preserve) ?? DEFAULT_TRUNCATE_OPTIONS.preserve;
18
- const flex = (options == null ? void 0 : options.flex) ?? DEFAULT_TRUNCATE_OPTIONS.flex;
19
- const minTokens = (options == null ? void 0 : options.minTokens) ?? DEFAULT_TRUNCATE_OPTIONS.minTokens;
20
- return `${WRAP_OPEN_TAG_1} preserve:${preserve} flex:${flex} min:${minTokens} ${WRAP_OPEN_TAG_2}${content}${WRAP_CLOSE_TAG}`;
21
- }
22
- function truncateWrappedContent({
23
- messages,
24
- tokenLimit,
25
- throwOnFailure = true
26
- }) {
27
- var _a, _b, _c;
28
- const tokenizer = getTokenizer();
29
- const parts = [];
30
- for (const msg of messages) {
31
- const current = [];
32
- const content = typeof msg.content === "string" ? msg.content : "";
33
- let match;
34
- const parser = new _MessageContentParser();
35
- while ((match = parser.parse(content)) !== null) {
36
- const { attributes, nonTruncatableContent, wrappedContent } = match;
37
- if (nonTruncatableContent) {
38
- current.push({
39
- content: nonTruncatableContent,
40
- tokens: tokenizer.count(nonTruncatableContent),
41
- truncatable: false
42
- });
43
- }
44
- current.push({
45
- content: wrappedContent,
46
- tokens: tokenizer.count(wrappedContent),
47
- truncatable: true,
48
- attributes: {
49
- preserve: attributes.preserve,
50
- flex: Number(attributes.flex) || DEFAULT_TRUNCATE_OPTIONS.flex,
51
- minTokens: Number(attributes.min) || DEFAULT_TRUNCATE_OPTIONS.minTokens
52
- }
53
- });
54
- }
55
- const remainingContent = parser.getRemainingContent(content);
56
- if (remainingContent) {
57
- current.push({
58
- content: remainingContent,
59
- tokens: tokenizer.count(remainingContent),
60
- truncatable: false
61
- });
62
- }
63
- parts.push(current);
64
- }
65
- let currentCount = _countTotalTokens(parts);
66
- while (currentCount > tokenLimit) {
67
- const { biggest, secondBiggest } = _getTwoBiggestTruncables(parts);
68
- if (!biggest || !biggest.truncatable || biggest.tokens <= 0) {
69
- if (throwOnFailure) {
70
- throw new Error(`Cannot truncate further, current count: ${currentCount}`);
71
- } else {
72
- break;
73
- }
74
- }
75
- const delta = Math.max(biggest.tokens - ((secondBiggest == null ? void 0 : secondBiggest.tokens) ?? 0), DEFAULT_REMOVE_CHUNK);
76
- const room = Math.min(delta, biggest.tokens);
77
- let toRemove = Math.min(room, currentCount - tokenLimit);
78
- if (toRemove <= 0) {
79
- if (throwOnFailure) {
80
- throw new Error(`Cannot truncate further, current count: ${currentCount}`);
81
- } else {
82
- break;
83
- }
84
- }
85
- if (biggest.tokens - toRemove < (((_a = biggest.attributes) == null ? void 0 : _a.minTokens) ?? 0)) {
86
- toRemove = biggest.tokens - (((_b = biggest.attributes) == null ? void 0 : _b.minTokens) ?? 0);
87
- }
88
- const preserve = ((_c = biggest.attributes) == null ? void 0 : _c.preserve) ?? DEFAULT_TRUNCATE_OPTIONS.preserve;
89
- const split = tokenizer.splitAndSlice(biggest.content);
90
- if (preserve === "bottom") {
91
- biggest.content = split.slice(toRemove).join("");
92
- } else if (preserve === "top") {
93
- biggest.content = split.slice(0, -toRemove).join("");
94
- } else {
95
- const anchor = Math.ceil(split.length / 2);
96
- const radius = Math.ceil(toRemove / 2);
97
- const left = anchor - radius;
98
- const right = anchor + radius;
99
- biggest.content = split.slice(0, left).join("") + split.slice(right).join("");
100
- }
101
- biggest.tokens -= toRemove;
102
- currentCount -= toRemove;
103
- }
104
- return messages.map((msg, i) => {
105
- const p = parts[i];
106
- return {
107
- ...msg,
108
- content: typeof msg.content === "string" ? _renderRemainingWrappers(p.map((part) => part.content).join("")) : msg.content
109
- };
110
- });
111
- }
112
- var _MessageContentParser = class {
113
- _regex;
114
- _lastIndex = 0;
115
- constructor() {
116
- this._regex = _createRegex();
117
- }
118
- parse(content) {
119
- const match = this._regex.exec(content);
120
- if (!match) {
121
- return null;
122
- }
123
- const attributes = match[1].split(/\s+/).slice(1).filter((x) => x !== WRAP_OPEN_TAG_2).map((x) => x.split(":")).reduce(
124
- (acc, [key, value]) => ({ ...acc, [key]: value }),
125
- {}
126
- );
127
- let nonTruncatableContent = void 0;
128
- if (match.index > this._lastIndex) {
129
- nonTruncatableContent = content.slice(this._lastIndex, match.index);
130
- }
131
- const wrappedContent = match[2];
132
- this._lastIndex = this._regex.lastIndex;
133
- return { attributes, nonTruncatableContent, wrappedContent };
134
- }
135
- getRemainingContent(content) {
136
- if (this._lastIndex < content.length) {
137
- const remainingContent = content.slice(this._lastIndex);
138
- return remainingContent;
139
- }
140
- return null;
141
- }
142
- };
143
- var _createRegex = () => new RegExp(REGEXP, "g");
144
- var _renderRemainingWrappers = (content) => content.replace(_createRegex(), "$2");
145
- var stripTruncationTags = (content) => _renderRemainingWrappers(content);
146
- var _countTotalTokens = (parts) => parts.reduce((acc, x) => acc + x.reduce((acc2, y) => acc2 + y.tokens, 0), 0);
147
- var _getTwoBiggestTruncables = (parts) => {
148
- var _a, _b;
149
- let biggest = null;
150
- let secondBiggest = null;
151
- for (const part of parts.flat()) {
152
- if (part.truncatable) {
153
- if (part.tokens <= (((_a = part.attributes) == null ? void 0 : _a.minTokens) ?? 0)) {
154
- continue;
155
- }
156
- const flex = ((_b = part.attributes) == null ? void 0 : _b.flex) ?? DEFAULT_TRUNCATE_OPTIONS.flex;
157
- const tokens = part.tokens * flex;
158
- if (!biggest || tokens > biggest.tokens) {
159
- secondBiggest = biggest;
160
- biggest = part;
161
- } else if (!secondBiggest || tokens > secondBiggest.tokens) {
162
- secondBiggest = part;
163
- }
164
- }
165
- }
166
- return { biggest, secondBiggest };
167
- };
168
-
169
- export {
170
- wrapContent,
171
- truncateWrappedContent,
172
- stripTruncationTags
173
- };
@@ -1,257 +0,0 @@
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
-
5
-
6
- var _chunkGOWPACSKcjs = require('./chunk-GOWPACSK.cjs');
7
-
8
-
9
- var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
10
-
11
- // src/exit.ts
12
- var _zui = require('@bpinternal/zui');
13
- var Exit = (_class = class _Exit {
14
- /** The primary name of the exit (used in return statements) */
15
-
16
- /** Alternative names that can be used to reference this exit */
17
- __init() {this.aliases = []}
18
- /** Human-readable description of when this exit should be used */
19
-
20
- /** Additional metadata for orchestration and custom logic */
21
-
22
- /** JSON Schema for validating exit result data */
23
-
24
- /**
25
- * Returns the Zod schema equivalent of the JSON schema (if available).
26
- * Used internally for validation and type inference.
27
- */
28
- get zSchema() {
29
- return this.schema ? _chunkGOWPACSKcjs.fromJSONSchemaCompat.call(void 0, this.schema) : void 0;
30
- }
31
- /**
32
- * Renames the exit and updates aliases accordingly.
33
- *
34
- * @param name - The new name for the exit (must be a valid identifier)
35
- * @returns This exit instance for chaining
36
- *
37
- * @example
38
- * ```typescript
39
- * const exit = new Exit({ name: 'old_name', description: 'Test exit' })
40
- * exit.rename('new_name')
41
- * console.log(exit.name) // 'new_name'
42
- * ```
43
- */
44
- rename(name) {
45
- const before = this.name;
46
- if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, name)) {
47
- throw new Error(
48
- `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.`
49
- );
50
- }
51
- this.name = name;
52
- this.aliases = _chunkHC2QZTVTcjs.uniq_default.call(void 0, [name, ...this.aliases.map((alias) => alias === before ? name : alias)]);
53
- return this;
54
- }
55
- /**
56
- * Creates a deep copy of this exit.
57
- *
58
- * The clone is completely independent and can be modified without affecting
59
- * the original exit. This is useful for creating variations of existing exits.
60
- *
61
- * @returns A new Exit instance with the same configuration
62
- *
63
- * @example
64
- * ```typescript
65
- * const originalExit = new Exit({
66
- * name: 'base',
67
- * description: 'Base exit',
68
- * schema: z.object({ status: z.string() }),
69
- * })
70
- *
71
- * const customExit = originalExit.clone().rename('custom')
72
- * // customExit is independent of originalExit
73
- * ```
74
- */
75
- clone() {
76
- return new _Exit({
77
- name: this.name,
78
- aliases: [...this.aliases],
79
- description: this.description,
80
- metadata: JSON.parse(JSON.stringify(this.metadata)),
81
- schema: this.zSchema
82
- });
83
- }
84
- /**
85
- * Type guard to check if this exit matches another exit by name.
86
- *
87
- * Used internally for type narrowing and exit comparison.
88
- *
89
- * @param exit - The exit to compare against
90
- * @returns True if the exits have the same name
91
- */
92
- is(exit) {
93
- return this.name === exit.name;
94
- }
95
- /**
96
- * Type guard to check if an ExitResult matches this exit.
97
- *
98
- * @param result - The exit result to check
99
- * @returns True if the result was created by this exit
100
- */
101
- match(result) {
102
- return result.exit instanceof _Exit && this.name === result.exit.name;
103
- }
104
- /**
105
- * Serializes this exit to a JSON-compatible object.
106
- *
107
- * @returns JSON representation of the exit
108
- *
109
- * @example
110
- * ```typescript
111
- * const exit = new Exit({
112
- * name: 'complete',
113
- * description: 'Task completed successfully',
114
- * })
115
- *
116
- * console.log(exit.toJSON())
117
- * // { name: 'complete', aliases: [], description: 'Task completed successfully', metadata: {}, schema: undefined }
118
- * ```
119
- */
120
- toJSON() {
121
- return {
122
- name: this.name,
123
- aliases: [...this.aliases],
124
- description: this.description,
125
- metadata: { ...this.metadata },
126
- schema: this.schema
127
- };
128
- }
129
- /**
130
- * Creates a new Exit instance.
131
- *
132
- * @param props - Exit configuration
133
- * @param props.name - Primary name for the exit (must be valid identifier)
134
- * @param props.description - Human-readable description of the exit's purpose
135
- * @param props.aliases - Alternative names that can be used to reference this exit
136
- * @param props.metadata - Additional data for orchestration and custom logic
137
- * @param props.schema - Zod schema for validating exit result data
138
- *
139
- * @example
140
- * ```typescript
141
- * // Simple exit without data validation
142
- * const exit = new Exit({
143
- * name: 'complete',
144
- * description: 'Task completed successfully',
145
- * })
146
- * ```
147
- *
148
- * @example
149
- * ```typescript
150
- * // Exit with typed result data
151
- * const approval = new Exit({
152
- * name: 'approved',
153
- * description: 'Request approved by system',
154
- * schema: z.object({
155
- * amount: z.number().positive(),
156
- * reference: z.string().min(1),
157
- * timestamp: z.date().default(() => new Date()),
158
- * }),
159
- * })
160
- * ```
161
- *
162
- * @example
163
- * ```typescript
164
- * // Exit with aliases and metadata
165
- * const handoff = new Exit({
166
- * name: 'handoff_support',
167
- * aliases: ['escalate', 'transfer'],
168
- * description: 'Transfer to human support agent',
169
- * metadata: {
170
- * department: 'customer_service',
171
- * priority: 'high',
172
- * },
173
- * schema: z.object({
174
- * reason: z.string(),
175
- * customerData: z.record(z.any()),
176
- * }),
177
- * })
178
- * ```
179
- */
180
- constructor(props) {;_class.prototype.__init.call(this);
181
- if (!_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, props.name)) {
182
- throw new Error(
183
- `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.`
184
- );
185
- }
186
- if (typeof props.description !== "string" || props.description.trim().length === 0) {
187
- throw new Error(
188
- `Invalid description for exit ${props.name}. Expected a non-empty string, but got type "${typeof props.description}"`
189
- );
190
- }
191
- if (props.metadata !== void 0 && typeof props.metadata !== "object") {
192
- throw new Error(
193
- `Invalid metadata for exit ${props.name}. Expected an object, but got type "${typeof props.metadata}"`
194
- );
195
- }
196
- if (props.aliases !== void 0 && !Array.isArray(props.aliases)) {
197
- throw new Error(
198
- `Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
199
- );
200
- }
201
- if (props.aliases && props.aliases.some((alias) => !_chunkGOWPACSKcjs.isValidIdentifier.call(void 0, alias))) {
202
- throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
203
- }
204
- if (typeof props.schema !== "undefined") {
205
- if (_chunkGOWPACSKcjs.isZuiSchema.call(void 0, props.schema)) {
206
- this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
207
- } else if (_chunkGOWPACSKcjs.isJsonSchema.call(void 0, props.schema)) {
208
- this.schema = props.schema;
209
- } else {
210
- throw new Error(
211
- `Invalid input schema for exit ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.schema}"`
212
- );
213
- }
214
- }
215
- this.name = props.name;
216
- this.aliases = _chunkHC2QZTVTcjs.uniq_default.call(void 0, [props.name, ..._nullishCoalesce(props.aliases, () => ( []))]);
217
- this.description = props.description;
218
- this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
219
- }
220
- /**
221
- * Ensures all exits in an array have unique names by renaming duplicates.
222
- *
223
- * When multiple exits have the same name, this method appends numbers to
224
- * create unique names (e.g., 'exit1', 'exit2'). This prevents naming conflicts
225
- * in execution contexts with multiple exits.
226
- *
227
- * @param exits - Array of exits that may have duplicate names
228
- * @returns Array of exits with guaranteed unique names
229
- *
230
- * @example
231
- * ```typescript
232
- * const exit1 = new Exit({ name: 'done', description: 'First done' })
233
- * const exit2 = new Exit({ name: 'done', description: 'Second done' })
234
- *
235
- * const uniqueExits = Exit.withUniqueNames([exit1, exit2])
236
- * // Result: [{ name: 'done' }, { name: 'done1' }]
237
- * ```
238
- */
239
- static __initStatic() {this.withUniqueNames = (exits) => {
240
- const names = /* @__PURE__ */ new Set();
241
- return exits.map((exit) => {
242
- if (exits.filter((t) => t.name === exit.name).length === 1) {
243
- return exit;
244
- }
245
- let counter = 1;
246
- let exitName = exit.name + counter;
247
- while (names.has(exitName)) {
248
- exitName = `${exit.name}${++counter}`;
249
- }
250
- return exit.rename(exitName);
251
- });
252
- }}
253
- }, _class.__initStatic(), _class);
254
-
255
-
256
-
257
- exports.Exit = Exit;