@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/umd/index.umd.js CHANGED
@@ -22,7 +22,7 @@
22
22
  *
23
23
  * @see https://github.com/webgptorg/promptbook
24
24
  */
25
- var PROMPTBOOK_ENGINE_VERSION = '0.78.4';
25
+ var PROMPTBOOK_ENGINE_VERSION = '0.80.0-0';
26
26
  /**
27
27
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
28
28
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -176,7 +176,7 @@
176
176
  function TODO_USE() {
177
177
  }
178
178
 
179
- 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"}];
179
+ 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"}];
180
180
 
181
181
  /**
182
182
  * Prettify the html code
@@ -224,6 +224,7 @@
224
224
  /**
225
225
  * Converts promptbook in JSON format to string format
226
226
  *
227
+ * @deprecated TODO: [🥍][🧠] Backup original files in `PipelineJson` same as in Promptbook.studio
227
228
  * @param pipelineJson Promptbook in JSON format (.book.json)
228
229
  * @returns Promptbook in string format (.book.md)
229
230
  * @public exported from `@promptbook/core`
@@ -507,78 +508,368 @@
507
508
  * @public exported from `@promptbook/core`
508
509
  */
509
510
  var DEFAULT_SCRAPE_CACHE_DIRNAME = './.promptbook/scrape-cache';
511
+ // <- TODO: [🧜‍♂️]
510
512
  /**
511
- * Nonce which is used for replacing things in strings
513
+ * @@@
512
514
  *
513
- * @private within the repository
515
+ * @public exported from `@promptbook/core`
514
516
  */
515
- var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
517
+ var DEFAULT_CSV_SETTINGS = Object.freeze({
518
+ delimiter: ',',
519
+ quoteChar: '"',
520
+ newline: '\n',
521
+ skipEmptyLines: true,
522
+ });
516
523
  /**
517
- * The names of the parameters that are reserved for special purposes
524
+ * @@@
518
525
  *
519
526
  * @public exported from `@promptbook/core`
520
527
  */
521
- var RESERVED_PARAMETER_NAMES =
522
- /* !!!!!! $asDeeplyFrozenSerializableJson('RESERVED_PARAMETER_NAMES', _____ as const); */ [
523
- 'content',
524
- 'context',
525
- 'knowledge',
526
- 'examples',
527
- 'modelName',
528
- 'currentDate',
529
- // <- TODO: list here all command names
530
- // <- TODO: Add more like 'date', 'modelName',...
531
- // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
532
- ];
528
+ var DEFAULT_IS_VERBOSE = false;
533
529
  /**
534
530
  * @@@
535
531
  *
536
- * @private within the repository
532
+ * @public exported from `@promptbook/core`
537
533
  */
538
- var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
534
+ var DEFAULT_IS_AUTO_INSTALLED = false;
539
535
  /**
540
536
  * @@@
541
537
  *
542
538
  * @private within the repository
543
539
  */
544
- var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
545
- // <- TODO: [🧜‍♂️]
540
+ var IS_PIPELINE_LOGIC_VALIDATED = just(
541
+ /**/
542
+ // Note: In normal situations, we check the pipeline logic:
543
+ true);
546
544
  /**
547
- * @@@
545
+ * Note: [💞] Ignore a discrepancy between file name and entity name
546
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
547
+ */
548
+
549
+ /**
550
+ * Orders JSON object by keys
551
+ *
552
+ * @returns The same type of object as the input re-ordered
553
+ * @public exported from `@promptbook/utils`
554
+ */
555
+ function orderJson(options) {
556
+ var value = options.value, order = options.order;
557
+ var orderedValue = __assign(__assign({}, (order === undefined ? {} : Object.fromEntries(order.map(function (key) { return [key, undefined]; })))), value);
558
+ return orderedValue;
559
+ }
560
+
561
+ /**
562
+ * Freezes the given object and all its nested objects recursively
563
+ *
564
+ * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
565
+ * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
566
+ *
567
+ * @returns The same object as the input, but deeply frozen
568
+ * @public exported from `@promptbook/utils`
569
+ */
570
+ function $deepFreeze(objectValue) {
571
+ var e_1, _a;
572
+ if (Array.isArray(objectValue)) {
573
+ return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
574
+ }
575
+ var propertyNames = Object.getOwnPropertyNames(objectValue);
576
+ try {
577
+ for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
578
+ var propertyName = propertyNames_1_1.value;
579
+ var value = objectValue[propertyName];
580
+ if (value && typeof value === 'object') {
581
+ $deepFreeze(value);
582
+ }
583
+ }
584
+ }
585
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
586
+ finally {
587
+ try {
588
+ if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
589
+ }
590
+ finally { if (e_1) throw e_1.error; }
591
+ }
592
+ Object.freeze(objectValue);
593
+ return objectValue;
594
+ }
595
+ /**
596
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
597
+ */
598
+
599
+ /**
600
+ * Make error report URL for the given error
601
+ *
602
+ * @private !!!!!!
603
+ */
604
+ function getErrorReportUrl(error) {
605
+ var report = {
606
+ title: "\uD83D\uDC1C Error report from ".concat(NAME),
607
+ 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 "); }),
608
+ };
609
+ var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
610
+ reportUrl.searchParams.set('labels', 'bug');
611
+ reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
612
+ reportUrl.searchParams.set('title', report.title);
613
+ reportUrl.searchParams.set('body', report.body);
614
+ return reportUrl;
615
+ }
616
+
617
+ /**
618
+ * This error type indicates that the error should not happen and its last check before crashing with some other error
548
619
  *
549
620
  * @public exported from `@promptbook/core`
550
621
  */
