@promptbook/markitdown 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/umd/index.umd.js CHANGED
@@ -25,7 +25,7 @@
25
25
  * @generated
26
26
  * @see https://github.com/webgptorg/promptbook
27
27
  */
28
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-1';
28
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-10';
29
29
  /**
30
30
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
31
31
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -106,6 +106,127 @@
106
106
  });
107
107
  }
108
108
 
109
+ /**
110
+ * Validates that a channel value is a valid number within the range of 0 to 255.
111
+ * Throws an error if the value is not valid.
112
+ *
113
+ * @param channelName - The name of the channel being validated.
114
+ * @param value - The value of the channel to validate.
115
+ * @throws Will throw an error if the value is not a valid channel number.
116
+ *
117
+ * @private util of `@promptbook/color`
118
+ */
119
+ function checkChannelValue(channelName, value) {
120
+ if (typeof value !== 'number') {
121
+ throw new Error(`${channelName} channel value is not number but ${typeof value}`);
122
+ }
123
+ if (isNaN(value)) {
124
+ throw new Error(`${channelName} channel value is NaN`);
125
+ }
126
+ if (Math.round(value) !== value) {
127
+ throw new Error(`${channelName} channel is not whole number, it is ${value}`);
128
+ }
129
+ if (value < 0) {
130
+ throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
131
+ }
132
+ if (value > 255) {
133
+ throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
134
+ }
135
+ }
136
+
137
+ /**
138
+ * Shared immutable channel storage and serialization helpers for `Color`.
139
+ *
140
+ * @private base class of Color
141
+ */
142
+ class ColorValue {
143
+ constructor(red, green, blue, alpha = 255) {
144
+ this.red = red;
145
+ this.green = green;
146
+ this.blue = blue;
147
+ this.alpha = alpha;
148
+ checkChannelValue('Red', red);
149
+ checkChannelValue('Green', green);
150
+ checkChannelValue('Blue', blue);
151
+ checkChannelValue('Alpha', alpha);
152
+ }
153
+ /**
154
+ * Shortcut for `red` property
155
+ * Number from 0 to 255
156
+ * @alias red
157
+ */
158
+ get r() {
159
+ return this.red;
160
+ }
161
+ /**
162
+ * Shortcut for `green` property
163
+ * Number from 0 to 255
164
+ * @alias green
165
+ */
166
+ get g() {
167
+ return this.green;
168
+ }
169
+ /**
170
+ * Shortcut for `blue` property
171
+ * Number from 0 to 255
172
+ * @alias blue
173
+ */
174
+ get b() {
175
+ return this.blue;
176
+ }
177
+ /**
178
+ * Shortcut for `alpha` property
179
+ * Number from 0 (transparent) to 255 (opaque)
180
+ * @alias alpha
181
+ */
182
+ get a() {
183
+ return this.alpha;
184
+ }
185
+ /**
186
+ * Shortcut for `alpha` property
187
+ * Number from 0 (transparent) to 255 (opaque)
188
+ * @alias alpha
189
+ */
190
+ get opacity() {
191
+ return this.alpha;
192
+ }
193
+ /**
194
+ * Shortcut for 1-`alpha` property
195
+ */
196
+ get transparency() {
197
+ return 255 - this.alpha;
198
+ }
199
+ clone() {
200
+ return take(this.createColor(this.red, this.green, this.blue, this.alpha));
201
+ }
202
+ toString() {
203
+ return this.toHex();
204
+ }
205
+ toHex() {
206
+ if (this.alpha === 255) {
207
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
208
+ .toString(16)
209
+ .padStart(2, '0')}`;
210
+ }
211
+ else {
212
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
213
+ .toString(16)
214
+ .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
215
+ }
216
+ }
217
+ toRgb() {
218
+ if (this.alpha === 255) {
219
+ return `rgb(${this.red}, ${this.green}, ${this.blue})`;
220
+ }
221
+ else {
222
+ return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
223
+ }
224
+ }
225
+ toHsl() {
226
+ throw new Error(`Getting HSL is not implemented`);
227
+ }
228
+ }
229
+
109
230
  /**
110
231
  * 🎨 List of all 140 color names which are supported by CSS
111
232
  *
@@ -265,127 +386,6 @@
265
386
  };
266
387
  // Note: [💞] Ignore a discrepancy between file name and entity name
267
388
 
268
- /**
269
- * Validates that a channel value is a valid number within the range of 0 to 255.
270
- * Throws an error if the value is not valid.
271
- *
272
- * @param channelName - The name of the channel being validated.
273
- * @param value - The value of the channel to validate.
274
- * @throws Will throw an error if the value is not a valid channel number.
275
- *
276
- * @private util of `@promptbook/color`
277
- */
278
- function checkChannelValue(channelName, value) {
279
- if (typeof value !== 'number') {
280
- throw new Error(`${channelName} channel value is not number but ${typeof value}`);
281
- }
282
- if (isNaN(value)) {
283
- throw new Error(`${channelName} channel value is NaN`);
284
- }
285
- if (Math.round(value) !== value) {
286
- throw new Error(`${channelName} channel is not whole number, it is ${value}`);
287
- }
288
- if (value < 0) {
289
- throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
290
- }
291
- if (value > 255) {
292
- throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
293
- }
294
- }
295
-
296
- /**
297
- * Shared immutable channel storage and serialization helpers for `Color`.
298
- *
299
- * @private base class of Color
300
- */
301
- class ColorValue {
302
- constructor(red, green, blue, alpha = 255) {
303
- this.red = red;
304
- this.green = green;
305
- this.blue = blue;
306
- this.alpha = alpha;
307
- checkChannelValue('Red', red);
308
- checkChannelValue('Green', green);
309
- checkChannelValue('Blue', blue);
310
- checkChannelValue('Alpha', alpha);
311
- }
312
- /**
313
- * Shortcut for `red` property
314
- * Number from 0 to 255
315
- * @alias red
316
- */
317
- get r() {
318
- return this.red;
319
- }
320
- /**
321
- * Shortcut for `green` property
322
- * Number from 0 to 255
323
- * @alias green
324
- */
325
- get g() {
326
- return this.green;
327
- }
328
- /**
329
- * Shortcut for `blue` property
330
- * Number from 0 to 255
331
- * @alias blue
332
- */
333
- get b() {
334
- return this.blue;
335
- }
336
- /**
337
- * Shortcut for `alpha` property
338
- * Number from 0 (transparent) to 255 (opaque)
339
- * @alias alpha
340
- */
341
- get a() {
342
- return this.alpha;
343
- }
344
- /**
345
- * Shortcut for `alpha` property
346
- * Number from 0 (transparent) to 255 (opaque)
347
- * @alias alpha
348
- */
349
- get opacity() {
350
- return this.alpha;
351
- }
352
- /**
353
- * Shortcut for 1-`alpha` property
354
- */
355
- get transparency() {
356
- return 255 - this.alpha;
357
- }
358
- clone() {
359
- return take(this.createColor(this.red, this.green, this.blue, this.alpha));
360
- }
361
- toString() {
362
- return this.toHex();
363
- }
364
- toHex() {
365
- if (this.alpha === 255) {
366
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
367
- .toString(16)
368
- .padStart(2, '0')}`;
369
- }
370
- else {
371
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
372
- .toString(16)
373
- .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
374
- }
375
- }
376
- toRgb() {
377
- if (this.alpha === 255) {
378
- return `rgb(${this.red}, ${this.green}, ${this.blue})`;
379
- }
380
- else {
381
- return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
382
- }
383
- }
384
- toHsl() {
385
- throw new Error(`Getting HSL is not implemented`);
386
- }
387
- }
388
-
389
389
  /**
390
390
  * Checks if the given value is a valid hex color string
391
391
  *
@@ -2368,20 +2368,109 @@
2368
2368
  // TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
2369
2369
 
2370
2370
  /**
2371
- * Orders JSON object by keys
2372
- *
2373
- * @returns The same type of object as the input re-ordered
2371
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2374
2372
  *
2375
- * @public exported from `@promptbook/utils`
2373
+ * @public exported from `@promptbook/core`
2376
2374
  */
