@promptbook/cli 0.60.0-0 → 0.60.0-3

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 (206) hide show
  1. package/README.md +6 -6
  2. package/esm/index.es.js +305 -306
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/src/_packages/core.index.d.ts +23 -23
  5. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  6. package/esm/typings/src/_packages/types.index.d.ts +11 -11
  7. package/esm/typings/src/_packages/utils.index.d.ts +9 -11
  8. package/esm/typings/src/config.d.ts +1 -1
  9. package/esm/typings/src/conversion/pipelineJsonToString.d.ts +12 -0
  10. package/esm/typings/src/conversion/pipelineStringToJson.d.ts +32 -0
  11. package/esm/typings/src/conversion/pipelineStringToJsonSync.d.ts +23 -0
  12. package/esm/typings/src/conversion/prettify/PrettifyOptions.d.ts +1 -1
  13. package/{umd/typings/src/conversion/prettify/prettifyPromptbookString.d.ts → esm/typings/src/conversion/prettify/prettifyPipelineString.d.ts} +2 -2
  14. package/esm/typings/src/conversion/prettify/{renderPromptbookMermaid.d.ts → renderPipelineMermaidOptions.d.ts} +4 -4
  15. package/esm/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  16. package/esm/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  17. package/esm/typings/src/conversion/utils/parseCommand.d.ts +2 -2
  18. package/esm/typings/src/conversion/utils/parseNumber.d.ts +1 -1
  19. package/esm/typings/src/conversion/utils/renameParameter.d.ts +4 -4
  20. package/esm/typings/src/conversion/validation/_importPipeline.d.ts +13 -0
  21. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +27 -0
  22. package/{umd/typings/src/errors/PromptbookLibraryError.d.ts → esm/typings/src/errors/CollectionError.d.ts} +2 -2
  23. package/esm/typings/src/errors/{PromptbookExecutionError.d.ts → ExecutionError.d.ts} +2 -2
  24. package/{umd/typings/src/errors/PromptbookNotFoundError.d.ts → esm/typings/src/errors/NotFoundError.d.ts} +2 -2
  25. package/{umd/typings/src/errors/PromptbookLogicError.d.ts → esm/typings/src/errors/PipelineLogicError.d.ts} +2 -2
  26. package/{umd/typings/src/errors/PromptbookReferenceError.d.ts → esm/typings/src/errors/ReferenceError.d.ts} +2 -2
  27. package/esm/typings/src/errors/{PromptbookSyntaxError.d.ts → SyntaxError.d.ts} +2 -2
  28. package/esm/typings/src/errors/TemplateError.d.ts +1 -1
  29. package/esm/typings/src/errors/_ExpectError.d.ts +2 -2
  30. package/esm/typings/src/execution/ExecutionTools.d.ts +1 -1
  31. package/esm/typings/src/execution/LlmExecutionTools.d.ts +4 -4
  32. package/esm/typings/src/execution/PromptResult.d.ts +1 -1
  33. package/esm/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
  34. package/esm/typings/src/execution/createPromptbookExecutor.d.ts +3 -3
  35. package/esm/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  36. package/esm/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  37. package/esm/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  38. package/esm/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  39. package/esm/typings/src/library/PipelineCollection.d.ts +25 -0
  40. package/esm/typings/src/library/{SimplePromptbookLibrary.d.ts → SimplePipelineCollection.d.ts} +11 -11
  41. package/{umd/typings/src/library/constructors/createLibraryFromDirectory.d.ts → esm/typings/src/library/constructors/createCollectionFromDirectory.d.ts} +5 -5
  42. package/esm/typings/src/library/constructors/createCollectionFromJson.d.ts +12 -0
  43. package/esm/typings/src/library/constructors/createCollectionFromPromise.d.ts +22 -0
  44. package/esm/typings/src/library/constructors/{createLibraryFromUrl.d.ts → createCollectionFromUrl.d.ts} +5 -5
  45. package/esm/typings/src/library/constructors/createSubcollection.d.ts +12 -0
  46. package/esm/typings/src/library/libraryToJson.d.ts +5 -5
  47. package/esm/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  48. package/esm/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -3
  49. package/esm/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  50. package/esm/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  51. package/esm/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
  52. package/esm/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -3
  53. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  54. package/esm/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  55. package/esm/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  56. package/esm/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -3
  57. package/esm/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
  58. package/esm/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  59. package/esm/typings/src/types/Command.d.ts +4 -4
  60. package/esm/typings/src/types/Parameters.d.ts +1 -1
  61. package/esm/typings/src/types/{PromptbookJson/PromptbookJson.d.ts → PipelineJson/PipelineJson.d.ts} +4 -4
  62. package/{umd/typings/src/types/PromptbookString.d.ts → esm/typings/src/types/PipelineString.d.ts} +3 -3
  63. package/esm/typings/src/types/Prompt.d.ts +3 -3
  64. package/esm/typings/src/types/execution-report/ExecutionReportJson.d.ts +2 -2
  65. package/esm/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  66. package/esm/typings/src/types/typeAliases.d.ts +2 -2
  67. package/esm/typings/src/utils/emojis.d.ts +2 -2
  68. package/esm/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  69. package/esm/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  70. package/esm/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  71. package/esm/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  72. package/esm/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  73. package/esm/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  74. package/esm/typings/src/utils/expectation-counters/index.d.ts +2 -2
  75. package/esm/typings/src/utils/formatNumber.d.ts +1 -1
  76. package/esm/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  77. package/esm/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  78. package/esm/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  79. package/esm/typings/src/utils/markdown-json/MarkdownStructure.d.ts +1 -1
  80. package/esm/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
  81. package/esm/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
  82. package/package.json +3 -3
  83. package/umd/index.umd.js +305 -306
  84. package/umd/index.umd.js.map +1 -1
  85. package/umd/typings/src/_packages/core.index.d.ts +23 -23
  86. package/umd/typings/src/_packages/node.index.d.ts +2 -2
  87. package/umd/typings/src/_packages/types.index.d.ts +11 -11
  88. package/umd/typings/src/_packages/utils.index.d.ts +9 -11
  89. package/umd/typings/src/config.d.ts +1 -1
  90. package/umd/typings/src/conversion/pipelineJsonToString.d.ts +12 -0
  91. package/umd/typings/src/conversion/pipelineStringToJson.d.ts +32 -0
  92. package/umd/typings/src/conversion/pipelineStringToJsonSync.d.ts +23 -0
  93. package/umd/typings/src/conversion/prettify/PrettifyOptions.d.ts +1 -1
  94. package/{esm/typings/src/conversion/prettify/prettifyPromptbookString.d.ts → umd/typings/src/conversion/prettify/prettifyPipelineString.d.ts} +2 -2
  95. package/umd/typings/src/conversion/prettify/{renderPromptbookMermaid.d.ts → renderPipelineMermaidOptions.d.ts} +4 -4
  96. package/umd/typings/src/conversion/utils/extractParametersFromPromptTemplate.d.ts +2 -2
  97. package/umd/typings/src/conversion/utils/extractVariables.d.ts +1 -1
  98. package/umd/typings/src/conversion/utils/parseCommand.d.ts +2 -2
  99. package/umd/typings/src/conversion/utils/parseNumber.d.ts +1 -1
  100. package/umd/typings/src/conversion/utils/renameParameter.d.ts +4 -4
  101. package/umd/typings/src/conversion/validation/_importPipeline.d.ts +13 -0
  102. package/umd/typings/src/conversion/validation/validatePipeline.d.ts +27 -0
  103. package/{esm/typings/src/errors/PromptbookLibraryError.d.ts → umd/typings/src/errors/CollectionError.d.ts} +2 -2
  104. package/umd/typings/src/errors/{PromptbookExecutionError.d.ts → ExecutionError.d.ts} +2 -2
  105. package/{esm/typings/src/errors/PromptbookNotFoundError.d.ts → umd/typings/src/errors/NotFoundError.d.ts} +2 -2
  106. package/{esm/typings/src/errors/PromptbookLogicError.d.ts → umd/typings/src/errors/PipelineLogicError.d.ts} +2 -2
  107. package/{esm/typings/src/errors/PromptbookReferenceError.d.ts → umd/typings/src/errors/ReferenceError.d.ts} +2 -2
  108. package/umd/typings/src/errors/{PromptbookSyntaxError.d.ts → SyntaxError.d.ts} +2 -2
  109. package/umd/typings/src/errors/TemplateError.d.ts +1 -1
  110. package/umd/typings/src/errors/_ExpectError.d.ts +2 -2
  111. package/umd/typings/src/execution/ExecutionTools.d.ts +1 -1
  112. package/umd/typings/src/execution/LlmExecutionTools.d.ts +4 -4
  113. package/umd/typings/src/execution/PromptResult.d.ts +1 -1
  114. package/umd/typings/src/execution/assertsExecutionSuccessful.d.ts +1 -1
  115. package/umd/typings/src/execution/createPromptbookExecutor.d.ts +3 -3
  116. package/umd/typings/src/execution/translation/automatic-translate/automatic-translators/utils/extractMultiplicatedOccurrence.d.ts +1 -1
  117. package/umd/typings/src/execution/utils/checkExpectations.d.ts +1 -1
  118. package/umd/typings/src/knowledge/prepare-knowledge/markdown/prepareKnowledgeFromMarkdown.d.ts +1 -1
  119. package/umd/typings/src/knowledge/prepare-knowledge/pdf/prepareKnowledgeFromPdf.d.ts +1 -1
  120. package/umd/typings/src/library/PipelineCollection.d.ts +25 -0
  121. package/umd/typings/src/library/{SimplePromptbookLibrary.d.ts → SimplePipelineCollection.d.ts} +11 -11
  122. package/{esm/typings/src/library/constructors/createLibraryFromDirectory.d.ts → umd/typings/src/library/constructors/createCollectionFromDirectory.d.ts} +5 -5
  123. package/umd/typings/src/library/constructors/createCollectionFromJson.d.ts +12 -0
  124. package/umd/typings/src/library/constructors/createCollectionFromPromise.d.ts +22 -0
  125. package/umd/typings/src/library/constructors/{createLibraryFromUrl.d.ts → createCollectionFromUrl.d.ts} +5 -5
  126. package/umd/typings/src/library/constructors/createSubcollection.d.ts +12 -0
  127. package/umd/typings/src/library/libraryToJson.d.ts +5 -5
  128. package/umd/typings/src/llm-providers/anthropic-claude/AnthropicClaudeExecutionTools.d.ts +3 -3
  129. package/umd/typings/src/llm-providers/azure-openai/AzureOpenAiExecutionTools.d.ts +3 -3
  130. package/umd/typings/src/llm-providers/mocked/MockedEchoLlmExecutionTools.d.ts +2 -2
  131. package/umd/typings/src/llm-providers/mocked/MockedFackedLlmExecutionTools.d.ts +3 -3
  132. package/umd/typings/src/llm-providers/mocked/fakeTextToExpectations.d.ts +1 -1
  133. package/umd/typings/src/llm-providers/multiple/MultipleLlmExecutionTools.d.ts +3 -3
  134. package/umd/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +3 -3
  135. package/umd/typings/src/llm-providers/openai/computeOpenaiUsage.d.ts +1 -1
  136. package/umd/typings/src/llm-providers/openai/computeUsage.d.ts +2 -2
  137. package/umd/typings/src/llm-providers/remote/RemoteLlmExecutionTools.d.ts +3 -3
  138. package/umd/typings/src/llm-providers/remote/interfaces/RemoteServerOptions.d.ts +2 -2
  139. package/umd/typings/src/llm-providers/remote/startRemoteServer.d.ts +1 -1
  140. package/umd/typings/src/types/Command.d.ts +4 -4
  141. package/umd/typings/src/types/Parameters.d.ts +1 -1
  142. package/umd/typings/src/types/{PromptbookJson/PromptbookJson.d.ts → PipelineJson/PipelineJson.d.ts} +4 -4
  143. package/{esm/typings/src/types/PromptbookString.d.ts → umd/typings/src/types/PipelineString.d.ts} +3 -3
  144. package/umd/typings/src/types/Prompt.d.ts +3 -3
  145. package/umd/typings/src/types/execution-report/ExecutionReportJson.d.ts +2 -2
  146. package/umd/typings/src/types/execution-report/countWorkingDuration.d.ts +1 -1
  147. package/umd/typings/src/types/typeAliases.d.ts +2 -2
  148. package/umd/typings/src/utils/emojis.d.ts +2 -2
  149. package/umd/typings/src/utils/expectation-counters/countCharacters.d.ts +1 -1
  150. package/umd/typings/src/utils/expectation-counters/countLines.d.ts +1 -1
  151. package/umd/typings/src/utils/expectation-counters/countPages.d.ts +1 -1
  152. package/umd/typings/src/utils/expectation-counters/countParagraphs.d.ts +1 -1
  153. package/umd/typings/src/utils/expectation-counters/countSentences.d.ts +1 -1
  154. package/umd/typings/src/utils/expectation-counters/countWords.d.ts +1 -1
  155. package/umd/typings/src/utils/expectation-counters/index.d.ts +2 -2
  156. package/umd/typings/src/utils/formatNumber.d.ts +1 -1
  157. package/umd/typings/src/utils/markdown/addAutoGeneratedSection.d.ts +1 -1
  158. package/umd/typings/src/utils/markdown/createMarkdownChart.d.ts +1 -1
  159. package/umd/typings/src/utils/markdown/createMarkdownTable.d.ts +1 -1
  160. package/umd/typings/src/utils/markdown-json/MarkdownStructure.d.ts +1 -1
  161. package/umd/typings/src/utils/markdown-json/countMarkdownStructureDeepness.d.ts +1 -1
  162. package/umd/typings/src/utils/markdown-json/markdownToMarkdownStructure.d.ts +1 -1
  163. package/esm/typings/src/conversion/promptbookJsonToString.d.ts +0 -12
  164. package/esm/typings/src/conversion/promptbookStringToJson.d.ts +0 -32
  165. package/esm/typings/src/conversion/promptbookStringToJsonSync.d.ts +0 -23
  166. package/esm/typings/src/conversion/validation/_importPromptbook.d.ts +0 -13
  167. package/esm/typings/src/conversion/validation/validatePromptbook.d.ts +0 -27
  168. package/esm/typings/src/library/PromptbookLibrary.d.ts +0 -25
  169. package/esm/typings/src/library/constructors/createLibraryFromJson.d.ts +0 -12
  170. package/esm/typings/src/library/constructors/createLibraryFromPromise.d.ts +0 -22
  171. package/esm/typings/src/library/constructors/createSublibrary.d.ts +0 -12
  172. package/umd/typings/src/conversion/promptbookJsonToString.d.ts +0 -12
  173. package/umd/typings/src/conversion/promptbookStringToJson.d.ts +0 -32
  174. package/umd/typings/src/conversion/promptbookStringToJsonSync.d.ts +0 -23
  175. package/umd/typings/src/conversion/validation/_importPromptbook.d.ts +0 -13
  176. package/umd/typings/src/conversion/validation/validatePromptbook.d.ts +0 -27
  177. package/umd/typings/src/library/PromptbookLibrary.d.ts +0 -25
  178. package/umd/typings/src/library/constructors/createLibraryFromJson.d.ts +0 -12
  179. package/umd/typings/src/library/constructors/createLibraryFromPromise.d.ts +0 -22
  180. package/umd/typings/src/library/constructors/createSublibrary.d.ts +0 -12
  181. /package/esm/typings/{promptbook-library → promptbook-collection}/index.d.ts +0 -0
  182. /package/esm/typings/src/conversion/{promptbookStringToJson.test.d.ts → pipelineStringToJson.test.d.ts} +0 -0
  183. /package/esm/typings/src/conversion/{promptbookStringToJsonSync.test.d.ts → pipelineStringToJsonSync.test.d.ts} +0 -0
  184. /package/esm/typings/src/conversion/validation/{promptbookStringToJson-syntaxErrors.test.d.ts → pipelineStringToJson-syntaxErrors.test.d.ts} +0 -0
  185. /package/esm/typings/src/conversion/validation/{validatePromptbook-logicErrors.test.d.ts → validatePipeline-logicErrors.test.d.ts} +0 -0
  186. /package/esm/typings/src/conversion/validation/{validatePromptbook.test.d.ts → validatePipeline.test.d.ts} +0 -0
  187. /package/esm/typings/src/library/constructors/{createLibraryFromDirectory.test.d.ts → createCollectionFromDirectory.test.d.ts} +0 -0
  188. /package/esm/typings/src/library/constructors/{createLibraryFromJson.test.d.ts → createCollectionFromJson.test.d.ts} +0 -0
  189. /package/esm/typings/src/library/constructors/{createLibraryFromPromise.test.d.ts → createCollectionFromPromise.test.d.ts} +0 -0
  190. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/KnowledgeJson.d.ts +0 -0
  191. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/MaterialKnowledgePieceJson.d.ts +0 -0
  192. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateJson.d.ts +0 -0
  193. /package/esm/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateParameterJson.d.ts +0 -0
  194. /package/umd/typings/{promptbook-library → promptbook-collection}/index.d.ts +0 -0
  195. /package/umd/typings/src/conversion/{promptbookStringToJson.test.d.ts → pipelineStringToJson.test.d.ts} +0 -0
  196. /package/umd/typings/src/conversion/{promptbookStringToJsonSync.test.d.ts → pipelineStringToJsonSync.test.d.ts} +0 -0
  197. /package/umd/typings/src/conversion/validation/{promptbookStringToJson-syntaxErrors.test.d.ts → pipelineStringToJson-syntaxErrors.test.d.ts} +0 -0
  198. /package/umd/typings/src/conversion/validation/{validatePromptbook-logicErrors.test.d.ts → validatePipeline-logicErrors.test.d.ts} +0 -0
  199. /package/umd/typings/src/conversion/validation/{validatePromptbook.test.d.ts → validatePipeline.test.d.ts} +0 -0
  200. /package/umd/typings/src/library/constructors/{createLibraryFromDirectory.test.d.ts → createCollectionFromDirectory.test.d.ts} +0 -0
  201. /package/umd/typings/src/library/constructors/{createLibraryFromJson.test.d.ts → createCollectionFromJson.test.d.ts} +0 -0
  202. /package/umd/typings/src/library/constructors/{createLibraryFromPromise.test.d.ts → createCollectionFromPromise.test.d.ts} +0 -0
  203. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/KnowledgeJson.d.ts +0 -0
  204. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/MaterialKnowledgePieceJson.d.ts +0 -0
  205. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateJson.d.ts +0 -0
  206. /package/umd/typings/src/types/{PromptbookJson → PipelineJson}/PromptTemplateParameterJson.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -143,7 +143,7 @@ new Function("\n try {\n if (typeof WorkerGlobalScope !== 'undefined'
143
143
  /**
144
144
  * The version of the Promptbook library
145
145
  */
146
- var PROMPTBOOK_VERSION = '0.59.0';
146
+ var PROMPTBOOK_VERSION = '0.60.0-2';
147
147
 
148
148
  /**
149
149
  * Initializes testing `hello` command for Promptbook CLI utilities
@@ -180,36 +180,36 @@ function initializeHello(program) {
180
180
  */
181
181
  var LOOP_LIMIT = 1000;
182
182
  /**
183
- * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createLibraryFromDirectory`
183
+ * The name of the builded promptbook library made by CLI `promptbook make` and for lookup in `createCollectionFromDirectory`
184
184
  */
185
185
  var PROMPTBOOK_MAKED_BASE_FILENAME = "index";
186
186
 
187
187
  /**
188
188
  * This error indicates that the promptbook object has valid syntax but contains logical errors (like circular dependencies)
189
189
  */
190
- var PromptbookLogicError = /** @class */ (function (_super) {
191
- __extends(PromptbookLogicError, _super);
192
- function PromptbookLogicError(message) {
190
+ var PipelineLogicError = /** @class */ (function (_super) {
191
+ __extends(PipelineLogicError, _super);
192
+ function PipelineLogicError(message) {
193
193
  var _this = _super.call(this, message) || this;
194
- _this.name = 'PromptbookLogicError';
195
- Object.setPrototypeOf(_this, PromptbookLogicError.prototype);
194
+ _this.name = 'PipelineLogicError';
195
+ Object.setPrototypeOf(_this, PipelineLogicError.prototype);
196
196
  return _this;
197
197
  }
198
- return PromptbookLogicError;
198
+ return PipelineLogicError;
199
199
  }(Error));
200
200
 
201
201
  /**
202
202
  * This error indicates that the promptbook in a markdown format cannot be parsed into a valid promptbook object
203
203
  */
204
- var PromptbookSyntaxError = /** @class */ (function (_super) {
205
- __extends(PromptbookSyntaxError, _super);
206
- function PromptbookSyntaxError(message) {
204
+ var SyntaxError = /** @class */ (function (_super) {
205
+ __extends(SyntaxError, _super);
206
+ function SyntaxError(message) {
207
207
  var _this = _super.call(this, message) || this;
208
- _this.name = 'PromptbookSyntaxError';
209
- Object.setPrototypeOf(_this, PromptbookSyntaxError.prototype);
208
+ _this.name = 'SyntaxError';
209
+ Object.setPrototypeOf(_this, SyntaxError.prototype);
210
210
  return _this;
211
211
  }
212
- return PromptbookSyntaxError;
212
+ return SyntaxError;
213
213
  }(Error));
214
214
 
215
215
  /**
@@ -252,7 +252,7 @@ function isValidUrl(url) {
252
252
  }
253
253
 
254
254
  /**
255
- * Validates PromptbookJson if it is logically valid
255
+ * Validates PipelineJson if it is logically valid
256
256
  *
257
257
  * It checks:
258
258
  * - if it has correct parameters dependency
@@ -261,48 +261,48 @@ function isValidUrl(url) {
261
261
  * - if it is valid json
262
262
  * - if it is meaningful
263
263
  *
264
- * @param promptbook valid or invalid PromptbookJson
265
- * @returns the same promptbook if it is logically valid
266
- * @throws {PromptbookLogicError} on logical error in the promptbook
264
+ * @param pipeline valid or invalid PipelineJson
265
+ * @returns the same pipeline if it is logically valid
266
+ * @throws {PipelineLogicError} on logical error in the pipeline
267
267
  */
268
- function validatePromptbook(promptbook) {
268
+ function validatePipeline(pipeline) {
269
269
  // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
270
270
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
271
- if (promptbook.promptbookUrl !== undefined) {
272
- if (!isValidUrl(promptbook.promptbookUrl)) {
271
+ if (pipeline.promptbookUrl !== undefined) {
272
+ if (!isValidUrl(pipeline.promptbookUrl)) {
273
273
  // TODO: This should be maybe the syntax error detected during parsing
274
- throw new PromptbookLogicError("Invalid promptbook URL \"".concat(promptbook.promptbookUrl, "\""));
274
+ throw new PipelineLogicError("Invalid promptbook URL \"".concat(pipeline.promptbookUrl, "\""));
275
275
  }
276
276
  }
277
277
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
278
- if (!Array.isArray(promptbook.parameters)) {
278
+ if (!Array.isArray(pipeline.parameters)) {
279
279
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
280
- throw new PromptbookSyntaxError(spaceTrim$1("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof promptbook.parameters, "\n ")));
280
+ throw new SyntaxError(spaceTrim$1("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.parameters expected to be an array, but got ".concat(typeof pipeline.parameters, "\n ")));
281
281
  }
282
282
  // TODO: [🧠] Maybe do here some propper JSON-schema / ZOD checking
283
- if (!Array.isArray(promptbook.promptTemplates)) {
283
+ if (!Array.isArray(pipeline.promptTemplates)) {
284
284
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
285
- throw new PromptbookSyntaxError(spaceTrim$1("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof promptbook.promptTemplates, "\n ")));
285
+ throw new SyntaxError(spaceTrim$1("\n Promptbook is valid JSON but with wrong structure\n\n promptbook.promptTemplates expected to be an array, but got ".concat(typeof pipeline.promptTemplates, "\n ")));
286
286
  }
287
287
  var _loop_1 = function (parameter) {
288
288
  if (parameter.isInput && parameter.isOutput) {
289
- throw new PromptbookLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
289
+ throw new PipelineLogicError("Parameter {".concat(parameter.name, "} can not be both input and output"));
290
290
  }
291
291
  // Note: Testing that parameter is either intermediate or output BUT not created and unused
292
292
  if (!parameter.isInput &&
293
293
  !parameter.isOutput &&
294
- !promptbook.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
295
- throw new PromptbookLogicError(spaceTrim$1("\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ")));
294
+ !pipeline.promptTemplates.some(function (template) { return template.dependentParameterNames.includes(parameter.name); })) {
295
+ throw new PipelineLogicError(spaceTrim$1("\n Parameter {".concat(parameter.name, "} is created but not used\n\n You can declare {").concat(parameter.name, "} as output parameter by adding in the header:\n - OUTPUT PARAMETER `{").concat(parameter.name, "}` ").concat(parameter.description || '', "\n\n ")));
296
296
  }
297
297
  // Note: Testing that parameter is either input or result of some template
298
298
  if (!parameter.isInput &&
299
- !promptbook.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
300
- throw new PromptbookLogicError(spaceTrim$1("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
299
+ !pipeline.promptTemplates.some(function (template) { return template.resultingParameterName === parameter.name; })) {
300
+ throw new PipelineLogicError(spaceTrim$1("\n Parameter {".concat(parameter.name, "} is declared but not defined\n\n You can do one of these:\n - Remove declaration of {").concat(parameter.name, "}\n - Add prompt template that results in -> {").concat(parameter.name, "}\n\n ")));
301
301
  }
302
302
  };
303
303
  try {
304
304
  // Note: Check each parameter individually
305
- for (var _e = __values(promptbook.parameters), _f = _e.next(); !_f.done; _f = _e.next()) {
305
+ for (var _e = __values(pipeline.parameters), _f = _e.next(); !_f.done; _f = _e.next()) {
306
306
  var parameter = _f.value;
307
307
  _loop_1(parameter);
308
308
  }
@@ -315,7 +315,7 @@ function validatePromptbook(promptbook) {
315
315
  finally { if (e_1) throw e_1.error; }
316
316
  }
317
317
  // Note: Check each template individually
318
- var definedParameters = new Set(promptbook.parameters.filter(function (_a) {
318
+ var definedParameters = new Set(pipeline.parameters.filter(function (_a) {
319
319
  var isInput = _a.isInput;
320
320
  return isInput;
321
321
  }).map(function (_a) {
@@ -323,25 +323,25 @@ function validatePromptbook(promptbook) {
323
323
  return name;
324
324
  }));
325
325
  try {
326
- for (var _g = __values(promptbook.promptTemplates), _h = _g.next(); !_h.done; _h = _g.next()) {
326
+ for (var _g = __values(pipeline.promptTemplates), _h = _g.next(); !_h.done; _h = _g.next()) {
327
327
  var template = _h.value;
328
328
  if (definedParameters.has(template.resultingParameterName)) {
329
- throw new PromptbookLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
329
+ throw new PipelineLogicError("Parameter {".concat(template.resultingParameterName, "} is defined multiple times"));
330
330
  }
331
331
  definedParameters.add(template.resultingParameterName);
332
332
  if (template.executionType === 'PROMPT_TEMPLATE' && template.modelRequirements.modelVariant === undefined) {
333
- throw new PromptbookLogicError(spaceTrim$1("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
333
+ throw new PipelineLogicError(spaceTrim$1("\n\n You must specify MODEL VARIANT in the prompt template \"".concat(template.title, "\"\n\n For example:\n - MODEL VARIANT Chat\n - MODEL NAME `gpt-4-1106-preview`\n\n ")));
334
334
  }
335
335
  if (template.jokers && template.jokers.length > 0) {
336
336
  if (!template.expectFormat &&
337
337
  !template.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
338
- throw new PromptbookLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
338
+ throw new PipelineLogicError("Joker parameters are used for {".concat(template.resultingParameterName, "} but no expectations are defined"));
339
339
  }
340
340
  try {
341
341
  for (var _j = (e_3 = void 0, __values(template.jokers)), _k = _j.next(); !_k.done; _k = _j.next()) {
342
342
  var joker = _k.value;
343
343
  if (!template.dependentParameterNames.includes(joker)) {
344
- throw new PromptbookLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
344
+ throw new PipelineLogicError("Parameter {".concat(joker, "} is used for {").concat(template.resultingParameterName, "} as joker but not in dependentParameterNames"));
345
345
  }
346
346
  }
347
347
  }
@@ -358,13 +358,13 @@ function validatePromptbook(promptbook) {
358
358
  for (var _l = (e_4 = void 0, __values(Object.entries(template.expectations))), _m = _l.next(); !_m.done; _m = _l.next()) {
359
359
  var _o = __read(_m.value, 2), unit = _o[0], _p = _o[1], min = _p.min, max = _p.max;
360
360
  if (min !== undefined && max !== undefined && min > max) {
361
- throw new PromptbookLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
361
+ throw new PipelineLogicError("Min expectation (=".concat(min, ") of ").concat(unit, " is higher than max expectation (=").concat(max, ")"));
362
362
  }
363
363
  if (min !== undefined && min < 0) {
364
- throw new PromptbookLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
364
+ throw new PipelineLogicError("Min expectation of ".concat(unit, " must be zero or positive"));
365
365
  }
366
366
  if (max !== undefined && max <= 0) {
367
- throw new PromptbookLogicError("Max expectation of ".concat(unit, " must be positive"));
367
+ throw new PipelineLogicError("Max expectation of ".concat(unit, " must be positive"));
368
368
  }
369
369
  }
370
370
  }
@@ -386,7 +386,7 @@ function validatePromptbook(promptbook) {
386
386
  finally { if (e_2) throw e_2.error; }
387
387
  }
388
388
  // Note: Detect circular dependencies
389
- var resovedParameters = promptbook.parameters
389
+ var resovedParameters = pipeline.parameters
390
390
  .filter(function (_a) {
391
391
  var isInput = _a.isInput;
392
392
  return isInput;
@@ -395,17 +395,17 @@ function validatePromptbook(promptbook) {
395
395
  var name = _a.name;
396
396
  return name;
397
397
  });
398
- var unresovedTemplates = __spreadArray([], __read(promptbook.promptTemplates), false);
398
+ var unresovedTemplates = __spreadArray([], __read(pipeline.promptTemplates), false);
399
399
  var loopLimit = LOOP_LIMIT;
400
400
  var _loop_2 = function () {
401
401
  if (loopLimit-- < 0) {
402
- throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePromptbook`');
402
+ throw new UnexpectedError('Loop limit reached during detection of circular dependencies in `validatePipeline`');
403
403
  }
404
404
  var currentlyResovedTemplates = unresovedTemplates.filter(function (template) {
405
405
  return template.dependentParameterNames.every(function (name) { return resovedParameters.includes(name); });
406
406
  });
407
407
  if (currentlyResovedTemplates.length === 0) {
408
- throw new PromptbookLogicError(spaceTrim$1(function (block) { return "\n\n Can not resolve some parameters\n It may be circular dependencies\n\n Can not resolve:\n ".concat(block(unresovedTemplates
408
+ throw new PipelineLogicError(spaceTrim$1(function (block) { return "\n\n Can not resolve some parameters\n It may be circular dependencies\n\n Can not resolve:\n ".concat(block(unresovedTemplates
409
409
  .map(function (_a) {
410
410
  var resultingParameterName = _a.resultingParameterName, dependentParameterNames = _a.dependentParameterNames;
411
411
  return "- {".concat(resultingParameterName, "} depends on ").concat(dependentParameterNames
@@ -423,41 +423,41 @@ function validatePromptbook(promptbook) {
423
423
  while (unresovedTemplates.length > 0) {
424
424
  _loop_2();
425
425
  }
426
- return promptbook;
426
+ return pipeline;
427
427
  }
428
428
  /**
429
429
  * TODO: [🧠] Work with promptbookVersion
430
430
  * TODO: Use here some json-schema, Zod or something similar and change it to:
431
431
  * > /**
432
- * > * Validates PromptbookJson if it is logically valid.
432
+ * > * Validates PipelineJson if it is logically valid.
433
433
  * > *
434
434
  * > * It checks:
435
435
  * > * - it has a valid structure
436
436
  * > * - ...
437
- * > ex port function validatePromptbook(promptbook: unknown): asserts promptbook is PromptbookJson {
437
+ * > ex port function validatePipeline(promptbook: unknown): asserts promptbook is PipelineJson {
438
438
  */
439
439
 
440
- var promptbookLibrary = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.59.0",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.59.0",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
440
+ var PipelineCollection = [{title:"Prepare Keywords",promptbookUrl:"https://promptbook.studio/promptbook/prepare-keywords.ptbk.md",promptbookVersion:"0.60.0-2",parameters:[{name:"content",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, detect the important keywords in the document.\n\n# Rules\n\n- Write just keywords separated by comma\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"keywords"}],knowledge:[]},{title:"Prepare Knowledge from Markdown",promptbookUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md",promptbookVersion:"0.60.0-2",parameters:[{name:"content",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledge",description:"The knowledge JSON object",isInput:false,isOutput:true}],promptTemplates:[{name:"knowledge",title:"Knowledge",dependentParameterNames:["content"],executionType:"PROMPT_TEMPLATE",modelRequirements:{modelVariant:"CHAT",modelName:"claude-3-opus-20240229"},content:"You are experienced data researcher, extract the important knowledge from the document.\n\n# Rules\n\n- Make pieces of information concise, clear, and easy to understand\n- One piece of information should be approximately 1 paragraph\n- Divide the paragraphs by markdown horizontal lines ---\n- Omit irrelevant information\n- Group redundant information\n- Write just extracted information, nothing else\n\n# The document\n\nTake information from this document:\n\n> {content}",resultingParameterName:"knowledge"}],knowledge:[]}];
441
441
 
442
442
  /**
443
443
  * This error indicates errors during the execution of the promptbook
444
444
  */
445
- var PromptbookExecutionError = /** @class */ (function (_super) {
446
- __extends(PromptbookExecutionError, _super);
447
- function PromptbookExecutionError(message) {
445
+ var ExecutionError = /** @class */ (function (_super) {
446
+ __extends(ExecutionError, _super);
447
+ function ExecutionError(message) {
448
448
  var _this = _super.call(this, message) || this;
449
- _this.name = 'PromptbookExecutionError';
450
- Object.setPrototypeOf(_this, PromptbookExecutionError.prototype);
449
+ _this.name = 'ExecutionError';
450
+ Object.setPrototypeOf(_this, ExecutionError.prototype);
451
451
  return _this;
452
452
  }
453
- return PromptbookExecutionError;
453
+ return ExecutionError;
454
454
  }(Error));
455
455
 
456
456
  /**
457
457
  * Asserts that the execution of a promptnook is successful
458
458
  *
459
459
  * @param executionResult - The partial result of the promptnook execution
460
- * @throws {PromptbookExecutionError} If the execution is not successful or if multiple errors occurred
460
+ * @throws {ExecutionError} If the execution is not successful or if multiple errors occurred
461
461
  */
462
462
  function assertsExecutionSuccessful(executionResult) {
463
463
  var isSuccessful = executionResult.isSuccessful, errors = executionResult.errors;
@@ -465,13 +465,13 @@ function assertsExecutionSuccessful(executionResult) {
465
465
  return;
466
466
  }
467
467
  if (errors.length === 0) {
468
- throw new PromptbookExecutionError("Promptnook Execution failed because of unknown reason");
468
+ throw new ExecutionError("Promptnook Execution failed because of unknown reason");
469
469
  }
470
470
  else if (errors.length === 1) {
471
471
  throw errors[0];
472
472
  }
473
473
  else {
474
- throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
474
+ throw new ExecutionError(spaceTrim$1(function (block) { return "\n Multiple errors occurred during promptnook execution\n\n ".concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n')), "\n "); }));
475
475
  }
476
476
  }
477
477
  /**
@@ -481,8 +481,8 @@ function assertsExecutionSuccessful(executionResult) {
481
481
  /**
482
482
  * This error occurs when some expectation is not met in the execution of the pipeline
483
483
  *
484
- * @private Always catched and rethrown as `PromptbookExecutionError`
485
- * Note: This is a kindof subtype of PromptbookExecutionError
484
+ * @private Always catched and rethrown as `ExecutionError`
485
+ * Note: This is a kindof subtype of ExecutionError
486
486
  */
487
487
  var ExpectError = /** @class */ (function (_super) {
488
488
  __extends(ExpectError, _super);
@@ -970,7 +970,7 @@ function checkExpectations(expectations, value) {
970
970
  /**
971
971
  * This error occurs during the parameter replacement in the template
972
972
  *
973
- * Note: This is a kindof subtype of PromptbookExecutionError because it occurs during the execution of the pipeline
973
+ * Note: This is a kindof subtype of ExecutionError because it occurs during the execution of the pipeline
974
974
  */
975
975
  var TemplateError = /** @class */ (function (_super) {
976
976
  __extends(TemplateError, _super);
@@ -1047,13 +1047,13 @@ function replaceParameters(template, parameters) {
1047
1047
  * Creates executor function from promptbook and execution tools.
1048
1048
  *
1049
1049
  * @returns The executor function
1050
- * @throws {PromptbookLogicError} on logical error in the promptbook
1050
+ * @throws {PipelineLogicError} on logical error in the promptbook
1051
1051
  */
1052
1052
  function createPromptbookExecutor(options) {
1053
1053
  var _this = this;
1054
1054
  var promptbook = options.promptbook, tools = options.tools, _a = options.settings, settings = _a === void 0 ? {} : _a;
1055
1055
  var _b = settings.maxExecutionAttempts, maxExecutionAttempts = _b === void 0 ? 3 : _b;
1056
- validatePromptbook(promptbook);
1056
+ validatePipeline(promptbook);
1057
1057
  var promptbookExecutor = function (inputParameters, onProgress) { return __awaiter(_this, void 0, void 0, function () {
1058
1058
  function executeSingleTemplate(currentTemplate) {
1059
1059
  return __awaiter(this, void 0, void 0, function () {
@@ -1100,7 +1100,7 @@ function createPromptbookExecutor(options) {
1100
1100
  expectError = null;
1101
1101
  if (isJokerAttempt) {
1102
1102
  if (typeof parametersToPass[joker] === 'undefined') {
1103
- throw new PromptbookExecutionError("Joker parameter {".concat(joker, "} not defined"));
1103
+ throw new ExecutionError("Joker parameter {".concat(joker, "} not defined"));
1104
1104
  }
1105
1105
  resultString = parametersToPass[joker];
1106
1106
  }
@@ -1180,13 +1180,13 @@ function createPromptbookExecutor(options) {
1180
1180
  return [7 /*endfinally*/];
1181
1181
  case 10:
1182
1182
  if (errors.length === 0) {
1183
- throw new PromptbookExecutionError('Postprocessing in LlmExecutionTools failed because no ScriptExecutionTools were provided');
1183
+ throw new ExecutionError('Postprocessing in LlmExecutionTools failed because no ScriptExecutionTools were provided');
1184
1184
  }
1185
1185
  else if (errors.length === 1) {
1186
1186
  throw errors[0];
1187
1187
  }
1188
1188
  else {
1189
- throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n Postprocessing in LlmExecutionTools failed ".concat(errors.length, "x\n\n ").concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
1189
+ throw new ExecutionError(spaceTrim$1(function (block) { return "\n Postprocessing in LlmExecutionTools failed ".concat(errors.length, "x\n\n ").concat(block(errors.map(function (error) { return '- ' + error.message; }).join('\n\n')), "\n "); }));
1190
1190
  }
1191
1191
  }
1192
1192
  });
@@ -1198,27 +1198,27 @@ function createPromptbookExecutor(options) {
1198
1198
  case 'COMPLETION': return [3 /*break*/, 9];
1199
1199
  }
1200
1200
  return [3 /*break*/, 11];
1201
- case 7: return [4 /*yield*/, tools.llm.gptChat(prompt)];
1201
+ case 7: return [4 /*yield*/, tools.llm.callChatModel(prompt)];
1202
1202
  case 8:
1203
1203
  chatThread = _o.sent();
1204
1204
  // TODO: [🍬] Destroy chatThread
1205
1205
  result = chatThread;
1206
1206
  resultString = chatThread.content;
1207
1207
  return [3 /*break*/, 12];
1208
- case 9: return [4 /*yield*/, tools.llm.gptComplete(prompt)];
1208
+ case 9: return [4 /*yield*/, tools.llm.callCompletionModel(prompt)];
1209
1209
  case 10:
1210
1210
  completionResult = _o.sent();
1211
1211
  result = completionResult;
1212
1212
  resultString = completionResult.content;
1213
1213
  return [3 /*break*/, 12];
1214
- case 11: throw new PromptbookExecutionError("Unknown model variant \"".concat(currentTemplate.modelRequirements.modelVariant, "\""));
1214
+ case 11: throw new ExecutionError("Unknown model variant \"".concat(currentTemplate.modelRequirements.modelVariant, "\""));
1215
1215
  case 12: return [3 /*break*/, 27];
1216
1216
  case 13:
1217
1217
  if (tools.script.length === 0) {
1218
- throw new PromptbookExecutionError('No script execution tools are available');
1218
+ throw new ExecutionError('No script execution tools are available');
1219
1219
  }
1220
1220
  if (!currentTemplate.contentLanguage) {
1221
- throw new PromptbookExecutionError("Script language is not defined for prompt template \"".concat(currentTemplate.name, "\""));
1221
+ throw new ExecutionError("Script language is not defined for prompt template \"".concat(currentTemplate.name, "\""));
1222
1222
  }
1223
1223
  // TODO: DRY [1]
1224
1224
  scriptExecutionErrors = [];
@@ -1270,13 +1270,13 @@ function createPromptbookExecutor(options) {
1270
1270
  throw scriptExecutionErrors[0];
1271
1271
  }
1272
1272
  else {
1273
- throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat(scriptExecutionErrors.length, " times\n\n ").concat(block(scriptExecutionErrors
1273
+ throw new ExecutionError(spaceTrim$1(function (block) { return "\n Script execution failed ".concat(scriptExecutionErrors.length, " times\n\n ").concat(block(scriptExecutionErrors
1274
1274
  .map(function (error) { return '- ' + error.message; })
1275
1275
  .join('\n\n')), "\n "); }));
1276
1276
  }
1277
1277
  case 24:
1278
1278
  if (tools.userInterface === undefined) {
1279
- throw new PromptbookExecutionError('User interface tools are not available');
1279
+ throw new ExecutionError('User interface tools are not available');
1280
1280
  }
1281
1281
  return [4 /*yield*/, tools.userInterface.promptDialog({
1282
1282
  promptTitle: currentTemplate.title,
@@ -1290,7 +1290,7 @@ function createPromptbookExecutor(options) {
1290
1290
  // TODO: [🌹] When making next attempt for `PROMPT DIALOG`, preserve the previous user input
1291
1291
  resultString = _o.sent();
1292
1292
  return [3 /*break*/, 27];
1293
- case 26: throw new PromptbookExecutionError(
1293
+ case 26: throw new ExecutionError(
1294
1294
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1295
1295
  "Unknown execution type \"".concat(currentTemplate.executionType, "\""));
1296
1296
  case 27:
@@ -1415,7 +1415,7 @@ function createPromptbookExecutor(options) {
1415
1415
  return [7 /*endfinally*/];
1416
1416
  case 47:
1417
1417
  if (expectError !== null && attempt === maxAttempts - 1) {
1418
- throw new PromptbookExecutionError(spaceTrim$1(function (block) { return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ---\n Last error ").concat((expectError === null || expectError === void 0 ? void 0 : expectError.name) || '', ":\n ").concat(block((expectError === null || expectError === void 0 ? void 0 : expectError.message) || ''), "\n\n Last result:\n ").concat(resultString, "\n ---\n "); }));
1418
+ throw new ExecutionError(spaceTrim$1(function (block) { return "\n LLM execution failed ".concat(maxExecutionAttempts, "x\n\n ---\n Last error ").concat((expectError === null || expectError === void 0 ? void 0 : expectError.name) || '', ":\n ").concat(block((expectError === null || expectError === void 0 ? void 0 : expectError.message) || ''), "\n\n Last result:\n ").concat(resultString, "\n ---\n "); }));
1419
1419
  }
1420
1420
  _o.label = 48;
1421
1421
  case 48:
@@ -1484,7 +1484,7 @@ function createPromptbookExecutor(options) {
1484
1484
  return template.dependentParameterNames.every(function (name) { return resovedParameters_1.includes(name); });
1485
1485
  });
1486
1486
  if (!(!currentTemplate && resolving_1.length === 0)) return [3 /*break*/, 1];
1487
- throw new UnexpectedError(spaceTrim$1("\n Can not resolve some parameters\n\n Note: This should be catched during validatePromptbook\n "));
1487
+ throw new UnexpectedError(spaceTrim$1("\n Can not resolve some parameters\n\n Note: This should be catched during validatePipeline\n "));
1488
1488
  case 1:
1489
1489
  if (!!currentTemplate) return [3 /*break*/, 3];
1490
1490
  /* [5] */ return [4 /*yield*/, Promise.race(resolving_1)];
@@ -1617,16 +1617,16 @@ function capitalize(word) {
1617
1617
  /**
1618
1618
  * Converts promptbook in JSON format to string format
1619
1619
  *
1620
- * @param promptbookJson Promptbook in JSON format (.ptbk.json)
1620
+ * @param pipelineJson Promptbook in JSON format (.ptbk.json)
1621
1621
  * @returns Promptbook in string format (.ptbk.md)
1622
1622
  */
1623
- function promptbookJsonToString(promptbookJson) {
1623
+ function pipelineJsonToString(pipelineJson) {
1624
1624
  var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e, e_6, _f;
1625
- var title = promptbookJson.title, promptbookUrl = promptbookJson.promptbookUrl, promptbookVersion = promptbookJson.promptbookVersion, description = promptbookJson.description, parameters = promptbookJson.parameters, promptTemplates = promptbookJson.promptTemplates;
1626
- var promptbookString = "# ".concat(title);
1625
+ var title = pipelineJson.title, promptbookUrl = pipelineJson.promptbookUrl, promptbookVersion = pipelineJson.promptbookVersion, description = pipelineJson.description, parameters = pipelineJson.parameters, promptTemplates = pipelineJson.promptTemplates;
1626
+ var pipelineString = "# ".concat(title);
1627
1627
  if (description) {
1628
- promptbookString += '\n\n';
1629
- promptbookString += description;
1628
+ pipelineString += '\n\n';
1629
+ pipelineString += description;
1630
1630
  }
1631
1631
  // TODO:> const commands: Array<Command>
1632
1632
  var commands = [];
@@ -1634,7 +1634,7 @@ function promptbookJsonToString(promptbookJson) {
1634
1634
  commands.push("PROMPTBOOK URL ".concat(promptbookUrl));
1635
1635
  }
1636
1636
  commands.push("PROMPTBOOK VERSION ".concat(promptbookVersion));
1637
- promptbookString = prettifyMarkdown(promptbookString);
1637
+ pipelineString = prettifyMarkdown(pipelineString);
1638
1638
  try {
1639
1639
  for (var _g = __values(parameters.filter(function (_a) {
1640
1640
  var isInput = _a.isInput;
@@ -1667,8 +1667,8 @@ function promptbookJsonToString(promptbookJson) {
1667
1667
  }
1668
1668
  finally { if (e_2) throw e_2.error; }
1669
1669
  }
1670
- promptbookString += '\n\n';
1671
- promptbookString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1670
+ pipelineString += '\n\n';
1671
+ pipelineString += commands.map(function (command) { return "- ".concat(command); }).join('\n');
1672
1672
  try {
1673
1673
  for (var promptTemplates_1 = __values(promptTemplates), promptTemplates_1_1 = promptTemplates_1.next(); !promptTemplates_1_1.done; promptTemplates_1_1 = promptTemplates_1.next()) {
1674
1674
  var promptTemplate = promptTemplates_1_1.value;
@@ -1677,11 +1677,11 @@ function promptbookJsonToString(promptbookJson) {
1677
1677
  title_1 = promptTemplate.title, description_1 = promptTemplate.description,
1678
1678
  /* Note: dependentParameterNames, */
1679
1679
  jokers = promptTemplate.jokers, executionType = promptTemplate.executionType, content = promptTemplate.content, postprocessing = promptTemplate.postprocessing, expectations = promptTemplate.expectations, expectFormat = promptTemplate.expectFormat, resultingParameterName = promptTemplate.resultingParameterName;
1680
- promptbookString += '\n\n';
1681
- promptbookString += "## ".concat(title_1);
1680
+ pipelineString += '\n\n';
1681
+ pipelineString += "## ".concat(title_1);
1682
1682
  if (description_1) {
1683
- promptbookString += '\n\n';
1684
- promptbookString += description_1;
1683
+ pipelineString += '\n\n';
1684
+ pipelineString += description_1;
1685
1685
  }
1686
1686
  // TODO:> const commands: Array<Command>
1687
1687
  var commands_1 = [];
@@ -1775,18 +1775,18 @@ function promptbookJsonToString(promptbookJson) {
1775
1775
  commands_1.push("EXPECT JSON");
1776
1776
  }
1777
1777
  } /* not else */
1778
- promptbookString += '\n\n';
1779
- promptbookString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
1780
- promptbookString += '\n\n';
1781
- promptbookString += '```' + contentLanguage;
1782
- promptbookString += '\n';
1783
- promptbookString += spaceTrim(content);
1778
+ pipelineString += '\n\n';
1779
+ pipelineString += commands_1.map(function (command) { return "- ".concat(command); }).join('\n');
1780
+ pipelineString += '\n\n';
1781
+ pipelineString += '```' + contentLanguage;
1782
+ pipelineString += '\n';
1783
+ pipelineString += spaceTrim(content);
1784
1784
  // <- TODO: !!! Escape
1785
1785
  // <- TODO: [🧠] Some clear strategy how to spaceTrim the blocks
1786
- promptbookString += '\n';
1787
- promptbookString += '```';
1788
- promptbookString += '\n\n';
1789
- promptbookString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1786
+ pipelineString += '\n';
1787
+ pipelineString += '```';
1788
+ pipelineString += '\n\n';
1789
+ pipelineString += "`-> {".concat(resultingParameterName, "}`"); // <- TODO: !!! If the parameter here has description, add it and use promptTemplateParameterJsonToString
1790
1790
  }
1791
1791
  }
1792
1792
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -1796,10 +1796,10 @@ function promptbookJsonToString(promptbookJson) {
1796
1796
  }
1797
1797
  finally { if (e_3) throw e_3.error; }
1798
1798
  }
1799
- return promptbookString;
1799
+ return pipelineString;
1800
1800
  }
1801
1801
  /**
1802
- * @private internal util of promptbookJsonToString
1802
+ * @private internal util of pipelineJsonToString
1803
1803
  */
1804
1804
  function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
1805
1805
  var name = promptTemplateParameterJson.name, description = promptTemplateParameterJson.description;
@@ -1816,49 +1816,49 @@ function promptTemplateParameterJsonToString(promptTemplateParameterJson) {
1816
1816
  /**
1817
1817
  * This error indicates that promptbook not found in the library
1818
1818
  */
1819
- var PromptbookNotFoundError = /** @class */ (function (_super) {
1820
- __extends(PromptbookNotFoundError, _super);
1821
- function PromptbookNotFoundError(message) {
1819
+ var NotFoundError = /** @class */ (function (_super) {
1820
+ __extends(NotFoundError, _super);
1821
+ function NotFoundError(message) {
1822
1822
  var _this = _super.call(this, message) || this;
1823
- _this.name = 'PromptbookNotFoundError';
1824
- Object.setPrototypeOf(_this, PromptbookNotFoundError.prototype);
1823
+ _this.name = 'NotFoundError';
1824
+ Object.setPrototypeOf(_this, NotFoundError.prototype);
1825
1825
  return _this;
1826
1826
  }
1827
- return PromptbookNotFoundError;
1827
+ return NotFoundError;
1828
1828
  }(Error));
1829
1829
 
1830
1830
  /**
1831
1831
  * This error indicates errors in referencing promptbooks between each other
1832
1832
  */
1833
- var PromptbookReferenceError = /** @class */ (function (_super) {
1834
- __extends(PromptbookReferenceError, _super);
1835
- function PromptbookReferenceError(message) {
1833
+ var ReferenceError$1 = /** @class */ (function (_super) {
1834
+ __extends(ReferenceError, _super);
1835
+ function ReferenceError(message) {
1836
1836
  var _this = _super.call(this, message) || this;
1837
- _this.name = 'PromptbookReferenceError';
1838
- Object.setPrototypeOf(_this, PromptbookReferenceError.prototype);
1837
+ _this.name = 'ReferenceError';
1838
+ Object.setPrototypeOf(_this, ReferenceError.prototype);
1839
1839
  return _this;
1840
1840
  }
1841
- return PromptbookReferenceError;
1841
+ return ReferenceError;
1842
1842
  }(Error));
1843
1843
 
1844
1844
  /**
1845
1845
  * Library of promptbooks that groups together promptbooks for an application.
1846
1846
  * This implementation is a very thin wrapper around the Array / Map of promptbooks.
1847
1847
  *
1848
- * @private use `createLibraryFromJson` instead
1849
- * @see https://github.com/webgptorg/promptbook#promptbook-library
1848
+ * @private use `createCollectionFromJson` instead
1849
+ * @see https://github.com/webgptorg/promptbook#promptbook-collection
1850
1850
  */
1851
- var SimplePromptbookLibrary = /** @class */ (function () {
1851
+ var SimplePipelineCollection = /** @class */ (function () {
1852
1852
  /**
1853
1853
  * Constructs a promptbook library from promptbooks
1854
1854
  *
1855
1855
  * @param promptbooks !!!
1856
1856
  *
1857
- * @private Use instead `createLibraryFromJson`
1857
+ * @private Use instead `createCollectionFromJson`
1858
1858
  * Note: During the construction logic of all promptbooks are validated
1859
- * Note: It is not recommended to use this constructor directly, use `createLibraryFromJson` *(or other variant)* instead
1859
+ * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
1860
1860
  */
1861
- function SimplePromptbookLibrary() {
1861
+ function SimplePipelineCollection() {
1862
1862
  var e_1, _a;
1863
1863
  var promptbooks = [];
1864
1864
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1869,14 +1869,13 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1869
1869
  for (var promptbooks_1 = __values(promptbooks), promptbooks_1_1 = promptbooks_1.next(); !promptbooks_1_1.done; promptbooks_1_1 = promptbooks_1.next()) {
1870
1870
  var promptbook = promptbooks_1_1.value;
1871
1871
  if (promptbook.promptbookUrl === undefined) {
1872
- throw new PromptbookReferenceError(spaceTrim$1("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1872
+ throw new ReferenceError$1(spaceTrim$1("\n Promptbook with name \"".concat(promptbook.title, "\" does not have defined URL\n\n Note: Promptbooks without URLs are called anonymous promptbooks\n They can be used as standalone promptbooks, but they cannot be referenced by other promptbooks\n And also they cannot be used in the promptbook library\n\n ")));
1873
1873
  }
1874
- validatePromptbook(promptbook);
1874
+ validatePipeline(promptbook);
1875
1875
  // Note: [🦄]
1876
1876
  if (this.library.has(promptbook.promptbookUrl) &&
1877
- promptbookJsonToString(promptbook) !==
1878
- promptbookJsonToString(this.library.get(promptbook.promptbookUrl))) {
1879
- throw new PromptbookReferenceError(spaceTrim$1("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
1877
+ pipelineJsonToString(promptbook) !== pipelineJsonToString(this.library.get(promptbook.promptbookUrl))) {
1878
+ throw new ReferenceError$1(spaceTrim$1("\n Promptbook with URL \"".concat(promptbook.promptbookUrl, "\" is already in the library\n\n Note: Promptbooks with the same URL are not allowed\n Note: Automatically check whether the promptbooks are the same BUT they are DIFFERENT\n\n ")));
1880
1879
  }
1881
1880
  this.library.set(promptbook.promptbookUrl, promptbook);
1882
1881
  }
@@ -1892,7 +1891,7 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1892
1891
  /**
1893
1892
  * Gets all promptbooks in the library
1894
1893
  */
1895
- SimplePromptbookLibrary.prototype.listPromptbooks = function () {
1894
+ SimplePipelineCollection.prototype.listPipelines = function () {
1896
1895
  return Array.from(this.library.keys());
1897
1896
  };
1898
1897
  /**
@@ -1900,14 +1899,14 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1900
1899
  *
1901
1900
  * Note: This is not a direct fetching from the URL, but a lookup in the library
1902
1901
  */
1903
- SimplePromptbookLibrary.prototype.getPromptbookByUrl = function (url) {
1902
+ SimplePipelineCollection.prototype.getPipelineByUrl = function (url) {
1904
1903
  var _this = this;
1905
1904
  var promptbook = this.library.get(url);
1906
1905
  if (!promptbook) {
1907
- if (this.listPromptbooks().length === 0) {
1908
- throw new PromptbookNotFoundError(spaceTrim$1("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
1906
+ if (this.listPipelines().length === 0) {
1907
+ throw new NotFoundError(spaceTrim$1("\n Promptbook with url \"".concat(url, "\" not found\n\n No promptbooks available\n ")));
1909
1908
  }
1910
- throw new PromptbookNotFoundError(spaceTrim$1(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPromptbooks()
1909
+ throw new NotFoundError(spaceTrim$1(function (block) { return "\n Promptbook with url \"".concat(url, "\" not found\n\n Available promptbooks:\n ").concat(block(_this.listPipelines()
1911
1910
  .map(function (promptbookUrl) { return "- ".concat(promptbookUrl); })
1912
1911
  .join('\n')), "\n\n "); }));
1913
1912
  }
@@ -1916,27 +1915,27 @@ var SimplePromptbookLibrary = /** @class */ (function () {
1916
1915
  /**
1917
1916
  * Checks whether given prompt was defined in any promptbook in the library
1918
1917
  */
1919
- SimplePromptbookLibrary.prototype.isResponsibleForPrompt = function (prompt) {
1918
+ SimplePipelineCollection.prototype.isResponsibleForPrompt = function (prompt) {
1920
1919
  return true;
1921
1920
  };
1922
- return SimplePromptbookLibrary;
1921
+ return SimplePipelineCollection;
1923
1922
  }());
1924
1923
 
1925
1924
  /**
1926
- * Creates PromptbookLibrary from array of PromptbookJson or PromptbookString
1925
+ * Creates PipelineCollection from array of PipelineJson or PipelineString
1927
1926
  *
1928
- * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
1927
+ * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
1929
1928
  * Note: During the construction syntax and logic of all sources are validated
1930
1929
  *
1931
1930
  * @param promptbookSources
1932
- * @returns PromptbookLibrary
1931
+ * @returns PipelineCollection
1933
1932
  */
1934
- function createLibraryFromJson() {
1933
+ function createCollectionFromJson() {
1935
1934
  var promptbooks = [];
1936
1935
  for (var _i = 0; _i < arguments.length; _i++) {
1937
1936
  promptbooks[_i] = arguments[_i];
1938
1937
  }
1939
- return new (SimplePromptbookLibrary.bind.apply(SimplePromptbookLibrary, __spreadArray([void 0], __read(promptbooks), false)))();
1938
+ return new (SimplePipelineCollection.bind.apply(SimplePipelineCollection, __spreadArray([void 0], __read(promptbooks), false)))();
1940
1939
  }
1941
1940
 
1942
1941
  /* tslint:disable */
@@ -2002,8 +2001,8 @@ function prepareKnowledgeFromMarkdown(options) {
2002
2001
  switch (_b.label) {
2003
2002
  case 0:
2004
2003
  content = options.content, llmTools = options.llmTools, _a = options.isVerbose, isVerbose = _a === void 0 ? false : _a;
2005
- library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookLibrary), false));
2006
- return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
2004
+ library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(PipelineCollection), false));
2005
+ return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.ptbk.md')];
2007
2006
  case 1:
2008
2007
  prepareKnowledgeFromMarkdownPromptbook = _b.sent();
2009
2008
  prepareKnowledgeFromMarkdownExecutor = createPromptbookExecutor({
@@ -2015,7 +2014,7 @@ function prepareKnowledgeFromMarkdown(options) {
2015
2014
  ],
2016
2015
  },
2017
2016
  });
2018
- return [4 /*yield*/, library.getPromptbookByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
2017
+ return [4 /*yield*/, library.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-keywords.ptbk.md')];
2019
2018
  case 2:
2020
2019
  prepareKeywordsPromptbook = _b.sent();
2021
2020
  prepareKeywordsExecutor = createPromptbookExecutor({
@@ -2104,7 +2103,7 @@ var SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
2104
2103
  /**
2105
2104
  * Computes the deepness of the markdown structure.
2106
2105
  *
2107
- * @private within the library
2106
+ * @private within the package
2108
2107
  */
2109
2108
  function countMarkdownStructureDeepness(markdownStructure) {
2110
2109
  var e_1, _a;
@@ -2134,7 +2133,7 @@ function countMarkdownStructureDeepness(markdownStructure) {
2134
2133
  * @param markdown The markdown string to parse.
2135
2134
  * @returns The MarkdownStructure object.
2136
2135
  *
2137
- * @private within the library
2136
+ * @private within the package
2138
2137
  */
2139
2138
  function markdownToMarkdownStructure(markdown) {
2140
2139
  var e_1, _a;
@@ -2409,7 +2408,7 @@ function extractParameters(template) {
2409
2408
  *
2410
2409
  * @param script from which to extract the variables
2411
2410
  * @returns the list of variable names
2412
- * @throws {PromptbookSyntaxError} if the script is invalid
2411
+ * @throws {SyntaxError} if the script is invalid
2413
2412
  */
2414
2413
  function extractVariables(script) {
2415
2414
  var variables = new Set();
@@ -2445,7 +2444,7 @@ function extractVariables(script) {
2445
2444
  if (!(error instanceof Error)) {
2446
2445
  throw error;
2447
2446
  }
2448
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
2447
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Can not extract variables from the script\n\n ".concat(block(error.name), ": ").concat(block(error.message), "\n "); }));
2449
2448
  }
2450
2449
  return variables;
2451
2450
  }
@@ -2458,7 +2457,7 @@ function extractVariables(script) {
2458
2457
  *
2459
2458
  * @param promptTemplate the template with used parameters
2460
2459
  * @returns the set of parameter names
2461
- * @throws {PromptbookSyntaxError} if the script is invalid
2460
+ * @throws {SyntaxError} if the script is invalid
2462
2461
  */
2463
2462
  function extractParametersFromPromptTemplate(promptTemplate) {
2464
2463
  var e_1, _a, e_2, _b;
@@ -2497,6 +2496,45 @@ function extractParametersFromPromptTemplate(promptTemplate) {
2497
2496
  * TODO: [🔣] If script require contentLanguage
2498
2497
  */
2499
2498
 
2499
+ /**
2500
+ * Execution type describes the way how the block is executed
2501
+ *
2502
+ * @see https://github.com/webgptorg/promptbook#execution-type
2503
+ */
2504
+ var ExecutionTypes = [
2505
+ 'PROMPT_TEMPLATE',
2506
+ 'SIMPLE_TEMPLATE',
2507
+ 'SCRIPT',
2508
+ 'PROMPT_DIALOG',
2509
+ // <- [🥻] Insert here when making new command
2510
+ ];
2511
+
2512
+ /**
2513
+ * Units of text measurement
2514
+ */
2515
+ var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
2516
+ /**
2517
+ * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
2518
+ * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
2519
+ * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
2520
+ */
2521
+
2522
+ /**
2523
+ * Removes Markdown formatting tags from a string.
2524
+ *
2525
+ * @param {string} str - The string to remove Markdown tags from.
2526
+ * @returns {string} The input string with all Markdown tags removed.
2527
+ */
2528
+ function removeMarkdownFormatting(str) {
2529
+ // Remove bold formatting
2530
+ str = str.replace(/\*\*(.*?)\*\*/g, '$1');
2531
+ // Remove italic formatting
2532
+ str = str.replace(/\*(.*?)\*/g, '$1');
2533
+ // Remove code formatting
2534
+ str = str.replace(/`(.*?)`/g, '$1');
2535
+ return str;
2536
+ }
2537
+
2500
2538
  /* tslint:disable */
2501
2539
  /*
2502
2540
  TODO: Tests
@@ -2561,45 +2599,6 @@ function normalizeTo_SCREAMING_CASE(sentence) {
2561
2599
  * TODO: [🌺] Use some intermediate util splitWords
2562
2600
  */
2563
2601
 
2564
- /**
2565
- * Execution type describes the way how the block is executed
2566
- *
2567
- * @see https://github.com/webgptorg/promptbook#execution-type
2568
- */
2569
- var ExecutionTypes = [
2570
- 'PROMPT_TEMPLATE',
2571
- 'SIMPLE_TEMPLATE',
2572
- 'SCRIPT',
2573
- 'PROMPT_DIALOG',
2574
- // <- [🥻] Insert here when making new command
2575
- ];
2576
-
2577
- /**
2578
- * Units of text measurement
2579
- */
2580
- var EXPECTATION_UNITS = ['CHARACTERS', 'WORDS', 'SENTENCES', 'LINES', 'PARAGRAPHS', 'PAGES'];
2581
- /**
2582
- * TODO: [💝] Unite object for expecting amount and format - remove expectFormat
2583
- * TODO: use one helper type> (string_prompt | string_javascript | string_markdown) & string_template
2584
- * TODO: [👙][🧠] Just selecting gpt3 or gpt4 level of model
2585
- */
2586
-
2587
- /**
2588
- * Removes Markdown formatting tags from a string.
2589
- *
2590
- * @param {string} str - The string to remove Markdown tags from.
2591
- * @returns {string} The input string with all Markdown tags removed.
2592
- */
2593
- function removeMarkdownFormatting(str) {
2594
- // Remove bold formatting
2595
- str = str.replace(/\*\*(.*?)\*\*/g, '$1');
2596
- // Remove italic formatting
2597
- str = str.replace(/\*(.*?)\*/g, '$1');
2598
- // Remove code formatting
2599
- str = str.replace(/`(.*?)`/g, '$1');
2600
- return str;
2601
- }
2602
-
2603
2602
  /**
2604
2603
  * Function parseNumber will parse number from string
2605
2604
  *
@@ -2607,7 +2606,7 @@ function removeMarkdownFormatting(str) {
2607
2606
  * Note: it also works only with decimal numbers
2608
2607
  *
2609
2608
  * @returns parsed number
2610
- * @throws {PromptbookSyntaxError} if the value is not a number
2609
+ * @throws {SyntaxError} if the value is not a number
2611
2610
  *
2612
2611
  * @private within the parseCommand
2613
2612
  */
@@ -2643,7 +2642,7 @@ function parseNumber(value) {
2643
2642
  var numerator = parseNumber(numerator_);
2644
2643
  var denominator = parseNumber(denominator_);
2645
2644
  if (denominator === 0) {
2646
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
2645
+ throw new SyntaxError("Unable to parse number from \"".concat(originalValue, "\" because denominator is zero"));
2647
2646
  }
2648
2647
  return numerator / denominator;
2649
2648
  }
@@ -2655,11 +2654,11 @@ function parseNumber(value) {
2655
2654
  return parseNumber(significand) * Math.pow(10, parseNumber(exponent));
2656
2655
  }
2657
2656
  if (!/^[0-9.]+$/.test(value) || value.split('.').length > 2) {
2658
- throw new PromptbookSyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
2657
+ throw new SyntaxError("Unable to parse number from \"".concat(originalValue, "\""));
2659
2658
  }
2660
2659
  var num = parseFloat(value);
2661
2660
  if (isNaN(num)) {
2662
- throw new PromptbookSyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
2661
+ throw new SyntaxError("Unexpected NaN when parsing number from \"".concat(originalValue, "\""));
2663
2662
  }
2664
2663
  return num;
2665
2664
  }
@@ -2671,14 +2670,14 @@ function parseNumber(value) {
2671
2670
  * Parses one line of ul/ol to command
2672
2671
  *
2673
2672
  * @returns parsed command object
2674
- * @throws {PromptbookSyntaxError} if the command is invalid
2673
+ * @throws {SyntaxError} if the command is invalid
2675
2674
  *
2676
- * @private within the promptbookStringToJson
2675
+ * @private within the pipelineStringToJson
2677
2676
  */
2678
2677
  function parseCommand(listItem) {
2679
2678
  var e_1, _a;
2680
2679
  if (listItem.includes('\n') || listItem.includes('\r')) {
2681
- throw new PromptbookSyntaxError('Command can not contain new line characters:');
2680
+ throw new SyntaxError('Command can not contain new line characters:');
2682
2681
  }
2683
2682
  var type = listItem.trim();
2684
2683
  type = type.split('`').join('');
@@ -2705,15 +2704,15 @@ function parseCommand(listItem) {
2705
2704
  type.startsWith('PROMPTBOOKURL') ||
2706
2705
  type.startsWith('HTTPS')) {
2707
2706
  if (!(listItemParts.length === 2 || (listItemParts.length === 1 && type.startsWith('HTTPS')))) {
2708
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2707
+ throw new SyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n ")));
2709
2708
  }
2710
2709
  var promptbookUrlString = listItemParts.pop();
2711
2710
  var promptbookUrl = new URL(promptbookUrlString);
2712
2711
  if (promptbookUrl.protocol !== 'https:') {
2713
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2712
+ throw new SyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n Protocol must be HTTPS\n ")));
2714
2713
  }
2715
2714
  if (promptbookUrl.hash !== '') {
2716
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2715
+ throw new SyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_URL command:\n\n - ".concat(listItem, "\n\n URL must not contain hash\n Hash is used for identification of the prompt template in the pipeline\n ")));
2717
2716
  }
2718
2717
  return {
2719
2718
  type: 'PROMPTBOOK_URL',
@@ -2722,7 +2721,7 @@ function parseCommand(listItem) {
2722
2721
  }
2723
2722
  else if (type.startsWith('PROMPTBOOK_VERSION') || type.startsWith('PTBK_VERSION')) {
2724
2723
  if (listItemParts.length !== 2) {
2725
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
2724
+ throw new SyntaxError(spaceTrim$1("\n Invalid PROMPTBOOK_VERSION command:\n\n - ".concat(listItem, "\n ")));
2726
2725
  }
2727
2726
  var promptbookVersion = listItemParts.pop();
2728
2727
  // TODO: Validate version
@@ -2737,7 +2736,7 @@ function parseCommand(listItem) {
2737
2736
  type.startsWith('SIMPLE_TEMPLATE')) {
2738
2737
  var executionTypes = ExecutionTypes.filter(function (executionType) { return type.includes(executionType); });
2739
2738
  if (executionTypes.length !== 1) {
2740
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
2739
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Unknown execution type in command:\n\n - ".concat(listItem, "\n\n Supported execution types are:\n ").concat(block(ExecutionTypes.join(', ')), "\n "); }));
2741
2740
  }
2742
2741
  return {
2743
2742
  type: 'EXECUTE',
@@ -2762,7 +2761,7 @@ function parseCommand(listItem) {
2762
2761
  };
2763
2762
  }
2764
2763
  else {
2765
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
2764
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Unknown model variant in command:\n\n - ".concat(listItem, "\n\n Supported variants are:\n ").concat(block(['CHAT', 'COMPLETION'].join(', ')), "\n "); }));
2766
2765
  }
2767
2766
  }
2768
2767
  if (type.startsWith('MODEL_NAME')) {
@@ -2773,7 +2772,7 @@ function parseCommand(listItem) {
2773
2772
  };
2774
2773
  }
2775
2774
  else {
2776
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
2775
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Unknown model key in command:\n\n - ".concat(listItem, "\n\n Supported model keys are:\n ").concat(block(['variant', 'name'].join(', ')), "\n\n Example:\n\n - MODEL VARIANT Chat\n - MODEL NAME gpt-4\n "); }));
2777
2776
  }
2778
2777
  }
2779
2778
  else if (type.startsWith('PARAM') ||
@@ -2783,12 +2782,12 @@ function parseCommand(listItem) {
2783
2782
  listItem.startsWith('> {') /* <- Note: This is a bit hack to parse return parameters defined at the end of each section */) {
2784
2783
  var parametersMatch = listItem.match(/\{(?<parameterName>[a-z0-9_]+)\}[^\S\r\n]*(?<parameterDescription>.*)$/im);
2785
2784
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
2786
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2785
+ throw new SyntaxError(spaceTrim$1("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2787
2786
  }
2788
2787
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2789
2788
  var _b = parametersMatch.groups, parameterName = _b.parameterName, parameterDescription = _b.parameterDescription;
2790
2789
  if (parameterDescription && parameterDescription.match(/\{(?<parameterName>[a-z0-9_]+)\}/im)) {
2791
- throw new PromptbookSyntaxError(spaceTrim$1("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
2790
+ throw new SyntaxError(spaceTrim$1("\n Parameter {".concat(parameterName, "} can not contain another parameter in description:\n\n - ").concat(listItem, "\n ")));
2792
2791
  }
2793
2792
  var isInput = type.startsWith('INPUT');
2794
2793
  var isOutput = type.startsWith('OUTPUT');
@@ -2806,11 +2805,11 @@ function parseCommand(listItem) {
2806
2805
  }
2807
2806
  else if (type.startsWith('JOKER')) {
2808
2807
  if (listItemParts.length !== 2) {
2809
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
2808
+ throw new SyntaxError(spaceTrim$1("\n Invalid JOKER command:\n\n - ".concat(listItem, "\n ")));
2810
2809
  }
2811
2810
  var parametersMatch = (listItemParts.pop() || '').match(/^\{(?<parameterName>[a-z0-9_]+)\}$/im);
2812
2811
  if (!parametersMatch || !parametersMatch.groups || !parametersMatch.groups.parameterName) {
2813
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2812
+ throw new SyntaxError(spaceTrim$1("\n Invalid parameter in command:\n\n - ".concat(listItem, "\n ")));
2814
2813
  }
2815
2814
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2816
2815
  var parameterName = parametersMatch.groups.parameterName;
@@ -2821,7 +2820,7 @@ function parseCommand(listItem) {
2821
2820
  }
2822
2821
  else if (type.startsWith('POSTPROCESS') || type.startsWith('POST_PROCESS')) {
2823
2822
  if (listItemParts.length !== 2) {
2824
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
2823
+ throw new SyntaxError(spaceTrim$1("\n Invalid POSTPROCESSING command:\n\n - ".concat(listItem, "\n ")));
2825
2824
  }
2826
2825
  var functionName = listItemParts.pop();
2827
2826
  return {
@@ -2851,15 +2850,15 @@ function parseCommand(listItem) {
2851
2850
  sign = 'MAXIMUM';
2852
2851
  }
2853
2852
  else {
2854
- throw new PromptbookSyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
2853
+ throw new SyntaxError("Invalid sign \"".concat(signRaw, "\", expected EXACTLY, MIN or MAX"));
2855
2854
  }
2856
2855
  var amountRaw = listItemParts.shift();
2857
2856
  var amount = parseNumber(amountRaw);
2858
2857
  if (amount < 0) {
2859
- throw new PromptbookSyntaxError('Amount must be positive number or zero');
2858
+ throw new SyntaxError('Amount must be positive number or zero');
2860
2859
  }
2861
2860
  if (amount !== Math.floor(amount)) {
2862
- throw new PromptbookSyntaxError('Amount must be whole number');
2861
+ throw new SyntaxError('Amount must be whole number');
2863
2862
  }
2864
2863
  var unitRaw = listItemParts.shift();
2865
2864
  var unit = undefined;
@@ -2874,7 +2873,7 @@ function parseCommand(listItem) {
2874
2873
  if (new RegExp("^".concat(existingUnitText.toLowerCase())).test(unitRaw.toLowerCase()) ||
2875
2874
  new RegExp("^".concat(unitRaw.toLowerCase())).test(existingUnitText.toLowerCase())) {
2876
2875
  if (unit !== undefined) {
2877
- throw new PromptbookSyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
2876
+ throw new SyntaxError("Ambiguous unit \"".concat(unitRaw, "\""));
2878
2877
  }
2879
2878
  unit = existingUnit;
2880
2879
  }
@@ -2888,7 +2887,7 @@ function parseCommand(listItem) {
2888
2887
  finally { if (e_1) throw e_1.error; }
2889
2888
  }
2890
2889
  if (unit === undefined) {
2891
- throw new PromptbookSyntaxError("Invalid unit \"".concat(unitRaw, "\""));
2890
+ throw new SyntaxError("Invalid unit \"".concat(unitRaw, "\""));
2892
2891
  }
2893
2892
  return {
2894
2893
  type: 'EXPECT_AMOUNT',
@@ -2901,7 +2900,7 @@ function parseCommand(listItem) {
2901
2900
  if (!(error instanceof Error)) {
2902
2901
  throw error;
2903
2902
  }
2904
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
2903
+ throw new SyntaxError(spaceTrim$1("\n Invalid EXPECT command; ".concat(error.message, ":\n\n - ").concat(listItem, "\n ")));
2905
2904
  }
2906
2905
  /*
2907
2906
  } else if (type.startsWith('__________________')) {
@@ -2909,7 +2908,7 @@ function parseCommand(listItem) {
2909
2908
  */
2910
2909
  }
2911
2910
  else {
2912
- throw new PromptbookSyntaxError(spaceTrim$1("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
2911
+ throw new SyntaxError(spaceTrim$1("\n Unknown command:\n\n - ".concat(listItem, "\n\n Supported commands are:\n - PROMPTBOOK_URL <url>\n - PROMPTBOOK_VERSION <version>\n - EXECUTE PROMPT TEMPLATE\n - EXECUTE SIMPLE TEMPLATE\n - SIMPLE TEMPLATE\n - EXECUTE SCRIPT\n - EXECUTE PROMPT_DIALOG'\n - PROMPT_DIALOG'\n - MODEL NAME <name>\n - MODEL VARIANT <\"Chat\"|\"Completion\">\n - INPUT PARAM {<name>} <description>\n - OUTPUT PARAM {<name>} <description>\n - POSTPROCESS `{functionName}`\n - JOKER {<name>}\n - EXPECT JSON\n - EXPECT <\"Exactly\"|\"Min\"|\"Max\"> <number> <\"Chars\"|\"Words\"|\"Sentences\"|\"Paragraphs\"|\"Pages\">\n\n ")));
2913
2912
  }
2914
2913
  }
2915
2914
 
@@ -2942,20 +2941,20 @@ function titleToName(value) {
2942
2941
  * Compile promptbook from string (markdown) format to JSON format synchronously
2943
2942
  *
2944
2943
  * Note: There are two similar functions:
2945
- * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2946
- * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2944
+ * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
2945
+ * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
2947
2946
  *
2948
- * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
2947
+ * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
2949
2948
  * @param options - Options and tools for the compilation
2950
2949
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
2951
- * @throws {PromptbookSyntaxError} if the promptbook string is not valid
2950
+ * @throws {SyntaxError} if the promptbook string is not valid
2952
2951
  *
2953
2952
  * Note: This function does not validate logic of the pipeline only the syntax
2954
2953
  * Note: This function acts as compilation process
2955
2954
  */
2956
- function promptbookStringToJsonSync(promptbookString) {
2955
+ function pipelineStringToJsonSync(pipelineString) {
2957
2956
  var e_1, _a, e_2, _b;
2958
- var promptbookJson = {
2957
+ var pipelineJson = {
2959
2958
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2960
2959
  title: undefined /* <- Note: Putting here placeholder to keep `title` on top at final JSON */,
2961
2960
  promptbookUrl: undefined /* <- Note: Putting here placeholder to keep `promptbookUrl` on top at final JSON */,
@@ -2967,19 +2966,19 @@ function promptbookStringToJsonSync(promptbookString) {
2967
2966
  };
2968
2967
  // =============================================================
2969
2968
  // Note: 1️⃣ Normalization of the PROMPTBOOK string
2970
- promptbookString = removeContentComments(promptbookString);
2971
- promptbookString = promptbookString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2972
- promptbookString = promptbookString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2969
+ pipelineString = removeContentComments(pipelineString);
2970
+ pipelineString = pipelineString.replaceAll(/`\{(?<parameterName>[a-z0-9_]+)\}`/gi, '{$<parameterName>}');
2971
+ pipelineString = pipelineString.replaceAll(/`->\s+\{(?<parameterName>[a-z0-9_]+)\}`/gi, '-> {$<parameterName>}');
2973
2972
  // =============================================================
2974
2973
  ///Note: 2️⃣ Function for adding parameters
2975
2974
  var addParam = function (parameterCommand) {
2976
2975
  var parameterName = parameterCommand.parameterName, parameterDescription = parameterCommand.parameterDescription, isInput = parameterCommand.isInput, isOutput = parameterCommand.isOutput;
2977
- var existingParameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2976
+ var existingParameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
2978
2977
  if (existingParameter &&
2979
2978
  existingParameter.description &&
2980
2979
  existingParameter.description !== parameterDescription &&
2981
2980
  parameterDescription) {
2982
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
2981
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Parameter {".concat(parameterName, "} is defined multiple times with different description.\n\n First definition:\n ").concat(block(existingParameter.description || '[undefined]'), "\n\n Second definition:\n ").concat(block(parameterDescription || '[undefined]'), "\n "); }));
2983
2982
  }
2984
2983
  if (existingParameter) {
2985
2984
  if (parameterDescription) {
@@ -2987,7 +2986,7 @@ function promptbookStringToJsonSync(promptbookString) {
2987
2986
  }
2988
2987
  }
2989
2988
  else {
2990
- promptbookJson.parameters.push({
2989
+ pipelineJson.parameters.push({
2991
2990
  name: parameterName,
2992
2991
  description: parameterDescription || undefined,
2993
2992
  isInput: isInput,
@@ -2996,13 +2995,13 @@ function promptbookStringToJsonSync(promptbookString) {
2996
2995
  }
2997
2996
  };
2998
2997
  // =============================================================
2999
- // Note: 3️⃣ Parse the dynamic part - the template pipeline
3000
- var markdownStructure = markdownToMarkdownStructure(promptbookString);
2998
+ // Note: 3️⃣ Parse the dynamic part - the pipeline
2999
+ var markdownStructure = markdownToMarkdownStructure(pipelineString);
3001
3000
  var markdownStructureDeepness = countMarkdownStructureDeepness(markdownStructure);
3002
3001
  if (markdownStructureDeepness !== 2) {
3003
- throw new PromptbookSyntaxError(spaceTrim$1("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
3002
+ throw new SyntaxError(spaceTrim$1("\n Invalid markdown structure.\n The markdown must have exactly 2 levels of headings (one top-level section and one section for each template).\n Now it has ".concat(markdownStructureDeepness, " levels of headings.\n ")));
3004
3003
  }
3005
- promptbookJson.title = markdownStructure.title;
3004
+ pipelineJson.title = markdownStructure.title;
3006
3005
  // TODO: [1] DRY description
3007
3006
  var description = markdownStructure.content;
3008
3007
  // Note: Remove codeblocks
@@ -3013,7 +3012,7 @@ function promptbookStringToJsonSync(promptbookString) {
3013
3012
  if (description === '') {
3014
3013
  description = undefined;
3015
3014
  }
3016
- promptbookJson.description = description;
3015
+ pipelineJson.description = description;
3017
3016
  var defaultModelRequirements = {};
3018
3017
  var listItems = extractAllListItemsFromMarkdown(markdownStructure.content);
3019
3018
  try {
@@ -3022,10 +3021,10 @@ function promptbookStringToJsonSync(promptbookString) {
3022
3021
  var command = parseCommand(listItem);
3023
3022
  switch (command.type) {
3024
3023
  case 'PROMPTBOOK_URL':
3025
- promptbookJson.promptbookUrl = command.promptbookUrl.href;
3024
+ pipelineJson.promptbookUrl = command.promptbookUrl.href;
3026
3025
  break;
3027
3026
  case 'PROMPTBOOK_VERSION':
3028
- promptbookJson.promptbookVersion = command.promptbookVersion;
3027
+ pipelineJson.promptbookVersion = command.promptbookVersion;
3029
3028
  break;
3030
3029
  case 'MODEL':
3031
3030
  defaultModelRequirements[command.key] = command.value;
@@ -3034,7 +3033,7 @@ function promptbookStringToJsonSync(promptbookString) {
3034
3033
  addParam(command);
3035
3034
  break;
3036
3035
  default:
3037
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
3036
+ throw new SyntaxError("Command ".concat(command.type, " is not allowed in the head of the promptbook ONLY at the prompt template block"));
3038
3037
  }
3039
3038
  }
3040
3039
  }
@@ -3068,7 +3067,7 @@ function promptbookStringToJsonSync(promptbookString) {
3068
3067
  break;
3069
3068
  case 'EXECUTE':
3070
3069
  if (isExecutionTypeChanged) {
3071
- throw new PromptbookSyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3070
+ throw new SyntaxError('Execution type is already defined in the prompt template. It can be defined only once.');
3072
3071
  }
3073
3072
  executionType = command.executionType;
3074
3073
  isExecutionTypeChanged = true;
@@ -3089,25 +3088,25 @@ function promptbookStringToJsonSync(promptbookString) {
3089
3088
  expectAmount[unit] = expectAmount[unit] || {};
3090
3089
  if (command.sign === 'MINIMUM' || command.sign === 'EXACTLY') {
3091
3090
  if (expectAmount[unit].min !== undefined) {
3092
- throw new PromptbookSyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3091
+ throw new SyntaxError("Already defined minumum ".concat(expectAmount[unit].min, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3093
3092
  }
3094
3093
  expectAmount[unit].min = command.amount;
3095
3094
  } /* not else */
3096
3095
  if (command.sign === 'MAXIMUM' || command.sign === 'EXACTLY') {
3097
3096
  if (expectAmount[unit].max !== undefined) {
3098
- throw new PromptbookSyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3097
+ throw new SyntaxError("Already defined maximum ".concat(expectAmount[unit].max, " ").concat(command.unit.toLowerCase(), ", now trying to redefine it to ").concat(command.amount));
3099
3098
  }
3100
3099
  expectAmount[unit].max = command.amount;
3101
3100
  }
3102
3101
  break;
3103
3102
  case 'EXPECT_FORMAT':
3104
3103
  if (expectFormat !== undefined && command.format !== expectFormat) {
3105
- throw new PromptbookSyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3104
+ throw new SyntaxError("Expect format is already defined to \"".concat(expectFormat, "\". Now you try to redefine it by \"").concat(command.format, "\"."));
3106
3105
  }
3107
3106
  expectFormat = command.format;
3108
3107
  break;
3109
3108
  default:
3110
- throw new PromptbookSyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3109
+ throw new SyntaxError("Command ".concat(command.type, " is not allowed in the block of the prompt template ONLY at the head of the promptbook"));
3111
3110
  }
3112
3111
  }
3113
3112
  }
@@ -3121,16 +3120,16 @@ function promptbookStringToJsonSync(promptbookString) {
3121
3120
  var _f = extractOneBlockFromMarkdown(section.content), language = _f.language, content = _f.content;
3122
3121
  if (executionType === 'SCRIPT') {
3123
3122
  if (!language) {
3124
- throw new PromptbookSyntaxError('You must specify the language of the script in the prompt template');
3123
+ throw new SyntaxError('You must specify the language of the script in the prompt template');
3125
3124
  }
3126
3125
  else if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
3127
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
3126
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Script language ".concat(language, " is not supported.\n\n Supported languages are:\n ").concat(block(SUPPORTED_SCRIPT_LANGUAGES.join(', ')), "\n\n "); }));
3128
3127
  }
3129
3128
  }
3130
3129
  var lastLine = section.content.split('\n').pop();
3131
3130
  var match = /^->\s*\{(?<resultingParamName>[a-z0-9_]+)\}/im.exec(lastLine);
3132
3131
  if (!match || match.groups === undefined || match.groups.resultingParamName === undefined) {
3133
- throw new PromptbookSyntaxError(spaceTrim$1(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3132
+ throw new SyntaxError(spaceTrim$1(function (block) { return "\n Invalid template - each section must end with \"-> {...}\"\n\n Invalid section:\n ".concat(block(
3134
3133
  // TODO: Show code of invalid sections each time + DRY
3135
3134
  section.content
3136
3135
  .split('\n')
@@ -3180,7 +3179,7 @@ function promptbookStringToJsonSync(promptbookString) {
3180
3179
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3181
3180
  delete template.modelRequirements;
3182
3181
  }
3183
- promptbookJson.promptTemplates.push(template);
3182
+ pipelineJson.promptTemplates.push(template);
3184
3183
  };
3185
3184
  try {
3186
3185
  for (var _c = __values(markdownStructure.sections), _d = _c.next(); !_d.done; _d = _c.next()) {
@@ -3196,7 +3195,7 @@ function promptbookStringToJsonSync(promptbookString) {
3196
3195
  finally { if (e_2) throw e_2.error; }
3197
3196
  }
3198
3197
  // =============================================================
3199
- return promptbookJson;
3198
+ return pipelineJson;
3200
3199
  }
3201
3200
  /**
3202
3201
  * TODO: Report here line/column of error
@@ -3208,21 +3207,21 @@ function promptbookStringToJsonSync(promptbookString) {
3208
3207
  * Compile promptbook from string (markdown) format to JSON format
3209
3208
  *
3210
3209
  * Note: There are two similar functions:
3211
- * - `promptbookStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3212
- * - `promptbookStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3210
+ * - `pipelineStringToJson` **(preferred)** - which propperly compiles the promptbook and use embedding for external knowledge
3211
+ * - `pipelineStringToJsonSync` - use only if you need to compile promptbook synchronously and it contains NO external knowledge
3213
3212
  *
3214
- * @param promptbookString {Promptbook} in string markdown format (.ptbk.md)
3213
+ * @param pipelineString {Promptbook} in string markdown format (.ptbk.md)
3215
3214
  * @param options - Options and tools for the compilation
3216
3215
  * @returns {Promptbook} compiled in JSON format (.ptbk.json)
3217
- * @throws {PromptbookSyntaxError} if the promptbook string is not valid
3216
+ * @throws {SyntaxError} if the promptbook string is not valid
3218
3217
  *
3219
3218
  * Note: This function does not validate logic of the pipeline only the syntax
3220
3219
  * Note: This function acts as compilation process
3221
3220
  */
3222
- function promptbookStringToJson(promptbookString, options) {
3221
+ function pipelineStringToJson(pipelineString, options) {
3223
3222
  if (options === void 0) { options = {}; }
3224
3223
  return __awaiter(this, void 0, void 0, function () {
3225
- var llmTools, knowledge, promptbookJson;
3224
+ var llmTools, knowledge, pipelineJson;
3226
3225
  return __generator(this, function (_a) {
3227
3226
  switch (_a.label) {
3228
3227
  case 0:
@@ -3237,8 +3236,8 @@ function promptbookStringToJson(promptbookString, options) {
3237
3236
  console.info('!!!! knowledge', knowledge);
3238
3237
  _a.label = 2;
3239
3238
  case 2:
3240
- promptbookJson = promptbookStringToJsonSync(promptbookString);
3241
- return [2 /*return*/, promptbookJson];
3239
+ pipelineJson = pipelineStringToJsonSync(pipelineString);
3240
+ return [2 /*return*/, pipelineJson];
3242
3241
  }
3243
3242
  });
3244
3243
  });
@@ -3250,37 +3249,37 @@ function promptbookStringToJson(promptbookString, options) {
3250
3249
  /**
3251
3250
  * This error indicates that the promptbook library cannot be propperly loaded
3252
3251
  */
3253
- var PromptbookLibraryError = /** @class */ (function (_super) {
3254
- __extends(PromptbookLibraryError, _super);
3255
- function PromptbookLibraryError(message) {
3252
+ var CollectionError = /** @class */ (function (_super) {
3253
+ __extends(CollectionError, _super);
3254
+ function CollectionError(message) {
3256
3255
  var _this = _super.call(this, message) || this;
3257
- _this.name = 'PromptbookLibraryError';
3258
- Object.setPrototypeOf(_this, PromptbookLibraryError.prototype);
3256
+ _this.name = 'CollectionError';
3257
+ Object.setPrototypeOf(_this, CollectionError.prototype);
3259
3258
  return _this;
3260
3259
  }
3261
- return PromptbookLibraryError;
3260
+ return CollectionError;
3262
3261
  }(Error));
3263
3262
 
3264
3263
  /**
3265
3264
  * Constructs Promptbook from async sources
3266
3265
  * It can be one of the following:
3267
- * - Promise of array of PromptbookJson or PromptbookString
3268
- * - Factory function that returns Promise of array of PromptbookJson or PromptbookString
3266
+ * - Promise of array of PipelineJson or PipelineString
3267
+ * - Factory function that returns Promise of array of PipelineJson or PipelineString
3269
3268
  *
3270
3269
  * Note: This is useful as internal tool for other constructor functions like
3271
- * `createLibraryFromUrl` or `createLibraryFromDirectory`
3270
+ * `createCollectionFromUrl` or `createCollectionFromDirectory`
3272
3271
  * Consider using those functions instead of this one
3273
3272
  *
3274
3273
  * Note: The function does NOT return promise it returns the library directly which waits for the sources to be resolved
3275
- * when error occurs in given promise or factory function, it is thrown during `listPromptbooks` or `getPromptbookByUrl` call
3274
+ * when error occurs in given promise or factory function, it is thrown during `listPipelines` or `getPipelineByUrl` call
3276
3275
  *
3277
- * Note: Consider using `createLibraryFromDirectory` or `createLibraryFromUrl`
3276
+ * Note: Consider using `createCollectionFromDirectory` or `createCollectionFromUrl`
3278
3277
  *
3279
3278
  * @param promptbookSourcesPromiseOrFactory
3280
- * @returns PromptbookLibrary
3279
+ * @returns PipelineCollection
3281
3280
  * @deprecated Do not use, it will became internal tool for other constructor functions
3282
3281
  */
3283
- function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3282
+ function createCollectionFromPromise(promptbookSourcesPromiseOrFactory) {
3284
3283
  var library;
3285
3284
  function forSources() {
3286
3285
  return __awaiter(this, void 0, void 0, function () {
@@ -3295,32 +3294,32 @@ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3295
3294
  return [4 /*yield*/, promptbookSourcesPromiseOrFactory];
3296
3295
  case 1:
3297
3296
  promptbookSources = _a.sent();
3298
- library = createLibraryFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3297
+ library = createCollectionFromJson.apply(void 0, __spreadArray([], __read(promptbookSources), false));
3299
3298
  return [2 /*return*/];
3300
3299
  }
3301
3300
  });
3302
3301
  });
3303
3302
  }
3304
- function listPromptbooks() {
3303
+ function listPipelines() {
3305
3304
  return __awaiter(this, void 0, void 0, function () {
3306
3305
  return __generator(this, function (_a) {
3307
3306
  switch (_a.label) {
3308
3307
  case 0: return [4 /*yield*/, forSources()];
3309
3308
  case 1:
3310
3309
  _a.sent();
3311
- return [2 /*return*/, /* not await */ library.listPromptbooks()];
3310
+ return [2 /*return*/, /* not await */ library.listPipelines()];
3312
3311
  }
3313
3312
  });
3314
3313
  });
3315
3314
  }
3316
- function getPromptbookByUrl(url) {
3315
+ function getPipelineByUrl(url) {
3317
3316
  return __awaiter(this, void 0, void 0, function () {
3318
3317
  return __generator(this, function (_a) {
3319
3318
  switch (_a.label) {
3320
3319
  case 0: return [4 /*yield*/, forSources()];
3321
3320
  case 1:
3322
3321
  _a.sent();
3323
- return [2 /*return*/, /* not await */ library.getPromptbookByUrl(url)];
3322
+ return [2 /*return*/, /* not await */ library.getPipelineByUrl(url)];
3324
3323
  }
3325
3324
  });
3326
3325
  });
@@ -3338,8 +3337,8 @@ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3338
3337
  });
3339
3338
  }
3340
3339
  return {
3341
- listPromptbooks: listPromptbooks,
3342
- getPromptbookByUrl: getPromptbookByUrl,
3340
+ listPipelines: listPipelines,
3341
+ getPipelineByUrl: getPipelineByUrl,
3343
3342
  isResponsibleForPrompt: isResponsibleForPrompt,
3344
3343
  };
3345
3344
  }
@@ -3351,9 +3350,9 @@ function createLibraryFromPromise(promptbookSourcesPromiseOrFactory) {
3351
3350
  *
3352
3351
  * @param path - path to the directory with promptbooks
3353
3352
  * @param options - Misc options for the library
3354
- * @returns PromptbookLibrary
3353
+ * @returns PipelineCollection
3355
3354
  */
3356
- function createLibraryFromDirectory(path, options) {
3355
+ function createCollectionFromDirectory(path, options) {
3357
3356
  return __awaiter(this, void 0, void 0, function () {
3358
3357
  var makedLibraryFilePath, makedLibraryFileExists, _a, _b, isRecursive, _c, isVerbose, _d, isLazyLoaded, _e, isCrashOnError, library;
3359
3358
  var _this = this;
@@ -3361,7 +3360,7 @@ function createLibraryFromDirectory(path, options) {
3361
3360
  switch (_f.label) {
3362
3361
  case 0:
3363
3362
  if (!isRunningInNode()) {
3364
- throw new Error('Function `createLibraryFromDirectory` can only be run in Node.js environment because it reads the file system.');
3363
+ throw new Error('Function `createCollectionFromDirectory` can only be run in Node.js environment because it reads the file system.');
3365
3364
  }
3366
3365
  makedLibraryFilePath = join(path, "".concat(PROMPTBOOK_MAKED_BASE_FILENAME, ".json"));
3367
3366
  return [4 /*yield*/, access(makedLibraryFilePath, constants.R_OK)
@@ -3377,7 +3376,7 @@ function createLibraryFromDirectory(path, options) {
3377
3376
  // TODO: !! Implement;
3378
3377
  }
3379
3378
  _a = options || {}, _b = _a.isRecursive, isRecursive = _b === void 0 ? true : _b, _c = _a.isVerbose, isVerbose = _c === void 0 ? false : _c, _d = _a.isLazyLoaded, isLazyLoaded = _d === void 0 ? false : _d, _e = _a.isCrashOnError, isCrashOnError = _e === void 0 ? true : _e;
3380
- library = createLibraryFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3379
+ library = createCollectionFromPromise(function () { return __awaiter(_this, void 0, void 0, function () {
3381
3380
  var fileNames, promptbooks, _loop_1, fileNames_1, fileNames_1_1, fileName, e_1_1;
3382
3381
  var e_1, _a;
3383
3382
  return __generator(this, function (_b) {
@@ -3391,7 +3390,7 @@ function createLibraryFromDirectory(path, options) {
3391
3390
  fileNames = _b.sent();
3392
3391
  promptbooks = [];
3393
3392
  _loop_1 = function (fileName) {
3394
- var promptbook, promptbookString, _c, _d, error_1, wrappedErrorMessage;
3393
+ var promptbook, pipelineString, _c, _d, error_1, wrappedErrorMessage;
3395
3394
  return __generator(this, function (_e) {
3396
3395
  switch (_e.label) {
3397
3396
  case 0:
@@ -3400,8 +3399,8 @@ function createLibraryFromDirectory(path, options) {
3400
3399
  if (!fileName.endsWith('.ptbk.md')) return [3 /*break*/, 3];
3401
3400
  return [4 /*yield*/, readFile(fileName, 'utf8')];
3402
3401
  case 1:
3403
- promptbookString = (_e.sent());
3404
- return [4 /*yield*/, promptbookStringToJson(promptbookString)];
3402
+ pipelineString = (_e.sent());
3403
+ return [4 /*yield*/, pipelineStringToJson(pipelineString)];
3405
3404
  case 2:
3406
3405
  promptbook = _e.sent();
3407
3406
  return [3 /*break*/, 6];
@@ -3436,9 +3435,9 @@ function createLibraryFromDirectory(path, options) {
3436
3435
  if (!isCrashOnError) {
3437
3436
  // Note: Validate promptbook to check if it is logically correct to not crash on invalid promptbooks
3438
3437
  // But be handled in current try-catch block
3439
- validatePromptbook(promptbook);
3438
+ validatePipeline(promptbook);
3440
3439
  }
3441
- // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePromptbookLibrary
3440
+ // Note: [🦄] Promptbook with same url uniqueness will be checked automatically in SimplePipelineCollection
3442
3441
  promptbooks.push(promptbook);
3443
3442
  }
3444
3443
  }
@@ -3450,7 +3449,7 @@ function createLibraryFromDirectory(path, options) {
3450
3449
  }
3451
3450
  wrappedErrorMessage = spaceTrim(function (block) { return "\n Error during loading promptbook from file ".concat(fileName.split('\\').join('/'), ":\n\n ").concat(block(error_1.message), "\n\n "); });
3452
3451
  if (isCrashOnError) {
3453
- throw new PromptbookLibraryError(wrappedErrorMessage);
3452
+ throw new CollectionError(wrappedErrorMessage);
3454
3453
  }
3455
3454
  console.error(wrappedErrorMessage);
3456
3455
  return [3 /*break*/, 8];
@@ -3489,7 +3488,7 @@ function createLibraryFromDirectory(path, options) {
3489
3488
  });
3490
3489
  }); });
3491
3490
  if (!(isLazyLoaded === false)) return [3 /*break*/, 3];
3492
- return [4 /*yield*/, library.listPromptbooks()];
3491
+ return [4 /*yield*/, library.listPipelines()];
3493
3492
  case 2:
3494
3493
  _f.sent();
3495
3494
  _f.label = 3;
@@ -3504,7 +3503,7 @@ function createLibraryFromDirectory(path, options) {
3504
3503
  * @param path
3505
3504
  * @param isRecursive
3506
3505
  * @returns List of all files in the directory
3507
- * @private internal function for `createLibraryFromDirectory`
3506
+ * @private internal function for `createCollectionFromDirectory`
3508
3507
  */
3509
3508
  function listAllFiles(path, isRecursive) {
3510
3509
  return __awaiter(this, void 0, void 0, function () {
@@ -3562,19 +3561,19 @@ function listAllFiles(path, isRecursive) {
3562
3561
  */
3563
3562
 
3564
3563
  /**
3565
- * Converts PromptbookLibrary to serialized JSON
3564
+ * Converts PipelineCollection to serialized JSON
3566
3565
  *
3567
- * Note: Functions `libraryToJson` and `createLibraryFromJson` are complementary
3566
+ * Note: Functions `libraryToJson` and `createCollectionFromJson` are complementary
3568
3567
  */
3569
3568
  function libraryToJson(library) {
3570
3569
  return __awaiter(this, void 0, void 0, function () {
3571
3570
  var promptbookUrls, promptbooks;
3572
3571
  return __generator(this, function (_a) {
3573
3572
  switch (_a.label) {
3574
- case 0: return [4 /*yield*/, library.listPromptbooks()];
3573
+ case 0: return [4 /*yield*/, library.listPipelines()];
3575
3574
  case 1:
3576
3575
  promptbookUrls = _a.sent();
3577
- return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPromptbookByUrl(url); }))];
3576
+ return [4 /*yield*/, Promise.all(promptbookUrls.map(function (url) { return library.getPipelineByUrl(url); }))];
3578
3577
  case 2:
3579
3578
  promptbooks = _a.sent();
3580
3579
  return [2 /*return*/, promptbooks];
@@ -3622,7 +3621,7 @@ function initializeMake(program) {
3622
3621
  console.error(colors.red("You can use only one format when saving to a file"));
3623
3622
  process.exit(1);
3624
3623
  }
3625
- return [4 /*yield*/, createLibraryFromDirectory(path, {
3624
+ return [4 /*yield*/, createCollectionFromDirectory(path, {
3626
3625
  isVerbose: verbose,
3627
3626
  isRecursive: true,
3628
3627
  })];
@@ -3640,18 +3639,18 @@ function initializeMake(program) {
3640
3639
  case 4:
3641
3640
  _f.trys.push([4, 10, 11, 12]);
3642
3641
  e_1 = void 0;
3643
- return [4 /*yield*/, library.listPromptbooks()];
3642
+ return [4 /*yield*/, library.listPipelines()];
3644
3643
  case 5:
3645
3644
  _b = (__values.apply(void 0, [_f.sent()])), _c = _b.next();
3646
3645
  _f.label = 6;
3647
3646
  case 6:
3648
3647
  if (!!_c.done) return [3 /*break*/, 9];
3649
3648
  promptbookUrl = _c.value;
3650
- return [4 /*yield*/, library.getPromptbookByUrl(promptbookUrl)];
3649
+ return [4 /*yield*/, library.getPipelineByUrl(promptbookUrl)];
3651
3650
  case 7:
3652
3651
  promptbook = _f.sent();
3653
3652
  if (validation_1 === 'logic') {
3654
- validatePromptbook(promptbook);
3653
+ validatePipeline(promptbook);
3655
3654
  if (verbose) {
3656
3655
  console.info(colors.cyan("Validated logic of ".concat(promptbook.promptbookUrl)));
3657
3656
  }
@@ -3719,13 +3718,13 @@ function initializeMake(program) {
3719
3718
  _f.label = 19;
3720
3719
  case 19:
3721
3720
  if (!formats.includes('javascript')) return [3 /*break*/, 21];
3722
- return [4 /*yield*/, saveFile('js', spaceTrim("\n import { createLibraryFromJson } from '@promptbook/core';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PromptbookLibrary} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPromptbookLibrary(){\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
3721
+ return [4 /*yield*/, saveFile('js', spaceTrim("\n import { createCollectionFromJson } from '@promptbook/core';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPipelineCollection`\n */\n let PipelineCollection = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPipelineCollection(){\n if(PipelineCollection===null){\n PipelineCollection = createCollectionFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return PipelineCollection;\n }\n ") + '\n'))];
3723
3722
  case 20:
3724
3723
  _f.sent();
3725
3724
  _f.label = 21;
3726
3725
  case 21:
3727
3726
  if (!formats.includes('typescript')) return [3 /*break*/, 23];
3728
- return [4 /*yield*/, saveFile('ts', spaceTrim("\n import { createLibraryFromJson } from '@promptbook/core';\n import type { PromptbookLibrary } from '@promptbook/types';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPromptbookLibrary`\n */\n let promptbookLibrary: null | PromptbookLibrary = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PromptbookLibrary} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPromptbookLibrary(): PromptbookLibrary{\n if(promptbookLibrary===null){\n promptbookLibrary = createLibraryFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return promptbookLibrary;\n }\n ") + '\n'))];
3727
+ return [4 /*yield*/, saveFile('ts', spaceTrim("\n import { createCollectionFromJson } from '@promptbook/core';\n import type { PipelineCollection } from '@promptbook/types';\n\n /**\n * Promptbook library for ".concat(projectName, "\n *\n * @private internal cache for `getPipelineCollection`\n */\n let PipelineCollection: null | PipelineCollection = null;\n\n\n /**\n * Get promptbook library for ").concat(projectName, "\n *\n * @returns {PipelineCollection} Library of promptbooks for ").concat(projectName, "\n * @generated by `@promptbook/cli`\n */\n export function getPipelineCollection(): PipelineCollection{\n if(PipelineCollection===null){\n PipelineCollection = createCollectionFromJson(").concat(libraryJsonString.substring(1, libraryJsonString.length - 1), ");\n }\n\n return PipelineCollection;\n }\n ") + '\n'))];
3729
3728
  case 22:
3730
3729
  _f.sent();
3731
3730
  _f.label = 23;
@@ -3741,7 +3740,7 @@ function initializeMake(program) {
3741
3740
  /**
3742
3741
  * Add or modify an auto-generated section in a markdown file
3743
3742
  *
3744
- * @private within the library
3743
+ * @private within the package
3745
3744
  */
3746
3745
  function addAutoGeneratedSection(content, options) {
3747
3746
  var sectionName = options.sectionName, sectionContent = options.sectionContent;
@@ -3819,23 +3818,23 @@ function normalizeTo_camelCase(sentence, __firstLetterCapital) {
3819
3818
  *
3820
3819
  * Note: The result is not wrapped in a Markdown code block
3821
3820
  */
3822
- function renderPromptbookMermaid(promptbookJson, options) {
3821
+ function renderPromptbookMermaid(pipelineJson, options) {
3823
3822
  var _a = (options || {}).linkPromptTemplate, linkPromptTemplate = _a === void 0 ? function () { return null; } : _a;
3824
3823
  var parameterNameToTemplateName = function (parameterName) {
3825
- var parameter = promptbookJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
3824
+ var parameter = pipelineJson.parameters.find(function (parameter) { return parameter.name === parameterName; });
3826
3825
  if (!parameter) {
3827
3826
  throw new UnexpectedError("Could not find {".concat(parameterName, "}"));
3828
3827
  }
3829
3828
  if (parameter.isInput) {
3830
3829
  return 'input';
3831
3830
  }
3832
- var template = promptbookJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
3831
+ var template = pipelineJson.promptTemplates.find(function (template) { return template.resultingParameterName === parameterName; });
3833
3832
  if (!template) {
3834
3833
  throw new Error("Could not find template for {".concat(parameterName, "}"));
3835
3834
  }
3836
3835
  return normalizeTo_camelCase('template-' + titleToName(template.title));
3837
3836
  };
3838
- var promptbookMermaid = spaceTrim$1(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(promptbookJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(promptbookJson.promptTemplates
3837
+ var promptbookMermaid = spaceTrim$1(function (block) { return "\n\n %% \uD83D\uDD2E Tip: Open this on GitHub or in the VSCode website to see the Mermaid graph visually\n\n flowchart LR\n subgraph \"".concat(pipelineJson.title, "\"\n\n direction TB\n\n input((Input)):::input\n ").concat(block(pipelineJson.promptTemplates
3839
3838
  .flatMap(function (_a) {
3840
3839
  var title = _a.title, dependentParameterNames = _a.dependentParameterNames, resultingParameterName = _a.resultingParameterName;
3841
3840
  return __spreadArray([
@@ -3844,7 +3843,7 @@ function renderPromptbookMermaid(promptbookJson, options) {
3844
3843
  return "".concat(parameterNameToTemplateName(dependentParameterName), "--\"{").concat(dependentParameterName, "}\"-->").concat(parameterNameToTemplateName(resultingParameterName));
3845
3844
  })), false);
3846
3845
  })
3847
- .join('\n')), "\n\n ").concat(block(promptbookJson.parameters
3846
+ .join('\n')), "\n\n ").concat(block(pipelineJson.parameters
3848
3847
  .filter(function (_a) {
3849
3848
  var isOutput = _a.isOutput;
3850
3849
  return isOutput;
@@ -3853,7 +3852,7 @@ function renderPromptbookMermaid(promptbookJson, options) {
3853
3852
  var name = _a.name;
3854
3853
  return "".concat(parameterNameToTemplateName(name), "--\"{").concat(name, "}\"-->output");
3855
3854
  })
3856
- .join('\n')), "\n output((Output)):::output\n\n ").concat(block(promptbookJson.promptTemplates
3855
+ .join('\n')), "\n output((Output)):::output\n\n ").concat(block(pipelineJson.promptTemplates
3857
3856
  .map(function (promptTemplate) {
3858
3857
  var link = linkPromptTemplate(promptTemplate);
3859
3858
  if (link === null) {
@@ -3875,33 +3874,33 @@ function renderPromptbookMermaid(promptbookJson, options) {
3875
3874
  /**
3876
3875
  * Prettyfies Promptbook string and adds Mermaid graph
3877
3876
  */
3878
- function prettifyPromptbookString(promptbookString, options) {
3877
+ function prettifyPipelineString(pipelineString, options) {
3879
3878
  return __awaiter(this, void 0, void 0, function () {
3880
- var isGraphAdded, isPrettifyed, promptbookJson, promptbookMermaid_1, promptbookMermaidBlock;
3879
+ var isGraphAdded, isPrettifyed, pipelineJson, promptbookMermaid_1, promptbookMermaidBlock;
3881
3880
  return __generator(this, function (_a) {
3882
3881
  switch (_a.label) {
3883
3882
  case 0:
3884
3883
  isGraphAdded = options.isGraphAdded, isPrettifyed = options.isPrettifyed;
3885
3884
  if (!isGraphAdded) return [3 /*break*/, 2];
3886
- return [4 /*yield*/, promptbookStringToJson(promptbookString)];
3885
+ return [4 /*yield*/, pipelineStringToJson(pipelineString)];
3887
3886
  case 1:
3888
- promptbookJson = _a.sent();
3889
- promptbookMermaid_1 = renderPromptbookMermaid(promptbookJson, {
3887
+ pipelineJson = _a.sent();
3888
+ promptbookMermaid_1 = renderPromptbookMermaid(pipelineJson, {
3890
3889
  linkPromptTemplate: function (promptTemplate) {
3891
3890
  return { href: "#".concat(promptTemplate.name), title: promptTemplate.title };
3892
3891
  },
3893
3892
  });
3894
3893
  promptbookMermaidBlock = spaceTrim$1(function (block) { return "\n ```mermaid\n ".concat(block(promptbookMermaid_1), "\n ```\n "); });
3895
- promptbookString = addAutoGeneratedSection(promptbookString, {
3894
+ pipelineString = addAutoGeneratedSection(pipelineString, {
3896
3895
  sectionName: 'Graph',
3897
3896
  sectionContent: promptbookMermaidBlock,
3898
3897
  });
3899
3898
  _a.label = 2;
3900
3899
  case 2:
3901
3900
  if (isPrettifyed) {
3902
- promptbookString = prettifyMarkdown(promptbookString);
3901
+ pipelineString = prettifyMarkdown(pipelineString);
3903
3902
  }
3904
- return [2 /*return*/, promptbookString];
3903
+ return [2 /*return*/, pipelineString];
3905
3904
  }
3906
3905
  });
3907
3906
  });
@@ -3950,7 +3949,7 @@ function initializePrettify(program) {
3950
3949
  _c.label = 5;
3951
3950
  case 5:
3952
3951
  _c.trys.push([5, 8, , 9]);
3953
- return [4 /*yield*/, prettifyPromptbookString(promptbookMarkdown, {
3952
+ return [4 /*yield*/, prettifyPipelineString(promptbookMarkdown, {
3954
3953
  isGraphAdded: true,
3955
3954
  isPrettifyed: true,
3956
3955
  // <- [🕌]
@@ -4003,7 +4002,7 @@ function promptbookCli() {
4003
4002
  var program;
4004
4003
  return __generator(this, function (_a) {
4005
4004
  if (!isRunningInNode()) {
4006
- throw new Error(spaceTrim$1("\n Function promptbookCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use function exported from `@promptbook/utils` or `@promptbook/core` directly, for example `prettifyPromptbookString`.\n\n "));
4005
+ throw new Error(spaceTrim$1("\n Function promptbookCli is initiator of CLI script and should be run in Node.js environment.\n\n - In browser use function exported from `@promptbook/utils` or `@promptbook/core` directly, for example `prettifyPipelineString`.\n\n "));
4007
4006
  }
4008
4007
  program = new commander.Command();
4009
4008
  program.name('promptbook');