@promptbook/markdown-utils 0.113.0-7 → 0.113.0-9
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.
- package/esm/index.es.js +459 -453
- package/esm/index.es.js.map +1 -1
- package/esm/src/_packages/types.index.d.ts +2 -2
- package/esm/src/avatars/renderAvatarVisualAsciiArt.d.ts +24 -1
- package/esm/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
- package/esm/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
- package/esm/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
- package/esm/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
- package/esm/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
- package/esm/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
- package/esm/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
- package/esm/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
- package/esm/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
- package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
- package/esm/src/commitments/META/META.d.ts +2 -2
- package/esm/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
- package/esm/src/commitments/index.d.ts +1 -1
- package/esm/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
- package/esm/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
- package/esm/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/esm/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
- package/esm/src/utils/color/Color.d.ts +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +459 -453
- package/umd/index.umd.js.map +1 -1
- package/umd/src/_packages/types.index.d.ts +2 -2
- package/umd/src/avatars/renderAvatarVisualAsciiArt.d.ts +24 -1
- package/umd/src/avatars/visuals/octopus3dAvatarVisualShared.d.ts +1 -1
- package/umd/src/book-components/BookEditor/BookEditorMonacoUploadPanel.d.ts +1 -1
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/bookEditorMonacoUploadTypes.d.ts +120 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/clearScheduledTimer.d.ts +6 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/enqueueFilesForUpload.d.ts +26 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadEditorSync.d.ts +23 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadItemsState.d.ts +21 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadProgressQueue.d.ts +12 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useBookEditorMonacoUploadQueue.d.ts +27 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads/useCompletedUploadsAutoClear.d.ts +12 -0
- package/umd/src/book-components/BookEditor/useBookEditorMonacoUploads.d.ts +5 -58
- package/umd/src/book-components/Chat/Chat/ChatImageAttachmentModal.d.ts +25 -0
- package/umd/src/book-components/Chat/Chat/ChatInputArea.d.ts +3 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageAttachments.d.ts +27 -0
- package/umd/src/book-components/Chat/Chat/ChatMessageItem.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/ChatMessageList.d.ts +1 -0
- package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +8 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.d.ts +12 -0
- package/umd/src/book-components/Chat/Chat/useChatInputAreaComposer.draftMessage.test.d.ts +2 -0
- package/umd/src/book-components/Chat/utils/isVisibleChatToolCall.d.ts +1 -1
- package/umd/src/book-components/Chat/utils/parseMessageButtons.d.ts +16 -2
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_FILENAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_BUILD_CACHE_VERSION.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AGENTS_SERVER_NEXT_BUILD_ID_FILENAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCache.d.ts +10 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/AgentsServerBuildCacheOptions.d.ts +10 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/NODE_MODULES_DIRECTORY_NAME.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/PreparedAgentsServerRuntime.d.ts +18 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerBuildSourceFingerprint.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/createAgentsServerRuntimeEnvironment.d.ts +28 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/ensureAgentsServerBuild.d.ts +19 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/getAgentsServerBuildInputRelativePaths.d.ts +11 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerAppPathMaterialized.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildCacheCurrent.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isAgentsServerBuildInputTestFile.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputDirectoryName.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerBuildInputPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isExcludedAgentsServerRuntimeSourcePath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isFile.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/isPathInsideNodeModules.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/normalizeAgentsServerBuildInputPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/prepareAgentsServerRuntime.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/readAgentsServerBuildCache.d.ts +8 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerAppPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildAppPath.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveAgentsServerBuildOutputPath.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNextCliPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/resolveNodeModulesPath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/runNextBuild.d.ts +12 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/shouldCopyAgentsServerRuntimePath.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/synchronizeMaterializedAgentsServerRuntime.d.ts +11 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer/writeAgentsServerBuildCache.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +8 -109
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerEnvFile.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/ensureAgentsServerGitignoreFile.d.ts +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerChildEnvironment.d.ts +16 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerLogStreams.d.ts +30 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerRuntimePaths.d.ts +19 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/AgentsServerSupervisorState.d.ts +37 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/LocalAgentRunnerLimits.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/PreparedAgentsServerLaunch.d.ts +13 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/StartAgentsServerOptions.d.ts +24 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createInternalRouteErrorMessage.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/createLocalAgentRunOptions.d.ts +9 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/forwardChildOutput.d.ts +13 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/loadAgentsServerProjectEnvironment.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/prepareAgentsServerLaunch.d.ts +18 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/readInternalRouteErrorDetails.d.ts +6 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/resolveAgentsServerChildHostname.d.ts +7 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startNextServer.d.ts +20 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/startUserChatJobWorkerPump.d.ts +15 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/stopChildProcess.d.ts +8 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer/waitForLocalAgentRunnerLimits.d.ts +16 -0
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +3 -30
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +1 -1
- package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +1 -1
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +1 -1
- package/umd/src/commitments/META/META.d.ts +2 -2
- package/umd/src/commitments/META_AVATAR/META_AVATAR.d.ts +9 -4
- package/umd/src/commitments/index.d.ts +1 -1
- package/umd/src/conversion/validation/validatePipeline/createPipelineValidationContext.d.ts +16 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineCollectionsStructure.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineDependencyResolution.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineMetadata.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineParameters.d.ts +7 -0
- package/umd/src/conversion/validation/validatePipeline/validatePipelineTasks.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/RegisteredLlmToolsMessageContext.d.ts +46 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/USED_ENV_FILENAME.d.ts +11 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolConfigurationStatusMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolEntryKey.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolInstallationStatusMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolStatus.d.ts +14 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/createRegisteredLlmToolsMessageContext.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getAvailableRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/getRegisteredLlmToolRegisters.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/hasRegisteredLlmToolEntry.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolEntries.d.ts +9 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/listRegisteredLlmToolStatuses.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderAvailableRegisteredLlmTools.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderNoRegisteredLlmToolsMessage.d.ts +7 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRegisteredLlmToolsMessage.d.ts +8 -0
- package/umd/src/llm-providers/_common/register/$registeredLlmToolsMessage/renderRelevantRegisteredLlmToolsEnvironmentVariables.d.ts +7 -0
- package/umd/src/utils/agents/resolveAgentAvatarImageUrl.d.ts +2 -2
- package/umd/src/utils/color/Color.d.ts +1 -1
- package/umd/src/version.d.ts +1 -1
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-
|
|
28
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.113.0-9';
|
|
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
|
|
@@ -228,6 +228,127 @@
|
|
|
228
228
|
});
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Validates that a channel value is a valid number within the range of 0 to 255.
|
|
233
|
+
* Throws an error if the value is not valid.
|
|
234
|
+
*
|
|
235
|
+
* @param channelName - The name of the channel being validated.
|
|
236
|
+
* @param value - The value of the channel to validate.
|
|
237
|
+
* @throws Will throw an error if the value is not a valid channel number.
|
|
238
|
+
*
|
|
239
|
+
* @private util of `@promptbook/color`
|
|
240
|
+
*/
|
|
241
|
+
function checkChannelValue(channelName, value) {
|
|
242
|
+
if (typeof value !== 'number') {
|
|
243
|
+
throw new Error(`${channelName} channel value is not number but ${typeof value}`);
|
|
244
|
+
}
|
|
245
|
+
if (isNaN(value)) {
|
|
246
|
+
throw new Error(`${channelName} channel value is NaN`);
|
|
247
|
+
}
|
|
248
|
+
if (Math.round(value) !== value) {
|
|
249
|
+
throw new Error(`${channelName} channel is not whole number, it is ${value}`);
|
|
250
|
+
}
|
|
251
|
+
if (value < 0) {
|
|
252
|
+
throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
|
|
253
|
+
}
|
|
254
|
+
if (value > 255) {
|
|
255
|
+
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Shared immutable channel storage and serialization helpers for `Color`.
|
|
261
|
+
*
|
|
262
|
+
* @private base class of Color
|
|
263
|
+
*/
|
|
264
|
+
class ColorValue {
|
|
265
|
+
constructor(red, green, blue, alpha = 255) {
|
|
266
|
+
this.red = red;
|
|
267
|
+
this.green = green;
|
|
268
|
+
this.blue = blue;
|
|
269
|
+
this.alpha = alpha;
|
|
270
|
+
checkChannelValue('Red', red);
|
|
271
|
+
checkChannelValue('Green', green);
|
|
272
|
+
checkChannelValue('Blue', blue);
|
|
273
|
+
checkChannelValue('Alpha', alpha);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Shortcut for `red` property
|
|
277
|
+
* Number from 0 to 255
|
|
278
|
+
* @alias red
|
|
279
|
+
*/
|
|
280
|
+
get r() {
|
|
281
|
+
return this.red;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Shortcut for `green` property
|
|
285
|
+
* Number from 0 to 255
|
|
286
|
+
* @alias green
|
|
287
|
+
*/
|
|
288
|
+
get g() {
|
|
289
|
+
return this.green;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Shortcut for `blue` property
|
|
293
|
+
* Number from 0 to 255
|
|
294
|
+
* @alias blue
|
|
295
|
+
*/
|
|
296
|
+
get b() {
|
|
297
|
+
return this.blue;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Shortcut for `alpha` property
|
|
301
|
+
* Number from 0 (transparent) to 255 (opaque)
|
|
302
|
+
* @alias alpha
|
|
303
|
+
*/
|
|
304
|
+
get a() {
|
|
305
|
+
return this.alpha;
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Shortcut for `alpha` property
|
|
309
|
+
* Number from 0 (transparent) to 255 (opaque)
|
|
310
|
+
* @alias alpha
|
|
311
|
+
*/
|
|
312
|
+
get opacity() {
|
|
313
|
+
return this.alpha;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Shortcut for 1-`alpha` property
|
|
317
|
+
*/
|
|
318
|
+
get transparency() {
|
|
319
|
+
return 255 - this.alpha;
|
|
320
|
+
}
|
|
321
|
+
clone() {
|
|
322
|
+
return take(this.createColor(this.red, this.green, this.blue, this.alpha));
|
|
323
|
+
}
|
|
324
|
+
toString() {
|
|
325
|
+
return this.toHex();
|
|
326
|
+
}
|
|
327
|
+
toHex() {
|
|
328
|
+
if (this.alpha === 255) {
|
|
329
|
+
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
330
|
+
.toString(16)
|
|
331
|
+
.padStart(2, '0')}`;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
335
|
+
.toString(16)
|
|
336
|
+
.padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
toRgb() {
|
|
340
|
+
if (this.alpha === 255) {
|
|
341
|
+
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
toHsl() {
|
|
348
|
+
throw new Error(`Getting HSL is not implemented`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
231
352
|
/**
|
|
232
353
|
* 🎨 List of all 140 color names which are supported by CSS
|
|
233
354
|
*
|
|
@@ -387,127 +508,6 @@
|
|
|
387
508
|
};
|
|
388
509
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
389
510
|
|
|
390
|
-
/**
|
|
391
|
-
* Validates that a channel value is a valid number within the range of 0 to 255.
|
|
392
|
-
* Throws an error if the value is not valid.
|
|
393
|
-
*
|
|
394
|
-
* @param channelName - The name of the channel being validated.
|
|
395
|
-
* @param value - The value of the channel to validate.
|
|
396
|
-
* @throws Will throw an error if the value is not a valid channel number.
|
|
397
|
-
*
|
|
398
|
-
* @private util of `@promptbook/color`
|
|
399
|
-
*/
|
|
400
|
-
function checkChannelValue(channelName, value) {
|
|
401
|
-
if (typeof value !== 'number') {
|
|
402
|
-
throw new Error(`${channelName} channel value is not number but ${typeof value}`);
|
|
403
|
-
}
|
|
404
|
-
if (isNaN(value)) {
|
|
405
|
-
throw new Error(`${channelName} channel value is NaN`);
|
|
406
|
-
}
|
|
407
|
-
if (Math.round(value) !== value) {
|
|
408
|
-
throw new Error(`${channelName} channel is not whole number, it is ${value}`);
|
|
409
|
-
}
|
|
410
|
-
if (value < 0) {
|
|
411
|
-
throw new Error(`${channelName} channel is lower than 0, it is ${value}`);
|
|
412
|
-
}
|
|
413
|
-
if (value > 255) {
|
|
414
|
-
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
/**
|
|
419
|
-
* Shared immutable channel storage and serialization helpers for `Color`.
|
|
420
|
-
*
|
|
421
|
-
* @private base class of Color
|
|
422
|
-
*/
|
|
423
|
-
class ColorValue {
|
|
424
|
-
constructor(red, green, blue, alpha = 255) {
|
|
425
|
-
this.red = red;
|
|
426
|
-
this.green = green;
|
|
427
|
-
this.blue = blue;
|
|
428
|
-
this.alpha = alpha;
|
|
429
|
-
checkChannelValue('Red', red);
|
|
430
|
-
checkChannelValue('Green', green);
|
|
431
|
-
checkChannelValue('Blue', blue);
|
|
432
|
-
checkChannelValue('Alpha', alpha);
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Shortcut for `red` property
|
|
436
|
-
* Number from 0 to 255
|
|
437
|
-
* @alias red
|
|
438
|
-
*/
|
|
439
|
-
get r() {
|
|
440
|
-
return this.red;
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* Shortcut for `green` property
|
|
444
|
-
* Number from 0 to 255
|
|
445
|
-
* @alias green
|
|
446
|
-
*/
|
|
447
|
-
get g() {
|
|
448
|
-
return this.green;
|
|
449
|
-
}
|
|
450
|
-
/**
|
|
451
|
-
* Shortcut for `blue` property
|
|
452
|
-
* Number from 0 to 255
|
|
453
|
-
* @alias blue
|
|
454
|
-
*/
|
|
455
|
-
get b() {
|
|
456
|
-
return this.blue;
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Shortcut for `alpha` property
|
|
460
|
-
* Number from 0 (transparent) to 255 (opaque)
|
|
461
|
-
* @alias alpha
|
|
462
|
-
*/
|
|
463
|
-
get a() {
|
|
464
|
-
return this.alpha;
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Shortcut for `alpha` property
|
|
468
|
-
* Number from 0 (transparent) to 255 (opaque)
|
|
469
|
-
* @alias alpha
|
|
470
|
-
*/
|
|
471
|
-
get opacity() {
|
|
472
|
-
return this.alpha;
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Shortcut for 1-`alpha` property
|
|
476
|
-
*/
|
|
477
|
-
get transparency() {
|
|
478
|
-
return 255 - this.alpha;
|
|
479
|
-
}
|
|
480
|
-
clone() {
|
|
481
|
-
return take(this.createColor(this.red, this.green, this.blue, this.alpha));
|
|
482
|
-
}
|
|
483
|
-
toString() {
|
|
484
|
-
return this.toHex();
|
|
485
|
-
}
|
|
486
|
-
toHex() {
|
|
487
|
-
if (this.alpha === 255) {
|
|
488
|
-
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
489
|
-
.toString(16)
|
|
490
|
-
.padStart(2, '0')}`;
|
|
491
|
-
}
|
|
492
|
-
else {
|
|
493
|
-
return `#${this.red.toString(16).padStart(2, '0')}${this.green.toString(16).padStart(2, '0')}${this.blue
|
|
494
|
-
.toString(16)
|
|
495
|
-
.padStart(2, '0')}${this.alpha.toString(16).padStart(2, '0')}`;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
toRgb() {
|
|
499
|
-
if (this.alpha === 255) {
|
|
500
|
-
return `rgb(${this.red}, ${this.green}, ${this.blue})`;
|
|
501
|
-
}
|
|
502
|
-
else {
|
|
503
|
-
return `rgba(${this.red}, ${this.green}, ${this.blue}, ${Math.round((this.alpha / 255) * 100)}%)`;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
toHsl() {
|
|
507
|
-
throw new Error(`Getting HSL is not implemented`);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
511
|
/**
|
|
512
512
|
* Checks if the given value is a valid hex color string
|
|
513
513
|
*
|
|
@@ -2017,20 +2017,109 @@
|
|
|
2017
2017
|
// TODO: [🧠] Should be in generated .book.md file GENERATOR_WARNING
|
|
2018
2018
|
|
|
2019
2019
|
/**
|
|
2020
|
-
*
|
|
2021
|
-
*
|
|
2022
|
-
* @returns The same type of object as the input re-ordered
|
|
2020
|
+
* This error indicates that the promptbook object has valid syntax (=can be parsed) but contains logical errors (like circular dependencies)
|
|
2023
2021
|
*
|
|
2024
|
-
* @public exported from `@promptbook/
|
|
2022
|
+
* @public exported from `@promptbook/core`
|
|
2025
2023
|
*/
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2024
|
+
class PipelineLogicError extends Error {
|
|
2025
|
+
constructor(message) {
|
|
2026
|
+
super(message);
|
|
2027
|
+
this.name = 'PipelineLogicError';
|
|
2028
|
+
Object.setPrototypeOf(this, PipelineLogicError.prototype);
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* Creates the shared validation context for one pipeline.
|
|
2034
|
+
*
|
|
2035
|
+
* @private function of `validatePipeline`
|
|
2036
|
+
*/
|
|
2037
|
+
function createPipelineValidationContext(pipeline) {
|
|
2038
|
+
return {
|
|
2039
|
+
pipeline,
|
|
2040
|
+
pipelineIdentification: getPipelineIdentification(pipeline),
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
/**
|
|
2044
|
+
* Builds a short file/url identification block for validation errors.
|
|
2045
|
+
*
|
|
2046
|
+
* @private internal utility of `validatePipeline`
|
|
2047
|
+
*/
|
|
2048
|
+
function getPipelineIdentification(pipeline) {
|
|
2049
|
+
// Note: This is a 😐 implementation of [🚞]
|
|
2050
|
+
const pipelineIdentificationParts = [];
|
|
2051
|
+
if (pipeline.sourceFile !== undefined) {
|
|
2052
|
+
pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
|
|
2053
|
+
}
|
|
2054
|
+
if (pipeline.pipelineUrl !== undefined) {
|
|
2055
|
+
pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
|
|
2056
|
+
}
|
|
2057
|
+
return pipelineIdentificationParts.join('\n');
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
/**
|
|
2061
|
+
* Validates that the expected top-level collections have array structure.
|
|
2062
|
+
*
|
|
2063
|
+
* @private function of `validatePipeline`
|
|
2064
|
+
*/
|
|
2065
|
+
function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification, }) {
|
|
2066
|
+
validatePipelineParametersCollection(pipeline, pipelineIdentification);
|
|
2067
|
+
validatePipelineTasksCollection(pipeline, pipelineIdentification);
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Validates that `pipeline.parameters` is an array.
|
|
2071
|
+
*
|
|
2072
|
+
* @private internal utility of `validatePipelineCollectionsStructure`
|
|
2073
|
+
*/
|
|
2074
|
+
function validatePipelineParametersCollection(pipeline, pipelineIdentification) {
|
|
2075
|
+
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2076
|
+
if (Array.isArray(pipeline.parameters)) {
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2080
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2081
|
+
Pipeline is valid JSON but with wrong structure
|
|
2082
|
+
|
|
2083
|
+
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
2084
|
+
|
|
2085
|
+
${block(pipelineIdentification)}
|
|
2086
|
+
`));
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Validates that `pipeline.tasks` is an array.
|
|
2090
|
+
*
|
|
2091
|
+
* @private internal utility of `validatePipelineCollectionsStructure`
|
|
2092
|
+
*/
|
|
2093
|
+
function validatePipelineTasksCollection(pipeline, pipelineIdentification) {
|
|
2094
|
+
// TODO: [🧠] Maybe do here some proper JSON-schema / ZOD checking
|
|
2095
|
+
if (Array.isArray(pipeline.tasks)) {
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2099
|
+
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2100
|
+
Pipeline is valid JSON but with wrong structure
|
|
2101
|
+
|
|
2102
|
+
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
2103
|
+
|
|
2104
|
+
${block(pipelineIdentification)}
|
|
2105
|
+
`));
|
|
2106
|
+
}
|
|
2107
|
+
|
|
2108
|
+
/**
|
|
2109
|
+
* Orders JSON object by keys
|
|
2110
|
+
*
|
|
2111
|
+
* @returns The same type of object as the input re-ordered
|
|
2112
|
+
*
|
|
2113
|
+
* @public exported from `@promptbook/utils`
|
|
2114
|
+
*/
|
|
2115
|
+
function orderJson(options) {
|
|
2116
|
+
const { value, order } = options;
|
|
2117
|
+
const orderedValue = {
|
|
2118
|
+
...(order === undefined ? {} : Object.fromEntries(order.map((key) => [key, undefined]))),
|
|
2119
|
+
...value,
|
|
2120
|
+
};
|
|
2121
|
+
return orderedValue;
|
|
2122
|
+
}
|
|
2034
2123
|
|
|
2035
2124
|
/**
|
|
2036
2125
|
* Freezes the given object and all its nested objects recursively
|
|
@@ -2379,16 +2468,137 @@
|
|
|
2379
2468
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
2380
2469
|
|
|
2381
2470
|
/**
|
|
2382
|
-
*
|
|
2471
|
+
* Validates that task dependencies can be resolved without cycles or missing definitions.
|
|
2383
2472
|
*
|
|
2384
|
-
* @
|
|
2473
|
+
* @private function of `validatePipeline`
|
|
2385
2474
|
*/
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2475
|
+
function validatePipelineDependencyResolution({ pipeline, pipelineIdentification, }) {
|
|
2476
|
+
let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
|
|
2477
|
+
let loopLimit = LOOP_LIMIT;
|
|
2478
|
+
while (hasUnresolvedTasks(dependencyResolutionState)) {
|
|
2479
|
+
if (loopLimit-- < 0) {
|
|
2480
|
+
throw createDependencyResolutionLoopLimitError(pipelineIdentification);
|
|
2481
|
+
}
|
|
2482
|
+
dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
/**
|
|
2486
|
+
* Collects the parameter names that are already resolvable before dependency traversal starts.
|
|
2487
|
+
*
|
|
2488
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2489
|
+
*/
|
|
2490
|
+
function createInitialDependencyResolutionState(pipeline) {
|
|
2491
|
+
return {
|
|
2492
|
+
resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
|
|
2493
|
+
unresolvedTasks: [...pipeline.tasks],
|
|
2494
|
+
};
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Checks whether dependency resolution still has tasks left to process.
|
|
2498
|
+
*
|
|
2499
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2500
|
+
*/
|
|
2501
|
+
function hasUnresolvedTasks({ unresolvedTasks }) {
|
|
2502
|
+
return unresolvedTasks.length > 0;
|
|
2503
|
+
}
|
|
2504
|
+
/**
|
|
2505
|
+
* Resolves the next batch of currently satisfiable tasks.
|
|
2506
|
+
*
|
|
2507
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2508
|
+
*/
|
|
2509
|
+
function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
|
|
2510
|
+
const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
|
|
2511
|
+
if (currentlyResolvedTasks.length === 0) {
|
|
2512
|
+
throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
|
|
2513
|
+
}
|
|
2514
|
+
return {
|
|
2515
|
+
resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
|
|
2516
|
+
unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
|
|
2517
|
+
};
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* Collects the parameter names that are already resolvable before dependency traversal starts.
|
|
2521
|
+
*
|
|
2522
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2523
|
+
*/
|
|
2524
|
+
function createInitiallyResolvedParameterNames(pipeline) {
|
|
2525
|
+
let resolvedParameterNames = pipeline.parameters
|
|
2526
|
+
.filter(({ isInput }) => isInput)
|
|
2527
|
+
.map(({ name }) => name);
|
|
2528
|
+
for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
|
|
2529
|
+
resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
|
|
2391
2530
|
}
|
|
2531
|
+
return resolvedParameterNames;
|
|
2532
|
+
}
|
|
2533
|
+
/**
|
|
2534
|
+
* Adds newly resolved task outputs to the resolved parameter list.
|
|
2535
|
+
*
|
|
2536
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2537
|
+
*/
|
|
2538
|
+
function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
|
|
2539
|
+
return [
|
|
2540
|
+
...resolvedParameterNames,
|
|
2541
|
+
...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
|
|
2542
|
+
];
|
|
2543
|
+
}
|
|
2544
|
+
/**
|
|
2545
|
+
* Selects tasks whose dependencies are already resolved.
|
|
2546
|
+
*
|
|
2547
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2548
|
+
*/
|
|
2549
|
+
function getCurrentlyResolvedTasks(unresolvedTasks, resolvedParameterNames) {
|
|
2550
|
+
return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Creates the unexpected loop-limit error for dependency resolution.
|
|
2554
|
+
*
|
|
2555
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2556
|
+
*/
|
|
2557
|
+
function createDependencyResolutionLoopLimitError(pipelineIdentification) {
|
|
2558
|
+
// Note: Really UnexpectedError not LimitReachedError - this should not happen and be caught below
|
|
2559
|
+
return new UnexpectedError(spacetrim.spaceTrim((block) => `
|
|
2560
|
+
Loop limit reached during detection of circular dependencies in \`validatePipeline\`
|
|
2561
|
+
|
|
2562
|
+
${block(pipelineIdentification)}
|
|
2563
|
+
`));
|
|
2564
|
+
}
|
|
2565
|
+
/**
|
|
2566
|
+
* Creates the detailed error for unresolved or circular task dependencies.
|
|
2567
|
+
*
|
|
2568
|
+
* @private internal utility of `validatePipelineDependencyResolution`
|
|
2569
|
+
*/
|
|
2570
|
+
function createUnresolvedTasksError(unresolvedTasks, resolvedParameterNames, pipelineIdentification) {
|
|
2571
|
+
return new PipelineLogicError(
|
|
2572
|
+
// TODO: [🐎] DRY
|
|
2573
|
+
spacetrim.spaceTrim((block) => `
|
|
2574
|
+
|
|
2575
|
+
Can not resolve some parameters:
|
|
2576
|
+
Either you are using a parameter that is not defined, or there are some circular dependencies.
|
|
2577
|
+
|
|
2578
|
+
${block(pipelineIdentification)}
|
|
2579
|
+
|
|
2580
|
+
**Can not resolve:**
|
|
2581
|
+
${block(unresolvedTasks
|
|
2582
|
+
.map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
|
|
2583
|
+
.map((dependentParameterName) => `\`{${dependentParameterName}}\``)
|
|
2584
|
+
.join(' and ')}`)
|
|
2585
|
+
.join('\n'))}
|
|
2586
|
+
|
|
2587
|
+
**Resolved:**
|
|
2588
|
+
${block(resolvedParameterNames
|
|
2589
|
+
.filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
|
|
2590
|
+
.map((name) => `- Parameter \`{${name}}\``)
|
|
2591
|
+
.join('\n'))}
|
|
2592
|
+
|
|
2593
|
+
|
|
2594
|
+
**Reserved (which are available):**
|
|
2595
|
+
${block(resolvedParameterNames
|
|
2596
|
+
.filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
|
|
2597
|
+
.map((name) => `- Parameter \`{${name}}\``)
|
|
2598
|
+
.join('\n'))}
|
|
2599
|
+
|
|
2600
|
+
|
|
2601
|
+
`));
|
|
2392
2602
|
}
|
|
2393
2603
|
|
|
2394
2604
|
/**
|
|
@@ -2466,171 +2676,22 @@
|
|
|
2466
2676
|
// TODO: [🐠] Maybe more info why the URL is invalid
|
|
2467
2677
|
|
|
2468
2678
|
/**
|
|
2469
|
-
* Validates
|
|
2470
|
-
*
|
|
2471
|
-
* It checks:
|
|
2472
|
-
* - if it has correct parameters dependency
|
|
2473
|
-
*
|
|
2474
|
-
* It does NOT check:
|
|
2475
|
-
* - if it is valid json
|
|
2476
|
-
* - if it is meaningful
|
|
2477
|
-
*
|
|
2478
|
-
* Note: [🔂] This function is idempotent.
|
|
2679
|
+
* Validates pipeline-level metadata fields.
|
|
2479
2680
|
*
|
|
2480
|
-
* @
|
|
2481
|
-
|
|
2482
|
-
|
|
2681
|
+
* @private function of `validatePipeline`
|
|
2682
|
+
*/
|
|
2683
|
+
function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
|
|
2684
|
+
validatePipelineUrl(pipeline, pipelineIdentification);
|
|
2685
|
+
validatePipelineBookVersion(pipeline, pipelineIdentification);
|
|
2686
|
+
}
|
|
2687
|
+
/**
|
|
2688
|
+
* Validates the pipeline URL, when present.
|
|
2483
2689
|
*
|
|
2484
|
-
* @
|
|
2690
|
+
* @private internal utility of `validatePipelineMetadata`
|
|
2485
2691
|
*/
|
|
2486
|
-
function
|
|
2487
|
-
if (
|
|
2488
|
-
|
|
2489
|
-
}
|
|
2490
|
-
else {
|
|
2491
|
-
try {
|
|
2492
|
-
validatePipeline_InnerFunction(pipeline);
|
|
2493
|
-
}
|
|
2494
|
-
catch (error) {
|
|
2495
|
-
if (!(error instanceof PipelineLogicError)) {
|
|
2496
|
-
throw error;
|
|
2497
|
-
}
|
|
2498
|
-
console.error(spacetrim.spaceTrim((block) => `
|
|
2499
|
-
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2500
|
-
|
|
2501
|
-
${block(error.message)}
|
|
2502
|
-
`));
|
|
2503
|
-
}
|
|
2504
|
-
}
|
|
2505
|
-
return pipeline;
|
|
2506
|
-
}
|
|
2507
|
-
/**
|
|
2508
|
-
* Validates pipeline inner function.
|
|
2509
|
-
*
|
|
2510
|
-
* @private internal function for `validatePipeline`
|
|
2511
|
-
*/
|
|
2512
|
-
function validatePipeline_InnerFunction(pipeline) {
|
|
2513
|
-
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
2514
|
-
const context = createPipelineValidationContext(pipeline);
|
|
2515
|
-
validatePipelineMetadata(context);
|
|
2516
|
-
validatePipelineCollectionsStructure(context);
|
|
2517
|
-
validatePipelineParameters(context);
|
|
2518
|
-
validatePipelineTasks(context);
|
|
2519
|
-
validatePipelineDependencyResolution(context);
|
|
2520
|
-
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
2521
|
-
// TODO: !!6 Implement this
|
|
2522
|
-
// pipeline.formfactorName
|
|
2523
|
-
}
|
|
2524
|
-
/**
|
|
2525
|
-
* Creates the shared validation context for one pipeline.
|
|
2526
|
-
*
|
|
2527
|
-
* @private internal utility of `validatePipeline`
|
|
2528
|
-
*/
|
|
2529
|
-
function createPipelineValidationContext(pipeline) {
|
|
2530
|
-
return {
|
|
2531
|
-
pipeline,
|
|
2532
|
-
pipelineIdentification: getPipelineIdentification(pipeline),
|
|
2533
|
-
};
|
|
2534
|
-
}
|
|
2535
|
-
/**
|
|
2536
|
-
* Builds a short file/url identification block for validation errors.
|
|
2537
|
-
*
|
|
2538
|
-
* @private internal utility of `validatePipeline`
|
|
2539
|
-
*/
|
|
2540
|
-
function getPipelineIdentification(pipeline) {
|
|
2541
|
-
// Note: This is a 😐 implementation of [🚞]
|
|
2542
|
-
const pipelineIdentificationParts = [];
|
|
2543
|
-
if (pipeline.sourceFile !== undefined) {
|
|
2544
|
-
pipelineIdentificationParts.push(`File: ${pipeline.sourceFile}`);
|
|
2545
|
-
}
|
|
2546
|
-
if (pipeline.pipelineUrl !== undefined) {
|
|
2547
|
-
pipelineIdentificationParts.push(`Url: ${pipeline.pipelineUrl}`);
|
|
2548
|
-
}
|
|
2549
|
-
return pipelineIdentificationParts.join('\n');
|
|
2550
|
-
}
|
|
2551
|
-
/**
|
|
2552
|
-
* Validates pipeline-level metadata fields.
|
|
2553
|
-
*
|
|
2554
|
-
* @private internal step of `validatePipeline`
|
|
2555
|
-
*/
|
|
2556
|
-
function validatePipelineMetadata({ pipeline, pipelineIdentification }) {
|
|
2557
|
-
validatePipelineUrl(pipeline, pipelineIdentification);
|
|
2558
|
-
validatePipelineBookVersion(pipeline, pipelineIdentification);
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* Validates that the expected top-level collections have array structure.
|
|
2562
|
-
*
|
|
2563
|
-
* @private internal step of `validatePipeline`
|
|
2564
|
-
*/
|
|
2565
|
-
function validatePipelineCollectionsStructure({ pipeline, pipelineIdentification }) {
|
|
2566
|
-
validatePipelineParametersCollection(pipeline, pipelineIdentification);
|
|
2567
|
-
validatePipelineTasksCollection(pipeline, pipelineIdentification);
|
|
2568
|
-
}
|
|
2569
|
-
/**
|
|
2570
|
-
* Validates all pipeline parameter declarations.
|
|
2571
|
-
*
|
|
2572
|
-
* @private internal step of `validatePipeline`
|
|
2573
|
-
*/
|
|
2574
|
-
function validatePipelineParameters({ pipeline, pipelineIdentification }) {
|
|
2575
|
-
for (const parameter of pipeline.parameters) {
|
|
2576
|
-
validatePipelineParameter(parameter, pipeline, pipelineIdentification);
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
/**
|
|
2580
|
-
* Validates all pipeline tasks and their per-task invariants.
|
|
2581
|
-
*
|
|
2582
|
-
* @private internal step of `validatePipeline`
|
|
2583
|
-
*/
|
|
2584
|
-
function validatePipelineTasks({ pipeline, pipelineIdentification }) {
|
|
2585
|
-
// Note: All input parameters are defined - so that they can be used as result of some task
|
|
2586
|
-
const definedParameters = createInitiallyDefinedParameters(pipeline);
|
|
2587
|
-
for (const task of pipeline.tasks) {
|
|
2588
|
-
validatePipelineTask(task, definedParameters, pipelineIdentification);
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
/**
|
|
2592
|
-
* Validates that task dependencies can be resolved without cycles or missing definitions.
|
|
2593
|
-
*
|
|
2594
|
-
* @private internal step of `validatePipeline`
|
|
2595
|
-
*/
|
|
2596
|
-
function validatePipelineDependencyResolution({ pipeline, pipelineIdentification }) {
|
|
2597
|
-
let dependencyResolutionState = createInitialDependencyResolutionState(pipeline);
|
|
2598
|
-
let loopLimit = LOOP_LIMIT;
|
|
2599
|
-
while (hasUnresolvedTasks(dependencyResolutionState)) {
|
|
2600
|
-
if (loopLimit-- < 0) {
|
|
2601
|
-
throw createDependencyResolutionLoopLimitError(pipelineIdentification);
|
|
2602
|
-
}
|
|
2603
|
-
dependencyResolutionState = resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification);
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
/**
|
|
2607
|
-
* Validates one pipeline parameter declaration.
|
|
2608
|
-
*
|
|
2609
|
-
* @private internal step of `validatePipeline`
|
|
2610
|
-
*/
|
|
2611
|
-
function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
|
|
2612
|
-
validateParameterDirection(parameter, pipelineIdentification);
|
|
2613
|
-
validateParameterUsage(parameter, pipeline, pipelineIdentification);
|
|
2614
|
-
validateParameterDefinition(parameter, pipeline, pipelineIdentification);
|
|
2615
|
-
}
|
|
2616
|
-
/**
|
|
2617
|
-
* Validates one pipeline task and its invariants.
|
|
2618
|
-
*
|
|
2619
|
-
* @private internal step of `validatePipeline`
|
|
2620
|
-
*/
|
|
2621
|
-
function validatePipelineTask(task, definedParameters, pipelineIdentification) {
|
|
2622
|
-
validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
|
|
2623
|
-
validateTaskJokers(task, pipelineIdentification);
|
|
2624
|
-
validateTaskExpectations(task, pipelineIdentification);
|
|
2625
|
-
}
|
|
2626
|
-
/**
|
|
2627
|
-
* Validates the pipeline URL, when present.
|
|
2628
|
-
*
|
|
2629
|
-
* @private internal utility of `validatePipeline`
|
|
2630
|
-
*/
|
|
2631
|
-
function validatePipelineUrl(pipeline, pipelineIdentification) {
|
|
2632
|
-
if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2633
|
-
return;
|
|
2692
|
+
function validatePipelineUrl(pipeline, pipelineIdentification) {
|
|
2693
|
+
if (pipeline.pipelineUrl === undefined || isValidPipelineUrl(pipeline.pipelineUrl)) {
|
|
2694
|
+
return;
|
|
2634
2695
|
}
|
|
2635
2696
|
// <- Note: [🚲]
|
|
2636
2697
|
throw new PipelineLogicError(spacetrim.spaceTrim((block) => `
|
|
@@ -2642,7 +2703,7 @@
|
|
|
2642
2703
|
/**
|
|
2643
2704
|
* Validates the Promptbook version, when present.
|
|
2644
2705
|
*
|
|
2645
|
-
* @private internal utility of `
|
|
2706
|
+
* @private internal utility of `validatePipelineMetadata`
|
|
2646
2707
|
*/
|
|
2647
2708
|
function validatePipelineBookVersion(pipeline, pipelineIdentification) {
|
|
2648
2709
|
if (pipeline.bookVersion === undefined || isValidPromptbookVersion(pipeline.bookVersion)) {
|
|
@@ -2655,48 +2716,31 @@
|
|
|
2655
2716
|
${block(pipelineIdentification)}
|
|
2656
2717
|
`));
|
|
2657
2718
|
}
|
|
2719
|
+
|
|
2658
2720
|
/**
|
|
2659
|
-
* Validates
|
|
2721
|
+
* Validates all pipeline parameter declarations.
|
|
2660
2722
|
*
|
|
2661
|
-
* @private
|
|
2723
|
+
* @private function of `validatePipeline`
|
|
2662
2724
|
*/
|
|
2663
|
-
function
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
return;
|
|
2725
|
+
function validatePipelineParameters({ pipeline, pipelineIdentification }) {
|
|
2726
|
+
for (const parameter of pipeline.parameters) {
|
|
2727
|
+
validatePipelineParameter(parameter, pipeline, pipelineIdentification);
|
|
2667
2728
|
}
|
|
2668
|
-
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2669
|
-
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2670
|
-
Pipeline is valid JSON but with wrong structure
|
|
2671
|
-
|
|
2672
|
-
\`PipelineJson.parameters\` expected to be an array, but got ${typeof pipeline.parameters}
|
|
2673
|
-
|
|
2674
|
-
${block(pipelineIdentification)}
|
|
2675
|
-
`));
|
|
2676
2729
|
}
|
|
2677
2730
|
/**
|
|
2678
|
-
* Validates
|
|
2731
|
+
* Validates one pipeline parameter declaration.
|
|
2679
2732
|
*
|
|
2680
|
-
* @private internal utility of `
|
|
2733
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2681
2734
|
*/
|
|
2682
|
-
function
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
}
|
|
2687
|
-
// TODO: [🧠] what is the correct error tp throw - maybe PromptbookSchemaError
|
|
2688
|
-
throw new ParseError(spacetrim.spaceTrim((block) => `
|
|
2689
|
-
Pipeline is valid JSON but with wrong structure
|
|
2690
|
-
|
|
2691
|
-
\`PipelineJson.tasks\` expected to be an array, but got ${typeof pipeline.tasks}
|
|
2692
|
-
|
|
2693
|
-
${block(pipelineIdentification)}
|
|
2694
|
-
`));
|
|
2735
|
+
function validatePipelineParameter(parameter, pipeline, pipelineIdentification) {
|
|
2736
|
+
validateParameterDirection(parameter, pipelineIdentification);
|
|
2737
|
+
validateParameterUsage(parameter, pipeline, pipelineIdentification);
|
|
2738
|
+
validateParameterDefinition(parameter, pipeline, pipelineIdentification);
|
|
2695
2739
|
}
|
|
2696
2740
|
/**
|
|
2697
2741
|
* Validates that one parameter does not declare incompatible directions.
|
|
2698
2742
|
*
|
|
2699
|
-
* @private internal utility of `
|
|
2743
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2700
2744
|
*/
|
|
2701
2745
|
function validateParameterDirection(parameter, pipelineIdentification) {
|
|
2702
2746
|
if (!parameter.isInput || !parameter.isOutput) {
|
|
@@ -2713,7 +2757,7 @@
|
|
|
2713
2757
|
/**
|
|
2714
2758
|
* Validates that one intermediate parameter is actually consumed by at least one task.
|
|
2715
2759
|
*
|
|
2716
|
-
* @private internal utility of `
|
|
2760
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2717
2761
|
*/
|
|
2718
2762
|
function validateParameterUsage(parameter, pipeline, pipelineIdentification) {
|
|
2719
2763
|
if (parameter.isInput || parameter.isOutput || isParameterUsedByAnyTask(parameter, pipeline.tasks)) {
|
|
@@ -2732,7 +2776,7 @@
|
|
|
2732
2776
|
/**
|
|
2733
2777
|
* Validates that one non-input parameter is produced by at least one task.
|
|
2734
2778
|
*
|
|
2735
|
-
* @private internal utility of `
|
|
2779
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2736
2780
|
*/
|
|
2737
2781
|
function validateParameterDefinition(parameter, pipeline, pipelineIdentification) {
|
|
2738
2782
|
if (parameter.isInput || isParameterDefinedByAnyTask(parameter, pipeline.tasks)) {
|
|
@@ -2751,7 +2795,7 @@
|
|
|
2751
2795
|
/**
|
|
2752
2796
|
* Checks whether one parameter is consumed by at least one task dependency list.
|
|
2753
2797
|
*
|
|
2754
|
-
* @private internal utility of `
|
|
2798
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2755
2799
|
*/
|
|
2756
2800
|
function isParameterUsedByAnyTask(parameter, tasks) {
|
|
2757
2801
|
return tasks.some((task) => task.dependentParameterNames.includes(parameter.name));
|
|
@@ -2759,23 +2803,46 @@
|
|
|
2759
2803
|
/**
|
|
2760
2804
|
* Checks whether one parameter is produced by at least one task.
|
|
2761
2805
|
*
|
|
2762
|
-
* @private internal utility of `
|
|
2806
|
+
* @private internal utility of `validatePipelineParameters`
|
|
2763
2807
|
*/
|
|
2764
2808
|
function isParameterDefinedByAnyTask(parameter, tasks) {
|
|
2765
2809
|
return tasks.some((task) => task.resultingParameterName === parameter.name);
|
|
2766
2810
|
}
|
|
2811
|
+
|
|
2812
|
+
/**
|
|
2813
|
+
* Validates all pipeline tasks and their per-task invariants.
|
|
2814
|
+
*
|
|
2815
|
+
* @private function of `validatePipeline`
|
|
2816
|
+
*/
|
|
2817
|
+
function validatePipelineTasks({ pipeline, pipelineIdentification }) {
|
|
2818
|
+
// Note: All input parameters are defined - so that they can be used as result of some task
|
|
2819
|
+
const definedParameters = createInitiallyDefinedParameters(pipeline);
|
|
2820
|
+
for (const task of pipeline.tasks) {
|
|
2821
|
+
validatePipelineTask(task, definedParameters, pipelineIdentification);
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2767
2824
|
/**
|
|
2768
2825
|
* Collects the parameter names that are already defined before task validation starts.
|
|
2769
2826
|
*
|
|
2770
|
-
* @private internal utility of `
|
|
2827
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2771
2828
|
*/
|
|
2772
2829
|
function createInitiallyDefinedParameters(pipeline) {
|
|
2773
2830
|
return new Set(pipeline.parameters.filter(({ isInput }) => isInput).map(({ name }) => name));
|
|
2774
2831
|
}
|
|
2832
|
+
/**
|
|
2833
|
+
* Validates one pipeline task and its invariants.
|
|
2834
|
+
*
|
|
2835
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2836
|
+
*/
|
|
2837
|
+
function validatePipelineTask(task, definedParameters, pipelineIdentification) {
|
|
2838
|
+
validateTaskResultingParameter(task, definedParameters, pipelineIdentification);
|
|
2839
|
+
validateTaskJokers(task, pipelineIdentification);
|
|
2840
|
+
validateTaskExpectations(task, pipelineIdentification);
|
|
2841
|
+
}
|
|
2775
2842
|
/**
|
|
2776
2843
|
* Validates one task result parameter declaration and marks it as defined.
|
|
2777
2844
|
*
|
|
2778
|
-
* @private internal utility of `
|
|
2845
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2779
2846
|
*/
|
|
2780
2847
|
function validateTaskResultingParameter(task, definedParameters, pipelineIdentification) {
|
|
2781
2848
|
if (definedParameters.has(task.resultingParameterName)) {
|
|
@@ -2797,7 +2864,7 @@
|
|
|
2797
2864
|
/**
|
|
2798
2865
|
* Validates joker parameters for one task.
|
|
2799
2866
|
*
|
|
2800
|
-
* @private internal utility of `
|
|
2867
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2801
2868
|
*/
|
|
2802
2869
|
function validateTaskJokers(task, pipelineIdentification) {
|
|
2803
2870
|
if (!hasTaskJokers(task)) {
|
|
@@ -2809,7 +2876,7 @@
|
|
|
2809
2876
|
/**
|
|
2810
2877
|
* Checks whether one task declares any joker parameters.
|
|
2811
2878
|
*
|
|
2812
|
-
* @private internal utility of `
|
|
2879
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2813
2880
|
*/
|
|
2814
2881
|
function hasTaskJokers(task) {
|
|
2815
2882
|
return !!task.jokerParameterNames && task.jokerParameterNames.length > 0;
|
|
@@ -2817,7 +2884,7 @@
|
|
|
2817
2884
|
/**
|
|
2818
2885
|
* Validates that a task has the required supporting features when using jokers.
|
|
2819
2886
|
*
|
|
2820
|
-
* @private internal utility of `
|
|
2887
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2821
2888
|
*/
|
|
2822
2889
|
function validateTaskSupportsJokers(task, pipelineIdentification) {
|
|
2823
2890
|
if (task.format || task.expectations /* <- TODO: Require at least 1 -> min <- expectation to use jokers */) {
|
|
@@ -2832,7 +2899,7 @@
|
|
|
2832
2899
|
/**
|
|
2833
2900
|
* Validates that every joker parameter is also listed among task dependencies.
|
|
2834
2901
|
*
|
|
2835
|
-
* @private internal utility of `
|
|
2902
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2836
2903
|
*/
|
|
2837
2904
|
function validateTaskJokerDependencies(task, pipelineIdentification) {
|
|
2838
2905
|
for (const joker of task.jokerParameterNames) {
|
|
@@ -2849,7 +2916,7 @@
|
|
|
2849
2916
|
/**
|
|
2850
2917
|
* Validates all expectation bounds configured on one task.
|
|
2851
2918
|
*
|
|
2852
|
-
* @private internal utility of `
|
|
2919
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2853
2920
|
*/
|
|
2854
2921
|
function validateTaskExpectations(task, pipelineIdentification) {
|
|
2855
2922
|
if (!task.expectations) {
|
|
@@ -2864,7 +2931,7 @@
|
|
|
2864
2931
|
/**
|
|
2865
2932
|
* Validates the minimum and maximum expectation ordering for one unit.
|
|
2866
2933
|
*
|
|
2867
|
-
* @private internal utility of `
|
|
2934
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2868
2935
|
*/
|
|
2869
2936
|
function validateTaskExpectationRange(unit, min, max, pipelineIdentification) {
|
|
2870
2937
|
if (min === undefined || max === undefined || min <= max) {
|
|
@@ -2879,7 +2946,7 @@
|
|
|
2879
2946
|
/**
|
|
2880
2947
|
* Validates the minimum expectation bound for one unit.
|
|
2881
2948
|
*
|
|
2882
|
-
* @private internal utility of `
|
|
2949
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2883
2950
|
*/
|
|
2884
2951
|
function validateTaskExpectationMin(unit, min, pipelineIdentification) {
|
|
2885
2952
|
if (min === undefined || min >= 0) {
|
|
@@ -2894,7 +2961,7 @@
|
|
|
2894
2961
|
/**
|
|
2895
2962
|
* Validates the maximum expectation bound for one unit.
|
|
2896
2963
|
*
|
|
2897
|
-
* @private internal utility of `
|
|
2964
|
+
* @private internal utility of `validatePipelineTasks`
|
|
2898
2965
|
*/
|
|
2899
2966
|
function validateTaskExpectationMax(unit, max, pipelineIdentification) {
|
|
2900
2967
|
if (max === undefined || max > 0) {
|
|
@@ -2906,123 +2973,62 @@
|
|
|
2906
2973
|
${block(pipelineIdentification)}
|
|
2907
2974
|
`));
|
|
2908
2975
|
}
|
|
2976
|
+
|
|
2909
2977
|
/**
|
|
2910
|
-
*
|
|
2911
|
-
*
|
|
2912
|
-
* @private internal utility of `validatePipeline`
|
|
2913
|
-
*/
|
|
2914
|
-
function createInitialDependencyResolutionState(pipeline) {
|
|
2915
|
-
return {
|
|
2916
|
-
resolvedParameterNames: createInitiallyResolvedParameterNames(pipeline),
|
|
2917
|
-
unresolvedTasks: [...pipeline.tasks],
|
|
2918
|
-
};
|
|
2919
|
-
}
|
|
2920
|
-
/**
|
|
2921
|
-
* Checks whether dependency resolution still has tasks left to process.
|
|
2922
|
-
*
|
|
2923
|
-
* @private internal utility of `validatePipeline`
|
|
2924
|
-
*/
|
|
2925
|
-
function hasUnresolvedTasks({ unresolvedTasks }) {
|
|
2926
|
-
return unresolvedTasks.length > 0;
|
|
2927
|
-
}
|
|
2928
|
-
/**
|
|
2929
|
-
* Resolves the next batch of currently satisfiable tasks.
|
|
2978
|
+
* Validates PipelineJson if it is logically valid
|
|
2930
2979
|
*
|
|
2931
|
-
*
|
|
2932
|
-
|
|
2933
|
-
function resolveNextDependencyResolutionState(dependencyResolutionState, pipelineIdentification) {
|
|
2934
|
-
const currentlyResolvedTasks = getCurrentlyResolvedTasks(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames);
|
|
2935
|
-
if (currentlyResolvedTasks.length === 0) {
|
|
2936
|
-
throw createUnresolvedTasksError(dependencyResolutionState.unresolvedTasks, dependencyResolutionState.resolvedParameterNames, pipelineIdentification);
|
|
2937
|
-
}
|
|
2938
|
-
return {
|
|
2939
|
-
resolvedParameterNames: appendResolvedTaskParameterNames(dependencyResolutionState.resolvedParameterNames, currentlyResolvedTasks),
|
|
2940
|
-
unresolvedTasks: dependencyResolutionState.unresolvedTasks.filter((task) => !currentlyResolvedTasks.includes(task)),
|
|
2941
|
-
};
|
|
2942
|
-
}
|
|
2943
|
-
/**
|
|
2944
|
-
* Collects the parameter names that are already resolvable before dependency traversal starts.
|
|
2980
|
+
* It checks:
|
|
2981
|
+
* - if it has correct parameters dependency
|
|
2945
2982
|
*
|
|
2946
|
-
*
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
let resolvedParameterNames = pipeline.parameters
|
|
2950
|
-
.filter(({ isInput }) => isInput)
|
|
2951
|
-
.map(({ name }) => name);
|
|
2952
|
-
for (const reservedParameterName of RESERVED_PARAMETER_NAMES) {
|
|
2953
|
-
resolvedParameterNames = [...resolvedParameterNames, reservedParameterName];
|
|
2954
|
-
}
|
|
2955
|
-
return resolvedParameterNames;
|
|
2956
|
-
}
|
|
2957
|
-
/**
|
|
2958
|
-
* Adds newly resolved task outputs to the resolved parameter list.
|
|
2983
|
+
* It does NOT check:
|
|
2984
|
+
* - if it is valid json
|
|
2985
|
+
* - if it is meaningful
|
|
2959
2986
|
*
|
|
2960
|
-
*
|
|
2961
|
-
*/
|
|
2962
|
-
function appendResolvedTaskParameterNames(resolvedParameterNames, currentlyResolvedTasks) {
|
|
2963
|
-
return [
|
|
2964
|
-
...resolvedParameterNames,
|
|
2965
|
-
...currentlyResolvedTasks.map(({ resultingParameterName }) => resultingParameterName),
|
|
2966
|
-
];
|
|
2967
|
-
}
|
|
2968
|
-
/**
|
|
2969
|
-
* Selects tasks whose dependencies are already resolved.
|
|
2987
|
+
* Note: [🔂] This function is idempotent.
|
|
2970
2988
|
*
|
|
2971
|
-
* @
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
return unresolvedTasks.filter((task) => task.dependentParameterNames.every((name) => resolvedParameterNames.includes(name)));
|
|
2975
|
-
}
|
|
2976
|
-
/**
|
|
2977
|
-
* Creates the unexpected loop-limit error for dependency resolution.
|
|
2989
|
+
* @param pipeline valid or invalid PipelineJson
|
|
2990
|
+
* @returns the same pipeline if it is logically valid
|
|
2991
|
+
* @throws {PipelineLogicError} on logical error in the pipeline
|
|
2978
2992
|
*
|
|
2979
|
-
* @
|
|
2993
|
+
* @public exported from `@promptbook/core`
|
|
2980
2994
|
*/
|
|
2981
|
-
function
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2995
|
+
function validatePipeline(pipeline) {
|
|
2996
|
+
if (IS_PIPELINE_LOGIC_VALIDATED) {
|
|
2997
|
+
validatePipeline_InnerFunction(pipeline);
|
|
2998
|
+
}
|
|
2999
|
+
else {
|
|
3000
|
+
try {
|
|
3001
|
+
validatePipeline_InnerFunction(pipeline);
|
|
3002
|
+
}
|
|
3003
|
+
catch (error) {
|
|
3004
|
+
if (!(error instanceof PipelineLogicError)) {
|
|
3005
|
+
throw error;
|
|
3006
|
+
}
|
|
3007
|
+
console.error(spacetrim.spaceTrim((block) => `
|
|
3008
|
+
Pipeline is not valid but logic errors are temporarily disabled via \`IS_PIPELINE_LOGIC_VALIDATED\`
|
|
2985
3009
|
|
|
2986
|
-
|
|
2987
|
-
|
|
3010
|
+
${block(error.message)}
|
|
3011
|
+
`));
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
return pipeline;
|
|
2988
3015
|
}
|
|
2989
3016
|
/**
|
|
2990
|
-
*
|
|
3017
|
+
* Validates pipeline inner function.
|
|
2991
3018
|
*
|
|
2992
|
-
* @private internal
|
|
3019
|
+
* @private internal function for `validatePipeline`
|
|
2993
3020
|
*/
|
|
2994
|
-
function
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
${block(unresolvedTasks
|
|
3006
|
-
.map(({ resultingParameterName, dependentParameterNames }) => `- Parameter \`{${resultingParameterName}}\` which depends on ${dependentParameterNames
|
|
3007
|
-
.map((dependentParameterName) => `\`{${dependentParameterName}}\``)
|
|
3008
|
-
.join(' and ')}`)
|
|
3009
|
-
.join('\n'))}
|
|
3010
|
-
|
|
3011
|
-
**Resolved:**
|
|
3012
|
-
${block(resolvedParameterNames
|
|
3013
|
-
.filter((name) => !RESERVED_PARAMETER_NAMES.includes(name))
|
|
3014
|
-
.map((name) => `- Parameter \`{${name}}\``)
|
|
3015
|
-
.join('\n'))}
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
**Reserved (which are available):**
|
|
3019
|
-
${block(resolvedParameterNames
|
|
3020
|
-
.filter((name) => RESERVED_PARAMETER_NAMES.includes(name))
|
|
3021
|
-
.map((name) => `- Parameter \`{${name}}\``)
|
|
3022
|
-
.join('\n'))}
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
`));
|
|
3021
|
+
function validatePipeline_InnerFunction(pipeline) {
|
|
3022
|
+
// TODO: [🧠] Maybe test if promptbook is a promise and make specific error case for that
|
|
3023
|
+
const context = createPipelineValidationContext(pipeline);
|
|
3024
|
+
validatePipelineMetadata(context);
|
|
3025
|
+
validatePipelineCollectionsStructure(context);
|
|
3026
|
+
validatePipelineParameters(context);
|
|
3027
|
+
validatePipelineTasks(context);
|
|
3028
|
+
validatePipelineDependencyResolution(context);
|
|
3029
|
+
// Note: Check that formfactor is corresponding to the pipeline interface
|
|
3030
|
+
// TODO: !!6 Implement this
|
|
3031
|
+
// pipeline.formfactorName
|
|
3026
3032
|
}
|
|
3027
3033
|
/**
|
|
3028
3034
|
* TODO: [🧞♀️] Do not allow joker + foreach
|