2377
- function orderJson(options) {
2378
- const { value, order } = options;
2379
- const orderedValue = {
2380
- ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2381
- ...value,
2382
- };
2383
- return orderedValue;
2384
- }
2375
+ class PipelineLogicError extends Error {
2376
+ constructor(message) {
2377
+ super(message);
2378
+ this.name = 'PipelineLogicError';
2379
+ Object.setPrototypeOf(this, PipelineLogicError.prototype);
2380
+ }
2381
+ }
2382
+
2383
+ /**
2384
+ * Creates the shared validation context for one pipeline.
2385
+ *
2386
+ * @private function of `validatePipeline`
2387
+ */
2388
+ function createPipelineValidationContext(pipeline) {
2389
+ return {
2390
+ pipeline,
2391
+ pipelineIdentification: getPipelineIdentification(pipeline),
2392
+ };
2393
+ }
2394
+ /**
2395
+ * Builds a short file/url identification block for validation errors.
2396
+ *
2397
+ * @private internal utility of `validatePipeline`
2398
+ */
2399
+ function getPipelineIdentification(pipeline) {
2400
+ // Note: This is a 😐 implementation of [🚞]
2401
+ const pipelineIdentificationParts = [];
2402
+ if (pipeline.sourceFile !== undefined) {
2403
+ pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2404
+ }
2405
+ if (pipeline.pipelineUrl !== undefined) {
2406
+ pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2407
+ }
2408
+ return pipelineIdentificationParts.join('\n');
2409
+ }
2410
+
2411
+ /**
2412
+ * Validates that the expected top-level collections have array structure.
2413
+ *
2414
+ * @private function of `validatePipeline`
2415
+ */
2416
+ function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification, }) {
2417
+ validatePipelineParametersCollection(pipeline, pipelineIdentification);
2418
+ validatePipelineTasksCollection(pipeline, pipelineIdentification);
2419
+ }
2420
+ /**
2421
+ * Validates that `pipeline.parameters` is an array.
2422
+ *
2423
+ * @private internal utility of `validatePipelineCollectionsStructure`
2424
+ */
2425
+ function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
2426
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2427
+ if (Array.isArray(pipeline.parameters)) {
2428
+ return;
2429
+ }
2430
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2431
+ throw new ParseError(spacetrim.spaceTrim((block) => `
2432
+ Pipeline is valid JSON but with wrong structure
2433
+
2434
+ \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
2435
+
2436
+ ${block(pipelineIdentification)}
2437
+ `));
2438
+ }
2439
+ /**
2440
+ * Validates that `pipeline.tasks` is an array.
2441
+ *
2442
+ * @private internal utility of `validatePipelineCollectionsStructure`
2443
+ */
2444
+ function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
2445
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2446
+ if (Array.isArray(pipeline.tasks)) {
2447
+ return;
2448
+ }
2449
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2450
+ throw new ParseError(spacetrim.spaceTrim((block) => `
2451
+ Pipeline is valid JSON but with wrong structure
2452
+
2453
+ \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
2454
+
2455
+ ${block(pipelineIdentification)}
2456
+ `));
2457
+ }
2458
+
2459
+ /**
2460
+ * Orders JSON object by keys
2461
+ *
2462
+ * @returns The same type of object as the input re-ordered
2463
+ *
2464
+ * @public exported from `@promptbook/utils`
2465
+ */
2466
+ function orderJson(options) {
2467
+ const { value, order } = options;
2468
+ const orderedValue = {
2469
+ ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2470
+ ...value,
2471
+ };
2472
+ return orderedValue;
2473
+ }
2385
2474
 
