@promptbook/website-crawler 0.113.0-1 → 0.113.0-10

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 (244) hide show
  1. package/README.md +1 -17
  2. package/esm/index.es.js +459 -453
  3. package/esm/index.es.js.map +1 -1
  4. package/esm/src/_packages/types.index.d.ts +2 -2
  5. package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +98 -0
  6. package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
  7. package/esm/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
  8. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
  9. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
  10. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
  11. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
  12. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
  13. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
  14. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
  15. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
  16. package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
  17. package/esm/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
  18. package/esm/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
  19. package/esm/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
  20. package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
  21. package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
  22. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
  23. package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +1 -1
  24. package/esm/src/book-components/Chat/Chat/CitationIframePreview.test.d.ts +2 -0
  25. package/esm/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
  26. package/esm/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
  27. package/esm/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
  28. package/esm/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
  29. package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
  30. package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
  31. package/esm/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
  32. package/esm/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
  33. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
  34. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
  35. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
  36. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
  37. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
  38. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
  39. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
  40. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
  41. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
  42. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
  43. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
  44. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
  45. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
  46. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
  47. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
  48. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
  49. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
  50. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
  51. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
  52. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
  53. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
  54. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
  55. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
  56. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
  57. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
  58. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
  59. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
  60. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
  61. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
  62. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
  63. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
  64. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
  65. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
  66. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
  67. package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
  68. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
  69. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
  70. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
  71. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
  72. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
  73. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
  74. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
  75. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
  76. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
  77. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
  78. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
  79. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
  80. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
  81. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
  82. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
  83. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
  84. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
  85. package/esm/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
  86. package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
  87. package/esm/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
  88. package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
  89. package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
  90. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
  91. package/esm/src/commitments/META/META.d.ts +2 -2
  92. package/esm/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
  93. package/esm/src/commitments/index.d.ts +1 -1
  94. package/esm/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
  95. package/esm/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
  96. package/esm/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
  97. package/esm/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
  98. package/esm/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
  99. package/esm/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
  100. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
  101. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
  102. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
  103. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
  104. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
  105. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
  106. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
  107. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  108. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
  109. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
  110. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
  111. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
  112. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
  113. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
  114. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
  115. package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  116. package/esm/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  117. package/esm/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
  118. package/esm/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  119. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  120. package/esm/src/utils/color/Color.d.ts +1 -1
  121. package/esm/src/version.d.ts +1 -1
  122. package/package.json +2 -2
  123. package/umd/index.umd.js +459 -453
  124. package/umd/index.umd.js.map +1 -1
  125. package/umd/src/_packages/types.index.d.ts +2 -2
  126. package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +98 -0
  127. package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
  128. package/umd/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
  129. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
  130. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
  131. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
  132. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
  133. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
  134. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
  135. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
  136. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
  137. package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
  138. package/umd/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
  139. package/umd/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
  140. package/umd/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
  141. package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
  142. package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
  143. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
  144. package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +1 -1
  145. package/umd/src/book-components/Chat/Chat/CitationIframePreview.test.d.ts +2 -0
  146. package/umd/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
  147. package/umd/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
  148. package/umd/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
  149. package/umd/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
  150. package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
  151. package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
  152. package/umd/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
  153. package/umd/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
  154. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
  155. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
  156. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
  157. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
  158. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
  159. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
  160. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
  161. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
  162. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
  163. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
  164. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
  165. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
  166. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
  167. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
  168. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
  169. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
  170. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
  171. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
  172. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
  173. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
  174. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
  175. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
  176. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
  177. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
  178. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
  179. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
  180. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
  181. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
  182. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
  183. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
  184. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
  185. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
  186. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
  187. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
  188. package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
  189. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
  190. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
  191. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
  192. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
  193. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
  194. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
  195. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
  196. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
  197. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
  198. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
  199. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
  200. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
  201. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
  202. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
  203. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
  204. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
  205. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
  206. package/umd/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
  207. package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
  208. package/umd/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
  209. package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
  210. package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
  211. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
  212. package/umd/src/commitments/META/META.d.ts +2 -2
  213. package/umd/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
  214. package/umd/src/commitments/index.d.ts +1 -1
  215. package/umd/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
  216. package/umd/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
  217. package/umd/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
  218. package/umd/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
  219. package/umd/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
  220. package/umd/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
  221. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
  222. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
  223. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
  224. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
  225. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
  226. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
  227. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
  228. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  229. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
  230. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
  231. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
  232. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
  233. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
  234. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
  235. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
  236. package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
  237. package/umd/src/utils/agent-message-runtime/agentMessageRuntimePaths.d.ts +24 -0
  238. package/umd/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
  239. package/umd/src/utils/ascii-art/$detectTerminalAnsiColorDepth.d.ts +15 -0
  240. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +80 -0
  241. package/umd/src/utils/color/Color.d.ts +1 -1
  242. package/umd/src/version.d.ts +1 -1
  243. package/esm/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +0 -12
  244. package/umd/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +0 -12
package/esm/index.es.js CHANGED
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-1';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-10';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -133,6 +133,127 @@ function take(initialValue) {
133
133
  });
134
134
  }
135
135
 
