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
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
} from "./chunk-GGWM6X2K.js";
|
|
7
7
|
import {
|
|
8
8
|
wrapContent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3JYCCI4S.js";
|
|
10
10
|
import {
|
|
11
11
|
escapeString,
|
|
12
12
|
getTokenizer
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-ZORRILUV.js";
|
|
14
14
|
import {
|
|
15
15
|
chain_default,
|
|
16
16
|
countBy_default,
|
|
@@ -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") {
|
|
@@ -228,7 +228,7 @@ var TranscriptArray = class extends Array {
|
|
|
228
228
|
items = Array.isArray(items) ? items : [];
|
|
229
229
|
super(...items);
|
|
230
230
|
items.forEach((item) => {
|
|
231
|
-
if (!["user", "assistant"].includes(item.role)) {
|
|
231
|
+
if (!["user", "assistant", "event", "summary"].includes(item.role)) {
|
|
232
232
|
throw new Error(`Invalid role "${item.role}" in transcript message`);
|
|
233
233
|
}
|
|
234
234
|
if ("name" in item && item.name && typeof item.name !== "string") {
|
|
@@ -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 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
|
|
@@ -42,7 +42,7 @@ var Exit = (_class = class _Exit {
|
|
|
42
42
|
*/
|
|
43
43
|
rename(name) {
|
|
44
44
|
const before = this.name;
|
|
45
|
-
if (!
|
|
45
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, name)) {
|
|
46
46
|
throw new Error(
|
|
47
47
|
`Invalid name for exit ${name}. An exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
48
48
|
);
|
|
@@ -100,6 +100,31 @@ var Exit = (_class = 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
|
*
|
|
@@ -152,7 +177,7 @@ var Exit = (_class = class _Exit {
|
|
|
152
177
|
* ```
|
|
153
178
|
*/
|
|
154
179
|
constructor(props) {;_class.prototype.__init.call(this);
|
|
155
|
-
if (!
|
|
180
|
+
if (!_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
156
181
|
throw new Error(
|
|
157
182
|
`Invalid name for exit ${props.name}. A exit name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
|
|
158
183
|
);
|
|
@@ -172,13 +197,13 @@ var Exit = (_class = class _Exit {
|
|
|
172
197
|
`Invalid aliases for exit ${props.name}. Expected an array, but got type "${typeof props.aliases}"`
|
|
173
198
|
);
|
|
174
199
|
}
|
|
175
|
-
if (props.aliases && props.aliases.some((alias) => !
|
|
200
|
+
if (props.aliases && props.aliases.some((alias) => !_chunkWHNOR4ZUcjs.isValidIdentifier.call(void 0, alias))) {
|
|
176
201
|
throw new Error(`Invalid aliases for exit ${props.name}. Expected an array of valid identifiers.`);
|
|
177
202
|
}
|
|
178
203
|
if (typeof props.schema !== "undefined") {
|
|
179
|
-
if (
|
|
204
|
+
if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.schema)) {
|
|
180
205
|
this.schema = _zui.transforms.toJSONSchemaLegacy(props.schema);
|
|
181
|
-
} else if (
|
|
206
|
+
} else if (_chunkWHNOR4ZUcjs.isJsonSchema.call(void 0, props.schema)) {
|
|
182
207
|
this.schema = props.schema;
|
|
183
208
|
} else {
|
|
184
209
|
throw new Error(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getTypings
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EE6NVDID.js";
|
|
4
4
|
import {
|
|
5
5
|
convertObjectToZuiLiterals,
|
|
6
6
|
isJsonSchema,
|
|
7
7
|
isValidIdentifier,
|
|
8
8
|
isZuiSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZORRILUV.js";
|
|
10
10
|
import {
|
|
11
11
|
isEmpty_default,
|
|
12
12
|
uniq_default
|
|
@@ -469,6 +469,23 @@ var Tool = 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
|
};
|
|
473
490
|
|
|
474
491
|
export {
|
|
@@ -5,7 +5,7 @@ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
9
9
|
|
|
10
10
|
// src/typings.ts
|
|
11
11
|
var _zui = require('@bpinternal/zui');
|
|
@@ -111,7 +111,7 @@ async function sUnwrapZod(schema, options) {
|
|
|
111
111
|
parent: schema
|
|
112
112
|
};
|
|
113
113
|
if (schema instanceof Declaration) {
|
|
114
|
-
const description =
|
|
114
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema.schema.description);
|
|
115
115
|
const withoutDesc = schema.schema.describe("");
|
|
116
116
|
const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
|
|
117
117
|
const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
|
|
@@ -132,7 +132,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
132
132
|
const optionalToken = schema.key.endsWith("?") ? "" : "?";
|
|
133
133
|
return sUnwrapZodRecursive(new KeyValue(schema.key + optionalToken, innerType), newOptions);
|
|
134
134
|
}
|
|
135
|
-
const description =
|
|
135
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema.value._def.description || schema.value.description);
|
|
136
136
|
const delimiter = (description == null ? void 0 : description.trim().length) > 0 ? "\n" : "";
|
|
137
137
|
const withoutDesc = schema.value.describe("");
|
|
138
138
|
return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
|
|
@@ -143,7 +143,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
143
143
|
for (let i = 0; i < schema.schema.items.length; i++) {
|
|
144
144
|
const argName = _nullishCoalesce(((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title), () => ( `arg${i}`));
|
|
145
145
|
const item = schema.schema.items[i];
|
|
146
|
-
args += `${await sUnwrapZodRecursive(new KeyValue(
|
|
146
|
+
args += `${await sUnwrapZodRecursive(new KeyValue(_chunkWHNOR4ZUcjs.toPropertyKey.call(void 0, argName), item), newOptions)}, `;
|
|
147
147
|
}
|
|
148
148
|
return args;
|
|
149
149
|
}
|
|
@@ -178,7 +178,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
178
178
|
return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
|
|
179
179
|
}
|
|
180
180
|
if (schema instanceof _zui.z.ZodFunction) {
|
|
181
|
-
const description =
|
|
181
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
182
182
|
const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
|
|
183
183
|
const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
|
|
184
184
|
if (options == null ? void 0 : options.declaration) {
|
|
@@ -196,7 +196,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
196
196
|
return `Array<${item}>`;
|
|
197
197
|
}
|
|
198
198
|
if (schema instanceof _zui.z.ZodEnum) {
|
|
199
|
-
const values = schema._def.values.map(
|
|
199
|
+
const values = schema._def.values.map(_chunkWHNOR4ZUcjs.escapeString);
|
|
200
200
|
return values.join(" | ");
|
|
201
201
|
}
|
|
202
202
|
if (schema instanceof _zui.z.ZodTuple) {
|
|
@@ -221,7 +221,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
221
221
|
const props = await Promise.all(
|
|
222
222
|
Object.entries(schema.shape).map(async ([key, value]) => {
|
|
223
223
|
if (value instanceof _zui.z.Schema) {
|
|
224
|
-
return sUnwrapZodRecursive(new KeyValue(
|
|
224
|
+
return sUnwrapZodRecursive(new KeyValue(_chunkWHNOR4ZUcjs.toPropertyKey.call(void 0, key), value), newOptions);
|
|
225
225
|
}
|
|
226
226
|
return `${key}: unknown`;
|
|
227
227
|
})
|
|
@@ -229,11 +229,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
229
229
|
return `{ ${props.join("; ")} }`;
|
|
230
230
|
}
|
|
231
231
|
if (schema instanceof _zui.z.ZodString) {
|
|
232
|
-
const description =
|
|
232
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
233
233
|
return `${description} string`.trim();
|
|
234
234
|
}
|
|
235
235
|
if (schema instanceof _zui.z.ZodUnion) {
|
|
236
|
-
const description =
|
|
236
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
237
237
|
const options2 = await Promise.all(
|
|
238
238
|
schema.options.map(async (option) => {
|
|
239
239
|
return sUnwrapZodRecursive(option, newOptions);
|
|
@@ -243,16 +243,16 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
|
|
|
243
243
|
${options2.join(" | ")}`;
|
|
244
244
|
}
|
|
245
245
|
if (schema instanceof _zui.z.ZodLiteral) {
|
|
246
|
-
const description =
|
|
246
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
247
247
|
return `${description}
|
|
248
|
-
${typeof schema.value === "string" ?
|
|
248
|
+
${typeof schema.value === "string" ? _chunkWHNOR4ZUcjs.escapeString.call(void 0, schema.value) : schema.value}`.trim();
|
|
249
249
|
}
|
|
250
250
|
if (schema instanceof _zui.z.ZodNumber) {
|
|
251
|
-
const description =
|
|
251
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
252
252
|
return `${description} number`.trim();
|
|
253
253
|
}
|
|
254
254
|
if (schema instanceof _zui.z.ZodBoolean) {
|
|
255
|
-
const description =
|
|
255
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
256
256
|
return `${description} boolean`.trim();
|
|
257
257
|
}
|
|
258
258
|
if (schema instanceof _zui.z.ZodCatch) {
|
|
@@ -262,7 +262,7 @@ ${typeof schema.value === "string" ? _chunk276Q6EWPcjs.escapeString.call(void 0,
|
|
|
262
262
|
return sUnwrapZodRecursive(schema._def.getter(), newOptions);
|
|
263
263
|
}
|
|
264
264
|
if (schema instanceof _zui.z.ZodRecord) {
|
|
265
|
-
const description =
|
|
265
|
+
const description = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, schema._def.description);
|
|
266
266
|
const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
|
|
267
267
|
const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
|
|
268
268
|
return `${description} { [key: (${keyType})]: (${valueType}) }`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
|
|
4
4
|
|
|
5
5
|
// src/truncator.ts
|
|
6
6
|
var DEFAULT_REMOVE_CHUNK = 250;
|
|
@@ -25,7 +25,7 @@ function truncateWrappedContent({
|
|
|
25
25
|
throwOnFailure = true
|
|
26
26
|
}) {
|
|
27
27
|
var _a, _b, _c;
|
|
28
|
-
const tokenizer =
|
|
28
|
+
const tokenizer = _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, );
|
|
29
29
|
const parts = [];
|
|
30
30
|
for (const msg of messages) {
|
|
31
31
|
const current = [];
|