@promptbook/core 0.72.0-9 → 0.72.0

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 (133) hide show
  1. package/README.md +4 -8
  2. package/esm/index.es.js +119 -127
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +24 -18
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -0
  6. package/esm/typings/src/_packages/types.index.d.ts +18 -12
  7. package/esm/typings/src/_packages/utils.index.d.ts +2 -2
  8. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  9. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
  10. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  11. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  12. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  13. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
  14. package/esm/typings/src/config.d.ts +21 -14
  15. package/esm/typings/src/executables/$provideExecutablesForNode.d.ts +12 -0
  16. package/esm/typings/src/executables/apps/locateLibreoffice.d.ts +11 -0
  17. package/esm/typings/src/executables/apps/locatePandoc.d.ts +11 -0
  18. package/esm/typings/src/executables/locateApp.d.ts +33 -0
  19. package/esm/typings/src/executables/locateApp.test.d.ts +1 -0
  20. package/esm/typings/src/executables/platforms/locateAppOnLinux.d.ts +12 -0
  21. package/esm/typings/src/executables/platforms/locateAppOnMacOs.d.ts +12 -0
  22. package/esm/typings/src/executables/platforms/locateAppOnWindows.d.ts +12 -0
  23. package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
  24. package/esm/typings/src/execution/Executables.d.ts +18 -0
  25. package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
  26. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  27. package/esm/typings/src/execution/LlmExecutionTools.d.ts +2 -2
  28. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  29. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +3 -2
  30. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
  31. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
  32. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
  33. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
  34. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
  35. package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
  36. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  37. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
  38. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -2
  39. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
  40. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  41. package/esm/typings/src/llm-providers/_common/register/createLlmToolsFromConfiguration.d.ts +7 -0
  42. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
  43. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  44. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionToolsOptions.d.ts +2 -2
  45. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  46. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  47. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionToolsOptions.d.ts +2 -1
  48. package/esm/typings/src/llm-providers/langtail/LangtailExecutionTools.d.ts +1 -1
  49. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  50. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  51. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
  53. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
  54. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +0 -1
  55. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +2 -2
  56. package/esm/typings/src/llm-providers/openai/OpenAiExecutionToolsOptions.d.ts +2 -2
  57. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  58. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +4 -4
  59. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Request.d.ts +15 -6
  60. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
  61. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Request.d.ts +6 -12
  62. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
  63. package/esm/typings/src/llm-providers/remote/interfaces/RemoteLlmExecutionToolsOptions.d.ts +9 -14
  64. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +23 -8
  65. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  66. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
  67. package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
  68. package/esm/typings/src/scrapers/_common/Scraper.d.ts +2 -9
  69. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  70. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
  71. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
  72. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
  73. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
  74. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  75. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
  76. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  77. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  78. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
  79. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  80. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  81. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  82. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
  83. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  84. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
  85. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  86. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  87. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
  88. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  89. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  90. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
  91. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.test.d.ts +1 -0
  92. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  93. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
  94. package/esm/typings/src/types/Arrayable.d.ts +1 -1
  95. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
  96. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
  97. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  98. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  99. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
  100. package/esm/typings/src/types/Prompt.d.ts +2 -1
  101. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  102. package/esm/typings/src/types/typeAliases.d.ts +11 -8
  103. package/esm/typings/src/utils/$Register.d.ts +1 -1
  104. package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
  105. package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
  106. package/esm/typings/src/utils/emojis.d.ts +1 -1
  107. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +4 -2
  108. package/esm/typings/src/utils/execCommand/$execCommandNormalizeOptions.d.ts +12 -0
  109. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +1 -0
  110. package/esm/typings/src/utils/execCommand/ExecCommandOptions.d.ts +45 -0
  111. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  112. package/esm/typings/src/utils/files/isExecutable.d.ts +11 -0
  113. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  114. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
  115. package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
  116. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
  117. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
  118. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
  119. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  120. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  121. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  122. package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
  123. package/esm/typings/src/utils/sets/union.d.ts +1 -1
  124. package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
  125. package/package.json +3 -2
  126. package/umd/index.umd.js +130 -135
  127. package/umd/index.umd.js.map +1 -1
  128. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
  129. package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
  130. package/esm/typings/src/utils/execCommand/IExecCommandOptions.d.ts +0 -23
  131. package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +0 -10
  132. /package/esm/typings/src/{scrapers/website/WebsiteScraper.test.d.ts → executables/apps/locateLibreoffice.test.d.ts} +0 -0
  133. /package/esm/typings/src/{scrapers/website/utils/markdownConverter.test.d.ts → executables/apps/locatePandoc.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -14,7 +14,7 @@ import moment from 'moment';
14
14
  /**
15
15
  * The version of the Promptbook library
16
16
  */
17
- var PROMPTBOOK_VERSION = '0.72.0-8';
17
+ var PROMPTBOOK_VERSION = '0.72.0-34';
18
18
  // TODO: [main] !!!! List here all the versions and annotate + put into script
19
19
 
20
20
  /*! *****************************************************************************
@@ -221,7 +221,6 @@ function pipelineJsonToString(pipelineJson) {
221
221
  pipelineString += '\n\n';
222
222
  pipelineString += description;
223
223
  }
224
- // TODO:> const commands: Array<Command>
225
224
  var commands = [];
226
225
  if (pipelineUrl) {
227
226
  commands.push("PIPELINE URL ".concat(pipelineUrl));
@@ -277,7 +276,6 @@ function pipelineJsonToString(pipelineJson) {
277
276
  pipelineString += '\n\n';
278
277
  pipelineString += description_1;
279
278
  }
280
- // TODO:> const commands: Array<Command>
281
279
  var commands_1 = [];
282
280
  var contentLanguage = 'text';
283
281
  if (templateType === 'PROMPT_TEMPLATE') {
@@ -637,7 +635,7 @@ var GENERATOR_WARNING = "\u26A0\uFE0F WARNING: This code has been generated so t
637
635
  *
638
636
  * @public exported from `@promptbook/core`
639
637
  */
640
- var CLAIM = "Supercharge LLM models with Promptbook";
638
+ var CLAIM = "Build responsible, controlled and transparent applications on top of LLM models!";
641
639
  // <- TODO: [🧠] Better system for generator warnings - not always "code" and "by `@promptbook/cli`"
642
640
  /**
643
641
  * The maximum number of iterations for a loops
@@ -652,37 +650,44 @@ var LOOP_LIMIT = 1000;
652
650
  */
653
651
  var IMMEDIATE_TIME = 10;
654
652
  /**
655
- * The maximum number of (LLM) tasks running in parallel
653
+ * The maximum length of the (generated) filename
656
654
  *
657
655
  * @public exported from `@promptbook/core`
658
656
  */
659
- var MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
657
+ var MAX_FILENAME_LENGTH = 30;
660
658
  /**
661
- * The maximum number of attempts to execute LLM task before giving up
659
+ * Strategy for caching the intermediate results for knowledge sources
662
660
  *
663
661
  * @public exported from `@promptbook/core`
664
662
  */
665
- var MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
663
+ var DEFAULT_INTERMEDIATE_FILES_STRATEGY = 'HIDE_AND_KEEP';
664
+ // <- TODO: [😡] Change to 'VISIBLE'
666
665
  /**
667
- * The maximum length of the (generated) filename
666
+ * The maximum number of (LLM) tasks running in parallel
668
667
  *
669
668
  * @public exported from `@promptbook/core`
670
669
  */
671
- var MAX_FILENAME_LENGTH = 30;
670
+ var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
671
+ /**
672
+ * The maximum number of attempts to execute LLM task before giving up
673
+ *
674
+ * @public exported from `@promptbook/core`
675
+ */
676
+ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
672
677
  /**
673
678
  * @@@
674
679
  * TODO: [🐝][main] !!! Use
675
680
  *
676
681
  * @public exported from `@promptbook/core`
677
682
  */
678
- var MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
683
+ var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH = 3;
679
684
  /**
680
685
  * @@@
681
686
  * TODO: [🐝][main] !!! Use
682
687
  *
683
688
  * @public exported from `@promptbook/core`
684
689
  */
685
- var MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
690
+ var DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
686
691
  /**
687
692
  * Where to store the cache of executions for promptbook CLI
688
693
  *
@@ -690,7 +695,7 @@ var MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL = 200;
690
695
  *
691
696
  * @public exported from `@promptbook/core`
692
697
  */
693
- var EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
698
+ var DEFAULT_EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
694
699
  /**
695
700
  * Where to store the scrape cache
696
701
  *
@@ -698,13 +703,13 @@ var EXECUTIONS_CACHE_DIRNAME = '/.promptbook/executions-cache';
698
703
  *
699
704
  * @public exported from `@promptbook/core`
700
705
  */
701
- var SCRAPE_CACHE_DIRNAME = '/.promptbook/scrape-cache';
706
+ var DEFAULT_SCRAPE_CACHE_DIRNAME = '/.promptbook/scrape-cache';
702
707
  /**
703
708
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
704
709
  *
705
710
  * @public exported from `@promptbook/core`
706
711
  */
707
- var PIPELINE_COLLECTION_BASE_FILENAME = "index";
712
+ var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
708
713
  /**
709
714
  * Nonce which is used for replacing things in strings
710
715
  *
@@ -777,13 +782,13 @@ var DEFAULT_CSV_SETTINGS = Object.freeze({
777
782
  *
778
783
  * @public exported from `@promptbook/core`
779
784
  */
780
- var IS_VERBOSE = false;
785
+ var DEFAULT_IS_VERBOSE = false;
781
786
  /**
782
787
  * @@@
783
788
  *
784
789
  * @public exported from `@promptbook/core`
785
790
  */
786
- var IS_AUTO_INSTALLED = false;
791
+ var DEFAULT_IS_AUTO_INSTALLED = false;
787
792
  /**
788
793
  * @@@
789
794
  *
@@ -1532,7 +1537,7 @@ function createCollectionFromUrl(url, options) {
1532
1537
  return __generator(this, function (_d) {
1533
1538
  switch (_d.label) {
1534
1539
  case 0:
1535
- _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
1540
+ _a = options || {}, _b = _a.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b, _c = _a.isLazyLoaded, isLazyLoaded = _c === void 0 ? false : _c;
1536
1541
  collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
1537
1542
  return __generator(this, function (_a) {
1538
1543
  if (isVerbose) {
@@ -1818,8 +1823,7 @@ var PipelineExecutionError = /** @class */ (function (_super) {
1818
1823
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
1819
1824
  *
1820
1825
  * Note: Internal utility of `joinLlmExecutionTools` but exposed type
1821
- * @public exported from `@promptbook/types`
1822
- * TODO: !!!!!! Export as runtime class not just type
1826
+ * @public exported from `@promptbook/core`
1823
1827
  */
1824
1828
  var MultipleLlmExecutionTools = /** @class */ (function () {
1825
1829
  /**
@@ -2435,6 +2439,7 @@ function assertsExecutionSuccessful(executionResult) {
2435
2439
  }
2436
2440
  }
2437
2441
  /**
2442
+ * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
2438
2443
  * TODO: [🧠] Can this return type be better typed than void
2439
2444
  */
2440
2445
 
@@ -3763,12 +3768,11 @@ function isPassingExpectations(expectations, value) {
3763
3768
  */
3764
3769
  function executeAttempts(options) {
3765
3770
  return __awaiter(this, void 0, void 0, function () {
3766
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, settings, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3771
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3767
3772
  return __generator(this, function (_a) {
3768
3773
  switch (_a.label) {
3769
3774
  case 0:
3770
- jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools, settings = options.settings, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification;
3771
- maxExecutionAttempts = settings.maxExecutionAttempts;
3775
+ jokerParameterNames = options.jokerParameterNames, priority = options.priority, maxAttempts = options.maxAttempts, preparedContent = options.preparedContent, parameters = options.parameters, template = options.template, preparedPipeline = options.preparedPipeline, tools = options.tools, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, maxExecutionAttempts = options.maxExecutionAttempts;
3772
3776
  $ongoingTemplateResult = {
3773
3777
  $result: null,
3774
3778
  $resultString: null,
@@ -4134,12 +4138,12 @@ function executeAttempts(options) {
4134
4138
  */
4135
4139
  function executeFormatSubvalues(options) {
4136
4140
  return __awaiter(this, void 0, void 0, function () {
4137
- var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4141
+ var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
4138
4142
  var _this = this;
4139
4143
  return __generator(this, function (_a) {
4140
4144
  switch (_a.label) {
4141
4145
  case 0:
4142
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
4146
+ template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
4143
4147
  if (template.foreach === undefined) {
4144
4148
  return [2 /*return*/, /* not await */ executeAttempts(options)];
4145
4149
  }
@@ -4169,7 +4173,7 @@ function executeFormatSubvalues(options) {
4169
4173
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
4170
4174
  }
4171
4175
  if (formatDefinition.formatName === 'CSV') {
4172
- formatSettings = settings.csvSettings;
4176
+ formatSettings = csvSettings;
4173
4177
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
4174
4178
  }
4175
4179
  return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
@@ -4322,13 +4326,12 @@ function getReservedParametersForTemplate(options) {
4322
4326
  */
4323
4327
  function executeTemplate(options) {
4324
4328
  return __awaiter(this, void 0, void 0, function () {
4325
- var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress, settings, $executionReport, pipelineIdentification, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _a, _b, _c, definedParameterNames, parameters, _loop_1, _d, _e, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
4326
- var e_1, _f, _g;
4327
- return __generator(this, function (_h) {
4328
- switch (_h.label) {
4329
+ var currentTemplate, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, _a, maxExecutionAttempts, name, title, priority, usedParameterNames, dependentParameterNames, definedParameters, _b, _c, _d, definedParameterNames, parameters, _loop_1, _e, _f, parameterName, maxAttempts, jokerParameterNames, preparedContent, resultString;
4330
+ var e_1, _g, _h;
4331
+ return __generator(this, function (_j) {
4332
+ switch (_j.label) {
4329
4333
  case 0:
4330
- currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, settings = options.settings, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification;
4331
- maxExecutionAttempts = settings.maxExecutionAttempts;
4334
+ currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a;
4332
4335
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
4333
4336
  title = currentTemplate.title;
4334
4337
  priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
@@ -4343,7 +4346,7 @@ function executeTemplate(options) {
4343
4346
  // <- [🍸]
4344
4347
  })];
4345
4348
  case 1:
4346
- _h.sent();
4349
+ _j.sent();
4347
4350
  usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4348
4351
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4349
4352
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
@@ -4354,15 +4357,15 @@ function executeTemplate(options) {
4354
4357
  .map(function (name) { return "{".concat(name, "}"); })
4355
4358
  .join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4356
4359
  }
4357
- _b = (_a = Object).freeze;
4358
- _c = [{}];
4360
+ _c = (_b = Object).freeze;
4361
+ _d = [{}];
4359
4362
  return [4 /*yield*/, getReservedParametersForTemplate({
4360
4363
  preparedPipeline: preparedPipeline,
4361
4364
  template: currentTemplate,
4362
4365
  pipelineIdentification: pipelineIdentification,
4363
4366
  })];
4364
4367
  case 2:
4365
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
4368
+ definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
4366
4369
  definedParameterNames = new Set(Object.keys(definedParameters));
4367
4370
  parameters = {};
4368
4371
  _loop_1 = function (parameterName) {
@@ -4382,15 +4385,15 @@ function executeTemplate(options) {
4382
4385
  try {
4383
4386
  // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4384
4387
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4385
- for (_d = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _e = _d.next(); !_e.done; _e = _d.next()) {
4386
- parameterName = _e.value;
4388
+ for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4389
+ parameterName = _f.value;
4387
4390
  _loop_1(parameterName);
4388
4391
  }
4389
4392
  }
4390
4393
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
4391
4394
  finally {
4392
4395
  try {
4393
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
4396
+ if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
4394
4397
  }
4395
4398
  finally { if (e_1) throw e_1.error; }
4396
4399
  }
@@ -4410,12 +4413,11 @@ function executeTemplate(options) {
4410
4413
  template: currentTemplate,
4411
4414
  preparedPipeline: preparedPipeline,
4412
4415
  tools: tools,
4413
- settings: settings,
4414
4416
  $executionReport: $executionReport,
4415
4417
  pipelineIdentification: pipelineIdentification,
4416
4418
  })];
4417
4419
  case 3:
4418
- resultString = _h.sent();
4420
+ resultString = _j.sent();
4419
4421
  return [4 /*yield*/, onProgress({
4420
4422
  name: name,
4421
4423
  title: title,
@@ -4427,12 +4429,12 @@ function executeTemplate(options) {
4427
4429
  // <- [🍸]
4428
4430
  })];
4429
4431
  case 4:
4430
- _h.sent();
4431
- return [2 /*return*/, Object.freeze((_g = {},
4432
- _g[currentTemplate.resultingParameterName] =
4432
+ _j.sent();
4433
+ return [2 /*return*/, Object.freeze((_h = {},
4434
+ _h[currentTemplate.resultingParameterName] =
4433
4435
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4434
4436
  resultString,
4435
- _g))];
4437
+ _h))];
4436
4438
  }
4437
4439
  });
4438
4440
  });
@@ -4491,13 +4493,12 @@ function filterJustOutputParameters(options) {
4491
4493
  */
4492
4494
  function executePipeline(options) {
4493
4495
  return __awaiter(this, void 0, void 0, function () {
4494
- var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, settings, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
4496
+ var inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, _a, isVerbose, preparedPipeline, errors, warnings, executionReport, isReturned, _b, _c, parameter, e_1_1, _loop_1, _d, _e, parameterName, state_1, e_2_1, parametersToPass, resovedParameterNames_1, unresovedTemplates_1, resolving_1, loopLimit, _loop_2, error_1, usage_1, outputParameters_1, usage, outputParameters;
4495
4497
  var e_1, _f, e_2, _g;
4496
4498
  return __generator(this, function (_h) {
4497
4499
  switch (_h.label) {
4498
4500
  case 0:
4499
- inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
4500
- maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4501
+ inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, maxParallelCount = options.maxParallelCount, rootDirname = options.rootDirname, _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4501
4502
  preparedPipeline = options.preparedPipeline;
4502
4503
  if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
4503
4504
  return [4 /*yield*/, preparePipeline(pipeline, tools, {
@@ -4682,12 +4683,7 @@ function executePipeline(options) {
4682
4683
  return [3 /*break*/, 4];
4683
4684
  case 3:
4684
4685
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4685
- work_1 = executeTemplate({
4686
- currentTemplate: currentTemplate,
4687
- preparedPipeline: preparedPipeline,
4688
- parametersToPass: parametersToPass,
4689
- tools: tools,
4690
- onProgress: function (progress) {
4686
+ work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4691
4687
  if (isReturned) {
4692
4688
  throw new UnexpectedError(spaceTrim$1(function (block) { return "\n Can not call `onProgress` after pipeline execution is finished\n\n ".concat(block(pipelineIdentification), "\n\n ").concat(block(JSON.stringify(progress, null, 4)
4693
4689
  .split('\n')
@@ -4697,11 +4693,7 @@ function executePipeline(options) {
4697
4693
  if (onProgress) {
4698
4694
  onProgress(progress);
4699
4695
  }
4700
- },
4701
- settings: settings,
4702
- $executionReport: executionReport,
4703
- pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
4704
- })
4696
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
4705
4697
  .then(function (newParametersToPass) {
4706
4698
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4707
4699
  resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
@@ -4805,8 +4797,7 @@ function executePipeline(options) {
4805
4797
  */
4806
4798
  function createPipelineExecutor(options) {
4807
4799
  var _this = this;
4808
- var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
4809
- var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? MAX_EXECUTION_ATTEMPTS : _b, _c = settings.maxParallelCount, maxParallelCount = _c === void 0 ? MAX_PARALLEL_COUNT : _c, _d = settings.csvSettings, csvSettings = _d === void 0 ? DEFAULT_CSV_SETTINGS : _d, _e = settings.isVerbose, isVerbose = _e === void 0 ? IS_VERBOSE : _e, _f = settings.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _f === void 0 ? false : _f, _g = settings.rootDirname, rootDirname = _g === void 0 ? null : _g;
4800
+ var pipeline = options.pipeline, tools = options.tools, _a = options.maxExecutionAttempts, maxExecutionAttempts = _a === void 0 ? DEFAULT_MAX_EXECUTION_ATTEMPTS : _a, _b = options.maxParallelCount, maxParallelCount = _b === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _b, _c = options.csvSettings, csvSettings = _c === void 0 ? DEFAULT_CSV_SETTINGS : _c, _d = options.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d, _e = options.isNotPreparedWarningSupressed, isNotPreparedWarningSupressed = _e === void 0 ? false : _e, _f = options.rootDirname, rootDirname = _f === void 0 ? null : _f;
4810
4801
  validatePipeline(pipeline);
4811
4802
  var pipelineIdentification = (function () {
4812
4803
  // Note: This is a 😐 implementation of [🚞]
@@ -4840,14 +4831,12 @@ function createPipelineExecutor(options) {
4840
4831
  tools: tools,
4841
4832
  onProgress: onProgress,
4842
4833
  pipelineIdentification: spaceTrim$1(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
4843
- settings: {
4844
- maxExecutionAttempts: maxExecutionAttempts,
4845
- maxParallelCount: maxParallelCount,
4846
- csvSettings: csvSettings,
4847
- isVerbose: isVerbose,
4848
- isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4849
- rootDirname: rootDirname,
4850
- },
4834
+ maxExecutionAttempts: maxExecutionAttempts,
4835
+ maxParallelCount: maxParallelCount,
4836
+ csvSettings: csvSettings,
4837
+ isVerbose: isVerbose,
4838
+ isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4839
+ rootDirname: rootDirname,
4851
4840
  })];
4852
4841
  });
4853
4842
  }); };
@@ -4870,7 +4859,7 @@ function preparePersona(personaDescription, tools, options) {
4870
4859
  return __generator(this, function (_d) {
4871
4860
  switch (_d.label) {
4872
4861
  case 0:
4873
- _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4862
+ _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4874
4863
  if (tools === undefined || tools.llm === undefined) {
4875
4864
  throw new MissingToolsError('LLM tools are required for preparing persona');
4876
4865
  }
@@ -5052,7 +5041,7 @@ var $Register = /** @class */ (function () {
5052
5041
  this.storage = globalScope[storageName];
5053
5042
  }
5054
5043
  $Register.prototype.list = function () {
5055
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
5044
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
5056
5045
  return this.storage;
5057
5046
  };
5058
5047
  $Register.prototype.register = function (registered) {
@@ -5104,7 +5093,6 @@ var $scrapersRegister = new $Register('scraper_constructors');
5104
5093
  * TODO: [®] DRY Register logic
5105
5094
  */
5106
5095
 
5107
- // TODO: !!!!!! Maybe delete this function
5108
5096
  /**
5109
5097
  * Creates a message with all registered scrapers
5110
5098
  *
@@ -5271,7 +5259,6 @@ function normalizeToKebabCase(text) {
5271
5259
  * @private within the repository
5272
5260
  */
5273
5261
  function sourceContentToName(sourceContent) {
5274
- // TODO: !!!!!! Better name for source than gibberish hash
5275
5262
  var hash = SHA256(hexEncoder.parse(JSON.stringify(sourceContent)))
5276
5263
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
5277
5264
  .toString( /* hex */)
@@ -5371,20 +5358,20 @@ function isValidFilePath(filename) {
5371
5358
  /**
5372
5359
  * @@@
5373
5360
  *
5374
- * @private for scraper utilities
5361
+ * @public exported from `@promptbook/core`
5375
5362
  */
5376
5363
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5377
5364
  var _a;
5378
5365
  return __awaiter(this, void 0, void 0, function () {
5379
5366
  var sourceContent, name, _b, _c, rootDirname, _d,
5380
5367
  // <- TODO: process.cwd() if running in Node.js
5381
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
5368
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5382
5369
  return __generator(this, function (_e) {
5383
5370
  switch (_e.label) {
5384
5371
  case 0:
5385
5372
  sourceContent = knowledgeSource.sourceContent;
5386
5373
  name = knowledgeSource.name;
5387
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? IS_VERBOSE : _d;
5374
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
5388
5375
  TODO_USE(isVerbose);
5389
5376
  if (!name) {
5390
5377
  name = sourceContentToName(sourceContent);
@@ -5400,19 +5387,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5400
5387
  filename: null,
5401
5388
  url: url,
5402
5389
  mimeType: mimeType,
5403
- asBlob: function () {
5404
- return __awaiter(this, void 0, void 0, function () {
5405
- var content;
5406
- return __generator(this, function (_a) {
5407
- switch (_a.label) {
5408
- case 0: return [4 /*yield*/, response_1.blob()];
5409
- case 1:
5410
- content = _a.sent();
5411
- return [2 /*return*/, content];
5412
- }
5413
- });
5414
- });
5415
- },
5390
+ /*
5391
+ TODO: [🥽]
5392
+ > async asBlob() {
5393
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
5394
+ > const content = await response.blob();
5395
+ > return content;
5396
+ > },
5397
+ */
5416
5398
  asJson: function () {
5417
5399
  return __awaiter(this, void 0, void 0, function () {
5418
5400
  var content;
@@ -5452,34 +5434,31 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5452
5434
  }
5453
5435
  filename_1 = join(rootDirname, sourceContent).split('\\').join('/');
5454
5436
  fileExtension = getFileExtension(filename_1);
5455
- mimeType_1 = extensionToMimeType(fileExtension || '');
5437
+ mimeType = extensionToMimeType(fileExtension || '');
5456
5438
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5457
5439
  case 3:
5458
5440
  if (!(_e.sent())) {
5459
5441
  throw new NotFoundError(spaceTrim(function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
5460
5442
  }
5461
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
5443
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5462
5444
  return [2 /*return*/, {
5463
5445
  source: name,
5464
5446
  filename: filename_1,
5465
5447
  url: null,
5466
- mimeType: mimeType_1,
5467
- asBlob: function () {
5468
- return __awaiter(this, void 0, void 0, function () {
5469
- var content;
5470
- return __generator(this, function (_a) {
5471
- switch (_a.label) {
5472
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5473
- case 1:
5474
- content = _a.sent();
5475
- return [2 /*return*/, new Blob([
5476
- content,
5477
- // <- TODO: !!!!!! Maybe not working
5478
- ], { type: mimeType_1 })];
5479
- }
5480
- });
5481
- });
5482
- },
5448
+ mimeType: mimeType,
5449
+ /*
5450
+ TODO: [🥽]
5451
+ > async asBlob() {
5452
+ > const content = await tools.fs!.readFile(filename);
5453
+ > return new Blob(
5454
+ > [
5455
+ > content,
5456
+ > // <- TODO: [🥽] This is NOT tested, test it
5457
+ > ],
5458
+ > { type: mimeType },
5459
+ > );
5460
+ > },
5461
+ */
5483
5462
  asJson: function () {
5484
5463
  return __awaiter(this, void 0, void 0, function () {
5485
5464
  var _a, _b;
@@ -5515,9 +5494,14 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5515
5494
  asJson: function () {
5516
5495
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
5517
5496
  },
5518
- asBlob: function () {
5519
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
5520
- },
5497
+ /*
5498
+ TODO: [🥽]
5499
+ > asBlob() {
5500
+ > throw new UnexpectedError(
5501
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
5502
+ > );
5503
+ > },
5504
+ */
5521
5505
  }];
5522
5506
  }
5523
5507
  });
@@ -5537,7 +5521,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
5537
5521
  return __generator(this, function (_c) {
5538
5522
  switch (_c.label) {
5539
5523
  case 0:
5540
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5524
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
5541
5525
  knowledgePreparedUnflatten = new Array(knowledgeSources.length);
5542
5526
  return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
5543
5527
  var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
@@ -5566,7 +5550,8 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
5566
5550
  case 4:
5567
5551
  partialPiecesUnchecked = _d.sent();
5568
5552
  if (partialPiecesUnchecked !== null) {
5569
- partialPieces = partialPiecesUnchecked;
5553
+ partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5554
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5570
5555
  return [3 /*break*/, 6];
5571
5556
  }
5572
5557
  _d.label = 5;
@@ -5614,7 +5599,7 @@ TODO: [🧊] This is how it can look in future
5614
5599
  > /**
5615
5600
  > * Unprepared knowledge
5616
5601
  > * /
5617
- > readonly knowledgeSources: Array<KnowledgeSourceJson>;
5602
+ > readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
5618
5603
  > };
5619
5604
  >
5620
5605
  > export async function prepareKnowledgePieces(
@@ -5672,7 +5657,7 @@ function prepareTemplates(pipeline, tools, options) {
5672
5657
  return __generator(this, function (_b) {
5673
5658
  switch (_b.label) {
5674
5659
  case 0:
5675
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
5660
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5676
5661
  templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5677
5662
  // TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
5678
5663
  TODO_USE(parameters);
@@ -5734,7 +5719,7 @@ function preparePipeline(pipeline, tools, options) {
5734
5719
  if (isPipelinePrepared(pipeline)) {
5735
5720
  return [2 /*return*/, pipeline];
5736
5721
  }
5737
- rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5722
+ rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
5738
5723
  parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5739
5724
  if (tools === undefined || tools.llm === undefined) {
5740
5725
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
@@ -5792,7 +5777,9 @@ function preparePipeline(pipeline, tools, options) {
5792
5777
  // ----- /Templates preparation -----
5793
5778
  // Note: Count total usage
5794
5779
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5795
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: templatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations }))];
5780
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5781
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5782
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5796
5783
  }
5797
5784
  });
5798
5785
  });
@@ -5839,6 +5826,7 @@ var knowledgeCommandParser = {
5839
5826
  'KNOWLEDGE ./hejny-cv.md',
5840
5827
  'KNOWLEDGE ./hejny-cv.pdf',
5841
5828
  'KNOWLEDGE ./hejny-cv.docx',
5829
+ // <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
5842
5830
  ],
5843
5831
  /**
5844
5832
  * Parses the KNOWLEDGE command
@@ -8962,7 +8950,7 @@ function $registeredLlmToolsMessage() {
8962
8950
  */
8963
8951
  function createLlmToolsFromConfiguration(configuration, options) {
8964
8952
  if (options === void 0) { options = {}; }
8965
- var _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8953
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
8966
8954
  var llmTools = configuration.map(function (llmConfiguration) {
8967
8955
  var registeredItem = $llmToolsRegister
8968
8956
  .list()
@@ -8973,7 +8961,7 @@ function createLlmToolsFromConfiguration(configuration, options) {
8973
8961
  if (registeredItem === undefined) {
8974
8962
  throw new Error(spaceTrim(function (block) { return "\n There is no constructor for LLM provider `".concat(llmConfiguration.className, "` from `").concat(llmConfiguration.packageName, "`\n\n You have probably forgotten install and import the provider package.\n To fix this issue, you can:\n\n Install:\n\n > npm install ").concat(llmConfiguration.packageName, "\n\n And import:\n\n > import '").concat(llmConfiguration.packageName, "';\n\n\n ").concat(block($registeredLlmToolsMessage()), "\n "); }));
8975
8963
  }
8976
- return registeredItem(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
8964
+ return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
8977
8965
  });
8978
8966
  return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
8979
8967
  }
@@ -9063,7 +9051,7 @@ function $currentDate() {
9063
9051
  function cacheLlmTools(llmTools, options) {
9064
9052
  var _this = this;
9065
9053
  if (options === void 0) { options = {}; }
9066
- var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.isReloaded, isReloaded = _b === void 0 ? false : _b;
9054
+ var _a = options.storage, storage = _a === void 0 ? new MemoryStorage() : _a, _b = options.isCacheReloaded, isCacheReloaded = _b === void 0 ? false : _b;
9067
9055
  var proxyTools = __assign(__assign({}, llmTools), {
9068
9056
  // <- Note: [🥫]
9069
9057
  get title() {
@@ -9085,7 +9073,7 @@ function cacheLlmTools(llmTools, options) {
9085
9073
  key = titleToName(prompt.title.substring(0, MAX_FILENAME_LENGTH - 10) +
9086
9074
  '-' +
9087
9075
  sha256(hexEncoder.parse(JSON.stringify(prompt.parameters))).toString( /* hex */));
9088
- if (!!isReloaded) return [3 /*break*/, 2];
9076
+ if (!!isCacheReloaded) return [3 /*break*/, 2];
9089
9077
  return [4 /*yield*/, storage.getItem(key)];
9090
9078
  case 1:
9091
9079
  _a = _c.sent();
@@ -9394,7 +9382,11 @@ var legacyDocumentScraperMetadata = $deepFreeze({
9394
9382
  mimeTypes: ['application/msword', 'text/rtf'],
9395
9383
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9396
9384
  isAvilableInBrowser: false,
9397
- requiredExecutables: ['!!!!!!'],
9385
+ requiredExecutables: [
9386
+ 'Pandoc',
9387
+ 'LibreOffice',
9388
+ // <- TODO: [🧠] Should be 'LibreOffice' here, its dependency of dependency
9389
+ ],
9398
9390
  }); /* <- TODO: [🤛] */
9399
9391
  /**
9400
9392
  * Registration of known scraper metadata
@@ -9418,7 +9410,7 @@ var documentScraperMetadata = $deepFreeze({
9418
9410
  mimeTypes: ['application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
9419
9411
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9420
9412
  isAvilableInBrowser: false,
9421
- requiredExecutables: ['!!!!!!'],
9413
+ requiredExecutables: ['Pandoc'],
9422
9414
  }); /* <- TODO: [🤛] */
9423
9415
  /**
9424
9416
  * Registration of known scraper metadata
@@ -9442,7 +9434,7 @@ var markdownScraperMetadata = $deepFreeze({
9442
9434
  mimeTypes: ['text/markdown', 'text/plain'],
9443
9435
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9444
9436
  isAvilableInBrowser: true,
9445
- requiredExecutables: ['!!!!!!'],
9437
+ requiredExecutables: [],
9446
9438
  }); /* <- TODO: [🤛] */
9447
9439
  /**
9448
9440
  * Registration of known scraper metadata
@@ -9466,7 +9458,7 @@ var pdfScraperMetadata = $deepFreeze({
9466
9458
  mimeTypes: ['application/pdf'],
9467
9459
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9468
9460
  isAvilableInBrowser: true,
9469
- requiredExecutables: ['!!!!!!'],
9461
+ requiredExecutables: [],
9470
9462
  }); /* <- TODO: [🤛] */
9471
9463
  /**
9472
9464
  * Registration of known scraper metadata
@@ -9490,7 +9482,7 @@ var websiteScraperMetadata = $deepFreeze({
9490
9482
  mimeTypes: ['text/html'],
9491
9483
  documentationUrl: 'https://github.com/webgptorg/promptbook/discussions/@@',
9492
9484
  isAvilableInBrowser: false,
9493
- requiredExecutables: ['!!!!!!'],
9485
+ requiredExecutables: [],
9494
9486
  }); /* <- TODO: [🤛] */
9495
9487
  /**
9496
9488
  * Registration of known scraper metadata
@@ -9852,5 +9844,5 @@ function executionReportJsonToString(executionReportJson, options) {
9852
9844
  * TODO: [🧠] Should be in generated file GENERATOR_WARNING
9853
9845
  */
9854
9846
 
9855
- export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, ERRORS, EXECUTIONS_CACHE_DIRNAME, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, IS_AUTO_INSTALLED, IS_VERBOSE, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_EXECUTION_ATTEMPTS, MAX_FILENAME_LENGTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, MAX_PARALLEL_COUNT, MODEL_VARIANTS, MemoryStorage, MissingToolsError, NotFoundError, NotYetImplementedError, PIPELINE_COLLECTION_BASE_FILENAME, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, SCRAPE_CACHE_DIRNAME, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9847
+ export { $llmToolsMetadataRegister, $llmToolsRegister, $scrapersMetadataRegister, $scrapersRegister, AbstractFormatError, CLAIM, CallbackInterfaceTools, CollectionError, CsvFormatDefinition, CsvFormatError, DEFAULT_CSV_SETTINGS, DEFAULT_EXECUTIONS_CACHE_DIRNAME, DEFAULT_INTERMEDIATE_FILES_STRATEGY, DEFAULT_IS_AUTO_INSTALLED, DEFAULT_IS_VERBOSE, DEFAULT_MAX_EXECUTION_ATTEMPTS, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_DEPTH, DEFAULT_MAX_KNOWLEDGE_SOURCES_SCRAPING_TOTAL, DEFAULT_MAX_PARALLEL_COUNT, DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME, DEFAULT_REMOTE_URL, DEFAULT_REMOTE_URL_PATH, DEFAULT_SCRAPE_CACHE_DIRNAME, ERRORS, EXPECTATION_UNITS, EnvironmentMismatchError, ExecutionReportStringOptionsDefaults, ExpectError, KnowledgeScrapeError, LimitReachedError, MANDATORY_CSV_SETTINGS, MAX_FILENAME_LENGTH, MODEL_VARIANTS, MemoryStorage, MissingToolsError, MultipleLlmExecutionTools, NotFoundError, NotYetImplementedError, PROMPTBOOK_VERSION, ParseError, PipelineExecutionError, PipelineLogicError, PipelineUrlError, PrefixStorage, RESERVED_PARAMETER_NAMES, TemplateTypes, TextFormatDefinition, UNCERTAIN_USAGE, UnexpectedError, ZERO_USAGE, _AnthropicClaudeMetadataRegistration, _AzureOpenAiMetadataRegistration, _DocumentScraperMetadataRegistration, _LegacyDocumentScraperMetadataRegistration, _MarkdownScraperMetadataRegistration, _OpenAiAssistantMetadataRegistration, _OpenAiMetadataRegistration, _PdfScraperMetadataRegistration, _WebsiteScraperMetadataRegistration, addUsage, assertsExecutionSuccessful, cacheLlmTools, collectionToJson, countTotalUsage, createCollectionFromJson, createCollectionFromPromise, createCollectionFromUrl, createLlmToolsFromConfiguration, createPipelineExecutor, createSubcollection, embeddingVectorToString, executionReportJsonToString, isPassingExpectations, isPipelinePrepared, joinLlmExecutionTools, limitTotalUsage, makeKnowledgeSourceHandler, pipelineJsonToString, pipelineStringToJson, pipelineStringToJsonSync, prepareKnowledgePieces, preparePersona, preparePipeline, prepareTemplates, prettifyPipelineString, stringifyPipelineJson, unpreparePipeline, usageToHuman, usageToWorktime, validatePipeline };
9856
9848
  //# sourceMappingURL=index.es.js.map