llmz 0.0.30 → 0.0.31
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/{chunk-WP4F6KMW.cjs → chunk-5BEKU5MZ.cjs} +2 -2
- package/dist/{chunk-VADA6DMR.cjs → chunk-66NCLCNT.cjs} +296 -10
- package/dist/{chunk-HCC76DDO.js → chunk-AAHUDKBY.js} +2 -2
- package/dist/{chunk-R3LXNE5N.cjs → chunk-CA7FRCZT.cjs} +303 -38
- package/dist/{chunk-DCYSCVQM.js → chunk-IAYPKHFV.js} +303 -38
- package/dist/{chunk-273DEMEU.cjs → chunk-J57224PD.cjs} +62 -8
- package/dist/{chunk-7POUFE5M.js → chunk-RC6YO5UW.js} +62 -8
- package/dist/{chunk-KQPGB6GB.js → chunk-WYFTNO2Y.js} +289 -3
- package/dist/compiler/plugins/html-to-markdown.d.ts +21 -0
- package/dist/compiler/plugins/jsx-undefined-vars.d.ts +14 -0
- package/dist/{dual-modes-DW3KRXT2.js → dual-modes-LEAHGCOF.js} +1 -1
- package/dist/{dual-modes-F4UV5VAZ.cjs → dual-modes-UBHAMQW4.cjs} +2 -2
- package/dist/exit-parser.d.ts +37 -0
- package/dist/index.cjs +12 -10
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -9
- package/dist/{llmz-DYB74G5C.cjs → llmz-NB4CQ5PW.cjs} +21 -42
- package/dist/{llmz-N6KWKJ2Q.js → llmz-VOXE65UW.js} +13 -34
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/{tool-GEBXW6AQ.js → tool-U6SV6BZ6.js} +1 -1
- package/dist/{tool-GMYMVXUK.cjs → tool-YCYYKKB3.cjs} +2 -2
- package/dist/tool.d.ts +1 -1
- package/dist/{vm-NGQ6DRS3.cjs → vm-2LG42J6U.cjs} +2 -2
- package/dist/{vm-J6UNJGIN.js → vm-FVQBX2XV.js} +1 -1
- package/package.json +1 -1
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
DualModePrompt,
|
|
3
3
|
extractType,
|
|
4
4
|
inspect
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-AAHUDKBY.js";
|
|
6
6
|
import {
|
|
7
7
|
Tool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-RC6YO5UW.js";
|
|
9
9
|
import {
|
|
10
10
|
LoopExceededError
|
|
11
11
|
} from "./chunk-MYLTD5WT.js";
|
|
@@ -20,9 +20,294 @@ import {
|
|
|
20
20
|
} from "./chunk-3JYCCI4S.js";
|
|
21
21
|
import {
|
|
22
22
|
cloneDeep_default,
|
|
23
|
-
isPlainObject_default
|
|
23
|
+
isPlainObject_default,
|
|
24
|
+
omit_default
|
|
24
25
|
} from "./chunk-7WRN4E42.js";
|
|
25
26
|
|
|
27
|
+
// src/exit-parser.ts
|
|
28
|
+
function isValuePrimitive(value) {
|
|
29
|
+
return value === null || value === void 0 || typeof value !== "object" || Array.isArray(value);
|
|
30
|
+
}
|
|
31
|
+
function generatePossibleWraps(value, shape, discriminator) {
|
|
32
|
+
const possibleWraps = [];
|
|
33
|
+
const commonNames = ["result", "value", "data", "message", "error", "output", "response"];
|
|
34
|
+
if (shape && typeof shape === "object") {
|
|
35
|
+
for (const key of Object.keys(shape)) {
|
|
36
|
+
if (key !== discriminator) {
|
|
37
|
+
const wrap = discriminator ? { [discriminator]: shape[discriminator]._def.value, [key]: value } : { [key]: value };
|
|
38
|
+
possibleWraps.push(wrap);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const name of commonNames) {
|
|
43
|
+
const hasName = possibleWraps.some((w) => Object.keys(w).includes(name));
|
|
44
|
+
if (!hasName) {
|
|
45
|
+
const wrap = discriminator && (shape == null ? void 0 : shape[discriminator]) ? { [discriminator]: shape[discriminator]._def.value, [name]: value } : { [name]: value };
|
|
46
|
+
possibleWraps.push(wrap);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return possibleWraps;
|
|
50
|
+
}
|
|
51
|
+
function tryObjectWrapping(schema, candidateValue) {
|
|
52
|
+
const possibleWraps = generatePossibleWraps(candidateValue, schema.shape);
|
|
53
|
+
for (const wrap of possibleWraps) {
|
|
54
|
+
const testParse = schema.safeParse(wrap);
|
|
55
|
+
if (testParse.success) {
|
|
56
|
+
return { success: true, valueToValidate: wrap, parsed: testParse };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { success: false, valueToValidate: candidateValue, parsed: { success: false } };
|
|
60
|
+
}
|
|
61
|
+
function detectDiscriminator(options) {
|
|
62
|
+
if (options.length === 0 || options[0]._def.typeName !== "ZodObject") {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
const firstShape = options[0].shape;
|
|
66
|
+
for (const key in firstShape) {
|
|
67
|
+
const firstFieldType = firstShape[key]._def.typeName;
|
|
68
|
+
if (firstFieldType === "ZodLiteral") {
|
|
69
|
+
const allHaveLiteral = options.every((opt) => {
|
|
70
|
+
var _a;
|
|
71
|
+
return ((_a = opt.shape[key]) == null ? void 0 : _a._def.typeName) === "ZodLiteral";
|
|
72
|
+
});
|
|
73
|
+
if (allHaveLiteral) {
|
|
74
|
+
return key;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return void 0;
|
|
79
|
+
}
|
|
80
|
+
function tryAddDiscriminator(schema, options, discriminator, valueToValidate) {
|
|
81
|
+
const matchingOptions = [];
|
|
82
|
+
for (const option of options) {
|
|
83
|
+
if (option._def.typeName === "ZodObject" && option.shape[discriminator]) {
|
|
84
|
+
const discriminatorValue = option.shape[discriminator]._def.value;
|
|
85
|
+
const wrappedValue = { [discriminator]: discriminatorValue, ...valueToValidate };
|
|
86
|
+
const testParse = schema.safeParse(wrappedValue);
|
|
87
|
+
if (testParse.success) {
|
|
88
|
+
matchingOptions.push({ wrappedValue });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (matchingOptions.length === 1) {
|
|
93
|
+
const wrapped = matchingOptions[0].wrappedValue;
|
|
94
|
+
return { success: true, valueToValidate: wrapped, parsed: schema.safeParse(wrapped) };
|
|
95
|
+
}
|
|
96
|
+
return { success: false, valueToValidate, parsed: { success: false } };
|
|
97
|
+
}
|
|
98
|
+
function tryUnionPrimitiveWrapping(schema, options, discriminator, valueToValidate) {
|
|
99
|
+
const allSuccessfulWraps = [];
|
|
100
|
+
for (const option of options) {
|
|
101
|
+
if (option._def.typeName === "ZodObject" && option.shape[discriminator]) {
|
|
102
|
+
const discriminatorValue = option.shape[discriminator]._def.value;
|
|
103
|
+
const possibleWraps = generatePossibleWraps(valueToValidate, option.shape, discriminator);
|
|
104
|
+
for (const wrap of possibleWraps) {
|
|
105
|
+
const finalWrap = { [discriminator]: discriminatorValue, ...wrap };
|
|
106
|
+
const testParse = schema.safeParse(finalWrap);
|
|
107
|
+
if (testParse.success) {
|
|
108
|
+
allSuccessfulWraps.push({ wrap: finalWrap });
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (allSuccessfulWraps.length === 1) {
|
|
115
|
+
const wrapped = allSuccessfulWraps[0].wrap;
|
|
116
|
+
return { success: true, valueToValidate: wrapped, parsed: schema.safeParse(wrapped) };
|
|
117
|
+
}
|
|
118
|
+
return { success: false, valueToValidate, parsed: { success: false } };
|
|
119
|
+
}
|
|
120
|
+
function tryUnionWrapping(schema, valueToValidate) {
|
|
121
|
+
const options = schema._def.options;
|
|
122
|
+
let discriminator = schema._def.discriminator;
|
|
123
|
+
if (!discriminator) {
|
|
124
|
+
discriminator = detectDiscriminator(options);
|
|
125
|
+
}
|
|
126
|
+
if (!discriminator) {
|
|
127
|
+
return { success: false, valueToValidate, parsed: { success: false } };
|
|
128
|
+
}
|
|
129
|
+
const isValueObject = valueToValidate !== null && typeof valueToValidate === "object" && !Array.isArray(valueToValidate);
|
|
130
|
+
const isPrimitive = isValuePrimitive(valueToValidate);
|
|
131
|
+
if (isValueObject && !(discriminator in valueToValidate)) {
|
|
132
|
+
const result = tryAddDiscriminator(schema, options, discriminator, valueToValidate);
|
|
133
|
+
if (result.success) {
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (isPrimitive) {
|
|
138
|
+
return tryUnionPrimitiveWrapping(schema, options, discriminator, valueToValidate);
|
|
139
|
+
}
|
|
140
|
+
return { success: false, valueToValidate, parsed: { success: false } };
|
|
141
|
+
}
|
|
142
|
+
function trySmartWrapping(schema, schemaType, valueToValidate, alternativeValue) {
|
|
143
|
+
const valuesToTry = [valueToValidate];
|
|
144
|
+
if (alternativeValue !== void 0 && alternativeValue !== valueToValidate) {
|
|
145
|
+
valuesToTry.push(alternativeValue);
|
|
146
|
+
}
|
|
147
|
+
for (const candidateValue of valuesToTry) {
|
|
148
|
+
const isPrimitive = isValuePrimitive(candidateValue);
|
|
149
|
+
if (schemaType === "ZodObject" && isPrimitive) {
|
|
150
|
+
const result = tryObjectWrapping(schema, candidateValue);
|
|
151
|
+
if (result.success) {
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (alternativeValue !== void 0 && alternativeValue !== valueToValidate) {
|
|
157
|
+
valueToValidate = alternativeValue;
|
|
158
|
+
}
|
|
159
|
+
if (schemaType === "ZodDiscriminatedUnion" || schemaType === "ZodUnion") {
|
|
160
|
+
const result = tryUnionWrapping(schema, valueToValidate);
|
|
161
|
+
if (result.success) {
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { valueToValidate, parsed: { success: false } };
|
|
166
|
+
}
|
|
167
|
+
function parseExit(returnValue, exits) {
|
|
168
|
+
if (!returnValue) {
|
|
169
|
+
return {
|
|
170
|
+
success: false,
|
|
171
|
+
error: "No return value provided",
|
|
172
|
+
returnValue
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const returnAction = returnValue.action;
|
|
176
|
+
if (!returnAction) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
error: `Code did not return an action. Valid actions are: ${exits.map((x) => x.name).join(", ")}`,
|
|
180
|
+
returnValue
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const returnExit = exits.find((x) => x.name.toLowerCase() === returnAction.toLowerCase()) ?? exits.find((x) => x.aliases.some((a) => a.toLowerCase() === returnAction.toLowerCase()));
|
|
184
|
+
if (!returnExit) {
|
|
185
|
+
return {
|
|
186
|
+
success: false,
|
|
187
|
+
error: `Exit "${returnAction}" not found. Valid actions are: ${exits.map((x) => x.name).join(", ")}`,
|
|
188
|
+
returnValue
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (!returnExit.zSchema) {
|
|
192
|
+
const otherProps = omit_default(returnValue, "action");
|
|
193
|
+
const value = Object.keys(otherProps).length === 1 ? Object.values(otherProps)[0] : otherProps;
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
exit: returnExit,
|
|
197
|
+
value
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
let valueToValidate = returnValue.value;
|
|
201
|
+
let alternativeValue = void 0;
|
|
202
|
+
if (valueToValidate === void 0) {
|
|
203
|
+
const otherProps = omit_default(returnValue, "action");
|
|
204
|
+
if (Object.keys(otherProps).length > 0) {
|
|
205
|
+
valueToValidate = otherProps;
|
|
206
|
+
if (Object.keys(otherProps).length === 1) {
|
|
207
|
+
alternativeValue = Object.values(otherProps)[0];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const schema = returnExit.zSchema;
|
|
212
|
+
const schemaType = schema._def.typeName;
|
|
213
|
+
let parsed = schema.safeParse(valueToValidate);
|
|
214
|
+
if (!parsed.success && alternativeValue !== void 0 && alternativeValue !== valueToValidate) {
|
|
215
|
+
const altParsed = schema.safeParse(alternativeValue);
|
|
216
|
+
if (altParsed.success) {
|
|
217
|
+
parsed = altParsed;
|
|
218
|
+
valueToValidate = alternativeValue;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!parsed.success) {
|
|
222
|
+
const result = trySmartWrapping(schema, schemaType, valueToValidate, alternativeValue);
|
|
223
|
+
valueToValidate = result.valueToValidate;
|
|
224
|
+
parsed = result.parsed;
|
|
225
|
+
}
|
|
226
|
+
if (!parsed.success) {
|
|
227
|
+
const getValueTypeDescription = (val) => {
|
|
228
|
+
if (val === null)
|
|
229
|
+
return "null";
|
|
230
|
+
if (val === void 0)
|
|
231
|
+
return "undefined";
|
|
232
|
+
if (Array.isArray(val))
|
|
233
|
+
return "array";
|
|
234
|
+
return typeof val;
|
|
235
|
+
};
|
|
236
|
+
const generatedType = getValueTypeDescription(valueToValidate);
|
|
237
|
+
let generatedStatement = `return { action: '${returnAction}'`;
|
|
238
|
+
if (returnValue.value !== void 0) {
|
|
239
|
+
generatedStatement += `, value: ${generatedType}`;
|
|
240
|
+
} else {
|
|
241
|
+
const otherProps = omit_default(returnValue, "action");
|
|
242
|
+
const propKeys = Object.keys(otherProps);
|
|
243
|
+
if (propKeys.length === 1) {
|
|
244
|
+
generatedStatement += `, ${propKeys[0]}: ${generatedType}`;
|
|
245
|
+
} else if (propKeys.length > 1) {
|
|
246
|
+
generatedStatement += `, ${propKeys.join(", ")}`;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
generatedStatement += " }";
|
|
250
|
+
const expectedStatements = [];
|
|
251
|
+
for (const exit of exits) {
|
|
252
|
+
let statement = `return { action: '${exit.name}'`;
|
|
253
|
+
if (exit.zSchema) {
|
|
254
|
+
const schema2 = exit.zSchema;
|
|
255
|
+
const typeName = schema2._def.typeName;
|
|
256
|
+
if (typeName === "ZodObject") {
|
|
257
|
+
const shape = schema2.shape;
|
|
258
|
+
const properties = Object.keys(shape).map((key) => {
|
|
259
|
+
var _a;
|
|
260
|
+
const field = shape[key];
|
|
261
|
+
const fieldType = field._def.typeName || "unknown";
|
|
262
|
+
const isOptional = ((_a = field.isOptional) == null ? void 0 : _a.call(field)) || false;
|
|
263
|
+
return `${key}${isOptional ? "?" : ""}: ${fieldType.replace("Zod", "").toLowerCase()}`;
|
|
264
|
+
});
|
|
265
|
+
statement += `, value: { ${properties.join(", ")} }`;
|
|
266
|
+
} else if (typeName === "ZodUnion" || typeName === "ZodDiscriminatedUnion") {
|
|
267
|
+
const options = schema2._def.options || [];
|
|
268
|
+
const variants = options.map((opt) => {
|
|
269
|
+
if (opt._def.typeName === "ZodObject") {
|
|
270
|
+
const shape = opt.shape;
|
|
271
|
+
const properties = Object.keys(shape).map((key) => {
|
|
272
|
+
const field = shape[key];
|
|
273
|
+
const fieldType = field._def.typeName || "unknown";
|
|
274
|
+
return `${key}: ${fieldType.replace("Zod", "").toLowerCase()}`;
|
|
275
|
+
});
|
|
276
|
+
return `{ ${properties.join(", ")} }`;
|
|
277
|
+
}
|
|
278
|
+
return "unknown";
|
|
279
|
+
});
|
|
280
|
+
statement += `, value: ${variants.join(" | ")}`;
|
|
281
|
+
} else {
|
|
282
|
+
const schemaTypeName = (typeName == null ? void 0 : typeName.replace("Zod", "").toLowerCase()) || "unknown";
|
|
283
|
+
statement += `, value: ${schemaTypeName}`;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
statement += " }";
|
|
287
|
+
expectedStatements.push(statement);
|
|
288
|
+
}
|
|
289
|
+
const errorMessage = [
|
|
290
|
+
`Invalid return value for exit "${returnExit.name}"`,
|
|
291
|
+
"",
|
|
292
|
+
"You generated:",
|
|
293
|
+
` ${generatedStatement}`,
|
|
294
|
+
"",
|
|
295
|
+
"But expected one of:",
|
|
296
|
+
...expectedStatements.map((s) => ` ${s}`)
|
|
297
|
+
].join("\n");
|
|
298
|
+
return {
|
|
299
|
+
success: false,
|
|
300
|
+
error: errorMessage,
|
|
301
|
+
returnValue
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
success: true,
|
|
306
|
+
exit: returnExit,
|
|
307
|
+
value: parsed.data
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
26
311
|
// src/snapshots.ts
|
|
27
312
|
import { ulid } from "ulid";
|
|
28
313
|
var MAX_SNAPSHOT_SIZE_BYTES = 4e3;
|
|
@@ -1101,6 +1386,7 @@ var Context = class {
|
|
|
1101
1386
|
};
|
|
1102
1387
|
|
|
1103
1388
|
export {
|
|
1389
|
+
parseExit,
|
|
1104
1390
|
Snapshot,
|
|
1105
1391
|
ExecutionResult,
|
|
1106
1392
|
SuccessExecutionResult,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PluginObj } from '@babel/core';
|
|
2
|
+
/**
|
|
3
|
+
* This plugin converts simple HTML tags in JSX text to markdown equivalents.
|
|
4
|
+
* Only handles basic formatting tags without attributes (except href/src).
|
|
5
|
+
*
|
|
6
|
+
* Supported conversions:
|
|
7
|
+
* - <strong>text</strong> -> **text**
|
|
8
|
+
* - <b>text</b> -> **text**
|
|
9
|
+
* - <em>text</em> -> *text*
|
|
10
|
+
* - <i>text</i> -> *text*
|
|
11
|
+
* - <u>text</u> -> __text__
|
|
12
|
+
* - <a href="url">text</a> -> [text](url)
|
|
13
|
+
* - <ul><li>item</li></ul> -> - item
|
|
14
|
+
* - <ol><li>item</li></ol> -> 1. item
|
|
15
|
+
* - <br>, <br/>, <br /> -> \n
|
|
16
|
+
* - <p>text</p> -> text\n\n
|
|
17
|
+
*
|
|
18
|
+
* Only converts tags that have no attributes (except href for links).
|
|
19
|
+
* Preserves complex HTML that can't be represented in simple markdown.
|
|
20
|
+
*/
|
|
21
|
+
export declare function htmlToMarkdownPlugin(): PluginObj;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PluginObj } from '@babel/core';
|
|
2
|
+
/**
|
|
3
|
+
* This plugin transforms JSX expressions that reference undefined variables
|
|
4
|
+
* into safe fallbacks that display the variable name as a string.
|
|
5
|
+
*
|
|
6
|
+
* For example:
|
|
7
|
+
* <div>{content}</div>
|
|
8
|
+
* becomes:
|
|
9
|
+
* <div>{(() => { try { return content } catch { return 'content' } })()}</div>
|
|
10
|
+
*
|
|
11
|
+
* This prevents "variable is not defined" errors when the LLM generates JSX
|
|
12
|
+
* with variable references that don't exist in the actual execution scope.
|
|
13
|
+
*/
|
|
14
|
+
export declare function jsxUndefinedVarsPlugin(): PluginObj;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunk5BEKU5MZcjs = require('./chunk-5BEKU5MZ.cjs');
|
|
4
4
|
require('./chunk-KIN7Y247.cjs');
|
|
5
5
|
require('./chunk-ZRCU35UV.cjs');
|
|
6
6
|
require('./chunk-KMZDFWYZ.cjs');
|
|
@@ -9,4 +9,4 @@ require('./chunk-WHNOR4ZU.cjs');
|
|
|
9
9
|
require('./chunk-UQOBUJIQ.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.DualModePrompt =
|
|
12
|
+
exports.DualModePrompt = _chunk5BEKU5MZcjs.DualModePrompt;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Exit } from './exit.js';
|
|
2
|
+
/**
|
|
3
|
+
* Result of parsing an exit from return value
|
|
4
|
+
*/
|
|
5
|
+
export type ParsedExit = {
|
|
6
|
+
success: true;
|
|
7
|
+
exit: Exit;
|
|
8
|
+
value: unknown;
|
|
9
|
+
} | {
|
|
10
|
+
success: false;
|
|
11
|
+
error: string;
|
|
12
|
+
returnValue: unknown;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Parses and validates a return value against a list of exits.
|
|
16
|
+
* Attempts to intelligently fit the data to the expected schema.
|
|
17
|
+
*
|
|
18
|
+
* @param returnValue - The raw return value from code execution
|
|
19
|
+
* @param exits - Available exits to match against
|
|
20
|
+
* @returns Parsed exit result with validated data or error
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const exits = [
|
|
25
|
+
* new Exit({ name: 'done', schema: z.object({ result: z.string() }) })
|
|
26
|
+
* ]
|
|
27
|
+
*
|
|
28
|
+
* // Returns primitive value - will be smart-wrapped
|
|
29
|
+
* const result = parseExit({ action: 'done', data: 'hello' }, exits)
|
|
30
|
+
* // result.success === true
|
|
31
|
+
* // result.value === { result: 'hello' }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseExit(returnValue: {
|
|
35
|
+
action: string;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
} | null, exits: Exit[]): ParsedExit;
|
package/dist/index.cjs
CHANGED
|
@@ -8,11 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var _chunkVADA6DMRcjs = require('./chunk-VADA6DMR.cjs');
|
|
12
|
-
require('./chunk-WP4F6KMW.cjs');
|
|
13
11
|
|
|
12
|
+
var _chunk66NCLCNTcjs = require('./chunk-66NCLCNT.cjs');
|
|
13
|
+
require('./chunk-5BEKU5MZ.cjs');
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
var _chunkJ57224PDcjs = require('./chunk-J57224PD.cjs');
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -427,7 +428,7 @@ var ObjectInstance = class {
|
|
|
427
428
|
this.description = props.description;
|
|
428
429
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
429
430
|
this.properties = props.properties;
|
|
430
|
-
this.tools =
|
|
431
|
+
this.tools = _chunkJ57224PDcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
431
432
|
}
|
|
432
433
|
/**
|
|
433
434
|
* Generates TypeScript namespace declarations for this object.
|
|
@@ -1103,20 +1104,20 @@ var utils = {
|
|
|
1103
1104
|
truncateWrappedContent: _chunkGZPN7RGHcjs.truncateWrappedContent
|
|
1104
1105
|
};
|
|
1105
1106
|
var execute = async (props) => {
|
|
1106
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1107
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-NB4CQ5PW.cjs")));
|
|
1107
1108
|
return executeContext(props);
|
|
1108
1109
|
};
|
|
1109
1110
|
var init = async () => {
|
|
1110
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1111
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-NB4CQ5PW.cjs")));
|
|
1111
1112
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
1112
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
1113
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-YCYYKKB3.cjs")));
|
|
1113
1114
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
|
|
1114
1115
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
1115
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-
|
|
1116
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-2LG42J6U.cjs")));
|
|
1116
1117
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-L5QAQXV2.cjs")));
|
|
1117
1118
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-W3NXBLYJ.cjs")));
|
|
1118
1119
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-2RAAZ2YP.cjs")));
|
|
1119
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
1120
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-UBHAMQW4.cjs")));
|
|
1120
1121
|
};
|
|
1121
1122
|
|
|
1122
1123
|
|
|
@@ -1145,4 +1146,5 @@ var init = async () => {
|
|
|
1145
1146
|
|
|
1146
1147
|
|
|
1147
1148
|
|
|
1148
|
-
|
|
1149
|
+
|
|
1150
|
+
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunk66NCLCNTcjs.DefaultExit; exports.ErrorExecutionResult = _chunk66NCLCNTcjs.ErrorExecutionResult; exports.ExecutionResult = _chunk66NCLCNTcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunk66NCLCNTcjs.ListenExit; exports.LoopExceededError = _chunkT63Y6GTWcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunk66NCLCNTcjs.PartialExecutionResult; exports.Snapshot = _chunk66NCLCNTcjs.Snapshot; exports.SnapshotSignal = _chunkT63Y6GTWcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunk66NCLCNTcjs.SuccessExecutionResult; exports.ThinkExit = _chunk66NCLCNTcjs.ThinkExit; exports.ThinkSignal = _chunkT63Y6GTWcjs.ThinkSignal; exports.Tool = _chunkJ57224PDcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunk66NCLCNTcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.parseExit = _chunk66NCLCNTcjs.parseExit; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Tool } from './tool.js';
|
|
|
2
2
|
export { Exit, ExitResult } from './exit.js';
|
|
3
3
|
export { ObjectInstance } from './objects.js';
|
|
4
4
|
export { SnapshotSignal, ThinkSignal, LoopExceededError } from './errors.js';
|
|
5
|
+
export { parseExit, type ParsedExit } from './exit-parser.js';
|
|
5
6
|
export { Component, RenderedComponent, LeafComponentDefinition, ContainerComponentDefinition, DefaultComponentDefinition, ComponentDefinition, assertValidComponent, isComponent, isAnyComponent, renderToTsx, } from './component.js';
|
|
6
7
|
export { Citation, CitationsManager } from './citations.js';
|
|
7
8
|
export { DefaultComponents } from './component.default.js';
|
package/dist/index.js
CHANGED
|
@@ -7,12 +7,13 @@ import {
|
|
|
7
7
|
Snapshot,
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
|
-
getValue
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
getValue,
|
|
11
|
+
parseExit
|
|
12
|
+
} from "./chunk-WYFTNO2Y.js";
|
|
13
|
+
import "./chunk-AAHUDKBY.js";
|
|
13
14
|
import {
|
|
14
15
|
Tool
|
|
15
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-RC6YO5UW.js";
|
|
16
17
|
import {
|
|
17
18
|
formatTypings,
|
|
18
19
|
getTypings
|
|
@@ -1103,20 +1104,20 @@ var utils = {
|
|
|
1103
1104
|
truncateWrappedContent
|
|
1104
1105
|
};
|
|
1105
1106
|
var execute = async (props) => {
|
|
1106
|
-
const { executeContext } = await import("./llmz-
|
|
1107
|
+
const { executeContext } = await import("./llmz-VOXE65UW.js");
|
|
1107
1108
|
return executeContext(props);
|
|
1108
1109
|
};
|
|
1109
1110
|
var init = async () => {
|
|
1110
|
-
await import("./llmz-
|
|
1111
|
+
await import("./llmz-VOXE65UW.js");
|
|
1111
1112
|
await import("./component-WFVDVSDK.js");
|
|
1112
|
-
await import("./tool-
|
|
1113
|
+
await import("./tool-U6SV6BZ6.js");
|
|
1113
1114
|
await import("./exit-YLO7BY7Z.js");
|
|
1114
1115
|
await import("./jsx-AEHVFB3L.js");
|
|
1115
|
-
await import("./vm-
|
|
1116
|
+
await import("./vm-FVQBX2XV.js");
|
|
1116
1117
|
await import("./utils-RQHQ2KOG.js");
|
|
1117
1118
|
await import("./truncator-BSP6PQPC.js");
|
|
1118
1119
|
await import("./typings-3VYUEACY.js");
|
|
1119
|
-
await import("./dual-modes-
|
|
1120
|
+
await import("./dual-modes-LEAHGCOF.js");
|
|
1120
1121
|
};
|
|
1121
1122
|
export {
|
|
1122
1123
|
Chat,
|
|
@@ -1143,6 +1144,7 @@ export {
|
|
|
1143
1144
|
init,
|
|
1144
1145
|
isAnyComponent,
|
|
1145
1146
|
isComponent,
|
|
1147
|
+
parseExit,
|
|
1146
1148
|
renderToTsx,
|
|
1147
1149
|
utils
|
|
1148
1150
|
};
|