551
- var DEFAULT_CSV_SETTINGS = Object.freeze({
552
- delimiter: ',',
553
- quoteChar: '"',
554
- newline: '\n',
555
- skipEmptyLines: true,
556
- });
622
+ var UnexpectedError = /** @class */ (function (_super) {
623
+ __extends(UnexpectedError, _super);
624
+ function UnexpectedError(message) {
625
+ 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;
626
+ _this.name = 'UnexpectedError';
627
+ Object.setPrototypeOf(_this, UnexpectedError.prototype);
628
+ return _this;
629
+ }
630
+ return UnexpectedError;
631
+ }(Error));
632
+
633
+ /**
634
+ * Checks if the value is [🚉] serializable as JSON
635
+ * If not, throws an UnexpectedError with a rich error message and tracking
636
+ *
637
+ * - Almost all primitives are serializable BUT:
638
+ * - `undefined` is not serializable
639
+ * - `NaN` is not serializable
640
+ * - Objects and arrays are serializable if all their properties are serializable
641
+ * - Functions are not serializable
642
+ * - Circular references are not serializable
643
+ * - `Date` objects are not serializable
644
+ * - `Map` and `Set` objects are not serializable
645
+ * - `RegExp` objects are not serializable
646
+ * - `Error` objects are not serializable
647
+ * - `Symbol` objects are not serializable
648
+ * - And much more...
649
+ *
650
+ * @throws UnexpectedError if the value is not serializable as JSON
651
+ * @public exported from `@promptbook/utils`
652
+ */
653
+ function checkSerializableAsJson(options) {
654
+ var e_1, _a;
655
+ var value = options.value, name = options.name, message = options.message;
656
+ if (value === undefined) {
657
+ throw new UnexpectedError("".concat(name, " is undefined"));
658
+ }
659
+ else if (value === null) {
660
+ return;
661
+ }
662
+ else if (typeof value === 'boolean') {
663
+ return;
664
+ }
665
+ else if (typeof value === 'number' && !isNaN(value)) {
666
+ return;
667
+ }
668
+ else if (typeof value === 'string') {
669
+ return;
670
+ }
671
+ else if (typeof value === 'symbol') {
672
+ throw new UnexpectedError("".concat(name, " is symbol"));
673
+ }
674
+ else if (typeof value === 'function') {
675
+ throw new UnexpectedError("".concat(name, " is function"));
676
+ }
677
+ else if (typeof value === 'object' && Array.isArray(value)) {
678
+ for (var i = 0; i < value.length; i++) {
679
+ checkSerializableAsJson({ name: "".concat(name, "[").concat(i, "]"), value: value[i], message: message });
680
+ }
681
+ }
682
+ else if (typeof value === 'object') {
683
+ if (value instanceof Date) {
684
+ throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
685
+ }
686
+ else if (value instanceof Map) {
687
+ throw new UnexpectedError("".concat(name, " is Map"));
688
+ }
689
+ else if (value instanceof Set) {
690
+ throw new UnexpectedError("".concat(name, " is Set"));
691
+ }
692
+ else if (value instanceof RegExp) {
693
+ throw new UnexpectedError("".concat(name, " is RegExp"));
694
+ }
695
+ else if (value instanceof Error) {
696
+ throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
697
+ }
698
+ else {
699
+ try {
700
+ for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
701
+ var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
702
+ if (subValue === undefined) {
703
+ // Note: undefined in object is serializable - it is just omited
704
+ continue;
705
+ }
706
+ checkSerializableAsJson({ name: "".concat(name, ".").concat(subName), value: subValue, message: message });
707
+ }
708
+ }
709
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
710
+ finally {
711
+ try {
712
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
713
+ }
714
+ finally { if (e_1) throw e_1.error; }
715
+ }
716
+ try {
717
+ JSON.stringify(value); // <- TODO: [0]
718
+ }
719
+ catch (error) {
720
+ if (!(error instanceof Error)) {
721
+ throw error;
722
+ }
723
+ throw new UnexpectedError(spaceTrim__default["default"](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 "); }));
724
+ }
725
+ /*
726
+ TODO: [0] Is there some more elegant way to check circular references?
727
+ const seen = new Set();
728
+ const stack = [{ value }];
729
+ while (stack.length > 0) {
730
+ const { value } = stack.pop()!;
731
+ if (typeof value === 'object' && value !== null) {
732
+ if (seen.has(value)) {
733
+ throw new UnexpectedError(`${name} has circular reference`);
734
+ }
735
+ seen.add(value);
736
+ if (Array.isArray(value)) {
737
+ stack.push(...value.map((value) => ({ value })));
738
+ } else {
739
+ stack.push(...Object.values(value).map((value) => ({ value })));
740
+ }
741
+ }
742
+ }
743
+ */
744
+ return;
745
+ }
746
+ }
747
+ else {
748
+ throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n `".concat(name, "` is unknown type\n\n Additional message for `").concat(name, "`:\n ").concat(block(message || '(nothing)'), "\n "); }));
749
+ }
750
+ }
751
+ /**
752
+ * TODO: Can be return type more type-safe? like `asserts options.value is JsonValue`
753
+ * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
754
+ * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
755
+ */
756
+
557
757
  /**
558
758
  * @@@
559
759
  *
760
+ * @public exported from `@promptbook/utils`
761
+ */
762
+ function deepClone(objectValue) {
763
+ return JSON.parse(JSON.stringify(objectValue));
764
+ /*
765
+ !!!!!!!!
766
+ TODO: [🧠] Is there a better implementation?
767
+ > const propertyNames = Object.getOwnPropertyNames(objectValue);
768
+ > for (const propertyName of propertyNames) {
769
+ > const value = (objectValue as really_any)[propertyName];
770
+ > if (value && typeof value === 'object') {
771
+ > deepClone(value);
772
+ > }
773
+ > }
774
+ > return Object.assign({}, objectValue);
775
+ */
776
+ }
777
+ /**
778
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
779
+ */
780
+
781
+ /**
782
+ * Utility to export a JSON object from a function
783
+ *
784
+ * 1) Checks if the value is serializable as JSON
785
+ * 2) Makes a deep clone of the object
786
+ * 2) Orders the object properties
787
+ * 2) Deeply freezes the cloned object
788
+ *
789
+ * Note: This function does not mutates the given object
790
+ *
791
+ * @returns The same type of object as the input but read-only and re-ordered
792
+ * @public exported from `@promptbook/utils`
793
+ */
794
+ function exportJson(options) {
795
+ var name = options.name, value = options.value, order = options.order, message = options.message;
796
+ checkSerializableAsJson({ name: name, value: value, message: message });
797
+ var orderedValue =
798
+ // TODO: Fix error "Type instantiation is excessively deep and possibly infinite."
799
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
800
+ // @ts-ignore
801
+ order === undefined
802
+ ? deepClone(value)
803
+ : orderJson({
804
+ value: value,
805
+ // <- Note: checkSerializableAsJson asserts that the value is serializable as JSON
806
+ order: order,
807
+ });
808
+ $deepFreeze(orderedValue);
809
+ return orderedValue;
810
+ }
811
+ /**
812
+ * TODO: [🧠] Is there a way how to meaningfully test this utility
813
+ */
814
+
815
+ /**
816
+ * Order of keys in the pipeline JSON
817
+ *
560
818
  * @public exported from `@promptbook/core`
561
819
  */
562
- var DEFAULT_IS_VERBOSE = false;
820
+ var ORDER_OF_PIPELINE_JSON = [
821
+ 'title',
822
+ 'pipelineUrl',
823
+ 'bookVersion',
824
+ 'description',
825
+ 'formfactorName',
826
+ 'parameters',
827
+ 'tasks',
828
+ 'personas',
829
+ 'preparations',
830
+ 'knowledgeSources',
831
+ 'knowledgePieces',
832
+ ];
833
+ /**
834
+ * Nonce which is used for replacing things in strings
835
+ *
836
+ * @private within the repository
837
+ */
838
+ var REPLACING_NONCE = 'u$k42k%!V2zo34w7Fu#@QUHYPW';
563
839
  /**
564
840
  * @@@
565
841
  *
566
- * @public exported from `@promptbook/core`
842
+ * @private within the repository
567
843
  */
568
- var DEFAULT_IS_AUTO_INSTALLED = false;
844
+ var RESERVED_PARAMETER_MISSING_VALUE = 'MISSING-' + REPLACING_NONCE;
569
845
  /**
570
846
  * @@@
571
847
  *
572
848
  * @private within the repository
573
849
  */
574
- var IS_PIPELINE_LOGIC_VALIDATED = just(
575
- /**/
576
- // Note: In normal situations, we check the pipeline logic:
577
- true);
850
+ var RESERVED_PARAMETER_RESTRICTED = 'RESTRICTED-' + REPLACING_NONCE;
851
+ /**
852
+ * The names of the parameters that are reserved for special purposes
853
+ *
854
+ * @public exported from `@promptbook/core`
855
+ */
856
+ var RESERVED_PARAMETER_NAMES = exportJson({
857
+ name: 'RESERVED_PARAMETER_NAMES',
858
+ message: "The names of the parameters that are reserved for special purposes",
859
+ value: [
860
+ 'content',
861
+ 'context',
862
+ 'knowledge',
863
+ 'examples',
864
+ 'modelName',
865
+ 'currentDate',
866
+ // <- TODO: list here all command names
867
+ // <- TODO: Add more like 'date', 'modelName',...
868
+ // <- TODO: Add [emoji] + instructions ACRY when adding new reserved parameter
869
+ ],
870
+ });
578
871
  /**
579
- * TODO: Extract `constants.ts` from `config.ts`
580
872
  * Note: [💞] Ignore a discrepancy between file name and entity name
581
- * TODO: [🧠][🧜‍♂️] Maybe join remoteUrl and path into single value
582
873
  */
583
874
 
584
875
  /**
@@ -616,40 +907,6 @@
616
907
  return PipelineLogicError;
617
908
  }(Error));
618
909
 
619
- /**
620
- * Make error report URL for the given error
621
- *
622
- * @private !!!!!!
623
- */
624
- function getErrorReportUrl(error) {
625
- var report = {
626
- title: "\uD83D\uDC1C Error report from ".concat(NAME),
627
- 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 "); }),
628
- };
629
- var reportUrl = new URL("https://github.com/webgptorg/promptbook/issues/new");
630
- reportUrl.searchParams.set('labels', 'bug');
631
- reportUrl.searchParams.set('assignees', ADMIN_GITHUB_NAME);
632
- reportUrl.searchParams.set('title', report.title);
633
- reportUrl.searchParams.set('body', report.body);
634
- return reportUrl;
635
- }
636
-
637
- /**
638
- * This error type indicates that the error should not happen and its last check before crashing with some other error
639
- *
640
- * @public exported from `@promptbook/core`
641
- */
642
- var UnexpectedError = /** @class */ (function (_super) {
643
- __extends(UnexpectedError, _super);
644
- function UnexpectedError(message) {
645
- 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;
646
- _this.name = 'UnexpectedError';
647
- Object.setPrototypeOf(_this, UnexpectedError.prototype);
648
- return _this;
649
- }
650
- return UnexpectedError;
651
- }(Error));
652
-
653
910
  /**
654
911
  * Tests if given string is valid semantic version
655
912
  *
@@ -887,6 +1144,21 @@
887
1144
  }
888
1145
  };
889
1146
  try {
1147
+ /*
1148
+ TODO: [🧠][🅾] Should be empty pipeline valid or not
1149
+ // Note: Check that pipeline has some tasks
1150
+ if (pipeline.tasks.length === 0) {
1151
+ throw new PipelineLogicError(
1152
+ spaceTrim(
1153
+ (block) => `
1154
+ Pipeline must have at least one task
1155
+
1156
+ ${block(pipelineIdentification)}
1157
+ `,
1158
+ ),
1159
+ );
1160
+ }
1161
+ */
890
1162
  // Note: Check each parameter individually
891
1163
  for (var _d = __values(pipeline.parameters), _e = _d.next(); !_e.done; _e = _d.next()) {
892
1164
  var parameter = _e.value;
@@ -1047,6 +1319,9 @@
1047
1319
  while (unresovedTasks.length > 0) {
1048
1320
  _loop_3();
1049
1321
  }
1322
+ // Note: Check that formfactor is corresponding to the pipeline interface
1323
+ // TODO: !!!!!! Implement this
1324
+ // pipeline.formfactorName
1050
1325
  }
1051
1326
  /**
1052
1327
  * TODO: !! [🧞‍♀️] Do not allow joker + foreach
@@ -1130,189 +1405,10 @@
1130
1405
  return parameterNames;
1131
1406
  }
1132
1407
 
1133
- /**
1134
- * @@@
1135
- *
1136
- * Note: `$` is used to indicate that this function is not a pure function - it mutates given object
1137
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
1138
- *
1139
- * @returns The same object as the input, but deeply frozen
1140
- * @public exported from `@promptbook/utils`
1141
- */
1142
- function $deepFreeze(objectValue) {
1143
- var e_1, _a;
1144
- if (Array.isArray(objectValue)) {
1145
- return Object.freeze(objectValue.map(function (item) { return $deepFreeze(item); }));
1146
- }
1147
- var propertyNames = Object.getOwnPropertyNames(objectValue);
1148
- try {
1149
- for (var propertyNames_1 = __values(propertyNames), propertyNames_1_1 = propertyNames_1.next(); !propertyNames_1_1.done; propertyNames_1_1 = propertyNames_1.next()) {
1150
- var propertyName = propertyNames_1_1.value;
1151
- var value = objectValue[propertyName];
1152
- if (value && typeof value === 'object') {
1153
- $deepFreeze(value);
1154
- }
1155
- }
1156
- }
1157
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1158
- finally {
1159
- try {
1160
- if (propertyNames_1_1 && !propertyNames_1_1.done && (_a = propertyNames_1.return)) _a.call(propertyNames_1);
1161
- }
1162
- finally { if (e_1) throw e_1.error; }
1163
- }
1164
- return Object.freeze(objectValue);
1165
- }
1166
- /**
1167
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1168
- */
1169
-
1170
- /**
1171
- * Checks if the value is [🚉] serializable as JSON
1172
- * If not, throws an UnexpectedError with a rich error message and tracking
1173
- *
1174
- * - Almost all primitives are serializable BUT:
1175
- * - `undefined` is not serializable
1176
- * - `NaN` is not serializable
1177
- * - Objects and arrays are serializable if all their properties are serializable
1178
- * - Functions are not serializable
1179
- * - Circular references are not serializable
1180
- * - `Date` objects are not serializable
1181
- * - `Map` and `Set` objects are not serializable
1182
- * - `RegExp` objects are not serializable
1183
- * - `Error` objects are not serializable
1184
- * - `Symbol` objects are not serializable
1185
- * - And much more...
1186
- *
1187
- * @throws UnexpectedError if the value is not serializable as JSON
1188
- * @public exported from `@promptbook/utils`
1189
- */
1190
- function checkSerializableAsJson(name, value) {
1191
- var e_1, _a;
1192
- if (value === undefined) {
1193
- throw new UnexpectedError("".concat(name, " is undefined"));
1194
- }
1195
- else if (value === null) {
1196
- return;
1197
- }
1198
- else if (typeof value === 'boolean') {
1199
- return;
1200
- }
1201
- else if (typeof value === 'number' && !isNaN(value)) {
1202
- return;
1203
- }
1204
- else if (typeof value === 'string') {
1205
- return;
1206
- }
1207
- else if (typeof value === 'symbol') {
1208
- throw new UnexpectedError("".concat(name, " is symbol"));
1209
- }
1210
- else if (typeof value === 'function') {
1211
- throw new UnexpectedError("".concat(name, " is function"));
1212
- }
1213
- else if (typeof value === 'object' && Array.isArray(value)) {
1214
- for (var i = 0; i < value.length; i++) {
1215
- checkSerializableAsJson("".concat(name, "[").concat(i, "]"), value[i]);
1216
- }
1217
- }
1218
- else if (typeof value === 'object') {
1219
- if (value instanceof Date) {
1220
- throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is Date\n\n Use `string_date_iso8601` instead\n ")));
1221
- }
1222
- else if (value instanceof Map) {
1223
- throw new UnexpectedError("".concat(name, " is Map"));
1224
- }
1225
- else if (value instanceof Set) {
1226
- throw new UnexpectedError("".concat(name, " is Set"));
1227
- }
1228
- else if (value instanceof RegExp) {
1229
- throw new UnexpectedError("".concat(name, " is RegExp"));
1230
- }
1231
- else if (value instanceof Error) {
1232
- throw new UnexpectedError(spaceTrim__default["default"]("\n ".concat(name, " is unserialized Error\n\n Use function `serializeError`\n ")));
1233
- }
1234
- else {
1235
- try {
1236
- for (var _b = __values(Object.entries(value)), _c = _b.next(); !_c.done; _c = _b.next()) {
1237
- var _d = __read(_c.value, 2), subName = _d[0], subValue = _d[1];
1238
- if (subValue === undefined) {
1239
- // Note: undefined in object is serializable - it is just omited
1240
- continue;
1241
- }
1242
- checkSerializableAsJson("".concat(name, ".").concat(subName), subValue);
1243
- }
1244
- }
1245
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1246
- finally {
1247
- try {
1248
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1249
- }
1250
- finally { if (e_1) throw e_1.error; }
1251
- }
1252
- try {
1253
- JSON.stringify(value); // <- TODO: [0]
1254
- }
1255
- catch (error) {
1256
- if (!(error instanceof Error)) {
1257
- throw error;
1258
- }
1259
- throw new UnexpectedError(spaceTrim__default["default"](function (block) { return "\n ".concat(name, " is not serializable\n\n ").concat(block(error.toString()), "\n "); }));
1260
- }
1261
- /*
1262
- TODO: [0] Is there some more elegant way to check circular references?
1263
- const seen = new Set();
1264
- const stack = [{ value }];
1265
- while (stack.length > 0) {
1266
- const { value } = stack.pop()!;
1267
- if (typeof value === 'object' && value !== null) {
1268
- if (seen.has(value)) {
1269
- throw new UnexpectedError(`${name} has circular reference`);
1270
- }
1271
- seen.add(value);
1272
- if (Array.isArray(value)) {
1273
- stack.push(...value.map((value) => ({ value })));
1274
- } else {
1275
- stack.push(...Object.values(value).map((value) => ({ value })));
1276
- }
1277
- }
1278
- }
1279
- */
1280
- return;
1281
- }
1282
- }
1283
- else {
1284
- throw new UnexpectedError("".concat(name, " is unknown"));
1285
- }
1286
- }
1287
- /**
1288
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
1289
- * TODO: [🧠][main] !!! In-memory cache of same values to prevent multiple checks
1290
- * Note: [🐠] This is how `checkSerializableAsJson` + `isSerializableAsJson` together can just retun true/false or rich error message
1291
- */
1292
-
1293
- /**
1294
- * @@@
1295
- * @@@
1296
- *
1297
- * Note: This function mutates the object and returns the original (but mutated-deep-freezed) object
1298
- *
1299
- * @param name - Name of the object for debugging purposes
1300
- * @param objectValue - Object to be deeply frozen
1301
- * @returns The same object as the input, but deeply frozen
1302
- * @private this is in comparison to `deepFreeze` a more specific utility and maybe not very good practice to use without specific reason and considerations
1303
- */
1304
- function $asDeeplyFrozenSerializableJson(name, objectValue) {
1305
- checkSerializableAsJson(name, objectValue);
1306
- return $deepFreeze(objectValue);
1307
- }
1308
- /**
1309
- * TODO: [🧠][🛣] More elegant way to tracking than passing `name`
1310
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1311
- */
1312
-
1313
1408
  /**
1314
1409
  * Unprepare just strips the preparation data of the pipeline
1315
1410
  *
1411
+ * @deprecated In future version this function will be removed or deprecated
1316
1412
  * @public exported from `@promptbook/core`
1317
1413
  */
1318
1414
  function unpreparePipeline(pipeline) {
@@ -1327,7 +1423,12 @@
1327
1423
  delete taskUnprepared.preparedContent;
1328
1424
  return taskUnprepared;
1329
1425
  });
