@promptbook/editable 0.103.0-8 → 0.103.0
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 +59 -39
- package/esm/index.es.js +203 -148
- 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 +22 -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 +70 -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 +20 -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 +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +85 -14
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +18 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +17 -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 +16 -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 +1 -1
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentIntegration.d.ts +52 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgentSeamlessIntegration.d.ts +14 -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 +2 -2
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CameraIcon.d.ts +11 -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/book-components/icons/SendIcon.d.ts +3 -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 +39 -0
- package/esm/typings/src/commitments/CLOSED/CLOSED.test.d.ts +4 -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 +42 -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 +14 -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 +26 -2
- package/esm/typings/src/execution/PromptResult.d.ts +7 -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 +72 -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/ollama/OllamaExecutionTools.d.ts +4 -0
- 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/OpenAiCompatibleExecutionTools.d.ts +13 -1
- package/esm/typings/src/llm-providers/openai/OpenAiExecutionTools.d.ts +4 -0
- package/esm/typings/src/llm-providers/openai/createOpenAiCompatibleExecutionTools.d.ts +6 -6
- 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/ModelRequirements.d.ts +13 -1
- package/esm/typings/src/types/ModelVariant.d.ts +1 -1
- package/esm/typings/src/types/Prompt.d.ts +13 -1
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +38 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +16 -1
- 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 +31 -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/random/CzechNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/EnglishNamePool.d.ts +7 -0
- package/esm/typings/src/utils/random/NamePool.d.ts +17 -0
- package/esm/typings/src/utils/random/getNamePool.d.ts +10 -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 +177 -122
- 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/BookEditorWrapper.d.ts +0 -9
- 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, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import { parse, unparse } from 'papaparse';
|
|
3
3
|
import { SHA256 } from 'crypto-js';
|
|
4
4
|
import hexEncoder from 'crypto-js/enc-hex';
|
|
@@ -10,19 +10,30 @@ import hexEncoder from 'crypto-js/enc-hex';
|
|
|
10
10
|
* @generated
|
|
11
11
|
* @see https://github.com/webgptorg/book
|
|
12
12
|
*/
|
|
13
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
13
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
14
14
|
/**
|
|
15
15
|
* The version of the Promptbook engine
|
|
16
16
|
*
|
|
17
17
|
* @generated
|
|
18
18
|
* @see https://github.com/webgptorg/promptbook
|
|
19
19
|
*/
|
|
20
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0
|
|
20
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0';
|
|
21
21
|
/**
|
|
22
22
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
23
23
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Trims string from all 4 sides
|
|
28
|
+
*
|
|
29
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
30
|
+
* Developed by same author @hejny as this package
|
|
31
|
+
*
|
|
32
|
+
* @public exported from `@promptbook/utils`
|
|
33
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
34
|
+
*/
|
|
35
|
+
const spaceTrim = spaceTrim$1;
|
|
36
|
+
|
|
26
37
|
/**
|
|
27
38
|
* @private util of `@promptbook/color`
|
|
28
39
|
* @de
|
|
@@ -71,6 +82,7 @@ function take(initialValue) {
|
|
|
71
82
|
* @public exported from `@promptbook/color`
|
|
72
83
|
*/
|
|
73
84
|
const CSS_COLORS = {
|
|
85
|
+
promptbook: '#79EAFD',
|
|
74
86
|
transparent: 'rgba(0,0,0,0)',
|
|
75
87
|
aliceblue: '#f0f8ff',
|
|
76
88
|
antiquewhite: '#faebd7',
|
|
@@ -252,9 +264,6 @@ function checkChannelValue(channelName, value) {
|
|
|
252
264
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
253
265
|
}
|
|
254
266
|
}
|
|
255
|
-
/**
|
|
256
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
257
|
-
*/
|
|
258
267
|
|
|
259
268
|
/**
|
|
260
269
|
* Color object represents an RGB color with alpha channel
|
|
@@ -274,21 +283,61 @@ class Color {
|
|
|
274
283
|
* @param color
|
|
275
284
|
* @returns Color object
|
|
276
285
|
*/
|
|
277
|
-
static from(color) {
|
|
278
|
-
if (color
|
|
286
|
+
static from(color, _isSingleValue = false) {
|
|
287
|
+
if (color === '') {
|
|
288
|
+
throw new Error(`Can not create color from empty string`);
|
|
289
|
+
}
|
|
290
|
+
else if (color instanceof Color) {
|
|
279
291
|
return take(color);
|
|
280
292
|
}
|
|
281
293
|
else if (Color.isColor(color)) {
|
|
282
294
|
return take(color);
|
|
283
295
|
}
|
|
284
296
|
else if (typeof color === 'string') {
|
|
285
|
-
|
|
297
|
+
try {
|
|
298
|
+
return Color.fromString(color);
|
|
299
|
+
}
|
|
300
|
+
catch (error) {
|
|
301
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
302
|
+
if (_isSingleValue) {
|
|
303
|
+
throw error;
|
|
304
|
+
}
|
|
305
|
+
const parts = color.split(/[\s+,;|]/);
|
|
306
|
+
if (parts.length > 0) {
|
|
307
|
+
return Color.from(parts[0].trim(), true);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
throw new Error(`Can not create color from given string "${color}"`);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
286
313
|
}
|
|
287
314
|
else {
|
|
288
315
|
console.error({ color });
|
|
289
316
|
throw new Error(`Can not create color from given object`);
|
|
290
317
|
}
|
|
291
318
|
}
|
|
319
|
+
/**
|
|
320
|
+
* Creates a new Color instance from miscellaneous formats
|
|
321
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
322
|
+
*
|
|
323
|
+
* @param color
|
|
324
|
+
* @returns Color object
|
|
325
|
+
*/
|
|
326
|
+
static fromSafe(color) {
|
|
327
|
+
try {
|
|
328
|
+
return Color.from(color);
|
|
329
|
+
}
|
|
330
|
+
catch (error) {
|
|
331
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
332
|
+
console.warn(spaceTrim((block) => `
|
|
333
|
+
Color.fromSafe error:
|
|
334
|
+
${block(error.message)}
|
|
335
|
+
|
|
336
|
+
Returning default PROMPTBOOK_COLOR.
|
|
337
|
+
`));
|
|
338
|
+
return Color.fromString('promptbook');
|
|
339
|
+
}
|
|
340
|
+
}
|
|
292
341
|
/**
|
|
293
342
|
* Creates a new Color instance from miscellaneous string formats
|
|
294
343
|
*
|
|
@@ -356,6 +405,9 @@ class Color {
|
|
|
356
405
|
if (hex.length === 3) {
|
|
357
406
|
return Color.fromHex3(hex);
|
|
358
407
|
}
|
|
408
|
+
if (hex.length === 4) {
|
|
409
|
+
return Color.fromHex4(hex);
|
|
410
|
+
}
|
|
359
411
|
if (hex.length === 6) {
|
|
360
412
|
return Color.fromHex6(hex);
|
|
361
413
|
}
|
|
@@ -376,6 +428,19 @@ class Color {
|
|
|
376
428
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
377
429
|
return take(new Color(r, g, b));
|
|
378
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
433
|
+
*
|
|
434
|
+
* @param color in hex for example `09df`
|
|
435
|
+
* @returns Color object
|
|
436
|
+
*/
|
|
437
|
+
static fromHex4(hex) {
|
|
438
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
439
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
440
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
441
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
442
|
+
return take(new Color(r, g, b, a));
|
|
443
|
+
}
|
|
379
444
|
/**
|
|
380
445
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
381
446
|
*
|
|
@@ -566,7 +631,8 @@ class Color {
|
|
|
566
631
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
567
632
|
*/
|
|
568
633
|
static isHexColorString(value) {
|
|
569
|
-
return typeof value === 'string' &&
|
|
634
|
+
return (typeof value === 'string' &&
|
|
635
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
570
636
|
}
|
|
571
637
|
/**
|
|
572
638
|
* Creates new Color object
|
|
@@ -681,6 +747,23 @@ class Color {
|
|
|
681
747
|
* TODO: Maybe connect with textures
|
|
682
748
|
*/
|
|
683
749
|
|
|
750
|
+
/**
|
|
751
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
752
|
+
*
|
|
753
|
+
* @param amount from 0 to 1
|
|
754
|
+
*
|
|
755
|
+
* @public exported from `@promptbook/color`
|
|
756
|
+
*/
|
|
757
|
+
function grayscale(amount) {
|
|
758
|
+
return ({ red, green, blue, alpha }) => {
|
|
759
|
+
const average = (red + green + blue) / 3;
|
|
760
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
761
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
762
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
763
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
|
|
684
767
|
/**
|
|
685
768
|
* Converts HSL values to RGB values
|
|
686
769
|
*
|
|
@@ -796,102 +879,6 @@ function lighten(amount) {
|
|
|
796
879
|
* TODO: Maybe implement by mix+hsl
|
|
797
880
|
*/
|
|
798
881
|
|
|
799
|
-
/**
|
|
800
|
-
* Calculates distance between two colors
|
|
801
|
-
*
|
|
802
|
-
* @param color1 first color
|
|
803
|
-
* @param color2 second color
|
|
804
|
-
*
|
|
805
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
806
|
-
*
|
|
807
|
-
* @public exported from `@promptbook/color`
|
|
808
|
-
*/
|
|
809
|
-
/**
|
|
810
|
-
* Calculates distance between two colors without square root
|
|
811
|
-
*
|
|
812
|
-
* @param color1 first color
|
|
813
|
-
* @param color2 second color
|
|
814
|
-
*
|
|
815
|
-
* @public exported from `@promptbook/color`
|
|
816
|
-
*/
|
|
817
|
-
function colorDistanceSquared(color1, color2) {
|
|
818
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
819
|
-
const r = color1.red - color2.red;
|
|
820
|
-
const g = color1.green - color2.green;
|
|
821
|
-
const b = color1.blue - color2.blue;
|
|
822
|
-
const weightR = 2 + rmean / 256;
|
|
823
|
-
const weightG = 4.0;
|
|
824
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
825
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
826
|
-
return distance;
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
/**
|
|
830
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
831
|
-
*
|
|
832
|
-
* @param colors array of colors to choose from
|
|
833
|
-
*
|
|
834
|
-
* @public exported from `@promptbook/color`
|
|
835
|
-
*/
|
|
836
|
-
function nearest(...colors) {
|
|
837
|
-
return (color) => {
|
|
838
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
839
|
-
const minDistance = Math.min(...distances);
|
|
840
|
-
const minIndex = distances.indexOf(minDistance);
|
|
841
|
-
const nearestColor = colors[minIndex];
|
|
842
|
-
return nearestColor;
|
|
843
|
-
};
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
/**
|
|
847
|
-
* Color transformer which returns the negative color
|
|
848
|
-
*
|
|
849
|
-
* @public exported from `@promptbook/color`
|
|
850
|
-
*/
|
|
851
|
-
function negative(color) {
|
|
852
|
-
const r = 255 - color.red;
|
|
853
|
-
const g = 255 - color.green;
|
|
854
|
-
const b = 255 - color.blue;
|
|
855
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
/**
|
|
859
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
860
|
-
*
|
|
861
|
-
* @param colors array of colors to choose from
|
|
862
|
-
*
|
|
863
|
-
* @public exported from `@promptbook/color`
|
|
864
|
-
*/
|
|
865
|
-
function furthest(...colors) {
|
|
866
|
-
return (color) => {
|
|
867
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
868
|
-
return furthestColor;
|
|
869
|
-
};
|
|
870
|
-
}
|
|
871
|
-
/**
|
|
872
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
873
|
-
*
|
|
874
|
-
* @public exported from `@promptbook/color`
|
|
875
|
-
*/
|
|
876
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
877
|
-
|
|
878
|
-
/**
|
|
879
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
880
|
-
*
|
|
881
|
-
* @param amount from 0 to 1
|
|
882
|
-
*
|
|
883
|
-
* @public exported from `@promptbook/color`
|
|
884
|
-
*/
|
|
885
|
-
function grayscale(amount) {
|
|
886
|
-
return ({ red, green, blue, alpha }) => {
|
|
887
|
-
const average = (red + green + blue) / 3;
|
|
888
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
889
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
890
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
891
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
892
|
-
};
|
|
893
|
-
}
|
|
894
|
-
|
|
895
882
|
/**
|
|
896
883
|
* Makes color transformer which saturate the given color
|
|
897
884
|
*
|
|
@@ -960,16 +947,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
960
947
|
*
|
|
961
948
|
* @public exported from `@promptbook/core`
|
|
962
949
|
*/
|
|
963
|
-
const PROMPTBOOK_COLOR = Color.
|
|
964
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
950
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
951
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
965
952
|
/**
|
|
966
|
-
*
|
|
953
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
954
|
+
*
|
|
955
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
956
|
+
*
|
|
957
|
+
* @public exported from `@promptbook/core`
|
|
958
|
+
*/
|
|
959
|
+
({
|
|
960
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
961
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
962
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
963
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
964
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
965
|
+
});
|
|
966
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
967
|
+
/**
|
|
968
|
+
* Chat color of the Promptbook (in chat)
|
|
967
969
|
*
|
|
968
970
|
* TODO: [🗽] Unite branding and make single place for it
|
|
969
971
|
*
|
|
970
972
|
* @public exported from `@promptbook/core`
|
|
971
973
|
*/
|
|
972
974
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
975
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
973
976
|
/**
|
|
974
977
|
* Color of the user (in chat)
|
|
975
978
|
*
|
|
@@ -978,6 +981,7 @@ PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
|
978
981
|
* @public exported from `@promptbook/core`
|
|
979
982
|
*/
|
|
980
983
|
Color.fromHex('#1D4ED8');
|
|
984
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
981
985
|
/**
|
|
982
986
|
* When the title is not provided, the default title is used
|
|
983
987
|
*
|
|
@@ -1029,7 +1033,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
|
1029
1033
|
function getErrorReportUrl(error) {
|
|
1030
1034
|
const report = {
|
|
1031
1035
|
title: `🐜 Error report from ${NAME}`,
|
|
1032
|
-
body: spaceTrim((block) => `
|
|
1036
|
+
body: spaceTrim$2((block) => `
|
|
1033
1037
|
|
|
1034
1038
|
|
|
1035
1039
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1488,7 +1492,7 @@ const expectCommandParser = {
|
|
|
1488
1492
|
/**
|
|
1489
1493
|
* Description of the FORMAT command
|
|
1490
1494
|
*/
|
|
1491
|
-
description: spaceTrim(`
|
|
1495
|
+
description: spaceTrim$2(`
|
|
1492
1496
|
Expect command describes the desired output of the task *(after post-processing)*
|
|
1493
1497
|
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.
|
|
1494
1498
|
`),
|
|
@@ -1562,7 +1566,7 @@ const expectCommandParser = {
|
|
|
1562
1566
|
}
|
|
1563
1567
|
catch (error) {
|
|
1564
1568
|
assertsError(error);
|
|
1565
|
-
throw new ParseError(spaceTrim((block) => `
|
|
1569
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
1566
1570
|
Invalid FORMAT command
|
|
1567
1571
|
${block(error.message)}:
|
|
1568
1572
|
`));
|
|
@@ -1714,7 +1718,7 @@ const CsvFormatParser = {
|
|
|
1714
1718
|
const { value, outputParameterName, settings, mapCallback, onProgress } = options;
|
|
1715
1719
|
const csv = csvParse(value, settings);
|
|
1716
1720
|
if (csv.errors.length !== 0) {
|
|
1717
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
1721
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
1718
1722
|
CSV parsing error
|
|
1719
1723
|
|
|
1720
1724
|
Error(s) from CSV parsing:
|
|
@@ -1759,7 +1763,7 @@ const CsvFormatParser = {
|
|
|
1759
1763
|
const { value, settings, mapCallback, onProgress } = options;
|
|
1760
1764
|
const csv = csvParse(value, settings);
|
|
1761
1765
|
if (csv.errors.length !== 0) {
|
|
1762
|
-
throw new CsvFormatError(spaceTrim((block) => `
|
|
1766
|
+
throw new CsvFormatError(spaceTrim$2((block) => `
|
|
1763
1767
|
CSV parsing error
|
|
1764
1768
|
|
|
1765
1769
|
Error(s) from CSV parsing:
|
|
@@ -2104,7 +2108,7 @@ function checkSerializableAsJson(options) {
|
|
|
2104
2108
|
}
|
|
2105
2109
|
else if (typeof value === 'object') {
|
|
2106
2110
|
if (value instanceof Date) {
|
|
2107
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2111
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2108
2112
|
\`${name}\` is Date
|
|
2109
2113
|
|
|
2110
2114
|
Use \`string_date_iso8601\` instead
|
|
@@ -2123,7 +2127,7 @@ function checkSerializableAsJson(options) {
|
|
|
2123
2127
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
2124
2128
|
}
|
|
2125
2129
|
else if (value instanceof Error) {
|
|
2126
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2130
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2127
2131
|
\`${name}\` is unserialized Error
|
|
2128
2132
|
|
|
2129
2133
|
Use function \`serializeError\`
|
|
@@ -2146,7 +2150,7 @@ function checkSerializableAsJson(options) {
|
|
|
2146
2150
|
}
|
|
2147
2151
|
catch (error) {
|
|
2148
2152
|
assertsError(error);
|
|
2149
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2153
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2150
2154
|
\`${name}\` is not serializable
|
|
2151
2155
|
|
|
2152
2156
|
${block(error.stack || error.message)}
|
|
@@ -2178,7 +2182,7 @@ function checkSerializableAsJson(options) {
|
|
|
2178
2182
|
}
|
|
2179
2183
|
}
|
|
2180
2184
|
else {
|
|
2181
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2185
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2182
2186
|
\`${name}\` is unknown type
|
|
2183
2187
|
|
|
2184
2188
|
Additional message for \`${name}\`:
|
|
@@ -2208,7 +2212,7 @@ function deepClone(objectValue) {
|
|
|
2208
2212
|
TODO: [🧠] Is there a better implementation?
|
|
2209
2213
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
2210
2214
|
> for (const propertyName of propertyNames) {
|
|
2211
|
-
> const value = (objectValue as
|
|
2215
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
2212
2216
|
> if (value && typeof value === 'object') {
|
|
2213
2217
|
> deepClone(value);
|
|
2214
2218
|
> }
|
|
@@ -2287,6 +2291,8 @@ const RESERVED_PARAMETER_NAMES = exportJson({
|
|
|
2287
2291
|
/**
|
|
2288
2292
|
* Normalizes a given text to camelCase format.
|
|
2289
2293
|
*
|
|
2294
|
+
* Note: [🔂] This function is idempotent.
|
|
2295
|
+
*
|
|
2290
2296
|
* @param text The text to be normalized.
|
|
2291
2297
|
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
2292
2298
|
* @returns The camelCase formatted string.
|
|
@@ -2645,6 +2651,8 @@ function removeQuotes(text) {
|
|
|
2645
2651
|
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
2646
2652
|
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
2647
2653
|
*
|
|
2654
|
+
* Note: [🔂] This function is idempotent.
|
|
2655
|
+
*
|
|
2648
2656
|
* @param parameterName The parameter name to validate and normalize.
|
|
2649
2657
|
* @returns The validated and normalized parameter name.
|
|
2650
2658
|
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
@@ -2704,7 +2712,7 @@ function validateParameterName(parameterName) {
|
|
|
2704
2712
|
if (!(error instanceof ParseError)) {
|
|
2705
2713
|
throw error;
|
|
2706
2714
|
}
|
|
2707
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2715
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2708
2716
|
${block(error.message)}
|
|
2709
2717
|
|
|
2710
2718
|
Tried to validate parameter name:
|
|
@@ -2763,7 +2771,7 @@ const foreachCommandParser = {
|
|
|
2763
2771
|
const assignSign = args[3];
|
|
2764
2772
|
const formatDefinition = FORMAT_DEFINITIONS.find((formatDefinition) => [formatDefinition.formatName, ...(formatDefinition.aliases || [])].includes(formatName));
|
|
2765
2773
|
if (formatDefinition === undefined) {
|
|
2766
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2774
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2767
2775
|
Unsupported format "${formatName}"
|
|
2768
2776
|
|
|
2769
2777
|
Available formats:
|
|
@@ -2775,7 +2783,7 @@ const foreachCommandParser = {
|
|
|
2775
2783
|
}
|
|
2776
2784
|
const subvalueParser = formatDefinition.subvalueParsers.find((subvalueParser) => [subvalueParser.subvalueName, ...(subvalueParser.aliases || [])].includes(subformatName));
|
|
2777
2785
|
if (subvalueParser === undefined) {
|
|
2778
|
-
throw new ParseError(spaceTrim((block) => `
|
|
2786
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
2779
2787
|
Unsupported subformat name "${subformatName}" for format "${formatName}"
|
|
2780
2788
|
|
|
2781
2789
|
Available subformat names for format "${formatDefinition.formatName}":
|
|
@@ -2823,7 +2831,7 @@ const foreachCommandParser = {
|
|
|
2823
2831
|
outputSubparameterName = 'newLine';
|
|
2824
2832
|
}
|
|
2825
2833
|
else {
|
|
2826
|
-
throw new ParseError(spaceTrim(`
|
|
2834
|
+
throw new ParseError(spaceTrim$2(`
|
|
2827
2835
|
FOREACH ${formatName} ${subformatName} must specify output subparameter
|
|
2828
2836
|
|
|
2829
2837
|
Correct example:
|
|
@@ -2899,7 +2907,7 @@ const formatCommandParser = {
|
|
|
2899
2907
|
/**
|
|
2900
2908
|
* Description of the FORMAT command
|
|
2901
2909
|
*/
|
|
2902
|
-
description: spaceTrim(`
|
|
2910
|
+
description: spaceTrim$2(`
|
|
2903
2911
|
Format command describes the desired output of the task (after post-processing)
|
|
2904
2912
|
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.
|
|
2905
2913
|
`),
|
|
@@ -3271,7 +3279,7 @@ const formfactorCommandParser = {
|
|
|
3271
3279
|
const formfactorNameCandidate = args[0].toUpperCase();
|
|
3272
3280
|
const formfactor = FORMFACTOR_DEFINITIONS.find((definition) => [definition.name, ...{ aliasNames: [], ...definition }.aliasNames].includes(formfactorNameCandidate));
|
|
3273
3281
|
if (formfactor === undefined) {
|
|
3274
|
-
throw new ParseError(spaceTrim((block) => `
|
|
3282
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3275
3283
|
Unknown formfactor name "${formfactorNameCandidate}"
|
|
3276
3284
|
|
|
3277
3285
|
Available formfactors:
|
|
@@ -3290,7 +3298,7 @@ const formfactorCommandParser = {
|
|
|
3290
3298
|
*/
|
|
3291
3299
|
$applyToPipelineJson(command, $pipelineJson) {
|
|
3292
3300
|
if ($pipelineJson.formfactorName !== undefined && $pipelineJson.formfactorName !== command.formfactorName) {
|
|
3293
|
-
throw new ParseError(spaceTrim(`
|
|
3301
|
+
throw new ParseError(spaceTrim$2(`
|
|
3294
3302
|
Redefinition of \`FORMFACTOR\` in the pipeline head
|
|
3295
3303
|
|
|
3296
3304
|
You have used:
|
|
@@ -3482,6 +3490,8 @@ function isValidUrl(url) {
|
|
|
3482
3490
|
/**
|
|
3483
3491
|
* Converts a given text to kebab-case format.
|
|
3484
3492
|
*
|
|
3493
|
+
* Note: [🔂] This function is idempotent.
|
|
3494
|
+
*
|
|
3485
3495
|
* @param text The text to be converted.
|
|
3486
3496
|
* @returns The kebab-case formatted string.
|
|
3487
3497
|
* @example 'hello-world'
|
|
@@ -3591,7 +3601,7 @@ const knowledgeCommandParser = {
|
|
|
3591
3601
|
*/
|
|
3592
3602
|
parse(input) {
|
|
3593
3603
|
const { args } = input;
|
|
3594
|
-
const knowledgeSourceContent = spaceTrim(args[0] || '');
|
|
3604
|
+
const knowledgeSourceContent = spaceTrim$2(args[0] || '');
|
|
3595
3605
|
if (knowledgeSourceContent === '') {
|
|
3596
3606
|
throw new ParseError(`Source is not defined`);
|
|
3597
3607
|
}
|
|
@@ -3649,7 +3659,7 @@ const knowledgeCommandParser = {
|
|
|
3649
3659
|
* @see {@link ModelVariant}
|
|
3650
3660
|
* @public exported from `@promptbook/core`
|
|
3651
3661
|
*/
|
|
3652
|
-
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3662
|
+
const MODEL_VARIANTS = ['COMPLETION', 'CHAT', 'IMAGE_GENERATION', 'EMBEDDING' /* <- TODO [🏳] */ /* <- [🤖] */];
|
|
3653
3663
|
|
|
3654
3664
|
/**
|
|
3655
3665
|
* Parses the model command
|
|
@@ -3685,7 +3695,7 @@ const modelCommandParser = {
|
|
|
3685
3695
|
*/
|
|
3686
3696
|
parse(input) {
|
|
3687
3697
|
const { args, normalized } = input;
|
|
3688
|
-
const availableVariantsMessage = spaceTrim((block) => `
|
|
3698
|
+
const availableVariantsMessage = spaceTrim$2((block) => `
|
|
3689
3699
|
Available variants are:
|
|
3690
3700
|
${block(MODEL_VARIANTS.map((variantName) => `- ${variantName}${variantName !== 'EMBEDDING' ? '' : ' (Not available in pipeline)'}`).join('\n'))}
|
|
3691
3701
|
`);
|
|
@@ -3707,14 +3717,14 @@ const modelCommandParser = {
|
|
|
3707
3717
|
// <- Note: [🤖]
|
|
3708
3718
|
}
|
|
3709
3719
|
else if (normalized.startsWith('MODEL_VARIANT_EMBED')) {
|
|
3710
|
-
spaceTrim((block) => `
|
|
3720
|
+
spaceTrim$2((block) => `
|
|
3711
3721
|
Embedding model can not be used in pipeline
|
|
3712
3722
|
|
|
3713
3723
|
${block(availableVariantsMessage)}
|
|
3714
3724
|
`);
|
|
3715
3725
|
}
|
|
3716
3726
|
else {
|
|
3717
|
-
throw new ParseError(spaceTrim((block) => `
|
|
3727
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3718
3728
|
Unknown model variant in command:
|
|
3719
3729
|
|
|
3720
3730
|
${block(availableVariantsMessage)}
|
|
@@ -3729,7 +3739,7 @@ const modelCommandParser = {
|
|
|
3729
3739
|
};
|
|
3730
3740
|
}
|
|
3731
3741
|
else {
|
|
3732
|
-
throw new ParseError(spaceTrim((block) => `
|
|
3742
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3733
3743
|
Unknown model key in command.
|
|
3734
3744
|
|
|
3735
3745
|
Supported model keys are:
|
|
@@ -3756,7 +3766,7 @@ const modelCommandParser = {
|
|
|
3756
3766
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3757
3767
|
}
|
|
3758
3768
|
else {
|
|
3759
|
-
throw new ParseError(spaceTrim(`
|
|
3769
|
+
throw new ParseError(spaceTrim$2(`
|
|
3760
3770
|
Redefinition of \`MODEL ${command.key}\` in the pipeline head
|
|
3761
3771
|
|
|
3762
3772
|
You have used:
|
|
@@ -3788,7 +3798,7 @@ const modelCommandParser = {
|
|
|
3788
3798
|
// <- TODO: [🏮] Some standard way how to transform errors into warnings and how to handle non-critical fails during the tasks
|
|
3789
3799
|
}
|
|
3790
3800
|
else {
|
|
3791
|
-
throw new ParseError(spaceTrim(`
|
|
3801
|
+
throw new ParseError(spaceTrim$2(`
|
|
3792
3802
|
Redefinition of MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}"
|
|
3793
3803
|
|
|
3794
3804
|
You have used:
|
|
@@ -3798,7 +3808,7 @@ const modelCommandParser = {
|
|
|
3798
3808
|
}
|
|
3799
3809
|
}
|
|
3800
3810
|
if (command.value === ($pipelineJson.defaultModelRequirements || {})[command.key]) {
|
|
3801
|
-
console.log(spaceTrim(`
|
|
3811
|
+
console.log(spaceTrim$2(`
|
|
3802
3812
|
Setting MODEL \`${command.key}\` in the task "${$taskJson.title || $taskJson.name}" to the same value as in the pipeline head
|
|
3803
3813
|
|
|
3804
3814
|
In pipeline head:
|
|
@@ -3881,7 +3891,7 @@ const parameterCommandParser = {
|
|
|
3881
3891
|
// <- TODO: When [🥶] fixed, change to:
|
|
3882
3892
|
// > const parameterDescriptionRaw = rawArgs.split(parameterNameRaw).join('').trim();
|
|
3883
3893
|
if (parameterDescriptionRaw && parameterDescriptionRaw.match(/\{(?<embeddedParameterName>[a-z0-9_]+)\}/im)) {
|
|
3884
|
-
throw new ParseError(spaceTrim((block) => `
|
|
3894
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
3885
3895
|
Parameter \`{${parameterNameRaw}}\` can not contain another parameter in description
|
|
3886
3896
|
|
|
3887
3897
|
The description:
|
|
@@ -4063,7 +4073,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
4063
4073
|
persona.description = personaDescription;
|
|
4064
4074
|
return;
|
|
4065
4075
|
}
|
|
4066
|
-
console.warn(spaceTrim(`
|
|
4076
|
+
console.warn(spaceTrim$2(`
|
|
4067
4077
|
|
|
4068
4078
|
Persona "${personaName}" is defined multiple times with different description:
|
|
4069
4079
|
|
|
@@ -4074,7 +4084,7 @@ function $applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
|
4074
4084
|
${personaDescription}
|
|
4075
4085
|
|
|
4076
4086
|
`));
|
|
4077
|
-
persona.description += spaceTrim('\n\n' + personaDescription);
|
|
4087
|
+
persona.description += spaceTrim$2('\n\n' + personaDescription);
|
|
4078
4088
|
}
|
|
4079
4089
|
|
|
4080
4090
|
/**
|
|
@@ -4296,7 +4306,7 @@ const sectionCommandParser = {
|
|
|
4296
4306
|
normalized = normalized.split('DIALOGUE').join('DIALOG');
|
|
4297
4307
|
const taskTypes = SectionTypes.filter((sectionType) => normalized.includes(sectionType.split('_TASK').join('')));
|
|
4298
4308
|
if (taskTypes.length !== 1) {
|
|
4299
|
-
throw new ParseError(spaceTrim((block) => `
|
|
4309
|
+
throw new ParseError(spaceTrim$2((block) => `
|
|
4300
4310
|
Unknown section type "${normalized}"
|
|
4301
4311
|
|
|
4302
4312
|
Supported section types are:
|
|
@@ -4316,7 +4326,7 @@ const sectionCommandParser = {
|
|
|
4316
4326
|
*/
|
|
4317
4327
|
$applyToTaskJson(command, $taskJson, $pipelineJson) {
|
|
4318
4328
|
if ($taskJson.isSectionTypeSet === true) {
|
|
4319
|
-
throw new ParseError(spaceTrim(`
|
|
4329
|
+
throw new ParseError(spaceTrim$2(`
|
|
4320
4330
|
Section type is already defined in the section.
|
|
4321
4331
|
It can be defined only once.
|
|
4322
4332
|
`));
|
|
@@ -4882,6 +4892,48 @@ function parseCommandVariant(input) {
|
|
|
4882
4892
|
return null;
|
|
4883
4893
|
}
|
|
4884
4894
|
|
|
4895
|
+
/**
|
|
4896
|
+
* Number of padding lines to add at the end of the book content
|
|
4897
|
+
*
|
|
4898
|
+
* @public exported from `@promptbook/core`
|
|
4899
|
+
*/
|
|
4900
|
+
const PADDING_LINES = 11;
|
|
4901
|
+
/**
|
|
4902
|
+
* A function that adds padding to the book content
|
|
4903
|
+
*
|
|
4904
|
+
* Note: [🔂] This function is idempotent.
|
|
4905
|
+
*
|
|
4906
|
+
* @public exported from `@promptbook/core`
|
|
4907
|
+
*/
|
|
4908
|
+
function padBook(content) {
|
|
4909
|
+
if (!content) {
|
|
4910
|
+
return '\n'.repeat(PADDING_LINES);
|
|
4911
|
+
}
|
|
4912
|
+
const lines = content.split('\n');
|
|
4913
|
+
let trailingEmptyLines = 0;
|
|
4914
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
4915
|
+
const line = lines[i];
|
|
4916
|
+
if (line === undefined) {
|
|
4917
|
+
// Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
|
|
4918
|
+
continue;
|
|
4919
|
+
}
|
|
4920
|
+
if (line.trim() === '') {
|
|
4921
|
+
trailingEmptyLines++;
|
|
4922
|
+
}
|
|
4923
|
+
else {
|
|
4924
|
+
break;
|
|
4925
|
+
}
|
|
4926
|
+
}
|
|
4927
|
+
if (trailingEmptyLines >= PADDING_LINES) {
|
|
4928
|
+
return content;
|
|
4929
|
+
}
|
|
4930
|
+
const linesToAdd = PADDING_LINES - trailingEmptyLines;
|
|
4931
|
+
return (content + '\n'.repeat(linesToAdd));
|
|
4932
|
+
}
|
|
4933
|
+
/**
|
|
4934
|
+
* TODO: [🧠] Maybe export
|
|
4935
|
+
*/
|
|
4936
|
+
|
|
4885
4937
|
/**
|
|
4886
4938
|
* Checks if value is valid email
|
|
4887
4939
|
*
|
|
@@ -4901,6 +4953,8 @@ function isValidEmail(email) {
|
|
|
4901
4953
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
4902
4954
|
* 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.
|
|
4903
4955
|
*
|
|
4956
|
+
* Note: [🔂] This function is idempotent.
|
|
4957
|
+
*
|
|
4904
4958
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
4905
4959
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
4906
4960
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -4945,7 +4999,7 @@ function removeMarkdownComments(content) {
|
|
|
4945
4999
|
*/
|
|
4946
5000
|
function isFlatPipeline(pipelineString) {
|
|
4947
5001
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
4948
|
-
pipelineString = spaceTrim(pipelineString);
|
|
5002
|
+
pipelineString = spaceTrim$2(pipelineString);
|
|
4949
5003
|
const isMarkdownBeginningWithHeadline = pipelineString.startsWith('# ');
|
|
4950
5004
|
//const isLastLineReturnStatement = pipelineString.split('\n').pop()!.split('`').join('').startsWith('->');
|
|
4951
5005
|
const isBacktickBlockUsed = pipelineString.includes('```');
|
|
@@ -4971,6 +5025,7 @@ function deflatePipeline(pipelineString) {
|
|
|
4971
5025
|
if (!isFlatPipeline(pipelineString)) {
|
|
4972
5026
|
return pipelineString;
|
|
4973
5027
|
}
|
|
5028
|
+
pipelineString = spaceTrim$2(pipelineString);
|
|
4974
5029
|
const pipelineStringLines = pipelineString.split('\n');
|
|
4975
5030
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
4976
5031
|
let returnStatement;
|
|
@@ -4983,19 +5038,19 @@ function deflatePipeline(pipelineString) {
|
|
|
4983
5038
|
returnStatement = `-> {${DEFAULT_BOOK_OUTPUT_PARAMETER_NAME}}`;
|
|
4984
5039
|
pipelineStringLines.push(potentialReturnStatement);
|
|
4985
5040
|
}
|
|
4986
|
-
const prompt = spaceTrim(pipelineStringLines.join('\n'));
|
|
5041
|
+
const prompt = spaceTrim$2(pipelineStringLines.join('\n'));
|
|
4987
5042
|
let quotedPrompt;
|
|
4988
5043
|
if (prompt.split('\n').length <= 1) {
|
|
4989
5044
|
quotedPrompt = `> ${prompt}`;
|
|
4990
5045
|
}
|
|
4991
5046
|
else {
|
|
4992
|
-
quotedPrompt = spaceTrim((block) => `
|
|
5047
|
+
quotedPrompt = spaceTrim$2((block) => `
|
|
4993
5048
|
\`\`\`
|
|
4994
5049
|
${block(prompt.split('`').join('\\`'))}
|
|
4995
5050
|
\`\`\`
|
|
4996
5051
|
`);
|
|
4997
5052
|
}
|
|
4998
|
-
pipelineString = validatePipelineString(spaceTrim((block) => `
|
|
5053
|
+
pipelineString = validatePipelineString(spaceTrim$2((block) => `
|
|
4999
5054
|
# ${DEFAULT_BOOK_TITLE}
|
|
5000
5055
|
|
|
5001
5056
|
## Prompt
|
|
@@ -5005,7 +5060,7 @@ function deflatePipeline(pipelineString) {
|
|
|
5005
5060
|
${returnStatement}
|
|
5006
5061
|
`));
|
|
5007
5062
|
// <- TODO: Maybe use book` notation
|
|
5008
|
-
return pipelineString;
|
|
5063
|
+
return padBook(pipelineString);
|
|
5009
5064
|
}
|
|
5010
5065
|
/**
|
|
5011
5066
|
* TODO: Unit test
|
|
@@ -5063,7 +5118,7 @@ function addPipelineCommand(options) {
|
|
|
5063
5118
|
);
|
|
5064
5119
|
*/
|
|
5065
5120
|
}
|
|
5066
|
-
return spaceTrim(newLines.join('\n'));
|
|
5121
|
+
return spaceTrim$2(newLines.join('\n'));
|
|
5067
5122
|
}
|
|
5068
5123
|
/**
|
|
5069
5124
|
* TODO: [🧠] What is the better solution - `- xxx`, - `- xxx` or preserve (see also next TODO)
|
|
@@ -5105,7 +5160,7 @@ function removePipelineCommand(options) {
|
|
|
5105
5160
|
}
|
|
5106
5161
|
newLines.push(line);
|
|
5107
5162
|
}
|
|
5108
|
-
const newPipeline = spaceTrim(newLines.join('\n'));
|
|
5163
|
+
const newPipeline = spaceTrim$2(newLines.join('\n'));
|
|
5109
5164
|
return newPipeline;
|
|
5110
5165
|
}
|
|
5111
5166
|
|
|
@@ -5208,7 +5263,7 @@ function isSerializableAsJson(value) {
|
|
|
5208
5263
|
*/
|
|
5209
5264
|
function stringifyPipelineJson(pipeline) {
|
|
5210
5265
|
if (!isSerializableAsJson(pipeline)) {
|
|
5211
|
-
throw new UnexpectedError(spaceTrim(`
|
|
5266
|
+
throw new UnexpectedError(spaceTrim$2(`
|
|
5212
5267
|
Cannot stringify the pipeline, because it is not serializable as JSON
|
|
5213
5268
|
|
|
5214
5269
|
There can be multiple reasons:
|