@promptbook/node 0.71.0-17 → 0.71.0-19

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 (107) hide show
  1. package/README.md +2 -4
  2. package/esm/index.es.js +106 -87
  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 +10 -10
  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/execution/EmbeddingVector.d.ts +1 -1
  16. package/esm/typings/src/execution/Executables.d.ts +18 -0
  17. package/esm/typings/src/execution/ExecutionTools.d.ts +9 -3
  18. package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
  19. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  20. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
  21. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
  22. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
  23. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
  24. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
  25. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/LindatAutomaticTranslator.d.ts +11 -3
  26. package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
  27. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  28. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
  29. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -2
  30. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
  31. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
  33. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  35. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +4 -5
  40. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
  41. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
  42. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  43. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  44. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +4 -4
  45. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_Prompt_Response.d.ts +3 -3
  46. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -23
  47. package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
  48. package/esm/typings/src/scrapers/_common/Scraper.d.ts +2 -2
  49. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  50. package/esm/typings/src/scrapers/_common/register/$provideExecutablesForNode.d.ts +12 -0
  51. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +2 -2
  52. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +2 -2
  53. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
  54. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
  55. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  56. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +2 -2
  57. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  58. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  59. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +3 -3
  60. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  61. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  62. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  63. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
  64. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  65. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +2 -2
  66. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  67. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  68. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +6 -3
  69. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  70. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  71. package/esm/typings/src/scrapers/website/utils/createShowdownConverter.d.ts +7 -0
  72. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  73. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
  74. package/esm/typings/src/types/Arrayable.d.ts +1 -1
  75. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
  76. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
  77. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  78. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  79. package/esm/typings/src/types/PipelineJson/TemplateJsonCommon.d.ts +2 -2
  80. package/esm/typings/src/types/Prompt.d.ts +1 -1
  81. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  82. package/esm/typings/src/utils/$Register.d.ts +1 -1
  83. package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
  84. package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
  85. package/esm/typings/src/utils/emojis.d.ts +1 -1
  86. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -2
  87. package/esm/typings/src/utils/execCommand/{IExecCommandOptions.d.ts → ExecCommandOptions.d.ts} +2 -6
  88. package/esm/typings/src/utils/execCommand/execCommandNormalizeOptions.d.ts +3 -3
  89. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  90. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  91. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
  92. package/esm/typings/src/utils/normalization/IKeywords.d.ts +2 -2
  93. package/esm/typings/src/utils/normalization/parseKeywords.d.ts +2 -2
  94. package/esm/typings/src/utils/normalization/parseKeywordsFromString.d.ts +2 -2
  95. package/esm/typings/src/utils/normalization/searchKeywords.d.ts +2 -2
  96. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  97. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  98. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  99. package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
  100. package/esm/typings/src/utils/sets/union.d.ts +1 -1
  101. package/esm/typings/src/utils/unwrapResult.d.ts +4 -4
  102. package/package.json +4 -3
  103. package/umd/index.umd.js +106 -86
  104. package/umd/index.umd.js.map +1 -1
  105. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
  106. package/esm/typings/src/scrapers/website/utils/markdownConverter.d.ts +0 -12
  107. /package/esm/typings/src/scrapers/website/utils/{markdownConverter.test.d.ts → createShowdownConverter.test.d.ts} +0 -0
package/umd/index.umd.js CHANGED
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.71.0-16';
38
+ var PROMPTBOOK_VERSION = '0.71.0-18';
39
39
  // TODO: [main] !!!! List here all the versions and annotate + put into script
40
40
 
41
41
  /*! *****************************************************************************
@@ -384,29 +384,30 @@
384
384
  */
385
385
  var IMMEDIATE_TIME = 10;
386
386
  /**
387
- * The maximum number of (LLM) tasks running in parallel
387
+ * The maximum length of the (generated) filename
388
388
  *
389
389
  * @public exported from `@promptbook/core`
390
390
  */
391
- var MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
391
+ var MAX_FILENAME_LENGTH = 30;
392
+ // <- TODO: [😡] Change to 'VISIBLE'
392
393
  /**
393
- * The maximum number of attempts to execute LLM task before giving up
394
+ * The maximum number of (LLM) tasks running in parallel
394
395
  *
395
396
  * @public exported from `@promptbook/core`
396
397
  */
