@promptbook/remote-server 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 +524 -389
  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 +8 -8
  257. package/umd/index.umd.js +545 -409
  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/umd/index.umd.js CHANGED
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('colors'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('spacetrim'), require('swagger-ui-express'), require('waitasecond'), require('crypto'), require('child_process'), require('fs/promises'), require('path'), require('rxjs'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse'), require('react'), require('react-dom/server')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'colors', 'express', 'express-openapi-validator', 'http', 'socket.io', 'spacetrim', 'swagger-ui-express', 'waitasecond', 'crypto', 'child_process', 'fs/promises', 'path', 'rxjs', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse', 'react', 'react-dom/server'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.colors, global.express, global.OpenApiValidator, global.http, global.socket_io, global.spaceTrim, global.swaggerUi, global.waitasecond, global.crypto, global.child_process, global.promises, global.path, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse, global.react, global.server));
5
- })(this, (function (exports, colors, express, OpenApiValidator, http, socket_io, spaceTrim, swaggerUi, waitasecond, crypto, child_process, promises, path, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse, react, server) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('path'), require('child_process'), require('colors'), require('spacetrim'), require('waitasecond'), require('express'), require('express-openapi-validator'), require('http'), require('socket.io'), require('swagger-ui-express'), require('crypto'), require('fs/promises'), require('rxjs'), require('crypto-js/enc-hex'), require('crypto-js/sha256'), require('crypto-js'), require('mime-types'), require('papaparse'), require('react'), require('react-dom/server')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'path', 'child_process', 'colors', 'spacetrim', 'waitasecond', 'express', 'express-openapi-validator', 'http', 'socket.io', 'swagger-ui-express', 'crypto', 'fs/promises', 'rxjs', 'crypto-js/enc-hex', 'crypto-js/sha256', 'crypto-js', 'mime-types', 'papaparse', 'react', 'react-dom/server'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-server"] = {}, global.path, global.child_process, global.colors, global.spaceTrim$1, global.waitasecond, global.express, global.OpenApiValidator, global.http, global.socket_io, global.swaggerUi, global.crypto, global.promises, global.rxjs, global.hexEncoder, global.sha256, global.cryptoJs, global.mimeTypes, global.papaparse, global.react, global.server));
5
+ })(this, (function (exports, path, child_process, colors, spaceTrim$1, waitasecond, express, OpenApiValidator, http, socket_io, swaggerUi, crypto, promises, rxjs, hexEncoder, sha256, cryptoJs, mimeTypes, papaparse, react, server) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,10 +25,10 @@
25
25
  }
26
26
 
27
27
  var colors__default = /*#__PURE__*/_interopDefaultLegacy(colors);
28
+ var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
28
29
  var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
29
30
  var OpenApiValidator__namespace = /*#__PURE__*/_interopNamespace(OpenApiValidator);
30
31
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
31
- var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
32
32
  var swaggerUi__default = /*#__PURE__*/_interopDefaultLegacy(swaggerUi);
33
33
  var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
34
34
  var sha256__default = /*#__PURE__*/_interopDefaultLegacy(sha256);
@@ -40,19 +40,30 @@
40
40
  * @generated
41
41
  * @see https://github.com/webgptorg/book
42
42
  */
43
- const BOOK_LANGUAGE_VERSION = '1.0.0';
43
+ const BOOK_LANGUAGE_VERSION = '2.0.0';
44
44
  /**
45
45
  * The version of the Promptbook engine
46
46
  *
47
47
  * @generated
48
48
  * @see https://github.com/webgptorg/promptbook
49
49
  */
50
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-9';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0';
51
51
  /**
52
52
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
53
53
  * Note: [💞] Ignore a discrepancy between file name and entity name
54
54
  */
55
55
 
56
+ /**
57
+ * Trims string from all 4 sides
58
+ *
59
+ * Note: This is a re-exported function from the `spacetrim` package which is
60
+ * Developed by same author @hejny as this package
61
+ *
62
+ * @public exported from `@promptbook/utils`
63
+ * @see https://github.com/hejny/spacetrim#usage
64
+ */
65
+ const spaceTrim = spaceTrim$1.spaceTrim;
66
+
56
67
  /**
57
68
  * @private util of `@promptbook/color`
58
69
  * @de
@@ -101,6 +112,7 @@
101
112
  * @public exported from `@promptbook/color`
102
113
  */
103
114
  const CSS_COLORS = {
115
+ promptbook: '#79EAFD',
104
116
  transparent: 'rgba(0,0,0,0)',
105
117
  aliceblue: '#f0f8ff',
106
118
  antiquewhite: '#faebd7',
@@ -282,9 +294,6 @@
282
294
  throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
283
295
  }
284
296
  }
285
- /**
286
- * TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
287
- */
288
297
 
289
298
  /**
290
299
  * Color object represents an RGB color with alpha channel
@@ -304,21 +313,61 @@
304
313
  * @param color
305
314
  * @returns Color object
306
315
  */
