@promptbook/pdf 0.79.0 → 0.80.0-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +4 -0
  2. package/esm/index.es.js +425 -348
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +6 -6
  5. package/esm/typings/src/_packages/core.index.d.ts +8 -6
  6. package/esm/typings/src/_packages/types.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/utils.index.d.ts +4 -0
  8. package/esm/typings/src/cli/cli-commands/runInteractiveChatbot.d.ts +32 -0
  9. package/esm/typings/src/commands/_common/getParserForCommand.d.ts +1 -1
  10. package/esm/typings/src/commands/_common/parseCommand.d.ts +1 -1
  11. package/esm/typings/src/commands/_common/stringifyCommand.d.ts +1 -1
  12. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +3 -0
  13. package/esm/typings/src/config.d.ts +0 -25
  14. package/esm/typings/src/constants.d.ts +35 -0
  15. package/esm/typings/src/conversion/{pipelineStringToJson.d.ts → compilePipeline.d.ts} +3 -3
  16. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +1 -0
  17. package/esm/typings/src/conversion/{pipelineStringToJsonSync.d.ts → precompilePipeline.d.ts} +4 -3
  18. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +20 -0
  19. package/esm/typings/src/high-level-abstractions/implicit-formfactor/ImplicitFormfactorHla.d.ts +10 -0
  20. package/esm/typings/src/high-level-abstractions/index.d.ts +44 -0
  21. package/esm/typings/src/high-level-abstractions/quick-chatbot/QuickChatbotHla.d.ts +10 -0
  22. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  23. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  24. package/esm/typings/src/prepare/prepareTasks.d.ts +1 -0
  25. package/esm/typings/src/prepare/unpreparePipeline.d.ts +1 -0
  26. package/esm/typings/src/types/typeAliases.d.ts +1 -1
  27. package/esm/typings/src/utils/normalization/orderJson.d.ts +21 -0
  28. package/esm/typings/src/utils/normalization/orderJson.test.d.ts +4 -0
  29. package/esm/typings/src/utils/organization/keepTypeImported.d.ts +9 -0
  30. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +1 -1
  31. package/esm/typings/src/utils/serialization/checkSerializableAsJson.d.ts +20 -2
  32. package/esm/typings/src/utils/serialization/deepClone.test.d.ts +1 -0
  33. package/esm/typings/src/utils/serialization/exportJson.d.ts +29 -0
  34. package/esm/typings/src/utils/serialization/isSerializableAsJson.d.ts +2 -1
  35. package/package.json +2 -2
  36. package/umd/index.umd.js +425 -348
  37. package/umd/index.umd.js.map +1 -1
  38. package/esm/typings/src/utils/serialization/$asDeeplyFrozenSerializableJson.d.ts +0 -17
  39. /package/esm/typings/src/conversion/{pipelineStringToJson.test.d.ts → compilePipeline.test.d.ts} +0 -0
  40. /package/esm/typings/src/conversion/{pipelineStringToJsonSync.test.d.ts → precompilePipeline.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -20,7 +20,7 @@ var BOOK_LANGUAGE_VERSION = '1.0.0';
20
20
  *
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
23
+ var PROMPTBOOK_ENGINE_VERSION = '0.80.0-0';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -174,7 +174,7 @@ var NotYetImplementedError = /** @class */ (function (_super) {
174
174
  function TODO_USE() {
175
175
  }
176
176
 
177
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],knowledgeSources:[],knowledgePieces:[],personas:[],preparations:[],sourceFile:"./books/prepare-persona.book.md"}];
177
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-from-markdown.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-keywords.book.md"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book.md",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Title should be concise and clear\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-knowledge-title.book.md"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book.md",formfactorName:"GENERIC",parameters:[{name:"availableModelNames",description:"List of available model names separated by comma (,)",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are experienced AI engineer, you need to create virtual assistant.\nWrite\n\n## Example\n\n```json\n{\n\"modelName\": \"gpt-4o\",\n\"systemMessage\": \"You are experienced AI engineer and helpfull assistant.\",\n\"temperature\": 0.7\n}\n```\n\n## Instructions\n\n- Your output format is JSON object\n- Write just the JSON object, no other text should be present\n- It contains the following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nPick from the following models:\n\n- {availableModelNames}\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelRequirements",format:"JSON",dependentParameterNames:["availableModelNames","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sourceFile:"./books/prepare-persona.book.md"}];
178
178
 
179
179
  /**
180
180
  * Prettify the html code
@@ -222,6 +222,7 @@ function capitalize(word) {
222
222
  /**
223
223
  * Converts promptbook in JSON format to string format
224
224
  *
225
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
225
226
  * @param pipelineJson Promptbook in JSON format (.book.json)
226
227
  * @returns Promptbook in string format (.book.md)
227
228
  * @public exported from `@promptbook/core`
@@ -505,78 +506,368 @@ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
505
506
  * @public exported from `@promptbook/core`
506
507
  */
507
508
  var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
509
+ // <- TODO: [🧜‍♂️]
508
510
  /**
509
- * Nonce which is used for replacing things in strings
511
+ * @@@
510
512
  *
511
- * @private within the repository
513
+ * @public exported from `@promptbook/core`
512
514
  */
513
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
515
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
516
+ delimiter: ',',
517
+ quoteChar: '"',
518
+ newline: '\n',
519
+ skipEmptyLines: true,
520
+ });
514
521
  /**
515
- * The names of the parameters that are reserved for special purposes
522
+ * @@@
516
523
  *
517
524
  * @public exported from `@promptbook/core`
518
525
  */
