@assistant-ui/metro 0.0.3 → 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/transformer.cjs +296 -84
- package/dist/transformer.cjs.map +1 -1
- package/package.json +10 -10
package/dist/transformer.cjs
CHANGED
|
@@ -40,9 +40,9 @@ _babel_types = __toESM(_babel_types, 1);
|
|
|
40
40
|
const DIRECTIVE = "use generative";
|
|
41
41
|
//#endregion
|
|
42
42
|
//#region ../x-generative-compiler/dist/package.js
|
|
43
|
-
var version = "0.0.
|
|
43
|
+
var version = "0.0.6";
|
|
44
44
|
//#endregion
|
|
45
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
45
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
|
|
46
46
|
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
47
47
|
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
48
48
|
const MAX_LENGTH = 256;
|
|
@@ -67,12 +67,12 @@ var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
67
67
|
};
|
|
68
68
|
}));
|
|
69
69
|
//#endregion
|
|
70
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
70
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
|
|
71
71
|
var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
72
72
|
module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
|
|
73
73
|
}));
|
|
74
74
|
//#endregion
|
|
75
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
75
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
|
|
76
76
|
var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
77
77
|
const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
|
|
78
78
|
const debug = require_debug();
|
|
@@ -151,7 +151,7 @@ var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
151
151
|
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
152
152
|
}));
|
|
153
153
|
//#endregion
|
|
154
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
154
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
|
|
155
155
|
var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
156
156
|
const looseOption = Object.freeze({ loose: true });
|
|
157
157
|
const emptyOpts = Object.freeze({});
|
|
@@ -163,7 +163,7 @@ var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
163
163
|
module.exports = parseOptions;
|
|
164
164
|
}));
|
|
165
165
|
//#endregion
|
|
166
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
166
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
|
|
167
167
|
var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
168
168
|
const numeric = /^[0-9]+$/;
|
|
169
169
|
const compareIdentifiers = (a, b) => {
|
|
@@ -183,7 +183,7 @@ var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
183
183
|
};
|
|
184
184
|
}));
|
|
185
185
|
//#endregion
|
|
186
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
186
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
|
|
187
187
|
var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
188
188
|
const debug = require_debug();
|
|
189
189
|
const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
|
|
@@ -368,7 +368,7 @@ var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
368
368
|
};
|
|
369
369
|
}));
|
|
370
370
|
//#endregion
|
|
371
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
371
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
|
|
372
372
|
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
373
373
|
const SemVer = require_semver$1();
|
|
374
374
|
const parse = (version, options, throwErrors = false) => {
|
|
@@ -383,7 +383,7 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
383
383
|
module.exports = parse;
|
|
384
384
|
}));
|
|
385
385
|
//#endregion
|
|
386
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
386
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
|
|
387
387
|
var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
388
388
|
const parse = require_parse();
|
|
389
389
|
const valid = (version, options) => {
|
|
@@ -393,7 +393,7 @@ var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
393
393
|
module.exports = valid;
|
|
394
394
|
}));
|
|
395
395
|
//#endregion
|
|
396
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
396
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js
|
|
397
397
|
var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
398
398
|
const parse = require_parse();
|
|
399
399
|
const clean = (version, options) => {
|
|
@@ -403,7 +403,7 @@ var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
403
403
|
module.exports = clean;
|
|
404
404
|
}));
|
|
405
405
|
//#endregion
|
|
406
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
406
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js
|
|
407
407
|
var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
408
408
|
const SemVer = require_semver$1();
|
|
409
409
|
const inc = (version, release, options, identifier, identifierBase) => {
|
|
@@ -421,7 +421,7 @@ var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
421
421
|
module.exports = inc;
|
|
422
422
|
}));
|
|
423
423
|
//#endregion
|
|
424
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
424
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js
|
|
425
425
|
var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
426
426
|
const parse = require_parse();
|
|
427
427
|
const diff = (version1, version2) => {
|
|
@@ -449,28 +449,28 @@ var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
449
449
|
module.exports = diff;
|
|
450
450
|
}));
|
|
451
451
|
//#endregion
|
|
452
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
452
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js
|
|
453
453
|
var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
454
454
|
const SemVer = require_semver$1();
|
|
455
455
|
const major = (a, loose) => new SemVer(a, loose).major;
|
|
456
456
|
module.exports = major;
|
|
457
457
|
}));
|
|
458
458
|
//#endregion
|
|
459
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
459
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js
|
|
460
460
|
var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
461
461
|
const SemVer = require_semver$1();
|
|
462
462
|
const minor = (a, loose) => new SemVer(a, loose).minor;
|
|
463
463
|
module.exports = minor;
|
|
464
464
|
}));
|
|
465
465
|
//#endregion
|
|
466
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
466
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js
|
|
467
467
|
var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
468
468
|
const SemVer = require_semver$1();
|
|
469
469
|
const patch = (a, loose) => new SemVer(a, loose).patch;
|
|
470
470
|
module.exports = patch;
|
|
471
471
|
}));
|
|
472
472
|
//#endregion
|
|
473
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
473
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js
|
|
474
474
|
var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
475
475
|
const parse = require_parse();
|
|
476
476
|
const prerelease = (version, options) => {
|
|
@@ -480,28 +480,28 @@ var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
480
480
|
module.exports = prerelease;
|
|
481
481
|
}));
|
|
482
482
|
//#endregion
|
|
483
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
483
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
|
|
484
484
|
var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
485
485
|
const SemVer = require_semver$1();
|
|
486
486
|
const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
|
|
487
487
|
module.exports = compare;
|
|
488
488
|
}));
|
|
489
489
|
//#endregion
|
|
490
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
490
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js
|
|
491
491
|
var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
492
492
|
const compare = require_compare();
|
|
493
493
|
const rcompare = (a, b, loose) => compare(b, a, loose);
|
|
494
494
|
module.exports = rcompare;
|
|
495
495
|
}));
|
|
496
496
|
//#endregion
|
|
497
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
497
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js
|
|
498
498
|
var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
499
499
|
const compare = require_compare();
|
|
500
500
|
const compareLoose = (a, b) => compare(a, b, true);
|
|
501
501
|
module.exports = compareLoose;
|
|
502
502
|
}));
|
|
503
503
|
//#endregion
|
|
504
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
504
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js
|
|
505
505
|
var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
506
506
|
const SemVer = require_semver$1();
|
|
507
507
|
const compareBuild = (a, b, loose) => {
|
|
@@ -512,63 +512,63 @@ var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
512
512
|
module.exports = compareBuild;
|
|
513
513
|
}));
|
|
514
514
|
//#endregion
|
|
515
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
515
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js
|
|
516
516
|
var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
517
517
|
const compareBuild = require_compare_build();
|
|
518
518
|
const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
|
|
519
519
|
module.exports = sort;
|
|
520
520
|
}));
|
|
521
521
|
//#endregion
|
|
522
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
522
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js
|
|
523
523
|
var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
524
524
|
const compareBuild = require_compare_build();
|
|
525
525
|
const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
|
|
526
526
|
module.exports = rsort;
|
|
527
527
|
}));
|
|
528
528
|
//#endregion
|
|
529
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
529
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
|
|
530
530
|
var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
531
531
|
const compare = require_compare();
|
|
532
532
|
const gt = (a, b, loose) => compare(a, b, loose) > 0;
|
|
533
533
|
module.exports = gt;
|
|
534
534
|
}));
|
|
535
535
|
//#endregion
|
|
536
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
536
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
|
|
537
537
|
var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
538
538
|
const compare = require_compare();
|
|
539
539
|
const lt = (a, b, loose) => compare(a, b, loose) < 0;
|
|
540
540
|
module.exports = lt;
|
|
541
541
|
}));
|
|
542
542
|
//#endregion
|
|
543
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
543
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
|
|
544
544
|
var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
545
545
|
const compare = require_compare();
|
|
546
546
|
const eq = (a, b, loose) => compare(a, b, loose) === 0;
|
|
547
547
|
module.exports = eq;
|
|
548
548
|
}));
|
|
549
549
|
//#endregion
|
|
550
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
550
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
|
|
551
551
|
var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
552
552
|
const compare = require_compare();
|
|
553
553
|
const neq = (a, b, loose) => compare(a, b, loose) !== 0;
|
|
554
554
|
module.exports = neq;
|
|
555
555
|
}));
|
|
556
556
|
//#endregion
|
|
557
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
557
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
|
|
558
558
|
var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
559
559
|
const compare = require_compare();
|
|
560
560
|
const gte = (a, b, loose) => compare(a, b, loose) >= 0;
|
|
561
561
|
module.exports = gte;
|
|
562
562
|
}));
|
|
563
563
|
//#endregion
|
|
564
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
564
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
|
|
565
565
|
var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
566
566
|
const compare = require_compare();
|
|
567
567
|
const lte = (a, b, loose) => compare(a, b, loose) <= 0;
|
|
568
568
|
module.exports = lte;
|
|
569
569
|
}));
|
|
570
570
|
//#endregion
|
|
571
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
571
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
|
|
572
572
|
var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
573
573
|
const eq = require_eq();
|
|
574
574
|
const neq = require_neq();
|
|
@@ -600,7 +600,7 @@ var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
600
600
|
module.exports = cmp;
|
|
601
601
|
}));
|
|
602
602
|
//#endregion
|
|
603
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
603
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js
|
|
604
604
|
var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
605
605
|
const SemVer = require_semver$1();
|
|
606
606
|
const parse = require_parse();
|
|
@@ -628,7 +628,7 @@ var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
628
628
|
module.exports = coerce;
|
|
629
629
|
}));
|
|
630
630
|
//#endregion
|
|
631
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
631
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js
|
|
632
632
|
var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
633
633
|
const parse = require_parse();
|
|
634
634
|
const constants = require_constants();
|
|
@@ -661,7 +661,7 @@ var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
661
661
|
module.exports = truncate;
|
|
662
662
|
}));
|
|
663
663
|
//#endregion
|
|
664
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
664
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
|
|
665
665
|
var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
666
666
|
var LRUCache = class {
|
|
667
667
|
constructor() {
|
|
@@ -694,7 +694,7 @@ var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
694
694
|
module.exports = LRUCache;
|
|
695
695
|
}));
|
|
696
696
|
//#endregion
|
|
697
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
697
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
|
|
698
698
|
var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
699
699
|
const SPACE_CHARACTERS = /\s+/g;
|
|
700
700
|
module.exports = class Range {
|
|
@@ -844,12 +844,13 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
844
844
|
};
|
|
845
845
|
const replaceTilde = (comp, options) => {
|
|
846
846
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
847
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
847
848
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
848
849
|
debug("tilde", comp, _, M, m, p, pr);
|
|
849
850
|
let ret;
|
|
850
851
|
if (isX(M)) ret = "";
|
|
851
|
-
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
852
|
-
else if (isX(p)) ret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`;
|
|
852
|
+
else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
|
|
853
|
+
else if (isX(p)) ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
|
|
853
854
|
else if (pr) {
|
|
854
855
|
debug("replaceTilde pr", pr);
|
|
855
856
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
@@ -970,7 +971,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
970
971
|
};
|
|
971
972
|
}));
|
|
972
973
|
//#endregion
|
|
973
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
974
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
|
|
974
975
|
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
975
976
|
const ANY = Symbol("SemVer ANY");
|
|
976
977
|
module.exports = class Comparator {
|
|
@@ -1040,7 +1041,7 @@ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1040
1041
|
const Range = require_range();
|
|
1041
1042
|
}));
|
|
1042
1043
|
//#endregion
|
|
1043
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1044
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
|
|
1044
1045
|
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1045
1046
|
const Range = require_range();
|
|
1046
1047
|
const satisfies = (version, range, options) => {
|
|
@@ -1054,14 +1055,14 @@ var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1054
1055
|
module.exports = satisfies;
|
|
1055
1056
|
}));
|
|
1056
1057
|
//#endregion
|
|
1057
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1058
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js
|
|
1058
1059
|
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1059
1060
|
const Range = require_range();
|
|
1060
1061
|
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1061
1062
|
module.exports = toComparators;
|
|
1062
1063
|
}));
|
|
1063
1064
|
//#endregion
|
|
1064
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1065
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js
|
|
1065
1066
|
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1066
1067
|
const SemVer = require_semver$1();
|
|
1067
1068
|
const Range = require_range();
|
|
@@ -1087,7 +1088,7 @@ var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1087
1088
|
module.exports = maxSatisfying;
|
|
1088
1089
|
}));
|
|
1089
1090
|
//#endregion
|
|
1090
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1091
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js
|
|
1091
1092
|
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1092
1093
|
const SemVer = require_semver$1();
|
|
1093
1094
|
const Range = require_range();
|
|
@@ -1113,7 +1114,7 @@ var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1113
1114
|
module.exports = minSatisfying;
|
|
1114
1115
|
}));
|
|
1115
1116
|
//#endregion
|
|
1116
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1117
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js
|
|
1117
1118
|
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1118
1119
|
const SemVer = require_semver$1();
|
|
1119
1120
|
const Range = require_range();
|
|
@@ -1153,7 +1154,7 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1153
1154
|
module.exports = minVersion;
|
|
1154
1155
|
}));
|
|
1155
1156
|
//#endregion
|
|
1156
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1157
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
|
|
1157
1158
|
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1158
1159
|
const Range = require_range();
|
|
1159
1160
|
const validRange = (range, options) => {
|
|
@@ -1166,7 +1167,7 @@ var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1166
1167
|
module.exports = validRange;
|
|
1167
1168
|
}));
|
|
1168
1169
|
//#endregion
|
|
1169
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1170
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
1170
1171
|
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1171
1172
|
const SemVer = require_semver$1();
|
|
1172
1173
|
const Comparator = require_comparator();
|
|
@@ -1219,21 +1220,21 @@ var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1219
1220
|
module.exports = outside;
|
|
1220
1221
|
}));
|
|
1221
1222
|
//#endregion
|
|
1222
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1223
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
|
|
1223
1224
|
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1224
1225
|
const outside = require_outside();
|
|
1225
1226
|
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1226
1227
|
module.exports = gtr;
|
|
1227
1228
|
}));
|
|
1228
1229
|
//#endregion
|
|
1229
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1230
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
|
|
1230
1231
|
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1231
1232
|
const outside = require_outside();
|
|
1232
1233
|
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1233
1234
|
module.exports = ltr;
|
|
1234
1235
|
}));
|
|
1235
1236
|
//#endregion
|
|
1236
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1237
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
|
|
1237
1238
|
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1238
1239
|
const Range = require_range();
|
|
1239
1240
|
const intersects = (r1, r2, options) => {
|
|
@@ -1244,7 +1245,7 @@ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1244
1245
|
module.exports = intersects;
|
|
1245
1246
|
}));
|
|
1246
1247
|
//#endregion
|
|
1247
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1248
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
|
|
1248
1249
|
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1249
1250
|
const satisfies = require_satisfies();
|
|
1250
1251
|
const compare = require_compare();
|
|
@@ -1274,7 +1275,7 @@ var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1274
1275
|
};
|
|
1275
1276
|
}));
|
|
1276
1277
|
//#endregion
|
|
1277
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1278
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
1278
1279
|
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1279
1280
|
const Range = require_range();
|
|
1280
1281
|
const Comparator = require_comparator();
|
|
@@ -1449,10 +1450,17 @@ const DISTRIBUTION_PACKAGES = [
|
|
|
1449
1450
|
* through untouched — the library, not this compiler, routes its halves.
|
|
1450
1451
|
*/
|
|
1451
1452
|
const GENERATIVE_FACTORY = "JSONGenerativeUI";
|
|
1453
|
+
/**
|
|
1454
|
+
* The factory producing an interactable's complete tool entry. Unlike
|
|
1455
|
+
* `JSONGenerativeUI`, its package has no per-target builds, so this compiler
|
|
1456
|
+
* splits the inline config: the client keeps `render`, the server drops it.
|
|
1457
|
+
* The factory's own `execute` is internal and client-safe (frontend tool).
|
|
1458
|
+
*/
|
|
1459
|
+
const INTERACTABLE_TOOL_FACTORY = "unstable_interactableTool";
|
|
1452
1460
|
/** Thrown when a `"use generative"` file violates an authoring constraint. */
|
|
1453
1461
|
var GenerativeCompileError = class extends Error {
|
|
1454
1462
|
constructor(message, filename) {
|
|
1455
|
-
super(`[assistant-ui/
|
|
1463
|
+
super(`[assistant-ui/use-generative]${filename ? ` ${filename}:` : ""} ${message}`);
|
|
1456
1464
|
this.name = "GenerativeCompileError";
|
|
1457
1465
|
}
|
|
1458
1466
|
};
|
|
@@ -1471,7 +1479,89 @@ function isGenerativeModule(code) {
|
|
|
1471
1479
|
i = end + 2;
|
|
1472
1480
|
} else break;
|
|
1473
1481
|
}
|
|
1474
|
-
|
|
1482
|
+
const quote = code[i];
|
|
1483
|
+
if (quote !== "\"" && quote !== "'") return false;
|
|
1484
|
+
const directiveStart = i + 1;
|
|
1485
|
+
if (!code.startsWith("use generative", directiveStart)) return false;
|
|
1486
|
+
const directiveEnd = directiveStart + 14;
|
|
1487
|
+
if (code[directiveEnd] !== quote) return false;
|
|
1488
|
+
return hasDirectiveTerminator(code, directiveEnd + 1);
|
|
1489
|
+
}
|
|
1490
|
+
function hasDirectiveTerminator(code, start) {
|
|
1491
|
+
let i = start;
|
|
1492
|
+
let sawLineTerminator = false;
|
|
1493
|
+
for (;;) {
|
|
1494
|
+
if (i >= code.length) return true;
|
|
1495
|
+
const char = code.charCodeAt(i);
|
|
1496
|
+
if (isSemicolon(char)) return true;
|
|
1497
|
+
if (isLineTerminator(char)) {
|
|
1498
|
+
sawLineTerminator = true;
|
|
1499
|
+
i++;
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
if (code.startsWith("//", i)) {
|
|
1503
|
+
const lineEnd = nextLineTerminatorIndex(code, i + 2);
|
|
1504
|
+
if (lineEnd === -1) return true;
|
|
1505
|
+
sawLineTerminator = true;
|
|
1506
|
+
i = lineEnd + 1;
|
|
1507
|
+
continue;
|
|
1508
|
+
}
|
|
1509
|
+
if (code.startsWith("/*", i)) {
|
|
1510
|
+
const end = code.indexOf("*/", i + 2);
|
|
1511
|
+
if (end === -1) return false;
|
|
1512
|
+
sawLineTerminator ||= containsLineTerminator(code, i + 2, end);
|
|
1513
|
+
i = end + 2;
|
|
1514
|
+
continue;
|
|
1515
|
+
}
|
|
1516
|
+
if (/\s/.test(code[i])) {
|
|
1517
|
+
i++;
|
|
1518
|
+
continue;
|
|
1519
|
+
}
|
|
1520
|
+
return sawLineTerminator && !startsExpressionContinuation(code, i);
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
function nextLineTerminatorIndex(code, start) {
|
|
1524
|
+
for (let i = start; i < code.length; i++) if (isLineTerminator(code.charCodeAt(i))) return i;
|
|
1525
|
+
return -1;
|
|
1526
|
+
}
|
|
1527
|
+
function containsLineTerminator(code, start, end) {
|
|
1528
|
+
for (let i = start; i < end; i++) if (isLineTerminator(code.charCodeAt(i))) return true;
|
|
1529
|
+
return false;
|
|
1530
|
+
}
|
|
1531
|
+
function startsExpressionContinuation(code, start) {
|
|
1532
|
+
switch (code[start]) {
|
|
1533
|
+
case ".":
|
|
1534
|
+
case "+":
|
|
1535
|
+
case "-":
|
|
1536
|
+
case "*":
|
|
1537
|
+
case "/":
|
|
1538
|
+
case "%":
|
|
1539
|
+
case "<":
|
|
1540
|
+
case ">":
|
|
1541
|
+
case "=":
|
|
1542
|
+
case "!":
|
|
1543
|
+
case "&":
|
|
1544
|
+
case "|":
|
|
1545
|
+
case "^":
|
|
1546
|
+
case "?":
|
|
1547
|
+
case ":":
|
|
1548
|
+
case ",":
|
|
1549
|
+
case "[":
|
|
1550
|
+
case "(":
|
|
1551
|
+
case "`": return true;
|
|
1552
|
+
}
|
|
1553
|
+
return startsKeywordContinuation(code, start, "as") || startsKeywordContinuation(code, start, "in") || startsKeywordContinuation(code, start, "instanceof") || startsKeywordContinuation(code, start, "satisfies");
|
|
1554
|
+
}
|
|
1555
|
+
function startsKeywordContinuation(code, start, keyword) {
|
|
1556
|
+
if (!code.startsWith(keyword, start)) return false;
|
|
1557
|
+
const next = code[start + keyword.length];
|
|
1558
|
+
return next === void 0 || !/[\p{ID_Continue}$]/u.test(next);
|
|
1559
|
+
}
|
|
1560
|
+
function isSemicolon(char) {
|
|
1561
|
+
return char === 59;
|
|
1562
|
+
}
|
|
1563
|
+
function isLineTerminator(char) {
|
|
1564
|
+
return char === 10 || char === 13 || char === 8232 || char === 8233;
|
|
1475
1565
|
}
|
|
1476
1566
|
/**
|
|
1477
1567
|
* Rewrites a `"use generative"` module for a single build target, keeping only the
|
|
@@ -1491,7 +1581,8 @@ function compileGenerative(code, options) {
|
|
|
1491
1581
|
ensureCompilerCompatibleWithCore(ast, filename);
|
|
1492
1582
|
ensureDefaultExport(ast, filename);
|
|
1493
1583
|
const generativeInstances = collectGenerativeInstances(ast);
|
|
1494
|
-
const
|
|
1584
|
+
const interactableToolImports = collectInteractableToolImports(ast);
|
|
1585
|
+
const toolkitSpreadNames = collectToolkitSpreadNames(ast, filename, createToolkitNameContext());
|
|
1495
1586
|
const flags = {
|
|
1496
1587
|
keptRender: false,
|
|
1497
1588
|
keptBackendExecute: false
|
|
@@ -1508,7 +1599,7 @@ function compileGenerative(code, options) {
|
|
|
1508
1599
|
}
|
|
1509
1600
|
if (_babel_types.isIdentifier(callee, { name: TOOLKIT_WRAPPER })) {
|
|
1510
1601
|
if (!object) throw new GenerativeCompileError(`${TOOLKIT_WRAPPER}() takes an inline object literal of tools`, filename);
|
|
1511
|
-
compileToolkit(object, target, generativeInstances,
|
|
1602
|
+
compileToolkit(object, target, generativeInstances, interactableToolImports, toolkitSpreadNames, flags, filename);
|
|
1512
1603
|
path.replaceWith(object);
|
|
1513
1604
|
path.skip();
|
|
1514
1605
|
}
|
|
@@ -1659,7 +1750,36 @@ function collectGenerativeInstances(ast) {
|
|
|
1659
1750
|
return names;
|
|
1660
1751
|
}
|
|
1661
1752
|
/**
|
|
1662
|
-
*
|
|
1753
|
+
* Collects the local names `unstable_interactableTool` is imported under from a
|
|
1754
|
+
* distribution package, so toolkit entries calling it can be recognized
|
|
1755
|
+
* (and a same-named local function can't smuggle an arbitrary call through).
|
|
1756
|
+
*/
|
|
1757
|
+
function collectInteractableToolImports(ast) {
|
|
1758
|
+
const names = /* @__PURE__ */ new Set();
|
|
1759
|
+
for (const statement of ast.program.body) {
|
|
1760
|
+
if (!_babel_types.isImportDeclaration(statement)) continue;
|
|
1761
|
+
if (!packageNameFromSpecifier(statement.source.value)) continue;
|
|
1762
|
+
for (const specifier of statement.specifiers) if (_babel_types.isImportSpecifier(specifier) && _babel_types.isIdentifier(specifier.imported, { name: INTERACTABLE_TOOL_FACTORY })) names.add(specifier.local.name);
|
|
1763
|
+
}
|
|
1764
|
+
return names;
|
|
1765
|
+
}
|
|
1766
|
+
function createToolkitNameContext() {
|
|
1767
|
+
return {
|
|
1768
|
+
importedToolkitNamesByFile: /* @__PURE__ */ new Map(),
|
|
1769
|
+
resolvingImportedToolkitNames: /* @__PURE__ */ new Set()
|
|
1770
|
+
};
|
|
1771
|
+
}
|
|
1772
|
+
/**
|
|
1773
|
+
* The inline config of an `unstable_interactableTool({ ... })` toolkit entry, or `null`
|
|
1774
|
+
* when the entry is some other expression.
|
|
1775
|
+
*/
|
|
1776
|
+
function interactableToolConfig(value, imports) {
|
|
1777
|
+
return _babel_types.isCallExpression(value) && _babel_types.isIdentifier(value.callee) && imports.has(value.callee.name) && _babel_types.isObjectExpression(value.arguments[0]) ? value.arguments[0] : null;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Toolkit identifiers that are safe to spread into a `defineToolkit({ ... })`,
|
|
1781
|
+
* paired with the static tool names they contain. A `null` name list means the
|
|
1782
|
+
* spread is safe, but its names are not statically known for duplicate checks.
|
|
1663
1783
|
*
|
|
1664
1784
|
* Two kinds qualify:
|
|
1665
1785
|
*
|
|
@@ -1672,30 +1792,38 @@ function collectGenerativeInstances(ast) {
|
|
|
1672
1792
|
* export crosses the generative-module boundary, so named imports don't
|
|
1673
1793
|
* qualify — they would be `undefined` once that module is build-split.
|
|
1674
1794
|
*/
|
|
1675
|
-
function
|
|
1676
|
-
const
|
|
1677
|
-
const
|
|
1795
|
+
function collectToolkitSpreadNames(ast, filename, context) {
|
|
1796
|
+
const spreadNames = /* @__PURE__ */ new Map();
|
|
1797
|
+
const localToolkitCalls = /* @__PURE__ */ new Map();
|
|
1678
1798
|
for (const statement of ast.program.body) {
|
|
1679
1799
|
if (_babel_types.isVariableDeclaration(statement)) {
|
|
1680
1800
|
for (const declaration of statement.declarations) {
|
|
1681
1801
|
const { id, init } = declaration;
|
|
1682
|
-
if (_babel_types.isIdentifier(id) && init
|
|
1802
|
+
if (_babel_types.isIdentifier(id) && init) {
|
|
1803
|
+
const toolkitCall = unwrapToToolkitCall(init);
|
|
1804
|
+
if (toolkitCall) localToolkitCalls.set(id.name, toolkitCall);
|
|
1805
|
+
}
|
|
1683
1806
|
}
|
|
1684
1807
|
continue;
|
|
1685
1808
|
}
|
|
1686
1809
|
if (_babel_types.isImportDeclaration(statement)) {
|
|
1687
1810
|
const defaultSpecifier = statement.specifiers.find((specifier) => _babel_types.isImportDefaultSpecifier(specifier));
|
|
1688
1811
|
if (!defaultSpecifier) continue;
|
|
1689
|
-
const
|
|
1690
|
-
|
|
1691
|
-
if (isGenerative === void 0) {
|
|
1692
|
-
isGenerative = isGenerativeImport(source, filename);
|
|
1693
|
-
generativeBySource.set(source, isGenerative);
|
|
1694
|
-
}
|
|
1695
|
-
if (isGenerative) names.add(defaultSpecifier.local.name);
|
|
1812
|
+
const names = getGenerativeImportToolkitNames(statement.source.value, filename, context);
|
|
1813
|
+
if (names !== void 0) spreadNames.set(defaultSpecifier.local.name, names);
|
|
1696
1814
|
}
|
|
1697
1815
|
}
|
|
1698
|
-
|
|
1816
|
+
const resolveLocal = (name) => {
|
|
1817
|
+
if (spreadNames.has(name)) return spreadNames.get(name);
|
|
1818
|
+
const call = localToolkitCalls.get(name);
|
|
1819
|
+
if (!call) return void 0;
|
|
1820
|
+
const object = _babel_types.isObjectExpression(call.arguments[0]) ? call.arguments[0] : null;
|
|
1821
|
+
const publicNames = uniqueToolkitNames(object ? collectToolkitObjectNames(object, spreadNames) : null);
|
|
1822
|
+
spreadNames.set(name, publicNames);
|
|
1823
|
+
return publicNames;
|
|
1824
|
+
};
|
|
1825
|
+
for (const name of localToolkitCalls.keys()) resolveLocal(name);
|
|
1826
|
+
return spreadNames;
|
|
1699
1827
|
}
|
|
1700
1828
|
const MODULE_EXTENSIONS = [
|
|
1701
1829
|
".ts",
|
|
@@ -1708,28 +1836,63 @@ const MODULE_EXTENSIONS = [
|
|
|
1708
1836
|
".cjs"
|
|
1709
1837
|
];
|
|
1710
1838
|
/** Extensions a specifier may carry that actually map to a TS source file. */
|
|
1711
|
-
const REWRITABLE_JS_EXTENSIONS = new Set([
|
|
1839
|
+
const REWRITABLE_JS_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1712
1840
|
".js",
|
|
1713
1841
|
".jsx",
|
|
1714
1842
|
".mjs",
|
|
1715
1843
|
".cjs"
|
|
1716
1844
|
]);
|
|
1717
1845
|
/**
|
|
1718
|
-
*
|
|
1719
|
-
* Relative specifiers and `tsconfig` path aliases
|
|
1720
|
-
* anything else (a bare package, an unresolvable
|
|
1721
|
-
* non-generative, and thus an unsafe spread.
|
|
1846
|
+
* Reads the static tool names from the default export of an imported
|
|
1847
|
+
* `"use generative"` module. Relative specifiers and `tsconfig` path aliases
|
|
1848
|
+
* (e.g. `@/tools`) are resolved; anything else (a bare package, an unresolvable
|
|
1849
|
+
* alias) is treated as non-generative, and thus an unsafe spread.
|
|
1722
1850
|
*/
|
|
1723
|
-
function
|
|
1851
|
+
function getGenerativeImportToolkitNames(source, filename, context) {
|
|
1724
1852
|
const cleanFilename = cleanAbsoluteFilename(filename);
|
|
1725
|
-
if (!cleanFilename) return
|
|
1853
|
+
if (!cleanFilename) return void 0;
|
|
1726
1854
|
const resolved = resolveImportedModuleFile(source, cleanFilename);
|
|
1727
|
-
if (!resolved) return
|
|
1855
|
+
if (!resolved) return void 0;
|
|
1856
|
+
if (context.importedToolkitNamesByFile.has(resolved)) return context.importedToolkitNamesByFile.get(resolved);
|
|
1857
|
+
if (context.resolvingImportedToolkitNames.has(resolved)) return null;
|
|
1858
|
+
let code;
|
|
1728
1859
|
try {
|
|
1729
|
-
|
|
1860
|
+
code = (0, node_fs.readFileSync)(resolved, "utf8");
|
|
1730
1861
|
} catch {
|
|
1731
|
-
|
|
1862
|
+
context.importedToolkitNamesByFile.set(resolved, void 0);
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
if (!isGenerativeModule(code)) {
|
|
1866
|
+
context.importedToolkitNamesByFile.set(resolved, void 0);
|
|
1867
|
+
return;
|
|
1732
1868
|
}
|
|
1869
|
+
context.resolvingImportedToolkitNames.add(resolved);
|
|
1870
|
+
try {
|
|
1871
|
+
const names = getDefaultExportToolkitNames((0, _babel_parser.parse)(code, {
|
|
1872
|
+
sourceType: "module",
|
|
1873
|
+
plugins: [
|
|
1874
|
+
"typescript",
|
|
1875
|
+
"jsx",
|
|
1876
|
+
"explicitResourceManagement"
|
|
1877
|
+
]
|
|
1878
|
+
}), resolved, context);
|
|
1879
|
+
context.importedToolkitNamesByFile.set(resolved, names);
|
|
1880
|
+
return names;
|
|
1881
|
+
} catch (error) {
|
|
1882
|
+
if (error instanceof GenerativeCompileError) throw error;
|
|
1883
|
+
context.importedToolkitNamesByFile.set(resolved, null);
|
|
1884
|
+
return null;
|
|
1885
|
+
} finally {
|
|
1886
|
+
context.resolvingImportedToolkitNames.delete(resolved);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
function getDefaultExportToolkitNames(ast, filename, context) {
|
|
1890
|
+
const def = ast.program.body.find((stmt) => _babel_types.isExportDefaultDeclaration(stmt));
|
|
1891
|
+
if (!def) return null;
|
|
1892
|
+
const toolkitCall = unwrapToToolkitCall(def.declaration);
|
|
1893
|
+
if (!toolkitCall || !_babel_types.isObjectExpression(toolkitCall.arguments[0])) return null;
|
|
1894
|
+
const spreadNames = collectToolkitSpreadNames(ast, filename, context);
|
|
1895
|
+
return uniqueToolkitNames(collectToolkitObjectNames(toolkitCall.arguments[0], spreadNames));
|
|
1733
1896
|
}
|
|
1734
1897
|
/** Resolves an import specifier (relative or `tsconfig`-aliased) to a file on disk. */
|
|
1735
1898
|
function resolveImportedModuleFile(source, fromFilename) {
|
|
@@ -1871,13 +2034,54 @@ function parseJsonc(text) {
|
|
|
1871
2034
|
function unwrapToToolkitCall(node) {
|
|
1872
2035
|
return unwrapToCall(node, TOOLKIT_WRAPPER) ?? unwrapToCall(node, MCP_TOOLKIT_WRAPPER);
|
|
1873
2036
|
}
|
|
1874
|
-
function
|
|
1875
|
-
|
|
2037
|
+
function collectToolkitObjectNames(object, toolkitSpreadNames) {
|
|
2038
|
+
const names = [];
|
|
2039
|
+
for (const entry of object.properties) {
|
|
2040
|
+
const entryNames = toolkitEntryNames(entry, toolkitSpreadNames);
|
|
2041
|
+
if (!entryNames) return null;
|
|
2042
|
+
names.push(...entryNames);
|
|
2043
|
+
}
|
|
2044
|
+
return names;
|
|
2045
|
+
}
|
|
2046
|
+
function uniqueToolkitNames(names) {
|
|
2047
|
+
return names ? [...new Set(names)] : names;
|
|
2048
|
+
}
|
|
2049
|
+
function toolkitEntryNames(entry, toolkitSpreadNames) {
|
|
2050
|
+
if (_babel_types.isSpreadElement(entry)) {
|
|
2051
|
+
if (_babel_types.isIdentifier(entry.argument)) return toolkitSpreadNames.get(entry.argument.name) ?? null;
|
|
2052
|
+
const directMcpToolkit = unwrapToCall(entry.argument, MCP_TOOLKIT_WRAPPER);
|
|
2053
|
+
if (directMcpToolkit && _babel_types.isObjectExpression(directMcpToolkit.arguments[0])) return collectToolkitObjectNames(directMcpToolkit.arguments[0], toolkitSpreadNames);
|
|
2054
|
+
return null;
|
|
2055
|
+
}
|
|
2056
|
+
if (_babel_types.isObjectProperty(entry) || _babel_types.isObjectMethod(entry)) {
|
|
2057
|
+
const name = memberName(entry.key, entry.computed);
|
|
2058
|
+
return name ? [name] : [];
|
|
2059
|
+
}
|
|
2060
|
+
return [];
|
|
2061
|
+
}
|
|
2062
|
+
function warnDuplicateToolkitNames(object, toolkitSpreadNames, filename) {
|
|
2063
|
+
const names = collectToolkitObjectNames(object, toolkitSpreadNames);
|
|
2064
|
+
if (!names) return;
|
|
2065
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2066
|
+
const warned = /* @__PURE__ */ new Set();
|
|
2067
|
+
for (const name of names) {
|
|
2068
|
+
if (seen.has(name)) {
|
|
2069
|
+
if (!warned.has(name)) {
|
|
2070
|
+
console.warn(new GenerativeCompileError(`Duplicate tool name "${name}" while composing toolkits. JavaScript object spread keeps the last definition.`, filename).message);
|
|
2071
|
+
warned.add(name);
|
|
2072
|
+
}
|
|
2073
|
+
continue;
|
|
2074
|
+
}
|
|
2075
|
+
seen.add(name);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
function isSafeToolkitSpread(entry, toolkitSpreadNames) {
|
|
2079
|
+
if (_babel_types.isIdentifier(entry.argument)) return toolkitSpreadNames.has(entry.argument.name);
|
|
1876
2080
|
const directMcpToolkit = unwrapToCall(entry.argument, MCP_TOOLKIT_WRAPPER);
|
|
1877
2081
|
return !!directMcpToolkit && _babel_types.isObjectExpression(directMcpToolkit.arguments[0]);
|
|
1878
2082
|
}
|
|
1879
2083
|
/** The `JSONGenerativeUI` methods that produce a split-by-condition tool. */
|
|
1880
|
-
const GENERATIVE_TOOL_METHODS = new Set(["present", "promptUser"]);
|
|
2084
|
+
const GENERATIVE_TOOL_METHODS = /* @__PURE__ */ new Set(["present", "promptUser"]);
|
|
1881
2085
|
/**
|
|
1882
2086
|
* Whether a toolkit entry's value is a call to a tool-producing method on a
|
|
1883
2087
|
* collected `JSONGenerativeUI` instance (`generative.present()`), which passes
|
|
@@ -1908,12 +2112,13 @@ function compileComponents(object, target, flags, filename) {
|
|
|
1908
2112
|
* `generative.present()` passes through, the library having already split it.
|
|
1909
2113
|
* Mutates the object in place and records outcomes in {@link TargetFlags}.
|
|
1910
2114
|
*/
|
|
1911
|
-
function compileToolkit(object, target, instances,
|
|
2115
|
+
function compileToolkit(object, target, instances, interactableToolImports, toolkitSpreadNames, flags, filename) {
|
|
2116
|
+
if (target === "client") warnDuplicateToolkitNames(object, toolkitSpreadNames, filename);
|
|
1912
2117
|
const nextProperties = [];
|
|
1913
2118
|
for (const entry of object.properties) {
|
|
1914
2119
|
const value = entryValue(entry);
|
|
1915
2120
|
if (!value) {
|
|
1916
|
-
if (_babel_types.isSpreadElement(entry) && isSafeToolkitSpread(entry,
|
|
2121
|
+
if (_babel_types.isSpreadElement(entry) && isSafeToolkitSpread(entry, toolkitSpreadNames)) {
|
|
1917
2122
|
nextProperties.push(entry);
|
|
1918
2123
|
continue;
|
|
1919
2124
|
}
|
|
@@ -1922,7 +2127,14 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1922
2127
|
nextProperties.push(entry);
|
|
1923
2128
|
continue;
|
|
1924
2129
|
}
|
|
1925
|
-
|
|
2130
|
+
const config = raw && interactableToolConfig(raw, interactableToolImports);
|
|
2131
|
+
if (config) {
|
|
2132
|
+
if (target === "client") flags.keptRender = true;
|
|
2133
|
+
else removeMember(config, "render");
|
|
2134
|
+
nextProperties.push(entry);
|
|
2135
|
+
continue;
|
|
2136
|
+
}
|
|
2137
|
+
throw new GenerativeCompileError("each tool must be an inline object literal (`name: { ... }`) or a compiler-visible toolkit spread / generative tool (e.g. `...defineMcpToolkit(...)`, `...baseToolkit`, `generative.present()`, or `unstable_interactableTool(...)`) so its `execute` can be routed", filename);
|
|
1926
2138
|
}
|
|
1927
2139
|
const execute = findMember(value, "execute");
|
|
1928
2140
|
const isStub = execute ? executeIsStubTool(execute) : false;
|
|
@@ -1932,7 +2144,7 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1932
2144
|
const hasRenderText = !!findMember(value, "renderText");
|
|
1933
2145
|
if (type === "frontend" && !hasRender && !hasRenderText) throw new GenerativeCompileError("a frontend tool must declare a `render` or `renderText` (it has no server execute to show otherwise)", filename);
|
|
1934
2146
|
if (type === "human" && !hasRender) throw new GenerativeCompileError("a human tool must declare a `render` so it can collect input", filename);
|
|
1935
|
-
if (type === "provider" && execute) applyProviderToolConfig(value, execute, filename);
|
|
2147
|
+
if (type === "provider" && execute) applyProviderToolConfig(value, execute, _babel_types.isObjectProperty(entry) ? memberName(entry.key, entry.computed) : void 0, filename);
|
|
1936
2148
|
if (isExternal) {
|
|
1937
2149
|
if (!hasRender && !hasRenderText) throw new GenerativeCompileError("an external tool must declare a `render` or `renderText` (assistant-ui only renders calls for tools defined elsewhere)", filename);
|
|
1938
2150
|
if (target === "server") continue;
|
|
@@ -1954,7 +2166,7 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1954
2166
|
}
|
|
1955
2167
|
object.properties = nextProperties;
|
|
1956
2168
|
}
|
|
1957
|
-
function applyProviderToolConfig(object, execute, filename) {
|
|
2169
|
+
function applyProviderToolConfig(object, execute, toolName, filename) {
|
|
1958
2170
|
if (!_babel_types.isObjectProperty(execute) || !_babel_types.isCallExpression(execute.value) || execute.value.arguments.length !== 1 || !_babel_types.isObjectExpression(execute.value.arguments[0])) throw new GenerativeCompileError("`providerTool(...)` must receive an inline object literal", filename);
|
|
1959
2171
|
const existingNames = new Set(object.properties.flatMap((prop) => {
|
|
1960
2172
|
if (!_babel_types.isObjectProperty(prop) && !_babel_types.isObjectMethod(prop)) return [];
|
|
@@ -1967,7 +2179,7 @@ function applyProviderToolConfig(object, execute, filename) {
|
|
|
1967
2179
|
const name = memberName(prop.key, prop.computed);
|
|
1968
2180
|
if (!name) throw new GenerativeCompileError("`providerTool(...)` config can only contain static property names", filename);
|
|
1969
2181
|
if (_babel_types.isFunctionExpression(prop.value) || _babel_types.isArrowFunctionExpression(prop.value)) throw new GenerativeCompileError("`providerTool(...)` config cannot contain function-valued properties", filename);
|
|
1970
|
-
if (existingNames.has(name) || configNames.has(name)) throw new GenerativeCompileError(
|
|
2182
|
+
if (existingNames.has(name) || configNames.has(name)) throw new GenerativeCompileError(`\`providerTool(...)\` config${toolName ? ` for "${toolName}"` : ""} duplicates "${name}"`, filename);
|
|
1971
2183
|
configNames.add(name);
|
|
1972
2184
|
object.properties.push(prop);
|
|
1973
2185
|
}
|