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.
Files changed (47) hide show
  1. package/dist/{chunk-KH6JQYQA.js → chunk-2D2DE7CD.js} +2 -2
  2. package/dist/{chunk-GOJY4GRL.cjs → chunk-2NU62OI4.cjs} +98 -19
  3. package/dist/{chunk-WL7ZIMYD.cjs → chunk-3G3BS5IA.cjs} +31 -6
  4. package/dist/{chunk-SNDVQU5A.js → chunk-3JYCCI4S.js} +1 -1
  5. package/dist/{chunk-OKTHMXRT.js → chunk-A7QHWVD7.js} +19 -2
  6. package/dist/{chunk-IH2WQFO5.js → chunk-EE6NVDID.js} +1 -1
  7. package/dist/{chunk-4L6D2A6O.cjs → chunk-FZJHYLM2.cjs} +14 -14
  8. package/dist/{chunk-JGVAZO4X.cjs → chunk-GZPN7RGH.cjs} +2 -2
  9. package/dist/{chunk-SHJDRZF5.cjs → chunk-PIDLNYIP.cjs} +25 -25
  10. package/dist/{chunk-2Z5SFF6R.js → chunk-QIZBF7A5.js} +84 -5
  11. package/dist/{chunk-XAN7HQP5.js → chunk-VPTFUOIK.js} +26 -1
  12. package/dist/{chunk-276Q6EWP.cjs → chunk-WHNOR4ZU.cjs} +3 -0
  13. package/dist/{chunk-KG7DT7WD.cjs → chunk-XGJOEQMW.cjs} +30 -13
  14. package/dist/{chunk-4MNIJGK6.js → chunk-ZORRILUV.js} +3 -0
  15. package/dist/context.d.ts +200 -4
  16. package/dist/{dual-modes-T53P72CH.js → dual-modes-7FI4T35O.js} +3 -3
  17. package/dist/{dual-modes-VLIGPIHX.cjs → dual-modes-OFHV2C3X.cjs} +4 -4
  18. package/dist/errors.d.ts +2 -2
  19. package/dist/exit-XAYKJ6TR.cjs +8 -0
  20. package/dist/{exit-7HDRH27N.js → exit-YLO7BY7Z.js} +2 -2
  21. package/dist/exit.d.ts +36 -2
  22. package/dist/index.cjs +56 -28
  23. package/dist/index.d.ts +9 -1
  24. package/dist/index.js +45 -17
  25. package/dist/{llmz-TR4CQK4F.cjs → llmz-EUESEPB7.cjs} +18 -18
  26. package/dist/{llmz-MCHRHRTD.js → llmz-T4DEP7OD.js} +7 -7
  27. package/dist/objects.d.ts +36 -1
  28. package/dist/prompts/chat-mode/system.md.d.ts +1 -1
  29. package/dist/prompts/chat-mode/user.md.d.ts +1 -1
  30. package/dist/prompts/worker-mode/system.md.d.ts +1 -1
  31. package/dist/prompts/worker-mode/user.md.d.ts +1 -1
  32. package/dist/result.d.ts +379 -6
  33. package/dist/snapshots.d.ts +12 -1
  34. package/dist/{tool-NS7EGK7Z.cjs → tool-O4SFRIE4.cjs} +4 -4
  35. package/dist/{tool-4AJIJ3QB.js → tool-PCOYOCRH.js} +3 -3
  36. package/dist/tool.d.ts +29 -2
  37. package/dist/{truncator-IY2MXOMC.js → truncator-BSP6PQPC.js} +2 -2
  38. package/dist/truncator-W3NXBLYJ.cjs +10 -0
  39. package/dist/types.d.ts +3 -0
  40. package/dist/{typings-GDMY6VY2.js → typings-WYHEFCYB.js} +2 -2
  41. package/dist/{typings-2CPHOFDN.cjs → typings-Y45GMPZT.cjs} +3 -3
  42. package/dist/utils-L5QAQXV2.cjs +39 -0
  43. package/dist/{utils-N24IHDFA.js → utils-RQHQ2KOG.js} +1 -1
  44. package/package.json +1 -1
  45. package/dist/exit-O2WZUEFS.cjs +0 -8
  46. package/dist/truncator-DUMWEGQO.cjs +0 -10
  47. package/dist/utils-A7WNEFTA.cjs +0 -39