1330
- return $asDeeplyFrozenSerializableJson('Unprepared PipelineJson', __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }));
1426
+ return exportJson({
1427
+ name: 'pipelineJson',
1428
+ message: "Result of `unpreparePipeline`",
1429
+ order: ORDER_OF_PIPELINE_JSON,
1430
+ value: __assign(__assign({}, pipeline), { tasks: tasks, knowledgeSources: knowledgeSources, knowledgePieces: [], personas: personas, preparations: [] }),
1431
+ });
1331
1432
  }
1332
1433
  /**
1333
1434
  * TODO: [🧿] Maybe do same process with same granularity and subfinctions as `preparePipeline`
@@ -1873,29 +1974,6 @@
1873
1974
  * Note: [💞] Ignore a discrepancy between file name and entity name
1874
1975
  */
1875
1976
 
1876
- /**
1877
- * @@@
1878
- *
1879
- * @public exported from `@promptbook/utils`
1880
- */
1881
- function deepClone(objectValue) {
1882
- return JSON.parse(JSON.stringify(objectValue));
1883
- /*
1884
- TODO: [🧠] Is there a better implementation?
1885
- > const propertyNames = Object.getOwnPropertyNames(objectValue);
1886
- > for (const propertyName of propertyNames) {
1887
- > const value = (objectValue as really_any)[propertyName];
1888
- > if (value && typeof value === 'object') {
1889
- > deepClone(value);
1890
- > }
1891
- > }
1892
- > return Object.assign({}, objectValue);
1893
- */
1894
- }
1895
- /**
1896
- * TODO: [🧠] Is there a way how to meaningfully test this utility
1897
- */
1898
-
1899
1977
  /**
1900
1978
  * Function `addUsage` will add multiple usages into one
1901
1979
  *
@@ -3421,36 +3499,6 @@
3421
3499
  * [ ] One piece can have multiple sources
3422
3500
  */
