llmz 0.0.85 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-EADBCAE7.js → chunk-2O3UTPVH.js} +2 -2
- package/dist/{chunk-KY27DGTG.cjs → chunk-7LMIOS6H.cjs} +14 -14
- package/dist/{chunk-ZVSO527D.cjs → chunk-BBX2LDZE.cjs} +25 -25
- package/dist/{chunk-EC2I4U4G.cjs → chunk-D6PU5YAS.cjs} +6 -6
- package/dist/{chunk-NFZXJRXS.cjs → chunk-FPLSJF4S.cjs} +5 -2
- package/dist/{chunk-YTFNFSDT.js → chunk-IRCB4FRM.js} +2 -2
- package/dist/{chunk-GEN6TAXY.js → chunk-L74UZONX.js} +16 -8
- package/dist/{chunk-2XSXXGXJ.js → chunk-NK2NCYSY.js} +4 -4
- package/dist/{chunk-N3XPJTPE.cjs → chunk-PQGZQQA6.cjs} +18 -18
- package/dist/{chunk-PASYUKW4.js → chunk-TOGYDN6U.js} +1 -1
- package/dist/{chunk-H3PZFBJL.cjs → chunk-WODK7Y4J.cjs} +10 -10
- package/dist/{chunk-TRWUQSEK.js → chunk-XVVYNOTX.js} +1 -1
- package/dist/{chunk-ZHHB3FT4.js → chunk-YX27XM67.js} +4 -1
- package/dist/{chunk-GFSUTNRM.cjs → chunk-ZPHRTTQX.cjs} +17 -9
- package/dist/{dual-modes-5NJMZJTA.js → dual-modes-HEXPFVUE.js} +3 -3
- package/dist/{dual-modes-WA5TPGJR.cjs → dual-modes-LLIWZCHC.cjs} +4 -4
- package/dist/{execute-I53OOORH.cjs → execute-2BVFYTJT.cjs} +30 -30
- package/dist/{execute-2T75URIX.js → execute-EZXXBWB6.js} +7 -7
- package/dist/exit-LUJY7JIG.cjs +8 -0
- package/dist/{exit-7NHSUR3V.js → exit-VJATJTQI.js} +2 -2
- package/dist/index.cjs +33 -33
- package/dist/index.js +16 -16
- package/dist/{tool-HXXQMDA3.js → tool-DNHVW3KC.js} +3 -3
- package/dist/{tool-4OPM7QRM.cjs → tool-GJ6ZXWS2.cjs} +4 -4
- package/dist/{truncator-ZQYBTVCJ.js → truncator-3U2QUUJJ.js} +2 -2
- package/dist/truncator-3ZN7W6NB.cjs +10 -0
- package/dist/{typings-YD2WAQ4A.js → typings-3YV3RDMP.js} +2 -2
- package/dist/{typings-QW4427V7.cjs → typings-ZTFPPA5W.cjs} +3 -3
- package/dist/utils-GLZVMRWO.cjs +39 -0
- package/dist/{utils-RKUVYFTJ.js → utils-ZEZ66X6Q.js} +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +2 -2
- package/dist/exit-V3ORIN65.cjs +0 -8
- package/dist/truncator-ZN7X6OMF.cjs +0 -10
- package/dist/utils-NQSM5FBL.cjs +0 -39
|
@@ -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" ? _chunkNFZXJRXScjs.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(
|
|
@@ -7,14 +7,17 @@
|
|
|
7
7
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
|
-
var
|
|
10
|
+
var _thicktoken = require('@bpinternal/thicktoken');
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
12
12
|
var tokenizer = null;
|
|
13
13
|
var init = async () => {
|
|
14
14
|
if (tokenizer) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
while (typeof _thicktoken.getWasmTokenizer !== "function") {
|
|
18
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
19
|
+
}
|
|
20
|
+
tokenizer = await _thicktoken.getWasmTokenizer.call(void 0, );
|
|
18
21
|
};
|
|
19
22
|
var getTokenizer = () => {
|
|
20
23
|
if (!tokenizer) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TOGYDN6U.js";
|
|
4
4
|
import {
|
|
5
5
|
isJsonSchema,
|
|
6
6
|
isValidIdentifier,
|
|
7
7
|
isZuiSchema
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YX27XM67.js";
|
|
9
9
|
import {
|
|
10
10
|
isEmpty_default,
|
|
11
11
|
uniq_default
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTokenizer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YX27XM67.js";
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -24,7 +24,7 @@ function truncateWrappedContent({
|
|
|
24
24
|
tokenLimit,
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
|
-
var _a, _b, _c
|
|
27
|
+
var _a, _b, _c;
|
|
28
28
|
const tokenizer = getTokenizer();
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
@@ -86,12 +86,20 @@ function truncateWrappedContent({
|
|
|
86
86
|
toRemove = biggest.tokens - (((_b = biggest.attributes) == null ? void 0 : _b.minTokens) ?? 0);
|
|
87
87
|
}
|
|
88
88
|
const preserve = ((_c = biggest.attributes) == null ? void 0 : _c.preserve) ?? DEFAULT_TRUNCATE_OPTIONS.preserve;
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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;
|
|
95
103
|
}
|
|
96
104
|
return messages.map((msg, i) => {
|
|
97
105
|
const p = parts[i];
|
|
@@ -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,
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkBBX2LDZEcjs = require('./chunk-BBX2LDZE.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkWODK7Y4Jcjs = require('./chunk-WODK7Y4J.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkD6PU5YAScjs = require('./chunk-D6PU5YAS.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkZPHRTTQXcjs = require('./chunk-ZPHRTTQX.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -493,10 +493,10 @@ var Snapshot = class _Snapshot {
|
|
|
493
493
|
};
|
|
494
494
|
function parseVariables(variableMap) {
|
|
495
495
|
return Object.entries(variableMap).map(([name, value]) => {
|
|
496
|
-
const type =
|
|
496
|
+
const type = _chunkBBX2LDZEcjs.extractType.call(void 0, value);
|
|
497
497
|
const bytes = JSON.stringify(value || "").length;
|
|
498
498
|
const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
|
|
499
|
-
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(
|
|
499
|
+
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkBBX2LDZEcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
|
|
500
500
|
});
|
|
501
501
|
}
|
|
502
502
|
|
|
@@ -507,9 +507,9 @@ function getMessagePreview(message) {
|
|
|
507
507
|
return message.content;
|
|
508
508
|
}
|
|
509
509
|
if (message.role === "event") {
|
|
510
|
-
return
|
|
510
|
+
return _chunkBBX2LDZEcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
511
511
|
}
|
|
512
|
-
return
|
|
512
|
+
return _chunkBBX2LDZEcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
|
|
513
513
|
}
|
|
514
514
|
function getMessageType(message) {
|
|
515
515
|
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
@@ -933,15 +933,15 @@ var HookedArray = class extends Array {
|
|
|
933
933
|
};
|
|
934
934
|
|
|
935
935
|
// src/context.ts
|
|
936
|
-
var ThinkExit = new (0,
|
|
936
|
+
var ThinkExit = new (0, _chunkD6PU5YAScjs.Exit)({
|
|
937
937
|
name: "think",
|
|
938
938
|
description: "Think about the current situation and provide a response"
|
|
939
939
|
});
|
|
940
|
-
var ListenExit = new (0,
|
|
940
|
+
var ListenExit = new (0, _chunkD6PU5YAScjs.Exit)({
|
|
941
941
|
name: "listen",
|
|
942
942
|
description: "Listen to the user and provide a response"
|
|
943
943
|
});
|
|
944
|
-
var DefaultExit = new (0,
|
|
944
|
+
var DefaultExit = new (0, _chunkD6PU5YAScjs.Exit)({
|
|
945
945
|
name: "done",
|
|
946
946
|
description: "When the execution is sucessfully completed or when error recovery is not possible",
|
|
947
947
|
schema: _zui.z.discriminatedUnion("success", [
|
|
@@ -1103,7 +1103,7 @@ var Context = (_class2 = class {
|
|
|
1103
1103
|
|
|
1104
1104
|
|
|
1105
1105
|
|
|
1106
|
-
__init3() {this.version =
|
|
1106
|
+
__init3() {this.version = _chunkBBX2LDZEcjs.DualModePrompt}
|
|
1107
1107
|
__init4() {this.timeout = 6e4}
|
|
1108
1108
|
// Default timeout of 60 seconds
|
|
1109
1109
|
|
|
@@ -1224,7 +1224,7 @@ var Context = (_class2 = class {
|
|
|
1224
1224
|
...lastIterationMessages,
|
|
1225
1225
|
{
|
|
1226
1226
|
role: "assistant",
|
|
1227
|
-
content:
|
|
1227
|
+
content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1228
1228
|
},
|
|
1229
1229
|
await this.version.getThinkingMessage({
|
|
1230
1230
|
reason: lastIteration.status.thinking_requested.reason,
|
|
@@ -1237,7 +1237,7 @@ var Context = (_class2 = class {
|
|
|
1237
1237
|
...lastIterationMessages,
|
|
1238
1238
|
{
|
|
1239
1239
|
role: "assistant",
|
|
1240
|
-
content:
|
|
1240
|
+
content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1241
1241
|
},
|
|
1242
1242
|
await this.version.getInvalidCodeMessage({
|
|
1243
1243
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -1250,7 +1250,7 @@ var Context = (_class2 = class {
|
|
|
1250
1250
|
...lastIterationMessages,
|
|
1251
1251
|
{
|
|
1252
1252
|
role: "assistant",
|
|
1253
|
-
content:
|
|
1253
|
+
content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1254
1254
|
},
|
|
1255
1255
|
await this.version.getInvalidCodeMessage({
|
|
1256
1256
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -1263,7 +1263,7 @@ var Context = (_class2 = class {
|
|
|
1263
1263
|
...lastIterationMessages,
|
|
1264
1264
|
{
|
|
1265
1265
|
role: "assistant",
|
|
1266
|
-
content:
|
|
1266
|
+
content: _chunkZPHRTTQXcjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
1267
1267
|
},
|
|
1268
1268
|
await this.version.getCodeExecutionErrorMessage({
|
|
1269
1269
|
message: lastIteration.status.execution_error.message,
|
|
@@ -1279,7 +1279,7 @@ var Context = (_class2 = class {
|
|
|
1279
1279
|
var _a, _b;
|
|
1280
1280
|
const instructions = await getValue(this.instructions, this);
|
|
1281
1281
|
const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
|
|
1282
|
-
const tools =
|
|
1282
|
+
const tools = _chunkWODK7Y4Jcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
|
|
1283
1283
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
1284
1284
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
1285
1285
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|
|
@@ -1312,7 +1312,7 @@ var Context = (_class2 = class {
|
|
|
1312
1312
|
"boolean",
|
|
1313
1313
|
"array"
|
|
1314
1314
|
];
|
|
1315
|
-
const MessageTool = this.chat && components.length ? new (0,
|
|
1315
|
+
const MessageTool = this.chat && components.length ? new (0, _chunkWODK7Y4Jcjs.Tool)({
|
|
1316
1316
|
name: "Message",
|
|
1317
1317
|
description: "Send a message to the user",
|
|
1318
1318
|
aliases: Array.from(
|