2386
2475
  /**
2387
2476
  * Freezes the given object and all its nested objects recursively
@@ -2730,16 +2819,137 @@
2730
2819
  // Note: [💞] Ignore a discrepancy between file name and entity name
2731
2820
 
2732
2821
  /**
2733
- * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2822
+ * Validates that task dependencies can be resolved without cycles or missing definitions.
2734
2823
  *
2735
- * @public exported from `@promptbook/core`
2824
+ * @private function of `validatePipeline`
2736
2825
  */
2737
- class PipelineLogicError extends Error {
2738
- constructor(message) {
2739
- super(message);
2740
- this.name = 'PipelineLogicError';
2741
- Object.setPrototypeOf(this, PipelineLogicError.prototype);
2826
+ function validatePipelineDependencyResolution({ pipeline, pipelineIdentification, }) {
2827
+ let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2828
+ let loopLimit = LOOP_LIMIT;
2829
+ while (hasUnresolvedTasks(dependencyResolutionState)) {
2830
+ if (loopLimit-- < 0) {
2831
+ throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2832
+ }
2833
+ dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2834
+ }
2835
+ }
2836
+ /**
2837
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2838
+ *
2839
+ * @private internal utility of `validatePipelineDependencyResolution`
2840
+ */
2841
+ function createInitialDependencyResolutionState(pipeline) {
2842
+ return {
2843
+ resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
2844
+ unresolvedTasks: [...pipeline.tasks],
2845
+ };
2846
+ }
2847
+ /**
2848
+ * Checks whether dependency resolution still has tasks left to process.
2849
+ *
2850
+ * @private internal utility of `validatePipelineDependencyResolution`
2851
+ */
2852
+ function hasUnresolvedTasks({ unresolvedTasks }) {
2853
+ return unresolvedTasks.length > 0;
2854
+ }
2855
+ /**
2856
+ * Resolves the next batch of currently satisfiable tasks.
2857
+ *
2858
+ * @private internal utility of `validatePipelineDependencyResolution`
2859
+ */
2860
+ function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
2861
+ const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
2862
+ if (currentlyResolvedTasks.length === 0) {
2863
+ throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
2864
+ }
2865
+ return {
2866
+ resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
2867
+ unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
2868
+ };
2869
+ }
2870
+ /**
2871
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2872
+ *
2873
+ * @private internal utility of `validatePipelineDependencyResolution`
2874
+ */
2875
+ function createInitiallyResolvedParameterNames(pipeline) {
2876
+ let resolvedParameterNames = pipeline.parameters
2877
+ .filter(({ isInput }) => isInput)
2878
+ .map(({ name }) => name);
2879
+ for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
2880
+ resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
2742
2881
  }
2882
+ return resolvedParameterNames;
2883
+ }
2884
+ /**
2885
+ * Adds newly resolved task outputs to the resolved parameter list.
2886
+ *
2887
+ * @private internal utility of `validatePipelineDependencyResolution`
2888
+ */
2889
+ function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
2890
+ return [
2891
+ ...resolvedParameterNames,
2892
+ ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
2893
+ ];
2894
+ }
2895
+ /**
2896
+ * Selects tasks whose dependencies are already resolved.
2897
+ *
2898
+ * @private internal utility of `validatePipelineDependencyResolution`
2899
+ */
2900
+ function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
2901
+ return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
2902
+ }
2903
+ /**
2904
+ * Creates the unexpected loop-limit error for dependency resolution.
2905
+ *
2906
+ * @private internal utility of `validatePipelineDependencyResolution`
2907
+ */
2908
+ function createDependencyResolutionLoopLimitError(pipelineIdentification) {
2909
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2910
+ return new UnexpectedError(spacetrim.spaceTrim((block) => `
2911
+ Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2912
+
2913
+ ${block(pipelineIdentification)}
2914
+ `));
2915
+ }
2916
+ /**
2917
+ * Creates the detailed error for unresolved or circular task dependencies.
2918
+ *
2919
+ * @private internal utility of `validatePipelineDependencyResolution`
2920
+ */
2921
+ function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
2922
+ return new PipelineLogicError(
2923
+ // TODO: [🐎] DRY
2924
+ spacetrim.spaceTrim((block) => `
2925
+
2926
+ Can not resolve some parameters:
2927
+ Either you are using a parameter that is not defined, or there are some circular dependencies.
2928
+
2929
+ ${block(pipelineIdentification)}
2930
+
2931
+ **Can not resolve:**
2932
+ ${block(unresolvedTasks
2933
+ .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
2934
+ .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
2935
+ .join(' and ')}`)
2936
+ .join('\n'))}
2937
+
2938
+ **Resolved:**
2939
+ ${block(resolvedParameterNames
2940
+ .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
2941
+ .map((name) => `- Parameter \`{${name}}\``)
2942
+ .join('\n'))}
2943
+
2944
+
2945
+ **Reserved (which are available):**
2946
+ ${block(resolvedParameterNames
2947
+ .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
2948
+ .map((name) => `- Parameter \`{${name}}\``)
2949
+ .join('\n'))}
2950
+
2951
+
2952
+ `));
2743
2953
  }
2744
2954
 
2745
2955
  /**
@@ -2817,171 +3027,22 @@
2817
3027
  // TODO: [🐠] Maybe more info why the URL is invalid
2818
3028
 
2819
3029
  /**
2820
- * Validates PipelineJson if it is logically valid
2821
- *
2822
- * It checks:
2823
- * - if it has correct parameters dependency
2824
- *
2825
- * It does NOT check:
2826
- * - if it is valid json
2827
- * - if it is meaningful
2828
- *
2829
- * Note: [🔂] This function is idempotent.
3030
+ * Validates pipeline-level metadata fields.
2830
3031
  *
2831
- * @param pipeline valid or invalid PipelineJson
2832
- * @returns the same pipeline if it is logically valid
2833
- * @throws {PipelineLogicError} on logical error in the pipeline
3032
+ * @private function of `validatePipeline`
3033
+ */
3034
+ function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
3035
+ validatePipelineUrl(pipeline, pipelineIdentification);
3036
+ validatePipelineBookVersion(pipeline, pipelineIdentification);
3037
+ }
3038
+ /**
3039
+ * Validates the pipeline URL, when present.
2834
3040
  *
2835
- * @public exported from `@promptbook/core`
3041
+ * @private internal utility of `validatePipelineMetadata`
2836
3042
  */
2837
- function validatePipeline(pipeline) {
2838
- if (IS_PIPELINE_LOGIC_VALIDATED) {
2839
- validatePipeline_InnerFunction(pipeline);
2840
- }
2841
- else {
2842
- try {
2843
- validatePipeline_InnerFunction(pipeline);
2844
- }
2845
- catch (error) {
2846
- if (!(error instanceof PipelineLogicError)) {
2847
- throw error;
2848
- }
2849
- console.error(spacetrim.spaceTrim((block) => `
2850
- Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2851
-
2852
- ${block(error.message)}
2853
- `));
2854
- }
2855
- }
2856
- return pipeline;
2857
- }
2858
- /**
2859
- * Validates pipeline inner function.
2860
- *
2861
- * @private internal function for `validatePipeline`
2862
- */
2863
- function validatePipeline_InnerFunction(pipeline) {
2864
- // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
2865
- const context = createPipelineValidationContext(pipeline);
2866
- validatePipelineMetadata(context);
2867
- validatePipelineCollectionsStructure(context);
2868
- validatePipelineParameters(context);
2869
- validatePipelineTasks(context);
2870
- validatePipelineDependencyResolution(context);
2871
- // Note: Check that formfactor is corresponding to the pipeline interface
2872
- // TODO: !!6 Implement this
2873
- // pipeline.formfactorName
2874
- }
2875
- /**
2876
- * Creates the shared validation context for one pipeline.
2877
- *
2878
- * @private internal utility of `validatePipeline`
2879
- */
2880
- function createPipelineValidationContext(pipeline) {
2881
- return {
2882
- pipeline,
2883
- pipelineIdentification: getPipelineIdentification(pipeline),
2884
- };
2885
- }
2886
- /**
2887
- * Builds a short file/url identification block for validation errors.
2888
- *
2889
- * @private internal utility of `validatePipeline`
2890
- */
2891
- function getPipelineIdentification(pipeline) {
2892
- // Note: This is a 😐 implementation of [🚞]
2893
- const pipelineIdentificationParts = [];
2894
- if (pipeline.sourceFile !== undefined) {
2895
- pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2896
- }
2897
- if (pipeline.pipelineUrl !== undefined) {
2898
- pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2899
- }
2900
- return pipelineIdentificationParts.join('\n');
2901
- }
2902
- /**
2903
- * Validates pipeline-level metadata fields.
2904
- *
2905
- * @private internal step of `validatePipeline`
2906
- */
2907
- function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
2908
- validatePipelineUrl(pipeline, pipelineIdentification);
2909
- validatePipelineBookVersion(pipeline, pipelineIdentification);
2910
- }
2911
- /**
2912
- * Validates that the expected top-level collections have array structure.
2913
- *
2914
- * @private internal step of `validatePipeline`
2915
- */
2916
- function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification }) {
2917
- validatePipelineParametersCollection(pipeline, pipelineIdentification);
2918
- validatePipelineTasksCollection(pipeline, pipelineIdentification);
2919
- }
2920
- /**
2921
- * Validates all pipeline parameter declarations.
2922
- *
2923
- * @private internal step of `validatePipeline`
2924
- */
2925
- function validatePipelineParameters({ pipeline, pipelineIdentification }) {
2926
- for (const parameter of pipeline.parameters) {
2927
- validatePipelineParameter(parameter, pipeline, pipelineIdentification);
2928
- }
2929
- }
2930
- /**
2931
- * Validates all pipeline tasks and their per-task invariants.
2932
- *
2933
- * @private internal step of `validatePipeline`
2934
- */
2935
- function validatePipelineTasks({ pipeline, pipelineIdentification }) {
2936
- // Note: All input parameters are defined - so that they can be used as result of some task
2937
- const definedParameters = createInitiallyDefinedParameters(pipeline);
2938
- for (const task of pipeline.tasks) {
2939
- validatePipelineTask(task, definedParameters, pipelineIdentification);
2940
- }
2941
- }
2942
- /**
2943
- * Validates that task dependencies can be resolved without cycles or missing definitions.
2944
- *
2945
- * @private internal step of `validatePipeline`
2946
- */
2947
- function validatePipelineDependencyResolution({ pipeline, pipelineIdentification }) {
2948
- let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2949
- let loopLimit = LOOP_LIMIT;
2950
- while (hasUnresolvedTasks(dependencyResolutionState)) {
2951
- if (loopLimit-- < 0) {
2952
- throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2953
- }
2954
- dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2955
- }
2956
- }
2957
- /**
2958
- * Validates one pipeline parameter declaration.
2959
- *
2960
- * @private internal step of `validatePipeline`
2961
- */
2962
- function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
2963
- validateParameterDirection(parameter, pipelineIdentification);
2964
- validateParameterUsage(parameter, pipeline, pipelineIdentification);
2965
- validateParameterDefinition(parameter, pipeline, pipelineIdentification);
2966
- }
2967
- /**
2968
- * Validates one pipeline task and its invariants.
2969
- *
2970
- * @private internal step of `validatePipeline`
2971
- */
2972
- function validatePipelineTask(task, definedParameters, pipelineIdentification) {
2973
- validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
2974
- validateTaskJokers(task, pipelineIdentification);
2975
- validateTaskExpectations(task, pipelineIdentification);
2976
- }
2977
- /**
2978
- * Validates the pipeline URL, when present.
2979
- *
2980
- * @private internal utility of `validatePipeline`
2981
- */
2982
- function validatePipelineUrl(pipeline, pipelineIdentification) {
2983
- if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
2984
- return;
3043
+ function validatePipelineUrl(pipeline, pipelineIdentification) {
3044
+ if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
3045
+ return;
2985
3046
  }
2986
3047
  // <- Note: [🚲]
2987
3048
  throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
@@ -2993,7 +3054,7 @@
2993
3054
  /**
2994
3055
  * Validates the Promptbook version, when present.
2995
3056
  *
2996
- * @private internal utility of `validatePipeline`
3057
+ * @private internal utility of `validatePipelineMetadata`
2997
3058
  */
2998
3059
  function validatePipelineBookVersion(pipeline, pipelineIdentification) {
2999
3060
  if (pipeline.bookVersion === undefined || isValidPromptbookVersion(pipeline.bookVersion)) {
@@ -3006,48 +3067,31 @@
3006
3067
  ${block(pipelineIdentification)}
3007
3068
  `));
