@promptbook/documents 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
@@ -26,7 +26,7 @@
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
@@ -107,6 +107,127 @@
107
107
  });
108
108
  }
109
109
 
110
+ /**
111
+ * Validates that a channel value is a valid number within the range of 0 to 255.
112
+ * Throws an error if the value is not valid.
113
+ *
114
+ * @param channelName - The name of the channel being validated.
115
+ * @param value - The value of the channel to validate.
116
+ * @throws Will throw an error if the value is not a valid channel number.
117
+ *
118
+ * @private util of `@promptbook/color`
119
+ */
120
+ function checkChannelValue(channelName, value) {
121
+ if (typeof value !== 'number') {
122
+ throw new Error(`${channelName} channel value is not number but ${typeof value}`);
123
+ }
124
+ if (isNaN(value)) {
125
+ throw new Error(`${channelName} channel value is NaN`);
126
+ }
127
+ if (Math.round(value) !== value) {
128
+ throw new Error(`${channelName} channel is not whole number, it is ${value}`);
129
+ }
130
+ if (value < 0) {
131
+ throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
132
+ }
133
+ if (value > 255) {
134
+ throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
135
+ }
136
+ }
137
+
138
+ /**
139
+ * Shared immutable channel storage and serialization helpers for `Color`.
140
+ *
141
+ * @private base class of Color
142
+ */
143
+ class ColorValue {
144
+ constructor(red, green, blue, alpha = 255) {
145
+ this.red = red;
146
+ this.green = green;
147
+ this.blue = blue;
148
+ this.alpha = alpha;
149
+ checkChannelValue('Red', red);
150
+ checkChannelValue('Green', green);
151
+ checkChannelValue('Blue', blue);
152
+ checkChannelValue('Alpha', alpha);
153
+ }
154
+ /**
155
+ * Shortcut for `red` property
156
+ * Number from 0 to 255
157
+ * @alias red
158
+ */
159
+ get r() {
160
+ return this.red;
161
+ }
162
+ /**
163
+ * Shortcut for `green` property
164
+ * Number from 0 to 255
165
+ * @alias green
166
+ */
167
+ get g() {
168
+ return this.green;
169
+ }
170
+ /**
171
+ * Shortcut for `blue` property
172
+ * Number from 0 to 255
173
+ * @alias blue
174
+ */
175
+ get b() {
176
+ return this.blue;
177
+ }
178
+ /**
179
+ * Shortcut for `alpha` property
180
+ * Number from 0 (transparent) to 255 (opaque)
181
+ * @alias alpha
182
+ */
183
+ get a() {
184
+ return this.alpha;
185
+ }
186
+ /**
187
+ * Shortcut for `alpha` property
188
+ * Number from 0 (transparent) to 255 (opaque)
189
+ * @alias alpha
190
+ */
191
+ get opacity() {
192
+ return this.alpha;
193
+ }
194
+ /**
195
+ * Shortcut for 1-`alpha` property
196
+ */
197
+ get transparency() {
198
+ return 255 - this.alpha;
199
+ }
200
+ clone() {
201
+ return take(this.createColor(this.red, this.green, this.blue, this.alpha));
202
+ }
203
+ toString() {
204
+ return this.toHex();
205
+ }
206
+ toHex() {
207
+ if (this.alpha === 255) {
208
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
209
+ .toString(16)
210
+ .padStart(2, '0')}`;
211
+ }
212
+ else {
213
+ return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
214
+ .toString(16)
215
+ .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
216
+ }
217
+ }
218
+ toRgb() {
219
+ if (this.alpha === 255) {
220
+ return `rgb(${this.red}, ${this.green}, ${this.blue})`;
221
+ }
222
+ else {
223
+ return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
224
+ }
225
+ }
226
+ toHsl() {
227
+ throw new Error(`Getting HSL is not implemented`);
228
+ }
229
+ }
230
+
110
231
  /**
111
232
  * 🎨 List of all 140 color names which are supported by CSS
112
233
  *
@@ -266,127 +387,6 @@
266
387
  };
267
388
  // Note: [💞] Ignore a discrepancy between file name and entity name
268
389
 
269
- /**
270
- * Validates that a channel value is a valid number within the range of 0 to 255.
271
- * Throws an error if the value is not valid.
272
- *
273
- * @param channelName - The name of the channel being validated.
274
- * @param value - The value of the channel to validate.
275
- * @throws Will throw an error if the value is not a valid channel number.
276
- *
277
- * @private util of `@promptbook/color`
278
- */
279
- function checkChannelValue(channelName, value) {
280
- if (typeof value !== 'number') {
281
- throw new Error(`${channelName} channel value is not number but ${typeof value}`);
282
- }
283
- if (isNaN(value)) {
284
- throw new Error(`${channelName} channel value is NaN`);
285
- }
286
- if (Math.round(value) !== value) {
287
- throw new Error(`${channelName} channel is not whole number, it is ${value}`);
288
- }
289
- if (value < 0) {
290
- throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
291
- }
292
- if (value > 255) {
293
- throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
294
- }
295
- }
296
-
297
- /**
298
- * Shared immutable channel storage and serialization helpers for `Color`.
299
- *
300
- * @private base class of Color
301
- */
302
- class ColorValue {
303
- constructor(red, green, blue, alpha = 255) {
304
- this.red = red;
305
- this.green = green;
306
- this.blue = blue;
307
- this.alpha = alpha;
308
- checkChannelValue('Red', red);
309
- checkChannelValue('Green', green);
310
- checkChannelValue('Blue', blue);
311
- checkChannelValue('Alpha', alpha);
312
- }
313
- /**
314
- * Shortcut for `red` property
315
- * Number from 0 to 255
316
- * @alias red
317
- */
318
- get r() {
319
- return this.red;
320
- }
321
- /**
322
- * Shortcut for `green` property
323
- * Number from 0 to 255
324
- * @alias green
325
- */
326
- get g() {
327
- return this.green;
328
- }
329
- /**
330
- * Shortcut for `blue` property
331
- * Number from 0 to 255
332
- * @alias blue
333
- */
334
- get b() {
335
- return this.blue;
336
- }
337
- /**
338
- * Shortcut for `alpha` property
339
- * Number from 0 (transparent) to 255 (opaque)
340
- * @alias alpha
341
- */
342
- get a() {
343
- return this.alpha;
344
- }
345
- /**
346
- * Shortcut for `alpha` property
347
- * Number from 0 (transparent) to 255 (opaque)
348
- * @alias alpha
349
- */
350
- get opacity() {
351
- return this.alpha;
352
- }
353
- /**
354
- * Shortcut for 1-`alpha` property
355
- */
356
- get transparency() {
357
- return 255 - this.alpha;
358
- }
359
- clone() {
360
- return take(this.createColor(this.red, this.green, this.blue, this.alpha));
361
- }
362
- toString() {
363
- return this.toHex();
364
- }
365
- toHex() {
366
- if (this.alpha === 255) {
367
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
368
- .toString(16)
369
- .padStart(2, '0')}`;
370
- }
371
- else {
372
- return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
373
- .toString(16)
374
- .padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
375
- }
376
- }
377
- toRgb() {
378
- if (this.alpha === 255) {
379
- return `rgb(${this.red}, ${this.green}, ${this.blue})`;
380
- }
381
- else {
382
- return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
383
- }
384
- }
385
- toHsl() {
386
- throw new Error(`Getting HSL is not implemented`);
387
- }
388
- }
389
-
390
390
  /**
391
391
  * Checks if the given value is a valid hex color string
392
392
  *
@@ -2122,20 +2122,109 @@
2122
2122
  // TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
2123
2123
 
2124
2124
  /**
2125
- * Orders JSON object by keys
2126
- *
2127
- * @returns The same type of object as the input re-ordered
2125
+ * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2128
2126
  *
2129
- * @public exported from `@promptbook/utils`
2127
+ * @public exported from `@promptbook/core`
2130
2128
  */