@@ -6,11 +6,11 @@ var _chunkIKSIOIIPcjs = require('./chunk-IKSIOIIP.cjs');
6
6
  var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
7
7
 
8
8
 
9
- var _chunkJGVAZO4Xcjs = require('./chunk-JGVAZO4X.cjs');
9
+ var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
10
10
 
11
11
 
12
12
 
13
- var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
13
+ var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
14
14
 
15
15
 
16
16
 
@@ -53,7 +53,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
53
53
  }
54
54
  if (typeof currentObj !== "object" || currentObj === null) {
55
55
  const value = JSON.stringify(currentObj);
56
- currentLength += _chunk276Q6EWPcjs.getTokenizer.call(void 0, ).count(value);
56
+ currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(value);
57
57
  return value;
58
58
  }
59
59
  const indentation = " ".repeat(currentIndent);
@@ -66,7 +66,7 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
66
66
  result += indentation + " ".repeat(indent) + recurse(currentObj[i], depth + 1, currentIndent + indent);
67
67
  }
68
68
  result += "\n" + indentation + "]";
69
- currentLength += _chunk276Q6EWPcjs.getTokenizer.call(void 0, ).count(result);
69
+ currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(result);
70
70
  return result;
71
71
  } else {
72
72
  let result = "{\n";
@@ -85,11 +85,11 @@ function printLimitedJson(obj, maxDepth, maxLength, maxKeys) {
85
85
  result += ",\n" + indentation + `... (${numKeys - maxKeys} more keys)`;
86
86
  }
87
87
  result += "\n" + indentation + "}";
88
- currentLength += _chunk276Q6EWPcjs.getTokenizer.call(void 0, ).count(result);
88
+ currentLength += _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(result);
89
89
  return result;
90
90
  }
91
91
  }
92
- const output = _chunk276Q6EWPcjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
92
+ const output = _chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).truncate(recurse(obj, 0, 0), maxLength);
93
93
  return { output, truncated: wasTruncated };
94
94
  }
