llmz 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-RB2L33ZR.js → chunk-4EWY34YA.js} +24 -24
- package/dist/{chunk-UG2GCPHF.js → chunk-4KB5WXHR.js} +3 -2
- package/dist/{chunk-YPOOKE3A.cjs → chunk-4QTK5ALH.cjs} +59 -28
- package/dist/{chunk-BKGPO722.cjs → chunk-5NVNEEYW.cjs} +55 -55
- package/dist/{chunk-DFZ6GX5C.js → chunk-5TRUJES5.js} +1 -1
- package/dist/{chunk-C2TSWGYC.cjs → chunk-6YWYCVAB.cjs} +5 -4
- package/dist/{chunk-7S3UY52U.js → chunk-7WRN4E42.js} +36 -8
- package/dist/{chunk-Q4DEJGXD.js → chunk-EFGXTO64.js} +2 -2
- package/dist/{chunk-VP6WWAE2.cjs → chunk-FIVFS4HG.cjs} +2 -2
- package/dist/{chunk-YUDUY7XW.cjs → chunk-HYVKY3W6.cjs} +23 -24
- package/dist/{chunk-PQN6HW7A.cjs → chunk-IKSIOIIP.cjs} +3 -3
- package/dist/{chunk-ZUAFUOUR.cjs → chunk-JDABP4SD.cjs} +3 -3
- package/dist/{chunk-E5W3P7EO.cjs → chunk-JK2LZW2G.cjs} +20 -2
- package/dist/{chunk-RJHDQL4C.js → chunk-JKVVQN2P.js} +1 -1
- package/dist/{chunk-MSTBEKOQ.js → chunk-JQBT7UWN.js} +3 -3
- package/dist/{chunk-BOLDQGES.cjs → chunk-KMZDFWYZ.cjs} +3 -3
- package/dist/{chunk-R2N2UUKC.cjs → chunk-LVKZYKTP.cjs} +14 -8
- package/dist/{chunk-7FIPXMZR.js → chunk-ORQP26SZ.js} +1 -1
- package/dist/{chunk-ENFB45AI.cjs → chunk-P7J2WCBB.cjs} +7 -7
- package/dist/{chunk-DILHJIMP.js → chunk-QBXIE6EY.js} +49 -18
- package/dist/{chunk-UVSOAH2H.js → chunk-QT4QF3YA.js} +1 -1
- package/dist/{chunk-6QDFMQHA.js → chunk-S6WICIDW.js} +8 -2
- package/dist/{chunk-QPSUMPLP.js → chunk-TJQVC4CE.js} +6 -6
- package/dist/{chunk-ZSRC3TN4.js → chunk-UNMKB2DA.js} +9 -10
- package/dist/{chunk-3CGLDS5T.cjs → chunk-UQOBUJIQ.cjs} +38 -10
- package/dist/{chunk-QZGFCB4T.cjs → chunk-VAF2H6UD.cjs} +22 -22
- package/dist/{chunk-E2B5DRIC.cjs → chunk-W6U2VXSF.cjs} +25 -25
- package/dist/{chunk-3T465BEW.js → chunk-ZCPQ3QOW.js} +19 -1
- package/dist/citations.d.ts +63 -0
- package/dist/component-HQ5YQNRX.cjs +14 -0
- package/dist/component-LQDU72LX.js +14 -0
- package/dist/component.d.ts +32 -10
- package/dist/component.default.d.ts +334 -8
- package/dist/context.d.ts +3 -1
- package/dist/dual-modes-QHBOFWHM.js +13 -0
- package/dist/dual-modes-YE4S2AIL.cjs +13 -0
- package/dist/exit-F6ZUL2NV.js +8 -0
- package/dist/exit-IDKGZD7M.cjs +8 -0
- package/dist/exit.d.ts +2 -0
- package/dist/index.cjs +209 -58
- package/dist/index.d.ts +3 -2
- package/dist/index.js +193 -42
- package/dist/{jsx-CJ2RBODH.js → jsx-AEHVFB3L.js} +2 -3
- package/dist/jsx-AJAXBWFE.cjs +13 -0
- package/dist/{llmz-WY74UVE3.js → llmz-AS5TGCQS.js} +98 -39
- package/dist/{llmz-EGTGPSTX.cjs → llmz-R6XZG3JQ.cjs} +129 -70
- package/dist/llmz.d.ts +3 -2
- package/dist/snapshots.d.ts +9 -1
- package/dist/tool-LY77IWV2.js +11 -0
- package/dist/tool-SWJYOR2Z.cjs +11 -0
- package/dist/tool.d.ts +34 -9
- package/dist/truncator-NYN7BGKJ.cjs +10 -0
- package/dist/truncator-WAL2GCUY.js +10 -0
- package/dist/types.d.ts +7 -1
- package/dist/typings-AIV2OASX.js +10 -0
- package/dist/typings-XR6CYHW4.cjs +10 -0
- package/dist/{utils-TS23YJPE.js → utils-L5GLCS3C.js} +2 -3
- package/dist/utils-QC4I2L6R.cjs +37 -0
- package/dist/vm-GJ5R72AP.cjs +12 -0
- package/dist/vm-ZUQOSRRM.js +12 -0
- package/dist/vm.d.ts +1 -1
- package/package.json +8 -6
- package/dist/chunk-A7BDFLAE.cjs +0 -30
- package/dist/chunk-YSQDPG26.js +0 -30
- package/dist/component-DWBRHLEN.cjs +0 -9
- package/dist/component-R3ZAVXUC.js +0 -9
- package/dist/dual-modes-2VDEOJ5D.js +0 -13
- package/dist/dual-modes-3MH5N6RY.cjs +0 -13
- package/dist/exit-GYMXZZ4I.js +0 -9
- package/dist/exit-PQHMJEOG.cjs +0 -9
- package/dist/jsx-PPLE5YTB.cjs +0 -14
- package/dist/tool-AY47ML65.cjs +0 -12
- package/dist/tool-WVIPESKN.js +0 -12
- package/dist/truncator-MTONQESU.js +0 -11
- package/dist/truncator-ZKPOW2I3.cjs +0 -11
- package/dist/typings-HTYLRNIC.js +0 -11
- package/dist/typings-QRJGGNUM.cjs +0 -11
- package/dist/utils-UR4IMUHC.cjs +0 -38
- package/dist/vm-4JFSZAMR.cjs +0 -13
- package/dist/vm-SMMA664M.js +0 -13
- package/patches/source-map-js@1.2.1.patch +0 -16
package/dist/index.cjs
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
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
|
|
3
|
+
var _chunk6YWYCVABcjs = require('./chunk-6YWYCVAB.cjs');
|
|
4
|
+
require('./chunk-VAF2H6UD.cjs');
|
|
4
5
|
|
|
5
6
|
|
|
6
|
-
var
|
|
7
|
+
var _chunk4QTK5ALHcjs = require('./chunk-4QTK5ALH.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
+
var _chunkHYVKY3W6cjs = require('./chunk-HYVKY3W6.cjs');
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var _chunkJDABP4SDcjs = require('./chunk-JDABP4SD.cjs');
|
|
17
|
+
require('./chunk-IKSIOIIP.cjs');
|
|
16
18
|
|
|
17
19
|
|
|
18
|
-
var
|
|
19
|
-
require('./chunk-QZGFCB4T.cjs');
|
|
20
|
-
require('./chunk-PQN6HW7A.cjs');
|
|
21
|
-
require('./chunk-E5W3P7EO.cjs');
|
|
20
|
+
var _chunkLVKZYKTPcjs = require('./chunk-LVKZYKTP.cjs');
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
var
|
|
25
|
+
var _chunkJK2LZW2Gcjs = require('./chunk-JK2LZW2G.cjs');
|
|
26
|
+
require('./chunk-KMZDFWYZ.cjs');
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
require('./chunk-
|
|
30
|
+
|
|
31
|
+
var _chunkP7J2WCBBcjs = require('./chunk-P7J2WCBB.cjs');
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
var _chunkUQOBUJIQcjs = require('./chunk-UQOBUJIQ.cjs');
|
|
32
36
|
|
|
33
37
|
// src/objects.ts
|
|
34
38
|
var _zui = require('@bpinternal/zui');
|
|
@@ -40,7 +44,7 @@ var _traverse = require('@babel/traverse'); var _traverse2 = _interopRequireDefa
|
|
|
40
44
|
var _types = require('@babel/types'); var t = _interopRequireWildcard(_types);
|
|
41
45
|
var traverse = _traverse2.default;
|
|
42
46
|
function getTypingsWithoutComments(type) {
|
|
43
|
-
const typeClone =
|
|
47
|
+
const typeClone = _chunkUQOBUJIQcjs.cloneDeep_default.call(void 0, type);
|
|
44
48
|
removeBabelComments(typeClone);
|
|
45
49
|
return new (0, _generator.CodeGenerator)(typeClone, { comments: false }).generate().code;
|
|
46
50
|
}
|
|
@@ -108,7 +112,7 @@ function extractAndHoistTypes(ast) {
|
|
|
108
112
|
}
|
|
109
113
|
currPath = parentPath;
|
|
110
114
|
}
|
|
111
|
-
return parts.size ? Array.from(parts).reverse().map(
|
|
115
|
+
return parts.size ? Array.from(parts).reverse().map(_chunkUQOBUJIQcjs.upperFirst_default) : ["UnnamedType"];
|
|
112
116
|
}
|
|
113
117
|
function generateTypeName(path) {
|
|
114
118
|
return getTypePaths(path).join("");
|
|
@@ -275,12 +279,12 @@ async function hoistTypings(code, formatOptions) {
|
|
|
275
279
|
} catch (err) {
|
|
276
280
|
console.error(err);
|
|
277
281
|
if (formatOptions.throwOnError) {
|
|
278
|
-
throw new (0,
|
|
282
|
+
throw new (0, _chunkJDABP4SDcjs.CodeFormattingError)(err instanceof Error ? err.message : String(_nullishCoalesce(err, () => ( "Unknown Error"))), code);
|
|
279
283
|
}
|
|
280
284
|
break;
|
|
281
285
|
}
|
|
282
286
|
}
|
|
283
|
-
return
|
|
287
|
+
return _chunkHYVKY3W6cjs.formatTypings.call(void 0, code, formatOptions);
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
// src/objects.ts
|
|
@@ -293,7 +297,7 @@ var ObjectInstance = class {
|
|
|
293
297
|
|
|
294
298
|
constructor(props) {
|
|
295
299
|
var _a;
|
|
296
|
-
if (!
|
|
300
|
+
if (!_chunkP7J2WCBBcjs.isValidIdentifier.call(void 0, props.name)) {
|
|
297
301
|
throw new Error(
|
|
298
302
|
`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
303
|
);
|
|
@@ -326,7 +330,7 @@ var ObjectInstance = class {
|
|
|
326
330
|
if (props.properties.filter((p) => p.name === prop.name).length > 1) {
|
|
327
331
|
throw new Error(`Duplicate property name "${prop.name}" in tool ${props.name}`);
|
|
328
332
|
}
|
|
329
|
-
if (!
|
|
333
|
+
if (!_chunkP7J2WCBBcjs.isValidIdentifier.call(void 0, prop.name)) {
|
|
330
334
|
throw new Error(
|
|
331
335
|
`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
336
|
);
|
|
@@ -350,7 +354,7 @@ var ObjectInstance = class {
|
|
|
350
354
|
this.description = props.description;
|
|
351
355
|
this.metadata = _nullishCoalesce(props.metadata, () => ( {}));
|
|
352
356
|
this.properties = props.properties;
|
|
353
|
-
this.tools =
|
|
357
|
+
this.tools = _chunk4QTK5ALHcjs.Tool.withUniqueNames(_nullishCoalesce(props.tools, () => ( [])));
|
|
354
358
|
}
|
|
355
359
|
async getTypings() {
|
|
356
360
|
return getObjectTypings(this).withProperties().withTools().build();
|
|
@@ -372,11 +376,11 @@ function getObjectTypings(obj) {
|
|
|
372
376
|
for (const prop of _nullishCoalesce(obj.properties, () => ( []))) {
|
|
373
377
|
const description = _nullishCoalesce(prop.description, () => ( ""));
|
|
374
378
|
if (description == null ? void 0 : description.trim().length) {
|
|
375
|
-
typings.push(
|
|
379
|
+
typings.push(_chunkP7J2WCBBcjs.getMultilineComment.call(void 0, description));
|
|
376
380
|
}
|
|
377
381
|
let type = "unknown";
|
|
378
382
|
if (prop.type) {
|
|
379
|
-
type = await
|
|
383
|
+
type = await _chunkHYVKY3W6cjs.getTypings.call(void 0, prop.type, {});
|
|
380
384
|
} else if (prop.value !== void 0) {
|
|
381
385
|
type = typeof prop.value;
|
|
382
386
|
}
|
|
@@ -396,7 +400,7 @@ function getObjectTypings(obj) {
|
|
|
396
400
|
typings.push("");
|
|
397
401
|
for (const tool of obj.tools) {
|
|
398
402
|
const fnType = _zui.z.function(tool.zInput, tool.zOutput).title(tool.name).describe(_nullishCoalesce(tool.description, () => ( "")));
|
|
399
|
-
let temp = await
|
|
403
|
+
let temp = await _chunkHYVKY3W6cjs.getTypings.call(void 0, fnType, {
|
|
400
404
|
declaration: true
|
|
401
405
|
});
|
|
402
406
|
temp = temp.replace("declare function ", "function ");
|
|
@@ -417,9 +421,9 @@ function getObjectTypings(obj) {
|
|
|
417
421
|
typings.push("}" + closingBracket);
|
|
418
422
|
let header = "";
|
|
419
423
|
if ((_a = obj.description) == null ? void 0 : _a.trim().length) {
|
|
420
|
-
header =
|
|
424
|
+
header = _chunkP7J2WCBBcjs.getMultilineComment.call(void 0, obj.description);
|
|
421
425
|
}
|
|
422
|
-
return
|
|
426
|
+
return _chunkHYVKY3W6cjs.formatTypings.call(void 0,
|
|
423
427
|
`${header}
|
|
424
428
|
export namespace ${obj.name} {
|
|
425
429
|
${body}
|
|
@@ -450,7 +454,7 @@ function getObjectTypings(obj) {
|
|
|
450
454
|
}
|
|
451
455
|
function embedPropertyValue(property) {
|
|
452
456
|
if (typeof property.value === "string") {
|
|
453
|
-
return
|
|
457
|
+
return _chunkP7J2WCBBcjs.escapeString.call(void 0, property.value);
|
|
454
458
|
}
|
|
455
459
|
if (Number.isNaN(property.value)) {
|
|
456
460
|
return "NaN";
|
|
@@ -468,7 +472,7 @@ function embedPropertyValue(property) {
|
|
|
468
472
|
return `new Date('${property.value.toISOString()}')`;
|
|
469
473
|
}
|
|
470
474
|
if (property.value instanceof RegExp) {
|
|
471
|
-
return `new RegExp(${
|
|
475
|
+
return `new RegExp(${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.source)}, ${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.flags)})`;
|
|
472
476
|
}
|
|
473
477
|
if (property.value === null) {
|
|
474
478
|
return "null";
|
|
@@ -486,7 +490,7 @@ function embedPropertyValue(property) {
|
|
|
486
490
|
return `${property.value}n`;
|
|
487
491
|
}
|
|
488
492
|
if (property.value instanceof Error) {
|
|
489
|
-
return `Error(${
|
|
493
|
+
return `Error(${_chunkP7J2WCBBcjs.escapeString.call(void 0, property.value.message)})`;
|
|
490
494
|
}
|
|
491
495
|
if (property.value instanceof Map) {
|
|
492
496
|
return `new Map(${JSON.stringify(Array.from(property.value.entries()))})`;
|
|
@@ -497,8 +501,142 @@ function embedPropertyValue(property) {
|
|
|
497
501
|
return "unknown";
|
|
498
502
|
}
|
|
499
503
|
|
|
504
|
+
// src/citations.ts
|
|
505
|
+
var RARE_SYMBOLS = {
|
|
506
|
+
ARROW_UP: "\u2191",
|
|
507
|
+
CIRCLE_BULLET: "\u30FB",
|
|
508
|
+
STAR_BULLET_FULL: "\u2605",
|
|
509
|
+
STAR_BULLET_EMPTY: "\u2606",
|
|
510
|
+
ARROW_BULLET: "\u2192",
|
|
511
|
+
SQUARE_BULLET: "\u25A0",
|
|
512
|
+
TRIANGLE_BULLET: "\u25BA",
|
|
513
|
+
OPENING_TAG: "\u3010",
|
|
514
|
+
CLOSING_TAG: "\u3011",
|
|
515
|
+
SS: "\xA7",
|
|
516
|
+
CROSS: "\u2020"
|
|
517
|
+
};
|
|
518
|
+
var CitationsManager = (_class = class {constructor() { _class.prototype.__init.call(this);_class.prototype.__init2.call(this); }
|
|
519
|
+
__init() {this._citations = /* @__PURE__ */ new Map()}
|
|
520
|
+
__init2() {this._nextId = 0}
|
|
521
|
+
/**
|
|
522
|
+
* Registers a new source and returns the created Citation.
|
|
523
|
+
* @param source An object representing the source of the citation.
|
|
524
|
+
* @returns The created Citation.
|
|
525
|
+
*/
|
|
526
|
+
registerSource(source) {
|
|
527
|
+
const id = this._nextId++;
|
|
528
|
+
const tag = `${RARE_SYMBOLS.OPENING_TAG}${id}${RARE_SYMBOLS.CLOSING_TAG}`;
|
|
529
|
+
const citation = {
|
|
530
|
+
id,
|
|
531
|
+
source,
|
|
532
|
+
tag
|
|
533
|
+
};
|
|
534
|
+
this._citations.set(id, citation);
|
|
535
|
+
return citation;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Extracts citations from the provided content and cleans the content of citation tags.
|
|
539
|
+
* Non-found citations are replaced with a special "Not Found" citation.
|
|
540
|
+
* @param content The string content containing citation tags.
|
|
541
|
+
* @returns An object containing the cleaned content and an array of found citations.
|
|
542
|
+
*/
|
|
543
|
+
extractCitations(content, replace) {
|
|
544
|
+
const citations = [];
|
|
545
|
+
const notFoundCitation = {
|
|
546
|
+
id: -1,
|
|
547
|
+
source: "Not Found",
|
|
548
|
+
tag: ""
|
|
549
|
+
};
|
|
550
|
+
const regex = new RegExp(`${RARE_SYMBOLS.OPENING_TAG}([\\d|\\w|\\s|,]{0,})${RARE_SYMBOLS.CLOSING_TAG}`, "ig");
|
|
551
|
+
let match;
|
|
552
|
+
const offsets = [];
|
|
553
|
+
while ((match = regex.exec(content)) !== null) {
|
|
554
|
+
const offset = match.index;
|
|
555
|
+
const length = match[0].length;
|
|
556
|
+
offsets.push({ start: offset, length });
|
|
557
|
+
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);
|
|
558
|
+
for (const citationId of multi) {
|
|
559
|
+
const citation = this._citations.get(citationId);
|
|
560
|
+
if (citation) {
|
|
561
|
+
citations.push({ ...citation, offset });
|
|
562
|
+
} else {
|
|
563
|
+
citations.push({ ...notFoundCitation, offset });
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
const entries = offsets.map((o) => ({
|
|
568
|
+
start: o.start,
|
|
569
|
+
length: o.length,
|
|
570
|
+
citations: citations.filter((x) => x.offset === o.start && x.id !== -1)
|
|
571
|
+
})).sort((a, b) => a.start - b.start);
|
|
572
|
+
let result = "";
|
|
573
|
+
let cursor = 0;
|
|
574
|
+
for (const { start, length, citations: citations2 } of entries) {
|
|
575
|
+
result += content.slice(cursor, start);
|
|
576
|
+
const replacement = citations2.map((citation) => replace ? replace(citation) : "").join("");
|
|
577
|
+
result += replacement;
|
|
578
|
+
cursor = start + length;
|
|
579
|
+
}
|
|
580
|
+
result += content.slice(cursor);
|
|
581
|
+
return { cleaned: result, citations };
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Strips citation tags from the provided content.
|
|
585
|
+
* @param content The string content containing citation tags.
|
|
586
|
+
* @returns The cleaned content without citation tags.
|
|
587
|
+
*/
|
|
588
|
+
static stripCitationTags(content) {
|
|
589
|
+
const regex = new RegExp(`${RARE_SYMBOLS.OPENING_TAG}([\\d|\\w|\\s|,]{0,})${RARE_SYMBOLS.CLOSING_TAG}?`, "g");
|
|
590
|
+
return content.replace(regex, "");
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Removes citations from a deeply nested plain object and returns a new object with citations removed.
|
|
594
|
+
* @param obj The plain object to process.
|
|
595
|
+
* @returns A tuple containing the new object and an array of extracted citations with paths.
|
|
596
|
+
*/
|
|
597
|
+
removeCitationsFromObject(obj) {
|
|
598
|
+
const result = [];
|
|
599
|
+
const processObject = (current, path) => {
|
|
600
|
+
if (typeof current === "string") {
|
|
601
|
+
const extraction = this.extractCitations(current);
|
|
602
|
+
if (extraction.citations.length > 0) {
|
|
603
|
+
result.push(...extraction.citations.map((citation) => ({ path, citation })));
|
|
604
|
+
}
|
|
605
|
+
return extraction.cleaned;
|
|
606
|
+
} else if (typeof current === "object" && current !== null) {
|
|
607
|
+
const newObject = Array.isArray(current) ? [] : {};
|
|
608
|
+
for (const key of Object.keys(current)) {
|
|
609
|
+
newObject[key] = processObject(current[key], `${path}.${key}`);
|
|
610
|
+
}
|
|
611
|
+
return newObject;
|
|
612
|
+
}
|
|
613
|
+
return current;
|
|
614
|
+
};
|
|
615
|
+
const newObj = processObject(obj, "root");
|
|
616
|
+
return [newObj, result];
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Re-adds citations to the cleaned content based on their offsets.
|
|
620
|
+
* @param cleaned The cleaned string without citation tags.
|
|
621
|
+
* @param citations The array of citations with offsets.
|
|
622
|
+
* @returns The string with citation tags re-added.
|
|
623
|
+
*/
|
|
624
|
+
reAddCitations(cleaned, citations) {
|
|
625
|
+
let content = cleaned;
|
|
626
|
+
citations.sort((a, b) => (_nullishCoalesce(a.offset, () => ( 0))) - (_nullishCoalesce(b.offset, () => ( 0))));
|
|
627
|
+
const adjustment = 0;
|
|
628
|
+
for (const citation of citations) {
|
|
629
|
+
if (citation.offset != null) {
|
|
630
|
+
const position = citation.offset + adjustment;
|
|
631
|
+
content = content.slice(0, position) + citation.tag + content.slice(position);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return content;
|
|
635
|
+
}
|
|
636
|
+
}, _class);
|
|
637
|
+
|
|
500
638
|
// src/component.default.ts
|
|
501
|
-
var Button = {
|
|
639
|
+
var Button = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
502
640
|
type: "leaf",
|
|
503
641
|
description: "A button component that can perform actions when clicked",
|
|
504
642
|
name: "Button",
|
|
@@ -548,8 +686,8 @@ var Button = {
|
|
|
548
686
|
}
|
|
549
687
|
]
|
|
550
688
|
}
|
|
551
|
-
};
|
|
552
|
-
var Image = {
|
|
689
|
+
});
|
|
690
|
+
var Image = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
553
691
|
type: "leaf",
|
|
554
692
|
name: "Image",
|
|
555
693
|
description: "Displays an image from a URL.",
|
|
@@ -579,8 +717,8 @@ var Image = {
|
|
|
579
717
|
}
|
|
580
718
|
]
|
|
581
719
|
}
|
|
582
|
-
};
|
|
583
|
-
var File = {
|
|
720
|
+
});
|
|
721
|
+
var File = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
584
722
|
type: "leaf",
|
|
585
723
|
name: "File",
|
|
586
724
|
description: "Sends a downloadable file to the user.",
|
|
@@ -610,8 +748,8 @@ var File = {
|
|
|
610
748
|
}
|
|
611
749
|
]
|
|
612
750
|
}
|
|
613
|
-
};
|
|
614
|
-
var Video = {
|
|
751
|
+
});
|
|
752
|
+
var Video = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
615
753
|
type: "leaf",
|
|
616
754
|
name: "Video",
|
|
617
755
|
description: "Embeds a video from a URL.",
|
|
@@ -641,8 +779,8 @@ var Video = {
|
|
|
641
779
|
}
|
|
642
780
|
]
|
|
643
781
|
}
|
|
644
|
-
};
|
|
645
|
-
var Audio = {
|
|
782
|
+
});
|
|
783
|
+
var Audio = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
646
784
|
type: "leaf",
|
|
647
785
|
name: "Audio",
|
|
648
786
|
description: "Plays an audio clip from a URL.",
|
|
@@ -672,8 +810,8 @@ var Audio = {
|
|
|
672
810
|
}
|
|
673
811
|
]
|
|
674
812
|
}
|
|
675
|
-
};
|
|
676
|
-
var Card = {
|
|
813
|
+
});
|
|
814
|
+
var Card = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
677
815
|
type: "container",
|
|
678
816
|
name: "Card",
|
|
679
817
|
description: "A visual card component that can include an image and buttons.",
|
|
@@ -709,16 +847,16 @@ var Card = {
|
|
|
709
847
|
children: [
|
|
710
848
|
{
|
|
711
849
|
description: "Image (optional, max 1)",
|
|
712
|
-
component: Image
|
|
850
|
+
component: Image.definition
|
|
713
851
|
},
|
|
714
852
|
{
|
|
715
853
|
description: "Button (optional, up to 5)",
|
|
716
|
-
component: Button
|
|
854
|
+
component: Button.definition
|
|
717
855
|
}
|
|
718
856
|
]
|
|
719
857
|
}
|
|
720
|
-
};
|
|
721
|
-
var Carousel = {
|
|
858
|
+
});
|
|
859
|
+
var Carousel = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
722
860
|
type: "container",
|
|
723
861
|
name: "Carousel",
|
|
724
862
|
description: "A virtual container for displaying 1 to 10 Card components as a carousel.",
|
|
@@ -746,12 +884,12 @@ var Carousel = {
|
|
|
746
884
|
children: [
|
|
747
885
|
{
|
|
748
886
|
description: "Card component (required, 1\u201310 allowed)",
|
|
749
|
-
component: Card
|
|
887
|
+
component: Card.definition
|
|
750
888
|
}
|
|
751
889
|
]
|
|
752
890
|
}
|
|
753
|
-
};
|
|
754
|
-
var Text = {
|
|
891
|
+
});
|
|
892
|
+
var Text = new (0, _chunkJK2LZW2Gcjs.Component)({
|
|
755
893
|
type: "default",
|
|
756
894
|
name: "Message",
|
|
757
895
|
aliases: ["Text", "Markdown"],
|
|
@@ -769,7 +907,15 @@ var Text = {
|
|
|
769
907
|
props: [],
|
|
770
908
|
children: []
|
|
771
909
|
}
|
|
772
|
-
};
|
|
910
|
+
});
|
|
911
|
+
var messageTool = (handler) => new (0, _chunk4QTK5ALHcjs.Tool)({
|
|
912
|
+
name: "Message",
|
|
913
|
+
metadata: {
|
|
914
|
+
system: true,
|
|
915
|
+
description: "Sends a message with components like Button, Image, File, Video, Audio, Card, Carousel, and Text."
|
|
916
|
+
},
|
|
917
|
+
handler: async (args) => await handler(args)
|
|
918
|
+
});
|
|
773
919
|
var DefaultComponents = {
|
|
774
920
|
Button,
|
|
775
921
|
Image,
|
|
@@ -783,20 +929,20 @@ var DefaultComponents = {
|
|
|
783
929
|
|
|
784
930
|
// src/index.ts
|
|
785
931
|
var executeContext = async (props) => {
|
|
786
|
-
const { executeContext: executeContext2 } = (await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
932
|
+
const { executeContext: executeContext2 } = (await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-R6XZG3JQ.cjs")))).llmz;
|
|
787
933
|
return executeContext2(props);
|
|
788
934
|
};
|
|
789
935
|
var init = async () => {
|
|
790
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-
|
|
791
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-
|
|
792
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-
|
|
793
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-
|
|
794
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-
|
|
795
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-
|
|
796
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-
|
|
797
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-
|
|
798
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-
|
|
799
|
-
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-
|
|
936
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./llmz-R6XZG3JQ.cjs")));
|
|
937
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./component-HQ5YQNRX.cjs")));
|
|
938
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./tool-SWJYOR2Z.cjs")));
|
|
939
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./exit-IDKGZD7M.cjs")));
|
|
940
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./jsx-AJAXBWFE.cjs")));
|
|
941
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./vm-GJ5R72AP.cjs")));
|
|
942
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./utils-QC4I2L6R.cjs")));
|
|
943
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./truncator-NYN7BGKJ.cjs")));
|
|
944
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./typings-XR6CYHW4.cjs")));
|
|
945
|
+
await Promise.resolve().then(() => _interopRequireWildcard(require("./dual-modes-YE4S2AIL.cjs")));
|
|
800
946
|
};
|
|
801
947
|
|
|
802
948
|
|
|
@@ -808,4 +954,9 @@ var init = async () => {
|
|
|
808
954
|
|
|
809
955
|
|
|
810
956
|
|
|
811
|
-
|
|
957
|
+
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
exports.CitationsManager = CitationsManager; exports.Component = _chunkJK2LZW2Gcjs.Component; exports.DefaultComponents = DefaultComponents; exports.Exit = _chunkLVKZYKTPcjs.Exit; exports.ObjectInstance = ObjectInstance; exports.Snapshot = _chunk6YWYCVABcjs.Snapshot; exports.SnapshotSignal = _chunkJDABP4SDcjs.SnapshotSignal; exports.ThinkSignal = _chunkJDABP4SDcjs.ThinkSignal; exports.Tool = _chunk4QTK5ALHcjs.Tool; exports.assertValidComponent = _chunkJK2LZW2Gcjs.assertValidComponent; exports.executeContext = executeContext; exports.init = init; exports.isComponent = _chunkJK2LZW2Gcjs.isComponent; exports.messageTool = messageTool;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ export { Tool } from './tool.js';
|
|
|
2
2
|
export { Exit } from './exit.js';
|
|
3
3
|
export { ObjectInstance } from './objects.js';
|
|
4
4
|
export { SnapshotSignal, ThinkSignal } from './errors.js';
|
|
5
|
-
export { Component,
|
|
6
|
-
export {
|
|
5
|
+
export { Component, RenderedComponent, LeafComponentDefinition, ContainerComponentDefinition, DefaultComponentDefinition, ComponentDefinition, assertValidComponent, isComponent, } from './component.js';
|
|
6
|
+
export { Citation, CitationsManager } from './citations.js';
|
|
7
|
+
export { DefaultComponents, messageTool } from './component.default.js';
|
|
7
8
|
export { Snapshot } from './snapshots.js';
|
|
8
9
|
import { type ExecutionProps } from './llmz.js';
|
|
9
10
|
import { type ExecutionResult } from './types.js';
|