@promptbook/remote-client 0.103.0-9 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/README.md +59 -39
  2. package/esm/index.es.js +266 -176
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/typings/books/index.d.ts +0 -81
  5. package/esm/typings/servers.d.ts +9 -7
  6. package/esm/typings/src/_packages/browser.index.d.ts +6 -0
  7. package/esm/typings/src/_packages/cli.index.d.ts +4 -0
  8. package/esm/typings/src/_packages/components.index.d.ts +22 -8
  9. package/esm/typings/src/_packages/core.index.d.ts +58 -18
  10. package/esm/typings/src/_packages/node.index.d.ts +2 -2
  11. package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
  12. package/esm/typings/src/_packages/types.index.d.ts +70 -8
  13. package/esm/typings/src/_packages/utils.index.d.ts +6 -0
  14. package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
  15. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +20 -5
  16. package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
  17. package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
  18. package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
  19. package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
  20. package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
  21. package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
  22. package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
  23. package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
  24. package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
  25. package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +6 -1
  26. package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +85 -14
  27. package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +18 -0
  28. package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
  29. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +17 -0
  30. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
  31. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +16 -0
  32. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  33. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
  34. package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
  35. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  36. package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
  37. package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
  38. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  39. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
  40. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -0
  41. package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
  42. package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
  43. package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
  44. package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
  45. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
  46. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
  47. package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
  48. package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
  49. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
  50. package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -0
  51. package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
  52. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
  53. package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
  54. package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
  55. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
  56. package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
  57. package/esm/typings/src/book-components/icons/SendIcon.d.ts +3 -0
  58. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
  59. package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
  60. package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
  61. package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
  62. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
  63. package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
  64. package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
  65. package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
  66. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
  67. package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
  68. package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
  69. package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
  70. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
  71. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
  72. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
  73. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
  74. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
  75. package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
  76. package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
  77. package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
  78. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
  79. package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
  80. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
  81. package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
  82. package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
  83. package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
  84. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
  85. package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
  86. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +39 -0
  87. package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -0
  88. package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
  89. package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
  90. package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
  91. package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
  92. package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
  93. package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
  94. package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
  95. package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
  96. package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
  97. package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
  98. package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
  99. package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
  100. package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
  101. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
  102. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  103. package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
  104. package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
  105. package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
  106. package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
  107. package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
  108. package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
  109. package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
  110. package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
  111. package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
  112. package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
  113. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  114. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +42 -0
  115. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  116. package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
  117. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  118. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +14 -2
  119. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
  120. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
  121. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  122. package/esm/typings/src/commitments/index.d.ts +93 -0
  123. package/esm/typings/src/config.d.ts +24 -3
  124. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
  125. package/esm/typings/src/errors/0-index.d.ts +6 -0
  126. package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
  127. package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
  128. package/esm/typings/src/errors/WrappedError.d.ts +2 -2
  129. package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
  130. package/esm/typings/src/execution/Executables.d.ts +3 -0
  131. package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
  132. package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
  133. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  134. package/esm/typings/src/execution/LlmExecutionTools.d.ts +26 -2
  135. package/esm/typings/src/execution/PromptResult.d.ts +7 -1
  136. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
  137. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
  138. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
  139. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
  140. package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
  141. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
  142. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
  143. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
  144. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
  145. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  146. package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
  147. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
  148. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
  149. package/esm/typings/src/llm-providers/agent/Agent.d.ts +72 -0
  150. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
  151. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
  152. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
  153. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
  154. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
  155. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
  156. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  157. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  158. package/esm/typings/src/llm-providers/ollama/OllamaExecutionTools.d.ts +4 -0
  159. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
  160. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
  161. package/esm/typings/src/llm-providers/openai/OpenAiCompatibleExecutionTools.d.ts +13 -1
  162. package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
  163. package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
  164. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  165. package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
  166. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  167. package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
  168. package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
  169. package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
  170. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
  171. package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
  172. package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
  173. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
  174. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
  175. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
  176. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
  177. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
  178. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
  179. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
  180. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
  181. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
  182. package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
  183. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
  184. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
  185. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
  186. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
  187. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
  188. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
  189. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
  190. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
  191. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
  192. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
  193. package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
  194. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
  195. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
  196. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
  197. package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
  198. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
  199. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  200. package/esm/typings/src/types/ModelRequirements.d.ts +13 -1
  201. package/esm/typings/src/types/ModelVariant.d.ts +1 -1
  202. package/esm/typings/src/types/Prompt.d.ts +13 -1
  203. package/esm/typings/src/types/Updatable.d.ts +19 -0
  204. package/esm/typings/src/types/typeAliases.d.ts +38 -2
  205. package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
  206. package/esm/typings/src/utils/color/Color.d.ts +16 -1
  207. package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
  208. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  209. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
  210. package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
  211. package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
  212. package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
  213. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
  214. package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
  215. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
  216. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
  217. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
  218. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
  219. package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
  220. package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
  221. package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
  222. package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
  223. package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
  224. package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
  225. package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
  226. package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
  227. package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
  228. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
  229. package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
  230. package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
  231. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
  232. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
  233. package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
  234. package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
  235. package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
  236. package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
  237. package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
  238. package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
  239. package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
  240. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +31 -0
  241. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
  242. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
  243. package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
  244. package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
  245. package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
  246. package/esm/typings/src/utils/random/CzechNamePool.d.ts +7 -0
  247. package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
  248. package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
  249. package/esm/typings/src/utils/random/getNamePool.d.ts +10 -0
  250. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
  251. package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
  252. package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
  253. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
  254. package/esm/typings/src/version.d.ts +1 -1
  255. package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
  256. package/package.json +6 -6
  257. package/umd/index.umd.js +229 -139
  258. package/umd/index.umd.js.map +1 -1
  259. package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
  260. package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
  261. package/esm/typings/src/book-components/BookEditor/BookEditorWrapper.d.ts +0 -9
  262. package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
  263. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
  264. package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
  265. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
  266. /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
  267. /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
  268. /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
  269. /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
  270. /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
  271. /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
  272. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
  273. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import spaceTrim$1, { spaceTrim } from 'spacetrim';
1
+ import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
2
2
  import { randomBytes } from 'crypto';
3
3
  import { io } from 'socket.io-client';
4
4
  import { SHA256 } from 'crypto-js';
@@ -13,14 +13,14 @@ import { basename } from 'path';
13
13
  * @generated
14
14
  * @see https://github.com/webgptorg/book
15
15
  */
16
- const BOOK_LANGUAGE_VERSION = '1.0.0';
16
+ const BOOK_LANGUAGE_VERSION = '2.0.0';
17
17
  /**
18
18
  * The version of the Promptbook engine
19
19
  *
20
20
  * @generated
21
21
  * @see https://github.com/webgptorg/promptbook
22
22
  */
