@promptbook/node 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 +466 -162
  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 +4 -3
  126. package/umd/index.umd.js +467 -163
  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/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex'), require('mime-types'), require('dotenv'), require('crypto-js/sha256'), require('child_process')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'papaparse', 'crypto-js', 'crypto-js/enc-hex', 'mime-types', 'dotenv', 'crypto-js/sha256', 'child_process'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.papaparse, global.cryptoJs, global.hexEncoder, global.mimeTypes, global.dotenv, global.sha256, global.child_process));
5
- })(this, (function (exports, colors, promises, path, spaceTrim, prettier, parserHtml, waitasecond, papaparse, cryptoJs, hexEncoder, mimeTypes, dotenv, sha256, child_process) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('fs/promises'), require('path'), require('spacetrim'), require('prettier'), require('prettier/parser-html'), require('waitasecond'), require('papaparse'), require('crypto-js'), require('crypto-js/enc-hex'), require('mime-types'), require('child_process'), require('util'), require('dotenv'), require('crypto-js/sha256')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'colors', 'fs/promises', 'path', 'spacetrim', 'prettier', 'prettier/parser-html', 'waitasecond', 'papaparse', 'crypto-js', 'crypto-js/enc-hex', 'mime-types', 'child_process', 'util', 'dotenv', 'crypto-js/sha256'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-node"] = {}, global.colors, global.promises, global.path, global.spaceTrim, global.prettier, global.parserHtml, global.waitasecond, global.papaparse, global.cryptoJs, global.hexEncoder, global.mimeTypes, global.child_process, global.util, global.dotenv, global.sha256));
5
+ })(this, (function (exports, colors, promises, path, spaceTrim, prettier, parserHtml, waitasecond, papaparse, cryptoJs, hexEncoder, mimeTypes, child_process, util, dotenv, sha256) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -35,7 +35,7 @@
35
35
  /**
36
36
  * The version of the Promptbook library
37
37
  */
38
- var PROMPTBOOK_VERSION = '0.72.0-8';
38
+ var PROMPTBOOK_VERSION = '0.72.0-34';
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') {
@@ -891,8 +890,7 @@
891
890
  * Multiple LLM Execution Tools is a proxy server that uses multiple execution tools internally and exposes the executor interface externally.
892
891
  *
893
892
  * Note: Internal utility of `joinLlmExecutionTools` but exposed type
894
- * @public exported from `@promptbook/types`
895
- * TODO: !!!!!! Export as runtime class not just type
893
+ * @public exported from `@promptbook/core`
896
894
  */
897
895
  var MultipleLlmExecutionTools = /** @class */ (function () {
898
896
  /**
@@ -2144,6 +2142,7 @@
2144
2142
  }
2145
2143
  }
2146
2144
  /**
2145
+ * TODO: [🐚] This function should be removed OR changed OR be completely rewritten
2147
2146
  * TODO: [🧠] Can this return type be better typed than void
2148
2147
  */
2149
2148
 
@@ -3450,12 +3449,11 @@
3450
3449
  */
3451
3450
  function executeAttempts(options) {
3452
3451
  return __awaiter(this, void 0, void 0, function () {
3453
- var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, settings, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3452
+ var jokerParameterNames, priority, maxAttempts, preparedContent, parameters, template, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, $ongoingTemplateResult, _llms, llmTools, _loop_1, attempt, state_1;
3454
3453
  return __generator(this, function (_a) {
3455
3454
  switch (_a.label) {
3456
3455
  case 0:
3457
- 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;
3458
- maxExecutionAttempts = settings.maxExecutionAttempts;
3456
+ 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;
3459
3457
  $ongoingTemplateResult = {
3460
3458
  $result: null,
3461
3459
  $resultString: null,
@@ -3821,12 +3819,12 @@
3821
3819
  */
3822
3820
  function executeFormatSubvalues(options) {
3823
3821
  return __awaiter(this, void 0, void 0, function () {
3824
- var template, jokerParameterNames, parameters, priority, pipelineIdentification, settings, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3822
+ var template, jokerParameterNames, parameters, priority, csvSettings, pipelineIdentification, parameterValue, formatDefinition, subvalueDefinition, formatSettings, resultString;
3825
3823
  var _this = this;
3826
3824
  return __generator(this, function (_a) {
3827
3825
  switch (_a.label) {
3828
3826
  case 0:
3829
- template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
3827
+ template = options.template, jokerParameterNames = options.jokerParameterNames, parameters = options.parameters, priority = options.priority, csvSettings = options.csvSettings, pipelineIdentification = options.pipelineIdentification;
3830
3828
  if (template.foreach === undefined) {
3831
3829
  return [2 /*return*/, /* not await */ executeAttempts(options)];
3832
3830
  }
@@ -3856,7 +3854,7 @@
3856
3854
  .join('\n')), "\n\n [\u26F7] This should never happen because subformat name should be validated during parsing\n\n ").concat(block(pipelineIdentification), "\n "); }));
3857
3855
  }
3858
3856
  if (formatDefinition.formatName === 'CSV') {
3859
- formatSettings = settings.csvSettings;
3857
+ formatSettings = csvSettings;
3860
3858
  // <- TODO: [🤹‍♂️] More universal, make simmilar pattern for other formats for example \n vs \r\n in text
3861
3859
  }
3862
3860
  return [4 /*yield*/, subvalueDefinition.mapValues(parameterValue, template.foreach.outputSubparameterName, formatSettings, function (subparameters, index) { return __awaiter(_this, void 0, void 0, function () {
@@ -4009,13 +4007,12 @@
4009
4007
  */
4010
4008
  function executeTemplate(options) {
4011
4009
  return __awaiter(this, void 0, void 0, function () {
4012
- 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;
4013
- var e_1, _f, _g;
4014
- return __generator(this, function (_h) {
4015
- switch (_h.label) {
4010
+ 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;
4011
+ var e_1, _g, _h;
4012
+ return __generator(this, function (_j) {
4013
+ switch (_j.label) {
4016
4014
  case 0:
4017
- currentTemplate = options.currentTemplate, preparedPipeline = options.preparedPipeline, parametersToPass = options.parametersToPass, tools = options.tools, onProgress = options.onProgress, settings = options.settings, $executionReport = options.$executionReport, pipelineIdentification = options.pipelineIdentification;
4018
- maxExecutionAttempts = settings.maxExecutionAttempts;
4015
+ 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;
4019
4016
  name = "pipeline-executor-frame-".concat(currentTemplate.name);
4020
4017
  title = currentTemplate.title;
4021
4018
  priority = preparedPipeline.templates.length - preparedPipeline.templates.indexOf(currentTemplate);
@@ -4030,7 +4027,7 @@
4030
4027
  // <- [🍸]
4031
4028
  })];
4032
4029
  case 1:
4033
- _h.sent();
4030
+ _j.sent();
4034
4031
  usedParameterNames = extractParameterNamesFromTemplate(currentTemplate);
4035
4032
  dependentParameterNames = new Set(currentTemplate.dependentParameterNames);
4036
4033
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
@@ -4041,15 +4038,15 @@
4041
4038
  .map(function (name) { return "{".concat(name, "}"); })
4042
4039
  .join(', '), "\n\n ").concat(block(pipelineIdentification), "\n\n "); }));
4043
4040
  }
4044
- _b = (_a = Object).freeze;
4045
- _c = [{}];
4041
+ _c = (_b = Object).freeze;
4042
+ _d = [{}];
4046
4043
  return [4 /*yield*/, getReservedParametersForTemplate({
4047
4044
  preparedPipeline: preparedPipeline,
4048
4045
  template: currentTemplate,
4049
4046
  pipelineIdentification: pipelineIdentification,
4050
4047
  })];
4051
4048
  case 2:
4052
- definedParameters = _b.apply(_a, [__assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_h.sent())])), parametersToPass])]);
4049
+ definedParameters = _c.apply(_b, [__assign.apply(void 0, [__assign.apply(void 0, _d.concat([(_j.sent())])), parametersToPass])]);
4053
4050
  definedParameterNames = new Set(Object.keys(definedParameters));
4054
4051
  parameters = {};
4055
4052
  _loop_1 = function (parameterName) {
@@ -4069,15 +4066,15 @@
4069
4066
  try {
4070
4067
  // Note: [2] Check that all used parameters are defined and removing unused parameters for this template
4071
4068
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
4072
- for (_d = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _e = _d.next(); !_e.done; _e = _d.next()) {
4073
- parameterName = _e.value;
4069
+ for (_e = __values(Array.from(union(definedParameterNames, usedParameterNames, dependentParameterNames))), _f = _e.next(); !_f.done; _f = _e.next()) {
4070
+ parameterName = _f.value;
4074
4071
  _loop_1(parameterName);
4075
4072
  }
4076
4073
  }
4077
4074
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
4078
4075
  finally {
4079
4076
  try {
4080
- if (_e && !_e.done && (_f = _d.return)) _f.call(_d);
4077
+ if (_f && !_f.done && (_g = _e.return)) _g.call(_e);
4081
4078
  }
4082
4079
  finally { if (e_1) throw e_1.error; }
4083
4080
  }
@@ -4097,12 +4094,11 @@
4097
4094
  template: currentTemplate,
4098
4095
  preparedPipeline: preparedPipeline,
4099
4096
  tools: tools,
4100
- settings: settings,
4101
4097
  $executionReport: $executionReport,
4102
4098
  pipelineIdentification: pipelineIdentification,
4103
4099
  })];
4104
4100
  case 3:
4105
- resultString = _h.sent();
4101
+ resultString = _j.sent();
4106
4102
  return [4 /*yield*/, onProgress({
4107
4103
  name: name,
4108
4104
  title: title,
@@ -4114,12 +4110,12 @@
4114
4110
  // <- [🍸]
4115
4111
  })];
4116
4112
  case 4:
4117
- _h.sent();
4118
- return [2 /*return*/, Object.freeze((_g = {},
4119
- _g[currentTemplate.resultingParameterName] =
4113
+ _j.sent();
4114
+ return [2 /*return*/, Object.freeze((_h = {},
4115
+ _h[currentTemplate.resultingParameterName] =
4120
4116
  // <- Note: [👩‍👩‍👧] No need to detect parameter collision here because pipeline checks logic consistency during construction
4121
4117
  resultString,
4122
- _g))];
4118
+ _h))];
4123
4119
  }
4124
4120
  });
4125
4121
  });
@@ -4178,13 +4174,12 @@
4178
4174
  */
4179
4175
  function executePipeline(options) {
4180
4176
  return __awaiter(this, void 0, void 0, function () {
4181
- 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;
4177
+ 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;
4182
4178
  var e_1, _f, e_2, _g;
4183
4179
  return __generator(this, function (_h) {
4184
4180
  switch (_h.label) {
4185
4181
  case 0:
4186
- inputParameters = options.inputParameters, tools = options.tools, onProgress = options.onProgress, pipeline = options.pipeline, setPreparedPipeline = options.setPreparedPipeline, pipelineIdentification = options.pipelineIdentification, settings = options.settings;
4187
- maxParallelCount = settings.maxParallelCount, rootDirname = settings.rootDirname, _a = settings.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4182
+ 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;
4188
4183
  preparedPipeline = options.preparedPipeline;
4189
4184
  if (!(preparedPipeline === undefined)) return [3 /*break*/, 2];
4190
4185
  return [4 /*yield*/, preparePipeline(pipeline, tools, {
@@ -4369,12 +4364,7 @@
4369
4364
  return [3 /*break*/, 4];
4370
4365
  case 3:
4371
4366
  unresovedTemplates_1 = unresovedTemplates_1.filter(function (template) { return template !== currentTemplate; });
4372
- work_1 = executeTemplate({
4373
- currentTemplate: currentTemplate,
4374
- preparedPipeline: preparedPipeline,
4375
- parametersToPass: parametersToPass,
4376
- tools: tools,
4377
- onProgress: function (progress) {
4367
+ work_1 = executeTemplate(__assign(__assign({}, options), { currentTemplate: currentTemplate, preparedPipeline: preparedPipeline, parametersToPass: parametersToPass, tools: tools, onProgress: function (progress) {
4378
4368
  if (isReturned) {
4379
4369
  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)
4380
4370
  .split('\n')
@@ -4384,11 +4374,7 @@
4384
4374
  if (onProgress) {
4385
4375
  onProgress(progress);
4386
4376
  }
4387
- },
4388
- settings: settings,
4389
- $executionReport: executionReport,
4390
- pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n Template name: ").concat(currentTemplate.name, "\n Template title: ").concat(currentTemplate.title, "\n "); }),
4391
- })
4377
+ }, $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 "); }) }))
4392
4378
  .then(function (newParametersToPass) {
4393
4379
  parametersToPass = __assign(__assign({}, newParametersToPass), parametersToPass);
4394
4380
  resovedParameterNames_1 = __spreadArray(__spreadArray([], __read(resovedParameterNames_1), false), [currentTemplate.resultingParameterName], false);
@@ -4492,8 +4478,7 @@
4492
4478
  */
4493
4479
  function createPipelineExecutor(options) {
4494
4480
  var _this = this;
4495
- var pipeline = options.pipeline, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
4496
- 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;
4481
+ 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;
4497
4482
  validatePipeline(pipeline);
4498
4483
  var pipelineIdentification = (function () {
4499
4484
  // Note: This is a 😐 implementation of [🚞]
@@ -4527,14 +4512,12 @@
4527
4512
  tools: tools,
4528
4513
  onProgress: onProgress,
4529
4514
  pipelineIdentification: spaceTrim.spaceTrim(function (block) { return "\n ".concat(block(pipelineIdentification), "\n ").concat(runCount === 1 ? '' : "Run #".concat(runCount), "\n "); }),
4530
- settings: {
4531
- maxExecutionAttempts: maxExecutionAttempts,
4532
- maxParallelCount: maxParallelCount,
4533
- csvSettings: csvSettings,
4534
- isVerbose: isVerbose,
4535
- isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4536
- rootDirname: rootDirname,
4537
- },
4515
+ maxExecutionAttempts: maxExecutionAttempts,
4516
+ maxParallelCount: maxParallelCount,
4517
+ csvSettings: csvSettings,
4518
+ isVerbose: isVerbose,
4519
+ isNotPreparedWarningSupressed: isNotPreparedWarningSupressed,
4520
+ rootDirname: rootDirname,
4538
4521
  })];
4539
4522
  });
4540
4523
  }); };
@@ -4557,7 +4540,7 @@
4557
4540
  return __generator(this, function (_d) {
4558
4541
  switch (_d.label) {
4559
4542
  case 0:
4560
- _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
4543
+ _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
4561
4544
  if (tools === undefined || tools.llm === undefined) {
4562
4545
  throw new MissingToolsError('LLM tools are required for preparing persona');
4563
4546
  }
@@ -4739,7 +4722,7 @@
4739
4722
  this.storage = globalScope[storageName];
4740
4723
  }
4741
4724
  $Register.prototype.list = function () {
4742
- // <- TODO: ReadonlyDeep<Array<TRegistered>>
4725
+ // <- TODO: ReadonlyDeep<ReadonlyArray<TRegistered>>
4743
4726
  return this.storage;
4744
4727
  };
4745
4728
  $Register.prototype.register = function (registered) {
@@ -4791,7 +4774,6 @@
4791
4774
  * TODO: [®] DRY Register logic
4792
4775
  */
4793
4776
 
4794
- // TODO: !!!!!! Maybe delete this function
4795
4777
  /**
4796
4778
  * Creates a message with all registered scrapers
4797
4779
  *
@@ -4958,7 +4940,6 @@
4958
4940
  * @private within the repository
4959
4941
  */
4960
4942
  function sourceContentToName(sourceContent) {
4961
- // TODO: !!!!!! Better name for source than gibberish hash
4962
4943
  var hash = cryptoJs.SHA256(hexEncoder__default["default"].parse(JSON.stringify(sourceContent)))
4963
4944
  // <- TODO: [🥬] Encapsulate sha256 to some private utility function
4964
4945
  .toString( /* hex */)
@@ -5058,20 +5039,20 @@
5058
5039
  /**
5059
5040
  * @@@
5060
5041
  *
5061
- * @private for scraper utilities
5042
+ * @public exported from `@promptbook/core`
5062
5043
  */
5063
5044
  function makeKnowledgeSourceHandler(knowledgeSource, tools, options) {
5064
5045
  var _a;
5065
5046
  return __awaiter(this, void 0, void 0, function () {
5066
5047
  var sourceContent, name, _b, _c, rootDirname, _d,
5067
5048
  // <- TODO: process.cwd() if running in Node.js
5068
- isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType_1;
5049
+ isVerbose, url, response_1, mimeType, filename_1, fileExtension, mimeType;
5069
5050
  return __generator(this, function (_e) {
5070
5051
  switch (_e.label) {
5071
5052
  case 0:
5072
5053
  sourceContent = knowledgeSource.sourceContent;
5073
5054
  name = knowledgeSource.name;
5074
- _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? IS_VERBOSE : _d;
5055
+ _b = options || {}, _c = _b.rootDirname, rootDirname = _c === void 0 ? null : _c, _d = _b.isVerbose, isVerbose = _d === void 0 ? DEFAULT_IS_VERBOSE : _d;
5075
5056
  TODO_USE(isVerbose);
5076
5057
  if (!name) {
5077
5058
  name = sourceContentToName(sourceContent);
@@ -5087,19 +5068,14 @@
5087
5068
  filename: null,
5088
5069
  url: url,
5089
5070
  mimeType: mimeType,
5090
- asBlob: function () {
5091
- return __awaiter(this, void 0, void 0, function () {
5092
- var content;
5093
- return __generator(this, function (_a) {
5094
- switch (_a.label) {
5095
- case 0: return [4 /*yield*/, response_1.blob()];
5096
- case 1:
5097
- content = _a.sent();
5098
- return [2 /*return*/, content];
5099
- }
5100
- });
5101
- });
5102
- },
5071
+ /*
5072
+ TODO: [🥽]
5073
+ > async asBlob() {
5074
+ > // TODO: [👨🏻‍🤝‍👨🏻] This can be called multiple times BUT when called second time, response in already consumed
5075
+ > const content = await response.blob();
5076
+ > return content;
5077
+ > },
5078
+ */
5103
5079
  asJson: function () {
5104
5080
  return __awaiter(this, void 0, void 0, function () {
5105
5081
  var content;
@@ -5139,34 +5115,31 @@
5139
5115
  }
5140
5116
  filename_1 = path.join(rootDirname, sourceContent).split('\\').join('/');
5141
5117
  fileExtension = getFileExtension(filename_1);
5142
- mimeType_1 = extensionToMimeType(fileExtension || '');
5118
+ mimeType = extensionToMimeType(fileExtension || '');
5143
5119
  return [4 /*yield*/, isFileExisting(filename_1, tools.fs)];
5144
5120
  case 3:
5145
5121
  if (!(_e.sent())) {
5146
5122
  throw new NotFoundError(spaceTrim__default["default"](function (block) { return "\n Can not make source handler for file which does not exist:\n\n File:\n ".concat(block(filename_1), "\n "); }));
5147
5123
  }
5148
- // TODO: !!!!!! Test security file - file is scoped to the project (maybe do this in `filesystemTools`)
5124
+ // TODO: [🧠][😿] Test security file - file is scoped to the project (BUT maybe do this in `filesystemTools`)
5149
5125
  return [2 /*return*/, {
5150
5126
  source: name,
5151
5127
  filename: filename_1,
5152
5128
  url: null,
5153
- mimeType: mimeType_1,
5154
- asBlob: function () {
5155
- return __awaiter(this, void 0, void 0, function () {
5156
- var content;
5157
- return __generator(this, function (_a) {
5158
- switch (_a.label) {
5159
- case 0: return [4 /*yield*/, tools.fs.readFile(filename_1)];
5160
- case 1:
5161
- content = _a.sent();
5162
- return [2 /*return*/, new Blob([
5163
- content,
5164
- // <- TODO: !!!!!! Maybe not working
5165
- ], { type: mimeType_1 })];
5166
- }
5167
- });
5168
- });
5169
- },
5129
+ mimeType: mimeType,
5130
+ /*
5131
+ TODO: [🥽]
5132
+ > async asBlob() {
5133
+ > const content = await tools.fs!.readFile(filename);
5134
+ > return new Blob(
5135
+ > [
5136
+ > content,
5137
+ > // <- TODO: [🥽] This is NOT tested, test it
5138
+ > ],
5139
+ > { type: mimeType },
5140
+ > );
5141
+ > },
5142
+ */
5170
5143
  asJson: function () {
5171
5144
  return __awaiter(this, void 0, void 0, function () {
5172
5145
  var _a, _b;
@@ -5202,9 +5175,14 @@
5202
5175
  asJson: function () {
5203
5176
  throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asJson`');
5204
5177
  },
5205
- asBlob: function () {
5206
- throw new UnexpectedError('Did not expect that `markdownScraper` would need to get the content `asBlob`');
5207
- },
5178
+ /*
5179
+ TODO: [🥽]
5180
+ > asBlob() {
5181
+ > throw new UnexpectedError(
5182
+ > 'Did not expect that `markdownScraper` would need to get the content `asBlob`',
5183
+ > );
5184
+ > },
5185
+ */
5208
5186
  }];
5209
5187
  }
5210
5188
  });
@@ -5224,7 +5202,7 @@
5224
5202
  return __generator(this, function (_c) {
5225
5203
  switch (_c.label) {
5226
5204
  case 0:
5227
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, rootDirname = options.rootDirname, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5205
+ _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;
5228
5206
  knowledgePreparedUnflatten = new Array(knowledgeSources.length);
5229
5207
  return [4 /*yield*/, forEachAsync(knowledgeSources, { maxParallelCount: maxParallelCount }, function (knowledgeSource, index) { return __awaiter(_this, void 0, void 0, function () {
5230
5208
  var partialPieces, sourceHandler, _a, _b, scraper, partialPiecesUnchecked, e_1_1, pieces;
@@ -5253,7 +5231,8 @@
5253
5231
  case 4:
5254
5232
  partialPiecesUnchecked = _d.sent();
5255
5233
  if (partialPiecesUnchecked !== null) {
5256
- partialPieces = partialPiecesUnchecked;
5234
+ partialPieces = __spreadArray([], __read(partialPiecesUnchecked), false);
5235
+ // <- TODO: [🪓] Here should be no need for spreading new array, just `partialPieces = partialPiecesUnchecked`
5257
5236
  return [3 /*break*/, 6];
5258
5237
  }
5259
5238
  _d.label = 5;
@@ -5301,7 +5280,7 @@
5301
5280
  > /**
5302
5281
  > * Unprepared knowledge
5303
5282
  > * /
5304
- > readonly knowledgeSources: Array<KnowledgeSourceJson>;
5283
+ > readonly knowledgeSources: ReadonlyArray<KnowledgeSourceJson>;
5305
5284
  > };
5306
5285
  >
5307
5286
  > export async function prepareKnowledgePieces(
@@ -5359,7 +5338,7 @@
5359
5338
  return __generator(this, function (_b) {
5360
5339
  switch (_b.label) {
5361
5340
  case 0:
5362
- _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a;
5341
+ _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? DEFAULT_MAX_PARALLEL_COUNT : _a;
5363
5342
  templates = pipeline.templates, parameters = pipeline.parameters, knowledgePiecesCount = pipeline.knowledgePiecesCount;
5364
5343
  // TODO: [main] !!!!! Apply samples to each template (if missing and is for the template defined)
5365
5344
  TODO_USE(parameters);
@@ -5421,7 +5400,7 @@
5421
5400
  if (isPipelinePrepared(pipeline)) {
5422
5401
  return [2 /*return*/, pipeline];
5423
5402
  }
5424
- rootDirname = options.rootDirname, _a = options.maxParallelCount, maxParallelCount = _a === void 0 ? MAX_PARALLEL_COUNT : _a, _b = options.isVerbose, isVerbose = _b === void 0 ? IS_VERBOSE : _b;
5403
+ 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;
5425
5404
  parameters = pipeline.parameters, templates = pipeline.templates, knowledgeSources = pipeline.knowledgeSources, personas = pipeline.personas;
5426
5405
  if (tools === undefined || tools.llm === undefined) {
5427
5406
  throw new MissingToolsError('LLM tools are required for preparing the pipeline');
@@ -5479,7 +5458,9 @@
5479
5458
  // ----- /Templates preparation -----
5480
5459
  // Note: Count total usage
5481
5460
  currentPreparation.usage = llmToolsWithUsage.getTotalUsage();
5482
- return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: templatesPrepared, knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: preparations }))];
5461
+ return [2 /*return*/, $asDeeplyFrozenSerializableJson('Prepared PipelineJson', __assign(__assign({}, clonePipeline(pipeline)), { templates: __spreadArray([], __read(templatesPrepared), false),
5462
+ // <- TODO: [🪓] Here should be no need for spreading new array, just ` templates: templatesPrepared`
5463
+ knowledgeSources: knowledgeSourcesPrepared, knowledgePieces: knowledgePiecesPrepared, personas: preparedPersonas, preparations: __spreadArray([], __read(preparations), false) }))];
5483
5464
  }
5484
5465
  });
5485
5466
  });
@@ -5526,6 +5507,7 @@
5526
5507
  'KNOWLEDGE ./hejny-cv.md',
5527
5508
  'KNOWLEDGE ./hejny-cv.pdf',
5528
5509
  'KNOWLEDGE ./hejny-cv.docx',
5510
+ // <- TODO: [😿] Allow ONLY files scoped in the (sub)directory NOT ../ and test it
5529
5511
  ],
5530
5512
  /**
5531
5513
  * Parses the KNOWLEDGE command
@@ -8243,6 +8225,327 @@
8243
8225
  */
8244
8226
  var $isRunningInNode = new Function("\n try {\n return this === global;\n } catch (e) {\n return false;\n }\n");
8245
8227
 
8228
+ // Note: We want to use the `exec` as async function
8229
+ var exec$1 = util.promisify(child_process.exec);
8230
+ /**
8231
+ * @@@
8232
+ *
8233
+ * @private within the repository
8234
+ */
8235
+ function locateAppOnLinux(_a) {
8236
+ var appName = _a.appName, linuxWhich = _a.linuxWhich;
8237
+ return __awaiter(this, void 0, void 0, function () {
8238
+ var _b, stderr, stdout, error_1;
8239
+ return __generator(this, function (_c) {
8240
+ switch (_c.label) {
8241
+ case 0:
8242
+ _c.trys.push([0, 2, , 3]);
8243
+ return [4 /*yield*/, exec$1("which ".concat(linuxWhich))];
8244
+ case 1:
8245
+ _b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
8246
+ if (!stderr && stdout) {
8247
+ return [2 /*return*/, stdout.trim()];
8248
+ }
8249
+ throw new Error("Can not locate app ".concat(appName, " on Linux.\n ").concat(stderr));
8250
+ case 2:
8251
+ error_1 = _c.sent();
8252
+ if (!(error_1 instanceof Error)) {
8253
+ throw error_1;
8254
+ }
8255
+ return [2 /*return*/, null];
8256
+ case 3: return [2 /*return*/];
8257
+ }
8258
+ });
8259
+ });
8260
+ }
8261
+ /**
8262
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8263
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8264
+ */
8265
+
8266
+ /**
8267
+ * @@@
8268
+ *
8269
+ * @public exported from `@promptbook/node`
8270
+ */
8271
+ function $provideFilesystemForNode(options) {
8272
+ if (!$isRunningInNode()) {
8273
+ throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
8274
+ }
8275
+ var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a;
8276
+ TODO_USE(isVerbose);
8277
+ return {
8278
+ stat: promises.stat,
8279
+ access: promises.access,
8280
+ constants: promises.constants,
8281
+ readFile: promises.readFile,
8282
+ writeFile: promises.writeFile,
8283
+ readdir: promises.readdir,
8284
+ };
8285
+ }
8286
+ /**
8287
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8288
+ */
8289
+
8290
+ /**
8291
+ * Checks if the file is executable
8292
+ *
8293
+ * @private within the repository
8294
+ */
8295
+ function isExecutable(path, fs) {
8296
+ return __awaiter(this, void 0, void 0, function () {
8297
+ return __generator(this, function (_a) {
8298
+ switch (_a.label) {
8299
+ case 0:
8300
+ _a.trys.push([0, 2, , 3]);
8301
+ return [4 /*yield*/, fs.access(path, fs.constants.X_OK)];
8302
+ case 1:
8303
+ _a.sent();
8304
+ return [2 /*return*/, true];
8305
+ case 2:
8306
+ _a.sent();
8307
+ return [2 /*return*/, false];
8308
+ case 3: return [2 /*return*/];
8309
+ }
8310
+ });
8311
+ });
8312
+ }
8313
+ /**
8314
+ * Note: Not [~🟢~] because it is not directly dependent on `fs
8315
+ * TODO: [🖇] What about symlinks?
8316
+ */
8317
+
8318
+ // Note: Module `userhome` has no types available, so it is imported using `require`
8319
+ // @see https://stackoverflow.com/questions/37000981/how-to-import-node-module-in-typescript-without-type-definitions
8320
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
8321
+ var userhome = require('userhome');
8322
+ // Note: We want to use the `exec` as async function
8323
+ var exec = util.promisify(child_process.exec);
8324
+ /**
8325
+ * @@@
8326
+ *
8327
+ * @private within the repository
8328
+ */
8329
+ function locateAppOnMacOs(_a) {
8330
+ var appName = _a.appName, macOsName = _a.macOsName;
8331
+ return __awaiter(this, void 0, void 0, function () {
8332
+ var toExec, regPath, altPath, _b, stderr, stdout, error_1;
8333
+ return __generator(this, function (_c) {
8334
+ switch (_c.label) {
8335
+ case 0:
8336
+ _c.trys.push([0, 6, , 7]);
8337
+ toExec = "/Contents/MacOS/".concat(macOsName);
8338
+ regPath = "/Applications/".concat(macOsName, ".app") + toExec;
8339
+ altPath = userhome(regPath.slice(1));
8340
+ return [4 /*yield*/, isExecutable(regPath, $provideFilesystemForNode())];
8341
+ case 1:
8342
+ if (!_c.sent()) return [3 /*break*/, 2];
8343
+ return [2 /*return*/, regPath];
8344
+ case 2: return [4 /*yield*/, isExecutable(altPath, $provideFilesystemForNode())];
8345
+ case 3:
8346
+ if (_c.sent()) {
8347
+ return [2 /*return*/, altPath];
8348
+ }
8349
+ _c.label = 4;
8350
+ case 4: return [4 /*yield*/, exec("mdfind 'kMDItemDisplayName == \"".concat(macOsName, "\" && kMDItemKind == Application'"))];
8351
+ case 5:
8352
+ _b = _c.sent(), stderr = _b.stderr, stdout = _b.stdout;
8353
+ if (!stderr && stdout) {
8354
+ return [2 /*return*/, stdout.trim() + toExec];
8355
+ }
8356
+ throw new Error("Can not locate app ".concat(appName, " on macOS.\n ").concat(stderr));
8357
+ case 6:
8358
+ error_1 = _c.sent();
8359
+ if (!(error_1 instanceof Error)) {
8360
+ throw error_1;
8361
+ }
8362
+ return [2 /*return*/, null];
8363
+ case 7: return [2 /*return*/];
8364
+ }
8365
+ });
8366
+ });
8367
+ }
8368
+ /**
8369
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8370
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8371
+ */
8372
+
8373
+ /**
8374
+ * @@@
8375
+ *
8376
+ * @private within the repository
8377
+ */
8378
+ function locateAppOnWindows(_a) {
8379
+ var appName = _a.appName, windowsSuffix = _a.windowsSuffix;
8380
+ return __awaiter(this, void 0, void 0, function () {
8381
+ var prefixes, prefixes_1, prefixes_1_1, prefix, path$1, e_1_1, error_1;
8382
+ var e_1, _b;
8383
+ return __generator(this, function (_c) {
8384
+ switch (_c.label) {
8385
+ case 0:
8386
+ _c.trys.push([0, 9, , 10]);
8387
+ prefixes = [
8388
+ process.env.LOCALAPPDATA,
8389
+ path.join(process.env.LOCALAPPDATA || '', 'Programs'),
8390
+ process.env.PROGRAMFILES,
8391
+ process.env['PROGRAMFILES(X86)'],
8392
+ ];
8393
+ _c.label = 1;
8394
+ case 1:
8395
+ _c.trys.push([1, 6, 7, 8]);
8396
+ prefixes_1 = __values(prefixes), prefixes_1_1 = prefixes_1.next();
8397
+ _c.label = 2;
8398
+ case 2:
8399
+ if (!!prefixes_1_1.done) return [3 /*break*/, 5];
8400
+ prefix = prefixes_1_1.value;
8401
+ path$1 = prefix + windowsSuffix;
8402
+ return [4 /*yield*/, isExecutable(path$1, $provideFilesystemForNode())];
8403
+ case 3:
8404
+ if (_c.sent()) {
8405
+ return [2 /*return*/, path$1];
8406
+ }
8407
+ _c.label = 4;
8408
+ case 4:
8409
+ prefixes_1_1 = prefixes_1.next();
8410
+ return [3 /*break*/, 2];
8411
+ case 5: return [3 /*break*/, 8];
8412
+ case 6:
8413
+ e_1_1 = _c.sent();
8414
+ e_1 = { error: e_1_1 };
8415
+ return [3 /*break*/, 8];
8416
+ case 7:
8417
+ try {
8418
+ if (prefixes_1_1 && !prefixes_1_1.done && (_b = prefixes_1.return)) _b.call(prefixes_1);
8419
+ }
8420
+ finally { if (e_1) throw e_1.error; }
8421
+ return [7 /*endfinally*/];
8422
+ case 8: throw new Error("Can not locate app ".concat(appName, " on Windows."));
8423
+ case 9:
8424
+ error_1 = _c.sent();
8425
+ if (!(error_1 instanceof Error)) {
8426
+ throw error_1;
8427
+ }
8428
+ return [2 /*return*/, null];
8429
+ case 10: return [2 /*return*/];
8430
+ }
8431
+ });
8432
+ });
8433
+ }
8434
+ /**
8435
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8436
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8437
+ */
8438
+
8439
+ /**
8440
+ * Locates an application on the system
8441
+ *
8442
+ * @private within the repository
8443
+ */
8444
+ function locateApp(options) {
8445
+ if (!$isRunningInNode()) {
8446
+ throw new EnvironmentMismatchError('Locating apps works only in Node.js environment');
8447
+ }
8448
+ var appName = options.appName, linuxWhich = options.linuxWhich, windowsSuffix = options.windowsSuffix, macOsName = options.macOsName;
8449
+ if (process.platform === 'win32') {
8450
+ if (windowsSuffix) {
8451
+ return locateAppOnWindows({ appName: appName, windowsSuffix: windowsSuffix });
8452
+ }
8453
+ else {
8454
+ throw new Error("".concat(appName, " is not available on Windows."));
8455
+ }
8456
+ }
8457
+ else if (process.platform === 'darwin') {
8458
+ if (macOsName) {
8459
+ return locateAppOnMacOs({ appName: appName, macOsName: macOsName });
8460
+ }
8461
+ else {
8462
+ throw new Error("".concat(appName, " is not available on macOS."));
8463
+ }
8464
+ }
8465
+ else {
8466
+ if (linuxWhich) {
8467
+ return locateAppOnLinux({ appName: appName, linuxWhich: linuxWhich });
8468
+ }
8469
+ else {
8470
+ throw new Error("".concat(appName, " is not available on Linux."));
8471
+ }
8472
+ }
8473
+ }
8474
+ /**
8475
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node`
8476
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8477
+ */
8478
+
8479
+ /**
8480
+ * @@@
8481
+ *
8482
+ * @private within the repository
8483
+ */
8484
+ function locateLibreoffice() {
8485
+ return locateApp({
8486
+ appName: 'Libreoffice',
8487
+ linuxWhich: 'libreoffice',
8488
+ windowsSuffix: '\\LibreOffice\\program\\soffice.exe',
8489
+ macOsName: 'LibreOffice',
8490
+ });
8491
+ }
8492
+ /**
8493
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/legacy-documents`
8494
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8495
+ */
8496
+
8497
+ /**
8498
+ * @@@
8499
+ *
8500
+ * @private within the repository
8501
+ */
8502
+ function locatePandoc() {
8503
+ return locateApp({
8504
+ appName: 'Pandoc',
8505
+ linuxWhich: 'pandoc',
8506
+ windowsSuffix: '\\Pandoc\\pandoc.exe',
8507
+ macOsName: 'Pandoc',
8508
+ });
8509
+ }
8510
+ /**
8511
+ * TODO: [🧠][♿] Maybe export through `@promptbook/node` OR `@promptbook/documents`
8512
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8513
+ */
8514
+
8515
+ /**
8516
+ * @@@
8517
+ *
8518
+ * @public exported from `@promptbook/node`
8519
+ */
8520
+ function $provideExecutablesForNode(options) {
8521
+ return __awaiter(this, void 0, void 0, function () {
8522
+ var _a, _b, isAutoInstalled, _c, isVerbose;
8523
+ var _d;
8524
+ return __generator(this, function (_e) {
8525
+ switch (_e.label) {
8526
+ case 0:
8527
+ if (!$isRunningInNode()) {
8528
+ throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8529
+ }
8530
+ _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;
8531
+ TODO_USE(isAutoInstalled); // <- TODO: [🔱][🧠] Auto-install the executables
8532
+ TODO_USE(isVerbose);
8533
+ _d = {};
8534
+ return [4 /*yield*/, locatePandoc()];
8535
+ case 1:
8536
+ _d.pandocPath = (_e.sent()) || undefined;
8537
+ return [4 /*yield*/, locateLibreoffice()];
8538
+ case 2: return [2 /*return*/, (_d.libreOfficePath = (_e.sent()) || undefined,
8539
+ _d)];
8540
+ }
8541
+ });
8542
+ });
8543
+ }
8544
+ /**
8545
+ * TODO: [🧠] Allow to override the executables without need to call `locatePandoc` / `locateLibreoffice` in case of provided
8546
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8547
+ */
8548
+
8246
8549
  /**
8247
8550
  * @@@
8248
8551
  *
@@ -8412,7 +8715,7 @@
8412
8715
  */
8413
8716
  function createLlmToolsFromConfiguration(configuration, options) {
8414
8717
  if (options === void 0) { options = {}; }
8415
- var _a = options.isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8718
+ var _a = options.isVerbose, isVerbose = _a === void 0 ? DEFAULT_IS_VERBOSE : _a, userId = options.userId;
8416
8719
  var llmTools = configuration.map(function (llmConfiguration) {
8417
8720
  var registeredItem = $llmToolsRegister
8418
8721
  .list()
@@ -8423,7 +8726,7 @@
8423
8726
  if (registeredItem === undefined) {
8424
8727
  throw new Error(spaceTrim__default["default"](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 "); }));
8425
8728
  }
8426
- return registeredItem(__assign({ isVerbose: isVerbose }, llmConfiguration.options));
8729
+ return registeredItem(__assign({ isVerbose: isVerbose, userId: userId }, llmConfiguration.options));
8427
8730
  });
8428
8731
  return joinLlmExecutionTools.apply(void 0, __spreadArray([], __read(llmTools), false));
8429
8732
  }
@@ -8476,29 +8779,6 @@
8476
8779
  /**
8477
8780
  * @@@
8478
8781
  *
8479
- * @public exported from `@promptbook/node`
8480
- */
8481
- function $provideFilesystemForNode(options) {
8482
- if (!$isRunningInNode()) {
8483
- throw new EnvironmentMismatchError('Function `$provideFilesystemForNode` works only in Node.js environment');
8484
- }
8485
- var _a = (options || {}).isVerbose, isVerbose = _a === void 0 ? IS_VERBOSE : _a;
8486
- TODO_USE(isVerbose);
8487
- return {
8488
- stat: promises.stat,
8489
- access: promises.access,
8490
- constants: promises.constants,
8491
- readFile: promises.readFile,
8492
- readdir: promises.readdir,
8493
- };
8494
- }
8495
- /**
8496
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
8497
- */
8498
-
8499
- /**
8500
- * !!!!!!
8501
- *
8502
8782
  * 1) @@@
8503
8783
  * 2) @@@
8504
8784
  *
@@ -8514,7 +8794,7 @@
8514
8794
  if (!$isRunningInNode()) {
8515
8795
  throw new EnvironmentMismatchError('Function `$getScrapersForNode` works only in Node.js environment');
8516
8796
  }
8517
- _a = options || {}, _b = _a.isAutoInstalled, isAutoInstalled = _b === void 0 ? IS_AUTO_INSTALLED : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? IS_VERBOSE : _c;
8797
+ _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;
8518
8798
  TODO_USE(isAutoInstalled);
8519
8799
  TODO_USE(isVerbose);
8520
8800
  scrapers = [];
@@ -9008,7 +9288,7 @@
9008
9288
  */
9009
9289
  function $provideExecutionToolsForNode(options) {
9010
9290
  return __awaiter(this, void 0, void 0, function () {
9011
- var fs, llm, tools;
9291
+ var fs, llm, executables, tools;
9012
9292
  var _a;
9013
9293
  return __generator(this, function (_b) {
9014
9294
  switch (_b.label) {
@@ -9018,12 +9298,16 @@
9018
9298
  }
9019
9299
  fs = $provideFilesystemForNode();
9020
9300
  llm = $provideLlmToolsFromEnv(options);
9301
+ return [4 /*yield*/, $provideExecutablesForNode(options)];
9302
+ case 1:
9303
+ executables = _b.sent();
9021
9304
  _a = {
9022
9305
  llm: llm,
9023
- fs: fs
9306
+ fs: fs,
9307
+ executables: executables
9024
9308
  };
9025
- return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm }, options)];
9026
- case 1:
9309
+ return [4 /*yield*/, $provideScrapersForNode({ fs: fs, llm: llm, executables: executables }, options)];
9310
+ case 2:
9027
9311
  tools = (_a.scrapers = _b.sent(),
9028
9312
  _a.script = [new JavascriptExecutionTools(options)],
9029
9313
  _a);
@@ -9261,7 +9545,9 @@
9261
9545
  throw new EnvironmentMismatchError('Can not create collection without filesystem tools');
9262
9546
  // <- TODO: [🧠] What is the best error type here`
9263
9547
  }
9264
- makedLibraryFilePath = path.join(path$1, "".concat(PIPELINE_COLLECTION_BASE_FILENAME, ".json"));
9548
+ makedLibraryFilePath = path.join(path$1, "".concat(DEFAULT_PIPELINE_COLLECTION_BASE_FILENAME
9549
+ // <- TODO: [🦒] Allow to override (pass different value into the function)
9550
+ , ".json"));
9265
9551
  return [4 /*yield*/, isFileExisting(makedLibraryFilePath, tools.fs)];
9266
9552
  case 3:
9267
9553
  if (!(_f.sent())) {
@@ -9272,7 +9558,7 @@
9272
9558
  // TODO: !! Implement;
9273
9559
  // TODO: [🌗]
9274
9560
  }
9275
- _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;
9561
+ _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;
9276
9562
  collection = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
9277
9563
  var fileNames, collection, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
9278
9564
  var e_1, _a;
@@ -9606,22 +9892,26 @@
9606
9892
  /**
9607
9893
  * Normalize options for `execCommand` and `execCommands`
9608
9894
  *
9895
+ * Note: `$` is used to indicate that this function behaves differently according to `process.platform`
9896
+ *
9609
9897
  * @private internal utility of `execCommand` and `execCommands`
9610
9898
  */
9611
- function execCommandNormalizeOptions(options) {
9899
+ function $execCommandNormalizeOptions(options) {
9612
9900
  var _a;
9613
- var _b, _c, _d;
9901
+ var _b, _c, _d, _e;
9614
9902
  var command;
9615
9903
  var cwd;
9616
9904
  var crashOnError;
9617
9905
  var args = [];
9618
9906
  var timeout;
9907
+ var isVerbose;
9619
9908
  if (typeof options === 'string') {
9620
9909
  // TODO: [1] DRY default values
9621
9910
  command = options;
9622
9911
  cwd = process.cwd();
9623
9912
  crashOnError = true;
9624
- timeout = Infinity;
9913
+ timeout = Infinity; // <- TODO: [⏳]
9914
+ isVerbose = DEFAULT_IS_VERBOSE;
9625
9915
  }
9626
9916
  else {
9627
9917
  /*
@@ -9637,6 +9927,7 @@
9637
9927
  cwd = (_b = options.cwd) !== null && _b !== void 0 ? _b : process.cwd();
9638
9928
  crashOnError = (_c = options.crashOnError) !== null && _c !== void 0 ? _c : true;
9639
9929
  timeout = (_d = options.timeout) !== null && _d !== void 0 ? _d : Infinity;
9930
+ isVerbose = (_e = options.isVerbose) !== null && _e !== void 0 ? _e : DEFAULT_IS_VERBOSE;
9640
9931
  }
9641
9932
  // TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
9642
9933
  var _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
@@ -9658,16 +9949,21 @@
9658
9949
  if (['ts-node'].includes(humanReadableCommand)) {
9659
9950
  humanReadableCommand += " ".concat(args[1]);
9660
9951
  }
9661
- return { command: command, humanReadableCommand: humanReadableCommand, args: args, cwd: cwd, crashOnError: crashOnError, timeout: timeout };
9952
+ if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
9953
+ command = "".concat(command, ".cmd");
9954
+ }
9955
+ return { command: command, humanReadableCommand: humanReadableCommand, args: args, cwd: cwd, crashOnError: crashOnError, timeout: timeout, isVerbose: isVerbose };
9662
9956
  }
9663
9957
  // TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
9664
9958
 
9665
9959
  /**
9666
9960
  * Run one command in a shell
9667
9961
  *
9962
+ *
9668
9963
  * Note: There are 2 similar functions in the codebase:
9669
9964
  * - `$execCommand` which runs a single command
9670
9965
  * - `$execCommands` which runs multiple commands
9966
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
9671
9967
  *
9672
9968
  * @public exported from `@promptbook/node`
9673
9969
  */
@@ -9677,7 +9973,7 @@
9677
9973
  }
9678
9974
  return new Promise(function (resolve, reject) {
9679
9975
  // eslint-disable-next-line prefer-const
9680
- var _a = execCommandNormalizeOptions(options), command = _a.command, humanReadableCommand = _a.humanReadableCommand, args = _a.args, cwd = _a.cwd, crashOnError = _a.crashOnError, timeout = _a.timeout;
9976
+ var _a = $execCommandNormalizeOptions(options), command = _a.command, humanReadableCommand = _a.humanReadableCommand, args = _a.args, cwd = _a.cwd, crashOnError = _a.crashOnError, timeout = _a.timeout, _b = _a.isVerbose, isVerbose = _b === void 0 ? DEFAULT_IS_VERBOSE : _b;
9681
9977
  if (timeout !== Infinity) {
9682
9978
  // TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
9683
9979
  waitasecond.forTime(timeout).then(function () {
@@ -9690,24 +9986,26 @@
9690
9986
  }
9691
9987
  });
9692
9988
  }
9693
- if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
9694
- command = "".concat(command, ".cmd");
9989
+ if (isVerbose) {
9990
+ console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
9695
9991
  }
9696
- // !!!!!! Verbose mode - to all consoles
9697
- console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
9698
9992
  try {
9699
9993
  var commandProcess = child_process.spawn(command, args, { cwd: cwd, shell: true });
9700
- commandProcess.on('message', function (message) {
9701
- console.info({ message: message });
9702
- });
9994
+ if (isVerbose) {
9995
+ commandProcess.on('message', function (message) {
9996
+ console.info({ message: message });
9997
+ });
9998
+ }
9703
9999
  var output_1 = [];
9704
10000
  commandProcess.stdout.on('data', function (stdout) {
9705
10001
  output_1.push(stdout.toString());
9706
- console.info(stdout.toString());
10002
+ if (isVerbose) {
10003
+ console.info(stdout.toString());
10004
+ }
9707
10005
  });
9708
10006
  commandProcess.stderr.on('data', function (stderr) {
9709
10007
  output_1.push(stderr.toString());
9710
- if (stderr.toString().trim()) {
10008
+ if (isVerbose && stderr.toString().trim()) {
9711
10009
  console.warn(stderr.toString());
9712
10010
  }
9713
10011
  });
@@ -9718,7 +10016,9 @@
9718
10016
  "Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code)));
9719
10017
  }
9720
10018
  else {
9721
- console.warn("Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code));
10019
+ if (isVerbose) {
10020
+ console.warn("Command \"".concat(humanReadableCommand, "\" exited with code ").concat(code));
10021
+ }
9722
10022
  resolve(spaceTrim.spaceTrim(output_1.join('\n')));
9723
10023
  }
9724
10024
  }
@@ -9737,7 +10037,9 @@
9737
10037
  reject(new Error("Command \"".concat(humanReadableCommand, "\" failed: \n").concat(error.message)));
9738
10038
  }
9739
10039
  else {
9740
- console.warn(error);
10040
+ if (isVerbose) {
10041
+ console.warn(error);
10042
+ }
9741
10043
  resolve(spaceTrim.spaceTrim(output_1.join('\n')));
9742
10044
  }
9743
10045
  });
@@ -9758,6 +10060,7 @@
9758
10060
  * Note: There are 2 similar functions in the codebase:
9759
10061
  * - `$execCommand` which runs a single command
9760
10062
  * - `$execCommands` which runs multiple commands
10063
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a commands in a shell
9761
10064
  *
9762
10065
  * @public exported from `@promptbook/node`
9763
10066
  */
@@ -9804,6 +10107,7 @@
9804
10107
 
9805
10108
  exports.$execCommand = $execCommand;
9806
10109
  exports.$execCommands = $execCommands;
10110
+ exports.$provideExecutablesForNode = $provideExecutablesForNode;
9807
10111
  exports.$provideExecutionToolsForNode = $provideExecutionToolsForNode;
9808
10112
  exports.$provideFilesystemForNode = $provideFilesystemForNode;
9809
10113
  exports.$provideLlmToolsConfigurationFromEnv = $provideLlmToolsConfigurationFromEnv;