3008
3069
  }
3070
+
3009
3071
  /**
3010
- * Validates that `pipeline.parameters` is an array.
3072
+ * Validates all pipeline parameter declarations.
3011
3073
  *
3012
- * @private internal utility of `validatePipeline`
3074
+ * @private function of `validatePipeline`
3013
3075
  */
3014
- function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
3015
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
3016
- if (Array.isArray(pipeline.parameters)) {
3017
- return;
3076
+ function validatePipelineParameters({ pipeline, pipelineIdentification }) {
3077
+ for (const parameter of pipeline.parameters) {
3078
+ validatePipelineParameter(parameter, pipeline, pipelineIdentification);
3018
3079
  }
3019
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
3020
- throw new ParseError(spacetrim.spaceTrim((block) => `
3021
- Pipeline is valid JSON but with wrong structure
3022
-
3023
- \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
3024
-
3025
- ${block(pipelineIdentification)}
3026
- `));
3027
3080
  }
3028
3081
  /**
3029
- * Validates that `pipeline.tasks` is an array.
3082
+ * Validates one pipeline parameter declaration.
3030
3083
  *
3031
- * @private internal utility of `validatePipeline`
3084
+ * @private internal utility of `validatePipelineParameters`
3032
3085
  */
3033
- function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
3034
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
3035
- if (Array.isArray(pipeline.tasks)) {
3036
- return;
3037
- }
3038
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
3039
- throw new ParseError(spacetrim.spaceTrim((block) => `
3040
- Pipeline is valid JSON but with wrong structure
3041
-
3042
- \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
3043
-
3044
- ${block(pipelineIdentification)}
3045
- `));
3086
+ function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
3087
+ validateParameterDirection(parameter, pipelineIdentification);
3088
+ validateParameterUsage(parameter, pipeline, pipelineIdentification);
3089
+ validateParameterDefinition(parameter, pipeline, pipelineIdentification);
3046
3090
  }