2131
- function orderJson(options) {
2132
- const { value, order } = options;
2133
- const orderedValue = {
2134
- ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2135
- ...value,
2136
- };
2137
- return orderedValue;
2138
- }
2129
+ class PipelineLogicError extends Error {
2130
+ constructor(message) {
2131
+ super(message);
2132
+ this.name = 'PipelineLogicError';
2133
+ Object.setPrototypeOf(this, PipelineLogicError.prototype);
2134
+ }
2135
+ }
2136
+
2137
+ /**
2138
+ * Creates the shared validation context for one pipeline.
2139
+ *
2140
+ * @private function of `validatePipeline`
2141
+ */
2142
+ function createPipelineValidationContext(pipeline) {
2143
+ return {
2144
+ pipeline,
2145
+ pipelineIdentification: getPipelineIdentification(pipeline),
2146
+ };
2147
+ }
2148
+ /**
2149
+ * Builds a short file/url identification block for validation errors.
2150
+ *
2151
+ * @private internal utility of `validatePipeline`
2152
+ */
2153
+ function getPipelineIdentification(pipeline) {
2154
+ // Note: This is a 😐 implementation of [🚞]
2155
+ const pipelineIdentificationParts = [];
2156
+ if (pipeline.sourceFile !== undefined) {
2157
+ pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2158
+ }
2159
+ if (pipeline.pipelineUrl !== undefined) {
2160
+ pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2161
+ }
2162
+ return pipelineIdentificationParts.join('\n');
2163
+ }
2164
+
2165
+ /**
2166
+ * Validates that the expected top-level collections have array structure.
2167
+ *
2168
+ * @private function of `validatePipeline`
2169
+ */
2170
+ function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification, }) {
2171
+ validatePipelineParametersCollection(pipeline, pipelineIdentification);
2172
+ validatePipelineTasksCollection(pipeline, pipelineIdentification);
2173
+ }
2174
+ /**
2175
+ * Validates that `pipeline.parameters` is an array.
2176
+ *
2177
+ * @private internal utility of `validatePipelineCollectionsStructure`
2178
+ */
2179
+ function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
2180
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2181
+ if (Array.isArray(pipeline.parameters)) {
2182
+ return;
2183
+ }
2184
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2185
+ throw new ParseError(spacetrim.spaceTrim((block) => `
2186
+ Pipeline is valid JSON but with wrong structure
2187
+
2188
+ \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
2189
+
2190
+ ${block(pipelineIdentification)}
2191
+ `));
2192
+ }
2193
+ /**
2194
+ * Validates that `pipeline.tasks` is an array.
2195
+ *
2196
+ * @private internal utility of `validatePipelineCollectionsStructure`
2197
+ */
2198
+ function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
2199
+ // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2200
+ if (Array.isArray(pipeline.tasks)) {
2201
+ return;
2202
+ }
2203
+ // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2204
+ throw new ParseError(spacetrim.spaceTrim((block) => `
2205
+ Pipeline is valid JSON but with wrong structure
2206
+
2207
+ \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
2208
+
2209
+ ${block(pipelineIdentification)}
2210
+ `));
2211
+ }
2212
+
2213
+ /**
2214
+ * Orders JSON object by keys
2215
+ *
2216
+ * @returns The same type of object as the input re-ordered
2217
+ *
2218
+ * @public exported from `@promptbook/utils`
2219
+ */
2220
+ function orderJson(options) {
2221
+ const { value, order } = options;
2222
+ const orderedValue = {
2223
+ ...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
2224
+ ...value,
2225
+ };
2226
+ return orderedValue;
2227
+ }
2139
2228
 