136
+ /**
137
+ * Validates that a channel value is a valid number within the range of 0 to 255.
138
+ * Throws an error if the value is not valid.
139
+ *
140
+ * @param channelName - The name of the channel being validated.
141
+ * @param value - The value of the channel to validate.
142
+ * @throws Will throw an error if the value is not a valid channel number.
143
+ *
144
+ * @private util of `@promptbook/color`
145
+ */
146
+ function checkChannelValue(channelName, value) {
147
+ if (typeof value !== 'number') {
148
+ throw new Error(`${channelName} channel value is not number but ${typeof value}`);
149
+ }
150
+ if (isNaN(value)) {
151
+ throw new Error(`${channelName} channel value is NaN`);
152
+ }
153
+ if (Math.round(value) !== value) {
154
+ throw new Error(`${channelName} channel is not whole number, it is ${value}`);
155
+ }
156
+ if (value < 0) {
157
+ throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
158
+ }
159
+ if (value > 255) {
160
+ throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Shared immutable channel storage and serialization helpers for `Color`.
166
+ *
167
+ * @private base class of Color
168
+ */
169
+ class ColorValue {
170
+ constructor(red, green, blue, alpha = 255) {
171
+ this.red = red;
172
+ this.green = green;
173
+ this.blue = blue;
174
+ this.alpha = alpha;
175
+ checkChannelValue('Red', red);
176
+ checkChannelValue('Green', green);
177
+ checkChannelValue('Blue', blue);
178
+ checkChannelValue('Alpha', alpha);
179
+ }
180
+ /**
181
+ * Shortcut for `red` property
182
+ * Number from 0 to 255
183
+ * @alias red
184
+ */
185
+ get r() {
186
+ return this.red;
187
+ }
188
+ /**
189
+ * Shortcut for `green` property
190
+ * Number from 0 to 255
191
+ * @alias green
192
+ */
193
+ get g() {
194
+ return this.green;
195
+ }
196
+ /**
197
+ * Shortcut for `blue` property
198
+ * Number from 0 to 255
199
+ * @alias blue
200
+ */
201
+ get b() {
202
+ return this.blue;
203
+ }
204
+ /**
205
+ * Shortcut for `alpha` property
206
+ * Number from 0 (transparent) to 255 (opaque)
207
+ * @alias alpha
208
+ */
209
+ get a() {
210
+ return this.alpha;
211
+ }
212
+ /**
213
+ * Shortcut for `alpha` property
214
+ * Number from 0 (transparent) to 255 (opaque)
215
+ * @alias alpha
216
+ */
217
+ get opacity() {
218
+ return this.alpha;
219
+ }
220
+ /**
221
+ * Shortcut for 1-`alpha` property
222
+ */
223
+ get transparency() {
224
+ return 255 - this.alpha;
225
+ }
226
+ clone() {
227
+ return take(this.createColor(this.red, this.green, this.blue, this.alpha));
228
+ }
229
+ toString() {
230
+ return this.toHex();
231
+ }
232
+ toHex() {
233
+ if (this.alpha === 255) {
234
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
235
+ .toString(16)
236
+ .padStart(2, '0')}`;
237
+ }
238
+ else {
239
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
240
+ .toString(16)
241
+ .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
242
+ }
243
+ }
244
+ toRgb() {
245
+ if (this.alpha === 255) {
246
+ return `rgb(${this.red}, ${this.green}, ${this.blue})`;
247
+ }
248
+ else {
249
+ return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
250
+ }
251
+ }
252
+ toHsl() {
253
+ throw new Error(`Getting HSL is not implemented`);
254
+ }
255
+ }
256
+
136
257
  /**
137
258
  * 🎨 List of all 140 color names which are supported by CSS
138
259
  *
@@ -292,127 +413,6 @@ const CSS_COLORS = {
292
413
  };
293
414
  // Note: [💞] Ignore a discrepancy between file name and entity name
294
415
 
295
- /**
296
- * Validates that a channel value is a valid number within the range of 0 to 255.
297
- * Throws an error if the value is not valid.
298
- *
299
- * @param channelName - The name of the channel being validated.
300
- * @param value - The value of the channel to validate.
301
- * @throws Will throw an error if the value is not a valid channel number.
302
- *
303
- * @private util of `@promptbook/color`
304
- */
305
- function checkChannelValue(channelName, value) {
306
- if (typeof value !== 'number') {
307
- throw new Error(`${channelName} channel value is not number but ${typeof value}`);
308
- }
309
- if (isNaN(value)) {
310
- throw new Error(`${channelName} channel value is NaN`);
311
- }
312
- if (Math.round(value) !== value) {
313
- throw new Error(`${channelName} channel is not whole number, it is ${value}`);
314
- }
315
- if (value < 0) {
316
- throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
317
- }
318
- if (value > 255) {
319
- throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
320
- }
321
- }
322
-
323
- /**
324
- * Shared immutable channel storage and serialization helpers for `Color`.
325
- *
326
- * @private base class of Color
327
- */
328
- class ColorValue {
329
- constructor(red, green, blue, alpha = 255) {
330
- this.red = red;
331
- this.green = green;
332
- this.blue = blue;
333
- this.alpha = alpha;
334
- checkChannelValue('Red', red);
335
- checkChannelValue('Green', green);
336
- checkChannelValue('Blue', blue);
337
- checkChannelValue('Alpha', alpha);
338
- }
339
- /**
340
- * Shortcut for `red` property
341
- * Number from 0 to 255
342
- * @alias red
343
- */
344
- get r() {
345
- return this.red;
346
- }
347
- /**
348
- * Shortcut for `green` property
349
- * Number from 0 to 255
350
- * @alias green
351
- */
352
- get g() {
353
- return this.green;
354
- }
355
- /**
356
- * Shortcut for `blue` property
357
- * Number from 0 to 255
358
- * @alias blue
359
- */
360
- get b() {
361
- return this.blue;
362
- }
363
- /**
364
- * Shortcut for `alpha` property
365
- * Number from 0 (transparent) to 255 (opaque)
366
- * @alias alpha
367
- */
368
- get a() {
369
- return this.alpha;
370
- }
371
- /**
372
- * Shortcut for `alpha` property
373
- * Number from 0 (transparent) to 255 (opaque)
374
- * @alias alpha
375
- */
376
- get opacity() {
377
- return this.alpha;
378
- }
379
- /**
380
- * Shortcut for 1-`alpha` property
381
- */
382
- get transparency() {
383
- return 255 - this.alpha;
384
- }
385
- clone() {
386
- return take(this.createColor(this.red, this.green, this.blue, this.alpha));
387
- }
388
- toString() {
389
- return this.toHex();
390
- }
391
- toHex() {
392
- if (this.alpha === 255) {
393
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
394
- .toString(16)
395
- .padStart(2, '0')}`;
396
- }
397
- else {
398
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
399
- .toString(16)
400
- .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
401
- }
402
- }
403
- toRgb() {
404
- if (this.alpha === 255) {
405
- return `rgb(${this.red}, ${this.green}, ${this.blue})`;
406
- }
407
- else {
408
- return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
409
- }
410
- }
411
- toHsl() {
412
- throw new Error(`Getting HSL is not implemented`);
413
- }
414
- }
415
-
416
416
  /**
417
417
  * Checks if the given value is a valid hex color string
418
418
  *
@@ -2110,20 +2110,109 @@ function pipelineJsonToString(pipelineJson) {
2110
2110
  // TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
2111
2111
 
2112
2112
  /**
2113
- * Orders JSON object by keys
2114
- *
2115
- * @returns The same type of object as the input re-ordered
2113
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2116
2114
  *
2117
- * @public exported from `@promptbook/utils`
2115
+ * @public exported from `@promptbook/core`
2118
2116
  */
2119
- function orderJson(options) {
2120
- const { value, order } = options;
2121
- const orderedValue = {
2122
- ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2123
- ...value,
2124
- };
2125
- return orderedValue;
2126
- }
2117
+ class PipelineLogicError extends Error {
2118
+ constructor(message) {
2119
+ super(message);
2120
+ this.name = 'PipelineLogicError';
2121
+ Object.setPrototypeOf(this, PipelineLogicError.prototype);
2122
+ }
2123
+ }
2124
+
2125
+ /**
2126
+ * Creates the shared validation context for one pipeline.
2127
+ *
2128
+ * @private function of `validatePipeline`
2129
+ */
2130
+ function createPipelineValidationContext(pipeline) {
2131
+ return {
2132
+ pipeline,
2133
+ pipelineIdentification: getPipelineIdentification(pipeline),
2134
+ };
2135
+ }
2136
+ /**
2137
+ * Builds a short file/url identification block for validation errors.
2138
+ *
2139
+ * @private internal utility of `validatePipeline`
2140
+ */
2141
+ function getPipelineIdentification(pipeline) {
2142
+ // Note: This is a 😐 implementation of [🚞]
2143
+ const pipelineIdentificationParts = [];
2144
+ if (pipeline.sourceFile !== undefined) {
2145
+ pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2146
+ }
2147
+ if (pipeline.pipelineUrl !== undefined) {
2148
+ pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2149
+ }
2150
+ return pipelineIdentificationParts.join('\n');
2151
+ }
2152
+
2153
+ /**
2154
+ * Validates that the expected top-level collections have array structure.
2155
+ *
2156
+ * @private function of `validatePipeline`
2157
+ */
2158
+ function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification, }) {
2159
+ validatePipelineParametersCollection(pipeline, pipelineIdentification);
2160
+ validatePipelineTasksCollection(pipeline, pipelineIdentification);
2161
+ }
2162
+ /**
2163
+ * Validates that `pipeline.parameters` is an array.
2164
+ *
2165
+ * @private internal utility of `validatePipelineCollectionsStructure`
2166
+ */
2167
+ function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
2168
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2169
+ if (Array.isArray(pipeline.parameters)) {
2170
+ return;
2171
+ }
2172
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2173
+ throw new ParseError(spaceTrim$1((block) => `
2174
+ Pipeline is valid JSON but with wrong structure
2175
+
2176
+ \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
2177
+
2178
+ ${block(pipelineIdentification)}
2179
+ `));
2180
+ }
2181
+ /**
2182
+ * Validates that `pipeline.tasks` is an array.
2183
+ *
2184
+ * @private internal utility of `validatePipelineCollectionsStructure`
2185
+ */
2186
+ function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
2187
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2188
+ if (Array.isArray(pipeline.tasks)) {
2189
+ return;
2190
+ }
2191
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2192
+ throw new ParseError(spaceTrim$1((block) => `
2193
+ Pipeline is valid JSON but with wrong structure
2194
+
2195
+ \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
2196
+
2197
+ ${block(pipelineIdentification)}
2198
+ `));
2199
+ }
2200
+
2201
+ /**
2202
+ * Orders JSON object by keys
2203
+ *
2204
+ * @returns The same type of object as the input re-ordered
2205
+ *
2206
+ * @public exported from `@promptbook/utils`
2207
+ */
2208
+ function orderJson(options) {
2209
+ const { value, order } = options;
2210
+ const orderedValue = {
2211
+ ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2212
+ ...value,
2213
+ };
2214
+ return orderedValue;
2215
+ }
2127
2216
 
