@promptbook/remote-server 0.103.0-10 → 0.103.0-100

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 (253) hide show
  1. package/README.md +59 -35
  2. package/esm/index.es.js +503 -386
  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 +20 -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 +58 -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 +19 -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 +77 -7
  27. package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
  28. package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
  29. package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
  30. package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
  31. package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
  32. package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
  33. package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
  34. package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
  35. package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
  36. package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
  37. package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +1 -1
  38. package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
  39. package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
  40. package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
  41. package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
  42. package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
  43. package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
  44. package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
  45. package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +2 -2
  46. package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
  47. package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
  48. package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
  49. package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
  50. package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
  51. package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
  52. package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
  53. package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
  54. package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
  55. package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
  56. package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
  57. package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
  58. package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
  59. package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
  60. package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
  61. package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
  62. package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
  63. package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
  64. package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
  65. package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
  66. package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
  67. package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
  68. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
  69. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
  70. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
  71. package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
  72. package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
  73. package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
  74. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
  75. package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
  76. package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
  77. package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
  78. package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
  79. package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
  80. package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
  81. package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
  82. package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
  83. package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
  84. package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
  85. package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
  86. package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
  87. package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
  88. package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
  89. package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
  90. package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
  91. package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
  92. package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
  93. package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
  94. package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
  95. package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
  96. package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
  97. package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
  98. package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
  99. package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
  100. package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
  101. package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
  102. package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
  103. package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
  104. package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
  105. package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
  106. package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
  107. package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
  108. package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
  109. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
  110. package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
  111. package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
  112. package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
  113. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
  114. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
  115. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
  116. package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
  117. package/esm/typings/src/commitments/index.d.ts +93 -0
  118. package/esm/typings/src/config.d.ts +24 -3
  119. package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
  120. package/esm/typings/src/errors/0-index.d.ts +6 -0
  121. package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
  122. package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
  123. package/esm/typings/src/errors/WrappedError.d.ts +2 -2
  124. package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
  125. package/esm/typings/src/execution/Executables.d.ts +3 -0
  126. package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
  127. package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
  128. package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
  129. package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
  130. package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
  131. package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
  132. package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
  133. package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
  134. package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
  135. package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
  136. package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
  137. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
  138. package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
  139. package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
  140. package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
  141. package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
  142. package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
  143. package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
  144. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
  145. package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
  146. package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
  147. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
  148. package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
  149. package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
  150. package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
  151. package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
  152. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
  153. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
  154. package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
  155. package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
  156. package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
  157. package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
  158. package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
  159. package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
  160. package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
  161. package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
  162. package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
  163. package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
  164. package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
  165. package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
  166. package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
  167. package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
  168. package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
  169. package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
  170. package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
  171. package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
  172. package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
  173. package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
  174. package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
  175. package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
  176. package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
  177. package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
  178. package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
  179. package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
  180. package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
  181. package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
  182. package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
  183. package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
  184. package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
  185. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
  186. package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
  187. package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
  188. package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
  189. package/esm/typings/src/types/LlmCall.d.ts +20 -0
  190. package/esm/typings/src/types/Updatable.d.ts +19 -0
  191. package/esm/typings/src/types/typeAliases.d.ts +32 -2
  192. package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
  193. package/esm/typings/src/utils/color/Color.d.ts +15 -0
  194. package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
  195. package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
  196. package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
  197. package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
  198. package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
  199. package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
  200. package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
  201. package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
  202. package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
  203. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
  204. package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
  205. package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
  206. package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
  207. package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
  208. package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
  209. package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
  210. package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
  211. package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
  212. package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
  213. package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
  214. package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
  215. package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
  216. package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
  217. package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
  218. package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
  219. package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
  220. package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
  221. package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
  222. package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
  223. package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
  224. package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
  225. package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
  226. package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
  227. package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
  228. package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
  229. package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
  230. package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
  231. package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
  232. package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
  233. package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
  234. package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
  235. package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
  236. package/esm/typings/src/version.d.ts +1 -1
  237. package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
  238. package/package.json +7 -7
  239. package/umd/index.umd.js +524 -406
  240. package/umd/index.umd.js.map +1 -1
  241. package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
  242. package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -11
  243. package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
  244. package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
  245. package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
  246. /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
  247. /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
  248. /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
  249. /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
  250. /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
  251. /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
  252. /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
  253. /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-10';
50
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
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
@@ -319,6 +328,28 @@
319
328
  throw new Error(`Can not create color from given object`);
320
329
  }
321
330
  }
331
+ /**
332
+ * Creates a new Color instance from miscellaneous formats
333
+ * It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
334
+ *
335
+ * @param color
336
+ * @returns Color object
337
+ */
338
+ static fromSafe(color) {
339
+ try {
340
+ return Color.from(color);
341
+ }
342
+ catch (error) {
343
+ // <- Note: Can not use `assertsError(error)` here because it causes circular dependency
344
+ console.warn(spaceTrim((block) => `
345
+ Color.fromSafe error:
346
+ ${block(error.message)}
347
+
348
+ Returning default PROMPTBOOK_COLOR.
349
+ `));
350
+ return Color.fromString('promptbook');
351
+ }
352
+ }
322
353
  /**
323
354
  * Creates a new Color instance from miscellaneous string formats
324
355
  *
@@ -386,6 +417,9 @@
386
417
  if (hex.length === 3) {
387
418
  return Color.fromHex3(hex);
388
419
  }
420
+ if (hex.length === 4) {
421
+ return Color.fromHex4(hex);
422
+ }
389
423
  if (hex.length === 6) {
390
424
  return Color.fromHex6(hex);
391
425
  }
@@ -406,6 +440,19 @@
406
440
  const b = parseInt(hex.substr(2, 1), 16) * 16;
407
441
  return take(new Color(r, g, b));
408
442
  }
443
+ /**
444
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
445
+ *
446
+ * @param color in hex for example `09df`
447
+ * @returns Color object
448
+ */
449
+ static fromHex4(hex) {
450
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
451
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
452
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
453
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
454
+ return take(new Color(r, g, b, a));
455
+ }
409
456
  /**
410
457
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
411
458
  *
@@ -596,7 +643,8 @@
596
643
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
597
644
  */
