@assistant-ui/metro 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/transformer.cjs +300 -86
- 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 {
|
|
@@ -838,17 +838,19 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
838
838
|
return comp;
|
|
839
839
|
};
|
|
840
840
|
const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
|
|
841
|
+
const invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
|
|
841
842
|
const replaceTildes = (comp, options) => {
|
|
842
843
|
return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
|
|
843
844
|
};
|
|
844
845
|
const replaceTilde = (comp, options) => {
|
|
845
846
|
const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
|
|
847
|
+
const z = options.includePrerelease ? "-0" : "";
|
|
846
848
|
return comp.replace(r, (_, M, m, p, pr) => {
|
|
847
849
|
debug("tilde", comp, _, M, m, p, pr);
|
|
848
850
|
let ret;
|
|
849
851
|
if (isX(M)) ret = "";
|
|
850
|
-
else if (isX(m)) ret = `>=${M}.0.0 <${+M + 1}.0.0-0`;
|
|
851
|
-
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`;
|
|
852
854
|
else if (pr) {
|
|
853
855
|
debug("replaceTilde pr", pr);
|
|
854
856
|
ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
|
|
@@ -878,8 +880,8 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
878
880
|
else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
|
|
879
881
|
} else {
|
|
880
882
|
debug("no pr");
|
|
881
|
-
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p}
|
|
882
|
-
else ret = `>=${M}.${m}.${p}
|
|
883
|
+
if (M === "0") if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
|
|
884
|
+
else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
|
|
883
885
|
else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
|
|
884
886
|
}
|
|
885
887
|
debug("caret return", ret);
|
|
@@ -895,6 +897,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
895
897
|
const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
|
|
896
898
|
return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
|
|
897
899
|
debug("xRange", comp, ret, gtlt, M, m, p, pr);
|
|
900
|
+
if (invalidXRangeOrder(M, m, p)) return comp;
|
|
898
901
|
const xM = isX(M);
|
|
899
902
|
const xm = xM || isX(m);
|
|
900
903
|
const xp = xm || isX(p);
|
|
@@ -968,7 +971,7 @@ var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
968
971
|
};
|
|
969
972
|
}));
|
|
970
973
|
//#endregion
|
|
971
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
974
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
|
|
972
975
|
var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
973
976
|
const ANY = Symbol("SemVer ANY");
|
|
974
977
|
module.exports = class Comparator {
|
|
@@ -1038,7 +1041,7 @@ var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1038
1041
|
const Range = require_range();
|
|
1039
1042
|
}));
|
|
1040
1043
|
//#endregion
|
|
1041
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1044
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
|
|
1042
1045
|
var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1043
1046
|
const Range = require_range();
|
|
1044
1047
|
const satisfies = (version, range, options) => {
|
|
@@ -1052,14 +1055,14 @@ var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1052
1055
|
module.exports = satisfies;
|
|
1053
1056
|
}));
|
|
1054
1057
|
//#endregion
|
|
1055
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1058
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js
|
|
1056
1059
|
var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1057
1060
|
const Range = require_range();
|
|
1058
1061
|
const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1059
1062
|
module.exports = toComparators;
|
|
1060
1063
|
}));
|
|
1061
1064
|
//#endregion
|
|
1062
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1065
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js
|
|
1063
1066
|
var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1064
1067
|
const SemVer = require_semver$1();
|
|
1065
1068
|
const Range = require_range();
|
|
@@ -1085,7 +1088,7 @@ var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1085
1088
|
module.exports = maxSatisfying;
|
|
1086
1089
|
}));
|
|
1087
1090
|
//#endregion
|
|
1088
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1091
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js
|
|
1089
1092
|
var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1090
1093
|
const SemVer = require_semver$1();
|
|
1091
1094
|
const Range = require_range();
|
|
@@ -1111,7 +1114,7 @@ var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
1111
1114
|
module.exports = minSatisfying;
|
|
1112
1115
|
}));
|
|
1113
1116
|
//#endregion
|
|
1114
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1117
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js
|
|
1115
1118
|
var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1116
1119
|
const SemVer = require_semver$1();
|
|
1117
1120
|
const Range = require_range();
|
|
@@ -1151,7 +1154,7 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1151
1154
|
module.exports = minVersion;
|
|
1152
1155
|
}));
|
|
1153
1156
|
//#endregion
|
|
1154
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1157
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
|
|
1155
1158
|
var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1156
1159
|
const Range = require_range();
|
|
1157
1160
|
const validRange = (range, options) => {
|
|
@@ -1164,7 +1167,7 @@ var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1164
1167
|
module.exports = validRange;
|
|
1165
1168
|
}));
|
|
1166
1169
|
//#endregion
|
|
1167
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1170
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
|
|
1168
1171
|
var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1169
1172
|
const SemVer = require_semver$1();
|
|
1170
1173
|
const Comparator = require_comparator();
|
|
@@ -1217,21 +1220,21 @@ var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1217
1220
|
module.exports = outside;
|
|
1218
1221
|
}));
|
|
1219
1222
|
//#endregion
|
|
1220
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1223
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
|
|
1221
1224
|
var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1222
1225
|
const outside = require_outside();
|
|
1223
1226
|
const gtr = (version, range, options) => outside(version, range, ">", options);
|
|
1224
1227
|
module.exports = gtr;
|
|
1225
1228
|
}));
|
|
1226
1229
|
//#endregion
|
|
1227
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1230
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
|
|
1228
1231
|
var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1229
1232
|
const outside = require_outside();
|
|
1230
1233
|
const ltr = (version, range, options) => outside(version, range, "<", options);
|
|
1231
1234
|
module.exports = ltr;
|
|
1232
1235
|
}));
|
|
1233
1236
|
//#endregion
|
|
1234
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1237
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
|
|
1235
1238
|
var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1236
1239
|
const Range = require_range();
|
|
1237
1240
|
const intersects = (r1, r2, options) => {
|
|
@@ -1242,7 +1245,7 @@ var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1242
1245
|
module.exports = intersects;
|
|
1243
1246
|
}));
|
|
1244
1247
|
//#endregion
|
|
1245
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1248
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
|
|
1246
1249
|
var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1247
1250
|
const satisfies = require_satisfies();
|
|
1248
1251
|
const compare = require_compare();
|
|
@@ -1272,7 +1275,7 @@ var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1272
1275
|
};
|
|
1273
1276
|
}));
|
|
1274
1277
|
//#endregion
|
|
1275
|
-
//#region ../../node_modules/.pnpm/semver@7.8.
|
|
1278
|
+
//#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
|
|
1276
1279
|
var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1277
1280
|
const Range = require_range();
|
|
1278
1281
|
const Comparator = require_comparator();
|
|
@@ -1447,10 +1450,17 @@ const DISTRIBUTION_PACKAGES = [
|
|
|
1447
1450
|
* through untouched — the library, not this compiler, routes its halves.
|
|
1448
1451
|
*/
|
|
1449
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";
|
|
1450
1460
|
/** Thrown when a `"use generative"` file violates an authoring constraint. */
|
|
1451
1461
|
var GenerativeCompileError = class extends Error {
|
|
1452
1462
|
constructor(message, filename) {
|
|
1453
|
-
super(`[assistant-ui/
|
|
1463
|
+
super(`[assistant-ui/use-generative]${filename ? ` ${filename}:` : ""} ${message}`);
|
|
1454
1464
|
this.name = "GenerativeCompileError";
|
|
1455
1465
|
}
|
|
1456
1466
|
};
|
|
@@ -1469,7 +1479,89 @@ function isGenerativeModule(code) {
|
|
|
1469
1479
|
i = end + 2;
|
|
1470
1480
|
} else break;
|
|
1471
1481
|
}
|
|
1472
|
-
|
|
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;
|
|
1473
1565
|
}
|
|
1474
1566
|
/**
|
|
1475
1567
|
* Rewrites a `"use generative"` module for a single build target, keeping only the
|
|
@@ -1489,7 +1581,8 @@ function compileGenerative(code, options) {
|
|
|
1489
1581
|
ensureCompilerCompatibleWithCore(ast, filename);
|
|
1490
1582
|
ensureDefaultExport(ast, filename);
|
|
1491
1583
|
const generativeInstances = collectGenerativeInstances(ast);
|
|
1492
|
-
const
|
|
1584
|
+
const interactableToolImports = collectInteractableToolImports(ast);
|
|
1585
|
+
const toolkitSpreadNames = collectToolkitSpreadNames(ast, filename, createToolkitNameContext());
|
|
1493
1586
|
const flags = {
|
|
1494
1587
|
keptRender: false,
|
|
1495
1588
|
keptBackendExecute: false
|
|
@@ -1506,7 +1599,7 @@ function compileGenerative(code, options) {
|
|
|
1506
1599
|
}
|
|
1507
1600
|
if (_babel_types.isIdentifier(callee, { name: TOOLKIT_WRAPPER })) {
|
|
1508
1601
|
if (!object) throw new GenerativeCompileError(`${TOOLKIT_WRAPPER}() takes an inline object literal of tools`, filename);
|
|
1509
|
-
compileToolkit(object, target, generativeInstances,
|
|
1602
|
+
compileToolkit(object, target, generativeInstances, interactableToolImports, toolkitSpreadNames, flags, filename);
|
|
1510
1603
|
path.replaceWith(object);
|
|
1511
1604
|
path.skip();
|
|
1512
1605
|
}
|
|
@@ -1657,7 +1750,36 @@ function collectGenerativeInstances(ast) {
|
|
|
1657
1750
|
return names;
|
|
1658
1751
|
}
|
|
1659
1752
|
/**
|
|
1660
|
-
*
|
|
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.
|
|
1661
1783
|
*
|
|
1662
1784
|
* Two kinds qualify:
|
|
1663
1785
|
*
|
|
@@ -1670,30 +1792,38 @@ function collectGenerativeInstances(ast) {
|
|
|
1670
1792
|
* export crosses the generative-module boundary, so named imports don't
|
|
1671
1793
|
* qualify — they would be `undefined` once that module is build-split.
|
|
1672
1794
|
*/
|
|
1673
|
-
function
|
|
1674
|
-
const
|
|
1675
|
-
const
|
|
1795
|
+
function collectToolkitSpreadNames(ast, filename, context) {
|
|
1796
|
+
const spreadNames = /* @__PURE__ */ new Map();
|
|
1797
|
+
const localToolkitCalls = /* @__PURE__ */ new Map();
|
|
1676
1798
|
for (const statement of ast.program.body) {
|
|
1677
1799
|
if (_babel_types.isVariableDeclaration(statement)) {
|
|
1678
1800
|
for (const declaration of statement.declarations) {
|
|
1679
1801
|
const { id, init } = declaration;
|
|
1680
|
-
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
|
+
}
|
|
1681
1806
|
}
|
|
1682
1807
|
continue;
|
|
1683
1808
|
}
|
|
1684
1809
|
if (_babel_types.isImportDeclaration(statement)) {
|
|
1685
1810
|
const defaultSpecifier = statement.specifiers.find((specifier) => _babel_types.isImportDefaultSpecifier(specifier));
|
|
1686
1811
|
if (!defaultSpecifier) continue;
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1689
|
-
if (isGenerative === void 0) {
|
|
1690
|
-
isGenerative = isGenerativeImport(source, filename);
|
|
1691
|
-
generativeBySource.set(source, isGenerative);
|
|
1692
|
-
}
|
|
1693
|
-
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);
|
|
1694
1814
|
}
|
|
1695
1815
|
}
|
|
1696
|
-
|
|
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;
|
|
1697
1827
|
}
|
|
1698
1828
|
const MODULE_EXTENSIONS = [
|
|
1699
1829
|
".ts",
|
|
@@ -1706,28 +1836,63 @@ const MODULE_EXTENSIONS = [
|
|
|
1706
1836
|
".cjs"
|
|
1707
1837
|
];
|
|
1708
1838
|
/** Extensions a specifier may carry that actually map to a TS source file. */
|
|
1709
|
-
const REWRITABLE_JS_EXTENSIONS = new Set([
|
|
1839
|
+
const REWRITABLE_JS_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
1710
1840
|
".js",
|
|
1711
1841
|
".jsx",
|
|
1712
1842
|
".mjs",
|
|
1713
1843
|
".cjs"
|
|
1714
1844
|
]);
|
|
1715
1845
|
/**
|
|
1716
|
-
*
|
|
1717
|
-
* Relative specifiers and `tsconfig` path aliases
|
|
1718
|
-
* anything else (a bare package, an unresolvable
|
|
1719
|
-
* 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.
|
|
1720
1850
|
*/
|
|
1721
|
-
function
|
|
1851
|
+
function getGenerativeImportToolkitNames(source, filename, context) {
|
|
1722
1852
|
const cleanFilename = cleanAbsoluteFilename(filename);
|
|
1723
|
-
if (!cleanFilename) return
|
|
1853
|
+
if (!cleanFilename) return void 0;
|
|
1724
1854
|
const resolved = resolveImportedModuleFile(source, cleanFilename);
|
|
1725
|
-
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;
|
|
1726
1859
|
try {
|
|
1727
|
-
|
|
1860
|
+
code = (0, node_fs.readFileSync)(resolved, "utf8");
|
|
1728
1861
|
} catch {
|
|
1729
|
-
|
|
1862
|
+
context.importedToolkitNamesByFile.set(resolved, void 0);
|
|
1863
|
+
return;
|
|
1864
|
+
}
|
|
1865
|
+
if (!isGenerativeModule(code)) {
|
|
1866
|
+
context.importedToolkitNamesByFile.set(resolved, void 0);
|
|
1867
|
+
return;
|
|
1730
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));
|
|
1731
1896
|
}
|
|
1732
1897
|
/** Resolves an import specifier (relative or `tsconfig`-aliased) to a file on disk. */
|
|
1733
1898
|
function resolveImportedModuleFile(source, fromFilename) {
|
|
@@ -1869,13 +2034,54 @@ function parseJsonc(text) {
|
|
|
1869
2034
|
function unwrapToToolkitCall(node) {
|
|
1870
2035
|
return unwrapToCall(node, TOOLKIT_WRAPPER) ?? unwrapToCall(node, MCP_TOOLKIT_WRAPPER);
|
|
1871
2036
|
}
|
|
1872
|
-
function
|
|
1873
|
-
|
|
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);
|
|
1874
2080
|
const directMcpToolkit = unwrapToCall(entry.argument, MCP_TOOLKIT_WRAPPER);
|
|
1875
2081
|
return !!directMcpToolkit && _babel_types.isObjectExpression(directMcpToolkit.arguments[0]);
|
|
1876
2082
|
}
|
|
1877
2083
|
/** The `JSONGenerativeUI` methods that produce a split-by-condition tool. */
|
|
1878
|
-
const GENERATIVE_TOOL_METHODS = new Set(["present", "promptUser"]);
|
|
2084
|
+
const GENERATIVE_TOOL_METHODS = /* @__PURE__ */ new Set(["present", "promptUser"]);
|
|
1879
2085
|
/**
|
|
1880
2086
|
* Whether a toolkit entry's value is a call to a tool-producing method on a
|
|
1881
2087
|
* collected `JSONGenerativeUI` instance (`generative.present()`), which passes
|
|
@@ -1906,12 +2112,13 @@ function compileComponents(object, target, flags, filename) {
|
|
|
1906
2112
|
* `generative.present()` passes through, the library having already split it.
|
|
1907
2113
|
* Mutates the object in place and records outcomes in {@link TargetFlags}.
|
|
1908
2114
|
*/
|
|
1909
|
-
function compileToolkit(object, target, instances,
|
|
2115
|
+
function compileToolkit(object, target, instances, interactableToolImports, toolkitSpreadNames, flags, filename) {
|
|
2116
|
+
if (target === "client") warnDuplicateToolkitNames(object, toolkitSpreadNames, filename);
|
|
1910
2117
|
const nextProperties = [];
|
|
1911
2118
|
for (const entry of object.properties) {
|
|
1912
2119
|
const value = entryValue(entry);
|
|
1913
2120
|
if (!value) {
|
|
1914
|
-
if (_babel_types.isSpreadElement(entry) && isSafeToolkitSpread(entry,
|
|
2121
|
+
if (_babel_types.isSpreadElement(entry) && isSafeToolkitSpread(entry, toolkitSpreadNames)) {
|
|
1915
2122
|
nextProperties.push(entry);
|
|
1916
2123
|
continue;
|
|
1917
2124
|
}
|
|
@@ -1920,7 +2127,14 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1920
2127
|
nextProperties.push(entry);
|
|
1921
2128
|
continue;
|
|
1922
2129
|
}
|
|
1923
|
-
|
|
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);
|
|
1924
2138
|
}
|
|
1925
2139
|
const execute = findMember(value, "execute");
|
|
1926
2140
|
const isStub = execute ? executeIsStubTool(execute) : false;
|
|
@@ -1930,7 +2144,7 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1930
2144
|
const hasRenderText = !!findMember(value, "renderText");
|
|
1931
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);
|
|
1932
2146
|
if (type === "human" && !hasRender) throw new GenerativeCompileError("a human tool must declare a `render` so it can collect input", filename);
|
|
1933
|
-
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);
|
|
1934
2148
|
if (isExternal) {
|
|
1935
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);
|
|
1936
2150
|
if (target === "server") continue;
|
|
@@ -1952,7 +2166,7 @@ function compileToolkit(object, target, instances, safeToolkitSpreads, flags, fi
|
|
|
1952
2166
|
}
|
|
1953
2167
|
object.properties = nextProperties;
|
|
1954
2168
|
}
|
|
1955
|
-
function applyProviderToolConfig(object, execute, filename) {
|
|
2169
|
+
function applyProviderToolConfig(object, execute, toolName, filename) {
|
|
1956
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);
|
|
1957
2171
|
const existingNames = new Set(object.properties.flatMap((prop) => {
|
|
1958
2172
|
if (!_babel_types.isObjectProperty(prop) && !_babel_types.isObjectMethod(prop)) return [];
|
|
@@ -1965,7 +2179,7 @@ function applyProviderToolConfig(object, execute, filename) {
|
|
|
1965
2179
|
const name = memberName(prop.key, prop.computed);
|
|
1966
2180
|
if (!name) throw new GenerativeCompileError("`providerTool(...)` config can only contain static property names", filename);
|
|
1967
2181
|
if (_babel_types.isFunctionExpression(prop.value) || _babel_types.isArrowFunctionExpression(prop.value)) throw new GenerativeCompileError("`providerTool(...)` config cannot contain function-valued properties", filename);
|
|
1968
|
-
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);
|
|
1969
2183
|
configNames.add(name);
|
|
1970
2184
|
object.properties.push(prop);
|
|
1971
2185
|
}
|