llmz 0.9.0 → 0.9.2
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/{common-BnvrDnIT.cjs → common-DJkSpeqw.cjs} +1 -1
- package/dist/{common-BlRFtdf2.js → common-DuEhn6u3.js} +1 -1
- package/dist/compiler/plugins/variable-extraction.d.ts +1 -7
- package/dist/{compiler-C-OI9sim.cjs → compiler-BJJUmNS9.cjs} +34 -68
- package/dist/{compiler-CW1VjQsn.js → compiler-BPl-5CXh.js} +34 -68
- package/dist/{component-C6Agl2ns.cjs → component-CPKXe6Ca.cjs} +2 -2
- package/dist/{custom-client-DAsGRnYc.cjs → custom-client-B_o56CB4.cjs} +6 -6
- package/dist/{custom-client-ChuZ63zp.js → custom-client-C-nDKG37.js} +3 -3
- package/dist/{dual-modes-DPXiuvNe.cjs → dual-modes-BNHlj2qM.cjs} +15 -14
- package/dist/{dual-modes-DDkoCp3R.js → dual-modes-BNIiNLrR.js} +13 -12
- package/dist/{execute-DM2-7y86.cjs → execute-0bvqakr7.cjs} +31 -18
- package/dist/{execute-BWcdv9so.js → execute-CWFIL5ny.js} +30 -17
- package/dist/{exit-DUM96DN1.cjs → exit-CGLXI0BH.cjs} +2 -2
- package/dist/index.cjs +21 -21
- package/dist/index.js +12 -12
- package/dist/index.workerd.js +217 -195
- package/dist/{jsx-owqxrquU.cjs → jsx-BJ6GWXI2.cjs} +1 -1
- package/dist/runtime/generate.test.d.ts +1 -0
- package/dist/{tool-Bv8N4IPj.js → tool-B6Pmuk6K.js} +35 -49
- package/dist/{tool-Dy6AJpJH.cjs → tool-BLTrA-sL.cjs} +38 -52
- package/dist/tool.d.ts +5 -3
- package/dist/{truncator-DZqEqnpD.js → truncator-CD7QtE84.js} +11 -6
- package/dist/{truncator-CLkouTCO.cjs → truncator-DmCu9M4m.cjs} +13 -8
- package/dist/{typings-3lsqCbkn.cjs → typings-DXJMu59O.cjs} +2 -2
- package/dist/{utils-3ESwP3yg.cjs → utils-DGQ4sRke.cjs} +1 -1
- package/dist/{vm-BLsHw1da.js → vm-Cn3jvZ00.js} +109 -53
- package/dist/{vm-D6s1zF6M.cjs → vm-X0uTj5Aa.cjs} +109 -53
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
2
|
const require__overArg = require("./_overArg-C5Hy7oCi.cjs");
|
|
3
3
|
const require_isPlainObject = require("./isPlainObject-CSxXVKCk.cjs");
|
|
4
4
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -164,13 +164,15 @@ var tool_exports = /* @__PURE__ */ __exportAll({ Tool: () => Tool });
|
|
|
164
164
|
*
|
|
165
165
|
* Tools automatically handle:
|
|
166
166
|
* - **Input validation**: Invalid inputs throw descriptive errors
|
|
167
|
-
* - **Output
|
|
167
|
+
* - **Output descriptions**: Output schemas describe likely results; handler output is returned unchanged
|
|
168
168
|
* - **Handler errors**: Exceptions in handlers are caught and can trigger retries
|
|
169
169
|
* - **Type coercion**: Basic type coercion where possible
|
|
170
170
|
*
|
|
171
171
|
*/
|
|
172
172
|
var Tool = class Tool {
|
|
173
173
|
_staticInputValues;
|
|
174
|
+
_inputSchema;
|
|
175
|
+
_outputSchema;
|
|
174
176
|
name;
|
|
175
177
|
aliases = [];
|
|
176
178
|
description;
|
|
@@ -241,23 +243,14 @@ var Tool = class Tool {
|
|
|
241
243
|
* @internal
|
|
242
244
|
*/
|
|
243
245
|
get zInput() {
|
|
244
|
-
|
|
245
|
-
if (this.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
else
|
|
251
|
-
|
|
252
|
-
if (z.is.zuiObject(input)) {
|
|
253
|
-
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
254
|
-
input = input.extend(inputExtensions);
|
|
255
|
-
} else if (z.is.zuiArray(input)) {
|
|
256
|
-
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
257
|
-
input = z.array(input.element.extend(inputExtensions));
|
|
258
|
-
} else input = convertObjectToZuiLiterals(this._staticInputValues);
|
|
259
|
-
}
|
|
260
|
-
return input;
|
|
246
|
+
const input = this._inputSchema ?? (this.input ? fromJSONSchemaCompat(this.input) : z.any());
|
|
247
|
+
if (isEmpty(this._staticInputValues)) return input;
|
|
248
|
+
const shape = this.input ? fromJSONSchemaCompat(this.input) : z.any();
|
|
249
|
+
let overrides;
|
|
250
|
+
if (z.is.zuiObject(shape)) overrides = z.object(convertObjectToZuiLiterals(this._staticInputValues)).passthrough();
|
|
251
|
+
else if (z.is.zuiArray(shape)) overrides = z.array(z.object(convertObjectToZuiLiterals(this._staticInputValues)).passthrough());
|
|
252
|
+
else overrides = convertObjectToZuiLiterals(this._staticInputValues);
|
|
253
|
+
return overrides.pipe(input);
|
|
261
254
|
}
|
|
262
255
|
/**
|
|
263
256
|
* Gets the output schema for validation.
|
|
@@ -354,18 +347,8 @@ var Tool = class Tool {
|
|
|
354
347
|
clone(props = {}) {
|
|
355
348
|
try {
|
|
356
349
|
var _props$input, _props$output;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
zInput = transforms.fromJSONSchema(this.input);
|
|
360
|
-
} catch {
|
|
361
|
-
zInput = transforms.fromJSONSchemaLegacy(this.input);
|
|
362
|
-
}
|
|
363
|
-
let zOutput;
|
|
364
|
-
if (this.output) try {
|
|
365
|
-
zOutput = transforms.fromJSONSchema(this.output);
|
|
366
|
-
} catch {
|
|
367
|
-
zOutput = transforms.fromJSONSchemaLegacy(this.output);
|
|
368
|
-
}
|
|
350
|
+
const zInput = this._inputSchema ?? (this.input ? fromJSONSchemaCompat(this.input) : void 0);
|
|
351
|
+
const zOutput = this._outputSchema ?? (this.output ? fromJSONSchemaCompat(this.output) : void 0);
|
|
369
352
|
return new Tool({
|
|
370
353
|
name: props.name ?? this.name,
|
|
371
354
|
aliases: props.aliases ?? [...this.aliases],
|
|
@@ -388,7 +371,7 @@ var Tool = class Tool {
|
|
|
388
371
|
* @param props.name - Unique tool name (must be valid TypeScript identifier)
|
|
389
372
|
* @param props.description - Human-readable description for the LLM
|
|
390
373
|
* @param props.input - Zui/Zod schema for input validation (optional)
|
|
391
|
-
* @param props.output - Zui/Zod schema
|
|
374
|
+
* @param props.output - Zui/Zod schema describing output (optional)
|
|
392
375
|
* @param props.handler - Async function that implements the tool logic
|
|
393
376
|
* @param props.aliases - Alternative names for the tool (optional)
|
|
394
377
|
* @param props.metadata - Additional metadata for the tool (optional)
|
|
@@ -465,21 +448,25 @@ var Tool = class Tool {
|
|
|
465
448
|
if (props.aliases !== void 0 && !Array.isArray(props.aliases)) throw new Error(`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`);
|
|
466
449
|
if (props.aliases && props.aliases.some((alias) => !isValidIdentifier(alias))) throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
467
450
|
if (typeof props.input !== "undefined") {
|
|
468
|
-
if (isZuiSchema(props.input))
|
|
469
|
-
this.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
451
|
+
if (isZuiSchema(props.input)) {
|
|
452
|
+
this._inputSchema = props.input;
|
|
453
|
+
try {
|
|
454
|
+
this.input = transforms.toJSONSchema(props.input);
|
|
455
|
+
} catch {
|
|
456
|
+
this.input = transforms.toJSONSchemaLegacy(props.input);
|
|
457
|
+
}
|
|
458
|
+
} else if (isJsonSchema(props.input)) this.input = props.input;
|
|
474
459
|
else throw new Error(`Invalid input schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.input}"`);
|
|
475
460
|
}
|
|
476
461
|
if (typeof props.output !== "undefined") {
|
|
477
|
-
if (isZuiSchema(props.output))
|
|
478
|
-
this.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
462
|
+
if (isZuiSchema(props.output)) {
|
|
463
|
+
this._outputSchema = props.output;
|
|
464
|
+
try {
|
|
465
|
+
this.output = transforms.toJSONSchema(props.output);
|
|
466
|
+
} catch {
|
|
467
|
+
this.output = transforms.toJSONSchemaLegacy(props.output);
|
|
468
|
+
}
|
|
469
|
+
} else if (isJsonSchema(props.output)) this.output = props.output;
|
|
483
470
|
else throw new Error(`Invalid output schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.output}"`);
|
|
484
471
|
}
|
|
485
472
|
this.name = props.name;
|
|
@@ -511,7 +498,7 @@ var Tool = class Tool {
|
|
|
511
498
|
/**
|
|
512
499
|
* Executes the tool with the given input and context.
|
|
513
500
|
*
|
|
514
|
-
* This method handles input validation, retry logic,
|
|
501
|
+
* This method handles input validation, retry logic, and error handling.
|
|
515
502
|
* It's called internally by the LLMz execution engine when generated code calls the tool.
|
|
516
503
|
*
|
|
517
504
|
* @param input - Input data to pass to the tool handler
|
|
@@ -533,17 +520,16 @@ var Tool = class Tool {
|
|
|
533
520
|
* @internal This method is primarily used internally by the LLMz execution engine
|
|
534
521
|
*/
|
|
535
522
|
async execute(rawInput, ctx, chat) {
|
|
536
|
-
const
|
|
537
|
-
const
|
|
523
|
+
const shape = this.input ? fromJSONSchemaCompat(this.input) : z.any();
|
|
524
|
+
const input = z.is.zuiObject(shape) ? rawInput ?? {} : rawInput;
|
|
525
|
+
const pInput = await this.zInput.safeParseAsync(input);
|
|
538
526
|
if (!pInput.success) throw new Error(`Tool "${this.name}" received invalid input: ${pInput.error.message}`);
|
|
539
527
|
let attempt = 0;
|
|
540
528
|
let yieldedCount = 0;
|
|
541
529
|
while (attempt < this.MAX_RETRIES) try {
|
|
542
|
-
|
|
530
|
+
return await this._executeHandler(pInput.data, ctx, chat, yieldedCount, (n) => {
|
|
543
531
|
yieldedCount = n;
|
|
544
532
|
});
|
|
545
|
-
const pOutput = this.zOutput.safeParse(result);
|
|
546
|
-
return pOutput.success ? pOutput.data : result;
|
|
547
533
|
} catch (err) {
|
|
548
534
|
var _this$retry;
|
|
549
535
|
if (!await ((_this$retry = this.retry) === null || _this$retry === void 0 ? void 0 : _this$retry.call(this, {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
2
|
const require_uniq = require("./uniq-G872RWmE.cjs");
|
|
3
|
-
const require_utils = require("./utils-
|
|
3
|
+
const require_utils = require("./utils-DGQ4sRke.cjs");
|
|
4
4
|
const require_isEmpty = require("./isEmpty-LY533Wmh.cjs");
|
|
5
|
-
const require_typings = require("./typings-
|
|
5
|
+
const require_typings = require("./typings-DXJMu59O.cjs");
|
|
6
6
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
7
7
|
//#region src/convert.ts
|
|
8
8
|
function convertObjectToZuiLiterals(obj, nested = false) {
|
|
@@ -164,13 +164,15 @@ var tool_exports = /* @__PURE__ */ require_compiler.__exportAll({ Tool: () => To
|
|
|
164
164
|
*
|
|
165
165
|
* Tools automatically handle:
|
|
166
166
|
* - **Input validation**: Invalid inputs throw descriptive errors
|
|
167
|
-
* - **Output
|
|
167
|
+
* - **Output descriptions**: Output schemas describe likely results; handler output is returned unchanged
|
|
168
168
|
* - **Handler errors**: Exceptions in handlers are caught and can trigger retries
|
|
169
169
|
* - **Type coercion**: Basic type coercion where possible
|
|
170
170
|
*
|
|
171
171
|
*/
|
|
172
172
|
var Tool = class Tool {
|
|
173
173
|
_staticInputValues;
|
|
174
|
+
_inputSchema;
|
|
175
|
+
_outputSchema;
|
|
174
176
|
name;
|
|
175
177
|
aliases = [];
|
|
176
178
|
description;
|
|
@@ -241,23 +243,14 @@ var Tool = class Tool {
|
|
|
241
243
|
* @internal
|
|
242
244
|
*/
|
|
243
245
|
get zInput() {
|
|
244
|
-
|
|
245
|
-
if (this.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
else
|
|
251
|
-
|
|
252
|
-
if (_bpinternal_zui.z.is.zuiObject(input)) {
|
|
253
|
-
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
254
|
-
input = input.extend(inputExtensions);
|
|
255
|
-
} else if (_bpinternal_zui.z.is.zuiArray(input)) {
|
|
256
|
-
const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
|
|
257
|
-
input = _bpinternal_zui.z.array(input.element.extend(inputExtensions));
|
|
258
|
-
} else input = convertObjectToZuiLiterals(this._staticInputValues);
|
|
259
|
-
}
|
|
260
|
-
return input;
|
|
246
|
+
const input = this._inputSchema ?? (this.input ? require_utils.fromJSONSchemaCompat(this.input) : _bpinternal_zui.z.any());
|
|
247
|
+
if (require_isEmpty.isEmpty(this._staticInputValues)) return input;
|
|
248
|
+
const shape = this.input ? require_utils.fromJSONSchemaCompat(this.input) : _bpinternal_zui.z.any();
|
|
249
|
+
let overrides;
|
|
250
|
+
if (_bpinternal_zui.z.is.zuiObject(shape)) overrides = _bpinternal_zui.z.object(convertObjectToZuiLiterals(this._staticInputValues)).passthrough();
|
|
251
|
+
else if (_bpinternal_zui.z.is.zuiArray(shape)) overrides = _bpinternal_zui.z.array(_bpinternal_zui.z.object(convertObjectToZuiLiterals(this._staticInputValues)).passthrough());
|
|
252
|
+
else overrides = convertObjectToZuiLiterals(this._staticInputValues);
|
|
253
|
+
return overrides.pipe(input);
|
|
261
254
|
}
|
|
262
255
|
/**
|
|
263
256
|
* Gets the output schema for validation.
|
|
@@ -354,18 +347,8 @@ var Tool = class Tool {
|
|
|
354
347
|
clone(props = {}) {
|
|
355
348
|
try {
|
|
356
349
|
var _props$input, _props$output;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
zInput = _bpinternal_zui.transforms.fromJSONSchema(this.input);
|
|
360
|
-
} catch {
|
|
361
|
-
zInput = _bpinternal_zui.transforms.fromJSONSchemaLegacy(this.input);
|
|
362
|
-
}
|
|
363
|
-
let zOutput;
|
|
364
|
-
if (this.output) try {
|
|
365
|
-
zOutput = _bpinternal_zui.transforms.fromJSONSchema(this.output);
|
|
366
|
-
} catch {
|
|
367
|
-
zOutput = _bpinternal_zui.transforms.fromJSONSchemaLegacy(this.output);
|
|
368
|
-
}
|
|
350
|
+
const zInput = this._inputSchema ?? (this.input ? require_utils.fromJSONSchemaCompat(this.input) : void 0);
|
|
351
|
+
const zOutput = this._outputSchema ?? (this.output ? require_utils.fromJSONSchemaCompat(this.output) : void 0);
|
|
369
352
|
return new Tool({
|
|
370
353
|
name: props.name ?? this.name,
|
|
371
354
|
aliases: props.aliases ?? [...this.aliases],
|
|
@@ -388,7 +371,7 @@ var Tool = class Tool {
|
|
|
388
371
|
* @param props.name - Unique tool name (must be valid TypeScript identifier)
|
|
389
372
|
* @param props.description - Human-readable description for the LLM
|
|
390
373
|
* @param props.input - Zui/Zod schema for input validation (optional)
|
|
391
|
-
* @param props.output - Zui/Zod schema
|
|
374
|
+
* @param props.output - Zui/Zod schema describing output (optional)
|
|
392
375
|
* @param props.handler - Async function that implements the tool logic
|
|
393
376
|
* @param props.aliases - Alternative names for the tool (optional)
|
|
394
377
|
* @param props.metadata - Additional metadata for the tool (optional)
|
|
@@ -465,21 +448,25 @@ var Tool = class Tool {
|
|
|
465
448
|
if (props.aliases !== void 0 && !Array.isArray(props.aliases)) throw new Error(`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`);
|
|
466
449
|
if (props.aliases && props.aliases.some((alias) => !require_utils.isValidIdentifier(alias))) throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
467
450
|
if (typeof props.input !== "undefined") {
|
|
468
|
-
if (require_utils.isZuiSchema(props.input))
|
|
469
|
-
this.
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
451
|
+
if (require_utils.isZuiSchema(props.input)) {
|
|
452
|
+
this._inputSchema = props.input;
|
|
453
|
+
try {
|
|
454
|
+
this.input = _bpinternal_zui.transforms.toJSONSchema(props.input);
|
|
455
|
+
} catch {
|
|
456
|
+
this.input = _bpinternal_zui.transforms.toJSONSchemaLegacy(props.input);
|
|
457
|
+
}
|
|
458
|
+
} else if (require_utils.isJsonSchema(props.input)) this.input = props.input;
|
|
474
459
|
else throw new Error(`Invalid input schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.input}"`);
|
|
475
460
|
}
|
|
476
461
|
if (typeof props.output !== "undefined") {
|
|
477
|
-
if (require_utils.isZuiSchema(props.output))
|
|
478
|
-
this.
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
462
|
+
if (require_utils.isZuiSchema(props.output)) {
|
|
463
|
+
this._outputSchema = props.output;
|
|
464
|
+
try {
|
|
465
|
+
this.output = _bpinternal_zui.transforms.toJSONSchema(props.output);
|
|
466
|
+
} catch {
|
|
467
|
+
this.output = _bpinternal_zui.transforms.toJSONSchemaLegacy(props.output);
|
|
468
|
+
}
|
|
469
|
+
} else if (require_utils.isJsonSchema(props.output)) this.output = props.output;
|
|
483
470
|
else throw new Error(`Invalid output schema for tool ${props.name}. Expected a ZodType or JSONSchema, but got type "${typeof props.output}"`);
|
|
484
471
|
}
|
|
485
472
|
this.name = props.name;
|
|
@@ -511,7 +498,7 @@ var Tool = class Tool {
|
|
|
511
498
|
/**
|
|
512
499
|
* Executes the tool with the given input and context.
|
|
513
500
|
*
|
|
514
|
-
* This method handles input validation, retry logic,
|
|
501
|
+
* This method handles input validation, retry logic, and error handling.
|
|
515
502
|
* It's called internally by the LLMz execution engine when generated code calls the tool.
|
|
516
503
|
*
|
|
517
504
|
* @param input - Input data to pass to the tool handler
|
|
@@ -533,17 +520,16 @@ var Tool = class Tool {
|
|
|
533
520
|
* @internal This method is primarily used internally by the LLMz execution engine
|
|
534
521
|
*/
|
|
535
522
|
async execute(rawInput, ctx, chat) {
|
|
536
|
-
const
|
|
537
|
-
const
|
|
523
|
+
const shape = this.input ? require_utils.fromJSONSchemaCompat(this.input) : _bpinternal_zui.z.any();
|
|
524
|
+
const input = _bpinternal_zui.z.is.zuiObject(shape) ? rawInput ?? {} : rawInput;
|
|
525
|
+
const pInput = await this.zInput.safeParseAsync(input);
|
|
538
526
|
if (!pInput.success) throw new Error(`Tool "${this.name}" received invalid input: ${pInput.error.message}`);
|
|
539
527
|
let attempt = 0;
|
|
540
528
|
let yieldedCount = 0;
|
|
541
529
|
while (attempt < this.MAX_RETRIES) try {
|
|
542
|
-
|
|
530
|
+
return await this._executeHandler(pInput.data, ctx, chat, yieldedCount, (n) => {
|
|
543
531
|
yieldedCount = n;
|
|
544
532
|
});
|
|
545
|
-
const pOutput = this.zOutput.safeParse(result);
|
|
546
|
-
return pOutput.success ? pOutput.data : result;
|
|
547
533
|
} catch (err) {
|
|
548
534
|
var _this$retry;
|
|
549
535
|
if (!await ((_this$retry = this.retry) === null || _this$retry === void 0 ? void 0 : _this$retry.call(this, {
|
package/dist/tool.d.ts
CHANGED
|
@@ -200,13 +200,15 @@ export declare namespace Tool {
|
|
|
200
200
|
*
|
|
201
201
|
* Tools automatically handle:
|
|
202
202
|
* - **Input validation**: Invalid inputs throw descriptive errors
|
|
203
|
-
* - **Output
|
|
203
|
+
* - **Output descriptions**: Output schemas describe likely results; handler output is returned unchanged
|
|
204
204
|
* - **Handler errors**: Exceptions in handlers are caught and can trigger retries
|
|
205
205
|
* - **Type coercion**: Basic type coercion where possible
|
|
206
206
|
*
|
|
207
207
|
*/
|
|
208
208
|
export declare class Tool<I extends z.ZodType = z.ZodType, O extends z.ZodType = z.ZodType> implements Serializable<Tool.JSON> {
|
|
209
209
|
private _staticInputValues?;
|
|
210
|
+
private _inputSchema?;
|
|
211
|
+
private _outputSchema?;
|
|
210
212
|
name: string;
|
|
211
213
|
aliases: string[];
|
|
212
214
|
description?: string;
|
|
@@ -364,7 +366,7 @@ export declare class Tool<I extends z.ZodType = z.ZodType, O extends z.ZodType =
|
|
|
364
366
|
* @param props.name - Unique tool name (must be valid TypeScript identifier)
|
|
365
367
|
* @param props.description - Human-readable description for the LLM
|
|
366
368
|
* @param props.input - Zui/Zod schema for input validation (optional)
|
|
367
|
-
* @param props.output - Zui/Zod schema
|
|
369
|
+
* @param props.output - Zui/Zod schema describing output (optional)
|
|
368
370
|
* @param props.handler - Async function that implements the tool logic
|
|
369
371
|
* @param props.aliases - Alternative names for the tool (optional)
|
|
370
372
|
* @param props.metadata - Additional metadata for the tool (optional)
|
|
@@ -448,7 +450,7 @@ export declare class Tool<I extends z.ZodType = z.ZodType, O extends z.ZodType =
|
|
|
448
450
|
/**
|
|
449
451
|
* Executes the tool with the given input and context.
|
|
450
452
|
*
|
|
451
|
-
* This method handles input validation, retry logic,
|
|
453
|
+
* This method handles input validation, retry logic, and error handling.
|
|
452
454
|
* It's called internally by the LLMz execution engine when generated code calls the tool.
|
|
453
455
|
*
|
|
454
456
|
* @param input - Input data to pass to the tool handler
|
|
@@ -126,9 +126,9 @@ function truncateWrappedContent({ messages, tokenLimit, throwOnFailure = true })
|
|
|
126
126
|
* After { content: 'content', tokens: 10, truncatable: false }
|
|
127
127
|
*/
|
|
128
128
|
const parts = [];
|
|
129
|
-
|
|
129
|
+
const contents = messages.flatMap((message) => typeof message.content === "string" ? [message.content] : (message.content ?? []).flatMap((part) => part.type === "text" ? [part.text ?? ""] : []));
|
|
130
|
+
for (const content of contents) {
|
|
130
131
|
const current = [];
|
|
131
|
-
const content = typeof msg.content === "string" ? msg.content : "";
|
|
132
132
|
let match;
|
|
133
133
|
const parser = new _MessageContentParser();
|
|
134
134
|
while ((match = parser.parse(content)) !== null) {
|
|
@@ -190,11 +190,16 @@ function truncateWrappedContent({ messages, tokenLimit, throwOnFailure = true })
|
|
|
190
190
|
biggest.tokens -= toRemove;
|
|
191
191
|
currentCount -= toRemove;
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
let textIndex = 0;
|
|
194
|
+
const renderText = () => _renderRemainingWrappers(parts[textIndex++].map((part) => part.content).join(""));
|
|
195
|
+
return messages.map((message) => {
|
|
196
|
+
var _message$content;
|
|
195
197
|
return {
|
|
196
|
-
...
|
|
197
|
-
content: typeof
|
|
198
|
+
...message,
|
|
199
|
+
content: typeof message.content === "string" ? renderText() : ((_message$content = message.content) === null || _message$content === void 0 ? void 0 : _message$content.map((part) => part.type === "text" ? {
|
|
200
|
+
...part,
|
|
201
|
+
text: renderText()
|
|
202
|
+
} : part)) ?? message.content
|
|
198
203
|
};
|
|
199
204
|
});
|
|
200
205
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
2
|
-
const require_utils = require("./utils-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
|
+
const require_utils = require("./utils-DGQ4sRke.cjs");
|
|
3
3
|
//#region src/truncator.ts
|
|
4
4
|
var truncator_exports = /* @__PURE__ */ require_compiler.__exportAll({
|
|
5
5
|
stripTruncationTags: () => stripTruncationTags,
|
|
@@ -126,9 +126,9 @@ function truncateWrappedContent({ messages, tokenLimit, throwOnFailure = true })
|
|
|
126
126
|
* After { content: 'content', tokens: 10, truncatable: false }
|
|
127
127
|
*/
|
|
128
128
|
const parts = [];
|
|
129
|
-
|
|
129
|
+
const contents = messages.flatMap((message) => typeof message.content === "string" ? [message.content] : (message.content ?? []).flatMap((part) => part.type === "text" ? [part.text ?? ""] : []));
|
|
130
|
+
for (const content of contents) {
|
|
130
131
|
const current = [];
|
|
131
|
-
const content = typeof msg.content === "string" ? msg.content : "";
|
|
132
132
|
let match;
|
|
133
133
|
const parser = new _MessageContentParser();
|
|
134
134
|
while ((match = parser.parse(content)) !== null) {
|
|
@@ -190,11 +190,16 @@ function truncateWrappedContent({ messages, tokenLimit, throwOnFailure = true })
|
|
|
190
190
|
biggest.tokens -= toRemove;
|
|
191
191
|
currentCount -= toRemove;
|
|
192
192
|
}
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
let textIndex = 0;
|
|
194
|
+
const renderText = () => _renderRemainingWrappers(parts[textIndex++].map((part) => part.content).join(""));
|
|
195
|
+
return messages.map((message) => {
|
|
196
|
+
var _message$content;
|
|
195
197
|
return {
|
|
196
|
-
...
|
|
197
|
-
content: typeof
|
|
198
|
+
...message,
|
|
199
|
+
content: typeof message.content === "string" ? renderText() : ((_message$content = message.content) === null || _message$content === void 0 ? void 0 : _message$content.map((part) => part.type === "text" ? {
|
|
200
|
+
...part,
|
|
201
|
+
text: renderText()
|
|
202
|
+
} : part)) ?? message.content
|
|
198
203
|
};
|
|
199
204
|
});
|
|
200
205
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
2
|
-
const require_utils = require("./utils-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
|
+
const require_utils = require("./utils-DGQ4sRke.cjs");
|
|
3
3
|
const require_errors = require("./errors-C962uJdS.cjs");
|
|
4
4
|
let _bpinternal_zui = require("@bpinternal/zui");
|
|
5
5
|
//#region src/typings-formatter.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_compiler = require("./compiler-
|
|
1
|
+
const require_compiler = require("./compiler-BJJUmNS9.cjs");
|
|
2
2
|
const require__baseIteratee = require("./_baseIteratee-CF4qP2a8.cjs");
|
|
3
3
|
const require__getPrototype = require("./_getPrototype-DQDlNVVM.cjs");
|
|
4
4
|
let _bpinternal_zui = require("@bpinternal/zui");
|