@promptbook/node 0.71.0-18 → 0.71.0-20

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 (88) hide show
  1. package/README.md +0 -6
  2. package/esm/index.es.js +66 -77
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +22 -18
  5. package/esm/typings/src/_packages/types.index.d.ts +2 -2
  6. package/esm/typings/src/collection/PipelineCollection.d.ts +1 -1
  7. package/esm/typings/src/collection/SimplePipelineCollection.d.ts +2 -2
  8. package/esm/typings/src/collection/collectionToJson.d.ts +1 -1
  9. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +1 -1
  10. package/esm/typings/src/collection/constructors/createCollectionFromPromise.d.ts +1 -1
  11. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +5 -5
  12. package/esm/typings/src/config.d.ts +21 -14
  13. package/esm/typings/src/execution/EmbeddingVector.d.ts +1 -1
  14. package/esm/typings/src/execution/LlmExecutionTools.d.ts +1 -1
  15. package/esm/typings/src/execution/PipelineExecutorResult.d.ts +2 -2
  16. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -0
  17. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorOptions.d.ts +29 -6
  18. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +2 -11
  19. package/esm/typings/src/execution/createPipelineExecutor/20-executeTemplate.d.ts +4 -13
  20. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +9 -14
  21. package/esm/typings/src/execution/utils/addUsage.d.ts +1 -1
  22. package/esm/typings/src/execution/utils/forEachAsync.d.ts +1 -1
  23. package/esm/typings/src/formats/_common/FormatDefinition.d.ts +2 -2
  24. package/esm/typings/src/formats/_common/FormatSubvalueDefinition.d.ts +2 -2
  25. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForCli.d.ts +2 -2
  26. package/esm/typings/src/llm-providers/_common/register/LlmToolsConfiguration.d.ts +1 -1
  27. package/esm/typings/src/llm-providers/_common/utils/cache/CacheLlmToolsOptions.d.ts +4 -1
  28. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +1 -1
  29. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  30. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/llm-providers/mocked/$fakeTextToExpectations.d.ts +1 -1
  32. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +1 -1
  33. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +1 -1
  34. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -3
  35. package/esm/typings/src/llm-providers/multiple/joinLlmExecutionTools.d.ts +1 -1
  36. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +1 -1
  37. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  38. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +1 -1
  39. package/esm/typings/src/llm-providers/remote/interfaces/PromptbookServer_ListModels_Response.d.ts +1 -1
  40. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +4 -4
  41. package/esm/typings/src/prepare/prepareTemplates.d.ts +1 -1
  42. package/esm/typings/src/scrapers/_common/Scraper.d.ts +1 -5
  43. package/esm/typings/src/scrapers/_common/prepareKnowledgePieces.d.ts +1 -1
  44. package/esm/typings/src/scrapers/_common/register/$provideScrapersForBrowser.d.ts +1 -1
  45. package/esm/typings/src/scrapers/_common/register/$provideScrapersForNode.d.ts +1 -1
  46. package/esm/typings/src/scrapers/_common/register/ScraperAndConverterMetadata.d.ts +2 -2
  47. package/esm/typings/src/scrapers/_common/utils/getScraperIntermediateSource.d.ts +2 -2
  48. package/esm/typings/src/scrapers/_common/utils/makeKnowledgeSourceHandler.d.ts +1 -1
  49. package/esm/typings/src/scrapers/document/DocumentScraper.d.ts +1 -1
  50. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -1
  51. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -1
  52. package/esm/typings/src/scrapers/document-legacy/LegacyDocumentScraper.d.ts +1 -1
  53. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -1
  54. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -1
  55. package/esm/typings/src/scrapers/markdown/MarkdownScraper.d.ts +1 -1
  56. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -1
  57. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -1
  58. package/esm/typings/src/scrapers/pdf/PdfScraper.d.ts +1 -1
  59. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -1
  60. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -1
  61. package/esm/typings/src/scrapers/website/WebsiteScraper.d.ts +1 -1
  62. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -1
  63. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -1
  64. package/esm/typings/src/scripting/javascript/utils/preserve.d.ts +1 -1
  65. package/esm/typings/src/storage/file-cache-storage/utils/nameToSubfolderPath.d.ts +1 -1
  66. package/esm/typings/src/types/Arrayable.d.ts +1 -1
  67. package/esm/typings/src/types/IntermediateFilesStrategy.d.ts +7 -0
  68. package/esm/typings/src/types/PipelineJson/KnowledgePieceJson.d.ts +4 -4
  69. package/esm/typings/src/types/PipelineJson/KnowledgeSourceJson.d.ts +1 -1
  70. package/esm/typings/src/types/PipelineJson/PersonaJson.d.ts +1 -1
  71. package/esm/typings/src/types/Prompt.d.ts +1 -1
  72. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +1 -1
  73. package/esm/typings/src/utils/$Register.d.ts +1 -1
  74. package/esm/typings/src/utils/FromtoItems.d.ts +1 -1
  75. package/esm/typings/src/utils/arrayableToArray.d.ts +1 -1
  76. package/esm/typings/src/utils/emojis.d.ts +1 -1
  77. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  78. package/esm/typings/src/utils/markdown/extractAllBlocksFromMarkdown.d.ts +1 -1
  79. package/esm/typings/src/utils/markdown/splitMarkdownIntoSections.d.ts +1 -1
  80. package/esm/typings/src/utils/organization/TODO_USE.d.ts +1 -1
  81. package/esm/typings/src/utils/organization/keepUnused.d.ts +1 -1
  82. package/esm/typings/src/utils/random/$randomSeed.d.ts +1 -1
  83. package/esm/typings/src/utils/sets/intersection.d.ts +1 -1
  84. package/esm/typings/src/utils/sets/union.d.ts +1 -1
  85. package/package.json +2 -2
  86. package/umd/index.umd.js +66 -77
  87. package/umd/index.umd.js.map +1 -1
  88. package/esm/typings/src/execution/createPipelineExecutor/00-CreatePipelineExecutorSettings.d.ts +0 -29