397
- var MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
398
+ var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
398
399
  /**
399
- * The maximum length of the (generated) filename
400
+ * The maximum number of attempts to execute LLM task before giving up
400
401
  *
401
402
  * @public exported from `@promptbook/core`
402
403
  */
403
- var MAX_FILENAME_LENGTH = 30;
404
+ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
404
405
  /**
405
406
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
406
407
  *
407
408
  * @public exported from `@promptbook/core`
408
409
  */
409
- var PIPELINE_COLLECTION_BASE_FILENAME = "index";
410
+ var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
410
411
  /**
411
412
  * Nonce which is used for replacing things in strings
412
413
  *
@@ -458,13 +459,13 @@
458
459
  *
459
460
  * @public exported from `@promptbook/core`
460
461
  */
461
- var IS_VERBOSE = false;
462
+ var DEFAULT_IS_VERBOSE = false;
462
463
  /**
463
464
  * @@@
464
465
  *
465
466
  * @public exported from `@promptbook/core`
466
467
  */
467
- var IS_AUTO_INSTALLED = false;
468
+ var DEFAULT_IS_AUTO_INSTALLED = false;
468
469
  /**
469
470
  * @@@
470
471
  *
@@ -536,7 +537,6 @@
536
537
  pipelineString += '\n\n';
537
538
  pipelineString += description;
538
539
  }
539
- // TODO:> const commands: Array<Command>
540
540
  var commands = [];
541
541
  if (pipelineUrl) {
542
542
  commands.push("PIPELINE URL ".concat(pipelineUrl));
@@ -592,7 +592,6 @@
592
592
  pipelineString += '\n\n';
593
593
  pipelineString += description_1;
594
594
  }
595
- // TODO:> const commands: Array<Command>
596
595
  var commands_1 = [];
597
596
  var contentLanguage = 'text';
598
597
  if (templateType === 'PROMPT_TEMPLATE') {
@@ -1046,8 +1045,7 @@
1046
1045
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
1047
1046
  *
1048
1047
  * Note: Internal utility of `joinLlmExecutionTools` but exposed type
1049
- * @public exported from `@promptbook/types`
1050
- * TODO: !!!!!! Export as runtime class not just type
1048
+ * @public exported from `@promptbook/core`
1051
1049
  */
