llmz 0.0.56 → 0.0.58

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 (29) hide show
  1. package/dist/{chunk-SZLX27VX.cjs → chunk-2JTZOTO5.cjs} +9 -9
  2. package/dist/{chunk-D3JSHTIK.cjs → chunk-3SZK4YSR.cjs} +2 -2
  3. package/dist/{chunk-WTWIJ2LI.js → chunk-6EAURSDP.js} +1 -1
  4. package/dist/{chunk-UOENUUUV.js → chunk-AMQFJRRX.js} +1 -1
  5. package/dist/{chunk-2NEOPXCS.cjs → chunk-BLB44ZDU.cjs} +34 -30
  6. package/dist/{chunk-FMEOHU4O.cjs → chunk-C4CL2QZI.cjs} +11 -11
  7. package/dist/{chunk-V7Z5YK5C.js → chunk-E6WEQRZF.js} +3 -3
  8. package/dist/{chunk-L2ZDZKCB.js → chunk-G5INQ5LJ.js} +9 -9
  9. package/dist/{chunk-TLOQBZKW.cjs → chunk-K2B5YEGJ.cjs} +1 -1
  10. package/dist/{chunk-YV5N57D3.js → chunk-LR6KTFHO.js} +34 -30
  11. package/dist/component-36KG7B5H.cjs +18 -0
  12. package/dist/{component-GNYIA77X.js → component-EZAROCAF.js} +1 -1
  13. package/dist/component.default.d.ts +42 -41
  14. package/dist/context.d.ts +2 -1
  15. package/dist/{dual-modes-FTHFPWZ4.cjs → dual-modes-EFWC4CAY.cjs} +3 -3
  16. package/dist/{dual-modes-GCL2U7YL.js → dual-modes-ILL7OVJG.js} +2 -2
  17. package/dist/index.cjs +26 -26
  18. package/dist/index.js +12 -12
  19. package/dist/jsx.d.ts +1 -1
  20. package/dist/{llmz-75TGKZJL.cjs → llmz-6L7C5M25.cjs} +15 -15
  21. package/dist/{llmz-QQULWMOC.js → llmz-7OZC2RFA.js} +5 -5
  22. package/dist/{tool-NAGC3ZMN.cjs → tool-NCCTC74P.cjs} +3 -3
  23. package/dist/{tool-5JXTEQNW.js → tool-ZP6BC3P2.js} +2 -2
  24. package/dist/tool.d.ts +6 -6
  25. package/dist/{typings-SNGR4WYT.cjs → typings-54UIN7ZR.cjs} +2 -2
  26. package/dist/{typings-ZO63Z4TF.js → typings-DVMU3KVB.js} +1 -1
  27. package/dist/utils.d.ts +2 -2
  28. package/package.json +3 -3
  29. package/dist/component-J72CVOKY.cjs +0 -18
@@ -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(); } } var _class;
2
2
 
3
- var _chunk2NEOPXCScjs = require('./chunk-2NEOPXCS.cjs');
3
+ var _chunkBLB44ZDUcjs = require('./chunk-BLB44ZDU.cjs');
4
4
 
5
5
 
6
6
 
