@promptbook/anthropic-claude 0.103.0-1 → 0.103.0-100
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +187 -116
- package/esm/index.es.js +160 -119
- package/esm/index.es.js.map +1 -1
- package/esm/typings/books/index.d.ts +0 -81
- package/esm/typings/servers.d.ts +9 -7
- package/esm/typings/src/_packages/browser.index.d.ts +6 -0
- package/esm/typings/src/_packages/cli.index.d.ts +4 -0
- package/esm/typings/src/_packages/components.index.d.ts +20 -8
- package/esm/typings/src/_packages/core.index.d.ts +58 -18
- package/esm/typings/src/_packages/node.index.d.ts +2 -2
- package/esm/typings/src/_packages/remote-server.index.d.ts +2 -0
- package/esm/typings/src/_packages/types.index.d.ts +58 -8
- package/esm/typings/src/_packages/utils.index.d.ts +6 -0
- package/esm/typings/src/_packages/wizard.index.d.ts +4 -0
- package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +19 -5
- package/esm/typings/src/book-2.0/agent-source/AgentModelRequirements.d.ts +17 -1
- package/esm/typings/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +3 -2
- package/esm/typings/src/book-2.0/agent-source/computeAgentHash.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/createCommitmentRegex.d.ts +3 -3
- package/esm/typings/src/book-2.0/agent-source/createDefaultAgentName.d.ts +8 -0
- package/esm/typings/src/book-2.0/agent-source/normalizeAgentName.d.ts +9 -0
- package/esm/typings/src/book-2.0/agent-source/padBook.d.ts +18 -0
- package/esm/typings/src/book-2.0/agent-source/parseAgentSourceWithCommitments.d.ts +1 -1
- package/esm/typings/src/book-2.0/agent-source/string_book.d.ts +3 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfile.d.ts +10 -0
- package/esm/typings/src/book-components/AvatarProfile/AvatarProfile/AvatarProfileTooltip.d.ts +15 -0
- package/esm/typings/src/book-components/BookEditor/BookEditor.d.ts +83 -8
- package/esm/typings/src/book-components/BookEditor/BookEditorActionbar.d.ts +14 -0
- package/esm/typings/src/book-components/BookEditor/BookEditorMonaco.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChat.d.ts +14 -0
- package/esm/typings/src/book-components/Chat/AgentChat/AgentChatProps.d.ts +13 -0
- package/esm/typings/src/book-components/Chat/Chat/ChatProps.d.ts +10 -0
- package/esm/typings/src/book-components/Chat/LlmChat/LlmChatProps.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/MarkdownContent/MarkdownContent.d.ts +15 -0
- package/esm/typings/src/book-components/Chat/MockedChat/MockedChat.d.ts +5 -0
- package/esm/typings/src/book-components/Chat/save/_common/ChatSaveFormatDefinition.d.ts +1 -1
- package/esm/typings/src/book-components/Chat/save/html/htmlSaveFormatDefinition.d.ts +1 -0
- package/esm/typings/src/book-components/Chat/save/pdf/pdfSaveFormatDefinition.d.ts +4 -0
- package/esm/typings/src/book-components/Chat/types/ChatParticipant.d.ts +5 -0
- package/esm/typings/src/book-components/PromptbookAgent/PromptbookAgent.d.ts +29 -0
- package/esm/typings/src/book-components/Qr/BrandedQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/GenericQrCode.d.ts +10 -0
- package/esm/typings/src/book-components/Qr/PromptbookQrCode.d.ts +18 -0
- package/esm/typings/src/book-components/Qr/useQrCode.d.ts +15 -0
- package/esm/typings/src/book-components/_common/Dropdown/Dropdown.d.ts +15 -0
- package/esm/typings/src/book-components/_common/HamburgerMenu/HamburgerMenu.d.ts +12 -0
- package/esm/typings/src/book-components/_common/Modal/Modal.d.ts +13 -0
- package/esm/typings/src/book-components/_common/Tooltip/Tooltip.d.ts +47 -0
- package/esm/typings/src/book-components/_common/react-utils/classNames.d.ts +1 -1
- package/esm/typings/src/book-components/icons/AboutIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/CloseIcon.d.ts +4 -8
- package/esm/typings/src/book-components/icons/DownloadIcon.d.ts +9 -0
- package/esm/typings/src/book-components/icons/ExitFullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/FullscreenIcon.d.ts +7 -0
- package/esm/typings/src/book-components/icons/MenuIcon.d.ts +12 -0
- package/esm/typings/src/book-components/icons/MicIcon.d.ts +8 -0
- package/esm/typings/src/cli/cli-commands/_boilerplate.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/about.d.ts +3 -1
- package/esm/typings/src/cli/cli-commands/hello.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-models.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/list-scrapers.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/login.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/make.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/prettify.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/run.d.ts +2 -1
- package/esm/typings/src/cli/cli-commands/{start-server.d.ts → start-agents-server.d.ts} +3 -2
- package/esm/typings/src/cli/cli-commands/start-pipelines-server.d.ts +15 -0
- package/esm/typings/src/cli/cli-commands/test-command.d.ts +2 -1
- package/esm/typings/src/cli/common/$addGlobalOptionsToCommand.d.ts +2 -1
- package/esm/typings/src/collection/agent-collection/AgentCollection.d.ts +12 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +75 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
- package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentsDatabaseSchema.d.ts +154 -0
- package/esm/typings/src/collection/{PipelineCollection.d.ts → pipeline-collection/PipelineCollection.d.ts} +7 -3
- package/esm/typings/src/collection/{SimplePipelineCollection.d.ts → pipeline-collection/SimplePipelineCollection.d.ts} +5 -5
- package/esm/typings/src/collection/{constructors/createCollectionFromDirectory.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.d.ts} +8 -11
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromJson.d.ts +13 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromPromise.d.ts → pipeline-collection/constructors/createPipelineCollectionFromPromise.d.ts} +6 -5
- package/esm/typings/src/collection/pipeline-collection/constructors/createPipelineCollectionFromPromise.test.d.ts +1 -0
- package/esm/typings/src/collection/{constructors/createCollectionFromUrl.d.ts → pipeline-collection/constructors/createPipelineCollectionFromUrl.d.ts} +3 -3
- package/esm/typings/src/collection/{constructors/createSubcollection.d.ts → pipeline-collection/constructors/createPipelineSubcollection.d.ts} +3 -3
- package/esm/typings/src/collection/pipeline-collection/pipelineCollectionToJson.d.ts +13 -0
- package/esm/typings/src/commands/_common/types/CommandParser.d.ts +4 -5
- package/esm/typings/src/{book-2.0/commitments → commitments}/ACTION/ACTION.d.ts +5 -1
- package/esm/typings/src/commitments/CLOSED/CLOSED.d.ts +35 -0
- package/esm/typings/src/commitments/COMPONENT/COMPONENT.d.ts +28 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/DELETE/DELETE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/FORMAT/FORMAT.d.ts +5 -1
- package/esm/typings/src/commitments/FROM/FROM.d.ts +34 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/GOAL/GOAL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/KNOWLEDGE/KNOWLEDGE.d.ts +5 -5
- package/esm/typings/src/commitments/LANGUAGE/LANGUAGE.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MEMORY/MEMORY.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/AgentMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/MESSAGE/MESSAGE.d.ts +5 -1
- package/esm/typings/src/commitments/MESSAGE/UserMessageCommitmentDefinition.d.ts +32 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META/META.d.ts +5 -1
- package/esm/typings/src/commitments/META_COLOR/META_COLOR.d.ts +48 -0
- package/esm/typings/src/commitments/META_FONT/META_FONT.d.ts +42 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_IMAGE/META_IMAGE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/META_LINK/META_LINK.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/MODEL/MODEL.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/NOTE/NOTE.d.ts +5 -1
- package/esm/typings/src/commitments/OPEN/OPEN.d.ts +35 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/PERSONA/PERSONA.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/RULE/RULE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SAMPLE/SAMPLE.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/SCENARIO/SCENARIO.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/STYLE/STYLE.d.ts +5 -1
- package/esm/typings/src/commitments/USE/USE.d.ts +53 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.d.ts +38 -0
- package/esm/typings/src/commitments/USE_BROWSER/USE_BROWSER.test.d.ts +1 -0
- package/esm/typings/src/commitments/USE_MCP/USE_MCP.d.ts +37 -0
- package/esm/typings/src/commitments/USE_SEARCH_ENGINE/USE_SEARCH_ENGINE.d.ts +38 -0
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BaseCommitmentDefinition.d.ts +8 -2
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/CommitmentDefinition.d.ts +6 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/NotYetImplementedCommitmentDefinition.d.ts +5 -1
- package/esm/typings/src/{book-2.0/commitments → commitments}/_base/createEmptyAgentModelRequirements.d.ts +1 -1
- package/esm/typings/src/commitments/index.d.ts +93 -0
- package/esm/typings/src/config.d.ts +24 -3
- package/esm/typings/src/conversion/validation/validatePipeline.d.ts +2 -0
- package/esm/typings/src/errors/0-index.d.ts +6 -0
- package/esm/typings/src/errors/DatabaseError.d.ts +12 -0
- package/esm/typings/src/errors/NotAllowed.d.ts +9 -0
- package/esm/typings/src/errors/WrappedError.d.ts +2 -2
- package/esm/typings/src/execution/AvailableModel.d.ts +1 -0
- package/esm/typings/src/execution/Executables.d.ts +3 -0
- package/esm/typings/src/execution/ExecutionTask.d.ts +12 -3
- package/esm/typings/src/execution/ExecutionTools.d.ts +5 -0
- package/esm/typings/src/execution/FilesystemTools.d.ts +1 -1
- package/esm/typings/src/execution/LlmExecutionTools.d.ts +21 -1
- package/esm/typings/src/execution/createPipelineExecutor/10-executePipeline.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/20-executeTask.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/30-executeFormatSubvalues.d.ts +5 -0
- package/esm/typings/src/execution/createPipelineExecutor/40-executeAttempts.d.ts +5 -0
- package/esm/typings/src/execution/utils/usage-constants.d.ts +4 -124
- package/esm/typings/src/execution/utils/validatePromptResult.d.ts +2 -0
- package/esm/typings/src/high-level-abstractions/_common/HighLevelAbstraction.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
- package/esm/typings/src/llm-providers/_common/register/$registeredLlmToolsMessage.d.ts +2 -1
- package/esm/typings/src/llm-providers/_common/register/LlmToolsMetadata.d.ts +1 -1
- package/esm/typings/src/llm-providers/_common/utils/assertUniqueModels.d.ts +12 -0
- package/esm/typings/src/llm-providers/_multiple/getSingleLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/_multiple/joinLlmExecutionTools.d.ts +1 -0
- package/esm/typings/src/llm-providers/agent/Agent.d.ts +70 -0
- package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +26 -4
- package/esm/typings/src/llm-providers/agent/AgentOptions.d.ts +19 -0
- package/esm/typings/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +17 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +50 -0
- package/esm/typings/src/llm-providers/agent/RemoteAgentOptions.d.ts +11 -0
- package/esm/typings/src/llm-providers/agent/createAgentLlmExecutionTools.d.ts +1 -19
- package/esm/typings/src/llm-providers/anthropic-claude/anthropic-claude-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/google/google-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +60 -2
- package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionToolsOptions.d.ts +7 -1
- package/esm/typings/src/llm-providers/openai/openai-models.d.ts +1 -1
- package/esm/typings/src/llm-providers/openai/openai-models.test.d.ts +4 -0
- package/esm/typings/src/other/templates/getTemplatesPipelineCollection.d.ts +1 -1
- package/esm/typings/src/pipeline/validatePipelineString.d.ts +2 -0
- package/esm/typings/src/playground/permanent/_boilerplate.d.ts +5 -0
- package/esm/typings/src/playground/permanent/agent-with-browser-playground.d.ts +5 -0
- package/esm/typings/src/prepare/PrepareAndScrapeOptions.d.ts +1 -0
- package/esm/typings/src/remote-server/startAgentServer.d.ts +26 -0
- package/esm/typings/src/remote-server/startRemoteServer.d.ts +4 -1
- package/esm/typings/src/remote-server/types/RemoteServerOptions.d.ts +3 -8
- package/esm/typings/src/scrapers/_boilerplate/createBoilerplateScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/_boilerplate/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document/createDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/document-legacy/createLegacyDocumentScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/document-legacy/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markdown/createMarkdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/markitdown/createMarkitdownScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/markitdown/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/pdf/createPdfScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/pdf/register-metadata.d.ts +1 -9
- package/esm/typings/src/scrapers/website/createWebsiteScraper.d.ts +1 -12
- package/esm/typings/src/scrapers/website/register-metadata.d.ts +1 -9
- package/esm/typings/src/storage/_common/PromptbookStorage.d.ts +1 -0
- package/esm/typings/src/storage/env-storage/$EnvStorage.d.ts +2 -1
- package/esm/typings/src/transpilers/_common/BookTranspiler.d.ts +33 -0
- package/esm/typings/src/transpilers/_common/BookTranspilerOptions.d.ts +18 -0
- package/esm/typings/src/transpilers/_common/register/$bookTranspilersRegister.d.ts +15 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/FormattedBookInMarkdownTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/formatted-book-in-markdown/register.d.ts +15 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.d.ts +16 -0
- package/esm/typings/src/transpilers/openai-sdk/OpenAiSdkTranspiler.test.d.ts +1 -0
- package/esm/typings/src/transpilers/openai-sdk/playground/playground.d.ts +5 -0
- package/esm/typings/src/transpilers/openai-sdk/register.d.ts +15 -0
- package/esm/typings/src/types/LlmCall.d.ts +20 -0
- package/esm/typings/src/types/Updatable.d.ts +19 -0
- package/esm/typings/src/types/typeAliases.d.ts +32 -2
- package/esm/typings/src/utils/color/$randomColor.d.ts +1 -0
- package/esm/typings/src/utils/color/Color.d.ts +15 -0
- package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
- package/esm/typings/src/utils/color/css-colors.d.ts +1 -0
- package/esm/typings/src/utils/color/internal-utils/checkChannelValue.d.ts +0 -3
- package/esm/typings/src/utils/color/operators/darken.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/grayscale.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/lighten.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/mixWithColor.d.ts +1 -1
- package/esm/typings/src/utils/color/operators/saturate.d.ts +1 -1
- package/esm/typings/src/utils/environment/$detectRuntimeEnvironment.d.ts +16 -0
- package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
- package/esm/typings/src/utils/execCommand/$execCommand.d.ts +2 -1
- package/esm/typings/src/utils/execCommand/$execCommands.d.ts +2 -1
- package/esm/typings/src/utils/files/$induceBookDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/$induceFileDownload.d.ts +13 -0
- package/esm/typings/src/utils/files/ObjectUrl.d.ts +46 -0
- package/esm/typings/src/utils/files/listAllFiles.d.ts +2 -3
- package/esm/typings/src/utils/misc/aboutPromptbookInformation.d.ts +27 -0
- package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
- package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
- package/esm/typings/src/utils/misc/injectCssModuleIntoShadowRoot.d.ts +1 -0
- package/esm/typings/src/utils/misc/xAboutPromptbookInformation.d.ts +13 -0
- package/esm/typings/src/utils/normalization/normalize-to-kebab-case.d.ts +2 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.d.ts +9 -0
- package/esm/typings/src/utils/normalization/normalizeMessageText.test.d.ts +1 -0
- package/esm/typings/src/utils/normalization/normalizeTo_PascalCase.d.ts +3 -0
- package/esm/typings/src/utils/normalization/normalizeTo_camelCase.d.ts +2 -0
- package/esm/typings/src/utils/normalization/titleToName.d.ts +2 -0
- package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
- package/esm/typings/src/utils/organization/$side_effect.d.ts +7 -0
- package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
- package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
- package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
- package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
- package/esm/typings/src/utils/random/$generateBookBoilerplate.d.ts +25 -0
- package/esm/typings/src/utils/random/$randomAgentPersona.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomFullnameWithColor.d.ts +13 -0
- package/esm/typings/src/utils/random/$randomItem.d.ts +9 -0
- package/esm/typings/src/utils/random/$randomSeed.d.ts +3 -0
- package/esm/typings/src/utils/random/$randomToken.d.ts +2 -0
- package/esm/typings/src/utils/serialization/$deepFreeze.d.ts +2 -1
- package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
- package/esm/typings/src/utils/serialization/serializeToPromptbookJavascript.d.ts +2 -2
- package/esm/typings/src/utils/validators/parameterName/validateParameterName.d.ts +2 -0
- package/esm/typings/src/version.d.ts +1 -1
- package/esm/typings/src/wizard/$getCompiledBook.d.ts +1 -2
- package/package.json +7 -7
- package/umd/index.umd.js +158 -117
- package/umd/index.umd.js.map +1 -1
- package/esm/typings/src/book-2.0/commitments/index.d.ts +0 -60
- package/esm/typings/src/book-components/BookEditor/BookEditorInner.d.ts +0 -5
- package/esm/typings/src/book-components/BookEditor/config.d.ts +0 -10
- package/esm/typings/src/book-components/Chat/utils/renderMarkdown.d.ts +0 -21
- package/esm/typings/src/collection/collectionToJson.d.ts +0 -13
- package/esm/typings/src/collection/constructors/createCollectionFromJson.d.ts +0 -13
- /package/esm/typings/src/{book-components/Chat/utils/renderMarkdown.test.d.ts → book-2.0/agent-source/computeAgentHash.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromDirectory.test.d.ts → book-2.0/agent-source/normalizeAgentName.test.d.ts} +0 -0
- /package/esm/typings/src/{collection/constructors/createCollectionFromJson.test.d.ts → book-components/Chat/AgentChat/AgentChat.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{constructors/createCollectionFromPromise.test.d.ts → pipeline-collection/constructors/createPipelineCollectionFromDirectory.test.d.ts} +0 -0
- /package/esm/typings/src/{commands/_common/parseCommand.test.d.ts → collection/pipeline-collection/constructors/createPipelineCollectionFromJson.test.d.ts} +0 -0
- /package/esm/typings/src/collection/{collectionToJson.test.d.ts → pipeline-collection/pipelineCollectionToJson.test.d.ts} +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/BookCommitment.d.ts +0 -0
- /package/esm/typings/src/{book-2.0/commitments → commitments}/_base/ParsedCommitment.d.ts +0 -0
package/esm/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import spaceTrim, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
1
|
+
import spaceTrim$2, { spaceTrim as spaceTrim$1 } from 'spacetrim';
|
|
2
2
|
import Anthropic from '@anthropic-ai/sdk';
|
|
3
3
|
import Bottleneck from 'bottleneck';
|
|
4
4
|
import colors from 'colors';
|
|
@@ -12,14 +12,14 @@ import { io } from 'socket.io-client';
|
|
|
12
12
|
* @generated
|
|
13
13
|
* @see https://github.com/webgptorg/book
|
|
14
14
|
*/
|
|
15
|
-
const BOOK_LANGUAGE_VERSION = '
|
|
15
|
+
const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
16
16
|
/**
|
|
17
17
|
* The version of the Promptbook engine
|
|
18
18
|
*
|
|
19
19
|
* @generated
|
|
20
20
|
* @see https://github.com/webgptorg/promptbook
|
|
21
21
|
*/
|
|
22
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-
|
|
22
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.103.0-100';
|
|
23
23
|
/**
|
|
24
24
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
25
25
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -67,6 +67,17 @@ function $deepFreeze(objectValue) {
|
|
|
67
67
|
* TODO: [🧠] Is there a way how to meaningfully test this utility
|
|
68
68
|
*/
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Trims string from all 4 sides
|
|
72
|
+
*
|
|
73
|
+
* Note: This is a re-exported function from the `spacetrim` package which is
|
|
74
|
+
* Developed by same author @hejny as this package
|
|
75
|
+
*
|
|
76
|
+
* @public exported from `@promptbook/utils`
|
|
77
|
+
* @see https://github.com/hejny/spacetrim#usage
|
|
78
|
+
*/
|
|
79
|
+
const spaceTrim = spaceTrim$1;
|
|
80
|
+
|
|
70
81
|
/**
|
|
71
82
|
* @private util of `@promptbook/color`
|
|
72
83
|
* @de
|
|
@@ -115,6 +126,7 @@ function take(initialValue) {
|
|
|
115
126
|
* @public exported from `@promptbook/color`
|
|
116
127
|
*/
|
|
117
128
|
const CSS_COLORS = {
|
|
129
|
+
promptbook: '#79EAFD',
|
|
118
130
|
transparent: 'rgba(0,0,0,0)',
|
|
119
131
|
aliceblue: '#f0f8ff',
|
|
120
132
|
antiquewhite: '#faebd7',
|
|
@@ -296,9 +308,6 @@ function checkChannelValue(channelName, value) {
|
|
|
296
308
|
throw new Error(`${channelName} channel is greater than 255, it is ${value}`);
|
|
297
309
|
}
|
|
298
310
|
}
|
|
299
|
-
/**
|
|
300
|
-
* TODO: [🧠][🚓] Is/which combination it better to use asserts/check, validate or is utility function?
|
|
301
|
-
*/
|
|
302
311
|
|
|
303
312
|
/**
|
|
304
313
|
* Color object represents an RGB color with alpha channel
|
|
@@ -333,6 +342,28 @@ class Color {
|
|
|
333
342
|
throw new Error(`Can not create color from given object`);
|
|
334
343
|
}
|
|
335
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* Creates a new Color instance from miscellaneous formats
|
|
347
|
+
* It just does not throw error when it fails, it returns PROMPTBOOK_COLOR instead
|
|
348
|
+
*
|
|
349
|
+
* @param color
|
|
350
|
+
* @returns Color object
|
|
351
|
+
*/
|
|
352
|
+
static fromSafe(color) {
|
|
353
|
+
try {
|
|
354
|
+
return Color.from(color);
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
// <- Note: Can not use `assertsError(error)` here because it causes circular dependency
|
|
358
|
+
console.warn(spaceTrim((block) => `
|
|
359
|
+
Color.fromSafe error:
|
|
360
|
+
${block(error.message)}
|
|
361
|
+
|
|
362
|
+
Returning default PROMPTBOOK_COLOR.
|
|
363
|
+
`));
|
|
364
|
+
return Color.fromString('promptbook');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
336
367
|
/**
|
|
337
368
|
* Creates a new Color instance from miscellaneous string formats
|
|
338
369
|
*
|
|
@@ -400,6 +431,9 @@ class Color {
|
|
|
400
431
|
if (hex.length === 3) {
|
|
401
432
|
return Color.fromHex3(hex);
|
|
402
433
|
}
|
|
434
|
+
if (hex.length === 4) {
|
|
435
|
+
return Color.fromHex4(hex);
|
|
436
|
+
}
|
|
403
437
|
if (hex.length === 6) {
|
|
404
438
|
return Color.fromHex6(hex);
|
|
405
439
|
}
|
|
@@ -420,6 +454,19 @@ class Color {
|
|
|
420
454
|
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
421
455
|
return take(new Color(r, g, b));
|
|
422
456
|
}
|
|
457
|
+
/**
|
|
458
|
+
* Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
|
|
459
|
+
*
|
|
460
|
+
* @param color in hex for example `09df`
|
|
461
|
+
* @returns Color object
|
|
462
|
+
*/
|
|
463
|
+
static fromHex4(hex) {
|
|
464
|
+
const r = parseInt(hex.substr(0, 1), 16) * 16;
|
|
465
|
+
const g = parseInt(hex.substr(1, 1), 16) * 16;
|
|
466
|
+
const b = parseInt(hex.substr(2, 1), 16) * 16;
|
|
467
|
+
const a = parseInt(hex.substr(3, 1), 16) * 16;
|
|
468
|
+
return take(new Color(r, g, b, a));
|
|
469
|
+
}
|
|
423
470
|
/**
|
|
424
471
|
* Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
|
|
425
472
|
*
|
|
@@ -610,7 +657,8 @@ class Color {
|
|
|
610
657
|
* @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
|
|
611
658
|
*/
|
|
612
659
|
static isHexColorString(value) {
|
|
613
|
-
return typeof value === 'string' &&
|
|
660
|
+
return (typeof value === 'string' &&
|
|
661
|
+
/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
|
|
614
662
|
}
|
|
615
663
|
/**
|
|
616
664
|
* Creates new Color object
|
|
@@ -725,6 +773,23 @@ class Color {
|
|
|
725
773
|
* TODO: Maybe connect with textures
|
|
726
774
|
*/
|
|
727
775
|
|
|
776
|
+
/**
|
|
777
|
+
* Makes color transformer which returns a grayscale version of the color
|
|
778
|
+
*
|
|
779
|
+
* @param amount from 0 to 1
|
|
780
|
+
*
|
|
781
|
+
* @public exported from `@promptbook/color`
|
|
782
|
+
*/
|
|
783
|
+
function grayscale(amount) {
|
|
784
|
+
return ({ red, green, blue, alpha }) => {
|
|
785
|
+
const average = (red + green + blue) / 3;
|
|
786
|
+
red = Math.round(average * amount + red * (1 - amount));
|
|
787
|
+
green = Math.round(average * amount + green * (1 - amount));
|
|
788
|
+
blue = Math.round(average * amount + blue * (1 - amount));
|
|
789
|
+
return Color.fromValues(red, green, blue, alpha);
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
|
|
728
793
|
/**
|
|
729
794
|
* Converts HSL values to RGB values
|
|
730
795
|
*
|
|
@@ -840,102 +905,6 @@ function lighten(amount) {
|
|
|
840
905
|
* TODO: Maybe implement by mix+hsl
|
|
841
906
|
*/
|
|
842
907
|
|
|
843
|
-
/**
|
|
844
|
-
* Calculates distance between two colors
|
|
845
|
-
*
|
|
846
|
-
* @param color1 first color
|
|
847
|
-
* @param color2 second color
|
|
848
|
-
*
|
|
849
|
-
* Note: This function is inefficient. Use colorDistanceSquared instead if possible.
|
|
850
|
-
*
|
|
851
|
-
* @public exported from `@promptbook/color`
|
|
852
|
-
*/
|
|
853
|
-
/**
|
|
854
|
-
* Calculates distance between two colors without square root
|
|
855
|
-
*
|
|
856
|
-
* @param color1 first color
|
|
857
|
-
* @param color2 second color
|
|
858
|
-
*
|
|
859
|
-
* @public exported from `@promptbook/color`
|
|
860
|
-
*/
|
|
861
|
-
function colorDistanceSquared(color1, color2) {
|
|
862
|
-
const rmean = (color1.red + color2.red) / 2;
|
|
863
|
-
const r = color1.red - color2.red;
|
|
864
|
-
const g = color1.green - color2.green;
|
|
865
|
-
const b = color1.blue - color2.blue;
|
|
866
|
-
const weightR = 2 + rmean / 256;
|
|
867
|
-
const weightG = 4.0;
|
|
868
|
-
const weightB = 2 + (255 - rmean) / 256;
|
|
869
|
-
const distance = weightR * r * r + weightG * g * g + weightB * b * b;
|
|
870
|
-
return distance;
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
/**
|
|
874
|
-
* Makes color transformer which finds the nearest color from the given list
|
|
875
|
-
*
|
|
876
|
-
* @param colors array of colors to choose from
|
|
877
|
-
*
|
|
878
|
-
* @public exported from `@promptbook/color`
|
|
879
|
-
*/
|
|
880
|
-
function nearest(...colors) {
|
|
881
|
-
return (color) => {
|
|
882
|
-
const distances = colors.map((c) => colorDistanceSquared(c, color));
|
|
883
|
-
const minDistance = Math.min(...distances);
|
|
884
|
-
const minIndex = distances.indexOf(minDistance);
|
|
885
|
-
const nearestColor = colors[minIndex];
|
|
886
|
-
return nearestColor;
|
|
887
|
-
};
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
/**
|
|
891
|
-
* Color transformer which returns the negative color
|
|
892
|
-
*
|
|
893
|
-
* @public exported from `@promptbook/color`
|
|
894
|
-
*/
|
|
895
|
-
function negative(color) {
|
|
896
|
-
const r = 255 - color.red;
|
|
897
|
-
const g = 255 - color.green;
|
|
898
|
-
const b = 255 - color.blue;
|
|
899
|
-
return Color.fromValues(r, g, b, color.alpha);
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
/**
|
|
903
|
-
* Makes color transformer which finds the furthest color from the given list
|
|
904
|
-
*
|
|
905
|
-
* @param colors array of colors to choose from
|
|
906
|
-
*
|
|
907
|
-
* @public exported from `@promptbook/color`
|
|
908
|
-
*/
|
|
909
|
-
function furthest(...colors) {
|
|
910
|
-
return (color) => {
|
|
911
|
-
const furthestColor = negative(nearest(...colors.map(negative))(color));
|
|
912
|
-
return furthestColor;
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Makes color transformer which finds the best text color (black or white) for the given background color
|
|
917
|
-
*
|
|
918
|
-
* @public exported from `@promptbook/color`
|
|
919
|
-
*/
|
|
920
|
-
furthest(Color.get('white'), Color.from('black'));
|
|
921
|
-
|
|
922
|
-
/**
|
|
923
|
-
* Makes color transformer which returns a grayscale version of the color
|
|
924
|
-
*
|
|
925
|
-
* @param amount from 0 to 1
|
|
926
|
-
*
|
|
927
|
-
* @public exported from `@promptbook/color`
|
|
928
|
-
*/
|
|
929
|
-
function grayscale(amount) {
|
|
930
|
-
return ({ red, green, blue, alpha }) => {
|
|
931
|
-
const average = (red + green + blue) / 3;
|
|
932
|
-
red = Math.round(average * amount + red * (1 - amount));
|
|
933
|
-
green = Math.round(average * amount + green * (1 - amount));
|
|
934
|
-
blue = Math.round(average * amount + blue * (1 - amount));
|
|
935
|
-
return Color.fromValues(red, green, blue, alpha);
|
|
936
|
-
};
|
|
937
|
-
}
|
|
938
|
-
|
|
939
908
|
/**
|
|
940
909
|
* Makes color transformer which saturate the given color
|
|
941
910
|
*
|
|
@@ -984,16 +953,32 @@ const ADMIN_GITHUB_NAME = 'hejny';
|
|
|
984
953
|
*
|
|
985
954
|
* @public exported from `@promptbook/core`
|
|
986
955
|
*/
|
|
987
|
-
const PROMPTBOOK_COLOR = Color.
|
|
988
|
-
// <- TODO: [🧠] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
956
|
+
const PROMPTBOOK_COLOR = Color.fromString('promptbook');
|
|
957
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
989
958
|
/**
|
|
990
|
-
*
|
|
959
|
+
* Colors for syntax highlighting in the `<BookEditor/>`
|
|
960
|
+
*
|
|
961
|
+
* TODO: [🗽] Unite branding and make single place for it
|
|
962
|
+
*
|
|
963
|
+
* @public exported from `@promptbook/core`
|
|
964
|
+
*/
|
|
965
|
+
({
|
|
966
|
+
TITLE: Color.fromHex('#244EA8'),
|
|
967
|
+
LINE: Color.fromHex('#eeeeee'),
|
|
968
|
+
SEPARATOR: Color.fromHex('#cccccc'),
|
|
969
|
+
COMMITMENT: Color.fromHex('#DA0F78'),
|
|
970
|
+
PARAMETER: Color.fromHex('#8e44ad'),
|
|
971
|
+
});
|
|
972
|
+
// <- TODO: [🧠][🈵] Using `Color` here increases the package size approx 3kb, maybe remove it
|
|
973
|
+
/**
|
|
974
|
+
* Chat color of the Promptbook (in chat)
|
|
991
975
|
*
|
|
992
976
|
* TODO: [🗽] Unite branding and make single place for it
|
|
993
977
|
*
|
|
994
978
|
* @public exported from `@promptbook/core`
|
|
995
979
|
*/
|
|
996
980
|
PROMPTBOOK_COLOR.then(lighten(0.1)).then(saturate(0.9)).then(grayscale(0.9));
|
|
981
|
+
// <- TODO: [🧠][🈵] Using `Color` and `lighten`, `saturate`,... here increases the package size approx 3kb, maybe remove it
|
|
997
982
|
/**
|
|
998
983
|
* Color of the user (in chat)
|
|
999
984
|
*
|
|
@@ -1083,7 +1068,7 @@ parseInt(process.env.API_REQUEST_TIMEOUT || '90000');
|
|
|
1083
1068
|
function getErrorReportUrl(error) {
|
|
1084
1069
|
const report = {
|
|
1085
1070
|
title: `🐜 Error report from ${NAME}`,
|
|
1086
|
-
body: spaceTrim((block) => `
|
|
1071
|
+
body: spaceTrim$2((block) => `
|
|
1087
1072
|
|
|
1088
1073
|
|
|
1089
1074
|
\`${error.name || 'Error'}\` has occurred in the [${NAME}], please look into it @${ADMIN_GITHUB_NAME}.
|
|
@@ -1241,7 +1226,7 @@ function checkSerializableAsJson(options) {
|
|
|
1241
1226
|
}
|
|
1242
1227
|
else if (typeof value === 'object') {
|
|
1243
1228
|
if (value instanceof Date) {
|
|
1244
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1229
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1245
1230
|
\`${name}\` is Date
|
|
1246
1231
|
|
|
1247
1232
|
Use \`string_date_iso8601\` instead
|
|
@@ -1260,7 +1245,7 @@ function checkSerializableAsJson(options) {
|
|
|
1260
1245
|
throw new UnexpectedError(`${name} is RegExp`);
|
|
1261
1246
|
}
|
|
1262
1247
|
else if (value instanceof Error) {
|
|
1263
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1248
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1264
1249
|
\`${name}\` is unserialized Error
|
|
1265
1250
|
|
|
1266
1251
|
Use function \`serializeError\`
|
|
@@ -1283,7 +1268,7 @@ function checkSerializableAsJson(options) {
|
|
|
1283
1268
|
}
|
|
1284
1269
|
catch (error) {
|
|
1285
1270
|
assertsError(error);
|
|
1286
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1271
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1287
1272
|
\`${name}\` is not serializable
|
|
1288
1273
|
|
|
1289
1274
|
${block(error.stack || error.message)}
|
|
@@ -1315,7 +1300,7 @@ function checkSerializableAsJson(options) {
|
|
|
1315
1300
|
}
|
|
1316
1301
|
}
|
|
1317
1302
|
else {
|
|
1318
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
1303
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
1319
1304
|
\`${name}\` is unknown type
|
|
1320
1305
|
|
|
1321
1306
|
Additional message for \`${name}\`:
|
|
@@ -1345,7 +1330,7 @@ function deepClone(objectValue) {
|
|
|
1345
1330
|
TODO: [🧠] Is there a better implementation?
|
|
1346
1331
|
> const propertyNames = Object.getOwnPropertyNames(objectValue);
|
|
1347
1332
|
> for (const propertyName of propertyNames) {
|
|
1348
|
-
> const value = (objectValue as
|
|
1333
|
+
> const value = (objectValue as chococake)[propertyName];
|
|
1349
1334
|
> if (value && typeof value === 'object') {
|
|
1350
1335
|
> deepClone(value);
|
|
1351
1336
|
> }
|
|
@@ -1404,7 +1389,7 @@ function pricing(value) {
|
|
|
1404
1389
|
/**
|
|
1405
1390
|
* List of available Anthropic Claude models with pricing
|
|
1406
1391
|
*
|
|
1407
|
-
* Note: Synced with official API docs at 2025-
|
|
1392
|
+
* Note: Synced with official API docs at 2025-11-19
|
|
1408
1393
|
*
|
|
1409
1394
|
* @see https://docs.anthropic.com/en/docs/models-overview
|
|
1410
1395
|
* @public exported from `@promptbook/anthropic-claude`
|
|
@@ -1412,6 +1397,26 @@ function pricing(value) {
|
|
|
1412
1397
|
const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
1413
1398
|
name: 'ANTHROPIC_CLAUDE_MODELS',
|
|
1414
1399
|
value: [
|
|
1400
|
+
{
|
|
1401
|
+
modelVariant: 'CHAT',
|
|
1402
|
+
modelTitle: 'Claude Sonnet 4.5',
|
|
1403
|
+
modelName: 'claude-sonnet-4-5-20250929',
|
|
1404
|
+
modelDescription: 'Our smartest model for complex agents and coding',
|
|
1405
|
+
pricing: {
|
|
1406
|
+
prompt: pricing(`$3.00 / 1M tokens`),
|
|
1407
|
+
output: pricing(`$15.00 / 1M tokens`),
|
|
1408
|
+
},
|
|
1409
|
+
},
|
|
1410
|
+
{
|
|
1411
|
+
modelVariant: 'CHAT',
|
|
1412
|
+
modelTitle: 'Claude Haiku 4.5',
|
|
1413
|
+
modelName: 'claude-haiku-4-5-20251001',
|
|
1414
|
+
modelDescription: 'Our fastest model with near-frontier intelligence',
|
|
1415
|
+
pricing: {
|
|
1416
|
+
prompt: pricing(`$1.00 / 1M tokens`),
|
|
1417
|
+
output: pricing(`$5.00 / 1M tokens`),
|
|
1418
|
+
},
|
|
1419
|
+
},
|
|
1415
1420
|
{
|
|
1416
1421
|
modelVariant: 'CHAT',
|
|
1417
1422
|
modelTitle: 'Claude Opus 4.1',
|
|
@@ -1426,7 +1431,7 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
|
1426
1431
|
modelVariant: 'CHAT',
|
|
1427
1432
|
modelTitle: 'Claude Opus 4',
|
|
1428
1433
|
modelName: 'claude-opus-4-20250514',
|
|
1429
|
-
modelDescription: 'Previous flagship Claude model with 200K token context window. Features very high intelligence and capability with exceptional performance across reasoning, coding, and creative tasks. Maintains strong safety guardrails while delivering sophisticated outputs for complex professional applications.',
|
|
1434
|
+
modelDescription: 'Previous flagship Claude model with 200K token context window. Features very high intelligence and capability with exceptional performance across reasoning, coding, and creative tasks. Maintains strong safety guardrails while delivering sophisticated outputs for complex professional applications. DEPRECATED: Use Claude Opus 4.1 instead.',
|
|
1430
1435
|
pricing: {
|
|
1431
1436
|
prompt: pricing(`$15.00 / 1M tokens`),
|
|
1432
1437
|
output: pricing(`$75.00 / 1M tokens`),
|
|
@@ -1436,7 +1441,7 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
|
1436
1441
|
modelVariant: 'CHAT',
|
|
1437
1442
|
modelTitle: 'Claude Sonnet 4',
|
|
1438
1443
|
modelName: 'claude-sonnet-4-20250514',
|
|
1439
|
-
modelDescription: 'High-performance Claude model with exceptional reasoning capabilities and 200K token context window (1M context beta available). Features balanced intelligence and efficiency with enhanced multimodal understanding. Offers optimal performance for most enterprise applications requiring sophisticated AI capabilities.',
|
|
1444
|
+
modelDescription: 'High-performance Claude model with exceptional reasoning capabilities and 200K token context window (1M context beta available). Features balanced intelligence and efficiency with enhanced multimodal understanding. Offers optimal performance for most enterprise applications requiring sophisticated AI capabilities. DEPRECATED: Use Claude Sonnet 4.5 instead.',
|
|
1440
1445
|
pricing: {
|
|
1441
1446
|
prompt: pricing(`$3.00 / 1M tokens`),
|
|
1442
1447
|
output: pricing(`$15.00 / 1M tokens`),
|
|
@@ -1577,6 +1582,7 @@ const ANTHROPIC_CLAUDE_MODELS = exportJson({
|
|
|
1577
1582
|
/**
|
|
1578
1583
|
* Generates random token
|
|
1579
1584
|
*
|
|
1585
|
+
* Note: `$` is used to indicate that this function is not a pure function - it is not deterministic
|
|
1580
1586
|
* Note: This function is cryptographically secure (it uses crypto.randomBytes internally)
|
|
1581
1587
|
*
|
|
1582
1588
|
* @private internal helper function
|
|
@@ -1586,6 +1592,7 @@ function $randomToken(randomness) {
|
|
|
1586
1592
|
return randomBytes(randomness).toString('hex');
|
|
1587
1593
|
}
|
|
1588
1594
|
/**
|
|
1595
|
+
* TODO: [🤶] Maybe export through `@promptbook/utils` or `@promptbook/random` package
|
|
1589
1596
|
* TODO: Maybe use nanoid instead https://github.com/ai/nanoid
|
|
1590
1597
|
*/
|
|
1591
1598
|
|
|
@@ -1871,10 +1878,13 @@ const LINES_PER_STANDARD_PAGE = 44;
|
|
|
1871
1878
|
* @public exported from `@promptbook/utils`
|
|
1872
1879
|
*/
|
|
1873
1880
|
function countLines(text) {
|
|
1881
|
+
if (text === '') {
|
|
1882
|
+
return 0;
|
|
1883
|
+
}
|
|
1874
1884
|
text = text.replace('\r\n', '\n');
|
|
1875
1885
|
text = text.replace('\r', '\n');
|
|
1876
1886
|
const lines = text.split('\n');
|
|
1877
|
-
return lines.reduce((count, line) => count + Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 0);
|
|
1887
|
+
return lines.reduce((count, line) => count + Math.max(Math.ceil(line.length / CHARACTERS_PER_STANDARD_LINE), 1), 0);
|
|
1878
1888
|
}
|
|
1879
1889
|
/**
|
|
1880
1890
|
* TODO: [🥴] Implement counting in formats - like JSON, CSV, XML,...
|
|
@@ -2513,7 +2523,7 @@ class AnthropicClaudeExecutionTools {
|
|
|
2513
2523
|
getDefaultModel(defaultModelName) {
|
|
2514
2524
|
const model = ANTHROPIC_CLAUDE_MODELS.find(({ modelName }) => modelName.startsWith(defaultModelName));
|
|
2515
2525
|
if (model === undefined) {
|
|
2516
|
-
throw new UnexpectedError(spaceTrim((block) => `
|
|
2526
|
+
throw new UnexpectedError(spaceTrim$2((block) => `
|
|
2517
2527
|
Cannot find model in Anthropic Claude models with name "${defaultModelName}" which should be used as default.
|
|
2518
2528
|
|
|
2519
2529
|
Available models:
|
|
@@ -2596,6 +2606,22 @@ class CollectionError extends Error {
|
|
|
2596
2606
|
}
|
|
2597
2607
|
}
|
|
2598
2608
|
|
|
2609
|
+
/**
|
|
2610
|
+
* This error indicates error from the database
|
|
2611
|
+
*
|
|
2612
|
+
* @public exported from `@promptbook/core`
|
|
2613
|
+
*/
|
|
2614
|
+
class DatabaseError extends Error {
|
|
2615
|
+
constructor(message) {
|
|
2616
|
+
super(message);
|
|
2617
|
+
this.name = 'DatabaseError';
|
|
2618
|
+
Object.setPrototypeOf(this, DatabaseError.prototype);
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
/**
|
|
2622
|
+
* TODO: [🐱🚀] Explain that NotFoundError ([🐱🚀] and other specific errors) has priority over DatabaseError in some contexts
|
|
2623
|
+
*/
|
|
2624
|
+
|
|
2599
2625
|
/**
|
|
2600
2626
|
* This error type indicates that you try to use a feature that is not available in the current environment
|
|
2601
2627
|
*
|
|
@@ -2656,6 +2682,19 @@ class MissingToolsError extends Error {
|
|
|
2656
2682
|
}
|
|
2657
2683
|
}
|
|
2658
2684
|
|
|
2685
|
+
/**
|
|
2686
|
+
* This error indicates that promptbook operation is not allowed
|
|
2687
|
+
*
|
|
2688
|
+
* @public exported from `@promptbook/core`
|
|
2689
|
+
*/
|
|
2690
|
+
class NotAllowed extends Error {
|
|
2691
|
+
constructor(message) {
|
|
2692
|
+
super(message);
|
|
2693
|
+
this.name = 'NotAllowed';
|
|
2694
|
+
Object.setPrototypeOf(this, NotAllowed.prototype);
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2659
2698
|
/**
|
|
2660
2699
|
* This error indicates that promptbook not found in the collection
|
|
2661
2700
|
*
|
|
@@ -2771,6 +2810,8 @@ const PROMPTBOOK_ERRORS = {
|
|
|
2771
2810
|
PromptbookFetchError,
|
|
2772
2811
|
UnexpectedError,
|
|
2773
2812
|
WrappedError,
|
|
2813
|
+
NotAllowed,
|
|
2814
|
+
DatabaseError,
|
|
2774
2815
|
// TODO: [🪑]> VersionMismatchError,
|
|
2775
2816
|
};
|
|
2776
2817
|
/**
|
|
@@ -2823,7 +2864,7 @@ function deserializeError(error) {
|
|
|
2823
2864
|
message = `${name}: ${message}`;
|
|
2824
2865
|
}
|
|
2825
2866
|
if (stack !== undefined && stack !== '') {
|
|
2826
|
-
message = spaceTrim((block) => `
|
|
2867
|
+
message = spaceTrim$2((block) => `
|
|
2827
2868
|
${block(message)}
|
|
2828
2869
|
|
|
2829
2870
|
Original stack trace:
|
|
@@ -2880,7 +2921,7 @@ async function createRemoteClient(options) {
|
|
|
2880
2921
|
const remoteServerUrlParsed = new URL(remoteServerUrl);
|
|
2881
2922
|
if (remoteServerUrlParsed.pathname !== '/' && remoteServerUrlParsed.pathname !== '') {
|
|
2882
2923
|
remoteServerUrlParsed.pathname = '/';
|
|
2883
|
-
throw new Error(spaceTrim((block) => `
|
|
2924
|
+
throw new Error(spaceTrim$2((block) => `
|
|
2884
2925
|
Remote server requires root url \`/\`
|
|
2885
2926
|
|
|
2886
2927
|
You have provided \`remoteServerUrl\`:
|