2128
2217
  /**
2129
2218
  * Checks if the value is [🚉] serializable as JSON
@@ -2446,16 +2535,137 @@ const RESERVED_PARAMETER_NAMES = exportJson({
2446
2535
  // Note: [💞] Ignore a discrepancy between file name and entity name
2447
2536
 
2448
2537
  /**
2449
- * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2538
+ * Validates that task dependencies can be resolved without cycles or missing definitions.
2450
2539
  *
2451
- * @public exported from `@promptbook/core`
2540
+ * @private function of `validatePipeline`
2452
2541
  */
2453
- class PipelineLogicError extends Error {
2454
- constructor(message) {
2455
- super(message);
2456
- this.name = 'PipelineLogicError';
2457
- Object.setPrototypeOf(this, PipelineLogicError.prototype);
2542
+ function validatePipelineDependencyResolution({ pipeline, pipelineIdentification, }) {
2543
+ let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2544
+ let loopLimit = LOOP_LIMIT;
2545
+ while (hasUnresolvedTasks(dependencyResolutionState)) {
2546
+ if (loopLimit-- < 0) {
2547
+ throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2548
+ }
2549
+ dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2550
+ }
2551
+ }
2552
+ /**
2553
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2554
+ *
2555
+ * @private internal utility of `validatePipelineDependencyResolution`
2556
+ */
2557
+ function createInitialDependencyResolutionState(pipeline) {
2558
+ return {
2559
+ resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
2560
+ unresolvedTasks: [...pipeline.tasks],
2561
+ };
2562
+ }
2563
+ /**
2564
+ * Checks whether dependency resolution still has tasks left to process.
2565
+ *
2566
+ * @private internal utility of `validatePipelineDependencyResolution`
2567
+ */
2568
+ function hasUnresolvedTasks({ unresolvedTasks }) {
2569
+ return unresolvedTasks.length > 0;
2570
+ }
2571
+ /**
2572
+ * Resolves the next batch of currently satisfiable tasks.
2573
+ *
2574
+ * @private internal utility of `validatePipelineDependencyResolution`
2575
+ */
2576
+ function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
2577
+ const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
2578
+ if (currentlyResolvedTasks.length === 0) {
2579
+ throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
2580
+ }
2581
+ return {
2582
+ resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
2583
+ unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
2584
+ };
2585
+ }
2586
+ /**
2587
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2588
+ *
2589
+ * @private internal utility of `validatePipelineDependencyResolution`
2590
+ */
2591
+ function createInitiallyResolvedParameterNames(pipeline) {
2592
+ let resolvedParameterNames = pipeline.parameters
2593
+ .filter(({ isInput }) => isInput)
2594
+ .map(({ name }) => name);
2595
+ for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
2596
+ resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
2458
2597
  }
2598
+ return resolvedParameterNames;
2599
+ }
2600
+ /**
2601
+ * Adds newly resolved task outputs to the resolved parameter list.
2602
+ *
2603
+ * @private internal utility of `validatePipelineDependencyResolution`
2604
+ */
2605
+ function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
2606
+ return [
2607
+ ...resolvedParameterNames,
2608
+ ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
2609
+ ];
2610
+ }
2611
+ /**
2612
+ * Selects tasks whose dependencies are already resolved.
2613
+ *
2614
+ * @private internal utility of `validatePipelineDependencyResolution`
2615
+ */
2616
+ function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
2617
+ return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
2618
+ }
2619
+ /**
2620
+ * Creates the unexpected loop-limit error for dependency resolution.
2621
+ *
2622
+ * @private internal utility of `validatePipelineDependencyResolution`
2623
+ */
2624
+ function createDependencyResolutionLoopLimitError(pipelineIdentification) {
2625
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2626
+ return new UnexpectedError(spaceTrim$1((block) => `
2627
+ Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2628
+
2629
+ ${block(pipelineIdentification)}
2630
+ `));
2631
+ }
2632
+ /**
2633
+ * Creates the detailed error for unresolved or circular task dependencies.
2634
+ *
2635
+ * @private internal utility of `validatePipelineDependencyResolution`
2636
+ */
2637
+ function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
2638
+ return new PipelineLogicError(
2639
+ // TODO: [🐎] DRY
2640
+ spaceTrim$1((block) => `
2641
+
2642
+ Can not resolve some parameters:
2643
+ Either you are using a parameter that is not defined, or there are some circular dependencies.
2644
+
2645
+ ${block(pipelineIdentification)}
2646
+
2647
+ **Can not resolve:**
2648
+ ${block(unresolvedTasks
2649
+ .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
2650
+ .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
2651
+ .join(' and ')}`)
2652
+ .join('\n'))}
2653
+
2654
+ **Resolved:**
2655
+ ${block(resolvedParameterNames
2656
+ .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
2657
+ .map((name) => `- Parameter \`{${name}}\``)
2658
+ .join('\n'))}
2659
+
2660
+
2661
+ **Reserved (which are available):**
2662
+ ${block(resolvedParameterNames
2663
+ .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
2664
+ .map((name) => `- Parameter \`{${name}}\``)
2665
+ .join('\n'))}
2666
+
2667
+
2668
+ `));
2459
2669
  }
2460
2670
 
2461
2671
  /**
@@ -2533,171 +2743,22 @@ function isValidPipelineUrl(url) {
2533
2743
  // TODO: [🐠] Maybe more info why the URL is invalid
2534
2744
 
2535
2745
  /**
2536
- * Validates PipelineJson if it is logically valid
2537
- *
2538
- * It checks:
2539
- * - if it has correct parameters dependency
2540
- *
2541
- * It does NOT check:
2542
- * - if it is valid json
2543
- * - if it is meaningful
2544
- *
2545
- * Note: [🔂] This function is idempotent.
2746
+ * Validates pipeline-level metadata fields.
2546
2747
  *
2547
- * @param pipeline valid or invalid PipelineJson
2548
- * @returns the same pipeline if it is logically valid
2549
- * @throws {PipelineLogicError} on logical error in the pipeline
2748
+ * @private function of `validatePipeline`
2749
+ */
2750
+ function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
2751
+ validatePipelineUrl(pipeline, pipelineIdentification);
2752
+ validatePipelineBookVersion(pipeline, pipelineIdentification);
2753
+ }
2754
+ /**
2755
+ * Validates the pipeline URL, when present.
2550
2756
  *
2551
- * @public exported from `@promptbook/core`
2757
+ * @private internal utility of `validatePipelineMetadata`
2552
2758
  */
2553
- function validatePipeline(pipeline) {
2554
- if (IS_PIPELINE_LOGIC_VALIDATED) {
2555
- validatePipeline_InnerFunction(pipeline);
2556
- }
2557
- else {
2558
- try {
2559
- validatePipeline_InnerFunction(pipeline);
2560
- }
2561
- catch (error) {
2562
- if (!(error instanceof PipelineLogicError)) {
2563
- throw error;
2564
- }
2565
- console.error(spaceTrim$1((block) => `
2566
- Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2567
-
2568
- ${block(error.message)}
2569
- `));
2570
- }
2571
- }
2572
- return pipeline;
2573
- }
2574
- /**
2575
- * Validates pipeline inner function.
2576
- *
2577
- * @private internal function for `validatePipeline`
2578
- */
2579
- function validatePipeline_InnerFunction(pipeline) {
2580
- // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
2581
- const context = createPipelineValidationContext(pipeline);
2582
- validatePipelineMetadata(context);
2583
- validatePipelineCollectionsStructure(context);
2584
- validatePipelineParameters(context);
2585
- validatePipelineTasks(context);
2586
- validatePipelineDependencyResolution(context);
2587
- // Note: Check that formfactor is corresponding to the pipeline interface
2588
- // TODO: !!6 Implement this
2589
- // pipeline.formfactorName
2590
- }
2591
- /**
2592
- * Creates the shared validation context for one pipeline.
2593
- *
2594
- * @private internal utility of `validatePipeline`
2595
- */
2596
- function createPipelineValidationContext(pipeline) {
2597
- return {
2598
- pipeline,
2599
- pipelineIdentification: getPipelineIdentification(pipeline),
2600
- };
2601
- }
2602
- /**
2603
- * Builds a short file/url identification block for validation errors.
2604
- *
2605
- * @private internal utility of `validatePipeline`
2606
- */
2607
- function getPipelineIdentification(pipeline) {
2608
- // Note: This is a 😐 implementation of [🚞]
2609
- const pipelineIdentificationParts = [];
2610
- if (pipeline.sourceFile !== undefined) {
2611
- pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2612
- }
2613
- if (pipeline.pipelineUrl !== undefined) {
2614
- pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2615
- }
2616
- return pipelineIdentificationParts.join('\n');
2617
- }
2618
- /**
2619
- * Validates pipeline-level metadata fields.
2620
- *
2621
- * @private internal step of `validatePipeline`
2622
- */
2623
- function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
2624
- validatePipelineUrl(pipeline, pipelineIdentification);
2625
- validatePipelineBookVersion(pipeline, pipelineIdentification);
2626
- }
2627
- /**
2628
- * Validates that the expected top-level collections have array structure.
2629
- *
2630
- * @private internal step of `validatePipeline`
2631
- */
2632
- function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification }) {
2633
- validatePipelineParametersCollection(pipeline, pipelineIdentification);
2634
- validatePipelineTasksCollection(pipeline, pipelineIdentification);
2635
- }
2636
- /**
2637
- * Validates all pipeline parameter declarations.
2638
- *
2639
- * @private internal step of `validatePipeline`
2640
- */
2641
- function validatePipelineParameters({ pipeline, pipelineIdentification }) {
2642
- for (const parameter of pipeline.parameters) {
2643
- validatePipelineParameter(parameter, pipeline, pipelineIdentification);
2644
- }
2645
- }
2646
- /**
2647
- * Validates all pipeline tasks and their per-task invariants.
2648
- *
2649
- * @private internal step of `validatePipeline`
2650
- */
2651
- function validatePipelineTasks({ pipeline, pipelineIdentification }) {
2652
- // Note: All input parameters are defined - so that they can be used as result of some task
2653
- const definedParameters = createInitiallyDefinedParameters(pipeline);
2654
- for (const task of pipeline.tasks) {
2655
- validatePipelineTask(task, definedParameters, pipelineIdentification);
2656
- }
2657
- }
2658
- /**
2659
- * Validates that task dependencies can be resolved without cycles or missing definitions.
2660
- *
2661
- * @private internal step of `validatePipeline`
2662
- */
2663
- function validatePipelineDependencyResolution({ pipeline, pipelineIdentification }) {
2664
- let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2665
- let loopLimit = LOOP_LIMIT;
2666
- while (hasUnresolvedTasks(dependencyResolutionState)) {
2667
- if (loopLimit-- < 0) {
2668
- throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2669
- }
2670
- dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2671
- }
2672
- }
2673
- /**
2674
- * Validates one pipeline parameter declaration.
2675
- *
2676
- * @private internal step of `validatePipeline`
2677
- */
2678
- function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
2679
- validateParameterDirection(parameter, pipelineIdentification);
2680
- validateParameterUsage(parameter, pipeline, pipelineIdentification);
2681
- validateParameterDefinition(parameter, pipeline, pipelineIdentification);
2682
- }
2683
- /**
2684
- * Validates one pipeline task and its invariants.
2685
- *
2686
- * @private internal step of `validatePipeline`
2687
- */
2688
- function validatePipelineTask(task, definedParameters, pipelineIdentification) {
2689
- validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
2690
- validateTaskJokers(task, pipelineIdentification);
2691
- validateTaskExpectations(task, pipelineIdentification);
2692
- }
2693
- /**
2694
- * Validates the pipeline URL, when present.
2695
- *
2696
- * @private internal utility of `validatePipeline`
2697
- */
2698
- function validatePipelineUrl(pipeline, pipelineIdentification) {
2699
- if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
2700
- return;
2759
+ function validatePipelineUrl(pipeline, pipelineIdentification) {
2760
+ if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
2761
+ return;
2701
2762
  }
2702
2763
  // <- Note: [🚲]
2703
2764
  throw new PipelineLogicError(spaceTrim$1((block) => `
