llmz 0.0.14 → 0.0.15
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-KH6JQYQA.js → chunk-2D2DE7CD.js} +2 -2
- package/dist/{chunk-WL7ZIMYD.cjs → chunk-3G3BS5IA.cjs} +31 -6
- package/dist/{chunk-SNDVQU5A.js → chunk-3JYCCI4S.js} +1 -1
- package/dist/{chunk-OKTHMXRT.js → chunk-A7QHWVD7.js} +19 -2
- package/dist/{chunk-IH2WQFO5.js → chunk-EE6NVDID.js} +1 -1
- package/dist/{chunk-4L6D2A6O.cjs → chunk-FZJHYLM2.cjs} +14 -14
- package/dist/{chunk-JGVAZO4X.cjs → chunk-GZPN7RGH.cjs} +2 -2
- package/dist/{chunk-SHJDRZF5.cjs → chunk-PIDLNYIP.cjs} +25 -25
- package/dist/{chunk-2Z5SFF6R.js → chunk-RBRTK37G.js} +83 -4
- package/dist/{chunk-GOJY4GRL.cjs → chunk-TCRRSS44.cjs} +97 -18
- package/dist/{chunk-XAN7HQP5.js → chunk-VPTFUOIK.js} +26 -1
- package/dist/{chunk-276Q6EWP.cjs → chunk-WHNOR4ZU.cjs} +3 -0
- package/dist/{chunk-KG7DT7WD.cjs → chunk-XGJOEQMW.cjs} +30 -13
- package/dist/{chunk-4MNIJGK6.js → chunk-ZORRILUV.js} +3 -0
- package/dist/context.d.ts +200 -4
- package/dist/{dual-modes-T53P72CH.js → dual-modes-7FI4T35O.js} +3 -3
- package/dist/{dual-modes-VLIGPIHX.cjs → dual-modes-OFHV2C3X.cjs} +4 -4
- package/dist/exit-XAYKJ6TR.cjs +8 -0
- package/dist/{exit-7HDRH27N.js → exit-YLO7BY7Z.js} +2 -2
- package/dist/exit.d.ts +36 -2
- package/dist/index.cjs +56 -28
- package/dist/index.d.ts +9 -1
- package/dist/index.js +45 -17
- package/dist/{llmz-MCHRHRTD.js → llmz-67EZPJ4E.js} +7 -7
- package/dist/{llmz-TR4CQK4F.cjs → llmz-WVNKAMCP.cjs} +18 -18
- package/dist/objects.d.ts +36 -1
- package/dist/result.d.ts +379 -6
- package/dist/snapshots.d.ts +12 -1
- package/dist/{tool-NS7EGK7Z.cjs → tool-O4SFRIE4.cjs} +4 -4
- package/dist/{tool-4AJIJ3QB.js → tool-PCOYOCRH.js} +3 -3
- package/dist/tool.d.ts +29 -2
- package/dist/{truncator-IY2MXOMC.js → truncator-BSP6PQPC.js} +2 -2
- package/dist/truncator-W3NXBLYJ.cjs +10 -0
- package/dist/types.d.ts +3 -0
- package/dist/{typings-GDMY6VY2.js → typings-WYHEFCYB.js} +2 -2
- package/dist/{typings-2CPHOFDN.cjs → typings-Y45GMPZT.cjs} +3 -3
- package/dist/utils-L5QAQXV2.cjs +39 -0
- package/dist/{utils-N24IHDFA.js → utils-RQHQ2KOG.js} +1 -1
- package/package.json +1 -1
- package/dist/exit-O2WZUEFS.cjs +0 -8
- package/dist/truncator-DUMWEGQO.cjs +0 -10
- package/dist/utils-A7WNEFTA.cjs +0 -39
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-GGWM6X2K.js";
|
|
7
7
|
import {
|
|
8
8
|
wrapContent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3JYCCI4S.js";
|
|
10
10
|
import {
|
|
11
11
|
escapeString,
|
|
12
12
|
getTokenizer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZORRILUV.js";
|
|
14
14
|
import {
|
|
15
15
|
chain_default,
|
|
16
16
|
countBy_default,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.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 (!_chunkWHNOR4ZUcjs.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
|
);
|
|
@@ -100,6 +100,31 @@ var Exit = (_class = class _Exit {
|
|
|
100
100
|
match(result) {
|
|
101
101
|
return result.exit instanceof _Exit && this.name === result.exit.name;
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Serializes this exit to a JSON-compatible object.
|
|
105
|
+
*
|
|
106
|
+
* @returns JSON representation of the exit
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const exit = new Exit({
|
|
111
|
+
* name: 'complete',
|
|
112
|
+
* description: 'Task completed successfully',
|
|
113
|
+
* })
|
|
114
|
+
*
|
|
115
|
+
* console.log(exit.toJSON())
|
|
116
|
+
* // { name: 'complete', aliases: [], description: 'Task completed successfully', metadata: {}, schema: undefined }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
toJSON() {
|
|
120
|
+
return {
|
|
121
|
+
name: this.name,
|
|
122
|
+
aliases: [...this.aliases],
|
|
123
|
+
description: this.description,
|
|
124
|
+
metadata: { ...this.metadata },
|
|
125
|
+
schema: this.schema
|
|
126
|
+
};
|
|
127
|
+
}
|
|
103
128
|
/**
|
|
104
129
|
* Creates a new Exit instance.
|
|
105
130
|
*
|
|
@@ -152,7 +177,7 @@ var Exit = (_class = class _Exit {
|
|
|
152
177
|
* ```
|
|
153
178
|
*/
|
|
154
179
|
constructor(props) {;_class.prototype.__init.call(this);
|
|
155
|
-
if (!
|
|
180
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
156
181
|
throw new Error(
|
|
157
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.`
|
|
158
183
|
);
|
|
@@ -172,13 +197,13 @@ var Exit = (_class = class _Exit {
|
|
|
172
197
|
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
173
198
|
);
|
|
174
199
|
}
|
|
175
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
200
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, alias))) {
|
|
176
201
|
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
177
202
|
}
|
|
178
203
|
if (typeof props.schema !== "undefined") {
|
|
179
|
-
if (
|
|
204
|
+
if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.schema)) {
|
|
180
205
|
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
181
|
-
} else if (
|
|
206
|
+
} else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.schema)) {
|
|
182
207
|
this.schema = props.schema;
|
|
183
208
|
} else {
|
|
184
209
|
throw new Error(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EE6NVDID.js";
|
|
4
4
|
import {
|
|
5
5
|
convertObjectToZuiLiterals,
|
|
6
6
|
isJsonSchema,
|
|
7
7
|
isValidIdentifier,
|
|
8
8
|
isZuiSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZORRILUV.js";
|
|
10
10
|
import {
|
|
11
11
|
isEmpty_default,
|
|
12
12
|
uniq_default
|
|
@@ -469,6 +469,23 @@ var Tool = class _Tool {
|
|
|
469
469
|
return tool.rename(toolName);
|
|
470
470
|
});
|
|
471
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* Converts the tool to its JSON representation.
|
|
474
|
+
*
|
|
475
|
+
* @returns JSON representation of the Tool instance
|
|
476
|
+
*/
|
|
477
|
+
toJSON() {
|
|
478
|
+
return {
|
|
479
|
+
name: this.name,
|
|
480
|
+
aliases: [...this.aliases],
|
|
481
|
+
description: this.description,
|
|
482
|
+
metadata: this.metadata,
|
|
483
|
+
input: this.input,
|
|
484
|
+
output: this.output,
|
|
485
|
+
staticInputValues: this._staticInputValues,
|
|
486
|
+
maxRetries: this.MAX_RETRIES
|
|
487
|
+
};
|
|
488
|
+
}
|
|
472
489
|
};
|
|
473
490
|
|
|
474
491
|
export {
|
|
@@ -5,7 +5,7 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.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 = _chunkWHNOR4ZUcjs.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 = _chunkWHNOR4ZUcjs.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(_chunkWHNOR4ZUcjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
147
|
}
|
|
148
148
|
return args;
|
|
149
149
|
}
|
|
@@ -178,7 +178,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
178
178
|
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
179
|
}
|
|
180
180
|
if (schema instanceof _zui.z.ZodFunction) {
|
|
181
|
-
const description =
|
|
181
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
182
182
|
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
183
183
|
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
184
184
|
if (options == null ? void 0 : options.declaration) {
|
|
@@ -196,7 +196,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
196
196
|
return `Array<${item}>`;
|
|
197
197
|
}
|
|
198
198
|
if (schema instanceof _zui.z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(
|
|
199
|
+
const values = schema._def.values.map(_chunkWHNOR4ZUcjs.escapeString);
|
|
200
200
|
return values.join(" | ");
|
|
201
201
|
}
|
|
202
202
|
if (schema instanceof _zui.z.ZodTuple) {
|
|
@@ -221,7 +221,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
221
221
|
const props = await Promise.all(
|
|
222
222
|
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
223
|
if (value instanceof _zui.z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(
|
|
224
|
+
return sUnwrapZodRecursive(new KeyValue(_chunkWHNOR4ZUcjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
225
225
|
}
|
|
226
226
|
return `${key}: unknown`;
|
|
227
227
|
})
|
|
@@ -229,11 +229,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
229
229
|
return `{ ${props.join("; ")} }`;
|
|
230
230
|
}
|
|
231
231
|
if (schema instanceof _zui.z.ZodString) {
|
|
232
|
-
const description =
|
|
232
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
233
233
|
return `${description} string`.trim();
|
|
234
234
|
}
|
|
235
235
|
if (schema instanceof _zui.z.ZodUnion) {
|
|
236
|
-
const description =
|
|
236
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
237
|
const options2 = await Promise.all(
|
|
238
238
|
schema.options.map(async (option) => {
|
|
239
239
|
return sUnwrapZodRecursive(option, newOptions);
|
|
@@ -243,16 +243,16 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
243
243
|
${options2.join(" | ")}`;
|
|
244
244
|
}
|
|
245
245
|
if (schema instanceof _zui.z.ZodLiteral) {
|
|
246
|
-
const description =
|
|
246
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
247
247
|
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ?
|
|
248
|
+
${typeof schema.value === "string" ? _chunkWHNOR4ZUcjs.escapeString.call(void 0, schema.value) : schema.value}`.trim();
|
|
249
249
|
}
|
|
250
250
|
if (schema instanceof _zui.z.ZodNumber) {
|
|
251
|
-
const description =
|
|
251
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
252
252
|
return `${description} number`.trim();
|
|
253
253
|
}
|
|
254
254
|
if (schema instanceof _zui.z.ZodBoolean) {
|
|
255
|
-
const description =
|
|
255
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
256
|
return `${description} boolean`.trim();
|
|
257
257
|
}
|
|
258
258
|
if (schema instanceof _zui.z.ZodCatch) {
|
|
@@ -262,7 +262,7 @@ ${typeof schema.value === "string" ? _chunk276Q6EWPcjs.escapeString.call(void 0,
|
|
|
262
262
|
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
263
|
}
|
|
264
264
|
if (schema instanceof _zui.z.ZodRecord) {
|
|
265
|
-
const description =
|
|
265
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
266
266
|
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
267
267
|
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
268
268
|
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
@@ -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(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -25,7 +25,7 @@ function truncateWrappedContent({
|
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
27
|
var _a, _b, _c;
|
|
28
|
-
const tokenizer =
|
|
28
|
+
const tokenizer = _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, );
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
31
31
|
const current = [];
|
|
@@ -6,11 +6,11 @@ var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
|
|
|
6
6
|
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
var
|
|
13
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -53,7 +53,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
53
53
|
}
|
|
54
54
|
if (typeof currentObj !== "object" || currentObj === null) {
|
|
55
55
|
const value = JSON.stringify(currentObj);
|
|
56
|
-
currentLength +=
|
|
56
|
+
currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(value);
|
|
57
57
|
return value;
|
|
58
58
|
}
|
|
59
59
|
const indentation = " ".repeat(currentIndent);
|
|
@@ -66,7 +66,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
66
66
|
result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
|
|
67
67
|
}
|
|
68
68
|
result += "\n" + indentation + "]";
|
|
69
|
-
currentLength +=
|
|
69
|
+
currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(result);
|
|
70
70
|
return result;
|
|
71
71
|
} else {
|
|
72
72
|
let result = "{\n";
|
|
@@ -85,11 +85,11 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
|
|
|
85
85
|
result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
|
|
86
86
|
}
|
|
87
87
|
result += "\n" + indentation + "}";
|
|
88
|
-
currentLength +=
|
|
88
|
+
currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(result);
|
|
89
89
|
return result;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const output =
|
|
92
|
+
const output = _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
|
|
93
93
|
return { output, truncated: wasTruncated };
|
|
94
94
|
}
|
|
95
95
|
function extractType(value, generic = true) {
|
|
@@ -154,9 +154,9 @@ function previewValue(value, length = LONG_TEXT_LENGTH) {
|
|
|
154
154
|
}
|
|
155
155
|
const previewStr = (str) => {
|
|
156
156
|
if (str.length > length) {
|
|
157
|
-
return
|
|
157
|
+
return _chunkWHNOR4ZUcjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
|
|
158
158
|
}
|
|
159
|
-
return
|
|
159
|
+
return _chunkWHNOR4ZUcjs.escapeString.call(void 0, str);
|
|
160
160
|
};
|
|
161
161
|
const previewObj = (obj) => {
|
|
162
162
|
const mapped = _chunkUQOBUJIQcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
|
|
@@ -336,7 +336,7 @@ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
|
|
|
336
336
|
} else if (genericType === "boolean") {
|
|
337
337
|
return header + previewValue(value);
|
|
338
338
|
} else if (typeof value === "string") {
|
|
339
|
-
if (
|
|
339
|
+
if (_chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
|
|
340
340
|
return header + previewValue(value);
|
|
341
341
|
} else {
|
|
342
342
|
return header + previewLongText(value);
|
|
@@ -491,15 +491,15 @@ ${variables_example}
|
|
|
491
491
|
role: "system",
|
|
492
492
|
content: replacePlaceholders(canTalk ? system_md_default : system_md_default2, {
|
|
493
493
|
is_message_enabled: canTalk,
|
|
494
|
-
"tools.d.ts":
|
|
494
|
+
"tools.d.ts": _chunkGZPN7RGHcjs.wrapContent.call(void 0, dts, {
|
|
495
495
|
preserve: "both",
|
|
496
496
|
minTokens: 500
|
|
497
497
|
}),
|
|
498
|
-
identity:
|
|
498
|
+
identity: _chunkGZPN7RGHcjs.wrapContent.call(void 0, ((_a = props.instructions) == null ? void 0 : _a.length) ? props.instructions : "No specific instructions provided", {
|
|
499
499
|
preserve: "both",
|
|
500
500
|
minTokens: 1e3
|
|
501
501
|
}),
|
|
502
|
-
transcript:
|
|
502
|
+
transcript: _chunkGZPN7RGHcjs.wrapContent.call(void 0, props.transcript.toString(), {
|
|
503
503
|
preserve: "bottom",
|
|
504
504
|
minTokens: 500
|
|
505
505
|
}),
|
|
@@ -508,7 +508,7 @@ ${variables_example}
|
|
|
508
508
|
writeable_vars: writeable_vars.join(", "),
|
|
509
509
|
variables_example,
|
|
510
510
|
exits,
|
|
511
|
-
components:
|
|
511
|
+
components: _chunkGZPN7RGHcjs.wrapContent.call(void 0,
|
|
512
512
|
props.components.map((component) => _chunkZRCU35UVcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
|
|
513
513
|
{
|
|
514
514
|
preserve: "top",
|
|
@@ -586,13 +586,13 @@ Code:
|
|
|
586
586
|
|
|
587
587
|
\`\`\`tsx
|
|
588
588
|
\u25A0fn_start
|
|
589
|
-
${
|
|
589
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.code)}
|
|
590
590
|
\u25A0fn_end
|
|
591
591
|
\`\`\`
|
|
592
592
|
|
|
593
593
|
Error:
|
|
594
594
|
\`\`\`
|
|
595
|
-
${
|
|
595
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
|
|
596
596
|
\`\`\`
|
|
597
597
|
|
|
598
598
|
Please fix the error and try again.
|
|
@@ -615,11 +615,11 @@ var getCodeExecutionErrorMessage = async (props) => {
|
|
|
615
615
|
|
|
616
616
|
An error occurred while executing the code.
|
|
617
617
|
|
|
618
|
-
${
|
|
618
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
|
|
619
619
|
|
|
620
620
|
Stack Trace:
|
|
621
621
|
\`\`\`
|
|
622
|
-
${
|
|
622
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
|
|
623
623
|
\`\`\`
|
|
624
624
|
|
|
625
625
|
Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
|
|
@@ -642,7 +642,7 @@ var getThinkingMessage = async (props) => {
|
|
|
642
642
|
if (inspected) {
|
|
643
643
|
acc.push(inspected);
|
|
644
644
|
} else {
|
|
645
|
-
acc.push(`Value of ${key} is ${
|
|
645
|
+
acc.push(`Value of ${key} is ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
|
|
646
646
|
}
|
|
647
647
|
return acc;
|
|
648
648
|
}, []);
|
|
@@ -653,7 +653,7 @@ var getThinkingMessage = async (props) => {
|
|
|
653
653
|
if (inspected) {
|
|
654
654
|
return inspected;
|
|
655
655
|
} else {
|
|
656
|
-
return `Value at index ${index} is ${
|
|
656
|
+
return `Value at index ${index} is ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
|
|
657
657
|
}
|
|
658
658
|
});
|
|
659
659
|
context = mapped.join("\n\n");
|
|
@@ -671,7 +671,7 @@ The assistant requested to think. Here's the context:
|
|
|
671
671
|
-------------------
|
|
672
672
|
Reason: ${props.reason || "Thinking requested"}
|
|
673
673
|
Context:
|
|
674
|
-
${
|
|
674
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, context, { preserve: "top" })}
|
|
675
675
|
-------------------
|
|
676
676
|
|
|
677
677
|
Please continue with the conversation (\u25A0fn_start).
|
|
@@ -690,19 +690,19 @@ var getSnapshotResolvedMessage = (props) => {
|
|
|
690
690
|
injectedVariables[variable.name] = variable.value;
|
|
691
691
|
variablesMessage += `
|
|
692
692
|
// Variable "${variable.name}" restored with its full value:
|
|
693
|
-
// ${
|
|
693
|
+
// ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
|
|
694
694
|
declare const ${variable.name}: ${variable.type}
|
|
695
695
|
`;
|
|
696
696
|
} else {
|
|
697
697
|
variablesMessage += `
|
|
698
698
|
// The variable "${variable.name}" was too large to be restored with its full value, here's a preview of its last known value:
|
|
699
|
-
// ${
|
|
699
|
+
// ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
|
|
700
700
|
// Important: To restore the full value, please re-run the code that generated this variable in the first place.
|
|
701
701
|
let ${variable.name}: undefined | ${variable.type} = undefined;
|
|
702
702
|
`;
|
|
703
703
|
}
|
|
704
704
|
}
|
|
705
|
-
const output =
|
|
705
|
+
const output = _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
|
|
706
706
|
preserve: "top",
|
|
707
707
|
flex: 4
|
|
708
708
|
});
|
|
@@ -724,7 +724,7 @@ ${_chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n
|
|
|
724
724
|
Continue the conversation from here, without repeating the above code, as it has already been executed. Here's the variables you can rely on:
|
|
725
725
|
|
|
726
726
|
\`\`\`tsx
|
|
727
|
-
${
|
|
727
|
+
${_chunkGZPN7RGHcjs.wrapContent.call(void 0, variablesMessage)}
|
|
728
728
|
\`\`\`
|
|
729
729
|
|
|
730
730
|
You can now assume that the code you about to generate can rely on the variables "${Object.keys(injectedVariables).join('", "')}" being available.
|
|
@@ -747,7 +747,7 @@ var getSnapshotRejectedMessage = (props) => {
|
|
|
747
747
|
throw new Error("Snapshot is not resolved");
|
|
748
748
|
}
|
|
749
749
|
const errorMessage = _nullishCoalesce(inspect(props.snapshot.status.error), () => ( "Unknown Error"));
|
|
750
|
-
const output =
|
|
750
|
+
const output = _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
|
|
751
751
|
preserve: "both",
|
|
752
752
|
minTokens: 100
|
|
753
753
|
});
|
|
@@ -2,22 +2,22 @@ import {
|
|
|
2
2
|
DualModePrompt,
|
|
3
3
|
extractType,
|
|
4
4
|
inspect
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2D2DE7CD.js";
|
|
6
6
|
import {
|
|
7
7
|
Tool
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-A7QHWVD7.js";
|
|
9
9
|
import {
|
|
10
10
|
LoopExceededError
|
|
11
11
|
} from "./chunk-JKVVQN2P.js";
|
|
12
12
|
import {
|
|
13
13
|
Exit
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-VPTFUOIK.js";
|
|
15
15
|
import {
|
|
16
16
|
assertValidComponent
|
|
17
17
|
} from "./chunk-GGWM6X2K.js";
|
|
18
18
|
import {
|
|
19
19
|
wrapContent
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-3JYCCI4S.js";
|
|
21
21
|
import {
|
|
22
22
|
cloneDeep_default,
|
|
23
23
|
isPlainObject_default
|
|
@@ -510,6 +510,25 @@ var SuccessExecutionResult = class extends ExecutionResult {
|
|
|
510
510
|
get iteration() {
|
|
511
511
|
return this.context.iterations.at(-1);
|
|
512
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Serializes the execution result to JSON.
|
|
515
|
+
*
|
|
516
|
+
* This method converts the execution result into a JSON format that includes
|
|
517
|
+
* the execution status, context, and exit information. It is used for serialization
|
|
518
|
+
* and transmission of the execution result.
|
|
519
|
+
*
|
|
520
|
+
* @returns The JSON representation of the execution result.
|
|
521
|
+
*/
|
|
522
|
+
toJSON() {
|
|
523
|
+
return {
|
|
524
|
+
status: "success",
|
|
525
|
+
context: this.context.toJSON(),
|
|
526
|
+
result: {
|
|
527
|
+
exit: this.result.exit.toJSON(),
|
|
528
|
+
result: this.result.result
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
513
532
|
};
|
|
514
533
|
var ErrorExecutionResult = class extends ExecutionResult {
|
|
515
534
|
error;
|
|
@@ -525,6 +544,13 @@ var ErrorExecutionResult = class extends ExecutionResult {
|
|
|
525
544
|
get output() {
|
|
526
545
|
return null;
|
|
527
546
|
}
|
|
547
|
+
toJSON() {
|
|
548
|
+
return {
|
|
549
|
+
status: "error",
|
|
550
|
+
context: this.context.toJSON(),
|
|
551
|
+
error: this.error
|
|
552
|
+
};
|
|
553
|
+
}
|
|
528
554
|
};
|
|
529
555
|
var PartialExecutionResult = class extends ExecutionResult {
|
|
530
556
|
signal;
|
|
@@ -542,6 +568,23 @@ var PartialExecutionResult = class extends ExecutionResult {
|
|
|
542
568
|
get output() {
|
|
543
569
|
return null;
|
|
544
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Serializes the execution result to JSON.
|
|
573
|
+
*
|
|
574
|
+
* @returns The JSON representation of the execution result.
|
|
575
|
+
*/
|
|
576
|
+
toJSON() {
|
|
577
|
+
return {
|
|
578
|
+
status: "interrupted",
|
|
579
|
+
context: this.context.toJSON(),
|
|
580
|
+
snapshot: this.snapshot.toJSON(),
|
|
581
|
+
signal: {
|
|
582
|
+
message: this.signal.message,
|
|
583
|
+
truncatedCode: this.signal.truncatedCode,
|
|
584
|
+
variables: this.signal.variables
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}
|
|
545
588
|
};
|
|
546
589
|
|
|
547
590
|
// src/getter.ts
|
|
@@ -715,6 +758,28 @@ var Iteration = class {
|
|
|
715
758
|
this.ended_ts = Date.now();
|
|
716
759
|
this.status = status;
|
|
717
760
|
}
|
|
761
|
+
toJSON() {
|
|
762
|
+
return {
|
|
763
|
+
id: this.id,
|
|
764
|
+
messages: [...this.messages],
|
|
765
|
+
code: this.code,
|
|
766
|
+
traces: [...this.traces],
|
|
767
|
+
variables: this.variables,
|
|
768
|
+
started_ts: this.started_ts,
|
|
769
|
+
ended_ts: this.ended_ts,
|
|
770
|
+
status: this.status,
|
|
771
|
+
mutations: [...this._mutations.values()],
|
|
772
|
+
llm: this.llm,
|
|
773
|
+
transcript: [...this._parameters.transcript],
|
|
774
|
+
tools: this._parameters.tools.map((tool) => tool.toJSON()),
|
|
775
|
+
objects: this._parameters.objects.map((obj) => obj.toJSON()),
|
|
776
|
+
exits: this._parameters.exits.map((exit) => exit.toJSON()),
|
|
777
|
+
instructions: this._parameters.instructions,
|
|
778
|
+
duration: this.duration,
|
|
779
|
+
error: this.error,
|
|
780
|
+
isChatEnabled: this.isChatEnabled
|
|
781
|
+
};
|
|
782
|
+
}
|
|
718
783
|
};
|
|
719
784
|
var Context = class {
|
|
720
785
|
id;
|
|
@@ -1006,6 +1071,20 @@ var Context = class {
|
|
|
1006
1071
|
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1007
1072
|
}
|
|
1008
1073
|
}
|
|
1074
|
+
toJSON() {
|
|
1075
|
+
var _a;
|
|
1076
|
+
return {
|
|
1077
|
+
id: this.id,
|
|
1078
|
+
iterations: this.iterations.map((iteration) => iteration.toJSON()),
|
|
1079
|
+
iteration: this.iteration,
|
|
1080
|
+
timeout: this.timeout,
|
|
1081
|
+
loop: this.loop,
|
|
1082
|
+
temperature: this.temperature,
|
|
1083
|
+
model: this.model,
|
|
1084
|
+
metadata: this.metadata,
|
|
1085
|
+
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1009
1088
|
};
|
|
1010
1089
|
|
|
1011
1090
|
export {
|