llmz 0.0.83 → 0.0.85
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-VDTORFBP.js → chunk-2XSXXGXJ.js} +4 -4
- package/dist/{chunk-I2CZYEMH.js → chunk-EADBCAE7.js} +2 -2
- package/dist/{chunk-RLUTWFAA.cjs → chunk-EC2I4U4G.cjs} +6 -6
- package/dist/{chunk-MM2FLD3J.js → chunk-GEN6TAXY.js} +8 -16
- package/dist/{chunk-6KR6VRA6.cjs → chunk-GFSUTNRM.cjs} +9 -17
- package/dist/{chunk-52QTFQOB.cjs → chunk-H3PZFBJL.cjs} +60 -14
- package/dist/{chunk-73XYX76S.cjs → chunk-KY27DGTG.cjs} +14 -14
- package/dist/{chunk-YCLKXXSF.cjs → chunk-N3XPJTPE.cjs} +18 -18
- package/dist/{chunk-NWTG73QR.cjs → chunk-NFZXJRXS.cjs} +3 -48
- package/dist/{chunk-NPVV3PHY.js → chunk-PASYUKW4.js} +1 -1
- package/dist/{chunk-VLJA22PB.js → chunk-TRWUQSEK.js} +1 -1
- package/dist/{chunk-5Z2SJOGS.js → chunk-YTFNFSDT.js} +65 -19
- package/dist/{chunk-5MAFEI2A.js → chunk-ZHHB3FT4.js} +1 -46
- package/dist/{chunk-NQBIU5VM.cjs → chunk-ZVSO527D.cjs} +25 -25
- package/dist/convert.d.ts +11 -0
- package/dist/{dual-modes-VDFZH4YM.js → dual-modes-5NJMZJTA.js} +3 -3
- package/dist/{dual-modes-E5HGE35E.cjs → dual-modes-WA5TPGJR.cjs} +4 -4
- package/dist/{execute-CJVHUFYI.js → execute-2T75URIX.js} +7 -7
- package/dist/{execute-R6R3A42S.cjs → execute-I53OOORH.cjs} +30 -30
- package/dist/{exit-GKF4EEMZ.js → exit-7NHSUR3V.js} +2 -2
- package/dist/exit-V3ORIN65.cjs +8 -0
- package/dist/index.cjs +33 -33
- package/dist/index.js +16 -16
- package/dist/{tool-4VK7TZV2.cjs → tool-4OPM7QRM.cjs} +4 -4
- package/dist/{tool-JZP3UN2F.js → tool-HXXQMDA3.js} +3 -3
- package/dist/truncator-ZN7X6OMF.cjs +10 -0
- package/dist/{truncator-IIRX3MB2.js → truncator-ZQYBTVCJ.js} +2 -2
- package/dist/{typings-SHVPZ5AR.cjs → typings-QW4427V7.cjs} +3 -3
- package/dist/{typings-SKZSSL2M.js → typings-YD2WAQ4A.js} +2 -2
- package/dist/utils-NQSM5FBL.cjs +39 -0
- package/dist/{utils-SYJGSVFW.js → utils-RKUVYFTJ.js} +1 -3
- package/dist/utils.d.ts +1 -5
- package/package.json +2 -2
- package/dist/exit-VZASQELZ.cjs +0 -8
- package/dist/truncator-NWENJXMR.cjs +0 -10
- package/dist/utils-6MFSS4AT.cjs +0 -41
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
DualModePrompt,
|
|
3
3
|
extractType,
|
|
4
4
|
inspect
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EADBCAE7.js";
|
|
6
6
|
import {
|
|
7
7
|
Tool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YTFNFSDT.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-TRWUQSEK.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-GEN6TAXY.js";
|
|
21
21
|
import {
|
|
22
22
|
cloneDeep_default,
|
|
23
23
|
isPlainObject_default,
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-3T5IU7OU.js";
|
|
7
7
|
import {
|
|
8
8
|
wrapContent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-GEN6TAXY.js";
|
|
10
10
|
import {
|
|
11
11
|
escapeString,
|
|
12
12
|
getTokenizer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZHHB3FT4.js";
|
|
14
14
|
import {
|
|
15
15
|
countBy_default,
|
|
16
16
|
filter_default,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.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 (!_chunkNFZXJRXScjs.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 (!_chunkNFZXJRXScjs.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) => !_chunkNFZXJRXScjs.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 (_chunkNFZXJRXScjs.isZuiSchema.call(void 0, props.schema)) {
|
|
205
205
|
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
206
|
-
} else if (
|
|
206
|
+
} else if (_chunkNFZXJRXScjs.isJsonSchema.call(void 0, props.schema)) {
|
|
207
207
|
this.schema = props.schema;
|
|
208
208
|
} else {
|
|
209
209
|
throw new Error(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTokenizer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ZHHB3FT4.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, _d;
|
|
28
28
|
const tokenizer = getTokenizer();
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
@@ -86,20 +86,12 @@ 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
|
-
|
|
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;
|
|
89
|
+
const targetTokens = Math.max(biggest.tokens - toRemove, ((_d = biggest.attributes) == null ? void 0 : _d.minTokens) ?? 0);
|
|
90
|
+
const mode = preserve === "bottom" ? "tail" : preserve === "both" ? "middle" : "head";
|
|
91
|
+
biggest.content = tokenizer.truncate(biggest.content, targetTokens, mode);
|
|
92
|
+
const nextTokens = tokenizer.count(biggest.content);
|
|
93
|
+
currentCount -= biggest.tokens - nextTokens;
|
|
94
|
+
biggest.tokens = nextTokens;
|
|
103
95
|
}
|
|
104
96
|
return messages.map((msg, i) => {
|
|
105
97
|
const p = parts[i];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.cjs');
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -24,8 +24,8 @@ function truncateWrappedContent({
|
|
|
24
24
|
tokenLimit,
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
|
-
var _a, _b, _c;
|
|
28
|
-
const tokenizer =
|
|
27
|
+
var _a, _b, _c, _d;
|
|
28
|
+
const tokenizer = _chunkNFZXJRXScjs.getTokenizer.call(void 0, );
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
31
31
|
const current = [];
|
|
@@ -86,20 +86,12 @@ function truncateWrappedContent({
|
|
|
86
86
|
toRemove = biggest.tokens - (_nullishCoalesce(((_b = biggest.attributes) == null ? void 0 : _b.minTokens), () => ( 0)));
|
|
87
87
|
}
|
|
88
88
|
const preserve = _nullishCoalesce(((_c = biggest.attributes) == null ? void 0 : _c.preserve), () => ( DEFAULT_TRUNCATE_OPTIONS.preserve));
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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;
|
|
89
|
+
const targetTokens = Math.max(biggest.tokens - toRemove, _nullishCoalesce(((_d = biggest.attributes) == null ? void 0 : _d.minTokens), () => ( 0)));
|
|
90
|
+
const mode = preserve === "bottom" ? "tail" : preserve === "both" ? "middle" : "head";
|
|
91
|
+
biggest.content = tokenizer.truncate(biggest.content, targetTokens, mode);
|
|
92
|
+
const nextTokens = tokenizer.count(biggest.content);
|
|
93
|
+
currentCount -= biggest.tokens - nextTokens;
|
|
94
|
+
biggest.tokens = nextTokens;
|
|
103
95
|
}
|
|
104
96
|
return messages.map((msg, i) => {
|
|
105
97
|
const p = parts[i];
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkKY27DGTGcjs = require('./chunk-KY27DGTG.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
var _chunkNWTG73QRcjs = require('./chunk-NWTG73QR.cjs');
|
|
8
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.cjs');
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
|
|
@@ -14,6 +13,49 @@ var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
|
14
13
|
|
|
15
14
|
// src/tool.ts
|
|
16
15
|
var _zui = require('@bpinternal/zui');
|
|
16
|
+
|
|
17
|
+
// src/convert.ts
|
|
18
|
+
|
|
19
|
+
function convertObjectToZuiLiterals(obj, nested = false) {
|
|
20
|
+
if (typeof obj === "string") {
|
|
21
|
+
return _zui.z.literal(obj).catch(() => obj);
|
|
22
|
+
}
|
|
23
|
+
if (typeof obj === "number") {
|
|
24
|
+
return _zui.z.literal(obj).catch(() => obj);
|
|
25
|
+
}
|
|
26
|
+
if (typeof obj === "boolean") {
|
|
27
|
+
return _zui.z.literal(obj).catch(() => obj);
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(obj)) {
|
|
30
|
+
if (obj.length === 0) {
|
|
31
|
+
return _zui.z.tuple([]).catch(() => obj);
|
|
32
|
+
}
|
|
33
|
+
const items = obj.map((child) => convertObjectToZuiLiterals(child, true));
|
|
34
|
+
return _zui.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 _zui.z.object(shape).catch(() => obj);
|
|
43
|
+
}
|
|
44
|
+
if (Object.keys(shape).length === 0) {
|
|
45
|
+
return _zui.z.object({}).catch(() => obj);
|
|
46
|
+
}
|
|
47
|
+
return shape;
|
|
48
|
+
}
|
|
49
|
+
if (obj === void 0) {
|
|
50
|
+
return _zui.z.undefined().catch(() => void 0);
|
|
51
|
+
}
|
|
52
|
+
if (obj === null) {
|
|
53
|
+
return _zui.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 = class _Tool {
|
|
18
60
|
|
|
19
61
|
|
|
@@ -105,12 +147,16 @@ var Tool = (_class = class _Tool {
|
|
|
105
147
|
input = _zui.z.any();
|
|
106
148
|
}
|
|
107
149
|
if (!_chunkHC2QZTVTcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
108
|
-
const inputExtensions = _chunkNWTG73QRcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
109
150
|
if (_zui.z.is.zuiObject(input)) {
|
|
151
|
+
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
110
152
|
input = input.extend(inputExtensions);
|
|
111
153
|
} else if (_zui.z.is.zuiArray(input)) {
|
|
154
|
+
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
112
155
|
input = _zui.z.array(input.element.extend(inputExtensions));
|
|
113
156
|
} else {
|
|
157
|
+
const inputExtensions = convertObjectToZuiLiterals(
|
|
158
|
+
this._staticInputValues
|
|
159
|
+
);
|
|
114
160
|
input = inputExtensions;
|
|
115
161
|
}
|
|
116
162
|
}
|
|
@@ -149,7 +195,7 @@ var Tool = (_class = class _Tool {
|
|
|
149
195
|
*/
|
|
150
196
|
rename(name) {
|
|
151
197
|
const before = this.name;
|
|
152
|
-
if (!
|
|
198
|
+
if (!_chunkNFZXJRXScjs.isValidIdentifier.call(void 0, name)) {
|
|
153
199
|
throw new Error(
|
|
154
200
|
`Invalid name for tool ${name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
155
201
|
);
|
|
@@ -325,7 +371,7 @@ var Tool = (_class = class _Tool {
|
|
|
325
371
|
* ```
|
|
326
372
|
*/
|
|
327
373
|
constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
328
|
-
if (!
|
|
374
|
+
if (!_chunkNFZXJRXScjs.isValidIdentifier.call(void 0, props.name)) {
|
|
329
375
|
throw new Error(
|
|
330
376
|
`Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
331
377
|
);
|
|
@@ -350,17 +396,17 @@ var Tool = (_class = class _Tool {
|
|
|
350
396
|
`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
351
397
|
);
|
|
352
398
|
}
|
|
353
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
399
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkNFZXJRXScjs.isValidIdentifier.call(void 0, alias))) {
|
|
354
400
|
throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
355
401
|
}
|
|
356
402
|
if (typeof props.input !== "undefined") {
|
|
357
|
-
if (
|
|
403
|
+
if (_chunkNFZXJRXScjs.isZuiSchema.call(void 0, props.input)) {
|
|
358
404
|
try {
|
|
359
405
|
this.input = _zui.transforms.toJSONSchema(props.input);
|
|
360
406
|
} catch (e6) {
|
|
361
407
|
this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
|
|
362
408
|
}
|
|
363
|
-
} else if (
|
|
409
|
+
} else if (_chunkNFZXJRXScjs.isJsonSchema.call(void 0, props.input)) {
|
|
364
410
|
this.input = props.input;
|
|
365
411
|
} else {
|
|
366
412
|
throw new Error(
|
|
@@ -369,13 +415,13 @@ var Tool = (_class = class _Tool {
|
|
|
369
415
|
}
|
|
370
416
|
}
|
|
371
417
|
if (typeof props.output !== "undefined") {
|
|
372
|
-
if (
|
|
418
|
+
if (_chunkNFZXJRXScjs.isZuiSchema.call(void 0, props.output)) {
|
|
373
419
|
try {
|
|
374
420
|
this.output = _zui.transforms.toJSONSchema(props.output);
|
|
375
421
|
} catch (e7) {
|
|
376
422
|
this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
|
|
377
423
|
}
|
|
378
|
-
} else if (
|
|
424
|
+
} else if (_chunkNFZXJRXScjs.isJsonSchema.call(void 0, props.output)) {
|
|
379
425
|
this.output = props.output;
|
|
380
426
|
} else {
|
|
381
427
|
throw new Error(
|
|
@@ -496,13 +542,13 @@ var Tool = (_class = class _Tool {
|
|
|
496
542
|
}
|
|
497
543
|
}
|
|
498
544
|
if (input && _zui.z.is.zuiObject(input.naked()) && typeof this._staticInputValues === "object" && !_chunkHC2QZTVTcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
499
|
-
const inputExtensions =
|
|
545
|
+
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
500
546
|
input = input.extend(inputExtensions);
|
|
501
547
|
} else if (this._staticInputValues !== void 0) {
|
|
502
|
-
input =
|
|
548
|
+
input = convertObjectToZuiLiterals(this._staticInputValues);
|
|
503
549
|
}
|
|
504
550
|
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
505
|
-
return
|
|
551
|
+
return _chunkKY27DGTGcjs.getTypings.call(void 0, fnType, {
|
|
506
552
|
declaration: true
|
|
507
553
|
});
|
|
508
554
|
}
|
|
@@ -5,7 +5,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkNFZXJRXScjs = require('./chunk-NFZXJRXS.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 = _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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(_chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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(_chunkNFZXJRXScjs.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(_chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.getMultilineComment.call(void 0, schema._def.description);
|
|
251
251
|
return `${description}
|
|
252
|
-
${typeof schema.value === "string" ?
|
|
252
|
+
${typeof schema.value === "string" ? _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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 = _chunkNFZXJRXScjs.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}) }`;
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkZVSO527Dcjs = require('./chunk-ZVSO527D.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkH3PZFBJLcjs = require('./chunk-H3PZFBJL.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunkEC2I4U4Gcjs = require('./chunk-EC2I4U4G.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
var _chunkCQ3UJW76cjs = require('./chunk-CQ3UJW76.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkGFSUTNRMcjs = require('./chunk-GFSUTNRM.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 = _chunkZVSO527Dcjs.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(_chunkZVSO527Dcjs.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 _chunkZVSO527Dcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
511
511
|
}
|
|
512
|
-
return
|
|
512
|
+
return _chunkZVSO527Dcjs.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, _chunkEC2I4U4Gcjs.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, _chunkEC2I4U4Gcjs.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, _chunkEC2I4U4Gcjs.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 = _chunkZVSO527Dcjs.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: _chunkGFSUTNRMcjs.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: _chunkGFSUTNRMcjs.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: _chunkGFSUTNRMcjs.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: _chunkGFSUTNRMcjs.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 = _chunkH3PZFBJLcjs.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, _chunkH3PZFBJLcjs.Tool)({
|
|
1316
1316
|
name: "Message",
|
|
1317
1317
|
description: "Send a message to the user",
|
|
1318
1318
|
aliases: Array.from(
|
|
@@ -7,17 +7,14 @@
|
|
|
7
7
|
var _chunkHC2QZTVTcjs = require('./chunk-HC2QZTVT.cjs');
|
|
8
8
|
|
|
9
9
|
// src/utils.ts
|
|
10
|
-
var
|
|
10
|
+
var _micro = require('@bpinternal/thicktoken/micro');
|
|
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
|
-
|
|
18
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
19
|
-
}
|
|
20
|
-
tokenizer = await _thicktoken.getWasmTokenizer.call(void 0, );
|
|
17
|
+
tokenizer = await _micro.getWasmTokenizer.call(void 0, );
|
|
21
18
|
};
|
|
22
19
|
var getTokenizer = () => {
|
|
23
20
|
if (!tokenizer) {
|
|
@@ -138,47 +135,6 @@ var stripInvalidIdentifiers = (object) => {
|
|
|
138
135
|
}
|
|
139
136
|
return _chunkHC2QZTVTcjs.pickBy_default.call(void 0, object, (__, key) => Identifier.safeParse(key).success);
|
|
140
137
|
};
|
|
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
138
|
var isValidSchema = (schema) => {
|
|
183
139
|
try {
|
|
184
140
|
_zui.transforms.fromJSONSchemaLegacy(schema);
|
|
@@ -225,5 +181,4 @@ var getErrorMessage = (err) => err instanceof Error ? err.message : JSON.stringi
|
|
|
225
181
|
|
|
226
182
|
|
|
227
183
|
|
|
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;
|
|
184
|
+
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;
|