@@ -2709,7 +2770,7 @@ function validatePipelineUrl(pipeline, pipelineIdentification) {
2709
2770
  /**
2710
2771
  * Validates the Promptbook version, when present.
2711
2772
  *
2712
- * @private internal utility of `validatePipeline`
2773
+ * @private internal utility of `validatePipelineMetadata`
2713
2774
  */
2714
2775
  function validatePipelineBookVersion(pipeline, pipelineIdentification) {
2715
2776
  if (pipeline.bookVersion === undefined || isValidPromptbookVersion(pipeline.bookVersion)) {
@@ -2722,48 +2783,31 @@ function validatePipelineBookVersion(pipeline, pipelineIdentification) {
2722
2783
  ${block(pipelineIdentification)}
2723
2784
  `));
2724
2785
  }
2786
+
2725
2787
  /**
2726
- * Validates that `pipeline.parameters` is an array.
2788
+ * Validates all pipeline parameter declarations.
2727
2789
  *
2728
- * @private internal utility of `validatePipeline`
2790
+ * @private function of `validatePipeline`
2729
2791
  */
2730
- function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
2731
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2732
- if (Array.isArray(pipeline.parameters)) {
2733
- return;
2792
+ function validatePipelineParameters({ pipeline, pipelineIdentification }) {
2793
+ for (const parameter of pipeline.parameters) {
2794
+ validatePipelineParameter(parameter, pipeline, pipelineIdentification);
2734
2795
  }
2735
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2736
- throw new ParseError(spaceTrim$1((block) => `
2737
- Pipeline is valid JSON but with wrong structure
2738
-
2739
- \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
2740
-
2741
- ${block(pipelineIdentification)}
2742
- `));
2743
2796
  }
2744
2797
  /**
2745
- * Validates that `pipeline.tasks` is an array.
2798
+ * Validates one pipeline parameter declaration.
2746
2799
  *
2747
- * @private internal utility of `validatePipeline`
2800
+ * @private internal utility of `validatePipelineParameters`
2748
2801
  */
2749
- function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
2750
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2751
- if (Array.isArray(pipeline.tasks)) {
2752
- return;
2753
- }
2754
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2755
- throw new ParseError(spaceTrim$1((block) => `
2756
- Pipeline is valid JSON but with wrong structure
2757
-
2758
- \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
2759
-
2760
- ${block(pipelineIdentification)}
2761
- `));
2802
+ function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
2803
+ validateParameterDirection(parameter, pipelineIdentification);
2804
+ validateParameterUsage(parameter, pipeline, pipelineIdentification);
2805
+ validateParameterDefinition(parameter, pipeline, pipelineIdentification);
2762
2806
  }
2763
2807
  /**
2764
2808
  * Validates that one parameter does not declare incompatible directions.
2765
2809
  *
2766
- * @private internal utility of `validatePipeline`
2810
+ * @private internal utility of `validatePipelineParameters`
2767
2811
  */
2768
2812
  function validateParameterDirection(parameter, pipelineIdentification) {
2769
2813
  if (!parameter.isInput || !parameter.isOutput) {
@@ -2780,7 +2824,7 @@ function validateParameterDirection(parameter, pipelineIdentification) {
2780
2824
  /**
2781
2825
  * Validates that one intermediate parameter is actually consumed by at least one task.
2782
2826
  *
2783
- * @private internal utility of `validatePipeline`
2827
+ * @private internal utility of `validatePipelineParameters`
2784
2828
  */
2785
2829
  function validateParameterUsage(parameter, pipeline, pipelineIdentification) {
2786
2830
  if (parameter.isInput || parameter.isOutput || isParameterUsedByAnyTask(parameter, pipeline.tasks)) {
@@ -2799,7 +2843,7 @@ function validateParameterUsage(parameter, pipeline, pipelineIdentification) {
2799
2843
  /**
2800
2844
  * Validates that one non-input parameter is produced by at least one task.
2801
2845
  *
2802
- * @private internal utility of `validatePipeline`
2846
+ * @private internal utility of `validatePipelineParameters`
2803
2847
  */
2804
2848
  function validateParameterDefinition(parameter, pipeline, pipelineIdentification) {
2805
2849
  if (parameter.isInput || isParameterDefinedByAnyTask(parameter, pipeline.tasks)) {
@@ -2818,7 +2862,7 @@ function validateParameterDefinition(parameter, pipeline, pipelineIdentification
2818
2862
  /**
2819
2863
  * Checks whether one parameter is consumed by at least one task dependency list.
2820
2864
  *
2821
- * @private internal utility of `validatePipeline`
2865
+ * @private internal utility of `validatePipelineParameters`
2822
2866
  */
2823
2867
  function isParameterUsedByAnyTask(parameter, tasks) {
2824
2868
  return tasks.some((task) => task.dependentParameterNames.includes(parameter.name));
@@ -2826,23 +2870,46 @@ function isParameterUsedByAnyTask(parameter, tasks) {
2826
2870
  /**
2827
2871
  * Checks whether one parameter is produced by at least one task.
2828
2872
  *
2829
- * @private internal utility of `validatePipeline`
2873
+ * @private internal utility of `validatePipelineParameters`
2830
2874
  */
2831
2875
  function isParameterDefinedByAnyTask(parameter, tasks) {
2832
2876
  return tasks.some((task) => task.resultingParameterName === parameter.name);
2833
2877
  }
2878
+
2879
+ /**
2880
+ * Validates all pipeline tasks and their per-task invariants.
2881
+ *
2882
+ * @private function of `validatePipeline`
2883
+ */
2884
+ function validatePipelineTasks({ pipeline, pipelineIdentification }) {
2885
+ // Note: All input parameters are defined - so that they can be used as result of some task
2886
+ const definedParameters = createInitiallyDefinedParameters(pipeline);
2887
+ for (const task of pipeline.tasks) {
2888
+ validatePipelineTask(task, definedParameters, pipelineIdentification);
2889
+ }
2890
+ }
2834
2891
  /**
2835
2892
  * Collects the parameter names that are already defined before task validation starts.
2836
2893
  *
2837
- * @private internal utility of `validatePipeline`
2894
+ * @private internal utility of `validatePipelineTasks`
2838
2895
  */
2839
2896
  function createInitiallyDefinedParameters(pipeline) {
2840
2897
  return new Set(pipeline.parameters.filter(({ isInput }) => isInput).map(({ name }) => name));
2841
2898
  }
2899
+ /**
2900
+ * Validates one pipeline task and its invariants.
2901
+ *
2902
+ * @private internal utility of `validatePipelineTasks`
2903
+ */
2904
+ function validatePipelineTask(task, definedParameters, pipelineIdentification) {
2905
+ validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
2906
+ validateTaskJokers(task, pipelineIdentification);
2907
+ validateTaskExpectations(task, pipelineIdentification);
2908
+ }
2842
2909
  /**
2843
2910
  * Validates one task result parameter declaration and marks it as defined.
2844
2911
  *
2845
- * @private internal utility of `validatePipeline`
2912
+ * @private internal utility of `validatePipelineTasks`
2846
2913
  */
2847
2914
  function validateTaskResultingParameter(task, definedParameters, pipelineIdentification) {
2848
2915
  if (definedParameters.has(task.resultingParameterName)) {
@@ -2864,7 +2931,7 @@ function validateTaskResultingParameter(task, definedParameters, pipelineIdentif
2864
2931
  /**
2865
2932
  * Validates joker parameters for one task.
2866
2933
  *
2867
- * @private internal utility of `validatePipeline`
2934
+ * @private internal utility of `validatePipelineTasks`
2868
2935
  */
2869
2936
  function validateTaskJokers(task, pipelineIdentification) {
2870
2937
  if (!hasTaskJokers(task)) {
@@ -2876,7 +2943,7 @@ function validateTaskJokers(task, pipelineIdentification) {
2876
2943
  /**
2877
2944
  * Checks whether one task declares any joker parameters.
2878
2945
  *
2879
- * @private internal utility of `validatePipeline`
2946
+ * @private internal utility of `validatePipelineTasks`
2880
2947
  */
2881
2948
  function hasTaskJokers(task) {
2882
2949
  return !!task.jokerParameterNames && task.jokerParameterNames.length > 0;
@@ -2884,7 +2951,7 @@ function hasTaskJokers(task) {
2884
2951
  /**
2885
2952
  * Validates that a task has the required supporting features when using jokers.
2886
2953
  *
2887
- * @private internal utility of `validatePipeline`
2954
+ * @private internal utility of `validatePipelineTasks`
2888
2955
  */
2889
2956
  function validateTaskSupportsJokers(task, pipelineIdentification) {
2890
2957
  if (task.format || task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
@@ -2899,7 +2966,7 @@ function validateTaskSupportsJokers(task, pipelineIdentification) {
2899
2966
  /**
2900
2967
  * Validates that every joker parameter is also listed among task dependencies.
2901
2968
  *
2902
- * @private internal utility of `validatePipeline`
2969
+ * @private internal utility of `validatePipelineTasks`
2903
2970
  */
2904
2971
  function validateTaskJokerDependencies(task, pipelineIdentification) {
2905
2972
  for (const joker of task.jokerParameterNames) {
@@ -2916,7 +2983,7 @@ function validateTaskJokerDependencies(task, pipelineIdentification) {
2916
2983
  /**
2917
2984
  * Validates all expectation bounds configured on one task.
2918
2985
  *
2919
- * @private internal utility of `validatePipeline`
2986
+ * @private internal utility of `validatePipelineTasks`
2920
2987
  */
2921
2988
  function validateTaskExpectations(task, pipelineIdentification) {
2922
2989
  if (!task.expectations) {
@@ -2931,7 +2998,7 @@ function validateTaskExpectations(task, pipelineIdentification) {
2931
2998
  /**
2932
2999
  * Validates the minimum and maximum expectation ordering for one unit.
2933
3000
  *
2934
- * @private internal utility of `validatePipeline`
3001
+ * @private internal utility of `validatePipelineTasks`
2935
3002
  */
2936
3003
  function validateTaskExpectationRange(unit, min, max, pipelineIdentification) {
2937
3004
  if (min === undefined || max === undefined || min <= max) {
@@ -2946,7 +3013,7 @@ function validateTaskExpectationRange(unit, min, max, pipelineIdentification) {
2946
3013
  /**
2947
3014
  * Validates the minimum expectation bound for one unit.
2948
3015
  *
2949
- * @private internal utility of `validatePipeline`
3016
+ * @private internal utility of `validatePipelineTasks`
2950
3017
  */
2951
3018
  function validateTaskExpectationMin(unit, min, pipelineIdentification) {
2952
3019
  if (min === undefined || min >= 0) {
@@ -2961,7 +3028,7 @@ function validateTaskExpectationMin(unit, min, pipelineIdentification) {
2961
3028
  /**
2962
3029
  * Validates the maximum expectation bound for one unit.
2963
3030
  *
2964
- * @private internal utility of `validatePipeline`
3031
+ * @private internal utility of `validatePipelineTasks`
2965
3032
  */
2966
3033
  function validateTaskExpectationMax(unit, max, pipelineIdentification) {
2967
3034
  if (max === undefined || max > 0) {
@@ -2973,123 +3040,62 @@ function validateTaskExpectationMax(unit, max, pipelineIdentification) {
2973
3040
  ${block(pipelineIdentification)}
2974
3041
  `));
2975
3042
  }
3043
+
2976
3044
  /**
2977
- * Collects the parameter names that are already resolvable before dependency traversal starts.
2978
- *
2979
- * @private internal utility of `validatePipeline`
2980
- */
2981
- function createInitialDependencyResolutionState(pipeline) {
2982
- return {
2983
- resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
2984
- unresolvedTasks: [...pipeline.tasks],
2985
- };
2986
- }
2987
- /**
2988
- * Checks whether dependency resolution still has tasks left to process.
2989
- *
2990
- * @private internal utility of `validatePipeline`
2991
- */
2992
- function hasUnresolvedTasks({ unresolvedTasks }) {
2993
- return unresolvedTasks.length > 0;
2994
- }
2995
- /**
2996
- * Resolves the next batch of currently satisfiable tasks.
3045
+ * Validates PipelineJson if it is logically valid
2997
3046
  *
2998
- * @private internal utility of `validatePipeline`
2999
- */
3000
- function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
3001
- const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
3002
- if (currentlyResolvedTasks.length === 0) {
3003
- throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
3004
- }
3005
- return {
3006
- resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
3007
- unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
3008
- };
3009
- }
3010
- /**
3011
- * Collects the parameter names that are already resolvable before dependency traversal starts.
3047
+ * It checks:
3048
+ * - if it has correct parameters dependency
3012
3049
  *
3013
- * @private internal utility of `validatePipeline`
3014
- */
3015
- function createInitiallyResolvedParameterNames(pipeline) {
3016
- let resolvedParameterNames = pipeline.parameters
3017
- .filter(({ isInput }) => isInput)
3018
- .map(({ name }) => name);
3019
- for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
3020
- resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
3021
- }
3022
- return resolvedParameterNames;
3023
- }
3024
- /**
3025
- * Adds newly resolved task outputs to the resolved parameter list.
3050
+ * It does NOT check:
3051
+ * - if it is valid json
3052
+ * - if it is meaningful
3026
3053
  *
3027
- * @private internal utility of `validatePipeline`
3028
- */
3029
- function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
3030
- return [
3031
- ...resolvedParameterNames,
3032
- ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
3033
- ];
3034
- }
3035
- /**
3036
- * Selects tasks whose dependencies are already resolved.
3054
+ * Note: [🔂] This function is idempotent.
3037
3055
  *
3038
- * @private internal utility of `validatePipeline`
3039
- */
3040
- function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
3041
- return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
3042
- }
3043
- /**
3044
- * Creates the unexpected loop-limit error for dependency resolution.
3056
+ * @param pipeline valid or invalid PipelineJson
3057
+ * @returns the same pipeline if it is logically valid
3058
+ * @throws {PipelineLogicError} on logical error in the pipeline
3045
3059
  *
3046
- * @private internal utility of `validatePipeline`
3060
+ * @public exported from `@promptbook/core`
3047
3061
  */
