llmz 0.0.2 → 0.0.5

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 (87) hide show
  1. package/dist/chat.d.ts +17 -0
  2. package/dist/chunk-3U57H7GT.js +608 -0
  3. package/dist/{chunk-RB2L33ZR.js → chunk-4EWY34YA.js} +24 -24
  4. package/dist/{chunk-R2N2UUKC.cjs → chunk-4I7UPBLN.cjs} +14 -8
  5. package/dist/{chunk-YPOOKE3A.cjs → chunk-4QTK5ALH.cjs} +59 -28
  6. package/dist/{chunk-BKGPO722.cjs → chunk-5NVNEEYW.cjs} +55 -55
  7. package/dist/{chunk-DFZ6GX5C.js → chunk-5TRUJES5.js} +1 -1
  8. package/dist/{chunk-E2B5DRIC.cjs → chunk-6WT5VZBG.cjs} +362 -26
  9. package/dist/{chunk-7S3UY52U.js → chunk-7WRN4E42.js} +36 -8
  10. package/dist/{chunk-E5W3P7EO.cjs → chunk-EJRCDWBA.cjs} +64 -7
  11. package/dist/{chunk-VP6WWAE2.cjs → chunk-FIVFS4HG.cjs} +2 -2
  12. package/dist/{chunk-3T465BEW.js → chunk-HP7RKM25.js} +63 -6
  13. package/dist/{chunk-YUDUY7XW.cjs → chunk-HYVKY3W6.cjs} +23 -24
  14. package/dist/{chunk-PQN6HW7A.cjs → chunk-IKSIOIIP.cjs} +3 -3
  15. package/dist/{chunk-ZUAFUOUR.cjs → chunk-JDABP4SD.cjs} +3 -3
  16. package/dist/{chunk-RJHDQL4C.js → chunk-JKVVQN2P.js} +1 -1
  17. package/dist/{chunk-MSTBEKOQ.js → chunk-JQBT7UWN.js} +3 -3
  18. package/dist/{chunk-BOLDQGES.cjs → chunk-KMZDFWYZ.cjs} +3 -3
  19. package/dist/chunk-MU4LFVY7.cjs +608 -0
  20. package/dist/{chunk-7FIPXMZR.js → chunk-ORQP26SZ.js} +1 -1
  21. package/dist/{chunk-ENFB45AI.cjs → chunk-P7J2WCBB.cjs} +7 -7
  22. package/dist/{chunk-DILHJIMP.js → chunk-QBXIE6EY.js} +49 -18
  23. package/dist/{chunk-UVSOAH2H.js → chunk-QT4QF3YA.js} +1 -1
  24. package/dist/{chunk-6QDFMQHA.js → chunk-S6FOL2HY.js} +8 -2
  25. package/dist/{chunk-ZSRC3TN4.js → chunk-UNMKB2DA.js} +9 -10
  26. package/dist/{chunk-3CGLDS5T.cjs → chunk-UQOBUJIQ.cjs} +38 -10
  27. package/dist/{chunk-QPSUMPLP.js → chunk-WLUVY5QU.js} +345 -9
  28. package/dist/citations.d.ts +63 -0
  29. package/dist/component-R2Y74VUI.js +16 -0
  30. package/dist/component-TSNW3SC7.cjs +16 -0
  31. package/dist/component.d.ts +26 -17
  32. package/dist/component.default.d.ts +314 -8
  33. package/dist/context.d.ts +9 -6
  34. package/dist/dual-modes-UHNDHNIF.cjs +12 -0
  35. package/dist/dual-modes-ZUQKPJFH.js +12 -0
  36. package/dist/exit-KJ4COC5N.cjs +8 -0
  37. package/dist/exit-OIYZLBVJ.js +8 -0
  38. package/dist/exit.d.ts +6 -0
  39. package/dist/getter.d.ts +1 -1
  40. package/dist/index.cjs +256 -160
  41. package/dist/index.d.ts +7 -4
  42. package/dist/index.js +242 -146
  43. package/dist/{jsx-CJ2RBODH.js → jsx-AEHVFB3L.js} +2 -3
  44. package/dist/jsx-AJAXBWFE.cjs +13 -0
  45. package/dist/llmz-VDA4M42R.cjs +604 -0
  46. package/dist/llmz-YE5N54IU.js +604 -0
  47. package/dist/llmz.d.ts +8 -10
  48. package/dist/snapshots.d.ts +9 -1
  49. package/dist/tool-LY77IWV2.js +11 -0
  50. package/dist/tool-SWJYOR2Z.cjs +11 -0
  51. package/dist/tool.d.ts +34 -9
  52. package/dist/truncator-NYN7BGKJ.cjs +10 -0
  53. package/dist/truncator-WAL2GCUY.js +10 -0
  54. package/dist/types.d.ts +9 -1
  55. package/dist/typings-AIV2OASX.js +10 -0
  56. package/dist/typings-XR6CYHW4.cjs +10 -0
  57. package/dist/{utils-TS23YJPE.js → utils-L5GLCS3C.js} +2 -3
  58. package/dist/utils-QC4I2L6R.cjs +37 -0
  59. package/dist/vm-GJ5R72AP.cjs +12 -0
  60. package/dist/vm-ZUQOSRRM.js +12 -0
  61. package/dist/vm.d.ts +1 -1
  62. package/package.json +8 -6
  63. package/dist/chunk-A7BDFLAE.cjs +0 -30
  64. package/dist/chunk-C2TSWGYC.cjs +0 -91
  65. package/dist/chunk-Q4DEJGXD.js +0 -344
  66. package/dist/chunk-QZGFCB4T.cjs +0 -344
  67. package/dist/chunk-UG2GCPHF.js +0 -91
  68. package/dist/chunk-YSQDPG26.js +0 -30
  69. package/dist/component-DWBRHLEN.cjs +0 -9
  70. package/dist/component-R3ZAVXUC.js +0 -9
  71. package/dist/dual-modes-2VDEOJ5D.js +0 -13
  72. package/dist/dual-modes-3MH5N6RY.cjs +0 -13
  73. package/dist/exit-GYMXZZ4I.js +0 -9
  74. package/dist/exit-PQHMJEOG.cjs +0 -9
  75. package/dist/jsx-PPLE5YTB.cjs +0 -14
  76. package/dist/llmz-EGTGPSTX.cjs +0 -1049
  77. package/dist/llmz-WY74UVE3.js +0 -1049
  78. package/dist/tool-AY47ML65.cjs +0 -12
  79. package/dist/tool-WVIPESKN.js +0 -12
  80. package/dist/truncator-MTONQESU.js +0 -11
  81. package/dist/truncator-ZKPOW2I3.cjs +0 -11
  82. package/dist/typings-HTYLRNIC.js +0 -11
  83. package/dist/typings-QRJGGNUM.cjs +0 -11
  84. package/dist/utils-UR4IMUHC.cjs +0 -38
  85. package/dist/vm-4JFSZAMR.cjs +0 -13
  86. package/dist/vm-SMMA664M.js +0 -13
  87. package/patches/source-map-js@1.2.1.patch +0 -16