95
95
  function extractType(value, generic = true) {
@@ -154,9 +154,9 @@ function previewValue(value, length = LONG_TEXT_LENGTH) {
154
154
  }
155
155
  const previewStr = (str) => {
156
156
  if (str.length > length) {
157
- return _chunk276Q6EWPcjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
157
+ return _chunkWHNOR4ZUcjs.escapeString.call(void 0, str.slice(0, length)) + " ... <truncated>";
158
158
  }
159
- return _chunk276Q6EWPcjs.escapeString.call(void 0, str);
159
+ return _chunkWHNOR4ZUcjs.escapeString.call(void 0, str);
160
160
  };
161
161
  const previewObj = (obj) => {
162
162
  const mapped = _chunkUQOBUJIQcjs.mapKeys_default.call(void 0, obj, (_value, key) => previewStr(key));
@@ -336,7 +336,7 @@ var inspect = (value, name, options = DEFAULT_OPTIONS) => {
336
336
  } else if (genericType === "boolean") {
337
337
  return header + previewValue(value);
338
338
  } else if (typeof value === "string") {
339
- if (_chunk276Q6EWPcjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
339
+ if (_chunkWHNOR4ZUcjs.getTokenizer.call(void 0, ).count(value) < options.tokens) {
340
340
  return header + previewValue(value);
341
341
  } else {
342
342
  return header + previewLongText(value);
@@ -491,15 +491,15 @@ ${variables_example}
491
491
  role: "system",
492
492
  content: replacePlaceholders(canTalk ? system_md_default : system_md_default2, {
493
493
  is_message_enabled: canTalk,
494
- "tools.d.ts": _chunkJGVAZO4Xcjs.wrapContent.call(void 0, dts, {
494
+ "tools.d.ts": _chunkGZPN7RGHcjs.wrapContent.call(void 0, dts, {
495
495
  preserve: "both",
496
496
  minTokens: 500
497
497
  }),
498
- identity: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, ((_a = props.instructions) == null ? void 0 : _a.length) ? props.instructions : "No specific instructions provided", {
498
+ identity: _chunkGZPN7RGHcjs.wrapContent.call(void 0, ((_a = props.instructions) == null ? void 0 : _a.length) ? props.instructions : "No specific instructions provided", {
499
499
  preserve: "both",
500
500
  minTokens: 1e3
501
501
  }),
502
- transcript: _chunkJGVAZO4Xcjs.wrapContent.call(void 0, props.transcript.toString(), {
502
+ transcript: _chunkGZPN7RGHcjs.wrapContent.call(void 0, props.transcript.toString(), {
503
503
  preserve: "bottom",
504
504
  minTokens: 500
505
505
  }),
@@ -508,7 +508,7 @@ ${variables_example}
508
508
  writeable_vars: writeable_vars.join(", "),
509
509
  variables_example,
510
510
  exits,
511
- components: _chunkJGVAZO4Xcjs.wrapContent.call(void 0,
511
+ components: _chunkGZPN7RGHcjs.wrapContent.call(void 0,
512
512
  props.components.map((component) => _chunkZRCU35UVcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
513
513
  {
514
514
  preserve: "top",
@@ -586,13 +586,13 @@ Code:
586
586
 
587
587
  \`\`\`tsx
588
588
  \u25A0fn_start
589
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, props.code)}
589
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.code)}
590
590
  \u25A0fn_end
591
591
  \`\`\`
592
592
 
593
593
  Error:
594
594
  \`\`\`
595
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
595
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.message, { flex: 4 })}
596
596
  \`\`\`
597
597
 
598
598
  Please fix the error and try again.
@@ -615,11 +615,11 @@ var getCodeExecutionErrorMessage = async (props) => {
615
615
 
616
616
  An error occurred while executing the code.
617
617
 
618
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
618
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, props.message, { preserve: "top", flex: 4 })}
619
619
 
620
620
  Stack Trace:
621
621
  \`\`\`
622
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
622
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, _chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, props.stacktrace), { flex: 6, preserve: "top" })}
623
623
  \`\`\`
624
624
 
625
625
  Let the user know that an error occurred, and if possible, try something else. Do not repeat yourself in the message.
@@ -642,7 +642,7 @@ var getThinkingMessage = async (props) => {
642
642
  if (inspected) {
643
643
  acc.push(inspected);
644
644
  } else {
645
- acc.push(`Value of ${key} is ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
645
+ acc.push(`Value of ${key} is ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`);
646
646
  }
647
647
  return acc;
648
648
  }, []);
@@ -653,7 +653,7 @@ var getThinkingMessage = async (props) => {
653
653
  if (inspected) {
654
654
  return inspected;
655
655
  } else {
656
- return `Value at index ${index} is ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
656
+ return `Value at index ${index} is ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, JSON.stringify(value, null, 2))}`;
657
657
  }
658
658
  });
659
659
  context = mapped.join("\n\n");
@@ -671,7 +671,7 @@ The assistant requested to think. Here's the context:
671
671
  -------------------
672
672
  Reason: ${props.reason || "Thinking requested"}
673
673
  Context:
674
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, context, { preserve: "top" })}
674
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, context, { preserve: "top" })}
675
675
  -------------------
676
676
 
677
677
  Please continue with the conversation (\u25A0fn_start).
@@ -690,19 +690,19 @@ var getSnapshotResolvedMessage = (props) => {
690
690
  injectedVariables[variable.name] = variable.value;
691
691
  variablesMessage += `
692
692
  // Variable "${variable.name}" restored with its full value:
693
- // ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
693
+ // ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_a = inspect(variable.value)) == null ? void 0 : _a.split("\n").join("\n// ")), () => ( "")))}
694
694
  declare const ${variable.name}: ${variable.type}
695
695
  `;
696
696
  } else {
697
697
  variablesMessage += `
698
698
  // The variable "${variable.name}" was too large to be restored with its full value, here's a preview of its last known value:
699
- // ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
699
+ // ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, variable.preview.split("\n").join("\n// "))}
700
700
  // Important: To restore the full value, please re-run the code that generated this variable in the first place.
701
701
  let ${variable.name}: undefined | ${variable.type} = undefined;
702
702
  `;
703
703
  }
704
704
  }
705
- const output = _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
705
+ const output = _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(((_b = inspect(props.snapshot.status.value)) == null ? void 0 : _b.split("\n").join("\n * ")), () => ( "")), {
706
706
  preserve: "top",
707
707
  flex: 4
708
708
  });
@@ -724,7 +724,7 @@ ${_chunkIKSIOIIPcjs.cleanStackTrace.call(void 0, props.snapshot.stack).split("\n
724
724
  Continue the conversation from here, without repeating the above code, as it has already been executed. Here's the variables you can rely on:
725
725
 
726
726
  \`\`\`tsx
727
- ${_chunkJGVAZO4Xcjs.wrapContent.call(void 0, variablesMessage)}
727
+ ${_chunkGZPN7RGHcjs.wrapContent.call(void 0, variablesMessage)}
728
728
  \`\`\`
729
729
 
730
730
  You can now assume that the code you about to generate can rely on the variables "${Object.keys(injectedVariables).join('", "')}" being available.
@@ -747,7 +747,7 @@ var getSnapshotRejectedMessage = (props) => {
747
747
  throw new Error("Snapshot is not resolved");
748
748
  }
749
749
  const errorMessage = _nullishCoalesce(inspect(props.snapshot.status.error), () => ( "Unknown Error"));
750
- const output = _chunkJGVAZO4Xcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
750
+ const output = _chunkGZPN7RGHcjs.wrapContent.call(void 0, _nullishCoalesce(errorMessage.split("\n").join("\n * "), () => ( "Unknown Error")), {
751
751
  preserve: "both",
752
752
  minTokens: 100
753
753
  });
@@ -2,22 +2,22 @@ import {
2
2
  DualModePrompt,
3
3
  extractType,
4
4
  inspect
5
- } from "./chunk-KH6JQYQA.js";
5
+ } from "./chunk-2D2DE7CD.js";
6
6
  import {
7
7
  Tool
8
- } from "./chunk-OKTHMXRT.js";
8
+ } from "./chunk-A7QHWVD7.js";
9
9
  import {
10
10
  LoopExceededError
11
11
  } from "./chunk-JKVVQN2P.js";
12
12
  import {
13
13
  Exit
14
- } from "./chunk-XAN7HQP5.js";
14
+ } from "./chunk-VPTFUOIK.js";
15
15
  import {
16
16
  assertValidComponent
17
17
  } from "./chunk-GGWM6X2K.js";
18
18
  import {
19
19
  wrapContent
20
- } from "./chunk-SNDVQU5A.js";
20
+ } from "./chunk-3JYCCI4S.js";
21
21
  import {
22
22
  cloneDeep_default,
23
23
  isPlainObject_default
@@ -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
  error;
@@ -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
  signal;
@@ -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
@@ -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 = class {
720
785
  id;
@@ -1006,6 +1071,20 @@ var Context = 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
  };
1010
1089
 
1011
1090
  export {
@@ -2,7 +2,7 @@ import {
2
2
  isJsonSchema,
3
3
  isValidIdentifier,
4
4
  isZuiSchema
5
- } from "./chunk-4MNIJGK6.js";
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 _chunk4L6D2A6Ocjs = require('./chunk-4L6D2A6O.cjs');
3
+ var _chunkFZJHYLM2cjs = require('./chunk-FZJHYLM2.cjs');
4
4
 
5
5
 
6
6
 
7
7
 
8
8
 
9
- var _chunk276Q6EWPcjs = require('./chunk-276Q6EWP.cjs');
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 = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
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 (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, name)) {
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 (!_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, props.name)) {
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) => !_chunk276Q6EWPcjs.isValidIdentifier.call(void 0, 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 (_chunk276Q6EWPcjs.isZuiSchema.call(void 0, props.input)) {
326
+ if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.input)) {
327
327
  this.input = _zui.transforms.toJSONSchemaLegacy(props.input);
328
- } else if (_chunk276Q6EWPcjs.isJsonSchema.call(void 0, props.input)) {
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 (_chunk276Q6EWPcjs.isZuiSchema.call(void 0, props.output)) {
337
+ if (_chunkWHNOR4ZUcjs.isZuiSchema.call(void 0, props.output)) {
338
338
  this.output = _zui.transforms.toJSONSchemaLegacy(props.output);
339
- } else if (_chunk276Q6EWPcjs.isJsonSchema.call(void 0, props.output)) {
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 = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
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 = _chunk276Q6EWPcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
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 _chunk4L6D2A6Ocjs.getTypings.call(void 0, fnType, {
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) {