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
package/dist/exit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JSONSchema7 } from 'json-schema';
|
|
2
|
-
import { ZuiType } from './types.js';
|
|
2
|
+
import { Serializable, ZuiType } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Represents the result of an agent execution that exited with a specific Exit.
|
|
5
5
|
*
|
|
@@ -11,6 +11,15 @@ export type ExitResult<T = unknown> = {
|
|
|
11
11
|
/** The result data returned by the exit (validated against the exit's schema) */
|
|
12
12
|
result: T;
|
|
13
13
|
};
|
|
14
|
+
export declare namespace Exit {
|
|
15
|
+
type JSON = {
|
|
16
|
+
name: string;
|
|
17
|
+
aliases: string[];
|
|
18
|
+
description: string;
|
|
19
|
+
metadata: Record<string, unknown>;
|
|
20
|
+
schema?: JSONSchema7;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
14
23
|
/**
|
|
15
24
|
* Defines how LLMz agent execution can terminate.
|
|
16
25
|
*
|
|
@@ -211,7 +220,7 @@ export type ExitResult<T = unknown> = {
|
|
|
211
220
|
* @see {@link ListenExit} Built-in chat listening exit
|
|
212
221
|
* @see {@link DefaultExit} Built-in completion exit
|
|
213
222
|
*/
|
|
214
|
-
export declare class Exit<T = unknown> {
|
|
223
|
+
export declare class Exit<T = unknown> implements Serializable<Exit.JSON> {
|
|
215
224
|
/** The primary name of the exit (used in return statements) */
|
|
216
225
|
name: string;
|
|
217
226
|
/** Alternative names that can be used to reference this exit */
|
|
@@ -278,6 +287,31 @@ export declare class Exit<T = unknown> {
|
|
|
278
287
|
* @returns True if the result was created by this exit
|
|
279
288
|
*/
|
|
280
289
|
match(result: ExitResult): result is ExitResult<T>;
|
|
290
|
+
/**
|
|
291
|
+
* Serializes this exit to a JSON-compatible object.
|
|
292
|
+
*
|
|
293
|
+
* @returns JSON representation of the exit
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const exit = new Exit({
|
|
298
|
+
* name: 'complete',
|
|
299
|
+
* description: 'Task completed successfully',
|
|
300
|
+
* })
|
|
301
|
+
*
|
|
302
|
+
* console.log(exit.toJSON())
|
|
303
|
+
* // { name: 'complete', aliases: [], description: 'Task completed successfully', metadata: {}, schema: undefined }
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
toJSON(): {
|
|
307
|
+
name: string;
|
|
308
|
+
aliases: string[];
|
|
309
|
+
description: string;
|
|
310
|
+
metadata: {
|
|
311
|
+
[x: string]: unknown;
|
|
312
|
+
};
|
|
313
|
+
schema: JSONSchema7 | undefined;
|
|
314
|
+
};
|
|
281
315
|
/**
|
|
282
316
|
* Creates a new Exit instance.
|
|
283
317
|
*
|
package/dist/index.cjs
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
12
|
-
require('./chunk-
|
|
11
|
+
var _chunkTCRRSS44cjs = require('./chunk-TCRRSS44.cjs');
|
|
12
|
+
require('./chunk-PIDLNYIP.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
var
|
|
15
|
+
var _chunkXGJOEQMWcjs = require('./chunk-XGJOEQMW.cjs');
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkFZJHYLM2cjs = require('./chunk-FZJHYLM2.cjs');
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
26
26
|
require('./chunk-IKSIOIIP.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var
|
|
29
|
+
var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
@@ -35,12 +35,16 @@ var _chunkWL7ZIMYDcjs = require('./chunk-WL7ZIMYD.cjs');
|
|
|
35
35
|
|
|
36
36
|
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
37
37
|
require('./chunk-KMZDFWYZ.cjs');
|
|
38
|
-
require('./chunk-JGVAZO4X.cjs');
|
|
39
38
|
|
|
40
39
|
|
|
40
|
+
var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
44
48
|
|
|
45
49
|
|
|
46
50
|
|
|
@@ -296,7 +300,7 @@ async function hoistTypings(code, formatOptions) {
|
|
|
296
300
|
break;
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
|
-
return
|
|
303
|
+
return _chunkFZJHYLM2cjs.formatTypings.call(void 0, code, formatOptions);
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
// src/objects.ts
|
|
@@ -365,7 +369,7 @@ var ObjectInstance = class {
|
|
|
365
369
|
*/
|
|
366
370
|
constructor(props) {
|
|
367
371
|
var _a;
|
|
368
|
-
if (!
|
|
372
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
369
373
|
throw new Error(
|
|
370
374
|
`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.`
|
|
371
375
|
);
|
|
@@ -398,7 +402,7 @@ var ObjectInstance = class {
|
|
|
398
402
|
if (props.properties.filter((p) => p.name === prop.name).length > 1) {
|
|
399
403
|
throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
|
|
400
404
|
}
|
|
401
|
-
if (!
|
|
405
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, prop.name)) {
|
|
402
406
|
throw new Error(
|
|
403
407
|
`Invalid name for property ${prop.name}. A property name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
404
408
|
);
|
|
@@ -422,7 +426,7 @@ var ObjectInstance = class {
|
|
|
422
426
|
this.description = props.description;
|
|
423
427
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
424
428
|
this.properties = props.properties;
|
|
425
|
-
this.tools =
|
|
429
|
+
this.tools = _chunkXGJOEQMWcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
426
430
|
}
|
|
427
431
|
/**
|
|
428
432
|
* Generates TypeScript namespace declarations for this object.
|
|
@@ -464,6 +468,24 @@ var ObjectInstance = class {
|
|
|
464
468
|
async getTypings() {
|
|
465
469
|
return getObjectTypings(this).withProperties().withTools().build();
|
|
466
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Converts this ObjectInstance to its JSON representation.
|
|
473
|
+
*
|
|
474
|
+
* This method serializes the object into a JSON format that includes its name,
|
|
475
|
+
* description, properties, tools, and metadata. It is used for serialization
|
|
476
|
+
* and transmission of the object state.
|
|
477
|
+
*
|
|
478
|
+
* @returns JSON representation of the ObjectInstance
|
|
479
|
+
*/
|
|
480
|
+
toJSON() {
|
|
481
|
+
return {
|
|
482
|
+
name: this.name,
|
|
483
|
+
description: this.description,
|
|
484
|
+
properties: this.properties,
|
|
485
|
+
tools: (_nullishCoalesce(this.tools, () => ( []))).map((tool) => tool.toJSON()),
|
|
486
|
+
metadata: this.metadata
|
|
487
|
+
};
|
|
488
|
+
}
|
|
467
489
|
};
|
|
468
490
|
function getObjectTypings(obj) {
|
|
469
491
|
let includeProperties = false;
|
|
@@ -481,11 +503,11 @@ function getObjectTypings(obj) {
|
|
|
481
503
|
for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
|
|
482
504
|
const description = _nullishCoalesce(prop.description, () => ( ""));
|
|
483
505
|
if (description == null ? void 0 : description.trim().length) {
|
|
484
|
-
typings.push(
|
|
506
|
+
typings.push(_chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, description));
|
|
485
507
|
}
|
|
486
508
|
let type = "unknown";
|
|
487
509
|
if (prop.type) {
|
|
488
|
-
type = await
|
|
510
|
+
type = await _chunkFZJHYLM2cjs.getTypings.call(void 0, prop.type, {});
|
|
489
511
|
} else if (prop.value !== void 0) {
|
|
490
512
|
type = typeof prop.value;
|
|
491
513
|
}
|
|
@@ -505,7 +527,7 @@ function getObjectTypings(obj) {
|
|
|
505
527
|
typings.push("");
|
|
506
528
|
for (const tool of obj.tools) {
|
|
507
529
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
508
|
-
let temp = await
|
|
530
|
+
let temp = await _chunkFZJHYLM2cjs.getTypings.call(void 0, fnType, {
|
|
509
531
|
declaration: true
|
|
510
532
|
});
|
|
511
533
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -526,9 +548,9 @@ function getObjectTypings(obj) {
|
|
|
526
548
|
typings.push("}" + closingBracket);
|
|
527
549
|
let header = "";
|
|
528
550
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
529
|
-
header =
|
|
551
|
+
header = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, obj.description);
|
|
530
552
|
}
|
|
531
|
-
return
|
|
553
|
+
return _chunkFZJHYLM2cjs.formatTypings.call(void 0,
|
|
532
554
|
`${header}
|
|
533
555
|
export namespace ${obj.name} {
|
|
534
556
|
${body}
|
|
@@ -559,7 +581,7 @@ function getObjectTypings(obj) {
|
|
|
559
581
|
}
|
|
560
582
|
function embedPropertyValue(property) {
|
|
561
583
|
if (typeof property.value === "string") {
|
|
562
|
-
return
|
|
584
|
+
return _chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value);
|
|
563
585
|
}
|
|
564
586
|
if (Number.isNaN(property.value)) {
|
|
565
587
|
return "NaN";
|
|
@@ -577,7 +599,7 @@ function embedPropertyValue(property) {
|
|
|
577
599
|
return `new Date('${property.value.toISOString()}')`;
|
|
578
600
|
}
|
|
579
601
|
if (property.value instanceof RegExp) {
|
|
580
|
-
return `new RegExp(${
|
|
602
|
+
return `new RegExp(${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.source)}, ${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.flags)})`;
|
|
581
603
|
}
|
|
582
604
|
if (property.value === null) {
|
|
583
605
|
return "null";
|
|
@@ -595,7 +617,7 @@ function embedPropertyValue(property) {
|
|
|
595
617
|
return `${property.value}n`;
|
|
596
618
|
}
|
|
597
619
|
if (property.value instanceof Error) {
|
|
598
|
-
return `Error(${
|
|
620
|
+
return `Error(${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.message)})`;
|
|
599
621
|
}
|
|
600
622
|
if (property.value instanceof Map) {
|
|
601
623
|
return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
|
|
@@ -1073,21 +1095,26 @@ var Chat = class {
|
|
|
1073
1095
|
};
|
|
1074
1096
|
|
|
1075
1097
|
// src/index.ts
|
|
1098
|
+
var utils = {
|
|
1099
|
+
toValidObjectName: _chunkWHNOR4ZUcjs.toValidObjectName,
|
|
1100
|
+
toValidFunctionName: _chunkWHNOR4ZUcjs.toValidFunctionName,
|
|
1101
|
+
wrapContent: _chunkGZPN7RGHcjs.wrapContent
|
|
1102
|
+
};
|
|
1076
1103
|
var execute = async (props) => {
|
|
1077
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1104
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-WVNKAMCP.cjs")));
|
|
1078
1105
|
return executeContext(props);
|
|
1079
1106
|
};
|
|
1080
1107
|
var init = async () => {
|
|
1081
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1108
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-WVNKAMCP.cjs")));
|
|
1082
1109
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
1083
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
1084
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-
|
|
1110
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-O4SFRIE4.cjs")));
|
|
1111
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
|
|
1085
1112
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
1086
1113
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-2DLG7V4G.cjs")));
|
|
1087
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-
|
|
1088
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-
|
|
1089
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
1090
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
1114
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-L5QAQXV2.cjs")));
|
|
1115
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-W3NXBLYJ.cjs")));
|
|
1116
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-Y45GMPZT.cjs")));
|
|
1117
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-OFHV2C3X.cjs")));
|
|
1091
1118
|
};
|
|
1092
1119
|
|
|
1093
1120
|
|
|
@@ -1115,4 +1142,5 @@ var init = async () => {
|
|
|
1115
1142
|
|
|
1116
1143
|
|
|
1117
1144
|
|
|
1118
|
-
|
|
1145
|
+
|
|
1146
|
+
exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkTCRRSS44cjs.DefaultExit; exports.ErrorExecutionResult = _chunkTCRRSS44cjs.ErrorExecutionResult; exports.ExecutionResult = _chunkTCRRSS44cjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkTCRRSS44cjs.ListenExit; exports.LoopExceededError = _chunkJDABP4SDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkTCRRSS44cjs.PartialExecutionResult; exports.Snapshot = _chunkTCRRSS44cjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkTCRRSS44cjs.SuccessExecutionResult; exports.ThinkExit = _chunkTCRRSS44cjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunkXGJOEQMWcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkTCRRSS44cjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,11 +9,19 @@ export { Snapshot } from './snapshots.js';
|
|
|
9
9
|
export { Chat, type MessageHandler } from './chat.js';
|
|
10
10
|
import { type ExecutionProps } from './llmz.js';
|
|
11
11
|
import { ExecutionResult } from './result.js';
|
|
12
|
+
import { wrapContent } from './truncator.js';
|
|
12
13
|
export { Transcript } from './transcript.js';
|
|
13
14
|
export { ErrorExecutionResult, ExecutionResult, PartialExecutionResult, SuccessExecutionResult } from './result.js';
|
|
14
|
-
export { Trace } from './types.js';
|
|
15
|
+
export { type Trace, type Traces } from './types.js';
|
|
15
16
|
export { type Iteration, ListenExit, ThinkExit, DefaultExit, IterationStatuses, IterationStatus } from './context.js';
|
|
17
|
+
export { type Context } from './context.js';
|
|
18
|
+
export type { LLMzPrompts } from './prompts/prompt.js';
|
|
16
19
|
export { type ValueOrGetter, getValue } from './getter.js';
|
|
20
|
+
export declare const utils: {
|
|
21
|
+
toValidObjectName: (str: string) => string;
|
|
22
|
+
toValidFunctionName: (str: string) => string;
|
|
23
|
+
wrapContent: typeof wrapContent;
|
|
24
|
+
};
|
|
17
25
|
/**
|
|
18
26
|
* Executes an LLMz agent in either Chat Mode or Worker Mode.
|
|
19
27
|
*
|
package/dist/index.js
CHANGED
|
@@ -8,15 +8,15 @@ import {
|
|
|
8
8
|
SuccessExecutionResult,
|
|
9
9
|
ThinkExit,
|
|
10
10
|
getValue
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import "./chunk-
|
|
11
|
+
} from "./chunk-RBRTK37G.js";
|
|
12
|
+
import "./chunk-2D2DE7CD.js";
|
|
13
13
|
import {
|
|
14
14
|
Tool
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-A7QHWVD7.js";
|
|
16
16
|
import {
|
|
17
17
|
formatTypings,
|
|
18
18
|
getTypings
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EE6NVDID.js";
|
|
20
20
|
import {
|
|
21
21
|
CodeFormattingError,
|
|
22
22
|
LoopExceededError,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import "./chunk-JQBT7UWN.js";
|
|
27
27
|
import {
|
|
28
28
|
Exit
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-VPTFUOIK.js";
|
|
30
30
|
import {
|
|
31
31
|
Component,
|
|
32
32
|
assertValidComponent,
|
|
@@ -35,12 +35,16 @@ import {
|
|
|
35
35
|
renderToTsx
|
|
36
36
|
} from "./chunk-GGWM6X2K.js";
|
|
37
37
|
import "./chunk-ORQP26SZ.js";
|
|
38
|
-
import
|
|
38
|
+
import {
|
|
39
|
+
wrapContent
|
|
40
|
+
} from "./chunk-3JYCCI4S.js";
|
|
39
41
|
import {
|
|
40
42
|
escapeString,
|
|
41
43
|
getMultilineComment,
|
|
42
|
-
isValidIdentifier
|
|
43
|
-
|
|
44
|
+
isValidIdentifier,
|
|
45
|
+
toValidFunctionName,
|
|
46
|
+
toValidObjectName
|
|
47
|
+
} from "./chunk-ZORRILUV.js";
|
|
44
48
|
import {
|
|
45
49
|
cloneDeep_default,
|
|
46
50
|
upperFirst_default
|
|
@@ -464,6 +468,24 @@ var ObjectInstance = class {
|
|
|
464
468
|
async getTypings() {
|
|
465
469
|
return getObjectTypings(this).withProperties().withTools().build();
|
|
466
470
|
}
|
|
471
|
+
/**
|
|
472
|
+
* Converts this ObjectInstance to its JSON representation.
|
|
473
|
+
*
|
|
474
|
+
* This method serializes the object into a JSON format that includes its name,
|
|
475
|
+
* description, properties, tools, and metadata. It is used for serialization
|
|
476
|
+
* and transmission of the object state.
|
|
477
|
+
*
|
|
478
|
+
* @returns JSON representation of the ObjectInstance
|
|
479
|
+
*/
|
|
480
|
+
toJSON() {
|
|
481
|
+
return {
|
|
482
|
+
name: this.name,
|
|
483
|
+
description: this.description,
|
|
484
|
+
properties: this.properties,
|
|
485
|
+
tools: (this.tools ?? []).map((tool) => tool.toJSON()),
|
|
486
|
+
metadata: this.metadata
|
|
487
|
+
};
|
|
488
|
+
}
|
|
467
489
|
};
|
|
468
490
|
function getObjectTypings(obj) {
|
|
469
491
|
let includeProperties = false;
|
|
@@ -1073,21 +1095,26 @@ var Chat = class {
|
|
|
1073
1095
|
};
|
|
1074
1096
|
|
|
1075
1097
|
// src/index.ts
|
|
1098
|
+
var utils = {
|
|
1099
|
+
toValidObjectName,
|
|
1100
|
+
toValidFunctionName,
|
|
1101
|
+
wrapContent
|
|
1102
|
+
};
|
|
1076
1103
|
var execute = async (props) => {
|
|
1077
|
-
const { executeContext } = await import("./llmz-
|
|
1104
|
+
const { executeContext } = await import("./llmz-67EZPJ4E.js");
|
|
1078
1105
|
return executeContext(props);
|
|
1079
1106
|
};
|
|
1080
1107
|
var init = async () => {
|
|
1081
|
-
await import("./llmz-
|
|
1108
|
+
await import("./llmz-67EZPJ4E.js");
|
|
1082
1109
|
await import("./component-WFVDVSDK.js");
|
|
1083
|
-
await import("./tool-
|
|
1084
|
-
await import("./exit-
|
|
1110
|
+
await import("./tool-PCOYOCRH.js");
|
|
1111
|
+
await import("./exit-YLO7BY7Z.js");
|
|
1085
1112
|
await import("./jsx-AEHVFB3L.js");
|
|
1086
1113
|
await import("./vm-FLBMZUA2.js");
|
|
1087
|
-
await import("./utils-
|
|
1088
|
-
await import("./truncator-
|
|
1089
|
-
await import("./typings-
|
|
1090
|
-
await import("./dual-modes-
|
|
1114
|
+
await import("./utils-RQHQ2KOG.js");
|
|
1115
|
+
await import("./truncator-BSP6PQPC.js");
|
|
1116
|
+
await import("./typings-WYHEFCYB.js");
|
|
1117
|
+
await import("./dual-modes-7FI4T35O.js");
|
|
1091
1118
|
};
|
|
1092
1119
|
export {
|
|
1093
1120
|
Chat,
|
|
@@ -1114,5 +1141,6 @@ export {
|
|
|
1114
1141
|
init,
|
|
1115
1142
|
isAnyComponent,
|
|
1116
1143
|
isComponent,
|
|
1117
|
-
renderToTsx
|
|
1144
|
+
renderToTsx,
|
|
1145
|
+
utils
|
|
1118
1146
|
};
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
PartialExecutionResult,
|
|
8
8
|
Snapshot,
|
|
9
9
|
SuccessExecutionResult
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-RBRTK37G.js";
|
|
11
|
+
import "./chunk-2D2DE7CD.js";
|
|
12
|
+
import "./chunk-A7QHWVD7.js";
|
|
13
|
+
import "./chunk-EE6NVDID.js";
|
|
14
14
|
import {
|
|
15
15
|
AssignmentError,
|
|
16
16
|
CodeExecutionError,
|
|
@@ -24,16 +24,16 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
cleanStackTrace
|
|
26
26
|
} from "./chunk-JQBT7UWN.js";
|
|
27
|
-
import "./chunk-
|
|
27
|
+
import "./chunk-VPTFUOIK.js";
|
|
28
28
|
import "./chunk-GGWM6X2K.js";
|
|
29
29
|
import "./chunk-ORQP26SZ.js";
|
|
30
30
|
import {
|
|
31
31
|
truncateWrappedContent
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-3JYCCI4S.js";
|
|
33
33
|
import {
|
|
34
34
|
init,
|
|
35
35
|
stripInvalidIdentifiers
|
|
36
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ZORRILUV.js";
|
|
37
37
|
import {
|
|
38
38
|
clamp_default,
|
|
39
39
|
isEqual_default,
|
|
@@ -7,10 +7,10 @@ var _chunkBEPRLBPKcjs = require('./chunk-BEPRLBPK.cjs');
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
require('./chunk-
|
|
12
|
-
require('./chunk-
|
|
13
|
-
require('./chunk-
|
|
10
|
+
var _chunkTCRRSS44cjs = require('./chunk-TCRRSS44.cjs');
|
|
11
|
+
require('./chunk-PIDLNYIP.cjs');
|
|
12
|
+
require('./chunk-XGJOEQMW.cjs');
|
|
13
|
+
require('./chunk-FZJHYLM2.cjs');
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
@@ -24,16 +24,16 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
|
|
27
|
-
require('./chunk-
|
|
27
|
+
require('./chunk-3G3BS5IA.cjs');
|
|
28
28
|
require('./chunk-ZRCU35UV.cjs');
|
|
29
29
|
require('./chunk-KMZDFWYZ.cjs');
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
var
|
|
32
|
+
var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
var
|
|
36
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
|
|
@@ -91,7 +91,7 @@ var getModelOutputLimit = (inputLength) => _chunkUQOBUJIQcjs.clamp_default.call(
|
|
|
91
91
|
);
|
|
92
92
|
var executeContext = async (props) => {
|
|
93
93
|
var _a, _b;
|
|
94
|
-
await
|
|
94
|
+
await _chunkWHNOR4ZUcjs.init.call(void 0, );
|
|
95
95
|
const result = await _executeContext(props);
|
|
96
96
|
try {
|
|
97
97
|
(_b = (_a = result.context.chat) == null ? void 0 : _a.onExecutionDone) == null ? void 0 : _b.call(_a, result);
|
|
@@ -105,7 +105,7 @@ var _executeContext = async (props) => {
|
|
|
105
105
|
const { onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
|
|
106
106
|
const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
|
|
107
107
|
const cleanups = [];
|
|
108
|
-
const ctx = new (0,
|
|
108
|
+
const ctx = new (0, _chunkTCRRSS44cjs.Context)({
|
|
109
109
|
chat: props.chat,
|
|
110
110
|
instructions: props.instructions,
|
|
111
111
|
objects: props.objects,
|
|
@@ -120,7 +120,7 @@ var _executeContext = async (props) => {
|
|
|
120
120
|
try {
|
|
121
121
|
while (true) {
|
|
122
122
|
if (ctx.iterations.length >= ctx.loop) {
|
|
123
|
-
return new (0,
|
|
123
|
+
return new (0, _chunkTCRRSS44cjs.ErrorExecutionResult)(ctx, new (0, _chunkJDABP4SDcjs.LoopExceededError)());
|
|
124
124
|
}
|
|
125
125
|
const iteration = await ctx.nextIteration();
|
|
126
126
|
if (controller.signal.aborted) {
|
|
@@ -130,7 +130,7 @@ var _executeContext = async (props) => {
|
|
|
130
130
|
reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
-
return new (0,
|
|
133
|
+
return new (0, _chunkTCRRSS44cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
|
|
134
134
|
}
|
|
135
135
|
cleanups.push(
|
|
136
136
|
iteration.traces.onPush((traces) => {
|
|
@@ -166,25 +166,25 @@ var _executeContext = async (props) => {
|
|
|
166
166
|
}
|
|
167
167
|
if (iteration.status.type === "exit_success") {
|
|
168
168
|
const exitName = iteration.status.exit_success.exit_name;
|
|
169
|
-
return new (0,
|
|
169
|
+
return new (0, _chunkTCRRSS44cjs.SuccessExecutionResult)(ctx, {
|
|
170
170
|
exit: iteration.exits.find((x) => x.name === exitName),
|
|
171
171
|
result: iteration.status.exit_success.return_value
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
if (iteration.status.type === "callback_requested") {
|
|
175
|
-
return new (0,
|
|
175
|
+
return new (0, _chunkTCRRSS44cjs.PartialExecutionResult)(
|
|
176
176
|
ctx,
|
|
177
177
|
iteration.status.callback_requested.signal,
|
|
178
|
-
|
|
178
|
+
_chunkTCRRSS44cjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
|
|
182
182
|
continue;
|
|
183
183
|
}
|
|
184
|
-
return new (0,
|
|
184
|
+
return new (0, _chunkTCRRSS44cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
|
|
185
185
|
}
|
|
186
186
|
} catch (error) {
|
|
187
|
-
return new (0,
|
|
187
|
+
return new (0, _chunkTCRRSS44cjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
|
|
188
188
|
} finally {
|
|
189
189
|
for (const cleanup of cleanups) {
|
|
190
190
|
try {
|
|
@@ -210,7 +210,7 @@ var executeIteration = async ({
|
|
|
210
210
|
const model = await cognitive.getModelDetails(_nullishCoalesce(ctx.model, () => ( "best")));
|
|
211
211
|
const modelLimit = model.input.maxTokens;
|
|
212
212
|
const responseLengthBuffer = getModelOutputLimit(modelLimit);
|
|
213
|
-
const messages =
|
|
213
|
+
const messages = _chunkGZPN7RGHcjs.truncateWrappedContent.call(void 0, {
|
|
214
214
|
messages: iteration.messages,
|
|
215
215
|
tokenLimit: modelLimit - responseLengthBuffer,
|
|
216
216
|
throwOnFailure: true
|
|
@@ -284,7 +284,7 @@ var executeIteration = async ({
|
|
|
284
284
|
model: model.ref,
|
|
285
285
|
code: iteration.code
|
|
286
286
|
});
|
|
287
|
-
const vmContext = { ...
|
|
287
|
+
const vmContext = { ..._chunkWHNOR4ZUcjs.stripInvalidIdentifiers.call(void 0, iteration.variables) };
|
|
288
288
|
for (const obj of iteration.objects) {
|
|
289
289
|
const internalValues = {};
|
|
290
290
|
const instance = {};
|
package/dist/objects.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from '@bpinternal/zui';
|
|
2
2
|
import { Tool } from './tool.js';
|
|
3
|
+
import { Serializable } from './types.js';
|
|
3
4
|
/**
|
|
4
5
|
* Defines a property within an ObjectInstance.
|
|
5
6
|
*
|
|
@@ -30,6 +31,15 @@ export type ObjectProperty = {
|
|
|
30
31
|
/** Whether the LLM can modify this property (default: false) */
|
|
31
32
|
writable?: boolean;
|
|
32
33
|
};
|
|
34
|
+
export declare namespace ObjectInstance {
|
|
35
|
+
type JSON = {
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
properties?: ObjectProperty[];
|
|
39
|
+
tools?: Tool.JSON[];
|
|
40
|
+
metadata?: Record<string, unknown>;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
33
43
|
/**
|
|
34
44
|
* ObjectInstance creates stateful, namespace-scoped objects for LLMz agents.
|
|
35
45
|
*
|
|
@@ -228,7 +238,7 @@ export type ObjectProperty = {
|
|
|
228
238
|
*
|
|
229
239
|
* @see {@link https://github.com/botpress/botpress/blob/master/packages/llmz/examples/09_chat_variables/index.ts} Example usage
|
|
230
240
|
*/
|
|
231
|
-
export declare class ObjectInstance {
|
|
241
|
+
export declare class ObjectInstance implements Serializable<ObjectInstance.JSON> {
|
|
232
242
|
name: string;
|
|
233
243
|
description?: string;
|
|
234
244
|
properties?: ObjectProperty[];
|
|
@@ -335,4 +345,29 @@ export declare class ObjectInstance {
|
|
|
335
345
|
* ```
|
|
336
346
|
*/
|
|
337
347
|
getTypings(): Promise<string>;
|
|
348
|
+
/**
|
|
349
|
+
* Converts this ObjectInstance to its JSON representation.
|
|
350
|
+
*
|
|
351
|
+
* This method serializes the object into a JSON format that includes its name,
|
|
352
|
+
* description, properties, tools, and metadata. It is used for serialization
|
|
353
|
+
* and transmission of the object state.
|
|
354
|
+
*
|
|
355
|
+
* @returns JSON representation of the ObjectInstance
|
|
356
|
+
*/
|
|
357
|
+
toJSON(): {
|
|
358
|
+
name: string;
|
|
359
|
+
description: string | undefined;
|
|
360
|
+
properties: ObjectProperty[] | undefined;
|
|
361
|
+
tools: {
|
|
362
|
+
name: string;
|
|
363
|
+
aliases: string[];
|
|
364
|
+
description: string | undefined;
|
|
365
|
+
metadata: Record<string, unknown>;
|
|
366
|
+
input: import("json-schema").JSONSchema7 | undefined;
|
|
367
|
+
output: import("json-schema").JSONSchema7 | undefined;
|
|
368
|
+
staticInputValues: unknown;
|
|
369
|
+
maxRetries: number;
|
|
370
|
+
}[];
|
|
371
|
+
metadata: Record<string, unknown> | undefined;
|
|
372
|
+
};
|
|
338
373
|
}
|