package/dist/index.cjs CHANGED
@@ -1,34 +1,43 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } var _class;
2
2
 
3
- var _chunkC2TSWGYCcjs = require('./chunk-C2TSWGYC.cjs');
4
3
 
5
4
 
6
- var _chunkYPOOKE3Acjs = require('./chunk-YPOOKE3A.cjs');
7
5
 
6
+ var _chunkMU4LFVY7cjs = require('./chunk-MU4LFVY7.cjs');
7
+ require('./chunk-6WT5VZBG.cjs');
8
8
 
9
9
 
10
- var _chunkYUDUY7XWcjs = require('./chunk-YUDUY7XW.cjs');
10
+ var _chunk4QTK5ALHcjs = require('./chunk-4QTK5ALH.cjs');
11
11
 
12
12
 
13
13
 
14
+ var _chunkHYVKY3W6cjs = require('./chunk-HYVKY3W6.cjs');
14
15
 
15
- var _chunkZUAFUOURcjs = require('./chunk-ZUAFUOUR.cjs');
16
16
 
17
17
 
18
- var _chunkR2N2UUKCcjs = require('./chunk-R2N2UUKC.cjs');
19
- require('./chunk-QZGFCB4T.cjs');
20
- require('./chunk-PQN6HW7A.cjs');
21
- require('./chunk-E5W3P7EO.cjs');
22
18
 
19
+ var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
20
+ require('./chunk-IKSIOIIP.cjs');
23
21
 
24
22
 
23
+ var _chunk4I7UPBLNcjs = require('./chunk-4I7UPBLN.cjs');
25
24
 
26
- var _chunkENFB45AIcjs = require('./chunk-ENFB45AI.cjs');
27
25
 