@@ -71,12 +71,12 @@ var Tool = (_class = class _Tool {
71
71
  return this;
72
72
  }
73
73
  const input = this.input ? _zui.transforms.fromJSONSchemaLegacy(this.input) : _zui.z.any();
74
- if (input instanceof _zui.z.ZodObject && typeof values !== "object") {
74
+ if (_zui.z.is.zuiObject(input) && typeof values !== "object") {
75
75
  throw new Error(
76
76
  `Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
77
77
  );
78
78
  }
79
- if (input instanceof _zui.z.ZodArray && !Array.isArray(values)) {
79
+ if (_zui.z.is.zuiArray(input) && !Array.isArray(values)) {
80
80
  throw new Error(
81
81
  `Invalid static input values for tool ${this.name}. Expected an array, but got type "${typeof values}"`
82
82
  );
@@ -106,9 +106,9 @@ var Tool = (_class = class _Tool {
106
106
  }
107
107
  if (!_chunkRKKRSBX3cjs.isEmpty_default.call(void 0, this._staticInputValues)) {
108
108
  const inputExtensions = _chunk4VYDQ3VFcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
109
- if (input instanceof _zui.z.ZodObject) {
109
+ if (_zui.z.is.zuiObject(input)) {
110
110
  input = input.extend(inputExtensions);
111
- } else if (input instanceof _zui.z.ZodArray) {
111
+ } else if (_zui.z.is.zuiArray(input)) {
112
112
  input = _zui.z.array(input.element.extend(inputExtensions));
113
113
  } else {
114
114
  input = inputExtensions;
@@ -238,8 +238,8 @@ var Tool = (_class = class _Tool {
238
238
  aliases: _nullishCoalesce(props.aliases, () => ( [...this.aliases])),
239
239
  description: _nullishCoalesce(props.description, () => ( this.description)),
240
240
  metadata: JSON.parse(JSON.stringify(_nullishCoalesce(props.metadata, () => ( this.metadata)))),
241
- input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : props.input instanceof _zui.ZodType ? props.input : zInput,
242
- output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : props.output instanceof _zui.ZodType ? props.output : zOutput,
241
+ input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : _zui.z.is.zuiType(props.input) ? props.input : zInput,
242
+ output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : _zui.z.is.zuiType(props.output) ? props.output : zOutput,
243
243
  handler: _nullishCoalesce(props.handler, () => ( this._handler)),
244
244
  retry: _nullishCoalesce(props.retry, () => ( this.retry))
245
245
  }).setStaticInputValues(_nullishCoalesce(props.staticInputValues, () => ( this._staticInputValues)));
@@ -472,14 +472,14 @@ var Tool = (_class = class _Tool {
472
472
  output = _zui.transforms.fromJSONSchemaLegacy(this.output);
473
473
  }
474
474
  }
475
- if ((input == null ? void 0 : input.naked()) instanceof _zui.ZodObject && typeof this._staticInputValues === "object" && !_chunkRKKRSBX3cjs.isEmpty_default.call(void 0, this._staticInputValues)) {
475
+ if (input && _zui.z.is.zuiObject(input.naked()) && typeof this._staticInputValues === "object" && !_chunkRKKRSBX3cjs.isEmpty_default.call(void 0, this._staticInputValues)) {
476
476
  const inputExtensions = _chunk4VYDQ3VFcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
477
477
  input = input.extend(inputExtensions);
478
478
  } else if (this._staticInputValues !== void 0) {
479
479
  input = _chunk4VYDQ3VFcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
480
480
  }
481
481
  const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
482
- return _chunk2NEOPXCScjs.getTypings.call(void 0, fnType, {
482
+ return _chunkBLB44ZDUcjs.getTypings.call(void 0, fnType, {
483
483
  declaration: true
484
484
  });
485
485
  }
@@ -3,7 +3,7 @@
3
3
  var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
4
4
 
5
5
 
6
- var _chunkTLOQBZKWcjs = require('./chunk-TLOQBZKW.cjs');
6
+ var _chunkK2B5YEGJcjs = require('./chunk-K2B5YEGJ.cjs');
7
7
 
8
8
 
9
9
  var _chunkUCXQ4U7Pcjs = require('./chunk-UCXQ4U7P.cjs');
@@ -526,7 +526,7 @@ ${variables_example}
526
526
  variables_example,
527
527
  exits,
528
528
  components: _chunkUCXQ4U7Pcjs.wrapContent.call(void 0,
529
- props.components.map((component) => _chunkTLOQBZKWcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
529
+ props.components.map((component) => _chunkK2B5YEGJcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
530
530
  {
531
531
  preserve: "top",
532
532
  minTokens: 500
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YEAWWJSJ.js";
4
4
  import {
5
5
  getComponentReference
6
- } from "./chunk-UOENUUUV.js";
6
+ } from "./chunk-AMQFJRRX.js";
7
7
  import {
8
8
  wrapContent
9
9
  } from "./chunk-M4WTTARE.js";
@@ -80,7 +80,7 @@ function getComponentReference(component) {
80
80
  const naked = schema.naked();
81
81
  const zodType = naked._def.typeName;
82
82
  const defValue = getDefaultValue(schema);
83
- const typings = naked instanceof z.ZodEnum ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
83
+ const typings = z.is.zuiEnum(naked) ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
84
84
  const required = !schema.isOptional() ? "**(required)**" : "(optional)";
85
85
  const def = defValue ? ` _Default: \`${defValue}\`_` : "";
86
86
  const description = schema.description || schema.naked().description || (schema == null ? void 0 : schema._def.description) || "";
@@ -89,7 +89,7 @@ async function getTypings(schema, options) {
89
89
  options ??= {};
90
90
  options.declaration ??= false;
91
91
  let wrappedSchema = schema;
92
- if ((options == null ? void 0 : options.declaration) && schema instanceof _zui.z.Schema) {
92
+ if ((options == null ? void 0 : options.declaration) && _zui.z.is.zuiType(schema)) {
93
93
  const title = "title" in schema.ui ? schema.ui.title : null;
94
94
  if (!title) {
95
95
  throw new Error('Only schemas with "title" Zui property can be declared.');
@@ -116,7 +116,7 @@ async function sUnwrapZod(schema, options) {
116
116
  const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
117
117
  const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
118
118
  const closingTag = isLargeDeclaration ? `// end of ${schema.identifier}` : "";
119
- if (schema.schema instanceof _zui.z.ZodFunction) {
119
+ if (_zui.z.is.zuiFunction(schema.schema)) {
120
120
  return stripSpaces(`${description}
121
121
  declare function ${schema.identifier}${typings};${closingTag}`);
122
122
  }
@@ -124,9 +124,9 @@ declare function ${schema.identifier}${typings};${closingTag}`);
124
124
  declare const ${schema.identifier}: ${typings};${closingTag}`);
125
125
  }
126
126
  if (schema instanceof KeyValue) {
127
- if (schema.value instanceof _zui.z.ZodOptional || schema.value instanceof _zui.z.ZodDefault) {
127
+ if (_zui.z.is.zuiOptional(schema.value) || _zui.z.is.zuiDefault(schema.value)) {
128
128
  let innerType = schema.value._def.innerType;
129
- if (innerType instanceof _zui.z.Schema && !innerType.description && schema.value.description) {
129
+ if (_zui.z.is.zuiType(innerType) && !innerType.description && schema.value.description) {
130
130
  innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
131
131
  }
132
132
  const optionalToken = schema.key.endsWith("?") ? "" : "?";
@@ -138,7 +138,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
138
138
  return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
139
139
  }
140
140
  if (schema instanceof FnParameters) {
141
- if (schema.schema instanceof _zui.z.ZodTuple) {
141
+ if (_zui.z.is.zuiTuple(schema.schema)) {
142
142
  let args = "";
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}`));
@@ -147,7 +147,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
147
147
  }
148
148
  return args;
149
149
  }
150
- const isLiteral = schema.schema.naked() instanceof _zui.z.ZodLiteral;
150
+ const isLiteral = _zui.z.is.zuiLiteral(schema.schema.naked());
151
151
  const typings = (await sUnwrapZodRecursive(schema.schema, newOptions)).trim();
152
152
  const startsWithPairs = typings.startsWith("{") && typings.endsWith("}") || typings.startsWith("[") && typings.endsWith("]") || typings.startsWith("(") && typings.endsWith(")") || typings.startsWith("Array<") && typings.endsWith(">") || typings.startsWith("Record<") && typings.endsWith(">") || isArrayOfPrimitives(typings);
153
153
  if (startsWithPairs || isLiteral) {
@@ -157,27 +157,31 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
157
157
  }
158
158
  }
159
159
  if (schema instanceof FnReturn) {
160
- if (schema.schema instanceof _zui.z.ZodOptional) {
160
+ if (_zui.z.is.zuiOptional(schema.schema)) {
161
161
  return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
162
162
  }
163
163
  return sUnwrapZodRecursive(schema.schema, newOptions);
164
164
  }
165
- if (schema instanceof _zui.z.ZodDefault) {
165
+ if (schema === null) {
166
+ return "unknown";
167
+ }
168
+ schema;
169
+ if (_zui.z.is.zuiDefault(schema)) {
166
170
  return sUnwrapZodRecursive(schema._def.innerType, options);
167
171
  }
168
- if (schema instanceof _zui.z.ZodVoid) {
172
+ if (_zui.z.is.zuiVoid(schema)) {
169
173
  return "void";
170
174
  }
171
- if (schema instanceof _zui.z.ZodUnknown) {
175
+ if (_zui.z.is.zuiUnknown(schema)) {
172
176
  return "unknown";
173
177
  }
174
- if (schema instanceof _zui.z.ZodAny) {
178
+ if (_zui.z.is.zuiAny(schema)) {
175
179
  return "any";
176
180
  }
177
- if (schema instanceof _zui.z.ZodPromise) {
181
+ if (_zui.z.is.zuiPromise(schema)) {
178
182
  return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
179
183
  }
180
- if (schema instanceof _zui.z.ZodFunction) {
184
+ if (_zui.z.is.zuiFunction(schema)) {
181
185
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
182
186
  const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
183
187
  const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
@@ -188,39 +192,39 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
188
192
  return `${description}
189
193
  (${input}) => ${output}`;
190
194
  }
191
- if (schema instanceof _zui.z.ZodArray) {
195
+ if (_zui.z.is.zuiArray(schema)) {
192
196
  const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
193
197
  if (isPrimitive(item)) {
194
198
  return `${item}[]`;
195
199
  }
196
200
  return `Array<${item}>`;
197
201
  }
198
- if (schema instanceof _zui.z.ZodEnum) {
202
+ if (_zui.z.is.zuiEnum(schema)) {
199
203
  const values = schema._def.values.map(_chunk4VYDQ3VFcjs.escapeString);
200
204
  return values.join(" | ");
201
205
  }
202
- if (schema instanceof _zui.z.ZodTuple) {
206
+ if (_zui.z.is.zuiTuple(schema)) {
203
207
  if (schema.items.length === 0) {
204
208
  return "[]";
205
209
  }
206
210
  const items = await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)));
207
211
  return `[${items.join(", ")}]`;
208
212
  }
209
- if (schema instanceof _zui.z.ZodNullable) {
213
+ if (_zui.z.is.zuiNullable(schema)) {
210
214
  return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
211
215
  }
212
- if (schema instanceof _zui.z.ZodOptional) {
213
- if ((options == null ? void 0 : options.declaration) || (options == null ? void 0 : options.parent) instanceof _zui.z.ZodRecord) {
216
+ if (_zui.z.is.zuiOptional(schema)) {
217
+ if ((options == null ? void 0 : options.declaration) || _zui.z.is.zuiType(options == null ? void 0 : options.parent) && options.parent.typeName === "ZodRecord") {
214
218
  return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
215
219
  }
216
220
  const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
217
221
  const val = `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
218
222
  return val;
219
223
  }
220
- if (schema instanceof _zui.z.ZodObject) {
224
+ if (_zui.z.is.zuiObject(schema)) {
221
225
  const props = await Promise.all(
222
226
  Object.entries(schema.shape).map(async ([key, value]) => {
223
- if (value instanceof _zui.z.Schema) {
227
+ if (_zui.z.is.zuiType(value)) {
224
228
  return sUnwrapZodRecursive(new KeyValue(_chunk4VYDQ3VFcjs.toPropertyKey.call(void 0, key), value), newOptions);
225
229
  }
226
230
  return `${key}: unknown`;
@@ -228,11 +232,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
228
232
  );
229
233
  return `{ ${props.join("; ")} }`;
230
234
  }
231
- if (schema instanceof _zui.z.ZodString) {
235
+ if (_zui.z.is.zuiString(schema)) {
232
236
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
233
237
  return `${description} string`.trim();
234
238
  }
235
- if (schema instanceof _zui.z.ZodUnion) {
239
+ if (_zui.z.is.zuiUnion(schema)) {
236
240
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
237
241
  const options2 = await Promise.all(
238
242
  schema.options.map(async (option) => {
@@ -242,26 +246,26 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
242
246
  return `${description}
243
247
  ${options2.join(" | ")}`;
244
248
  }
245
- if (schema instanceof _zui.z.ZodLiteral) {
249
+ if (_zui.z.is.zuiLiteral(schema)) {
246
250
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
247
251
  return `${description}
248
- ${typeof schema.value === "string" ? _chunk4VYDQ3VFcjs.escapeString.call(void 0, schema.value) : schema.value}`.trim();
252
+ ${typeof schema.value === "string" ? _chunk4VYDQ3VFcjs.escapeString.call(void 0, schema.value) : String(schema.value)}`.trim();
249
253
  }
250
- if (schema instanceof _zui.z.ZodNumber) {
254
+ if (_zui.z.is.zuiNumber(schema)) {
251
255
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
252
256
  return `${description} number`.trim();
253
257
  }
254
- if (schema instanceof _zui.z.ZodBoolean) {
258
+ if (_zui.z.is.zuiBoolean(schema)) {
255
259
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
256
260
  return `${description} boolean`.trim();
257
261
  }
258
- if (schema instanceof _zui.z.ZodCatch) {
262
+ if (_zui.z.is.zuiCatch(schema)) {
259
263
  return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
260
264
  }
261
- if (schema instanceof _zui.z.ZodLazy) {
265
+ if (_zui.z.is.zuiLazy(schema)) {
262
266
  return sUnwrapZodRecursive(schema._def.getter(), newOptions);
263
267
  }
264
- if (schema instanceof _zui.z.ZodRecord) {
268
+ if (_zui.z.is.zuiRecord(schema)) {
265
269
  const description = _chunk4VYDQ3VFcjs.getMultilineComment.call(void 0, schema._def.description);
266
270
  const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
267
271
  const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkD3JSHTIKcjs = require('./chunk-D3JSHTIK.cjs');
5
+ var _chunk3SZK4YSRcjs = require('./chunk-3SZK4YSR.cjs');
6
6
 
7
7
 
8
- var _chunkSZLX27VXcjs = require('./chunk-SZLX27VX.cjs');
8
+ var _chunk2JTZOTO5cjs = require('./chunk-2JTZOTO5.cjs');
9
9
 
10
10
 
11
11
  var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
@@ -14,7 +14,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
14
14
  var _chunkF4OZHUMScjs = require('./chunk-F4OZHUMS.cjs');
15
15
 
16
16
 
17
- var _chunkTLOQBZKWcjs = require('./chunk-TLOQBZKW.cjs');
17
+ var _chunkK2B5YEGJcjs = require('./chunk-K2B5YEGJ.cjs');
18
18
 
19
19
 
20
20
  var _chunkUCXQ4U7Pcjs = require('./chunk-UCXQ4U7P.cjs');
@@ -493,10 +493,10 @@ var Snapshot = class _Snapshot {
493
493
  };
494
494
  function parseVariables(variableMap) {
495
495
  return Object.entries(variableMap).map(([name, value]) => {
496
- const type = _chunkD3JSHTIKcjs.extractType.call(void 0, value);
496
+ const type = _chunk3SZK4YSRcjs.extractType.call(void 0, value);
497
497
  const bytes = JSON.stringify(value || "").length;
498
498
  const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
499
- return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkD3JSHTIKcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
499
+ return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunk3SZK4YSRcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
500
500
  });
501
501
  }
502
502
 
@@ -507,9 +507,9 @@ function getMessagePreview(message) {
507
507
  return message.content;
508
508
  }
509
509
  if (message.role === "event") {
510
- return _chunkD3JSHTIKcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
510
+ return _chunk3SZK4YSRcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
511
511
  }
512
- return _chunkD3JSHTIKcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
512
+ return _chunk3SZK4YSRcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
513
513
  }
514
514
  function getMessageType(message) {
515
515
  if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
@@ -1103,7 +1103,7 @@ var Context = (_class2 = class {
1103
1103
 
1104
1104
 
1105
1105
 
1106
- __init3() {this.version = _chunkD3JSHTIKcjs.DualModePrompt}
1106
+ __init3() {this.version = _chunk3SZK4YSRcjs.DualModePrompt}
1107
1107
  __init4() {this.timeout = 6e4}
1108
1108
  // Default timeout of 60 seconds
1109
1109
 
@@ -1279,7 +1279,7 @@ var Context = (_class2 = class {
1279
1279
  var _a, _b;
1280
1280
  const instructions = await getValue(this.instructions, this);
1281
1281
  const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
1282
- const tools = _chunkSZLX27VXcjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1282
+ const tools = _chunk2JTZOTO5cjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1283
1283
  const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
1284
1284
  const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
1285
1285
  const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
@@ -1293,7 +1293,7 @@ var Context = (_class2 = class {
1293
1293
  throw new Error("Too many tools. Expected at most 100 tools.");
1294
1294
  }
1295
1295
  for (const component of components) {
1296
- _chunkTLOQBZKWcjs.assertValidComponent.call(void 0, component.definition);
1296
+ _chunkK2B5YEGJcjs.assertValidComponent.call(void 0, component.definition);
1297
1297
  }
1298
1298
  const ReservedToolNames = [
1299
1299
  "think",
@@ -1312,7 +1312,7 @@ var Context = (_class2 = class {
1312
1312
  "boolean",
1313
1313
  "array"
1314
1314
  ];
1315
- const MessageTool = this.chat && components.length ? new (0, _chunkSZLX27VXcjs.Tool)({
1315
+ const MessageTool = this.chat && components.length ? new (0, _chunk2JTZOTO5cjs.Tool)({
1316
1316
  name: "Message",
1317
1317
  description: "Send a message to the user",
1318
1318
  aliases: Array.from(
@@ -2,10 +2,10 @@ import {
2
2
  DualModePrompt,
3
3
  extractType,
4
4
  inspect
5
- } from "./chunk-WTWIJ2LI.js";
5
+ } from "./chunk-6EAURSDP.js";
6
6
  import {
7
7
  Tool
8
- } from "./chunk-L2ZDZKCB.js";
8
+ } from "./chunk-G5INQ5LJ.js";
9
9
  import {
10
10
  LoopExceededError
11
11
  } from "./chunk-WSVDMGMR.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-E5YW5YQN.js";
15
15
  import {
16
16
  assertValidComponent
17
- } from "./chunk-UOENUUUV.js";
17
+ } from "./chunk-AMQFJRRX.js";
18
18
  import {
19
19
  wrapContent
20
20
  } from "./chunk-M4WTTARE.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-YV5N57D3.js";
3
+ } from "./chunk-LR6KTFHO.js";
4
4
  import {
5
5
  convertObjectToZuiLiterals,
6
6
  isJsonSchema,
@@ -13,7 +13,7 @@ import {
13
13
  } from "./chunk-5XC6ZMS5.js";
14
14
 
15
15
  // src/tool.ts
16
- import { z, transforms, ZodObject, ZodType } from "@bpinternal/zui";
16
+ import { z, transforms } from "@bpinternal/zui";
17
17
  var Tool = class _Tool {
18
18
  _staticInputValues;
19
19
  name;
@@ -71,12 +71,12 @@ var Tool = class _Tool {
71
71
  return this;
72
72
  }
73
73
  const input = this.input ? transforms.fromJSONSchemaLegacy(this.input) : z.any();
74
- if (input instanceof z.ZodObject && typeof values !== "object") {
74
+ if (z.is.zuiObject(input) && typeof values !== "object") {
75
75
  throw new Error(
76
76
  `Invalid static input values for tool ${this.name}. Expected an object, but got type "${typeof values}"`
77
77
  );
78
78
  }
79
- if (input instanceof z.ZodArray && !Array.isArray(values)) {
79
+ if (z.is.zuiArray(input) && !Array.isArray(values)) {
80
80
  throw new Error(
81
81
  `Invalid static input values for tool ${this.name}. Expected an array, but got type "${typeof values}"`
82
82
  );
@@ -106,9 +106,9 @@ var Tool = class _Tool {
106
106
  }
107
107
  if (!isEmpty_default(this._staticInputValues)) {
108
108
  const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
109
- if (input instanceof z.ZodObject) {
109
+ if (z.is.zuiObject(input)) {
110
110
  input = input.extend(inputExtensions);
111
- } else if (input instanceof z.ZodArray) {
111
+ } else if (z.is.zuiArray(input)) {
112
112
  input = z.array(input.element.extend(inputExtensions));
113
113
  } else {
114
114
  input = inputExtensions;
@@ -238,8 +238,8 @@ var Tool = class _Tool {
238
238
  aliases: props.aliases ?? [...this.aliases],
239
239
  description: props.description ?? this.description,
240
240
  metadata: JSON.parse(JSON.stringify(props.metadata ?? this.metadata)),
241
- input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : props.input instanceof ZodType ? props.input : zInput,
242
- output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : props.output instanceof ZodType ? props.output : zOutput,
241
+ input: typeof props.input === "function" ? (_a = props.input) == null ? void 0 : _a.call(props, zInput) : z.is.zuiType(props.input) ? props.input : zInput,
242
+ output: typeof props.output === "function" ? (_b = props.output) == null ? void 0 : _b.call(props, zOutput) : z.is.zuiType(props.output) ? props.output : zOutput,
243
243
  handler: props.handler ?? this._handler,
244
244
  retry: props.retry ?? this.retry
245
245
  }).setStaticInputValues(props.staticInputValues ?? this._staticInputValues);
@@ -472,7 +472,7 @@ var Tool = class _Tool {
472
472
  output = transforms.fromJSONSchemaLegacy(this.output);
473
473
  }
474
474
  }
475
- if ((input == null ? void 0 : input.naked()) instanceof ZodObject && typeof this._staticInputValues === "object" && !isEmpty_default(this._staticInputValues)) {
475
+ if (input && z.is.zuiObject(input.naked()) && typeof this._staticInputValues === "object" && !isEmpty_default(this._staticInputValues)) {
476
476
  const inputExtensions = convertObjectToZuiLiterals(this._staticInputValues);
477
477
  input = input.extend(inputExtensions);
478
478
  } else if (this._staticInputValues !== void 0) {
@@ -80,7 +80,7 @@ function getComponentReference(component) {
80
80
  const naked = schema.naked();
81
81
  const zodType = naked._def.typeName;
82
82
  const defValue = getDefaultValue(schema);
83
- const typings = naked instanceof _zui.z.ZodEnum ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
83
+ const typings = _zui.z.is.zuiEnum(naked) ? naked._def.values.map((x) => `"${x}"`).join(" | ") : zodTypeToTsType[zodType] || zodType;
84
84
  const required = !schema.isOptional() ? "**(required)**" : "(optional)";
85
85
  const def = defValue ? ` _Default: \`${defValue}\`_` : "";
86
86
  const description = schema.description || schema.naked().description || (schema == null ? void 0 : schema._def.description) || "";
@@ -89,7 +89,7 @@ async function getTypings(schema, options) {
89
89
  options ??= {};
90
90
  options.declaration ??= false;
91
91
  let wrappedSchema = schema;
92
- if ((options == null ? void 0 : options.declaration) && schema instanceof z.Schema) {
92
+ if ((options == null ? void 0 : options.declaration) && z.is.zuiType(schema)) {
93
93
  const title = "title" in schema.ui ? schema.ui.title : null;
94
94
  if (!title) {
95
95
  throw new Error('Only schemas with "title" Zui property can be declared.');
@@ -116,7 +116,7 @@ async function sUnwrapZod(schema, options) {
116
116
  const typings = await sUnwrapZodRecursive(withoutDesc, { ...newOptions, declaration: true });
117
117
  const isLargeDeclaration = typings.split("\n").length >= LARGE_DECLARATION_LINES;
118
118
  const closingTag = isLargeDeclaration ? `// end of ${schema.identifier}` : "";
119
- if (schema.schema instanceof z.ZodFunction) {
119
+ if (z.is.zuiFunction(schema.schema)) {
120
120
  return stripSpaces(`${description}
121
121
  declare function ${schema.identifier}${typings};${closingTag}`);
122
122
  }
@@ -124,9 +124,9 @@ declare function ${schema.identifier}${typings};${closingTag}`);
124
124
  declare const ${schema.identifier}: ${typings};${closingTag}`);
125
125
  }
126
126
  if (schema instanceof KeyValue) {
127
- if (schema.value instanceof z.ZodOptional || schema.value instanceof z.ZodDefault) {
127
+ if (z.is.zuiOptional(schema.value) || z.is.zuiDefault(schema.value)) {
128
128
  let innerType = schema.value._def.innerType;
129
- if (innerType instanceof z.Schema && !innerType.description && schema.value.description) {
129
+ if (z.is.zuiType(innerType) && !innerType.description && schema.value.description) {
130
130
  innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
131
131
  }
132
132
  const optionalToken = schema.key.endsWith("?") ? "" : "?";
@@ -138,7 +138,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
138
138
  return `${delimiter}${description}${delimiter}${schema.key}: ${await sUnwrapZodRecursive(withoutDesc, newOptions)}${delimiter}`;
139
139
  }
140
140
  if (schema instanceof FnParameters) {
141
- if (schema.schema instanceof z.ZodTuple) {
141
+ if (z.is.zuiTuple(schema.schema)) {
142
142
  let args = "";
143
143
  for (let i = 0; i < schema.schema.items.length; i++) {
144
144
  const argName = ((_b = (_a = schema.schema.items[i]) == null ? void 0 : _a.ui) == null ? void 0 : _b.title) ?? `arg${i}`;
@@ -147,7 +147,7 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
147
147
  }
148
148
  return args;
149
149
  }
150
- const isLiteral = schema.schema.naked() instanceof z.ZodLiteral;
150
+ const isLiteral = z.is.zuiLiteral(schema.schema.naked());
151
151
  const typings = (await sUnwrapZodRecursive(schema.schema, newOptions)).trim();
152
152
  const startsWithPairs = typings.startsWith("{") && typings.endsWith("}") || typings.startsWith("[") && typings.endsWith("]") || typings.startsWith("(") && typings.endsWith(")") || typings.startsWith("Array<") && typings.endsWith(">") || typings.startsWith("Record<") && typings.endsWith(">") || isArrayOfPrimitives(typings);
153
153
  if (startsWithPairs || isLiteral) {
@@ -157,27 +157,31 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
157
157
  }
158
158
  }
159
159
  if (schema instanceof FnReturn) {
160
- if (schema.schema instanceof z.ZodOptional) {
160
+ if (z.is.zuiOptional(schema.schema)) {
161
161
  return `${await sUnwrapZodRecursive(schema.schema.unwrap(), newOptions)} | undefined`;
162
162
  }
163
163
  return sUnwrapZodRecursive(schema.schema, newOptions);
164
164
  }
165
- if (schema instanceof z.ZodDefault) {
165
+ if (schema === null) {
166
+ return "unknown";
167
+ }
168
+ schema;
169
+ if (z.is.zuiDefault(schema)) {
166
170
  return sUnwrapZodRecursive(schema._def.innerType, options);
167
171
  }
168
- if (schema instanceof z.ZodVoid) {
172
+ if (z.is.zuiVoid(schema)) {
169
173
  return "void";
170
174
  }
171
- if (schema instanceof z.ZodUnknown) {
175
+ if (z.is.zuiUnknown(schema)) {
172
176
  return "unknown";
173
177
  }
174
- if (schema instanceof z.ZodAny) {
178
+ if (z.is.zuiAny(schema)) {
175
179
  return "any";
176
180
  }
177
- if (schema instanceof z.ZodPromise) {
181
+ if (z.is.zuiPromise(schema)) {
178
182
  return `Promise<${await sUnwrapZodRecursive(schema.unwrap(), newOptions)}>`;
179
183
  }
180
- if (schema instanceof z.ZodFunction) {
184
+ if (z.is.zuiFunction(schema)) {
181
185
  const description = getMultilineComment(schema._def.description);
182
186
  const input = await sUnwrapZodRecursive(new FnParameters(schema._def.args), newOptions);
183
187
  const output = await sUnwrapZodRecursive(new FnReturn(schema._def.returns), newOptions);
@@ -188,39 +192,39 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
188
192
  return `${description}
189
193
  (${input}) => ${output}`;
190
194
  }
191
- if (schema instanceof z.ZodArray) {
195
+ if (z.is.zuiArray(schema)) {
192
196
  const item = await sUnwrapZodRecursive(schema._def.type, newOptions);
193
197
  if (isPrimitive(item)) {
194
198
  return `${item}[]`;
195
199
  }
196
200
  return `Array<${item}>`;
197
201
  }
198
- if (schema instanceof z.ZodEnum) {
202
+ if (z.is.zuiEnum(schema)) {
199
203
  const values = schema._def.values.map(escapeString);
200
204
  return values.join(" | ");
201
205
  }
202
- if (schema instanceof z.ZodTuple) {
206
+ if (z.is.zuiTuple(schema)) {
203
207
  if (schema.items.length === 0) {
204
208
  return "[]";
205
209
  }
206
210
  const items = await Promise.all(schema.items.map((i) => sUnwrapZodRecursive(i, newOptions)));
207
211
  return `[${items.join(", ")}]`;
208
212
  }
209
- if (schema instanceof z.ZodNullable) {
213
+ if (z.is.zuiNullable(schema)) {
210
214
  return `${await sUnwrapZodRecursive(schema.unwrap(), options)} | null`;
211
215
  }
212
- if (schema instanceof z.ZodOptional) {
213
- if ((options == null ? void 0 : options.declaration) || (options == null ? void 0 : options.parent) instanceof z.ZodRecord) {
216
+ if (z.is.zuiOptional(schema)) {
217
+ if ((options == null ? void 0 : options.declaration) || z.is.zuiType(options == null ? void 0 : options.parent) && options.parent.typeName === "ZodRecord") {
214
218
  return `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)} | undefined`;
215
219
  }
216
220
  const optionalToken = options.parent instanceof KeyValue ? "| undefined" : "";
217
221
  const val = `${await sUnwrapZodRecursive(schema._def.innerType, newOptions)}${optionalToken}`;
218
222
  return val;
219
223
  }
220
- if (schema instanceof z.ZodObject) {
224
+ if (z.is.zuiObject(schema)) {
221
225
  const props = await Promise.all(
222
226
  Object.entries(schema.shape).map(async ([key, value]) => {
223
- if (value instanceof z.Schema) {
227
+ if (z.is.zuiType(value)) {
224
228
  return sUnwrapZodRecursive(new KeyValue(toPropertyKey(key), value), newOptions);
225
229
  }
226
230
  return `${key}: unknown`;
@@ -228,11 +232,11 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
228
232
  );
229
233
  return `{ ${props.join("; ")} }`;
230
234
  }
231
- if (schema instanceof z.ZodString) {
235
+ if (z.is.zuiString(schema)) {
232
236
  const description = getMultilineComment(schema._def.description);
233
237
  return `${description} string`.trim();
234
238
  }
235
- if (schema instanceof z.ZodUnion) {
239
+ if (z.is.zuiUnion(schema)) {
236
240
  const description = getMultilineComment(schema._def.description);
237
241
  const options2 = await Promise.all(
238
242
  schema.options.map(async (option) => {
@@ -242,26 +246,26 @@ declare const ${schema.identifier}: ${typings};${closingTag}`);
242
246
  return `${description}
243
247
  ${options2.join(" | ")}`;
244
248
  }
245
- if (schema instanceof z.ZodLiteral) {
249
+ if (z.is.zuiLiteral(schema)) {
246
250
  const description = getMultilineComment(schema._def.description);
247
251
  return `${description}
248
- ${typeof schema.value === "string" ? escapeString(schema.value) : schema.value}`.trim();
252
+ ${typeof schema.value === "string" ? escapeString(schema.value) : String(schema.value)}`.trim();
249
253
  }
250
- if (schema instanceof z.ZodNumber) {
254
+ if (z.is.zuiNumber(schema)) {
251
255
  const description = getMultilineComment(schema._def.description);
252
256
  return `${description} number`.trim();
253
257
  }
254
- if (schema instanceof z.ZodBoolean) {
258
+ if (z.is.zuiBoolean(schema)) {
255
259
  const description = getMultilineComment(schema._def.description);
256
260
  return `${description} boolean`.trim();
257
261
  }
258
- if (schema instanceof z.ZodCatch) {
262
+ if (z.is.zuiCatch(schema)) {
259
263
  return sUnwrapZodRecursive(schema.removeCatch(), newOptions);
260
264
  }
261
- if (schema instanceof z.ZodLazy) {
265
+ if (z.is.zuiLazy(schema)) {
262
266
  return sUnwrapZodRecursive(schema._def.getter(), newOptions);
263
267
  }
264
- if (schema instanceof z.ZodRecord) {
268
+ if (z.is.zuiRecord(schema)) {
265
269
  const description = getMultilineComment(schema._def.description);
266
270
  const keyType = await sUnwrapZodRecursive(schema._def.keyType, newOptions);
267
271
  const valueType = await sUnwrapZodRecursive(schema._def.valueType, newOptions);