3423
3501
 
3424
- /**
3425
- * @@@
3426
- *
3427
- * Note: It is usefull @@@
3428
- *
3429
- * @param pipeline
3430
- * @public exported from `@promptbook/utils`
3431
- */
3432
- function clonePipeline(pipeline) {
3433
- // Note: Not using spread operator (...) because @@@
3434
- 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;
3435
- return {
3436
- pipelineUrl: pipelineUrl,
3437
- sourceFile: sourceFile,
3438
- title: title,
3439
- bookVersion: bookVersion,
3440
- description: description,
3441
- formfactorName: formfactorName,
3442
- parameters: parameters,
3443
- tasks: tasks,
3444
- knowledgeSources: knowledgeSources,
3445
- knowledgePieces: knowledgePieces,
3446
- personas: personas,
3447
- preparations: preparations,
3448
- };
3449
- }
3450
- /**
3451
- * TODO: [🍙] Make some standard order of json properties
3452
- */
3453
-
3454
3502
  /**
3455
3503
  * @@@
3456
3504
  *
@@ -3491,6 +3539,7 @@
3491
3539
  });
3492
3540
  }
3493
3541
  /**
3542
+ * TODO: [😂] Adding knowledge should be convert to async high-level abstractions, simmilar thing with expectations to sync high-level abstractions
3494
3543
  * TODO: [🧠] Add context to each task (if missing)
3495
3544
  * TODO: [🧠] What is better name `prepareTask` or `prepareTaskAndParameters`
3496
3545
  * TODO: [♨][main] !!! Prepare index the examples and maybe tasks
@@ -3579,11 +3628,19 @@
3579
3628
  case 3:
3580
3629
  tasksPrepared = (_c.sent()).tasksPrepared;
3581
3630
  // ----- /Tasks preparation -----
3631
+ // TODO: [😂] Use here all `AsyncHighLevelAbstraction`
3582
3632
  // Note: Count total usage
3583
3633
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
3584
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { tasks: __spreadArray([], __read(tasksPrepared), false),
3585
- // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3586
- knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
3634
+ return [2 /*return*/, exportJson({
3635
+ name: 'pipelineJson',
3636
+ message: "Result of `preparePipeline`",
3637
+ order: ORDER_OF_PIPELINE_JSON,
3638
+ value: __assign(__assign({}, pipeline), {
3639
+ // <- TODO: Probbably deeply clone the pipeline because `$exportJson` freezes the subobjects
3640
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, tasks: __spreadArray([], __read(tasksPrepared), false),
3641
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` tasks: tasksPrepared`
3642
+ personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }),
3643
+ })];
3587
3644
  }