28
26
 
29
27
 
30
- var _chunk3CGLDS5Tcjs = require('./chunk-3CGLDS5T.cjs');
31
- require('./chunk-A7BDFLAE.cjs');
28
+
29
+ var _chunkEJRCDWBAcjs = require('./chunk-EJRCDWBA.cjs');
30
+ require('./chunk-KMZDFWYZ.cjs');
31
+ require('./chunk-FIVFS4HG.cjs');
32
+
33
+
34
+
35
+
36
+ var _chunkP7J2WCBBcjs = require('./chunk-P7J2WCBB.cjs');
37
+
38
+
39
+
40
+ var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
32
41
 
33
42
  // src/objects.ts
34
43
  var _zui = require('@bpinternal/zui');
@@ -40,7 +49,7 @@ var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefa
40
49
  var _types = require('@babel/types'); var t = _interopRequireWildcard(_types);
41
50
  var traverse = _traverse2.default;
42
51
  function getTypingsWithoutComments(type) {
43
- const typeClone = _chunk3CGLDS5Tcjs.cloneDeep_default.call(void 0, type);
52
+ const typeClone = _chunkUQOBUJIQcjs.cloneDeep_default.call(void 0, type);
44
53
  removeBabelComments(typeClone);
45
54
  return new (0, _generator.CodeGenerator)(typeClone, { comments: false }).generate().code;
46
55
  }
@@ -108,7 +117,7 @@ function extractAndHoistTypes(ast) {
108
117
  }
109
118
  currPath = parentPath;
110
119
  }
111
- return parts.size ? Array.from(parts).reverse().map(_chunk3CGLDS5Tcjs.upperFirst_default) : ["UnnamedType"];
120
+ return parts.size ? Array.from(parts).reverse().map(_chunkUQOBUJIQcjs.upperFirst_default) : ["UnnamedType"];
112
121
  }
