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
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkPIDLNYIPcjs = require('./chunk-PIDLNYIP.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkXGJOEQMWcjs = require('./chunk-XGJOEQMW.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
|
|
@@ -62,10 +62,10 @@ var Snapshot = class _Snapshot {
|
|
|
62
62
|
*/
|
|
63
63
|
static fromSignal(signal) {
|
|
64
64
|
const variables = Object.entries(signal.variables).map(([name, value]) => {
|
|
65
|
-
const type =
|
|
65
|
+
const type = _chunkPIDLNYIPcjs.extractType.call(void 0, value);
|
|
66
66
|
const bytes = JSON.stringify(value || "").length;
|
|
67
67
|
const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
|
|
68
|
-
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(
|
|
68
|
+
return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkPIDLNYIPcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
|
|
69
69
|
});
|
|
70
70
|
return new _Snapshot({
|
|
71
71
|
id: "snapshot_" + _ulid.ulid.call(void 0, ),
|
|
@@ -210,9 +210,9 @@ function getMessagePreview(message) {
|
|
|
210
210
|
return message.content;
|
|
211
211
|
}
|
|
212
212
|
if (message.role === "event") {
|
|
213
|
-
return
|
|
213
|
+
return _chunkPIDLNYIPcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
|
|
214
214
|
}
|
|
215
|
-
return
|
|
215
|
+
return _chunkPIDLNYIPcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
|
|
216
216
|
}
|
|
217
217
|
function getMessageType(message) {
|
|
218
218
|
if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
|
|
@@ -510,6 +510,25 @@ var SuccessExecutionResult = class extends ExecutionResult {
|
|
|
510
510
|
get iteration() {
|
|
511
511
|
return this.context.iterations.at(-1);
|
|
512
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* Serializes the execution result to JSON.
|
|
515
|
+
*
|
|
516
|
+
* This method converts the execution result into a JSON format that includes
|
|
517
|
+
* the execution status, context, and exit information. It is used for serialization
|
|
518
|
+
* and transmission of the execution result.
|
|
519
|
+
*
|
|
520
|
+
* @returns The JSON representation of the execution result.
|
|
521
|
+
*/
|
|
522
|
+
toJSON() {
|
|
523
|
+
return {
|
|
524
|
+
status: "success",
|
|
525
|
+
context: this.context.toJSON(),
|
|
526
|
+
result: {
|
|
527
|
+
exit: this.result.exit.toJSON(),
|
|
528
|
+
result: this.result.result
|
|
529
|
+
}
|
|
530
|
+
};
|
|
531
|
+
}
|
|
513
532
|
};
|
|
514
533
|
var ErrorExecutionResult = class extends ExecutionResult {
|
|
515
534
|
|
|
@@ -525,6 +544,13 @@ var ErrorExecutionResult = class extends ExecutionResult {
|
|
|
525
544
|
get output() {
|
|
526
545
|
return null;
|
|
527
546
|
}
|
|
547
|
+
toJSON() {
|
|
548
|
+
return {
|
|
549
|
+
status: "error",
|
|
550
|
+
context: this.context.toJSON(),
|
|
551
|
+
error: this.error
|
|
552
|
+
};
|
|
553
|
+
}
|
|
528
554
|
};
|
|
529
555
|
var PartialExecutionResult = class extends ExecutionResult {
|
|
530
556
|
|
|
@@ -542,6 +568,23 @@ var PartialExecutionResult = class extends ExecutionResult {
|
|
|
542
568
|
get output() {
|
|
543
569
|
return null;
|
|
544
570
|
}
|
|
571
|
+
/**
|
|
572
|
+
* Serializes the execution result to JSON.
|
|
573
|
+
*
|
|
574
|
+
* @returns The JSON representation of the execution result.
|
|
575
|
+
*/
|
|
576
|
+
toJSON() {
|
|
577
|
+
return {
|
|
578
|
+
status: "interrupted",
|
|
579
|
+
context: this.context.toJSON(),
|
|
580
|
+
snapshot: this.snapshot.toJSON(),
|
|
581
|
+
signal: {
|
|
582
|
+
message: this.signal.message,
|
|
583
|
+
truncatedCode: this.signal.truncatedCode,
|
|
584
|
+
variables: this.signal.variables
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
}
|
|
545
588
|
};
|
|
546
589
|
|
|
547
590
|
// src/getter.ts
|
|
@@ -593,15 +636,15 @@ var HookedArray = class extends Array {
|
|
|
593
636
|
};
|
|
594
637
|
|
|
595
638
|
// src/context.ts
|
|
596
|
-
var ThinkExit = new (0,
|
|
639
|
+
var ThinkExit = new (0, _chunk3G3BS5IAcjs.Exit)({
|
|
597
640
|
name: "think",
|
|
598
641
|
description: "Think about the current situation and provide a response"
|
|
599
642
|
});
|
|
600
|
-
var ListenExit = new (0,
|
|
643
|
+
var ListenExit = new (0, _chunk3G3BS5IAcjs.Exit)({
|
|
601
644
|
name: "listen",
|
|
602
645
|
description: "Listen to the user and provide a response"
|
|
603
646
|
});
|
|
604
|
-
var DefaultExit = new (0,
|
|
647
|
+
var DefaultExit = new (0, _chunk3G3BS5IAcjs.Exit)({
|
|
605
648
|
name: "done",
|
|
606
649
|
description: "When the execution is sucessfully completed or when error recovery is not possible",
|
|
607
650
|
schema: _zui.z.discriminatedUnion("success", [
|
|
@@ -715,6 +758,28 @@ var Iteration = class {
|
|
|
715
758
|
this.ended_ts = Date.now();
|
|
716
759
|
this.status = status;
|
|
717
760
|
}
|
|
761
|
+
toJSON() {
|
|
762
|
+
return {
|
|
763
|
+
id: this.id,
|
|
764
|
+
messages: [...this.messages],
|
|
765
|
+
code: this.code,
|
|
766
|
+
traces: [...this.traces],
|
|
767
|
+
variables: this.variables,
|
|
768
|
+
started_ts: this.started_ts,
|
|
769
|
+
ended_ts: this.ended_ts,
|
|
770
|
+
status: this.status,
|
|
771
|
+
mutations: [...this._mutations.values()],
|
|
772
|
+
llm: this.llm,
|
|
773
|
+
transcript: [...this._parameters.transcript],
|
|
774
|
+
tools: this._parameters.tools.map((tool) => tool.toJSON()),
|
|
775
|
+
objects: this._parameters.objects.map((obj) => obj.toJSON()),
|
|
776
|
+
exits: this._parameters.exits.map((exit) => exit.toJSON()),
|
|
777
|
+
instructions: this._parameters.instructions,
|
|
778
|
+
duration: this.duration,
|
|
779
|
+
error: this.error,
|
|
780
|
+
isChatEnabled: this.isChatEnabled
|
|
781
|
+
};
|
|
782
|
+
}
|
|
718
783
|
};
|
|
719
784
|
var Context = (_class2 = class {
|
|
720
785
|
|
|
@@ -723,7 +788,7 @@ var Context = (_class2 = class {
|
|
|
723
788
|
|
|
724
789
|
|
|
725
790
|
|
|
726
|
-
__init3() {this.version =
|
|
791
|
+
__init3() {this.version = _chunkPIDLNYIPcjs.DualModePrompt}
|
|
727
792
|
__init4() {this.timeout = 6e4}
|
|
728
793
|
// Default timeout of 60 seconds
|
|
729
794
|
|
|
@@ -838,7 +903,7 @@ var Context = (_class2 = class {
|
|
|
838
903
|
...lastIterationMessages,
|
|
839
904
|
{
|
|
840
905
|
role: "assistant",
|
|
841
|
-
content:
|
|
906
|
+
content: _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_c = lastIteration.llm) == null ? void 0 : _c.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
842
907
|
},
|
|
843
908
|
await this.version.getThinkingMessage({
|
|
844
909
|
reason: lastIteration.status.thinking_requested.reason,
|
|
@@ -851,7 +916,7 @@ var Context = (_class2 = class {
|
|
|
851
916
|
...lastIterationMessages,
|
|
852
917
|
{
|
|
853
918
|
role: "assistant",
|
|
854
|
-
content:
|
|
919
|
+
content: _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_d = lastIteration.llm) == null ? void 0 : _d.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
855
920
|
},
|
|
856
921
|
await this.version.getInvalidCodeMessage({
|
|
857
922
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -864,7 +929,7 @@ var Context = (_class2 = class {
|
|
|
864
929
|
...lastIterationMessages,
|
|
865
930
|
{
|
|
866
931
|
role: "assistant",
|
|
867
|
-
content:
|
|
932
|
+
content: _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_e = lastIteration.llm) == null ? void 0 : _e.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
868
933
|
},
|
|
869
934
|
await this.version.getInvalidCodeMessage({
|
|
870
935
|
code: _nullishCoalesce(lastIteration.code, () => ( "// No code generated")),
|
|
@@ -877,7 +942,7 @@ var Context = (_class2 = class {
|
|
|
877
942
|
...lastIterationMessages,
|
|
878
943
|
{
|
|
879
944
|
role: "assistant",
|
|
880
|
-
content:
|
|
945
|
+
content: _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_f = lastIteration.llm) == null ? void 0 : _f.output), () => ( "")), { preserve: "top", flex: 4, minTokens: 25 })
|
|
881
946
|
},
|
|
882
947
|
await this.version.getCodeExecutionErrorMessage({
|
|
883
948
|
message: lastIteration.status.execution_error.message,
|
|
@@ -893,7 +958,7 @@ var Context = (_class2 = class {
|
|
|
893
958
|
var _a, _b;
|
|
894
959
|
const instructions = await getValue(this.instructions, this);
|
|
895
960
|
const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
|
|
896
|
-
const tools =
|
|
961
|
+
const tools = _chunkXGJOEQMWcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
|
|
897
962
|
const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
|
|
898
963
|
const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
|
|
899
964
|
const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
|
|
@@ -923,7 +988,7 @@ var Context = (_class2 = class {
|
|
|
923
988
|
"boolean",
|
|
924
989
|
"array"
|
|
925
990
|
];
|
|
926
|
-
const MessageTool = this.chat && components.length ? new (0,
|
|
991
|
+
const MessageTool = this.chat && components.length ? new (0, _chunkXGJOEQMWcjs.Tool)({
|
|
927
992
|
name: "Message",
|
|
928
993
|
description: "Send a message to the user",
|
|
929
994
|
aliases: Array.from(
|
|
@@ -1006,6 +1071,20 @@ var Context = (_class2 = class {
|
|
|
1006
1071
|
throw new Error("Invalid temperature. Expected a number between 0 and 2.");
|
|
1007
1072
|
}
|
|
1008
1073
|
}
|
|
1074
|
+
toJSON() {
|
|
1075
|
+
var _a;
|
|
1076
|
+
return {
|
|
1077
|
+
id: this.id,
|
|
1078
|
+
iterations: this.iterations.map((iteration) => iteration.toJSON()),
|
|
1079
|
+
iteration: this.iteration,
|
|
1080
|
+
timeout: this.timeout,
|
|
1081
|
+
loop: this.loop,
|
|
1082
|
+
temperature: this.temperature,
|
|
1083
|
+
model: this.model,
|
|
1084
|
+
metadata: this.metadata,
|
|
1085
|
+
snapshot: (_a = this.snapshot) == null ? void 0 : _a.toJSON()
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1009
1088
|
}, _class2);
|
|
1010
1089
|
|
|
1011
1090
|
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
isJsonSchema,
|
|
3
3
|
isValidIdentifier,
|
|
4
4
|
isZuiSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ZORRILUV.js";
|
|
6
6
|
import {
|
|
7
7
|
uniq_default
|
|
8
8
|
} from "./chunk-7WRN4E42.js";
|
|
@@ -100,6 +100,31 @@ var Exit = class _Exit {
|
|
|
100
100
|
match(result) {
|
|
101
101
|
return result.exit instanceof _Exit && this.name === result.exit.name;
|
|
102
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Serializes this exit to a JSON-compatible object.
|
|
105
|
+
*
|
|
106
|
+
* @returns JSON representation of the exit
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const exit = new Exit({
|
|
111
|
+
* name: 'complete',
|
|
112
|
+
* description: 'Task completed successfully',
|
|
113
|
+
* })
|
|
114
|
+
*
|
|
115
|
+
* console.log(exit.toJSON())
|
|
116
|
+
* // { name: 'complete', aliases: [], description: 'Task completed successfully', metadata: {}, schema: undefined }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
toJSON() {
|
|
120
|
+
return {
|
|
121
|
+
name: this.name,
|
|
122
|
+
aliases: [...this.aliases],
|
|
123
|
+
description: this.description,
|
|
124
|
+
metadata: { ...this.metadata },
|
|
125
|
+
schema: this.schema
|
|
126
|
+
};
|
|
127
|
+
}
|
|
103
128
|
/**
|
|
104
129
|
* Creates a new Exit instance.
|
|
105
130
|
*
|
|
@@ -166,6 +166,9 @@ var convertObjectToZuiLiterals = (obj, nested = false) => {
|
|
|
166
166
|
if (nested) {
|
|
167
167
|
return _zui.z.object(shape).catch(() => shape);
|
|
168
168
|
}
|
|
169
|
+
if (Object.keys(shape).length === 0) {
|
|
170
|
+
return _zui.z.object({}).catch(() => shape);
|
|
171
|
+
}
|
|
169
172
|
return shape;
|
|
170
173
|
}
|
|
171
174
|
if (obj === void 0) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkFZJHYLM2cjs = require('./chunk-FZJHYLM2.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -96,7 +96,7 @@ var Tool = (_class = class _Tool {
|
|
|
96
96
|
get zInput() {
|
|
97
97
|
let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
|
|
98
98
|
if (!_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
99
|
-
const inputExtensions =
|
|
99
|
+
const inputExtensions = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
100
100
|
if (input instanceof _zui.z.ZodObject) {
|
|
101
101
|
input = input.extend(inputExtensions);
|
|
102
102
|
} else if (input instanceof _zui.z.ZodArray) {
|
|
@@ -132,7 +132,7 @@ var Tool = (_class = class _Tool {
|
|
|
132
132
|
*/
|
|
133
133
|
rename(name) {
|
|
134
134
|
const before = this.name;
|
|
135
|
-
if (!
|
|
135
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, name)) {
|
|
136
136
|
throw new Error(
|
|
137
137
|
`Invalid name for tool ${name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
138
138
|
);
|
|
@@ -294,7 +294,7 @@ var Tool = (_class = class _Tool {
|
|
|
294
294
|
* ```
|
|
295
295
|
*/
|
|
296
296
|
constructor(props) {;_class.prototype.__init.call(this);_class.prototype.__init2.call(this);
|
|
297
|
-
if (!
|
|
297
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
298
298
|
throw new Error(
|
|
299
299
|
`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.`
|
|
300
300
|
);
|
|
@@ -319,13 +319,13 @@ var Tool = (_class = class _Tool {
|
|
|
319
319
|
`Invalid aliases for tool ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
320
320
|
);
|
|
321
321
|
}
|
|
322
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
322
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, alias))) {
|
|
323
323
|
throw new Error(`Invalid aliases for tool ${props.name}. Expected an array of valid identifiers.`);
|
|
324
324
|
}
|
|
325
325
|
if (typeof props.input !== "undefined") {
|
|
326
|
-
if (
|
|
326
|
+
if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.input)) {
|
|
327
327
|
this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
|
|
328
|
-
} else if (
|
|
328
|
+
} else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.input)) {
|
|
329
329
|
this.input = props.input;
|
|
330
330
|
} else {
|
|
331
331
|
throw new Error(
|
|
@@ -334,9 +334,9 @@ var Tool = (_class = class _Tool {
|
|
|
334
334
|
}
|
|
335
335
|
}
|
|
336
336
|
if (typeof props.output !== "undefined") {
|
|
337
|
-
if (
|
|
337
|
+
if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.output)) {
|
|
338
338
|
this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
|
|
339
|
-
} else if (
|
|
339
|
+
} else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.output)) {
|
|
340
340
|
this.output = props.output;
|
|
341
341
|
} else {
|
|
342
342
|
throw new Error(
|
|
@@ -416,13 +416,13 @@ var Tool = (_class = class _Tool {
|
|
|
416
416
|
let input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : void 0;
|
|
417
417
|
const output = this.output ? _zui.transforms.fromJSONSchemaLegacy(this.output) : _zui.z.void();
|
|
418
418
|
if ((input == null ? void 0 : input.naked()) instanceof _zui.ZodObject && typeof this._staticInputValues === "object" && !_chunkUQOBUJIQcjs.isEmpty_default.call(void 0, this._staticInputValues)) {
|
|
419
|
-
const inputExtensions =
|
|
419
|
+
const inputExtensions = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
420
420
|
input = input.extend(inputExtensions);
|
|
421
421
|
} else if (this._staticInputValues !== void 0) {
|
|
422
|
-
input =
|
|
422
|
+
input = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
|
|
423
423
|
}
|
|
424
424
|
const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
|
|
425
|
-
return
|
|
425
|
+
return _chunkFZJHYLM2cjs.getTypings.call(void 0, fnType, {
|
|
426
426
|
declaration: true
|
|
427
427
|
});
|
|
428
428
|
}
|
|
@@ -469,6 +469,23 @@ var Tool = (_class = class _Tool {
|
|
|
469
469
|
return tool.rename(toolName);
|
|
470
470
|
});
|
|
471
471
|
}}
|
|
472
|
+
/**
|
|
473
|
+
* Converts the tool to its JSON representation.
|
|
474
|
+
*
|
|
475
|
+
* @returns JSON representation of the Tool instance
|
|
476
|
+
*/
|
|
477
|
+
toJSON() {
|
|
478
|
+
return {
|
|
479
|
+
name: this.name,
|
|
480
|
+
aliases: [...this.aliases],
|
|
481
|
+
description: this.description,
|
|
482
|
+
metadata: this.metadata,
|
|
483
|
+
input: this.input,
|
|
484
|
+
output: this.output,
|
|
485
|
+
staticInputValues: this._staticInputValues,
|
|
486
|
+
maxRetries: this.MAX_RETRIES
|
|
487
|
+
};
|
|
488
|
+
}
|
|
472
489
|
}, _class.__initStatic(), _class);
|
|
473
490
|
|
|
474
491
|
|
|
@@ -166,6 +166,9 @@ var convertObjectToZuiLiterals = (obj, nested = false) => {
|
|
|
166
166
|
if (nested) {
|
|
167
167
|
return z.object(shape).catch(() => shape);
|
|
168
168
|
}
|
|
169
|
+
if (Object.keys(shape).length === 0) {
|
|
170
|
+
return z.object({}).catch(() => shape);
|
|
171
|
+
}
|
|
169
172
|
return shape;
|
|
170
173
|
}
|
|
171
174
|
if (obj === void 0) {
|
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;
|