2140
2229
  /**
2141
2230
  * Freezes the given object and all its nested objects recursively
@@ -2484,16 +2573,137 @@
2484
2573
  // Note: [💞] Ignore a discrepancy between file name and entity name
2485
2574
 
2486
2575
  /**
2487
- * This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
2576
+ * Validates that task dependencies can be resolved without cycles or missing definitions.
2488
2577
  *
2489
- * @public exported from `@promptbook/core`
2578
+ * @private function of `validatePipeline`
2490
2579
  */
2491
- class PipelineLogicError extends Error {
2492
- constructor(message) {
2493
- super(message);
2494
- this.name = 'PipelineLogicError';
2495
- Object.setPrototypeOf(this, PipelineLogicError.prototype);
2580
+ function validatePipelineDependencyResolution({ pipeline, pipelineIdentification, }) {
2581
+ let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2582
+ let loopLimit = LOOP_LIMIT;
2583
+ while (hasUnresolvedTasks(dependencyResolutionState)) {
2584
+ if (loopLimit-- < 0) {
2585
+ throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2586
+ }
2587
+ dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2588
+ }
2589
+ }
2590
+ /**
2591
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2592
+ *
2593
+ * @private internal utility of `validatePipelineDependencyResolution`
2594
+ */
2595
+ function createInitialDependencyResolutionState(pipeline) {
2596
+ return {
2597
+ resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
2598
+ unresolvedTasks: [...pipeline.tasks],
2599
+ };
2600
+ }
2601
+ /**
2602
+ * Checks whether dependency resolution still has tasks left to process.
2603
+ *
2604
+ * @private internal utility of `validatePipelineDependencyResolution`
2605
+ */
2606
+ function hasUnresolvedTasks({ unresolvedTasks }) {
2607
+ return unresolvedTasks.length > 0;
2608
+ }
2609
+ /**
2610
+ * Resolves the next batch of currently satisfiable tasks.
2611
+ *
2612
+ * @private internal utility of `validatePipelineDependencyResolution`
2613
+ */
2614
+ function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
2615
+ const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
2616
+ if (currentlyResolvedTasks.length === 0) {
2617
+ throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
2618
+ }
2619
+ return {
2620
+ resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
2621
+ unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
2622
+ };
2623
+ }
2624
+ /**
2625
+ * Collects the parameter names that are already resolvable before dependency traversal starts.
2626
+ *
2627
+ * @private internal utility of `validatePipelineDependencyResolution`
2628
+ */
2629
+ function createInitiallyResolvedParameterNames(pipeline) {
2630
+ let resolvedParameterNames = pipeline.parameters
2631
+ .filter(({ isInput }) => isInput)
2632
+ .map(({ name }) => name);
2633
+ for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
2634
+ resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
2496
2635
  }
2636
+ return resolvedParameterNames;
2637
+ }
2638
+ /**
2639
+ * Adds newly resolved task outputs to the resolved parameter list.
2640
+ *
2641
+ * @private internal utility of `validatePipelineDependencyResolution`
2642
+ */
2643
+ function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
2644
+ return [
2645
+ ...resolvedParameterNames,
2646
+ ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
2647
+ ];
2648
+ }
2649
+ /**
2650
+ * Selects tasks whose dependencies are already resolved.
2651
+ *
2652
+ * @private internal utility of `validatePipelineDependencyResolution`
2653
+ */
2654
+ function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
2655
+ return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
2656
+ }
2657
+ /**
2658
+ * Creates the unexpected loop-limit error for dependency resolution.
2659
+ *
2660
+ * @private internal utility of `validatePipelineDependencyResolution`
2661
+ */
2662
+ function createDependencyResolutionLoopLimitError(pipelineIdentification) {
2663
+ // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
2664
+ return new UnexpectedError(spacetrim.spaceTrim((block) => `
2665
+ Loop limit reached during detection of circular dependencies in \`validatePipeline\`
2666
+
2667
+ ${block(pipelineIdentification)}
2668
+ `));
2669
+ }
2670
+ /**
2671
+ * Creates the detailed error for unresolved or circular task dependencies.
2672
+ *
2673
+ * @private internal utility of `validatePipelineDependencyResolution`
2674
+ */
2675
+ function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
2676
+ return new PipelineLogicError(
2677
+ // TODO: [🐎] DRY
2678
+ spacetrim.spaceTrim((block) => `
2679
+
2680
+ Can not resolve some parameters:
2681
+ Either you are using a parameter that is not defined, or there are some circular dependencies.
2682
+
2683
+ ${block(pipelineIdentification)}
2684
+
2685
+ **Can not resolve:**
2686
+ ${block(unresolvedTasks
2687
+ .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
2688
+ .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
2689
+ .join(' and ')}`)
2690
+ .join('\n'))}
2691
+
2692
+ **Resolved:**
2693
+ ${block(resolvedParameterNames
2694
+ .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
2695
+ .map((name) => `- Parameter \`{${name}}\``)
2696
+ .join('\n'))}
2697
+
2698
+
2699
+ **Reserved (which are available):**
2700
+ ${block(resolvedParameterNames
2701
+ .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
2702
+ .map((name) => `- Parameter \`{${name}}\``)
2703
+ .join('\n'))}
2704
+
2705
+
2706
+ `));
2497
2707
  }
2498
2708
 
2499
2709
  /**
@@ -2571,171 +2781,22 @@
2571
2781
  // TODO: [🐠] Maybe more info why the URL is invalid
2572
2782
 
2573
2783
  /**
2574
- * Validates PipelineJson if it is logically valid
2575
- *
2576
- * It checks:
2577
- * - if it has correct parameters dependency
2578
- *
2579
- * It does NOT check:
2580
- * - if it is valid json
2581
- * - if it is meaningful
2582
- *
2583
- * Note: [🔂] This function is idempotent.
2784
+ * Validates pipeline-level metadata fields.
2584
2785
  *
2585
- * @param pipeline valid or invalid PipelineJson
2586
- * @returns the same pipeline if it is logically valid
2587
- * @throws {PipelineLogicError} on logical error in the pipeline
2786
+ * @private function of `validatePipeline`
2787
+ */
2788
+ function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
2789
+ validatePipelineUrl(pipeline, pipelineIdentification);
2790
+ validatePipelineBookVersion(pipeline, pipelineIdentification);
2791
+ }
2792
+ /**
2793
+ * Validates the pipeline URL, when present.
2588
2794
  *
2589
- * @public exported from `@promptbook/core`
2795
+ * @private internal utility of `validatePipelineMetadata`
2590
2796
  */
2591
- function validatePipeline(pipeline) {
2592
- if (IS_PIPELINE_LOGIC_VALIDATED) {
2593
- validatePipeline_InnerFunction(pipeline);
2594
- }
2595
- else {
2596
- try {
2597
- validatePipeline_InnerFunction(pipeline);
2598
- }
2599
- catch (error) {
2600
- if (!(error instanceof PipelineLogicError)) {
2601
- throw error;
2602
- }
2603
- console.error(spacetrim.spaceTrim((block) => `
2604
- Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
2605
-
2606
- ${block(error.message)}
2607
- `));
2608
- }
2609
- }
2610
- return pipeline;
2611
- }
2612
- /**
2613
- * Validates pipeline inner function.
2614
- *
2615
- * @private internal function for `validatePipeline`
2616
- */
2617
- function validatePipeline_InnerFunction(pipeline) {
2618
- // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
2619
- const context = createPipelineValidationContext(pipeline);
2620
- validatePipelineMetadata(context);
2621
- validatePipelineCollectionsStructure(context);
2622
- validatePipelineParameters(context);
2623
- validatePipelineTasks(context);
2624
- validatePipelineDependencyResolution(context);
2625
- // Note: Check that formfactor is corresponding to the pipeline interface
2626
- // TODO: !!6 Implement this
2627
- // pipeline.formfactorName
2628
- }
2629
- /**
2630
- * Creates the shared validation context for one pipeline.
2631
- *
2632
- * @private internal utility of `validatePipeline`
2633
- */
2634
- function createPipelineValidationContext(pipeline) {
2635
- return {
2636
- pipeline,
2637
- pipelineIdentification: getPipelineIdentification(pipeline),
2638
- };
2639
- }
2640
- /**
2641
- * Builds a short file/url identification block for validation errors.
2642
- *
2643
- * @private internal utility of `validatePipeline`
2644
- */
2645
- function getPipelineIdentification(pipeline) {
2646
- // Note: This is a 😐 implementation of [🚞]
2647
- const pipelineIdentificationParts = [];
2648
- if (pipeline.sourceFile !== undefined) {
2649
- pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
2650
- }
2651
- if (pipeline.pipelineUrl !== undefined) {
2652
- pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
2653
- }
2654
- return pipelineIdentificationParts.join('\n');
2655
- }
2656
- /**
2657
- * Validates pipeline-level metadata fields.
2658
- *
2659
- * @private internal step of `validatePipeline`
2660
- */
2661
- function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
2662
- validatePipelineUrl(pipeline, pipelineIdentification);
2663
- validatePipelineBookVersion(pipeline, pipelineIdentification);
2664
- }
2665
- /**
2666
- * Validates that the expected top-level collections have array structure.
2667
- *
2668
- * @private internal step of `validatePipeline`
2669
- */
2670
- function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification }) {
2671
- validatePipelineParametersCollection(pipeline, pipelineIdentification);
2672
- validatePipelineTasksCollection(pipeline, pipelineIdentification);
2673
- }
2674
- /**
2675
- * Validates all pipeline parameter declarations.
2676
- *
2677
- * @private internal step of `validatePipeline`
2678
- */
2679
- function validatePipelineParameters({ pipeline, pipelineIdentification }) {
2680
- for (const parameter of pipeline.parameters) {
2681
- validatePipelineParameter(parameter, pipeline, pipelineIdentification);
2682
- }
2683
- }
2684
- /**
2685
- * Validates all pipeline tasks and their per-task invariants.
2686
- *
2687
- * @private internal step of `validatePipeline`
2688
- */
2689
- function validatePipelineTasks({ pipeline, pipelineIdentification }) {
2690
- // Note: All input parameters are defined - so that they can be used as result of some task
2691
- const definedParameters = createInitiallyDefinedParameters(pipeline);
2692
- for (const task of pipeline.tasks) {
2693
- validatePipelineTask(task, definedParameters, pipelineIdentification);
2694
- }
2695
- }
2696
- /**
2697
- * Validates that task dependencies can be resolved without cycles or missing definitions.
2698
- *
2699
- * @private internal step of `validatePipeline`
2700
- */
2701
- function validatePipelineDependencyResolution({ pipeline, pipelineIdentification }) {
2702
- let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
2703
- let loopLimit = LOOP_LIMIT;
2704
- while (hasUnresolvedTasks(dependencyResolutionState)) {
2705
- if (loopLimit-- < 0) {
2706
- throw createDependencyResolutionLoopLimitError(pipelineIdentification);
2707
- }
2708
- dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
2709
- }
2710
- }
2711
- /**
2712
- * Validates one pipeline parameter declaration.
2713
- *
2714
- * @private internal step of `validatePipeline`
2715
- */
2716
- function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
2717
- validateParameterDirection(parameter, pipelineIdentification);
2718
- validateParameterUsage(parameter, pipeline, pipelineIdentification);
2719
- validateParameterDefinition(parameter, pipeline, pipelineIdentification);
2720
- }
2721
- /**
2722
- * Validates one pipeline task and its invariants.
2723
- *
2724
- * @private internal step of `validatePipeline`
2725
- */
2726
- function validatePipelineTask(task, definedParameters, pipelineIdentification) {
2727
- validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
2728
- validateTaskJokers(task, pipelineIdentification);
2729
- validateTaskExpectations(task, pipelineIdentification);
2730
- }
2731
- /**
2732
- * Validates the pipeline URL, when present.
2733
- *
2734
- * @private internal utility of `validatePipeline`
2735
- */
2736
- function validatePipelineUrl(pipeline, pipelineIdentification) {
2737
- if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
2738
- return;
2797
+ function validatePipelineUrl(pipeline, pipelineIdentification) {
2798
+ if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
2799
+ return;
2739
2800
  }
2740
2801
  // <- Note: [🚲]
2741
2802
  throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
@@ -2747,7 +2808,7 @@
2747
2808
  /**
2748
2809
  * Validates the Promptbook version, when present.
2749
2810
  *
2750
- * @private internal utility of `validatePipeline`
2811
+ * @private internal utility of `validatePipelineMetadata`
2751
2812
  */
2752
2813
  function validatePipelineBookVersion(pipeline, pipelineIdentification) {
2753
2814
  if (pipeline.bookVersion === undefined || isValidPromptbookVersion(pipeline.bookVersion)) {
@@ -2760,48 +2821,31 @@
2760
2821
  ${block(pipelineIdentification)}
2761
2822
  `));