23
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-9';
23
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0';
24
24
  /**
25
25
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
26
26
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -82,6 +82,22 @@ class CollectionError extends Error {
82
82
  }
83
83
  }
84
84
 
85
+ /**
86
+ * This error indicates error from the database
87
+ *
88
+ * @public exported from `@promptbook/core`
89
+ */
90
+ class DatabaseError extends Error {
91
+ constructor(message) {
92
+ super(message);
93
+ this.name = 'DatabaseError';
94
+ Object.setPrototypeOf(this, DatabaseError.prototype);
95
+ }
96
+ }
97
+ /**
98
+ * TODO: [🐱‍🚀] Explain that NotFoundError ([🐱‍🚀] and other specific errors) has priority over DatabaseError in some contexts
99
+ */
100
+
85
101
  /**
86
102
  * This error type indicates that you try to use a feature that is not available in the current environment
87
103
  *
@@ -144,7 +160,7 @@ class LimitReachedError extends Error {
144
160
  */
145
161
  class MissingToolsError extends Error {
146
162
  constructor(message) {
147
- super(spaceTrim((block) => `
163
+ super(spaceTrim$1((block) => `
148
164
  ${block(message)}
149
165
 
150
166
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -155,6 +171,19 @@ class MissingToolsError extends Error {
155
171
  }
156
172
  }
157
173
 
174
+ /**
175
+ * This error indicates that promptbook operation is not allowed
176
+ *
177
+ * @public exported from `@promptbook/core`
178
+ */
179
+ class NotAllowed extends Error {
180
+ constructor(message) {
181
+ super(message);
182
+ this.name = 'NotAllowed';
183
+ Object.setPrototypeOf(this, NotAllowed.prototype);
184
+ }
185
+ }
186
+
158
187
  /**
159
188
  * This error indicates that promptbook not found in the collection
160
189
  *
@@ -175,7 +204,7 @@ class NotFoundError extends Error {
175
204
  */
176
205
  class NotYetImplementedError extends Error {
177
206
  constructor(message) {
178
- super(spaceTrim((block) => `
207
+ super(spaceTrim$1((block) => `
179
208
  ${block(message)}
180
209
 
181
210
  Note: This feature is not implemented yet but it will be soon.
@@ -210,6 +239,7 @@ class ParseError extends Error {
210
239
  /**
211
240
  * Generates random token
212
241
  *
242
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
213
243
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
214
244
  *
215
245
  * @private internal helper function
@@ -219,6 +249,7 @@ function $randomToken(randomness) {
219
249
  return randomBytes(randomness).toString('hex');
220
250
  }
221
251
  /**
252
+ * TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
222
253
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
223
254
  */
224
255
 
@@ -280,6 +311,17 @@ class PromptbookFetchError extends Error {
280
311
  }
281
312
  }
282
313
 
314
+ /**
315
+ * Trims string from all 4 sides
316
+ *
317
+ * Note: This is a re-exported function from the `spacetrim` package which is
318
+ * Developed by same author @hejny as this package
319
+ *
320
+ * @public exported from `@promptbook/utils`
321
+ * @see https://github.com/hejny/spacetrim#usage
322
+ */
323
+ const spaceTrim = spaceTrim$1;
324
+
283
325
  /**
284
326
  * @private util of `@promptbook/color`
285
327
  * @de
@@ -328,6 +370,7 @@ function take(initialValue) {
328
370
  * @public exported from `@promptbook/color`
329
371
  */
330
372
  const CSS_COLORS = {
373
+ promptbook: '#79EAFD',
331
374
  transparent: 'rgba(0,0,0,0)',
332
375
  aliceblue: '#f0f8ff',
333
376
  antiquewhite: '#faebd7',
@@ -509,9 +552,6 @@ function checkChannelValue(channelName, value) {
509
552
  throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
510
553
  }
511
554
  }
512
- /**
513
- * TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
514
- */
515
555
 
516
556
  /**
517
557
  * Color object represents an RGB color with alpha channel
@@ -531,21 +571,61 @@ class Color {
531
571
  * @param color
532
572
  * @returns Color object
533
573
  */
534
- static from(color) {
535
- if (color instanceof Color) {
574
+ static from(color, _isSingleValue = false) {
575
+ if (color === '') {
576
+ throw new Error(`Can not create color from empty string`);
577
+ }
578
+ else if (color instanceof Color) {
536
579
  return take(color);
537
580
  }
538
581
  else if (Color.isColor(color)) {
539
582
  return take(color);
540
583
  }
541
584
  else if (typeof color === 'string') {
542
- return Color.fromString(color);
585
+ try {
586
+ return Color.fromString(color);
587
+ }
588
+ catch (error) {
589
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
590
+ if (_isSingleValue) {
591
+ throw error;
592
+ }
593
+ const parts = color.split(/[\s+,;|]/);
594
+ if (parts.length > 0) {
595
+ return Color.from(parts[0].trim(), true);
596
+ }
597
+ else {
598
+ throw new Error(`Can not create color from given string "${color}"`);
599
+ }
600
+ }
543
601
  }
544
602
  else {
545
603
  console.error({ color });
546
604
  throw new Error(`Can not create color from given object`);
547
605
  }
548
606
  }
607
+ /**
608
+ * Creates a new Color instance from miscellaneous formats
609
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
610
+ *
611
+ * @param color
612
+ * @returns Color object
613
+ */
614
+ static fromSafe(color) {
615
+ try {
616
+ return Color.from(color);
617
+ }
618
+ catch (error) {
619
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
620
+ console.warn(spaceTrim((block) => `
621
+ Color.fromSafe error:
622
+ ${block(error.message)}
623
+
624
+ Returning default PROMPTBOOK_COLOR.
625
+ `));
626
+ return Color.fromString('promptbook');
627
+ }
628
+ }
549
629
  /**
550
630
  * Creates a new Color instance from miscellaneous string formats
551
631
  *
@@ -613,6 +693,9 @@ class Color {
613
693
  if (hex.length === 3) {
614
694
  return Color.fromHex3(hex);
615
695
  }
696
+ if (hex.length === 4) {
697
+ return Color.fromHex4(hex);
698
+ }
616
699
  if (hex.length === 6) {
617
700
  return Color.fromHex6(hex);
618
701
  }
@@ -633,6 +716,19 @@ class Color {
633
716
  const b = parseInt(hex.substr(2, 1), 16) * 16;
634
717
  return take(new Color(r, g, b));
635
718
  }
719
+ /**
720
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
721
+ *
722
+ * @param color in hex for example `09df`
723
+ * @returns Color object
724
+ */
725
+ static fromHex4(hex) {
726
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
727
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
728
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
729
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
730
+ return take(new Color(r, g, b, a));
731
+ }
636
732
  /**
637
733
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
638
734
  *
@@ -823,7 +919,8 @@ class Color {
823
919
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
824
920
  */
825
921
  static isHexColorString(value) {
826
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
922
+ return (typeof value === 'string' &&
923
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
827
924
  }
828
925
  /**
829
926
  * Creates new Color object
@@ -938,6 +1035,23 @@ class Color {
938
1035
  * TODO: Maybe connect with textures
939
1036
  */
940
1037
 
1038
+ /**
1039
+ * Makes color transformer which returns a grayscale version of the color
1040
+ *
1041
+ * @param amount from 0 to 1
1042
+ *
1043
+ * @public exported from `@promptbook/color`
1044
+ */
1045
+ function grayscale(amount) {
1046
+ return ({ red, green, blue, alpha }) => {
1047
+ const average = (red + green + blue) / 3;
1048
+ red = Math.round(average * amount + red * (1 - amount));
1049
+ green = Math.round(average * amount + green * (1 - amount));
1050
+ blue = Math.round(average * amount + blue * (1 - amount));
1051
+ return Color.fromValues(red, green, blue, alpha);
1052
+ };
1053
+ }
1054
+
941
1055
  /**
942
1056
  * Converts HSL values to RGB values
943
1057
  *
@@ -1053,102 +1167,6 @@ function lighten(amount) {
1053
1167
  * TODO: Maybe implement by mix+hsl
1054
1168
  */
1055
1169
 
1056
- /**
1057
- * Calculates distance between two colors
1058
- *
1059
- * @param color1 first color
1060
- * @param color2 second color
1061
- *
1062
- * Note: This function is inefficient. Use colorDistanceSquared instead if possible.
1063
- *
1064
- * @public exported from `@promptbook/color`
1065
- */
1066
- /**
1067
- * Calculates distance between two colors without square root
1068
- *
1069
- * @param color1 first color
1070
- * @param color2 second color
1071
- *
1072
- * @public exported from `@promptbook/color`
1073
- */
1074
- function colorDistanceSquared(color1, color2) {
1075
- const rmean = (color1.red + color2.red) / 2;
1076
- const r = color1.red - color2.red;
1077
- const g = color1.green - color2.green;
1078
- const b = color1.blue - color2.blue;
1079
- const weightR = 2 + rmean / 256;
1080
- const weightG = 4.0;
1081
- const weightB = 2 + (255 - rmean) / 256;
1082
- const distance = weightR * r * r + weightG * g * g + weightB * b * b;
1083
- return distance;
1084
- }
1085
-
1086
- /**
1087
- * Makes color transformer which finds the nearest color from the given list
1088
- *
1089
- * @param colors array of colors to choose from
1090
- *
1091
- * @public exported from `@promptbook/color`
1092
- */
1093
- function nearest(...colors) {
1094
- return (color) => {
1095
- const distances = colors.map((c) => colorDistanceSquared(c, color));
1096
- const minDistance = Math.min(...distances);
1097
- const minIndex = distances.indexOf(minDistance);
1098
- const nearestColor = colors[minIndex];
1099
- return nearestColor;
1100
- };
1101
- }
1102
-
1103
- /**
1104
- * Color transformer which returns the negative color
1105
- *
1106
- * @public exported from `@promptbook/color`
1107
- */
1108
- function negative(color) {
1109
- const r = 255 - color.red;
1110
- const g = 255 - color.green;
1111
- const b = 255 - color.blue;
1112
- return Color.fromValues(r, g, b, color.alpha);
1113
- }
1114
-
1115
- /**
1116
- * Makes color transformer which finds the furthest color from the given list
1117
- *
1118
- * @param colors array of colors to choose from
1119
- *
1120
- * @public exported from `@promptbook/color`
1121
- */
1122
- function furthest(...colors) {
1123
- return (color) => {
1124
- const furthestColor = negative(nearest(...colors.map(negative))(color));
1125
- return furthestColor;
1126
- };
1127
- }
1128
- /**
1129
- * Makes color transformer which finds the best text color (black or white) for the given background color
1130
- *
1131
- * @public exported from `@promptbook/color`
1132
- */
1133
- furthest(Color.get('white'), Color.from('black'));
1134
-
1135
- /**
1136
- * Makes color transformer which returns a grayscale version of the color
1137
- *
1138
- * @param amount from 0 to 1
1139
- *
1140
- * @public exported from `@promptbook/color`
1141
- */
1142
- function grayscale(amount) {
1143
- return ({ red, green, blue, alpha }) => {
1144
- const average = (red + green + blue) / 3;
1145
- red = Math.round(average * amount + red * (1 - amount));
1146
- green = Math.round(average * amount + green * (1 - amount));
1147
- blue = Math.round(average * amount + blue * (1 - amount));
1148
- return Color.fromValues(red, green, blue, alpha);
1149
- };
1150
- }
1151
-
1152
1170
  /**
1153
1171
  * Makes color transformer which saturate the given color
1154
1172
  *
@@ -1217,16 +1235,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
1217
1235
  *
1218
1236
  * @public exported from `@promptbook/core`
1219
1237
  */
1220
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1221
- // <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
1238
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
1239
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1222
1240
  /**
1223
- * Dark color of the Promptbook
1241
+ * Colors for syntax highlighting in the `<BookEditor/>`
1242
+ *
1243
+ * TODO: [🗽] Unite branding and make single place for it
1244
+ *
1245
+ * @public exported from `@promptbook/core`
1246
+ */
1247
+ ({
1248
+ TITLE: Color.fromHex('#244EA8'),
1249
+ LINE: Color.fromHex('#eeeeee'),
1250
+ SEPARATOR: Color.fromHex('#cccccc'),
1251
+ COMMITMENT: Color.fromHex('#DA0F78'),
1252
+ PARAMETER: Color.fromHex('#8e44ad'),
1253
+ });
1254
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1255
+ /**
1256
+ * Chat color of the Promptbook (in chat)
1224
1257
  *
1225
1258
  * TODO: [🗽] Unite branding and make single place for it
1226
1259
  *
1227
1260
  * @public exported from `@promptbook/core`
1228
1261
  */
1229
1262
  PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
1263
+ // <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
1230
1264
  /**
1231
1265
  * Color of the user (in chat)
1232
1266
  *
@@ -1235,6 +1269,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
1235
1269
  * @public exported from `@promptbook/core`
1236
1270
  */
1237
1271
  Color.fromHex('#1D4ED8');
1272
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1238
1273
  /**
1239
1274
  * When the title is not provided, the default title is used
1240
1275
  *
@@ -1305,7 +1340,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1305
1340
  function getErrorReportUrl(error) {
1306
1341
  const report = {
1307
1342
  title: `🐜 Error report from ${NAME}`,
1308
- body: spaceTrim$1((block) => `
1343
+ body: spaceTrim$2((block) => `
1309
1344
 
1310
1345
 
1311
1346
  \`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
@@ -1348,7 +1383,7 @@ function getErrorReportUrl(error) {
1348
1383
  */
1349
1384
  class UnexpectedError extends Error {
1350
1385
  constructor(message) {
1351
- super(spaceTrim((block) => `
1386
+ super(spaceTrim$1((block) => `
1352
1387
  ${block(message)}
1353
1388
 
1354
1389
  Note: This error should not happen.
@@ -1374,7 +1409,7 @@ class WrappedError extends Error {
1374
1409
  constructor(whatWasThrown) {
1375
1410
  const tag = `[🤮]`;
1376
1411
  console.error(tag, whatWasThrown);
1377
- super(spaceTrim(`
1412
+ super(spaceTrim$1(`
1378
1413
  Non-Error object was thrown
1379
1414
 
1380
1415
  Note: Look for ${tag} in the console for more details
@@ -1409,6 +1444,8 @@ const PROMPTBOOK_ERRORS = {
1409
1444
  PromptbookFetchError,
1410
1445
  UnexpectedError,
1411
1446
  WrappedError,
1447
+ NotAllowed,
1448
+ DatabaseError,
1412
1449
  // TODO: [🪑]> VersionMismatchError,
1413
1450
  };
1414
1451
  /**
@@ -1461,7 +1498,7 @@ function deserializeError(error) {
1461
1498
  message = `${name}: ${message}`;
1462
1499
  }
1463
1500
  if (stack !== undefined && stack !== '') {
1464
- message = spaceTrim$1((block) => `
1501
+ message = spaceTrim$2((block) => `
1465
1502
  ${block(message)}
1466
1503
 
1467
1504
  Original stack trace:
@@ -1518,7 +1555,7 @@ async function createRemoteClient(options) {
1518
1555
  const remoteServerUrlParsed = new URL(remoteServerUrl);
1519
1556
  if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
1520
1557
  remoteServerUrlParsed.pathname = '/';
1521
- throw new Error(spaceTrim$1((block) => `
1558
+ throw new Error(spaceTrim$2((block) => `
1522
1559
  Remote server requires root url \`/\`
1523
1560
 
1524
1561
  You have provided \`remoteServerUrl\`:
@@ -1943,6 +1980,8 @@ function removeDiacritics(input) {
1943
1980
  /**
1944
1981
  * Converts a given text to kebab-case format.
1945
1982
  *
1983
+ * Note: [🔂] This function is idempotent.
1984
+ *
1946
1985
  * @param text The text to be converted.
1947
1986
  * @returns The kebab-case formatted string.
1948
1987
  * @example 'hello-world'
@@ -2052,7 +2091,7 @@ const knowledgeCommandParser = {
2052
2091
  */
2053
2092
  parse(input) {
2054
2093
  const { args } = input;
2055
- const knowledgeSourceContent = spaceTrim$1(args[0] || '');
2094
+ const knowledgeSourceContent = spaceTrim$2(args[0] || '');
2056
2095
  if (knowledgeSourceContent === '') {
2057
2096
  throw new ParseError(`Source is not defined`);
2058
2097
  }
@@ -2196,7 +2235,7 @@ const sectionCommandParser = {
2196
2235
  normalized = normalized.split('DIALOGUE').join('DIALOG');
2197
2236
  const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
2198
2237
  if (taskTypes.length !== 1) {
2199
- throw new ParseError(spaceTrim$1((block) => `
2238
+ throw new ParseError(spaceTrim$2((block) => `
2200
2239
  Unknown section type "${normalized}"
2201
2240
 
2202
2241
  Supported section types are:
@@ -2216,7 +2255,7 @@ const sectionCommandParser = {
2216
2255
  */
2217
2256
  $applyToTaskJson(command, $taskJson, $pipelineJson) {
2218
2257
  if ($taskJson.isSectionTypeSet === true) {
2219
- throw new ParseError(spaceTrim$1(`
2258
+ throw new ParseError(spaceTrim$2(`
2220
2259
  Section type is already defined in the section.
2221
2260
  It can be defined only once.
2222
2261
  `));
@@ -2635,7 +2674,7 @@ const expectCommandParser = {
2635
2674
  /**
2636
2675
  * Description of the FORMAT command
2637
2676
  */
2638
- description: spaceTrim$1(`
2677
+ description: spaceTrim$2(`
2639
2678
  Expect command describes the desired output of the task *(after post-processing)*
2640
2679
  It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
2641
2680
  `),
@@ -2709,7 +2748,7 @@ const expectCommandParser = {
2709
2748
  }
2710
2749
  catch (error) {
2711
2750
  assertsError(error);
2712
- throw new ParseError(spaceTrim$1((block) => `
2751
+ throw new ParseError(spaceTrim$2((block) => `
2713
2752
  Invalid FORMAT command
2714
2753
  ${block(error.message)}:
2715
2754
  `));
@@ -2831,7 +2870,7 @@ const CsvFormatParser = {
2831
2870
  const { value, outputParameterName, settings, mapCallback, onProgress } = options;
2832
2871
  const csv = csvParse(value, settings);
2833
2872
  if (csv.errors.length !== 0) {
2834
- throw new CsvFormatError(spaceTrim$1((block) => `
2873
+ throw new CsvFormatError(spaceTrim$2((block) => `
2835
2874
  CSV parsing error
2836
2875
 
2837
2876
  Error(s) from CSV parsing:
@@ -2876,7 +2915,7 @@ const CsvFormatParser = {
2876
2915
  const { value, settings, mapCallback, onProgress } = options;
2877
2916
  const csv = csvParse(value, settings);
2878
2917
  if (csv.errors.length !== 0) {
2879
- throw new CsvFormatError(spaceTrim$1((block) => `
2918
+ throw new CsvFormatError(spaceTrim$2((block) => `
2880
2919
  CSV parsing error
2881
2920
 
2882
2921
  Error(s) from CSV parsing:
@@ -3221,7 +3260,7 @@ function checkSerializableAsJson(options) {
3221
3260
  }
3222
3261
  else if (typeof value === 'object') {
3223
3262
  if (value instanceof Date) {
3224
- throw new UnexpectedError(spaceTrim$1((block) => `
3263
+ throw new UnexpectedError(spaceTrim$2((block) => `
3225
3264
  \`${name}\` is Date
3226
3265
 
3227
3266
  Use \`string_date_iso8601\` instead
@@ -3240,7 +3279,7 @@ function checkSerializableAsJson(options) {
3240
3279
  throw new UnexpectedError(`${name} is RegExp`);
3241
3280
  }
3242
3281
  else if (value instanceof Error) {
3243
- throw new UnexpectedError(spaceTrim$1((block) => `
3282
+ throw new UnexpectedError(spaceTrim$2((block) => `
3244
3283
  \`${name}\` is unserialized Error
3245
3284
 
3246
3285
  Use function \`serializeError\`
@@ -3263,7 +3302,7 @@ function checkSerializableAsJson(options) {
3263
3302
  }
3264
3303
  catch (error) {
3265
3304
  assertsError(error);
3266
- throw new UnexpectedError(spaceTrim$1((block) => `
3305
+ throw new UnexpectedError(spaceTrim$2((block) => `
3267
3306
  \`${name}\` is not serializable
3268
3307
 
3269
3308
  ${block(error.stack || error.message)}
@@ -3295,7 +3334,7 @@ function checkSerializableAsJson(options) {
3295
3334
  }
3296
3335
  }
3297
3336
  else {
3298
- throw new UnexpectedError(spaceTrim$1((block) => `
3337
+ throw new UnexpectedError(spaceTrim$2((block) => `
3299
3338
  \`${name}\` is unknown type
3300
3339
 
3301
3340
  Additional message for \`${name}\`:
@@ -3325,7 +3364,7 @@ function deepClone(objectValue) {
3325
3364
  TODO: [🧠] Is there a better implementation?
3326
3365
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
3327
3366
  > for (const propertyName of propertyNames) {
3328
- > const value = (objectValue as really_any)[propertyName];
3367
+ > const value = (objectValue as chococake)[propertyName];
3329
3368
  > if (value && typeof value === 'object') {
3330
3369
  > deepClone(value);
3331
3370
  > }
@@ -3418,6 +3457,8 @@ const RESERVED_PARAMETER_NAMES = exportJson({
3418
3457
  /**
3419
3458
  * Normalizes a given text to camelCase format.
3420
3459
  *
3460
+ * Note: [🔂] This function is idempotent.
3461
+ *
3421
3462
  * @param text The text to be normalized.
3422
3463
  * @param _isFirstLetterCapital Whether the first letter should be capitalized.
3423
3464
  * @returns The camelCase formatted string.
@@ -3513,6 +3554,8 @@ function removeQuotes(text) {
3513
3554
  * Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
3514
3555
  * It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
3515
3556
  *
3557
+ * Note: [🔂] This function is idempotent.
3558
+ *
3516
3559
  * @param parameterName The parameter name to validate and normalize.
3517
3560
  * @returns The validated and normalized parameter name.
3518
3561
  * @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
@@ -3572,7 +3615,7 @@ function validateParameterName(parameterName) {
3572
3615
  if (!(error instanceof ParseError)) {
3573
3616
  throw error;
3574
3617
  }
3575
- throw new ParseError(spaceTrim$1((block) => `
3618
+ throw new ParseError(spaceTrim$2((block) => `
3576
3619
  ${block(error.message)}
3577
3620
 
3578
3621
  Tried to validate parameter name:
@@ -3631,7 +3674,7 @@ const foreachCommandParser = {
3631
3674
  const assignSign = args[3];
3632
3675
  const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
3633
3676
  if (formatDefinition === undefined) {
3634
- throw new ParseError(spaceTrim$1((block) => `
3677
+ throw new ParseError(spaceTrim$2((block) => `
3635
3678
  Unsupported format "${formatName}"
3636
3679
 
3637
3680
  Available formats:
@@ -3643,7 +3686,7 @@ const foreachCommandParser = {
3643
3686
  }
3644
3687
  const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
3645
3688
  if (subvalueParser === undefined) {
3646
- throw new ParseError(spaceTrim$1((block) => `
3689
+ throw new ParseError(spaceTrim$2((block) => `
3647
3690
  Unsupported subformat name "${subformatName}" for format "${formatName}"
3648
3691
 
3649
3692
  Available subformat names for format "${formatDefinition.formatName}":
@@ -3691,7 +3734,7 @@ const foreachCommandParser = {
3691
3734
  outputSubparameterName = 'newLine';
3692
3735
  }
3693
3736
  else {
3694
- throw new ParseError(spaceTrim$1(`
3737
+ throw new ParseError(spaceTrim$2(`
3695
3738
  FOREACH ${formatName} ${subformatName} must specify output subparameter
3696
3739
 
3697
3740
  Correct example:
@@ -3767,7 +3810,7 @@ const formatCommandParser = {
3767
3810
  /**
3768
3811
  * Description of the FORMAT command
3769
3812
  */
3770
- description: spaceTrim$1(`
3813
+ description: spaceTrim$2(`
3771
3814
  Format command describes the desired output of the task (after post-processing)
3772
3815
  It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
3773
3816
  `),
@@ -4139,7 +4182,7 @@ const formfactorCommandParser = {
4139
4182
  const formfactorNameCandidate = args[0].toUpperCase();
4140
4183
  const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
4141
4184
  if (formfactor === undefined) {
4142
- throw new ParseError(spaceTrim$1((block) => `
4185
+ throw new ParseError(spaceTrim$2((block) => `
4143
4186
  Unknown formfactor name "${formfactorNameCandidate}"
4144
4187
 
4145
4188
  Available formfactors:
@@ -4158,7 +4201,7 @@ const formfactorCommandParser = {
4158
4201
  */
4159
4202
  $applyToPipelineJson(command, $pipelineJson) {
4160
4203
  if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
4161
- throw new ParseError(spaceTrim$1(`
4204
+ throw new ParseError(spaceTrim$2(`
4162
4205
  Redefinition of \`FORMFACTOR\` in the pipeline head
4163
4206
 
4164
4207
  You have used:
@@ -4265,7 +4308,7 @@ const jokerCommandParser = {
4265
4308
  * @see {@link ModelVariant}
4266
4309
  * @public exported from `@promptbook/core`
4267
4310
  */
4268
- const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
4311
+ const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'IMAGE_GENERATION', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
4269
4312
 
4270
4313
  /**
4271
4314
  * Parses the model command
@@ -4301,7 +4344,7 @@ const modelCommandParser = {
4301
4344
  */
4302
4345
  parse(input) {
4303
4346
  const { args, normalized } = input;
4304
- const availableVariantsMessage = spaceTrim$1((block) => `
4347
+ const availableVariantsMessage = spaceTrim$2((block) => `
4305
4348
  Available variants are:
4306
4349
  ${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
4307
4350
  `);
@@ -4323,14 +4366,14 @@ const modelCommandParser = {
4323
4366
  // <- Note: [🤖]
4324
4367
  }
4325
4368
  else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
4326
- spaceTrim$1((block) => `
4369
+ spaceTrim$2((block) => `
4327
4370
  Embedding model can not be used in pipeline
4328
4371
 
4329
4372
  ${block(availableVariantsMessage)}
4330
4373
  `);
4331
4374
  }
4332
4375
  else {
4333
- throw new ParseError(spaceTrim$1((block) => `
4376
+ throw new ParseError(spaceTrim$2((block) => `
4334
4377
  Unknown model variant in command:
4335
4378
 
4336
4379
  ${block(availableVariantsMessage)}
@@ -4345,7 +4388,7 @@ const modelCommandParser = {
4345
4388
  };
4346
4389
  }
4347
4390
  else {
4348
- throw new ParseError(spaceTrim$1((block) => `
4391
+ throw new ParseError(spaceTrim$2((block) => `
4349
4392
  Unknown model key in command.
4350
4393
 
4351
4394
  Supported model keys are:
@@ -4372,7 +4415,7 @@ const modelCommandParser = {
4372
4415
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4373
4416
  }
4374
4417
  else {
4375
- throw new ParseError(spaceTrim$1(`
4418
+ throw new ParseError(spaceTrim$2(`
4376
4419
  Redefinition of \`MODEL ${command.key}\` in the pipeline head
4377
4420
 
4378
4421
  You have used:
@@ -4404,7 +4447,7 @@ const modelCommandParser = {
4404
4447
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
4405
4448
  }
4406
4449
  else {
4407
- throw new ParseError(spaceTrim$1(`
4450
+ throw new ParseError(spaceTrim$2(`
4408
4451
  Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
4409
4452
 
4410
4453
  You have used:
@@ -4414,7 +4457,7 @@ const modelCommandParser = {
4414
4457
  }
4415
4458
  }
4416
4459
  if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
4417
- console.log(spaceTrim$1(`
4460
+ console.log(spaceTrim$2(`
4418
4461
  Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
4419
4462
 
4420
4463
  In pipeline head:
@@ -4497,7 +4540,7 @@ const parameterCommandParser = {
4497
4540
  // <- TODO: When [🥶] fixed, change to:
4498
4541
  // > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
4499
4542
  if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
4500
- throw new ParseError(spaceTrim$1((block) => `
4543
+ throw new ParseError(spaceTrim$2((block) => `
4501
4544
  Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
4502
4545
 
4503
4546
  The description:
@@ -4679,7 +4722,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4679
4722
  persona.description = personaDescription;
4680
4723
  return;
4681
4724
  }
4682
- console.warn(spaceTrim$1(`
4725
+ console.warn(spaceTrim$2(`
4683
4726
 
4684
4727
  Persona "${personaName}" is defined multiple times with different description:
4685
4728
 
@@ -4690,7 +4733,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
4690
4733
  ${personaDescription}
4691
4734
 
4692
4735
  `));
4693
- persona.description += spaceTrim$1('\n\n' + personaDescription);
4736
+ persona.description += spaceTrim$2('\n\n' + personaDescription);
4694
4737
  }
4695
4738
 
4696
4739
  /**
@@ -5087,7 +5130,7 @@ const COMMANDS = [
5087
5130
  function getParserForCommand(command) {
5088
5131
  const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
5089
5132
  if (commandParser === undefined) {
5090
- throw new UnexpectedError(spaceTrim((block) => `
5133
+ throw new UnexpectedError(spaceTrim$1((block) => `
5091
5134
  Command ${command.type} parser is not found
5092
5135
 
5093
5136
  ${block(JSON.stringify(command, null, 4)
@@ -5163,7 +5206,7 @@ function parseCommand(raw, usagePlace) {
5163
5206
  .map(removeMarkdownFormatting)
5164
5207
  .map((item) => item.trim());
5165
5208
  if (items.length === 0 || items[0] === '') {
5166
- throw new ParseError(spaceTrim((block) => `
5209
+ throw new ParseError(spaceTrim$1((block) => `
5167
5210
  Malformed command:
5168
5211
  - ${raw}
5169
5212
 
@@ -5199,7 +5242,7 @@ function parseCommand(raw, usagePlace) {
5199
5242
  return command;
5200
5243
  }
5201
5244
  }
5202
- throw new ParseError(spaceTrim((block) => `
5245
+ throw new ParseError(spaceTrim$1((block) => `
5203
5246
  Malformed or unknown command:
5204
5247
  - ${raw}
5205
5248
 
@@ -5250,7 +5293,7 @@ function parseCommandVariant(input) {
5250
5293
  if (!(error instanceof ParseError)) {
5251
5294
  throw error;
5252
5295
  }
5253
- throw new ParseError(spaceTrim((block) => `
5296
+ throw new ParseError(spaceTrim$1((block) => `
5254
5297
  Invalid ${commandName} command:
5255
5298
 
5256
5299
  Your command:
@@ -5527,6 +5570,8 @@ function isValidEmail(email) {
5527
5570
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
5528
5571
  * It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
5529
5572
  *
5573
+ * Note: [🔂] This function is idempotent.
5574
+ *
5530
5575
  * @param {string} pipelineString the candidate for a pipeline string
5531
5576
  * @returns {PipelineString} the same string as input, but validated as valid
5532
5577
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -5560,6 +5605,48 @@ function validatePipelineString(pipelineString) {
5560
5605
  const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
5561
5606
  // <- TODO: [🏥] DRY
5562
5607
 
5608
+ /**
5609
+ * Number of padding lines to add at the end of the book content
5610
+ *
5611
+ * @public exported from `@promptbook/core`
5612
+ */
5613
+ const PADDING_LINES = 11;
5614
+ /**
5615
+ * A function that adds padding to the book content
5616
+ *
5617
+ * Note: [🔂] This function is idempotent.
5618
+ *
5619
+ * @public exported from `@promptbook/core`
5620
+ */
5621
+ function padBook(content) {
5622
+ if (!content) {
5623
+ return '\n'.repeat(PADDING_LINES);
5624
+ }
5625
+ const lines = content.split('\n');
5626
+ let trailingEmptyLines = 0;
5627
+ for (let i = lines.length - 1; i >= 0; i--) {
5628
+ const line = lines[i];
5629
+ if (line === undefined) {
5630
+ // Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
5631
+ continue;
5632
+ }
5633
+ if (line.trim() === '') {
5634
+ trailingEmptyLines++;
5635
+ }
5636
+ else {
5637
+ break;
5638
+ }
5639
+ }
5640
+ if (trailingEmptyLines >= PADDING_LINES) {
5641
+ return content;
5642
+ }
5643
+ const linesToAdd = PADDING_LINES - trailingEmptyLines;
5644
+ return (content + '\n'.repeat(linesToAdd));
5645
+ }
5646
+ /**
5647
+ * TODO: [🧠] Maybe export
5648
+ */
5649
+
5563
5650
  /**
5564
5651
  * Removes Markdown (or HTML) comments
5565
5652
  *
@@ -5568,7 +5655,7 @@ const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
5568
5655
  * @public exported from `@promptbook/markdown-utils`
5569
5656
  */
5570
5657
  function removeMarkdownComments(content) {
5571
- return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
5658
+ return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
5572
5659
  }
5573
5660
 
5574
5661
  /**
@@ -5579,7 +5666,7 @@ function removeMarkdownComments(content) {
5579
5666
  */
5580
5667
  function isFlatPipeline(pipelineString) {
5581
5668
  pipelineString = removeMarkdownComments(pipelineString);
5582
- pipelineString = spaceTrim$1(pipelineString);
5669
+ pipelineString = spaceTrim$2(pipelineString);
5583
5670
  const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
5584
5671
  //const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
5585
5672
  const isBacktickBlockUsed = pipelineString.includes('```');
@@ -5605,6 +5692,7 @@ function deflatePipeline(pipelineString) {
5605
5692
  if (!isFlatPipeline(pipelineString)) {
5606
5693
  return pipelineString;
5607
5694
  }
5695
+ pipelineString = spaceTrim$2(pipelineString);
5608
5696
  const pipelineStringLines = pipelineString.split('\n');
5609
5697
  const potentialReturnStatement = pipelineStringLines.pop();
5610
5698
  let returnStatement;
@@ -5617,19 +5705,19 @@ function deflatePipeline(pipelineString) {
5617
5705
  returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
5618
5706
  pipelineStringLines.push(potentialReturnStatement);
5619
5707
  }
5620
- const prompt = spaceTrim$1(pipelineStringLines.join('\n'));
5708
+ const prompt = spaceTrim$2(pipelineStringLines.join('\n'));
5621
5709
  let quotedPrompt;
5622
5710
  if (prompt.split('\n').length <= 1) {
5623
5711
  quotedPrompt = `> ${prompt}`;
5624
5712
  }
5625
5713
  else {
5626
- quotedPrompt = spaceTrim$1((block) => `
5714
+ quotedPrompt = spaceTrim$2((block) => `
5627
5715
  \`\`\`
5628
5716
  ${block(prompt.split('`').join('\\`'))}
5629
5717
  \`\`\`
5630
5718
  `);
5631
5719
  }
5632
- pipelineString = validatePipelineString(spaceTrim$1((block) => `
5720
+ pipelineString = validatePipelineString(spaceTrim$2((block) => `
5633
5721
  # ${DEFAULT_BOOK_TITLE}
5634
5722
 
5635
5723
  ## Prompt
@@ -5639,7 +5727,7 @@ function deflatePipeline(pipelineString) {
5639
5727
  ${returnStatement}
5640
5728
  `));
5641
5729
  // <- TODO: Maybe use book` notation
5642
- return pipelineString;
5730
+ return padBook(pipelineString);
5643
5731
  }
5644
5732
  /**
5645
5733
  * TODO: Unit test
@@ -5770,7 +5858,7 @@ function extractAllBlocksFromMarkdown(markdown) {
5770
5858
  function extractOneBlockFromMarkdown(markdown) {
5771
5859
  const codeBlocks = extractAllBlocksFromMarkdown(markdown);
5772
5860
  if (codeBlocks.length !== 1) {
5773
- throw new ParseError(spaceTrim$1((block) => `
5861
+ throw new ParseError(spaceTrim$2((block) => `
5774
5862
  There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
5775
5863
 
5776
5864
  ${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
@@ -5795,7 +5883,7 @@ function parseMarkdownSection(value) {
5795
5883
  }
5796
5884
  const title = lines[0].replace(/^#+\s*/, '');
5797
5885
  const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
5798
- const content = spaceTrim$1(lines.slice(1).join('\n'));
5886
+ const content = spaceTrim$2(lines.slice(1).join('\n'));
5799
5887
  if (level < 1 || level > 6) {
5800
5888
  throw new ParseError('Markdown section must have heading level between 1 and 6');
5801
5889
  }
@@ -5823,7 +5911,7 @@ function splitMarkdownIntoSections(markdown) {
5823
5911
  if (buffer.length === 0) {
5824
5912
  return;
5825
5913
  }
5826
- let section = spaceTrim$1(buffer.join('\n'));
5914
+ let section = spaceTrim$2(buffer.join('\n'));
5827
5915
  if (section === '') {
5828
5916
  return;
5829
5917
  }
@@ -5898,7 +5986,7 @@ function flattenMarkdown(markdown) {
5898
5986
  flattenedMarkdown += `## ${title}` + `\n\n`;
5899
5987
  flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
5900
5988
  }
5901
- return spaceTrim$1(flattenedMarkdown);
5989
+ return spaceTrim$2(flattenedMarkdown);
5902
5990
  }
5903
5991
  /**
5904
5992
  * TODO: [🏛] This can be part of markdown builder
@@ -5911,6 +5999,8 @@ function flattenMarkdown(markdown) {
5911
5999
  /**
5912
6000
  * Converts a title string into a normalized name.
5913
6001
  *
6002
+ * Note: [🔂] This function is idempotent.
6003
+ *
5914
6004
  * @param value The title string to be converted to a name.
5915
6005
  * @returns A normalized name derived from the input title.
5916
6006
  * @example 'Hello World!' -> 'hello-world'
@@ -5984,7 +6074,7 @@ function extractVariablesFromJavascript(script) {
5984
6074
  }
5985
6075
  catch (error) {
5986
6076
  assertsError(error);
5987
- throw new ParseError(spaceTrim((block) => `
6077
+ throw new ParseError(spaceTrim$1((block) => `
5988
6078
  Can not extract variables from the script
5989
6079
  ${block(error.stack || error.message)}
5990
6080
 
@@ -6126,7 +6216,7 @@ function parsePipeline(pipelineString) {
6126
6216
  if (pipelineString.startsWith('#!')) {
6127
6217
  const [shebangLine, ...restLines] = pipelineString.split('\n');
6128
6218
  if (!(shebangLine || '').includes('ptbk')) {
6129
- throw new ParseError(spaceTrim((block) => `
6219
+ throw new ParseError(spaceTrim$1((block) => `
6130
6220
  It seems that you try to parse a book file which has non-standard shebang line for book files:
6131
6221
  Shebang line must contain 'ptbk'
6132
6222
 
@@ -6142,7 +6232,7 @@ function parsePipeline(pipelineString) {
6142
6232
  pipelineString = validatePipelineString(restLines.join('\n'));
6143
6233
  }
6144
6234
  pipelineString = removeMarkdownComments(pipelineString);
6145
- pipelineString = spaceTrim(pipelineString);
6235
+ pipelineString = spaceTrim$1(pipelineString);
6146
6236
  // <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
6147
6237
  pipelineString = deflatePipeline(pipelineString);
6148
6238
  // ==============
@@ -6154,7 +6244,7 @@ function parsePipeline(pipelineString) {
6154
6244
  // ==============
6155
6245
  // Note: 1️⃣◽4️⃣ Check markdown structure
6156
6246
  if (pipelineHead === undefined) {
6157
- throw new UnexpectedError(spaceTrim((block) => `
6247
+ throw new UnexpectedError(spaceTrim$1((block) => `
6158
6248
  Pipeline head is not defined
6159
6249
 
6160
6250
  ${block(getPipelineIdentification())}
@@ -6163,7 +6253,7 @@ function parsePipeline(pipelineString) {
6163
6253
  `));
6164
6254
  }
6165
6255
  if (pipelineHead.level !== 1) {
6166
- throw new UnexpectedError(spaceTrim((block) => `
6256
+ throw new UnexpectedError(spaceTrim$1((block) => `
6167
6257
  Pipeline head is not h1
6168
6258
 
6169
6259
  ${block(getPipelineIdentification())}
@@ -6172,7 +6262,7 @@ function parsePipeline(pipelineString) {
6172
6262
  `));
6173
6263
  }
6174
6264
  if (!pipelineSections.every((section) => section.level === 2)) {
6175
- throw new UnexpectedError(spaceTrim((block) => `
6265
+ throw new UnexpectedError(spaceTrim$1((block) => `
6176
6266
  Not every pipeline section is h2
6177
6267
 
6178
6268
  ${block(getPipelineIdentification())}
@@ -6185,7 +6275,7 @@ function parsePipeline(pipelineString) {
6185
6275
  const defineParam = (parameterCommand) => {
6186
6276
  const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
6187
6277
  if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
6188
- throw new ParseError(spaceTrim((block) => `
6278
+ throw new ParseError(spaceTrim$1((block) => `
6189
6279
  Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
6190
6280
 
6191
6281
  ${block(getPipelineIdentification())}
@@ -6196,7 +6286,7 @@ function parsePipeline(pipelineString) {
6196
6286
  existingParameter.description &&
6197
6287
  existingParameter.description !== parameterDescription &&
6198
6288
  parameterDescription) {
6199
- throw new ParseError(spaceTrim((block) => `
6289
+ throw new ParseError(spaceTrim$1((block) => `
6200
6290
  Parameter \`{${parameterName}}\` is defined multiple times with different description:
6201
6291
 
6202
6292
  ${block(getPipelineIdentification())}
@@ -6234,7 +6324,7 @@ function parsePipeline(pipelineString) {
6234
6324
  description = description.split(/^>.*$/gm).join('');
6235
6325
  //Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
6236
6326
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6237
- description = spaceTrim(description);
6327
+ description = spaceTrim$1(description);
6238
6328
  if (description === '') {
6239
6329
  description = undefined;
6240
6330
  }
@@ -6245,7 +6335,7 @@ function parsePipeline(pipelineString) {
6245
6335
  const command = parseCommand(listItem, 'PIPELINE_HEAD');
6246
6336
  const commandParser = getParserForCommand(command);
6247
6337
  if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
6248
- throw new ParseError(spaceTrim((block) => `
6338
+ throw new ParseError(spaceTrim$1((block) => `
6249
6339
  Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
6250
6340
 
6251
6341
  ${block(getPipelineIdentification())}
@@ -6259,7 +6349,7 @@ function parsePipeline(pipelineString) {
6259
6349
  if (!(error instanceof ParseError)) {
6260
6350
  throw error;
6261
6351
  }
6262
- throw new ParseError(spaceTrim((block) => `
6352
+ throw new ParseError(spaceTrim$1((block) => `
6263
6353
  Command ${command.type} failed to apply to the pipeline
6264
6354
 
6265
6355
  The error:
@@ -6312,7 +6402,7 @@ function parsePipeline(pipelineString) {
6312
6402
  description = description.split(/^>.*$/gm).join('');
6313
6403
  //Note: Remove lists and return statement - TODO: [🎾]
6314
6404
  description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
6315
- description = spaceTrim(description);
6405
+ description = spaceTrim$1(description);
6316
6406
  if (description === '') {
6317
6407
  description = undefined;
6318
6408
  }
@@ -6346,7 +6436,7 @@ function parsePipeline(pipelineString) {
6346
6436
  for (const { listItem, command } of commands) {
6347
6437
  const commandParser = getParserForCommand(command);
6348
6438
  if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
6349
- throw new ParseError(spaceTrim((block) => `
6439
+ throw new ParseError(spaceTrim$1((block) => `
6350
6440
  Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
6351
6441
 
6352
6442
  ${block(getPipelineIdentification())}
@@ -6361,7 +6451,7 @@ function parsePipeline(pipelineString) {
6361
6451
  if (!(error instanceof ParseError)) {
6362
6452
  throw error;
6363
6453
  }
6364
- throw new ParseError(spaceTrim((block) => `
6454
+ throw new ParseError(spaceTrim$1((block) => `
6365
6455
  Command \`${command.type}\` failed to apply to the task
6366
6456
 
6367
6457
  The error:
@@ -6392,14 +6482,14 @@ function parsePipeline(pipelineString) {
6392
6482
  // TODO: [🍧] Should be done in SECTION command
6393
6483
  if ($taskJson.taskType === 'SCRIPT_TASK') {
6394
6484
  if (!language) {
6395
- throw new ParseError(spaceTrim((block) => `
6485
+ throw new ParseError(spaceTrim$1((block) => `
6396
6486
  You must specify the language of the script in the \`SCRIPT\` task
6397
6487
 
6398
6488
  ${block(getPipelineIdentification())}
6399
6489
  `));
6400
6490
  }
6401
6491
  if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
6402
- throw new ParseError(spaceTrim((block) => `
6492
+ throw new ParseError(spaceTrim$1((block) => `
6403
6493
  Script language ${language} is not supported.
6404
6494
 
6405
6495
  Supported languages are: