llmz 0.0.33 → 0.0.35

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 (27) hide show
  1. package/dist/{chunk-U4HWJLF2.js → chunk-B42FGPCX.js} +1 -1
  2. package/dist/{chunk-4XIOQWVZ.cjs → chunk-B742DUFY.cjs} +36 -16
  3. package/dist/{chunk-AAHUDKBY.js → chunk-DOIKBDLR.js} +2 -2
  4. package/dist/{chunk-23SY6IDW.js → chunk-GXLMCQYF.js} +9 -8
  5. package/dist/{chunk-GGWM6X2K.js → chunk-HA52ORZL.js} +0 -2
  6. package/dist/{chunk-INDOGCAQ.cjs → chunk-KED57HR5.cjs} +1 -1
  7. package/dist/{chunk-SOEKWFU2.cjs → chunk-QR54TZ36.cjs} +10 -9
  8. package/dist/{chunk-5BEKU5MZ.cjs → chunk-QRFGEFRO.cjs} +3 -3
  9. package/dist/{chunk-ZRCU35UV.cjs → chunk-QY2TRWGK.cjs} +0 -2
  10. package/dist/{chunk-4JN4PPGP.js → chunk-RANA7NBF.js} +31 -11
  11. package/dist/component-AAEMNCHB.cjs +18 -0
  12. package/dist/{component-WFVDVSDK.js → component-EOMTLA64.js} +1 -1
  13. package/dist/{dual-modes-UBHAMQW4.cjs → dual-modes-MHUM2LEI.cjs} +3 -3
  14. package/dist/{dual-modes-LEAHGCOF.js → dual-modes-NJGSJEE4.js} +2 -2
  15. package/dist/index.cjs +43 -35
  16. package/dist/index.js +29 -21
  17. package/dist/{llmz-3E2JM3HM.js → llmz-NX2764TL.js} +12 -9
  18. package/dist/{llmz-HGUVAYIN.cjs → llmz-XRJIDXIZ.cjs} +21 -18
  19. package/dist/llmz.d.ts +2 -1
  20. package/dist/snapshots.d.ts +1 -1
  21. package/dist/{tool-7QXH6A24.js → tool-ADXBCB4R.js} +2 -2
  22. package/dist/{tool-JVLOALQN.cjs → tool-JYXLFJGQ.cjs} +3 -3
  23. package/dist/tool.d.ts +2 -2
  24. package/dist/{typings-OLI56LGT.cjs → typings-7C2RXO75.cjs} +2 -2
  25. package/dist/{typings-ALZEKGV6.js → typings-AQGJAMVH.js} +1 -1
  26. package/package.json +5 -4
  27. package/dist/component-R4WTW6DZ.cjs +0 -18
@@ -124,7 +124,7 @@ 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) {
127
+ if (schema.value instanceof z.ZodOptional || schema.value instanceof z.ZodDefault) {
128
128
  let innerType = schema.value._def.innerType;
129
129
  if (innerType instanceof z.Schema && !innerType.description && schema.value.description) {
130
130
  innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk5BEKU5MZcjs = require('./chunk-5BEKU5MZ.cjs');
5
+ var _chunkQRFGEFROcjs = require('./chunk-QRFGEFRO.cjs');
6
6
 
7
7
 
8
- var _chunkSOEKWFU2cjs = require('./chunk-SOEKWFU2.cjs');
8
+ var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.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 _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
15
15
 
16
16
 
17
- var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
17
+ var _chunkQY2TRWGKcjs = require('./chunk-QY2TRWGK.cjs');
18
18
 
19
19
 
20
20
  var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
@@ -346,17 +346,11 @@ var Snapshot = class _Snapshot {
346
346
  * @internal
347
347
  */
348
348
  static fromSignal(signal) {
349
- const variables = Object.entries(signal.variables).map(([name, value]) => {
350
- const type = _chunk5BEKU5MZcjs.extractType.call(void 0, value);
351
- const bytes = JSON.stringify(value || "").length;
352
- const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
353
- return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunk5BEKU5MZcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
354
- });
355
349
  return new _Snapshot({
356
350
  id: "snapshot_" + _ulid.ulid.call(void 0, ),
357
351
  reason: signal.message,
358
352
  stack: signal.truncatedCode,
359
- variables,
353
+ variables: parseVariables(signal.variables),
360
354
  toolCall: signal.toolCall,
361
355
  status: { type: "pending" }
362
356
  });
@@ -453,9 +447,19 @@ var Snapshot = class _Snapshot {
453
447
  * ```
454
448
  */
455
449
  resolve(value) {
450
+ var _a;
456
451
  if (this.#status.type !== "pending") {
457
452
  throw new Error(`Cannot resolve snapshot because it is already settled: ${this.#status.type}`);
458
453
  }
454
+ const assignment = (_a = this.toolCall) == null ? void 0 : _a.assignment;
455
+ if (assignment) {
456
+ try {
457
+ const fn = new Function(assignment.evalFn);
458
+ const assignmentValue = fn(value);
459
+ this.variables = [...this.variables, ...parseVariables(assignmentValue)];
460
+ } catch (e2) {
461
+ }
462
+ }
459
463
  this.#status = { type: "resolved", value };
460
464
  }
461
465
  /**
@@ -487,6 +491,14 @@ var Snapshot = class _Snapshot {
487
491
  this.#status = { type: "rejected", error };
488
492
  }
489
493
  };
494
+ function parseVariables(variableMap) {
495
+ return Object.entries(variableMap).map(([name, value]) => {
496
+ const type = _chunkQRFGEFROcjs.extractType.call(void 0, value);
497
+ const bytes = JSON.stringify(value || "").length;
498
+ const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
499
+ return truncated ? { name, type, bytes, truncated: true, preview: _nullishCoalesce(_chunkQRFGEFROcjs.inspect.call(void 0, value, name), () => ( "N/A")) } : { name, type, bytes, truncated: false, value };
500
+ });
501
+ }
490
502
 
491
503
  // src/transcript.ts
492
504
  var MAX_MESSAGE_LENGTH = 5e3;
@@ -495,9 +507,9 @@ function getMessagePreview(message) {
495
507
  return message.content;
496
508
  }
497
509
  if (message.role === "event") {
498
- return _chunk5BEKU5MZcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
510
+ return _chunkQRFGEFROcjs.inspect.call(void 0, message.payload, message.name, { tokens: 1e3 });
499
511
  }
500
- return _chunk5BEKU5MZcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
512
+ return _chunkQRFGEFROcjs.inspect.call(void 0, message, void 0, { tokens: 1e3 });
501
513
  }
502
514
  function getMessageType(message) {
503
515
  if (message.role === "assistant" || message.role === "user" || message.role === "summary") {
@@ -1086,7 +1098,7 @@ var Context = (_class2 = class {
1086
1098
 
1087
1099
 
1088
1100
 
1089
- __init3() {this.version = _chunk5BEKU5MZcjs.DualModePrompt}
1101
+ __init3() {this.version = _chunkQRFGEFROcjs.DualModePrompt}
1090
1102
  __init4() {this.timeout = 6e4}
1091
1103
  // Default timeout of 60 seconds
1092
1104
 
@@ -1117,6 +1129,7 @@ var Context = (_class2 = class {
1117
1129
  return iteration;
1118
1130
  }
1119
1131
  _getIterationVariables() {
1132
+ var _a;
1120
1133
  const lastIteration = this.iterations.at(-1);
1121
1134
  const variables = {};
1122
1135
  if ((lastIteration == null ? void 0 : lastIteration.status.type) === "thinking_requested") {
@@ -1128,6 +1141,13 @@ var Context = (_class2 = class {
1128
1141
  if (_chunkUQOBUJIQcjs.isPlainObject_default.call(void 0, lastIteration == null ? void 0 : lastIteration.variables)) {
1129
1142
  Object.assign(variables, _chunkUQOBUJIQcjs.cloneDeep_default.call(void 0, _nullishCoalesce((lastIteration == null ? void 0 : lastIteration.variables), () => ( {}))));
1130
1143
  }
1144
+ if (((_a = this.snapshot) == null ? void 0 : _a.status.type) === "resolved") {
1145
+ for (const v of this.snapshot.variables) {
1146
+ if (!v.truncated && v.value !== void 0) {
1147
+ variables[v.name] = v.value;
1148
+ }
1149
+ }
1150
+ }
1131
1151
  return variables;
1132
1152
  }
1133
1153
  async _getIterationMessages(parameters) {
@@ -1254,7 +1274,7 @@ var Context = (_class2 = class {
1254
1274
  var _a, _b;
1255
1275
  const instructions = await getValue(this.instructions, this);
1256
1276
  const transcript = new TranscriptArray(await getValue(_nullishCoalesce(((_a = this.chat) == null ? void 0 : _a.transcript), () => ( [])), this));
1257
- const tools = _chunkSOEKWFU2cjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1277
+ const tools = _chunkQR54TZ36cjs.Tool.withUniqueNames(await _asyncNullishCoalesce(await getValue(this.tools, this), async () => ( [])));
1258
1278
  const objects = await _asyncNullishCoalesce(await getValue(this.objects, this), async () => ( []));
1259
1279
  const exits = await _asyncNullishCoalesce(await getValue(this.exits, this), async () => ( []));
1260
1280
  const components = await getValue(_nullishCoalesce(((_b = this.chat) == null ? void 0 : _b.components), () => ( [])), this);
@@ -1267,7 +1287,7 @@ var Context = (_class2 = class {
1267
1287
  throw new Error("Too many tools. Expected at most 100 tools.");
1268
1288
  }
1269
1289
  for (const component of components) {
1270
- _chunkZRCU35UVcjs.assertValidComponent.call(void 0, component.definition);
1290
+ _chunkQY2TRWGKcjs.assertValidComponent.call(void 0, component.definition);
1271
1291
  }
1272
1292
  const ReservedToolNames = [
1273
1293
  "think",
@@ -1286,7 +1306,7 @@ var Context = (_class2 = class {
1286
1306
  "boolean",
1287
1307
  "array"
1288
1308
  ];
1289
- const MessageTool = this.chat && components.length ? new (0, _chunkSOEKWFU2cjs.Tool)({
1309
+ const MessageTool = this.chat && components.length ? new (0, _chunkQR54TZ36cjs.Tool)({
1290
1310
  name: "Message",
1291
1311
  description: "Send a message to the user",
1292
1312
  aliases: Array.from(
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-YEAWWJSJ.js";
4
4
  import {
5
5
  getComponentReference
6
- } from "./chunk-GGWM6X2K.js";
6
+ } from "./chunk-HA52ORZL.js";
7
7
  import {
8
8
  wrapContent
9
9
  } from "./chunk-3JYCCI4S.js";
@@ -449,7 +449,7 @@ var getSystemMessage = async (props) => {
449
449
 
450
450
  `;
451
451
  }
452
- for (const tool of props.globalTools) {
452
+ for (const tool of props.globalTools.filter((t) => t.name.toLowerCase() !== "message")) {
453
453
  dts += await tool.getTypings() + "\n";
454
454
  tool_names.push(tool.name);
455
455
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-U4HWJLF2.js";
3
+ } from "./chunk-B42FGPCX.js";
4
4
  import {
5
5
  convertObjectToZuiLiterals,
6
6
  isJsonSchema,
@@ -123,14 +123,15 @@ var Tool = class _Tool {
123
123
  * @internal
124
124
  */
125
125
  get zOutput() {
126
- if (!this.output) {
127
- return z.void();
128
- }
129
- try {
130
- return transforms.fromJSONSchema(this.output);
131
- } catch {
132
- return transforms.fromJSONSchemaLegacy(this.output);
126
+ let output = z.void();
127
+ if (this.output) {
128
+ try {
129
+ output = transforms.fromJSONSchema(this.output);
130
+ } catch {
131
+ output = transforms.fromJSONSchemaLegacy(this.output);
132
+ }
133
133
  }
134
+ return z.promise(output);
134
135
  }
135
136
  /**
136
137
  * Renames the tool and updates its aliases.
@@ -121,8 +121,6 @@ ${example.code.trim()}
121
121
  default:
122
122
  doc += "**Props:**\n\n";
123
123
  doc += getPropsDoc(component.default.props);
124
- doc += "**Children:**\n\n";
125
- doc += getChildrenDoc(component.default.children);
126
124
  doc += getExamplesDoc(component.examples);
127
125
  break;
128
126
  }
@@ -124,7 +124,7 @@ 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) {
127
+ if (schema.value instanceof _zui.z.ZodOptional || schema.value instanceof _zui.z.ZodDefault) {
128
128
  let innerType = schema.value._def.innerType;
129
129
  if (innerType instanceof _zui.z.Schema && !innerType.description && schema.value.description) {
130
130
  innerType = innerType == null ? void 0 : innerType.describe(schema.value.description);
@@ -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 _chunkINDOGCAQcjs = require('./chunk-INDOGCAQ.cjs');
3
+ var _chunkKED57HR5cjs = require('./chunk-KED57HR5.cjs');
4
4
 
5
5
 
6
6
 
@@ -123,14 +123,15 @@ var Tool = (_class = class _Tool {
123
123
  * @internal
124
124
  */
125
125
  get zOutput() {
126
- if (!this.output) {
127
- return _zui.z.void();
128
- }
129
- try {
130
- return _zui.transforms.fromJSONSchema(this.output);
131
- } catch (e3) {
132
- return _zui.transforms.fromJSONSchemaLegacy(this.output);
126
+ let output = _zui.z.void();
127
+ if (this.output) {
128
+ try {
129
+ output = _zui.transforms.fromJSONSchema(this.output);
130
+ } catch (e3) {
131
+ output = _zui.transforms.fromJSONSchemaLegacy(this.output);
132
+ }
133
133
  }
134
+ return _zui.z.promise(output);
134
135
  }
135
136
  /**
136
137
  * Renames the tool and updates its aliases.
@@ -476,7 +477,7 @@ var Tool = (_class = class _Tool {
476
477
  input = _chunkWHNOR4ZUcjs.convertObjectToZuiLiterals.call(void 0, this._staticInputValues);
477
478
  }
478
479
  const fnType = _zui.z.function(input, _zui.z.promise(output)).title(this.name).describe(_nullishCoalesce(this.description, () => ( "")));
479
- return _chunkINDOGCAQcjs.getTypings.call(void 0, fnType, {
480
+ return _chunkKED57HR5cjs.getTypings.call(void 0, fnType, {
480
481
  declaration: true
481
482
  });
482
483
  }
@@ -3,7 +3,7 @@
3
3
  var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
4
4
 
5
5
 
6
- var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
6
+ var _chunkQY2TRWGKcjs = require('./chunk-QY2TRWGK.cjs');
7
7
 
8
8
 
9
9
  var _chunkGZPN7RGHcjs = require('./chunk-GZPN7RGH.cjs');
@@ -449,7 +449,7 @@ var getSystemMessage = async (props) => {
449
449
 
450
450
  `;
451
451
  }
452
- for (const tool of props.globalTools) {
452
+ for (const tool of props.globalTools.filter((t) => t.name.toLowerCase() !== "message")) {
453
453
  dts += await tool.getTypings() + "\n";
454
454
  tool_names.push(tool.name);
455
455
  }
@@ -509,7 +509,7 @@ ${variables_example}
509
509
  variables_example,
510
510
  exits,
511
511
  components: _chunkGZPN7RGHcjs.wrapContent.call(void 0,
512
- props.components.map((component) => _chunkZRCU35UVcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
512
+ props.components.map((component) => _chunkQY2TRWGKcjs.getComponentReference.call(void 0, component.definition)).join("\n\n"),
513
513
  {
514
514
  preserve: "top",
515
515
  minTokens: 500
@@ -121,8 +121,6 @@ ${example.code.trim()}
121
121
  default:
122
122
  doc += "**Props:**\n\n";
123
123
  doc += getPropsDoc(component.default.props);
124
- doc += "**Children:**\n\n";
125
- doc += getChildrenDoc(component.default.children);
126
124
  doc += getExamplesDoc(component.examples);
127
125
  break;
128
126
  }
@@ -2,10 +2,10 @@ import {
2
2
  DualModePrompt,
3
3
  extractType,
4
4
  inspect
5
- } from "./chunk-AAHUDKBY.js";
5
+ } from "./chunk-DOIKBDLR.js";
6
6
  import {
7
7
  Tool
8
- } from "./chunk-23SY6IDW.js";
8
+ } from "./chunk-GXLMCQYF.js";
9
9
  import {
10
10
  LoopExceededError
11
11
  } from "./chunk-WSVDMGMR.js";
@@ -14,7 +14,7 @@ import {
14
14
  } from "./chunk-VPTFUOIK.js";
15
15
  import {
16
16
  assertValidComponent
17
- } from "./chunk-GGWM6X2K.js";
17
+ } from "./chunk-HA52ORZL.js";
18
18
  import {
19
19
  wrapContent
20
20
  } from "./chunk-3JYCCI4S.js";
@@ -315,8 +315,8 @@ var Snapshot = class _Snapshot {
315
315
  id;
316
316
  reason;
317
317
  stack;
318
- variables;
319
318
  toolCall;
319
+ variables;
320
320
  #status;
321
321
  /**
322
322
  * Gets the current status of the snapshot.
@@ -346,17 +346,11 @@ var Snapshot = class _Snapshot {
346
346
  * @internal
347
347
  */
348
348
  static fromSignal(signal) {
349
- const variables = Object.entries(signal.variables).map(([name, value]) => {
350
- const type = extractType(value);
351
- const bytes = JSON.stringify(value || "").length;
352
- const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
353
- return truncated ? { name, type, bytes, truncated: true, preview: inspect(value, name) ?? "N/A" } : { name, type, bytes, truncated: false, value };
354
- });
355
349
  return new _Snapshot({
356
350
  id: "snapshot_" + ulid(),
357
351
  reason: signal.message,
358
352
  stack: signal.truncatedCode,
359
- variables,
353
+ variables: parseVariables(signal.variables),
360
354
  toolCall: signal.toolCall,
361
355
  status: { type: "pending" }
362
356
  });
@@ -453,9 +447,19 @@ var Snapshot = class _Snapshot {
453
447
  * ```
454
448
  */
455
449
  resolve(value) {
450
+ var _a;
456
451
  if (this.#status.type !== "pending") {
457
452
  throw new Error(`Cannot resolve snapshot because it is already settled: ${this.#status.type}`);
458
453
  }
454
+ const assignment = (_a = this.toolCall) == null ? void 0 : _a.assignment;
455
+ if (assignment) {
456
+ try {
457
+ const fn = new Function(assignment.evalFn);
458
+ const assignmentValue = fn(value);
459
+ this.variables = [...this.variables, ...parseVariables(assignmentValue)];
460
+ } catch {
461
+ }
462
+ }
459
463
  this.#status = { type: "resolved", value };
460
464
  }
461
465
  /**
@@ -487,6 +491,14 @@ var Snapshot = class _Snapshot {
487
491
  this.#status = { type: "rejected", error };
488
492
  }
489
493
  };
494
+ function parseVariables(variableMap) {
495
+ return Object.entries(variableMap).map(([name, value]) => {
496
+ const type = extractType(value);
497
+ const bytes = JSON.stringify(value || "").length;
498
+ const truncated = bytes > MAX_SNAPSHOT_SIZE_BYTES;
499
+ return truncated ? { name, type, bytes, truncated: true, preview: inspect(value, name) ?? "N/A" } : { name, type, bytes, truncated: false, value };
500
+ });
501
+ }
490
502
 
491
503
  // src/transcript.ts
492
504
  var MAX_MESSAGE_LENGTH = 5e3;
@@ -1117,6 +1129,7 @@ var Context = class {
1117
1129
  return iteration;
1118
1130
  }
1119
1131
  _getIterationVariables() {
1132
+ var _a;
1120
1133
  const lastIteration = this.iterations.at(-1);
1121
1134
  const variables = {};
1122
1135
  if ((lastIteration == null ? void 0 : lastIteration.status.type) === "thinking_requested") {
@@ -1128,6 +1141,13 @@ var Context = class {
1128
1141
  if (isPlainObject_default(lastIteration == null ? void 0 : lastIteration.variables)) {
1129
1142
  Object.assign(variables, cloneDeep_default((lastIteration == null ? void 0 : lastIteration.variables) ?? {}));
1130
1143
  }
1144
+ if (((_a = this.snapshot) == null ? void 0 : _a.status.type) === "resolved") {
1145
+ for (const v of this.snapshot.variables) {
1146
+ if (!v.truncated && v.value !== void 0) {
1147
+ variables[v.name] = v.value;
1148
+ }
1149
+ }
1150
+ }
1131
1151
  return variables;
1132
1152
  }
1133
1153
  async _getIterationMessages(parameters) {
@@ -0,0 +1,18 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+
8
+ var _chunkQY2TRWGKcjs = require('./chunk-QY2TRWGK.cjs');
9
+ require('./chunk-KMZDFWYZ.cjs');
10
+ require('./chunk-UQOBUJIQ.cjs');
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+ exports.Component = _chunkQY2TRWGKcjs.Component; exports.assertValidComponent = _chunkQY2TRWGKcjs.assertValidComponent; exports.getComponentReference = _chunkQY2TRWGKcjs.getComponentReference; exports.isAnyComponent = _chunkQY2TRWGKcjs.isAnyComponent; exports.isComponent = _chunkQY2TRWGKcjs.isComponent; exports.renderToTsx = _chunkQY2TRWGKcjs.renderToTsx;
@@ -5,7 +5,7 @@ import {
5
5
  isAnyComponent,
6
6
  isComponent,
7
7
  renderToTsx
8
- } from "./chunk-GGWM6X2K.js";
8
+ } from "./chunk-HA52ORZL.js";
9
9
  import "./chunk-ORQP26SZ.js";
10
10
  import "./chunk-7WRN4E42.js";
11
11
  export {
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk5BEKU5MZcjs = require('./chunk-5BEKU5MZ.cjs');
3
+ var _chunkQRFGEFROcjs = require('./chunk-QRFGEFRO.cjs');
4
4
  require('./chunk-KIN7Y247.cjs');
5
- require('./chunk-ZRCU35UV.cjs');
5
+ require('./chunk-QY2TRWGK.cjs');
6
6
  require('./chunk-KMZDFWYZ.cjs');
7
7
  require('./chunk-GZPN7RGH.cjs');
8
8
  require('./chunk-WHNOR4ZU.cjs');
9
9
  require('./chunk-UQOBUJIQ.cjs');
10
10
 
11
11
 
12
- exports.DualModePrompt = _chunk5BEKU5MZcjs.DualModePrompt;
12
+ exports.DualModePrompt = _chunkQRFGEFROcjs.DualModePrompt;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  DualModePrompt
3
- } from "./chunk-AAHUDKBY.js";
3
+ } from "./chunk-DOIKBDLR.js";
4
4
  import "./chunk-YEAWWJSJ.js";
5
- import "./chunk-GGWM6X2K.js";
5
+ import "./chunk-HA52ORZL.js";
6
6
  import "./chunk-ORQP26SZ.js";
7
7
  import "./chunk-3JYCCI4S.js";
8
8
  import "./chunk-ZORRILUV.js";
package/dist/index.cjs CHANGED
@@ -9,15 +9,15 @@
9
9
 
10
10
 
11
11
 
12
- var _chunk4XIOQWVZcjs = require('./chunk-4XIOQWVZ.cjs');
13
- require('./chunk-5BEKU5MZ.cjs');
12
+ var _chunkB742DUFYcjs = require('./chunk-B742DUFY.cjs');
13
+ require('./chunk-QRFGEFRO.cjs');
14
14
 
15
15
 
16
- var _chunkSOEKWFU2cjs = require('./chunk-SOEKWFU2.cjs');
16
+ var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.cjs');
17
17
 
18
18
 
19
19
 
20
- var _chunkINDOGCAQcjs = require('./chunk-INDOGCAQ.cjs');
20
+ var _chunkKED57HR5cjs = require('./chunk-KED57HR5.cjs');
21
21
 
22
22
 
23
23
 
@@ -34,7 +34,7 @@ var _chunk3G3BS5IAcjs = require('./chunk-3G3BS5IA.cjs');
34
34
 
35
35
 
36
36
 
37
- var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
37
+ var _chunkQY2TRWGKcjs = require('./chunk-QY2TRWGK.cjs');
38
38
  require('./chunk-KMZDFWYZ.cjs');
39
39
 
40
40
 
@@ -302,7 +302,7 @@ async function hoistTypings(code, formatOptions) {
302
302
  break;
303
303
  }
304
304
  }
305
- return _chunkINDOGCAQcjs.formatTypings.call(void 0, code, formatOptions);
305
+ return _chunkKED57HR5cjs.formatTypings.call(void 0, code, formatOptions);
306
306
  }
307
307
 
308
308
  // src/objects.ts
@@ -428,7 +428,7 @@ var ObjectInstance = class {
428
428
  this.description = props.description;
429
429
  this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
430
430
  this.properties = props.properties;
431
- this.tools = _chunkSOEKWFU2cjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
431
+ this.tools = _chunkQR54TZ36cjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
432
432
  }
433
433
  /**
434
434
  * Generates TypeScript namespace declarations for this object.
@@ -509,7 +509,7 @@ function getObjectTypings(obj) {
509
509
  }
510
510
  let type = "unknown";
511
511
  if (prop.type) {
512
- type = await _chunkINDOGCAQcjs.getTypings.call(void 0, prop.type, {});
512
+ type = await _chunkKED57HR5cjs.getTypings.call(void 0, prop.type, {});
513
513
  } else if (prop.value !== void 0) {
514
514
  type = typeof prop.value;
515
515
  }
@@ -529,7 +529,7 @@ function getObjectTypings(obj) {
529
529
  typings.push("");
530
530
  for (const tool of obj.tools) {
531
531
  const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
532
- let temp = await _chunkINDOGCAQcjs.getTypings.call(void 0, fnType, {
532
+ let temp = await _chunkKED57HR5cjs.getTypings.call(void 0, fnType, {
533
533
  declaration: true
534
534
  });
535
535
  temp = temp.replace("declare function ", "function ");
@@ -552,7 +552,7 @@ function getObjectTypings(obj) {
552
552
  if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
553
553
  header = _chunkWHNOR4ZUcjs.getMultilineComment.call(void 0, obj.description);
554
554
  }
555
- return _chunkINDOGCAQcjs.formatTypings.call(void 0,
555
+ return _chunkKED57HR5cjs.formatTypings.call(void 0,
556
556
  `${header}
557
557
  export namespace ${obj.name} {
558
558
  ${body}
@@ -766,7 +766,7 @@ var CitationsManager = (_class = class {constructor() { _class.prototype.__init.
766
766
 
767
767
  // src/component.default.ts
768
768
 
769
- var Button = new (0, _chunkZRCU35UVcjs.Component)({
769
+ var Button = new (0, _chunkQY2TRWGKcjs.Component)({
770
770
  type: "leaf",
771
771
  description: "A button component that can perform actions when clicked",
772
772
  name: "Button",
@@ -775,28 +775,30 @@ var Button = new (0, _chunkZRCU35UVcjs.Component)({
775
775
  {
776
776
  name: "Say action",
777
777
  description: "A button that triggers a say action",
778
- code: `<Message>
778
+ code: `yield <Message>
779
779
  <Button action="say" label="Hello" />
780
780
  </Message>`
781
781
  },
782
782
  {
783
783
  name: "Postback action",
784
784
  description: "A button that sends a postback value",
785
- code: `<Message>
785
+ code: `yield <Message>
786
+ Choose an option:
786
787
  <Button action="postback" label="Buy" value="buy_product" />
788
+ <Button action="postback" label="Buy" value="buy_product2" />
787
789
  </Message>`
788
790
  }
789
791
  ],
790
792
  leaf: {
791
793
  props: _zui.z.object({
792
794
  action: _zui.z.enum(["say", "url", "postback"]).default("say").describe('The action to perform when the button is clicked. Can be "say", "url", or "postback"'),
793
- label: _zui.z.string().describe("The text displayed on the button"),
795
+ label: _zui.z.string().describe("The text displayed on the button (min 1 character, max 250 characters)"),
794
796
  value: _zui.z.string().optional().describe('The postback value to send when the button is clicked. Required if action is "postback"'),
795
797
  url: _zui.z.string().optional().describe('The URL to open when the button is clicked. Required if action is "url"')
796
798
  })
797
799
  }
798
800
  });
799
- var Image = new (0, _chunkZRCU35UVcjs.Component)({
801
+ var Image = new (0, _chunkQY2TRWGKcjs.Component)({
800
802
  type: "leaf",
801
803
  name: "Image",
802
804
  description: "Displays an image from a URL.",
@@ -805,7 +807,8 @@ var Image = new (0, _chunkZRCU35UVcjs.Component)({
805
807
  {
806
808
  name: "Basic image",
807
809
  description: "A simple image with alt text",
808
- code: `<Message>
810
+ code: `yield <Message>
811
+ An example image:
809
812
  <Image url="https://example.com/photo.jpg" alt="Example image" />
810
813
  </Message>`
811
814
  }
@@ -817,7 +820,7 @@ var Image = new (0, _chunkZRCU35UVcjs.Component)({
817
820
  })
818
821
  }
819
822
  });
820
- var File = new (0, _chunkZRCU35UVcjs.Component)({
823
+ var File = new (0, _chunkQY2TRWGKcjs.Component)({
821
824
  type: "leaf",
822
825
  name: "File",
823
826
  description: "Sends a downloadable file to the user.",
@@ -826,7 +829,8 @@ var File = new (0, _chunkZRCU35UVcjs.Component)({
826
829
  {
827
830
  name: "PDF download",
828
831
  description: "Send a PDF file with a name",
829
- code: `<Message>
832
+ code: `yield <Message>
833
+ Here is your report:
830
834
  <File url="https://example.com/report.pdf" name="Report.pdf" />
831
835
  </Message>`
832
836
  }
@@ -838,7 +842,7 @@ var File = new (0, _chunkZRCU35UVcjs.Component)({
838
842
  })
839
843
  }
840
844
  });
841
- var Video = new (0, _chunkZRCU35UVcjs.Component)({
845
+ var Video = new (0, _chunkQY2TRWGKcjs.Component)({
842
846
  type: "leaf",
843
847
  name: "Video",
844
848
  description: "Embeds a video from a URL.",
@@ -847,7 +851,8 @@ var Video = new (0, _chunkZRCU35UVcjs.Component)({
847
851
  {
848
852
  name: "Intro video",
849
853
  description: "A video with a title",
850
- code: `<Message>
854
+ code: `yield <Message>
855
+ Watch this video:
851
856
  <Video url="https://example.com/intro.mp4" title="Welcome" />
852
857
  </Message>`
853
858
  }
@@ -859,7 +864,7 @@ var Video = new (0, _chunkZRCU35UVcjs.Component)({
859
864
  })
860
865
  }
861
866
  });
862
- var Audio = new (0, _chunkZRCU35UVcjs.Component)({
867
+ var Audio = new (0, _chunkQY2TRWGKcjs.Component)({
863
868
  type: "leaf",
864
869
  name: "Audio",
865
870
  description: "Plays an audio clip from a URL.",
@@ -868,7 +873,8 @@ var Audio = new (0, _chunkZRCU35UVcjs.Component)({
868
873
  {
869
874
  name: "Sample audio",
870
875
  description: "Play a short audio clip with a title",
871
- code: `<Message>
876
+ code: `yield <Message>
877
+ Listen to this audio:
872
878
  <Audio url="https://example.com/audio.mp3" title="Sample" />
873
879
  </Message>`
874
880
  }
@@ -880,7 +886,7 @@ var Audio = new (0, _chunkZRCU35UVcjs.Component)({
880
886
  })
881
887
  }
882
888
  });
883
- var Card = new (0, _chunkZRCU35UVcjs.Component)({
889
+ var Card = new (0, _chunkQY2TRWGKcjs.Component)({
884
890
  type: "container",
885
891
  name: "Card",
886
892
  description: "A visual card component that can include an image and buttons.",
@@ -889,7 +895,8 @@ var Card = new (0, _chunkZRCU35UVcjs.Component)({
889
895
  {
890
896
  name: "Product card",
891
897
  description: "A card with an image and two buttons",
892
- code: `<Message>
898
+ code: `yield <Message>
899
+ Featured product:
893
900
  <Card title="Product Name" subtitle="Limited offer">
894
901
  <Image url="https://example.com/product.jpg" alt="Product image" />
895
902
  <Button action="postback" label="Buy" value="buy_product" />
@@ -915,7 +922,7 @@ var Card = new (0, _chunkZRCU35UVcjs.Component)({
915
922
  ]
916
923
  }
917
924
  });
918
- var Carousel = new (0, _chunkZRCU35UVcjs.Component)({
925
+ var Carousel = new (0, _chunkQY2TRWGKcjs.Component)({
919
926
  type: "container",
920
927
  name: "Carousel",
921
928
  description: "A virtual container for displaying 1 to 10 Card components as a carousel.",
@@ -924,7 +931,8 @@ var Carousel = new (0, _chunkZRCU35UVcjs.Component)({
924
931
  {
925
932
  name: "Product carousel",
926
933
  description: "A carousel with multiple cards",
927
- code: `<Message>
934
+ code: `yield <Message>
935
+ Here are some products you might like:
928
936
  <Carousel>
929
937
  <Card title="Item 1" subtitle="First product">
930
938
  <Image url="https://example.com/item1.jpg" alt="Item 1" />
@@ -948,7 +956,7 @@ var Carousel = new (0, _chunkZRCU35UVcjs.Component)({
948
956
  ]
949
957
  }
950
958
  });
951
- var Text = new (0, _chunkZRCU35UVcjs.Component)({
959
+ var Text = new (0, _chunkQY2TRWGKcjs.Component)({
952
960
  type: "default",
953
961
  name: "Message",
954
962
  aliases: ["Text", "Markdown"],
@@ -957,7 +965,7 @@ var Text = new (0, _chunkZRCU35UVcjs.Component)({
957
965
  {
958
966
  name: "Basic Markdown",
959
967
  description: "Simple markdown content inside a message",
960
- code: `<Message>
968
+ code: `yield <Message>
961
969
  **Hello**, welcome to our service!
962
970
  </Message>`
963
971
  }
@@ -1104,20 +1112,20 @@ var utils = {
1104
1112
  truncateWrappedContent: _chunkGZPN7RGHcjs.truncateWrappedContent
1105
1113
  };
1106
1114
  var execute = async (props) => {
1107
- const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-HGUVAYIN.cjs")));
1115
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-XRJIDXIZ.cjs")));
1108
1116
  return executeContext(props);
1109
1117
  };
1110
1118
  var init = async () => {
1111
- await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-HGUVAYIN.cjs")));
1112
- await Promise.resolve().then(() => _interopRequireWildcard(require("./component-R4WTW6DZ.cjs")));
1113
- await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-JVLOALQN.cjs")));
1119
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-XRJIDXIZ.cjs")));
1120
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./component-AAEMNCHB.cjs")));
1121
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-JYXLFJGQ.cjs")));
1114
1122
  await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-XAYKJ6TR.cjs")));
1115
1123
  await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
1116
1124
  await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-VFORKC54.cjs")));
1117
1125
  await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-L5QAQXV2.cjs")));
1118
1126
  await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-W3NXBLYJ.cjs")));
1119
- await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-OLI56LGT.cjs")));
1120
- await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-UBHAMQW4.cjs")));
1127
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-7C2RXO75.cjs")));
1128
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-MHUM2LEI.cjs")));
1121
1129
  };
1122
1130
 
1123
1131
 
@@ -1147,4 +1155,4 @@ var init = async () => {
1147
1155
 
1148
1156
 
1149
1157
 
1150
- exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkZRCU35UVcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunk4XIOQWVZcjs.DefaultExit; exports.ErrorExecutionResult = _chunk4XIOQWVZcjs.ErrorExecutionResult; exports.ExecutionResult = _chunk4XIOQWVZcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunk4XIOQWVZcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunk4XIOQWVZcjs.PartialExecutionResult; exports.Snapshot = _chunk4XIOQWVZcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunk4XIOQWVZcjs.SuccessExecutionResult; exports.ThinkExit = _chunk4XIOQWVZcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkSOEKWFU2cjs.Tool; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunk4XIOQWVZcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.parseExit = _chunk4XIOQWVZcjs.parseExit; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx; exports.utils = utils;
1158
+ exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkQY2TRWGKcjs.Component; exports.DefaultComponents = DefaultComponents; exports.DefaultExit = _chunkB742DUFYcjs.DefaultExit; exports.ErrorExecutionResult = _chunkB742DUFYcjs.ErrorExecutionResult; exports.ExecutionResult = _chunkB742DUFYcjs.ExecutionResult; exports.Exit = _chunk3G3BS5IAcjs.Exit; exports.ListenExit = _chunkB742DUFYcjs.ListenExit; exports.LoopExceededError = _chunkPK72FAKDcjs.LoopExceededError; exports.ObjectInstance = ObjectInstance; exports.PartialExecutionResult = _chunkB742DUFYcjs.PartialExecutionResult; exports.Snapshot = _chunkB742DUFYcjs.Snapshot; exports.SnapshotSignal = _chunkPK72FAKDcjs.SnapshotSignal; exports.SuccessExecutionResult = _chunkB742DUFYcjs.SuccessExecutionResult; exports.ThinkExit = _chunkB742DUFYcjs.ThinkExit; exports.ThinkSignal = _chunkPK72FAKDcjs.ThinkSignal; exports.Tool = _chunkQR54TZ36cjs.Tool; exports.assertValidComponent = _chunkQY2TRWGKcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkB742DUFYcjs.getValue; exports.init = init; exports.isAnyComponent = _chunkQY2TRWGKcjs.isAnyComponent; exports.isComponent = _chunkQY2TRWGKcjs.isComponent; exports.parseExit = _chunkB742DUFYcjs.parseExit; exports.renderToTsx = _chunkQY2TRWGKcjs.renderToTsx; exports.utils = utils;
package/dist/index.js CHANGED
@@ -9,15 +9,15 @@ import {
9
9
  ThinkExit,
10
10
  getValue,
11
11
  parseExit
12
- } from "./chunk-4JN4PPGP.js";
13
- import "./chunk-AAHUDKBY.js";
12
+ } from "./chunk-RANA7NBF.js";
13
+ import "./chunk-DOIKBDLR.js";
14
14
  import {
15
15
  Tool
16
- } from "./chunk-23SY6IDW.js";
16
+ } from "./chunk-GXLMCQYF.js";
17
17
  import {
18
18
  formatTypings,
19
19
  getTypings
20
- } from "./chunk-U4HWJLF2.js";
20
+ } from "./chunk-B42FGPCX.js";
21
21
  import {
22
22
  CodeFormattingError,
23
23
  LoopExceededError,
@@ -34,7 +34,7 @@ import {
34
34
  isAnyComponent,
35
35
  isComponent,
36
36
  renderToTsx
37
- } from "./chunk-GGWM6X2K.js";
37
+ } from "./chunk-HA52ORZL.js";
38
38
  import "./chunk-ORQP26SZ.js";
39
39
  import {
40
40
  truncateWrappedContent,
@@ -775,22 +775,24 @@ var Button = new Component({
775
775
  {
776
776
  name: "Say action",
777
777
  description: "A button that triggers a say action",
778
- code: `<Message>
778
+ code: `yield <Message>
779
779
  <Button action="say" label="Hello" />
780
780
  </Message>`
781
781
  },
782
782
  {
783
783
  name: "Postback action",
784
784
  description: "A button that sends a postback value",
785
- code: `<Message>
785
+ code: `yield <Message>
786
+ Choose an option:
786
787
  <Button action="postback" label="Buy" value="buy_product" />
788
+ <Button action="postback" label="Buy" value="buy_product2" />
787
789
  </Message>`
788
790
  }
789
791
  ],
790
792
  leaf: {
791
793
  props: z2.object({
792
794
  action: z2.enum(["say", "url", "postback"]).default("say").describe('The action to perform when the button is clicked. Can be "say", "url", or "postback"'),
793
- label: z2.string().describe("The text displayed on the button"),
795
+ label: z2.string().describe("The text displayed on the button (min 1 character, max 250 characters)"),
794
796
  value: z2.string().optional().describe('The postback value to send when the button is clicked. Required if action is "postback"'),
795
797
  url: z2.string().optional().describe('The URL to open when the button is clicked. Required if action is "url"')
796
798
  })
@@ -805,7 +807,8 @@ var Image = new Component({
805
807
  {
806
808
  name: "Basic image",
807
809
  description: "A simple image with alt text",
808
- code: `<Message>
810
+ code: `yield <Message>
811
+ An example image:
809
812
  <Image url="https://example.com/photo.jpg" alt="Example image" />
810
813
  </Message>`
811
814
  }
@@ -826,7 +829,8 @@ var File = new Component({
826
829
  {
827
830
  name: "PDF download",
828
831
  description: "Send a PDF file with a name",
829
- code: `<Message>
832
+ code: `yield <Message>
833
+ Here is your report:
830
834
  <File url="https://example.com/report.pdf" name="Report.pdf" />
831
835
  </Message>`
832
836
  }
@@ -847,7 +851,8 @@ var Video = new Component({
847
851
  {
848
852
  name: "Intro video",
849
853
  description: "A video with a title",
850
- code: `<Message>
854
+ code: `yield <Message>
855
+ Watch this video:
851
856
  <Video url="https://example.com/intro.mp4" title="Welcome" />
852
857
  </Message>`
853
858
  }
@@ -868,7 +873,8 @@ var Audio = new Component({
868
873
  {
869
874
  name: "Sample audio",
870
875
  description: "Play a short audio clip with a title",
871
- code: `<Message>
876
+ code: `yield <Message>
877
+ Listen to this audio:
872
878
  <Audio url="https://example.com/audio.mp3" title="Sample" />
873
879
  </Message>`
874
880
  }
@@ -889,7 +895,8 @@ var Card = new Component({
889
895
  {
890
896
  name: "Product card",
891
897
  description: "A card with an image and two buttons",
892
- code: `<Message>
898
+ code: `yield <Message>
899
+ Featured product:
893
900
  <Card title="Product Name" subtitle="Limited offer">
894
901
  <Image url="https://example.com/product.jpg" alt="Product image" />
895
902
  <Button action="postback" label="Buy" value="buy_product" />
@@ -924,7 +931,8 @@ var Carousel = new Component({
924
931
  {
925
932
  name: "Product carousel",
926
933
  description: "A carousel with multiple cards",
927
- code: `<Message>
934
+ code: `yield <Message>
935
+ Here are some products you might like:
928
936
  <Carousel>
929
937
  <Card title="Item 1" subtitle="First product">
930
938
  <Image url="https://example.com/item1.jpg" alt="Item 1" />
@@ -957,7 +965,7 @@ var Text = new Component({
957
965
  {
958
966
  name: "Basic Markdown",
959
967
  description: "Simple markdown content inside a message",
960
- code: `<Message>
968
+ code: `yield <Message>
961
969
  **Hello**, welcome to our service!
962
970
  </Message>`
963
971
  }
@@ -1104,20 +1112,20 @@ var utils = {
1104
1112
  truncateWrappedContent
1105
1113
  };
1106
1114
  var execute = async (props) => {
1107
- const { executeContext } = await import("./llmz-3E2JM3HM.js");
1115
+ const { executeContext } = await import("./llmz-NX2764TL.js");
1108
1116
  return executeContext(props);
1109
1117
  };
1110
1118
  var init = async () => {
1111
- await import("./llmz-3E2JM3HM.js");
1112
- await import("./component-WFVDVSDK.js");
1113
- await import("./tool-7QXH6A24.js");
1119
+ await import("./llmz-NX2764TL.js");
1120
+ await import("./component-EOMTLA64.js");
1121
+ await import("./tool-ADXBCB4R.js");
1114
1122
  await import("./exit-YLO7BY7Z.js");
1115
1123
  await import("./jsx-AEHVFB3L.js");
1116
1124
  await import("./vm-Y3WY2627.js");
1117
1125
  await import("./utils-RQHQ2KOG.js");
1118
1126
  await import("./truncator-BSP6PQPC.js");
1119
- await import("./typings-ALZEKGV6.js");
1120
- await import("./dual-modes-LEAHGCOF.js");
1127
+ await import("./typings-AQGJAMVH.js");
1128
+ await import("./dual-modes-NJGSJEE4.js");
1121
1129
  };
1122
1130
  export {
1123
1131
  Chat,
@@ -8,10 +8,10 @@ import {
8
8
  Snapshot,
9
9
  SuccessExecutionResult,
10
10
  parseExit
11
- } from "./chunk-4JN4PPGP.js";
12
- import "./chunk-AAHUDKBY.js";
13
- import "./chunk-23SY6IDW.js";
14
- import "./chunk-U4HWJLF2.js";
11
+ } from "./chunk-RANA7NBF.js";
12
+ import "./chunk-DOIKBDLR.js";
13
+ import "./chunk-GXLMCQYF.js";
14
+ import "./chunk-B42FGPCX.js";
15
15
  import {
16
16
  AssignmentError,
17
17
  CodeExecutionError,
@@ -27,7 +27,7 @@ import {
27
27
  cleanStackTrace
28
28
  } from "./chunk-YEAWWJSJ.js";
29
29
  import "./chunk-VPTFUOIK.js";
30
- import "./chunk-GGWM6X2K.js";
30
+ import "./chunk-HA52ORZL.js";
31
31
  import "./chunk-ORQP26SZ.js";
32
32
  import {
33
33
  truncateWrappedContent
@@ -44,6 +44,7 @@ import {
44
44
  } from "./chunk-7WRN4E42.js";
45
45
 
46
46
  // src/llmz.ts
47
+ import { Client } from "@botpress/client";
47
48
  import { Cognitive } from "@botpress/cognitive";
48
49
  import { z } from "@bpinternal/zui";
49
50
  import ms from "ms";
@@ -105,7 +106,8 @@ var _executeContext = async (props) => {
105
106
  var _a, _b;
106
107
  const controller = createJoinedAbortController([props.signal]);
107
108
  const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
108
- const cognitive = Cognitive.isCognitiveClient(props.client) ? props.client : new Cognitive({ client: props.client });
109
+ const client = props.client ?? new Client();
110
+ const cognitive = Cognitive.isCognitiveClient(client) ? client : new Cognitive({ client });
109
111
  const cleanups = [];
110
112
  const ctx = new Context({
111
113
  chat: props.chat,
@@ -219,7 +221,7 @@ var executeIteration = async ({
219
221
  onBeforeTool,
220
222
  onAfterTool
221
223
  }) => {
222
- var _a, _b, _c, _d, _e;
224
+ var _a, _b, _c, _d;
223
225
  let startedAt = Date.now();
224
226
  const traces = iteration.traces;
225
227
  const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
@@ -236,6 +238,7 @@ var executeIteration = async ({
236
238
  typeof x.content !== "string" || x.content.trim().length > 0
237
239
  )
238
240
  );
241
+ iteration.messages = messages;
239
242
  traces.push({
240
243
  type: "llm_call_started",
241
244
  started_at: startedAt,
@@ -251,7 +254,7 @@ var executeIteration = async ({
251
254
  messages: messages.filter((x) => x.role !== "system"),
252
255
  stopSequences: ctx.version.getStopTokens()
253
256
  });
254
- const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
257
+ const out = typeof ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.content) === "string" ? output.output.choices[0].content : null;
255
258
  if (!out) {
256
259
  throw new CognitiveError("LLM did not return any text output");
257
260
  }
@@ -427,7 +430,7 @@ var executeIteration = async ({
427
430
  return iteration.end({
428
431
  type: "execution_error",
429
432
  execution_error: {
430
- message: ((_e = result == null ? void 0 : result.error) == null ? void 0 : _e.message) ?? "Unknown error occurred",
433
+ message: ((_d = result == null ? void 0 : result.error) == null ? void 0 : _d.message) ?? "Unknown error occurred",
431
434
  stack: cleanStackTrace(result.error.stack ?? "No stack trace available")
432
435
  }
433
436
  });
@@ -8,10 +8,10 @@ var _chunk5FWOHMO4cjs = require('./chunk-5FWOHMO4.cjs');
8
8
 
9
9
 
10
10
 
11
- var _chunk4XIOQWVZcjs = require('./chunk-4XIOQWVZ.cjs');
12
- require('./chunk-5BEKU5MZ.cjs');
13
- require('./chunk-SOEKWFU2.cjs');
14
- require('./chunk-INDOGCAQ.cjs');
11
+ var _chunkB742DUFYcjs = require('./chunk-B742DUFY.cjs');
12
+ require('./chunk-QRFGEFRO.cjs');
13
+ require('./chunk-QR54TZ36.cjs');
14
+ require('./chunk-KED57HR5.cjs');
15
15
 
16
16
 
17
17
 
@@ -27,7 +27,7 @@ var _chunkPK72FAKDcjs = require('./chunk-PK72FAKD.cjs');
27
27
 
28
28
  var _chunkKIN7Y247cjs = require('./chunk-KIN7Y247.cjs');
29
29
  require('./chunk-3G3BS5IA.cjs');
30
- require('./chunk-ZRCU35UV.cjs');
30
+ require('./chunk-QY2TRWGK.cjs');
31
31
  require('./chunk-KMZDFWYZ.cjs');
32
32
 
33
33
 
@@ -44,6 +44,7 @@ var _chunkWHNOR4ZUcjs = require('./chunk-WHNOR4ZU.cjs');
44
44
  var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
45
45
 
46
46
  // src/llmz.ts
47
+ var _client = require('@botpress/client');
47
48
  var _cognitive = require('@botpress/cognitive');
48
49
  var _zui = require('@bpinternal/zui');
49
50
  var _ms = require('ms'); var _ms2 = _interopRequireDefault(_ms);
@@ -105,9 +106,10 @@ var _executeContext = async (props) => {
105
106
  var _a, _b;
106
107
  const controller = createJoinedAbortController([props.signal]);
107
108
  const { onIterationStart, onIterationEnd, onTrace, onExit, onBeforeExecution, onAfterTool, onBeforeTool } = props;
108
- const cognitive = _cognitive.Cognitive.isCognitiveClient(props.client) ? props.client : new (0, _cognitive.Cognitive)({ client: props.client });
109
+ const client = _nullishCoalesce(props.client, () => ( new (0, _client.Client)()));
110
+ const cognitive = _cognitive.Cognitive.isCognitiveClient(client) ? client : new (0, _cognitive.Cognitive)({ client });
109
111
  const cleanups = [];
110
- const ctx = new (0, _chunk4XIOQWVZcjs.Context)({
112
+ const ctx = new (0, _chunkB742DUFYcjs.Context)({
111
113
  chat: props.chat,
112
114
  instructions: props.instructions,
113
115
  objects: props.objects,
@@ -122,7 +124,7 @@ var _executeContext = async (props) => {
122
124
  try {
123
125
  while (true) {
124
126
  if (ctx.iterations.length >= ctx.loop) {
125
- return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
127
+ return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, new (0, _chunkPK72FAKDcjs.LoopExceededError)());
126
128
  }
127
129
  const iteration = await ctx.nextIteration();
128
130
  try {
@@ -145,7 +147,7 @@ var _executeContext = async (props) => {
145
147
  reason: _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted"))
146
148
  }
147
149
  });
148
- return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
150
+ return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(controller.signal.reason, () => ( "The operation was aborted")));
149
151
  }
150
152
  cleanups.push(
151
153
  iteration.traces.onPush((traces) => {
@@ -181,25 +183,25 @@ var _executeContext = async (props) => {
181
183
  }
182
184
  if (iteration.status.type === "exit_success") {
183
185
  const exitName = iteration.status.exit_success.exit_name;
184
- return new (0, _chunk4XIOQWVZcjs.SuccessExecutionResult)(ctx, {
186
+ return new (0, _chunkB742DUFYcjs.SuccessExecutionResult)(ctx, {
185
187
  exit: iteration.exits.find((x) => x.name === exitName),
186
188
  result: iteration.status.exit_success.return_value
187
189
  });
188
190
  }
189
191
  if (iteration.status.type === "callback_requested") {
190
- return new (0, _chunk4XIOQWVZcjs.PartialExecutionResult)(
192
+ return new (0, _chunkB742DUFYcjs.PartialExecutionResult)(
191
193
  ctx,
192
194
  iteration.status.callback_requested.signal,
193
- _chunk4XIOQWVZcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
195
+ _chunkB742DUFYcjs.Snapshot.fromSignal(iteration.status.callback_requested.signal)
194
196
  );
195
197
  }
196
198
  if (iteration.status.type === "thinking_requested" || iteration.status.type === "exit_error" || iteration.status.type === "execution_error" || iteration.status.type === "invalid_code_error") {
197
199
  continue;
198
200
  }
199
- return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
201
+ return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(iteration.error, () => ( `Unknown error. Status: ${iteration.status.type}`)));
200
202
  }
201
203
  } catch (error) {
202
- return new (0, _chunk4XIOQWVZcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
204
+ return new (0, _chunkB742DUFYcjs.ErrorExecutionResult)(ctx, _nullishCoalesce(error, () => ( "Unknown error")));
203
205
  } finally {
204
206
  for (const cleanup of cleanups) {
205
207
  try {
@@ -219,7 +221,7 @@ var executeIteration = async ({
219
221
  onBeforeTool,
220
222
  onAfterTool
221
223
  }) => {
222
- var _a, _b, _c, _d, _e;
224
+ var _a, _b, _c, _d;
223
225
  let startedAt = Date.now();
224
226
  const traces = iteration.traces;
225
227
  const model = await cognitive.getModelDetails(Array.isArray(iteration.model) ? iteration.model[0] : iteration.model);
@@ -236,6 +238,7 @@ var executeIteration = async ({
236
238
  typeof x.content !== "string" || x.content.trim().length > 0
237
239
  )
238
240
  );
241
+ iteration.messages = messages;
239
242
  traces.push({
240
243
  type: "llm_call_started",
241
244
  started_at: startedAt,
@@ -251,7 +254,7 @@ var executeIteration = async ({
251
254
  messages: messages.filter((x) => x.role !== "system"),
252
255
  stopSequences: ctx.version.getStopTokens()
253
256
  });
254
- const out = ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.type) === "text" && typeof ((_d = output.output.choices) == null ? void 0 : _d[0].content) === "string" ? output.output.choices[0].content : null;
257
+ const out = typeof ((_c = (_b = output.output.choices) == null ? void 0 : _b[0]) == null ? void 0 : _c.content) === "string" ? output.output.choices[0].content : null;
255
258
  if (!out) {
256
259
  throw new (0, _chunkPK72FAKDcjs.CognitiveError)("LLM did not return any text output");
257
260
  }
@@ -427,7 +430,7 @@ var executeIteration = async ({
427
430
  return iteration.end({
428
431
  type: "execution_error",
429
432
  execution_error: {
430
- message: _nullishCoalesce(((_e = result == null ? void 0 : result.error) == null ? void 0 : _e.message), () => ( "Unknown error occurred")),
433
+ message: _nullishCoalesce(((_d = result == null ? void 0 : result.error) == null ? void 0 : _d.message), () => ( "Unknown error occurred")),
431
434
  stack: _chunkKIN7Y247cjs.cleanStackTrace.call(void 0, _nullishCoalesce(result.error.stack, () => ( "No stack trace available")))
432
435
  }
433
436
  });
@@ -471,7 +474,7 @@ var executeIteration = async ({
471
474
  }
472
475
  });
473
476
  }
474
- const parsedExit = _chunk4XIOQWVZcjs.parseExit.call(void 0, returnValue, iteration.exits);
477
+ const parsedExit = _chunkB742DUFYcjs.parseExit.call(void 0, returnValue, iteration.exits);
475
478
  if (!parsedExit.success) {
476
479
  return iteration.end({
477
480
  type: "exit_error",
package/dist/llmz.d.ts CHANGED
@@ -167,8 +167,9 @@ export type ExecutionProps = {
167
167
  /**
168
168
  * An instance of a Botpress Client, or an instance of Cognitive Client (@botpress/cognitive).
169
169
  * This is used to generate content using the LLM and to access the Botpress API.
170
+ * If not provided, a default client will be created using environment variables.
170
171
  */
171
- client: Cognitive | BotpressClientLike;
172
+ client?: Cognitive | BotpressClientLike;
172
173
  /**
173
174
  * When provided, the execution will immediately stop when the signal is aborted.
174
175
  * This will stop the LLM generation, as well as kill the VM sandbox execution.
@@ -116,8 +116,8 @@ export declare class Snapshot implements Serializable<Snapshot.JSON> {
116
116
  readonly id: string;
117
117
  readonly reason?: string;
118
118
  readonly stack: string;
119
- readonly variables: Variable[];
120
119
  readonly toolCall?: ToolCall;
120
+ variables: Variable[];
121
121
  /**
122
122
  * Gets the current status of the snapshot.
123
123
  *
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Tool
3
- } from "./chunk-23SY6IDW.js";
4
- import "./chunk-U4HWJLF2.js";
3
+ } from "./chunk-GXLMCQYF.js";
4
+ import "./chunk-B42FGPCX.js";
5
5
  import "./chunk-WSVDMGMR.js";
6
6
  import "./chunk-YEAWWJSJ.js";
7
7
  import "./chunk-ZORRILUV.js";
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkSOEKWFU2cjs = require('./chunk-SOEKWFU2.cjs');
4
- require('./chunk-INDOGCAQ.cjs');
3
+ var _chunkQR54TZ36cjs = require('./chunk-QR54TZ36.cjs');
4
+ require('./chunk-KED57HR5.cjs');
5
5
  require('./chunk-PK72FAKD.cjs');
6
6
  require('./chunk-KIN7Y247.cjs');
7
7
  require('./chunk-WHNOR4ZU.cjs');
8
8
  require('./chunk-UQOBUJIQ.cjs');
9
9
 
10
10
 
11
- exports.Tool = _chunkSOEKWFU2cjs.Tool;
11
+ exports.Tool = _chunkQR54TZ36cjs.Tool;
package/dist/tool.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { TypeOf } from '@bpinternal/zui';
1
+ import { TypeOf, z } from '@bpinternal/zui';
2
2
  import { JSONSchema7 } from 'json-schema';
3
3
  import { Serializable, ZuiType } from './types.js';
4
4
  /**
@@ -269,7 +269,7 @@ export declare class Tool<I extends ZuiType = ZuiType, O extends ZuiType = ZuiTy
269
269
  * @returns The Zui schema for output validation
270
270
  * @internal
271
271
  */
272
- get zOutput(): import("@bpinternal/zui").ZodTypeAny | import("@bpinternal/zui").ZodVoid;
272
+ get zOutput(): import("@bpinternal/zui").ZodPromise<z.Schema<any, import("@bpinternal/zui").ZodTypeDef, any>>;
273
273
  /**
274
274
  * Renames the tool and updates its aliases.
275
275
  *
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkINDOGCAQcjs = require('./chunk-INDOGCAQ.cjs');
3
+ var _chunkKED57HR5cjs = require('./chunk-KED57HR5.cjs');
4
4
  require('./chunk-PK72FAKD.cjs');
5
5
  require('./chunk-KIN7Y247.cjs');
6
6
  require('./chunk-WHNOR4ZU.cjs');
7
7
  require('./chunk-UQOBUJIQ.cjs');
8
8
 
9
9
 
10
- exports.getTypings = _chunkINDOGCAQcjs.getTypings;
10
+ exports.getTypings = _chunkKED57HR5cjs.getTypings;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getTypings
3
- } from "./chunk-U4HWJLF2.js";
3
+ } from "./chunk-B42FGPCX.js";
4
4
  import "./chunk-WSVDMGMR.js";
5
5
  import "./chunk-YEAWWJSJ.js";
6
6
  import "./chunk-ZORRILUV.js";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "llmz",
3
3
  "type": "module",
4
4
  "description": "LLMz – An LLM-native Typescript VM built on top of Zui",
5
- "version": "0.0.33",
5
+ "version": "0.0.35",
6
6
  "types": "./dist/index.d.ts",
7
7
  "main": "./dist/index.cjs",
8
8
  "module": "./dist/index.js",
@@ -49,6 +49,7 @@
49
49
  "ulid": "^2.3.0"
50
50
  },
51
51
  "devDependencies": {
52
+ "@botpress/cli": "workspace:*",
52
53
  "@microsoft/api-extractor": "^7.49.0",
53
54
  "@types/babel__core": "^7.20.5",
54
55
  "@types/babel__generator": "^7.6.8",
@@ -70,10 +71,10 @@
70
71
  "tsx": "^4.19.2"
71
72
  },
72
73
  "peerDependencies": {
73
- "@botpress/client": "1.27.2",
74
- "@botpress/cognitive": "0.3.1",
74
+ "@botpress/client": "1.28.0",
75
+ "@botpress/cognitive": "0.3.3",
75
76
  "@bpinternal/thicktoken": "^1.0.5",
76
- "@bpinternal/zui": "1.2.1"
77
+ "@bpinternal/zui": "1.3.1"
77
78
  },
78
79
  "dependenciesMeta": {
79
80
  "@bpinternal/zui": {
@@ -1,18 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
-
4
-
5
-
6
-
7
-
8
- var _chunkZRCU35UVcjs = require('./chunk-ZRCU35UV.cjs');
9
- require('./chunk-KMZDFWYZ.cjs');
10
- require('./chunk-UQOBUJIQ.cjs');
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
- exports.Component = _chunkZRCU35UVcjs.Component; exports.assertValidComponent = _chunkZRCU35UVcjs.assertValidComponent; exports.getComponentReference = _chunkZRCU35UVcjs.getComponentReference; exports.isAnyComponent = _chunkZRCU35UVcjs.isAnyComponent; exports.isComponent = _chunkZRCU35UVcjs.isComponent; exports.renderToTsx = _chunkZRCU35UVcjs.renderToTsx;