307
- static from(color) {
308
- if (color instanceof Color) {
316
+ static from(color, _isSingleValue = false) {
317
+ if (color === '') {
318
+ throw new Error(`Can not create color from empty string`);
319
+ }
320
+ else if (color instanceof Color) {
309
321
  return take(color);
310
322
  }
311
323
  else if (Color.isColor(color)) {
312
324
  return take(color);
313
325
  }
314
326
  else if (typeof color === 'string') {
315
- return Color.fromString(color);
327
+ try {
328
+ return Color.fromString(color);
329
+ }
330
+ catch (error) {
331
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
332
+ if (_isSingleValue) {
333
+ throw error;
334
+ }
335
+ const parts = color.split(/[\s+,;|]/);
336
+ if (parts.length > 0) {
337
+ return Color.from(parts[0].trim(), true);
338
+ }
339
+ else {
340
+ throw new Error(`Can not create color from given string "${color}"`);
341
+ }
342
+ }
316
343
  }
317
344
  else {
318
345
  console.error({ color });
319
346
  throw new Error(`Can not create color from given object`);
320
347
  }
321
348
  }
349
+ /**
350
+ * Creates a new Color instance from miscellaneous formats
351
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
352
+ *
353
+ * @param color
354
+ * @returns Color object
355
+ */
356
+ static fromSafe(color) {
357
+ try {
358
+ return Color.from(color);
359
+ }
360
+ catch (error) {
361
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
362
+ console.warn(spaceTrim((block) => `
363
+ Color.fromSafe error:
364
+ ${block(error.message)}
365
+
366
+ Returning default PROMPTBOOK_COLOR.
367
+ `));
368
+ return Color.fromString('promptbook');
369
+ }
370
+ }
322
371
  /**
323
372
  * Creates a new Color instance from miscellaneous string formats
324
373
  *
@@ -386,6 +435,9 @@
386
435
  if (hex.length === 3) {
387
436
  return Color.fromHex3(hex);
388
437
  }
438
+ if (hex.length === 4) {
439
+ return Color.fromHex4(hex);
440
+ }
389
441
  if (hex.length === 6) {
390
442
  return Color.fromHex6(hex);
391
443
  }
@@ -406,6 +458,19 @@
406
458
  const b = parseInt(hex.substr(2, 1), 16) * 16;
407
459
  return take(new Color(r, g, b));
408
460
  }
461
+ /**
462
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
463
+ *
464
+ * @param color in hex for example `09df`
465
+ * @returns Color object
466
+ */
467
+ static fromHex4(hex) {
468
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
469
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
470
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
471
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
472
+ return take(new Color(r, g, b, a));
473
+ }
409
474
  /**
410
475
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
411
476
  *
@@ -596,7 +661,8 @@
596
661
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
597
662
  */
598
663
  static isHexColorString(value) {
599
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
664
+ return (typeof value === 'string' &&
665
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
600
666
  }
601
667
  /**
602
668
  * Creates new Color object
@@ -711,6 +777,23 @@
711
777
  * TODO: Maybe connect with textures
712
778
  */
713
779
 
780
+ /**
781
+ * Makes color transformer which returns a grayscale version of the color
782
+ *
783
+ * @param amount from 0 to 1
784
+ *
785
+ * @public exported from `@promptbook/color`
786
+ */
787
+ function grayscale(amount) {
788
+ return ({ red, green, blue, alpha }) => {
789
+ const average = (red + green + blue) / 3;
790
+ red = Math.round(average * amount + red * (1 - amount));
791
+ green = Math.round(average * amount + green * (1 - amount));
792
+ blue = Math.round(average * amount + blue * (1 - amount));
793
+ return Color.fromValues(red, green, blue, alpha);
794
+ };
795
+ }
796
+
714
797
  /**
715
798
  * Converts HSL values to RGB values
716
799
  *
@@ -826,102 +909,6 @@
826
909
  * TODO: Maybe implement by mix+hsl
827
910
  */
828
911
 
829
- /**
830
- * Calculates distance between two colors
831
- *
832
- * @param color1 first color
833
- * @param color2 second color
834
- *
835
- * Note: This function is inefficient. Use colorDistanceSquared instead if possible.
836
- *
837
- * @public exported from `@promptbook/color`
838
- */
839
- /**
840
- * Calculates distance between two colors without square root
841
- *
842
- * @param color1 first color
843
- * @param color2 second color
844
- *
845
- * @public exported from `@promptbook/color`
846
- */
847
- function colorDistanceSquared(color1, color2) {
848
- const rmean = (color1.red + color2.red) / 2;
849
- const r = color1.red - color2.red;
850
- const g = color1.green - color2.green;
851
- const b = color1.blue - color2.blue;
852
- const weightR = 2 + rmean / 256;
853
- const weightG = 4.0;
854
- const weightB = 2 + (255 - rmean) / 256;
855
- const distance = weightR * r * r + weightG * g * g + weightB * b * b;
856
- return distance;
857
- }
858
-
859
- /**
860
- * Makes color transformer which finds the nearest color from the given list
861
- *
862
- * @param colors array of colors to choose from
863
- *
864
- * @public exported from `@promptbook/color`
865
- */
866
- function nearest(...colors) {
867
- return (color) => {
868
- const distances = colors.map((c) => colorDistanceSquared(c, color));
869
- const minDistance = Math.min(...distances);
870
- const minIndex = distances.indexOf(minDistance);
871
- const nearestColor = colors[minIndex];
872
- return nearestColor;
873
- };
874
- }
875
-
876
- /**
877
- * Color transformer which returns the negative color
878
- *
879
- * @public exported from `@promptbook/color`
880
- */
881
- function negative(color) {
882
- const r = 255 - color.red;
883
- const g = 255 - color.green;
884
- const b = 255 - color.blue;
885
- return Color.fromValues(r, g, b, color.alpha);
886
- }
887
-
888
- /**
889
- * Makes color transformer which finds the furthest color from the given list
890
- *
891
- * @param colors array of colors to choose from
892
- *
893
- * @public exported from `@promptbook/color`
894
- */
895
- function furthest(...colors) {
896
- return (color) => {
897
- const furthestColor = negative(nearest(...colors.map(negative))(color));
898
- return furthestColor;
899
- };
900
- }
901
- /**
902
- * Makes color transformer which finds the best text color (black or white) for the given background color
903
- *
904
- * @public exported from `@promptbook/color`
905
- */
906
- furthest(Color.get('white'), Color.from('black'));
907
-
908
- /**
909
- * Makes color transformer which returns a grayscale version of the color
910
- *
911
- * @param amount from 0 to 1
912
- *
913
- * @public exported from `@promptbook/color`
914
- */
915
- function grayscale(amount) {
916
- return ({ red, green, blue, alpha }) => {
917
- const average = (red + green + blue) / 3;
918
- red = Math.round(average * amount + red * (1 - amount));
919
- green = Math.round(average * amount + green * (1 - amount));
920
- blue = Math.round(average * amount + blue * (1 - amount));
921
- return Color.fromValues(red, green, blue, alpha);
922
- };
923
- }
924
-
925
912
  /**
926
913
  * Makes color transformer which saturate the given color
927
914
  *
@@ -998,16 +985,32 @@
998
985
  *
999
986
  * @public exported from `@promptbook/core`
1000
987
  */
1001
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1002
- // <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
988
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
989
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
990
+ /**
991
+ * Colors for syntax highlighting in the `<BookEditor/>`
992
+ *
993
+ * TODO: [🗽] Unite branding and make single place for it
994
+ *
995
+ * @public exported from `@promptbook/core`
996
+ */
997
+ ({
998
+ TITLE: Color.fromHex('#244EA8'),
999
+ LINE: Color.fromHex('#eeeeee'),
1000
+ SEPARATOR: Color.fromHex('#cccccc'),
1001
+ COMMITMENT: Color.fromHex('#DA0F78'),
1002
+ PARAMETER: Color.fromHex('#8e44ad'),
1003
+ });
1004
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1003
1005
  /**
1004
- * Dark color of the Promptbook
1006
+ * Chat color of the Promptbook (in chat)
1005
1007
  *
1006
1008
  * TODO: [🗽] Unite branding and make single place for it
1007
1009
  *
1008
1010
  * @public exported from `@promptbook/core`
1009
1011
  */
1010
1012
  PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
1013
+ // <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
1011
1014
  /**
1012
1015
  * Color of the user (in chat)
1013
1016
  *
@@ -1016,6 +1019,7 @@
1016
1019
  * @public exported from `@promptbook/core`
1017
1020
  */
1018
1021
  Color.fromHex('#1D4ED8');
1022
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1019
1023
  /**
1020
1024
  * When the title is not provided, the default title is used
1021
1025
  *
@@ -1102,7 +1106,7 @@
1102
1106
  * @public exported from `@promptbook/core`
1103
1107
  */
1104
1108
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹‍♂️]
1105
- // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
1109
+ // <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
1106
1110
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
1107
1111
  /**
1108
1112
  * Where to store the temporary downloads
@@ -1151,24 +1155,246 @@
1151
1155
  */
1152
1156
  const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
1153
1157
  /**
1154
- * API request timeout in milliseconds
1155
- * Can be overridden via API_REQUEST_TIMEOUT environment variable
1156
- *
1157
- * @public exported from `@promptbook/core`
1158
+ * API request timeout in milliseconds
1159
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
1160
+ *
1161
+ * @public exported from `@promptbook/core`
1162
+ */
1163
+ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1164
+ /**
1165
+ * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
1166
+ *
1167
+ * @private within the repository
1168
+ */
1169
+ const IS_PIPELINE_LOGIC_VALIDATED = just(
1170
+ /**/
1171
+ // Note: In normal situations, we check the pipeline logic:
1172
+ true);
1173
+ /**
1174
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1175
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
1176
+ */
1177
+
1178
+ /**
1179
+ * This error type indicates that you try to use a feature that is not available in the current environment
1180
+ *
1181
+ * @public exported from `@promptbook/core`
1182
+ */
1183
+ class EnvironmentMismatchError extends Error {
1184
+ constructor(message) {
1185
+ super(message);
1186
+ this.name = 'EnvironmentMismatchError';
1187
+ Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
1188
+ }
1189
+ }
1190
+
1191
+ /**
1192
+ * Detects if the code is running in a Node.js environment
1193
+ *
1194
+ * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1195
+ *
1196
+ * @public exported from `@promptbook/utils`
1197
+ */
1198
+ const $isRunningInNode = new Function(`
1199
+ try {
1200
+ return this === global;
1201
+ } catch (e) {
1202
+ return false;
1203
+ }
1204
+ `);
1205
+ /**
1206
+ * TODO: [🎺]
1207
+ */
1208
+
1209
+ /**
1210
+ * Normalize options for `execCommand` and `execCommands`
1211
+ *
1212
+ * Note: `$` is used to indicate that this function behaves differently according to `process.platform`
1213
+ *
1214
+ * @private internal utility of `execCommand` and `execCommands`
1215
+ */
1216
+ function $execCommandNormalizeOptions(options) {
1217
+ var _a, _b, _c, _d;
1218
+ let command;
1219
+ let cwd;
1220
+ let crashOnError;
1221
+ let args = [];
1222
+ let timeout;
1223
+ let isVerbose;
1224
+ if (typeof options === 'string') {
1225
+ // TODO: [1] DRY default values
1226
+ command = options;
1227
+ cwd = process.cwd();
1228
+ crashOnError = true;
1229
+ timeout = Infinity; // <- TODO: [⏳]
1230
+ isVerbose = DEFAULT_IS_VERBOSE;
1231
+ }
1232
+ else {
1233
+ /*
1234
+ TODO:
1235
+ if ((options as any).commands !== undefined) {
1236
+ commands = (options as any).commands;
1237
+ } else {
1238
+ commands = [(options as any).command];
1239
+ }
1240
+ */
1241
+ // TODO: [1] DRY default values
1242
+ command = options.command;
1243
+ cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
1244
+ crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
1245
+ timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
1246
+ isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
1247
+ }
1248
+ // TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
1249
+ const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
1250
+ .map(([match]) => match)
1251
+ .filter((arg) => arg !== '');
1252
+ if (_.length > 1) {
1253
+ [command, ...args] = _;
1254
+ }
1255
+ if (options.args) {
1256
+ args = [...args, ...options.args];
1257
+ }
1258
+ let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
1259
+ if (['ts-node'].includes(humanReadableCommand)) {
1260
+ humanReadableCommand += ` ${args[1]}`;
1261
+ }
1262
+ if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
1263
+ command = `${command}.cmd`;
1264
+ }
1265
+ return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
1266
+ }
1267
+ // TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
1268
+
1269
+ /**
1270
+ * Run one command in a shell
1271
+ *
1272
+ *
1273
+ * Note: There are 2 similar functions in the codebase:
1274
+ * - `$execCommand` which runs a single command
1275
+ * - `$execCommands` which runs multiple commands
1276
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
1277
+ *
1278
+ * @public exported from `@promptbook/node`
1279
+ */
1280
+ function $execCommand(options) {
1281
+ if (!$isRunningInNode()) {
1282
+ throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
1283
+ }
1284
+ return new Promise((resolve, reject) => {
1285
+ // eslint-disable-next-line prefer-const
1286
+ const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
1287
+ if (timeout !== Infinity) {
1288
+ // TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
1289
+ waitasecond.forTime(timeout).then(() => {
1290
+ if (crashOnError) {
1291
+ reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
1292
+ }
1293
+ else {
1294
+ console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
1295
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1296
+ resolve('Command exceeded time limit');
1297
+ }
1298
+ });
1299
+ }
1300
+ if (isVerbose) {
1301
+ console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
1302
+ }
1303
+ try {
1304
+ const commandProcess = child_process.spawn(command, args, { cwd, shell: true });
1305
+ if (isVerbose) {
1306
+ commandProcess.on('message', (message) => {
1307
+ console.info({ message });
1308
+ });
1309
+ }
1310
+ const output = [];
1311
+ commandProcess.stdout.on('data', (stdout) => {
1312
+ output.push(stdout.toString());
1313
+ if (isVerbose) {
1314
+ console.info(stdout.toString());
1315
+ }
1316
+ });
1317
+ commandProcess.stderr.on('data', (stderr) => {
1318
+ output.push(stderr.toString());
1319
+ if (isVerbose && stderr.toString().trim()) {
1320
+ console.warn(stderr.toString());
1321
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1322
+ }
1323
+ });
1324
+ const finishWithCode = (code) => {
1325
+ if (code !== 0) {
1326
+ if (crashOnError) {
1327
+ reject(new Error(output.join('\n').trim() ||
1328
+ `Command "${humanReadableCommand}" exited with code ${code}`));
1329
+ }
1330
+ else {
1331
+ if (isVerbose) {
1332
+ console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1333
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1334
+ }
1335
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1336
+ }
1337
+ }
1338
+ else {
1339
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1340
+ }
1341
+ };
1342
+ commandProcess.on('close', finishWithCode);
1343
+ commandProcess.on('exit', finishWithCode);
1344
+ commandProcess.on('disconnect', () => {
1345
+ // Note: Unexpected disconnection should always result in rejection
1346
+ reject(new Error(`Command "${humanReadableCommand}" disconnected`));
1347
+ });
1348
+ commandProcess.on('error', (error) => {
1349
+ if (crashOnError) {
1350
+ reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
1351
+ }
1352
+ else {
1353
+ if (isVerbose) {
1354
+ console.warn(error);
1355
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1356
+ }
1357
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1358
+ }
1359
+ });
1360
+ }
1361
+ catch (error) {
1362
+ // Note: Unexpected error in sync code should always result in rejection
1363
+ reject(error);
1364
+ }
1365
+ });
1366
+ }
1367
+ /**
1368
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1158
1369
  */
1159
- parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1370
+
1160
1371
  /**
1161
- * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
1372
+ * [🐱‍🚀]
1373
+ * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
1162
1374
  *
1163
- * @private within the repository
1164
- */
1165
- const IS_PIPELINE_LOGIC_VALIDATED = just(
1166
- /**/
1167
- // Note: In normal situations, we check the pipeline logic:
1168
- true);
1375
+ * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
1376
+ * This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
1377
+ *
1378
+ * @see https://github.com/webgptorg/promptbook#remote-server
1379
+ * @public exported from `@promptbook/remote-server`
1380
+ * <- TODO: [🐱‍🚀] Change to `@promptbook/agent-server`
1381
+ */
1382
+ async function startAgentServer(options) {
1383
+ const { port = 4440 } = options;
1384
+ // TODO: [🐱‍🚀] [🌕]
1385
+ const agentsServerRoot = path.join(__dirname, '../apps/agents-server');
1386
+ console.trace(`!!! Starting agents server on port ${port}...`);
1387
+ console.log(`!!! cwd`, process.cwd());
1388
+ console.log(`!!! __dirname`, __dirname);
1389
+ console.log(`!!! agentsServerRoot`, agentsServerRoot);
1390
+ await $execCommand({
1391
+ cwd: agentsServerRoot,
1392
+ command: `next dev --port ${port} `,
1393
+ isVerbose: true,
1394
+ });
1395
+ }
1169
1396
  /**
1170
- * Note: [💞] Ignore a discrepancy between file name and entity name
1171
- * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
1397
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1172
1398
  */
1173
1399
 
1174
1400
  /**
@@ -1222,7 +1448,7 @@
1222
1448
  */
1223
1449
  class UnexpectedError extends Error {
1224
1450
  constructor(message) {
1225
- super(spaceTrim.spaceTrim((block) => `
1451
+ super(spaceTrim$1.spaceTrim((block) => `
1226
1452
  ${block(message)}
1227
1453
 
1228
1454
  Note: This error should not happen.
@@ -1248,7 +1474,7 @@
1248
1474
  constructor(whatWasThrown) {
1249
1475
  const tag = `[🤮]`;
1250
1476
  console.error(tag, whatWasThrown);
1251
- super(spaceTrim.spaceTrim(`
1477
+ super(spaceTrim$1.spaceTrim(`
1252
1478
  Non-Error object was thrown
1253
1479
 
1254
1480
  Note: Look for ${tag} in the console for more details
@@ -1303,6 +1529,7 @@
1303
1529
  /**
1304
1530
  * Generates random token
1305
1531
  *
1532
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
1306
1533
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
1307
1534
  *
1308
1535
  * @private internal helper function
@@ -1312,6 +1539,7 @@
1312
1539
  return crypto.randomBytes(randomness).toString('hex');
1313
1540
  }
1314
1541
  /**
1542
+ * TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
1315
1543
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1316
1544
  */
1317
1545
 
@@ -1378,17 +1606,20 @@
1378
1606
  }
1379
1607
 
1380
1608
  /**
1381
- * This error type indicates that you try to use a feature that is not available in the current environment
1609
+ * This error indicates error from the database
1382
1610
  *
1383
1611
  * @public exported from `@promptbook/core`
1384
1612
  */
1385
- class EnvironmentMismatchError extends Error {
1613
+ class DatabaseError extends Error {
1386
1614
  constructor(message) {
1387
1615
  super(message);
1388
- this.name = 'EnvironmentMismatchError';
1389
- Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
1616
+ this.name = 'DatabaseError';
1617
+ Object.setPrototypeOf(this, DatabaseError.prototype);
1390
1618
  }
1391
1619
  }
1620
+ /**
1621
+ * TODO: [🐱‍🚀] Explain that NotFoundError ([🐱‍🚀] and other specific errors) has priority over DatabaseError in some contexts
1622
+ */
1392
1623
 
1393
1624
  /**
1394
1625
  * This error occurs when some expectation is not met in the execution of the pipeline
@@ -1439,7 +1670,7 @@
1439
1670
  */
1440
1671
  class MissingToolsError extends Error {
1441
1672
  constructor(message) {
1442
- super(spaceTrim.spaceTrim((block) => `
1673
+ super(spaceTrim$1.spaceTrim((block) => `
1443
1674
  ${block(message)}
1444
1675
 
1445
1676
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -1450,6 +1681,19 @@
1450
1681
  }
1451
1682
  }
1452
1683
 
1684
+ /**
1685
+ * This error indicates that promptbook operation is not allowed
1686
+ *
1687
+ * @public exported from `@promptbook/core`
1688
+ */
1689
+ class NotAllowed extends Error {
1690
+ constructor(message) {
1691
+ super(message);
1692
+ this.name = 'NotAllowed';
1693
+ Object.setPrototypeOf(this, NotAllowed.prototype);
1694
+ }
1695
+ }
1696
+
1453
1697
  /**
1454
1698
  * This error indicates that promptbook not found in the collection
1455
1699
  *
@@ -1470,7 +1714,7 @@
1470
1714
  */
1471
1715
  class NotYetImplementedError extends Error {
1472
1716
  constructor(message) {
1473
- super(spaceTrim.spaceTrim((block) => `
1717
+ super(spaceTrim$1.spaceTrim((block) => `
1474
1718
  ${block(message)}
1475
1719
 
1476
1720
  Note: This feature is not implemented yet but it will be soon.
@@ -1565,6 +1809,8 @@
1565
1809
  PromptbookFetchError,
1566
1810
  UnexpectedError,
1567
1811
  WrappedError,
1812
+ NotAllowed,
1813
+ DatabaseError,
1568
1814
  // TODO: [🪑]> VersionMismatchError,
1569
1815
  };
1570
1816
  /**
@@ -1632,186 +1878,6 @@
1632
1878
  };
1633
1879
  }
1634
1880
 
1635
- /**
1636
- * Detects if the code is running in a Node.js environment
1637
- *
1638
- * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1639
- *
1640
- * @public exported from `@promptbook/utils`
1641
- */
1642
- const $isRunningInNode = new Function(`
1643
- try {
1644
- return this === global;
1645
- } catch (e) {
1646
- return false;
1647
- }
1648
- `);
1649
- /**
1650
- * TODO: [🎺]
1651
- */
1652
-
1653
- /**
1654
- * Normalize options for `execCommand` and `execCommands`
1655
- *
1656
- * Note: `$` is used to indicate that this function behaves differently according to `process.platform`
1657
- *
1658
- * @private internal utility of `execCommand` and `execCommands`
1659
- */
1660
- function $execCommandNormalizeOptions(options) {
1661
- var _a, _b, _c, _d;
1662
- let command;
1663
- let cwd;
1664
- let crashOnError;
1665
- let args = [];
1666
- let timeout;
1667
- let isVerbose;
1668
- if (typeof options === 'string') {
1669
- // TODO: [1] DRY default values
1670
- command = options;
1671
- cwd = process.cwd();
1672
- crashOnError = true;
1673
- timeout = Infinity; // <- TODO: [⏳]
1674
- isVerbose = DEFAULT_IS_VERBOSE;
1675
- }
1676
- else {
1677
- /*
1678
- TODO:
1679
- if ((options as any).commands !== undefined) {
1680
- commands = (options as any).commands;
1681
- } else {
1682
- commands = [(options as any).command];
1683
- }
1684
- */
1685
- // TODO: [1] DRY default values
1686
- command = options.command;
1687
- cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
1688
- crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
1689
- timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
1690
- isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
1691
- }
1692
- // TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
1693
- const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
1694
- .map(([match]) => match)
1695
- .filter((arg) => arg !== '');
1696
- if (_.length > 1) {
1697
- [command, ...args] = _;
1698
- }
1699
- if (options.args) {
1700
- args = [...args, ...options.args];
1701
- }
1702
- let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
1703
- if (['ts-node'].includes(humanReadableCommand)) {
1704
- humanReadableCommand += ` ${args[1]}`;
1705
- }
1706
- if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
1707
- command = `${command}.cmd`;
1708
- }
1709
- return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
1710
- }
1711
- // TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
1712
-
1713
- /**
1714
- * Run one command in a shell
1715
- *
1716
- *
1717
- * Note: There are 2 similar functions in the codebase:
1718
- * - `$execCommand` which runs a single command
1719
- * - `$execCommands` which runs multiple commands
1720
- * Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
1721
- *
1722
- * @public exported from `@promptbook/node`
1723
- */
1724
- function $execCommand(options) {
1725
- if (!$isRunningInNode()) {
1726
- throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
1727
- }
1728
- return new Promise((resolve, reject) => {
1729
- // eslint-disable-next-line prefer-const
1730
- const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
1731
- if (timeout !== Infinity) {
1732
- // TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
1733
- waitasecond.forTime(timeout).then(() => {
1734
- if (crashOnError) {
1735
- reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
1736
- }
1737
- else {
1738
- console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
1739
- // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1740
- resolve('Command exceeded time limit');
1741
- }
1742
- });
1743
- }
1744
- if (isVerbose) {
1745
- console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
1746
- }
1747
- try {
1748
- const commandProcess = child_process.spawn(command, args, { cwd, shell: true });
1749
- if (isVerbose) {
1750
- commandProcess.on('message', (message) => {
1751
- console.info({ message });
1752
- });
1753
- }
1754
- const output = [];
1755
- commandProcess.stdout.on('data', (stdout) => {
1756
- output.push(stdout.toString());
1757
- if (isVerbose) {
1758
- console.info(stdout.toString());
1759
- }
1760
- });
1761
- commandProcess.stderr.on('data', (stderr) => {
1762
- output.push(stderr.toString());
1763
- if (isVerbose && stderr.toString().trim()) {
1764
- console.warn(stderr.toString());
1765
- // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1766
- }
1767
- });
1768
- const finishWithCode = (code) => {
1769
- if (code !== 0) {
1770
- if (crashOnError) {
1771
- reject(new Error(output.join('\n').trim() ||
1772
- `Command "${humanReadableCommand}" exited with code ${code}`));
1773
- }
1774
- else {
1775
- if (isVerbose) {
1776
- console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1777
- // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1778
- }
1779
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1780
- }
1781
- }
1782
- else {
1783
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1784
- }
1785
- };
1786
- commandProcess.on('close', finishWithCode);
1787
- commandProcess.on('exit', finishWithCode);
1788
- commandProcess.on('disconnect', () => {
1789
- // Note: Unexpected disconnection should always result in rejection
1790
- reject(new Error(`Command "${humanReadableCommand}" disconnected`));
1791
- });
1792
- commandProcess.on('error', (error) => {
1793
- if (crashOnError) {
1794
- reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
1795
- }
1796
- else {
1797
- if (isVerbose) {
1798
- console.warn(error);
1799
- // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1800
- }
1801
- resolve(spaceTrim.spaceTrim(output.join('\n')));
1802
- }
1803
- });
1804
- }
1805
- catch (error) {
1806
- // Note: Unexpected error in sync code should always result in rejection
1807
- reject(error);
1808
- }
1809
- });
1810
- }
1811
- /**
1812
- * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1813
- */
1814
-
1815
1881
  /**
1816
1882
  * Attempts to locate the specified application on a Linux system using the 'which' command.
1817
1883
  * Returns the path to the executable if found, or null otherwise.
@@ -1851,6 +1917,7 @@
1851
1917
  writeFile: promises.writeFile,
1852
1918
  readdir: promises.readdir,
1853
1919
  mkdir: promises.mkdir,
1920
+ watch: promises.watch,
1854
1921
  };
1855
1922
  }
1856
1923
  /**
@@ -2239,7 +2306,7 @@
2239
2306
  TODO: [🧠] Is there a better implementation?
2240
2307
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
2241
2308
  > for (const propertyName of propertyNames) {
2242
- > const value = (objectValue as really_any)[propertyName];
2309
+ > const value = (objectValue as chococake)[propertyName];
2243
2310
  > if (value && typeof value === 'object') {
2244
2311
  > deepClone(value);
2245
2312
  > }
@@ -2461,6 +2528,8 @@
2461
2528
  * - if it is valid json
2462
2529
  * - if it is meaningful
2463
2530
  *
2531
+ * Note: [🔂] This function is idempotent.
2532
+ *
2464
2533
  * @param pipeline valid or invalid PipelineJson
2465
2534
  * @returns the same pipeline if it is logically valid
2466
2535
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -2478,7 +2547,7 @@
2478
2547
  if (!(error instanceof PipelineLogicError)) {
2479
2548
  throw error;
2480
2549
  }
2481
- console.error(spaceTrim.spaceTrim((block) => `
2550
+ console.error(spaceTrim$1.spaceTrim((block) => `
2482
2551
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2483
2552
 
2484
2553
  ${block(error.message)}
@@ -2505,7 +2574,7 @@
2505
2574
  })();
2506
2575
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2507
2576
  // <- Note: [🚲]
2508
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2577
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2509
2578
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2510
2579
 
2511
2580
  ${block(pipelineIdentification)}
@@ -2513,7 +2582,7 @@
2513
2582
  }
2514
2583
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2515
2584
  // <- Note: [🚲]
2516
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2585
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2517
2586
  Invalid Promptbook Version "${pipeline.bookVersion}"
2518
2587
 
2519
2588
  ${block(pipelineIdentification)}
@@ -2522,7 +2591,7 @@
2522
2591
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2523
2592
  if (!Array.isArray(pipeline.parameters)) {
2524
2593
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2525
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2594
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2526
2595
  Pipeline is valid JSON but with wrong structure
2527
2596
 
2528
2597
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2533,7 +2602,7 @@
2533
2602
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2534
2603
  if (!Array.isArray(pipeline.tasks)) {
2535
2604
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2536
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2605
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2537
2606
  Pipeline is valid JSON but with wrong structure
2538
2607
 
2539
2608
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2559,7 +2628,7 @@
2559
2628
  // Note: Check each parameter individually
2560
2629
  for (const parameter of pipeline.parameters) {
2561
2630
  if (parameter.isInput && parameter.isOutput) {
2562
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2631
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2563
2632
 
2564
2633
  Parameter \`{${parameter.name}}\` can not be both input and output
2565
2634
 
@@ -2570,7 +2639,7 @@
2570
2639
  if (!parameter.isInput &&
2571
2640
  !parameter.isOutput &&
2572
2641
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2573
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2642
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2574
2643
  Parameter \`{${parameter.name}}\` is created but not used
2575
2644
 
2576
2645
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2582,7 +2651,7 @@
2582
2651
  }
2583
2652
  // Note: Testing that parameter is either input or result of some task
2584
2653
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2585
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2654
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2586
2655
  Parameter \`{${parameter.name}}\` is declared but not defined
2587
2656
 
2588
2657
  You can do one of these:
@@ -2598,14 +2667,14 @@
2598
2667
  // Note: Checking each task individually
2599
2668
  for (const task of pipeline.tasks) {
2600
2669
  if (definedParameters.has(task.resultingParameterName)) {
2601
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2670
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2602
2671
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2603
2672
 
2604
2673
  ${block(pipelineIdentification)}
2605
2674
  `));
2606
2675
  }
2607
2676
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2608
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2677
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2609
2678
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2610
2679
 
2611
2680
  ${block(pipelineIdentification)}
@@ -2615,7 +2684,7 @@
2615
2684
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2616
2685
  if (!task.format &&
2617
2686
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2618
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2687
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2619
2688
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2620
2689
 
2621
2690
  ${block(pipelineIdentification)}
@@ -2623,7 +2692,7 @@
2623
2692
  }
2624
2693
  for (const joker of task.jokerParameterNames) {
2625
2694
  if (!task.dependentParameterNames.includes(joker)) {
2626
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2695
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2627
2696
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2628
2697
 
2629
2698
  ${block(pipelineIdentification)}
@@ -2634,21 +2703,21 @@
2634
2703
  if (task.expectations) {
2635
2704
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2636
2705
  if (min !== undefined && max !== undefined && min > max) {
2637
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2706
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2638
2707
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2639
2708
 
2640
2709
  ${block(pipelineIdentification)}
2641
2710
  `));
2642
2711
  }
2643
2712
  if (min !== undefined && min < 0) {
2644
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2713
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2645
2714
  Min expectation of ${unit} must be zero or positive
2646
2715
 
2647
2716
  ${block(pipelineIdentification)}
2648
2717
  `));
2649
2718
  }
2650
2719
  if (max !== undefined && max <= 0) {
2651
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2720
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2652
2721
  Max expectation of ${unit} must be positive
2653
2722
 
2654
2723
  ${block(pipelineIdentification)}
@@ -2670,7 +2739,7 @@
2670
2739
  while (unresovedTasks.length > 0) {
2671
2740
  if (loopLimit-- < 0) {
2672
2741
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2673
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
2742
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
2674
2743
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2675
2744
 
2676
2745
  ${block(pipelineIdentification)}
@@ -2680,7 +2749,7 @@
2680
2749
  if (currentlyResovedTasks.length === 0) {
2681
2750
  throw new PipelineLogicError(
2682
2751
  // TODO: [🐎] DRY
2683
- spaceTrim.spaceTrim((block) => `
2752
+ spaceTrim$1.spaceTrim((block) => `
2684
2753
 
2685
2754
  Can not resolve some parameters:
2686
2755
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2921,11 +2990,11 @@
2921
2990
  throw deserializeError(errors[0]);
2922
2991
  }
2923
2992
  else {
2924
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
2993
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
2925
2994
  Multiple errors occurred during Promptbook execution
2926
2995
 
2927
2996
  ${block(errors
2928
- .map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
2997
+ .map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
2929
2998
  ${name} ${index + 1}:
2930
2999
  ${block(stack || message)}
2931
3000
  `))
@@ -2952,6 +3021,7 @@
2952
3021
  let updatedAt = createdAt;
2953
3022
  const errors = [];
2954
3023
  const warnings = [];
3024
+ const llmCalls = [];
2955
3025
  let currentValue = {};
2956
3026
  let customTldr = null;
2957
3027
  const partialResultSubject = new rxjs.Subject();
@@ -2967,6 +3037,9 @@
2967
3037
  }, (tldrInfo) => {
2968
3038
  customTldr = tldrInfo;
2969
3039
  updatedAt = new Date();
3040
+ }, (llmCall) => {
3041
+ llmCalls.push(llmCall);
3042
+ updatedAt = new Date();
2970
3043
  });
2971
3044
  finalResultPromise
2972
3045
  .catch((error) => {
@@ -3089,7 +3162,7 @@
3089
3162
  }
3090
3163
  return {
3091
3164
  percent: percent,
3092
- message,
3165
+ message: message + ' (!!!fallback)',
3093
3166
  };
3094
3167
  },
3095
3168
  get createdAt() {
@@ -3112,6 +3185,10 @@
3112
3185
  return warnings;
3113
3186
  // <- Note: [1] --||--
3114
3187
  },
3188
+ get llmCalls() {
3189
+ return [...llmCalls, { foo: '!!! bar' }];
3190
+ // <- Note: [1] --||--
3191
+ },
3115
3192
  get currentValue() {
3116
3193
  return currentValue;
3117
3194
  // <- Note: [1] --||--
@@ -3191,7 +3268,7 @@
3191
3268
  * Note: [💞] Ignore a discrepancy between file name and entity name
3192
3269
  */
3193
3270
 
3194
- var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"},{title:"📊 Curriculum Audit",pipelineUrl:"https://promptbook.studio/promptbook//examples/lsvp-asistent.book",formfactorName:"GENERIC",parameters:[{name:"result",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"prompt",title:"Prompt",content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.",resultingParameterName:"result",dependentParameterNames:[]}],personas:[],preparations:[{id:1,promptbookVersion:"0.103.0-8",usage:{price:{value:0},input:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}},output:{tokensCount:{value:0},charactersCount:{value:0},wordsCount:{value:0},sentencesCount:{value:0},linesCount:{value:0},paragraphsCount:{value:0},pagesCount:{value:0}}}}],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"Asistent pro LŠVP\n\nPERSONA Jsi asistent pro RVP Lyceum v rámci Národního pedagogického institutu České Republiky\nMETA IMAGE https://edulk.cz/getFile/id:475818/type:large/02%20zna%C4%8Dka%20npi.jpg\nRULE Pokud jsi nejsi jistý, napiš nevím\nKNOWLEDGE ./241129_Lyceum_final.pdf\nCONTEXT Obecně dokážeš řešit libovolné ŠVP, aktuálně řešíš {Školní vzdělávací program LYCEUM}\nRULE Z {Porovnání RVP a ŠVP - postup} je nejdůležitější fáze 3\nKNOWLEDGE {Školní vzdělávací program LYCEUM} ./ŠVP Lyceum - Finance v digitální době.pdf\nKNOWLEDGE @Slovník\n\n**Interní slovník - RVP/ŠVP**\n\n**RVP**\n\nRámcový vzdělávací program pro obor vzdělání Lyceum je dokument na národní úrovni, který formuluje požadavky na školní vzdělávací programy ve formě především očekávaných výsledků učení, kterých mají žáci absolvováním tohoto programu na dané škole dosáhnout.\n\n**ŠVP**\n\nŠkolní vzdělávací program pro obor vzdělání Lyceum je dokument každé jednotlivé školy, který popisuje v jakých vyučovacích předmětech/ vzdělávacích modulech a v jakých ročnících budou požadované očekávané výsledky učení naplněny. Zároveň formuluje další očekávané výsledky učení, které naplňují disponibilní část vyučovacího času určeného RVP pro tento obor vzdělání.\n\n**Očekávaný výsledek učení (OVU)**\n\nVyjadřuje jednotlivý požadavek na to, co mají žáci umět na konci vzdělávacího programu, tzn. jejich požadované kompetence. Je vyjádřen formulací, která je uvozena činnostním slovesem a dále obsahuje předmět této činnosti. Formulace je konkretizována resp. doplněna zpravidla formou odrážek vymezením dílčích znalostí, dovedností, postojů, jejichž splnění je předpokladem dosažení OVU jako celku.\n\n_Příklad:_\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th><p><strong>Žák/žákyně řídí realizaci jednoduchého projektu</strong></p></th></tr><tr><td><ul><li>naplánuje aktivity projektu</li></ul></td></tr><tr><td><ul><li>navrhne rozpočet projektu vzhledem k navrženým aktivitám</li></ul></td></tr><tr><td><ul><li>stanoví základní ukazatele a sleduje jejich naplňování</li></ul></td></tr><tr><td><ul><li>vede projektový tým</li></ul></td></tr><tr><td><ul><li>uvede, jak by řešil krizové situace v projektu</li></ul></td></tr><tr><td><ul><li>vyhodnotí úspěšnost projektu</li></ul></td></tr></tbody></table></div>\n\n**Vzdělávací oblasti**\n\nOčekávané výsledky učení jsou v **_RVP členěny do 4 vzdělávacích oblastí_**, které tvoří společný všeobecně vzdělávací základ:\n\n- Osobnostní rozvoj, vzdělávání ke zdraví, bezpečí a produktivnímu pracovnímu životu (kariéře)\n- Komunikační a jazykové vzdělávání\n- Aplikované vzdělávání STEM (Science, Technology, Engeneering, Math), tj. přírodní vědy, informatika, technika, matematika\n- Prakticky orientované vzdělávání společenskovědní a humanitní\n\nKaždá vzdělávací oblast se dále člení na okruhy, v jejichž rámci jsou OVU samostatně číslované.\n\n<div class=\"joplin-table-wrapper\"><table><tbody><tr><th rowspan=\"21\"><ul><li>Prakticky orientované vzdělávání společenskovědní a humanitní</li></ul></th><th rowspan=\"21\"><p><strong>Člověk, ekonomie a podnikání</strong></p></th><th rowspan=\"7\"><p><strong>1</strong></p></th><th><p><strong>zpracuje podklady související s podnikáním</strong></p></th></tr><tr><td><p>připraví podnikatelský záměr</p></td></tr><tr><td><p>sestaví zakladatelský rozpočet</p></td></tr><tr><td><p>zkalkuluje cenu zboží nebo služby</p></td></tr><tr><td><p>vysvětlí na příkladu základní povinnosti podnikatele vůči státu a zaměstnancům</p></td></tr><tr><td><p>vede daňovou evidenci</p></td></tr><tr><td><p>vysvětlí na příkladech etiku v podnikání</p></td></tr><tr><td rowspan=\"7\"><p><strong>2</strong></p></td><td><p><strong>řídí realizaci jednoduchého projektu</strong></p></td></tr><tr><td><p>naplánuje aktivity projektu</p></td></tr><tr><td><p>navrhne rozpočet projektu vzhledem k navrženým aktivitám</p></td></tr><tr><td><p>stanoví základní ukazatele a sleduje jejich naplňování</p></td></tr><tr><td><p>vede projektový tým</p></td></tr><tr><td><p>uvede, jak by řešil krizové situace v projektu</p></td></tr><tr><td><p>vyhodnotí úspěšnost projektu</p></td></tr><tr><td rowspan=\"7\"><p><strong>3</strong></p></td><td><p><strong>aplikuje ekonomické teorie v osobním a profesním životě</strong></p></td></tr><tr><td><p>vysvětlí základní ekonomické otázky</p></td></tr><tr><td><p>vysvětí stanovení rovnovážné ceny na dokonalém i nedokonalém trhu</p></td></tr><tr><td><p>charakterizuje výrobní faktory a vysvětlí hranici produkčních možností a náklady obětované příležitosti</p></td></tr><tr><td><p>uvede nejdůležitější makroekonomické pojmy a vliv jejich výše na kvalitu života a podnikání v daném státě</p></td></tr><tr><td><p>vysvětlí podstatu inflace a její důsledky na finanční situaci obyvatel a na příkladu ukáže jak se bránit jejím nepříznivým důsledkům</p></td></tr><tr><td><p>uvede hlavní výhody a nevýhody mezinárodního obchodu a vliv ochranářských opatření na ekonomickou situaci dané země</p></td></tr><tr><td></td><td></td><td><p><strong>4</strong></p></td><td><p>Atd.</p></td></tr></tbody></table></div>\n\n**Vyučovací předmět / vzdělávací modul**\n\nOčekávané výsledky učení jsou v **ŠVP** členěny do vyučovacích předmětů nebo vzdělávacích modulů, které jsou dále zařazeny do jednoho nebo více ročníků 4letého studia. Vyučovací předmět / vzdělávací modul tvoří vyučovací jednotku, kde jsou očekávané výsledky učení dále rozpracovány pro potřeby výuky podle následující šablony\n\n| **A. VSTUPNÍ ČÁST** |\n| --- |\n| **1\\. Název** |\n| **2\\. Kód** (kódy by měly být navázány na obory vzdělání a výsledky učení) |\n| **2a) Kategorie vzdělání** - v případě, že nebude součástí kódu |\n| **3\\. Typ vyučovací jednotky** (modul, předmět, stáž apod.) |\n| **4\\. Délka** (počet hodin - dělitelný čtyřmi (optimální modul 16, 32 hodin = týden výuky) |\n| **5\\. Platnost** (datum, od kterého platí) |\n| **6\\. Vstupní předpoklady** (vymezení požadované úrovně vstupních vědomostí a dovedností, které jsou předpokladem úspěšného studia) |\n| |\n| **B. JÁDRO VYUČOVACÍ JEDNOTKY** |\n| **1\\. Charakteristika** (stručná anotace popisující obecné cíle a pojetí) |\n| **2\\. Očekávané výsledky učení a jejich indikátory (převzaté z RVP nebo dále konkretizované)** |\n| **3\\. Podpora rozvoje klíčových kompetencí a základních gramotností** (které klíčové kompetence jsou v rozvíjeny) |\n| **4\\. Obsah vzdělávání** (rozpis učiva) |\n| **5\\. Vzdělávací strategie** (strategie výuky, resp. učební činnosti žáků, které jsou doporučené pro dosažení výsledků) |\n| |\n| **C. VÝSTUPNÍ ČÁST** |\n| **1\\. Způsob ověřování dosažených výsledků** (ve vazbě na jednotlivé výsledky učení) |\n| **2\\. Kritéria hodnocení** (co znamená splnění výsledků učení, kdy je splněna celá vyučovací jednotka, kritéria pro známky, příp. procentuální, slovní hodnocení) |\n| **3\\. Doporučená studijní literatura, odkazy na ilustrační zdroje** |\n| **4\\. Poznámky** |\n\n**Soulad OVU RVP a ŠVP**\n\nTento soulad je předmětem zjišťování. Soulad nastává, jestliže jsou očekávané výsledky učení z jednotlivých vzdělávacích oblastí RVP **obsaženy** ve vyučovacích předmětech/ vzdělávacích modulech ŠVP jednotlivých škol, tzn. že v ŠVP se objevuje jejich formulace buď v doslovném nebo podobném znění v jednom nebo více vyučovacích předmětech/ vzdělávacích modulech.\n\n_Příklad souladu:_\n\nRVP ŠVP - komunikace a marketing (SŠ obchodní Č.\n\n| **2** | **řídí realizaci jednoduchého projektu** |\n| --- | --- |\n| naplánuje aktivity projektu |\n| navrhne rozpočet projektu vzhledem k navrženým aktivitám |\n| stanoví základní ukazatele a sleduje jejich naplňování |\n| vede projektový tým |\n| uvede, jak by řešil krizové situace v projektu |\n| vyhodnotí úspěšnost projektu |\n\nKNOWLEDGE {Porovnání RVP a ŠVP - postup}\n\n\n# AUDITNÍ PROTOKOL ŠVP-RVP\n\n# (POPIS KONTROLNÍHO ALGORITMU)\n\nMetodika je určena pro **Kvantifikaci Shody** školního vzdělávacího programu (ŠVP) s Rámcovým vzdělávacím programem (RVP).\n\n## FÁZE 1: VALIDACE DOKUMENTACE\n\n**Cíl:** Ověřit platnost, aktuálnost a strukturu zdrojových dokumentů.\n\n- **RVP Verifikace:** Otevřít aktuální verzi RVP (např. RVP ZV/G/SOŠ).\n- **Typová shoda:** Ověřit, že RVP se vztahuje k danému typu školy.\n- **ŠVP Dimenze:** Identifikovat a izolovat relevantní části ŠVP: Profil absolventa, Klíčové kompetence (KK), Vzdělávací oblasti (VO), případně Učební plán (UP).\n- **Verzování:** Potvrdit, že obě verze (RVP a ŠVP) jsou nejnovější a platné (včetně dodatků RVP).\n\n## FÁZE 2: DATABÁZOVÉ MAPOVÁNÍ VÝSTUPŮ (MASTER MATICE)\n\n**Cíl:** Vytvořit systémovou databázi pro křížové porovnání všech povinných komponent RVP se ŠVP.\n\n- **Dekompozice RVP:** Rozložit RVP na základní povinné komponenty: Klíčové kompetence, Vzdělávací oblasti a obory, Očekávané výstupy (OVU), Průřezová témata (PT).\n- **Přiřazovací mapa:** Vytvořit hlavní kontrolní matici (Master Matice) pro záznam vazeb.\n\n| Oblast RVP | Výstup RVP (OVU) | Odpovídající Část ŠVP (Předmět/Ročník) | Konkrétní Tématický Celek v ŠVP | Stav Shody (Protokol) |\n| --- | --- | --- | --- | --- |\n| ... | ... | ... | ... | ... |\n| --- | --- | --- | --- | --- |\n\n## FÁZE 3: ALGORITMICKÁ KONTROLA POKRYTÍ A HLOUBKY\n\n**Cíl:** Posoudit, zda každý povinný výstup RVP je adekvátně reflektován v obsahu ŠVP, a přidělit bodovou hodnotu pro kvantifikaci.\n\n- **Audit OVU:** Projít každý jednotlivý Očekávaný výstup (OVU) z RVP.\n- **Kódování stavu a bodování:** U každého OVU v matici označit stav pokrytí dle následujícího schématu:\n\n| Kód (Protokol) | Popis (Kvalitativní zjištění) | Bodová hodnota (Kvantifikace) |\n| --- | --- | --- |\n| ✅ | Plná shoda (Výstup pokryt v plném rozsahu, odpovídající úrovni RVP) | 1,0 |\n| --- | --- | --- |\n| ⚠️ | Částečná shoda (Formální pokrytí, omezený rozsah, chybná návaznost) | 0,5 |\n| --- | --- | --- |\n| ❌ | Absence (Výstup zcela chybí v obsahu ŠVP) | 0,0 |\n| --- | --- | --- |\n\n- **Defektologie ŠVP:** Identifikovat a zaznamenat deficity ŠVP: Chybějící výstupy (❌), Sémantické překryvy, Přetížení obsahu.\n- **Kvalitativní posun:** Ověřit, zda je formulace výstupů v ŠVP **aktivní, měřitelná a v souladu** s úrovní RVP.\n\n## FÁZE 4: STRUKTURÁLNÍ VERIFIKACE NÁVAZNOSTI (VERTIKÁLA/HORIZONTÁLA)\n\n**Cíl:** Zkontrolovat logickou posloupnost a provázanost učiva v rámci ŠVP.\n\n- **Vertikální Kontrola:** Ověřit posloupnost OVU a učiva uvnitř jednoho předmětu/oblasti (postup od jednodušších ke složitějším konceptům napříč ročníky).\n- **Horizontální Kontrola:** Zkontrolovat logické provázání napříč vzdělávacími oblastmi a předměty (např. fyzika ↔ matematika).\n- **PT Integrace:** Audit reálné integrace Průřezových témat (PT) do konkrétních částí obsahu, metod a projektů.\n\n## FÁZE 5: ANALÝZA ŠKOLNÍ PROFILACE A ROZŠÍŘENÍ RVP\n\n**Cíl:** Validovat, že profilace školy je **v souladu** s RVP a nejedná se o **rozpor**.\n\n- **Nekonfliktnost:** Porovnat definovaný Profil absolventa školy s Klíčovými kompetencemi RVP. Profil ŠVP musí RVP rozvíjet, nikoli mu odporovat.\n- **Modularita:** Zkontrolovat, zda volitelné předměty a rozšiřující moduly logicky navazují na vzdělávací oblasti RVP.\n- **Implementace specializace:** Popisně uvést, jak je školní profilace (např. STEM zaměření, projektová výuka) integrována do OVU a kompetencí definovaných RVP.\n\n## FÁZE 6: GENERÁTOR ZÁVĚREČNÉ ZPRÁVY A KVANTIFIKACE\n\n**Cíl:** Syntetizovat výsledky, kvantifikovat soulad a generovat závazné návrhy na korekce.\n\n### 6.1 Kvantifikace Souladu\n\nVypočítat Index shody (IS) na základě bodového hodnocení (Fáze 3):\n\n### 6.2 Interpretace Indexu Shody (IS)\n\nKlasifikace souladu pro standardizované vyhodnocení:\n\n| Interval IS | Klasifikace souladu | Popis |\n| --- | --- | --- |\n| 95-100 % | Výborný soulad | ŠVP plně odpovídá RVP, pouze stylistické nebo formální rozdíly. |\n| --- | --- | --- |\n| 85-94 % | Dobrá shoda | ŠVP pokrývá všechny klíčové výstupy, menší korekce nutné. |\n| --- | --- | --- |\n| 70-84 % | Částečná shoda | Významné nedostatky v některých oblastech, nutná revize obsahu. |\n| --- | --- | --- |\n| < 70 % | Kritická neshoda | ŠVP neplní rámcové požadavky, ohrožuje legislativní soulad. |\n| --- | --- | --- |\n\n### 6.3 Doplňkové Indexy\n\nVypočítat následující doplňkové indexy pro detailní kvalitativní analýzu:\n\n- **Index kompetenčního souladu (IKS):** Poměr pokrytí klíčových kompetencí RVP v ŠVP.\n- **Index průřezové integrace (IPI):** Míra reálné integrace průřezových témat do výuky.\n- **Index hloubky pokrytí (IHP):** Procento výstupů, které jsou v ŠVP rozvedeny na konkrétní výukové cíle (měřitelné, aktivní formulace).\n- **Index profilové rozšiřitelnosti (IPR):** Kolik rozšiřujících nebo profilových výstupů přesahuje rámec RVP, aniž by narušily jeho strukturu.\n\n### 6.4 Vizuální výstupy\n\nZajistit generování následujících vizualizací pro Závěrečnou zprávu:\n\n- Graf pokrytí po vzdělávacích oblastech (Sloupcový graf IS pro VO).\n- Pavoukový diagram Klíčových kompetencí (RVP vs. ŠVP).\n- Mapa defektů (Vizualizace ❌ a ⚠️ výstupů).\n\n### 6.5 Struktura Závěrečné Zprávy\n\nZpráva musí být strukturována dle standardizovaného formátu:\n\n| Oddíl | Obsah |\n| --- | --- |\n| A. Identifikace | Název školy, IZO, typ školy, datum revize, zpracovatel, verze ŠVP a RVP. |\n| --- | --- |\n| B. Shrnutí výsledků | Celkový Index Shody (IS), hlavní závěry a doporučení. |\n| --- | --- |\n| C. Kvantitativní analýza | Přehled IS v % dle kategorií OVU / VO / kompetencí. |\n| --- | --- |\n| D. Kvalitativní analýza | Slovní zhodnocení kvality souladu (formulace, obtížnost, integrace PT). |\n| --- | --- |\n| E. Rizikové oblasti | Přehled nalezených defektů (chybějící OVU, přetížení, formální shoda). |\n| --- | --- |\n| F. Návrhy opatření (Korekční plán) | Přesné návrhy změn - **Co, Kde, Kdo** má upravit, včetně termínu. |\n| --- | --- |\n| G. Přílohy | Master Matice (Fáze 2-3), revizní tabulka, výstupní grafy a metriky. |\n| --- | --- |\n\n\n\n\n.\n"}],sourceFile:"./books/examples/lsvp-asistent.book"}];
3271
+ var PipelineCollection = [{title:"Prepare Knowledge from Markdown",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book",formfactorName:"GENERIC",parameters:[{name:"knowledgeContent",description:"Markdown document content",isInput:true,isOutput:false},{name:"knowledgePieces",description:"The knowledge JSON object",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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> {knowledgeContent}",resultingParameterName:"knowledgePieces",dependentParameterNames:["knowledgeContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge from Markdown\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-from-markdown.book`\n- INPUT PARAMETER `{knowledgeContent}` Markdown document content\n- OUTPUT PARAMETER `{knowledgePieces}` The knowledge JSON object\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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> {knowledgeContent}\n```\n\n`-> {knowledgePieces}`\n"}],sourceFile:"./books/prepare-knowledge-from-markdown.book"},{title:"Prepare Keywords",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-keywords.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"keywords",description:"Keywords separated by comma",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",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> {knowledgePieceContent}",resultingParameterName:"keywords",dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Keywords\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-keywords.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{keywords}` Keywords separated by comma\n\n## Knowledge\n\n<!-- TODO: [🍆] -FORMAT JSON -->\n\n```markdown\nYou 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> {knowledgePieceContent}\n```\n\n`-> {keywords}`\n"}],sourceFile:"./books/prepare-knowledge-keywords.book"},{title:"Prepare Knowledge-piece Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-knowledge-title.book",formfactorName:"GENERIC",parameters:[{name:"knowledgePieceContent",description:"The content",isInput:true,isOutput:false},{name:"title",description:"The title of the document",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"knowledge",title:"Knowledge",content:"You are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}",resultingParameterName:"title",expectations:{words:{min:1,max:8}},dependentParameterNames:["knowledgePieceContent"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Knowledge-piece Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-knowledge-title.book`\n- INPUT PARAMETER `{knowledgePieceContent}` The content\n- OUTPUT PARAMETER `{title}` The title of the document\n\n## Knowledge\n\n- EXPECT MIN 1 WORD\n- EXPECT MAX 8 WORDS\n\n```markdown\nYou are experienced content creator, write best title for the document.\n\n# Rules\n\n- Write just title, nothing else\n- Write maximum 5 words for the title\n\n# The document\n\n> {knowledgePieceContent}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-knowledge-title.book"},{title:"Prepare Persona",pipelineUrl:"https://promptbook.studio/promptbook/prepare-persona.book",formfactorName:"GENERIC",parameters:[{name:"availableModels",description:"List of available model names together with their descriptions as JSON",isInput:true,isOutput:false},{name:"personaDescription",description:"Description of the persona",isInput:true,isOutput:false},{name:"modelsRequirements",description:"Specific requirements for the model",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-model-requirements",title:"Make modelRequirements",content:"You are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n```json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n```\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n```json\n{availableModels}\n```\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}",resultingParameterName:"modelsRequirements",format:"JSON",dependentParameterNames:["availableModels","personaDescription"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Persona\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-persona.book`\n- INPUT PARAMETER `{availableModels}` List of available model names together with their descriptions as JSON\n- INPUT PARAMETER `{personaDescription}` Description of the persona\n- OUTPUT PARAMETER `{modelsRequirements}` Specific requirements for the model\n\n## Make modelRequirements\n\n- FORMAT JSON\n\n```markdown\nYou are an experienced AI engineer, you need to find the best models for virtual assistants:\n\n## Example\n\n\\`\\`\\`json\n[\n {\n \"modelName\": \"gpt-4o\",\n \"systemMessage\": \"You are experienced AI engineer and helpful assistant.\",\n \"temperature\": 0.7\n },\n {\n \"modelName\": \"claude-3-5-sonnet\",\n \"systemMessage\": \"You are a friendly and knowledgeable chatbot.\",\n \"temperature\": 0.5\n }\n]\n\\`\\`\\`\n\n## Instructions\n\n- Your output format is JSON array\n- Sort best-fitting models first\n- Omit any models that are not suitable\n- Write just the JSON, no other text should be present\n- Array contain items with following keys:\n - `modelName`: The name of the model to use\n - `systemMessage`: The system message to provide context to the model\n - `temperature`: The sampling temperature to use\n\n### Key `modelName`\n\nHere are the available models:\n\n\\`\\`\\`json\n{availableModels}\n\\`\\`\\`\n\n### Key `systemMessage`\n\nThe system message is used to communicate instructions or provide context to the model at the beginning of a conversation. It is displayed in a different format compared to user messages, helping the model understand its role in the conversation. The system message typically guides the model's behavior, sets the tone, or specifies desired output from the model. By utilizing the system message effectively, users can steer the model towards generating more accurate and relevant responses.\n\nFor example:\n\n> You are an experienced AI engineer and helpful assistant.\n\n> You are a friendly and knowledgeable chatbot.\n\n### Key `temperature`\n\nThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.\n\nYou can pick a value between 0 and 2. For example:\n\n- `0.1`: Low temperature, extremely conservative and deterministic\n- `0.5`: Medium temperature, balanced between conservative and creative\n- `1.0`: High temperature, creative and bit random\n- `1.5`: Very high temperature, extremely creative and often chaotic and unpredictable\n- `2.0`: Maximum temperature, completely random and unpredictable, for some extreme creative use cases\n\n# The assistant\n\nTake this description of the persona:\n\n> {personaDescription}\n```\n\n`-> {modelsRequirements}`\n"}],sourceFile:"./books/prepare-persona.book"},{title:"Prepare Title",pipelineUrl:"https://promptbook.studio/promptbook/prepare-title.book",formfactorName:"GENERIC",parameters:[{name:"book",description:"The book to prepare the title for",isInput:true,isOutput:false},{name:"title",description:"Best title for the book",isInput:false,isOutput:true}],tasks:[{taskType:"PROMPT_TASK",name:"make-title",title:"Make title",content:"Make best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}",resultingParameterName:"title",expectations:{words:{min:1,max:8},lines:{min:1,max:1}},dependentParameterNames:["book"]}],personas:[],preparations:[],knowledgeSources:[],knowledgePieces:[],sources:[{type:"BOOK",path:null,content:"# Prepare Title\n\n- PIPELINE URL `https://promptbook.studio/promptbook/prepare-title.book`\n- INPUT PARAMETER `{book}` The book to prepare the title for\n- OUTPUT PARAMETER `{title}` Best title for the book\n\n## Make title\n\n- EXPECT MIN 1 Word\n- EXPECT MAX 8 Words\n- EXPECT EXACTLY 1 Line\n\n```markdown\nMake best title for given text which describes the workflow:\n\n## Rules\n\n- Write just title, nothing else\n- Title should be concise and clear - Write maximum ideally 2 words, maximum 5 words\n- Title starts with emoticon\n- Title should not mention the input and output of the workflow but the main purpose of the workflow\n _For example, not \"✍ Convert Knowledge-piece to title\" but \"✍ Title\"_\n\n## The workflow\n\n> {book}\n```\n\n`-> {title}`\n"}],sourceFile:"./books/prepare-title.book"}];
3195
3272
 
3196
3273
  /**
3197
3274
  * Checks if value is valid email
@@ -3268,6 +3345,8 @@
3268
3345
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
3269
3346
  * 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.
3270
3347
  *
3348
+ * Note: [🔂] This function is idempotent.
3349
+ *
3271
3350
  * @param {string} pipelineString the candidate for a pipeline string
3272
3351
  * @returns {PipelineString} the same string as input, but validated as valid
3273
3352
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -3515,7 +3594,7 @@
3515
3594
  * Library of pipelines that groups together pipelines for an application.
3516
3595
  * This implementation is a very thin wrapper around the Array / Map of pipelines.
3517
3596
  *
3518
- * @private internal function of `createCollectionFromJson`, use `createCollectionFromJson` instead
3597
+ * @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
3519
3598
  * @see https://github.com/webgptorg/pipeline#pipeline-collection
3520
3599
  */
3521
3600
  class SimplePipelineCollection {
@@ -3525,14 +3604,14 @@
3525
3604
  * @param pipelines Array of pipeline JSON objects to include in the collection
3526
3605
  *
3527
3606
  * Note: During the construction logic of all pipelines are validated
3528
- * Note: It is not recommended to use this constructor directly, use `createCollectionFromJson` *(or other variant)* instead
3607
+ * Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
3529
3608
  */
3530
3609
  constructor(...pipelines) {
3531
3610
  this.collection = new Map();
3532
3611
  for (const pipeline of pipelines) {
3533
3612
  // TODO: [👠] DRY
3534
3613
  if (pipeline.pipelineUrl === undefined) {
3535
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3614
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3536
3615
  Pipeline with name "${pipeline.title}" does not have defined URL
3537
3616
 
3538
3617
  File:
@@ -3554,7 +3633,7 @@
3554
3633
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3555
3634
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3556
3635
  const existing = this.collection.get(pipeline.pipelineUrl);
3557
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3636
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3558
3637
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3559
3638
 
3560
3639
  Conflicting files:
@@ -3586,13 +3665,13 @@
3586
3665
  const pipeline = this.collection.get(url);
3587
3666
  if (!pipeline) {
3588
3667
  if (this.listPipelines().length === 0) {
3589
- throw new NotFoundError(spaceTrim.spaceTrim(`
3668
+ throw new NotFoundError(spaceTrim$1.spaceTrim(`
3590
3669
  Pipeline with url "${url}" not found
3591
3670
 
3592
3671
  No pipelines available
3593
3672
  `));
3594
3673
  }
3595
- throw new NotFoundError(spaceTrim.spaceTrim((block) => `
3674
+ throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
3596
3675
  Pipeline with url "${url}" not found
3597
3676
 
3598
3677
  Available pipelines:
@@ -3613,16 +3692,16 @@
3613
3692
  }
3614
3693
 
3615
3694
  /**
3616
- * Creates PipelineCollection from array of PipelineJson or PipelineString
3695
+ * Creates `PipelineCollection` from array of PipelineJson or PipelineString
3617
3696
  *
3618
- * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
3697
+ * Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
3619
3698
  * Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
3620
3699
  *
3621
3700
  * @param promptbookSources
3622
3701
  * @returns PipelineCollection
3623
3702
  * @public exported from `@promptbook/core`
3624
3703
  */
3625
- function createCollectionFromJson(...promptbooks) {
3704
+ function createPipelineCollectionFromJson(...promptbooks) {
3626
3705
  return new SimplePipelineCollection(...promptbooks);
3627
3706
  }
3628
3707
 
@@ -4000,6 +4079,7 @@
4000
4079
  return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
4001
4080
  }
4002
4081
  /**
4082
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4003
4083
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4004
4084
  */
4005
4085
 
@@ -4016,6 +4096,7 @@
4016
4096
  return llmTools;
4017
4097
  }
4018
4098
  /**
4099
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4019
4100
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4020
4101
  */
4021
4102
 
@@ -4031,7 +4112,7 @@
4031
4112
  throw new MissingToolsError('LLM tools are required for preparing persona');
4032
4113
  }
4033
4114
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
4034
- const collection = createCollectionFromJson(...PipelineCollection);
4115
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
4035
4116
  const preparePersonaExecutor = createPipelineExecutor({
4036
4117
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
4037
4118
  tools,
@@ -4597,6 +4678,8 @@
4597
4678
  /**
4598
4679
  * Converts a given text to kebab-case format.
4599
4680
  *
4681
+ * Note: [🔂] This function is idempotent.
4682
+ *
4600
4683
  * @param text The text to be converted.
4601
4684
  * @returns The kebab-case formatted string.
4602
4685
  * @example 'hello-world'
@@ -4752,6 +4835,8 @@
4752
4835
  /**
4753
4836
  * Converts a title string into a normalized name.
4754
4837
  *
4838
+ * Note: [🔂] This function is idempotent.
4839
+ *
4755
4840
  * @param value The title string to be converted to a name.
4756
4841
  * @returns A normalized name derived from the input title.
4757
4842
  * @example 'Hello World!' -> 'hello-world'
@@ -5140,7 +5225,7 @@
5140
5225
  if (task.taskType === 'PROMPT_TASK' &&
5141
5226
  knowledgePiecesCount > 0 &&
5142
5227
  !dependentParameterNames.includes('knowledge')) {
5143
- preparedContent = spaceTrim.spaceTrim(`
5228
+ preparedContent = spaceTrim$1.spaceTrim(`
5144
5229
  {content}
5145
5230
 
5146
5231
  ## Knowledge
@@ -5226,7 +5311,7 @@
5226
5311
  let title = pipeline.title;
5227
5312
  if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
5228
5313
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
5229
- const collection = createCollectionFromJson(...PipelineCollection);
5314
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
5230
5315
  const prepareTitleExecutor = createPipelineExecutor({
5231
5316
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
5232
5317
  tools,
@@ -5453,7 +5538,7 @@
5453
5538
  }
5454
5539
  catch (error) {
5455
5540
  assertsError(error);
5456
- throw new ParseError(spaceTrim.spaceTrim((block) => `
5541
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
5457
5542
  Can not extract variables from the script
5458
5543
  ${block(error.stack || error.message)}
5459
5544
 
@@ -6155,10 +6240,13 @@
6155
6240
  * @public exported from `@promptbook/utils`
6156
6241
  */
6157
6242
  function countLines(text) {
6243
+ if (text === '') {
6244
+ return 0;
6245
+ }
6158
6246
  text = text.replace('\r\n', '\n');
6159
6247
  text = text.replace('\r', '\n');
6160
6248
  const lines = text.split('\n');
6161
- return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
6249
+ return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
6162
6250
  }
6163
6251
  /**
6164
6252
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
@@ -6283,6 +6371,8 @@
6283
6371
  * This function provides a common abstraction for result validation that can be used
6284
6372
  * by both execution logic and caching logic to ensure consistency.
6285
6373
  *
6374
+ * Note: [🔂] This function is idempotent.
6375
+ *
6286
6376
  * @param options - The validation options including result string, expectations, and format
6287
6377
  * @returns Validation result with processed string and validity status
6288
6378
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -6302,7 +6392,7 @@
6302
6392
  }
6303
6393
  catch (error) {
6304
6394
  keepUnused(error);
6305
- throw new ExpectError(spaceTrim.spaceTrim((block) => `
6395
+ throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
6306
6396
  Expected valid JSON string
6307
6397
 
6308
6398
  The expected JSON text:
@@ -6351,7 +6441,7 @@
6351
6441
  */
6352
6442
  async function executeAttempts(options) {
6353
6443
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
6354
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
6444
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
6355
6445
  const $ongoingTaskResult = {
6356
6446
  $result: null,
6357
6447
  $resultString: null,
@@ -6365,7 +6455,7 @@
6365
6455
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6366
6456
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6367
6457
  if (isJokerAttempt && !jokerParameterName) {
6368
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6458
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6369
6459
  Joker not found in attempt ${attemptIndex}
6370
6460
 
6371
6461
  ${block(pipelineIdentification)}
@@ -6376,7 +6466,7 @@
6376
6466
  $ongoingTaskResult.$expectError = null;
6377
6467
  if (isJokerAttempt) {
6378
6468
  if (parameters[jokerParameterName] === undefined) {
6379
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6469
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6380
6470
  Joker parameter {${jokerParameterName}} not defined
6381
6471
 
6382
6472
  ${block(pipelineIdentification)}
@@ -6434,7 +6524,7 @@
6434
6524
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6435
6525
  break variant;
6436
6526
  case 'EMBEDDING':
6437
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6527
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6438
6528
  Embedding model can not be used in pipeline
6439
6529
 
6440
6530
  This should be catched during parsing
@@ -6445,7 +6535,7 @@
6445
6535
  break variant;
6446
6536
  // <- case [🤖]:
6447
6537
  default:
6448
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6538
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6449
6539
  Unknown model variant "${task.modelRequirements.modelVariant}"
6450
6540
 
6451
6541
  ${block(pipelineIdentification)}
@@ -6456,14 +6546,14 @@
6456
6546
  break;
6457
6547
  case 'SCRIPT_TASK':
6458
6548
  if (arrayableToArray(tools.script).length === 0) {
6459
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6549
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6460
6550
  No script execution tools are available
6461
6551
 
6462
6552
  ${block(pipelineIdentification)}
6463
6553
  `));
6464
6554
  }
6465
6555
  if (!task.contentLanguage) {
6466
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6556
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6467
6557
  Script language is not defined for SCRIPT TASK "${task.name}"
6468
6558
 
6469
6559
  ${block(pipelineIdentification)}
@@ -6494,7 +6584,7 @@
6494
6584
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6495
6585
  }
6496
6586
  else {
6497
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6587
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6498
6588
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6499
6589
 
6500
6590
  ${block(pipelineIdentification)}
@@ -6508,7 +6598,7 @@
6508
6598
  break taskType;
6509
6599
  case 'DIALOG_TASK':
6510
6600
  if (tools.userInterface === undefined) {
6511
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6601
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6512
6602
  User interface tools are not available
6513
6603
 
6514
6604
  ${block(pipelineIdentification)}
@@ -6526,7 +6616,7 @@
6526
6616
  break taskType;
6527
6617
  // <- case: [🅱]
6528
6618
  default:
6529
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6619
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6530
6620
  Unknown execution type "${task.taskType}"
6531
6621
 
6532
6622
  ${block(pipelineIdentification)}
@@ -6599,14 +6689,10 @@
6599
6689
  });
6600
6690
  }
6601
6691
  finally {
6602
- if (!isJokerAttempt &&
6603
- task.taskType === 'PROMPT_TASK' &&
6604
- $ongoingTaskResult.$prompt
6605
- // <- Note: [2] When some expected parameter is not defined, error will occur in templateParameters
6606
- // In that case we don’t want to make a report about it because it’s not a llm execution error
6607
- ) {
6608
- // TODO: [🧠] Maybe put other taskTypes into report
6609
- $executionReport.promptExecutions.push({
6692
+ if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
6693
+ // Note: [2] When some expected parameter is not defined, error will occur in templateParameters
6694
+ // In that case we don’t want to make a report about it because it’s not a llm execution error
6695
+ const executionPromptReport = {
6610
6696
  prompt: {
6611
6697
  ...$ongoingTaskResult.$prompt,
6612
6698
  // <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
@@ -6615,13 +6701,20 @@
6615
6701
  error: $ongoingTaskResult.$expectError === null
6616
6702
  ? undefined
6617
6703
  : serializeError($ongoingTaskResult.$expectError),
6618
- });
6704
+ };
6705
+ $executionReport.promptExecutions.push(executionPromptReport);
6706
+ if (logLlmCall) {
6707
+ logLlmCall({
6708
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
6709
+ report: executionPromptReport,
6710
+ });
6711
+ }
6619
6712
  }
6620
6713
  }
6621
6714
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6622
6715
  // Note: Create a summary of all failures
6623
6716
  const failuresSummary = $ongoingTaskResult.$failedResults
6624
- .map((failure) => spaceTrim.spaceTrim((block) => {
6717
+ .map((failure) => spaceTrim$1.spaceTrim((block) => {
6625
6718
  var _a, _b;
6626
6719
  return `
6627
6720
  Attempt ${failure.attemptIndex + 1}:
@@ -6631,14 +6724,14 @@
6631
6724
  Result:
6632
6725
  ${block(failure.result === null
6633
6726
  ? 'null'
6634
- : spaceTrim.spaceTrim(failure.result)
6727
+ : spaceTrim$1.spaceTrim(failure.result)
6635
6728
  .split('\n')
6636
6729
  .map((line) => `> ${line}`)
6637
6730
  .join('\n'))}
6638
6731
  `;
6639
6732
  }))
6640
6733
  .join('\n\n---\n\n');
6641
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
6734
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
6642
6735
  var _a;
6643
6736
  return `
6644
6737
  LLM execution failed ${maxExecutionAttempts}x
@@ -6658,7 +6751,7 @@
6658
6751
  }
6659
6752
  }
6660
6753
  if ($ongoingTaskResult.$resultString === null) {
6661
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6754
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6662
6755
  Something went wrong and prompt result is null
6663
6756
 
6664
6757
  ${block(pipelineIdentification)}
@@ -6680,9 +6773,9 @@
6680
6773
  * @private internal utility of `createPipelineExecutor`
6681
6774
  */
6682
6775
  async function executeFormatSubvalues(options) {
6683
- const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
6776
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
6684
6777
  if (task.foreach === undefined) {
6685
- return /* not await */ executeAttempts(options);
6778
+ return /* not await */ executeAttempts({ ...options, logLlmCall });
6686
6779
  }
6687
6780
  if (jokerParameterNames.length !== 0) {
6688
6781
  throw new UnexpectedError(spaceTrim__default["default"]((block) => `
@@ -6888,7 +6981,7 @@
6888
6981
  },
6889
6982
  content: task.content,
6890
6983
  parameters,
6891
- };
6984
+ }; /* <- Note: [🤛] */
6892
6985
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6893
6986
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6894
6987
  const { index } = knowledgePiece;
@@ -6964,7 +7057,7 @@
6964
7057
  // Note: Doublecheck that ALL reserved parameters are defined:
6965
7058
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6966
7059
  if (reservedParameters[parameterName] === undefined) {
6967
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7060
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6968
7061
  Reserved parameter {${parameterName}} is not defined
6969
7062
 
6970
7063
  ${block(pipelineIdentification)}
@@ -6983,14 +7076,14 @@
6983
7076
  * @private internal utility of `createPipelineExecutor`
6984
7077
  */
6985
7078
  async function executeTask(options) {
6986
- const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
7079
+ const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
6987
7080
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
6988
7081
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
6989
7082
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
6990
7083
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6991
7084
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6992
7085
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6993
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7086
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6994
7087
  Dependent parameters are not consistent with used parameters:
6995
7088
 
6996
7089
  Dependent parameters:
@@ -7034,7 +7127,7 @@
7034
7127
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
7035
7128
  // Houston, we have a problem
7036
7129
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
7037
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7130
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7038
7131
  Parameter \`{${parameterName}}\` is NOT defined
7039
7132
  BUT used in task "${currentTask.title || currentTask.name}"
7040
7133
 
@@ -7062,6 +7155,7 @@
7062
7155
  tools,
7063
7156
  $executionReport,
7064
7157
  onProgress,
7158
+ logLlmCall,
7065
7159
  pipelineIdentification,
7066
7160
  maxExecutionAttempts,
7067
7161
  maxParallelCount,
@@ -7102,9 +7196,32 @@
7102
7196
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
7103
7197
  if (parametersToPass[parameter.name] === undefined) {
7104
7198
  // [4]
7105
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7199
+ $warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7106
7200
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
7107
7201
 
7202
+ Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
7203
+
7204
+ All parameters:
7205
+ ${block(preparedPipeline.parameters
7206
+ .map(({ name, isInput, isOutput, description }) => {
7207
+ let line = `\`{${name}}\``;
7208
+ if (isInput) {
7209
+ line += ' `[input parameter]`';
7210
+ }
7211
+ if (isOutput) {
7212
+ line += ' `[output parameter]`';
7213
+ }
7214
+ if (parametersToPass[name] === undefined) {
7215
+ line += ` <- Warning: Should be in the output but its not |`;
7216
+ }
7217
+ if (description) {
7218
+ line += ` ${description}`;
7219
+ }
7220
+ return line;
7221
+ })
7222
+ .map((line, index) => `${index + 1}) ${line}`)
7223
+ .join('\n'))}
7224
+
7108
7225
  ${block(pipelineIdentification)}
7109
7226
  `)));
7110
7227
  continue;
@@ -7125,7 +7242,7 @@
7125
7242
  * @private internal utility of `createPipelineExecutor`
7126
7243
  */
7127
7244
  async function executePipeline(options) {
7128
- const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
7245
+ const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
7129
7246
  let { preparedPipeline } = options;
7130
7247
  if (preparedPipeline === undefined) {
7131
7248
  preparedPipeline = await preparePipeline(pipeline, tools, {
@@ -7187,7 +7304,7 @@
7187
7304
  for (const parameterName of Object.keys(inputParameters)) {
7188
7305
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
7189
7306
  if (parameter === undefined) {
7190
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7307
+ warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7191
7308
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
7192
7309
 
7193
7310
  ${block(pipelineIdentification)}
@@ -7202,7 +7319,7 @@
7202
7319
  // TODO: [🧠] This should be also non-critical error
7203
7320
  return exportJson({
7204
7321
  name: 'pipelineExecutorResult',
7205
- message: spaceTrim.spaceTrim((block) => `
7322
+ message: spaceTrim$1.spaceTrim((block) => `
7206
7323
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
7207
7324
 
7208
7325
  ${block(pipelineIdentification)}
@@ -7211,7 +7328,7 @@
7211
7328
  value: {
7212
7329
  isSuccessful: false,
7213
7330
  errors: [
7214
- new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7331
+ new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7215
7332
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
7216
7333
 
7217
7334
  ${block(pipelineIdentification)}
@@ -7238,7 +7355,7 @@
7238
7355
  while (unresovedTasks.length > 0) {
7239
7356
  if (loopLimit-- < 0) {
7240
7357
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
7241
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7358
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7242
7359
  Loop limit reached during resolving parameters pipeline execution
7243
7360
 
7244
7361
  ${block(pipelineIdentification)}
@@ -7248,7 +7365,7 @@
7248
7365
  if (!currentTask && resolving.length === 0) {
7249
7366
  throw new UnexpectedError(
7250
7367
  // TODO: [🐎] DRY
7251
- spaceTrim.spaceTrim((block) => `
7368
+ spaceTrim$1.spaceTrim((block) => `
7252
7369
  Can not resolve some parameters:
7253
7370
 
7254
7371
  ${block(pipelineIdentification)}
@@ -7288,7 +7405,7 @@
7288
7405
  tools,
7289
7406
  onProgress(newOngoingResult) {
7290
7407
  if (isReturned) {
7291
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7408
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7292
7409
  Can not call \`onProgress\` after pipeline execution is finished
7293
7410
 
7294
7411
  ${block(pipelineIdentification)}
@@ -7303,8 +7420,9 @@
7303
7420
  onProgress(newOngoingResult);
7304
7421
  }
7305
7422
  },
7423
+ logLlmCall,
7306
7424
  $executionReport: executionReport,
7307
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7425
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7308
7426
  ${block(pipelineIdentification)}
7309
7427
  Task name: ${currentTask.name}
7310
7428
  Task title: ${currentTask.title}
@@ -7413,7 +7531,7 @@
7413
7531
  preparedPipeline = pipeline;
7414
7532
  }
7415
7533
  else if (isNotPreparedWarningSuppressed !== true) {
7416
- console.warn(spaceTrim.spaceTrim((block) => `
7534
+ console.warn(spaceTrim$1.spaceTrim((block) => `
7417
7535
  Pipeline is not prepared
7418
7536
 
7419
7537
  ${block(pipelineIdentification)}
@@ -7426,7 +7544,7 @@
7426
7544
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7427
7545
  }
7428
7546
  let runCount = 0;
7429
- const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
7547
+ const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
7430
7548
  runCount++;
7431
7549
  return /* not await */ executePipeline({
7432
7550
  pipeline,
@@ -7437,7 +7555,8 @@
7437
7555
  inputParameters,
7438
7556
  tools,
7439
7557
  onProgress,
7440
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7558
+ logLlmCall,
7559
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7441
7560
  ${block(pipelineIdentification)}
7442
7561
  ${runCount === 1 ? '' : `Run #${runCount}`}
7443
7562
  `),
@@ -7640,10 +7759,10 @@
7640
7759
  var _a, _b;
7641
7760
  const isMetadataAviailable = $llmToolsMetadataRegister
7642
7761
  .list()
7643
- .find(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7762
+ .some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7644
7763
  const isInstalled = $llmToolsRegister
7645
7764
  .list()
7646
- .find(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7765
+ .some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7647
7766
  const isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every((envVariableName) => env[envVariableName] !== undefined)) || false;
7648
7767
  const isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some((envVariableName) => env[envVariableName] !== undefined)) || false;
7649
7768
  // <- Note: [🗨]
@@ -7820,6 +7939,8 @@
7820
7939
  /**
7821
7940
  * Normalizes a given text to camelCase format.
7822
7941
  *
7942
+ * Note: [🔂] This function is idempotent.
7943
+ *
7823
7944
  * @param text The text to be normalized.
7824
7945
  * @param _isFirstLetterCapital Whether the first letter should be capitalized.
7825
7946
  * @returns The camelCase formatted string.
@@ -7946,6 +8067,9 @@
7946
8067
  }
7947
8068
 
7948
8069
  /**
8070
+ * Normalizes a given text to PascalCase format.
8071
+ *
8072
+ * Note: [🔂] This function is idempotent.
7949
8073
  *
7950
8074
  * @param text @public exported from `@promptbook/utils`
7951
8075
  * @returns
@@ -8010,7 +8134,7 @@
8010
8134
  let trimmedText = text;
8011
8135
  // Remove leading and trailing spaces and newlines
8012
8136
  if (isTrimmed) {
8013
- trimmedText = spaceTrim.spaceTrim(trimmedText);
8137
+ trimmedText = spaceTrim$1.spaceTrim(trimmedText);
8014
8138
  }
8015
8139
  let processedText = trimmedText;
8016
8140
  if (isIntroduceSentenceRemoved) {
@@ -8019,7 +8143,7 @@
8019
8143
  // Remove the introduce sentence and quotes by replacing it with an empty string
8020
8144
  processedText = processedText.replace(introduceSentenceRegex, '');
8021
8145
  }
8022
- processedText = spaceTrim.spaceTrim(processedText);
8146
+ processedText = spaceTrim$1.spaceTrim(processedText);
8023
8147
  }
8024
8148
  if (processedText.length < 3) {
8025
8149
  return trimmedText;
@@ -8123,13 +8247,13 @@
8123
8247
  * @public exported from `@promptbook/markdown-utils`
8124
8248
  */
8125
8249
  function trimCodeBlock(value) {
8126
- value = spaceTrim.spaceTrim(value);
8250
+ value = spaceTrim$1.spaceTrim(value);
8127
8251
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
8128
8252
  return value;
8129
8253
  }
8130
8254
  value = value.replace(/^```[a-z]*/i, '');
8131
8255
  value = value.replace(/```$/i, '');
8132
- value = spaceTrim.spaceTrim(value);
8256
+ value = spaceTrim$1.spaceTrim(value);
8133
8257
  return value;
8134
8258
  }
8135
8259
 
@@ -8142,9 +8266,9 @@
8142
8266
  * @public exported from `@promptbook/markdown-utils`
8143
8267
  */
8144
8268
  function trimEndOfCodeBlock(value) {
8145
- value = spaceTrim.spaceTrim(value);
8269
+ value = spaceTrim$1.spaceTrim(value);
8146
8270
  value = value.replace(/```$/g, '');
8147
- value = spaceTrim.spaceTrim(value);
8271
+ value = spaceTrim$1.spaceTrim(value);
8148
8272
  return value;
8149
8273
  }
8150
8274
 
@@ -9009,7 +9133,10 @@
9009
9133
  }), h(KeyVal, {
9010
9134
  label: 'Application mode:',
9011
9135
  value: info.isApplicationModeAllowed ? 'enabled' : 'disabled',
9012
- }), h(KeyVal, { label: 'Running executions:', value: String(info.runningExecutions) })), h(Section, { title: 'Pipelines in collection' }, h(List, { items: info.pipelines })), h(Section, { title: 'Paths' }, h(List, { items: info.paths })), h(Section, { title: 'Instructions' }, h('ol', { className: 'list-decimal ml-6 space-y-1' }, h('li', null, 'The client ', h('a', { href: 'https://www.npmjs.com/package/@promptbook/remote-client', className: 'text-blue-600 underline' }, 'https://www.npmjs.com/package/@promptbook/remote-client')), h('li', null, 'OpenAI compatible client ', h('span', { className: 'text-gray-500' }, '(Not working yet)')), h('li', null, 'REST API')), h('p', { className: 'mt-2' }, 'For more information look at: ', h('a', { href: 'https://github.com/webgptorg/promptbook', className: 'text-blue-600 underline' }, 'https://github.com/webgptorg/promptbook'))));
9136
+ }), h(KeyVal, { label: 'Running executions:', value: String(info.runningExecutions) })), h(Section, { title: 'Pipelines in collection' }, h(List, { items: info.pipelines })), h(Section, { title: 'Paths' }, h(List, { items: info.paths })), h(Section, { title: 'Instructions' }, h('ol', { className: 'list-decimal ml-6 space-y-1' }, h('li', null, 'The client ', h('a', {
9137
+ href: 'https://www.npmjs.com/package/@promptbook/remote-client',
9138
+ className: 'text-blue-600 underline',
9139
+ }, 'https://www.npmjs.com/package/@promptbook/remote-client')), h('li', null, 'OpenAI compatible client ', h('span', { className: 'text-gray-500' }, '(Not working yet)')), h('li', null, 'REST API')), h('p', { className: 'mt-2' }, 'For more information look at: ', h('a', { href: 'https://github.com/webgptorg/promptbook', className: 'text-blue-600 underline' }, 'https://github.com/webgptorg/promptbook'))));
9013
9140
  }
9014
9141
  function HtmlDoc({ info }) {
9015
9142
  return h('html', { lang: 'en' }, h('head', null, h('meta', { charSet: 'UTF-8' }), h('meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0' }), h('title', null, 'Promptbook Server'), h('link', {
@@ -9026,6 +9153,7 @@
9026
9153
  return '<!DOCTYPE html>' + server.renderToStaticMarkup(h(HtmlDoc, { info }));
9027
9154
  }
9028
9155
 
9156
+ // TODO: !!! Deprecate
9029
9157
  /**
9030
9158
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
9031
9159
  *
@@ -9204,7 +9332,7 @@
9204
9332
  response.type('text/html').send(renderServerIndexHtml(serverInfo));
9205
9333
  }
9206
9334
  else {
9207
- response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
9335
+ response.type('text/markdown').send(await spaceTrim$1.spaceTrim(async (block) => `
9208
9336
  # Promptbook
9209
9337
 
9210
9338
  > ${block(CLAIM)}
@@ -9332,10 +9460,10 @@
9332
9460
  .send({ error: serializeError(error) });
9333
9461
  }
9334
9462
  });
9335
- function exportExecutionTask(executionTask, isFull) {
9463
+ function exportExecutionTask(executionTask, isDetailed) {
9336
9464
  // <- TODO: [🧠] This should be maybe method of `ExecutionTask` itself
9337
- const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, } = executionTask;
9338
- if (isFull) {
9465
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
9466
+ if (isDetailed) {
9339
9467
  return {
9340
9468
  taskId,
9341
9469
  title,
@@ -9345,9 +9473,11 @@
9345
9473
  tldr,
9346
9474
  errors: errors.map(serializeError),
9347
9475
  warnings: warnings.map(serializeError),
9476
+ llmCalls,
9348
9477
  createdAt,
9349
9478
  updatedAt,
9350
9479
  currentValue,
9480
+ ptbkNonce: 0,
9351
9481
  };
9352
9482
  }
9353
9483
  else {
@@ -9360,6 +9490,8 @@
9360
9490
  tldr,
9361
9491
  createdAt,
9362
9492
  updatedAt,
9493
+ llmCalls,
9494
+ ptbkNonce: 0,
9363
9495
  };
9364
9496
  }
9365
9497
  }
@@ -9587,21 +9719,25 @@
9587
9719
  };
9588
9720
  }
9589
9721
  /**
9722
+
9723
+ * TODO: [🕋] Use here `aboutPromptbookInformation`
9590
9724
  * TODO: [🌡] Add CORS and security - probably via `helmet`
9591
9725
  * TODO: Split this file into multiple functions - handler for each request
9592
9726
  * TODO: Maybe use `$exportJson`
9593
9727
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
9594
- * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
9728
+ * TODO: [⚖] Expose the collection to be able to connect to same collection via createPipelineCollectionFromUrl
9595
9729
  * TODO: Handle progress - support streaming
9596
9730
  * TODO: [🗯] Do not hang up immediately but wait until client closes OR timeout
9597
9731
  * TODO: [🗯] Timeout on chat to free up resources
9598
9732
  * TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
9599
9733
  * TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
9600
9734
  * TODO: Allow to constrain anonymous mode for specific models / providers
9735
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9601
9736
  */
9602
9737
 
9603
9738
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
9604
9739
  exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
9740
+ exports.startAgentServer = startAgentServer;
9605
9741
  exports.startRemoteServer = startRemoteServer;
9606
9742
 
9607
9743
  Object.defineProperty(exports, '__esModule', { value: true });