3047
3091
  /**
3048
3092
  * Validates that one parameter does not declare incompatible directions.
3049
3093
  *
3050
- * @private internal utility of `validatePipeline`
3094
+ * @private internal utility of `validatePipelineParameters`
3051
3095
  */
3052
3096
  function validateParameterDirection(parameter, pipelineIdentification) {
3053
3097
  if (!parameter.isInput || !parameter.isOutput) {
@@ -3064,7 +3108,7 @@
3064
3108
  /**
3065
3109
  * Validates that one intermediate parameter is actually consumed by at least one task.
3066
3110
  *
3067
- * @private internal utility of `validatePipeline`
3111
+ * @private internal utility of `validatePipelineParameters`
3068
3112
  */
3069
3113
  function validateParameterUsage(parameter, pipeline, pipelineIdentification) {
3070
3114
  if (parameter.isInput || parameter.isOutput || isParameterUsedByAnyTask(parameter, pipeline.tasks)) {
@@ -3083,7 +3127,7 @@
3083
3127
  /**
3084
3128
  * Validates that one non-input parameter is produced by at least one task.
3085
3129
  *
3086
- * @private internal utility of `validatePipeline`
3130
+ * @private internal utility of `validatePipelineParameters`
3087
3131
  */
3088
3132
  function validateParameterDefinition(parameter, pipeline, pipelineIdentification) {
3089
3133
  if (parameter.isInput || isParameterDefinedByAnyTask(parameter, pipeline.tasks)) {
@@ -3102,7 +3146,7 @@
3102
3146
  /**
3103
3147
  * Checks whether one parameter is consumed by at least one task dependency list.
3104
3148
  *
3105
- * @private internal utility of `validatePipeline`
3149
+ * @private internal utility of `validatePipelineParameters`
3106
3150
  */
3107
3151
  function isParameterUsedByAnyTask(parameter, tasks) {
3108
3152
  return tasks.some((task) => task.dependentParameterNames.includes(parameter.name));
@@ -3110,23 +3154,46 @@
3110
3154
  /**
3111
3155
  * Checks whether one parameter is produced by at least one task.
3112
3156
  *
3113
- * @private internal utility of `validatePipeline`
3157
+ * @private internal utility of `validatePipelineParameters`
3114
3158
  */
3115
3159
  function isParameterDefinedByAnyTask(parameter, tasks) {
3116
3160
  return tasks.some((task) => task.resultingParameterName === parameter.name);
3117
3161
  }
3162
+
3163
+ /**
3164
+ * Validates all pipeline tasks and their per-task invariants.
3165
+ *
3166
+ * @private function of `validatePipeline`
3167
+ */
3168
+ function validatePipelineTasks({ pipeline, pipelineIdentification }) {
3169
+ // Note: All input parameters are defined - so that they can be used as result of some task
3170
+ const definedParameters = createInitiallyDefinedParameters(pipeline);
3171
+ for (const task of pipeline.tasks) {
3172
+ validatePipelineTask(task, definedParameters, pipelineIdentification);
3173
+ }
3174
+ }
3118
3175
  /**
3119
3176
  * Collects the parameter names that are already defined before task validation starts.
3120
3177
  *
3121
- * @private internal utility of `validatePipeline`
3178
+ * @private internal utility of `validatePipelineTasks`
3122
3179
  */
3123
3180
  function createInitiallyDefinedParameters(pipeline) {
3124
3181
  return new Set(pipeline.parameters.filter(({ isInput }) => isInput).map(({ name }) => name));
3125
3182
  }
3183
+ /**
3184
+ * Validates one pipeline task and its invariants.
3185
+ *
3186
+ * @private internal utility of `validatePipelineTasks`
3187
+ */
3188
+ function validatePipelineTask(task, definedParameters, pipelineIdentification) {
3189
+ validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
3190
+ validateTaskJokers(task, pipelineIdentification);
3191
+ validateTaskExpectations(task, pipelineIdentification);
3192
+ }
3126
3193
  /**
3127
3194
  * Validates one task result parameter declaration and marks it as defined.
3128
3195
  *
3129
- * @private internal utility of `validatePipeline`
3196
+ * @private internal utility of `validatePipelineTasks`
3130
3197
  */
3131
3198
  function validateTaskResultingParameter(task, definedParameters, pipelineIdentification) {
3132
3199
  if (definedParameters.has(task.resultingParameterName)) {
@@ -3148,7 +3215,7 @@
3148
3215
  /**
3149
3216
  * Validates joker parameters for one task.
3150
3217
  *
3151
- * @private internal utility of `validatePipeline`
3218
+ * @private internal utility of `validatePipelineTasks`
3152
3219
  */
3153
3220
  function validateTaskJokers(task, pipelineIdentification) {
3154
3221
  if (!hasTaskJokers(task)) {
@@ -3160,7 +3227,7 @@
3160
3227
  /**
3161
3228
  * Checks whether one task declares any joker parameters.
3162
3229
  *
3163
- * @private internal utility of `validatePipeline`
3230
+ * @private internal utility of `validatePipelineTasks`
3164
3231
  */
3165
3232
  function hasTaskJokers(task) {
3166
3233
  return !!task.jokerParameterNames && task.jokerParameterNames.length > 0;
@@ -3168,7 +3235,7 @@
3168
3235
  /**
3169
3236
  * Validates that a task has the required supporting features when using jokers.
3170
3237
  *
3171
- * @private internal utility of `validatePipeline`
3238
+ * @private internal utility of `validatePipelineTasks`
3172
3239
  */
3173
3240
  function validateTaskSupportsJokers(task, pipelineIdentification) {
3174
3241
  if (task.format || task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
@@ -3183,7 +3250,7 @@
3183
3250
  /**
3184
3251
  * Validates that every joker parameter is also listed among task dependencies.
3185
3252
  *
3186
- * @private internal utility of `validatePipeline`
3253
+ * @private internal utility of `validatePipelineTasks`
3187
3254
  */
3188
3255
  function validateTaskJokerDependencies(task, pipelineIdentification) {
3189
3256
  for (const joker of task.jokerParameterNames) {
@@ -3200,7 +3267,7 @@
3200
3267
  /**
3201
3268
  * Validates all expectation bounds configured on one task.
3202
3269
  *
3203
- * @private internal utility of `validatePipeline`
3270
+ * @private internal utility of `validatePipelineTasks`
3204
3271
  */
3205
3272
  function validateTaskExpectations(task, pipelineIdentification) {
3206
3273
  if (!task.expectations) {
@@ -3215,7 +3282,7 @@
3215
3282
  /**
3216
3283
  * Validates the minimum and maximum expectation ordering for one unit.
3217
3284
  *
3218
- * @private internal utility of `validatePipeline`
3285
+ * @private internal utility of `validatePipelineTasks`
3219
3286
  */
3220
3287
  function validateTaskExpectationRange(unit, min, max, pipelineIdentification) {
3221
3288
  if (min === undefined || max === undefined || min <= max) {
@@ -3230,7 +3297,7 @@
3230
3297
  /**
3231
3298
  * Validates the minimum expectation bound for one unit.
3232
3299
  *
3233
- * @private internal utility of `validatePipeline`
3300
+ * @private internal utility of `validatePipelineTasks`
3234
3301
  */
3235
3302
  function validateTaskExpectationMin(unit, min, pipelineIdentification) {
3236
3303
  if (min === undefined || min >= 0) {
@@ -3245,7 +3312,7 @@
3245
3312
  /**
3246
3313
  * Validates the maximum expectation bound for one unit.
3247
3314
  *
3248
- * @private internal utility of `validatePipeline`
3315
+ * @private internal utility of `validatePipelineTasks`
3249
3316
  */
3250
3317
  function validateTaskExpectationMax(unit, max, pipelineIdentification) {
3251
3318
  if (max === undefined || max > 0) {
@@ -3257,123 +3324,62 @@
3257
3324
  ${block(pipelineIdentification)}
3258
3325
  `));
3259
3326
  }
3327
+
3260
3328
  /**
3261
- * Collects the parameter names that are already resolvable before dependency traversal starts.
3262
- *
3263
- * @private internal utility of `validatePipeline`
3264
- */
3265
- function createInitialDependencyResolutionState(pipeline) {
3266
- return {
3267
- resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
3268
- unresolvedTasks: [...pipeline.tasks],
3269
- };
3270
- }
3271
- /**
3272
- * Checks whether dependency resolution still has tasks left to process.
3273
- *
3274
- * @private internal utility of `validatePipeline`
3275
- */
3276
- function hasUnresolvedTasks({ unresolvedTasks }) {
3277
- return unresolvedTasks.length > 0;
3278
- }
3279
- /**
3280
- * Resolves the next batch of currently satisfiable tasks.
3329
+ * Validates PipelineJson if it is logically valid
3281
3330
  *
3282
- * @private internal utility of `validatePipeline`
3283
- */
3284
- function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
3285
- const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
3286
- if (currentlyResolvedTasks.length === 0) {
3287
- throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
3288
- }
3289
- return {
3290
- resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
3291
- unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
3292
- };
3293
- }
3294
- /**
3295
- * Collects the parameter names that are already resolvable before dependency traversal starts.
3331
+ * It checks:
3332
+ * - if it has correct parameters dependency
3296
3333
  *
3297
- * @private internal utility of `validatePipeline`
3298
- */
3299
- function createInitiallyResolvedParameterNames(pipeline) {
3300
- let resolvedParameterNames = pipeline.parameters
3301
- .filter(({ isInput }) => isInput)
3302
- .map(({ name }) => name);
3303
- for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
3304
- resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
3305
- }
3306
- return resolvedParameterNames;
3307
- }
3308
- /**
3309
- * Adds newly resolved task outputs to the resolved parameter list.
3334
+ * It does NOT check:
3335
+ * - if it is valid json
3336
+ * - if it is meaningful
3310
3337
  *
3311
- * @private internal utility of `validatePipeline`
3312
- */
3313
- function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
3314
- return [
3315
- ...resolvedParameterNames,
3316
- ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
3317
- ];
3318
- }
3319
- /**
3320
- * Selects tasks whose dependencies are already resolved.
3338
+ * Note: [🔂] This function is idempotent.
3321
3339
  *
3322
- * @private internal utility of `validatePipeline`
3323
- */
3324
- function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
3325
- return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
3326
- }
3327
- /**
3328
- * Creates the unexpected loop-limit error for dependency resolution.
3340
+ * @param pipeline valid or invalid PipelineJson
3341
+ * @returns the same pipeline if it is logically valid
3342
+ * @throws {PipelineLogicError} on logical error in the pipeline
3329
3343
  *
3330
- * @private internal utility of `validatePipeline`
3344
+ * @public exported from `@promptbook/core`
3331
3345
  */
3332
- function createDependencyResolutionLoopLimitError(pipelineIdentification) {
3333
- // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
3334
- return new UnexpectedError(spacetrim.spaceTrim((block) => `
3335
- Loop limit reached during detection of circular dependencies in \`validatePipeline\`
3346
+ function validatePipeline(pipeline) {
3347
+ if (IS_PIPELINE_LOGIC_VALIDATED) {
3348
+ validatePipeline_InnerFunction(pipeline);
3349
+ }
3350
+ else {
3351
+ try {
3352
+ validatePipeline_InnerFunction(pipeline);
3353
+ }
3354
+ catch (error) {
3355
+ if (!(error instanceof PipelineLogicError)) {
3356
+ throw error;
3357
+ }
3358
+ console.error(spacetrim.spaceTrim((block) => `
3359
+ Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
3336
3360
 
3337
- ${block(pipelineIdentification)}
3338
- `));
3361
+ ${block(error.message)}
3362
+ `));
3363
+ }
3364
+ }
3365
+ return pipeline;
3339
3366
  }
3340
3367
  /**
3341
- * Creates the detailed error for unresolved or circular task dependencies.
3368
+ * Validates pipeline inner function.
3342
3369
  *
3343
- * @private internal utility of `validatePipeline`
3370
+ * @private internal function for `validatePipeline`
3344
3371
  */
3345
- function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
3346
- return new PipelineLogicError(
3347
- // TODO: [🐎] DRY
3348
- spacetrim.spaceTrim((block) => `
3349
-
3350
- Can not resolve some parameters:
3351
- Either you are using a parameter that is not defined, or there are some circular dependencies.
3352
-
3353
- ${block(pipelineIdentification)}
3354
-
3355
- **Can not resolve:**
3356
- ${block(unresolvedTasks
3357
- .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
3358
- .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
3359
- .join(' and ')}`)
3360
- .join('\n'))}
3361
-
3362
- **Resolved:**
3363
- ${block(resolvedParameterNames
3364
- .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
3365
- .map((name) => `- Parameter \`{${name}}\``)
3366
- .join('\n'))}
3367
-
3368
-
3369
- **Reserved (which are available):**
3370
- ${block(resolvedParameterNames
3371
- .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
3372
- .map((name) => `- Parameter \`{${name}}\``)
3373
- .join('\n'))}
3374
-
3375
-
3376
- `));
3372
+ function validatePipeline_InnerFunction(pipeline) {
3373
+ // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
3374
+ const context = createPipelineValidationContext(pipeline);
3375
+ validatePipelineMetadata(context);
3376
+ validatePipelineCollectionsStructure(context);
3377
+ validatePipelineParameters(context);
3378
+ validatePipelineTasks(context);
3379
+ validatePipelineDependencyResolution(context);
3380
+ // Note: Check that formfactor is corresponding to the pipeline interface
3381
+ // TODO: !!6 Implement this
3382
+ // pipeline.formfactorName
3377
3383
  }
3378
3384
  /**
3379
3385
  * TODO: [🧞‍♀️] Do not allow joker + foreach