1052
1050
  var MultipleLlmExecutionTools = /** @class */ (function () {
1053
1051
  /**
@@ -2117,6 +2115,7 @@
2117
2115
  }
2118
2116
  }
2119
2117
  /**
2118
+ * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
2120
2119
  * TODO: [🧠] Can this return type be better typed than void
2121
2120
  */
2122
2121
 
@@ -3423,12 +3422,11 @@
3423
3422
  */
3424
3423
  function executeAttempts(options) {
3425
3424
  return __awaiter(this, void 0, void 0, function () {
3426
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, settings, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3425
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3427
3426
  return __generator(this, function (_a) {
3428
3427
  switch (_a.label) {
3429
3428
  case 0:
3430
- 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;
3431
- maxExecutionAttempts = settings.maxExecutionAttempts;
3429
+ 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;
3432
3430
  $ongoingTemplateResult = {
3433
3431
  $result: null,
3434
3432
  $resultString: null,
@@ -3794,12 +3792,12 @@
3794
3792
  */
3795
3793
  function executeFormatSubvalues(options) {
3796
3794
  return __awaiter(this, void 0, void 0, function () {
3797
- var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3795
+ var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3798
3796
  var _this = this;
3799
3797
  return __generator(this, function (_a) {
3800
3798
  switch (_a.label) {
3801
3799
  case 0:
3802
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
3800
+ template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3803
3801
  if (template.foreach === undefined) {
3804
3802
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3805
3803
  }
@@ -3829,7 +3827,7 @@
3829
3827
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3830
3828
  }
3831
3829
  if (formatDefinition.formatName === 'CSV') {
3832
- formatSettings = settings.csvSettings;
3830
+ formatSettings = csvSettings;
3833
3831
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
3834
3832
  }
3835
3833
  return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
@@ -3982,13 +3980,12 @@
3982
3980
  */
3983
3981
  function executeTemplate(options) {
3984
3982
  return __awaiter(this, void 0, void 0, function () {
3985
- 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;
3986
- var e_1, _f, _g;
3987
- return __generator(this, function (_h) {
3988
- switch (_h.label) {
3983
+ 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;
3984
+ var e_1, _g, _h;
3985
+ return __generator(this, function (_j) {
3986
+ switch (_j.label) {
3989
3987
  case 0:
3990
- currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, settings = options.settings, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification;
3991
- maxExecutionAttempts = settings.maxExecutionAttempts;
3988
+ 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;
3992
3989
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3993
3990
  title = currentTemplate.title;
3994
3991
  priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
@@ -4003,7 +4000,7 @@
4003
4000
  // <- [🍸]
4004
4001
  })];
4005
4002
  case 1:
4006
- _h.sent();
4003
+ _j.sent();
4007
4004
  usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4008
4005
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4009
4006
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
@@ -4014,15 +4011,15 @@
4014
4011
  .map(function (name) { return "{".concat(name, "}"); })
4015
4012
  .join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4016
4013
  }
4017
- _b = (_a = Object).freeze;
4018
- _c = [{}];
4014
+ _c = (_b = Object).freeze;
4015
+ _d = [{}];
4019
4016
  return [4 /*yield*/, getReservedParametersForTemplate({
4020
4017
  preparedPipeline: preparedPipeline,
4021
4018
  template: currentTemplate,
4022
4019
  pipelineIdentification: pipelineIdentification,
4023
4020
  })];
4024
4021
  case 2:
4025
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
4022
+ definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
4026
4023
  definedParameterNames = new Set(Object.keys(definedParameters));
4027
4024
  parameters = {};
4028
4025
  _loop_1 = function (parameterName) {
@@ -4042,15 +4039,15 @@
4042
4039
  try {
4043
4040
  // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4044
4041
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4045
- for (_d = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _e = _d.next(); !_e.done; _e = _d.next()) {
4046
- parameterName = _e.value;
4042
+ for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4043
+ parameterName = _f.value;
4047
4044
  _loop_1(parameterName);
4048
4045
  }
4049
4046
  }
4050
4047
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
4051
4048
  finally {
4052
4049
  try {
4053
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
4050
+ if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
4054
4051
  }
4055
4052
  finally { if (e_1) throw e_1.error; }
4056
4053
  }
@@ -4070,12 +4067,11 @@
4070
4067
  template: currentTemplate,
4071
4068
  preparedPipeline: preparedPipeline,
4072
4069
  tools: tools,
4073
- settings: settings,
4074
4070
  $executionReport: $executionReport,
4075
4071
  pipelineIdentification: pipelineIdentification,
4076
4072
  })];
4077
4073
  case 3:
4078
- resultString = _h.sent();
4074
+ resultString = _j.sent();
4079
4075
  return [4 /*yield*/, onProgress({
4080
4076
  name: name,
4081
4077
  title: title,
@@ -4087,12 +4083,12 @@
4087
4083
  // <- [🍸]
4088
4084
  })];
4089
4085
  case 4:
4090
- _h.sent();
4091
- return [2 /*return*/, Object.freeze((_g = {},
4092
- _g[currentTemplate.resultingParameterName] =
4086
+ _j.sent();
4087
+ return [2 /*return*/, Object.freeze((_h = {},
4088
+ _h[currentTemplate.resultingParameterName] =
4093
4089
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4094
4090
  resultString,
4095
- _g))];
4091
+ _h))];
4096
4092
  }
4097
4093
  });
4098
4094
  });
@@ -4151,13 +4147,12 @@
4151
4147
  */
4152
4148
  function executePipeline(options) {
4153
4149
  return __awaiter(this, void 0, void 0, function () {
4154
- 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;
4150
+ 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;
4155
4151
  var e_1, _f, e_2, _g;
4156
4152
  return __generator(this, function (_h) {
4157
4153
  switch (_h.label) {
4158
4154
  case 0:
4159
- inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
4160
- maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4155
+ 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;
4161
4156
  preparedPipeline = options.preparedPipeline;
4162
4157
  if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
4163
4158
  return [4 /*yield*/, preparePipeline(pipeline, tools, {
@@ -4342,12 +4337,7 @@
4342
4337
  return [3 /*break*/, 4];
4343
4338
  case 3:
4344
4339
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4345
- work_1 = executeTemplate({
4346
- currentTemplate: currentTemplate,
4347
- preparedPipeline: preparedPipeline,
4348
- parametersToPass: parametersToPass,
4349
- tools: tools,
4350
- onProgress: function (progress) {
4340
+ work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4351
4341
  if (isReturned) {
4352
4342
  throw new UnexpectedError(spaceTrim.spaceTrim(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)
4353
4343
  .split('\n')
@@ -4357,11 +4347,7 @@
4357
4347
  if (onProgress) {
4358
4348
  onProgress(progress);
4359
4349
  }
4360
- },
4361
- settings: settings,
4362
- $executionReport: executionReport,
4363
- pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
4364
- })
4350
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
4365
4351
  .then(function (newParametersToPass) {
4366
4352
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4367
4353
  resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
@@ -4465,8 +4451,7 @@
4465
4451
  */
4466
4452
  function createPipelineExecutor(options) {
4467
4453
  var _this = this;
4468
- var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
4469
- 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;
4454
+ 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;
4470
4455
  validatePipeline(pipeline);
4471
4456
  var pipelineIdentification = (function () {
4472
4457
  // Note: This is a 😐 implementation of [🚞]
@@ -4500,14 +4485,12 @@
4500
4485
  tools: tools,
4501
4486
  onProgress: onProgress,
4502
4487
  pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
4503
- settings: {
4504
- maxExecutionAttempts: maxExecutionAttempts,
4505
- maxParallelCount: maxParallelCount,
4506
- csvSettings: csvSettings,
4507
- isVerbose: isVerbose,
4508
- isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4509
- rootDirname: rootDirname,
4510
- },
4488
+ maxExecutionAttempts: maxExecutionAttempts,
4489
+ maxParallelCount: maxParallelCount,
4490
+ csvSettings: csvSettings,
4491
+ isVerbose: isVerbose,
4492
+ isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4493
+ rootDirname: rootDirname,
4511
4494
  })];
4512
4495
  });
4513
4496
  }); };
@@ -4530,7 +4513,7 @@
4530
4513
  return __generator(this, function (_d) {
4531
4514
  switch (_d.label) {
4532
4515
  case 0:
4533
- _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4516
+ _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4534
4517
  if (tools === undefined || tools.llm === undefined) {
4535
4518
  throw new MissingToolsError('LLM tools are required for preparing persona');
4536
4519
  }
@@ -4712,7 +4695,7 @@
4712
4695
  this.storage = globalScope[storageName];
4713
4696
  }
4714
4697
  $Register.prototype.list = function () {
4715
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
4698
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
4716
4699
  return this.storage;
4717
4700
  };
4718
4701
  $Register.prototype.register = function (registered) {
@@ -4764,7 +4747,7 @@
4764
4747
  * TODO: [®] DRY Register logic
4765
4748
  */
4766
4749
 
4767
- // TODO: !!!!!! Maybe delete this function
4750
+ // TODO: !!!!!!last - Maybe delete this function
4768
4751
  /**
4769
4752
  * Creates a message with all registered scrapers
4770
4753
  *
@@ -4931,7 +4914,6 @@
4931
4914
  * @private within the repository
4932
4915
  */
4933
4916
  function sourceContentToName(sourceContent) {
4934
- // TODO: !!!!!! Better name for source than gibberish hash
4935
4917
  var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
4936
4918
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
4937
4919
  .toString( /* hex */)
@@ -5031,7 +5013,7 @@
5031
5013
  /**
5032
5014
  * @@@
5033
5015
  *
5034
- * @private for scraper utilities
5016
+ * @public exported from `@promptbook/core`
5035
5017
  */
5036
5018
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5037
5019
  var _a;
@@ -5044,7 +5026,7 @@
5044
5026
  case 0:
5045
5027
  sourceContent = knowledgeSource.sourceContent;
5046
5028
  name = knowledgeSource.name;
5047
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? IS_VERBOSE : _d;
5029
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
5048
5030
  TODO_USE(isVerbose);
5049
5031
  if (!name) {
5050
5032
  name = sourceContentToName(sourceContent);
@@ -5134,7 +5116,7 @@
5134
5116
  content = _a.sent();
5135
5117
  return [2 /*return*/, new Blob([
5136
5118
  content,
5137
- // <- TODO: !!!!!! Maybe not working
5119
+ // <- TODO: !!!!!! Test that this is working
5138
5120
  ], { type: mimeType_1 })];
5139
5121
  }
5140
5122
  });
@@ -5197,7 +5179,7 @@
5197
5179
  return __generator(this, function (_c) {
5198
5180
  switch (_c.label) {
5199
5181
  case 0:
5200
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5182
+ _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;
5201
5183
  knowledgePreparedUnflatten = new Array(knowledgeSources.length);
5202
5184
  return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
5203
5185
  var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
@@ -5226,7 +5208,8 @@
5226
5208
  case 4:
5227
5209
  partialPiecesUnchecked = _d.sent();
5228
5210
  if (partialPiecesUnchecked !== null) {
5229
- partialPieces = partialPiecesUnchecked;
5211
+ partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5212
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5230
5213
  return [3 /*break*/, 6];
5231
5214
  }
5232
5215
  _d.label = 5;
@@ -5274,7 +5257,7 @@
5274
5257
  > /**
5275
5258
  > * Unprepared knowledge
5276
5259
  > * /
5277
- > readonly knowledgeSources: Array<KnowledgeSourceJson>;
5260
+ > readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
5278
5261
  > };
5279
5262
  >
5280
5263
  > export async function prepareKnowledgePieces(
@@ -5332,7 +5315,7 @@
5332
5315
  return __generator(this, function (_b) {
5333
5316
  switch (_b.label) {
5334
5317
  case 0:
5335
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
5318
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5336
5319
  templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5337
5320
  // TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
5338
5321
  TODO_USE(parameters);
@@ -5394,7 +5377,7 @@
5394
5377
  if (isPipelinePrepared(pipeline)) {
5395
5378
  return [2 /*return*/, pipeline];
5396
5379
  }
5397
- rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5380
+ 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;
5398
5381
  parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5399
5382
  if (tools === undefined || tools.llm === undefined) {
5400
5383
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
@@ -5452,7 +5435,9 @@
5452
5435
  // ----- /Templates preparation -----
5453
5436
  // Note: Count total usage
5454
5437
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5455
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: templatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations }))];
5438
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5439
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5440
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5456
5441
  }
5457
5442
  });
5458
5443
  });
@@ -8385,7 +8370,7 @@
8385
8370
  */
8386
8371
  function createLlmToolsFromConfiguration(configuration, options) {
8387
8372
  if (options === void 0) { options = {}; }
8388
- var _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8373
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
8389
8374
  var llmTools = configuration.map(function (llmConfiguration) {
8390
8375
  var registeredItem = $llmToolsRegister
8391
8376
  .list()
@@ -8446,6 +8431,34 @@
8446
8431
  * TODO: [®] DRY Register logic
8447
8432
  */
8448
8433
 
8434
+ /**
8435
+ * @@@
8436
+ *
8437
+ * @public exported from `@promptbook/node`
8438
+ */
8439
+ function $provideExecutablesForNode(options) {
8440
+ return __awaiter(this, void 0, void 0, function () {
8441
+ var _a, _b, isAutoInstalled, _c, isVerbose;
8442
+ return __generator(this, function (_d) {
8443
+ if (!$isRunningInNode()) {
8444
+ throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8445
+ }
8446
+ _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
8447
+ TODO_USE(isAutoInstalled);
8448
+ TODO_USE(isVerbose);
8449
+ return [2 /*return*/, {
8450
+ // TODO: !!!!!! use `locate-app` library here
8451
+ pandocPath: 'C:/Users/me/AppData/Local/Pandoc/pandoc.exe',
8452
+ libreOfficePath: 'C:/Program Files/LibreOffice/program/swriter.exe',
8453
+ }];
8454
+ });
8455
+ });
8456
+ }
8457
+ /**
8458
+ * TODO: [🧠] THis should be maybe in different folder
8459
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8460
+ */
8461
+
8449
8462
  /**
8450
8463
  * @@@
8451
8464
  *
@@ -8455,7 +8468,7 @@
8455
8468
  if (!$isRunningInNode()) {
8456
8469
  throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
8457
8470
  }
8458
- var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8471
+ var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
8459
8472
  TODO_USE(isVerbose);
8460
8473
  return {
8461
8474
  stat: promises.stat,
@@ -8470,7 +8483,7 @@
8470
8483
  */
8471
8484
 
8472
8485
  /**
8473
- * !!!!!!
8486
+ * @@@
8474
8487
  *
8475
8488
  * 1) @@@
8476
8489
  * 2) @@@
@@ -8487,7 +8500,7 @@
8487
8500
  if (!$isRunningInNode()) {
8488
8501
  throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8489
8502
  }
8490
- _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? IS_VERBOSE : _c;
8503
+ _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? DEFAULT_IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c;
8491
8504
  TODO_USE(isAutoInstalled);
8492
8505
  TODO_USE(isVerbose);
8493
8506
  scrapers = [];
@@ -8981,7 +8994,7 @@
8981
8994
  */
8982
8995
  function $provideExecutionToolsForNode(options) {
8983
8996
  return __awaiter(this, void 0, void 0, function () {
8984
- var fs, llm, tools;
8997
+ var fs, llm, executables, tools;
8985
8998
  var _a;
8986
8999
  return __generator(this, function (_b) {
8987
9000
  switch (_b.label) {
@@ -8991,12 +9004,16 @@
8991
9004
  }
8992
9005
  fs = $provideFilesystemForNode();
8993
9006
  llm = $provideLlmToolsFromEnv(options);
9007
+ return [4 /*yield*/, $provideExecutablesForNode(options)];
9008
+ case 1:
9009
+ executables = _b.sent();
8994
9010
  _a = {
8995
9011
  llm: llm,
8996
- fs: fs
9012
+ fs: fs,
9013
+ executables: executables
8997
9014
  };
8998
- return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm }, options)];
8999
- case 1:
9015
+ return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, options)];
9016
+ case 2:
9000
9017
  tools = (_a.scrapers = _b.sent(),
9001
9018
  _a.script = [new JavascriptExecutionTools(options)],
9002
9019
  _a);
@@ -9234,7 +9251,9 @@
9234
9251
  throw new EnvironmentMismatchError('Can not create collection without filesystem tools');
9235
9252
  // <- TODO: [🧠] What is the best error type here`
9236
9253
  }
9237
- makedLibraryFilePath = path.join(path$1, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
9254
+ makedLibraryFilePath = path.join(path$1, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
9255
+ // <- TODO: [🦒] Allow to override (pass different value into the function)
9256
+ , ".json"));
9238
9257
  return [4 /*yield*/, isFileExisting(makedLibraryFilePath, tools.fs)];
9239
9258
  case 3:
9240
9259
  if (!(_f.sent())) {
@@ -9245,7 +9264,7 @@
9245
9264
  // TODO: !! Implement;
9246
9265
  // TODO: [🌗]
9247
9266
  }
9248
- _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? IS_VERBOSE : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashedOnError, isCrashedOnError = _e === void 0 ? true : _e;
9267
+ _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? DEFAULT_IS_VERBOSE : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashedOnError, isCrashedOnError = _e === void 0 ? true : _e;
9249
9268
  collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
9250
9269
  var fileNames, collection, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
9251
9270
  var e_1, _a;
@@ -9777,6 +9796,7 @@
9777
9796
 
9778
9797
  exports.$execCommand = $execCommand;
9779
9798
  exports.$execCommands = $execCommands;
9799
+ exports.$provideExecutablesForNode = $provideExecutablesForNode;
9780
9800
  exports.$provideExecutionToolsForNode = $provideExecutionToolsForNode;
9781
9801
  exports.$provideFilesystemForNode = $provideFilesystemForNode;
9782
9802
  exports.$provideLlmToolsConfigurationFromEnv = $provideLlmToolsConfigurationFromEnv;