llmz 0.0.14 → 0.0.16
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-GOJY4GRL.cjs → chunk-2NU62OI4.cjs} +98 -19
- 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-QIZBF7A5.js} +84 -5
- 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/errors.d.ts +2 -2
- 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-TR4CQK4F.cjs → llmz-EUESEPB7.cjs} +18 -18
- package/dist/{llmz-MCHRHRTD.js → llmz-T4DEP7OD.js} +7 -7
- package/dist/objects.d.ts +36 -1
- package/dist/prompts/chat-mode/system.md.d.ts +1 -1
- package/dist/prompts/chat-mode/user.md.d.ts +1 -1
- package/dist/prompts/worker-mode/system.md.d.ts +1 -1
- package/dist/prompts/worker-mode/user.md.d.ts +1 -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/context.d.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { ObjectInstance } from './objects.js';
|
|
|
9
9
|
import { LLMzPrompts, Prompt } from './prompts/prompt.js';
|
|
10
10
|
import { Snapshot } from './snapshots.js';
|
|
11
11
|
import { Tool } from './tool.js';
|
|
12
|
-
import { TranscriptArray } from './transcript.js';
|
|
13
|
-
import { ObjectMutation, Trace } from './types.js';
|
|
12
|
+
import { Transcript, TranscriptArray } from './transcript.js';
|
|
13
|
+
import { ObjectMutation, Serializable, Trace } from './types.js';
|
|
14
14
|
type Model = Parameters<InstanceType<typeof Cognitive>['generateContent']>[0]['model'];
|
|
15
15
|
export type IterationParameters = {
|
|
16
16
|
transcript: TranscriptArray;
|
|
@@ -300,7 +300,38 @@ export declare const DefaultExit: Exit<{
|
|
|
300
300
|
error: string;
|
|
301
301
|
success: false;
|
|
302
302
|
}>;
|
|
303
|
-
export declare
|
|
303
|
+
export declare namespace Iteration {
|
|
304
|
+
type JSON = {
|
|
305
|
+
id: string;
|
|
306
|
+
messages: LLMzPrompts.Message[];
|
|
307
|
+
code?: string;
|
|
308
|
+
traces: Trace[];
|
|
309
|
+
variables: Record<string, any>;
|
|
310
|
+
started_ts: number;
|
|
311
|
+
ended_ts?: number;
|
|
312
|
+
status: IterationStatus;
|
|
313
|
+
mutations: ObjectMutation[];
|
|
314
|
+
llm?: {
|
|
315
|
+
started_at: number;
|
|
316
|
+
ended_at: number;
|
|
317
|
+
status: 'success' | 'error';
|
|
318
|
+
cached: boolean;
|
|
319
|
+
tokens: number;
|
|
320
|
+
spend: number;
|
|
321
|
+
output: string;
|
|
322
|
+
model: string;
|
|
323
|
+
};
|
|
324
|
+
transcript: Transcript.Message[];
|
|
325
|
+
tools: Tool.JSON[];
|
|
326
|
+
objects: ObjectInstance.JSON[];
|
|
327
|
+
exits: Exit.JSON[];
|
|
328
|
+
instructions?: string;
|
|
329
|
+
duration?: string;
|
|
330
|
+
error?: string | null;
|
|
331
|
+
isChatEnabled?: boolean;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
export declare class Iteration implements Serializable<Iteration.JSON> {
|
|
304
335
|
id: string;
|
|
305
336
|
messages: LLMzPrompts.Message[];
|
|
306
337
|
code?: string;
|
|
@@ -350,8 +381,82 @@ export declare class Iteration {
|
|
|
350
381
|
variables: Record<string, any>;
|
|
351
382
|
});
|
|
352
383
|
end(status: IterationStatus): void;
|
|
384
|
+
toJSON(): {
|
|
385
|
+
id: string;
|
|
386
|
+
messages: LLMzPrompts.Message[];
|
|
387
|
+
code: string | undefined;
|
|
388
|
+
traces: import("./types.js").Traces.Trace[];
|
|
389
|
+
variables: Record<string, any>;
|
|
390
|
+
started_ts: number;
|
|
391
|
+
ended_ts: number | undefined;
|
|
392
|
+
status: IterationStatus;
|
|
393
|
+
mutations: ObjectMutation[];
|
|
394
|
+
llm: {
|
|
395
|
+
started_at: number;
|
|
396
|
+
ended_at: number;
|
|
397
|
+
status: "success" | "error";
|
|
398
|
+
cached: boolean;
|
|
399
|
+
tokens: number;
|
|
400
|
+
spend: number;
|
|
401
|
+
output: string;
|
|
402
|
+
model: string;
|
|
403
|
+
} | undefined;
|
|
404
|
+
transcript: Transcript.Message[];
|
|
405
|
+
tools: {
|
|
406
|
+
name: string;
|
|
407
|
+
aliases: string[];
|
|
408
|
+
description: string | undefined;
|
|
409
|
+
metadata: Record<string, unknown>;
|
|
410
|
+
input: import("json-schema").JSONSchema7 | undefined;
|
|
411
|
+
output: import("json-schema").JSONSchema7 | undefined;
|
|
412
|
+
staticInputValues: unknown;
|
|
413
|
+
maxRetries: number;
|
|
414
|
+
}[];
|
|
415
|
+
objects: {
|
|
416
|
+
name: string;
|
|
417
|
+
description: string | undefined;
|
|
418
|
+
properties: import("./objects.js").ObjectProperty[] | undefined;
|
|
419
|
+
tools: {
|
|
420
|
+
name: string;
|
|
421
|
+
aliases: string[];
|
|
422
|
+
description: string | undefined;
|
|
423
|
+
metadata: Record<string, unknown>;
|
|
424
|
+
input: import("json-schema").JSONSchema7 | undefined;
|
|
425
|
+
output: import("json-schema").JSONSchema7 | undefined;
|
|
426
|
+
staticInputValues: unknown;
|
|
427
|
+
maxRetries: number;
|
|
428
|
+
}[];
|
|
429
|
+
metadata: Record<string, unknown> | undefined;
|
|
430
|
+
}[];
|
|
431
|
+
exits: {
|
|
432
|
+
name: string;
|
|
433
|
+
aliases: string[];
|
|
434
|
+
description: string;
|
|
435
|
+
metadata: {
|
|
436
|
+
[x: string]: unknown;
|
|
437
|
+
};
|
|
438
|
+
schema: import("json-schema").JSONSchema7 | undefined;
|
|
439
|
+
}[];
|
|
440
|
+
instructions: string | undefined;
|
|
441
|
+
duration: string;
|
|
442
|
+
error: string | null;
|
|
443
|
+
isChatEnabled: boolean;
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
export declare namespace Context {
|
|
447
|
+
type JSON = {
|
|
448
|
+
id: string;
|
|
449
|
+
iterations: Iteration.JSON[];
|
|
450
|
+
iteration: number;
|
|
451
|
+
timeout: number;
|
|
452
|
+
loop: number;
|
|
453
|
+
temperature: number;
|
|
454
|
+
model?: Model;
|
|
455
|
+
metadata: Record<string, any>;
|
|
456
|
+
snapshot?: Snapshot.JSON;
|
|
457
|
+
};
|
|
353
458
|
}
|
|
354
|
-
export declare class Context {
|
|
459
|
+
export declare class Context implements Serializable<Context.JSON> {
|
|
355
460
|
id: string;
|
|
356
461
|
chat?: Chat;
|
|
357
462
|
instructions?: ValueOrGetter<string, Context>;
|
|
@@ -384,5 +489,96 @@ export declare class Context {
|
|
|
384
489
|
snapshot?: Snapshot;
|
|
385
490
|
timeout?: number;
|
|
386
491
|
});
|
|
492
|
+
toJSON(): {
|
|
493
|
+
id: string;
|
|
494
|
+
iterations: {
|
|
495
|
+
id: string;
|
|
496
|
+
messages: LLMzPrompts.Message[];
|
|
497
|
+
code: string | undefined;
|
|
498
|
+
traces: import("./types.js").Traces.Trace[];
|
|
499
|
+
variables: Record<string, any>;
|
|
500
|
+
started_ts: number;
|
|
501
|
+
ended_ts: number | undefined;
|
|
502
|
+
status: IterationStatus;
|
|
503
|
+
mutations: ObjectMutation[];
|
|
504
|
+
llm: {
|
|
505
|
+
started_at: number;
|
|
506
|
+
ended_at: number;
|
|
507
|
+
status: "success" | "error";
|
|
508
|
+
cached: boolean;
|
|
509
|
+
tokens: number;
|
|
510
|
+
spend: number;
|
|
511
|
+
output: string;
|
|
512
|
+
model: string;
|
|
513
|
+
} | undefined;
|
|
514
|
+
transcript: Transcript.Message[];
|
|
515
|
+
tools: {
|
|
516
|
+
name: string;
|
|
517
|
+
aliases: string[];
|
|
518
|
+
description: string | undefined;
|
|
519
|
+
metadata: Record<string, unknown>;
|
|
520
|
+
input: import("json-schema").JSONSchema7 | undefined;
|
|
521
|
+
output: import("json-schema").JSONSchema7 | undefined;
|
|
522
|
+
staticInputValues: unknown;
|
|
523
|
+
maxRetries: number;
|
|
524
|
+
}[];
|
|
525
|
+
objects: {
|
|
526
|
+
name: string;
|
|
527
|
+
description: string | undefined;
|
|
528
|
+
properties: import("./objects.js").ObjectProperty[] | undefined;
|
|
529
|
+
tools: {
|
|
530
|
+
name: string;
|
|
531
|
+
aliases: string[];
|
|
532
|
+
description: string | undefined;
|
|
533
|
+
metadata: Record<string, unknown>;
|
|
534
|
+
input: import("json-schema").JSONSchema7 | undefined;
|
|
535
|
+
output: import("json-schema").JSONSchema7 | undefined;
|
|
536
|
+
staticInputValues: unknown;
|
|
537
|
+
maxRetries: number;
|
|
538
|
+
}[];
|
|
539
|
+
metadata: Record<string, unknown> | undefined;
|
|
540
|
+
}[];
|
|
541
|
+
exits: {
|
|
542
|
+
name: string;
|
|
543
|
+
aliases: string[];
|
|
544
|
+
description: string;
|
|
545
|
+
metadata: {
|
|
546
|
+
[x: string]: unknown;
|
|
547
|
+
};
|
|
548
|
+
schema: import("json-schema").JSONSchema7 | undefined;
|
|
549
|
+
}[];
|
|
550
|
+
instructions: string | undefined;
|
|
551
|
+
duration: string;
|
|
552
|
+
error: string | null;
|
|
553
|
+
isChatEnabled: boolean;
|
|
554
|
+
}[];
|
|
555
|
+
iteration: number;
|
|
556
|
+
timeout: number;
|
|
557
|
+
loop: number;
|
|
558
|
+
temperature: number;
|
|
559
|
+
model: "best" | "fast" | `${string}:${string}` | undefined;
|
|
560
|
+
metadata: Record<string, any>;
|
|
561
|
+
snapshot: {
|
|
562
|
+
id: string;
|
|
563
|
+
reason: string | undefined;
|
|
564
|
+
stack: string;
|
|
565
|
+
variables: ({
|
|
566
|
+
name: string;
|
|
567
|
+
type: string;
|
|
568
|
+
bytes: number;
|
|
569
|
+
preview?: string;
|
|
570
|
+
value?: unknown;
|
|
571
|
+
truncated: boolean;
|
|
572
|
+
} & ({
|
|
573
|
+
truncated: true;
|
|
574
|
+
preview: string;
|
|
575
|
+
} | {
|
|
576
|
+
truncated: false;
|
|
577
|
+
value: unknown;
|
|
578
|
+
}))[];
|
|
579
|
+
toolCall: import("./errors.js").ToolCall | undefined;
|
|
580
|
+
status: import("./snapshots.js").SnapshotStatus;
|
|
581
|
+
} | undefined;
|
|
582
|
+
};
|
|
387
583
|
}
|
|
388
584
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DualModePrompt
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2D2DE7CD.js";
|
|
4
4
|
import "./chunk-JQBT7UWN.js";
|
|
5
5
|
import "./chunk-GGWM6X2K.js";
|
|
6
6
|
import "./chunk-ORQP26SZ.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-3JYCCI4S.js";
|
|
8
|
+
import "./chunk-ZORRILUV.js";
|
|
9
9
|
import "./chunk-7WRN4E42.js";
|
|
10
10
|
export {
|
|
11
11
|
DualModePrompt
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkPIDLNYIPcjs = require('./chunk-PIDLNYIP.cjs');
|
|
4
4
|
require('./chunk-IKSIOIIP.cjs');
|
|
5
5
|
require('./chunk-ZRCU35UV.cjs');
|
|
6
6
|
require('./chunk-KMZDFWYZ.cjs');
|
|
7
|
-
require('./chunk-
|
|
8
|
-
require('./chunk-
|
|
7
|
+
require('./chunk-GZPN7RGH.cjs');
|
|
8
|
+
require('./chunk-WHNOR4ZU.cjs');
|
|
9
9
|
require('./chunk-UQOBUJIQ.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
exports.DualModePrompt =
|
|
12
|
+
exports.DualModePrompt = _chunkPIDLNYIPcjs.DualModePrompt;
|
package/dist/errors.d.ts
CHANGED
|
@@ -39,8 +39,8 @@ export declare class VMLoopSignal extends VMSignal {
|
|
|
39
39
|
}
|
|
40
40
|
export declare class ThinkSignal extends VMLoopSignal {
|
|
41
41
|
reason: string;
|
|
42
|
-
context?: any;
|
|
43
|
-
constructor(reason: string, context?: any);
|
|
42
|
+
context?: any | undefined;
|
|
43
|
+
constructor(reason: string, context?: any | undefined);
|
|
44
44
|
toString(): string;
|
|
45
45
|
}
|
|
46
46
|
export declare class CodeExecutionError extends Error {
|
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 _chunk2NU62OI4cjs = require('./chunk-2NU62OI4.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-EUESEPB7.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-EUESEPB7.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 = _chunk2NU62OI4cjs.DefaultExit; exports.ErrorExecutionResult = _chunk2NU62OI4cjs.ErrorExecutionResult; exports.ExecutionResult = _chunk2NU62OI4cjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunk2NU62OI4cjs.ListenExit; exports.LoopExceededError = _chunkJDABP4SDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunk2NU62OI4cjs.PartialExecutionResult; exports.Snapshot = _chunk2NU62OI4cjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunk2NU62OI4cjs.SuccessExecutionResult; exports.ThinkExit = _chunk2NU62OI4cjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunkXGJOEQMWcjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunk2NU62OI4cjs.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
|
*
|