2762
2823
  }
2824
+
2763
2825
  /**
2764
- * Validates that `pipeline.parameters` is an array.
2826
+ * Validates all pipeline parameter declarations.
2765
2827
  *
2766
- * @private internal utility of `validatePipeline`
2828
+ * @private function of `validatePipeline`
2767
2829
  */
2768
- function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
2769
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2770
- if (Array.isArray(pipeline.parameters)) {
2771
- return;
2830
+ function validatePipelineParameters({ pipeline, pipelineIdentification }) {
2831
+ for (const parameter of pipeline.parameters) {
2832
+ validatePipelineParameter(parameter, pipeline, pipelineIdentification);
2772
2833
  }
2773
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2774
- throw new ParseError(spacetrim.spaceTrim((block) => `
2775
- Pipeline is valid JSON but with wrong structure
2776
-
2777
- \`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
2778
-
2779
- ${block(pipelineIdentification)}
2780
- `));
2781
2834
  }
2782
2835
  /**
2783
- * Validates that `pipeline.tasks` is an array.
2836
+ * Validates one pipeline parameter declaration.
2784
2837
  *
2785
- * @private internal utility of `validatePipeline`
2838
+ * @private internal utility of `validatePipelineParameters`
2786
2839
  */
2787
- function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
2788
- // TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
2789
- if (Array.isArray(pipeline.tasks)) {
2790
- return;
2791
- }
2792
- // TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
2793
- throw new ParseError(spacetrim.spaceTrim((block) => `
2794
- Pipeline is valid JSON but with wrong structure
2795
-
2796
- \`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
2797
-
2798
- ${block(pipelineIdentification)}
2799
- `));
2840
+ function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
2841
+ validateParameterDirection(parameter, pipelineIdentification);
2842
+ validateParameterUsage(parameter, pipeline, pipelineIdentification);
2843
+ validateParameterDefinition(parameter, pipeline, pipelineIdentification);
2800
2844
  }
