@promptbook/remote-client 0.103.0-10 → 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 +59 -35
- 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 +6 -1
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +77 -7
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -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 +1 -1
- 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 +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/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/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/config.d.ts +0 -11
- 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/umd/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('spacetrim'), require('crypto'), require('socket.io-client'), require('crypto-js'), require('crypto-js/enc-hex'), require('papaparse'), require('path')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'spacetrim', 'crypto', 'socket.io-client', 'crypto-js', 'crypto-js/enc-hex', 'papaparse', 'path'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.spaceTrim, global.crypto, global.socket_ioClient, global.cryptoJs, global.hexEncoder, global.papaparse, global.path));
|
|
5
|
-
})(this, (function (exports, spaceTrim, crypto, socket_ioClient, cryptoJs, hexEncoder, papaparse, path) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["promptbook-remote-client"] = {}, global.spaceTrim$1, global.crypto, global.socket_ioClient, global.cryptoJs, global.hexEncoder, global.papaparse, global.path));
|
|
5
|
+
})(this, (function (exports, spaceTrim$1, crypto, socket_ioClient, cryptoJs, hexEncoder, papaparse, path) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim);
|
|
9
|
+
var spaceTrim__default = /*#__PURE__*/_interopDefaultLegacy(spaceTrim$1);
|
|
10
10
|
var hexEncoder__default = /*#__PURE__*/_interopDefaultLegacy(hexEncoder);
|
|
11
11
|
|
|
12
12
|
// ⚠️ WARNING: This code has been generated so that any manual changes will be overwritten
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
* @generated
|
|
17
17
|
* @see https://github.com/webgptorg/book
|
|
18
18
|
*/
|
|
19
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
19
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
20
20
|
/**
|
|
21
21
|
* The version of the Promptbook engine
|
|
22
22
|
*
|
|
23
23
|
* @generated
|
|
24
24
|
* @see https://github.com/webgptorg/promptbook
|
|
25
25
|
*/
|
|
26
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
26
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
|
|
27
27
|
/**
|
|
28
28
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
29
29
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -85,6 +85,22 @@
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
/**
|
|
89
|
+
* This error indicates error from the database
|
|
90
|
+
*
|
|
91
|
+
* @public exported from `@promptbook/core`
|
|
92
|
+
*/
|
|
93
|
+
class DatabaseError extends Error {
|
|
94
|
+
constructor(message) {
|
|
95
|
+
super(message);
|
|
96
|
+
this.name = 'DatabaseError';
|
|
97
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
102
|
+
*/
|
|
103
|
+
|
|
88
104
|
/**
|
|
89
105
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
90
106
|
*
|
|
@@ -147,7 +163,7 @@
|
|
|
147
163
|
*/
|
|
148
164
|
class MissingToolsError extends Error {
|
|
149
165
|
constructor(message) {
|
|
150
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
166
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
151
167
|
${block(message)}
|
|
152
168
|
|
|
153
169
|
Note: You have probably forgot to provide some tools for pipeline execution or preparation
|
|
@@ -158,6 +174,19 @@
|
|
|
158
174
|
}
|
|
159
175
|
}
|
|
160
176
|
|
|
177
|
+
/**
|
|
178
|
+
* This error indicates that promptbook operation is not allowed
|
|
179
|
+
*
|
|
180
|
+
* @public exported from `@promptbook/core`
|
|
181
|
+
*/
|
|
182
|
+
class NotAllowed extends Error {
|
|
183
|
+
constructor(message) {
|
|
184
|
+
super(message);
|
|
185
|
+
this.name = 'NotAllowed';
|
|
186
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
161
190
|
/**
|
|
162
191
|
* This error indicates that promptbook not found in the collection
|
|
163
192
|
*
|
|
@@ -178,7 +207,7 @@
|
|
|
178
207
|
*/
|
|
179
208
|
class NotYetImplementedError extends Error {
|
|
180
209
|
constructor(message) {
|
|
181
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
210
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
182
211
|
${block(message)}
|
|
183
212
|
|
|
184
213
|
Note: This feature is not implemented yet but it will be soon.
|
|
@@ -213,6 +242,7 @@
|
|
|
213
242
|
/**
|
|
214
243
|
* Generates random token
|
|
215
244
|
*
|
|
245
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
216
246
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
217
247
|
*
|
|
218
248
|
* @private internal helper function
|
|
@@ -222,6 +252,7 @@
|
|
|
222
252
|
return crypto.randomBytes(randomness).toString('hex');
|
|
223
253
|
}
|
|
224
254
|
/**
|
|
255
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
225
256
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
226
257
|
*/
|
|
227
258
|
|
|
@@ -283,6 +314,17 @@
|
|
|
283
314
|
}
|
|
284
315
|
}
|
|
285
316
|
|
|
317
|
+
/**
|
|
318
|
+
* Trims string from all 4 sides
|
|
319
|
+
*
|
|
320
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
321
|
+
* Developed by same author @hejny as this package
|
|
322
|
+
*
|
|
323
|
+
* @public exported from `@promptbook/utils`
|
|
324
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
325
|
+
*/
|
|
326
|
+
const spaceTrim = spaceTrim$1.spaceTrim;
|
|
327
|
+
|
|
286
328
|
/**
|
|
287
329
|
* @private util of `@promptbook/color`
|
|
288
330
|
* @de
|
|
@@ -331,6 +373,7 @@
|
|
|
331
373
|
* @public exported from `@promptbook/color`
|
|
332
374
|
*/
|
|
333
375
|
const CSS_COLORS = {
|
|
376
|
+
promptbook: '#79EAFD',
|
|
334
377
|
transparent: 'rgba(0,0,0,0)',
|
|
335
378
|
aliceblue: '#f0f8ff',
|
|
336
379
|
antiquewhite: '#faebd7',
|
|
@@ -512,9 +555,6 @@
|
|
|
512
555
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
513
556
|
}
|
|
514
557
|
}
|
|
515
|
-
/**
|
|
516
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
517
|
-
*/
|
|
518
558
|
|
|
519
559
|
/**
|
|
520
560
|
* Color object represents an RGB color with alpha channel
|
|
@@ -549,6 +589,28 @@
|
|
|
549
589
|
throw new Error(`Can not create color from given object`);
|
|
550
590
|
}
|
|
551
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Creates a new Color instance from miscellaneous formats
|
|
594
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
595
|
+
*
|
|
596
|
+
* @param color
|
|
597
|
+
* @returns Color object
|
|
598
|
+
*/
|
|
599
|
+
static fromSafe(color) {
|
|
600
|
+
try {
|
|
601
|
+
return Color.from(color);
|
|
602
|
+
}
|
|
603
|
+
catch (error) {
|
|
604
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
605
|
+
console.warn(spaceTrim((block) => `
|
|
606
|
+
Color.fromSafe error:
|
|
607
|
+
${block(error.message)}
|
|
608
|
+
|
|
609
|
+
Returning default PROMPTBOOK_COLOR.
|
|
610
|
+
`));
|
|
611
|
+
return Color.fromString('promptbook');
|
|
612
|
+
}
|
|
613
|
+
}
|
|
552
614
|
/**
|
|
553
615
|
* Creates a new Color instance from miscellaneous string formats
|
|
554
616
|
*
|
|
@@ -616,6 +678,9 @@
|
|
|
616
678
|
if (hex.length === 3) {
|
|
617
679
|
return Color.fromHex3(hex);
|
|
618
680
|
}
|
|
681
|
+
if (hex.length === 4) {
|
|
682
|
+
return Color.fromHex4(hex);
|
|
683
|
+
}
|
|
619
684
|
if (hex.length === 6) {
|
|
620
685
|
return Color.fromHex6(hex);
|
|
621
686
|
}
|
|
@@ -636,6 +701,19 @@
|
|
|
636
701
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
637
702
|
return take(new Color(r, g, b));
|
|
638
703
|
}
|
|
704
|
+
/**
|
|
705
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
706
|
+
*
|
|
707
|
+
* @param color in hex for example `09df`
|
|
708
|
+
* @returns Color object
|
|
709
|
+
*/
|
|
710
|
+
static fromHex4(hex) {
|
|
711
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
712
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
713
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
714
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
715
|
+
return take(new Color(r, g, b, a));
|
|
716
|
+
}
|
|
639
717
|
/**
|
|
640
718
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
641
719
|
*
|
|
@@ -826,7 +904,8 @@
|
|
|
826
904
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
827
905
|
*/
|
|
828
906
|
static isHexColorString(value) {
|
|
829
|
-
return typeof value === 'string' &&
|
|
907
|
+
return (typeof value === 'string' &&
|
|
908
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
830
909
|
}
|
|
831
910
|
/**
|
|
832
911
|
* Creates new Color object
|
|
@@ -941,6 +1020,23 @@
|
|
|
941
1020
|
* TODO: Maybe connect with textures
|
|
942
1021
|
*/
|
|
943
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
1025
|
+
*
|
|
1026
|
+
* @param amount from 0 to 1
|
|
1027
|
+
*
|
|
1028
|
+
* @public exported from `@promptbook/color`
|
|
1029
|
+
*/
|
|
1030
|
+
function grayscale(amount) {
|
|
1031
|
+
return ({ red, green, blue, alpha }) => {
|
|
1032
|
+
const average = (red + green + blue) / 3;
|
|
1033
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
1034
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
1035
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1036
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
944
1040
|
/**
|
|
945
1041
|
* Converts HSL values to RGB values
|
|
946
1042
|
*
|
|
@@ -1056,102 +1152,6 @@
|
|
|
1056
1152
|
* TODO: Maybe implement by mix+hsl
|
|
1057
1153
|
*/
|
|
1058
1154
|
|
|
1059
|
-
/**
|
|
1060
|
-
* Calculates distance between two colors
|
|
1061
|
-
*
|
|
1062
|
-
* @param color1 first color
|
|
1063
|
-
* @param color2 second color
|
|
1064
|
-
*
|
|
1065
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
1066
|
-
*
|
|
1067
|
-
* @public exported from `@promptbook/color`
|
|
1068
|
-
*/
|
|
1069
|
-
/**
|
|
1070
|
-
* Calculates distance between two colors without square root
|
|
1071
|
-
*
|
|
1072
|
-
* @param color1 first color
|
|
1073
|
-
* @param color2 second color
|
|
1074
|
-
*
|
|
1075
|
-
* @public exported from `@promptbook/color`
|
|
1076
|
-
*/
|
|
1077
|
-
function colorDistanceSquared(color1, color2) {
|
|
1078
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
1079
|
-
const r = color1.red - color2.red;
|
|
1080
|
-
const g = color1.green - color2.green;
|
|
1081
|
-
const b = color1.blue - color2.blue;
|
|
1082
|
-
const weightR = 2 + rmean / 256;
|
|
1083
|
-
const weightG = 4.0;
|
|
1084
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
1085
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
1086
|
-
return distance;
|
|
1087
|
-
}
|
|
1088
|
-
|
|
1089
|
-
/**
|
|
1090
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
1091
|
-
*
|
|
1092
|
-
* @param colors array of colors to choose from
|
|
1093
|
-
*
|
|
1094
|
-
* @public exported from `@promptbook/color`
|
|
1095
|
-
*/
|
|
1096
|
-
function nearest(...colors) {
|
|
1097
|
-
return (color) => {
|
|
1098
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
1099
|
-
const minDistance = Math.min(...distances);
|
|
1100
|
-
const minIndex = distances.indexOf(minDistance);
|
|
1101
|
-
const nearestColor = colors[minIndex];
|
|
1102
|
-
return nearestColor;
|
|
1103
|
-
};
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
* Color transformer which returns the negative color
|
|
1108
|
-
*
|
|
1109
|
-
* @public exported from `@promptbook/color`
|
|
1110
|
-
*/
|
|
1111
|
-
function negative(color) {
|
|
1112
|
-
const r = 255 - color.red;
|
|
1113
|
-
const g = 255 - color.green;
|
|
1114
|
-
const b = 255 - color.blue;
|
|
1115
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
/**
|
|
1119
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
1120
|
-
*
|
|
1121
|
-
* @param colors array of colors to choose from
|
|
1122
|
-
*
|
|
1123
|
-
* @public exported from `@promptbook/color`
|
|
1124
|
-
*/
|
|
1125
|
-
function furthest(...colors) {
|
|
1126
|
-
return (color) => {
|
|
1127
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
1128
|
-
return furthestColor;
|
|
1129
|
-
};
|
|
1130
|
-
}
|
|
1131
|
-
/**
|
|
1132
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
1133
|
-
*
|
|
1134
|
-
* @public exported from `@promptbook/color`
|
|
1135
|
-
*/
|
|
1136
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
1137
|
-
|
|
1138
|
-
/**
|
|
1139
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
1140
|
-
*
|
|
1141
|
-
* @param amount from 0 to 1
|
|
1142
|
-
*
|
|
1143
|
-
* @public exported from `@promptbook/color`
|
|
1144
|
-
*/
|
|
1145
|
-
function grayscale(amount) {
|
|
1146
|
-
return ({ red, green, blue, alpha }) => {
|
|
1147
|
-
const average = (red + green + blue) / 3;
|
|
1148
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
1149
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
1150
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
1151
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
1155
|
/**
|
|
1156
1156
|
* Makes color transformer which saturate the given color
|
|
1157
1157
|
*
|
|
@@ -1220,16 +1220,32 @@
|
|
|
1220
1220
|
*
|
|
1221
1221
|
* @public exported from `@promptbook/core`
|
|
1222
1222
|
*/
|
|
1223
|
-
const PROMPTBOOK_COLOR = Color.
|
|
1224
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1223
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
1224
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1225
1225
|
/**
|
|
1226
|
-
*
|
|
1226
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
1227
|
+
*
|
|
1228
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
1229
|
+
*
|
|
1230
|
+
* @public exported from `@promptbook/core`
|
|
1231
|
+
*/
|
|
1232
|
+
({
|
|
1233
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
1234
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
1235
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
1236
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
1237
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
1238
|
+
});
|
|
1239
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1240
|
+
/**
|
|
1241
|
+
* Chat color of the Promptbook (in chat)
|
|
1227
1242
|
*
|
|
1228
1243
|
* TODO: [🗽] Unite branding and make single place for it
|
|
1229
1244
|
*
|
|
1230
1245
|
* @public exported from `@promptbook/core`
|
|
1231
1246
|
*/
|
|
1232
1247
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
1248
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
1233
1249
|
/**
|
|
1234
1250
|
* Color of the user (in chat)
|
|
1235
1251
|
*
|
|
@@ -1238,6 +1254,7 @@
|
|
|
1238
1254
|
* @public exported from `@promptbook/core`
|
|
1239
1255
|
*/
|
|
1240
1256
|
Color.fromHex('#1D4ED8');
|
|
1257
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
1241
1258
|
/**
|
|
1242
1259
|
* When the title is not provided, the default title is used
|
|
1243
1260
|
*
|
|
@@ -1351,7 +1368,7 @@
|
|
|
1351
1368
|
*/
|
|
1352
1369
|
class UnexpectedError extends Error {
|
|
1353
1370
|
constructor(message) {
|
|
1354
|
-
super(spaceTrim.spaceTrim((block) => `
|
|
1371
|
+
super(spaceTrim$1.spaceTrim((block) => `
|
|
1355
1372
|
${block(message)}
|
|
1356
1373
|
|
|
1357
1374
|
Note: This error should not happen.
|
|
@@ -1377,7 +1394,7 @@
|
|
|
1377
1394
|
constructor(whatWasThrown) {
|
|
1378
1395
|
const tag = `[🤮]`;
|
|
1379
1396
|
console.error(tag, whatWasThrown);
|
|
1380
|
-
super(spaceTrim.spaceTrim(`
|
|
1397
|
+
super(spaceTrim$1.spaceTrim(`
|
|
1381
1398
|
Non-Error object was thrown
|
|
1382
1399
|
|
|
1383
1400
|
Note: Look for ${tag} in the console for more details
|
|
@@ -1412,6 +1429,8 @@
|
|
|
1412
1429
|
PromptbookFetchError,
|
|
1413
1430
|
UnexpectedError,
|
|
1414
1431
|
WrappedError,
|
|
1432
|
+
NotAllowed,
|
|
1433
|
+
DatabaseError,
|
|
1415
1434
|
// TODO: [🪑]> VersionMismatchError,
|
|
1416
1435
|
};
|
|
1417
1436
|
/**
|
|
@@ -1946,6 +1965,8 @@
|
|
|
1946
1965
|
/**
|
|
1947
1966
|
* Converts a given text to kebab-case format.
|
|
1948
1967
|
*
|
|
1968
|
+
* Note: [🔂] This function is idempotent.
|
|
1969
|
+
*
|
|
1949
1970
|
* @param text The text to be converted.
|
|
1950
1971
|
* @returns The kebab-case formatted string.
|
|
1951
1972
|
* @example 'hello-world'
|
|
@@ -3328,7 +3349,7 @@
|
|
|
3328
3349
|
TODO: [🧠] Is there a better implementation?
|
|
3329
3350
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
3330
3351
|
> for (const propertyName of propertyNames) {
|
|
3331
|
-
> const value = (objectValue as
|
|
3352
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
3332
3353
|
> if (value && typeof value === 'object') {
|
|
3333
3354
|
> deepClone(value);
|
|
3334
3355
|
> }
|
|
@@ -3421,6 +3442,8 @@
|
|
|
3421
3442
|
/**
|
|
3422
3443
|
* Normalizes a given text to camelCase format.
|
|
3423
3444
|
*
|
|
3445
|
+
* Note: [🔂] This function is idempotent.
|
|
3446
|
+
*
|
|
3424
3447
|
* @param text The text to be normalized.
|
|
3425
3448
|
* @param _isFirstLetterCapital Whether the first letter should be capitalized.
|
|
3426
3449
|
* @returns The camelCase formatted string.
|
|
@@ -3516,6 +3539,8 @@
|
|
|
3516
3539
|
* Function `validateParameterName` will normalize and validate a parameter name for use in pipelines.
|
|
3517
3540
|
* It removes diacritics, emojis, and quotes, normalizes to camelCase, and checks for reserved names and invalid characters.
|
|
3518
3541
|
*
|
|
3542
|
+
* Note: [🔂] This function is idempotent.
|
|
3543
|
+
*
|
|
3519
3544
|
* @param parameterName The parameter name to validate and normalize.
|
|
3520
3545
|
* @returns The validated and normalized parameter name.
|
|
3521
3546
|
* @throws {ParseError} If the parameter name is empty, reserved, or contains invalid characters.
|
|
@@ -5090,7 +5115,7 @@
|
|
|
5090
5115
|
function getParserForCommand(command) {
|
|
5091
5116
|
const commandParser = COMMANDS.find((commandParser) => commandParser.name === command.type);
|
|
5092
5117
|
if (commandParser === undefined) {
|
|
5093
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
5118
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
5094
5119
|
Command ${command.type} parser is not found
|
|
5095
5120
|
|
|
5096
5121
|
${block(JSON.stringify(command, null, 4)
|
|
@@ -5166,7 +5191,7 @@
|
|
|
5166
5191
|
.map(removeMarkdownFormatting)
|
|
5167
5192
|
.map((item) => item.trim());
|
|
5168
5193
|
if (items.length === 0 || items[0] === '') {
|
|
5169
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5194
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5170
5195
|
Malformed command:
|
|
5171
5196
|
- ${raw}
|
|
5172
5197
|
|
|
@@ -5202,7 +5227,7 @@
|
|
|
5202
5227
|
return command;
|
|
5203
5228
|
}
|
|
5204
5229
|
}
|
|
5205
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5230
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5206
5231
|
Malformed or unknown command:
|
|
5207
5232
|
- ${raw}
|
|
5208
5233
|
|
|
@@ -5253,7 +5278,7 @@
|
|
|
5253
5278
|
if (!(error instanceof ParseError)) {
|
|
5254
5279
|
throw error;
|
|
5255
5280
|
}
|
|
5256
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
5281
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5257
5282
|
Invalid ${commandName} command:
|
|
5258
5283
|
|
|
5259
5284
|
Your command:
|
|
@@ -5530,6 +5555,8 @@
|
|
|
5530
5555
|
* Function `validatePipelineString` will validate the if the string is a valid pipeline string
|
|
5531
5556
|
* 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.
|
|
5532
5557
|
*
|
|
5558
|
+
* Note: [🔂] This function is idempotent.
|
|
5559
|
+
*
|
|
5533
5560
|
* @param {string} pipelineString the candidate for a pipeline string
|
|
5534
5561
|
* @returns {PipelineString} the same string as input, but validated as valid
|
|
5535
5562
|
* @throws {ParseError} if the string is not a valid pipeline string
|
|
@@ -5563,6 +5590,48 @@
|
|
|
5563
5590
|
const SUPPORTED_SCRIPT_LANGUAGES = ['javascript', 'typescript', 'python'];
|
|
5564
5591
|
// <- TODO: [🏥] DRY
|
|
5565
5592
|
|
|
5593
|
+
/**
|
|
5594
|
+
* Number of padding lines to add at the end of the book content
|
|
5595
|
+
*
|
|
5596
|
+
* @public exported from `@promptbook/core`
|
|
5597
|
+
*/
|
|
5598
|
+
const PADDING_LINES = 11;
|
|
5599
|
+
/**
|
|
5600
|
+
* A function that adds padding to the book content
|
|
5601
|
+
*
|
|
5602
|
+
* Note: [🔂] This function is idempotent.
|
|
5603
|
+
*
|
|
5604
|
+
* @public exported from `@promptbook/core`
|
|
5605
|
+
*/
|
|
5606
|
+
function padBook(content) {
|
|
5607
|
+
if (!content) {
|
|
5608
|
+
return '\n'.repeat(PADDING_LINES);
|
|
5609
|
+
}
|
|
5610
|
+
const lines = content.split('\n');
|
|
5611
|
+
let trailingEmptyLines = 0;
|
|
5612
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
5613
|
+
const line = lines[i];
|
|
5614
|
+
if (line === undefined) {
|
|
5615
|
+
// Note: This should not happen in reality, but it's here to satisfy TypeScript's noUncheckedIndexedAccess option
|
|
5616
|
+
continue;
|
|
5617
|
+
}
|
|
5618
|
+
if (line.trim() === '') {
|
|
5619
|
+
trailingEmptyLines++;
|
|
5620
|
+
}
|
|
5621
|
+
else {
|
|
5622
|
+
break;
|
|
5623
|
+
}
|
|
5624
|
+
}
|
|
5625
|
+
if (trailingEmptyLines >= PADDING_LINES) {
|
|
5626
|
+
return content;
|
|
5627
|
+
}
|
|
5628
|
+
const linesToAdd = PADDING_LINES - trailingEmptyLines;
|
|
5629
|
+
return (content + '\n'.repeat(linesToAdd));
|
|
5630
|
+
}
|
|
5631
|
+
/**
|
|
5632
|
+
* TODO: [🧠] Maybe export
|
|
5633
|
+
*/
|
|
5634
|
+
|
|
5566
5635
|
/**
|
|
5567
5636
|
* Removes Markdown (or HTML) comments
|
|
5568
5637
|
*
|
|
@@ -5571,7 +5640,7 @@
|
|
|
5571
5640
|
* @public exported from `@promptbook/markdown-utils`
|
|
5572
5641
|
*/
|
|
5573
5642
|
function removeMarkdownComments(content) {
|
|
5574
|
-
return spaceTrim.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
5643
|
+
return spaceTrim$1.spaceTrim(content.replace(/<!--(.*?)-->/gs, ''));
|
|
5575
5644
|
}
|
|
5576
5645
|
|
|
5577
5646
|
/**
|
|
@@ -5608,6 +5677,7 @@
|
|
|
5608
5677
|
if (!isFlatPipeline(pipelineString)) {
|
|
5609
5678
|
return pipelineString;
|
|
5610
5679
|
}
|
|
5680
|
+
pipelineString = spaceTrim__default["default"](pipelineString);
|
|
5611
5681
|
const pipelineStringLines = pipelineString.split('\n');
|
|
5612
5682
|
const potentialReturnStatement = pipelineStringLines.pop();
|
|
5613
5683
|
let returnStatement;
|
|
@@ -5642,7 +5712,7 @@
|
|
|
5642
5712
|
${returnStatement}
|
|
5643
5713
|
`));
|
|
5644
5714
|
// <- TODO: Maybe use book` notation
|
|
5645
|
-
return pipelineString;
|
|
5715
|
+
return padBook(pipelineString);
|
|
5646
5716
|
}
|
|
5647
5717
|
/**
|
|
5648
5718
|
* TODO: Unit test
|
|
@@ -5914,6 +5984,8 @@
|
|
|
5914
5984
|
/**
|
|
5915
5985
|
* Converts a title string into a normalized name.
|
|
5916
5986
|
*
|
|
5987
|
+
* Note: [🔂] This function is idempotent.
|
|
5988
|
+
*
|
|
5917
5989
|
* @param value The title string to be converted to a name.
|
|
5918
5990
|
* @returns A normalized name derived from the input title.
|
|
5919
5991
|
* @example 'Hello World!' -> 'hello-world'
|
|
@@ -5987,7 +6059,7 @@
|
|
|
5987
6059
|
}
|
|
5988
6060
|
catch (error) {
|
|
5989
6061
|
assertsError(error);
|
|
5990
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6062
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
5991
6063
|
Can not extract variables from the script
|
|
5992
6064
|
${block(error.stack || error.message)}
|
|
5993
6065
|
|
|
@@ -6129,7 +6201,7 @@
|
|
|
6129
6201
|
if (pipelineString.startsWith('#!')) {
|
|
6130
6202
|
const [shebangLine, ...restLines] = pipelineString.split('\n');
|
|
6131
6203
|
if (!(shebangLine || '').includes('ptbk')) {
|
|
6132
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6204
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6133
6205
|
It seems that you try to parse a book file which has non-standard shebang line for book files:
|
|
6134
6206
|
Shebang line must contain 'ptbk'
|
|
6135
6207
|
|
|
@@ -6145,7 +6217,7 @@
|
|
|
6145
6217
|
pipelineString = validatePipelineString(restLines.join('\n'));
|
|
6146
6218
|
}
|
|
6147
6219
|
pipelineString = removeMarkdownComments(pipelineString);
|
|
6148
|
-
pipelineString = spaceTrim.spaceTrim(pipelineString);
|
|
6220
|
+
pipelineString = spaceTrim$1.spaceTrim(pipelineString);
|
|
6149
6221
|
// <- TODO: [😧] `spaceTrim` should preserve discriminated type *(or at lease `PipelineString`)*
|
|
6150
6222
|
pipelineString = deflatePipeline(pipelineString);
|
|
6151
6223
|
// ==============
|
|
@@ -6157,7 +6229,7 @@
|
|
|
6157
6229
|
// ==============
|
|
6158
6230
|
// Note: 1️⃣◽4️⃣ Check markdown structure
|
|
6159
6231
|
if (pipelineHead === undefined) {
|
|
6160
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6232
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6161
6233
|
Pipeline head is not defined
|
|
6162
6234
|
|
|
6163
6235
|
${block(getPipelineIdentification())}
|
|
@@ -6166,7 +6238,7 @@
|
|
|
6166
6238
|
`));
|
|
6167
6239
|
}
|
|
6168
6240
|
if (pipelineHead.level !== 1) {
|
|
6169
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6241
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6170
6242
|
Pipeline head is not h1
|
|
6171
6243
|
|
|
6172
6244
|
${block(getPipelineIdentification())}
|
|
@@ -6175,7 +6247,7 @@
|
|
|
6175
6247
|
`));
|
|
6176
6248
|
}
|
|
6177
6249
|
if (!pipelineSections.every((section) => section.level === 2)) {
|
|
6178
|
-
throw new UnexpectedError(spaceTrim.spaceTrim((block) => `
|
|
6250
|
+
throw new UnexpectedError(spaceTrim$1.spaceTrim((block) => `
|
|
6179
6251
|
Not every pipeline section is h2
|
|
6180
6252
|
|
|
6181
6253
|
${block(getPipelineIdentification())}
|
|
@@ -6188,7 +6260,7 @@
|
|
|
6188
6260
|
const defineParam = (parameterCommand) => {
|
|
6189
6261
|
const { parameterName, parameterDescription, isInput, isOutput } = parameterCommand;
|
|
6190
6262
|
if (RESERVED_PARAMETER_NAMES.includes(parameterName)) {
|
|
6191
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6263
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6192
6264
|
Parameter name {${parameterName}} is reserved and cannot be used as resulting parameter name
|
|
6193
6265
|
|
|
6194
6266
|
${block(getPipelineIdentification())}
|
|
@@ -6199,7 +6271,7 @@
|
|
|
6199
6271
|
existingParameter.description &&
|
|
6200
6272
|
existingParameter.description !== parameterDescription &&
|
|
6201
6273
|
parameterDescription) {
|
|
6202
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6274
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6203
6275
|
Parameter \`{${parameterName}}\` is defined multiple times with different description:
|
|
6204
6276
|
|
|
6205
6277
|
${block(getPipelineIdentification())}
|
|
@@ -6237,7 +6309,7 @@
|
|
|
6237
6309
|
description = description.split(/^>.*$/gm).join('');
|
|
6238
6310
|
//Note: Remove lists and return statement - TODO: [🎾] Make util (exported from `@promptbool/utils`)
|
|
6239
6311
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
6240
|
-
description = spaceTrim.spaceTrim(description);
|
|
6312
|
+
description = spaceTrim$1.spaceTrim(description);
|
|
6241
6313
|
if (description === '') {
|
|
6242
6314
|
description = undefined;
|
|
6243
6315
|
}
|
|
@@ -6248,7 +6320,7 @@
|
|
|
6248
6320
|
const command = parseCommand(listItem, 'PIPELINE_HEAD');
|
|
6249
6321
|
const commandParser = getParserForCommand(command);
|
|
6250
6322
|
if (commandParser.isUsedInPipelineHead !== true /* <- Note: [🦦][4] */) {
|
|
6251
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6323
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6252
6324
|
Command \`${command.type}\` is not allowed in the head of the pipeline ONLY at the pipeline task
|
|
6253
6325
|
|
|
6254
6326
|
${block(getPipelineIdentification())}
|
|
@@ -6262,7 +6334,7 @@
|
|
|
6262
6334
|
if (!(error instanceof ParseError)) {
|
|
6263
6335
|
throw error;
|
|
6264
6336
|
}
|
|
6265
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6337
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6266
6338
|
Command ${command.type} failed to apply to the pipeline
|
|
6267
6339
|
|
|
6268
6340
|
The error:
|
|
@@ -6315,7 +6387,7 @@
|
|
|
6315
6387
|
description = description.split(/^>.*$/gm).join('');
|
|
6316
6388
|
//Note: Remove lists and return statement - TODO: [🎾]
|
|
6317
6389
|
description = description.split(/^(?:(?:-)|(?:\d\))|(?:`?->))\s+.*$/gm).join('');
|
|
6318
|
-
description = spaceTrim.spaceTrim(description);
|
|
6390
|
+
description = spaceTrim$1.spaceTrim(description);
|
|
6319
6391
|
if (description === '') {
|
|
6320
6392
|
description = undefined;
|
|
6321
6393
|
}
|
|
@@ -6349,7 +6421,7 @@
|
|
|
6349
6421
|
for (const { listItem, command } of commands) {
|
|
6350
6422
|
const commandParser = getParserForCommand(command);
|
|
6351
6423
|
if (commandParser.isUsedInPipelineTask !== true /* <- Note: [🦦][4] */) {
|
|
6352
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6424
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6353
6425
|
Command \`${command.type}\` is not allowed in the task of the promptbook ONLY at the pipeline head
|
|
6354
6426
|
|
|
6355
6427
|
${block(getPipelineIdentification())}
|
|
@@ -6364,7 +6436,7 @@
|
|
|
6364
6436
|
if (!(error instanceof ParseError)) {
|
|
6365
6437
|
throw error;
|
|
6366
6438
|
}
|
|
6367
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6439
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6368
6440
|
Command \`${command.type}\` failed to apply to the task
|
|
6369
6441
|
|
|
6370
6442
|
The error:
|
|
@@ -6395,14 +6467,14 @@
|
|
|
6395
6467
|
// TODO: [🍧] Should be done in SECTION command
|
|
6396
6468
|
if ($taskJson.taskType === 'SCRIPT_TASK') {
|
|
6397
6469
|
if (!language) {
|
|
6398
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6470
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6399
6471
|
You must specify the language of the script in the \`SCRIPT\` task
|
|
6400
6472
|
|
|
6401
6473
|
${block(getPipelineIdentification())}
|
|
6402
6474
|
`));
|
|
6403
6475
|
}
|
|
6404
6476
|
if (!SUPPORTED_SCRIPT_LANGUAGES.includes(language)) {
|
|
6405
|
-
throw new ParseError(spaceTrim.spaceTrim((block) => `
|
|
6477
|
+
throw new ParseError(spaceTrim$1.spaceTrim((block) => `
|
|
6406
6478
|
Script language ${language} is not supported.
|
|
6407
6479
|
|
|
6408
6480
|
Supported languages are:
|