113
122
  function generateTypeName(path) {
114
123
  return getTypePaths(path).join("");
@@ -275,12 +284,12 @@ async function hoistTypings(code, formatOptions) {
275
284
  } catch (err) {
276
285
  console.error(err);
277
286
  if (formatOptions.throwOnError) {
278
- throw new (0, _chunkZUAFUOURcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
287
+ throw new (0, _chunkJDABP4SDcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
279
288
  }
280
289
  break;
281
290
  }
282
291
  }
283
- return _chunkYUDUY7XWcjs.formatTypings.call(void 0, code, formatOptions);
292
+ return _chunkHYVKY3W6cjs.formatTypings.call(void 0, code, formatOptions);
284
293
  }
285
294
 
286
295
  // src/objects.ts
@@ -293,7 +302,7 @@ var ObjectInstance = class {
293
302
 
294
303
  constructor(props) {
295
304
  var _a;
296
- if (!_chunkENFB45AIcjs.isValidIdentifier.call(void 0, props.name)) {
305
+ if (!_chunkP7J2WCBBcjs.isValidIdentifier.call(void 0, props.name)) {
297
306
  throw new Error(
298
307
  `Invalid name for tool ${props.name}. A tool name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
299
308
  );
@@ -326,7 +335,7 @@ var ObjectInstance = class {
326
335
  if (props.properties.filter((p) => p.name === prop.name).length > 1) {
327
336
  throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
328
337
  }
329
- if (!_chunkENFB45AIcjs.isValidIdentifier.call(void 0, prop.name)) {
338
+ if (!_chunkP7J2WCBBcjs.isValidIdentifier.call(void 0, prop.name)) {
330
339
  throw new Error(
331
340
  `Invalid name for property ${prop.name}. A property name must start with a letter and contain only letters, numbers, and underscores. It must be 1-50 characters long.`
332
341
  );
@@ -350,7 +359,7 @@ var ObjectInstance = class {
350
359
  this.description = props.description;
351
360
  this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
352
361
  this.properties = props.properties;
353
- this.tools = _chunkYPOOKE3Acjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
362
+ this.tools = _chunk4QTK5ALHcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
354
363
  }
355
364
  async getTypings() {
356
365
  return getObjectTypings(this).withProperties().withTools().build();
@@ -372,11 +381,11 @@ function getObjectTypings(obj) {
372
381
  for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
373
382
  const description = _nullishCoalesce(prop.description, () => ( ""));
374
383
  if (description == null ? void 0 : description.trim().length) {
375
- typings.push(_chunkENFB45AIcjs.getMultilineComment.call(void 0, description));
384
+ typings.push(_chunkP7J2WCBBcjs.getMultilineComment.call(void 0, description));
376
385
  }
377
386
  let type = "unknown";
378
387
  if (prop.type) {
379
- type = await _chunkYUDUY7XWcjs.getTypings.call(void 0, prop.type, {});
388
+ type = await _chunkHYVKY3W6cjs.getTypings.call(void 0, prop.type, {});
380
389
  } else if (prop.value !== void 0) {
381
390
  type = typeof prop.value;
382
391
  }
@@ -396,7 +405,7 @@ function getObjectTypings(obj) {
396
405
  typings.push("");
397
406
  for (const tool of obj.tools) {
398
407
  const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
399
- let temp = await _chunkYUDUY7XWcjs.getTypings.call(void 0, fnType, {
408
+ let temp = await _chunkHYVKY3W6cjs.getTypings.call(void 0, fnType, {
400
409
  declaration: true
401
410
  });
402
411
  temp = temp.replace("declare function ", "function ");
@@ -417,9 +426,9 @@ function getObjectTypings(obj) {
417
426
  typings.push("}" + closingBracket);
418
427
  let header = "";
419
428
  if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
420
- header = _chunkENFB45AIcjs.getMultilineComment.call(void 0, obj.description);
429
+ header = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, obj.description);
421
430
  }
422
- return _chunkYUDUY7XWcjs.formatTypings.call(void 0,
431
+ return _chunkHYVKY3W6cjs.formatTypings.call(void 0,
423
432
  `${header}
424
433
  export namespace ${obj.name} {
425
434
  ${body}
@@ -450,7 +459,7 @@ function getObjectTypings(obj) {
450
459
  }
451
460
  function embedPropertyValue(property) {
452
461
  if (typeof property.value === "string") {
453
- return _chunkENFB45AIcjs.escapeString.call(void 0, property.value);
462
+ return _chunkP7J2WCBBcjs.escapeString.call(void 0, property.value);
454
463
  }
455
464
  if (Number.isNaN(property.value)) {
456
465
  return "NaN";
@@ -468,7 +477,7 @@ function embedPropertyValue(property) {
468
477
  return `new Date('${property.value.toISOString()}')`;
469
478
  }
470
479
  if (property.value instanceof RegExp) {
471
- return `new RegExp(${_chunkENFB45AIcjs.escapeString.call(void 0, property.value.source)}, ${_chunkENFB45AIcjs.escapeString.call(void 0, property.value.flags)})`;
480
+ return `new RegExp(${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.source)}, ${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.flags)})`;
472
481
  }
473
482
  if (property.value === null) {
474
483
  return "null";
@@ -486,7 +495,7 @@ function embedPropertyValue(property) {
486
495
  return `${property.value}n`;
487
496
  }
488
497
  if (property.value instanceof Error) {
489
- return `Error(${_chunkENFB45AIcjs.escapeString.call(void 0, property.value.message)})`;
498
+ return `Error(${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.message)})`;
490
499
  }
491
500
  if (property.value instanceof Map) {
492
501
  return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
@@ -497,8 +506,143 @@ function embedPropertyValue(property) {
497
506
  return "unknown";
498
507
  }
499
508
 
509
+ // src/citations.ts
510
+ var RARE_SYMBOLS = {
511
+ ARROW_UP: "\u2191",
512
+ CIRCLE_BULLET: "\u30FB",
513
+ STAR_BULLET_FULL: "\u2605",
514
+ STAR_BULLET_EMPTY: "\u2606",
515
+ ARROW_BULLET: "\u2192",
516
+ SQUARE_BULLET: "\u25A0",
517
+ TRIANGLE_BULLET: "\u25BA",
518
+ OPENING_TAG: "\u3010",
519
+ CLOSING_TAG: "\u3011",
520
+ SS: "\xA7",
521
+ CROSS: "\u2020"
522
+ };
523
+ var CitationsManager = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
524
+ __init() {this._citations = /* @__PURE__ */ new Map()}
525
+ __init2() {this._nextId = 0}
526
+ /**
527
+ * Registers a new source and returns the created Citation.
528
+ * @param source An object representing the source of the citation.
529
+ * @returns The created Citation.
530
+ */
531
+ registerSource(source) {
532
+ const id = this._nextId++;
533
+ const tag = `${RARE_SYMBOLS.OPENING_TAG}${id}${RARE_SYMBOLS.CLOSING_TAG}`;
534
+ const citation = {
535
+ id,
536
+ source,
537
+ tag
538
+ };
539
+ this._citations.set(id, citation);
540
+ return citation;
541
+ }
542
+ /**
543
+ * Extracts citations from the provided content and cleans the content of citation tags.
544
+ * Non-found citations are replaced with a special "Not Found" citation.
545
+ * @param content The string content containing citation tags.
546
+ * @returns An object containing the cleaned content and an array of found citations.
547
+ */
548
+ extractCitations(content, replace) {
549
+ const citations = [];
550
+ const notFoundCitation = {
551
+ id: -1,
552
+ source: "Not Found",
553
+ tag: ""
554
+ };
555
+ const regex = new RegExp(`${RARE_SYMBOLS.OPENING_TAG}([\\d|\\w|\\s|,]{0,})${RARE_SYMBOLS.CLOSING_TAG}`, "ig");
556
+ let match;
557
+ const offsets = [];
558
+ while ((match = regex.exec(content)) !== null) {
559
+ const offset = match.index;
560
+ const length = match[0].length;
561
+ offsets.push({ start: offset, length });
562
+ const multi = (_nullishCoalesce(match[1], () => ( ""))).split(/\D/g).map((s) => s.trim()).filter(Boolean).map((s) => parseInt(s, 10)).filter((s) => !isNaN(s) && s >= 0);
563
+ for (const citationId of multi) {
564
+ const citation = this._citations.get(citationId);
565
+ if (citation) {
566
+ citations.push({ ...citation, offset });
567
+ } else {
568
+ citations.push({ ...notFoundCitation, offset });
569
+ }
570
+ }
571
+ }
572
+ const entries = offsets.map((o) => ({
573
+ start: o.start,
574
+ length: o.length,
575
+ citations: citations.filter((x) => x.offset === o.start && x.id !== -1)
576
+ })).sort((a, b) => a.start - b.start);
577
+ let result = "";
578
+ let cursor = 0;
579
+ for (const { start, length, citations: citations2 } of entries) {
580
+ result += content.slice(cursor, start);
581
+ const replacement = citations2.map((citation) => replace ? replace(citation) : "").join("");
582
+ result += replacement;
583
+ cursor = start + length;
584
+ }
585
+ result += content.slice(cursor);
586
+ return { cleaned: result, citations };
587
+ }
588
+ /**
589
+ * Strips citation tags from the provided content.
590
+ * @param content The string content containing citation tags.
591
+ * @returns The cleaned content without citation tags.
592
+ */
593
+ static stripCitationTags(content) {
594
+ const regex = new RegExp(`${RARE_SYMBOLS.OPENING_TAG}([\\d|\\w|\\s|,]{0,})${RARE_SYMBOLS.CLOSING_TAG}?`, "g");
595
+ return content.replace(regex, "");
596
+ }
597
+ /**
598
+ * Removes citations from a deeply nested plain object and returns a new object with citations removed.
599
+ * @param obj The plain object to process.
600
+ * @returns A tuple containing the new object and an array of extracted citations with paths.
601
+ */
602
+ removeCitationsFromObject(obj) {
603
+ const result = [];
604
+ const processObject = (current, path) => {
605
+ if (typeof current === "string") {
606
+ const extraction = this.extractCitations(current);
607
+ if (extraction.citations.length > 0) {
608
+ result.push(...extraction.citations.map((citation) => ({ path, citation })));
609
+ }
610
+ return extraction.cleaned;
611
+ } else if (typeof current === "object" && current !== null) {
612
+ const newObject = Array.isArray(current) ? [] : {};
613
+ for (const key of Object.keys(current)) {
614
+ newObject[key] = processObject(current[key], `${path}.${key}`);
615
+ }
616
+ return newObject;
617
+ }
618
+ return current;
619
+ };
620
+ const newObj = processObject(obj, "root");
621
+ return [newObj, result];
622
+ }
623
+ /**
624
+ * Re-adds citations to the cleaned content based on their offsets.
625
+ * @param cleaned The cleaned string without citation tags.
626
+ * @param citations The array of citations with offsets.
627
+ * @returns The string with citation tags re-added.
628
+ */
629
+ reAddCitations(cleaned, citations) {
630
+ let content = cleaned;
631
+ citations.sort((a, b) => (_nullishCoalesce(a.offset, () => ( 0))) - (_nullishCoalesce(b.offset, () => ( 0))));
632
+ const adjustment = 0;
633
+ for (const citation of citations) {
634
+ if (citation.offset != null) {
635
+ const position = citation.offset + adjustment;
636
+ content = content.slice(0, position) + citation.tag + content.slice(position);
637
+ }
638
+ }
639
+ return content;
640
+ }
641
+ }, _class);
642
+
500
643
  // src/component.default.ts
501
- var Button = {
644
+
645
+ var Button = new (0, _chunkEJRCDWBAcjs.Component)({
502
646
  type: "leaf",
503
647
  description: "A button component that can perform actions when clicked",
504
648
  name: "Button",
@@ -520,36 +664,15 @@ var Button = {
520
664
  }
521
665
  ],
522
666
  leaf: {
523
- props: [
524
- {
525
- name: "action",
526
- type: "string",
527
- default: "say",
528
- description: 'The action to perform when the button is clicked. Can be "say", "url", or "postback"',
529
- required: true
530
- },
531
- {
532
- name: "label",
533
- type: "string",
534
- description: "The text displayed on the button",
535
- required: true
536
- },
537
- {
538
- name: "value",
539
- type: "string",
540
- description: 'The postback value to send when the button is clicked. Required if action is "postback"',
541
- required: false
542
- },
543
- {
544
- name: "url",
545
- type: "string",
546
- description: 'The URL to open when the button is clicked. Required if action is "url"',
547
- required: false
548
- }
549
- ]
550
- }
551
- };
552
- var Image = {
667
+ props: _zui.z.object({
668
+ 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"'),
669
+ label: _zui.z.string().describe("The text displayed on the button"),
670
+ value: _zui.z.string().optional().describe('The postback value to send when the button is clicked. Required if action is "postback"'),
671
+ url: _zui.z.string().optional().describe('The URL to open when the button is clicked. Required if action is "url"')
672
+ })
673
+ }
674
+ });
675
+ var Image = new (0, _chunkEJRCDWBAcjs.Component)({
553
676
  type: "leaf",
554
677
  name: "Image",
555
678
  description: "Displays an image from a URL.",
@@ -564,23 +687,13 @@ var Image = {
564
687
  }
565
688
  ],
566
689
  leaf: {
567
- props: [
568
- {
569
- name: "url",
570
- type: "string",
571
- description: "The URL of the image (must be valid)",
572
- required: true
573
- },
574
- {
575
- name: "alt",
576
- type: "string",
577
- description: "Alternative text describing the image",
578
- required: false
579
- }
580
- ]
690
+ props: _zui.z.object({
691
+ url: _zui.z.string().describe("The URL of the image (must be valid)"),
692
+ alt: _zui.z.string().optional().describe("Alternative text describing the image")
693
+ })
581
694
  }
582
- };
583
- var File = {
695
+ });
696
+ var File = new (0, _chunkEJRCDWBAcjs.Component)({
584
697
  type: "leaf",
585
698
  name: "File",
586
699
  description: "Sends a downloadable file to the user.",
@@ -595,23 +708,13 @@ var File = {
595
708
  }
596
709
  ],
597
710
  leaf: {
598
- props: [
599
- {
600
- name: "url",
601
- type: "string",
602
- description: "The URL of the file (must be valid)",
603
- required: true
604
- },
605
- {
606
- name: "name",
607
- type: "string",
608
- description: "The display name of the file",
609
- required: false
610
- }
611
- ]
711
+ props: _zui.z.object({
712
+ url: _zui.z.string().describe("The URL of the file (must be valid)"),
713
+ name: _zui.z.string().optional().describe("The display name of the file")
714
+ })
612
715
  }
613
- };
614
- var Video = {
716
+ });
717
+ var Video = new (0, _chunkEJRCDWBAcjs.Component)({
615
718
  type: "leaf",
616
719
  name: "Video",
617
720
  description: "Embeds a video from a URL.",
@@ -626,23 +729,13 @@ var Video = {
626
729
  }
627
730
  ],
628
731
  leaf: {
629
- props: [
630
- {
631
- name: "url",
632
- type: "string",
633
- description: "The URL of the video (must be valid)",
634
- required: true
635
- },
636
- {
637
- name: "title",
638
- type: "string",
639
- description: "Title for the video",
640
- required: false
641
- }
642
- ]
732
+ props: _zui.z.object({
733
+ url: _zui.z.string().describe("The URL of the video (must be valid)"),
734
+ title: _zui.z.string().optional().describe("Title for the video")
735
+ })
643
736
  }
644
- };
645
- var Audio = {
737
+ });
738
+ var Audio = new (0, _chunkEJRCDWBAcjs.Component)({
646
739
  type: "leaf",
647
740
  name: "Audio",
648
741
  description: "Plays an audio clip from a URL.",
@@ -657,23 +750,13 @@ var Audio = {
657
750
  }
658
751
  ],
659
752
  leaf: {
660
- props: [
661
- {
662
- name: "url",
663
- type: "string",
664
- description: "The URL of the audio clip (must be valid)",
665
- required: true
666
- },
667
- {
668
- name: "title",
669
- type: "string",
670
- description: "Title for the audio clip",
671
- required: false
672
- }
673
- ]
753
+ props: _zui.z.object({
754
+ url: _zui.z.string().describe("The URL of the audio clip (must be valid)"),
755
+ title: _zui.z.string().optional().describe("Title for the audio clip")
756
+ })
674
757
  }
675
- };
676
- var Card = {
758
+ });
759
+ var Card = new (0, _chunkEJRCDWBAcjs.Component)({
677
760
  type: "container",
678
761
  name: "Card",
679
762
  description: "A visual card component that can include an image and buttons.",
@@ -692,33 +775,23 @@ var Card = {
692
775
  }
693
776
  ],
694
777
  container: {
695
- props: [
696
- {
697
- name: "title",
698
- type: "string",
699
- description: "Title text (1\u2013250 characters)",
700
- required: true
701
- },
702
- {
703
- name: "subtitle",
704
- type: "string",
705
- description: "Optional subtitle for the card",
706
- required: false
707
- }
708
- ],
778
+ props: _zui.z.object({
779
+ title: _zui.z.string().min(1).max(250).describe("Title text (1\u2013250 characters)"),
780
+ subtitle: _zui.z.string().optional().describe("Optional subtitle for the card")
781
+ }),
709
782
  children: [
710
783
  {
711
784
  description: "Image (optional, max 1)",
712
- component: Image
785
+ component: Image.definition
713
786
  },
714
787
  {
715
788
  description: "Button (optional, up to 5)",
716
- component: Button
789
+ component: Button.definition
717
790
  }
718
791
  ]
719
792
  }
720
- };
721
- var Carousel = {
793
+ });
794
+ var Carousel = new (0, _chunkEJRCDWBAcjs.Component)({
722
795
  type: "container",
723
796
  name: "Carousel",
724
797
  description: "A virtual container for displaying 1 to 10 Card components as a carousel.",
@@ -742,16 +815,16 @@ var Carousel = {
742
815
  }
743
816
  ],
744
817
  container: {
745
- props: [],
818
+ props: _zui.z.object({}),
746
819
  children: [
747
820
  {
748
821
  description: "Card component (required, 1\u201310 allowed)",
749
- component: Card
822
+ component: Card.definition
750
823
  }
751
824
  ]
752
825
  }
753
- };
754
- var Text = {
826
+ });
827
+ var Text = new (0, _chunkEJRCDWBAcjs.Component)({
755
828
  type: "default",
756
829
  name: "Message",
757
830
  aliases: ["Text", "Markdown"],
@@ -766,10 +839,10 @@ var Text = {
766
839
  }
767
840
  ],
768
841
  default: {
769
- props: [],
842
+ props: _zui.z.object({}),
770
843
  children: []
771
844
  }
772
- };
845
+ });
773
846
  var DefaultComponents = {
774
847
  Button,
775
848
  Image,
@@ -781,22 +854,36 @@ var DefaultComponents = {
781
854
  Text
782
855
  };
783
856
 
857
+ // src/chat.ts
858
+ var Chat = class {
859
+
860
+
861
+
862
+ constructor(props) {
863
+ this.handler = props.handler;
864
+ this.components = props.components;
865
+ this.transcript = props.transcript || [];
866
+ }
867
+ onExecutionDone(_result) {
868
+ }
869
+ };
870
+
784
871
  // src/index.ts
785
- var executeContext = async (props) => {
786
- const { executeContext: executeContext2 } = (await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-EGTGPSTX.cjs")))).llmz;
787
- return executeContext2(props);
872
+ var execute = async (props) => {
873
+ const { executeContext } = await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-VDA4M42R.cjs")));
874
+ return executeContext(props);
788
875
  };
789
876
  var init = async () => {
790
- await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-EGTGPSTX.cjs")));
791
- await Promise.resolve().then(() => _interopRequireWildcard(require("./component-DWBRHLEN.cjs")));
792
- await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-AY47ML65.cjs")));
793
- await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-PQHMJEOG.cjs")));
794
- await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-PPLE5YTB.cjs")));
795
- await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-4JFSZAMR.cjs")));
796
- await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-UR4IMUHC.cjs")));
797
- await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-ZKPOW2I3.cjs")));
798
- await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-QRJGGNUM.cjs")));
799
- await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-3MH5N6RY.cjs")));
877
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-VDA4M42R.cjs")));
878
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./component-TSNW3SC7.cjs")));
879
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-SWJYOR2Z.cjs")));
880
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-KJ4COC5N.cjs")));
881
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
882
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-GJ5R72AP.cjs")));
883
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-QC4I2L6R.cjs")));
884
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-NYN7BGKJ.cjs")));
885
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-XR6CYHW4.cjs")));
886
+ await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-UHNDHNIF.cjs")));
800
887
  };
801
888
 
802
889
 
@@ -808,4 +895,13 @@ var init = async () => {
808
895
 
809
896
 
810
897
 
811
- exports.DefaultComponents = DefaultComponents; exports.Exit = _chunkR2N2UUKCcjs.Exit; exports.ObjectInstance = ObjectInstance; exports.Snapshot = _chunkC2TSWGYCcjs.Snapshot; exports.SnapshotSignal = _chunkZUAFUOURcjs.SnapshotSignal; exports.ThinkSignal = _chunkZUAFUOURcjs.ThinkSignal; exports.Tool = _chunkYPOOKE3Acjs.Tool; exports.executeContext = executeContext; exports.init = init;
898
+
899
+
900
+
901
+
902
+
903
+
904
+
905
+
906
+
907
+ exports.Chat = Chat; exports.CitationsManager = CitationsManager; exports.Component = _chunkEJRCDWBAcjs.Component; exports.DefaultComponents = DefaultComponents; exports.Exit = _chunk4I7UPBLNcjs.Exit; exports.ListenExit = _chunkMU4LFVY7cjs.ListenExit; exports.ObjectInstance = ObjectInstance; exports.Snapshot = _chunkMU4LFVY7cjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.ThinkExit = _chunkMU4LFVY7cjs.ThinkExit; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunk4QTK5ALHcjs.Tool; exports.assertValidComponent = _chunkEJRCDWBAcjs.assertValidComponent; exports.execute = execute; exports.getValue = _chunkMU4LFVY7cjs.getValue; exports.init = init; exports.isAnyComponent = _chunkEJRCDWBAcjs.isAnyComponent; exports.isComponent = _chunkEJRCDWBAcjs.isComponent;
package/dist/index.d.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  export { Tool } from './tool.js';
2
- export { Exit } from './exit.js';
2
+ export { Exit, ExitResult } from './exit.js';
3
3
  export { ObjectInstance } from './objects.js';
4
4
  export { SnapshotSignal, ThinkSignal } from './errors.js';
5
- export { Component, ContainerComponent, DefaultComponent, LeafComponent } from './component.js';
5
+ export { Component, RenderedComponent, LeafComponentDefinition, ContainerComponentDefinition, DefaultComponentDefinition, ComponentDefinition, assertValidComponent, isComponent, isAnyComponent, } from './component.js';
6
+ export { Citation, CitationsManager } from './citations.js';
6
7
  export { DefaultComponents } from './component.default.js';
7
8
  export { Snapshot } from './snapshots.js';
9
+ export { Chat, type MessageHandler } from './chat.js';
8
10
  import { type ExecutionProps } from './llmz.js';
9
11
  import { type ExecutionResult } from './types.js';
10
12
  export { type ExecutionResult, Trace } from './types.js';
11
- export type { Iteration } from './context.js';
12
- export declare const executeContext: (props: ExecutionProps) => Promise<ExecutionResult>;
13
+ export { type Iteration, ListenExit, ThinkExit, IterationStatuses, IterationStatus } from './context.js';
14
+ export { type ValueOrGetter, getValue } from './getter.js';
15
+ export declare const execute: (props: ExecutionProps) => Promise<ExecutionResult>;
13
16
  /**
14
17
  * Loads the necessary dependencies for the library to work
15
18
  * Calling this function is optional, but it will improve the performance of the first call to `executeContext`