3048
- function createDependencyResolutionLoopLimitError(pipelineIdentification) {
3049
- // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
3050
- return new UnexpectedError(spaceTrim$1((block) => `
3051
- Loop limit reached during detection of circular dependencies in \`validatePipeline\`
3062
+ function validatePipeline(pipeline) {
3063
+ if (IS_PIPELINE_LOGIC_VALIDATED) {
3064
+ validatePipeline_InnerFunction(pipeline);
3065
+ }
3066
+ else {
3067
+ try {
3068
+ validatePipeline_InnerFunction(pipeline);
3069
+ }
3070
+ catch (error) {
3071
+ if (!(error instanceof PipelineLogicError)) {
3072
+ throw error;
3073
+ }
3074
+ console.error(spaceTrim$1((block) => `
3075
+ Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
3052
3076
 
3053
- ${block(pipelineIdentification)}
3054
- `));
3077
+ ${block(error.message)}
3078
+ `));
3079
+ }
3080
+ }
3081
+ return pipeline;
3055
3082
  }
3056
3083
  /**
3057
- * Creates the detailed error for unresolved or circular task dependencies.
3084
+ * Validates pipeline inner function.
3058
3085
  *
3059
- * @private internal utility of `validatePipeline`
3086
+ * @private internal function for `validatePipeline`
3060
3087
  */
