@promptbook/remote-client 0.103.0-1 → 0.103.0-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +153 -89
- package/esm/index.es.js +244 -172
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +20 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +58 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +19 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +10 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileTooltip.d.ts +15 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +83 -8
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +5 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +13 -0
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +32 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +15 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +5 -5
- package/umd/index.umd.js +207 -135
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim$
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { randomBytes } from 'crypto';
|
|
3
3
|
import { io } from 'socket.io-client';
|
|
4
4
|
import { SHA256 } from 'crypto-js';
|
|
@@ -13,14 +13,14 @@ import { basename } from 'path';
|
|
|
13
13
|
* @generated
|
|
14
14
|
* @see https://github.com/webgptorg/book
|
|
15
15
|
*/
|
|
16
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
16
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
17
17
|
/**
|
|
18
18
|
* The version of the Promptbook engine
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
* @see https://github.com/webgptorg/promptbook
|
|
22
22
|
*/
|
|
23
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
23
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
|
|
24
24
|
/**
|
|
25
25
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
26
26
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -82,6 +82,22 @@ class CollectionError extends Error {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* This error indicates error from the database
|
|
87
|
+
*
|
|
88
|
+
* @public exported from `@promptbook/core`
|
|
89
|
+
*/
|
|
90
|
+
class DatabaseError extends Error {
|
|
91
|
+
constructor(message) {
|
|
92
|
+
super(message);
|
|
93
|
+
this.name = 'DatabaseError';
|
|
94
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
99
|
+
*/
|
|
100
|
+
|
|
85
101
|
/**
|
|
86
102
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
87
103
|
*
|
|
@@ -144,7 +160,7 @@ class LimitReachedError extends Error {
|
|
|
144
160
|
*/
|
|
145
161
|
class MissingToolsError extends Error {
|
|
146
162
|
constructor(message) {
|
|
147
|
-
super(spaceTrim((block) => `
|
|
163
|
+
super(spaceTrim$1((block) => `
|
|
148
164
|
${block(message)}
|
|
149
165
|
|
|
150
166
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -155,6 +171,19 @@ class MissingToolsError extends Error {
|
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
173
|
|
|
174
|
+
/**
|
|
175
|
+
* This error indicates that promptbook operation is not allowed
|
|
176
|
+
*
|
|
177
|
+
* @public exported from `@promptbook/core`
|
|
178
|
+
*/
|
|
179
|
+
class NotAllowed extends Error {
|
|
180
|
+
constructor(message) {
|
|
181
|
+
super(message);
|
|
182
|
+
this.name = 'NotAllowed';
|
|
183
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
158
187
|
/**
|
|
159
188
|
* This error indicates that promptbook not found in the collection
|
|
160
189
|
*
|
|
@@ -175,7 +204,7 @@ class NotFoundError extends Error {
|
|
|
175
204
|
*/
|
|
176
205
|
class NotYetImplementedError extends Error {
|
|
177
206
|
constructor(message) {
|
|
178
|
-
super(spaceTrim((block) => `
|
|
207
|
+
super(spaceTrim$1((block) => `
|
|
179
208
|
${block(message)}
|
|
180
209
|
|
|
181
210
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -210,6 +239,7 @@ class ParseError extends Error {
|
|
|
210
239
|
/**
|
|
211
240
|
* Generates random token
|
|
212
241
|
*
|
|
242
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
213
243
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
214
244
|
*
|
|
215
245
|
* @private internal helper function
|
|
@@ -219,6 +249,7 @@ function $randomToken(randomness) {
|
|
|
219
249
|
return randomBytes(randomness).toString('hex');
|
|
220
250
|
}
|
|
221
251
|
/**
|
|
252
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
222
253
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
223
254
|
*/
|
|
224
255
|
|
|
@@ -280,6 +311,17 @@ class PromptbookFetchError extends Error {
|
|
|
280
311
|
}
|
|
281
312
|
}
|
|
282
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Trims string from all 4 sides
|
|
316
|
+
*
|
|
317
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
318
|
+
* Developed by same author @hejny as this package
|
|
319
|
+
*
|
|
320
|
+
* @public exported from `@promptbook/utils`
|
|
321
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
322
|
+
*/
|
|
323
|
+
const spaceTrim = spaceTrim$1;
|
|
324
|
+
|
|
283
325
|
/**
|
|
284
326
|
* @private util of `@promptbook/color`
|
|
285
327
|
* @de
|
|
@@ -328,6 +370,7 @@ function take(initialValue) {
|
|
|
328
370
|
* @public exported from `@promptbook/color`
|
|
329
371
|
*/
|
|
330
372
|
const CSS_COLORS = {
|
|
373
|
+
promptbook: '#79EAFD',
|
|
331
374
|
transparent: 'rgba(0,0,0,0)',
|
|
332
375
|
aliceblue: '#f0f8ff',
|
|
333
376
|
antiquewhite: '#faebd7',
|
|
@@ -509,9 +552,6 @@ function checkChannelValue(channelName, value) {
|
|
|
509
552
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
510
553
|
}
|
|
511
554
|
}
|
|
512
|
-
/**
|
|
513
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
514
|
-
*/
|
|
515
555
|
|
|
516
556
|
/**
|
|
517
557
|
* Color object represents an RGB color with alpha channel
|
|
@@ -546,6 +586,28 @@ class Color {
|
|
|
546
586
|
throw new Error(`Can not create color from given object`);
|
|
547
587
|
}
|
|
548
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* Creates a new Color instance from miscellaneous formats
|
|
591
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
592
|
+
*
|
|
593
|
+
* @param color
|
|
594
|
+
* @returns Color object
|
|
595
|
+
*/
|
|
596
|
+
static fromSafe(color) {
|
|
597
|
+
try {
|
|
598
|
+
return Color.from(color);
|
|
599
|
+
}
|
|
600
|
+
catch (error) {
|
|
601
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
602
|
+
console.warn(spaceTrim((block) => `
|
|
603
|
+
Color.fromSafe error:
|
|
604
|
+
${block(error.message)}
|
|
605
|
+
|
|
606
|
+
Returning default PROMPTBOOK_COLOR.
|
|
607
|
+
`));
|
|
608
|
+
return Color.fromString('promptbook');
|
|
609
|
+
}
|
|
610
|
+
}
|
|
549
611
|
/**
|
|
550
612
|
* Creates a new Color instance from miscellaneous string formats
|
|
551
613
|
*
|
|
@@ -613,6 +675,9 @@ class Color {
|
|
|
613
675
|
if (hex.length === 3) {
|
|
614
676
|
return Color.fromHex3(hex);
|
|
615
677
|
}
|
|
678
|
+
if (hex.length === 4) {
|
|
679
|
+
return Color.fromHex4(hex);
|
|
680
|
+
}
|
|
616
681
|
if (hex.length === 6) {
|
|
617
682
|
return Color.fromHex6(hex);
|
|
618
683
|
}
|
|
@@ -633,6 +698,19 @@ class Color {
|
|
|
633
698
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
634
699
|
return take(new Color(r, g, b));
|
|
635
700
|
}
|
|
701
|
+
/**
|
|
702
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
703
|
+
*
|
|
704
|
+
* @param color in hex for example `09df`
|
|
705
|
+
* @returns Color object
|
|
706
|
+
*/
|
|
707
|
+
static fromHex4(hex) {
|
|
708
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
709
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
710
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
711
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
712
|
+
return take(new Color(r, g, b, a));
|
|
713
|
+
}
|
|
636
714
|
/**
|
|
637
715
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
638
716
|
*
|
|
@@ -823,7 +901,8 @@ class Color {
|
|
|
823
901
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
824
902
|
*/
|
|
825
903
|
static isHexColorString(value) {
|
|
826
|
-
return typeof value === 'string' &&
|
|
904
|
+
return (typeof value === 'string' &&
|
|
905
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
827
906
|
}
|
|
828
907
|
/**
|
|
829
908
|
* Creates new Color object
|
|
@@ -938,6 +1017,23 @@ class Color {
|
|
|
938
1017
|
* TODO: Maybe connect with textures
|
|
939
1018
|
*/
|
|
940
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
1022
|
+
*
|
|
1023
|
+
* @param amount from 0 to 1
|
|
1024
|
+
*
|
|
1025
|
+
* @public exported from `@promptbook/color`
|
|
1026
|
+
*/
|
|
1027
|
+
function grayscale(amount) {
|
|
1028
|
+
return ({ red, green, blue, alpha }) => {
|
|
1029
|
+
const average = (red + green + blue) / 3;
|
|
1030
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
1031
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
1032
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1033
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
1034
|
+
};
|
|
1035
|
+
}
|
|
1036
|
+
|
|
941
1037
|
/**
|
|
942
1038
|
* Converts HSL values to RGB values
|
|
943
1039
|
*
|
|
@@ -1053,102 +1149,6 @@ function lighten(amount) {
|
|
|
1053
1149
|
* TODO: Maybe implement by mix+hsl
|
|
1054
1150
|
*/
|
|
1055
1151
|
|
|
1056
|
-
/**
|
|
1057
|
-
* Calculates distance between two colors
|
|
1058
|
-
*
|
|
1059
|
-
* @param color1 first color
|
|
1060
|
-
* @param color2 second color
|
|
1061
|
-
*
|
|
1062
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
1063
|
-
*
|
|
1064
|
-
* @public exported from `@promptbook/color`
|
|
1065
|
-
*/
|
|
1066
|
-
/**
|
|
1067
|
-
* Calculates distance between two colors without square root
|
|
1068
|
-
*
|
|
1069
|
-
* @param color1 first color
|
|
1070
|
-
* @param color2 second color
|
|
1071
|
-
*
|
|
1072
|
-
* @public exported from `@promptbook/color`
|
|
1073
|
-
*/
|
|
1074
|
-
function colorDistanceSquared(color1, color2) {
|
|
1075
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
1076
|
-
const r = color1.red - color2.red;
|
|
1077
|
-
const g = color1.green - color2.green;
|
|
1078
|
-
const b = color1.blue - color2.blue;
|
|
1079
|
-
const weightR = 2 + rmean / 256;
|
|
1080
|
-
const weightG = 4.0;
|
|
1081
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
1082
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
1083
|
-
return distance;
|
|
1084
|
-
}
|
|
1085
|
-
|
|
1086
|
-
/**
|
|
1087
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
1088
|
-
*
|
|
1089
|
-
* @param colors array of colors to choose from
|
|
1090
|
-
*
|
|
1091
|
-
* @public exported from `@promptbook/color`
|
|
1092
|
-
*/
|
|
1093
|
-
function nearest(...colors) {
|
|
1094
|
-
return (color) => {
|
|
1095
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
1096
|
-
const minDistance = Math.min(...distances);
|
|
1097
|
-
const minIndex = distances.indexOf(minDistance);
|
|
1098
|
-
const nearestColor = colors[minIndex];
|
|
1099
|
-
return nearestColor;
|
|
1100
|
-
};
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
/**
|
|
1104
|
-
* Color transformer which returns the negative color
|
|
1105
|
-
*
|
|
1106
|
-
* @public exported from `@promptbook/color`
|
|
1107
|
-
*/
|
|
1108
|
-
function negative(color) {
|
|
1109
|
-
const r = 255 - color.red;
|
|
1110
|
-
const g = 255 - color.green;
|
|
1111
|
-
const b = 255 - color.blue;
|
|
1112
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
/**
|
|
1116
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1117
|
-
*
|
|
1118
|
-
* @param colors array of colors to choose from
|
|
1119
|
-
*
|
|
1120
|
-
* @public exported from `@promptbook/color`
|
|
1121
|
-
*/
|
|
1122
|
-
function furthest(...colors) {
|
|
1123
|
-
return (color) => {
|
|
1124
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1125
|
-
return furthestColor;
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1130
|
-
*
|
|
1131
|
-
* @public exported from `@promptbook/color`
|
|
1132
|
-
*/
|
|
1133
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1134
|
-
|
|
1135
|
-
/**
|
|
1136
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1137
|
-
*
|
|
1138
|
-
* @param amount from 0 to 1
|
|
1139
|
-
*
|
|
1140
|
-
* @public exported from `@promptbook/color`
|
|
1141
|
-
*/
|
|
1142
|
-
function grayscale(amount) {
|
|
1143
|
-
return ({ red, green, blue, alpha }) => {
|
|
1144
|
-
const average = (red + green + blue) / 3;
|
|
1145
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1146
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1147
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1148
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1149
|
-
};
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
1152
|
/**
|
|
1153
1153
|
* Makes color transformer which saturate the given color
|
|
1154
1154
|
*
|
|
@@ -1217,16 +1217,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
1217
1217
|
*
|
|
1218
1218
|
* @public exported from `@promptbook/core`
|
|
1219
1219
|
*/
|
|
1220
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1221
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1220
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1221
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1222
|
+
/**
|
|
1223
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
1224
|
+
*
|
|
1225
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
1226
|
+
*
|
|
1227
|
+
* @public exported from `@promptbook/core`
|
|
1228
|
+
*/
|
|
1229
|
+
({
|
|
1230
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
1231
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
1232
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1233
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1234
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1235
|
+
});
|
|
1236
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1222
1237
|
/**
|
|
1223
|
-
*
|
|
1238
|
+
* Chat color of the Promptbook (in chat)
|
|
1224
1239
|
*
|
|
1225
1240
|
* TODO: [🗽] Unite branding and make single place for it
|
|
1226
1241
|
*
|
|
1227
1242
|
* @public exported from `@promptbook/core`
|
|
1228
1243
|
*/
|
|
1229
1244
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
1245
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
1230
1246
|
/**
|
|
1231
1247
|
* Color of the user (in chat)
|
|
1232
1248
|
*
|
|
@@ -1235,6 +1251,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
1235
1251
|
* @public exported from `@promptbook/core`
|
|
1236
1252
|
*/
|
|
1237
1253
|
Color.fromHex('#1D4ED8');
|
|
1254
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1238
1255
|
/**
|
|
1239
1256
|
* When the title is not provided, the default title is used
|
|
1240
1257
|
*
|
|
@@ -1305,7 +1322,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
|
1305
1322
|
function getErrorReportUrl(error) {
|
|
1306
1323
|
const report = {
|
|
1307
1324
|
title: `🐜 Error report from ${NAME}`,
|
|
1308
|
-
body: spaceTrim$
|
|
1325
|
+
body: spaceTrim$2((block) => `
|
|
1309
1326
|
|
|
1310
1327
|
|
|
1311
1328
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1348,7 +1365,7 @@ function getErrorReportUrl(error) {
|
|
|
1348
1365
|
*/
|
|
1349
1366
|
class UnexpectedError extends Error {
|
|
1350
1367
|
constructor(message) {
|
|
1351
|
-
super(spaceTrim((block) => `
|
|
1368
|
+
super(spaceTrim$1((block) => `
|
|
1352
1369
|
${block(message)}
|
|
1353
1370
|
|
|
1354
1371
|
Note: This error should not happen.
|
|
@@ -1374,7 +1391,7 @@ class WrappedError extends Error {
|
|
|
1374
1391
|
constructor(whatWasThrown) {
|
|
1375
1392
|
const tag = `[🤮]`;
|
|
1376
1393
|
console.error(tag, whatWasThrown);
|
|
1377
|
-
super(spaceTrim(`
|
|
1394
|
+
super(spaceTrim$1(`
|
|
1378
1395
|
Non-Error object was thrown
|
|
1379
1396
|
|
|
1380
1397
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1409,6 +1426,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
1409
1426
|
PromptbookFetchError,
|
|
1410
1427
|
UnexpectedError,
|
|
1411
1428
|
WrappedError,
|
|
1429
|
+
NotAllowed,
|
|
1430
|
+
DatabaseError,
|
|
1412
1431
|
// TODO: [🪑]> VersionMismatchError,
|
|
1413
1432
|
};
|
|
1414
1433
|
/**
|
|
@@ -1461,7 +1480,7 @@ function deserializeError(error) {
|
|
|
1461
1480
|
message = `${name}: ${message}`;
|
|
1462
1481
|
}
|
|
1463
1482
|
if (stack !== undefined && stack !== '') {
|
|
1464
|
-
message = spaceTrim$
|
|
1483
|
+
message = spaceTrim$2((block) => `
|
|
1465
1484
|
${block(message)}
|
|
1466
1485
|
|
|
1467
1486
|
Original stack trace:
|
|
@@ -1518,7 +1537,7 @@ async function createRemoteClient(options) {
|
|
|
1518
1537
|
const remoteServerUrlParsed = new URL(remoteServerUrl);
|
|
1519
1538
|
if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
|
|
1520
1539
|
remoteServerUrlParsed.pathname = '/';
|
|
1521
|
-
throw new Error(spaceTrim$
|
|
1540
|
+
throw new Error(spaceTrim$2((block) => `
|
|
1522
1541
|
Remote server requires root url \`/\`
|
|
1523
1542
|
|
|
1524
1543
|
You have provided \`remoteServerUrl\`:
|
|
@@ -1943,6 +1962,8 @@ function removeDiacritics(input) {
|
|
|
1943
1962
|
/**
|
|
1944
1963
|
* Converts a given text to kebab-case format.
|
|
1945
1964
|
*
|
|
1965
|
+
* Note: [🔂] This function is idempotent.
|
|
1966
|
+
*
|
|
1946
1967
|
* @param text The text to be converted.
|
|
1947
1968
|
* @returns The kebab-case formatted string.
|
|
1948
1969
|
* @example 'hello-world'
|
|
@@ -2052,7 +2073,7 @@ const knowledgeCommandParser = {
|
|
|
2052
2073
|
*/
|
|
2053
2074
|
parse(input) {
|
|
2054
2075
|
const { args } = input;
|
|
2055
|
-
const knowledgeSourceContent = spaceTrim$
|
|
2076
|
+
const knowledgeSourceContent = spaceTrim$2(args[0] || '');
|
|
2056
2077
|
if (knowledgeSourceContent === '') {
|
|
2057
2078
|
throw new ParseError(`Source is not defined`);
|
|
2058
2079
|
}
|
|
@@ -2196,7 +2217,7 @@ const sectionCommandParser = {
|
|
|
2196
2217
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
2197
2218
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
2198
2219
|
if (taskTypes.length !== 1) {
|
|
2199
|
-
throw new ParseError(spaceTrim$
|
|
2220
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2200
2221
|
Unknown section type "${normalized}"
|
|
2201
2222
|
|
|
2202
2223
|
Supported section types are:
|
|
@@ -2216,7 +2237,7 @@ const sectionCommandParser = {
|
|
|
2216
2237
|
*/
|
|
2217
2238
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
2218
2239
|
if ($taskJson.isSectionTypeSet === true) {
|
|
2219
|
-
throw new ParseError(spaceTrim$
|
|
2240
|
+
throw new ParseError(spaceTrim$2(`
|
|
2220
2241
|
Section type is already defined in the section.
|
|
2221
2242
|
It can be defined only once.
|
|
2222
2243
|
`));
|
|
@@ -2635,7 +2656,7 @@ const expectCommandParser = {
|
|
|
2635
2656
|
/**
|
|
2636
2657
|
* Description of the FORMAT command
|
|
2637
2658
|
*/
|
|
2638
|
-
description: spaceTrim$
|
|
2659
|
+
description: spaceTrim$2(`
|
|
2639
2660
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
2640
2661
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
2641
2662
|
`),
|
|
@@ -2709,7 +2730,7 @@ const expectCommandParser = {
|
|
|
2709
2730
|
}
|
|
2710
2731
|
catch (error) {
|
|
2711
2732
|
assertsError(error);
|
|
2712
|
-
throw new ParseError(spaceTrim$
|
|
2733
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2713
2734
|
Invalid FORMAT command
|
|
2714
2735
|
${block(error.message)}:
|
|
2715
2736
|
`));
|
|
@@ -2831,7 +2852,7 @@ const CsvFormatParser = {
|
|
|
2831
2852
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
2832
2853
|
const csv = csvParse(value, settings);
|
|
2833
2854
|
if (csv.errors.length !== 0) {
|
|
2834
|
-
throw new CsvFormatError(spaceTrim$
|
|
2855
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
2835
2856
|
CSV parsing error
|
|
2836
2857
|
|
|
2837
2858
|
Error(s) from CSV parsing:
|
|
@@ -2876,7 +2897,7 @@ const CsvFormatParser = {
|
|
|
2876
2897
|
const { value, settings, mapCallback, onProgress } = options;
|
|
2877
2898
|
const csv = csvParse(value, settings);
|
|
2878
2899
|
if (csv.errors.length !== 0) {
|
|
2879
|
-
throw new CsvFormatError(spaceTrim$
|
|
2900
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
2880
2901
|
CSV parsing error
|
|
2881
2902
|
|
|
2882
2903
|
Error(s) from CSV parsing:
|
|
@@ -3221,7 +3242,7 @@ function checkSerializableAsJson(options) {
|
|
|
3221
3242
|
}
|
|
3222
3243
|
else if (typeof value === 'object') {
|
|
3223
3244
|
if (value instanceof Date) {
|
|
3224
|
-
throw new UnexpectedError(spaceTrim$
|
|
3245
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
3225
3246
|
\`${name}\` is Date
|
|
3226
3247
|
|
|
3227
3248
|
Use \`string_date_iso8601\` instead
|
|
@@ -3240,7 +3261,7 @@ function checkSerializableAsJson(options) {
|
|
|
3240
3261
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
3241
3262
|
}
|
|
3242
3263
|
else if (value instanceof Error) {
|
|
3243
|
-
throw new UnexpectedError(spaceTrim$
|
|
3264
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
3244
3265
|
\`${name}\` is unserialized Error
|
|
3245
3266
|
|
|
3246
3267
|
Use function \`serializeError\`
|
|
@@ -3263,7 +3284,7 @@ function checkSerializableAsJson(options) {
|
|
|
3263
3284
|
}
|
|
3264
3285
|
catch (error) {
|
|
3265
3286
|
assertsError(error);
|
|
3266
|
-
throw new UnexpectedError(spaceTrim$
|
|
3287
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
3267
3288
|
\`${name}\` is not serializable
|
|
3268
3289
|
|
|
3269
3290
|
${block(error.stack || error.message)}
|
|
@@ -3295,7 +3316,7 @@ function checkSerializableAsJson(options) {
|
|
|
3295
3316
|
}
|
|
3296
3317
|
}
|
|
3297
3318
|
else {
|
|
3298
|
-
throw new UnexpectedError(spaceTrim$
|
|
3319
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
3299
3320
|
\`${name}\` is unknown type
|
|
3300
3321
|
|
|
3301
3322
|
Additional message for \`${name}\`:
|
|
@@ -3325,7 +3346,7 @@ function deepClone(objectValue) {
|
|
|
3325
3346
|
TODO: [🧠] Is there a better implementation?
|
|
3326
3347
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
3327
3348
|
> for (const propertyName of propertyNames) {
|
|
3328
|
-
> const value = (objectValue as
|
|
3349
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
3329
3350
|
> if (value && typeof value === 'object') {
|
|
3330
3351
|
> deepClone(value);
|
|
3331
3352
|
> }
|
|
@@ -3418,6 +3439,8 @@ const RESERVED_PARAMETER_NAMES = exportJson({
|
|
|
3418
3439
|
/**
|
|
3419
3440
|
* Normalizes a given text to camelCase format.
|
|
3420
3441
|
*
|
|
3442
|
+
* Note: [🔂] This function is idempotent.
|
|
3443
|
+
*
|
|
3421
3444
|
* @param text The text to be normalized.
|
|
3422
3445
|
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
3423
3446
|
* @returns The camelCase formatted string.
|
|
@@ -3513,6 +3536,8 @@ function removeQuotes(text) {
|
|
|
3513
3536
|
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
3514
3537
|
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
3515
3538
|
*
|
|
3539
|
+
* Note: [🔂] This function is idempotent.
|
|
3540
|
+
*
|
|
3516
3541
|
* @param parameterName The parameter name to validate and normalize.
|
|
3517
3542
|
* @returns The validated and normalized parameter name.
|
|
3518
3543
|
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
@@ -3572,7 +3597,7 @@ function validateParameterName(parameterName) {
|
|
|
3572
3597
|
if (!(error instanceof ParseError)) {
|
|
3573
3598
|
throw error;
|
|
3574
3599
|
}
|
|
3575
|
-
throw new ParseError(spaceTrim$
|
|
3600
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3576
3601
|
${block(error.message)}
|
|
3577
3602
|
|
|
3578
3603
|
Tried to validate parameter name:
|
|
@@ -3631,7 +3656,7 @@ const foreachCommandParser = {
|
|
|
3631
3656
|
const assignSign = args[3];
|
|
3632
3657
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
3633
3658
|
if (formatDefinition === undefined) {
|
|
3634
|
-
throw new ParseError(spaceTrim$
|
|
3659
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3635
3660
|
Unsupported format "${formatName}"
|
|
3636
3661
|
|
|
3637
3662
|
Available formats:
|
|
@@ -3643,7 +3668,7 @@ const foreachCommandParser = {
|
|
|
3643
3668
|
}
|
|
3644
3669
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
3645
3670
|
if (subvalueParser === undefined) {
|
|
3646
|
-
throw new ParseError(spaceTrim$
|
|
3671
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3647
3672
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
3648
3673
|
|
|
3649
3674
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -3691,7 +3716,7 @@ const foreachCommandParser = {
|
|
|
3691
3716
|
outputSubparameterName = 'newLine';
|
|
3692
3717
|
}
|
|
3693
3718
|
else {
|
|
3694
|
-
throw new ParseError(spaceTrim$
|
|
3719
|
+
throw new ParseError(spaceTrim$2(`
|
|
3695
3720
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
3696
3721
|
|
|
3697
3722
|
Correct example:
|
|
@@ -3767,7 +3792,7 @@ const formatCommandParser = {
|
|
|
3767
3792
|
/**
|
|
3768
3793
|
* Description of the FORMAT command
|
|
3769
3794
|
*/
|
|
3770
|
-
description: spaceTrim$
|
|
3795
|
+
description: spaceTrim$2(`
|
|
3771
3796
|
Format command describes the desired output of the task (after post-processing)
|
|
3772
3797
|
It can set limits for the maximum/minimum length of the output, measured in characters, words, sentences, paragraphs or some other shape of the output.
|
|
3773
3798
|
`),
|
|
@@ -4139,7 +4164,7 @@ const formfactorCommandParser = {
|
|
|
4139
4164
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
4140
4165
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
4141
4166
|
if (formfactor === undefined) {
|
|
4142
|
-
throw new ParseError(spaceTrim$
|
|
4167
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
4143
4168
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
4144
4169
|
|
|
4145
4170
|
Available formfactors:
|
|
@@ -4158,7 +4183,7 @@ const formfactorCommandParser = {
|
|
|
4158
4183
|
*/
|
|
4159
4184
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
4160
4185
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
4161
|
-
throw new ParseError(spaceTrim$
|
|
4186
|
+
throw new ParseError(spaceTrim$2(`
|
|
4162
4187
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
4163
4188
|
|
|
4164
4189
|
You have used:
|
|
@@ -4301,7 +4326,7 @@ const modelCommandParser = {
|
|
|
4301
4326
|
*/
|
|
4302
4327
|
parse(input) {
|
|
4303
4328
|
const { args, normalized } = input;
|
|
4304
|
-
const availableVariantsMessage = spaceTrim$
|
|
4329
|
+
const availableVariantsMessage = spaceTrim$2((block) => `
|
|
4305
4330
|
Available variants are:
|
|
4306
4331
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
4307
4332
|
`);
|
|
@@ -4323,14 +4348,14 @@ const modelCommandParser = {
|
|
|
4323
4348
|
// <- Note: [🤖]
|
|
4324
4349
|
}
|
|
4325
4350
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
4326
|
-
spaceTrim$
|
|
4351
|
+
spaceTrim$2((block) => `
|
|
4327
4352
|
Embedding model can not be used in pipeline
|
|
4328
4353
|
|
|
4329
4354
|
${block(availableVariantsMessage)}
|
|
4330
4355
|
`);
|
|
4331
4356
|
}
|
|
4332
4357
|
else {
|
|
4333
|
-
throw new ParseError(spaceTrim$
|
|
4358
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
4334
4359
|
Unknown model variant in command:
|
|
4335
4360
|
|
|
4336
4361
|
${block(availableVariantsMessage)}
|
|
@@ -4345,7 +4370,7 @@ const modelCommandParser = {
|
|
|
4345
4370
|
};
|
|
4346
4371
|
}
|
|
4347
4372
|
else {
|
|
4348
|
-
throw new ParseError(spaceTrim$
|
|
4373
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
4349
4374
|
Unknown model key in command.
|
|
4350
4375
|
|
|
4351
4376
|
Supported model keys are:
|
|
@@ -4372,7 +4397,7 @@ const modelCommandParser = {
|
|
|
4372
4397
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4373
4398
|
}
|
|
4374
4399
|
else {
|
|
4375
|
-
throw new ParseError(spaceTrim$
|
|
4400
|
+
throw new ParseError(spaceTrim$2(`
|
|
4376
4401
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
4377
4402
|
|
|
4378
4403
|
You have used:
|
|
@@ -4404,7 +4429,7 @@ const modelCommandParser = {
|
|
|
4404
4429
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
4405
4430
|
}
|
|
4406
4431
|
else {
|
|
4407
|
-
throw new ParseError(spaceTrim$
|
|
4432
|
+
throw new ParseError(spaceTrim$2(`
|
|
4408
4433
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
4409
4434
|
|
|
4410
4435
|
You have used:
|
|
@@ -4414,7 +4439,7 @@ const modelCommandParser = {
|
|
|
4414
4439
|
}
|
|
4415
4440
|
}
|
|
4416
4441
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
4417
|
-
console.log(spaceTrim$
|
|
4442
|
+
console.log(spaceTrim$2(`
|
|
4418
4443
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
4419
4444
|
|
|
4420
4445
|
In pipeline head:
|
|
@@ -4497,7 +4522,7 @@ const parameterCommandParser = {
|
|
|
4497
4522
|
// <- TODO: When [🥶] fixed, change to:
|
|
4498
4523
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
4499
4524
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
4500
|
-
throw new ParseError(spaceTrim$
|
|
4525
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
4501
4526
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
4502
4527
|
|
|
4503
4528
|
The description:
|
|
@@ -4679,7 +4704,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
4679
4704
|
persona.description = personaDescription;
|
|
4680
4705
|
return;
|
|
4681
4706
|
}
|
|
4682
|
-
console.warn(spaceTrim$
|
|
4707
|
+
console.warn(spaceTrim$2(`
|
|
4683
4708
|
|
|
4684
4709
|
Persona "${personaName}" is defined multiple times with different description:
|
|
4685
4710
|
|
|
@@ -4690,7 +4715,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
4690
4715
|
${personaDescription}
|
|
4691
4716
|
|
|
4692
4717
|
`));
|
|
4693
|
-
persona.description += spaceTrim$
|
|
4718
|
+
persona.description += spaceTrim$2('\n\n' + personaDescription);
|
|
4694
4719
|
}
|
|
4695
4720
|
|
|
4696
4721
|
/**
|
|
@@ -5087,7 +5112,7 @@ const COMMANDS = [
|
|
|
5087
5112
|
function getParserForCommand(command) {
|
|
5088
5113
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
5089
5114
|
if (commandParser === undefined) {
|
|
5090
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
5115
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
5091
5116
|
Command ${command.type} parser is not found
|
|
5092
5117
|
|
|
5093
5118
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -5163,7 +5188,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
5163
5188
|
.map(removeMarkdownFormatting)
|
|
5164
5189
|
.map((item) => item.trim());
|
|
5165
5190
|
if (items.length === 0 || items[0] === '') {
|
|
5166
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5191
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5167
5192
|
Malformed command:
|
|
5168
5193
|
- ${raw}
|
|
5169
5194
|
|
|
@@ -5199,7 +5224,7 @@ function parseCommand(raw, usagePlace) {
|
|
|
5199
5224
|
return command;
|
|
5200
5225
|
}
|
|
5201
5226
|
}
|
|
5202
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5227
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5203
5228
|
Malformed or unknown command:
|
|
5204
5229
|
- ${raw}
|
|
5205
5230
|
|
|
@@ -5250,7 +5275,7 @@ function parseCommandVariant(input) {
|
|
|
5250
5275
|
if (!(error instanceof ParseError)) {
|
|
5251
5276
|
throw error;
|
|
5252
5277
|
}
|
|
5253
|
-
throw new ParseError(spaceTrim((block) => `
|
|
5278
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5254
5279
|
Invalid ${commandName} command:
|
|
5255
5280
|
|
|
5256
5281
|
Your command:
|
|
@@ -5527,6 +5552,8 @@ function isValidEmail(email) {
|
|
|
5527
5552
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
5528
5553
|
* It does not check if the string is fully logically correct, but if it is a string that can be a pipeline string or the string looks completely different.
|
|
5529
5554
|
*
|
|
5555
|
+
* Note: [🔂] This function is idempotent.
|
|
5556
|
+
*
|
|
5530
5557
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
5531
5558
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
5532
5559
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -5560,6 +5587,48 @@ function validatePipelineString(pipelineString) {
|
|
|
5560
5587
|
const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
5561
5588
|
// <- TODO: [🏥] DRY
|
|
5562
5589
|
|
|
5590
|
+
/**
|
|
5591
|
+
* Number of padding lines to add at the end of the book content
|
|
5592
|
+
*
|
|
5593
|
+
* @public exported from `@promptbook/core`
|
|
5594
|
+
*/
|
|
5595
|
+
const PADDING_LINES = 11;
|
|
5596
|
+
/**
|
|
5597
|
+
* A function that adds padding to the book content
|
|
5598
|
+
*
|
|
5599
|
+
* Note: [🔂] This function is idempotent.
|
|
5600
|
+
*
|
|
5601
|
+
* @public exported from `@promptbook/core`
|
|
5602
|
+
*/
|
|
5603
|
+
function padBook(content) {
|
|
5604
|
+
if (!content) {
|
|
5605
|
+
return '\n'.repeat(PADDING_LINES);
|
|
5606
|
+
}
|
|
5607
|
+
const lines = content.split('\n');
|
|
5608
|
+
let trailingEmptyLines = 0;
|
|
5609
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
5610
|
+
const line = lines[i];
|
|
5611
|
+
if (line === undefined) {
|
|
5612
|
+
// Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
|
|
5613
|
+
continue;
|
|
5614
|
+
}
|
|
5615
|
+
if (line.trim() === '') {
|
|
5616
|
+
trailingEmptyLines++;
|
|
5617
|
+
}
|
|
5618
|
+
else {
|
|
5619
|
+
break;
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
if (trailingEmptyLines >= PADDING_LINES) {
|
|
5623
|
+
return content;
|
|
5624
|
+
}
|
|
5625
|
+
const linesToAdd = PADDING_LINES - trailingEmptyLines;
|
|
5626
|
+
return (content + '\n'.repeat(linesToAdd));
|
|
5627
|
+
}
|
|
5628
|
+
/**
|
|
5629
|
+
* TODO: [🧠] Maybe export
|
|
5630
|
+
*/
|
|
5631
|
+
|
|
5563
5632
|
/**
|
|
5564
5633
|
* Removes Markdown (or HTML) comments
|
|
5565
5634
|
*
|
|
@@ -5568,7 +5637,7 @@ const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
|
5568
5637
|
* @public exported from `@promptbook/markdown-utils`
|
|
5569
5638
|
*/
|
|
5570
5639
|
function removeMarkdownComments(content) {
|
|
5571
|
-
return spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
5640
|
+
return spaceTrim$1(content.replace(/<!--(.*?)-->/gs, ''));
|
|
5572
5641
|
}
|
|
5573
5642
|
|
|
5574
5643
|
/**
|
|
@@ -5579,7 +5648,7 @@ function removeMarkdownComments(content) {
|
|
|
5579
5648
|
*/
|
|
5580
5649
|
function isFlatPipeline(pipelineString) {
|
|
5581
5650
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
5582
|
-
pipelineString = spaceTrim$
|
|
5651
|
+
pipelineString = spaceTrim$2(pipelineString);
|
|
5583
5652
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
5584
5653
|
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
5585
5654
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -5605,6 +5674,7 @@ function deflatePipeline(pipelineString) {
|
|
|
5605
5674
|
if (!isFlatPipeline(pipelineString)) {
|
|
5606
5675
|
return pipelineString;
|
|
5607
5676
|
}
|
|
5677
|
+
pipelineString = spaceTrim$2(pipelineString);
|
|
5608
5678
|
const pipelineStringLines = pipelineString.split('\n');
|
|
5609
5679
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
5610
5680
|
let returnStatement;
|
|
@@ -5617,19 +5687,19 @@ function deflatePipeline(pipelineString) {
|
|
|
5617
5687
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
5618
5688
|
pipelineStringLines.push(potentialReturnStatement);
|
|
5619
5689
|
}
|
|
5620
|
-
const prompt = spaceTrim$
|
|
5690
|
+
const prompt = spaceTrim$2(pipelineStringLines.join('\n'));
|
|
5621
5691
|
let quotedPrompt;
|
|
5622
5692
|
if (prompt.split('\n').length <= 1) {
|
|
5623
5693
|
quotedPrompt = `> ${prompt}`;
|
|
5624
5694
|
}
|
|
5625
5695
|
else {
|
|
5626
|
-
quotedPrompt = spaceTrim$
|
|
5696
|
+
quotedPrompt = spaceTrim$2((block) => `
|
|
5627
5697
|
\`\`\`
|
|
5628
5698
|
${block(prompt.split('`').join('\\`'))}
|
|
5629
5699
|
\`\`\`
|
|
5630
5700
|
`);
|
|
5631
5701
|
}
|
|
5632
|
-
pipelineString = validatePipelineString(spaceTrim$
|
|
5702
|
+
pipelineString = validatePipelineString(spaceTrim$2((block) => `
|
|
5633
5703
|
# ${DEFAULT_BOOK_TITLE}
|
|
5634
5704
|
|
|
5635
5705
|
## Prompt
|
|
@@ -5639,7 +5709,7 @@ function deflatePipeline(pipelineString) {
|
|
|
5639
5709
|
${returnStatement}
|
|
5640
5710
|
`));
|
|
5641
5711
|
// <- TODO: Maybe use book` notation
|
|
5642
|
-
return pipelineString;
|
|
5712
|
+
return padBook(pipelineString);
|
|
5643
5713
|
}
|
|
5644
5714
|
/**
|
|
5645
5715
|
* TODO: Unit test
|
|
@@ -5770,7 +5840,7 @@ function extractAllBlocksFromMarkdown(markdown) {
|
|
|
5770
5840
|
function extractOneBlockFromMarkdown(markdown) {
|
|
5771
5841
|
const codeBlocks = extractAllBlocksFromMarkdown(markdown);
|
|
5772
5842
|
if (codeBlocks.length !== 1) {
|
|
5773
|
-
throw new ParseError(spaceTrim$
|
|
5843
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
5774
5844
|
There should be exactly 1 code block in task section, found ${codeBlocks.length} code blocks
|
|
5775
5845
|
|
|
5776
5846
|
${block(codeBlocks.map((block, i) => `Block ${i + 1}:\n${block.content}`).join('\n\n\n'))}
|
|
@@ -5795,7 +5865,7 @@ function parseMarkdownSection(value) {
|
|
|
5795
5865
|
}
|
|
5796
5866
|
const title = lines[0].replace(/^#+\s*/, '');
|
|
5797
5867
|
const level = (_b = (_a = lines[0].match(/^#+/)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
|
|
5798
|
-
const content = spaceTrim$
|
|
5868
|
+
const content = spaceTrim$2(lines.slice(1).join('\n'));
|
|
5799
5869
|
if (level < 1 || level > 6) {
|
|
5800
5870
|
throw new ParseError('Markdown section must have heading level between 1 and 6');
|
|
5801
5871
|
}
|
|
@@ -5823,7 +5893,7 @@ function splitMarkdownIntoSections(markdown) {
|
|
|
5823
5893
|
if (buffer.length === 0) {
|
|
5824
5894
|
return;
|
|
5825
5895
|
}
|
|
5826
|
-
let section = spaceTrim$
|
|
5896
|
+
let section = spaceTrim$2(buffer.join('\n'));
|
|
5827
5897
|
if (section === '') {
|
|
5828
5898
|
return;
|
|
5829
5899
|
}
|
|
@@ -5898,7 +5968,7 @@ function flattenMarkdown(markdown) {
|
|
|
5898
5968
|
flattenedMarkdown += `## ${title}` + `\n\n`;
|
|
5899
5969
|
flattenedMarkdown += content + `\n\n`; // <- [🧠] Maybe 3 new lines?
|
|
5900
5970
|
}
|
|
5901
|
-
return spaceTrim$
|
|
5971
|
+
return spaceTrim$2(flattenedMarkdown);
|
|
5902
5972
|
}
|
|
5903
5973
|
/**
|
|
5904
5974
|
* TODO: [🏛] This can be part of markdown builder
|
|
@@ -5911,6 +5981,8 @@ function flattenMarkdown(markdown) {
|
|
|
5911
5981
|
/**
|
|
5912
5982
|
* Converts a title string into a normalized name.
|
|
5913
5983
|
*
|
|
5984
|
+
* Note: [🔂] This function is idempotent.
|
|
5985
|
+
*
|
|
5914
5986
|
* @param value The title string to be converted to a name.
|
|
5915
5987
|
* @returns A normalized name derived from the input title.
|
|
5916
5988
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -5984,7 +6056,7 @@ function extractVariablesFromJavascript(script) {
|
|
|
5984
6056
|
}
|
|
5985
6057
|
catch (error) {
|
|
5986
6058
|
assertsError(error);
|
|
5987
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6059
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
5988
6060
|
Can not extract variables from the script
|
|
5989
6061
|
${block(error.stack || error.message)}
|
|
5990
6062
|
|
|
@@ -6126,7 +6198,7 @@ function parsePipeline(pipelineString) {
|
|
|
6126
6198
|
if (pipelineString.startsWith('#!')) {
|
|
6127
6199
|
const [shebangLine, ...restLines] = pipelineString.split('\n');
|
|
6128
6200
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
6129
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6201
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6130
6202
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
6131
6203
|
Shebang line must contain 'ptbk'
|
|
6132
6204
|
|
|
@@ -6142,7 +6214,7 @@ function parsePipeline(pipelineString) {
|
|
|
6142
6214
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
6143
6215
|
}
|
|
6144
6216
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
6145
|
-
pipelineString = spaceTrim(pipelineString);
|
|
6217
|
+
pipelineString = spaceTrim$1(pipelineString);
|
|
6146
6218
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
6147
6219
|
pipelineString = deflatePipeline(pipelineString);
|
|
6148
6220
|
// ==============
|
|
@@ -6154,7 +6226,7 @@ function parsePipeline(pipelineString) {
|
|
|
6154
6226
|
// ==============
|
|
6155
6227
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
6156
6228
|
if (pipelineHead === undefined) {
|
|
6157
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6229
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6158
6230
|
Pipeline head is not defined
|
|
6159
6231
|
|
|
6160
6232
|
${block(getPipelineIdentification())}
|
|
@@ -6163,7 +6235,7 @@ function parsePipeline(pipelineString) {
|
|
|
6163
6235
|
`));
|
|
6164
6236
|
}
|
|
6165
6237
|
if (pipelineHead.level !== 1) {
|
|
6166
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6238
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6167
6239
|
Pipeline head is not h1
|
|
6168
6240
|
|
|
6169
6241
|
${block(getPipelineIdentification())}
|
|
@@ -6172,7 +6244,7 @@ function parsePipeline(pipelineString) {
|
|
|
6172
6244
|
`));
|
|
6173
6245
|
}
|
|
6174
6246
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
6175
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
6247
|
+
throw new UnexpectedError(spaceTrim$1((block) => `
|
|
6176
6248
|
Not every pipeline section is h2
|
|
6177
6249
|
|
|
6178
6250
|
${block(getPipelineIdentification())}
|
|
@@ -6185,7 +6257,7 @@ function parsePipeline(pipelineString) {
|
|
|
6185
6257
|
const defineParam = (parameterCommand) => {
|
|
6186
6258
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
6187
6259
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
6188
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6260
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6189
6261
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
6190
6262
|
|
|
6191
6263
|
${block(getPipelineIdentification())}
|
|
@@ -6196,7 +6268,7 @@ function parsePipeline(pipelineString) {
|
|
|
6196
6268
|
existingParameter.description &&
|
|
6197
6269
|
existingParameter.description !== parameterDescription &&
|
|
6198
6270
|
parameterDescription) {
|
|
6199
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6271
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6200
6272
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
6201
6273
|
|
|
6202
6274
|
${block(getPipelineIdentification())}
|
|
@@ -6234,7 +6306,7 @@ function parsePipeline(pipelineString) {
|
|
|
6234
6306
|
description = description.split(/^>.*$/gm).join('');
|
|
6235
6307
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
6236
6308
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
6237
|
-
description = spaceTrim(description);
|
|
6309
|
+
description = spaceTrim$1(description);
|
|
6238
6310
|
if (description === '') {
|
|
6239
6311
|
description = undefined;
|
|
6240
6312
|
}
|
|
@@ -6245,7 +6317,7 @@ function parsePipeline(pipelineString) {
|
|
|
6245
6317
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6246
6318
|
const commandParser = getParserForCommand(command);
|
|
6247
6319
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
6248
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6320
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6249
6321
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
6250
6322
|
|
|
6251
6323
|
${block(getPipelineIdentification())}
|
|
@@ -6259,7 +6331,7 @@ function parsePipeline(pipelineString) {
|
|
|
6259
6331
|
if (!(error instanceof ParseError)) {
|
|
6260
6332
|
throw error;
|
|
6261
6333
|
}
|
|
6262
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6334
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6263
6335
|
Command ${command.type} failed to apply to the pipeline
|
|
6264
6336
|
|
|
6265
6337
|
The error:
|
|
@@ -6312,7 +6384,7 @@ function parsePipeline(pipelineString) {
|
|
|
6312
6384
|
description = description.split(/^>.*$/gm).join('');
|
|
6313
6385
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
6314
6386
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
6315
|
-
description = spaceTrim(description);
|
|
6387
|
+
description = spaceTrim$1(description);
|
|
6316
6388
|
if (description === '') {
|
|
6317
6389
|
description = undefined;
|
|
6318
6390
|
}
|
|
@@ -6346,7 +6418,7 @@ function parsePipeline(pipelineString) {
|
|
|
6346
6418
|
for (const { listItem, command } of commands) {
|
|
6347
6419
|
const commandParser = getParserForCommand(command);
|
|
6348
6420
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
6349
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6421
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6350
6422
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
6351
6423
|
|
|
6352
6424
|
${block(getPipelineIdentification())}
|
|
@@ -6361,7 +6433,7 @@ function parsePipeline(pipelineString) {
|
|
|
6361
6433
|
if (!(error instanceof ParseError)) {
|
|
6362
6434
|
throw error;
|
|
6363
6435
|
}
|
|
6364
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6436
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6365
6437
|
Command \`${command.type}\` failed to apply to the task
|
|
6366
6438
|
|
|
6367
6439
|
The error:
|
|
@@ -6392,14 +6464,14 @@ function parsePipeline(pipelineString) {
|
|
|
6392
6464
|
// TODO: [🍧] Should be done in SECTION command
|
|
6393
6465
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
6394
6466
|
if (!language) {
|
|
6395
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6467
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6396
6468
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
6397
6469
|
|
|
6398
6470
|
${block(getPipelineIdentification())}
|
|
6399
6471
|
`));
|
|
6400
6472
|
}
|
|
6401
6473
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6402
|
-
throw new ParseError(spaceTrim((block) => `
|
|
6474
|
+
throw new ParseError(spaceTrim$1((block) => `
|
|
6403
6475
|
Script language ${language} is not supported.
|
|
6404
6476
|
|
|
6405
6477
|
Supported languages are:
|