llmz 0.0.13 → 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/CLAUDE.md +363 -0
- package/README.md +61 -34
- package/dist/abort-signal.d.ts +40 -0
- package/dist/chat.d.ts +325 -0
- package/dist/{chunk-KH6JQYQA.js → chunk-2D2DE7CD.js} +2 -2
- package/dist/chunk-3G3BS5IA.cjs +256 -0
- package/dist/{chunk-SNDVQU5A.js → chunk-3JYCCI4S.js} +1 -1
- package/dist/chunk-A7QHWVD7.js +493 -0
- 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-PRVFVXT4.js → chunk-RBRTK37G.js} +383 -4
- package/dist/{chunk-HJKOSEH2.cjs → chunk-TCRRSS44.cjs} +397 -18
- package/dist/chunk-VPTFUOIK.js +256 -0
- package/dist/{chunk-276Q6EWP.cjs → chunk-WHNOR4ZU.cjs} +3 -0
- package/dist/chunk-XGJOEQMW.cjs +493 -0
- package/dist/{chunk-4MNIJGK6.js → chunk-ZORRILUV.js} +3 -0
- package/dist/context.d.ts +412 -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-YORW76T3.js → exit-YLO7BY7Z.js} +2 -2
- package/dist/exit.d.ts +369 -2
- package/dist/index.cjs +253 -28
- package/dist/index.d.ts +71 -1
- package/dist/index.js +242 -17
- package/dist/{llmz-ROOX7RYI.js → llmz-67EZPJ4E.js} +113 -39
- package/dist/{llmz-QLZBDG2Z.cjs → llmz-WVNKAMCP.cjs} +123 -49
- package/dist/llmz.d.ts +142 -5
- package/dist/objects.d.ts +350 -1
- package/dist/result.d.ts +809 -6
- package/dist/snapshots.d.ts +181 -1
- package/dist/{tool-QP4MVRWI.cjs → tool-O4SFRIE4.cjs} +4 -4
- package/dist/{tool-N6ODRRGH.js → tool-PCOYOCRH.js} +3 -3
- package/dist/tool.d.ts +470 -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/docs/TODO.md +919 -0
- package/package.json +3 -3
- package/dist/chunk-C6WNNTEV.cjs +0 -212
- package/dist/chunk-GWFYZDUR.cjs +0 -105
- package/dist/chunk-JAGB2AOU.js +0 -212
- package/dist/chunk-JMSZKB4T.js +0 -105
- package/dist/exit-TRXEU4OU.cjs +0 -8
- package/dist/truncator-DUMWEGQO.cjs +0 -10
- package/dist/utils-A7WNEFTA.cjs +0 -39
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 _chunkGWFYZDURcjs = require('./chunk-GWFYZDUR.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
|
|
@@ -307,9 +311,65 @@ var ObjectInstance = class {
|
|
|
307
311
|
|
|
308
312
|
|
|
309
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Creates a new ObjectInstance.
|
|
316
|
+
*
|
|
317
|
+
* @param props - Object configuration
|
|
318
|
+
* @param props.name - Unique object name (must be valid TypeScript identifier)
|
|
319
|
+
* @param props.description - Human-readable description of the object
|
|
320
|
+
* @param props.tools - Array of tools to group under this object namespace
|
|
321
|
+
* @param props.properties - Array of stateful properties for this object
|
|
322
|
+
* @param props.metadata - Additional metadata for the object
|
|
323
|
+
*
|
|
324
|
+
* @throws Error if name is not a valid identifier
|
|
325
|
+
* @throws Error if description is not a string
|
|
326
|
+
* @throws Error if metadata is not an object
|
|
327
|
+
* @throws Error if properties/tools are not arrays
|
|
328
|
+
* @throws Error if properties exceed 100 limit
|
|
329
|
+
* @throws Error if property names are duplicated or invalid
|
|
330
|
+
* @throws Error if property descriptions exceed 5000 characters
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* const userProfile = new ObjectInstance({
|
|
335
|
+
* name: 'user',
|
|
336
|
+
* description: 'User profile management',
|
|
337
|
+
* properties: [
|
|
338
|
+
* {
|
|
339
|
+
* name: 'name',
|
|
340
|
+
* value: 'John Doe',
|
|
341
|
+
* type: z.string().min(1),
|
|
342
|
+
* description: 'User full name',
|
|
343
|
+
* writable: true,
|
|
344
|
+
* },
|
|
345
|
+
* {
|
|
346
|
+
* name: 'email',
|
|
347
|
+
* value: null,
|
|
348
|
+
* type: z.string().email().nullable(),
|
|
349
|
+
* description: 'User email address',
|
|
350
|
+
* writable: true,
|
|
351
|
+
* },
|
|
352
|
+
* ],
|
|
353
|
+
* tools: [
|
|
354
|
+
* new Tool({
|
|
355
|
+
* name: 'updateProfile',
|
|
356
|
+
* input: z.object({ name: z.string(), email: z.string() }),
|
|
357
|
+
* handler: async ({ name, email }) => {
|
|
358
|
+
* // Update external system
|
|
359
|
+
* await updateUserInDatabase({ name, email })
|
|
360
|
+
* },
|
|
361
|
+
* }),
|
|
362
|
+
* ],
|
|
363
|
+
* metadata: {
|
|
364
|
+
* version: '1.0',
|
|
365
|
+
* category: 'user-management',
|
|
366
|
+
* },
|
|
367
|
+
* })
|
|
368
|
+
* ```
|
|
369
|
+
*/
|
|
310
370
|
constructor(props) {
|
|
311
371
|
var _a;
|
|
312
|
-
if (!
|
|
372
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
313
373
|
throw new Error(
|
|
314
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.`
|
|
315
375
|
);
|
|
@@ -342,7 +402,7 @@ var ObjectInstance = class {
|
|
|
342
402
|
if (props.properties.filter((p) => p.name === prop.name).length > 1) {
|
|
343
403
|
throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
|
|
344
404
|
}
|
|
345
|
-
if (!
|
|
405
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, prop.name)) {
|
|
346
406
|
throw new Error(
|
|
347
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.`
|
|
348
408
|
);
|
|
@@ -366,11 +426,66 @@ var ObjectInstance = class {
|
|
|
366
426
|
this.description = props.description;
|
|
367
427
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
368
428
|
this.properties = props.properties;
|
|
369
|
-
this.tools =
|
|
429
|
+
this.tools = _chunkXGJOEQMWcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
370
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Generates TypeScript namespace declarations for this object.
|
|
433
|
+
*
|
|
434
|
+
* This method creates TypeScript definitions that are included in the LLM context
|
|
435
|
+
* to help it understand the available properties and tools. Properties become
|
|
436
|
+
* const declarations with appropriate Readonly/Writable types, and tools become
|
|
437
|
+
* function signatures.
|
|
438
|
+
*
|
|
439
|
+
* @returns Promise resolving to TypeScript namespace declaration
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const obj = new ObjectInstance({
|
|
444
|
+
* name: 'user',
|
|
445
|
+
* properties: [
|
|
446
|
+
* { name: 'name', value: 'John', writable: true },
|
|
447
|
+
* { name: 'id', value: 123, writable: false },
|
|
448
|
+
* ],
|
|
449
|
+
* tools: [
|
|
450
|
+
* new Tool({
|
|
451
|
+
* name: 'save',
|
|
452
|
+
* input: z.object({ data: z.string() }),
|
|
453
|
+
* handler: async ({ data }) => { /* ... *\/ },
|
|
454
|
+
* }),
|
|
455
|
+
* ],
|
|
456
|
+
* })
|
|
457
|
+
*
|
|
458
|
+
* const typings = await obj.getTypings()
|
|
459
|
+
* console.log(typings)
|
|
460
|
+
* // Output:
|
|
461
|
+
* // export namespace user {
|
|
462
|
+
* // const name: Writable<string> = "John"
|
|
463
|
+
* // const id: Readonly<number> = 123
|
|
464
|
+
* // function save(args: { data: string }): Promise<void>
|
|
465
|
+
* // }
|
|
466
|
+
* ```
|
|
467
|
+
*/
|
|
371
468
|
async getTypings() {
|
|
372
469
|
return getObjectTypings(this).withProperties().withTools().build();
|
|
373
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
|
+
}
|
|
374
489
|
};
|
|
375
490
|
function getObjectTypings(obj) {
|
|
376
491
|
let includeProperties = false;
|
|
@@ -388,11 +503,11 @@ function getObjectTypings(obj) {
|
|
|
388
503
|
for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
|
|
389
504
|
const description = _nullishCoalesce(prop.description, () => ( ""));
|
|
390
505
|
if (description == null ? void 0 : description.trim().length) {
|
|
391
|
-
typings.push(
|
|
506
|
+
typings.push(_chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, description));
|
|
392
507
|
}
|
|
393
508
|
let type = "unknown";
|
|
394
509
|
if (prop.type) {
|
|
395
|
-
type = await
|
|
510
|
+
type = await _chunkFZJHYLM2cjs.getTypings.call(void 0, prop.type, {});
|
|
396
511
|
} else if (prop.value !== void 0) {
|
|
397
512
|
type = typeof prop.value;
|
|
398
513
|
}
|
|
@@ -412,7 +527,7 @@ function getObjectTypings(obj) {
|
|
|
412
527
|
typings.push("");
|
|
413
528
|
for (const tool of obj.tools) {
|
|
414
529
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
415
|
-
let temp = await
|
|
530
|
+
let temp = await _chunkFZJHYLM2cjs.getTypings.call(void 0, fnType, {
|
|
416
531
|
declaration: true
|
|
417
532
|
});
|
|
418
533
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -433,9 +548,9 @@ function getObjectTypings(obj) {
|
|
|
433
548
|
typings.push("}" + closingBracket);
|
|
434
549
|
let header = "";
|
|
435
550
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
436
|
-
header =
|
|
551
|
+
header = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, obj.description);
|
|
437
552
|
}
|
|
438
|
-
return
|
|
553
|
+
return _chunkFZJHYLM2cjs.formatTypings.call(void 0,
|
|
439
554
|
`${header}
|
|
440
555
|
export namespace ${obj.name} {
|
|
441
556
|
${body}
|
|
@@ -466,7 +581,7 @@ function getObjectTypings(obj) {
|
|
|
466
581
|
}
|
|
467
582
|
function embedPropertyValue(property) {
|
|
468
583
|
if (typeof property.value === "string") {
|
|
469
|
-
return
|
|
584
|
+
return _chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value);
|
|
470
585
|
}
|
|
471
586
|
if (Number.isNaN(property.value)) {
|
|
472
587
|
return "NaN";
|
|
@@ -484,7 +599,7 @@ function embedPropertyValue(property) {
|
|
|
484
599
|
return `new Date('${property.value.toISOString()}')`;
|
|
485
600
|
}
|
|
486
601
|
if (property.value instanceof RegExp) {
|
|
487
|
-
return `new RegExp(${
|
|
602
|
+
return `new RegExp(${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.source)}, ${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.flags)})`;
|
|
488
603
|
}
|
|
489
604
|
if (property.value === null) {
|
|
490
605
|
return "null";
|
|
@@ -502,7 +617,7 @@ function embedPropertyValue(property) {
|
|
|
502
617
|
return `${property.value}n`;
|
|
503
618
|
}
|
|
504
619
|
if (property.value instanceof Error) {
|
|
505
|
-
return `Error(${
|
|
620
|
+
return `Error(${_chunkWHNOR4ZUcjs.escapeString.call(void 0, property.value.message)})`;
|
|
506
621
|
}
|
|
507
622
|
if (property.value instanceof Map) {
|
|
508
623
|
return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
|
|
@@ -866,31 +981,140 @@ var Chat = class {
|
|
|
866
981
|
|
|
867
982
|
|
|
868
983
|
|
|
984
|
+
/**
|
|
985
|
+
* Creates a new Chat instance.
|
|
986
|
+
*
|
|
987
|
+
* @param props - Chat configuration
|
|
988
|
+
* @param props.handler - Function to handle agent messages (called for every agent output)
|
|
989
|
+
* @param props.components - Available UI components (static array or dynamic function)
|
|
990
|
+
* @param props.transcript - Conversation history (static array or dynamic function, defaults to empty)
|
|
991
|
+
*
|
|
992
|
+
* @example
|
|
993
|
+
* ```typescript
|
|
994
|
+
* // Basic chat with static configuration
|
|
995
|
+
* const chat = new Chat({
|
|
996
|
+
* handler: async (input) => {
|
|
997
|
+
* if (isComponent(input, DefaultComponents.Text)) {
|
|
998
|
+
* console.log('Agent:', input.children.join(''))
|
|
999
|
+
* }
|
|
1000
|
+
* },
|
|
1001
|
+
* components: [DefaultComponents.Text, DefaultComponents.Button],
|
|
1002
|
+
* transcript: [
|
|
1003
|
+
* { role: 'user', content: 'Hello', timestamp: Date.now() }
|
|
1004
|
+
* ],
|
|
1005
|
+
* })
|
|
1006
|
+
* ```
|
|
1007
|
+
*
|
|
1008
|
+
* @example
|
|
1009
|
+
* ```typescript
|
|
1010
|
+
* // Dynamic chat with functions for real-time updates
|
|
1011
|
+
* class MyChat extends Chat {
|
|
1012
|
+
* private messages: Transcript.Message[] = []
|
|
1013
|
+
*
|
|
1014
|
+
* constructor() {
|
|
1015
|
+
* super({
|
|
1016
|
+
* handler: (input) => this.handleMessage(input),
|
|
1017
|
+
*
|
|
1018
|
+
* // Dynamic components - can change during execution
|
|
1019
|
+
* components: () => [
|
|
1020
|
+
* DefaultComponents.Text,
|
|
1021
|
+
* DefaultComponents.Button,
|
|
1022
|
+
* ...this.getCustomComponents()
|
|
1023
|
+
* ],
|
|
1024
|
+
*
|
|
1025
|
+
* // Dynamic transcript - always reflects current state
|
|
1026
|
+
* transcript: () => this.messages,
|
|
1027
|
+
* })
|
|
1028
|
+
* }
|
|
1029
|
+
* }
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
869
1032
|
constructor(props) {
|
|
870
1033
|
this.handler = props.handler;
|
|
871
1034
|
this.components = props.components;
|
|
872
1035
|
this.transcript = props.transcript || [];
|
|
873
1036
|
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Called when an execution cycle completes, regardless of the outcome.
|
|
1039
|
+
*
|
|
1040
|
+
* Override this method to handle execution results, manage conversation flow,
|
|
1041
|
+
* or perform cleanup tasks. This is called after each `execute()` call completes,
|
|
1042
|
+
* whether it succeeds, fails, or is interrupted.
|
|
1043
|
+
*
|
|
1044
|
+
* @param result - The execution result containing status, iterations, and exit information
|
|
1045
|
+
*
|
|
1046
|
+
* @example
|
|
1047
|
+
* ```typescript
|
|
1048
|
+
* class MyChat extends Chat {
|
|
1049
|
+
* public result?: ExecutionResult
|
|
1050
|
+
*
|
|
1051
|
+
* onExecutionDone(result: ExecutionResult) {
|
|
1052
|
+
* // Store result for conversation flow control
|
|
1053
|
+
* this.result = result
|
|
1054
|
+
*
|
|
1055
|
+
* // Handle different result types
|
|
1056
|
+
* if (result.isSuccess()) {
|
|
1057
|
+
* console.log('✅ Execution completed successfully')
|
|
1058
|
+
* console.log('Exit:', result.output.exit_name)
|
|
1059
|
+
* } else if (result.isError()) {
|
|
1060
|
+
* console.error('❌ Execution failed:', result.output.error)
|
|
1061
|
+
* } else if (result.isInterrupted()) {
|
|
1062
|
+
* console.log('⏸️ Execution interrupted (partial result)')
|
|
1063
|
+
* }
|
|
1064
|
+
* }
|
|
1065
|
+
*
|
|
1066
|
+
* // Use stored result for conversation flow
|
|
1067
|
+
* isWaitingForInput(): boolean {
|
|
1068
|
+
* return this.result?.is(ListenExit) ?? false
|
|
1069
|
+
* }
|
|
1070
|
+
* }
|
|
1071
|
+
* ```
|
|
1072
|
+
*
|
|
1073
|
+
* @example
|
|
1074
|
+
* ```typescript
|
|
1075
|
+
* // CLIChat implementation example
|
|
1076
|
+
* class CLIChat extends Chat {
|
|
1077
|
+
* public status?: IterationStatus
|
|
1078
|
+
* public result?: ExecutionResult
|
|
1079
|
+
*
|
|
1080
|
+
* onExecutionDone(result: ExecutionResult) {
|
|
1081
|
+
* this.result = result
|
|
1082
|
+
* this.status = result.iterations.at(-1)?.status
|
|
1083
|
+
* }
|
|
1084
|
+
*
|
|
1085
|
+
* // Check if agent exited with specific exit type
|
|
1086
|
+
* hasExitedWith<R>(exit: Exit<R>): boolean {
|
|
1087
|
+
* return this.status?.type === 'exit_success' &&
|
|
1088
|
+
* this.status.exit_success.exit_name === exit.name
|
|
1089
|
+
* }
|
|
1090
|
+
* }
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
874
1093
|
onExecutionDone(_result) {
|
|
875
1094
|
}
|
|
876
1095
|
};
|
|
877
1096
|
|
|
878
1097
|
// src/index.ts
|
|
1098
|
+
var utils = {
|
|
1099
|
+
toValidObjectName: _chunkWHNOR4ZUcjs.toValidObjectName,
|
|
1100
|
+
toValidFunctionName: _chunkWHNOR4ZUcjs.toValidFunctionName,
|
|
1101
|
+
wrapContent: _chunkGZPN7RGHcjs.wrapContent
|
|
1102
|
+
};
|
|
879
1103
|
var execute = async (props) => {
|
|
880
|
-
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1104
|
+
const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-WVNKAMCP.cjs")));
|
|
881
1105
|
return executeContext(props);
|
|
882
1106
|
};
|
|
883
1107
|
var init = async () => {
|
|
884
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
1108
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-WVNKAMCP.cjs")));
|
|
885
1109
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
|
|
886
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
887
|
-
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")));
|
|
888
1112
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
889
1113
|
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-2DLG7V4G.cjs")));
|
|
890
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-
|
|
891
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-
|
|
892
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
893
|
-
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")));
|
|
894
1118
|
};
|
|
895
1119
|
|
|
896
1120
|
|
|
@@ -918,4 +1142,5 @@ var init = async () => {
|
|
|
918
1142
|
|
|
919
1143
|
|
|
920
1144
|
|
|
921
|
-
|
|
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,81 @@ 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
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Executes an LLMz agent in either Chat Mode or Worker Mode.
|
|
27
|
+
*
|
|
28
|
+
* LLMz is a code-first AI agent framework that generates and runs TypeScript code
|
|
29
|
+
* in a sandbox rather than using traditional JSON tool calling. This enables complex
|
|
30
|
+
* logic, multi-tool orchestration, and native LLM thinking via comments and code structure.
|
|
31
|
+
*
|
|
32
|
+
* @param props - Configuration object for the execution
|
|
33
|
+
* @param props.client - Botpress Client or Cognitive Client instance for LLM generation
|
|
34
|
+
* @param props.instructions - System prompt/instructions for the LLM (static string or dynamic function)
|
|
35
|
+
* @param props.chat - Optional Chat instance to enable Chat Mode with user interaction
|
|
36
|
+
* @param props.tools - Array of Tool instances available to the agent (static or dynamic)
|
|
37
|
+
* @param props.objects - Array of ObjectInstance for namespaced tools and variables (static or dynamic)
|
|
38
|
+
* @param props.exits - Array of Exit definitions for structured completion (static or dynamic)
|
|
39
|
+
* @param props.snapshot - Optional Snapshot to resume paused execution
|
|
40
|
+
* @param props.signal - Optional AbortSignal to cancel execution
|
|
41
|
+
* @param props.options - Optional execution options (loop limit, temperature, model, timeout)
|
|
42
|
+
* @param props.onTrace - Optional non-blocking hook for monitoring traces during execution
|
|
43
|
+
* @param props.onIterationEnd - Optional blocking hook called after each iteration
|
|
44
|
+
* @param props.onExit - Optional blocking hook called when an exit is reached (can prevent exit)
|
|
45
|
+
* @param props.onBeforeExecution - Optional blocking hook to modify code before VM execution
|
|
46
|
+
* @param props.onBeforeTool - Optional blocking hook to modify tool inputs before execution
|
|
47
|
+
* @param props.onAfterTool - Optional blocking hook to modify tool outputs after execution
|
|
48
|
+
*
|
|
49
|
+
* @returns Promise<ExecutionResult> - Result containing success/error/interrupted status with type-safe exit checking
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // Worker Mode - Automated execution
|
|
53
|
+
* const result = await execute({
|
|
54
|
+
* client: cognitiveClient,
|
|
55
|
+
* instructions: 'Calculate the sum of numbers 1 to 100',
|
|
56
|
+
* exits: [myExit]
|
|
57
|
+
* })
|
|
58
|
+
*
|
|
59
|
+
* if (result.is(myExit)) {
|
|
60
|
+
* console.log('Result:', result.output)
|
|
61
|
+
* }
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Chat Mode - Interactive conversation
|
|
65
|
+
* const result = await execute({
|
|
66
|
+
* client: cognitiveClient,
|
|
67
|
+
* instructions: 'You are a helpful assistant',
|
|
68
|
+
* chat: myChatInstance,
|
|
69
|
+
* tools: [searchTool, calculatorTool]
|
|
70
|
+
* })
|
|
71
|
+
*
|
|
72
|
+
* if (result.is(ListenExit)) {
|
|
73
|
+
* // Agent is waiting for user input
|
|
74
|
+
* }
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* // With dynamic instructions and hooks
|
|
78
|
+
* const result = await execute({
|
|
79
|
+
* client: cognitiveClient,
|
|
80
|
+
* instructions: (ctx) => `Process ${ctx.variables.dataCount} records`,
|
|
81
|
+
* tools: async (ctx) => await getContextualTools(ctx),
|
|
82
|
+
* options: { loop: 10, temperature: 0.1 },
|
|
83
|
+
* onTrace: ({ trace, iteration }) => console.log(trace),
|
|
84
|
+
* onExit: async (result) => await validateResult(result)
|
|
85
|
+
* })
|
|
86
|
+
*/
|
|
17
87
|
export declare const execute: (props: ExecutionProps) => Promise<ExecutionResult>;
|
|
18
88
|
/**
|
|
19
89
|
* Loads the necessary dependencies for the library to work
|