llmz 0.0.83 → 0.0.84
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-I2CZYEMH.js → chunk-2O3UTPVH.js} +2 -2
- package/dist/{chunk-73XYX76S.cjs → chunk-7LMIOS6H.cjs} +14 -14
- package/dist/{chunk-NQBIU5VM.cjs → chunk-BBX2LDZE.cjs} +25 -25
- package/dist/{chunk-RLUTWFAA.cjs → chunk-D6PU5YAS.cjs} +6 -6
- package/dist/{chunk-NWTG73QR.cjs → chunk-FPLSJF4S.cjs} +1 -43
- package/dist/{chunk-5Z2SJOGS.js → chunk-IRCB4FRM.js} +65 -19
- package/dist/{chunk-MM2FLD3J.js → chunk-L74UZONX.js} +1 -1
- package/dist/{chunk-VDTORFBP.js → chunk-NK2NCYSY.js} +4 -4
- package/dist/{chunk-YCLKXXSF.cjs → chunk-PQGZQQA6.cjs} +18 -18
- package/dist/{chunk-NPVV3PHY.js → chunk-TOGYDN6U.js} +1 -1
- package/dist/{chunk-52QTFQOB.cjs → chunk-WODK7Y4J.cjs} +60 -14
- package/dist/{chunk-VLJA22PB.js → chunk-XVVYNOTX.js} +1 -1
- package/dist/{chunk-5MAFEI2A.js → chunk-YX27XM67.js} +0 -42
- package/dist/{chunk-6KR6VRA6.cjs → chunk-ZPHRTTQX.cjs} +2 -2
- package/dist/convert.d.ts +11 -0
- package/dist/{dual-modes-VDFZH4YM.js → dual-modes-HEXPFVUE.js} +3 -3
- package/dist/{dual-modes-E5HGE35E.cjs → dual-modes-LLIWZCHC.cjs} +4 -4
- package/dist/{execute-R6R3A42S.cjs → execute-2BVFYTJT.cjs} +30 -30
- package/dist/{execute-CJVHUFYI.js → execute-EZXXBWB6.js} +7 -7
- package/dist/exit-LUJY7JIG.cjs +8 -0
- package/dist/{exit-GKF4EEMZ.js → exit-VJATJTQI.js} +2 -2
- package/dist/index.cjs +33 -33
- package/dist/index.js +16 -16
- package/dist/{tool-JZP3UN2F.js → tool-DNHVW3KC.js} +3 -3
- package/dist/{tool-4VK7TZV2.cjs → tool-GJ6ZXWS2.cjs} +4 -4
- package/dist/{truncator-IIRX3MB2.js → truncator-3U2QUUJJ.js} +2 -2
- package/dist/truncator-3ZN7W6NB.cjs +10 -0
- package/dist/{typings-SKZSSL2M.js → typings-3YV3RDMP.js} +2 -2
- package/dist/{typings-SHVPZ5AR.cjs → typings-ZTFPPA5W.cjs} +3 -3
- package/dist/utils-GLZVMRWO.cjs +39 -0
- package/dist/{utils-SYJGSVFW.js → utils-ZEZ66X6Q.js} +1 -3
- package/dist/utils.d.ts +0 -4
- package/package.json +1 -1
- package/dist/exit-VZASQELZ.cjs +0 -8
- package/dist/truncator-NWENJXMR.cjs +0 -10
- package/dist/utils-6MFSS4AT.cjs +0 -41
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-3T5IU7OU.js";
|
|
7
7
|
import {
|
|
8
8
|
wrapContent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-L74UZONX.js";
|
|
10
10
|
import {
|
|
11
11
|
escapeString,
|
|
12
12
|
getTokenizer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-YX27XM67.js";
|
|
14
14
|
import {
|
|
15
15
|
countBy_default,
|
|
16
16
|
filter_default,
|
|
@@ -5,7 +5,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
9
9
|
|
|
10
10
|
// src/typings.ts
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
@@ -111,7 +111,7 @@ async function sUnwrapZod(schema, options) {
|
|
|
111
111
|
parent: schema
|
|
112
112
|
};
|
|
113
113
|
if (schema instanceof Declaration) {
|
|
114
|
-
const description =
|
|
114
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
115
115
|
const withoutDesc = schema.schema.describe("");
|
|
116
116
|
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
117
117
|
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
@@ -132,7 +132,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
132
132
|
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
133
133
|
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
134
134
|
}
|
|
135
|
-
const description =
|
|
135
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
136
136
|
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
137
137
|
const withoutDesc = schema.value.describe("");
|
|
138
138
|
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
@@ -143,7 +143,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
143
143
|
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
144
|
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
145
145
|
const item = schema.schema.items[i];
|
|
146
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(
|
|
146
|
+
args += `${await sUnwrapZodRecursive(new KeyValue(_chunkFPLSJF4Scjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
147
|
}
|
|
148
148
|
return args;
|
|
149
149
|
}
|
|
@@ -182,7 +182,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
182
182
|
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
183
183
|
}
|
|
184
184
|
if (_zui.z.is.zuiFunction(schema)) {
|
|
185
|
-
const description =
|
|
185
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
186
186
|
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
187
187
|
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
188
188
|
if (options == null ? void 0 : options.declaration) {
|
|
@@ -200,7 +200,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
200
200
|
return `Array<${item}>`;
|
|
201
201
|
}
|
|
202
202
|
if (_zui.z.is.zuiEnum(schema)) {
|
|
203
|
-
const values = schema._def.values.map(
|
|
203
|
+
const values = schema._def.values.map(_chunkFPLSJF4Scjs.escapeString);
|
|
204
204
|
return values.join(" | ");
|
|
205
205
|
}
|
|
206
206
|
if (_zui.z.is.zuiTuple(schema)) {
|
|
@@ -225,7 +225,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
225
225
|
const props = await Promise.all(
|
|
226
226
|
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
227
227
|
if (_zui.z.is.zuiType(value)) {
|
|
228
|
-
return sUnwrapZodRecursive(new KeyValue(
|
|
228
|
+
return sUnwrapZodRecursive(new KeyValue(_chunkFPLSJF4Scjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
229
229
|
}
|
|
230
230
|
return `${key}: unknown`;
|
|
231
231
|
})
|
|
@@ -233,11 +233,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
233
233
|
return `{ ${props.join("; ")} }`;
|
|
234
234
|
}
|
|
235
235
|
if (_zui.z.is.zuiString(schema)) {
|
|
236
|
-
const description =
|
|
236
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
237
|
return `${description} string`.trim();
|
|
238
238
|
}
|
|
239
239
|
if (_zui.z.is.zuiUnion(schema)) {
|
|
240
|
-
const description =
|
|
240
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
241
241
|
const options2 = await Promise.all(
|
|
242
242
|
schema.options.map(async (option) => {
|
|
243
243
|
return sUnwrapZodRecursive(option, newOptions);
|
|
@@ -247,16 +247,16 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
247
247
|
${options2.join(" | ")}`;
|
|
248
248
|
}
|
|
249
249
|
if (_zui.z.is.zuiLiteral(schema)) {
|
|
250
|
-
const description =
|
|
250
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
251
251
|
return `${description}
|
|
252
|
-
${typeof schema.value === "string" ?
|
|
252
|
+
${typeof schema.value === "string" ? _chunkFPLSJF4Scjs.escapeString.call(void 0, schema.value) : String(schema.value)}`.trim();
|
|
253
253
|
}
|
|
254
254
|
if (_zui.z.is.zuiNumber(schema)) {
|
|
255
|
-
const description =
|
|
255
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
256
|
return `${description} number`.trim();
|
|
257
257
|
}
|
|
258
258
|
if (_zui.z.is.zuiBoolean(schema)) {
|
|
259
|
-
const description =
|
|
259
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
260
260
|
return `${description} boolean`.trim();
|
|
261
261
|
}
|
|
262
262
|
if (_zui.z.is.zuiCatch(schema)) {
|
|
@@ -266,7 +266,7 @@ ${typeof schema.value === "string" ? _chunkNWTG73QRcjs.escapeString.call(void 0,
|
|
|
266
266
|
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
267
267
|
}
|
|
268
268
|
if (_zui.z.is.zuiRecord(schema)) {
|
|
269
|
-
const description =
|
|
269
|
+
const description = _chunkFPLSJF4Scjs.getMultilineComment.call(void 0, schema._def.description);
|
|
270
270
|
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
271
271
|
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
272
272
|
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
@@ -6,11 +6,11 @@ var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
|
|
|
6
6
|
var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkZPHRTTQXcjs = require('./chunk-ZPHRTTQX.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -57,7 +57,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
57
57
|
}
|
|
58
58
|
if (typeof currentObj !== "object" || currentObj === null) {
|
|
59
59
|
const value = JSON.stringify(currentObj);
|
|
60
|
-
currentLength +=
|
|
60
|
+
currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(value);
|
|
61
61
|
return value;
|
|
62
62
|
}
|
|
63
63
|
const indentation = " ".repeat(currentIndent);
|
|
@@ -70,7 +70,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
70
70
|
result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
|
|
71
71
|
}
|
|
72
72
|
result += "\n" + indentation + "]";
|
|
73
|
-
currentLength +=
|
|
73
|
+
currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(result);
|
|
74
74
|
return result;
|
|
75
75
|
} else {
|
|
76
76
|
let result = "{\n";
|
|
@@ -89,11 +89,11 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
89
89
|
result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
|
|
90
90
|
}
|
|
91
91
|
result += "\n" + indentation + "}";
|
|
92
|
-
currentLength +=
|
|
92
|
+
currentLength += _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(result);
|
|
93
93
|
return result;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
-
const output =
|
|
96
|
+
const output = _chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
|
|
97
97
|
return { output, truncated: wasTruncated };
|
|
98
98
|
}
|
|
99
99
|
function extractType(value, generic = true) {
|
|
@@ -158,9 +158,9 @@ function previewValue(value, length = LONG_TEXT_LENGTH) {
|
|
|
158
158
|
}
|
|
159
159
|
const previewStr = (str) => {
|
|
160
160
|
if (str.length > length) {
|
|
161
|
-
return
|
|
161
|
+
return _chunkFPLSJF4Scjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
|
|
162
162
|
}
|
|
163
|
-
return
|
|
163
|
+
return _chunkFPLSJF4Scjs.escapeString.call(void 0, str);
|
|
164
164
|
};
|
|
165
165
|
const previewObj = (obj) => {
|
|
166
166
|
const mapped = _chunkHC2QZTVTcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
|
|
@@ -353,7 +353,7 @@ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
|
|
|
353
353
|
} else if (genericType === "boolean") {
|
|
354
354
|
return header + previewValue(value);
|
|
355
355
|
} else if (typeof value === "string") {
|
|
356
|
-
if (
|
|
356
|
+
if (_chunkFPLSJF4Scjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
|
|
357
357
|
return header + previewValue(value);
|
|
358
358
|
} else {
|
|
359
359
|
return header + previewLongText(value);
|
|
@@ -508,15 +508,15 @@ ${variables_example}
|
|
|
508
508
|
role: "system",
|
|
509
509
|
content: replacePlaceholders(canTalk ? system_md_default : system_md_default2, {
|
|
510
510
|
is_message_enabled: canTalk,
|
|
511
|
-
"tools.d.ts":
|
|
511
|
+
"tools.d.ts": _chunkZPHRTTQXcjs.wrapContent.call(void 0, dts, {
|
|
512
512
|
preserve: "both",
|
|
513
513
|
minTokens: 500
|
|
514
514
|
}),
|
|
515
|
-
identity:
|
|
515
|
+
identity: _chunkZPHRTTQXcjs.wrapContent.call(void 0, ((_a = props.instructions) == null ? void 0 : _a.length) ? props.instructions : "No specific instructions provided", {
|
|
516
516
|
preserve: "both",
|
|
517
517
|
minTokens: 1e3
|
|
518
518
|
}),
|
|
519
|
-
transcript:
|
|
519
|
+
transcript: _chunkZPHRTTQXcjs.wrapContent.call(void 0, props.transcript.toString(), {
|
|
520
520
|
preserve: "bottom",
|
|
521
521
|
minTokens: 500
|
|
522
522
|
}),
|
|
@@ -525,7 +525,7 @@ ${variables_example}
|
|
|
525
525
|
writeable_vars: writeable_vars.join(", "),
|
|
526
526
|
variables_example,
|
|
527
527
|
exits,
|
|
528
|
-
components:
|
|
528
|
+
components: _chunkZPHRTTQXcjs.wrapContent.call(void 0,
|
|
529
529
|
props.components.map((component) => _chunkCQ3UJW76cjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
|
|
530
530
|
{
|
|
531
531
|
preserve: "top",
|
|
@@ -603,13 +603,13 @@ Code:
|
|
|
603
603
|
|
|
604
604
|
\`\`\`tsx
|
|
605
605
|
\u25A0fn_start
|
|
606
|
-
${
|
|
606
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, props.code)}
|
|
607
607
|
\u25A0fn_end
|
|
608
608
|
\`\`\`
|
|
609
609
|
|
|
610
610
|
Error:
|
|
611
611
|
\`\`\`
|
|
612
|
-
${
|
|
612
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
|
|
613
613
|
\`\`\`
|
|
614
614
|
|
|
615
615
|
Please fix the error and try again.
|
|
@@ -632,11 +632,11 @@ var getCodeExecutionErrorMessage = async (props) => {
|
|
|
632
632
|
|
|
633
633
|
An error occurred while executing the code.
|
|
634
634
|
|
|
635
|
-
${
|
|
635
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
|
|
636
636
|
|
|
637
637
|
Stack Trace:
|
|
638
638
|
\`\`\`
|
|
639
|
-
${
|
|
639
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
|
|
640
640
|
\`\`\`
|
|
641
641
|
|
|
642
642
|
Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
|
|
@@ -659,7 +659,7 @@ var getThinkingMessage = async (props) => {
|
|
|
659
659
|
if (inspected) {
|
|
660
660
|
acc.push(inspected);
|
|
661
661
|
} else {
|
|
662
|
-
acc.push(`Value of ${key} is ${
|
|
662
|
+
acc.push(`Value of ${key} is ${_chunkZPHRTTQXcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
|
|
663
663
|
}
|
|
664
664
|
return acc;
|
|
665
665
|
}, []);
|
|
@@ -670,7 +670,7 @@ var getThinkingMessage = async (props) => {
|
|
|
670
670
|
if (inspected) {
|
|
671
671
|
return inspected;
|
|
672
672
|
} else {
|
|
673
|
-
return `Value at index ${index} is ${
|
|
673
|
+
return `Value at index ${index} is ${_chunkZPHRTTQXcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
|
|
674
674
|
}
|
|
675
675
|
});
|
|
676
676
|
context = mapped.join("\n\n");
|
|
@@ -688,7 +688,7 @@ The assistant requested to think. Here's the context:
|
|
|
688
688
|
-------------------
|
|
689
689
|
Reason: ${props.reason || "Thinking requested"}
|
|
690
690
|
Context:
|
|
691
|
-
${
|
|
691
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, context, { preserve: "top" })}
|
|
692
692
|
-------------------
|
|
693
693
|
|
|
694
694
|
Please continue with the conversation (\u25A0fn_start).
|
|
@@ -707,19 +707,19 @@ var getSnapshotResolvedMessage = (props) => {
|
|
|
707
707
|
injectedVariables[variable.name] = variable.value;
|
|
708
708
|
variablesMessage += `
|
|
709
709
|
// Variable "${variable.name}" restored with its full value:
|
|
710
|
-
// ${
|
|
710
|
+
// ${_chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
|
|
711
711
|
declare const ${variable.name}: ${variable.type}
|
|
712
712
|
`;
|
|
713
713
|
} else {
|
|
714
714
|
variablesMessage += `
|
|
715
715
|
// The variable "${variable.name}" was too large to be restored with its full value, here's a preview of its last known value:
|
|
716
|
-
// ${
|
|
716
|
+
// ${_chunkZPHRTTQXcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
|
|
717
717
|
// Important: To restore the full value, please re-run the code that generated this variable in the first place.
|
|
718
718
|
let ${variable.name}: undefined | ${variable.type} = undefined;
|
|
719
719
|
`;
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
-
const output =
|
|
722
|
+
const output = _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
|
|
723
723
|
preserve: "top",
|
|
724
724
|
flex: 4
|
|
725
725
|
});
|
|
@@ -741,7 +741,7 @@ ${_chunkKIN7Y247cjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n
|
|
|
741
741
|
Continue the conversation from here, without repeating the above code, as it has already been executed. Here's the variables you can rely on:
|
|
742
742
|
|
|
743
743
|
\`\`\`tsx
|
|
744
|
-
${
|
|
744
|
+
${_chunkZPHRTTQXcjs.wrapContent.call(void 0, variablesMessage)}
|
|
745
745
|
\`\`\`
|
|
746
746
|
|
|
747
747
|
You can now assume that the code you about to generate can rely on the variables "${Object.keys(injectedVariables).join('", "')}" being available.
|
|
@@ -764,7 +764,7 @@ var getSnapshotRejectedMessage = (props) => {
|
|
|
764
764
|
throw new Error("Snapshot is not resolved");
|
|
765
765
|
}
|
|
766
766
|
const errorMessage = _nullishCoalesce(inspect(props.snapshot.status.error), () => ( "Unknown Error"));
|
|
767
|
-
const output =
|
|
767
|
+
const output = _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
|
|
768
768
|
preserve: "both",
|
|
769
769
|
minTokens: 100
|
|
770
770
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkFPLSJF4Scjs = require('./chunk-FPLSJF4S.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
@@ -42,7 +42,7 @@ var Exit = (_class = class _Exit {
|
|
|
42
42
|
*/
|
|
43
43
|
rename(name) {
|
|
44
44
|
const before = this.name;
|
|
45
|
-
if (!
|
|
45
|
+
if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, name)) {
|
|
46
46
|
throw new Error(
|
|
47
47
|
`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.`
|
|
48
48
|
);
|
|
@@ -177,7 +177,7 @@ var Exit = (_class = class _Exit {
|
|
|
177
177
|
* ```
|
|
178
178
|
*/
|
|
179
179
|
constructor(props) {;_class.prototype.__init.call(this);
|
|
180
|
-
if (!
|
|
180
|
+
if (!_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, props.name)) {
|
|
181
181
|
throw new Error(
|
|
182
182
|
`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.`
|
|
183
183
|
);
|
|
@@ -197,13 +197,13 @@ var Exit = (_class = class _Exit {
|
|
|
197
197
|
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
200
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkFPLSJF4Scjs.isValidIdentifier.call(void 0, alias))) {
|
|
201
201
|
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
202
202
|
}
|
|
203
203
|
if (typeof props.schema !== "undefined") {
|
|
204
|
-
if (
|
|
204
|
+
if (_chunkFPLSJF4Scjs.isZuiSchema.call(void 0, props.schema)) {
|
|
205
205
|
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
206
|
-
} else if (
|
|
206
|
+
} else if (_chunkFPLSJF4Scjs.isJsonSchema.call(void 0, props.schema)) {
|
|
207
207
|
this.schema = props.schema;
|
|
208
208
|
} else {
|
|
209
209
|
throw new Error(
|
|
@@ -138,47 +138,6 @@ var stripInvalidIdentifiers = (object) => {
|
|
|
138
138
|
}
|
|
139
139
|
return _chunkHC2QZTVTcjs.pickBy_default.call(void 0, object, (__, key) => Identifier.safeParse(key).success);
|
|
140
140
|
};
|
|
141
|
-
var convertObjectToZuiLiterals = (obj, nested = false) => {
|
|
142
|
-
if (typeof obj === "string") {
|
|
143
|
-
return _zui.z.literal(obj).catch(() => obj);
|
|
144
|
-
}
|
|
145
|
-
if (typeof obj === "number") {
|
|
146
|
-
return _zui.z.literal(obj).catch(() => obj);
|
|
147
|
-
}
|
|
148
|
-
if (typeof obj === "boolean") {
|
|
149
|
-
return _zui.z.literal(obj).catch(() => obj);
|
|
150
|
-
}
|
|
151
|
-
if (Array.isArray(obj)) {
|
|
152
|
-
if (obj.length === 0) {
|
|
153
|
-
return _zui.z.tuple([]).catch(() => obj);
|
|
154
|
-
}
|
|
155
|
-
return _zui.z.tuple([
|
|
156
|
-
// the tuple needs to have at least one element
|
|
157
|
-
convertObjectToZuiLiterals(obj[0]),
|
|
158
|
-
...obj.slice(1).map((child) => convertObjectToZuiLiterals(child))
|
|
159
|
-
]).catch(() => obj);
|
|
160
|
-
}
|
|
161
|
-
if (obj !== null && typeof obj === "object") {
|
|
162
|
-
const shape = {};
|
|
163
|
-
for (const key in obj) {
|
|
164
|
-
shape[key] = convertObjectToZuiLiterals(obj[key], true);
|
|
165
|
-
}
|
|
166
|
-
if (nested) {
|
|
167
|
-
return _zui.z.object(shape).catch(() => shape);
|
|
168
|
-
}
|
|
169
|
-
if (Object.keys(shape).length === 0) {
|
|
170
|
-
return _zui.z.object({}).catch(() => shape);
|
|
171
|
-
}
|
|
172
|
-
return shape;
|
|
173
|
-
}
|
|
174
|
-
if (obj === void 0) {
|
|
175
|
-
return _zui.z.undefined().catch(() => void 0);
|
|
176
|
-
}
|
|
177
|
-
if (obj === null) {
|
|
178
|
-
return _zui.z.null().catch(() => null);
|
|
179
|
-
}
|
|
180
|
-
throw new Error(`Unsupported object type ${typeof obj}, ${obj})`);
|
|
181
|
-
};
|
|
182
141
|
var isValidSchema = (schema) => {
|
|
183
142
|
try {
|
|
184
143
|
_zui.transforms.fromJSONSchemaLegacy(schema);
|
|
@@ -225,5 +184,4 @@ var getErrorMessage = (err) => err instanceof Error ? err.message : JSON.stringi
|
|
|
225
184
|
|
|
226
185
|
|
|
227
186
|
|
|
228
|
-
|
|
229
|
-
exports.init = init; exports.getTokenizer = getTokenizer; exports.Tokens = Tokens; exports.Identifier = Identifier; exports.escapeString = escapeString; exports.toPropertyKey = toPropertyKey; exports.getMultilineComment = getMultilineComment; exports.toValidFunctionName = toValidFunctionName; exports.awaitObject = awaitObject; exports.toValidObjectName = toValidObjectName; exports.stripInvalidIdentifiers = stripInvalidIdentifiers; exports.convertObjectToZuiLiterals = convertObjectToZuiLiterals; exports.isValidSchema = isValidSchema; exports.isZuiSchema = isZuiSchema; exports.isJsonSchema = isJsonSchema; exports.isValidIdentifier = isValidIdentifier; exports.isValidMessageName = isValidMessageName; exports.getErrorMessage = getErrorMessage;
|
|
187
|
+
exports.init = init; exports.getTokenizer = getTokenizer; exports.Tokens = Tokens; exports.Identifier = Identifier; exports.escapeString = escapeString; exports.toPropertyKey = toPropertyKey; exports.getMultilineComment = getMultilineComment; exports.toValidFunctionName = toValidFunctionName; exports.awaitObject = awaitObject; exports.toValidObjectName = toValidObjectName; exports.stripInvalidIdentifiers = stripInvalidIdentifiers; exports.isValidSchema = isValidSchema; exports.isZuiSchema = isZuiSchema; exports.isJsonSchema = isJsonSchema; exports.isValidIdentifier = isValidIdentifier; exports.isValidMessageName = isValidMessageName; exports.getErrorMessage = getErrorMessage;
|
|
@@ -1,19 +1,61 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TOGYDN6U.js";
|
|
4
4
|
import {
|
|
5
|
-
convertObjectToZuiLiterals,
|
|
6
5
|
isJsonSchema,
|
|
7
6
|
isValidIdentifier,
|
|
8
7
|
isZuiSchema
|
|
9
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YX27XM67.js";
|
|
10
9
|
import {
|
|
11
10
|
isEmpty_default,
|
|
12
11
|
uniq_default
|
|
13
12
|
} from "./chunk-34GJUS6U.js";
|
|
14
13
|
|
|
15
14
|
// src/tool.ts
|
|
16
|
-
import { z, transforms } from "@bpinternal/zui";
|
|
15
|
+
import { z as z2, transforms } from "@bpinternal/zui";
|
|
16
|
+
|
|
17
|
+
// src/convert.ts
|
|
18
|
+
import { z } from "@bpinternal/zui";
|
|
19
|
+
function convertObjectToZuiLiterals(obj, nested = false) {
|
|
20
|
+
if (typeof obj === "string") {
|
|
21
|
+
return z.literal(obj).catch(() => obj);
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === "number") {
|
|
24
|
+
return z.literal(obj).catch(() => obj);
|
|
25
|
+
}
|
|
26
|
+
if (typeof obj === "boolean") {
|
|
27
|
+
return z.literal(obj).catch(() => obj);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
if (obj.length === 0) {
|
|
31
|
+
return z.tuple([]).catch(() => obj);
|
|
32
|
+
}
|
|
33
|
+
const items = obj.map((child) => convertObjectToZuiLiterals(child, true));
|
|
34
|
+
return z.tuple(items).catch(() => obj);
|
|
35
|
+
}
|
|
36
|
+
if (obj !== null && typeof obj === "object") {
|
|
37
|
+
const shape = {};
|
|
38
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
39
|
+
shape[key] = convertObjectToZuiLiterals(value, true);
|
|
40
|
+
}
|
|
41
|
+
if (nested) {
|
|
42
|
+
return z.object(shape).catch(() => obj);
|
|
43
|
+
}
|
|
44
|
+
if (Object.keys(shape).length === 0) {
|
|
45
|
+
return z.object({}).catch(() => obj);
|
|
46
|
+
}
|
|
47
|
+
return shape;
|
|
48
|
+
}
|
|
49
|
+
if (obj === void 0) {
|
|
50
|
+
return z.undefined().catch(() => void 0);
|
|
51
|
+
}
|
|
52
|
+
if (obj === null) {
|
|
53
|
+
return z.null().catch(() => null);
|
|
54
|
+
}
|
|
55
|
+
throw new Error(`Unsupported object type ${typeof obj}, ${obj})`);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// src/tool.ts
|
|
17
59
|
var Tool = class _Tool {
|
|
18
60
|
_staticInputValues;
|
|
19
61
|
name;
|
|
@@ -70,13 +112,13 @@ var Tool = class _Tool {
|
|
|
70
112
|
this._staticInputValues = void 0;
|
|
71
113
|
return this;
|
|
72
114
|
}
|
|
73
|
-
const input = this.input ? transforms.fromJSONSchemaLegacy(this.input) :
|
|
74
|
-
if (
|
|
115
|
+
const input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : z2.any();
|
|
116
|
+
if (z2.is.zuiObject(input) && typeof values !== "object") {
|
|
75
117
|
throw new Error(
|
|
76
118
|
`Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
|
|
77
119
|
);
|
|
78
120
|
}
|
|
79
|
-
if (
|
|
121
|
+
if (z2.is.zuiArray(input) && !Array.isArray(values)) {
|
|
80
122
|
throw new Error(
|
|
81
123
|
`Invalid static input values for tool ${this.name}. Expected an array, but got type "${typeof values}"`
|
|
82
124
|
);
|
|
@@ -102,15 +144,19 @@ var Tool = class _Tool {
|
|
|
102
144
|
input = transforms.fromJSONSchemaLegacy(this.input);
|
|
103
145
|
}
|
|
104
146
|
} else {
|
|
105
|
-
input =
|
|
147
|
+
input = z2.any();
|
|
106
148
|
}
|
|
107
149
|
if (!isEmpty_default(this._staticInputValues)) {
|
|
108
|
-
|
|
109
|
-
|
|
150
|
+
if (z2.is.zuiObject(input)) {
|
|
151
|
+
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
110
152
|
input = input.extend(inputExtensions);
|
|
111
|
-
} else if (
|
|
112
|
-
|
|
153
|
+
} else if (z2.is.zuiArray(input)) {
|
|
154
|
+
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
155
|
+
input = z2.array(input.element.extend(inputExtensions));
|
|
113
156
|
} else {
|
|
157
|
+
const inputExtensions = convertObjectToZuiLiterals(
|
|
158
|
+
this._staticInputValues
|
|
159
|
+
);
|
|
114
160
|
input = inputExtensions;
|
|
115
161
|
}
|
|
116
162
|
}
|
|
@@ -123,7 +169,7 @@ var Tool = class _Tool {
|
|
|
123
169
|
* @internal
|
|
124
170
|
*/
|
|
125
171
|
get zOutput() {
|
|
126
|
-
let output =
|
|
172
|
+
let output = z2.void();
|
|
127
173
|
if (this.output) {
|
|
128
174
|
try {
|
|
129
175
|
output = transforms.fromJSONSchema(this.output);
|
|
@@ -131,7 +177,7 @@ var Tool = class _Tool {
|
|
|
131
177
|
output = transforms.fromJSONSchemaLegacy(this.output);
|
|
132
178
|
}
|
|
133
179
|
}
|
|
134
|
-
return
|
|
180
|
+
return z2.promise(output);
|
|
135
181
|
}
|
|
136
182
|
/**
|
|
137
183
|
* Renames the tool and updates its aliases.
|
|
@@ -238,8 +284,8 @@ var Tool = class _Tool {
|
|
|
238
284
|
aliases: props.aliases ?? [...this.aliases],
|
|
239
285
|
description: props.description ?? this.description,
|
|
240
286
|
metadata: JSON.parse(JSON.stringify(props.metadata ?? this.metadata)),
|
|
241
|
-
input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) :
|
|
242
|
-
output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) :
|
|
287
|
+
input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : z2.is.zuiType(props.input) ? props.input : zInput,
|
|
288
|
+
output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : z2.is.zuiType(props.output) ? props.output : zOutput,
|
|
243
289
|
handler: props.handler ?? this._handler,
|
|
244
290
|
retry: props.retry ?? this.retry
|
|
245
291
|
}).setStaticInputValues(props.staticInputValues ?? this._staticInputValues);
|
|
@@ -487,7 +533,7 @@ var Tool = class _Tool {
|
|
|
487
533
|
}
|
|
488
534
|
let output;
|
|
489
535
|
if (!this.output || Object.keys(this.output).length === 0) {
|
|
490
|
-
output =
|
|
536
|
+
output = z2.void();
|
|
491
537
|
} else {
|
|
492
538
|
try {
|
|
493
539
|
output = transforms.fromJSONSchema(this.output);
|
|
@@ -495,13 +541,13 @@ var Tool = class _Tool {
|
|
|
495
541
|
output = transforms.fromJSONSchemaLegacy(this.output);
|
|
496
542
|
}
|
|
497
543
|
}
|
|
498
|
-
if (input &&
|
|
544
|
+
if (input && z2.is.zuiObject(input.naked()) && typeof this._staticInputValues === "object" && !isEmpty_default(this._staticInputValues)) {
|
|
499
545
|
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
500
546
|
input = input.extend(inputExtensions);
|
|
501
547
|
} else if (this._staticInputValues !== void 0) {
|
|
502
548
|
input = convertObjectToZuiLiterals(this._staticInputValues);
|
|
503
549
|
}
|
|
504
|
-
const fnType =
|
|
550
|
+
const fnType = z2.function(input, z2.promise(output)).title(this.name).describe(this.description ?? "");
|
|
505
551
|
return getTypings(fnType, {
|
|
506
552
|
declaration: true
|
|
507
553
|
});
|
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
DualModePrompt,
|
|
3
3
|
extractType,
|
|
4
4
|
inspect
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2O3UTPVH.js";
|
|
6
6
|
import {
|
|
7
7
|
Tool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-IRCB4FRM.js";
|
|
9
9
|
import {
|
|
10
10
|
LoopExceededError
|
|
11
11
|
} from "./chunk-WSVDMGMR.js";
|
|
12
12
|
import {
|
|
13
13
|
Exit
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-XVVYNOTX.js";
|
|
15
15
|
import {
|
|
16
16
|
assertValidComponent
|
|
17
17
|
} from "./chunk-3T5IU7OU.js";
|
|
18
18
|
import {
|
|
19
19
|
wrapContent
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-L74UZONX.js";
|
|
21
21
|
import {
|
|
22
22
|
cloneDeep_default,
|
|
23
23
|
isPlainObject_default,
|