3061
- function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
3062
- return new PipelineLogicError(
3063
- // TODO: [🐎] DRY
3064
- spaceTrim$1((block) => `
3065
-
3066
- Can not resolve some parameters:
3067
- Either you are using a parameter that is not defined, or there are some circular dependencies.
3068
-
3069
- ${block(pipelineIdentification)}
3070
-
3071
- **Can not resolve:**
3072
- ${block(unresolvedTasks
3073
- .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
3074
- .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
3075
- .join(' and ')}`)
3076
- .join('\n'))}
3077
-
3078
- **Resolved:**
3079
- ${block(resolvedParameterNames
3080
- .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
3081
- .map((name) => `- Parameter \`{${name}}\``)
3082
- .join('\n'))}
3083
-
3084
-
3085
- **Reserved (which are available):**
3086
- ${block(resolvedParameterNames
3087
- .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
3088
- .map((name) => `- Parameter \`{${name}}\``)
3089
- .join('\n'))}
3090
-
3091
-
3092
- `));
3088
+ function validatePipeline_InnerFunction(pipeline) {
3089
+ // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
3090
+ const context = createPipelineValidationContext(pipeline);
3091
+ validatePipelineMetadata(context);
3092
+ validatePipelineCollectionsStructure(context);
3093
+ validatePipelineParameters(context);
3094
+ validatePipelineTasks(context);
3095
+ validatePipelineDependencyResolution(context);
3096
+ // Note: Check that formfactor is corresponding to the pipeline interface
3097
+ // TODO: !!6 Implement this
3098
+ // pipeline.formfactorName
3093
3099
  }
3094
3100
  /**
3095
3101
  * TODO: [🧞‍♀️] Do not allow joker + foreach