package/README.md CHANGED
@@ -20,12 +20,6 @@ Build responsible, controlled and transparent applications on top of LLM models!
20
20
 
21
21
  - ✨ **Support of [OpenAI o1 model](https://openai.com/o1/)**
22
22
 
23
- <blockquote style="color: #ff8811">
24
- <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
25
- </blockquote>
26
-
27
-
28
-
29
23
  <blockquote style="color: #ff8811">
30
24
  <b>⚠ Warning:</b> This is a pre-release version of the library. It is not yet ready for production use. Please look at <a href="https://www.npmjs.com/package/@promptbook/core?activeTab=versions">latest stable release</a>.
31
25
  </blockquote>
package/esm/index.es.js CHANGED
@@ -17,7 +17,7 @@ import { spawn } from 'child_process';
17
17
  /**
18
18
  * The version of the Promptbook library
19
19
  */
20
- var PROMPTBOOK_VERSION = '0.71.0-17';
20
+ var PROMPTBOOK_VERSION = '0.71.0-19';
21
21
  // TODO: [main] !!!! List here all the versions and annotate + put into script
22
22
 
23
23
  /*! *****************************************************************************
@@ -366,29 +366,30 @@ var LOOP_LIMIT = 1000;
366
366
  */
367
367
  var IMMEDIATE_TIME = 10;
368
368
  /**
369
- * The maximum number of (LLM) tasks running in parallel
369
+ * The maximum length of the (generated) filename
370
370
  *
371
371
  * @public exported from `@promptbook/core`
372
372
  */
373
- var MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
373
+ var MAX_FILENAME_LENGTH = 30;
374
+ // <- TODO: [😡] Change to 'VISIBLE'
374
375
  /**
375
- * The maximum number of attempts to execute LLM task before giving up
376
+ * The maximum number of (LLM) tasks running in parallel
376
377
  *
377
378
  * @public exported from `@promptbook/core`
378
379
  */
379
- var MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
380
+ var DEFAULT_MAX_PARALLEL_COUNT = 5; // <- TODO: [🤹‍♂️]
380
381
  /**
381
- * The maximum length of the (generated) filename
382
+ * The maximum number of attempts to execute LLM task before giving up
382
383
  *
383
384
  * @public exported from `@promptbook/core`
384
385
  */
385
- var MAX_FILENAME_LENGTH = 30;
386
+ var DEFAULT_MAX_EXECUTION_ATTEMPTS = 3; // <- TODO: [🤹‍♂️]
386
387
  /**
387
388
  * The name of the builded pipeline collection made by CLI `ptbk make` and for lookup in `createCollectionFromDirectory`
388
389
  *
389
390
  * @public exported from `@promptbook/core`
390
391
  */
391
- var PIPELINE_COLLECTION_BASE_FILENAME = "index";
392
+ var DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME = "index";
392
393
  /**
393
394
  * Nonce which is used for replacing things in strings
394
395
  *
@@ -440,13 +441,13 @@ var DEFAULT_CSV_SETTINGS = Object.freeze({
440
441
  *
441
442
  * @public exported from `@promptbook/core`
442
443
  */
443
- var IS_VERBOSE = false;
444
+ var DEFAULT_IS_VERBOSE = false;
444
445
  /**
445
446
  * @@@
446
447
  *
447
448
  * @public exported from `@promptbook/core`
448
449
  */
449
- var IS_AUTO_INSTALLED = false;
450
+ var DEFAULT_IS_AUTO_INSTALLED = false;
450
451
  /**
451
452
  * @@@
452
453
  *
@@ -518,7 +519,6 @@ function pipelineJsonToString(pipelineJson) {
518
519
  pipelineString += '\n\n';
519
520
  pipelineString += description;
520
521
  }
521
- // TODO:> const commands: Array<Command>
522
522
  var commands = [];
523
523
  if (pipelineUrl) {
524
524
  commands.push("PIPELINE URL ".concat(pipelineUrl));
@@ -574,7 +574,6 @@ function pipelineJsonToString(pipelineJson) {
574
574
  pipelineString += '\n\n';
575
575
  pipelineString += description_1;
576
576
  }
577
- // TODO:> const commands: Array<Command>
578
577
  var commands_1 = [];
579
578
  var contentLanguage = 'text';
580
579
  if (templateType === 'PROMPT_TEMPLATE') {
@@ -2098,6 +2097,7 @@ function assertsExecutionSuccessful(executionResult) {
2098
2097
  }
2099
2098
  }
2100
2099
  /**
2100
+ * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
2101
2101
  * TODO: [🧠] Can this return type be better typed than void
2102
2102
  */
2103
2103
 
@@ -3404,12 +3404,11 @@ function checkExpectations(expectations, value) {
3404
3404
  */
3405
3405
  function executeAttempts(options) {
3406
3406
  return __awaiter(this, void 0, void 0, function () {
3407
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, settings, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3407
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3408
3408
  return __generator(this, function (_a) {
3409
3409
  switch (_a.label) {
3410
3410
  case 0:
3411
- 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;
3412
- maxExecutionAttempts = settings.maxExecutionAttempts;
3411
+ 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;
3413
3412
  $ongoingTemplateResult = {
3414
3413
  $result: null,
3415
3414
  $resultString: null,
@@ -3775,12 +3774,12 @@ function executeAttempts(options) {
3775
3774
  */
3776
3775
  function executeFormatSubvalues(options) {
3777
3776
  return __awaiter(this, void 0, void 0, function () {
3778
- var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3777
+ var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3779
3778
  var _this = this;
3780
3779
  return __generator(this, function (_a) {
3781
3780
  switch (_a.label) {
3782
3781
  case 0:
3783
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
3782
+ template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3784
3783
  if (template.foreach === undefined) {
3785
3784
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3786
3785
  }
@@ -3810,7 +3809,7 @@ function executeFormatSubvalues(options) {
3810
3809
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3811
3810
  }
3812
3811
  if (formatDefinition.formatName === 'CSV') {
3813
- formatSettings = settings.csvSettings;
3812
+ formatSettings = csvSettings;
3814
3813
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
3815
3814
  }
3816
3815
  return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
@@ -3963,13 +3962,12 @@ function getReservedParametersForTemplate(options) {
3963
3962
  */
3964
3963
  function executeTemplate(options) {
3965
3964
  return __awaiter(this, void 0, void 0, function () {
3966
- 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;
3967
- var e_1, _f, _g;
3968
- return __generator(this, function (_h) {
3969
- switch (_h.label) {
3965
+ 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;
3966
+ var e_1, _g, _h;
3967
+ return __generator(this, function (_j) {
3968
+ switch (_j.label) {
3970
3969
  case 0:
3971
- currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, settings = options.settings, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification;
3972
- maxExecutionAttempts = settings.maxExecutionAttempts;
3970
+ 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;
3973
3971
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
3974
3972
  title = currentTemplate.title;
3975
3973
  priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
@@ -3984,7 +3982,7 @@ function executeTemplate(options) {
3984
3982
  // <- [🍸]
3985
3983
  })];
3986
3984
  case 1:
3987
- _h.sent();
3985
+ _j.sent();
3988
3986
  usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
3989
3987
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
3990
3988
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
@@ -3995,15 +3993,15 @@ function executeTemplate(options) {
3995
3993
  .map(function (name) { return "{".concat(name, "}"); })
3996
3994
  .join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
3997
3995
  }
3998
- _b = (_a = Object).freeze;
3999
- _c = [{}];
3996
+ _c = (_b = Object).freeze;
3997
+ _d = [{}];
4000
3998
  return [4 /*yield*/, getReservedParametersForTemplate({
4001
3999
  preparedPipeline: preparedPipeline,
4002
4000
  template: currentTemplate,
4003
4001
  pipelineIdentification: pipelineIdentification,
4004
4002
  })];
4005
4003
  case 2:
4006
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
4004
+ definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
4007
4005
  definedParameterNames = new Set(Object.keys(definedParameters));
4008
4006
  parameters = {};
4009
4007
  _loop_1 = function (parameterName) {
@@ -4023,15 +4021,15 @@ function executeTemplate(options) {
4023
4021
  try {
4024
4022
  // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4025
4023
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4026
- for (_d = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _e = _d.next(); !_e.done; _e = _d.next()) {
4027
- parameterName = _e.value;
4024
+ for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4025
+ parameterName = _f.value;
4028
4026
  _loop_1(parameterName);
4029
4027
  }
4030
4028
  }
4031
4029
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
4032
4030
  finally {
4033
4031
  try {
4034
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
4032
+ if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
4035
4033
  }
4036
4034
  finally { if (e_1) throw e_1.error; }
4037
4035
  }
@@ -4051,12 +4049,11 @@ function executeTemplate(options) {
4051
4049
  template: currentTemplate,
4052
4050
  preparedPipeline: preparedPipeline,
4053
4051
  tools: tools,
4054
- settings: settings,
4055
4052
  $executionReport: $executionReport,
4056
4053
  pipelineIdentification: pipelineIdentification,
4057
4054
  })];
4058
4055
  case 3:
4059
- resultString = _h.sent();
4056
+ resultString = _j.sent();
4060
4057
  return [4 /*yield*/, onProgress({
4061
4058
  name: name,
4062
4059
  title: title,
@@ -4068,12 +4065,12 @@ function executeTemplate(options) {
4068
4065
  // <- [🍸]
4069
4066
  })];
4070
4067
  case 4:
4071
- _h.sent();
4072
- return [2 /*return*/, Object.freeze((_g = {},
4073
- _g[currentTemplate.resultingParameterName] =
4068
+ _j.sent();
4069
+ return [2 /*return*/, Object.freeze((_h = {},
4070
+ _h[currentTemplate.resultingParameterName] =
4074
4071
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4075
4072
  resultString,
4076
- _g))];
4073
+ _h))];
4077
4074
  }
4078
4075
  });
4079
4076
  });
@@ -4132,13 +4129,12 @@ function filterJustOutputParameters(options) {
4132
4129
  */
4133
4130
  function executePipeline(options) {
4134
4131
  return __awaiter(this, void 0, void 0, function () {
4135
- 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;
4132
+ 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;
4136
4133
  var e_1, _f, e_2, _g;
4137
4134
  return __generator(this, function (_h) {
4138
4135
  switch (_h.label) {
4139
4136
  case 0:
4140
- inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
4141
- maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4137
+ 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;
4142
4138
  preparedPipeline = options.preparedPipeline;
4143
4139
  if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
4144
4140
  return [4 /*yield*/, preparePipeline(pipeline, tools, {
@@ -4323,12 +4319,7 @@ function executePipeline(options) {
4323
4319
  return [3 /*break*/, 4];
4324
4320
  case 3:
4325
4321
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4326
- work_1 = executeTemplate({
4327
- currentTemplate: currentTemplate,
4328
- preparedPipeline: preparedPipeline,
4329
- parametersToPass: parametersToPass,
4330
- tools: tools,
4331
- onProgress: function (progress) {
4322
+ work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4332
4323
  if (isReturned) {
4333
4324
  throw new UnexpectedError(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)
4334
4325
  .split('\n')
@@ -4338,11 +4329,7 @@ function executePipeline(options) {
4338
4329
  if (onProgress) {
4339
4330
  onProgress(progress);
4340
4331
  }
4341
- },
4342
- settings: settings,
4343
- $executionReport: executionReport,
4344
- pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
4345
- })
4332
+ }, $executionReport: executionReport, pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }) }))
4346
4333
  .then(function (newParametersToPass) {
4347
4334
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4348
4335
  resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
@@ -4446,8 +4433,7 @@ function executePipeline(options) {
4446
4433
  */
4447
4434
  function createPipelineExecutor(options) {
4448
4435
  var _this = this;
4449
- var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
4450
- 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;
4436
+ 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;
4451
4437
  validatePipeline(pipeline);
4452
4438
  var pipelineIdentification = (function () {
4453
4439
  // Note: This is a 😐 implementation of [🚞]
@@ -4481,14 +4467,12 @@ function createPipelineExecutor(options) {
4481
4467
  tools: tools,
4482
4468
  onProgress: onProgress,
4483
4469
  pipelineIdentification: spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
4484
- settings: {
4485
- maxExecutionAttempts: maxExecutionAttempts,
4486
- maxParallelCount: maxParallelCount,
4487
- csvSettings: csvSettings,
4488
- isVerbose: isVerbose,
4489
- isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4490
- rootDirname: rootDirname,
4491
- },
4470
+ maxExecutionAttempts: maxExecutionAttempts,
4471
+ maxParallelCount: maxParallelCount,
4472
+ csvSettings: csvSettings,
4473
+ isVerbose: isVerbose,
4474
+ isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4475
+ rootDirname: rootDirname,
4492
4476
  })];
4493
4477
  });
4494
4478
  }); };
@@ -4511,7 +4495,7 @@ function preparePersona(personaDescription, tools, options) {
4511
4495
  return __generator(this, function (_d) {
4512
4496
  switch (_d.label) {
4513
4497
  case 0:
4514
- _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4498
+ _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4515
4499
  if (tools === undefined || tools.llm === undefined) {
4516
4500
  throw new MissingToolsError('LLM tools are required for preparing persona');
4517
4501
  }
@@ -4693,7 +4677,7 @@ var $Register = /** @class */ (function () {
4693
4677
  this.storage = globalScope[storageName];
4694
4678
  }
4695
4679
  $Register.prototype.list = function () {
4696
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
4680
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
4697
4681
  return this.storage;
4698
4682
  };
4699
4683
  $Register.prototype.register = function (registered) {
@@ -5011,7 +4995,7 @@ function isValidFilePath(filename) {
5011
4995
  /**
5012
4996
  * @@@
5013
4997
  *
5014
- * @private for scraper utilities
4998
+ * @public exported from `@promptbook/core`
5015
4999
  */
5016
5000
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5017
5001
  var _a;
@@ -5024,7 +5008,7 @@ function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5024
5008
  case 0:
5025
5009
  sourceContent = knowledgeSource.sourceContent;
5026
5010
  name = knowledgeSource.name;
5027
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? IS_VERBOSE : _d;
5011
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
5028
5012
  TODO_USE(isVerbose);
5029
5013
  if (!name) {
5030
5014
  name = sourceContentToName(sourceContent);
@@ -5177,7 +5161,7 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
5177
5161
  return __generator(this, function (_c) {
5178
5162
  switch (_c.label) {
5179
5163
  case 0:
5180
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5164
+ _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;
5181
5165
  knowledgePreparedUnflatten = new Array(knowledgeSources.length);
5182
5166
  return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
5183
5167
  var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
@@ -5206,7 +5190,8 @@ function prepareKnowledgePieces(knowledgeSources, tools, options) {
5206
5190
  case 4:
5207
5191
  partialPiecesUnchecked = _d.sent();
5208
5192
  if (partialPiecesUnchecked !== null) {
5209
- partialPieces = partialPiecesUnchecked;
5193
+ partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5194
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5210
5195
  return [3 /*break*/, 6];
5211
5196
  }
5212
5197
  _d.label = 5;
@@ -5254,7 +5239,7 @@ TODO: [🧊] This is how it can look in future
5254
5239
  > /**
5255
5240
  > * Unprepared knowledge
5256
5241
  > * /
5257
- > readonly knowledgeSources: Array<KnowledgeSourceJson>;
5242
+ > readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
5258
5243
  > };
5259
5244
  >
5260
5245
  > export async function prepareKnowledgePieces(
@@ -5312,7 +5297,7 @@ function prepareTemplates(pipeline, tools, options) {
5312
5297
  return __generator(this, function (_b) {
5313
5298
  switch (_b.label) {
5314
5299
  case 0:
5315
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
5300
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5316
5301
  templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5317
5302
  // TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
5318
5303
  TODO_USE(parameters);
@@ -5374,7 +5359,7 @@ function preparePipeline(pipeline, tools, options) {
5374
5359
  if (isPipelinePrepared(pipeline)) {
5375
5360
  return [2 /*return*/, pipeline];
5376
5361
  }
5377
- rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5362
+ 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;
5378
5363
  parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5379
5364
  if (tools === undefined || tools.llm === undefined) {
5380
5365
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
@@ -5432,7 +5417,9 @@ function preparePipeline(pipeline, tools, options) {
5432
5417
  // ----- /Templates preparation -----
5433
5418
  // Note: Count total usage
5434
5419
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5435
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: templatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations }))];
5420
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5421
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5422
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5436
5423
  }
5437
5424
  });
5438
5425
  });
@@ -8365,7 +8352,7 @@ function $registeredLlmToolsMessage() {
8365
8352
  */
8366
8353
  function createLlmToolsFromConfiguration(configuration, options) {
8367
8354
  if (options === void 0) { options = {}; }
8368
- var _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8355
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
8369
8356
  var llmTools = configuration.map(function (llmConfiguration) {
8370
8357
  var registeredItem = $llmToolsRegister
8371
8358
  .list()
@@ -8438,7 +8425,7 @@ function $provideExecutablesForNode(options) {
8438
8425
  if (!$isRunningInNode()) {
8439
8426
  throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8440
8427
  }
8441
- _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? IS_VERBOSE : _c;
8428
+ _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;
8442
8429
  TODO_USE(isAutoInstalled);
8443
8430
  TODO_USE(isVerbose);
8444
8431
  return [2 /*return*/, {
@@ -8463,7 +8450,7 @@ function $provideFilesystemForNode(options) {
8463
8450
  if (!$isRunningInNode()) {
8464
8451
  throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
8465
8452
  }
8466
- var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8453
+ var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
8467
8454
  TODO_USE(isVerbose);
8468
8455
  return {
8469
8456
  stat: stat,
@@ -8495,7 +8482,7 @@ function $provideScrapersForNode(tools, options) {
8495
8482
  if (!$isRunningInNode()) {
8496
8483
  throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8497
8484
  }
8498
- _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? IS_VERBOSE : _c;
8485
+ _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;
8499
8486
  TODO_USE(isAutoInstalled);
8500
8487
  TODO_USE(isVerbose);
8501
8488
  scrapers = [];
@@ -9246,7 +9233,9 @@ function createCollectionFromDirectory(path, tools, options) {
9246
9233
  throw new EnvironmentMismatchError('Can not create collection without filesystem tools');
9247
9234
  // <- TODO: [🧠] What is the best error type here`
9248
9235
  }
9249
- makedLibraryFilePath = join(path, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
9236
+ makedLibraryFilePath = join(path, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
9237
+ // <- TODO: [🦒] Allow to override (pass different value into the function)
9238
+ , ".json"));
9250
9239
  return [4 /*yield*/, isFileExisting(makedLibraryFilePath, tools.fs)];
9251
9240
  case 3:
9252
9241
  if (!(_f.sent())) {
@@ -9257,7 +9246,7 @@ function createCollectionFromDirectory(path, tools, options) {
9257
9246
  // TODO: !! Implement;
9258
9247
  // TODO: [🌗]
9259
9248
  }
9260
- _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;
9249
+ _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;
9261
9250
  collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
9262
9251
  var fileNames, collection, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
9263
9252
  var e_1, _a;