519
- var RESERVED_PARAMETER_NAMES =
520
- /* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
521
- 'content',
522
- 'context',
523
- 'knowledge',
524
- 'examples',
525
- 'modelName',
526
- 'currentDate',
527
- // <- TODO: list here all command names
528
- // <- TODO: Add more like 'date', 'modelName',...
529
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
530
- ];
526
+ var DEFAULT_IS_VERBOSE = false;
531
527
  /**
532
528
  * @@@
533
529
  *
534
- * @private within the repository
530
+ * @public exported from `@promptbook/core`
535
531
  */
536
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
532
+ var DEFAULT_IS_AUTO_INSTALLED = false;
537
533
  /**
538
534
  * @@@
539
535
  *
540
536
  * @private within the repository
541
537
  */
542
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
543
- // <- TODO: [🧜‍♂️]
538
+ var IS_PIPELINE_LOGIC_VALIDATED = just(
539
+ /**/
540
+ // Note: In normal situations, we check the pipeline logic:
541
+ true);
544
542
  /**
545
- * @@@
543
+ * Note: [💞] Ignore a discrepancy between file name and entity name
544
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
545
+ */
546
+
547
+ /**
548
+ * Orders JSON object by keys
549
+ *
550
+ * @returns The same type of object as the input re-ordered
551
+ * @public exported from `@promptbook/utils`
552
+ */
553
+ function orderJson(options) {
554
+ var value = options.value, order = options.order;
555
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
556
+ return orderedValue;
557
+ }
558
+
559
+ /**
560
+ * Freezes the given object and all its nested objects recursively
561
+ *
562
+ * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
563
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
564
+ *
565
+ * @returns The same object as the input, but deeply frozen
566
+ * @public exported from `@promptbook/utils`
567
+ */
568
+ function $deepFreeze(objectValue) {
569
+ var e_1, _a;
570
+ if (Array.isArray(objectValue)) {
571
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
572
+ }
573
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
574
+ try {
575
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
576
+ var propertyName = propertyNames_1_1.value;
577
+ var value = objectValue[propertyName];
578
+ if (value && typeof value === 'object') {
579
+ $deepFreeze(value);
580
+ }
581
+ }
582
+ }
583
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
584
+ finally {
585
+ try {
586
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
587
+ }
588
+ finally { if (e_1) throw e_1.error; }
589
+ }
590
+ Object.freeze(objectValue);
591
+ return objectValue;
592
+ }
593
+ /**
594
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
595
+ */
596
+
597
+ /**
598
+ * Make error report URL for the given error
599
+ *
600
+ * @private !!!!!!
601
+ */
602
+ function getErrorReportUrl(error) {
603
+ var report = {
604
+ title: "\uD83D\uDC1C Error report from ".concat(NAME),
605
+ body: spaceTrim$1(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 "); }),
606
+ };
607
+ var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
608
+ reportUrl.searchParams.set('labels', 'bug');
609
+ reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
610
+ reportUrl.searchParams.set('title', report.title);
611
+ reportUrl.searchParams.set('body', report.body);
612
+ return reportUrl;
613
+ }
614
+
615
+ /**
616
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
546
617
  *
547
618
  * @public exported from `@promptbook/core`
548
619
  */
549
- var DEFAULT_CSV_SETTINGS = Object.freeze({
550
- delimiter: ',',
551
- quoteChar: '"',
552
- newline: '\n',
553
- skipEmptyLines: true,
554
- });
620
+ var UnexpectedError = /** @class */ (function (_super) {
621
+ __extends(UnexpectedError, _super);
622
+ function UnexpectedError(message) {
623
+ var _this = _super.call(this, 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;
624
+ _this.name = 'UnexpectedError';
625
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
626
+ return _this;
627
+ }
628
+ return UnexpectedError;
629
+ }(Error));
630
+
631
+ /**
632
+ * Checks if the value is [🚉] serializable as JSON
633
+ * If not, throws an UnexpectedError with a rich error message and tracking
634
+ *
635
+ * - Almost all primitives are serializable BUT:
636
+ * - `undefined` is not serializable
637
+ * - `NaN` is not serializable
638
+ * - Objects and arrays are serializable if all their properties are serializable
639
+ * - Functions are not serializable
640
+ * - Circular references are not serializable
641
+ * - `Date` objects are not serializable
642
+ * - `Map` and `Set` objects are not serializable
643
+ * - `RegExp` objects are not serializable
644
+ * - `Error` objects are not serializable
645
+ * - `Symbol` objects are not serializable
646
+ * - And much more...
647
+ *
648
+ * @throws UnexpectedError if the value is not serializable as JSON
649
+ * @public exported from `@promptbook/utils`
650
+ */
651
+ function checkSerializableAsJson(options) {
652
+ var e_1, _a;
653
+ var value = options.value, name = options.name, message = options.message;
654
+ if (value === undefined) {
655
+ throw new UnexpectedError("".concat(name, " is undefined"));
656
+ }
657
+ else if (value === null) {
658
+ return;
659
+ }
660
+ else if (typeof value === 'boolean') {
661
+ return;
662
+ }
663
+ else if (typeof value === 'number' && !isNaN(value)) {
664
+ return;
665
+ }
666
+ else if (typeof value === 'string') {
667
+ return;
668
+ }
669
+ else if (typeof value === 'symbol') {
670
+ throw new UnexpectedError("".concat(name, " is symbol"));
671
+ }
672
+ else if (typeof value === 'function') {
673
+ throw new UnexpectedError("".concat(name, " is function"));
674
+ }
675
+ else if (typeof value === 'object' && Array.isArray(value)) {
676
+ for (var i = 0; i < value.length; i++) {
677
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
678
+ }
679
+ }
680
+ else if (typeof value === 'object') {
681
+ if (value instanceof Date) {
682
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is Date\n\n Use `string_date_iso8601` instead\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
683
+ }
684
+ else if (value instanceof Map) {
685
+ throw new UnexpectedError("".concat(name, " is Map"));
686
+ }
687
+ else if (value instanceof Set) {
688
+ throw new UnexpectedError("".concat(name, " is Set"));
689
+ }
690
+ else if (value instanceof RegExp) {
691
+ throw new UnexpectedError("".concat(name, " is RegExp"));
692
+ }
693
+ else if (value instanceof Error) {
694
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is unserialized Error\n\n Use function `serializeError`\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n\n "); }));
695
+ }
696
+ else {
697
+ try {
698
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
699
+ var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
700
+ if (subValue === undefined) {
701
+ // Note: undefined in object is serializable - it is just omited
702
+ continue;
703
+ }
704
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
705
+ }
706
+ }
707
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
708
+ finally {
709
+ try {
710
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
711
+ }
712
+ finally { if (e_1) throw e_1.error; }
713
+ }
714
+ try {
715
+ JSON.stringify(value); // <- TODO: [0]
716
+ }
717
+ catch (error) {
718
+ if (!(error instanceof Error)) {
719
+ throw error;
720
+ }
721
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is not serializable\n\n ").concat(block(error.toString()), "\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
722
+ }
723
+ /*
724
+ TODO: [0] Is there some more elegant way to check circular references?
725
+ const seen = new Set();
726
+ const stack = [{ value }];
727
+ while (stack.length > 0) {
728
+ const { value } = stack.pop()!;
729
+ if (typeof value === 'object' && value !== null) {
730
+ if (seen.has(value)) {
731
+ throw new UnexpectedError(`${name} has circular reference`);
732
+ }
733
+ seen.add(value);
734
+ if (Array.isArray(value)) {
735
+ stack.push(...value.map((value) => ({ value })));
736
+ } else {
737
+ stack.push(...Object.values(value).map((value) => ({ value })));
738
+ }
739
+ }
740
+ }
741
+ */
742
+ return;
743
+ }
744
+ }
745
+ else {
746
+ throw new UnexpectedError(spaceTrim$1(function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
747
+ }
748
+ }
749
+ /**
750
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
751
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
752
+ * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
753
+ */
754
+
555
755
  /**
556
756
  * @@@
557
757
  *
758
+ * @public exported from `@promptbook/utils`
759
+ */
760
+ function deepClone(objectValue) {
761
+ return JSON.parse(JSON.stringify(objectValue));
762
+ /*
763
+ !!!!!!!!
764
+ TODO: [🧠] Is there a better implementation?
765
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
766
+ > for (const propertyName of propertyNames) {
767
+ > const value = (objectValue as really_any)[propertyName];
768
+ > if (value && typeof value === 'object') {
769
+ > deepClone(value);
770
+ > }
771
+ > }
772
+ > return Object.assign({}, objectValue);
773
+ */
774
+ }
775
+ /**
776
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
777
+ */
778
+
779
+ /**
780
+ * Utility to export a JSON object from a function
781
+ *
782
+ * 1) Checks if the value is serializable as JSON
783
+ * 2) Makes a deep clone of the object
784
+ * 2) Orders the object properties
785
+ * 2) Deeply freezes the cloned object
786
+ *
787
+ * Note: This function does not mutates the given object
788
+ *
789
+ * @returns The same type of object as the input but read-only and re-ordered
790
+ * @public exported from `@promptbook/utils`
791
+ */
792
+ function exportJson(options) {
793
+ var name = options.name, value = options.value, order = options.order, message = options.message;
794
+ checkSerializableAsJson({ name: name, value: value, message: message });
795
+ var orderedValue =
796
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
797
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
798
+ // @ts-ignore
799
+ order === undefined
800
+ ? deepClone(value)
801
+ : orderJson({
802
+ value: value,
803
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
804
+ order: order,
805
+ });
806
+ $deepFreeze(orderedValue);
807
+ return orderedValue;
808
+ }
809
+ /**
810
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
811
+ */
812
+
813
+ /**
814
+ * Order of keys in the pipeline JSON
815
+ *
558
816
  * @public exported from `@promptbook/core`
559
817
  */
560
- var DEFAULT_IS_VERBOSE = false;
818
+ var ORDER_OF_PIPELINE_JSON = [
819
+ 'title',
820
+ 'pipelineUrl',
821
+ 'bookVersion',
822
+ 'description',
823
+ 'formfactorName',
824
+ 'parameters',
825
+ 'tasks',
826
+ 'personas',
827
+ 'preparations',
828
+ 'knowledgeSources',
829
+ 'knowledgePieces',
830
+ ];
831
+ /**
832
+ * Nonce which is used for replacing things in strings
833
+ *
834
+ * @private within the repository
835
+ */
836
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
561
837
  /**
562
838
  * @@@
563
839
  *
564
- * @public exported from `@promptbook/core`
840
+ * @private within the repository
565
841
  */
566
- var DEFAULT_IS_AUTO_INSTALLED = false;
842
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
567
843
  /**
568
844
  * @@@
569
845
  *
570
846
  * @private within the repository
571
847
  */
572
- var IS_PIPELINE_LOGIC_VALIDATED = just(
573
- /**/
574
- // Note: In normal situations, we check the pipeline logic:
575
- true);
848
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
849
+ /**
850
+ * The names of the parameters that are reserved for special purposes
851
+ *
852
+ * @public exported from `@promptbook/core`
853
+ */
854
+ var RESERVED_PARAMETER_NAMES = exportJson({
855
+ name: 'RESERVED_PARAMETER_NAMES',
856
+ message: "The names of the parameters that are reserved for special purposes",
857
+ value: [
858
+ 'content',
859
+ 'context',
860
+ 'knowledge',
861
+ 'examples',
862
+ 'modelName',
863
+ 'currentDate',
864
+ // <- TODO: list here all command names
865
+ // <- TODO: Add more like 'date', 'modelName',...
866
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
867
+ ],
868
+ });
576
869
  /**
577
- * TODO: Extract `constants.ts` from `config.ts`
578
870
  * Note: [💞] Ignore a discrepancy between file name and entity name
579
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
580
871
  */
581
872
 
582
873
  /**
@@ -614,40 +905,6 @@ var PipelineLogicError = /** @class */ (function (_super) {
614
905
  return PipelineLogicError;
615
906
  }(Error));
616
907
 
617
- /**
618
- * Make error report URL for the given error
619
- *
620
- * @private !!!!!!
621
- */
622
- function getErrorReportUrl(error) {
623
- var report = {
624
- title: "\uD83D\uDC1C Error report from ".concat(NAME),
625
- body: spaceTrim$1(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 "); }),
626
- };
627
- var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
628
- reportUrl.searchParams.set('labels', 'bug');
629
- reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
630
- reportUrl.searchParams.set('title', report.title);
631
- reportUrl.searchParams.set('body', report.body);
632
- return reportUrl;
633
- }
634
-
635
- /**
636
- * This error type indicates that the error should not happen and its last check before crashing with some other error
637
- *
638
- * @public exported from `@promptbook/core`
639
- */
640
- var UnexpectedError = /** @class */ (function (_super) {
641
- __extends(UnexpectedError, _super);
642
- function UnexpectedError(message) {
643
- var _this = _super.call(this, 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;
644
- _this.name = 'UnexpectedError';
645
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
646
- return _this;
647
- }
648
- return UnexpectedError;
649
- }(Error));
650
-
651
908
  /**
652
909
  * Tests if given string is valid semantic version
653
910
  *
@@ -885,6 +1142,21 @@ function validatePipelineCore(pipeline) {
885
1142
  }
886
1143
  };
887
1144
  try {
1145
+ /*
1146
+ TODO: [🧠][🅾] Should be empty pipeline valid or not
1147
+ // Note: Check that pipeline has some tasks
1148
+ if (pipeline.tasks.length === 0) {
1149
+ throw new PipelineLogicError(
1150
+ spaceTrim(
1151
+ (block) => `
1152
+ Pipeline must have at least one task
1153
+
1154
+ ${block(pipelineIdentification)}
1155
+ `,
1156
+ ),
1157
+ );
1158
+ }
1159
+ */
888
1160
  // Note: Check each parameter individually
889
1161
  for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
890
1162
  var parameter = _e.value;
@@ -1045,6 +1317,9 @@ function validatePipelineCore(pipeline) {
1045
1317
  while (unresovedTasks.length > 0) {
1046
1318
  _loop_3();
1047
1319
  }
1320
+ // Note: Check that formfactor is corresponding to the pipeline interface
1321
+ // TODO: !!!!!! Implement this
1322
+ // pipeline.formfactorName
1048
1323
  }
1049
1324
  /**
1050
1325
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -1128,189 +1403,10 @@ function extractParameterNames(template) {
1128
1403
  return parameterNames;
1129
1404
  }
1130
1405
 
1131
- /**
1132
- * @@@
1133
- *
1134
- * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
1135
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
1136
- *
1137
- * @returns The same object as the input, but deeply frozen
1138
- * @public exported from `@promptbook/utils`
1139
- */
1140
- function $deepFreeze(objectValue) {
1141
- var e_1, _a;
1142
- if (Array.isArray(objectValue)) {
1143
- return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
1144
- }
1145
- var propertyNames = Object.getOwnPropertyNames(objectValue);
1146
- try {
1147
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
1148
- var propertyName = propertyNames_1_1.value;
1149
- var value = objectValue[propertyName];
1150
- if (value && typeof value === 'object') {
1151
- $deepFreeze(value);
1152
- }
1153
- }
1154
- }
1155
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1156
- finally {
1157
- try {
1158
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
1159
- }
1160
- finally { if (e_1) throw e_1.error; }
1161
- }
1162
- return Object.freeze(objectValue);
1163
- }
1164
- /**
1165
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1166
- */
1167
-
1168
- /**
1169
- * Checks if the value is [🚉] serializable as JSON
1170
- * If not, throws an UnexpectedError with a rich error message and tracking
1171
- *
1172
- * - Almost all primitives are serializable BUT:
1173
- * - `undefined` is not serializable
1174
- * - `NaN` is not serializable
1175
- * - Objects and arrays are serializable if all their properties are serializable
1176
- * - Functions are not serializable
1177
- * - Circular references are not serializable
1178
- * - `Date` objects are not serializable
1179
- * - `Map` and `Set` objects are not serializable
1180
- * - `RegExp` objects are not serializable
1181
- * - `Error` objects are not serializable
1182
- * - `Symbol` objects are not serializable
1183
- * - And much more...
1184
- *
1185
- * @throws UnexpectedError if the value is not serializable as JSON
1186
- * @public exported from `@promptbook/utils`
1187
- */
1188
- function checkSerializableAsJson(name, value) {
1189
- var e_1, _a;
1190
- if (value === undefined) {
1191
- throw new UnexpectedError("".concat(name, " is undefined"));
1192
- }
1193
- else if (value === null) {
1194
- return;
1195
- }
1196
- else if (typeof value === 'boolean') {
1197
- return;
1198
- }
1199
- else if (typeof value === 'number' && !isNaN(value)) {
1200
- return;
1201
- }
1202
- else if (typeof value === 'string') {
1203
- return;
1204
- }
1205
- else if (typeof value === 'symbol') {
1206
- throw new UnexpectedError("".concat(name, " is symbol"));
1207
- }
1208
- else if (typeof value === 'function') {
1209
- throw new UnexpectedError("".concat(name, " is function"));
1210
- }
1211
- else if (typeof value === 'object' && Array.isArray(value)) {
1212
- for (var i = 0; i < value.length; i++) {
1213
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
1214
- }
1215
- }
1216
- else if (typeof value === 'object') {
1217
- if (value instanceof Date) {
1218
- throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
1219
- }
1220
- else if (value instanceof Map) {
1221
- throw new UnexpectedError("".concat(name, " is Map"));
1222
- }
1223
- else if (value instanceof Set) {
1224
- throw new UnexpectedError("".concat(name, " is Set"));
1225
- }
1226
- else if (value instanceof RegExp) {
1227
- throw new UnexpectedError("".concat(name, " is RegExp"));
1228
- }
1229
- else if (value instanceof Error) {
1230
- throw new UnexpectedError(spaceTrim$1("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
1231
- }
1232
- else {
1233
- try {
1234
- for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
1235
- var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
1236
- if (subValue === undefined) {
1237
- // Note: undefined in object is serializable - it is just omited
1238
- continue;
1239
- }
1240
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
1241
- }
1242
- }
1243
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1244
- finally {
1245
- try {
1246
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1247
- }
1248
- finally { if (e_1) throw e_1.error; }
1249
- }
1250
- try {
1251
- JSON.stringify(value); // <- TODO: [0]
1252
- }
1253
- catch (error) {
1254
- if (!(error instanceof Error)) {
1255
- throw error;
1256
- }
1257
- throw new UnexpectedError(spaceTrim$1(function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
1258
- }
1259
- /*
1260
- TODO: [0] Is there some more elegant way to check circular references?
1261
- const seen = new Set();
1262
- const stack = [{ value }];
1263
- while (stack.length > 0) {
1264
- const { value } = stack.pop()!;
1265
- if (typeof value === 'object' && value !== null) {
1266
- if (seen.has(value)) {
1267
- throw new UnexpectedError(`${name} has circular reference`);
1268
- }
1269
- seen.add(value);
1270
- if (Array.isArray(value)) {
1271
- stack.push(...value.map((value) => ({ value })));
1272
- } else {
1273
- stack.push(...Object.values(value).map((value) => ({ value })));
1274
- }
1275
- }
1276
- }
1277
- */
1278
- return;
1279
- }
1280
- }
1281
- else {
1282
- throw new UnexpectedError("".concat(name, " is unknown"));
1283
- }
1284
- }
1285
- /**
1286
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
1287
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
1288
- * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
1289
- */
1290
-
1291
- /**
1292
- * @@@
1293
- * @@@
1294
- *
1295
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
1296
- *
1297
- * @param name - Name of the object for debugging purposes
1298
- * @param objectValue - Object to be deeply frozen
1299
- * @returns The same object as the input, but deeply frozen
1300
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
1301
- */
1302
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
1303
- checkSerializableAsJson(name, objectValue);
1304
- return $deepFreeze(objectValue);
1305
- }
1306
- /**
1307
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
1308
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1309
- */
1310
-
1311
1406
  /**
1312
1407
  * Unprepare just strips the preparation data of the pipeline
1313
1408
  *
1409
+ * @deprecated In future version this function will be removed or deprecated
1314
1410
  * @public exported from `@promptbook/core`
1315
1411
  */
1316
1412
  function unpreparePipeline(pipeline) {
@@ -1325,7 +1421,12 @@ function unpreparePipeline(pipeline) {
1325
1421
  delete taskUnprepared.preparedContent;
1326
1422
  return taskUnprepared;
1327
1423
  });
1328
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1424
+ return exportJson({
1425
+ name: 'pipelineJson',
1426
+ message: "Result of `unpreparePipeline`",
1427
+ order: ORDER_OF_PIPELINE_JSON,
1428
+ value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
1429
+ });
1329
1430
  }
1330
1431
  /**
1331
1432
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1871,29 +1972,6 @@ $deepFreeze({
1871
1972
  * Note: [💞] Ignore a discrepancy between file name and entity name
1872
1973
  */
1873
1974
 
1874
- /**
1875
- * @@@
1876
- *
1877
- * @public exported from `@promptbook/utils`
1878
- */
1879
- function deepClone(objectValue) {
1880
- return JSON.parse(JSON.stringify(objectValue));
1881
- /*
1882
- TODO: [🧠] Is there a better implementation?
1883
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
1884
- > for (const propertyName of propertyNames) {
1885
- > const value = (objectValue as really_any)[propertyName];
1886
- > if (value && typeof value === 'object') {
1887
- > deepClone(value);
1888
- > }
1889
- > }
1890
- > return Object.assign({}, objectValue);
1891
- */
1892
- }
1893
- /**
1894
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1895
- */
1896
-
1897
1975
  /**
1898
1976
  * Function `addUsage` will add multiple usages into one
1899
1977
  *
@@ -3419,36 +3497,6 @@ TODO: [🧊] This is how it can look in future
3419
3497
  * [ ] One piece can have multiple sources
3420
3498
  */
3421
3499
 
3422
- /**
3423
- * @@@
3424
- *
3425
- * Note: It is usefull @@@
3426
- *
3427
- * @param pipeline
3428
- * @public exported from `@promptbook/utils`
3429
- */
3430
- function clonePipeline(pipeline) {
3431
- // Note: Not using spread operator (...) because @@@
3432
- var pipelineUrl = pipeline.pipelineUrl, sourceFile = pipeline.sourceFile, title = pipeline.title, bookVersion = pipeline.bookVersion, description = pipeline.description, formfactorName = pipeline.formfactorName, parameters = pipeline.parameters, tasks = pipeline.tasks, knowledgeSources = pipeline.knowledgeSources, knowledgePieces = pipeline.knowledgePieces, personas = pipeline.personas, preparations = pipeline.preparations;
3433
- return {
3434
- pipelineUrl: pipelineUrl,
3435
- sourceFile: sourceFile,
3436
- title: title,
3437
- bookVersion: bookVersion,
3438
- description: description,
3439
- formfactorName: formfactorName,
3440
- parameters: parameters,
3441
- tasks: tasks,
3442
- knowledgeSources: knowledgeSources,
3443
- knowledgePieces: knowledgePieces,
3444
- personas: personas,
3445
- preparations: preparations,
3446
- };
3447
- }
3448
- /**
3449
- * TODO: [🍙] Make some standard order of json properties
3450
- */
3451
-
3452
3500
  /**
3453
3501
  * @@@
3454
3502
  *
@@ -3489,6 +3537,7 @@ function prepareTasks(pipeline, tools, options) {
3489
3537
  });
3490
3538
  }
3491
3539
  /**
3540
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
3492
3541
  * TODO: [🧠] Add context to each task (if missing)
3493
3542
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3494
3543
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -3577,11 +3626,19 @@ function preparePipeline(pipeline, tools, options) {
3577
3626
  case 3:
3578
3627
  tasksPrepared = (_c.sent()).tasksPrepared;
3579
3628
  // ----- /Tasks preparation -----
3629
+ // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
3580
3630
  // Note: Count total usage
3581
3631
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
3582
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
3583
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3584
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
3632
+ return [2 /*return*/, exportJson({
3633
+ name: 'pipelineJson',
3634
+ message: "Result of `preparePipeline`",
3635
+ order: ORDER_OF_PIPELINE_JSON,
3636
+ value: __assign(__assign({}, pipeline), {
3637
+ // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
3638
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
3639
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3640
+ personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
3641
+ })];
3585
3642
  }
3586
3643
  });
3587
3644
  });
@@ -5278,16 +5335,21 @@ function executePipeline(options) {
5278
5335
  // Note: Wait a short time to prevent race conditions
5279
5336
  _g.sent();
5280
5337
  _g.label = 6;
5281
- case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5282
- isSuccessful: false,
5283
- errors: __spreadArray([
5284
- new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5285
- ], __read(errors), false).map(serializeError),
5286
- warnings: [],
5287
- executionReport: executionReport,
5288
- outputParameters: {},
5289
- usage: ZERO_USAGE,
5290
- preparedPipeline: preparedPipeline,
5338
+ case 6: return [2 /*return*/, exportJson({
5339
+ name: "executionReport",
5340
+ message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
5341
+ order: [],
5342
+ value: {
5343
+ isSuccessful: false,
5344
+ errors: __spreadArray([
5345
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5346
+ ], __read(errors), false).map(serializeError),
5347
+ warnings: [],
5348
+ executionReport: executionReport,
5349
+ outputParameters: {},
5350
+ usage: ZERO_USAGE,
5351
+ preparedPipeline: preparedPipeline,
5352
+ },
5291
5353
  })];
5292
5354
  case 7:
5293
5355
  _b = _a.next();
@@ -5326,16 +5388,21 @@ function executePipeline(options) {
5326
5388
  // Note: Wait a short time to prevent race conditions
5327
5389
  _h.sent();
5328
5390
  _h.label = 3;
5329
- case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
5330
- isSuccessful: false,
5331
- errors: __spreadArray([
5332
- new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5333
- ], __read(errors), false).map(serializeError),
5334
- warnings: warnings.map(serializeError),
5335
- executionReport: executionReport,
5336
- outputParameters: {},
5337
- usage: ZERO_USAGE,
5338
- preparedPipeline: preparedPipeline,
5391
+ case 3: return [2 /*return*/, { value: exportJson({
5392
+ name: 'pipelineExecutorResult',
5393
+ message: spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
5394
+ order: [],
5395
+ value: {
5396
+ isSuccessful: false,
5397
+ errors: __spreadArray([
5398
+ new PipelineExecutionError(spaceTrim(function (block) { return "\n Parameter `{".concat(parameter.name, "}` is passed as input parameter but it is not input\n\n ").concat(block(pipelineIdentification), "\n "); }))
5399
+ ], __read(errors), false).map(serializeError),
5400
+ warnings: warnings.map(serializeError),
5401
+ executionReport: executionReport,
5402
+ outputParameters: {},
5403
+ usage: ZERO_USAGE,
5404
+ preparedPipeline: preparedPipeline,
5405
+ },
5339
5406
  }) }];
5340
5407
  case 4: return [2 /*return*/];
5341
5408
  }
@@ -5489,14 +5556,19 @@ function executePipeline(options) {
5489
5556
  // Note: Wait a short time to prevent race conditions
5490
5557
  _g.sent();
5491
5558
  _g.label = 27;
5492
- case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
5493
- isSuccessful: false,
5494
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5495
- warnings: warnings.map(serializeError),
5496
- usage: usage_1,
5497
- executionReport: executionReport,
5498
- outputParameters: outputParameters_1,
5499
- preparedPipeline: preparedPipeline,
5559
+ case 27: return [2 /*return*/, exportJson({
5560
+ name: 'pipelineExecutorResult',
5561
+ message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
5562
+ order: [],
5563
+ value: {
5564
+ isSuccessful: false,
5565
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5566
+ warnings: warnings.map(serializeError),
5567
+ usage: usage_1,
5568
+ executionReport: executionReport,
5569
+ outputParameters: outputParameters_1,
5570
+ preparedPipeline: preparedPipeline,
5571
+ },
5500
5572
  })];
5501
5573
  case 28:
5502
5574
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
@@ -5517,14 +5589,19 @@ function executePipeline(options) {
5517
5589
  // Note: Wait a short time to prevent race conditions
5518
5590
  _g.sent();
5519
5591
  _g.label = 30;
5520
- case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
5521
- isSuccessful: true,
5522
- errors: errors.map(serializeError),
5523
- warnings: warnings.map(serializeError),
5524
- usage: usage,
5525
- executionReport: executionReport,
5526
- outputParameters: outputParameters,
5527
- preparedPipeline: preparedPipeline,
5592
+ case 30: return [2 /*return*/, exportJson({
5593
+ name: 'pipelineExecutorResult',
5594
+ message: "Successful PipelineExecutorResult",
5595
+ order: [],
5596
+ value: {
5597
+ isSuccessful: true,
5598
+ errors: errors.map(serializeError),
5599
+ warnings: warnings.map(serializeError),
5600
+ usage: usage,
5601
+ executionReport: executionReport,
5602
+ outputParameters: outputParameters,
5603
+ preparedPipeline: preparedPipeline,
5604
+ },
5528
5605
  })];
5529
5606
  }
5530
5607
  });
@@ -5648,7 +5725,7 @@ var markdownScraperMetadata = $deepFreeze({
5648
5725
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5649
5726
  isAvilableInBrowser: true,
5650
5727
  requiredExecutables: [],
5651
- }); /* <- TODO: [🤛] */
5728
+ }); /* <- Note: [🤛] */
5652
5729
  /**
5653
5730
  * Registration of known scraper metadata
5654
5731
  *
@@ -5845,7 +5922,7 @@ var pdfScraperMetadata = $deepFreeze({
5845
5922
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5846
5923
  isAvilableInBrowser: true,
5847
5924
  requiredExecutables: [],
5848
- }); /* <- TODO: [🤛] */
5925
+ }); /* <- Note: [🤛] */
5849
5926
  /**
5850
5927
  * Registration of known scraper metadata
5851
5928
  *
@@ -5925,7 +6002,7 @@ var PdfScraper = /** @class */ (function () {
5925
6002
  */
5926
6003
  var createPdfScraper = Object.assign(function (tools, options) {
5927
6004
  return new PdfScraper(tools, options);
5928
- }, pdfScraperMetadata); /* <- TODO: [🤛] */
6005
+ }, pdfScraperMetadata); /* <- Note: [🤛] */
5929
6006
  /**
5930
6007
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5931
6008
  */