@promptbook/core 0.78.0-0 → 0.78.3
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/README.md +0 -4
- package/esm/index.es.js +257 -211
- package/esm/index.es.js.map +1 -1
- package/esm/typings/src/_packages/core.index.d.ts +4 -0
- package/esm/typings/src/_packages/types.index.d.ts +0 -2
- package/esm/typings/src/commands/_common/types/CommandType.d.ts +1 -1
- package/esm/typings/src/config.d.ts +14 -0
- package/esm/typings/src/errors/utils/getErrorReportUrl.d.ts +6 -0
- package/esm/typings/src/execution/execution-report/ExecutionReportString.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/pipeline/PipelineString.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +258 -210
- package/umd/index.umd.js.map +1 -1
package/umd/index.umd.js
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*
|
|
26
26
|
* @see https://github.com/webgptorg/promptbook
|
|
27
27
|
*/
|
|
28
|
-
var PROMPTBOOK_ENGINE_VERSION = '0.
|
|
28
|
+
var PROMPTBOOK_ENGINE_VERSION = '0.78.2';
|
|
29
29
|
/**
|
|
30
30
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
31
31
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -446,199 +446,6 @@
|
|
|
446
446
|
return value;
|
|
447
447
|
}
|
|
448
448
|
|
|
449
|
-
/**
|
|
450
|
-
* @@@
|
|
451
|
-
*
|
|
452
|
-
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
453
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
454
|
-
*
|
|
455
|
-
* @returns The same object as the input, but deeply frozen
|
|
456
|
-
* @public exported from `@promptbook/utils`
|
|
457
|
-
*/
|
|
458
|
-
function $deepFreeze(objectValue) {
|
|
459
|
-
var e_1, _a;
|
|
460
|
-
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
461
|
-
try {
|
|
462
|
-
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
463
|
-
var propertyName = propertyNames_1_1.value;
|
|
464
|
-
var value = objectValue[propertyName];
|
|
465
|
-
if (value && typeof value === 'object') {
|
|
466
|
-
$deepFreeze(value);
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
471
|
-
finally {
|
|
472
|
-
try {
|
|
473
|
-
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
474
|
-
}
|
|
475
|
-
finally { if (e_1) throw e_1.error; }
|
|
476
|
-
}
|
|
477
|
-
return Object.freeze(objectValue);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
485
|
-
*
|
|
486
|
-
* @public exported from `@promptbook/core`
|
|
487
|
-
*/
|
|
488
|
-
var UnexpectedError = /** @class */ (function (_super) {
|
|
489
|
-
__extends(UnexpectedError, _super);
|
|
490
|
-
function UnexpectedError(message) {
|
|
491
|
-
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n https://github.com/webgptorg/promptbook/issues\n\n Or contact us on me@pavolhejny.com\n\n "); })) || this;
|
|
492
|
-
_this.name = 'UnexpectedError';
|
|
493
|
-
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
494
|
-
return _this;
|
|
495
|
-
}
|
|
496
|
-
return UnexpectedError;
|
|
497
|
-
}(Error));
|
|
498
|
-
|
|
499
|
-
/**
|
|
500
|
-
* Checks if the value is [🚉] serializable as JSON
|
|
501
|
-
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
502
|
-
*
|
|
503
|
-
* - Almost all primitives are serializable BUT:
|
|
504
|
-
* - `undefined` is not serializable
|
|
505
|
-
* - `NaN` is not serializable
|
|
506
|
-
* - Objects and arrays are serializable if all their properties are serializable
|
|
507
|
-
* - Functions are not serializable
|
|
508
|
-
* - Circular references are not serializable
|
|
509
|
-
* - `Date` objects are not serializable
|
|
510
|
-
* - `Map` and `Set` objects are not serializable
|
|
511
|
-
* - `RegExp` objects are not serializable
|
|
512
|
-
* - `Error` objects are not serializable
|
|
513
|
-
* - `Symbol` objects are not serializable
|
|
514
|
-
* - And much more...
|
|
515
|
-
*
|
|
516
|
-
* @throws UnexpectedError if the value is not serializable as JSON
|
|
517
|
-
* @public exported from `@promptbook/utils`
|
|
518
|
-
*/
|
|
519
|
-
function checkSerializableAsJson(name, value) {
|
|
520
|
-
var e_1, _a;
|
|
521
|
-
if (value === undefined) {
|
|
522
|
-
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
523
|
-
}
|
|
524
|
-
else if (value === null) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
else if (typeof value === 'boolean') {
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
else if (typeof value === 'number' && !isNaN(value)) {
|
|
531
|
-
return;
|
|
532
|
-
}
|
|
533
|
-
else if (typeof value === 'string') {
|
|
534
|
-
return;
|
|
535
|
-
}
|
|
536
|
-
else if (typeof value === 'symbol') {
|
|
537
|
-
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
538
|
-
}
|
|
539
|
-
else if (typeof value === 'function') {
|
|
540
|
-
throw new UnexpectedError("".concat(name, " is function"));
|
|
541
|
-
}
|
|
542
|
-
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
543
|
-
for (var i = 0; i < value.length; i++) {
|
|
544
|
-
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
else if (typeof value === 'object') {
|
|
548
|
-
if (value instanceof Date) {
|
|
549
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
550
|
-
}
|
|
551
|
-
else if (value instanceof Map) {
|
|
552
|
-
throw new UnexpectedError("".concat(name, " is Map"));
|
|
553
|
-
}
|
|
554
|
-
else if (value instanceof Set) {
|
|
555
|
-
throw new UnexpectedError("".concat(name, " is Set"));
|
|
556
|
-
}
|
|
557
|
-
else if (value instanceof RegExp) {
|
|
558
|
-
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
559
|
-
}
|
|
560
|
-
else if (value instanceof Error) {
|
|
561
|
-
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
562
|
-
}
|
|
563
|
-
else {
|
|
564
|
-
try {
|
|
565
|
-
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
566
|
-
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
567
|
-
if (subValue === undefined) {
|
|
568
|
-
// Note: undefined in object is serializable - it is just omited
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
575
|
-
finally {
|
|
576
|
-
try {
|
|
577
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
578
|
-
}
|
|
579
|
-
finally { if (e_1) throw e_1.error; }
|
|
580
|
-
}
|
|
581
|
-
try {
|
|
582
|
-
JSON.stringify(value); // <- TODO: [0]
|
|
583
|
-
}
|
|
584
|
-
catch (error) {
|
|
585
|
-
if (!(error instanceof Error)) {
|
|
586
|
-
throw error;
|
|
587
|
-
}
|
|
588
|
-
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
589
|
-
}
|
|
590
|
-
/*
|
|
591
|
-
TODO: [0] Is there some more elegant way to check circular references?
|
|
592
|
-
const seen = new Set();
|
|
593
|
-
const stack = [{ value }];
|
|
594
|
-
while (stack.length > 0) {
|
|
595
|
-
const { value } = stack.pop()!;
|
|
596
|
-
if (typeof value === 'object' && value !== null) {
|
|
597
|
-
if (seen.has(value)) {
|
|
598
|
-
throw new UnexpectedError(`${name} has circular reference`);
|
|
599
|
-
}
|
|
600
|
-
seen.add(value);
|
|
601
|
-
if (Array.isArray(value)) {
|
|
602
|
-
stack.push(...value.map((value) => ({ value })));
|
|
603
|
-
} else {
|
|
604
|
-
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
*/
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
else {
|
|
613
|
-
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
/**
|
|
617
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
618
|
-
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
619
|
-
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
620
|
-
*/
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* @@@
|
|
624
|
-
* @@@
|
|
625
|
-
*
|
|
626
|
-
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
627
|
-
*
|
|
628
|
-
* @param name - Name of the object for debugging purposes
|
|
629
|
-
* @param objectValue - Object to be deeply frozen
|
|
630
|
-
* @returns The same object as the input, but deeply frozen
|
|
631
|
-
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
632
|
-
*/
|
|
633
|
-
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
634
|
-
checkSerializableAsJson(name, objectValue);
|
|
635
|
-
return $deepFreeze(objectValue);
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
639
|
-
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
640
|
-
*/
|
|
641
|
-
|
|
642
449
|
/**
|
|
643
450
|
* Warning message for the generated sections and files files
|
|
644
451
|
*
|
|
@@ -653,6 +460,18 @@
|
|
|
653
460
|
* @public exported from `@promptbook/core`
|
|
654
461
|
*/
|
|
655
462
|
var NAME = "Promptbook";
|
|
463
|
+
/**
|
|
464
|
+
* Email of the responsible person
|
|
465
|
+
*
|
|
466
|
+
* @public exported from `@promptbook/core`
|
|
467
|
+
*/
|
|
468
|
+
var ADMIN_EMAIL = 'me@pavolhejny.com';
|
|
469
|
+
/**
|
|
470
|
+
* Name of the responsible person for the Promptbook on GitHub
|
|
471
|
+
*
|
|
472
|
+
* @public exported from `@promptbook/core`
|
|
473
|
+
*/
|
|
474
|
+
var ADMIN_GITHUB_NAME = 'hejny';
|
|
656
475
|
/**
|
|
657
476
|
* Claim for the Promptbook
|
|
658
477
|
*
|
|
@@ -776,7 +595,8 @@
|
|
|
776
595
|
*
|
|
777
596
|
* @public exported from `@promptbook/core`
|
|
778
597
|
*/
|
|
779
|
-
var RESERVED_PARAMETER_NAMES =
|
|
598
|
+
var RESERVED_PARAMETER_NAMES =
|
|
599
|
+
/* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
|
|
780
600
|
'content',
|
|
781
601
|
'context',
|
|
782
602
|
'knowledge',
|
|
@@ -786,7 +606,7 @@
|
|
|
786
606
|
// <- TODO: list here all command names
|
|
787
607
|
// <- TODO: Add more like 'date', 'modelName',...
|
|
788
608
|
// <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
|
|
789
|
-
]
|
|
609
|
+
];
|
|
790
610
|
/**
|
|
791
611
|
* @@@
|
|
792
612
|
*
|
|
@@ -904,6 +724,40 @@
|
|
|
904
724
|
return PipelineLogicError;
|
|
905
725
|
}(Error));
|
|
906
726
|
|
|
727
|
+
/**
|
|
728
|
+
* Make error report URL for the given error
|
|
729
|
+
*
|
|
730
|
+
* @private !!!!!!
|
|
731
|
+
*/
|
|
732
|
+
function getErrorReportUrl(error) {
|
|
733
|
+
var report = {
|
|
734
|
+
title: "\uD83D\uDC1C Error report from ".concat(NAME),
|
|
735
|
+
body: spaceTrim__default["default"](function (block) { return "\n\n\n `".concat(error.name || 'Error', "` has occurred in the [").concat(NAME, "], please look into it @").concat(ADMIN_GITHUB_NAME, ".\n\n ```\n ").concat(block(error.message || '(no error message)'), "\n ```\n\n\n ## More info:\n\n - **Promptbook engine version:** ").concat(PROMPTBOOK_ENGINE_VERSION, "\n - **Book language version:** ").concat(BOOK_LANGUAGE_VERSION, "\n - **Time:** ").concat(new Date().toISOString(), "\n\n <details>\n <summary>Stack trace:</summary>\n\n ## Stack trace:\n\n ```stacktrace\n ").concat(block(error.stack || '(empty)'), "\n ```\n </details>\n\n "); }),
|
|
736
|
+
};
|
|
737
|
+
var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
|
|
738
|
+
reportUrl.searchParams.set('labels', 'bug');
|
|
739
|
+
reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
|
|
740
|
+
reportUrl.searchParams.set('title', report.title);
|
|
741
|
+
reportUrl.searchParams.set('body', report.body);
|
|
742
|
+
return reportUrl;
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* This error type indicates that the error should not happen and its last check before crashing with some other error
|
|
747
|
+
*
|
|
748
|
+
* @public exported from `@promptbook/core`
|
|
749
|
+
*/
|
|
750
|
+
var UnexpectedError = /** @class */ (function (_super) {
|
|
751
|
+
__extends(UnexpectedError, _super);
|
|
752
|
+
function UnexpectedError(message) {
|
|
753
|
+
var _this = _super.call(this, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(message), "\n\n Note: This error should not happen.\n It's probbably a bug in the pipeline collection\n\n Please report issue:\n ").concat(block(getErrorReportUrl(new Error(message)).href), "\n\n Or contact us on ").concat(ADMIN_EMAIL, "\n\n "); })) || this;
|
|
754
|
+
_this.name = 'UnexpectedError';
|
|
755
|
+
Object.setPrototypeOf(_this, UnexpectedError.prototype);
|
|
756
|
+
return _this;
|
|
757
|
+
}
|
|
758
|
+
return UnexpectedError;
|
|
759
|
+
}(Error));
|
|
760
|
+
|
|
907
761
|
/**
|
|
908
762
|
* Tests if given string is valid semantic version
|
|
909
763
|
*
|
|
@@ -1384,6 +1238,183 @@
|
|
|
1384
1238
|
return parameterNames;
|
|
1385
1239
|
}
|
|
1386
1240
|
|
|
1241
|
+
/**
|
|
1242
|
+
* @@@
|
|
1243
|
+
*
|
|
1244
|
+
* Note: `$` is used to indicate that this function is not a pure function - it mutates given object
|
|
1245
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1246
|
+
*
|
|
1247
|
+
* @returns The same object as the input, but deeply frozen
|
|
1248
|
+
* @public exported from `@promptbook/utils`
|
|
1249
|
+
*/
|
|
1250
|
+
function $deepFreeze(objectValue) {
|
|
1251
|
+
var e_1, _a;
|
|
1252
|
+
var propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1253
|
+
try {
|
|
1254
|
+
for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
|
|
1255
|
+
var propertyName = propertyNames_1_1.value;
|
|
1256
|
+
var value = objectValue[propertyName];
|
|
1257
|
+
if (value && typeof value === 'object') {
|
|
1258
|
+
$deepFreeze(value);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
}
|
|
1262
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1263
|
+
finally {
|
|
1264
|
+
try {
|
|
1265
|
+
if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
|
|
1266
|
+
}
|
|
1267
|
+
finally { if (e_1) throw e_1.error; }
|
|
1268
|
+
}
|
|
1269
|
+
return Object.freeze(objectValue);
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1273
|
+
*/
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Checks if the value is [🚉] serializable as JSON
|
|
1277
|
+
* If not, throws an UnexpectedError with a rich error message and tracking
|
|
1278
|
+
*
|
|
1279
|
+
* - Almost all primitives are serializable BUT:
|
|
1280
|
+
* - `undefined` is not serializable
|
|
1281
|
+
* - `NaN` is not serializable
|
|
1282
|
+
* - Objects and arrays are serializable if all their properties are serializable
|
|
1283
|
+
* - Functions are not serializable
|
|
1284
|
+
* - Circular references are not serializable
|
|
1285
|
+
* - `Date` objects are not serializable
|
|
1286
|
+
* - `Map` and `Set` objects are not serializable
|
|
1287
|
+
* - `RegExp` objects are not serializable
|
|
1288
|
+
* - `Error` objects are not serializable
|
|
1289
|
+
* - `Symbol` objects are not serializable
|
|
1290
|
+
* - And much more...
|
|
1291
|
+
*
|
|
1292
|
+
* @throws UnexpectedError if the value is not serializable as JSON
|
|
1293
|
+
* @public exported from `@promptbook/utils`
|
|
1294
|
+
*/
|
|
1295
|
+
function checkSerializableAsJson(name, value) {
|
|
1296
|
+
var e_1, _a;
|
|
1297
|
+
if (value === undefined) {
|
|
1298
|
+
throw new UnexpectedError("".concat(name, " is undefined"));
|
|
1299
|
+
}
|
|
1300
|
+
else if (value === null) {
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
else if (typeof value === 'boolean') {
|
|
1304
|
+
return;
|
|
1305
|
+
}
|
|
1306
|
+
else if (typeof value === 'number' && !isNaN(value)) {
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
else if (typeof value === 'string') {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
else if (typeof value === 'symbol') {
|
|
1313
|
+
throw new UnexpectedError("".concat(name, " is symbol"));
|
|
1314
|
+
}
|
|
1315
|
+
else if (typeof value === 'function') {
|
|
1316
|
+
throw new UnexpectedError("".concat(name, " is function"));
|
|
1317
|
+
}
|
|
1318
|
+
else if (typeof value === 'object' && Array.isArray(value)) {
|
|
1319
|
+
for (var i = 0; i < value.length; i++) {
|
|
1320
|
+
checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
else if (typeof value === 'object') {
|
|
1324
|
+
if (value instanceof Date) {
|
|
1325
|
+
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
|
|
1326
|
+
}
|
|
1327
|
+
else if (value instanceof Map) {
|
|
1328
|
+
throw new UnexpectedError("".concat(name, " is Map"));
|
|
1329
|
+
}
|
|
1330
|
+
else if (value instanceof Set) {
|
|
1331
|
+
throw new UnexpectedError("".concat(name, " is Set"));
|
|
1332
|
+
}
|
|
1333
|
+
else if (value instanceof RegExp) {
|
|
1334
|
+
throw new UnexpectedError("".concat(name, " is RegExp"));
|
|
1335
|
+
}
|
|
1336
|
+
else if (value instanceof Error) {
|
|
1337
|
+
throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
|
|
1338
|
+
}
|
|
1339
|
+
else {
|
|
1340
|
+
try {
|
|
1341
|
+
for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
1342
|
+
var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
|
|
1343
|
+
if (subValue === undefined) {
|
|
1344
|
+
// Note: undefined in object is serializable - it is just omited
|
|
1345
|
+
continue;
|
|
1346
|
+
}
|
|
1347
|
+
checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1351
|
+
finally {
|
|
1352
|
+
try {
|
|
1353
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
1354
|
+
}
|
|
1355
|
+
finally { if (e_1) throw e_1.error; }
|
|
1356
|
+
}
|
|
1357
|
+
try {
|
|
1358
|
+
JSON.stringify(value); // <- TODO: [0]
|
|
1359
|
+
}
|
|
1360
|
+
catch (error) {
|
|
1361
|
+
if (!(error instanceof Error)) {
|
|
1362
|
+
throw error;
|
|
1363
|
+
}
|
|
1364
|
+
throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
|
|
1365
|
+
}
|
|
1366
|
+
/*
|
|
1367
|
+
TODO: [0] Is there some more elegant way to check circular references?
|
|
1368
|
+
const seen = new Set();
|
|
1369
|
+
const stack = [{ value }];
|
|
1370
|
+
while (stack.length > 0) {
|
|
1371
|
+
const { value } = stack.pop()!;
|
|
1372
|
+
if (typeof value === 'object' && value !== null) {
|
|
1373
|
+
if (seen.has(value)) {
|
|
1374
|
+
throw new UnexpectedError(`${name} has circular reference`);
|
|
1375
|
+
}
|
|
1376
|
+
seen.add(value);
|
|
1377
|
+
if (Array.isArray(value)) {
|
|
1378
|
+
stack.push(...value.map((value) => ({ value })));
|
|
1379
|
+
} else {
|
|
1380
|
+
stack.push(...Object.values(value).map((value) => ({ value })));
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
*/
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
throw new UnexpectedError("".concat(name, " is unknown"));
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1394
|
+
* TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
|
|
1395
|
+
* Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
|
|
1396
|
+
*/
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @@@
|
|
1400
|
+
* @@@
|
|
1401
|
+
*
|
|
1402
|
+
* Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
|
|
1403
|
+
*
|
|
1404
|
+
* @param name - Name of the object for debugging purposes
|
|
1405
|
+
* @param objectValue - Object to be deeply frozen
|
|
1406
|
+
* @returns The same object as the input, but deeply frozen
|
|
1407
|
+
* @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
|
|
1408
|
+
*/
|
|
1409
|
+
function $asDeeplyFrozenSerializableJson(name, objectValue) {
|
|
1410
|
+
checkSerializableAsJson(name, objectValue);
|
|
1411
|
+
return $deepFreeze(objectValue);
|
|
1412
|
+
}
|
|
1413
|
+
/**
|
|
1414
|
+
* TODO: [🧠][🛣] More elegant way to tracking than passing `name`
|
|
1415
|
+
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
1416
|
+
*/
|
|
1417
|
+
|
|
1387
1418
|
/**
|
|
1388
1419
|
* Unprepare just strips the preparation data of the pipeline
|
|
1389
1420
|
*
|
|
@@ -2651,6 +2682,7 @@
|
|
|
2651
2682
|
*/
|
|
2652
2683
|
function extractVariablesFromScript(script) {
|
|
2653
2684
|
var variables = new Set();
|
|
2685
|
+
var originalScript = script;
|
|
2654
2686
|
script = "(()=>{".concat(script, "})()");
|
|
2655
2687
|
try {
|
|
2656
2688
|
for (var i = 0; i < 100 /* <- TODO: This limit to configuration */; i++)
|
|
@@ -2661,20 +2693,32 @@
|
|
|
2661
2693
|
if (!(error instanceof ReferenceError)) {
|
|
2662
2694
|
throw error;
|
|
2663
2695
|
}
|
|
2664
|
-
var undefinedName = error.message.split(' ')[0];
|
|
2665
2696
|
/*
|
|
2666
2697
|
Note: Parsing the error
|
|
2698
|
+
🌟 Most devices:
|
|
2667
2699
|
[PipelineUrlError: thing is not defined]
|
|
2700
|
+
|
|
2701
|
+
🍏 iPhone`s Safari:
|
|
2702
|
+
[PipelineUrlError: Can't find variable: thing]
|
|
2668
2703
|
*/
|
|
2669
|
-
|
|
2704
|
+
var variableName = undefined;
|
|
2705
|
+
if (error.message.startsWith("Can't")) {
|
|
2706
|
+
// 🍏 Case
|
|
2707
|
+
variableName = error.message.split(' ').pop();
|
|
2708
|
+
}
|
|
2709
|
+
else {
|
|
2710
|
+
// 🌟 Case
|
|
2711
|
+
variableName = error.message.split(' ').shift();
|
|
2712
|
+
}
|
|
2713
|
+
if (variableName === undefined) {
|
|
2670
2714
|
throw error;
|
|
2671
2715
|
}
|
|
2672
|
-
if (script.includes(
|
|
2673
|
-
script = "const ".concat(
|
|
2716
|
+
if (script.includes(variableName + '(')) {
|
|
2717
|
+
script = "const ".concat(variableName, " = ()=>'';") + script;
|
|
2674
2718
|
}
|
|
2675
2719
|
else {
|
|
2676
|
-
variables.add(
|
|
2677
|
-
script = "const ".concat(
|
|
2720
|
+
variables.add(variableName);
|
|
2721
|
+
script = "const ".concat(variableName, " = '';") + script;
|
|
2678
2722
|
}
|
|
2679
2723
|
}
|
|
2680
2724
|
}
|
|
@@ -2682,7 +2726,9 @@
|
|
|
2682
2726
|
if (!(error instanceof Error)) {
|
|
2683
2727
|
throw error;
|
|
2684
2728
|
}
|
|
2685
|
-
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n
|
|
2729
|
+
throw new ParseError(spaceTrim.spaceTrim(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.toString()), "}\n\n\n Found variables:\n\n ").concat(Array.from(variables)
|
|
2730
|
+
.map(function (variableName, i) { return "".concat(i + 1, ") ").concat(variableName); })
|
|
2731
|
+
.join('\n'), "\n\n\n The script:\n\n ```javascript\n ").concat(block(originalScript), "\n ```\n "); }));
|
|
2686
2732
|
}
|
|
2687
2733
|
return variables;
|
|
2688
2734
|
}
|
|
@@ -6140,7 +6186,7 @@
|
|
|
6140
6186
|
throw new ParseError(spaceTrim__default["default"]("\n Section type is already defined in the section.\n It can be defined only once.\n "));
|
|
6141
6187
|
}
|
|
6142
6188
|
$taskJson.isSectionTypeSet = true;
|
|
6143
|
-
// TODO: [🍧] Rearrange better - but at bottom and unwrap from function
|
|
6189
|
+
// TODO: [🍧][💩] Rearrange better - but at bottom and unwrap from function
|
|
6144
6190
|
var expectResultingParameterName = function () {
|
|
6145
6191
|
if ($taskJson.resultingParameterName) {
|
|
6146
6192
|
return;
|
|
@@ -7442,7 +7488,7 @@
|
|
|
7442
7488
|
if ($pipelineJson.defaultModelRequirements[command.key] !== undefined) {
|
|
7443
7489
|
if ($pipelineJson.defaultModelRequirements[command.key] === command.value) {
|
|
7444
7490
|
console.warn("Multiple commands `MODEL ".concat(command.key, " ").concat(command.value, "` in the pipeline head"));
|
|
7445
|
-
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
7491
|
+
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
7446
7492
|
}
|
|
7447
7493
|
else {
|
|
7448
7494
|
throw new ParseError(spaceTrim__default["default"]("\n Redefinition of MODEL `".concat(command.key, "` in the pipeline head\n\n You have used:\n - MODEL ").concat(command.key, " ").concat($pipelineJson.defaultModelRequirements[command.key], "\n - MODEL ").concat(command.key, " ").concat(command.value, "\n ")));
|
|
@@ -8077,7 +8123,7 @@
|
|
|
8077
8123
|
personaCommandParser,
|
|
8078
8124
|
foreachCommandParser,
|
|
8079
8125
|
boilerplateCommandParser, // <- TODO: !! Only in development, remove in production
|
|
8080
|
-
// <- Note: [♓️] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
|
|
8126
|
+
// <- Note: [♓️][💩] This is the order of the commands in the pipeline, BUT its not used in parsing and before usage maybe it should be done better
|
|
8081
8127
|
];
|
|
8082
8128
|
/**
|
|
8083
8129
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -9007,11 +9053,11 @@
|
|
|
9007
9053
|
var placeForSection = removeContentComments(content).match(/^##.*$/im);
|
|
9008
9054
|
if (placeForSection !== null) {
|
|
9009
9055
|
var _a = __read(placeForSection, 1), heading_1 = _a[0];
|
|
9010
|
-
return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n
|
|
9056
|
+
return content.replace(heading_1, spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(contentToInsert), "\n\n ").concat(block(heading_1), "\n "); }));
|
|
9011
9057
|
}
|
|
9012
9058
|
console.warn("No place where to put the section <!--".concat(sectionName, "-->, using the end of the file"));
|
|
9013
|
-
// <- TODO: [🚎] Some better way how to get warnings from pipeline parsing / logic
|
|
9014
|
-
return spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(content), "\n
|
|
9059
|
+
// <- TODO: [🚎][💩] Some better way how to get warnings from pipeline parsing / logic
|
|
9060
|
+
return spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(content), "\n\n ").concat(block(contentToInsert), "\n "); });
|
|
9015
9061
|
}
|
|
9016
9062
|
/**
|
|
9017
9063
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -9562,7 +9608,7 @@
|
|
|
9562
9608
|
'\n\n' +
|
|
9563
9609
|
executionReportJson.promptExecutions
|
|
9564
9610
|
.map(function (promptExecution) {
|
|
9565
|
-
// TODO: Make some better system to convert
|
|
9611
|
+
// TODO: [💩] Make some better system to convert headings to links
|
|
9566
9612
|
var hash = normalizeToKebabCase(promptExecution.prompt.title);
|
|
9567
9613
|
if (/^\s*\p{Extended_Pictographic}/u.test(promptExecution.prompt.title)) {
|
|
9568
9614
|
hash = '-' + hash;
|
|
@@ -10801,6 +10847,8 @@
|
|
|
10801
10847
|
exports.$llmToolsRegister = $llmToolsRegister;
|
|
10802
10848
|
exports.$scrapersMetadataRegister = $scrapersMetadataRegister;
|
|
10803
10849
|
exports.$scrapersRegister = $scrapersRegister;
|
|
10850
|
+
exports.ADMIN_EMAIL = ADMIN_EMAIL;
|
|
10851
|
+
exports.ADMIN_GITHUB_NAME = ADMIN_GITHUB_NAME;
|
|
10804
10852
|
exports.AbstractFormatError = AbstractFormatError;
|
|
10805
10853
|
exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
|
|
10806
10854
|
exports.BlackholeStorage = BlackholeStorage;
|