598
645
  static isHexColorString(value) {
599
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
646
+ return (typeof value === 'string' &&
647
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
600
648
  }
601
649
  /**
602
650
  * Creates new Color object
@@ -711,6 +759,23 @@
711
759
  * TODO: Maybe connect with textures
712
760
  */
713
761
 
762
+ /**
763
+ * Makes color transformer which returns a grayscale version of the color
764
+ *
765
+ * @param amount from 0 to 1
766
+ *
767
+ * @public exported from `@promptbook/color`
768
+ */
769
+ function grayscale(amount) {
770
+ return ({ red, green, blue, alpha }) => {
771
+ const average = (red + green + blue) / 3;
772
+ red = Math.round(average * amount + red * (1 - amount));
773
+ green = Math.round(average * amount + green * (1 - amount));
774
+ blue = Math.round(average * amount + blue * (1 - amount));
775
+ return Color.fromValues(red, green, blue, alpha);
776
+ };
777
+ }
778
+
714
779
  /**
715
780
  * Converts HSL values to RGB values
716
781
  *
@@ -826,102 +891,6 @@
826
891
  * TODO: Maybe implement by mix+hsl
827
892
  */
828
893
 
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
894
  /**
926
895
  * Makes color transformer which saturate the given color
927
896
  *
@@ -998,16 +967,32 @@
998
967
  *
999
968
  * @public exported from `@promptbook/core`
1000
969
  */
1001
- const PROMPTBOOK_COLOR = Color.fromHex('#79EAFD');
1002
- // <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
970
+ const PROMPTBOOK_COLOR = Color.fromString('promptbook');
971
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
972
+ /**
973
+ * Colors for syntax highlighting in the `<BookEditor/>`
974
+ *
975
+ * TODO: [🗽] Unite branding and make single place for it
976
+ *
977
+ * @public exported from `@promptbook/core`
978
+ */
979
+ ({
980
+ TITLE: Color.fromHex('#244EA8'),
981
+ LINE: Color.fromHex('#eeeeee'),
982
+ SEPARATOR: Color.fromHex('#cccccc'),
983
+ COMMITMENT: Color.fromHex('#DA0F78'),
984
+ PARAMETER: Color.fromHex('#8e44ad'),
985
+ });
986
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1003
987
  /**
1004
- * Dark color of the Promptbook
988
+ * Chat color of the Promptbook (in chat)
1005
989
  *
1006
990
  * TODO: [🗽] Unite branding and make single place for it
1007
991
  *
1008
992
  * @public exported from `@promptbook/core`
1009
993
  */
1010
994
  PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
995
+ // <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
1011
996
  /**
1012
997
  * Color of the user (in chat)
1013
998
  *
@@ -1016,6 +1001,7 @@
1016
1001
  * @public exported from `@promptbook/core`
1017
1002
  */
1018
1003
  Color.fromHex('#1D4ED8');
1004
+ // <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
1019
1005
  /**
1020
1006
  * When the title is not provided, the default title is used
1021
1007
  *
@@ -1102,7 +1088,7 @@
1102
1088
  * @public exported from `@promptbook/core`
1103
1089
  */
1104
1090
  const DEFAULT_MAX_EXECUTION_ATTEMPTS = 7; // <- TODO: [🤹‍♂️]
1105
- // <- TODO: [🕝] Make also `BOOKS_DIRNAME_ALTERNATIVES`
1091
+ // <- TODO: [🕝] Make also `AGENTS_DIRNAME_ALTERNATIVES`
1106
1092
  // TODO: Just `.promptbook` in config, hardcode subfolders like `download-cache` or `execution-cache`
1107
1093
  /**
1108
1094
  * Where to store the temporary downloads
@@ -1151,24 +1137,246 @@
1151
1137
  */
1152
1138
  const DEFAULT_TASK_SIMULATED_DURATION_MS = 5 * 60 * 1000; // 5 minutes
1153
1139
  /**
1154
- * API request timeout in milliseconds
1155
- * Can be overridden via API_REQUEST_TIMEOUT environment variable
1156
- *
1157
- * @public exported from `@promptbook/core`
1140
+ * API request timeout in milliseconds
1141
+ * Can be overridden via API_REQUEST_TIMEOUT environment variable
1142
+ *
1143
+ * @public exported from `@promptbook/core`
1144
+ */
1145
+ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1146
+ /**
1147
+ * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
1148
+ *
1149
+ * @private within the repository
1150
+ */
1151
+ const IS_PIPELINE_LOGIC_VALIDATED = just(
1152
+ /**/
1153
+ // Note: In normal situations, we check the pipeline logic:
1154
+ true);
1155
+ /**
1156
+ * Note: [💞] Ignore a discrepancy between file name and entity name
1157
+ * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
1158
+ */
1159
+
1160
+ /**
1161
+ * This error type indicates that you try to use a feature that is not available in the current environment
1162
+ *
1163
+ * @public exported from `@promptbook/core`
1164
+ */
1165
+ class EnvironmentMismatchError extends Error {
1166
+ constructor(message) {
1167
+ super(message);
1168
+ this.name = 'EnvironmentMismatchError';
1169
+ Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
1170
+ }
1171
+ }
1172
+
1173
+ /**
1174
+ * Detects if the code is running in a Node.js environment
1175
+ *
1176
+ * Note: `$` is used to indicate that this function is not a pure function - it looks at the global object to determine the environment
1177
+ *
1178
+ * @public exported from `@promptbook/utils`
1179
+ */
1180
+ const $isRunningInNode = new Function(`
1181
+ try {
1182
+ return this === global;
1183
+ } catch (e) {
1184
+ return false;
1185
+ }
1186
+ `);
1187
+ /**
1188
+ * TODO: [🎺]
1189
+ */
1190
+
1191
+ /**
1192
+ * Normalize options for `execCommand` and `execCommands`
1193
+ *
1194
+ * Note: `$` is used to indicate that this function behaves differently according to `process.platform`
1195
+ *
1196
+ * @private internal utility of `execCommand` and `execCommands`
1197
+ */
1198
+ function $execCommandNormalizeOptions(options) {
1199
+ var _a, _b, _c, _d;
1200
+ let command;
1201
+ let cwd;
1202
+ let crashOnError;
1203
+ let args = [];
1204
+ let timeout;
1205
+ let isVerbose;
1206
+ if (typeof options === 'string') {
1207
+ // TODO: [1] DRY default values
1208
+ command = options;
1209
+ cwd = process.cwd();
1210
+ crashOnError = true;
1211
+ timeout = Infinity; // <- TODO: [⏳]
1212
+ isVerbose = DEFAULT_IS_VERBOSE;
1213
+ }
1214
+ else {
1215
+ /*
1216
+ TODO:
1217
+ if ((options as any).commands !== undefined) {
1218
+ commands = (options as any).commands;
1219
+ } else {
1220
+ commands = [(options as any).command];
1221
+ }
1222
+ */
1223
+ // TODO: [1] DRY default values
1224
+ command = options.command;
1225
+ cwd = (_a = options.cwd) !== null && _a !== void 0 ? _a : process.cwd();
1226
+ crashOnError = (_b = options.crashOnError) !== null && _b !== void 0 ? _b : true;
1227
+ timeout = (_c = options.timeout) !== null && _c !== void 0 ? _c : Infinity;
1228
+ isVerbose = (_d = options.isVerbose) !== null && _d !== void 0 ? _d : DEFAULT_IS_VERBOSE;
1229
+ }
1230
+ // TODO: /(-[a-zA-Z0-9-]+\s+[^\s]*)|[^\s]*/g
1231
+ const _ = Array.from(command.matchAll(/(".*")|([^\s]*)/g))
1232
+ .map(([match]) => match)
1233
+ .filter((arg) => arg !== '');
1234
+ if (_.length > 1) {
1235
+ [command, ...args] = _;
1236
+ }
1237
+ if (options.args) {
1238
+ args = [...args, ...options.args];
1239
+ }
1240
+ let humanReadableCommand = !['npx', 'npm'].includes(command) ? command : args[0];
1241
+ if (['ts-node'].includes(humanReadableCommand)) {
1242
+ humanReadableCommand += ` ${args[1]}`;
1243
+ }
1244
+ if (/^win/.test(process.platform) && ['npm', 'npx'].includes(command)) {
1245
+ command = `${command}.cmd`;
1246
+ }
1247
+ return { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose };
1248
+ }
1249
+ // TODO: This should show type error> execCommandNormalizeOptions({ command: '', commands: [''] });
1250
+
1251
+ /**
1252
+ * Run one command in a shell
1253
+ *
1254
+ *
1255
+ * Note: There are 2 similar functions in the codebase:
1256
+ * - `$execCommand` which runs a single command
1257
+ * - `$execCommands` which runs multiple commands
1258
+ * Note: `$` is used to indicate that this function is not a pure function - it runs a command in a shell
1259
+ *
1260
+ * @public exported from `@promptbook/node`
1261
+ */
1262
+ function $execCommand(options) {
1263
+ if (!$isRunningInNode()) {
1264
+ throw new EnvironmentMismatchError('Function `$execCommand` can run only in Node environment.js');
1265
+ }
1266
+ return new Promise((resolve, reject) => {
1267
+ // eslint-disable-next-line prefer-const
1268
+ const { command, humanReadableCommand, args, cwd, crashOnError, timeout, isVerbose = DEFAULT_IS_VERBOSE, } = $execCommandNormalizeOptions(options);
1269
+ if (timeout !== Infinity) {
1270
+ // TODO: In waitasecond forTime(Infinity) should be equivalent to forEver()
1271
+ waitasecond.forTime(timeout).then(() => {
1272
+ if (crashOnError) {
1273
+ reject(new Error(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms`));
1274
+ }
1275
+ else {
1276
+ console.warn(`Command "${humanReadableCommand}" exceeded time limit of ${timeout}ms but continues running`);
1277
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1278
+ resolve('Command exceeded time limit');
1279
+ }
1280
+ });
1281
+ }
1282
+ if (isVerbose) {
1283
+ console.info(colors__default["default"].yellow(cwd) + ' ' + colors__default["default"].green(command) + ' ' + colors__default["default"].blue(args.join(' ')));
1284
+ }
1285
+ try {
1286
+ const commandProcess = child_process.spawn(command, args, { cwd, shell: true });
1287
+ if (isVerbose) {
1288
+ commandProcess.on('message', (message) => {
1289
+ console.info({ message });
1290
+ });
1291
+ }
1292
+ const output = [];
1293
+ commandProcess.stdout.on('data', (stdout) => {
1294
+ output.push(stdout.toString());
1295
+ if (isVerbose) {
1296
+ console.info(stdout.toString());
1297
+ }
1298
+ });
1299
+ commandProcess.stderr.on('data', (stderr) => {
1300
+ output.push(stderr.toString());
1301
+ if (isVerbose && stderr.toString().trim()) {
1302
+ console.warn(stderr.toString());
1303
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1304
+ }
1305
+ });
1306
+ const finishWithCode = (code) => {
1307
+ if (code !== 0) {
1308
+ if (crashOnError) {
1309
+ reject(new Error(output.join('\n').trim() ||
1310
+ `Command "${humanReadableCommand}" exited with code ${code}`));
1311
+ }
1312
+ else {
1313
+ if (isVerbose) {
1314
+ console.warn(`Command "${humanReadableCommand}" exited with code ${code}`);
1315
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1316
+ }
1317
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1318
+ }
1319
+ }
1320
+ else {
1321
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1322
+ }
1323
+ };
1324
+ commandProcess.on('close', finishWithCode);
1325
+ commandProcess.on('exit', finishWithCode);
1326
+ commandProcess.on('disconnect', () => {
1327
+ // Note: Unexpected disconnection should always result in rejection
1328
+ reject(new Error(`Command "${humanReadableCommand}" disconnected`));
1329
+ });
1330
+ commandProcess.on('error', (error) => {
1331
+ if (crashOnError) {
1332
+ reject(new Error(`Command "${humanReadableCommand}" failed: \n${error.message}`));
1333
+ }
1334
+ else {
1335
+ if (isVerbose) {
1336
+ console.warn(error);
1337
+ // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
1338
+ }
1339
+ resolve(spaceTrim$1.spaceTrim(output.join('\n')));
1340
+ }
1341
+ });
1342
+ }
1343
+ catch (error) {
1344
+ // Note: Unexpected error in sync code should always result in rejection
1345
+ reject(error);
1346
+ }
1347
+ });
1348
+ }
1349
+ /**
1350
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1158
1351
  */
1159
- parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
1352
+
1160
1353
  /**
1161
- * Indicates whether pipeline logic validation is enabled. When true, the pipeline logic is checked for consistency.
1354
+ * [🐱‍🚀]
1355
+ * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
1162
1356
  *
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);
1357
+ * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
1358
+ * This is useful to make all logic on browser side but not expose your API keys or no need to use customer's GPU.
1359
+ *
1360
+ * @see https://github.com/webgptorg/promptbook#remote-server
1361
+ * @public exported from `@promptbook/remote-server`
1362
+ * <- TODO: [🐱‍🚀] Change to `@promptbook/agent-server`
1363
+ */
1364
+ async function startAgentServer(options) {
1365
+ const { port = 4440 } = options;
1366
+ // TODO: [🐱‍🚀] [🌕]
1367
+ const agentsServerRoot = path.join(__dirname, '../apps/agents-server');
1368
+ console.trace(`!!! Starting agents server on port ${port}...`);
1369
+ console.log(`!!! cwd`, process.cwd());
1370
+ console.log(`!!! __dirname`, __dirname);
1371
+ console.log(`!!! agentsServerRoot`, agentsServerRoot);
1372
+ await $execCommand({
1373
+ cwd: agentsServerRoot,
1374
+ command: `next dev --port ${port} `,
1375
+ isVerbose: true,
1376
+ });
1377
+ }
1169
1378
  /**
1170
- * Note: [💞] Ignore a discrepancy between file name and entity name
1171
- * TODO: [🧠][🧜‍♂️] Maybe join remoteServerUrl and path into single value
1379
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
1172
1380
  */
1173
1381
 
1174
1382
  /**
@@ -1222,7 +1430,7 @@
1222
1430
  */
1223
1431
  class UnexpectedError extends Error {
1224
1432
  constructor(message) {
1225
- super(spaceTrim.spaceTrim((block) => `
1433
+ super(spaceTrim$1.spaceTrim((block) => `
1226
1434
  ${block(message)}
1227
1435
 
1228
1436
  Note: This error should not happen.
@@ -1248,7 +1456,7 @@
1248
1456
  constructor(whatWasThrown) {
1249
1457
  const tag = `[🤮]`;
1250
1458
  console.error(tag, whatWasThrown);
1251
- super(spaceTrim.spaceTrim(`
1459
+ super(spaceTrim$1.spaceTrim(`
1252
1460
  Non-Error object was thrown
1253
1461
 
1254
1462
  Note: Look for ${tag} in the console for more details
@@ -1303,6 +1511,7 @@
1303
1511
  /**
1304
1512
  * Generates random token
1305
1513
  *
1514
+ * Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
1306
1515
  * Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
1307
1516
  *
1308
1517
  * @private internal helper function
@@ -1312,6 +1521,7 @@
1312
1521
  return crypto.randomBytes(randomness).toString('hex');
1313
1522
  }
1314
1523
  /**
1524
+ * TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
1315
1525
  * TODO: Maybe use nanoid instead https://github.com/ai/nanoid
1316
1526
  */
1317
1527
 
@@ -1378,17 +1588,20 @@
1378
1588
  }
1379
1589
 
1380
1590
  /**
1381
- * This error type indicates that you try to use a feature that is not available in the current environment
1591
+ * This error indicates error from the database
1382
1592
  *
1383
1593
  * @public exported from `@promptbook/core`
1384
1594
  */
1385
- class EnvironmentMismatchError extends Error {
1595
+ class DatabaseError extends Error {
1386
1596
  constructor(message) {
1387
1597
  super(message);
1388
- this.name = 'EnvironmentMismatchError';
1389
- Object.setPrototypeOf(this, EnvironmentMismatchError.prototype);
1598
+ this.name = 'DatabaseError';
1599
+ Object.setPrototypeOf(this, DatabaseError.prototype);
1390
1600
  }
1391
1601
  }
1602
+ /**
1603
+ * TODO: [🐱‍🚀] Explain that NotFoundError ([🐱‍🚀] and other specific errors) has priority over DatabaseError in some contexts
1604
+ */
1392
1605
 
1393
1606
  /**
1394
1607
  * This error occurs when some expectation is not met in the execution of the pipeline
@@ -1439,7 +1652,7 @@
1439
1652
  */
1440
1653
  class MissingToolsError extends Error {
1441
1654
  constructor(message) {
1442
- super(spaceTrim.spaceTrim((block) => `
1655
+ super(spaceTrim$1.spaceTrim((block) => `
1443
1656
  ${block(message)}
1444
1657
 
1445
1658
  Note: You have probably forgot to provide some tools for pipeline execution or preparation
@@ -1450,6 +1663,19 @@
1450
1663
  }
1451
1664
  }
1452
1665
 
1666
+ /**
1667
+ * This error indicates that promptbook operation is not allowed
1668
+ *
1669
+ * @public exported from `@promptbook/core`
1670
+ */
1671
+ class NotAllowed extends Error {
1672
+ constructor(message) {
1673
+ super(message);
1674
+ this.name = 'NotAllowed';
1675
+ Object.setPrototypeOf(this, NotAllowed.prototype);
1676
+ }
1677
+ }
1678
+
1453
1679
  /**
1454
1680
  * This error indicates that promptbook not found in the collection
1455
1681
  *
@@ -1470,7 +1696,7 @@
1470
1696
  */
1471
1697
  class NotYetImplementedError extends Error {
1472
1698
  constructor(message) {
1473
- super(spaceTrim.spaceTrim((block) => `
1699
+ super(spaceTrim$1.spaceTrim((block) => `
1474
1700
  ${block(message)}
1475
1701
 
1476
1702
  Note: This feature is not implemented yet but it will be soon.
@@ -1565,6 +1791,8 @@
1565
1791
  PromptbookFetchError,
1566
1792
  UnexpectedError,
1567
1793
  WrappedError,
1794
+ NotAllowed,
1795
+ DatabaseError,
1568
1796
  // TODO: [🪑]> VersionMismatchError,
1569
1797
  };
1570
1798
  /**
@@ -1632,186 +1860,6 @@
1632
1860
  };
1633
1861
  }
1634
1862
 
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
1863
  /**
1816
1864
  * Attempts to locate the specified application on a Linux system using the 'which' command.
1817
1865
  * Returns the path to the executable if found, or null otherwise.
@@ -1851,6 +1899,7 @@
1851
1899
  writeFile: promises.writeFile,
1852
1900
  readdir: promises.readdir,
1853
1901
  mkdir: promises.mkdir,
1902
+ watch: promises.watch,
1854
1903
  };
1855
1904
  }
1856
1905
  /**
@@ -2239,7 +2288,7 @@
2239
2288
  TODO: [🧠] Is there a better implementation?
2240
2289
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
2241
2290
  > for (const propertyName of propertyNames) {
2242
- > const value = (objectValue as really_any)[propertyName];
2291
+ > const value = (objectValue as chococake)[propertyName];
2243
2292
  > if (value && typeof value === 'object') {
2244
2293
  > deepClone(value);
2245
2294
  > }
@@ -2461,6 +2510,8 @@
2461
2510
  * - if it is valid json
2462
2511
  * - if it is meaningful
2463
2512
  *
2513
+ * Note: [🔂] This function is idempotent.
2514
+ *
2464
2515
  * @param pipeline valid or invalid PipelineJson
2465
2516
  * @returns the same pipeline if it is logically valid
2466
2517
  * @throws {PipelineLogicError} on logical error in the pipeline
@@ -2478,7 +2529,7 @@
2478
2529
  if (!(error instanceof PipelineLogicError)) {
2479
2530
  throw error;
2480
2531
  }
2481
- console.error(spaceTrim.spaceTrim((block) => `
2532
+ console.error(spaceTrim$1.spaceTrim((block) => `
2482
2533
  Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2483
2534
 
2484
2535
  ${block(error.message)}
@@ -2505,7 +2556,7 @@
2505
2556
  })();
2506
2557
  if (pipeline.pipelineUrl !== undefined && !isValidPipelineUrl(pipeline.pipelineUrl)) {
2507
2558
  // <- Note: [🚲]
2508
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2559
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2509
2560
  Invalid promptbook URL "${pipeline.pipelineUrl}"
2510
2561
 
2511
2562
  ${block(pipelineIdentification)}
@@ -2513,7 +2564,7 @@
2513
2564
  }
2514
2565
  if (pipeline.bookVersion !== undefined && !isValidPromptbookVersion(pipeline.bookVersion)) {
2515
2566
  // <- Note: [🚲]
2516
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2567
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2517
2568
  Invalid Promptbook Version "${pipeline.bookVersion}"
2518
2569
 
2519
2570
  ${block(pipelineIdentification)}
@@ -2522,7 +2573,7 @@
2522
2573
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2523
2574
  if (!Array.isArray(pipeline.parameters)) {
2524
2575
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2525
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2576
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2526
2577
  Pipeline is valid JSON but with wrong structure
2527
2578
 
2528
2579
  \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
@@ -2533,7 +2584,7 @@
2533
2584
  // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2534
2585
  if (!Array.isArray(pipeline.tasks)) {
2535
2586
  // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2536
- throw new ParseError(spaceTrim.spaceTrim((block) => `
2587
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
2537
2588
  Pipeline is valid JSON but with wrong structure
2538
2589
 
2539
2590
  \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
@@ -2559,7 +2610,7 @@
2559
2610
  // Note: Check each parameter individually
2560
2611
  for (const parameter of pipeline.parameters) {
2561
2612
  if (parameter.isInput && parameter.isOutput) {
2562
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2613
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2563
2614
 
2564
2615
  Parameter \`{${parameter.name}}\` can not be both input and output
2565
2616
 
@@ -2570,7 +2621,7 @@
2570
2621
  if (!parameter.isInput &&
2571
2622
  !parameter.isOutput &&
2572
2623
  !pipeline.tasks.some((task) => task.dependentParameterNames.includes(parameter.name))) {
2573
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2624
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2574
2625
  Parameter \`{${parameter.name}}\` is created but not used
2575
2626
 
2576
2627
  You can declare {${parameter.name}} as output parameter by adding in the header:
@@ -2582,7 +2633,7 @@
2582
2633
  }
2583
2634
  // Note: Testing that parameter is either input or result of some task
2584
2635
  if (!parameter.isInput && !pipeline.tasks.some((task) => task.resultingParameterName === parameter.name)) {
2585
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2636
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2586
2637
  Parameter \`{${parameter.name}}\` is declared but not defined
2587
2638
 
2588
2639
  You can do one of these:
@@ -2598,14 +2649,14 @@
2598
2649
  // Note: Checking each task individually
2599
2650
  for (const task of pipeline.tasks) {
2600
2651
  if (definedParameters.has(task.resultingParameterName)) {
2601
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2652
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2602
2653
  Parameter \`{${task.resultingParameterName}}\` is defined multiple times
2603
2654
 
2604
2655
  ${block(pipelineIdentification)}
2605
2656
  `));
2606
2657
  }
2607
2658
  if (RESERVED_PARAMETER_NAMES.includes(task.resultingParameterName)) {
2608
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2659
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2609
2660
  Parameter name {${task.resultingParameterName}} is reserved, please use different name
2610
2661
 
2611
2662
  ${block(pipelineIdentification)}
@@ -2615,7 +2666,7 @@
2615
2666
  if (task.jokerParameterNames && task.jokerParameterNames.length > 0) {
2616
2667
  if (!task.format &&
2617
2668
  !task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
2618
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2669
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2619
2670
  Joker parameters are used for {${task.resultingParameterName}} but no expectations are defined
2620
2671
 
2621
2672
  ${block(pipelineIdentification)}
@@ -2623,7 +2674,7 @@
2623
2674
  }
2624
2675
  for (const joker of task.jokerParameterNames) {
2625
2676
  if (!task.dependentParameterNames.includes(joker)) {
2626
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2677
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2627
2678
  Parameter \`{${joker}}\` is used for {${task.resultingParameterName}} as joker but not in \`dependentParameterNames\`
2628
2679
 
2629
2680
  ${block(pipelineIdentification)}
@@ -2634,21 +2685,21 @@
2634
2685
  if (task.expectations) {
2635
2686
  for (const [unit, { min, max }] of Object.entries(task.expectations)) {
2636
2687
  if (min !== undefined && max !== undefined && min > max) {
2637
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2688
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2638
2689
  Min expectation (=${min}) of ${unit} is higher than max expectation (=${max})
2639
2690
 
2640
2691
  ${block(pipelineIdentification)}
2641
2692
  `));
2642
2693
  }
2643
2694
  if (min !== undefined && min < 0) {
2644
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2695
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2645
2696
  Min expectation of ${unit} must be zero or positive
2646
2697
 
2647
2698
  ${block(pipelineIdentification)}
2648
2699
  `));
2649
2700
  }
2650
2701
  if (max !== undefined && max <= 0) {
2651
- throw new PipelineLogicError(spaceTrim.spaceTrim((block) => `
2702
+ throw new PipelineLogicError(spaceTrim$1.spaceTrim((block) => `
2652
2703
  Max expectation of ${unit} must be positive
2653
2704
 
2654
2705
  ${block(pipelineIdentification)}
@@ -2670,7 +2721,7 @@
2670
2721
  while (unresovedTasks.length > 0) {
2671
2722
  if (loopLimit-- < 0) {
2672
2723
  // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2673
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
2724
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
2674
2725
  Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2675
2726
 
2676
2727
  ${block(pipelineIdentification)}
@@ -2680,7 +2731,7 @@
2680
2731
  if (currentlyResovedTasks.length === 0) {
2681
2732
  throw new PipelineLogicError(
2682
2733
  // TODO: [🐎] DRY
2683
- spaceTrim.spaceTrim((block) => `
2734
+ spaceTrim$1.spaceTrim((block) => `
2684
2735
 
2685
2736
  Can not resolve some parameters:
2686
2737
  Either you are using a parameter that is not defined, or there are some circular dependencies.
@@ -2921,11 +2972,11 @@
2921
2972
  throw deserializeError(errors[0]);
2922
2973
  }
2923
2974
  else {
2924
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
2975
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
2925
2976
  Multiple errors occurred during Promptbook execution
2926
2977
 
2927
2978
  ${block(errors
2928
- .map(({ name, stack, message }, index) => spaceTrim.spaceTrim((block) => `
2979
+ .map(({ name, stack, message }, index) => spaceTrim$1.spaceTrim((block) => `
2929
2980
  ${name} ${index + 1}:
2930
2981
  ${block(stack || message)}
2931
2982
  `))
@@ -2952,6 +3003,7 @@
2952
3003
  let updatedAt = createdAt;
2953
3004
  const errors = [];
2954
3005
  const warnings = [];
3006
+ const llmCalls = [];
2955
3007
  let currentValue = {};
2956
3008
  let customTldr = null;
2957
3009
  const partialResultSubject = new rxjs.Subject();
@@ -2967,6 +3019,9 @@
2967
3019
  }, (tldrInfo) => {
2968
3020
  customTldr = tldrInfo;
2969
3021
  updatedAt = new Date();
3022
+ }, (llmCall) => {
3023
+ llmCalls.push(llmCall);
3024
+ updatedAt = new Date();
2970
3025
  });
2971
3026
  finalResultPromise
2972
3027
  .catch((error) => {
@@ -3089,7 +3144,7 @@
3089
3144
  }
3090
3145
  return {
3091
3146
  percent: percent,
3092
- message,
3147
+ message: message + ' (!!!fallback)',
3093
3148
  };
3094
3149
  },
3095
3150
  get createdAt() {
@@ -3112,6 +3167,10 @@
3112
3167
  return warnings;
3113
3168
  // <- Note: [1] --||--
3114
3169
  },
3170
+ get llmCalls() {
3171
+ return [...llmCalls, { foo: '!!! bar' }];
3172
+ // <- Note: [1] --||--
3173
+ },
3115
3174
  get currentValue() {
3116
3175
  return currentValue;
3117
3176
  // <- Note: [1] --||--
@@ -3191,7 +3250,7 @@
3191
3250
  * Note: [💞] Ignore a discrepancy between file name and entity name
3192
3251
  */
3193
3252
 
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-9",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"}];
3253
+ 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
3254
 
3196
3255
  /**
3197
3256
  * Checks if value is valid email
@@ -3268,6 +3327,8 @@
3268
3327
  * Function `validatePipelineString` will validate the if the string is a valid pipeline string
3269
3328
  * 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
3329
  *
3330
+ * Note: [🔂] This function is idempotent.
3331
+ *
3271
3332
  * @param {string} pipelineString the candidate for a pipeline string
3272
3333
  * @returns {PipelineString} the same string as input, but validated as valid
3273
3334
  * @throws {ParseError} if the string is not a valid pipeline string
@@ -3515,7 +3576,7 @@
3515
3576
  * Library of pipelines that groups together pipelines for an application.
3516
3577
  * This implementation is a very thin wrapper around the Array / Map of pipelines.
3517
3578
  *
3518
- * @private internal function of `createCollectionFromJson`, use `createCollectionFromJson` instead
3579
+ * @private internal function of `createPipelineCollectionFromJson`, use `createPipelineCollectionFromJson` instead
3519
3580
  * @see https://github.com/webgptorg/pipeline#pipeline-collection
3520
3581
  */
3521
3582
  class SimplePipelineCollection {
@@ -3525,14 +3586,14 @@
3525
3586
  * @param pipelines Array of pipeline JSON objects to include in the collection
3526
3587
  *
3527
3588
  * 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
3589
+ * Note: It is not recommended to use this constructor directly, use `createPipelineCollectionFromJson` *(or other variant)* instead
3529
3590
  */
3530
3591
  constructor(...pipelines) {
3531
3592
  this.collection = new Map();
3532
3593
  for (const pipeline of pipelines) {
3533
3594
  // TODO: [👠] DRY
3534
3595
  if (pipeline.pipelineUrl === undefined) {
3535
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3596
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3536
3597
  Pipeline with name "${pipeline.title}" does not have defined URL
3537
3598
 
3538
3599
  File:
@@ -3554,7 +3615,7 @@
3554
3615
  pipelineJsonToString(unpreparePipeline(pipeline)) !==
3555
3616
  pipelineJsonToString(unpreparePipeline(this.collection.get(pipeline.pipelineUrl)))) {
3556
3617
  const existing = this.collection.get(pipeline.pipelineUrl);
3557
- throw new PipelineUrlError(spaceTrim.spaceTrim(`
3618
+ throw new PipelineUrlError(spaceTrim$1.spaceTrim(`
3558
3619
  Pipeline with URL ${pipeline.pipelineUrl} is already in the collection 🍎
3559
3620
 
3560
3621
  Conflicting files:
@@ -3586,13 +3647,13 @@
3586
3647
  const pipeline = this.collection.get(url);
3587
3648
  if (!pipeline) {
3588
3649
  if (this.listPipelines().length === 0) {
3589
- throw new NotFoundError(spaceTrim.spaceTrim(`
3650
+ throw new NotFoundError(spaceTrim$1.spaceTrim(`
3590
3651
  Pipeline with url "${url}" not found
3591
3652
 
3592
3653
  No pipelines available
3593
3654
  `));
3594
3655
  }
3595
- throw new NotFoundError(spaceTrim.spaceTrim((block) => `
3656
+ throw new NotFoundError(spaceTrim$1.spaceTrim((block) => `
3596
3657
  Pipeline with url "${url}" not found
3597
3658
 
3598
3659
  Available pipelines:
@@ -3613,16 +3674,16 @@
3613
3674
  }
3614
3675
 
3615
3676
  /**
3616
- * Creates PipelineCollection from array of PipelineJson or PipelineString
3677
+ * Creates `PipelineCollection` from array of PipelineJson or PipelineString
3617
3678
  *
3618
- * Note: Functions `collectionToJson` and `createCollectionFromJson` are complementary
3679
+ * Note: Functions `pipelineCollectionToJson` and `createPipelineCollectionFromJson` are complementary
3619
3680
  * Note: Syntax, parsing, and logic consistency checks are performed on all sources during build
3620
3681
  *
3621
3682
  * @param promptbookSources
3622
3683
  * @returns PipelineCollection
3623
3684
  * @public exported from `@promptbook/core`
3624
3685
  */
3625
- function createCollectionFromJson(...promptbooks) {
3686
+ function createPipelineCollectionFromJson(...promptbooks) {
3626
3687
  return new SimplePipelineCollection(...promptbooks);
3627
3688
  }
3628
3689
 
@@ -4000,6 +4061,7 @@
4000
4061
  return new MultipleLlmExecutionTools(title || 'Multiple LLM Providers joined by `joinLlmExecutionTools`', ...llmExecutionTools);
4001
4062
  }
4002
4063
  /**
4064
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4003
4065
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4004
4066
  */
4005
4067
 
@@ -4016,6 +4078,7 @@
4016
4078
  return llmTools;
4017
4079
  }
4018
4080
  /**
4081
+ * TODO: [🙆] `getSingleLlmExecutionTools` vs `joinLlmExecutionTools` - explain difference or pick one
4019
4082
  * TODO: [👷‍♂️] @@@ Manual about construction of llmTools
4020
4083
  */
4021
4084
 
@@ -4031,7 +4094,7 @@
4031
4094
  throw new MissingToolsError('LLM tools are required for preparing persona');
4032
4095
  }
4033
4096
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
4034
- const collection = createCollectionFromJson(...PipelineCollection);
4097
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
4035
4098
  const preparePersonaExecutor = createPipelineExecutor({
4036
4099
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-persona.book'),
4037
4100
  tools,
@@ -4597,6 +4660,8 @@
4597
4660
  /**
4598
4661
  * Converts a given text to kebab-case format.
4599
4662
  *
4663
+ * Note: [🔂] This function is idempotent.
4664
+ *
4600
4665
  * @param text The text to be converted.
4601
4666
  * @returns The kebab-case formatted string.
4602
4667
  * @example 'hello-world'
@@ -4752,6 +4817,8 @@
4752
4817
  /**
4753
4818
  * Converts a title string into a normalized name.
4754
4819
  *
4820
+ * Note: [🔂] This function is idempotent.
4821
+ *
4755
4822
  * @param value The title string to be converted to a name.
4756
4823
  * @returns A normalized name derived from the input title.
4757
4824
  * @example 'Hello World!' -> 'hello-world'
@@ -5140,7 +5207,7 @@
5140
5207
  if (task.taskType === 'PROMPT_TASK' &&
5141
5208
  knowledgePiecesCount > 0 &&
5142
5209
  !dependentParameterNames.includes('knowledge')) {
5143
- preparedContent = spaceTrim.spaceTrim(`
5210
+ preparedContent = spaceTrim$1.spaceTrim(`
5144
5211
  {content}
5145
5212
 
5146
5213
  ## Knowledge
@@ -5226,7 +5293,7 @@
5226
5293
  let title = pipeline.title;
5227
5294
  if (title === undefined || title === '' || title === DEFAULT_BOOK_TITLE) {
5228
5295
  // TODO: [🌼] In future use `ptbk make` and made getPipelineCollection
5229
- const collection = createCollectionFromJson(...PipelineCollection);
5296
+ const collection = createPipelineCollectionFromJson(...PipelineCollection);
5230
5297
  const prepareTitleExecutor = createPipelineExecutor({
5231
5298
  pipeline: await collection.getPipelineByUrl('https://promptbook.studio/promptbook/prepare-title.book'),
5232
5299
  tools,
@@ -5453,7 +5520,7 @@
5453
5520
  }
5454
5521
  catch (error) {
5455
5522
  assertsError(error);
5456
- throw new ParseError(spaceTrim.spaceTrim((block) => `
5523
+ throw new ParseError(spaceTrim$1.spaceTrim((block) => `
5457
5524
  Can not extract variables from the script
5458
5525
  ${block(error.stack || error.message)}
5459
5526
 
@@ -6155,10 +6222,13 @@
6155
6222
  * @public exported from `@promptbook/utils`
6156
6223
  */
6157
6224
  function countLines(text) {
6225
+ if (text === '') {
6226
+ return 0;
6227
+ }
6158
6228
  text = text.replace('\r\n', '\n');
6159
6229
  text = text.replace('\r', '\n');
6160
6230
  const lines = text.split('\n');
6161
- return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
6231
+ return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
6162
6232
  }
6163
6233
  /**
6164
6234
  * TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
@@ -6283,6 +6353,8 @@
6283
6353
  * This function provides a common abstraction for result validation that can be used
6284
6354
  * by both execution logic and caching logic to ensure consistency.
6285
6355
  *
6356
+ * Note: [🔂] This function is idempotent.
6357
+ *
6286
6358
  * @param options - The validation options including result string, expectations, and format
6287
6359
  * @returns Validation result with processed string and validity status
6288
6360
  * @private internal function of `createPipelineExecutor` and `cacheLlmTools`
@@ -6302,7 +6374,7 @@
6302
6374
  }
6303
6375
  catch (error) {
6304
6376
  keepUnused(error);
6305
- throw new ExpectError(spaceTrim.spaceTrim((block) => `
6377
+ throw new ExpectError(spaceTrim$1.spaceTrim((block) => `
6306
6378
  Expected valid JSON string
6307
6379
 
6308
6380
  The expected JSON text:
@@ -6351,7 +6423,7 @@
6351
6423
  */
6352
6424
  async function executeAttempts(options) {
6353
6425
  const { jokerParameterNames, priority, maxAttempts, // <- Note: [💂]
6354
- preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, } = options;
6426
+ preparedContent, parameters, task, preparedPipeline, tools, $executionReport, pipelineIdentification, maxExecutionAttempts, onProgress, logLlmCall, } = options;
6355
6427
  const $ongoingTaskResult = {
6356
6428
  $result: null,
6357
6429
  $resultString: null,
@@ -6365,7 +6437,7 @@
6365
6437
  const jokerParameterName = jokerParameterNames[jokerParameterNames.length + attemptIndex];
6366
6438
  // TODO: [🧠][🍭] JOKERS, EXPECTATIONS, POSTPROCESSING and FOREACH
6367
6439
  if (isJokerAttempt && !jokerParameterName) {
6368
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6440
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6369
6441
  Joker not found in attempt ${attemptIndex}
6370
6442
 
6371
6443
  ${block(pipelineIdentification)}
@@ -6376,7 +6448,7 @@
6376
6448
  $ongoingTaskResult.$expectError = null;
6377
6449
  if (isJokerAttempt) {
6378
6450
  if (parameters[jokerParameterName] === undefined) {
6379
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6451
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6380
6452
  Joker parameter {${jokerParameterName}} not defined
6381
6453
 
6382
6454
  ${block(pipelineIdentification)}
@@ -6434,7 +6506,7 @@
6434
6506
  $ongoingTaskResult.$resultString = $ongoingTaskResult.$completionResult.content;
6435
6507
  break variant;
6436
6508
  case 'EMBEDDING':
6437
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6509
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6438
6510
  Embedding model can not be used in pipeline
6439
6511
 
6440
6512
  This should be catched during parsing
@@ -6445,7 +6517,7 @@
6445
6517
  break variant;
6446
6518
  // <- case [🤖]:
6447
6519
  default:
6448
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6520
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6449
6521
  Unknown model variant "${task.modelRequirements.modelVariant}"
6450
6522
 
6451
6523
  ${block(pipelineIdentification)}
@@ -6456,14 +6528,14 @@
6456
6528
  break;
6457
6529
  case 'SCRIPT_TASK':
6458
6530
  if (arrayableToArray(tools.script).length === 0) {
6459
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6531
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6460
6532
  No script execution tools are available
6461
6533
 
6462
6534
  ${block(pipelineIdentification)}
6463
6535
  `));
6464
6536
  }
6465
6537
  if (!task.contentLanguage) {
6466
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6538
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6467
6539
  Script language is not defined for SCRIPT TASK "${task.name}"
6468
6540
 
6469
6541
  ${block(pipelineIdentification)}
@@ -6494,7 +6566,7 @@
6494
6566
  throw $ongoingTaskResult.$scriptPipelineExecutionErrors[0];
6495
6567
  }
6496
6568
  else {
6497
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6569
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6498
6570
  Script execution failed ${$ongoingTaskResult.$scriptPipelineExecutionErrors.length}x
6499
6571
 
6500
6572
  ${block(pipelineIdentification)}
@@ -6508,7 +6580,7 @@
6508
6580
  break taskType;
6509
6581
  case 'DIALOG_TASK':
6510
6582
  if (tools.userInterface === undefined) {
6511
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6583
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6512
6584
  User interface tools are not available
6513
6585
 
6514
6586
  ${block(pipelineIdentification)}
@@ -6526,7 +6598,7 @@
6526
6598
  break taskType;
6527
6599
  // <- case: [🅱]
6528
6600
  default:
6529
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
6601
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
6530
6602
  Unknown execution type "${task.taskType}"
6531
6603
 
6532
6604
  ${block(pipelineIdentification)}
@@ -6599,14 +6671,10 @@
6599
6671
  });
6600
6672
  }
6601
6673
  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({
6674
+ if (!isJokerAttempt && task.taskType === 'PROMPT_TASK' && $ongoingTaskResult.$prompt) {
6675
+ // Note: [2] When some expected parameter is not defined, error will occur in templateParameters
6676
+ // In that case we don’t want to make a report about it because it’s not a llm execution error
6677
+ const executionPromptReport = {
6610
6678
  prompt: {
6611
6679
  ...$ongoingTaskResult.$prompt,
6612
6680
  // <- TODO: [🧠] How to pick everyhing except `pipelineUrl`
@@ -6615,13 +6683,20 @@
6615
6683
  error: $ongoingTaskResult.$expectError === null
6616
6684
  ? undefined
6617
6685
  : serializeError($ongoingTaskResult.$expectError),
6618
- });
6686
+ };
6687
+ $executionReport.promptExecutions.push(executionPromptReport);
6688
+ if (logLlmCall) {
6689
+ logLlmCall({
6690
+ modelName: 'model' /* <- TODO: How to get model name from the report */,
6691
+ report: executionPromptReport,
6692
+ });
6693
+ }
6619
6694
  }
6620
6695
  }
6621
6696
  if ($ongoingTaskResult.$expectError !== null && attemptIndex === maxAttempts - 1) {
6622
6697
  // Note: Create a summary of all failures
6623
6698
  const failuresSummary = $ongoingTaskResult.$failedResults
6624
- .map((failure) => spaceTrim.spaceTrim((block) => {
6699
+ .map((failure) => spaceTrim$1.spaceTrim((block) => {
6625
6700
  var _a, _b;
6626
6701
  return `
6627
6702
  Attempt ${failure.attemptIndex + 1}:
@@ -6631,14 +6706,14 @@
6631
6706
  Result:
6632
6707
  ${block(failure.result === null
6633
6708
  ? 'null'
6634
- : spaceTrim.spaceTrim(failure.result)
6709
+ : spaceTrim$1.spaceTrim(failure.result)
6635
6710
  .split('\n')
6636
6711
  .map((line) => `> ${line}`)
6637
6712
  .join('\n'))}
6638
6713
  `;
6639
6714
  }))
6640
6715
  .join('\n\n---\n\n');
6641
- throw new PipelineExecutionError(spaceTrim.spaceTrim((block) => {
6716
+ throw new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => {
6642
6717
  var _a;
6643
6718
  return `
6644
6719
  LLM execution failed ${maxExecutionAttempts}x
@@ -6658,7 +6733,7 @@
6658
6733
  }
6659
6734
  }
6660
6735
  if ($ongoingTaskResult.$resultString === null) {
6661
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
6736
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6662
6737
  Something went wrong and prompt result is null
6663
6738
 
6664
6739
  ${block(pipelineIdentification)}
@@ -6680,9 +6755,9 @@
6680
6755
  * @private internal utility of `createPipelineExecutor`
6681
6756
  */
6682
6757
  async function executeFormatSubvalues(options) {
6683
- const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, pipelineIdentification } = options;
6758
+ const { task, jokerParameterNames, parameters, priority, csvSettings, onProgress, logLlmCall, pipelineIdentification, } = options;
6684
6759
  if (task.foreach === undefined) {
6685
- return /* not await */ executeAttempts(options);
6760
+ return /* not await */ executeAttempts({ ...options, logLlmCall });
6686
6761
  }
6687
6762
  if (jokerParameterNames.length !== 0) {
6688
6763
  throw new UnexpectedError(spaceTrim__default["default"]((block) => `
@@ -6888,7 +6963,7 @@
6888
6963
  },
6889
6964
  content: task.content,
6890
6965
  parameters,
6891
- };
6966
+ }; /* <- Note: [🤛] */
6892
6967
  const taskEmbeddingResult = await llmTools.callEmbeddingModel(taskEmbeddingPrompt);
6893
6968
  const knowledgePiecesWithRelevance = preparedPipeline.knowledgePieces.map((knowledgePiece) => {
6894
6969
  const { index } = knowledgePiece;
@@ -6964,7 +7039,7 @@
6964
7039
  // Note: Doublecheck that ALL reserved parameters are defined:
6965
7040
  for (const parameterName of RESERVED_PARAMETER_NAMES) {
6966
7041
  if (reservedParameters[parameterName] === undefined) {
6967
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7042
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6968
7043
  Reserved parameter {${parameterName}} is not defined
6969
7044
 
6970
7045
  ${block(pipelineIdentification)}
@@ -6983,14 +7058,14 @@
6983
7058
  * @private internal utility of `createPipelineExecutor`
6984
7059
  */
6985
7060
  async function executeTask(options) {
6986
- const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
7061
+ const { currentTask, preparedPipeline, parametersToPass, tools, onProgress, logLlmCall, $executionReport, pipelineIdentification, maxExecutionAttempts, maxParallelCount, csvSettings, isVerbose, rootDirname, cacheDirname, intermediateFilesStrategy, isAutoInstalled, isNotPreparedWarningSuppressed, } = options;
6987
7062
  const priority = preparedPipeline.tasks.length - preparedPipeline.tasks.indexOf(currentTask);
6988
7063
  // Note: Check consistency of used and dependent parameters which was also done in `validatePipeline`, but it’s good to doublecheck
6989
7064
  const usedParameterNames = extractParameterNamesFromTask(currentTask);
6990
7065
  const dependentParameterNames = new Set(currentTask.dependentParameterNames);
6991
7066
  // TODO: [👩🏾‍🤝‍👩🏻] Use here `mapAvailableToExpectedParameters`
6992
7067
  if (difference(union(difference(usedParameterNames, dependentParameterNames), difference(dependentParameterNames, usedParameterNames)), new Set(RESERVED_PARAMETER_NAMES)).size !== 0) {
6993
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7068
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
6994
7069
  Dependent parameters are not consistent with used parameters:
6995
7070
 
6996
7071
  Dependent parameters:
@@ -7034,7 +7109,7 @@
7034
7109
  else if (!definedParameterNames.has(parameterName) && usedParameterNames.has(parameterName)) {
7035
7110
  // Houston, we have a problem
7036
7111
  // Note: Checking part is also done in `validatePipeline`, but it’s good to doublecheck
7037
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7112
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7038
7113
  Parameter \`{${parameterName}}\` is NOT defined
7039
7114
  BUT used in task "${currentTask.title || currentTask.name}"
7040
7115
 
@@ -7062,6 +7137,7 @@
7062
7137
  tools,
7063
7138
  $executionReport,
7064
7139
  onProgress,
7140
+ logLlmCall,
7065
7141
  pipelineIdentification,
7066
7142
  maxExecutionAttempts,
7067
7143
  maxParallelCount,
@@ -7102,9 +7178,32 @@
7102
7178
  for (const parameter of preparedPipeline.parameters.filter(({ isOutput }) => isOutput)) {
7103
7179
  if (parametersToPass[parameter.name] === undefined) {
7104
7180
  // [4]
7105
- $warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7181
+ $warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7106
7182
  Parameter \`{${parameter.name}}\` should be an output parameter, but it was not generated during pipeline execution
7107
7183
 
7184
+ Note: This is a warning which happened after the pipeline was executed, and \`{${parameter.name}}\` was not for some reason defined in output parameters
7185
+
7186
+ All parameters:
7187
+ ${block(preparedPipeline.parameters
7188
+ .map(({ name, isInput, isOutput, description }) => {
7189
+ let line = `\`{${name}}\``;
7190
+ if (isInput) {
7191
+ line += ' `[input parameter]`';
7192
+ }
7193
+ if (isOutput) {
7194
+ line += ' `[output parameter]`';
7195
+ }
7196
+ if (parametersToPass[name] === undefined) {
7197
+ line += ` <- Warning: Should be in the output but its not |`;
7198
+ }
7199
+ if (description) {
7200
+ line += ` ${description}`;
7201
+ }
7202
+ return line;
7203
+ })
7204
+ .map((line, index) => `${index + 1}) ${line}`)
7205
+ .join('\n'))}
7206
+
7108
7207
  ${block(pipelineIdentification)}
7109
7208
  `)));
7110
7209
  continue;
@@ -7125,7 +7224,7 @@
7125
7224
  * @private internal utility of `createPipelineExecutor`
7126
7225
  */
7127
7226
  async function executePipeline(options) {
7128
- const { inputParameters, tools, onProgress, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
7227
+ const { inputParameters, tools, onProgress, logLlmCall, pipeline, setPreparedPipeline, pipelineIdentification, maxParallelCount, rootDirname, isVerbose, } = options;
7129
7228
  let { preparedPipeline } = options;
7130
7229
  if (preparedPipeline === undefined) {
7131
7230
  preparedPipeline = await preparePipeline(pipeline, tools, {
@@ -7187,7 +7286,7 @@
7187
7286
  for (const parameterName of Object.keys(inputParameters)) {
7188
7287
  const parameter = preparedPipeline.parameters.find(({ name }) => name === parameterName);
7189
7288
  if (parameter === undefined) {
7190
- warnings.push(new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7289
+ warnings.push(new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7191
7290
  Extra parameter {${parameterName}} is being passed which is not part of the pipeline.
7192
7291
 
7193
7292
  ${block(pipelineIdentification)}
@@ -7202,7 +7301,7 @@
7202
7301
  // TODO: [🧠] This should be also non-critical error
7203
7302
  return exportJson({
7204
7303
  name: 'pipelineExecutorResult',
7205
- message: spaceTrim.spaceTrim((block) => `
7304
+ message: spaceTrim$1.spaceTrim((block) => `
7206
7305
  Unsuccessful PipelineExecutorResult (with extra parameter {${parameter.name}}) PipelineExecutorResult
7207
7306
 
7208
7307
  ${block(pipelineIdentification)}
@@ -7211,7 +7310,7 @@
7211
7310
  value: {
7212
7311
  isSuccessful: false,
7213
7312
  errors: [
7214
- new PipelineExecutionError(spaceTrim.spaceTrim((block) => `
7313
+ new PipelineExecutionError(spaceTrim$1.spaceTrim((block) => `
7215
7314
  Parameter \`{${parameter.name}}\` is passed as input parameter but it is not input
7216
7315
 
7217
7316
  ${block(pipelineIdentification)}
@@ -7238,7 +7337,7 @@
7238
7337
  while (unresovedTasks.length > 0) {
7239
7338
  if (loopLimit-- < 0) {
7240
7339
  // Note: Really UnexpectedError not LimitReachedError - this should be catched during validatePipeline
7241
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7340
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7242
7341
  Loop limit reached during resolving parameters pipeline execution
7243
7342
 
7244
7343
  ${block(pipelineIdentification)}
@@ -7248,7 +7347,7 @@
7248
7347
  if (!currentTask && resolving.length === 0) {
7249
7348
  throw new UnexpectedError(
7250
7349
  // TODO: [🐎] DRY
7251
- spaceTrim.spaceTrim((block) => `
7350
+ spaceTrim$1.spaceTrim((block) => `
7252
7351
  Can not resolve some parameters:
7253
7352
 
7254
7353
  ${block(pipelineIdentification)}
@@ -7288,7 +7387,7 @@
7288
7387
  tools,
7289
7388
  onProgress(newOngoingResult) {
7290
7389
  if (isReturned) {
7291
- throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
7390
+ throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
7292
7391
  Can not call \`onProgress\` after pipeline execution is finished
7293
7392
 
7294
7393
  ${block(pipelineIdentification)}
@@ -7303,8 +7402,9 @@
7303
7402
  onProgress(newOngoingResult);
7304
7403
  }
7305
7404
  },
7405
+ logLlmCall,
7306
7406
  $executionReport: executionReport,
7307
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7407
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7308
7408
  ${block(pipelineIdentification)}
7309
7409
  Task name: ${currentTask.name}
7310
7410
  Task title: ${currentTask.title}
@@ -7413,7 +7513,7 @@
7413
7513
  preparedPipeline = pipeline;
7414
7514
  }
7415
7515
  else if (isNotPreparedWarningSuppressed !== true) {
7416
- console.warn(spaceTrim.spaceTrim((block) => `
7516
+ console.warn(spaceTrim$1.spaceTrim((block) => `
7417
7517
  Pipeline is not prepared
7418
7518
 
7419
7519
  ${block(pipelineIdentification)}
@@ -7426,7 +7526,7 @@
7426
7526
  // <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
7427
7527
  }
7428
7528
  let runCount = 0;
7429
- const pipelineExecutorWithCallback = async (inputParameters, onProgress) => {
7529
+ const pipelineExecutorWithCallback = async (inputParameters, onProgress, logLlmCall) => {
7430
7530
  runCount++;
7431
7531
  return /* not await */ executePipeline({
7432
7532
  pipeline,
@@ -7437,7 +7537,8 @@
7437
7537
  inputParameters,
7438
7538
  tools,
7439
7539
  onProgress,
7440
- pipelineIdentification: spaceTrim.spaceTrim((block) => `
7540
+ logLlmCall,
7541
+ pipelineIdentification: spaceTrim$1.spaceTrim((block) => `
7441
7542
  ${block(pipelineIdentification)}
7442
7543
  ${runCount === 1 ? '' : `Run #${runCount}`}
7443
7544
  `),
@@ -7640,10 +7741,10 @@
7640
7741
  var _a, _b;
7641
7742
  const isMetadataAviailable = $llmToolsMetadataRegister
7642
7743
  .list()
7643
- .find(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7744
+ .some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7644
7745
  const isInstalled = $llmToolsRegister
7645
7746
  .list()
7646
- .find(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7747
+ .some(({ packageName, className }) => metadata.packageName === packageName && metadata.className === className);
7647
7748
  const isFullyConfigured = ((_a = metadata.envVariables) === null || _a === void 0 ? void 0 : _a.every((envVariableName) => env[envVariableName] !== undefined)) || false;
7648
7749
  const isPartiallyConfigured = ((_b = metadata.envVariables) === null || _b === void 0 ? void 0 : _b.some((envVariableName) => env[envVariableName] !== undefined)) || false;
7649
7750
  // <- Note: [🗨]
@@ -7820,6 +7921,8 @@
7820
7921
  /**
7821
7922
  * Normalizes a given text to camelCase format.
7822
7923
  *
7924
+ * Note: [🔂] This function is idempotent.
7925
+ *
7823
7926
  * @param text The text to be normalized.
7824
7927
  * @param _isFirstLetterCapital Whether the first letter should be capitalized.
7825
7928
  * @returns The camelCase formatted string.
@@ -7946,6 +8049,9 @@
7946
8049
  }
7947
8050
 
7948
8051
  /**
8052
+ * Normalizes a given text to PascalCase format.
8053
+ *
8054
+ * Note: [🔂] This function is idempotent.
7949
8055
  *
7950
8056
  * @param text @public exported from `@promptbook/utils`
7951
8057
  * @returns
@@ -8010,7 +8116,7 @@
8010
8116
  let trimmedText = text;
8011
8117
  // Remove leading and trailing spaces and newlines
8012
8118
  if (isTrimmed) {
8013
- trimmedText = spaceTrim.spaceTrim(trimmedText);
8119
+ trimmedText = spaceTrim$1.spaceTrim(trimmedText);
8014
8120
  }
8015
8121
  let processedText = trimmedText;
8016
8122
  if (isIntroduceSentenceRemoved) {
@@ -8019,7 +8125,7 @@
8019
8125
  // Remove the introduce sentence and quotes by replacing it with an empty string
8020
8126
  processedText = processedText.replace(introduceSentenceRegex, '');
8021
8127
  }
8022
- processedText = spaceTrim.spaceTrim(processedText);
8128
+ processedText = spaceTrim$1.spaceTrim(processedText);
8023
8129
  }
8024
8130
  if (processedText.length < 3) {
8025
8131
  return trimmedText;
@@ -8123,13 +8229,13 @@
8123
8229
  * @public exported from `@promptbook/markdown-utils`
8124
8230
  */
8125
8231
  function trimCodeBlock(value) {
8126
- value = spaceTrim.spaceTrim(value);
8232
+ value = spaceTrim$1.spaceTrim(value);
8127
8233
  if (!/^```[a-z]*(.*)```$/is.test(value)) {
8128
8234
  return value;
8129
8235
  }
8130
8236
  value = value.replace(/^```[a-z]*/i, '');
8131
8237
  value = value.replace(/```$/i, '');
8132
- value = spaceTrim.spaceTrim(value);
8238
+ value = spaceTrim$1.spaceTrim(value);
8133
8239
  return value;
8134
8240
  }
8135
8241
 
@@ -8142,9 +8248,9 @@
8142
8248
  * @public exported from `@promptbook/markdown-utils`
8143
8249
  */
8144
8250
  function trimEndOfCodeBlock(value) {
8145
- value = spaceTrim.spaceTrim(value);
8251
+ value = spaceTrim$1.spaceTrim(value);
8146
8252
  value = value.replace(/```$/g, '');
8147
- value = spaceTrim.spaceTrim(value);
8253
+ value = spaceTrim$1.spaceTrim(value);
8148
8254
  return value;
8149
8255
  }
8150
8256
 
@@ -9009,7 +9115,10 @@
9009
9115
  }), h(KeyVal, {
9010
9116
  label: 'Application mode:',
9011
9117
  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'))));
9118
+ }), 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', {
9119
+ href: 'https://www.npmjs.com/package/@promptbook/remote-client',
9120
+ className: 'text-blue-600 underline',
9121
+ }, '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
9122
  }
9014
9123
  function HtmlDoc({ info }) {
9015
9124
  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 +9135,7 @@
9026
9135
  return '<!DOCTYPE html>' + server.renderToStaticMarkup(h(HtmlDoc, { info }));
9027
9136
  }
9028
9137
 
9138
+ // TODO: !!! Deprecate
9029
9139
  /**
9030
9140
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
9031
9141
  *
@@ -9204,7 +9314,7 @@
9204
9314
  response.type('text/html').send(renderServerIndexHtml(serverInfo));
9205
9315
  }
9206
9316
  else {
9207
- response.type('text/markdown').send(await spaceTrim.spaceTrim(async (block) => `
9317
+ response.type('text/markdown').send(await spaceTrim$1.spaceTrim(async (block) => `
9208
9318
  # Promptbook
9209
9319
 
9210
9320
  > ${block(CLAIM)}
@@ -9332,10 +9442,10 @@
9332
9442
  .send({ error: serializeError(error) });
9333
9443
  }
9334
9444
  });
9335
- function exportExecutionTask(executionTask, isFull) {
9445
+ function exportExecutionTask(executionTask, isDetailed) {
9336
9446
  // <- 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) {
9447
+ const { taskType, promptbookVersion, taskId, title, status, errors, tldr, warnings, createdAt, updatedAt, currentValue, llmCalls, } = executionTask;
9448
+ if (isDetailed) {
9339
9449
  return {
9340
9450
  taskId,
9341
9451
  title,
@@ -9345,9 +9455,11 @@
9345
9455
  tldr,
9346
9456
  errors: errors.map(serializeError),
9347
9457
  warnings: warnings.map(serializeError),
9458
+ llmCalls,
9348
9459
  createdAt,
9349
9460
  updatedAt,
9350
9461
  currentValue,
9462
+ ptbkNonce: 0,
9351
9463
  };
9352
9464
  }
9353
9465
  else {
@@ -9360,6 +9472,8 @@
9360
9472
  tldr,
9361
9473
  createdAt,
9362
9474
  updatedAt,
9475
+ llmCalls,
9476
+ ptbkNonce: 0,
9363
9477
  };
9364
9478
  }
9365
9479
  }
@@ -9587,21 +9701,25 @@
9587
9701
  };
9588
9702
  }
9589
9703
  /**
9704
+
9705
+ * TODO: [🕋] Use here `aboutPromptbookInformation`
9590
9706
  * TODO: [🌡] Add CORS and security - probably via `helmet`
9591
9707
  * TODO: Split this file into multiple functions - handler for each request
9592
9708
  * TODO: Maybe use `$exportJson`
9593
9709
  * TODO: [🧠][🛍] Maybe not `isAnonymous: boolean` BUT `mode: 'ANONYMOUS'|'COLLECTION'`
9594
- * TODO: [⚖] Expose the collection to be able to connect to same collection via createCollectionFromUrl
9710
+ * TODO: [⚖] Expose the collection to be able to connect to same collection via createPipelineCollectionFromUrl
9595
9711
  * TODO: Handle progress - support streaming
9596
9712
  * TODO: [🗯] Do not hang up immediately but wait until client closes OR timeout
9597
9713
  * TODO: [🗯] Timeout on chat to free up resources
9598
9714
  * TODO: [🃏] Pass here some security token to prevent malitious usage and/or DDoS
9599
9715
  * TODO: [0] Set unavailable models as undefined in `RemoteLlmExecutionTools` NOT throw error here
9600
9716
  * TODO: Allow to constrain anonymous mode for specific models / providers
9717
+ * Note: [🟢] Code in this file should never be never released in packages that could be imported into browser environment
9601
9718
  */
9602
9719
 
9603
9720
  exports.BOOK_LANGUAGE_VERSION = BOOK_LANGUAGE_VERSION;
9604
9721
  exports.PROMPTBOOK_ENGINE_VERSION = PROMPTBOOK_ENGINE_VERSION;
9722
+ exports.startAgentServer = startAgentServer;
9605
9723
  exports.startRemoteServer = startRemoteServer;
9606
9724
 
9607
9725
  Object.defineProperty(exports, '__esModule', { value: true });