2801
2845
  /**
2802
2846
  * Validates that one parameter does not declare incompatible directions.
2803
2847
  *
2804
- * @private internal utility of `validatePipeline`
2848
+ * @private internal utility of `validatePipelineParameters`
2805
2849
  */
2806
2850
  function validateParameterDirection(parameter, pipelineIdentification) {
2807
2851
  if (!parameter.isInput || !parameter.isOutput) {
@@ -2818,7 +2862,7 @@
2818
2862
  /**
2819
2863
  * Validates that one intermediate parameter is actually consumed by at least one task.
2820
2864
  *
2821
- * @private internal utility of `validatePipeline`
2865
+ * @private internal utility of `validatePipelineParameters`
2822
2866
  */
2823
2867
  function validateParameterUsage(parameter, pipeline, pipelineIdentification) {
2824
2868
  if (parameter.isInput || parameter.isOutput || isParameterUsedByAnyTask(parameter, pipeline.tasks)) {
@@ -2837,7 +2881,7 @@
2837
2881
  /**
2838
2882
  * Validates that one non-input parameter is produced by at least one task.
2839
2883
  *
2840
- * @private internal utility of `validatePipeline`
2884
+ * @private internal utility of `validatePipelineParameters`
2841
2885
  */
2842
2886
  function validateParameterDefinition(parameter, pipeline, pipelineIdentification) {
2843
2887
  if (parameter.isInput || isParameterDefinedByAnyTask(parameter, pipeline.tasks)) {
@@ -2856,7 +2900,7 @@
2856
2900
  /**
2857
2901
  * Checks whether one parameter is consumed by at least one task dependency list.
2858
2902
  *
2859
- * @private internal utility of `validatePipeline`
2903
+ * @private internal utility of `validatePipelineParameters`
2860
2904
  */
2861
2905
  function isParameterUsedByAnyTask(parameter, tasks) {
2862
2906
  return tasks.some((task) => task.dependentParameterNames.includes(parameter.name));
@@ -2864,23 +2908,46 @@
2864
2908
  /**
2865
2909
  * Checks whether one parameter is produced by at least one task.
2866
2910
  *
2867
- * @private internal utility of `validatePipeline`
2911
+ * @private internal utility of `validatePipelineParameters`
2868
2912
  */
2869
2913
  function isParameterDefinedByAnyTask(parameter, tasks) {
2870
2914
  return tasks.some((task) => task.resultingParameterName === parameter.name);
2871
2915
  }
2916
+
2917
+ /**
2918
+ * Validates all pipeline tasks and their per-task invariants.
2919
+ *
2920
+ * @private function of `validatePipeline`
2921
+ */
2922
+ function validatePipelineTasks({ pipeline, pipelineIdentification }) {
2923
+ // Note: All input parameters are defined - so that they can be used as result of some task
2924
+ const definedParameters = createInitiallyDefinedParameters(pipeline);
2925
+ for (const task of pipeline.tasks) {
2926
+ validatePipelineTask(task, definedParameters, pipelineIdentification);
2927
+ }
2928
+ }
2872
2929
  /**
2873
2930
  * Collects the parameter names that are already defined before task validation starts.
2874
2931
  *
2875
- * @private internal utility of `validatePipeline`
2932
+ * @private internal utility of `validatePipelineTasks`
2876
2933
  */
2877
2934
  function createInitiallyDefinedParameters(pipeline) {
2878
2935
  return new Set(pipeline.parameters.filter(({ isInput }) => isInput).map(({ name }) => name));
2879
2936
  }
2937
+ /**
2938
+ * Validates one pipeline task and its invariants.
2939
+ *
2940
+ * @private internal utility of `validatePipelineTasks`
2941
+ */
2942
+ function validatePipelineTask(task, definedParameters, pipelineIdentification) {
2943
+ validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
2944
+ validateTaskJokers(task, pipelineIdentification);
2945
+ validateTaskExpectations(task, pipelineIdentification);
2946
+ }
2880
2947
  /**
2881
2948
  * Validates one task result parameter declaration and marks it as defined.
2882
2949
  *
2883
- * @private internal utility of `validatePipeline`
2950
+ * @private internal utility of `validatePipelineTasks`
2884
2951
  */
2885
2952
  function validateTaskResultingParameter(task, definedParameters, pipelineIdentification) {
2886
2953
  if (definedParameters.has(task.resultingParameterName)) {
@@ -2902,7 +2969,7 @@
2902
2969
  /**
2903
2970
  * Validates joker parameters for one task.
2904
2971
  *
2905
- * @private internal utility of `validatePipeline`
2972
+ * @private internal utility of `validatePipelineTasks`
2906
2973
  */
2907
2974
  function validateTaskJokers(task, pipelineIdentification) {
2908
2975
  if (!hasTaskJokers(task)) {
@@ -2914,7 +2981,7 @@
2914
2981
  /**
2915
2982
  * Checks whether one task declares any joker parameters.
2916
2983
  *
2917
- * @private internal utility of `validatePipeline`
2984
+ * @private internal utility of `validatePipelineTasks`
2918
2985
  */
2919
2986
  function hasTaskJokers(task) {
2920
2987
  return !!task.jokerParameterNames && task.jokerParameterNames.length > 0;
@@ -2922,7 +2989,7 @@
2922
2989
  /**
2923
2990
  * Validates that a task has the required supporting features when using jokers.
2924
2991
  *
2925
- * @private internal utility of `validatePipeline`
2992
+ * @private internal utility of `validatePipelineTasks`
2926
2993
  */
2927
2994
  function validateTaskSupportsJokers(task, pipelineIdentification) {
2928
2995
  if (task.format || task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
@@ -2937,7 +3004,7 @@
2937
3004
  /**
2938
3005
  * Validates that every joker parameter is also listed among task dependencies.
2939
3006
  *
2940
- * @private internal utility of `validatePipeline`
3007
+ * @private internal utility of `validatePipelineTasks`
2941
3008
  */
2942
3009
  function validateTaskJokerDependencies(task, pipelineIdentification) {
2943
3010
  for (const joker of task.jokerParameterNames) {
@@ -2954,7 +3021,7 @@
2954
3021
  /**
2955
3022
  * Validates all expectation bounds configured on one task.
2956
3023
  *
2957
- * @private internal utility of `validatePipeline`
3024
+ * @private internal utility of `validatePipelineTasks`
2958
3025
  */
2959
3026
  function validateTaskExpectations(task, pipelineIdentification) {
2960
3027
  if (!task.expectations) {
@@ -2969,7 +3036,7 @@
2969
3036
  /**
2970
3037
  * Validates the minimum and maximum expectation ordering for one unit.
2971
3038
  *
2972
- * @private internal utility of `validatePipeline`
3039
+ * @private internal utility of `validatePipelineTasks`
2973
3040
  */
2974
3041
  function validateTaskExpectationRange(unit, min, max, pipelineIdentification) {
2975
3042
  if (min === undefined || max === undefined || min <= max) {
@@ -2984,7 +3051,7 @@
2984
3051
  /**
2985
3052
  * Validates the minimum expectation bound for one unit.
2986
3053
  *
2987
- * @private internal utility of `validatePipeline`
3054
+ * @private internal utility of `validatePipelineTasks`
2988
3055
  */
2989
3056
  function validateTaskExpectationMin(unit, min, pipelineIdentification) {
2990
3057
  if (min === undefined || min >= 0) {
@@ -2999,7 +3066,7 @@
2999
3066
  /**
3000
3067
  * Validates the maximum expectation bound for one unit.
3001
3068
  *
3002
- * @private internal utility of `validatePipeline`
3069
+ * @private internal utility of `validatePipelineTasks`
3003
3070
  */
3004
3071
  function validateTaskExpectationMax(unit, max, pipelineIdentification) {
3005
3072
  if (max === undefined || max > 0) {
@@ -3011,123 +3078,62 @@
3011
3078
  ${block(pipelineIdentification)}
3012
3079
  `));
3013
3080
  }
3081
+
3014
3082
  /**
3015
- * Collects the parameter names that are already resolvable before dependency traversal starts.
3016
- *
3017
- * @private internal utility of `validatePipeline`
3018
- */
3019
- function createInitialDependencyResolutionState(pipeline) {
3020
- return {
3021
- resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
3022
- unresolvedTasks: [...pipeline.tasks],
3023
- };
3024
- }
3025
- /**
3026
- * Checks whether dependency resolution still has tasks left to process.
3027
- *
3028
- * @private internal utility of `validatePipeline`
3029
- */
3030
- function hasUnresolvedTasks({ unresolvedTasks }) {
3031
- return unresolvedTasks.length > 0;
3032
- }
3033
- /**
3034
- * Resolves the next batch of currently satisfiable tasks.
3083
+ * Validates PipelineJson if it is logically valid
3035
3084
  *
3036
- * @private internal utility of `validatePipeline`
3037
- */
3038
- function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
3039
- const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
3040
- if (currentlyResolvedTasks.length === 0) {
3041
- throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
3042
- }
3043
- return {
3044
- resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
3045
- unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
3046
- };
3047
- }
3048
- /**
3049
- * Collects the parameter names that are already resolvable before dependency traversal starts.
3085
+ * It checks:
3086
+ * - if it has correct parameters dependency
3050
3087
  *
3051
- * @private internal utility of `validatePipeline`
3052
- */
3053
- function createInitiallyResolvedParameterNames(pipeline) {
3054
- let resolvedParameterNames = pipeline.parameters
3055
- .filter(({ isInput }) => isInput)
3056
- .map(({ name }) => name);
3057
- for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
3058
- resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
3059
- }
3060
- return resolvedParameterNames;
3061
- }
3062
- /**
3063
- * Adds newly resolved task outputs to the resolved parameter list.
3088
+ * It does NOT check:
3089
+ * - if it is valid json
3090
+ * - if it is meaningful
3064
3091
  *
3065
- * @private internal utility of `validatePipeline`
3066
- */
3067
- function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
3068
- return [
3069
- ...resolvedParameterNames,
3070
- ...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
3071
- ];
3072
- }
3073
- /**
3074
- * Selects tasks whose dependencies are already resolved.
3092
+ * Note: [🔂] This function is idempotent.
3075
3093
  *
3076
- * @private internal utility of `validatePipeline`
3077
- */
3078
- function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
3079
- return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
3080
- }
3081
- /**
3082
- * Creates the unexpected loop-limit error for dependency resolution.
3094
+ * @param pipeline valid or invalid PipelineJson
3095
+ * @returns the same pipeline if it is logically valid
3096
+ * @throws {PipelineLogicError} on logical error in the pipeline
3083
3097
  *
3084
- * @private internal utility of `validatePipeline`
3098
+ * @public exported from `@promptbook/core`
3085
3099
  */
3086
- function createDependencyResolutionLoopLimitError(pipelineIdentification) {
3087
- // Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
3088
- return new UnexpectedError(spacetrim.spaceTrim((block) => `
3089
- Loop limit reached during detection of circular dependencies in \`validatePipeline\`
3100
+ function validatePipeline(pipeline) {
3101
+ if (IS_PIPELINE_LOGIC_VALIDATED) {
3102
+ validatePipeline_InnerFunction(pipeline);
3103
+ }
3104
+ else {
3105
+ try {
3106
+ validatePipeline_InnerFunction(pipeline);
3107
+ }
3108
+ catch (error) {
3109
+ if (!(error instanceof PipelineLogicError)) {
3110
+ throw error;
3111
+ }
3112
+ console.error(spacetrim.spaceTrim((block) => `
3113
+ Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
3090
3114
 
3091
- ${block(pipelineIdentification)}
3092
- `));
3115
+ ${block(error.message)}
3116
+ `));
3117
+ }
3118
+ }
3119
+ return pipeline;
3093
3120
  }
3094
3121
  /**
3095
- * Creates the detailed error for unresolved or circular task dependencies.
3122
+ * Validates pipeline inner function.
3096
3123
  *
3097
- * @private internal utility of `validatePipeline`
3124
+ * @private internal function for `validatePipeline`
3098
3125
  */
3099
- function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
3100
- return new PipelineLogicError(
3101
- // TODO: [🐎] DRY
3102
- spacetrim.spaceTrim((block) => `
3103
-
3104
- Can not resolve some parameters:
3105
- Either you are using a parameter that is not defined, or there are some circular dependencies.
3106
-
3107
- ${block(pipelineIdentification)}
3108
-
3109
- **Can not resolve:**
3110
- ${block(unresolvedTasks
3111
- .map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
3112
- .map((dependentParameterName) => `\`{${dependentParameterName}}\``)
3113
- .join(' and ')}`)
3114
- .join('\n'))}
3115
-
3116
- **Resolved:**
3117
- ${block(resolvedParameterNames
3118
- .filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
3119
- .map((name) => `- Parameter \`{${name}}\``)
3120
- .join('\n'))}
3121
-
3122
-
3123
- **Reserved (which are available):**
3124
- ${block(resolvedParameterNames
3125
- .filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
3126
- .map((name) => `- Parameter \`{${name}}\``)
3127
- .join('\n'))}
3128
-
3129
-
3130
- `));
3126
+ function validatePipeline_InnerFunction(pipeline) {
3127
+ // TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
3128
+ const context = createPipelineValidationContext(pipeline);
3129
+ validatePipelineMetadata(context);
3130
+ validatePipelineCollectionsStructure(context);
3131
+ validatePipelineParameters(context);
3132
+ validatePipelineTasks(context);
3133
+ validatePipelineDependencyResolution(context);
3134
+ // Note: Check that formfactor is corresponding to the pipeline interface
3135
+ // TODO: !!6 Implement this
3136
+ // pipeline.formfactorName
3131
3137
  }
3132
3138
  /**
3133
3139
  * TODO: [🧞‍♀️] Do not allow joker + foreach