3588
3645
  });
3589
3646
  });
@@ -5280,16 +5337,21 @@
5280
5337
  // Note: Wait a short time to prevent race conditions
5281
5338
  _g.sent();
5282
5339
  _g.label = 6;
5283
- case 6: return [2 /*return*/, $asDeeplyFrozenSerializableJson("Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"), {
5284
- isSuccessful: false,
5285
- errors: __spreadArray([
5286
- new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5287
- ], __read(errors), false).map(serializeError),
5288
- warnings: [],
5289
- executionReport: executionReport,
5290
- outputParameters: {},
5291
- usage: ZERO_USAGE,
5292
- preparedPipeline: preparedPipeline,
5340
+ case 6: return [2 /*return*/, exportJson({
5341
+ name: "executionReport",
5342
+ message: "Unuccessful PipelineExecutorResult (with missing parameter {".concat(parameter.name, "}) PipelineExecutorResult"),
5343
+ order: [],
5344
+ value: {
5345
+ isSuccessful: false,
5346
+ errors: __spreadArray([
5347
+ new PipelineExecutionError("Parameter `{".concat(parameter.name, "}` is required as an input parameter"))
5348
+ ], __read(errors), false).map(serializeError),
5349
+ warnings: [],
5350
+ executionReport: executionReport,
5351
+ outputParameters: {},
5352
+ usage: ZERO_USAGE,
5353
+ preparedPipeline: preparedPipeline,
5354
+ },
5293
5355
  })];
5294
5356
  case 7:
5295
5357
  _b = _a.next();
@@ -5328,16 +5390,21 @@
5328
5390
  // Note: Wait a short time to prevent race conditions
5329
5391
  _h.sent();
5330
5392
  _h.label = 3;
5331
- case 3: return [2 /*return*/, { value: $asDeeplyFrozenSerializableJson(spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }), {
5332
- isSuccessful: false,
5333
- errors: __spreadArray([
5334
- new PipelineExecutionError(spaceTrim.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 "); }))
5335
- ], __read(errors), false).map(serializeError),
5336
- warnings: warnings.map(serializeError),
5337
- executionReport: executionReport,
5338
- outputParameters: {},
5339
- usage: ZERO_USAGE,
5340
- preparedPipeline: preparedPipeline,
5393
+ case 3: return [2 /*return*/, { value: exportJson({
5394
+ name: 'pipelineExecutorResult',
5395
+ message: spaceTrim.spaceTrim(function (block) { return "\n Unuccessful PipelineExecutorResult (with extra parameter {".concat(parameter.name, "}) PipelineExecutorResult\n\n ").concat(block(pipelineIdentification), "\n "); }),
5396
+ order: [],
5397
+ value: {
5398
+ isSuccessful: false,
5399
+ errors: __spreadArray([
5400
+ new PipelineExecutionError(spaceTrim.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 "); }))
5401
+ ], __read(errors), false).map(serializeError),
5402
+ warnings: warnings.map(serializeError),
5403
+ executionReport: executionReport,
5404
+ outputParameters: {},
5405
+ usage: ZERO_USAGE,
5406
+ preparedPipeline: preparedPipeline,
5407
+ },
5341
5408
  }) }];
5342
5409
  case 4: return [2 /*return*/];
5343
5410
  }
@@ -5491,14 +5558,19 @@
5491
5558
  // Note: Wait a short time to prevent race conditions
5492
5559
  _g.sent();
5493
5560
  _g.label = 27;
5494
- case 27: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult', {
5495
- isSuccessful: false,
5496
- errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5497
- warnings: warnings.map(serializeError),
5498
- usage: usage_1,
5499
- executionReport: executionReport,
5500
- outputParameters: outputParameters_1,
5501
- preparedPipeline: preparedPipeline,
5561
+ case 27: return [2 /*return*/, exportJson({
5562
+ name: 'pipelineExecutorResult',
5563
+ message: "Unuccessful PipelineExecutorResult (with misc errors) PipelineExecutorResult",
5564
+ order: [],
5565
+ value: {
5566
+ isSuccessful: false,
5567
+ errors: __spreadArray([error_1], __read(errors), false).map(serializeError),
5568
+ warnings: warnings.map(serializeError),
5569
+ usage: usage_1,
5570
+ executionReport: executionReport,
5571
+ outputParameters: outputParameters_1,
5572
+ preparedPipeline: preparedPipeline,
5573
+ },
5502
5574
  })];
5503
5575
  case 28:
5504
5576
  usage = addUsage.apply(void 0, __spreadArray([], __read(executionReport.promptExecutions.map(function (_a) {
@@ -5519,14 +5591,19 @@
5519
5591
  // Note: Wait a short time to prevent race conditions
5520
5592
  _g.sent();
5521
5593
  _g.label = 30;
5522
- case 30: return [2 /*return*/, $asDeeplyFrozenSerializableJson('Successful PipelineExecutorResult', {
5523
- isSuccessful: true,
5524
- errors: errors.map(serializeError),
5525
- warnings: warnings.map(serializeError),
5526
- usage: usage,
5527
- executionReport: executionReport,
5528
- outputParameters: outputParameters,
5529
- preparedPipeline: preparedPipeline,
5594
+ case 30: return [2 /*return*/, exportJson({
5595
+ name: 'pipelineExecutorResult',
5596
+ message: "Successful PipelineExecutorResult",
5597
+ order: [],
5598
+ value: {
5599
+ isSuccessful: true,
5600
+ errors: errors.map(serializeError),
5601
+ warnings: warnings.map(serializeError),
5602
+ usage: usage,
5603
+ executionReport: executionReport,
5604
+ outputParameters: outputParameters,
5605
+ preparedPipeline: preparedPipeline,
5606
+ },
5530
5607
  })];
5531
5608
  }
5532
5609
  });
@@ -5650,7 +5727,7 @@
5650
5727
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5651
5728
  isAvilableInBrowser: true,
5652
5729
  requiredExecutables: [],
5653
- }); /* <- TODO: [🤛] */
5730
+ }); /* <- Note: [🤛] */
5654
5731
  /**
5655
5732
  * Registration of known scraper metadata
5656
5733
  *
@@ -5847,7 +5924,7 @@
5847
5924
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
5848
5925
  isAvilableInBrowser: true,
5849
5926
  requiredExecutables: [],
5850
- }); /* <- TODO: [🤛] */
5927
+ }); /* <- Note: [🤛] */
5851
5928
  /**
5852
5929
  * Registration of known scraper metadata
5853
5930
  *
@@ -5927,7 +6004,7 @@
5927
6004
  */
5928
6005
  var createPdfScraper = Object.assign(function (tools, options) {
5929
6006
  return new PdfScraper(tools, options);
5930
- }, pdfScraperMetadata); /* <- TODO: [🤛] */
6007
+ }, pdfScraperMetadata); /* <- Note: [🤛] */
5931
6008
  /**
5932
6009
  * TODO: [🎶] Naming "constructor" vs "creator" vs "factory"
5933
6010
  */